1!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},t=(new e.Error).stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="33f50e6e-2655-4564-b2e9-9fe1090f49ce",e._sentryDebugIdIdentifier="sentry-dbid-33f50e6e-2655-4564-b2e9-9fe1090f49ce")}catch(e){}}();"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3231],{65600:function(e,t,n){n.d(t,{p:function(){return i}});var r=n(99199),s=n(71632);let o={PIXEL:"P\xe1gina",GOOGLE_ADS:"Google Ads",FACEBOOK_ADS:"Meta Ads",HOTMART:"Hotmart",TALLY_FORMS:"Tally Forms",WEBHOOK:"Webhook API",FORM:"Formul\xe1rios",ACTIVECAMPAIGN_EVENTS:"ActiveCampaign",META_PAGES_INSTAGRAM:"Facebook Pages + Instagram",ZOOM:"Zoom",SENDGRID:"SendGrid",KIWIFY:"Kiwify",DATABASE:"Banco de dados"};function a(e){var t,n,r,s,a;return{id:e.id,name:e.name,slug:e.slug,origin:e.source_type,engine:"string"==typeof(null===(t=e.config)||void 0===t?void 0:t.engine)?e.config.engine:null,product:(null===(n=e.config)||void 0===n?void 0:n.product)==="instagram"||(null===(r=e.config)||void 0===r?void 0:r.product)==="facebook_pages"?e.config.product:null,originLabel:"META_PAGES_INSTAGRAM"===e.source_type&&(null===(s=e.config)||void 0===s?void 0:s.product)==="instagram"?"Instagram":"META_PAGES_INSTAGRAM"===e.source_type&&(null===(a=e.config)||void 0===a?void 0:a.product)==="facebook_pages"?"P\xe1ginas do Facebook":o[e.source_type]||e.source_type,capabilities:e.capabilities,status:e.status,isActive:e.is_active,lastSyncAt:e.last_sync_at,lastSyncStatus:e.last_sync_status,lastEventAt:e.last_event_at,eventsLast30Days:e.events_count_30d,createdAt:e.created_at,updatedAt:e.updated_at}}function i(){var e,t,n,o,i,l;let d=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},u=(0,r.i)(e=>e.project),c=(null==u?void 0:u.uuid)||"",m=(0,s.a)({queryKey:["sources",c,d],queryFn:async()=>{let e=new URLSearchParams;d.search&&e.set("search",d.search),d.sourceType&&e.set("source_type",d.sourceType),d.status&&e.set("status",d.status),d.sort&&e.set("sort",d.sort),d.order&&e.set("order",d.order),d.page&&e.set("page",String(d.page)),d.pageSize&&e.set("page_size",String(d.pageSize));let t=e.toString(),n=await fetch("/api/projects/".concat(c,"/sources").concat(t?"?".concat(t):""));if(!n.ok)throw Error("Failed to fetch sources");let r=await n.json();return{sources:r.results.map(a),total:r.count,hasMore:null!==r.next}},enabled:!!c});return{sources:null!==(o=null===(e=m.data)||void 0===e?void 0:e.sources)&&void 0!==o?o:[],total:null!==(i=null===(t=m.data)||void 0===t?void 0:t.total)&&void 0!==i?i:0,hasMore:null!==(l=null===(n=m.data)||void 0===n?void 0:n.hasMore)&&void 0!==l&&l,isLoading:m.isLoading,error:m.error,refetch:m.refetch}}},3231:function(e,t,n){n.r(t),n.d(t,{JourneyFlowTemplate:function(){return rk},origemDoGatilho:function(){return rC},rotuloDaOrigem:function(){return r_},tipoDoNo:function(){return rS}});var r=n(57437);let s=/^([01]\d|2[0-3]):[0-5]\d$/;function o(e){let t=null==e?void 0:e.desde;return t&&"number"==typeof t.version&&t.created_at?{version:t.version,created_at:t.created_at}:null}function a(e){if(!e)return null;let t=new Date(e.created_at);return Number.isNaN(t.getTime())?null:{key:"journeys.detail.sinceRevision",params:{date:t.toLocaleDateString(void 0,{day:"2-digit",month:"2-digit"}),version:e.version}}}var i=n(36555),l=n(79455),d=n(95733),u=n(25477),c=n(57175),m=n(24028),x=n(65252),p=n(19889),h=n(32286),j=n(29827),v=n(71632),g=n(21770),f=n(52542);n(36190);var b=n(99397),y=n(32489),N=n(21047),k=n(75821),w=n(27648),_=n(99376),C=n(2265),A=n(14438),S=n(56372),I=n(68440),z=n(13781),E=n(65690),T=n(8522),L=n(91723),P=n(44743),Z=n(53761);let D=[{tipo:"branch",icone:z.Z,chave:"journeys.builder.addBranch"},{tipo:"hold",icone:E.Z,chave:"journeys.builder.addHold"},{tipo:"split",icone:T.Z,chave:"journeys.split.menuItem"}],M={jornada:function(e){var t;let{id:n,sourceX:s,sourceY:o,targetX:a,targetY:i,sourcePosition:l,targetPosition:d,data:u,markerEnd:c}=e,{t:m}=(0,p.$G)(),[x,h,j]=(0,I.OW)({sourceX:s,sourceY:o,targetX:a,targetY:i,sourcePosition:l,targetPosition:d,borderRadius:10}),v=null!=u?u:{},g=null!==(t=v.insercao)&&void 0!==t?t:null,y=!!(v.podeInserir&&g&&v.onInserir);return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(f.u5,{id:n,path:x,markerEnd:c,interactionWidth:0,style:{stroke:"hsl(var(--muted-foreground) / 0.45)",strokeWidth:1.25}}),y&&g?(0,r.jsx)(f.XQ,{children:(0,r.jsx)("div",{className:"nodrag nopan","data-aresta":n,style:{position:"absolute",transform:"translate(-50%, -50%) translate(".concat(h,"px, ").concat(j,"px)"),pointerEvents:"all",zIndex:10},children:(0,r.jsxs)(S.h_,{children:[(0,r.jsx)(S.$F,{asChild:!0,children:(0,r.jsx)("button",{type:"button","aria-label":m("journeys.flow.addStep"),title:m("journeys.flow.addStep"),className:"flex h-5 w-5 items-center justify-center rounded-full border bg-background text-muted-foreground opacity-60 shadow-sm transition hover:scale-110 hover:border-primary hover:text-primary hover:opacity-100",children:(0,r.jsx)(b.Z,{className:"h-3 w-3"})})}),(0,r.jsxs)(S.AW,{align:"center",className:"z-[90]",children:[(0,r.jsxs)(S.Xi,{onClick:()=>{var e;return null===(e=v.onInserir)||void 0===e?void 0:e.call(v,g,"wait")},children:[(0,r.jsx)(L.Z,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground"})," ",m("journeys.builder.addWait")]}),(0,r.jsxs)(S.Xi,{onClick:()=>{var e;return null===(e=v.onInserir)||void 0===e?void 0:e.call(v,g,"action")},children:[(0,r.jsx)(P.Z,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground"})," ",m("journeys.builder.addAction")]}),g.nivelDeBranch<Z.Hv&&D.map(e=>{let{tipo:t,icone:n,chave:s}=e;return(0,r.jsxs)(S.Xi,{onClick:()=>{var e;return null===(e=v.onInserir)||void 0===e?void 0:e.call(v,g,t)},children:[(0,r.jsx)(n,{className:"mr-2 h-3.5 w-3.5 text-muted-foreground"})," ",m(s)]},t)})]})]})})}):null]})}};var G=n(76865),R=n(11239),O=n(47692),$=n(62720),B=n(95468),F=n(23882),H=n(7912),q=n(31683);
1let K="!h-2 !w-2 !border-border !bg-muted-foreground/40",V={amber:"bg-amber-100 text-amber-700 dark:bg-amber-950 dark:text-amber-400",rose:"bg-rose-100 text-rose-700 dark:bg-rose-950 dark:text-rose-400",violet:"bg-violet-100 text-violet-700 dark:bg-violet-950 dark:text-violet-400",sky:"bg-sky-100 text-sky-700 dark:bg-sky-950 dark:text-sky-400",emerald:"bg-emerald-100 text-emerald-700 dark:bg-emerald-950 dark:text-emerald-400"};function W(e){let{data:t,selected:n,icone:s,cor:o,entrada:a=!0,saida:i=!0}=e;return(0,r.jsxs)("div",{className:(0,F.cn)("w-full cursor-pointer rounded-lg border bg-card px-3 py-2.5 text-card-foreground shadow-sm transition-colors",n?"border-primary ring-1 ring-primary/40":"hover:border-primary/40",t.erro&&"border-destructive/60"),children:[a&&(0,r.jsx)(f.HH,{type:"target",position:I.Ly.Top,className:K}),(0,r.jsxs)("div",{className:"flex items-start gap-2.5",children:[(0,r.jsx)("span",{className:(0,F.cn)("mt-0.5 flex h-7 w-7 shrink-0 items-center justify-center rounded-md",V[o]),children:(0,r.jsx)(s,{className:"h-3.5 w-3.5"})}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsxs)("span",{className:"flex items-center gap-1.5",children:[(0,r.jsx)("span",{className:"block text-[10px] font-medium uppercase tracking-wide text-muted-foreground",children:t.rotulo}),t.erro&&(0,r.jsx)(G.Z,{className:"h-3 w-3 shrink-0 text-destructive"}),t.avisoDestino&&!t.erro&&(0,r.jsx)(G.Z,{className:"h-3 w-3 shrink-0 text-amber-600 dark:text-amber-400"})]}),(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1.5",children:[t.badge?(0,r.jsx)("span",{className:"shrink-0 rounded border px-1 font-mono text-[10px] text-muted-foreground",children:t.badge}):null,(0,r.jsx)("span",{className:"block min-w-0 truncate text-sm text-foreground",title:t.titulo,children:t.titulo})]}),(t.numeros||t.mortos||t.desde)&&(0,r.jsxs)("span",{className:"mt-1 flex flex-wrap items-baseline gap-x-2 text-[11px] tabular-nums text-muted-foreground",children:[t.numeros?(0,r.jsx)("span",{children:t.numeros}):null,t.mortos?(0,r.jsx)("span",{className:"text-red-600 dark:text-red-400",children:t.mortos}):null,t.desde?(0,r.jsx)("span",{className:"rounded bg-muted px-1 py-px text-[10px] font-normal not-italic tabular-nums",children:t.desde}):null]})]})]}),i&&(0,r.jsx)(f.HH,{type:"source",position:I.Ly.Bottom,className:K})]})}let Q={trigger:function(e){let{data:t,selected:n}=e,s=t.origem?q.l[t.origem]:void 0,o=s?e=>{let{className:t}=e;return(0,r.jsx)(s,{className:t,showTooltip:!1})}:R.Z;return(0,r.jsx)(W,{data:t,selected:n,icone:o,cor:"amber",entrada:!1})},trigger_vazio:function(e){let{data:t,selected:n}=e;return(0,r.jsxs)("div",{className:(0,F.cn)("flex h-full min-h-[72px] w-full cursor-pointer items-center justify-center rounded-lg border border-dashed px-6 py-6 text-center transition-colors",n?"border-primary bg-primary/5":"border-muted-foreground/40 hover:border-primary/50 hover:bg-muted/40"),children:[(0,r.jsx)("span",{className:"text-sm text-muted-foreground",children:t.rotulo}),(0,r.jsx)(f.HH,{type:"source",position:I.Ly.Bottom,className:K})]})},fim:function(e){let{data:t}=e;return(0,r.jsxs)("div",{className:"flex h-full w-full items-center justify-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,r.jsx)(f.HH,{type:"target",position:I.Ly.Top,className:K}),(0,r.jsx)(B.Z,{className:"h-3 w-3"}),t.rotulo]})},exit:function(e){let{data:t,selected:n}=e;return(0,r.jsx)(W,{data:t,selected:n,icone:O.Z,cor:"rose",saida:!1})},wait:function(e){let{data:t,selected:n}=e;return(0,r.jsx)(W,{data:t,selected:n,icone:L.Z,cor:"sky"})},action:function(e){let{data:t,selected:n}=e,s=t.destinoTipo?e=>{let{className:n}=e;return(0,r.jsx)(H.s,{id:t.destinoTipo,className:n})}:P.Z;return(0,r.jsx)(W,{data:t,selected:n,icone:s,cor:"emerald"})},branch:function(e){let{data:t,selected:n}=e;return(0,r.jsx)(W,{data:t,selected:n,icone:z.Z,cor:"violet"})},set_attribute:function(e){let{data:t,selected:n}=e;return(0,r.jsx)(W,{data:t,selected:n,icone:$.Z,cor:"emerald"})},hold_until:function(e){let{data:t,selected:n}=e;return(0,r.jsx)(W,{data:t,selected:n,icone:E.Z,cor:"amber"})},split:function(e){let{data:t,selected:n}=e;return(0,r.jsx)(W,{data:t,selected:n,icone:T.Z,cor:"violet"})},case:function(e){let{data:t,selected:n}=e,{t:s}=(0,p.$G)();return(0,r.jsxs)("div",{className:(0,F.cn)("flex h-8 w-full cursor-pointer items-center justify-between gap-2 rounded-full border bg-background px-3 shadow-sm transition-colors",n?"border-primary ring-1 ring-primary/40":"hover:border-primary/40",t.erro&&"border-destructive/60"),title:"".concat(t.rotulo).concat(t.holdout?" \xb7 ".concat(s("journeys.split.holdout")):"")+" \xb7 ".concat(t.numero," ").concat(t.tituloDoNumero),children:[(0,r.jsx)(f.HH,{type:"target",position:I.Ly.Top,className:K}),(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-1",children:[(0,r.jsx)("span",{className:(0,F.cn)("truncate text-[11px] font-medium",t.ehDefault?"text-muted-foreground":"text-foreground"),children:t.rotulo}),t.holdout&&(0,r.jsx)("span",{className:"shrink-0 rounded bg-muted px-1 text-[9px] uppercase tracking-wide text-muted-foreground",children:s("journeys.split.holdout")})]}),(0,r.jsxs)("span",{className:"flex shrink-0 items-center gap-1 text-[11px] tabular-nums text-muted-foreground",children:[t.erro&&(0,r.jsx)(G.Z,{className:"h-3 w-3 text-destructive"}),t.numero]}),(0,r.jsx)(f.HH,{type:"source",position:I.Ly.Bottom,className:K})]})}};var U=n(27064),J=n(63935),X=n(88414),Y=n(14163),ee=n(48125),et=n(10877),en=n(28737),er=n(73107),es=n(14858),eo=n(77646),ea=n(33245),ei=n(18930),el=n(30401),ed=n(10407),eu=n(61788),ec=n(30588);let em={editavel:!0,origem:"HOTMART",eventos:[],filtro:null};function ex(e){return e.editavel?(0,Z.aU)(e.origem,e.eventos,e.filtro):e.original}let ep={editavel:!0,spec:{origem:null,sourceIds:[],eventos:[],filtro:null}};function eh(e){return!e||!!e.editavel&&(null===e.spec.origem||0===e.spec.eventos.length)}
1function ej(e,t,n){if(!e)return ep;let r=(0,Z.Q$)(e,t,n);return r?{editavel:!0,spec:r}:{editavel:!1,original:e}}function ev(e){return e.editavel?e.spec.origem?(0,Z.VK)(e.spec):null:e.original}function eg(e,t){var n,r,s,o;if("hold_until"===e.kind){let n=!1,s={};for(let o of["met","timeout"]){let a=e[o],i=null!==(r=null==a?void 0:a.steps)&&void 0!==r?r:[],l=t(i);s[o]=l===i?a:{...a,steps:l},l!==i&&(n=!0)}return n?{...e,met:s.met,timeout:s.timeout}:e}if("split"===e.kind){let n=!1,r=(null!==(s=e.paths)&&void 0!==s?s:[]).map(e=>{var r;let s=null!==(r=null==e?void 0:e.steps)&&void 0!==r?r:[],o=t(s);return o===s?e:(n=!0,{...e,steps:o})});return n?{...e,paths:r}:e}if("branch"!==e.kind)return e;let a=!1,i=e.cases.map(e=>{var n;let r=null!==(n=e.steps)&&void 0!==n?n:[],s=t(r);return s===r?e:(a=!0,{...e,steps:s})}),l=null!==(o=null===(n=e.default)||void 0===n?void 0:n.steps)&&void 0!==o?o:[],d=t(l);return d!==l&&(a=!0),a?{...e,cases:i,default:{...e.default,steps:d}}:e}function ef(e,t){let n=!1,r=e.map(e=>{let r=t(e);return r!==e&&(n=!0),r});return n?r:e}function eb(e,t){let n=!1,r=e.filter(e=>e.id!==t||(n=!0,!1)),s=ef(r,e=>eg(e,e=>eb(e,t)));return n||s!==r?s:e}function ey(e,t,n){return ef(e,e=>{if(e.id===t){let t={...e,...n,id:e.id,kind:e.kind};if("hold_until"===e.kind&&"hold_until"===t.kind){var r,s,o,a,i,l;t.met={...t.met,id:null!==(i=null===(r=e.met)||void 0===r?void 0:r.id)&&void 0!==i?i:null===(s=t.met)||void 0===s?void 0:s.id},t.timeout={...t.timeout,id:null!==(l=null===(o=e.timeout)||void 0===o?void 0:o.id)&&void 0!==l?l:null===(a=t.timeout)||void 0===a?void 0:a.id}}return t}return eg(e,e=>ey(e,t,n))})}function eN(e,t,n){if(n.id!==t)throw Error("substituirPassoNaArvore: o passo novo precisa ter o mesmo id (".concat(t," != ").concat(n.id,")"));return ef(e,e=>e.id===t?n:eg(e,e=>eN(e,t,n)))}function ek(e,t,n,r,s){return ef(e,e=>{if(e.kind===t&&e.id===n){let n={...r(e),id:e.id,kind:t};return s?s(e,n):n}return eg(e,e=>ek(e,t,n,r,s))})}function ew(e,t,n){return ek(e,"split",t,n)}function e_(e,t,n){return ek(e,"branch",t,n)}function eC(e,t){for(let n of e){if(n.id===t)return n;let e=null;if(eg(n,n=>(e=null!=e?e:eC(n,t),n)),e)return e}return null}var eA=n(53565);function eS(e){var t;let n=null!==(t=e.params)&&void 0!==t?t:{},r=Object.keys(n).sort().map(e=>"".concat(e,"=").concat(String(n[e]))).join("&");return"".concat(e.key,"|").concat(r)}function eI(e,t){let n=null!=e?e:[],r=new Set((null!=t?t:[]).filter(Boolean).map(e=>eS(e)));return 0===r.size?[...n]:n.filter(e=>!r.has(eS(e)))}var ez=n(34437),eE=n(49906),eT=n(58340),eL=n(36204);function eP(e){if(""===e.trim())return"";let t=Number(e);return Number.isFinite(t)?t:""}let eZ=[{tipo:"texto",rotulo:"journeysAcao.atributo.tipoTexto"},{tipo:"numero",rotulo:"journeysAcao.atributo.tipoNumero"},{tipo:"booleano",rotulo:"journeysAcao.atributo.tipoBooleano"}];function eD(e){var t;let{passo:n,onChange:s,projectId:o}=e,{t:a}=(0,p.$G)(),{chaves:i,carregando:l}=(0,eT.c)(o),[d,c]=(0,C.useState)(()=>(0,eL.EO)(n.value)),[m,x]=(0,C.useState)(n.id),[h,j]=(0,C.useState)({chave:!1,valor:!1});m!==n.id&&(x(n.id),c((0,eL.EO)(n.value)),j({chave:!1,valor:!1}));let v="string"==typeof(t=n.value)?t:null==t?"":Array.isArray(t)||"object"==typeof t?JSON.stringify(t):String(t),g=h.chave?(0,eL.rz)((0,eL.LJ)(n.key)):null,f=h.valor?(0,eL.rz)((0,eL.$6)(n.value)):null,b=e=>{j(e=>e.valor?e:{...e,valor:!0}),s(e)},y=e=>{c(e),"numero"===e?b({value:eP(v)}):"booleano"===e?b({value:"boolean"==typeof n.value?n.value:""}):b({value:v})};return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:a("journeysAcao.atributo.chave")}),(0,r.jsx)(eE.J,{options:i,value:n.key,onChange:e=>{j(e=>e.chave?e:{...e,chave:!0}),s({key:e})},isLoading:l,error:!!g,placeholder:a("journeysAcao.atributo.chavePlaceholder"),commitarAoDigitar:!0}),i.length>0&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("journeysAcao.atributo.chaveSugestoes")}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("journeysAcao.atributo.chaveAjuda")}),g&&(0,r.jsx)("p",{className:"text-[11px] text-destructive",children:a(g)})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:a("journeysAcao.atributo.valor")}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsxs)(J.Ph,{value:d,onValueChange:e=>y(e),children:[(0,r.jsx)(J.i4,{className:"w-32 shrink-0",children:(0,r.jsx)(J.ki,{})}),(0,r.jsx)(J.Bw,{children:eZ.map(e=>(0,r.jsx)(J.Ql,{value:e.tipo,children:a(e.rotulo)},e.tipo))})]}),(0,r.jsx)(eM,{tipo:d,valor:n.value,texto:v,onChange:b})]}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a("journeysAcao.atributo.valorAjuda",{chave:n.key||"â¦"})}),f&&(0,r.jsx)("p",{className:"text-[11px] text-destructive",children:a(f)})]}),n.key.trim()?(0,r.jsx)("p",{className:"rounded-md border border-dashed px-2 py-1.5 text-[11px] text-muted-foreground",children:a("journeysAcao.atributo.resumo",{chave:n.key,valor:v||"â¦"})}):null]})}function eM(e){let{tipo:t,valor:n,texto:s,onChange:o}
1=e,{t:a}=(0,p.$G)();return"booleano"===t?(0,r.jsxs)(J.Ph,{value:!0===n?"sim":!1===n?"nao":void 0,onValueChange:e=>o({value:"sim"===e}),children:[(0,r.jsx)(J.i4,{className:"flex-1",children:(0,r.jsx)(J.ki,{})}),(0,r.jsxs)(J.Bw,{children:[(0,r.jsx)(J.Ql,{value:"sim",children:a("journeysAcao.atributo.sim")}),(0,r.jsx)(J.Ql,{value:"nao",children:a("journeysAcao.atributo.nao")})]})]}):"numero"===t?(0,r.jsx)(d.I,{className:"flex-1",type:"number",value:s,onChange:e=>o({value:eP(e.target.value)})}):(0,r.jsx)(d.I,{className:"flex-1",value:s,onChange:e=>o({value:e.target.value})})}let eG="lead.";function eR(e,t,n){return n.map(n=>{let[r,s,o]=n;return{caminho:e+r,grupo:t,exemplo:s,...o?{destaque:!0}:{}}})}let eO=[...eR("lead.","lead",[["first_name","Maria",!0],["last_name","Souza",!0],["email","[email protected]",!0],["phone","+5511999990000",!0],["city","S\xe3o Paulo",!0],["region","SP"],["postal_code","01310-000"],["country","BR"],["last_city","Campinas"],["last_region","SP"],["last_postal_code","13010-000"],["last_country","BR"],["gender","f"],["birthdate","1990-04-17"],["is_identified","true"],["fbc","fb.1.1700000000.IwAR0"],["fbp","fb.1.1700000000.1234567890"]]),...eR("","jornada",[["journey_name","Boas-vindas",!0],["occurred_at","2026-08-31T14:03:00Z",!0],["event_type","journey.step"],["journey_id","3f1c9a52-0b7e-4a55-9d2a-8c1f7e4b0a11"],["step_id","9a7d2f10-44c3-4b8e-a6d1-2e5b90c3f7aa"],["lead_id","b2c6f0d4-91ae-4f3b
1-8c72-1d5e6a9f0b33"],["channel","email"],["destination_id","c8e1a7b3-5d92-4c60-9f8a-73b2e1d4c605"],["project_id","b581dba0-9001-4dd9-8e8a-761651861c65"]]),...eR("","contexto",[["journey_context.trigger.event_type","hotmart",!0],["journey_context.trigger.occurred_at","2026-08-31T13:58:12Z"],["journey_context.trigger.source","hotmart_sync"],["journey_context.entered_at","2026-08-31T13:58:12Z"],["journey_context.journey.name","Boas-vindas"]])],e$=new Map(eO.map(e=>[e.caminho,e]));function eB(e){var t,n;return null!==(n=null===(t=e$.get(e))||void 0===t?void 0:t.exemplo)&&void 0!==n?n:""}let eF=/\{([a-zA-Z0-9_.$]+)\}/g;function eH(e){let t=[];for(let n of String(null!=e?e:"").matchAll(eF))t.includes(n[1])||t.push(n[1]);return t}function eq(e,t){return String(null!=e?e:"").replace(eF,(e,n)=>{if(n.startsWith(eG)){var r;return String(null!==(r=t[n.slice(eG.length)])&&void 0!==r?r:"")}return eB(n)})}let eK=["lead.","journey_context.trigger.attrs.","journey_context.trigger.hotmart.","journey_context.trigger.data.","journey_context.observed."],eV=/(e_?mail|phone|cellphone|mobile|whatsapp|telefone|(^|_)cpf($|_)|cnpj|document|passport|address|street|zipcode|zip_code|postal|endereco|(buyer|customer|user|participant|holder|payer|subscriber|first|last|full|display)_names?)/i;function eW(e){return eV.test(String(null!=e?e:""))}let eQ=["journey_context.trigger.","journey_context.observed."],eU=eO.filter(e=>"lead"===e.grupo).map(e=>e.caminho.slice(eG.length));function eJ(){let e={};for(let t of eO)"lead"===t.grupo&&(e[t.caminho.slice(eG.length)]=t.exemplo);return e}let eX=new Set(["city","region","postal_code","country"]);function eY(e){if(null==e)return"";if("string"==typeof e){let t=e.trim();return(t.length>=2&&t.startsWith('"')&&t.endsWith('"')?t.slice(1,-1):t).trim()}return"number"==typeof e||"boolean"==typeof e?String(e):""}function e0(e,t,n){var r;let s=(null!=e?e:[]).filter(e=>!1!==e.is_current&&!e.valid_to),o=null!==(r=s.find(e=>e.identity_id===t))&&void 0!==r?r:s[0];return o?eY(n(o)):""}function e1(e){var t,n,r;let s=String(null!==(t=null==e?void 0:e.display_name)&&void 0!==t?t:"").trim();return s?s:e0(null==e?void 0:e.emails,null!==(n=null==e?void 0:e.primary_email_id)&&void 0!==n?n:null,e=>e.email)||String(null!==(r=null==e?void 0:e.id)&&void 0!==r?r:"").slice(0,8)}let e5=["project_id","lead_id","event_type","journey_id","journey_name","step_id","channel","destination_id","occurred_at","lead"],e2="journey_context.";function e3(e){let t="".concat(e,"."),n=eO.filter(e=>e.caminho.startsWith(t));if(0===n.length)return null;let r={};for(let e of n){let n=e.caminho.slice(t.length);n.includes(".")||(r[n]=e.exemplo)}return Object.keys(r).length>0?r:null}function e4(e){let{passo:t,definicao:n,journeyId:s,journeyName:o,leadId:a,bloco:i}=e,{t:l}=(0,p.$G)(),d=(0,C.useMemo)(()=>(function(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.journeyId||eB("journey_id"),s={journey_id:r,step_id:t.id,channel:t.channel,destination_id:t.destination_id||eB("destination_id"),lead:n.bloco&&Object.keys(n.bloco).length>0?n.bloco:eJ(),...n.leadId?{lead_id:n.leadId}:{},...n.journeyName?{journey_name:n.journeyName}:{}},o={};for(let e of e5)o[e]=e in s?s[e]:eB(e);let a=function(e,t){let n=(0,Z.pY)(e);if(0===n.length)return null;let r={},s=e3("".concat(e2,"trigger"));for(let e of n){var o;let n;let a=e.slice(e2.length),i=a.split(".");n="trigger"===a?null!=s?s:{}:"observed"===i[0]?null!=s?s:{}:"journey.id"===a?t:null!==(o=e3(e))&&void 0!==o?o:eB(e),function(e,t,n){let r=e;for(let e=0;e<t.length-1;e++){let n=t[e];("object"!=typeof r[n]||null===r[n])&&(r[n]={}),r=r[n]}r[t[t.length-1]]=n}(r,i,n)}return"observed"in r||(r.observed={}),r}(e,r);a&&(o.journey_context=a);let i=t.content;return i&&"object"==typeof i&&Object.keys(i).length>0&&(o.content=i),o})(n,t,{journeyId:s,journeyName:o,leadId:a,bloco:i}),[n,t,s,o,a,i]);return(0,r.jsxs)("section",{className:"space-y-1.5",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-foreground",children:l("journeysAcao.webhook.titulo")}),(0,r.jsx)("pre",{className:"max-h-72 overflow-auto rounded-md border bg-muted/30 p-3 text-[11px] leading-relaxed text-foreground",children:JSON.stringify(d,null,2)}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:l("journeysAcao.webhook.nota")})]})}let e6=[{id:"",valor:""}];function e7(e){if(!e||"object"!=typeof e||Array.isArray(e))return e6;let t=Object.entries(e).map(e=>{let[t,n]=e;return{id:t,valor:null==n?"":String(n)}});return t.length>0?t:e6}function e8(e){let t={};for(let n of e){let e=n.id.trim();e&&(t[e]=n.valor.trim())}return t}let e9={disponivel:!1,motivo:null,fields:[],lists:[]},te=e=>(null==e?"":String(e)).trim();function tt(e,t){if(!Array.isArray(e))return[];let n=[];for(let r of e){if(!r||"object"!=typeof r)continue;let e=t(r);e&&n.push(e)}return n}function tn(e){return e.label===e.id?e.id:"".concat(e.label," \xb7 ").concat(e.id)}async function tr(e,t){try{var n;let r=await fetch("/api/projects/".concat(encodeURIComponent(e),"/actions/destinations/").concat(encodeURIComponent(t),"/ac-catalog"),{cache:"no-store"});if(!r.ok)return e9;let s=await r.json();return!(n=null==s?void 0:s.data)||"object"!=typeof n||Array.isArray(n)?e9:!0!==n.disponivel?{...e9,motivo:te(n.motivo)||null}:{disponivel:!0,motivo:null,fields:tt(n.fields,e=>{let t=te(e.id);return t?{id:t,label:te(e.label)||t,type:te(e.type)}:null}),lists:tt(n.lists,e=>{let t=te(e.id);return t?{id:t,name:te(e.name)||t}:null})}}catch(e){return e9}}
1let ts={tagsAplicar:"ac_tags",tagsRemover:"ac_tags_remove",listasEntrar:"ac_lists",listasSair:"ac_lists_remove",campos:"ac_fields"};function to(e){let t=Array.isArray(e)?e:"string"==typeof e?e.split(","):[],n=[],r=new Set;for(let e of t){if(null==e||"object"==typeof e)continue;let t=String(e).trim();!t||r.has(t)||(r.add(t),n.push(t))}return n}function ta(e,t){let n=t.trim();return!n||e.includes(n)?e:[...e,n]}function ti(e,t){return e.filter(e=>e!==t)}let tl=(e,t)=>to(null==e?void 0:e[t]);function td(e){let t=new Set(tl(e,ts.tagsAplicar)),n=new Set(tl(e,ts.listasEntrar));return{tags:tl(e,ts.tagsRemover).filter(e=>t.has(e)),listas:tl(e,ts.listasSair).filter(e=>n.has(e))}}function tu(e){let t=null==e?void 0:e[ts.campos];return{tagsAplicar:tl(e,ts.tagsAplicar).length,tagsRemover:tl(e,ts.tagsRemover).length,listasEntrar:tl(e,ts.listasEntrar).length,listasSair:tl(e,ts.listasSair).length,campos:t&&"object"==typeof t&&!Array.isArray(t)?Object.keys(t).length:0}}function tc(e){let t=tu(e);return t.tagsAplicar+t.tagsRemover+t.listasEntrar+t.listasSair+t.campos===0}function tm(e,t){var n;let r=(0,v.a)({queryKey:["journeys","ac-catalog",e,t],queryFn:()=>tr(e,t),enabled:!!e&&!!t,staleTime:6e4});return{catalogo:null!==(n=r.data)&&void 0!==n?n:e9,carregando:r.isLoading&&!!t}}function tx(e){let{passo:t,onChange:n,projectId:s}=e,{t:o}=(0,p.$G)(),{catalogo:a,carregando:i}=tm(null!=s?s:"",t.destination_id||""),l=t.content,d=(e,r)=>n({content:{...t.content,[e]:r}}),u=td(l),c=tu(l);return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:o("journeys.crmContent.hint")}),tc(l)&&(0,r.jsx)("p",{className:"rounded-md border border-dashed px-2 py-1.5 text-[11px] text-muted-foreground",children:o("journeys.crmContent.onlyContact")}),(0,r.jsxs)(tp,{titulo:o("journeys.crmContent.tagsSection"),children:[(0,r.jsx)(tj,{rotulo:o("journeys.crmContent.tagsApplyLabel"),ajuda:o("journeys.crmContent.tagsApplyHint"),itens:to(null==l?void 0:l[ts.tagsAplicar]),conflitos:u.tags,onChange:e=>d(ts.tagsAplicar,e)}),(0,r.jsx)(tj,{rotulo:o("journeys.crmContent.tagsRemoveLabel"),ajuda:o("journeys.crmContent.tagsRemoveHint"),itens:to(null==l?void 0:l[ts.tagsRemover]),conflitos:u.tags,destrutivo:!0,onChange:e=>d(ts.tagsRemover,e)}),u.tags.length>0&&(0,r.jsx)(th,{texto:o("journeys.crmContent.conflictTags"),valores:u.tags})]}),(0,r.jsxs)(tp,{titulo:o("journeys.crmContent.listsSection"),children:[(0,r.jsx)(tv,{rotulo:o("journeys.crmContent.listsJoinLabel"),ajuda:o("journeys.crmContent.listsJoinHint"),chave:ts.listasEntrar,escolhidas:to(null==l?void 0:l[ts.listasEntrar]),conflitos:u.listas,catalogo:a,gravarLista:d}),(0,r.jsx)(tv,{rotulo:o("journeys.crmContent.listsLeaveLabel"),ajuda:o("journeys.crmContent.listsLeaveHint"),chave:ts.listasSair,escolhidas:to(null==l?void 0:l[ts.listasSair]),conflitos:u.listas,catalogo:a,gravarLista:d,destrutivo:!0}),u.listas.length>0&&(0,r.jsx)(th,{texto:o("journeys.crmContent.conflictLists"),valores:u.listas})]}),(0,r.jsx)(tp,{titulo:o("journeys.crmContent.fieldsLabel"),contagem:c.campos,children:(0,r.jsx)(tg,{passo:t,onChange:n,catalogo:a,carregando:i})})]})}function tp(e){let{titulo:t,contagem:n,children:s}=e;return(0,r.jsxs)("div",{className:"space-y-2 rounded-md border p-2.5",children:[(0,r.jsxs)("p",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:[t,n?(0,r.jsxs)("span",{className:"ml-1 font-normal normal-case",children:["(",n,")"]}):null]}),s]})}function th(e){let{texto:t,valores:n}=e;return(0,r.jsxs)("p",{className:"rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-[11px] text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300",children:[t," ",(0,r.jsx)("span",{className:"font-mono",children:n.join(", ")})]})}function tj(e){let{rotulo:t,ajuda:n,itens:s,onChange:o,destrutivo:a,conflitos:i}=e,{t:c}=(0,p.$G)(),[m,x]=(0,C.useState)(""),h=()=>{let e=ta(s,m);e!==s&&o(e),x("")};return(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:(0,F.cn)("text-xs",a&&"text-amber-700 dark:text-amber-400"),children:t}),s.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:s.map(e=>(0,r.jsxs)("span",{className:(0,F.cn)("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-[11px]",a?"border-amber-300 bg-amber-50 text-amber-900 dark:border-amber-800 dark:bg-amber-950 dar
1k:text-amber-200":"bg-muted",i.includes(e)&&"ring-1 ring-amber-500"),children:[(0,r.jsx)("span",{className:"truncate",children:e}),(0,r.jsx)("button",{type:"button","aria-label":c("journeys.crmContent.tagRemoveChip"),title:c("journeys.crmContent.tagRemoveChip"),onClick:()=>o(ti(s,e)),className:"shrink-0 opacity-60 transition-opacity hover:opacity-100",children:(0,r.jsx)(y.Z,{className:"h-3 w-3"})})]},e))}),(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,r.jsx)(d.I,{className:"h-8 flex-1",placeholder:c("journeys.crmContent.tagAddPlaceholder"),value:m,onChange:e=>x(e.target.value),onKeyDown:e=>{"Enter"===e.key&&(e.preventDefault(),h())},onBlur:h}),(0,r.jsx)(l.z,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 shrink-0 p-0","aria-label":c("journeys.crmContent.tagAdd"),title:c("journeys.crmContent.tagAdd"),onClick:h,children:(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})})]}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n})]})}function tv(e){let{rotulo:t,ajuda:n,chave:s,escolhidas:o,catalogo:a,gravarLista:i,destrutivo:l,conflitos:c}=e,{t:m}=(0,p.$G)();if(!a.disponivel)return(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:(0,F.cn)("text-xs",l&&"text-amber-700 dark:text-amber-400"),children:t}),(0,r.jsx)(d.I,{className:"h-8",placeholder:m("journeys.crmContent.listIdsPlaceholder"),value:o.join(", "),onChange:e=>i(s,to(e.target.value))}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n})]});let x=function(e,t){let n=new Set(e.map(e=>e.id)),r=[],s=new Set;for(let e of t){let t=e.trim();!t||n.has(t)||s.has(t)||(s.add(t),r.push({id:t,name:t,desconhecido:!0}))}return r.length?[...r,...e]:e}(a.lists,o);return(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:(0,F.cn)("text-xs",l&&"text-amber-700 dark:text-amber-400"),children:t}),(0,r.jsxs)("div",{className:"max-h-40 space-y-1 overflow-y-auto rounded-md border p-1.5",children:[0===x.length&&(0,r.jsx)("p",{className:"px-1 py-0.5 text-[11px] text-muted-foreground",children:"â"}),x.map(e=>{let t=o.includes(e.id);return(0,r.jsxs)("button",{type:"button",onClick:()=>{var t;return i(s,(t=e.id,o.includes(t)?ti(o,t):ta(o,t)))},className:(0,F.cn)("flex w-full items-center gap-2 rounded px-1.5 py-1 text-left text-xs transition-colors",t?l?"bg-amber-50 text-amber-900 dark:bg-amber-950 dark:text-amber-200":"bg-accent text-foreground":"hover:bg-muted",t&&c.includes(e.id)&&"ring-1 ring-amber-500"),children:[(0,r.jsx)("span",{className:(0,F.cn)("h-3 w-3 shrink-0 rounded-sm border",t&&(l?"border-amber-500 bg-amber-500":"border-primary bg-primary"))}),(0,r.jsx)("span",{className:"truncate",children:e.name}),(0,r.jsx)("span",{className:"ml-auto shrink-0 font-mono text-[10px] text-muted-foreground",children:e.id}),e.desconhecido&&(0,r.jsx)("span",{className:"shrink-0 text-[10px] text-amber-600",children:m("journeys.crmContent.fieldUnknown")})]},e.id)})]}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n})]})}function tg(e){var t;let{passo:n,onChange:s,catalogo:o,carregando:a}=e,{t:i}=(0,p.$G)(),u=null===(t=n.content)||void 0===t?void 0:t[ts.campos],[c,m]=(0,C.useState)(()=>e7(u)),x=function(e,t){let n=e7(t),r=e8(n);return!function(e,t){let n=Object.keys(e);return n.length===Object.keys(t).length&&n.every(n=>Object.prototype.hasOwnProperty.call(t,n)&&e[n]===t[n])}(e8(e),r)?n:e}(c,u);x!==c&&m(x);let h=e=>{m(e),s({content:{...n.content,[ts.campos]:e8(e)}})},j=(e,t)=>h(x.map((n,r)=>r===e?{...n,...t}:n)),v=o.disponivel?"journeys.crmContent.catalogState":a?"journeys.crmContent.catalogLoading":"journeys.crmContent.catalogUnavailable",g=x.some(e=>e.id.trim()&&!e.valor.trim());return(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:i(v)}),!o.disponivel&&!a&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:i("journeys.crmContent.fieldsHint")}),(0,r.jsx)("div",{className:"space-y-1.5",children:x.map((e,t)=>(0,r.jsxs)("div",{className:"flex items-center gap-1.5",children:[o.disponivel?(0,r.jsxs)(J.Ph,{value:e.id||void 0,onValueChange:e=>j(t,{id:e}),children:[(0,r.jsx)(J.i4,{className:"w-44",children:(0,r.jsx)(J.ki,{placeholder:i("journeys.crmContent.fieldIdPlaceholder")})}),(0,r.jsx)(J.Bw,{children:(function(e,t){let n=t.trim();return!n||e.some(e=>e.id===n)?e:[{id:n,label:n,type:"",desconhecido:!0},...e]})(o.fields,e.id).map(e=>(0,r.jsx)(J.Ql,{value:e.id,children:e.desconhecido?"".concat(e.id," (").concat(i("journeys.crmContent.fieldUnknown"),")"):tn(e)},e.id))})]}):(0,r.jsx)(d.I,{className:"w-24 font-mono",placeholder:i("journeys.crmContent.fieldIdPlaceholder"),value:e.id,onChange:e=>j(t,{id:e.target.value})}),(0,r.jsx)(d.I,{className:"flex-1",placeholder:i("journeys.crmContent.fieldValuePlaceholder"),value:e.valor,onChange:e=>j(t,{valor:e.target.value})}),(0,r.jsx)(l.z,{type:"button",variant:"ghost",size:"sm",className:"h-8 w-8 shrink-0 p-0",title:i("journeys.crmContent.fieldRemove"),"aria-label":i("journeys.crmContent.fieldRemove"),onClick:()=>
1h(x.filter((e,n)=>n!==t)),children:(0,r.jsx)(y.Z,{className:"h-3.5 w-3.5"})})]},t))}),g&&(0,r.jsx)("p",{className:"text-[11px] text-amber-700 dark:text-amber-400",children:i("journeys.crmContent.fieldEmptyClears")}),(0,r.jsxs)(l.z,{type:"button",variant:"ghost",size:"sm",className:"h-7 px-2 text-xs",onClick:()=>h([...x,{id:"",valor:""}]),children:[(0,r.jsx)(b.Z,{className:"mr-1 h-3.5 w-3.5"})," ",i("journeys.crmContent.fieldAdd")]})]})}var tf=n(12581),tb=n(20265),ty=n(15051),tN=n(84502),tk=n(58857),tw=n(87769),t_=n(42208),tC=n(19542);let tA=[".html",".htm"];function tS(e){return new TextEncoder().encode(e).length}function tI(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pt-BR",n=e=>new Intl.NumberFormat(t,{maximumFractionDigits:1}).format(e);if(e<1024)return"".concat(n(e)," B");let r=e/1024;return r<1024?"".concat(n(r)," KB"):"".concat(n(r/1024)," MB")}function tz(e){let{tom:t,children:n}=e,s="atencao"===t?G.Z:ea.Z;return(0,r.jsxs)("p",{className:(0,F.cn)("flex items-start gap-1.5 rounded-md border p-2 text-[11px]","atencao"===t?"border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300":"border-border bg-muted/40 text-muted-foreground"),children:[(0,r.jsx)(s,{className:"mt-px h-3 w-3 shrink-0"}),(0,r.jsx)("span",{className:"min-w-0",children:n})]})}function tE(e){let{corpoAtual:t,onHtml:n}=e,{t:s}=(0,p.$G)(),o=(0,p.bU)(),[a,i]=(0,C.useState)(null),l=t.trim().length>0;return(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsx)(u._,{className:"text-xs",children:s("journeysAcao.email.abaArquivo")}),(0,r.jsx)(d.I,{type:"file",accept:".html,.htm",onChange:e=>{var t;let r=null===(t=e.target.files)||void 0===t?void 0:t[0];if(e.target.value="",!r)return;let s=function(e,t){let n=e.toLowerCase();return tA.some(e=>n.endsWith(e))?t>1048576?"journeysAcao.email.arquivoGrande":null:"journeysAcao.email.arquivoRecusado"}(r.name,r.size);if(i(s),s)return;let o=new FileReader;o.onload=()=>{var e;return n(String(null!==(e=o.result)&&void 0!==e?e:""),r.name)},o.onerror=()=>i("journeysAcao.email.arquivoFalhou"),o.readAsText(r)},className:"h-auto py-1.5"}),l?(0,r.jsx)(tz,{tom:"nota",children:s("journeysAcao.email.arquivoAjuda")}):(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:s("journeysAcao.email.arquivoAjuda")}),a&&(0,r.jsx)(tz,{tom:"atencao",children:s(a,{max:tI(1048576,o)})})]})}let tT={texto:"journeys.msgContent.modeTexto",html:"journeys.msgContent.modeHtml",template_id:"journeys.msgContent.modeTemplateId"},tL="arquivo",tP={html:"journeysAcao.email.abaHtml",[tL]:"journeysAcao.email.abaArquivo",template_id:"journeysAcao.email.abaModelo",texto:"journeysAcao.email.abaTexto"},tZ=Object.keys(tP),tD={texto:"journeys.msgContent.trackingTexto",html:"journeys.msgContent.trackingHtml",template_id:"journeys.msgContent.trackingTemplateId"},tM={lead:"journeys.msgContent.varsGroupLead",jornada:"journeys.msgContent.varsGroupJornada",contexto:"journeys.msgContent.varsGroupContexto"},tG=["lead","jornada","contexto"];function tR(e){let{tom:t,children:n}=e,s="atencao"===t?G.Z:ea.Z;return(0,r.jsxs)("p",{className:(0,F.cn)("flex items-start gap-1.5 rounded-md border p-2 text-[11px]","atencao"===t?"border-amber-200 bg-amber-50 text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300":"border-border bg-muted/40 text-muted-foreground"),children:[(0,r.jsx)(s,{className:"mt-px h-3 w-3 shrink-0"}),(0,r.jsx)("span",{className:"min-w-0",children:n})]})}function tO(e){let{textos:t}=e,{t:n}=(0,p.$G)(),s=t.join("\n"),o=eH(s).filter(e=>!e$.has(e)&&!eK.some(t=>e.startsWith(t))),a=eH(s).filter(e=>{let t=eQ.find(t=>e.startsWith(t));return!!t&&e.slice(t.length).split(".").some(eW)});return 0===o.length&&0===a.length?null:(0,r.jsxs)("div",{className:"space-y-1.5",children:[a.length>0&&(0,r.jsx)(tR,{tom:"atencao",children:n("journeys.msgContent.warnPii",{caminhos:a.join(", ")})}),o.length>0&&(0,r.jsx)(tR,{tom:"atencao",children:n("journeys.msgContent.warnUnknown",{caminhos:o.join(", ")})})]})}function t$(e){let{corpo:t,comoHtml:n}=e,{t:s}=(0,p.$G)(),[o,a]=(0,C.useState)(()=>t.trim().length>0),i=(0,C.useMemo)(()=>String(null!=t?t:"").replace(eF,(e,t)=>eB(t)),[t]);return(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsxs)("button",{type:"button",onClick:()=>a(e=>!e),className:"flex items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground",children:[o?(0,r.jsx)(tw.Z,{className:"h-3 w-3"}):(0,r.jsx)(t_.Z,{className:"h-3 w-3"}),s("journeys.msgContent.previewTitle")]}),o&&(0,r.jsxs)("div",{className:"space-y-1",children:[0===t.trim().length?(0,r.jsx)("p",{className:"rounded-md border border-dashed p-3 text-xs text-muted-foreground",children:s("journeys.msgContent.previewEmpty")}):n?(0,r.jsx)("iframe",{sandbox:"",srcDoc:i,title:s("journeys.msgContent.previewTitle"),className:"h-48 w-full rounded-md border bg-white"}):(0,r.jsx)("pre",{className:"max-h-48 overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs text-foreground",children:i}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:s("journeys.msgContent.previewNote")})]})]})}function tB(e){let{aoInserir:t}=e,{t:n}=(0,p.$G)(),[s,o]=(0,C.useState)(!1);return(0,r.jsxs)("div",{className:"space-y-1.5 rounded-md border bg-muted/20 p-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:n("journeys.msgContent.varsTitle")}),(0,r.jsx)("button",{type:"button",onClick:()=>o(e=>!e),className:"text-[11px] text-muted-foreground underline-offset-2 hover:underline",children:n(s?"journeys.msgContent.varsLess":"journeys.msgContent.varsMore")})]}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("journeys.msgContent.varsHint")}),tG.map(e=>{let o=eO.filter(t=>t.grupo===e&&(s||t.destaque));return 0===o.length?null:(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("span",{className:"text-[11px] uppercase tracking-wide text-muted-foreground",children:n(tM[e])}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:o.map(e=>(0,r.jsx)("button",{type:"button",title:e.exemplo,onMouseDown:e=>e.preventDefault(),onClick:()=>t(e.caminho),className:"rounded border bg-background px-1.5 py-0.5 font-mono text-[11px] text-foreground hover:bg-accent",children:"{"+e.caminho+"}"},e.caminho))})]},e)}),s&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("journeys.msgContent.varsOpen")}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("journeys.msgContent.varsAddressNote")})]})]})}function tF(){let e=(0,C.useRef)(null),t=(0,C.useRef)({});return{campo:n=>({ref:e=>{t.current[n]=e},onFocus:t=>{var r,s;let o=t.currentTarget;e.current={nome:n,inicio:null!==(r=o.selectionStart)&&void 0!==r?r:0,fim:null!==(s=o.selectionEnd)&&void 0!==s?s:0}},onSelect:t=>{var r,s;let o=t.currentTarget;e.current={nome:n,inicio:null!==(r=o.selectionStart)&&void 0!==r?r:0,fim:null!==(s=o.selectionEnd)&&void 0!==s?s:0}}}),inserir:(n,r,s)=>{var o,a;
1let i=null!==(o=e.current)&&void 0!==o?o:{nome:s,inicio:-1,fim:-1},l=t.current[i.nome],d=null!==(a=null==l?void 0:l.value)&&void 0!==a?a:"",u=i.inicio>=0?i.inicio:d.length,c=i.fim>=0?i.fim:d.length,m="{"+n+"}";r(i.nome,d.slice(0,u)+m+d.slice(c));let x=u+m.length;e.current={nome:i.nome,inicio:x,fim:x},window.requestAnimationFrame(()=>{null==l||l.focus(),null==l||l.setSelectionRange(x,x)})}}}let tH="flex w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring";function tq(e){var t,n;let{passo:s,onChange:o,destinoTipo:a,modoEscolhido:i,onModoEscolhido:l}=e,{t:c}=(0,p.$G)(),m=(0,p.bU)(),{campo:x,inserir:h}=tF(),[j,v]=(0,C.useState)(null),[g,f]=(0,C.useState)(null),[b,y]=(0,C.useState)(null),[N,k]=(0,C.useState)(!1),[w,_]=(0,C.useState)(null),A=e=>{_(e),null==l||l(e)},[S,I]=(0,C.useState)(s.id);S!==s.id&&(I(s.id),_(null),v(null),f(null),y(null),k(!1));let z=null!==(t=s.content)&&void 0!==t?t:{},E=(0,tC.v9)(a),T=(0,tC.q6)(z),L=(0,tC.w$)(z,void 0!==i?i:w),P=[...new Set([...E,T,L])],Z=tZ.filter(e=>e===tL||P.includes(e)),D=String(null!==(n=z.assunto)&&void 0!==n?n:""),M=(0,tC.pl)(z,L),G=(e,t)=>o({content:{...z,[e]:t}}),R=e=>{v(null),A(e),y(null),o({content:(0,tC.qT)(z,e)})},O=e=>e===L?void 0:(0,tC.a0)(z,e)?v(e):R(e),$=(e,t)=>{f(null),v(null),A("html"),o({content:{...(0,tC.qT)(z,"html"),html:e}}),y({nome:t,tamanho:tS(e)}),k(!1)},B=(e,t)=>M.trim().length>0?f({html:e,nome:t}):$(e,t),H="template_id"===L&&(0,tC.Cj)(a,M),q=(0,tC.hW)(z,a),K=N?"html":L,V=e=>{let t=(0,tC.pl)(z,e),n="html"===e&&t.trim().length>0?function(e){let t=[];return tS(e)>102400&&t.push("journeysAcao.email.avisoTamanho"),/<a\s[^>]*href=/i.test(e)||t.push("journeysAcao.email.avisoSemAncora"),t}(t):[];return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:c("html"===e?"journeys.msgContent.bodyHtml":"journeys.msgContent.bodyTexto")}),(0,r.jsx)("textarea",{className:(0,F.cn)(tH,"html"===e?"min-h-[180px] font-mono text-xs":"min-h-[120px]"),value:t,onChange:t=>{y(null),G((0,tC.Tc)(e),t.target.value)},...x("corpo")}),"html"===e&&t.trim().length>0&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:c("journeysAcao.email.bytes",{n:tS(t).toLocaleString(m)})})]}),"html"===e&&b&&(0,r.jsx)(tR,{tom:"nota",children:c("journeysAcao.email.arquivoLido",{nome:b.nome,tamanho:tI(b.tamanho,m)})}),n.map(e=>(0,r.jsx)(tR,{tom:"atencao",children:c(e)},e)),(0,r.jsx)(tO,{textos:[D,t]}),(0,r.jsx)(tB,{aoInserir:t=>h(t,(t,n)=>G("assunto"===t?"assunto":(0,tC.Tc)(e),n),"corpo")}),(0,r.jsx)(t$,{corpo:t,comoHtml:"html"===e})]})},W=e=>e===tL?(0,r.jsx)(tE,{corpoAtual:M,onHtml:B}):"template_id"===e?(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:c("journeys.msgContent.templateId")}),(0,r.jsx)(d.I,{value:(0,tC.pl)(z,"template_id"),placeholder:c("journeys.msgContent.templateIdPlaceholder"),onChange:e=>G((0,tC.Tc)("template_id"),e.target.value)}),q?(0,r.jsx)(tR,{tom:"atencao",children:c("journeys.msgContent.modeIgnored")}):(0,r.jsx)(tR,{tom:"nota",children:c("journeys.msgContent.templateIdHint")}),H&&(0,r.jsx)(tR,{tom:"atencao",children:c("journeys.msgContent.templateIdBrevo")})]}):V(e),Q=(e,t,n)=>(0,r.jsxs)(tR,{tom:"atencao",children:[(0,r.jsx)("span",{className:"block",children:n}),(0,r.jsxs)("span",{className:"mt-1 flex gap-2",children:[(0,r.jsx)("button",{type:"button",onClick:e,className:"rounded border border-current px-1.5 py-0.5 text-[11px]",children:c("journeys.msgContent.switchConfirm")}),(0,r.jsx)("button",{type:"button",onClick:t,className:"px-1.5 py-0.5 text-[11px] underline-offset-2 hover:underline",children:c("journeys.msgContent.switchCancel")})]})]});return(0,r.jsxs)("div",{className:"space-y-3",children:["template_id"!==K&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:c("journeys.msgContent.subject")}),(0,r.jsx)(d.I,{value:D,onChange:e=>G("assunto",e.target.value),...x("assunto")})]}),(0,r.jsxs)(tk.mQ,{value:N?tL:L,onValueChange:e=>{if(e===tL){v(null),k(!0);return}k(!1),O(e)},className:"space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(tk.dr,{className:"h-auto flex-wrap justify-start",children:Z.map(e=>(0,r.jsx)(tk.SP,{value:e,className:"text-xs",children:c(tP[e])},e))}),g?Q(()=>$(g.html,g.nome),()=>f(null),(0,tC.a0)(z,"html")?c("journeys.msgContent.switchWarn",{modo:c(tT.html)}):c("journeysAcao.email.substituirCorpo")):j?Q(()=>R(j),()=>v(null),c("journeys.msgContent.switchWarn",{modo:c(tT[j])})):(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:c(tD[K])})]}),Z.map(e=>(0,r.jsx)(tk.nU,{value:e,className:"mt-0 space-y-3",children:W(e)},e))]})]})}function tK(e){var t;let{passo:n,onChange:s}=e,{t:o}=(0,p.$G)(),{campo:a,inserir:i}=tF(),l=null!==(t=n.content)&&void 0!==t?t:{},d=(0,tC.f8)(l),c=(0,tC.R5)(d),m=(e,t)=>
1s({content:(0,tC.m_)(l,t)});return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,tC.i0)(l)&&(0,r.jsx)(tR,{tom:"atencao",children:o("journeys.msgContent.smsLegacy")}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:o("journeys.msgContent.smsLabel")}),(0,r.jsx)("textarea",{className:(0,F.cn)(tH,"min-h-[80px]"),value:d,onChange:e=>m("corpo",e.target.value),...a("corpo")}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:o("journeysAcao.sms.contador",{n:c.chars,segmentos:c.segmentos})})]}),(0,r.jsx)(tO,{textos:[d]}),(0,r.jsx)(tB,{aoInserir:e=>i(e,m,"corpo")}),(0,r.jsx)(t$,{corpo:d,comoHtml:!1})]})}var tV=n(77243);function tW(e){var t,n;let{gate:s}=e,{t:o}=(0,p.$G)(),a=null!==(n=null===(t=s.rule)||void 0===t?void 0:t.conditions)&&void 0!==n?n:[];return(0,r.jsxs)("div",{className:"space-y-1 text-xs",children:[s.event_source?(0,r.jsx)(i.C,{variant:"outline",className:"font-mono text-[10px]",children:s.event_source}):null,a.map((e,t)=>{var n,s,a;return e.type?(0,r.jsx)("p",{className:"text-muted-foreground",children:o("journeys.detail.nestedConditions",{n:null!==(s=null===(n=e.conditions)||void 0===n?void 0:n.length)&&void 0!==s?s:0})},t):(0,r.jsxs)("p",{className:"text-muted-foreground",children:[(0,r.jsx)("span",{className:"font-mono",children:e.field})," ",e.operator," ",(0,r.jsx)("span",{className:"font-mono",children:Array.isArray(e.value)?e.value.join(", "):String(null!==(a=e.value)&&void 0!==a?a:"")})]},t)})]})}function tQ(e){let{passo:t,onChange:n}=e,{t:s}=(0,p.$G)();return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(u._,{className:"text-xs",children:s("journeys.builder.waitLabel")}),(0,r.jsx)(d.I,{type:"number",min:Z.eY,max:Z.hF,className:"w-28",value:t.minutes,onChange:e=>n({minutes:Number(e.target.value)})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:s("journeys.builder.waitMinutes")})]})}let tU={minutes:1,hours:60,days:1440};function tJ(e){let{passo:t,onChange:n}=e,{t:s}=(0,p.$G)(),[o,a]=(0,C.useState)(()=>{var e;return(e=t.timeout_minutes)>0&&e%1440==0?"days":e>0&&e%60==0?"hours":"minutes"}),i=Math.max(1,Math.round(t.timeout_minutes/tU[o])),l=(e,t)=>
1n({timeout_minutes:Math.min(Z.ZF,Math.max(1,e*tU[t]))});return(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(u._,{className:"text-xs",children:s("journeys.builder.holdTimeoutLabel")}),(0,r.jsx)(d.I,{type:"number",min:1,className:"w-24",value:i,onChange:e=>l(Number(e.target.value)||1,o)}),(0,r.jsxs)(J.Ph,{value:o,onValueChange:e=>{a(e),l(i,e)},children:[(0,r.jsx)(J.i4,{className:"w-28",children:(0,r.jsx)(J.ki,{})}),(0,r.jsxs)(J.Bw,{className:"z-[110]",children:[(0,r.jsx)(J.Ql,{value:"minutes",children:s("journeys.builder.waitMinutes")}),(0,r.jsx)(J.Ql,{value:"hours",children:"h"}),(0,r.jsx)(J.Ql,{value:"days",children:"d"})]})]})]})}function tX(e){let{branch:t,onChange:n,onSelecionarCase:s}=e,{t:o}=(0,p.$G)();return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:o("journeys.builder.branchHint")}),(0,r.jsx)("div",{className:"space-y-1.5",children:t.cases.map((e,a)=>(0,r.jsxs)("div",{className:"flex items-center gap-1 rounded-md border px-2 py-1.5",children:[(0,r.jsx)("button",{type:"button",className:"min-w-0 flex-1 truncate text-left text-xs font-medium text-foreground hover:underline",onClick:()=>s(e.id),children:e.label||o("journeys.canvas.caseFallback",{n:a+1})}),(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",disabled:0===a,title:o("journeys.builder.moveUp"),onClick:()=>n((0,Z.sM)(t,e.id,-1)),children:(0,r.jsx)(tb.Z,{className:"h-3 w-3"})}),(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",disabled:a===t.cases.length-1,title:o("journeys.builder.moveDown"),onClick:()=>n((0,Z.sM)(t,e.id,1)),children:(0,r.jsx)(ty.Z,{className:"h-3 w-3"})}),(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-red-600 dark:text-red-400",title:o("journeys.builder.removeCase"),onClick:()=>n((0,Z.tZ)(t,e.id)),children:(0,r.jsx)(ei.Z,{className:"h-3 w-3"})})]},e.id))}),(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5",disabled:t.cases.length>=Z.lS,onClick:()=>n((0,Z.$U)(t)),children:[(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})," ",o("journeys.builder.addCase")]}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:o("journeys.builder.elseHint")})]})}function tY(e){let{split:t,onChange:n,onSelecionarCaminho:s}=e,{t:o}=(0,p.$G)(),a=t.paths.length>=eA.dy,i=t.paths.length<=eA.O6;return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:o("journeys.split.hint")}),(0,r.jsx)("div",{className:"space-y-1.5",children:t.paths.map(e=>(0,r.jsxs)("div",{className:"flex items-center gap-2 rounded-md border px-2 py-1.5",children:[(0,r.jsx)(d.I,{type:"number",min:0,max:100,className:"h-7 w-20","aria-label":o("journeys.split.weightLabel"),value:e.weight,onChange:r=>n((0,eA.ZW)(t,e.id,Number(r.target.value)))}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"%"}),(0,r.jsx)("button",{type:"button",className:"min-w-0 flex-1 truncate text-left text-xs text-muted-foreground hover:underline",onClick:()=>s(e.id),children:(0,eA.N_)(e)?o("journeys.split.holdoutNoSteps"):o("journeys.split.pathTitle",{peso:e.weight})}),(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0 text-red-600 dark:text-red-400",disabled:i,"aria-label":o("journeys.split.removePath"),onClick:()=>n((0,eA.Oi)(t,e.id)),children:(0,r.jsx)(ei.Z,{className:"h-3 w-3"})})]},e.id))}),(0,r.jsx)(t0,{paths:t.paths}),(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5",disabled:a,onClick:()=>n((0,eA.rG)(t)),children:[(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})," ",o("journeys.split.addPath")]}),(0,r.jsxs)(l.z,{variant:"ghost",size:"sm",className:"gap-1.5",title:o("journeys.split.equalizeHint"),onClick:()=>n((0,eA.Ic)(t)),children:[(0,r.jsx)(tN.Z,{className:"h-3.5 w-3.5"})," ",o("journeys.split.equalize")]})]}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:a?o("journeys.split.addPathBlocked",{max:eA.dy}):o("journeys.split.addEvens")}),i&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:o("journeys.split.removePathBlocked",{min:eA.O6})})]})}function t0(e){let{paths:t}=e,{t:n}=(0,p.$G)(),s=(0,eA.uO)(t),o=(0,eA.tM)(t);return(0,r.jsx)("p",{className:(0,F.cn)("text-[11px]",s?"text-destructive":"text-muted-foreground"),children:s?n(s.key,s.params):n("journeys.split.sumOk",{soma:o})})}function t1(e){let{split:t,caminhoId:n,onChange:s}=e,{t:o}=(0,p.$G)(),a=t.paths.find(e=>e.id===n);return a?(0,r.jsxs)("div",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(d.I,{type:"number",min:0,max:100,className:"h-7 w-20","aria-label":o("journeys.split.weightLabel"),value:a.weight,onChange:e=>s((0,eA.ZW)(t,n,Number(e.target.value)))}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"%"})]}),(0,r.jsx)(t0,{paths:t.paths})]}):null}function t5(e){var t,n;let{branch:s,caso:o,onChangeBranch:a,audiencias:i,audienciasErro:c}=e,{t:m}=(0,p.$G)(),x=null!==(t=o.condition)&&void 0!==t?t:{},h=e=>a((0,Z.dm)(s,o.id,e));return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:m("journeys.builder.caseLabel")}),(0,r.jsx)(d.I,{value:null!==(n=o.label)&&void 0!==n?n:"",placeholder:m("journeys.builder.caseLabelPlaceholder"),onChange:e=>h({label:e.target.value})})]}),(0,r.jsxs)("div",{className:"space-y-2",children:[x.profile?(0,r.jsx)(t4,{profile:x.profile,onChange:e=>h({condition:{...x,profile:null!=e?e:void 0}}),onRemover:()=>h({condition:{observed:x.observed}})}):null,x.observed?(0,r.jsx)(t6,{observed:x.observed,onChange:e=>h({condition:{...x,observed:e}}),onRemover:()=>h({condition:{profile:x.profile}})}):null,x.audience?(0,r.jsx)(t2,{audience:x.audience,audiencias:i,audienciasErro:c,onChange:e=>h({condition:{...x,audience:e}}),onRemover:()=>h({condition:{profile:x.profile,observed:x.observed}})}
1):null,[x.profile,x.observed,x.audience].filter(Boolean).length>1?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:m("journeys.builder.bothConditionsNote")}):null,(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[!x.profile&&(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>h({condition:{...x,profile:{type:"and",conditions:[]}}}),children:[(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})," ",m("journeys.builder.addProfileCondition")]}),!x.observed&&(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>h({condition:{...x,observed:{event_source:"",rule:{type:"and",conditions:[]},operator:"gte"}}}),children:[(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})," ",m("journeys.builder.addObservedCondition")]}),!x.audience&&(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>h({condition:{...x,audience:{id:"",in:!0}}}),children:[(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})," ",m("journeys.builder.addAudienceCondition")]})]})]})]})}function t2(e){let{audience:t,audiencias:n,audienciasErro:s,onChange:o,onRemover:a}=e,{t:i}=(0,p.$G)(),d=n.some(e=>e.id===t.id);return(0,r.jsxs)("div",{className:"rounded-md border bg-muted/30 p-3",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:i("journeys.builder.audienceConditionTitle")}),(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",title:i("journeys.builder.removeCondition"),onClick:a,children:(0,r.jsx)(y.Z,{className:"h-3 w-3"})})]}),s&&0===n.length?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:i("journeys.sidebar.audienceLoadError")}):null,(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:i("pipeline.audience.originLabel")}),(0,r.jsxs)(J.Ph,{value:t.id||void 0,onValueChange:e=>o({...t,id:e}),children:[(0,r.jsx)(J.i4,{children:(0,r.jsx)(J.ki,{placeholder:i("journeys.builder.audiencePickPlaceholder")})}),(0,r.jsxs)(J.Bw,{className:"z-[110]",children:[n.map(e=>(0,r.jsx)(J.Ql,{value:e.id,children:e.name},e.id)),!d&&t.id?(0,r.jsx)(J.Ql,{value:t.id,children:(0,r.jsx)("span",{className:"font-mono text-[11px]",children:t.id})}):null]})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:i("journeys.builder.audienceConditionTitle")}),(0,r.jsxs)(J.Ph,{value:t.in?"in":"not_in",onValueChange:e=>o({...t,in:"in"===e}),children:[(0,r.jsx)(J.i4,{children:(0,r.jsx)(J.ki,{})}),(0,r.jsxs)(J.Bw,{className:"z-[110]",children:[(0,r.jsx)(J.Ql,{value:"in",children:i("journeys.builder.audienceIs")}),(0,r.jsx)(J.Ql,{value:"not_in",children:i("journeys.builder.audienceIsNot")})]})]})]})]}),(0,r.jsx)("p",{className:"mt-2 text-[11px] text-muted-foreground",children:i("journeys.sidebar.audienceClockNote")})]})}let t3=er.GG.map(e=>({label:e.label,field:e.key,data_type:"text"}));function t4(e){let{profile:t,onChange:n,onRemover:s}=e,{t:o}=(0,p.$G)(),a=(0,C.useMemo)(()=>{var e;let n=null!==(e=t.conditions)&&void 0!==e?e:[];return 0===n.length?{vazio:!0,filtro:null}:{vazio:!1,filtro:"and"===t.type?(0,tV.PT)(n):(0,tV.PT)([t])}},[]),i=!a.vazio&&null===a.filtro;return(0,r.jsxs)("div",{className:"rounded-md border bg-muted/30 p-3",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:o("journeys.builder.profileConditionTitle")}),(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",title:o("journeys.builder.removeCondition"),onClick:s,children:(0,r.jsx)(y.Z,{className:"h-3 w-3"})})]}),i?(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:o("journeys.builder.conditionPreserved")}),(0,r.jsx)(tW,{gate:{rule:t}})]}):(0,r.jsx)(ez.Z,{fields:t3,initialQuery:a.filtro,onChange:e=>{var t;return n(null!==(t=(0,tf.jD)(e))&&void 0!==t?t:{type:"and",conditions:[]})}})]})}function t6(e){var t,n,s,o;let{observed:a,onChange:i,onRemover:c}=e,{t:x}=(0,p.$G)(),h=0===(null!==(n=null===(t=a.rule)||void 0===t?void 0:t.conditions)&&void 0!==n?n:[]).length,j=(0,C.useMemo)(()=>h?null:(0,Z.uX)({event_source:a.event_source,rule:a.rule}),[a.event_source,a.rule,h]),v=!h&&null===j,[g,f]=(0,C.useState)(()=>{var e;return null!==(e=null==j?void 0:j.origem)&&void 0!==e?e:"HOTMART"}),b=null!==(s=null==j?void 0:j.eventos[0])&&void 0!==s?s:"",N=(0,er.lm)(g),k="zero"===a.operator?"nao_fez":void 0!==a.count&&a.count>1?"pelo_menos":"fez",w=(e,t)=>{var n,r;f(e);let s=t?(0,Z.aU)(e,[t],null):null;i({...a,event_source:null!==(n=null==s?void 0:s.event_source)&&void 0!==n?n:"",rule:null!==(r=null==s?void 0:s.rule)&&void 0!==r?r:{type:"and",conditions:[]}})};return(0,r.jsxs)("div",{className:"rounded-md border bg-muted/30 p-3",children:[(0,r.jsxs)("div",{className:"mb-2 flex items-center justify-between",children:[(0,r.jsx)("span",{className:"text-xs font-medium text-foreground",children:x("journeys.builder.observedConditionTitle")}),(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-6 w-6 p-0",title:x("journeys.builder.removeCondition"),onClick:c,children:(0,r.jsx)(y.Z,{className:"h-3 w-3"})})]}),v?(0,r.jsxs)("div",{className:"space-y-1",children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:x("journeys.builder.conditionPreserved")}),(0,r.jsx)(tW,{gate:{event_source:a.event_source,rule:a.rule}}
1)]}):(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:x("journeys.builder.originLabel")}),(0,r.jsxs)(J.Ph,{value:g,onValueChange:e=>w(e,""),children:[(0,r.jsx)(J.i4,{children:(0,r.jsx)(J.ki,{})}),(0,r.jsxs)(J.Bw,{children:[(0,r.jsx)(J.Ql,{value:"HOTMART",children:"Hotmart"}),(0,r.jsx)(J.Ql,{value:"PIXEL",children:"Pixel"})]})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:x("journeys.builder.eventLabel")}),(0,r.jsxs)(J.Ph,{value:b||void 0,onValueChange:e=>w(g,e),children:[(0,r.jsx)(J.i4,{children:(0,r.jsx)(J.ki,{})}),(0,r.jsx)(J.Bw,{children:N.map(e=>(0,r.jsx)(J.Ql,{value:e.value,children:e.labelKey?x(e.labelKey):e.label},e.value))})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:x("journeys.builder.observedConditionTitle")}),(0,r.jsxs)(J.Ph,{value:k,onValueChange:e=>{var t;"nao_fez"===e?i({...a,operator:"zero",count:void 0}):"fez"===e?i({...a,operator:"gte",count:void 0}):i({...a,operator:"gte",count:Math.max(2,null!==(t=a.count)&&void 0!==t?t:2)})},children:[(0,r.jsx)(J.i4,{children:(0,r.jsx)(J.ki,{})}),(0,r.jsxs)(J.Bw,{children:[(0,r.jsx)(J.Ql,{value:"fez",children:x("journeys.builder.observedOperatorDid")}),(0,r.jsx)(J.Ql,{value:"nao_fez",children:x("journeys.builder.observedOperatorDidNot")}),(0,r.jsx)(J.Ql,{value:"pelo_menos",children:x("journeys.builder.observedOperatorAtLeast")})]})]})]}),"pelo_menos"===k&&(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{className:"text-xs",children:x("journeys.builder.observedOperatorAtLeast")}),(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(d.I,{type:"number",min:2,max:Z.E_,className:"w-24",value:null!==(o=a.count)&&void 0!==o?o:2,onChange:e=>i({...a,count:Math.min(Z.E_,Math.max(2,Number(e.target.value)||2))})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:x("journeys.builder.observedCountSuffix")})]})]})]}),(0,r.jsx)("p",{className:"mt-2 text-[11px] text-muted-foreground",children:x("journeys.builder.observedResetNote")}),(0,r.jsxs)("label",{className:"mt-2 flex items-start gap-2",children:[(0,r.jsx)(m.r,{checked:!0===a.captura,onCheckedChange:e=>i(e?{...a,captura:!0}:(e=>{let{captura:t,...n}=e;return n})(a)),"aria-label":x("journeys.builder.capturaLabel")}),(0,r.jsxs)("span",{className:"min-w-0",children:[(0,r.jsx)("span",{className:"block text-xs text-foreground",children:x("journeys.builder.capturaLabel")}),(0,r.jsx)("span",{className:"block text-[11px] text-muted-foreground",children:x("journeys.builder.capturaNote")})]})]})]})}function t7(e){let{passo:t,onChange:n,projectId:s,destinoTipo:o,definicao:a,journeyName:i,modoDoEmail:l,onModoDoEmail:d}=e,{t:u}=(0,p.$G)();return"set_attribute"===t.kind?(0,r.jsx)(eD,{passo:t,onChange:n,projectId:s}):"email"===t.channel?(0,r.jsx)(tq,{passo:t,onChange:n,destinoTipo:o,modoEscolhido:l,onModoEscolhido:d}):"sms"===t.channel?(0,r.jsx)(tK,{passo:t,onChange:n}):"crm"===t.channel?(0,r.jsx)(tx,{passo:t,onChange:n,projectId:s}):(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:u("journeys.builder.webhookContentHint")}),a?(0,r.jsx)(e4,{passo:t,definicao:a,journeyName:i}):null]})}var t8=n(68307);function t9(e){let{k:t,v:n,mono:s=!0}=e;return(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3 text-xs",children:[(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:t}),(0,r.jsx)("span",{className:s?"min-w-0 break-all text-right font-mono text-[11px] text-foreground":"min-w-0 text-right text-foreground",children:n})]})}function ne(e){let{titulo:t,children:n}=e;return(0,r.jsxs)("details",{className:"mt-2 rounded-md border border-border",children:[(0,r.jsx)("summary",{className:"cursor-pointer px-2.5 py-1.5 text-[11px] text-muted-foreground",children:t}),(0,r.jsx)("div",{className:"space-y-1 px-2.5 pb-2.5",children:n})]})}var nt=n(93554);let nn=["acao","conteudo","revisao"];function nr(e){return nn.indexOf(e)}function ns(e,t){if("action"!==e.kind)return!0;
1if(!e.destination_id)return!1;let n=t.find(t=>t.id===e.destination_id);return!!n&&!n.quebrado&&(0,Z.a2)(e.channel).includes(n.type)}function no(e,t,n){return"acao"===e?ns(t,n.destinos):"conteudo"!==e||!n.incompleto(t)}function na(e){let t=e=>null!=e&&("string"==typeof e?e.trim().length>0:Array.isArray(e)?e.length>0:"object"!=typeof e||Object.values(e).some(t));return"set_attribute"===e.kind?t(e.key)||t(e.value):t(e.destination_id)||t(e.content)}function ni(e,t){return no("acao",e,t)?no("conteudo",e,t)?"revisao":"conteudo":"acao"}var nl=n(89345),nd=n(11),nu=n(42979),nc=n(23628),nm=n(73247),nx=n(96362),np=n(82431),nh=n(19700);function nj(e,t){return{id:e,grupo:t,channel:e,tiposDeDestino:(0,Z.a2)(e),nomeKey:"journeysAcao.acao.".concat(e),descKey:"journeysAcao.acao.".concat(e,"Desc")}}let nv=[nj("email","mensagem"),nj("sms","mensagem"),{id:"atributo",grupo:"dados",channel:null,tiposDeDestino:[],nomeKey:"journeysAcao.acao.atributo",descKey:"journeysAcao.acao.atributoDesc"},nj("crm","dados"),nj("webhook","integracao")];function ng(e,t){return t.filter(t=>e.tiposDeDestino.includes(t.type))}function nf(e){return e.normalize("NFD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/[^a-z0-9]/g,"")}let nb={email:nl.Z,sms:nd.Z,atributo:$.Z,crm:nu.Z,webhook:nc.Z},ny=[...new Set(nv.map(e=>e.grupo))];function nN(e){var t,n;let{passo:s,passos:o,destinos:a,projectSlug:i,onEscolher:l,invalidarDestinos:u}=e,{t:c}=(0,p.$G)(),[m,x]=(0,C.useState)(""),h=function(e,t,n){let r=nf(e);return r?nv.filter(e=>[t(e.nomeKey),t(e.descKey),...e.tiposDeDestino.map(e=>{var t,n;return null!==(n=null===(t=(0,nh.WV)(e))||void 0===t?void 0:t.label)&&void 0!==n?n:""}),...ng(e,n).map(e=>e.name)].some(e=>nf(e).includes(r))):[...nv]}(m,c,a),j=(t=s,n=a,"set_attribute"===t.kind?"atributo":ns(t,n)?"set_attribute"===t.kind?"atributo":t.channel:null),v="action"===s.kind?s.destination_id:"",g=e=>{if(!e.channel){l({kind:"set_attribute"});return}l({channel:e.channel,destination_id:function(e,t,n,r){let s=ng(e,t).filter(e=>!e.quebrado);if(0===s.length)return null;let o=e=>e&&s.some(t=>t.id===e)?e:null;if("action"===n.kind){let e=o(n.destination_id);if(e)return e}if(e.channel){let t=(0,Z.wv)(r).filter(t=>"action"===t.kind&&t.channel===e.channel);for(let e=t.length-1;e>=0;e-=1){let n=o(t[e].destination_id);if(n)return n}}return s[0].id}(e,a,s,o)})};return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("div",{className:"relative",children:[(0,r.jsx)(nm.Z,{className:"pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground"}),(0,r.jsx)(d.I,{value:m,onChange:e=>x(e.target.value),placeholder:c("journeysAcao.busca.placeholder"),className:"h-8 pl-8 text-xs"})]}),0===h.length?(0,r.jsx)("p",{className:"rounded-md border border-dashed p-4 text-center text-xs text-muted-foreground",children:c("journeysAcao.busca.vazio",{q:m})}):ny.map(e=>{let t=h.filter(t=>t.grupo===e);return 0===t.length?null:(0,r.jsxs)("section",{className:"space-y-1.5",children:[(0,r.jsx)("h4",{className:"text-[11px] font-medium uppercase tracking-wide text-muted-foreground/70",children:c("journeysAcao.grupo.".concat(e))}),t.map(e=>(0,r.jsx)(nk,{linha:e,destinos:a,marcada:j===e.id,destinoDoPasso:v,projectSlug:i,onEscolherLinha:()=>g(e),onEscolher:l,invalidarDestinos:u},e.id))]},e)})]})}function nk(e){let{linha:t,destinos:n,marcada:s,destinoDoPasso:o,projectSlug:a,onEscolherLinha:i,onEscolher:l,invalidarDestinos:d}=e,{t:u}=(0,p.$G)(),c=nb[t.id],m=t.channel,x=ng(t,n),h=x.filter(e=>!e.quebrado),j=null!==m&&0===h.length;return(0,r.jsxs)("div",{className:(0,F.cn)("rounded-md border transition-colors",s?"border-primary bg-primary/5":"border-border"),children:[(0,r.jsxs)("button",{type:"button",disabled:j,"aria-pressed":s,onClick:i,className:(0,F.cn)("flex w-full items-center gap-2.5 p-2.5 text-left transition-colors",j?"cursor-not-allowed opacity-60":"hover:bg-muted/50"),children:[(0,r.jsx)("span",{className:"flex h-8 w-8 shrink-0 items-center justify-center rounded-md bg-muted",children:(0,r.jsx)(c,{className:"h-4 w-4 text-muted-foreground"})}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block truncate text-xs font-medium text-foreground",children:u(t.nomeKey)}),(0,r.jsx)("span",{className:"block text-[11px] leading-snug text-muted-foreground",children:u(t.descKey)})]}),s&&(0,r.jsx)(el.Z,{className:"h-4 w-4 shrink-0 text-primary"})]}),null!==m&&(0,r.jsx)("div",{className:"space-y-1.5 border-t border-border/60 px-2.5 py-2",children:j?(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,r.jsx)("span",{className:"text-[11px] text-muted-foreground",children:u("journeysAcao.destino.semDestino",{canal:u(t.nomeKey)})}),(0,r.jsxs)(w.default,{href:"/projects/".concat(a,"/destinations/new"),target:"_blank",className:"inline-flex items-center gap-1 rounded-md border border-dashed px-1.5 py-0.5 text-[11px] text-muted-foreground transition-colors hover:border-primary hover:text-foreground",children:[(0,r.jsx)(b.Z,{className:"h-3 w-3"}),u("journeysAcao.destino.conectar"),(0,r.jsx)(nx.Z,{className:"h-2.5 w-2.5"})]}),(0,r.jsx)(nw,{invalidarDestinos:d})]}):(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[x.map(e=>(0,r.jsx)(n_,{destino:e,marcado:o===e.id,onEscolher:()=>l({channel:m,destination_id:e.id})},e.id)),(0,r.jsx)(nw,{invalidarDestinos:d})]})})]})}function nw(e){let{invalidarDestinos:t}=e,{t:n}=(0,p.$G)();return(0,r.jsx)("button",{type:"button",onClick:()=>t(),title:n("journeysAcao.destino.recarregar"),"aria-label":n("journeysAcao.destino.recarregar"),className:"inline-flex h-5 w-5 items-center justify-center rounded text-muted-foreground transition-colors hover:bg-muted hover:text-foreground",children:(0,r.jsx)(np.Z,{className:"h-3 w-3"})})}function n_(e){let{destino:t,marcado:n,onEscolher:s}=e,{t:o}=(0,p.$G)();return(0,r.jsxs)("button",{type:"button",disabled:t.quebrado,"aria-pressed":n,onClick:s,title:t.quebrado?o("journeysAcao.destino.quebrado"):t.name,className:(0,F.cn)("inline-flex max-w-full items-center gap-1.5 rounded-md border px-2 py-1 text-[11px] transition-colors",n?"border-primary bg-primary/5 text-foreground":"border-border text-muted-foreground",t.quebrado?"cursor-not-allowed opacity-60":"hover:border-primary/50 hover:text-foreground"),children:[(0,r.jsx)(H.s,{id:t.type,className:"h-3.5 w-3.5 shrink-0"}),(0,r.jsx)("span",{className:"min-w-0 truncate",children:t.name}),t.quebrado&&(0,r.jsx)(G.Z,{className:"h-3 w-3 shrink-0 text-amber-600 dar
1k:text-amber-400"}),n&&(0,r.jsx)(el.Z,{className:"h-3 w-3 shrink-0 text-primary"})]})}var nC=n(38612);function nA(e){var t,n,s,o;let{projectId:a,journeyId:i,stepId:l,scope:d}=e,{t:u}=(0,p.$G)(),m=(0,nC.Kr)(a,i,l,d);if(m.isLoading)return(0,r.jsx)(c.O,{className:"h-24 w-full"});if(m.isError)return(0,r.jsx)("p",{className:"py-3 text-xs text-muted-foreground",children:u("journeys.stepPeople.error")});let x=null!==(s=null===(t=m.data)||void 0===t?void 0:t.results)&&void 0!==s?s:[],h=null!==(o=null===(n=m.data)||void 0===n?void 0:n.count)&&void 0!==o?o:0;return 0===h?(0,r.jsx)("p",{className:"py-3 text-xs text-muted-foreground",children:u("passed"===d?"journeys.stepPeople.emptyPassed":"journeys.stepPeople.emptyHere")}):(0,r.jsxs)("div",{className:"space-y-1.5 py-2",children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:u("journeys.stepPeople.total",{total:String(h)})}),(0,r.jsx)("ul",{className:"divide-y rounded-md border",children:x.map(e=>(0,r.jsxs)("li",{className:"flex items-center justify-between gap-2 px-2.5 py-1.5",children:[(0,r.jsx)("span",{className:"truncate font-mono text-[11px] text-foreground",children:e.lead_id}),(0,r.jsx)("span",{className:"shrink-0 text-[11px] text-muted-foreground",children:e.status})]},e.id))}),x.length<h&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:u("journeys.stepPeople.more",{mostrando:String(x.length),total:String(h)})})]})}function nS(e){let{projectId:t,journeyId:n,stepId:s}=e,{t:o}=(0,p.$G)(),[a,i]=(0,C.useState)("passed");return(0,r.jsxs)("section",{className:"space-y-2",children:[(0,r.jsx)("h3",{className:"text-xs font-medium text-foreground",children:o("journeys.stepPeople.title")}),(0,r.jsxs)(tk.mQ,{value:a,onValueChange:e=>i(e),children:[(0,r.jsxs)(tk.dr,{className:"h-8",children:[(0,r.jsx)(tk.SP,{value:"passed",className:"h-6 text-[11px]",children:o("journeys.stepPeople.passed")}),(0,r.jsx)(tk.SP,{value:"here",className:"h-6 text-[11px]",children:o("journeys.stepPeople.here")})]}),(0,r.jsx)(tk.nU,{value:"passed",children:(0,r.jsx)(nA,{projectId:t,journeyId:n,stepId:s,scope:"passed"})}),(0,r.jsx)(tk.nU,{value:"here",children:(0,r.jsx)(nA,{projectId:t,journeyId:n,stepId:s,scope:"here"})})]})]})}var nI=n(14447);function nz(e){let{rotulo:t,itens:n}=e;return 0===n.length?null:(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3 py-1.5 text-xs",children:[(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:t}),(0,r.jsx)("span",{className:"flex min-w-0 flex-wrap justify-end gap-1",children:n.map(e=>(0,r.jsx)("span",{className:"max-w-full truncate rounded-md border px-1.5 py-0.5 text-[11px] text-foreground",children:e},e))})]})}function nE(e){let{chave:t,itens:n}=e,{t:s}=(0,p.$G)();return 0===n.length?null:(0,r.jsxs)("p",{className:"rounded-md border border-amber-200 bg-amber-50 p-2 text-[11px] text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300",children:[s(t)," ",n.join(", ")]})}function nT(e){let{passo:t,projectId:n}=e,{t:s}=(0,p.$G)(),{catalogo:o}=tm(n,t.destination_id),a=t.content,i=e=>{var t,n;return null!==(n=null===(t=o.lists.find(t=>String(t.id)===e))||void 0===t?void 0:t.name)&&void 0!==n?n:e},l=null==a?void 0:a[ts.campos],d=l&&"object"==typeof l&&!Array.isArray(l)?Object.entries(l):[],u=e=>{let t=o.fields.find(t=>String(t.id)===e);return t?tn(t):e};if(tc(a))return(0,r.jsx)("p",{className:"rounded-md border bg-muted/30 p-3 text-xs text-foreground",children:s("journeys.crmContent.onlyContact")});let c=td(a);return(0,r.jsxs)("section",{className:"space-y-2",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-foreground",children:s("journeysAcao.webhook.titulo")}),(0,r.jsxs)("div",{className:"divide-y rounded-md border px-3",children:[(0,r.jsx)(nz,{rotulo:"".concat(s("journeys.crmContent.tagsSection")," \xb7 ").concat(s("journeys.crmContent.tagsApplyLabel")),itens:to(null==a?void 0:a[ts.tagsAplicar])}),(0,r.jsx)(nz,{rotulo:"".concat(s("journeys.crmContent.tagsSection")," \xb7 ").concat(s("journeys.crmContent.tagsRemoveLabel")),itens:to(null==a?void 0:a[ts.tagsRemover])}),(0,r.jsx)(nz,{rotulo:"".concat(s("journeys.crmContent.listsSection")," \xb7 ").concat(s("journeys.crmContent.listsJoinLabel")),itens:to(null==a?void 0:a[ts.listasEntrar]).map(i)}),(0,r.jsx)(nz,{rotulo:"".concat(s("journeys.crmContent.listsSection")," \xb7 ").concat(s("journeys.crmContent.listsLeaveLabel")),itens:to(null==a?void 0:a[ts.listasSair]).map(i)}),(0,r.jsx)(nz,{rotulo:s("journeys.crmContent.fieldsLabel"),itens:d.map(e=>{let[t,n]=e;return"".concat(u(t)," = ").concat(String(null!=n?n:""))})})]}),(0,r.jsx)(nE,{chave:"journeys.crmContent.conflictTags",itens:c.tags}),(0,r.jsx)(nE,{chave:"journeys.crmContent.conflictLists",itens:c.listas}),d.some(e=>{let[,t]=e;return""===String(null!=t?t:"").trim()})&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:s("journeys.crmContent.fieldEmptyClears")})]})}let nL=e=>"set_attribute"===e.kind;function nP(e){let{rotulo:t,valor:n,icone:s,onEditar:o,rotuloDoBotao:a}=e;return(0,r.jsxs)("div",{className:"flex items-start justify-between gap-3 py-1.5 text-xs",children:[(0,r.jsx)("span",{className:"shrink-0 text-muted-foreground",children:t}),(0,r.jsxs)("span",{className:"flex min-w-0 items-center gap-2",children:[s,(0,r.jsx)("span",{className:"min-w-0 truncate text-right text-foreground",children:n}),o&&(0,r.jsx)(l.z,{type:"button",variant:"ghost",size:"sm",className:"h-6 shrink-0 px-1.5 text-[11px]",onClick:o,children:a})]})]})}function nZ(e){var t,n,s,o,a,i,u;let{passo:c,definicao:m,destino:x,projectId:h,journeyId:j,journeyName:v,modoEdicao:g,modoDetalhe:f,statsDoPasso:b,statsProntos:y,onIrPara:N}=e,{t:k}=(0,p.$G)(),w=function(e){var t,n;let[r,s]=(0,C.useState)(""),[o,a]=(0,C.useState)(""),[i,l]=(0,C.useState)(null);(0,C.useEffect)(()=>{let e=setTimeout(()=>a(r),300);return()=>clearTimeout(e)},[r]);let d=o.trim(),u=nI.a6.crm.searchLeads.useQuery({project_id:e,query:d,limit:8},{enabled:!!e&&d.length>=1,staleTime:6e4}),c=nI.a6.crm.getLeadDetail.useQuery({project_id:e,lead_id:i||""},{enabled:!!e&&!!i,staleTime:6e4});return{busca:r,setBusca:s,resultados:(0,C.useMemo)(()=>{var e,t,n;return(null!==(n=null===(t=u.data)||void 0===t?void 0:null===(e=t.data)||void 0===e?void 0:e.items)&&void 0!==n?n:[]).map(e=>({id:e.id,rotulo:function(e){var t,n,r,s;let o=String(null!==(t=e.display_name)&&void 0!==t?t:"").trim();if(o)return o;let a=String(null!==(n=e.primary_email)&&void 0!==n?n:"").trim();return a?a:String(null!==(r=e.primary_phone)&&void 0!==r?r:"").trim()||String(null!==(s=e.id)&&void 0!==s?s:"").slice(0,8)}(e)}))},[u.data]),escolhido:null!==(n=null===(t=c.data)||void 0===t?void 0:t.data)&&void 0!==n?n:null,escolher:l,carregando:!!i&&c.isLoading,buscando:r.trim().length>0&&(r.trim()!==d||u.isLoading)}}(h),[_,A]=(0,C.useState)(!1),S=nL(c)?c:null,I="action"===c.kind?c:null,z=null==I?void 0:I.content,E=(0,tC.q6)(z),T=(0,tC.pl)(z,E),L=String(null!==(n=null==z?void 0:z.assunto)&&void 0!==n?n:""),P=(0,C.useMemo)(()=>w.escolhido?function(e){let t={},n=function(e){var t,n;if("boolean"==typeof(null==e?void 0:e.is_identified))return e.is_identified;let r=e=>!1!==e.is_current&&!e.valid_to;return(null!==(t=null==e?void 0:e.emails)&&void 0!==t?t:[]).some(r)||(null!==(n=null==e?void 0:e.phones)&&void 0!==n?n:[]).some(r)}(e),r=n?function(e){var t;let n=[...null!==(t=e.addresses)&&void 0!==t?t:[]];return n.sort((e,t)=>
1{var n,r;return e.is_primary!==t.is_primary?e.is_primary?-1:1:String(null!==(n=t.created_at)&&void 0!==n?n:"").localeCompare(String(null!==(r=e.created_at)&&void 0!==r?r:""))}),n[0]}(e):void 0;for(let s of eU){if("is_identified"===s){t[s]=String(n);continue}if(!n){t[s]="";continue}"email"===s?t[s]=e0(e.emails,e.primary_email_id,e=>e.email):"phone"===s?t[s]=e0(e.phones,e.primary_phone_id,e=>e.phone):eX.has(s)?t[s]=eY(null==r?void 0:r[s]):t[s]=function(e,t){var n,r;let s=null!==(n=e.attributes_by_namespace)&&void 0!==n?n:{};for(let e of["profile","attribution"]){let n=null===(r=s[e])||void 0===r?void 0:r.find(e=>e.key===t);if(n){let e=eY(n.value);if(e)return e}}return""}(e,s)}return t}(w.escolhido):eJ(),[w.escolhido]),D=(0,C.useMemo)(()=>eq(T,P),[T,P]),M=(0,C.useMemo)(()=>eq(L,P),[L,P]),G=(0,C.useMemo)(()=>w.escolhido?eH("".concat(L,"\n").concat(T)).filter(e=>{var t;return e.startsWith(eG)&&!String(null!==(t=P[e.slice(eG.length)])&&void 0!==t?t:"").trim()}):[],[w.escolhido,L,T,P]),R=I?(0,t8.fx)(I.channel):null,O=(0,tC.MD)(null==I?void 0:I.channel),$=(null==I?void 0:I.channel)==="webhook"||(null==x?void 0:x.type)==="webhook";return(0,r.jsxs)("div",{className:"space-y-4",children:[(0,r.jsxs)("section",{children:[(0,r.jsx)("p",{className:"mb-1 text-xs font-medium text-foreground",children:k("journeysAcao.revisao.resumo")}),(0,r.jsx)("div",{className:"divide-y rounded-md border px-3",children:S?(0,r.jsx)(nP,{rotulo:k("journeysAcao.titulo.atributo"),valor:k("journeysAcao.subtitulo.atributo",{chave:S.key}),rotuloDoBotao:k("journeysAcao.botao.editar"),onEditar:g?()=>N("acao"):void 0}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(nP,{rotulo:k("journeysAcao.revisao.canal"),valor:R?k(R):String(null!==(s=null==I?void 0:I.channel)&&void 0!==s?s:""),rotuloDoBotao:k("journeysAcao.botao.editar"),onEditar:g?()=>N("acao"):void 0}),(0,r.jsx)(nP,{rotulo:k("journeysAcao.revisao.destino"),valor:null!==(a=null!==(o=null==x?void 0:x.name)&&void 0!==o?o:null==I?void 0:I.destination_id)&&void 0!==a?a:"â",icone:x?(0,r.jsx)(H.s,{id:x.type,className:"h-4 w-4 shrink-0"}):void 0,rotuloDoBotao:k("journeysAcao.botao.editar"),onEditar:g?()=>N("acao"):void 0}),O&&L&&(0,r.jsx)(nP,{rotulo:k("journeysAcao.revisao.assunto"),valor:M,rotuloDoBotao:k("journeysAcao.botao.editar"),onEditar:g?()=>N("conteudo"):void 0}),O&&(0,r.jsx)(nP,{rotulo:k("journeysAcao.revisao.modo"),valor:k("html"===E?"journeysAcao.no.modoHtml":"template_id"===E?"journeysAcao.no.modoModelo":"journeysAcao.no.modoTexto"),rotuloDoBotao:k("journeysAcao.botao.editar"),onEditar:g?()=>N("conteudo"):void 0})]})})]}),S?(0,r.jsx)("p",{className:"rounded-md border bg-muted/30 p-3 text-xs text-foreground",children:k("journeysAcao.atributo.resumo",{chave:S.key,valor:String(S.value)})}):$&&I?(0,r.jsx)(e4,{passo:I,definicao:m,journeyId:j,journeyName:v,leadId:null===(t=w.escolhido)||void 0===t?void 0:t.id,bloco:w.escolhido?P:void 0}):I&&"crm"===I.channel?(0,r.jsx)(nT,{passo:I,projectId:h}):O?(0,r.jsxs)("section",{className:"space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center justify-between gap-2",children:[(0,r.jsx)("p",{className:"text-xs font-medium text-foreground",children:k("journeysAcao.revisao.previa")}),"template_id"!==E&&(0,r.jsxs)("div",{className:"flex items-center gap-1",role:"group",children:[(0,r.jsx)(l.z,{type:"button",variant:_?"ghost":"secondary",size:"sm",className:"h-6 px-2 text-[11px]",onClick:()=>A(!1),children:k("journeysAcao.revisao.desktop")}),(0,r.jsx)(l.z,{type:"button",variant:_?"secondary":"ghost",size:"sm",className:"h-6 px-2 text-[11px]",onClick:()=>A(!0),children:k("journeysAcao.revisao.mobile")})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(d.I,{value:w.busca,onChange:e=>w.setBusca(e.target.value),placeholder:k("journeysAcao.revisao.buscarLead"),className:"h-8 text-xs"}),w.resultados.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:w.resultados.map(e=>{var t;return(0,r.jsx)(l.z,{type:"button",variant:(null===(t=w.escolhido)||void 0===t?void 0:t.id)===e.id?"secondary":"outline",size:"sm",className:"h-6 max-w-full px-2 text-[11px]",onClick:()=>w.escolher(e.id),children:(0,r.jsx)("span",{className:"truncate",children:e.rotulo})},e.id)})}),w.escolhido?(0,r.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5",children:[(0,r.jsxs)("span",{className:"min-w-0 truncate text-[11px] text-muted-foreground",children:[k("journeysAcao.revisao.previaComo"),": ",(0,r.jsx)("span",{className:"text-foreground",children:e1(w.escolhido)})]}),(0,r.jsx)(l.z,{type:"button",variant:"ghost",size:"sm",className:"h-6 px-1.5 text-[11px] text-muted-foreground",onClick:()=>
1w.escolher(null),children:k("journeysAcao.revisao.usarExemplos")})]}):w.buscando?(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:k("journeysAcao.revisao.buscando")}):(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:k("journeysAcao.revisao.semLead")})]}),"template_id"===E?(0,r.jsx)("p",{className:"rounded-md border border-dashed p-3 text-xs text-muted-foreground",children:k("journeysAcao.revisao.modeloNoProvedor",{id:String(null!==(i=null==z?void 0:z.template_id)&&void 0!==i?i:"")})}):(0,r.jsx)("div",{className:"mx-auto w-full transition-[max-width]",style:_?{maxWidth:375}:void 0,children:"html"===E?(0,r.jsx)("iframe",{sandbox:"",srcDoc:D,title:k("journeysAcao.revisao.previa"),className:"h-72 w-full rounded-md border bg-white"}):(0,r.jsx)("pre",{className:"max-h-72 w-full overflow-auto whitespace-pre-wrap rounded-md border bg-muted/30 p-3 text-xs text-foreground",children:D})}),G.length>0&&(0,r.jsx)("p",{className:"rounded-md border border-amber-200 bg-amber-50 p-2 text-[11px] text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300",children:k("journeysAcao.revisao.vazias",{nome:w.escolhido?e1(w.escolhido):"",caminhos:G.join(", ")})})]}):null,I&&(0,r.jsxs)("section",{children:[(0,r.jsx)("p",{className:"mb-1 text-xs font-medium text-foreground",children:k("journeysAcao.revisao.comoExecuta")}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:k("journeys.detail.sentNote")}),(0,r.jsxs)(ne,{titulo:k("journeys.sidebar.subscriptionTitle"),children:[(0,r.jsx)(t9,{k:"signal",v:"journey.step"}),(0,r.jsx)(t9,{k:"step_id",v:I.id}),(0,r.jsx)(t9,{k:k("journeys.builder.destinationLabel"),v:x?"".concat(x.name," (").concat(x.type,")"):I.destination_id||"â"}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:k("journeys.sidebar.subscriptionNote")})]}),(0,r.jsxs)(ne,{titulo:k("journeys.sidebar.contextKeysTitle"),children:[(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:(0,Z.pY)(m).map(e=>(0,r.jsx)("span",{className:"rounded-md border px-1.5 py-0.5 font-mono text-[10px] text-muted-foreground",children:e},e))}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:k("journeys.sidebar.contextKeysNote")})]}),f&&(0,r.jsxs)("div",{className:"mt-2 space-y-1",children:[(0,r.jsx)(t9,{k:k("journeys.detail.executed"),v:y?String(null!==(u=null==b?void 0:b.executados)&&void 0!==u?u:0):"â"}),(0,r.jsx)(t9,{k:k("journeys.detail.delivered"),v:y&&null!==(0,t8.Kk)(b)?String((0,t8.Kk)(b)):"â"}),(0,r.jsx)(t9,{k:k("journeys.detail.dead"),v:y&&null!==(0,t8.p6)(b)?String((0,t8.p6)(b)):"â"})]})]})]})}function nD(e){let{passo:t,passos:n,definicao:s,destinos:o,destinoPorId:a,projectId:i,projectSlug:l,journeyId:d,journeyName:u,modoEdicao:c,problemas:m,stats:x,statsProntos:h,onPassos:j,onFechar:v,invalidarDestinos:g}=e,{t:f}=(0,p.$G)(),b=(0,C.useMemo)(()=>o.map(e=>({id:e.id,name:e.name,type:e.type,quebrado:!!(0,t8.h0)(e)})),[o]),[y,N]=(0,C.useState)(null),k=(0,C.useMemo)(()=>({destinos:b,incompleto:Z.re,motivoDoConteudo:e=>(function(e,t){if("set_attribute"===e.kind)return(0,eL.uJ)(e);if("sms"===e.channel)return"journeysAcao.bloqueio.smsVazio";if("email"===e.channel){var n;let r;return"template_id"===(0,tC.w$)(e.content,t)?"journeysAcao.bloqueio.modeloVazio":"string"!=typeof(r=null===(n=e.content)||void 0===n?void 0:n.assunto)||0===r.trim().length?"journeysAcao.bloqueio.assuntoVazio":"journeysAcao.bloqueio.corpoVazio"}return null})(e,y)}),[b,y]),[w,_]=(0,C.useState)(()=>ni(t,k)),[A]=(0,C.useState)(()=>!na(t)),[S,I]=(0,C.useState)(0),[z,E]=(0,C.useState)(null),T=()=>I(e=>e+1),L=()=>E(S),[D,M]=(0,C.useState)(()=>nr(ni(t,k))),G=c?w:"revisao",R=Math.max(D,nr(ni(t,k)),nr(G)),O="set_attribute"===t.kind,B=a.get("action"===t.kind?t.destination_id:""),F=(0,t8.ot)(x).get(t.id),H=(0,Z.re)(t),q=no(G,t,k)?null:"acao"===G?"journeysAcao.bloqueio.escolhaDestino":"conteudo"===G?k.motivoDoConteudo(t):null,K=no(G,t,k),V="revisao"===G,W=!c||h,Q=V?H?f("journeysAcao.bloqueio.concluirIncompleto"):null:K||!q?null:f(q),U=function(e,t){let n=null==t?void 0:t.trim();return n?e.filter(e=>e.trim()!==n):[...e]}(m.map(e=>f(e.key,e.params)),Q),J=(0,C.useRef)(null);(0,C.useEffect)(()=>{J.current&&(J.current.scrollTop=0)},[G]);let Y=e=>{nr(e)>nr(G)&&L(),_(e),M(t=>Math.max(t,nr(e)))},ee="action"===t.kind?(0,t8.fx)(t.channel):null,et=O?t.key?{chave:"journeysAcao.subtitulo.atributo",params:{chave:t.key}}:{chave:"journeysAcao.subtitulo.semEscolha"}:B&&ee?{chave:"journeysAcao.subtitulo.canalDestino",params:{canal:f(ee),destino:B.name}}:{chave:"journeysAcao.subtitulo.semEscolha"},en=O?$.Z:P.Z;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(X.Tu,{className:"shrink-0 space-y-2 border-b border-border px-6 py-4 text-left",children:[(0,r.jsxs)(X.bC,{className:"flex items-center gap-2 text-base",children:[(0,r.jsx)(en,{className:"h-4 w-4 text-muted-foreground"}),f(O?"journeysAcao.titulo.atributo":"journeysAcao.titulo.acao")]}),(0,r.jsx)(X.Ei,{className:"text-xs",children:f(et.chave,et.params)}),U.length>0&&function(e){let{passoNovo:t,tentouAvancar:n,temConteudo:r}=e;return!!n||!t||r}(function(e){let{intocadoAoAbrir:t,geracao:n,geracaoDoVeredito:r,passo:s}=e;return{passoNovo:t||n>0,tentouAvancar:r===n,temConteudo:na(s)}}({intocadoAoAbrir:A,geracao:S,geracaoDoVeredito:z,passo:t}))&&(0,r.jsx)("ul",{className:"space-y-1 rounded-md border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800 dark:border-amber-900 dark:bg-amber-950 dar
1k:text-amber-300",children:U.map((e,t)=>(0,r.jsx)("li",{children:e},t))}),c&&(0,r.jsx)(nt.L,{className:"pt-1",steps:nn.map(e=>f("journeysAcao.etapa.".concat(e))),current:nr(G),maxReached:R,onGo:e=>Y(nn[e])})]}),(0,r.jsxs)("div",{ref:J,className:"min-h-0 flex-1 space-y-5 overflow-y-auto px-6 py-5",children:[c&&(0,r.jsx)("p",{className:"text-xs leading-relaxed text-muted-foreground",children:f(function(e,t){let n="set_attribute"===t.kind;return"revisao"===e?n?"journeysAcao.descricaoEtapa.revisaoAtributo":"journeysAcao.descricaoEtapa.revisao":"acao"===e?"journeysAcao.descricaoEtapa.acao":n?"journeysAcao.descricaoEtapa.conteudoAtributo":"webhook"===t.channel?"journeysAcao.descricaoEtapa.conteudoWebhook":"crm"===t.channel?"journeysAcao.descricaoEtapa.conteudoCrm":"journeysAcao.descricaoEtapa.conteudo"}(G,t))}),(0,r.jsx)(nB,{stat:F}),(0,t8.h0)(B)&&(0,r.jsx)("p",{className:"rounded-md border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300",children:f("journeys.detail.destinationBroken")}),"acao"===G&&(0,r.jsx)(nN,{passo:t,passos:n,destinos:b,projectSlug:l,onEscolher:e=>{var r;if("kind"in e){if(O)return;T(),j(eN(n,t.id,(0,eL.MF)(t.id)));return}let s=null!==(r=e.destination_id)&&void 0!==r?r:"";if("action"!==t.kind){T(),j(eN(n,t.id,{...(0,Z.d$)(e.channel),id:t.id,destination_id:s}));return}if(t.channel!==e.channel){T(),j(ey(n,t.id,{channel:e.channel,destination_id:s,content:{}}));return}j(ey(n,t.id,{destination_id:s}))},invalidarDestinos:g}),"conteudo"===G&&(0,r.jsx)(t7,{passo:t,onChange:e=>
1{if("set_attribute"===t.kind){j(eN(n,t.id,{...t,...e,id:t.id,kind:"set_attribute"}));return}j(ey(n,t.id,e))},projectId:i,destinoTipo:null==B?void 0:B.type,definicao:s,journeyName:u,modoDoEmail:y,onModoDoEmail:N}),"revisao"===G&&(0,r.jsx)(nZ,{passo:t,definicao:s,destino:B,projectId:i,journeyId:d,journeyName:u,modoEdicao:c,modoDetalhe:W,statsDoPasso:F,statsProntos:h,onIrPara:Y}),d&&V?(0,r.jsx)(nS,{projectId:i,journeyId:d,stepId:t.id}):null]}),c&&(0,r.jsx)(nM,{etapa:G,onRemover:()=>{j(eb(n,t.id)),v()},incompleto:H,liberado:K,frase:Q,onIrPara:Y,onConcluir:()=>{L(),v()}})]})}function nM(e){let{etapa:t,onRemover:n,incompleto:s,liberado:o,frase:a,onIrPara:i,onConcluir:d}=e,{t:u}=(0,p.$G)(),c="revisao"===t,m=function(e){let t=nr(e);return t>0?nn[t-1]:null}(t);return(0,r.jsxs)("div",{className:"flex shrink-0 items-center justify-between gap-3 border-t border-border px-6 py-3",children:[(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-1",children:[(0,r.jsx)(l.z,{variant:"ghost",size:"sm",disabled:null===m,onClick:()=>{m&&i(m)},children:u("journeysAcao.botao.voltar")}),(0,r.jsx)(re,{onClick:n,noRodape:!0})]}),(0,r.jsxs)("div",{className:"flex min-w-0 items-center gap-3",children:[a?(0,r.jsx)("span",{className:"min-w-0 truncate text-xs text-muted-foreground",children:a}):null,c?(0,r.jsx)(l.z,{size:"sm",onClick:d,children:u(s?"journeysAcao.botao.concluirMesmoAssim":"journeysAcao.botao.concluir")}):(0,r.jsx)(l.z,{size:"sm",disabled:!o,onClick:()=>{var e;let n=null!==(e=nn[nr(t)+1])&&void 0!==e?e:null;n&&i(n)},children:u("journeysAcao.botao.proximo")})]})]})}function nG(e){let{selecao:t,onFechar:n}=e,s=(null==t?void 0:t.tipo)==="passo"?eC(e.passos,t.id):null,o=(null==s?void 0:s.kind)==="action"||(null==s?void 0:s.kind)==="set_attribute",a=t?(0,t8.MW)(t):"";return(0,r.jsx)(X.yo,{open:!!t,onOpenChange:e=>{e||n()},children:(0,r.jsx)(X.ue,{side:"right",noOverlay:!0,className:o?"flex w-[760px] flex-col gap-0 p-0 sm:max-w-[760px]":"w-[760px] overflow-y-auto sm:max-w-[760px]",children:t?(0,r.jsx)(nR,{...e,selecao:t},a):null})})}function nR(e){let{t}=(0,p.$G)(),n=(0,j.NL)(),{selecao:s,passos:o,problemas:a}=e;if("trigger"===s.tipo)return(0,r.jsx)(nW,{...e,indice:s.indice});if("gate"===s.tipo)return(0,r.jsx)(nX,{...e});if("case"===s.tipo)return(0,r.jsx)(n8,{...e,selecao:s});if("hold-ramo"===s.tipo)return(0,r.jsx)(n4,{...e,selecao:s});if("split-caminho"===s.tipo)return(0,r.jsx)(n7,{...e,selecao:s});let i=eC(o,s.id);if(!i)return(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:t("journeys.detail.loadError")});let l=(null!=a?a:[]).filter(e=>e.stepId===i.id);if("action"===i.kind||"set_attribute"===i.kind)return(0,r.jsx)(nD,{passo:i,passos:o,definicao:{steps:o},destinos:e.destinos,destinoPorId:e.destinoPorId,projectId:e.projectId,projectSlug:e.projectSlug,journeyId:e.journeyId,journeyName:e.journeyName,modoEdicao:e.modoEdicao,problemas:l,stats:e.stats,statsProntos:e.statsProntos,onPassos:e.onPassos,onFechar:e.onFechar,invalidarDestinos:()=>void n.invalidateQueries({queryKey:["actions","destinations",e.projectId]})});let d="wait"===i.kind?(0,r.jsx)(n5,{...e,passo:i,problemas:l}):"hold_until"===i.kind?(0,r.jsx)(n3,{...e,passo:i,problemas:l}):"branch"===i.kind?(0,r.jsx)(n2,{...e,branch:i,problemas:l}):"split"===i.kind?(0,r.jsx)(n6,{...e,split:i,problemas:l}):(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:t("journeys.detail.loadError")});return e.journeyId?(0,r.jsxs)("div",{className:"space-y-5",children:[d,(0,r.jsx)(nS,{projectId:e.projectId,journeyId:e.journeyId,stepId:i.id})]}):d}function nO(e){let{icone:t,titulo:n,problemas:s}=e,{t:o}=(0,p.$G)();return(0,r.jsxs)(X.Tu,{className:"mb-3 space-y-2",children:[(0,r.jsxs)(X.bC,{className:"flex items-center gap-2 text-base",children:[(0,r.jsx)(t,{className:"h-4 w-4 text-muted-foreground"})," ",n]}),s&&s.length>0?(0,r.jsx)("ul",{className:"space-y-1 rounded-md border border-amber-200 bg-amber-50 p-2 text-xs text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300",children:s.map((e,t)=>(0,r.jsx)("li",{children:o(e.key,e.params)},t))}):null]})}function n$(e){let{titulo:t,children:n}=e;return(0,r.jsxs)("section",{className:"mb-4",children:[(0,r.jsx)("h3",{className:"mb-2 text-[11px] font-medium uppercase tracking-wide text-muted-foreground",children:t}),(0,r.jsx)("div",{className:"space-y-2",children:n})]})}function nB(e){let{stat:t}=e,{t:n}=(0,p.$G)(),s=a(o(t));return s?(0,r.jsx)("p",{className:"mb-3 rounded-md border border-border bg-muted/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:n("journeys.sidebar.stepDebutNote",{date:s.params.date,version:s.params.version})}):null}function nF(e){let{stats:t}=e,{t:n}=(0,p.$G)(),s=function(e){let t=null==e?void 0:e.entradas_sem_gatilho;return"number"==typeof t&&t>0?t:null}(t);return null===s?null:(0,r.jsx)("p",{className:"mb-3 rounded-md border border-border bg-muted/40 px-2.5 py-2 text-[11px] text-muted-foreground",children:n("journeys.sidebar.entriesBeforeMeasure",{n:s})})}function nH(e){var t,n;let{t:s}=(0,p.$G)(),{entrada:o,onTrocar:a,modoEdicao:i}=e,l=function(e){if(!e)return"ilimitado";let{max_entries:t,cooldown_minutes:n}=e;return 1===t?"uma_vez":"number"==typeof t&&t>1?"ate_n":"number"==typeof n&&n>0?"com_carencia":"ilimitado"}(o),u={maxEntries:null==o?void 0:o.max_entries,cooldownMinutes:null==o?void 0:o.cooldown_minutes},c=function(e,t){let n=t.maxEntries,r=t.cooldownMinutes;if("com_carencia"===e)return"number"==typeof r&&r>0?null:"cooldownRequired";if("ate_n"===e){if(!("number"==typeof n&&n>0))return"maxRequired";if(1===n&&"number"==typeof r&&r>0)return"cooldownWithSingleEntry"}return null}(l,u),m=(e,t)=>
1{null==a||a(function(e,t){if("ilimitado"===e)return;if("uma_vez"===e)return{max_entries:1};if("com_carencia"===e)return{cooldown_minutes:t.cooldownMinutes};let n={max_entries:t.maxEntries};return"number"==typeof t.cooldownMinutes&&t.cooldownMinutes>0&&(n.cooldown_minutes=t.cooldownMinutes),n}(e,t))},x=[["ilimitado",s("journeys.reentry.unlimited")],["uma_vez",s("journeys.reentry.onceEver")],["ate_n",s("journeys.reentry.upToN")],["com_carencia",s("journeys.reentry.withCooldown")]];return(0,r.jsxs)(n$,{titulo:s("journeys.reentry.title"),children:[(0,r.jsx)("div",{className:"space-y-1.5",children:x.map(e=>{let[t,n]=e;return(0,r.jsxs)("label",{className:"flex items-start gap-2 text-xs",children:[(0,r.jsx)("input",{type:"radio",className:"mt-0.5",checked:l===t,disabled:!i,onChange:()=>m(t,u)}),(0,r.jsx)("span",{className:l===t?"text-foreground":"text-muted-foreground",children:n})]},t)})}),"ate_n"===l&&(0,r.jsx)(d.I,{type:"number",min:1,className:"mt-2 h-8 text-xs",disabled:!i,value:null!==(t=u.maxEntries)&&void 0!==t?t:"",placeholder:s("journeys.reentry.maxPlaceholder"),onChange:e=>m("ate_n",{...u,maxEntries:Number(e.target.value)||void 0})}),"com_carencia"===l&&(0,r.jsx)(d.I,{type:"number",min:1,className:"mt-2 h-8 text-xs",disabled:!i,value:null!==(n=u.cooldownMinutes)&&void 0!==n?n:"",placeholder:s("journeys.reentry.cooldownPlaceholder"),onChange:e=>m("com_carencia",{...u,cooldownMinutes:Number(e.target.value)||void 0})}),c&&(0,r.jsx)("p",{className:"mt-2 text-[11px] text-red-600 dark:text-red-400",children:s("journeys.reentry.".concat(c))}),(0,r.jsx)("p",{className:"mt-2 text-[11px] text-muted-foreground",children:s("journeys.reentry.note")})]})}function nq(e){var t;let{t:n}=(0,p.$G)(),{janela:o,onTrocar:a,modoEdicao:i}=e,l=o?s.test(o.from)&&s.test(o.to)?o.from>=o.to?"crossesMidnight":o.tz?o.days&&0===o.days.length?"daysRequired":null:"tzRequired":"badTime":null,u=null!==(t=null==o?void 0:o.days)&&void 0!==t?t:[],c=e=>{if(!o)return;let t=u.includes(e)?u.filter(t=>t!==e):[...u,e].sort();a({...o,days:t.length?t:void 0})};return(0,r.jsxs)(n$,{titulo:n("journeys.window.title"),children:[(0,r.jsxs)("label",{className:"flex items-start gap-2 text-xs",children:[(0,r.jsx)("input",{type:"checkbox",className:"mt-0.5",checked:!!o,disabled:!i,onChange:e=>a(e.target.checked?{from:"09:00",to:"18:00",tz:Intl.DateTimeFormat().resolvedOptions().timeZone||"UTC"}:void 0)}),(0,r.jsx)("span",{className:o?"text-foreground":"text-muted-foreground",children:n("journeys.window.enable")})]}),o&&(0,r.jsxs)("div",{className:"mt-2 space-y-2",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(d.I,{type:"time",className:"h-8 text-xs",disabled:!i,value:o.from,onChange:e=>a({...o,from:e.target.value})}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"â"}),(0,r.jsx)(d.I,{type:"time",className:"h-8 text-xs",disabled:!i,value:o.to,onChange:e=>a({...o,to:e.target.value})})]}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:[1,2,3,4,5,6,7].map(e=>(0,r.jsx)("button",{type:"button",disabled:!i,onClick:()=>c(e),className:"rounded border px-1.5 py-0.5 text-[11px] "+(0===u.length||u.includes(e)?"border-foreground
1/30 text-foreground":"border-border text-muted-foreground"),children:n("journeys.window.day".concat(e))},e))}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("journeys.window.tzNote",{tz:o.tz})}),l&&(0,r.jsx)("p",{className:"text-[11px] text-red-600 dark:text-red-400",children:n("journeys.window.".concat(l))})]})]})}function nK(e){let{children:t}=e,{t:n}=(0,p.$G)();return(0,r.jsxs)(U.J2,{children:[(0,r.jsx)(U.xo,{asChild:!0,children:(0,r.jsxs)("button",{type:"button","aria-label":n("journeys.sidebar.howItRuns"),className:"mb-3 inline-flex items-center gap-1.5 rounded-md border border-border px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted",children:[(0,r.jsx)(ea.Z,{className:"h-3 w-3"}),n("journeys.sidebar.howItRuns")]})}),(0,r.jsx)(U.yk,{align:"start",className:"w-80 space-y-2",children:t})]})}let nV=e=>{let{children:t}=e;return(0,r.jsx)("div",{className:"space-y-1.5 rounded-md border bg-muted/30 p-3",children:t})};function nW(e){let{t}=(0,p.$G)(),{indice:n,gatilhos:s,modoEdicao:o,onTrocarGatilho:a,onRemoverGatilho:i,projectId:d,sources:u,problemas:c}=e,[m,x]=(0,C.useState)(1),h=s[n],j=(0,Z.pO)(n),v=(null!=c?c:[]).filter(e=>e.stepId===j||!e.stepId&&e.key.includes("trigger")),g=s.length>1?"".concat(t("journeys.builder.triggerTitle")," ").concat(n+1):t("journeys.builder.triggerTitle");if(!h)return null;let f=ev(h);return(0,r.jsxs)("div",{children:[(0,r.jsx)(nO,{icone:R.Z,titulo:g,problemas:v}),(0,r.jsx)(nF,{stats:e.stats}),(0,r.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:t("journeys.builder.triggerHint")}),(0,r.jsx)(n$,{titulo:t("journeys.sidebar.configure"),children:h.editavel?o?(0,r.jsx)(nU,{projectId:d,sources:u,ui:h,etapa:m,onEtapa:x,onChange:e=>a(n,e)}):f?(0,r.jsx)(tW,{gate:f}):null:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.builder.conditionPreserved")}),(0,r.jsx)(tW,{gate:h.original})]})}),(!o||!h.editavel||2===m)&&(0,r.jsx)(nK,{children:f?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(nV,{children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.sidebar.gateRuleTitle")}),(0,r.jsx)(tW,{gate:f})]}),(0,r.jsx)(nQ,{ui:h})]}):(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.sidebar.triggerIncomplete")}
1)}),o&&s.length>1&&(0,r.jsx)("div",{className:"border-t pt-3",children:(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400",onClick:()=>i(n),children:[(0,r.jsx)(ei.Z,{className:"h-3.5 w-3.5"})," ",t("journeys.sidebar.removeTrigger")]})}),(0,r.jsx)(nH,{entrada:e.entrada,onTrocar:e.onTrocarEntrada,modoEdicao:o})]})}function nQ(e){let{ui:t}=e,{t:n}=(0,p.$G)();if(!t.editavel)return null;let s=(0,Z.MV)(t.spec);return 0===s.length?null:(0,r.jsxs)(nV,{children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("journeys.sidebar.runtimeEvents")}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:s.map(e=>(0,r.jsx)(i.C,{variant:"outline",className:"font-mono text-[10px]",children:e},e))}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("journeys.sidebar.gateVsRuntimeNote")})]})}function nU(e){var t,n,s,o,a;let{projectId:i,sources:d,ui:u,etapa:c,onEtapa:m,onChange:x}=e,{t:h}=(0,p.$G)(),j=u.spec,g=e=>x({editavel:!0,spec:{...j,...e}}),f=new Map;for(let e of d){if(!er.XC.includes(e.origin))continue;let t=f.get(e.origin);f.set(e.origin,{label:e.originLabel,count:(null!==(n=null==t?void 0:t.count)&&void 0!==n?n:0)+1})}let b=(0,v.a)({queryKey:["audiences",i,"lista"],queryFn:()=>et.j.listAudiences(i),enabled:!!i,staleTime:6e4}),y=(null!==(s=null===(t=b.data)||void 0===t?void 0:t.results)&&void 0!==s?s:[]).filter(e=>"archived"!==e.status),N=d.filter(e=>e.origin===j.origem),k=e=>{let t=d.filter(t=>t.origin===e).map(e=>e.id);g({origem:e,sourceIds:"PIXEL"===e||e===en.eu?[]:t,eventos:[],audienceId:void 0,filtro:null})},w=e=>g({sourceIds:j.sourceIds.includes(e)?j.sourceIds.filter(t=>t!==e):[...j.sourceIds,e]}),_=e=>g({eventos:j.eventos.includes(e)?j.eventos.filter(t=>t!==e):[...j.eventos,e]}),C=N.filter(e=>j.sourceIds.includes(e.id)).map(e=>e.slug),{eventos:A}=(0,es.BX)(i,j.origem,C),S=j.origem?(0,er.lm)(j.origem):[],I=new Set(S.map(e=>e.value)),z=new Map(A.map(e=>[e.name,e.count])),E=A.filter(e=>!I.has(e.name)).slice(0,8),T=(0,Z.MV)(j),{amostras:L,carregando:P}=(0,eo.v)(i,T),D=j.origem?(0,er.tv)(j.origem,null,null!==(o=T[0])&&void 0!==o?o:""):[],M=!!j.origem&&"TALLY_FORMS"!==j.origem,G=T.length>0;return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)(nJ,{etapa:c,onEtapa:m,podeCondicionar:G}),1===c&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1.5 text-xs font-medium text-foreground",children:h("pipeline.sourceStep.title")}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[[...f.entries()].map(e=>{let[t,n]=e,s=t===en.eu?void 0:q.l[t],o=j.origem===t;return(0,r.jsxs)("button",{type:"button",onClick:()=>k(t),className:(0,F.cn)("flex items-center gap-2 rounded-md border p-2.5 text-left transition-colors",o?"border-primary bg-primary/5":"hover:border-primary/50"),children:[(0,r.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-muted",children:s?(0,r.jsx)(s,{className:"h-4 w-4",showTooltip:!1}):null}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block truncate text-xs font-medium text-foreground",children:n.label}),(0,r.jsx)("span",{className:"block text-[10px] text-muted-foreground",children:h("pipeline.sourceStep.integrationsCount",{count:n.count})})]}),o?(0,r.jsx)(el.Z,{className:"h-3.5 w-3.5 shrink-0 text-primary"}):(0,r.jsx)(ed.Z,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]},t)}),(0,r.jsxs)("button",{type:"button",onClick:()=>k(en.eu),className:(0,F.cn)("flex items-center gap-2 rounded-md border p-2.5 text-left transition-colors",j.origem===en.eu?"border-primary bg-primary/5":"hover:border-primary/50"),children:[(0,r.jsx)("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md bg-muted",children:(0,r.jsx)(Y.ee,{className:"h-4 w-4",showTooltip:!1})}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block truncate text-xs font-medium text-foreground",children:h("pipeline.audience.originLabel")}),(0,r.jsx)("span",{className:"block text-[10px] text-muted-foreground",children:b.isError?h("journeys.sidebar.audie
1nceLoadError"):y.length>0?h("pipeline.audience.typeHint",{count:y.length}):h("pipeline.audience.typeNone")})]}),j.origem===en.eu?(0,r.jsx)(el.Z,{className:"h-3.5 w-3.5 shrink-0 text-primary"}):(0,r.jsx)(ed.Z,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"})]})]})]}),"PIXEL"===j.origem&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:h("journeys.sidebar.pixelNoSourceCut")}),j.origem===en.eu&&(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1.5 text-xs font-medium text-foreground",children:h("pipeline.audience.pickTitle")}),b.isError?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:h("journeys.sidebar.audienceLoadError")}):0===y.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:h("pipeline.audience.none")}):(0,r.jsx)("div",{className:"flex max-h-56 flex-col gap-1.5 overflow-y-auto pr-1",children:y.map(e=>{let t=j.audienceId===e.id;return(0,r.jsxs)("button",{type:"button",onClick:()=>g({audienceId:t?void 0:e.id}),className:(0,F.cn)("flex items-center gap-2 rounded-md border p-2 text-left transition-colors",t?"border-primary bg-primary/5":"hover:border-foreground
1/20"),children:[(0,r.jsx)("span",{className:(0,F.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded-full border",t?"border-primary bg-primary text-primary-foreground":"border-input"),children:t&&(0,r.jsx)(el.Z,{className:"h-3 w-3"})}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block truncate text-xs font-medium text-foreground",children:e.name}),(0,r.jsx)("span",{className:"block text-[10px] text-muted-foreground",children:h("pipeline.audience.members",{count:e.members.toLocaleString("pt-BR")})})]})]},e.id)})})]}),j.origem&&"PIXEL"!==j.origem&&j.origem!==en.eu&&(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1.5 text-xs font-medium text-foreground",children:h("pipeline.sourceStep.pickSource")}),0===N.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:h("pipeline.sourceStep.noSources")}):(0,r.jsx)("div",{className:"flex max-h-56 flex-col gap-1.5 overflow-y-auto pr-1",children:N.map(e=>{let t=j.sourceIds.includes(e.id);return(0,r.jsxs)("button",{type:"button",onClick:()=>w(e.id),className:(0,F.cn)("flex items-center gap-2 rounded-md border p-2 text-left transition-colors",t?"border-primary bg-primary/5":"hover:border-foreground
1/20"),children:[(0,r.jsx)("span",{className:(0,F.cn)("flex h-4 w-4 shrink-0 items-center justify-center rounded border",t?"border-primary bg-primary text-primary-foreground":"border-input"),children:t&&(0,r.jsx)(el.Z,{className:"h-3 w-3"})}),(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:"block truncate text-xs font-medium text-foreground",children:e.name}),(0,r.jsx)("span",{className:"block text-[10px] text-muted-foreground",children:e.eventsLast30Days?h("pipeline.sourceStep.seenCount",{count:e.eventsLast30Days.toLocaleString("pt-BR")}):e.originLabel})]})]},e.id)})})]}),"TALLY_FORMS"===j.origem&&j.sourceIds.length>0&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:h("journeys.sidebar.tallyGateNote")}),M&&(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1.5 text-xs font-medium text-foreground",children:h("pipeline.sourceStep.originEventLabel")}),(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-1.5",children:[S.map(e=>{let t=j.eventos.includes(e.value),n=z.get(e.value);return(0,r.jsxs)("button",{type:"button",onClick:()=>_(e.value),className:(0,F.cn)("flex items-center gap-2 rounded-md border p-2 text-left transition-colors",t?"border-primary bg-primary/5":"hover:border-foreground
1/20"),children:[(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:(0,F.cn)("block truncate text-xs",t?"text-foreground":"text-muted-foreground"),children:e.labelKey?h(e.labelKey):e.label}),void 0!==n&&(0,r.jsx)("span",{className:"block text-[10px] tabular-nums text-muted-foreground/70",children:h("pipeline.sourceStep.seenCount",{count:n.toLocaleString("pt-BR")})})]}),t&&(0,r.jsx)(el.Z,{className:"h-3 w-3 shrink-0 text-primary"})]},e.value)}),j.origem!==en.eu&&E.map(e=>{let t=j.eventos.includes(e.name);return(0,r.jsxs)("button",{type:"button",onClick:()=>_(e.name),className:(0,F.cn)("flex items-center gap-2 rounded-md border p-2 text-left transition-colors",t?"border-primary bg-primary/5":"hover:border-foreground/20"),children:[(0,r.jsxs)("span",{className:"min-w-0 flex-1",children:[(0,r.jsx)("span",{className:(0,F.cn)("block truncate font-mono text-[11px]",t?"text-foreground":"text-muted-foreground"),children:e.name}),(0,r.jsx)("span",{className:"block text-[10px] tabular-nums text-muted-foreground/70",children:h("pipeline.sourceStep.seenCount",{count:e.count.toLocaleString("pt-BR")})})]}),t&&(0,r.jsx)(el.Z,{className:"h-3 w-3 shrink-0 text-primary"})]},e.name)})]})]})]}),2===c&&(G&&j.origem?(0,r.jsx)(ee.d,{origin:j.origem===en.eu?null:j.origem,value:j.filtro,onChange:e=>g({filtro:e}),sourceEventFields:D,originEvent:null!==(a=T[0])&&void 0!==a?a:"",amostras:L,carregandoAmostras:P}):(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:h("journeys.sidebar.stepNeedsEvent")})),(0,r.jsxs)("div",{className:"flex items-center justify-between border-t pt-3",children:[2===c?(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"text-xs",onClick:()=>m(1),children:h("journeys.sidebar.stepBack")}):(0,r.jsx)("span",{}),1===c&&(0,r.jsx)(l.z,{size:"sm",className:"text-xs",disabled:!G,title:G?void 0:h("journeys.sidebar.stepNeedsEvent"),onClick:()=>m(2),children:h("journeys.sidebar.stepNext")})]})]})}function nJ(e){let{etapa:t,onEtapa:n,podeCondicionar:s}=e,{t:o}=(0,p.$G)(),a=(e,s,o)=>(0,r.jsxs)("button",{type:"button",disabled:!o,onClick:()=>n(e),className:(0,F.cn)("flex items-center gap-1.5 rounded-md px-2 py-1 text-[11px] transition-colors",t===e?"bg-muted font-medium text-foreground":"text-muted-foreground",o?"hover:text-foreground":"cursor-not-allowed opacity-50"),children:[(0,r.jsx)("span",{className:(0,F.cn)("flex h-4 w-4 items-center justify-center rounded-full border text-[9px] tabular-nums",t===e?"border-primary text-primary":"border-muted-foreground/40"),children:e}),s]});return(0,r.jsxs)("div",{className:"flex items-center gap-1",children:[a(1,o("journeys.sidebar.stepOrigin"),!0),(0,r.jsx)(ed.Z,{className:"h-3 w-3 text-muted-foreground/50"}),a(2,o("journeys.sidebar.stepConditions"),s)]})}function nX(e){let{t}=(0,p.$G)(),{saida:n,modoEdicao:s,onTrocarSaida:o,projectId:a,problemas:l}=e,d=(null!=l?l:[]).filter(e=>!e.stepId&&e.key.includes("exit"));return(0,r.jsxs)("div",{children:[(0,r.jsx)(nO,{icone:O.Z,titulo:t("journeys.builder.exitTitle"),problemas:d}),(0,r.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:t("journeys.detail.exitPhrase")}),(0,r.jsx)(n$,{titulo:t("journeys.sidebar.configure"),children:s?(0,r.jsx)(n0,{projectId:a,value:n,onChange:o}):(0,r.jsx)(tW,{gate:nY(n)})}),(0,r.jsxs)(nK,{children:[(0,r.jsxs)(nV,{children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.sidebar.gateRuleTitle")}),(0,r.jsx)(tW,{gate:nY(n)})]}),n.editavel&&n.eventos.length>0&&(0,r.jsxs)(nV,{children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.sidebar.runtimeEvents")}),(0,r.jsx)("div",{className:"flex flex-wrap gap-1",children:(0,Z.OU)(n.origem,n.eventos).map(e=>(0,r.jsx)(i.C,{variant:"outline",className:"font-mono text-[10px]",children:e},e))}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.sidebar.gateVsRuntimeNote")})]}),!n.editavel&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.builder.conditionPreserved")})]})]})}function nY(e){var t;return e.editavel?null!==(t=(0,Z.aU)(e.origem,e.eventos,e.filtro))&&void 0!==t?t:{event_source:"HOTMART"===e.origem?"hotmart":"pixel",rule:{type:"and",conditions:[]}}:e.original}function n0(e){let{projectId:t,value:n,onChange:s}=e;return n.editavel?(0,r.jsx)(n1,{projectId:t,value:n,onChange:s}):(0,r.jsx)(tW,{gate:n.original})}function n1(e){var t,n,s;let{projectId:o,value:a,onChange:i}=e,{t:l}=(0,p.$G)(),d=(0,er.lm)(a.origem),c=(0,Z.OU)(a.origem,a.eventos),{amostras:m,carregando:x}=(0,eo.v)(o,c),h=(0,er.tv)(a.origem,null,null!==(t=a.eventos[0])&&void 0!==t?t:"");return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsxs)("div",{className:"grid grid-cols-2 gap-3",children:[(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{children:l("journeys.builder.originLabel")}),(0,r.jsxs)(J.Ph,{value:a.origem,onValueChange:e=>i({...a,origem:e,eventos:[],filtro:null}),children:[(0,r.jsx)(J.i4,{children:(0,r.jsx)(J.ki,{})}),(0,r.jsxs)(J.Bw,{className:"z-[110]",children:[(0,r.jsx)(J.Ql,{value:"HOTMART",children:"Hotmart"}),(0,r.jsx)(J.Ql,{value:"PIXEL",children:"Pixel"})]})]})]}),(0,r.jsxs)("div",{className:"space-y-1.5",children:[(0,r.jsx)(u._,{children:l("journeys.builder.eventLabel")}),(0,r.jsxs)(J.Ph,{value:null!==(n=a.eventos[0])&&void 0!==n?n:"",onValueChange:e=>i({...a,eventos:[e]}),children:[(0,r.jsx)(J.i4,{children:(0,r.jsx)(J.ki,{})}),(0,r.jsx)(J.Bw,{className:"z-[110]",children:d.map(e=>(0,r.jsx)(J.Ql,{value:e.value,children:e.labelKey?l(e.labelKey):e.label},e.value))})]})]})]}),a.eventos.length>0&&(0,r.jsx)(ee.d,{origin:a.origem,value:a.filtro,onChange:e=>i({...a,filtro:e}),sourceEventFields:h,originEvent:null!==(s=a.eventos[0])&&void 0!==s?s:"",amostras:m,carregandoAmostras:x})]})}function n5(e){var t;let{t:n}=(0,p.$G)(),{passo:s,modoEdicao:o,onPassos:a,passos:i,statsProntos:l}=e,d=(0,t8.Mg)(s.minutes),u=n(d.key,d.params),c=(0,t8.ot)(e.stats).get(s.id);return(0,r.jsxs)("div",{children:[(0,r.jsx)(nO,{icone:L.Z,titulo:n("journeys.detail.wait"),problemas:e.problemas}),(0,r.jsx)(nB,{stat:c}),(0,r.jsx)(n$,{titulo:n("journeys.sidebar.configure"),children:o?(0,r.jsx)(tQ,{passo:s,onChange:e=>a(ey(i,s.id,e))}):(0,r.jsx)("p",{className:"text-sm text-foreground",children:u})}),(0,r.jsx)(nq,{janela:s.window,onTrocar:e=>a(ey(i,s.id,{window:e})),modoEdicao:o}),(0,r.jsxs)(nK,{children:[(0,r.jsxs)(nV,{children:[(0,r.jsx)("p",{className:"text-xs text-foreground",children:n("journeys.sidebar.waitHow",{duracao:u})}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n(t8.C5)})]}
1),!o&&(0,r.jsx)(t9,{k:n("journeys.detail.executed"),v:l?String(null!==(t=null==c?void 0:c.executados)&&void 0!==t?t:0):"â"})]}),o&&(0,r.jsx)(re,{onClick:()=>rt(e,s.id)})]})}function n2(e){let{t}=(0,p.$G)(),{branch:n,modoEdicao:s,onPassos:o,passos:a,onSelecionar:i,onInserirApos:d}=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)(nO,{icone:z.Z,titulo:t("journeys.builder.branchTitle"),problemas:e.problemas}),(0,r.jsx)(n$,{titulo:t("journeys.sidebar.configure"),children:s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tX,{branch:n,onChange:e=>o(e_(a,n.id,()=>e)),onSelecionarCase:e=>i({tipo:"case",branchId:n.id,caseId:e,ehDefault:!1})}),(0,r.jsxs)("div",{className:"space-y-1.5 border-t pt-3",children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.flow.addAfterBranch")}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>d(n.id,"wait"),children:[(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})," ",t("journeys.builder.addWait")]}),(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>d(n.id,"action"),children:[(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})," ",t("journeys.builder.addAction")]})]})]})]}):(0,r.jsxs)("ul",{className:"space-y-1 text-sm text-foreground",children:[n.cases.map((e,s)=>(0,r.jsx)("li",{children:(0,r.jsx)("button",{type:"button",className:"text-left hover:underline",onClick:()=>i({tipo:"case",branchId:n.id,caseId:e.id,ehDefault:!1}),children:e.label||t("journeys.canvas.caseFallback",{n:s+1})})},e.id)),(0,r.jsx)("li",{className:"text-muted-foreground",children:t("journeys.canvas.elseLabel")})]})}),(0,r.jsxs)(nK,{children:[(0,r.jsx)(nV,{children:(0,r.jsx)("p",{className:"text-xs text-foreground",children:t("journeys.builder.branchHint")})}),n.cases.some(e=>{var t;return null===(t=e.condition)||void 0===t?void 0:t.observed})&&(0,r.jsxs)(nV,{children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.sidebar.observersOfBranch")}),n.cases.map((e,n)=>{var s;return(null===(s=e.condition)||void 0===s?void 0:s.observed)?(0,r.jsx)(t9,{k:e.label||t("journeys.canvas.caseFallback",{n:n+1}),v:(0,ec.yZ)(e.condition.observed.event_source,e.condition.observed.rule)},e.id):null}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.sidebar.observerHashNote")})]})]}),s&&(0,r.jsx)(re,{onClick:()=>rt(e,n.id)})]})}function n3(e){var t;let{t:n}=(0,p.$G)(),{passo:s,modoEdicao:o,onPassos:a,passos:i,projectId:l,sources:d,medidos:u}=e,[c,m]=(0,C.useState)(1),x=(0,C.useCallback)(e=>(0,Z.Xc)([e],null!=u?u:[]),[u]),[h,j]=(0,C.useState)(()=>{var e,t,n;return 0===(null!==(n=null===(t=s.event)||void 0===t?void 0:null===(e=t.rule)||void 0===e?void 0:e.conditions)&&void 0!==n?n:[]).length?ep:ej(s.event,e=>{var t;return null===(t=(null!=d?d:[]).find(t=>t.id===e))||void 0===t?void 0:t.origin},x)}),v=e=>a(ey(i,s.id,e)),g=s.event,f=!!(null==g?void 0:g.rule)&&(null!==(t=g.rule.conditions)&&void 0!==t?t:[]).length>0,b=(0,t8.Mg)(s.timeout_minutes),y=n(b.key,b.params);return(0,r.jsxs)("div",{children:[(0,r.jsx)(nO,{icone:E.Z,titulo:n("journeys.hold.title"),problemas:e.problemas}),(0,r.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:n("journeys.hold.hint")}),(0,r.jsxs)(n$,{titulo:n("journeys.hold.capTitle"),children:[o?(0,r.jsx)(tJ,{passo:s,onChange:e=>v(e)}):(0,r.jsx)("p",{className:"text-sm font-medium text-foreground",children:y}),(0,r.jsx)("p",{className:"mt-1.5 text-[11px] text-muted-foreground",children:n("journeys.hold.capExplain")})]}),(0,r.jsx)(n$,{titulo:n("journeys.hold.eventTitle"),children:o?h.editavel?(0,r.jsx)(nU,{projectId:l,sources:null!=d?d:[],ui:h,etapa:c,onEtapa:m,onChange:e=>{j(e);let t=ev(e);v({event:null!=t?t:{event_source:"pixel",rule:{type:"and",conditions:[]}}})}}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("p",{className:"mb-2 text-[11px] text-muted-foreground",children:n("journeys.sidebar.gatePreserved")}),(0,r.jsx)(tW,{gate:h.original})]}):f?(0,r.jsx)(tW,{gate:g}):(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:"â"})}),(0,r.jsxs)(nK,{children:[(0,r.jsxs)(nV,{children:[(0,r.jsx)("p",{className:"text-xs text-foreground",children:n("journeys.sidebar.holdHow")}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n(t8.C5)})]}),f&&(0,r.jsxs)(ne,{titulo:n("journeys.sidebar.holdWakeTitle"),children:[(0,r.jsx)(t9,{k:"observer_id",v:(0,ec.yZ)(g.event_source,g.rule)}),(0,r.jsx)(t9,{k:"event_source",v:g.event_source}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("journeys.sidebar.holdWakeNote")}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:n("journeys.sidebar.observerHashNote")})]})]}),o&&(0,r.jsx)(re,{onClick:()=>rt(e,s.id)})]})}function n4(e){let{t}=(0,p.$G)(),{selecao:n,statsProntos:s,stats:o}=e,a="met"===n.ramo,i=(0,t8.xq)(o,n.holdId,n.ramoId);return(0,r.jsxs)("div",{children:[(0,r.jsx)(nO,{icone:E.Z,titulo:t(a?"journeys.hold.metLabel":"journeys.hold.timeoutLabel")}),(0,r.jsxs)(nK,{children:[(0,r.jsx)(nV,{children:(0,r.jsx)("p",{className:"text-xs text-foreground",children:t(a?"journeys.sidebar.holdMetHow":"journeys.sidebar.holdTimeoutHow")})}),!e.modoEdicao&&(0,r.jsx)(t9,{k:t("journeys.canvas.entriesLabel"),v:s&&null!==i?String(i):"â"})]})]})}function n6(e){let{t}=(0,p.$G)(),{split:n,modoEdicao:s,onPassos:o,passos:a,onSelecionar:i,onInserirApos:d}=e;return(0,r.jsxs)("div",{children:[(0,r.jsx)(nO,{icone:T.Z,titulo:t("journeys.split.title"),problemas:eI(e.problemas,[(0,eA.uO)(n.paths)])}),(0,r.jsx)(n$,{titulo:t("journeys.split.pathsTitle"),children:s?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(tY,{split:n,onChange:e=>o(ew(a,n.id,()=>e)),onSelecionarCaminho:e=>i({tipo:"split-caminho",splitId:n.id,caminhoId:e})}),(0,r.jsxs)("div",{className:"space-y-1.5 border-t pt-3",children:[(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.split.addAfter")}),(0,r.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>d(n.id,"wait"),children:[(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})," ",t("journeys.builder.addWait")]}),(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>d(n.id,"action"),children:[(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})," ",t("journeys.builder.addAction")]})]})]})]}):0===n.paths.length?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:t("journeys.split.empty")}):(0,r.jsx)("ul",{className:"space-y-1 text-sm text-foreground",children:n.paths.map(e=>(0,r.jsx)("li",{children:(0,r.jsxs)("button",{type:"button",className:"text-left hover:underline",onClick:()=>i({tipo:"split-caminho",splitId:n.id,caminhoId:e.id}),children:[t("journeys.split.pathLabel",{peso:e.weight}),(0,eA.N_)(e)?" \xb7 ".concat(t("journeys.split.holdout")):""]})},e.id))})}),(0,r.jsxs)(nK,{children:[(0,r.jsxs)(nV,{children:[(0,r.jsx)("p",{className:"text-xs text-foreground",children:t("journeys.split.how")}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.split.howEdit")})]}),(0,r.jsxs)(ne,{titulo:t("journeys.split.howKeyTitle"),children:[(0,r.jsx)(t9,{k:"sha256",v:"".concat(n.id,":<lead_id>")}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:t("journeys.split.howKeyNote")})]})]}),s&&(0,r.jsx)(re,{onClick:()=>rt(e,n.id)})]})}function n7(e){var t;let{t:n}=(0,p.$G)(),{selecao:s,passos:o,modoEdicao:a,onPassos:i,statsProntos:l,stats:d}=e,u=eC(o,s.splitId);if(!u||"split"!==u.kind)return(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:n("journeys.detail.loadError")});let c=u.paths.find(e=>e.id===s.caminhoId);if(!c)return(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:n("journeys.detail.loadError")});let m=(0,t8.xq)(d,s.splitId,s.caminhoId);return(0,r.jsxs)("div",{children:[(0,r.jsx)(nO,{icone:T.Z,titulo:n("journeys.split.pathTitle",{peso:c.weight}),problemas:eI((null!==(t=e.problemas)&&void 0!==t?t:[]).filter(e=>e.stepId===u.id),[(0,eA.uO)(u.paths)])}),(0,eA.N_)(c)&&(0,r.jsx)("p",{className:"mb-3 text-xs text-muted-foreground",children:n("journeys.split.holdoutHint")}),(0,r.jsx)(n$,{titulo:n("journeys.sidebar.configure"),children:a?(0,r.jsx)(t1,{split:u,caminhoId:c.id,onChange:e=>i(ew(o,u.id,()=>e))}):(0,r.jsx)("p",{className:"text-xs text-foreground",children:n("journeys.split.pathLabel",{peso:c.weight})})}),(0,r.jsxs)(nK,{children:[(0,r.jsx)(nV,{children:(0,r.jsx)("p",{className:"text-xs text-foreground",children:n("journeys.split.how")})}),!e.modoEdicao&&(0,r.jsx)(t9,{k:n("journeys.canvas.entriesLabel"),v:l&&null!==m?String(m):"â"})]})]})}function n8(e){var t,n,s,o,a;let{t:i}=(0,p.$G)(),{selecao:l,passos:d,modoEdicao:u,onPassos:c,statsProntos:m,stats:x}=e,h=eC(d,l.branchId);if(!h||"branch"!==h.kind)return(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:i("journeys.detail.loadError")});let j=h.cases.findIndex(e=>e.id===l.caseId),v=l.ehDefault?null:h.cases[j],g=l.ehDefault?i("journeys.canvas.elseLabel"):(null==v?void 0:v.label)||i("journeys.canvas.caseFallback",{n:j+1}),f=(0,t8.xq)(x,h.id,l.caseId),b=null==v?void 0:null===(t=v.condition)||void 0===t?void 0:t.observed,y=null==v?void 0:null===(n=v.condition)||void 0===n?void 0:n.audience;return(0,r.jsxs)("div",{children:[(0,r.jsx)(nO,{icone:eu.Z,titulo:g,problemas:(null!==(o=e.problemas)&&void 0!==o?o:[]).filter(e=>e.stepId===h.id)}),(0,r.jsx)(n$,{titulo:i("journeys.sidebar.configure"),children:l.ehDefault?(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:i("journeys.builder.elseHint")}):v&&u?(0,r.jsx)(n9,{projectId:e.projectId,branch:h,caso:v,onChangeBranch:e=>c(e_(d,h.id,()=>e))}):v?(0,r.jsxs)("div",{className:"space-y-2 text-xs",children:[(null===(s=v.condition)||void 0===s?void 0:s.profile)?(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1 text-muted-foreground",children:i("journeys.builder.profileConditionTitle")}),(0,r.jsx)(tW,{gate:{rule:v.condition.profile}})]}):null,b?(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1 text-muted-foreground",children:i("journeys.builder.observedConditionTitle")}),(0,r.jsx)(tW,{gate:{event_source:b.event_source,rule:b.rule}})]}):null,y?(0,r.jsxs)("div",{children:[(0,r.jsx)("p",{className:"mb-1 text-muted-foreground",children:i("journeys.builder.audienceConditionTitle")}),(0,r.jsxs)("p",{className:"text-foreground",children:[i(y.in?"journeys.sidebar.audie
1nceIn":"journeys.sidebar.audienceNotIn")," \xb7 ",(0,r.jsx)("span",{className:"font-mono text-[11px]",children:y.id})]})]}):null]}):null}),(0,r.jsxs)(nK,{children:[b?(0,r.jsxs)(nV,{children:[(0,r.jsx)(t9,{k:i("journeys.builder.observedConditionTitle"),v:"zero"===b.operator?i("journeys.builder.observedOperatorDidNot"):"⥠".concat(null!==(a=b.count)&&void 0!==a?a:1),mono:!1}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:i("journeys.builder.observedResetNote")}),(0,r.jsxs)(ne,{titulo:i("journeys.sidebar.observerTitle"),children:[(0,r.jsx)(t9,{k:"observer_id",v:(0,ec.yZ)(b.event_source,b.rule)}),(0,r.jsx)(t9,{k:"event_source",v:b.event_source}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:i("journeys.sidebar.observerHashNote")})]})]}):(0,r.jsx)(nV,{children:(0,r.jsx)("p",{className:"text-xs text-foreground",children:i(l.ehDefault?"journeys.builder.elseHint":"journeys.builder.branchHint")})}),y?(0,r.jsxs)(nV,{children:[(0,r.jsx)(t9,{k:i("journeys.builder.audienceConditionTitle"),v:i(y.in?"journeys.sidebar.audienceIn":"journeys.sidebar.audienceNotIn"),mono:!1}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:i("journeys.sidebar.audienceClockNote")}),(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:i("journeys.sidebar.audienceFailNote")}),(0,r.jsx)(ne,{titulo:i("journeys.builder.audienceConditionTitle"),children:(0,r.jsx)(t9,{k:"audience_id",v:y.id||"â"})})]}):null,!u&&(0,r.jsx)(t9,{k:i("journeys.canvas.entriesLabel"),v:m&&null!==f?String(f):"â"})]})]})}function n9(e){var t,n;let{projectId:s,branch:o,caso:a,onChangeBranch:i}=e,l=(0,v.a)({queryKey:["audiences",s,"lista"],queryFn:()=>et.j.listAudiences(s),enabled:!!s,staleTime:6e4}),d=(null!==(n=null===(t=l.data)||void 0===t?void 0:t.results)&&void 0!==n?n:[]).filter(e=>"archived"!==e.status);return(0,r.jsx)(t5,{branch:o,caso:a,onChangeBranch:i,audiencias:d.map(e=>({id:e.id,name:e.name,members:e.members})),audienciasErro:l.isError})}function re(e){let{onClick:t,noRodape:n=!1}=e,{t:s}=(0,p.$G)(),o=(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"gap-1.5 text-red-600 hover:text-red-700 dark:text-red-400",onClick:t,children:[(0,r.jsx)(ei.Z,{className:"h-3.5 w-3.5"})," ",s("journeys.builder.removeStep")]});return n?o:(0,r.jsx)("div",{className:"border-t pt-3",children:o})}function rt(e,t){e.onPassos(eb(e.passos,t)),e.onFechar()}function rn(e){var t,n,s,o,a;let{saida:i,onAbrir:l,selecionado:d}=e,{t:u}=(0,p.$G)(),c=!!i&&(!0===i.editavel?(null!==(a=null===(s=i.eventos)||void 0===s?void 0:s.length)&&void 0!==a?a:0)>0||!!i.filtro:!!(null===(o=i.original)||void 0===o?void 0:o.rule)),m=(null==i?void 0:i.editavel)===!0?null!==(n=i.eventos)&&void 0!==n?n:[]:(null==i?void 0:null===(t=i.original)||void 0===t?void 0:t.event_source)?[i.original.event_source]:[];return(0,r.jsxs)("button",{type:"button",onClick:l,className:(0,F.cn)("flex w-full items-center gap-2.5 border-t bg-muted/30 px-5 py-2 text-left transition-colors","hover:bg-muted/60",d&&"bg-muted/60"),children:[(0,r.jsx)(O.Z,{className:"h-3.5 w-3.5 shrink-0 text-muted-foreground"}),(0,r.jsx)("span",{className:"shrink-0 text-xs font-medium text-muted-foreground",children:u("journeys.exitGate.label")}),(0,r.jsx)("span",{className:"min-w-0 flex-1 truncate text-xs text-muted-foreground",children:c?u("journeys.exitGate.configured",{eventos:m.join(", ")||"â"}):u("journeys.exitGate.empty")})]})}var rr=n(51817),rs=n(49322);function ro(e){let{estado:t,salvoEm:n}=e,{t:s}=(0,p.$G)();if("ocioso"===t)return null;if("salvando"===t)return(0,r.jsxs)("span",{className:"flex items-center gap-1.5 px-2 text-xs text-muted-foreground",children:[(0,r.jsx)(rr.Z,{className:"h-3 w-3 animate-spin"})," ",s("journeys.header.savingNow")]});if("erro"===t)return(0,r.jsxs)("span",{className:"flex items-center gap-1.5 px-2 text-xs text-amber-700 dark:text-amber-400",children:[(0,r.jsx)(rs.Z,{className:"h-3 w-3"})," ",s("journeys.header.saveFailed")]});let o=n?n.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"}):"";return(0,r.jsxs)("span",{className:"flex items-center gap-1.5 px-2 text-xs text-muted-foreground",children:[(0,r.jsx)(el.Z,{className:"h-3 w-3"})," ",s("journeys.header.savedAt",{hora:o})]})}var ra=n(95805);function ri(e){let{nome:t,onNome:n,editavel:s,statusSlot:o,autoSaveSlot:a,acoesSlot:i,voltarHref:u,onHistorico:c,onContatos:m,contatosTotal:x}=e,{t:h}=(0,p.$G)(),j=(0,_.useRouter)();return(0,r.jsxs)("header",{className:"flex h-12 shrink-0 items-center justify-between gap-3 border-b bg-background px-5",children:[(0,r.jsxs)("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[(0,r.jsx)(l.z,{variant:"ghost",size:"icon",className:"h-8 w-8 shrink-0","aria-label":h("journeys.header.back"),onClick:()=>j.push(u),children:(0,r.jsx)(y.Z,{className:"h-4 w-4"})}),s&&n?(0,r.jsx)(d.I,{value:t,onChange:e=>n(e.target.value),placeholder:h("journeys.builder.namePlaceholder"),"aria-label":h("journeys.builder.name"),className:(0,F.cn)("h-8 max-w-sm border-transparent bg-transparent px-2 text-sm font-medium","shadow-none hover:bg-muted/60 focus-visible:bg-background focus-visible:ring-1")}):(0,r.jsx)("h1",{className:"truncate text-sm font-medium text-foreground",children:t}),o]}),(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-1.5",children:[a,m&&(0,r.jsxs)(l.z,{variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-xs",onClick:m,children:[(0,r.jsx)(ra.Z,{className:"h-3.5 w-3.5"}),h("journeys.header.contacts"),"number"==typeof x&&(0,r.jsx)("span",{className:"tabular-nums text-muted-foreground",children:x})]}),c&&(0,r.jsxs)(l.z,{variant:"ghost",size:"sm",className:"h-8 gap-1.5 text-xs",onClick:c,children:[(0,r.jsx)(L.Z,{className:"h-3.5 w-3.5"})," ",h("journeys.header.history")]}),i]})]})}
1let rl=new Set(["case","default","hold_met","hold_timeout","split_path"]);function rd(e){return 0===e.length?260:Math.max(...e.map(ru))}function ru(e){if(!(0,Z.a7)(e))return 260;let t=rc(e);return t.reduce((e,t)=>e+rd(t.steps),0)+40*(t.length-1)}function rc(e){var t,n,r,s,o,a,i,l,d,u,c,m,x;if("split"===e.kind)return(null!==(t=e.paths)&&void 0!==t?t:[]).map((t,n)=>{var r;return{id:(0,eA.$S)(e.id,t,n),kind:"split_path",label:"",ordinal:n+1,steps:null!==(r=null==t?void 0:t.steps)&&void 0!==r?r:[]}});if("hold_until"===e.kind)return[{id:null!==(a=null===(n=e.met)||void 0===n?void 0:n.id)&&void 0!==a?a:"".concat(e.id,":met"),kind:"hold_met",label:"",ordinal:1,steps:null!==(i=null===(r=e.met)||void 0===r?void 0:r.steps)&&void 0!==i?i:[]},{id:null!==(l=null===(s=e.timeout)||void 0===s?void 0:s.id)&&void 0!==l?l:"".concat(e.id,":timeout"),kind:"hold_timeout",label:"",ordinal:2,steps:null!==(d=null===(o=e.timeout)||void 0===o?void 0:o.steps)&&void 0!==d?d:[]}];let p=(null!==(u=e.cases)&&void 0!==u?u:[]).map((e,t)=>{var n,r;return{id:e.id,kind:"case",label:null!==(n=e.label)&&void 0!==n?n:"",ordinal:t+1,steps:null!==(r=e.steps)&&void 0!==r?r:[]}}),h=e.default;return[...p,{id:null!==(c=null==h?void 0:h.id)&&void 0!==c?c:"".concat(e.id,":default"),kind:"default",label:null!==(m=null==h?void 0:h.label)&&void 0!==m?m:"",ordinal:p.length+1,steps:null!==(x=null==h?void 0:h.steps)&&void 0!==x?x:[]}]}function rm(e,t,n,r,s){var o,a;let i=null!==(o=t.w)&&void 0!==o?o:rl.has(t.kind)?200:260,l="fim"===(a=t.kind)?24:"trigger"===a||"exit"===a?72:"branch"===a||"split"===a?56:"case"===a||"default"===a||"hold_met"===a||"hold_timeout"===a||"split_path"===a?32:84,d={...t,w:i,h:l,x:n-i/2,y:r};for(let t of(e.nodes.push(d),s))e.edges.push(function(e,t){let n=t.x+t.w/2,r=t.y;if(e.x===n)return{from:e.id,to:t.id,points:[{x:e.x,y:e.y},{x:n,y:r}]};let s=r-22;return{from:e.id,to:t.id,points:[{x:e.x,y:e.y},{x:e.x,y:s},{x:n,y:s},{x:n,y:r}]}}(t,d));return d}let rx=e=>({id:e.id,x:e.x+e.w/2,y:e.y+e.h});function rp(e){let t={passos:new Map,pills:new Map,branches:new Set},n=(e,r,s)=>{e.forEach((e,o)=>{var a,i,l,d,u,c,m,x,p;if(t.passos.set(e.id,{local:r,indice:o,nivelDeBranch:s}),"hold_until"===e.kind){for(let r of(t.branches.add(e.id),["met","timeout"])){let o=e[r];o&&(t.pills.set(o.id,{local:{tipo:"hold",holdId:e.id,ramo:r},nivelDeBranch:s+1}),n(null!==(l=o.steps)&&void 0!==l?l:[],{tipo:"hold",holdId:e.id,ramo:r},s+1))}return}if("split"===e.kind){for(let[r,o]of(t.branches.add(e.id),(null!==(d=e.paths)&&void 0!==d?d:[]).entries())){let a=(0,eA.$S)(e.id,o,r),i={tipo:"split",splitId:e.id,caminhoId:a};t.pills.set(a,{local:i,nivelDeBranch:s+1}),n(null!==(u=null==o?void 0:o.steps)&&void 0!==u?u:[],i,s+1)}return}if("branch"!==e.kind)return;for(let r of(t.branches.add(e.id),null!==(c=e.cases)&&void 0!==c?c:[]))t.pills.set(r.id,{local:{tipo:"case",branchId:e.id,caseId:r.id},nivelDeBranch:s+1}),n(null!==(m=r.steps)&&void 0!==m?m:[],{tipo:"case",branchId:e.id,caseId:r.id},s+1);let h=null!==(x=null===(a=e.default)||void 0===a?void 0:a.id)&&void 0!==x?x:"".concat(e.id,":default");t.pills.set(h,{local:{tipo:"default",branchId:e.id},nivelDeBranch:s+1}),n(null!==(p=null===(i=e.default)||void 0===i?void 0:i.steps)&&void 0!==p?p:[],{tipo:"default",branchId:e.id},s+1)})};return n(e,{tipo:"root"},0),t}function rh(e){var t;return e?e.editavel?e.spec.origem?"PIXEL"===e.spec.origem?null:e.spec.origem:null:(null===(t=e.original)||void 0===t?void 0:t.event_source)==="hotmart"?"HOTMART":null:null}function rj(e,t){var n,r,s;if(!e)return null;if("hotmart"===e.event_source)return"HOTMART";let o=null===(r=e.rule)||void 0===r?void 0:null===(n=r.conditions)||void 0===n?void 0:n[0];if((null==o?void 0:o.field)!=="event_type")return null;let a=(Array.isArray(o.value)?o.value:[o.value]).map(String);if(0===a.length)return null;let i=(0,Z.K_)(a);if(i)return i;let l=new Set(a.map(e=>null==t?void 0:t(e)));return 1!==l.size?null:null!==(s=[...l][0])&&void 0!==s?s:null}let rv={entrada:"positive",acao:"positive",passo:"muted",saida:"muted",entrada_barrada:"warning",erro:"negative"},rg={positive:"border-emerald-200 bg-emerald-50 text-emerald-700 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-300",warning:"border-amber-200 bg-amber-50 text-amber-700 dark:border-amber-900 dark:bg-amber-950 dar
1k:text-amber-300",negative:"border-red-200 bg-red-50 text-red-700 dark:border-red-900 dark:bg-red-950 dark:text-red-300",muted:"border-border bg-muted text-muted-foreground"};function rf(e){var t,n,s,o;let{projectId:a,journeyId:l}=e,{t:u}=(0,p.$G)(),[m,x]=(0,C.useState)(""),[h,j]=(0,C.useState)([]),v=(0,nC.en)(a,l,{lead:m.trim()||void 0,decisao:h}),g=e=>j(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e]),f=null!==(n=null===(t=v.data)||void 0===t?void 0:t.results)&&void 0!==n?n:[],b=null!==(o=null==(s=v.data)?void 0:s.decisoes)&&void 0!==o?o:[];return(0,r.jsxs)("div",{className:"space-y-3",children:[(0,r.jsx)("p",{className:"text-xs text-muted-foreground",children:u("journeys.trail.help")}),(0,r.jsx)(d.I,{value:m,onChange:e=>x(e.target.value),placeholder:u("journeys.trail.leadPlaceholder"),className:"h-8 text-xs"}),b.length>0&&(0,r.jsx)("div",{className:"flex flex-wrap gap-1.5",children:b.map(e=>(0,r.jsx)("button",{type:"button",onClick:()=>g(e),className:(0,F.cn)("rounded-full border px-2 py-0.5 font-mono text-[10px] transition-colors",h.includes(e)?"border-primary bg-primary/10 text-foreground":"text-muted-foreground hover:border-foreground
1/20"),children:e},e))}),v.isLoading?(0,r.jsx)(c.O,{className:"h-24 w-full"}):v.isError?(0,r.jsx)("p",{className:"py-3 text-xs text-muted-foreground",children:u("journeys.trail.error")}):v.data&&!v.data.available?(0,r.jsx)("p",{className:"py-3 text-xs text-amber-700 dark:text-amber-300",children:u("journeys.trail.unavailable")}):0===f.length?(0,r.jsx)("p",{className:"py-3 text-xs text-muted-foreground",children:u("journeys.trail.empty")}):(0,r.jsx)("ul",{className:"divide-y divide-border rounded-md border border-border",children:f.map((e,t)=>{var n;let s=function(e){if(!e||"object"!=typeof e)return"";let t=[];for(let[n,r]of Object.entries(e))if(null!=r){if(Array.isArray(r)){t.push("".concat(n,": ").concat(r.length));continue}if("object"==typeof r){t.push("".concat(n,": ").concat(Object.keys(r).length));continue}t.push("".concat(n,": ").concat(String(r)))}return t.join(" \xb7 ")}(e.detalhe);return(0,r.jsxs)("li",{className:"space-y-1 p-2.5",children:[(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(i.C,{variant:"outline",className:(0,F.cn)("font-mono text-[10px]",rg[null!==(n=rv[e.decisao])&&void 0!==n?n:"muted"]),children:e.decisao}),e.motivo&&(0,r.jsx)("span",{className:"font-mono text-[11px] text-foreground",children:e.motivo}),(0,r.jsx)("span",{className:"ml-auto shrink-0 text-[10px] tabular-nums text-muted-foreground",children:function(e){if(!e)return"";let t=e.includes("T")?e:e.replace(" ","T"),n=new Date(t.endsWith("Z")?t:"".concat(t,"Z"));return Number.isNaN(n.getTime())?e:n.toLocaleString()}(e.decided_at)})]}),s&&(0,r.jsx)("p",{className:"text-[11px] text-muted-foreground",children:s}),e.lead_id&&(0,r.jsxs)("p",{className:"truncate font-mono text-[10px] text-muted-foreground/70",title:e.lead_id,children:[u("journeys.trail.leadLabel")," ",e.lead_id]})]},"".concat(e.decided_at,"-").concat(t))})})]})}var rb=n(72123),ry=n(65600);class rN extends Error{constructor(e){super(e instanceof Error?e.message:"salvar falhou")}}function rk(e){var t;let{projectId:n,projectSlug:s,modo:o,journeyId:a}=e,{t:i}=(0,p.$G)(),l=(0,nC.cn)(n,null!=a?a:""),d=(0,ry.p)({pageSize:200}),u=d.sources,m=(0,es.Dd)(n);return a&&l.isLoading||d.isLoading||m.carregando?(0,r.jsxs)("div",{className:"space-y-4 p-6",children:[(0,r.jsx)(c.O,{className:"h-8 w-64"}),(0,r.jsx)(c.O,{className:"h-[480px] w-full"})]}):a&&(l.isError||!l.data)?(0,r.jsx)("div",{className:"p-6 text-sm text-muted-foreground",children:i("journeys.detail.loadError")}):(0,r.jsx)(f.tV,{children:(0,r.jsx)(rw,{projectId:n,projectSlug:s,modo:o,journeyId:a,inicial:a&&null!==(t=l.data)&&void 0!==t?t:void 0,sources:u,medidos:m.eventos})})}function rw(e){var t,n,s,c,N,k,w,S,I,z,E,T;let{projectId:L,projectSlug:P,modo:D,journeyId:G,inicial:R,sources:O,medidos:$}=e,{t:B}=(0,p.$G)(),F=(0,_.useRouter)(),H=(0,j.NL)(),q="ver"!==D,[K,V]=(0,C.useState)(!!(null==R?void 0:R.published_revision_id)),W=(0,C.useMemo)(()=>R?(0,t8.dW)(R):null,[R]),[U,J]=(0,C.useState)(()=>null==W?void 0:W.entry);(0,C.useEffect)(()=>{J(null==W?void 0:W.entry)},[W]);let[X,Y]=(0,C.useState)(null!==(s=null==R?void 0:R.name)&&void 0!==s?s:""),[ee,et]=(0,C.useState)(null!==(c=null==R?void 0:R.description)&&void 0!==c?c:""),er=(0,C.useCallback)(e=>(0,Z.Xc)([e],$),[$]),[es,eo]=(0,C.useState)(()=>{let e=W?(0,Z.NS)(W):[];if(0===e.length)return[ep];let t=e=>{var t;return null===(t=O.find(t=>t.id===e))||void 0===t?void 0:t.origin};return e.map(e=>{let n=ej(e,t,er);if(!n.editavel)return n;let r=function(e,t){let{origem:n}=e;if(!n||"PIXEL"===n||n===en.eu||e.sourceIds.length>0)return null;let r=t.filter(e=>e.origin===n).map(e=>e.id);return r.length>0?r:null}(n.spec,O);return r?{...n,spec:{...n.spec,sourceIds:r}}:n})}),[ea,ei]=(0,C.useState)(()=>(function(e){if(!e)return em;let t=(0,Z.uX)(e);return t?{editavel:!0,origem:t.origem,eventos:t.eventos,filtro:t.filtro}:{editavel:!1,original:e}})(null==W?void 0:W.exit)),[el,ed]=(0,C.useState)(()=>{var e;return null!==(e=null==W?void 0:W.steps)&&void 0!==e?e:[]}),[eu,eg]=(0,C.useState)(null),[ef,eb]=(0,C.useState)(null),[ey,eN]=(0,C.useState)(!1),[eS,eI]=(0,C.useState)(!1),[ez,eE]=(0,C.useState)(!1),[eT,eL]=(0,C.useState)(null!=G?G:null),eP=(0,nC.J4)(L,K&&null!=G?G:""),eZ=(0,v.a)({queryKey:["actions","destinations",L],queryFn:()=>x.d.listDestinations(L),enabled:!!L,staleTime:6e4}),eD=(0,C.useMemo)(()=>{var e,t;let n=new Map;for(let r of null!==(t=null===(e=eZ.data)||void 0===e?void 0:e.data)&&void 0!==t?t:[])n.set(r.id,r);return n},[eZ.data]),eM=(0,C.useMemo)(()=>{let e=es.map(ev),t=ex(ea);return!t||e.some(e=>null===e)?null:(0,Z.tQ)(e,t,el,U)},[es,ea,el,U]),eG=(0,C.useMemo)(()=>{var e;let t={event_source:"hotmart",rule:{type:"and",conditions:[]}},n=es.map(e=>{var n;return null!==(n=ev(e))&&void 0!==n?n:t}),r=null!==(e=ex(ea))&&void 0!==e?e:t;return(0,Z.tQ)(n,r,el,U)},[es,ea,el,U]),eR=(0,C.useMemo)(()=>(0,Z.pZ)(eG),[eG]),eO=(0,Z.wv)(el).some(Z.re),e$=!!eM&&(null==eR?void 0:eR.length)===0&&!eO&&X.trim().length>
10,eB=(0,t8.bH)({problemas:eR,conteudoIncompleto:eO,nomeVazio:0===X.trim().length}),eF=(0,t8.PT)({definitionLegivel:!K||!!W,statsErro:eP.isError,statsChegaram:null!=eP.data,jaPublicada:!!(null==R?void 0:R.published_revision_id)||"criar"===D}),eH=K&&"com_stats"===eF,eq=(e,t)=>{let n="wait"===t?(0,Z.Ws)(30):"action"===t?(0,Z.d$)("email"):"hold"===t?(0,Z.QE)():"split"===t?(0,Z.f3)():(0,Z.Mp)();ed(t=>(function(e,t,n){let{local:r,indice:s}=t,o=e=>{let t=Math.max(0,Math.min(s,e.length));return[...e.slice(0,t),n,...e.slice(t)]};return"root"===r.tipo?o(e):"hold"===r.tipo?ek(e,"hold_until",r.holdId,e=>{var t;let n=e[r.ramo];return{...e,[r.ramo]:{...n,steps:o(null!==(t=null==n?void 0:n.steps)&&void 0!==t?t:[])}}},(e,t)=>{var n,r,s,o,a,i;return{...t,met:{...t.met,id:null!==(a=null===(n=e.met)||void 0===n?void 0:n.id)&&void 0!==a?a:null===(r=t.met)||void 0===r?void 0:r.id},timeout:{...t.timeout,id:null!==(i=null===(s=e.timeout)||void 0===s?void 0:s.id)&&void 0!==i?i:null===(o=t.timeout)||void 0===o?void 0:o.id}}}):"split"===r.tipo?ew(e,r.splitId,e=>e.paths.some(e=>e.id===r.caminhoId)?{...e,paths:e.paths.map(e=>{var t;return e.id===r.caminhoId?{...e,steps:o(null!==(t=e.steps)&&void 0!==t?t:[])}:e})}:e):e_(e,r.branchId,e=>{if("default"===r.tipo){var t,n;return{...e,default:{...e.default,steps:o(null!==(n=null===(t=e.default)||void 0===t?void 0:t.steps)&&void 0!==n?n:[])}}}return e.cases.some(e=>e.id===r.caseId)?{...e,cases:e.cases.map(e=>{var t;return e.id===r.caseId?{...e,steps:o(null!==(t=e.steps)&&void 0!==t?t:[])}:e})}:e})})(t,e,n)),eg({tipo:"passo",id:n.id})},eK=(0,C.useMemo)(()=>(function(e){var t;let n=function(e){var t;let n={nodes:[],edges:[]},r=null!==(t=e.steps)&&void 0!==t?t:[],s=Math.max(260,rd(r)),o=24+s/2,a=rm(n,{id:"trigger",kind:"trigger"},o,24,[]),i=function e(t,n,r,s,o){let a=o,i=s;for(let s of n){if((0,Z.a7)(s)){let n=function(t,n,r,s,o){let a=rm(t,{id:n.id,kind:n.kind,step:n},r,s,o),i=rx(a),l=rc(n),d=l.map(e=>rd(e.steps)),u=r-(d.reduce((e,t)=>e+t,0)+40*(l.length-1))/2,c=a.y+a.h+44,m=[],x=c;return l.forEach((r,s)=>{let o=u+d[s]/2,a=rm(t,{id:r.id,kind:r.kind,label:r.label,ordinal:r.ordinal,branchId:n.id},o,c,[i]),l=e(t,r.steps,o,a.y+a.h+44,[rx(a)]);m.push(...l.saidas),x=Math.max(x,l.y),u+=d[s]+40}),{saidas:m,y:x}}(t,s,r,i,a);a=n.saidas,i=n.y;continue}let n=rm(t,{id:s.id,kind:s.kind,step:s},r,i,a);a=[rx(n)],i=n.y+n.h+44}return{saidas:a,y:i}}(n,r,o,a.y+a.h+44,[rx(a)]),l=rm(n,{id:"fim",kind:"fim"},o,i.y+36,i.saidas);return{nodes:n.nodes,edges:n.edges,width:s+48,height:l.y+l.h+24}}(e),r=rp(null!==(t=e.steps)&&void 0!==t?t:[]),s=n.nodes.map(e=>({id:e.id,kind:e.kind,position:{x:e.x,y:e.y},largura:e.w,altura:e.h,step:e.step,label:e.label,ordinal:e.ordinal,branchId:e.branchId}
1)),o=n.edges.map(e=>({id:"".concat(e.from,"->").concat(e.to),source:e.from,target:e.to,insercao:function(e,t){if("trigger"===e)return{local:{tipo:"root"},indice:0,nivelDeBranch:0};if(t.branches.has(e))return null;let n=t.pills.get(e);if(n)return{local:n.local,indice:0,nivelDeBranch:n.nivelDeBranch};let r=t.passos.get(e);return r?{local:r.local,indice:r.indice+1,nivelDeBranch:r.nivelDeBranch}:null}(e.from,r)})),a=(0,Z.NS)(e).length;if(a>1){let e=s.find(e=>"trigger"===e.id);if(e){let t=e.position.x+e.largura/2-(260*a+(a-1)*40)/2,n=Array.from({length:a},(n,r)=>({id:(0,Z.pO)(r),kind:"trigger",position:{x:t+300*r,y:e.position.y},largura:260,altura:e.altura}));s=[...n,...s.filter(e=>"trigger"!==e.id)];let r=o.filter(e=>"trigger"===e.source),i=o.filter(e=>"trigger"!==e.source);o=[...n.flatMap(e=>r.map(t=>({id:"".concat(e.id,"->").concat(t.target),source:e.id,target:t.target,insercao:t.insercao}))),...i]}}return{nodes:s,edges:o,width:n.width,height:n.height}})(eG),[eG]),eV=(0,C.useMemo)(()=>(function(e){let t=new Set;for(let n of e){if(n.stepId){t.add(n.stepId);continue}n.key.startsWith("journeys.validation.trigger")?t.add("trigger"):n.key.startsWith("journeys.validation.exit")&&t.add("exit")}return t})(null!=eR?eR:[]),[eR]),eW=(0,C.useMemo)(()=>{var e;return(0,t8.ot)(null!==(e=eP.data)&&void 0!==e?e:null)},[eP.data]),eQ=(0,C.useMemo)(()=>{if(!eK)return[];let e=e=>{if(!K)return;let t=a(o(eW.get(e)));return t?B(t.key,t.params):void 0},t=e=>eH?String(null!=e?e:0):"â";return eK.nodes.map(n=>{var r,s,o,a,i,l,d,u,c,m,x,p,h,j,v,g,f,b,y,N,k,w,_,C,A;let S;if("fim"===n.kind)S={rotulo:B("journeys.flow.journeyEnds")};else if("hold_met"===n.kind||"hold_timeout"===n.kind){let e=n.branchId?(0,t8.xq)(null!==(r=eP.data)&&void 0!==r?r:null,n.branchId,n.id):null;S={rotulo:"hold_met"===n.kind?B("journeys.hold.metLabel"):B("journeys.hold.timeoutLabel"),numero:eH&&null!==e?String(e):"â",tituloDoNumero:B("journeys.canvas.entriesLabel"),ehDefault:"hold_timeout"===n.kind}}else if("split_path"===n.kind){let e=n.branchId?eC(el,n.branchId):null,t=null==e?void 0:null===(s=e.paths)||void 0===s?void 0:s.find(e=>e.id===n.id),r=n.branchId?(0,t8.xq)(null!==(o=eP.data)&&void 0!==o?o:null,n.branchId,n.id):null;S={rotulo:B("journeys.split.pathLabel",{peso:null!==(a=null==t?void 0:t.weight)&&void 0!==a?a:0}),numero:eH&&null!==r?String(r):"â",tituloDoNumero:B("journeys.canvas.entriesLabel"),holdout:(0,eA.N_)(t)}}else if("case"===n.kind||"default"===n.kind){let e="default"===n.kind?n.label||B("journeys.canvas.elseLabel"):n.label||B("journeys.canvas.caseFallback",{n:null!==(i=n.ordinal)&&void 0!==i?i:0}),t=n.branchId?(0,t8.xq)(null!==(l=eP.data)&&void 0!==l?l:null,n.branchId,n.id):null;S={rotulo:e,numero:eH&&null!==t?String(t):"â",tituloDoNumero:B("journeys.canvas.entriesLabel"),ehDefault:"default"===n.kind}}else if("trigger"===n.kind||"exit"===n.kind){let e="exit"===n.kind?eG.exit:(0,Z.NS)(eG)[rI(n.id)],t=null==e?void 0:null===(u=e.rule)||void 0===u?void 0:null===(d=u.conditions)||void 0===d?void 0:d[0],r=t&&"value"in t?Array.isArray(t.value)?t.value.join(", "):String(null!==(c=t.value)&&void 0!==c?c:""):"";S={rotulo:"trigger"===n.kind&&eh(es[rI(n.id)])?B("journeys.flow.emptyTrigger"):"trigger"===n.kind?B("journeys.detail.trigger"):B("journeys.detail.exit"),titulo:r||"â",badge:"trigger"===n.kind?rC(es[rI(n.id)],O):r_(rj(e,er),O),origem:"trigger"===n.kind&&null!==(m=rh(es[rI(n.id)]))&&void 0!==m?m:void 0,numeros:K&&"trigger"===n.kind?(()=>{let e=function(e,t){let n=null==e?void 0:e.entradas_por_gatilho;if(!Array.isArray(n))return null;let r=n[t];return"number"==typeof r?r:null}(eP.data,rI(n.id));return null===e?void 0:"".concat(e," ").concat(B("journeys.canvas.entriesLabel"))})():void 0,erro:eV.has(n.id)}}else if("wait"===n.kind){let r=(0,t8.Mg)(n.step.minutes);S={rotulo:B("journeys.detail.wait"),titulo:B(r.key,r.params),numeros:K?"".concat(t(null===(x=eW.get(n.id))||void 0===x?void 0:x.executados)," ").concat(B("journeys.detail.executed")):void 0,badge:null!==(p=function(e){var t;if(!e)return null;let n=(null===(t=e.days)||void 0===t?void 0:t.length)?"".concat(e.days.length,"d \xb7 "):"";return"".concat(n).concat(e.from,"â").concat(e.to)}(n.step.window))&&void 0!==p?p:void 0,desde:e(n.id),erro:eV.has(n.id)}}else if("action"===n.kind){let r=n.step,s=eD.get(r.destination_id),o=(0,t8.fx)(r.channel),a=eW.get(n.id),i=(0,t8.Kk)(a),l=(0,t8.p6)(a);S={rotulo:B("journeys.detail.action"),titulo:(o?B(o):r.channel)+(s?" \xb7 ".concat(s.name):"")+("email"!==r.channel||(0,Z.re)(n.step)?"":" \xb7 ".concat(B(rA[(0,tC.q6)(n.step.content)]))),numeros:K?"".concat(t(null==a?void 0:a.executados)," ").concat(B("journeys.detail.executed")," \xb7 ").concat(eH&&null!==i?String(i):"â"," ").concat(B("journeys.detail.delivered")):void 0,desde:e(n.id),mortos:K&&eH&&(null!=l?l:0)>0?"".concat(l," ").concat(B("journeys.detail.dead")):void 0,destinoTipo:null!==(h=(_=r.destination_id)&&null!==(A=null===(C=eD.get(_))||void 0===C?void 0:C.type)&&void 0!==A?A:null)&&void 0!==h?h:void 0,avisoDestino:(0,t8.h0)(s),erro:eV.has(n.id)||(0,Z.re)(n.step)}}else if("set_attribute"===n.kind){let r=n.step;S={rotulo:B("journeysAcao.no.atributo"),titulo:"custom.".concat(r.key," = ").concat(Array.isArray(r.value)?r.value.join(", "):String(r.value)),numeros:K?"".concat(t(null===(j=eW.get(n.id))||void 0===j?void 0:j.executados)," ").concat(B("journeys.detail.executed")):void 0,desde:e(n.id),erro:eV.has(n.id)||(0,Z.re)(r)}}else if("hold_until"===n.kind){let t=n.step,r=null===(f=t.event)||void 0===f?void 0:null===(g=f.rule)||void 0===g?void 0:null===(v=g.conditions)||void 0===v?void 0:v[0],s=r&&"value"in r?Array.isArray(r.value)?r.value.join(", "):String(null!==(b=r.value)&&void 0!==b?b:""):"",o=(0,t8.Mg)(null!==(y=t.timeout_minutes)&&void 0!==y?y:0);S={rotulo:B("journeys.hold.title"),titulo:s||"â",badge:r_(rj(t.event,er),O),numeros:B("journeys.hold.capNote",{duracao:B(o.key,o.params)}),desde:e(n.id),erro:eV.has(n.id)}}else if("split"===n.kind){let e=n.step;S={rotulo:B("journeys.split.title"),titulo:(null!==(N=e.paths)&&void 0!==N?N:[]).map(e=>{var t;return B("journeys.split.pathLabel",{peso:null!==(t=null==e?void 0:e.weight)&&void 0!==t?t:0})}).join(" \xb7 "),erro:eV.has(n.id)}}else{let e=n.step;S={rotulo:B("journeys.canvas.branchTitle"),titulo:B("journeys.canvas.branchPaths",{n:(null!==(w=null==e?void 0:null===(k=e.cases)||void 0===k?void 0:k.length)&&void 0!==w?w:0)+1}),erro:eV.has(n.id)}}return{id:n.id,type:rS(n,eh(es[rI(n.id)])),position:n.position,data:S,draggable:!1,
1connectable:!1,style:{width:n.largura}}})},[eK,eG,eV,eW,eP.data,eH,eD,D,B,el,es,O]),eU=(0,C.useMemo)(()=>eK?eK.edges.map(e=>({id:e.id,source:e.source,target:e.target,type:"jornada",data:{insercao:e.insercao,podeInserir:q,onInserir:eq}})):[],[eK,q,el]),eJ=e=>{if("trigger"===e||e.startsWith("trigger:")){eg({tipo:"trigger",indice:rI(e)});return}if("exit"===e){eg({tipo:"gate",qual:"exit"});return}let t=null==eK?void 0:eK.nodes.find(t=>t.id===e);if(t&&"fim"!==t.kind){if("case"===t.kind||"default"===t.kind){if(!t.branchId)return;eg({tipo:"case",branchId:t.branchId,caseId:t.id,ehDefault:"default"===t.kind});return}if("split_path"===t.kind){if(!t.branchId)return;eg({tipo:"split-caminho",splitId:t.branchId,caminhoId:t.id});return}if("hold_met"===t.kind||"hold_timeout"===t.kind){if(!t.branchId)return;eg({tipo:"hold-ramo",holdId:t.branchId,ramoId:t.id,ramo:"hold_met"===t.kind?"met":"timeout"});return}eg({tipo:"passo",id:e})}},eX=()=>H.invalidateQueries({queryKey:["journeys",L]}),eY=(0,g.D)({mutationFn:async()=>{if(!eM)throw Error(B("journeys.builder.saveError"));let e=null!=G?G:eT;if(e)return await h.l.updateJourney(L,e,{name:X.trim(),description:ee||void 0,definition:eM}),e;let t=await h.l.createJourney(L,{name:X.trim(),description:ee||void 0,definition:eM});return eL(t.id),t.id},onSuccess:()=>eX(),onError:e=>A.Am.error(e instanceof Error?e.message:B("journeys.builder.saveError"))}),e0=async()=>{try{let e=await eY.mutateAsync();A.Am.success(B("journeys.builder.saved")),G||F.replace("/projects/".concat(P,"/journeys/").concat(e,"/edit"))}catch(e){}},e1=(0,g.D)({mutationFn:async()=>{let e;try{e=await eY.mutateAsync()}catch(e){throw new rN(e)}let t=await h.l.previewPublish(L,e);return{id:e,p:t}},onSuccess:e=>{let{id:t,p:n}=e;eL(t),eb(n),eN(!1),eI(!0)},onError:e=>{e instanceof rN||(eb(null),eN(!0),eI(!0))}}),e5=(0,g.D)({mutationFn:async()=>{let e=null!=G?G:eT;if(!e)throw Error(B("journeys.builder.publishNeedsPreview"));return await h.l.publishJourney(L,e),e},onSuccess:e=>{eX(),A.Am.success(B("journeys.builder.published")),F.push("/projects/".concat(P,"/journeys/").concat(e))},onError:e=>A.Am.error(e instanceof Error?e.message:B("journeys.builder.publishError"))}),e2=q&&X.trim().length>0&&!!eM&&(!R||"draft"===R.status),e3=function(e){let{payload:t,salvar:n,ativo:r,atrasoMs:s=1200}=e,[o,a]=(0,C.useState)("ocioso"),[i,l]=(0,C.useState)(null),d=(0,C.useRef)(null),u=(0,C.useRef)(!1),c=(0,C.useRef)(null),m=(0,C.useRef)(n);m.current=n;let x=(0,C.useCallback)(async e=>{let t=JSON.stringify(e);if(t!==d.current){if(u.current){c.current=e;return}u.current=!0,a("salvando");try{await m.current(e),d.current=t,l(new Date),a("salvo")}catch(e){a("erro")}finally{u.current=!1;let e=c.current;c.current=null,e&&x(e)}}},[]);return(0,C.useEffect)(()=>{if(!r||null===t)return;let e=setTimeout(()=>void x(t),s);return()=>clearTimeout(e)},[r,t,s,x]),{estado:o,salvoEm:i,agora:(0,C.useCallback)(async()=>{null!==t&&await x(t)},[t,x])}}({payload:e2?{nome:X,descricao:ee,definition:eM}:null,salvar:async()=>{await eY.mutateAsync()},ativo:e2}),e4=e=>{let t=(0,Z.wv)(el).findIndex(t=>t.id===e);return -1===t?e:"#".concat(t+1)},e6=0===el.length&&es.every(e=>eh(e)),e7=null!==(N=null==R?void 0:null===(t=R.published_revision)||void 0===t?void 0:t.definition_json)&&void 0!==N?N:null,e8=!!(null==R?void 0:R.published_revision_id)&&!!eM&&!!e7&&(0,ec.L2)(eM)!==(0,ec.L2)(e7),e9="/projects/".concat(P,"/journeys"),te=q?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-8 text-xs",onClick:()=>F.push(e9),children:B("journeys.builder.cancel")}),(0,r.jsx)(l.z,{variant:"outline",size:"sm",className:"h-8 text-xs",disabled:eY.isPending||!eM||0===X.trim().length,onClick:()=>void e0(),children:B("journeys.builder.save")}),(0,r.jsx)(l.z,{size:"sm",className:"h-8 text-xs",disabled:!e$||e1.isPending,title:e$?void 0:eB?B(eB.key,eB.params):B("journeys.builder.publishNeedsPreview"),onClick:()=>e1.mutate(),children:e1.isPending?B("journeys.builder.publishPreviewLoading"):B("journeys.builder.publish")})]}):null;return(0,r.jsxs)("div",{className:"absolute inset-0 z-[60] flex flex-col bg-background",children:[(0,r.jsx)(ri,{nome:q?X:null!==(k=null==R?void 0:R.name)&&void 0!==k?k:X,onNome:q?Y:void 0,editavel:q,voltarHref:e9,statusSlot:R?(0,r.jsxs)("div",{className:"flex items-center gap-2",children:[(0,r.jsx)(rb.JourneyStatusBadge,{status:R.status}),G&&("active"===R.status||"paused"===R.status)&&(0,r.jsx)(rz,{projectId:L,journeyId:G,status:R.status})]}):(0,r.jsx)(i.C,{variant:"outline",className:"text-[10px]",children:B("journeys.status.draft")}),autoSaveSlot:(0,r.jsxs)("div",{className:"flex items-center gap-2.5",children:[e8&&(0,r.jsx)("span",{className:"rounded-full bg-amber-100 px-2 py-0.5 text-[10px] font-medium text-amber-800 dark:bg-amber-950 dar
1k:text-amber-300",children:B("journeys.header.unpublished")}),(null==R?void 0:R.published_revision_id)&&(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-1.5 text-[11px] text-muted-foreground",children:[(0,r.jsx)(m.r,{checked:K,onCheckedChange:V,className:"scale-75"}),B("journeys.header.monitoring")]}),q&&(0,r.jsx)(ro,{estado:e3.estado,salvoEm:e3.salvoEm})]}),acoesSlot:null!=te?te:void 0,onHistorico:K&&G?()=>eE(!0):void 0}),q&&(0,r.jsxs)("div",{className:"flex shrink-0 items-center gap-2 border-b bg-muted/20 px-5 py-1.5",children:[(0,r.jsx)(u._,{htmlFor:"journey-desc",className:"text-[11px] text-muted-foreground",children:B("journeys.builder.descriptionLabel")}),(0,r.jsx)(d.I,{id:"journey-desc",value:null!=ee?ee:"",onChange:e=>et(e.target.value),className:"h-7 max-w-xl border-transparent bg-transparent px-2 text-xs shadow-none hover:bg-background focus-visible:bg-background focus-visible:ring-1"})]}),K&&"definition_ilegivel"===eF&&(0,r.jsx)("div",{className:"shrink-0 border-b px-5 py-2 text-sm text-muted-foreground",children:B("journeys.detail.definitionUnreadable")}),K&&"stats_erro"===eF&&(0,r.jsx)("div",{className:"shrink-0 border-b border-amber-200 bg-amber-50 px-5 py-2 text-xs text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300",children:B("journeys.detail.statsError")}),q&&!1===e6&&(eR&&eR.length>0||eO)&&(0,r.jsxs)("div",{className:"shrink-0 space-y-1 border-b border-amber-200 bg-amber-50 px-5 py-2 text-xs text-amber-800 dark:border-amber-900 dark:bg-amber-950 dark:text-amber-300",children:[(function(e){let t=new Set;return e.filter(e=>!t.has(e.key)&&(t.add(e.key),!0))})(null!=eR?eR:[]).map((e,t)=>(0,r.jsx)("p",{children:B(e.key,e.params)},t)),eO&&(0,r.jsx)("p",{children:B("journeys.validation.contentRequired")})]}),(0,r.jsx)("div",{className:"relative min-h-0 flex-1 bg-muted/30",children:(0,r.jsxs)(f.x$,{nodes:eQ,edges:eU,nodeTypes:Q,edgeTypes:M,onNodeClick:(e,t)=>eJ(t.id),fitView:!0,fitViewOptions:{padding:.2,maxZoom:1},nodesDraggable:!1,nodesConnectable:!1,panOnScroll:!0,zoomOnDoubleClick:!1,minZoom:.25,maxZoom:1.5,proOptions:{hideAttribution:!0},style:{background:"transparent"},children:[(0,r.jsx)(rE,{chave:"".concat(eK.nodes.length,":").concat(eK.width,"x").concat(eK.height)}),(0,r.jsx)(f.Aq,{variant:f.T7.Dots,gap:18,size:1,color:"hsl(var(--muted-foreground) / 0.25)",style:{background:"transparent"}}),(0,r.jsx)(rT,{}),q&&(0,r.jsx)(f.s_,{position:"top-right",children:(0,r.jsxs)(l.z,{variant:"outline",size:"sm",className:"h-7 gap-1 bg-background text-xs shadow-sm",disabled:es.length>=Z.LV,onClick:()=>{eo(e=>[...e,ep]),eg({tipo:"trigger",indice:es.length})},children:[(0,r.jsx)(b.Z,{className:"h-3 w-3"})," ",B("journeys.flow.addTrigger")]})}),K&&(0,r.jsx)(f.s_,{position:"top-right",children:(0,r.jsx)("span",{className:"rounded-md border bg-background/90 px-2 py-1 text-[11px] text-muted-foreground shadow-sm",children:B("journeys.canvas.countersLegend",{label:B("journeys.canvas.entriesLabel")})})})]})}),(0,r.jsx)(rn,{saida:ea,onAbrir:()=>eg({tipo:"gate",qual:"exit"}),selecionado:(null==eu?void 0:eu.tipo)==="gate"}),q&&(0,r.jsx)("p",{className:"shrink-0 border-t bg-muted/20 px-5 py-1.5 text-[11px] text-muted-foreground",children:B(t8.C5)}),(0,r.jsx)(nG,{medidos:$,projectId:L,projectSlug:P,journeyId:K?G:void 0,journeyName:X,selecao:eu,onFechar:()=>eg(null),onSelecionar:eg,modoEdicao:q,passos:el,gatilhos:es,saida:ea,onTrocarGatilho:(e,t)=>eo(n=>n.map((n,r)=>r===e?t:n)),onRemoverGatilho:e=>{eo(t=>t.length>1?t.filter((t,n)=>n!==e):t),eg(null)},onTrocarSaida:ei,entrada:U,onTrocarEntrada:J,onPassos:ed,onInserirApos:(e,t)=>{let n=function(e,t){let n=rp(e).passos.get(t);return n?{local:n.local,indice:n.indice+1,nivelDeBranch:n.nivelDeBranch}:null}(el,e);n&&eq(n,t)},destinos:null!==(w=null===(n=eZ.data)||void 0===n?void 0:n.data)&&void 0!==w?w:[],sources:O,problemas:eR,stats:null!==(S=eP.data)&&void 0!==S?S:null,statsProntos:eH,destinoPorId:eD}),K&&G&&ez&&(0,r.jsx)("div",{className:"fixed inset-0 z-[70] flex justify-end bg-black/30",onClick:()=>eE(!1),children:(0,r.jsxs)("div",{className:"h-full w-full max-w-xl overflow-auto border-l bg-background p-5",onClick:e=>e.stopPropagation(),children:[(0,r.jsxs)("div",{className:"mb-3 flex items-center justify-between",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-foreground",children:B("journeys.header.history")}),(0,r.jsx)(l.z,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>eE(!1),children:(0,r.jsx)(y.Z,{className:"h-4 w-4"})})]}),(0,r.jsxs)(tk.mQ,{defaultValue:"pessoas",children:[(0,r.jsxs)(tk.dr,{className:"mb-3",children:[(0,r.jsx)(tk.SP,{value:"pessoas",className:"text-xs",children:B("journeys.detail.instances")}),(0,r.jsx)(tk.SP,{value:"trilha",className:"text-xs",children:B("journeys.trail.title")})]}),(0,r.jsxs)(tk.nU,{value:"pessoas",children:[(0,r.jsx)("p",{className:"mb-3 text-[11px] text-muted-foreground",children:B("journeys.detail.exitPhrase")}),(0,r.jsx)(rL,{projectId:L,projectSlug:P,journeyId:G,definitionSteps:null!==(I=null==W?void 0:W.steps)&&void 0!==I?I:[]})]}),(0,r.jsx)(tk.nU,{value:"trilha",children:(0,r.jsx)(rf,{projectId:L,journeyId:G})})]})]})}),eS&&(0,r.jsx)("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",children:(0,r.jsxs)("div",{className:"w-full max-w-md
1space-y-3 rounded-lg border bg-background p-5 shadow-lg",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-foreground",children:B("journeys.builder.publishPreviewTitle")}),ey?(0,r.jsx)("p",{className:"text-sm text-red-600 dark:text-red-400",children:B("journeys.builder.publishPreviewError")}):(0,r.jsxs)("div",{className:"space-y-2 text-sm text-muted-foreground",children:[(0,r.jsx)("p",{children:B("journeys.builder.publishPreviewInFlight",{n:null!==(z=null==ef?void 0:ef.em_voo)&&void 0!==z?z:0})}),(null!==(E=null==ef?void 0:ef.passos_removidos)&&void 0!==E?E:[]).map(e=>(0,r.jsx)("p",{children:e.destino?B("journeys.builder.publishPreviewRemoved",{afetados:e.afetados,destino:e4(e.destino)}):B("journeys.builder.publishPreviewRemovedToEnd",{afetados:e.afetados})},e.step_id)),(null!==(T=null==ef?void 0:ef.holds_afetados)&&void 0!==T?T:[]).map(e=>(0,r.jsx)("p",{children:B("journeys.builder.publishPreviewHolds",{afetados:e.afetados})},"hold-".concat(e.step_id)))]}),(0,r.jsxs)("div",{className:"flex justify-end ga
1p-2 pt-2",children:[(0,r.jsx)(l.z,{variant:"ghost",size:"sm",onClick:()=>eI(!1),children:B("journeys.builder.cancel")}),(0,r.jsx)(l.z,{size:"sm",disabled:ey||e5.isPending,onClick:()=>{eI(!1),e5.mutate()},children:B("journeys.builder.confirmPublish")})]})]})})]})}function r_(e,t){var n,r;if(e)return null!==(r=null===(n=t.find(t=>t.origin===e))||void 0===n?void 0:n.originLabel)&&void 0!==r?r:e}function rC(e,t){if((null==e?void 0:e.editavel)&&e.spec.origem)return r_(rh(e),t)}let rA={html:"journeysAcao.no.modoHtml",texto:"journeysAcao.no.modoTexto",template_id:"journeysAcao.no.modoModelo"};function rS(e,t){return"default"===e.kind||"hold_met"===e.kind||"hold_timeout"===e.kind||"split_path"===e.kind?"case":"trigger"===e.kind&&t?"trigger_vazio":e.kind}function rI(e){if("trigger"===e)return 0;let t=Number(e.split(":")[1]);return Number.isInteger(t)?t:0}function rz(e){let{projectId:t,journeyId:n,status:s}=e,{t:o}=(0,p.$G)(),a=(0,nC.mv)(t,n),i=a.pause.isPending||a.resume.isPending,l=async()=>{try{"active"===s?await a.pause.mutateAsync():await a.resume.mutateAsync()}catch(e){A.Am.error(e instanceof Error?e.message:o("journeys.detail.loadError"))}};return(0,r.jsxs)("label",{className:"flex cursor-pointer items-center gap-2",children:[(0,r.jsx)(m.r,{checked:"active"===s,disabled:i,onCheckedChange:()=>void l(),"aria-label":"active"===s?o("journeys.status.active"):o("journeys.status.paused")}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground",children:"active"===s?o("journeys.status.active"):o("journeys.status.paused")})]})}function rE(e){let{chave:t}=e,{fitView:n}=(0,f._K)();return(0,C.useEffect)(()=>{let e=requestAnimationFrame(()=>void n({padding:.15,maxZoom:1,duration:250}));return()=>cancelAnimationFrame(e)},[t,n]),null}function rT(){let{t:e}=(0,p.$G)(),{zoomIn:t,zoomOut:n,fitView:s}=(0,f._K)();return(0,r.jsxs)(f.s_,{position:"bottom-left",className:"flex gap-1 rounded-md border bg-background p-1 shadow-sm",children:[(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",title:e("journeys.canvas.zoomOut"),"aria-label":e("journeys.canvas.zoomOut"),onClick:()=>void n(),children:(0,r.jsx)(N.Z,{className:"h-3.5 w-3.5"})}),(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",title:e("journeys.canvas.zoomIn"),"aria-label":e("journeys.canvas.zoomIn"),onClick:()=>void t(),children:(0,r.jsx)(b.Z,{className:"h-3.5 w-3.5"})}),(0,r.jsx)(l.z,{variant:"ghost",size:"sm",className:"h-7 w-7 p-0",title:e("journeys.canvas.zoomReset"),"aria-label":e("journeys.canvas.zoomReset"),onClick:()=>void s({padding:.15,maxZoom:1}),children:(0,r.jsx)(k.Z,{className:"h-3.5 w-3.5"})})]})}function rL(e){var t;let{projectId:n,projectSlug:s,journeyId:o,definitionSteps:a}=e,{t:i}=(0,p.$G)(),[l,d]=(0,C.useState)(1),u=(0,nC.FP)(n,o,l),m=(0,nC.mv)(n,o),x=async e=>{try{await e()}catch(e){A.Am.error(e instanceof Error?e.message:i("journeys.instance.error_loading"))}};return(0,r.jsxs)("section",{className:"space-y-2",children:[(0,r.jsx)("h2",{className:"text-sm font-medium text-foreground",children:i("journeys.detail.instances")}),u.isLoading?(0,r.jsx)(c.O,{className:"h-24 w-full"}):u.isError?(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:i("journeys.instance.error_loading")}):(0,r.jsx)(rP,{projectSlug:s,instancias:(0,t8.Wg)(u.data),definitionSteps:a,onRetry:e=>x(()=>m.retry.mutateAsync(e)),onDiscard:e=>x(()=>m.discard.mutateAsync(e)),pagina:l,setPagina:d,temMais:(0,t8.Nx)({count:null===(t=u.data)||void 0===t?void 0:t.count,recebidos:(0,t8.Wg)(u.data).length,pagina:l})})]})}function rP(e){let{projectSlug:t,instancias:n,definitionSteps:s,onRetry:o,onDiscard:a,pagina:d,setPagina:u,temMais:c}=e,{t:m}=(0,p.$G)();return 0===n.length&&1===d?(0,r.jsx)("p",{className:"text-sm text-muted-foreground",children:m("journeys.instance.empty")}):(0,r.jsxs)("div",{className:"divide-y rounded-md border",children:[n.map(e=>{var n;let d=(0,t8.sV)(e.status),u=(0,t8.N2)({steps:s},e.passo_atual);return(0,r.jsxs)("div",{className:"flex items-center gap-3 px-4 py-2.5 text-sm",children:[(0,r.jsx)(w.default,{href:"/projects/".concat(t,"/leads?lead=").concat(encodeURIComponent(e.lead_id)),className:"min-w-0 flex-1 truncate font-mono text-xs text-foreground hover:underline",children:e.lead_id}),d?(0,r.jsx)(i.C,{variant:"outline",className:"text-[11px]",children:m(d.labelKey)}):(0,r.jsx)(i.C,{variant:"outline",className:"font-mono text-[11px]",children:e.status}),(0,r.jsx)("span",{className:"w-40 shrink-0 text-xs text-muted-foreground",children:null===u?m("journeys.instance.positionUnknown"):0===u.indice?m("journeys.instance.positionEntry"):m("journeys.instance.position",{indice:u.indice,total:u.total})}),"error"===e.status&&(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)("span",{className:"max-w-[220px] truncate text-xs text-red-600 dark:text-red-400",title:null!==(n=e.last_error)&&void 0!==n?n:"",children:e.last_error}),(0,r.jsx)(l.z,{variant:"outline",size:"sm",className:"h-7 text-xs",title:m("journeys.instance.retryHint"),onClick:()=>o(e.id),children:m("journeys.instance.retry")}),(0,r.jsx)(l.z,{variant:"outline",size:"sm",className:"h-7 text-xs",title:m("journeys.instance.discardHint"),onClick:()=>a(e.id),children:m("journeys.instance.discard")})]})]},e.id)}),(d>1||c)&&(0,r.jsxs)("div",{className:"flex items-center justify-between px-4 py-2",children:[(0,r.jsx)(l.z,{variant:"outline",size:"sm",className:"h-7 text-xs",disabled:d<=1,onClick:()=>u(d-1),children:"â¹"}),(0,r.jsx)("span",{className:"text-xs text-muted-foreground tabular-nums",children:d}),(0,r.jsx)(l.z,{variant:"outline",size:"sm",className:"h-7 text-xs",disabled:!c,onClick:()=>u(d+1),children:"âº"})]})]})}},7912:function(e,t,n){n.d(t,{s:function(){return m}});var r=n(57437),s=n(31679),o=n(44743),a=n(23882),i=n(19700),l=n(94806);function d(e){let{svgKey:t,className:n}=e,s=l.Y[t];return s?(0,r.jsx)("svg",{viewBox:s.viewBox,className:n,style:{width:"auto"},"aria-hidden":!0,...s.mono?{fill:"currentColor"}:{},dangerouslySetInnerHTML:{__html:s.inner}}):null}let u={microsoft_ads:function(e){let{className:t}=e;return(0,r.jsxs)("svg",{viewBox:"0 0 24 24",className:t,style:{width:"auto"},"aria-hidden":!0,xmlns:"http://www.w3.org/2000/svg",children:[(0,r.jsx)("rect",{x:"1",y:"1",width:"10",height:"10",fill:"#F25022"}),(0,r.jsx)("rect",{x:"13",y:"1",width:"10",height:"10",fill:"#7FBA00"}),(0,r.jsx)("rect",{x:"1",y:"13",width:"10",height:"10",fill:"#00A4EF"}),(0,r.jsx)("rect",{x:"13",y:"13",width:"10",height:"10",fill:"#FFB900"})]})},slack:e=>(0,r.jsx)(d,{svgKey:"slack",...e}),linkedin:e=>(0,r.jsx)(d,{svgKey:"linkedin",...e}),amplitude:e=>(0,r.jsx)(d,{svgKey:"amplitude",...e}),segment:e=>(0,r.jsx)(d,{svgKey:"segment",...e}),mparticle:e=>(0,r.jsx)(d,{svgKey:"mparticle",...e}),customerio:e=>(0,r.jsx)(d,{svgKey:"customerio",...e}),rudderstack:e=>(0,r.jsx)(d,{svgKey:"rudderstack",...e}),criteo:e=>(0,r.jsx)(d,{svgKey:"criteo",...e}),firehose:e=>(0,r.jsx)(d,{svgKey:"aws",...e}),twilio:e=>(0,r.jsx)(d,{svgKey:"twilio",...e}),sendgrid:e=>(0,r.jsx)(d,{svgKey:"sendgrid",...e}),zenvia:e=>(0,r.jsx)(d,{svgKey:"zenvia",...e})}
1,c={facebook_capi:s.ISX,meta_audience:s.ISX,tiktok:s.RNP,ga4:s.NTK,snapchat:s.kjT,pinterest:s.i5h,reddit:s.kDT,twitter:s.uQ_,posthog:s.rvq,mixpanel:s.LiW,hubspot:s.mnu,resend:s.y80,brevo:s.Dg_};function m(e){var t;let{id:n,className:s}=e,l=(0,i.WV)(n),d=u[n];if(d)return(0,r.jsx)(r.Fragment,{children:d({className:s})});let m=c[n];if(null==m?void 0:m.path)return(0,r.jsx)("svg",{role:"img","aria-hidden":!0,viewBox:"0 0 24 24",fill:"currentColor",className:(0,a.cn)(s,null==l?void 0:l.accent),children:(0,r.jsx)("path",{d:m.path})});let x=null!==(t=null==l?void 0:l.icon)&&void 0!==t?t:o.Z;return(0,r.jsx)(x,{className:(0,a.cn)(s,null==l?void 0:l.accent)})}},27064:function(e,t,n){n.d(t,{J2:function(){return i},tW:function(){return d},xo:function(){return l},yk:function(){return u}});var r=n(57437),s=n(27312),o=n(2265),a=n(23882);let i=s.fC,l=s.xz,d=s.ee,u=o.forwardRef((e,t)=>{let{className:n,align:o="center",sideOffset:i=4,...l}=e;return(0,r.jsx)(s.h_,{children:(0,r.jsx)(s.VY,{ref:t,align:o,sideOffset:i,className:(0,a.cn)("z-[110] w-72 rounded-md border bg-popover p-4 text-popover-foreground shadow-md outline-none data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-[--radix-popover-content-transform-origin]",n),...l})})});u.displayName=s.VY.displayName},24028:function(e,t,n){n.d(t,{r:function(){return i}});var r=n(57437),s=n(2265),o=n(50721),a=n(23882);let i=s.forwardRef((e,t)=>{let{className:n,...s}=e;return(0,r.jsx)(o.fC,{className:(0,a.cn)("peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 focus-visible:ring-offset-background disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input",n),...s,ref:t,children:(0,r.jsx)(o.bU,{className:(0,a.cn)("pointer-events-none block h-5 w-5 rounded-full bg-background shadow-lg ring-0 transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0")})})});i.displayName=o.fC.displayName},58857:function(e,t,n){n.d(t,{SP:function(){return d},dr:function(){return l},mQ:function(){return i},nU:function(){return u}});var r=n(57437),s=n(2265),o=n(20271),a=n(23882);let i=o.fC,l=s.forwardRef((e,t)=>{let{className:n,...s}=e;return(0,r.jsx)(o.aV,{ref:t,className:(0,a.cn)("inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",n),...s})});l.displayName=o.aV.displayName;let d=s.forwardRef((e,t)=>{let{className:n,...s}=e;return(0,r.jsx)(o.xz,{ref:t,className:(0,a.cn)("inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",n),...s})});d.displayName=o.xz.displayName;let u=s.forwardRef((e,t)=>{let{className:n,...s}=e;return(0,r.jsx)(o.VY,{ref:t,className:(0,a.cn)("mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",n),...s})});u.displayName=o.VY.displayName},10877:function(e,t,n){n.d(t,{j:function(){return u}});var r=n(14447);let s=()=>(0,r.SV)()+"/api";async function o(e){let t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},{method:n="GET",body:r,headers:o}=t,a=e.startsWith("http")?e:"".concat(s()).concat(e),i=await fetch(a,{method:n,headers:{"Content-Type":"application/json",...o},body:void 0!==r?JSON.stringify(r):void 0,credentials:"include"});if(!i.ok){let e=await i.json().catch(()=>({}));throw Error(e.message||e.error||e.detail||"Audiences API: ".concat(i.status," ").concat(i.statusText))}if(204===i.status)return;let l=await i.text();if(l&&""!==l.trim())return JSON.parse(l)}let a=encodeURIComponent;function i(e){return"/projects/".concat(a(e),"/segments/audiences")}function l(e,t){return"".concat(i(e),"/").concat(a(t))}function d(e,t,n){return"".concat(l(e,t),"/list-destinations/").concat(a(n))}let u={getLeadAudiences:(e,t)=>
1o("/projects/".concat(a(e),"/leads/").concat(a(t),"/audiences/")),listAudiences:e=>o("".concat(i(e),"/")),getAudience:(e,t)=>o("".concat(l(e,t),"/")),createAudience:(e,t)=>o("".concat(i(e),"/"),{method:"POST",body:t}),updateAudience:(e,t,n)=>o("".concat(l(e,t),"/"),{method:"PATCH",body:n}),previewAudienceEdit:(e,t,n)=>o("".concat(l(e,t),"/"),{method:"PATCH",body:{...n,preview:!0}}),deleteAudience:(e,t)=>o("".concat(l(e,t),"/"),{method:"DELETE"}),syncNow:(e,t)=>o("".concat(l(e,t),"/sync-now/"),{method:"POST"}),getStatus:(e,t)=>o("".concat(l(e,t),"/status/")),getSerie(e,t){let n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:30;return o("".concat(l(e,t),"/serie/?days=").concat(encodeURIComponent(String(n))))},getCatalogo:e=>o("".concat(i(e),"/catalogo-de-eventos/")),getProfileFieldsCobertura:e=>o("".concat(i(e),"/profile-fields-cobertura/")),getEstimativa(e,t){let n=new URLSearchParams({event_type:t.event_type,window_days:String(t.window_days)});return t.source_system&&n.set("source_system",t.source_system),o("".concat(i(e),"/estimativa/?").concat(n.toString()))},getVolumeDoProduto(e,t){let n=new URLSearchParams({event_type:t});return o("".concat(i(e),"/volume-do-produto/?").concat(n.toString()))},listListDestinations:(e,t)=>o("".concat(l(e,t),"/list-destinations/")),addListDestination:(e,t,n)=>o("".concat(l(e,t),"/list-destinations/"),{method:"POST",body:n}),patchListDestination:(e,t,n,r)=>o("".concat(d(e,t,n),"/"),{method:"PATCH",body:r}),removeListDestination:(e,t,n)=>o("".concat(d(e,t,n),"/"),{method:"DELETE"}),listDestinationSyncNow:(e,t,n)=>o("".concat(d(e,t,n),"/sync-now/"),{method:"POST"}),repair:(e,t,n)=>o("".concat(d(e,t,n),"/repair/"),{method:"POST"})}}}]);
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.