1import{j as n}from"./index-C_Fqshtm.js";import{r as d,R as P,f as Qe}from"./router-BXL9ASSk.js";import{c as Te}from"./createLucideIcon-0jETPTlQ.js";import{P as Dt,X as Ns}from"./x-DzBoDhQk.js";import{M as Zt}from"./mail-CZGeFh77.js";import{C as en}from"./clock-CqqNwWk5.js";import{A as ke}from"./alert-triangle-QAQrtls-.js";import{C as Be}from"./check-circle-2-CMG1mnCs.js";import{S as Ln}from"./search-DQVJjOoe.js";import{b as Ze,a as re,S as In,c as yt,d as ie,E as ze,e as Fn,M as _e,r as Vt,f as Ss,g as Cs}from"./consoleUi-DJ-VJD0x.js";import{L as st,P as Bn}from"./play-DKyaTOh1.js";import{Z as Jt,A as zn}from"./zap-B1z791N5.js";import{P as _s}from"./pause-circle-DzuaghDD.js";import{A as qe}from"./activity-XkJO6rsN.js";import{A as ks}from"./alert-circle-WAhqTMXQ.js";import{T as Es}from"./target-mFyhom_T.js";import{T as Rt}from"./trash-2-9Se24Ovq.js";import{S as Ds}from"./save-CIs_3KEF.js";import{S as Rs}from"./send-CN_gpVE2.js";import{C as qn}from"./copy-DcpDJEZe.js";import{C as Wn}from"./chevron-down-Co5aPzv0.js";import{R as $s}from"./refresh-cw-Cr914ebE.js";import{C as xn}from"./chevron-right-DzXxyMQ2.js";import{P as fn}from"./pencil-SEvQiMmq.js";import"./vendor-BNcAc9ko.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{};e.SENTRY_RELEASE={id:"[email protected]"}}catch{}})();try{(function(){var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="2b957c74-30c7-4831-9edb-cb44e18a4f96",e._sentryDebugIdIdentifier="sentry-dbid-2b957c74-30c7-4831-9edb-cb44e18a4f96")})()}catch{}const $t=Te("GitBranch",[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]]),Un=Te("GripVertical",[["circle",{cx:"9",cy:"12",r:"1",key:"1vctgf"}],["circle",{cx:"9",cy:"5",r:"1",key:"hp0tcf"}],["circle",{cx:"9",cy:"19",r:"1",key:"fkjjf6"}],["circle",{cx:"15",cy:"12",r:"1",key:"1tmaij"}],["circle",{cx:"15",cy:"5",r:"1",key:"19l28e"}],["circle",{cx:"15",cy:"19",r:"1",key:"f4zoj3"}]]),As=Te("History",[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]]),tn=Te("LogOut",[["path",{d:"M9 21H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h4",key:"1uf3rs"}],["polyline",{points:"16 17 21 12 16 7",key:"1gabdz"}],["line",{x1:"21",x2:"9",y1:"12",y2:"12",key:"1uyos4"}]]),Hn=Te("Map",[["polygon",{points:"3 6 9 3 15 6 21 3 21 18 15 21 9 18 3 21",key:"ok2ie8"}],["line",{x1:"9",x2:"9",y1:"3",y2:"18",key:"w34qz5"}],["line",{x1:"15",x2:"15",y1:"6",y2:"21",key:"volv9a"}]]),Vn=Te("PlayCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["polygon",{points:"10 8 16 12 10 16 10 8",key:"1cimsy"}]]),nn=Te("UserCog",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["circle",{cx:"19",cy:"11",r:"2",key:"1rxg02"}],["path",{d:"M19 8v1",key:"1iffrw"}],["path",{d:"M19 13v1",key:"z4xc62"}],["path",{d:"m21.6 9.5-.87.5",key:"6lxupl"}],["path",{d:"m17.27 12-.87.5",key:"1rwhxx"}],["path",{d:"m21.6 12.5-.87-.5",key:"agvc9a"}],["path",{d:"m17.27 10-.87-.5",key:"12d57s"}]]),At=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function He(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function sn(e){return"nodeType"in e}function J(e){var t,s;return e?He(e)?e:sn(e)&&(t=(s=e.ownerDocument)==null?void 0:s.defaultView)!=null?t:window:window}function rn(e){const{Document:t}=J(e);return e instanceof t}function it(e){return He(e)?!1:e instanceof J(e).HTMLElement}function Jn(e){return e instanceof J(e).SVGElement}function Ve(e){return e?He(e)?e.document:sn(e)?rn(e)?e:it(e)||Jn(e)?e.ownerDocument:document:document:document}const be=At?d.useLayoutEffect:d.useEffect;function Tt(e){const t=d.useRef(e);return be(()=>{t.current=e}),d.useCallback(function(){for(var s=arguments.length,r=new Array(s),a=0;a<s;a++)r[a]=arguments[a];return t.current==null?void 0:t.current(...r)},[])}function Ts(){const e=d.useRef(null),t=d.useCallback((r,a)=>{e.current=setInterval(r,a)},[]),s=d.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,s]}function rt(e,t){t===void 0&&(t=[e]);const s=d.useRef(e);return be(()=>{s.current!==e&&(s.current=e)},t),s}function ot(e,t){const s=d.useRef();return d.useMemo(()=>{const r=e(s.current);return s.current=r,r},[...t])}function jt(e){const t=Tt(e),s=d.useRef(null),r=d.useCallback(a=>{a!==s.current&&t?.(a,s.current),s.current=a},[]);return[s,r]}function Nt(e){const t=d.useRef();return d.useEffect(()=>{t.current=e},[e]),t.current}let zt={};function Mt(e,t){return d.useMemo(()=>
1{if(t)return t;const s=zt[e]==null?0:zt[e]+1;return zt[e]=s,e+"-"+s},[e,t])}function Yn(e){return function(t){for(var s=arguments.length,r=new Array(s>1?s-1:0),a=1;a<s;a++)r[a-1]=arguments[a];return r.reduce((l,o)=>{const i=Object.entries(o);for(const[c,u]of i){const p=l[c];p!=null&&(l[c]=p+e*u)}return l},{...t})}}const We=Yn(1),St=Yn(-1);function Ms(e){return"clientX"in e&&"clientY"in e}function an(e){if(!e)return!1;const{KeyboardEvent:t}=J(e.target);return t&&e instanceof t}function Os(e){if(!e)return!1;const{TouchEvent:t}=J(e.target);return t&&e instanceof t}function Ct(e){if(Os(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:s}=e.touches[0];return{x:t,y:s}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:s}=e.changedTouches[0];return{x:t,y:s}}}return Ms(e)?{x:e.clientX,y:e.clientY}:null}const at=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:s}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(s?Math.round(s):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:s}=e;return"scaleX("+t+") scaleY("+s+")"}},Transform:{toString(e){if(e)return[at.Translate.toString(e),at.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:s,easing:r}=e;return t+" "+s+"ms "+r}}}),gn="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function Ps(e){return e.matches(gn)?e:e.querySelector(gn)}const Ls={display:"none"};function Is(e){let{id:t,value:s}=e;return P.createElement("div",{id:t,style:Ls},s)}function Fs(e){let{id:t,announcement:s,ariaLiveType:r="assertive"}=e;const a={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return P.createElement("div",{id:t,style:a,role:"status","aria-live":r,"aria-atomic":!0},s)}function Bs(){const[e,t]=d.useState("");return{announce:d.useCallback(r=>{r!=null&&t(r)},[]),announcement:e}}const Xn=d.createContext(null);function zs(e){const t=d.useContext(Xn);d.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function qs(){const[e]=d.useState(()=>new Set),t=d.useCallback(r=>(e.add(r),()=>e.delete(r)),[e]);return[d.useCallback(r=>{let{type:a,event:l}=r;e.forEach(o=>{var i;return(i=o[a])==null?void 0:i.call(o,l)})},[e]),t]}const Ws={draggable:` 2 To pick up a draggable item, press the space bar. 3 While dragging, use the arrow keys to move the item. 4 Press space again to drop the item in its new position, or press escape to cancel. 5 `},Us={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was moved over droppable area "+s.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:s}=e;return s?"Draggable item "+t.id+" was dropped over droppable area "+s.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function Hs(e){let{announcements:t=Us,container:s,hiddenTextDescribedById:r,screenReaderInstructions:a=Ws}=e;const{announce:l,announcement:o}=Bs(),i=Mt("DndLiveRegion"),[c,u]=d.useState(!1);if(d.useEffect(()=>{u(!0)},[]),zs(d.useMemo(()=>({onDragStart(m){let{active:b}=m;l(t.onDragStart({active:b}))},onDragMove(m){let{active:b,over:f}=m;t.onDragMove&&l(t.onDragMove({active:b,over:f}))},onDragOver(m){let{active:b,over:f}=m;l(t.onDragOver({active:b,over:f}))},onDragEnd(m){let{active:b,over:f}=m;l(t.onDragEnd({active:b,over:f}))},onDragCancel(m){let{active:b,over:f}=m;l(t.onDragCancel({active:b,over:f}))}}),[l,t])),!c)return null;const p=P.createElement(P.Fragment,null,P.createElement(Is,{id:r,value:a.draggable}),P.createElement(Fs,{id:i,announcement:o}));return s?Qe.createPortal(p,s):p}var z;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(z||(z={}));function _t(){}function bn(e,t){return d.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function Vs(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return d.useMemo(()=>[...t].filter(r=>r!=null),[...t])}const ce=Object.freeze({x:0,y:0});function Js(e,t){return Math.sqrt(Math.pow(e.x-t.x,2)+Math.pow(e.y-t.y,2))}function Ys(e,t){const s=Ct(e);if(!s)return"0 0";const r={x:(s.x-t.left)/t.width*100,y:(s.y-t.top)/t.height*100};return r.x+"% "+r.y+"%"}function Xs(e,t){let{data:{value:s}}=e,{data:{value:r}}=t;return s-r}function Ks(e,t){let{data:{value:s}}=e,{data:{value:r}}=t;return r-s}
5function Gs(e,t){if(!e||e.length===0)return null;const[s]=e;return s[t]}function vn(e,t,s){return t===void 0&&(t=e.left),s===void 0&&(s=e.top),{x:t+e.width*.5,y:s+e.height*.5}}const Qs=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:r}=e;const a=vn(t,t.left,t.top),l=[];for(const o of r){const{id:i}=o,c=s.get(i);if(c){const u=Js(vn(c),a);l.push({id:i,data:{droppableContainer:o,value:u}})}}return l.sort(Xs)};function Zs(e,t){const s=Math.max(t.top,e.top),r=Math.max(t.left,e.left),a=Math.min(t.left+t.width,e.left+e.width),l=Math.min(t.top+t.height,e.top+e.height),o=a-r,i=l-s;if(r<a&&s<l){const c=t.width*t.height,u=e.width*e.height,p=o*i,m=p/(c+u-p);return Number(m.toFixed(4))}return 0}const er=e=>{let{collisionRect:t,droppableRects:s,droppableContainers:r}=e;const a=[];for(const l of r){const{id:o}=l,i=s.get(o);if(i){const c=Zs(i,t);c>0&&a.push({id:o,data:{droppableContainer:l,value:c}})}}return a.sort(Ks)};function tr(e,t,s){return{...e,scaleX:t&&s?t.width/s.width:1,scaleY:t&&s?t.height/s.height:1}}function Kn(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:ce}function nr(e){return function(s){for(var r=arguments.length,a=new Array(r>1?r-1:0),l=1;l<r;l++)a[l-1]=arguments[l];return a.reduce((o,i)=>({...o,top:o.top+e*i.y,bottom:o.bottom+e*i.y,left:o.left+e*i.x,right:o.right+e*i.x}),{...s})}}const sr=nr(1);function Gn(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function rr(e,t,s){const r=Gn(t);if(!r)return e;const{scaleX:a,scaleY:l,x:o,y:i}=r,c=e.left-o-(1-a)*parseFloat(s),u=e.top-i-(1-l)*parseFloat(s.slice(s.indexOf(" ")+1)),p=a?e.width/a:e.width,m=l?e.height/l:e.height;return{width:p,height:m,top:u,right:c+p,bottom:u+m,left:c}}const ar={ignoreTransform:!1};function ct(e,t){t===void 0&&(t=ar);let s=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:u,transformOrigin:p}=J(e).getComputedStyle(e);u&&(s=rr(s,u,p))}const{top:r,left:a,width:l,height:o,bottom:i,right:c}=s;return{top:r,left:a,width:l,height:o,bottom:i,right:c}}function yn(e){return ct(e,{ignoreTransform:!0})}function lr(e){const t=e.innerWidth,s=e.innerHeight;return{top:0,left:0,right:t,bottom:s,width:t,height:s}}function ir(e,t){return t===void 0&&(t=J(e).getComputedStyle(e)),t.position==="fixed"}function or(e,t){t===void 0&&(t=J(e).getComputedStyle(e));const s=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(a=>{const l=t[a];return typeof l=="string"?s.test(l):!1})}function ln(e,t){const s=[];function r(a){if(t!=null&&s.length>=t||!a)return s;if(rn(a)&&a.scrollingElement!=null&&!s.includes(a.scrollingElement))return s.push(a.scrollingElement),s;if(!it(a)||Jn(a)||s.includes(a))return s;const l=J(e).getComputedStyle(a);return a!==e&&or(a,l)&&s.push(a),ir(a,l)?s:r(a.parentNode)}return e?r(e):s}function Qn(e){const[t]=ln(e,1);return t??null}function qt(e){return!At||!e?null:He(e)?e:sn(e)?rn(e)||e===Ve(e).scrollingElement?window:it(e)?e:null:null}function Zn(e){return He(e)?e.scrollX:e.scrollLeft}function es(e){return He(e)?e.scrollY:e.scrollTop}function Yt(e){return{x:Zn(e),y:es(e)}}var W;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(W||(W={}));function ts(e){return!At||!e?!1:e===document.scrollingElement}function ns(e){const t={x:0,y:0},s=ts(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},r={x:e.scrollWidth-s.width,y:e.scrollHeight-s.height},a=e.scrollTop<=t.y,l=e.scrollLeft<=t.x,o=e.scrollTop>=r.y,i=e.scrollLeft>=r.x;return{isTop:a,isLeft:l,isBottom:o,isRight:i,maxScroll:r,minScroll:t}}const cr={x:.2,y:.2};function dr(e,t,s,r,a){let{top:l,left:o,right:i,bottom:c}=s;r===void 0&&(r=10),a===void 0&&(a=cr);const{isTop:u,isBottom:p,isLeft:m,isRight:b}=ns(e),f={x:0,y:0},j={x:0,y:0},v={height:t.height*a.y,width:t.width*a.x};return!u&&l<=t.top+v.height?(f.y=W.Backward,j.y=r*Math.abs((t.top+v.height-l)/v.height)):!p&&c>=t.bottom-v.height&&(f.y=W.Forward,j.y=r*Math.abs((t.bottom-v.height-c)/v.height)),!b&&i>=t.right-v.width?(f.x=W.Forward,j.x=r*Math.abs((t.right-v.width-i)/v.width)):!m&&o<=t.left+v.width&&(f.x=W.Backward,j.x=r*Math.abs((t.left+v.width-o)/v.width)),{direction:f,speed:j}}function ur(e){if(e===document.scrollingElement){const{innerWidth:l,innerHe
5ight:o}=window;return{top:0,left:0,right:l,bottom:o,width:l,height:o}}const{top:t,left:s,right:r,bottom:a}=e.getBoundingClientRect();return{top:t,left:s,right:r,bottom:a,width:e.clientWidth,height:e.clientHeight}}function ss(e){return e.reduce((t,s)=>We(t,Yt(s)),ce)}function hr(e){return e.reduce((t,s)=>t+Zn(s),0)}function mr(e){return e.reduce((t,s)=>t+es(s),0)}function rs(e,t){if(t===void 0&&(t=ct),!e)return;const{top:s,left:r,bottom:a,right:l}=t(e);Qn(e)&&(a<=0||l<=0||s>=window.innerHeight||r>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const pr=[["x",["left","right"],hr],["y",["top","bottom"],mr]];class on{constructor(t,s){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const r=ln(s),a=ss(r);this.rect={...t},this.width=t.width,this.height=t.height;for(const[l,o,i]of pr)for(const c of o)Object.defineProperty(this,c,{get:()=>{const u=i(r),p=a[l]-u;return this.rect[c]+p},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class et{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(s=>{var r;return(r=this.target)==null?void 0:r.removeEventListener(...s)})},this.target=t}add(t,s,r){var a;(a=this.target)==null||a.addEventListener(t,s,r),this.listeners.push([t,s,r])}}function xr(e){const{EventTarget:t}=J(e);return e instanceof t?e:Ve(e)}function Wt(e,t){const s=Math.abs(e.x),r=Math.abs(e.y);return typeof t=="number"?Math.sqrt(s**2+r**2)>t:"x"in t&&"y"in t?s>t.x&&r>t.y:"x"in t?s>t.x:"y"in t?r>t.y:!1}var se;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(se||(se={}));function wn(e){e.preventDefault()}function fr(e){e.stopPropagation()}var O;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(O||(O={}));const as={start:[O.Space,O.Enter],cancel:[O.Esc],end:[O.Space,O.Enter,O.Tab]},gr=(e,t)=>{let{currentCoordinates:s}=t;switch(e.code){case O.Right:return{...s,x:s.x+25};case O.Left:return{...s,x:s.x-25};case O.Down:return{...s,y:s.y+25};case O.Up:return{...s,y:s.y-25}}};class cn{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:s}}=t;this.props=t,this.listeners=new et(Ve(s)),this.windowListeners=new et(J(s)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(se.Resize,this.handleCancel),this.windowListeners.add(se.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(se.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:s}=this.props,r=t.node.current;r&&rs(r),s(ce)}handleKeyDown(t){if(an(t)){const{active:s,context:r,options:a}=this.props,{keyboardCodes:l=as,coordinateGetter:o=gr,scrollBehavior:i="smooth"}=a,{code:c}=t;if(l.end.includes(c)){this.handleEnd(t);return}if(l.cancel.includes(c)){this.handleCancel(t);return}const{collisionRect:u}=r.current,p=u?{x:u.left,y:u.top}:ce;this.referenceCoordinates||(this.referenceCoordinates=p);const m=o(t,{active:s,context:r.current,currentCoordinates:p});if(m){const b=St(m,p),f={x:0,y:0},{scrollableAncestors:j}=r.current;for(const v of j){const N=t.code,{isTop:E,isRight:C,isLeft:D,isBottom:y,maxScroll:_,minScroll:R}=ns(v),w=ur(v),k={x:Math.min(N===O.Right?w.right-w.width/2:w.right,Math.max(N===O.Right?w.left:w.left+w.width/2,m.x)),y:Math.min(N===O.Down?w.bottom-w.height/2:w.bottom,Math.max(N===O.Down?w.top:w.top+w.height/2,m.y))},M=N===O.Right&&!C||N===O.Left&&!D,g=N===O.Down&&!y||N===O.Up&&!E;if(M&&k.x!==m.x){const S=v.scrollLeft+b.x,L=N===O.Right&&S<=_.x||N===O.Left&&S>=R.x;if(L&&!b.y){v.scrollTo({left:S,behavior:i});return}L?f.x=v.scrollLeft-S:f.x=N===O.Right?v.scrollLeft-_.x:v.scrollLeft-R.x,f.x&&v.scrollBy({left:-f.x,behavior:i});break}else if(g&&k.y!==m.y){const S=v.scrollTop+b.y,L=N===O.Down&&S<=_.y||N===O.Up&&S>=R.y;if(L&&!b.x){v.scrollTo({top:S,behavior:i});return}
5L?f.y=v.scrollTop-S:f.y=N===O.Down?v.scrollTop-_.y:v.scrollTop-R.y,f.y&&v.scrollBy({top:-f.y,behavior:i});break}}this.handleMove(t,We(St(m,this.referenceCoordinates),f))}}}handleMove(t,s){const{onMove:r}=this.props;t.preventDefault(),r(s)}handleEnd(t){const{onEnd:s}=this.props;t.preventDefault(),this.detach(),s()}handleCancel(t){const{onCancel:s}=this.props;t.preventDefault(),this.detach(),s()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}cn.activators=[{eventName:"onKeyDown",handler:(e,t,s)=>{let{keyboardCodes:r=as,onActivation:a}=t,{active:l}=s;const{code:o}=e.nativeEvent;if(r.start.includes(o)){const i=l.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),a?.({event:e.nativeEvent}),!0)}return!1}}];function jn(e){return!!(e&&"distance"in e)}function Nn(e){return!!(e&&"delay"in e)}class dn{constructor(t,s,r){var a;r===void 0&&(r=xr(t.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=t,this.events=s;const{event:l}=t,{target:o}=l;this.props=t,this.events=s,this.document=Ve(o),this.documentListeners=new et(this.document),this.listeners=new et(r),this.windowListeners=new et(J(o)),this.initialCoordinates=(a=Ct(l))!=null?a:ce,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:t,props:{options:{activationConstraint:s,bypassActivationConstraint:r}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(se.Resize,this.handleCancel),this.windowListeners.add(se.DragStart,wn),this.windowListeners.add(se.VisibilityChange,this.handleCancel),this.windowListeners.add(se.ContextMenu,wn),this.documentListeners.add(se.Keydown,this.handleKeydown),s){if(r!=null&&r({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Nn(s)){this.timeoutId=setTimeout(this.handleStart,s.delay),this.handlePending(s);return}if(jn(s)){this.handlePending(s);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(t,s){const{active:r,onPending:a}=this.props;a(r,t,this.initialCoordinates,s)}handleStart(){const{initialCoordinates:t}=this,{onStart:s}=this.props;t&&(this.activated=!0,this.documentListeners.add(se.Click,fr,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(se.SelectionChange,this.removeTextSelection),s(t))}handleMove(t){var s;const{activated:r,initialCoordinates:a,props:l}=this,{onMove:o,options:{activationConstraint:i}}=l;if(!a)return;const c=(s=Ct(t))!=null?s:ce,u=St(a,c);if(!r&&i){if(jn(i)){if(i.tolerance!=null&&Wt(u,i.tolerance))return this.handleCancel();if(Wt(u,i.distance))return this.handleStart()}if(Nn(i)&&Wt(u,i.tolerance))return this.handleCancel();this.handlePending(i,u);return}t.cancelable&&t.preventDefault(),o(c)}handleEnd(){const{onAbort:t,onEnd:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleCancel(){const{onAbort:t,onCancel:s}=this.props;this.detach(),this.activated||t(this.props.active),s()}handleKeydown(t){t.code===O.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const br={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class un extends dn{constructor(t){const{event:s}=t,r=Ve(s.target);super(t,br,r)}}un.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;return!s.isPrimary||s.button!==0?!1:(r?.({event:s}),!0)}}];const vr={move:{name:"mousemove"},end:{name:"mouseup"}};var Xt;(function(e){e[e.RightClick=2]="RightClick"})(Xt||(Xt={}));class yr extends dn{constructor(t){super(t,vr,Ve(t.event.target))}}yr.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;return s.button===Xt.RightClick?!1:(r?.({event:s}),!0)}}];const Ut={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class wr extends dn{constructor(t){super(t,Ut)}static setup(){return window.addEventListener(Ut.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Ut.move.name,t)};function t(){}}}wr.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:s}=e,{onActivation:r}=t;const{touches:a}=s;return a.length>1?!1:(r?.({event:s}),!0)}}];var tt;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(tt||(tt={}));var kt;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="Rever
5sedTreeOrder"})(kt||(kt={}));function jr(e){let{acceleration:t,activator:s=tt.Pointer,canScroll:r,draggingRect:a,enabled:l,interval:o=5,order:i=kt.TreeOrder,pointerCoordinates:c,scrollableAncestors:u,scrollableAncestorRects:p,delta:m,threshold:b}=e;const f=Sr({delta:m,disabled:!l}),[j,v]=Ts(),N=d.useRef({x:0,y:0}),E=d.useRef({x:0,y:0}),C=d.useMemo(()=>{switch(s){case tt.Pointer:return c?{top:c.y,bottom:c.y,left:c.x,right:c.x}:null;case tt.DraggableRect:return a}},[s,a,c]),D=d.useRef(null),y=d.useCallback(()=>{const R=D.current;if(!R)return;const w=N.current.x*E.current.x,k=N.current.y*E.current.y;R.scrollBy(w,k)},[]),_=d.useMemo(()=>i===kt.TreeOrder?[...u].reverse():u,[i,u]);d.useEffect(()=>{if(!l||!u.length||!C){v();return}for(const R of _){if(r?.(R)===!1)continue;const w=u.indexOf(R),k=p[w];if(!k)continue;const{direction:M,speed:g}=dr(R,k,C,t,b);for(const S of["x","y"])f[S][M[S]]||(g[S]=0,M[S]=0);if(g.x>0||g.y>0){v(),D.current=R,j(y,o),N.current=g,E.current=M;return}}N.current={x:0,y:0},E.current={x:0,y:0},v()},[t,y,r,v,l,o,JSON.stringify(C),JSON.stringify(f),j,u,_,p,JSON.stringify(b)])}const Nr={x:{[W.Backward]:!1,[W.Forward]:!1},y:{[W.Backward]:!1,[W.Forward]:!1}};function Sr(e){let{delta:t,disabled:s}=e;const r=Nt(t);return ot(a=>{if(s||!r||!a)return Nr;const l={x:Math.sign(t.x-r.x),y:Math.sign(t.y-r.y)};return{x:{[W.Backward]:a.x[W.Backward]||l.x===-1,[W.Forward]:a.x[W.Forward]||l.x===1},y:{[W.Backward]:a.y[W.Backward]||l.y===-1,[W.Forward]:a.y[W.Forward]||l.y===1}}},[s,t,r])}function Cr(e,t){const s=t!=null?e.get(t):void 0,r=s?s.node.current:null;return ot(a=>{var l;return t==null?null:(l=r??a)!=null?l:null},[r,t])}function _r(e,t){return d.useMemo(()=>e.reduce((s,r)=>{const{sensor:a}=r,l=a.activators.map(o=>({eventName:o.eventName,handler:t(o.handler,r)}));return[...s,...l]},[]),[e,t])}var lt;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(lt||(lt={}));var Kt;(function(e){e.Optimized="optimized"})(Kt||(Kt={}));const Sn=new Map;function kr(e,t){let{dragging:s,dependencies:r,config:a}=t;const[l,o]=d.useState(null),{frequency:i,measure:c,strategy:u}=a,p=d.useRef(e),m=N(),b=rt(m),f=d.useCallback(function(E){E===void 0&&(E=[]),!b.current&&o(C=>C===null?E:C.concat(E.filter(D=>!C.includes(D))))},[b]),j=d.useRef(null),v=ot(E=>{if(m&&!s)return Sn;if(!E||E===Sn||p.current!==e||l!=null){const C=new Map;for(let D of e){if(!D)continue;if(l&&l.length>0&&!l.includes(D.id)&&D.rect.current){C.set(D.id,D.rect.current);continue}const y=D.node.current,_=y?new on(c(y),y):null;D.rect.current=_,_&&C.set(D.id,_)}return C}return E},[e,l,s,m,c]);return d.useEffect(()=>{p.current=e},[e]),d.useEffect(()=>{m||f()},[s,m]),d.useEffect(()=>{l&&l.length>0&&o(null)},[JSON.stringify(l)]),d.useEffect(()=>{m||typeof i!="number"||j.current!==null||(j.current=setTimeout(()=>{f(),j.current=null},i))},[i,m,f,...r]),{droppableRects:v,measureDroppableContainers:f,measuringScheduled:l!=null};function N(){switch(u){case lt.Always:return!1;case lt.BeforeDragging:return s;default:return!s}}}function hn(e,t){return ot(s=>e?s||(typeof t=="function"?t(e):e):null,[t,e])}function Er(e,t){return hn(e,t)}function Dr(e){let{callback:t,disabled:s}=e;const r=Tt(t),a=d.useMemo(()=>{if(s||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:l}=window;return new l(r)},[r,s]);return d.useEffect(()=>()=>a?.disconnect(),[a]),a}function Ot(e){let{callback:t,disabled:s}=e;const r=Tt(t),a=d.useMemo(()=>{if(s||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:l}=window;return new l(r)},[s]);return d.useEffect(()=>()=>a?.disconnect(),[a]),a}function Rr(e){return new on(ct(e),e)}function Cn(e,t,s){t===void 0&&(t=Rr);const[r,a]=d.useState(null);function l(){a(c=>{if(!e)return null;if(e.isConnected===!1){var u;return(u=c??s)!=null?u:null}const p=t(e);return JSON.stringify(c)===JSON.stringify(p)?c:p})}const o=Dr({callback(c){if(e)for(const u of c){const{type:p,target:m}=u;if(p==="childList"&&m instanceof HTMLElement&&m.contains(e)){l();break}}}}),i=Ot({callback:l});return be(()=>{l(),e?(i?.observe(e),o?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),o?.disconnect())},[e]),r}function $r(e){const t=hn(e);return Kn(e,t)}const _n=[];function Ar(e){const t=d.useRef(e),s=ot(r=>e?r&&r!==_n&&e&&t.current&&e.parentNode===t.current.parentNode?r:ln(e):_n,[e]);return d.useEffect(()=>{t.current=e},[e]),s}
5function Tr(e){const[t,s]=d.useState(null),r=d.useRef(e),a=d.useCallback(l=>{const o=qt(l.target);o&&s(i=>i?(i.set(o,Yt(o)),new Map(i)):null)},[]);return d.useEffect(()=>{const l=r.current;if(e!==l){o(l);const i=e.map(c=>{const u=qt(c);return u?(u.addEventListener("scroll",a,{passive:!0}),[u,Yt(u)]):null}).filter(c=>c!=null);s(i.length?new Map(i):null),r.current=e}return()=>{o(e),o(l)};function o(i){i.forEach(c=>{const u=qt(c);u?.removeEventListener("scroll",a)})}},[a,e]),d.useMemo(()=>e.length?t?Array.from(t.values()).reduce((l,o)=>We(l,o),ce):ss(e):ce,[e,t])}function kn(e,t){t===void 0&&(t=[]);const s=d.useRef(null);return d.useEffect(()=>{s.current=null},t),d.useEffect(()=>{const r=e!==ce;r&&!s.current&&(s.current=e),!r&&s.current&&(s.current=null)},[e]),s.current?St(e,s.current):ce}function Mr(e){d.useEffect(()=>{if(!At)return;const t=e.map(s=>{let{sensor:r}=s;return r.setup==null?void 0:r.setup()});return()=>{for(const s of t)s?.()}},e.map(t=>{let{sensor:s}=t;return s}))}function Or(e,t){return d.useMemo(()=>e.reduce((s,r)=>{let{eventName:a,handler:l}=r;return s[a]=o=>{l(o,t)},s},{}),[e,t])}function ls(e){return d.useMemo(()=>e?lr(e):null,[e])}const En=[];function Pr(e,t){t===void 0&&(t=ct);const[s]=e,r=ls(s?J(s):null),[a,l]=d.useState(En);function o(){l(()=>e.length?e.map(c=>ts(c)?r:new on(t(c),c)):En)}const i=Ot({callback:o});return be(()=>{i?.disconnect(),o(),e.forEach(c=>i?.observe(c))},[e]),a}function is(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return it(t)?t:e}function Lr(e){let{measure:t}=e;const[s,r]=d.useState(null),a=d.useCallback(u=>{for(const{target:p}of u)if(it(p)){r(m=>{const b=t(p);return m?{...m,width:b.width,height:b.height}:b});break}},[t]),l=Ot({callback:a}),o=d.useCallback(u=>{const p=is(u);l?.disconnect(),p&&l?.observe(p),r(p?t(p):null)},[t,l]),[i,c]=jt(o);return d.useMemo(()=>({nodeRef:i,rect:s,setRef:c}),[s,i,c])}const Ir=[{sensor:un,options:{}},{sensor:cn,options:{}}],Fr={current:{}},wt={draggable:{measure:yn},droppable:{measure:yn,strategy:lt.WhileDragging,frequency:Kt.Optimized},dragOverlay:{measure:ct}};class nt extends Map{get(t){var s;return t!=null&&(s=super.get(t))!=null?s:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:s}=t;return!s})}getNodeFor(t){var s,r;return(s=(r=this.get(t))==null?void 0:r.node.current)!=null?s:void 0}}const Br={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new nt,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:_t},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:wt,measureDroppableContainers:_t,windowRect:null,measuringScheduled:!1},os={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:_t,draggableNodes:new Map,over:null,measureDroppableContainers:_t},dt=d.createContext(os),cs=d.createContext(Br);function zr(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new nt}}}function qr(e,t){switch(t.type){case z.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case z.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case z.DragEnd:case z.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case z.RegisterDroppable:{const{element:s}=t,{id:r}=s,a=new nt(e.droppable.containers);return a.set(r,s),{...e,droppable:{...e.droppable,containers:a}}}case z.SetDroppableDisabled:{const{id:s,key:r,disabled:a}=t,l=e.droppable.containers.get(s);if(!l||r!==l.key)return e;const o=new nt(e.droppable.containers);return o.set(s,{...l,disabled:a}),{...e,droppable:{...e.droppable,containers:o}}}case z.UnregisterDroppable:{const{id:s,key:r}=t,a=e.droppable.containers.get(s);if(!a||r!==a.key)return e;
5const l=new nt(e.droppable.containers);return l.delete(s),{...e,droppable:{...e.droppable,containers:l}}}default:return e}}function Wr(e){let{disabled:t}=e;const{active:s,activatorEvent:r,draggableNodes:a}=d.useContext(dt),l=Nt(r),o=Nt(s?.id);return d.useEffect(()=>{if(!t&&!r&&l&&o!=null){if(!an(l)||document.activeElement===l.target)return;const i=a.get(o);if(!i)return;const{activatorNode:c,node:u}=i;if(!c.current&&!u.current)return;requestAnimationFrame(()=>{for(const p of[c.current,u.current]){if(!p)continue;const m=Ps(p);if(m){m.focus();break}}})}},[r,t,a,o,l]),null}function ds(e,t){let{transform:s,...r}=t;return e!=null&&e.length?e.reduce((a,l)=>l({transform:a,...r}),s):s}function Ur(e){return d.useMemo(()=>({draggable:{...wt.draggable,...e?.draggable},droppable:{...wt.droppable,...e?.droppable},dragOverlay:{...wt.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function Hr(e){let{activeNode:t,measure:s,initialRect:r,config:a=!0}=e;const l=d.useRef(!1),{x:o,y:i}=typeof a=="boolean"?{x:a,y:a}:a;be(()=>{if(!o&&!i||!t){l.current=!1;return}if(l.current||!r)return;const u=t?.node.current;if(!u||u.isConnected===!1)return;const p=s(u),m=Kn(p,r);if(o||(m.x=0),i||(m.y=0),l.current=!0,Math.abs(m.x)>0||Math.abs(m.y)>0){const b=Qn(u);b&&b.scrollBy({top:m.y,left:m.x})}},[t,o,i,r,s])}const Pt=d.createContext({...ce,scaleX:1,scaleY:1});var Ce;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Ce||(Ce={}));const Vr=d.memo(function(t){var s,r,a,l;let{id:o,accessibility:i,autoScroll:c=!0,children:u,sensors:p=Ir,collisionDetection:m=er,measuring:b,modifiers:f,...j}=t;const v=d.useReducer(qr,void 0,zr),[N,E]=v,[C,D]=qs(),[y,_]=d.useState(Ce.Uninitialized),R=y===Ce.Initialized,{draggable:{active:w,nodes:k,translate:M},droppable:{containers:g}}=N,S=w!=null?k.get(w):null,L=d.useRef({initial:null,translated:null}),I=d.useMemo(()=>{var H;return w!=null?{id:w,data:(H=S?.data)!=null?H:Fr,rect:L}:null},[w,S]),X=d.useRef(null),[Ee,De]=d.useState(null),[x,T]=d.useState(null),F=rt(j,Object.values(j)),ae=Mt("DndDescribedBy",o),ut=d.useMemo(()=>g.getEnabled(),[g]),V=Ur(b),{droppableRects:me,measureDroppableContainers:Y,measuringScheduled:Re}=kr(ut,{dragging:R,dependencies:[M.x,M.y],config:V.droppable}),K=Cr(k,w),ht=d.useMemo(()=>x?Ct(x):null,[x]),mt=js(),pt=Er(K,V.draggable.measure);Hr({activeNode:w!=null?k.get(w):null,config:mt.layoutShiftCompensation,initialRect:pt,measure:V.draggable.measure});const G=Cn(K,V.draggable.measure,pt),Je=Cn(K?K.parentElement:null),pe=d.useRef({activatorEvent:null,active:null,activeNode:K,collisionRect:null,collisions:null,droppableRects:me,draggableNodes:k,draggingNode:null,draggingNodeRect:null,droppableContainers:g,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),Me=g.getNodeFor((s=pe.current.over)==null?void 0:s.id),le=Lr({measure:V.dragOverlay.measure}),Oe=(r=le.nodeRef.current)!=null?r:K,ve=R?(a=le.rect)!=null?a:G:null,$e=!!(le.nodeRef.current&&le.rect),Pe=$r($e?null:G),Ae=ls(Oe?J(Oe):null),te=Ar(R?Me??K:null),ye=Pr(te),de=ds(f,{transform:{x:M.x-Pe.x,y:M.y-Pe.y,scaleX:1,scaleY:1},activatorEvent:x,active:I,activeNodeRect:G,containerNodeRect:Je,draggingNodeRect:ve,over:pe.current.over,overlayNodeRect:le.rect,scrollableAncestors:te,scrollableAncestorRects:ye,windowRect:Ae}),xt=ht?We(ht,M):null,ft=Tr(te),Lt=kn(ft),It=kn(ft,[G]),h=We(de,Lt),$=ve?sr(ve,de):null,A=I&&$?m({active:I,collisionRect:$,droppableRects:me,droppableContainers:ut,pointerCoordinates:xt}):null,q=Gs(A,"id"),[B,xe]=d.useState(null),Ft=$e?de:We(de,It),Le=tr(Ft,(l=B?.rect)!=null?l:null,G),Ye=d.useRef(null),gt=d.useCallback((H,Q)=>{let{sensor:Z,options:we}=Q;if(X.current==null)return;const ne=k.get(X.current);if(!ne)return;const ee=H.nativeEvent,ue=new Z({active:X.current,activeNode:ne,event:ee,options:we,context:pe,onAbort(U){if(!k.get(U))return;const{onDragAbort:he}=F.current,fe={id:U};he?.(fe),C({type:"onDragAbort",event:fe})},onPending(U,je,he,fe){if(!k.get(U))return;const{onDragPending:Ke}=F.current,Ne={id:U,constraint:je,initialCoordinates:he,offset:fe};Ke?.(Ne),C({type:"onDragPending",event:Ne})},onStart(U){const je=X.current;if(je==null)return;const he=k.get(je);if(!he)return;const{onDragStart:fe}=F.current,Xe={activatorEvent:ee,active:{id:je,data:he.data,rect:L}};Qe.unstable_batchedUpdates(()=>{fe?.(Xe),_(Ce.Initializing),E({type:z.DragStart,initialCoordinates:U,active:je}),C({type:"onDragStart",event:Xe}),De(Ye.current),T(ee)})},onMove(U){E({type:z.DragMove,coordinates:U})},onEnd:Ie(z.DragEnd),onCancel:Ie(z.DragCancel)});Ye.current=ue;function Ie(U){return async function(){const{active:he,collisions:fe,over:Xe,scrollAdjustedTranslate:Ke}=pe.current;let Ne=null;if(he&&Ke){const{cancelDrop:Ge}=F.current;Ne={activatorEvent:ee,active:he,collisions:fe,delta:Ke,over:Xe},U===z.DragEnd&&typeof Ge=="function"&&await Promise.resolve(Ge(Ne))&&(U=z.DragCancel)}X.current=null,Qe.unstable_batchedUpdates(()=>{E({type:U}),_(Ce.Uninitialized),xe(null),De(null),T(null),Ye.current=null;const Ge=U===z.DragEnd?"onDragEnd":"onDragCancel";if(Ne){const Bt=F.current[Ge];Bt?.(Ne),C({type:Ge,event:Ne})}})}}},[k]),vs=d.useCallback((H,Q)=>(Z,we)=>{const ne=Z.nativeEvent,ee=k.get(we);if(X.current!==null||!ee||ne.dndKit||ne.defaultPrevented)return;const ue={active:ee};H(Z,Q.options,ue)===!0&&(ne.dndKit={capturedBy:Q.sensor},X.current=we,gt(Z,Q))},[k,gt]),pn=_r(p,vs);Mr(p),be(()=>{G&&y===Ce.Initializing&&_(Ce.Initialized)},[G,y]),d.useEffect(()=>{const{onDragMove:H}=F.current,{active:Q,activatorEvent:Z,collisions:we,over:ne}=pe.current;if(!Q||!Z)return;const ee={active:Q,activatorEvent:Z,collisions:we,delta:{x:h.x,y:h.y},over:ne};Qe.unstable_batchedUpdates(()=>{H?.(ee),C({type:"onDragMove",event:ee})})},[h.x,h.y]),d.useEffect(()=>{const{active:H,activatorEvent:Q,collisions:Z,droppableContainers:we,scrollAdjustedTranslate:ne}=pe.current;if(!H||X.current==null||!Q||!ne)return;const{onDragOver:ee}=F.current,ue=we.get(q),Ie=ue&&ue.rect.current?{id:ue.id,rect:ue.rect.current,data:ue.data,disabled:ue.disabled}:null,U={active:H,activatorEvent:Q,collisions:Z,delta:{x:ne.x,y:ne.y},over:Ie};Qe.unstable_batchedUpdates(()=>{xe(Ie),ee?.(U),C({type:"onDragOver",event:U})})},[q]),be(()=>{pe.current={activatorEvent:x,active:I,activeNode:K,collisionRect:$,collisions:A,droppableRects:me,draggableNodes:k,draggingNode:Oe,draggingNodeRect:ve,droppableContainers:g,over:B,scrollableAncestors:te,scrollAdjustedTranslate:h},L.current={initial:ve,translated:$}},[I,K,A,$,k,Oe,ve,me,g,B,te,h]),jr({...mt,delta:M,draggingRect:$,pointerCoordinates:xt,scrollableAncestors:te,scrollableAncestorRects:ye});const ys=d.useMemo(()=>({active:I,activeNode:K,activeNodeRect:G,activatorEvent:x,collisions:A,containerNodeRect:Je,dragOverlay:le,draggableNodes:k,droppableContainers:g,droppableRects:me,over:B,measureDroppableContainers:Y,scrollableAncestors:te,scrollableAncestorRects:ye,measuringConfiguration:V,measuringScheduled:Re,windowRect:Ae}),[I,K,G,x,A,Je,le,k,g,me,B,Y,te,ye,V,Re,Ae]),ws=d.useMemo(()=>({activatorEvent:x,activators:pn,active:I,activeNodeRect:G,ariaDescribedById:{draggable:ae},dispatch:E,draggableNodes:k,over:B,measureDroppableContainers:Y}),[x,pn,I,G,E,ae,k,B,Y]);return P.createElement(Xn.Provider,{value:D},P.createElement(dt.Provider,{value:ws},P.createElement(cs.Provider,{value:ys},P.createElement(Pt.Provider,{value:Le},u)),P.createElement(Wr,{disabled:i?.restoreFocus===!1})),P.createElement(Hs,{...i,hiddenTextDescribedById:ae}));function js(){const H=Ee?.autoScrollEnabled===!1,Q=typeof c=="object"?c.enabled===!1:c===!1,Z=R&&!H&&!Q;return typeof c=="object"?{...c,enabled:Z}:{enabled:Z}}}),Jr=d.createContext(null),Dn="button",Yr="Draggable";function us(e){let{id:t,data:s,disabled:r=!1,attributes:a}=e;const l=Mt(Yr),{activators:o,activatorEvent:i,active:c,activeNodeRect:u,ariaDescribedById:p,draggableNodes:m,over:b}
5=d.useContext(dt),{role:f=Dn,roleDescription:j="draggable",tabIndex:v=0}=a??{},N=c?.id===t,E=d.useContext(N?Pt:Jr),[C,D]=jt(),[y,_]=jt(),R=Or(o,t),w=rt(s);be(()=>(m.set(t,{id:t,key:l,node:C,activatorNode:y,data:w}),()=>{const M=m.get(t);M&&M.key===l&&m.delete(t)}),[m,t]);const k=d.useMemo(()=>({role:f,tabIndex:v,"aria-disabled":r,"aria-pressed":N&&f===Dn?!0:void 0,"aria-roledescription":j,"aria-describedby":p.draggable}),[r,f,v,N,j,p.draggable]);return{active:c,activatorEvent:i,activeNodeRect:u,attributes:k,isDragging:N,listeners:r?void 0:R,node:C,over:b,setNodeRef:D,setActivatorNodeRef:_,transform:E}}function Xr(){return d.useContext(cs)}const Kr="Droppable",Gr={timeout:25};function Qr(e){let{data:t,disabled:s=!1,id:r,resizeObserverConfig:a}=e;const l=Mt(Kr),{active:o,dispatch:i,over:c,measureDroppableContainers:u}=d.useContext(dt),p=d.useRef({disabled:s}),m=d.useRef(!1),b=d.useRef(null),f=d.useRef(null),{disabled:j,updateMeasurementsFor:v,timeout:N}={...Gr,...a},E=rt(v??r),C=d.useCallback(()=>{if(!m.current){m.current=!0;return}f.current!=null&&clearTimeout(f.current),f.current=setTimeout(()=>{u(Array.isArray(E.current)?E.current:[E.current]),f.current=null},N)},[N]),D=Ot({callback:C,disabled:j||!o}),y=d.useCallback((k,M)=>{D&&(M&&(D.unobserve(M),m.current=!1),k&&D.observe(k))},[D]),[_,R]=jt(y),w=rt(t);return d.useEffect(()=>{!D||!_.current||(D.disconnect(),m.current=!1,D.observe(_.current))},[_,D]),d.useEffect(()=>(i({type:z.RegisterDroppable,element:{id:r,key:l,disabled:s,node:_,rect:b,data:w}}),()=>i({type:z.UnregisterDroppable,key:l,id:r})),[r]),d.useEffect(()=>{s!==p.current.disabled&&(i({type:z.SetDroppableDisabled,id:r,key:l,disabled:s}),p.current.disabled=s)},[r,l,s,i]),{active:o,rect:b,isOver:c?.id===r,node:_,over:c,setNodeRef:R}}function Zr(e){let{animation:t,children:s}=e;const[r,a]=d.useState(null),[l,o]=d.useState(null),i=Nt(s);return!s&&!r&&i&&a(i),be(()=>{if(!l)return;const c=r?.key,u=r?.props.id;if(c==null||u==null){a(null);return}Promise.resolve(t(u,l)).then(()=>{a(null)})},[t,r,l]),P.createElement(P.Fragment,null,s,r?d.cloneElement(r,{ref:o}):null)}const ea={x:0,y:0,scaleX:1,scaleY:1};function ta(e){let{children:t}=e;return P.createElement(dt.Provider,{value:os},P.createElement(Pt.Provider,{value:ea},t))}const na={position:"fixed",touchAction:"none"},sa=e=>an(e)?"transform 250ms ease":void 0,ra=d.forwardRef((e,t)=>{let{as:s,activatorEvent:r,adjustScale:a,children:l,className:o,rect:i,style:c,transform:u,transition:p=sa}=e;if(!i)return null;const m=a?u:{...u,scaleX:1,scaleY:1},b={...na,width:i.width,height:i.height,top:i.top,left:i.left,transform:at.Transform.toString(m),transformOrigin:a&&r?Ys(r,i):void 0,transition:typeof p=="function"?p(r):p,...c};return P.createElement(s,{className:o,style:b,ref:t},l)}),aa=e=>t=>{let{active:s,dragOverlay:r}=t;const a={},{styles:l,className:o}=e;if(l!=null&&l.active)for(const[i,c]of Object.entries(l.active))c!==void 0&&(a[i]=s.node.style.getPropertyValue(i),s.node.style.setProperty(i,c));if(l!=null&&l.dragOverlay)for(const[i,c]of Object.entries(l.dragOverlay))c!==void 0&&r.node.style.setProperty(i,c);return o!=null&&o.active&&s.node.classList.add(o.active),o!=null&&o.dragOverlay&&r.node.classList.add(o.dragOverlay),function(){for(const[c,u]of Object.entries(a))s.node.style.setProperty(c,u);o!=null&&o.active&&s.node.classList.remove(o.active)}},la=e=>{let{transform:{initial:t,final:s}}=e;return[{transform:at.Transform.toString(t)},{transform:at.Transform.toString(s)}]},ia={duration:250,easing:"ease",keyframes:la,sideEffects:aa({styles:{active:{opacity:"0"}}})};function oa(e){let{config:t,draggableNodes:s,droppableContainers:r,measuringConfiguration:a}=e;return Tt((l,o)=>{if(t===null)return;const i=s.get(l);if(!i)return;const c=i.node.current;if(!c)return;const u=is(o);if(!u)return;const{transform:p}=J(o).getComputedStyle(o),m=Gn(p);if(!m)return;const b=typeof t=="function"?t:ca(t);return rs(c,a.draggable.measure),b({active:{id:l,data:i.data,node:c,rect:a.draggable.measure(c)},draggableNodes:s,dragOverlay:{node:o,rect:a.dragOverlay.measure(u)},droppableContainers:r,measuringConfiguration:a,transform:m})})}function ca(e){const{duration:t,easing:s,sideEffects:r,keyframes:a}={...ia,...e};return l=>{let{active:o,dragOverlay:i,transform:c,...u}=l;if(!t)return;const p={x:i.rect.left-o.rect.left,y:i.rect.top-o.rect.top},m={scaleX:c.scaleX!==1?o.rect.width*c.scaleX/i.rect.width:1,scaleY:c.scaleY!==1?o.rect.height*c.scaleY/i.rect.height:1},b={x:c.x-p.x,y:c.y-p.y,...m},f=a({...u,active:o,dragOverlay:i,transform:{initial:c,final:b}}),[j]=f,v=f[f.length-1];if(JSON.stringify(j)===JSON.stringify(v))return;const N=r?.({active:o,dragOverlay:i,...u}),E=i.node.animate(f,{duration:t,easing:s,fill:"forwards"});return new Promise(C=>{E.onfinish=()=>{N?.(),C()}})}}let Rn=0;function da(e){return d.useMemo(()=>
5{if(e!=null)return Rn++,Rn},[e])}const ua=P.memo(e=>{let{adjustScale:t=!1,children:s,dropAnimation:r,style:a,transition:l,modifiers:o,wrapperElement:i="div",className:c,zIndex:u=999}=e;const{activatorEvent:p,active:m,activeNodeRect:b,containerNodeRect:f,draggableNodes:j,droppableContainers:v,dragOverlay:N,over:E,measuringConfiguration:C,scrollableAncestors:D,scrollableAncestorRects:y,windowRect:_}=Xr(),R=d.useContext(Pt),w=da(m?.id),k=ds(o,{activatorEvent:p,active:m,activeNodeRect:b,containerNodeRect:f,draggingNodeRect:N.rect,over:E,overlayNodeRect:N.rect,scrollableAncestors:D,scrollableAncestorRects:y,transform:R,windowRect:_}),M=hn(b),g=oa({config:r,draggableNodes:j,droppableContainers:v,measuringConfiguration:C}),S=M?N.setRef:void 0;return P.createElement(ta,null,P.createElement(Zr,{animation:g},m&&w?P.createElement(ra,{key:w,id:m.id,ref:S,as:i,activatorEvent:p,adjustScale:t,className:c,transition:l,rect:M,style:{zIndex:u,...a},transform:k},s):null))});let ha=0;const oe=()=>`n${Date.now().toString(36)}${(ha++).toString(36)}`,ma=new Set(["gte","lte","gt","lt","within_days","older_than_days"]),pa=(e,t,s)=>{if(e==="between")return[Number(t),Number(s)];if(ma.has(e))return Number(t);const r=Number(t);return t!==""&&!Number.isNaN(r)?r:t},xa=e=>{const t={};let s=null;const r=()=>(s||(s=oe(),t[s]={type:"exit"}),s),a=i=>i.length===0?r():(i.forEach((c,u)=>{const p=u<i.length-1?i[u+1].id:null;l(c,p)}),i[0].id),l=(i,c)=>{switch(i.kind){case"send_email":t[i.id]={type:"send_email",template_alias:i.template_alias,variables:i.variables,...i.template_id?{template_id:i.template_id}:{},next:c??r()};break;case"wait":t[i.id]={type:"wait",duration_seconds:i.duration_seconds,next:c??r()};break;case"update_profile":t[i.id]={type:"update_profile",set:i.set,next:c??r()};break;case"exit":t[i.id]={type:"exit"};break;case"condition":t[i.id]={type:"condition",field:i.field,op:i.op,value:pa(i.op,i.value,i.value2),on_true:a(i.on_true),on_false:a(i.on_false)};break}},o=a(e.sequence);return{trigger:{type:e.trigger.type,config:e.trigger.config},entry:o,steps:t,goal_config:e.goal?{field:e.goal.field,op:e.goal.op,value:e.goal.value}:null}},$n=e=>{const t=e.steps??{},s=(r,a)=>{const l=[];let o=r??null;for(;o&&t[o]&&!a.has(o);){a.add(o);const i=t[o],c=i.type;if(c==="exit")break;if(c==="send_email")l.push({id:o,kind:"send_email",template_alias:String(i.template_alias??""),...typeof i.template_id=="number"?{template_id:i.template_id}:{},variables:i.variables??{}}),o=i.next??null;else if(c==="wait")l.push({id:o,kind:"wait",duration_seconds:Number(i.duration_seconds??60)}),o=i.next??null;else if(c==="update_profile")l.push({id:o,kind:"update_profile",set:i.set??{}}),o=i.next??null;else if(c==="condition"){const u=i.value;l.push({id:o,kind:"condition",field:String(i.field??""),op:String(i.op??"eq"),value:Array.isArray(u)?String(u[0]??""):String(u??""),value2:Array.isArray(u)?String(u[1]??""):"",on_true:s(i.on_true,new Set(a)),on_false:s(i.on_false,new Set(a))});break}else break}return l};return s(e.entry,new Set)},fa=e=>{switch(e.kind){case"send_email":return{...e,id:oe(),variables:{...e.variables}};case"wait":return{...e,id:oe()};case"update_profile":return{...e,id:oe(),set:{...e.set}};case"condition":return{...e,id:oe(),on_true:[],on_false:[]};case"exit":return{id:oe(),kind:"exit"}}},hs=e=>{switch(e){case"send_email":return{id:oe(),kind:e,template_alias:"",variables:{}};case"wait":return{id:oe(),kind:e,duration_seconds:86400};case"update_profile":return{id:oe(),kind:e,set:{}};case"condition":return{id:oe(),kind:e,field:"",op:"eq",value:"",value2:"",on_true:[],on_false:[]};case"exit":return{id:oe(),kind:e}}},ge={wait:{label:"Wait",hint:"Pause the journey for a set time",icon:n.jsx(en,{className:"w-4 h-4"}),iconBg:"bg-amber-50 text-amber-600"},send_email:{label:"Send email",hint:"Send one of your templates",icon:n.jsx(Zt,{className:"w-4 h-4"}),iconBg:"bg-indigo-50 text-indigo-600"},condition:{label:"Condition",hint:"Split: yes-path and no-path",icon:n.jsx($t,{className:"w-4 h-4"}),iconBg:"bg-violet-50 text-violet-600"},update_profile:{label:"Update data",hint:"Remember something on this person",icon:n.jsx(nn,{className:"w-4 h-4"}),iconBg:"bg-slate-100 text-slate-500"},exit:{label:"End",hint:"Finish the journey here",icon:n.jsx(tn,{className:"w-4 h-4"}),iconBg:"bg-slate-100 text-slate-500"}},ms=["wait","send_email","condition","update_profile","exit"],ga=(e,t)=>{if(t==="")return e;const s=t.split(".");let r=e;for(let a=0;a+1<s.length;a+=2){const l=r[Number(s[a])];if(!l||l.kind!=="condition")return[];r=s[a+1]==="f"?l.on_false:l.on_true}return r},Ue=(e,t,s)=>{if(t==="")return s(e);const r=t.split("."),a=Number(r[0]),l=r[1],o=r.slice(2).join(".");return e.map((i,c)=>c!==a||i.kind!=="condition"?i:l==="t"?{...i,on_true:Ue(i.on_true,o,s)}:{...i,on_false:Ue(i.on_false,o,s)})},ba=(e,t,s)=>{if(!s.startsWith("slot|"))return null;const[,r,a]=s.split("|"),l=Number(a);if(Number.isNaN(l))return null;if(t.from==="palette"){const m=hs(t.kind);return{seq:Ue(e,r,b=>{const f=[...b];return f.splice(l,0,m),f}),inserted:m}}const o=`${t.path===""?"":`${t.path}.`}${t.index}.`;if(r.startsWith(o))return null;const i=ga(e,t.path)[t.index];if(!i)return null;
5let c=Ue(e,t.path,m=>m.filter((b,f)=>f!==t.index)),u=r;if(r!==t.path&&(t.path===""||r.startsWith(`${t.path}.`))){const b=(t.path===""?r:r.slice(t.path.length+1)).split("."),f=Number(b[0]);!Number.isNaN(f)&&f>t.index&&(b[0]=String(f-1),u=t.path===""?b.join("."):`${t.path}.${b.join(".")}`)}const p=t.path===r&&t.index<l?l-1:l;return c=Ue(c,u,m=>{const b=[...m];return b.splice(p,0,i),b}),{seq:c}},Gt=(e,t,s=[])=>{let r=!1;return e.forEach((a,l)=>{if(r&&s.push({nodeId:a.id,severity:"warn",text:"Will never run â it comes after an End step. Move it up or remove the End above."}),a.kind==="exit"&&(r=!0),a.kind==="send_email"&&a.template_id){const o=t.find(i=>i.id===a.template_id);o&&o.category==="transactional"&&s.push({nodeId:a.id,severity:"warn",text:`â${o.name}â is a transactional template â receipts and confirmations send automatically. Probably not what you want in a journey.`})}if(a.kind==="send_email"&&a.template_id){const o=t.find(i=>i.id===a.template_id);o&&(o.max_sends==null||o.per_days==null)&&s.push({nodeId:a.id,severity:"nudge",text:`â${o.name}â has no send cap â it can repeat to the same person without limit. Consider setting one where templates are managed.`})}a.kind==="send_email"&&l>0&&e[l-1].kind==="send_email"&&s.push({nodeId:a.id,severity:"nudge",text:"Two emails back-to-back â consider a Wait between them so people arenât emailed twice in a minute."}),a.kind==="condition"&&(Gt(a.on_true,t,s),Gt(a.on_false,t,s))}),s},va=new Set(["first_name","user_name","signer_name","name","email","email_address"]),ya=new Set(["unsubscribe_url","site_url","contact_url","privacy_policy_url","terms_url","preferences_url"]),wa=(e,t)=>{const s=e.toLowerCase();return va.has(s)?"profile":ya.has(s)?"computed":t.has(s)?"event":"missing"},An={profile:{label:"profile",cls:"bg-blue-50 text-blue-700 border-blue-200"},event:{label:"event",cls:"bg-emerald-50 text-emerald-700 border-emerald-200"},computed:{label:"computed",cls:"bg-violet-50 text-violet-700 border-violet-200"}},ja={first_name:"Delfina",user_name:"Delfina F.",signer_name:"Delfina F.",name:"Delfina",email:"delfinaâ¢â¢â¢@gmail.com",email_address:"delfinaâ¢â¢â¢@gmail.com",unsubscribe_url:"https://atzuma.co.il/unsubscribe/tok_9f2â¦",site_url:"https://atzuma.co.il"},Na=({template:e,triggerEvent:t})=>{const s=d.useMemo(()=>new Set((t?.properties??[]).map(o=>o.name.toLowerCase())),[t]),r=e.variables.map(o=>{const i=e.sources?.[o],c=i===void 0?wa(o,s):i==="event_required"?s.has(o.toLowerCase())?"event":"missing":i;return{v:o,source:c}}),a=r.filter(o=>o.source==="missing"),l=(o,i)=>{if(i==="event"){const c=(t?.properties??[]).find(u=>u.name.toLowerCase()===o.toLowerCase());return c?.example!=null?String(c.example):"from the trigger event"}return ja[o.toLowerCase()]??(i==="profile"?"from the personâs profile":"generated per send")};return n.jsxs("div",{className:"mt-3 border border-slate-200 rounded-xl overflow-hidden","data-testid":"variables-panel",children:[n.jsxs("div",{className:"px-3 py-2 bg-slate-50 border-b border-slate-200 flex items-center gap-2",children:[n.jsx("span",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-500",children:"This template's variables"}),n.jsxs("span",{className:"text-[11px] text-slate-400",children:[r.length," total",a.length>0?` · ${a.length} unresolved`:r.length>0?" · all resolved â":""]})]}),r.length===0?n.jsx("div",{className:"px-3 py-2.5 text-[12.5px] text-slate-400",children:"This template declares no variables."}):n.jsx("ul",{className:"divide-y divide-slate-100",children:r.map(({v:o,source:i})=>n.jsxs("li",{className:`px-3 py-2 flex items-start gap-2.5 text-[12.5px] ${i==="missing"?"bg-red-50/60":""}`,children:[n.jsx("code",{className:`font-semibold ${i==="missing"?"text-red-700":"text-slate-800"}`,children:`{{${o}}}`}),i==="missing"?n.jsxs("span",{className:"text-red-600 flex items-center gap-1.5 min-w-0",children:[n.jsx(ke,{className:"w-3.5 h-3.5 flex-none"}),t?n.jsxs(n.Fragment,{children:["this journey's trigger (",n.jsx("b",{children:t.label}),") doesn't carry ",n.jsx("b",{children:o})," â pick another template or another trigger"]}):n.jsxs(n.Fragment,{children:["pick a trigger first â then we can check where ",n.jsx("b",{children:o})," comes from"]})]}):n.jsxs(n.Fragment,{children:[n.jsx("span",{className:`flex-none text-[10.5px] font-bold px-1.5 py-0.5 rounded border ${An[i].cls}`,children:An[i].label}),n.jsxs("span",{className:"text-slate-500 truncate",title:l(o,i),children:["e.g. ",n.jsxs("em",{className:"not-italic text-slate-600",children:["â",l(o,i),"â"]}
5)]})]})]},o))})]})},Sa=({templates:e,onPick:t})=>{const[s,r]=d.useState(""),[a,l]=d.useState(!1),o=e.filter(u=>u.category==="marketing"),i=a?e:o,c=d.useMemo(()=>i.filter(u=>u.name.toLowerCase().includes(s.toLowerCase())).slice(0,8),[i,s]);return n.jsxs("div",{children:[n.jsxs("div",{className:"relative mb-1.5",children:[n.jsx(Ln,{className:"w-3.5 h-3.5 text-slate-400 absolute left-2.5 top-2.5"}),n.jsx("input",{value:s,onChange:u=>r(u.target.value),placeholder:`Search ${i.length} ${a?"":"marketing "}templatesâ¦`,className:"w-full border border-slate-200 rounded-lg pl-8 pr-3 py-1.5 text-[13px] focus:outline-none focus:border-indigo-400"})]}),n.jsxs("ul",{className:"border border-slate-200 rounded-lg divide-y divide-slate-100 max-h-56 overflow-y-auto",children:[c.map(u=>n.jsx("li",{children:n.jsxs("button",{onClick:()=>t(u),className:"w-full px-3 py-2 text-left hover:bg-slate-50 flex items-center gap-2",children:[n.jsx("span",{className:"text-[13px] font-medium text-slate-800 truncate",children:u.name}),n.jsx("span",{className:`ml-auto flex-none text-[10px] font-bold px-1.5 py-0.5 rounded-full ${u.category==="marketing"?"bg-pink-50 text-pink-600":"bg-sky-50 text-sky-600"}`,children:u.category}),n.jsx("span",{className:"flex-none",children:n.jsx(ps,{template:u})}),n.jsxs("span",{className:"flex-none text-[11px] text-slate-400",children:[u.variables.length," vars"]})]})},u.id)),c.length===0&&n.jsx("li",{className:"px-3 py-3 text-[12.5px] text-slate-400",children:s?`No template matches â${s}â.`:"No marketing templates yet â use âShow allâ."})]}),n.jsx("button",{onClick:()=>l(u=>!u),className:"mt-1.5 text-[11.5px] text-slate-400 hover:text-slate-700 underline",children:a?`Show marketing only (${o.length})`:`Show all ${e.length} templates (incl. transactional & one-offs)`})]})},Ca=e=>e.max_sends!=null&&e.per_days!=null?`max ${e.max_sends} per ${e.per_days} days`:null,ps=({template:e})=>{const t=Ca(e);return t?n.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded-full bg-slate-100 text-slate-600",title:"Send cap â the runner never sends this template to the same person more often than this. Caps are edited where templates are managed.",children:t}):n.jsx("span",{className:"text-[10px] font-bold px-1.5 py-0.5 rounded-full bg-amber-50 text-amber-600",title:"No cap set â this template can repeat to the same person without limit. Set a cap where templates are managed.",children:"no cap set"})},_a=({kind:e})=>{const{attributes:t,listeners:s,setNodeRef:r,isDragging:a}=us({id:`pal-${e}`,data:{from:"palette",kind:e}}),l=ge[e];return n.jsx("button",{ref:r,...t,...s,className:`w-full text-left bg-white border border-slate-200 rounded-xl px-3 py-2.5 shadow-sm cursor-grab active:cursor-grabbing hover:border-indigo-300 hover:shadow transition-all motion-reduce:transition-none ${a?"opacity-40":""}`,children:n.jsxs("span",{className:"flex items-center gap-2.5",children:[n.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center flex-none ${l.iconBg}`,children:l.icon}),n.jsxs("span",{className:"min-w-0",children:[n.jsx("span",{className:"block text-[13px] font-semibold text-slate-800",children:l.label}),n.jsx("span",{className:"block text-[11px] text-slate-500 leading-tight",children:l.hint})]}),n.jsx(Un,{className:"w-4 h-4 text-slate-300 ml-auto flex-none"})]})})},Et=({path:e,index:t,dragActive:s,compact:r,onInsert:a})=>{const{setNodeRef:l,isOver:o}=Qr({id:`slot|${e}|${t}`}),[i,c]=d.useState(!1);return n.jsxs("div",{ref:l,className:`relative flex items-center justify-center transition-all motion-reduce:transition-none ${s?r?"h-9":"h-12":r?"h-6":"h-7"} ${o?"scale-[1.02]":""}`,children:[n.jsx("div",{className:`absolute inset-x-6 rounded-lg border-2 border-dashed transition-all motion-reduce:transition-none flex items-center justify-center text-[11px] font-semibold 6 ${o?"inset-y-0.5 border-indigo-500 bg-indigo-50 text-indigo-600":s?"inset-y-1 border-indigo-200 bg-indigo-50/40 text-indigo-300":"inset-y-2.5 border-transparent text-transparent"}`,children:o?"Drop here":s?"drop zone":""}),!s&&n.jsxs("div",{className:"relative z-10",children:[n.jsx("button",{onClick:()=>c(u=>!u),"aria-label":`Insert a step (position ${t+1})`,className:"w-5 h-5 rounded-full border border-dashed border-slate-300 bg-white text-slate-400 hover:border-indigo-400 hover:text-indigo-500 flex items-center justify-center",children:n.jsx(Dt,{className:"w-3 h-3"})}),i&&n.jsx("div",{className:"absolute left-1/2 -translate-x-1/2 top-7 z-30 bg-white border border-slate-200 rounded-xl shadow-lg py-1 w-60",children:ms.map(u=>n.jsxs("button",{onClick:()=>{a(u,e,t),c(!1)},className:"w-full px-3 py-2 text-left hover:bg-slate-50 flex items-center gap-2.5",children:[n.jsx("span",{className:`w-7 h-7 rounded-lg flex items-center justify-center ${ge[u].iconBg}`,children:ge[u].icon}),n.jsxs("span",{children:[n.jsx("span",{className:"block text-[13px] font-semibold text-slate-800",children:ge[u].label}),n.jsx("span",{className:"block text-[10.5px] text-slate-500",children:ge[u].hint})]})]},u))})]})]})},mn=e=>{switch(e.kind){case"send_email":return e.template_alias===""?"pick a template":null;case"condition":return e.field===""?"pick what to check":e.value===""&&e.op!=="eq"?"set a value":null;case"wait":return e.duration_seconds>0?null:"pick how long";case"update_profile":return Object.keys(e.set).length===0?"pick a field to set":null;case"exit":return null}}
6,ka=({gap:e})=>e?n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold text-amber-600",children:[n.jsx(ke,{className:"w-3 h-3"})," Needs setup â ",e]}):n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold text-emerald-600",children:[n.jsx(Be,{className:"w-3 h-3"})," Configured"]}),Ea=async(e,t)=>{const s=localStorage.getItem("auth_token"),r=await fetch(e,{method:"POST",headers:{Authorization:`Bearer ${s}`,Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(t)}),a=await r.json().catch(()=>({}));if(!r.ok)throw new Error((a.errors??[`Request failed (${r.status})`]).join(` 7`));return a},Da=e=>{switch(e){case"send_email":return n.jsx(Zt,{className:"w-4 h-4 text-blue-500"});case"wait":return n.jsx(en,{className:"w-4 h-4 text-amber-500"});case"condition":return n.jsx($t,{className:"w-4 h-4 text-purple-500"});case"update_profile":return n.jsx(nn,{className:"w-4 h-4 text-gray-500"});case"exit":return n.jsx(tn,{className:"w-4 h-4 text-green-600"});default:return n.jsx(ke,{className:"w-4 h-4 text-red-500"})}},Ra=e=>{switch(e.type){case"send_email":return`template: ${e.template_alias??"â"}`;case"wait":return`wait ${e.wait_seconds}s â resume ${e.resume_at??""}`;case"condition":return`${e.field??""} â ${e.result?"TRUE":"FALSE"}`;case"update_profile":return`set ${Object.keys(e.set??{}).join(", ")}`;case"exit":return`reason: ${e.reason??"flow_end"}`;case"aborted":return`aborted: ${e.reason??""}`;default:return""}},$a=({journeyId:e,stepTree:t,onClose:s})=>{const[r,a]=d.useState(""),[l,o]=d.useState(!1),[i,c]=d.useState(null),[u,p]=d.useState(null),[m,b]=d.useState(null),f=()=>{o(!0),b(null),c(null),Ea(`/api/v1/admin/journeys/${e}/simulate`,{email:r.trim(),step_tree:t}).then(j=>{c(j.simulation),p(j.segment)}).catch(j=>b(j.message)).finally(()=>o(!1))};return n.jsx("div",{className:"fixed inset-0 z-50 flex justify-end bg-black/30",onClick:s,children:n.jsxs("div",{className:"w-full max-w-lg bg-white h-full overflow-y-auto shadow-xl",onClick:j=>j.stopPropagation(),children:[n.jsxs("div",{className:"sticky top-0 bg-white border-b px-5 py-4 flex items-center justify-between",children:[n.jsxs("div",{children:[n.jsx("h3",{className:"font-bold text-gray-800",children:"Simulate on a real profile"}),n.jsx("p",{className:"text-xs text-gray-400",children:"Read-only â no sends, no enrollment. Virtual clock."})]}),n.jsx("button",{onClick:s,className:"text-gray-400 hover:text-gray-700",children:n.jsx(Ns,{className:"w-5 h-5"})})]}),n.jsxs("div",{className:"p-5",children:[n.jsx("label",{className:"block text-xs text-gray-500 mb-1",children:"Recipient email"}),n.jsxs("div",{className:"flex gap-2",children:[n.jsx("input",{className:"flex-1 border rounded px-2 py-1.5 text-sm",placeholder:"[email protected]",value:r,onChange:j=>a(j.target.value),onKeyDown:j=>j.key==="Enter"&&f()}),n.jsxs("button",{onClick:f,disabled:l||!r.trim(),className:"inline-flex items-center gap-1 px-3 py-1.5 bg-gray-800 text-white rounded text-sm hover:bg-gray-900 disabled:opacity-50",children:[l?n.jsx(st,{className:"w-4 h-4 animate-spin"}):n.jsx(Bn,{className:"w-4 h-4"})," Run"]})]}),m&&n.jsx("div",{className:"mt-3 text-sm text-red-600 whitespace-pre-line",children:m}),i&&n.jsxs("div",{className:"mt-4",children:[n.jsxs("div",{className:"text-xs text-gray-400 mb-2",children:["enrollment ",i.enrollment_id," · version ",i.version_no??"â",u?` · segment ${u}`:""]}),n.jsx("ol",{className:"relative border-l border-gray-200 ml-2",children:i.events.map((j,v)=>n.jsxs("li",{className:"mb-4 ml-4",children:[n.jsx("span",{className:"absolute -left-2 flex items-center justify-center w-4 h-4 bg-white rounded-full",children:Da(j.type)}),n.jsxs("div",{className:"text-sm font-medium text-gray-800",children:[j.seq,". ",j.type]}),n.jsx("div",{className:"text-xs text-gray-400",children:j.at}),n.jsx("div",{className:"text-xs text-gray-600",children:Ra(j)})]},v))})]})]})]})})},Aa=e=>{switch(e.kind){case"send_email":return{icon:n.jsx(Zt,{className:"w-3 h-3 text-blue-500"}),text:e.template_alias||"email"};case"wait":return{icon:n.jsx(en,{className:"w-3 h-3 text-amber-500"}),text:`wait ${Math.round(e.duration_seconds/86400)||Math.round(e.duration_seconds/3600)}${e.duration_seconds%86400===0?"d":"h"}`};case"update_profile":return{icon:n.jsx(nn,{className:"w-3 h-3 text-gray-500"}),text:`set ${Object.keys(e.set).length} field(s)`};case"exit":return{icon:n.jsx(tn,{className:"w-3 h-3 text-green-600"}),text:"exit"}}},Ta=({node:e})=>
7{if(e.kind==="condition")return n.jsxs("div",{className:"border rounded p-1 bg-purple-50 border-purple-200",children:[n.jsxs("div",{className:"text-[10px] font-medium text-purple-700 inline-flex items-center gap-1",children:[n.jsx($t,{className:"w-3 h-3"})," ",e.field||"?"," ",e.op," ",e.value,e.op==="between"?`â${e.value2}`:""]}),n.jsxs("div",{className:"grid grid-cols-2 gap-1 mt-1",children:[n.jsxs("div",{className:"pl-1 border-l-2 border-green-300",children:[n.jsx("div",{className:"text-[9px] text-green-700",children:"TRUE"}),n.jsx(Qt,{nodes:e.on_true})]}),n.jsxs("div",{className:"pl-1 border-l-2 border-red-300",children:[n.jsx("div",{className:"text-[9px] text-red-700",children:"FALSE"}),n.jsx(Qt,{nodes:e.on_false})]})]})]});const{icon:t,text:s}=Aa(e);return n.jsxs("div",{className:"border rounded px-1.5 py-1 bg-white text-[10px] text-gray-700 inline-flex items-center gap-1 w-full",children:[t,n.jsx("span",{className:"truncate",children:s})]})},Qt=({nodes:e})=>n.jsx("div",{className:"flex flex-col gap-1",children:e.length===0?n.jsx("div",{className:"text-[9px] text-gray-300 text-center",children:"â exit"}):e.map(t=>n.jsx(Ta,{node:t},t.id))}),Tn=({nodes:e,triggerLabel:t})=>n.jsxs("div",{children:[t&&n.jsxs("div",{className:"mb-1 inline-flex items-center gap-1 text-[10px] text-indigo-700 bg-indigo-50 border border-indigo-200 rounded px-1.5 py-0.5",children:[n.jsx(Jt,{className:"w-3 h-3"})," ",t]}),n.jsx(Qt,{nodes:e}),n.jsx("div",{className:"text-[9px] text-gray-300 text-center mt-1",children:"journey ends"})]}),Se=async e=>{const t=localStorage.getItem("auth_token"),s=await fetch(e,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});if(!s.ok)throw new Error(`Request failed (${s.status})`);return s.json()},Fe=async(e,t,s)=>{const r=localStorage.getItem("auth_token"),a=await fetch(e,{method:t,headers:{Authorization:`Bearer ${r}`,Accept:"application/json","Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)}),l=await a.json().catch(()=>({}));if(!a.ok)throw new Error((l.errors??[l.message??`Request failed (${a.status})`]).join(` 8`));return l},xs=[{s:3600,label:"1 hour"},{s:86400,label:"1 day"},{s:259200,label:"3 days"},{s:604800,label:"1 week"}],fs=e=>e%86400===0?{n:e/86400,unit:86400}:e%3600===0?{n:e/3600,unit:3600}:{n:Math.max(1,Math.round(e/60)),unit:60},gs=e=>xs.find(t=>t.s===e)?.label??(()=>{const t=fs(e);return`${t.n} ${t.unit===86400?"day":t.unit===3600?"hour":"min"}${t.n===1?"":"s"}`})(),Ma=({label:e,rows:t,fieldOptions:s,onChange:r})=>{const a=Object.entries(t),l=(o,i)=>{const c={};a.forEach(([u,p])=>{c[u===o?i:u]=p}),r(c)};return n.jsxs("div",{children:[n.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-400 mb-1",children:e}),a.map(([o,i],c)=>n.jsxs("div",{className:"flex items-center gap-1.5 mb-1",children:[s?n.jsxs("select",{className:"border border-slate-200 rounded-lg px-2 py-1 text-[13px] min-w-[160px]",value:o,onChange:u=>l(o,u.target.value),children:[n.jsx("option",{value:"",children:"fieldâ¦"}),s.map(u=>n.jsx("option",{value:u.key,children:u.label},u.key))]}):n.jsx("input",{className:"border border-slate-200 rounded-lg px-2 py-1 text-[13px] w-40",placeholder:"name",value:o,onChange:u=>l(o,u.target.value)}),n.jsx("span",{className:"text-slate-300",children:"="}),n.jsx("input",{className:"border border-slate-200 rounded-lg px-2 py-1 text-[13px] flex-1",placeholder:"value",value:i,onChange:u=>r({...t,[o]:u.target.value})}),n.jsx("button",{onClick:()=>{const u={...t};delete u[o],r(u)},"aria-label":`Remove ${o||"row"}`,className:"text-slate-300 hover:text-red-500",children:n.jsx(Rt,{className:"w-4 h-4"})})]},c)),n.jsxs("button",{onClick:()=>r({...t,"":""}),className:"text-xs text-indigo-600 hover:text-indigo-800 inline-flex items-center gap-1",children:[n.jsx(Dt,{className:"w-3 h-3"})," add"]})]})},bs=({node:e,path:t,index:s,catalog:r,templates:a,triggerEvent:l,lint:o,expandedIds:i,dragActive:c,setExpanded:u,mutate:p,onInsert:m})=>{const{attributes:b,listeners:f,setNodeRef:j,isDragging:v}=us({id:`step-${e.id}`,data:{from:"flow",path:t,index:s,kind:e.kind}}),N=ge[e.kind],E=i.has(e.id),C=mn(e),D=o.filter(g=>g.nodeId===e.id),y=e.kind==="send_email"?a.find(g=>e.template_id?g.id===e.template_id:g.slug===e.template_alias)??null:null,_=e.kind==="condition"?r.fields.find(g=>g.key===e.field):void 0,R=e.kind==="wait"?`Wait ${gs(e.duration_seconds)}`:e.kind==="send_email"?y?`Send â${y.name}â`:e.template_alias?`Send â${e.template_alias}â`:"Send email":e.kind==="condition"?e.field?`Split on: ${_?.label??e.field}`:"Condition":e.kind==="update_profile"?"Update data":"End of journey",w=g=>p(t,S=>S.map((L,I)=>I===s?g:L)),k=()=>
8p(t,g=>g.filter((S,L)=>L!==s)),M=()=>p(t,g=>{const S=[...g];return S.splice(s+1,0,fa(e)),S});return n.jsxs("div",{ref:j,className:`bg-white border rounded-xl shadow-sm transition-all motion-reduce:transition-none ${v?"opacity-40":""} ${E?"border-indigo-300 ring-1 ring-indigo-100":"border-slate-200 hover:border-slate-300"}`,children:[n.jsxs("div",{className:"px-3.5 py-3 flex items-center gap-3 cursor-pointer",onClick:()=>u(e.id),children:[n.jsx("span",{...b,...f,onClick:g=>g.stopPropagation(),"aria-label":`Drag to move the ${N.label} step`,className:"cursor-grab active:cursor-grabbing text-slate-300 hover:text-slate-500 flex-none touch-none",children:n.jsx(Un,{className:"w-4 h-4"})}),n.jsx("span",{className:`w-9 h-9 rounded-lg flex items-center justify-center flex-none ${N.iconBg}`,children:N.icon}),n.jsxs("span",{className:"min-w-0 flex-1",children:[n.jsx("span",{className:"block text-[13.5px] font-semibold text-slate-800 truncate",children:R}),n.jsx(ka,{gap:C})]}),n.jsx("button",{onClick:g=>{g.stopPropagation(),M()},"aria-label":`Duplicate the ${N.label} step`,className:"text-slate-300 hover:text-indigo-500 flex-none",children:n.jsx(qn,{className:"w-4 h-4"})}),n.jsx("button",{onClick:g=>{g.stopPropagation(),k()},"aria-label":`Remove the ${N.label} step`,className:"text-slate-300 hover:text-red-500 flex-none",children:n.jsx(Rt,{className:"w-4 h-4"})}),n.jsx(Wn,{className:`w-4 h-4 text-slate-300 flex-none transition-transform motion-reduce:transition-none ${E?"rotate-180":""}`})]}),D.map((g,S)=>n.jsxs("div",{className:`mx-3.5 mb-2 -mt-1 rounded-lg px-2.5 py-1.5 text-[12px] flex items-start gap-1.5 ${g.severity==="warn"?"bg-amber-50 text-amber-700 border border-amber-200":"bg-slate-50 text-slate-500 border border-slate-200"}`,children:[n.jsx(ke,{className:"w-3.5 h-3.5 flex-none mt-0.5"})," ",g.text]},S)),E&&n.jsxs("div",{className:"border-t border-slate-100 px-3.5 py-3",onClick:g=>g.stopPropagation(),children:[e.kind==="wait"&&(()=>{const g=fs(e.duration_seconds);return n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[xs.map(S=>n.jsx("button",{onClick:()=>w({...e,duration_seconds:S.s}),className:`px-3 py-1.5 rounded-lg text-[12.5px] font-semibold border ${e.duration_seconds===S.s?"bg-amber-500 border-amber-500 text-white":"bg-white border-slate-200 text-slate-600 hover:border-amber-300"}`,children:S.label},S.s)),n.jsx("span",{className:"text-slate-300 mx-1",children:"·"}),n.jsx("input",{type:"number",min:1,className:"w-16 border border-slate-200 rounded-lg px-2 py-1 text-[13px]",value:g.n,onChange:S=>w({...e,duration_seconds:Math.max(1,Number(S.target.value))*g.unit}),"aria-label":"Custom wait amount"}),n.jsxs("select",{className:"border border-slate-200 rounded-lg px-2 py-1 text-[13px]",value:g.unit,onChange:S=>w({...e,duration_seconds:g.n*Number(S.target.value)}),"aria-label":"Custom wait unit",children:[n.jsx("option",{value:60,children:"minutes"}),n.jsx("option",{value:3600,children:"hours"}),n.jsx("option",{value:86400,children:"days"})]}),n.jsx("span",{className:"w-full text-[11.5px] text-slate-400",children:"The journey pauses here, then continues automatically."})]})})(),e.kind==="send_email"&&(y?n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-[13px] font-semibold text-slate-800",children:y.name}),n.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded-full ${y.category==="marketing"?"bg-pink-50 text-pink-600":"bg-sky-50 text-sky-600"}`,children:y.category}),n.jsx(ps,{template:y}),n.jsx("button",{onClick:()=>w({...e,template_id:void 0,template_alias:""}),className:"ml-auto text-[11.5px] text-slate-400 hover:text-slate-700 underline",children:"change template"})]}),n.jsx(Na,{template:y,triggerEvent:l})]}):e.template_alias?n.jsxs("div",{className:"text-[12.5px] text-amber-700 bg-amber-50 border border-amber-200 rounded-lg px-2.5 py-2 flex items-start gap-1.5",children:[n.jsx(ke,{className:"w-3.5 h-3.5 flex-none mt-0.5"}),n.jsxs("span",{children:["Saved with alias â",e.template_alias,"â, which isn't in the active template list.",n.jsx("button",{onClick:()=>w({...e,template_alias:""}),className:"underline ml-1",children:"Pick a template"})]})]}):n.jsx(Sa,{templates:a,onPick:g=>w({...e,template_id:g.id,template_alias:g.slug})})),e.kind==="condition"&&n.jsxs("div",{className:"space-y-3",children:[n.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[n.jsxs("select",{className:"border border-slate-200 rounded-lg px-2.5 py-1.5 text-[13px] min-w-[180px]",value:e.field,onChange:g=>{const S=r.fields.find(L=>L.key===g.target.value);w({...e,field:g.target.value,op:S?.operators[0]??"eq"})},children:[n.jsx("option",{value:"",children:"Split onâ¦"}),r.fields.map(g=>n.jsxs("option",{value:g.key,children:[g.label,g.in_catalog?"":" (raw)"]},g.key))]}),n.jsx("select",{className:"border border-slate-200 rounded-lg px-2.5 py-1.5 text-[13px]",value:e.op,onChange:g=>w({...e,op:g.target.value}),"aria-label":"Operator",children:(_?.operators??Object.keys(r.operators)).map(g=>n.jsx("option",{value:g,children:r.operators[g]?.label??g},g))}),n.jsx("input",{className:"w-28 border border-slate-200 rounded-lg px-2.5 py-1.5 text-[13px]",placeholder:"value",value:e.value,onChange:g=>w({...e,value:g.target.value})}),e.op==="between"&&n.jsx("input",{className:"w-28 border border-slate-200 rounded-lg px-2.5 py-1.5 text-[13px]",placeholder:"â¦and",value:e.value2,onChange:g=>w({...e,value2:g.target.value})})]}),n.jsx("p",{className:"text-[11.5px] text-slate-400 -mt-1",children:"Each person takes exactly one path. Both paths end the journey (they don't rejoin)."}),n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 gap-3",children:[n.jsx(Mn,{label:"Yes â condition is true",cls:"border-emerald-200 bg-emerald-50/40",labelCls:"text-emerald-700",nodes:e.on_true,path:`${t===""?"":`${t}.`}${s}.t`,catalog:r,templates:a,triggerEvent:l,lint:o,expandedIds:i,dragActive:c,setExpanded:u,mutate:p,onInsert:m}),n.jsx(Mn,{label:"No â condition is false",cls:"border-red-200 bg-red-50/30",labelCls:"text-red-700",nodes:e.on_fal
8se,path:`${t===""?"":`${t}.`}${s}.f`,catalog:r,templates:a,triggerEvent:l,lint:o,expandedIds:i,dragActive:c,setExpanded:u,mutate:p,onInsert:m})]})]}),e.kind==="update_profile"&&n.jsx(Ma,{label:"Remember on this person (journey-only, never the live profile)",rows:e.set,fieldOptions:r.fields,onChange:g=>w({...e,set:g})}),e.kind==="exit"&&n.jsx("p",{className:"text-[12.5px] text-slate-500",children:"Everyone who reaches this point finishes the journey."})]})]})},Mn=({label:e,cls:t,labelCls:s,nodes:r,path:a,...l})=>n.jsxs("div",{className:`border rounded-xl p-2 ${t}`,children:[n.jsx("div",{className:`text-[11px] font-bold uppercase tracking-wider mb-1 ${s}`,children:e}),r.map((o,i)=>n.jsxs(P.Fragment,{children:[n.jsx(Et,{path:a,index:i,dragActive:l.dragActive,compact:!0,onInsert:l.onInsert}),n.jsx(bs,{node:o,path:a,index:i,...l})]},o.id)),n.jsx(Et,{path:a,index:r.length,dragActive:l.dragActive,compact:!0,onInsert:l.onInsert}),r.length===0&&n.jsx("div",{className:"text-[11px] text-slate-400 text-center pb-1 -mt-1",children:"empty â this path just ends"})]}),Oa=(e,t,s,r,a,l)=>{const o=t==="event"?e?{text:`When ${e.label.toLowerCase()}`,ok:!0}:{text:"When ⦠(pick a trigger)",ok:!1}:t==="segment_transition"?s.to_segment?{text:`When someone enters â${s.to_segment}â`,ok:!0}:{text:"When someone enters ⦠(pick a segment)",ok:!1}:{text:s.cron||s.at?`On schedule (${s.cron??s.at})`:"On schedule ⦠(set it)",ok:!!(s.cron||s.at)},i=r.map(c=>{const u=mn(c);switch(c.kind){case"wait":return{text:`wait ${gs(c.duration_seconds)}`,ok:!u};case"send_email":{const p=a.find(m=>c.template_id?m.id===c.template_id:m.slug===c.template_alias);return{text:p?`send â${p.name}â`:c.template_alias?`send â${c.template_alias}â`:"send ⦠(pick a template)",ok:!u}}case"condition":{const p=l.find(m=>m.key===c.field);return{text:c.field?`split on ${p?.label?.toLowerCase()??c.field} (yes: ${c.on_true.length} step${c.on_true.length===1?"":"s"} / no: ${c.on_false.length})`:"split on ⦠(pick what to check)",ok:!u}}case"update_profile":return{text:"remember data",ok:!u};case"exit":return{text:"done",ok:!0}}});return[o,...i,...r.some(c=>c.kind==="exit")?[]:[{text:"done",ok:!0}]]},Pa=({journeyId:e,onBack:t,onOpenActivity:s})=>{const[r,a]=d.useState(null),[l,o]=d.useState(null),[i,c]=d.useState([]),[u,p]=d.useState([]),[m,b]=d.useState([]),[f,j]=d.useState(!1),[v,N]=d.useState(!1),[E,C]=d.useState(!1),[D,y]=d.useState(null),[_,R]=d.useState(!1),[w,k]=d.use
8State(null),[M,g]=d.useState(null),[S,L]=d.useState(!1),[I,X]=d.useState("edit"),[Ee,De]=d.useState(null),[x,T]=d.useState(null),[F,ae]=d.useState(new Set),ut=d.useCallback(h=>{ae($=>{const A=new Set($);return A.has(h)?A.delete(h):A.add(h),A})},[]),[V,me]=d.useState(null);d.useEffect(()=>{Promise.all([Se(`/api/v1/admin/journeys/${e}`),Se("/api/v1/admin/journeys/field-catalog"),Se("/api/v1/admin/journeys/enforcement"),Se("/api/v1/admin/segments").catch(()=>({segments:[]})),Se("/api/v1/admin/journeys/event-types").catch(()=>({event_types:[]})),Se("/api/v1/admin/journeys/email-templates").catch(()=>({templates:[]}))]).then(([h,$,A,q,B,xe])=>{a({name:h.journey.name,trigger:{type:h.journey.trigger_type,config:h.journey.trigger_config??{}},goal:h.journey.goal_config??null,sequence:$n(h.journey.step_tree),load:{maxSends:h.journey.load_max_sends??1,perDays:h.journey.load_per_days??7,gapHours:h.journey.min_platform_gap_hours??4}}),o($),j(A.enforcement),N(h.journey.shadow_active),C(h.journey.runner_paused),c(q.segments??[]),p(B.event_types??[]),b(xe.templates??[]),Se("/api/v1/admin/journeys/conflicts").then(Ft=>{const Le=Ft.conflicts.find(Ye=>Ye.journeys.some(gt=>gt.id===e));De(Le?`${Le.trigger_type} â â${Le.trigger_key}â (${Le.journeys.length} journeys)`:null)}).catch(()=>{})}).catch(()=>y(["Failed to load journey."]))},[e]);const Y=d.useMemo(()=>r?xa(r):null,[r]),Re=h=>{g(h),window.setTimeout(()=>g(null),2500)},K=d.useCallback(()=>{Y&&(k("validate"),y(null),R(!1),Fe(`/api/v1/admin/journeys/${e}/validate`,"POST",{step_tree:Y}).then(h=>{R(h.valid),y(h.valid?null:h.errors)}).catch(h=>y([h.message])).finally(()=>k(null)))},[Y,e]),ht=()=>{!Y||!r||(k("save"),Fe(`/api/v1/admin/journeys/${e}`,"PUT",{name:r.name,trigger_type:r.trigger.type,trigger_config:r.trigger.config,goal_config:r.goal,load_max_sends:r.load.maxSends,load_per_days:r.load.perDays,min_platform_gap_hours:r.load.gapHours}).then(()=>Fe(`/api/v1/admin/journeys/${e}/save`,"POST",{step_tree:Y})).then(h=>Re(`Saved as version ${h.version_no}`)).catch(h=>y([h.message])).finally(()=>k(null)))},mt=()=>{Y&&(k("publish"),Fe(`/api/v1/admin/journeys/${e}/publish`,"POST",{step_tree:Y}).then(()=>Re("Published.")).catch(h=>y([h.message])).finally(()=>k(null)))},pt=h=>{k(h);const $=f?h:`shadow-${h}`;Fe(`/api/v1/admin/journeys/${e}/${$}`,"POST").then(A=>{typeof A.runner_paused=="boolean"&&C(A.runner_paused),Re(f?`Journey ${A.status}`:`Shadow runner ${A.runner_paused?"paused":"resumed"} for this journey`)}).catch(A=>y([A.message])).finally(()=>k(null))},G=()=>{k("shadow_active"),Fe(`/api/v1/admin/journeys/${e}/shadow-active`,"POST",{shadow_active:!v}).then(h=>{N(h.shadow_active),Re(h.shadow_active?"Shadow mode enabled â the runner will process this draft":"Shadow mode disabled")}).catch(h=>y([h.message])).finally(()=>k(null))},Je=()=>{X("history"),x===null&&Se(`/api/v1/admin/journeys/${e}/versions`).then(h=>T(h.versions??[])).catch(()=>T([]))},pe=Vs(bn(un,{activationConstraint:{distance:4}}),bn(cn)),Me=d.useCallback((h,$)=>{a(A=>A&&{...A,sequence:Ue(A.sequence,h,$)})},[]),le=d.useCallback((h,$,A)=>{const q=hs(h);Me($,B=>{const xe=[...B];return xe.splice(A,0,q),xe}),ae(B=>new Set(B).add(q.id))},[Me]),Oe=h=>{const $=h.active.data.current;me($?.kind??"wait")},ve=h=>{me(null);const $=h.active.data.current;if(!$)return;const A=String(h.over?.id??"");a(q=>{if(!q)return q;const B=ba(q.sequence,$,A);return B?(B.inserted&&ae(xe=>new Set(xe).add(B.inserted.id)),{...q,sequence:B.seq}):q})};if(!r||!l)return n.jsx("div",{className:"p-10 text-center text-slate-500",children:"Loadingâ¦"});const $e=r.trigger.type==="event"?u.find(h=>h.name===r.trigger.config.event)??null:null,Pe=Gt(r.sequence,m),Ae=Pe.filter(h=>h.severity==="warn").length,te=r.trigger.type==="event"?!!r.trigger.config.event:r.trigger.type==="segment_transition"?!!r.trigger.config.to_segment:!!(r.trigger.config.cron||r.trigger.config.at),ye=r.sequence.length===0||Pe.some(h=>h.severity==="warn")||r.sequence.some(function h($){return mn($)!==null||$.kind==="condition"&&($.on_true.some(h)||$.on_false.some(h))}),de=te?ye?2:_?4:3:1,xt=["Pick a trigger","Add steps","Validate & simulate","Activate in shadow"],ft=de===1?"Start by picking what starts the journey â":de===2?Ae>0?`Fix the ${Ae} warning${Ae===1?"":"s"} below`:"Configure the amber steps â drag from the left to add more":de===3?"Looks complete â run Validate, then Simulate":"Valid â â Save, then enable Shadow to watch it run",Lt=Oa($e,r.trigger.type,r.trigger.config,r.sequence,m,l.fields),It=w!==null?null:ye?"Complete the amber steps (and fix warnings) first â then Simulate walks a real profile through the flow":null;return n.jsxs("div",{className:"max-w-6xl mx-auto pb-32",children:[n.jsxs("button",{onClick:t,className:"inline-flex items-center gap-1 text-[13px] text-slate-400 hover:text-slate-700 mb-1.5",children:[n.jsx(zn,{className:"w-4 h-4"})," All journeys"]}),n.jsxs("div",{className:"flex items-center gap-3 mb-3 flex-wrap",children:[n.jsx("input",{className:"text-[20px] font-bold tracking-tight text-slate-900 bg-transparent border-b border-transparent hover:border-slate-200 focus:border-indigo-400 outline-none min-w-[220px]",value:r.name,onChange:h=>a({...r,name:h.target.value}),"aria-label":"Journey name"}),n.jsxs("div",{className:"ml-auto flex items-center gap-2 flex-wrap",children:[r.trigger.type!=="schedule"&&n.jsxs("button",{onClick:G,disabled:w!==null,title:v?"Runner is processing this draft in shadow â click to disable":"Let the shadow runner process this draft (no real sends)",className:v?`${Ze} !bg-violet-600 hover:!bg-violet-700`:re,children:[n.jsx(Jt,{className:"w-4 h-4"})," ",v?"Shadow active":"Shadow"]}),n.jsxs("button",{onClick:()=>pt(E?"resume":"pause"),disabled:!f&&!v||w!==null,title:f?"Pause/resume this journey":v?"Pause/resume the shadow runner for this journey":"Enables with enforcement, or mark this draft Shadow",className:re,children:[E?n.jsx(Vn,{className:"w-4 h-4"}):n.jsx(_s,{className:"w-4 h-4"})," ",E?"Resume":"Pause"]}),s&&n.jsxs("button",{onClick:s,title:"What this journey actually did â person by person",className:re,children:[n.jsx(qe,{className:"w-4 h-4"})," Activity"]}),n.jsx("div",{className:"inline-flex rounded-lg border border-slate-200 overflow-hidden text-xs",children:[["edit","Edit",null],["map","Map",n.jsx(Hn,{className:"w-3.5 h-3.5"},"m")],["history","History",n.jsx(As,{className:"w-3.5 h-3.5"},"h")]].map(([h,$,A])=>n.jsxs("button",{onClick:()=>h==="history"?Je():X(h),className:`px-2.5 py-1.5 inline-flex items-center gap-1 font-semibold ${I===h?"bg-indigo-600 text-white":"bg-white text-slate-600 hover:bg-slate-50"}`,children:[A,$]},h))})]})]}),n.jsx(In,{children:"Shadow mode â journeys you build here simulate first. No real email goes out until enforcement is on."}),n.jsxs("div",{className:"bg-white border border-slate-200 rounded-xl shadow-sm px-4 py-3 mb-4 flex items-center gap-1 overflow-x-auto","data-testid":"guided-skeleton",children:[xt.map((h,$)=>{const A=$+1,q=A<de?"done":A===de?"now":"todo";return n.jsxs(P.Fragment,{children:[$>0&&n.jsx("span",{className:"w-6 h-px bg-slate-200 flex-none"}),n.jsxs("span",{className:`flex items-center gap-2 px-2.5 py-1 rounded-full flex-none text-[12.5px] font-semibold 9 ${q==="now"?"bg-indigo-600 text-white":q==="done"?"text-emerald-600":"text-slate-400"}`,children:[q==="done"?n.jsx(Be,{className:"w-4 h-4"}):n.jsx("span",{className:`w-4 h-4 rounded-full text-[10px] flex items-center justify-center font-bold ${q==="now"?"bg-white/25":"bg-slate-100"}`,children:A}),h]})]},h)}),n.jsx("span",{className:"ml-auto text-[11.5px] text-slate-400 flex-none pl-3",children:ft})]}),Ee&&n.jsxs("div",{className:"mb-4 bg-amber-50 border border-amber-200 rounded-xl p-3 text-sm text-amber-800 inline-flex items-center gap-2",children:[n.jsx(ke,{className:"w-4 h-4"})," Trigger conflict: another journey shares this trigger (",Ee,"). Both would enroll the same people."]}),D&&n.jsxs("div",{className:"mb-4 bg-red-50 border border-red-200 rounded-xl p-3",children:[n.jsxs("div",{className:"flex items-center gap-1 text-sm font-medium text-red-700 mb-1",children:[n.jsx(ks,{className:"w-4 h-4"})," Validation errors"]}),n.jsx("ul",{className:"list-disc ml-5 text-sm text-red-600",children:D.map((h,$)=>n.jsx("li",{children:h},$))})]}),_&&!D&&n.jsxs("div",{className:"mb-4 text-sm text-emerald-700 inline-flex items-center gap-1",children:[n.jsx(Be,{className:"w-4 h-4"})," Valid â ready to simulate."]}),I==="edit"&&n.jsxs(Vr,{sensors:pe,collisionDetection:Qs,onDragStart:Oe,onDragEnd:ve,children:[n.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[230px_1fr] gap-5 items-start",children:[n.jsxs("div",{className:"md:sticky md:top-4",children:[n.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-400 mb-2",children:"Steps â drag into the flow"}),n.jsx("div",{className:"space-y-2",children:ms.map(h=>n.jsx(_a,{kind:h},h))}),n.jsxs("div",{className:"mt-4 bg-indigo-50 border border-indigo-100 rounded-xl px-3 py-2.5 text-[11.5px] text-indigo-700",children:[n.jsx("b",{children:"Tip:"})," drop a step anywhere a slot lights up, or click a ",n.jsx("b",{children:"+"})," between steps. Works inside condition branches too."]})]}),n.jsxs("div",{children:[n.jsxs("div",{className:`bg-white border rounded-xl shadow-sm px-3.5 py-3 ${te?"border-slate-200":"border-indigo-300 ring-1 ring-indigo-100"}`,children:[n.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[n.jsx("span",{className:"w-9 h-9 rounded-lg bg-indigo-600 text-white flex items-center justify-center flex-none",children:n.jsx(Jt,{className:"w-4 h-4"})}),n.jsxs("div",{className:"flex-1 min-w-[260px]",children:[n.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-400",children:"Trigger â what starts the journey"}),n.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-1",children:[n.jsxs("select",{className:"border border-slate-200 rounded-lg px-2.5 py-1.5 text-[13px] font-semibold",value:r.trigger.type,onCh
9ange:h=>a({...r,trigger:{type:h.target.value,config:{}}}),"aria-label":"Trigger type",children:[n.jsx("option",{value:"event",children:"Event happens"}),n.jsx("option",{value:"segment_transition",children:"Enters a segment"}),n.jsx("option",{value:"schedule",children:"On a schedule"})]}),r.trigger.type==="event"&&n.jsxs("select",{className:"border border-slate-200 rounded-lg px-2.5 py-1.5 text-[13px]",value:r.trigger.config.event??"",onChange:h=>a({...r,trigger:{...r.trigger,config:{event:h.target.value}}}),"aria-label":"Trigger event",children:[n.jsx("option",{value:"",children:"on eventâ¦"}),u.map(h=>n.jsx("option",{value:h.name,children:h.label},h.name))]}),r.trigger.type==="segment_transition"&&n.jsxs("select",{className:"border border-slate-200 rounded-lg px-2.5 py-1.5 text-[13px]",value:r.trigger.config.to_segment??"",onChange:h=>a({...r,trigger:{...r.trigger,config:{...r.trigger.config,to_segment:h.target.value}}}),"aria-label":"Target segment",children:[n.jsx("option",{value:"",children:"enters segmentâ¦"}),i.map(h=>n.jsxs("option",{value:h.key,children:[h.name," (",h.key,")"]},h.key))]}),r.trigger.type==="schedule"&&n.jsx("input",{className:"border border-slate-200 rounded-lg px-2.5 py-1.5 text-[13px]",placeholder:"cron (0 9 * * *) or ISO datetime",value:r.trigger.config.cron??r.trigger.config.at??"",onChange:h=>a({...r,trigger:{...r.trigger,config:h.target.value.includes(" ")?{cron:h.target.value}:{at:h.target.value}}})})]})]}),te&&n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11px] font-semibold text-emerald-600 flex-none",children:[n.jsx(Be,{className:"w-3 h-3"})," Configured"]})]}),$e&&n.jsxs("div",{className:"mt-2.5 md:ml-12 flex items-center gap-1.5 flex-wrap text-[11.5px]",children:[n.jsx("span",{className:"text-slate-500",children:"This event carries:"}),$e.properties.map(h=>n.jsx("code",{className:"px-1.5 py-0.5 rounded border border-emerald-200 bg-emerald-50 text-emerald-700 font-semibold",children:h.name},h.name)),n.jsx("span",{className:"text-slate-400",children:"â email templates can use these"})]})]}),n.jsxs("div",{className:"bg-white border border-slate-200 rounded-xl shadow-sm px-3.5 py-3 mt-3","data-testid":"load-control",children:[n.jsx("div",{className:"text-[11px] font-bold uppercase tracking-wider text-slate-400 mb-1.5",children:"Load control â how hard this journey may push"}),n.jsxs("div",{className:"flex items-center gap-1.5 flex-wrap text-[13px] text-slate-700",children:[n.jsx("span",{children:"Email the same person at most"}),n.jsx("input",{type:"number",min:1,max:50,className:"w-14 border border-slate-200 rounded-lg px-2 py-1 tabular-nums",value:r.load.maxSends,onChange:h=>a({...r,load:{...r.load,maxSends:Math.max(1,Number(h.target.value))}}),"aria-label":"Max journey emails"}),n.jsxs("span",{children:["time",r.load.maxSends===1?"":"s"," per"]}),n.jsx("input",{type:"number",min:1,max:365,className:"w-14 border border-slate-200 rounded-lg px-2 py-1 tabular-nums",value:r.load.perDays,onChange:h=>a({...r,load:{...r.load,perDays:Math.max(1,Number(h.target.value))}}),"aria-label":"Per days window"}),n.jsx("span",{children:"days, and never within"}),n.jsx("input",{type:"number",min:0,max:168,className:"w-14 border border-slate-200 rounded-lg px-2 py-1 tabular-nums",value:r.load.gapHours,onChange:h=>a({...r,load:{...r.load,gapHours:Math.max(0,Number(h.target.value))}}),"aria-label":"Platform gap hours"}),n.jsx("span",{children:"hours of any other email we send them."})]}),n.jsx("div",{className:"text-[11.5px] text-slate-400 mt-1",children:"Journeys don't count against the campaign weekly budget â this card is the whole budget. Template caps apply on top."})]}),r.sequence.map((h,$)=>n.jsxs(P.Fragment,{children:[n.jsx(Et,{path:"",index:$,dragActive:V!==null,onInsert:le}),n.jsx(bs,{node:h,path:"",index:$,catalog:l,templates:m,triggerEvent:$e,lint:Pe,expandedIds:F,dragActive:V!==null,setExpanded:ut,mutate:Me,onInsert:le})]},h.id)),n.jsx(Et,{path:"",index:r.sequence.length,dragActive:V!==null,onInsert:le}),r.sequence.length===0&&n.jsxs("div",{className:"text-center text-[12.5px] text-slate-400 py-2",children:["No steps yet â drag one in from the left, or click the ",n.jsx("b",{children:"+"})," above."]}),n.jsxs("div",{className:"bg-white border border-slate-200 rounded-xl shadow-sm p-4 mt-4",children:[n.jsxs("div",{className:"flex items-center gap-2 mb-1.5",children:[n.jsx(Es,{className:"w-4 h-4 text-emerald-600"}),n.jsx("span",{className:"font-semibold text-slate-700 text-[13px]",children:"Goal â early exit"})]}),n.jsx("p",{className:"text-xs text-slate-400 mb-2",children:"If set, a person who meets this condition exits early (goal reached). Suppression & out-of-segment exits are automatic."}),r.goal?n.jsxs("div",{className:"flex flex-wrap items-center gap-2 text-sm",children:[n.jsxs("select",{className:"border border-slate-200 rounded-lg px-2 py-1 min-w-[160px] text-[13px]",value:r.goal.field,onChange:h=>a({...r,goal:{...r.goal,field:h.target.value}}),"aria-label":"Goal field",children:[n.jsx("option",{value:"",children:"fieldâ¦"}),l.fields.map(h=>n.jsx("option",{value:h.key,children:h.label},h.key))]}),n.jsx("select",{className:"border border-slate-200 rounded-lg px-2 py-1 text-[13px]",value:r.goal.op,onChange:h=>a({...r,goal:{...r.goal,op:h.target.value}}),"aria-label":"Goal operator",children:Object.keys(l.operators).map(h=>n.jsx("option",{value:h,children:l.operators[h]?.label??h},h))}),n.jsx("input",{className:"w-28 border border-slate-200 rounded-lg px-2 py-1 text-[13px]",placeholder:"value",value:r.goal.value,onChange:h=>a({...r,goal:{...r.goal,value:h.target.value}})}),n.jsx("button",{onClick:()=>a({...r,goal:null}),"aria-label":"Remove goal",className:"text-slate-300 hover:text-red-500",children:n.jsx(Rt,{className:"w-4 h-4"})})]}):n.jsxs("button",{onClick:()=>a({...r,goal:{field:"",op:"gte",value:""}}),className:"text-xs text-indigo-600 hover:text-indigo-800 inline-flex items-center gap-1",children:[n.jsx(Dt,{className:"w-3 h-3"})," add goal"]})]})]})]}),n.jsx(ua,{dropAnimation:null,children:V&&n.jsxs("div",{className:"bg-white border-2 border-indigo-400 rounded-xl px-3 py-2.5 shadow-xl flex items-center gap-2.5 w-56",children:[n.jsx("span",{className:`w-8 h-8 rounded-lg flex items-center justify-center ${ge[V].iconBg}`,children:ge[V].icon}),n.jsx("span",{className:"text-[13px] font-semibold text-slate-800",children:ge[V].label})]})})]}),I==="map"&&n.jsx("div",{className:"bg-white border border-slate-200 rounded-xl shadow-sm p-4",children:n.jsx(Tn,{nodes:r.sequence,triggerLabel:`${r.trigger.type}${r.trigger.config.to_segment?` â ${r.trigger.config.to_segment}`:r.trigger.config.event?` · ${r.trigger.config.event}`:""}`})}),I==="history"&&n.jsxs("div",{className:"bg-white border border-slate-200 rounded-xl shadow-sm p-4 text-sm",children:[n.jsx("div",{className:"text-xs text-slate-400 mb-2",children:"Immutable version snapshots (view-only; restore is v2)."}),x===null?n.jsx("div",{className:"text-slate-400",children:"Loadingâ¦"}):x.length===0?n.jsx("div",{className:"text-slate-400",children:"No saved versions yet â Save creates the first one."}):n.jsx("ul",{className:"space-y-4",children:x.map(h=>n.jsxs("li",{className:"border-b border-slate-100 pb-3 last:border-0",children:[n.jsxs("div",{className:"text-xs text-slate-500 mb-1",children:["v",h.version_no," · ",new Date(h.created_at).toLocaleStr
9ing()]}),n.jsx(Tn,{nodes:$n(h.step_tree)})]},h.version_no))})]}),I==="edit"&&n.jsx("div",{className:"fixed bottom-0 left-0 right-0 bg-white/95 backdrop-blur border-t border-slate-200 px-6 py-2.5 z-20",children:n.jsxs("div",{className:"max-w-6xl mx-auto",children:[n.jsxs("div",{className:"flex items-center gap-2 flex-wrap text-[12.5px] mb-1.5","data-testid":"summary-strip",children:[n.jsx(yt,{kind:"shadow"}),n.jsx("span",{className:"font-bold uppercase tracking-wider text-[10px] text-slate-400 mr-1",children:"Your journey"}),Lt.map((h,$)=>n.jsxs(P.Fragment,{children:[$>0&&n.jsx("span",{className:"text-slate-300",children:"â"}),n.jsx("span",{className:h.ok?"text-slate-700 font-medium":"text-amber-600 font-medium",children:h.text})]},$))]}),n.jsxs("div",{className:"flex items-center gap-2",children:[M&&n.jsx("span",{className:"text-[13px] text-emerald-700",children:M}),n.jsxs("div",{className:"ml-auto flex gap-2",children:[n.jsxs("button",{onClick:K,disabled:w!==null,className:`${re} ${ie}`,children:[w==="validate"?n.jsx(st,{className:"w-4 h-4 animate-spin"}):n.jsx(Be,{className:"w-4 h-4"})," Validate"]}),n.jsxs("button",{onClick:()=>L(!0),disabled:w!==null||ye,title:It??"Walk a real profile through this flow â nothing sends",className:`${re} ${ie}`,children:[n.jsx(Bn,{className:"w-4 h-4"})," Simulate"]}),n.jsxs("button",{onClick:ht,disabled:w!==null,className:`${Ze} ${ie}`,children:[w==="save"?n.jsx(st,{className:"w-4 h-4 animate-spin"}):n.jsx(Ds,{className:"w-4 h-4"})," Save"]}),n.jsxs("button",{onClick:mt,disabled:!f||w!==null,title:f?"Publish this journey â it starts enrolling for real":"Publish enables when enforcement is switched on. Until then, use Shadow to watch it run safely.",className:`${Ze} ${ie} !bg-emerald-600 hover:!bg-emerald-700`,children:[n.jsx(Rs,{className:"w-4 h-4"})," Publish"]})]})]})]})}),S&&Y&&n.jsx($a,{journeyId:e,stepTree:Y,onClose:()=>L(!1)})]})},On=async e=>{const t=localStorage.getItem("auth_token"),s=await fetch(e,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});if(!s.ok)throw new Error(`Request failed (${s.status})`);return s.json()},La={enrolled:{badge:"ENROLLED",badgeCls:"bg-blue-50 text-blue-600",avatarCls:"bg-blue-50 text-blue-600"},wait:{badge:"WAITING",badgeCls:"bg-amber-50 text-amber-600",avatarCls:"bg-amber-50 text-amber-600"},would_send:{badge:"WOULD SEND",badgeCls:"bg-emerald-50 text-emerald-600",avatarCls:"bg-emerald-50 text-emerald-600"},would_hold_quota:{badge:"HELD",badgeCls:"bg-red-50 text-red-600",avatarCls:"bg-red-50 text-red-600"},would_hold_frequency:{badge:"HELD (FREQUENCY)",badgeCls:"bg-amber-50 text-amber-600",avatarCls:"bg-amber-50 text-amber-600"},would_hold_gap:{badge:"HELD (GAP)",badgeCls:"bg-amber-50 text-amber-600",avatarCls:"bg-amber-50 text-amber-600"},would_hold_cap:{badge:"HELD (CAP)",badgeCls:"bg-red-50 text-red-600",avatarCls:"bg-red-50 text-red-600"},condition:{badge:"CHECKED",badgeCls:"bg-violet-50 text-violet-600",avatarCls:"bg-violet-50 text-violet-600"},update_profile:{badge:"UPDATED",badgeCls:"bg-slate-100 text-slate-500",avatarCls:"bg-slate-100 text-slate-500"},exit:{badge:"FINISHED",badgeCls:"bg-slate-100 text-slate-500",avatarCls:"bg-slate-100 text-slate-500"},aborted:{badge:"STOPPED",badgeCls:"bg-red-50 text-red-600",avatarCls:"bg-red-50 text-red-600"}},Ht=e=>La[e]??{badge:e.replaceAll("_"," ").toUpperCase(),badgeCls:"bg-slate-100 text-slate-500",avatarCls:"bg-slate-100 text-slate-500"},Ia=e=>{const t=e.split("@")[0]??"",s=t.split(/[._\-+]/).filter(Boolean);return((s.length>=2?s[0][0]+s[1][0]:t.slice(0,2))||"?").toUpperCase()},Fa=e=>e?new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):"",Ba=e=>{const t=e.meta??{};switch(e.event){case"enrolled":{const s=typeof t.petition_title=="string"?t.petition_title:null;return s?n.jsxs(n.Fragment,{children:["Joined â signed ",n.jsxs("b",{className:"text-slate-800 font-semibold",children:["â",s.length>60?`${s.slice(0,60)}â¦`:s,"â"]})]}):typeof t.to_segment=="string"?n.jsxs(n.Fragment,{children:["Joined â entered segment ",n.jsx("b",{className:"text-slate-800 font-semibold",children:t.to_segment})]}):n.jsx(n.Fragment,{children:"Joined the journey"})}case"wait":{const s=typeof t.duration_seconds=="number"?t.duration_seconds:null,r=s===null?"a while":s%86400===0?`${s/86400} day${s===86400?"":"s"}`:s%3600===0?`${s/3600} hour${s===3600?"":"s"}`:`${Math.round(s/60)} min`,a=typeof t.resume_at=="string"?Fa(t.resume_at):null;return n.jsxs(n.Fragment,{children:["Started a ",r," wait",a?n.jsxs(n.Fragment,{children:[" â continues automatically at ",n.jsx("b",{className:"text-slate-800 font-semibold",children:a})]}):""]})}case"would_send":return n.jsxs(n.Fragment,{children:["Would get ",n.jsxs("b",{className:"text-slate-800 font-semibold",children:["â",String(t.template_alias??"email"),"â"]}
9)," â shadow only, no real email"]});case"would_hold_quota":return n.jsxs(n.Fragment,{children:["Send held back â ",n.jsx("b",{className:"text-slate-800 font-semibold",children:String(e.reason??"over todayâs quota")})]});case"would_hold_frequency":return n.jsxs(n.Fragment,{children:["Send held â already got ",String(t.count??"?")," email",t.count===1?"":"s"," from this journey in the last ",String(t.window_days??"?")," days (limit ",String(t.max??"?"),")"]});case"would_hold_gap":return n.jsxs(n.Fragment,{children:["Send held â another email went out within the last ",String(t.gap_hours??"?")," hours",typeof t.source=="string"?n.jsxs(n.Fragment,{children:[" (",t.source==="email_logs"?"a real send":"another journey",")"]}):""]});case"would_hold_cap":return n.jsxs(n.Fragment,{children:["Send held back â over this templateâs cap",e.reason?n.jsxs(n.Fragment,{children:[" (",n.jsx("b",{className:"text-slate-800 font-semibold",children:e.reason}),")"]}):""]});case"condition":return n.jsxs(n.Fragment,{children:["Checked ",n.jsx("b",{className:"text-slate-800 font-semibold",children:String(t.field??"a condition")})," â took the ",t.result?"yes":"no"," branch"]});case"update_profile":return n.jsx(n.Fragment,{children:"Updated journey data"});case"exit":return e.reason==="goal_reached"?n.jsx(n.Fragment,{children:"Reached the goal â finished the journey ð"}):n.jsx(n.Fragment,{children:"Reached the end â finished the journey"});case"aborted":return n.jsxs(n.Fragment,{children:["Journey stopped for this person â ",n.jsx("b",{className:"text-slate-800 font-semibold",children:String(e.reason??"unexpected step")})]});default:return e.reason?n.jsx("b",{className:"text-slate-800 font-semibold",children:e.reason}):n.jsx(n.Fragment,{children:e.event.replaceAll("_"," ")})}},za=({journeyId:e,onBack:t})=>{const[s,r]=d.useState("loading"),[a,l]=d.useState(null),[o,i]=d.useState([]),[c,u]=d.useState(null),[p,m]=d.useState(null),[b,f]=d.useState(!1),j=d.useCallback(y=>{const _=new URLSearchParams;p&&_.set("event",p),y&&_.set("before_id",String(y));const R=_.toString();return`/api/v1/admin/journeys/${e}/activity${R?`?${R}`:""}`},[e,p]),v=d.useCallback(()=>{r("loading"),On(j()).then(y=>{l(y),i(y.feed??[]),u(y.next_before_id??null),r("ready")}).catch(()=>r("error"))},[j]);d.useEffect(()=>{v()},[v]);const N=()=>{c!==null&&(f(!0),On(j(c)).then(y=>{i(_=>[..._,...y.feed??[]]),u(y.next_before_id??null)}).catch(()=>{}).finally(()=>f(!1)))},E=a?.summary.enrollments,C=a?.summary.events??{},D=(C.would_hold_quota??0)+(C.would_hold_cap??0)+(C.would_hold_frequency??0)+(C.would_hold_gap??0);return n.jsxs("div",{className:"max-w-5xl mx-auto",children:[n.jsxs("button",{onClick:t,className:"inline-flex items-center gap-1 text-[13px] text-slate-400 hover:text-slate-700 mb-1.5",children:[n.jsx(zn,{className:"w-4 h-4"})," All journeys"]}),n.jsxs("div",{className:"flex items-start gap-3 mb-1.5",children:[n.jsxs("h1",{className:"text-[22px] font-bold tracking-tight text-slate-900",children:[a?a.journey.name:"Journey"," ",n.jsx("span",{className:"text-slate-400 font-medium",children:"· activity"})]}),n.jsx("div",{className:"ml-auto flex items-center gap-2",children:n.jsxs("button",{onClick:v,className:re,children:[n.jsx($s,{className:"w-4 h-4"})," Refresh"]})})]}),n.jsx("p",{className:"text-slate-500 text-[13.5px] max-w-2xl mb-4",children:"Everything this journey actually did, newest first. Each row is one person. Look here after activating a journey, or when a number on the Journeys screen surprises you."}),(a?.journey.shadow_active||a===null)&&n.jsx(In,{}),s==="error"&&n.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200",children:n.jsx(ze,{icon:n.jsx(qe,{className:"w-5 h-5"}),title:"Couldn't load journey activity",body:"The server didn't answer. This is usually temporary.",action:{label:"Try again",onClick:v}})}),s==="loading"&&n.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200",children:n.jsx(Fn,{rows:5})}),s==="ready"&&a&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-4",children:[n.jsx(_e,{tone:E&&E.waiting>0?"warn":"plain",label:"Waiting",value:E?.waiting??0,help:"People currently inside a Wait step â the journey continues them automatically.",sub:"inside a Wait step right now"}),n.jsx(_e,{tone:"plain",label:"Would send",value:C.would_send??0,help:"Emails this journey WOULD have sent. Logged only â nothing was sent.",sub:"shadow sends, logged only"}),n.jsx(_e,{tone:"ok",label:"Completed",value:E?.completed??0,help:"People who reached the end of the journey.",sub:"reached the end"}),n.jsx(_e,{tone:D>0?"warn":"plain",label:"Blocked / held",value:D,help:"Sends the system held back â over a cap or quota. Each feed row says why.",sub:D>0?"see the red rows below for why":"nothing held so far"})]}),n.jsxs("div",{className:"flex flex-wrap gap-2 mb-4",children:[n.jsxs("button",{onClick:()=>m(null),className:`inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-semibold ${p===null?"bg-slate-900 border-slate-900 text-white":"bg-white border-slate-200 text-slate-600 hover:border-slate-400"}`,children:["All ",n.jsx("span",{className:`tabular-nums rounded-full px-1.5 ${p===null?"bg-white/20":"bg-slate-100 text-slate-500"}`,children:Object.values(C).reduce((y,_)=>y+_,0)})]}),Object.entries(C).map(([y,_])=>{const R=p===y;return n.jsxs("button",{onClick:()=>m(R?null:y),className:`inline-flex items-center gap-1.5 rounded-full border px-3 py-1 text-xs font-semibold ${R?"bg-slate-900 border-slate-900 text-white":"bg-white border-slate-200 text-slate-600 hover:border-slate-400"}`,children:[Ht(y).badge.toLowerCase(),n.jsx("span",{className:`tabular-nums rounded-full px-1.5 ${R?"bg-white/20":"bg-slate-100 text-slate-500"}`,children:_})]},y)})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden mb-6",children:[n.jsxs("div",{className:"px-4 py-3 border-b border-slate-200 flex items-center gap-2.5",children:[n.jsx("span",{className:"text-[13px] font-semibold text-slate-700",children:"Activity feed"}),n.jsxs("span",{className:"text-xs text-slate-400",children:[a.summary.last_event_at?`last event ${Vt(a.summary.last_event_at)}`:"no events yet"," · updates every 15 min"]})]}),o.length===0?p?n.jsx(ze,{icon:n.jsx(Ln,{className:"w-5 h-5"}),title:`No â${Ht(p).badge.toLowerCase()}â events yet`,body:"Nothing of this type has happened so far. The runner adds rows as enrollments advance â check back after the next run.",action:{label:"Show all events",onClick:()=>m(null)}}):n.jsx(ze,{icon:n.jsx(qe,{className:"w-5 h-5"}),title:"No activity yet",body:a.journey.trigger_type==="event"?"People enter this journey when its trigger event happens. The runner checks every 15 minutes â data appears here shortly after.":"People enter this journey when they move into
9its target segment (recomputed nightly). Data appears here after the next run."}):n.jsx("ul",{className:"relative before:content-[''] before:absolute before:left-[35px] before:top-0 before:bottom-0 before:w-0.5 before:bg-slate-100",children:o.map(y=>{const _=Ht(y.event);return n.jsxs("li",{className:"flex gap-3.5 px-4 py-2.5 hover:bg-slate-50/70 transition-colors",children:[n.jsx("span",{className:`relative z-10 w-10 h-10 rounded-full flex-none flex items-center justify-center font-bold text-[13px] border-2 border-white ${_.avatarCls}`,children:Ia(y.recipient_email)}),n.jsxs("div",{className:"flex-1 min-w-0",children:[n.jsxs("div",{className:"flex items-baseline gap-2 flex-wrap",children:[n.jsx("span",{className:"font-semibold text-slate-800 truncate",children:y.recipient_email}),n.jsx("span",{className:`text-[10.5px] font-bold tracking-wide px-2 py-0.5 rounded-full ${_.badgeCls}`,children:_.badge}),n.jsx("span",{className:"ml-auto text-xs text-slate-400 whitespace-nowrap",title:new Date(y.occurred_at).toLocaleString(),children:Vt(y.occurred_at)})]}),n.jsx("div",{className:"text-[12.5px] text-slate-500 mt-0.5",children:Ba(y)})]})]},y.id)})}),c!==null&&n.jsx("div",{className:"border-t border-slate-100 px-3 py-2.5 flex justify-center",children:n.jsxs("button",{onClick:N,disabled:b,className:`${re} ${ie}`,children:[b?n.jsx(st,{className:"w-3.5 h-3.5 animate-spin"}):n.jsx(Wn,{className:"w-3.5 h-3.5"})," Show older activity"]})})]})]})]})},bt=async e=>{const t=localStorage.getItem("auth_token"),s=await fetch(e,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json"}});if(!s.ok)throw new Error(`Request failed (${s.status})`);return s.json()},vt=async(e,t,s)=>{const r=localStorage.getItem("auth_token"),a=await fetch(e,{method:t,headers:{Authorization:`Bearer ${r}`,Accept:"application/json","Content-Type":"application/json"},body:s===void 0?void 0:JSON.stringify(s)});if(!a.ok)throw new Error(`Request failed (${a.status})`);return a.json()},Pn=e=>e.runner_paused?"paused":e.status==="active"?"live":e.shadow_active?"shadow":"draft",qa=({j:e})=>e.trigger_type==="event"&&e.trigger_config?.event?n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11.5px] font-semibold px-2 py-0.5 rounded-full bg-blue-50 text-blue-600",children:["â¡ ",e.trigger_config.event.replaceAll("_"," ")]}):e.trigger_type==="segment_transition"&&e.trigger_config?.to_segment?n.jsxs("span",{className:"inline-flex items-center gap-1 text-[11.5px] font-semibold px-2 py-0.5 rounded-full bg-slate-100 text-slate-600",children:["â enters segment: ",e.trigger_config.to_segment]}):n.jsx("span",{className:"text-xs text-slate-400",children:"not configured"}),pl=()=>{const[e,t]=d.useState("loading"),[s,r]=d.useState(null),[a,l]=d.useState([]),[o,i]=d.useState([]),[c,u]=d.useState(null),[p,m]=d.useState(null),[b,f]=d.useState(null),[j,v]=d.useState(!1),[N,E]=d.useState(!1),[C,D]=d.useState(!1),[y,_]=d.useState(!1),R=d.useCallback(()=>{t("loading"),Promise.all([bt("/api/v1/admin/journeys"),bt("/api/v1/admin/journeys/conflicts").catch(()=>({conflicts:[]})),bt("/api/v1/admin/segments").catch(()=>({segments:[]})),bt("/api/v1/admin/orchestration/journey-runner/status").catch(()=>({paused:!1}))]).then(([x,T,F,ae])=>{r(x),l(T.conflicts??[]),i(F.segments??[]),D(ae.paused),t("ready")}).catch(()=>t("error"))},[]);d.useEffect(()=>{c===null&&p===null&&R()},[c,p,R]);const w=()=>{_(!0),vt(`/api/v1/admin/orchestration/journey-runner/${C?"resume":"pause"}`,"POST").then(T=>D(T.paused)).catch(()=>window.alert("Failed to toggle the journey runner.")).finally(()=>_(!1))},k=()=>{v(!0),vt("/api/v1/admin/journeys","POST",{name:"Untitled journey",trigger_type:"event",trigger_config:{}}).then(x=>u(x.journey.id)).catch(()=>t("error")).finally(()=>v(!1))},M=x=>{vt(`/api/v1/admin/journeys/${x}/duplicate`,"POST").then(T=>u(T.journey.id)).catch(()=>t("error"))},g=x=>{const T=x.active_enrollments>0?` Its ${x.active_enrollments} current enrollments are removed too.`:"";window.confirm(`Delete â${x.name}â? 10This removes the draft and cannot be undone.${T}`)&&vt(`/api/v1/admin/journeys/${x.id}`,"DELETE").then(R).catch(()=>window.alert("Only draft journeys can be deleted."))};if(p!==null)return n.jsx("div",{className:"min-h-screen bg-slate-50 p-6",children:n.jsx(za,{journeyId:p,onBack:()=>m(null)})});if(c!==null)return n.jsx("div",{className:"min-h-screen bg-slate-50 p-6",children:n.jsx(Pa,{journeyId:c,onBack:()=>u(null),onOpenActivity:()=>m(c)})});
10const S=s?.journeys??[],L=S.filter(x=>x.shadow_active).length,I=S.reduce((x,T)=>x+(T.active_enrollments??0),0),X=S.reduce((x,T)=>x+(T.would_send_7d??0),0),Ee=x=>S.filter(T=>T.trigger_type==="segment_transition"&&T.trigger_config?.to_segment===x),De=S.filter(x=>x.trigger_type!=="segment_transition");return n.jsx("div",{className:"min-h-screen bg-slate-50 p-6",children:n.jsxs("div",{className:"max-w-6xl mx-auto",children:[n.jsxs("div",{className:"flex items-start gap-3 mb-1.5",children:[n.jsx("h1",{className:"text-[22px] font-bold tracking-tight text-slate-900",children:"Journeys"}),n.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[n.jsxs("button",{onClick:w,disabled:y,title:C?"Resume the shadow journey runner (all journeys)":"Pause the shadow journey runner (all journeys) â instant, no deploy",className:re+(C?" !text-red-600 !border-red-200 !bg-red-50":""),children:[C?n.jsx(Vn,{className:"w-4 h-4"}):n.jsx(yt,{kind:C?"paused":"shadow"}),"Runner: ",C?"paused":"running"]}),n.jsxs("button",{onClick:k,disabled:j,className:Ze,children:[j?n.jsx(st,{className:"w-4 h-4 animate-spin"}):n.jsx(Dt,{className:"w-4 h-4"})," New journey"]})]})]}),n.jsxs("p",{className:"text-slate-500 text-[13.5px] max-w-2xl mb-5",children:["Automated email sequences â a trigger enrolls a person, steps run over days. Everything runs in shadow: the system logs what it ",n.jsx("em",{children:"would"})," send, but no real email goes out until enforcement is switched on."]}),e==="error"&&n.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200",children:n.jsx(ze,{icon:n.jsx(ke,{className:"w-5 h-5"}),title:"Couldn't load journeys",body:"The server didn't answer. This is usually temporary.",action:{label:"Try again",onClick:R}})}),e==="loading"&&n.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200",children:n.jsx(Fn,{rows:4})}),e==="ready"&&s&&!s.activated&&n.jsx("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200",children:n.jsx(ze,{icon:n.jsx(qe,{className:"w-5 h-5"}),title:"Journeys aren't set up yet",body:"The journey tables are created during the nightly run. Check back tomorrow morning."})}),e==="ready"&&s?.activated&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3 mb-5",children:[n.jsx(_e,{tone:"shadow",label:"In shadow",value:L,help:"Journeys the runner is actively simulating â enrolling real people, sending nothing.",sub:`of ${S.length} journeys · simulating, not sending`}),n.jsx(_e,{tone:I>0?"warn":"plain",label:"People in journeys",value:I,help:"Live enrollments right now â currently inside a step or waiting for one.",sub:"currently inside a step or waiting"}),n.jsx(_e,{tone:"plain",label:"Shadow sends · 7d",value:X,help:"Emails the journeys WOULD have sent in the last 7 days. Zero real emails were sent.",sub:"would-send events, logged only"}),n.jsx(_e,{tone:a.length>0?"warn":"ok",label:"Needs attention",value:a.length>0?a.length:n.jsx(Be,{className:"w-7 h-7 text-emerald-600","aria-label":"all clear"}),help:"Trigger conflicts â two journeys enrolling the same people from the same trigger.",sub:a.length>0?"trigger conflicts â see below":"no conflicts"})]}),n.jsx(Ss,{}),a.length>0&&n.jsxs("div",{className:"bg-amber-50 border border-amber-200 rounded-xl p-4 mb-4",children:[n.jsxs("div",{className:"text-sm font-semibold text-amber-800 inline-flex items-center gap-1.5 mb-2",children:[n.jsx(ke,{className:"w-4 h-4"})," ",a.length," trigger conflict",a.length===1?"":"s"," â these journeys enroll the same people"]}),n.jsx("ul",{className:"text-[13px] text-amber-800 space-y-1",children:a.map((x,T)=>n.jsxs("li",{children:[n.jsxs("span",{className:"font-medium",children:[x.trigger_type," â â",x.trigger_key,"â"]}),": ",x.journeys.map(F=>F.name).join(", ")]},T))})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 mb-4",children:[n.jsxs("button",{onClick:()=>E(x=>!x),className:"w-full px-4 py-3 flex items-center gap-2 text-[13px] font-semibold text-slate-700",children:[n.jsx(Hn,{className:"w-4 h-4 text-slate-400"})," Coverage map â which segments have a journey",n.jsx(xn,{className:`w-4 h-4 text-slate-300 transition-transform ${N?"rotate-90":""}`})]}),N&&n.jsxs("div",{className:"px-4 pb-4 grid grid-cols-1 md:grid-cols-2 gap-2",children:[o.map(x=>{const T=Ee(x.key),F=T.length===0?"border-slate-200 bg-slate-50":T.length>1?"border-amber-300 bg-amber-50":"border-emerald-200 bg-emerald-50";return n.jsxs("div",{className:`border rounded-lg p-2 ${F}`,children:[n.jsxs("div",{className:"text-xs font-medium text-slate-700",children:[x.name," ",n.jsx("span",{className:"text-slate-400",children:x.key})]}),T.length===0?n.jsx("div",{className:"text-[11px] text-slate-400",children:"no journey â
10coverage gap"}):n.jsxs("div",{className:"text-[11px] text-slate-600",children:[T.map(ae=>ae.name).join(", "),T.length>1?" â conflict":""]})]},x.key)}),De.length>0&&n.jsxs("div",{className:"border rounded-lg p-2 border-slate-200 bg-white md:col-span-2",children:[n.jsx("div",{className:"text-xs font-medium text-slate-700",children:"Event / schedule triggers (not segment-based)"}),n.jsx("div",{className:"text-[11px] text-slate-600",children:De.map(x=>`${x.name} (${x.trigger_type})`).join(", ")})]})]})]}),n.jsxs("div",{className:"bg-white rounded-xl shadow-sm border border-slate-200 overflow-hidden",children:[n.jsxs("div",{className:"px-4 py-3 border-b border-slate-200 flex items-center gap-2.5",children:[n.jsx("span",{className:"text-[13px] font-semibold text-slate-700",children:"All journeys"}),n.jsxs("span",{className:"text-xs text-slate-400",children:[S.length," journeys"]})]}),S.length===0?n.jsx(ze,{icon:n.jsx($t,{className:"w-5 h-5"}),title:"No journeys yet",body:"A journey enrolls people automatically when something happens â like signing a petition â and emails them over the following days.",action:{label:"ï¼ Create your first journey",onClick:k,primary:!0}}):n.jsx("div",{className:"overflow-x-auto",children:n.jsxs("table",{className:"w-full text-[13.5px]",children:[n.jsx("thead",{children:n.jsxs("tr",{className:"text-left text-[11px] font-bold uppercase tracking-wider text-slate-400 border-b border-slate-200",children:[n.jsx("th",{className:"px-4 py-2.5 w-[34%]",children:"Journey"}),n.jsx("th",{className:"px-4 py-2.5",children:"Trigger"}),n.jsx("th",{className:"px-4 py-2.5 text-right",children:"People"}),n.jsx("th",{className:"px-4 py-2.5 text-right",children:"Would-send · 7d"}),n.jsx("th",{className:"px-4 py-2.5",children:"Last activity"}),n.jsx("th",{className:"px-4 py-2.5 w-[200px]",children:n.jsx("span",{className:"sr-only",children:"Actions"})})]})}),n.jsx("tbody",{children:S.map(x=>{const T=b===x.id;return n.jsxs(P.Fragment,{children:[n.jsxs("tr",{onClick:()=>f(T?null:x.id),className:"group cursor-pointer hover:bg-slate-50/80 border-b border-slate-100 transition-colors",children:[n.jsx("td",{className:"px-4 py-3",children:n.jsxs("span",{className:"flex items-center gap-2.5 font-semibold text-slate-800",children:[n.jsx(xn,{className:`w-3.5 h-3.5 text-slate-300 transition-transform ${T?"rotate-90":""}`}),n.jsx(yt,{kind:Pn(x)}),x.name]})}),n.jsx("td",{className:"px-4 py-3",children:n.jsx(qa,{j:x})}),n.jsx("td",{className:`px-4 py-3 text-right tabular-nums ${x.active_enrollments>0?"font-semibold text-slate-800":"text-slate-400"}`,children:x.active_enrollments>0?x.active_enrollments.toLocaleString():"â"}),n.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-slate-500",children:x.would_send_7d>0?x.would_send_7d.toLocaleString():"â"}),n.jsx("td",{className:"px-4 py-3 text-slate-400 text-[13px]",children:Vt(x.last_activity_at)}),n.jsx("td",{className:"px-4 py-3",children:n.jsxs("div",{className:`flex gap-1.5 justify-end transition-opacity ${T?"opacity-100":"opacity-0 group-hover:opacity-100"}`,children:[n.jsxs("button",{onClick:F=>{F.stopPropagation(),m(x.id)},className:`${re} ${ie}`,title:"What this journey actually did â person by person",children:[n.jsx(qe,{className:"w-3.5 h-3.5"})," Activity"]}),n.jsxs("button",{onClick:F=>{F.stopPropagation(),u(x.id)},className:`${re} ${ie}`,title:"Open in the builder",children:[n.jsx(fn,{className:"w-3.5 h-3.5"})," Edit"]})]})})]}),T&&n.jsx("tr",{className:"border-b border-slate-200",children:n.jsxs("td",{colSpan:6,className:"bg-slate-50/60 px-4 py-4",children:[n.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-2.5 mb-3",children:[n.jsxs("div",{className:"bg-white border border-slate-200 rounded-lg px-3 py-2",children:[n.jsx("div",{className:"text-[10.5px] font-bold uppercase tracking-wider text-slate-400",children:"Status"}),n.jsxs("div",{className:"text-sm font-semibold text-slate-800 flex items-center gap-1.5 mt-0.5",children:[n.jsx(yt,{kind:Pn(x)})," ",x.runner_paused?"paused":x.shadow_active?"shadow":x.status]})]}),n.jsxs("div",{className:"bg-white border border-slate-200 rounded-lg px-3 py-2",children:[n.jsx("div",{className:"text-[10.5px] font-bold uppercase tracking-wider text-slate-400",children:"People now"}),n.jsx("div",{className:"text-lg font-bold tabular-nums text-slate-800",children:x.active_enrollments.toLocaleStr
10ing()})]}),n.jsxs("div",{className:"bg-white border border-slate-200 rounded-lg px-3 py-2",children:[n.jsx("div",{className:"text-[10.5px] font-bold uppercase tracking-wider text-slate-400",children:"Would-send · 7d"}),n.jsx("div",{className:"text-lg font-bold tabular-nums text-slate-800",children:x.would_send_7d.toLocaleString()})]}),n.jsxs("div",{className:"bg-white border border-slate-200 rounded-lg px-3 py-2",children:[n.jsx("div",{className:"text-[10.5px] font-bold uppercase tracking-wider text-slate-400",children:"Version"}),n.jsx("div",{className:"text-lg font-bold tabular-nums text-slate-800",children:x.latest_version>0?`v${x.latest_version}`:"â"})]})]}),n.jsxs("div",{className:"flex gap-2 flex-wrap",children:[n.jsxs("button",{onClick:()=>m(x.id),className:`${Ze} ${ie}`,children:[n.jsx(qe,{className:"w-3.5 h-3.5"})," Open activity"]}),n.jsxs("button",{onClick:()=>u(x.id),className:`${re} ${ie}`,children:[n.jsx(fn,{className:"w-3.5 h-3.5"})," Edit journey"]}),n.jsxs("button",{onClick:()=>M(x.id),className:`${re} ${ie}`,children:[n.jsx(qn,{className:"w-3.5 h-3.5"})," Duplicate"]}),n.jsx("span",{className:"flex-1"}),x.status==="draft"&&n.jsxs("button",{onClick:()=>g(x),className:`${Cs} ${ie}`,children:[n.jsx(Rt,{className:"w-3.5 h-3.5"})," Deleteâ¦"]})]})]})})]},x.id)})})]})})]})]})]})})};export{pl as default}; 11//# sourceMappingURL=JourneysAdmin-D6gbPron.js.map
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.