1import{r as v,j as e,cf as Oa,y as Jt,co as Ia,b0 as _a,br as Ba,be as Ha,cp as Ra,cq as za,w as Va,cr as Fe,cs as Le,$ as gt,a2 as Xt,bn as ea,as as Wa,v as Ka,aV as ot,ct as Ga,f as bt,u as Qa,c as ta,cu as Ua,cv as Za,aj as Ya,E as Ja,cw as Xa,cx as Bt,z as he,e as ee,i as es,aP as ts,a0 as at,q as st,aL as as,K as aa,ao as ss,a6 as ns,b8 as os,b9 as rs,B as is,bO as ht,cy as ls,cz as ds,cA as cs,cB as ps,cC as Ht,bw as us,b1 as ms,aZ as sa,cD as xs,cE as hs,cF as Rt,aw as na,T as Pe,s as oa,a9 as ra,aa as ge,an as gs}from"./app-BEDoDvHI.js";import{u as ia}from"./useIsLight-DXoUQrp0.js";import{M as zt}from"./Modal-C9KyQKWz.js";import{buildXlsx as bs,XLSX_MIME as fs}from"./xlsxStyled-DNRGQs3m.js";import{r as vs}from"./locale-BJ7r9eqn.js";import{N as je,A as nt,a as Vt,T as Ye,i as ys,u as js,e as Ee,g as mt,b as Ns,o as ws,t as ks,p as Je,c as Wt,R as Kt,M as Ke,d as Gt,f as Te,C as Cs,h as Es,B as Ss,j as Ts,v as Ps}from"./ContatosDoFluxo-CNKONY8J.js";import{T as As}from"./TemplatePreview-D2yU3xgs.js";import"./useTplPreviewMedia-DjoTBYPq.js";function qs(n){if(!n)return"";try{const o=String(n).split("?")[0].split("#")[0];return decodeURIComponent(o.split("/").pop()||"")}catch{return String(n).split("/").pop()||""}}function Ms(n=""){const o=String(n).match(/\.([a-z0-9]{2,5})$/i);return o?o[1].toUpperCase():""}const Ds=[7,12,9,16,11,6,14,10,17,8,13,9,15,7,11,14,8,12,6,10,16,9,13,7],Qt={empty:{pt:"Nenhuma mÃdia selecionada",en:"No media selected",es:"Ninguna media seleccionada"},emptyHint:{pt:"Cole uma URL ou envie um arquivo abaixo.",en:"Paste a URL or upload a file below.",es:"Pega una URL o sube un archivo abajo."},failed:{pt:"Não foi possÃvel carregar a mÃdia",en:"Couldn't load the media",es:"No se pudo cargar la media"},imageAlt:{pt:"Prévia da imagem",en:"Image preview",es:"Vista previa de la imagen"},video:{pt:"VÃdeo",en:"Video",es:"Video"},voice:{pt:"Mensagem de voz",en:"Voice message",es:"Mensaje de voz"},audio:{pt:"Ãudio",en:"Audio",es:"Audio"},document:{pt:"documento",en:"document",es:"documento"},file:{pt:"ARQUIVO",en:"FILE",es:"ARCHIVO"},media:{pt:"mÃdia",en:"media",es:"media"}};function la({mediaType:n="image",url:o,caption:a,fileName:s,ptt:r,compact:p=!1,locale:j="pt"}){const i=m=>{var b,w;return((b=Qt[m])==null?void 0:b[j])||((w=Qt[m])==null?void 0:w.pt)||""},[g,u]=v.useState(!1);v.useEffect(()=>{u(!1)},[o]);const l=n||"image",d=s||qs(o),x=p?"h-[104px]":"h-[180px]";return o?g&&(l==="image"||l==="video"||l==="sticker")?e.jsx(Se,{caption:a,compact:p,children:e.jsxs("div",{className:`${x} rounded-lg bg-white/[0.03] border border-white/10 flex flex-col items-center justify-center gap-1.5 px-3 text-center`,children:[e.jsx(Jt,{className:"text-gray-400",size:16}),e.jsx("span",{className:"text-[12px] text-gray-300",children:i("failed")}),e.jsx("span",{className:"text-[11px] text-gray-500 truncate max-w-full",children:d})]})}):l==="image"?e.jsx(Se,{caption:a,compact:p,children:e.jsx("img",{src:o,alt:a||i("imageAlt"),onError:()=>u(!0),className:`w-full ${x} object-cover rounded-lg bg-black/20 border border-white/[0.08]`})}):l==="sticker"?e.jsx(Se,{caption:null,compact:p,children:e.jsx("div",{className:`${p?"w-[88px] h-[88px]":"w-[120px] h-[120px]"} rounded-lg p-1.5`,style:{backgroundImage:"linear-gradient(45deg,rgba(127,127,127,.14) 25%,transparent 25%,transparent 75%,rgba(127,127,127,.14) 75%),linear-gradient(45deg,rgba(127,127,127,.14) 25%,transparent 25%,transparent 75%,rgba(127,127,127,.14) 75%)",backgroundSize:"12px 12px",backgroundPosition:"0 0,6px 6px"},children:e.jsx("img",{src:o,alt:"Sticker",onError:()=>u(!0),className:"w-full h-full object-contain"})})}):l==="video"?e.jsx(Se,{caption:a,compact:p,children:e.jsxs("div",{className:`relative w-full ${x} rounded-lg overflow-hidden bg-black border border-white/[0.08]`,children:[e.jsx("video",{src:o,preload:"metadata",muted:!0,playsInline:!0,onError:()=>u(!0),className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-black/25",children:e.jsx("div",{className:`${p?"w-9 h-9":"w-12 h-12"} rounded-full bg-black/60 backdrop-blur-sm flex items-center justify-center`,children:e.jsx("svg",{width:p?13:17,height:p?13:17,viewBox:"0 0 24 24",fill:"#fff",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})}),e.jsxs("span",{className:"absolute left-1.5 bottom-1.5 inline-flex items-center gap-1 px-1.5 py-0.5 rounded bg-black/60 text-white text-[10px] font-medium",children:[e.jsx(Ia,{size:10})," ",i("video")]})]})}):l==="audio"?e.jsxs(Se,{caption:null,compact:p,children:[e.jsxs("div",{className:"rounded-lg border border-white/[0.08] bg-white/[0.03] px-2.5 py-2 flex items-center gap-2.5",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-indigo-500/15 text-indigo-300 flex items-center justify-center flex-shrink-0",children:r!==!1?e.jsx(_a,{size:15}):e.jsx("svg",{width:"13",height:"13",viewBox:"0 0 24 24",fill:"
1currentColor",children:e.jsx("path",{d:"M8 5v14l11-7z"})})}),e.jsx("div",{className:"flex items-end gap-[2px] flex-1 min-w-0 h-6 overflow-hidden",children:Ds.slice(0,p?16:24).map((m,b)=>e.jsx("span",{className:"w-[2px] rounded-full bg-gray-400/60",style:{height:`${m}px`}},b))}),e.jsx("span",{className:"text-[11px] text-gray-400 tabular-nums flex-shrink-0",children:"0:00"})]}),e.jsx("div",{className:"text-[11px] text-gray-500 mt-1",children:i(r!==!1?"voice":"audio")})]}):l==="document"?e.jsx(Se,{caption:a,compact:p,children:e.jsxs("div",{className:"rounded-lg border border-white/[0.08] bg-white/[0.03] px-2.5 py-2.5 flex items-center gap-2.5",children:[e.jsx("div",{className:"w-9 h-9 rounded-lg bg-indigo-500/15 text-indigo-300 flex items-center justify-center flex-shrink-0",children:e.jsx(Ba,{size:17})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("div",{className:"text-[12.5px] text-gray-100 font-medium truncate",children:d||i("document")}),e.jsx("div",{className:"text-[11px] text-gray-400 mt-0.5",children:Ms(d)||i("file")})]})]})}):e.jsx(Se,{caption:a,compact:p,children:e.jsxs("div",{className:"rounded-lg border border-white/[0.08] bg-white/[0.03] px-2.5 py-2.5 flex items-center gap-2 text-[12px] text-gray-300",children:[e.jsx(Ha,{size:14,className:"text-gray-400"})," ",d||i("media")]})}):e.jsxs("div",{className:`rounded-lg border border-dashed border-white/[0.16] bg-white/[0.02] ${p?"py-4":"py-7"} px-3 flex flex-col items-center justify-center gap-1.5 text-center`,children:[e.jsx(Oa,{className:"text-gray-400",size:p?16:20}),e.jsx("span",{className:"text-[12px] text-gray-400",children:i("empty")}),!p&&e.jsx("span",{className:"text-[11.5px] text-gray-500",children:i("emptyHint")})]})}function Se({children:n,caption:o,compact:a}){return e.jsxs("div",{className:"space-y-1.5",children:[n,o?e.jsx("p",{className:`${a?"text-[12px] line-clamp-2":"text-[13px]"} text-gray-300 leading-snug whitespace-pre-wrap break-words`,children:o}):null]})}const Ie="#00a884";function Oe({id:n,colors:o,color:a}){return e.jsx(Fe,{id:n,type:"source",position:Le.Right,style:{right:-19,top:"50%",transform:"translateY(-50%)"},className:`!w-2.5 !h-2.5 !border-2 !border-dark-900 ${a||(o==null?void 0:o.handle)||""}`})}const Ut=new Set(["input","condition","webhook","ai"]);function ft(n){return n==null?"":n<1e3?String(n):n<1e6?(n/1e3).toFixed(n<1e4?1:0).replace(".",",").replace(",0","")+"K":(n/1e6).toFixed(1).replace(".",",").replace(",0","")+"M"}function ye(n,o,a){return`${ft(n)} ${n===1?o:a}`}function $s({metrics:n,nodeType:o}){if(!n)return null;const a=(n.failed||0)+(n.timeouts||0),s=n.unique_people!=null,r=n.unique_people||0,p=n.executions||0,j=s?o==="trigger"?ye(r,"pessoa entrou","pessoas entraram"):o==="message"||o==="media"?ye(r,"pessoa viu","pessoas viram"):o==="buttons"||o==="list"||o==="choice"?ye(r,"pessoa","pessoas"):o==="input"?ye(r,"pessoa respondeu","pessoas responderam"):o==="delay"?ye(r,"pessoa esperou","pessoas esperaram"):o==="end"?ye(r,"pessoa finalizou","pessoas finalizaram"):ye(r,"pessoa","pessoas"):ye(p,"acionamento","acionamentos"),i=[s?`${r} ${r===1?"pessoa única":"pessoas únicas"}`:null,`${p} ${p===1?"acionamento total":"acionamentos totais"}`,n.unique_sessions!=null&&n.unique_sessions!==r?`${n.unique_sessions} ${n.unique_sessions===1?"conversa":"conversas"}`:null,n.resumes>0?`${n.resumes} respostas recebidas`:null,n.avg_ms>50?`Tempo médio: ${n.avg_ms}ms`:null,a>0?`${n.failed} falhas, ${n.timeouts} timeouts`:null].filter(Boolean).join(` 2`),g=r>0||p>0?"bg-emerald-500/15 text-emerald-300 border-emerald-500/25":"bg-white/[0.05] text-gray-400 border-white/[0.08]";return e.jsxs("div",{className:"flex items-center gap-1",title:i,children:[e.jsxs("span",{className:`inline-flex items-center gap-1 text-[11px] font-semibold px-1.5 py-0.5 rounded-full border ${g}`,children:[e.jsx(gt,{size:9}),e.jsx("span",{className:"tabular-nums",children:j})]}),a>0&&e.jsxs("span",{className:"inline-flex items-center gap-0.5 text-[11px] font-semibold px-1.5 py-0.5 rounded-full bg-rose-500/12 text-rose-300 border border-rose-500/25 tabular-nums",title:`${n.failed} falhas + ${n.timeouts} timeouts`,children:[e.jsx(Xt,{size:9}),ft(a)]})]})}function Ge({count:n,totalForGroup:o,accentClass:a}){const s=n||0,r=o>0?Math.round(s/o*100):0,p=r>=50,j=p?"bg-gradient-to-r from-emerald-400/70 to-emerald-500/70":`${a||"bg-indigo-400/40"}`;return e.jsxs("div",{className:"flex items-center gap-1.5 mt-1",children:[e.jsx("div",{className:"flex-1 h-1 rounded-full bg-dark-800 overflow-hidden",children:e.jsx("div",{className:`h-full rounded-full transition-all ${j}`,style:{width:`${r}%`}})}),e.jsxs("span",{className:`text-[11px] font-bold tabular-nums w-9 text-right ${p?"text-emerald-300":"text-gray-400"}`,children:[r,"%"]}),e.jsx("span",{className:"text-[10px] text-gray-400 tabular-nums w-7 text-right",title:`${s} ${s===1?"clique":"cliques"}`,children:ft(s)})]})}function Xe({branches:n,branchClicks:o}){const a={success:{dot:"bg-emerald-400",text:"text-emerald-300/90",tag:"text-emerald-500/40",handle:"!bg-emerald-400",bar:"bg-emerald-400/40"},danger:{dot:"bg-rose-400",text:"text-rose-300/90",tag:"text-rose-500/40",handle:"!bg-rose-400",bar:"bg-rose-400/40"}
2,warning:{dot:"bg-sky-400",text:"text-sky-300/90",tag:"text-sky-500/40",handle:"!bg-sky-400",bar:"bg-sky-400/40"}},s=o?Object.values(o).reduce((r,p)=>r+(p||0),0):0;return e.jsx("div",{className:"space-y-1 mt-1.5 pt-1.5 border-t border-white/[0.07]",children:n.map(r=>{const p=a[r.tone]||a.success,j=(r.id||"").match(/^out-(\d+)$/),i=j?parseInt(j[1],10):null,g=o&&i!=null?o[i]:null;return e.jsxs("div",{className:"relative px-1",children:[e.jsxs("div",{className:"flex items-center gap-2 py-0.5",children:[e.jsx("span",{className:`w-1 h-1 rounded-full ${p.dot} flex-shrink-0`}),e.jsx("span",{className:`text-[12px] ${p.text} truncate flex-1`,children:r.label}),e.jsx(Oe,{id:r.id,color:p.handle})]}),o&&e.jsx(Ge,{count:g,totalForGroup:s,accentClass:p.bar})]},r.id)})})}const _e={aguardando:{pt:"aguardando",en:"waiting",es:"esperando"},chegaram:{pt:"chegaram",en:"reached",es:"llegaron"},entraram:{pt:"entraram",en:"entered",es:"entraron"},kanban:{pt:"Kanban",en:"Kanban",es:"Kanban"},faseHint:{pt:"Fase: quando o contato chega neste bloco, o card vai para",en:"Phase: when the contact reaches this block, the card goes to",es:"Fase: cuando el contacto llega a este bloque, la tarjeta va a"}};function Fs({cf:n,locale:o,onAbrir:a}){const s=r=>r[o]||r.pt;return n.aqui?e.jsx("div",{className:"cf-onde sem-clique nodrag nopan",onClick:r=>r.stopPropagation(),children:e.jsxs("span",{className:`cf-pill ${n.aqui.ativo?"":"fim"}`,children:[e.jsx(Vt,{nome:n.aqui.nome,foto:n.aqui.avatar,tam:22}),e.jsx("b",{children:String(n.aqui.nome||"").split(" ")[0]})," ",n.aqui.texto]})}):!n.aguardando&&!n.passaram?null:e.jsxs("div",{className:`cf-onde nodrag nopan ${a?"":"sem-clique"}`,onClick:a?r=>{r.stopPropagation(),a()}:void 0,onKeyDown:a?r=>{(r.key==="Enter"||r.key===" ")&&(r.preventDefault(),r.stopPropagation(),a())}:void 0,role:a?"button":void 0,tabIndex:a?0:void 0,children:[n.aguardando>0&&e.jsx("span",{className:"cf-linha",children:e.jsxs("span",{className:"cf-pill",children:[e.jsx("span",{className:"cf-stack",children:(n.avatares||[]).map((r,p)=>e.jsx(Vt,{nome:r.nome,foto:r.avatar,tam:22},p))}),n.aguardando," ",s(_e.aguardando)]})}),n.passaram>0&&e.jsx("span",{className:"cf-linha",children:e.jsxs("span",{className:"cf-passou",children:[e.jsx(gt,{size:10})," ",n.passaram," ",s(n.inicio?_e.entraram:_e.chegaram)]})})]})}function Ls({id:n,data:o,selected:a}){var m,b,w,F;const s=je[o.type],r=Ra(),p=D=>{D.stopPropagation(),o.onDelete&&o.onDelete(n)},j=Os(o);if(v.useEffect(()=>{n&&r(n)},[n,r,j.length]),!s)return null;const i=s.icon,g=nt[s.accent]||nt.indigo,u=o.type==="template_entry",l=o.locale||"pt",d=(s.label[l]||s.label.pt)+(o.type==="trigger"&&o.gatilhoTotal>1?` ${o.gatilhoOrdem}`:""),x=s.outputs==="dynamic"?0:s.outputs;return e.jsxs("div",{className:`group relative rounded-2xl border ${u?"w-[300px]":"w-[250px]"} transition-all bg-dark-800 ${u?"":a?"border-indigo-500/50":"border-white/10 hover:border-white/[0.16]"} ${a?"shadow-xl ring-2 ring-indigo-500/35":"shadow-[0_12px_30px_-16px_rgba(0,0,0,0.9)]"}${(m=o.cf)!=null&&m.estado?` cf-estado-${o.cf.estado}`:""}`,style:u?{borderColor:a?Ie:"rgba(0,168,132,0.5)",boxShadow:a?"0 0 0 3px rgba(0,168,132,0.18), 0 16px 40px rgba(0,168,132,0.22)":"0 0 0 1px rgba(0,168,132,0.15), 0 8px 24px rgba(0,0,0,0.35)"}:void 0,children:[o.cf&&e.jsx(Fs,{cf:o.cf,locale:l,onAbrir:o.onCfBloco?()=>o.onCfBloco(n):null}),((b=o.cf)==null?void 0:b.passo)&&e.jsx("span",{className:"cf-passo",children:o.cf.passo.slice(0,3).join(" · ")}),o.fase&&e.jsxs("div",{className:"cf-fase nodrag nopan",title:`${_e.faseHint[l]||_e.faseHint.pt} ${o.fase.coluna}`,role:o.onFase?"button":void 0,tabIndex:o.onFase?0:void 0,onClick:o.onFase?D=>{D.stopPropagation(),o.onFase(n)}:void 0,onKeyDown:o.onFase?D=>{(D.key==="Enter"||D.key===" ")&&(D.preventDefault(),D.stopPropagation(),o.onFase(n))}:void 0,children:[e.jsx(za,{size:11}),e.jsx("span",{children:_e.kanban[l]||"Kanban"}),e.jsx(Va,{size:10}),e.jsx("b",{children:o.fase.coluna})]}),o.type!=="template_entry"&&(o.type!=="trigger"||o.gatilhoTotal>1)&&e.jsxs("button",{onMouseDown:D=>D.stopPropagation(),onClick:p,className:"nodrag group/del absolute -top-2.5 -right-2.5 z-20 hidden group-hover:flex items-center justify-center",title:"Remover node (Delete)",style:{animation:"edgeBtnIn 160ms cubic-bezier(0.34, 1.56, 0.64, 1)"},children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-rose-500/25 blur-md scale-150 opacity-0 group-hover/del:opacity-100 transition-opacity"}),e.jsx("span",{className:"relative w-6 h-6 rounded-full bg-dark-900/95 backdrop-blur border border-white/[0.12] group-hover/del:border-rose-400/70 group-hover/del:bg-rose-500/95 flex items-center justify-center shadow-[0_4px_12px_rgba(0,0,0,0.5)] transition-all duration-150 group-hover/del:scale-110",children:e.jsxs("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",className:"text-gray-400 group-hover/del:text-white transition-colors",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),e.jsxs("div",{className:`px-3 pt-3 pb-2 flex items-center gap-2.5 ${u?"rounded-t-[15px] border-b":""}`,style:u?{borderColor:"rgba(0,168,132,0.28)",background:"linear-gradient(180deg, rgba(0,168,132,0.16), rgba(0,168,132,0.05))"}:void 0,children:[e.jsx("div",{className:`w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 ${u?"":`${g.bg} ${g.text}`}`,style:u?{background:"rgba(0,168,132,0.22)",color:Ie}:void 0,children:e.jsx(i,{size:16})}),e.jsx("span",{className:`text-[13.5px] font-semibold tracking-tight flex-1 truncate ${u?"":"text-gray-100"}`,style:u?{color:Ie}:void 0,children:d}),e.jsx($s,{metrics:o.metrics,nodeType:o.type})]}),e.jsx("div",{className:"px-3 py-2.5 space-y-2 min-h-[40px]",children:Is(o,s,g,j)}),((w=o.config)==null?void 0:w.note)&&e.jsx("div",{className:"px-3 pb-2",children:e.jsx("div",{className:"text-[11px] text-gray-400 italic leading-snug line-clamp-2 border-l-2 border-white/10 pl-2",children:o.config.note})}),((F=o.config)==null?void 0:F.label)&&e.jsx("div",{className:"px-3 pb-2",children:e.jsxs("div",{className:"text-[11px] text-gray-400 font-mono",children:["#",o.config.label]})}),s.inputs>0&&e.jsx(Fe,{type:"target",position:Le.Left,className:`!w-2.5 !h-2.5 !border-2 !border-dark-900 ${g.handle}`}),s.outputs!==0&&s.outputs!=="dynamic"&&x===1&&e.jsx(Fe,{type:"source",position:Le.Right,className:`!w-2.5 !h-2.5 !border-2 !border-dark-900 ${g.handle}`}),x===2&&!Ut.has(o.type)&&Array.from({length:2}).map((D,S)=>e.jsx(Fe,{id:`out-${S}
2`,type:"source",position:Le.Right,style:{top:`${(S+1)/3*100}%`},className:`!w-3 !h-3 !border-2 !border-dark-900 ${S===0?"!bg-emerald-400":"!bg-rose-400"}`,title:S===0?"out-0 â sucesso / válido":"out-1 â erro / inválido / timeout"},S)),x>2&&!Ut.has(o.type)&&Array.from({length:x}).map((D,S)=>e.jsx(Fe,{id:`out-${S}`,type:"source",position:Le.Right,style:{top:`${(S+1)/(x+1)*100}%`},className:`!w-2.5 !h-2.5 !border-2 !border-dark-900 ${g.handle}`},S)),s.outputs==="dynamic"&&j.length===0&&e.jsx(Fe,{type:"source",position:Le.Right,className:`!w-2.5 !h-2.5 !border-2 !border-dark-900 ${g.handle}`})]})}function Os(n){const o=n.config||{};if(n.type==="buttons")return(o.buttons||[]).map((a,s)=>({label:a,idx:s}));if(n.type==="template_entry")return(o.buttons||[]).map((a,s)=>({label:typeof a=="string"?a:(a==null?void 0:a.text)||(a==null?void 0:a.label)||"",idx:s}));if(n.type==="choice")return(o.options||[]).map((a,s)=>({label:a,idx:s}));if(n.type==="list"){const a=[];let s=0;for(const r of o.sections||[])for(const p of r.rows||[]){const j=typeof p=="string"?p:(p==null?void 0:p.title)||"";a.push({label:j,idx:s++,sectionTitle:r.title})}return a}if(n.type==="random"){const a=(o.paths||[]).map(r=>typeof r=="string"?{label:r}:r),s=a.length>0?Math.round(100/a.length):0;return a.map((r,p)=>({label:r.label||`Caminho ${String.fromCharCode(65+p)}`,weight:typeof r.weight=="number"?r.weight:s,idx:p}))}return[]}const et={anuncio:{pt:"escolha ao menos um anúncio",en:"pick at least one ad",es:"elige al menos un anuncio"},keyword:{pt:"digite ao menos uma palavra",en:"type at least one word",es:"escribe al menos una palabra"}};function Is(n,o,a,s){var p,j,i,g;const r=n.config||{};if(n.type==="trigger"){const u=r.keywords||[],l=n.locale||"pt",d=r.triggerType||"keyword",x={keyword:"ð¤",webhook:"ð",first_message:"ð¬",anuncio:"ð£"};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-[12px] text-gray-400",children:[x[d]||"ð¤"," ",(Ye[d]||Ye.keyword)[l]||(Ye[d]||Ye.keyword).pt]}),r.triggerType==="anuncio"?e.jsxs("div",{className:"flex flex-wrap gap-1",children:[(r.adSourceIds||[]).slice(0,3).map((m,b)=>e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded ${a.bg} ${a.text} max-w-[210px] truncate`,title:m,children:r.adTitulos&&r.adTitulos[m]||m},b)),(r.adSourceIds||[]).length>3&&e.jsxs("span",{className:"text-[11px] text-gray-400",children:["+",r.adSourceIds.length-3]}),!ys(r).length&&e.jsx("span",{className:"text-[11px] text-rose-300",children:et.anuncio[l]||et.anuncio.pt})]}):d==="keyword"?e.jsxs("div",{className:"flex flex-wrap gap-1",children:[u.slice(0,4).map((m,b)=>e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded ${a.bg} ${a.text} font-mono`,children:m},b)),u.length>4&&e.jsxs("span",{className:"text-[11px] text-gray-400",children:["+",u.length-4]}),!u.some(m=>String(m??"").trim())&&e.jsx("span",{className:"text-[11px] text-rose-300",children:et.keyword[l]||et.keyword.pt})]}):null]})}if(n.type==="template_entry"){const u=Array.isArray(r.components)?r.components:[],l=u.filter(w=>String(w.type).toUpperCase()!=="BUTTONS"),d=((p=u.find(w=>String(w.type).toUpperCase()==="BUTTONS"))==null?void 0:p.buttons)||[],x=d.filter(w=>String(w.type).toUpperCase()==="QUICK_REPLY").length;let m=-1;const b={"--text":"#e8eef0","--text-2":"#c7d2d6","--text-4":"#7c8a90","--indigo":Ie,"--hairline":"rgba(255,255,255,0.08)"};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 -mt-0.5 mb-1",children:[e.jsx("span",{className:"text-[10px] font-bold uppercase tracking-wider px-1.5 py-0.5 rounded",style:{background:"rgba(0,168,132,0.16)",color:Ie,border:"1px solid rgba(0,168,132,0.35)"},children:"Template aprovado"}),e.jsx("span",{className:"text-[11px] text-gray-400 font-mono truncate flex-1",children:r.templateName||"â"})]}),e.jsx("div",{className:"rounded-xl p-2.5",style:{...b,background:"linear-gradient(180deg,#0b1a17,#0a1512)",border:"1px solid rgba(0,168,132,0.18)"},children:e.jsx(As,{components:l,compact:!0,locale:n.locale||"pt"})}),d.length>0&&e.jsx("div",{className:"space-y-1 pt-0.5",children:d.map((w,F)=>{const D=String(w.type||"").toUpperCase();if(D==="QUICK_REPLY"){m+=1;const B=m;return e.jsxs("div",{className:"relative rounded-lg px-2.5 py-2 flex items-center gap-2",style:{background:"rgba(0,168,132,0.12)",border:"1px solid rgba(0,168,132,0.4)"},children:[e.jsx(ea,{size:12,className:"shrink-0",style:{color:Ie}}),e.jsx("span",{className:"text-[13px] font-semibold truncate flex-1",style:{color:"#7fe8cf"},children:w.text||`Botão ${B+1}`}),e.jsxs("span",{className:"text-[10px] font-mono shrink-0",style:{color:"rgba(0,168,132,0.75)"},children:["saÃda #",B]}),e.jsx(Oe,{id:`out-${B}`,color:"!bg-teal-400"})]},F)}const S=D==="URL"?Wa:D==="PHONE_NUMBER"?Ka:null;return e.jsxs("div",{className:"rounded-lg px-2.5 py-2 flex items-center gap-2 opacity-55",style:{background:"rgba(255,255,255,0.03)",border:"1px solid rgba(255,255,255,0.08)"},children:[S?e.jsx(S,{size:11,className:"shrink-0 text-gray-400"}):e.jsx("span",{className:"text-[12px] shrink-0",children:"ð"}),e.jsx("span",{className:"text-[12px] text-gray-400 truncate flex-1",children:w.text}),e.jsx("span",{className:"text-[9px] text-gray-500 uppercase font-mono",children:D==="URL"?"link":D==="PHONE_NUMBER"?"ligar":"copiar"})]},F)})}),x===0&&e.jsx("div",{className:"text-[11px] text-gray-400 italic",children:"Template sem botões de resposta rápida"})]})}if(n.type==="message")return e.jsx("p",{className:"text-[13px] text-gray-200 leading-snug line-clamp-3",children:r.text||"(vazio)"});if(n.type==="media")return e.jsx(la,{mediaType:r.mediaType,url:r.url,caption:r.caption,fileName:r.fileName,ptt:r.ptt,locale:n.locale||"pt",compact:!0});if(n.type==="buttons"){const u=r.headerType==="image"?{icon:"ð¼ï¸",label:"Imagem",tone:"bg-indigo-500/10 text-indigo-300 border-indigo-500/30"}:r.headerType==="video"?{icon:"ð¥",label:"VÃdeo",tone:"bg-violet-500/10 text-violet-300 border-violet-500/30"}:r.headerType==="document"?{icon:"ð",label:r.headerFileName||"Documento",tone:"bg-blue-500/10 text-blue-300 border-blue-500/30"}:r.headerType==="location"?{icon:"ð",label:r.headerName||"Localização",tone:"bg-emerald-500/10 text-emerald-300 border-emerald-500/30"}:null,l=r.headerType==="image"||r.headerType==="video"?r.headerUrl:null;return e.jsxs(e.Fragment,{children:[u&&e.jsxs("div",{className:`text-[12px] px-2 py-1 rounded border flex items-center gap-1.5 ${u.tone}`,children:[e.jsx("span",{className:"text-sm",children:u.icon}),e.jsx("span",{className:"font-semibold truncate flex-1",children:u.label}),r.headerType==="location"&&r.headerLat!=null&&e.jsxs("span",{className:"text-[11px] font-mono opacity-70",children:[Number(r.headerLat).toFixed(2),", ",Number(r.headerLon).toFixed(2)]})]}),l&&r.headerType==="image"&&e.jsx("img",{src:l,alt:"",className:"w-full h-20 object-cover rounded border border-white/[0.08]",onError:d=>{d.target.style.display="none"}}),l&&r.headerType==="video"&&e.jsxs("div",{className:"relative w-full h-20 bg-black rounded border border-white/[0.08] overflow-hidden flex items-center justify-center",children:[e.jsx("video",{src:l,preload:"metadata",muted:!0,className:"w-full h-full object-cover"}),e.jsx("div",{className:"absolute inset-0 bg-black/30 flex items-center justify-center",children:e.jsx("div",{className:"w-7 h-7 rounded-full bg-black/70 flex items-center justify-center",children:e.jsx("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"white",children:e.jsx("path",{d:"M8 5v14l11-7z"})})})})]}),r.text&&e.jsx("p",{className:"text-[13px] text-gray-200 leading-snug line-clamp-2",children:r.text}),s.length===0&&e.jsx("div",{className:"text-[12px] text-gray-400 italic",children:"Sem botões â adicione no painel"}),e.jsx("div",{className:"space-y-1",children:s.map(d=>{var x,m;return e.jsxs("div",{className:`relative px-2 py-1.5 rounded border ${a.border} ${a.bg}`,children:[e.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[e.jsxs("span",{className:`flex items-center gap-1.5 truncate ${a.text}`,children:[e.jsx(ot,{size:9}),e.jsx("span",{className:"truncate",children:d.label||`Botão ${d.idx+1}`})]}),!n.metricsBranches&&e.jsxs("span",{className:"text-[10px] text-gray-400 font-mono ml-1",children:["â #",d.idx]})]}),n.metricsBranches&&e.jsx(Ge,{count:(x=n.metricsBranches.byIdx)==null?void 0:x[d.idx],totalForGroup:n.metricsBranches.totalForGroup,accentClass:(m=a.handle)==null?void 0:m.replace("!","")}),e.jsx(Oe,{id:`out-${d.idx}`,colors:a})]},d.idx)})}),r.footer&&e.jsx("p",{className:"text-[11px] text-gray-400 italic line-clamp-1 pt-0.5",children:r.footer})]})}if(n.type==="list"){let u=null;return e.jsxs(e.Fragment,{children:[r.text&&e.jsx("p",{className:"text-[12px] text-gray-300 line-clamp-1",children:r.text}),e.jsxs("div",{className:`text-[12px] px-2 py-1 rounded ${a.bg} ${a.text} text-center font-medium`,children:["ð ",r.buttonText||"Ver opções"]}),s.length===0&&e.jsx("div",{className:"text-[12px] text-gray-400 italic",children:"Sem opções â adicione no painel"}),e.jsx("div",{className:"space-y-0.5",children:s.map(l=>{var x,m;const d=l.sectionTitle&&l.sectionTitle!==u;return u=l.sectionTitle||u,e.jsxs("div",{children:[d&&e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-gray-400 px-1 pt-1 pb-0.5",children:l.sectionTitle}),e.jsxs("div",{className:`relative px-2 py-1 rounded border ${a.border} bg-dark-800/40`,children:[e.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[e.jsxs("span",{className:"text-gray-300 truncate",children:["⢠",l.label]}),!n.metricsBranches&&e.jsxs("span",{className:"text-[10px] text-gray-400 font-mono ml-1",children:["â #",l.idx]})]}),n.metricsBranches&&e.jsx(Ge,{count:(x=n.metricsBranches.byIdx)==null?void 0:x[l.idx],totalForGroup:n.metricsBranches.totalForGroup,accentClass:(m=a.handle)==null?void 0:m.replace("!","")}),e.jsx(Oe,{id:`out-${l.idx}`,colors:a})]})]},l.idx)})}),r.footer&&e.jsx("p",{className:"text-[11px] text-gray-400 italic line-clamp-1",children:r.footer})]})}if(n.type==="template"){if(!r.templateId)return e.jsx("div",{className:"text-[12px] text-gray-400 italic px-2 py-2 text-center border border-dashed border-white/10 rounded",children:"Selecione um template no painel"});const u=l=>!l||l<1e3?null:l<6e4?`${Math.round(l/1e3)}s`:l<36e5?`${Math.round(l/6e4)}min`:`${(l/36e5).toFixed(1)}h`;return e.jsxs("div",{className:`px-2 py-2 rounded ${a.bg} border ${a.border}`,children:[e.jsxs("div",{className:`text-[11px] font-bold uppercase tracking-wider ${a.text} mb-1 flex items-center gap-1`,children:["ð Template ",e.jsxs("span",{className:"text-gray-400 font-mono",children:["#",r.templateId]})]}),e.jsx("div",{className:"text-[12px] text-gray-100 font-medium truncate",children:r.templateName||"(template removido?)"}),(r.templateStepCount||r.templateTotalDelayMs)&&e.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-gray-400 mt-1",children:[r.templateStepCount>0&&e.jsxs("span",{children:[r.templateStepCount," step",r.templateStepCount===1?"":"s"]}),u(r.templateTotalDelayMs)&&e.jsxs("span",{children:["· â± ",u(r.templateTotalDelayMs)]})]})]})}if(n.type==="input"){const u=r.validate||"text",l={text:"âï¸ texto livre",email:"âï¸ e-mail",phone:"ð telefone",number:"ð¢ número",cpf:"ð CPF",date:"ð
data"},d={text:"Timeout",email:"Não é e-mail",phone:"Não é telefone",number:"Não é número",cpf:"CPF inválido",date:"Data inválida"};return e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[13px] text-gray-200 leading-snug line-clamp-2",children:r.question||"(pergunta vazia)"}),e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[e.jsx("span",{className:"text-gray-400",children:"â"}),e.jsx("span",{className:`px-1.5 py-0.5 rounded font-mono ${a.bg} ${a.text}`,children:`{{${r.variable||"var"}}
2}`}),e.jsx("span",{className:`text-[11px] px-1.5 py-0.5 rounded ${u==="text"?"bg-white/[0.05] text-gray-400":"bg-cyan-500/15 text-cyan-300"}`,children:l[u]||u})]}),e.jsx(Xe,{branches:u==="text"?[{id:"out-0",tone:"success",label:"Qualquer resposta"},{id:"out-2",tone:"warning",label:"Timeout"}]:[{id:"out-0",tone:"success",label:`${((j=l[u])==null?void 0:j.split(" ")[1])||u} válido`},{id:"out-1",tone:"danger",label:d[u]||"Inválido"},{id:"out-2",tone:"warning",label:"Timeout"}],branchClicks:(i=n.metricsBranches)==null?void 0:i.byIdx})]})}if(n.type==="choice")return e.jsxs(e.Fragment,{children:[r.question&&e.jsx("p",{className:"text-[12px] text-gray-300 line-clamp-2",children:r.question.split(` 3`)[0]}),s.length===0&&e.jsx("div",{className:"text-[12px] text-gray-400 italic",children:"Sem opções â adicione no painel"}),e.jsx("div",{className:"space-y-1",children:s.map(u=>{var l,d;return e.jsxs("div",{className:`relative px-2 py-1.5 rounded border ${a.border}`,children:[e.jsxs("div",{className:"flex items-center justify-between text-[12px]",children:[e.jsxs("span",{className:"flex items-center gap-1.5 truncate",children:[e.jsx("span",{className:`w-4 h-4 rounded text-[11px] font-bold flex items-center justify-center flex-shrink-0 ${a.bg} ${a.text}`,children:u.idx+1}),e.jsx("span",{className:"truncate",children:u.label})]}),!n.metricsBranches&&e.jsxs("span",{className:"text-[10px] text-gray-400 font-mono ml-1",children:["â #",u.idx]})]}),n.metricsBranches&&e.jsx(Ge,{count:(l=n.metricsBranches.byIdx)==null?void 0:l[u.idx],totalForGroup:n.metricsBranches.totalForGroup,accentClass:(d=a.handle)==null?void 0:d.replace("!","")}),e.jsx(Oe,{id:`out-${u.idx}`,colors:a})]},u.idx)})})]});if(n.type==="condition"){const u={equals:"=",contains:"contém",not_equals:"â ",greater:">",less:"<",regex:"regex"};return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"text-[12px] flex items-center gap-1.5 flex-wrap",children:[e.jsx("span",{className:`px-1.5 py-0.5 rounded font-mono ${a.bg} ${a.text}`,children:`{{${r.variable||"var"}}}`}),e.jsx("span",{className:"text-gray-400",children:u[r.operator]||"="}),e.jsx("span",{className:"px-1.5 py-0.5 rounded bg-dark-800 text-gray-300 font-mono",children:r.value||"?"})]}),e.jsx(Xe,{branches:[{id:"out-0",tone:"success",label:"Verdadeiro"},{id:"out-1",tone:"danger",label:"Falso"}],branchClicks:(g=n.metricsBranches)==null?void 0:g.byIdx})]})}if(n.type==="delay"){const u={seconds:"s",minutes:"min",hours:"h",days:"d"};return e.jsxs("div",{className:"text-center py-1",children:[e.jsxs("div",{className:`text-2xl font-bold ${a.text}`,children:[r.value||5,e.jsx("span",{className:"text-sm",children:u[r.unit]||"min"})]}),e.jsx("div",{className:"text-[12px] text-gray-400 mt-0.5",children:r.mode==="until"?"até hora especÃfica":"tempo fixo"})]})}if(n.type==="random")return e.jsxs("div",{className:"space-y-1",children:[s.length===0&&e.jsx("div",{className:"text-[12px] text-gray-400 italic",children:"Sem paths â adicione no painel"}),s.map(u=>{var l,d;return e.jsxs("div",{className:"relative px-1 py-1 rounded",children:[e.jsxs("div",{className:"flex items-center gap-2 text-[12px]",children:[e.jsxs("div",{className:`w-6 h-6 rounded-full text-[11px] font-bold flex items-center justify-center flex-shrink-0 ${a.bg} ${a.text}`,children:[u.weight,"%"]}),e.jsx("span",{className:"text-gray-300 flex-1 truncate",children:u.label}),!n.metricsBranches&&e.jsxs("span",{className:"text-[10px] text-gray-400 font-mono",children:["#",u.idx]})]}),n.metricsBranches&&e.jsx(Ge,{count:(l=n.metricsBranches.byIdx)==null?void 0:l[u.idx],totalForGroup:n.metricsBranches.totalForGroup,accentClass:(d=a.handle)==null?void 0:d.replace("!","")}),e.jsx(Oe,{id:`out-${u.idx}`,colors:a})]},u.idx)})]});if(n.type==="webhook")return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-[12px]",children:[e.jsx("span",{className:`font-bold uppercase px-1.5 py-0.5 rounded ${a.bg} ${a.text}`,children:r.method}),e.jsx("span",{className:"text-gray-400 truncate flex-1 font-mono text-[11px]",children:r.url?r.url.replace(/^https?:\/\//,""):"(url)"})]}),e.jsxs("div",{className:"text-[12px] text-gray-400",children:["â ",e.jsx("span",{className:`font-mono ${a.text}`,children:`{{${r.saveTo||"response"}}}`})]}),e.jsx(Xe,{branches:[{id:"out-0",tone:"success",label:"Sucesso (2xx)"},{id:"out-1",tone:"danger",label:"Erro / timeout"}]})]});if(n.type==="ai")return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"flex items-center gap-1.5 text-[12px]",children:r.agentId?e.jsx("span",{className:`font-bold px-1.5 py-0.5 rounded ${a.bg} ${a.text}`,children:"Agente"}):r.provider?e.jsxs(e.Fragment,{children:[e.jsx("span",{className:`font-bold px-1.5 py-0.5 rounded ${a.bg} ${a.text}`,children:r.provider}),e.jsx("span",{className:"text-gray-400 truncate flex-1 font-mono text-[11px]",children:r.model})]}):e.jsx("span",{className:"font-bold px-1.5 py-0.5 rounded bg-rose-500/15 text-rose-300",children:"sem agente"})}),e.jsx("div",{className:"text-[12px] text-gray-400",children:r.mode==="reply"?"ð¬ Responder":r.mode==="classify"?"ð·ï¸ Classificar":"ð Extrair"}),r.systemPrompt&&e.jsx("p",{className:"text-[11px] text-gray-400 italic line-clamp-2",children:r.systemPrompt}),e.jsx(Xe,{branches:[{id:"out-0",tone:"success",label:"Resposta gerada"},{id:"out-1",tone:"danger",label:"Erro / sem chave"}]})]});if(n.type==="database")return e.jsxs("div",{className:"text-[12px] space-y-1",children:[e.jsxs("div",{children:["ð ",e.jsxs("span",{className:"font-mono text-gray-300",children:[r.source||"contact",".",r.field||"tags"]})]}),e.jsxs("div",{className:"text-gray-400",children:["â ",e.jsx("span",{className:`font-mono ${a.text}`,children:`{{${r.saveTo||"data"}}}`})]})]});if(n.type==="tag")return e.jsxs("div",{className:"text-[12px] flex items-center gap-2",children:[e.jsx("span",{className:`px-2 py-0.5 rounded font-bold uppercase ${r.action==="add"?"bg-emerald-500/15 text-emerald-300":"bg-rose-500/15 text-rose-300"}`,children:r.action==="add"?"+ Adicionar":"â Remover"}),e.jsx("span",{className:"text-gray-300 truncate",children:r.labelName||"â"})]});if(n.type==="venda"){const u=b=>b[n.locale]||b.pt,l=r.evento||"Purchase",d=u({Purchase:{pt:"Compra",es:"Compra",en:"Purchase"},InitiateCheckout:{pt:"Iniciou a compra",es:"Inició la compra",en:"Initiated checkout"},Lead:{pt:"Lead",es:"Lead",en:"Lead"}}[l]||{pt:"Compra",es:"Compra",en:"Purchase"}),x=String(r.valor||"").trim(),m=l!=="Purchase"?u({pt:"Card fica onde está",es:"La tarjeta queda donde está",en:"Card stays where it is"}):r.esperarConfirmacao?`Card â ${r.colunaEspera||"â"} · ${u({pt:"equipe confirma",es:"el equipo confirma",en:"team confirms"})}`:`Card â ${r.coluna||u({pt:"coluna de conversão",es:"columna de conversión",en:"conversion column"})}`;return e.jsxs("div",{className:"text-[12px] space-y-1",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx("span",{className:"px-2 py-0.5 rounded font-bold uppercase bg-rose-500/15 text-rose-300 shrink-0",children:d}),x&&e.jsxs("span",{className:"text-gray-300 truncate",children:[r.moeda?`${r.moeda} `:"",x]})]}),e.jsxs("div",{className:"text-gray-400 truncate",children:[m,r.avisarMeta!==!1?` · ${u({pt:"avisa o Pixel da Meta",es:"avisa al PÃxel de Meta",en:"notifies the Meta Pixel"})}`:""]})]})}return n.type==="optout"?e.jsxs("div",{className:"text-[12px] flex items-center gap-2",children:[e.jsx("span",{className:"px-2 py-0.5 rounded font-bold uppercase bg-rose-500/15 text-rose-300",children:"Marketing"}),e.jsx("span",{className:"text-gray-400 truncate",children:r.sendConfirmation===!1?"sem confirmação":"confirma ao contato"})]}):n.type==="handoff"?e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"text-[12px] text-gray-300 line-clamp-2",children:r.reason||"Solicitado pelo usuário"}),e.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-gray-400",children:[e.jsx("span",{children:"â¸"}),e.jsxs("span",{children:["Pausa bot ",r.pauseBotHours||24,"h"]})]})]}):n.type==="end"?e.jsx("p",{className:"text-[12px] text-gray-400 text-center py-2",children:"Fim do fluxo"}):null}const da=v.memo(Ls);da.displayName="FlowNode";const t={back:{pt:"Voltar",en:"Back",es:"Volver"},untitled:{pt:"Chatbot sem nome",en:"Untitled chatbot",es:"Chatbot sin nombre"},save:{pt:"Salvar",en:"Save",es:"Guardar"},publish:{pt:"Publicar",en:"Publish",es:"Publicar"},test:{pt:"Testar",en:"Test",es:"Probar"},saved:{pt:"Salvo automaticamente",en:"Auto-saved",es:"Guardado automáticamente"}
3,nodes:{pt:"Componentes",en:"Components",es:"Componentes"},inspector:{pt:"Configuração",en:"Configuration",es:"Configuración"},selectNode:{pt:"Selecione um nó pra editar",en:"Select a node to edit",es:"Selecciona un nodo para editar"},dragHint:{pt:"Arraste pro canvas â",en:"Drag to canvas â",es:"Arrastra al lienzo â"},duplicateNode:{pt:"Duplicar",en:"Duplicate",es:"Duplicar"},deleteNode:{pt:"Excluir",en:"Delete",es:"Eliminar"},removeConnection:{pt:"Remover conexão",en:"Remove connection",es:"Quitar conexión"},notFound:{pt:"Chatbot não encontrado",en:"Chatbot not found",es:"Chatbot no encontrado"},savingDots:{pt:"salvandoâ¦",en:"savingâ¦",es:"guardandoâ¦"},unsaved:{pt:"não salvo",en:"unsaved",es:"sin guardar"},errSave:{pt:"Erro ao salvar",en:"Error saving",es:"Error al guardar"},errSaveSettings:{pt:"Erro ao salvar configurações",en:"Error saving settings",es:"Error al guardar los ajustes"},errPublish:{pt:"Erro ao publicar",en:"Error publishing",es:"Error al publicar"},errGeneric:{pt:"Erro",en:"Error",es:"Error"},settingsBtn:{pt:"Config",en:"Settings",es:"Ajustes"},settingsHint:{pt:"Configurações (dispositivos, timeout, descrição)",en:"Settings (devices, timeout, description)",es:"Ajustes (dispositivos, timeout, descripción)"},metrics:{pt:"Métricas",en:"Metrics",es:"Métricas"},metricsOff:{pt:"Desativar métricas",en:"Turn metrics off",es:"Desactivar métricas"},metricsShow:{pt:"Mostrar métricas por bloco",en:"Show per-block metrics",es:"Mostrar métricas por bloque"},today:{pt:"Hoje",en:"Today",es:"Hoy"},oneYear:{pt:"1a",en:"1y",es:"1a"},exportContacts:{pt:"Exportar contatos",en:"Export contacts",es:"Exportar contactos"},exportNothing:{pt:"Nenhum contato acionou este chatbot ainda â nada para exportar",en:"No contact has triggered this chatbot yet â nothing to export",es:"Ningún contacto ha activado este chatbot todavÃa â nada para exportar"},exportHint:{pt:"Exportar (Excel) os contatos que acionaram este chatbot",en:"Export (Excel) the contacts that triggered this chatbot",es:"Exportar (Excel) los contactos que activaron este chatbot"},pause:{pt:"Pausar",en:"Pause",es:"Pausar"},activate:{pt:"Ativar",en:"Activate",es:"Activar"},cancel:{pt:"Cancelar",en:"Cancel",es:"Cancelar"},exportEmpty:{pt:"Nenhum contato acionou este chatbot ainda.",en:"No contact has triggered this chatbot yet.",es:"Ningún contacto ha activado este chatbot todavÃa."},exportOk:{pt:"{n} contato(s) exportado(s).",en:"{n} contact(s) exported.",es:"{n} contacto(s) exportado(s)."},exportErr:{pt:"Erro ao exportar contatos.",en:"Error exporting contacts.",es:"Error al exportar contactos."},stCompleted:{pt:"ConcluÃdo",en:"Completed",es:"Completado"},stActive:{pt:"Em andamento",en:"In progress",es:"En curso"},stCancelled:{pt:"Cancelado",en:"Cancelled",es:"Cancelado"},stTimeout:{pt:"Expirou",en:"Expired",es:"Expiró"},stFailed:{pt:"Falhou",en:"Failed",es:"Falló"},colName:{pt:"Nome",en:"Name",es:"Nombre"},colPhone:{pt:"Telefone",en:"Phone",es:"Teléfono"},colKeyword:{pt:"Palavra-chave que acionou",en:"Keyword that triggered",es:"Palabra clave que activó"},colEntry:{pt:"Entrou por",en:"Came in through",es:"Entró por"},colDevice:{pt:"Dispositivo que acionou",en:"Device that triggered",es:"Dispositivo que activó"},colTimes:{pt:"Vezes que acionou",en:"Times triggered",es:"Veces que activó"},colFinished:{pt:"Concluiu o fluxo",en:"Finished the flow",es:"Completó el flujo"},colStatus:{pt:"Status atual",en:"Current status",es:"Estado actual"},colFirst:{pt:"1º disparo",en:"First trigger",es:"Primer disparo"},colLast:{pt:"Ãltimo disparo",en:"Last trigger",es:"Ãltimo disparo"},colSaved:{pt:"Salvo na agenda",en:"Saved in contacts",es:"Guardado en la agenda"},noNameSaved:{pt:"(sem nome salvo)",en:"(no saved name)",es:"(sin nombre guardado)"},exportFilePrefix:{pt:"contatos",en:"contacts",es:"contactos"},yes:{pt:"Sim",en:"Yes",es:"SÃ"},no:{pt:"Não",en:"No",es:"No"},publishAsk:{pt:"Publicar este chatbot? Ele começará a responder mensagens automaticamente.",en:"Publish this chatbot? It will start replying to messages automatically.",es:"¿Publicar este chatbot? Empezará a responder mensajes automáticamente."},mediaMissingOne:{pt:"1 bloco de MÃdia está sem arquivo",en:"1 Media block has no file",es:"1 bloque de Multimedia está sin archivo"},mediaMissingN:{pt:"{n} blocos de MÃdia estão sem arquivo",en:"{n} Media blocks have no file",es:"{n} bloques de Multimedia están sin archivo"},mediaMissingHint:{pt:"Esses blocos vão falhar na hora de enviar. Dá pra publicar assim mesmo e corrigir depois.",en:"These blocks will fail when sending. You can publish anyway and fix them later.",es:"Estos bloques van a fallar al enviar. Puedes publicar igual y corregirlo después."},settingsTitle:{pt:"Configurações do chatbot",en:"Chatbot settings",es:"Ajustes del chatbot"},description:{pt:"Descrição",en:"Description",es:"Descripción"},descriptionPh:{pt:"Atendimento inicial, captura de leads, etc.",en:"First-touch support, lead capture, etc.",es:"Atención inicial, captación de leads, etc."},botLang:{pt:"Idioma das mensagens",en:"Message language",es:"Idioma de los mensajes"},botLangHint:{pt:'Idioma dos textos padrão que o contato recebe. "Do meu perfil" usa o idioma configurado no seu perfil.',en:'Language of the default texts the contact receives. "From my profile" uses the language set in your profile.',es:'Idioma de los textos por defecto que recibe el contacto. "De mi perfil" usa el idioma configurado en tu perfil.'},botLangProfile:{pt:"Do meu perfil",en:"From my profile",es:"De mi perfil"},botLangPt:{pt:"Português",en:"Portuguese",es:"Portugués"},botLangEn:{pt:"Inglês",en:"English",es:"Inglés"},botLangEs:{pt:"Espanhol",en:"Spanish",es:"Español"},botLangAuto:{pt:"Automático (segue o contato)",en:"Automatic (follows the contact)",es:"Automático (sigue al contacto)"},devicesLabel:{pt:"Dispositivos onde este chatbot atua",en:"Devices this chatbot acts on",es:"Dispositivos donde actúa este chatbot"}
3,devicesTemplateHint:{pt:"Fluxo de template: roda só no dispositivo Cloud/Coex dono do template. Não é editável.",en:"Template flow: runs only on the Cloud/Coex device that owns the template. Not editable.",es:"Flujo de template: se ejecuta solo en el dispositivo Cloud/Coex dueño del template. No es editable."},devicesHint:{pt:"Escolha em quais números este chatbot vai responder. Sem seleção = todos os dispositivos conectados.",en:"Choose which numbers this chatbot replies on. None = all connected devices.",es:"Elige en qué números responderá este chatbot. Sin selección = todos los dispositivos conectados."},noWabaDevice:{pt:"Nenhum dispositivo Cloud/Coex desta conta (WABA) conectado.",en:"No Cloud/Coex device from this account (WABA) is connected.",es:"Ningún dispositivo Cloud/Coex de esta cuenta (WABA) está conectado."},locked:{pt:"fixo",en:"locked",es:"fijo"},noDevice:{pt:"Nenhum dispositivo conectado. Conecte um WhatsApp em /dashboard/devices primeiro.",en:"No device connected. Connect a WhatsApp at /dashboard/devices first.",es:"Ningún dispositivo conectado. Conecta un WhatsApp en /dashboard/devices primero."},allDevices:{pt:"Todos os dispositivos",en:"All devices",es:"Todos los dispositivos"},allDevicesHint:{pt:"Bot dispara em qualquer número conectado.",en:"Bot fires on any connected number.",es:"El bot se activa en cualquier número conectado."},someDevices:{pt:"Dispositivos especÃficos",en:"Specific devices",es:"Dispositivos especÃficos"},someDevicesHint:{pt:"Selecione abaixo quais números terão este bot.",en:"Pick below which numbers run this bot.",es:"Selecciona abajo qué números tendrán este bot."},banned:{pt:"banida",en:"banned",es:"suspendida"},online:{pt:"online",en:"online",es:"en lÃnea"},offline:{pt:"offline",en:"offline",es:"desconectado"},sessionTimeout:{pt:"Timeout de sessão",en:"Session timeout",es:"Timeout de sesión"},sessionTimeoutHint:{pt:"Quanto tempo a sessão de um contato fica ativa sem resposta antes de expirar.",en:"How long a contact session stays active without reply before timing out.",es:"Cuánto tiempo la sesión de un contacto sigue activa sin respuesta antes de expirar."},h1:{pt:"1 hora",en:"1 hour",es:"1 hora"},h3:{pt:"3 horas",en:"3 hours",es:"3 horas"},h6:{pt:"6 horas",en:"6 hours",es:"6 horas"},h12:{pt:"12 horas",en:"12 hours",es:"12 horas"},h24rec:{pt:"24 horas (recomendado)",en:"24 hours (recommended)",es:"24 horas (recomendado)"},d3:{pt:"3 dias",en:"3 days",es:"3 dÃas"},d7:{pt:"7 dias",en:"7 days",es:"7 dÃas"},expandPalette:{pt:"Expandir componentes",en:"Expand components",es:"Expandir componentes"},collapse:{pt:"Recolher",en:"Collapse",es:"Contraer"},searchPh:{pt:"Buscar...",en:"Search...",es:"Buscar..."},closeEsc:{pt:"Fechar (Esc)",en:"Close (Esc)",es:"Cerrar (Esc)"},teTitle:{pt:"Template de entrada",en:"Entry template",es:"Template de entrada"},teIntro:{pt:"Este é o inÃcio do fluxo. O contato entra quando toca um botão de resposta do template â cada botão tem sua própria saÃda pra você conectar.",en:"This is the start of the flow. The contact enters when they tap a reply button on the template â each button has its own output for you to connect.",es:"Este es el inicio del flujo. El contacto entra cuando toca un botón de respuesta del template â cada botón tiene su propia salida para que la conectes."},teTemplate:{pt:"Template",en:"Template",es:"Template"},teLanguage:{pt:"Idioma",en:"Language",es:"Idioma"},teCategory:{pt:"Categoria",en:"Category",es:"CategorÃa"},teButtons:{pt:"Botões â saÃdas do fluxo",en:"Buttons â flow outputs",es:"Botones â salidas del flujo"},teOutput:{pt:"saÃda",en:"output",es:"salida"},teNoButtons:{pt:"Sem botões de resposta rápida.",en:"No quick reply buttons.",es:"Sin botones de respuesta rápida."},teFooter1:{pt:"Funciona em dispositivos",en:"Works on",es:"Funciona en dispositivos"},teFooter2:{pt:"(template Meta). Para usar outro template, crie um novo fluxo a partir dele.",en:"devices (Meta template). To use another template, create a new flow from it.",es:"(template de Meta). Para usar otro template, crea un nuevo flujo a partir de él."},advLabel:{pt:"Rótulo do nó",en:"Block label",es:"Etiqueta del bloque"},advLabelHint:{pt:"Aparece só aqui no editor, pra você se organizar. Não vai pro contato.",en:"Shows only here in the editor, to keep you organized. The contact never sees it.",es:"Aparece solo aquà en el editor, para que te organices. No le llega al contacto."},advLabelPh:{pt:"Ex: Boas-vindas",en:"Ex: Welcome",es:"Ej: Bienvenida"},advNote:{pt:"Nota interna (opcional)",en:"Internal note (optional)",es:"Nota interna (opcional)"},advNoteHint:{pt:"Só pra você se organizar â não vai pro contato e não muda o envio.",en:"Just for your own organization â the contact never sees it and it changes nothing in the sending.",es:"Solo para que te organices â no le llega al contacto y no camb
3ia el envÃo."},advId:{pt:"Identificador do nó",en:"Block identifier",es:"Identificador del bloque"},advCopied:{pt:"â copiado",en:"â copied",es:"â copiado"},mtNoData:{pt:"Sem dados ainda",en:"No data yet",es:"Sin datos todavÃa"},mtNoDataHint1:{pt:"Ligue",en:"Turn on",es:"Activa"},mtNoDataHint2:{pt:"na barra do topo (com o fluxo publicado). Aqui aparece quantas pessoas passaram por este bloco e por onde elas seguem.",en:"in the top bar (with the flow published). Here you see how many people went through this block and where they go next.",es:"en la barra superior (con el flujo publicado). Aquà verás cuántas personas pasaron por este bloque y hacia dónde siguen."},mtSeeMetrics:{pt:"Ver métricas",en:"View metrics",es:"Ver métricas"},mtPeople:{pt:"Pessoas",en:"People",es:"Personas"},mtRuns:{pt:"Acionamentos",en:"Triggers",es:"Activaciones"},mtFails:{pt:"Falhas",en:"Failures",es:"Fallos"},mtAvgTime:{pt:"Tempo médio",en:"Average time",es:"Tiempo medio"},mtWhereGo:{pt:"Por onde as pessoas seguem",en:"Where people go next",es:"Por dónde siguen las personas"},mtOutput:{pt:"SaÃda",en:"Output",es:"Salida"},msgText:{pt:"Texto da mensagem",en:"Message text",es:"Texto del mensaje"},msgTextHint:{pt:"Use {{variavel}} pra inserir dados. Spintax: {opção1|opção2}",en:"Use {{variable}} to insert data. Spintax: {option1|option2}",es:"Usa {{variable}} para insertar datos. Spintax: {opción1|opción2}"},mdPreview:{pt:"Prévia â como o contato recebe",en:"Preview â how the contact receives it",es:"Vista previa â cómo lo recibe el contacto"},mdSwap:{pt:"Trocar mÃdia",en:"Replace media",es:"Cambiar multimedia"},mdSend:{pt:"Enviar mÃdia",en:"Upload media",es:"Subir multimedia"},mdRemoveHint:{pt:"Remover a mÃdia deste bloco",en:"Remove the media from this block",es:"Quitar la multimedia de este bloque"},remove:{pt:"Remover",en:"Remove",es:"Quitar"},mdType:{pt:"Tipo de mÃdia",en:"Media type",es:"Tipo de multimedia"},mdImage:{pt:"Imagem",en:"Image",es:"Imagen"},mdVideo:{pt:"VÃdeo",en:"Video",es:"Video"},mdAudioPtt:{pt:"Ãudio (mensagem de voz)",en:"Audio (voice message)",es:"Audio (mensaje de voz)"},mdDocument:{pt:"Documento",en:"Document",es:"Documento"},mdSticker:{pt:"Sticker",en:"Sticker",es:"Sticker"},mdCaption:{pt:"Legenda (opcional)",en:"Caption (optional)",es:"Leyenda (opcional)"},mdCaptionHint:{pt:"Suporta {{variavel}}",en:"Supports {{variable}}",es:"Admite {{variable}}"},mdFileName:{pt:"Nome do arquivo",en:"File name",es:"Nombre del archivo"},mdFileNameHint:{pt:"à o nome que o contato vê ao receber o documento.",en:"This is the name the contact sees when receiving the document.",es:"Es el nombre que el contacto ve al recibir el documento."},mdPttCheck:{pt:"Enviar como mensagem de voz (PTT)",en:"Send as voice message (PTT)",es:"Enviar como mensaje de voz (PTT)"},mdSource:{pt:"Origem do arquivo (avançado)",en:"File source (advanced)",es:"Origen del archivo (avanzado)"},mdUrl:{pt:"Endereço da mÃdia",en:"Media address",es:"Dirección de la multimedia"},mdUrlHint:{pt:"Preenchido sozinho ao enviar um arquivo. Só mexa se souber o que está fazendo â um endereço errado quebra o envio.",en:"Filled in automatically when you upload a file. Only change it if you know what you are doing â a wrong address breaks the sending.",es:"Se rellena solo al subir un archivo. Cámbialo solo si sabes lo que haces â una dirección incorrecta rompe el envÃo."},mdUrlPh:{pt:"https://... ou /uploads/arquivo.jpg",en:"https://... or /uploads/file.jpg",es:"https://... o /uploads/archivo.jpg"},mdMimeHint:{pt:"Deixe vazio para detectar automaticamente.",en:"Leave empty to detect automatically.",es:"Déjalo vacÃo para detectarlo automáticamente."},btNoMedia:{pt:"Sem mÃdia",en:"No media",es:"Sin multimedia"},btLocation:{pt:"Local",en:"Location",es:"Ubicación"},btHeader:{pt:"MÃdia no topo (opcional)",en:"Media on top (optional)",es:"Multimedia arriba (opcional)"},btHeaderHint:{pt:"Aparece acima do texto. Ãtil pra catálogo, vÃdeo demo, foto do produto.",en:"Shows above the text. Useful for a catalog, demo video or product photo.",es:"Aparece encima del texto. Ãtil para catálogo, video demo o foto del producto."},btUrlPh:{pt:"ou cole URL: /uploads/foto.jpg",en:"or paste a URL: /uploads/photo.jpg",es:"o pega una URL: /uploads/foto.jpg"},btLat:{pt:"Latitude",en:"Latitude",es:"Latitud"},btLon:{pt:"Longitude",en:"Longitude",es:"Longitud"},btPlaceName:{pt:"Nome do local",en:"Place name",es:"Nombre del lugar"},btAddress:{pt:"Endereço",en:"Address",es:"Dirección"},btAddressPh:{pt:"BrasÃlia, DF",en:"Austin, TX",es:"Bogotá, DC"},btQuestion:{pt:"Texto da pergunta",en:"Question text",es:"Texto de la pregunta"},btFooter:{pt:"Footer (opcional)",en:"Footer (optional)",es:"Pie de página (opcional)"},btFooterPh:{pt:"Ex: Pragmaz Bot",en:"Ex: Pragmaz Bot",es:"Ej: Pragmaz Bot"},btButtons:{pt:"Botões (até 3)",en:"Buttons (up to 3)",es:"Botones (hasta 3)"},btButton:{pt:"Botão",en:"Button",es:"Botón"},btAdd:{pt:"Adicionar botão",en:"Add button",es:"Añadir botón"},btMenuMode:{pt:"Comportamento do menu",en:"Menu behavior",es:"Comportamiento del menú"},btKeepOpen:{pt:"Menu com várias opções (cada botão responde 1Ã)",en:"Multi-option menu (each button replies once)",es:"Menú con varias opciones (cada botón responde 1Ã)"},btKeepOpen1:{pt:'O contato pode tocar cada botão e recebe a resposta daquele botão â o menu não "acaba" no primeiro clique.',en:'The contact c
3an tap each button and gets that buttonâs reply â the menu does not "end" on the first click.',es:'El contacto puede tocar cada botón y recibe la respuesta de ese botón â el menú no "termina" en el primer clic.'},btKeepOpen2:{pt:"Cada botão responde só uma vez",en:"Each button replies only once",es:"Cada botón responde solo una vez"},btKeepOpen3:{pt:"(tocar de novo não repete). Ao usar a última opção, o fluxo segue/encerra. Pra finalizar antes num ramo, use",en:"(tapping again does not repeat). After the last option, the flow continues or ends. To finish earlier on a branch, use",es:"(tocar de nuevo no repite). Al usar la última opción, el flujo sigue o termina. Para terminar antes en una rama, usa"},btKeepOpenEnd:{pt:"Encerrar",en:"End",es:"Finalizar"},btKeepOpenHandoff:{pt:"Transferir humano",en:"Handoff to human",es:"Transferir a humano"},or:{pt:"ou",en:"or",es:"o"},inValText:{pt:"qualquer texto",en:"any text",es:"cualquier texto"},inValEmail:{pt:"um e-mail válido",en:"a valid email",es:"un correo válido"},inValPhone:{pt:"um telefone válido",en:"a valid phone number",es:"un teléfono válido"},inValNumber:{pt:"um número",en:"a number",es:"un número"},inValCpf:{pt:"um CPF válido",en:"a valid CPF",es:"un CPF válido"},inValDate:{pt:"uma data válida",en:"a valid date",es:"una fecha válida"},inQuestion:{pt:"Pergunta",en:"Question",es:"Pregunta"},inSaveVar:{pt:"Salvar em variável",en:"Save to variable",es:"Guardar en variable"},inVarPh:{pt:"nome",en:"name",es:"nombre"},inValidation:{pt:"Validação",en:"Validation",es:"Validación"},inValidationHint:{pt:"Define o que conta como resposta VÃLIDA",en:"Defines what counts as a VALID answer",es:"Define qué cuenta como respuesta VÃLIDA"},inOptText:{pt:"Texto livre (aceita qualquer coisa)",en:"Free text (accepts anything)",es:"Texto libre (acepta cualquier cosa)"},inOptEmail:{pt:"E-mail (formato [email protected])",en:"Email (format [email protected])",es:"Correo (formato [email protected])"},inOptPhone:{pt:"Telefone",en:"Phone",es:"Teléfono"},inOptNumber:{pt:"Número",en:"Number",es:"Número"},inOptDate:{pt:"Data",en:"Date",es:"Fecha"},inWarnTitle:{pt:"Atenção à validação",en:"Mind the validation",es:"Atención a la validación"},inWarn1:{pt:"Só passa pra",en:"It only goes to",es:"Solo pasa a"},inWarn2:{pt:"se o usuário responder com",en:"if the user replies with",es:"si el usuario responde con"},inWarnEg:{pt:"ex:",en:"eg:",es:"ej:"},inWarn3:{pt:"Qualquer outra coisa cai em",en:"Anything else falls to",es:"Cualquier otra cosa cae en"},inTimeoutHint:{pt:"Após quanto tempo desistir da resposta e ir pra out-1",en:"How long before giving up on the answer and going to out-1",es:"Cuánto tiempo esperar antes de dejar de esperar la respuesta e ir a out-1"},inBrAny:{pt:"Qualquer resposta",en:"Any answer",es:"Cualquier respuesta"},inBrAnyDesc:{pt:"Texto livre â aceita qualquer coisa que o usuário enviar.",en:"Free text â accepts anything the user sends.",es:"Texto libre â acepta cualquier cosa que el usuario envÃe."},inBrTimeoutDesc:{pt:"Usuário não respondeu dentro do tempo limite configurado.",en:"The user did not reply within the configured time limit.",es:"El usuario no respondió dentro del tiempo lÃmite configurado."},inBrValid:{pt:"Resposta válida",en:"Valid answer",es:"Respuesta válida"},inBrValidDesc:{pt:"Resposta no formato",en:"Answer in the format",es:"Respuesta en el formato"},inBrInvalid:{pt:"Não é",en:"Not",es:"No es"},inBrInvalidDesc:{pt:"Usuário respondeu, mas o formato não bateu.",en:"The user replied, but the format did not match.",es:"El usuario respondió, pero el formato no coincidió."},chQuestionHint:{pt:"Só a pergunta â a lista numerada é montada sozinha a partir das opções abaixo.",en:"Just the question â the numbered list is built automatically from the options below.",es:"Solo la pregunta â la lista numerada se arma sola a partir de las opciones de abajo."},chOptionsHint:{pt:"Cada opção vira uma saÃda. Enter cria a próxima.",en:"Each option becomes an output. Enter creates the next one.",es:"Cada opción crea una salida. Enter crea la siguiente."},chOptionPh:{pt:"Ex: Vendas",en:"e.g. Sales",es:"Ej: Ventas"},chAddOption:{pt:"Adicionar opção",en:"Add option",es:"Agregar opción"},chRemoveOption:{pt:"Remover opção",en:"Remove option",es:"Quitar opción"},chPreviewEmpty:{pt:"Escreva a pergunta e as opções para ver a mensagem.",en:"Write the question and options to see the message.",es:"Escribe la pregunta y las opciones para ver el mensaje."},chPreview:{pt:"O contato vai receber:",en:"The contact will receive:",es:"El contacto recibirá:"}
3,chOptions:{pt:"Opções (uma por linha â cada linha cria uma saÃda out-N)",en:"Options (one per line â each line creates an out-N output)",es:"Opciones (una por lÃnea â cada lÃnea crea una salida out-N)"},chVariable:{pt:"Variável (opcional)",en:"Variable (optional)",es:"Variable (opcional)"},chVariableHint:{pt:"Salva a escolha numa variável dedicada (não sobrescreve a escolha anterior). Ãtil em fluxos com várias Múltiplas Escolhas (BANT, qualificação).",en:"Saves the choice to a dedicated variable (does not overwrite the previous choice). Useful in flows with several Multiple Choice blocks (BANT, qualification).",es:"Guarda la elección en una variable dedicada (no sobrescribe la elección anterior). Ãtil en flujos con varias Opciones Múltiples (BANT, calificación)."},chVariablePh:{pt:"ex: orcamento",en:"eg: budget",es:"ej: presupuesto"},chEmpty:{pt:"Adicione opções pra criar saÃdas.",en:"Add options to create outputs.",es:"Añade opciones para crear salidas."},chOutputs:{pt:"saÃda(s):",en:"output(s):",es:"salida(s):"},lsButtonText:{pt:"Texto do botão (abre a lista)",en:"Button text (opens the list)",es:"Texto del botón (abre la lista)"},lsSeeOptions:{pt:"Ver opções",en:"See options",es:"Ver opciones"},lsOptions:{pt:"Opções da lista",en:"List options",es:"Opciones de la lista"},lsAddSection:{pt:"Adicionar seção",en:"Add section",es:"Añadir sección"},lsOverA:{pt:"WhatsApp aceita no máximo 10 opções no total â você tem",en:"WhatsApp accepts at most 10 options in total â you have",es:"WhatsApp acepta como máximo 10 opciones en total â tienes"},lsOverB:{pt:"Remova",en:"Remove",es:"Quita"},lsHint1:{pt:"Cada opção vira uma saÃda",en:"Each option becomes an",es:"Cada opción se convierte en una salida"},lsHint2:{pt:"no fluxo. Limite WhatsApp: 10 opções totais.",en:"output in the flow. WhatsApp limit: 10 options in total.",es:"en el flujo. LÃmite de WhatsApp: 10 opciones en total."},lsExpand:{pt:"Expandir",en:"Expand",es:"Expandir"},lsCollapse:{pt:"Colapsar",en:"Collapse",es:"Contraer"},lsSection:{pt:"SEÃÃO",en:"SECTION",es:"SECCIÃN"},lsSectionPh:{pt:"TÃtulo da seção (opcional)",en:"Section title (optional)",es:"TÃtulo de la sección (opcional)"},lsRemoveSection:{pt:"Remover seção",en:"Remove section",es:"Quitar sección"},lsAddFirst:{pt:"Adicionar primeira opção",en:"Add first option",es:"Añadir primera opción"},lsDragHint:{pt:"Arraste pra reordenar",en:"Drag to reorder",es:"Arrastra para reordenar"},lsRowTitlePh:{pt:"TÃtulo da opção",en:"Option title",es:"TÃtulo de la opción"},lsRowDescPh:{pt:"Descrição (opcional)",en:"Description (optional)",es:"Descripción (opcional)"},lsRemoveRow:{pt:"Remover opção",en:"Remove option",es:"Quitar opción"},lsAddRow:{pt:"Adicionar opção",en:"Add option",es:"Añadir opción"},lsAddRowKbd:{pt:"(ou Enter no tÃtulo)",en:"(or Enter in the title)",es:"(o Enter en el tÃtulo)"},cdVariable:{pt:"Variável",en:"Variable",es:"Variable"},cdOperator:{pt:"Operador",en:"Operator",es:"Operador"},cdEquals:{pt:"Igual a",en:"Equals",es:"Igual a"},cdNotEquals:{pt:"Diferente de",en:"Not equal to",es:"Distinto de"},cdContains:{pt:"Contém",en:"Contains",es:"Contiene"},cdGreater:{pt:"Maior que",en:"Greater than",es:"Mayor que"},cdLess:{pt:"Menor que",en:"Less than",es:"Menor que"},cdEmpty:{pt:"Vazio",en:"Empty",es:"VacÃo"},cdValue:{pt:"Valor",en:"Value",es:"Valor"},rdTitle:{pt:"Escolha aleatória uniforme",en:"Uniform random choice",es:"Elección aleatoria uniforme"},rdDesc1:{pt:"Cada execução escolhe",en:"Each run picks",es:"Cada ejecución elige"},rdDescOne:{pt:"UMA",en:"ONE",es:"UNA"},rdDesc2:{pt:"das",en:"of the",es:"de las"},rdDesc3:{pt:"saÃdas com igual probabilidade",en:"outputs with equal probability",es:"salidas con igual probabilidad"},rdDesc4:{pt:"cada",en:"each",es:"cada una"},rdPathPh:{pt:"Caminho",en:"Path",es:"Ruta"},rdRemoveOut:{pt:"Remover saÃda",en:"Remove output",es:"Quitar salida"},rdAddOut:{pt:"Adicionar saÃda",en:"Add output",es:"Añadir salida"},dbSource:{pt:"Fonte de dados",en:"Data source",es:"Fuente de datos"}
3,dbContact:{pt:"Contato (nome, lid, jid)",en:"Contact (name, lid, jid)",es:"Contacto (nombre, lid, jid)"},dbHasLabel:{pt:"Tem etiqueta? (true/false)",en:"Has label? (true/false)",es:"¿Tiene etiqueta? (true/false)"},dbMsgCount:{pt:"Total de mensagens",en:"Total messages",es:"Total de mensajes"},dbLastAge:{pt:"Tempo desde última msg (s)",en:"Time since last message (s)",es:"Tiempo desde el último mensaje (s)"},dbFirstContact:{pt:"à primeiro contato? (true/false)",en:"Is first contact? (true/false)",es:"¿Es primer contacto? (true/false)"},dbSql:{pt:"SQL custom (avançado)",en:"Custom SQL (advanced)",es:"SQL personalizado (avanzado)"},dbField:{pt:"Campo",en:"Field",es:"Campo"},dbFieldName:{pt:"Nome (salvo)",en:"Name (saved)",es:"Nombre (guardado)"},dbFieldNotify:{pt:"Push name",en:"Push name",es:"Push name"},dbFieldIsSaved:{pt:"Está salvo? (0/1)",en:"Is it saved? (0/1)",es:"¿Está guardado? (0/1)"},dbLabelName:{pt:"Nome da etiqueta",en:"Label name",es:"Nombre de la etiqueta"},dbLabelPh:{pt:"Ex: Cliente VIP",en:"Eg: VIP customer",es:"Ej: Cliente VIP"},dbQuery:{pt:"Query SQL (somente SELECT)",en:"SQL query (SELECT only)",es:"Consulta SQL (solo SELECT)"},dbQueryHint:{pt:"Use ? como placeholder. cfg.params interpola variáveis",en:"Use ? as a placeholder. cfg.params interpolates variables",es:"Usa ? como marcador. cfg.params interpola variables"},dbParams:{pt:"Parâmetros (um por linha â interpola {{variavel}})",en:"Parameters (one per line â interpolates {{variable}})",es:"Parámetros (uno por lÃnea â interpola {{variable}})"},dbSaveTo:{pt:"Salvar resultado em variável",en:"Save result to variable",es:"Guardar resultado en variable"},dbBrOk:{pt:"Sucesso / true",en:"Success / true",es:"Ãxito / true"},dbBrOkDesc:{pt:"HTTP 2xx ou condição verdadeira.",en:"HTTP 2xx or condition true.",es:"HTTP 2xx o condición verdadera."},dbBrErr:{pt:"Erro / false",en:"Error / false",es:"Error / false"},dbBrErrDesc:{pt:"HTTP 4xx-5xx, timeout ou condição falsa.",en:"HTTP 4xx-5xx, timeout or condition false.",es:"HTTP 4xx-5xx, timeout o condición falsa."},dlMode:{pt:"Modo",en:"Mode",es:"Modo"},dlFixed:{pt:"Tempo fixo",en:"Fixed time",es:"Tiempo fijo"},dlUntil:{pt:"Até hora especÃfica",en:"Until a specific time",es:"Hasta una hora especÃfica"},dlTime:{pt:"Tempo",en:"Time",es:"Tiempo"},dlUnit:{pt:"Unidade",en:"Unit",es:"Unidad"},dlSeconds:{pt:"segundos",en:"seconds",es:"segundos"},dlMinutes:{pt:"minutos",en:"minutes",es:"minutos"},dlHours:{pt:"horas",en:"hours",es:"horas"},dlDays:{pt:"dias",en:"days",es:"dÃas"},dlTarget:{pt:"Hora alvo",en:"Target time",es:"Hora objetivo"},whMethod:{pt:"Método",en:"Method",es:"Método"},whBody:{pt:"Body (JSON)",en:"Body (JSON)",es:"Body (JSON)"},whSaveTo:{pt:"Salvar resposta em variável",en:"Save response to variable",es:"Guardar respuesta en variable"},aiProvider:{pt:"Provedor",en:"Provider",es:"Proveedor"},aiModel:{pt:"Modelo",en:"Model",es:"Modelo"},aiMode:{pt:"Modo",en:"Mode",es:"Modo"},aiReply:{pt:"Responder ao usuário (envia direto)",en:"Reply to the user (sends directly)",es:"Responder al usuario (envÃa directo)"},aiClassify:{pt:"Classificar intenção (salva em variável)",en:"Classify intent (saves to variable)",es:"Clasificar intención (guarda en variable)"},aiExtract:{pt:"Extrair dados (JSON em variável)",en:"Extract data (JSON into variable)",es:"Extraer datos (JSON en variable)"},aiPromptHint:{pt:"Suporta {{variavel}} pra contexto dinâmico",en:"Supports {{variable}} for dynamic context",es:"Admite {{variable}} para contexto dinámico"},aiTempHint:{pt:"0 = determinÃstico, 1 = criativo",en:"0 = deterministic, 1 = creative",es:"0 = determinista, 1 = creativo"},aiBrOk:{pt:"Resposta gerada",en:"Response generated",es:"Respuesta generada"},aiBrOkDesc:{pt:"A IA respondeu com sucesso e o resultado foi salvo na variável.",en:"The AI replied successfully and the result was saved to the variable.",es:"La IA respondió con éxito y el resultado se guardó en la variable."},aiBrErrDesc:{pt:"API key inválida, rate limit, modelo offline ou timeout.",en:"Invalid API key, rate limit, model offline or timeout.",es:"API key inválida, lÃmite de solicitudes, modelo offline o timeout."},tgAction:{pt:"Ação",en:"Action",es:"Acción"},tgAdd:{pt:"Adicionar etiqueta",en:"Add label",es:"Añadir etiqueta"},tgRemove:{pt:"Remover etiqueta",en:"Remove label",es:"Quitar etiqueta"},tgLabel:{pt:"Etiqueta",en:"Label",es:"Etiqueta"},tgLabelPh:{pt:"Lead Quente",en:"Hot Lead",es:"Lead Caliente"},tgHint:{pt:"Em WhatsApp Web Business vira etiqueta; nos demais devices, coluna do Kanban com esse nome",en:"On WhatsApp Web Business it becomes a label; on other devices, a Kanban column with this name",es:"En WhatsApp Web Business es una etiqueta; en otros dispositivos, una columna del Kanban con ese nombre"},tgLoading:{pt:"Verificando seus devicesâ¦",en:"Checking your devicesâ¦",es:"Verificando tus dispositivosâ¦"},tgModeNative:{pt:"Etiqueta",en:"Label",es:"Etiqueta"},tgModeKanban:{pt:"Kanban",en:"Kanban",es:"Kanban"},tgMissing:{pt:"Esse nome não existe nos devices deste fluxo â o nó vai falhar até você criá-lo.",en:"This name doesn't exist on this flow's devices â the node will fail until you create it.",es:"Ese nombre no existe en los dispositivos de este flujo â el nodo fallará hasta crearlo."},tgSrcNative:{pt:"etiquetas do WhatsApp Business",en:"WhatsApp Business labels",es:"etiquetas de WhatsApp Business"},tgSrcKanban:{pt:"colunas do Kanban",en:"Kanban columns",es:"columnas del Kanban"},tgEmptyNative:{pt:"Nenhuma etiqueta neste device ainda. Crie no WhatsApp Business do celular.",en:"No labels on this device yet. Create them in WhatsApp Business on the phone.",es:"Aún no hay etiquetas en este dispositivo. Créalas en WhatsApp Business."},tgEmptyKanban:{pt:"O Kanban destes devices ainda não tem colunas. Abra o Kanban uma vez para criá-las.",en:"These devices' Kanban has no columns yet. Open the Kanban once to create them.",es:"El Kanban de estos dispositivos aún no tiene columnas. Ãbrelo una vez para crearlas."},tgCustom:{pt:"Usar outro nomeâ¦",en:"Use another nameâ¦",es:"Usar otro nombreâ¦"},tgFollowup:{pt:"Disparar o follow-up automático da coluna ao mover o card (desligado por padrão â fluxo que etiqueta muita gente viraria disparo em massa)",en:"Trigger the column automatic follow-up when moving the card (off by default)",es:"Disparar el follow-up automático de la columna al mover la tarjeta (apagado por defecto)"},agLabel:{pt:"Agente de IA",en:"AI agent",es:"Agente de IA"},agHint:{pt:"O agente traz a base de conhecimento, as ações e os horários dele",en:"The agent brings its knowledge base, actions and schedules",es:"El agente aporta su base de conocimiento, acciones y horarios"}
3,agLoading:{pt:"Carregando agentesâ¦",en:"Loading agentsâ¦",es:"Cargando agentesâ¦"},agSearch:{pt:"Buscar agenteâ¦",en:"Search agentâ¦",es:"Buscar agenteâ¦"},agEmpty:{pt:"Nenhum agente criado",en:"No agents yet",es:"Ningún agente creado"},agEmptyHint:{pt:"Crie um agente com a base de conhecimento do seu negócio e depois selecione aqui.",en:"Create an agent with your business knowledge base, then select it here.",es:"Crea un agente con la base de conocimiento de tu negocio y selecciónalo aquÃ."},agCreateFirst:{pt:"Criar agente",en:"Create agent",es:"Crear agente"},agLoadErr:{pt:"Erro ao carregar agentes",en:"Failed to load agents",es:"Error al cargar agentes"},agInactive:{pt:"Este agente não está ativo â o nó vai falhar até reativá-lo.",en:"This agent is not active â the node will fail until you reactivate it.",es:"Este agente no está activo â el nodo fallará hasta reactivarlo."},agLegacy:{pt:"Este nó usa a configuração antiga (prompt e modelo digitados no próprio nó). Ele continua funcionando; escolha um agente abaixo quando quiser migrar.",en:"This node uses the old setup (prompt and model typed in the node). It keeps working; pick an agent below when you want to migrate.",es:"Este nodo usa la configuración antigua. Sigue funcionando; elige un agente abajo cuando quieras migrar."},ooExplain:{pt:"O contato entra na lista de descadastrados e para de receber disparos de MARKETING. Mensagens de utilidade e o próprio fluxo continuam. Não funciona em device WhatsApp Web (lá não há supressão no envio).",en:"The contact is added to the unsubscribe list and stops receiving MARKETING broadcasts. Utility messages and this flow still work. Not available on WhatsApp Web devices.",es:"El contacto entra en la lista de bajas y deja de recibir envÃos de MARKETING. Los mensajes de utilidad y este flujo siguen. No funciona en dispositivos WhatsApp Web."},ooConfirm:{pt:"Enviar mensagem de confirmação ao contato",en:"Send a confirmation message to the contact",es:"Enviar mensaje de confirmación al contacto"},ooText:{pt:"Texto da confirmação",en:"Confirmation text",es:"Texto de la confirmación"},ooTextHint:{pt:"Vazio usa o texto padrão no idioma do fluxo",en:"Empty uses the default text in the flow language",es:"VacÃo usa el texto por defecto en el idioma del flujo"},hoReason:{pt:"Motivo da transferência",en:"Handoff reason",es:"Motivo de la transferencia"},hoPause:{pt:"Pausar bot por (horas)",en:"Pause bot for (hours)",es:"Pausar el bot por (horas)"},hoNotify:{pt:"Notificar atendentes",en:"Notify agents",es:"Notificar a los agentes"},endDesc:{pt:"Encerra a sessão do chatbot. Próximas mensagens do contato cairão como inbound normal (até serem capturadas por outro gatilho).",en:"Ends the chatbot session. The contactâs next messages arrive as normal inbound (until another trigger catches them).",es:"Finaliza la sesión del chatbot. Los próximos mensajes del contacto llegarán como mensajes entrantes normales (hasta que otro disparador los capture)."},vdEvent:{pt:"Evento",en:"Event",es:"Evento"},vdEvPurchase:{pt:"Compra (Purchase)",en:"Purchase",es:"Compra (Purchase)"},vdEvCheckout:{pt:"Iniciou a compra (InitiateCheckout)",en:"Initiate checkout",es:"Inició la compra (InitiateCheckout)"},vdEvLead:{pt:"Lead",en:"Lead",es:"Lead"},vdEvHint:{pt:"Compra move o card no Kanban. Lead e Iniciou a compra só avisam a Meta.",en:"Purchase moves the Kanban card. Lead and Initiate checkout only notify Meta.",es:"Compra mueve la tarjeta en el Kanban. Lead e Inició la compra solo avisan a Meta."},vdValue:{pt:"Valor",en:"Value",es:"Valor"},vdValueHint:{pt:'Ou uma variável, ex.: {{valor}}. Vai para o campo "Valor do negócio" do card.',en:'Or a variable, e.g. {{valor}}. Goes to the card "Deal value" field.',es:'O una variable, ej.: {{valor}}. Va al campo "Valor del negocio" de la tarjeta.'},vdCurrency:{pt:"Moeda",en:"Currency",es:"Moneda"},vdCurrencyCol:{pt:"A da coluna de conversão",en:"The conversion column's",es:"La de la columna de conversión"},vdColumn:{pt:"Coluna de conversão",en:"Conversion column",es:"
3Columna de conversión"},vdColumnHint:{pt:'Só aparecem as colunas que você marcou com "Marca conversão (ganho)" no Kanban.',en:'Only columns you marked as "Marks conversion (won)" in the Kanban appear.',es:'Solo aparecen las columnas que marcaste con "Marca conversión (ganada)" en el Kanban.'},vdColumnNone:{pt:'Nenhuma coluna de conversão nos devices deste fluxo. No Kanban, abra "Editar coluna" e ligue "Marca conversão (ganho)".',en:`No conversion column on this flow's devices. In the Kanban, open "Edit column" and turn on "Marks conversion (won)".`,es:'No hay columna de conversión en los dispositivos de este flujo. En el Kanban, abre "Editar columna" y activa "Marca conversión (ganada)".'},vdChoose:{pt:"Escolhaâ¦",en:"Chooseâ¦",es:"Eligeâ¦"},vdMeta:{pt:"Avisar o Pixel da Meta",en:"Notify the Meta Pixel",es:"Avisar al PÃxel de Meta"},vdMetaHint:{pt:'Usa o pixel configurado no Kanban. Só vai para quem veio de anúncio ou de Lançamento. Desligado, a venda ainda vai se a coluna de conversão tiver "Enviar a venda para a Meta".',en:'Uses the pixel set up in the Kanban. Only for contacts who came from an ad or a Launch. When off, the sale still goes if the conversion column has "Send the sale to Meta" on.',es:'Usa el pÃxel configurado en el Kanban. Solo para quien vino de un anuncio o de un Lanzamiento. Apagado, la venta igual va si la columna de conversión tiene "Enviar la venta a Meta".'},vdLoadFail:{pt:"Não foi possÃvel verificar o Kanban de:",en:"Could not check the Kanban of:",es:"No se pudo verificar el Kanban de:"},vdWaitMissing:{pt:"Essa coluna não existe em:",en:"This column does not exist on:",es:"Esa columna no existe en:"},vdWaitIsConv:{pt:"à coluna de conversão em (escolha uma coluna antes da venda):",en:"It is a conversion column on (pick a column before the sale):",es:"Es columna de conversión en (elige una columna antes de la venta):"},vdNeedCurrency:{pt:"Com valor, escolha a moeda: sem moeda o valor não vai para a Meta.",en:"With a value, pick the currency: without it the value does not reach Meta.",es:"Con valor, elige la moneda: sin moneda el valor no llega a Meta."},vdColNoCurrency:{pt:"A coluna de conversão está sem moeda em (escolha a moeda aqui ou em Editar coluna):",en:"The conversion column has no currency on (pick it here or in Edit column):",es:"La columna de conversión no tiene moneda en (elÃgela aquà o en Editar columna):"},vdValueOne:{pt:'Use UM valor só (ex.: 1500 ou 1.500,00). Texto com mais de um número, como "2x 49,90", não vira valor.',en:'Use ONE value (e.g. 1500 or 1,500.00). Text with more than one number, like "2x 49.90", is not a value.',es:'Usa UN solo valor (ej.: 1500 o 1.500,00). Un texto con más de un número, como "2x 49,90", no es un valor.'},vdPixelOff:{pt:"O Pixel da Meta ainda não está configurado em:",en:"The Meta Pixel is not set up yet on:",es:"El PÃxel de Meta aún no está configurado en:"}
3,vdPixelHow:{pt:"Configure no Kanban: Editar coluna â Enviar a venda para a Meta â configurar.",en:"Set it up in the Kanban: Edit column â Send the sale to Meta â set up.",es:"Configúralo en el Kanban: Editar columna â Enviar la venta a Meta â configurar."},vdWait:{pt:"Esperar a equipe confirmar",en:"Wait for the team to confirm",es:"Esperar que el equipo confirme"},vdWaitHint:{pt:'O card vai para a coluna escolhida abaixo com o chip "confirmar venda". A compra só vai para a Meta quando alguém mover o card para uma coluna de conversão.',en:'The card goes to the column below with the "confirm sale" chip. The purchase only goes to Meta when someone moves the card to a conversion column.',es:'La tarjeta va a la columna de abajo con el chip "confirmar venta". La compra solo va a Meta cuando alguien mueve la tarjeta a una columna de conversión.'},vdWaitColumn:{pt:"Enquanto espera, mover para",en:"While waiting, move to",es:"Mientras espera, mover a"},vdWaitColumnHint:{pt:"Uma coluna antes da venda â coluna de conversão já é a venda confirmada.",en:"A column before the sale â a conversion column already is the confirmed sale.",es:"Una columna antes de la venta â la columna de conversión ya es la venta confirmada."},vdMissingIn:{pt:"Não é coluna de conversão em:",en:"Not a conversion column on:",es:"No es columna de conversión en:"},vdLoading:{pt:"Verificando o Kanban dos devicesâ¦",en:"Checking the devices' Kanbanâ¦",es:"Verificando el Kanban de los dispositivosâ¦"},vdNoDevice:{pt:"Escolha em Config os devices deste fluxo para listar as colunas.",en:"Choose this flow's devices in Settings to list the columns.",es:"Elige en Ajustes los dispositivos de este flujo para listar las columnas."},unknownNode:{pt:"Tipo de bloco desconhecido:",en:"Unknown block type:",es:"Tipo de bloque desconocido:"},brOutputs:{pt:"SaÃdas do bloco",en:"Block outputs",es:"Salidas del bloque"},tsLoadErr:{pt:"Erro ao carregar templates",en:"Error loading templates",es:"Error al cargar los templates"},tsLoading:{pt:"Carregando templates...",en:"Loading templates...",es:"Cargando templates..."},tsEmpty:{pt:"Nenhum template criado ainda",en:"No template created yet",es:"Ningún template creado todavÃa"},tsEmptyHint:{pt:"Templates são sequências de mensagens reutilizáveis (texto, mÃdia, com timing). Crie um pra usar aqui.",en:"Templates are reusable message sequences (text, media, with timing). Create one to use it here.",es:"Los templates son secuencias de mensajes reutilizables (texto, multimedia, con temporización). Crea uno para usarlo aquÃ."},tsCreateFirst:{pt:"Criar primeiro template",en:"Create first template",es:"Crear el primer template"},tsSearchPh:{pt:"Buscar template...",en:"Search template...",es:"Buscar template..."},tsRefresh:{pt:"Atualizar lista",en:"Refresh list",es:"Actualizar lista"},tsSelected:{pt:"SELECIONADO",en:"SELECTED",es:"SELECCIONADO"},tsUnselect:{pt:"Desmarcar",en:"Unselect",es:"Desmarcar"},tsSendOne:{pt:"envio",en:"send",es:"envÃo"},tsSendMany:{pt:"envios",en:"sends",es:"envÃos"},tsNoMatch:{pt:"Nenhum template bate com a busca.",en:"No template matches the search.",es:"Ningún template coincide con la búsqueda."},tsCreateNew:{pt:"Criar novo template",en:"Create new template",es:"Crear nuevo template"},tsWaits1:{pt:"Chatbot",en:"The chatbot",es:"El chatbot"},tsWaitsBold:{pt:"aguarda",en:"waits for",es:"espera a que"},tsWaits2:{pt:"todas as mensagens do template serem enviadas antes de seguir pro próximo bloco.",en:"all template messages to be sent before moving to the next block.",es:"todos los mensajes del template se envÃen antes de pasar al siguiente bloque."},tsVars1:{pt:"As",en:"The",es:"Las"},tsVarsToken:{pt:"variáveis",en:"variables",es:"variables"},tsVars2:{pt:"do fluxo são repassadas como contexto.",en:"from the flow are passed along as context.",es:"del flujo se pasan como contexto."},tpSec:{pt:"seg",en:"sec",es:"seg"},tpMin:{pt:"min",en:"min",es:"min"},tpHour:{pt:"h",en:"h",es:"h"},tpDay:{pt:"dia",en:"day",es:"dÃa"},tpDays:{pt:"dias",en:"days",es:"dÃas"},tp1min:{pt:"1 min",en:"1 min",es:"1 min"},tp5min:{pt:"5 min",en:"5 min",es:"5 min"},tp30min:{pt:"30 min",en:"30 min",es:"30 min"},tp1h:{pt:"1 h",en:"1 h",es:"1 h"},tp24h:{pt:"24 h",en:"24 h",es:"24 h"},upDefault:{pt:"Upload de arquivo",en:"Upload file",es:"Subir archivo"},upSending:{pt:"Enviandoâ¦",en:"Uploadingâ¦",es:"Subiendoâ¦"},upNoUrl:{pt:"Sem URL na resposta",en:"No URL in the response",es:"Sin URL en la respuesta"},trKeyword:{pt:"Palavra-chave",en:"Keyword",es:"Palabra clave"},trKeywordDesc:{pt:"Quando alguém envia uma palavra ou frase especÃfica",en:"When someone sends a specific word or phrase",es:"Cuando alguien envÃa una palabra o frase especÃfica"},trFirstMsg:{pt:"Primeira mensagem",en:"First message",es:"Primer mensaje"},trFirstMsgDesc:{pt:"Quando um contato novo manda a primeira mensagem",en:"When a new contact sends their first message",es:"Cuando un contacto nuevo envÃa su primer mensaje"}
3,trWebhook:{pt:"Webhook externo",en:"External webhook",es:"Webhook externo"},trWebhookDesc:{pt:"Disparado pelo seu sistema (e-commerce, CRM, etc.)",en:"Fired by your own system (e-commerce, CRM, etc.)",es:"Disparado por tu sistema (e-commerce, CRM, etc.)"},trHowStart:{pt:"Como este gatilho abre o fluxo?",en:"How does this trigger open the flow?",es:"¿Cómo abre el flujo este disparador?"},trDois:{pt:"Este fluxo tem 2 gatilhos: qualquer um deles abre o fluxo, e cada conversa começa pelo gatilho que casou. Ligue cada um ao bloco por onde a conversa deve começar â normalmente o mesmo primeiro bloco.",en:"This flow has 2 triggers: either one opens the flow, and each conversation starts from the trigger that matched. Connect each one to the block where the conversation should start â usually the same first block.",es:"Este flujo tiene 2 disparadores: cualquiera de los dos abre el flujo, y cada conversación empieza por el disparador que coincidió. Conecta cada uno al bloque donde debe empezar la conversación â normalmente el mismo primer bloque."},trDoisWebhooks:{pt:"O outro gatilho também é webhook â só pode haver um por fluxo. Troque o tipo de um dos dois.",en:"The other trigger is also a webhook â only one per flow. Change the type of one of them.",es:"El otro disparador también es webhook â solo puede haber uno por flujo. Cambia el tipo de uno de los dos."},trDica2:{pt:'Dica: um fluxo pode ter até 2 gatilhos. Ex.: "Veio do anúncio" + a palavra "menu" (Exato) para a pessoa recomeçar quando quiser â arraste outro Gatilho da paleta e ligue ao mesmo primeiro bloco.',en:'Tip: a flow can have up to 2 triggers. E.g. "Came from an ad" + the word "menu" (Exact) so people can restart whenever they want â drag another Trigger from the palette and connect it to the same first block.',es:'Consejo: un flujo puede tener hasta 2 disparadores. Ej.: "Vino del anuncio" + la palabra "menu" (Exacto) para que la persona vuelva a empezar cuando quiera â arrastra otro Disparador de la paleta y conéctalo al mismo primer bloque.'},trWebhookOcupado:{pt:"O outro gatilho deste fluxo já é o webhook (só pode haver um).",en:"The other trigger in this flow is already the webhook (only one allowed).",es:"El otro disparador de este flujo ya es el webhook (solo puede haber uno)."},eqFluxo:{pt:"Valem para o fluxo inteiro: os 2 gatilhos usam as mesmas regras (mudar aqui muda no outro).",en:"They apply to the whole flow: both triggers share the same rules (changing here changes the other).",es:"Valen para todo el flujo: los 2 disparadores usan las mismas reglas (cambiar aquà cambia el otro)."},trAnuncio:{pt:"Veio do anúncio",en:"Came from an ad",es:"Vino del anuncio"},trAnuncioDesc:{pt:"Só quando o contato chega por um anúncio especÃfico do Facebook/Instagram",en:"Only when the contact arrives from a specific Facebook/Instagram ad",es:"Solo cuando el contacto llega por un anuncio especÃfico de Facebook/Instagram"},adIntro:{pt:"Este gatilho abre o fluxo só para quem clicou num dos anúncios abaixo. Quem chegou por outro anúncio, ou sem anúncio, não entra por aqui â só pelo outro gatilho, se o fluxo tiver.",en:"This trigger opens the flow only for people who clicked one of the ads below. Anyone who came from another ad, or without an ad, does not come in this way â only through the other trigger, if the flow has one.",es:"Este disparador abre el flujo solo para quien hizo clic en uno de los anuncios de abajo. Quien llegó por otro anuncio, o sin anuncio, no entra por aquà â solo por el otro disparador, si el flujo tiene uno."},adListTitle:{pt:"Anúncios que já chegaram neste número",en:"Ads that already reached this number",es:"Anuncios que ya llegaron a este número"},adListEmpty:{pt:"Nenhum anúncio chegou neste número ainda. Cole o código do anúncio abaixo.",en:"No ad has reached this number yet. Paste the ad code below.",es:"TodavÃa no llegó ningún anuncio a este número. Pega el código del anuncio abajo."},adLoading:{pt:"Buscando os anúncios dos devicesâ¦",en:"Looking up the devicesâ adsâ¦",es:"Buscando los anuncios de los dispositivosâ¦"},adNoDevice:{pt:"Escolha em Config os devices deste fluxo para listar os anúncios.",en:"Pick this flowâs devices in Settings to list the ads.",es:"Elige en Ajustes los dispositivos de este flujo para listar los anuncios."},adFail:{pt:"Não deu para carregar os anúncios de: ",en:"Could not load the ads of: ",es:"No se pudieron cargar los anuncios de: "},adContatos:{pt:"contatos",en:"contacts",es:"contactos"},adManualTitle:{pt:"Anúncio que ainda não chegou? Cole o código",en:"Ad that has not arrived yet? Paste its code",es:"¿Anuncio que todavÃa no llegó? Pega el código"},adManualHint:{pt:"à o ID do anúncio no Gerenciador de Anúncios da Meta (só letras, números, _ e -). Aparece aqui como código até o primeiro contato chegar por ele.",en:"It is the ad ID from Meta Ads Manager (letters, numbers, _ and - only). It shows here as a code until the first contact arrives through it.",es:"Es el ID del anuncio en el Administrador de Anuncios de Meta (solo letras, números, _ y -). Aparece aquà como código hasta que llegue el primer contacto por él."},adManualAdd:{pt:"Adicionar",en:"Add",es:"Agregar"},adManualBad:{pt:"Código inválido: use de 3 a 64 caracteres entre letras, números, _ e -.",en:"Invalid code: use 3 to 64 characters among letters, numbers, _ and -.",es:"Código inválido: usa de 3 a 64 caracteres entre letras, números, _ y -."},adSelected:{pt:"Anúncios escolhidos",en:"Chosen ads",es:"Anuncios elegidos"},adNoneChosen:{pt:"Escolha ao menos um anúncio â sem isso o fluxo não publica.",en:"Pick at least one ad â without it the flow will not publish.",es:"Elige al menos un anuncio â sin eso el flujo no se publica."},adEmOutro:{pt:"também abre",en:"also opens",es:"también abre"},adConflito:{pt:"{anuncio} também abre o fluxo {fluxos}. Com o mesmo anúncio em dois fluxos, quem clica entra no que foi publicado há mais tempo â deixe cada anúncio em um fluxo só.",en:"{anuncio} also opens the flow {fluxos}. With the same ad in two flows, whoever clicks goes into the one published longest ago â keep each ad in a single flow.",es:"{anuncio} también abre el flujo {fluxos}. Con el mismo anuncio en dos flujos, quien hace clic entra en el que se publicó hace más tiempo â deja cada anuncio en un solo flujo."},pubAvisoAnuncio:{pt:"Publicado. Atenção: anúncio deste fluxo também abre {fluxos} â quem clica entra no fluxo publicado há mais tempo.",en:"Published. Heads up: an ad in this flow also opens {fluxos} â whoever clicks goes into the flow published longest ago.",es:"Publicado. Atención: un anuncio de este flujo también abre {fluxos} â quien hace clic entra en el flujo publicado hace más tiempo."},adOnce:{pt:"Só uma vez por contato",en:"Only once per contact",es:"Solo una vez por contacto"},adOnceDesc:{pt:"Quem já entrou neste fluxo â por qualquer gatilho â não entra de novo pelo anúncio, mesmo mandando outra mensagem por ele.",en:"Whoever already entered this flow â through any trigger â does not come in again through the ad, even sending another message through it.",es:"Quien ya entró en este flujo â por cualquier disparador â no vuelve a entrar por el anuncio, aunque mande otro mensaje por él."},adHowWorks:{pt:'Como funciona: a Pragmaz lê o anúncio que veio n
3a própria mensagem (clique para WhatsApp) e abre o fluxo. Quem já está no fluxo continua de onde parou, mesmo clicando no anúncio de novo. Quem já terminou só entra de novo com um novo clique no anúncio (uma resposta qualquer não abre). Para a pessoa recomeçar quando quiser, adicione um 2º gatilho de palavra-chave (ex.: "menu", Exato) ligado ao mesmo primeiro bloco.',en:'How it works: Pragmaz reads the ad that came in the message itself (click-to-WhatsApp) and starts the flow. Someone already in the flow carries on where they are, even if they click the ad again. Someone who already finished only gets back in with a new click on the ad (a regular reply does not open it). To let people restart whenever they want, add a 2nd keyword trigger (e.g. "menu", Exact) connected to the same first block.',es:'Cómo funciona: Pragmaz lee el anuncio que vino en el propio mensaje (clic a WhatsApp) y abre el flujo. Quien ya está en el flujo sigue donde estaba, aunque vuelva a hacer clic en el anuncio. Quien ya terminó solo vuelve a entrar con un nuevo clic en el anuncio (una respuesta cualquiera no lo abre). Para que la persona vuelva a empezar cuando quiera, agrega un 2º disparador de palabra clave (ej.: "menu", Exacto) conectado al mismo primer bloque.'},eqTitulo:{pt:"Quando alguém da equipe responder",en:"When someone on the team replies",es:"Cuando alguien del equipo responda"},eqHint:{pt:'Vale para resposta pelo painel, pelo celular e pelo WhatsApp Web. Evita o bot mandar "Não entendi" por cima de quem já está atendendo.',en:`Applies to replies from the panel, the phone and WhatsApp Web. Keeps the bot from sending "I didn't get that" over someone who is already handling the chat.`,es:'Vale para respuestas desde el panel, el celular y WhatsApp Web. Evita que el bot mande "No entendÃ" encima de quien ya está atendiendo.'},eqPausar:{pt:"Encerrar o fluxo e pausar o chatbot nesta conversa",en:"End the flow and pause the chatbot in this chat",es:"Terminar el flujo y pausar el chatbot en esta conversación"},eqPausarHint:{pt:"O bot só volta para esta pessoa depois do prazo â ou quando você clicar em Retomar no chat.",en:"The bot only comes back to this person after the period â or when you click Resume in the chat.",es:"El bot solo vuelve con esta persona después del plazo â o cuando hagas clic en Reanudar en el chat."},eqEncerrar:{pt:"Só encerrar o fluxo",en:"Only end the flow",es:"Solo terminar el flujo"},eqEncerrarHint:{pt:"A próxima mensagem que casar com um dos gatilhos abre o fluxo de novo.",en:"The next message matching one of the triggers starts the flow again.",es:"El próximo mensaje que coincida con uno de los disparadores abre el flujo de nuevo."},eqContinuar:{pt:"Continuar normalmente",en:"Keep going",es:"Continuar normalmente"},eqContinuarHint:{pt:"O bot segue esperando a resposta do contato, mesmo com a equipe na conversa.",en:"The bot keeps waiting for the contact, even with the team in the chat.",es:"El bot sigue esperando la respuesta del contacto, aunque el equipo esté en la conversación."},eqRecomendado:{pt:"recomendado",en:"recommended",es:"recomendado"},eqPor:{pt:"Por",en:"For",es:"Por"},eqHoras:{pt:"horas",en:"hours",es:"horas"},neTitulo:{pt:"Se o contato não escolher uma opção válida",en:"If the contact doesn't pick a valid option",es:"Si el contacto no elige una opción válida"},neHint:{pt:'Em vez de repetir "Não entendi" sem fim, o fluxo encerra ou transfere depois de N tentativas seguidas.',en:`Instead of repeating "I didn't get that" forever, the flow ends or hands off after N attempts in a row.`,es:'En vez de repetir "No entendÃ" sin fin, el flujo termina o transfiere después de N intentos seguidos.'},neDepois:{pt:"Depois de",en:"After",es:"Después de"},neTentativas:{pt:"tentativas seguidas",en:"attempts in a row",es:"intentos seguidos"},neEncerrar:{pt:"Encerrar o fluxo",en:"End the flow",es:"Terminar el flujo"},neTransferir:{pt:"Transferir para humano",en:"Hand off to a human",es:"Transferir a un humano"},neMsgPh:{pt:'Mensagem de despedida (opcional). Padrão: "Não consegui entender sua resposta. Vou encerrar por aquiâ¦"',en:`Farewell message (optional). Default: "I couldn't understand your reply. I'll stop hereâ¦"`,es:'Mensaje de despedida (opcional). Predeterminado: "No pude entender tu respuesta. Termino por aquÃâ¦"'},neZero:{pt:"0 = sem limite (o bot repete o aviso até o tempo da sessão acabar).",en:"0 = no limit (the bot repeats the notice until the session times out).",es:"0 = sin lÃmite (el bot repite el aviso hasta que se acabe el tiempo de la sesión)."},kwField:{pt:"Palavras ou frases que disparam",en:"Words or phrases that trigger it",es:"Palabras o frases que lo activan"},kwFieldHint:{pt:"Pressione Enter ou vÃrgula pra adicionar",en:"Press Enter or comma to add",es:"Presiona Enter o coma para añadir"},kwEmpty:{pt:"Nenhuma palavra ainda",en:"No word yet",es:"Ninguna palabra todavÃa"},kwPh:{pt:"Ex: oi, comprar, atendimento...",en:"Eg: hi, buy, support...",es:"Ej: hola, comprar, soporte..."},kwMatch:{pt:"Como combinar?",en:"How to match?",es:"¿Cómo coincidir?"},kwContains:{pt:"Contém",en:"Contains",es:"Contiene"},kwContainsHint:{pt:'Aceita "preciso de ajuda" se a palavra é "ajuda"',en:'Accepts "I need help" when the word is "help"',es:'Acepta "necesito ayuda" si la palabra es "ayuda"'},kwExact:{pt:"Exato",en:"Exact",es:"Exacto"},kwExactHint:{pt:"Só aceita exatamente a palavra/frase",en:"Accepts only the exact word/phrase",es:"Solo acepta exactamente la palabra o frase"},kwStarts:{pt:"Começa com",en:"Starts with",es:"Empieza con"},kwStartsHint:{pt:'Aceita "ajuda por favor"',en:'Accepts "help please"',es:'Acepta "ayuda por favor"'},kwRegex:{pt:"Regex (avançado)",en:"Regex (advanced)",es:"Regex (avanzado)"},kwRegexHint:{pt:"Padrão regex completo",en:"Full regex pattern",es:"Patrón regex completo"},kwCaseSensitive:{pt:"Diferenciar maiúsculas e minúsculas",en:"Case sensitive",es:"Distinguir mayúsculas y minúsculas"},kwOnce1:{pt:"Disparar apenas",en:"Trigger only",es:"Activar solo"},kwOnceBold:{pt:"uma vez por contato",en:"once per contact",es:"una vez por contacto"},kwOnceHint:{pt:'Se o contato já passou por este fluxo (por qualquer gatilho), a palavra não abre de novo (evita reenvio duplicado). Deixe desligado na palavra de recomeç
3o, como "menu".',en:'If the contact already went through this flow (through any trigger), the word will not open it again (avoids duplicate sends). Leave it off on a restart word like "menu".',es:'Si el contacto ya pasó por este flujo (por cualquier disparador), la palabra no lo abre de nuevo (evita reenvÃos duplicados). Déjalo apagado en la palabra para volver a empezar, como "menu".'},fmIntro1:{pt:"Este gatilho abre o fluxo",en:"This trigger opens the flow",es:"Este disparador abre el flujo"},fmIntroBold:{pt:"na primeira vez",en:"the first time",es:"la primera vez"},fmIntro2:{pt:"que um contato manda mensagem pra você. Perfeito pra mensagem de boas-vindas, qualificação inicial ou apresentação automática.",en:"a contact messages you. Perfect for a welcome message, initial qualification or an automatic introduction.",es:"que un contacto te escribe. Perfecto para un mensaje de bienvenida, calificación inicial o presentación automática."},fmWhen:{pt:"Quando considerar 'primeiro contato'?",en:"When should it count as 'first contact'?",es:"¿Cuándo considerar 'primer contacto'?"},fmNever:{pt:"Nunca conversamos antes",en:"We never talked before",es:"Nunca hablamos antes"},fmNeverDesc:{pt:"Só dispara se NUNCA houve troca de mensagens",en:"Fires only if there was NEVER a message exchange",es:"Solo se activa si NUNCA hubo intercambio de mensajes"},fm30:{pt:"Sem conversa há mais de 30 dias",en:"No conversation for over 30 days",es:"Sin conversación desde hace más de 30 dÃas"},fm30Desc:{pt:"Reativação: contato esquecido volta a falar",en:"Reactivation: a forgotten contact talks again",es:"Reactivación: un contacto olvidado vuelve a hablar"},fm90:{pt:"Sem conversa há mais de 90 dias",en:"No conversation for over 90 days",es:"Sin conversación desde hace más de 90 dÃas"},fm90Desc:{pt:"Reengajamento de contato antigo",en:"Re-engaging an old contact",es:"Reenganche de un contacto antiguo"},whIntro1:{pt:"Use quando o disparo do fluxo deve vir de",en:"Use this when the flow should be fired from",es:"Ãsalo cuando el disparo del flujo debe venir de"},whIntroBold:{pt:"fora",en:"outside",es:"fuera"},whIntro2:{pt:"â abandono de carrinho, mudança de pedido no e-commerce, novo lead no CRM, n8n, Zapier, etc. Seu sistema faz um POST e o chatbot dispara automaticamente.",en:"â cart abandonment, order change in your e-commerce, a new lead in the CRM, n8n, Zapier, etc. Your system does a POST and the chatbot fires automatically.",es:"â abandono de carrito, cambio de pedido en el e-commerce, nuevo lead en el CRM, n8n, Zapier, etc. Tu sistema hace un POST y el chatbot se dispara automáticamente."},whToken:{pt:"Token de autenticação",en:"Authentication token",es:"Token de autenticación"},whTokenHint:{pt:"Ãnico requisito de segurança â sem ele o webhook não funciona.",en:"The only security requirement â without it the webhook does not work.",es:"Ãnico requisito de seguridad â sin él el webhook no funciona."},whTokenPh:{pt:"Clique em 'Gerar token' abaixo â",en:"Click 'Generate token' below â",es:"Haz clic en 'Generar token' abajo â"},whTokenPlaceholderValue:{pt:"SEU_TOKEN_AQUI",en:"YOUR_TOKEN_HERE",es:"TU_TOKEN_AQUI"},whNoToken:{pt:"Sem token o webhook fica desativado (não dispara).",en:"Without a token the webhook stays disabled (it does not fire).",es:"Sin token el webhook queda desactivado (no se dispara)."},whGenNew:{pt:"Gerar novo token",en:"Generate new token",es:"Generar nuevo token"},whGen:{pt:"Gerar token aleatório (recomendado)",en:"Generate random token (recommended)",es:"Generar token aleatorio (recomendado)"},whUrl:{pt:"URL pra chamar (do seu sistema)",en:"URL to call (from your system)",es:"URL para llamar (desde tu sistema)"},whUrlHint:{pt:"Endpoint público â não precisa de login. Autenticação 100% pelo token acima.",en:"Public endpoint â no login needed. Authentication is 100% via the token above.",es:"Endpoint público â no necesita login. Autenticación 100% por el token de arriba."},whCurl:{pt:"Exemplo pronto pra copiar (cURL)",en:"Ready-to-copy example (cURL)",es:"Ejemplo listo para copiar (cURL)"},whBodyHelp:{pt:"Como funciona o body?",en:"How does the body work?",es:"¿Cómo funciona el body?"},whBodyP1a:{pt:"Você envia",en:"You send",es:"EnvÃas"},whBodyP1b:{pt:"(telefone do contato no formato WhatsApp) e opcionalmente",en:"(the contact phone in WhatsApp format) and optionally",es:"(el teléfono del contacto en formato WhatsApp) y opcionalmente"},whBodyP1c:{pt:"(variáveis que o fluxo pode usar com",en:"(variables the flow can use with",es:"(variables que el flujo puede usar con"},whBodyP2a:{pt:"Resposta:",en:"Response:",es:"Respuesta:"}
3,whBodyP2b:{pt:"Erros retornam",en:"Errors return",es:"Los errores devuelven"},whBodyP2c:{pt:"com HTTP 400/401/403/429.",en:"with HTTP 400/401/403/429.",es:"con HTTP 400/401/403/429."},whBodyP3:{pt:"Limite: 60 requisições por minuto por chatbot.",en:"Limit: 60 requests per minute per chatbot.",es:"LÃmite: 60 solicitudes por minuto por chatbot."},whIntegHelp:{pt:"Como integrar com n8n / Zapier / Make?",en:"How to integrate with n8n / Zapier / Make?",es:"¿Cómo integrar con n8n / Zapier / Make?"},whIntegA:{pt:'Adicione um bloco "HTTP Request" â método POST â a URL acima â header',en:'Add an "HTTP Request" node â POST method â the URL above â header',es:'Añade un bloque "HTTP Request" â método POST â la URL de arriba â header'},whIntegB:{pt:"com o token â body JSON com",en:"with the token â JSON body with",es:"con el token â body JSON con"},whIntegC:{pt:"do contato. Pronto.",en:"of the contact. Done.",es:"del contacto. Listo."},copy:{pt:"Copiar",en:"Copy",es:"Copiar"},copiedCheck:{pt:"â Copiado",en:"â Copied",es:"â Copiado"},sbPublished:{pt:"Publicado",en:"Published",es:"Publicado"},sbPaused:{pt:"Pausado",en:"Paused",es:"Pausado"},sbDraft:{pt:"Rascunho",en:"Draft",es:"Borrador"},msTitle:{pt:"Métricas do chatbot",en:"Chatbot metrics",es:"Métricas del chatbot"},msToday:{pt:"hoje",en:"today",es:"hoy"},msLast7:{pt:"últimos 7 dias",en:"last 7 days",es:"últimos 7 dÃas"},msLast30:{pt:"últimos 30 dias",en:"last 30 days",es:"últimos 30 dÃas"},msLast90:{pt:"últimos 90 dias",en:"last 90 days",es:"últimos 90 dÃas"},msLastYear:{pt:"último ano",en:"last year",es:"último año"},msPeopleServed:{pt:"Pessoas atendidas",en:"People served",es:"Personas atendidas"},msTriggers:{pt:"Acionamentos",en:"Triggers",es:"Activaciones"},msPersonIn:{pt:"pessoa entrou",en:"person entered",es:"persona entró"},msPeopleIn:{pt:"pessoas entraram",en:"people entered",es:"personas entraron"},msFiredOnce:{pt:"vez disparou",en:"time fired",es:"vez se disparó"},msFiredMany:{pt:"vezes disparou",en:"times fired",es:"veces se disparó"},msTriggerOne:{pt:"acionamento",en:"trigger",es:"activación"},msTriggerMany:{pt:"acionamentos",en:"triggers",es:"activaciones"},msTriggerTitle:{pt:"Total de vezes que o fluxo foi aberto pelos gatilhos (a mesma pessoa pode abrir várias)",en:"Total times the flow was opened by its triggers (the same person can open it several times)",es:"Total de veces que los disparadores abrieron el flujo (la misma persona puede abrirlo varias veces)"},msConvOne:{pt:"conversa",en:"conversation",es:"conversación"},msConvMany:{pt:"conversas",en:"conversations",es:"conversaciones"},msConvTitle:{pt:"Conversas distintas (uma pessoa pode ter várias)",en:"Distinct conversations (one person can have several)",es:"Conversaciones distintas (una persona puede tener varias)"},msMostClicked:{pt:"Mais clicado",en:"Most clicked",es:"Más clicado"},msClickOne:{pt:"clique",en:"click",es:"clic"},msClickMany:{pt:"cliques",en:"clicks",es:"clics"},msIn:{pt:"em",en:"in",es:"en"},msNextStep:{pt:"próximo passo",en:"next step",es:"próximo paso"},msMenu:{pt:"menu",en:"menu",es:"menú"},msDropOff:{pt:"Onde mais desistem",en:"Where most people drop off",es:"Dónde más abandonan"},msDropOne:{pt:"pessoa abandonou",en:"person dropped off",es:"persona abandonó"},msDropMany:{pt:"pessoas abandonaram",en:"people dropped off",es:"personas abandonaron"},msNoData:{pt:"Sem dados ainda neste perÃodo",en:"No data yet in this period",es:"Sin datos todavÃa en este perÃodo"},msRefresh:{pt:"Atualiza a cada 15s",en:"Refreshes every 15s",es:"Se actualiza cada 15s"},fsNodes:{pt:"blocos",en:"blocks",es:"bloques"},fsEdges:{pt:"conexões",en:"connections",es:"conexiones"},fsEntryOne:{pt:"inÃcio",en:"entry",es:"inicio"},fsEntryMany:{pt:"inÃcios",en:"entries",es:"inicios"},fsOrphanOne:{pt:"órfão",en:"orphan",es:"huérfano"},fsOrphanMany:{pt:"órfãos",en:"orphans",es:"huérfanos"}};function G(){const{locale:n}=ta(),o=v.useCallback(a=>(a==null?void 0:a[n])||(a==null?void 0:a.en)||(a==null?void 0:a.pt)||"",[n]);return{locale:n,tl:o}}const Zt=(n,o)=>String(n).replace("{n}",o),_s={flowNode:da};function Bs({id:n,sourceX:o,sourceY:a,targetX:s,targetY:r,sourcePosition:p,targetPosition:j,style:i,markerEnd:g,data:u,selected:l}){const[d,x,m]=xs({sourceX:o,sourceY:a,sourcePosition:p,targetX:s,targetY:r,targetPosition:j}),[b,w]=v.useState(!1),{tl:F}=G(),D=ia(),S=b||l,B=u==null?void 0:u.cfRota,W=B?D?"#4f46e5":"#a5b4fc":(i==null?void 0:i.stroke)||(D?"rgba(30,30,45,0.22)":"#6366f1"),T=D?"#6366f1":"#a5b4fc",P=u==null?void 0:u.order,N=(u==null?void 0:u.totalSiblings)||1;return e.jsxs(e.Fragment,{children:[e.jsx("path",{d,stroke:"transparent",strokeWidth:24,fill:"none",onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),style:{cursor:"pointer"}}),S&&e.jsx("path",{d,stroke:l?"#f43f5e":"#818cf8",strokeWidth:6,fill:"none",style:{opacity:.2,f
3ilter:"blur(3px)"},pointerEvents:"none"}),e.jsx(hs,{id:n,path:d,markerEnd:g,style:{...i,stroke:l?"#f43f5e":b?T:W,strokeWidth:S?2.25:B?3.25:(i==null?void 0:i.strokeWidth)||1.5,opacity:B===!1&&!S?.16:1,transition:"stroke 180ms ease, stroke-width 180ms ease, opacity 180ms ease"}}),N>1&&P&&!S&&e.jsx(Rt,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${x}px, ${m}px)`,pointerEvents:"none"},children:e.jsxs("div",{className:"flex items-center gap-1 bg-dark-900/95 backdrop-blur-sm border border-indigo-500/40 rounded-full px-2 py-0.5 shadow-lg",children:[e.jsxs("span",{className:"text-[9px] font-bold text-indigo-300",children:[P,"º"]}),e.jsxs("span",{className:"text-[8px] text-gray-500",children:["/",N]})]})})}),S&&e.jsx(Rt,{children:e.jsx("div",{style:{position:"absolute",transform:`translate(-50%, -50%) translate(${x}px, ${m}px)`,pointerEvents:"all"},onMouseEnter:()=>w(!0),onMouseLeave:()=>w(!1),children:e.jsxs("button",{onClick:f=>{var L;f.stopPropagation(),(L=u==null?void 0:u.onDelete)==null||L.call(u,n)},className:"group/del relative flex items-center justify-center",title:F(t.removeConnection),style:{animation:"edgeBtnIn 180ms cubic-bezier(0.34, 1.56, 0.64, 1)"},children:[e.jsx("span",{className:"absolute inset-0 rounded-full bg-rose-500/20 blur-md scale-150 opacity-0 group-hover/del:opacity-100 transition-opacity"}),e.jsx("span",{className:"relative w-7 h-7 rounded-full bg-dark-900/95 backdrop-blur-md border border-white/[0.12] group-hover/del:border-rose-400/70 group-hover/del:bg-rose-500/95 flex items-center justify-center shadow-[0_4px_16px_rgba(0,0,0,0.4)] transition-all duration-200 group-hover/del:scale-110",children:e.jsxs("svg",{width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",className:"text-gray-400 group-hover/del:text-white transition-colors",children:[e.jsx("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),e.jsx("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]})})})]})}const Hs={deletable:Bs};function En(){return e.jsx(Ga,{children:e.jsx(Rs,{})})}function Rs(){var Lt,Ot,It,_t;const{id:n}=bt(),o=Qa(),{locale:a}=ta(),s=c=>(c==null?void 0:c[a])||(c==null?void 0:c.en)||(c==null?void 0:c.pt)||"",[r,p]=v.useState(""),[j,i]=v.useState("draft"),[g,u,l]=Ua([]),[d,x,m]=Za([]),[b,w]=v.useState(null),[F,D]=v.useState(""),[S,B]=v.useState(!0),[W,T]=v.useState(!1),[P,N]=v.useState(!1),[f,L]=v.useState(!1),[$,K]=v.useState(0),V=v.useRef(null),[I,U]=v.useState(null),Q=ia(),[Z,ce]=v.useState(null),[oe,Ae]=v.useState(!1),[Be,Ne]=v.useState(!1),[qe,pe]=v.useState(!1),[Y,ue]=v.useState([]),[vt,yt]=v.useState(86400),[jt,Nt]=v.useState(""),[wt,kt]=v.useState(""),[we,ca]=v.useState([]),Ct=v.useMemo(()=>Y.length?we.filter(c=>Y.includes(c.session_id)):we,[Y,we]),rt=v.useRef(!0),[be,pa]=v.useState(!1),[Qe,ua]=v.useState(30),[Me,Et]=v.useState(null),{socket:ma}=Ya()||{},[He,xa]=Ja(),[fe,it]=v.useState(()=>!!(He.get("contato")||He.get("fases"))),[xe,re]=v.useState(()=>Number(He.get("contato"))||null),[te,ie]=v.useState(null),[Re,St]=v.useState({}),[De,lt]=v.useState(null),le=js({chatbotId:n,ativo:fe,socket:ma});v.useEffect(()=>{(He.get("contato")||He.get("fases"))&&xa({},{replace:!0})},[]);const[dt,ha]=v.useState(()=>{try{return localStorage.getItem("chatbotEditor:paletteCollapsed")==="1"?!0:typeof window<"u"&&window.matchMedia("(max-width:1023px)").matches}catch{return!1}});v.useEffect(()=>{try{localStorage.setItem("chatbotEditor:paletteCollapsed",dt?"1":"0")}catch{}},[dt]),v.useEffect(()=>{let c=!1;return(async()=>{var y,E;try{const[{data:A},q]=await Promise.all([ee.get(`/wa/chatbots/${n}`),ee.get("/wa/sessions?minimal=true").catch(()=>({data:{sessions:[]}}))]);if(c)return;p(A.chatbot.name),i(A.chatbot.status),Nt(A.chatbot.description||""),kt(A.chatbot.language||""),ue(Array.isArray(A.chatbot.allowed_sessions)?A.chatbot.allowed_sessions:[]),yt(A.chatbot.session_timeout_seconds||86400),K(A.chatbot.contacts_count||0),St(A.chatbot.fases||{}),ca(((y=q.data)==null?void 0:y.sessions)||[]);const H=((E=A.currentVersion)==null?void 0:E.graph)||{nodes:[],edges:[]};rt.current=!0,u((H.nodes||[]).map(_=>({..._,data:{..._.data,locale:a}}))),x(H.edges||[])}catch(A){c||(console.error(A),alert(s(t.notFound)),o("/dashboard/chatbots"))}finally{c||B(!1)}})(),()=>{c=!0}},[n,o,u,x,a]),v.useEffect(()=>{if(rt.current){rt.current=!1;return}Ae(!0)},[g,d]);const Tt=v.useRef(!1);v.useEffect(()=>{Tt.current||!I||S||g.length===0||(Tt.current=!0,requestAnimationFrame(()=>{try{I.fitView({padding:.25,maxZoom:.85,minZoom:.4,duration:400})}catch{}}))},[I,S,g.length]),v.useEffect(()=>{if(!oe||S)return;const c=setTimeout(()=>{Ve(!0)},3e3);return()=>clearTimeout(c)},[oe,g,d,S]);const Pt=v.useCallback(c=>{x(h=>h.filter(y=>y.id!==c))},[x]),ga=v.useCallback(c=>{const h=new Set(c.map(y=>y.id));x(y=>y.filter(E=>!h.has(E.source)&&!h.has(E.target))),w(y=>y&&h.has(y.id)?null:y)},[x]),At=v.useCallback(c=>{var E;const h=ze.current||[],y=h.find(A=>A.id===c);!y||((E=y.data)==null?void 0:E.type)==="template_entry"||Ee(y)&&mt(h).length<2||(u(A=>A.filter(q=>q.id!==c)),x(A=>A.filter(q=>q.source!==c&&q.target!==c)),w(A=>(A==null?void 0:A.id)===c?null:A))},[u,x]);v.useEffect(()=>{if(!be||!n){Et(null);return}let c=!1;const h=async()=>{try{const{data:E}=await ee.get(`/wa/chatbots/${n}/node-metrics?days=${Qe}`);c||Et(E)}catch(E){c||console.warn("[metrics]",E.message)}};h();const y=setInterval(h,15e3);return()=>{c=!0,clearInterval(y)}},[be,Qe,n]);const Ue=v.useMemo(()=>new Map(g.map(c=>[c.id,c])),[g]),ct=v.useMemo(()=>g.filter(Ns).map(c=>c.id).join("|"),[g]),ze=v.useRef(g);ze.current=g;const se=v.useMemo(()=>{var E,A;if(!fe)return null;const c=((E=le.dados)==null?void 0:E.porNo)||{},h={};for(const q of((A=le.dados)==null?void 0:A.contatos)||[])q.grupo==="agora"&&q.nodeId&&(h[q.nodeId]=h[q.nodeId]||[]).push(q);let y=null;if(xe&&te&&te.sessaoId===xe){const q=[],H=k=>{k&&q[q.length-1]!==k&&q.push(k)},_=ct?ct.split("|"):[];
3H(te.entrada&&_.includes(te.entrada)?te.entrada:_[0]);for(const k of te.passos||[])H(k.nodeId);H(te.nodeId);const R=new Map;q.forEach((k,M)=>{R.has(k)||R.set(k,[]),R.get(k).push(M+1)});const O=new Set;for(let k=1;k<q.length;k++)O.add(`${q[k-1]}>${q[k]}`);y={seq:q,passos:R,pares:O,atual:te.nodeId,ficha:te}}return{porNo:c,aguardando:h,rota:y}},[fe,le.dados,xe,te,ct]),pt=v.useCallback(c=>{const h=ze.current.find(y=>y.id===c);h&&(re(null),ie(null),lt(y=>({aba:"contatos",n:((y==null?void 0:y.n)||0)+1})),w(h))},[]),$e=v.useMemo(()=>ws(g),[g]),ba=v.useMemo(()=>g.map(c=>{var y,E,A;const h={...c.data,onDelete:At};if(Ee(c)&&(h.gatilhoOrdem=$e.get(c.id)||1,h.gatilhoTotal=$e.size),h.fase=Re[c.id]?{coluna:Re[c.id]}:null,h.onFase=pt,se){const q=se.rota;if(q){const H=c.id===q.atual,_=q.ficha;h.cf={estado:H?"aqui":q.passos.has(c.id)?"passou":"apagado",passo:q.passos.get(c.id)||null,aqui:H?{nome:_.nome||_.telefone||"",avatar:_.avatar,ativo:_.status==="active",texto:_.status==="active"?s(Te.aguardandoHa).replace("{t}",ks(_.ultimaEm)):_.status==="completed"?s(Te.fimAqui):_.status==="timeout"?s(Te.timeoutAqui):s(Te.saiuAqui)}:null}}else{const H=se.porNo[c.id]||{},_=se.aguardando[c.id]||[];h.cf={aguardando:H.aguardando||0,passaram:H.passaram||0,avatares:_.slice(0,3).map(R=>({nome:R.nome||R.telefone||"",avatar:R.avatar})),inicio:((y=c.data)==null?void 0:y.type)==="trigger"||((E=c.data)==null?void 0:E.type)==="template_entry"}}h.onCfBloco=pt}else h.cf=null;if(be&&Me){h.metrics=Me.byNode[c.id]||null;const q=Me.byBranch[c.id]||[];if(q.length){const H={};for(const O of q)H[O.next_node]=(H[O.next_node]||0)+O.clicks;const _={};for(const O of d){if(O.source!==c.id)continue;const k=(O.sourceHandle||"").match(/^out-(\d+)$/);if(k){const M=parseInt(k[1],10);_[M]=(_[M]||0)+(H[O.target]||0)}}const R=Object.values(_).reduce((O,k)=>O+(k||0),0);h.metricsBranches={byIdx:_,byDest:H,totalForGroup:R}}else h.metricsBranches={byIdx:{},byDest:{},totalForGroup:0}}else h.metrics=null,h.metricsBranches=null;return{...c,data:h,deletable:((A=c.data)==null?void 0:A.type)!=="template_entry"}}),[g,d,At,be,Me,Re,se,pt,a,$e]),fa=v.useCallback(c=>{x(h=>Xa({...c,type:"deletable",animated:!0,style:{stroke:"#6366f1"},markerEnd:{type:Bt.ArrowClosed,color:"#6366f1"}},h))},[x]),va=v.useMemo(()=>{const c={};return d.forEach(h=>{const y=`${h.source}|${h.sourceHandle??""}`;c[y]||(c[y]=[]),c[y].push(h.id)}),d.map(h=>{const y=`${h.source}|${h.sourceHandle??""}`,E=c[y],A=E.indexOf(h.id)+1;return{...h,type:"deletable",data:{...h.data||{},onDelete:Pt,order:A,totalSiblings:E.length,cfRota:se!=null&&se.rota?se.rota.pares.has(`${h.source}>${h.target}`):null}}})},[d,Pt,se]);v.useEffect(()=>{const c=se==null?void 0:se.rota;!I||!c||!Ue.has(c.atual)||requestAnimationFrame(()=>{var h,y;try{const E=((h=V.current)==null?void 0:h.clientWidth)||600,A=((y=V.current)==null?void 0:y.clientHeight)||500,q=window.innerWidth<1024&&E-Math.min(400,E)>=240?Math.min(400,E):0,H=E-q,_=k=>{var X,ve;let M=1/0,ne=1/0,me=-1/0,J=-1/0;for(const ke of k){const Ce=I.getNode(ke);if(!Ce)continue;const Fa=((X=Ce.measured)==null?void 0:X.width)||250,La=((ve=Ce.measured)==null?void 0:ve.height)||120;M=Math.min(M,Ce.position.x),ne=Math.min(ne,Ce.position.y),me=Math.max(me,Ce.position.x+Fa),J=Math.max(J,Ce.position.y+La)}return{w:me-M,h:J-ne}},R=[c.atual];for(let k=c.seq.length-1;k>=0&&R.length<3;k--){const M=c.seq[k];if(R.includes(M)||!Ue.has(M))continue;const ne=_([...R,M]);if(ne.w*.5>H-180||ne.h*.5>A-200)break;R.push(M)}const O=R.length===1?.9:.45;I.fitView({nodes:R.map(k=>({id:k})),padding:q?{top:O,bottom:O,left:O,right:`${q+24}px`}:O,maxZoom:.85,minZoom:.3,duration:450})}catch{}})},[I,xe,te==null?void 0:te.sessaoId,te==null?void 0:te.nodeId]);const qt=v.useCallback(c=>{const h=V.current;h&&c&&h.style.setProperty("--cf-inv",String(Math.min(1/c,2.6)))},[]),ya=v.useCallback(c=>{c.preventDefault(),c.dataTransfer.dropEffect="move"},[]),ja=v.useCallback(c=>{var R;c.preventDefault();const h=c.dataTransfer.getData("application/reactflow-nodetype");if(!h||!I)return;const y=je[h];if(!y)return;const E=I.screenToFlowPosition({x:c.clientX,y:c.clientY}),A=ze.current||[],q=Je(h,A);if(q){he.error(s(Ke[q]));return}const H=h==="trigger"?mt(A)[0]:null,_={id:`n_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,type:"flowNode",position:E,data:{type:h,config:H?Wt(y.defaults,(R=H.data)==null?void 0:R.config,"keyword"):{...y.defaults},locale:a}};u(O=>h==="trigger"&&Je(h,O)?O:O.concat(_))},[I,u,a,s]),Na=v.useCallback((c,h)=>{re(null),ie(null),lt(null),w(h)},[]),wa=v.useCallback(()=>{w(null),re(null),ie(null)},[]);v.useEffect(()=>{if(!b&&!xe)return;const c=h=>{var E;if(h.key!=="Escape")return;const y=(((E=h.target)==null?void 0:E.tagName)||"").toLowerCase();y==="input"||y==="textarea"||y==="select"||(w(null),re(null),ie(null))};return window.addEventListener("keydown",c),()=>window.removeEventListener("keydown",c)},[b,xe]);const ut=v.useCallback((c,h)=>{if(!h)return null;const y=E=>typeof E=="string"?E:(E==null?void 0:E.text)||(E==null?void 0:E.label)||(E==null?void 0:E.title)||"";return c==="buttons"||c==="template_entry"?(h.buttons||[]).map(y):c==="choice"?(h.options||[]).map(y):c==="random"?(h.paths||[]).map(y):c==="list"?(h.sections||[]).flatMap(E=>(E.rows||[]).map(y)):null},[]),ka=v.useCallback(c=>{var R,O;if(!b)return;const h=(R=b.data)==null?void 0:R.type,y=((O=b.data)==null?void 0:O.config)||{},E={...y,...c},A=ut(h,y),q=ut(h,E);if(A&&q&&(A.length!==q.length||A.some((k,M)=>k!==q[M]))){const k=me=>String(me||"").trim().toLowerCase(),M=new Array(q.length).fill(!1),ne=new Map;A.forEach((me,J)=>{let X=q.findIndex((ve,ke)=>!M[ke]&&k(ve)===k(me)&&k(me)!=="");X<0&&J<q.length&&k(A[J])===k(q[J])&&(X=J),X>=0&&(M[X]=!0),ne.set(J,X>=0?X:null)}),x(me=>me.reduce((J,X)=>{if(X.source!==b.id||!X.sourceHandle)return J.push(X),J;const ve=/^out-(\d+)$/.exec(X.sourceHandle);if(!ve)return J.push(X),J;
3const ke=ne.get(parseInt(ve[1],10));return ke==null||J.push(ke===parseInt(ve[1],10)?X:{...X,sourceHandle:`out-${ke}`}),J},[]))}const _=h==="trigger"&&Kt.some(k=>k in c)?Object.fromEntries(Kt.map(k=>[k,E[k]])):null;u(k=>k.map(M=>{var ne;return M.id===b.id?{...M,data:{...M.data,config:E}}:_&&Ee(M)?{...M,data:{...M.data,config:{...((ne=M.data)==null?void 0:ne.config)||{},..._}}}:M})),w(k=>k&&{...k,data:{...k.data,config:{...k.data.config,...c}}})},[b,u,x,ut]),Ca=v.useCallback(()=>{var c;!b||((c=b.data)==null?void 0:c.type)==="template_entry"||(u(h=>h.filter(y=>y.id!==b.id)),x(h=>h.filter(y=>y.source!==b.id&&y.target!==b.id)),w(null))},[b,u,x]),Ea=v.useCallback(()=>{var q,H,_,R,O;if(!b||((q=b.data)==null?void 0:q.type)==="template_entry")return;const c=ze.current||[],h=c.find(k=>k.id===b.id)||b,y=Ee(h);if(y){const k=Je("trigger",c);if(k){he.error(s(Ke[k]));return}}const E=((H=h.data)==null?void 0:H.config)||{},A={id:`n_${Date.now()}_${Math.random().toString(36).slice(2,7)}`,type:h.type,position:{x:(((_=h.position)==null?void 0:_.x)||0)+60,y:(((R=h.position)==null?void 0:R.y)||0)+60},data:{type:(O=h.data)==null?void 0:O.type,config:y?Wt(je.trigger.defaults,E,E.triggerType||"keyword"):JSON.parse(JSON.stringify(E)),locale:a}};u(k=>y&&Je("trigger",k)?k:k.concat(A))},[b,u,s,a]),Ve=async(c=!1)=>{c||T(!0);try{const h=g.map(y=>({id:y.id,type:y.type,position:y.position,data:{type:y.data.type,config:y.data.config}}));return await ee.put(`/wa/chatbots/${n}/graph`,{graph:{nodes:h,edges:d}}),ce(new Date),Ae(!1),c||setTimeout(()=>ce(null),2500),!0}catch(h){return c||alert(s(t.errSave)),console.error(h),!1}finally{T(!1)}},Sa=async(c,h)=>{var A;oe&&await Ve(!0);const{data:y}=await ee.put(`/wa/chatbots/${n}/fases`,{nodeId:c,coluna:h}),E=(A=y==null?void 0:y.fases)==null?void 0:A[c];St(q=>{const H={...q};return E?H[c]=E:delete H[c],H})},Mt=async()=>{oe&&await Ve(!0)},Ta=async c=>{try{await ee.patch(`/wa/chatbots/${n}`,{name:c})}catch{}},Pa=async()=>{var c,h;try{await ee.patch(`/wa/chatbots/${n}`,{description:jt,language:wt||null,allowedSessions:Array.isArray(Y)?Y:[],sessionTimeoutSeconds:parseInt(vt)||86400}),pe(!1),ce(new Date),setTimeout(()=>ce(null),2500)}catch(y){alert(((h=(c=y.response)==null?void 0:c.data)==null?void 0:h.error)||s(t.errSaveSettings))}},Dt=c=>{const h=c&&g.find(y=>y.id===c);if(h){re(null),ie(null),lt(y=>({aba:"content",n:((y==null?void 0:y.n)||0)+1})),w(h);try{I==null||I.fitView({nodes:[{id:h.id}],padding:.9,maxZoom:.85,duration:400})}catch{}}},Aa=async()=>{var h,y,E,A,q,H,_,R;Ne(!1);const c=Ps(g,d);if(c){he.error(s(Ke[c.code]||t.errPublish)),Dt(c.node);return}N(!0);try{if(!await Ve(!0)){he.error(s(t.errSave));return}const{data:O}=await ee.post(`/wa/chatbots/${n}/publish`),k=((O==null?void 0:O.avisos)||[]).find(M=>M.code==="anuncio_em_outro_fluxo");k&&he(s(t.pubAvisoAnuncio).replace("{fluxos}",(k.fluxos||[]).map(M=>`«${M.name}»`).join(", ")),{icon:"â ï¸",duration:9e3}),i("active"),ce(new Date),setTimeout(()=>ce(null),3e3)}catch(O){const k=(y=(h=O.response)==null?void 0:h.data)==null?void 0:y.code;if(k==="plan_limit"||k==="trial_limit")return;if(Ke[k]){he.error(s(Ke[k])),Dt((A=(E=O.response)==null?void 0:E.data)==null?void 0:A.node);return}alert(((H=(q=O.response)==null?void 0:q.data)==null?void 0:H.message)||((R=(_=O.response)==null?void 0:_.data)==null?void 0:R.error)||s(t.errPublish))}finally{N(!1)}},qa=()=>Ne(!0),$t=async()=>{var c,h;try{const y=j==="active"?"pause":"resume";await ee.post(`/wa/chatbots/${n}/${y}`),i(j==="active"?"paused":"active")}catch(y){alert(((h=(c=y.response)==null?void 0:c.data)==null?void 0:h.error)||s(t.errGeneric))}},Ma=async()=>{var c;if(!f){L(!0);try{const{data:h}=await ee.get(`/wa/chatbots/${n}/contacts`),y=(h==null?void 0:h.contacts)||[];if(!y.length){he(s(t.exportEmpty),{icon:"ð"});return}const E={completed:s(t.stCompleted),active:s(t.stActive),cancelled:s(t.stCancelled),timeout:s(t.stTimeout),failed:s(t.stFailed)},A=M=>M?new Date(M).toLocaleString("pt-BR",{timeZone:"America/Sao_Paulo"}):"",q=M=>M.completed?"read":M.last_status==="active"?"sent":M.last_status==="failed"?"failed":"skipped",H=[{header:s(t.colName),width:26},{header:s(t.colPhone),width:18},{header:s(t.colKeyword),width:22},{header:s(t.colEntry),width:20},{header:s(t.colDevice),width:28},{header:s(t.colTimes),width:15},{header:s(t.colFinished),width:15},{header:s(t.colStatus),width:15},{header:s(t.colFirst),width:20},{header:s(t.colLast),width:20},{header:s(t.colSaved),width:15}],_=y.map(M=>
3({style:q(M),values:[M.name||s(t.noNameSaved),M.phone||"",M.keyword||"",M.entry?s(an[M.entry]||{pt:M.entry}):"",M.device||"",String(M.sessions||1),M.completed?s(t.yes):s(t.no),E[M.last_status]||M.last_status||"",A(M.first_at),A(M.last_at),M.saved?s(t.yes):s(t.no)]})),R=((c=h==null?void 0:h.chatbot)==null?void 0:c.name)||r||"chatbot",O=bs({sheetName:R.slice(0,31),columns:H,rows:_}),k=document.createElement("a");k.href=URL.createObjectURL(new Blob([O],{type:fs})),k.download=`${s(t.exportFilePrefix)}_${R.replace(/[^a-zA-Z0-9]+/g,"_").slice(0,40)||"chatbot"}.xlsx`,document.body.appendChild(k),k.click(),k.remove(),setTimeout(()=>URL.revokeObjectURL(k.href),5e3),he.success(Zt(s(t.exportOk),y.length))}catch(h){console.warn("[export contacts]",h.message),he.error(s(t.exportErr))}finally{L(!1)}}};if(S)return e.jsx("div",{className:"flex items-center justify-center h-[calc(100vh-64px)]",children:e.jsx(es,{})});const Ze=g.find(c=>{var h;return((h=c.data)==null?void 0:h.type)==="template_entry"}),We=!!Ze,Da=((Ot=(Lt=Ze==null?void 0:Ze.data)==null?void 0:Lt.config)==null?void 0:Ot.wabaId)||null,Ft=We?we.filter(c=>(c.provider_type==="cloud_api"||c.provider_type==="coexistence")&&c.waba_id===Da):[],$a=We||mt(g).length>=Gt;return e.jsxs("div",{className:"cbe -m-6 h-[calc(100vh-64px)] flex flex-col bg-dark-900 overflow-hidden",children:[e.jsxs("div",{className:"h-14 max-lg:h-auto max-lg:min-h-14 max-lg:flex-wrap max-lg:py-2 border-b border-white/[0.07] bg-dark-900/95 backdrop-blur flex items-center px-4 gap-3 z-10 flex-shrink-0",children:[e.jsx("button",{onClick:()=>o("/dashboard/chatbots"),className:"p-2 hover:bg-dark-800 rounded-lg text-gray-400",children:e.jsx(ts,{size:16})}),e.jsxs("div",{className:"flex items-center gap-2 flex-1 min-w-0",children:[e.jsx(at,{className:"text-indigo-400 flex-shrink-0",size:16}),e.jsx("input",{type:"text",value:r,onChange:c=>p(c.target.value),onBlur:()=>Ta(r),className:"bg-transparent text-base font-semibold text-gray-100 outline-none border-b border-transparent hover:border-white/10 focus:border-indigo-500 transition-colors px-1 min-w-0 flex-1 max-w-md"}),e.jsx(hn,{status:j}),W&&e.jsx("span",{className:"text-[10px] text-gray-400 ml-2",children:s(t.savingDots)}),!W&&Z&&e.jsxs("span",{className:"text-[10px] text-emerald-400 flex items-center gap-1 ml-2",children:[e.jsx(st,{size:10})," ",s(t.saved)]}),oe&&!W&&!Z&&e.jsx("span",{className:"text-[11px] text-gray-400 ml-2",children:s(t.unsaved)})]}),e.jsxs("div",{className:"flex items-center gap-2 max-lg:w-full max-lg:flex-wrap max-lg:justify-end",children:[e.jsxs("button",{onClick:()=>pe(!0),className:"px-3 py-2 text-[13.5px] font-medium text-gray-300 hover:bg-dark-800 rounded-lg flex items-center gap-2",title:s(t.settingsHint),children:[e.jsx(as,{size:15})," ",s(t.settingsBtn),Y.length>0&&e.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 rounded-full text-[10px] font-semibold bg-indigo-500/20 text-indigo-300",children:Y.length})]}),e.jsxs("button",{onClick:()=>{it(c=>!c),re(null),ie(null)},className:`px-3 py-2 text-[13.5px] font-medium rounded-lg flex items-center gap-2 transition-colors ${fe?"bg-indigo-500/15 text-indigo-300 hover:bg-indigo-500/25":"text-gray-300 hover:bg-dark-800"}`,title:s(Te.botaoHint),children:[e.jsx(gt,{size:15})," ",e.jsx("span",{className:"max-xl:hidden",children:s(Te.botao)}),fe&&le.dados&&e.jsx("span",{className:"px-1.5 py-0.5 rounded-full text-[10px] font-semibold bg-indigo-500/20 text-indigo-300 tabular-nums",children:((It=le.dados.contagens)==null?void 0:It.todos)??le.dados.total})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsxs("button",{onClick:()=>pa(c=>!c),className:`px-3 py-2 text-[13.5px] font-medium rounded-lg flex items-center gap-2 transition-colors ${be?"bg-indigo-500/15 text-indigo-300 hover:bg-indigo-500/25":"text-gray-300 hover:bg-dark-800"}`,title:s(be?t.metricsOff:t.metricsShow),children:[e.jsx(aa,{size:15})," ",s(t.metrics)]}),be&&e.jsxs("select",{value:Qe,onChange:c=>ua(parseInt(c.target.value,10)),className:"px-2 py-2 text-[13px] bg-dark-800 text-gray-300 border border-white/10 rounded-lg focus:outline-none focus:border-indigo-500/50",children:[e.jsx("option",{value:1,children:s(t.today)}),e.jsx("option",{value:7,children:"7d"}),e.jsx("option",{value:30,children:"30d"}),e.jsx("option",{value:90,children:"90d"}),e.jsx("option",{value:365,children:s(t.oneYear)})]})]}),e.jsxs("button",{onClick:Ma,disabled:f||!$,className:"px-3 py-2 text-[13.5px] font-medium text-gray-300 hover:bg-dark-800 rounded-lg flex items-center gap-2 disabled:opacity-40 disabled:cursor-not-allowed disabled:hover:bg-transparent",title:s($?t.exportHint:t.exportNothing),children:[e.jsx(ss,{size:15})," ",f?"...":`${s(t.exportContacts)}${$?` (${$})`:""}`]}),e.jsxs("button",{onClick:()=>Ve(!1),disabled:W,className:"px-3 py-2 text-[13.5px] font-medium text-gray-300 hover:bg-dark-800 rounded-lg flex items-center gap-2 disabled:opacity-50",children:[e.jsx(ns,{size:15})," ",s(t.save)]}),j==="active"&&e.jsxs("button",{onClick:$t,className:"px-3 py-2 text-[13.5px] font-medium text-gray-300 hover:bg-white/[0.05] border border-white/10 rounded-lg flex items-center gap-2 transition-colors",children:[e.jsx(os,{size:15})," ",s(t.pause)]}),j==="paused"&&e.jsxs("button",{onClick:$t,className:"px-3 py-1.5 text-xs text-emerald-300 hover:bg-emerald-500/10 rounded-lg flex items-center gap-1.5",children:[e.jsx(rs,{size:12})," ",s(t.activate)]}),e.jsxs(is,{size:"sm",onClick:qa,disabled:P,children:[e.jsx(ht,{size:12})," ",P?"...":s(t.publish)]})]})]}),e.jsxs("div",{className:"flex flex-1 overflow-hidden max-lg:relative",children:[fe?e.jsx(Cs,{cf:le,selecionado:xe,onSelecionar:c=>{w(null),ie(null),re(c)},onFechar:()=>{it(!1),re(null),ie(null)},nodesById:Ue,onAbrirPagina:async()=>{await Mt(),o(`/dashboard/chatbots/${n}/contacts`)}}):e.jsx(zs,{search:F,setSearch:D,l:s,collapsed:dt,onToggleCollapsed:()=>ha(c=>!c),hideEntry:$a}),e.jsx("div",{className:"flex-1 relative",ref:V,children:e.jsxs(ls,{nodes:ba,edges:va,onNodesChange:l,onEdgesChange:m,onNodesDelete:ga,onConnect:fa,onInit:c=>{U(c);try{qt(c.getZoom())}catch{}},onMove:(c,h)=>qt(h==null?void 0:h.zoom),onDrop:ja,onDragOver:ya,onNodeClick:Na,onPaneClick:wa,nodeTypes:_s,edgeTypes:Hs,fitView:!0,fitViewOptions:{padding:.25,maxZoom:.85,minZoom:.4},proOptions:{hideAttribution:!0},minZoom:.2,maxZoom:1.8,deleteKeyCode:["Delete","Backspace"],defaultEdgeOptions:{type:"deletable",animated:!0,markerEnd:{type:Bt.ArrowClosed,color:"#6366f1"}},children:[e.jsx(ds,{color:Q?"#e7e9f2":"#27272a",gap:Q?24:22,size:Q?1:1.5,variant:"dots"}),e.jsx(cs,{className:"!bg-dark-800 !border-white/10 !rounded-lg [&>button]:!bg-dark-800 [&>button]:!border-white/10 [&>button]:!text-gray-300"}),e.jsx(ps,{nodeColor:c=>{var E;const h=je[(E=c.data)==null?void 0:E.type];return h&&{emerald:"#34d399",indigo:"#818cf8",cyan:"#22d3ee",violet:"#a78bfa",blue:"#60a5fa",rose:"#fb7185",gray:"#71717a",pink:"#818cf8",fuchsia:"#818cf8",teal:"#22d3ee",lime:"#22d3ee",sky:"#60a5fa",green:"#34d399",red:"#fb7185",amber:"#a78bfa",orange:"#a
378bfa",yellow:"#a78bfa"}[h.accent]||"#6366f1"},className:"!bg-dark-800/90 !border !border-white/10 !rounded-lg",maskColor:Q?"rgba(244,244,246,0.65)":"rgba(15,19,28,0.7)"}),e.jsx(Ht,{position:"top-left",className:"!m-3",children:e.jsx(bn,{nodes:g,edges:d})}),be&&Me&&e.jsx(Ht,{position:"top-right",className:"!m-3",children:e.jsx(gn,{metrics:Me,nodes:g,edges:d,days:Qe})})]})}),xe?e.jsx(Es,{chatbotId:n,sessaoId:xe,nodes:g,nodesById:Ue,fases:Re,aviso:le.aviso,onFechar:()=>{re(null),ie(null)},onTrocarSessao:c=>re(c),onMudou:le.recarregar,onFicha:ie,antesDeSair:Mt}):b&&e.jsx(Vs,{node:b,gatilho:Ee(b)?{ordem:$e.get(b.id)||1,total:$e.size,outros:g.filter(c=>Ee(c)&&c.id!==b.id).map(c=>{var h;return((h=c.data)==null?void 0:h.config)||{}})}:null,podeDuplicar:((_t=b.data)==null?void 0:_t.type)!=="template_entry"&&(!Ee(b)||!We&&$e.size<Gt),onUpdate:ka,onDelete:Ca,onDuplicate:Ea,onClose:()=>w(null),l:s,botSessions:Ct,abaInicial:(De==null?void 0:De.aba)||(fe?"contatos":"content"),abaVersao:(De==null?void 0:De.n)||0,contatosTab:e.jsx(Ss,{chatbotId:n,node:b,fases:Re,onSalvarFase:Sa,botSessions:Ct,onAbrirContato:c=>{it(!0),w(null),ie(null),re(c)},aviso:le.aviso,filtros:fe?le.filtros:null})})]}),Be&&e.jsxs(zt,{open:!0,onClose:()=>Ne(!1),title:s(t.publish),children:[e.jsx("p",{className:"text-sm text-gray-300 mb-4",children:s(t.publishAsk)}),(()=>{const c=g.filter(h=>{var y,E,A;return((y=h.data)==null?void 0:y.type)==="media"&&!((A=(E=h.data)==null?void 0:E.config)!=null&&A.url)});return c.length?e.jsxs("div",{className:"mb-4 rounded-lg border border-white/10 bg-white/[0.03] p-3",children:[e.jsx("div",{className:"text-[13px] font-semibold text-indigo-200 mb-1",children:c.length===1?s(t.mediaMissingOne):Zt(s(t.mediaMissingN),c.length)}),e.jsx("div",{className:"text-[12px] text-gray-400 leading-relaxed",children:s(t.mediaMissingHint)})]}):null})(),e.jsxs("div",{className:"flex gap-2 justify-end",children:[e.jsx("button",{onClick:()=>Ne(!1),className:"px-3 py-2 text-xs text-gray-300 hover:bg-dark-800 rounded-lg",children:s(t.cancel)}),e.jsxs("button",{onClick:Aa,className:"px-3 py-2 text-xs text-white bg-emerald-500 hover:bg-emerald-600 rounded-lg flex items-center gap-1.5",children:[e.jsx(ht,{size:12})," ",s(t.publish)]})]})]}),qe&&e.jsxs(zt,{open:!0,onClose:()=>pe(!1),title:s(t.settingsTitle),size:"lg",children:[e.jsxs("div",{className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-300 mb-1.5",children:s(t.description)}),e.jsx("textarea",{value:jt,onChange:c=>Nt(c.target.value),rows:2,placeholder:s(t.descriptionPh),className:"w-full bg-dark-800 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-100 placeholder-gray-500 outline-none focus:border-indigo-500"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-300 mb-1.5",children:s(t.botLang)}),e.jsxs("select",{value:wt,onChange:c=>kt(c.target.value),className:"w-full bg-dark-800 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-100 outline-none focus:border-indigo-500",children:[e.jsx("option",{value:"",children:s(t.botLangProfile)}),e.jsx("option",{value:"pt",children:s(t.botLangPt)}),e.jsx("option",{value:"en",children:s(t.botLangEn)}),e.jsx("option",{value:"es",children:s(t.botLangEs)}),e.jsx("option",{value:"auto",children:s(t.botLangAuto)})]}),e.jsx("p",{className:"text-[10px] text-gray-500 mt-1.5",children:s(t.botLangHint)})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"block text-xs font-medium text-gray-300 mb-1.5 flex items-center gap-2",children:[e.jsx(at,{size:11,className:"text-indigo-400"}),s(t.devicesLabel)]}),e.jsx("p",{className:"text-[10px] text-gray-500 mb-3",children:s(We?t.devicesTemplateHint:t.devicesHint)}),We?e.jsx("div",{className:"space-y-2",children:Ft.length===0?e.jsx("p",{className:"text-xs text-gray-400 bg-dark-800 border border-white/10 rounded-lg px-3 py-2",children:s(t.noWabaDevice)}):Ft.map(c=>e.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 rounded-lg border border-sky-500/40 bg-sky-500/10",children:[e.jsx(at,{size:11,className:"text-sky-400 shrink-0"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-gray-100 truncate",children:c.name||c.profile_name||c.phone||c.session_id}),e.jsxs("div",{className:"text-[10px] text-gray-500 font-mono",children:[c.p
3hone?`+${c.phone}`:c.session_id," · ",c.provider_type==="coexistence"?"Coex":"Cloud"]})]}),e.jsxs("span",{className:"text-[10px] text-sky-300 font-semibold shrink-0",children:["ð ",s(t.locked)]})]},c.session_id))}):we.length===0?e.jsx("p",{className:"text-[13px] text-gray-300 bg-white/[0.03] border border-white/10 rounded-lg px-3 py-2",children:s(t.noDevice)}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("label",{className:`flex items-center gap-3 px-3 py-2 rounded-lg border cursor-pointer transition-all ${Y.length===0?"bg-indigo-500/10 border-indigo-500/40 text-indigo-200":"bg-dark-800 border-white/10 hover:border-white/[0.16] text-gray-300"}`,children:[e.jsx("input",{type:"radio",checked:Y.length===0,onChange:()=>ue([]),className:"accent-indigo-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold",children:s(t.allDevices)}),e.jsx("div",{className:"text-[10px] text-gray-500",children:s(t.allDevicesHint)})]})]}),e.jsxs("label",{className:`flex items-center gap-3 px-3 py-2 rounded-lg border cursor-pointer transition-all ${Y.length>0?"bg-indigo-500/10 border-indigo-500/40 text-indigo-200":"bg-dark-800 border-white/10 hover:border-white/[0.16] text-gray-300"}`,children:[e.jsx("input",{type:"radio",checked:Y.length>0,onChange:()=>{var c;return Y.length===0&&ue([(c=we.find(h=>!h.waba_is_banned))==null?void 0:c.session_id].filter(Boolean))},className:"accent-indigo-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold",children:s(t.someDevices)}),e.jsx("div",{className:"text-[10px] text-gray-500",children:s(t.someDevicesHint)})]})]}),Y.length>0&&e.jsx("div",{className:"ml-6 space-y-1.5 pt-1",children:we.filter(c=>!c.waba_is_banned||Y.includes(c.session_id)).map(c=>{const h=Y.includes(c.session_id);return e.jsxs("label",{className:`flex items-center gap-3 px-3 py-2 rounded-lg border cursor-pointer transition-all ${h?"bg-emerald-500/10 border-emerald-500/40":"bg-dark-800/60 border-white/[0.09] hover:border-white/[0.16]"}`,children:[e.jsx("input",{type:"checkbox",checked:h,onChange:()=>{ue(y=>h?y.filter(E=>E!==c.session_id):[...y,c.session_id])},className:"accent-emerald-500"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-xs font-semibold text-gray-100 truncate",children:c.name||c.profile_name||c.phone||c.session_id}),e.jsxs("div",{className:"text-[10px] text-gray-500 font-mono",children:[c.phone?`+${c.phone}`:c.session_id,c.waba_is_banned?e.jsxs("span",{className:"ml-2 px-1.5 py-0.5 rounded bg-rose-500/15 text-rose-300",children:["â ",s(t.banned)]}):c.status&&e.jsx("span",{className:`ml-2 px-1.5 py-0.5 rounded ${c.status==="connected"?"bg-emerald-500/15 text-emerald-300":"bg-gray-500/15 text-gray-400"}`,children:c.status==="connected"?`â ${s(t.online)}`:`â ${s(t.offline)}`})]})]})]},c.session_id)})})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-xs font-medium text-gray-300 mb-1.5",children:s(t.sessionTimeout)}),e.jsx("p",{className:"text-[10px] text-gray-500 mb-2",children:s(t.sessionTimeoutHint)}),e.jsxs("select",{value:vt,onChange:c=>yt(parseInt(c.target.value)),className:"w-full bg-dark-800 border border-white/10 rounded-lg px-3 py-2 text-sm text-gray-100 outline-none focus:border-indigo-500",children:[e.jsx("option",{value:3600,children:s(t.h1)}),e.jsx("option",{value:10800,children:s(t.h3)}),e.jsx("option",{value:21600,children:s(t.h6)}),e.jsx("option",{value:43200,children:s(t.h12)}),e.jsx("option",{value:86400,children:s(t.h24rec)}),e.jsx("option",{value:259200,children:s(t.d3)}),e.jsx("option",{value:604800,children:s(t.d7)})]})]})]}),e.jsxs("div",{className:"flex gap-2 justify-end mt-6 pt-4 border-t border-white/[0.08]",children:[e.jsx("button",{onClick:()=>pe(!1),className:"px-3 py-2 text-xs text-gray-300 hover:bg-dark-800 rounded-lg",children:s(t.cancel)}),e.jsxs("button",{onClick:Pa,className:"px-3 py-2 text-xs text-white bg-indigo-500 hover:bg-indigo-600 rounded-lg flex items-center gap-1.5",children:[e.jsx(st,{size:12})," ",s(t.save)]})]})]})]})}function zs({search:n,setSearch:o,l:a,collapsed:s,onToggleCollapsed:r,hideEntry:p}){const{locale:j}=G(),i=(u,l)=>{u.dataTransfer.setData("application/reactflow-nodetype",l),u.dataTransfer.effectAllowed="move"},g=v.useMemo(()=>{const u=Ts.map(d=>({...d,types:d.types.filter(x=>{var m;return!((m=je[x])!=null&&m.hidden)&&!(p&&x==="trigger")})})).filter(d=>d.types.length>0);if(!n)return u;const l=n.toLowerCase();return u.map(d=>({...d,types:d.types.filter(x=>{const m=je[x];return a(m==null?void 0:m.label).toLowerCase().includes(l)||a(m==null?void 0:m.description).toLowerCase().includes(l)})})).filter(d=>d.types.length>0)},[n,p,j]);return s?e.jsxs("div",{className:"w-10 border-r border-white/[0.07] bg-dark-900/60 backdrop-blur flex-shrink-0 flex flex-col items-center py-3 gap-2",children:[e.jsx("button",{onClick:r,className:"w-7 h-7 rounded-lg bg-dark-800 hover:bg-indigo-500/20 text-gray-400 hover:text-indigo-300 flex items-center justify-center transition-colors",title:a(t.expandPalette),children:e.jsx(ot,{size:14})}),e.jsx("div",{className:"w-7 h-7 rounded-lg bg-dark-800/50 text-gray-400 flex items-center justify-center",title:a(t.nodes),children:e.jsx(us,{size:13})}),e.jsx("div",{className:"mt-2 text-[12px] text-gray-500 uppercase tracking-widest font-bold",style:{writingMode:"vertical-rl",transform:"rotate(180deg)"},children:a(t.nodes)})]}):e.jsxs("div",{className:"w-72 border-r border-white/[0.07] bg-dark-900/60 backdrop-blur flex-shrink-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"p-3 border-b border-white/[0.07]",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2.5",children:[e.jsx("div",{className:"text-[12px] font-bold uppercase tracking-wider text-gray-500",children:a(t.nodes)}),e.jsx("button",{onClick:r,className:"w-6 h-6 rounded text-gray-400 hover:text-gray-200 hover:bg-dark-800 flex items-center justify-center transition-colors",title:a(t.collapse),children:e.jsx(ms,{size:14})})]}),e.jsxs("div",{className:"relative",children:[e.jsx(sa,{className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-400",size:12}),e.jsx("input",{type:"text",placeholder:a(t.searchPh),value:n,onChange:u=>o(u.target.value),className:"w-full bg-dark-800 border border-white/10 rounded-lg pl-7 pr-2 py-1.5 text-[13px] text-gray-100 placeholder-gray-400 focus:outline-none focus:border-indigo-500"})]})]}),e.jsx("div",{className:"flex-1 overflow-y-auto p-3 space-y-4",children:g.map(u=>e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] font-bold uppercase tracking-wider text-gray-400 mb-2",children:a(u.label)}),e.jsx("div",{className:"space-y-2",children:u.types.map(l=>{const d=je[l],x=d.icon,m=nt[d.accent];return e.jsxs("div",{draggable:!0,onDragStart:b=>i(b,l),className:"group flex items-center gap-3 px-2.5 py-2.5 rounded-xl border border-white/10 bg-dark-800/60 hover:bg-dark-800 hover:border-white/[0.16] hover:-translate-y-
3px hover:shadow-[0_8px_20px_-14px_rgba(0,0,0,0.9)] cursor-grab active:cursor-grabbing transition-all",children:[e.jsx("div",{className:`w-9 h-9 rounded-lg flex items-center justify-center flex-shrink-0 ${m.bg} ${m.text}`,children:e.jsx(x,{size:18})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[14.5px] font-semibold text-gray-100 leading-tight truncate",children:a(d.label)}),e.jsx("div",{className:"text-[12.5px] text-gray-400 leading-snug truncate",children:a(d.description)})]}),e.jsxs("svg",{width:"15",height:"15",viewBox:"0 0 24 24",fill:"currentColor",className:"text-gray-500 opacity-0 group-hover:opacity-70 transition-opacity flex-shrink-0",children:[e.jsx("circle",{cx:"9",cy:"6",r:"1.3"}),e.jsx("circle",{cx:"9",cy:"12",r:"1.3"}),e.jsx("circle",{cx:"9",cy:"18",r:"1.3"}),e.jsx("circle",{cx:"15",cy:"6",r:"1.3"}),e.jsx("circle",{cx:"15",cy:"12",r:"1.3"}),e.jsx("circle",{cx:"15",cy:"18",r:"1.3"})]})]},l)})})]},u.key))}),e.jsx("div",{className:"p-3 border-t border-white/[0.07] text-[12px] text-gray-400 text-center",children:a(t.dragHint)})]})}function Vs({node:n,onUpdate:o,onDelete:a,onDuplicate:s,onClose:r,l:p,botSessions:j=[],abaInicial:i="content",abaVersao:g=0,contatosTab:u=null,gatilho:l=null,podeDuplicar:d=!0}){var W,T;const x=je[n.data.type],m=x.icon,b=nt[x.accent],w=n.data.config||{},F=((W=n.data)==null?void 0:W.type)==="template_entry",D=u&&i==="contatos"?"contatos":"content",[S,B]=v.useState(D);return v.useEffect(()=>{B(D)},[n.id,g]),e.jsxs("div",{className:"w-96 max-lg:absolute max-lg:z-30 max-lg:inset-y-0 max-lg:right-0 max-lg:w-full max-lg:max-w-[400px] max-lg:shadow-2xl border-l border-white/[0.07] bg-dark-900/60 backdrop-blur flex-shrink-0 flex flex-col overflow-hidden",children:[e.jsxs("div",{className:"px-5 py-4 border-b border-white/[0.07] bg-white/[0.02] relative",children:[e.jsx("button",{onClick:r,className:"absolute top-2 right-2 w-6 h-6 rounded text-gray-400 hover:text-gray-100 hover:bg-dark-800 flex items-center justify-center transition-colors",title:p(t.closeEsc),children:e.jsx(Pe,{size:14})}),e.jsxs("div",{className:"flex items-start gap-3 pr-6",children:[e.jsx("div",{className:`w-11 h-11 rounded-xl flex items-center justify-center flex-shrink-0 bg-white/[0.05] border border-white/10 ${b.text}`,children:e.jsx(m,{size:20})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wider font-semibold text-indigo-300",children:p(t.inspector)}),e.jsxs("div",{className:"text-[16px] font-semibold text-gray-100 leading-tight mt-0.5",children:[p(x.label),l&&l.total>1?` ${l.ordem}`:""]}),e.jsxs("div",{className:"text-[12px] text-gray-400 font-mono mt-0.5",children:["#",n.id]})]})]})]}),!F&&e.jsx("div",{className:`flex items-center gap-0.5 ${u?"px-3":"px-5"} pt-2.5 border-b border-white/[0.07] flex-shrink-0`,children:[...u?[["contatos",p(Te.abaContatos)]]:[],["content",p({pt:"Conteúdo",en:"Content",es:"Contenido"})],["advanced",p({pt:"Avançado",en:"Advanced",es:"Avanzado"})],["metrics",p({pt:"Métricas",en:"Metrics",es:"Métricas"})]].map(([P,N])=>e.jsxs("button",{onClick:()=>B(P),className:`relative h-9 ${u?"px-2.5":"px-3"} text-[13px] font-semibold rounded-t-lg transition-colors whitespace-nowrap ${S===P?"text-gray-100":"text-gray-500 hover:text-gray-300"}`,children:[N,S===P&&e.jsx("span",{className:"absolute left-2.5 right-2.5 -bottom-px h-0.5 rounded-full bg-indigo-500"})]},P))}),e.jsx("div",{className:"flex-1 overflow-y-auto px-5 py-4 space-y-4",children:!F&&S==="contatos"&&u?u:F||S==="content"?e.jsx(Qs,{node:n,cfg:w,onUpdate:o,colors:b,botSessions:j,gatilho:l}):S==="advanced"?e.jsx(Ks,{node:n,cfg:w,onUpdate:o}):e.jsx(Gs,{node:n})}),((T=n.data)==null?void 0:T.type)==="template_entry"?e.jsx("div",{className:"px-5 py-3.5 border-t border-white/[0.07] text-[12px] text-gray-400 text-center leading-relaxed",children:p({pt:"Bloco de inÃcio do fluxo â não pode ser removido nem duplicado.",en:"Flow entry block â cannot be removed or duplicated.",es:"Bloque de inicio â no se puede eliminar ni duplicar."})}):e.jsxs("div",{className:"px-5 py-3.5 border-t border-white/[0.07] flex gap-2",children:[d&&e.jsxs("button",{onClick:s,className:"flex-1 text-[13px] px-3 py-2 rounded-lg bg-dark-800 border border-white/10 hover:bg-dark-700 hover:border-white/15 text-gray-300 flex items-center justify-center gap-1.5 transition-colors",children:[e.jsx(oa,{size:12})," ",p(t.duplicateNode)]}),e.jsxs("button",{onClick:a,className:"flex-1 text-[13px] px-3 py-2 rounded-lg bg-rose-500/10 hover:bg-rose-500/[0.18] text-rose-300 border border-rose-500/20 flex items-center justify-center gap-1.5 transition-colors",children:[e.jsx(ra,{size:12})," ",p(t.deleteNode)]})]})]})}function Ws({cfg:n}){var p;const{tl:o}=G(),s=(((p=(Array.isArray(n.components)?n.components:[]).find(j=>String(j.type).toUpperCase()==="BUTTONS"))==null?void 0:p.buttons)||[]).filter(j=>String(j.type).toUpperCase()==="QUICK_REPLY"),r=({label:j,value:i})=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-gray-400",children:j}),e.jsx("span",{className:"text-gray-300 font-medium truncate ml-2",children:i||"â"})]});return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"rounded-lg border border-sky-500/30 bg-sky-500/[0.06] p-3",children:[e.jsxs("div",{className:"flex items-center gap-2 text-sky-300 text-[13px] font-semibold",children:[e.jsx(gs,{size:13})," ",o(t.teTitle)]}),e.jsx("div",{className:"mt-1 text-[13px] text-gray-400 leading-relaxed",children:o(t.teIntro)})]}),e.jsxs("div",{className:"text-[13px] space-y-1.5",children:[e.jsx(r,{label:o(t.teTemplate),value:n.templateName}),e.jsx(r,{label:o(t.teLanguage),value:n.language}),n.category&&e.jsx(r,{label:o(t.teCategory),value:n.category})]}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[12px] uppercase tracking-wider text-gray-400 mb-1.5",children:o(t.teButtons)}),e.jsxs("div",{className:"space-y-1",children:[s.map((j,i)=>e.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5 rounded border border-sky-500/25 bg-sky-500/[0.06] text-[13px]",children:[e.jsx(ea,{size:11,className:"text-sky-300 shrink-0"}),e.jsx("span",{className:"text-sky-200 flex-1 truncate",children:j.text}),e.jsxs("span",{className:"text-[12px] text-gray-400 font-mono",children:[o(t.teOutput)," #",i]})]},i)),s.length===0&&e.jsx("div",{className:"text-[13px] text-gray-400 italic",children:o(t.teNoButtons)})]})]}),e.jsxs("div",{className:"text-[12px] text-gray-400 leading-relaxed border-t border-white/[0.07] pt-2",children:[o(t.teFooter1)," ",e.jsx("b",{className:"text-gray-400",children:"Cloud/Coex"})," ",o(t.teFooter2)]})]})}
3function tt(n){return(n||0).toLocaleString(vs())}function Ks({node:n,cfg:o,onUpdate:a}){const{tl:s}=G(),[r,p]=v.useState(!1);return e.jsxs(e.Fragment,{children:[e.jsx(C,{label:s(t.advLabel),hint:s(t.advLabelHint),children:e.jsx(z,{value:o.label||"",onChange:j=>a({label:j}),placeholder:s(t.advLabelPh)})}),e.jsx(C,{label:s(t.advNote),hint:s(t.advNoteHint),children:e.jsx(de,{value:o.note||"",onChange:j=>a({note:j}),rows:2})}),e.jsxs("div",{className:"rounded-xl border border-white/[0.07] bg-dark-800/40 p-3.5",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-gray-500 font-semibold mb-2",children:s(t.advId)}),e.jsxs("button",{onClick:()=>{typeof navigator>"u"||!navigator.clipboard||navigator.clipboard.writeText(n.id).then(()=>{p(!0),setTimeout(()=>p(!1),1200)}).catch(()=>{})},className:"flex items-center gap-2 text-[12px] text-gray-300 font-mono hover:text-gray-100 transition-colors",children:[e.jsx("span",{className:"text-gray-500",children:"#"}),n.id,r?e.jsx("span",{className:"text-emerald-300 ml-1",children:s(t.advCopied)}):e.jsx(oa,{size:11,className:"ml-1 text-gray-500"})]})]})]})}function Gs({node:n}){var u,l;const{tl:o}=G(),a=(u=n.data)==null?void 0:u.metrics,s=(l=n.data)==null?void 0:l.metricsBranches;if(!a||!a.executions&&!a.unique_people)return e.jsxs("div",{className:"rounded-xl border border-white/[0.07] bg-dark-800/40 p-5 text-center",children:[e.jsx("div",{className:"text-[13px] font-semibold text-gray-200",children:o(t.mtNoData)}),e.jsxs("div",{className:"text-[12px] text-gray-400 mt-1.5 leading-relaxed",children:[o(t.mtNoDataHint1)," ",e.jsx("b",{className:"text-gray-300",children:o(t.mtSeeMetrics)})," ",o(t.mtNoDataHint2)]})]});const r=a.unique_people??a.executions??0,p=(a.failed||0)+(a.timeouts||0),j=[{label:o(t.mtPeople),value:tt(r)},{label:o(t.mtRuns),value:tt(a.executions||0)},{label:o(t.mtFails),value:tt(p)},{label:o(t.mtAvgTime),value:a.avg_ms?`${a.avg_ms}ms`:"â"}],i=(s==null?void 0:s.totalForGroup)||0,g=s!=null&&s.byIdx?Object.keys(s.byIdx).sort((d,x)=>d-x).map(d=>({idx:d,count:s.byIdx[d]||0})):[];return e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"grid grid-cols-2 gap-px rounded-xl overflow-hidden border border-white/[0.07] bg-white/[0.07]",children:j.map(d=>e.jsxs("div",{className:"bg-dark-900 p-3.5",children:[e.jsx("div",{className:"text-[11.5px] text-gray-400",children:d.label}),e.jsx("div",{className:"text-[22px] font-semibold text-gray-100 tabular-nums mt-1.5 leading-none tracking-tight",children:d.value})]},d.label))}),g.length>0&&e.jsxs("div",{className:"rounded-xl border border-white/[0.07] bg-dark-800/40 p-4",children:[e.jsx("div",{className:"text-[13px] font-semibold text-gray-100 mb-3",children:o(t.mtWhereGo)}),e.jsx("div",{className:"space-y-2.5",children:g.map(d=>{const x=i>0?Math.round(d.count/i*100):0;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex justify-between text-[12.5px] mb-1",children:[e.jsxs("span",{className:"text-gray-300",children:[o(t.mtOutput)," #",d.idx]}),e.jsxs("span",{className:"text-gray-400 tabular-nums",children:[x,"% · ",tt(d.count)]})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-dark-700 overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-gradient-to-r from-indigo-500 to-indigo-400",style:{width:`${x}%`}})})]},d.idx)})})]})]})}function Qs({node:n,cfg:o,onUpdate:a,colors:s,botSessions:r=[],gatilho:p=null}){var u;const{locale:j,tl:i}=G(),g=n.data.type;if(g==="trigger")return e.jsx(nn,{cfg:o,onUpdate:a,chatbotId:n.data.chatbotId,botSessions:r,gatilho:p});if(g==="template_entry")return e.jsx(Ws,{cfg:o});if(g==="message")return e.jsx(e.Fragment,{children:e.jsx(C,{label:i(t.msgText),hint:i(t.msgTextHint),children:e.jsx(de,{value:o.text||"",onChange:l=>a({text:l}),rows:6})})});if(g==="media")return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"rounded-xl border border-white/[0.07] bg-dark-800/40 p-3",children:[e.jsx("div",{className:"text-[11px] uppercase tracking-wider text-gray-500 font-semibold mb-2.5",children:i(t.mdPreview)}),e.jsx(la,{mediaType:o.mediaType,url:o.url,caption:o.caption,fileName:o.fileName,ptt:o.ptt,locale:((u=n.data)==null?void 0:u.locale)||j}),e.jsxs("div",{className:"flex gap-2 mt-3",children:[e.jsx(Yt,{label:o.url?i(t.mdSwap):i(t.mdSend),onUpload:l=>a({url:l})}),o.url&&e.jsxs("button",{onClick:()=>a({url:""}),className:"h-9 px-3 text-[13px] font-medium rounded-lg bg-dark-800 border border-white/10 text-gray-400 hover:text-rose-300 hover:border-rose-500/30 hover:bg-rose-500/[0.08] transition-colors flex items-center gap-1.5 flex-shrink-0",title:i(t.mdRemoveHint),children:[e.jsx(ra,{size:13})," ",i(t.remove)]})]})]}),e.jsx(C,{label:i(t.mdType),children:e.jsx(ae,{value:o.mediaType||"image",onCh
3ange:l=>a({mediaType:l}),options:[{v:"image",l:`ð¼ï¸ ${i(t.mdImage)}`},{v:"video",l:`ð¥ ${i(t.mdVideo)}`},{v:"audio",l:`ðµ ${i(t.mdAudioPtt)}`},{v:"document",l:`ð ${i(t.mdDocument)}`},{v:"sticker",l:`ð·ï¸ ${i(t.mdSticker)}`}]})}),o.mediaType!=="audio"&&o.mediaType!=="sticker"&&e.jsx(C,{label:i(t.mdCaption),hint:i(t.mdCaptionHint),children:e.jsx(de,{value:o.caption||"",onChange:l=>a({caption:l}),rows:2})}),o.mediaType==="document"&&e.jsx(C,{label:i(t.mdFileName),hint:i(t.mdFileNameHint),children:e.jsx(z,{value:o.fileName||"",onChange:l=>a({fileName:l}),placeholder:"catalogo.pdf"})}),o.mediaType==="audio"&&e.jsxs("label",{className:"flex items-center gap-2 text-[13px] text-gray-300",children:[e.jsx("input",{type:"checkbox",checked:o.ptt!==!1,onChange:l=>a({ptt:l.target.checked}),className:"accent-indigo-500"}),i(t.mdPttCheck)]}),e.jsxs("details",{className:"group rounded-xl border border-white/[0.07] bg-dark-800/40 overflow-hidden",children:[e.jsxs("summary",{className:"cursor-pointer list-none px-3 py-2.5 text-[12.5px] text-gray-400 hover:text-gray-200 flex items-center gap-2 transition-colors",children:[e.jsx(ot,{size:13,className:"transition-transform group-open:rotate-90 flex-shrink-0"}),i(t.mdSource)]}),e.jsxs("div",{className:"px-3 pb-3 pt-0.5 space-y-3",children:[e.jsx(C,{label:i(t.mdUrl),hint:i(t.mdUrlHint),children:e.jsx(z,{value:o.url||"",onChange:l=>a({url:l}),placeholder:i(t.mdUrlPh)})}),o.mediaType==="document"&&e.jsx(C,{label:"MIME type",hint:i(t.mdMimeHint),children:e.jsx(z,{value:o.mimetype||"",onChange:l=>a({mimetype:l}),placeholder:"application/pdf"})})]})]})]});if(g==="buttons"){const l=o.buttons||[],d=[{v:"none",icon:"â",label:i(t.btNoMedia)},{v:"image",icon:"ð¼ï¸",label:i(t.mdImage)},{v:"video",icon:"ð¥",label:i(t.mdVideo)},{v:"document",icon:"ð",label:i(t.mdDocument)},{v:"location",icon:"ð",label:i(t.btLocation)}],x=o.headerType||"none";return e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.btHeader),hint:i(t.btHeaderHint),children:e.jsx("div",{className:"grid grid-cols-5 gap-1",children:d.map(m=>e.jsxs("button",{type:"button",onClick:()=>a({headerType:m.v==="none"?null:m.v}),className:`flex flex-col items-center gap-1 px-1 py-2 rounded-lg border transition-all ${x===m.v?"bg-indigo-500/15 border-indigo-500/60 text-indigo-300":"bg-dark-800 border-white/10 text-gray-400 hover:border-white/[0.16] hover:text-gray-200"}`,children:[e.jsx("span",{className:"text-base leading-none",children:m.icon}),e.jsx("span",{className:"text-[12px] font-medium",children:m.label})]},m.v))})}),(o.headerType==="image"||o.headerType==="video"||o.headerType==="document")&&e.jsxs(C,{label:o.headerType==="image"?i(t.mdImage):o.headerType==="video"?i(t.mdVideo):i(t.mdDocument),children:[e.jsx(Yt,{onUpload:m=>a({headerUrl:m})}),e.jsx(z,{value:o.headerUrl||"",onChange:m=>a({headerUrl:m}),placeholder:i(t.btUrlPh)}),o.headerUrl&&o.headerType==="image"&&e.jsx("img",{src:o.headerUrl,alt:"preview",className:"mt-2 max-h-40 w-full rounded border border-white/10 object-cover",onError:m=>{m.target.style.display="none"}}),o.headerUrl&&o.headerType==="video"&&e.jsx("video",{src:o.headerUrl,controls:!0,className:"mt-2 max-h-40 w-full rounded border border-white/10"}),o.headerUrl&&o.headerType==="document"&&e.jsxs("div",{className:"mt-2 px-3 py-2 bg-dark-800 border border-white/10 rounded text-[13px] text-gray-400 flex items-center gap-2",children:[e.jsx("span",{children:"ð"}),e.jsx("span",{className:"truncate",children:o.headerUrl.split("/").pop()})]})]}),o.headerType==="document"&&e.jsx(C,{label:i(t.mdFileName),children:e.jsx(z,{value:o.headerFileName||"",onChange:m=>a({headerFileName:m}),placeholder:"catalogo.pdf"})}),o.headerType==="location"&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(C,{label:i(t.btLat),children:e.jsx(z,{type:"number",value:o.headerLat??"",onChange:m=>a({headerLat:parseFloat(m)||0}),placeholder:"-15.794"})}),e.jsx(C,{label:i(t.btLon),children:e.jsx(z,{type:"number",value:o.headerLon??"",onChange:m=>a({headerLon:parseFloat(m)||0}),placeholder:"-47.882"})})]}),e.jsx(C,{label:i(t.btPlaceName),children:e.jsx(z,{value:o.headerName||"",onChange:m=>a({headerName:m}),placeholder:"Pragmaz HQ"})}),e.jsx(C,{label:i(t.btAddress),children:e.jsx(z,{value:o.headerAddress||"",onChange:m=>a({headerAddress:m}),placeholder:i(t.btAddressPh)})})]}),e.jsx(C,{label:i(t.btQuestion),children:e.jsx(de,{value:o.text||"",onChange:m=>a({text:m}),rows:3})}),e.jsx(C,{label:i(t.btFooter),children:e.jsx(z,{value:o.footer||"",onChange:m=>a({footer:m}),placeholder:i(t.btFooterPh)})}),e.jsxs(C,{label:i(t.btButtons),children:[l.map((m,b)=>e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx(z,{value:m,onChange:w=>{const F=[...l];F[b]=w,a({buttons:F})},placeholder:`${i(t.btButton)} ${b+1}`}),e.jsx("button",{onClick:()=>a({buttons:l.filter((w,F)=>F!==b)}),className:"px-2 text-rose-400 hover:bg-rose-500/10 rounded",children:e.jsx(Pe,{size:14})})]},b)),l.length<3&&e.jsxs("button",{onClick:()=>a({buttons:[...l,`Botão ${l.length+1}`]}),className:"text-[13px] text-indigo-300 hover:text-indigo-200 flex items-center gap-1",children:[e.jsx(ge,{size:11})," ",i(t.btAdd)]})]}),e.jsx(C,{label:i(t.btMenuMode),children:e.jsxs("label",{className:"flex items-start gap-2.5 px-3 py-2.5 rounded-lg border border-white/10 bg-dark-800 cursor-pointer hover:border-white/[0.16] transition-colors",children:[e.jsx("input",{type:"checkbox",checked:!!o.keepOpen,onChange:m=>a({keepOpen:m.target.checked}),className:"mt-0.5 accent-indigo-500"}),e.jsxs("div",{children:[e.jsx("div",{className:"text-[13px] font-medium text-gray-200",children:i(t.btKeepOpen)}),e.jsxs("div",{className:"text-[12px] text-gray-400 leading-relaxed mt-0.5",children:[i(t.btKeepOpen1)," ",e.jsx("b",{className:"text-gray-400",children:i(t.btKeepOpen2)})," ",i(t.btKeepOpen3)," ",e.jsx("b",{className:"text-gray-400",children:i(t.btKeepOpenEnd)})," / ",e.jsx("b",{className:"text-gray-400",children:i(t.btKeepOpenHandoff)}),"."]})]})]})})]})}if(g==="input"){const l=o.validate||"text",d={text:i(t.inValText),email:i(t.inValEmail),phone:i(t.inValPhone),number:i(t.inValNumber),cpf:i(t.inValCpf),date:i(t.inValDate)},x={email:"[email protected]",phone:"+55 11 99999-9999",number:"42",cpf:"123.456.789-00",date:"2026-05-03"},m=l!=="text";return e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.inQuestion),children:e.jsx(de,{value:o.question||"",onChange:b=>a({question:b}),rows:3})}),e.jsx(C,{label:i(t.inSaveVar),children:e.jsx(z,{value:o.variable||"",onChange:b=>a({variable:b}
3),placeholder:i(t.inVarPh),prefix:"{{",suffix:"}}"})}),e.jsx(C,{label:i(t.inValidation),hint:i(t.inValidationHint),children:e.jsx(ae,{value:l,onChange:b=>a({validate:b}),options:[{v:"text",l:i(t.inOptText)},{v:"email",l:i(t.inOptEmail)},{v:"phone",l:i(t.inOptPhone)},{v:"number",l:i(t.inOptNumber)},{v:"cpf",l:"CPF"},{v:"date",l:i(t.inOptDate)}]})}),m&&e.jsxs("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-2.5 flex gap-2",children:[e.jsx("span",{className:"text-indigo-300 text-sm flex-shrink-0",children:"â "}),e.jsxs("div",{className:"text-[13px] text-gray-300 leading-relaxed",children:[e.jsx("p",{className:"font-semibold text-indigo-200 mb-0.5",children:i(t.inWarnTitle)}),e.jsxs("p",{children:[i(t.inWarn1)," ",e.jsx("span",{className:"font-mono text-emerald-300",children:"out-0"})," ",i(t.inWarn2)," ",e.jsx("strong",{children:d[l]}),x[l]?e.jsxs(e.Fragment,{children:[" (",i(t.inWarnEg)," ",e.jsx("span",{className:"font-mono",children:x[l]}),")"]}):null,"."]}),e.jsxs("p",{className:"mt-1",children:[i(t.inWarn3)," ",e.jsx("span",{className:"font-mono text-rose-300",children:"out-1"}),"."]})]})]}),e.jsx(C,{label:"Timeout",hint:i(t.inTimeoutHint),children:e.jsx(en,{value:o.timeout||86400,onChange:b=>a({timeout:b})})}),e.jsx(xt,{branches:l==="text"?[{code:"out-0",tone:"success",label:i(t.inBrAny),desc:i(t.inBrAnyDesc)},{code:"out-2",tone:"warning",label:"Timeout",desc:i(t.inBrTimeoutDesc)}]:[{code:"out-0",tone:"success",label:i(t.inBrValid),desc:`${i(t.inBrValidDesc)} ${d[l]}.`},{code:"out-1",tone:"danger",label:`${i(t.inBrInvalid)} ${d[l]}`,desc:i(t.inBrInvalidDesc)},{code:"out-2",tone:"warning",label:"Timeout",desc:i(t.inBrTimeoutDesc)}]})]})}if(g==="choice")return e.jsx(mn,{cfg:o,onUpdate:a,tl:i,T:t});if(g==="list"){const l=T=>typeof T=="string"?{title:T,description:""}:{title:T.title||"",description:T.description||""},d=(o.sections||[{title:"",rows:[]}]).map(T=>({...T,rows:(T.rows||[]).map(l)})),x=d.reduce((T,P)=>T+P.rows.length,0),m=x>10,b=(T,P)=>{const N=d.map((f,L)=>L===T?{...f,...P}:f);a({sections:N})},w=(T,P,N)=>{b(T,{rows:d[T].rows.map((f,L)=>L===P?{...f,...N}:f)})},F=T=>{b(T,{rows:[...d[T].rows,{title:"",description:""}]})},D=(T,P)=>{b(T,{rows:d[T].rows.filter((N,f)=>f!==P)})},S=(T,P,N)=>{const f=[...d[T].rows],[L]=f.splice(P,1);f.splice(N,0,L),b(T,{rows:f})},B=()=>{a({sections:[...d,{title:"",rows:[{title:"",description:""}]}]})},W=T=>{a({sections:d.filter((P,N)=>N!==T)})};return e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.btQuestion),children:e.jsx(de,{value:o.text||"",onChange:T=>a({text:T}),rows:3})}),e.jsx(C,{label:i(t.lsButtonText),children:e.jsx(z,{value:o.buttonText||"Ver opções",onChange:T=>a({buttonText:T}),placeholder:"Ver opções"})}),e.jsx(C,{label:i(t.btFooter),children:e.jsx(z,{value:o.footer||"",onChange:T=>a({footer:T}),placeholder:i(t.btFooterPh)})}),e.jsxs("div",{className:"flex items-center justify-between mt-4 mb-2",children:[e.jsx("label",{className:"text-[13px] font-semibold text-gray-300 uppercase tracking-wider",children:i(t.lsOptions)}),e.jsxs("span",{className:`text-[13px] font-mono px-2 py-0.5 rounded-full ${m?"bg-rose-500/15 text-rose-300 border border-rose-500/30":"bg-dark-700 text-gray-400 border border-white/10"}`,children:[x,"/10"]})]}),e.jsx("div",{className:"space-y-3",children:d.map((T,P)=>e.jsx(tn,{section:T,sectionIndex:P,canDelete:d.length>1,globalRowOffset:d.slice(0,P).reduce((N,f)=>N+f.rows.length,0),onTitleChange:N=>b(P,{title:N}),onRowChange:(N,f)=>w(P,N,f),onRowAdd:()=>F(P),onRowRemove:N=>D(P,N),onRowMove:(N,f)=>S(P,N,f),onSectionDelete:()=>W(P)},P))}),e.jsxs("button",{type:"button",onClick:B,className:"w-full mt-3 py-2 text-[13px] text-indigo-300 hover:text-indigo-200 bg-indigo-500/5 hover:bg-indigo-500/10 border border-dashed border-indigo-500/30 hover:border-indigo-500/50 rounded-lg transition-all flex items-center justify-center gap-1.5",children:[e.jsx(ge,{size:12})," ",i(t.lsAddSection)]}),e.jsxs("div",{className:`mt-3 text-[13px] leading-relaxed flex items-start gap-1.5 ${m?"text-rose-300":"text-gray-400"}`,children:[m&&e.jsx("span",{className:"text-rose-400 mt-0.5",children:"â "}),e.jsx("span",{children:m?`${i(t.lsOverA)} ${x}. ${i(t.lsOverB)} ${x-10}.`:e.jsxs(e.Fragment,{children:[i(t.lsHint1)," ",e.jsx("span",{className:"font-mono text-indigo-300",children:"out-N"})," ",i(t.lsHint2)]})})]})]})}if(g==="template")return e.jsx(Xs,{cfg:o,onUpdate:a});if(g==="condition")return e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.cdVariable),children:e.jsx(z,{value:o.variable||"",onChange:l=>a({variable:l}
3),placeholder:i(t.inVarPh),prefix:"{{",suffix:"}}"})}),e.jsx(C,{label:i(t.cdOperator),children:e.jsx(ae,{value:o.operator||"equals",onChange:l=>a({operator:l}),options:[{v:"equals",l:`= ${i(t.cdEquals)}`},{v:"not_equals",l:`â ${i(t.cdNotEquals)}`},{v:"contains",l:`â ${i(t.cdContains)}`},{v:"greater",l:`> ${i(t.cdGreater)}`},{v:"less",l:`< ${i(t.cdLess)}`},{v:"regex",l:"â¡ Regex"},{v:"is_empty",l:`â
${i(t.cdEmpty)}`}]})}),e.jsx(C,{label:i(t.cdValue),children:e.jsx(z,{value:o.value||"",onChange:l=>a({value:l})})})]});if(g==="random"){const l=(o.paths||[{label:"Caminho A"},{label:"Caminho B"}]).map(x=>({label:typeof x=="string"?x:x.label||""})),d=l.length>0?(100/l.length).toFixed(l.length>3?1:0):0;return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-2.5 flex gap-2",children:[e.jsx("span",{className:"text-indigo-300 text-sm flex-shrink-0",children:"ð²"}),e.jsxs("div",{className:"text-[13px] text-gray-300 leading-relaxed",children:[e.jsx("p",{className:"font-semibold text-gray-100 mb-0.5",children:i(t.rdTitle)}),e.jsxs("p",{children:[i(t.rdDesc1)," ",e.jsx("strong",{children:i(t.rdDescOne)})," ",i(t.rdDesc2)," ",l.length," ",i(t.rdDesc3)," (",e.jsxs("span",{className:"font-mono",children:[d,"%"]})," ",i(t.rdDesc4),")."]})]})]}),e.jsx("div",{className:"space-y-1.5",children:l.map((x,m)=>e.jsxs("div",{className:"group flex items-center gap-2 bg-dark-800/60 border border-white/[0.08] hover:border-indigo-500/40 rounded-lg px-2.5 py-1.5 transition-colors",children:[e.jsxs("span",{className:"text-[12px] font-mono text-indigo-400/70 font-bold min-w-[36px]",children:["out-",m]}),e.jsx("input",{value:x.label,onChange:b=>{const w=l.map((F,D)=>D===m?{label:b.target.value}:F);a({paths:w})},placeholder:`${i(t.rdPathPh)} ${m+1}`,className:"flex-1 bg-transparent text-sm text-gray-100 placeholder-gray-500 focus:outline-none"}),e.jsxs("span",{className:"text-[12px] text-gray-400 font-mono",children:[d,"%"]}),l.length>1&&e.jsx("button",{onClick:()=>a({paths:l.filter((b,w)=>w!==m)}),className:"text-gray-500 hover:text-rose-400 hover:bg-rose-500/10 rounded p-0.5 opacity-0 group-hover:opacity-100 transition-all",title:i(t.rdRemoveOut),children:e.jsx(Pe,{size:12})})]},m))}),e.jsxs("button",{type:"button",onClick:()=>a({paths:[...l,{label:`Caminho ${String.fromCharCode(65+l.length)}`}]}),className:"w-full mt-2 py-1.5 text-[13px] text-indigo-300 hover:text-indigo-200 bg-indigo-500/5 hover:bg-indigo-500/10 border border-dashed border-indigo-500/30 hover:border-indigo-500/50 rounded-lg transition-all flex items-center justify-center gap-1.5",children:[e.jsx(ge,{size:12})," ",i(t.rdAddOut)]})]})}return g==="database"?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.dbSource),children:e.jsx(ae,{value:o.source||"contact",onChange:l=>a({source:l}),options:[{v:"contact",l:`ð¤ ${i(t.dbContact)}`},{v:"has_label",l:`ð·ï¸ ${i(t.dbHasLabel)}`},{v:"message_count",l:`ð¬ ${i(t.dbMsgCount)}`},{v:"last_inbound_age_seconds",l:`â° ${i(t.dbLastAge)}`},{v:"is_first_contact",l:`ð ${i(t.dbFirstContact)}`},{v:"sql",l:`ð§ ${i(t.dbSql)}`}]})}),o.source==="contact"&&e.jsx(C,{label:i(t.dbField),children:e.jsx(ae,{value:o.field||"name",onChange:l=>a({field:l}),options:[{v:"name",l:i(t.dbFieldName)},{v:"notify",l:i(t.dbFieldNotify)},{v:"jid",l:"JID"},{v:"lid",l:"LID"},{v:"is_saved",l:i(t.dbFieldIsSaved)}]})}),o.source==="has_label"&&e.jsx(C,{label:i(t.dbLabelName),children:e.jsx(z,{value:o.labelName||"",onChange:l=>a({labelName:l}),placeholder:i(t.dbLabelPh)})}),o.source==="sql"&&e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.dbQuery),hint:i(t.dbQueryHint),children:e.jsx(de,{mono:!0,value:o.query||"",onChange:l=>a({query:l}),rows:4})}),e.jsx(C,{label:i(t.dbParams),children:e.jsx(xn,{value:o.params||[],onChange:l=>a({params:l}),trim:!1,rows:2})})]}),e.jsx(C,{label:i(t.dbSaveTo),children:e.jsx(z,{value:o.saveTo||"",onChange:l=>a({saveTo:l}),placeholder:"data",prefix:"{{",suffix:"}}"})}),e.jsx(xt,{branches:[{code:"out-0",tone:"success",label:i(t.dbBrOk),desc:i(t.dbBrOkDesc)},{code:"out-1",tone:"danger",label:i(t.dbBrErr),desc:i(t.dbBrErrDesc)}]})]}):g==="delay"?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.dlMode),children:e.jsx(ae,{value:o.mode||"fixed",onChange:l=>a({mode:l}),options:[{v:"fixed",l:i(t.dlFixed)},{v:"until",l:i(t.dlUntil)}]})}),o.mode==="fixed"||!o.mode?e.jsxs("div",{className:"grid grid-cols-2 gap-2",children:[e.jsx(C,{label:i(t.dlTime),children:e.jsx(z,{type:"number",value:o.value||5,onChange:l=>a({value:parseInt(l)}
3)})}),e.jsx(C,{label:i(t.dlUnit),children:e.jsx(ae,{value:o.unit||"minutes",onChange:l=>a({unit:l}),options:[{v:"seconds",l:i(t.dlSeconds)},{v:"minutes",l:i(t.dlMinutes)},{v:"hours",l:i(t.dlHours)},{v:"days",l:i(t.dlDays)}]})})]}):e.jsx(C,{label:i(t.dlTarget),children:e.jsx(z,{type:"datetime-local",value:o.targetTime||"",onChange:l=>a({targetTime:l})})})]}):g==="webhook"?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.whMethod),children:e.jsx(ae,{value:o.method||"POST",onChange:l=>a({method:l}),options:[{v:"GET",l:"GET"},{v:"POST",l:"POST"},{v:"PUT",l:"PUT"},{v:"DELETE",l:"DELETE"}]})}),e.jsx(C,{label:"URL",children:e.jsx(z,{value:o.url||"",onChange:l=>a({url:l}),placeholder:"https://api.exemplo.com/endpoint"})}),e.jsx(C,{label:i(t.whBody),children:e.jsx(de,{value:o.body||"",onChange:l=>a({body:l}),rows:4,mono:!0})}),e.jsx(C,{label:i(t.whSaveTo),children:e.jsx(z,{value:o.saveTo||"",onChange:l=>a({saveTo:l}),placeholder:"response",prefix:"{{",suffix:"}}"})})]}):g==="ai"?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.agLabel),hint:i(t.agHint),children:e.jsx(Us,{cfg:o,onUpdate:a})}),e.jsx(C,{label:i(t.aiMode),children:e.jsx(ae,{value:o.mode||"reply",onChange:l=>a({mode:l}),options:[{v:"reply",l:`ð¬ ${i(t.aiReply)}`},{v:"classify",l:`ð·ï¸ ${i(t.aiClassify)}`},{v:"extract",l:`ð ${i(t.aiExtract)}`}]})}),e.jsx(C,{label:i(t.whSaveTo),children:e.jsx(z,{value:o.saveTo||"ai_response",onChange:l=>a({saveTo:l}),placeholder:"ai_response",prefix:"{{",suffix:"}}"})}),e.jsx(xt,{branches:[{code:"out-0",tone:"success",label:i(t.aiBrOk),desc:i(t.aiBrOkDesc)},{code:"out-1",tone:"danger",label:i(t.errGeneric),desc:i(t.aiBrErrDesc)}]})]}):g==="tag"?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.tgAction),children:e.jsx(ae,{value:o.action||"add",onChange:l=>a({action:l}),options:[{v:"add",l:`+ ${i(t.tgAdd)}`},{v:"remove",l:`â ${i(t.tgRemove)}`}]})}),e.jsx(C,{label:i(t.tgLabel),hint:i(t.tgHint),children:e.jsx(Zs,{cfg:o,onUpdate:a,botSessions:r})})]}):g==="venda"?e.jsx(Js,{cfg:o,onUpdate:a,botSessions:r}):g==="optout"?e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-3 text-[12.5px] text-gray-400 leading-relaxed",children:i(t.ooExplain)}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5 accent-indigo-500",checked:o.sendConfirmation!==!1,onChange:l=>a({sendConfirmation:l.target.checked})}),e.jsx("span",{className:"text-[13px] text-gray-300 leading-snug",children:i(t.ooConfirm)})]}),o.sendConfirmation!==!1&&e.jsx(C,{label:i(t.ooText),hint:i(t.ooTextHint),children:e.jsx(de,{value:o.confirmText||"",onChange:l=>a({confirmText:l}),rows:3})})]}):g==="handoff"?e.jsxs(e.Fragment,{children:[e.jsx(C,{label:i(t.hoReason),children:e.jsx(de,{value:o.reason||"",onChange:l=>a({reason:l}),rows:2})}),e.jsx(C,{label:i(t.hoPause),children:e.jsx(z,{type:"number",value:o.pauseBotHours||24,onChange:l=>a({pauseBotHours:parseInt(l)})})}),e.jsxs("label",{className:"flex items-center gap-2 text-[13px] text-gray-300",children:[e.jsx("input",{type:"checkbox",checked:!!o.notify,onChange:l=>a({notify:l.target.checked}),className:"accent-indigo-500"}),i(t.hoNotify)]})]}):g==="end"?e.jsx("p",{className:"text-[13px] text-gray-400 leading-relaxed",children:i(t.endDesc)}):e.jsxs("div",{className:"text-[13px] text-gray-400 italic text-center py-4",children:[i(t.unknownNode)," ",g]})}function Us({cfg:n,onUpdate:o}){const{tl:a}=G(),[s,r]=v.useState(null),[p,j]=v.useState(""),[i,g]=v.useState(null);v.useEffect(()=>{let x=!0;return(async()=>{var m,b;try{const{data:w}=await ee.get("/ai-agents");x&&r(Array.isArray(w==null?void 0:w.agents)?w.agents:[])}catch(w){x&&(g(((b=(m=w.response)==null?void 0:m.data)==null?void 0:b.error)||a(t.agLoadErr)),r([]))}})(),()=>{x=!1}},[a]);const u=!n.agentId&&(n.systemPrompt||n.provider),l=s==null?void 0:s.find(x=>String(x.id)===String(n.agentId)),d=v.useMemo(()=>{if(!s)return[];const x=p.trim().toLowerCase();return x?s.filter(m=>(m.name||"").toLowerCase().includes(x)):s},[s,p]);return s===null?e.jsxs("div",{className:"bg-dark-800/40 border border-white/[0.08] rounded-lg p-6 flex flex-col items-center gap-2",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-indigo-400 border-t-transparent roun
3ded-full animate-spin"}),e.jsx("p",{className:"text-[13px] text-gray-400",children:a(t.agLoading)})]}):e.jsxs("div",{className:"space-y-2",children:[u&&e.jsx("div",{className:"bg-sky-500/10 border border-sky-500/25 rounded-lg p-3 text-[12.5px] text-sky-200 leading-relaxed",children:a(t.agLegacy)}),i&&e.jsx("p",{className:"text-[12.5px] text-rose-400",children:i}),s.length===0?e.jsxs("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-4 text-center space-y-2",children:[e.jsx("p",{className:"text-sm font-semibold text-gray-100",children:a(t.agEmpty)}),e.jsx("p",{className:"text-[13px] text-gray-400 leading-relaxed",children:a(t.agEmptyHint)}),e.jsxs("a",{href:"/dashboard/ai-agents",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 mt-1 px-3 py-1.5 bg-indigo-500/20 hover:bg-indigo-500/30 text-indigo-200 text-[13px] font-medium rounded-lg transition-colors",children:[e.jsx(ge,{size:12})," ",a(t.agCreateFirst)]})]}):e.jsxs(e.Fragment,{children:[s.length>6&&e.jsx(z,{value:p,onChange:j,placeholder:a(t.agSearch)}),e.jsx("div",{className:"max-h-[220px] overflow-y-auto space-y-1 pr-1",children:d.map(x=>{const m=String(x.id)===String(n.agentId);return e.jsxs("button",{type:"button",onClick:()=>o({agentId:x.id}),className:`w-full text-left px-3 py-2 rounded-lg border transition-colors ${m?"bg-indigo-500/15 border-indigo-500/40":"bg-white/[0.02] border-white/[0.08] hover:bg-white/[0.05]"}`,children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("span",{className:"text-[13px] font-medium text-gray-100 truncate",children:x.name}),x.status!=="active"&&e.jsx("span",{className:"text-[10.5px] px-1.5 py-0.5 rounded bg-rose-500/15 text-rose-300 shrink-0",children:x.status})]}),e.jsx("div",{className:"text-[11.5px] text-gray-500 truncate",children:x.ai_model||""})]},x.id)})}),l&&l.status!=="active"&&e.jsx("p",{className:"text-[12px] text-rose-300",children:a(t.agInactive)})]})]})}function Zs({cfg:n,onUpdate:o,botSessions:a=[]}){const{tl:s}=G(),[r,p]=v.useState(null),j=(a||[]).map(d=>d==null?void 0:d.session_id).filter(Boolean).sort().join(",");v.useEffect(()=>{let d=!0;const x=(a||[]).filter(m=>m==null?void 0:m.session_id);if(!x.length){p({mode:null,options:[],devices:[]});return}return(async()=>{const m=await Promise.all(x.map(async S=>{try{const{data:B}=await ee.get("/wa/chatbots/tag-options",{params:{sessionId:S.session_id}});return{sessionId:S.session_id,name:S.name||S.phone||S.session_id,mode:B.mode,items:B.mode==="native"?B.labels||[]:B.c
3olumns||[]}}catch{return null}}));if(!d)return;const b=m.filter(Boolean),w=b.length>0&&b.every(S=>S.mode==="native"),F=w?"native":"kanban",D=new Map;for(const S of b)if(!(w?S.mode!=="native":S.mode!=="kanban"))for(const B of S.items){const W=String(B.name||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").trim().toLowerCase();!W||D.has(W)||D.set(W,{name:B.name,color:B.color,devices:[S.name]})}p({mode:F,options:[...D.values()],devices:b})})(),()=>{d=!1}},[j]);const i=String(n.labelName||""),g=d=>String(d||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").trim().toLowerCase(),u=(r==null?void 0:r.mode)==="native",l=d=>typeof d.color=="string"&&d.color.startsWith("#")?d.color:null;return r===null?e.jsx("p",{className:"text-[12px] text-gray-500",children:s(t.tgLoading)}):e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:`text-[10.5px] px-1.5 py-0.5 rounded shrink-0 ${u?"bg-indigo-500/15 text-indigo-300":"bg-sky-500/15 text-sky-300"}`,children:s(u?t.tgModeNative:t.tgModeKanban)}),e.jsx("span",{className:"text-[11.5px] text-gray-500 truncate",children:s(u?t.tgSrcNative:t.tgSrcKanban)})]}),r.options.length===0?e.jsx("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-3 text-[12.5px] text-gray-400 leading-relaxed",children:s(u?t.tgEmptyNative:t.tgEmptyKanban)}):e.jsx("div",{className:"max-h-[200px] overflow-y-auto space-y-1 pr-1",children:r.options.map(d=>{const x=g(d.name)===g(i),m=l(d);return e.jsxs("button",{type:"button",onClick:()=>o({labelName:d.name}),className:`w-full text-left px-3 py-1.5 rounded-lg border transition-colors flex items-center gap-2 ${x?"bg-indigo-500/15 border-indigo-500/40":"bg-white/[0.02] border-white/[0.08] hover:bg-white/[0.05]"}`,children:[m&&e.jsx("span",{className:"w-2.5 h-2.5 rounded-full shrink-0",style:{background:m}}),e.jsx("span",{className:"text-[13px] text-gray-100 truncate",children:d.name}),x&&e.jsx(st,{size:13,className:"ml-auto text-indigo-300 shrink-0"})]},d.name)})}),e.jsxs("details",{className:"group",children:[e.jsx("summary",{className:"text-[11.5px] text-gray-500 cursor-pointer hover:text-gray-300",children:s(t.tgCustom)}),e.jsx("div",{className:"pt-1.5",children:e.jsx(z,{value:n.labelName||"",onChange:d=>o({labelName:d}),placeholder:s(t.tgLabelPh)})})]}),i&&r.options.length>0&&!r.options.some(d=>g(d.name)===g(i))&&e.jsx("p",{className:"text-[12px] text-rose-300",children:s(t.tgMissing)}),!u&&e.jsxs("label",{className:"flex items-start gap-2 pt-1 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5 accent-indigo-500",checked:n.triggerFollowup===!0,onChange:d=>o({triggerFollowup:d.target.checked})}),e.jsx("span",{className:"text-[12px] text-gray-400 leading-snug",children:s(t.tgFollowup)})]})]})}const Ys=["BRL","ARS","USD","EUR","MXN","CLP","COP","PEN","UYU","PYG","BOB","GBP"];function Js({cfg:n,onUpdate:o,botSessions:a=[]}){const{tl:s}=G(),[r,p]=v.useState(null),j=(a||[]).map(f=>f==null?void 0:f.session_id).filter(Boolean).sort().join(",");v.useEffect(()=>{let f=!0;p(null);const L=(a||[]).filter($=>$==null?void 0:$.session_id);if(!L.length){p({devices:[],falhas:[]});return}return(async()=>{const $=await Promise.all(L.map(async K=>{const V=K.name||K.phone||K.session_id;try{const{data:I}=await ee.get("/wa/chatbots/venda-options",{params:{sessionId:K.session_id}});return{name:V,columns:I.columns||[],pixel:I.pixel||{}}}catch{return{name:V,falhou:!0}}}));f&&p({devices:$.filter(K=>!K.falhou),falhas:$.filter(K=>K.falhou).map(K=>K.name)})})(),()=>{f=!1}},[j]);const i=f=>String(f||"").normalize("NFD").replace(/[\u0300-\u036f]/g,"").trim().toLowerCase(),g=n.evento||"Purchase",u=g==="Purchase",l=u&&n.esperarConfirmacao===!0,d=(r==null?void 0:r.devices)||[],x=f=>{const L=new Map;for(const $ of d)for(const K of $.columns.filter(f)){const V=i(K.name);V&&!L.has(V)&&L.set(V,K.name)}return[...L.values()]},m=x(f=>f.is_conversion===1),b=x(f=>f.is_conversion!==1),w=u&&!l&&n.coluna?d.filter(f=>!f.columns.some(L=>L.is_conversion===1&&i(L.name)===i(n.coluna))).map(f=>f.name):[],F=n.avisarMeta!==!1?d.filter(f=>!(f.pixel.pixel_id&&f.pixel.token_set)).map(f=>f.name):[],D=(r==null?void 0:r.falhas)||[],S=l&&n.colunaEspera?d.filter(f=>!f.columns.some(L=>i(L.name)===i(n.colunaEspera))).map(f=>f.name):[],B=l&&n.colunaEspera?d.filter(f=>f.columns.some(L=>L.is_conversion===1&&i(L.name)===i(n.colunaEspera))).map(f=>f.name):[],W=String(n.valor||"").trim()!=="",T=!u&&W&&!n.moeda,P=u&&!n.moeda&&n.avisarMeta!==!1?d.filter(f=>{const L=l?f.columns.filter($=>$.is_conversion===1):f.columns.filter($=>$.is_conversion===1&&i($.name)===i(n.coluna));return L.length>0&&L.every($=>!$.meta_moeda)}).map(f=>f.name):[],N=W&&!/\{\{/.test(n.valor)&&(String(n.valor).match(/\d[\d.,]*/g)||[]).length>1;return e.jsxs(e.Fragment,{children:[e.jsx(C,{label:s(t.vdEvent),hint:s(t.vdEvHint),children:e.jsx(ae,{value:g,onChange:f=>o({evento:f}),options:[{v:"Purchase",l:s(t.vdEvPurchase)},{v:"InitiateCheckout",l:s(t.vdEvCheckout)},{v:"Lead",l:s(t.vdEvLead)}]})}),e.jsxs(C,{label:s(t.vdValue),hint:s(t.vdValueHint),children:[e.jsx(z,{value:n.valor||"",onChange:f=>o({valor:f}),placeholder:"180000"}),N&&e.jsx("p",{className:"text-[12px] text-rose-300 mt-1",children:s(t.vdValueOne)})]}),e.jsxs(C,{label:s(t.vdCurrency),children:[e.jsx(ae,{value:n.moeda||"",onChange:f=>o({moeda:f}),options:[{v:"",l:s(t.vdCurrencyCol)},...Ys.map(f=>({v:f,l:f}))]}),T&&e.jsx("p",{className:"text-[12px] text-rose-300 mt-1",children:s(t.vdNeedCurrency)}),P.length>0&&e.jsxs("p",{className:"text-[12px] text-rose-300 mt-1",children:[s(t.vdColNoCurrency)," ",P.join(", ")
3]})]}),r===null&&e.jsx("p",{className:"text-[12px] text-gray-500",children:s(t.vdLoading)}),r!==null&&D.length>0&&e.jsxs("p",{className:"text-[12px] text-rose-300",children:[s(t.vdLoadFail)," ",D.join(", ")]}),r!==null&&!d.length&&!D.length&&e.jsx("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-3 text-[12.5px] text-gray-400 leading-relaxed",children:s(t.vdNoDevice)}),r!==null&&d.length>0&&u&&!l&&e.jsxs(C,{label:s(t.vdColumn),hint:m.length?s(t.vdColumnHint):null,children:[m.length?e.jsx(ae,{value:n.coluna||"",onChange:f=>o({coluna:f}),options:[...n.coluna&&!m.some(f=>i(f)===i(n.coluna))?[{v:n.coluna,l:n.coluna}]:[],...n.coluna?[]:[{v:"",l:s(t.vdChoose)}],...m.map(f=>({v:f,l:f}))]}):e.jsx("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-3 text-[12.5px] text-gray-400 leading-relaxed",children:s(t.vdColumnNone)}),w.length>0&&e.jsxs("p",{className:"text-[12px] text-rose-300 mt-1",children:[s(t.vdMissingIn)," ",w.join(", ")]})]}),e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5 accent-indigo-500",checked:n.avisarMeta!==!1,onChange:f=>o({avisarMeta:f.target.checked})}),e.jsx("span",{className:"text-[13px] text-gray-300 leading-snug",children:s(t.vdMeta)})]}),e.jsx("p",{className:"text-[12px] text-gray-400 mt-1 pl-6",children:s(t.vdMetaHint)}),r!==null&&F.length>0&&e.jsxs("p",{className:"text-[12px] text-rose-300 mt-1 pl-6",children:[s(t.vdPixelOff)," ",F.join(", "),". ",s(t.vdPixelHow)]})]}),u&&e.jsxs("div",{children:[e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",className:"mt-0.5 accent-indigo-500",checked:l,onChange:f=>o({esperarConfirmacao:f.target.checked})}),e.jsx("span",{className:"text-[13px] text-gray-300 leading-snug",children:s(t.vdWait)})]}),e.jsx("p",{className:"text-[12px] text-gray-400 mt-1 pl-6",children:s(t.vdWaitHint)})]}),l&&r!==null&&d.length>0&&e.jsxs(C,{label:s(t.vdWaitColumn),hint:s(t.vdWaitColumnHint),
3children:[e.jsx(ae,{value:n.colunaEspera||"",onChange:f=>o({colunaEspera:f}),options:[...n.colunaEspera&&!b.some(f=>i(f)===i(n.colunaEspera))?[{v:n.colunaEspera,l:n.colunaEspera}]:[],...n.colunaEspera?[]:[{v:"",l:s(t.vdChoose)}],...b.map(f=>({v:f,l:f}))]}),S.length>0&&e.jsxs("p",{className:"text-[12px] text-rose-300 mt-1",children:[s(t.vdWaitMissing)," ",S.join(", ")]}),B.length>0&&e.jsxs("p",{className:"text-[12px] text-rose-300 mt-1",children:[s(t.vdWaitIsConv)," ",B.join(", ")]})]})]})}function Xs({cfg:n,onUpdate:o}){const{tl:a}=G(),[s,r]=v.useState(null),[p,j]=v.useState(""),[i,g]=v.useState(null),u=v.useCallback(async()=>{var m,b;g(null);try{const{data:w}=await ee.get("/wa/templates");r(Array.isArray(w==null?void 0:w.templates)?w.templates:[])}catch(w){g(((b=(m=w.response)==null?void 0:m.data)==null?void 0:b.error)||a(t.tsLoadErr)),r([])}},[a]);v.useEffect(()=>{u()},[u]);const l=s==null?void 0:s.find(m=>m.id===n.templateId),d=v.useMemo(()=>{if(!s)return[];if(!p)return s;const m=p.toLowerCase();return s.filter(b=>(b.name||"").toLowerCase().includes(m)||(b.description||"").toLowerCase().includes(m))},[s,p]),x=m=>!m||m<1e3?null:m<6e4?`${Math.round(m/1e3)}s`:m<36e5?`${Math.round(m/6e4)}min`:`${(m/36e5).toFixed(1)}h`;return s===null?e.jsxs("div",{className:"bg-dark-800/40 border border-white/[0.08] rounded-lg p-6 flex flex-col items-center gap-2",children:[e.jsx("div",{className:"w-5 h-5 border-2 border-indigo-400 border-t-transparent rounded-full animate-spin"}),e.jsx("p",{className:"text-[13px] text-gray-400",children:a(t.tsLoading)})]}):s.length===0?e.jsxs("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-4 text-center space-y-2",children:[e.jsx("p",{className:"text-2xl",children:"ð"}),e.jsx("p",{className:"text-sm font-semibold text-gray-100",children:a(t.tsEmpty)}),e.jsx("p",{className:"text-[13px] text-gray-400 leading-relaxed",children:a(t.tsEmptyHint)}),e.jsxs("a",{href:"/dashboard/templates",target:"_blank",rel:"noreferrer",className:"inline-flex items-center gap-1.5 mt-2 px-3 py-1.5 bg-indigo-500/20 hover:bg-indigo-500/30 text-indigo-200 text-[13px] font-medium rounded-lg transition-colors",children:[e.jsx(ge,{size:12})," ",a(t.tsCreateFirst)]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(sa,{className:"absolute left-2 top-1/2 -translate-y-1/2 text-gray-400",size:11}),e.jsx("input",{type:"text",placeholder:a(t.tsSearchPh),value:p,onChange:m=>j(m.target.value),className:"w-full bg-dark-800 border border-white/10 rounded-lg pl-7 pr-2 py-1.5 text-[13px] text-gray-100 placeholder-gray-400 focus:outline-none focus:border-indigo-500/50"})]}),e.jsxs("span",{className:"text-[12px] text-gray-400 font-mono",children:[d.length,"/",s.length]}),e.jsx("button",{type:"button",onClick:u,className:"text-gray-400 hover:text-indigo-300 hover:bg-dark-800 rounded p-1.5 transition-colors",title:a(t.tsRefresh),children:e.jsx(na,{size:12})})]}),l&&e.jsxs("div",{className:"bg-indigo-500/[0.07] border border-indigo-500/30 rounded-lg p-3 space-y-1.5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("span",{className:"text-[12px] uppercase tracking-wider text-indigo-300 font-bold",children:a(t.tsSelected)}),e.jsx("button",{type:"button",onClick:()=>o({templateId:null}),className:"text-[12px] text-gray-400 hover:text-rose-400 transition-colors",children:a(t.tsUnselect)})]}),e.jsx("p",{className:"text-sm font-semibold text-gray-100 truncate",children:l.name}),l.description&&e.jsx("p",{className:"text-[13px] text-gray-400 line-clamp-2",children:l.description}),e.jsxs("div",{className:"flex items-center gap-3 text-[12px] text-gray-400 pt-1",children:[e.jsxs("span",{className:"flex items-center gap-1",children:["ð ",l.step_count||0," step",l.step_count===1?"":"s"]}),x(l.total_delay_ms)&&e.jsxs("span",{className:"flex items-center gap-1",children:["â± ",x(l.total_delay_ms)]}),l.runs_total>0&&e.jsxs("span",{className:"flex items-center gap-1",children:["ð ",l.runs_total," ",l.runs_total===1?a(t.tsSendOne):a(t.tsSendMany)]})]})]}),e.jsx("div",{className:"space-y-1.5 max-h-[280px] overflow-y-auto pr-1 -mr-1",children:d.length===0?e.jsx("p",{className:"text-[13px] text-gray-400 italic text-center py-4",children:a(t.tsNoMatch)}):d.map(m=>{const b=n.templateId===m.id;return e.jsxs("button",{type:"button",onClick:()=>o({templateId:m.id,templateName:m.name,templateStepCount:m.step_count,templateTotalDelayMs:m.total_delay_ms}),className:`w-full text-left p-2.5 rounded-lg border transition-all ${b?"bg-indigo-500/15 border-indigo-500/60 text-gray-100":"bg-dark-800/40 border-white/[0.08] hover:border-white/[0.16] text-gray-200"}`,children:[e.jsxs("div",{className:"flex items-start justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-medium truncate flex items-center gap-1.5",children:[!!m.is_quick_send&&e.jsx("span",{className:"text-[12px] bg-indigo-500/20 text-indigo-300 px-1.5 py-0.5 rounded font-bold",children:"QUICK"}),m.name]}),m.description&&e.jsx("p",{className:"text-[13px] text-gray-400 line-clamp-1 mt-0.5",children:m.description})]}),b&&e.jsx(st,{className:"text-indigo-300 flex-shrink-0 mt-0.5",size:14})]}),e.jsxs("div",{className:"flex items-center gap-3 text-[12px] text-gray-400 mt-1.5",children:[e.jsxs("span",{children:["ð ",m.step_count||0]}),x(m.total_delay_ms)&&e.jsxs("span",{children:["â± ",x(m.total_delay_ms)]}),m.runs_total>0&&e.jsxs("span",{children:["ð ",m.runs_total]})]})]},m.id)})}),e.jsxs("a",{href:"/dashboard/templates",target:"_blank",rel:"noreferrer",className:"text-[13px] text-indigo-400 hover:text-indigo-300 inline-flex items-center gap-1 transition-colors",children:[e.jsx(ge,{size:11})," ",a(t.tsCreateNew)]}),e.jsxs("div",{className:"text-[13px] text-gray-400 leading-relaxed pt-2 border-t border-white/[0.07] space-y-1",children:[e.jsxs("p",{className:"flex items-start gap-1.5",children:[e.jsx("span",{className:"text-indigo-400",children:"â¸"}),e.jsxs("span",{children:[a(t.tsWaits1)," ",e.jsx("strong",{children:a(t.tsWaitsBold)})," ",a(t.tsWaits2)]})]}),e.jsxs("p",{className:"text-[12px] text-gray-400",children:[a(t.tsVars1)," ",e.jsx("span",{className:"font-mono text-indigo-300",children:`{{${a(t.tsVarsToken)}}}`})," ",a(t.tsVars2)]})]}),i&&e.jsx("p",{className:"text-[13px] text-rose-400",children:i})]})}function en({value:n,onChange:o}){const{tl:a}=G(),s=[{s:60,l:a(t.tp1min)},{s:300,l:a(t.tp5min)},{s:1800,l:a(t.tp30min)},{s:3600,l:a(t.tp1h)},{s:86400,l:a(t.tp24h)},{s:604800,l:a(t.d7)}],r=p=>!p||p<60?`${p||0}s`:p<3600?`${Math.round(p/60)} ${a(t.tpMin)}`:p<86400?`${(p/3600).toFixed(p%3600?1:0)} ${a(t.tpHour)}`:`${(p/86400).toFixed(p%86400?1:0)} ${p>=172800?a(t.tpDays):a(t.tpDay)}`;return e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"number",min:"10",value:n,onChange:p=>o(Math.max(10,parseInt(p.target.value)||10)),className:"flex-1 bg-dark-700 border border-white/[0.16] rounded-lg px-3 py-1.5 text-sm text-gray-100 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500"}),e.jsx("span",{className:"text-[13px] text-gray-400 font-mono",children:a(t.tpSec)}),e.jsxs("span",{className:"text-[13px] text-indigo-300 font-semibold min-w-[60px] text-right",children:["â ",r(n)]})]}),e.jsx("div",{className:"flex flex-wrap gap-1",children:s.map(p=>e.jsx("button",{type:"button",onClick:()=>o(p.s),className:`text-[12px] px-2 py-0.5 rounded-full border transition-all ${n===p.s?"bg-indigo-500/20 border-indigo-500/60 text-indigo-200":"bg-dark-800 border-white/10 text-gray-400 hover:border-white/[0.16] hover:text-gray-200"}`,children:p.l},p.s))})]})}function xt({branches:n}){const{tl:o}=G(),a={success:{dot:"bg-emerald-400",tag:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30",text:"text-emerald-200"},danger:{dot:"bg-rose-400",tag:"bg-rose-500/15 text-rose-300 border-rose-500/30",text:"text-rose-200"}
3,warning:{dot:"bg-sky-400",tag:"bg-sky-500/15 text-sky-300 border-sky-500/30",text:"text-sky-200"},info:{dot:"bg-indigo-400",tag:"bg-indigo-500/15 text-indigo-300 border-indigo-500/30",text:"text-indigo-200"}};return e.jsxs("div",{className:"mt-3 bg-dark-800/60 border border-white/[0.08] rounded-lg p-2.5 space-y-2",children:[e.jsx("p",{className:"text-[12px] uppercase tracking-wider text-gray-400 font-semibold mb-1",children:o(t.brOutputs)}),n.map((s,r)=>{const p=a[s.tone]||a.info;return e.jsxs("div",{className:"flex gap-2.5 items-start",children:[e.jsxs("div",{className:"flex items-center gap-1.5 flex-shrink-0 mt-0.5",children:[e.jsx("span",{className:`w-1.5 h-1.5 rounded-full ${p.dot}`}),e.jsx("span",{className:`text-[12px] font-mono font-semibold px-1.5 py-0.5 rounded border ${p.tag}`,children:s.code})]}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:`text-[13px] font-semibold ${p.text}`,children:s.label}),e.jsx("p",{className:"text-[13px] text-gray-400 leading-snug",children:s.desc})]})]},r)})]})}function tn({section:n,sectionIndex:o,canDelete:a,globalRowOffset:s,onTitleChange:r,onRowChange:p,onRowAdd:j,onRowRemove:i,onRowMove:g,onSectionDelete:u}){const{tl:l}=G(),[d,x]=v.useState(null),[m,b]=v.useState(null),[w,F]=v.useState(!1),[D,S]=v.useState(null),B=v.useRef({});v.useEffect(()=>{D!=null&&B.current[D]&&(B.current[D].focus(),S(null))},[D]);const W=()=>{j(),S(n.rows.length)};return e.jsxs("div",{className:"bg-dark-800/40 border border-white/[0.06] rounded-xl overflow-hidden hover:border-white/[0.10] transition-colors",children:[e.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-dark-800/60 border-b border-white/[0.06]",children:[e.jsx("button",{type:"button",onClick:()=>F(T=>!T),className:"text-gray-400 hover:text-gray-200 transition-colors p-0.5 hover:bg-dark-700 rounded",title:l(w?t.lsExpand:t.lsCollapse),children:e.jsx(ot,{size:14,className:`transition-transform ${w?"":"rotate-90"}`})}),e.jsxs("span",{className:"text-[12px] uppercase tracking-wider text-gray-400 font-bold flex-shrink-0",children:[l(t.lsSection)," ",o+1]}),e.jsx("input",{value:n.title||"",onChange:T=>r(T.target.value),placeholder:l(t.lsSectionPh),className:"flex-1 bg-transparent text-sm text-gray-100 placeholder-gray-500 focus:outline-none font-medium"}),e.jsx("span",{className:`text-[12px] font-mono px-1.5 py-0.5 rounded-full font-semibold ${n.rows.length===0?"bg-dark-700 text-gray-400":"bg-indigo-500/15 text-indigo-300"}`,children:n.rows.length}),a&&e.jsx("button",{type:"button",onClick:u,className:"text-gray-400 hover:text-rose-400 hover:bg-rose-500/10 rounded p-1 transition-colors",title:l(t.lsRemoveSection),children:e.jsx(Pe,{size:14})})]}),!w&&e.jsxs("div",{className:"p-2",children:[n.rows.length===0&&e.jsxs("button",{type:"button",onClick:W,className:"w-full py-6 text-[13px] text-gray-400 hover:text-indigo-300 hover:bg-indigo-500/5 border border-dashed border-white/[0.08] hover:border-indigo-500/40 rounded-lg transition-all flex flex-col items-center gap-1",children:[e.jsx(ge,{size:16}),e.jsx("span",{children:l(t.lsAddFirst)})]}),n.rows.map((T,P)=>{const N=s+P,f=d===P,L=m===P&&d!==null&&d!==P;return e.jsxs("div",{children:[L&&e.jsx("div",{className:"h-0.5 bg-indigo-400 rounded-full my-1 shadow-[0_0_8px_rgba(99,102,241,0.5)]"}),e.jsx("div",{draggable:!0,onDragStart:$=>{x(P),$.dataTransfer.effectAllowed="move"},onDragEnd:()=>{x(null),b(null)},onDragOver:$=>{if($.preventDefault(),d===null||d===P)return;const K=$.currentTarget.getBoundingClientRect(),V=K.top+K.height/2;b($.clientY<V?P:P+1)},onDrop:$=>{if($.preventDefault(),d!==null&&m!==null&&d!==m&&d!==m-1){const K=m>d?m-1:m;g(d,K)}x(null),b(null)},className:`group bg-dark-900/40 hover:bg-dark-900/70 border rounded-lg transition-all mb-1.5 ${f?"opacity-40 border-indigo-500/40":"border-white/[0.06] hover:border-white/[0.16]"}`,children:e.jsxs("div",{className:"flex items-stretch",children:[e.jsx("div",{className:"px-1.5 cursor-grab active:cursor-grabbing text-gray-500 group-hover:text-gray-400 flex items-center transition-colors",title:l(t.lsDragHint),children:e.jsxs("svg",{width:"8",he
3ight:"14",viewBox:"0 0 6 10",fill:"currentColor",children:[e.jsx("circle",{cx:"1.5",cy:"1.5",r:"1"}),e.jsx("circle",{cx:"4.5",cy:"1.5",r:"1"}),e.jsx("circle",{cx:"1.5",cy:"5",r:"1"}),e.jsx("circle",{cx:"4.5",cy:"5",r:"1"}),e.jsx("circle",{cx:"1.5",cy:"8.5",r:"1"}),e.jsx("circle",{cx:"4.5",cy:"8.5",r:"1"})]})}),e.jsxs("span",{className:"flex items-center text-[12px] text-indigo-400/70 group-hover:text-indigo-300 font-mono font-bold transition-colors min-w-[36px]",children:["out-",N]}),e.jsxs("div",{className:"flex-1 px-2 py-2 min-w-0 space-y-0.5",children:[e.jsx("input",{ref:$=>{B.current[P]=$},value:T.title,onChange:$=>p(P,{title:$.target.value}),onKeyDown:$=>{$.key==="Enter"&&($.preventDefault(),W()),$.key==="Backspace"&&!T.title&&!T.description&&($.preventDefault(),i(P))},placeholder:l(t.lsRowTitlePh),className:"w-full bg-transparent text-sm text-gray-100 placeholder-gray-500 focus:outline-none font-medium"}),e.jsx("input",{value:T.description,onChange:$=>p(P,{description:$.target.value}),placeholder:l(t.lsRowDescPh),className:"w-full bg-transparent text-[13px] text-gray-400 placeholder-gray-500/70 focus:outline-none focus:text-gray-300"})]}),e.jsx("button",{type:"button",onClick:()=>i(P),className:"px-2 text-gray-500 hover:text-rose-400 hover:bg-rose-500/10 transition-colors flex items-center opacity-0 group-hover:opacity-100",title:l(t.lsRemoveRow),children:e.jsx(Pe,{size:13})})]})}),m===n.rows.length&&P===n.rows.length-1&&d!==null&&d!==P&&e.jsx("div",{className:"h-0.5 bg-indigo-400 rounded-full my-1 shadow-[0_0_8px_rgba(99,102,241,0.5)]"})]},P)}),n.rows.length>0&&e.jsxs("button",{type:"button",onClick:W,className:"w-full mt-1 py-1.5 text-[13px] text-gray-400 hover:text-indigo-300 hover:bg-indigo-500/5 border border-dashed border-white/[0.06] hover:border-indigo-500/40 rounded-md transition-all flex items-center justify-center gap-1.5",children:[e.jsx(ge,{size:11})," ",l(t.lsAddRow),e.jsx("span",{className:"text-[12px] text-gray-500 ml-1",children:l(t.lsAddRowKbd)})]})]})]})}function Yt({onUpload:n,label:o}){const{tl:a}=G(),[s,r]=v.useState(!1),[p,j]=v.useState(null),i=async g=>{var l,d,x,m;const u=(l=g.target.files)==null?void 0:l[0];if(u){r(!0),j(null);try{const b=new FormData;b.append("file",u);const w=await ee.post("/wa/upload",b,{headers:{"Content-Type":"multipart/form-data"}});(d=w.data)!=null&&d.url?n(w.data.url):j(a(t.upNoUrl))}catch(b){j(((m=(x=b==null?void 0:b.response)==null?void 0:x.data)==null?void 0:m.error)||b.message)}finally{r(!1),g.target.value=""}}};return e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("label",{className:"flex items-center justify-center gap-2 h-9 px-3 text-[13px] font-medium rounded-lg bg-dark-800 border border-white/10 text-gray-200 hover:bg-dark-700 hover:border-white/[0.16] cursor-pointer transition-colors focus-within:border-indigo-500 focus-within:ring-1 focus-within:ring-indigo-500/30",children:[e.jsx(ht,{size:13}),s?a(t.upSending):o||a(t.upDefault),e.jsx("input",{type:"file",onChange:i,className:"sr-only",disabled:s})]}),p&&e.jsx("p",{className:"text-[12px] text-rose-400 mt-1",children:p})]})}const an={keyword:t.trKeyword,first_message:t.trFirstMsg,webhook:t.trWebhook,anuncio:t.trAnuncio,template:{pt:"Template de entrada",en:"Entry template",es:"Plantilla de entrada"}},sn=[{v:"keyword",l:t.trKeyword,icon:"ð¤",desc:t.trKeywordDesc},{v:"first_message",l:t.trFirstMsg,icon:"ð",desc:t.trFirstMsgDesc},{v:"webhook",l:t.trWebhook,icon:"ð",desc:t.trWebhookDesc},{v:"anuncio",l:t.trAnuncio,icon:"ð£",desc:t.trAnuncioDesc}];function nn({cfg:n,onUpdate:o,botSessions:a=[],gatilho:s=null}){const{tl:r}=G(),p=n.triggerType||"keyword",j=!!s&&s.total>1,i=!!s&&(s.outros||[]).some(g=>g&&g.triggerType==="webhook");return e.jsxs("div",{className:"space-y-4",children:[j&&e.jsx("div",{className:"px-3 py-2.5 rounded-lg bg-white/[0.03] border border-white/10 text-[12px] text-gray-300 leading-relaxed","data-gatilho-dois":!0,children:r(t.trDois)}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-[13px] font-medium text-gray-300 mb-2",children:r(t.trHowStart)}),e.jsx("div",{className:"grid grid-cols-2 gap-1.5",children:sn.map(g=>{const u=p===g.v,l=g.v==="webhook"&&i&&!u;return e.jsxs("button",{onClick:()=>{l||o({triggerType:g.v})},disabled:l,title:l?r(t.trWebhookOcupado):void 0,"data-tipo-gatilho":g.v,className:`text-left px-2 py-2 rounded-lg border transition-all ${u?"border-indigo-500/60 bg-indigo-500/10 ring-1 ring-indigo-500/30":l?"border-white/[0.06] bg-dark-800/30 opacity-45 cursor-not-allowed":"border-white/10 bg-dark-800/50 hover:border-white/[0.16] hover:bg-dark-800"}`,children:[e.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[e.jsx("span",{className:"text-sm",children:g.icon}),e.jsx("span",{className:`text-[13px] font-semibold ${u?"text-indigo-300":"text-gray-100"}`,children:r(g.l)})]}),e.jsx("div",{className:"text-[12px] text-gray-400 leading-tight line-clamp-2",children:r(g.desc)})]},g.v)})}),i&&e.jsx("p",{className:`mt-2 text-[12px] leading-snug ${p==="webhook"?"text-rose-300":"text-gray-400"}`,"data-webhook-ocupado":!0,children:r(p==="webhook"?t.trDoisWebhooks:t.trWebhookOcupado)})]}),p==="keyword"&&e.jsx(rn,{cfg:n,onUpdate:o}),p==="first_message"&&e.jsx(dn,{cfg:n,onUpdate:o}),p==="webhook"&&e.jsx(cn,{cfg:n,onUpdate:o}),p==="anuncio"&&e.jsx(ln,{cfg:n,onUpdate:o,botSessions:a}),e.jsx(on,{cfg:n,onUpdate:o,dois:j}),s&&!j&&e.jsx("p",{className:"text-[12px] text-gray-400 leading-relaxed","data-gatilho-dica":!0,children:r(t.trDica2)})]})}function on({cfg:n,onUpdate:o,dois:a=!1}){const{tl:s}=G(),r=["pause","end","continue"].includes(n.humanReply)?n.humanReply:"pause",p=n.humanReplyPauseHours??24,j=n.noMatchLimit??3,i=n.noMatchAction==="handoff"?"handoff":"end",g=[{v:"pause",l:s(t.eqPausar),hint:s(t.eqPausarHint),rec:!0},{v:"end",l:s(t.eqEncerrar),hint:s(t.eqEncerrarHint)},{v:"continue",l:s(t.eqContinuar),hint:s(t.eqContinuarHint)}],u="w-16 bg-dark-800 border border-white/10 rounded-md px-2 py-1 text-[12px] text-gray-100 focus:border-indigo-500 outline-none";return e.jsxs("div",{className:"space-y-3 pt-3 border-t border-white/10","data-gatilho-equipe":!0,children:[a&&e.jsx("p",{className:"text-[12px] text-indigo-300 leading-relaxed","data-eq-fluxo":!0,children:s(t.eqFluxo)}),e.jsxs(C,{label:s(t.eqTitulo),hint:s(t.eqHint),children:[e.jsx("div",{className:"space-y-1",children:g.map(l=>{const d=r===l.v;return e.jsxs("button",{"data-eq-opcao":l.v,onClick:()=>o({humanReply:l.v}),className:`w-full text-left px-2 py-1.5 rounded-md border text-[12px] transition-all ${d?"border-indigo-500/60 bg-indigo-500/10 text-indigo-200":"border-white/10 bg-dark-800/50 text-gray-300 hover:border-white/[0.16]"}`,children:[e.jsxs("div",{className:"font-semibold flex items-center gap-1.5",children:[l.l,l.rec&&e.jsx("span",{className:"text-[10px] font-medium px-1 py-px rounded bg-emerald-500/15 text-emerald-300",children:s(t.eqRecomendado)})]}),e.jsx("div",{className:"text-[11px] text-gray-400 leading-tight",children:l.hint})]},l.v)})}),r==="pause"&&e.jsxs("label",{className:"mt-2 flex items-center gap-2 text-[12px] text-gray-300",children:[s(t.eqPor),e.jsx("input",{type:"number",min:1,max:720,value:p,"data-eq-horas":!0,onChange:l=>o({humanReplyPauseHours:Math.min(720,Math.max(1,parseInt(l.target.value,10)||24))}),className:u}),s(t.eqHoras)]})]}),e.jsxs(C,{label:s(t.neTitulo),hint:s(t.neHint),children:[e.jsxs("div",{className:"flex items-center gap-2 text-[12px] text-gray-300 flex-wrap","data-gatilho-naoentendi":!0,children:[s(t.neDepois),e.jsx("input",{type:"number",min:0,max:20,value:j,"data-ne-limite":!0,onChange:l=>o({noMatchLimit:Math.min(20,Math.max(0,parseInt(l.target.value,10)||0))}),className:u}),s(t.neTentativas)]}),e.jsx("div",{className:"grid grid-cols-2 gap-1 mt-2",children:[{v:"end",l:s(t.neEncerrar)},{v:"handoff",l:s(t.neTransferir)}
3].map(l=>{const d=i===l.v;return e.jsx("button",{"data-ne-acao":l.v,onClick:()=>o({noMatchAction:l.v}),className:`text-left px-2 py-1.5 rounded-md border text-[12px] font-semibold transition-all ${d?"border-indigo-500/60 bg-indigo-500/10 text-indigo-200":"border-white/10 bg-dark-800/50 text-gray-300 hover:border-white/[0.16]"}`,children:l.l},l.v)})}),e.jsx("textarea",{rows:2,value:n.noMatchMessage||"","data-ne-msg":!0,placeholder:s(t.neMsgPh),onChange:l=>o({noMatchMessage:l.target.value.slice(0,500)}),className:"mt-2 w-full bg-dark-800 border border-white/10 rounded-lg px-2 py-1.5 text-[12px] text-gray-100 placeholder-gray-400 focus:border-indigo-500 outline-none resize-none"}),e.jsx("p",{className:"text-[11px] text-gray-400 mt-1",children:s(t.neZero)})]})]})}function rn({cfg:n,onUpdate:o}){const{tl:a}=G(),[s,r]=v.useState(""),p=n.keywords||[],j=()=>{const d=s.trim();if(d){if(p.includes(d)){r("");return}o({keywords:[...p,d]}),r("")}},i=d=>o({keywords:p.filter(x=>x!==d)}),g=d=>{d.key==="Enter"||d.key===","?(d.preventDefault(),j()):d.key==="Backspace"&&!s&&p.length&&i(p[p.length-1])},u=[{v:"contains",l:a(t.kwContains),hint:a(t.kwContainsHint)},{v:"exact",l:a(t.kwExact),hint:a(t.kwExactHint)},{v:"starts_with",l:a(t.kwStarts),hint:a(t.kwStartsHint)},{v:"regex",l:a(t.kwRegex),hint:a(t.kwRegexHint)}],l=u.find(d=>d.v===(n.match||"contains"));return e.jsxs("div",{className:"space-y-3",children:[e.jsx(C,{label:a(t.kwField),hint:a(t.kwFieldHint),children:e.jsxs("div",{className:"bg-dark-800 border border-white/10 rounded-lg p-2 focus-within:border-indigo-500 transition-colors",children:[e.jsxs("div",{className:"flex flex-wrap gap-1 mb-1",children:[p.length===0&&e.jsx("span",{className:"text-[12px] text-gray-400 italic",children:a(t.kwEmpty)}),p.map(d=>e.jsxs("span",{className:"inline-flex items-center gap-1 px-1.5 py-0.5 rounded-md bg-indigo-500/15 text-indigo-300 text-[12px] font-medium border border-indigo-500/30",children:[d,e.jsx("button",{onClick:()=>i(d),className:"hover:text-rose-300 transition-colors",title:a(t.remove),children:e.jsx(Pe,{size:10})})]},d))]}),e.jsx("input",{type:"text",value:s,onChange:d=>r(d.target.value),onKeyDown:g,onBlur:j,placeholder:a(t.kwPh),className:"w-full bg-transparent text-[13px] text-gray-100 placeholder-gray-400 outline-none"})]})}),e.jsxs(C,{label:a(t.kwMatch),children:[e.jsx("div",{className:"grid grid-cols-2 gap-1",children:u.map(d=>{const x=(n.match||"contains")===d.v;return e.jsx("button",{onClick:()=>o({match:d.v}),className:`text-left px-2 py-1.5 rounded-md border text-[12px] transition-all ${x?"border-indigo-500/60 bg-indigo-500/10 text-indigo-200":"border-white/10 bg-dark-800/50 text-gray-300 hover:border-white/[0.16]"}`,children:e.jsx("div",{className:"font-semibold",children:d.l})},d.v)})}),l&&e.jsx("p",{className:"text-[12px] text-gray-400 mt-1.5",children:l.hint})]}),e.jsxs("label",{className:"flex items-center gap-2 text-[13px] text-gray-300 select-none cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!n.caseSensitive,onChange:d=>o({caseSensitive:d.target.checked}),className:"accent-indigo-500"}),a(t.kwCaseSensitive)]}),e.jsxs("label",{className:"flex items-start gap-2 text-[13px] text-gray-300 select-none cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!n.oncePerContact,onChange:d=>o({oncePerContact:d.target.checked}),className:"accent-indigo-500 mt-0.5"}),e.jsxs("span",{children:[a(t.kwOnce1)," ",e.jsx("b",{className:"text-gray-100",children:a(t.kwOnceBold)}),e.jsx("span",{className:"block text-[12px] text-gray-400 mt-0.5",children:a(t.kwOnceHint)})]})]})]})}function ln({cfg:n,onUpdate:o,botSessions:a=[]}){const{tl:s}=G(),{id:r}=bt(),[p,j]=v.useState(null),[i,g]=v.useState({});v.useEffect(()=>{let N=!0;if(r)return ee.get(`/wa/chatbots/${r}/anuncios-em-uso`).then(({data:f})=>{N&&g((f==null?void 0:f.usos)||{})}).catch(()=>{}),()=>{N=!1}},[r]);const u=N=>(i[N]||[]).map(f=>`«${f.name}»`).join(", "),[l,d]=v.useState(""),[x,m]=v.useState(""),b=(a||[]).map(N=>N==null?void 0:N.session_id).filter(Boolean).sort().join(",");v.useEffect(()=>{let N=!0;j(null);const f=(a||[]).filter(L=>L==null?void 0:L.session_id);if(!f.length){j({anuncios:[],falhas:[]});return}return(async()=>{const L=await Promise.all(f.map(async V=>{const I=V.name||V.phone||V.session_id;try{const{data:U}=await ee.get("/wa/chatbots/anuncio-options",{params:{sessionId:V.session_id}});return{name:I,anuncios:U.anuncios||[]}}catch{return{name:I,falhou:!0}}}));if(!N)return;const $=new Map;for(const V of L)for(const I of V.anuncios||[]){const U=$.get(I.sourceId);U?U.contatos+=I.contatos||0:$.set(I.sourceId,{...I,contatos:I.contatos||0})}const K=[...$.values()].sort((V,I)=>I.contatos-V.contatos);j({anuncios:K,falhas:L.filter(V=>V.falhou).map(V=>V.name)})})(),()=>{N=!1}},[b]);const w=Array.isArray(n.adSourceIds)?n.adSourceIds:[],F=n.adTitulos||{},D=N=>F[N]||(((p==null?void 0:p.anuncios)||[]).find(f=>f.sourceId===N)||{}).titulo||N,S=(N,f={})=>o({adSourceIds:N,adTitulos:{...F,...f}}),B=N=>{w.includes(N.sourceId)?S(w.filter(f=>
3f!==N.sourceId)):S([...w,N.sourceId],N.titulo?{[N.sourceId]:N.titulo}:{})},W=()=>{const N=String(l||"").trim();if(!/^[\w-]{3,64}$/.test(N)){m(s(t.adManualBad));return}m(""),w.includes(N)||S([...w,N]),d("")},T=new Set(((p==null?void 0:p.anuncios)||[]).map(N=>N.sourceId)),P=w.filter(N=>!T.has(N));return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-3 text-[13px] text-gray-300 leading-relaxed flex gap-2",children:[e.jsx("span",{className:"text-base",children:"ð£"}),e.jsx("div",{children:s(t.adIntro)})]}),e.jsxs(C,{label:s(t.adListTitle),children:[p===null&&e.jsx("div",{className:"text-[12px] text-gray-400",children:s(t.adLoading)}),p&&!(a||[]).length&&e.jsx("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-3 text-[12px] text-gray-400",children:s(t.adNoDevice)}),p&&!!(a||[]).length&&!p.anuncios.length&&e.jsx("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-3 text-[12px] text-gray-400",children:s(t.adListEmpty)}),p&&p.anuncios.length>0&&e.jsx("div",{className:"space-y-1 max-h-72 overflow-y-auto pr-0.5","data-ad-list":!0,children:p.anuncios.map(N=>{const f=w.includes(N.sourceId);return e.jsxs("button",{type:"button",onClick:()=>B(N),"data-ad-option":N.sourceId,className:`w-full text-left flex items-center gap-2.5 px-2.5 py-2 rounded-lg border transition-all ${f?"border-indigo-500/60 bg-indigo-500/10":"border-white/10 bg-dark-800/50 hover:border-white/[0.16]"}`,children:[e.jsx("span",{className:`w-4 h-4 rounded border flex items-center justify-center text-[11px] shrink-0 ${f?"bg-indigo-500 border-indigo-500 text-white":"border-white/20"}`,children:f?"â":""}),N.imagem?e.jsx("img",{src:N.imagem,alt:"",className:"w-9 h-9 rounded-md object-cover shrink-0"}):e.jsx("span",{className:"w-9 h-9 rounded-md bg-white/[0.06] flex items-center justify-center text-base shrink-0",children:"ð£"}),e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:`block text-[13px] truncate ${f?"text-indigo-200 font-semibold":"text-gray-100"}`,children:N.titulo||N.sourceId}),e.jsxs("span",{className:"block text-[11.5px] text-gray-400 truncate",children:[N.contatos," ",s(t.adContatos)," · ",N.sourceId]}),i[N.sourceId]&&e.jsxs("span",{className:"block text-[11.5px] text-rose-300 truncate","data-ad-em-outro":N.sourceId,children:[s(t.adEmOutro)," ",u(N.sourceId)]})]})]},N.sourceId)})}),p&&p.falhas.length>0&&e.jsxs("p",{className:"text-[12px] text-rose-300 mt-1",children:[s(t.adFail),p.falhas.join(", ")]})]}),e.jsxs(C,{label:s(t.adManualTitle),hint:s(t.adManualHint),children:[e.jsxs("div",{className:"flex gap-1.5",children:[e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx(z,{value:l,onChange:N=>{d(N),m("")},placeholder:"120212345678901234"})}),e.jsx("button",{type:"button",onClick:W,"data-ad-add":!0,className:"px-3 rounded-lg bg-indigo-600 hover:bg-indigo-500 text-white text-[13px] font-semibold whitespace-nowrap",children:s(t.adManualAdd)})]}),x&&e.jsx("p",{className:"text-[12px] text-rose-300 mt-1",children:x})]}),e.jsxs(C,{label:s(t.adSelected),children:[!w.length&&e.jsx("p",{className:"text-[12px] text-rose-300",children:s(t.adNoneChosen)}),w.length>0&&e.jsx("div",{className:"flex flex-wrap gap-1.5","data-ad-selected":!0,children:w.map(N=>e.jsxs("span",{className:"inline-flex items-center gap-1.5 max-w-full px-2 py-1 rounded-full bg-indigo-500/15 border border-indigo-500/30 text-[12px] text-indigo-200",children:[e.jsxs("span",{className:"truncate max-w-[180px]",title:N,children:[F[N]||N,P.includes(N)?" · "+s(t.adManualAdd).toLowerCase():""]}),e.jsx("button",{type:"button",onClick:()=>S(w.filter(f=>f!==N)),className:"text-indigo-300 hover:text-white leading-none","aria-label":"remover",children:"Ã"})]},N))}),w.filter(N=>i[N]).map(N=>e.jsxs("p",{className:"mt-2 text-[12px] leading-snug text-rose-300","data-ad-conflito":N,children:["â ï¸ ",s(t.adConflito).replace("{anuncio}",`«${D(N)}»`).replace("{fluxos}",u(N))]},N))]}),e.jsxs("label",{className:"flex items-start gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!n.oncePerContact,onChange:N=>o({oncePerContact:N.target.checked}),className:"mt-1 accent-indigo-500"}),e.jsxs("span",{children:[e.jsx("span",{className:"block text-[13px] text-gray-100",children:s(t.adOnce)}),e.jsx("span",{className:"block text-[12px] text-gray-400",children:s(t.adOnceDesc)})]})]}),e.jsx("p",{className:"text-[12px] text-gray-400",children:s(t.adHowWorks)})]})}function dn({cfg:n,onUpdate:o}){const{tl:a}=G();return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-white/[0.03] border border-white/10 rounded-lg p-3 text-[13px] text-gray-300 leading-relaxed flex gap-2",children:[e.jsx("span",{className:"text-base",children:"ð"}),e.jsxs("div",{children:[a(t.fmIntro1)," ",e.jsx("strong",{children:a(t.fmIntroBold)})," ",a(t.fmIntro2)]})]}),e.jsx(C,{label:a(t.fmWhen),children:e.jsx("div",{className:"space-y-1",children:[{v:"never",l:a(t.fmNever),d:a(t.fmNeverDesc)},{v:"days_30",l:a(t.fm30),d:a(t.fm30Desc)},{v:"days_90",l:a(t.fm90),d:a(t.fm90Desc)}].map(s=>{const r=(n.firstMessageMode||"never")===s.v;return e.jsxs("button",{onClick:()=>o({firstMessageMode:s.v}),className:`w-full text-left px-2.5 py-2 rounded-lg border text-[13px] transition-all ${r?"border-indigo-500/60 bg-indigo-500/10":"border-white/10 bg-dark-800/50 hover:border-white/[0.16]"}`,children:[e.jsx("div",{className:`font-semibold ${r?"text-indigo-300":"text-gray-100"}`,children:s.l}),e.jsx("div",{className:"text-[12px] text-gray-400 mt-0.5",children:s.d})]},s.v)})})})]})}function cn({cfg:n,onUpdate:o}){const{tl:a}=G(),{id:s}=bt(),[r,p]=v.useState(""),i=`${typeof window<"u"?window.location.origin:"https://pragmaz.ai"}/api/wa/chatbot/trigger/${s}`,g=n.triggerToken||"",u=g.length>0,l="[email protected]",d=()=>{const b=new Uint8Array(16);if(typeof crypto<"u"&&crypto.getRandomValues)crypto.getRandomValues(b);else for(let F=0;F<b.length;F++)b[F]=Math.floor(Math.random()*256);const w=Array.from(b).map(F=>F.toString(16).padStart(2,"0")).join("");o({triggerToken:w}
3)},x=[`curl -X POST '${i}' \\`," -H 'Content-Type: application/json' \\",` -H 'x-trigger-token: ${g||a(t.whTokenPlaceholderValue)}' \\`,` -d '${JSON.stringify({jid:l,vars:{nome:"João"}})}'`].join(` 4`),m=(b,w)=>{typeof navigator<"u"&&navigator.clipboard&&navigator.clipboard.writeText(b).then(()=>{p(w),setTimeout(()=>p(""),1500)})};return e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"bg-sky-500/5 border border-sky-500/20 rounded-lg p-3 text-[13px] text-sky-200/90 leading-relaxed flex gap-2",children:[e.jsx("span",{className:"text-base",children:"ð"}),e.jsxs("div",{children:[a(t.whIntro1)," ",e.jsx("strong",{children:a(t.whIntroBold)})," ",a(t.whIntro2)]})]}),e.jsx(C,{label:a(t.whToken),hint:a(t.whTokenHint),children:e.jsxs("div",{className:"space-y-1.5",children:[e.jsxs("div",{className:`flex items-stretch border rounded-lg overflow-hidden focus-within:border-indigo-500 ${u?"bg-dark-800 border-white/10":"bg-indigo-500/5 border-indigo-500/40"}`,children:[e.jsx("input",{value:g,onChange:b=>o({triggerToken:b.target.value}),placeholder:a(t.whTokenPh),className:"flex-1 bg-transparent px-2 py-1.5 text-[13px] text-gray-200 font-mono outline-none placeholder-indigo-300/50"}),u&&e.jsx("button",{onClick:()=>m(g,"tok"),className:`px-2 text-[12px] font-medium border-l border-white/10 ${r==="tok"?"bg-indigo-500/20 text-indigo-300":"bg-dark-900/60 text-gray-400 hover:text-gray-100"}`,children:r==="tok"?"â":a(t.copy)})]}),!u&&e.jsxs("p",{className:"text-[12px] text-indigo-300/90 flex items-center gap-1",children:[e.jsx(Xt,{size:10})," ",a(t.whNoToken)]}),e.jsxs("button",{onClick:d,className:"w-full text-[12px] py-1.5 rounded-md bg-indigo-500/10 text-indigo-300 border border-indigo-500/30 hover:bg-indigo-500/20 transition-colors",children:["ð² ",a(u?t.whGenNew:t.whGen)]})]})}),e.jsxs(C,{label:a(t.whUrl),children:[e.jsxs("div",{className:"flex items-stretch bg-dark-800 border border-white/10 rounded-lg overflow-hidden",children:[e.jsx("input",{readOnly:!0,value:i,className:"flex-1 bg-transparent px-2 py-1.5 text-[13px] text-gray-200 font-mono outline-none"}),e.jsx("button",{onClick:()=>m(i,"url"),className:`px-2 text-[12px] font-medium border-l border-white/10 transition-colors ${r==="url"?"bg-indigo-500/20 text-indigo-300":"bg-dark-900/60 text-gray-400 hover:text-gray-100"}`,children:r==="url"?"â":a(t.copy)})]}),e.jsx("p",{className:"text-[12px] text-gray-400 mt-1",children:a(t.whUrlHint)})]}),e.jsx(C,{label:a(t.whCurl),children:e.jsxs("div",{className:"relative bg-dark-900 border border-white/10 rounded-lg overflow-hidden",children:[e.jsx("pre",{className:"text-[12px] text-gray-300 font-mono p-2 overflow-x-auto leading-relaxed whitespace-pre",children:x}),e.jsx("button",{onClick:()=>m(x,"curl"),className:`absolute top-1.5 right-1.5 px-1.5 py-0.5 text-[12px] rounded font-medium transition-colors ${r==="curl"?"bg-indigo-500/20 text-indigo-300":"bg-dark-800/90 text-gray-400 hover:text-gray-100 border border-white/10"}`,children:a(r==="curl"?t.copiedCheck:t.copy)})]})}),e.jsxs("details",{className:"text-[12px]",children:[e.jsxs("summary",{className:"cursor-pointer text-gray-400 hover:text-gray-200",children:["ð ",a(t.whBodyHelp)]}),e.jsxs("div",{className:"text-gray-400 mt-1.5 leading-relaxed space-y-1.5",children:[e.jsxs("p",{children:[a(t.whBodyP1a)," ",e.jsx("code",{className:"bg-dark-800 px-1 rounded text-gray-300",children:"jid"})," ",a(t.whBodyP1b)," ",e.jsx("code",{className:"bg-dark-800 px-1 rounded text-gray-300",children:"vars"})," ",a(t.whBodyP1c)," ",e.jsx("code",{className:"bg-dark-800 px-1 rounded text-gray-300",children:"{{nome}}"}),")."]}),e.jsxs("p",{children:[a(t.whBodyP2a)," ",e.jsx("code",{className:"bg-dark-800 px-1 rounded text-gray-300",children:"{ ok: true, sessionId, chatbotSessionId }"}),". ",a(t.whBodyP2b)," ",e.jsx("code",{className:"bg-dark-800 px-1 rounded text-gray-300",children:"{ error }"})," ",a(t.whBodyP2c)]}),e.jsx("p",{children:a(t.whBodyP3)})]})]}),e.jsxs("details",{className:"text-[12px]",children:[e.jsxs("summary",{className:"cursor-pointer text-gray-400 hover:text-gray-200",children:["ð¢ ",a(t.whIntegHelp)]}),e.jsxs("p",{className:"text-gray-400 mt-1.5 leading-relaxed",children:[a(t.whIntegA)," ",e.jsx("code",{className:"bg-dark-800 px-1 rounded text-gray-300",children:"x-trigger-token"})," ",a(t.whIntegB)," ",e.jsx("code",{className:"bg-dark-800 px-1 rounded text-gray-300",children:"jid"})," ",a(t.whIntegC)]})]})]})}function pn(n,o){const a=(o||[]).map(r=>
4String(r||"").trim()).filter(Boolean);return a.length?String(n||"").split(` 5`).filter(r=>{const p=r.match(/^\s*(\d+)\s*[-).:â¢]?\s*(.+?)\s*$/);if(!p)return!0;const j=a[parseInt(p[1],10)-1];return!(j&&p[2].trim().toLowerCase()===j.toLowerCase())}).join(` 6`).replace(/\n{3,}/g,` 7 8`).trim():String(n||"")}function un(n,o){const a=String(n||"").trim(),s=(o||[]).map(p=>String(p||"").trim()).filter(Boolean);if(!s.length)return a;const r=s.map((p,j)=>`${j+1} - ${p}`).join(` 9`);return a?`${a} 10 11${r}`:r}function mn({cfg:n,onUpdate:o,tl:a,T:s}){const r=n.options||[],p=v.useRef([]);v.useEffect(()=>{const l=pn(n.question,r);l!==String(n.question||"")&&o({question:l})},[n.question,r.join("\0")]);const j=(l,d)=>o({options:r.map((x,m)=>m===l?d:x)}),i=l=>o({options:r.filter((d,x)=>x!==l)}),g=(l=r.length-1)=>{const d=[...r];d.splice(l+1,0,""),o({options:d}),requestAnimationFrame(()=>{var x;return(x=p.current[l+1])==null?void 0:x.focus()})},u=un(n.question,r);return e.jsxs(e.Fragment,{children:[e.jsx(C,{label:a(s.inQuestion),hint:a(s.chQuestionHint),children:e.jsx(de,{value:n.question||"",onChange:l=>o({question:l}),rows:3})}),e.jsx(C,{label:a(s.chOptions),hint:a(s.chOptionsHint),children:e.jsxs("div",{className:"space-y-1.5",children:[r.map((l,d)=>e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"w-6 h-6 shrink-0 grid place-items-center rounded-md bg-dark-700 text-[11px] font-semibold text-gray-300",children:d+1}),e.jsxs("div",{className:"flex-1 min-w-0 flex items-stretch bg-dark-800 border border-white/10 rounded-lg overflow-hidden transition-colors focus-within:border-indigo-500 focus-within:ring-1 focus-within:ring-indigo-500/30",children:[e.jsx("input",{ref:x=>{p.current[d]=x},value:l,onChange:x=>j(d,x.target.value),onKeyDown:x=>{x.key==="Enter"&&(x.preventDefault(),g(d)),x.key==="Backspace"&&!l&&r.length>1&&(x.preventDefault(),i(d),requestAnimationFrame(()=>{var m;return(m=p.current[Math.max(0,d-1)])==null?void 0:m.focus()}))},placeholder:a(s.chOptionPh),className:"flex-1 bg-transparent px-3 py-2 text-[13px] text-gray-100 placeholder-gray-400 outline-none min-w-0"}),e.jsxs("span",{className:"px-2.5 flex items-center text-[11px] text-gray-400 font-mono bg-dark-900/60 shrink-0",children:["out-",d]})]}),e.jsx("button",{type:"button",onClick:()=>i(d),title:a(s.chRemoveOption),"aria-label":`${a(s.chRemoveOption)} ${d+1}`,className:"w-7 h-7 shrink-0 grid place-items-center rounded-md text-gray-400 hover:text-red-400 hover:bg-red-500/10 transition-colors",children:e.jsx(Pe,{size:14})})]},d)),e.jsxs("button",{type:"button",onClick:()=>g(),className:"flex items-center gap-1.5 px-2.5 py-1.5 rounded-md text-[13px] text-indigo-400 hover:bg-indigo-500/10 transition-colors",children:[e.jsx(ge,{size:14})," ",a(s.chAddOption)]})]})}),e.jsx(C,{label:a(s.chVariable),hint:a(s.chVariableHint),children:e.jsx(z,{value:n.variable||"",onChange:l=>o({variable:l}),placeholder:a(s.chVariablePh)})}),e.jsx(C,{label:a(s.chPreview),children:e.jsx("div",{className:"cbe-wa-preview",children:u?e.jsx("div",{className:"cbe-wa-bubble",children:u}):e.jsx("p",{className:"cbe-wa-vazio",children:a(s.chPreviewEmpty)})})}),e.jsx("p",{className:"text-[13px] text-gray-400 leading-relaxed",children:r.length===0?a(s.chEmpty):`${r.length} ${a(s.chOutputs)} ${r.map((l,d)=>`out-${d}`).join(", ")}`})]})}function C({label:n,hint:o,children:a}){return e.jsxs("div",{children:[e.jsx("label",{className:"block text-[13px] font-medium text-gray-300 mb-1.5",children:n}),a,o&&e.jsx("p",{className:"text-[12px] text-gray-400 mt-1",children:o})]})}function z({value:n,onChange:o,placeholder:a,type:s="text",prefix:r,suffix:p}){return e.jsxs("div",{className:"flex items-stretch bg-dark-800 border border-white/10 rounded-lg overflow-hidden transition-colors focus-within:border-indigo-500 focus-within:ring-1 focus-within:ring-indigo-500/30",children:[r&&e.jsx("span",{className:"px-2.5 flex items-center text-gray-400 text-[13px] font-mono bg-dark-900/60",children:r}),e.jsx("input",{type:s,value:n??"",onChange:j=>o(j.target.value),placeholder:a,className:"flex-1 bg-transparent px-3 py-2 text-[13px] text-gray-100 placeholder-gray-400 outline-none min-w-0"}),p&&e.jsx("span",{className:"px-2.5 flex items-center text-gray-400 text-[13px] font-mono bg-dark-900/60",children:p})]})}function de({value:n,onChange:o,rows:a=3,mono:s}){return e.jsx("textarea",{value:n??"",onChange:r=>o(r.target.value),rows:a,className:`w-full bg-dark-800 border border-white/10 rounded-lg px-3 py-2 text-[13px] text-gray-100 placeholder-gray-400 outline-none transition-colors resize-y focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500/30 ${s?"font-mono":""}`})}function xn({value:n,onChange:o,rows:a=3,trim:s=!0,placeholder:r}){const p=u=>u.split(` 12`).map(l=>
12s?l.trim():l).filter(Boolean),j=Array.isArray(n)?n:[],[i,g]=v.useState(()=>j.join(` 13`));return v.useEffect(()=>{const u=p(i);(u.length!==j.length||u.some((l,d)=>l!==j[d]))&&g(j.join(` 14`))},[n]),e.jsx("textarea",{value:i,placeholder:r,onChange:u=>{g(u.target.value),o(p(u.target.value))},onBlur:()=>g(p(i).join(` 15`)),rows:a,className:"w-full bg-dark-800 border border-white/10 rounded-lg px-3 py-2 text-[13px] text-gray-100 placeholder-gray-400 outline-none transition-colors resize-y focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500/30"})}function ae({value:n,onChange:o,options:a}){return e.jsx("select",{value:n,onChange:s=>o(s.target.value),className:"w-full bg-dark-800 border border-white/10 rounded-lg px-3 py-2 text-[13px] text-gray-100 outline-none transition-colors focus:border-indigo-500 focus:ring-1 focus:ring-indigo-500/30",children:a.map(s=>e.jsx("option",{value:s.v,children:s.l},s.v))})}function hn({status:n}){const{tl:o}=G(),a={active:{class:"bg-emerald-500/15 text-emerald-300 border-emerald-500/30",label:o(t.sbPublished)},paused:{class:"bg-white/[0.05] text-gray-300 border-white/12",label:o(t.sbPaused)},draft:{class:"bg-gray-500/15 text-gray-400 border-gray-500/30",label:o(t.sbDraft)}}[n];return a?e.jsx("span",{className:`text-[10px] px-2 py-0.5 rounded-full border font-bold uppercase tracking-wider ${a.class}`,children:a.label}):null}function gn({metrics:n,nodes:o,edges:a,days:s}){var b,w,F,D,S,B,W,T,P,N,f,L,$,K,V;const{tl:r}=G();if(!(n!=null&&n.byNode))return null;const p=Object.fromEntries(o.map(I=>[I.id,I]));let j=0,i=0,g=0,u=!1;for(const[I,U]of Object.entries(n.byNode)){const Q=p[I];(((b=Q==null?void 0:Q.data)==null?void 0:b.type)==="trigger"||((w=Q==null?void 0:Q.data)==null?void 0:w.type)==="template_entry")&&(j+=U.executions||0,U.unique_people!=null&&(i+=U.unique_people,u=!0),g+=U.unique_sessions||0)}n.entrada&&n.entrada.unique_people!=null&&(i=n.entrada.unique_people,u=!0,n.entrada.unique_sessions!=null&&(g=n.entrada.unique_sessions)),n.entrada&&typeof n.entrada.executions=="number"&&(j=n.entrada.executions);let l=null;for(const[I,U]of Object.entries(n.byBranch||{}))for(const Q of U)if(!l||Q.clicks>l.clicks){const Z=p[I],ce=p[Q.next_node];let oe=null;if((F=Z==null?void 0:Z.data)!=null&&F.config){const Ae=Z.data.config,Be=a.find(pe=>pe.source===I&&pe.target===Q.next_node),Ne=(D=Be==null?void 0:Be.sourceHandle)==null?void 0:D.match(/^out-(\d+)$/),qe=Ne?parseInt(Ne[1],10):null;if(qe!=null){if(Z.data.type==="buttons")oe=(S=Ae.buttons)==null?void 0:S[qe];else if(Z.data.type==="choice")oe=(B=Ae.options)==null?void 0:B[qe];else if(Z.data.type==="list"){let pe=0;for(const Y of Ae.sections||[]){for(const ue of Y.rows||[]){if(pe===qe){oe=typeof ue=="string"?ue:ue==null?void 0:ue.title;break}pe++}if(oe)break}}}}l={clicks:Q.clicks,label:oe||`â ${((T=(W=ce==null?void 0:ce.data)==null?void 0:W.config)==null?void 0:T.label)||r(t.msNextStep)}`,nodeName:((N=(P=Z==null?void 0:Z.data)==null?void 0:P.config)==null?void 0:N.label)||((f=Z==null?void 0:Z.data)==null?void 0:f.type)||r(t.msMenu)}}const d=new Set(["input","buttons","list","choice","template"]);let x=null;for(const[I,U]of Object.entries(n.byNode)){const Q=p[I];if(!Q||!d.has((L=Q.data)==null?void 0:L.type)||U.executions<3)continue;const Z=U.executions>0?Math.round(U.drop_off/U.executions*100):0;Z<20||(!x||U.drop_off>x.count)&&(x={count:U.drop_off,pct:Z,name:((K=($=Q.data)==null?void 0:$.config)==null?void 0:K.label)||((V=Q.data)==null?void 0:V.type)})}const m={1:r(t.msToday),7:r(t.msLast7),30:r(t.msLast30),90:r(t.msLast90),365:r(t.msLastYear)}[s]||`${s}d`;return e.jsxs("div",{className:"bg-dark-900/95 backdrop-blur border border-indigo-500/30 rounded-xl shadow-lg w-72 overflow-hidden",children:[e.jsxs("div",{className:"px-3 py-2 bg-gradient-to-r from-indigo-500/10 to-indigo-500/10 border-b border-white/[0.07] flex items-center gap-2",children:[e.jsx(aa,{size:13,className:"text-indigo-300"}),e.jsx("span",{className:"text-[11px] font-bold text-gray-100 flex-1",children:r(t.msTitle)}),e.jsx("span",{className:"text-[9px] text-gray-500",children:m})]}),e.jsxs("div",{className:"p-3 space-y-3",children:[e.jsxs("div",{children:[e.jsx("div",{className:"text-[10px] text-gray-500 uppercase tracking-wider mb-1",children:r(u?t.msPeopleServed:t.msTriggers)}),e.jsxs("div",{className:"flex items-baseline gap-2",children:[e.jsx("span",{className:"text-2xl font-bold text-emerald-300 tabular-nums",children:u?i:j}
15),e.jsx("span",{className:"text-[11px] text-gray-400",children:r(u?i===1?t.msPersonIn:t.msPeopleIn:j===1?t.msFiredOnce:t.msFiredMany)})]}),e.jsxs("div",{className:"text-[10px] text-gray-500 mt-0.5 space-x-2",children:[u&&e.jsxs("span",{title:r(t.msTriggerTitle),children:[j," ",r(j===1?t.msTriggerOne:t.msTriggerMany)]}),g>0&&g!==i&&e.jsxs("span",{title:r(t.msConvTitle),children:["· ",g," ",r(g===1?t.msConvOne:t.msConvMany)]})]})]}),l&&e.jsxs("div",{className:"pt-2 border-t border-white/[0.07]",children:[e.jsxs("div",{className:"text-[10px] text-gray-500 uppercase tracking-wider mb-1",children:["ð ",r(t.msMostClicked)]}),e.jsx("div",{className:"text-[12px] font-semibold text-gray-100 truncate",title:l.label,children:l.label}),e.jsxs("div",{className:"text-[10px] text-gray-400 mt-0.5",children:[e.jsx("span",{className:"font-bold text-indigo-300",children:l.clicks})," ",l.clicks===1?r(t.msClickOne):r(t.msClickMany),e.jsxs("span",{className:"text-gray-600",children:[" · ",r(t.msIn),' "',l.nodeName,'"']})]})]}),x&&e.jsxs("div",{className:"pt-2 border-t border-white/[0.07]",children:[e.jsxs("div",{className:"text-[10px] text-gray-500 uppercase tracking-wider mb-1",children:["â ï¸ ",r(t.msDropOff)]}),e.jsx("div",{className:"text-[12px] font-semibold text-gray-100 truncate",title:x.name,children:x.name}),e.jsxs("div",{className:"text-[10px] text-gray-400 mt-0.5",children:[e.jsx("span",{className:"font-bold text-rose-300",children:x.count})," ",x.count===1?r(t.msDropOne):r(t.msDropMany),e.jsxs("span",{className:"text-gray-600",children:[" (",x.pct,"%)"]})]})]}),!l&&!x&&e.jsx("div",{className:"pt-2 border-t border-white/[0.07] text-[10px] text-gray-500 italic text-center",children:r(t.msNoData)}),e.jsx("div",{className:"pt-2 border-t border-white/[0.07] text-[9px] text-gray-600 text-center",children:r(t.msRefresh)})]})]})}function bn({nodes:n,edges:o}){const{tl:a}=G(),s=j=>{var i,g;return((i=j.data)==null?void 0:i.type)==="trigger"||((g=j.data)==null?void 0:g.type)==="template_entry"},r=n.filter(s).length,p=n.filter(j=>s(j)?!1:!o.some(i=>i.target===j.id)).length;return e.jsxs("div",{className:"bg-dark-900/90 backdrop-blur border border-white/[0.07] rounded-lg px-3 py-2 flex items-center gap-4 text-[10px]",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-gray-300",children:[e.jsx(na,{size:11})," ",n.length," ",a(t.fsNodes)," · ",o.length," ",a(t.fsEdges)]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-emerald-300",children:[e.jsx(at,{size:11})," ",r," ",a(r!==1?t.fsEntryMany:t.fsEntryOne)]}),p>0&&e.jsxs("div",{className:"flex items-center gap-1.5 text-rose-300",children:[e.jsx(Jt,{size:11})," ",p," ",a(p!==1?t.fsOrphanMany:t.fsOrphanOne)]})]})}export{En as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.