@johnz4021/illuminate 0.5.12 → 0.5.13
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.
- package/README.md +1 -1
- package/dist/cli.mjs +1 -1
- package/package.json +1 -1
- package/viewer/assets/{elk.bundled-DRxy2Gqg.js → elk.bundled-DB_FYbjx.js} +2 -2
- package/viewer/assets/{elk.bundled-DRxy2Gqg.js.map → elk.bundled-DB_FYbjx.js.map} +1 -1
- package/viewer/assets/{index-BaI1s138.js → index-6Ek7tR19.js} +4 -4
- package/viewer/assets/index-6Ek7tR19.js.map +1 -0
- package/viewer/index.html +1 -1
- package/viewer/assets/index-BaI1s138.js.map +0 -1
|
@@ -58,7 +58,7 @@ Error generating stack: `+s.message+`
|
|
|
58
58
|
|
|
59
59
|
`,`
|
|
60
60
|
+`).split(`
|
|
61
|
-
`)),c=u.reduce((d,h)=>d.concat(...h),[]);return[u,c]}return[[],[]]},[e]);return T.useEffect(()=>{const l=(t==null?void 0:t.target)??Ah,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const c=f=>{var S,y;if(o.current=f.ctrlKey||f.metaKey||f.shiftKey||f.altKey,(!o.current||o.current&&!u)&&vy(f))return!1;const x=jh(f.code,a);if(s.current.add(f[x]),Mh(i,s.current,!1)){const m=((y=(S=f.composedPath)==null?void 0:S.call(f))==null?void 0:y[0])||f.target,p=(m==null?void 0:m.nodeName)==="BUTTON"||(m==null?void 0:m.nodeName)==="A";t.preventDefault!==!1&&(o.current||!p)&&f.preventDefault(),r(!0)}},d=f=>{const v=jh(f.code,a);Mh(i,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(f[v]),f.key==="Meta"&&s.current.clear(),o.current=!1},h=()=>{s.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",c),l==null||l.addEventListener("keyup",d),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{l==null||l.removeEventListener("keydown",c),l==null||l.removeEventListener("keyup",d),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,r]),n}function Mh(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function jh(e,t){return t.includes(e)?"code":"key"}const dN=()=>{const e=Ae();return T.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,s],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??s},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:s,maxZoom:i,panZoom:a}=e.getState(),l=hd(t,r,o,s,i,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(l,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:s,domNode:i}=e.getState();if(!i)return t;const{x:a,y:l}=i.getBoundingClientRect(),u={x:t.x-a,y:t.y-l},c=n.snapGrid??o,d=n.snapToGrid??s;return Os(u,r,d,c)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:s}=r.getBoundingClientRect(),i=ho(t,n);return{x:i.x+o,y:i.y+s}}}),[])};function Uy(e,t){const n=[],r=new Map,o=[];for(const s of e)if(s.type==="add"){o.push(s);continue}else if(s.type==="remove"||s.type==="replace")r.set(s.id,[s]);else{const i=r.get(s.id);i?i.push(s):r.set(s.id,[s])}for(const s of t){const i=r.get(s.id);if(!i){n.push(s);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const a={...s};for(const l of i)fN(l,a);n.push(a)}return o.length&&o.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function fN(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 hN(e,t){return Uy(e,t)}function pN(e,t){return Uy(e,t)}function or(e,t){return{id:e,type:"select",selected:t}}function Gr(e,t=new Set,n=!1){const r=[];for(const[o,s]of e){const i=t.has(o);!(s.selected===void 0&&!i)&&s.selected!==i&&(n&&(s.selected=i),r.push(or(s.id,i)))}return r}function Th({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(s=>[s.id,s]));for(const[s,i]of e.entries()){const a=t.get(i.id),l=((o=a==null?void 0:a.internals)==null?void 0:o.userNode)??a;l!==void 0&&l!==i&&n.push({id:i.id,item:i,type:"replace"}),l===void 0&&n.push({item:i,type:"add",index:s})}for(const[s]of t)r.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function $h(e){return{id:e.id,type:"remove"}}const gN=hy();function mN(e,t,n={}){return Db(e,t,{...n,onError:n.onError??gN})}const Ih=e=>Eb(e),yN=e=>ly(e);function Vy(e){return T.forwardRef(e)}const Wy=typeof window<"u"?T.useLayoutEffect:T.useEffect;function Rh(e){const[t,n]=T.useState(BigInt(0)),[r]=T.useState(()=>vN(()=>n(o=>o+BigInt(1))));return Wy(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function vN(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Gy=T.createContext(null);function wN({children:e}){const t=Ae(),n=T.useCallback(a=>{const{nodes:l=[],setNodes:u,hasDefaultNodes:c,onNodesChange:d,nodeLookup:h,fitViewQueued:f,onNodesChangeMiddlewareMap:v}=t.getState();let x=l;for(const y of a)x=typeof y=="function"?y(x):y;let S=Th({items:x,lookup:h});for(const y of v.values())S=y(S);c&&u(x),S.length>0?d==null||d(S):f&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:m,setNodes:p}=t.getState();y&&p(m)})},[]),r=Rh(n),o=T.useCallback(a=>{const{edges:l=[],setEdges:u,hasDefaultEdges:c,onEdgesChange:d,edgeLookup:h}=t.getState();let f=l;for(const v of a)f=typeof v=="function"?v(f):v;c?u(f):d&&d(Th({items:f,lookup:h}))},[]),s=Rh(o),i=T.useMemo(()=>({nodeQueue:r,edgeQueue:s}),[]);return g.jsx(Gy.Provider,{value:i,children:e})}function xN(){const e=T.useContext(Gy);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const kN=e=>!!e.panZoom;function Ds(){const e=dN(),t=Ae(),n=xN(),r=ge(kN),o=T.useMemo(()=>{const s=d=>t.getState().nodeLookup.get(d),i=d=>{n.nodeQueue.push(d)},a=d=>{n.edgeQueue.push(d)},l=d=>{var y,m;const{nodeLookup:h,nodeOrigin:f}=t.getState(),v=Ih(d)?d:h.get(d.id),x=v.parentId?gy(v.position,v.measured,v.parentId,h,f):v.position,S={...v,position:x,width:((y=v.measured)==null?void 0:y.width)??v.width,height:((m=v.measured)==null?void 0:m.height)??v.height};return Ss(S)},u=(d,h,f={replace:!1})=>{i(v=>v.map(x=>{if(x.id===d){const S=typeof h=="function"?h(x):h;return f.replace&&Ih(S)?S:{...x,...S}}return x}))},c=(d,h,f={replace:!1})=>{a(v=>v.map(x=>{if(x.id===d){const S=typeof h=="function"?h(x):h;return f.replace&&yN(S)?S:{...x,...S}}return x}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var h;return(h=s(d))==null?void 0:h.internals.userNode},getInternalNode:s,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(h=>({...h}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:i,setEdges:a,addNodes:d=>{const h=Array.isArray(d)?d:[d];n.nodeQueue.push(f=>[...f,...h])},addEdges:d=>{const h=Array.isArray(d)?d:[d];n.edgeQueue.push(f=>[...f,...h])},toObject:()=>{const{nodes:d=[],edges:h=[],transform:f}=t.getState(),[v,x,S]=f;return{nodes:d.map(y=>({...y})),edges:h.map(y=>({...y})),viewport:{x:v,y:x,zoom:S}}},deleteElements:async({nodes:d=[],edges:h=[]})=>{const{nodes:f,edges:v,onNodesDelete:x,onEdgesDelete:S,triggerNodeChanges:y,triggerEdgeChanges:m,onDelete:p,onBeforeDelete:w}=t.getState(),{nodes:b,edges:k}=await Mb({nodesToRemove:d,edgesToRemove:h,nodes:f,edges:v,onBeforeDelete:w}),E=k.length>0,_=b.length>0;if(E){const A=k.map($h);S==null||S(k),m(A)}if(_){const A=b.map($h);x==null||x(b),y(A)}return(_||E)&&(p==null||p({nodes:b,edges:k})),{deletedNodes:b,deletedEdges:k}},getIntersectingNodes:(d,h=!0,f)=>{const v=lh(d),x=v?d:l(d),S=f!==void 0;return x?(f||t.getState().nodes).filter(y=>{const m=t.getState().nodeLookup.get(y.id);if(m&&!v&&(y.id===d.id||!m.internals.positionAbsolute))return!1;const p=Ss(S?y:m),w=Sa(p,x);return h&&w>0||w>=p.width*p.height||w>=x.width*x.height}):[]},isNodeIntersecting:(d,h,f=!0)=>{const x=lh(d)?d:l(d);if(!x)return!1;const S=Sa(x,h);return f&&S>0||S>=h.width*h.height||S>=x.width*x.height},updateNode:u,updateNodeData:(d,h,f={replace:!1})=>{u(d,v=>{const x=typeof h=="function"?h(v):h;return f.replace?{...v,data:x}:{...v,data:{...v.data,...x}}},f)},updateEdge:c,updateEdgeData:(d,h,f={replace:!1})=>{c(d,v=>{const x=typeof h=="function"?h(v):h;return f.replace?{...v,data:x}:{...v,data:{...v.data,...x}}},f)},getNodesBounds:d=>{const{nodeLookup:h,nodeOrigin:f}=t.getState();return Nb(d,{nodeLookup:h,nodeOrigin:f})},getHandleConnections:({type:d,id:h,nodeId:f})=>{var v;return Array.from(((v=t.getState().connectionLookup.get(`${f}-${d}${h?`-${h}`:""}`))==null?void 0:v.values())??[])},getNodeConnections:({type:d,handleId:h,nodeId:f})=>{var v;return Array.from(((v=t.getState().connectionLookup.get(`${f}${d?h?`-${d}-${h}`:`-${d}`:""}`))==null?void 0:v.values())??[])},fitView:async d=>{const h=t.getState().fitViewResolver??$b();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:h}),n.nodeQueue.push(f=>[...f]),h.promise}}},[]);return T.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const Lh=e=>e.selected,SN=typeof window<"u"?window:void 0;function bN({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Ae(),{deleteElements:r}=Ds(),o=Es(e,{actInsideInputWithModifier:!1}),s=Es(t,{target:SN});T.useEffect(()=>{if(o){const{edges:i,nodes:a}=n.getState();r({nodes:a.filter(Lh),edges:i.filter(Lh)}),n.setState({nodesSelectionActive:!1})}},[o]),T.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])}function EN(e){const t=Ae();T.useEffect(()=>{const n=()=>{var o,s,i,a;if(!e.current||!(((s=(o=e.current).checkVisibility)==null?void 0:s.call(o))??!0))return!1;const r=pd(e.current);(r.height===0||r.width===0)&&((a=(i=t.getState()).onError)==null||a.call(i,"004",Xt.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const tl={position:"absolute",width:"100%",height:"100%",top:0,left:0},NN=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function _N({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:o,panOnScrollSpeed:s=.5,panOnScrollMode:i=hr.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:u,translateExtent:c,minZoom:d,maxZoom:h,zoomActivationKeyCode:f,preventScrolling:v=!0,children:x,noWheelClassName:S,noPanClassName:y,onViewportChange:m,isControlledViewport:p,paneClickDistance:w,selectionOnDrag:b}){const k=Ae(),E=T.useRef(null),{userSelectionActive:_,lib:A,connectionInProgress:L}=ge(NN,Le),$=Es(f),F=T.useRef();EN(E);const B=T.useCallback(N=>{m==null||m({x:N[0],y:N[1],zoom:N[2]}),p||k.setState({transform:N})},[m,p]);return T.useEffect(()=>{if(E.current){F.current=gE({domNode:E.current,minZoom:d,maxZoom:h,translateExtent:c,viewport:u,onDraggingChange:O=>k.setState(j=>j.paneDragging===O?j:{paneDragging:O}),onPanZoomStart:(O,j)=>{const{onViewportChangeStart:M,onMoveStart:I}=k.getState();I==null||I(O,j),M==null||M(j)},onPanZoom:(O,j)=>{const{onViewportChange:M,onMove:I}=k.getState();I==null||I(O,j),M==null||M(j)},onPanZoomEnd:(O,j)=>{const{onViewportChangeEnd:M,onMoveEnd:I}=k.getState();I==null||I(O,j),M==null||M(j)}});const{x:N,y:P,zoom:R}=F.current.getViewport();return k.setState({panZoom:F.current,transform:[N,P,R],domNode:E.current.closest(".react-flow")}),()=>{var O;(O=F.current)==null||O.destroy()}}},[]),T.useEffect(()=>{var N;(N=F.current)==null||N.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:o,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:$,preventScrolling:v,noPanClassName:y,userSelectionActive:_,noWheelClassName:S,lib:A,onTransformChange:B,connectionInProgress:L,selectionOnDrag:b,paneClickDistance:w})},[e,t,n,r,o,s,i,a,l,$,v,y,_,S,A,B,L,b,w]),g.jsx("div",{className:"react-flow__renderer",ref:E,style:tl,children:x})}const CN=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function AN(){const{userSelectionActive:e,userSelectionRect:t}=ge(CN,Le);return e&&t?g.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}const Hl=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},MN=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function jN({isSelecting:e,selectionKeyPressed:t,selectionMode:n=xs.Full,panOnDrag:r,autoPanOnSelection:o,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:u,onPaneContextMenu:c,onPaneScroll:d,onPaneMouseEnter:h,onPaneMouseMove:f,onPaneMouseLeave:v,children:x}){const S=T.useRef(0),y=Ae(),{userSelectionActive:m,elementsSelectable:p,dragging:w,panBy:b,autoPanSpeed:k}=ge(MN,Le),E=p&&(e||m),_=T.useRef(null),A=T.useRef(),L=T.useRef(new Set),$=T.useRef(new Set),F=T.useRef(!1),B=T.useRef(!1),N=T.useRef({x:0,y:0}),P=T.useRef(!1),R=C=>{if(B.current||F.current||y.getState().connection.inProgress){B.current=!1,F.current=!1;return}u==null||u(C),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},O=C=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){C.preventDefault();return}c==null||c(C)},j=d?C=>d(C):void 0,M=C=>{B.current&&(C.stopPropagation(),B.current=!1)},I=C=>{var de,Fe;if(C.pointerType==="touch"&&r!==!1&&!t)return;const{domNode:D,transform:Z}=y.getState();if(A.current=D==null?void 0:D.getBoundingClientRect(),!A.current)return;const Y=C.target===_.current;if(!Y&&!!C.target.closest(".nokey")||!e||!(i&&Y||t)||C.button!==0||!C.isPrimary)return;(Fe=(de=C.target)==null?void 0:de.setPointerCapture)==null||Fe.call(de,C.pointerId),B.current=!1;const{x:G,y:re}=Vt(C.nativeEvent,A.current),ae=Os({x:G,y:re},Z);y.setState({userSelectionRect:{width:0,height:0,startX:ae.x,startY:ae.y,x:G,y:re}}),Y||(C.stopPropagation(),C.preventDefault())};function z(C,D){const{userSelectionRect:Z}=y.getState();if(!Z)return;const{transform:Y,nodeLookup:X,edgeLookup:V,connectionLookup:G,triggerNodeChanges:re,triggerEdgeChanges:ae,defaultEdgeOptions:de}=y.getState(),Fe={x:Z.startX,y:Z.startY},{x:We,y:Ge}=ho(Fe,Y),rt={startX:Fe.x,startY:Fe.y,x:C<We?C:We,y:D<Ge?D:Ge,width:Math.abs(C-We),height:Math.abs(D-Ge)},fe=L.current,wt=$.current;L.current=new Set(dd(X,rt,Y,n===xs.Partial,!0).map(te=>te.id)),$.current=new Set;const W=(de==null?void 0:de.selectable)??!0;for(const te of L.current){const ce=G.get(te);if(ce)for(const{edgeId:le}of ce.values()){const pe=V.get(le);pe&&(pe.selectable??W)&&$.current.add(le)}}if(!uh(fe,L.current)){const te=Gr(X,L.current,!0);re(te)}if(!uh(wt,$.current)){const te=Gr(V,$.current);ae(te)}y.setState({userSelectionRect:rt,userSelectionActive:!0,nodesSelectionActive:!1})}function H(){if(!o||!A.current)return;const[C,D]=fd(N.current,A.current,k);b({x:C,y:D}).then(Z=>{if(!B.current||!Z){S.current=requestAnimationFrame(H);return}const{x:Y,y:X}=N.current;z(Y,X),S.current=requestAnimationFrame(H)})}const ne=()=>{cancelAnimationFrame(S.current),S.current=0,P.current=!1};T.useEffect(()=>()=>ne(),[]);const Q=C=>{const{userSelectionRect:D,transform:Z,resetSelectedElements:Y}=y.getState();if(!A.current||!D)return;const{x:X,y:V}=Vt(C.nativeEvent,A.current);N.current={x:X,y:V};const G=ho({x:D.startX,y:D.startY},Z);if(!B.current){const re=t?0:s;if(Math.hypot(X-G.x,V-G.y)<=re)return;Y(),a==null||a(C)}B.current=!0,P.current||(H(),P.current=!0),z(X,V)},U=C=>{var D,Z;if(!E){C.target===_.current&&y.getState().connection.inProgress&&(F.current=!0);return}C.button===0&&((Z=(D=C.target)==null?void 0:D.releasePointerCapture)==null||Z.call(D,C.pointerId),!m&&C.target===_.current&&y.getState().userSelectionRect&&(R==null||R(C)),y.setState({userSelectionActive:!1,userSelectionRect:null}),B.current&&(l==null||l(C),y.setState({nodesSelectionActive:L.current.size>0})),ne())},J=C=>{var D,Z;(Z=(D=C.target)==null?void 0:D.releasePointerCapture)==null||Z.call(D,C.pointerId),ne()},ee=r===!0||Array.isArray(r)&&r.includes(0);return g.jsxs("div",{className:De(["react-flow__pane",{draggable:ee,dragging:w,selection:e}]),onClick:E?void 0:Hl(R,_),onContextMenu:Hl(O,_),onWheel:Hl(j,_),onPointerEnter:E?void 0:h,onPointerMove:E?Q:f,onPointerUp:U,onPointerCancel:E?J:void 0,onPointerDownCapture:E?I:void 0,onClickCapture:E?M:void 0,onPointerLeave:v,ref:_,style:tl,children:[x,g.jsx(AN,{})]})}function Zu({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:s,multiSelectionActive:i,nodeLookup:a,onError:l}=t.getState(),u=a.get(e);if(!u){l==null||l("012",Xt.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&i)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var c;return(c=r==null?void 0:r.current)==null?void 0:c.blur()})):o([e])}function Yy({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:s,nodeClickDistance:i}){const a=Ae(),[l,u]=T.useState(!1),c=T.useRef();return T.useEffect(()=>{if(!t)return c.current=tE({getStoreItems:()=>a.getState(),onNodeMouseDown:d=>{Zu({id:d,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}}),()=>{var d;(d=c.current)==null||d.destroy(),c.current=void 0}},[t,a,e]),T.useEffect(()=>{t||!e.current||!c.current||c.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:s,nodeId:o,nodeClickDistance:i})},[n,r,t,s,e,o,i]),l}const TN=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Xy(){const e=Ae();return T.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:s,nodesDraggable:i,onError:a,updateNodePositions:l,nodeLookup:u,nodeOrigin:c}=e.getState(),d=new Map,h=TN(i),f=o?s[0]:5,v=o?s[1]:5,x=n.direction.x*f*n.factor,S=n.direction.y*v*n.factor;for(const[,y]of u){if(!h(y))continue;let m={x:y.internals.positionAbsolute.x+x,y:y.internals.positionAbsolute.y+S};o&&(m=Ps(m,s));const{position:p,positionAbsolute:w}=uy({nodeId:y.id,nextPosition:m,nodeLookup:u,nodeExtent:r,nodeOrigin:c,onError:a});y.position=p,y.internals.positionAbsolute=w,d.set(y.id,y)}l(d)},[])}const kd=T.createContext(null),$N=kd.Provider;kd.Consumer;const qy=()=>T.useContext(kd),IN=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Ky=T.createContext(null);function RN({children:e}){const t=ge(IN,Le);return g.jsx(Ky.Provider,{value:t,children:e})}function LN(){const e=T.useContext(Ky);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const PN={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},ON=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:s,connection:i}=r,{fromHandle:a,toHandle:l,isValid:u}=i;if(!a&&!o)return PN;const c=(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:c,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:s===co.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!o,valid:c&&u}};function zN({type:e="source",position:t=ie.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:s=!0,id:i,onConnect:a,children:l,className:u,onMouseDown:c,onTouchStart:d,...h},f){var P,R;const v=i||null,x=e==="target",S=Ae(),y=qy(),{connectOnClick:m,noPanClassName:p,rfId:w}=LN(),{connectingFrom:b,connectingTo:k,clickConnecting:E,isPossibleEndHandle:_,connectionInProcess:A,clickConnectionInProcess:L,valid:$}=ge(ON(y,v,e),Le);y||(R=(P=S.getState()).onError)==null||R.call(P,"010",Xt.error010());const F=O=>{const{defaultEdgeOptions:j,onConnect:M,hasDefaultEdges:I}=S.getState(),z={...j,...O};if(I){const{edges:H,setEdges:ne,onError:Q}=S.getState();ne(mN(z,H,{onError:Q}))}M==null||M(z),a==null||a(z)},B=O=>{if(!y)return;const j=wy(O.nativeEvent);if(o&&(j&&O.button===0||!j)){const M=S.getState();Ku.onPointerDown(O.nativeEvent,{handleDomNode:O.currentTarget,autoPanOnConnect:M.autoPanOnConnect,connectionMode:M.connectionMode,connectionRadius:M.connectionRadius,domNode:M.domNode,nodeLookup:M.nodeLookup,lib:M.lib,isTarget:x,handleId:v,nodeId:y,flowId:M.rfId,panBy:M.panBy,cancelConnection:M.cancelConnection,onConnectStart:M.onConnectStart,onConnectEnd:(...I)=>{var z,H;return(H=(z=S.getState()).onConnectEnd)==null?void 0:H.call(z,...I)},updateConnection:M.updateConnection,onConnect:F,isValidConnection:n||((...I)=>{var z,H;return((H=(z=S.getState()).isValidConnection)==null?void 0:H.call(z,...I))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:M.autoPanSpeed,dragThreshold:M.connectionDragThreshold})}j?c==null||c(O):d==null||d(O)},N=O=>{const{onClickConnectStart:j,onClickConnectEnd:M,connectionClickStartHandle:I,connectionMode:z,isValidConnection:H,lib:ne,rfId:Q,nodeLookup:U,connection:J}=S.getState();if(!y||!I&&!o)return;if(!I){j==null||j(O.nativeEvent,{nodeId:y,handleId:v,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:y,type:e,id:v}});return}const ee=yy(O.target),C=n||H,{connection:D,isValid:Z}=Ku.isValid(O.nativeEvent,{handle:{nodeId:y,id:v,type:e},connectionMode:z,fromNodeId:I.nodeId,fromHandleId:I.id||null,fromType:I.type,isValidConnection:C,flowId:Q,doc:ee,lib:ne,nodeLookup:U});Z&&D&&F(D);const Y=structuredClone(J);delete Y.inProgress,Y.toPosition=Y.toHandle?Y.toHandle.position:null,M==null||M(O,Y),S.setState({connectionClickStartHandle:null})};return g.jsx("div",{"data-handleid":v,"data-nodeid":y,"data-handlepos":t,"data-id":`${w}-${y}-${v}-${e}`,className:De(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,u,{source:!x,target:x,connectable:r,connectablestart:o,connectableend:s,clickconnecting:E,connectingfrom:b,connectingto:k,valid:$,connectionindicator:r&&(!A||_)&&(A||L?s:o)}]),onMouseDown:B,onTouchStart:B,onClick:m?N:void 0,ref:f,...h,children:l})}const mo=T.memo(Vy(zN));function DN({data:e,isConnectable:t,sourcePosition:n=ie.Bottom}){return g.jsxs(g.Fragment,{children:[e==null?void 0:e.label,g.jsx(mo,{type:"source",position:n,isConnectable:t})]})}function FN({data:e,isConnectable:t,targetPosition:n=ie.Top,sourcePosition:r=ie.Bottom}){return g.jsxs(g.Fragment,{children:[g.jsx(mo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,g.jsx(mo,{type:"source",position:r,isConnectable:t})]})}function BN(){return null}function HN({data:e,isConnectable:t,targetPosition:n=ie.Top}){return g.jsxs(g.Fragment,{children:[g.jsx(mo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Ea={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ph={input:DN,default:FN,output:HN,group:BN};function UN(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const VN=e=>{const{width:t,height:n,x:r,y:o}=Ls(e.nodeLookup,{filter:s=>!!s.selected});return{width:Ut(t)?t:null,height:Ut(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function WN({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Ae(),{width:o,height:s,transformString:i,userSelectionActive:a}=ge(VN,Le),l=Xy(),u=T.useRef(null);T.useEffect(()=>{var f;n||(f=u.current)==null||f.focus({preventScroll:!0})},[n]);const c=!a&&o!==null&&s!==null;if(Yy({nodeRef:u,disabled:!c}),!c)return null;const d=e?f=>{const v=r.getState().nodes.filter(x=>x.selected);e(f,v)}:void 0,h=f=>{Object.prototype.hasOwnProperty.call(Ea,f.key)&&(f.preventDefault(),l({direction:Ea[f.key],factor:f.shiftKey?4:1}))};return g.jsx("div",{className:De(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:g.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:o,height:s}})})}const Oh=typeof window<"u"?window:void 0,GN=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Zy({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,paneClickDistance:a,deleteKeyCode:l,selectionKeyCode:u,selectionOnDrag:c,selectionMode:d,onSelectionStart:h,onSelectionEnd:f,multiSelectionKeyCode:v,panActivationKeyCode:x,zoomActivationKeyCode:S,elementsSelectable:y,zoomOnScroll:m,zoomOnPinch:p,panOnScroll:w,panOnScrollSpeed:b,panOnScrollMode:k,zoomOnDoubleClick:E,panOnDrag:_,autoPanOnSelection:A,defaultViewport:L,translateExtent:$,minZoom:F,maxZoom:B,preventScrolling:N,onSelectionContextMenu:P,noWheelClassName:R,noPanClassName:O,disableKeyboardA11y:j,onViewportChange:M,isControlledViewport:I}){const{nodesSelectionActive:z,userSelectionActive:H}=ge(GN,Le),ne=Es(u,{target:Oh}),Q=Es(x,{target:Oh}),U=Q||_,J=Q||w,ee=c&&U!==!0,C=ne||H||ee;return bN({deleteKeyCode:l,multiSelectionKeyCode:v}),g.jsx(_N,{onPaneContextMenu:s,elementsSelectable:y,zoomOnScroll:m,zoomOnPinch:p,panOnScroll:J,panActivationKeyPressed:Q,panOnScrollSpeed:b,panOnScrollMode:k,zoomOnDoubleClick:E,panOnDrag:!ne&&U,defaultViewport:L,translateExtent:$,minZoom:F,maxZoom:B,zoomActivationKeyCode:S,preventScrolling:N,noWheelClassName:R,noPanClassName:O,onViewportChange:M,isControlledViewport:I,paneClickDistance:a,selectionOnDrag:ee,children:g.jsxs(jN,{onSelectionStart:h,onSelectionEnd:f,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:U,autoPanOnSelection:A,isSelecting:!!C,selectionMode:d,selectionKeyPressed:ne,paneClickDistance:a,selectionOnDrag:ee,children:[e,z&&g.jsx(WN,{onSelectionContextMenu:P,noPanClassName:O,disableKeyboardA11y:j})]})})}Zy.displayName="FlowRenderer";const YN=T.memo(Zy),XN=e=>t=>e?dd(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function qN(e){return ge(T.useCallback(XN(e),[e]),Le)}const KN=e=>e.updateNodeInternals;function ZN(){const e=ge(KN),[t]=T.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const s=o.target.getAttribute("data-id");r.set(s,{id:s,nodeElement:o.target,force:!0})}),e(r)}));return T.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function QN({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=Ae(),s=T.useRef(null),i=T.useRef(null),a=T.useRef(e.sourcePosition),l=T.useRef(e.targetPosition),u=T.useRef(t),c=n&&!!e.internals.handleBounds;return T.useEffect(()=>{s.current&&!e.hidden&&(!c||i.current!==s.current)&&(i.current&&(r==null||r.unobserve(i.current)),r==null||r.observe(s.current),i.current=s.current)},[c,e.hidden]),T.useEffect(()=>()=>{i.current&&(r==null||r.unobserve(i.current),i.current=null)},[]),T.useEffect(()=>{if(s.current){const d=u.current!==t,h=a.current!==e.sourcePosition,f=l.current!==e.targetPosition;(d||h||f)&&(u.current=t,a.current=e.sourcePosition,l.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function JN({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:s,onDoubleClick:i,nodesDraggable:a,elementsSelectable:l,nodesConnectable:u,nodesFocusable:c,resizeObserver:d,noDragClassName:h,noPanClassName:f,disableKeyboardA11y:v,rfId:x,nodeTypes:S,nodeClickDistance:y,onError:m}){const{node:p,internals:w,isParent:b}=ge(C=>{const D=C.nodeLookup.get(e),Z=C.parentLookup.has(e);return{node:D,internals:D.internals,isParent:Z}},Le);let k=p.type||"default",E=(S==null?void 0:S[k])||Ph[k];E===void 0&&(m==null||m("003",Xt.error003(k)),k="default",E=(S==null?void 0:S.default)||Ph.default);const _=!!(p.draggable||a&&typeof p.draggable>"u"),A=!!(p.selectable||l&&typeof p.selectable>"u"),L=!!(p.connectable||u&&typeof p.connectable>"u"),$=!!(p.focusable||c&&typeof p.focusable>"u"),F=Ae(),B=py(p),N=QN({node:p,nodeType:k,hasDimensions:B,resizeObserver:d}),P=Yy({nodeRef:N,disabled:p.hidden||!_,noDragClassName:h,handleSelector:p.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:y}),R=Xy();if(p.hidden)return null;const O=Kt(p),j=UN(p),M=A||_||t||n||r||o,I=n?C=>n(C,{...w.userNode}):void 0,z=r?C=>r(C,{...w.userNode}):void 0,H=o?C=>o(C,{...w.userNode}):void 0,ne=s?C=>s(C,{...w.userNode}):void 0,Q=i?C=>i(C,{...w.userNode}):void 0,U=C=>{const{selectNodesOnDrag:D,nodeDragThreshold:Z}=F.getState();A&&(!D||!_||Z>0)&&Zu({id:e,store:F,nodeRef:N}),t&&t(C,{...w.userNode})},J=C=>{if(!(vy(C.nativeEvent)||v)){if(sy.includes(C.key)&&A){const D=C.key==="Escape";Zu({id:e,store:F,unselect:D,nodeRef:N})}else if(_&&p.selected&&Object.prototype.hasOwnProperty.call(Ea,C.key)){C.preventDefault();const{ariaLabelConfig:D}=F.getState();F.setState({ariaLiveMessage:D["node.a11yDescription.ariaLiveMessage"]({direction:C.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),R({direction:Ea[C.key],factor:C.shiftKey?4:1})}}},ee=()=>{var G;if(v||!((G=N.current)!=null&&G.matches(":focus-visible")))return;const{transform:C,width:D,height:Z,autoPanOnNodeFocus:Y,setCenter:X}=F.getState();if(!Y)return;dd(new Map([[e,p]]),{x:0,y:0,width:D,height:Z},C,!0).length>0||X(p.position.x+O.width/2,p.position.y+O.height/2,{zoom:C[2]})};return g.jsx("div",{className:De(["react-flow__node",`react-flow__node-${k}`,{[f]:_},p.className,{selected:p.selected,selectable:A,parent:b,draggable:_,dragging:P}]),ref:N,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:M?"all":"none",visibility:B?"visible":"hidden",...p.style,...j},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:z,onMouseLeave:H,onContextMenu:ne,onClick:U,onDoubleClick:Q,onKeyDown:$?J:void 0,tabIndex:$?0:void 0,onFocus:$?ee:void 0,role:p.ariaRole??($?"group":void 0),"aria-roledescription":"node","aria-describedby":v?void 0:`${Fy}-${x}`,"aria-label":p.ariaLabel,...p.domAttributes,children:g.jsx($N,{value:e,children:g.jsx(E,{id:e,data:p.data,type:k,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:p.selected??!1,selectable:A,draggable:_,deletable:p.deletable??!0,isConnectable:L,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:P,dragHandle:p.dragHandle,zIndex:w.z,parentId:p.parentId,...O})})})}var e_=T.memo(JN);const t_=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Qy(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:o}=ge(t_,Le),s=qN(e.onlyRenderVisibleElements),i=ZN();return g.jsx("div",{className:"react-flow__nodes",style:tl,children:s.map(a=>g.jsx(e_,{id:a,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:i,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:o},a))})}Qy.displayName="NodeRenderer";const n_=T.memo(Qy);function r_(e){return ge(T.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const s=n.nodeLookup.get(o.source),i=n.nodeLookup.get(o.target);s&&i&&Pb({sourceNode:s,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),Le)}const o_=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return g.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},s_=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return g.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},zh={[ks.Arrow]:o_,[ks.ArrowClosed]:s_};function i_(e){const t=Ae();return T.useMemo(()=>{var o,s;return Object.prototype.hasOwnProperty.call(zh,e)?zh[e]:((s=(o=t.getState()).onError)==null||s.call(o,"009",Xt.error009(e)),null)},[e])}const a_=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{const l=i_(t);return l?g.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:a,refX:"0",refY:"0",children:g.jsx(l,{color:n,strokeWidth:i})}):null},Jy=({defaultColor:e,rfId:t})=>{const n=ge(s=>s.edges),r=ge(s=>s.defaultEdgeOptions),o=T.useMemo(()=>Vb(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?g.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:g.jsx("defs",{children:o.map(s=>g.jsx(a_,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};Jy.displayName="MarkerDefinitions";var l_=T.memo(Jy);function e0({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:s,labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:l,className:u,...c}){const[d,h]=T.useState({x:1,y:0,width:0,height:0}),f=De(["react-flow__edge-textwrapper",u]),v=T.useRef(null);return T.useEffect(()=>{if(v.current){const x=v.current.getBBox();h({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),n?g.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:f,visibility:d.width?"visible":"hidden",...c,children:[o&&g.jsx("rect",{width:d.width+2*i[0],x:-i[0],y:-i[1],height:d.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:a,ry:a}),g.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:v,style:r,children:n}),l]}):null}e0.displayName="EdgeText";const u_=T.memo(e0);function Fs({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:s,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:l,interactionWidth:u=20,...c}){return g.jsxs(g.Fragment,{children:[g.jsx("path",{...c,d:e,fill:"none",className:De(["react-flow__edge-path",c.className])}),u?g.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&Ut(t)&&Ut(n)?g.jsx(u_,{x:t,y:n,label:r,labelStyle:o,labelShowBg:s,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:l}):null]})}function Dh({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===ie.Left||e===ie.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function t0({sourceX:e,sourceY:t,sourcePosition:n=ie.Bottom,targetX:r,targetY:o,targetPosition:s=ie.Top}){const[i,a]=Dh({pos:n,x1:e,y1:t,x2:r,y2:o}),[l,u]=Dh({pos:s,x1:r,y1:o,x2:e,y2:t}),[c,d,h,f]=xy({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:i,sourceControlY:a,targetControlX:l,targetControlY:u});return[`M${e},${t} C${i},${a} ${l},${u} ${r},${o}`,c,d,h,f]}function n0(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,sourcePosition:i,targetPosition:a,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:v,markerEnd:x,markerStart:S,interactionWidth:y})=>{const[m,p,w]=t0({sourceX:n,sourceY:r,sourcePosition:i,targetX:o,targetY:s,targetPosition:a}),b=e.isInternal?void 0:t;return g.jsx(Fs,{id:b,path:m,labelX:p,labelY:w,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:v,markerEnd:x,markerStart:S,interactionWidth:y})})}const c_=n0({isInternal:!1}),r0=n0({isInternal:!0});c_.displayName="SimpleBezierEdge";r0.displayName="SimpleBezierEdgeInternal";function o0(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,sourcePosition:f=ie.Bottom,targetPosition:v=ie.Top,markerEnd:x,markerStart:S,pathOptions:y,interactionWidth:m})=>{const[p,w,b]=ba({sourceX:n,sourceY:r,sourcePosition:f,targetX:o,targetY:s,targetPosition:v,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),k=e.isInternal?void 0:t;return g.jsx(Fs,{id:k,path:p,labelX:w,labelY:b,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:x,markerStart:S,interactionWidth:m})})}const s0=o0({isInternal:!1}),i0=o0({isInternal:!0});s0.displayName="SmoothStepEdge";i0.displayName="SmoothStepEdgeInternal";function a0(e){return T.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return g.jsx(s0,{...n,id:r,pathOptions:T.useMemo(()=>{var s;return{borderRadius:0,offset:(s=n.pathOptions)==null?void 0:s.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const d_=a0({isInternal:!1}),l0=a0({isInternal:!0});d_.displayName="StepEdge";l0.displayName="StepEdgeInternal";function u0(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:v,interactionWidth:x})=>{const[S,y,m]=Sy({sourceX:n,sourceY:r,targetX:o,targetY:s}),p=e.isInternal?void 0:t;return g.jsx(Fs,{id:p,path:S,labelX:y,labelY:m,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:v,interactionWidth:x})})}const f_=u0({isInternal:!1}),c0=u0({isInternal:!0});f_.displayName="StraightEdge";c0.displayName="StraightEdgeInternal";function d0(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,sourcePosition:i=ie.Bottom,targetPosition:a=ie.Top,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:v,markerEnd:x,markerStart:S,pathOptions:y,interactionWidth:m})=>{const[p,w,b]=gd({sourceX:n,sourceY:r,sourcePosition:i,targetX:o,targetY:s,targetPosition:a,curvature:y==null?void 0:y.curvature}),k=e.isInternal?void 0:t;return g.jsx(Fs,{id:k,path:p,labelX:w,labelY:b,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:v,markerEnd:x,markerStart:S,interactionWidth:m})})}const h_=d0({isInternal:!1}),f0=d0({isInternal:!0});h_.displayName="BezierEdge";f0.displayName="BezierEdgeInternal";const Fh={default:f0,straight:c0,step:l0,smoothstep:i0,simplebezier:r0},Bh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},p_=(e,t,n)=>n===ie.Left?e-t:n===ie.Right?e+t:e,g_=(e,t,n)=>n===ie.Top?e-t:n===ie.Bottom?e+t:e,Hh="react-flow__edgeupdater";function Uh({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:s,onMouseOut:i,type:a}){return g.jsx("circle",{onMouseDown:o,onMouseEnter:s,onMouseOut:i,className:De([Hh,`${Hh}-${a}`]),cx:p_(t,r,e),cy:g_(n,r,e),r,stroke:"transparent",fill:"transparent"})}function m_({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,onReconnect:u,onReconnectStart:c,onReconnectEnd:d,setReconnecting:h,setUpdateHover:f}){const v=Ae(),x=(w,b)=>{if(w.button!==0)return;const{autoPanOnConnect:k,domNode:E,connectionMode:_,connectionRadius:A,lib:L,onConnectStart:$,cancelConnection:F,nodeLookup:B,rfId:N,panBy:P,updateConnection:R}=v.getState(),O=b.type==="target",j=(z,H)=>{h(!1),d==null||d(z,n,b.type,H)},M=z=>u==null?void 0:u(n,z),I=(z,H)=>{h(!0),c==null||c(w,n,b.type),$==null||$(z,H)};Ku.onPointerDown(w.nativeEvent,{autoPanOnConnect:k,connectionMode:_,connectionRadius:A,domNode:E,handleId:b.id,nodeId:b.nodeId,nodeLookup:B,isTarget:O,edgeUpdaterType:b.type,lib:L,flowId:N,cancelConnection:F,panBy:P,isValidConnection:(...z)=>{var H,ne;return((ne=(H=v.getState()).isValidConnection)==null?void 0:ne.call(H,...z))??!0},onConnect:M,onConnectStart:I,onConnectEnd:(...z)=>{var H,ne;return(ne=(H=v.getState()).onConnectEnd)==null?void 0:ne.call(H,...z)},onReconnectEnd:j,updateConnection:R,getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,dragThreshold:v.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},S=w=>x(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=w=>x(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),m=()=>f(!0),p=()=>f(!1);return g.jsxs(g.Fragment,{children:[(e===!0||e==="source")&&g.jsx(Uh,{position:a,centerX:r,centerY:o,radius:t,onMouseDown:S,onMouseEnter:m,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&g.jsx(Uh,{position:l,centerX:s,centerY:i,radius:t,onMouseDown:y,onMouseEnter:m,onMouseOut:p,type:"target"})]})}function y_({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:s,onContextMenu:i,onMouseEnter:a,onMouseMove:l,onMouseLeave:u,reconnectRadius:c,onReconnect:d,onReconnectStart:h,onReconnectEnd:f,rfId:v,edgeTypes:x,noPanClassName:S,onError:y,disableKeyboardA11y:m}){let p=ge(X=>X.edgeLookup.get(e));const w=ge(X=>X.defaultEdgeOptions);p=w?{...w,...p}:p;let b=p.type||"default",k=(x==null?void 0:x[b])||Fh[b];k===void 0&&(y==null||y("011",Xt.error011(b)),b="default",k=(x==null?void 0:x.default)||Fh.default);const E=!!(p.focusable||t&&typeof p.focusable>"u"),_=typeof d<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),A=!!(p.selectable||r&&typeof p.selectable>"u"),L=T.useRef(null),[$,F]=T.useState(!1),[B,N]=T.useState(!1),P=Ae(),{zIndex:R=p.zIndex,sourceX:O,sourceY:j,targetX:M,targetY:I,sourcePosition:z,targetPosition:H}=ge(T.useCallback(X=>{const V=X.nodeLookup.get(p.source),G=X.nodeLookup.get(p.target);if(!V||!G)return Bh;const re=Ub({id:e,sourceNode:V,targetNode:G,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:X.connectionMode,onError:y}),ae=Lb({selected:p.selected,zIndex:p.zIndex,sourceNode:V,targetNode:G,elevateOnSelect:X.elevateEdgesOnSelect,zIndexMode:X.zIndexMode});return{...re||Bh,zIndex:ae}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex,y]),Le),ne=T.useMemo(()=>p.markerStart?`url('#${Xu(p.markerStart,v)}')`:void 0,[p.markerStart,v]),Q=T.useMemo(()=>p.markerEnd?`url('#${Xu(p.markerEnd,v)}')`:void 0,[p.markerEnd,v]);if(p.hidden||O===null||j===null||M===null||I===null)return null;const U=X=>{var ae;const{addSelectedEdges:V,unselectNodesAndEdges:G,multiSelectionActive:re}=P.getState();A&&(P.setState({nodesSelectionActive:!1}),p.selected&&re?(G({nodes:[],edges:[p]}),(ae=L.current)==null||ae.blur()):V([e])),o&&o(X,p)},J=s?X=>{s(X,{...p})}:void 0,ee=i?X=>{i(X,{...p})}:void 0,C=a?X=>{a(X,{...p})}:void 0,D=l?X=>{l(X,{...p})}:void 0,Z=u?X=>{u(X,{...p})}:void 0,Y=X=>{var V;if(!m&&sy.includes(X.key)&&A){const{unselectNodesAndEdges:G,addSelectedEdges:re}=P.getState();X.key==="Escape"?((V=L.current)==null||V.blur(),G({edges:[p]})):re([e])}};return g.jsx("svg",{style:{zIndex:R},children:g.jsxs("g",{className:De(["react-flow__edge",`react-flow__edge-${b}`,p.className,S,{selected:p.selected,animated:p.animated,inactive:!A&&!o,updating:$,selectable:A}]),onClick:U,onDoubleClick:J,onContextMenu:ee,onMouseEnter:C,onMouseMove:D,onMouseLeave:Z,onKeyDown:E?Y:void 0,tabIndex:E?0:void 0,role:p.ariaRole??(E?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":E?`${By}-${v}`:void 0,ref:L,...p.domAttributes,children:[!B&&g.jsx(k,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:A,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:O,sourceY:j,targetX:M,targetY:I,sourcePosition:z,targetPosition:H,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:ne,markerEnd:Q,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),_&&g.jsx(m_,{edge:p,isReconnectable:_,reconnectRadius:c,onReconnect:d,onReconnectStart:h,onReconnectEnd:f,sourceX:O,sourceY:j,targetX:M,targetY:I,sourcePosition:z,targetPosition:H,setUpdateHover:F,setReconnecting:N})]})})}var v_=T.memo(y_);const w_=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function h0({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:s,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:u,onEdgeClick:c,reconnectRadius:d,onEdgeDoubleClick:h,onReconnectStart:f,onReconnectEnd:v,disableKeyboardA11y:x}){const{edgesFocusable:S,edgesReconnectable:y,elementsSelectable:m,onError:p}=ge(w_,Le),w=r_(t);return g.jsxs("div",{className:"react-flow__edges",children:[g.jsx(l_,{defaultColor:e,rfId:n}),w.map(b=>g.jsx(v_,{id:b,edgesFocusable:S,edgesReconnectable:y,elementsSelectable:m,noPanClassName:o,onReconnect:s,onContextMenu:i,onMouseEnter:a,onMouseMove:l,onMouseLeave:u,onClick:c,reconnectRadius:d,onDoubleClick:h,onReconnectStart:f,onReconnectEnd:v,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:x},b))]})}h0.displayName="EdgeRenderer";const x_=T.memo(h0),Vh=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function k_({children:e}){const t=Ae(),n=T.useRef(null),[r]=T.useState(()=>t.getState().transform);return Wy(()=>{let o=null;const s=()=>{const i=t.getState().transform;o&&i[0]===o[0]&&i[1]===o[1]&&i[2]===o[2]||(o=i,n.current&&(n.current.style.transform=Vh(i)))};return s(),t.subscribe(s)},[t]),g.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Vh(r)},children:e})}function S_(e){const t=Ds(),n=T.useRef(!1);T.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const b_=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function E_(e){const t=ge(b_),n=Ae();return T.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function N_(e){return e.connection.inProgress?{...e.connection,to:Os(e.connection.to,e.transform)}:{...e.connection}}function __(e){return N_}function C_(e){const t=__();return ge(t,Le)}const A_=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function M_({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:s,height:i,isValid:a,inProgress:l}=ge(A_,Le);return!(s&&o&&l)?null:g.jsx("svg",{style:e,width:s,height:i,className:"react-flow__connectionline react-flow__container",children:g.jsx("g",{className:De(["react-flow__connection",my(a)]),children:g.jsx(p0,{style:t,type:n,CustomComponent:r,isValid:a})})})}const p0=({style:e,type:t=On.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:s,fromNode:i,fromHandle:a,fromPosition:l,to:u,toNode:c,toHandle:d,toPosition:h,pointer:f}=C_();if(!o)return;if(n)return g.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:a,fromX:s.x,fromY:s.y,toX:u.x,toY:u.y,fromPosition:l,toPosition:h,connectionStatus:my(r),toNode:c,toHandle:d,pointer:f});let v="";const x={sourceX:s.x,sourceY:s.y,sourcePosition:l,targetX:u.x,targetY:u.y,targetPosition:h};switch(t){case On.Bezier:[v]=gd(x);break;case On.SimpleBezier:[v]=t0(x);break;case On.Step:[v]=ba({...x,borderRadius:0});break;case On.SmoothStep:[v]=ba(x);break;default:[v]=Sy(x)}return g.jsx("path",{d:v,fill:"none",className:"react-flow__connection-path",style:e})};p0.displayName="ConnectionLine";const j_={};function Wh(e=j_){T.useRef(e),Ae(),T.useEffect(()=>{},[e])}function T_(){Ae(),T.useRef(!1),T.useEffect(()=>{},[])}function g0({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:s,onEdgeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:u,onNodeContextMenu:c,onSelectionContextMenu:d,onSelectionStart:h,onSelectionEnd:f,connectionLineType:v,connectionLineStyle:x,connectionLineComponent:S,connectionLineContainerStyle:y,selectionKeyCode:m,selectionOnDrag:p,selectionMode:w,multiSelectionKeyCode:b,panActivationKeyCode:k,zoomActivationKeyCode:E,deleteKeyCode:_,onlyRenderVisibleElements:A,elementsSelectable:L,defaultViewport:$,translateExtent:F,minZoom:B,maxZoom:N,preventScrolling:P,defaultMarkerColor:R,zoomOnScroll:O,zoomOnPinch:j,panOnScroll:M,panOnScrollSpeed:I,panOnScrollMode:z,zoomOnDoubleClick:H,panOnDrag:ne,autoPanOnSelection:Q,onPaneClick:U,onPaneMouseEnter:J,onPaneMouseMove:ee,onPaneMouseLeave:C,onPaneScroll:D,onPaneContextMenu:Z,paneClickDistance:Y,nodeClickDistance:X,onEdgeContextMenu:V,onEdgeMouseEnter:G,onEdgeMouseMove:re,onEdgeMouseLeave:ae,reconnectRadius:de,onReconnect:Fe,onReconnectStart:We,onReconnectEnd:Ge,noDragClassName:rt,noWheelClassName:fe,noPanClassName:wt,disableKeyboardA11y:W,nodeExtent:te,rfId:ce,viewport:le,onViewportChange:pe,nodesDraggable:oe}){return Wh(e),Wh(t),T_(),S_(n),E_(le),g.jsx(YN,{onPaneClick:U,onPaneMouseEnter:J,onPaneMouseMove:ee,onPaneMouseLeave:C,onPaneContextMenu:Z,onPaneScroll:D,paneClickDistance:Y,deleteKeyCode:_,selectionKeyCode:m,selectionOnDrag:p,selectionMode:w,onSelectionStart:h,onSelectionEnd:f,multiSelectionKeyCode:b,panActivationKeyCode:k,zoomActivationKeyCode:E,elementsSelectable:L,zoomOnScroll:O,zoomOnPinch:j,zoomOnDoubleClick:H,panOnScroll:M,panOnScrollSpeed:I,panOnScrollMode:z,panOnDrag:ne,autoPanOnSelection:Q,defaultViewport:$,translateExtent:F,minZoom:B,maxZoom:N,onSelectionContextMenu:d,preventScrolling:P,noDragClassName:rt,noWheelClassName:fe,noPanClassName:wt,disableKeyboardA11y:W,onViewportChange:pe,isControlledViewport:!!le,children:g.jsxs(k_,{children:[g.jsx(x_,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:i,onReconnect:Fe,onReconnectStart:We,onReconnectEnd:Ge,onlyRenderVisibleElements:A,onEdgeContextMenu:V,onEdgeMouseEnter:G,onEdgeMouseMove:re,onEdgeMouseLeave:ae,reconnectRadius:de,defaultMarkerColor:R,noPanClassName:wt,disableKeyboardA11y:W,rfId:ce}),g.jsx(M_,{style:x,type:v,component:S,containerStyle:y}),g.jsx("div",{className:"react-flow__edgelabel-renderer"}),g.jsx(n_,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:u,onNodeContextMenu:c,nodeClickDistance:X,onlyRenderVisibleElements:A,noPanClassName:wt,noDragClassName:rt,disableKeyboardA11y:W,nodeExtent:te,rfId:ce,nodesDraggable:oe}),g.jsx("div",{className:"react-flow__viewport-portal"})]})})}g0.displayName="GraphView";const $_=T.memo(g0),I_=hy(),Gh=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:l=.5,maxZoom:u=2,nodeOrigin:c,nodeExtent:d,zIndexMode:h="basic"}={})=>{const f=new Map,v=new Map,x=new Map,S=new Map,y=r??t??[],m=n??e??[],p=c??[0,0],w=d??ws;Ny(x,S,y);const{nodesInitialized:b}=qu(m,f,v,{nodeOrigin:p,nodeExtent:w,zIndexMode:h});let k=[0,0,1];if(i&&o&&s){const E=Ls(f,{filter:$=>!!(($.width||$.initialWidth)&&($.height||$.initialHeight))}),{x:_,y:A,zoom:L}=hd(E,o,s,l,u,(a==null?void 0:a.padding)??.1);k=[_,A,L]}return{rfId:"1",width:o??0,height:s??0,transform:k,nodes:m,nodesInitialized:b,nodeLookup:f,parentLookup:v,edges:y,edgeLookup:S,connectionLookup:x,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:l,maxZoom:u,translateExtent:ws,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:co.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,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:i??!1,fitViewOptions:a,fitViewResolver:null,connection:{...ay},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:I_,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:iy,zIndexMode:h,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}},R_=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:l,maxZoom:u,nodeOrigin:c,nodeExtent:d,zIndexMode:h})=>GE((f,v)=>{async function x(){const{nodeLookup:S,panZoom:y,fitViewOptions:m,fitViewResolver:p,width:w,height:b,minZoom:k,maxZoom:E}=v();y&&(await Ab({nodes:S,width:w,height:b,panZoom:y,minZoom:k,maxZoom:E},m),p==null||p.resolve(!0),f({fitViewResolver:null}))}return{...Gh({nodes:e,edges:t,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:l,maxZoom:u,nodeOrigin:c,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:h}),setNodes:S=>{const{nodeLookup:y,parentLookup:m,nodeOrigin:p,nodeExtent:w,elevateNodesOnSelect:b,fitViewQueued:k,zIndexMode:E,nodesSelectionActive:_}=v(),{nodesInitialized:A,hasSelectedNodes:L}=qu(S,y,m,{nodeOrigin:p,nodeExtent:w,elevateNodesOnSelect:b,checkEquality:!0,zIndexMode:E}),$=_&&L;k&&A?(x(),f({nodes:S,nodesInitialized:A,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:$})):f({nodes:S,nodesInitialized:A,nodesSelectionActive:$})},setEdges:S=>{const{connectionLookup:y,edgeLookup:m}=v();Ny(y,m,S),f({edges:S})},setDefaultNodesAndEdges:(S,y)=>{if(S){const{setNodes:m}=v();m(S),f({hasDefaultNodes:!0})}if(y){const{setEdges:m}=v();m(y),f({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:y,nodeLookup:m,parentLookup:p,domNode:w,nodeOrigin:b,nodeExtent:k,debug:E,fitViewQueued:_,zIndexMode:A}=v(),{changes:L,updatedInternals:$}=Zb(S,m,p,w,b,k,A);$&&(Yb(m,p,{nodeOrigin:b,nodeExtent:k,zIndexMode:A}),_?(x(),f({fitViewQueued:!1,fitViewOptions:void 0})):f({}),(L==null?void 0:L.length)>0&&(E&&console.log("React Flow: trigger node changes",L),y==null||y(L)))},updateNodePositions:(S,y=!1)=>{const m=[];let p=[];const{nodeLookup:w,triggerNodeChanges:b,connection:k,updateConnection:E,onNodesChangeMiddlewareMap:_}=v();for(const[A,L]of S){const $=w.get(A),F=!!($!=null&&$.expandParent&&($!=null&&$.parentId)&&(L!=null&&L.position)),B={id:A,type:"position",position:F?{x:Math.max(0,L.position.x),y:Math.max(0,L.position.y)}:L.position,dragging:y};if($&&k.inProgress&&k.fromNode.id===$.id){const N=Cr($,k.fromHandle,ie.Left,!0);E({...k,from:N})}F&&$.parentId&&m.push({id:A,parentId:$.parentId,rect:{...L.internals.positionAbsolute,width:L.measured.width??0,height:L.measured.height??0}}),p.push(B)}if(m.length>0){const{parentLookup:A,nodeOrigin:L}=v(),$=xd(m,w,A,L);p.push(...$)}for(const A of _.values())p=A(p);b(p)},triggerNodeChanges:S=>{const{onNodesChange:y,setNodes:m,nodes:p,hasDefaultNodes:w,debug:b}=v();if(S!=null&&S.length){if(w){const k=hN(S,p);m(k)}b&&console.log("React Flow: trigger node changes",S),y==null||y(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:y,setEdges:m,edges:p,hasDefaultEdges:w,debug:b}=v();if(S!=null&&S.length){if(w){const k=pN(S,p);m(k)}b&&console.log("React Flow: trigger edge changes",S),y==null||y(S)}},addSelectedNodes:S=>{const{multiSelectionActive:y,edgeLookup:m,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:b}=v();if(y){const k=S.map(E=>or(E,!0));w(k);return}w(Gr(p,new Set([...S]),!0)),b(Gr(m))},addSelectedEdges:S=>{const{multiSelectionActive:y,edgeLookup:m,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:b}=v();if(y){const k=S.map(E=>or(E,!0));b(k);return}b(Gr(m,new Set([...S]))),w(Gr(p,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:y}={})=>{const{edges:m,nodes:p,nodeLookup:w,triggerNodeChanges:b,triggerEdgeChanges:k}=v(),E=S||p,_=y||m,A=[];for(const $ of E){if(!$.selected)continue;const F=w.get($.id);F&&(F.selected=!1),A.push(or($.id,!1))}const L=[];for(const $ of _)$.selected&&L.push(or($.id,!1));b(A),k(L)},setMinZoom:S=>{const{panZoom:y,maxZoom:m}=v();y==null||y.setScaleExtent([S,m]),f({minZoom:S})},setMaxZoom:S=>{const{panZoom:y,minZoom:m}=v();y==null||y.setScaleExtent([m,S]),f({maxZoom:S})},setTranslateExtent:S=>{var y;(y=v().panZoom)==null||y.setTranslateExtent(S),f({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:y,triggerNodeChanges:m,triggerEdgeChanges:p,elementsSelectable:w}=v();if(!w)return;const b=y.reduce((E,_)=>_.selected?[...E,or(_.id,!1)]:E,[]),k=S.reduce((E,_)=>_.selected?[...E,or(_.id,!1)]:E,[]);m(b),p(k)},setNodeExtent:S=>{const{nodes:y,nodeLookup:m,parentLookup:p,nodeOrigin:w,elevateNodesOnSelect:b,nodeExtent:k,zIndexMode:E}=v();S[0][0]===k[0][0]&&S[0][1]===k[0][1]&&S[1][0]===k[1][0]&&S[1][1]===k[1][1]||(qu(y,m,p,{nodeOrigin:w,nodeExtent:S,elevateNodesOnSelect:b,checkEquality:!1,zIndexMode:E}),f({nodeExtent:S}))},panBy:S=>{const{transform:y,width:m,height:p,panZoom:w,translateExtent:b}=v();return Qb({delta:S,panZoom:w,transform:y,translateExtent:b,width:m,height:p})},setCenter:async(S,y,m)=>{const{width:p,height:w,maxZoom:b,panZoom:k}=v();if(!k)return!1;const E=typeof(m==null?void 0:m.zoom)<"u"?m.zoom:b;return await k.setViewport({x:p/2-S*E,y:w/2-y*E,zoom:E},{duration:m==null?void 0:m.duration,ease:m==null?void 0:m.ease,interpolate:m==null?void 0:m.interpolate}),!0},cancelConnection:()=>{f({connection:{...ay}})},updateConnection:S=>{f({connection:S})},reset:()=>f({...Gh()})}},Object.is);function m0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:s,initialMinZoom:i,initialMaxZoom:a,initialFitViewOptions:l,fitView:u,nodeOrigin:c,nodeExtent:d,zIndexMode:h,children:f}){const[v]=T.useState(()=>R_({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:s,fitView:u,minZoom:i,maxZoom:a,fitViewOptions:l,nodeOrigin:c,nodeExtent:d,zIndexMode:h}));return g.jsx(YE,{value:v,children:g.jsx(wN,{children:g.jsx(RN,{children:f})})})}function L_({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:u,maxZoom:c,nodeOrigin:d,nodeExtent:h,zIndexMode:f}){return T.useContext(el)?g.jsx(g.Fragment,{children:e}):g.jsx(m0,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:s,initialHeight:i,fitView:a,initialFitViewOptions:l,initialMinZoom:u,initialMaxZoom:c,nodeOrigin:d,nodeExtent:h,zIndexMode:f,children:e})}const P_={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function O_({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:s,edgeTypes:i,onNodeClick:a,onEdgeClick:l,onInit:u,onMove:c,onMoveStart:d,onMoveEnd:h,onConnect:f,onConnectStart:v,onConnectEnd:x,onClickConnectStart:S,onClickConnectEnd:y,onNodeMouseEnter:m,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:b,onNodeDoubleClick:k,onNodeDragStart:E,onNodeDrag:_,onNodeDragStop:A,onNodesDelete:L,onEdgesDelete:$,onDelete:F,onSelectionChange:B,onSelectionDragStart:N,onSelectionDrag:P,onSelectionDragStop:R,onSelectionContextMenu:O,onSelectionStart:j,onSelectionEnd:M,onBeforeDelete:I,connectionMode:z,connectionLineType:H=On.Bezier,connectionLineStyle:ne,connectionLineComponent:Q,connectionLineContainerStyle:U,deleteKeyCode:J="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:C=!1,selectionMode:D=xs.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:Y=bs()?"Meta":"Control",zoomActivationKeyCode:X=bs()?"Meta":"Control",snapToGrid:V,snapGrid:G,onlyRenderVisibleElements:re=!1,selectNodesOnDrag:ae,nodesDraggable:de,autoPanOnNodeFocus:Fe,nodesConnectable:We,nodesFocusable:Ge,nodeOrigin:rt=Hy,edgesFocusable:fe,edgesReconnectable:wt,elementsSelectable:W=!0,defaultViewport:te=iN,minZoom:ce=.5,maxZoom:le=2,translateExtent:pe=ws,preventScrolling:oe=!0,nodeExtent:ue,defaultMarkerColor:xe="#b1b1b7",zoomOnScroll:me=!0,zoomOnPinch:ke=!0,panOnScroll:Me=!1,panOnScrollSpeed:ot=.5,panOnScrollMode:st=hr.Free,zoomOnDoubleClick:Ne=!0,panOnDrag:Zt=!0,onPaneClick:Qt,onPaneMouseEnter:Jn,onPaneMouseMove:q,onPaneMouseLeave:ve,onPaneScroll:we,onPaneContextMenu:Te,paneClickDistance:it=1,nodeClickDistance:xt=0,children:Jt,onReconnect:er,onReconnectStart:fn,onReconnectEnd:Cn,onEdgeContextMenu:Ws,onEdgeDoubleClick:Gs,onEdgeMouseEnter:Ys,onEdgeMouseMove:Xs,onEdgeMouseLeave:ko,reconnectRadius:B0=10,onNodesChange:H0,onEdgesChange:U0,noDragClassName:V0="nodrag",noWheelClassName:W0="nowheel",noPanClassName:Nd="nopan",fitView:_d,fitViewOptions:Cd,connectOnClick:G0,attributionPosition:Y0,proOptions:X0,defaultEdgeOptions:q0,elevateNodesOnSelect:K0=!0,elevateEdgesOnSelect:Z0=!1,disableKeyboardA11y:Ad=!1,autoPanOnConnect:Q0,autoPanOnNodeDrag:J0,autoPanOnSelection:ev=!0,autoPanSpeed:tv,connectionRadius:nv,isValidConnection:rv,onError:ov,style:sv,id:Md,nodeDragThreshold:iv,connectionDragThreshold:av,viewport:lv,onViewportChange:uv,width:cv,height:dv,colorMode:fv="light",debug:hv,onScroll:qs,ariaLabelConfig:pv,zIndexMode:jd="basic",...gv},mv){const al=Md||"1",yv=cN(fv),vv=T.useCallback(Td=>{Td.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),qs==null||qs(Td)},[qs]);return g.jsx("div",{"data-testid":"rf__wrapper",...gv,onScroll:vv,style:{...sv,...P_},ref:mv,className:De(["react-flow",o,yv]),id:Md,role:"application",children:g.jsxs(L_,{nodes:e,edges:t,width:cv,height:dv,fitView:_d,fitViewOptions:Cd,minZoom:ce,maxZoom:le,nodeOrigin:rt,nodeExtent:ue,zIndexMode:jd,children:[g.jsx(uN,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:f,onConnectStart:v,onConnectEnd:x,onClickConnectStart:S,onClickConnectEnd:y,nodesDraggable:de,autoPanOnNodeFocus:Fe,nodesConnectable:We,nodesFocusable:Ge,edgesFocusable:fe,edgesReconnectable:wt,elementsSelectable:W,elevateNodesOnSelect:K0,elevateEdgesOnSelect:Z0,minZoom:ce,maxZoom:le,nodeExtent:ue,onNodesChange:H0,onEdgesChange:U0,snapToGrid:V,snapGrid:G,connectionMode:z,translateExtent:pe,connectOnClick:G0,defaultEdgeOptions:q0,fitView:_d,fitViewOptions:Cd,onNodesDelete:L,onEdgesDelete:$,onDelete:F,onNodeDragStart:E,onNodeDrag:_,onNodeDragStop:A,onSelectionDrag:P,onSelectionDragStart:N,onSelectionDragStop:R,onMove:c,onMoveStart:d,onMoveEnd:h,noPanClassName:Nd,nodeOrigin:rt,rfId:al,autoPanOnConnect:Q0,autoPanOnNodeDrag:J0,autoPanSpeed:tv,onError:ov,connectionRadius:nv,isValidConnection:rv,selectNodesOnDrag:ae,nodeDragThreshold:iv,connectionDragThreshold:av,onBeforeDelete:I,debug:hv,ariaLabelConfig:pv,zIndexMode:jd}),g.jsx($_,{onInit:u,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:m,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:b,onNodeDoubleClick:k,nodeTypes:s,edgeTypes:i,connectionLineType:H,connectionLineStyle:ne,connectionLineComponent:Q,connectionLineContainerStyle:U,selectionKeyCode:ee,selectionOnDrag:C,selectionMode:D,deleteKeyCode:J,multiSelectionKeyCode:Y,panActivationKeyCode:Z,zoomActivationKeyCode:X,onlyRenderVisibleElements:re,defaultViewport:te,translateExtent:pe,minZoom:ce,maxZoom:le,preventScrolling:oe,zoomOnScroll:me,zoomOnPinch:ke,zoomOnDoubleClick:Ne,panOnScroll:Me,panOnScrollSpeed:ot,panOnScrollMode:st,panOnDrag:Zt,autoPanOnSelection:ev,onPaneClick:Qt,onPaneMouseEnter:Jn,onPaneMouseMove:q,onPaneMouseLeave:ve,onPaneScroll:we,onPaneContextMenu:Te,paneClickDistance:it,nodeClickDistance:xt,onSelectionContextMenu:O,onSelectionStart:j,onSelectionEnd:M,onReconnect:er,onReconnectStart:fn,onReconnectEnd:Cn,onEdgeContextMenu:Ws,onEdgeDoubleClick:Gs,onEdgeMouseEnter:Ys,onEdgeMouseMove:Xs,onEdgeMouseLeave:ko,reconnectRadius:B0,defaultMarkerColor:xe,noDragClassName:V0,noWheelClassName:W0,noPanClassName:Nd,rfId:al,disableKeyboardA11y:Ad,nodeExtent:ue,viewport:lv,onViewportChange:uv,nodesDraggable:de}),g.jsx(sN,{onSelectionChange:B}),Jt,g.jsx(eN,{proOptions:X0,position:Y0}),g.jsx(JE,{rfId:al,disableKeyboardA11y:Ad})]})})}var z_=Vy(O_);const D_=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function F_({children:e}){const t=ge(D_);return t?Cm.createPortal(e,t):null}function B_({dimensions:e,lineWidth:t,variant:n,className:r}){return g.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:De(["react-flow__background-pattern",n,r])})}function H_({radius:e,className:t}){return g.jsx("circle",{cx:e,cy:e,r:e,className:De(["react-flow__background-pattern","dots",t])})}var xn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(xn||(xn={}));const U_={[xn.Dots]:1,[xn.Lines]:1,[xn.Cross]:6},V_=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function y0({id:e,variant:t=xn.Dots,gap:n=20,size:r,lineWidth:o=1,offset:s=0,color:i,bgColor:a,style:l,className:u,patternClassName:c}){const d=T.useRef(null),{transform:h,patternId:f}=ge(V_,Le),v=r||U_[t],x=t===xn.Dots,S=t===xn.Cross,y=Array.isArray(n)?n:[n,n],m=[y[0]*h[2]||1,y[1]*h[2]||1],p=v*h[2],w=Array.isArray(s)?s:[s,s],b=S?[p,p]:m,k=[w[0]*h[2]+b[0]/2,w[1]*h[2]+b[1]/2],E=`${f}${e||""}`;return g.jsxs("svg",{className:De(["react-flow__background",u]),style:{...l,...tl,"--xy-background-color-props":a,"--xy-background-pattern-color-props":i},ref:d,"data-testid":"rf__background",children:[g.jsx("pattern",{id:E,x:h[0]%m[0],y:h[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:x?g.jsx(H_,{radius:p/2,className:c}):g.jsx(B_,{dimensions:b,lineWidth:o,variant:t,className:c})}),g.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}y0.displayName="Background";const W_=T.memo(y0);function G_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:g.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Y_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:g.jsx("path",{d:"M0 0h32v4.2H0z"})})}function X_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:g.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 q_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:g.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 K_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:g.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 ki({children:e,className:t,...n}){return g.jsx("button",{type:"button",className:De(["react-flow__controls-button",t]),...n,children:e})}const Z_=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function v0({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:s,onZoomOut:i,onFitView:a,onInteractiveChange:l,className:u,children:c,position:d="bottom-left",orientation:h="vertical","aria-label":f}){const v=Ae(),{isInteractive:x,minZoomReached:S,maxZoomReached:y,ariaLabelConfig:m}=ge(Z_,Le),{zoomIn:p,zoomOut:w,fitView:b}=Ds(),k=()=>{p(),s==null||s()},E=()=>{w(),i==null||i()},_=()=>{b(o),a==null||a()},A=()=>{v.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),l==null||l(!x)},L=h==="horizontal"?"horizontal":"vertical";return g.jsxs(zs,{className:De(["react-flow__controls",L,u]),position:d,style:e,"data-testid":"rf__controls","aria-label":f??m["controls.ariaLabel"],children:[t&&g.jsxs(g.Fragment,{children:[g.jsx(ki,{onClick:k,className:"react-flow__controls-zoomin",title:m["controls.zoomIn.ariaLabel"],"aria-label":m["controls.zoomIn.ariaLabel"],disabled:y,children:g.jsx(G_,{})}),g.jsx(ki,{onClick:E,className:"react-flow__controls-zoomout",title:m["controls.zoomOut.ariaLabel"],"aria-label":m["controls.zoomOut.ariaLabel"],disabled:S,children:g.jsx(Y_,{})})]}),n&&g.jsx(ki,{className:"react-flow__controls-fitview",onClick:_,title:m["controls.fitView.ariaLabel"],"aria-label":m["controls.fitView.ariaLabel"],children:g.jsx(X_,{})}),r&&g.jsx(ki,{className:"react-flow__controls-interactive",onClick:A,title:m["controls.interactive.ariaLabel"],"aria-label":m["controls.interactive.ariaLabel"],children:x?g.jsx(K_,{}):g.jsx(q_,{})}),c]})}v0.displayName="Controls";T.memo(v0);function Q_({id:e,x:t,y:n,width:r,height:o,style:s,color:i,strokeColor:a,strokeWidth:l,className:u,borderRadius:c,shapeRendering:d,selected:h,onClick:f}){const{background:v,backgroundColor:x}=s||{},S=i||v||x;return g.jsx("rect",{className:De(["react-flow__minimap-node",{selected:h},u]),x:t,y:n,rx:c,ry:c,width:r,height:o,style:{fill:S,stroke:a,strokeWidth:l},shapeRendering:d,onClick:f?y=>f(y,e):void 0})}const J_=T.memo(Q_),eC=e=>e.nodes.map(t=>t.id),Ul=e=>e instanceof Function?e:()=>e;function tC({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:s=J_,onClick:i}){const a=ge(eC,Le),l=Ul(t),u=Ul(e),c=Ul(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return g.jsx(g.Fragment,{children:a.map(h=>g.jsx(rC,{id:h,nodeColorFunc:l,nodeStrokeColorFunc:u,nodeClassNameFunc:c,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:s,onClick:i,shapeRendering:d},h))})}function nC({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:s,shapeRendering:i,NodeComponent:a,onClick:l}){const{node:u,x:c,y:d,width:h,height:f}=ge(v=>{const x=v.nodeLookup.get(e);if(!x)return{node:void 0,x:0,y:0,width:0,height:0};const S=x.internals.userNode,{x:y,y:m}=x.internals.positionAbsolute,{width:p,height:w}=Kt(S);return{node:S,x:y,y:m,width:p,height:w}},Le);return!u||u.hidden||!py(u)?null:g.jsx(a,{x:c,y:d,width:h,height:f,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:o,strokeColor:n(u),strokeWidth:s,shapeRendering:i,onClick:l,id:u.id})}const rC=T.memo(nC);var oC=T.memo(tC);const sC=200,iC=150,aC=e=>!e.hidden,lC=e=>{const 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]};let n=!1;for(const r of e.nodeLookup.values())if(!r.hidden){n=!0;break}return{viewBB:t,boundingRect:n?dy(Ls(e.nodeLookup,{filter:aC}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Yh=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,uC=(e,t)=>Yh(e.viewBB,t.viewBB)&&Yh(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,cC="react-flow__minimap-desc";function w0({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:i,nodeComponent:a,bgColor:l,maskColor:u,maskStrokeColor:c,maskStrokeWidth:d,position:h="bottom-right",onClick:f,onNodeClick:v,pannable:x=!1,zoomable:S=!1,ariaLabel:y,inversePan:m,zoomStep:p=1,offsetScale:w=5}){const b=Ae(),k=T.useRef(null),{boundingRect:E,panZoom:_,viewBB:A,rfId:L,translateExtent:$,flowWidth:F,flowHeight:B,ariaLabelConfig:N}=ge(lC,uC),P=(e==null?void 0:e.width)??sC,R=(e==null?void 0:e.height)??iC,O=E.width/P,j=E.height/R,M=Math.max(O,j),I=M*P,z=M*R,H=w*M,ne=E.x-(I-E.width)/2-H,Q=E.y-(z-E.height)/2-H,U=I+H*2,J=z+H*2,ee=`${cC}-${L}`,C=T.useRef(0),D=T.useRef();C.current=M,T.useEffect(()=>{const G=b.getState().panZoom;if(k.current&&G)return D.current=aE({domNode:k.current,panZoom:G,getTransform:()=>b.getState().transform,getViewScale:()=>C.current}),()=>{var re;(re=D.current)==null||re.destroy()}},[_]),T.useEffect(()=>{var G;(G=D.current)==null||G.update({translateExtent:$,width:F,height:B,inversePan:m,pannable:x,zoomStep:p,zoomable:S})},[x,S,m,p,$,F,B]);const Z=f?G=>{var de;const[re,ae]=((de=D.current)==null?void 0:de.pointer(G))||[0,0];f(G,{x:re,y:ae})}:void 0,Y=T.useCallback((G,re)=>{const ae=b.getState().nodeLookup.get(re).internals.userNode;v==null||v(G,ae)},[v]),X=v?Y:void 0,V=y??N["minimap.ariaLabel"];return g.jsx(zs,{position:h,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*M:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:De(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:g.jsxs("svg",{width:P,height:R,viewBox:`${ne} ${Q} ${U} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ee,ref:k,onClick:Z,children:[V&&g.jsx("title",{id:ee,children:V}),g.jsx(oC,{onClick:X,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:o,nodeStrokeWidth:i,nodeComponent:a}),g.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-H},${Q-H}h${U+H*2}v${J+H*2}h${-U-H*2}z
|
|
61
|
+
`)),c=u.reduce((d,h)=>d.concat(...h),[]);return[u,c]}return[[],[]]},[e]);return T.useEffect(()=>{const l=(t==null?void 0:t.target)??Ah,u=(t==null?void 0:t.actInsideInputWithModifier)??!0;if(e!==null){const c=f=>{var S,y;if(o.current=f.ctrlKey||f.metaKey||f.shiftKey||f.altKey,(!o.current||o.current&&!u)&&vy(f))return!1;const x=jh(f.code,a);if(s.current.add(f[x]),Mh(i,s.current,!1)){const m=((y=(S=f.composedPath)==null?void 0:S.call(f))==null?void 0:y[0])||f.target,p=(m==null?void 0:m.nodeName)==="BUTTON"||(m==null?void 0:m.nodeName)==="A";t.preventDefault!==!1&&(o.current||!p)&&f.preventDefault(),r(!0)}},d=f=>{const v=jh(f.code,a);Mh(i,s.current,!0)?(r(!1),s.current.clear()):s.current.delete(f[v]),f.key==="Meta"&&s.current.clear(),o.current=!1},h=()=>{s.current.clear(),r(!1)};return l==null||l.addEventListener("keydown",c),l==null||l.addEventListener("keyup",d),window.addEventListener("blur",h),window.addEventListener("contextmenu",h),()=>{l==null||l.removeEventListener("keydown",c),l==null||l.removeEventListener("keyup",d),window.removeEventListener("blur",h),window.removeEventListener("contextmenu",h)}}},[e,r]),n}function Mh(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(o=>t.has(o)))}function jh(e,t){return t.includes(e)?"code":"key"}const dN=()=>{const e=Ae();return T.useMemo(()=>({zoomIn:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{const{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{const{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!1},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{const{transform:[r,o,s],panZoom:i}=e.getState();return i?(await i.setViewport({x:t.x??r,y:t.y??o,zoom:t.zoom??s},n),!0):!1},getViewport:()=>{const[t,n,r]=e.getState().transform;return{x:t,y:n,zoom:r}},setCenter:async(t,n,r)=>e.getState().setCenter(t,n,r),fitBounds:async(t,n)=>{const{width:r,height:o,minZoom:s,maxZoom:i,panZoom:a}=e.getState(),l=hd(t,r,o,s,i,(n==null?void 0:n.padding)??.1);return a?(await a.setViewport(l,{duration:n==null?void 0:n.duration,ease:n==null?void 0:n.ease,interpolate:n==null?void 0:n.interpolate}),!0):!1},screenToFlowPosition:(t,n={})=>{const{transform:r,snapGrid:o,snapToGrid:s,domNode:i}=e.getState();if(!i)return t;const{x:a,y:l}=i.getBoundingClientRect(),u={x:t.x-a,y:t.y-l},c=n.snapGrid??o,d=n.snapToGrid??s;return Os(u,r,d,c)},flowToScreenPosition:t=>{const{transform:n,domNode:r}=e.getState();if(!r)return t;const{x:o,y:s}=r.getBoundingClientRect(),i=ho(t,n);return{x:i.x+o,y:i.y+s}}}),[])};function Uy(e,t){const n=[],r=new Map,o=[];for(const s of e)if(s.type==="add"){o.push(s);continue}else if(s.type==="remove"||s.type==="replace")r.set(s.id,[s]);else{const i=r.get(s.id);i?i.push(s):r.set(s.id,[s])}for(const s of t){const i=r.get(s.id);if(!i){n.push(s);continue}if(i[0].type==="remove")continue;if(i[0].type==="replace"){n.push({...i[0].item});continue}const a={...s};for(const l of i)fN(l,a);n.push(a)}return o.length&&o.forEach(s=>{s.index!==void 0?n.splice(s.index,0,{...s.item}):n.push({...s.item})}),n}function fN(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 hN(e,t){return Uy(e,t)}function pN(e,t){return Uy(e,t)}function or(e,t){return{id:e,type:"select",selected:t}}function Gr(e,t=new Set,n=!1){const r=[];for(const[o,s]of e){const i=t.has(o);!(s.selected===void 0&&!i)&&s.selected!==i&&(n&&(s.selected=i),r.push(or(s.id,i)))}return r}function Th({items:e=[],lookup:t}){var o;const n=[],r=new Map(e.map(s=>[s.id,s]));for(const[s,i]of e.entries()){const a=t.get(i.id),l=((o=a==null?void 0:a.internals)==null?void 0:o.userNode)??a;l!==void 0&&l!==i&&n.push({id:i.id,item:i,type:"replace"}),l===void 0&&n.push({item:i,type:"add",index:s})}for(const[s]of t)r.get(s)===void 0&&n.push({id:s,type:"remove"});return n}function $h(e){return{id:e.id,type:"remove"}}const gN=hy();function mN(e,t,n={}){return Db(e,t,{...n,onError:n.onError??gN})}const Ih=e=>Eb(e),yN=e=>ly(e);function Vy(e){return T.forwardRef(e)}const Wy=typeof window<"u"?T.useLayoutEffect:T.useEffect;function Rh(e){const[t,n]=T.useState(BigInt(0)),[r]=T.useState(()=>vN(()=>n(o=>o+BigInt(1))));return Wy(()=>{const o=r.get();o.length&&(e(o),r.reset())},[t]),r}function vN(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}const Gy=T.createContext(null);function wN({children:e}){const t=Ae(),n=T.useCallback(a=>{const{nodes:l=[],setNodes:u,hasDefaultNodes:c,onNodesChange:d,nodeLookup:h,fitViewQueued:f,onNodesChangeMiddlewareMap:v}=t.getState();let x=l;for(const y of a)x=typeof y=="function"?y(x):y;let S=Th({items:x,lookup:h});for(const y of v.values())S=y(S);c&&u(x),S.length>0?d==null||d(S):f&&window.requestAnimationFrame(()=>{const{fitViewQueued:y,nodes:m,setNodes:p}=t.getState();y&&p(m)})},[]),r=Rh(n),o=T.useCallback(a=>{const{edges:l=[],setEdges:u,hasDefaultEdges:c,onEdgesChange:d,edgeLookup:h}=t.getState();let f=l;for(const v of a)f=typeof v=="function"?v(f):v;c?u(f):d&&d(Th({items:f,lookup:h}))},[]),s=Rh(o),i=T.useMemo(()=>({nodeQueue:r,edgeQueue:s}),[]);return g.jsx(Gy.Provider,{value:i,children:e})}function xN(){const e=T.useContext(Gy);if(!e)throw new Error("useBatchContext must be used within a BatchProvider");return e}const kN=e=>!!e.panZoom;function Ds(){const e=dN(),t=Ae(),n=xN(),r=ge(kN),o=T.useMemo(()=>{const s=d=>t.getState().nodeLookup.get(d),i=d=>{n.nodeQueue.push(d)},a=d=>{n.edgeQueue.push(d)},l=d=>{var y,m;const{nodeLookup:h,nodeOrigin:f}=t.getState(),v=Ih(d)?d:h.get(d.id),x=v.parentId?gy(v.position,v.measured,v.parentId,h,f):v.position,S={...v,position:x,width:((y=v.measured)==null?void 0:y.width)??v.width,height:((m=v.measured)==null?void 0:m.height)??v.height};return Ss(S)},u=(d,h,f={replace:!1})=>{i(v=>v.map(x=>{if(x.id===d){const S=typeof h=="function"?h(x):h;return f.replace&&Ih(S)?S:{...x,...S}}return x}))},c=(d,h,f={replace:!1})=>{a(v=>v.map(x=>{if(x.id===d){const S=typeof h=="function"?h(x):h;return f.replace&&yN(S)?S:{...x,...S}}return x}))};return{getNodes:()=>t.getState().nodes.map(d=>({...d})),getNode:d=>{var h;return(h=s(d))==null?void 0:h.internals.userNode},getInternalNode:s,getEdges:()=>{const{edges:d=[]}=t.getState();return d.map(h=>({...h}))},getEdge:d=>t.getState().edgeLookup.get(d),setNodes:i,setEdges:a,addNodes:d=>{const h=Array.isArray(d)?d:[d];n.nodeQueue.push(f=>[...f,...h])},addEdges:d=>{const h=Array.isArray(d)?d:[d];n.edgeQueue.push(f=>[...f,...h])},toObject:()=>{const{nodes:d=[],edges:h=[],transform:f}=t.getState(),[v,x,S]=f;return{nodes:d.map(y=>({...y})),edges:h.map(y=>({...y})),viewport:{x:v,y:x,zoom:S}}},deleteElements:async({nodes:d=[],edges:h=[]})=>{const{nodes:f,edges:v,onNodesDelete:x,onEdgesDelete:S,triggerNodeChanges:y,triggerEdgeChanges:m,onDelete:p,onBeforeDelete:w}=t.getState(),{nodes:b,edges:k}=await Mb({nodesToRemove:d,edgesToRemove:h,nodes:f,edges:v,onBeforeDelete:w}),E=k.length>0,_=b.length>0;if(E){const A=k.map($h);S==null||S(k),m(A)}if(_){const A=b.map($h);x==null||x(b),y(A)}return(_||E)&&(p==null||p({nodes:b,edges:k})),{deletedNodes:b,deletedEdges:k}},getIntersectingNodes:(d,h=!0,f)=>{const v=lh(d),x=v?d:l(d),S=f!==void 0;return x?(f||t.getState().nodes).filter(y=>{const m=t.getState().nodeLookup.get(y.id);if(m&&!v&&(y.id===d.id||!m.internals.positionAbsolute))return!1;const p=Ss(S?y:m),w=Sa(p,x);return h&&w>0||w>=p.width*p.height||w>=x.width*x.height}):[]},isNodeIntersecting:(d,h,f=!0)=>{const x=lh(d)?d:l(d);if(!x)return!1;const S=Sa(x,h);return f&&S>0||S>=h.width*h.height||S>=x.width*x.height},updateNode:u,updateNodeData:(d,h,f={replace:!1})=>{u(d,v=>{const x=typeof h=="function"?h(v):h;return f.replace?{...v,data:x}:{...v,data:{...v.data,...x}}},f)},updateEdge:c,updateEdgeData:(d,h,f={replace:!1})=>{c(d,v=>{const x=typeof h=="function"?h(v):h;return f.replace?{...v,data:x}:{...v,data:{...v.data,...x}}},f)},getNodesBounds:d=>{const{nodeLookup:h,nodeOrigin:f}=t.getState();return Nb(d,{nodeLookup:h,nodeOrigin:f})},getHandleConnections:({type:d,id:h,nodeId:f})=>{var v;return Array.from(((v=t.getState().connectionLookup.get(`${f}-${d}${h?`-${h}`:""}`))==null?void 0:v.values())??[])},getNodeConnections:({type:d,handleId:h,nodeId:f})=>{var v;return Array.from(((v=t.getState().connectionLookup.get(`${f}${d?h?`-${d}-${h}`:`-${d}`:""}`))==null?void 0:v.values())??[])},fitView:async d=>{const h=t.getState().fitViewResolver??$b();return t.setState({fitViewQueued:!0,fitViewOptions:d,fitViewResolver:h}),n.nodeQueue.push(f=>[...f]),h.promise}}},[]);return T.useMemo(()=>({...o,...e,viewportInitialized:r}),[r])}const Lh=e=>e.selected,SN=typeof window<"u"?window:void 0;function bN({deleteKeyCode:e,multiSelectionKeyCode:t}){const n=Ae(),{deleteElements:r}=Ds(),o=Es(e,{actInsideInputWithModifier:!1}),s=Es(t,{target:SN});T.useEffect(()=>{if(o){const{edges:i,nodes:a}=n.getState();r({nodes:a.filter(Lh),edges:i.filter(Lh)}),n.setState({nodesSelectionActive:!1})}},[o]),T.useEffect(()=>{n.setState({multiSelectionActive:s})},[s])}function EN(e){const t=Ae();T.useEffect(()=>{const n=()=>{var o,s,i,a;if(!e.current||!(((s=(o=e.current).checkVisibility)==null?void 0:s.call(o))??!0))return!1;const r=pd(e.current);(r.height===0||r.width===0)&&((a=(i=t.getState()).onError)==null||a.call(i,"004",Xt.error004())),t.setState({width:r.width||500,height:r.height||500})};if(e.current){n(),window.addEventListener("resize",n);const r=new ResizeObserver(()=>n());return r.observe(e.current),()=>{window.removeEventListener("resize",n),r&&e.current&&r.unobserve(e.current)}}},[])}const tl={position:"absolute",width:"100%",height:"100%",top:0,left:0},NN=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function _N({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panActivationKeyPressed:o,panOnScrollSpeed:s=.5,panOnScrollMode:i=hr.Free,zoomOnDoubleClick:a=!0,panOnDrag:l=!0,defaultViewport:u,translateExtent:c,minZoom:d,maxZoom:h,zoomActivationKeyCode:f,preventScrolling:v=!0,children:x,noWheelClassName:S,noPanClassName:y,onViewportChange:m,isControlledViewport:p,paneClickDistance:w,selectionOnDrag:b}){const k=Ae(),E=T.useRef(null),{userSelectionActive:_,lib:A,connectionInProgress:L}=ge(NN,Le),$=Es(f),F=T.useRef();EN(E);const B=T.useCallback(N=>{m==null||m({x:N[0],y:N[1],zoom:N[2]}),p||k.setState({transform:N})},[m,p]);return T.useEffect(()=>{if(E.current){F.current=gE({domNode:E.current,minZoom:d,maxZoom:h,translateExtent:c,viewport:u,onDraggingChange:O=>k.setState(j=>j.paneDragging===O?j:{paneDragging:O}),onPanZoomStart:(O,j)=>{const{onViewportChangeStart:M,onMoveStart:I}=k.getState();I==null||I(O,j),M==null||M(j)},onPanZoom:(O,j)=>{const{onViewportChange:M,onMove:I}=k.getState();I==null||I(O,j),M==null||M(j)},onPanZoomEnd:(O,j)=>{const{onViewportChangeEnd:M,onMoveEnd:I}=k.getState();I==null||I(O,j),M==null||M(j)}});const{x:N,y:P,zoom:R}=F.current.getViewport();return k.setState({panZoom:F.current,transform:[N,P,R],domNode:E.current.closest(".react-flow")}),()=>{var O;(O=F.current)==null||O.destroy()}}},[]),T.useEffect(()=>{var N;(N=F.current)==null||N.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panActivationKeyPressed:o,panOnScrollSpeed:s,panOnScrollMode:i,zoomOnDoubleClick:a,panOnDrag:l,zoomActivationKeyPressed:$,preventScrolling:v,noPanClassName:y,userSelectionActive:_,noWheelClassName:S,lib:A,onTransformChange:B,connectionInProgress:L,selectionOnDrag:b,paneClickDistance:w})},[e,t,n,r,o,s,i,a,l,$,v,y,_,S,A,B,L,b,w]),g.jsx("div",{className:"react-flow__renderer",ref:E,style:tl,children:x})}const CN=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function AN(){const{userSelectionActive:e,userSelectionRect:t}=ge(CN,Le);return e&&t?g.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}const Hl=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},MN=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function jN({isSelecting:e,selectionKeyPressed:t,selectionMode:n=xs.Full,panOnDrag:r,autoPanOnSelection:o,paneClickDistance:s,selectionOnDrag:i,onSelectionStart:a,onSelectionEnd:l,onPaneClick:u,onPaneContextMenu:c,onPaneScroll:d,onPaneMouseEnter:h,onPaneMouseMove:f,onPaneMouseLeave:v,children:x}){const S=T.useRef(0),y=Ae(),{userSelectionActive:m,elementsSelectable:p,dragging:w,panBy:b,autoPanSpeed:k}=ge(MN,Le),E=p&&(e||m),_=T.useRef(null),A=T.useRef(),L=T.useRef(new Set),$=T.useRef(new Set),F=T.useRef(!1),B=T.useRef(!1),N=T.useRef({x:0,y:0}),P=T.useRef(!1),R=C=>{if(B.current||F.current||y.getState().connection.inProgress){B.current=!1,F.current=!1;return}u==null||u(C),y.getState().resetSelectedElements(),y.setState({nodesSelectionActive:!1})},O=C=>{if(Array.isArray(r)&&(r!=null&&r.includes(2))){C.preventDefault();return}c==null||c(C)},j=d?C=>d(C):void 0,M=C=>{B.current&&(C.stopPropagation(),B.current=!1)},I=C=>{var de,Fe;if(C.pointerType==="touch"&&r!==!1&&!t)return;const{domNode:D,transform:Z}=y.getState();if(A.current=D==null?void 0:D.getBoundingClientRect(),!A.current)return;const Y=C.target===_.current;if(!Y&&!!C.target.closest(".nokey")||!e||!(i&&Y||t)||C.button!==0||!C.isPrimary)return;(Fe=(de=C.target)==null?void 0:de.setPointerCapture)==null||Fe.call(de,C.pointerId),B.current=!1;const{x:G,y:re}=Vt(C.nativeEvent,A.current),ae=Os({x:G,y:re},Z);y.setState({userSelectionRect:{width:0,height:0,startX:ae.x,startY:ae.y,x:G,y:re}}),Y||(C.stopPropagation(),C.preventDefault())};function z(C,D){const{userSelectionRect:Z}=y.getState();if(!Z)return;const{transform:Y,nodeLookup:X,edgeLookup:V,connectionLookup:G,triggerNodeChanges:re,triggerEdgeChanges:ae,defaultEdgeOptions:de}=y.getState(),Fe={x:Z.startX,y:Z.startY},{x:We,y:Ge}=ho(Fe,Y),rt={startX:Fe.x,startY:Fe.y,x:C<We?C:We,y:D<Ge?D:Ge,width:Math.abs(C-We),height:Math.abs(D-Ge)},fe=L.current,wt=$.current;L.current=new Set(dd(X,rt,Y,n===xs.Partial,!0).map(te=>te.id)),$.current=new Set;const W=(de==null?void 0:de.selectable)??!0;for(const te of L.current){const ce=G.get(te);if(ce)for(const{edgeId:ue}of ce.values()){const pe=V.get(ue);pe&&(pe.selectable??W)&&$.current.add(ue)}}if(!uh(fe,L.current)){const te=Gr(X,L.current,!0);re(te)}if(!uh(wt,$.current)){const te=Gr(V,$.current);ae(te)}y.setState({userSelectionRect:rt,userSelectionActive:!0,nodesSelectionActive:!1})}function H(){if(!o||!A.current)return;const[C,D]=fd(N.current,A.current,k);b({x:C,y:D}).then(Z=>{if(!B.current||!Z){S.current=requestAnimationFrame(H);return}const{x:Y,y:X}=N.current;z(Y,X),S.current=requestAnimationFrame(H)})}const ne=()=>{cancelAnimationFrame(S.current),S.current=0,P.current=!1};T.useEffect(()=>()=>ne(),[]);const Q=C=>{const{userSelectionRect:D,transform:Z,resetSelectedElements:Y}=y.getState();if(!A.current||!D)return;const{x:X,y:V}=Vt(C.nativeEvent,A.current);N.current={x:X,y:V};const G=ho({x:D.startX,y:D.startY},Z);if(!B.current){const re=t?0:s;if(Math.hypot(X-G.x,V-G.y)<=re)return;Y(),a==null||a(C)}B.current=!0,P.current||(H(),P.current=!0),z(X,V)},U=C=>{var D,Z;if(!E){C.target===_.current&&y.getState().connection.inProgress&&(F.current=!0);return}C.button===0&&((Z=(D=C.target)==null?void 0:D.releasePointerCapture)==null||Z.call(D,C.pointerId),!m&&C.target===_.current&&y.getState().userSelectionRect&&(R==null||R(C)),y.setState({userSelectionActive:!1,userSelectionRect:null}),B.current&&(l==null||l(C),y.setState({nodesSelectionActive:L.current.size>0})),ne())},J=C=>{var D,Z;(Z=(D=C.target)==null?void 0:D.releasePointerCapture)==null||Z.call(D,C.pointerId),ne()},ee=r===!0||Array.isArray(r)&&r.includes(0);return g.jsxs("div",{className:De(["react-flow__pane",{draggable:ee,dragging:w,selection:e}]),onClick:E?void 0:Hl(R,_),onContextMenu:Hl(O,_),onWheel:Hl(j,_),onPointerEnter:E?void 0:h,onPointerMove:E?Q:f,onPointerUp:U,onPointerCancel:E?J:void 0,onPointerDownCapture:E?I:void 0,onClickCapture:E?M:void 0,onPointerLeave:v,ref:_,style:tl,children:[x,g.jsx(AN,{})]})}function Zu({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:o,unselectNodesAndEdges:s,multiSelectionActive:i,nodeLookup:a,onError:l}=t.getState(),u=a.get(e);if(!u){l==null||l("012",Xt.error012(e));return}t.setState({nodesSelectionActive:!1}),u.selected?(n||u.selected&&i)&&(s({nodes:[u],edges:[]}),requestAnimationFrame(()=>{var c;return(c=r==null?void 0:r.current)==null?void 0:c.blur()})):o([e])}function Yy({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:o,isSelectable:s,nodeClickDistance:i}){const a=Ae(),[l,u]=T.useState(!1),c=T.useRef();return T.useEffect(()=>{if(!t)return c.current=tE({getStoreItems:()=>a.getState(),onNodeMouseDown:d=>{Zu({id:d,store:a,nodeRef:e})},onDragStart:()=>{u(!0)},onDragStop:()=>{u(!1)}}),()=>{var d;(d=c.current)==null||d.destroy(),c.current=void 0}},[t,a,e]),T.useEffect(()=>{t||!e.current||!c.current||c.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:s,nodeId:o,nodeClickDistance:i})},[n,r,t,s,e,o,i]),l}const TN=e=>t=>t.selected&&(t.draggable||e&&typeof t.draggable>"u");function Xy(){const e=Ae();return T.useCallback(n=>{const{nodeExtent:r,snapToGrid:o,snapGrid:s,nodesDraggable:i,onError:a,updateNodePositions:l,nodeLookup:u,nodeOrigin:c}=e.getState(),d=new Map,h=TN(i),f=o?s[0]:5,v=o?s[1]:5,x=n.direction.x*f*n.factor,S=n.direction.y*v*n.factor;for(const[,y]of u){if(!h(y))continue;let m={x:y.internals.positionAbsolute.x+x,y:y.internals.positionAbsolute.y+S};o&&(m=Ps(m,s));const{position:p,positionAbsolute:w}=uy({nodeId:y.id,nextPosition:m,nodeLookup:u,nodeExtent:r,nodeOrigin:c,onError:a});y.position=p,y.internals.positionAbsolute=w,d.set(y.id,y)}l(d)},[])}const kd=T.createContext(null),$N=kd.Provider;kd.Consumer;const qy=()=>T.useContext(kd),IN=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),Ky=T.createContext(null);function RN({children:e}){const t=ge(IN,Le);return g.jsx(Ky.Provider,{value:t,children:e})}function LN(){const e=T.useContext(Ky);if(!e)throw new Error("useHandleConfig must be used within a HandleConfigProvider");return e}const PN={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},ON=(e,t,n)=>r=>{const{connectionClickStartHandle:o,connectionMode:s,connection:i}=r,{fromHandle:a,toHandle:l,isValid:u}=i;if(!a&&!o)return PN;const c=(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.id)===t&&(l==null?void 0:l.type)===n;return{connectingFrom:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.id)===t&&(a==null?void 0:a.type)===n,connectingTo:c,clickConnecting:(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.id)===t&&(o==null?void 0:o.type)===n,isPossibleEndHandle:s===co.Strict?(a==null?void 0:a.type)!==n:e!==(a==null?void 0:a.nodeId)||t!==(a==null?void 0:a.id),connectionInProcess:!!a,clickConnectionInProcess:!!o,valid:c&&u}};function zN({type:e="source",position:t=ie.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:o=!0,isConnectableEnd:s=!0,id:i,onConnect:a,children:l,className:u,onMouseDown:c,onTouchStart:d,...h},f){var P,R;const v=i||null,x=e==="target",S=Ae(),y=qy(),{connectOnClick:m,noPanClassName:p,rfId:w}=LN(),{connectingFrom:b,connectingTo:k,clickConnecting:E,isPossibleEndHandle:_,connectionInProcess:A,clickConnectionInProcess:L,valid:$}=ge(ON(y,v,e),Le);y||(R=(P=S.getState()).onError)==null||R.call(P,"010",Xt.error010());const F=O=>{const{defaultEdgeOptions:j,onConnect:M,hasDefaultEdges:I}=S.getState(),z={...j,...O};if(I){const{edges:H,setEdges:ne,onError:Q}=S.getState();ne(mN(z,H,{onError:Q}))}M==null||M(z),a==null||a(z)},B=O=>{if(!y)return;const j=wy(O.nativeEvent);if(o&&(j&&O.button===0||!j)){const M=S.getState();Ku.onPointerDown(O.nativeEvent,{handleDomNode:O.currentTarget,autoPanOnConnect:M.autoPanOnConnect,connectionMode:M.connectionMode,connectionRadius:M.connectionRadius,domNode:M.domNode,nodeLookup:M.nodeLookup,lib:M.lib,isTarget:x,handleId:v,nodeId:y,flowId:M.rfId,panBy:M.panBy,cancelConnection:M.cancelConnection,onConnectStart:M.onConnectStart,onConnectEnd:(...I)=>{var z,H;return(H=(z=S.getState()).onConnectEnd)==null?void 0:H.call(z,...I)},updateConnection:M.updateConnection,onConnect:F,isValidConnection:n||((...I)=>{var z,H;return((H=(z=S.getState()).isValidConnection)==null?void 0:H.call(z,...I))??!0}),getTransform:()=>S.getState().transform,getFromHandle:()=>S.getState().connection.fromHandle,autoPanSpeed:M.autoPanSpeed,dragThreshold:M.connectionDragThreshold})}j?c==null||c(O):d==null||d(O)},N=O=>{const{onClickConnectStart:j,onClickConnectEnd:M,connectionClickStartHandle:I,connectionMode:z,isValidConnection:H,lib:ne,rfId:Q,nodeLookup:U,connection:J}=S.getState();if(!y||!I&&!o)return;if(!I){j==null||j(O.nativeEvent,{nodeId:y,handleId:v,handleType:e}),S.setState({connectionClickStartHandle:{nodeId:y,type:e,id:v}});return}const ee=yy(O.target),C=n||H,{connection:D,isValid:Z}=Ku.isValid(O.nativeEvent,{handle:{nodeId:y,id:v,type:e},connectionMode:z,fromNodeId:I.nodeId,fromHandleId:I.id||null,fromType:I.type,isValidConnection:C,flowId:Q,doc:ee,lib:ne,nodeLookup:U});Z&&D&&F(D);const Y=structuredClone(J);delete Y.inProgress,Y.toPosition=Y.toHandle?Y.toHandle.position:null,M==null||M(O,Y),S.setState({connectionClickStartHandle:null})};return g.jsx("div",{"data-handleid":v,"data-nodeid":y,"data-handlepos":t,"data-id":`${w}-${y}-${v}-${e}`,className:De(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",p,u,{source:!x,target:x,connectable:r,connectablestart:o,connectableend:s,clickconnecting:E,connectingfrom:b,connectingto:k,valid:$,connectionindicator:r&&(!A||_)&&(A||L?s:o)}]),onMouseDown:B,onTouchStart:B,onClick:m?N:void 0,ref:f,...h,children:l})}const mo=T.memo(Vy(zN));function DN({data:e,isConnectable:t,sourcePosition:n=ie.Bottom}){return g.jsxs(g.Fragment,{children:[e==null?void 0:e.label,g.jsx(mo,{type:"source",position:n,isConnectable:t})]})}function FN({data:e,isConnectable:t,targetPosition:n=ie.Top,sourcePosition:r=ie.Bottom}){return g.jsxs(g.Fragment,{children:[g.jsx(mo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,g.jsx(mo,{type:"source",position:r,isConnectable:t})]})}function BN(){return null}function HN({data:e,isConnectable:t,targetPosition:n=ie.Top}){return g.jsxs(g.Fragment,{children:[g.jsx(mo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label]})}const Ea={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Ph={input:DN,default:FN,output:HN,group:BN};function UN(e){var t,n,r,o;return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??((t=e.style)==null?void 0:t.width),height:e.height??e.initialHeight??((n=e.style)==null?void 0:n.height)}:{width:e.width??((r=e.style)==null?void 0:r.width),height:e.height??((o=e.style)==null?void 0:o.height)}}const VN=e=>{const{width:t,height:n,x:r,y:o}=Ls(e.nodeLookup,{filter:s=>!!s.selected});return{width:Ut(t)?t:null,height:Ut(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${o}px)`}};function WN({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Ae(),{width:o,height:s,transformString:i,userSelectionActive:a}=ge(VN,Le),l=Xy(),u=T.useRef(null);T.useEffect(()=>{var f;n||(f=u.current)==null||f.focus({preventScroll:!0})},[n]);const c=!a&&o!==null&&s!==null;if(Yy({nodeRef:u,disabled:!c}),!c)return null;const d=e?f=>{const v=r.getState().nodes.filter(x=>x.selected);e(f,v)}:void 0,h=f=>{Object.prototype.hasOwnProperty.call(Ea,f.key)&&(f.preventDefault(),l({direction:Ea[f.key],factor:f.shiftKey?4:1}))};return g.jsx("div",{className:De(["react-flow__nodesselection","react-flow__container",t]),style:{transform:i},children:g.jsx("div",{ref:u,className:"react-flow__nodesselection-rect",onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:h,style:{width:o,height:s}})})}const Oh=typeof window<"u"?window:void 0,GN=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Zy({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,paneClickDistance:a,deleteKeyCode:l,selectionKeyCode:u,selectionOnDrag:c,selectionMode:d,onSelectionStart:h,onSelectionEnd:f,multiSelectionKeyCode:v,panActivationKeyCode:x,zoomActivationKeyCode:S,elementsSelectable:y,zoomOnScroll:m,zoomOnPinch:p,panOnScroll:w,panOnScrollSpeed:b,panOnScrollMode:k,zoomOnDoubleClick:E,panOnDrag:_,autoPanOnSelection:A,defaultViewport:L,translateExtent:$,minZoom:F,maxZoom:B,preventScrolling:N,onSelectionContextMenu:P,noWheelClassName:R,noPanClassName:O,disableKeyboardA11y:j,onViewportChange:M,isControlledViewport:I}){const{nodesSelectionActive:z,userSelectionActive:H}=ge(GN,Le),ne=Es(u,{target:Oh}),Q=Es(x,{target:Oh}),U=Q||_,J=Q||w,ee=c&&U!==!0,C=ne||H||ee;return bN({deleteKeyCode:l,multiSelectionKeyCode:v}),g.jsx(_N,{onPaneContextMenu:s,elementsSelectable:y,zoomOnScroll:m,zoomOnPinch:p,panOnScroll:J,panActivationKeyPressed:Q,panOnScrollSpeed:b,panOnScrollMode:k,zoomOnDoubleClick:E,panOnDrag:!ne&&U,defaultViewport:L,translateExtent:$,minZoom:F,maxZoom:B,zoomActivationKeyCode:S,preventScrolling:N,noWheelClassName:R,noPanClassName:O,onViewportChange:M,isControlledViewport:I,paneClickDistance:a,selectionOnDrag:ee,children:g.jsxs(jN,{onSelectionStart:h,onSelectionEnd:f,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:o,onPaneContextMenu:s,onPaneScroll:i,panOnDrag:U,autoPanOnSelection:A,isSelecting:!!C,selectionMode:d,selectionKeyPressed:ne,paneClickDistance:a,selectionOnDrag:ee,children:[e,z&&g.jsx(WN,{onSelectionContextMenu:P,noPanClassName:O,disableKeyboardA11y:j})]})})}Zy.displayName="FlowRenderer";const YN=T.memo(Zy),XN=e=>t=>e?dd(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(n=>n.id):Array.from(t.nodeLookup.keys());function qN(e){return ge(T.useCallback(XN(e),[e]),Le)}const KN=e=>e.updateNodeInternals;function ZN(){const e=ge(KN),[t]=T.useState(()=>typeof ResizeObserver>"u"?null:new ResizeObserver(n=>{const r=new Map;n.forEach(o=>{const s=o.target.getAttribute("data-id");r.set(s,{id:s,nodeElement:o.target,force:!0})}),e(r)}));return T.useEffect(()=>()=>{t==null||t.disconnect()},[t]),t}function QN({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){const o=Ae(),s=T.useRef(null),i=T.useRef(null),a=T.useRef(e.sourcePosition),l=T.useRef(e.targetPosition),u=T.useRef(t),c=n&&!!e.internals.handleBounds;return T.useEffect(()=>{s.current&&!e.hidden&&(!c||i.current!==s.current)&&(i.current&&(r==null||r.unobserve(i.current)),r==null||r.observe(s.current),i.current=s.current)},[c,e.hidden]),T.useEffect(()=>()=>{i.current&&(r==null||r.unobserve(i.current),i.current=null)},[]),T.useEffect(()=>{if(s.current){const d=u.current!==t,h=a.current!==e.sourcePosition,f=l.current!==e.targetPosition;(d||h||f)&&(u.current=t,a.current=e.sourcePosition,l.current=e.targetPosition,o.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:s.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),s}function JN({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:o,onContextMenu:s,onDoubleClick:i,nodesDraggable:a,elementsSelectable:l,nodesConnectable:u,nodesFocusable:c,resizeObserver:d,noDragClassName:h,noPanClassName:f,disableKeyboardA11y:v,rfId:x,nodeTypes:S,nodeClickDistance:y,onError:m}){const{node:p,internals:w,isParent:b}=ge(C=>{const D=C.nodeLookup.get(e),Z=C.parentLookup.has(e);return{node:D,internals:D.internals,isParent:Z}},Le);let k=p.type||"default",E=(S==null?void 0:S[k])||Ph[k];E===void 0&&(m==null||m("003",Xt.error003(k)),k="default",E=(S==null?void 0:S.default)||Ph.default);const _=!!(p.draggable||a&&typeof p.draggable>"u"),A=!!(p.selectable||l&&typeof p.selectable>"u"),L=!!(p.connectable||u&&typeof p.connectable>"u"),$=!!(p.focusable||c&&typeof p.focusable>"u"),F=Ae(),B=py(p),N=QN({node:p,nodeType:k,hasDimensions:B,resizeObserver:d}),P=Yy({nodeRef:N,disabled:p.hidden||!_,noDragClassName:h,handleSelector:p.dragHandle,nodeId:e,isSelectable:A,nodeClickDistance:y}),R=Xy();if(p.hidden)return null;const O=Kt(p),j=UN(p),M=A||_||t||n||r||o,I=n?C=>n(C,{...w.userNode}):void 0,z=r?C=>r(C,{...w.userNode}):void 0,H=o?C=>o(C,{...w.userNode}):void 0,ne=s?C=>s(C,{...w.userNode}):void 0,Q=i?C=>i(C,{...w.userNode}):void 0,U=C=>{const{selectNodesOnDrag:D,nodeDragThreshold:Z}=F.getState();A&&(!D||!_||Z>0)&&Zu({id:e,store:F,nodeRef:N}),t&&t(C,{...w.userNode})},J=C=>{if(!(vy(C.nativeEvent)||v)){if(sy.includes(C.key)&&A){const D=C.key==="Escape";Zu({id:e,store:F,unselect:D,nodeRef:N})}else if(_&&p.selected&&Object.prototype.hasOwnProperty.call(Ea,C.key)){C.preventDefault();const{ariaLabelConfig:D}=F.getState();F.setState({ariaLiveMessage:D["node.a11yDescription.ariaLiveMessage"]({direction:C.key.replace("Arrow","").toLowerCase(),x:~~w.positionAbsolute.x,y:~~w.positionAbsolute.y})}),R({direction:Ea[C.key],factor:C.shiftKey?4:1})}}},ee=()=>{var G;if(v||!((G=N.current)!=null&&G.matches(":focus-visible")))return;const{transform:C,width:D,height:Z,autoPanOnNodeFocus:Y,setCenter:X}=F.getState();if(!Y)return;dd(new Map([[e,p]]),{x:0,y:0,width:D,height:Z},C,!0).length>0||X(p.position.x+O.width/2,p.position.y+O.height/2,{zoom:C[2]})};return g.jsx("div",{className:De(["react-flow__node",`react-flow__node-${k}`,{[f]:_},p.className,{selected:p.selected,selectable:A,parent:b,draggable:_,dragging:P}]),ref:N,style:{zIndex:w.z,transform:`translate(${w.positionAbsolute.x}px,${w.positionAbsolute.y}px)`,pointerEvents:M?"all":"none",visibility:B?"visible":"hidden",...p.style,...j},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:I,onMouseMove:z,onMouseLeave:H,onContextMenu:ne,onClick:U,onDoubleClick:Q,onKeyDown:$?J:void 0,tabIndex:$?0:void 0,onFocus:$?ee:void 0,role:p.ariaRole??($?"group":void 0),"aria-roledescription":"node","aria-describedby":v?void 0:`${Fy}-${x}`,"aria-label":p.ariaLabel,...p.domAttributes,children:g.jsx($N,{value:e,children:g.jsx(E,{id:e,data:p.data,type:k,positionAbsoluteX:w.positionAbsolute.x,positionAbsoluteY:w.positionAbsolute.y,selected:p.selected??!1,selectable:A,draggable:_,deletable:p.deletable??!0,isConnectable:L,sourcePosition:p.sourcePosition,targetPosition:p.targetPosition,dragging:P,dragHandle:p.dragHandle,zIndex:w.z,parentId:p.parentId,...O})})})}var e_=T.memo(JN);const t_=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Qy(e){const{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:o}=ge(t_,Le),s=qN(e.onlyRenderVisibleElements),i=ZN();return g.jsx("div",{className:"react-flow__nodes",style:tl,children:s.map(a=>g.jsx(e_,{id:a,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:i,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:o},a))})}Qy.displayName="NodeRenderer";const n_=T.memo(Qy);function r_(e){return ge(T.useCallback(n=>{if(!e)return n.edges.map(o=>o.id);const r=[];if(n.width&&n.height)for(const o of n.edges){const s=n.nodeLookup.get(o.source),i=n.nodeLookup.get(o.target);s&&i&&Pb({sourceNode:s,targetNode:i,width:n.width,height:n.height,transform:n.transform})&&r.push(o.id)}return r},[e]),Le)}const o_=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e}};return g.jsx("polyline",{className:"arrow",style:n,strokeLinecap:"round",fill:"none",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4"})},s_=({color:e="none",strokeWidth:t=1})=>{const n={strokeWidth:t,...e&&{stroke:e,fill:e}};return g.jsx("polyline",{className:"arrowclosed",style:n,strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"})},zh={[ks.Arrow]:o_,[ks.ArrowClosed]:s_};function i_(e){const t=Ae();return T.useMemo(()=>{var o,s;return Object.prototype.hasOwnProperty.call(zh,e)?zh[e]:((s=(o=t.getState()).onError)==null||s.call(o,"009",Xt.error009(e)),null)},[e])}const a_=({id:e,type:t,color:n,width:r=12.5,height:o=12.5,markerUnits:s="strokeWidth",strokeWidth:i,orient:a="auto-start-reverse"})=>{const l=i_(t);return l?g.jsx("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${o}`,viewBox:"-10 -10 20 20",markerUnits:s,orient:a,refX:"0",refY:"0",children:g.jsx(l,{color:n,strokeWidth:i})}):null},Jy=({defaultColor:e,rfId:t})=>{const n=ge(s=>s.edges),r=ge(s=>s.defaultEdgeOptions),o=T.useMemo(()=>Vb(n,{id:t,defaultColor:e,defaultMarkerStart:r==null?void 0:r.markerStart,defaultMarkerEnd:r==null?void 0:r.markerEnd}),[n,r,t,e]);return o.length?g.jsx("svg",{className:"react-flow__marker","aria-hidden":"true",children:g.jsx("defs",{children:o.map(s=>g.jsx(a_,{id:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient},s.id))})}):null};Jy.displayName="MarkerDefinitions";var l_=T.memo(Jy);function e0({x:e,y:t,label:n,labelStyle:r,labelShowBg:o=!0,labelBgStyle:s,labelBgPadding:i=[2,4],labelBgBorderRadius:a=2,children:l,className:u,...c}){const[d,h]=T.useState({x:1,y:0,width:0,height:0}),f=De(["react-flow__edge-textwrapper",u]),v=T.useRef(null);return T.useEffect(()=>{if(v.current){const x=v.current.getBBox();h({x:x.x,y:x.y,width:x.width,height:x.height})}},[n]),n?g.jsxs("g",{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:f,visibility:d.width?"visible":"hidden",...c,children:[o&&g.jsx("rect",{width:d.width+2*i[0],x:-i[0],y:-i[1],height:d.height+2*i[1],className:"react-flow__edge-textbg",style:s,rx:a,ry:a}),g.jsx("text",{className:"react-flow__edge-text",y:d.height/2,dy:"0.3em",ref:v,style:r,children:n}),l]}):null}e0.displayName="EdgeText";const u_=T.memo(e0);function Fs({path:e,labelX:t,labelY:n,label:r,labelStyle:o,labelShowBg:s,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:l,interactionWidth:u=20,...c}){return g.jsxs(g.Fragment,{children:[g.jsx("path",{...c,d:e,fill:"none",className:De(["react-flow__edge-path",c.className])}),u?g.jsx("path",{d:e,fill:"none",strokeOpacity:0,strokeWidth:u,className:"react-flow__edge-interaction"}):null,r&&Ut(t)&&Ut(n)?g.jsx(u_,{x:t,y:n,label:r,labelStyle:o,labelShowBg:s,labelBgStyle:i,labelBgPadding:a,labelBgBorderRadius:l}):null]})}function Dh({pos:e,x1:t,y1:n,x2:r,y2:o}){return e===ie.Left||e===ie.Right?[.5*(t+r),n]:[t,.5*(n+o)]}function t0({sourceX:e,sourceY:t,sourcePosition:n=ie.Bottom,targetX:r,targetY:o,targetPosition:s=ie.Top}){const[i,a]=Dh({pos:n,x1:e,y1:t,x2:r,y2:o}),[l,u]=Dh({pos:s,x1:r,y1:o,x2:e,y2:t}),[c,d,h,f]=xy({sourceX:e,sourceY:t,targetX:r,targetY:o,sourceControlX:i,sourceControlY:a,targetControlX:l,targetControlY:u});return[`M${e},${t} C${i},${a} ${l},${u} ${r},${o}`,c,d,h,f]}function n0(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,sourcePosition:i,targetPosition:a,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:v,markerEnd:x,markerStart:S,interactionWidth:y})=>{const[m,p,w]=t0({sourceX:n,sourceY:r,sourcePosition:i,targetX:o,targetY:s,targetPosition:a}),b=e.isInternal?void 0:t;return g.jsx(Fs,{id:b,path:m,labelX:p,labelY:w,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:v,markerEnd:x,markerStart:S,interactionWidth:y})})}const c_=n0({isInternal:!1}),r0=n0({isInternal:!0});c_.displayName="SimpleBezierEdge";r0.displayName="SimpleBezierEdgeInternal";function o0(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,sourcePosition:f=ie.Bottom,targetPosition:v=ie.Top,markerEnd:x,markerStart:S,pathOptions:y,interactionWidth:m})=>{const[p,w,b]=ba({sourceX:n,sourceY:r,sourcePosition:f,targetX:o,targetY:s,targetPosition:v,borderRadius:y==null?void 0:y.borderRadius,offset:y==null?void 0:y.offset,stepPosition:y==null?void 0:y.stepPosition}),k=e.isInternal?void 0:t;return g.jsx(Fs,{id:k,path:p,labelX:w,labelY:b,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:x,markerStart:S,interactionWidth:m})})}const s0=o0({isInternal:!1}),i0=o0({isInternal:!0});s0.displayName="SmoothStepEdge";i0.displayName="SmoothStepEdgeInternal";function a0(e){return T.memo(({id:t,...n})=>{var o;const r=e.isInternal?void 0:t;return g.jsx(s0,{...n,id:r,pathOptions:T.useMemo(()=>{var s;return{borderRadius:0,offset:(s=n.pathOptions)==null?void 0:s.offset}},[(o=n.pathOptions)==null?void 0:o.offset])})})}const d_=a0({isInternal:!1}),l0=a0({isInternal:!0});d_.displayName="StepEdge";l0.displayName="StepEdgeInternal";function u0(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:v,interactionWidth:x})=>{const[S,y,m]=Sy({sourceX:n,sourceY:r,targetX:o,targetY:s}),p=e.isInternal?void 0:t;return g.jsx(Fs,{id:p,path:S,labelX:y,labelY:m,label:i,labelStyle:a,labelShowBg:l,labelBgStyle:u,labelBgPadding:c,labelBgBorderRadius:d,style:h,markerEnd:f,markerStart:v,interactionWidth:x})})}const f_=u0({isInternal:!1}),c0=u0({isInternal:!0});f_.displayName="StraightEdge";c0.displayName="StraightEdgeInternal";function d0(e){return T.memo(({id:t,sourceX:n,sourceY:r,targetX:o,targetY:s,sourcePosition:i=ie.Bottom,targetPosition:a=ie.Top,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:v,markerEnd:x,markerStart:S,pathOptions:y,interactionWidth:m})=>{const[p,w,b]=gd({sourceX:n,sourceY:r,sourcePosition:i,targetX:o,targetY:s,targetPosition:a,curvature:y==null?void 0:y.curvature}),k=e.isInternal?void 0:t;return g.jsx(Fs,{id:k,path:p,labelX:w,labelY:b,label:l,labelStyle:u,labelShowBg:c,labelBgStyle:d,labelBgPadding:h,labelBgBorderRadius:f,style:v,markerEnd:x,markerStart:S,interactionWidth:m})})}const h_=d0({isInternal:!1}),f0=d0({isInternal:!0});h_.displayName="BezierEdge";f0.displayName="BezierEdgeInternal";const Fh={default:f0,straight:c0,step:l0,smoothstep:i0,simplebezier:r0},Bh={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},p_=(e,t,n)=>n===ie.Left?e-t:n===ie.Right?e+t:e,g_=(e,t,n)=>n===ie.Top?e-t:n===ie.Bottom?e+t:e,Hh="react-flow__edgeupdater";function Uh({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:o,onMouseEnter:s,onMouseOut:i,type:a}){return g.jsx("circle",{onMouseDown:o,onMouseEnter:s,onMouseOut:i,className:De([Hh,`${Hh}-${a}`]),cx:p_(t,r,e),cy:g_(n,r,e),r,stroke:"transparent",fill:"transparent"})}function m_({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:o,targetX:s,targetY:i,sourcePosition:a,targetPosition:l,onReconnect:u,onReconnectStart:c,onReconnectEnd:d,setReconnecting:h,setUpdateHover:f}){const v=Ae(),x=(w,b)=>{if(w.button!==0)return;const{autoPanOnConnect:k,domNode:E,connectionMode:_,connectionRadius:A,lib:L,onConnectStart:$,cancelConnection:F,nodeLookup:B,rfId:N,panBy:P,updateConnection:R}=v.getState(),O=b.type==="target",j=(z,H)=>{h(!1),d==null||d(z,n,b.type,H)},M=z=>u==null?void 0:u(n,z),I=(z,H)=>{h(!0),c==null||c(w,n,b.type),$==null||$(z,H)};Ku.onPointerDown(w.nativeEvent,{autoPanOnConnect:k,connectionMode:_,connectionRadius:A,domNode:E,handleId:b.id,nodeId:b.nodeId,nodeLookup:B,isTarget:O,edgeUpdaterType:b.type,lib:L,flowId:N,cancelConnection:F,panBy:P,isValidConnection:(...z)=>{var H,ne;return((ne=(H=v.getState()).isValidConnection)==null?void 0:ne.call(H,...z))??!0},onConnect:M,onConnectStart:I,onConnectEnd:(...z)=>{var H,ne;return(ne=(H=v.getState()).onConnectEnd)==null?void 0:ne.call(H,...z)},onReconnectEnd:j,updateConnection:R,getTransform:()=>v.getState().transform,getFromHandle:()=>v.getState().connection.fromHandle,dragThreshold:v.getState().connectionDragThreshold,handleDomNode:w.currentTarget})},S=w=>x(w,{nodeId:n.target,id:n.targetHandle??null,type:"target"}),y=w=>x(w,{nodeId:n.source,id:n.sourceHandle??null,type:"source"}),m=()=>f(!0),p=()=>f(!1);return g.jsxs(g.Fragment,{children:[(e===!0||e==="source")&&g.jsx(Uh,{position:a,centerX:r,centerY:o,radius:t,onMouseDown:S,onMouseEnter:m,onMouseOut:p,type:"source"}),(e===!0||e==="target")&&g.jsx(Uh,{position:l,centerX:s,centerY:i,radius:t,onMouseDown:y,onMouseEnter:m,onMouseOut:p,type:"target"})]})}function y_({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:o,onDoubleClick:s,onContextMenu:i,onMouseEnter:a,onMouseMove:l,onMouseLeave:u,reconnectRadius:c,onReconnect:d,onReconnectStart:h,onReconnectEnd:f,rfId:v,edgeTypes:x,noPanClassName:S,onError:y,disableKeyboardA11y:m}){let p=ge(X=>X.edgeLookup.get(e));const w=ge(X=>X.defaultEdgeOptions);p=w?{...w,...p}:p;let b=p.type||"default",k=(x==null?void 0:x[b])||Fh[b];k===void 0&&(y==null||y("011",Xt.error011(b)),b="default",k=(x==null?void 0:x.default)||Fh.default);const E=!!(p.focusable||t&&typeof p.focusable>"u"),_=typeof d<"u"&&(p.reconnectable||n&&typeof p.reconnectable>"u"),A=!!(p.selectable||r&&typeof p.selectable>"u"),L=T.useRef(null),[$,F]=T.useState(!1),[B,N]=T.useState(!1),P=Ae(),{zIndex:R=p.zIndex,sourceX:O,sourceY:j,targetX:M,targetY:I,sourcePosition:z,targetPosition:H}=ge(T.useCallback(X=>{const V=X.nodeLookup.get(p.source),G=X.nodeLookup.get(p.target);if(!V||!G)return Bh;const re=Ub({id:e,sourceNode:V,targetNode:G,sourceHandle:p.sourceHandle||null,targetHandle:p.targetHandle||null,connectionMode:X.connectionMode,onError:y}),ae=Lb({selected:p.selected,zIndex:p.zIndex,sourceNode:V,targetNode:G,elevateOnSelect:X.elevateEdgesOnSelect,zIndexMode:X.zIndexMode});return{...re||Bh,zIndex:ae}},[p.source,p.target,p.sourceHandle,p.targetHandle,p.selected,p.zIndex,y]),Le),ne=T.useMemo(()=>p.markerStart?`url('#${Xu(p.markerStart,v)}')`:void 0,[p.markerStart,v]),Q=T.useMemo(()=>p.markerEnd?`url('#${Xu(p.markerEnd,v)}')`:void 0,[p.markerEnd,v]);if(p.hidden||O===null||j===null||M===null||I===null)return null;const U=X=>{var ae;const{addSelectedEdges:V,unselectNodesAndEdges:G,multiSelectionActive:re}=P.getState();A&&(P.setState({nodesSelectionActive:!1}),p.selected&&re?(G({nodes:[],edges:[p]}),(ae=L.current)==null||ae.blur()):V([e])),o&&o(X,p)},J=s?X=>{s(X,{...p})}:void 0,ee=i?X=>{i(X,{...p})}:void 0,C=a?X=>{a(X,{...p})}:void 0,D=l?X=>{l(X,{...p})}:void 0,Z=u?X=>{u(X,{...p})}:void 0,Y=X=>{var V;if(!m&&sy.includes(X.key)&&A){const{unselectNodesAndEdges:G,addSelectedEdges:re}=P.getState();X.key==="Escape"?((V=L.current)==null||V.blur(),G({edges:[p]})):re([e])}};return g.jsx("svg",{style:{zIndex:R},children:g.jsxs("g",{className:De(["react-flow__edge",`react-flow__edge-${b}`,p.className,S,{selected:p.selected,animated:p.animated,inactive:!A&&!o,updating:$,selectable:A}]),onClick:U,onDoubleClick:J,onContextMenu:ee,onMouseEnter:C,onMouseMove:D,onMouseLeave:Z,onKeyDown:E?Y:void 0,tabIndex:E?0:void 0,role:p.ariaRole??(E?"group":"img"),"aria-roledescription":"edge","data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":p.ariaLabel===null?void 0:p.ariaLabel||`Edge from ${p.source} to ${p.target}`,"aria-describedby":E?`${By}-${v}`:void 0,ref:L,...p.domAttributes,children:[!B&&g.jsx(k,{id:e,source:p.source,target:p.target,type:p.type,selected:p.selected,animated:p.animated,selectable:A,deletable:p.deletable??!0,label:p.label,labelStyle:p.labelStyle,labelShowBg:p.labelShowBg,labelBgStyle:p.labelBgStyle,labelBgPadding:p.labelBgPadding,labelBgBorderRadius:p.labelBgBorderRadius,sourceX:O,sourceY:j,targetX:M,targetY:I,sourcePosition:z,targetPosition:H,data:p.data,style:p.style,sourceHandleId:p.sourceHandle,targetHandleId:p.targetHandle,markerStart:ne,markerEnd:Q,pathOptions:"pathOptions"in p?p.pathOptions:void 0,interactionWidth:p.interactionWidth}),_&&g.jsx(m_,{edge:p,isReconnectable:_,reconnectRadius:c,onReconnect:d,onReconnectStart:h,onReconnectEnd:f,sourceX:O,sourceY:j,targetX:M,targetY:I,sourcePosition:z,targetPosition:H,setUpdateHover:F,setReconnecting:N})]})})}var v_=T.memo(y_);const w_=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function h0({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:o,onReconnect:s,onEdgeContextMenu:i,onEdgeMouseEnter:a,onEdgeMouseMove:l,onEdgeMouseLeave:u,onEdgeClick:c,reconnectRadius:d,onEdgeDoubleClick:h,onReconnectStart:f,onReconnectEnd:v,disableKeyboardA11y:x}){const{edgesFocusable:S,edgesReconnectable:y,elementsSelectable:m,onError:p}=ge(w_,Le),w=r_(t);return g.jsxs("div",{className:"react-flow__edges",children:[g.jsx(l_,{defaultColor:e,rfId:n}),w.map(b=>g.jsx(v_,{id:b,edgesFocusable:S,edgesReconnectable:y,elementsSelectable:m,noPanClassName:o,onReconnect:s,onContextMenu:i,onMouseEnter:a,onMouseMove:l,onMouseLeave:u,onClick:c,reconnectRadius:d,onDoubleClick:h,onReconnectStart:f,onReconnectEnd:v,rfId:n,onError:p,edgeTypes:r,disableKeyboardA11y:x},b))]})}h0.displayName="EdgeRenderer";const x_=T.memo(h0),Vh=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function k_({children:e}){const t=Ae(),n=T.useRef(null),[r]=T.useState(()=>t.getState().transform);return Wy(()=>{let o=null;const s=()=>{const i=t.getState().transform;o&&i[0]===o[0]&&i[1]===o[1]&&i[2]===o[2]||(o=i,n.current&&(n.current.style.transform=Vh(i)))};return s(),t.subscribe(s)},[t]),g.jsx("div",{ref:n,className:"react-flow__viewport xyflow__viewport react-flow__container",style:{transform:Vh(r)},children:e})}function S_(e){const t=Ds(),n=T.useRef(!1);T.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const b_=e=>{var t;return(t=e.panZoom)==null?void 0:t.syncViewport};function E_(e){const t=ge(b_),n=Ae();return T.useEffect(()=>{e&&(t==null||t(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function N_(e){return e.connection.inProgress?{...e.connection,to:Os(e.connection.to,e.transform)}:{...e.connection}}function __(e){return N_}function C_(e){const t=__();return ge(t,Le)}const A_=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function M_({containerStyle:e,style:t,type:n,component:r}){const{nodesConnectable:o,width:s,height:i,isValid:a,inProgress:l}=ge(A_,Le);return!(s&&o&&l)?null:g.jsx("svg",{style:e,width:s,height:i,className:"react-flow__connectionline react-flow__container",children:g.jsx("g",{className:De(["react-flow__connection",my(a)]),children:g.jsx(p0,{style:t,type:n,CustomComponent:r,isValid:a})})})}const p0=({style:e,type:t=On.Bezier,CustomComponent:n,isValid:r})=>{const{inProgress:o,from:s,fromNode:i,fromHandle:a,fromPosition:l,to:u,toNode:c,toHandle:d,toPosition:h,pointer:f}=C_();if(!o)return;if(n)return g.jsx(n,{connectionLineType:t,connectionLineStyle:e,fromNode:i,fromHandle:a,fromX:s.x,fromY:s.y,toX:u.x,toY:u.y,fromPosition:l,toPosition:h,connectionStatus:my(r),toNode:c,toHandle:d,pointer:f});let v="";const x={sourceX:s.x,sourceY:s.y,sourcePosition:l,targetX:u.x,targetY:u.y,targetPosition:h};switch(t){case On.Bezier:[v]=gd(x);break;case On.SimpleBezier:[v]=t0(x);break;case On.Step:[v]=ba({...x,borderRadius:0});break;case On.SmoothStep:[v]=ba(x);break;default:[v]=Sy(x)}return g.jsx("path",{d:v,fill:"none",className:"react-flow__connection-path",style:e})};p0.displayName="ConnectionLine";const j_={};function Wh(e=j_){T.useRef(e),Ae(),T.useEffect(()=>{},[e])}function T_(){Ae(),T.useRef(!1),T.useEffect(()=>{},[])}function g0({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:o,onNodeDoubleClick:s,onEdgeDoubleClick:i,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:u,onNodeContextMenu:c,onSelectionContextMenu:d,onSelectionStart:h,onSelectionEnd:f,connectionLineType:v,connectionLineStyle:x,connectionLineComponent:S,connectionLineContainerStyle:y,selectionKeyCode:m,selectionOnDrag:p,selectionMode:w,multiSelectionKeyCode:b,panActivationKeyCode:k,zoomActivationKeyCode:E,deleteKeyCode:_,onlyRenderVisibleElements:A,elementsSelectable:L,defaultViewport:$,translateExtent:F,minZoom:B,maxZoom:N,preventScrolling:P,defaultMarkerColor:R,zoomOnScroll:O,zoomOnPinch:j,panOnScroll:M,panOnScrollSpeed:I,panOnScrollMode:z,zoomOnDoubleClick:H,panOnDrag:ne,autoPanOnSelection:Q,onPaneClick:U,onPaneMouseEnter:J,onPaneMouseMove:ee,onPaneMouseLeave:C,onPaneScroll:D,onPaneContextMenu:Z,paneClickDistance:Y,nodeClickDistance:X,onEdgeContextMenu:V,onEdgeMouseEnter:G,onEdgeMouseMove:re,onEdgeMouseLeave:ae,reconnectRadius:de,onReconnect:Fe,onReconnectStart:We,onReconnectEnd:Ge,noDragClassName:rt,noWheelClassName:fe,noPanClassName:wt,disableKeyboardA11y:W,nodeExtent:te,rfId:ce,viewport:ue,onViewportChange:pe,nodesDraggable:oe}){return Wh(e),Wh(t),T_(),S_(n),E_(ue),g.jsx(YN,{onPaneClick:U,onPaneMouseEnter:J,onPaneMouseMove:ee,onPaneMouseLeave:C,onPaneContextMenu:Z,onPaneScroll:D,paneClickDistance:Y,deleteKeyCode:_,selectionKeyCode:m,selectionOnDrag:p,selectionMode:w,onSelectionStart:h,onSelectionEnd:f,multiSelectionKeyCode:b,panActivationKeyCode:k,zoomActivationKeyCode:E,elementsSelectable:L,zoomOnScroll:O,zoomOnPinch:j,zoomOnDoubleClick:H,panOnScroll:M,panOnScrollSpeed:I,panOnScrollMode:z,panOnDrag:ne,autoPanOnSelection:Q,defaultViewport:$,translateExtent:F,minZoom:B,maxZoom:N,onSelectionContextMenu:d,preventScrolling:P,noDragClassName:rt,noWheelClassName:fe,noPanClassName:wt,disableKeyboardA11y:W,onViewportChange:pe,isControlledViewport:!!ue,children:g.jsxs(k_,{children:[g.jsx(x_,{edgeTypes:t,onEdgeClick:o,onEdgeDoubleClick:i,onReconnect:Fe,onReconnectStart:We,onReconnectEnd:Ge,onlyRenderVisibleElements:A,onEdgeContextMenu:V,onEdgeMouseEnter:G,onEdgeMouseMove:re,onEdgeMouseLeave:ae,reconnectRadius:de,defaultMarkerColor:R,noPanClassName:wt,disableKeyboardA11y:W,rfId:ce}),g.jsx(M_,{style:x,type:v,component:S,containerStyle:y}),g.jsx("div",{className:"react-flow__edgelabel-renderer"}),g.jsx(n_,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:s,onNodeMouseEnter:a,onNodeMouseMove:l,onNodeMouseLeave:u,onNodeContextMenu:c,nodeClickDistance:X,onlyRenderVisibleElements:A,noPanClassName:wt,noDragClassName:rt,disableKeyboardA11y:W,nodeExtent:te,rfId:ce,nodesDraggable:oe}),g.jsx("div",{className:"react-flow__viewport-portal"})]})})}g0.displayName="GraphView";const $_=T.memo(g0),I_=hy(),Gh=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:l=.5,maxZoom:u=2,nodeOrigin:c,nodeExtent:d,zIndexMode:h="basic"}={})=>{const f=new Map,v=new Map,x=new Map,S=new Map,y=r??t??[],m=n??e??[],p=c??[0,0],w=d??ws;Ny(x,S,y);const{nodesInitialized:b}=qu(m,f,v,{nodeOrigin:p,nodeExtent:w,zIndexMode:h});let k=[0,0,1];if(i&&o&&s){const E=Ls(f,{filter:$=>!!(($.width||$.initialWidth)&&($.height||$.initialHeight))}),{x:_,y:A,zoom:L}=hd(E,o,s,l,u,(a==null?void 0:a.padding)??.1);k=[_,A,L]}return{rfId:"1",width:o??0,height:s??0,transform:k,nodes:m,nodesInitialized:b,nodeLookup:f,parentLookup:v,edges:y,edgeLookup:S,connectionLookup:x,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:l,maxZoom:u,translateExtent:ws,nodeExtent:w,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:co.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:p,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:i??!1,fitViewOptions:a,fitViewResolver:null,connection:{...ay},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:I_,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:"react",debug:!1,ariaLabelConfig:iy,zIndexMode:h,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}},R_=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:l,maxZoom:u,nodeOrigin:c,nodeExtent:d,zIndexMode:h})=>GE((f,v)=>{async function x(){const{nodeLookup:S,panZoom:y,fitViewOptions:m,fitViewResolver:p,width:w,height:b,minZoom:k,maxZoom:E}=v();y&&(await Ab({nodes:S,width:w,height:b,panZoom:y,minZoom:k,maxZoom:E},m),p==null||p.resolve(!0),f({fitViewResolver:null}))}return{...Gh({nodes:e,edges:t,width:o,height:s,fitView:i,fitViewOptions:a,minZoom:l,maxZoom:u,nodeOrigin:c,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:h}),setNodes:S=>{const{nodeLookup:y,parentLookup:m,nodeOrigin:p,nodeExtent:w,elevateNodesOnSelect:b,fitViewQueued:k,zIndexMode:E,nodesSelectionActive:_}=v(),{nodesInitialized:A,hasSelectedNodes:L}=qu(S,y,m,{nodeOrigin:p,nodeExtent:w,elevateNodesOnSelect:b,checkEquality:!0,zIndexMode:E}),$=_&&L;k&&A?(x(),f({nodes:S,nodesInitialized:A,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:$})):f({nodes:S,nodesInitialized:A,nodesSelectionActive:$})},setEdges:S=>{const{connectionLookup:y,edgeLookup:m}=v();Ny(y,m,S),f({edges:S})},setDefaultNodesAndEdges:(S,y)=>{if(S){const{setNodes:m}=v();m(S),f({hasDefaultNodes:!0})}if(y){const{setEdges:m}=v();m(y),f({hasDefaultEdges:!0})}},updateNodeInternals:S=>{const{triggerNodeChanges:y,nodeLookup:m,parentLookup:p,domNode:w,nodeOrigin:b,nodeExtent:k,debug:E,fitViewQueued:_,zIndexMode:A}=v(),{changes:L,updatedInternals:$}=Zb(S,m,p,w,b,k,A);$&&(Yb(m,p,{nodeOrigin:b,nodeExtent:k,zIndexMode:A}),_?(x(),f({fitViewQueued:!1,fitViewOptions:void 0})):f({}),(L==null?void 0:L.length)>0&&(E&&console.log("React Flow: trigger node changes",L),y==null||y(L)))},updateNodePositions:(S,y=!1)=>{const m=[];let p=[];const{nodeLookup:w,triggerNodeChanges:b,connection:k,updateConnection:E,onNodesChangeMiddlewareMap:_}=v();for(const[A,L]of S){const $=w.get(A),F=!!($!=null&&$.expandParent&&($!=null&&$.parentId)&&(L!=null&&L.position)),B={id:A,type:"position",position:F?{x:Math.max(0,L.position.x),y:Math.max(0,L.position.y)}:L.position,dragging:y};if($&&k.inProgress&&k.fromNode.id===$.id){const N=Cr($,k.fromHandle,ie.Left,!0);E({...k,from:N})}F&&$.parentId&&m.push({id:A,parentId:$.parentId,rect:{...L.internals.positionAbsolute,width:L.measured.width??0,height:L.measured.height??0}}),p.push(B)}if(m.length>0){const{parentLookup:A,nodeOrigin:L}=v(),$=xd(m,w,A,L);p.push(...$)}for(const A of _.values())p=A(p);b(p)},triggerNodeChanges:S=>{const{onNodesChange:y,setNodes:m,nodes:p,hasDefaultNodes:w,debug:b}=v();if(S!=null&&S.length){if(w){const k=hN(S,p);m(k)}b&&console.log("React Flow: trigger node changes",S),y==null||y(S)}},triggerEdgeChanges:S=>{const{onEdgesChange:y,setEdges:m,edges:p,hasDefaultEdges:w,debug:b}=v();if(S!=null&&S.length){if(w){const k=pN(S,p);m(k)}b&&console.log("React Flow: trigger edge changes",S),y==null||y(S)}},addSelectedNodes:S=>{const{multiSelectionActive:y,edgeLookup:m,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:b}=v();if(y){const k=S.map(E=>or(E,!0));w(k);return}w(Gr(p,new Set([...S]),!0)),b(Gr(m))},addSelectedEdges:S=>{const{multiSelectionActive:y,edgeLookup:m,nodeLookup:p,triggerNodeChanges:w,triggerEdgeChanges:b}=v();if(y){const k=S.map(E=>or(E,!0));b(k);return}b(Gr(m,new Set([...S]))),w(Gr(p,new Set,!0))},unselectNodesAndEdges:({nodes:S,edges:y}={})=>{const{edges:m,nodes:p,nodeLookup:w,triggerNodeChanges:b,triggerEdgeChanges:k}=v(),E=S||p,_=y||m,A=[];for(const $ of E){if(!$.selected)continue;const F=w.get($.id);F&&(F.selected=!1),A.push(or($.id,!1))}const L=[];for(const $ of _)$.selected&&L.push(or($.id,!1));b(A),k(L)},setMinZoom:S=>{const{panZoom:y,maxZoom:m}=v();y==null||y.setScaleExtent([S,m]),f({minZoom:S})},setMaxZoom:S=>{const{panZoom:y,minZoom:m}=v();y==null||y.setScaleExtent([m,S]),f({maxZoom:S})},setTranslateExtent:S=>{var y;(y=v().panZoom)==null||y.setTranslateExtent(S),f({translateExtent:S})},resetSelectedElements:()=>{const{edges:S,nodes:y,triggerNodeChanges:m,triggerEdgeChanges:p,elementsSelectable:w}=v();if(!w)return;const b=y.reduce((E,_)=>_.selected?[...E,or(_.id,!1)]:E,[]),k=S.reduce((E,_)=>_.selected?[...E,or(_.id,!1)]:E,[]);m(b),p(k)},setNodeExtent:S=>{const{nodes:y,nodeLookup:m,parentLookup:p,nodeOrigin:w,elevateNodesOnSelect:b,nodeExtent:k,zIndexMode:E}=v();S[0][0]===k[0][0]&&S[0][1]===k[0][1]&&S[1][0]===k[1][0]&&S[1][1]===k[1][1]||(qu(y,m,p,{nodeOrigin:w,nodeExtent:S,elevateNodesOnSelect:b,checkEquality:!1,zIndexMode:E}),f({nodeExtent:S}))},panBy:S=>{const{transform:y,width:m,height:p,panZoom:w,translateExtent:b}=v();return Qb({delta:S,panZoom:w,transform:y,translateExtent:b,width:m,height:p})},setCenter:async(S,y,m)=>{const{width:p,height:w,maxZoom:b,panZoom:k}=v();if(!k)return!1;const E=typeof(m==null?void 0:m.zoom)<"u"?m.zoom:b;return await k.setViewport({x:p/2-S*E,y:w/2-y*E,zoom:E},{duration:m==null?void 0:m.duration,ease:m==null?void 0:m.ease,interpolate:m==null?void 0:m.interpolate}),!0},cancelConnection:()=>{f({connection:{...ay}})},updateConnection:S=>{f({connection:S})},reset:()=>f({...Gh()})}},Object.is);function m0({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:o,initialHeight:s,initialMinZoom:i,initialMaxZoom:a,initialFitViewOptions:l,fitView:u,nodeOrigin:c,nodeExtent:d,zIndexMode:h,children:f}){const[v]=T.useState(()=>R_({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:o,height:s,fitView:u,minZoom:i,maxZoom:a,fitViewOptions:l,nodeOrigin:c,nodeExtent:d,zIndexMode:h}));return g.jsx(YE,{value:v,children:g.jsx(wN,{children:g.jsx(RN,{children:f})})})}function L_({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:o,width:s,height:i,fitView:a,fitViewOptions:l,minZoom:u,maxZoom:c,nodeOrigin:d,nodeExtent:h,zIndexMode:f}){return T.useContext(el)?g.jsx(g.Fragment,{children:e}):g.jsx(m0,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:o,initialWidth:s,initialHeight:i,fitView:a,initialFitViewOptions:l,initialMinZoom:u,initialMaxZoom:c,nodeOrigin:d,nodeExtent:h,zIndexMode:f,children:e})}const P_={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0};function O_({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:o,nodeTypes:s,edgeTypes:i,onNodeClick:a,onEdgeClick:l,onInit:u,onMove:c,onMoveStart:d,onMoveEnd:h,onConnect:f,onConnectStart:v,onConnectEnd:x,onClickConnectStart:S,onClickConnectEnd:y,onNodeMouseEnter:m,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:b,onNodeDoubleClick:k,onNodeDragStart:E,onNodeDrag:_,onNodeDragStop:A,onNodesDelete:L,onEdgesDelete:$,onDelete:F,onSelectionChange:B,onSelectionDragStart:N,onSelectionDrag:P,onSelectionDragStop:R,onSelectionContextMenu:O,onSelectionStart:j,onSelectionEnd:M,onBeforeDelete:I,connectionMode:z,connectionLineType:H=On.Bezier,connectionLineStyle:ne,connectionLineComponent:Q,connectionLineContainerStyle:U,deleteKeyCode:J="Backspace",selectionKeyCode:ee="Shift",selectionOnDrag:C=!1,selectionMode:D=xs.Full,panActivationKeyCode:Z="Space",multiSelectionKeyCode:Y=bs()?"Meta":"Control",zoomActivationKeyCode:X=bs()?"Meta":"Control",snapToGrid:V,snapGrid:G,onlyRenderVisibleElements:re=!1,selectNodesOnDrag:ae,nodesDraggable:de,autoPanOnNodeFocus:Fe,nodesConnectable:We,nodesFocusable:Ge,nodeOrigin:rt=Hy,edgesFocusable:fe,edgesReconnectable:wt,elementsSelectable:W=!0,defaultViewport:te=iN,minZoom:ce=.5,maxZoom:ue=2,translateExtent:pe=ws,preventScrolling:oe=!0,nodeExtent:le,defaultMarkerColor:xe="#b1b1b7",zoomOnScroll:me=!0,zoomOnPinch:ke=!0,panOnScroll:Me=!1,panOnScrollSpeed:ot=.5,panOnScrollMode:st=hr.Free,zoomOnDoubleClick:Ne=!0,panOnDrag:Zt=!0,onPaneClick:Qt,onPaneMouseEnter:Jn,onPaneMouseMove:q,onPaneMouseLeave:ve,onPaneScroll:we,onPaneContextMenu:Te,paneClickDistance:it=1,nodeClickDistance:xt=0,children:Jt,onReconnect:er,onReconnectStart:fn,onReconnectEnd:Cn,onEdgeContextMenu:Ws,onEdgeDoubleClick:Gs,onEdgeMouseEnter:Ys,onEdgeMouseMove:Xs,onEdgeMouseLeave:ko,reconnectRadius:B0=10,onNodesChange:H0,onEdgesChange:U0,noDragClassName:V0="nodrag",noWheelClassName:W0="nowheel",noPanClassName:Nd="nopan",fitView:_d,fitViewOptions:Cd,connectOnClick:G0,attributionPosition:Y0,proOptions:X0,defaultEdgeOptions:q0,elevateNodesOnSelect:K0=!0,elevateEdgesOnSelect:Z0=!1,disableKeyboardA11y:Ad=!1,autoPanOnConnect:Q0,autoPanOnNodeDrag:J0,autoPanOnSelection:ev=!0,autoPanSpeed:tv,connectionRadius:nv,isValidConnection:rv,onError:ov,style:sv,id:Md,nodeDragThreshold:iv,connectionDragThreshold:av,viewport:lv,onViewportChange:uv,width:cv,height:dv,colorMode:fv="light",debug:hv,onScroll:qs,ariaLabelConfig:pv,zIndexMode:jd="basic",...gv},mv){const al=Md||"1",yv=cN(fv),vv=T.useCallback(Td=>{Td.currentTarget.scrollTo({top:0,left:0,behavior:"instant"}),qs==null||qs(Td)},[qs]);return g.jsx("div",{"data-testid":"rf__wrapper",...gv,onScroll:vv,style:{...sv,...P_},ref:mv,className:De(["react-flow",o,yv]),id:Md,role:"application",children:g.jsxs(L_,{nodes:e,edges:t,width:cv,height:dv,fitView:_d,fitViewOptions:Cd,minZoom:ce,maxZoom:ue,nodeOrigin:rt,nodeExtent:le,zIndexMode:jd,children:[g.jsx(uN,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:f,onConnectStart:v,onConnectEnd:x,onClickConnectStart:S,onClickConnectEnd:y,nodesDraggable:de,autoPanOnNodeFocus:Fe,nodesConnectable:We,nodesFocusable:Ge,edgesFocusable:fe,edgesReconnectable:wt,elementsSelectable:W,elevateNodesOnSelect:K0,elevateEdgesOnSelect:Z0,minZoom:ce,maxZoom:ue,nodeExtent:le,onNodesChange:H0,onEdgesChange:U0,snapToGrid:V,snapGrid:G,connectionMode:z,translateExtent:pe,connectOnClick:G0,defaultEdgeOptions:q0,fitView:_d,fitViewOptions:Cd,onNodesDelete:L,onEdgesDelete:$,onDelete:F,onNodeDragStart:E,onNodeDrag:_,onNodeDragStop:A,onSelectionDrag:P,onSelectionDragStart:N,onSelectionDragStop:R,onMove:c,onMoveStart:d,onMoveEnd:h,noPanClassName:Nd,nodeOrigin:rt,rfId:al,autoPanOnConnect:Q0,autoPanOnNodeDrag:J0,autoPanSpeed:tv,onError:ov,connectionRadius:nv,isValidConnection:rv,selectNodesOnDrag:ae,nodeDragThreshold:iv,connectionDragThreshold:av,onBeforeDelete:I,debug:hv,ariaLabelConfig:pv,zIndexMode:jd}),g.jsx($_,{onInit:u,onNodeClick:a,onEdgeClick:l,onNodeMouseEnter:m,onNodeMouseMove:p,onNodeMouseLeave:w,onNodeContextMenu:b,onNodeDoubleClick:k,nodeTypes:s,edgeTypes:i,connectionLineType:H,connectionLineStyle:ne,connectionLineComponent:Q,connectionLineContainerStyle:U,selectionKeyCode:ee,selectionOnDrag:C,selectionMode:D,deleteKeyCode:J,multiSelectionKeyCode:Y,panActivationKeyCode:Z,zoomActivationKeyCode:X,onlyRenderVisibleElements:re,defaultViewport:te,translateExtent:pe,minZoom:ce,maxZoom:ue,preventScrolling:oe,zoomOnScroll:me,zoomOnPinch:ke,zoomOnDoubleClick:Ne,panOnScroll:Me,panOnScrollSpeed:ot,panOnScrollMode:st,panOnDrag:Zt,autoPanOnSelection:ev,onPaneClick:Qt,onPaneMouseEnter:Jn,onPaneMouseMove:q,onPaneMouseLeave:ve,onPaneScroll:we,onPaneContextMenu:Te,paneClickDistance:it,nodeClickDistance:xt,onSelectionContextMenu:O,onSelectionStart:j,onSelectionEnd:M,onReconnect:er,onReconnectStart:fn,onReconnectEnd:Cn,onEdgeContextMenu:Ws,onEdgeDoubleClick:Gs,onEdgeMouseEnter:Ys,onEdgeMouseMove:Xs,onEdgeMouseLeave:ko,reconnectRadius:B0,defaultMarkerColor:xe,noDragClassName:V0,noWheelClassName:W0,noPanClassName:Nd,rfId:al,disableKeyboardA11y:Ad,nodeExtent:le,viewport:lv,onViewportChange:uv,nodesDraggable:de}),g.jsx(sN,{onSelectionChange:B}),Jt,g.jsx(eN,{proOptions:X0,position:Y0}),g.jsx(JE,{rfId:al,disableKeyboardA11y:Ad})]})})}var z_=Vy(O_);const D_=e=>{var t;return(t=e.domNode)==null?void 0:t.querySelector(".react-flow__edgelabel-renderer")};function F_({children:e}){const t=ge(D_);return t?Cm.createPortal(e,t):null}function B_({dimensions:e,lineWidth:t,variant:n,className:r}){return g.jsx("path",{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:De(["react-flow__background-pattern",n,r])})}function H_({radius:e,className:t}){return g.jsx("circle",{cx:e,cy:e,r:e,className:De(["react-flow__background-pattern","dots",t])})}var xn;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(xn||(xn={}));const U_={[xn.Dots]:1,[xn.Lines]:1,[xn.Cross]:6},V_=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function y0({id:e,variant:t=xn.Dots,gap:n=20,size:r,lineWidth:o=1,offset:s=0,color:i,bgColor:a,style:l,className:u,patternClassName:c}){const d=T.useRef(null),{transform:h,patternId:f}=ge(V_,Le),v=r||U_[t],x=t===xn.Dots,S=t===xn.Cross,y=Array.isArray(n)?n:[n,n],m=[y[0]*h[2]||1,y[1]*h[2]||1],p=v*h[2],w=Array.isArray(s)?s:[s,s],b=S?[p,p]:m,k=[w[0]*h[2]+b[0]/2,w[1]*h[2]+b[1]/2],E=`${f}${e||""}`;return g.jsxs("svg",{className:De(["react-flow__background",u]),style:{...l,...tl,"--xy-background-color-props":a,"--xy-background-pattern-color-props":i},ref:d,"data-testid":"rf__background",children:[g.jsx("pattern",{id:E,x:h[0]%m[0],y:h[1]%m[1],width:m[0],height:m[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${k[0]},-${k[1]})`,children:x?g.jsx(H_,{radius:p/2,className:c}):g.jsx(B_,{dimensions:b,lineWidth:o,variant:t,className:c})}),g.jsx("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${E})`})]})}y0.displayName="Background";const W_=T.memo(y0);function G_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32",children:g.jsx("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"})})}function Y_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5",children:g.jsx("path",{d:"M0 0h32v4.2H0z"})})}function X_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30",children:g.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 q_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:g.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 K_(){return g.jsx("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32",children:g.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 ki({children:e,className:t,...n}){return g.jsx("button",{type:"button",className:De(["react-flow__controls-button",t]),...n,children:e})}const Z_=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function v0({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:o,onZoomIn:s,onZoomOut:i,onFitView:a,onInteractiveChange:l,className:u,children:c,position:d="bottom-left",orientation:h="vertical","aria-label":f}){const v=Ae(),{isInteractive:x,minZoomReached:S,maxZoomReached:y,ariaLabelConfig:m}=ge(Z_,Le),{zoomIn:p,zoomOut:w,fitView:b}=Ds(),k=()=>{p(),s==null||s()},E=()=>{w(),i==null||i()},_=()=>{b(o),a==null||a()},A=()=>{v.setState({nodesDraggable:!x,nodesConnectable:!x,elementsSelectable:!x}),l==null||l(!x)},L=h==="horizontal"?"horizontal":"vertical";return g.jsxs(zs,{className:De(["react-flow__controls",L,u]),position:d,style:e,"data-testid":"rf__controls","aria-label":f??m["controls.ariaLabel"],children:[t&&g.jsxs(g.Fragment,{children:[g.jsx(ki,{onClick:k,className:"react-flow__controls-zoomin",title:m["controls.zoomIn.ariaLabel"],"aria-label":m["controls.zoomIn.ariaLabel"],disabled:y,children:g.jsx(G_,{})}),g.jsx(ki,{onClick:E,className:"react-flow__controls-zoomout",title:m["controls.zoomOut.ariaLabel"],"aria-label":m["controls.zoomOut.ariaLabel"],disabled:S,children:g.jsx(Y_,{})})]}),n&&g.jsx(ki,{className:"react-flow__controls-fitview",onClick:_,title:m["controls.fitView.ariaLabel"],"aria-label":m["controls.fitView.ariaLabel"],children:g.jsx(X_,{})}),r&&g.jsx(ki,{className:"react-flow__controls-interactive",onClick:A,title:m["controls.interactive.ariaLabel"],"aria-label":m["controls.interactive.ariaLabel"],children:x?g.jsx(K_,{}):g.jsx(q_,{})}),c]})}v0.displayName="Controls";T.memo(v0);function Q_({id:e,x:t,y:n,width:r,height:o,style:s,color:i,strokeColor:a,strokeWidth:l,className:u,borderRadius:c,shapeRendering:d,selected:h,onClick:f}){const{background:v,backgroundColor:x}=s||{},S=i||v||x;return g.jsx("rect",{className:De(["react-flow__minimap-node",{selected:h},u]),x:t,y:n,rx:c,ry:c,width:r,height:o,style:{fill:S,stroke:a,strokeWidth:l},shapeRendering:d,onClick:f?y=>f(y,e):void 0})}const J_=T.memo(Q_),eC=e=>e.nodes.map(t=>t.id),Ul=e=>e instanceof Function?e:()=>e;function tC({nodeStrokeColor:e,nodeColor:t,nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:o,nodeComponent:s=J_,onClick:i}){const a=ge(eC,Le),l=Ul(t),u=Ul(e),c=Ul(n),d=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return g.jsx(g.Fragment,{children:a.map(h=>g.jsx(rC,{id:h,nodeColorFunc:l,nodeStrokeColorFunc:u,nodeClassNameFunc:c,nodeBorderRadius:r,nodeStrokeWidth:o,NodeComponent:s,onClick:i,shapeRendering:d},h))})}function nC({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:o,nodeStrokeWidth:s,shapeRendering:i,NodeComponent:a,onClick:l}){const{node:u,x:c,y:d,width:h,height:f}=ge(v=>{const x=v.nodeLookup.get(e);if(!x)return{node:void 0,x:0,y:0,width:0,height:0};const S=x.internals.userNode,{x:y,y:m}=x.internals.positionAbsolute,{width:p,height:w}=Kt(S);return{node:S,x:y,y:m,width:p,height:w}},Le);return!u||u.hidden||!py(u)?null:g.jsx(a,{x:c,y:d,width:h,height:f,style:u.style,selected:!!u.selected,className:r(u),color:t(u),borderRadius:o,strokeColor:n(u),strokeWidth:s,shapeRendering:i,onClick:l,id:u.id})}const rC=T.memo(nC);var oC=T.memo(tC);const sC=200,iC=150,aC=e=>!e.hidden,lC=e=>{const 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]};let n=!1;for(const r of e.nodeLookup.values())if(!r.hidden){n=!0;break}return{viewBB:t,boundingRect:n?dy(Ls(e.nodeLookup,{filter:aC}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},Yh=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,uC=(e,t)=>Yh(e.viewBB,t.viewBB)&&Yh(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,cC="react-flow__minimap-desc";function w0({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:o="",nodeBorderRadius:s=5,nodeStrokeWidth:i,nodeComponent:a,bgColor:l,maskColor:u,maskStrokeColor:c,maskStrokeWidth:d,position:h="bottom-right",onClick:f,onNodeClick:v,pannable:x=!1,zoomable:S=!1,ariaLabel:y,inversePan:m,zoomStep:p=1,offsetScale:w=5}){const b=Ae(),k=T.useRef(null),{boundingRect:E,panZoom:_,viewBB:A,rfId:L,translateExtent:$,flowWidth:F,flowHeight:B,ariaLabelConfig:N}=ge(lC,uC),P=(e==null?void 0:e.width)??sC,R=(e==null?void 0:e.height)??iC,O=E.width/P,j=E.height/R,M=Math.max(O,j),I=M*P,z=M*R,H=w*M,ne=E.x-(I-E.width)/2-H,Q=E.y-(z-E.height)/2-H,U=I+H*2,J=z+H*2,ee=`${cC}-${L}`,C=T.useRef(0),D=T.useRef();C.current=M,T.useEffect(()=>{const G=b.getState().panZoom;if(k.current&&G)return D.current=aE({domNode:k.current,panZoom:G,getTransform:()=>b.getState().transform,getViewScale:()=>C.current}),()=>{var re;(re=D.current)==null||re.destroy()}},[_]),T.useEffect(()=>{var G;(G=D.current)==null||G.update({translateExtent:$,width:F,height:B,inversePan:m,pannable:x,zoomStep:p,zoomable:S})},[x,S,m,p,$,F,B]);const Z=f?G=>{var de;const[re,ae]=((de=D.current)==null?void 0:de.pointer(G))||[0,0];f(G,{x:re,y:ae})}:void 0,Y=T.useCallback((G,re)=>{const ae=b.getState().nodeLookup.get(re).internals.userNode;v==null||v(G,ae)},[v]),X=v?Y:void 0,V=y??N["minimap.ariaLabel"];return g.jsx(zs,{position:h,style:{...e,"--xy-minimap-background-color-props":typeof l=="string"?l:void 0,"--xy-minimap-mask-background-color-props":typeof u=="string"?u:void 0,"--xy-minimap-mask-stroke-color-props":typeof c=="string"?c:void 0,"--xy-minimap-mask-stroke-width-props":typeof d=="number"?d*M:void 0,"--xy-minimap-node-background-color-props":typeof r=="string"?r:void 0,"--xy-minimap-node-stroke-color-props":typeof n=="string"?n:void 0,"--xy-minimap-node-stroke-width-props":typeof i=="number"?i:void 0},className:De(["react-flow__minimap",t]),"data-testid":"rf__minimap",children:g.jsxs("svg",{width:P,height:R,viewBox:`${ne} ${Q} ${U} ${J}`,className:"react-flow__minimap-svg",role:"img","aria-labelledby":ee,ref:k,onClick:Z,children:[V&&g.jsx("title",{id:ee,children:V}),g.jsx(oC,{onClick:X,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:s,nodeClassName:o,nodeStrokeWidth:i,nodeComponent:a}),g.jsx("path",{className:"react-flow__minimap-mask",d:`M${ne-H},${Q-H}h${U+H*2}v${J+H*2}h${-U-H*2}z
|
|
62
62
|
M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fillRule:"evenodd",pointerEvents:"none"})]})})}w0.displayName="MiniMap";T.memo(w0);const dC=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,fC={[po.Line]:"right",[po.Handle]:"bottom-right"};function hC({nodeId:e,position:t,variant:n=po.Handle,className:r,style:o=void 0,children:s,color:i,minWidth:a=10,minHeight:l=10,maxWidth:u=Number.MAX_VALUE,maxHeight:c=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:h,autoScale:f=!0,shouldResize:v,onResizeStart:x,onResize:S,onResizeEnd:y}){const m=qy(),p=typeof e=="string"?e:m,w=Ae(),b=T.useRef(null),k=n===po.Handle,E=ge(T.useCallback(dC(k&&f),[k,f]),Le),_=T.useRef(null),A=t??fC[n];T.useEffect(()=>{if(!(!b.current||!p))return _.current||(_.current=xE({domNode:b.current,nodeId:p,getStoreItems:()=>{const{nodeLookup:$,transform:F,snapGrid:B,snapToGrid:N,nodeOrigin:P,domNode:R}=w.getState();return{nodeLookup:$,transform:F,snapGrid:B,snapToGrid:N,nodeOrigin:P,paneDomNode:R}},onChange:($,F)=>{const{triggerNodeChanges:B,nodeLookup:N,parentLookup:P,nodeOrigin:R}=w.getState(),O=[],j={x:$.x,y:$.y},M=N.get(p);if(M&&M.expandParent&&M.parentId){const I=M.origin??R,z=$.width??M.measured.width??0,H=$.height??M.measured.height??0,ne={id:M.id,parentId:M.parentId,rect:{width:z,height:H,...gy({x:$.x??M.position.x,y:$.y??M.position.y},{width:z,height:H},M.parentId,N,I)}},Q=xd([ne],N,P,R);O.push(...Q),j.x=$.x?Math.max(I[0]*z,$.x):void 0,j.y=$.y?Math.max(I[1]*H,$.y):void 0}if(j.x!==void 0&&j.y!==void 0){const I={id:p,type:"position",position:{...j}};O.push(I)}if($.width!==void 0&&$.height!==void 0){const z={id:p,type:"dimensions",resizing:!0,setAttributes:h?h==="horizontal"?"width":"height":!0,dimensions:{width:$.width,height:$.height}};O.push(z)}for(const I of F){const z={...I,type:"position"};O.push(z)}B(O)},onEnd:({width:$,height:F})=>{const B={id:p,type:"dimensions",resizing:!1,dimensions:{width:$,height:F}};w.getState().triggerNodeChanges([B])}})),_.current.update({controlPosition:A,boundaries:{minWidth:a,minHeight:l,maxWidth:u,maxHeight:c},keepAspectRatio:d,resizeDirection:h,onResizeStart:x,onResize:S,onResizeEnd:y,shouldResize:v}),()=>{var $;($=_.current)==null||$.destroy()}},[A,a,l,u,c,d,x,S,y,v]);const L=A.split("-");return g.jsx("div",{className:De(["react-flow__resize-control","nodrag",...L,n,r]),ref:b,style:{...o,scale:E,...i&&{[k?"backgroundColor":"borderColor"]:i}},children:s})}T.memo(hC);function pC(){const e=new URLSearchParams(location.search).get("t");try{return e&&sessionStorage.setItem("illuminate-token",e),e??sessionStorage.getItem("illuminate-token")??""}catch{return e??""}}const yo=pC(),sn=e=>`/${e?`m/${encodeURIComponent(e)}`:""}?t=${encodeURIComponent(yo)}`,Na=e=>e.kind==="capture"?`/api/screens/${encodeURIComponent(e.capture)}.png?t=${encodeURIComponent(yo)}`:`/api/repo-image?file=${encodeURIComponent(e.file)}&t=${encodeURIComponent(yo)}`;class x0 extends Error{constructor(t,n=[]){super(t),this.problems=n}}async function Mt(e,t,n){const r=await fetch(t,{method:e,headers:{"x-illuminate-token":yo,"content-type":"application/json"},body:n===void 0?void 0:JSON.stringify(n)}),o=await r.json().catch(()=>({}));if(!r.ok)throw new x0(o.error??`Request failed (${r.status})`,o.problems??[]);return o}const Ht={list:()=>Mt("GET","/api/maps"),get:e=>Mt("GET",`/api/maps/${encodeURIComponent(e)}`),make:(e,t)=>Mt("POST","/api/maps",{question:e,parent:t}),offer:(e,t,n)=>Mt("POST",`/api/maps/${encodeURIComponent(e)}/answers/${encodeURIComponent(t)}/offer`,{choice:n}),selection:(e,t,n)=>Mt("PUT",`/api/maps/${encodeURIComponent(e)}/selection`,{selection:t,step:n}),ask:(e,t,n)=>Mt("POST",`/api/maps/${encodeURIComponent(e)}/ask`,{question:t,selection:n}),approve:(e,t)=>Mt("POST",`/api/maps/${encodeURIComponent(e)}/fixes/${encodeURIComponent(t)}/approve`),reject:(e,t)=>Mt("POST",`/api/maps/${encodeURIComponent(e)}/fixes/${encodeURIComponent(t)}/reject`),undo:(e,t)=>Mt("POST",`/api/maps/${encodeURIComponent(e)}/fixes/${encodeURIComponent(t)}/undo`),code:(e,t,n="now")=>Mt("GET",`/api/maps/${encodeURIComponent(e)}/code?item=${encodeURIComponent(t)}${n==="before"?"&when=before":""}`),answerCode:(e,t)=>Mt("GET",`/api/maps/${encodeURIComponent(e)}/answers/${encodeURIComponent(t)}/code`),stop:()=>Mt("POST","/api/stop")},gC=4e3;function k0(e,t,n,r){let o=null,s=!1,i=null;const a=()=>{o=new WebSocket(`${location.protocol==="https:"?"wss":"ws"}://${location.host}/ws?t=${encodeURIComponent(yo)}${r?`&m=${encodeURIComponent(r)}`:""}`),o.onopen=()=>t(!0),o.onmessage=l=>{try{e(JSON.parse(String(l.data)))}catch{}},o.onclose=l=>{t(!1),l.code===gC?(s=!0,n()):s||(i=setTimeout(a,1e3))}};return a(),()=>{s=!0,i&&clearTimeout(i),o==null||o.close()}}const S0={name:"Claude",asks:"page"},nl=e=>e.asks==="chat";function mC(e,t,n){return{title:`Ask in the ${e.name} chat beside this page`,detail:t?`${e.name} will see what you selected here.`:n?`${e.name} will know you're on the step “${n}”.`:`${e.name} will see what you select here.`}}function yC(e,t,n){return nl(e)?{selection:t,step:n}:null}function vC(e,t){var r;if(((r=e.offer)==null?void 0:r.status)==="pending")return!0;const n=e.fix?t[e.fix.id]:void 0;return!!n&&(n.status==="proposed"||n.status==="applying"||n.status==="failed"||n.status==="applied"&&n.undoable)}function wC(e,t,n){return nl(e)?t.filter(r=>vC(r,n)):t}const Sd=[{id:"vscode",name:"VS Code"},{id:"cursor",name:"Cursor"},{id:"windsurf",name:"Windsurf"},{id:"zed",name:"Zed"}];function xC(e,t,n,r){const o=`${t.replace(/\\/g,"/").replace(/\/+$/,"")}/${n}`;return`${e}://file${o.startsWith("/")?"":"/"}${o.split("/").map(encodeURIComponent).join("/").replace(/%3A/g,":")}:${r}`}const Xh=globalThis;Xh.Prism={...Xh.Prism??{},manual:!0,disableWorkerMessageHandler:!0};var b0={exports:{}};(function(e){var t=typeof window<"u"?window:typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?self:{};/**
|
|
63
63
|
* Prism: Lightweight, robust, elegant syntax highlighting
|
|
64
64
|
*
|
|
@@ -75,8 +75,8 @@ Error generating stack: `+s.message+`
|
|
|
75
75
|
`),n=[];let r=[];const o=()=>{r.length&&n.push({kind:"p",text:r.join(`
|
|
76
76
|
`)}),r=[]};for(let s=0;s<t.length;s++){const i=t[s];if(Kh.test(i)){o();const d=[];for(s++;s<t.length&&!Kh.test(t[s]);s++)d.push(t[s]);n.push({kind:"code",text:d.join(`
|
|
77
77
|
`)});continue}if(!i.trim()){o();continue}const a=RC.exec(i);if(a){o(),n.push({kind:"h",text:a[1]});continue}const l=LC.exec(i),u=l?null:PC.exec(i);if(l||u){o();const d=l?"ul":"ol",h=n[n.length-1],f=l?l[1]:u[2];h&&h.kind===d?h.items.push(f):n.push(d==="ul"?{kind:d,items:[f]}:{kind:d,items:[f],start:Number(u[1])});continue}const c=n[n.length-1];if(!r.length&&c&&(c.kind==="ul"||c.kind==="ol")&&/^\s+\S/.test(i)){c.items[c.items.length-1]+=` ${i.trim()}`;continue}r.push(i)}return o(),n}const zC=new RegExp("(`+)([^`]+?)\\1|\\*\\*(.+?)\\*\\*|__(.+?)__|\\*(?!\\s)(.+?)\\*|(?<![\\w])_(?!\\s)(.+?)_(?![\\w])|\\[([^\\]]+)\\]\\(([^)\\s]+)\\)","g");function ur(e,t="i"){const n=[];let r=0,o=0;const s=i=>{i.split(`
|
|
78
|
-
`).forEach((a,l)=>{l>0&&n.push(g.jsx("br",{},`${t}-br${o++}`)),a&&n.push(a)})};for(const i of e.matchAll(zC)){s(e.slice(r,i.index));const a=`${t}-${o++}`;if(i[2]!==void 0)n.push(g.jsx("code",{children:i[2]},a));else if(i[3]!==void 0||i[4]!==void 0)n.push(g.jsx("strong",{children:ur(i[3]??i[4],a)},a));else if(i[5]!==void 0||i[6]!==void 0)n.push(g.jsx("em",{children:ur(i[5]??i[6],a)},a));else if(i[7]!==void 0){const l=i[8];n.push(/^https?:\/\//i.test(l)?g.jsx("a",{href:l,target:"_blank",rel:"noreferrer",children:ur(i[7],a)},a):g.jsx("span",{children:ur(i[7],a)},a))}r=i.index+i[0].length}return s(e.slice(r)),n}function _s({text:e,className:t}){const n=OC(e);return n.length?g.jsx("div",{className:t?`md ${t}`:"md",children:n.map((r,o)=>{const s=`b${o}`;if(r.kind==="p")return g.jsx("p",{children:ur(r.text,s)},s);if(r.kind==="h")return g.jsx("p",{className:"md-h",children:ur(r.text,s)},s);if(r.kind==="code")return g.jsx("pre",{children:g.jsx("code",{children:r.text})},s);const i=r.items.map((a,l)=>g.jsx("li",{children:ur(a,`${s}-${l}`)},`${s}-${l}`));return r.kind==="ul"?g.jsx("ul",{children:i},s):g.jsx("ol",{start:r.start,children:i},s)})}):null}const DC=/^About the walkthrough step “([^”]*)”: /,FC=(e,t)=>`About the walkthrough step “${e}”: ${t}`;function BC(e){const t=DC.exec(e);return t?{question:e.slice(t[0].length),step:t[1]}:{question:e,step:null}}function HC(e,t,n,r=12){return Math.max(0,e+(n-t)-r)}function UC(e,t,n=40){return t>e-n}const VC="modulepreload",WC=function(e){return"/"+e},Zh={},GC=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),a=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=Promise.allSettled(n.map(l=>{if(l=WC(l),l in Zh)return;Zh[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":VC,u||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return o.then(i=>{for(const a of i||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})},tt=232,qe=96,YC=e=>e.view==="journey"&&[...e.nodes,...e.edges].some(t=>!!t.branch);function _a(e,t){var s;const n=((s=e.nodes[t])==null?void 0:s.y)??0,r=e.rowTops??[];let o=0;for(const[i,a]of r.entries())n>=a-1&&(o=i);return o}const XC=132;function tc(e,t=!1){return e==="choice"?{w:196,h:132}:e==="action"?{w:196,h:60}:t?{w:232,h:64+XC}:{w:196,h:72}}let qC=null;const bd=()=>qC??(qC=GC(()=>import("./elk.bundled-DRxy2Gqg.js").then(e=>e.e),[]).then(e=>new e.default)),Ca={"elk.algorithm":"layered","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"};function Bs(e,t){const n=new Set(e.nodes.map(r=>r.id));return[...e.edges.map(r=>({id:`e:${r.id}`,from:r.from,to:r.to})),...e.absences.flatMap(r=>r.between?[{id:`a:${r.id}`,from:r.between.from,to:r.between.to}]:[]),...t.map(r=>({id:`x:${r.id}`,from:r.from,to:r.to}))].filter(r=>n.has(r.from)&&n.has(r.to)&&r.from!==r.to)}const be={top:52,side:26,bottom:26},on=64,pr=44,KC=56,ZC=140;async function Ed(e,t,n,r){const o=await e.layout({id:t,layoutOptions:{...Ca,"elk.direction":"DOWN","elk.padding":`[top=${be.top},left=${be.side},bottom=${be.bottom},right=${be.side}]`,"elk.layered.spacing.nodeNodeBetweenLayers":String(on),"elk.spacing.nodeNode":String(pr)},children:n.map(i=>({id:i.id,width:tt,height:qe})),edges:r.map(i=>({id:i.id,sources:[i.from],targets:[i.to]}))}),s={};for(const i of o.children??[])s[i.id]={x:i.x??0,y:i.y??0,w:tt,h:qe};return{nodes:s,size:{w:o.width??tt+2*be.side,h:o.height??qe+be.top+be.bottom}}}function QC(e,t){const n=e.nodes.filter(o=>!t.has(o.id)),r=new Set(n.map(o=>o.id));return{...e,areas:e.areas.filter(o=>!t.has(o.id)),nodes:n,edges:e.edges.filter(o=>!t.has(o.id)&&r.has(o.from)&&r.has(o.to)),absences:e.absences.filter(o=>!t.has(o.id)&&(!o.between||r.has(o.between.from)&&r.has(o.between.to)))}}async function JC(e,t=[],n=new Set,r=new Set){if(e.view==="journey")return YC(e)?o2(e,t,r):M0(e,t,r);const o=e2(e),s=await t2(e,t,n);return o.length?{...s,branches:o}:s}function e2(e){const t=[];for(const n of[...e.nodes,...e.edges])n.branch&&!t.includes(n.branch)&&t.push(n.branch);return t}async function t2(e,t,n){var w;if(e.view==="timeline")return s2(e,t);const r=e.nodes.filter(b=>n.has(b.id));if(!r.length)return sp(e,t);const o=QC(e,n),s=new Set(o.nodes.map(b=>b.id)),i=await sp(o,t.filter(b=>s.has(b.from)&&s.has(b.to))),a=await bd(),l=Object.fromEntries(Object.entries(i.areas).map(([b,k])=>[b,{...k}])),u={...i.nodes},c={},d={};for(const b of r)(d[w=b.area]??(d[w]=[])).push(b);for(const[b,k]of Object.entries(d)){const E=l[b];if(!E)continue;const _=Math.max(1,Math.floor((E.w-2*be.side+pr)/(tt+pr))),A=Math.max(be.top-on,...o.nodes.filter($=>$.area===b).map($=>{var F;return(((F=u[$.id])==null?void 0:F.y)??0)+qe}))+on;k.forEach(($,F)=>{u[$.id]={x:be.side+F%_*(tt+pr),y:A+Math.floor(F/_)*(qe+on),w:tt,h:qe}});const L=Math.max(E.h,A+Math.ceil(k.length/_)*(qe+on)-on+be.bottom);c[b]=L-E.h,E.h=L}const h=Object.fromEntries(Object.entries(i.areas).map(([b,k])=>[b,k])),f=Object.keys(h).sort((b,k)=>h[b].y-h[k].y),v={};for(const b of f){const k=h[b];v[b]=Math.max(0,...f.filter(E=>E!==b&&v[E]!==void 0).filter(E=>{const _=h[E];return _.y+_.h<=k.y+1&&_.x<k.x+k.w&&k.x<_.x+_.w}).map(E=>v[E]+(c[E]??0))),l[b].y+=v[b]}const x=Bs(e,t),S=new Map(e.nodes.map(b=>[b.id,b.area])),y=Math.max(0,...Object.values(l).map(b=>b.x+b.w))+ZC;let m=0;for(const b of e.areas){if(l[b.id])continue;const k=e.nodes.filter(A=>A.area===b.id);if(!k.length)continue;const E=x.filter(A=>S.get(A.from)===b.id&&S.get(A.to)===b.id),_=await Ed(a,b.id,k,E);Object.assign(u,_.nodes),l[b.id]={x:y,y:m,w:_.size.w,h:_.size.h},m+=_.size.h+KC}const p=Object.values(l);return{areas:l,nodes:u,width:Math.max(0,...p.map(b=>b.x+b.w)),height:Math.max(0,...p.map(b=>b.y+b.h)),...i.rings?{rings:i.rings}:{}}}const Qh=1900,nc=130;async function M0(e,t,n){const o=await(await bd()).layout({id:"root",layoutOptions:{...Ca,"elk.direction":"RIGHT","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.spacing.nodeNodeBetweenLayers":"176","elk.spacing.nodeNode":"56","elk.spacing.componentComponent":"72"},children:e.nodes.map(f=>({id:f.id,width:tc(f.kind,n.has(f.id)).w,height:tc(f.kind,n.has(f.id)).h})),edges:Bs(e,t).map(f=>({id:f.id,sources:[f.from],targets:[f.to]}))}),s={};for(const f of o.children??[])s[f.id]={x:f.x??0,y:f.y??0,w:f.width??0,h:f.height??0};const i=o.width??0;if(i<=Qh)return{areas:{},nodes:s,width:i,height:o.height??0,flat:!0};const a=[];for(const[f,v]of Object.entries(s).sort((x,S)=>x[1].x+x[1].w/2-(S[1].x+S[1].w/2))){const x=a[a.length-1];x&&v.x+v.w/2<x.right?(x.ids.push(f),x.left=Math.min(x.left,v.x),x.right=Math.max(x.right,v.x+v.w)):a.push({left:v.x,right:v.x+v.w,ids:[f]})}const l=Math.ceil(i/Qh),u=Math.ceil(a.length/l);let c=0,d=0;const h=[];for(let f=0;f*u<a.length;f++){const v=a.slice(f*u,(f+1)*u),x=v.flatMap(m=>m.ids),S=v[0].left,y=Math.min(...x.map(m=>s[m].y));h.push(c);for(const m of x)s[m]={...s[m],x:s[m].x-S,y:s[m].y-y+c};c=Math.max(...x.map(m=>s[m].y+s[m].h))+nc,d=Math.max(d,v[v.length-1].right-S)}return{areas:{},nodes:s,width:d,height:c-nc,flat:!0,rowTops:h}}const Si=176,Jh=120,ep=34,n2=14;function r2(e,t){const n=new Map(e.map(s=>[s,0]));for(const s of t)n.set(s.to,(n.get(s.to)??0)+1);const r=new Set(e),o=[];for(;r.size;){const s=e.find(i=>r.has(i)&&!n.get(i))??e.find(i=>r.has(i));r.delete(s),o.push(s);for(const i of t)i.from===s&&r.has(i.to)&&n.set(i.to,n.get(i.to)-1)}return o}async function o2(e,t,n){const r=Bs(e,t),o=new Map(e.nodes.map(C=>[C.id,tc(C.kind,n.has(C.id))])),s=new Map(e.nodes.map(C=>[C.id,C.branch??null])),i=r2(e.nodes.map(C=>C.id),r),a=i.filter(C=>!s.get(C));if(!a.length)return M0(e,t,n);const l=C=>o.get(C).w,u=C=>o.get(C).h,c=new Map,d=new Map;let h=0;for(const C of a)c.set(C,h),d.set(C,0),h+=l(C)+Si;const f=C=>c.get(C)+l(C)/2,v=C=>c.get(C)+l(C),x=[...new Set([...e.nodes,...e.edges].flatMap(C=>C.branch?[C.branch]:[]))],S=new Map;for(const C of i){const D=s.get(C);D&&S.set(D,[...S.get(D)??[],C])}const y=[],m=new Map,p=new Set(S.keys()),w=(C,D)=>{const Z=S.get(C),Y=new Set(Z),X=r.filter(fe=>Y.has(fe.to)&&!Y.has(fe.from));if(!D&&X.length&&!X.some(fe=>d.has(fe.from)))return null;const V=X.filter(fe=>d.has(fe.from)).map(fe=>fe.from).sort((fe,wt)=>d.get(fe)-d.get(wt)||f(fe)-f(wt))[0]??null,G=V&&d.get(V)===0?a[a.indexOf(V)+1]:void 0,re=Z[0],ae=V?G?(f(V)+f(G))/2:f(V)+(l(V)/2+Si+l(re)/2)/2:l(re)/2,de=[];let Fe=ae-l(re)/2;for(const fe of Z)de.push(Fe),Fe+=l(fe)+Si;const We=r.filter(fe=>Y.has(fe.from)&&!Y.has(fe.to)&&d.has(fe.to)),Ge=We.filter(fe=>f(fe.to)>=de[0]).map(fe=>f(fe.to)),rt=We.filter(fe=>f(fe.to)<de[0]).map(fe=>f(fe.to));return{name:C,ids:Z,anchor:V,xs:de,kind:rt.length?2:Ge.length?0:1,reach:Math.max(0,...Ge),span:[Math.min(V?f(V):de[0],...rt)-30,Math.max(Fe-Si,...Ge)+30],verticals:[...V?[{x:f(V),from:d.get(V)}]:[],...We.map(fe=>({x:f(fe.to),from:d.get(fe.to)}))],minLane:V?d.get(V)+1:1,root:V?d.get(V)===0?a.indexOf(V):m.get(s.get(V))??a.length:a.length}};for(;p.size;){const D=[...p].flatMap(V=>w(V,!1)??[]).sort((V,G)=>(V.anchor?f(V.anchor):1/0)-(G.anchor?f(G.anchor):1/0)||V.kind-G.kind||V.reach-G.reach||x.indexOf(V.name)-x.indexOf(G.name))[0]??w(x.find(V=>p.has(V))??[...p][0],!0);p.delete(D.name);const Z=V=>!y.some(G=>G.lane===V&&G.span[0]<D.span[1]&&D.span[0]<G.span[1]),Y=V=>D.verticals.every(G=>y.every(re=>!(re.lane>G.from&&re.lane<V)||re.boxes.every(ae=>G.x<c.get(ae)-12||G.x>v(ae)+12)))&&y.every(G=>G.lane<=V||G.verticals.every(re=>re.from>=V||D.xs.every((ae,de)=>re.x<ae-12||re.x>ae+l(D.ids[de])+12)));let X=D.minLane;for(;X<D.minLane+12&&!(Z(X)&&Y(X));)X++;if(X>=D.minLane+12)for(X=D.minLane;!Z(X);X++);D.ids.forEach((V,G)=>{c.set(V,D.xs[G]),d.set(V,X)}),y.push({name:D.name,lane:X,span:D.span,verticals:D.verticals,boxes:D.ids,root:D.root}),m.set(D.name,D.root)}const b=[...new Set([...d.values()])].sort((C,D)=>C-D),k=new Map,E=new Map;let _=0;for(const C of b){const D=Math.max(...[...d].filter(([,Z])=>Z===C).map(([Z])=>u(Z)));k.set(C,_),E.set(C,_+D),_+=D+Jh}const A={};for(const C of e.nodes){const D=d.get(C.id);A[C.id]={x:c.get(C.id),y:k.get(D)+(E.get(D)-k.get(D)-u(C.id))/2,w:l(C.id),h:u(C.id)}}const L=new Map(e.nodes.map(C=>[C.id,C.kind])),$=(C,D,Z)=>{const Y=A[C],X=L.get(C)==="choice"?Math.min(Y.h/2,Math.abs(D-(Y.x+Y.w/2))*Y.h/Y.w):0;return Z==="top"?Y.y+X:Y.y+Y.h-X},F=C=>A[C].y+A[C].h/2,B=C=>d.get(C),N=C=>[...d].filter(([,D])=>D===C).map(([D])=>D).sort((D,Z)=>c.get(D)-c.get(Z)),P=new Map,R=new Map,O=(C,D,Z,Y)=>R.set(`${C}:${D}`,[...R.get(`${C}:${D}`)??[],{link:Z,key:Y}]);for(const C of r){const D=B(C.from),Z=B(C.to);let Y;if(D===Z){const X=N(D);Y=X.indexOf(C.to)===X.indexOf(C.from)+1?"straight":D===0?"arc":"under"}else Z>D?Y="down":Y=f(C.to)>v(C.from)+24?"rejoin":f(C.to)<c.get(C.from)-24?"return":"up";P.set(C.id,Y),Y==="arc"&&(O(C.from,"t",C.id,[f(C.to)]),O(C.to,"t",C.id,[f(C.from)])),(Y==="rejoin"||Y==="up")&&O(C.to,"b",C.id,[0,D]),Y==="return"&&O(C.to,"b",C.id,[1,-D]),Y==="down"&&O(C.from,"b",C.id,[2,-Z])}const j=new Map;for(const[C,D]of R){const Z=C.slice(0,C.lastIndexOf(":"));D.sort((Y,X)=>Y.key.reduce((V,G,re)=>V||G-(X.key[re]??0),0)),D.forEach((Y,X)=>j.set(`${Y.link}:${C}`,f(Z)+(X-(D.length-1)/2)*n2))}const M=(C,D,Z)=>j.get(`${C}:${D}:${Z}`)??f(D),I=r.filter(C=>P.get(C.id)==="arc").sort((C,D)=>Math.abs(f(C.to)-f(C.from))-Math.abs(f(D.to)-f(D.from))),z=new Map(I.map((C,D)=>[C.id,D])),H=new Map,ne={};for(const C of r){const D=A[C.from],Z=A[C.to],Y=B(C.from),X=P.get(C.id);let V;if(X==="straight")V={points:[[D.x+D.w,F(C.from)],[Z.x,F(C.to)]],label:0};else if(X==="arc"){const G=-58-18*z.get(C.id),re=M(C.id,C.from,"t"),ae=M(C.id,C.to,"t");V={points:[[re,$(C.from,re,"top")],[re,G],[ae,G],[ae,$(C.to,ae,"top")]],label:1}}else if(X==="under"||X==="return"){const G=H.get(Y)??0;H.set(Y,G+1);const re=E.get(Y)+ep+16*G,ae=f(C.from)+(X==="under"?6:0),de=X==="return"?M(C.id,C.to,"b"):f(C.to)-6;V={points:[[ae,D.y+D.h],[ae,re],[de,re],[de,$(C.to,de,"bottom")]],label:1}}else if(X==="down"){const G=M(C.id,C.from,"b"),re=f(C.to),ae=k.get(B(C.to))-ep;V=Math.abs(re-G)<4?{points:[[G,$(C.from,G,"bottom")],[G,Z.y]],label:0}:{points:[[G,$(C.from,G,"bottom")],[G,ae],[re,ae],[re,Z.y]],label:1}}else if(X==="rejoin"){const G=M(C.id,C.to,"b"),re=N(Y).some(de=>de!==C.from&&c.get(de)<G&&v(de)>D.x+D.w),ae=k.get(Y)-Jh/2;V=re?{points:[[f(C.from),D.y],[f(C.from),ae],[G,ae],[G,$(C.to,G,"bottom")]],label:1}:{points:[[D.x+D.w,F(C.from)],[G,F(C.from)],[G,$(C.to,G,"bottom")]],label:G-(D.x+D.w)>=150?0:1}}else{const G=Math.min(Math.max(M(C.id,C.to,"b"),D.x+12),D.x+D.w-12);V={points:[[G,D.y],[G,$(C.to,G,"bottom")]],label:0}}ne[C.id]=V}const U=x.map(C=>{var X;const D=y.find(V=>V.name===C);if(D)return{name:C,root:D.root};const Z=(X=e.edges.find(V=>V.branch===C))==null?void 0:X.from,Y=Z?s.get(Z):null;return{name:C,root:Z&&d.get(Z)===0?a.indexOf(Z):Y?m.get(Y)??a.length:a.length}}).sort((C,D)=>C.root-D.root||x.indexOf(C.name)-x.indexOf(D.name)).map(C=>C.name),J=Object.values(A),ee=Object.values(ne).flatMap(C=>C.points);return{areas:{},nodes:A,width:Math.max(...J.map(C=>C.x+C.w),...ee.map(C=>C[0])),height:Math.max(...J.map(C=>C.y+C.h),...ee.map(C=>C[1])),flat:!0,routes:ne,branches:U}}const tp=132,np=40,rp=36;function Hs(e,t){const n=new Map,r=new Set;for(const c of t)(n.get(c.from)??n.set(c.from,[]).get(c.from)).push(c.to),r.add(c.to);const o=new Map,s=[],i=c=>{o.set(c,"open");for(const d of n.get(c)??[])o.has(d)||i(d);o.set(c,"done"),s.push(c)};for(const c of[...e.filter(d=>!r.has(d)),...e])o.has(c)||i(c);const a=s.reverse(),l=new Map(a.map((c,d)=>[c,d])),u=new Map(e.map(c=>[c,0]));for(const c of a)for(const d of n.get(c)??[])(l.get(d)??0)>(l.get(c)??0)&&u.set(d,Math.max(u.get(d)??0,(u.get(c)??0)+1));return u}async function s2(e,t){const n=Hs(e.nodes.map(c=>c.id),Bs(e,t)),r=Math.max(0,...n.values())+1,o=2*be.side+r*tt+(r-1)*tp,s=c=>Math.min(...e.nodes.filter(d=>d.area===c).map(d=>n.get(d.id)??0)),i=e.areas.filter(c=>e.nodes.some(d=>d.area===c.id)).sort((c,d)=>s(c.id)-s(d.id)),a={},l={};let u=0;for(const c of i){const d=new Map;let h=1;for(const v of e.nodes.filter(x=>x.area===c.id)){const x=n.get(v.id)??0,S=d.get(x)??0;d.set(x,S+1),h=Math.max(h,S+1),l[v.id]={x:be.side+x*(tt+tp),y:be.top+S*(qe+np),w:tt,h:qe}}const f=be.top+h*qe+(h-1)*np+be.bottom;a[c.id]={x:0,y:u,w:o,h:f},u+=f+rp}return{areas:a,nodes:l,width:o,height:Math.max(0,u-rp),lanes:!0}}function i2(e){const t=e.nodes.map(v=>v.id),n=new Map;for(const v of e.edges)v.from!==v.to&&(n.get(v.from)??n.set(v.from,[]).get(v.from)).push(v.to);let r=0;const o=new Map,s=new Map,i=[],a=new Set,l=[],u=v=>{o.set(v,r),s.set(v,r),r++,i.push(v),a.add(v);for(const x of n.get(v)??[])o.has(x)?a.has(x)&&s.set(v,Math.min(s.get(v),o.get(x))):(u(x),s.set(v,Math.min(s.get(v),s.get(x))));if(s.get(v)===o.get(v)){const x=[];for(let S=i.pop();a.delete(S),x.push(S),S!==v;S=i.pop());l.push(x)}};for(const v of t)o.has(v)||u(v);const c=Hs(t,e.edges.map(v=>({from:v.from,to:v.to}))),d=new Map(e.nodes.map(v=>[v.id,v.area])),h=new Set,f=[];for(const v of l){if(v.length<3||v.length>8)continue;const x=new Set(v),S=[...v].sort((p,w)=>(c.get(p)??0)-(c.get(w)??0)||t.indexOf(p)-t.indexOf(w)),y=[S[0]];for(let p=S[0];;){const w=S.find(b=>!y.includes(b)&&(n.get(p)??[]).includes(b));if(!w)break;y.push(w),p=w}for(const p of S)y.includes(p)||y.push(p);const m=[];for(const p of y)m[m.length-1]!==d.get(p)&&m.push(d.get(p));if(m.length>1&&m[0]===m[m.length-1]&&m.pop(),!(m.length>2||m.some(p=>h.has(p))||!x.size)){for(const p of m)h.add(p);f.push({order:y,areas:m})}}return f}const Zo=70;async function op(e,t,n,r,o,s,i){const a=n.length?await Ed(e,t,n,r.filter(f=>n.some(v=>v.id===f.from)&&n.some(v=>v.id===f.to))):null,l={},u=a?a.size.w-be.side:0,c=s==="right"?(a?u+pr:be.side)+Zo:be.side,d=s==="left"&&a?tt+pr+Zo:0;if(a)for(const[f,v]of Object.entries(a.nodes))l[f]={...v,x:v.x+d};o.forEach((f,v)=>{const x=Zo*Math.sin(Math.PI*(v+.5)/o.length);l[f]={x:c+(s==="right"?-x:x),y:be.top+i+v*(qe+on),w:tt,h:qe}});const h=Object.values(l);return{nodes:l,size:{w:Math.max(...h.map(f=>f.x+f.w))+be.side,h:Math.max(...h.map(f=>f.y+f.h),a?a.size.h-be.bottom:0)+be.bottom}}}async function sp(e,t){var b;const n=await bd(),r=new Map(e.nodes.map(k=>[k.id,k.area])),o=Bs(e,t),s=i2(e),i=Hs(e.nodes.map(k=>k.id),e.edges.map(k=>({from:k.from,to:k.to}))),a=new Set(e.nodes.map(k=>k.area)),l=()=>{const k=new Map;for(const E of o){const _=r.get(E.from),A=r.get(E.to);_!==A&&k.set(`${_}>${A}`,{from:_,to:A})}return[...k.values()]},u=new Map;if(s.some(k=>k.areas.length===2)){const k=await n.layout({id:"root",layoutOptions:{...Ca,"elk.direction":"RIGHT"},children:e.areas.filter(E=>a.has(E.id)).map(E=>({id:E.id,width:100,height:100})),edges:l().map((E,_)=>({id:`q${_}`,sources:[E.from],targets:[E.to]}))});for(const E of k.children??[])u.set(E.id,E.x??0)}const c=new Map,d=new Map,h=new Map;for(const k of s)if(k.areas.length===2){const[E,_]=k.areas,A=M=>Math.min(...e.nodes.filter(I=>I.area===M).map(I=>i.get(I.id)??0)),[L,$]=A(_)<A(E)?[_,E]:[E,_];(u.get(L)??0)<(u.get($)??0)||c.set(L,$);const F=k.order.length,B=k.order.findIndex((M,I)=>r.get(M)===L&&r.get(k.order[(I-1+F)%F])===$),N=[...k.order.slice(B),...k.order.slice(0,B)],P=N.filter(M=>r.get(M)===L).reverse(),R=N.filter(M=>r.get(M)===$),O=Math.max(P.length,R.length),j=M=>(O-M)*(qe+on)/2;d.set(L,[{column:P,side:"right",drop:j(P.length)}]),d.set($,[{column:R,side:"left",drop:j(R.length)}]),h.set(L,$)}else{const E=Math.ceil(k.order.length/2),_=k.order.slice(0,E).reverse(),A=k.order.slice(E),L=Math.max(_.length,A.length),$=F=>(L-F)*(qe+on)/2;d.set(k.areas[0],[{column:_,side:"right",drop:$(_.length)},{column:A,side:"left",drop:$(A.length)}])}const f={},v={};for(const k of e.areas){const E=e.nodes.filter($=>$.area===k.id);if(!E.length)continue;const _=o.filter($=>r.get($.from)===k.id&&r.get($.to)===k.id),A=d.get(k.id);if((A==null?void 0:A.length)===1){const $=A[0],F=await op(n,k.id,E.filter(B=>!$.column.includes(B.id)),_,$.column,$.side,$.drop);Object.assign(f,F.nodes),v[k.id]=F.size;continue}if((A==null?void 0:A.length)===2){const[$,F]=A,B=new Set([...$.column,...F.column]),N=await op(n,k.id,E.filter(O=>!B.has(O.id)),_,$.column,"right",$.drop),P=Math.max(...$.column.map(O=>N.nodes[O].x))+tt+pr+Zo;F.column.forEach((O,j)=>{const M=Zo*Math.sin(Math.PI*(j+.5)/F.column.length);N.nodes[O]={x:P+M,y:be.top+F.drop+j*(qe+on),w:tt,h:qe}}),Object.assign(f,N.nodes);const R=Object.values(N.nodes);v[k.id]={w:Math.max(...R.map(O=>O.x+O.w))+be.side,h:Math.max(N.size.h,...R.map(O=>O.y+O.h+be.bottom))};continue}const L=await Ed(n,k.id,E,_);Object.assign(f,L.nodes),v[k.id]=L.size}const x=new Map,S=new Map(e.edges.map(k=>[`${k.from}>${k.to}`,k.label]));for(const k of o){const E=r.get(k.from),_=r.get(k.to);if(E===_||!v[E]||!v[_]||c.get(_)===E)continue;const A=`${E}>${_}`,L=l2(S.get(`${k.from}>${k.to}`)??"");x.set(A,{from:E,to:_,label:Math.max(((b=x.get(A))==null?void 0:b.label)??0,L)})}const y=await n.layout({id:"root",layoutOptions:{...Ca,"elk.direction":"RIGHT","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.nodeNode":"48","elk.spacing.componentComponent":"64"},children:e.areas.filter(k=>v[k.id]).map(k=>({id:k.id,width:v[k.id].w,height:v[k.id].h})),edges:[...x.values()].map((k,E)=>{const _=c2(k.label);return{id:`p${E}`,sources:[k.from],targets:[k.to],..._?{labels:[{id:`p${E}l`,text:" ",width:_,height:a2}]}:{}}})}),m={};for(const k of y.children??[])m[k.id]={x:k.x??0,y:k.y??0,w:k.width??0,h:k.height??0};for(const[k,E]of h){const _=m[k],A=m[E];if(!_||!A)continue;const L=_.y-A.y,$={...A,y:A.y+L};Object.entries(m).some(([B,N])=>B!==E&&B!==k&&$.x<N.x+N.w&&N.x<$.x+$.w&&$.y<N.y+N.h&&N.y<$.y+$.h)||(m[E]=$)}const p=Object.values(m),w=Math.min(0,...p.map(k=>k.y));if(w<0)for(const k of p)k.y-=w;return{areas:m,nodes:f,width:Math.max(y.width??0,...p.map(k=>k.x+k.w)),height:Math.max(y.height??0,...p.map(k=>k.y+k.h)),...s.length?{rings:s.map(k=>k.order)}:{}}}const a2=24,l2=e=>e?Math.ceil(e.length*6.8+16):0,u2=40;function c2(e){return Math.max(0,e+2*u2-2*120)}function j0(e){const t=Hs(e.nodes.map(n=>n.id),e.edges.map(n=>({from:n.from,to:n.to})));return new Set(e.edges.filter(n=>n.from!==n.to&&(t.get(n.to)??0)<=(t.get(n.from)??0)).map(n=>n.id))}function T0(e,t){const n=e.edges.find(d=>d.id===t);if(!n||!j0(e).has(t))return null;const r=e.edges.filter(d=>d.id!==t),o=(d,h)=>{const f=new Set([d]);for(let v=!0;v;){v=!1;for(const x of r){const[S,y]=h(x);f.has(S)&&!f.has(y)&&(f.add(y),v=!0)}}return f},s=o(n.to,d=>[d.from,d.to]),i=o(n.from,d=>[d.to,d.from]),a=new Set([...s].filter(d=>i.has(d))),l=Hs(e.nodes.map(d=>d.id),e.edges.map(d=>({from:d.from,to:d.to}))),u=e.nodes.map(d=>d.id).filter(d=>a.has(d)).sort((d,h)=>(l.get(d)??0)-(l.get(h)??0)),c=[...r.filter(d=>a.has(d.from)&&a.has(d.to)).map(d=>d.id),t];return{nodes:u,edges:c}}function d2(e,t,n,r){var h;if(t.flat){const f=y=>{const m=t.nodes[y];return m?{x:m.x+m.w/2,y:m.y+m.h/2}:{x:0,y:0}},v=f(r).x-f(n).x,x=f(r).y-f(n).y;if(Math.abs(v)<40)return x>=0?["b","t"]:["t","b"];const S=_a(t,r)-_a(t,n);return S?S>0?["b","t"]:["r","b"]:v>=0?["r","l"]:["l","r"]}const o=f=>{var v;return((v=e.nodes.find(x=>x.id===f))==null?void 0:v.area)??""},s=f=>{const v=t.areas[o(f)],x=t.nodes[f];return v&&x?{x:v.x+x.x+x.w/2,y:v.y+x.y+x.h/2}:{x:0,y:0}},i=s(n),a=s(r),l=a.x-i.x,u=a.y-i.y,c=(h=t.rings)==null?void 0:h.find(f=>f.includes(n)),d=!!c&&c.includes(r)&&Math.abs(l)>=tt*.75;return!t.lanes&&!d&&o(n)===o(r)||Math.abs(l)<tt*.75?u>=0?["b","t"]:["t","b"]:l>=0?["r","l"]:["l","r"]}function f2(e,t=[],n=[],r=[]){return JSON.stringify([e.view??null,e.view==="journey"?[e.nodes.map(o=>o.kind),[...r].sort()]:null,[...e.nodes,...e.edges].map(o=>o.branch??""),[...n].sort(),e.areas.map(o=>o.id),e.nodes.map(o=>`${o.id}@${o.area}`),e.edges.map(o=>`${o.from}>${o.to}`),e.absences.map(o=>o.between?`${o.between.from}~${o.between.to}`:""),t.map(o=>`${o.from}+${o.to}`)])}const Ir=()=>({nodes:[],edges:[],absences:[]}),zo=e=>e.nodes.length+e.edges.length+e.absences.length,h2=e=>({mapId:e,phase:"loading",meta:null,map:null,report:null,job:null,error:null,answers:[],shown:null,selection:Ir(),tour:null,peek:!1,views:[],viewIndex:-1,fixes:{},fresh:[],hidden:[],connected:!1,agent:S0}),p2=e=>e.views[e.viewIndex]??null;function Us(e){if(!e.map)return[];const t=new Set([...e.map.areas,...e.map.nodes,...e.map.edges,...e.map.absences].map(n=>n.id));return e.answers.flatMap(n=>{const r=n.added.filter(o=>t.has(o));return r.length?[{answerId:n.id,question:n.question,ids:r,visible:!e.hidden.includes(n.id)}]:[]})}const g2=e=>Us(e).flatMap(t=>t.ids);function $0(e){if(!e.map)return null;const t=new Set(Us(e).filter(o=>!o.visible).flatMap(o=>o.ids));if(!t.size)return e.map;const n=e.map.nodes.filter(o=>!t.has(o.id)),r=new Set(n.map(o=>o.id));return{...e.map,areas:e.map.areas.filter(o=>!t.has(o.id)),nodes:n,edges:e.map.edges.filter(o=>!t.has(o.id)&&r.has(o.from)&&r.has(o.to)),absences:e.map.absences.filter(o=>!t.has(o.id)&&(!o.between||r.has(o.between.from)&&r.has(o.between.to)))}}function m2(e,t){if(!t)return e;const n=(r,o)=>r.filter(s=>o.some(i=>i.id===s));return{nodes:n(e.nodes,t.nodes),edges:n(e.edges,t.edges),absences:n(e.absences,t.absences)}}function y2(e,t){var i,a,l;const n=e.tour[t];if(!n)return null;const r=e.nodes.filter(u=>{var c;return(c=n.focus.areas)==null?void 0:c.includes(u.area)}).map(u=>u.id),o=[...n.focus.nodes??[],...n.focus.edges??[],...n.focus.absences??[],...r],s=(n.focus.edges??[]).length||(n.focus.absences??[]).length?[]:I0(e,new Set(o));return{focus:((i=n.focus.nodes)==null?void 0:i[0])??((a=n.focus.edges)==null?void 0:a[0])??((l=n.focus.absences)==null?void 0:l[0])??null,highlight:[...new Set([...o,...s])]}}function I0(e,t){return e.edges.filter(n=>t.has(n.from)&&t.has(n.to)).map(n=>n.id)}function ip(e,t){const n=[...t.moves.highlight,...t.added],r=e?[...new Set([...n,...I0(e,new Set(n))])]:n;return r.length||t.moves.focus?{focus:t.moves.focus??r[0]??null,highlight:r}:null}function tr(e,t){if(!t)return e;const n=[...e.views.slice(0,e.viewIndex+1),t].slice(-50);return{...e,views:n,viewIndex:n.length-1}}function ap(e,t,n){const r={...t};for(const o of e){if(!o.fix||r[o.fix.id]&&!n)continue;const s=n?n[o.fix.id]:{status:"proposed"};r[o.fix.id]={proposal:o.fix,answerId:o.id,status:(s==null?void 0:s.status)??"rejected",problems:[],edgeId:(s==null?void 0:s.edgeId)??null,closed:(s==null?void 0:s.closed)??[],undoable:(s==null?void 0:s.undoable)??!0}}return r}function v2(e,t){var n;switch(t.type){case"loaded":{const r=t.payload,o=r.map?"ready":r.job?"making":r.failure?"failed":"missing";return{...e,phase:o,meta:r.meta,map:r.map,report:r.report,job:r.job,error:((n=r.failure)==null?void 0:n.error)??null,answers:r.answers,shown:null,fixes:ap(r.answers,e.fixes,r.fixes??{}),agent:r.agent??e.agent}}case"missing":return{...e,phase:"missing"};case"connected":return{...e,connected:t.value};case"event":{const r=t.event;if(r.mapId!==e.mapId)return e;if(r.type==="job")return r.status==="started"?{...e,job:{kind:r.job,question:r.question,progress:[]},error:null,phase:r.job==="make"?"making":e.phase}:r.status==="failed"?{...e,job:null,error:r.error??"Something went wrong.",phase:r.job==="make"&&!e.map?"failed":e.phase}:{...e,job:null};if(r.type==="progress")return e.job?{...e,job:{...e.job,progress:[...e.job.progress,r.text].slice(-200)}}:e;if(r.type==="map"){const o=i=>i.filter(a=>r.map.nodes.some(l=>l.id===a)||r.map.edges.some(l=>l.id===a)||r.map.absences.some(l=>l.id===a)),s={nodes:o(e.selection.nodes),edges:o(e.selection.edges),absences:o(e.selection.absences)};return{...e,phase:"ready",meta:r.meta,map:r.map,report:r.report,selection:s}}if(r.type==="answer"){const o=[...e.answers,r.answer],s={...e,answers:o,shown:r.answer.id,tour:null,peek:!1,fresh:r.answer.added,fixes:ap([r.answer],e.fixes,void 0)};return tr(s,ip(e.map,r.answer))}if(r.type==="answerUpdate")return{...e,answers:e.answers.map(o=>o.id===r.answer.id?r.answer:o)};if(r.type==="fix"){const o=e.fixes[r.fixId];if(!o)return e;const s=r.status,i={...e.fixes,[r.fixId]:{...o,status:s,problems:r.problems??[],edgeId:r.edgeId??o.edgeId,closed:r.closed??o.closed,undoable:r.status==="applied"?!0:o.undoable}},a={...e,fixes:i};if(r.status==="applied"&&r.edgeId){const l=o.proposal.connects;return tr(a,{focus:r.edgeId,highlight:[r.edgeId,...l?[l.from,l.to]:[]]})}return a}return e}case"select":{const r=e.selection[t.kind],o=r.includes(t.id),s=t.additive?{...e.selection,[t.kind]:o?r.filter(i=>i!==t.id):[...r,t.id]}:{...Ir(),[t.kind]:o&&zo(e.selection)===1?[]:[t.id]};return{...e,selection:s}}case"selectMany":return{...e,selection:t.selection};case"clearSelection":return{...e,selection:Ir()};case"tour":{if(!e.map)return{...e,tour:null,peek:!1};if(t.stop===null)return e.tour===null?e:tr({...e,tour:null,peek:!1},{focus:null,highlight:[]});const r=Math.max(0,Math.min(t.stop,e.map.tour.length-1));return tr({...e,tour:r,selection:Ir()},y2(e.map,r))}case"peek":{if(!t.open)return{...e,peek:!1};const r=e.answers[e.answers.length-1];return r?{...e,peek:!0,shown:e.shown??r.id}:e}case"focus":{if(!e.map)return e;const r=e.map.nodes.some(o=>o.id===t.id)?"nodes":e.map.edges.some(o=>o.id===t.id)?"edges":e.map.absences.some(o=>o.id===t.id)?"absences":null;return r?tr({...e,tour:null,peek:!1,selection:{...Ir(),[r]:[t.id]}},{focus:t.id,highlight:[t.id]}):e}case"back":return e.viewIndex>0?{...e,viewIndex:e.viewIndex-1}:e.viewIndex===0?{...e,viewIndex:-1}:e;case"forward":return e.viewIndex<e.views.length-1?{...e,viewIndex:e.viewIndex+1}:e;case"show":{const r=e.answers.find(o=>o.id===t.answerId);return tr({...e,shown:t.answerId,tour:null,peek:!1},r?ip(e.map,r):null)}case"overview":return tr({...e,shown:null,tour:null,peek:!1,selection:Ir(),fresh:[]},{focus:null,highlight:[]});case"layer":case"allLayers":{const r=t.type==="layer"?[t.answerId]:Us(e).map(i=>i.answerId),o=t.visible?e.hidden.filter(i=>!r.includes(i)):[...new Set([...e.hidden,...r])],s={...e,hidden:o};return{...s,selection:m2(e.selection,$0(s))}}case"fixStatus":{const r=e.fixes[t.fixId];return r?{...e,fixes:{...e.fixes,[t.fixId]:{...r,status:t.status,problems:t.problems??r.problems}}}:e}case"error":return{...e,error:t.message}}}const gr=(...e)=>e.filter(Boolean).join(" ");function ut(e,t){const n=e.nodes.find(i=>i.id===t);if(n)return n.name;const r=e.edges.find(i=>i.id===t);if(r)return`${ut(e,r.from)} → ${ut(e,r.to)}`;const o=e.absences.find(i=>i.id===t);if(o)return o.claim;const s=e.areas.find(i=>i.id===t);return(s==null?void 0:s.label)??t}const w2={add:{pending:"Proposed: this isn’t in the code yet.",done:"This was proposed, and the code now has it."},change:{pending:"Proposed: this code would change.",done:"This was proposed to change, and the code here has changed since."},remove:{pending:"Proposed: this code would be removed.",done:"This was proposed for removal, and it’s no longer in the code."}},x2={added:"New since",changed:"Changed since",removed:"Removed since"};function rc(e,t){return e?e.nodes[t]??e.edges[t]??(e.absences[t]?{status:e.absences[t].status,reasons:e.absences[t].reasons}:null):null}function ht({eyebrow:e,title:t,children:n,tone:r,className:o}){return g.jsxs("section",{className:gr("card",r&&`card-${r}`,o),children:[e&&g.jsx("div",{className:"eyebrow",children:e}),t&&g.jsx("h2",{className:"card-title",children:t}),n]})}function k2({map:e,ids:t,onPick:n}){return t.length?g.jsx("div",{className:"chips",children:t.map(({id:r,status:o})=>g.jsxs("button",{className:gr("chip",o==="proposed"?"chip-proposed":o!=="confirmed"&&"chip-unconfirmed"),onClick:()=>n(r),title:o==="confirmed"?"Confirmed against the code":o==="proposed"?"Part of a proposal, not in the code":"Couldn't confirm against the code",children:[g.jsx("span",{className:o==="confirmed"?"tick":o==="proposed"?"pmark":"qmark",children:o==="confirmed"?"✓":o==="proposed"?"+":"?"}),ut(e,r)]},r))}):null}function lp({lines:e,working:t}){const n=e.slice(-8);return g.jsxs("ul",{className:"progress",children:[n.map((r,o)=>g.jsxs("li",{className:gr(t&&o===n.length-1&&"running"),children:[g.jsx("span",{className:"ic",children:t&&o===n.length-1?"…":"✓"}),r]},`${o}-${r}`)),!n.length&&t&&g.jsxs("li",{className:"running",children:[g.jsx("span",{className:"ic",children:"…"}),"Starting"]})]})}function S2({fix:e,onApprove:t,onReject:n,onUndo:r,map:o}){const s=e.proposal,i=s.files.filter(a=>a.uncommitted);return e.status==="applied"?g.jsxs(ht,{eyebrow:"Fix applied · re-checked",tone:"ok",children:[g.jsxs("ul",{className:"progress",children:[g.jsxs("li",{children:[g.jsx("span",{className:"ic",children:"✓"}),"Changed ",s.files.length," ",s.files.length===1?"file":"files",": ",s.files.map(a=>a.file).join(", ")]}),e.edgeId&&g.jsxs("li",{children:[g.jsx("span",{className:"ic",children:"✓"}),"New confirmed connection: ",ut(o,e.edgeId)]}),e.closed.length>0&&g.jsxs("li",{children:[g.jsx("span",{className:"ic",children:"✓"}),"Closed: ",e.closed.length===1?"the missing connection":`${e.closed.length} missing connections`]})]}),e.undoable?g.jsx("div",{className:"btns",children:g.jsx("button",{className:"btn",onClick:r,children:"Undo this fix"})}):g.jsx("p",{className:"muted small",children:"Undo ended when illuminate stopped. Use git to reverse it."})]}):e.status==="rejected"||e.status==="undone"?g.jsxs(ht,{eyebrow:e.status==="undone"?"Fix undone":"Fix rejected",children:[g.jsx(_s,{text:s.summary,className:"muted"}),e.status==="undone"&&g.jsx("div",{className:"btns",children:g.jsx("button",{className:"btn",onClick:t,children:"Apply it again"})})]}):g.jsxs(ht,{eyebrow:`Proposed fix · ${s.files.length} ${s.files.length===1?"file":"files"} · nothing changed yet`,tone:"ai",children:[g.jsx(_s,{text:s.summary}),s.connects&&g.jsx("p",{className:"muted small",children:"The green dashed arrow is the connection it adds."}),g.jsx("pre",{className:"diff",children:s.diff.split(`
|
|
78
|
+
`).forEach((a,l)=>{l>0&&n.push(g.jsx("br",{},`${t}-br${o++}`)),a&&n.push(a)})};for(const i of e.matchAll(zC)){s(e.slice(r,i.index));const a=`${t}-${o++}`;if(i[2]!==void 0)n.push(g.jsx("code",{children:i[2]},a));else if(i[3]!==void 0||i[4]!==void 0)n.push(g.jsx("strong",{children:ur(i[3]??i[4],a)},a));else if(i[5]!==void 0||i[6]!==void 0)n.push(g.jsx("em",{children:ur(i[5]??i[6],a)},a));else if(i[7]!==void 0){const l=i[8];n.push(/^https?:\/\//i.test(l)?g.jsx("a",{href:l,target:"_blank",rel:"noreferrer",children:ur(i[7],a)},a):g.jsx("span",{children:ur(i[7],a)},a))}r=i.index+i[0].length}return s(e.slice(r)),n}function _s({text:e,className:t}){const n=OC(e);return n.length?g.jsx("div",{className:t?`md ${t}`:"md",children:n.map((r,o)=>{const s=`b${o}`;if(r.kind==="p")return g.jsx("p",{children:ur(r.text,s)},s);if(r.kind==="h")return g.jsx("p",{className:"md-h",children:ur(r.text,s)},s);if(r.kind==="code")return g.jsx("pre",{children:g.jsx("code",{children:r.text})},s);const i=r.items.map((a,l)=>g.jsx("li",{children:ur(a,`${s}-${l}`)},`${s}-${l}`));return r.kind==="ul"?g.jsx("ul",{children:i},s):g.jsx("ol",{start:r.start,children:i},s)})}):null}const DC=/^About the walkthrough step “([^”]*)”: /,FC=(e,t)=>`About the walkthrough step “${e}”: ${t}`;function BC(e){const t=DC.exec(e);return t?{question:e.slice(t[0].length),step:t[1]}:{question:e,step:null}}function HC(e,t,n,r=12){return Math.max(0,e+(n-t)-r)}function UC(e,t,n=40){return t>e-n}const VC="modulepreload",WC=function(e){return"/"+e},Zh={},GC=function(t,n,r){let o=Promise.resolve();if(n&&n.length>0){document.getElementsByTagName("link");const i=document.querySelector("meta[property=csp-nonce]"),a=(i==null?void 0:i.nonce)||(i==null?void 0:i.getAttribute("nonce"));o=Promise.allSettled(n.map(l=>{if(l=WC(l),l in Zh)return;Zh[l]=!0;const u=l.endsWith(".css"),c=u?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${l}"]${c}`))return;const d=document.createElement("link");if(d.rel=u?"stylesheet":VC,u||(d.as="script"),d.crossOrigin="",d.href=l,a&&d.setAttribute("nonce",a),document.head.appendChild(d),u)return new Promise((h,f)=>{d.addEventListener("load",h),d.addEventListener("error",()=>f(new Error(`Unable to preload CSS for ${l}`)))})}))}function s(i){const a=new Event("vite:preloadError",{cancelable:!0});if(a.payload=i,window.dispatchEvent(a),!a.defaultPrevented)throw i}return o.then(i=>{for(const a of i||[])a.status==="rejected"&&s(a.reason);return t().catch(s)})},tt=232,qe=96,YC=e=>e.view==="journey"&&[...e.nodes,...e.edges].some(t=>!!t.branch);function _a(e,t){var s;const n=((s=e.nodes[t])==null?void 0:s.y)??0,r=e.rowTops??[];let o=0;for(const[i,a]of r.entries())n>=a-1&&(o=i);return o}const XC=132;function tc(e,t=!1){return e==="choice"?{w:196,h:132}:e==="action"?{w:196,h:60}:t?{w:232,h:64+XC}:{w:196,h:72}}let qC=null;const bd=()=>qC??(qC=GC(()=>import("./elk.bundled-DB_FYbjx.js").then(e=>e.e),[]).then(e=>new e.default)),Ca={"elk.algorithm":"layered","elk.layered.nodePlacement.strategy":"NETWORK_SIMPLEX","elk.layered.considerModelOrder.strategy":"NODES_AND_EDGES"};function Bs(e,t){const n=new Set(e.nodes.map(r=>r.id));return[...e.edges.map(r=>({id:`e:${r.id}`,from:r.from,to:r.to})),...e.absences.flatMap(r=>r.between?[{id:`a:${r.id}`,from:r.between.from,to:r.between.to}]:[]),...t.map(r=>({id:`x:${r.id}`,from:r.from,to:r.to}))].filter(r=>n.has(r.from)&&n.has(r.to)&&r.from!==r.to)}const be={top:52,side:26,bottom:26},on=64,pr=44,KC=56,ZC=140;async function Ed(e,t,n,r){const o=await e.layout({id:t,layoutOptions:{...Ca,"elk.direction":"DOWN","elk.padding":`[top=${be.top},left=${be.side},bottom=${be.bottom},right=${be.side}]`,"elk.layered.spacing.nodeNodeBetweenLayers":String(on),"elk.spacing.nodeNode":String(pr)},children:n.map(i=>({id:i.id,width:tt,height:qe})),edges:r.map(i=>({id:i.id,sources:[i.from],targets:[i.to]}))}),s={};for(const i of o.children??[])s[i.id]={x:i.x??0,y:i.y??0,w:tt,h:qe};return{nodes:s,size:{w:o.width??tt+2*be.side,h:o.height??qe+be.top+be.bottom}}}function QC(e,t){const n=e.nodes.filter(o=>!t.has(o.id)),r=new Set(n.map(o=>o.id));return{...e,areas:e.areas.filter(o=>!t.has(o.id)),nodes:n,edges:e.edges.filter(o=>!t.has(o.id)&&r.has(o.from)&&r.has(o.to)),absences:e.absences.filter(o=>!t.has(o.id)&&(!o.between||r.has(o.between.from)&&r.has(o.between.to)))}}async function JC(e,t=[],n=new Set,r=new Set){if(e.view==="journey")return YC(e)?o2(e,t,r):M0(e,t,r);const o=e2(e),s=await t2(e,t,n);return o.length?{...s,branches:o}:s}function e2(e){const t=[];for(const n of[...e.nodes,...e.edges])n.branch&&!t.includes(n.branch)&&t.push(n.branch);return t}async function t2(e,t,n){var w;if(e.view==="timeline")return s2(e,t);const r=e.nodes.filter(b=>n.has(b.id));if(!r.length)return sp(e,t);const o=QC(e,n),s=new Set(o.nodes.map(b=>b.id)),i=await sp(o,t.filter(b=>s.has(b.from)&&s.has(b.to))),a=await bd(),l=Object.fromEntries(Object.entries(i.areas).map(([b,k])=>[b,{...k}])),u={...i.nodes},c={},d={};for(const b of r)(d[w=b.area]??(d[w]=[])).push(b);for(const[b,k]of Object.entries(d)){const E=l[b];if(!E)continue;const _=Math.max(1,Math.floor((E.w-2*be.side+pr)/(tt+pr))),A=Math.max(be.top-on,...o.nodes.filter($=>$.area===b).map($=>{var F;return(((F=u[$.id])==null?void 0:F.y)??0)+qe}))+on;k.forEach(($,F)=>{u[$.id]={x:be.side+F%_*(tt+pr),y:A+Math.floor(F/_)*(qe+on),w:tt,h:qe}});const L=Math.max(E.h,A+Math.ceil(k.length/_)*(qe+on)-on+be.bottom);c[b]=L-E.h,E.h=L}const h=Object.fromEntries(Object.entries(i.areas).map(([b,k])=>[b,k])),f=Object.keys(h).sort((b,k)=>h[b].y-h[k].y),v={};for(const b of f){const k=h[b];v[b]=Math.max(0,...f.filter(E=>E!==b&&v[E]!==void 0).filter(E=>{const _=h[E];return _.y+_.h<=k.y+1&&_.x<k.x+k.w&&k.x<_.x+_.w}).map(E=>v[E]+(c[E]??0))),l[b].y+=v[b]}const x=Bs(e,t),S=new Map(e.nodes.map(b=>[b.id,b.area])),y=Math.max(0,...Object.values(l).map(b=>b.x+b.w))+ZC;let m=0;for(const b of e.areas){if(l[b.id])continue;const k=e.nodes.filter(A=>A.area===b.id);if(!k.length)continue;const E=x.filter(A=>S.get(A.from)===b.id&&S.get(A.to)===b.id),_=await Ed(a,b.id,k,E);Object.assign(u,_.nodes),l[b.id]={x:y,y:m,w:_.size.w,h:_.size.h},m+=_.size.h+KC}const p=Object.values(l);return{areas:l,nodes:u,width:Math.max(0,...p.map(b=>b.x+b.w)),height:Math.max(0,...p.map(b=>b.y+b.h)),...i.rings?{rings:i.rings}:{}}}const Qh=1900,nc=130;async function M0(e,t,n){const o=await(await bd()).layout({id:"root",layoutOptions:{...Ca,"elk.direction":"RIGHT","elk.layered.cycleBreaking.strategy":"MODEL_ORDER","elk.layered.spacing.nodeNodeBetweenLayers":"176","elk.spacing.nodeNode":"56","elk.spacing.componentComponent":"72"},children:e.nodes.map(f=>({id:f.id,width:tc(f.kind,n.has(f.id)).w,height:tc(f.kind,n.has(f.id)).h})),edges:Bs(e,t).map(f=>({id:f.id,sources:[f.from],targets:[f.to]}))}),s={};for(const f of o.children??[])s[f.id]={x:f.x??0,y:f.y??0,w:f.width??0,h:f.height??0};const i=o.width??0;if(i<=Qh)return{areas:{},nodes:s,width:i,height:o.height??0,flat:!0};const a=[];for(const[f,v]of Object.entries(s).sort((x,S)=>x[1].x+x[1].w/2-(S[1].x+S[1].w/2))){const x=a[a.length-1];x&&v.x+v.w/2<x.right?(x.ids.push(f),x.left=Math.min(x.left,v.x),x.right=Math.max(x.right,v.x+v.w)):a.push({left:v.x,right:v.x+v.w,ids:[f]})}const l=Math.ceil(i/Qh),u=Math.ceil(a.length/l);let c=0,d=0;const h=[];for(let f=0;f*u<a.length;f++){const v=a.slice(f*u,(f+1)*u),x=v.flatMap(m=>m.ids),S=v[0].left,y=Math.min(...x.map(m=>s[m].y));h.push(c);for(const m of x)s[m]={...s[m],x:s[m].x-S,y:s[m].y-y+c};c=Math.max(...x.map(m=>s[m].y+s[m].h))+nc,d=Math.max(d,v[v.length-1].right-S)}return{areas:{},nodes:s,width:d,height:c-nc,flat:!0,rowTops:h}}const Si=176,Jh=120,ep=34,n2=14;function r2(e,t){const n=new Map(e.map(s=>[s,0]));for(const s of t)n.set(s.to,(n.get(s.to)??0)+1);const r=new Set(e),o=[];for(;r.size;){const s=e.find(i=>r.has(i)&&!n.get(i))??e.find(i=>r.has(i));r.delete(s),o.push(s);for(const i of t)i.from===s&&r.has(i.to)&&n.set(i.to,n.get(i.to)-1)}return o}async function o2(e,t,n){const r=Bs(e,t),o=new Map(e.nodes.map(C=>[C.id,tc(C.kind,n.has(C.id))])),s=new Map(e.nodes.map(C=>[C.id,C.branch??null])),i=r2(e.nodes.map(C=>C.id),r),a=i.filter(C=>!s.get(C));if(!a.length)return M0(e,t,n);const l=C=>o.get(C).w,u=C=>o.get(C).h,c=new Map,d=new Map;let h=0;for(const C of a)c.set(C,h),d.set(C,0),h+=l(C)+Si;const f=C=>c.get(C)+l(C)/2,v=C=>c.get(C)+l(C),x=[...new Set([...e.nodes,...e.edges].flatMap(C=>C.branch?[C.branch]:[]))],S=new Map;for(const C of i){const D=s.get(C);D&&S.set(D,[...S.get(D)??[],C])}const y=[],m=new Map,p=new Set(S.keys()),w=(C,D)=>{const Z=S.get(C),Y=new Set(Z),X=r.filter(fe=>Y.has(fe.to)&&!Y.has(fe.from));if(!D&&X.length&&!X.some(fe=>d.has(fe.from)))return null;const V=X.filter(fe=>d.has(fe.from)).map(fe=>fe.from).sort((fe,wt)=>d.get(fe)-d.get(wt)||f(fe)-f(wt))[0]??null,G=V&&d.get(V)===0?a[a.indexOf(V)+1]:void 0,re=Z[0],ae=V?G?(f(V)+f(G))/2:f(V)+(l(V)/2+Si+l(re)/2)/2:l(re)/2,de=[];let Fe=ae-l(re)/2;for(const fe of Z)de.push(Fe),Fe+=l(fe)+Si;const We=r.filter(fe=>Y.has(fe.from)&&!Y.has(fe.to)&&d.has(fe.to)),Ge=We.filter(fe=>f(fe.to)>=de[0]).map(fe=>f(fe.to)),rt=We.filter(fe=>f(fe.to)<de[0]).map(fe=>f(fe.to));return{name:C,ids:Z,anchor:V,xs:de,kind:rt.length?2:Ge.length?0:1,reach:Math.max(0,...Ge),span:[Math.min(V?f(V):de[0],...rt)-30,Math.max(Fe-Si,...Ge)+30],verticals:[...V?[{x:f(V),from:d.get(V)}]:[],...We.map(fe=>({x:f(fe.to),from:d.get(fe.to)}))],minLane:V?d.get(V)+1:1,root:V?d.get(V)===0?a.indexOf(V):m.get(s.get(V))??a.length:a.length}};for(;p.size;){const D=[...p].flatMap(V=>w(V,!1)??[]).sort((V,G)=>(V.anchor?f(V.anchor):1/0)-(G.anchor?f(G.anchor):1/0)||V.kind-G.kind||V.reach-G.reach||x.indexOf(V.name)-x.indexOf(G.name))[0]??w(x.find(V=>p.has(V))??[...p][0],!0);p.delete(D.name);const Z=V=>!y.some(G=>G.lane===V&&G.span[0]<D.span[1]&&D.span[0]<G.span[1]),Y=V=>D.verticals.every(G=>y.every(re=>!(re.lane>G.from&&re.lane<V)||re.boxes.every(ae=>G.x<c.get(ae)-12||G.x>v(ae)+12)))&&y.every(G=>G.lane<=V||G.verticals.every(re=>re.from>=V||D.xs.every((ae,de)=>re.x<ae-12||re.x>ae+l(D.ids[de])+12)));let X=D.minLane;for(;X<D.minLane+12&&!(Z(X)&&Y(X));)X++;if(X>=D.minLane+12)for(X=D.minLane;!Z(X);X++);D.ids.forEach((V,G)=>{c.set(V,D.xs[G]),d.set(V,X)}),y.push({name:D.name,lane:X,span:D.span,verticals:D.verticals,boxes:D.ids,root:D.root}),m.set(D.name,D.root)}const b=[...new Set([...d.values()])].sort((C,D)=>C-D),k=new Map,E=new Map;let _=0;for(const C of b){const D=Math.max(...[...d].filter(([,Z])=>Z===C).map(([Z])=>u(Z)));k.set(C,_),E.set(C,_+D),_+=D+Jh}const A={};for(const C of e.nodes){const D=d.get(C.id);A[C.id]={x:c.get(C.id),y:k.get(D)+(E.get(D)-k.get(D)-u(C.id))/2,w:l(C.id),h:u(C.id)}}const L=new Map(e.nodes.map(C=>[C.id,C.kind])),$=(C,D,Z)=>{const Y=A[C],X=L.get(C)==="choice"?Math.min(Y.h/2,Math.abs(D-(Y.x+Y.w/2))*Y.h/Y.w):0;return Z==="top"?Y.y+X:Y.y+Y.h-X},F=C=>A[C].y+A[C].h/2,B=C=>d.get(C),N=C=>[...d].filter(([,D])=>D===C).map(([D])=>D).sort((D,Z)=>c.get(D)-c.get(Z)),P=new Map,R=new Map,O=(C,D,Z,Y)=>R.set(`${C}:${D}`,[...R.get(`${C}:${D}`)??[],{link:Z,key:Y}]);for(const C of r){const D=B(C.from),Z=B(C.to);let Y;if(D===Z){const X=N(D);Y=X.indexOf(C.to)===X.indexOf(C.from)+1?"straight":D===0?"arc":"under"}else Z>D?Y="down":Y=f(C.to)>v(C.from)+24?"rejoin":f(C.to)<c.get(C.from)-24?"return":"up";P.set(C.id,Y),Y==="arc"&&(O(C.from,"t",C.id,[f(C.to)]),O(C.to,"t",C.id,[f(C.from)])),(Y==="rejoin"||Y==="up")&&O(C.to,"b",C.id,[0,D]),Y==="return"&&O(C.to,"b",C.id,[1,-D]),Y==="down"&&O(C.from,"b",C.id,[2,-Z])}const j=new Map;for(const[C,D]of R){const Z=C.slice(0,C.lastIndexOf(":"));D.sort((Y,X)=>Y.key.reduce((V,G,re)=>V||G-(X.key[re]??0),0)),D.forEach((Y,X)=>j.set(`${Y.link}:${C}`,f(Z)+(X-(D.length-1)/2)*n2))}const M=(C,D,Z)=>j.get(`${C}:${D}:${Z}`)??f(D),I=r.filter(C=>P.get(C.id)==="arc").sort((C,D)=>Math.abs(f(C.to)-f(C.from))-Math.abs(f(D.to)-f(D.from))),z=new Map(I.map((C,D)=>[C.id,D])),H=new Map,ne={};for(const C of r){const D=A[C.from],Z=A[C.to],Y=B(C.from),X=P.get(C.id);let V;if(X==="straight")V={points:[[D.x+D.w,F(C.from)],[Z.x,F(C.to)]],label:0};else if(X==="arc"){const G=-58-18*z.get(C.id),re=M(C.id,C.from,"t"),ae=M(C.id,C.to,"t");V={points:[[re,$(C.from,re,"top")],[re,G],[ae,G],[ae,$(C.to,ae,"top")]],label:1}}else if(X==="under"||X==="return"){const G=H.get(Y)??0;H.set(Y,G+1);const re=E.get(Y)+ep+16*G,ae=f(C.from)+(X==="under"?6:0),de=X==="return"?M(C.id,C.to,"b"):f(C.to)-6;V={points:[[ae,D.y+D.h],[ae,re],[de,re],[de,$(C.to,de,"bottom")]],label:1}}else if(X==="down"){const G=M(C.id,C.from,"b"),re=f(C.to),ae=k.get(B(C.to))-ep;V=Math.abs(re-G)<4?{points:[[G,$(C.from,G,"bottom")],[G,Z.y]],label:0}:{points:[[G,$(C.from,G,"bottom")],[G,ae],[re,ae],[re,Z.y]],label:1}}else if(X==="rejoin"){const G=M(C.id,C.to,"b"),re=N(Y).some(de=>de!==C.from&&c.get(de)<G&&v(de)>D.x+D.w),ae=k.get(Y)-Jh/2;V=re?{points:[[f(C.from),D.y],[f(C.from),ae],[G,ae],[G,$(C.to,G,"bottom")]],label:1}:{points:[[D.x+D.w,F(C.from)],[G,F(C.from)],[G,$(C.to,G,"bottom")]],label:G-(D.x+D.w)>=150?0:1}}else{const G=Math.min(Math.max(M(C.id,C.to,"b"),D.x+12),D.x+D.w-12);V={points:[[G,D.y],[G,$(C.to,G,"bottom")]],label:0}}ne[C.id]=V}const U=x.map(C=>{var X;const D=y.find(V=>V.name===C);if(D)return{name:C,root:D.root};const Z=(X=e.edges.find(V=>V.branch===C))==null?void 0:X.from,Y=Z?s.get(Z):null;return{name:C,root:Z&&d.get(Z)===0?a.indexOf(Z):Y?m.get(Y)??a.length:a.length}}).sort((C,D)=>C.root-D.root||x.indexOf(C.name)-x.indexOf(D.name)).map(C=>C.name),J=Object.values(A),ee=Object.values(ne).flatMap(C=>C.points);return{areas:{},nodes:A,width:Math.max(...J.map(C=>C.x+C.w),...ee.map(C=>C[0])),height:Math.max(...J.map(C=>C.y+C.h),...ee.map(C=>C[1])),flat:!0,routes:ne,branches:U}}const tp=132,np=40,rp=36;function Hs(e,t){const n=new Map,r=new Set;for(const c of t)(n.get(c.from)??n.set(c.from,[]).get(c.from)).push(c.to),r.add(c.to);const o=new Map,s=[],i=c=>{o.set(c,"open");for(const d of n.get(c)??[])o.has(d)||i(d);o.set(c,"done"),s.push(c)};for(const c of[...e.filter(d=>!r.has(d)),...e])o.has(c)||i(c);const a=s.reverse(),l=new Map(a.map((c,d)=>[c,d])),u=new Map(e.map(c=>[c,0]));for(const c of a)for(const d of n.get(c)??[])(l.get(d)??0)>(l.get(c)??0)&&u.set(d,Math.max(u.get(d)??0,(u.get(c)??0)+1));return u}async function s2(e,t){const n=Hs(e.nodes.map(c=>c.id),Bs(e,t)),r=Math.max(0,...n.values())+1,o=2*be.side+r*tt+(r-1)*tp,s=c=>Math.min(...e.nodes.filter(d=>d.area===c).map(d=>n.get(d.id)??0)),i=e.areas.filter(c=>e.nodes.some(d=>d.area===c.id)).sort((c,d)=>s(c.id)-s(d.id)),a={},l={};let u=0;for(const c of i){const d=new Map;let h=1;for(const v of e.nodes.filter(x=>x.area===c.id)){const x=n.get(v.id)??0,S=d.get(x)??0;d.set(x,S+1),h=Math.max(h,S+1),l[v.id]={x:be.side+x*(tt+tp),y:be.top+S*(qe+np),w:tt,h:qe}}const f=be.top+h*qe+(h-1)*np+be.bottom;a[c.id]={x:0,y:u,w:o,h:f},u+=f+rp}return{areas:a,nodes:l,width:o,height:Math.max(0,u-rp),lanes:!0}}function i2(e){const t=e.nodes.map(v=>v.id),n=new Map;for(const v of e.edges)v.from!==v.to&&(n.get(v.from)??n.set(v.from,[]).get(v.from)).push(v.to);let r=0;const o=new Map,s=new Map,i=[],a=new Set,l=[],u=v=>{o.set(v,r),s.set(v,r),r++,i.push(v),a.add(v);for(const x of n.get(v)??[])o.has(x)?a.has(x)&&s.set(v,Math.min(s.get(v),o.get(x))):(u(x),s.set(v,Math.min(s.get(v),s.get(x))));if(s.get(v)===o.get(v)){const x=[];for(let S=i.pop();a.delete(S),x.push(S),S!==v;S=i.pop());l.push(x)}};for(const v of t)o.has(v)||u(v);const c=Hs(t,e.edges.map(v=>({from:v.from,to:v.to}))),d=new Map(e.nodes.map(v=>[v.id,v.area])),h=new Set,f=[];for(const v of l){if(v.length<3||v.length>8)continue;const x=new Set(v),S=[...v].sort((p,w)=>(c.get(p)??0)-(c.get(w)??0)||t.indexOf(p)-t.indexOf(w)),y=[S[0]];for(let p=S[0];;){const w=S.find(b=>!y.includes(b)&&(n.get(p)??[]).includes(b));if(!w)break;y.push(w),p=w}for(const p of S)y.includes(p)||y.push(p);const m=[];for(const p of y)m[m.length-1]!==d.get(p)&&m.push(d.get(p));if(m.length>1&&m[0]===m[m.length-1]&&m.pop(),!(m.length>2||m.some(p=>h.has(p))||!x.size)){for(const p of m)h.add(p);f.push({order:y,areas:m})}}return f}const Zo=70;async function op(e,t,n,r,o,s,i){const a=n.length?await Ed(e,t,n,r.filter(f=>n.some(v=>v.id===f.from)&&n.some(v=>v.id===f.to))):null,l={},u=a?a.size.w-be.side:0,c=s==="right"?(a?u+pr:be.side)+Zo:be.side,d=s==="left"&&a?tt+pr+Zo:0;if(a)for(const[f,v]of Object.entries(a.nodes))l[f]={...v,x:v.x+d};o.forEach((f,v)=>{const x=Zo*Math.sin(Math.PI*(v+.5)/o.length);l[f]={x:c+(s==="right"?-x:x),y:be.top+i+v*(qe+on),w:tt,h:qe}});const h=Object.values(l);return{nodes:l,size:{w:Math.max(...h.map(f=>f.x+f.w))+be.side,h:Math.max(...h.map(f=>f.y+f.h),a?a.size.h-be.bottom:0)+be.bottom}}}async function sp(e,t){var b;const n=await bd(),r=new Map(e.nodes.map(k=>[k.id,k.area])),o=Bs(e,t),s=i2(e),i=Hs(e.nodes.map(k=>k.id),e.edges.map(k=>({from:k.from,to:k.to}))),a=new Set(e.nodes.map(k=>k.area)),l=()=>{const k=new Map;for(const E of o){const _=r.get(E.from),A=r.get(E.to);_!==A&&k.set(`${_}>${A}`,{from:_,to:A})}return[...k.values()]},u=new Map;if(s.some(k=>k.areas.length===2)){const k=await n.layout({id:"root",layoutOptions:{...Ca,"elk.direction":"RIGHT"},children:e.areas.filter(E=>a.has(E.id)).map(E=>({id:E.id,width:100,height:100})),edges:l().map((E,_)=>({id:`q${_}`,sources:[E.from],targets:[E.to]}))});for(const E of k.children??[])u.set(E.id,E.x??0)}const c=new Map,d=new Map,h=new Map;for(const k of s)if(k.areas.length===2){const[E,_]=k.areas,A=M=>Math.min(...e.nodes.filter(I=>I.area===M).map(I=>i.get(I.id)??0)),[L,$]=A(_)<A(E)?[_,E]:[E,_];(u.get(L)??0)<(u.get($)??0)||c.set(L,$);const F=k.order.length,B=k.order.findIndex((M,I)=>r.get(M)===L&&r.get(k.order[(I-1+F)%F])===$),N=[...k.order.slice(B),...k.order.slice(0,B)],P=N.filter(M=>r.get(M)===L).reverse(),R=N.filter(M=>r.get(M)===$),O=Math.max(P.length,R.length),j=M=>(O-M)*(qe+on)/2;d.set(L,[{column:P,side:"right",drop:j(P.length)}]),d.set($,[{column:R,side:"left",drop:j(R.length)}]),h.set(L,$)}else{const E=Math.ceil(k.order.length/2),_=k.order.slice(0,E).reverse(),A=k.order.slice(E),L=Math.max(_.length,A.length),$=F=>(L-F)*(qe+on)/2;d.set(k.areas[0],[{column:_,side:"right",drop:$(_.length)},{column:A,side:"left",drop:$(A.length)}])}const f={},v={};for(const k of e.areas){const E=e.nodes.filter($=>$.area===k.id);if(!E.length)continue;const _=o.filter($=>r.get($.from)===k.id&&r.get($.to)===k.id),A=d.get(k.id);if((A==null?void 0:A.length)===1){const $=A[0],F=await op(n,k.id,E.filter(B=>!$.column.includes(B.id)),_,$.column,$.side,$.drop);Object.assign(f,F.nodes),v[k.id]=F.size;continue}if((A==null?void 0:A.length)===2){const[$,F]=A,B=new Set([...$.column,...F.column]),N=await op(n,k.id,E.filter(O=>!B.has(O.id)),_,$.column,"right",$.drop),P=Math.max(...$.column.map(O=>N.nodes[O].x))+tt+pr+Zo;F.column.forEach((O,j)=>{const M=Zo*Math.sin(Math.PI*(j+.5)/F.column.length);N.nodes[O]={x:P+M,y:be.top+F.drop+j*(qe+on),w:tt,h:qe}}),Object.assign(f,N.nodes);const R=Object.values(N.nodes);v[k.id]={w:Math.max(...R.map(O=>O.x+O.w))+be.side,h:Math.max(N.size.h,...R.map(O=>O.y+O.h+be.bottom))};continue}const L=await Ed(n,k.id,E,_);Object.assign(f,L.nodes),v[k.id]=L.size}const x=new Map,S=new Map(e.edges.map(k=>[`${k.from}>${k.to}`,k.label]));for(const k of o){const E=r.get(k.from),_=r.get(k.to);if(E===_||!v[E]||!v[_]||c.get(_)===E)continue;const A=`${E}>${_}`,L=l2(S.get(`${k.from}>${k.to}`)??"");x.set(A,{from:E,to:_,label:Math.max(((b=x.get(A))==null?void 0:b.label)??0,L)})}const y=await n.layout({id:"root",layoutOptions:{...Ca,"elk.direction":"RIGHT","elk.layered.spacing.nodeNodeBetweenLayers":"120","elk.spacing.nodeNode":"48","elk.spacing.componentComponent":"64"},children:e.areas.filter(k=>v[k.id]).map(k=>({id:k.id,width:v[k.id].w,height:v[k.id].h})),edges:[...x.values()].map((k,E)=>{const _=c2(k.label);return{id:`p${E}`,sources:[k.from],targets:[k.to],..._?{labels:[{id:`p${E}l`,text:" ",width:_,height:a2}]}:{}}})}),m={};for(const k of y.children??[])m[k.id]={x:k.x??0,y:k.y??0,w:k.width??0,h:k.height??0};for(const[k,E]of h){const _=m[k],A=m[E];if(!_||!A)continue;const L=_.y-A.y,$={...A,y:A.y+L};Object.entries(m).some(([B,N])=>B!==E&&B!==k&&$.x<N.x+N.w&&N.x<$.x+$.w&&$.y<N.y+N.h&&N.y<$.y+$.h)||(m[E]=$)}const p=Object.values(m),w=Math.min(0,...p.map(k=>k.y));if(w<0)for(const k of p)k.y-=w;return{areas:m,nodes:f,width:Math.max(y.width??0,...p.map(k=>k.x+k.w)),height:Math.max(y.height??0,...p.map(k=>k.y+k.h)),...s.length?{rings:s.map(k=>k.order)}:{}}}const a2=24,l2=e=>e?Math.ceil(e.length*6.8+16):0,u2=40;function c2(e){return Math.max(0,e+2*u2-2*120)}function j0(e){const t=Hs(e.nodes.map(n=>n.id),e.edges.map(n=>({from:n.from,to:n.to})));return new Set(e.edges.filter(n=>n.from!==n.to&&(t.get(n.to)??0)<=(t.get(n.from)??0)).map(n=>n.id))}function T0(e,t){const n=e.edges.find(d=>d.id===t);if(!n||!j0(e).has(t))return null;const r=e.edges.filter(d=>d.id!==t),o=(d,h)=>{const f=new Set([d]);for(let v=!0;v;){v=!1;for(const x of r){const[S,y]=h(x);f.has(S)&&!f.has(y)&&(f.add(y),v=!0)}}return f},s=o(n.to,d=>[d.from,d.to]),i=o(n.from,d=>[d.to,d.from]),a=new Set([...s].filter(d=>i.has(d))),l=Hs(e.nodes.map(d=>d.id),e.edges.map(d=>({from:d.from,to:d.to}))),u=e.nodes.map(d=>d.id).filter(d=>a.has(d)).sort((d,h)=>(l.get(d)??0)-(l.get(h)??0)),c=[...r.filter(d=>a.has(d.from)&&a.has(d.to)).map(d=>d.id),t];return{nodes:u,edges:c}}function d2(e,t,n,r){var h;if(t.flat){const f=y=>{const m=t.nodes[y];return m?{x:m.x+m.w/2,y:m.y+m.h/2}:{x:0,y:0}},v=f(r).x-f(n).x,x=f(r).y-f(n).y;if(Math.abs(v)<40)return x>=0?["b","t"]:["t","b"];const S=_a(t,r)-_a(t,n);return S?S>0?["b","t"]:["r","b"]:v>=0?["r","l"]:["l","r"]}const o=f=>{var v;return((v=e.nodes.find(x=>x.id===f))==null?void 0:v.area)??""},s=f=>{const v=t.areas[o(f)],x=t.nodes[f];return v&&x?{x:v.x+x.x+x.w/2,y:v.y+x.y+x.h/2}:{x:0,y:0}},i=s(n),a=s(r),l=a.x-i.x,u=a.y-i.y,c=(h=t.rings)==null?void 0:h.find(f=>f.includes(n)),d=!!c&&c.includes(r)&&Math.abs(l)>=tt*.75;return!t.lanes&&!d&&o(n)===o(r)||Math.abs(l)<tt*.75?u>=0?["b","t"]:["t","b"]:l>=0?["r","l"]:["l","r"]}function f2(e,t=[],n=[],r=[]){return JSON.stringify([e.view??null,e.view==="journey"?[e.nodes.map(o=>o.kind),[...r].sort()]:null,[...e.nodes,...e.edges].map(o=>o.branch??""),[...n].sort(),e.areas.map(o=>o.id),e.nodes.map(o=>`${o.id}@${o.area}`),e.edges.map(o=>`${o.from}>${o.to}`),e.absences.map(o=>o.between?`${o.between.from}~${o.between.to}`:""),t.map(o=>`${o.from}+${o.to}`)])}const Ir=()=>({nodes:[],edges:[],absences:[]}),zo=e=>e.nodes.length+e.edges.length+e.absences.length,h2=e=>({mapId:e,phase:"loading",meta:null,map:null,report:null,job:null,error:null,answers:[],shown:null,selection:Ir(),tour:null,peek:!1,views:[],viewIndex:-1,fixes:{},fresh:[],hidden:[],connected:!1,agent:S0}),p2=e=>e.views[e.viewIndex]??null;function Us(e){if(!e.map)return[];const t=new Set([...e.map.areas,...e.map.nodes,...e.map.edges,...e.map.absences].map(n=>n.id));return e.answers.flatMap(n=>{const r=n.added.filter(o=>t.has(o));return r.length?[{answerId:n.id,question:n.question,ids:r,visible:!e.hidden.includes(n.id)}]:[]})}const g2=e=>Us(e).flatMap(t=>t.ids);function $0(e){if(!e.map)return null;const t=new Set(Us(e).filter(o=>!o.visible).flatMap(o=>o.ids));if(!t.size)return e.map;const n=e.map.nodes.filter(o=>!t.has(o.id)),r=new Set(n.map(o=>o.id));return{...e.map,areas:e.map.areas.filter(o=>!t.has(o.id)),nodes:n,edges:e.map.edges.filter(o=>!t.has(o.id)&&r.has(o.from)&&r.has(o.to)),absences:e.map.absences.filter(o=>!t.has(o.id)&&(!o.between||r.has(o.between.from)&&r.has(o.between.to)))}}function m2(e,t){if(!t)return e;const n=(r,o)=>r.filter(s=>o.some(i=>i.id===s));return{nodes:n(e.nodes,t.nodes),edges:n(e.edges,t.edges),absences:n(e.absences,t.absences)}}function y2(e,t){var i,a,l;const n=e.tour[t];if(!n)return null;const r=e.nodes.filter(u=>{var c;return(c=n.focus.areas)==null?void 0:c.includes(u.area)}).map(u=>u.id),o=[...n.focus.nodes??[],...n.focus.edges??[],...n.focus.absences??[],...r],s=(n.focus.edges??[]).length||(n.focus.absences??[]).length?[]:I0(e,new Set(o));return{focus:((i=n.focus.nodes)==null?void 0:i[0])??((a=n.focus.edges)==null?void 0:a[0])??((l=n.focus.absences)==null?void 0:l[0])??null,highlight:[...new Set([...o,...s])]}}function I0(e,t){return e.edges.filter(n=>t.has(n.from)&&t.has(n.to)).map(n=>n.id)}function ip(e,t){const n=[...t.moves.highlight,...t.added],r=e?[...new Set([...n,...I0(e,new Set(n))])]:n;return r.length||t.moves.focus?{focus:t.moves.focus??r[0]??null,highlight:r}:null}function tr(e,t){if(!t)return e;const n=[...e.views.slice(0,e.viewIndex+1),t].slice(-50);return{...e,views:n,viewIndex:n.length-1}}function ap(e,t,n){const r={...t};for(const o of e){if(!o.fix||r[o.fix.id]&&!n)continue;const s=n?n[o.fix.id]:{status:"proposed"};r[o.fix.id]={proposal:o.fix,answerId:o.id,status:(s==null?void 0:s.status)??"rejected",problems:[],edgeId:(s==null?void 0:s.edgeId)??null,closed:(s==null?void 0:s.closed)??[],undoable:(s==null?void 0:s.undoable)??!0}}return r}function v2(e,t){var n;switch(t.type){case"loaded":{const r=t.payload,o=r.map?"ready":r.job?"making":r.failure?"failed":"missing";return{...e,phase:o,meta:r.meta,map:r.map,report:r.report,job:r.job,error:((n=r.failure)==null?void 0:n.error)??null,answers:r.answers,shown:null,fixes:ap(r.answers,e.fixes,r.fixes??{}),agent:r.agent??e.agent}}case"missing":return{...e,phase:"missing"};case"connected":return{...e,connected:t.value};case"event":{const r=t.event;if(r.mapId!==e.mapId)return e;if(r.type==="job")return r.status==="started"?{...e,job:{kind:r.job,question:r.question,progress:[]},error:null,phase:r.job==="make"?"making":e.phase}:r.status==="failed"?{...e,job:null,error:r.error??"Something went wrong.",phase:r.job==="make"&&!e.map?"failed":e.phase}:{...e,job:null};if(r.type==="progress")return e.job?{...e,job:{...e.job,progress:[...e.job.progress,r.text].slice(-200)}}:e;if(r.type==="map"){const o=i=>i.filter(a=>r.map.nodes.some(l=>l.id===a)||r.map.edges.some(l=>l.id===a)||r.map.absences.some(l=>l.id===a)),s={nodes:o(e.selection.nodes),edges:o(e.selection.edges),absences:o(e.selection.absences)};return{...e,phase:"ready",meta:r.meta,map:r.map,report:r.report,selection:s}}if(r.type==="answer"){const o=[...e.answers,r.answer],s={...e,answers:o,shown:r.answer.id,tour:null,peek:!1,fresh:r.answer.added,fixes:ap([r.answer],e.fixes,void 0)};return tr(s,ip(e.map,r.answer))}if(r.type==="answerUpdate")return{...e,answers:e.answers.map(o=>o.id===r.answer.id?r.answer:o)};if(r.type==="fix"){const o=e.fixes[r.fixId];if(!o)return e;const s=r.status,i={...e.fixes,[r.fixId]:{...o,status:s,problems:r.problems??[],edgeId:r.edgeId??o.edgeId,closed:r.closed??o.closed,undoable:r.status==="applied"?!0:o.undoable}},a={...e,fixes:i};if(r.status==="applied"&&r.edgeId){const l=o.proposal.connects;return tr(a,{focus:r.edgeId,highlight:[r.edgeId,...l?[l.from,l.to]:[]]})}return a}return e}case"select":{const r=e.selection[t.kind],o=r.includes(t.id),s=t.additive?{...e.selection,[t.kind]:o?r.filter(i=>i!==t.id):[...r,t.id]}:{...Ir(),[t.kind]:o&&zo(e.selection)===1?[]:[t.id]};return{...e,selection:s}}case"selectMany":return{...e,selection:t.selection};case"clearSelection":return{...e,selection:Ir()};case"tour":{if(!e.map)return{...e,tour:null,peek:!1};if(t.stop===null)return e.tour===null?e:tr({...e,tour:null,peek:!1},{focus:null,highlight:[]});const r=Math.max(0,Math.min(t.stop,e.map.tour.length-1));return tr({...e,tour:r,selection:Ir()},y2(e.map,r))}case"peek":{if(!t.open)return{...e,peek:!1};const r=e.answers[e.answers.length-1];return r?{...e,peek:!0,shown:e.shown??r.id}:e}case"focus":{if(!e.map)return e;const r=e.map.nodes.some(o=>o.id===t.id)?"nodes":e.map.edges.some(o=>o.id===t.id)?"edges":e.map.absences.some(o=>o.id===t.id)?"absences":null;return r?tr({...e,tour:null,peek:!1,selection:{...Ir(),[r]:[t.id]}},{focus:t.id,highlight:[t.id]}):e}case"back":return e.viewIndex>0?{...e,viewIndex:e.viewIndex-1}:e.viewIndex===0?{...e,viewIndex:-1}:e;case"forward":return e.viewIndex<e.views.length-1?{...e,viewIndex:e.viewIndex+1}:e;case"show":{const r=e.answers.find(o=>o.id===t.answerId);return tr({...e,shown:t.answerId,tour:null,peek:!1},r?ip(e.map,r):null)}case"overview":return tr({...e,shown:null,tour:null,peek:!1,selection:Ir(),fresh:[]},{focus:null,highlight:[]});case"layer":case"allLayers":{const r=t.type==="layer"?[t.answerId]:Us(e).map(i=>i.answerId),o=t.visible?e.hidden.filter(i=>!r.includes(i)):[...new Set([...e.hidden,...r])],s={...e,hidden:o};return{...s,selection:m2(e.selection,$0(s))}}case"fixStatus":{const r=e.fixes[t.fixId];return r?{...e,fixes:{...e.fixes,[t.fixId]:{...r,status:t.status,problems:t.problems??r.problems}}}:e}case"error":return{...e,error:t.message}}}const gr=(...e)=>e.filter(Boolean).join(" ");function ut(e,t){const n=e.nodes.find(i=>i.id===t);if(n)return n.name;const r=e.edges.find(i=>i.id===t);if(r)return`${ut(e,r.from)} → ${ut(e,r.to)}`;const o=e.absences.find(i=>i.id===t);if(o)return o.claim;const s=e.areas.find(i=>i.id===t);return(s==null?void 0:s.label)??t}const w2={add:{pending:"Proposed: this isn’t in the code yet.",done:"This was proposed, and the code now has it."},change:{pending:"Proposed: this code would change.",done:"This was proposed to change, and the code here has changed since."},remove:{pending:"Proposed: this code would be removed.",done:"This was proposed for removal, and it’s no longer in the code."}},x2={added:"New since",changed:"Changed since",removed:"Removed since"};function rc(e,t){return e?e.nodes[t]??e.edges[t]??(e.absences[t]?{status:e.absences[t].status,reasons:e.absences[t].reasons}:null):null}function ht({eyebrow:e,title:t,children:n,tone:r,className:o}){return g.jsxs("section",{className:gr("card",r&&`card-${r}`,o),children:[e&&g.jsx("div",{className:"eyebrow",children:e}),t&&g.jsx("h2",{className:"card-title",children:t}),n]})}function k2({map:e,ids:t,onPick:n}){return t.length?g.jsx("div",{className:"chips",children:t.map(({id:r,status:o})=>g.jsxs("button",{className:gr("chip",o==="proposed"?"chip-proposed":o!=="confirmed"&&"chip-unconfirmed"),onClick:()=>n(r),title:o==="confirmed"?"Confirmed against the code":o==="proposed"?"Part of a proposal, not in the code":"Couldn't confirm against the code",children:[g.jsx("span",{className:o==="confirmed"?"tick":o==="proposed"?"pmark":"qmark",children:o==="confirmed"?"✓":o==="proposed"?"+":"?"}),ut(e,r)]},r))}):null}function lp({lines:e,working:t}){const n=e.slice(-8);return g.jsxs("ul",{className:"progress",children:[n.map((r,o)=>g.jsxs("li",{className:gr(t&&o===n.length-1&&"running"),children:[g.jsx("span",{className:"ic",children:t&&o===n.length-1?"…":"✓"}),r]},`${o}-${r}`)),!n.length&&t&&g.jsxs("li",{className:"running",children:[g.jsx("span",{className:"ic",children:"…"}),"Starting"]})]})}function S2({fix:e,onApprove:t,onReject:n,onUndo:r,map:o}){const s=e.proposal,i=s.files.filter(a=>a.uncommitted);return e.status==="applied"?g.jsxs(ht,{eyebrow:"Fix applied · re-checked",tone:"ok",children:[g.jsxs("ul",{className:"progress",children:[g.jsxs("li",{children:[g.jsx("span",{className:"ic",children:"✓"}),"Changed ",s.files.length," ",s.files.length===1?"file":"files",": ",s.files.map(a=>a.file).join(", ")]}),e.edgeId&&g.jsxs("li",{children:[g.jsx("span",{className:"ic",children:"✓"}),"New confirmed connection: ",ut(o,e.edgeId)]}),e.closed.length>0&&g.jsxs("li",{children:[g.jsx("span",{className:"ic",children:"✓"}),"Closed: ",e.closed.length===1?"the missing connection":`${e.closed.length} missing connections`]})]}),e.undoable?g.jsx("div",{className:"btns",children:g.jsx("button",{className:"btn",onClick:r,children:"Undo this fix"})}):g.jsx("p",{className:"muted small",children:"Undo ended when illuminate stopped. Use git to reverse it."})]}):e.status==="rejected"||e.status==="undone"?g.jsxs(ht,{eyebrow:e.status==="undone"?"Fix undone":"Fix rejected",children:[g.jsx(_s,{text:s.summary,className:"muted"}),e.status==="undone"&&g.jsx("div",{className:"btns",children:g.jsx("button",{className:"btn",onClick:t,children:"Apply it again"})})]}):g.jsxs(ht,{eyebrow:`Proposed fix · ${s.files.length} ${s.files.length===1?"file":"files"} · nothing changed yet`,tone:"ai",children:[g.jsx(_s,{text:s.summary}),s.connects&&g.jsx("p",{className:"muted small",children:"The green dashed arrow is the connection it adds."}),g.jsx("pre",{className:"diff",children:s.diff.split(`
|
|
79
79
|
`).map((a,l)=>g.jsxs("span",{className:a.startsWith("+ ")?"add":a.startsWith("- ")?"del":a.includes(" · ")?"file":"",children:[a,`
|
|
80
80
|
`]},l))}),i.length>0?g.jsxs("p",{className:"warn small",children:["⚠ ",i.map(a=>a.file).join(", ")," ",i.length===1?"has":"have"," uncommitted changes. They'll be kept; the fix applies on top."]}):null,e.problems.length>0&&g.jsx("ul",{className:"problems",children:e.problems.map(a=>g.jsx("li",{children:a},a))}),g.jsxs("div",{className:"btns",children:[g.jsx("button",{className:"btn primary",disabled:e.status==="applying",onClick:t,children:e.status==="applying"?"Applying…":"Approve"}),g.jsx("button",{className:"btn",onClick:n,children:"Reject"})]}),g.jsx("p",{className:"muted small",children:"Won't apply if these files change first."})]})}function b2({state:e,dispatch:t,onFix:n,onFocus:r,onOffer:o,composer:s}){const i=e.map,a=e.job,l=T.useRef(null),u=T.useRef(!0),[c,d]=T.useState(!1),h=()=>{var y;const S=(y=l.current)==null?void 0:y.querySelectorAll(":scope > .turn");return S!=null&&S.length?S[S.length-1]:null},f=(S=!1)=>{const y=l.current,m=h();!y||!m||y.scrollTo({top:HC(y.scrollTop,y.getBoundingClientRect().top,m.getBoundingClientRect().top),behavior:S?"smooth":"auto"})};if(T.useEffect(()=>{const S=l.current;if(!S)return;u.current=!0,d(!1),f();const y=new ResizeObserver(()=>{u.current&&f()});for(const m of Array.from(S.children))y.observe(m);return()=>y.disconnect()},[e.answers.length,!!a,!!i]),T.useEffect(()=>{const S=l.current;if(!S)return;const y=()=>{u.current=!1},m=w=>{w.target===S&&y()},p=()=>{const w=h();d(!!w&&UC(S.getBoundingClientRect().bottom,w.getBoundingClientRect().top))};return S.addEventListener("wheel",y,{passive:!0}),S.addEventListener("touchmove",y,{passive:!0}),S.addEventListener("keydown",y),S.addEventListener("pointerdown",m),S.addEventListener("scroll",p,{passive:!0}),()=>{S.removeEventListener("wheel",y),S.removeEventListener("touchmove",y),S.removeEventListener("keydown",y),S.removeEventListener("pointerdown",m),S.removeEventListener("scroll",p)}},[!!i]),e.phase==="loading")return g.jsx("aside",{className:"panel",children:g.jsx("div",{className:"panel-scroll",children:g.jsx(ht,{children:g.jsx("p",{className:"muted",children:"Loading…"})})})});if(e.phase==="missing")return g.jsx("aside",{className:"panel",children:g.jsx("div",{className:"panel-scroll",children:g.jsx(ht,{title:"No map here",children:g.jsx("p",{className:"muted",children:"This map isn't in this repo."})})})});if(!i)return g.jsx("aside",{className:"panel",children:g.jsxs("div",{className:"panel-scroll",children:[a&&g.jsx(ht,{eyebrow:"Making your map",title:a.question,tone:"ai",children:g.jsx(lp,{lines:a.progress,working:!0})}),e.phase==="failed"&&g.jsx(ht,{title:"The map couldn't be made",tone:"dead",children:g.jsx("p",{children:e.error})})]})});[...e.selection.nodes,...e.selection.edges,...e.selection.absences];const v=Us(e),x=v.length>0&&v.every(S=>!S.visible);return g.jsxs("aside",{className:"panel","aria-label":"Conversation about this map",children:[g.jsxs("header",{className:"panel-head",children:[g.jsx("h2",{className:"panel-title",children:"Conversation"}),v.length>0&&g.jsx("button",{className:"link-btn small",onClick:()=>t({type:"allLayers",visible:x}),children:x?"Show everything":"Show the original map"}),g.jsx("button",{className:"card-close","aria-label":"Close the conversation",title:"Close (Esc). It stays here to reopen.",onClick:()=>t(e.tour!==null?{type:"peek",open:!1}:{type:"overview"}),children:"×"})]}),g.jsxs("div",{className:"panel-scroll",ref:l,children:[e.error&&g.jsxs("div",{className:"banner banner-dead",role:"alert",children:[e.error,g.jsx("button",{className:"link-btn",onClick:()=>t({type:"error",message:null}),children:"Dismiss"})]}),e.answers.map(S=>g.jsx(N2,{answer:S,state:e,dispatch:t,onFix:n,onFocus:r,onOffer:o},S.id)),(a==null?void 0:a.kind)==="ask"&&g.jsxs("article",{className:"turn",children:[g.jsx(R0,{question:a.question}),g.jsx(ht,{eyebrow:`${e.agent.name} is working`,tone:"ai",children:g.jsx(lp,{lines:a.progress,working:!0})})]}),!e.answers.length&&!a&&g.jsx("p",{className:"muted small thread-empty",children:"Ask anything about this map. Click a box or arrow first to ask about it."})]}),g.jsxs("footer",{className:"panel-foot",children:[c&&g.jsx("button",{className:"to-latest",onClick:()=>{u.current=!0,f(!0)},children:"↓ Latest"}),s]})]})}function E2({map:e,edgeId:t}){const n=T0(e,t);if(!n)return null;const r=n.nodes.map(o=>ut(e,o));return g.jsxs("p",{className:"loop-note small",children:[g.jsx("strong",{children:"A loop."})," It goes back to ",r[0],", so this runs round again: ",r.join(" → ")," → ",r[0],"."]})}function R0({question:e,about:t}){const{question:n,step:r}=BC(e),o=[r&&`the step “${r}”`,t].filter(Boolean);return g.jsxs("div",{className:"you",children:[g.jsx("p",{className:"you-q",children:n}),o.length>0&&g.jsxs("span",{className:"you-about",children:["About ",o.join(", ")]})]})}function N2({answer:e,state:t,dispatch:n,onFix:r,onFocus:o,onOffer:s}){const i=t.map,a=e.fix?t.fixes[e.fix.id]??null:null,l=e.id===t.shown&&t.tour===null,u=[...e.selection.nodes??[],...e.selection.edges??[],...e.selection.absences??[]].map(x=>ut(i,x)).join(", "),c=Us(t).find(x=>x.answerId===e.id),d=e.problems.filter(x=>x.startsWith("The proposed fix")),h=e.problems.filter(x=>!x.startsWith("The proposed fix")),f=e.refs.filter(x=>{var S;return x.status!=="unknown"&&((S=rc(t.report,x.id))==null?void 0:S.status)==="unconfirmed"}).map(x=>x.id),v=e.moves.highlight.length>0||!!e.moves.focus||e.added.length>0||(e.screens??[]).length>0;return g.jsxs("article",{className:"turn",children:[g.jsx(R0,{question:e.question,about:u||void 0}),e.offer?g.jsx(_2,{answer:e,busy:!!t.job,agentName:t.agent.name,onOffer:s}):g.jsxs("section",{className:gr("card","reply",l&&"card-focus"),children:[g.jsxs("div",{className:"reply-meta",children:[g.jsx("span",{children:e.source==="map"?"From the map":"Looked in the code"}),v&&(l?g.jsx("span",{className:"reply-lit",children:"Lit on the map"}):g.jsx("button",{className:"link-btn small",onClick:()=>n({type:"show",answerId:e.id}),children:"Show on the map"}))]}),g.jsx(_s,{text:e.concept,className:"depth-text"}),(e.notes??[]).length>0&&g.jsx(MC,{mapId:t.mapId,answerId:e.id,stamp:t.report}),(e.screens??[]).map(x=>{const S=ec(t.report,x);return S?g.jsx(A0,{show:S,name:ut(i,x)},x):null}),f.length>0&&g.jsxs("p",{className:"warn small reply-warn",children:["Relies on ",f.length===1?"1 thing":`${f.length} things`," the checker couldn't confirm:"," ",f.map((x,S)=>g.jsxs("span",{children:[S>0&&", ",g.jsx("button",{className:"link-btn small",title:"Show it on the map",onClick:()=>o(x),children:ut(i,x)})]},x))]}),c&&g.jsxs("div",{className:"reply-added",children:[g.jsxs("span",{children:["Added ",c.ids.length," to the map"]}),g.jsx("button",{className:"link-btn small",onClick:()=>n({type:"layer",answerId:e.id,visible:!c.visible}),children:c.visible?"Hide":"Show"})]}),h.length>0&&g.jsxs("details",{className:"problems-box",children:[g.jsxs("summary",{children:[h.length," thing",h.length===1?"":"s"," Claude found but couldn't confirm or show"]}),g.jsx("ul",{className:"problems",children:h.map(x=>g.jsx("li",{children:x},x))})]})]}),a&&g.jsx(S2,{fix:a,map:i,onApprove:()=>r(a.proposal.id,"approve"),onReject:()=>r(a.proposal.id,"reject"),onUndo:()=>r(a.proposal.id,"undo")}),d.length>0&&g.jsxs(ht,{eyebrow:"The proposed fix can't be applied",tone:"dead",children:[g.jsx("ul",{className:"problems",children:d.map(x=>g.jsx("li",{children:x.replace("The proposed fix can't be applied: ","")},x))}),g.jsx("p",{className:"muted small",children:"Ask again, or ask for a smaller change."})]})]})}function _2({answer:e,busy:t,agentName:n,onOffer:r}){const o=e.offer;return o.status==="mapped"?g.jsxs(ht,{eyebrow:"A different part of the app",children:[g.jsx("p",{className:"muted",children:"You made a new map for this."}),o.mapId&&g.jsx("div",{className:"btns",children:g.jsx("a",{className:"btn primary",href:sn(o.mapId),children:"Open it"})})]}):o.status==="answered"?g.jsx(ht,{eyebrow:"A different part of the app",children:g.jsx("p",{className:"muted",children:"Answered in words, below."})}):g.jsxs(ht,{eyebrow:"A different part of the app",tone:"ai",children:[g.jsx("p",{children:"This is about a different part of the app than this map shows."}),o.existing&&g.jsxs("p",{children:["There's already a map for it: “",o.existing.question,"”."]}),g.jsxs("div",{className:"btns",children:[o.existing&&g.jsx("a",{className:"btn primary",href:sn(o.existing.id),children:"Open that map"}),g.jsx("button",{className:o.existing?"btn":"btn primary",onClick:()=>r(e.id,"map"),children:"Make a new map for this"}),g.jsx("button",{className:"btn",disabled:t,onClick:()=>r(e.id,"words"),title:t?`${n} is still working on this map`:void 0,children:"Just answer in words"})]})]})}function C2({mapId:e,map:t,report:n,ids:r,onClose:o}){var A,L,$,F,B;const[s,i]=jC(),[a,l]=TC(),[u,c]=T.useState(null),d=g.jsx("button",{className:"card-close","aria-label":"Close",title:"Close (Esc)",onClick:o,children:"×"});if(r.length>1)return g.jsxs(ht,{eyebrow:`Asking about ${r.length} things`,className:"card-selected",children:[d,g.jsx(k2,{map:t,ids:r.map(N=>{var P;return{id:N,status:((P=rc(n,N))==null?void 0:P.status)??"unknown"}}),onPick:()=>{}})]});const h=r[0],f=t.nodes.find(N=>N.id===h),v=t.edges.find(N=>N.id===h),x=t.absences.find(N=>N.id===h),S=rc(n,h),y=(f==null?void 0:f.evidence)??(v==null?void 0:v.evidence)??[],m=S&&"evidence"in S&&S.evidence?S.evidence:[],p=f?"Step":v?"Connection":"Missing connection",w=(S==null?void 0:S.proposal)??null,b=(L=(A=f??v)==null?void 0:A.proposed)==null?void 0:L.note,k=S&&"change"in S?S.change??null:null,E=((F=($=n==null?void 0:n.since)==null?void 0:$.commit)==null?void 0:F.slice(0,7))??"the commit this map is compared with",_=x?(n==null?void 0:n.absences[x.id])??null:null;return g.jsxs(ht,{eyebrow:p,title:ut(t,h),tone:x?"dead":void 0,className:"card-selected",children:[d,((B=f==null?void 0:f.explain)==null?void 0:B.concept)&&g.jsx(_s,{text:f.explain.concept,className:"depth-text"}),v&&g.jsx(E2,{map:t,edgeId:v.id}),f&&ec(n,f.id)&&g.jsx(A0,{show:ec(n,f.id),name:f.name}),w&&g.jsxs("div",{className:gr("proposal-note",`proposal-note-${w.state}`),children:[g.jsx("strong",{children:w2[w.kind][w.state]}),b&&g.jsxs(g.Fragment,{children:[" ",b]})]}),k&&g.jsxs("div",{className:gr("change-note",`change-note-${k.kind}`),children:[g.jsxs("div",{className:"change-head",children:[g.jsxs("span",{children:[g.jsxs("strong",{children:[x2[k.kind]," ",E,"."]}),k.kind==="changed"&&!k.diff&&" A line it cites wasn’t there then.",k.kind==="removed"&&" It was in the code then and is gone now.",k.diff&&g.jsx(A2,{diff:k.diff})]}),k.diff&&g.jsx("button",{className:"link-btn small",onClick:()=>l(!a),children:a?"Hide what changed":"Show what changed"})]}),k.diff&&a&&g.jsx("pre",{className:"diff",children:k.diff.map((N,P)=>g.jsxs("span",{className:N.startsWith("+ ")?"add":N.startsWith("- ")?"del":"",children:[N,`
|
|
81
|
-
`]},P))})]}),x&&_&&g.jsxs("p",{children:[_.found>x.matches?"This may no longer be missing: the search below now finds something.":"Nothing in the code connects these, going by this search."," ","Searched ",_.searched??"?"," ",_.searched===1?"file":"files",x.search.paths?g.jsxs(g.Fragment,{children:[" in ",g.jsx("code",{children:x.search.paths.join(", ")})]}):" (the whole repo)"," for ",g.jsx("code",{children:x.search.pattern}),": ",_.found," ",_.found===1?"match":"matches","."]}),S&&S.status==="unconfirmed"&&g.jsxs("div",{className:"warn small",children:["Couldn't confirm against the code: ",S.reasons.join("; ")]}),y.length>0&&g.jsxs("div",{className:"basis",children:[g.jsx("div",{className:"eyebrow",children:(k==null?void 0:k.kind)==="removed"?`In the code as it was at ${E}`:"In the code"}),g.jsx("div",{className:"chips",children:y.map((N,P)=>{var I,z;const R=((I=m[P])==null?void 0:I.ok)??!1,O=((z=m[P])==null?void 0:z.foundAt)??N.line,j=`${N.file}:${O}`,M=s&&((u==null?void 0:u.at)===j||!u&&y.length===1);return R?g.jsxs("button",{className:gr("chip cite",M&&"chip-open"),"aria-pressed":M,title:M?"Hide the code":"Show the code at this line",onClick:()=>{if(M){i(!1),c(null);return}i(!0),c(H=>({at:j,n:((H==null?void 0:H.n)??0)+1}))},children:[g.jsx("span",{className:"tick",children:"✓"}),N.file,":",O]},P):g.jsxs("span",{className:"chip static chip-unconfirmed",children:[g.jsx("span",{className:"qmark",children:"?"}),N.file,":",O]},P)})}),s&&(f||v)&&g.jsx(AC,{mapId:e,itemId:h,change:(k==null?void 0:k.kind)??null,since:E,stamp:n,jump:u})]})]})}function A2({diff:e}){const t=e.filter(r=>r.startsWith("+ ")).length,n=e.filter(r=>r.startsWith("- ")).length;return g.jsxs("span",{className:"diff-size",children:[t>0&&g.jsxs("span",{className:"add",children:[" +",t]}),n>0&&g.jsxs("span",{className:"del",children:[" −",n]})]})}function M2({map:e,selection:t,draft:n,busy:r,agentName:o="Claude",autoFocus:s,onDraft:i,onRemove:a,step:l,onRemoveStep:u,onSend:c}){const d=T.useRef(null),h=["nodes","edges","absences"].flatMap(f=>t[f].map(v=>({kind:f,id:v})));return T.useEffect(()=>{const f=d.current;f&&(f.style.height="auto",f.style.height=`${Math.min(f.scrollHeight,140)}px`)},[n]),T.useEffect(()=>{var f;n&&((f=d.current)==null||f.focus())},[n===""]),T.useEffect(()=>{var f;s&&((f=d.current)==null||f.focus({preventScroll:!0}))},[]),g.jsxs("form",{className:"composer",onSubmit:f=>{f.preventDefault(),!r&&n.trim()&&c()},children:[l&&g.jsxs("span",{className:"sel-chip sel-step",children:[g.jsxs("span",{className:"sel-text",title:`Walkthrough step: ${l}`,children:["▸ ",l]}),g.jsx("button",{type:"button","aria-label":`Don't ask about the step “${l}”`,onClick:u,children:"×"})]}),h.map(f=>g.jsxs("span",{className:`sel-chip sel-${f.kind}`,children:[g.jsxs("span",{className:"sel-text",title:ut(e,f.id),children:[f.kind==="absences"?"✕ ":"◉ ",ut(e,f.id)]}),g.jsx("button",{type:"button","aria-label":`Remove ${ut(e,f.id)}`,onClick:()=>a(f.kind,f.id),children:"×"})]},`${f.kind}:${f.id}`)),g.jsx("textarea",{ref:d,id:"ask",rows:1,value:n,placeholder:r?`${o} is working…`:h.length===1&&h[0].kind==="nodes"?"Ask, or try “what if it fails?”":h.length?"Ask about what you selected…":l?"Ask about this step…":"Ask about this map…",onChange:f=>i(f.target.value),onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),!r&&n.trim()&&c())},"aria-label":"Ask a question about the map"}),g.jsx("button",{type:"submit",className:"send",disabled:r||!n.trim(),"aria-label":"Send",children:"↑"})]})}function j2({map:e,agent:t,selection:n,step:r,onRemove:o}){const s=["nodes","edges","absences"].flatMap(a=>n[a].map(l=>({kind:a,id:l}))),i=mC(t,s.length,r);return g.jsxs("div",{className:"composer composer-chat",role:"note","aria-label":"Where to ask",children:[s.map(a=>g.jsxs("span",{className:`sel-chip sel-${a.kind}`,children:[g.jsxs("span",{className:"sel-text",title:ut(e,a.id),children:[a.kind==="absences"?"✕ ":"◉ ",ut(e,a.id)]}),g.jsx("button",{type:"button","aria-label":`Remove ${ut(e,a.id)}`,onClick:()=>o(a.kind,a.id),children:"×"})]},`${a.kind}:${a.id}`)),g.jsxs("p",{className:"chat-hint",children:[g.jsx("strong",{children:i.title})," ",g.jsx("span",{className:"muted",children:i.detail})]})]})}const Vl="illuminate-toured",T2=100;function up(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function $2(e,t,n=T2){return[...e.filter(r=>r!==t),t].slice(-n)}function I2(e,t){const[n,r]=T.useState(()=>up(Ns(Vl)).includes(e));return T.useEffect(()=>{!t||n||!e||(rl(Vl,JSON.stringify($2(up(Ns(Vl)),e))),r(!0))},[e,t,n]),n}function R2({map:e,mapId:t,tour:n,onTour:r,selected:o,children:s}){const i=I2(t,n!==null),a=e.tour.length,l=a>0&&n===null;return!l&&!s?null:g.jsxs("div",{className:"dock",children:[l&&g.jsxs("section",{className:"dock-part dock-walk","aria-label":"Walkthrough",children:[g.jsx("h2",{className:"dock-title",children:"Walkthrough"}),g.jsxs("button",{className:i?"dock-start":"dock-start glow",onClick:()=>r(0),children:["Take the walkthrough ",g.jsxs("span",{className:"muted",children:[a," ",a===1?"stop":"stops"]})]})]}),s&&g.jsxs("section",{className:"dock-part dock-ask","aria-label":"Ask about the map",children:[g.jsxs("div",{className:"dock-head",children:[g.jsx("h2",{className:"dock-title",children:"Ask about the map"}),g.jsx("span",{className:"dock-hint",children:o?"Shift-click to add more":"Click a box or arrow to ask about it"})]}),s]})]})}function L2({state:e,dispatch:t}){const n=e.answers[e.answers.length-1];return n?g.jsx("div",{className:"history-corner",children:g.jsxs("button",{className:"pill-btn history-btn",onClick:()=>t(e.tour!==null?{type:"peek",open:!0}:{type:"show",answerId:n.id}),title:"Open the conversation about this map",children:[g.jsx("span",{className:"history-arrow",children:"‹"})," Conversation ",g.jsx("span",{className:"muted",children:e.answers.length})]})}):null}const $r=14,Ye=12;function P2(e,t){const n=a=>a[a.length-1],r=n(t.nodes),o=n(t.edges),s=n(t.absences),i=r!==void 0?`.react-flow__node[data-id="${CSS.escape(r)}"]`:o!==void 0?`.link-label[data-id="${CSS.escape(`e:${o}`)}"]`:s!==void 0?`.link-label[data-id="${CSS.escape(`a:${s}`)}"]`:null;return i?e.querySelector(i):null}const oc="illuminate-bubble-size",L0=300,P0=180;function O2(){try{const e=JSON.parse(Ns(oc)??"null");if(e&&typeof e=="object"&&"w"in e&&"h"in e&&typeof e.w=="number"&&typeof e.h=="number")return{w:Math.max(L0,e.w),h:Math.max(P0,e.h)}}catch{}return null}function z2({mapId:e,map:t,report:n,selection:r,onClose:o}){const s=[...r.nodes,...r.edges,...r.absences],i=s.join(" "),a=T.useRef(null),[l,u]=T.useState(null),c=T.useRef(null),d=Ds(),h=ge(p=>p.transform.join(",")),[f,v]=T.useState(""),[x,S]=T.useState(O2),y=p=>{const w=a.current,b=w==null?void 0:w.querySelector(".card-selected"),k=w==null?void 0:w.parentElement;if(!w||!b||!k||!l)return;p.preventDefault();const E=p.clientX,_=p.clientY,A=w.offsetWidth,L=b.offsetHeight,$=k.clientWidth-2*Ye,F=l.side==="right"?1:-1;let B={w:A,h:L};const N=R=>{B={w:Math.round(Math.max(L0,Math.min($,A+F*(R.clientX-E)))),h:Math.round(Math.max(P0,L+R.clientY-_))},S(B)},P=()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",P),document.body.classList.remove("resizing-bubble"),rl(oc,JSON.stringify(B))};window.addEventListener("pointermove",N),window.addEventListener("pointerup",P),document.body.classList.add("resizing-bubble")},m=()=>{try{localStorage.removeItem(oc)}catch{}S(null)};return T.useLayoutEffect(()=>{const p=a.current;if(!p)return;const w=new ResizeObserver(()=>v(`${p.offsetWidth}x${p.offsetHeight}`));return w.observe(p),()=>w.disconnect()},[i]),T.useLayoutEffect(()=>{const p=a.current,w=p==null?void 0:p.parentElement;if(!p||!w)return;const b=P2(w,r);if(!b){u(null);return}const k=w.getBoundingClientRect(),E=b.getBoundingClientRect(),_={left:E.left-k.left,right:E.right-k.left,top:E.top-k.top,bottom:E.bottom-k.top},A=w.querySelector(".dock"),L=A?A.getBoundingClientRect().top-k.top-Ye:k.height-Ye,$=Math.max(160,L-Ye),F=p.offsetWidth,B=Math.min(p.offsetHeight,$),N=k.width-Ye-_.right-$r,P=_.left-$r-Ye,R=N>=F||N>=P?"right":"left",O=R==="right"?_.right+$r:_.left-$r-F,j=Math.max(Ye,Math.min(O,k.width-Ye-F)),M=Math.max(Ye,Math.min(_.top,L-B)),I=Math.max(16,Math.min((_.top+_.bottom)/2-M,B-16));if(u({left:j,top:M,side:R,pointer:I,maxHeight:$}),c.current===i)return;c.current=i;const z=R==="right"?_.left:_.left-$r-F,H=R==="right"?_.right+$r+F:_.right,ne=H-z<=k.width-2*Ye,Q=ne?z:_.left,U=ne?H:_.right,J=Q<Ye?Ye-Q:U>k.width-Ye?k.width-Ye-U:0,ee=_.top<Ye?Ye-_.top:_.bottom>L?Math.max(L-_.bottom,Ye-_.top):0;if(J||ee){const C=d.getViewport();d.setViewport({...C,x:C.x+J,y:C.y+ee},{duration:300})}},[i,h,f]),s.length?g.jsxs("div",{ref:a,className:`box-bubble box-bubble-${(l==null?void 0:l.side)??"right"}`,style:{...l?{left:l.left,top:l.top,"--bubble-max":`${l.maxHeight}px`}:{visibility:"hidden",left:0,top:0},...x?{width:x.w,"--bubble-cap":`${x.h}px`}:{}},role:"dialog","aria-label":"What you selected",children:[l&&g.jsx("i",{className:"box-bubble-pointer",style:{top:l.pointer},"aria-hidden":"true"}),g.jsx(C2,{mapId:e,map:t,report:n,ids:s,onClose:o},i),g.jsx("span",{className:"box-bubble-grip",onPointerDown:y,onDoubleClick:m,title:"Drag to resize. Double-click for the usual size.","aria-hidden":"true"})]}):null}const O0=[.5,.42,.58,.34,.66,.26,.74,.2,.8],D2=[...O0,.86,.14,.9,.1],bi=4,Ei={w:26,h:18},Wl=(e,t)=>e.x<t.x+t.w+bi&&t.x<e.x+e.w+bi&&e.y<t.y+t.h+bi&&t.y<e.y+e.h+bi,Ni=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,w:t,h:n});function F2(e,t,n=[]){const r=[],o={},s=(l,u)=>!t.some(c=>Wl(l,c))&&!r.some(c=>Wl(l,c))&&(!u||!n.some(c=>Wl(l,c))),i=[...e.filter(l=>l.keep),...e.filter(l=>!l.keep)],a=(l,u,c,d=O0)=>{for(const h of[!0,!1]){if(s(Ni(l.at,u,c),h))return l.at;for(const f of d){const v=l.along(f);if(v&&s(Ni(v,u,c),h))return v}}return null};for(const l of i){const u=a(l,l.w,l.h)??(l.keep?l.at:null);if(!u){const c=a(l,Ei.w,Ei.h,D2);c?(r.push(Ni(c,Ei.w,Ei.h)),o[l.id]={...c,dot:!0}):o[l.id]="dot";continue}r.push(Ni(u,l.w,l.h)),u!==l.at&&(o[l.id]=u)}return o}function B2(e,t){const n=[];let r=!1;for(const o of e.nodes)t("node",o.id)&&(r=!0,o.branch&&!n.includes(o.branch)&&n.push(o.branch));for(const o of e.edges)t("edge",o.id)&&(r=!0,o.branch&&!n.includes(o.branch)&&n.push(o.branch));return r?["now",...n.length>=2?n.map(o=>`option:${o}`):["proposed"],"both"]:[]}function sc(e,t){return e==="proposed"?!0:e.startsWith("option:")?!t||t===e.slice(7):!1}function ic(e,t,n){return e==="both"||!t||t.state!=="pending"?null:t.kind==="add"?sc(e,n)?null:e.startsWith("option:")?"other":"unbuilt":t.kind==="remove"&&sc(e,n)?"dropped":null}function H2(e,t,n){return t?e==="both"||t.state!=="pending"?!0:sc(e,n)&&!ic(e,t,n):!1}function cp(e){if(e==="now")return{label:"Now",title:"The code as it is; what is proposed is a shadow",heading:"The code as it is"};if(e==="proposed")return{label:"With the change",title:"The code as it would be; what would go is a shadow",heading:"With the change"};if(e==="both")return{label:"Both",title:"The code as it is, with the change drawn on top",heading:"The change on top of the code"};const t=e.slice(7);return{label:t,title:`The code as it would be with ${t}; the other options are shadows`,heading:`With ${t}`}}const cn=(...e)=>e.filter(Boolean).join(" "),mr={add:{pending:"Proposed",done:"Now in the code",mark:"+",title:"Proposed: not in the code yet"},change:{pending:"Would change",done:"Changed",mark:"~",title:"Proposed: this code would change"},remove:{pending:"Would be removed",done:"Removed",mark:"−",title:"Proposed: this code would be removed"}},ol=e=>e&&`proposal proposal-${e.kind} proposal-${e.state}${e.quiet&&e.state==="pending"?" proposal-quiet":""}`,U2={add:"New",change:"Changed",remove:"Removed"},yr={added:{label:"Added",mark:"+",title:"New since the commit this map is compared with"},changed:{label:"Changed",mark:"~",title:"Different from the commit this map is compared with"},removed:{label:"Removed",mark:"−",title:"Was in the code at the commit this map is compared with, and is gone now"}},sl=e=>e&&`change change-${e}`,Aa={later:{label:"Not there yet",title:"Added after this version of the code"},gone:{label:"Gone",title:"Removed: it was in the code before, and isn’t now"},unbuilt:{label:"Not built yet",title:"Proposed: only there with the change"},other:{label:"Other option",title:"Part of another option of the change, not this one"},dropped:{label:"Would go",title:"Proposed to be removed: not there with the change"}};function V2(e){if(!(e!=null&&e.length))return null;const t=e.filter(r=>r.startsWith("+ ")).length,n=e.filter(r=>r.startsWith("- ")).length;return[t&&`+${t}`,n&&`−${n}`].filter(Boolean).join(" ")||null}const W2=[["before","Before","The code as it was at that commit; what was added since is a shadow"],["after","After","The code as it is now; what was removed is a shadow"],["both","Both","The code as it is now, with what was removed drawn in too"]];function G2({commit:e,when:t,onWhen:n}){return g.jsxs("div",{className:"change-key",children:[g.jsx("div",{className:"seg",role:"group","aria-label":"Which version of the code to show",children:W2.map(([r,o,s])=>g.jsx("button",{className:cn("seg-btn",t===r&&"on"),title:s,"aria-pressed":t===r,onClick:()=>n(r),children:o},r))}),g.jsx("span",{className:"change-key-title",children:t==="before"?`The code at ${e}`:t==="after"?"The code now":`Now, compared with ${e}`}),t==="both"&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch"}),"Same as before"]}),t==="both"&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-added"}),"Added"]}),g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:cn("key-swatch key-changed",t!=="both"&&"key-quiet")}),t==="before"?"Changes later":"Changed"]}),t==="both"&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-removed"}),"Removed (only in the before)"]}),t!=="both"&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-ghost"}),t==="before"?"Not there yet":"Gone"]})]})}const Y2=5,Vs=e=>e&&`branch branch-${e.colour}`;function X2({branches:e,journey:t}){return g.jsxs("div",{className:"change-key branch-key",children:[g.jsx("span",{className:"change-key-title",children:"Ways through"}),t?g.jsxs("span",{className:"key-item",title:"What most people do, start to finish",children:[g.jsx("i",{className:"key-swatch"}),"Main path"]}):g.jsxs("span",{className:"key-item",title:"On every way through",children:[g.jsx("i",{className:"key-swatch"}),"Shared"]}),e.map(n=>g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:cn("key-swatch",Vs(n))}),n.name]},n.name))]})}function q2({views:e,plan:t,onPlan:n,shown:r}){return g.jsxs("div",{className:"change-key plan-key",children:[g.jsx("div",{className:"seg",role:"group","aria-label":"Which version of the proposal to show",children:e.map(o=>{const{label:s,title:i}=cp(o);return g.jsx("button",{className:cn("seg-btn",t===o&&"on"),title:i,"aria-pressed":t===o,onClick:()=>n(o),children:s},o)})}),g.jsx("span",{className:"change-key-title",children:cp(t).heading}),r.has("new")&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-new"}),"New"]}),r.has("unbuilt")&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-ghost"}),"Not built yet"]}),r.has("other")&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-ghost"}),"Other option"]}),r.has("dropped")&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-ghost"}),"Would go"]})]})}const _i={entry:["Where it starts","▸"],store:["Saved data","▤"],external:["Outside the app","↗"],job:["Background job","◷"]},dp=[["t",ie.Top],["r",ie.Right],["b",ie.Bottom],["l",ie.Left]];function z0(){return g.jsxs(g.Fragment,{children:[dp.map(([e,t])=>g.jsx(mo,{id:`s${e}`,type:"source",position:t,className:"handle",isConnectable:!1},`s${e}`)),dp.map(([e,t])=>g.jsx(mo,{id:`t${e}`,type:"target",position:t,className:"handle",isConnectable:!1},`t${e}`))]})}function K2({data:e}){var t,n,r;return e.journey?g.jsx(Z2,{data:e}):g.jsxs("div",{className:cn("step","nopan",`kind-${e.kind}`,!e.confirmed&&"unconfirmed",ol(e.proposal),sl(e.change),e.quiet&&"quiet",e.ghost&&"ghost",Vs(e.branch),e.selected&&"selected",e.hl&&"hl",e.dim&&"dim"),onClick:o=>{o.stopPropagation(),e.onClick(o.shiftKey||o.metaKey)},onMouseEnter:()=>{var o;return(o=e.onHover)==null?void 0:o.call(e,!0)},onMouseLeave:()=>{var o;return(o=e.onHover)==null?void 0:o.call(e,!1)},children:[g.jsx(z0,{}),(_i[e.kind]||e.fresh||e.screen||e.proposal||e.change||e.ghost)&&g.jsxs("div",{className:"step-head",children:[e.ghost&&g.jsx("span",{className:"badge-ghost",title:Aa[e.ghost].title,children:Aa[e.ghost].label}),e.proposal&&g.jsx("span",{className:"badge-proposal",children:e.proposal.quiet&&e.proposal.state==="pending"?U2[e.proposal.kind]:mr[e.proposal.kind][e.proposal.state]}),e.change&&g.jsxs("span",{className:"badge-change",title:yr[e.change].title,children:[e.quiet==="before"?"Changes later":yr[e.change].label,e.changeSize&&!e.quiet&&g.jsxs("span",{className:"change-size",children:[" ",e.changeSize]})]}),_i[e.kind]&&!e.proposal&&!e.change&&!e.ghost&&g.jsxs(g.Fragment,{children:[g.jsx("i",{className:"step-mark","aria-hidden":"true",children:_i[e.kind][1]}),_i[e.kind][0]]}),e.screen&&g.jsx("span",{className:"badge-screen",title:"Select this step to see the screen",children:"▣ Screen"}),e.fresh&&g.jsx("span",{className:"badge-new",children:"New"})]}),g.jsx("div",{className:"step-name",title:e.name,children:e.name}),g.jsxs("div",{className:"step-code",title:((t=e.proposal)==null?void 0:t.state)==="pending"?mr[e.proposal.kind].title:e.confirmed?"Confirmed against the code":"The checker couldn't confirm this against the code",children:[((n=e.proposal)==null?void 0:n.state)==="pending"&&e.proposal.kind==="add"||e.ghost==="unbuilt"||e.ghost==="other"?g.jsx("span",{className:"pmark",children:"+"}):((r=e.proposal)==null?void 0:r.state)==="done"&&e.proposal.kind!=="add"?g.jsx("span",{className:"pmark",children:mr[e.proposal.kind].mark}):e.change&&e.confirmed?g.jsx("span",{className:"cmark",children:yr[e.change].mark}):g.jsx("span",{className:e.confirmed?"tick":"qmark",children:e.confirmed?"✓":"?"}),g.jsx("span",{className:"step-sub",children:e.sub})]})]})}function Z2({data:e}){const t=e.journey,n=e.proposal;return g.jsxs("div",{className:cn("step","jstep","nopan",`j-${t.shape}`,t.show&&"j-pictured",t.outside&&"j-outside",!e.confirmed&&"unconfirmed",ol(n),sl(e.change),e.quiet&&"quiet",e.ghost&&"ghost",Vs(t.branch),e.selected&&"selected",e.hl&&"hl",e.dim&&"dim"),style:{width:t.w,height:t.h},onClick:r=>{r.stopPropagation(),e.onClick(r.shiftKey||r.metaKey)},onMouseEnter:()=>{var r;return(r=e.onHover)==null?void 0:r.call(e,!0)},onMouseLeave:()=>{var r;return(r=e.onHover)==null?void 0:r.call(e,!1)},children:[g.jsx(z0,{}),t.stage&&g.jsx("div",{className:"j-stage",children:t.stage}),t.shape==="choice"&&g.jsx("svg",{className:"j-diamond",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",children:g.jsx("polygon",{points:"50,1 99,50 50,99 1,50",vectorEffect:"non-scaling-stroke"})}),g.jsxs("div",{className:"j-tags",children:[n&&g.jsx("span",{className:"badge-proposal",children:mr[n.kind][n.state]}),e.ghost&&g.jsx("span",{className:"badge-ghost",title:Aa[e.ghost].title,children:Aa[e.ghost].label}),e.change&&g.jsx("span",{className:"badge-change",title:yr[e.change].title,children:e.quiet==="before"?"Changes later":yr[e.change].label}),!e.confirmed&&g.jsx("span",{className:"j-q",title:"The checker couldn't confirm this against the code",children:"?"}),e.fresh&&g.jsx("span",{className:"badge-new",children:"New"})]}),t.show&&g.jsx($C,{show:t.show,name:e.name}),g.jsx("div",{className:"j-name",title:e.name,children:e.name}),t.outside&&t.shape!=="choice"&&g.jsx("div",{className:"j-note",children:"Outside the app"})]})}function Q2({data:e}){return g.jsx("div",{className:cn("area",e.dim&&"dim"),children:g.jsxs("div",{className:"area-label",children:[e.label,e.note&&g.jsxs("span",{className:"area-note",children:[" ",e.note]})]})})}function J2(e,t,n,r,o){if(o==="over"){const l=Math.max(Math.abs(n-e)/2,40),u=Math.max(70,Math.min(170,Math.abs(n-e)*.32)),c=e<n?1:0;return[`M ${e} ${t} A ${l} ${u} 0 0 ${c} ${n} ${r}`,(e+n)/2,(t+r)/2-u]}const s=Math.max(Math.abs(r-t)/2,40),i=Math.max(60,Math.min(150,Math.abs(r-t)*.32)),a=t<r?1:0;return[`M ${e} ${t} A ${i} ${s} 0 0 ${a} ${n} ${r}`,Math.max(e,n)+i,(t+r)/2]}function eA(e,t,n,r,o){const s=Math.hypot(n-e,r-t)||1,i=-(r-t)/s,a=(n-e)/s,l=(e+n)/2+i*o*2,u=(t+r)/2+a*o*2;return[`M ${e} ${t} Q ${l} ${u} ${n} ${r}`,(e+n)/2+i*o,(t+r)/2+a*o]}function fp(e,t=18,n){let r=`M ${e[0][0]} ${e[0][1]}`;for(let l=1;l<e.length-1;l++){const[u,c]=e[l-1],[d,h]=e[l],[f,v]=e[l+1],x=Math.min(t,Math.hypot(d-u,h-c)/2),S=Math.min(t,Math.hypot(f-d,v-h)/2),y=Math.sign(d-u),m=Math.sign(h-c),p=Math.sign(f-d),w=Math.sign(v-h);r+=` L ${d-y*x} ${h-m*x} Q ${d} ${h} ${d+p*S} ${h+w*S}`}const o=e[e.length-1];r+=` L ${o[0]} ${o[1]}`;const[s,i]=n!==void 0?[e[n],e[n+1]]:[];if(s&&i)return[r,(s[0]+i[0])/2,(s[1]+i[1])/2];let a=[0,e[0][0],e[0][1]];for(let l=1;l<e.length;l++){const[u,c]=e[l-1],[d,h]=e[l];c===h&&Math.abs(d-u)>a[0]&&(a=[Math.abs(d-u),(u+d)/2,h])}return[r,a[1],a[2]]}function tA({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,markerEnd:a,data:l}){const[u,c,d]=l!=null&&l.loop?J2(t,n,r,o,l.loop):l!=null&&l.route?fp(l.route.points,18,l.route.label):(l==null?void 0:l.wrapY)!==void 0&&s===ie.Right?fp([[t,n],[t+30,n],[t+30,l.wrapY],[r,l.wrapY],[r,o]]):(l==null?void 0:l.wrapY)!==void 0?ba({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i,borderRadius:18,centerY:l.wrapY}):l!=null&&l.offset?eA(t,n,r,o,l.offset):gd({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i});if(!l)return null;const h=l.place&&l.place!=="dot"?l.place:null,f=(l.place==="dot"||typeof l.place=="object"&&"dot"in l.place)&&!l.selected;return g.jsxs(g.Fragment,{children:[l.selected&&g.jsx("path",{d:u,className:"edge-halo"}),g.jsx(Fs,{id:e,path:u,markerEnd:a,interactionWidth:18}),g.jsx(F_,{children:g.jsxs("div",{className:cn("link-label",f&&"dot",`link-${l.variant}`,!l.confirmed&&"unconfirmed",ol(l.proposal),sl(l.change),l.ghost&&"ghost",Vs(l.branch),l.hl&&"hl",l.dim&&"dim",l.selected&&"selected","nodrag nopan"),"data-id":e,"data-x":c,"data-y":d,title:f?l.label:void 0,onMouseEnter:l.onHover&&(()=>l.onHover(!0)),onMouseLeave:l.onHover&&(()=>l.onHover(!1)),style:{transform:`translate(-50%, -50%) translate(${(h==null?void 0:h.x)??c}px, ${(h==null?void 0:h.y)??d}px)`},onClick:v=>{var x;v.stopPropagation(),(x=l.onClick)==null||x.call(l,v.shiftKey||v.metaKey)},children:[l.variant==="absence"&&g.jsx("span",{className:"gap-q","aria-hidden":"true",children:"?"}),l.proposal&&!(l.proposal.quiet&&l.proposal.state==="pending"&&l.proposal.kind==="add")&&g.jsx("span",{className:"pmark",title:l.proposal.state==="done"?mr[l.proposal.kind].done:mr[l.proposal.kind].title,children:l.proposal.state==="done"&&l.proposal.kind==="add"?"✓":mr[l.proposal.kind].mark}),l.change&&g.jsx("span",{className:"cmark",title:yr[l.change].title,children:yr[l.change].mark}),g.jsx("span",{className:"link-text",children:l.label}),!l.confirmed&&l.variant==="edge"&&g.jsx("span",{className:"q",children:" ?"})]})})]})}const nA={step:K2,area:Q2},rA={link:tA};function hp(e,t){const n=new Set;for(const r of t){e.nodes.some(i=>i.id===r)&&n.add(r);const o=e.edges.find(i=>i.id===r);o&&n.add(o.from).add(o.to);const s=e.absences.find(i=>i.id===r);s!=null&&s.between&&n.add(s.between.from).add(s.between.to)}return[...n]}const oA="440px",sA=e=>e.length>28?`${e.slice(0,26)}…`:e;function iA(e){var V,G,re,ae,de,Fe,We,Ge,rt,fe,wt;const t=(V=e.ghost)!=null&&V.connects&&e.map.nodes.some(W=>W.id===e.ghost.connects.from)&&e.map.nodes.some(W=>W.id===e.ghost.connects.to)?e.ghost:null,n=T.useMemo(()=>t!=null&&t.connects?[{id:t.id,from:t.connects.from,to:t.connects.to}]:[],[t]),r=T.useMemo(()=>e.map.view==="journey"?e.map.nodes.filter(W=>{var te,ce,le;return W.kind!=="action"&&W.kind!=="choice"&&((le=(ce=(te=e.report)==null?void 0:te.screens)==null?void 0:ce[W.id])==null?void 0:le.status)==="confirmed"}).map(W=>W.id):[],[e.map,e.report]),o=f2(e.map,n,e.added,r),[s,i]=T.useState(null),a=Ds(),[l,u]=T.useState({key:"",at:{}}),[c,d]=T.useState("both"),f=!!((re=(G=e.report)==null?void 0:G.since)!=null&&re.commit)?c:"both",v=W=>{var te,ce,le,pe,oe,ue;return((le=(ce=(te=e.report)==null?void 0:te.nodes[W])==null?void 0:ce.change)==null?void 0:le.kind)??((ue=(oe=(pe=e.report)==null?void 0:pe.edges[W])==null?void 0:oe.change)==null?void 0:ue.kind)??null},[x,S]=T.useState("both"),y=T.useMemo(()=>B2(e.map,(W,te)=>{var ce,le,pe,oe;return((oe=(pe=W==="node"?(ce=e.report)==null?void 0:ce.nodes[te]:(le=e.report)==null?void 0:le.edges[te])==null?void 0:pe.proposal)==null?void 0:oe.state)==="pending"}),[e.map,e.report]),m=y.includes(x)?x:"both",p=W=>{const te=e.map.nodes.find(pe=>pe.id===W);if(te)return te.branch??null;const ce=e.map.edges.find(pe=>pe.id===W),le=pe=>{var oe;return(oe=e.map.nodes.find(ue=>ue.id===pe))==null?void 0:oe.branch};return(ce==null?void 0:ce.branch)??le(ce==null?void 0:ce.to)??le(ce==null?void 0:ce.from)??null},w=W=>{var te,ce,le,pe;return((ce=(te=e.report)==null?void 0:te.nodes[W])==null?void 0:ce.proposal)??((pe=(le=e.report)==null?void 0:le.edges[W])==null?void 0:pe.proposal)??null},b=W=>{const te=w(W);return te&&H2(m,te,p(W))?{...te,quiet:m!=="both"}:null},k=W=>f==="before"&&v(W)==="added"?"later":f==="after"&&v(W)==="removed"?"gone":ic(m,w(W),p(W)),E=W=>f==="both"||W==="changed"?W:null,_=JSON.stringify([(s==null?void 0:s.key)??null,f,m,(t==null?void 0:t.id)??null]),A=new Set;if(m!=="both")for(const W of e.map.nodes.map(te=>te.id)){const te=ic(m,w(W),p(W));te?A.add(te):((ae=b(W))==null?void 0:ae.kind)==="add"&&A.add("new")}T.useEffect(()=>{let W=!0;return JC(e.map,n,new Set(e.added),new Set(r)).then(te=>W&&i({key:o,layout:te}),te=>console.error("illuminate: the map could not be laid out",te)),()=>{W=!1}},[o]);const L=T.useMemo(()=>!s||s.layout.flat||s.layout.lanes?new Set:j0(e.map),[e.map,s]),$=T.useMemo(()=>[...L].flatMap(W=>T0(e.map,W)??[]),[L,e.map]),F=W=>$.find(te=>te.edges.includes(W))??null,B=T.useRef(void 0),N=T.useRef([]),P=T.useRef(F);P.current=F;const R=(W,te,ce)=>{window.clearTimeout(B.current),B.current=window.setTimeout(()=>{for(const xe of N.current)xe.classList.remove("pointed");if(N.current=[],!ce)return;const le=W==="edge"?P.current(te):null,pe=le?le.nodes:W==="node"?[te]:[],oe=le?le.edges:W==="edge"?[te]:[],ue=[...pe.flatMap(xe=>[...document.querySelectorAll(`.react-flow__node[data-id="${CSS.escape(xe)}"] .step`)]),...oe.flatMap(xe=>[...document.querySelectorAll(`.react-flow__edge[data-id="${CSS.escape(`e:${xe}`)}"], .link-label[data-id="${CSS.escape(`e:${xe}`)}"]`)])];for(const xe of ue)xe.classList.add("pointed");N.current=ue},ce?150:80)};T.useEffect(()=>()=>window.clearTimeout(B.current),[]);const O=e.selection.edges.map(F).find(W=>!!W)??null,j=O?new Set([...O.nodes,...O.edges]):(de=e.view)!=null&&de.highlight.length?new Set(e.view.highlight):null,M=T.useMemo(()=>j?new Set(hp(e.map,[...j])):null,[j,e.map]),I=e.selection,z=T.useMemo(()=>((s==null?void 0:s.layout.branches)??[]).map((W,te)=>({name:W,colour:te%Y2+1})),[s]),H=y.some(W=>W.startsWith("option:")),ne=W=>!H||m==="both"||m===`option:${W}`,Q=W=>W&&ne(W)?z.find(te=>te.name===W)??null:null,U=z.filter(W=>ne(W.name)),J=(W,te,ce)=>{var oe;if(!z.length||!ce)return null;if(W==="node")return Q((oe=e.map.nodes.find(ue=>ue.id===te))==null?void 0:oe.branch);const le=e.map.edges.find(ue=>ue.id===te),pe=ue=>{var xe;return(xe=e.map.nodes.find(me=>me.id===ue))==null?void 0:xe.branch};return Q((le==null?void 0:le.branch)??pe(le==null?void 0:le.to)??pe(le==null?void 0:le.from))},ee=T.useMemo(()=>{if(!s)return[];const W=s.layout,te=oe=>!M||e.map.nodes.some(ue=>ue.area===oe&&M.has(ue.id)),ce=e.map.areas.flatMap(oe=>{const ue=W.areas[oe.id];return ue?[{id:`area:${oe.id}`,type:"area",position:{x:ue.x,y:ue.y},style:{width:ue.w,height:ue.h},initialWidth:ue.w,initialHeight:ue.h,data:{label:oe.label,note:null,dim:!te(oe.id)},selectable:!1,draggable:!1,zIndex:0}]:[]}),le=new Map;if(W.flat){const oe=ue=>W.branches&&ue.branch?1:0;for(const ue of e.map.areas){const xe=e.map.nodes.filter(me=>me.area===ue.id&&W.nodes[me.id]).sort((me,ke)=>oe(me)-oe(ke)||W.nodes[me.id].x-W.nodes[ke.id].x||W.nodes[me.id].y-W.nodes[ke.id].y)[0];xe&&le.set(xe.id,ue.label)}}const pe=e.map.nodes.flatMap(oe=>{var ot,st,Ne,Zt,Qt,Jn,q,ve,we,Te,it,xt,Jt,er,fn;const ue=W.nodes[oe.id];if(!ue)return[];const xe=oe.evidence[0],me=oe.symbol?oe.symbol.slice(oe.symbol.indexOf("#")+1):xe?`${xe.file.split("/").pop()}:${xe.line}`:"not in the code yet",ke=(ot=e.report)==null?void 0:ot.nodes[oe.id],Me=J("node",oe.id,!!ke&&(ke.status!=="unconfirmed"||!!ke.proposal)&&!E(((st=ke.change)==null?void 0:st.kind)??null)&&!k(oe.id));return[{id:oe.id,type:"step",...W.flat?{}:{parentId:`area:${oe.area}`,extent:"parent"},position:{x:ue.x,y:ue.y},initialWidth:ue.w,initialHeight:ue.h,data:{name:oe.name,sub:me,kind:oe.kind,confirmed:!!e.report&&((Ne=e.report.nodes[oe.id])==null?void 0:Ne.status)!=="unconfirmed",proposal:b(oe.id),screen:((Jn=(Qt=(Zt=e.report)==null?void 0:Zt.screens)==null?void 0:Qt[oe.id])==null?void 0:Jn.status)==="confirmed",selected:I.nodes.includes(oe.id),hl:!!(M!=null&&M.has(oe.id)),dim:!!M&&!M.has(oe.id)&&!I.nodes.includes(oe.id),fresh:e.fresh.includes(oe.id),change:E(((we=(ve=(q=e.report)==null?void 0:q.nodes[oe.id])==null?void 0:ve.change)==null?void 0:we.kind)??null),changeSize:V2((xt=(it=(Te=e.report)==null?void 0:Te.nodes[oe.id])==null?void 0:it.change)==null?void 0:xt.diff),ghost:k(oe.id),quiet:f==="both"?null:f,branch:Me,...W.flat&&{journey:{w:ue.w,h:ue.h,shape:oe.kind==="choice"?"choice":oe.kind==="action"?"action":"screen",outside:oe.kind==="external",stage:le.get(oe.id)??null,show:r.includes(oe.id)?((fn=(er=(Jt=e.report)==null?void 0:Jt.screens)==null?void 0:er[oe.id])==null?void 0:fn.show)??null:null,branch:Me}},onClick:Cn=>e.onSelect("nodes",oe.id,Cn),onHover:Cn=>R("node",oe.id,Cn)},draggable:!1,zIndex:3}]});return[...ce,...pe]},[s,e.map,e.report,I,M,e.fresh,e.onSelect,r,f,m,z]),C=T.useMemo(()=>{var Ne,Zt,Qt,Jn;if(!s)return[];const W=q=>({type:ks.ArrowClosed,width:16,height:16,color:q}),te=q=>!!(j!=null&&j.has(q)),ce=(q,ve)=>{const[we,Te]=d2(e.map,s.layout,q,ve);return{sourceHandle:`s${we}`,targetHandle:`t${Te}`}},le=new Map,pe=(q,ve)=>{const we=s.layout.rowTops,Te=_a(s.layout,q),it=_a(s.layout,ve);if(!we||Te===it)return;const xt=Math.max(Te,it),Jt=le.get(xt)??0;return le.set(xt,Jt+1),we[xt]-nc/2+(Jt%2?1:-1)*Math.ceil(Jt/2)*18},oe=L,ue=q=>{const ve=e.map.nodes.find(it=>it.id===q),we=s.layout.nodes[q],Te=ve?s.layout.areas[ve.area]:void 0;return we?{x:((Te==null?void 0:Te.x)??0)+we.x+we.w/2,y:((Te==null?void 0:Te.y)??0)+we.y+we.h/2}:{x:0,y:0}},xe=new Map((s.layout.rings??[]).flatMap((q,ve)=>q.map(we=>[we,ve]))),me=q=>xe.has(q.from)&&xe.get(q.from)===xe.get(q.to),ke=q=>{if(!oe.has(q.id)||me(q))return;const ve=Math.abs(ue(q.to).x-ue(q.from).x),we=Math.abs(ue(q.to).y-ue(q.from).y);return ve<tt*.75?"side":we<qe/2?"over":void 0},Me=e.map.edges.map(q=>{var Cn,Ws,Gs,Ys,Xs;const ve=!!e.report&&((Cn=e.report.edges[q.id])==null?void 0:Cn.status)!=="unconfirmed",we=ke(q),Te=b(q.id),it=E(((Ys=(Gs=(Ws=e.report)==null?void 0:Ws.edges[q.id])==null?void 0:Gs.change)==null?void 0:Ys.kind)??null),xt=k(q.id)??k(q.from)??k(q.to),Jt=te(q.id)||!!M&&M.has(q.from)&&M.has(q.to)&&!j,er="edge",fn=J("edge",q.id,!it&&!xt);return{id:`e:${q.id}`,source:q.from,target:q.to,...we==="over"?{sourceHandle:"st",targetHandle:"tt"}:we==="side"?{sourceHandle:"sr",targetHandle:"tr"}:ce(q.from,q.to),type:"link",className:cn("link",`link-${er}`,oe.has(q.id)&&"link-loop",!ve&&"unconfirmed",ol(Te),sl(it),xt&&"ghost",Vs(fn),te(q.id)&&"hl",!!j&&!te(q.id)&&"dim",I.edges.includes(q.id)&&"selected"),markerEnd:W(xt?"var(--line)":fn?`var(--branch-${fn.colour})`:we?"var(--path)":(Te==null?void 0:Te.state)==="pending"&&Te.kind!=="remove"?"var(--ai)":it==="added"?"var(--ok)":it==="removed"?"var(--dead)":te(q.id)?"var(--path)":"var(--line-strong)"),zIndex:1,data:{label:q.label,loop:we,onHover:ko=>R("edge",q.id,ko),wrapY:pe(q.from,q.to),route:(Xs=s.layout.routes)==null?void 0:Xs[`e:${q.id}`],branch:fn,variant:er,proposal:Te,change:it,ghost:xt,confirmed:ve,hl:Jt,dim:!!j&&!te(q.id)&&!I.edges.includes(q.id),selected:I.edges.includes(q.id),onClick:ko=>e.onSelect("edges",q.id,ko)}}}),ot=q=>{var ve;return((ve=t==null?void 0:t.connects)==null?void 0:ve.from)===q.from&&t.connects.to===q.to};for(const q of e.map.absences){if(!q.between||ot(q.between))continue;const ve=((Zt=(Ne=e.report)==null?void 0:Ne.absences[q.id])==null?void 0:Zt.status)==="confirmed";Me.push({id:`a:${q.id}`,hidden:f==="before",source:q.between.from,target:q.between.to,...ce(q.between.from,q.between.to),type:"link",className:cn("link","link-absence",!ve&&"unconfirmed",te(q.id)&&"hl",!!j&&!te(q.id)&&"dim",I.absences.includes(q.id)&&"selected"),markerEnd:W("var(--dead)"),zIndex:1,data:{label:sA(q.claim),route:(Qt=s.layout.routes)==null?void 0:Qt[`a:${q.id}`],variant:"absence",confirmed:ve,hl:te(q.id),dim:!!j&&!te(q.id)&&!I.absences.includes(q.id),selected:I.absences.includes(q.id),onClick:we=>e.onSelect("absences",q.id,we)}})}t!=null&&t.connects&&Me.push({id:`g:${t.id}`,source:t.connects.from,target:t.connects.to,...ce(t.connects.from,t.connects.to),type:"link",className:"link link-ghost",markerEnd:W("var(--ok)"),zIndex:2,data:{label:`+ ${t.connects.label}`,route:(Jn=s.layout.routes)==null?void 0:Jn[`x:${t.id}`],variant:"ghost",confirmed:!0,hl:!0,dim:!1,selected:!1}});const st=new Map;for(const q of Me){const ve=[q.source,q.target].sort().join("|");st.set(ve,[...st.get(ve)??[],q])}for(const q of st.values())q.length<2||q.some(ve=>{var we;return(we=ve.data)==null?void 0:we.route})||q.forEach((ve,we)=>{ve.data&&(ve.data.offset=(we-(q.length-1)/2)*44)});if(l.key===_)for(const q of Me)q.data&&l.at[q.id]&&(q.data.place=l.at[q.id]);return Me},[s,e.map,e.report,I,j,M,t,e.onSelect,f,m,z,l,_]);T.useEffect(()=>{if(!s)return;let W=0,te=0;const ce=()=>{const le=[...document.querySelectorAll(".react-flow__edgelabel-renderer .link-label[data-id]")],pe=le.length>0&&le.every(me=>me.offsetWidth>0)&&a.getNodes().every(me=>{var ke,Me;return(Me=(ke=a.getInternalNode(me.id))==null?void 0:ke.measured)==null?void 0:Me.width});if(W++<2||!pe){W<60&&(te=requestAnimationFrame(ce));return}const oe=[],ue=[];for(const me of a.getNodes()){const ke=a.getInternalNode(me.id);if(!ke||me.hidden)continue;const Me=ke.internals.positionAbsolute,ot=ke.measured.width??0,st=ke.measured.height??0;me.type==="step"?oe.push({x:Me.x,y:Me.y,w:ot,h:st}):me.type==="area"&&ue.push({x:Me.x,y:Me.y,w:Math.min(ot,280),h:40})}const xe=le.map(me=>{var ot;const ke=document.getElementById(me.dataset.id),Me=((ot=ke==null?void 0:ke.getTotalLength)==null?void 0:ot.call(ke))??0;return{id:me.dataset.id,w:me.offsetWidth,h:me.offsetHeight,at:{x:Number(me.dataset.x),y:Number(me.dataset.y)},keep:me.dataset.id.startsWith("a:"),along:st=>{if(!ke||!Me)return null;const Ne=ke.getPointAtLength(Me*st);return{x:Ne.x,y:Ne.y}}}});u({key:_,at:F2(xe,oe,ue)})};return te=requestAnimationFrame(ce),()=>cancelAnimationFrame(te)},[_]);const D=ge(W=>W.width),Z=T.useRef(0);T.useEffect(()=>{const W=Z.current;if(Z.current=D,!W||!D||W===D||e.touring)return;const te=a.getViewport();a.setViewport({...te,x:te.x+(D-W)/2})},[D]);const Y=JSON.stringify([s==null?void 0:s.key,(Fe=e.view)==null?void 0:Fe.focus,(We=e.view)==null?void 0:We.highlight,e.touring,e.touring?D:null]),X=T.useRef(!0);return T.useEffect(()=>{if(!s)return;const W=e.view?hp(e.map,e.view.highlight.length?e.view.highlight:e.view.focus?[e.view.focus]:[]):[];let te=0,ce=0;const le=()=>{var st;const pe=a.getNodes();if(te<2||!pe.length||!pe.every(Ne=>{var Zt,Qt;return(Qt=(Zt=a.getInternalNode(Ne.id))==null?void 0:Zt.measured)==null?void 0:Qt.width})){te++<60&&(ce=requestAnimationFrame(le));return}const oe=X.current?0:650;X.current=!1;const ue=Object.values(s.layout.nodes),xe=Object.values(s.layout.routes??{}).flatMap(Ne=>Ne.points),me=Math.max(0,Math.min(0,...ue.map(Ne=>Ne.y))-Math.min(0,...xe.map(Ne=>Ne[1]))),ke=Math.max(0,Math.max(0,...xe.map(Ne=>Ne[1]))-Math.max(0,...ue.map(Ne=>Ne.y+Ne.h))+(xe.length?16:0)),Me=(st=s.layout.branches)!=null&&st.length?56:0,ot=W.length?{top:`${60+Me}px`,left:e.touring?oA:"60px",right:"60px",bottom:"150px"}:{top:`${64+me+Me}px`,left:"32px",right:"32px",bottom:`${130+ke}px`};a.fitView(W.length?{nodes:W.map(Ne=>({id:Ne})),duration:oe,padding:ot,maxZoom:1.15}:{duration:oe,padding:ot,maxZoom:1.1})};return ce=requestAnimationFrame(le),()=>cancelAnimationFrame(ce)},[Y]),g.jsxs(z_,{className:s!=null&&s.layout.flat?"journey":s!=null&&s.layout.lanes?"lanes":void 0,nodes:ee,edges:C,zIndexMode:"manual",nodeTypes:nA,edgeTypes:rA,onNodeClick:()=>{},onEdgeClick:(W,te)=>{te.id.startsWith("e:")&&e.onSelect("edges",te.id.slice(2),W.shiftKey||W.metaKey),te.id.startsWith("a:")&&e.onSelect("absences",te.id.slice(2),W.shiftKey||W.metaKey)},onEdgeMouseEnter:(W,te)=>{te.id.startsWith("e:")&&R("edge",te.id.slice(2),!0)},onEdgeMouseLeave:(W,te)=>{te.id.startsWith("e:")&&R("edge",te.id.slice(2),!1)},onPaneClick:e.onClear,panOnDrag:!0,elementsSelectable:!1,nodesDraggable:!1,nodesConnectable:!1,minZoom:.15,maxZoom:2,children:[g.jsx(W_,{variant:xn.Dots,gap:22,size:1.3}),(((rt=(Ge=e.report)==null?void 0:Ge.since)==null?void 0:rt.commit)||y.length>0||z.length>0)&&g.jsx(zs,{position:"top-left",children:g.jsxs("div",{className:"map-keys",children:[((wt=(fe=e.report)==null?void 0:fe.since)==null?void 0:wt.commit)&&g.jsx(G2,{commit:e.report.since.commit.slice(0,7),when:f,onWhen:d}),y.length>0&&g.jsx(q2,{views:y,plan:m,onPlan:S,shown:A}),U.length>0&&g.jsx(X2,{branches:U,journey:e.map.view==="journey"})]})})]})}function il(e){e!==`${location.pathname}${location.search}`&&(history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")))}function aA(){const[e,t]=T.useState(location.pathname);return T.useEffect(()=>{const n=()=>t(location.pathname),r=o=>{var i,a;if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;const s=(a=(i=o.target)==null?void 0:i.closest)==null?void 0:a.call(i,"a[href]");!(s instanceof HTMLAnchorElement)||s.target||s.origin!==location.origin||(o.preventDefault(),il(`${s.pathname}${s.search}`))};return window.addEventListener("popstate",n),document.addEventListener("click",r),()=>{window.removeEventListener("popstate",n),document.removeEventListener("click",r)}},[]),e}const lA=8e3;function D0({busy:e,agentName:t="Claude",onStopped:n,onError:r}){const[o,s]=T.useState(!1);return T.useEffect(()=>{if(!o)return;const i=setTimeout(()=>s(!1),lA),a=l=>{l.key==="Escape"&&s(!1)};return window.addEventListener("keydown",a),()=>{clearTimeout(i),window.removeEventListener("keydown",a)}},[o]),o&&!e?g.jsxs("span",{className:"stop-ask",role:"group","aria-label":"Stop illuminate?",children:[g.jsx("span",{className:"stop-ask-text",children:"Stop illuminate? Maps stay saved."}),g.jsx("button",{className:"pill-btn stop-yes",autoFocus:!0,onClick:()=>{s(!1),Ht.stop().then(n,i=>r(i.message))},children:"Stop"}),g.jsx("button",{className:"pill-btn",onClick:()=>s(!1),children:"Keep running"})]}):g.jsx("button",{className:"pill-btn",disabled:e,title:e?`${t} is still working`:"Maps stay saved. Undo for applied fixes ends.",onClick:()=>s(!0),children:"Stop illuminate"})}function uA(){return g.jsxs("main",{className:"home",children:[g.jsx("h1",{children:"illuminate has stopped"}),g.jsx("p",{className:"muted lede",children:"You can close this tab."}),g.jsxs("p",{className:"muted lede",children:["Maps are saved in ",g.jsx("code",{children:".illuminate/maps"}),". Run ",g.jsx("code",{children:"illume open"})," in the repo to see them again."]})]})}function cA({onStopped:e}){const[t,n]=T.useState(""),[r,o]=T.useState(null),[s,i]=T.useState([]),[a,l]=T.useState(""),[u,c]=T.useState(null),[d,h]=T.useState(!1),[f,v]=T.useState(S0);T.useEffect(()=>k0(()=>{},()=>{},e),[e]),T.useEffect(()=>{Ht.list().then(S=>{n(S.repo),o(S.maps),i(S.making),S.agent&&v(S.agent)},S=>c(S.message))},[]);const x=async()=>{if(a.trim()){h(!0);try{const{id:S}=await Ht.make(a.trim());il(sn(S))}catch(S){c(S.message),h(!1)}}};return g.jsxs("main",{className:"home",children:[g.jsxs("div",{className:"home-brand",children:[g.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate",t&&g.jsx("span",{className:"muted",children:t})]}),g.jsx("h1",{children:"Ask how your code works"}),g.jsx("p",{className:"muted lede",children:"Every box and arrow is checked against the code."}),nl(f)?g.jsxs("p",{className:"home-ask chat-hint",children:[g.jsxs("strong",{children:["Ask for a new map in the ",f.name," chat beside this page"]})," ",g.jsx("span",{className:"muted",children:"for example: “Map what happens when a user signs up.”"})]}):g.jsxs("form",{className:"home-ask",onSubmit:S=>{S.preventDefault(),x()},children:[g.jsx("input",{id:"question",value:a,onChange:S=>l(S.target.value),placeholder:"What happens when a user signs up?","aria-label":"Your question",autoFocus:!0}),g.jsx("button",{className:"btn primary",disabled:d||!a.trim(),children:d?"Starting…":"Map it"})]}),u&&g.jsx("div",{className:"banner banner-dead",role:"alert",children:u}),s.length>0&&g.jsxs("section",{children:[g.jsx("h2",{className:"section-title",children:"Being made now"}),g.jsx("ul",{className:"maplist",children:s.map(S=>g.jsxs("li",{children:[g.jsx("a",{href:sn(S.id),children:S.question}),g.jsxs("span",{className:"muted small",children:[f.name," is exploring…"]})]},S.id))})]}),g.jsxs("section",{children:[g.jsx("h2",{className:"section-title",children:"Maps in this repo"}),r===null?g.jsx("p",{className:"muted",children:"Loading…"}):r.length===0?g.jsx("p",{className:"muted",children:"None yet."}):g.jsx("ul",{className:"maplist",children:r.map(S=>g.jsxs("li",{children:[g.jsx("a",{href:sn(S.id),children:S.question}),g.jsxs("span",{className:"muted small",children:[new Date(S.updatedAt).toLocaleString(),S.commit?` · ${S.commit.slice(0,7)}`:""]})]},S.id))})]}),g.jsx("footer",{className:"home-foot",children:g.jsx(D0,{busy:s.length>0,agentName:f.name,onStopped:e,onError:c})})]})}const pp="illuminate-panel-width",ac=300,F0=400,dA=360,Gl=e=>Math.round(Math.max(ac,Math.min(e,Math.max(ac,window.innerWidth-dA))));function fA(){const[e,t]=T.useState(()=>{const r=Number(localStorage.getItem(pp));return Gl(r>0?r:F0)}),n=T.useCallback(r=>{const o=Gl(r);t(o),localStorage.setItem(pp,String(o))},[]);return T.useEffect(()=>{const r=()=>t(o=>Gl(o));return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),[e,n]}function hA({width:e,onWidth:t}){return g.jsx("div",{className:"panel-handle",role:"separator","aria-orientation":"vertical","aria-label":"Panel width","aria-valuenow":e,"aria-valuemin":ac,tabIndex:0,title:"Drag to resize the panel",onPointerDown:n=>{n.preventDefault();const r=n.currentTarget;r.setPointerCapture(n.pointerId),document.body.classList.add("resizing");const o=i=>t(window.innerWidth-i.clientX),s=()=>{r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",s),r.removeEventListener("pointercancel",s),document.body.classList.remove("resizing")};r.addEventListener("pointermove",o),r.addEventListener("pointerup",s),r.addEventListener("pointercancel",s)},onDoubleClick:()=>t(F0),onKeyDown:n=>{n.key==="ArrowLeft"&&(n.preventDefault(),t(e+24)),n.key==="ArrowRight"&&(n.preventDefault(),t(e-24))}})}const pA=(...e)=>e.filter(Boolean).join(" ");function gA({map:e,stop:t,onTour:n,onAsk:r}){var i;const o=e.tour[t];if(!o)return null;const s=t===e.tour.length-1;return g.jsxs("section",{className:"card card-focus tour-bubble","aria-label":"Walkthrough","aria-live":"polite",children:[g.jsx("button",{className:"card-close","aria-label":"Leave the walkthrough",title:"Leave the walkthrough (Esc)",onClick:()=>n(null),children:"×"}),g.jsxs("div",{className:"tour-head",children:[g.jsxs("span",{className:"eyebrow",children:["Walkthrough, stop ",t+1," of ",e.tour.length]}),g.jsx("span",{className:"dots","aria-hidden":"true",children:e.tour.map((a,l)=>g.jsx("i",{className:pA(l===t&&"on",l<t&&"done")},a.id))})]}),g.jsx("h2",{className:"card-title",children:o.title}),g.jsx(_s,{text:o.text,className:"depth-text"}),(i=o.terms)!=null&&i.length?g.jsxs("p",{className:"muted small",children:["Terms: ",o.terms.join(", ")]}):null,g.jsxs("div",{className:"tour-nav",children:[g.jsx("button",{className:"btn",disabled:t===0,onClick:()=>n(t-1),children:"‹ Back"}),r&&g.jsx("button",{className:"btn",onClick:r,children:"Ask about this step"}),g.jsx("span",{className:"grow"}),s?g.jsx("button",{className:"btn primary",onClick:()=>n(null),children:"Done"}):g.jsx("button",{className:"btn primary",onClick:()=>n(t+1),children:"Next ›"})]}),g.jsx("div",{className:"kbd",children:"← → to step, Esc to leave"})]})}function mA(){return yo?g.jsx(yA,{}):g.jsxs("main",{className:"home",children:[g.jsx("h1",{children:"Open illuminate from its link"}),g.jsxs("p",{className:"muted lede",children:["Use the link illuminate printed in your terminal (it ends in ",g.jsx("code",{children:"?t=…"}),")."]})]})}function yA(){const[e,t]=T.useState(!1),n=T.useCallback(()=>{window.close(),t(!0)},[]),r=aA();if(e)return g.jsx(uA,{});const o=/^\/m\/([a-z0-9-]{1,80})\/?$/.exec(r);return o?g.jsx(kA,{mapId:o[1],onStopped:n},o[1]):g.jsx(cA,{onStopped:n})}function vA({mapId:e,question:t,making:n}){const[r,o]=T.useState([]);T.useEffect(()=>{Ht.list().then(i=>o([...i.making.map(a=>({...a,making:!0})),...i.maps.map(a=>({id:a.id,question:a.question}))]),()=>{})},[e,n]);const s=r.some(i=>i.id===e)?r:[{id:e,question:t},...r];return g.jsx("select",{className:"switcher",value:e,onChange:i=>il(sn(i.target.value)),"aria-label":"Switch to another map",title:"Switch to another map in this repo",children:s.map(i=>g.jsxs("option",{value:i.id,children:[i.question||i.id,i.making?" (being made)":""]},i.id))})}function wA({report:e}){if(!e)return null;const t=e.summary.unconfirmed,{pending:n,done:r}=e.summary.proposals??{pending:0,done:0},o=n+r,s=o?g.jsx("span",{className:"map-status proposals",title:"Parts of this map are a proposal, drawn in violet: they aren't in the code yet, or would change or go. illuminate checks the code to see which have been done.",children:r===0?`${o} proposed ${o===1?"change":"changes"}`:`${r} of ${o} proposed changes done`}):null,i=g.jsxs(g.Fragment,{children:[s,g.jsx(xA,{report:e})]});return t?g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"map-status off",title:"Every time the map is shown, illuminate re-checks it against the code. These parts no longer hold, usually because the code changed after the map was made. They're dashed and marked ? on the map; click one to see why.",children:t===1?"1 part of this map doesn’t match the code":`${t} parts of this map don’t match the code`}),i]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"map-status ok",title:"Every box and arrow on this map was just re-checked and is really in the code, and every gap's search still finds nothing. That shows each part is real; it doesn't show the map covers everything.",children:"✓ Every part is in the code"}),i]})}function xA({report:e}){const t=e.since;if(!t)return null;if(!t.commit)return g.jsx("span",{className:"map-status off",title:`This map compares the code with "${t.ref}", but that isn't a commit in this repo, so nothing could be compared.`,children:"Can’t find the commit this map compares with"});const{added:n,changed:r,removed:o}=e.summary.changes??{added:0,changed:0,removed:0},s=t.date?new Date(t.date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):null,i=[n&&`${n} added`,r&&`${r} changed`,o&&`${o} removed`].filter(Boolean).join(" · ");return g.jsxs("span",{className:"map-status changes",title:`This map shows the code as it is now, compared with commit ${t.commit.slice(0,7)}${t.subject?` ("${t.subject}")`:""}. illuminate works out from the two versions which boxes and arrows are new, different or gone. It can't tell who made a change.`,children:["Changes since ",t.commit.slice(0,7),s?` (${s})`:"",i?`: ${i}`:": nothing on this map differs"]})}function kA({mapId:e,onStopped:t}){var O,j,M,I,z,H,ne,Q;const[n,r]=T.useReducer(v2,e,h2),[o,s]=T.useState(""),[i,a]=fA(),l=T.useRef(!1),u=T.useCallback(()=>{Ht.get(e).then(U=>r({type:"loaded",payload:U}),U=>r(U instanceof x0&&/No such map/.test(U.message)?{type:"missing"}:{type:"error",message:U.message}))},[e]);T.useEffect(u,[u]),T.useEffect(()=>k0(U=>r({type:"event",event:U}),U=>{r({type:"connected",value:U}),U&&l.current===!1&&n.phase!=="loading"&&u(),l.current=U},t,e),[]);const c=n.map&&n.tour!==null?((O=n.map.tour[n.tour])==null?void 0:O.title)??null:null;T.useEffect(()=>{const U=n.phase==="ready"?yC(n.agent,n.selection,c):null;if(!U)return;const J=setTimeout(()=>void Ht.selection(e,U.selection,U.step).catch(()=>{}),250);return()=>clearTimeout(J)},[e,n.phase,n.agent,n.selection,c]);const d=nl(n.agent),[h,f]=T.useState(null);T.useEffect(()=>f(null),[n.tour]);const v=n.map&&n.tour!==null&&h===n.tour?((j=n.map.tour[n.tour])==null?void 0:j.title)??null:null,x=T.useCallback(U=>{const J=U.trim();if(!J||n.job)return;const ee=v?FC(v,J):J;Ht.ask(e,ee,n.selection).then(()=>s(""),C=>r({type:"error",message:C.message}))},[e,n.job,n.selection,v]),S=(U,J)=>{J==="approve"&&r({type:"fixStatus",fixId:U,status:"applying",problems:[]}),Ht[J](e,U).catch(ee=>{r(J==="approve"?{type:"fixStatus",fixId:U,status:"failed",problems:ee.problems.length?ee.problems:[ee.message]}:{type:"error",message:[ee.message,...ee.problems].join(" ")})})},y=(U,J)=>{Ht.offer(e,U,J).then(ee=>{ee.id&&il(sn(ee.id))},ee=>r({type:"error",message:ee.message}))};T.useEffect(()=>{const U=J=>{const ee=J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLInputElement;if(J.key==="Escape"){zo(n.selection)?r({type:"clearSelection"}):n.tour!==null&&n.peek?r({type:"peek",open:!1}):n.tour!==null?r({type:"tour",stop:null}):r({type:"overview"});return}ee||n.tour===null||(J.key==="ArrowRight"&&r({type:"tour",stop:n.tour+1}),J.key==="ArrowLeft"&&r({type:"tour",stop:n.tour-1}))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[n.tour,n.peek,n.selection]);const m=n.answers.find(U=>U.id===n.shown),p=m!=null&&m.fix&&["proposed","applying","failed"].includes(((M=n.fixes[m.fix.id])==null?void 0:M.status)??"")?m.fix:null,w=T.useCallback((U,J,ee)=>r({type:"select",kind:U,id:J,additive:ee}),[]),b=T.useCallback(()=>r({type:"clearSelection"}),[]),k=$0(n),E=g2(n),_=p2(n),A=!!n.map&&n.tour!==null,L=T.useMemo(()=>({...n,answers:wC(n.agent,n.answers,n.fixes)}),[n]),$=n.shown!==null&&L.answers.some(U=>U.id===n.shown),F=((I=n.job)==null?void 0:I.kind)==="ask"&&!d,N=(!n.map||!!n.error||!!n.job&&(n.job.kind==="make"||F)||$)&&(!A||n.peek||!!n.error||F),P=N&&!!n.map,R=n.map&&d?g.jsx(j2,{map:n.map,agent:n.agent,selection:n.selection,step:c,onRemove:(U,J)=>r({type:"select",kind:U,id:J,additive:!0})}):n.map?g.jsx(M2,{map:n.map,selection:n.selection,draft:o,busy:!!n.job,agentName:n.agent.name,autoFocus:P,onDraft:s,onRemove:(U,J)=>r({type:"select",kind:U,id:J,additive:!0}),step:v,onRemoveStep:()=>f(null),onSend:()=>x(o)}):null;return g.jsx(m0,{children:g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("a",{className:"brand",href:sn(),title:"All maps in this repo",children:[g.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate"]}),g.jsxs("div",{className:"topbar-map",children:[((z=n.meta)==null?void 0:z.parent)&&g.jsxs("a",{className:"crumb",href:sn(n.meta.parent.mapId),title:`Back to the map this one came from: ${n.meta.parent.question}`,children:["← ",n.meta.parent.question]}),g.jsx(vA,{mapId:e,question:((H=n.map)==null?void 0:H.question)??((ne=n.job)==null?void 0:ne.question)??"",making:((Q=n.job)==null?void 0:Q.kind)==="make"})]}),g.jsx(wA,{report:n.report}),g.jsx("a",{className:"pill-btn",href:sn(),title:"Ask a new question and make a map for it",children:"New map"}),g.jsx(D0,{busy:!!n.job,agentName:n.agent.name,onStopped:t,onError:U=>r({type:"error",message:U})}),g.jsx("span",{className:n.connected?"live on":"live",title:n.connected?"Connected to illuminate":"Reconnecting to illuminate…"})]}),g.jsxs("div",{className:N?"body":"body full",style:{"--panel-w":`${i}px`},children:[g.jsx("div",{className:"canvas",children:n.map&&k?g.jsxs(g.Fragment,{children:[g.jsx(iA,{map:k,report:n.report,selection:n.selection,view:_,fresh:n.fresh,added:E,ghost:p??null,touring:A,onSelect:w,onClear:b}),!N&&g.jsx(L2,{state:L,dispatch:r}),zo(n.selection)>0&&g.jsx(z2,{mapId:e,map:k,report:n.report,selection:n.selection,onClose:b}),A&&zo(n.selection)===0&&g.jsx(gA,{map:n.map,stop:n.tour,onTour:U=>r({type:"tour",stop:U}),onAsk:d?void 0:()=>{var U;f(n.tour),(U=document.getElementById("ask"))==null||U.focus()}}),g.jsx(R2,{map:n.map,mapId:e,tour:n.tour,onTour:U=>r({type:"tour",stop:U}),selected:zo(n.selection),children:P?null:R})]}):g.jsx("div",{className:"empty",children:n.phase==="making"?g.jsxs("div",{className:"pulse",children:[n.agent.name," is exploring the code…"]}):null})}),N&&g.jsx(hA,{width:i,onWidth:a}),N&&g.jsx(b2,{state:L,dispatch:r,onFix:S,onFocus:U=>r({type:"focus",id:U}),onOffer:y,composer:P?R:null})]})]})})}Am(document.getElementById("root")).render(g.jsx(T.StrictMode,{children:g.jsx(mA,{})}));export{$d as c,lc as g};
|
|
82
|
-
//# sourceMappingURL=index-
|
|
81
|
+
`]},P))})]}),x&&_&&g.jsxs("p",{children:[_.found>x.matches?"This may no longer be missing: the search below now finds something.":"Nothing in the code connects these, going by this search."," ","Searched ",_.searched??"?"," ",_.searched===1?"file":"files",x.search.paths?g.jsxs(g.Fragment,{children:[" in ",g.jsx("code",{children:x.search.paths.join(", ")})]}):" (the whole repo)"," for ",g.jsx("code",{children:x.search.pattern}),": ",_.found," ",_.found===1?"match":"matches","."]}),S&&S.status==="unconfirmed"&&g.jsxs("div",{className:"warn small",children:["Couldn't confirm against the code: ",S.reasons.join("; ")]}),y.length>0&&g.jsxs("div",{className:"basis",children:[g.jsx("div",{className:"eyebrow",children:(k==null?void 0:k.kind)==="removed"?`In the code as it was at ${E}`:"In the code"}),g.jsx("div",{className:"chips",children:y.map((N,P)=>{var I,z;const R=((I=m[P])==null?void 0:I.ok)??!1,O=((z=m[P])==null?void 0:z.foundAt)??N.line,j=`${N.file}:${O}`,M=s&&((u==null?void 0:u.at)===j||!u&&y.length===1);return R?g.jsxs("button",{className:gr("chip cite",M&&"chip-open"),"aria-pressed":M,title:M?"Hide the code":"Show the code at this line",onClick:()=>{if(M){i(!1),c(null);return}i(!0),c(H=>({at:j,n:((H==null?void 0:H.n)??0)+1}))},children:[g.jsx("span",{className:"tick",children:"✓"}),N.file,":",O]},P):g.jsxs("span",{className:"chip static chip-unconfirmed",children:[g.jsx("span",{className:"qmark",children:"?"}),N.file,":",O]},P)})}),s&&(f||v)&&g.jsx(AC,{mapId:e,itemId:h,change:(k==null?void 0:k.kind)??null,since:E,stamp:n,jump:u})]})]})}function A2({diff:e}){const t=e.filter(r=>r.startsWith("+ ")).length,n=e.filter(r=>r.startsWith("- ")).length;return g.jsxs("span",{className:"diff-size",children:[t>0&&g.jsxs("span",{className:"add",children:[" +",t]}),n>0&&g.jsxs("span",{className:"del",children:[" −",n]})]})}function M2({map:e,selection:t,draft:n,busy:r,agentName:o="Claude",autoFocus:s,onDraft:i,onRemove:a,step:l,onRemoveStep:u,onSend:c}){const d=T.useRef(null),h=["nodes","edges","absences"].flatMap(f=>t[f].map(v=>({kind:f,id:v})));return T.useEffect(()=>{const f=d.current;f&&(f.style.height="auto",f.style.height=`${Math.min(f.scrollHeight,140)}px`)},[n]),T.useEffect(()=>{var f;n&&((f=d.current)==null||f.focus())},[n===""]),T.useEffect(()=>{var f;s&&((f=d.current)==null||f.focus({preventScroll:!0}))},[]),g.jsxs("form",{className:"composer",onSubmit:f=>{f.preventDefault(),!r&&n.trim()&&c()},children:[l&&g.jsxs("span",{className:"sel-chip sel-step",children:[g.jsxs("span",{className:"sel-text",title:`Walkthrough step: ${l}`,children:["▸ ",l]}),g.jsx("button",{type:"button","aria-label":`Don't ask about the step “${l}”`,onClick:u,children:"×"})]}),h.map(f=>g.jsxs("span",{className:`sel-chip sel-${f.kind}`,children:[g.jsxs("span",{className:"sel-text",title:ut(e,f.id),children:[f.kind==="absences"?"✕ ":"◉ ",ut(e,f.id)]}),g.jsx("button",{type:"button","aria-label":`Remove ${ut(e,f.id)}`,onClick:()=>a(f.kind,f.id),children:"×"})]},`${f.kind}:${f.id}`)),g.jsx("textarea",{ref:d,id:"ask",rows:1,value:n,placeholder:r?`${o} is working…`:h.length===1&&h[0].kind==="nodes"?"Ask, or try “what if it fails?”":h.length?"Ask about what you selected…":l?"Ask about this step…":"Ask about this map…",onChange:f=>i(f.target.value),onKeyDown:f=>{f.key==="Enter"&&!f.shiftKey&&(f.preventDefault(),!r&&n.trim()&&c())},"aria-label":"Ask a question about the map"}),g.jsx("button",{type:"submit",className:"send",disabled:r||!n.trim(),"aria-label":"Send",children:"↑"})]})}function j2({map:e,agent:t,selection:n,step:r,onRemove:o}){const s=["nodes","edges","absences"].flatMap(a=>n[a].map(l=>({kind:a,id:l}))),i=mC(t,s.length,r);return g.jsxs("div",{className:"composer composer-chat",role:"note","aria-label":"Where to ask",children:[s.map(a=>g.jsxs("span",{className:`sel-chip sel-${a.kind}`,children:[g.jsxs("span",{className:"sel-text",title:ut(e,a.id),children:[a.kind==="absences"?"✕ ":"◉ ",ut(e,a.id)]}),g.jsx("button",{type:"button","aria-label":`Remove ${ut(e,a.id)}`,onClick:()=>o(a.kind,a.id),children:"×"})]},`${a.kind}:${a.id}`)),g.jsxs("p",{className:"chat-hint",children:[g.jsx("strong",{children:i.title})," ",g.jsx("span",{className:"muted",children:i.detail})]})]})}const Vl="illuminate-toured",T2=100;function up(e){if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}function $2(e,t,n=T2){return[...e.filter(r=>r!==t),t].slice(-n)}function I2(e,t){const[n,r]=T.useState(()=>up(Ns(Vl)).includes(e));return T.useEffect(()=>{!t||n||!e||(rl(Vl,JSON.stringify($2(up(Ns(Vl)),e))),r(!0))},[e,t,n]),n}function R2({map:e,mapId:t,tour:n,onTour:r,selected:o,children:s}){const i=I2(t,n!==null),a=e.tour.length,l=a>0&&n===null;return!l&&!s?null:g.jsxs("div",{className:"dock",children:[l&&g.jsxs("section",{className:"dock-part dock-walk","aria-label":"Walkthrough",children:[g.jsx("h2",{className:"dock-title",children:"Walkthrough"}),g.jsxs("button",{className:i?"dock-start":"dock-start glow",onClick:()=>r(0),children:["Take the walkthrough ",g.jsxs("span",{className:"muted",children:[a," ",a===1?"stop":"stops"]})]})]}),s&&g.jsxs("section",{className:"dock-part dock-ask","aria-label":"Ask about the map",children:[g.jsxs("div",{className:"dock-head",children:[g.jsx("h2",{className:"dock-title",children:"Ask about the map"}),g.jsx("span",{className:"dock-hint",children:o?"Shift-click to add more":"Click a box or arrow to ask about it"})]}),s]})]})}function L2({state:e,dispatch:t}){const n=e.answers[e.answers.length-1];return n?g.jsx("div",{className:"history-corner",children:g.jsxs("button",{className:"pill-btn history-btn",onClick:()=>t(e.tour!==null?{type:"peek",open:!0}:{type:"show",answerId:n.id}),title:"Open the conversation about this map",children:[g.jsx("span",{className:"history-arrow",children:"‹"})," Conversation ",g.jsx("span",{className:"muted",children:e.answers.length})]})}):null}const $r=14,Ye=12;function P2(e,t){const n=a=>a[a.length-1],r=n(t.nodes),o=n(t.edges),s=n(t.absences),i=r!==void 0?`.react-flow__node[data-id="${CSS.escape(r)}"]`:o!==void 0?`.link-label[data-id="${CSS.escape(`e:${o}`)}"]`:s!==void 0?`.link-label[data-id="${CSS.escape(`a:${s}`)}"]`:null;return i?e.querySelector(i):null}const oc="illuminate-bubble-size",L0=300,P0=180;function O2(){try{const e=JSON.parse(Ns(oc)??"null");if(e&&typeof e=="object"&&"w"in e&&"h"in e&&typeof e.w=="number"&&typeof e.h=="number")return{w:Math.max(L0,e.w),h:Math.max(P0,e.h)}}catch{}return null}function z2({mapId:e,map:t,report:n,selection:r,onClose:o}){const s=[...r.nodes,...r.edges,...r.absences],i=s.join(" "),a=T.useRef(null),[l,u]=T.useState(null),c=T.useRef(null),d=Ds(),h=ge(p=>p.transform.join(",")),[f,v]=T.useState(""),[x,S]=T.useState(O2),y=p=>{const w=a.current,b=w==null?void 0:w.querySelector(".card-selected"),k=w==null?void 0:w.parentElement;if(!w||!b||!k||!l)return;p.preventDefault();const E=p.clientX,_=p.clientY,A=w.offsetWidth,L=b.offsetHeight,$=k.clientWidth-2*Ye,F=l.side==="right"?1:-1;let B={w:A,h:L};const N=R=>{B={w:Math.round(Math.max(L0,Math.min($,A+F*(R.clientX-E)))),h:Math.round(Math.max(P0,L+R.clientY-_))},S(B)},P=()=>{window.removeEventListener("pointermove",N),window.removeEventListener("pointerup",P),document.body.classList.remove("resizing-bubble"),rl(oc,JSON.stringify(B))};window.addEventListener("pointermove",N),window.addEventListener("pointerup",P),document.body.classList.add("resizing-bubble")},m=()=>{try{localStorage.removeItem(oc)}catch{}S(null)};return T.useLayoutEffect(()=>{const p=a.current;if(!p)return;const w=new ResizeObserver(()=>v(`${p.offsetWidth}x${p.offsetHeight}`));return w.observe(p),()=>w.disconnect()},[i]),T.useLayoutEffect(()=>{const p=a.current,w=p==null?void 0:p.parentElement;if(!p||!w)return;const b=P2(w,r);if(!b){u(null);return}const k=w.getBoundingClientRect(),E=b.getBoundingClientRect(),_={left:E.left-k.left,right:E.right-k.left,top:E.top-k.top,bottom:E.bottom-k.top},A=w.querySelector(".dock"),L=A?A.getBoundingClientRect().top-k.top-Ye:k.height-Ye,$=Math.max(160,L-Ye),F=p.offsetWidth,B=Math.min(p.offsetHeight,$),N=k.width-Ye-_.right-$r,P=_.left-$r-Ye,R=N>=F||N>=P?"right":"left",O=R==="right"?_.right+$r:_.left-$r-F,j=Math.max(Ye,Math.min(O,k.width-Ye-F)),M=Math.max(Ye,Math.min(_.top,L-B)),I=Math.max(16,Math.min((_.top+_.bottom)/2-M,B-16));if(u({left:j,top:M,side:R,pointer:I,maxHeight:$}),c.current===i)return;c.current=i;const z=R==="right"?_.left:_.left-$r-F,H=R==="right"?_.right+$r+F:_.right,ne=H-z<=k.width-2*Ye,Q=ne?z:_.left,U=ne?H:_.right,J=Q<Ye?Ye-Q:U>k.width-Ye?k.width-Ye-U:0,ee=_.top<Ye?Ye-_.top:_.bottom>L?Math.max(L-_.bottom,Ye-_.top):0;if(J||ee){const C=d.getViewport();d.setViewport({...C,x:C.x+J,y:C.y+ee},{duration:300})}},[i,h,f]),s.length?g.jsxs("div",{ref:a,className:`box-bubble box-bubble-${(l==null?void 0:l.side)??"right"}`,style:{...l?{left:l.left,top:l.top,"--bubble-max":`${l.maxHeight}px`}:{visibility:"hidden",left:0,top:0},...x?{width:x.w,"--bubble-cap":`${x.h}px`}:{}},role:"dialog","aria-label":"What you selected",children:[l&&g.jsx("i",{className:"box-bubble-pointer",style:{top:l.pointer},"aria-hidden":"true"}),g.jsx(C2,{mapId:e,map:t,report:n,ids:s,onClose:o},i),g.jsx("span",{className:"box-bubble-grip",onPointerDown:y,onDoubleClick:m,title:"Drag to resize. Double-click for the usual size.","aria-hidden":"true"})]}):null}const O0=[.5,.42,.58,.34,.66,.26,.74,.2,.8],D2=[...O0,.86,.14,.9,.1],bi=4,Ei={w:26,h:18},Wl=(e,t)=>e.x<t.x+t.w+bi&&t.x<e.x+e.w+bi&&e.y<t.y+t.h+bi&&t.y<e.y+e.h+bi,Ni=(e,t,n)=>({x:e.x-t/2,y:e.y-n/2,w:t,h:n});function F2(e,t,n=[]){const r=[],o={},s=(l,u)=>!t.some(c=>Wl(l,c))&&!r.some(c=>Wl(l,c))&&(!u||!n.some(c=>Wl(l,c))),i=[...e.filter(l=>l.keep),...e.filter(l=>!l.keep)],a=(l,u,c,d=O0)=>{for(const h of[!0,!1]){if(s(Ni(l.at,u,c),h))return l.at;for(const f of d){const v=l.along(f);if(v&&s(Ni(v,u,c),h))return v}}return null};for(const l of i){const u=a(l,l.w,l.h)??(l.keep?l.at:null);if(!u){const c=a(l,Ei.w,Ei.h,D2);c?(r.push(Ni(c,Ei.w,Ei.h)),o[l.id]={...c,dot:!0}):o[l.id]="dot";continue}r.push(Ni(u,l.w,l.h)),u!==l.at&&(o[l.id]=u)}return o}function B2(e,t){const n=[];let r=!1;for(const o of e.nodes)t("node",o.id)&&(r=!0,o.branch&&!n.includes(o.branch)&&n.push(o.branch));for(const o of e.edges)t("edge",o.id)&&(r=!0,o.branch&&!n.includes(o.branch)&&n.push(o.branch));return r?["now",...n.length>=2?n.map(o=>`option:${o}`):["proposed"],"both"]:[]}function sc(e,t){return e==="proposed"?!0:e.startsWith("option:")?!t||t===e.slice(7):!1}function ic(e,t,n){return e==="both"||!t||t.state!=="pending"?null:t.kind==="add"?sc(e,n)?null:e.startsWith("option:")?"other":"unbuilt":t.kind==="remove"&&sc(e,n)?"dropped":null}function H2(e,t,n){return t?e==="both"||t.state!=="pending"?!0:sc(e,n)&&!ic(e,t,n):!1}function cp(e){if(e==="now")return{label:"Now",title:"The code as it is; what is proposed is a shadow",heading:"The code as it is"};if(e==="proposed")return{label:"With the change",title:"The code as it would be; what would go is a shadow",heading:"With the change"};if(e==="both")return{label:"Both",title:"The code as it is, with the change drawn on top",heading:"The change on top of the code"};const t=e.slice(7);return{label:t,title:`The code as it would be with ${t}; the other options are shadows`,heading:`With ${t}`}}const cn=(...e)=>e.filter(Boolean).join(" "),mr={add:{pending:"Proposed",done:"Now in the code",mark:"+",title:"Proposed: not in the code yet"},change:{pending:"Would change",done:"Changed",mark:"~",title:"Proposed: this code would change"},remove:{pending:"Would be removed",done:"Removed",mark:"−",title:"Proposed: this code would be removed"}},ol=e=>e&&`proposal proposal-${e.kind} proposal-${e.state}${e.quiet&&e.state==="pending"?" proposal-quiet":""}`,U2={add:"New",change:"Changed",remove:"Removed"},yr={added:{label:"Added",mark:"+",title:"New since the commit this map is compared with"},changed:{label:"Changed",mark:"~",title:"Different from the commit this map is compared with"},removed:{label:"Removed",mark:"−",title:"Was in the code at the commit this map is compared with, and is gone now"}},sl=e=>e&&`change change-${e}`,Aa={later:{label:"Not there yet",title:"Added after this version of the code"},gone:{label:"Gone",title:"Removed: it was in the code before, and isn’t now"},unbuilt:{label:"Not built yet",title:"Proposed: only there with the change"},other:{label:"Other option",title:"Part of another option of the change, not this one"},dropped:{label:"Would go",title:"Proposed to be removed: not there with the change"}};function V2(e){if(!(e!=null&&e.length))return null;const t=e.filter(r=>r.startsWith("+ ")).length,n=e.filter(r=>r.startsWith("- ")).length;return[t&&`+${t}`,n&&`−${n}`].filter(Boolean).join(" ")||null}const W2=[["before","Before","The code as it was at that commit; what was added since is a shadow"],["after","After","The code as it is now; what was removed is a shadow"],["both","Both","The code as it is now, with what was removed drawn in too"]];function G2({commit:e,when:t,onWhen:n}){return g.jsxs("div",{className:"change-key",children:[g.jsx("div",{className:"seg",role:"group","aria-label":"Which version of the code to show",children:W2.map(([r,o,s])=>g.jsx("button",{className:cn("seg-btn",t===r&&"on"),title:s,"aria-pressed":t===r,onClick:()=>n(r),children:o},r))}),g.jsx("span",{className:"change-key-title",children:t==="before"?`The code at ${e}`:t==="after"?"The code now":`Now, compared with ${e}`}),t==="both"&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch"}),"Same as before"]}),t==="both"&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-added"}),"Added"]}),g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:cn("key-swatch key-changed",t!=="both"&&"key-quiet")}),t==="before"?"Changes later":"Changed"]}),t==="both"&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-removed"}),"Removed (only in the before)"]}),t!=="both"&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-ghost"}),t==="before"?"Not there yet":"Gone"]})]})}const Y2=5,Vs=e=>e&&`branch branch-${e.colour}`;function X2({branches:e,journey:t}){return g.jsxs("div",{className:"change-key branch-key",children:[g.jsx("span",{className:"change-key-title",children:"Ways through"}),t?g.jsxs("span",{className:"key-item",title:"What most people do, start to finish",children:[g.jsx("i",{className:"key-swatch"}),"Main path"]}):g.jsxs("span",{className:"key-item",title:"On every way through",children:[g.jsx("i",{className:"key-swatch"}),"Shared"]}),e.map(n=>g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:cn("key-swatch",Vs(n))}),n.name]},n.name))]})}function q2({views:e,plan:t,onPlan:n,shown:r}){return g.jsxs("div",{className:"change-key plan-key",children:[g.jsx("div",{className:"seg",role:"group","aria-label":"Which version of the proposal to show",children:e.map(o=>{const{label:s,title:i}=cp(o);return g.jsx("button",{className:cn("seg-btn",t===o&&"on"),title:i,"aria-pressed":t===o,onClick:()=>n(o),children:s},o)})}),g.jsx("span",{className:"change-key-title",children:cp(t).heading}),r.has("new")&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-new"}),"New"]}),r.has("unbuilt")&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-ghost"}),"Not built yet"]}),r.has("other")&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-ghost"}),"Other option"]}),r.has("dropped")&&g.jsxs("span",{className:"key-item",children:[g.jsx("i",{className:"key-swatch key-ghost"}),"Would go"]})]})}const _i={entry:["Where it starts","▸"],store:["Saved data","▤"],external:["Outside the app","↗"],job:["Background job","◷"]},dp=[["t",ie.Top],["r",ie.Right],["b",ie.Bottom],["l",ie.Left]];function z0(){return g.jsxs(g.Fragment,{children:[dp.map(([e,t])=>g.jsx(mo,{id:`s${e}`,type:"source",position:t,className:"handle",isConnectable:!1},`s${e}`)),dp.map(([e,t])=>g.jsx(mo,{id:`t${e}`,type:"target",position:t,className:"handle",isConnectable:!1},`t${e}`))]})}function K2({data:e}){var t,n,r;return e.journey?g.jsx(Z2,{data:e}):g.jsxs("div",{className:cn("step","nopan",`kind-${e.kind}`,!e.confirmed&&"unconfirmed",ol(e.proposal),sl(e.change),e.quiet&&"quiet",e.ghost&&"ghost",Vs(e.branch),e.selected&&"selected",e.hl&&"hl",e.dim&&"dim"),onClick:o=>{o.stopPropagation(),e.onClick(o.shiftKey||o.metaKey)},onMouseEnter:()=>{var o;return(o=e.onHover)==null?void 0:o.call(e,!0)},onMouseLeave:()=>{var o;return(o=e.onHover)==null?void 0:o.call(e,!1)},children:[g.jsx(z0,{}),(_i[e.kind]||e.fresh||e.screen||e.proposal||e.change||e.ghost)&&g.jsxs("div",{className:"step-head",children:[e.ghost&&g.jsx("span",{className:"badge-ghost",title:Aa[e.ghost].title,children:Aa[e.ghost].label}),e.proposal&&g.jsx("span",{className:"badge-proposal",children:e.proposal.quiet&&e.proposal.state==="pending"?U2[e.proposal.kind]:mr[e.proposal.kind][e.proposal.state]}),e.change&&g.jsxs("span",{className:"badge-change",title:yr[e.change].title,children:[e.quiet==="before"?"Changes later":yr[e.change].label,e.changeSize&&!e.quiet&&g.jsxs("span",{className:"change-size",children:[" ",e.changeSize]})]}),_i[e.kind]&&!e.proposal&&!e.change&&!e.ghost&&g.jsxs(g.Fragment,{children:[g.jsx("i",{className:"step-mark","aria-hidden":"true",children:_i[e.kind][1]}),_i[e.kind][0]]}),e.screen&&g.jsx("span",{className:"badge-screen",title:"Select this step to see the screen",children:"▣ Screen"}),e.fresh&&g.jsx("span",{className:"badge-new",children:"New"})]}),g.jsx("div",{className:"step-name",title:e.name,children:e.name}),g.jsxs("div",{className:"step-code",title:((t=e.proposal)==null?void 0:t.state)==="pending"?mr[e.proposal.kind].title:e.confirmed?"Confirmed against the code":"The checker couldn't confirm this against the code",children:[((n=e.proposal)==null?void 0:n.state)==="pending"&&e.proposal.kind==="add"||e.ghost==="unbuilt"||e.ghost==="other"?g.jsx("span",{className:"pmark",children:"+"}):((r=e.proposal)==null?void 0:r.state)==="done"&&e.proposal.kind!=="add"?g.jsx("span",{className:"pmark",children:mr[e.proposal.kind].mark}):e.change&&e.confirmed?g.jsx("span",{className:"cmark",children:yr[e.change].mark}):g.jsx("span",{className:e.confirmed?"tick":"qmark",children:e.confirmed?"✓":"?"}),g.jsx("span",{className:"step-sub",children:e.sub})]})]})}function Z2({data:e}){const t=e.journey,n=e.proposal;return g.jsxs("div",{className:cn("step","jstep","nopan",`j-${t.shape}`,t.show&&"j-pictured",t.outside&&"j-outside",!e.confirmed&&"unconfirmed",ol(n),sl(e.change),e.quiet&&"quiet",e.ghost&&"ghost",Vs(t.branch),e.selected&&"selected",e.hl&&"hl",e.dim&&"dim"),style:{width:t.w,height:t.h},onClick:r=>{r.stopPropagation(),e.onClick(r.shiftKey||r.metaKey)},onMouseEnter:()=>{var r;return(r=e.onHover)==null?void 0:r.call(e,!0)},onMouseLeave:()=>{var r;return(r=e.onHover)==null?void 0:r.call(e,!1)},children:[g.jsx(z0,{}),t.stage&&g.jsx("div",{className:"j-stage",children:t.stage}),t.shape==="choice"&&g.jsx("svg",{className:"j-diamond",viewBox:"0 0 100 100",preserveAspectRatio:"none","aria-hidden":"true",children:g.jsx("polygon",{points:"50,1 99,50 50,99 1,50",vectorEffect:"non-scaling-stroke"})}),g.jsxs("div",{className:"j-tags",children:[n&&g.jsx("span",{className:"badge-proposal",children:mr[n.kind][n.state]}),e.ghost&&g.jsx("span",{className:"badge-ghost",title:Aa[e.ghost].title,children:Aa[e.ghost].label}),e.change&&g.jsx("span",{className:"badge-change",title:yr[e.change].title,children:e.quiet==="before"?"Changes later":yr[e.change].label}),!e.confirmed&&g.jsx("span",{className:"j-q",title:"The checker couldn't confirm this against the code",children:"?"}),e.fresh&&g.jsx("span",{className:"badge-new",children:"New"})]}),t.show&&g.jsx($C,{show:t.show,name:e.name}),g.jsx("div",{className:"j-name",title:e.name,children:e.name}),t.outside&&t.shape!=="choice"&&g.jsx("div",{className:"j-note",children:"Outside the app"})]})}function Q2({data:e}){return g.jsx("div",{className:cn("area",e.dim&&"dim"),children:g.jsxs("div",{className:"area-label",children:[e.label,e.note&&g.jsxs("span",{className:"area-note",children:[" ",e.note]})]})})}function J2(e,t,n,r,o){if(o==="over"){const l=Math.max(Math.abs(n-e)/2,40),u=Math.max(70,Math.min(170,Math.abs(n-e)*.32)),c=e<n?1:0;return[`M ${e} ${t} A ${l} ${u} 0 0 ${c} ${n} ${r}`,(e+n)/2,(t+r)/2-u]}const s=Math.max(Math.abs(r-t)/2,40),i=Math.max(60,Math.min(150,Math.abs(r-t)*.32)),a=t<r?1:0;return[`M ${e} ${t} A ${i} ${s} 0 0 ${a} ${n} ${r}`,Math.max(e,n)+i,(t+r)/2]}function eA(e,t,n,r,o){const s=Math.hypot(n-e,r-t)||1,i=-(r-t)/s,a=(n-e)/s,l=(e+n)/2+i*o*2,u=(t+r)/2+a*o*2;return[`M ${e} ${t} Q ${l} ${u} ${n} ${r}`,(e+n)/2+i*o,(t+r)/2+a*o]}function fp(e,t=18,n){let r=`M ${e[0][0]} ${e[0][1]}`;for(let l=1;l<e.length-1;l++){const[u,c]=e[l-1],[d,h]=e[l],[f,v]=e[l+1],x=Math.min(t,Math.hypot(d-u,h-c)/2),S=Math.min(t,Math.hypot(f-d,v-h)/2),y=Math.sign(d-u),m=Math.sign(h-c),p=Math.sign(f-d),w=Math.sign(v-h);r+=` L ${d-y*x} ${h-m*x} Q ${d} ${h} ${d+p*S} ${h+w*S}`}const o=e[e.length-1];r+=` L ${o[0]} ${o[1]}`;const[s,i]=n!==void 0?[e[n],e[n+1]]:[];if(s&&i)return[r,(s[0]+i[0])/2,(s[1]+i[1])/2];let a=[0,e[0][0],e[0][1]];for(let l=1;l<e.length;l++){const[u,c]=e[l-1],[d,h]=e[l];c===h&&Math.abs(d-u)>a[0]&&(a=[Math.abs(d-u),(u+d)/2,h])}return[r,a[1],a[2]]}function tA({id:e,sourceX:t,sourceY:n,targetX:r,targetY:o,sourcePosition:s,targetPosition:i,markerEnd:a,data:l}){const[u,c,d]=l!=null&&l.loop?J2(t,n,r,o,l.loop):l!=null&&l.route?fp(l.route.points,18,l.route.label):(l==null?void 0:l.wrapY)!==void 0&&s===ie.Right?fp([[t,n],[t+30,n],[t+30,l.wrapY],[r,l.wrapY],[r,o]]):(l==null?void 0:l.wrapY)!==void 0?ba({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i,borderRadius:18,centerY:l.wrapY}):l!=null&&l.offset?eA(t,n,r,o,l.offset):gd({sourceX:t,sourceY:n,sourcePosition:s,targetX:r,targetY:o,targetPosition:i});if(!l)return null;const h=l.place&&l.place!=="dot"?l.place:null,f=(l.place==="dot"||typeof l.place=="object"&&"dot"in l.place)&&!l.selected;return g.jsxs(g.Fragment,{children:[l.selected&&g.jsx("path",{d:u,className:"edge-halo"}),g.jsx(Fs,{id:e,path:u,markerEnd:a,interactionWidth:18}),g.jsx(F_,{children:g.jsxs("div",{className:cn("link-label",f&&"dot",`link-${l.variant}`,!l.confirmed&&"unconfirmed",ol(l.proposal),sl(l.change),l.ghost&&"ghost",Vs(l.branch),l.hl&&"hl",l.dim&&"dim",l.selected&&"selected","nodrag nopan"),"data-id":e,"data-x":c,"data-y":d,title:f?l.label:void 0,onMouseEnter:l.onHover&&(()=>l.onHover(!0)),onMouseLeave:l.onHover&&(()=>l.onHover(!1)),style:{transform:`translate(-50%, -50%) translate(${(h==null?void 0:h.x)??c}px, ${(h==null?void 0:h.y)??d}px)`},onClick:v=>{var x;v.stopPropagation(),(x=l.onClick)==null||x.call(l,v.shiftKey||v.metaKey)},children:[l.variant==="absence"&&g.jsx("span",{className:"gap-q","aria-hidden":"true",children:"?"}),l.proposal&&!(l.proposal.quiet&&l.proposal.state==="pending"&&l.proposal.kind==="add")&&g.jsx("span",{className:"pmark",title:l.proposal.state==="done"?mr[l.proposal.kind].done:mr[l.proposal.kind].title,children:l.proposal.state==="done"&&l.proposal.kind==="add"?"✓":mr[l.proposal.kind].mark}),l.change&&g.jsx("span",{className:"cmark",title:yr[l.change].title,children:yr[l.change].mark}),g.jsx("span",{className:"link-text",children:l.label}),!l.confirmed&&l.variant==="edge"&&g.jsx("span",{className:"q",children:" ?"})]})})]})}const nA={step:K2,area:Q2},rA={link:tA};function hp(e,t){const n=new Set;for(const r of t){e.nodes.some(i=>i.id===r)&&n.add(r);const o=e.edges.find(i=>i.id===r);o&&n.add(o.from).add(o.to);const s=e.absences.find(i=>i.id===r);s!=null&&s.between&&n.add(s.between.from).add(s.between.to)}return[...n]}const oA="440px",sA=e=>e.length>28?`${e.slice(0,26)}…`:e;function iA(e){var V,G,re,ae,de,Fe,We,Ge,rt,fe,wt;const t=(V=e.ghost)!=null&&V.connects&&e.map.nodes.some(W=>W.id===e.ghost.connects.from)&&e.map.nodes.some(W=>W.id===e.ghost.connects.to)?e.ghost:null,n=T.useMemo(()=>t!=null&&t.connects?[{id:t.id,from:t.connects.from,to:t.connects.to}]:[],[t]),r=T.useMemo(()=>e.map.view==="journey"?e.map.nodes.filter(W=>{var te,ce,ue;return W.kind!=="action"&&W.kind!=="choice"&&((ue=(ce=(te=e.report)==null?void 0:te.screens)==null?void 0:ce[W.id])==null?void 0:ue.status)==="confirmed"}).map(W=>W.id):[],[e.map,e.report]),o=f2(e.map,n,e.added,r),[s,i]=T.useState(null),a=Ds(),[l,u]=T.useState({key:"",at:{}}),[c,d]=T.useState("both"),f=!!((re=(G=e.report)==null?void 0:G.since)!=null&&re.commit)?c:"both",v=W=>{var te,ce,ue,pe,oe,le;return((ue=(ce=(te=e.report)==null?void 0:te.nodes[W])==null?void 0:ce.change)==null?void 0:ue.kind)??((le=(oe=(pe=e.report)==null?void 0:pe.edges[W])==null?void 0:oe.change)==null?void 0:le.kind)??null},[x,S]=T.useState("both"),y=T.useMemo(()=>B2(e.map,(W,te)=>{var ce,ue,pe,oe;return((oe=(pe=W==="node"?(ce=e.report)==null?void 0:ce.nodes[te]:(ue=e.report)==null?void 0:ue.edges[te])==null?void 0:pe.proposal)==null?void 0:oe.state)==="pending"}),[e.map,e.report]),m=y.includes(x)?x:"both",p=W=>{const te=e.map.nodes.find(pe=>pe.id===W);if(te)return te.branch??null;const ce=e.map.edges.find(pe=>pe.id===W),ue=pe=>{var oe;return(oe=e.map.nodes.find(le=>le.id===pe))==null?void 0:oe.branch};return(ce==null?void 0:ce.branch)??ue(ce==null?void 0:ce.to)??ue(ce==null?void 0:ce.from)??null},w=W=>{var te,ce,ue,pe;return((ce=(te=e.report)==null?void 0:te.nodes[W])==null?void 0:ce.proposal)??((pe=(ue=e.report)==null?void 0:ue.edges[W])==null?void 0:pe.proposal)??null},b=W=>{const te=w(W);return te&&H2(m,te,p(W))?{...te,quiet:m!=="both"}:null},k=W=>f==="before"&&v(W)==="added"?"later":f==="after"&&v(W)==="removed"?"gone":ic(m,w(W),p(W)),E=W=>f==="both"||W==="changed"?W:null,_=JSON.stringify([(s==null?void 0:s.key)??null,f,m,(t==null?void 0:t.id)??null]),A=new Set;if(m!=="both")for(const W of e.map.nodes.map(te=>te.id)){const te=ic(m,w(W),p(W));te?A.add(te):((ae=b(W))==null?void 0:ae.kind)==="add"&&A.add("new")}T.useEffect(()=>{let W=!0;return JC(e.map,n,new Set(e.added),new Set(r)).then(te=>W&&i({key:o,layout:te}),te=>console.error("illuminate: the map could not be laid out",te)),()=>{W=!1}},[o]);const L=T.useMemo(()=>!s||s.layout.flat||s.layout.lanes?new Set:j0(e.map),[e.map,s]),$=T.useMemo(()=>[...L].flatMap(W=>T0(e.map,W)??[]),[L,e.map]),F=W=>$.find(te=>te.edges.includes(W))??null,B=T.useRef(void 0),N=T.useRef([]),P=T.useRef(F);P.current=F;const R=(W,te,ce)=>{window.clearTimeout(B.current),B.current=window.setTimeout(()=>{for(const xe of N.current)xe.classList.remove("pointed");if(N.current=[],!ce)return;const ue=W==="edge"?P.current(te):null,pe=ue?ue.nodes:W==="node"?[te]:[],oe=ue?ue.edges:W==="edge"?[te]:[],le=[...pe.flatMap(xe=>[...document.querySelectorAll(`.react-flow__node[data-id="${CSS.escape(xe)}"] .step`)]),...oe.flatMap(xe=>[...document.querySelectorAll(`.react-flow__edge[data-id="${CSS.escape(`e:${xe}`)}"], .link-label[data-id="${CSS.escape(`e:${xe}`)}"]`)])];for(const xe of le)xe.classList.add("pointed");N.current=le},ce?150:80)};T.useEffect(()=>()=>window.clearTimeout(B.current),[]);const O=e.selection.edges.map(F).find(W=>!!W)??null,j=O?new Set([...O.nodes,...O.edges]):(de=e.view)!=null&&de.highlight.length?new Set(e.view.highlight):null,M=T.useMemo(()=>j?new Set(hp(e.map,[...j])):null,[j,e.map]),I=e.selection,z=T.useMemo(()=>((s==null?void 0:s.layout.branches)??[]).map((W,te)=>({name:W,colour:te%Y2+1})),[s]),H=y.some(W=>W.startsWith("option:")),ne=W=>!H||m==="both"||m===`option:${W}`,Q=W=>W&&ne(W)?z.find(te=>te.name===W)??null:null,U=z.filter(W=>ne(W.name)),J=(W,te,ce)=>{var oe;if(!z.length||!ce)return null;if(W==="node")return Q((oe=e.map.nodes.find(le=>le.id===te))==null?void 0:oe.branch);const ue=e.map.edges.find(le=>le.id===te),pe=le=>{var xe;return(xe=e.map.nodes.find(me=>me.id===le))==null?void 0:xe.branch};return Q((ue==null?void 0:ue.branch)??pe(ue==null?void 0:ue.to)??pe(ue==null?void 0:ue.from))},ee=T.useMemo(()=>{if(!s)return[];const W=s.layout,te=oe=>!M||e.map.nodes.some(le=>le.area===oe&&M.has(le.id)),ce=e.map.areas.flatMap(oe=>{const le=W.areas[oe.id];return le?[{id:`area:${oe.id}`,type:"area",position:{x:le.x,y:le.y},style:{width:le.w,height:le.h},initialWidth:le.w,initialHeight:le.h,measured:{width:le.w,height:le.h},data:{label:oe.label,note:null,dim:!te(oe.id)},selectable:!1,draggable:!1,zIndex:0}]:[]}),ue=new Map;if(W.flat){const oe=le=>W.branches&&le.branch?1:0;for(const le of e.map.areas){const xe=e.map.nodes.filter(me=>me.area===le.id&&W.nodes[me.id]).sort((me,ke)=>oe(me)-oe(ke)||W.nodes[me.id].x-W.nodes[ke.id].x||W.nodes[me.id].y-W.nodes[ke.id].y)[0];xe&&ue.set(xe.id,le.label)}}const pe=e.map.nodes.flatMap(oe=>{var ot,st,Ne,Zt,Qt,Jn,q,ve,we,Te,it,xt,Jt,er,fn;const le=W.nodes[oe.id];if(!le)return[];const xe=oe.evidence[0],me=oe.symbol?oe.symbol.slice(oe.symbol.indexOf("#")+1):xe?`${xe.file.split("/").pop()}:${xe.line}`:"not in the code yet",ke=(ot=e.report)==null?void 0:ot.nodes[oe.id],Me=J("node",oe.id,!!ke&&(ke.status!=="unconfirmed"||!!ke.proposal)&&!E(((st=ke.change)==null?void 0:st.kind)??null)&&!k(oe.id));return[{id:oe.id,type:"step",...W.flat?{}:{parentId:`area:${oe.area}`,extent:"parent"},position:{x:le.x,y:le.y},initialWidth:le.w,initialHeight:le.h,measured:{width:le.w,height:le.h},data:{name:oe.name,sub:me,kind:oe.kind,confirmed:!!e.report&&((Ne=e.report.nodes[oe.id])==null?void 0:Ne.status)!=="unconfirmed",proposal:b(oe.id),screen:((Jn=(Qt=(Zt=e.report)==null?void 0:Zt.screens)==null?void 0:Qt[oe.id])==null?void 0:Jn.status)==="confirmed",selected:I.nodes.includes(oe.id),hl:!!(M!=null&&M.has(oe.id)),dim:!!M&&!M.has(oe.id)&&!I.nodes.includes(oe.id),fresh:e.fresh.includes(oe.id),change:E(((we=(ve=(q=e.report)==null?void 0:q.nodes[oe.id])==null?void 0:ve.change)==null?void 0:we.kind)??null),changeSize:V2((xt=(it=(Te=e.report)==null?void 0:Te.nodes[oe.id])==null?void 0:it.change)==null?void 0:xt.diff),ghost:k(oe.id),quiet:f==="both"?null:f,branch:Me,...W.flat&&{journey:{w:le.w,h:le.h,shape:oe.kind==="choice"?"choice":oe.kind==="action"?"action":"screen",outside:oe.kind==="external",stage:ue.get(oe.id)??null,show:r.includes(oe.id)?((fn=(er=(Jt=e.report)==null?void 0:Jt.screens)==null?void 0:er[oe.id])==null?void 0:fn.show)??null:null,branch:Me}},onClick:Cn=>e.onSelect("nodes",oe.id,Cn),onHover:Cn=>R("node",oe.id,Cn)},draggable:!1,zIndex:3}]});return[...ce,...pe]},[s,e.map,e.report,I,M,e.fresh,e.onSelect,r,f,m,z]),C=T.useMemo(()=>{var Ne,Zt,Qt,Jn;if(!s)return[];const W=q=>({type:ks.ArrowClosed,width:16,height:16,color:q}),te=q=>!!(j!=null&&j.has(q)),ce=(q,ve)=>{const[we,Te]=d2(e.map,s.layout,q,ve);return{sourceHandle:`s${we}`,targetHandle:`t${Te}`}},ue=new Map,pe=(q,ve)=>{const we=s.layout.rowTops,Te=_a(s.layout,q),it=_a(s.layout,ve);if(!we||Te===it)return;const xt=Math.max(Te,it),Jt=ue.get(xt)??0;return ue.set(xt,Jt+1),we[xt]-nc/2+(Jt%2?1:-1)*Math.ceil(Jt/2)*18},oe=L,le=q=>{const ve=e.map.nodes.find(it=>it.id===q),we=s.layout.nodes[q],Te=ve?s.layout.areas[ve.area]:void 0;return we?{x:((Te==null?void 0:Te.x)??0)+we.x+we.w/2,y:((Te==null?void 0:Te.y)??0)+we.y+we.h/2}:{x:0,y:0}},xe=new Map((s.layout.rings??[]).flatMap((q,ve)=>q.map(we=>[we,ve]))),me=q=>xe.has(q.from)&&xe.get(q.from)===xe.get(q.to),ke=q=>{if(!oe.has(q.id)||me(q))return;const ve=Math.abs(le(q.to).x-le(q.from).x),we=Math.abs(le(q.to).y-le(q.from).y);return ve<tt*.75?"side":we<qe/2?"over":void 0},Me=e.map.edges.map(q=>{var Cn,Ws,Gs,Ys,Xs;const ve=!!e.report&&((Cn=e.report.edges[q.id])==null?void 0:Cn.status)!=="unconfirmed",we=ke(q),Te=b(q.id),it=E(((Ys=(Gs=(Ws=e.report)==null?void 0:Ws.edges[q.id])==null?void 0:Gs.change)==null?void 0:Ys.kind)??null),xt=k(q.id)??k(q.from)??k(q.to),Jt=te(q.id)||!!M&&M.has(q.from)&&M.has(q.to)&&!j,er="edge",fn=J("edge",q.id,!it&&!xt);return{id:`e:${q.id}`,source:q.from,target:q.to,...we==="over"?{sourceHandle:"st",targetHandle:"tt"}:we==="side"?{sourceHandle:"sr",targetHandle:"tr"}:ce(q.from,q.to),type:"link",className:cn("link",`link-${er}`,oe.has(q.id)&&"link-loop",!ve&&"unconfirmed",ol(Te),sl(it),xt&&"ghost",Vs(fn),te(q.id)&&"hl",!!j&&!te(q.id)&&"dim",I.edges.includes(q.id)&&"selected"),markerEnd:W(xt?"var(--line)":fn?`var(--branch-${fn.colour})`:we?"var(--path)":(Te==null?void 0:Te.state)==="pending"&&Te.kind!=="remove"?"var(--ai)":it==="added"?"var(--ok)":it==="removed"?"var(--dead)":te(q.id)?"var(--path)":"var(--line-strong)"),zIndex:1,data:{label:q.label,loop:we,onHover:ko=>R("edge",q.id,ko),wrapY:pe(q.from,q.to),route:(Xs=s.layout.routes)==null?void 0:Xs[`e:${q.id}`],branch:fn,variant:er,proposal:Te,change:it,ghost:xt,confirmed:ve,hl:Jt,dim:!!j&&!te(q.id)&&!I.edges.includes(q.id),selected:I.edges.includes(q.id),onClick:ko=>e.onSelect("edges",q.id,ko)}}}),ot=q=>{var ve;return((ve=t==null?void 0:t.connects)==null?void 0:ve.from)===q.from&&t.connects.to===q.to};for(const q of e.map.absences){if(!q.between||ot(q.between))continue;const ve=((Zt=(Ne=e.report)==null?void 0:Ne.absences[q.id])==null?void 0:Zt.status)==="confirmed";Me.push({id:`a:${q.id}`,hidden:f==="before",source:q.between.from,target:q.between.to,...ce(q.between.from,q.between.to),type:"link",className:cn("link","link-absence",!ve&&"unconfirmed",te(q.id)&&"hl",!!j&&!te(q.id)&&"dim",I.absences.includes(q.id)&&"selected"),markerEnd:W("var(--dead)"),zIndex:1,data:{label:sA(q.claim),route:(Qt=s.layout.routes)==null?void 0:Qt[`a:${q.id}`],variant:"absence",confirmed:ve,hl:te(q.id),dim:!!j&&!te(q.id)&&!I.absences.includes(q.id),selected:I.absences.includes(q.id),onClick:we=>e.onSelect("absences",q.id,we)}})}t!=null&&t.connects&&Me.push({id:`g:${t.id}`,source:t.connects.from,target:t.connects.to,...ce(t.connects.from,t.connects.to),type:"link",className:"link link-ghost",markerEnd:W("var(--ok)"),zIndex:2,data:{label:`+ ${t.connects.label}`,route:(Jn=s.layout.routes)==null?void 0:Jn[`x:${t.id}`],variant:"ghost",confirmed:!0,hl:!0,dim:!1,selected:!1}});const st=new Map;for(const q of Me){const ve=[q.source,q.target].sort().join("|");st.set(ve,[...st.get(ve)??[],q])}for(const q of st.values())q.length<2||q.some(ve=>{var we;return(we=ve.data)==null?void 0:we.route})||q.forEach((ve,we)=>{ve.data&&(ve.data.offset=(we-(q.length-1)/2)*44)});if(l.key===_)for(const q of Me)q.data&&l.at[q.id]&&(q.data.place=l.at[q.id]);return Me},[s,e.map,e.report,I,j,M,t,e.onSelect,f,m,z,l,_]);T.useEffect(()=>{if(!s)return;let W=0,te=0;const ce=()=>{const ue=[...document.querySelectorAll(".react-flow__edgelabel-renderer .link-label[data-id]")],pe=ue.length>0&&ue.every(me=>me.offsetWidth>0)&&a.getNodes().every(me=>{var ke,Me;return(Me=(ke=a.getInternalNode(me.id))==null?void 0:ke.measured)==null?void 0:Me.width});if(W++<2||!pe){W<60&&(te=requestAnimationFrame(ce));return}const oe=[],le=[];for(const me of a.getNodes()){const ke=a.getInternalNode(me.id);if(!ke||me.hidden)continue;const Me=ke.internals.positionAbsolute,ot=ke.measured.width??0,st=ke.measured.height??0;me.type==="step"?oe.push({x:Me.x,y:Me.y,w:ot,h:st}):me.type==="area"&&le.push({x:Me.x,y:Me.y,w:Math.min(ot,280),h:40})}const xe=ue.map(me=>{var ot;const ke=document.getElementById(me.dataset.id),Me=((ot=ke==null?void 0:ke.getTotalLength)==null?void 0:ot.call(ke))??0;return{id:me.dataset.id,w:me.offsetWidth,h:me.offsetHeight,at:{x:Number(me.dataset.x),y:Number(me.dataset.y)},keep:me.dataset.id.startsWith("a:"),along:st=>{if(!ke||!Me)return null;const Ne=ke.getPointAtLength(Me*st);return{x:Ne.x,y:Ne.y}}}});u({key:_,at:F2(xe,oe,le)})};return te=requestAnimationFrame(ce),()=>cancelAnimationFrame(te)},[_]);const D=ge(W=>W.width),Z=T.useRef(0);T.useEffect(()=>{const W=Z.current;if(Z.current=D,!W||!D||W===D||e.touring)return;const te=a.getViewport();a.setViewport({...te,x:te.x+(D-W)/2})},[D]);const Y=JSON.stringify([s==null?void 0:s.key,(Fe=e.view)==null?void 0:Fe.focus,(We=e.view)==null?void 0:We.highlight,e.touring,e.touring?D:null]),X=T.useRef(!0);return T.useEffect(()=>{if(!s)return;const W=e.view?hp(e.map,e.view.highlight.length?e.view.highlight:e.view.focus?[e.view.focus]:[]):[];let te=0,ce=0;const ue=()=>{var st;const pe=a.getNodes();if(te<2||!pe.length||!pe.every(Ne=>{var Zt,Qt;return(Qt=(Zt=a.getInternalNode(Ne.id))==null?void 0:Zt.measured)==null?void 0:Qt.width})){te++<60&&(ce=requestAnimationFrame(ue));return}const oe=X.current?0:650;X.current=!1;const le=Object.values(s.layout.nodes),xe=Object.values(s.layout.routes??{}).flatMap(Ne=>Ne.points),me=Math.max(0,Math.min(0,...le.map(Ne=>Ne.y))-Math.min(0,...xe.map(Ne=>Ne[1]))),ke=Math.max(0,Math.max(0,...xe.map(Ne=>Ne[1]))-Math.max(0,...le.map(Ne=>Ne.y+Ne.h))+(xe.length?16:0)),Me=(st=s.layout.branches)!=null&&st.length?56:0,ot=W.length?{top:`${60+Me}px`,left:e.touring?oA:"60px",right:"60px",bottom:"150px"}:{top:`${64+me+Me}px`,left:"32px",right:"32px",bottom:`${130+ke}px`};a.fitView(W.length?{nodes:W.map(Ne=>({id:Ne})),duration:oe,padding:ot,maxZoom:1.15}:{duration:oe,padding:ot,maxZoom:1.1})};return ce=requestAnimationFrame(ue),()=>cancelAnimationFrame(ce)},[Y]),g.jsxs(z_,{className:s!=null&&s.layout.flat?"journey":s!=null&&s.layout.lanes?"lanes":void 0,nodes:ee,edges:C,zIndexMode:"manual",nodeTypes:nA,edgeTypes:rA,onNodeClick:()=>{},onEdgeClick:(W,te)=>{te.id.startsWith("e:")&&e.onSelect("edges",te.id.slice(2),W.shiftKey||W.metaKey),te.id.startsWith("a:")&&e.onSelect("absences",te.id.slice(2),W.shiftKey||W.metaKey)},onEdgeMouseEnter:(W,te)=>{te.id.startsWith("e:")&&R("edge",te.id.slice(2),!0)},onEdgeMouseLeave:(W,te)=>{te.id.startsWith("e:")&&R("edge",te.id.slice(2),!1)},onPaneClick:e.onClear,panOnDrag:!0,elementsSelectable:!1,nodesDraggable:!1,nodesConnectable:!1,minZoom:.15,maxZoom:2,children:[g.jsx(W_,{variant:xn.Dots,gap:22,size:1.3}),(((rt=(Ge=e.report)==null?void 0:Ge.since)==null?void 0:rt.commit)||y.length>0||z.length>0)&&g.jsx(zs,{position:"top-left",children:g.jsxs("div",{className:"map-keys",children:[((wt=(fe=e.report)==null?void 0:fe.since)==null?void 0:wt.commit)&&g.jsx(G2,{commit:e.report.since.commit.slice(0,7),when:f,onWhen:d}),y.length>0&&g.jsx(q2,{views:y,plan:m,onPlan:S,shown:A}),U.length>0&&g.jsx(X2,{branches:U,journey:e.map.view==="journey"})]})})]})}function il(e){e!==`${location.pathname}${location.search}`&&(history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate")))}function aA(){const[e,t]=T.useState(location.pathname);return T.useEffect(()=>{const n=()=>t(location.pathname),r=o=>{var i,a;if(o.defaultPrevented||o.button!==0||o.metaKey||o.ctrlKey||o.shiftKey||o.altKey)return;const s=(a=(i=o.target)==null?void 0:i.closest)==null?void 0:a.call(i,"a[href]");!(s instanceof HTMLAnchorElement)||s.target||s.origin!==location.origin||(o.preventDefault(),il(`${s.pathname}${s.search}`))};return window.addEventListener("popstate",n),document.addEventListener("click",r),()=>{window.removeEventListener("popstate",n),document.removeEventListener("click",r)}},[]),e}const lA=8e3;function D0({busy:e,agentName:t="Claude",onStopped:n,onError:r}){const[o,s]=T.useState(!1);return T.useEffect(()=>{if(!o)return;const i=setTimeout(()=>s(!1),lA),a=l=>{l.key==="Escape"&&s(!1)};return window.addEventListener("keydown",a),()=>{clearTimeout(i),window.removeEventListener("keydown",a)}},[o]),o&&!e?g.jsxs("span",{className:"stop-ask",role:"group","aria-label":"Stop illuminate?",children:[g.jsx("span",{className:"stop-ask-text",children:"Stop illuminate? Maps stay saved."}),g.jsx("button",{className:"pill-btn stop-yes",autoFocus:!0,onClick:()=>{s(!1),Ht.stop().then(n,i=>r(i.message))},children:"Stop"}),g.jsx("button",{className:"pill-btn",onClick:()=>s(!1),children:"Keep running"})]}):g.jsx("button",{className:"pill-btn",disabled:e,title:e?`${t} is still working`:"Maps stay saved. Undo for applied fixes ends.",onClick:()=>s(!0),children:"Stop illuminate"})}function uA(){return g.jsxs("main",{className:"home",children:[g.jsx("h1",{children:"illuminate has stopped"}),g.jsx("p",{className:"muted lede",children:"You can close this tab."}),g.jsxs("p",{className:"muted lede",children:["Maps are saved in ",g.jsx("code",{children:".illuminate/maps"}),". Run ",g.jsx("code",{children:"illume open"})," in the repo to see them again."]})]})}function cA({onStopped:e}){const[t,n]=T.useState(""),[r,o]=T.useState(null),[s,i]=T.useState([]),[a,l]=T.useState(""),[u,c]=T.useState(null),[d,h]=T.useState(!1),[f,v]=T.useState(S0);T.useEffect(()=>k0(()=>{},()=>{},e),[e]),T.useEffect(()=>{Ht.list().then(S=>{n(S.repo),o(S.maps),i(S.making),S.agent&&v(S.agent)},S=>c(S.message))},[]);const x=async()=>{if(a.trim()){h(!0);try{const{id:S}=await Ht.make(a.trim());il(sn(S))}catch(S){c(S.message),h(!1)}}};return g.jsxs("main",{className:"home",children:[g.jsxs("div",{className:"home-brand",children:[g.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate",t&&g.jsx("span",{className:"muted",children:t})]}),g.jsx("h1",{children:"Ask how your code works"}),g.jsx("p",{className:"muted lede",children:"Every box and arrow is checked against the code."}),nl(f)?g.jsxs("p",{className:"home-ask chat-hint",children:[g.jsxs("strong",{children:["Ask for a new map in the ",f.name," chat beside this page"]})," ",g.jsx("span",{className:"muted",children:"for example: “Map what happens when a user signs up.”"})]}):g.jsxs("form",{className:"home-ask",onSubmit:S=>{S.preventDefault(),x()},children:[g.jsx("input",{id:"question",value:a,onChange:S=>l(S.target.value),placeholder:"What happens when a user signs up?","aria-label":"Your question",autoFocus:!0}),g.jsx("button",{className:"btn primary",disabled:d||!a.trim(),children:d?"Starting…":"Map it"})]}),u&&g.jsx("div",{className:"banner banner-dead",role:"alert",children:u}),s.length>0&&g.jsxs("section",{children:[g.jsx("h2",{className:"section-title",children:"Being made now"}),g.jsx("ul",{className:"maplist",children:s.map(S=>g.jsxs("li",{children:[g.jsx("a",{href:sn(S.id),children:S.question}),g.jsxs("span",{className:"muted small",children:[f.name," is exploring…"]})]},S.id))})]}),g.jsxs("section",{children:[g.jsx("h2",{className:"section-title",children:"Maps in this repo"}),r===null?g.jsx("p",{className:"muted",children:"Loading…"}):r.length===0?g.jsx("p",{className:"muted",children:"None yet."}):g.jsx("ul",{className:"maplist",children:r.map(S=>g.jsxs("li",{children:[g.jsx("a",{href:sn(S.id),children:S.question}),g.jsxs("span",{className:"muted small",children:[new Date(S.updatedAt).toLocaleString(),S.commit?` · ${S.commit.slice(0,7)}`:""]})]},S.id))})]}),g.jsx("footer",{className:"home-foot",children:g.jsx(D0,{busy:s.length>0,agentName:f.name,onStopped:e,onError:c})})]})}const pp="illuminate-panel-width",ac=300,F0=400,dA=360,Gl=e=>Math.round(Math.max(ac,Math.min(e,Math.max(ac,window.innerWidth-dA))));function fA(){const[e,t]=T.useState(()=>{const r=Number(localStorage.getItem(pp));return Gl(r>0?r:F0)}),n=T.useCallback(r=>{const o=Gl(r);t(o),localStorage.setItem(pp,String(o))},[]);return T.useEffect(()=>{const r=()=>t(o=>Gl(o));return window.addEventListener("resize",r),()=>window.removeEventListener("resize",r)},[]),[e,n]}function hA({width:e,onWidth:t}){return g.jsx("div",{className:"panel-handle",role:"separator","aria-orientation":"vertical","aria-label":"Panel width","aria-valuenow":e,"aria-valuemin":ac,tabIndex:0,title:"Drag to resize the panel",onPointerDown:n=>{n.preventDefault();const r=n.currentTarget;r.setPointerCapture(n.pointerId),document.body.classList.add("resizing");const o=i=>t(window.innerWidth-i.clientX),s=()=>{r.removeEventListener("pointermove",o),r.removeEventListener("pointerup",s),r.removeEventListener("pointercancel",s),document.body.classList.remove("resizing")};r.addEventListener("pointermove",o),r.addEventListener("pointerup",s),r.addEventListener("pointercancel",s)},onDoubleClick:()=>t(F0),onKeyDown:n=>{n.key==="ArrowLeft"&&(n.preventDefault(),t(e+24)),n.key==="ArrowRight"&&(n.preventDefault(),t(e-24))}})}const pA=(...e)=>e.filter(Boolean).join(" ");function gA({map:e,stop:t,onTour:n,onAsk:r}){var i;const o=e.tour[t];if(!o)return null;const s=t===e.tour.length-1;return g.jsxs("section",{className:"card card-focus tour-bubble","aria-label":"Walkthrough","aria-live":"polite",children:[g.jsx("button",{className:"card-close","aria-label":"Leave the walkthrough",title:"Leave the walkthrough (Esc)",onClick:()=>n(null),children:"×"}),g.jsxs("div",{className:"tour-head",children:[g.jsxs("span",{className:"eyebrow",children:["Walkthrough, stop ",t+1," of ",e.tour.length]}),g.jsx("span",{className:"dots","aria-hidden":"true",children:e.tour.map((a,l)=>g.jsx("i",{className:pA(l===t&&"on",l<t&&"done")},a.id))})]}),g.jsx("h2",{className:"card-title",children:o.title}),g.jsx(_s,{text:o.text,className:"depth-text"}),(i=o.terms)!=null&&i.length?g.jsxs("p",{className:"muted small",children:["Terms: ",o.terms.join(", ")]}):null,g.jsxs("div",{className:"tour-nav",children:[g.jsx("button",{className:"btn",disabled:t===0,onClick:()=>n(t-1),children:"‹ Back"}),r&&g.jsx("button",{className:"btn",onClick:r,children:"Ask about this step"}),g.jsx("span",{className:"grow"}),s?g.jsx("button",{className:"btn primary",onClick:()=>n(null),children:"Done"}):g.jsx("button",{className:"btn primary",onClick:()=>n(t+1),children:"Next ›"})]}),g.jsx("div",{className:"kbd",children:"← → to step, Esc to leave"})]})}function mA(){return yo?g.jsx(yA,{}):g.jsxs("main",{className:"home",children:[g.jsx("h1",{children:"Open illuminate from its link"}),g.jsxs("p",{className:"muted lede",children:["Use the link illuminate printed in your terminal (it ends in ",g.jsx("code",{children:"?t=…"}),")."]})]})}function yA(){const[e,t]=T.useState(!1),n=T.useCallback(()=>{window.close(),t(!0)},[]),r=aA();if(e)return g.jsx(uA,{});const o=/^\/m\/([a-z0-9-]{1,80})\/?$/.exec(r);return o?g.jsx(kA,{mapId:o[1],onStopped:n},o[1]):g.jsx(cA,{onStopped:n})}function vA({mapId:e,question:t,making:n}){const[r,o]=T.useState([]);T.useEffect(()=>{Ht.list().then(i=>o([...i.making.map(a=>({...a,making:!0})),...i.maps.map(a=>({id:a.id,question:a.question}))]),()=>{})},[e,n]);const s=r.some(i=>i.id===e)?r:[{id:e,question:t},...r];return g.jsx("select",{className:"switcher",value:e,onChange:i=>il(sn(i.target.value)),"aria-label":"Switch to another map",title:"Switch to another map in this repo",children:s.map(i=>g.jsxs("option",{value:i.id,children:[i.question||i.id,i.making?" (being made)":""]},i.id))})}function wA({report:e}){if(!e)return null;const t=e.summary.unconfirmed,{pending:n,done:r}=e.summary.proposals??{pending:0,done:0},o=n+r,s=o?g.jsx("span",{className:"map-status proposals",title:"Parts of this map are a proposal, drawn in violet: they aren't in the code yet, or would change or go. illuminate checks the code to see which have been done.",children:r===0?`${o} proposed ${o===1?"change":"changes"}`:`${r} of ${o} proposed changes done`}):null,i=g.jsxs(g.Fragment,{children:[s,g.jsx(xA,{report:e})]});return t?g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"map-status off",title:"Every time the map is shown, illuminate re-checks it against the code. These parts no longer hold, usually because the code changed after the map was made. They're dashed and marked ? on the map; click one to see why.",children:t===1?"1 part of this map doesn’t match the code":`${t} parts of this map don’t match the code`}),i]}):g.jsxs(g.Fragment,{children:[g.jsx("span",{className:"map-status ok",title:"Every box and arrow on this map was just re-checked and is really in the code, and every gap's search still finds nothing. That shows each part is real; it doesn't show the map covers everything.",children:"✓ Every part is in the code"}),i]})}function xA({report:e}){const t=e.since;if(!t)return null;if(!t.commit)return g.jsx("span",{className:"map-status off",title:`This map compares the code with "${t.ref}", but that isn't a commit in this repo, so nothing could be compared.`,children:"Can’t find the commit this map compares with"});const{added:n,changed:r,removed:o}=e.summary.changes??{added:0,changed:0,removed:0},s=t.date?new Date(t.date).toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit"}):null,i=[n&&`${n} added`,r&&`${r} changed`,o&&`${o} removed`].filter(Boolean).join(" · ");return g.jsxs("span",{className:"map-status changes",title:`This map shows the code as it is now, compared with commit ${t.commit.slice(0,7)}${t.subject?` ("${t.subject}")`:""}. illuminate works out from the two versions which boxes and arrows are new, different or gone. It can't tell who made a change.`,children:["Changes since ",t.commit.slice(0,7),s?` (${s})`:"",i?`: ${i}`:": nothing on this map differs"]})}function kA({mapId:e,onStopped:t}){var O,j,M,I,z,H,ne,Q;const[n,r]=T.useReducer(v2,e,h2),[o,s]=T.useState(""),[i,a]=fA(),l=T.useRef(!1),u=T.useCallback(()=>{Ht.get(e).then(U=>r({type:"loaded",payload:U}),U=>r(U instanceof x0&&/No such map/.test(U.message)?{type:"missing"}:{type:"error",message:U.message}))},[e]);T.useEffect(u,[u]),T.useEffect(()=>k0(U=>r({type:"event",event:U}),U=>{r({type:"connected",value:U}),U&&l.current===!1&&n.phase!=="loading"&&u(),l.current=U},t,e),[]);const c=n.map&&n.tour!==null?((O=n.map.tour[n.tour])==null?void 0:O.title)??null:null;T.useEffect(()=>{const U=n.phase==="ready"?yC(n.agent,n.selection,c):null;if(!U)return;const J=setTimeout(()=>void Ht.selection(e,U.selection,U.step).catch(()=>{}),250);return()=>clearTimeout(J)},[e,n.phase,n.agent,n.selection,c]);const d=nl(n.agent),[h,f]=T.useState(null);T.useEffect(()=>f(null),[n.tour]);const v=n.map&&n.tour!==null&&h===n.tour?((j=n.map.tour[n.tour])==null?void 0:j.title)??null:null,x=T.useCallback(U=>{const J=U.trim();if(!J||n.job)return;const ee=v?FC(v,J):J;Ht.ask(e,ee,n.selection).then(()=>s(""),C=>r({type:"error",message:C.message}))},[e,n.job,n.selection,v]),S=(U,J)=>{J==="approve"&&r({type:"fixStatus",fixId:U,status:"applying",problems:[]}),Ht[J](e,U).catch(ee=>{r(J==="approve"?{type:"fixStatus",fixId:U,status:"failed",problems:ee.problems.length?ee.problems:[ee.message]}:{type:"error",message:[ee.message,...ee.problems].join(" ")})})},y=(U,J)=>{Ht.offer(e,U,J).then(ee=>{ee.id&&il(sn(ee.id))},ee=>r({type:"error",message:ee.message}))};T.useEffect(()=>{const U=J=>{const ee=J.target instanceof HTMLTextAreaElement||J.target instanceof HTMLInputElement;if(J.key==="Escape"){zo(n.selection)?r({type:"clearSelection"}):n.tour!==null&&n.peek?r({type:"peek",open:!1}):n.tour!==null?r({type:"tour",stop:null}):r({type:"overview"});return}ee||n.tour===null||(J.key==="ArrowRight"&&r({type:"tour",stop:n.tour+1}),J.key==="ArrowLeft"&&r({type:"tour",stop:n.tour-1}))};return window.addEventListener("keydown",U),()=>window.removeEventListener("keydown",U)},[n.tour,n.peek,n.selection]);const m=n.answers.find(U=>U.id===n.shown),p=m!=null&&m.fix&&["proposed","applying","failed"].includes(((M=n.fixes[m.fix.id])==null?void 0:M.status)??"")?m.fix:null,w=T.useCallback((U,J,ee)=>r({type:"select",kind:U,id:J,additive:ee}),[]),b=T.useCallback(()=>r({type:"clearSelection"}),[]),k=$0(n),E=g2(n),_=p2(n),A=!!n.map&&n.tour!==null,L=T.useMemo(()=>({...n,answers:wC(n.agent,n.answers,n.fixes)}),[n]),$=n.shown!==null&&L.answers.some(U=>U.id===n.shown),F=((I=n.job)==null?void 0:I.kind)==="ask"&&!d,N=(!n.map||!!n.error||!!n.job&&(n.job.kind==="make"||F)||$)&&(!A||n.peek||!!n.error||F),P=N&&!!n.map,R=n.map&&d?g.jsx(j2,{map:n.map,agent:n.agent,selection:n.selection,step:c,onRemove:(U,J)=>r({type:"select",kind:U,id:J,additive:!0})}):n.map?g.jsx(M2,{map:n.map,selection:n.selection,draft:o,busy:!!n.job,agentName:n.agent.name,autoFocus:P,onDraft:s,onRemove:(U,J)=>r({type:"select",kind:U,id:J,additive:!0}),step:v,onRemoveStep:()=>f(null),onSend:()=>x(o)}):null;return g.jsx(m0,{children:g.jsxs("div",{className:"app",children:[g.jsxs("header",{className:"topbar",children:[g.jsxs("a",{className:"brand",href:sn(),title:"All maps in this repo",children:[g.jsx("i",{className:"brand-mark","aria-hidden":"true"}),"illuminate"]}),g.jsxs("div",{className:"topbar-map",children:[((z=n.meta)==null?void 0:z.parent)&&g.jsxs("a",{className:"crumb",href:sn(n.meta.parent.mapId),title:`Back to the map this one came from: ${n.meta.parent.question}`,children:["← ",n.meta.parent.question]}),g.jsx(vA,{mapId:e,question:((H=n.map)==null?void 0:H.question)??((ne=n.job)==null?void 0:ne.question)??"",making:((Q=n.job)==null?void 0:Q.kind)==="make"})]}),g.jsx(wA,{report:n.report}),g.jsx("a",{className:"pill-btn",href:sn(),title:"Ask a new question and make a map for it",children:"New map"}),g.jsx(D0,{busy:!!n.job,agentName:n.agent.name,onStopped:t,onError:U=>r({type:"error",message:U})}),g.jsx("span",{className:n.connected?"live on":"live",title:n.connected?"Connected to illuminate":"Reconnecting to illuminate…"})]}),g.jsxs("div",{className:N?"body":"body full",style:{"--panel-w":`${i}px`},children:[g.jsx("div",{className:"canvas",children:n.map&&k?g.jsxs(g.Fragment,{children:[g.jsx(iA,{map:k,report:n.report,selection:n.selection,view:_,fresh:n.fresh,added:E,ghost:p??null,touring:A,onSelect:w,onClear:b}),!N&&g.jsx(L2,{state:L,dispatch:r}),zo(n.selection)>0&&g.jsx(z2,{mapId:e,map:k,report:n.report,selection:n.selection,onClose:b}),A&&zo(n.selection)===0&&g.jsx(gA,{map:n.map,stop:n.tour,onTour:U=>r({type:"tour",stop:U}),onAsk:d?void 0:()=>{var U;f(n.tour),(U=document.getElementById("ask"))==null||U.focus()}}),g.jsx(R2,{map:n.map,mapId:e,tour:n.tour,onTour:U=>r({type:"tour",stop:U}),selected:zo(n.selection),children:P?null:R})]}):g.jsx("div",{className:"empty",children:n.phase==="making"?g.jsxs("div",{className:"pulse",children:[n.agent.name," is exploring the code…"]}):null})}),N&&g.jsx(hA,{width:i,onWidth:a}),N&&g.jsx(b2,{state:L,dispatch:r,onFix:S,onFocus:U=>r({type:"focus",id:U}),onOffer:y,composer:P?R:null})]})]})})}Am(document.getElementById("root")).render(g.jsx(T.StrictMode,{children:g.jsx(mA,{})}));export{$d as c,lc as g};
|
|
82
|
+
//# sourceMappingURL=index-6Ek7tR19.js.map
|