toolroll 0.9.27 → 0.9.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/agentconfig.js +71 -3
  3. package/dist/browser/workspace.js +3 -3
  4. package/dist/build-review.js +3 -2
  5. package/dist/builder.js +10 -8
  6. package/dist/chat-actions.js +7 -4
  7. package/dist/chat-flow.js +10 -6
  8. package/dist/converse.js +3 -2
  9. package/dist/coordinator-proposals.js +2 -2
  10. package/dist/decision.d.ts +3 -3
  11. package/dist/decision.js +4 -3
  12. package/dist/desktop-update.d.ts +1 -1
  13. package/dist/evidence.js +1 -1
  14. package/dist/flow-actions.d.ts +1 -0
  15. package/dist/flow-actions.js +6 -7
  16. package/dist/flow-code.d.ts +3 -2
  17. package/dist/flow-code.js +6 -4
  18. package/dist/flow-draft.d.ts +10 -4
  19. package/dist/flow-draft.js +19 -8
  20. package/dist/flow-engine.d.ts +0 -3
  21. package/dist/flow-engine.js +17 -10
  22. package/dist/flow-people.d.ts +0 -1
  23. package/dist/flow-people.js +9 -1
  24. package/dist/flow-send.js +3 -2
  25. package/dist/flow-steps.js +33 -10
  26. package/dist/flows.d.ts +23 -8
  27. package/dist/flows.js +106 -52
  28. package/dist/guides.js +1 -1
  29. package/dist/lead-context.d.ts +3 -9
  30. package/dist/lead-context.js +21 -5
  31. package/dist/lead-status.js +17 -12
  32. package/dist/mate-doors.js +8 -2
  33. package/dist/mate-tools.js +27 -10
  34. package/dist/mate.js +13 -2
  35. package/dist/needs-you.d.ts +2 -2
  36. package/dist/needs-you.js +3 -0
  37. package/dist/operate.d.ts +3 -0
  38. package/dist/operate.js +144 -9
  39. package/dist/phase-routing.d.ts +86 -5
  40. package/dist/phase-routing.js +229 -17
  41. package/dist/process-liveness.d.ts +1 -0
  42. package/dist/process-liveness.js +5 -0
  43. package/dist/project-skills.d.ts +10 -0
  44. package/dist/proposal.d.ts +10 -2
  45. package/dist/proposal.js +25 -10
  46. package/dist/recipe-ui.js +2 -1
  47. package/dist/scout-report.d.ts +10 -4
  48. package/dist/scout-report.js +23 -6
  49. package/dist/scout.d.ts +2 -0
  50. package/dist/scout.js +83 -10
  51. package/dist/serve.js +71 -15
  52. package/dist/setup-guide.d.ts +2 -2
  53. package/dist/store.d.ts +72 -8
  54. package/dist/store.js +230 -29
  55. package/dist/task-sizing.d.ts +78 -0
  56. package/dist/task-sizing.js +228 -0
  57. package/dist/task-text.d.ts +4 -4
  58. package/dist/task-text.js +10 -6
  59. package/dist/teammate-work.js +31 -7
  60. package/dist/teammates.d.ts +20 -1
  61. package/dist/teammates.js +18 -5
  62. package/dist/teams-chat.d.ts +4 -1
  63. package/dist/teams-chat.js +17 -6
  64. package/dist/telegram-flow.js +6 -2
  65. package/dist/test-temp.js +1 -1
  66. package/dist/text-limits.d.ts +67 -0
  67. package/dist/text-limits.js +73 -0
  68. package/dist/tier-report.d.ts +44 -0
  69. package/dist/tier-report.js +71 -0
  70. package/package.json +1 -1
@@ -56,12 +56,12 @@ ${o}`),a.dispatchEvent(new Event("input",{bubbles:!0})),a.scrollIntoView({block:
56
56
  `,`
57
57
  +`).split(`
58
58
  `)),f=c.reduce((u,d)=>u.concat(...d),[]);return[c,f]}return[[],[]]},[e]);return(0,J.useEffect)(()=>{let l=t?.target??rD,c=t?.actInsideInputWithModifier??!0;if(e!==null){let f=p=>{if(o.current=p.ctrlKey||p.metaKey||p.shiftKey||p.altKey,(!o.current||o.current&&!c)&&Aw(p))return!1;let v=iD(p.code,i);if(r.current.add(p[v]),sD(s,r.current,!1)){let b=p.composedPath?.()?.[0]||p.target,x=b?.nodeName==="BUTTON"||b?.nodeName==="A";t.preventDefault!==!1&&(o.current||!x)&&p.preventDefault(),n(!0)}},u=p=>{let g=iD(p.code,i);sD(s,r.current,!0)?(n(!1),r.current.clear()):r.current.delete(p[g]),p.key==="Meta"&&r.current.clear(),o.current=!1},d=()=>{r.current.clear(),n(!1)};return l?.addEventListener("keydown",f),l?.addEventListener("keyup",u),window.addEventListener("blur",d),window.addEventListener("contextmenu",d),()=>{l?.removeEventListener("keydown",f),l?.removeEventListener("keyup",u),window.removeEventListener("blur",d),window.removeEventListener("contextmenu",d)}}},[e,n]),a}function sD(e,t,a){return e.filter(n=>a||n.length===t.size).some(n=>n.every(o=>t.has(o)))}function iD(e,t){return t.includes(e)?"code":"key"}var $$=()=>{let e=vt();return(0,J.useMemo)(()=>({zoomIn:async t=>{let{panZoom:a}=e.getState();return a?a.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:a}=e.getState();return a?a.scaleBy(1/1.2,t):!1},zoomTo:async(t,a)=>{let{panZoom:n}=e.getState();return n?n.scaleTo(t,a):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,a)=>{let{transform:[n,o,r],panZoom:s}=e.getState();return s?(await s.setViewport({x:t.x??n,y:t.y??o,zoom:t.zoom??r},a),!0):!1},getViewport:()=>{let[t,a,n]=e.getState().transform;return{x:t,y:a,zoom:n}},setCenter:async(t,a,n)=>e.getState().setCenter(t,a,n),fitBounds:async(t,a)=>{let{width:n,height:o,minZoom:r,maxZoom:s,panZoom:i}=e.getState(),l=gp(t,n,o,r,s,a?.padding??.1);return i?(await i.setViewport(l,{duration:a?.duration,ease:a?.ease,interpolate:a?.interpolate}),!0):!1},screenToFlowPosition:(t,a={})=>{let{transform:n,snapGrid:o,snapToGrid:r,domNode:s}=e.getState();if(!s)return t;let{x:i,y:l}=s.getBoundingClientRect(),c={x:t.x-i,y:t.y-l},f=a.snapGrid??o,u=a.snapToGrid??r;return wc(c,n,u,f)},flowToScreenPosition:t=>{let{transform:a,domNode:n}=e.getState();if(!n)return t;let{x:o,y:r}=n.getBoundingClientRect(),s=wl(t,a);return{x:s.x+o,y:s.y+r}}}),[])};function AD(e,t){let a=[],n=new Map,o=[];for(let r of e)if(r.type==="add"){o.push(r);continue}else if(r.type==="remove"||r.type==="replace")n.set(r.id,[r]);else{let s=n.get(r.id);s?s.push(r):n.set(r.id,[r])}for(let r of t){let s=n.get(r.id);if(!s){a.push(r);continue}if(s[0].type==="remove")continue;if(s[0].type==="replace"){a.push({...s[0].item});continue}let i={...r};for(let l of s)X$(l,i);a.push(i)}return o.length&&o.forEach(r=>{r.index!==void 0?a.splice(r.index,0,{...r.item}):a.push({...r.item})}),a}function X$(e,t){switch(e.type){case"select":{t.selected=e.selected;break}case"position":{typeof e.position<"u"&&(t.position=e.position),typeof e.dragging<"u"&&(t.dragging=e.dragging);break}case"dimensions":{typeof e.dimensions<"u"&&(t.measured={...e.dimensions},e.setAttributes&&((e.setAttributes===!0||e.setAttributes==="width")&&(t.width=e.dimensions.width),(e.setAttributes===!0||e.setAttributes==="height")&&(t.height=e.dimensions.height))),typeof e.resizing=="boolean"&&(t.resizing=e.resizing);break}}}function jw(e,t){return AD(e,t)}function W$(e,t){return AD(e,t)}function Cl(e,t){return{id:e,type:"select",selected:t}}function kc(e,t=new Set,a=!1){let n=[];for(let[o,r]of e){let s=t.has(o);!(r.selected===void 0&&!s)&&r.selected!==s&&(a&&(r.selected=s),n.push(Cl(r.id,s)))}return n}function lD({items:e=[],lookup:t}){let a=[],n=new Map(e.map(o=>[o.id,o]));for(let[o,r]of e.entries()){let s=t.get(r.id),i=s?.internals?.userNode??s;i!==void 0&&i!==r&&a.push({id:r.id,item:r,type:"replace"}),i===void 0&&a.push({item:r,type:"add",index:o})}for(let[o]of t)n.get(o)===void 0&&a.push({id:o,type:"remove"});return a}function uD(e){return{id:e.id,type:"remove"}}var Y$=Iw("React Flow","https://reactflow.dev/");function K$(e,t,a={}){return v6(e,t,{...a,onError:a.onError??Y$})}var cD=e=>l6(e),Z$=e=>bw(e);function DD(e){return(0,J.forwardRef)(e)}var _D=typeof window<"u"?J.useLayoutEffect:J.useEffect;function dD(e){let[t,a]=(0,J.useState)(BigInt(0)),[n]=(0,J.useState)(()=>Q$(()=>a(o=>o+BigInt(1))));return _D(()=>{let o=n.get();o.length&&(e(o),n.reset())},[t]),n}function Q$(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:a=>{t.push(a),e()}}}var PD=(0,J.createContext)(null);function J$({children:e}){let t=vt(),a=(0,J.useCallback)(i=>{let{nodes:l=[],setNodes:c,hasDefaultNodes:f,onNodesChange:u,nodeLookup:d,fitViewQueued:p,onNodesChangeMiddlewareMap:g}=t.getState(),v=l;for(let x of i)v=typeof x=="function"?x(v):x;let b=lD({items:v,lookup:d});for(let x of g.values())b=x(b);f&&c(v),b.length>0?u?.(b):p&&window.requestAnimationFrame(()=>{let{fitViewQueued:x,nodes:y,setNodes:h}=t.getState();x&&h(y)})},[]),n=dD(a),o=(0,J.useCallback)(i=>{let{edges:l=[],setEdges:c,hasDefaultEdges:f,onEdgesChange:u,edgeLookup:d}=t.getState(),p=l;for(let g of i)p=typeof g=="function"?g(p):g;f?c(p):u&&u(lD({items:p,lookup:d}))},[]),r=dD(o),s=(0,J.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,Y.jsx)(PD.Provider,{value:s,children:e})}function eX(){let e=(0,J.useContext)(PD);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}var tX=e=>!!e.panZoom;function vp(){let e=$$(),t=vt(),a=eX(),n=je(tX),o=(0,J.useMemo)(()=>{let r=u=>t.getState().nodeLookup.get(u),s=u=>{a.nodeQueue.push(u)},i=u=>{a.edgeQueue.push(u)},l=u=>{let{nodeLookup:d,nodeOrigin:p}=t.getState(),g=cD(u)?u:d.get(u.id),v=g.parentId?Rw(g.position,g.measured,g.parentId,d,p):g.position,b={...g,position:v,width:g.measured?.width??g.width,height:g.measured?.height??g.height};return yc(b)},c=(u,d,p={replace:!1})=>{s(g=>g.map(v=>{if(v.id===u){let b=typeof d=="function"?d(v):d;return p.replace&&cD(b)?b:{...v,...b}}return v}))},f=(u,d,p={replace:!1})=>{i(g=>g.map(v=>{if(v.id===u){let b=typeof d=="function"?d(v):d;return p.replace&&Z$(b)?b:{...v,...b}}return v}))};return{getNodes:()=>t.getState().nodes.map(u=>({...u})),getNode:u=>r(u)?.internals.userNode,getInternalNode:r,getEdges:()=>{let{edges:u=[]}=t.getState();return u.map(d=>({...d}))},getEdge:u=>t.getState().edgeLookup.get(u),setNodes:s,setEdges:i,addNodes:u=>{let d=Array.isArray(u)?u:[u];a.nodeQueue.push(p=>[...p,...d])},addEdges:u=>{let d=Array.isArray(u)?u:[u];a.edgeQueue.push(p=>[...p,...d])},toObject:()=>{let{nodes:u=[],edges:d=[],transform:p}=t.getState(),[g,v,b]=p;return{nodes:u.map(x=>({...x})),edges:d.map(x=>({...x})),viewport:{x:g,y:v,zoom:b}}},deleteElements:async({nodes:u=[],edges:d=[]})=>{let{nodes:p,edges:g,onNodesDelete:v,onEdgesDelete:b,triggerNodeChanges:x,triggerEdgeChanges:y,onDelete:h,onBeforeDelete:w}=t.getState(),{nodes:S,edges:C}=await d6({nodesToRemove:u,edgesToRemove:d,nodes:p,edges:g,onBeforeDelete:w}),I=C.length>0,L=S.length>0;if(I){let N=C.map(uD);b?.(C),y(N)}if(L){let N=S.map(uD);v?.(S),x(N)}return(L||I)&&h?.({nodes:S,edges:C}),{deletedNodes:S,deletedEdges:C}},getIntersectingNodes:(u,d=!0,p)=>{let g=Lw(u),v=g?u:l(u),b=p!==void 0;return v?(p||t.getState().nodes).filter(x=>{let y=t.getState().nodeLookup.get(x.id);if(y&&!g&&(x.id===u.id||!y.internals.positionAbsolute))return!1;let h=yc(b?x:y),w=hp(h,v);return d&&w>0||w>=h.width*h.height||w>=v.width*v.height}):[]},isNodeIntersecting:(u,d,p=!0)=>{let v=Lw(u)?u:l(u);if(!v)return!1;let b=hp(v,d);return p&&b>0||b>=d.width*d.height||b>=v.width*v.height},updateNode:c,updateNodeData:(u,d,p={replace:!1})=>{c(u,g=>{let v=typeof d=="function"?d(g):d;return p.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},p)},updateEdge:f,updateEdgeData:(u,d,p={replace:!1})=>{f(u,g=>{let v=typeof d=="function"?d(g):d;return p.replace?{...g,data:v}:{...g,data:{...g.data,...v}}},p)},getNodesBounds:u=>{let{nodeLookup:d,nodeOrigin:p}=t.getState();return Sw(u,{nodeLookup:d,nodeOrigin:p})},getHandleConnections:({type:u,id:d,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}-${u}${d?`-${d}`:""}`)?.values()??[]),getNodeConnections:({type:u,handleId:d,nodeId:p})=>Array.from(t.getState().connectionLookup.get(`${p}${u?d?`-${u}-${d}`:`-${u}`:""}`)?.values()??[]),fitView:async u=>{let d=t.getState().fitViewResolver??m6();return t.setState({fitViewQueued:!0,fitViewOptions:u,fitViewResolver:d}),a.nodeQueue.push(p=>[...p]),d.promise}}},[]);return(0,J.useMemo)(()=>({...o,...e,viewportInitialized:n}),[n])}var fD=e=>e.selected,aX=typeof window<"u"?window:void 0;function nX({deleteKeyCode:e,multiSelectionKeyCode:t}){let a=vt(),{deleteElements:n}=vp(),o=xp(e,{actInsideInputWithModifier:!1}),r=xp(t,{target:aX});(0,J.useEffect)(()=>{if(o){let{edges:s,nodes:i}=a.getState();n({nodes:i.filter(fD),edges:s.filter(fD)}),a.setState({nodesSelectionActive:!1})}},[o]),(0,J.useEffect)(()=>{a.setState({multiSelectionActive:r})},[r])}function oX(e){let t=vt();(0,J.useEffect)(()=>{let a=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=gx(e.current);(n.height===0||n.width===0)&&t.getState().onError?.("004",_n.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){a(),window.addEventListener("resize",a);let n=new ResizeObserver(()=>a());return n.observe(e.current),()=>{window.removeEventListener("resize",a),n&&e.current&&n.unobserve(e.current)}}},[])}var Ex={position:"absolute",width:"100%",height:"100%",top:0,left:0},rX=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function sX({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:a=!0,panOnScroll:n=!1,panActivationKeyPressed:o,panOnScrollSpeed:r=.5,panOnScrollMode:s=zr.Free,zoomOnDoubleClick:i=!0,panOnDrag:l=!0,defaultViewport:c,translateExtent:f,minZoom:u,maxZoom:d,zoomActivationKeyCode:p,preventScrolling:g=!0,children:v,noWheelClassName:b,noPanClassName:x,onViewportChange:y,isControlledViewport:h,paneClickDistance:w,selectionOnDrag:S}){let C=vt(),I=(0,J.useRef)(null),{userSelectionActive:L,lib:N,connectionInProgress:P}=je(rX,kt),O=xp(p),B=(0,J.useRef)();oX(I);let U=(0,J.useCallback)(R=>{y?.({x:R[0],y:R[1],zoom:R[2]}),h||C.setState({transform:R})},[y,h]);return(0,J.useEffect)(()=>{if(I.current){B.current=P6({domNode:I.current,minZoom:u,maxZoom:d,translateExtent:f,viewport:c,onDraggingChange:A=>C.setState(H=>H.paneDragging===A?H:{paneDragging:A}),onPanZoomStart:(A,H)=>{let{onViewportChangeStart:V,onMoveStart:D}=C.getState();D?.(A,H),V?.(H)},onPanZoom:(A,H)=>{let{onViewportChange:V,onMove:D}=C.getState();D?.(A,H),V?.(H)},onPanZoomEnd:(A,H)=>{let{onViewportChangeEnd:V,onMoveEnd:D}=C.getState();D?.(A,H),V?.(H)}});let{x:R,y:E,zoom:M}=B.current.getViewport();return C.setState({panZoom:B.current,transform:[R,E,M],domNode:I.current.closest(".react-flow")}),()=>{B.current?.destroy()}}},[]),(0,J.useEffect)(()=>{B.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:a,panOnScroll:n,panActivationKeyPressed:o,panOnScrollSpeed:r,panOnScrollMode:s,zoomOnDoubleClick:i,panOnDrag:l,zoomActivationKeyPressed:O,preventScrolling:g,noPanClassName:x,userSelectionActive:L,noWheelClassName:b,lib:N,onTransformChange:U,connectionInProgress:P,selectionOnDrag:S,paneClickDistance:w})},[e,t,a,n,o,r,s,i,l,O,g,x,L,b,N,U,P,S,w]),(0,Y.jsx)("div",{className:"react-flow__renderer",ref:I,style:Ex,children:v})}var iX=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function lX(){let{userSelectionActive:e,userSelectionRect:t}=je(iX,kt);return e&&t?(0,Y.jsx)("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var Uw=(e,t)=>a=>{a.target===t.current&&e?.(a)},uX=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function cX({isSelecting:e,selectionKeyPressed:t,selectionMode:a=yl.Full,panOnDrag:n,autoPanOnSelection:o,paneClickDistance:r,selectionOnDrag:s,onSelectionStart:i,onSelectionEnd:l,onPaneClick:c,onPaneContextMenu:f,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:p,onPaneMouseLeave:g,children:v}){let b=(0,J.useRef)(0),x=vt(),{userSelectionActive:y,elementsSelectable:h,dragging:w,panBy:S,autoPanSpeed:C}=je(uX,kt),I=h&&(e||y),L=(0,J.useRef)(null),N=(0,J.useRef)(),P=(0,J.useRef)(new Set),O=(0,J.useRef)(new Set),B=(0,J.useRef)(!1),U=(0,J.useRef)(!1),R=(0,J.useRef)({x:0,y:0}),E=(0,J.useRef)(!1),M=q=>{if(U.current||B.current||x.getState().connection.inProgress){U.current=!1,B.current=!1;return}c?.(q),x.getState().resetSelectedElements(),x.setState({nodesSelectionActive:!1})},A=q=>{if(Array.isArray(n)&&n?.includes(2)){q.preventDefault();return}f?.(q)},H=u?q=>u(q):void 0,V=q=>{U.current&&(q.stopPropagation(),U.current=!1)},D=q=>{if(q.pointerType==="touch"&&n!==!1&&!t)return;let{domNode:W,transform:ce}=x.getState();if(N.current=W?.getBoundingClientRect(),!N.current)return;let de=q.target===L.current;if(!de&&!!q.target.closest(".nokey")||!e||!(s&&de||t)||q.button!==0||!q.isPrimary)return;q.target?.setPointerCapture?.(q.pointerId),U.current=!1;let{x:ie,y:Z}=no(q.nativeEvent,N.current),Le=wc({x:ie,y:Z},ce);x.setState({userSelectionRect:{width:0,height:0,startX:Le.x,startY:Le.y,x:ie,y:Z}}),de||(q.stopPropagation(),q.preventDefault())};function Q(q,W){let{userSelectionRect:ce}=x.getState();if(!ce)return;let{transform:de,nodeLookup:F,edgeLookup:G,connectionLookup:ie,triggerNodeChanges:Z,triggerEdgeChanges:Le,defaultEdgeOptions:Be}=x.getState(),yt={x:ce.startX,y:ce.startY},{x:rt,y:Vt}=wl(yt,de),Ge={startX:yt.x,startY:yt.y,x:q<rt?q:rt,y:W<Vt?W:Vt,width:Math.abs(q-rt),height:Math.abs(W-Vt)},tt=P.current,za=O.current;P.current=new Set(fx(F,Ge,de,a===yl.Partial,!0).map(xn=>xn.id)),O.current=new Set;let Nt=Be?.selectable??!0;for(let xn of P.current){let so=ie.get(xn);if(so)for(let{edgeId:Za}of so.values()){let rr=G.get(Za);rr&&(rr.selectable??Nt)&&O.current.add(Za)}}if(!Tw(tt,P.current)){let xn=kc(F,P.current,!0);Z(xn)}if(!Tw(za,O.current)){let xn=kc(G,O.current);Le(xn)}x.setState({userSelectionRect:Ge,userSelectionActive:!0,nodesSelectionActive:!1})}function K(){if(!o||!N.current)return;let[q,W]=px(R.current,N.current,C);S({x:q,y:W}).then(ce=>{if(!U.current||!ce){b.current=requestAnimationFrame(K);return}let{x:de,y:F}=R.current;Q(de,F),b.current=requestAnimationFrame(K)})}let ue=()=>{cancelAnimationFrame(b.current),b.current=0,E.current=!1};(0,J.useEffect)(()=>()=>ue(),[]);let re=q=>{let{userSelectionRect:W,transform:ce,resetSelectedElements:de}=x.getState();if(!N.current||!W)return;let{x:F,y:G}=no(q.nativeEvent,N.current);R.current={x:F,y:G};let ie=wl({x:W.startX,y:W.startY},ce);if(!U.current){let Z=t?0:r;if(Math.hypot(F-ie.x,G-ie.y)<=Z)return;de(),i?.(q)}U.current=!0,E.current||(K(),E.current=!0),Q(F,G)},se=q=>{if(!I){q.target===L.current&&x.getState().connection.inProgress&&(B.current=!0);return}q.button===0&&(q.target?.releasePointerCapture?.(q.pointerId),!y&&q.target===L.current&&x.getState().userSelectionRect&&M?.(q),x.setState({userSelectionActive:!1,userSelectionRect:null}),U.current&&(l?.(q),x.setState({nodesSelectionActive:P.current.size>0})),ue())},_=q=>{q.target?.releasePointerCapture?.(q.pointerId),ue()},ne=n===!0||Array.isArray(n)&&n.includes(0);return(0,Y.jsxs)("div",{className:At(["react-flow__pane",{draggable:ne,dragging:w,selection:e}]),onClick:I?void 0:Uw(M,L),onContextMenu:Uw(A,L),onWheel:Uw(H,L),onPointerEnter:I?void 0:d,onPointerMove:I?re:p,onPointerUp:se,onPointerCancel:I?_:void 0,onPointerDownCapture:I?D:void 0,onClickCapture:I?V:void 0,onPointerLeave:g,ref:L,style:Ex,children:[v,(0,Y.jsx)(lX,{})]})}function Gw({id:e,store:t,unselect:a=!1,nodeRef:n}){let{addSelectedNodes:o,unselectNodesAndEdges:r,multiSelectionActive:s,nodeLookup:i,onError:l}=t.getState(),c=i.get(e);if(!c){l?.("012",_n.error012(e));return}t.setState({nodesSelectionActive:!1}),c.selected?(a||c.selected&&s)&&(r({nodes:[c],edges:[]}),requestAnimationFrame(()=>n?.current?.blur())):o([e])}function OD({nodeRef:e,disabled:t=!1,noDragClassName:a,handleSelector:n,nodeId:o,isSelectable:r,nodeClickDistance:s}){let i=vt(),[l,c]=(0,J.useState)(!1),f=(0,J.useRef)();return(0,J.useEffect)(()=>{if(!t)return f.current=N6({getStoreItems:()=>i.getState(),onNodeMouseDown:u=>{Gw({id:u,store:i,nodeRef:e})},onDragStart:()=>{c(!0)},onDragStop:()=>{c(!1)}}),()=>{f.current?.destroy(),f.current=void 0}},[t,i,e]),(0,J.useEffect)(()=>{t||!e.current||!f.current||f.current.update({noDragClassName:a,handleSelector:n,domNode:e.current,isSelectable:r,nodeId:o,nodeClickDistance:s})},[a,n,t,r,e,o,s]),l}var dX=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function zD(){let e=vt();return(0,J.useCallback)(a=>{let{nodeExtent:n,snapToGrid:o,snapGrid:r,nodesDraggable:s,onError:i,updateNodePositions:l,nodeLookup:c,nodeOrigin:f}=e.getState(),u=new Map,d=dX(s),p=o?r[0]:5,g=o?r[1]:5,v=a.direction.x*p*a.factor,b=a.direction.y*g*a.factor;for(let[,x]of c){if(!d(x))continue;let y={x:x.internals.positionAbsolute.x+v,y:x.internals.positionAbsolute.y+b};o&&(y=bc(y,r));let{position:h,positionAbsolute:w}=Cw({nodeId:x.id,nextPosition:y,nodeLookup:c,nodeExtent:n,nodeOrigin:f,onError:i});x.position=h,x.internals.positionAbsolute=w,u.set(x.id,x)}l(u)},[])}var $w=(0,J.createContext)(null),fX=$w.Provider;$w.Consumer;var BD=()=>(0,J.useContext)($w),pX=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),FD=(0,J.createContext)(null);function mX({children:e}){let t=je(pX,kt);return(0,Y.jsx)(FD.Provider,{value:t,children:e})}function hX(){let e=(0,J.useContext)(FD);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}var gX={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},xX=(e,t,a)=>n=>{let{connectionClickStartHandle:o,connectionMode:r,connection:s}=n,{fromHandle:i,toHandle:l,isValid:c}=s;if(!i&&!o)return gX;let f=l?.nodeId===e&&l?.id===t&&l?.type===a;return{connectingFrom:i?.nodeId===e&&i?.id===t&&i?.type===a,connectingTo:f,clickConnecting:o?.nodeId===e&&o?.id===t&&o?.type===a,isPossibleEndHandle:r===Ws.Strict?i?.type!==a:e!==i?.nodeId||t!==i?.id,connectionInProcess:!!i,clickConnectionInProcess:!!o,valid:f&&c}};function vX({type:e="source",position:t=we.Top,isValidConnection:a,isConnectable:n=!0,isConnectableStart:o=!0,isConnectableEnd:r=!0,id:s,onConnect:i,children:l,className:c,onMouseDown:f,onTouchStart:u,...d},p){let g=s||null,v=e==="target",b=vt(),x=BD(),{connectOnClick:y,noPanClassName:h,rfId:w}=hX(),{connectingFrom:S,connectingTo:C,clickConnecting:I,isPossibleEndHandle:L,connectionInProcess:N,clickConnectionInProcess:P,valid:O}=je(xX(x,g,e),kt);x||b.getState().onError?.("010",_n.error010());let B=E=>{let{defaultEdgeOptions:M,onConnect:A,hasDefaultEdges:H}=b.getState(),V={...M,...E};if(H){let{edges:D,setEdges:Q,onError:K}=b.getState();Q(K$(V,D,{onError:K}))}A?.(V),i?.(V)},U=E=>{if(!x)return;let M=Dw(E.nativeEvent);if(o&&(M&&E.button===0||!M)){let A=b.getState();Cx.onPointerDown(E.nativeEvent,{handleDomNode:E.currentTarget,autoPanOnConnect:A.autoPanOnConnect,connectionMode:A.connectionMode,connectionRadius:A.connectionRadius,domNode:A.domNode,nodeLookup:A.nodeLookup,lib:A.lib,isTarget:v,handleId:g,nodeId:x,flowId:A.rfId,panBy:A.panBy,cancelConnection:A.cancelConnection,onConnectStart:A.onConnectStart,onConnectEnd:(...H)=>b.getState().onConnectEnd?.(...H),updateConnection:A.updateConnection,onConnect:B,isValidConnection:a||((...H)=>b.getState().isValidConnection?.(...H)??!0),getTransform:()=>b.getState().transform,getFromHandle:()=>b.getState().connection.fromHandle,autoPanSpeed:A.autoPanSpeed,dragThreshold:A.connectionDragThreshold})}M?f?.(E):u?.(E)},R=E=>{let{onClickConnectStart:M,onClickConnectEnd:A,connectionClickStartHandle:H,connectionMode:V,isValidConnection:D,lib:Q,rfId:K,nodeLookup:ue,connection:re}=b.getState();if(!x||!H&&!o)return;if(!H){M?.(E.nativeEvent,{nodeId:x,handleId:g,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:x,type:e,id:g}});return}let se=Ew(E.target),_=a||D,{connection:ne,isValid:q}=Cx.isValid(E.nativeEvent,{handle:{nodeId:x,id:g,type:e},connectionMode:V,fromNodeId:H.nodeId,fromHandleId:H.id||null,fromType:H.type,isValidConnection:_,flowId:K,doc:se,lib:Q,nodeLookup:ue});q&&ne&&B(ne);let W=structuredClone(re);delete W.inProgress,W.toPosition=W.toHandle?W.toHandle.position:null,A?.(E,W),b.setState({connectionClickStartHandle:null})};return(0,Y.jsx)("div",{"data-handleid":g,"data-nodeid":x,"data-handlepos":t,"data-id":`${w}-${x}-${g}-${e}`,className:At(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",h,c,{source:!v,target:v,connectable:n,connectablestart:o,connectableend:r,clickconnecting:I,connectingfrom:S,connectingto:C,valid:O,connectionindicator:n&&(!N||L)&&(N||P?r:o)}]),onMouseDown:U,onTouchStart:U,onClick:y?R:void 0,ref:p,...d,children:l})}var or=(0,J.memo)(DD(vX));function yX({data:e,isConnectable:t,sourcePosition:a=we.Bottom}){return(0,Y.jsxs)(Y.Fragment,{children:[e?.label,(0,Y.jsx)(or,{type:"source",position:a,isConnectable:t})]})}function bX({data:e,isConnectable:t,targetPosition:a=we.Top,sourcePosition:n=we.Bottom}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(or,{type:"target",position:a,isConnectable:t}),e?.label,(0,Y.jsx)(or,{type:"source",position:n,isConnectable:t})]})}function wX(){return null}function SX({data:e,isConnectable:t,targetPosition:a=we.Top}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(or,{type:"target",position:a,isConnectable:t}),e?.label]})}var Rx={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},pD={input:yX,default:bX,output:SX,group:wX};function CX(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var kX=e=>{let{width:t,height:a,x:n,y:o}=vc(e.nodeLookup,{filter:r=>!!r.selected});return{width:ao(t)?t:null,height:ao(a)?a:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${n}px,${o}px)`}};function LX({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:a}){let n=vt(),{width:o,height:r,transformString:s,userSelectionActive:i}=je(kX,kt),l=zD(),c=(0,J.useRef)(null);(0,J.useEffect)(()=>{a||c.current?.focus({preventScroll:!0})},[a]);let f=!i&&o!==null&&r!==null;if(OD({nodeRef:c,disabled:!f}),!f)return null;let u=e?p=>{let g=n.getState().nodes.filter(v=>v.selected);e(p,g)}:void 0,d=p=>{Object.prototype.hasOwnProperty.call(Rx,p.key)&&(p.preventDefault(),l({direction:Rx[p.key],factor:p.shiftKey?4:1}))};return(0,Y.jsx)("div",{className:At(["react-flow__nodesselection","react-flow__container",t]),style:{transform:s},children:(0,Y.jsx)("div",{ref:c,className:"react-flow__nodesselection-rect",onContextMenu:u,tabIndex:a?void 0:-1,onKeyDown:a?void 0:d,style:{width:o,height:r}})})}var mD=typeof window<"u"?window:void 0,IX=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function HD({children:e,onPaneClick:t,onPaneMouseEnter:a,onPaneMouseMove:n,onPaneMouseLeave:o,onPaneContextMenu:r,onPaneScroll:s,paneClickDistance:i,deleteKeyCode:l,selectionKeyCode:c,selectionOnDrag:f,selectionMode:u,onSelectionStart:d,onSelectionEnd:p,multiSelectionKeyCode:g,panActivationKeyCode:v,zoomActivationKeyCode:b,elementsSelectable:x,zoomOnScroll:y,zoomOnPinch:h,panOnScroll:w,panOnScrollSpeed:S,panOnScrollMode:C,zoomOnDoubleClick:I,panOnDrag:L,autoPanOnSelection:N,defaultViewport:P,translateExtent:O,minZoom:B,maxZoom:U,preventScrolling:R,onSelectionContextMenu:E,noWheelClassName:M,noPanClassName:A,disableKeyboardA11y:H,onViewportChange:V,isControlledViewport:D}){let{nodesSelectionActive:Q,userSelectionActive:K}=je(IX,kt),ue=xp(c,{target:mD}),re=xp(v,{target:mD}),se=re||L,_=re||w,ne=f&&se!==!0,q=ue||K||ne;return nX({deleteKeyCode:l,multiSelectionKeyCode:g}),(0,Y.jsx)(sX,{onPaneContextMenu:r,elementsSelectable:x,zoomOnScroll:y,zoomOnPinch:h,panOnScroll:_,panActivationKeyPressed:re,panOnScrollSpeed:S,panOnScrollMode:C,zoomOnDoubleClick:I,panOnDrag:!ue&&se,defaultViewport:P,translateExtent:O,minZoom:B,maxZoom:U,zoomActivationKeyCode:b,preventScrolling:R,noWheelClassName:M,noPanClassName:A,onViewportChange:V,isControlledViewport:D,paneClickDistance:i,selectionOnDrag:ne,children:(0,Y.jsxs)(cX,{onSelectionStart:d,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:a,onPaneMouseMove:n,onPaneMouseLeave:o,onPaneContextMenu:r,onPaneScroll:s,panOnDrag:se,autoPanOnSelection:N,isSelecting:!!q,selectionMode:u,selectionKeyPressed:ue,paneClickDistance:i,selectionOnDrag:ne,children:[e,Q&&(0,Y.jsx)(LX,{onSelectionContextMenu:E,noPanClassName:A,disableKeyboardA11y:H})]})})}HD.displayName="FlowRenderer";var NX=(0,J.memo)(HD),RX=e=>t=>e?fx(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(a=>a.id):Array.from(t.nodeLookup.keys());function TX(e){return je((0,J.useCallback)(RX(e),[e]),kt)}var MX=e=>e.updateNodeInternals;function EX(){let e=je(MX),[t]=(0,J.useState)(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(a=>{let n=new Map;a.forEach(o=>{let r=o.target.getAttribute("data-id");n.set(r,{id:r,nodeElement:o.target,force:!0})}),e(n)}));return(0,J.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function AX({node:e,nodeType:t,hasDimensions:a,resizeObserver:n}){let o=vt(),r=(0,J.useRef)(null),s=(0,J.useRef)(null),i=(0,J.useRef)(e.sourcePosition),l=(0,J.useRef)(e.targetPosition),c=(0,J.useRef)(t),f=a&&!!e.internals.handleBounds;return(0,J.useEffect)(()=>{r.current&&!e.hidden&&(!f||s.current!==r.current)&&(s.current&&n?.unobserve(s.current),n?.observe(r.current),s.current=r.current)},[f,e.hidden]),(0,J.useEffect)(()=>()=>{s.current&&(n?.unobserve(s.current),s.current=null)},[]),(0,J.useEffect)(()=>{if(r.current){let u=c.current!==t,d=i.current!==e.sourcePosition,p=l.current!==e.targetPosition;(u||d||p)&&(c.current=t,i.current=e.sourcePosition,l.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:r.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),r}function DX({id:e,onClick:t,onMouseEnter:a,onMouseMove:n,onMouseLeave:o,onContextMenu:r,onDoubleClick:s,nodesDraggable:i,elementsSelectable:l,nodesConnectable:c,nodesFocusable:f,resizeObserver:u,noDragClassName:d,noPanClassName:p,disableKeyboardA11y:g,rfId:v,nodeTypes:b,nodeClickDistance:x,onError:y}){let{node:h,internals:w,isParent:S}=je(q=>{let W=q.nodeLookup.get(e),ce=q.parentLookup.has(e);return{node:W,internals:W.internals,isParent:ce}},kt),C=h.type||"default",I=b?.[C]||pD[C];I===void 0&&(y?.("003",_n.error003(C)),C="default",I=b?.default||pD.default);let L=!!(h.draggable||i&&typeof h.draggable>"u"),N=!!(h.selectable||l&&typeof h.selectable>"u"),P=!!(h.connectable||c&&typeof h.connectable>"u"),O=!!(h.focusable||f&&typeof h.focusable>"u"),B=vt(),U=Nw(h),R=AX({node:h,nodeType:C,hasDimensions:U,resizeObserver:u}),E=OD({nodeRef:R,disabled:h.hidden||!L,noDragClassName:d,handleSelector:h.dragHandle,nodeId:e,isSelectable:N,nodeClickDistance:x}),M=zD();if(h.hidden)return null;let A=ro(h),H=CX(h),V=N||L||t||a||n||o,D=a?q=>a(q,{...w.userNode}):void 0,Q=n?q=>n(q,{...w.userNode}):void 0,K=o?q=>o(q,{...w.userNode}):void 0,ue=r?q=>r(q,{...w.userNode}):void 0,re=s?q=>s(q,{...w.userNode}):void 0,se=q=>{let{selectNodesOnDrag:W,nodeDragThreshold:ce}=B.getState();N&&(!W||!L||ce>0)&&Gw({id:e,store:B,nodeRef:R}),t&&t(q,{...w.userNode})},_=q=>{if(!(Aw(q.nativeEvent)||g)){if(xw.includes(q.key)&&N){let W=q.key==="Escape";Gw({id:e,store:B,unselect:W,nodeRef:R})}else if(L&&h.selected&&Object.prototype.hasOwnProperty.call(Rx,q.key)){q.preventDefault();let{ariaLabelConfig:W}=B.getState();B.setState({ariaLiveMessage:W["node.a11yDescription.ariaLiveMessage"]({direction:q.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),M({direction:Rx[q.key],factor:q.shiftKey?4:1})}}},ne=()=>{if(g||!R.current?.matches(":focus-visible"))return;let{transform:q,width:W,height:ce,autoPanOnNodeFocus:de,setCenter:F}=B.getState();if(!de)return;fx(new Map([[e,h]]),{x:0,y:0,width:W,height:ce},q,!0).length>0||F(h.position.x+A.width/2,h.position.y+A.height/2,{zoom:q[2]})};return(0,Y.jsx)("div",{className:At(["react-flow__node",`react-flow__node-${C}`,{[p]:L},h.className,{selected:h.selected,selectable:N,parent:S,draggable:L,dragging:E}]),ref:R,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:V?"all":"none",visibility:U?"visible":"hidden",...h.style,...H},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:D,onMouseMove:Q,onMouseLeave:K,onContextMenu:ue,onClick:se,onDoubleClick:re,onKeyDown:O?_:void 0,tabIndex:O?0:void 0,onFocus:O?ne:void 0,role:h.ariaRole??(O?"group":void 0),"aria-roledescription":"node","aria-describedby":g?void 0:`${TD}-${v}`,"aria-label":h.ariaLabel,...h.domAttributes,children:(0,Y.jsx)(fX,{value:e,children:(0,Y.jsx)(I,{id:e,data:h.data,type:C,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:h.selected??!1,selectable:N,draggable:L,deletable:h.deletable??!0,isConnectable:P,sourcePosition:h.sourcePosition,targetPosition:h.targetPosition,dragging:E,dragHandle:h.dragHandle,zIndex:w.z,parentId:h.parentId,...A})})})}var _X=(0,J.memo)(DX),PX=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function qD(e){let{nodesConnectable:t,nodesFocusable:a,elementsSelectable:n,onError:o}=je(PX,kt),r=TX(e.onlyRenderVisibleElements),s=EX();return(0,Y.jsx)("div",{className:"react-flow__nodes",style:Ex,children:r.map(i=>(0,Y.jsx)(_X,{id:i,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:a,elementsSelectable:n,nodeClickDistance:e.nodeClickDistance,onError:o},i))})}qD.displayName="NodeRenderer";var OX=(0,J.memo)(qD);function zX(e){return je((0,J.useCallback)(a=>{if(!e)return a.edges.map(o=>o.id);let n=[];if(a.width&&a.height)for(let o of a.edges){let r=a.nodeLookup.get(o.source),s=a.nodeLookup.get(o.target);r&&s&&x6({sourceNode:r,targetNode:s,width:a.width,height:a.height,transform:a.transform})&&n.push(o.id)}return n},[e]),kt)}var BX=({color:e="none",strokeWidth:t=1})=>{let a={strokeWidth:t,...e&&{stroke:e}};return(0,Y.jsx)("polyline",{className:"arrow",style:a,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},FX=({color:e="none",strokeWidth:t=1})=>{let a={strokeWidth:t,...e&&{stroke:e,fill:e}};return(0,Y.jsx)("polyline",{className:"arrowclosed",style:a,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},hD={[oo.Arrow]:BX,[oo.ArrowClosed]:FX};function HX(e){let t=vt();return(0,J.useMemo)(()=>Object.prototype.hasOwnProperty.call(hD,e)?hD[e]:(t.getState().onError?.("009",_n.error009(e)),null),[e])}var qX=({id:e,type:t,color:a,width:n=12.5,height:o=12.5,markerUnits:r="strokeWidth",strokeWidth:s,orient:i="auto-start-reverse"})=>{let l=HX(t);return l?(0,Y.jsx)("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${n}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:r,orient:i,refX:"0",refY:"0",children:(0,Y.jsx)(l,{color:a,strokeWidth:s})}):null},UD=({defaultColor:e,rfId:t})=>{let a=je(r=>r.edges),n=je(r=>r.defaultEdgeOptions),o=(0,J.useMemo)(()=>b6(a,{id:t,defaultColor:e,defaultMarkerStart:n?.markerStart,defaultMarkerEnd:n?.markerEnd}),[a,n,t,e]);return o.length?(0,Y.jsx)("svg",{className:"react-flow__marker","aria-hidden":"true",children:(0,Y.jsx)("defs",{children:o.map(r=>(0,Y.jsx)(qX,{id:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient},r.id))})}):null};UD.displayName="MarkerDefinitions";var UX=(0,J.memo)(UD);function VD({x:e,y:t,label:a,labelStyle:n,labelShowBg:o=!0,labelBgStyle:r,labelBgPadding:s=[2,4],labelBgBorderRadius:i=2,children:l,className:c,...f}){let[u,d]=(0,J.useState)({x:1,y:0,width:0,height:0}),p=At(["react-flow__edge-textwrapper",c]),g=(0,J.useRef)(null);return(0,J.useEffect)(()=>{if(g.current){let v=g.current.getBBox();d({x:v.x,y:v.y,width:v.width,height:v.height})}},[a]),a?(0,Y.jsxs)("g",{transform:`translate(${e-u.width/2} ${t-u.height/2})`,className:p,visibility:u.width?"visible":"hidden",...f,children:[o&&(0,Y.jsx)("rect",{width:u.width+2*s[0],x:-s[0],y:-s[1],height:u.height+2*s[1],className:"react-flow__edge-textbg",style:r,rx:i,ry:i}),(0,Y.jsx)("text",{className:"react-flow__edge-text",y:u.height/2,dy:"0.3em",ref:g,style:n,children:a}),l]}):null}VD.displayName="EdgeText";var VX=(0,J.memo)(VD);function Lc({path:e,labelX:t,labelY:a,label:n,labelStyle:o,labelShowBg:r,labelBgStyle:s,labelBgPadding:i,labelBgBorderRadius:l,interactionWidth:c=20,...f}){return(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)("path",{...f,d:e,fill:"none",className:At(["react-flow__edge-path",f.className])}),c?(0,Y.jsx)("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:c,className:"react-flow__edge-interaction"}):null,n&&ao(t)&&ao(a)?(0,Y.jsx)(VX,{x:t,y:a,label:n,labelStyle:o,labelShowBg:r,labelBgStyle:s,labelBgPadding:i,labelBgBorderRadius:l}):null]})}function gD({pos:e,x1:t,y1:a,x2:n,y2:o}){return e===we.Left||e===we.Right?[.5*(t+n),a]:[t,.5*(a+o)]}function GD({sourceX:e,sourceY:t,sourcePosition:a=we.Bottom,targetX:n,targetY:o,targetPosition:r=we.Top}){let[s,i]=gD({pos:a,x1:e,y1:t,x2:n,y2:o}),[l,c]=gD({pos:r,x1:n,y1:o,x2:e,y2:t}),[f,u,d,p]=xx({sourceX:e,sourceY:t,targetX:n,targetY:o,sourceControlX:s,sourceControlY:i,targetControlX:l,targetControlY:c});return[`M${e},${t} C${s},${i} ${l},${c} ${n},${o}`,f,u,d,p]}function jD(e){return(0,J.memo)(({id:t,sourceX:a,sourceY:n,targetX:o,targetY:r,sourcePosition:s,targetPosition:i,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:b,interactionWidth:x})=>{let[y,h,w]=GD({sourceX:a,sourceY:n,sourcePosition:s,targetX:o,targetY:r,targetPosition:i}),S=e.isInternal?void 0:t;return(0,Y.jsx)(Lc,{id:S,path:y,labelX:h,labelY:w,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:b,interactionWidth:x})})}var GX=jD({isInternal:!1}),$D=jD({isInternal:!0});GX.displayName="SimpleBezierEdge";$D.displayName="SimpleBezierEdgeInternal";function XD(e){return(0,J.memo)(({id:t,sourceX:a,sourceY:n,targetX:o,targetY:r,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,sourcePosition:p=we.Bottom,targetPosition:g=we.Top,markerEnd:v,markerStart:b,pathOptions:x,interactionWidth:y})=>{let[h,w,S]=Ks({sourceX:a,sourceY:n,sourcePosition:p,targetX:o,targetY:r,targetPosition:g,borderRadius:x?.borderRadius,offset:x?.offset,stepPosition:x?.stepPosition}),C=e.isInternal?void 0:t;return(0,Y.jsx)(Lc,{id:C,path:h,labelX:w,labelY:S,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:v,markerStart:b,interactionWidth:y})})}var WD=XD({isInternal:!1}),YD=XD({isInternal:!0});WD.displayName="SmoothStepEdge";YD.displayName="SmoothStepEdgeInternal";function KD(e){return(0,J.memo)(({id:t,...a})=>{let n=e.isInternal?void 0:t;return(0,Y.jsx)(WD,{...a,id:n,pathOptions:(0,J.useMemo)(()=>({borderRadius:0,offset:a.pathOptions?.offset}),[a.pathOptions?.offset])})})}var jX=KD({isInternal:!1}),ZD=KD({isInternal:!0});jX.displayName="StepEdge";ZD.displayName="StepEdgeInternal";function QD(e){return(0,J.memo)(({id:t,sourceX:a,sourceY:n,targetX:o,targetY:r,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:p,markerStart:g,interactionWidth:v})=>{let[b,x,y]=yx({sourceX:a,sourceY:n,targetX:o,targetY:r}),h=e.isInternal?void 0:t;return(0,Y.jsx)(Lc,{id:h,path:b,labelX:x,labelY:y,label:s,labelStyle:i,labelShowBg:l,labelBgStyle:c,labelBgPadding:f,labelBgBorderRadius:u,style:d,markerEnd:p,markerStart:g,interactionWidth:v})})}var $X=QD({isInternal:!1}),JD=QD({isInternal:!0});$X.displayName="StraightEdge";JD.displayName="StraightEdgeInternal";function e_(e){return(0,J.memo)(({id:t,sourceX:a,sourceY:n,targetX:o,targetY:r,sourcePosition:s=we.Bottom,targetPosition:i=we.Top,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:b,pathOptions:x,interactionWidth:y})=>{let[h,w,S]=vx({sourceX:a,sourceY:n,sourcePosition:s,targetX:o,targetY:r,targetPosition:i,curvature:x?.curvature}),C=e.isInternal?void 0:t;return(0,Y.jsx)(Lc,{id:C,path:h,labelX:w,labelY:S,label:l,labelStyle:c,labelShowBg:f,labelBgStyle:u,labelBgPadding:d,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:b,interactionWidth:y})})}var XX=e_({isInternal:!1}),t_=e_({isInternal:!0});XX.displayName="BezierEdge";t_.displayName="BezierEdgeInternal";var xD={default:t_,straight:JD,step:ZD,smoothstep:YD,simplebezier:$D},vD={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},WX=(e,t,a)=>a===we.Left?e-t:a===we.Right?e+t:e,YX=(e,t,a)=>a===we.Top?e-t:a===we.Bottom?e+t:e,yD="react-flow__edgeupdater";function bD({position:e,centerX:t,centerY:a,radius:n=10,onMouseDown:o,onMouseEnter:r,onMouseOut:s,type:i}){return(0,Y.jsx)("circle",{onMouseDown:o,onMouseEnter:r,onMouseOut:s,className:At([yD,`${yD}-${i}`]),cx:WX(t,n,e),cy:YX(a,n,e),r:n,stroke:"transparent",fill:"transparent"})}function KX({isReconnectable:e,reconnectRadius:t,edge:a,sourceX:n,sourceY:o,targetX:r,targetY:s,sourcePosition:i,targetPosition:l,onReconnect:c,onReconnectStart:f,onReconnectEnd:u,setReconnecting:d,setUpdateHover:p}){let g=vt(),v=(w,S)=>{if(w.button!==0)return;let{autoPanOnConnect:C,domNode:I,connectionMode:L,connectionRadius:N,lib:P,onConnectStart:O,cancelConnection:B,nodeLookup:U,rfId:R,panBy:E,updateConnection:M}=g.getState(),A=S.type==="target",H=(Q,K)=>{d(!1),u?.(Q,a,S.type,K)},V=Q=>c?.(a,Q),D=(Q,K)=>{d(!0),f?.(w,a,S.type),O?.(Q,K)};Cx.onPointerDown(w.nativeEvent,{autoPanOnConnect:C,connectionMode:L,connectionRadius:N,domNode:I,handleId:S.id,nodeId:S.nodeId,nodeLookup:U,isTarget:A,edgeUpdaterType:S.type,lib:P,flowId:R,cancelConnection:B,panBy:E,isValidConnection:(...Q)=>g.getState().isValidConnection?.(...Q)??!0,onConnect:V,onConnectStart:D,onConnectEnd:(...Q)=>g.getState().onConnectEnd?.(...Q),onReconnectEnd:H,updateConnection:M,getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,dragThreshold:g.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},b=w=>v(w,{nodeId:a.target,id:a.targetHandle??null,type:"target"}),x=w=>v(w,{nodeId:a.source,id:a.sourceHandle??null,type:"source"}),y=()=>p(!0),h=()=>p(!1);return(0,Y.jsxs)(Y.Fragment,{children:[(e===!0||e==="source")&&(0,Y.jsx)(bD,{position:i,centerX:n,centerY:o,radius:t,onMouseDown:b,onMouseEnter:y,onMouseOut:h,type:"source"}),(e===!0||e==="target")&&(0,Y.jsx)(bD,{position:l,centerX:r,centerY:s,radius:t,onMouseDown:x,onMouseEnter:y,onMouseOut:h,type:"target"})]})}function ZX({id:e,edgesFocusable:t,edgesReconnectable:a,elementsSelectable:n,onClick:o,onDoubleClick:r,onContextMenu:s,onMouseEnter:i,onMouseMove:l,onMouseLeave:c,reconnectRadius:f,onReconnect:u,onReconnectStart:d,onReconnectEnd:p,rfId:g,edgeTypes:v,noPanClassName:b,onError:x,disableKeyboardA11y:y}){let h=je(F=>F.edgeLookup.get(e)),w=je(F=>F.defaultEdgeOptions);h=w?{...w,...h}:h;let S=h.type||"default",C=v?.[S]||xD[S];C===void 0&&(x?.("011",_n.error011(S)),S="default",C=v?.default||xD.default);let I=!!(h.focusable||t&&typeof h.focusable>"u"),L=typeof u<"u"&&(h.reconnectable||a&&typeof h.reconnectable>"u"),N=!!(h.selectable||n&&typeof h.selectable>"u"),P=(0,J.useRef)(null),[O,B]=(0,J.useState)(!1),[U,R]=(0,J.useState)(!1),E=vt(),{zIndex:M=h.zIndex,sourceX:A,sourceY:H,targetX:V,targetY:D,sourcePosition:Q,targetPosition:K}=je((0,J.useCallback)(F=>{let G=F.nodeLookup.get(h.source),ie=F.nodeLookup.get(h.target);if(!G||!ie)return vD;let Z=y6({id:e,sourceNode:G,targetNode:ie,sourceHandle:h.sourceHandle||null,targetHandle:h.targetHandle||null,connectionMode:F.connectionMode,onError:x}),Le=g6({selected:h.selected,zIndex:h.zIndex,sourceNode:G,targetNode:ie,elevateOnSelect:F.elevateEdgesOnSelect,zIndexMode:F.zIndexMode});return{...Z||vD,zIndex:Le}},[h.source,h.target,h.sourceHandle,h.targetHandle,h.selected,h.zIndex,x]),kt),ue=(0,J.useMemo)(()=>h.markerStart?`url('#${bx(h.markerStart,g)}')`:void 0,[h.markerStart,g]),re=(0,J.useMemo)(()=>h.markerEnd?`url('#${bx(h.markerEnd,g)}')`:void 0,[h.markerEnd,g]);if(h.hidden||A===null||H===null||V===null||D===null)return null;let se=F=>{let{addSelectedEdges:G,unselectNodesAndEdges:ie,multiSelectionActive:Z}=E.getState();N&&(E.setState({nodesSelectionActive:!1}),h.selected&&Z?(ie({nodes:[],edges:[h]}),P.current?.blur()):G([e])),o&&o(F,h)},_=r?F=>{r(F,{...h})}:void 0,ne=s?F=>{s(F,{...h})}:void 0,q=i?F=>{i(F,{...h})}:void 0,W=l?F=>{l(F,{...h})}:void 0,ce=c?F=>{c(F,{...h})}:void 0,de=F=>{if(!y&&xw.includes(F.key)&&N){let{unselectNodesAndEdges:G,addSelectedEdges:ie}=E.getState();F.key==="Escape"?(P.current?.blur(),G({edges:[h]})):ie([e])}};return(0,Y.jsx)("svg",{style:{zIndex:M},children:(0,Y.jsxs)("g",{className:At(["react-flow__edge",`react-flow__edge-${S}`,h.className,b,{selected:h.selected,animated:h.animated,inactive:!N&&!o,updating:O,selectable:N}]),onClick:se,onDoubleClick:_,onContextMenu:ne,onMouseEnter:q,onMouseMove:W,onMouseLeave:ce,onKeyDown:I?de:void 0,tabIndex:I?0:void 0,role:h.ariaRole??(I?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":h.ariaLabel===null?void 0:h.ariaLabel||`Edge from ${h.source} to ${h.target}`,"aria-describedby":I?`${MD}-${g}`:void 0,ref:P,...h.domAttributes,children:[!U&&(0,Y.jsx)(C,{id:e,source:h.source,target:h.target,type:h.type,selected:h.selected,animated:h.animated,selectable:N,deletable:h.deletable??!0,label:h.label,labelStyle:h.labelStyle,labelShowBg:h.labelShowBg,labelBgStyle:h.labelBgStyle,labelBgPadding:h.labelBgPadding,labelBgBorderRadius:h.labelBgBorderRadius,sourceX:A,sourceY:H,targetX:V,targetY:D,sourcePosition:Q,targetPosition:K,data:h.data,style:h.style,sourceHandleId:h.sourceHandle,targetHandleId:h.targetHandle,markerStart:ue,markerEnd:re,pathOptions:"pathOptions"in h?h.pathOptions:void 0,interactionWidth:h.interactionWidth}),L&&(0,Y.jsx)(KX,{edge:h,isReconnectable:L,reconnectRadius:f,onReconnect:u,onReconnectStart:d,onReconnectEnd:p,sourceX:A,sourceY:H,targetX:V,targetY:D,sourcePosition:Q,targetPosition:K,setUpdateHover:B,setReconnecting:R})]})})}var QX=(0,J.memo)(ZX),JX=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function a_({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:a,edgeTypes:n,noPanClassName:o,onReconnect:r,onEdgeContextMenu:s,onEdgeMouseEnter:i,onEdgeMouseMove:l,onEdgeMouseLeave:c,onEdgeClick:f,reconnectRadius:u,onEdgeDoubleClick:d,onReconnectStart:p,onReconnectEnd:g,disableKeyboardA11y:v}){let{edgesFocusable:b,edgesReconnectable:x,elementsSelectable:y,onError:h}=je(JX,kt),w=zX(t);return(0,Y.jsxs)("div",{className:"react-flow__edges",children:[(0,Y.jsx)(UX,{defaultColor:e,rfId:a}),w.map(S=>(0,Y.jsx)(QX,{id:S,edgesFocusable:b,edgesReconnectable:x,elementsSelectable:y,noPanClassName:o,onReconnect:r,onContextMenu:s,onMouseEnter:i,onMouseMove:l,onMouseLeave:c,onClick:f,reconnectRadius:u,onDoubleClick:d,onReconnectStart:p,onReconnectEnd:g,rfId:a,onError:h,edgeTypes:n,disableKeyboardA11y:v},S))]})}a_.displayName="EdgeRenderer";var eW=(0,J.memo)(a_),wD=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function tW({children:e}){let t=vt(),a=(0,J.useRef)(null),[n]=(0,J.useState)(()=>t.getState().transform);return _D(()=>{let o=null,r=()=>{let s=t.getState().transform;o&&s[0]===o[0]&&s[1]===o[1]&&s[2]===o[2]||(o=s,a.current&&(a.current.style.transform=wD(s)))};return r(),t.subscribe(r)},[t]),(0,Y.jsx)("div",{ref:a,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:wD(n)},children:e})}function aW(e){let t=vp(),a=(0,J.useRef)(!1);(0,J.useEffect)(()=>{!a.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),a.current=!0)},[e,t.viewportInitialized])}var nW=e=>e.panZoom?.syncViewport;function oW(e){let t=je(nW),a=vt();return(0,J.useEffect)(()=>{e&&(t?.(e),a.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function SD(e){return e.connection.inProgress?{...e.connection,to:wc(e.connection.to,e.transform)}:{...e.connection}}function rW(e){return e?a=>{let n=SD(a);return e(n)}:SD}function sW(e){let t=rW(e);return je(t,kt)}var iW=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function lW({containerStyle:e,style:t,type:a,component:n}){let{nodesConnectable:o,width:r,height:s,isValid:i,inProgress:l}=je(iW,kt);return!(r&&o&&l)?null:(0,Y.jsx)("svg",{style:e,width:r,height:s,className:"react-flow__connectionline react-flow__container",children:(0,Y.jsx)("g",{className:At(["react-flow__connection",Mw(i)]),children:(0,Y.jsx)(n_,{style:t,type:a,CustomComponent:n,isValid:i})})})}var n_=({style:e,type:t=ar.Bezier,CustomComponent:a,isValid:n})=>{let{inProgress:o,from:r,fromNode:s,fromHandle:i,fromPosition:l,to:c,toNode:f,toHandle:u,toPosition:d,pointer:p}=sW();if(!o)return;if(a)return(0,Y.jsx)(a,{connectionLineType:t,connectionLineStyle:e,fromNode:s,fromHandle:i,fromX:r.x,fromY:r.y,toX:c.x,toY:c.y,fromPosition:l,toPosition:d,connectionStatus:Mw(n),toNode:f,toHandle:u,pointer:p});let g="",v={sourceX:r.x,sourceY:r.y,sourcePosition:l,targetX:c.x,targetY:c.y,targetPosition:d};switch(t){case ar.Bezier:[g]=vx(v);break;case ar.SimpleBezier:[g]=GD(v);break;case ar.Step:[g]=Ks({...v,borderRadius:0});break;case ar.SmoothStep:[g]=Ks(v);break;default:[g]=yx(v)}return(0,Y.jsx)("path",{d:g,fill:"none",className:"react-flow__connection-path",style:e})};n_.displayName="ConnectionLine";var uW={};function CD(e=uW){let t=(0,J.useRef)(e),a=vt();(0,J.useEffect)(()=>{},[e])}function cW(){let e=vt(),t=(0,J.useRef)(!1);(0,J.useEffect)(()=>{},[])}function o_({nodeTypes:e,edgeTypes:t,onInit:a,onNodeClick:n,onEdgeClick:o,onNodeDoubleClick:r,onEdgeDoubleClick:s,onNodeMouseEnter:i,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:f,onSelectionContextMenu:u,onSelectionStart:d,onSelectionEnd:p,connectionLineType:g,connectionLineStyle:v,connectionLineComponent:b,connectionLineContainerStyle:x,selectionKeyCode:y,selectionOnDrag:h,selectionMode:w,multiSelectionKeyCode:S,panActivationKeyCode:C,zoomActivationKeyCode:I,deleteKeyCode:L,onlyRenderVisibleElements:N,elementsSelectable:P,defaultViewport:O,translateExtent:B,minZoom:U,maxZoom:R,preventScrolling:E,defaultMarkerColor:M,zoomOnScroll:A,zoomOnPinch:H,panOnScroll:V,panOnScrollSpeed:D,panOnScrollMode:Q,zoomOnDoubleClick:K,panOnDrag:ue,autoPanOnSelection:re,onPaneClick:se,onPaneMouseEnter:_,onPaneMouseMove:ne,onPaneMouseLeave:q,onPaneScroll:W,onPaneContextMenu:ce,paneClickDistance:de,nodeClickDistance:F,onEdgeContextMenu:G,onEdgeMouseEnter:ie,onEdgeMouseMove:Z,onEdgeMouseLeave:Le,reconnectRadius:Be,onReconnect:yt,onReconnectStart:rt,onReconnectEnd:Vt,noDragClassName:Ge,noWheelClassName:tt,noPanClassName:za,disableKeyboardA11y:Nt,nodeExtent:xn,rfId:so,viewport:Za,onViewportChange:rr,nodesDraggable:Ll}){return CD(e),CD(t),cW(),aW(a),oW(Za),(0,Y.jsx)(NX,{onPaneClick:se,onPaneMouseEnter:_,onPaneMouseMove:ne,onPaneMouseLeave:q,onPaneContextMenu:ce,onPaneScroll:W,paneClickDistance:de,deleteKeyCode:L,selectionKeyCode:y,selectionOnDrag:h,selectionMode:w,onSelectionStart:d,onSelectionEnd:p,multiSelectionKeyCode:S,panActivationKeyCode:C,zoomActivationKeyCode:I,elementsSelectable:P,zoomOnScroll:A,zoomOnPinch:H,zoomOnDoubleClick:K,panOnScroll:V,panOnScrollSpeed:D,panOnScrollMode:Q,panOnDrag:ue,autoPanOnSelection:re,defaultViewport:O,translateExtent:B,minZoom:U,maxZoom:R,onSelectionContextMenu:u,preventScrolling:E,noDragClassName:Ge,noWheelClassName:tt,noPanClassName:za,disableKeyboardA11y:Nt,onViewportChange:rr,isControlledViewport:!!Za,children:(0,Y.jsxs)(tW,{children:[(0,Y.jsx)(eW,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:s,onReconnect:yt,onReconnectStart:rt,onReconnectEnd:Vt,onlyRenderVisibleElements:N,onEdgeContextMenu:G,onEdgeMouseEnter:ie,onEdgeMouseMove:Z,onEdgeMouseLeave:Le,reconnectRadius:Be,defaultMarkerColor:M,noPanClassName:za,disableKeyboardA11y:Nt,rfId:so}),(0,Y.jsx)(lW,{style:v,type:g,component:b,containerStyle:x}),(0,Y.jsx)("div",{className:"react-flow__edgelabel-renderer"}),(0,Y.jsx)(OX,{nodeTypes:e,onNodeClick:n,onNodeDoubleClick:r,onNodeMouseEnter:i,onNodeMouseMove:l,onNodeMouseLeave:c,onNodeContextMenu:f,nodeClickDistance:F,onlyRenderVisibleElements:N,noPanClassName:za,noDragClassName:Ge,disableKeyboardA11y:Nt,nodeExtent:xn,rfId:so,nodesDraggable:Ll}),(0,Y.jsx)("div",{className:"react-flow__viewport-portal"})]})})}o_.displayName="GraphView";var dW=(0,J.memo)(o_),fW=Iw("React Flow","https://reactflow.dev/"),kD=({nodes:e,edges:t,defaultNodes:a,defaultEdges:n,width:o,height:r,fitView:s,fitViewOptions:i,minZoom:l=.5,maxZoom:c=2,nodeOrigin:f,nodeExtent:u,zIndexMode:d="basic"}={})=>{let p=new Map,g=new Map,v=new Map,b=new Map,x=n??t??[],y=a??e??[],h=f??[0,0],w=u??xc;Fw(v,b,x);let{nodesInitialized:S}=wx(y,p,g,{nodeOrigin:h,nodeExtent:w,zIndexMode:d}),C=[0,0,1];if(s&&o&&r){let I=vc(p,{filter:O=>!!((O.width||O.initialWidth)&&(O.height||O.initialHeight))}),{x:L,y:N,zoom:P}=gp(I,o,r,l,c,i?.padding??.1);C=[L,N,P]}return{rfId:"1",width:o??0,height:r??0,transform:C,nodes:y,nodesInitialized:S,nodeLookup:p,parentLookup:g,edges:x,edgeLookup:b,connectionLookup:v,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:a!==void 0,hasDefaultEdges:n!==void 0,panZoom:null,minZoom:l,maxZoom:c,translateExtent:xc,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Ws.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:h,nodeDragThreshold:1,connectionDragThreshold:1,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesReconnectable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,elevateEdgesOnSelect:!0,selectNodesOnDrag:!0,multiSelectionActive:!1,fitViewQueued:s??!1,fitViewOptions:i,fitViewResolver:null,connection:{...yw},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:fW,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:vw,zIndexMode:d,defaultEdgeOptions:void 0,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map,onNodesDelete:void 0,onEdgesDelete:void 0,onDelete:void 0,onBeforeDelete:void 0,onViewportChangeStart:void 0,onViewportChange:void 0,onViewportChangeEnd:void 0,onNodeDragStart:void 0,onNodeDrag:void 0,onNodeDragStop:void 0,onSelectionDragStart:void 0,onSelectionDrag:void 0,onSelectionDragStop:void 0,onMoveStart:void 0,onMove:void 0,onMoveEnd:void 0,onConnect:void 0,onConnectStart:void 0,onConnectEnd:void 0,onClickConnectStart:void 0,onClickConnectEnd:void 0}},pW=({nodes:e,edges:t,defaultNodes:a,defaultEdges:n,width:o,height:r,fitView:s,fitViewOptions:i,minZoom:l,maxZoom:c,nodeOrigin:f,nodeExtent:u,zIndexMode:d})=>J6((p,g)=>{async function v(){let{nodeLookup:b,panZoom:x,fitViewOptions:y,fitViewResolver:h,width:w,height:S,minZoom:C,maxZoom:I}=g();x&&(await c6({nodes:b,width:w,height:S,panZoom:x,minZoom:C,maxZoom:I},y),h?.resolve(!0),p({fitViewResolver:null}))}return{...kD({nodes:e,edges:t,width:o,height:r,fitView:s,fitViewOptions:i,minZoom:l,maxZoom:c,nodeOrigin:f,nodeExtent:u,defaultNodes:a,defaultEdges:n,zIndexMode:d}),setNodes:b=>{let{nodeLookup:x,parentLookup:y,nodeOrigin:h,nodeExtent:w,elevateNodesOnSelect:S,fitViewQueued:C,zIndexMode:I,nodesSelectionActive:L}=g(),{nodesInitialized:N,hasSelectedNodes:P}=wx(b,x,y,{nodeOrigin:h,nodeExtent:w,elevateNodesOnSelect:S,checkEquality:!0,zIndexMode:I}),O=L&&P;C&&N?(v(),p({nodes:b,nodesInitialized:N,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:O})):p({nodes:b,nodesInitialized:N,nodesSelectionActive:O})},setEdges:b=>{let{connectionLookup:x,edgeLookup:y}=g();Fw(x,y,b),p({edges:b})},setDefaultNodesAndEdges:(b,x)=>{if(b){let{setNodes:y}=g();y(b),p({hasDefaultNodes:!0})}if(x){let{setEdges:y}=g();y(x),p({hasDefaultEdges:!0})}},updateNodeInternals:b=>{let{triggerNodeChanges:x,nodeLookup:y,parentLookup:h,domNode:w,nodeOrigin:S,nodeExtent:C,debug:I,fitViewQueued:L,zIndexMode:N}=g(),{changes:P,updatedInternals:O}=k6(b,y,h,w,S,C,N);O&&(S6(y,h,{nodeOrigin:S,nodeExtent:C,zIndexMode:N}),L?(v(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),P?.length>0&&(I&&console.log("React Flow: trigger node changes",P),x?.(P)))},updateNodePositions:(b,x=!1)=>{let y=[],h=[],{nodeLookup:w,triggerNodeChanges:S,connection:C,updateConnection:I,onNodesChangeMiddlewareMap:L}=g();for(let[N,P]of b){let O=w.get(N),B=!!(O?.expandParent&&O?.parentId&&P?.position),U={id:N,type:"position",position:B?{x:Math.max(0,P.position.x),y:Math.max(0,P.position.y)}:P.position,dragging:x};if(O&&C.inProgress&&C.fromNode.id===O.id){let R=Ys(O,C.fromHandle,we.Left,!0);I({...C,from:R})}B&&O.parentId&&y.push({id:N,parentId:O.parentId,rect:{...P.internals.positionAbsolute,width:P.measured.width??0,height:P.measured.height??0}}),h.push(U)}if(y.length>0){let{parentLookup:N,nodeOrigin:P}=g(),O=Sx(y,w,N,P);h.push(...O)}for(let N of L.values())h=N(h);S(h)},triggerNodeChanges:b=>{let{onNodesChange:x,setNodes:y,nodes:h,hasDefaultNodes:w,debug:S}=g();if(b?.length){if(w){let C=jw(b,h);y(C)}S&&console.log("React Flow: trigger node changes",b),x?.(b)}},triggerEdgeChanges:b=>{let{onEdgesChange:x,setEdges:y,edges:h,hasDefaultEdges:w,debug:S}=g();if(b?.length){if(w){let C=W$(b,h);y(C)}S&&console.log("React Flow: trigger edge changes",b),x?.(b)}},addSelectedNodes:b=>{let{multiSelectionActive:x,edgeLookup:y,nodeLookup:h,triggerNodeChanges:w,triggerEdgeChanges:S}=g();if(x){let C=b.map(I=>Cl(I,!0));w(C);return}w(kc(h,new Set([...b]),!0)),S(kc(y))},addSelectedEdges:b=>{let{multiSelectionActive:x,edgeLookup:y,nodeLookup:h,triggerNodeChanges:w,triggerEdgeChanges:S}=g();if(x){let C=b.map(I=>Cl(I,!0));S(C);return}S(kc(y,new Set([...b]))),w(kc(h,new Set,!0))},unselectNodesAndEdges:({nodes:b,edges:x}={})=>{let{edges:y,nodes:h,nodeLookup:w,triggerNodeChanges:S,triggerEdgeChanges:C}=g(),I=b||h,L=x||y,N=[];for(let O of I){if(!O.selected)continue;let B=w.get(O.id);B&&(B.selected=!1),N.push(Cl(O.id,!1))}let P=[];for(let O of L)O.selected&&P.push(Cl(O.id,!1));S(N),C(P)},setMinZoom:b=>{let{panZoom:x,maxZoom:y}=g();x?.setScaleExtent([b,y]),p({minZoom:b})},setMaxZoom:b=>{let{panZoom:x,minZoom:y}=g();x?.setScaleExtent([y,b]),p({maxZoom:b})},setTranslateExtent:b=>{g().panZoom?.setTranslateExtent(b),p({translateExtent:b})},resetSelectedElements:()=>{let{edges:b,nodes:x,triggerNodeChanges:y,triggerEdgeChanges:h,elementsSelectable:w}=g();if(!w)return;let S=x.reduce((I,L)=>L.selected?[...I,Cl(L.id,!1)]:I,[]),C=b.reduce((I,L)=>L.selected?[...I,Cl(L.id,!1)]:I,[]);y(S),h(C)},setNodeExtent:b=>{let{nodes:x,nodeLookup:y,parentLookup:h,nodeOrigin:w,elevateNodesOnSelect:S,nodeExtent:C,zIndexMode:I}=g();b[0][0]===C[0][0]&&b[0][1]===C[0][1]&&b[1][0]===C[1][0]&&b[1][1]===C[1][1]||(wx(x,y,h,{nodeOrigin:w,nodeExtent:b,elevateNodesOnSelect:S,checkEquality:!1,zIndexMode:I}),p({nodeExtent:b}))},panBy:b=>{let{transform:x,width:y,height:h,panZoom:w,translateExtent:S}=g();return L6({delta:b,panZoom:w,transform:x,translateExtent:S,width:y,height:h})},setCenter:async(b,x,y)=>{let{width:h,height:w,maxZoom:S,panZoom:C}=g();if(!C)return!1;let I=typeof y?.zoom<"u"?y.zoom:S;return await C.setViewport({x:h/2-b*I,y:w/2-x*I,zoom:I},{duration:y?.duration,ease:y?.ease,interpolate:y?.interpolate}),!0},cancelConnection:()=>{p({connection:{...yw}})},updateConnection:b=>{p({connection:b})},reset:()=>p({...kD()})}},Object.is);function Xw({initialNodes:e,initialEdges:t,defaultNodes:a,defaultEdges:n,initialWidth:o,initialHeight:r,initialMinZoom:s,initialMaxZoom:i,initialFitViewOptions:l,fitView:c,nodeOrigin:f,nodeExtent:u,zIndexMode:d,children:p}){let[g]=(0,J.useState)(()=>pW({nodes:e,edges:t,defaultNodes:a,defaultEdges:n,width:o,height:r,fitView:c,minZoom:s,maxZoom:i,fitViewOptions:l,nodeOrigin:f,nodeExtent:u,zIndexMode:d}));return(0,Y.jsx)(R$,{value:g,children:(0,Y.jsx)(J$,{children:(0,Y.jsx)(mX,{children:p})})})}function mW({children:e,nodes:t,edges:a,defaultNodes:n,defaultEdges:o,width:r,height:s,fitView:i,fitViewOptions:l,minZoom:c,maxZoom:f,nodeOrigin:u,nodeExtent:d,zIndexMode:p}){return(0,J.useContext)(Tx)?(0,Y.jsx)(Y.Fragment,{children:e}):(0,Y.jsx)(Xw,{initialNodes:t,initialEdges:a,defaultNodes:n,defaultEdges:o,initialWidth:r,initialHeight:s,fitView:i,initialFitViewOptions:l,initialMinZoom:c,initialMaxZoom:f,nodeOrigin:u,nodeExtent:d,zIndexMode:p,children:e})}var hW={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function gW({nodes:e,edges:t,defaultNodes:a,defaultEdges:n,className:o,nodeTypes:r,edgeTypes:s,onNodeClick:i,onEdgeClick:l,onInit:c,onMove:f,onMoveStart:u,onMoveEnd:d,onConnect:p,onConnectStart:g,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:x,onNodeMouseEnter:y,onNodeMouseMove:h,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:C,onNodeDragStart:I,onNodeDrag:L,onNodeDragStop:N,onNodesDelete:P,onEdgesDelete:O,onDelete:B,onSelectionChange:U,onSelectionDragStart:R,onSelectionDrag:E,onSelectionDragStop:M,onSelectionContextMenu:A,onSelectionStart:H,onSelectionEnd:V,onBeforeDelete:D,connectionMode:Q,connectionLineType:K=ar.Bezier,connectionLineStyle:ue,connectionLineComponent:re,connectionLineContainerStyle:se,deleteKeyCode:_="Backspace",selectionKeyCode:ne="Shift",selectionOnDrag:q=!1,selectionMode:W=yl.Full,panActivationKeyCode:ce="Space",multiSelectionKeyCode:de=Sc()?"Meta":"Control",zoomActivationKeyCode:F=Sc()?"Meta":"Control",snapToGrid:G,snapGrid:ie,onlyRenderVisibleElements:Z=!1,selectNodesOnDrag:Le,nodesDraggable:Be,autoPanOnNodeFocus:yt,nodesConnectable:rt,nodesFocusable:Vt,nodeOrigin:Ge=ED,edgesFocusable:tt,edgesReconnectable:za,elementsSelectable:Nt=!0,defaultViewport:xn=q$,minZoom:so=.5,maxZoom:Za=2,translateExtent:rr=xc,preventScrolling:Ll=!0,nodeExtent:Js,defaultMarkerColor:Fr="#b1b1b7",zoomOnScroll:bp=!0,zoomOnPinch:Hr=!0,panOnScroll:Px=!1,panOnScrollSpeed:Ox=.5,panOnScrollMode:wp=zr.Free,zoomOnDoubleClick:Sp=!0,panOnDrag:Pn=!0,onPaneClick:zx,onPaneMouseEnter:Ic,onPaneMouseMove:Ro,onPaneMouseLeave:Cp,onPaneScroll:Bx,onPaneContextMenu:kp,paneClickDistance:Lp=1,nodeClickDistance:Ae=0,children:zt,onReconnect:Qt,onReconnectStart:La,onReconnectEnd:ei,onEdgeContextMenu:Gt,onEdgeDoubleClick:Qa,onEdgeMouseEnter:On,onEdgeMouseMove:Nc,onEdgeMouseLeave:zn,reconnectRadius:Rc=10,onNodesChange:Z_,onEdgesChange:Q_,noDragClassName:J_="nodrag",noWheelClassName:e8="nowheel",noPanClassName:t2="nopan",fitView:a2,fitViewOptions:n2,connectOnClick:t8,attributionPosition:a8,proOptions:n8,defaultEdgeOptions:o8,elevateNodesOnSelect:r8=!0,elevateEdgesOnSelect:s8=!1,disableKeyboardA11y:o2=!1,autoPanOnConnect:i8,autoPanOnNodeDrag:l8,autoPanOnSelection:u8=!0,autoPanSpeed:c8,connectionRadius:d8,isValidConnection:f8,onError:p8,style:m8,id:r2,nodeDragThreshold:h8,connectionDragThreshold:g8,viewport:x8,onViewportChange:v8,width:y8,height:b8,colorMode:w8="light",debug:S8,onScroll:s2,ariaLabelConfig:C8,zIndexMode:i2="basic",...k8},L8){let Fx=r2||"1",I8=j$(w8),N8=(0,J.useCallback)(l2=>{l2.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),s2?.(l2)},[s2]);return(0,Y.jsx)("div",{"data-testid":"rf__wrapper",...k8,onScroll:N8,style:{...m8,...hW},ref:L8,className:At(["react-flow",o,I8]),id:r2,role:"application",children:(0,Y.jsxs)(mW,{nodes:e,edges:t,width:y8,height:b8,fitView:a2,fitViewOptions:n2,minZoom:so,maxZoom:Za,nodeOrigin:Ge,nodeExtent:Js,zIndexMode:i2,children:[(0,Y.jsx)(G$,{nodes:e,edges:t,defaultNodes:a,defaultEdges:n,onConnect:p,onConnectStart:g,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:x,nodesDraggable:Be,autoPanOnNodeFocus:yt,nodesConnectable:rt,nodesFocusable:Vt,edgesFocusable:tt,edgesReconnectable:za,elementsSelectable:Nt,elevateNodesOnSelect:r8,elevateEdgesOnSelect:s8,minZoom:so,maxZoom:Za,nodeExtent:Js,onNodesChange:Z_,onEdgesChange:Q_,snapToGrid:G,snapGrid:ie,connectionMode:Q,translateExtent:rr,connectOnClick:t8,defaultEdgeOptions:o8,fitView:a2,fitViewOptions:n2,onNodesDelete:P,onEdgesDelete:O,onDelete:B,onNodeDragStart:I,onNodeDrag:L,onNodeDragStop:N,onSelectionDrag:E,onSelectionDragStart:R,onSelectionDragStop:M,onMove:f,onMoveStart:u,onMoveEnd:d,noPanClassName:t2,nodeOrigin:Ge,rfId:Fx,autoPanOnConnect:i8,autoPanOnNodeDrag:l8,autoPanSpeed:c8,onError:p8,connectionRadius:d8,isValidConnection:f8,selectNodesOnDrag:Le,nodeDragThreshold:h8,connectionDragThreshold:g8,onBeforeDelete:D,debug:S8,ariaLabelConfig:C8,zIndexMode:i2}),(0,Y.jsx)(dW,{onInit:c,onNodeClick:i,onEdgeClick:l,onNodeMouseEnter:y,onNodeMouseMove:h,onNodeMouseLeave:w,onNodeContextMenu:S,onNodeDoubleClick:C,nodeTypes:r,edgeTypes:s,connectionLineType:K,connectionLineStyle:ue,connectionLineComponent:re,connectionLineContainerStyle:se,selectionKeyCode:ne,selectionOnDrag:q,selectionMode:W,deleteKeyCode:_,multiSelectionKeyCode:de,panActivationKeyCode:ce,zoomActivationKeyCode:F,onlyRenderVisibleElements:Z,defaultViewport:xn,translateExtent:rr,minZoom:so,maxZoom:Za,preventScrolling:Ll,zoomOnScroll:bp,zoomOnPinch:Hr,zoomOnDoubleClick:Sp,panOnScroll:Px,panOnScrollSpeed:Ox,panOnScrollMode:wp,panOnDrag:Pn,autoPanOnSelection:u8,onPaneClick:zx,onPaneMouseEnter:Ic,onPaneMouseMove:Ro,onPaneMouseLeave:Cp,onPaneScroll:Bx,onPaneContextMenu:kp,paneClickDistance:Lp,nodeClickDistance:Ae,onSelectionContextMenu:A,onSelectionStart:H,onSelectionEnd:V,onReconnect:Qt,onReconnectStart:La,onReconnectEnd:ei,onEdgeContextMenu:Gt,onEdgeDoubleClick:Qa,onEdgeMouseEnter:On,onEdgeMouseMove:Nc,onEdgeMouseLeave:zn,reconnectRadius:Rc,defaultMarkerColor:Fr,noDragClassName:J_,noWheelClassName:e8,noPanClassName:t2,rfId:Fx,disableKeyboardA11y:o2,nodeExtent:Js,viewport:x8,onViewportChange:v8,nodesDraggable:Be}),(0,Y.jsx)(H$,{onSelectionChange:U}),zt,(0,Y.jsx)(P$,{proOptions:n8,position:a8}),(0,Y.jsx)(_$,{rfId:Fx,disableKeyboardA11y:o2})]})})}var r_=DD(gW),xW=e=>e.domNode?.querySelector(".react-flow__edgelabel-renderer");function s_({children:e}){let t=je(xW);return t?(0,ND.createPortal)(e,t):null}var Gpe=_n.error014();function vW({dimensions:e,lineWidth:t,variant:a,className:n}){return(0,Y.jsx)("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:At(["react-flow__background-pattern",a,n])})}function yW({radius:e,className:t}){return(0,Y.jsx)("circle",{cx:e,cy:e,r:e,className:At(["react-flow__background-pattern","dots",t])})}var nr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(nr||(nr={}));var bW={[nr.Dots]:1,[nr.Lines]:1,[nr.Cross]:6},wW=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function i_({id:e,variant:t=nr.Dots,gap:a=20,size:n,lineWidth:o=1,offset:r=0,color:s,bgColor:i,style:l,className:c,patternClassName:f}){let u=(0,J.useRef)(null),{transform:d,patternId:p}=je(wW,kt),g=n||bW[t],v=t===nr.Dots,b=t===nr.Cross,x=Array.isArray(a)?a:[a,a],y=[x[0]*d[2]||1,x[1]*d[2]||1],h=g*d[2],w=Array.isArray(r)?r:[r,r],S=b?[h,h]:y,C=[w[0]*d[2]+S[0]/2,w[1]*d[2]+S[1]/2],I=`${p}${e||""}`;return(0,Y.jsxs)("svg",{className:At(["react-flow__background",c]),style:{...l,...Ex,"--xy-background-color-props":i,"--xy-background-pattern-color-props":s},ref:u,"data-testid":"rf__background",children:[(0,Y.jsx)("pattern",{id:I,x:d[0]%y[0],y:d[1]%y[1],width:y[0],height:y[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`,children:v?(0,Y.jsx)(yW,{radius:h/2,className:f}):(0,Y.jsx)(vW,{dimensions:S,lineWidth:o,variant:t,className:f})}),(0,Y.jsx)("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${I})`})]})}i_.displayName="Background";var l_=(0,J.memo)(i_);function SW(){return(0,Y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:(0,Y.jsx)("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function CW(){return(0,Y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:(0,Y.jsx)("path",{d:"M0 0h32v4.2H0z"})})}function kW(){return(0,Y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:(0,Y.jsx)("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"})})}function LW(){return(0,Y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,Y.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"})})}function IW(){return(0,Y.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:(0,Y.jsx)("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"})})}function Nx({children:e,className:t,...a}){return(0,Y.jsx)("button",{type:"button",className:At(["react-flow__controls-button",t]),...a,children:e})}var NW=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function u_({style:e,showZoom:t=!0,showFitView:a=!0,showInteractive:n=!0,fitViewOptions:o,onZoomIn:r,onZoomOut:s,onFitView:i,onInteractiveChange:l,className:c,children:f,position:u="bottom-left",orientation:d="vertical","aria-label":p}){let g=vt(),{isInteractive:v,minZoomReached:b,maxZoomReached:x,ariaLabelConfig:y}=je(NW,kt),{zoomIn:h,zoomOut:w,fitView:S}=vp(),C=()=>{h(),r?.()},I=()=>{w(),s?.()},L=()=>{S(o),i?.()},N=()=>{g.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),l?.(!v)};return(0,Y.jsxs)(Mx,{className:At(["react-flow__controls",d==="horizontal"?"horizontal":"vertical",c]),position:u,style:e,"data-testid":"rf__controls","aria-label":p??y["controls.ariaLabel"],children:[t&&(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(Nx,{onClick:C,className:"react-flow__controls-zoomin",title:y["controls.zoomIn.ariaLabel"],"aria-label":y["controls.zoomIn.ariaLabel"],disabled:x,children:(0,Y.jsx)(SW,{})}),(0,Y.jsx)(Nx,{onClick:I,className:"react-flow__controls-zoomout",title:y["controls.zoomOut.ariaLabel"],"aria-label":y["controls.zoomOut.ariaLabel"],disabled:b,children:(0,Y.jsx)(CW,{})})]}),a&&(0,Y.jsx)(Nx,{className:"react-flow__controls-fitview",onClick:L,title:y["controls.fitView.ariaLabel"],"aria-label":y["controls.fitView.ariaLabel"],children:(0,Y.jsx)(kW,{})}),n&&(0,Y.jsx)(Nx,{className:"react-flow__controls-interactive",onClick:N,title:y["controls.interactive.ariaLabel"],"aria-label":y["controls.interactive.ariaLabel"],children:v?(0,Y.jsx)(IW,{}):(0,Y.jsx)(LW,{})}),f]})}u_.displayName="Controls";var c_=(0,J.memo)(u_);function RW({id:e,x:t,y:a,width:n,height:o,style:r,color:s,strokeColor:i,strokeWidth:l,className:c,borderRadius:f,shapeRendering:u,selected:d,onClick:p}){let{background:g,backgroundColor:v}=r||{},b=s||g||v;return(0,Y.jsx)("rect",{className:At(["react-flow__minimap-node",{selected:d},c]),x:t,y:a,rx:f,ry:f,width:n,height:o,style:{fill:b,stroke:i,strokeWidth:l},shapeRendering:u,onClick:p?x=>p(x,e):void 0})}var TW=(0,J.memo)(RW),MW=e=>e.nodes.map(t=>t.id),Vw=e=>e instanceof Function?e:()=>e;function EW({nodeStrokeColor:e,nodeColor:t,nodeClassName:a="",nodeBorderRadius:n=5,nodeStrokeWidth:o,nodeComponent:r=TW,onClick:s}){let i=je(MW,kt),l=Vw(t),c=Vw(e),f=Vw(a),u=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return(0,Y.jsx)(Y.Fragment,{children:i.map(d=>(0,Y.jsx)(DW,{id:d,nodeColorFunc:l,nodeStrokeColorFunc:c,nodeClassNameFunc:f,nodeBorderRadius:n,nodeStrokeWidth:o,NodeComponent:r,onClick:s,shapeRendering:u},d))})}function AW({id:e,nodeColorFunc:t,nodeStrokeColorFunc:a,nodeClassNameFunc:n,nodeBorderRadius:o,nodeStrokeWidth:r,shapeRendering:s,NodeComponent:i,onClick:l}){let{node:c,x:f,y:u,width:d,height:p}=je(g=>{let v=g.nodeLookup.get(e);if(!v)return{node:void 0,x:0,y:0,width:0,height:0};let b=v.internals.userNode,{x,y}=v.internals.positionAbsolute,{width:h,height:w}=ro(b);return{node:b,x,y,width:h,height:w}},kt);return!c||c.hidden||!Nw(c)?null:(0,Y.jsx)(i,{x:f,y:u,width:d,height:p,style:c.style,selected:!!c.selected,className:n(c),color:t(c),borderRadius:o,strokeColor:a(c),strokeWidth:r,shapeRendering:s,onClick:l,id:c.id})}var DW=(0,J.memo)(AW),_W=(0,J.memo)(EW),PW=200,OW=150,zW=e=>!e.hidden,BW=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]},a=!1;for(let n of e.nodeLookup.values())if(!n.hidden){a=!0;break}return{viewBB:t,boundingRect:a?kw(vc(e.nodeLookup,{filter:zW}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},LD=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,FW=(e,t)=>LD(e.viewBB,t.viewBB)&&LD(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,HW="react-flow__minimap-desc";function d_({style:e,className:t,nodeStrokeColor:a,nodeColor:n,nodeClassName:o="",nodeBorderRadius:r=5,nodeStrokeWidth:s,nodeComponent:i,bgColor:l,maskColor:c,maskStrokeColor:f,maskStrokeWidth:u,position:d="bottom-right",onClick:p,onNodeClick:g,pannable:v=!1,zoomable:b=!1,ariaLabel:x,inversePan:y,zoomStep:h=1,offsetScale:w=5}){let S=vt(),C=(0,J.useRef)(null),{boundingRect:I,panZoom:L,viewBB:N,rfId:P,translateExtent:O,flowWidth:B,flowHeight:U,ariaLabelConfig:R}=je(BW,FW),E=e?.width??PW,M=e?.height??OW,A=I.width/E,H=I.height/M,V=Math.max(A,H),D=V*E,Q=V*M,K=w*V,ue=I.x-(D-I.width)/2-K,re=I.y-(Q-I.height)/2-K,se=D+K*2,_=Q+K*2,ne=`${HW}-${P}`,q=(0,J.useRef)(0),W=(0,J.useRef)();q.current=V,(0,J.useEffect)(()=>{let ie=S.getState().panZoom;if(C.current&&ie)return W.current=A6({domNode:C.current,panZoom:ie,getTransform:()=>S.getState().transform,getViewScale:()=>q.current}),()=>{W.current?.destroy()}},[L]),(0,J.useEffect)(()=>{W.current?.update({translateExtent:O,width:B,height:U,inversePan:y,pannable:v,zoomStep:h,zoomable:b})},[v,b,y,h,O,B,U]);let ce=p?ie=>{let[Z,Le]=W.current?.pointer(ie)||[0,0];p(ie,{x:Z,y:Le})}:void 0,de=(0,J.useCallback)((ie,Z)=>{let Le=S.getState().nodeLookup.get(Z).internals.userNode;g?.(ie,Le)},[g]),F=g?de:void 0,G=x??R["minimap.ariaLabel"];return(0,Y.jsx)(Mx,{position:d,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-color-props":typeof f=="string"?f:void 0,"--xy-minimap-mask-stroke-width-props":typeof u=="number"?u*V:void 0,"--xy-minimap-node-background-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-color-props":typeof a=="string"?a:void 0,"--xy-minimap-node-stroke-width-props":typeof s=="number"?s:void 0},className:At(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:(0,Y.jsxs)("svg",{width:E,height:M,viewBox:`${ue} ${re} ${se} ${_}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ne,ref:C,onClick:ce,children:[G&&(0,Y.jsx)("title",{id:ne,children:G}),(0,Y.jsx)(_W,{onClick:F,nodeColor:n,nodeStrokeColor:a,nodeBorderRadius:r,nodeClassName:o,nodeStrokeWidth:s,nodeComponent:i}),(0,Y.jsx)("path",{className:"react-flow__minimap-mask",d:`M${ue-K},${re-K}h${se+K*2}v${_+K*2}h${-se-K*2}z
59
- M${N.x},${N.y}h${N.width}v${N.height}h${-N.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}d_.displayName="MiniMap";var jpe=(0,J.memo)(d_),qW=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,UW={[Br.Line]:"right",[Br.Handle]:"bottom-right"};function VW({nodeId:e,position:t,variant:a=Br.Handle,className:n,style:o=void 0,children:r,color:s,minWidth:i=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:d,autoScale:p=!0,shouldResize:g,onResizeStart:v,onResize:b,onResizeEnd:x}){let y=BD(),h=typeof e=="string"?e:y,w=vt(),S=(0,J.useRef)(null),C=a===Br.Handle,I=je((0,J.useCallback)(qW(C&&p),[C,p]),kt),L=(0,J.useRef)(null),N=t??UW[a];(0,J.useEffect)(()=>{if(!(!S.current||!h))return L.current||(L.current=F6({domNode:S.current,nodeId:h,getStoreItems:()=>{let{nodeLookup:O,transform:B,snapGrid:U,snapToGrid:R,nodeOrigin:E,domNode:M}=w.getState();return{nodeLookup:O,transform:B,snapGrid:U,snapToGrid:R,nodeOrigin:E,paneDomNode:M}},onChange:(O,B)=>{let{triggerNodeChanges:U,nodeLookup:R,parentLookup:E,nodeOrigin:M}=w.getState(),A=[],H={x:O.x,y:O.y},V=R.get(h);if(V&&V.expandParent&&V.parentId){let D=V.origin??M,Q=O.width??V.measured.width??0,K=O.height??V.measured.height??0,ue={id:V.id,parentId:V.parentId,rect:{width:Q,height:K,...Rw({x:O.x??V.position.x,y:O.y??V.position.y},{width:Q,height:K},V.parentId,R,D)}},re=Sx([ue],R,E,M);A.push(...re),H.x=O.x?Math.max(D[0]*Q,O.x):void 0,H.y=O.y?Math.max(D[1]*K,O.y):void 0}if(H.x!==void 0&&H.y!==void 0){let D={id:h,type:"position",position:{...H}};A.push(D)}if(O.width!==void 0&&O.height!==void 0){let Q={id:h,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};A.push(Q)}for(let D of B){let Q={...D,type:"position"};A.push(Q)}U(A)},onEnd:({width:O,height:B})=>{let U={id:h,type:"dimensions",resizing:!1,dimensions:{width:O,height:B}};w.getState().triggerNodeChanges([U])}})),L.current.update({controlPosition:N,boundaries:{minWidth:i,minHeight:l,maxWidth:c,maxHeight:f},keepAspectRatio:u,resizeDirection:d,onResizeStart:v,onResize:b,onResizeEnd:x,shouldResize:g}),()=>{L.current?.destroy()}},[N,i,l,c,f,u,v,b,x,g]);let P=N.split("-");return(0,Y.jsx)("div",{className:At(["react-flow__resize-control","nodrag",...P,a,n]),ref:S,style:{...o,scale:I,...s&&{[C?"backgroundColor":"borderColor"]:s}},children:r})}var ID=(0,J.memo)(VW);function f_({nodeId:e,isVisible:t=!0,handleClassName:a,handleStyle:n,lineClassName:o,lineStyle:r,color:s,minWidth:i=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,autoScale:d=!0,shouldResize:p,onResizeStart:g,onResize:v,onResizeEnd:b}){return t?(0,Y.jsxs)(Y.Fragment,{children:[z6.map(x=>(0,Y.jsx)(ID,{className:o,style:r,nodeId:e,position:x,variant:Br.Line,color:s,minWidth:i,minHeight:l,maxWidth:c,maxHeight:f,onResizeStart:g,keepAspectRatio:u,autoScale:d,shouldResize:p,onResize:v,onResizeEnd:b},x)),O6.map(x=>(0,Y.jsx)(ID,{className:a,style:n,nodeId:e,position:x,color:s,minWidth:i,minHeight:l,maxWidth:c,maxHeight:f,onResizeStart:g,keepAspectRatio:u,autoScale:d,shouldResize:p,onResize:v,onResizeEnd:b},x))]}):null}var me=$(ge(),1);var m=$(pe(),1);function Zs({name:e,size:t="sm"}){let a=[...e].reduce((o,r)=>(o*31+r.charCodeAt(0))%360,7),n=e.split(/[\s._-]+/).filter(Boolean).map(o=>o[0].toUpperCase()).slice(0,2).join("")||e.slice(0,2).toUpperCase();return(0,m.jsx)("span",{title:e,"aria-label":e,className:ae("inline-flex shrink-0 items-center justify-center rounded-full font-semibold text-white",t==="sm"?"size-5 text-[9px]":"size-7 text-[11px]"),style:{background:`hsl(${a} 45% 45%)`},children:n})}var yp={slate:"#64748b",blue:"#3b82f6",violet:"#8b5cf6",amber:"#d97706",green:"#059669",rose:"#e11d48"},h_={inbox:(0,m.jsx)(Fi,{className:"size-3.5","aria-hidden":"true"}),task:(0,m.jsx)(ef,{className:"size-3.5","aria-hidden":"true"}),report:(0,m.jsx)(gf,{className:"size-3.5","aria-hidden":"true"}),approval:(0,m.jsx)(wf,{className:"size-3.5","aria-hidden":"true"}),notify:(0,m.jsx)(uf,{className:"size-3.5","aria-hidden":"true"}),done:(0,m.jsx)(Kd,{className:"size-3.5","aria-hidden":"true"}),check:(0,m.jsx)(eo,{className:"size-3.5","aria-hidden":"true"}),"pull-request":(0,m.jsx)(Is,{className:"size-3.5","aria-hidden":"true"}),update:(0,m.jsx)(cf,{className:"size-3.5","aria-hidden":"true"}),sort:(0,m.jsx)(Uu,{className:"size-3.5","aria-hidden":"true"}),draft:(0,m.jsx)(Ts,{className:"size-3.5","aria-hidden":"true"}),request:(0,m.jsx)(Jd,{className:"size-3.5","aria-hidden":"true"}),email:(0,m.jsx)(Hu,{className:"size-3.5","aria-hidden":"true"}),tool:(0,m.jsx)(Ui,{className:"size-3.5","aria-hidden":"true"}),wait:(0,m.jsx)(af,{className:"size-3.5","aria-hidden":"true"}),teammate:(0,m.jsx)(Pi,{className:"size-3.5","aria-hidden":"true"}),send:(0,m.jsx)(xf,{className:"size-3.5","aria-hidden":"true"}),choose:(0,m.jsx)(yf,{className:"size-3.5","aria-hidden":"true"})};function Ww({sorted:e}){return(0,m.jsxs)("span",{className:ae("inline-flex max-w-full items-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-[11px] font-medium",!e.confident&&"text-warning"),title:e.confident?"Sorted by Jev":"Jev wasn't sure","data-sort-chip":!0,children:[(0,m.jsx)(Uu,{className:"size-3 shrink-0",style:{color:e.confident?yp.violet:void 0},"aria-hidden":"true"}),(0,m.jsx)("span",{className:"truncate",children:e.confident?e.chip:`Not sure · ${e.chip}`})]})}var g_={button:(0,m.jsx)(qu,{className:"size-3.5","aria-hidden":"true"}),schedule:(0,m.jsx)(Gd,{className:"size-3.5","aria-hidden":"true"}),github:(0,m.jsx)(Is,{className:"size-3.5","aria-hidden":"true"}),linear:(0,m.jsx)(Ms,{className:"size-3.5","aria-hidden":"true"}),flow:(0,m.jsx)(qi,{className:"size-3.5","aria-hidden":"true"}),webhook:(0,m.jsx)(Sf,{className:"size-3.5","aria-hidden":"true"}),email:(0,m.jsx)(Hu,{className:"size-3.5","aria-hidden":"true"}),chat:(0,m.jsx)(Rs,{className:"size-3.5","aria-hidden":"true"})};async function ka(e,t,a){let n=new URLSearchParams({csrf:a,...t});try{let o=await fetch(e,{method:"POST",body:n,credentials:"same-origin",headers:{accept:"application/json"},signal:AbortSignal.timeout(2e4)}),r=await o.json();return{ok:r.ok===!0,said:typeof r.said=="string"?r.said:o.ok?"Done.":"That didn't go through.",...r.view===void 0?{}:{view:r.view},...r.reveal===void 0?{}:{reveal:r.reveal}}}catch{return{ok:!1,said:"That didn't go through. Check your connection and try again."}}}function x_(e,t,a){let[n,o]=(0,me.useState)([]),r=(0,me.useRef)(e.live);r.current=e.live;let s=(0,me.useRef)(a.editing);s.current=a.editing;let i=(0,me.useRef)(!1),l=e.flow.href,c=(0,me.useCallback)(async()=>{if(!(i.current||s.current)){i.current=!0;try{let f=await fetch(`${l}?format=json`,{credentials:"same-origin",headers:{accept:"application/json"}});if(f.ok){let u=await f.json();r.current=u.live,t(u)}}catch{}finally{i.current=!1}}},[l,t]);return(0,me.useEffect)(()=>{let f=null,u,d=new URLSearchParams({...a.card===null?{}:{card:String(a.card)},...a.editing?{editing:"1"}:{}}).toString(),p=()=>{window.clearInterval(u),u=window.setInterval(()=>{document.visibilityState==="visible"&&c()},5e3)},g=()=>{if(typeof EventSource>"u"){p();return}let x=new EventSource(`${l}/live${d===""?"":`?${d}`}`);f=x,x.addEventListener("change",y=>{try{let h=JSON.parse(y.data).at;(h===null||h!==r.current)&&c()}catch{c()}}),x.addEventListener("here",y=>{try{o(JSON.parse(y.data).people)}catch{}}),x.addEventListener("gone",()=>{x.close(),f===x&&(f=null),o([])}),x.addEventListener("open",()=>window.clearInterval(u)),x.addEventListener("error",()=>{x.readyState===EventSource.CLOSED&&(f===x&&(f=null),o([]),p())})},v=()=>{f?.close(),f=null,window.clearInterval(u),o([])},b=()=>{document.hidden?v():f===null&&(g(),c())};return document.hidden||g(),document.addEventListener("visibilitychange",b),()=>{document.removeEventListener("visibilitychange",b),v()}},[l,a.card,a.editing,c]),n}function v_({others:e,cards:t}){if(e.length===0)return null;let a=r=>{if(r.editing)return"changing this flow";let s=r.cards.map(i=>t.find(l=>l.id===i)?.title).filter(i=>i!==void 0);return s.length===0?"looking at the flow":`looking at ${s.map(i=>`“${i}”`).join(", ")}`},n=e.map(r=>`${r.name} is ${a(r)}`).join(". "),o=e.find(r=>r.editing);return(0,m.jsxs)("div",{className:"inline-flex min-w-0 items-center gap-1.5","data-also-here":!0,role:"status","aria-label":`Also here: ${n}`,title:n,children:[(0,m.jsx)("span",{className:"flex -space-x-1.5",children:e.slice(0,4).map(r=>(0,m.jsx)("span",{className:"rounded-full ring-2 ring-card",children:(0,m.jsx)(Zs,{name:r.name})},r.name))}),(0,m.jsx)("span",{className:"truncate text-[12px] text-muted-foreground",children:o!==void 0?`${o.name} is changing this flow`:e.length===1?`${e[0].name} is here`:`${e.length} others here`})]})}function GW({data:e,selected:t}){let{stage:a,cards:n,editing:o,canMove:r}=e,s=yp[a.zone.color]??yp.slate,[i,l]=(0,me.useState)(!1),c=ae("!size-2.5 !border-2 !border-card",!o&&"!opacity-0");return(0,m.jsxs)("div",{className:ae("flex h-full flex-col overflow-hidden rounded-xl border bg-muted/40 shadow-sm",t&&o?"ring-2 ring-primary":"",i&&"ring-2 ring-primary/60"),onDragOver:f=>{!r||o||(f.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:f=>{l(!1);let u=Number(f.dataTransfer.getData("text/so-card"));u>0&&e.onDrop(u,a.id)},"data-zone":a.id,children:[o&&(0,m.jsx)(f_,{isVisible:t,minWidth:220,minHeight:160,lineClassName:"!border-primary",handleClassName:"!size-2 !bg-primary",onResizeEnd:(f,u)=>e.onResize(a.id,u)}),(0,m.jsx)(or,{type:"source",position:we.Right,id:"next",className:ae(c,"!bg-primary"),isConnectable:o}),(0,m.jsx)(or,{type:"source",position:we.Bottom,id:"fail",className:ae(c,"!bg-destructive"),style:{left:"75%"},isConnectable:o}),["Left","Right","Top","Bottom"].map(f=>(0,m.jsx)(or,{type:"target",position:we[f],id:`t-${f}`,className:c,isConnectable:o},`t-${f}`)),["Left","Right","Top","Bottom"].map(f=>(0,m.jsx)(or,{type:"source",position:we[f],id:`s-${f}`,className:"!opacity-0 !pointer-events-none",isConnectable:!1},`s-${f}`)),(0,m.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2",children:[(0,m.jsx)("span",{className:"inline-flex size-6 items-center justify-center rounded-md text-white",style:{background:s},children:h_[a.kind]}),(0,m.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,m.jsx)("div",{className:"truncate text-[13px] font-semibold",children:a.title}),(0,m.jsxs)("div",{className:"truncate text-[11px] text-muted-foreground",children:[e.kindLabel,e.start?" · new cards start here":"",e.teammate!==null?` · ${e.teammate}`:a.toOwner===!0?` · ${e.owner}`:a.approver?` · ${a.approver}`:""]})]}),n.length>0&&(0,m.jsx)("span",{className:"rounded-full bg-muted px-1.5 text-[11px] font-semibold text-muted-foreground",children:n.length})]}),(0,m.jsxs)("ul",{className:"nowheel flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-2",children:[n.map(f=>(0,m.jsx)("li",{children:(0,m.jsxs)("button",{type:"button",draggable:r&&!o,onDragStart:u=>{u.dataTransfer.setData("text/so-card",String(f.id)),u.dataTransfer.effectAllowed="move"},onClick:()=>e.onCard(f.id),className:ae("nodrag nopan w-full cursor-pointer rounded-lg border bg-card px-2.5 py-2 text-left shadow-xs transition-colors hover:border-primary/50",e.selectedCard===f.id&&"border-primary ring-1 ring-primary",f.canDecide&&"border-attention/60"),"data-card":f.id,children:[(0,m.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,m.jsx)("div",{className:"line-clamp-2 min-w-0 flex-1 text-[12.5px] font-medium leading-snug",children:f.title}),(e.lookers[f.id]?.length??0)>0&&(0,m.jsx)("span",{className:"flex shrink-0 -space-x-1","data-card-lookers":!0,title:`${e.lookers[f.id].join(" and ")} ${e.lookers[f.id].length===1?"is":"are"} looking at this`,children:e.lookers[f.id].slice(0,2).map(u=>(0,m.jsx)("span",{className:"rounded-full ring-2 ring-primary/70",children:(0,m.jsx)(Zs,{name:u})},u))})]}),f.sorted!==null&&(0,m.jsx)("div",{className:"mt-1 flex",children:(0,m.jsx)(Ww,{sorted:f.sorted})}),f.waiting!==null&&(0,m.jsx)("div",{className:ae("mt-1 line-clamp-2 text-[11px] leading-snug",f.canDecide||f.question?.mine?"font-semibold text-attention":"text-muted-foreground"),children:f.canDecide?Vf.card.sentence({}):f.question?.mine?`${f.question.from.split(" · ")[0]} asks you`:f.waiting}),f.deadline!=null&&(0,m.jsx)("div",{className:"mt-0.5 text-[11px] text-muted-foreground","data-card-deadline":!0,children:Dh(f.deadline)}),(f.owner!==null||f.comments.length>0)&&(0,m.jsxs)("div",{className:"mt-1.5 flex items-center gap-1.5",children:[f.owner!==null&&(0,m.jsx)(Zs,{name:f.owner}),(0,m.jsx)("span",{className:"flex-1"}),f.comments.length>0&&(0,m.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[11px] text-muted-foreground",children:[(0,m.jsx)(Rs,{className:"size-3","aria-hidden":"true"}),f.comments.length]})]})]})},f.id)),n.length===0&&(0,m.jsx)("li",{className:"px-1 py-2 text-[11px] text-muted-foreground",children:o?a.kind==="done"?"":"Drag the dots to connect zones.":e.hidden>0?"":"No cards here."}),e.hidden>0&&(0,m.jsxs)("li",{className:"px-1 py-1 text-[11px] text-muted-foreground",children:[e.hidden," other card",e.hidden===1?"":"s"]})]})]})}var y_=44,b_=30;function jW({data:e}){return(0,m.jsxs)("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border bg-card shadow-sm","data-trigger-group":!0,children:[(0,m.jsx)(or,{type:"source",position:we.Right,id:"out",className:"!opacity-0 !pointer-events-none",isConnectable:!1}),(0,m.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",style:{height:b_},children:[(0,m.jsx)(Es,{className:"size-3","aria-hidden":"true"}),"Starts cards"]}),e.triggers.map(t=>{let a=t.failing||t.hook!==null&&!t.hook.ready,n=t.state==="paused"?"Paused":t.failing?"Needs attention":t.hook!==null&&!t.hook.ready?"Needs its secret":t.detail;return(0,m.jsxs)("div",{className:ae("flex items-center gap-2 border-t px-2.5",t.state==="paused"&&"opacity-60"),style:{height:y_},"data-trigger":t.id,children:[(0,m.jsx)("span",{className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:g_[t.kind]??(0,m.jsx)(Es,{className:"size-3.5","aria-hidden":"true"})}),(0,m.jsxs)("button",{type:"button",className:"nodrag nopan min-w-0 flex-1 cursor-pointer text-left",onClick:()=>e.onOpen(t.id),"aria-label":`Trigger: ${t.words}`,children:[(0,m.jsx)("div",{className:"truncate text-[12px] font-semibold",children:t.name}),(0,m.jsx)("div",{className:ae("truncate text-[11px]",a?"text-warning":"text-muted-foreground"),children:n})]}),t.button!==null&&t.state==="active"&&(0,m.jsx)(te,{size:"sm",className:"nodrag nopan h-7 px-2.5",onClick:()=>e.onPress(t.id),children:"Start"})]},t.id)})]})}var $W={zone:GW,trigger:jW};function XW({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:o,targetPosition:r,label:s,labelStyle:i,labelBgStyle:l,markerEnd:c,style:f,data:u}){let{path:d,shift:p}=u??{},[g,v,b]=Ks({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:o,targetPosition:r,...d}),x=i;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Lc,{path:g,...c===void 0?{}:{markerEnd:c},...f===void 0?{}:{style:f}}),(0,m.jsx)(s_,{children:(0,m.jsx)("div",{className:"nodrag nopan pointer-events-none absolute rounded-sm px-1 leading-4 whitespace-nowrap",style:{transform:`translate(-50%, -50%) translate(${v+(p?.x??0)}px, ${b+(p?.y??0)}px)`,color:x?.fill,fontSize:x?.fontSize,fontWeight:x?.fontWeight,background:l?.fill},children:s})})]})}var WW={named:XW};function YW(e,t){let a=(r,s)=>{let i=t.find(u=>u.id===r)?.zone;if(i===void 0||s==null)return null;let l=s.slice(2),c=l==="Left"?i.x:l==="Right"?i.x+i.w:i.x+i.w/2,f=l==="Top"?i.y:l==="Bottom"?i.y+i.h:i.y+i.h/2;return{x:c,y:f,position:we[l]}},n=[],o=r=>n.some(s=>Math.abs(s.x-r.x)<(s.w+r.w)/2+4&&Math.abs(s.y-r.y)<(s.h+r.h)/2+2);return e.map(r=>{if(typeof r.label!="string"||r.type!=="smoothstep")return r;let s=a(r.source,r.sourceHandle),i=a(r.target,r.targetHandle);if(s===null||i===null)return r;let l=r.pathOptions,[,c,f]=Ks({sourceX:s.x,sourceY:s.y,sourcePosition:s.position,targetX:i.x,targetY:i.y,targetPosition:i.position,...l}),u=r.label.length*6.4+10,d=18,g=(s.position===we.Left||s.position===we.Right)&&(i.position===we.Left||i.position===we.Right)?{x:0,y:d+6}:{x:u/2+34,y:0},v={x:0,y:0};for(let y of[0,1,-1,2,-2,3,-3])if(v={x:g.x*y,y:g.y*y},!o({x:c+v.x,y:f+v.y,w:u,h:d}))break;n.push({x:c+v.x,y:f+v.y,w:u,h:d});let{pathOptions:b,...x}=r;return{...x,type:"named",data:{...r.data,path:l,shift:v}}})}function KW(e,t){let a=[],n=new Set,o=r=>{for(;r!==null&&!n.has(r);){let s=e.find(i=>i.id===r);if(s===void 0)return;n.add(r),a.push(s);for(let i of s.sort?.answers??[])o(i.to);s.sort!==null&&s.onFail!==null&&o(s.onFail),r=s.next}};o(t);for(let r of e)n.has(r.id)||o(r.id);return[...a.filter(r=>r.kind!=="done"),...a.filter(r=>r.kind==="done")]}function ZW(e,t){let a=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,24)||"zone",n=a,o=2;for(;t.has(n);)n=`${a}-${o++}`;return n}var Yw=e=>mn(e),QW=(e,t=new Date)=>Number.isNaN(new Date(e).getTime())?"":zu(e,t,Di(),!0),JW=e=>e%1440===0?`${e/1440} day${e===1440?"":"s"}`:e%60===0?`${e/60} h`:`${e} min`;function w_({link:e}){return e===null?null:(0,m.jsxs)(m.Fragment,{children:[" ",(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:e.href,"data-status-link":!0,children:e.label})]})}function eY({body:e,mentions:t}){if(t.length===0)return(0,m.jsx)(m.Fragment,{children:e});let a=new RegExp(`(@(?:${t.map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}))(?![A-Za-z0-9_])`,"gi");return(0,m.jsx)(m.Fragment,{children:e.split(a).map((n,o)=>o%2===1?(0,m.jsx)("span",{className:"font-semibold text-primary",children:n},o):n)})}function tY({card:e,view:t,csrf:a,apply:n}){let[o,r]=(0,me.useState)(""),[s,i]=(0,me.useState)(!1),l=/(?:^|\s)@([A-Za-z0-9_.-]*)$/.exec(o)?.[1],c=l===void 0?[]:t.approvers.filter(f=>f!==t.me&&f.toLowerCase().startsWith(l.toLowerCase())).slice(0,6);return(0,m.jsxs)("div",{className:"flex flex-col gap-2","data-flow-discussion":!0,children:[(0,m.jsx)("h3",{className:"text-[13px] font-semibold",children:"Discussion"}),e.comments.length===0?(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"No comments yet."}):(0,m.jsx)("ol",{className:"flex flex-col gap-3",children:e.comments.map(f=>(0,m.jsxs)("li",{className:"flex gap-2","data-comment":f.id,children:[(0,m.jsx)(Zs,{name:f.author,size:"md"}),(0,m.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,m.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:[(0,m.jsx)("span",{className:"font-semibold text-foreground",children:f.author})," · ",Yw(f.at)]}),(0,m.jsx)("p",{className:"whitespace-pre-wrap break-words text-[13px]",children:(0,m.jsx)(eY,{body:f.body,mentions:f.mentions})})]})]},f.id))}),t.canEdit&&(0,m.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:async f=>{f.preventDefault(),i(!0);let u=await ka(`${t.flow.href}/cards/${e.id}/comment`,{body:o},a);i(!1),n(u),u.ok&&r("")},children:[(0,m.jsx)(Ot,{value:o,onChange:f=>r(f.target.value),rows:3,maxLength:4e3,placeholder:"Add a comment. Type @ and a name to ping someone.","aria-label":"Comment"}),c.length>0&&(0,m.jsx)("div",{className:"flex flex-wrap gap-1.5","aria-label":"People to mention",children:c.map(f=>(0,m.jsxs)("button",{type:"button",className:"inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2 text-[12px] hover:border-primary/60",onClick:()=>r(u=>u.replace(/@([A-Za-z0-9_.-]*)$/,`@${f} `)),children:[(0,m.jsx)(Zs,{name:f}),f]},f))}),(0,m.jsx)(te,{type:"submit",size:"sm",className:"self-start",disabled:s||o.trim()==="",children:"Comment"})]})]})}function aY({card:e,view:t,csrf:a,apply:n}){let[o,r]=(0,me.useState)(!1),s=async(l,c)=>{r(!0),n(await ka(`${t.flow.href}/cards/${e.id}/${l}`,c,a)),r(!1)},i=e.watchers.filter(l=>l!==e.owner);return(0,m.jsxs)("div",{className:"flex flex-col gap-2","data-flow-card-people":!0,children:[t.canEdit&&e.state==="active"?(0,m.jsxs)("label",{className:"grid gap-1.5",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Owner"}),(0,m.jsxs)("select",{className:ht,value:e.owner??"",disabled:o,onChange:l=>{s("assign",{owner:l.target.value})},"aria-label":"Owner",children:[(0,m.jsx)("option",{value:"",children:"No owner"}),t.approvers.map(l=>(0,m.jsx)("option",{value:l,children:l===t.me?`${l} (you)`:l},l))]})]}):e.owner!==null&&(0,m.jsxs)("p",{className:"flex items-center gap-2 text-[13px]",children:[(0,m.jsx)(Zs,{name:e.owner})," Owned by ",e.owner]}),(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[t.canEdit&&e.state==="active"&&e.owner===null&&(0,m.jsx)(te,{size:"sm",variant:"outline",disabled:o,onClick:()=>{s("assign",{owner:t.me})},children:"Take it"}),i.length>0&&(0,m.jsxs)("span",{className:"flex items-center gap-1 text-[12px] text-muted-foreground",children:[i.slice(0,5).map(l=>(0,m.jsx)(Zs,{name:l},l)),i.length===1?" follows it":" follow it"]}),t.canEdit&&e.owner!==t.me&&(0,m.jsx)(te,{size:"sm",variant:"ghost",disabled:o,onClick:()=>{s("watch",{watching:e.watching?"no":"yes"})},"aria-pressed":e.watching,children:e.watching?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(qd,{className:"size-4"}),"Stop following"]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Ud,{className:"size-4"}),"Follow"]})})]})]})}function S_({links:e}){return(0,m.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:e.map(t=>(0,m.jsx)("a",{className:"text-[13px] font-medium text-primary underline-offset-4 hover:underline",href:t.href,...t.href.startsWith("/")?{}:{target:"_blank",rel:"noreferrer"},children:t.label},t.label))})}function C_({items:e}){return(0,m.jsx)("ol",{className:"flex flex-col gap-3","data-flow-items":!0,children:e.map(t=>(0,m.jsxs)("li",{className:"flex items-start gap-3","data-flow-item":t.number,children:[(0,m.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 text-[12.5px]",children:[(0,m.jsxs)("p",{className:"font-semibold",children:[t.number,". ",t.title]}),t.lines.map((a,n)=>(0,m.jsx)("p",{className:"break-words text-muted-foreground",children:a},n)),(0,m.jsx)("a",{className:"self-start font-medium text-primary underline-offset-4 hover:underline",href:t.url,target:"_blank",rel:"noreferrer",children:t.source})]}),t.image!==null&&(0,m.jsx)("a",{className:"w-28 shrink-0",href:t.image.src,target:"_blank",rel:"noreferrer",children:(0,m.jsx)("img",{className:"w-full rounded-md border object-cover object-top",style:{aspectRatio:"4 / 3"},src:t.image.src,alt:t.image.caption,loading:"lazy"})})]},t.number))})}function nY({sent:e}){return(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2","data-flow-sent":!0,children:[(0,m.jsxs)("summary",{className:"cursor-pointer text-[13px] font-medium",children:["Sent to ",e.person," · ",Yw(e.at)]}),(0,m.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:e.title}),(0,m.jsx)("p",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words text-[12.5px]",children:e.summary}),e.items!==void 0&&(0,m.jsx)(C_,{items:e.items}),e.links.length>0&&(0,m.jsx)(S_,{links:e.links})]})]})}function oY({choose:e,base:t,csrf:a,apply:n}){let[o,r]=(0,me.useState)(""),[s,i]=(0,me.useState)(!1),l=async c=>{i(!0);let f=await ka(`${t}/choose`,c,a);i(!1),n(f),f.ok&&r("")};return(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3","data-flow-choose":!0,children:[(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:e.title}),(0,m.jsx)("p",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words text-[12.5px]",children:e.summary}),e.items!==void 0&&(0,m.jsx)(C_,{items:e.items}),e.links.length>0&&(0,m.jsx)(S_,{links:e.links}),e.mine?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{className:"flex flex-wrap gap-2",children:e.options.map(c=>(0,m.jsx)(te,{size:"sm",variant:c.choice===0?"default":"outline",disabled:s,onClick:()=>{l({choice:String(c.choice),label:c.label,entry:String(e.entry)})},"data-flow-choice":c.choice,children:c.label},c.choice))}),e.reply&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Ot,{value:o,onChange:c=>r(c.target.value),rows:2,maxLength:2e3,placeholder:"Or say what you'd change","aria-label":"What you'd change"}),(0,m.jsx)(te,{size:"sm",variant:"outline",className:"self-start",disabled:s||o.trim()==="",onClick:()=>{l({note:o,entry:String(e.entry)})},children:"Send reply"})]})]}):(0,m.jsxs)("p",{className:"text-[12.5px] text-muted-foreground",children:["Waiting for ",e.person," to choose."]})]})}function k_({card:e,view:t,csrf:a,apply:n,onClose:o}){let[r,s]=(0,me.useState)(""),[i,l]=(0,me.useState)(e.draft?.text??"");(0,me.useEffect)(()=>{l(e.draft?.text??"")},[e.id,e.draft?.text]);let[c,f]=(0,me.useState)(!1),u=t.stages.find(g=>g.id===e.stage),d=async(g,v)=>{f(!0);let b=await ka(g,v,a);f(!1),n(b),b.ok&&s("")},p=`${t.flow.href}/cards/${e.id}`;return(0,m.jsxs)("div",{className:"flex flex-col gap-4","data-flow-card-panel":e.id,children:[(0,m.jsxs)("div",{className:"flex items-start gap-2",children:[(0,m.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,m.jsx)("h2",{className:"text-[15px] font-semibold leading-snug",children:e.title}),(0,m.jsxs)("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[e.state==="active"?`In ${u?.title??e.stage}`:e.state==="done"?"Done":e.waiting==="Ignored"?"Ignored":"Cancelled"," · added by ",e.createdBy]}),e.sorted!==null&&(0,m.jsx)("div",{className:"mt-1.5 flex",children:(0,m.jsx)(Ww,{sorted:e.sorted})})]}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:o,"aria-label":"Close",children:(0,m.jsx)(Et,{className:"size-4"})})]}),e.source!==null&&(0,m.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:["From ",e.source.url===null?e.source.label:(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:e.source.url,...e.source.url.startsWith("/")?{}:{target:"_blank",rel:"noreferrer"},children:e.source.label})]}),e.description!==null&&(0,m.jsx)("p",{className:"whitespace-pre-wrap text-[13px]",children:e.description}),e.waiting!==null&&e.question==null&&e.choose==null&&e.state==="active"&&(0,m.jsxs)("p",{className:"rounded-md bg-muted px-3 py-2 text-[13px]",children:[e.waiting,e.deadline!=null&&(0,m.jsx)("span",{className:"block text-muted-foreground",children:Dh(e.deadline)})]}),e.question!=null&&(0,m.jsx)(lY,{question:e.question,csrf:a,apply:n}),e.choose!=null&&(0,m.jsx)(oY,{choose:e.choose,base:`${t.flow.href}/cards/${e.id}`,csrf:a,apply:n}),e.sent!=null&&(0,m.jsx)(nY,{sent:e.sent}),e.question!=null&&e.deadline!=null&&(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:Dh(e.deadline)}),(0,m.jsx)(aY,{card:e,view:t,csrf:a,apply:n}),e.task!==null&&(0,m.jsx)("a",{className:"text-[13px] font-medium text-primary underline-offset-4 hover:underline",href:e.task.href,children:"Open its task"}),e.draft!==null&&!e.canDecide&&(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2",open:!0,"data-flow-draft":!0,children:[(0,m.jsxs)("summary",{className:"cursor-pointer text-[13px] font-medium",children:["Draft from ",e.draft.title]}),(0,m.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-[12.5px]",children:e.draft.text})]}),e.canDecide&&(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3",children:[e.handoff!=null&&(0,m.jsxs)("p",{className:"rounded-md bg-muted px-3 py-2 text-[13px]","data-teammate-handoff":!0,children:[(0,m.jsxs)("span",{className:"font-medium",children:[e.handoff.from,":"]})," ",e.handoff.note]}),e.draft!==null&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(Ct,{htmlFor:"flow-draft",className:"text-[13px]",children:["Draft from ",e.draft.title]}),(0,m.jsx)(Ot,{id:"flow-draft",value:i,onChange:g=>l(g.target.value),rows:8,maxLength:4e3,"data-flow-draft-edit":!0}),i.trim()!==e.draft.text.trim()&&(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"Approving sends your edited version on."})]}),(0,m.jsxs)(Ct,{htmlFor:"flow-note",className:"text-[13px]",children:[u?.title??"Decision",": approve, or send it back"]}),(0,m.jsx)(Ot,{id:"flow-note",value:r,onChange:g=>s(g.target.value),placeholder:"What should change? (needed to send it back)",rows:3}),(0,m.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,m.jsx)(te,{size:"sm",disabled:c||e.draft!==null&&i.trim()==="",onClick:()=>{d(`${p}/decide`,{decision:"approve",note:r,...e.draft===null?{}:{draft:i}})},children:Vf.card.action.label}),u?.onFail!==null&&u?.onFail!==void 0&&(0,m.jsx)(te,{size:"sm",variant:"outline",disabled:c||r.trim()==="",onClick:()=>{d(`${p}/decide`,{decision:"send-back",note:r})},children:"Send back"})]})]}),t.canEdit&&e.state==="active"&&(0,m.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,m.jsx)(Ct,{htmlFor:"flow-move",className:"text-[13px]",children:"Move to"}),(0,m.jsx)("select",{id:"flow-move",className:"h-9 rounded-md border bg-transparent px-2 text-[13px]",value:e.stage,disabled:c,onChange:g=>{d(`${p}/move`,{stage:g.target.value})},children:t.stages.map(g=>(0,m.jsx)("option",{value:g.id,children:g.title},g.id))})]}),(e.calls??[]).length>0&&(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2","data-teammate-calls":!0,children:[(0,m.jsxs)("summary",{className:"cursor-pointer text-[13px] font-medium",children:["Tool calls (",e.calls.length,")"]}),(0,m.jsx)("ol",{className:"mt-2 flex flex-col gap-2.5",children:e.calls.map(g=>(0,m.jsxs)("li",{className:"flex flex-col gap-0.5 text-[12.5px]","data-teammate-call":g.state,children:[(0,m.jsxs)("span",{className:"break-words",children:[(0,m.jsx)("span",{className:"font-medium",children:g.who})," · ",g.words]}),(0,m.jsxs)("span",{className:"text-muted-foreground",children:[g.outcome,g.why!==""&&g.state!=="refused"?` · ${g.why}`:""]}),g.result!==null&&g.result!==""&&(g.state==="done"||g.state==="failed")&&(0,m.jsx)("span",{className:"mt-0.5 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded bg-muted px-2 py-1 text-[12px]",children:g.result}),g.undo!=null&&g.teammate!==void 0&&(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"mt-1 self-start",disabled:c,"data-teammate-undo":g.id,onClick:()=>{d(`/teammates/${g.teammate}/week`,{op:"undo",id:String(g.id)})},children:["Undo with ",g.undo]})]},g.id))})]}),e.outputs.length>0&&(0,m.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,m.jsx)("h3",{className:"text-[13px] font-semibold",children:"What zones reported"}),e.outputs.map(g=>(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2",children:[(0,m.jsx)("summary",{className:"cursor-pointer text-[13px] font-medium",children:g.title}),(0,m.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-[12.5px] text-muted-foreground",children:g.text})]},g.stage))]}),(0,m.jsx)(tY,{card:e,view:t,csrf:a,apply:n}),(0,m.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,m.jsx)("h3",{className:"text-[13px] font-semibold",children:"History"}),(0,m.jsx)("ol",{className:"flex flex-col gap-1.5",children:e.history.map((g,v)=>(0,m.jsxs)("li",{className:"text-[12px]",children:[(0,m.jsx)("span",{className:"text-muted-foreground",children:QW(g.at)})," · ",g.text]},v))})]}),t.canEdit&&e.state==="active"&&(0,m.jsx)(te,{variant:"ghost",size:"sm",className:"self-start text-destructive",disabled:c,onClick:()=>{d(`${p}/cancel`,{})},children:"Cancel card"})]})}function he({label:e,hint:t,children:a}){return(0,m.jsxs)("label",{className:"grid gap-1.5",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:e}),a,t!==void 0&&(0,m.jsx)("span",{className:"text-[12px] text-muted-foreground",children:t})]})}var ht="h-9 w-full rounded-md border bg-transparent px-2 text-[13px]",rY=[.95,.9,.85,.8,.7,.6];function sY({sort:e,others:t,ready:a,set:n}){let o=(s,i)=>n({...e,answers:e.answers.map((l,c)=>c===s?{...l,...i}:l)}),r=(s,i)=>n({...e,notes:e.notes.map((l,c)=>c===s?{...l,...i}:l)});return(0,m.jsxs)(m.Fragment,{children:[!a&&(0,m.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-sort-needs-key":!0,children:["Sorting needs an OpenRouter key. ",(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings#providers",children:"Add it in Settings"})]}),(0,m.jsx)(he,{label:"Question",children:(0,m.jsx)(ve,{value:e.question,maxLength:300,onChange:s=>n({...e,question:s.target.value}),"aria-label":"Question"})}),(0,m.jsxs)("div",{className:"grid gap-2",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Answers"}),e.answers.map((s,i)=>(0,m.jsxs)("div",{className:"grid gap-1.5 rounded-md border p-2","data-sort-answer":i,children:[(0,m.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,m.jsx)(ve,{value:s.answer,maxLength:40,placeholder:"Answer",onChange:l=>o(i,{answer:l.target.value}),"aria-label":`Answer ${i+1}`}),(0,m.jsx)(te,{variant:"ghost",size:"icon",disabled:e.answers.length<=2,onClick:()=>n({...e,answers:e.answers.filter((l,c)=>c!==i)}),"aria-label":`Remove ${s.answer||`answer ${i+1}`}`,children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsx)(ve,{value:s.means,maxLength:200,placeholder:"What it means, in a few words",onChange:l=>o(i,{means:l.target.value}),"aria-label":`What ${s.answer||`answer ${i+1}`} means`}),(0,m.jsxs)("select",{className:ht,value:s.to,onChange:l=>o(i,{to:l.target.value}),"aria-label":`Where ${s.answer||`answer ${i+1}`} goes`,children:[s.to===""&&(0,m.jsx)("option",{value:"",children:"Choose where it goes"}),t.map(l=>(0,m.jsxs)("option",{value:l.id,children:["Goes to ",l.title]},l.id))]})]},i)),e.answers.length<12&&(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>n({...e,answers:[...e.answers,{answer:"",means:"",to:""}]}),children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add an answer"]})]}),(0,m.jsx)(he,{label:"Acts on its own when",hint:"Below this, the card takes the not-sure path.",children:(0,m.jsx)("select",{className:ht,value:String(e.sureAt),onChange:s=>n({...e,sureAt:Number(s.target.value)}),"aria-label":"Acts on its own when",children:[...new Set([...rY,e.sureAt])].sort((s,i)=>i-s).map(s=>(0,m.jsxs)("option",{value:String(s),children:[Math.round(s*100),"% sure or more"]},s))})}),(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2",open:e.notes.length>0,children:[(0,m.jsxs)("summary",{className:"cursor-pointer text-[13px] font-medium",children:["Also note on the card",e.notes.length>0?` (${e.notes.length})`:""]}),(0,m.jsxs)("div",{className:"mt-2 grid gap-2",children:[e.notes.map((s,i)=>(0,m.jsxs)("div",{className:"grid gap-1.5 rounded-md border p-2","data-sort-note":i,children:[(0,m.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,m.jsxs)("select",{className:ht,value:s.kind,onChange:l=>r(i,l.target.value==="score"?{kind:"score",levels:s.levels??["Low","Medium","High"]}:{kind:"yes-no",levels:null}),"aria-label":`Note ${i+1}: kind`,children:[(0,m.jsx)("option",{value:"score",children:"A score"}),(0,m.jsx)("option",{value:"yes-no",children:"Yes or no"})]}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>n({...e,notes:e.notes.filter((l,c)=>c!==i)}),"aria-label":`Remove note ${i+1}`,children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsx)(ve,{value:s.question,maxLength:300,placeholder:s.kind==="score"?"How urgent is this?":"Is the customer asking for money back?",onChange:l=>r(i,{question:l.target.value}),"aria-label":`Note ${i+1}: question`}),s.kind==="score"&&(0,m.jsx)(Ot,{rows:3,value:(s.levels??[]).join(`
59
+ M${N.x},${N.y}h${N.width}v${N.height}h${-N.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}d_.displayName="MiniMap";var jpe=(0,J.memo)(d_),qW=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,UW={[Br.Line]:"right",[Br.Handle]:"bottom-right"};function VW({nodeId:e,position:t,variant:a=Br.Handle,className:n,style:o=void 0,children:r,color:s,minWidth:i=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,resizeDirection:d,autoScale:p=!0,shouldResize:g,onResizeStart:v,onResize:b,onResizeEnd:x}){let y=BD(),h=typeof e=="string"?e:y,w=vt(),S=(0,J.useRef)(null),C=a===Br.Handle,I=je((0,J.useCallback)(qW(C&&p),[C,p]),kt),L=(0,J.useRef)(null),N=t??UW[a];(0,J.useEffect)(()=>{if(!(!S.current||!h))return L.current||(L.current=F6({domNode:S.current,nodeId:h,getStoreItems:()=>{let{nodeLookup:O,transform:B,snapGrid:U,snapToGrid:R,nodeOrigin:E,domNode:M}=w.getState();return{nodeLookup:O,transform:B,snapGrid:U,snapToGrid:R,nodeOrigin:E,paneDomNode:M}},onChange:(O,B)=>{let{triggerNodeChanges:U,nodeLookup:R,parentLookup:E,nodeOrigin:M}=w.getState(),A=[],H={x:O.x,y:O.y},V=R.get(h);if(V&&V.expandParent&&V.parentId){let D=V.origin??M,Q=O.width??V.measured.width??0,K=O.height??V.measured.height??0,ue={id:V.id,parentId:V.parentId,rect:{width:Q,height:K,...Rw({x:O.x??V.position.x,y:O.y??V.position.y},{width:Q,height:K},V.parentId,R,D)}},re=Sx([ue],R,E,M);A.push(...re),H.x=O.x?Math.max(D[0]*Q,O.x):void 0,H.y=O.y?Math.max(D[1]*K,O.y):void 0}if(H.x!==void 0&&H.y!==void 0){let D={id:h,type:"position",position:{...H}};A.push(D)}if(O.width!==void 0&&O.height!==void 0){let Q={id:h,type:"dimensions",resizing:!0,setAttributes:d?d==="horizontal"?"width":"height":!0,dimensions:{width:O.width,height:O.height}};A.push(Q)}for(let D of B){let Q={...D,type:"position"};A.push(Q)}U(A)},onEnd:({width:O,height:B})=>{let U={id:h,type:"dimensions",resizing:!1,dimensions:{width:O,height:B}};w.getState().triggerNodeChanges([U])}})),L.current.update({controlPosition:N,boundaries:{minWidth:i,minHeight:l,maxWidth:c,maxHeight:f},keepAspectRatio:u,resizeDirection:d,onResizeStart:v,onResize:b,onResizeEnd:x,shouldResize:g}),()=>{L.current?.destroy()}},[N,i,l,c,f,u,v,b,x,g]);let P=N.split("-");return(0,Y.jsx)("div",{className:At(["react-flow__resize-control","nodrag",...P,a,n]),ref:S,style:{...o,scale:I,...s&&{[C?"backgroundColor":"borderColor"]:s}},children:r})}var ID=(0,J.memo)(VW);function f_({nodeId:e,isVisible:t=!0,handleClassName:a,handleStyle:n,lineClassName:o,lineStyle:r,color:s,minWidth:i=10,minHeight:l=10,maxWidth:c=Number.MAX_VALUE,maxHeight:f=Number.MAX_VALUE,keepAspectRatio:u=!1,autoScale:d=!0,shouldResize:p,onResizeStart:g,onResize:v,onResizeEnd:b}){return t?(0,Y.jsxs)(Y.Fragment,{children:[z6.map(x=>(0,Y.jsx)(ID,{className:o,style:r,nodeId:e,position:x,variant:Br.Line,color:s,minWidth:i,minHeight:l,maxWidth:c,maxHeight:f,onResizeStart:g,keepAspectRatio:u,autoScale:d,shouldResize:p,onResize:v,onResizeEnd:b},x)),O6.map(x=>(0,Y.jsx)(ID,{className:a,style:n,nodeId:e,position:x,color:s,minWidth:i,minHeight:l,maxWidth:c,maxHeight:f,onResizeStart:g,keepAspectRatio:u,autoScale:d,shouldResize:p,onResize:v,onResizeEnd:b},x))]}):null}var me=$(ge(),1);var m=$(pe(),1);function Zs({name:e,size:t="sm"}){let a=[...e].reduce((o,r)=>(o*31+r.charCodeAt(0))%360,7),n=e.split(/[\s._-]+/).filter(Boolean).map(o=>o[0].toUpperCase()).slice(0,2).join("")||e.slice(0,2).toUpperCase();return(0,m.jsx)("span",{title:e,"aria-label":e,className:ae("inline-flex shrink-0 items-center justify-center rounded-full font-semibold text-white",t==="sm"?"size-5 text-[9px]":"size-7 text-[11px]"),style:{background:`hsl(${a} 45% 45%)`},children:n})}var yp={slate:"#64748b",blue:"#3b82f6",violet:"#8b5cf6",amber:"#d97706",green:"#059669",rose:"#e11d48"},h_={inbox:(0,m.jsx)(Fi,{className:"size-3.5","aria-hidden":"true"}),task:(0,m.jsx)(ef,{className:"size-3.5","aria-hidden":"true"}),report:(0,m.jsx)(gf,{className:"size-3.5","aria-hidden":"true"}),approval:(0,m.jsx)(wf,{className:"size-3.5","aria-hidden":"true"}),notify:(0,m.jsx)(uf,{className:"size-3.5","aria-hidden":"true"}),done:(0,m.jsx)(Kd,{className:"size-3.5","aria-hidden":"true"}),check:(0,m.jsx)(eo,{className:"size-3.5","aria-hidden":"true"}),"pull-request":(0,m.jsx)(Is,{className:"size-3.5","aria-hidden":"true"}),update:(0,m.jsx)(cf,{className:"size-3.5","aria-hidden":"true"}),sort:(0,m.jsx)(Uu,{className:"size-3.5","aria-hidden":"true"}),draft:(0,m.jsx)(Ts,{className:"size-3.5","aria-hidden":"true"}),request:(0,m.jsx)(Jd,{className:"size-3.5","aria-hidden":"true"}),email:(0,m.jsx)(Hu,{className:"size-3.5","aria-hidden":"true"}),tool:(0,m.jsx)(Ui,{className:"size-3.5","aria-hidden":"true"}),wait:(0,m.jsx)(af,{className:"size-3.5","aria-hidden":"true"}),teammate:(0,m.jsx)(Pi,{className:"size-3.5","aria-hidden":"true"}),send:(0,m.jsx)(xf,{className:"size-3.5","aria-hidden":"true"}),choose:(0,m.jsx)(yf,{className:"size-3.5","aria-hidden":"true"})};function Ww({sorted:e}){return(0,m.jsxs)("span",{className:ae("inline-flex max-w-full items-center gap-1 rounded-full bg-muted px-1.5 py-0.5 text-[11px] font-medium",!e.confident&&"text-warning"),title:e.confident?"Sorted by Jev":"Jev wasn't sure","data-sort-chip":!0,children:[(0,m.jsx)(Uu,{className:"size-3 shrink-0",style:{color:e.confident?yp.violet:void 0},"aria-hidden":"true"}),(0,m.jsx)("span",{className:"truncate",children:e.confident?e.chip:`Not sure · ${e.chip}`})]})}var g_={button:(0,m.jsx)(qu,{className:"size-3.5","aria-hidden":"true"}),schedule:(0,m.jsx)(Gd,{className:"size-3.5","aria-hidden":"true"}),github:(0,m.jsx)(Is,{className:"size-3.5","aria-hidden":"true"}),linear:(0,m.jsx)(Ms,{className:"size-3.5","aria-hidden":"true"}),flow:(0,m.jsx)(qi,{className:"size-3.5","aria-hidden":"true"}),webhook:(0,m.jsx)(Sf,{className:"size-3.5","aria-hidden":"true"}),email:(0,m.jsx)(Hu,{className:"size-3.5","aria-hidden":"true"}),chat:(0,m.jsx)(Rs,{className:"size-3.5","aria-hidden":"true"})};async function ka(e,t,a){let n=new URLSearchParams({csrf:a,...t});try{let o=await fetch(e,{method:"POST",body:n,credentials:"same-origin",headers:{accept:"application/json"},signal:AbortSignal.timeout(2e4)}),r=await o.json();return{ok:r.ok===!0,said:typeof r.said=="string"?r.said:o.ok?"Done.":"That didn't go through.",...r.view===void 0?{}:{view:r.view},...r.reveal===void 0?{}:{reveal:r.reveal}}}catch{return{ok:!1,said:"That didn't go through. Check your connection and try again."}}}function x_(e,t,a){let[n,o]=(0,me.useState)([]),r=(0,me.useRef)(e.live);r.current=e.live;let s=(0,me.useRef)(a.editing);s.current=a.editing;let i=(0,me.useRef)(!1),l=e.flow.href,c=(0,me.useCallback)(async()=>{if(!(i.current||s.current)){i.current=!0;try{let f=await fetch(`${l}?format=json`,{credentials:"same-origin",headers:{accept:"application/json"}});if(f.ok){let u=await f.json();r.current=u.live,t(u)}}catch{}finally{i.current=!1}}},[l,t]);return(0,me.useEffect)(()=>{let f=null,u,d=new URLSearchParams({...a.card===null?{}:{card:String(a.card)},...a.editing?{editing:"1"}:{}}).toString(),p=()=>{window.clearInterval(u),u=window.setInterval(()=>{document.visibilityState==="visible"&&c()},5e3)},g=()=>{if(typeof EventSource>"u"){p();return}let x=new EventSource(`${l}/live${d===""?"":`?${d}`}`);f=x,x.addEventListener("change",y=>{try{let h=JSON.parse(y.data).at;(h===null||h!==r.current)&&c()}catch{c()}}),x.addEventListener("here",y=>{try{o(JSON.parse(y.data).people)}catch{}}),x.addEventListener("gone",()=>{x.close(),f===x&&(f=null),o([])}),x.addEventListener("open",()=>window.clearInterval(u)),x.addEventListener("error",()=>{x.readyState===EventSource.CLOSED&&(f===x&&(f=null),o([]),p())})},v=()=>{f?.close(),f=null,window.clearInterval(u),o([])},b=()=>{document.hidden?v():f===null&&(g(),c())};return document.hidden||g(),document.addEventListener("visibilitychange",b),()=>{document.removeEventListener("visibilitychange",b),v()}},[l,a.card,a.editing,c]),n}function v_({others:e,cards:t}){if(e.length===0)return null;let a=r=>{if(r.editing)return"changing this flow";let s=r.cards.map(i=>t.find(l=>l.id===i)?.title).filter(i=>i!==void 0);return s.length===0?"looking at the flow":`looking at ${s.map(i=>`“${i}”`).join(", ")}`},n=e.map(r=>`${r.name} is ${a(r)}`).join(". "),o=e.find(r=>r.editing);return(0,m.jsxs)("div",{className:"inline-flex min-w-0 items-center gap-1.5","data-also-here":!0,role:"status","aria-label":`Also here: ${n}`,title:n,children:[(0,m.jsx)("span",{className:"flex -space-x-1.5",children:e.slice(0,4).map(r=>(0,m.jsx)("span",{className:"rounded-full ring-2 ring-card",children:(0,m.jsx)(Zs,{name:r.name})},r.name))}),(0,m.jsx)("span",{className:"truncate text-[12px] text-muted-foreground",children:o!==void 0?`${o.name} is changing this flow`:e.length===1?`${e[0].name} is here`:`${e.length} others here`})]})}function GW({data:e,selected:t}){let{stage:a,cards:n,editing:o,canMove:r}=e,s=yp[a.zone.color]??yp.slate,[i,l]=(0,me.useState)(!1),c=ae("!size-2.5 !border-2 !border-card",!o&&"!opacity-0");return(0,m.jsxs)("div",{className:ae("flex h-full flex-col overflow-hidden rounded-xl border bg-muted/40 shadow-sm",t&&o?"ring-2 ring-primary":"",i&&"ring-2 ring-primary/60"),onDragOver:f=>{!r||o||(f.preventDefault(),l(!0))},onDragLeave:()=>l(!1),onDrop:f=>{l(!1);let u=Number(f.dataTransfer.getData("text/so-card"));u>0&&e.onDrop(u,a.id)},"data-zone":a.id,children:[o&&(0,m.jsx)(f_,{isVisible:t,minWidth:220,minHeight:160,lineClassName:"!border-primary",handleClassName:"!size-2 !bg-primary",onResizeEnd:(f,u)=>e.onResize(a.id,u)}),(0,m.jsx)(or,{type:"source",position:we.Right,id:"next",className:ae(c,"!bg-primary"),isConnectable:o}),(0,m.jsx)(or,{type:"source",position:we.Bottom,id:"fail",className:ae(c,"!bg-destructive"),style:{left:"75%"},isConnectable:o}),["Left","Right","Top","Bottom"].map(f=>(0,m.jsx)(or,{type:"target",position:we[f],id:`t-${f}`,className:c,isConnectable:o},`t-${f}`)),["Left","Right","Top","Bottom"].map(f=>(0,m.jsx)(or,{type:"source",position:we[f],id:`s-${f}`,className:"!opacity-0 !pointer-events-none",isConnectable:!1},`s-${f}`)),(0,m.jsxs)("header",{className:"flex items-center gap-2 border-b px-3 py-2",children:[(0,m.jsx)("span",{className:"inline-flex size-6 items-center justify-center rounded-md text-white",style:{background:s},children:h_[a.kind]}),(0,m.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,m.jsx)("div",{className:"truncate text-[13px] font-semibold",children:a.title}),(0,m.jsxs)("div",{className:"truncate text-[11px] text-muted-foreground",children:[e.kindLabel,e.start?" · new cards start here":"",e.teammate!==null?` · ${e.teammate}`:a.toOwner===!0?` · ${e.owner}`:a.approver?` · ${a.approver}`:""]})]}),n.length>0&&(0,m.jsx)("span",{className:"rounded-full bg-muted px-1.5 text-[11px] font-semibold text-muted-foreground",children:n.length})]}),(0,m.jsxs)("ul",{className:"nowheel flex min-h-0 flex-1 flex-col gap-2 overflow-y-auto p-2",children:[n.map(f=>(0,m.jsx)("li",{children:(0,m.jsxs)("button",{type:"button",draggable:r&&!o,onDragStart:u=>{u.dataTransfer.setData("text/so-card",String(f.id)),u.dataTransfer.effectAllowed="move"},onClick:()=>e.onCard(f.id),className:ae("nodrag nopan w-full cursor-pointer rounded-lg border bg-card px-2.5 py-2 text-left shadow-xs transition-colors hover:border-primary/50",e.selectedCard===f.id&&"border-primary ring-1 ring-primary",f.canDecide&&"border-attention/60"),"data-card":f.id,children:[(0,m.jsxs)("div",{className:"flex items-start gap-1.5",children:[(0,m.jsx)("div",{className:"line-clamp-2 min-w-0 flex-1 text-[12.5px] font-medium leading-snug",children:f.title}),(e.lookers[f.id]?.length??0)>0&&(0,m.jsx)("span",{className:"flex shrink-0 -space-x-1","data-card-lookers":!0,title:`${e.lookers[f.id].join(" and ")} ${e.lookers[f.id].length===1?"is":"are"} looking at this`,children:e.lookers[f.id].slice(0,2).map(u=>(0,m.jsx)("span",{className:"rounded-full ring-2 ring-primary/70",children:(0,m.jsx)(Zs,{name:u})},u))})]}),f.sorted!==null&&(0,m.jsx)("div",{className:"mt-1 flex",children:(0,m.jsx)(Ww,{sorted:f.sorted})}),f.waiting!==null&&(0,m.jsx)("div",{className:ae("mt-1 line-clamp-2 text-[11px] leading-snug",f.canDecide||f.question?.mine?"font-semibold text-attention":"text-muted-foreground"),children:f.canDecide?Vf.card.sentence({}):f.question?.mine?`${f.question.from.split(" · ")[0]} asks you`:f.waiting}),f.deadline!=null&&(0,m.jsx)("div",{className:"mt-0.5 text-[11px] text-muted-foreground","data-card-deadline":!0,children:Dh(f.deadline)}),(f.owner!==null||f.comments.length>0)&&(0,m.jsxs)("div",{className:"mt-1.5 flex items-center gap-1.5",children:[f.owner!==null&&(0,m.jsx)(Zs,{name:f.owner}),(0,m.jsx)("span",{className:"flex-1"}),f.comments.length>0&&(0,m.jsxs)("span",{className:"inline-flex items-center gap-0.5 text-[11px] text-muted-foreground",children:[(0,m.jsx)(Rs,{className:"size-3","aria-hidden":"true"}),f.comments.length]})]})]})},f.id)),n.length===0&&(0,m.jsx)("li",{className:"px-1 py-2 text-[11px] text-muted-foreground",children:o?a.kind==="done"?"":"Drag the dots to connect zones.":e.hidden>0?"":"No cards here."}),e.hidden>0&&(0,m.jsxs)("li",{className:"px-1 py-1 text-[11px] text-muted-foreground",children:[e.hidden," other card",e.hidden===1?"":"s"]})]})]})}var y_=44,b_=30;function jW({data:e}){return(0,m.jsxs)("div",{className:"flex h-full flex-col overflow-hidden rounded-lg border bg-card shadow-sm","data-trigger-group":!0,children:[(0,m.jsx)(or,{type:"source",position:we.Right,id:"out",className:"!opacity-0 !pointer-events-none",isConnectable:!1}),(0,m.jsxs)("div",{className:"flex items-center gap-1.5 px-2.5 text-[11px] font-semibold uppercase tracking-wide text-muted-foreground",style:{height:b_},children:[(0,m.jsx)(Es,{className:"size-3","aria-hidden":"true"}),"Starts cards"]}),e.triggers.map(t=>{let a=t.failing||t.hook!==null&&!t.hook.ready,n=t.state==="paused"?"Paused":t.failing?"Needs attention":t.hook!==null&&!t.hook.ready?"Needs its secret":t.detail;return(0,m.jsxs)("div",{className:ae("flex items-center gap-2 border-t px-2.5",t.state==="paused"&&"opacity-60"),style:{height:y_},"data-trigger":t.id,children:[(0,m.jsx)("span",{className:"inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:g_[t.kind]??(0,m.jsx)(Es,{className:"size-3.5","aria-hidden":"true"})}),(0,m.jsxs)("button",{type:"button",className:"nodrag nopan min-w-0 flex-1 cursor-pointer text-left",onClick:()=>e.onOpen(t.id),"aria-label":`Trigger: ${t.words}`,children:[(0,m.jsx)("div",{className:"truncate text-[12px] font-semibold",children:t.name}),(0,m.jsx)("div",{className:ae("truncate text-[11px]",a?"text-warning":"text-muted-foreground"),children:n})]}),t.button!==null&&t.state==="active"&&(0,m.jsx)(te,{size:"sm",className:"nodrag nopan h-7 px-2.5",onClick:()=>e.onPress(t.id),children:"Start"})]},t.id)})]})}var $W={zone:GW,trigger:jW};function XW({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:o,targetPosition:r,label:s,labelStyle:i,labelBgStyle:l,markerEnd:c,style:f,data:u}){let{path:d,shift:p}=u??{},[g,v,b]=Ks({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:o,targetPosition:r,...d}),x=i;return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Lc,{path:g,...c===void 0?{}:{markerEnd:c},...f===void 0?{}:{style:f}}),(0,m.jsx)(s_,{children:(0,m.jsx)("div",{className:"nodrag nopan pointer-events-none absolute rounded-sm px-1 leading-4 whitespace-nowrap",style:{transform:`translate(-50%, -50%) translate(${v+(p?.x??0)}px, ${b+(p?.y??0)}px)`,color:x?.fill,fontSize:x?.fontSize,fontWeight:x?.fontWeight,background:l?.fill},children:s})})]})}var WW={named:XW};function YW(e,t){let a=(r,s)=>{let i=t.find(u=>u.id===r)?.zone;if(i===void 0||s==null)return null;let l=s.slice(2),c=l==="Left"?i.x:l==="Right"?i.x+i.w:i.x+i.w/2,f=l==="Top"?i.y:l==="Bottom"?i.y+i.h:i.y+i.h/2;return{x:c,y:f,position:we[l]}},n=[],o=r=>n.some(s=>Math.abs(s.x-r.x)<(s.w+r.w)/2+4&&Math.abs(s.y-r.y)<(s.h+r.h)/2+2);return e.map(r=>{if(typeof r.label!="string"||r.type!=="smoothstep")return r;let s=a(r.source,r.sourceHandle),i=a(r.target,r.targetHandle);if(s===null||i===null)return r;let l=r.pathOptions,[,c,f]=Ks({sourceX:s.x,sourceY:s.y,sourcePosition:s.position,targetX:i.x,targetY:i.y,targetPosition:i.position,...l}),u=r.label.length*6.4+10,d=18,g=(s.position===we.Left||s.position===we.Right)&&(i.position===we.Left||i.position===we.Right)?{x:0,y:d+6}:{x:u/2+34,y:0},v={x:0,y:0};for(let y of[0,1,-1,2,-2,3,-3])if(v={x:g.x*y,y:g.y*y},!o({x:c+v.x,y:f+v.y,w:u,h:d}))break;n.push({x:c+v.x,y:f+v.y,w:u,h:d});let{pathOptions:b,...x}=r;return{...x,type:"named",data:{...r.data,path:l,shift:v}}})}function KW(e,t){let a=[],n=new Set,o=r=>{for(;r!==null&&!n.has(r);){let s=e.find(i=>i.id===r);if(s===void 0)return;n.add(r),a.push(s);for(let i of s.sort?.answers??[])o(i.to);s.sort!==null&&s.onFail!==null&&o(s.onFail),r=s.next}};o(t);for(let r of e)n.has(r.id)||o(r.id);return[...a.filter(r=>r.kind!=="done"),...a.filter(r=>r.kind==="done")]}function ZW(e,t){let a=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,24)||"zone",n=a,o=2;for(;t.has(n);)n=`${a}-${o++}`;return n}var Yw=e=>mn(e),QW=(e,t=new Date)=>Number.isNaN(new Date(e).getTime())?"":zu(e,t,Di(),!0),JW=e=>e%1440===0?`${e/1440} day${e===1440?"":"s"}`:e%60===0?`${e/60} h`:`${e} min`;function w_({link:e}){return e===null?null:(0,m.jsxs)(m.Fragment,{children:[" ",(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:e.href,"data-status-link":!0,children:e.label})]})}function eY({body:e,mentions:t}){if(t.length===0)return(0,m.jsx)(m.Fragment,{children:e});let a=new RegExp(`(@(?:${t.map(n=>n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")).join("|")}))(?![A-Za-z0-9_])`,"gi");return(0,m.jsx)(m.Fragment,{children:e.split(a).map((n,o)=>o%2===1?(0,m.jsx)("span",{className:"font-semibold text-primary",children:n},o):n)})}function tY({card:e,view:t,csrf:a,apply:n}){let[o,r]=(0,me.useState)(""),[s,i]=(0,me.useState)(!1),l=/(?:^|\s)@([A-Za-z0-9_.-]*)$/.exec(o)?.[1],c=l===void 0?[]:t.approvers.filter(f=>f!==t.me&&f.toLowerCase().startsWith(l.toLowerCase())).slice(0,6);return(0,m.jsxs)("div",{className:"flex flex-col gap-2","data-flow-discussion":!0,children:[(0,m.jsx)("h3",{className:"text-[13px] font-semibold",children:"Discussion"}),e.comments.length===0?(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"No comments yet."}):(0,m.jsx)("ol",{className:"flex flex-col gap-3",children:e.comments.map(f=>(0,m.jsxs)("li",{className:"flex gap-2","data-comment":f.id,children:[(0,m.jsx)(Zs,{name:f.author,size:"md"}),(0,m.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,m.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:[(0,m.jsx)("span",{className:"font-semibold text-foreground",children:f.author})," · ",Yw(f.at)]}),(0,m.jsx)("p",{className:"whitespace-pre-wrap break-words text-[13px]",children:(0,m.jsx)(eY,{body:f.body,mentions:f.mentions})})]})]},f.id))}),t.canEdit&&(0,m.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:async f=>{f.preventDefault(),i(!0);let u=await ka(`${t.flow.href}/cards/${e.id}/comment`,{body:o},a);i(!1),n(u),u.ok&&r("")},children:[(0,m.jsx)(Ot,{value:o,onChange:f=>r(f.target.value),rows:3,maxLength:4e3,placeholder:"Add a comment. Type @ and a name to ping someone.","aria-label":"Comment"}),c.length>0&&(0,m.jsx)("div",{className:"flex flex-wrap gap-1.5","aria-label":"People to mention",children:c.map(f=>(0,m.jsxs)("button",{type:"button",className:"inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2 text-[12px] hover:border-primary/60",onClick:()=>r(u=>u.replace(/@([A-Za-z0-9_.-]*)$/,`@${f} `)),children:[(0,m.jsx)(Zs,{name:f}),f]},f))}),(0,m.jsx)(te,{type:"submit",size:"sm",className:"self-start",disabled:s||o.trim()==="",children:"Comment"})]})]})}function aY({card:e,view:t,csrf:a,apply:n}){let[o,r]=(0,me.useState)(!1),s=async(l,c)=>{r(!0),n(await ka(`${t.flow.href}/cards/${e.id}/${l}`,c,a)),r(!1)},i=e.watchers.filter(l=>l!==e.owner);return(0,m.jsxs)("div",{className:"flex flex-col gap-2","data-flow-card-people":!0,children:[t.canEdit&&e.state==="active"?(0,m.jsxs)("label",{className:"grid gap-1.5",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Owner"}),(0,m.jsxs)("select",{className:ht,value:e.owner??"",disabled:o,onChange:l=>{s("assign",{owner:l.target.value})},"aria-label":"Owner",children:[(0,m.jsx)("option",{value:"",children:"No owner"}),t.approvers.map(l=>(0,m.jsx)("option",{value:l,children:l===t.me?`${l} (you)`:l},l))]})]}):e.owner!==null&&(0,m.jsxs)("p",{className:"flex items-center gap-2 text-[13px]",children:[(0,m.jsx)(Zs,{name:e.owner})," Owned by ",e.owner]}),(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[t.canEdit&&e.state==="active"&&e.owner===null&&(0,m.jsx)(te,{size:"sm",variant:"outline",disabled:o,onClick:()=>{s("assign",{owner:t.me})},children:"Take it"}),i.length>0&&(0,m.jsxs)("span",{className:"flex items-center gap-1 text-[12px] text-muted-foreground",children:[i.slice(0,5).map(l=>(0,m.jsx)(Zs,{name:l},l)),i.length===1?" follows it":" follow it"]}),t.canEdit&&e.owner!==t.me&&(0,m.jsx)(te,{size:"sm",variant:"ghost",disabled:o,onClick:()=>{s("watch",{watching:e.watching?"no":"yes"})},"aria-pressed":e.watching,children:e.watching?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(qd,{className:"size-4"}),"Stop following"]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Ud,{className:"size-4"}),"Follow"]})})]})]})}function S_({links:e}){return(0,m.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1",children:e.map(t=>(0,m.jsx)("a",{className:"text-[13px] font-medium text-primary underline-offset-4 hover:underline",href:t.href,...t.href.startsWith("/")?{}:{target:"_blank",rel:"noreferrer"},children:t.label},t.label))})}function C_({items:e}){return(0,m.jsx)("ol",{className:"flex flex-col gap-3","data-flow-items":!0,children:e.map(t=>(0,m.jsxs)("li",{className:"flex items-start gap-3","data-flow-item":t.number,children:[(0,m.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-0.5 text-[12.5px]",children:[(0,m.jsxs)("p",{className:"font-semibold",children:[t.number,". ",t.title]}),t.lines.map((a,n)=>(0,m.jsx)("p",{className:"break-words text-muted-foreground",children:a},n)),(0,m.jsx)("a",{className:"self-start font-medium text-primary underline-offset-4 hover:underline",href:t.url,target:"_blank",rel:"noreferrer",children:t.source})]}),t.image!==null&&(0,m.jsx)("a",{className:"w-28 shrink-0",href:t.image.src,target:"_blank",rel:"noreferrer",children:(0,m.jsx)("img",{className:"w-full rounded-md border object-cover object-top",style:{aspectRatio:"4 / 3"},src:t.image.src,alt:t.image.caption,loading:"lazy"})})]},t.number))})}function nY({sent:e}){return(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2","data-flow-sent":!0,children:[(0,m.jsxs)("summary",{className:"cursor-pointer text-[13px] font-medium",children:["Sent to ",e.person," · ",Yw(e.at)]}),(0,m.jsxs)("div",{className:"mt-2 flex flex-col gap-2",children:[(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:e.title}),(0,m.jsx)("p",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words text-[12.5px]",children:e.summary}),e.items!==void 0&&(0,m.jsx)(C_,{items:e.items}),e.links.length>0&&(0,m.jsx)(S_,{links:e.links})]})]})}function oY({choose:e,base:t,csrf:a,apply:n}){let[o,r]=(0,me.useState)(""),[s,i]=(0,me.useState)(!1),l=async c=>{i(!0);let f=await ka(`${t}/choose`,c,a);i(!1),n(f),f.ok&&r("")};return(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3","data-flow-choose":!0,children:[(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:e.title}),(0,m.jsx)("p",{className:"max-h-60 overflow-auto whitespace-pre-wrap break-words text-[12.5px]",children:e.summary}),e.items!==void 0&&(0,m.jsx)(C_,{items:e.items}),e.links.length>0&&(0,m.jsx)(S_,{links:e.links}),e.mine?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("div",{className:"flex flex-wrap gap-2",children:e.options.map(c=>(0,m.jsx)(te,{size:"sm",variant:c.choice===0?"default":"outline",disabled:s,onClick:()=>{l({choice:String(c.choice),label:c.label,entry:String(e.entry)})},"data-flow-choice":c.choice,children:c.label},c.choice))}),e.reply&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Ot,{value:o,onChange:c=>r(c.target.value),rows:2,maxLength:4e3,placeholder:"Or say what you'd change","aria-label":"What you'd change"}),(0,m.jsx)(te,{size:"sm",variant:"outline",className:"self-start",disabled:s||o.trim()==="",onClick:()=>{l({note:o,entry:String(e.entry)})},children:"Send reply"})]})]}):(0,m.jsxs)("p",{className:"text-[12.5px] text-muted-foreground",children:["Waiting for ",e.person," to choose."]})]})}function k_({card:e,view:t,csrf:a,apply:n,onClose:o}){let[r,s]=(0,me.useState)(""),[i,l]=(0,me.useState)(e.draft?.text??"");(0,me.useEffect)(()=>{l(e.draft?.text??"")},[e.id,e.draft?.text]);let[c,f]=(0,me.useState)(!1),u=t.stages.find(g=>g.id===e.stage),d=async(g,v)=>{f(!0);let b=await ka(g,v,a);f(!1),n(b),b.ok&&s("")},p=`${t.flow.href}/cards/${e.id}`;return(0,m.jsxs)("div",{className:"flex flex-col gap-4","data-flow-card-panel":e.id,children:[(0,m.jsxs)("div",{className:"flex items-start gap-2",children:[(0,m.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,m.jsx)("h2",{className:"text-[15px] font-semibold leading-snug",children:e.title}),(0,m.jsxs)("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:[e.state==="active"?`In ${u?.title??e.stage}`:e.state==="done"?"Done":e.waiting==="Ignored"?"Ignored":"Cancelled"," · added by ",e.createdBy]}),e.sorted!==null&&(0,m.jsx)("div",{className:"mt-1.5 flex",children:(0,m.jsx)(Ww,{sorted:e.sorted})})]}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:o,"aria-label":"Close",children:(0,m.jsx)(Et,{className:"size-4"})})]}),e.source!==null&&(0,m.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:["From ",e.source.url===null?e.source.label:(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:e.source.url,...e.source.url.startsWith("/")?{}:{target:"_blank",rel:"noreferrer"},children:e.source.label})]}),e.description!==null&&(0,m.jsx)("p",{className:"whitespace-pre-wrap text-[13px]",children:e.description}),e.waiting!==null&&e.question==null&&e.choose==null&&e.state==="active"&&(0,m.jsxs)("p",{className:"rounded-md bg-muted px-3 py-2 text-[13px]",children:[e.waiting,e.deadline!=null&&(0,m.jsx)("span",{className:"block text-muted-foreground",children:Dh(e.deadline)})]}),e.question!=null&&(0,m.jsx)(lY,{question:e.question,csrf:a,apply:n}),e.choose!=null&&(0,m.jsx)(oY,{choose:e.choose,base:`${t.flow.href}/cards/${e.id}`,csrf:a,apply:n}),e.sent!=null&&(0,m.jsx)(nY,{sent:e.sent}),e.question!=null&&e.deadline!=null&&(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:Dh(e.deadline)}),(0,m.jsx)(aY,{card:e,view:t,csrf:a,apply:n}),e.task!==null&&(0,m.jsx)("a",{className:"text-[13px] font-medium text-primary underline-offset-4 hover:underline",href:e.task.href,children:"Open its task"}),e.draft!==null&&!e.canDecide&&(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2",open:!0,"data-flow-draft":!0,children:[(0,m.jsxs)("summary",{className:"cursor-pointer text-[13px] font-medium",children:["Draft from ",e.draft.title]}),(0,m.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-[12.5px]",children:e.draft.text})]}),e.canDecide&&(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3",children:[e.handoff!=null&&(0,m.jsxs)("p",{className:"rounded-md bg-muted px-3 py-2 text-[13px]","data-teammate-handoff":!0,children:[(0,m.jsxs)("span",{className:"font-medium",children:[e.handoff.from,":"]})," ",e.handoff.note]}),e.draft!==null&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(Ct,{htmlFor:"flow-draft",className:"text-[13px]",children:["Draft from ",e.draft.title]}),(0,m.jsx)(Ot,{id:"flow-draft",value:i,onChange:g=>l(g.target.value),rows:8,maxLength:12e3,"data-flow-draft-edit":!0}),i.trim()!==e.draft.text.trim()&&(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"Approving sends your edited version on."})]}),(0,m.jsxs)(Ct,{htmlFor:"flow-note",className:"text-[13px]",children:[u?.title??"Decision",": approve, or send it back"]}),(0,m.jsx)(Ot,{id:"flow-note",value:r,onChange:g=>s(g.target.value),placeholder:"What should change? (needed to send it back)",rows:3}),(0,m.jsxs)("div",{className:"flex flex-wrap gap-2",children:[(0,m.jsx)(te,{size:"sm",disabled:c||e.draft!==null&&i.trim()==="",onClick:()=>{d(`${p}/decide`,{decision:"approve",note:r,...e.draft===null?{}:{draft:i}})},children:Vf.card.action.label}),u?.onFail!==null&&u?.onFail!==void 0&&(0,m.jsx)(te,{size:"sm",variant:"outline",disabled:c||r.trim()==="",onClick:()=>{d(`${p}/decide`,{decision:"send-back",note:r})},children:"Send back"})]})]}),t.canEdit&&e.state==="active"&&(0,m.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,m.jsx)(Ct,{htmlFor:"flow-move",className:"text-[13px]",children:"Move to"}),(0,m.jsx)("select",{id:"flow-move",className:"h-9 rounded-md border bg-transparent px-2 text-[13px]",value:e.stage,disabled:c,onChange:g=>{d(`${p}/move`,{stage:g.target.value})},children:t.stages.map(g=>(0,m.jsx)("option",{value:g.id,children:g.title},g.id))})]}),(e.calls??[]).length>0&&(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2","data-teammate-calls":!0,children:[(0,m.jsxs)("summary",{className:"cursor-pointer text-[13px] font-medium",children:["Tool calls (",e.calls.length,")"]}),(0,m.jsx)("ol",{className:"mt-2 flex flex-col gap-2.5",children:e.calls.map(g=>(0,m.jsxs)("li",{className:"flex flex-col gap-0.5 text-[12.5px]","data-teammate-call":g.state,children:[(0,m.jsxs)("span",{className:"break-words",children:[(0,m.jsx)("span",{className:"font-medium",children:g.who})," · ",g.words]}),(0,m.jsxs)("span",{className:"text-muted-foreground",children:[g.outcome,g.why!==""&&g.state!=="refused"?` · ${g.why}`:""]}),g.result!==null&&g.result!==""&&(g.state==="done"||g.state==="failed")&&(0,m.jsx)("span",{className:"mt-0.5 max-h-40 overflow-auto whitespace-pre-wrap break-words rounded bg-muted px-2 py-1 text-[12px]",children:g.result}),g.undo!=null&&g.teammate!==void 0&&(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"mt-1 self-start",disabled:c,"data-teammate-undo":g.id,onClick:()=>{d(`/teammates/${g.teammate}/week`,{op:"undo",id:String(g.id)})},children:["Undo with ",g.undo]})]},g.id))})]}),e.outputs.length>0&&(0,m.jsxs)("div",{className:"flex flex-col gap-2",children:[(0,m.jsx)("h3",{className:"text-[13px] font-semibold",children:"What zones reported"}),e.outputs.map(g=>(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2",children:[(0,m.jsx)("summary",{className:"cursor-pointer text-[13px] font-medium",children:g.title}),(0,m.jsx)("p",{className:"mt-2 whitespace-pre-wrap text-[12.5px] text-muted-foreground",children:g.text})]},g.stage))]}),(0,m.jsx)(tY,{card:e,view:t,csrf:a,apply:n}),(0,m.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,m.jsx)("h3",{className:"text-[13px] font-semibold",children:"History"}),(0,m.jsx)("ol",{className:"flex flex-col gap-1.5",children:e.history.map((g,v)=>(0,m.jsxs)("li",{className:"text-[12px]",children:[(0,m.jsx)("span",{className:"text-muted-foreground",children:QW(g.at)})," · ",g.text]},v))})]}),t.canEdit&&e.state==="active"&&(0,m.jsx)(te,{variant:"ghost",size:"sm",className:"self-start text-destructive",disabled:c,onClick:()=>{d(`${p}/cancel`,{})},children:"Cancel card"})]})}function he({label:e,hint:t,children:a}){return(0,m.jsxs)("label",{className:"grid gap-1.5",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:e}),a,t!==void 0&&(0,m.jsx)("span",{className:"text-[12px] text-muted-foreground",children:t})]})}var ht="h-9 w-full rounded-md border bg-transparent px-2 text-[13px]",rY=[.95,.9,.85,.8,.7,.6];function sY({sort:e,others:t,ready:a,set:n}){let o=(s,i)=>n({...e,answers:e.answers.map((l,c)=>c===s?{...l,...i}:l)}),r=(s,i)=>n({...e,notes:e.notes.map((l,c)=>c===s?{...l,...i}:l)});return(0,m.jsxs)(m.Fragment,{children:[!a&&(0,m.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-sort-needs-key":!0,children:["Sorting needs an OpenRouter key. ",(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings#providers",children:"Add it in Settings"})]}),(0,m.jsx)(he,{label:"Question",children:(0,m.jsx)(ve,{value:e.question,maxLength:300,onChange:s=>n({...e,question:s.target.value}),"aria-label":"Question"})}),(0,m.jsxs)("div",{className:"grid gap-2",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Answers"}),e.answers.map((s,i)=>(0,m.jsxs)("div",{className:"grid gap-1.5 rounded-md border p-2","data-sort-answer":i,children:[(0,m.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,m.jsx)(ve,{value:s.answer,maxLength:40,placeholder:"Answer",onChange:l=>o(i,{answer:l.target.value}),"aria-label":`Answer ${i+1}`}),(0,m.jsx)(te,{variant:"ghost",size:"icon",disabled:e.answers.length<=2,onClick:()=>n({...e,answers:e.answers.filter((l,c)=>c!==i)}),"aria-label":`Remove ${s.answer||`answer ${i+1}`}`,children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsx)(ve,{value:s.means,maxLength:200,placeholder:"What it means, in a few words",onChange:l=>o(i,{means:l.target.value}),"aria-label":`What ${s.answer||`answer ${i+1}`} means`}),(0,m.jsxs)("select",{className:ht,value:s.to,onChange:l=>o(i,{to:l.target.value}),"aria-label":`Where ${s.answer||`answer ${i+1}`} goes`,children:[s.to===""&&(0,m.jsx)("option",{value:"",children:"Choose where it goes"}),t.map(l=>(0,m.jsxs)("option",{value:l.id,children:["Goes to ",l.title]},l.id))]})]},i)),e.answers.length<12&&(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>n({...e,answers:[...e.answers,{answer:"",means:"",to:""}]}),children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add an answer"]})]}),(0,m.jsx)(he,{label:"Acts on its own when",hint:"Below this, the card takes the not-sure path.",children:(0,m.jsx)("select",{className:ht,value:String(e.sureAt),onChange:s=>n({...e,sureAt:Number(s.target.value)}),"aria-label":"Acts on its own when",children:[...new Set([...rY,e.sureAt])].sort((s,i)=>i-s).map(s=>(0,m.jsxs)("option",{value:String(s),children:[Math.round(s*100),"% sure or more"]},s))})}),(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2",open:e.notes.length>0,children:[(0,m.jsxs)("summary",{className:"cursor-pointer text-[13px] font-medium",children:["Also note on the card",e.notes.length>0?` (${e.notes.length})`:""]}),(0,m.jsxs)("div",{className:"mt-2 grid gap-2",children:[e.notes.map((s,i)=>(0,m.jsxs)("div",{className:"grid gap-1.5 rounded-md border p-2","data-sort-note":i,children:[(0,m.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,m.jsxs)("select",{className:ht,value:s.kind,onChange:l=>r(i,l.target.value==="score"?{kind:"score",levels:s.levels??["Low","Medium","High"]}:{kind:"yes-no",levels:null}),"aria-label":`Note ${i+1}: kind`,children:[(0,m.jsx)("option",{value:"score",children:"A score"}),(0,m.jsx)("option",{value:"yes-no",children:"Yes or no"})]}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>n({...e,notes:e.notes.filter((l,c)=>c!==i)}),"aria-label":`Remove note ${i+1}`,children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsx)(ve,{value:s.question,maxLength:300,placeholder:s.kind==="score"?"How urgent is this?":"Is the customer asking for money back?",onChange:l=>r(i,{question:l.target.value}),"aria-label":`Note ${i+1}: question`}),s.kind==="score"&&(0,m.jsx)(Ot,{rows:3,value:(s.levels??[]).join(`
60
60
  `),onChange:l=>r(i,{levels:l.target.value.split(`
61
- `)}),placeholder:"One level per line, lowest first","aria-label":`Note ${i+1}: levels, lowest first`})]},i)),e.notes.length<3&&(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>n({...e,notes:[...e.notes,{id:"",kind:"yes-no",question:"",levels:null}]}),children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add a note"]})]})]})]})}var Kw="Fill-ins: {{card.title}}, {{card.description}}, {{card.email}}, {{stage.<zone id>}}.";function iY({request:e,view:t,csrf:a,apply:n,set:o}){let r=Object.entries(e.headers),s=(i,l,c)=>o({...e,headers:Object.fromEntries(r.map((f,u)=>u===i?[l,c]:f).filter(([f])=>f!==""))});return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Address",hint:`The host is written out; fill-ins can go after it. ${Kw}`,children:(0,m.jsxs)("div",{className:"flex gap-1.5",children:[(0,m.jsx)("select",{className:ae(ht,"w-24 shrink-0"),value:e.method,onChange:i=>o({...e,method:i.target.value}),"aria-label":"Method",children:["GET","POST","PUT","PATCH","DELETE"].map(i=>(0,m.jsx)("option",{value:i,children:i},i))}),(0,m.jsx)(ve,{value:e.url,maxLength:2e3,onChange:i=>o({...e,url:i.target.value}),className:"font-mono text-[12.5px]",placeholder:"https://api.example.com/items","aria-label":"Address"})]})}),(0,m.jsxs)("div",{className:"grid gap-1.5",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Headers"}),r.map(([i,l],c)=>(0,m.jsxs)("div",{className:"flex gap-1.5","data-request-header":c,children:[(0,m.jsx)(ve,{value:i,maxLength:64,onChange:f=>s(c,f.target.value,l),className:"w-32 shrink-0 font-mono text-[12px]",placeholder:"Authorization","aria-label":`Header ${c+1} name`}),(0,m.jsx)(ve,{value:l,maxLength:500,onChange:f=>s(c,i,f.target.value),className:"font-mono text-[12px]",placeholder:"Bearer {{secret.API_TOKEN}}","aria-label":`Header ${c+1} value`}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>o({...e,headers:Object.fromEntries(r.filter((f,u)=>u!==c))}),"aria-label":`Remove header ${i||c+1}`,children:(0,m.jsx)(Et,{className:"size-4"})})]},c)),r.length<10&&(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>o({...e,headers:{...e.headers,[`X-Header-${r.length+1}`]:""}}),children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add a header"]})]}),e.method!=="GET"&&e.method!=="DELETE"&&(0,m.jsx)(he,{label:"What it sends",hint:"JSON is sent as JSON, with fill-ins inside its strings; anything else as plain text.",children:(0,m.jsx)(Ot,{rows:5,value:e.body??"",maxLength:8e3,onChange:i=>o({...e,body:i.target.value}),className:"font-mono text-[12px]","aria-label":"What it sends"})}),(0,m.jsx)(L_,{view:t,csrf:a,apply:n,words:(0,m.jsxs)(m.Fragment,{children:["Kept on this computer, never shown again. Use one in a header as ","{{secret.NAME}}","."]})})]})}function L_({view:e,csrf:t,apply:a,words:n,chosen:o,choose:r}){let[s,i]=(0,me.useState)({name:"",value:""}),[l,c]=(0,me.useState)(!1),f=o??[];return(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2","data-request-secrets":!0,open:f.length>0?!0:void 0,children:[(0,m.jsxs)("summary",{className:"cursor-pointer text-[13px] font-medium",children:["Secrets",r!==void 0?f.length>0?` (${f.length} used)`:"":e.requestSecrets.length>0?` (${e.requestSecrets.length})`:""]}),(0,m.jsxs)("div",{className:"mt-2 grid gap-2",children:[(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:n}),e.requestSecrets.length>0&&(r===void 0?(0,m.jsx)("p",{className:"flex flex-wrap gap-1.5",children:e.requestSecrets.map(u=>(0,m.jsx)(ya,{tone:"neutral",className:"font-mono",children:u},u))}):(0,m.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1.5",children:e.requestSecrets.map(u=>(0,m.jsxs)("label",{className:"inline-flex items-center gap-1.5 font-mono text-[12px]",children:[(0,m.jsx)("input",{type:"checkbox",className:"size-4 accent-[var(--so-accent)]",checked:f.includes(u),onChange:d=>r(d.target.checked?[...f,u]:f.filter(p=>p!==u))}),u]},u))})),f.filter(u=>!e.requestSecrets.includes(u)).map(u=>(0,m.jsxs)("p",{className:"text-[12px] text-warning",children:[u," isn't saved yet: save it below."]},u)),(0,m.jsxs)("div",{className:"flex gap-1.5",children:[(0,m.jsx)(ve,{value:s.name,onChange:u=>i({...s,name:u.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"_")}),className:"w-32 shrink-0 font-mono text-[12px]",placeholder:"API_TOKEN","aria-label":"Secret name"}),(0,m.jsx)(ve,{type:"password",autoComplete:"off",value:s.value,onChange:u=>i({...s,value:u.target.value}),placeholder:"Its value (empty removes it)","aria-label":"Secret value"})]}),(0,m.jsx)(te,{size:"sm",variant:"outline",className:"self-start",disabled:l||s.name==="",onClick:async()=>{c(!0);let u=await ka(`${e.flow.href}/secrets`,s,t);c(!1),a(u),u.ok&&(r!==void 0&&s.value.trim()!==""&&!f.includes(s.name)&&r([...f,s.name]),i({name:"",value:""}))},children:"Save secret"})]})]})}function I_({routes:e,others:t,set:a,hint:n}){return(0,m.jsxs)("div",{className:"grid gap-1.5","data-code-routes":!0,children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Answers (optional)"}),(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:n}),e.map((o,r)=>(0,m.jsxs)("div",{className:"flex gap-1.5",children:[(0,m.jsx)(ve,{value:o.answer,maxLength:40,onChange:s=>a(e.map((i,l)=>l===r?{...i,answer:s.target.value}:i)),className:"w-32 shrink-0",placeholder:"Urgent","aria-label":`Answer ${r+1}`}),(0,m.jsx)("select",{className:ht,value:o.to,onChange:s=>a(e.map((i,l)=>l===r?{...i,to:s.target.value}:i)),"aria-label":`Where ${o.answer||`answer ${r+1}`} leads`,children:t.map(s=>(0,m.jsx)("option",{value:s.id,children:s.title},s.id))}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>a(e.filter((s,i)=>i!==r)),"aria-label":`Remove ${o.answer||`answer ${r+1}`}`,children:(0,m.jsx)(Et,{className:"size-4"})})]},r)),e.length<12&&t.length>0&&(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>a([...e,{answer:"",to:t[0].id}]),children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add an answer"]})]})}function lY({question:e,csrf:t,apply:a}){let[n,o]=(0,me.useState)(""),[r,s]=(0,me.useState)(!1),i=async c=>{s(!0);let f=await ka(`/teammates/questions/${e.id}/answer`,c,t);s(!1),a(f),f.ok&&o("")},l=e.call??null;return(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3","data-teammate-question":e.id,children:[(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:l===null?`${e.from} asks${e.mine?" you":` ${e.askedOf}`}`:`${e.from} needs ${e.mine?"your":`${e.askedOf}'s`} approval`}),(0,m.jsx)("p",{className:"break-words text-[13px] font-medium",children:e.question}),l!==null&&(0,m.jsxs)("p",{className:"text-[12.5px] text-muted-foreground","data-teammate-call-why":!0,children:[l.why!==""&&(0,m.jsxs)(m.Fragment,{children:[l.why," "]}),"(",l.rule,")"]}),e.mine&&(0,m.jsxs)(m.Fragment,{children:[e.options.length>0&&(0,m.jsx)("div",{className:"flex flex-wrap gap-2",children:e.options.map((c,f)=>(0,m.jsx)(te,{size:"sm",variant:l!==null&&f===0?"default":"outline",disabled:r,onClick:()=>{i({choice:c.id})},children:c.label},c.id))}),(0,m.jsx)(Ot,{value:n,onChange:c=>o(c.target.value),rows:2,maxLength:2e3,placeholder:l===null?"Or answer in your words":`Or tell ${e.from.split(" · ")[0]} what to do instead`,"aria-label":"Your answer"}),(0,m.jsx)(te,{size:"sm",className:"self-start",disabled:r||n.trim()==="",onClick:()=>{i({text:n})},children:"Answer"})]})]})}function uY({stage:e,others:t,view:a,update:n}){let o=a.teammates??[];return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Teammate",hint:o.length===0?void 0:"It follows its soul file's rules, and asks the flow's owner when they say to.",children:o.length===0?(0,m.jsxs)("p",{className:"text-[13px] text-muted-foreground",children:["No teammates in this project yet. ",(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/teammates",children:"Add one"}),"."]}):(0,m.jsx)("select",{className:ht,"aria-label":"Teammate",value:e.teammate??"",onChange:r=>n({teammate:r.target.value}),children:o.map(r=>(0,m.jsxs)("option",{value:r.handle,children:[r.label,r.working?"":" (paused)"]},r.handle))})}),(0,m.jsx)(he,{label:"What to do here",children:(0,m.jsx)(Ot,{rows:4,value:e.instructions??"",maxLength:4e3,onChange:r=>n({instructions:r.target.value}),"aria-label":"What to do here",placeholder:"Read the customer's reply and decide what happens next."})}),(0,m.jsx)(I_,{routes:e.routes??[],others:t,set:r=>n({routes:r}),hint:"It picks one, and writes what the next zones send. With none, it moves the card on to “Then”."}),(0,m.jsxs)("label",{className:"flex items-start gap-2 text-[13px]",children:[(0,m.jsx)("input",{type:"checkbox",className:"mt-0.5 size-4",checked:e.reply===!0,onChange:r=>n({reply:r.target.checked?!0:void 0}),"data-teammate-reply":!0}),(0,m.jsxs)("span",{children:["Answer whoever asked",(0,m.jsx)("span",{className:"block text-[12px] text-muted-foreground",children:"What it writes goes back to the person who added the card, in their chat app."})]})]})]})}function cY({stage:e,others:t,view:a,csrf:n,apply:o,update:r}){let s=e.routes??[],i=a.scripts.find(c=>c.name===e.script),l=c=>r({routes:c});return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Script",hint:a.scripts.length===0?"This project has no scripts yet: make one with Scripts in the toolbar, or ask your lead in chat.":i!==void 0?`${N_[i.language]}${i.file===null?"":`, runs ${i.file}`}. It gets the card as JSON on stdin; what it prints is this step's result.`:void 0,children:(0,m.jsxs)("select",{className:ht,"aria-label":"Script",value:e.script??"",onChange:c=>r({script:c.target.value||null}),children:[(0,m.jsx)("option",{value:"",children:"Choose a script"}),a.scripts.map(c=>(0,m.jsxs)("option",{value:c.name,children:[c.name," — ",c.about]},c.name)),e.script!==null&&!a.scripts.some(c=>c.name===e.script)&&(0,m.jsxs)("option",{value:e.script,children:[e.script," (missing)"]})]})}),(0,m.jsx)(he,{label:"Runs in",hint:(e.runIn??"copy")==="folder"?"Fast. The project's folder is at $FLOW_PROJECT.":"The project's setup runs first. Use this to test or check code.",children:(0,m.jsxs)("select",{className:ht,"aria-label":"Runs in",value:e.runIn??"copy",onChange:c=>r({runIn:c.target.value}),children:[(0,m.jsx)("option",{value:"folder",children:"An empty folder"}),(0,m.jsx)("option",{value:"copy",children:"A copy of the project, at the card's work"})]})}),(0,m.jsx)(I_,{routes:s,others:t,set:l,hint:(0,m.jsxs)(m.Fragment,{children:["If its last line is “goto: ",(0,m.jsx)("em",{children:"answer"}),"”, the card goes where that answer leads."]})}),(0,m.jsx)(L_,{view:a,csrf:n,apply:o,chosen:e.secrets??[],choose:c=>r({secrets:c}),words:"Kept on this computer, never shown again. The script gets each one it's given as a variable of the same name."})]})}var N_={shell:"Shell",python:"Python",node:"Node"},dY={python:`import json, sys
61
+ `)}),placeholder:"One level per line, lowest first","aria-label":`Note ${i+1}: levels, lowest first`})]},i)),e.notes.length<3&&(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>n({...e,notes:[...e.notes,{id:"",kind:"yes-no",question:"",levels:null}]}),children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add a note"]})]})]})]})}var Kw="Fill-ins: {{card.title}}, {{card.description}}, {{card.email}}, {{stage.<zone id>}}.";function iY({request:e,view:t,csrf:a,apply:n,set:o}){let r=Object.entries(e.headers),s=(i,l,c)=>o({...e,headers:Object.fromEntries(r.map((f,u)=>u===i?[l,c]:f).filter(([f])=>f!==""))});return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Address",hint:`The host is written out; fill-ins can go after it. ${Kw}`,children:(0,m.jsxs)("div",{className:"flex gap-1.5",children:[(0,m.jsx)("select",{className:ae(ht,"w-24 shrink-0"),value:e.method,onChange:i=>o({...e,method:i.target.value}),"aria-label":"Method",children:["GET","POST","PUT","PATCH","DELETE"].map(i=>(0,m.jsx)("option",{value:i,children:i},i))}),(0,m.jsx)(ve,{value:e.url,maxLength:2e3,onChange:i=>o({...e,url:i.target.value}),className:"font-mono text-[12.5px]",placeholder:"https://api.example.com/items","aria-label":"Address"})]})}),(0,m.jsxs)("div",{className:"grid gap-1.5",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Headers"}),r.map(([i,l],c)=>(0,m.jsxs)("div",{className:"flex gap-1.5","data-request-header":c,children:[(0,m.jsx)(ve,{value:i,maxLength:64,onChange:f=>s(c,f.target.value,l),className:"w-32 shrink-0 font-mono text-[12px]",placeholder:"Authorization","aria-label":`Header ${c+1} name`}),(0,m.jsx)(ve,{value:l,maxLength:500,onChange:f=>s(c,i,f.target.value),className:"font-mono text-[12px]",placeholder:"Bearer {{secret.API_TOKEN}}","aria-label":`Header ${c+1} value`}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>o({...e,headers:Object.fromEntries(r.filter((f,u)=>u!==c))}),"aria-label":`Remove header ${i||c+1}`,children:(0,m.jsx)(Et,{className:"size-4"})})]},c)),r.length<10&&(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>o({...e,headers:{...e.headers,[`X-Header-${r.length+1}`]:""}}),children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add a header"]})]}),e.method!=="GET"&&e.method!=="DELETE"&&(0,m.jsx)(he,{label:"What it sends",hint:"JSON is sent as JSON, with fill-ins inside its strings; anything else as plain text.",children:(0,m.jsx)(Ot,{rows:5,value:e.body??"",maxLength:8e3,onChange:i=>o({...e,body:i.target.value}),className:"font-mono text-[12px]","aria-label":"What it sends"})}),(0,m.jsx)(L_,{view:t,csrf:a,apply:n,words:(0,m.jsxs)(m.Fragment,{children:["Kept on this computer, never shown again. Use one in a header as ","{{secret.NAME}}","."]})})]})}function L_({view:e,csrf:t,apply:a,words:n,chosen:o,choose:r}){let[s,i]=(0,me.useState)({name:"",value:""}),[l,c]=(0,me.useState)(!1),f=o??[];return(0,m.jsxs)("details",{className:"rounded-md border px-3 py-2","data-request-secrets":!0,open:f.length>0?!0:void 0,children:[(0,m.jsxs)("summary",{className:"cursor-pointer text-[13px] font-medium",children:["Secrets",r!==void 0?f.length>0?` (${f.length} used)`:"":e.requestSecrets.length>0?` (${e.requestSecrets.length})`:""]}),(0,m.jsxs)("div",{className:"mt-2 grid gap-2",children:[(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:n}),e.requestSecrets.length>0&&(r===void 0?(0,m.jsx)("p",{className:"flex flex-wrap gap-1.5",children:e.requestSecrets.map(u=>(0,m.jsx)(ya,{tone:"neutral",className:"font-mono",children:u},u))}):(0,m.jsx)("div",{className:"flex flex-wrap gap-x-3 gap-y-1.5",children:e.requestSecrets.map(u=>(0,m.jsxs)("label",{className:"inline-flex items-center gap-1.5 font-mono text-[12px]",children:[(0,m.jsx)("input",{type:"checkbox",className:"size-4 accent-[var(--so-accent)]",checked:f.includes(u),onChange:d=>r(d.target.checked?[...f,u]:f.filter(p=>p!==u))}),u]},u))})),f.filter(u=>!e.requestSecrets.includes(u)).map(u=>(0,m.jsxs)("p",{className:"text-[12px] text-warning",children:[u," isn't saved yet: save it below."]},u)),(0,m.jsxs)("div",{className:"flex gap-1.5",children:[(0,m.jsx)(ve,{value:s.name,onChange:u=>i({...s,name:u.target.value.toUpperCase().replace(/[^A-Z0-9_]/g,"_")}),className:"w-32 shrink-0 font-mono text-[12px]",placeholder:"API_TOKEN","aria-label":"Secret name"}),(0,m.jsx)(ve,{type:"password",autoComplete:"off",value:s.value,onChange:u=>i({...s,value:u.target.value}),placeholder:"Its value (empty removes it)","aria-label":"Secret value"})]}),(0,m.jsx)(te,{size:"sm",variant:"outline",className:"self-start",disabled:l||s.name==="",onClick:async()=>{c(!0);let u=await ka(`${e.flow.href}/secrets`,s,t);c(!1),a(u),u.ok&&(r!==void 0&&s.value.trim()!==""&&!f.includes(s.name)&&r([...f,s.name]),i({name:"",value:""}))},children:"Save secret"})]})]})}function I_({routes:e,others:t,set:a,hint:n}){return(0,m.jsxs)("div",{className:"grid gap-1.5","data-code-routes":!0,children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Answers (optional)"}),(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:n}),e.map((o,r)=>(0,m.jsxs)("div",{className:"flex gap-1.5",children:[(0,m.jsx)(ve,{value:o.answer,maxLength:40,onChange:s=>a(e.map((i,l)=>l===r?{...i,answer:s.target.value}:i)),className:"w-32 shrink-0",placeholder:"Urgent","aria-label":`Answer ${r+1}`}),(0,m.jsx)("select",{className:ht,value:o.to,onChange:s=>a(e.map((i,l)=>l===r?{...i,to:s.target.value}:i)),"aria-label":`Where ${o.answer||`answer ${r+1}`} leads`,children:t.map(s=>(0,m.jsx)("option",{value:s.id,children:s.title},s.id))}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:()=>a(e.filter((s,i)=>i!==r)),"aria-label":`Remove ${o.answer||`answer ${r+1}`}`,children:(0,m.jsx)(Et,{className:"size-4"})})]},r)),e.length<12&&t.length>0&&(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>a([...e,{answer:"",to:t[0].id}]),children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add an answer"]})]})}function lY({question:e,csrf:t,apply:a}){let[n,o]=(0,me.useState)(""),[r,s]=(0,me.useState)(!1),i=async c=>{s(!0);let f=await ka(`/teammates/questions/${e.id}/answer`,c,t);s(!1),a(f),f.ok&&o("")},l=e.call??null;return(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-attention/50 p-3","data-teammate-question":e.id,children:[(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:l===null?`${e.from} asks${e.mine?" you":` ${e.askedOf}`}`:`${e.from} needs ${e.mine?"your":`${e.askedOf}'s`} approval`}),(0,m.jsx)("p",{className:"break-words text-[13px] font-medium",children:e.question}),l!==null&&(0,m.jsxs)("p",{className:"text-[12.5px] text-muted-foreground","data-teammate-call-why":!0,children:[l.why!==""&&(0,m.jsxs)(m.Fragment,{children:[l.why," "]}),"(",l.rule,")"]}),e.mine&&(0,m.jsxs)(m.Fragment,{children:[e.options.length>0&&(0,m.jsx)("div",{className:"flex flex-wrap gap-2",children:e.options.map((c,f)=>(0,m.jsx)(te,{size:"sm",variant:l!==null&&f===0?"default":"outline",disabled:r,onClick:()=>{i({choice:c.id})},children:c.label},c.id))}),(0,m.jsx)(Ot,{value:n,onChange:c=>o(c.target.value),rows:2,maxLength:2e3,placeholder:l===null?"Or answer in your words":`Or tell ${e.from.split(" · ")[0]} what to do instead`,"aria-label":"Your answer"}),(0,m.jsx)(te,{size:"sm",className:"self-start",disabled:r||n.trim()==="",onClick:()=>{i({text:n})},children:"Answer"})]})]})}function uY({stage:e,others:t,view:a,update:n}){let o=a.teammates??[];return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Teammate",hint:o.length===0?void 0:"It follows its soul file's rules, and asks the flow's owner when they say to.",children:o.length===0?(0,m.jsxs)("p",{className:"text-[13px] text-muted-foreground",children:["No teammates in this project yet. ",(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/teammates",children:"Add one"}),"."]}):(0,m.jsx)("select",{className:ht,"aria-label":"Teammate",value:e.teammate??"",onChange:r=>n({teammate:r.target.value}),children:o.map(r=>(0,m.jsxs)("option",{value:r.handle,children:[r.label,r.working?"":" (paused)"]},r.handle))})}),(0,m.jsx)(he,{label:"What to do here",children:(0,m.jsx)(Ot,{rows:4,value:e.instructions??"",maxLength:8e3,onChange:r=>n({instructions:r.target.value}),"aria-label":"What to do here",placeholder:"Read the customer's reply and decide what happens next."})}),(0,m.jsx)(I_,{routes:e.routes??[],others:t,set:r=>n({routes:r}),hint:"It picks one, and writes what the next zones send. With none, it moves the card on to “Then”."}),(0,m.jsxs)("label",{className:"flex items-start gap-2 text-[13px]",children:[(0,m.jsx)("input",{type:"checkbox",className:"mt-0.5 size-4",checked:e.reply===!0,onChange:r=>n({reply:r.target.checked?!0:void 0}),"data-teammate-reply":!0}),(0,m.jsxs)("span",{children:["Answer whoever asked",(0,m.jsx)("span",{className:"block text-[12px] text-muted-foreground",children:"What it writes goes back to the person who added the card, in their chat app."})]})]})]})}function cY({stage:e,others:t,view:a,csrf:n,apply:o,update:r}){let s=e.routes??[],i=a.scripts.find(c=>c.name===e.script),l=c=>r({routes:c});return(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Script",hint:a.scripts.length===0?"This project has no scripts yet: make one with Scripts in the toolbar, or ask your lead in chat.":i!==void 0?`${N_[i.language]}${i.file===null?"":`, runs ${i.file}`}. It gets the card as JSON on stdin; what it prints is this step's result.`:void 0,children:(0,m.jsxs)("select",{className:ht,"aria-label":"Script",value:e.script??"",onChange:c=>r({script:c.target.value||null}),children:[(0,m.jsx)("option",{value:"",children:"Choose a script"}),a.scripts.map(c=>(0,m.jsxs)("option",{value:c.name,children:[c.name," — ",c.about]},c.name)),e.script!==null&&!a.scripts.some(c=>c.name===e.script)&&(0,m.jsxs)("option",{value:e.script,children:[e.script," (missing)"]})]})}),(0,m.jsx)(he,{label:"Runs in",hint:(e.runIn??"copy")==="folder"?"Fast. The project's folder is at $FLOW_PROJECT.":"The project's setup runs first. Use this to test or check code.",children:(0,m.jsxs)("select",{className:ht,"aria-label":"Runs in",value:e.runIn??"copy",onChange:c=>r({runIn:c.target.value}),children:[(0,m.jsx)("option",{value:"folder",children:"An empty folder"}),(0,m.jsx)("option",{value:"copy",children:"A copy of the project, at the card's work"})]})}),(0,m.jsx)(I_,{routes:s,others:t,set:l,hint:(0,m.jsxs)(m.Fragment,{children:["If its last line is “goto: ",(0,m.jsx)("em",{children:"answer"}),"”, the card goes where that answer leads."]})}),(0,m.jsx)(L_,{view:a,csrf:n,apply:o,chosen:e.secrets??[],choose:c=>r({secrets:c}),words:"Kept on this computer, never shown again. The script gets each one it's given as a variable of the same name."})]})}var N_={shell:"Shell",python:"Python",node:"Node"},dY={python:`import json, sys
62
62
  card = json.load(sys.stdin)["card"]
63
63
  print(f"Looked at {card['title']}")`,node:'import { readFileSync } from "node:fs";\nconst { card } = JSON.parse(readFileSync(0, "utf8"));\nconsole.log(`Looked at ${card.title}`);',shell:`npm ci
64
- npm test`};function fY({email:e,view:t,set:a}){return(0,m.jsxs)(m.Fragment,{children:[!t.emailReady&&(0,m.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-email-needs-setup":!0,children:["Email isn't set up yet. ",(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings#email",children:"Add your mail server in Settings"})]}),(0,m.jsx)(he,{label:"To",children:(0,m.jsx)(ve,{value:e.to,maxLength:500,onChange:n=>a({...e,to:n.target.value}),"aria-label":"To"})}),(0,m.jsx)(he,{label:"Subject",children:(0,m.jsx)(ve,{value:e.subject,maxLength:200,onChange:n=>a({...e,subject:n.target.value}),"aria-label":"Subject"})}),(0,m.jsx)(he,{label:"Email",hint:Kw,children:(0,m.jsx)(Ot,{rows:6,value:e.body,maxLength:8e3,onChange:n=>a({...e,body:n.target.value}),"aria-label":"Email"})})]})}function pY({tool:e,view:t,set:a}){let n=t.tools.find(o=>o.name===e.server);return(0,m.jsxs)(m.Fragment,{children:[t.tools.length===0?(0,m.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-tool-needs-setup":!0,children:["This project has no tools yet. ",(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings/tools",children:"Add one on the Tools page"})]}):(0,m.jsx)(he,{label:"Tool",...n!==void 0&&!n.ready?{hint:"It needs its secrets set on the Tools page first."}:n!==void 0?{hint:n.about}:{},children:(0,m.jsxs)("select",{className:ht,value:e.server,onChange:o=>a({...e,server:o.target.value,name:t.tools.find(r=>r.name===o.target.value)?.functions[0]??""}),"aria-label":"Tool",children:[n===void 0&&(0,m.jsx)("option",{value:e.server,children:e.server===""?"Choose a tool":`${e.server} (missing)`}),t.tools.map(o=>(0,m.jsx)("option",{value:o.name,children:o.name},o.name))]})}),(0,m.jsx)(he,{label:"What it does",hint:n!==void 0&&n.functions.length===0?"Test the tool on the Tools page to list what it can do.":void 0,children:n!==void 0&&n.functions.length>0?(0,m.jsxs)("select",{className:ht,value:e.name,onChange:o=>a({...e,name:o.target.value}),"aria-label":"What it does",children:[!n.functions.includes(e.name)&&(0,m.jsx)("option",{value:e.name,children:e.name||"Choose"}),n.functions.map(o=>(0,m.jsx)("option",{value:o,children:o},o))]}):(0,m.jsx)(ve,{value:e.name,maxLength:100,onChange:o=>a({...e,name:o.target.value}),className:"font-mono","aria-label":"What it does"})}),(0,m.jsx)(he,{label:"Arguments",hint:`JSON, with fill-ins inside its strings. ${Kw}`,children:(0,m.jsx)(Ot,{rows:5,value:e.args,maxLength:4e3,onChange:o=>a({...e,args:o.target.value}),className:"font-mono text-[12px]","aria-label":"Arguments"})})]})}function mY({stage:e,stages:t,view:a,csrf:n,apply:o,update:r,remove:s,makeStart:i,onClose:l}){let c=t.filter(d=>d.id!==e.id),f=ht,u=a.kinds.find(d=>d.kind===e.kind);return(0,m.jsxs)("div",{className:"flex flex-col gap-3","data-flow-zone-panel":e.id,children:[(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[(0,m.jsx)("h2",{className:"flex-1 text-[15px] font-semibold",children:"Edit zone"}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:l,"aria-label":"Close",children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsx)(he,{label:"Name",children:(0,m.jsx)(ve,{value:e.title,maxLength:60,onChange:d=>r({title:d.target.value}),"aria-label":"Zone name"})}),(0,m.jsx)(he,{label:"What happens here",...u===void 0?{}:{hint:u.about},children:(0,m.jsx)("select",{className:f,"aria-label":"What happens here",value:e.kind,onChange:d=>r({kind:d.target.value,...d.target.value==="done"?{next:null,onFail:null}:{},...d.target.value==="update"?{close:e.close??!0,message:e.message??"Done: {{card.title}}"}:{},...d.target.value==="check"?{script:e.script??a.scripts[0]?.name??null,runIn:e.runIn??"folder"}:{},...d.target.value==="request"?{request:e.request??{method:"POST",url:"https://",headers:{},body:'{"title": "{{card.title}}", "details": "{{card.description}}"}'}}:{},...d.target.value==="email"?{email:e.email??{to:"{{card.email}}",subject:"Re: {{card.title}}",body:t.find(p=>p.kind==="draft")?`{{stage.${t.find(p=>p.kind==="draft").id}}}`:""}}:{},...d.target.value==="tool"?{tool:e.tool??{server:a.tools[0]?.name??"",name:a.tools[0]?.functions[0]??"",args:'{"text": "{{card.title}}"}'}}:{},...d.target.value==="draft"?{instructions:e.instructions??"Write a short, friendly reply to the person who sent this card, in plain words."}:{},...d.target.value==="approval"?{toOwner:e.toOwner??!0}:{},...d.target.value==="wait"?{wait:e.wait??{for:"reply",minutes:4320}}:{},...d.target.value==="teammate"?{teammate:e.teammate??a.teammates?.[0]?.handle,instructions:e.instructions??"Read the card and decide what happens next."}:d.target.value!=="approval"?{teammate:void 0}:{},...d.target.value==="wait"||d.target.value==="done"?{limit:void 0}:d.target.value!=="inbox"&&d.target.value!=="approval"&&d.target.value!=="choose"&&e.limit!==void 0?{limit:{...e.limit,to:null}}:{},...d.target.value==="choose"?{next:null,options:e.options??[{label:"Looks good",to:c.find(p=>p.kind==="done")?.id??c[0]?.id??"end"},{label:"Ignore",to:"end"}]}:{options:void 0},...d.target.value==="task"?{}:{repo:void 0},...d.target.value==="sort"?{next:null,sort:e.sort??{question:"What kind of card is this?",answers:c.slice(0,2).map(p=>({answer:p.title.slice(0,40),means:p.title,to:p.id})),sureAt:.8,notes:[]}}:{}}),children:a.kinds.map(d=>(0,m.jsx)("option",{value:d.kind,children:d.label},d.kind))})}),e.kind==="draft"&&(0,m.jsx)(he,{label:"What Claude should write",hint:"Claude reads the card and what earlier zones said. Put a “Person decides” zone next to read and edit it first.",children:(0,m.jsx)(Ot,{rows:5,value:e.instructions??"",maxLength:4e3,onChange:d=>r({instructions:d.target.value}),"aria-label":"What Claude should write"})}),(e.kind==="task"||e.kind==="report")&&(0,m.jsx)(he,{label:"What the agent should do",hint:"Fill-ins: {{card.title}}, {{card.description}}, {{note}} (the latest send-back note), {{stage.<zone id>}} (an earlier zone's report; a research zone adds .items and .report).",children:(0,m.jsx)(Ot,{rows:7,value:e.instructions??"",onChange:d=>r({instructions:d.target.value}),"aria-label":"What the agent should do"})}),e.kind==="task"&&(a.projects??[]).length>1&&(0,m.jsx)(he,{label:"Builds in",hint:"Another project files its task there, as the flow's owner, under that project's approvals.",children:(0,m.jsxs)("select",{className:f,"aria-label":"Builds in",value:e.repo??a.projects[0].path,onChange:d=>r({repo:d.target.value===a.projects[0].path?void 0:d.target.value}),children:[a.projects.map((d,p)=>(0,m.jsx)("option",{value:d.path,children:p===0?`${d.name} (this flow's project)`:d.name},d.path)),e.repo!==void 0&&!a.projects.some(d=>d.path===e.repo)&&(0,m.jsxs)("option",{value:e.repo,children:[e.repo," (not yours)"]})]})}),e.kind==="choose"&&(0,m.jsx)(hY,{options:e.options??[],others:c,set:d=>r({options:d})}),e.kind==="task"&&(0,m.jsx)(he,{label:"Plan first?",children:(0,m.jsxs)("select",{className:f,"aria-label":"Plan first?",value:e.planning??"auto",onChange:d=>r({planning:d.target.value}),children:[(0,m.jsx)("option",{value:"auto",children:"Let Toolroll decide"}),(0,m.jsx)("option",{value:"required",children:"Always plan first"}),(0,m.jsx)("option",{value:"skip",children:"Build directly"})]})}),e.kind==="approval"&&(0,m.jsx)(he,{label:"Who decides",children:(0,m.jsxs)("select",{className:f,"aria-label":"Who decides",value:e.teammate!==void 0?`__mate__:${e.teammate}`:e.toOwner===!0?"__owner__":e.approver??"",onChange:d=>r(d.target.value.startsWith("__mate__:")?{teammate:d.target.value.slice(9),toOwner:!0,approver:null}:d.target.value==="__owner__"?{teammate:void 0,toOwner:!0,approver:null}:{teammate:void 0,toOwner:!1,approver:d.target.value===""?null:d.target.value}),children:[(a.teammates??[]).map(d=>(0,m.jsxs)("option",{value:`__mate__:${d.handle}`,children:[d.name," (AI teammate), handing hard ones to the flow's owner",d.working?"":" (paused)"]},d.handle)),(0,m.jsxs)("option",{value:"__owner__",children:["The flow's owner (",a.flow.owner,"), in their chat app"]}),(0,m.jsx)("option",{value:"",children:"Anyone who can approve"}),a.approvers.map(d=>(0,m.jsx)("option",{value:d,children:d},d))]})}),e.kind==="notify"&&(0,m.jsx)(he,{label:"Message",children:(0,m.jsx)(ve,{value:e.message??"",maxLength:1e3,onChange:d=>r({message:d.target.value}),"aria-label":"Message"})}),e.kind==="update"&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Comment on the issue",hint:"Fill-ins: {{card.title}}, {{note}}, {{stage.<zone id>}}.",children:(0,m.jsx)(Ot,{rows:3,value:e.message??"",maxLength:1e3,onChange:d=>r({message:d.target.value}),"aria-label":"Comment on the issue"})}),(0,m.jsxs)("label",{className:"flex items-center gap-2 text-[13px]",children:[(0,m.jsx)("input",{type:"checkbox",className:"size-4 accent-[var(--so-accent)]",checked:e.close!==!1,onChange:d=>r({close:d.target.checked})}),"Close the issue too (Linear: move it to done)"]})]}),e.kind==="pull-request"&&(0,m.jsx)(he,{label:"When checks pass",hint:"Merging needs a “Person decides” zone before this one, and a person's approval of the card since it was built.",children:(0,m.jsxs)("select",{className:f,"aria-label":"When checks pass",value:e.merge??"",onChange:d=>r({merge:d.target.value===""?void 0:d.target.value}),children:[(0,m.jsx)("option",{value:"",children:"Move on; a person merges"}),(0,m.jsx)("option",{value:"squash",children:"Merge (squash)"}),(0,m.jsx)("option",{value:"merge",children:"Merge (merge commit)"}),(0,m.jsx)("option",{value:"rebase",children:"Merge (rebase)"})]})}),e.kind==="check"&&(0,m.jsx)(cY,{stage:e,others:c,view:a,csrf:n,apply:o,update:r}),e.kind==="teammate"&&(0,m.jsx)(uY,{stage:e,others:c,view:a,update:r}),e.kind==="request"&&e.request!==void 0&&(0,m.jsx)(iY,{request:e.request,view:a,csrf:n,apply:o,set:d=>r({request:d})}),e.kind==="email"&&e.email!==void 0&&(0,m.jsx)(fY,{email:e.email,view:a,set:d=>r({email:d})}),e.kind==="tool"&&e.tool!==void 0&&(0,m.jsx)(pY,{tool:e.tool,view:a,set:d=>r({tool:d})}),e.kind==="sort"&&e.sort!==null&&(0,m.jsx)(sY,{sort:e.sort,others:c,ready:a.sortReady,set:d=>r({sort:d})}),e.kind==="wait"&&e.wait!==void 0&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Wait for",hint:e.wait.for==="reply"?"Only a reply from someone it emailed counts. Needs the inbox in Settings → Email.":void 0,children:(0,m.jsxs)("select",{className:f,"aria-label":"Wait for",value:e.wait.for,onChange:d=>r({wait:d.target.value==="hours"?{for:"hours",minutes:0,from:e.wait.from??"22:00",to:e.wait.to??"06:00"}:{for:d.target.value,minutes:e.wait.minutes>0?e.wait.minutes:1440}}),children:[(0,m.jsx)("option",{value:"reply",children:"A reply to the card's email"}),(0,m.jsx)("option",{value:"time",children:"A set time"}),(0,m.jsx)("option",{value:"hours",children:"Set hours, like overnight"})]})}),e.wait.for==="hours"?(0,m.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,m.jsx)(he,{label:"From",children:(0,m.jsx)(ve,{type:"time",value:e.wait.from??"22:00",onChange:d=>r({wait:{...e.wait,from:d.target.value}}),"aria-label":"From"})}),(0,m.jsx)(he,{label:"Until",children:(0,m.jsx)(ve,{type:"time",value:e.wait.to??"06:00",onChange:d=>r({wait:{...e.wait,to:d.target.value}}),"aria-label":"Until"})})]}):(0,m.jsx)(he,{label:e.wait.for==="reply"?"For up to":"How long",children:(0,m.jsx)(R_,{minutes:e.wait.minutes,label:e.wait.for==="reply"?"For up to":"How long",set:d=>r({wait:{...e.wait,minutes:d}})})})]}),e.kind!=="done"&&e.kind!=="sort"&&e.kind!=="choose"&&(0,m.jsx)(he,{label:e.kind==="wait"&&e.wait?.for==="reply"?"When they reply":"Then",children:(0,m.jsxs)("select",{className:f,"aria-label":e.kind==="wait"&&e.wait?.for==="reply"?"When they reply":"Then",value:e.next??"",onChange:d=>r({next:d.target.value||null}),children:[(0,m.jsx)("option",{value:"",children:"Wait here"}),c.map(d=>(0,m.jsx)("option",{value:d.id,children:d.title},d.id))]})}),e.kind==="wait"&&e.wait?.for==="reply"&&(0,m.jsx)(he,{label:"If no reply",children:(0,m.jsxs)("select",{className:f,"aria-label":"If no reply",value:e.onFail??"",onChange:d=>r({onFail:d.target.value||null}),children:[(0,m.jsx)("option",{value:"",children:"Stay here for a person"}),c.map(d=>(0,m.jsx)("option",{value:d.id,children:d.title},d.id))]})}),(e.kind==="approval"||e.kind==="task"||e.kind==="report"||e.kind==="check"||e.kind==="pull-request"||e.kind==="update"||e.kind==="sort"||e.kind==="request"||e.kind==="email"||e.kind==="tool"||e.kind==="teammate"||e.kind==="choose")&&(0,m.jsx)(he,{label:p_[e.kind]??"If it fails",...e.kind==="choose"?{hint:"Their reply is the note there ({{note}})."}:{},children:(0,m.jsxs)("select",{className:f,"aria-label":p_[e.kind]??"If it fails",value:e.onFail??"",onChange:d=>r({onFail:d.target.value||null}),children:[(0,m.jsx)("option",{value:"",children:e.kind==="approval"?"Can't be sent back":e.kind==="sort"?"Wait here for a person":e.kind==="choose"?"Where the first option goes":"Wait here"}),c.map(d=>(0,m.jsx)("option",{value:d.id,children:d.title},d.id))]})}),e.kind!=="wait"&&e.kind!=="done"&&(0,m.jsx)(gY,{stage:e,others:c,update:r}),(0,m.jsxs)("div",{className:"grid gap-1.5",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Color"}),(0,m.jsx)("div",{className:"flex gap-2",children:a.colors.map(d=>(0,m.jsx)("button",{type:"button","aria-label":d,"aria-pressed":e.zone.color===d,className:ae("size-7 rounded-full border-2",e.zone.color===d?"border-foreground":"border-transparent"),style:{background:yp[d]},onClick:()=>r({zone:{...e.zone,color:d}})},d))})]}),(0,m.jsxs)("div",{className:"flex flex-wrap gap-2 pt-1",children:[a.start!==e.id&&(0,m.jsx)(te,{variant:"outline",size:"sm",onClick:i,children:"New cards start here"}),(0,m.jsx)(te,{variant:"ghost",size:"sm",className:"text-destructive",onClick:s,disabled:t.length<=1,children:"Delete zone"})]})]})}var p_={approval:"If sent back",sort:"If it isn't sure",teammate:"If it can't handle it","pull-request":"If checks fail",choose:"If they reply"};function hY({options:e,others:t,set:a}){let n=(o,r)=>a(e.map((s,i)=>i===o?{...s,...r}:s));return(0,m.jsxs)("div",{className:"grid gap-2","data-choose-options":!0,children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Buttons"}),e.map((o,r)=>(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,m.jsx)(ve,{className:"min-w-0 flex-1",value:o.label,maxLength:40,onChange:s=>n(r,{label:s.target.value}),"aria-label":`Button ${r+1}`}),(0,m.jsxs)("select",{className:ae(ht,"min-w-0 flex-1"),"aria-label":`Button ${r+1} goes to`,value:o.to,onChange:s=>n(r,{to:s.target.value}),children:[(0,m.jsx)("option",{value:"end",children:"Ignore the card"}),t.map(s=>(0,m.jsx)("option",{value:s.id,children:s.title},s.id))]}),e.length>2&&(0,m.jsx)(te,{type:"button",variant:"ghost",size:"icon",onClick:()=>a(e.filter((s,i)=>i!==r)),"aria-label":`Remove button ${r+1}`,children:(0,m.jsx)(Et,{className:"size-4"})})]},r)),e.length<4&&(0,m.jsxs)(te,{type:"button",variant:"outline",size:"sm",className:"self-start",onClick:()=>a([...e,{label:"",to:t[0]?.id??"end"}]),children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add a button"]})]})}function R_({minutes:e,label:t,set:a}){let n=e%1440===0?1440:e%60===0?60:1;return(0,m.jsxs)("div",{className:"flex gap-2",children:[(0,m.jsx)(ve,{type:"number",min:1,max:Math.floor(43200/n),value:e/n,className:"w-24","aria-label":`${t} (number)`,onChange:o=>{let r=Math.round(Number(o.target.value));Number.isFinite(r)&&r>=1&&a(Math.min(43200,r*n))}}),(0,m.jsxs)("select",{className:ht,"aria-label":`${t} (unit)`,value:n,onChange:o=>a(Math.min(43200,Math.max(1,e/n*Number(o.target.value)))),children:[(0,m.jsx)("option",{value:1,children:"minutes"}),(0,m.jsx)("option",{value:60,children:"hours"}),(0,m.jsx)("option",{value:1440,children:"days"})]})]})}function gY({stage:e,others:t,update:a}){let n=e.kind==="inbox"||e.kind==="approval"||e.kind==="choose";return(0,m.jsxs)("div",{className:"grid gap-2","data-time-limit":!0,children:[(0,m.jsxs)("label",{className:"flex items-center gap-2 text-[13px] font-medium",children:[(0,m.jsx)("input",{type:"checkbox",className:"size-4 accent-[var(--so-accent)]",checked:e.limit!==void 0,onChange:o=>a({limit:o.target.checked?{minutes:1440,to:null}:void 0})}),"Time limit"]}),e.limit!==void 0&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Remind after",hint:e.kind==="approval"?"Whoever decides hears about it once.":e.kind==="choose"?"Whoever chooses hears about it once.":"The card's owner (or the flow's) hears about it once.",children:(0,m.jsx)(R_,{minutes:e.limit.minutes,label:"Remind after",set:o=>a({limit:{...e.limit,minutes:o}})})}),n&&(0,m.jsx)(he,{label:e.kind==="choose"?"If no reply":"Then",children:(0,m.jsxs)("select",{className:ht,"aria-label":"After the time limit",value:e.limit.to??"",onChange:o=>a({limit:{...e.limit,to:o.target.value||null}}),children:[(0,m.jsx)("option",{value:"",children:"Keep it here"}),t.map(o=>(0,m.jsxs)("option",{value:o.id,children:["Move it to ",o.title]},o.id))]})})]})]})}function T_({view:e,csrf:t,apply:a,onClose:n}){let[o,r]=(0,me.useState)(""),[s,i]=(0,me.useState)(""),[l,c]=(0,me.useState)(!1),f=e.stages.find(u=>u.id===e.start);return(0,m.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:async u=>{u.preventDefault(),c(!0);let d=await ka(`${e.flow.href}/cards`,{title:o,description:s},t);c(!1),a(d),d.ok&&(r(""),i(""))},children:[(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[(0,m.jsx)("h2",{className:"flex-1 text-[15px] font-semibold",children:"New card"}),n!==void 0&&(0,m.jsx)(te,{type:"button",variant:"ghost",size:"icon",onClick:n,"aria-label":"Close",children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:["It starts in ",f?.title??"the first zone","."]}),(0,m.jsx)(ve,{value:o,onChange:u=>r(u.target.value),placeholder:"What needs doing?",maxLength:200,required:!0,"aria-label":"Title"}),(0,m.jsx)(Ot,{value:s,onChange:u=>i(u.target.value),placeholder:"Details (optional)",rows:4,"aria-label":"Details"}),(0,m.jsxs)(te,{type:"submit",size:"sm",className:"self-start",disabled:l||o.trim()==="",children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add card"]})]})}var M_=e=>{if(e===null)return"";let t=Math.round((Date.now()-Date.parse(e))/6e4);return t<1?"Just now":t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} h ago`:mn(e)};function m_({label:e,value:t}){return(0,m.jsxs)("div",{className:"grid gap-1",children:[(0,m.jsx)("span",{className:"text-[12px] font-medium",children:e}),(0,m.jsxs)("div",{className:"flex gap-2",children:[(0,m.jsx)(ve,{readOnly:!0,value:t,className:"h-8 font-mono text-[12px]",onFocus:n=>n.target.select(),"aria-label":e}),(0,m.jsx)(te,{type:"button",size:"sm",variant:"outline",onClick:()=>{navigator.clipboard?.writeText(t).then(()=>pn.success(`${e} copied.`),()=>pn.error("Select it and copy it by hand."))},"aria-label":`Copy ${e.toLowerCase()}`,children:(0,m.jsx)($d,{className:"size-3.5"})})]})]})}function xY({kind:e,reveal:t,onDone:a}){return(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-primary/40 bg-primary/5 p-3","data-trigger-reveal":!0,children:[(0,m.jsx)("p",{className:"text-[13px] font-semibold",children:"Copy these now. They aren't shown again."}),t.address===null?(0,m.jsxs)("p",{className:"text-[12px]",children:["Save your public webhook address below first, then choose New address. ",(0,m.jsx)("span",{className:"break-all font-mono",children:t.path})]}):(0,m.jsx)(m_,{label:"Address",value:t.address}),t.secret!==null&&(0,m.jsx)(m_,{label:"Secret",value:t.secret}),(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:e==="github"?"In GitHub: Settings → Webhooks → Add webhook. Paste the address and the secret, choose application/json, and pick the events this trigger watches (Issues, Pull requests or Workflow runs).":e==="linear"?"In Linear: Settings → API → Webhooks → New webhook. Paste the address and choose Issues. Then paste Linear's signing secret on this trigger.":e==="form"?"Share this link. Anyone who has it can add a card without signing in; the work it starts still waits for your approval.":"Post JSON to the address. A title field becomes the card's title; description, its details."}),(0,m.jsx)(te,{type:"button",size:"sm",variant:"outline",className:"self-start",onClick:a,children:"Done"})]})}var vY={button:["label","questions"],schedule:["schedule","title","description","script","secrets"],github:["repo","watch","label","branch","from","delivery"],linear:["team","state","label","delivery"],flow:["flow","when"],webhook:["title","titleField","bodyField"],email:["folder","sender","subject"],"plane-review":["at","timeZone"]};function yY({view:e,csrf:t,open:a,onResult:n}){let o=e.triggerSetup,[r,s]=(0,me.useState)("button"),[i,l]=(0,me.useState)({}),[c,f]=(0,me.useState)(!1),[u,d]=(0,me.useState)(!1),p=Intl.DateTimeFormat().resolvedOptions().timeZone,g={schedule:{schedule:`daily 09:00 ${p}`},github:{repo:o.githubRepo??"",watch:"issues",from:"team",delivery:"poll",branch:"main"},linear:{delivery:"poll"},flow:{flow:String(o.otherFlows[0]?.id??"")},webhook:{title:"Webhook"},email:{folder:"INBOX"},"plane-review":{at:"07:30",timeZone:p}},v=h=>i[h]??g[r]?.[h]??"",b=h=>w=>l(S=>({...S,[h]:w.target.value})),x=o.otherFlows.find(h=>String(h.id)===v("flow")),y=async h=>{h.preventDefault();let w={kind:r,zone:v("zone")||null};for(let C of vY[r]??[])w[C]=C==="questions"?v(C).split(`
64
+ npm test`};function fY({email:e,view:t,set:a}){return(0,m.jsxs)(m.Fragment,{children:[!t.emailReady&&(0,m.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-email-needs-setup":!0,children:["Email isn't set up yet. ",(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings#email",children:"Add your mail server in Settings"})]}),(0,m.jsx)(he,{label:"To",children:(0,m.jsx)(ve,{value:e.to,maxLength:500,onChange:n=>a({...e,to:n.target.value}),"aria-label":"To"})}),(0,m.jsx)(he,{label:"Subject",children:(0,m.jsx)(ve,{value:e.subject,maxLength:200,onChange:n=>a({...e,subject:n.target.value}),"aria-label":"Subject"})}),(0,m.jsx)(he,{label:"Email",hint:Kw,children:(0,m.jsx)(Ot,{rows:6,value:e.body,maxLength:8e3,onChange:n=>a({...e,body:n.target.value}),"aria-label":"Email"})})]})}function pY({tool:e,view:t,set:a}){let n=t.tools.find(o=>o.name===e.server);return(0,m.jsxs)(m.Fragment,{children:[t.tools.length===0?(0,m.jsxs)("p",{className:"rounded-md border border-border px-3 py-2 text-[12.5px]","data-tool-needs-setup":!0,children:["This project has no tools yet. ",(0,m.jsx)("a",{className:"font-medium text-primary underline-offset-4 hover:underline",href:"/settings/tools",children:"Add one on the Tools page"})]}):(0,m.jsx)(he,{label:"Tool",...n!==void 0&&!n.ready?{hint:"It needs its secrets set on the Tools page first."}:n!==void 0?{hint:n.about}:{},children:(0,m.jsxs)("select",{className:ht,value:e.server,onChange:o=>a({...e,server:o.target.value,name:t.tools.find(r=>r.name===o.target.value)?.functions[0]??""}),"aria-label":"Tool",children:[n===void 0&&(0,m.jsx)("option",{value:e.server,children:e.server===""?"Choose a tool":`${e.server} (missing)`}),t.tools.map(o=>(0,m.jsx)("option",{value:o.name,children:o.name},o.name))]})}),(0,m.jsx)(he,{label:"What it does",hint:n!==void 0&&n.functions.length===0?"Test the tool on the Tools page to list what it can do.":void 0,children:n!==void 0&&n.functions.length>0?(0,m.jsxs)("select",{className:ht,value:e.name,onChange:o=>a({...e,name:o.target.value}),"aria-label":"What it does",children:[!n.functions.includes(e.name)&&(0,m.jsx)("option",{value:e.name,children:e.name||"Choose"}),n.functions.map(o=>(0,m.jsx)("option",{value:o,children:o},o))]}):(0,m.jsx)(ve,{value:e.name,maxLength:100,onChange:o=>a({...e,name:o.target.value}),className:"font-mono","aria-label":"What it does"})}),(0,m.jsx)(he,{label:"Arguments",hint:`JSON, with fill-ins inside its strings. ${Kw}`,children:(0,m.jsx)(Ot,{rows:5,value:e.args,maxLength:4e3,onChange:o=>a({...e,args:o.target.value}),className:"font-mono text-[12px]","aria-label":"Arguments"})})]})}function mY({stage:e,stages:t,view:a,csrf:n,apply:o,update:r,remove:s,makeStart:i,onClose:l}){let c=t.filter(d=>d.id!==e.id),f=ht,u=a.kinds.find(d=>d.kind===e.kind);return(0,m.jsxs)("div",{className:"flex flex-col gap-3","data-flow-zone-panel":e.id,children:[(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[(0,m.jsx)("h2",{className:"flex-1 text-[15px] font-semibold",children:"Edit zone"}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:l,"aria-label":"Close",children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsx)(he,{label:"Name",children:(0,m.jsx)(ve,{value:e.title,maxLength:60,onChange:d=>r({title:d.target.value}),"aria-label":"Zone name"})}),(0,m.jsx)(he,{label:"What happens here",...u===void 0?{}:{hint:u.about},children:(0,m.jsx)("select",{className:f,"aria-label":"What happens here",value:e.kind,onChange:d=>r({kind:d.target.value,...d.target.value==="done"?{next:null,onFail:null}:{},...d.target.value==="update"?{close:e.close??!0,message:e.message??"Done: {{card.title}}"}:{},...d.target.value==="check"?{script:e.script??a.scripts[0]?.name??null,runIn:e.runIn??"folder"}:{},...d.target.value==="request"?{request:e.request??{method:"POST",url:"https://",headers:{},body:'{"title": "{{card.title}}", "details": "{{card.description}}"}'}}:{},...d.target.value==="email"?{email:e.email??{to:"{{card.email}}",subject:"Re: {{card.title}}",body:t.find(p=>p.kind==="draft")?`{{stage.${t.find(p=>p.kind==="draft").id}}}`:""}}:{},...d.target.value==="tool"?{tool:e.tool??{server:a.tools[0]?.name??"",name:a.tools[0]?.functions[0]??"",args:'{"text": "{{card.title}}"}'}}:{},...d.target.value==="draft"?{instructions:e.instructions??"Write a short, friendly reply to the person who sent this card, in plain words."}:{},...d.target.value==="approval"?{toOwner:e.toOwner??!0}:{},...d.target.value==="wait"?{wait:e.wait??{for:"reply",minutes:4320}}:{},...d.target.value==="teammate"?{teammate:e.teammate??a.teammates?.[0]?.handle,instructions:e.instructions??"Read the card and decide what happens next."}:d.target.value!=="approval"?{teammate:void 0}:{},...d.target.value==="wait"||d.target.value==="done"?{limit:void 0}:d.target.value!=="inbox"&&d.target.value!=="approval"&&d.target.value!=="choose"&&e.limit!==void 0?{limit:{...e.limit,to:null}}:{},...d.target.value==="choose"?{next:null,options:e.options??[{label:"Looks good",to:c.find(p=>p.kind==="done")?.id??c[0]?.id??"end"},{label:"Ignore",to:"end"}]}:{options:void 0},...d.target.value==="task"?{}:{repo:void 0},...d.target.value==="sort"?{next:null,sort:e.sort??{question:"What kind of card is this?",answers:c.slice(0,2).map(p=>({answer:p.title.slice(0,40),means:p.title,to:p.id})),sureAt:.8,notes:[]}}:{}}),children:a.kinds.map(d=>(0,m.jsx)("option",{value:d.kind,children:d.label},d.kind))})}),e.kind==="draft"&&(0,m.jsx)(he,{label:"What Claude should write",hint:"Claude reads the card and what earlier zones said. Put a “Person decides” zone next to read and edit it first.",children:(0,m.jsx)(Ot,{rows:5,value:e.instructions??"",maxLength:8e3,onChange:d=>r({instructions:d.target.value}),"aria-label":"What Claude should write"})}),(e.kind==="task"||e.kind==="report")&&(0,m.jsx)(he,{label:"What the agent should do",hint:"Fill-ins: {{card.title}}, {{card.description}}, {{note}} (the latest send-back note), {{stage.<zone id>}} (an earlier zone's report; a research zone adds .items and .report).",children:(0,m.jsx)(Ot,{rows:7,value:e.instructions??"",onChange:d=>r({instructions:d.target.value}),"aria-label":"What the agent should do"})}),e.kind==="task"&&(a.projects??[]).length>1&&(0,m.jsx)(he,{label:"Builds in",hint:"Another project files its task there, as the flow's owner, under that project's approvals.",children:(0,m.jsxs)("select",{className:f,"aria-label":"Builds in",value:e.repo??a.projects[0].path,onChange:d=>r({repo:d.target.value===a.projects[0].path?void 0:d.target.value}),children:[a.projects.map((d,p)=>(0,m.jsx)("option",{value:d.path,children:p===0?`${d.name} (this flow's project)`:d.name},d.path)),e.repo!==void 0&&!a.projects.some(d=>d.path===e.repo)&&(0,m.jsxs)("option",{value:e.repo,children:[e.repo," (not yours)"]})]})}),e.kind==="choose"&&(0,m.jsx)(hY,{options:e.options??[],others:c,set:d=>r({options:d})}),e.kind==="task"&&(0,m.jsx)(he,{label:"Plan first?",children:(0,m.jsxs)("select",{className:f,"aria-label":"Plan first?",value:e.planning??"auto",onChange:d=>r({planning:d.target.value}),children:[(0,m.jsx)("option",{value:"auto",children:"Let Toolroll decide"}),(0,m.jsx)("option",{value:"required",children:"Always plan first"}),(0,m.jsx)("option",{value:"skip",children:"Build directly"})]})}),e.kind==="approval"&&(0,m.jsx)(he,{label:"Who decides",children:(0,m.jsxs)("select",{className:f,"aria-label":"Who decides",value:e.teammate!==void 0?`__mate__:${e.teammate}`:e.toOwner===!0?"__owner__":e.approver??"",onChange:d=>r(d.target.value.startsWith("__mate__:")?{teammate:d.target.value.slice(9),toOwner:!0,approver:null}:d.target.value==="__owner__"?{teammate:void 0,toOwner:!0,approver:null}:{teammate:void 0,toOwner:!1,approver:d.target.value===""?null:d.target.value}),children:[(a.teammates??[]).map(d=>(0,m.jsxs)("option",{value:`__mate__:${d.handle}`,children:[d.name," (AI teammate), handing hard ones to the flow's owner",d.working?"":" (paused)"]},d.handle)),(0,m.jsxs)("option",{value:"__owner__",children:["The flow's owner (",a.flow.owner,"), in their chat app"]}),(0,m.jsx)("option",{value:"",children:"Anyone who can approve"}),a.approvers.map(d=>(0,m.jsx)("option",{value:d,children:d},d))]})}),e.kind==="notify"&&(0,m.jsx)(he,{label:"Message",children:(0,m.jsx)(ve,{value:e.message??"",maxLength:1e3,onChange:d=>r({message:d.target.value}),"aria-label":"Message"})}),e.kind==="update"&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Comment on the issue",hint:"Fill-ins: {{card.title}}, {{note}}, {{stage.<zone id>}}.",children:(0,m.jsx)(Ot,{rows:3,value:e.message??"",maxLength:1e3,onChange:d=>r({message:d.target.value}),"aria-label":"Comment on the issue"})}),(0,m.jsxs)("label",{className:"flex items-center gap-2 text-[13px]",children:[(0,m.jsx)("input",{type:"checkbox",className:"size-4 accent-[var(--so-accent)]",checked:e.close!==!1,onChange:d=>r({close:d.target.checked})}),"Close the issue too (Linear: move it to done)"]})]}),e.kind==="pull-request"&&(0,m.jsx)(he,{label:"When checks pass",hint:"Merging needs a “Person decides” zone before this one, and a person's approval of the card since it was built.",children:(0,m.jsxs)("select",{className:f,"aria-label":"When checks pass",value:e.merge??"",onChange:d=>r({merge:d.target.value===""?void 0:d.target.value}),children:[(0,m.jsx)("option",{value:"",children:"Move on; a person merges"}),(0,m.jsx)("option",{value:"squash",children:"Merge (squash)"}),(0,m.jsx)("option",{value:"merge",children:"Merge (merge commit)"}),(0,m.jsx)("option",{value:"rebase",children:"Merge (rebase)"})]})}),e.kind==="check"&&(0,m.jsx)(cY,{stage:e,others:c,view:a,csrf:n,apply:o,update:r}),e.kind==="teammate"&&(0,m.jsx)(uY,{stage:e,others:c,view:a,update:r}),e.kind==="request"&&e.request!==void 0&&(0,m.jsx)(iY,{request:e.request,view:a,csrf:n,apply:o,set:d=>r({request:d})}),e.kind==="email"&&e.email!==void 0&&(0,m.jsx)(fY,{email:e.email,view:a,set:d=>r({email:d})}),e.kind==="tool"&&e.tool!==void 0&&(0,m.jsx)(pY,{tool:e.tool,view:a,set:d=>r({tool:d})}),e.kind==="sort"&&e.sort!==null&&(0,m.jsx)(sY,{sort:e.sort,others:c,ready:a.sortReady,set:d=>r({sort:d})}),e.kind==="wait"&&e.wait!==void 0&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Wait for",hint:e.wait.for==="reply"?"Only a reply from someone it emailed counts. Needs the inbox in Settings → Email.":void 0,children:(0,m.jsxs)("select",{className:f,"aria-label":"Wait for",value:e.wait.for,onChange:d=>r({wait:d.target.value==="hours"?{for:"hours",minutes:0,from:e.wait.from??"22:00",to:e.wait.to??"06:00"}:{for:d.target.value,minutes:e.wait.minutes>0?e.wait.minutes:1440}}),children:[(0,m.jsx)("option",{value:"reply",children:"A reply to the card's email"}),(0,m.jsx)("option",{value:"time",children:"A set time"}),(0,m.jsx)("option",{value:"hours",children:"Set hours, like overnight"})]})}),e.wait.for==="hours"?(0,m.jsxs)("div",{className:"grid grid-cols-2 gap-2",children:[(0,m.jsx)(he,{label:"From",children:(0,m.jsx)(ve,{type:"time",value:e.wait.from??"22:00",onChange:d=>r({wait:{...e.wait,from:d.target.value}}),"aria-label":"From"})}),(0,m.jsx)(he,{label:"Until",children:(0,m.jsx)(ve,{type:"time",value:e.wait.to??"06:00",onChange:d=>r({wait:{...e.wait,to:d.target.value}}),"aria-label":"Until"})})]}):(0,m.jsx)(he,{label:e.wait.for==="reply"?"For up to":"How long",children:(0,m.jsx)(R_,{minutes:e.wait.minutes,label:e.wait.for==="reply"?"For up to":"How long",set:d=>r({wait:{...e.wait,minutes:d}})})})]}),e.kind!=="done"&&e.kind!=="sort"&&e.kind!=="choose"&&(0,m.jsx)(he,{label:e.kind==="wait"&&e.wait?.for==="reply"?"When they reply":"Then",children:(0,m.jsxs)("select",{className:f,"aria-label":e.kind==="wait"&&e.wait?.for==="reply"?"When they reply":"Then",value:e.next??"",onChange:d=>r({next:d.target.value||null}),children:[(0,m.jsx)("option",{value:"",children:"Wait here"}),c.map(d=>(0,m.jsx)("option",{value:d.id,children:d.title},d.id))]})}),e.kind==="wait"&&e.wait?.for==="reply"&&(0,m.jsx)(he,{label:"If no reply",children:(0,m.jsxs)("select",{className:f,"aria-label":"If no reply",value:e.onFail??"",onChange:d=>r({onFail:d.target.value||null}),children:[(0,m.jsx)("option",{value:"",children:"Stay here for a person"}),c.map(d=>(0,m.jsx)("option",{value:d.id,children:d.title},d.id))]})}),(e.kind==="approval"||e.kind==="task"||e.kind==="report"||e.kind==="check"||e.kind==="pull-request"||e.kind==="update"||e.kind==="sort"||e.kind==="request"||e.kind==="email"||e.kind==="tool"||e.kind==="teammate"||e.kind==="choose")&&(0,m.jsx)(he,{label:p_[e.kind]??"If it fails",...e.kind==="choose"?{hint:"Their reply is the note there ({{note}})."}:{},children:(0,m.jsxs)("select",{className:f,"aria-label":p_[e.kind]??"If it fails",value:e.onFail??"",onChange:d=>r({onFail:d.target.value||null}),children:[(0,m.jsx)("option",{value:"",children:e.kind==="approval"?"Can't be sent back":e.kind==="sort"?"Wait here for a person":e.kind==="choose"?"Where the first option goes":"Wait here"}),c.map(d=>(0,m.jsx)("option",{value:d.id,children:d.title},d.id))]})}),e.kind!=="wait"&&e.kind!=="done"&&(0,m.jsx)(gY,{stage:e,others:c,update:r}),(0,m.jsxs)("div",{className:"grid gap-1.5",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Color"}),(0,m.jsx)("div",{className:"flex gap-2",children:a.colors.map(d=>(0,m.jsx)("button",{type:"button","aria-label":d,"aria-pressed":e.zone.color===d,className:ae("size-7 rounded-full border-2",e.zone.color===d?"border-foreground":"border-transparent"),style:{background:yp[d]},onClick:()=>r({zone:{...e.zone,color:d}})},d))})]}),(0,m.jsxs)("div",{className:"flex flex-wrap gap-2 pt-1",children:[a.start!==e.id&&(0,m.jsx)(te,{variant:"outline",size:"sm",onClick:i,children:"New cards start here"}),(0,m.jsx)(te,{variant:"ghost",size:"sm",className:"text-destructive",onClick:s,disabled:t.length<=1,children:"Delete zone"})]})]})}var p_={approval:"If sent back",sort:"If it isn't sure",teammate:"If it can't handle it","pull-request":"If checks fail",choose:"If they reply"};function hY({options:e,others:t,set:a}){let n=(o,r)=>a(e.map((s,i)=>i===o?{...s,...r}:s));return(0,m.jsxs)("div",{className:"grid gap-2","data-choose-options":!0,children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Buttons"}),e.map((o,r)=>(0,m.jsxs)("div",{className:"flex flex-wrap items-center gap-2",children:[(0,m.jsx)(ve,{className:"min-w-0 flex-1",value:o.label,maxLength:40,onChange:s=>n(r,{label:s.target.value}),"aria-label":`Button ${r+1}`}),(0,m.jsxs)("select",{className:ae(ht,"min-w-0 flex-1"),"aria-label":`Button ${r+1} goes to`,value:o.to,onChange:s=>n(r,{to:s.target.value}),children:[(0,m.jsx)("option",{value:"end",children:"Ignore the card"}),t.map(s=>(0,m.jsx)("option",{value:s.id,children:s.title},s.id))]}),e.length>2&&(0,m.jsx)(te,{type:"button",variant:"ghost",size:"icon",onClick:()=>a(e.filter((s,i)=>i!==r)),"aria-label":`Remove button ${r+1}`,children:(0,m.jsx)(Et,{className:"size-4"})})]},r)),e.length<4&&(0,m.jsxs)(te,{type:"button",variant:"outline",size:"sm",className:"self-start",onClick:()=>a([...e,{label:"",to:t[0]?.id??"end"}]),children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add a button"]})]})}function R_({minutes:e,label:t,set:a}){let n=e%1440===0?1440:e%60===0?60:1;return(0,m.jsxs)("div",{className:"flex gap-2",children:[(0,m.jsx)(ve,{type:"number",min:1,max:Math.floor(43200/n),value:e/n,className:"w-24","aria-label":`${t} (number)`,onChange:o=>{let r=Math.round(Number(o.target.value));Number.isFinite(r)&&r>=1&&a(Math.min(43200,r*n))}}),(0,m.jsxs)("select",{className:ht,"aria-label":`${t} (unit)`,value:n,onChange:o=>a(Math.min(43200,Math.max(1,e/n*Number(o.target.value)))),children:[(0,m.jsx)("option",{value:1,children:"minutes"}),(0,m.jsx)("option",{value:60,children:"hours"}),(0,m.jsx)("option",{value:1440,children:"days"})]})]})}function gY({stage:e,others:t,update:a}){let n=e.kind==="inbox"||e.kind==="approval"||e.kind==="choose";return(0,m.jsxs)("div",{className:"grid gap-2","data-time-limit":!0,children:[(0,m.jsxs)("label",{className:"flex items-center gap-2 text-[13px] font-medium",children:[(0,m.jsx)("input",{type:"checkbox",className:"size-4 accent-[var(--so-accent)]",checked:e.limit!==void 0,onChange:o=>a({limit:o.target.checked?{minutes:1440,to:null}:void 0})}),"Time limit"]}),e.limit!==void 0&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Remind after",hint:e.kind==="approval"?"Whoever decides hears about it once.":e.kind==="choose"?"Whoever chooses hears about it once.":"The card's owner (or the flow's) hears about it once.",children:(0,m.jsx)(R_,{minutes:e.limit.minutes,label:"Remind after",set:o=>a({limit:{...e.limit,minutes:o}})})}),n&&(0,m.jsx)(he,{label:e.kind==="choose"?"If no reply":"Then",children:(0,m.jsxs)("select",{className:ht,"aria-label":"After the time limit",value:e.limit.to??"",onChange:o=>a({limit:{...e.limit,to:o.target.value||null}}),children:[(0,m.jsx)("option",{value:"",children:"Keep it here"}),t.map(o=>(0,m.jsxs)("option",{value:o.id,children:["Move it to ",o.title]},o.id))]})})]})]})}function T_({view:e,csrf:t,apply:a,onClose:n}){let[o,r]=(0,me.useState)(""),[s,i]=(0,me.useState)(""),[l,c]=(0,me.useState)(!1),f=e.stages.find(u=>u.id===e.start);return(0,m.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:async u=>{u.preventDefault(),c(!0);let d=await ka(`${e.flow.href}/cards`,{title:o,description:s},t);c(!1),a(d),d.ok&&(r(""),i(""))},children:[(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[(0,m.jsx)("h2",{className:"flex-1 text-[15px] font-semibold",children:"New card"}),n!==void 0&&(0,m.jsx)(te,{type:"button",variant:"ghost",size:"icon",onClick:n,"aria-label":"Close",children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:["It starts in ",f?.title??"the first zone","."]}),(0,m.jsx)(ve,{value:o,onChange:u=>r(u.target.value),placeholder:"What needs doing?",maxLength:200,required:!0,"aria-label":"Title"}),(0,m.jsx)(Ot,{value:s,onChange:u=>i(u.target.value),placeholder:"Details (optional)",rows:4,"aria-label":"Details"}),(0,m.jsxs)(te,{type:"submit",size:"sm",className:"self-start",disabled:l||o.trim()==="",children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add card"]})]})}var M_=e=>{if(e===null)return"";let t=Math.round((Date.now()-Date.parse(e))/6e4);return t<1?"Just now":t<60?`${t} min ago`:t<1440?`${Math.round(t/60)} h ago`:mn(e)};function m_({label:e,value:t}){return(0,m.jsxs)("div",{className:"grid gap-1",children:[(0,m.jsx)("span",{className:"text-[12px] font-medium",children:e}),(0,m.jsxs)("div",{className:"flex gap-2",children:[(0,m.jsx)(ve,{readOnly:!0,value:t,className:"h-8 font-mono text-[12px]",onFocus:n=>n.target.select(),"aria-label":e}),(0,m.jsx)(te,{type:"button",size:"sm",variant:"outline",onClick:()=>{navigator.clipboard?.writeText(t).then(()=>pn.success(`${e} copied.`),()=>pn.error("Select it and copy it by hand."))},"aria-label":`Copy ${e.toLowerCase()}`,children:(0,m.jsx)($d,{className:"size-3.5"})})]})]})}function xY({kind:e,reveal:t,onDone:a}){return(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-lg border border-primary/40 bg-primary/5 p-3","data-trigger-reveal":!0,children:[(0,m.jsx)("p",{className:"text-[13px] font-semibold",children:"Copy these now. They aren't shown again."}),t.address===null?(0,m.jsxs)("p",{className:"text-[12px]",children:["Save your public webhook address below first, then choose New address. ",(0,m.jsx)("span",{className:"break-all font-mono",children:t.path})]}):(0,m.jsx)(m_,{label:"Address",value:t.address}),t.secret!==null&&(0,m.jsx)(m_,{label:"Secret",value:t.secret}),(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:e==="github"?"In GitHub: Settings → Webhooks → Add webhook. Paste the address and the secret, choose application/json, and pick the events this trigger watches (Issues, Pull requests or Workflow runs).":e==="linear"?"In Linear: Settings → API → Webhooks → New webhook. Paste the address and choose Issues. Then paste Linear's signing secret on this trigger.":e==="form"?"Share this link. Anyone who has it can add a card without signing in; the work it starts still waits for your approval.":"Post JSON to the address. A title field becomes the card's title; description, its details."}),(0,m.jsx)(te,{type:"button",size:"sm",variant:"outline",className:"self-start",onClick:a,children:"Done"})]})}var vY={button:["label","questions"],schedule:["schedule","title","description","script","secrets"],github:["repo","watch","label","branch","from","delivery"],linear:["team","state","label","delivery"],flow:["flow","when"],webhook:["title","titleField","bodyField"],email:["folder","sender","subject"],"plane-review":["at","timeZone"]};function yY({view:e,csrf:t,open:a,onResult:n}){let o=e.triggerSetup,[r,s]=(0,me.useState)("button"),[i,l]=(0,me.useState)({}),[c,f]=(0,me.useState)(!1),[u,d]=(0,me.useState)(!1),p=Intl.DateTimeFormat().resolvedOptions().timeZone,g={schedule:{schedule:`daily 09:00 ${p}`},github:{repo:o.githubRepo??"",watch:"issues",from:"team",delivery:"poll",branch:"main"},linear:{delivery:"poll"},flow:{flow:String(o.otherFlows[0]?.id??"")},webhook:{title:"Webhook"},email:{folder:"INBOX"},"plane-review":{at:"07:30",timeZone:p}},v=h=>i[h]??g[r]?.[h]??"",b=h=>w=>l(S=>({...S,[h]:w.target.value})),x=o.otherFlows.find(h=>String(h.id)===v("flow")),y=async h=>{h.preventDefault();let w={kind:r,zone:v("zone")||null};for(let C of vY[r]??[])w[C]=C==="questions"?v(C).split(`
65
65
  `):C==="flow"?Number(v(C)):v(C)||null;d(!0);let S=await ka(`${e.flow.href}/triggers`,{trigger:JSON.stringify(w)},t);d(!1),n(S,r),S.ok&&l({})};return(0,m.jsxs)("details",{className:"rounded-lg border px-3 py-2",open:a,children:[(0,m.jsx)("summary",{className:"cursor-pointer text-[13px] font-semibold",children:"Add a trigger"}),(0,m.jsxs)("form",{className:"flex flex-col gap-3 pt-3",onSubmit:h=>{y(h)},"data-add-trigger":!0,children:[(0,m.jsx)(he,{label:"What starts cards",children:(0,m.jsx)("select",{className:ht,value:r,onChange:h=>{s(h.target.value),l({})},children:o.kinds.map(h=>(0,m.jsx)("option",{value:h.kind,children:h.label},h.kind))})}),r==="button"&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Button name",children:(0,m.jsx)(ve,{value:v("label"),onChange:b("label"),placeholder:"Report a bug",maxLength:40,required:!0})}),(0,m.jsx)(he,{label:"Questions it asks",hint:"One per line. The first answer becomes the card's title.",children:(0,m.jsx)(Ot,{rows:3,value:v("questions"),onChange:b("questions"),placeholder:`What happened?
66
66
  Steps to reproduce
67
67
  How bad is it?`})})]}),r==="schedule"&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"When",hint:"For example: daily 09:00 Europe/London, monday 09:00, every 4 hours.",children:(0,m.jsx)(ve,{value:v("schedule"),onChange:b("schedule"),required:!0})}),(0,m.jsx)(he,{label:"Makes",children:(0,m.jsxs)("select",{className:ht,value:v("script")===""&&!c?"card":"script","aria-label":"Makes",onChange:h=>{f(h.target.value==="script"),l(w=>({...w,script:h.target.value==="script"?e.scripts[0]?.name??"":""}))},children:[(0,m.jsx)("option",{value:"card",children:"One card each time"}),(0,m.jsx)("option",{value:"script",children:"A card for each item a script prints"})]})}),v("script")!==""||c?e.scripts.length===0?(0,m.jsx)("p",{className:"text-[13px] text-muted-foreground",children:"This project has no scripts yet: make one with Scripts in the toolbar."}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Script",hint:'It prints one item per line (a title, or JSON like {"title": "…", "key": 42}). The same item never makes two cards.',children:(0,m.jsx)("select",{className:ht,value:v("script"),onChange:b("script"),"aria-label":"Script",children:e.scripts.map(h=>(0,m.jsxs)("option",{value:h.name,children:[h.name," — ",h.about]},h.name))})}),(0,m.jsx)(he,{label:"Secrets it gets (optional)",hint:"Names of saved secrets, like CRM_KEY. Save them on a script zone's Secrets.",children:(0,m.jsx)(ve,{value:v("secrets"),onChange:b("secrets"),className:"font-mono",placeholder:"CRM_KEY",maxLength:400})})]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Card title",hint:"Each card's date is added to it.",children:(0,m.jsx)(ve,{value:v("title"),onChange:b("title"),placeholder:"Dependency check",maxLength:200,required:!0})}),(0,m.jsx)(he,{label:"Details (optional)",children:(0,m.jsx)(Ot,{rows:3,value:v("description"),onChange:b("description")})})]})]}),r==="github"&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Repository",children:(0,m.jsx)(ve,{value:v("repo"),onChange:b("repo"),placeholder:"owner/name",required:!0})}),(0,m.jsx)(he,{label:"Watch",children:(0,m.jsxs)("select",{className:ht,value:v("watch"),onChange:b("watch"),children:[(0,m.jsx)("option",{value:"issues",children:"New issues"}),(0,m.jsx)("option",{value:"pulls",children:"New pull requests"}),(0,m.jsx)("option",{value:"checks",children:"Failed checks"})]})}),v("watch")!=="checks"&&(0,m.jsx)(he,{label:"Label (optional)",hint:v("watch")==="issues"?"With a label, an issue joins the moment it gets the label.":"Only pull requests with this label.",children:(0,m.jsx)(ve,{value:v("label"),onChange:b("label"),placeholder:"bug",maxLength:50})}),v("watch")==="checks"&&(0,m.jsx)(he,{label:"Branch",children:(0,m.jsx)(ve,{value:v("branch"),onChange:b("branch"),maxLength:100})}),v("watch")!=="checks"&&(0,m.jsx)(he,{label:"From",hint:v("from")==="anyone"?"Anyone who can open one there can write what the agent reads. The work still waits for your approval.":void 0,children:(0,m.jsxs)("select",{className:ht,value:v("from"),onChange:b("from"),children:[(0,m.jsx)("option",{value:"team",children:"People with write access"}),(0,m.jsx)("option",{value:"anyone",children:"Anyone"})]})})]}),r==="linear"&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Team key",hint:"Like ENG. Name a team, a label, or both.",children:(0,m.jsx)(ve,{value:v("team"),onChange:b("team"),placeholder:"ENG",maxLength:12})}),(0,m.jsx)(he,{label:"When it moves to (optional)",children:(0,m.jsx)(ve,{value:v("state"),onChange:b("state"),placeholder:"Todo",maxLength:40})}),(0,m.jsx)(he,{label:"Label (optional)",children:(0,m.jsx)(ve,{value:v("label"),onChange:b("label"),placeholder:"bug",maxLength:50})})]}),(r==="github"||r==="linear")&&(0,m.jsx)(he,{label:"How it arrives",hint:v("delivery")==="webhook"?o.hooksBase===null?"Needs your public webhook address: set it under Settings below.":"You'll get an address to paste into "+(r==="github"?"GitHub.":"Linear."):r==="linear"&&!o.linearKey?"Save your Linear key under Settings below first.":void 0,children:(0,m.jsxs)("select",{className:ht,value:v("delivery"),onChange:b("delivery"),children:[(0,m.jsx)("option",{value:"poll",children:"Checked every 2 minutes"}),(0,m.jsx)("option",{value:"webhook",children:"Sent to a webhook address"})]})}),r==="flow"&&(o.otherFlows.length===0?(0,m.jsx)("p",{className:"text-[13px] text-muted-foreground",children:"There are no other flows to follow yet."}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Flow",children:(0,m.jsx)("select",{className:ht,value:v("flow"),onChange:h=>l(w=>({...w,flow:h.target.value,when:""})),children:o.otherFlows.map(h=>(0,m.jsx)("option",{value:h.id,children:h.name},h.id))})}),(0,m.jsx)(he,{label:"When a card reaches",children:(0,m.jsxs)("select",{className:ht,value:v("when"),onChange:b("when"),children:[(0,m.jsx)("option",{value:"",children:"The end"}),x?.zones.map(h=>(0,m.jsx)("option",{value:h.id,children:h.title},h.id))]})})]})),r==="chat"&&(0,m.jsxs)("div",{className:"flex flex-col gap-2 rounded-md bg-muted px-2.5 py-2 text-[12.5px]","data-chat-connect":!0,children:[(0,m.jsx)("p",{children:"Connect a Slack, Discord or Teams channel, or a Telegram group, from the channel itself. Where Toolroll is, send:"}),(0,m.jsx)("p",{children:(0,m.jsxs)("code",{className:"rounded bg-background px-1.5 py-0.5 font-semibold",children:["flow ",e.flow.id]})}),(0,m.jsxs)("p",{className:"text-muted-foreground",children:["Each new message there becomes a card here, and replies in its thread join the card's discussion. “flow off” stops it. In Teams, mention Toolroll in each message. In Telegram, send /flow ",e.flow.id,", and turn the bot's privacy mode off in BotFather so it sees every message."]})]}),r==="email"&&(0,m.jsxs)(m.Fragment,{children:[o.mailbox===null?(0,m.jsxs)("p",{className:"rounded-md bg-muted px-2.5 py-2 text-[12.5px]","data-mailbox-missing":!0,children:["Reading mail isn't set up yet. Add your mail server's IMAP address, or sign in with Google, in ",(0,m.jsx)("a",{className:"underline",href:"/settings#email",children:"Settings → Email"}),"."]}):(0,m.jsxs)("p",{className:"text-[12.5px] text-muted-foreground",children:["New mail in ",o.mailbox," becomes cards, from now on. The mailbox is only read: nothing is marked or moved."]}),(0,m.jsx)(he,{label:"Folder",children:(0,m.jsx)(ve,{value:v("folder"),onChange:b("folder"),placeholder:"INBOX",maxLength:100})}),(0,m.jsx)(he,{label:"Only from (optional)",hint:"Addresses or domains, like priya@example.com, example.com.",children:(0,m.jsx)(ve,{value:v("sender"),onChange:b("sender"),maxLength:300})}),(0,m.jsx)(he,{label:"Subject has (optional)",children:(0,m.jsx)(ve,{value:v("subject"),onChange:b("subject"),placeholder:"Order",maxLength:100})})]}),r==="plane-review"&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)("p",{className:"text-[12.5px] text-muted-foreground",children:"Every morning, reads the last 24 hours and makes one card per problem worth fixing. A problem that comes back joins its card. A clean day adds nothing."}),(0,m.jsx)(he,{label:"Time",hint:`Every day, in ${v("timeZone")||"your time zone"}.`,children:(0,m.jsx)(ve,{type:"time",value:v("at"),onChange:b("at"),required:!0})})]}),r==="webhook"&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(he,{label:"Title field",hint:"Where to find the card's title in the posted JSON, like title or data.issue.title.",children:(0,m.jsx)(ve,{value:v("titleField"),onChange:b("titleField"),placeholder:"title",maxLength:80})}),(0,m.jsx)(he,{label:"Details field",children:(0,m.jsx)(ve,{value:v("bodyField"),onChange:b("bodyField"),placeholder:"description",maxLength:80})}),(0,m.jsx)(he,{label:"Title when there is none",children:(0,m.jsx)(ve,{value:v("title"),onChange:b("title"),maxLength:120})})]}),r!=="chat"&&(0,m.jsx)(he,{label:"Cards start in",children:(0,m.jsxs)("select",{className:ht,value:v("zone"),onChange:b("zone"),children:[(0,m.jsx)("option",{value:"",children:e.stages.find(h=>h.id===e.start)?.title??"The first zone"}),e.stages.filter(h=>h.id!==e.start).map(h=>(0,m.jsx)("option",{value:h.id,children:h.title},h.id))]})}),r!=="chat"&&(0,m.jsxs)(te,{type:"submit",size:"sm",className:"self-start",disabled:u||r==="flow"&&o.otherFlows.length===0,children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add trigger"]})]})]})}function bY({view:e,csrf:t,apply:a}){let n=e.triggerSetup,[o,r]=(0,me.useState)(""),[s,i]=(0,me.useState)(""),[l,c]=(0,me.useState)(n.hooksBase??""),[f,u]=(0,me.useState)(!1),d=async(p,g)=>{u(!0);let v=await ka(p,g,t);u(!1),a(v),v.ok&&(r(""),i(""))};return(0,m.jsxs)("details",{className:"rounded-lg border px-3 py-2",children:[(0,m.jsx)("summary",{className:"cursor-pointer text-[13px] font-semibold",children:"Settings"}),(0,m.jsxs)("div",{className:"flex flex-col gap-4 pt-3",children:[n.linearKey?(0,m.jsxs)("div",{className:"grid gap-1.5",children:[(0,m.jsx)("span",{className:"text-[13px] font-medium",children:"Linear key"}),(0,m.jsx)("p",{className:"text-[12px] text-muted-foreground",children:"Saved on this computer."}),(0,m.jsx)(te,{type:"button",size:"sm",variant:"ghost",className:"self-start text-destructive",disabled:f,onClick:()=>{d(`${e.flow.href}/linear-key`,{remove:"yes"})},children:"Remove key"})]}):(0,m.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:p=>{p.preventDefault(),d(`${e.flow.href}/linear-key`,{key:o,password:s})},children:[(0,m.jsx)(he,{label:"Linear key",hint:"From Linear → Settings → Security & access → Personal API keys. Kept on this computer only.",children:(0,m.jsx)(ve,{type:"password",autoComplete:"off",value:o,onChange:p=>r(p.target.value),placeholder:"lin_api_…"})}),(0,m.jsx)(E_,{view:e,password:s,setPassword:i}),(0,m.jsx)(te,{type:"submit",size:"sm",className:"self-start",disabled:f||o.trim()===""||!A_(e,s),children:"Save key"})]}),(0,m.jsxs)("form",{className:"flex flex-col gap-2",onSubmit:p=>{p.preventDefault(),d(`${e.flow.href}/hooks-address`,{address:l})},children:[(0,m.jsx)(he,{label:"Public webhook address",hint:"The https site your reverse proxy (Caddy, for example) serves. Have it pass only paths starting /hooks/ to this console.",children:(0,m.jsx)(ve,{value:l,onChange:p=>c(p.target.value),placeholder:"https://hooks.example.com"})}),(0,m.jsx)(te,{type:"submit",size:"sm",variant:"outline",className:"self-start",disabled:f,children:"Save address"})]})]})]})}function E_({view:e,password:t,setPassword:a}){return e.stepUp===void 0?(0,m.jsx)(he,{label:"Your Toolroll password",children:(0,m.jsx)(ve,{type:"password",autoComplete:"current-password",value:t,onChange:n=>a(n.target.value)})}):e.stepUp.fresh?(0,m.jsxs)("p",{className:"text-[13px] text-success","data-sso-step-up":"confirmed",children:["✓ Confirmed with ",e.stepUp.label]}):(0,m.jsxs)("a",{className:"text-[13px] underline","data-sso-step-up":"confirm",href:e.stepUp.confirmHref,children:["Confirm with ",e.stepUp.label]})}var A_=(e,t)=>e.stepUp===void 0?t!=="":e.stepUp.fresh;function wY({trigger:e,view:t,csrf:a,apply:n}){let[o,r]=(0,me.useState)(""),[s,i]=(0,me.useState)(""),[l,c]=(0,me.useState)(!1);return(0,m.jsxs)("form",{className:"mt-2 flex flex-col gap-2 rounded-md border border-attention/50 p-2",onSubmit:async f=>{f.preventDefault(),c(!0);let u=await ka(`${t.flow.href}/triggers/${e.id}/secret`,{secret:o,password:s},a);c(!1),n(u),u.ok&&(r(""),i(""))},children:[(0,m.jsx)(he,{label:"Linear's signing secret",hint:"Linear shows it when you create the webhook.",children:(0,m.jsx)(ve,{type:"password",autoComplete:"off",value:o,onChange:f=>r(f.target.value)})}),(0,m.jsx)(E_,{view:t,password:s,setPassword:i}),(0,m.jsx)(te,{type:"submit",size:"sm",className:"self-start",disabled:l||o.trim()===""||!A_(t,s),children:"Save secret"})]})}function SY({view:e,csrf:t,apply:a,focus:n,onPress:o,onClose:r}){let[s,i]=(0,me.useState)(null),[l,c]=(0,me.useState)(!1),f=`${e.flow.href}/triggers`,u=async(p,g)=>{c(!0);let v=await ka(p,{},t);c(!1),a(v),v.reveal!==void 0&&i({kind:g,reveal:v.reveal})},d=e.triggers.filter(p=>p.state!=="removed");return(0,me.useEffect)(()=>{n!==null&&document.querySelector(`[data-trigger-row="${n}"]`)?.scrollIntoView({block:"nearest"})},[n]),(0,m.jsxs)("div",{className:"flex flex-col gap-4","data-flow-triggers":!0,children:[(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[(0,m.jsx)("h2",{className:"flex-1 text-[15px] font-semibold",children:"Triggers"}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:r,"aria-label":"Close",children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsx)("p",{className:"text-[13px] text-muted-foreground",children:"Triggers add cards to this flow on their own. The work they start still waits for your usual approvals."}),s!==null&&(0,m.jsx)(xY,{kind:s.kind,reveal:s.reveal,onDone:()=>i(null)}),d.length>0&&(0,m.jsx)("ul",{className:"flex flex-col gap-3",children:d.map(p=>(0,m.jsxs)("li",{className:ae("rounded-lg border p-3",n===p.id&&"ring-2 ring-primary/50"),"data-trigger-row":p.id,children:[(0,m.jsxs)("div",{className:"flex items-start gap-2",children:[(0,m.jsx)("span",{className:"mt-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:g_[p.kind]??(0,m.jsx)(Es,{className:"size-3.5","aria-hidden":"true"})}),(0,m.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,m.jsx)("p",{className:"text-[13px] font-medium leading-snug",children:p.words}),(0,m.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:["Starts in ",p.zone,p.state==="paused"?" · Paused":"",p.shared?" · Shared as a form":""]}),p.status!==null&&(0,m.jsxs)("p",{className:ae("text-[12px]",p.failing?"text-warning":"text-muted-foreground"),children:[M_(p.statusAt),": ",p.status,(0,m.jsx)(w_,{link:p.statusLink})]})]})]}),p.hook?.needsSecret===!0&&!p.hook.ready&&(0,m.jsx)(wY,{trigger:p,view:e,csrf:t,apply:a}),(0,m.jsxs)("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[p.button!==null&&p.state==="active"&&(0,m.jsx)(te,{size:"sm",onClick:()=>o(p.id),children:"Start"}),p.button!==null&&(0,m.jsx)(te,{size:"sm",variant:"outline",disabled:l,onClick:()=>{u(`${f}/${p.id}/share`,"form")},children:p.shared?"New form link":"Share as a form"}),p.shared&&(0,m.jsx)(te,{size:"sm",variant:"ghost",disabled:l,onClick:()=>{u(`${f}/${p.id}/unshare`,"form")},children:"Stop sharing"}),p.checkable&&p.state==="active"&&(0,m.jsx)(te,{size:"sm",variant:"outline",disabled:l,onClick:()=>{u(`${f}/${p.id}/check`,p.kind)},children:p.kind==="schedule"?"Run now":"Check now"}),p.hook!==null&&(0,m.jsx)(te,{size:"sm",variant:"outline",disabled:l,onClick:()=>{u(`${f}/${p.id}/renew`,p.kind)},children:"New address"}),(0,m.jsx)(te,{size:"sm",variant:"ghost",disabled:l,onClick:()=>{u(`${f}/${p.id}/${p.state==="paused"?"resume":"pause"}`,p.kind)},children:p.state==="paused"?"Turn on":"Pause"}),(0,m.jsx)(te,{size:"sm",variant:"ghost",className:"text-destructive",disabled:l,onClick:()=>{u(`${f}/${p.id}/remove`,p.kind)},children:"Remove"})]})]},p.id))}),(0,m.jsx)(yY,{view:e,csrf:t,open:d.length===0,onResult:(p,g)=>{a(p),p.reveal!==void 0&&i({kind:g,reveal:p.reveal})}}),(0,m.jsx)(bY,{view:e,csrf:t,apply:a})]})}function D_({trigger:e,view:t,csrf:a,apply:n,onClose:o}){let r=e.button?.questions??[],[s,i]=(0,me.useState)(r.map(()=>"")),[l,c]=(0,me.useState)(!1),f=u=>d=>i(p=>p.map((g,v)=>v===u?d.target.value:g));return(0,m.jsxs)("form",{className:"flex flex-col gap-3","data-flow-press":e.id,onSubmit:async u=>{u.preventDefault(),c(!0);let d=await ka(`${t.flow.href}/triggers/${e.id}/press`,{answers:JSON.stringify(s)},a);c(!1),n(d),d.ok&&o()},children:[(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[(0,m.jsx)("h2",{className:"flex-1 text-[15px] font-semibold",children:e.button?.label}),(0,m.jsx)(te,{type:"button",variant:"ghost",size:"icon",onClick:o,"aria-label":"Close",children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:["The card starts in ",e.zone,"."]}),r.map((u,d)=>(0,m.jsx)(he,{label:u,children:d===0?(0,m.jsx)(ve,{value:s[d]??"",onChange:f(d),maxLength:200,required:!0,autoFocus:!0}):(0,m.jsx)(Ot,{rows:3,value:s[d]??"",onChange:f(d)})},d)),(0,m.jsxs)(te,{type:"submit",size:"sm",className:"self-start",disabled:l||(s[0]??"").trim()==="",children:[(0,m.jsx)(Yt,{className:"size-4"}),"Add card"]})]})}function CY({view:e,csrf:t,apply:a,onClose:n}){let o={name:"",about:"",body:"",timeoutMinutes:"15",language:"python",file:""},[r,s]=(0,me.useState)(e.scripts.length===0?o:null),[i,l]=(0,me.useState)(!1),c=async()=>{if(r===null)return;l(!0);let p=await ka(`${e.flow.href}/scripts`,r,t);l(!1),a(p),p.ok&&(s(null),d(!1))},f=p=>g=>s(v=>v===null?v:{...v,[p]:g.target.value}),[u,d]=(0,me.useState)(!1);return(0,m.jsxs)("div",{className:"flex flex-col gap-4","data-flow-scripts":!0,children:[(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[(0,m.jsx)("h2",{className:"flex-1 text-[15px] font-semibold",children:"Scripts"}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:n,"aria-label":"Close",children:(0,m.jsx)(Et,{className:"size-4"})})]}),(0,m.jsxs)("p",{className:"text-[13px] text-muted-foreground",children:["Reusable steps with no AI, in shell, Python or Node. A “Run a script” zone runs one with the card, and a schedule can run one to make cards. Any flow in ",e.flow.project," can use them."]}),e.scripts.length>0&&(0,m.jsx)("ul",{className:"flex flex-col gap-2",children:e.scripts.map(p=>(0,m.jsxs)("li",{className:"rounded-lg border p-3","data-script":p.name,children:[(0,m.jsxs)("div",{className:"flex items-start gap-2",children:[(0,m.jsx)("span",{className:"mt-0.5 inline-flex size-6 shrink-0 items-center justify-center rounded-md bg-muted text-muted-foreground",children:(0,m.jsx)(eo,{className:"size-3.5","aria-hidden":"true"})}),(0,m.jsxs)("div",{className:"min-w-0 flex-1",children:[(0,m.jsxs)("p",{className:"flex flex-wrap items-center gap-1.5 font-mono text-[13px] font-semibold",children:[p.name,p.held&&(0,m.jsx)(ya,{tone:"attention",children:"Needs approval"})]}),(0,m.jsx)("p",{className:"text-[12.5px]",children:p.about}),(0,m.jsxs)("p",{className:"text-[12px] text-muted-foreground",children:[N_[p.language],p.file===null?"":` · runs ${p.file}`," · version ",p.version," · ",p.savedBy," · up to ",p.timeoutMinutes," min",p.usedHere.length>0?` · runs in ${p.usedHere.join(", ")}`:" · not used in this flow"]})]})]}),p.file===null&&(0,m.jsxs)("details",{className:"mt-2",children:[(0,m.jsx)("summary",{className:"cursor-pointer text-[12px] text-muted-foreground",children:"Show the script"}),(0,m.jsx)("pre",{className:"mt-2 max-h-56 overflow-auto rounded-md bg-muted p-2 font-mono text-[12px]",children:p.body})]}),p.held&&(0,m.jsx)("p",{className:"mt-2 text-[12.5px]","data-script-held":!0,children:"It came with an imported flow, so it doesn't run until you approve it. Read it first."}),e.canEdit&&(0,m.jsxs)("div",{className:"mt-2 flex gap-1.5",children:[p.held&&(0,m.jsx)(te,{size:"sm",disabled:i,onClick:async()=>{l(!0),a(await ka(`${e.flow.href}/scripts`,{approve:"yes",name:p.name},t)),l(!1)},"data-approve-script":!0,children:"Approve"}),(0,m.jsx)(te,{size:"sm",variant:"outline",onClick:()=>{d(p.file!==null),s({name:p.name,about:p.about,body:p.body,timeoutMinutes:String(p.timeoutMinutes),language:p.language,file:p.file??""})},children:"Edit"}),(0,m.jsx)(te,{size:"sm",variant:"ghost",className:"text-destructive",disabled:i,onClick:async()=>{l(!0),a(await ka(`${e.flow.href}/scripts`,{remove:"yes",name:p.name},t)),l(!1)},children:"Remove"})]})]},p.name))}),e.canEdit&&(r===null?(0,m.jsxs)(te,{size:"sm",variant:"outline",className:"self-start",onClick:()=>{d(!1),s(o)},children:[(0,m.jsx)(Yt,{className:"size-4"}),"New script"]}):(0,m.jsxs)("form",{className:"flex flex-col gap-3 rounded-lg border p-3",onSubmit:p=>{p.preventDefault(),c()},"data-script-form":!0,children:[(0,m.jsx)(he,{label:"Name",hint:"Lowercase and dashes, like run-tests. Saving under an existing name makes a new version.",children:(0,m.jsx)(ve,{value:r.name,onChange:f("name"),maxLength:40,className:"font-mono",required:!0})}),(0,m.jsx)(he,{label:"What it checks or does",children:(0,m.jsx)(ve,{value:r.about,onChange:f("about"),maxLength:160,placeholder:"Looks the company up in our CRM",required:!0})}),(0,m.jsxs)("div",{className:"flex gap-2",children:[(0,m.jsx)(he,{label:"Language",children:(0,m.jsxs)("select",{className:ht,value:r.language,onChange:f("language"),"aria-label":"Language",children:[(0,m.jsx)("option",{value:"python",children:"Python"}),(0,m.jsx)("option",{value:"node",children:"Node"}),(0,m.jsx)("option",{value:"shell",children:"Shell"})]})}),(0,m.jsx)(he,{label:"Runs",children:(0,m.jsxs)("select",{className:ht,value:r.file===""&&!u?"here":"file",onChange:p=>{d(p.target.value==="file"),s(g=>g===null?g:{...g,file:p.target.value==="file"?g.file:""})},"aria-label":"Runs",children:[(0,m.jsx)("option",{value:"here",children:"What's written here"}),(0,m.jsx)("option",{value:"file",children:"A file in the project"})]})})]}),u||r.file!==""?(0,m.jsx)(he,{label:"File",hint:"A path from the top of the project. It gets the card as JSON on stdin (and in $FLOW_INPUT); what it prints is the step's result.",children:(0,m.jsx)(ve,{value:r.file,onChange:f("file"),maxLength:200,className:"font-mono",placeholder:"scripts/enrich.py",required:!0})}):(0,m.jsx)(he,{label:"Script",hint:"It gets the card as JSON on stdin (and in $FLOW_INPUT). What it prints is the step's result; a last line “goto: <answer>” picks the next zone. Exit 0 passes.",children:(0,m.jsx)(Ot,{value:r.body,onChange:f("body"),rows:8,className:"font-mono text-[12.5px]",placeholder:dY[r.language]??"",required:!0})}),(0,m.jsx)(he,{label:"Stop it after (minutes)",children:(0,m.jsx)(ve,{type:"number",min:1,max:60,value:r.timeoutMinutes,onChange:f("timeoutMinutes"),className:"w-28"})}),(0,m.jsxs)("div",{className:"flex gap-2",children:[(0,m.jsx)(te,{type:"submit",size:"sm",disabled:i,children:"Save script"}),(0,m.jsx)(te,{type:"button",size:"sm",variant:"ghost",onClick:()=>s(null),children:"Cancel"})]})]}))]})}var kY=e=>e===null?"—":e<1?"under a minute":e<90?`${Math.round(e)} min`:e<2880?`${Math.round(e/60)} h`:`${Math.round(e/1440)} days`;function LY({view:e,onClose:t}){let[a,n]=(0,me.useState)(30),[o,r]=(0,me.useState)(null),[s,i]=(0,me.useState)(null),[l,c]=(0,me.useState)(null);(0,me.useEffect)(()=>{let u=!0;return r(null),i(null),fetch(`${e.flow.href}/insights?days=${a}`,{credentials:"same-origin",headers:{accept:"application/json"}}).then(async d=>{if(u){if(!d.ok)throw new Error("load");r(await d.json())}}).catch(()=>{u&&i("The insights couldn't load. Try again.")}),()=>{u=!1}},[a,e.flow.href,e.flow.revision]);let f=async(u,d)=>{let p=`${u}:${d}`;if(l?.key===p){c(null);return}try{let v=await(await fetch(`${e.flow.href}/runs/${u}/${d}`,{credentials:"same-origin",headers:{accept:"application/json"}})).json();c({key:p,text:v.log===void 0||v.log===""?"This run left no output.":v.log})}catch{c({key:p,text:"The log couldn't load."})}};return(0,m.jsxs)("div",{className:"flex flex-col gap-4","data-flow-insights":!0,children:[(0,m.jsxs)("div",{className:"flex items-center gap-2",children:[(0,m.jsx)("h2",{className:"flex-1 text-[15px] font-semibold",children:"Insights"}),(0,m.jsxs)("select",{className:"h-8 rounded-md border bg-transparent px-2 text-[12px]",value:a,onChange:u=>n(Number(u.target.value)),"aria-label":"Period",children:[(0,m.jsx)("option",{value:7,children:"Last 7 days"}),(0,m.jsx)("option",{value:30,children:"Last 30 days"}),(0,m.jsx)("option",{value:90,children:"Last 90 days"})]}),(0,m.jsx)(te,{variant:"ghost",size:"icon",onClick:t,"aria-label":"Close",children:(0,m.jsx)(Et,{className:"size-4"})})]}),s!==null&&(0,m.jsx)("p",{className:"text-[13px] text-destructive",children:s}),o===null&&s===null&&(0,m.jsx)("p",{className:"text-[13px] text-muted-foreground",children:"Loading…"}),o!==null&&(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)("p",{className:"text-[13px]",children:[o.cards.started," card",o.cards.started===1?"":"s"," started, ",o.cards.finished," finished, ",o.cards.active," in progress."]}),(0,m.jsxs)("section",{className:"flex flex-col gap-2",children:[(0,m.jsx)("h3",{className:"text-[13px] font-semibold",children:"Where it breaks"}),o.breaks.length===0?(0,m.jsx)("p",{className:"text-[12.5px] text-muted-foreground",children:"Nothing failed or was sent back in this period."}):(0,m.jsx)("ul",{className:"flex flex-col gap-2",children:o.breaks.map(u=>{let d=o.zones.find(p=>p.zone===u.zone);return(0,m.jsxs)("li",{className:"rounded-lg border border-border p-2.5 text-[13px]",children:[(0,m.jsxs)("p",{children:[(0,m.jsx)("span",{className:"font-semibold",children:u.title}),": ",u.problems," of ",u.of," card",u.of===1?"":"s"," failed or were sent back"]}),d?.lastProblem&&(0,m.jsxs)("p",{className:"mt-0.5 text-[12px] text-muted-foreground",children:["Latest: ",d.lastProblem.cardTitle,d.lastProblem.note===null?"":` — ${d.lastProblem.note.split(`