From 37184bedb61ceba2483610e551afa8d41e58d4ae Mon Sep 17 00:00:00 2001 From: Jason Robert Date: Mon, 3 Aug 2026 17:16:01 -0400 Subject: [PATCH] fix(web): resolve inline-expanded subworkflow to newest invocation on loop-back MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dashboard's inline-expanded subworkflow view resolved a repeated slotKey child SubworkflowContext via Array.prototype.findIndex, which returns the first (oldest) match. When a loop-back route re-invokes the same sequential subworkflow, the engine/store correctly appends a new sibling context, but the inline view kept pinning its childContextKey to the stale, already-completed first invocation instead of the live one — even though double-click navigation and the Activity tab correctly tracked the live run. Fix both affected call sites in graph-layout.ts (collectExpandableContextKeys and layoutContext's inline-expand branch for type: workflow steps) to match newest-first, mirroring the existing convention already used elsewhere (workflow-store.ts::findChildContext/resolveSlotPath, issue #145; and hooks/use-deep-link.ts::resolveSubworkflowPath). Adds regression tests simulating a subworkflow that completes once and is then re-invoked via a loop-back route, verifying both fixed call sites resolve to the newest (live) context rather than the stale completed one. Fixes #361 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .../src/components/graph/graph-layout.test.ts | 125 ++++++++++++++++++ .../src/components/graph/graph-layout.ts | 24 +++- .../{index-DT3gmBmg.js => index-CZ10hUnS.js} | 2 +- src/conductor/web/static/index.html | 2 +- 4 files changed, 148 insertions(+), 5 deletions(-) rename src/conductor/web/static/assets/{index-DT3gmBmg.js => index-CZ10hUnS.js} (91%) diff --git a/src/conductor/web/frontend/src/components/graph/graph-layout.test.ts b/src/conductor/web/frontend/src/components/graph/graph-layout.test.ts index 3dc8a334..ab730fc1 100644 --- a/src/conductor/web/frontend/src/components/graph/graph-layout.test.ts +++ b/src/conductor/web/frontend/src/components/graph/graph-layout.test.ts @@ -159,6 +159,91 @@ function seedNestedSubworkflows(): void { ); } +/** + * Reproduces a loop-back re-invocation of the same sequential subworkflow + * (issue #361): `sub_agent` runs to completion once, then a route sends + * execution back through it a second time. This produces two sibling + * `SubworkflowContext`s sharing `slotKey: 'sub_agent'` — index 0 (completed) + * and index 1 (running) — so slot-key resolution must pick the newest + * (index 1), not the first, match. + */ +function seedRootWithLoopedBackSubworkflow(): void { + const { processEvent } = useWorkflowStore.getState(); + + processEvent( + event('workflow_started', { + name: 'root', + agents: [{ name: 'planner' }, { name: 'sub_agent', type: 'workflow' }], + routes: [ + { from: 'planner', to: 'sub_agent' }, + { from: 'sub_agent', to: '$end' }, + ], + parallel_groups: [], + for_each_groups: [], + entry_point: 'planner', + }), + ); + + // First invocation: starts, runs, completes. + processEvent( + event('subworkflow_started', { + agent_name: 'sub_agent', + workflow: 'sub.yaml', + iteration: 1, + slot_key: 'sub_agent', + parent_path: [], + }), + ); + processEvent( + event('workflow_started', { + name: 'child-workflow', + agents: [{ name: 'childA' }], + routes: [{ from: 'childA', to: '$end' }], + parallel_groups: [], + for_each_groups: [], + entry_point: 'childA', + subworkflow_path: ['sub_agent'], + }), + ); + processEvent( + event('workflow_completed', { + output: {}, + subworkflow_path: ['sub_agent'], + }), + ); + processEvent( + event('subworkflow_completed', { + agent_name: 'sub_agent', + elapsed: 1.0, + parent_path: [], + }), + ); + + // Loop-back: a route sends execution through `sub_agent` a second time, + // creating a new sibling context with the same slotKey. + processEvent( + event('subworkflow_started', { + agent_name: 'sub_agent', + workflow: 'sub.yaml', + iteration: 2, + slot_key: 'sub_agent', + parent_path: [], + }), + ); + processEvent( + event('workflow_started', { + name: 'child-workflow', + agents: [{ name: 'childA' }], + routes: [{ from: 'childA', to: '$end' }], + parallel_groups: [], + for_each_groups: [], + entry_point: 'childA', + subworkflow_path: ['sub_agent'], + }), + ); + processEvent(event('agent_started', { agent_name: 'childA', iteration: 1, subworkflow_path: ['sub_agent'] })); +} + /** * Dispatch a root workflow with a `for_each`-of-workflow group (`batch`) that * has fanned out into `count` started iterations, each its own child @@ -508,6 +593,36 @@ describe('buildGraphElements — inline subworkflow expansion', () => { expect(ingress?.type).toBe('ingressNode'); expect(ingress?.data.parentAgent).toBe('sub_agent'); }); + + it('tracks the newest invocation after a loop-back re-invocation (issue #361)', () => { + seedRootWithLoopedBackSubworkflow(); + const s = useWorkflowStore.getState(); + expect(s.subworkflowContexts).toHaveLength(2); + expect(s.subworkflowContexts[0]!.status).toBe('completed'); + expect(s.subworkflowContexts[1]!.status).toBe('running'); + + // Collapsed: childContextKey must point at the live (index 1) context, + // not the stale completed (index 0) one. The pill's own status (sourced + // from ctx.nodes['sub_agent'], separate from childContextKey resolution) + // should agree that the subworkflow is live. + const collapsed = buildGraphElements(rootBase(), [], new Set()); + const wfCollapsed = collapsed.nodes.find((n) => n.id === nodeKey([], 'sub_agent')); + expect(wfCollapsed!.data.childContextKey).toBe(contextKey([1])); + expect(wfCollapsed!.data.status).toBe('running'); + + // Expanded: the inline child DAG embeds the newest (running) context's + // agents, not the stale first invocation. + const expanded = new Set([contextKey([1])]); + const { nodes } = buildGraphElements(rootBase(), [], expanded); + const container = nodes.find((n) => n.id === nodeKey([], 'sub_agent')); + expect(container!.data.expanded).toBe(true); + const childA = nodes.find((n) => n.id === nodeKey([1], 'childA')); + expect(childA).toBeDefined(); + expect(childA!.data.contextPath).toEqual([1]); + expect(childA!.data.status).toBe('running'); + // The stale first invocation's nodes are not rendered inline. + expect(nodes.some((n) => n.id === nodeKey([0], 'childA'))).toBe(false); + }); }); describe('collectExpandableContextKeys', () => { @@ -578,6 +693,16 @@ describe('collectExpandableContextKeys', () => { contextKey([0, 0]), ]); }); + + it('resolves to the newest context after a loop-back re-invocation (issue #361)', () => { + seedRootWithLoopedBackSubworkflow(); + const s = useWorkflowStore.getState(); + expect(s.subworkflowContexts).toHaveLength(2); + // Must key off index 1 (the live re-invocation), not index 0 (stale). + expect(collectExpandableContextKeys(s.agents, s.subworkflowContexts, [])).toEqual([ + contextKey([1]), + ]); + }); }); describe('expansionKeysForContextPath', () => { diff --git a/src/conductor/web/frontend/src/components/graph/graph-layout.ts b/src/conductor/web/frontend/src/components/graph/graph-layout.ts index 6e0e9c43..dc953a3a 100644 --- a/src/conductor/web/frontend/src/components/graph/graph-layout.ts +++ b/src/conductor/web/frontend/src/components/graph/graph-layout.ts @@ -145,7 +145,15 @@ export function collectExpandableContextKeys( ): void => { for (const a of ctxAgents) { if ((a.type || 'agent') !== 'workflow') continue; - const childIdx = ctxChildren.findIndex((c) => c.slotKey === a.name); + // Match newest-first: a loop-back route can re-invoke the same + // subworkflow, appending another child with the same slotKey (issue #361). + let childIdx = -1; + for (let i = ctxChildren.length - 1; i >= 0; i--) { + if (ctxChildren[i]!.slotKey === a.name) { + childIdx = i; + break; + } + } if (childIdx < 0) continue; const child = ctxChildren[childIdx]!; if (child.agents.length === 0) continue; @@ -489,8 +497,18 @@ function layoutContext( if (nodeType === 'workflow') { // Sequential subworkflow: slotKey === agent name. Locate its child // context so the node can advertise a stable expansion key and, when - // expanded, render the child DAG inline as a container. - const childIdx = ctx.children.findIndex((c) => c.slotKey === a.name); + // expanded, render the child DAG inline as a container. Match + // newest-first: a loop-back route can re-invoke the same subworkflow, + // appending a sibling child with the same slotKey (issue #361) — same + // precedent as findChildContext/resolveSlotPath (workflow-store.ts) and + // resolveSubworkflowPath (use-deep-link.ts), issue #145. + let childIdx = -1; + for (let i = ctx.children.length - 1; i >= 0; i--) { + if (ctx.children[i]!.slotKey === a.name) { + childIdx = i; + break; + } + } const child = childIdx >= 0 ? ctx.children[childIdx] : undefined; const childKey = childIdx >= 0 ? contextKey([...absPath, childIdx]) : undefined; const canExpand = !!child && child.agents.length > 0; diff --git a/src/conductor/web/static/assets/index-DT3gmBmg.js b/src/conductor/web/static/assets/index-CZ10hUnS.js similarity index 91% rename from src/conductor/web/static/assets/index-DT3gmBmg.js rename to src/conductor/web/static/assets/index-CZ10hUnS.js index da4cb9e4..19e46fe1 100644 --- a/src/conductor/web/static/assets/index-DT3gmBmg.js +++ b/src/conductor/web/static/assets/index-CZ10hUnS.js @@ -53,7 +53,7 @@ Error generating stack: `+e.message+` `,` +`).split(` `));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,v.useEffect)(()=>{let n=t?.target??gf,c=t?.actInsideInputWithModifier??!0;if(e!==null){let e=e=>{if(i.current=e.ctrlKey||e.metaKey||e.shiftKey||e.altKey,(!i.current||i.current&&!c)&&Gl(e))return!1;let n=yf(e.code,s);if(a.current.add(e[n]),vf(o,a.current,!1)){let n=e.composedPath?.()?.[0]||e.target,a=n?.nodeName===`BUTTON`||n?.nodeName===`A`;t.preventDefault!==!1&&(i.current||!a)&&e.preventDefault(),r(!0)}},l=e=>{let t=yf(e.code,s);vf(o,a.current,!0)?(r(!1),a.current.clear()):a.current.delete(e[t]),e.key===`Meta`&&a.current.clear(),i.current=!1},u=()=>{a.current.clear(),r(!1)};return n?.addEventListener(`keydown`,e),n?.addEventListener(`keyup`,l),window.addEventListener(`blur`,u),window.addEventListener(`contextmenu`,u),()=>{n?.removeEventListener(`keydown`,e),n?.removeEventListener(`keyup`,l),window.removeEventListener(`blur`,u),window.removeEventListener(`contextmenu`,u)}}},[e,r]),n}function vf(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function yf(e,t){return t.includes(e)?`code`:`key`}var bf=()=>{let e=Ud();return(0,v.useMemo)(()=>({zoomIn:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomOut:t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,{duration:t?.duration}):Promise.resolve(!1)},zoomTo:(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,{duration:n?.duration}):Promise.resolve(!1)},getZoom:()=>e.getState().transform[2],setViewport:async(t,n)=>{let{transform:[r,i,a],panZoom:o}=e.getState();return o?(await o.setViewport({x:t.x??r,y:t.y??i,zoom:t.zoom??a},n),Promise.resolve(!0)):Promise.resolve(!1)},getViewport:()=>{let[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)=>{let{width:r,height:i,minZoom:a,maxZoom:o,panZoom:s}=e.getState(),c=Nl(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)):Promise.resolve(!1)},screenToFlowPosition:(t,n={})=>{let{transform:r,snapGrid:i,snapToGrid:a,domNode:o}=e.getState();if(!o)return t;let{x:s,y:c}=o.getBoundingClientRect(),l={x:t.x-s,y:t.y-c},u=n.snapGrid??i;return Ol(l,r,n.snapToGrid??a,u)},flowToScreenPosition:t=>{let{transform:n,domNode:r}=e.getState();if(!r)return t;let{x:i,y:a}=r.getBoundingClientRect(),o=kl(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function xf(e,t){let n=[],r=new Map,i=[];for(let t of e)if(t.type===`add`){i.push(t);continue}else if(t.type===`remove`||t.type===`replace`)r.set(t.id,[t]);else{let e=r.get(t.id);e?e.push(t):r.set(t.id,[t])}for(let e of t){let t=r.get(e.id);if(!t){n.push(e);continue}if(t[0].type===`remove`)continue;if(t[0].type===`replace`){n.push({...t[0].item});continue}let i={...e};for(let e of t)Sf(e,i);n.push(i)}return i.length&&i.forEach(e=>{e.index===void 0?n.push({...e.item}):n.splice(e.index,0,{...e.item})}),n}function Sf(e,t){switch(e.type){case`select`:t.selected=e.selected;break;case`position`:e.position!==void 0&&(t.position=e.position),e.dragging!==void 0&&(t.dragging=e.dragging);break;case`dimensions`:e.dimensions!==void 0&&(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 Cf(e,t){return xf(e,t)}function wf(e,t){return xf(e,t)}function Tf(e,t){return{id:e,type:`select`,selected:t}}function Ef(e,t=new Set,n=!1){let r=[];for(let[i,a]of e){let e=t.has(i);!(a.selected===void 0&&!e)&&a.selected!==e&&(n&&(a.selected=e),r.push(Tf(a.id,e)))}return r}function Df({items:e=[],lookup:t}){let n=[],r=new Map(e.map(e=>[e.id,e]));for(let[r,i]of e.entries()){let e=t.get(i.id),a=e?.internals?.userNode??e;a!==void 0&&a!==i&&n.push({id:i.id,item:i,type:`replace`}),a===void 0&&n.push({item:i,type:`add`,index:r})}for(let[e]of t)r.get(e)===void 0&&n.push({id:e,type:`remove`});return n}function Of(e){return{id:e.id,type:`remove`}}var kf=e=>tl(e),Af=e=>el(e);function jf(e){return(0,v.forwardRef)(e)}var Mf=typeof window<`u`?v.useLayoutEffect:v.useEffect;function Nf(e){let[t,n]=(0,v.useState)(BigInt(0)),[r]=(0,v.useState)(()=>Pf(()=>n(e=>e+BigInt(1))));return Mf(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function Pf(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var Ff=(0,v.createContext)(null);function If({children:e}){let t=Ud(),n=Nf((0,v.useCallback)(e=>{let{nodes:n=[],setNodes:r,hasDefaultNodes:i,onNodesChange:a,nodeLookup:o,fitViewQueued:s,onNodesChangeMiddlewareMap:c}=t.getState(),l=n;for(let t of e)l=typeof t==`function`?t(l):t;let u=Df({items:l,lookup:o});for(let e of c.values())u=e(u);i&&r(l),u.length>0?a?.(u):s&&window.requestAnimationFrame(()=>{let{fitViewQueued:e,nodes:n,setNodes:r}=t.getState();e&&r(n)})},[])),r=Nf((0,v.useCallback)(e=>{let{edges:n=[],setEdges:r,hasDefaultEdges:i,onEdgesChange:a,edgeLookup:o}=t.getState(),s=n;for(let t of e)s=typeof t==`function`?t(s):t;i?r(s):a&&a(Df({items:s,lookup:o}))},[])),i=(0,v.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,H.jsx)(Ff.Provider,{value:i,children:e})}function Lf(){let e=(0,v.useContext)(Ff);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var Rf=e=>!!e.panZoom;function zf(){let e=bf(),t=Ud(),n=Lf(),r=Y(Rf),i=(0,v.useMemo)(()=>{let e=e=>t.getState().nodeLookup.get(e),r=e=>{n.nodeQueue.push(e)},i=e=>{n.edgeQueue.push(e)},a=e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState(),i=kf(e)?e:n.get(e.id),a=i.parentId?Rl(i.position,i.measured,i.parentId,n,r):i.position;return bl({...i,position:a,width:i.measured?.width??i.width,height:i.measured?.height??i.height})},o=(e,t,n={replace:!1})=>{r(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&kf(e)?e:{...r,...e}}return r}))},s=(e,t,n={replace:!1})=>{i(r=>r.map(r=>{if(r.id===e){let e=typeof t==`function`?t(r):t;return n.replace&&Af(e)?e:{...r,...e}}return r}))};return{getNodes:()=>t.getState().nodes.map(e=>({...e})),getNode:t=>e(t)?.internals.userNode,getInternalNode:e,getEdges:()=>{let{edges:e=[]}=t.getState();return e.map(e=>({...e}))},getEdge:e=>t.getState().edgeLookup.get(e),setNodes:r,setEdges:i,addNodes:e=>{let t=Array.isArray(e)?e:[e];n.nodeQueue.push(e=>[...e,...t])},addEdges:e=>{let t=Array.isArray(e)?e:[e];n.edgeQueue.push(e=>[...e,...t])},toObject:()=>{let{nodes:e=[],edges:n=[],transform:r}=t.getState(),[i,a,o]=r;return{nodes:e.map(e=>({...e})),edges:n.map(e=>({...e})),viewport:{x:i,y:a,zoom:o}}},deleteElements:async({nodes:e=[],edges:n=[]})=>{let{nodes:r,edges:i,onNodesDelete:a,onEdgesDelete:o,triggerNodeChanges:s,triggerEdgeChanges:c,onDelete:l,onBeforeDelete:u}=t.getState(),{nodes:d,edges:f}=await dl({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(Of);o?.(f),c(e)}if(m){let e=d.map(Of);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=wl(e),o=i?e:a(e),s=r!==void 0;return o?(r||t.getState().nodes).filter(r=>{let a=t.getState().nodeLookup.get(r.id);if(a&&!i&&(r.id===e.id||!a.internals.positionAbsolute))return!1;let c=bl(s?r:a),l=Cl(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=wl(e)?e:a(e);if(!r)return!1;let i=Cl(r,t);return n&&i>0||i>=t.width*t.height||i>=r.width*r.height},updateNode:o,updateNodeData:(e,t,n={replace:!1})=>{o(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},updateEdge:s,updateEdgeData:(e,t,n={replace:!1})=>{s(e,e=>{let r=typeof t==`function`?t(e):t;return n.replace?{...e,data:r}:{...e,data:{...e.data,...r}}},n)},getNodesBounds:e=>{let{nodeLookup:n,nodeOrigin:r}=t.getState();return il(e,{nodeLookup:n,nodeOrigin:r})},getHandleConnections:({type:e,id:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}-${e}${n?`-${n}`:``}`)?.values()??[]),getNodeConnections:({type:e,handleId:n,nodeId:r})=>Array.from(t.getState().connectionLookup.get(`${r}${e?n?`-${e}-${n}`:`-${e}`:``}`)?.values()??[]),fitView:async e=>{let r=t.getState().fitViewResolver??q();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,v.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var Bf=e=>e.selected,Vf=typeof window<`u`?window:void 0;function Hf({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=Ud(),{deleteElements:r}=zf(),i=_f(e,{actInsideInputWithModifier:!1}),a=_f(t,{target:Vf});(0,v.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(Bf),edges:e.filter(Bf)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,v.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function Uf(e){let t=Ud();(0,v.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=Hl(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,Hc.error004()),t.setState({width:n.width||500,height:n.height||500})};if(e.current){n(),window.addEventListener(`resize`,n);let t=new ResizeObserver(()=>n());return t.observe(e.current),()=>{window.removeEventListener(`resize`,n),t&&e.current&&t.unobserve(e.current)}}},[])}var Wf={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},Gf=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function Kf({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=qc.Free,zoomOnDoubleClick:o=!0,panOnDrag:s=!0,defaultViewport:c,translateExtent:l,minZoom:u,maxZoom:d,zoomActivationKeyCode:f,preventScrolling:p=!0,children:m,noWheelClassName:h,noPanClassName:g,onViewportChange:_,isControlledViewport:y,paneClickDistance:b,selectionOnDrag:x}){let S=Ud(),C=(0,v.useRef)(null),{userSelectionActive:w,lib:T,connectionInProgress:E}=Y(Gf,Rd),D=_f(f),O=(0,v.useRef)();Uf(C);let k=(0,v.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),y||S.setState({transform:e})},[_,y]);return(0,v.useEffect)(()=>{if(C.current){O.current=pd({domNode:C.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>S.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=S.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=S.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=S.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=O.current.getViewport();return S.setState({panZoom:O.current,transform:[e,t,n],domNode:C.current.closest(`.react-flow`)}),()=>{O.current?.destroy()}}},[]),(0,v.useEffect)(()=>{O.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:D,preventScrolling:p,noPanClassName:g,userSelectionActive:w,noWheelClassName:h,lib:T,onTransformChange:k,connectionInProgress:E,selectionOnDrag:x,paneClickDistance:b})},[e,t,n,r,i,a,o,s,D,p,g,w,h,T,k,E,x,b]),(0,H.jsx)(`div`,{className:`react-flow__renderer`,ref:C,style:Wf,children:m})}var qf=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function Jf(){let{userSelectionActive:e,userSelectionRect:t}=Y(qf,Rd);return e&&t?(0,H.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var Yf=(e,t)=>n=>{n.target===t.current&&e?.(n)},Xf=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,connectionInProgress:e.connection.inProgress,dragging:e.paneDragging});function Zf({isSelecting:e,selectionKeyPressed:t,selectionMode:n=Jc.Full,panOnDrag:r,paneClickDistance:i,selectionOnDrag:a,onSelectionStart:o,onSelectionEnd:s,onPaneClick:c,onPaneContextMenu:l,onPaneScroll:u,onPaneMouseEnter:d,onPaneMouseMove:f,onPaneMouseLeave:p,children:m}){let h=Ud(),{userSelectionActive:g,elementsSelectable:_,dragging:y,connectionInProgress:b}=Y(Xf,Rd),x=_&&(e||g),S=(0,v.useRef)(null),C=(0,v.useRef)(),w=(0,v.useRef)(new Set),T=(0,v.useRef)(new Set),E=(0,v.useRef)(!1),D=e=>{if(E.current||b){E.current=!1;return}c?.(e),h.getState().resetSelectedElements(),h.setState({nodesSelectionActive:!1})},O=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}l?.(e)},k=u?e=>u(e):void 0;return(0,H.jsxs)(`div`,{className:ir([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:y,selection:e}]),onClick:x?void 0:Yf(D,S),onContextMenu:Yf(O,S),onWheel:Yf(k,S),onPointerEnter:x?void 0:d,onPointerMove:x?e=>{let{userSelectionRect:r,transform:a,nodeLookup:s,edgeLookup:c,connectionLookup:l,triggerNodeChanges:u,triggerEdgeChanges:d,defaultEdgeOptions:f,resetSelectedElements:p}=h.getState();if(!C.current||!r)return;let{x:m,y:g}=ql(e.nativeEvent,C.current),{startX:_,startY:v}=r;if(!E.current){let n=t?0:i;if(Math.hypot(m-_,g-v)<=n)return;p(),o?.(e)}E.current=!0;let y={startX:_,startY:v,x:m<_?m:_,y:ge.id)),T.current=new Set;let S=f?.selectable??!0;for(let e of w.current){let t=l.get(e);if(t)for(let{edgeId:e}of t.values()){let t=c.get(e);t&&(t.selectable??S)&&T.current.add(e)}}zl(b,w.current)||u(Ef(s,w.current,!0)),zl(x,T.current)||d(Ef(c,T.current)),h.setState({userSelectionRect:y,userSelectionActive:!0,nodesSelectionActive:!1})}:f,onPointerUp:x?e=>{e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!g&&e.target===S.current&&h.getState().userSelectionRect&&D?.(e),h.setState({userSelectionActive:!1,userSelectionRect:null}),E.current&&(s?.(e),h.setState({nodesSelectionActive:w.current.size>0})))}:void 0,onPointerDownCapture:x?n=>{let{domNode:r}=h.getState();if(C.current=r?.getBoundingClientRect(),!C.current)return;let i=n.target===S.current;if(!i&&n.target.closest(`.nokey`)||!e||!(a&&i||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),E.current=!1;let{x:o,y:s}=ql(n.nativeEvent,C.current);h.setState({userSelectionRect:{width:0,height:0,startX:o,startY:s,x:o,y:s}}),i||(n.stopPropagation(),n.preventDefault())}:void 0,onClickCapture:x?e=>{E.current&&=(e.stopPropagation(),!1)}:void 0,onPointerLeave:p,ref:S,style:Wf,children:[m,(0,H.jsx)(Jf,{})]})}function Qf({id:e,store:t,unselect:n=!1,nodeRef:r}){let{addSelectedNodes:i,unselectNodesAndEdges:a,multiSelectionActive:o,nodeLookup:s,onError:c}=t.getState(),l=s.get(e);if(!l){c?.(`012`,Hc.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function $f({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=Ud(),[c,l]=(0,v.useState)(!1),u=(0,v.useRef)();return(0,v.useEffect)(()=>{u.current=Hu({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{Qf({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}})},[]),(0,v.useEffect)(()=>{if(!(t||!e.current||!u.current))return u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o}),()=>{u.current?.destroy()}},[n,r,t,a,e,i,o]),c}var ep=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function tp(){let e=Ud();return(0,v.useCallback)(t=>{let{nodeExtent:n,snapToGrid:r,snapGrid:i,nodesDraggable:a,onError:o,updateNodePositions:s,nodeLookup:c,nodeOrigin:l}=e.getState(),u=new Map,d=ep(a),f=r?i[0]:5,p=r?i[1]:5,m=t.direction.x*f*t.factor,h=t.direction.y*p*t.factor;for(let[,e]of c){if(!d(e))continue;let t={x:e.internals.positionAbsolute.x+m,y:e.internals.positionAbsolute.y+h};r&&(t=Dl(t,i));let{position:a,positionAbsolute:s}=ul({nodeId:e.id,nextPosition:t,nodeLookup:c,nodeExtent:n,nodeOrigin:l,onError:o});e.position=a,e.internals.positionAbsolute=s,u.set(e.id,e)}s(u)},[])}var np=(0,v.createContext)(null),rp=np.Provider;np.Consumer;var ip=()=>(0,v.useContext)(np),ap=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),op=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o,u=c?.nodeId===e&&c?.id===t&&c?.type===n;return{connectingFrom:s?.nodeId===e&&s?.id===t&&s?.type===n,connectingTo:u,clickConnecting:i?.nodeId===e&&i?.id===t&&i?.type===n,isPossibleEndHandle:a===Kc.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function sp({type:e=`source`,position:t=K.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:i=!0,isConnectableEnd:a=!0,id:o,onConnect:s,children:c,className:l,onMouseDown:u,onTouchStart:d,...f},p){let m=o||null,h=e===`target`,g=Ud(),_=ip(),{connectOnClick:v,noPanClassName:y,rfId:b}=Y(ap,Rd),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=Y(op(_,m,e),Rd);_||g.getState().onError?.(`010`,Hc.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t}=g.getState();t(iu(i,e))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=Kl(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();Qu.onPointerDown(e.nativeEvent,{handleDomNode:e.currentTarget,autoPanOnConnect:t.autoPanOnConnect,connectionMode:t.connectionMode,connectionRadius:t.connectionRadius,domNode:t.domNode,nodeLookup:t.nodeLookup,lib:t.lib,isTarget:h,handleId:m,nodeId:_,flowId:t.rfId,panBy:t.panBy,cancelConnection:t.cancelConnection,onConnectStart:t.onConnectStart,onConnectEnd:(...e)=>g.getState().onConnectEnd?.(...e),updateConnection:t.updateConnection,onConnect:O,isValidConnection:n||((...e)=>g.getState().isValidConnection?.(...e)??!0),getTransform:()=>g.getState().transform,getFromHandle:()=>g.getState().connection.fromHandle,autoPanSpeed:t.autoPanSpeed,dragThreshold:t.connectionDragThreshold})}t?u?.(e):d?.(e)};return(0,H.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:ir([`react-flow__handle`,`react-flow__handle-${t}`,`nodrag`,y,l,{source:!h,target:h,connectable:r,connectablestart:i,connectableend:a,clickconnecting:C,connectingfrom:x,connectingto:S,valid:D,connectionindicator:r&&(!T||w)&&(T||E?a:i)}]),onMouseDown:k,onTouchStart:k,onClick:v?t=>{let{onClickConnectStart:r,onClickConnectEnd:a,connectionClickStartHandle:o,connectionMode:s,isValidConnection:c,lib:l,rfId:u,nodeLookup:d,connection:f}=g.getState();if(!_||!o&&!i)return;if(!o){r?.(t.nativeEvent,{nodeId:_,handleId:m,handleType:e}),g.setState({connectionClickStartHandle:{nodeId:_,type:e,id:m}});return}let p=Ul(t.target),h=n||c,{connection:v,isValid:y}=Qu.isValid(t.nativeEvent,{handle:{nodeId:_,id:m,type:e},connectionMode:s,fromNodeId:o.nodeId,fromHandleId:o.id||null,fromType:o.type,isValidConnection:h,flowId:u,doc:p,lib:l,nodeLookup:d});y&&v&&O(v);let b=structuredClone(f);delete b.inProgress,b.toPosition=b.toHandle?b.toHandle.position:null,a?.(t,b),g.setState({connectionClickStartHandle:null})}:void 0,ref:p,...f,children:c})}var cp=(0,v.memo)(jf(sp));function lp({data:e,isConnectable:t,sourcePosition:n=K.Bottom}){return(0,H.jsxs)(H.Fragment,{children:[e?.label,(0,H.jsx)(cp,{type:`source`,position:n,isConnectable:t})]})}function up({data:e,isConnectable:t,targetPosition:n=K.Top,sourcePosition:r=K.Bottom}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:n,isConnectable:t}),e?.label,(0,H.jsx)(cp,{type:`source`,position:r,isConnectable:t})]})}function dp(){return null}function fp({data:e,isConnectable:t,targetPosition:n=K.Top}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:n,isConnectable:t}),e?.label]})}var pp={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},mp={input:lp,default:up,output:fp,group:dp};function hp(e){return e.internals.handleBounds===void 0?{width:e.width??e.initialWidth??e.style?.width,height:e.height??e.initialHeight??e.style?.height}:{width:e.width??e.style?.width,height:e.height??e.style?.height}}var gp=e=>{let{width:t,height:n,x:r,y:i}=al(e.nodeLookup,{filter:e=>!!e.selected});return{width:Tl(t)?t:null,height:Tl(n)?n:null,userSelectionActive:e.userSelectionActive,transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]}) translate(${r}px,${i}px)`}};function _p({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=Ud(),{width:i,height:a,transformString:o,userSelectionActive:s}=Y(gp,Rd),c=tp(),l=(0,v.useRef)(null);(0,v.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if($f({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,H.jsx)(`div`,{className:ir([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,H.jsx)(`div`,{ref:l,className:`react-flow__nodesselection-rect`,onContextMenu:d,tabIndex:n?void 0:-1,onKeyDown:n?void 0:e=>{Object.prototype.hasOwnProperty.call(pp,e.key)&&(e.preventDefault(),c({direction:pp[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var vp=typeof window<`u`?window:void 0,yp=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function bp({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,paneClickDistance:s,deleteKeyCode:c,selectionKeyCode:l,selectionOnDrag:u,selectionMode:d,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:m,panActivationKeyCode:h,zoomActivationKeyCode:g,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:b,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:w,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,preventScrolling:k,onSelectionContextMenu:A,noWheelClassName:j,noPanClassName:M,disableKeyboardA11y:N,onViewportChange:ee,isControlledViewport:te}){let{nodesSelectionActive:P,userSelectionActive:F}=Y(yp,Rd),ne=_f(l,{target:vp}),re=_f(h,{target:vp}),ie=re||w,ae=re||b,I=u&&ie!==!0,L=ne||F||I;return Hf({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,H.jsx)(Kf,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:ae,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!ne&&ie,defaultViewport:T,translateExtent:E,minZoom:D,maxZoom:O,zoomActivationKeyCode:g,preventScrolling:k,noWheelClassName:j,noPanClassName:M,onViewportChange:ee,isControlledViewport:te,paneClickDistance:s,selectionOnDrag:I,children:(0,H.jsxs)(Zf,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:ie,isSelecting:!!L,selectionMode:d,selectionKeyPressed:ne,paneClickDistance:s,selectionOnDrag:I,children:[e,P&&(0,H.jsx)(_p,{onSelectionContextMenu:A,noPanClassName:M,disableKeyboardA11y:N})]})})}bp.displayName=`FlowRenderer`;var xp=(0,v.memo)(bp),Sp=e=>t=>e?ol(t.nodeLookup,{x:0,y:0,width:t.width,height:t.height},t.transform,!0).map(e=>e.id):Array.from(t.nodeLookup.keys());function Cp(e){return Y((0,v.useCallback)(Sp(e),[e]),Rd)}var wp=e=>e.updateNodeInternals;function Tp(){let e=Y(wp),[t]=(0,v.useState)(()=>typeof ResizeObserver>`u`?null:new ResizeObserver(t=>{let n=new Map;t.forEach(e=>{let t=e.target.getAttribute(`data-id`);n.set(t,{id:t,nodeElement:e.target,force:!0})}),e(n)}));return(0,v.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Ep({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=Ud(),a=(0,v.useRef)(null),o=(0,v.useRef)(null),s=(0,v.useRef)(e.sourcePosition),c=(0,v.useRef)(e.targetPosition),l=(0,v.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,v.useEffect)(()=>{a.current&&!e.hidden&&(!u||o.current!==a.current)&&(o.current&&r?.unobserve(o.current),r?.observe(a.current),o.current=a.current)},[u,e.hidden]),(0,v.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,v.useEffect)(()=>{if(a.current){let n=l.current!==t,r=s.current!==e.sourcePosition,o=c.current!==e.targetPosition;(n||r||o)&&(l.current=t,s.current=e.sourcePosition,c.current=e.targetPosition,i.getState().updateNodeInternals(new Map([[e.id,{id:e.id,nodeElement:a.current,force:!0}]])))}},[e.id,t,e.sourcePosition,e.targetPosition]),a}function Dp({id:e,onClick:t,onMouseEnter:n,onMouseMove:r,onMouseLeave:i,onContextMenu:a,onDoubleClick:o,nodesDraggable:s,elementsSelectable:c,nodesConnectable:l,nodesFocusable:u,resizeObserver:d,noDragClassName:f,noPanClassName:p,disableKeyboardA11y:m,rfId:h,nodeTypes:g,nodeClickDistance:_,onError:v}){let{node:y,internals:b,isParent:x}=Y(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},Rd),S=y.type||`default`,C=g?.[S]||mp[S];C===void 0&&(v?.(`003`,Hc.error003(S)),S=`default`,C=g?.default||mp.default);let w=!!(y.draggable||s&&y.draggable===void 0),T=!!(y.selectable||c&&y.selectable===void 0),E=!!(y.connectable||l&&y.connectable===void 0),D=!!(y.focusable||u&&y.focusable===void 0),O=Ud(),k=Ll(y),A=Ep({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=$f({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=tp();if(y.hidden)return null;let N=Il(y),ee=hp(y),te=T||w||t||n||r||i,P=n?e=>n(e,{...b.userNode}):void 0,F=r?e=>r(e,{...b.userNode}):void 0,ne=i?e=>i(e,{...b.userNode}):void 0,re=a?e=>a(e,{...b.userNode}):void 0,ie=o?e=>o(e,{...b.userNode}):void 0,ae=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&Qf({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},I=t=>{if(!(Gl(t.nativeEvent)||m)){if(Wc.includes(t.key)&&T)Qf({id:e,store:O,unselect:t.key===`Escape`,nodeRef:A});else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(pp,t.key)){t.preventDefault();let{ariaLabelConfig:e}=O.getState();O.setState({ariaLiveMessage:e[`node.a11yDescription.ariaLiveMessage`]({direction:t.key.replace(`Arrow`,``).toLowerCase(),x:~~b.positionAbsolute.x,y:~~b.positionAbsolute.y})}),M({direction:pp[t.key],factor:t.shiftKey?4:1})}}},L=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(ol(new Map([[e,y]]),{x:0,y:0,width:n,height:r},t,!0).length>0||a(y.position.x+N.width/2,y.position.y+N.height/2,{zoom:t[2]}))};return(0,H.jsx)(`div`,{className:ir([`react-flow__node`,`react-flow__node-${S}`,{[p]:w},y.className,{selected:y.selected,selectable:T,parent:x,draggable:w,dragging:j}]),ref:A,style:{zIndex:b.z,transform:`translate(${b.positionAbsolute.x}px,${b.positionAbsolute.y}px)`,pointerEvents:te?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...ee},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:P,onMouseMove:F,onMouseLeave:ne,onContextMenu:re,onClick:ae,onDoubleClick:ie,onKeyDown:D?I:void 0,tabIndex:D?0:void 0,onFocus:D?L:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${Kd}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,H.jsx)(rp,{value:e,children:(0,H.jsx)(C,{id:e,data:y.data,type:S,positionAbsoluteX:b.positionAbsolute.x,positionAbsoluteY:b.positionAbsolute.y,selected:y.selected??!1,selectable:T,draggable:w,deletable:y.deletable??!0,isConnectable:E,sourcePosition:y.sourcePosition,targetPosition:y.targetPosition,dragging:j,dragHandle:y.dragHandle,zIndex:b.z,parentId:y.parentId,...N})})})}var Op=(0,v.memo)(Dp),kp=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Ap(e){let{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,onError:a}=Y(kp,Rd),o=Cp(e.onlyRenderVisibleElements),s=Tp();return(0,H.jsx)(`div`,{className:`react-flow__nodes`,style:Wf,children:o.map(o=>(0,H.jsx)(Op,{id:o,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:s,nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:i,nodeClickDistance:e.nodeClickDistance,onError:a},o))})}Ap.displayName=`NodeRenderer`;var jp=(0,v.memo)(Ap);function Mp(e){return Y((0,v.useCallback)(t=>{if(!e)return t.edges.map(e=>e.id);let n=[];if(t.width&&t.height)for(let e of t.edges){let r=t.nodeLookup.get(e.source),i=t.nodeLookup.get(e.target);r&&i&&tu({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),Rd)}var Np=({color:e=`none`,strokeWidth:t=1})=>(0,H.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),Pp=({color:e=`none`,strokeWidth:t=1})=>(0,H.jsx)(`polyline`,{className:`arrowclosed`,style:{strokeWidth:t,...e&&{stroke:e,fill:e}},strokeLinecap:`round`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4 -5,-4`}),Fp={[Zc.Arrow]:Np,[Zc.ArrowClosed]:Pp};function Ip(e){let t=Ud();return(0,v.useMemo)(()=>Object.prototype.hasOwnProperty.call(Fp,e)?Fp[e]:(t.getState().onError?.(`009`,Hc.error009(e)),null),[e])}var Lp=({id:e,type:t,color:n,width:r=12.5,height:i=12.5,markerUnits:a=`strokeWidth`,strokeWidth:o,orient:s=`auto-start-reverse`})=>{let c=Ip(t);return c?(0,H.jsx)(`marker`,{className:`react-flow__arrowhead`,id:e,markerWidth:`${r}`,markerHeight:`${i}`,viewBox:`-10 -10 20 20`,markerUnits:a,orient:s,refX:`0`,refY:`0`,children:(0,H.jsx)(c,{color:n,strokeWidth:o})}):null},Rp=({defaultColor:e,rfId:t})=>{let n=Y(e=>e.edges),r=Y(e=>e.defaultEdgeOptions),i=(0,v.useMemo)(()=>vu(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,H.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,H.jsx)(`defs`,{children:i.map(e=>(0,H.jsx)(Lp,{id:e.id,type:e.type,color:e.color,width:e.width,height:e.height,markerUnits:e.markerUnits,strokeWidth:e.strokeWidth,orient:e.orient},e.id))})}):null};Rp.displayName=`MarkerDefinitions`;var zp=(0,v.memo)(Rp);function Bp({x:e,y:t,label:n,labelStyle:r,labelShowBg:i=!0,labelBgStyle:a,labelBgPadding:o=[2,4],labelBgBorderRadius:s=2,children:c,className:l,...u}){let[d,f]=(0,v.useState)({x:1,y:0,width:0,height:0}),p=ir([`react-flow__edge-textwrapper`,l]),m=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(m.current){let e=m.current.getBBox();f({x:e.x,y:e.y,width:e.width,height:e.height})}},[n]),n?(0,H.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,H.jsx)(`rect`,{width:d.width+2*o[0],x:-o[0],y:-o[1],height:d.height+2*o[1],className:`react-flow__edge-textbg`,style:a,rx:s,ry:s}),(0,H.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}Bp.displayName=`EdgeText`;var Vp=(0,v.memo)(Bp);function Hp({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`path`,{...u,d:e,fill:`none`,className:ir([`react-flow__edge-path`,u.className])}),l?(0,H.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&Tl(t)&&Tl(n)?(0,H.jsx)(Vp,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function Up({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===K.Left||e===K.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function Wp({sourceX:e,sourceY:t,sourcePosition:n=K.Bottom,targetX:r,targetY:i,targetPosition:a=K.Top}){let[o,s]=Up({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=Up({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=Yl({sourceX:e,sourceY:t,targetX:r,targetY:i,sourceControlX:o,sourceControlY:s,targetControlX:c,targetControlY:l});return[`M${e},${t} C${o},${s} ${c},${l} ${r},${i}`,u,d,f,p]}function Gp(e){return(0,v.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o,targetPosition:s,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})=>{let[v,y,b]=Wp({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,H.jsx)(Hp,{id:e.isInternal?void 0:t,path:v,labelX:y,labelY:b,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:_})})}var Kp=Gp({isInternal:!1}),qp=Gp({isInternal:!0});Kp.displayName=`SimpleBezierEdge`,qp.displayName=`SimpleBezierEdgeInternal`;function Jp(e){return(0,v.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=K.Bottom,targetPosition:m=K.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=du({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,H.jsx)(Hp,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:h,markerStart:g,interactionWidth:v})})}var Yp=Jp({isInternal:!1}),Xp=Jp({isInternal:!0});Yp.displayName=`SmoothStepEdge`,Xp.displayName=`SmoothStepEdgeInternal`;function Zp(e){return(0,v.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,H.jsx)(Yp,{...n,id:r,pathOptions:(0,v.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var Qp=Zp({isInternal:!1}),$p=Zp({isInternal:!0});Qp.displayName=`StepEdge`,$p.displayName=`StepEdgeInternal`;function em(e){return(0,v.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})=>{let[g,_,v]=au({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,H.jsx)(Hp,{id:e.isInternal?void 0:t,path:g,labelX:_,labelY:v,label:o,labelStyle:s,labelShowBg:c,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:h})})}var tm=em({isInternal:!1}),nm=em({isInternal:!0});tm.displayName=`StraightEdge`,nm.displayName=`StraightEdgeInternal`;function rm(e){return(0,v.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=K.Bottom,targetPosition:s=K.Top,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=Ql({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,H.jsx)(Hp,{id:e.isInternal?void 0:t,path:y,labelX:b,labelY:x,label:c,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:h,markerStart:g,interactionWidth:v})})}var im=rm({isInternal:!1}),am=rm({isInternal:!0});im.displayName=`BezierEdge`,am.displayName=`BezierEdgeInternal`;var om={default:am,straight:nm,step:$p,smoothstep:Xp,simplebezier:qp},sm={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null},cm=(e,t,n)=>n===K.Left?e-t:n===K.Right?e+t:e,lm=(e,t,n)=>n===K.Top?e-t:n===K.Bottom?e+t:e,um=`react-flow__edgeupdater`;function dm({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,H.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:ir([um,`${um}-${s}`]),cx:cm(t,r,e),cy:lm(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function fm({isReconnectable:e,reconnectRadius:t,edge:n,sourceX:r,sourceY:i,targetX:a,targetY:o,sourcePosition:s,targetPosition:c,onReconnect:l,onReconnectStart:u,onReconnectEnd:d,setReconnecting:f,setUpdateHover:p}){let m=Ud(),h=(e,t)=>{if(e.button!==0)return;let{autoPanOnConnect:r,domNode:i,connectionMode:a,connectionRadius:o,lib:s,onConnectStart:c,cancelConnection:p,nodeLookup:h,rfId:g,panBy:_,updateConnection:v}=m.getState(),y=t.type===`target`;Qu.onPointerDown(e.nativeEvent,{autoPanOnConnect:r,connectionMode:a,connectionRadius:o,domNode:i,handleId:t.id,nodeId:t.nodeId,nodeLookup:h,isTarget:y,edgeUpdaterType:t.type,lib:s,flowId:g,cancelConnection:p,panBy:_,isValidConnection:(...e)=>m.getState().isValidConnection?.(...e)??!0,onConnect:e=>l?.(n,e),onConnectStart:(r,i)=>{f(!0),u?.(e,n,t.type),c?.(r,i)},onConnectEnd:(...e)=>m.getState().onConnectEnd?.(...e),onReconnectEnd:(e,r)=>{f(!1),d?.(e,n,t.type,r)},updateConnection:v,getTransform:()=>m.getState().transform,getFromHandle:()=>m.getState().connection.fromHandle,dragThreshold:m.getState().connectionDragThreshold,handleDomNode:e.currentTarget})},g=e=>h(e,{nodeId:n.target,id:n.targetHandle??null,type:`target`}),_=e=>h(e,{nodeId:n.source,id:n.sourceHandle??null,type:`source`}),v=()=>p(!0),y=()=>p(!1);return(0,H.jsxs)(H.Fragment,{children:[(e===!0||e===`source`)&&(0,H.jsx)(dm,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,H.jsx)(dm,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function pm({id:e,edgesFocusable:t,edgesReconnectable:n,elementsSelectable:r,onClick:i,onDoubleClick:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,rfId:m,edgeTypes:h,noPanClassName:g,onError:_,disableKeyboardA11y:y}){let b=Y(t=>t.edgeLookup.get(e)),x=Y(e=>e.defaultEdgeOptions);b=x?{...x,...b}:b;let S=b.type||`default`,C=h?.[S]||om[S];C===void 0&&(_?.(`011`,Hc.error011(S)),S=`default`,C=h?.default||om.default);let w=!!(b.focusable||t&&b.focusable===void 0),T=d!==void 0&&(b.reconnectable||n&&b.reconnectable===void 0),E=!!(b.selectable||r&&b.selectable===void 0),D=(0,v.useRef)(null),[O,k]=(0,v.useState)(!1),[A,j]=(0,v.useState)(!1),M=Ud(),{zIndex:N,sourceX:ee,sourceY:te,targetX:P,targetY:F,sourcePosition:ne,targetPosition:re}=Y((0,v.useCallback)(t=>{let n=t.nodeLookup.get(b.source),r=t.nodeLookup.get(b.target);if(!n||!r)return{zIndex:b.zIndex,...sm};let i=pu({id:e,sourceNode:n,targetNode:r,sourceHandle:b.sourceHandle||null,targetHandle:b.targetHandle||null,connectionMode:t.connectionMode,onError:_});return{zIndex:eu({selected:b.selected,zIndex:b.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode}),...i||sm}},[b.source,b.target,b.sourceHandle,b.targetHandle,b.selected,b.zIndex]),Rd),ie=(0,v.useMemo)(()=>b.markerStart?`url('#${_u(b.markerStart,m)}')`:void 0,[b.markerStart,m]),ae=(0,v.useMemo)(()=>b.markerEnd?`url('#${_u(b.markerEnd,m)}')`:void 0,[b.markerEnd,m]);if(b.hidden||ee===null||te===null||P===null||F===null)return null;let I=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=M.getState();E&&(M.setState({nodesSelectionActive:!1}),b.selected&&a?(r({nodes:[],edges:[b]}),D.current?.blur()):n([e])),i&&i(t,b)},L=a?e=>{a(e,{...b})}:void 0,oe=o?e=>{o(e,{...b})}:void 0,se=s?e=>{s(e,{...b})}:void 0,ce=c?e=>{c(e,{...b})}:void 0,le=l?e=>{l(e,{...b})}:void 0;return(0,H.jsx)(`svg`,{style:{zIndex:N},children:(0,H.jsxs)(`g`,{className:ir([`react-flow__edge`,`react-flow__edge-${S}`,b.className,g,{selected:b.selected,animated:b.animated,inactive:!E&&!i,updating:O,selectable:E}]),onClick:I,onDoubleClick:L,onContextMenu:oe,onMouseEnter:se,onMouseMove:ce,onMouseLeave:le,onKeyDown:w?t=>{if(!y&&Wc.includes(t.key)&&E){let{unselectNodesAndEdges:n,addSelectedEdges:r}=M.getState();t.key===`Escape`?(D.current?.blur(),n({edges:[b]})):r([e])}}:void 0,tabIndex:w?0:void 0,role:b.ariaRole??(w?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":b.ariaLabel===null?void 0:b.ariaLabel||`Edge from ${b.source} to ${b.target}`,"aria-describedby":w?`${qd}-${m}`:void 0,ref:D,...b.domAttributes,children:[!A&&(0,H.jsx)(C,{id:e,source:b.source,target:b.target,type:b.type,selected:b.selected,animated:b.animated,selectable:E,deletable:b.deletable??!0,label:b.label,labelStyle:b.labelStyle,labelShowBg:b.labelShowBg,labelBgStyle:b.labelBgStyle,labelBgPadding:b.labelBgPadding,labelBgBorderRadius:b.labelBgBorderRadius,sourceX:ee,sourceY:te,targetX:P,targetY:F,sourcePosition:ne,targetPosition:re,data:b.data,style:b.style,sourceHandleId:b.sourceHandle,targetHandleId:b.targetHandle,markerStart:ie,markerEnd:ae,pathOptions:`pathOptions`in b?b.pathOptions:void 0,interactionWidth:b.interactionWidth}),T&&(0,H.jsx)(fm,{edge:b,isReconnectable:T,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:ee,sourceY:te,targetX:P,targetY:F,sourcePosition:ne,targetPosition:re,setUpdateHover:k,setReconnecting:j})]})})}var mm=(0,v.memo)(pm),hm=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function gm({defaultMarkerColor:e,onlyRenderVisibleElements:t,rfId:n,edgeTypes:r,noPanClassName:i,onReconnect:a,onEdgeContextMenu:o,onEdgeMouseEnter:s,onEdgeMouseMove:c,onEdgeMouseLeave:l,onEdgeClick:u,reconnectRadius:d,onEdgeDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,disableKeyboardA11y:h}){let{edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,onError:y}=Y(hm,Rd),b=Mp(t);return(0,H.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,H.jsx)(zp,{defaultColor:e,rfId:n}),b.map(e=>(0,H.jsx)(mm,{id:e,edgesFocusable:g,edgesReconnectable:_,elementsSelectable:v,noPanClassName:i,onReconnect:a,onContextMenu:o,onMouseEnter:s,onMouseMove:c,onMouseLeave:l,onClick:u,reconnectRadius:d,onDoubleClick:f,onReconnectStart:p,onReconnectEnd:m,rfId:n,onError:y,edgeTypes:r,disableKeyboardA11y:h},e))]})}gm.displayName=`EdgeRenderer`;var _m=(0,v.memo)(gm),vm=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function ym({children:e}){return(0,H.jsx)(`div`,{className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:Y(vm)},children:e})}function bm(e){let t=zf(),n=(0,v.useRef)(!1);(0,v.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var xm=e=>e.panZoom?.syncViewport;function Sm(e){let t=Y(xm),n=Ud();return(0,v.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function Cm(e){return e.connection.inProgress?{...e.connection,to:Ol(e.connection.to,e.transform)}:{...e.connection}}function wm(e){return e?t=>e(Cm(t)):Cm}function Tm(e){return Y(wm(e),Rd)}var Em=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function Dm({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=Y(Em,Rd);return a&&i&&c?(0,H.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,H.jsx)(`g`,{className:ir([`react-flow__connection`,$c(s)]),children:(0,H.jsx)(Om,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var Om=({style:e,type:t=Xc.Bezier,CustomComponent:n,isValid:r})=>{let{inProgress:i,from:a,fromNode:o,fromHandle:s,fromPosition:c,to:l,toNode:u,toHandle:d,toPosition:f,pointer:p}=Tm();if(!i)return;if(n)return(0,H.jsx)(n,{connectionLineType:t,connectionLineStyle:e,fromNode:o,fromHandle:s,fromX:a.x,fromY:a.y,toX:l.x,toY:l.y,fromPosition:c,toPosition:f,connectionStatus:$c(r),toNode:u,toHandle:d,pointer:p});let m=``,h={sourceX:a.x,sourceY:a.y,sourcePosition:c,targetX:l.x,targetY:l.y,targetPosition:f};switch(t){case Xc.Bezier:[m]=Ql(h);break;case Xc.SimpleBezier:[m]=Wp(h);break;case Xc.Step:[m]=du({...h,borderRadius:0});break;case Xc.SmoothStep:[m]=du(h);break;default:[m]=au(h)}return(0,H.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};Om.displayName=`ConnectionLine`;var km={};function Am(e=km){(0,v.useRef)(e),Ud(),(0,v.useEffect)(()=>{},[e])}function jm(){Ud(),(0,v.useRef)(!1),(0,v.useEffect)(()=>{},[])}function Mm({nodeTypes:e,edgeTypes:t,onInit:n,onNodeClick:r,onEdgeClick:i,onNodeDoubleClick:a,onEdgeDoubleClick:o,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,onSelectionContextMenu:d,onSelectionStart:f,onSelectionEnd:p,connectionLineType:m,connectionLineStyle:h,connectionLineComponent:g,connectionLineContainerStyle:_,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,deleteKeyCode:w,onlyRenderVisibleElements:T,elementsSelectable:E,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,preventScrolling:j,defaultMarkerColor:M,zoomOnScroll:N,zoomOnPinch:ee,panOnScroll:te,panOnScrollSpeed:P,panOnScrollMode:F,zoomOnDoubleClick:ne,panOnDrag:re,onPaneClick:ie,onPaneMouseEnter:ae,onPaneMouseMove:I,onPaneMouseLeave:L,onPaneScroll:oe,onPaneContextMenu:se,paneClickDistance:ce,nodeClickDistance:le,onEdgeContextMenu:ue,onEdgeMouseEnter:de,onEdgeMouseMove:fe,onEdgeMouseLeave:pe,reconnectRadius:me,onReconnect:he,onReconnectStart:ge,onReconnectEnd:_e,noDragClassName:ve,noWheelClassName:ye,noPanClassName:be,disableKeyboardA11y:xe,nodeExtent:Se,rfId:Ce,viewport:we,onViewportChange:Te}){return Am(e),Am(t),jm(),bm(n),Sm(we),(0,H.jsx)(xp,{onPaneClick:ie,onPaneMouseEnter:ae,onPaneMouseMove:I,onPaneMouseLeave:L,onPaneContextMenu:se,onPaneScroll:oe,paneClickDistance:ce,deleteKeyCode:w,selectionKeyCode:v,selectionOnDrag:y,selectionMode:b,onSelectionStart:f,onSelectionEnd:p,multiSelectionKeyCode:x,panActivationKeyCode:S,zoomActivationKeyCode:C,elementsSelectable:E,zoomOnScroll:N,zoomOnPinch:ee,zoomOnDoubleClick:ne,panOnScroll:te,panOnScrollSpeed:P,panOnScrollMode:F,panOnDrag:re,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:ve,noWheelClassName:ye,noPanClassName:be,disableKeyboardA11y:xe,onViewportChange:Te,isControlledViewport:!!we,children:(0,H.jsxs)(ym,{children:[(0,H.jsx)(_m,{edgeTypes:t,onEdgeClick:i,onEdgeDoubleClick:o,onReconnect:he,onReconnectStart:ge,onReconnectEnd:_e,onlyRenderVisibleElements:T,onEdgeContextMenu:ue,onEdgeMouseEnter:de,onEdgeMouseMove:fe,onEdgeMouseLeave:pe,reconnectRadius:me,defaultMarkerColor:M,noPanClassName:be,disableKeyboardA11y:xe,rfId:Ce}),(0,H.jsx)(Dm,{style:h,type:m,component:g,containerStyle:_}),(0,H.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,H.jsx)(jp,{nodeTypes:e,onNodeClick:r,onNodeDoubleClick:a,onNodeMouseEnter:s,onNodeMouseMove:c,onNodeMouseLeave:l,onNodeContextMenu:u,nodeClickDistance:le,onlyRenderVisibleElements:T,noPanClassName:be,noDragClassName:ve,disableKeyboardA11y:xe,nodeExtent:Se,rfId:Ce}),(0,H.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}Mm.displayName=`GraphView`;var Nm=(0,v.memo)(Mm),Pm=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c=.5,maxZoom:l=2,nodeOrigin:u,nodeExtent:d,zIndexMode:f=`basic`}={})=>{let p=new Map,m=new Map,h=new Map,g=new Map,_=r??t??[],v=n??e??[],y=u??[0,0],b=d??Uc;Iu(h,g,_);let x=Du(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=Nl(al(p,{filter:e=>!!((e.width||e.initialWidth)&&(e.height||e.initialHeight))}),i,a,c,l,s?.padding??.1);S=[e,t,n]}return{rfId:`1`,width:i??0,height:a??0,transform:S,nodes:v,nodesInitialized:x,nodeLookup:p,parentLookup:m,edges:_,edgeLookup:g,connectionLookup:h,onNodesChange:null,onEdgesChange:null,hasDefaultNodes:n!==void 0,hasDefaultEdges:r!==void 0,panZoom:null,minZoom:c,maxZoom:l,translateExtent:Uc,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:Kc.Strict,domNode:null,paneDragging:!1,noPanClassName:`nopan`,nodeOrigin:y,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:o??!1,fitViewOptions:s,fitViewResolver:null,connection:{...Yc},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:El,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:Gc,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},Fm=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f})=>Ld((p,m)=>{async function h(){let{nodeLookup:e,panZoom:t,fitViewOptions:n,fitViewResolver:r,width:i,height:a,minZoom:o,maxZoom:s}=m();t&&(await ll({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...Pm({nodes:e,edges:t,width:i,height:a,fitView:o,fitViewOptions:s,minZoom:c,maxZoom:l,nodeOrigin:u,nodeExtent:d,defaultNodes:n,defaultEdges:r,zIndexMode:f}),setNodes:e=>{let{nodeLookup:t,parentLookup:n,nodeOrigin:r,elevateNodesOnSelect:i,fitViewQueued:a,zIndexMode:o}=m(),s=Du(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o});a&&s?(h(),p({nodes:e,nodesInitialized:s,fitViewQueued:!1,fitViewOptions:void 0})):p({nodes:e,nodesInitialized:s})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();Iu(t,n,e),p({edges:e})},setDefaultNodesAndEdges:(e,t)=>{if(e){let{setNodes:t}=m();t(e),p({hasDefaultNodes:!0})}if(t){let{setEdges:e}=m();e(t),p({hasDefaultEdges:!0})}},updateNodeInternals:e=>{let{triggerNodeChanges:t,nodeLookup:n,parentLookup:r,domNode:i,nodeOrigin:a,nodeExtent:o,debug:s,fitViewQueued:c,zIndexMode:l}=m(),{changes:u,updatedInternals:d}=Nu(e,n,r,i,a,o,l);d&&(wu(n,r,{nodeOrigin:a,nodeExtent:o,zIndexMode:l}),c?(h(),p({fitViewQueued:!1,fitViewOptions:void 0})):p({}),u?.length>0&&(s&&console.log(`React Flow: trigger node changes`,u),t?.(u)))},updateNodePositions:(e,t=!1)=>{let n=[],r=[],{nodeLookup:i,triggerNodeChanges:a,connection:o,updateConnection:s,onNodesChangeMiddlewareMap:c}=m();for(let[a,c]of e){let e=i.get(a),l=!!(e?.expandParent&&e?.parentId&&c?.position),u={id:a,type:`position`,position:l?{x:Math.max(0,c.position.x),y:Math.max(0,c.position.y)}:c.position,dragging:t};if(e&&o.inProgress&&o.fromNode.id===e.id){let t=hu(e,o.fromHandle,K.Left,!0);s({...o,from:t})}l&&e.parentId&&n.push({id:a,parentId:e.parentId,rect:{...c.internals.positionAbsolute,width:c.measured.width??0,height:c.measured.height??0}}),r.push(u)}if(n.length>0){let{parentLookup:e,nodeOrigin:t}=m(),a=Mu(n,i,e,t);r.push(...a)}for(let e of c.values())r=e(r);a(r)},triggerNodeChanges:e=>{let{onNodesChange:t,setNodes:n,nodes:r,hasDefaultNodes:i,debug:a}=m();e?.length&&(i&&n(Cf(e,r)),a&&console.log(`React Flow: trigger node changes`,e),t?.(e))},triggerEdgeChanges:e=>{let{onEdgesChange:t,setEdges:n,edges:r,hasDefaultEdges:i,debug:a}=m();e?.length&&(i&&n(wf(e,r)),a&&console.log(`React Flow: trigger edge changes`,e),t?.(e))},addSelectedNodes:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){i(e.map(e=>Tf(e,!0)));return}i(Ef(r,new Set([...e]),!0)),a(Ef(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>Tf(e,!0)));return}a(Ef(n,new Set([...e]))),i(Ef(r,new Set,!0))},unselectNodesAndEdges:({nodes:e,edges:t}={})=>{let{edges:n,nodes:r,nodeLookup:i,triggerNodeChanges:a,triggerEdgeChanges:o}=m(),s=e||r,c=t||n,l=[];for(let e of s){if(!e.selected)continue;let t=i.get(e.id);t&&(t.selected=!1),l.push(Tf(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(Tf(e.id,!1));a(l),o(u)},setMinZoom:e=>{let{panZoom:t,maxZoom:n}=m();t?.setScaleExtent([e,n]),p({minZoom:e})},setMaxZoom:e=>{let{panZoom:t,minZoom:n}=m();t?.setScaleExtent([n,e]),p({maxZoom:e})},setTranslateExtent:e=>{m().panZoom?.setTranslateExtent(e),p({translateExtent:e})},resetSelectedElements:()=>{let{edges:e,nodes:t,triggerNodeChanges:n,triggerEdgeChanges:r,elementsSelectable:i}=m();if(!i)return;let a=t.reduce((e,t)=>t.selected?[...e,Tf(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,Tf(t.id,!1)]:e,[]);n(a),r(o)},setNodeExtent:e=>{let{nodes:t,nodeLookup:n,parentLookup:r,nodeOrigin:i,elevateNodesOnSelect:a,nodeExtent:o,zIndexMode:s}=m();e[0][0]===o[0][0]&&e[0][1]===o[0][1]&&e[1][0]===o[1][0]&&e[1][1]===o[1][1]||(Du(t,n,r,{nodeOrigin:i,nodeExtent:e,elevateNodesOnSelect:a,checkEquality:!1,zIndexMode:s}),p({nodeExtent:e}))},panBy:e=>{let{transform:t,width:n,height:r,panZoom:i,translateExtent:a}=m();return Pu({delta:e,panZoom:i,transform:t,translateExtent:a,width:n,height:r})},setCenter:async(e,t,n)=>{let{width:r,height:i,maxZoom:a,panZoom:o}=m();if(!o)return Promise.resolve(!1);let s=n?.zoom===void 0?a:n.zoom;return await o.setViewport({x:r/2-e*s,y:i/2-t*s,zoom:s},{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),Promise.resolve(!0)},cancelConnection:()=>{p({connection:{...Yc}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...Pm()})}},Object.is);function Im({initialNodes:e,initialEdges:t,defaultNodes:n,defaultEdges:r,initialWidth:i,initialHeight:a,initialMinZoom:o,initialMaxZoom:s,initialFitViewOptions:c,fitView:l,nodeOrigin:u,nodeExtent:d,zIndexMode:f,children:p}){let[m]=(0,v.useState)(()=>Fm({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,width:i,height:a,fitView:l,minZoom:o,maxZoom:s,fitViewOptions:c,nodeOrigin:u,nodeExtent:d,zIndexMode:f}));return(0,H.jsx)(Vd,{value:m,children:(0,H.jsx)(If,{children:p})})}function Lm({children:e,nodes:t,edges:n,defaultNodes:r,defaultEdges:i,width:a,height:o,fitView:s,fitViewOptions:c,minZoom:l,maxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p}){return(0,v.useContext)(Bd)?(0,H.jsx)(H.Fragment,{children:e}):(0,H.jsx)(Im,{initialNodes:t,initialEdges:n,defaultNodes:r,defaultEdges:i,initialWidth:a,initialHeight:o,fitView:s,initialFitViewOptions:c,initialMinZoom:l,initialMaxZoom:u,nodeOrigin:d,nodeExtent:f,zIndexMode:p,children:e})}var Rm={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function zm({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:i,nodeTypes:a,edgeTypes:o,onNodeClick:s,onEdgeClick:c,onInit:l,onMove:u,onMoveStart:d,onMoveEnd:f,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:x,onNodeContextMenu:S,onNodeDoubleClick:C,onNodeDragStart:w,onNodeDrag:T,onNodeDragStop:E,onNodesDelete:D,onEdgesDelete:O,onDelete:k,onSelectionChange:A,onSelectionDragStart:j,onSelectionDrag:M,onSelectionDragStop:N,onSelectionContextMenu:ee,onSelectionStart:te,onSelectionEnd:P,onBeforeDelete:F,connectionMode:ne,connectionLineType:re=Xc.Bezier,connectionLineStyle:ie,connectionLineComponent:ae,connectionLineContainerStyle:I,deleteKeyCode:L=`Backspace`,selectionKeyCode:oe=`Shift`,selectionOnDrag:se=!1,selectionMode:ce=Jc.Full,panActivationKeyCode:le=`Space`,multiSelectionKeyCode:ue=Pl()?`Meta`:`Control`,zoomActivationKeyCode:de=Pl()?`Meta`:`Control`,snapToGrid:fe,snapGrid:pe,onlyRenderVisibleElements:me=!1,selectNodesOnDrag:he,nodesDraggable:ge,autoPanOnNodeFocus:_e,nodesConnectable:ve,nodesFocusable:ye,nodeOrigin:be=cf,edgesFocusable:xe,edgesReconnectable:Se,elementsSelectable:Ce=!0,defaultViewport:we=lf,minZoom:Te=.5,maxZoom:Ee=2,translateExtent:De=Uc,preventScrolling:Oe=!0,nodeExtent:ke,defaultMarkerColor:Ae=`#b1b1b7`,zoomOnScroll:je=!0,zoomOnPinch:Me=!0,panOnScroll:Ne=!1,panOnScrollSpeed:Pe=.5,panOnScrollMode:R=qc.Free,zoomOnDoubleClick:Fe=!0,panOnDrag:z=!0,onPaneClick:Ie,onPaneMouseEnter:Le,onPaneMouseMove:Re,onPaneMouseLeave:ze,onPaneScroll:Be,onPaneContextMenu:Ve,paneClickDistance:He=1,nodeClickDistance:Ue=0,children:We,onReconnect:Ge,onReconnectStart:B,onReconnectEnd:V,onEdgeContextMenu:Ke,onEdgeDoubleClick:qe,onEdgeMouseEnter:Je,onEdgeMouseMove:Ye,onEdgeMouseLeave:Xe,reconnectRadius:Ze=10,onNodesChange:Qe,onEdgesChange:$e,noDragClassName:et=`nodrag`,noWheelClassName:tt=`nowheel`,noPanClassName:nt=`nopan`,fitView:rt,fitViewOptions:it,connectOnClick:at,attributionPosition:ot,proOptions:U,defaultEdgeOptions:st,elevateNodesOnSelect:ct=!0,elevateEdgesOnSelect:lt=!1,disableKeyboardA11y:ut=!1,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:pt,connectionRadius:mt,isValidConnection:ht,onError:gt,style:_t,id:vt,nodeDragThreshold:yt,connectionDragThreshold:bt,viewport:xt,onViewportChange:St,width:Ct,height:wt,colorMode:Tt=`light`,debug:Et,onScroll:Dt,ariaLabelConfig:Ot,zIndexMode:kt=`basic`,...At},jt){let Mt=vt||`1`,Nt=hf(Tt),Pt=(0,v.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Dt?.(e)},[Dt]);return(0,H.jsx)(`div`,{"data-testid":`rf__wrapper`,...At,onScroll:Pt,style:{..._t,...Rm},ref:jt,className:ir([`react-flow`,i,Nt]),id:vt,role:`application`,children:(0,H.jsxs)(Lm,{nodes:e,edges:t,width:Ct,height:wt,fitView:rt,fitViewOptions:it,minZoom:Te,maxZoom:Ee,nodeOrigin:be,nodeExtent:ke,zIndexMode:kt,children:[(0,H.jsx)(Nm,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:y,onNodeMouseMove:b,onNodeMouseLeave:x,onNodeContextMenu:S,onNodeDoubleClick:C,nodeTypes:a,edgeTypes:o,connectionLineType:re,connectionLineStyle:ie,connectionLineComponent:ae,connectionLineContainerStyle:I,selectionKeyCode:oe,selectionOnDrag:se,selectionMode:ce,deleteKeyCode:L,multiSelectionKeyCode:ue,panActivationKeyCode:le,zoomActivationKeyCode:de,onlyRenderVisibleElements:me,defaultViewport:we,translateExtent:De,minZoom:Te,maxZoom:Ee,preventScrolling:Oe,zoomOnScroll:je,zoomOnPinch:Me,zoomOnDoubleClick:Fe,panOnScroll:Ne,panOnScrollSpeed:Pe,panOnScrollMode:R,panOnDrag:z,onPaneClick:Ie,onPaneMouseEnter:Le,onPaneMouseMove:Re,onPaneMouseLeave:ze,onPaneScroll:Be,onPaneContextMenu:Ve,paneClickDistance:He,nodeClickDistance:Ue,onSelectionContextMenu:ee,onSelectionStart:te,onSelectionEnd:P,onReconnect:Ge,onReconnectStart:B,onReconnectEnd:V,onEdgeContextMenu:Ke,onEdgeDoubleClick:qe,onEdgeMouseEnter:Je,onEdgeMouseMove:Ye,onEdgeMouseLeave:Xe,reconnectRadius:Ze,defaultMarkerColor:Ae,noDragClassName:et,noWheelClassName:tt,noPanClassName:nt,rfId:Mt,disableKeyboardA11y:ut,nodeExtent:ke,viewport:xt,onViewportChange:St}),(0,H.jsx)(pf,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:ge,autoPanOnNodeFocus:_e,nodesConnectable:ve,nodesFocusable:ye,edgesFocusable:xe,edgesReconnectable:Se,elementsSelectable:Ce,elevateNodesOnSelect:ct,elevateEdgesOnSelect:lt,minZoom:Te,maxZoom:Ee,nodeExtent:ke,onNodesChange:Qe,onEdgesChange:$e,snapToGrid:fe,snapGrid:pe,connectionMode:ne,translateExtent:De,connectOnClick:at,defaultEdgeOptions:st,fitView:rt,fitViewOptions:it,onNodesDelete:D,onEdgesDelete:O,onDelete:k,onNodeDragStart:w,onNodeDrag:T,onNodeDragStop:E,onSelectionDrag:M,onSelectionDragStart:j,onSelectionDragStop:N,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:nt,nodeOrigin:be,rfId:Mt,autoPanOnConnect:dt,autoPanOnNodeDrag:ft,autoPanSpeed:pt,onError:gt,connectionRadius:mt,isValidConnection:ht,selectNodesOnDrag:he,nodeDragThreshold:yt,connectionDragThreshold:bt,onBeforeDelete:F,debug:Et,ariaLabelConfig:Ot,zIndexMode:kt}),(0,H.jsx)(sf,{onSelectionChange:A}),We,(0,H.jsx)(ef,{proOptions:U,position:ot}),(0,H.jsx)(Qd,{rfId:Mt,disableKeyboardA11y:ut})]})})}var Bm=jf(zm),Vm=e=>e.domNode?.querySelector(`.react-flow__edgelabel-renderer`);function Hm({children:e}){let t=Y(Vm);return t?(0,zd.createPortal)(e,t):null}function Um(e){let[t,n]=(0,v.useState)(e);return[t,n,(0,v.useCallback)(e=>n(t=>Cf(e,t)),[])]}function Wm(e){let[t,n]=(0,v.useState)(e);return[t,n,(0,v.useCallback)(e=>n(t=>wf(e,t)),[])]}Hc.error014();function Gm({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,H.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:ir([`react-flow__background-pattern`,n,r])})}function Km({radius:e,className:t}){return(0,H.jsx)(`circle`,{cx:e,cy:e,r:e,className:ir([`react-flow__background-pattern`,`dots`,t])})}var qm;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(qm||={});var Jm={[qm.Dots]:1,[qm.Lines]:1,[qm.Cross]:6},Ym=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function Xm({id:e,variant:t=qm.Dots,gap:n=20,size:r,lineWidth:i=1,offset:a=0,color:o,bgColor:s,style:c,className:l,patternClassName:u}){let d=(0,v.useRef)(null),{transform:f,patternId:p}=Y(Ym,Rd),m=r||Jm[t],h=t===qm.Dots,g=t===qm.Cross,_=Array.isArray(n)?n:[n,n],y=[_[0]*f[2]||1,_[1]*f[2]||1],b=m*f[2],x=Array.isArray(a)?a:[a,a],S=g?[b,b]:y,C=[x[0]*f[2]||1+S[0]/2,x[1]*f[2]||1+S[1]/2],w=`${p}${e||``}`;return(0,H.jsxs)(`svg`,{className:ir([`react-flow__background`,l]),style:{...c,...Wf,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,H.jsx)(`pattern`,{id:w,x:f[0]%y[0],y:f[1]%y[1],width:y[0],height:y[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${C[0]},-${C[1]})`,children:h?(0,H.jsx)(Km,{radius:b/2,className:u}):(0,H.jsx)(Gm,{dimensions:S,lineWidth:i,variant:t,className:u})}),(0,H.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${w})`})]})}Xm.displayName=`Background`;var Zm=(0,v.memo)(Xm);function Qm(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,H.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function $m(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,H.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function eh(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,H.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 th(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,H.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 nh(){return(0,H.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,H.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 rh({children:e,className:t,...n}){return(0,H.jsx)(`button`,{type:`button`,className:ir([`react-flow__controls-button`,t]),...n,children:e})}var ih=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function ah({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:i,onZoomIn:a,onZoomOut:o,onFitView:s,onInteractiveChange:c,className:l,children:u,position:d=`bottom-left`,orientation:f=`vertical`,"aria-label":p}){let m=Ud(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=Y(ih,Rd),{zoomIn:y,zoomOut:b,fitView:x}=zf();return(0,H.jsxs)($d,{className:ir([`react-flow__controls`,f===`horizontal`?`horizontal`:`vertical`,l]),position:d,style:e,"data-testid":`rf__controls`,"aria-label":p??v[`controls.ariaLabel`],children:[t&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(rh,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,H.jsx)(Qm,{})}),(0,H.jsx)(rh,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,H.jsx)($m,{})})]}),n&&(0,H.jsx)(rh,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,H.jsx)(eh,{})}),r&&(0,H.jsx)(rh,{className:`react-flow__controls-interactive`,onClick:()=>{m.setState({nodesDraggable:!h,nodesConnectable:!h,elementsSelectable:!h}),c?.(!h)},title:v[`controls.interactive.ariaLabel`],"aria-label":v[`controls.interactive.ariaLabel`],children:h?(0,H.jsx)(nh,{}):(0,H.jsx)(th,{})}),u]})}ah.displayName=`Controls`;var oh=(0,v.memo)(ah);function sh({id:e,x:t,y:n,width:r,height:i,style:a,color:o,strokeColor:s,strokeWidth:c,className:l,borderRadius:u,shapeRendering:d,selected:f,onClick:p}){let{background:m,backgroundColor:h}=a||{},g=o||m||h;return(0,H.jsx)(`rect`,{className:ir([`react-flow__minimap-node`,{selected:f},l]),x:t,y:n,rx:u,ry:u,width:r,height:i,style:{fill:g,stroke:s,strokeWidth:c},shapeRendering:d,onClick:p?t=>p(t,e):void 0})}var ch=(0,v.memo)(sh),lh=e=>e.nodes.map(e=>e.id),uh=e=>e instanceof Function?e:()=>e;function dh({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=ch,onClick:o}){let s=Y(lh,Rd),c=uh(t),l=uh(e),u=uh(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,H.jsx)(H.Fragment,{children:s.map(e=>(0,H.jsx)(ph,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function fh({id:e,nodeColorFunc:t,nodeStrokeColorFunc:n,nodeClassNameFunc:r,nodeBorderRadius:i,nodeStrokeWidth:a,shapeRendering:o,NodeComponent:s,onClick:c}){let{node:l,x:u,y:d,width:f,height:p}=Y(t=>{let n=t.nodeLookup.get(e);if(!n)return{node:void 0,x:0,y:0,width:0,height:0};let r=n.internals.userNode,{x:i,y:a}=n.internals.positionAbsolute,{width:o,height:s}=Il(r);return{node:r,x:i,y:a,width:o,height:s}},Rd);return!l||l.hidden||!Ll(l)?null:(0,H.jsx)(s,{x:u,y:d,width:f,height:p,style:l.style,selected:!!l.selected,className:r(l),color:t(l),borderRadius:i,strokeColor:n(l),strokeWidth:a,shapeRendering:o,onClick:c,id:l.id})}var ph=(0,v.memo)(fh),mh=(0,v.memo)(dh),hh=200,gh=150,_h=e=>!e.hidden,vh=e=>{let t={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:t,boundingRect:e.nodeLookup.size>0?Sl(al(e.nodeLookup,{filter:_h}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},yh=`react-flow__minimap-desc`;function bh({style:e,className:t,nodeStrokeColor:n,nodeColor:r,nodeClassName:i=``,nodeBorderRadius:a=5,nodeStrokeWidth:o,nodeComponent:s,bgColor:c,maskColor:l,maskStrokeColor:u,maskStrokeWidth:d,position:f=`bottom-right`,onClick:p,onNodeClick:m,pannable:h=!1,zoomable:g=!1,ariaLabel:_,inversePan:y,zoomStep:b=1,offsetScale:x=5}){let S=Ud(),C=(0,v.useRef)(null),{boundingRect:w,viewBB:T,rfId:E,panZoom:D,translateExtent:O,flowWidth:k,flowHeight:A,ariaLabelConfig:j}=Y(vh,Rd),M=e?.width??hh,N=e?.height??gh,ee=w.width/M,te=w.height/N,P=Math.max(ee,te),F=P*M,ne=P*N,re=x*P,ie=w.x-(F-w.width)/2-re,ae=w.y-(ne-w.height)/2-re,I=F+re*2,L=ne+re*2,oe=`${yh}-${E}`,se=(0,v.useRef)(0),ce=(0,v.useRef)();se.current=P,(0,v.useEffect)(()=>{if(C.current&&D)return ce.current=$u({domNode:C.current,panZoom:D,getTransform:()=>S.getState().transform,getViewScale:()=>se.current}),()=>{ce.current?.destroy()}},[D]),(0,v.useEffect)(()=>{ce.current?.update({translateExtent:O,width:k,height:A,inversePan:y,pannable:h,zoomStep:b,zoomable:g})},[h,g,y,b,O,k,A]);let le=p?e=>{let[t,n]=ce.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ue=m?(0,v.useCallback)((e,t)=>{let n=S.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,de=_??j[`minimap.ariaLabel`];return(0,H.jsx)($d,{position:f,style:{...e,"--xy-minimap-background-color-props":typeof c==`string`?c:void 0,"--xy-minimap-mask-background-color-props":typeof l==`string`?l:void 0,"--xy-minimap-mask-stroke-color-props":typeof u==`string`?u:void 0,"--xy-minimap-mask-stroke-width-props":typeof d==`number`?d*P: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 o==`number`?o:void 0},className:ir([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,H.jsxs)(`svg`,{width:M,height:N,viewBox:`${ie} ${ae} ${I} ${L}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":oe,ref:C,onClick:le,children:[de&&(0,H.jsx)(`title`,{id:oe,children:de}),(0,H.jsx)(mh,{onClick:ue,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,H.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${ie-re},${ae-re}h${I+re*2}v${L+re*2}h${-I-re*2}z - M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}bh.displayName=`MiniMap`;var xh=(0,v.memo)(bh),Sh=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Ch={[md.Line]:`right`,[md.Handle]:`bottom-right`};function wh({nodeId:e,position:t,variant:n=md.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let y=ip(),b=typeof e==`string`?e:y,x=Ud(),S=(0,v.useRef)(null),C=n===md.Handle,w=Y((0,v.useCallback)(Sh(C&&p),[C,p]),Rd),T=(0,v.useRef)(null),E=t??Ch[n];return(0,v.useEffect)(()=>{if(!(!S.current||!b))return T.current||=Td({domNode:S.current,nodeId:b,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=x.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=x.getState(),o=[],s={x:e.x,y:e.y},c=r.get(b);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=Mu([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...Rl({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:b,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:b,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:b,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};x.getState().triggerNodeChanges([n])}}),T.current.update({controlPosition:E,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{T.current?.destroy()}},[E,s,c,l,u,d,h,g,_,m]),(0,H.jsx)(`div`,{className:ir([`react-flow__resize-control`,`nodrag`,...E.split(`-`),n,r]),ref:S,style:{...i,scale:w,...o&&{[C?`backgroundColor`:`borderColor`]:o}},children:a})}(0,v.memo)(wh);function Th(e){return e.join(`.`)}function Eh(e,t){return`${Th(e)}::${t}`}function Dh(e){let t=e.indexOf(`::`);if(t===-1)return{contextPath:[],name:e};let n=e.slice(0,t),r=e.slice(t+2);return{contextPath:n===``?[]:n.split(`.`).map(e=>Number(e)),name:r}}function Oh(e,t){return Eh(e,t)}function kh(e){return e.includes(`::`)}function Ah(e){let t=e.indexOf(`[`);return t<=0||!e.endsWith(`]`)?null:{group:e.slice(0,t),key:e.slice(t+1,-1)}}function jh(e,t){if(t.length===0)return null;let n=e[t[0]];for(let e=1;ee.nodes),n=B(e=>e.subworkflowContexts),r=e?.iterationContextPath,i=e?.contextPath??[],a=e?.name,o=r?r.join(`.`):``;return(0,v.useMemo)(()=>{if(r&&r.length>0){let e=jh(n,r);return e?{name:a??``,status:e.status,type:`workflow`,activity:[],error_message:e.workflowFailure?.message,error_type:e.workflowFailure?.error_type}:void 0}if(a)return i.length===0?t[a]:jh(n,i)?.nodes[a]},[`${i.join(`.`)}::${a??``}`,o,t,n])}function Nh(){let e=B(e=>e.selectedNode),t=B(e=>e.nodes),n=B(e=>e.subworkflowContexts);return(0,v.useMemo)(()=>{if(!e)return;let{contextPath:r,name:i}=Dh(e),a=(r.length===0?t:jh(n,r)?.nodes)?.[i];if(a)return a;if(Ah(i)){let e=r.length===0?n:jh(n,r)?.children??[],t;for(let n=e.length-1;n>=0;n--)if(e[n].slotKey===i){t=e[n];break}if(t)return{name:i,status:t.status,type:`workflow`,activity:[],tokens:t.totalTokens||void 0,cost_usd:t.totalCost||void 0,error_message:t.workflowFailure?.message,error_type:t.workflowFailure?.error_type}}},[e,t,n])}function Ph(){let e=B(e=>e.viewContextPath),t=B(e=>e.groupProgress),n=B(e=>e.subworkflowContexts);return(0,v.useMemo)(()=>e.length===0?t:jh(n,e)?.groupProgress??t,[e,t,n])}function Fh(){let e=B(e=>e.viewContextPath),t=B(e=>e.subworkflowContexts);return(0,v.useMemo)(()=>e.length===0?t:jh(t,e)?.children??[],[e,t])}function Ih(){let e=B(e=>e.viewContextPath),t=B(e=>e.agents),n=B(e=>e.routes),r=B(e=>e.parallelGroups),i=B(e=>e.forEachGroups),a=B(e=>e.nodes),o=B(e=>e.groupProgress),s=B(e=>e.entryPoint),c=B(e=>e.subworkflowContexts);return(0,v.useMemo)(()=>{if(e.length===0)return{agents:t,routes:n,parallelGroups:r,forEachGroups:i,nodes:a,groupProgress:o,entryPoint:s,subworkflowContexts:c,parentAgent:null,basePath:[]};let l=jh(c,e);return l?{agents:l.agents,routes:l.routes,parallelGroups:l.parallelGroups,forEachGroups:l.forEachGroups,nodes:l.nodes,groupProgress:l.groupProgress,entryPoint:l.entryPoint,subworkflowContexts:l.children,parentAgent:l.parentAgent,basePath:e}:{agents:t,routes:n,parallelGroups:r,forEachGroups:i,nodes:a,groupProgress:o,entryPoint:s,subworkflowContexts:c,parentAgent:null,basePath:[]}},[e,t,n,r,i,a,o,s,c])}var Lh=o(((e,t)=>{var n=`\0`,r=`\0`,i=``,a=class{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>void 0;_defaultEdgeLabelFn=()=>void 0;_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(e){e&&(this._isDirected=Object.hasOwn(e,`directed`)?e.directed:!0,this._isMultigraph=Object.hasOwn(e,`multigraph`)?e.multigraph:!1,this._isCompound=Object.hasOwn(e,`compound`)?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[r]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,typeof e!=`function`&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter(t=>Object.keys(e._in[t]).length===0)}sinks(){var e=this;return this.nodes().filter(t=>Object.keys(e._out[t]).length===0)}setNodes(e,t){var n=arguments,r=this;return e.forEach(function(e){n.length>1?r.setNode(e,t):r.setNode(e)}),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=r,this._children[e]={},this._children[r][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var n=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(function(e){t.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=r;else{t+=``;for(var n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==r)return t}}children(e=r){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else if(e===r)return this.nodes();else if(this.hasNode(e))return[]}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){let r=new Set(t);for(var n of this.successors(e))r.add(n);return Array.from(r.values())}}isLeaf(e){return(this.isDirected()?this.successors(e):this.neighbors(e)).length===0}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach(function([n,r]){e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))});var r={};function i(e){var a=n.parent(e);return a===void 0||t.hasNode(a)?(r[e]=a,a):a in r?r[a]:i(a)}return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,i(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,typeof e!=`function`&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var n=this,r=arguments;return e.reduce(function(e,i){return r.length>1?n.setEdge(e,i,t):n.setEdge(e,i),i}),this}setEdge(){var e,t,n,r,i=!1,a=arguments[0];typeof a==`object`&&a&&`v`in a?(e=a.v,t=a.w,n=a.name,arguments.length===2&&(r=arguments[1],i=!0)):(e=a,t=arguments[1],n=arguments[3],arguments.length>2&&(r=arguments[2],i=!0)),e=``+e,t=``+t,n!==void 0&&(n=``+n);var s=c(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,s))return i&&(this._edgeLabels[s]=r),this;if(n!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(e),this.setNode(t),this._edgeLabels[s]=i?r:this._defaultEdgeLabelFn(e,t,n);var u=l(this._isDirected,e,t,n);return e=u.v,t=u.w,Object.freeze(u),this._edgeObjs[s]=u,o(this._preds[t],e),o(this._sucs[e],t),this._in[t][s]=u,this._out[e][s]=u,this._edgeCount++,this}edge(e,t,n){var r=arguments.length===1?u(this._isDirected,arguments[0]):c(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(){let e=this.edge(...arguments);return typeof e==`object`?e:{label:e}}hasEdge(e,t,n){var r=arguments.length===1?u(this._isDirected,arguments[0]):c(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,r)}removeEdge(e,t,n){var r=arguments.length===1?u(this._isDirected,arguments[0]):c(this._isDirected,e,t,n),i=this._edgeObjs[r];return i&&(e=i.v,t=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],s(this._preds[t],e),s(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var r=Object.values(n);return t?r.filter(e=>e.v===t):r}}outEdges(e,t){var n=this._out[e];if(n){var r=Object.values(n);return t?r.filter(e=>e.w===t):r}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}};function o(e,t){e[t]?e[t]++:e[t]=1}function s(e,t){--e[t]||delete e[t]}function c(e,t,r,a){var o=``+t,s=``+r;if(!e&&o>s){var c=o;o=s,s=c}return o+i+s+i+(a===void 0?n:a)}function l(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return r&&(s.name=r),s}function u(e,t){return c(e,t.v,t.w,t.name)}t.exports=a})),Rh=o(((e,t)=>{t.exports=`2.2.4`})),zh=o(((e,t)=>{t.exports={Graph:Lh(),version:Rh()}})),Bh=o(((e,t)=>{var n=Lh();t.exports={write:r,read:o};function r(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:i(e),edges:a(e)};return e.graph()!==void 0&&(t.value=structuredClone(e.graph())),t}function i(e){return e.nodes().map(function(t){var n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function a(e){return e.edges().map(function(t){var n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function o(e){var t=new n(e.options).setGraph(e.value);return e.nodes.forEach(function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}})),Vh=o(((e,t)=>{t.exports=n;function n(e){var t={},n=[],r;function i(n){Object.hasOwn(t,n)||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}})),Hh=o(((e,t)=>{t.exports=class{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(e){return e.key})}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){var n=this._keyIndices;if(e=String(e),!Object.hasOwn(n,e)){var r=this._arr,i=r.length;return n[e]=i,r.push({key:e,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw Error(`New priority is greater than current priority. Key: `+e+` Old: `+this._arr[n].priority+` New: `+t);this._arr[n].priority=t,this._decrease(n)}_heapify(e){var t=this._arr,n=2*e,r=n+1,i=e;n>1,!(t[r].priority{var n=Hh();t.exports=i;var r=()=>1;function i(e,t,n,i){return a(e,String(t),n||r,i||function(t){return e.outEdges(t)})}function a(e,t,r,i){var a={},o=new n,s,c,l=function(e){var t=e.v===s?e.w:e.v,n=a[t],i=r(e),l=c.distance+i;if(i<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+i);l0&&(s=o.removeMin(),c=a[s],c.distance!==1/0);)i(s).forEach(l);return a}})),Wh=o(((e,t)=>{var n=Uh();t.exports=r;function r(e,t,r){return e.nodes().reduce(function(i,a){return i[a]=n(e,a,t,r),i},{})}})),Gh=o(((e,t)=>{t.exports=n;function n(e){var t=0,n=[],r={},i=[];function a(o){var s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){Object.hasOwn(r,e)?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){var c=[],l;do l=n.pop(),r[l].onStack=!1,c.push(l);while(o!==l);i.push(c)}}return e.nodes().forEach(function(e){Object.hasOwn(r,e)||a(e)}),i}})),Kh=o(((e,t)=>{var n=Gh();t.exports=r;function r(e){return n(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}})),qh=o(((e,t)=>{t.exports=r;var n=()=>1;function r(e,t,r){return i(e,t||n,r||function(t){return e.outEdges(t)})}function i(e,t,n){var r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0})}),n(e).forEach(function(n){var i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){var t=r[e];i.forEach(function(n){var a=r[n];i.forEach(function(n){var r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s{function n(e){var t={},n={},i=[];function a(o){if(Object.hasOwn(n,o))throw new r;Object.hasOwn(t,o)||(n[o]=!0,t[o]=!0,e.predecessors(o).forEach(a),delete n[o],i.push(o))}if(e.sinks().forEach(a),Object.keys(t).length!==e.nodeCount())throw new r;return i}var r=class extends Error{constructor(){super(...arguments)}};t.exports=n,n.CycleException=r})),Yh=o(((e,t)=>{var n=Jh();t.exports=r;function r(e){try{n(e)}catch(e){if(e instanceof n.CycleException)return!1;throw e}return!0}})),Xh=o(((e,t)=>{t.exports=n;function n(e,t,n){Array.isArray(t)||(t=[t]);var a=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),o=n===`post`?r:i,s=[],c={};return t.forEach(t=>{if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);o(t,a,c,s)}),s}function r(e,t,n,r){for(var i=[[e,!1]];i.length>0;){var o=i.pop();o[1]?r.push(o[0]):Object.hasOwn(n,o[0])||(n[o[0]]=!0,i.push([o[0],!0]),a(t(o[0]),e=>i.push([e,!1])))}}function i(e,t,n,r){for(var i=[e];i.length>0;){var o=i.pop();Object.hasOwn(n,o)||(n[o]=!0,r.push(o),a(t(o),e=>i.push(e)))}}function a(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}})),Zh=o(((e,t)=>{var n=Xh();t.exports=r;function r(e,t){return n(e,t,`post`)}})),Qh=o(((e,t)=>{var n=Xh();t.exports=r;function r(e,t){return n(e,t,`pre`)}})),$h=o(((e,t)=>{var n=Lh(),r=Hh();t.exports=i;function i(e,t){var i=new n,a={},o=new r,s;function c(e){var n=e.v===s?e.w:e.v,r=o.priority(n);if(r!==void 0){var i=t(e);i0;){if(s=o.removeMin(),Object.hasOwn(a,s))i.setEdge(s,a[s]);else if(l)throw Error(`Input graph is not connected: `+e);else l=!0;e.nodeEdges(s).forEach(c)}return i}})),eg=o(((e,t)=>{t.exports={components:Vh(),dijkstra:Uh(),dijkstraAll:Wh(),findCycles:Kh(),floydWarshall:qh(),isAcyclic:Yh(),postorder:Zh(),preorder:Qh(),prim:$h(),tarjan:Gh(),topsort:Jh()}})),tg=o(((e,t)=>{var n=zh();t.exports={Graph:n.Graph,json:Bh(),alg:eg(),version:n.version}})),ng=o(((e,t)=>{var n=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return r(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&r(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,i)),n=n._prev;return`[`+e.join(`, `)+`]`}};function r(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function i(e,t){if(e!==`_next`&&e!==`_prev`)return t}t.exports=n})),rg=o(((e,t)=>{var n=tg().Graph,r=ng();t.exports=a;var i=()=>1;function a(e,t){if(e.nodeCount()<=1)return[];let n=c(e,t||i);return o(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w))}function o(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)s(e,t,n,o);for(;o=i.dequeue();)s(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i].dequeue(),o){r=r.concat(s(e,t,n,o,!0));break}}}return r}function s(e,t,n,r,i){let a=i?[]:void 0;return e.inEdges(r.v).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,l(t,n,s)}),e.outEdges(r.v).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,l(t,n,o)}),e.removeNode(r.v),a}function c(e,t){let i=new n,a=0,o=0;e.nodes().forEach(e=>{i.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let n=i.edge(e.v,e.w)||0,r=t(e),s=n+r;i.setEdge(e.v,e.w,s),o=Math.max(o,i.node(e.v).out+=r),a=Math.max(a,i.node(e.w).in+=r)});let s=u(o+a+3).map(()=>new r),c=a+1;return i.nodes().forEach(e=>{l(s,c,i.node(e))}),{graph:i,buckets:s,zeroIdx:c}}function l(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}function u(e){let t=[];for(let n=0;n{var n=tg().Graph;t.exports={addBorderNode:f,addDummyNode:r,applyWithChunking:h,asNonCompoundGraph:a,buildLayerMatrix:l,intersectRect:c,mapValues:w,maxRank:g,normalizeRanks:u,notime:y,partition:_,pick:C,predecessorWeights:s,range:S,removeEmptyRanks:d,simplify:i,successorWeights:o,time:v,uniqueId:x,zipObject:T};function r(e,t,n,r){for(var i=r;e.hasNode(i);)i=x(r);return n.dummy=t,e.setNode(i,n),i}function i(e){let t=new n().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function a(e){let t=new n({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function o(e){let t=e.nodes().map(t=>{let n={};return e.outEdges(t).forEach(t=>{n[t.w]=(n[t.w]||0)+e.edge(t).weight}),n});return T(e.nodes(),t)}function s(e){let t=e.nodes().map(t=>{let n={};return e.inEdges(t).forEach(t=>{n[t.v]=(n[t.v]||0)+e.edge(t).weight}),n});return T(e.nodes(),t)}function c(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function l(e){let t=S(g(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i][r.order]=n)}),t}function u(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=h(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function d(e){let t=e.nodes().map(t=>e.node(t).rank),n=h(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function f(e,t,n,i){let a={width:0,height:0};return arguments.length>=4&&(a.rank=n,a.order=i),r(e,`border`,a,t)}function p(e,t=m){let n=[];for(let r=0;rm){let n=p(t);return e.apply(null,n.map(t=>e.apply(null,t)))}else return e.apply(null,t)}function g(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return h(Math.max,t)}function _(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function v(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function y(e,t){return t()}var b=0;function x(e){return e+(``+ ++b)}function S(e,t,n=1){t??(t=e,e=0);let r=e=>ete[t]),Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function T(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}})),ag=o(((e,t)=>{var n=rg(),r=ig().uniqueId;t.exports={run:i,undo:o};function i(e){(e.graph().acyclicer===`greedy`?n(e,t(e)):a(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,r(`rev`))});function t(e){return t=>e.edge(t).weight}}function a(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function o(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}})),og=o(((e,t)=>{var n=ig();t.exports={run:r,undo:a};function r(e){e.graph().dummyChains=[],e.edges().forEach(t=>i(e,t))}function i(e,t){let r=t.v,i=e.node(r).rank,a=t.w,o=e.node(a).rank,s=t.name,c=e.edge(t),l=c.labelRank;if(o===i+1)return;e.removeEdge(t);let u,d,f;for(f=0,++i;i{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}})),sg=o(((e,t)=>{var{applyWithChunking:n}=ig();t.exports={longestPath:r,slack:i};function r(e){var t={};function r(i){var a=e.node(i);if(Object.hasOwn(t,i))return a.rank;t[i]=!0;let o=e.outEdges(i).map(t=>t==null?1/0:r(t.w)-e.edge(t).minlen);var s=n(Math.min,o);return s===1/0&&(s=0),a.rank=s}e.sources().forEach(r)}function i(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}})),cg=o(((e,t)=>{var n=tg().Graph,r=sg().slack;t.exports=i;function i(e){var t=new n({directed:!1}),i=e.nodes()[0],c=e.nodeCount();t.setNode(i,{});for(var l,u;a(t,e){var o=a.v,s=i===o?a.w:o;!e.hasNode(s)&&!r(t,a)&&(e.setNode(s,{}),e.setEdge(i,s,{}),n(s))})}return e.nodes().forEach(n),e.nodeCount()}function o(e,t){return t.edges().reduce((n,i)=>{let a=1/0;return e.hasNode(i.v)!==e.hasNode(i.w)&&(a=r(t,i)),at.node(e).rank+=n)}})),lg=o(((e,t)=>{var n=cg(),r=sg().slack,i=sg().longestPath,a=tg().alg.preorder,o=tg().alg.postorder,s=ig().simplify;t.exports=c,c.initLowLimValues=f,c.initCutValues=l,c.calcCutValue=d,c.leaveEdge=m,c.enterEdge=h,c.exchangeEdges=g;function c(e){e=s(e),i(e);var t=n(e);f(t),l(t,e);for(var r,a;r=m(t);)a=h(t,e,r),g(t,e,r,a)}function l(e,t){var n=o(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>u(e,t,n))}function u(e,t,n){var r=e.node(n).parent;e.edge(n,r).cutvalue=d(e,t,n)}function d(e,t,n){var r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;return a||=(i=!1,t.edge(r,n)),o=a.weight,t.nodeEdges(n).forEach(a=>{var s=a.v===n,c=s?a.w:a.v;if(c!==r){var l=s===i,u=t.edge(a).weight;if(o+=l?u:-u,v(e,n,c)){var d=e.edge(n,c).cutvalue;o+=l?-d:d}}}),o}function f(e,t){arguments.length<2&&(t=e.nodes()[0]),p(e,{},1,t)}function p(e,t,n,r,i){var a=n,o=e.node(r);return t[r]=!0,e.neighbors(r).forEach(i=>{Object.hasOwn(t,i)||(n=p(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function m(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function h(e,t,n){var i=n.v,a=n.w;t.hasEdge(i,a)||(i=n.w,a=n.v);var o=e.node(i),s=e.node(a),c=o,l=!1;return o.lim>s.lim&&(c=s,l=!0),t.edges().filter(t=>l===y(e,e.node(t.v),c)&&l!==y(e,e.node(t.w),c)).reduce((e,n)=>r(t,n)!t.node(e).parent));n=n.slice(1),n.forEach(n=>{var r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function v(e,t,n){return e.hasEdge(t,n)}function y(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}})),ug=o(((e,t)=>{var n=sg().longestPath,r=cg(),i=lg();t.exports=a;function a(e){var t=e.graph().ranker;if(t instanceof Function)return t(e);switch(e.graph().ranker){case`network-simplex`:c(e);break;case`tight-tree`:s(e);break;case`longest-path`:o(e);break;case`none`:break;default:c(e)}}var o=n;function s(e){n(e),r(e)}function c(e){i(e)}})),dg=o(((e,t)=>{t.exports=n;function n(e){let t=i(e);e.graph().dummyChains.forEach(n=>{let i=e.node(n),a=i.edgeObj,o=r(e,t,a.v,a.w),s=o.path,c=o.lca,l=0,u=s[l],d=!0;for(;n!==a.w;){if(i=e.node(n),d){for(;(u=s[l])!==c&&e.node(u).maxRanko||s>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)a.push(c);return{path:i.concat(a.reverse()),lca:l}}function i(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children().forEach(r),t}})),fg=o(((e,t)=>{var n=ig();t.exports={run:r,cleanup:s};function r(e){let t=n.addDummyNode(e,`root`,{},`_root`),r=a(e),s=Object.values(r),c=n.applyWithChunking(Math.max,s)-1,l=2*c+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=l);let u=o(e)+1;e.children().forEach(n=>i(e,t,l,u,c,r,n)),e.graph().nodeRankFactor=l}function i(e,t,r,a,o,s,c){let l=e.children(c);if(!l.length){c!==t&&e.setEdge(t,c,{weight:0,minlen:r});return}let u=n.addBorderNode(e,`_bt`),d=n.addBorderNode(e,`_bb`),f=e.node(c);e.setParent(u,c),f.borderTop=u,e.setParent(d,c),f.borderBottom=d,l.forEach(n=>{i(e,t,r,a,o,s,n);let l=e.node(n),f=l.borderTop?l.borderTop:n,p=l.borderBottom?l.borderBottom:n,m=l.borderTop?a:2*a,h=f===p?o-s[c]+1:1;e.setEdge(u,f,{weight:m,minlen:h,nestingEdge:!0}),e.setEdge(p,d,{weight:m,minlen:h,nestingEdge:!0})}),e.parent(c)||e.setEdge(t,u,{weight:0,minlen:o+s[c]})}function a(e){var t={};function n(r,i){var a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children().forEach(e=>n(e,1)),t}function o(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function s(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}})),pg=o(((e,t)=>{var n=ig();t.exports=r;function r(e){function t(n){let r=e.children(n),a=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(a,`minRank`)){a.borderLeft=[],a.borderRight=[];for(let t=a.minRank,r=a.maxRank+1;t{t.exports={adjust:n,undo:r};function n(e){let t=e.graph().rankdir.toLowerCase();(t===`lr`||t===`rl`)&&i(e)}function r(e){let t=e.graph().rankdir.toLowerCase();(t===`bt`||t===`rl`)&&o(e),(t===`lr`||t===`rl`)&&(c(e),i(e))}function i(e){e.nodes().forEach(t=>a(e.node(t))),e.edges().forEach(t=>a(e.edge(t)))}function a(e){let t=e.width;e.width=e.height,e.height=t}function o(e){e.nodes().forEach(t=>s(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(s),Object.hasOwn(n,`y`)&&s(n)})}function s(e){e.y=-e.y}function c(e){e.nodes().forEach(t=>l(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(l),Object.hasOwn(n,`x`)&&l(n)})}function l(e){let t=e.x;e.x=e.y,e.y=t}})),hg=o(((e,t)=>{var n=ig();t.exports=r;function r(e){let t={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=n.applyWithChunking(Math.max,i),o=n.range(a+1).map(()=>[]);function s(n){t[n]||(t[n]=!0,o[e.node(n).rank].push(n),e.successors(n).forEach(s))}return r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(s),o}})),gg=o(((e,t)=>{var n=ig().zipObject;t.exports=r;function r(e,t){let n=0;for(let r=1;rt)),a=t.flatMap(t=>e.outEdges(t).map(t=>({pos:i[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos)),o=1;for(;o{let t=e.pos+o;c[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=c[t+1]),t=t-1>>1,c[t]+=e.weight;l+=e.weight*n}),l}})),_g=o(((e,t)=>{t.exports=n;function n(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(n.length){let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}else return{v:t}})}})),vg=o(((e,t)=>{var n=ig();t.exports=r;function r(e,t){let n={};return e.forEach((e,t)=>{let r=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight)}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(n[e.w]))}),i(Object.values(n).filter(e=>!e.indegree))}function i(e){let t=[];function r(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&a(e,t)}}function i(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let n=e.pop();t.push(n),n.in.reverse().forEach(r(n)),n.out.forEach(i(n))}return t.filter(e=>!e.merged).map(e=>n.pick(e,[`vs`,`i`,`barycenter`,`weight`]))}function a(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}})),yg=o(((e,t)=>{var n=ig();t.exports=r;function r(e,t){let r=n.partition(e,e=>Object.hasOwn(e,`barycenter`)),o=r.lhs,s=r.rhs.sort((e,t)=>t.i-e.i),c=[],l=0,u=0,d=0;o.sort(a(!!t)),d=i(c,s,d),o.forEach(e=>{d+=e.vs.length,c.push(e.vs),l+=e.barycenter*e.weight,u+=e.weight,d=i(c,s,d)});let f={vs:c.flat(!0)};return u&&(f.barycenter=l/u,f.weight=u),f}function i(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function a(e){return(t,n)=>t.barycentern.barycenter?1:e?n.i-t.i:t.i-n.i}})),bg=o(((e,t)=>{var n=_g(),r=vg(),i=yg();t.exports=a;function a(e,t,c,l){let u=e.children(t),d=e.node(t),f=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};f&&(u=u.filter(e=>e!==f&&e!==p));let h=n(e,u);h.forEach(t=>{if(e.children(t.v).length){let n=a(e,t.v,c,l);m[t.v]=n,Object.hasOwn(n,`barycenter`)&&s(t,n)}});let g=r(h,c);o(g,m);let _=i(g,l);if(f&&(_.vs=[f,_.vs,p].flat(!0),e.predecessors(f).length)){let t=e.node(e.predecessors(f)[0]),n=e.node(e.predecessors(p)[0]);Object.hasOwn(_,`barycenter`)||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+t.order+n.order)/(_.weight+2),_.weight+=2}return _}function o(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function s(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}})),xg=o(((e,t)=>{var n=tg().Graph,r=ig();t.exports=i;function i(e,t,r,i){i||=e.nodes();let o=a(e),s=new n({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(t=>e.node(t));return i.forEach(n=>{let i=e.node(n),a=e.parent(n);(i.rank===t||i.minRank<=t&&t<=i.maxRank)&&(s.setNode(n),s.setParent(n,a||o),e[r](n).forEach(t=>{let r=t.v===n?t.w:t.v,i=s.edge(r,n),a=i===void 0?0:i.weight;s.setEdge(r,n,{weight:e.edge(t).weight+a})}),Object.hasOwn(i,`minRank`)&&s.setNode(n,{borderLeft:i.borderLeft[t],borderRight:i.borderRight[t]}))}),s}function a(e){for(var t;e.hasNode(t=r.uniqueId(`_root`)););return t}})),Sg=o(((e,t)=>{t.exports=n;function n(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}})),Cg=o(((e,t)=>{var n=hg(),r=gg(),i=bg(),a=xg(),o=Sg(),s=tg().Graph,c=ig();t.exports=l;function l(e,t){if(t&&typeof t.customOrder==`function`){t.customOrder(e,l);return}let i=c.maxRank(e),a=u(e,c.range(1,i+1),`inEdges`),o=u(e,c.range(i-1,-1,-1),`outEdges`),s=n(e);if(f(e,s),t&&t.disableOptimalOrderHeuristic)return;let p=1/0,m;for(let t=0,n=0;n<4;++t,++n){d(t%2?a:o,t%4>=2),s=c.buildLayerMatrix(e);let i=r(e,s);i{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return a(e,t,n,r.get(t)||[])})}function d(e,t){let n=new s;e.forEach(function(e){let r=e.graph().root,a=i(e,r,n,t);a.vs.forEach((t,n)=>e.node(t).order=n),o(e,n,a.vs)})}function f(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}})),wg=o(((e,t)=>{var n=tg().Graph,r=ig();t.exports={positionX:h,findType1Conflicts:i,findType2Conflicts:a,addConflict:s,hasConflict:c,verticalAlignment:l,horizontalCompaction:u,alignCoordinates:p,findSmallestWidthAlignment:f,balance:m};function i(e,t){let n={};function r(t,r){let i=0,a=0,c=t.length,l=r[r.length-1];return r.forEach((t,u)=>{let d=o(e,t),f=d?e.node(d).order:c;(d||t===l)&&(r.slice(a,u+1).forEach(t=>{e.predecessors(t).forEach(r=>{let a=e.node(r),o=a.order;(o{l=t[r],e.node(l).dummy&&e.predecessors(l).forEach(t=>{let r=e.node(t);r.dummy&&(r.orderc)&&s(n,t,l)})})}function a(t,n){let r=-1,a,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);t.length&&(a=e.node(t[0]).order,i(n,o,c,r,a),o=c,r=a)}i(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(a),n}function o(e,t){if(e.node(t).dummy)return e.predecessors(t).find(t=>e.node(t).dummy)}function s(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function c(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function l(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s.length){s=s.sort((e,t)=>o[e]-o[t]);let r=(s.length-1)/2;for(let l=Math.floor(r),u=Math.ceil(r);l<=u;++l){let r=s[l];a[e]===e&&tMath.max(e,a[t.v]+o.edge(t)),0)}function u(t){let n=o.outEdges(t).reduce((e,t)=>Math.min(e,a[t.w]-o.edge(t)),1/0),r=e.node(t);n!==1/0&&r.borderType!==s&&(a[t]=Math.max(a[t],n))}return c(l,o.predecessors.bind(o)),c(u,o.successors.bind(o)),Object.keys(r).forEach(e=>a[e]=a[n[e]]),a}function d(e,t,r,i){let a=new n,o=e.graph(),s=g(o.nodesep,o.edgesep,i);return t.forEach(t=>{let n;t.forEach(t=>{let i=r[t];if(a.setNode(i),n){var o=r[n],c=a.edge(o,i);a.setEdge(o,i,Math.max(s(e,t,n),c||0))}n=t})}),a}function f(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=_(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a{[`l`,`r`].forEach(o=>{let s=n+o,c=e[s];if(c===t)return;let l=Object.values(c),u=i-r.applyWithChunking(Math.min,l);o!==`l`&&(u=a-r.applyWithChunking(Math.max,l)),u&&(e[s]=r.mapValues(c,e=>e+u))})})}function m(e,t){return r.mapValues(e.ul,(n,r)=>{if(t)return e[t.toLowerCase()][r];{let t=Object.values(e).map(e=>e[r]).sort((e,t)=>e-t);return(t[1]+t[2])/2}})}function h(e){let t=r.buildLayerMatrix(e),n=Object.assign(i(e,t),a(e,t)),o={},s;return[`u`,`d`].forEach(i=>{s=i===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(s=s.map(e=>Object.values(e).reverse()));let a=(i===`u`?e.predecessors:e.successors).bind(e),c=l(e,s,n,a),d=u(e,s,c.root,c.align,t===`r`);t===`r`&&(d=r.mapValues(d,e=>-e)),o[i+t]=d})}),p(o,f(e,o)),m(o,e.graph().align)}function g(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2;break}if(l&&(c+=n?l:-l),l=0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2;break}return l&&(c+=n?l:-l),l=0,c}}function _(e,t){return e.node(t).width}})),Tg=o(((e,t)=>{var n=ig(),r=wg().positionX;t.exports=i;function i(e){e=n.asNonCompoundGraph(e),a(e),Object.entries(r(e)).forEach(([t,n])=>e.node(t).x=n)}function a(e){let t=n.buildLayerMatrix(e),r=e.graph().ranksep,i=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height;return t>r?t:r},0);t.forEach(t=>e.node(t).y=i+n/2),i+=n+r})}})),Eg=o(((e,t)=>{var n=ag(),r=og(),i=ug(),a=ig().normalizeRanks,o=dg(),s=ig().removeEmptyRanks,c=fg(),l=pg(),u=mg(),d=Cg(),f=Tg(),p=ig(),m=tg().Graph;t.exports=h;function h(e,t){let n=t&&t.debugTiming?p.time:p.notime;n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>E(e));n(` runLayout`,()=>g(r,n,t)),n(` updateInputGraph`,()=>_(e,r))})}function g(e,t,m){t(` makeSpaceForEdgeLabels`,()=>D(e)),t(` removeSelfEdges`,()=>P(e)),t(` acyclic`,()=>n.run(e)),t(` nestingGraph.run`,()=>c.run(e)),t(` rank`,()=>i(p.asNonCompoundGraph(e))),t(` injectEdgeLabelProxies`,()=>O(e)),t(` removeEmptyRanks`,()=>s(e)),t(` nestingGraph.cleanup`,()=>c.cleanup(e)),t(` normalizeRanks`,()=>a(e)),t(` assignRankMinMax`,()=>k(e)),t(` removeEdgeLabelProxies`,()=>A(e)),t(` normalize.run`,()=>r.run(e)),t(` parentDummyChains`,()=>o(e)),t(` addBorderSegments`,()=>l(e)),t(` order`,()=>d(e,m)),t(` insertSelfEdges`,()=>F(e)),t(` adjustCoordinateSystem`,()=>u.adjust(e)),t(` position`,()=>f(e)),t(` positionSelfEdges`,()=>ne(e)),t(` removeBorderNodes`,()=>te(e)),t(` normalize.undo`,()=>r.undo(e)),t(` fixupEdgeLabelCoords`,()=>N(e)),t(` undoCoordinateSystem`,()=>u.undo(e)),t(` translateGraph`,()=>j(e)),t(` assignNodeIntersects`,()=>M(e)),t(` reversePoints`,()=>ee(e)),t(` acyclic.undo`,()=>n.undo(e))}function _(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var v=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],y={ranksep:50,edgesep:20,nodesep:50,rankdir:`tb`},b=[`acyclicer`,`ranker`,`rankdir`,`align`],x=[`width`,`height`,`rank`],S={width:0,height:0},C=[`minlen`,`weight`,`width`,`height`,`labeloffset`],w={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},T=[`labelpos`];function E(e){let t=new m({multigraph:!0,compound:!0}),n=ie(e.graph());return t.setGraph(Object.assign({},y,re(n,v),p.pick(n,b))),e.nodes().forEach(n=>{let r=re(ie(e.node(n)),x);Object.keys(S).forEach(e=>{r[e]===void 0&&(r[e]=S[e])}),t.setNode(n,r),t.setParent(n,e.parent(n))}),e.edges().forEach(n=>{let r=ie(e.edge(n));t.setEdge(n,Object.assign({},w,re(r,C),p.pick(r,T)))}),t}function D(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function O(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),r={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};p.addDummyNode(e,`edge-proxy`,r,`_ep`)}})}function k(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function A(e){e.nodes().forEach(t=>{let n=e.node(t);n.dummy===`edge-proxy`&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function j(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function M(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(p.intersectRect(r,a)),n.points.push(p.intersectRect(i,o))})}function N(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset;break}})}function ee(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function te(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function P(e){e.edges().forEach(t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function F(e){p.buildLayerMatrix(e).forEach(t=>{var n=0;t.forEach((t,r)=>{var i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{p.addDummyNode(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function ne(e){e.nodes().forEach(t=>{var n=e.node(t);if(n.dummy===`selfedge`){var r=e.node(n.e.v),i=r.x+r.width/2,a=r.y,o=n.x-i,s=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*o/3,y:a-s},{x:i+5*o/6,y:a-s},{x:i+o,y:a},{x:i+5*o/6,y:a+s},{x:i+2*o/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}})}function re(e,t){return p.mapValues(p.pick(e,t),Number)}function ie(e){var t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}})),Dg=o(((e,t)=>{var n=ig(),r=tg().Graph;t.exports={debugOrdering:i};function i(e){let t=n.buildLayerMatrix(e),i=new r({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{i.setNode(t,{label:t}),i.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>i.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let n=`layer`+t;i.setNode(n,{rank:`same`}),e.reduce((e,t)=>(i.setEdge(e,t,{style:`invis`}),t))}),i}})),Og=o(((e,t)=>{t.exports=`1.1.8`})),kg=l(o(((e,t)=>{t.exports={graphlib:tg(),layout:Eg(),debug:Dg(),util:{time:ig().time,notime:ig().notime},version:Og()}}))(),1),Ag=200,jg=56,Mg=20,Ng=40,Pg=20,Fg=12,Ig=16,Lg=46,Rg=16,zg=Ag,Bg=14;function Vg(e){return{agents:e.agents,routes:e.routes,parallelGroups:e.parallelGroups,forEachGroups:e.forEachGroups,nodes:e.nodes,groupProgress:e.groupProgress,entryPoint:e.entryPoint,parentAgent:e.parentAgent,children:e.children}}function Hg(e,t,n){let{nodes:r,edges:i}=qg(e,t,n);return{nodes:r,edges:i}}function Ug(e,t,n){let r=[],i=(e,t,n)=>{for(let a of e){if((a.type||`agent`)!==`workflow`)continue;let e=t.findIndex(e=>e.slotKey===a.name);if(e<0)continue;let o=t[e];o.agents.length!==0&&(r.push(Th([...n,e])),i(o.agents,o.children,[...n,e]))}let a=new Set;for(let e of t){let t=Ah(e.slotKey);!t||a.has(t.group)||(a.add(t.group),r.push(Oh(n,t.group)))}};return i(e,t,n),r}function Wg(e,t){let n=[],r=e,i=[];for(let e of t){let t=r[e];if(!t)break;let a=Ah(t.slotKey);a&&n.push(Oh(i,a.group)),i.push(e),n.push(Th(i)),r=t.children}return n}function Gg(e,t){let n=[];for(let r=0;r0,m=p&&r.has(u),h={label:f?f.key:c.slotKey,name:c.slotKey,contextPath:t,type:`workflow`,status:c.status||`pending`,canExpand:p,expanded:m,childContextKey:u,childName:c.workflowName||void 0,iterationContextPath:e,isForEachIteration:!0};if(m){let t=qg(Vg(c),e,r,!0),l=t.width+Ig*2,u=t.height+Lg+Rg;i.push({id:d,type:`workflowNode`,position:{x:Ig,y:o},parentId:n,extent:`parent`,data:h,style:{width:l,height:u}});for(let e of t.nodes)e.parentId||(e.parentId=d,e.extent=`parent`,e.position={x:e.position.x+Ig,y:e.position.y+Lg}),i.push(e);for(let e of t.edges)a.push(e);o+=u+Bg,s=Math.max(s,l)}else i.push({id:d,type:`workflowNode`,position:{x:Ig,y:o},parentId:n,extent:`parent`,data:h}),o+=70}return{nodes:i,edges:a,width:s+Ig*2,height:(e.length>0?o-Bg:Lg)+Rg}}function qg(e,t,n,r=!1){let i=[],a=[],o=new Set,s=new Set,c=e.parentAgent!=null,l=e=>Eh(t,e),u=[],d=[],f=[],p=new Map;for(let t of e.parallelGroups)for(let e of t.agents)s.add(e),p.set(e,t.name);for(let n of e.parallelGroups){let r=e.nodes[n.name],a=n.agents.length,s=Ng+a*jg+(a-1)*Fg+Pg;i.push({id:l(n.name),type:`groupNode`,position:{x:0,y:0},data:{label:n.name,name:n.name,contextPath:t,type:`parallel_group`,status:r?.status||`pending`,groupName:n.name,progress:e.groupProgress[n.name]},style:{width:240,height:s}});for(let r=0;r0,u=Oh(t,r.name);if(c&&n.has(u)){let o=Kg(s,t,u,n);i.push({id:l(r.name),type:`groupNode`,position:{x:0,y:0},data:{label:r.name,name:r.name,contextPath:t,type:`for_each_group`,status:a?.status||`pending`,groupName:r.name,progress:e.groupProgress[r.name],expanded:!0,canExpand:!0,groupExpansionKey:u},style:{width:o.width,height:o.height}});for(let e of o.nodes)d.push(e);for(let e of o.edges)f.push(e)}else i.push({id:l(r.name),type:`groupNode`,position:{x:0,y:0},data:{label:r.name,name:r.name,contextPath:t,type:`for_each_group`,status:a?.status||`pending`,groupName:r.name,progress:e.groupProgress[r.name],expanded:!1,canExpand:c,groupExpansionKey:c?u:void 0}});o.add(r.name)}for(let r of e.agents){if(o.has(r.name)||s.has(r.name))continue;let a=r.type||`agent`,c=e.nodes[r.name],d=`agentNode`;if(a===`script`?d=`scriptNode`:a===`set`?d=`setNode`:a===`human_gate`?d=`gateNode`:a===`workflow`?d=`workflowNode`:a===`wait`?d=`waitNode`:a===`terminate`&&(d=`terminateNode`),a===`workflow`){let s=e.children.findIndex(e=>e.slotKey===r.name),d=s>=0?e.children[s]:void 0,f=s>=0?Th([...t,s]):void 0,p=!!d&&d.agents.length>0;if(p&&f!=null&&n.has(f)&&d){let e=qg(Vg(d),[...t,s],n,!0),o=e.width+Ig*2,p=e.height+Lg+Rg;i.push({id:l(r.name),type:`workflowNode`,position:{x:0,y:0},data:{label:r.name,name:r.name,contextPath:t,type:a,status:c?.status||`pending`,expanded:!0,canExpand:!0,childContextKey:f,childName:d.workflowName||void 0},style:{width:o,height:p}}),u.push({containerId:l(r.name),sub:e})}else i.push({id:l(r.name),type:`workflowNode`,position:{x:0,y:0},data:{label:r.name,name:r.name,contextPath:t,type:a,status:c?.status||`pending`,expanded:!1,canExpand:p,childContextKey:f,childName:d?.workflowName||void 0}});o.add(r.name);continue}i.push({id:l(r.name),type:d,position:{x:0,y:0},data:{label:r.name,name:r.name,contextPath:t,type:a,status:c?.status||`pending`}}),o.add(r.name)}let m=!1;for(let t of e.routes)t.to===`$end`&&(m=!0);if(m){let n=e.nodes.$end;i.push({id:l(`$end`),type:c?`egressNode`:`endNode`,position:{x:0,y:0},data:{label:`$end`,name:`$end`,contextPath:t,type:c?`egress`:`end`,status:n?.status||`pending`,...c&&!r?{parentAgent:e.parentAgent??void 0}:{}}})}if(e.entryPoint){let n=e.nodes.$start;i.push({id:l(`$start`),type:c?`ingressNode`:`startNode`,position:{x:0,y:0},data:{label:`$start`,name:`$start`,contextPath:t,type:c?`ingress`:`start`,status:n?.status||`pending`,...c&&!r?{parentAgent:e.parentAgent??void 0}:{}}}),a.push({id:`${l(`$start`)}->@entry`,source:l(`$start`),target:l(e.entryPoint),type:`animatedEdge`,data:{},animated:!1})}let h=new Set(i.map(e=>e.id)),g=new Map;for(let e of i)e.parentId&&g.set(e.id,e.parentId);let _=new Map;for(let t of e.routes){let e=g.get(l(t.from))??l(t.from),n=g.get(l(t.to))??l(t.to);if(!h.has(e)||!h.has(n)||e===n)continue;let r=`${e}->${n}`,i=_.get(r);if(i){i.when!==t.when&&(a[i.idx].data={when:void 0});continue}let o=a.length;_.set(r,{when:t.when,idx:o});let s=`${r}${t.when?`[${t.when}]`:``}`;a.push({id:s,source:e,target:n,type:`animatedEdge`,data:{when:t.when},animated:!1})}let{width:v,height:y}=Xg(i,a,Jg(i,a,l(`$start`)));for(let{containerId:e,sub:t}of u){for(let n of t.nodes)n.parentId||(n.parentId=e,n.extent=`parent`,n.position={x:n.position.x+Ig,y:n.position.y+Lg}),i.push(n);for(let e of t.edges)a.push(e)}for(let e of d)i.push(e);for(let e of f)a.push(e);return{nodes:i,edges:a,width:v,height:y}}function Jg(e,t,n){let r=new Set(e.filter(e=>!e.parentId).map(e=>e.id)),i=new Map;for(let e of t)!r.has(e.source)||!r.has(e.target)||(i.has(e.source)||i.set(e.source,[]),i.get(e.source).push({target:e.target,edgeId:e.id}));for(let e of i.values())e.sort((e,t)=>e.targett.target));let a=new Set,o=new Set,s=new Set,c=e=>{s.add(e),o.add(e);for(let{target:t,edgeId:n}of i.get(e)??[])o.has(t)?a.add(n):s.has(t)||c(t);o.delete(e)};r.has(n)&&c(n);for(let e of[...i.keys()].sort())s.has(e)||c(e);return a}function Yg(e){let t=e.style?.width,n=e.style?.height;return typeof t==`number`&&typeof n==`number`?{w:t,h:n}:{w:Ag,h:jg}}function Xg(e,t,n){let r=new kg.default.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:`TB`,nodesep:50,ranksep:70,marginx:30,marginy:30});for(let t of e){if(t.parentId)continue;let{w:e,h:n}=Yg(t);r.setNode(t.id,{width:e,height:n})}for(let e of t)!r.hasNode(e.source)||!r.hasNode(e.target)||(n.has(e.id)?r.setEdge(e.target,e.source):r.setEdge(e.source,e.target));kg.default.layout(r);let i=1/0,a=1/0,o=-1/0,s=-1/0;for(let t of e){if(t.parentId)continue;let e=r.node(t.id);if(!e)continue;let{w:n,h:c}=Yg(t),l=e.x-n/2,u=e.y-c/2;t.position={x:l,y:u},i=Math.min(i,l),a=Math.min(a,u),o=Math.max(o,l+n),s=Math.max(s,u+c)}if(!Number.isFinite(i))return{width:Ag,height:jg};for(let t of e)t.parentId||(t.position={x:t.position.x-i,y:t.position.y-a});return{width:o-i,height:s-a}}function Zg(){let e=new URLSearchParams(window.location.search);return{subworkflowPath:e.get(`subworkflow`),agent:e.get(`agent`)}}function Qg(e,t){let n=[],r=e;for(let e of t){let t=-1;for(let n=r.length-1;n>=0;n--)if(r[n].slotKey===e){t=n;break}if(t===-1){for(let n=r.length-1;n>=0;n--)if(r[n].parentAgent===e){t=n;break}}if(t===-1)return{path:n,failedSegment:e};n.push(t),r=r[t].children}return{path:n,failedSegment:null}}function $g(e,t){let n=e,r=null;for(let e of t){if(r=n[e]??null,!r)return null;n=r.children}return r}function e_(e,t,n=[]){let r=[];for(let i=0;ie.name===t)&&r.push({path:o,ctx:a}),a.children.length>0&&r.push(...e_(a.children,t,o))}return r}function t_(e){return e.length===0?null:[...e].sort((e,t)=>{let n=+(e.ctx.status===`running`),r=+(t.ctx.status===`running`);if(n!==r)return r-n;if(e.path.length!==t.path.length)return t.path.length-e.path.length;for(let n=0;n{if(n.current||!s)return;let e=null,c=null,l=null,u=null,d=(e,t)=>{let n=B.getState(),r=n.subworkflowContexts;e.length>0&&!$g(r,e)&&console.warn(`[use-deep-link] reveal target path is not fully materialized; expanding only the resolved prefix`,e),n.expandContexts(Wg(r,e)),B.setState({viewContextPath:[],selectedNode:t})},f=e=>{let t=0,n=()=>{l=null;let a=i(e)?.measured;a?.width&&a?.height?r({nodes:[{id:e}],padding:.5,duration:400}):t++<40?l=requestAnimationFrame(n):(console.warn(`[use-deep-link] node "${e}" was not measured in time; fitting the whole graph instead`),r({padding:.2,duration:400}))};l=requestAnimationFrame(n)},p=()=>{if(n.current)return;n.current=!0,e&&clearTimeout(e),c&&clearTimeout(c),u&&u();let r=B.getState();if(r.agents.length===0){t({message:`Workflow state did not load.`});return}let i=[];if(a){let e=a.split(`/`).filter(Boolean),n=Qg(r.subworkflowContexts,e);if(n.failedSegment){let r=e.slice(0,n.path.length).join(`/`);d(n.path,null),t({message:`Subworkflow "${n.failedSegment}" not found${r?` (resolved: ${r})`:``}. It may not have started yet.`});return}i=n.path}if(o){if((i.length===0?r.agents:$g(r.subworkflowContexts,i)?.agents??[]).some(e=>e.name===o)){let e=Eh(i,o);d(i,e),f(e);return}let e=e_(r.subworkflowContexts,o);if(e.length===0){let e=a||`root workflow`;d(i,null),t({message:`Agent "${o}" not found in ${e}.`});return}if(a){let n=e.slice(0,5).map(e=>n_(r.subworkflowContexts,e.path)).join(`, `),s=e.length>5?`, and ${e.length-5} more`:``;d(i,null),t({message:`Agent "${o}" not found in ${a}. Found in: ${n}${s}`});return}let n=t_(e),s=Eh(n.path,o);d(n.path,s),f(s);return}if(d(i,null),i.length>0){let e=$g(r.subworkflowContexts,i);e&&f(Eh(i.slice(0,-1),e.slotKey))}},m=()=>{try{p()}catch(e){console.warn(`[use-deep-link] failed to apply deep-link target`,e),t({message:`Could not resolve the deep-link target.`})}},h=()=>{let e=B.getState();if(e.agents.length===0)return!1;if(e.workflowStatus!==`running`&&e.workflowStatus!==`pending`)return!0;if(a){let t=a.split(`/`).filter(Boolean),{failedSegment:n}=Qg(e.subworkflowContexts,t);if(n)return!1}return!(o&&!a&&!e.agents.some(e=>e.name===o)&&e_(e.subworkflowContexts,o).length===0)},g=()=>{e&&clearTimeout(e),e=setTimeout(()=>{n.current||h()&&m()},200)};return u=B.subscribe(g),c=setTimeout(()=>{n.current||m()},5e3),g(),()=>{e&&clearTimeout(e),c&&clearTimeout(c),l!=null&&cancelAnimationFrame(l),u&&u()}},[s,a,o,r,i]),e}var X={pending:`#6b7280`,running:`#3b82f6`,completed:`#22c55e`,failed:`#ef4444`,paused:`#f59e0b`,idle:`#6b7280`,waiting:`#a855f7`};function i_({data:e,children:t}){let[n,r]=(0,v.useState)(!1),i=(0,v.useRef)(null),a=(0,v.useCallback)(()=>{i.current=setTimeout(()=>r(!0),200)},[]),o=(0,v.useCallback)(()=>{i.current&&clearTimeout(i.current),r(!1)},[]),s=X[e.status]||X.pending;return(0,H.jsxs)(`div`,{className:`relative`,onMouseEnter:a,onMouseLeave:o,children:[t,n&&(0,H.jsxs)(`div`,{className:U(`absolute z-50 bottom-full left-1/2 -translate-x-1/2 mb-2`,`bg-[var(--surface-raised)] border border-[var(--border)] shadow-lg`,`rounded-lg px-3 py-2 max-w-[260px] pointer-events-none`,`animate-[tooltip-in_150ms_ease-out]`),children:[(0,H.jsx)(`div`,{className:`absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-x-[6px] border-x-transparent border-t-[6px] border-t-[var(--border)]`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-[11px]`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(`span`,{className:`w-2 h-2 rounded-full flex-shrink-0`,style:{backgroundColor:s}}),(0,H.jsx)(`span`,{className:`font-medium text-[var(--text)] capitalize`,children:e.status}),e.iteration!=null&&e.iteration>1&&(0,H.jsxs)(`span`,{className:`text-[var(--text-muted)] ml-auto`,children:[`iter `,e.iteration]})]}),(0,H.jsx)(`div`,{className:`h-px bg-[var(--border)]`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:[e.elapsed!=null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Elapsed`}),(0,H.jsx)(`span`,{className:`text-[var(--text)] font-mono`,children:st(e.elapsed)})]}),e.model&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Model`}),(0,H.jsx)(`span`,{className:`text-[var(--text)] truncate`,children:e.model})]}),e.tokens!=null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Tokens`}),(0,H.jsxs)(`span`,{className:`text-[var(--text)] font-mono`,children:[ct(e.tokens),e.inputTokens!=null&&e.outputTokens!=null&&(0,H.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[` `,`(`,ct(e.inputTokens),`↑ `,ct(e.outputTokens),`↓)`]})]})]}),e.costUsd!=null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Cost`}),(0,H.jsx)(`span`,{className:`text-[var(--text)] font-mono`,children:lt(e.costUsd)})]}),e.exitCode!=null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Exit code`}),(0,H.jsx)(`span`,{className:U(`font-mono`,e.exitCode===0?`text-[var(--completed)]`:`text-[var(--failed)]`),children:e.exitCode})]}),e.selectedOption&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Selected`}),(0,H.jsx)(`span`,{className:`text-[var(--text)] truncate`,children:e.selectedOption})]}),e.terminationStatus&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Termination`}),(0,H.jsx)(`span`,{className:U(`font-mono capitalize`,e.terminationStatus===`success`?`text-[var(--completed)]`:`text-[var(--failed)]`),children:e.terminationStatus})]})]}),e.reason&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`h-px bg-[var(--border)]`}),(0,H.jsxs)(`div`,{className:U(`leading-tight break-words`,e.terminationStatus===`failed`?`text-red-400`:`text-[var(--text)]`),children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] mr-1`,children:`Reason:`}),e.reason.slice(0,160),e.reason.length>160?`...`:``]})]}),e.errorMessage&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`h-px bg-[var(--border)]`}),(0,H.jsxs)(`div`,{className:`text-red-400 leading-tight`,children:[e.errorType&&(0,H.jsxs)(`span`,{className:`font-medium`,children:[e.errorType,`: `]}),(0,H.jsxs)(`span`,{className:`break-words`,children:[e.errorMessage.slice(0,120),e.errorMessage.length>120?`...`:``]})]})]})]})]})]})}var a_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.elapsed,s=r?.model,c=r?.tokens,l=r?.input_tokens,u=r?.output_tokens,d=r?.cost_usd,f=r?.iteration,p=r?.error_type,m=r?.error_message,h=r?.context_pct,g=r?.provider_tier,_=r?.provider_name,v=o_(r?.startedAt,i),y=s_(i),b=(()=>{if(i===`failed`&&m)return{text:m.length>40?m.slice(0,37)+`...`:m,className:`text-red-400`};if(i===`running`)return{text:v,className:`text-[var(--text-muted)]`};if(i===`completed`){let e=[];return o!=null&&e.push(st(o)),c!=null&&e.push(`${ct(c)} tok`),d!=null&&e.push(lt(d)),{text:e.join(` · `)||null,className:`text-[var(--text-muted)]`}}return{text:null,className:``}})();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,elapsed:o,model:s,tokens:c,inputTokens:l,outputTokens:u,costUsd:d,iteration:f,errorType:p,errorMessage:m},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`,y),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`running`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(O,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),f!=null&&f>1&&(0,H.jsxs)(`span`,{className:`flex-shrink-0 inline-flex items-center justify-center px-1.5 py-0.5 rounded-full text-[9px] font-bold leading-none`,style:{backgroundColor:`${a}25`,color:a},children:[`x`,f]}),g===`experimental`&&(0,H.jsx)(`span`,{className:`flex-shrink-0 inline-flex items-center justify-center px-1.5 py-0.5 rounded-full text-[9px] font-bold leading-none uppercase tracking-wide`,style:{backgroundColor:`rgba(245, 158, 11, 0.18)`,color:`#f59e0b`},title:`Experimental provider: ${_??`unknown`}`,children:`exp`})]}),b.text&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight`,b.className),children:b.text})]}),h!=null&&(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-[2px] rounded-b-lg overflow-hidden`,style:{backgroundColor:`rgba(255,255,255,0.06)`},children:(0,H.jsx)(`div`,{className:U(`h-full transition-all duration-500`,h>=90?`animate-[context-pulse_2s_ease-in-out_infinite]`:``),style:{width:`${Math.min(h,100)}%`,backgroundColor:h>=90?`#ef4444`:h>=70?`#f59e0b`:`#22c55e`}})})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function o_(e,t){let n=B(e=>e.replayMode),r=B(e=>e.lastEventTime),[i,a]=(0,v.useState)(`0.0s`),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(t===`running`){if(n){o.current&&clearInterval(o.current);let t=e??r??0;a(st((r??t)-t));return}let t=e==null?Date.now():e*1e3,i=()=>{a(st((Date.now()-t)/1e3))};return i(),o.current=setInterval(i,1e3),()=>{o.current&&clearInterval(o.current)}}else o.current&&clearInterval(o.current)},[t,e,n,r]),i}function s_(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`?r(`node-activate`):n===`running`&&(e===`completed`||e===`failed`)&&r(e===`completed`?`node-complete`:`node-fail`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var c_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.elapsed,s=r?.exit_code,c=r?.error_type,l=r?.error_message,u=l_(r?.startedAt,i),d=u_(i),f=(()=>{if(i===`failed`&&l)return{text:l.length>40?l.slice(0,37)+`...`:l,className:`text-red-400`};if(i===`running`)return{text:u,className:`text-[var(--text-muted)]`};if(i===`completed`){let e=[];return o!=null&&e.push(st(o)),s!=null&&e.push(`exit ${s}`),{text:e.join(` · `)||null,className:`text-[var(--text-muted)]`}}return{text:null,className:``}})();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,elapsed:o,exitCode:s,errorType:c,errorMessage:l},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`,d),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`running`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(Se,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),f.text&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight`,f.className),children:f.text})]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function l_(e,t){let n=B(e=>e.replayMode),r=B(e=>e.lastEventTime),[i,a]=(0,v.useState)(`0.0s`),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(t===`running`){if(n){o.current&&clearInterval(o.current);let t=e??r??0;a(st((r??t)-t));return}let t=e==null?Date.now():e*1e3,i=()=>{a(st((Date.now()-t)/1e3))};return i(),o.current=setInterval(i,1e3),()=>{o.current&&clearInterval(o.current)}}else o.current&&clearInterval(o.current)},[t,e,n,r]),i}function u_(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`?r(`node-activate`):n===`running`&&(e===`completed`||e===`failed`)&&r(e===`completed`?`node-complete`:`node-fail`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var d_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.elapsed,s=r?.set_output_keys,c=r?.set_value_repr,l=r?.error_type,u=r?.error_message,d=f_(r?.startedAt,i),f=p_(i),p=(()=>{if(i===`failed`&&u)return{text:u.length>40?u.slice(0,37)+`...`:u,className:`text-red-400`};if(i===`running`)return{text:d,className:`text-[var(--text-muted)]`};if(i===`completed`){let e=[];if(o!=null&&e.push(st(o)),s&&s.length>0)e.push(`${s.length} key${s.length===1?``:`s`}`);else if(c){let t=c.length>24?c.slice(0,21)+`…`:c;e.push(t)}return{text:e.join(` · `)||null,className:`text-[var(--text-muted)]`}}return{text:null,className:``}})();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,elapsed:o,errorType:l,errorMessage:u},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`,f),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`running`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(we,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),p.text&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight`,p.className),children:p.text})]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function f_(e,t){let n=B(e=>e.replayMode),r=B(e=>e.lastEventTime),[i,a]=(0,v.useState)(`0.0s`),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(t===`running`){if(n){o.current&&clearInterval(o.current);let t=e??r??0;a(st((r??t)-t));return}let t=e==null?Date.now():e*1e3,i=()=>{a(st((Date.now()-t)/1e3))};return i(),o.current=setInterval(i,1e3),()=>{o.current&&clearInterval(o.current)}}else o.current&&clearInterval(o.current)},[t,e,n,r]),i}function p_(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`?r(`node-activate`):n===`running`&&(e===`completed`||e===`failed`)&&r(e===`completed`?`node-complete`:`node-fail`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var m_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.selected_option,s=h_(i);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,selectedOption:o},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 border-dashed bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`waiting`&&`shadow-[0_0_12px_var(--waiting-muted)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`,s),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`waiting`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(ye,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),i===`waiting`&&(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--waiting)] truncate leading-tight`,children:`Awaiting input...`}),i===`completed`&&o&&(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] truncate leading-tight`,children:o})]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function h_(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`||e===`waiting`?r(`node-activate`):(n===`running`||n===`waiting`)&&e===`completed`&&r(`node-complete`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var g_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=n.type===`for_each_group`?ge:se,i=n.progress,a=Mh(n)?.status||n.status||`pending`,o=X[a]||X.pending,s=__(a),c=B(e=>e.toggleContextExpanded),l=n.expanded===!0,u=n.canExpand===!0,d=n.groupExpansionKey,f=e=>{e.stopPropagation(),d!=null&&c(d)},p=i?`${i.completed+i.failed}/${i.total}${i.failed>0?` (${i.failed} failed)`:``}`:null,m=i&&i.total>0?(i.completed+i.failed)/i.total*100:0,h=i!=null&&i.failed>0;return l?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(`div`,{className:U(`w-full h-full rounded-xl border-2 border-dashed bg-[var(--surface)]/40 transition-all duration-300 animate-[subflow-expand-in_200ms_ease-out]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,a===`running`&&`shadow-[0_0_16px_var(--running-glow)]`,s),style:{borderColor:o,minHeight:`100%`},children:(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2`,children:[(0,H.jsx)(`button`,{onClick:f,className:`nodrag flex items-center justify-center w-5 h-5 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0`,title:`Collapse for-each iterations`,children:(0,H.jsx)(A,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(r,{className:`w-3.5 h-3.5 flex-shrink-0`,style:{color:o}}),(0,H.jsx)(`span`,{className:`text-xs font-semibold text-[var(--text)] truncate`,children:n.label}),p&&(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] font-mono flex-shrink-0`,children:p})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsxs)(`div`,{className:U(`flex flex-col gap-1 px-4 py-3 rounded-xl border-2 border-dashed bg-[var(--surface)]/80 min-w-[180px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,a===`running`&&`shadow-[0_0_16px_var(--running-glow)]`,s),style:{borderColor:o,minHeight:`100%`},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u&&(0,H.jsx)(`button`,{onClick:f,className:`nodrag flex items-center justify-center w-5 h-5 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0 -ml-1`,title:`Expand for-each iterations inline`,children:(0,H.jsx)(j,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(r,{className:`w-3.5 h-3.5`,style:{color:o}}),(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text-secondary)]`,children:n.label})]}),p&&(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] font-mono`,children:p}),i&&i.total>0&&a===`running`&&(0,H.jsx)(`div`,{className:`w-full h-1 rounded-full bg-[var(--border)] overflow-hidden mt-0.5`,children:(0,H.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ease-out`,style:{width:`${m}%`,backgroundColor:h?`var(--failed)`:`var(--completed)`}})})]}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function __(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`?r(`node-activate`):n===`running`&&(e===`completed`||e===`failed`)&&r(e===`completed`?`node-complete`:`node-fail`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var v_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.elapsed,s=r?.error_message,c=B(e=>e.toggleContextExpanded),l=n.expanded===!0,u=n.canExpand===!0,d=n.childContextKey,f=n.childName,p=e=>{e.stopPropagation(),d!=null&&c(d)};if(l)return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(`div`,{className:U(`w-full h-full rounded-xl border-2 border-dashed bg-[var(--surface)]/40 transition-all duration-300 animate-[subflow-expand-in_200ms_ease-out]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_16px_var(--running-glow)]`),style:{borderColor:a,minHeight:`100%`},children:(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2`,children:[(0,H.jsx)(`button`,{onClick:p,className:`nodrag flex items-center justify-center w-5 h-5 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0`,title:`Collapse subworkflow`,children:(0,H.jsx)(A,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(le,{className:`w-3.5 h-3.5 flex-shrink-0`,style:{color:a}}),(0,H.jsx)(`span`,{className:`text-xs font-semibold text-[var(--text)] truncate`,children:n.label}),f&&(0,H.jsxs)(`span`,{className:`text-[10px] text-[var(--text-muted)] truncate`,children:[`· `,f]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]});let m=(()=>{if(i===`failed`&&s)return{text:s.length>35?s.slice(0,32)+`...`:s,className:`text-red-400`};if(i===`running`)return{text:f||`Running subworkflow…`,className:`text-[var(--text-muted)]`};if(i===`completed`){let e=[];return f&&e.push(f),o!=null&&e.push(`${o.toFixed(1)}s`),{text:e.join(` · `)||`Done`,className:`text-[var(--text-muted)]`}}return{text:f||null,className:`text-[var(--text-muted)]`}})();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,elapsed:o,errorType:void 0,errorMessage:s,iteration:void 0},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[240px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`),style:{borderColor:a,borderStyle:`dashed`},children:[u?(0,H.jsx)(`button`,{onClick:p,className:`nodrag flex items-center justify-center w-5 h-5 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0`,title:`Expand subworkflow inline (double-click to focus)`,children:(0,H.jsx)(j,{className:`w-3.5 h-3.5`})}):(0,H.jsx)(`div`,{className:`flex items-center justify-center w-5 h-5 flex-shrink-0 text-[var(--text-muted)] opacity-25`,title:`Subworkflow structure not yet known (will be expandable once it starts)`,"aria-hidden":`true`,children:(0,H.jsx)(j,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`running`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(le,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label})}),m.text&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight`,m.className),children:m.text})]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})}),y_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.duration_seconds??r?.requested_seconds,s=r?.waited_seconds,c=r?.elapsed,l=r?.interrupted,u=r?.error_type,d=r?.error_message,f=b_(r?.startedAt,i),p=x_(i),m=(()=>{if(i===`failed`&&d)return{text:d.length>40?d.slice(0,37)+`...`:d,className:`text-red-400`};if(i===`running`)return{text:`${f}${typeof o==`number`?` / ${st(o)}`:``}`,className:`text-[var(--text-muted)]`};if(i===`completed`){let e=[];return s==null?c!=null&&e.push(st(c)):e.push(st(s)),l&&e.push(`interrupted`),{text:e.join(` · `)||null,className:`text-[var(--text-muted)]`}}return i===`pending`&&typeof o==`number`?{text:st(o),className:`text-[var(--text-muted)]`}:{text:null,className:``}})();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,elapsed:s??c,errorType:u,errorMessage:d},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`,p),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`running`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(F,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),m.text&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight`,m.className),children:m.text})]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function b_(e,t){let n=B(e=>e.replayMode),r=B(e=>e.lastEventTime),[i,a]=(0,v.useState)(`0.0s`),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(t===`running`){if(n){o.current&&clearInterval(o.current);let t=e??r??0;a(st((r??t)-t));return}let t=e==null?Date.now():e*1e3,i=()=>{a(st((Date.now()-t)/1e3))};return i(),o.current=setInterval(i,1e3),()=>{o.current&&clearInterval(o.current)}}else o.current&&clearInterval(o.current)},[t,e,n,r]),i}function x_(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`?r(`node-activate`):n===`running`&&(e===`completed`||e===`failed`)&&r(e===`completed`?`node-complete`:`node-fail`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var S_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.termination_reason,s=r?.termination_status,c=r?.error_message,l=r?.error_type,u=o||c,d=i===`failed`?`text-red-400`:i===`completed`?`text-green-400`:`text-[var(--text-muted)]`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,reason:o,terminationStatus:s,errorType:l,errorMessage:c},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[260px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`completed`&&`shadow-[0_0_12px_var(--completed-muted)]`,i===`failed`&&`shadow-[0_0_12px_var(--failed-muted)]`),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,style:{backgroundColor:`${a}20`},children:(0,H.jsx)(pe,{className:`w-3.5 h-3.5`,style:{color:a},fill:i===`completed`||i===`failed`?a:`transparent`,fillOpacity:.2})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),(0,H.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide text-[var(--text-muted)] truncate leading-tight`,children:[`terminate`,s?` · ${s}`:``]}),u&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight mt-0.5`,d),title:u,children:u.length>50?u.slice(0,47)+`...`:u})]})]})})]})}),C_=(0,v.memo)(function({data:e,selected:t}){let n=e.status||`pending`,r=n===`completed`,i=n===`failed`,a=!r&&!i,o=r?X.completed:i?X.failed:X.pending;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300`,r?`bg-[var(--completed)] shadow-[0_0_16px_var(--completed-muted)]`:i?`bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]`:`bg-[var(--node-bg)]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`),style:{borderColor:o},children:r?(0,H.jsx)(k,{className:`w-5 h-5 text-white`,strokeWidth:3}):i?(0,H.jsx)(xe,{className:`w-3.5 h-3.5 text-white`,fill:`white`}):(0,H.jsx)(k,{className:`w-5 h-5`,strokeWidth:2.5,style:{color:a?X.pending:o}})})]})}),w_=(0,v.memo)(function({data:e,selected:t}){let n=e.status||`pending`,r=X[n]||X.pending,i=n===`running`||n===`completed`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300`,i?`bg-[var(--completed)]`:`bg-[var(--node-bg)]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i&&`shadow-[0_0_12px_var(--completed-muted)]`),style:{borderColor:r},children:(0,H.jsx)(he,{className:`w-4 h-4 ml-0.5`,style:{color:i?`white`:r}})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})}),T_=`#a78bfa`,E_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=n.status||`pending`,i=r===`running`||r===`completed`,a=i?T_:X[r]||T_,o=n.parentAgent,s=B(e=>e.navigateUp);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer`,i?`bg-[#a78bfa]`:`bg-[var(--node-bg)]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i&&`shadow-[0_0_12px_rgba(167,139,250,0.4)]`),style:{borderColor:a},onDoubleClick:e=>{e.stopPropagation(),s()},children:(0,H.jsx)(E,{className:`w-4 h-4`,style:{color:i?`white`:a}})}),o&&(0,H.jsxs)(`span`,{className:`text-[10px] text-[var(--text-muted)] whitespace-nowrap`,children:[`from `,(0,H.jsx)(`span`,{className:`font-medium text-[var(--text)]`,children:o})]})]}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})}),D_=`#a78bfa`,O_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=n.status||`pending`,i=r===`completed`,a=r===`failed`,o=i?D_:a?X.failed:D_,s=n.parentAgent,c=B(e=>e.navigateUp);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer`,i?`bg-[#a78bfa] shadow-[0_0_12px_rgba(167,139,250,0.4)]`:a?`bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]`:`bg-[var(--node-bg)]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`),style:{borderColor:o},onDoubleClick:e=>{e.stopPropagation(),c()},children:(0,H.jsx)(D,{className:`w-4 h-4`,style:{color:i||a?`white`:o}})}),s&&(0,H.jsxs)(`span`,{className:`text-[10px] text-[var(--text-muted)] whitespace-nowrap`,children:[`return to `,(0,H.jsx)(`span`,{className:`font-medium text-[var(--text)]`,children:s})]})]})]})}),k_=(0,v.memo)(function({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o,data:s}){let[c,l,u]=Ql({sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o}),d=s?.when,f=s?.highlightState,p=!!d,m=f===`taken`,h=f===`highlighted`,g=f===`failed`,_=`var(--edge-color)`,v=2,y;return g?(_=`var(--failed)`,v=3):m?(_=`var(--edge-taken)`,v=3):h&&(_=`var(--edge-active)`,v=3),p&&!m&&!h&&!g&&(y=`6 3`),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Hp,{id:e,path:c,style:{stroke:_,strokeWidth:v,strokeDasharray:y,transition:`stroke 0.3s ease, stroke-width 0.3s ease`},markerEnd:`url(#arrow-${g?`failed`:m?`taken`:h?`active`:`default`})`}),p&&(0,H.jsx)(Hm,{children:(0,H.jsx)(`div`,{className:`nodrag nopan`,style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${l}px,${u}px)`,pointerEvents:`all`},children:(0,H.jsx)(`span`,{className:`inline-block px-1.5 py-0.5 rounded-full text-[9px] font-mono leading-tight max-w-[140px] truncate`,style:{backgroundColor:g?`var(--failed)`:m?`var(--edge-taken)`:`var(--surface)`,color:g||m?`var(--bg)`:`var(--text-muted)`,border:`1px solid ${g?`var(--failed)`:m?`var(--edge-taken)`:`var(--border)`}`},title:d,children:d})})}),m&&(0,H.jsx)(`circle`,{r:`3`,fill:`var(--edge-taken)`,children:(0,H.jsx)(`animateMotion`,{dur:`1s`,repeatCount:`indefinite`,path:c})}),g&&(0,H.jsx)(`circle`,{r:`3`,fill:`var(--failed)`,opacity:`0.8`,children:(0,H.jsx)(`animateMotion`,{dur:`1.5s`,repeatCount:`indefinite`,path:c})})]})});function A_(){let e=B(e=>e.workflowStatus),t=B(e=>e.workflowFailure),n=B(e=>e.workflowFailedAgent),r=B(e=>e.workflowTermination),i=B(e=>e.selectNode);if(e!==`failed`||!t)return null;if(t.stopped_by_user){let e=t.checkpoint_path?.split(`/`).pop();return(0,H.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]`,children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-4 py-2 rounded-lg`,`bg-slate-900/90 border border-slate-500/40 shadow-lg shadow-slate-500/10`,`backdrop-blur-sm max-w-[560px]`),children:[(0,H.jsx)(xe,{className:`w-4 h-4 text-slate-300 flex-shrink-0`}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-slate-200`,children:`Workflow Stopped`}),t.checkpoint_path?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`text-[11px] text-slate-300/80 truncate`,title:t.checkpoint_path,children:[`Checkpoint saved: `,e]}),(0,H.jsx)(`span`,{className:`text-[10px] text-slate-400/70 truncate`,children:`Resume from the CLI with: conductor resume`})]}):t.checkpoint_unavailable_reason?(0,H.jsxs)(`span`,{className:`text-[11px] text-amber-300/80 truncate`,title:t.checkpoint_unavailable_reason,children:[`No checkpoint could be saved — `,t.checkpoint_unavailable_reason]}):(0,H.jsx)(`span`,{className:`text-[11px] text-slate-400/70 truncate`,children:`Saving checkpoint…`})]}),n&&(0,H.jsxs)(`button`,{onClick:()=>i(Eh([],n)),className:`flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium text-slate-200 bg-slate-500/20 hover:bg-slate-500/30 transition-colors flex-shrink-0 ml-1`,children:[(0,H.jsx)(ae,{className:`w-3 h-3`}),`View`]})]})})}let a=r?.is_explicit&&r.status===`failed`,o=a?r.termination_reason||t.message||`Workflow terminated`:t.message||t.error_type||`Unknown error`,s=a?`Workflow Terminated`:`Workflow Failed`,c=t.error_type===`TimeoutError`;return(0,H.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]`,children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-4 py-2 rounded-lg`,`bg-red-950/90 border border-red-500/40 shadow-lg shadow-red-500/10`,`backdrop-blur-sm max-w-[560px]`),children:[(0,H.jsx)(Ce,{className:`w-4 h-4 text-red-400 flex-shrink-0`}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-red-300`,children:s}),(0,H.jsx)(`span`,{className:`text-[11px] text-red-400/80 truncate`,children:o}),a&&r?.terminated_by&&(0,H.jsxs)(`span`,{className:`text-[10px] text-red-400/60 truncate`,children:[`Terminated by: `,r.terminated_by]}),c&&t.current_agent&&(0,H.jsxs)(`span`,{className:`text-[10px] text-red-400/60 truncate`,children:[`Timed out on agent: `,t.current_agent]}),t.checkpoint_path&&(0,H.jsxs)(`span`,{className:`text-[10px] text-red-400/50 truncate`,title:t.checkpoint_path,children:[`Checkpoint: `,t.checkpoint_path.split(`/`).pop()]})]}),n&&(0,H.jsxs)(`button`,{onClick:()=>i(Eh([],n)),className:`flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium text-red-300 bg-red-500/20 hover:bg-red-500/30 transition-colors flex-shrink-0 ml-1`,children:[(0,H.jsx)(ae,{className:`w-3 h-3`}),`View`]})]})})}function j_(){let[e,t]=(0,v.useState)(!1),n=B(e=>e.workflowStatus),r=B(e=>e.workflowTermination),i=B(e=>e.totalCost),a=B(e=>e.totalTokens),o=B(e=>e.agentsCompleted),s=B(e=>e.agentsTotal),c=ft();if(n!==`completed`||e)return null;let l=r?.is_explicit&&r.status===`success`;return(0,H.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]`,children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-3 px-4 py-2 rounded-lg`,`bg-green-950/90 border border-green-500/40 shadow-lg shadow-green-500/10`,`backdrop-blur-sm max-w-[560px]`),children:[(0,H.jsx)(te,{className:`w-4 h-4 text-green-400 flex-shrink-0`}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-green-300`,children:l?`Workflow Terminated`:`Completed`}),l&&r?.termination_reason&&(0,H.jsx)(`span`,{className:`text-[11px] text-green-400/80 truncate`,children:r.termination_reason}),l&&r?.terminated_by&&(0,H.jsxs)(`span`,{className:`text-[10px] text-green-400/60 truncate`,children:[`Terminated by: `,r.terminated_by]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-green-400/80 font-mono flex-shrink-0 ml-auto`,children:[(0,H.jsx)(`span`,{children:c}),s>0&&(0,H.jsxs)(`span`,{children:[o,`/`,s,` agents`]}),a>0&&(0,H.jsxs)(`span`,{children:[ct(a),` tok`]}),i>0&&(0,H.jsx)(`span`,{children:lt(i)})]}),(0,H.jsx)(`button`,{onClick:()=>t(!0),className:`p-0.5 rounded text-green-500/60 hover:text-green-300 transition-colors flex-shrink-0 ml-1`,children:(0,H.jsx)(De,{className:`w-3.5 h-3.5`})})]})})}var M_=6e4;function N_({wsStatus:e,wsDisconnectedSince:t,workflowStatus:n,replayMode:r,now:i=Date.now(),thresholdMs:a=M_}){return r||n!==`running`||e===`connected`||t==null?!1:i-t>=a}function P_(){let e=B(e=>e.wsStatus),t=B(e=>e.wsDisconnectedSince),n=B(e=>e.workflowStatus),r=B(e=>e.replayMode),[i,a]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{if(t==null||e===`connected`)return;let n=()=>a(Date.now());n();let r=setInterval(n,1e3);return()=>clearInterval(r)},[t,e]),{stuck:N_({wsStatus:e,wsDisconnectedSince:t,workflowStatus:n,replayMode:r,now:i}),elapsedMs:t==null?0:Math.max(0,i-t)}}function F_(){let{stuck:e,elapsedMs:t}=P_(),n=B(e=>e.bgStderrLog),r=B(e=>e.bgStdoutLog),i=B(e=>e.systemLogFile);if(!e)return null;let a=n?`Check the captured logs: ${n}${r?` (and ${r})`:``}`:i?`Check the event log: ${i}`:"Check the terminal where `conductor run` was launched, or re-run with --log-file to capture one.";return(0,H.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]`,children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-4 py-2 rounded-lg`,`bg-amber-950/90 border border-amber-500/40 shadow-lg shadow-amber-500/10`,`backdrop-blur-sm max-w-[560px]`),children:[(0,H.jsx)(Ce,{className:`w-4 h-4 text-amber-400 flex-shrink-0`}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-amber-300`,children:`Connection lost — workflow may have stopped responding`}),(0,H.jsxs)(`span`,{className:`text-[11px] text-amber-400/80 truncate`,children:[`Reconnecting for `,st(t/1e3),` with no success. The Conductor process may have crashed.`]}),(0,H.jsx)(`span`,{className:`text-[10px] text-amber-400/60 truncate`,title:n??i??void 0,children:a})]})]})})}var I_={agentNode:a_,scriptNode:c_,setNode:d_,gateNode:m_,groupNode:g_,workflowNode:v_,waitNode:y_,terminateNode:S_,endNode:C_,startNode:w_,ingressNode:E_,egressNode:O_},L_={animatedEdge:k_},R_={type:`animatedEdge`};function z_(){return(0,H.jsx)(`svg`,{style:{position:`absolute`,width:0,height:0},children:(0,H.jsxs)(`defs`,{children:[(0,H.jsx)(`marker`,{id:`arrow-default`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto-start-reverse`,children:(0,H.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`var(--edge-color)`})}),(0,H.jsx)(`marker`,{id:`arrow-active`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto-start-reverse`,children:(0,H.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`var(--edge-active)`})}),(0,H.jsx)(`marker`,{id:`arrow-taken`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto-start-reverse`,children:(0,H.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`var(--edge-taken)`})}),(0,H.jsx)(`marker`,{id:`arrow-failed`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto-start-reverse`,children:(0,H.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`var(--failed)`})})]})})}function B_(e,t){if(t.length===0)return null;let n=e[t[0]];for(let e=1;ee.viewContextPath),n=B(e=>e.selectNode),r=B(e=>e.selectedNode),i=B(e=>e.workflowStatus),a=B(e=>e.wsStatus),o=B(e=>e.workflowFailedAgent),s=B(e=>e.navigateIntoSubworkflow),{agents:c,routes:l,parallelGroups:u,forEachGroups:d,nodes:f,groupProgress:p,entryPoint:m,subworkflowContexts:h,parentAgent:g,basePath:_}=e,y=B(e=>e.expandedContexts),b=B(e=>e.nodes),x=B(e=>e.groupProgress),S=B(e=>e.subworkflowContexts),C=B(e=>e.highlightedEdges),[w,T,E]=Um([]),[D,O,k]=Wm([]),A=(0,v.useRef)(``),j=JSON.stringify(t),M=(0,v.useMemo)(()=>{let e=[`${j}#${c.map(e=>e.name).join(`,`)}`];for(let t of[...y].sort()){if(kh(t)){let{contextPath:n,name:r}=Dh(t),i=n.length===0?null:B_(S,n),a=(n.length===0?S:i?.children??[]).filter(e=>{let t=Ah(e.slotKey);return t!=null&&t.group===r}).map(e=>`${e.slotKey}:${e.entryPoint??``}:${e.agents.map(e=>e.name).join(`,`)}`);e.push(`${t}=>${a.join(`|`)}`);continue}let n=B_(S,t.split(`.`).filter(Boolean).map(Number));e.push(`${t}:${n?.entryPoint??``}:${n?.agents.map(e=>e.name).join(`,`)??``}`)}return e.join(`||`)},[j,c,y,S]);(0,v.useEffect)(()=>{if(c.length===0){A.current!==M&&(A.current=M,T([]),O([]));return}if(A.current===M)return;A.current=M;let{nodes:e,edges:t}=Hg({agents:c,routes:l,parallelGroups:u,forEachGroups:d,nodes:f,groupProgress:p,entryPoint:m,parentAgent:g,children:h},_,y);T(e),O(t)},[M,c,l,u,d,f,p,m,g,h,_,y,T,O]),(0,v.useEffect)(()=>{T(e=>e.map(e=>{let t=e.data,n=t.iterationContextPath;if(n&&n.length>0){let r=B_(S,n)?.status;return!r||r===t.status?e:{...e,data:{...t,status:r}}}let r=t.contextPath??[],i=r.length===0?null:B_(S,r),a=r.length===0?b:i?.nodes,o=r.length===0?x:i?.groupProgress,s=t.name??e.id,c=a?a[s]:void 0;if(!c)return e;let l=t,u=!1,d=c.status||`pending`;if(d!==t.status&&(l={...l,status:d},u=!0),t.groupName&&o&&o[t.groupName]){let e=o[t.groupName],n=l.progress;e&&(!n||n.completed!==e.completed||n.failed!==e.failed)&&(l={...l,progress:e},u=!0)}return u?{...e,data:l}:e}))},[b,x,S,T]),(0,v.useEffect)(()=>{O(e=>e.map(e=>{let{contextPath:t,name:n}=Dh(e.source),r=Dh(e.target).name,i=t.length===0?null:B_(S,t),a=(t.length===0?C:i?.highlightedEdges??[]).find(e=>e.from===n&&e.to===r)?.state;return e.data?.highlightState===a?e:{...e,data:{...e.data,highlightState:a}}}))},[C,S,O]);let N=(0,v.useCallback)((e,t)=>{t.type===`groupNode`&&t.data.type!==`for_each_group`||n(t.id)},[n]),ee=(0,v.useCallback)((e,n)=>{let r=n.data;if(r.type!==`workflow`||(r.contextPath??[]).join(`.`)!==t.join(`.`))return;let i=r.name;i&&h.some(e=>e.slotKey===i||e.parentAgent===i)&&s(i)},[h,s,t]),te=(0,v.useCallback)(()=>{n(null)},[n]),P=(0,v.useCallback)(e=>X[e.data?.status||`pending`]??X.pending??`#6b7280`,[]);(0,v.useEffect)(()=>{T(e=>e.map(e=>({...e,selected:e.id===r})))},[r,T]),(0,v.useEffect)(()=>{i===`failed`&&o&&n(Eh([],o))},[i,o,n]);let F=i===`pending`&&c.length===0,ne=(()=>{switch(a){case`connecting`:return`Connecting to workflow…`;case`reconnecting`:return`Reconnecting…`;case`disconnected`:return`Connection lost. Retrying…`;default:return`Waiting for workflow…`}})();return(0,H.jsxs)(`div`,{className:`w-full h-full relative`,children:[(0,H.jsx)(z_,{}),(0,H.jsx)(A_,{}),(0,H.jsx)(j_,{}),(0,H.jsx)(F_,{}),F&&(0,H.jsxs)(`div`,{className:`absolute inset-0 z-10 flex flex-col items-center justify-center pointer-events-none`,children:[(0,H.jsxs)(`div`,{className:`relative mb-3`,children:[(0,H.jsx)(Oe,{className:`w-8 h-8 text-[var(--accent)] opacity-20`}),(0,H.jsx)(ue,{className:`w-8 h-8 text-[var(--text-muted)] animate-spin absolute inset-0 opacity-40`})]}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--text-muted)] animate-pulse`,children:ne})]}),(0,H.jsxs)(Bm,{nodes:w,edges:D,onNodesChange:E,onEdgesChange:k,onNodeClick:N,onNodeDoubleClick:ee,onPaneClick:te,nodeTypes:I_,edgeTypes:L_,defaultEdgeOptions:R_,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:2,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[(0,H.jsx)(Zm,{variant:qm.Dots,gap:20,size:1,color:`var(--border-subtle)`}),(0,H.jsx)(xh,{nodeColor:P,maskColor:`var(--minimap-mask)`,style:{background:`var(--minimap-bg)`},pannable:!0,zoomable:!0}),(0,H.jsxs)(oh,{showInteractive:!1,children:[(0,H.jsx)(U_,{}),(0,H.jsx)(H_,{})]}),(0,H.jsx)(W_,{}),(0,H.jsx)(G_,{viewPathKey:j}),(0,H.jsx)(K_,{})]})]})}function H_(){let{fitView:e}=zf();return(0,H.jsx)(`button`,{onClick:(0,v.useCallback)(()=>{e({padding:.2,duration:300})},[e]),className:`react-flow__controls-button`,title:`Fit view (F)`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,H.jsx)(de,{className:`w-3.5 h-3.5`})})}function U_(){let{agents:e,subworkflowContexts:t,basePath:n}=Ih(),r=B(e=>e.expandedContexts),i=B(e=>e.expandContexts),a=B(e=>e.collapseContexts),o=(0,v.useMemo)(()=>Ug(e,t,n),[e,t,n]),s=(0,v.useMemo)(()=>o.some(e=>r.has(e)),[o,r]),c=(0,v.useCallback)(()=>{o.length!==0&&(s?a(o):i(o))},[o,s,a,i]);if((0,v.useEffect)(()=>{let e=e=>{let t=e.target?.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.key===`e`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&c()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c]),o.length===0)return null;let l=s?`Collapse all subworkflows`:`Expand all subworkflows`;return(0,H.jsx)(`button`,{onClick:c,className:`react-flow__controls-button`,title:`${l} (E)`,"aria-label":l,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:s?(0,H.jsx)(N,{className:`w-3.5 h-3.5`}):(0,H.jsx)(ee,{className:`w-3.5 h-3.5`})})}function W_(){let{fitView:e}=zf();return(0,v.useEffect)(()=>{let t=t=>{let n=t.target?.tagName;n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.key===`f`&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&e({padding:.2,duration:300})};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),null}function G_({viewPathKey:e}){let{fitView:t}=zf(),n=(0,v.useRef)(e);return(0,v.useEffect)(()=>{n.current!==e&&(n.current=e,setTimeout(()=>t({padding:.2,duration:300}),50))},[e,t]),null}function K_(){let e=r_();return e?(0,H.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-amber-950/90 border border-amber-500/40 shadow-lg shadow-amber-500/10 backdrop-blur-sm max-w-[560px]`,children:[(0,H.jsx)(`span`,{className:`text-xs text-amber-300`,children:`⚠`}),(0,H.jsx)(`span`,{className:`text-[11px] text-amber-400/80`,children:e.message}),(0,H.jsx)(`a`,{href:window.location.pathname,className:`px-2 py-0.5 rounded text-[10px] font-medium text-amber-300 bg-amber-500/20 hover:bg-amber-500/30 transition-colors flex-shrink-0 ml-1`,children:`Root`})]})}):null}function q_({items:e}){let t=e.filter(e=>e.value!=null&&e.value!==``);return t.length===0?null:(0,H.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs`,children:t.map(({label:e,value:t})=>(0,H.jsxs)(`div`,{className:`contents`,children:[(0,H.jsx)(`dt`,{className:`text-[var(--text-muted)] whitespace-nowrap`,children:e}),(0,H.jsx)(`dd`,{className:`text-[var(--text)] break-words`,children:typeof t==`object`?JSON.stringify(t):String(t)})]},e))})}function J_(e){let t=[];return e.elapsed!=null&&t.push({label:`Elapsed`,value:st(e.elapsed)}),e.model&&t.push({label:`Model`,value:e.model}),e.reasoning_effort&&t.push({label:`Reasoning`,value:e.reasoning_effort}),e.tokens!=null&&t.push({label:`Tokens`,value:ct(e.tokens)}),e.input_tokens!=null&&e.output_tokens!=null&&t.push({label:`In / Out`,value:`${ct(e.input_tokens)} / ${ct(e.output_tokens)}`}),e.cost_usd!=null&&t.push({label:`Cost`,value:lt(e.cost_usd)}),e.context_window_used!=null&&e.context_window_max!=null&&t.push({label:`Context`,value:dt(e.context_window_used,e.context_window_max)}),e.iteration!=null&&t.push({label:`Iteration`,value:e.iteration}),e.error_type&&t.push({label:`Error`,value:e.error_type}),e.error_message&&t.push({label:`Message`,value:e.error_message}),t}function Y_({output:e,title:t=`Output`,defaultExpanded:n=!0,maxHeight:r=`300px`}){let[i,a]=(0,v.useState)(n),[o,s]=(0,v.useState)(!1),c=ut(e);if(!c)return null;let l=typeof e==`object`&&!!e;return(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold`,children:[i?(0,H.jsx)(A,{className:`w-3 h-3`}):(0,H.jsx)(j,{className:`w-3 h-3`}),t]}),i&&(0,H.jsx)(`button`,{onClick:async()=>{await navigator.clipboard.writeText(c),s(!0),setTimeout(()=>s(!1),2e3)},className:`flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors`,title:`Copy to clipboard`,children:o?(0,H.jsx)(k,{className:`w-3 h-3 text-[var(--completed)]`}):(0,H.jsx)(re,{className:`w-3 h-3`})})]}),i&&(0,H.jsx)(`pre`,{className:`bg-[var(--bg)] border border-[var(--border)] rounded-md p-3 font-mono text-[11px] leading-relaxed text-[var(--text)] overflow-auto whitespace-pre-wrap break-words`,style:{maxHeight:r},children:l?(0,H.jsx)(X_,{text:c}):c})]})}function X_({text:e}){let t=e.split(/("(?:[^"\\]|\\.)*")/g);return(0,H.jsx)(H.Fragment,{children:t.map((e,n)=>{if(n%2==1){let r=t.slice(n+1).join(``);return(0,H.jsx)(`span`,{className:/^\s*:/.test(r)?`text-blue-400`:`text-green-400`,children:e},n)}return(0,H.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(e,t,n)=>t?`${e}`:n?`${e}`:e)}},n)})})}function Z_({activity:e,defaultExpanded:t=!0}){let[n,r]=(0,v.useState)(t),i=(0,v.useRef)(null);return(0,v.useEffect)(()=>{i.current&&n&&(i.current.scrollTop=i.current.scrollHeight)},[e.length,n]),e.length===0?null:(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsxs)(`button`,{onClick:()=>r(!n),className:`flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold`,children:[n?(0,H.jsx)(A,{className:`w-3 h-3`}):(0,H.jsx)(j,{className:`w-3 h-3`}),`Activity (`,e.length,`)`]}),n&&(0,H.jsx)(`div`,{ref:i,className:`max-h-[400px] overflow-y-auto space-y-0.5`,children:e.map((e,t)=>(0,H.jsx)(Q_,{entry:e},t))})]})}function Q_({entry:e}){return(0,H.jsxs)(`div`,{className:U(`py-1.5 px-2 rounded text-[11px] leading-relaxed border-b border-[var(--border-subtle)] last:border-b-0`),children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,H.jsx)(`span`,{className:`w-4 text-center flex-shrink-0`,children:e.icon}),(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] uppercase text-[9px] font-semibold tracking-wider w-12 flex-shrink-0 pt-px`,children:e.label}),(0,H.jsx)(`span`,{className:U(`break-words`,{reasoning:`text-indigo-400/70`,"tool-start":`text-blue-400`,"tool-complete":`text-green-400`,turn:`text-amber-400`,message:`text-[var(--text)]`,"parse-recovery":`text-yellow-400`}[e.type]||`text-[var(--text)]`),children:typeof e.text==`object`?JSON.stringify(e.text):e.text})]}),e.detail&&(0,H.jsx)(`div`,{className:`mt-1 ml-[4.25rem] px-2 py-1 bg-[var(--bg)] rounded text-[10px] font-mono text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto`,children:typeof e.detail==`object`?JSON.stringify(e.detail,null,2):e.detail})]})}var $_={running:{label:`Validating…`,color:`#3b82f6`},passed:{label:`Passed`,color:`#22c55e`},failed:{label:`Failed`,color:`#f59e0b`},error:{label:`Validator error (treated as pass)`,color:`#f59e0b`}};function ev({node:e}){let t=e.validator_state;if(!t)return null;let n=$_[t]??{label:`Validating…`,color:`#3b82f6`},r=e.validator_issues??[],i=(t===`failed`||t===`error`)&&r.length>0;return(0,H.jsxs)(`div`,{className:`border border-[var(--border)] rounded-lg overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-[var(--bg)]`,children:[(0,H.jsx)(`span`,{className:`text-xs font-semibold text-[var(--text)]`,children:`Validation`}),(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider ml-auto`,style:{backgroundColor:`${n.color}20`,color:n.color},children:n.label})]}),(0,H.jsxs)(`div`,{className:`px-3 py-3 space-y-2 border-t border-[var(--border)]`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-[var(--text-muted)]`,children:[e.validator_model&&(0,H.jsxs)(`span`,{children:[`model: `,e.validator_model]}),e.validator_cost_usd!=null&&(0,H.jsxs)(`span`,{children:[`cost: $`,e.validator_cost_usd.toFixed(4)]}),e.validator_attempts!=null&&e.validator_attempts>1&&(0,H.jsxs)(`span`,{children:[`runs: `,e.validator_attempts]})]}),i&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-[var(--text-muted)]`,children:`Issues`}),(0,H.jsx)(`ul`,{className:`space-y-1`,children:r.map((e,t)=>(0,H.jsxs)(`li`,{className:`text-xs text-[var(--text)] flex gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] flex-shrink-0`,children:`•`}),(0,H.jsx)(`span`,{children:e})]},t))})]}),e.validator_will_retry&&(0,H.jsx)(`div`,{className:`text-[10px] text-[var(--text-muted)] italic`,children:`Primary agent re-run once with this feedback appended.`})]})]})}function tv({node:e}){let t=e.status,n=X[t]||X.pending,r=e.iterationHistory&&e.iterationHistory.length>0;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider`,style:{backgroundColor:`${n}20`,color:n},children:t}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--text-muted)]`,children:`Agent`})]}),(0,H.jsx)(ev,{node:e}),r?(0,H.jsx)(nv,{label:`Iteration ${e.iteration??`?`} (current)`,defaultExpanded:!0,status:t,snapshot:{iteration:e.iteration??0,prompt:e.prompt,output:e.output,elapsed:e.elapsed,model:e.model,reasoning_effort:e.reasoning_effort,tokens:e.tokens,input_tokens:e.input_tokens,output_tokens:e.output_tokens,cost_usd:e.cost_usd,activity:e.activity,error_type:e.error_type,error_message:e.error_message}}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(q_,{items:J_(e)}),e.prompt&&(0,H.jsx)(Y_,{output:e.prompt,title:`Input / Prompt`,defaultExpanded:!0}),(0,H.jsx)(Z_,{activity:e.activity,defaultExpanded:t!==`completed`}),e.output!=null&&(0,H.jsx)(Y_,{output:e.output,title:`Output`})]}),r&&[...e.iterationHistory].reverse().map(e=>(0,H.jsx)(nv,{label:`Iteration ${e.iteration}`,defaultExpanded:!1,status:t,snapshot:e},e.iteration))]})}function nv({label:e,defaultExpanded:t,snapshot:n,status:r}){let[i,a]=(0,v.useState)(t);return(0,H.jsxs)(`div`,{className:`border border-[var(--border)] rounded-lg overflow-hidden`,children:[(0,H.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-2 w-full px-3 py-2 bg-[var(--bg)] hover:bg-[var(--node-bg)] transition-colors text-left`,children:[i?(0,H.jsx)(A,{className:`w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0`}):(0,H.jsx)(j,{className:`w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0`}),(0,H.jsx)(`span`,{className:`text-xs font-semibold text-[var(--text)]`,children:e}),n.elapsed!=null&&(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] ml-auto`,children:rv(n.elapsed)})]}),i&&(0,H.jsxs)(`div`,{className:`px-3 py-3 space-y-3 border-t border-[var(--border)]`,children:[(0,H.jsx)(q_,{items:J_(n)}),n.prompt&&(0,H.jsx)(Y_,{output:n.prompt,title:`Input / Prompt`,defaultExpanded:!1}),(0,H.jsx)(Z_,{activity:n.activity,defaultExpanded:t&&r!==`completed`}),n.output!=null&&(0,H.jsx)(Y_,{output:n.output,title:`Output`,defaultExpanded:!0}),n.error_type&&(0,H.jsxs)(`div`,{className:`text-xs text-red-400`,children:[(0,H.jsx)(`span`,{className:`font-semibold`,children:n.error_type}),n.error_message&&(0,H.jsxs)(`span`,{className:`ml-1`,children:[`— `,n.error_message]})]})]})]})}function rv(e){return e<1?`${(e*1e3).toFixed(0)}ms`:e<60?`${e.toFixed(1)}s`:`${Math.floor(e/60)}m ${(e%60).toFixed(0)}s`}function iv({node:e}){let t=e.status,n=X[t]||X.pending,r=[];e.elapsed!=null&&r.push({label:`Elapsed`,value:st(e.elapsed)}),e.exit_code!=null&&r.push({label:`Exit Code`,value:e.exit_code}),e.error_type&&r.push({label:`Error`,value:e.error_type}),e.error_message&&r.push({label:`Message`,value:e.error_message});let i=``;return e.stdout&&(i+=e.stdout),e.stderr&&(i+=(i?` + M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}bh.displayName=`MiniMap`;var xh=(0,v.memo)(bh),Sh=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,Ch={[md.Line]:`right`,[md.Handle]:`bottom-right`};function wh({nodeId:e,position:t,variant:n=md.Handle,className:r,style:i=void 0,children:a,color:o,minWidth:s=10,minHeight:c=10,maxWidth:l=Number.MAX_VALUE,maxHeight:u=Number.MAX_VALUE,keepAspectRatio:d=!1,resizeDirection:f,autoScale:p=!0,shouldResize:m,onResizeStart:h,onResize:g,onResizeEnd:_}){let y=ip(),b=typeof e==`string`?e:y,x=Ud(),S=(0,v.useRef)(null),C=n===md.Handle,w=Y((0,v.useCallback)(Sh(C&&p),[C,p]),Rd),T=(0,v.useRef)(null),E=t??Ch[n];return(0,v.useEffect)(()=>{if(!(!S.current||!b))return T.current||=Td({domNode:S.current,nodeId:b,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=x.getState();return{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,paneDomNode:a}},onChange:(e,t)=>{let{triggerNodeChanges:n,nodeLookup:r,parentLookup:i,nodeOrigin:a}=x.getState(),o=[],s={x:e.x,y:e.y},c=r.get(b);if(c&&c.expandParent&&c.parentId){let t=c.origin??a,n=e.width??c.measured.width??0,l=e.height??c.measured.height??0,u=Mu([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...Rl({x:e.x??c.position.x,y:e.y??c.position.y},{width:n,height:l},c.parentId,r,t)}}],r,i,a);o.push(...u),s.x=e.x?Math.max(t[0]*n,e.x):void 0,s.y=e.y?Math.max(t[1]*l,e.y):void 0}if(s.x!==void 0&&s.y!==void 0){let e={id:b,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:b,type:`dimensions`,resizing:!0,setAttributes:f?f===`horizontal`?`width`:`height`:!0,dimensions:{width:e.width,height:e.height}};o.push(t)}for(let e of t){let t={...e,type:`position`};o.push(t)}n(o)},onEnd:({width:e,height:t})=>{let n={id:b,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};x.getState().triggerNodeChanges([n])}}),T.current.update({controlPosition:E,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{T.current?.destroy()}},[E,s,c,l,u,d,h,g,_,m]),(0,H.jsx)(`div`,{className:ir([`react-flow__resize-control`,`nodrag`,...E.split(`-`),n,r]),ref:S,style:{...i,scale:w,...o&&{[C?`backgroundColor`:`borderColor`]:o}},children:a})}(0,v.memo)(wh);function Th(e){return e.join(`.`)}function Eh(e,t){return`${Th(e)}::${t}`}function Dh(e){let t=e.indexOf(`::`);if(t===-1)return{contextPath:[],name:e};let n=e.slice(0,t),r=e.slice(t+2);return{contextPath:n===``?[]:n.split(`.`).map(e=>Number(e)),name:r}}function Oh(e,t){return Eh(e,t)}function kh(e){return e.includes(`::`)}function Ah(e){let t=e.indexOf(`[`);return t<=0||!e.endsWith(`]`)?null:{group:e.slice(0,t),key:e.slice(t+1,-1)}}function jh(e,t){if(t.length===0)return null;let n=e[t[0]];for(let e=1;ee.nodes),n=B(e=>e.subworkflowContexts),r=e?.iterationContextPath,i=e?.contextPath??[],a=e?.name,o=r?r.join(`.`):``;return(0,v.useMemo)(()=>{if(r&&r.length>0){let e=jh(n,r);return e?{name:a??``,status:e.status,type:`workflow`,activity:[],error_message:e.workflowFailure?.message,error_type:e.workflowFailure?.error_type}:void 0}if(a)return i.length===0?t[a]:jh(n,i)?.nodes[a]},[`${i.join(`.`)}::${a??``}`,o,t,n])}function Nh(){let e=B(e=>e.selectedNode),t=B(e=>e.nodes),n=B(e=>e.subworkflowContexts);return(0,v.useMemo)(()=>{if(!e)return;let{contextPath:r,name:i}=Dh(e),a=(r.length===0?t:jh(n,r)?.nodes)?.[i];if(a)return a;if(Ah(i)){let e=r.length===0?n:jh(n,r)?.children??[],t;for(let n=e.length-1;n>=0;n--)if(e[n].slotKey===i){t=e[n];break}if(t)return{name:i,status:t.status,type:`workflow`,activity:[],tokens:t.totalTokens||void 0,cost_usd:t.totalCost||void 0,error_message:t.workflowFailure?.message,error_type:t.workflowFailure?.error_type}}},[e,t,n])}function Ph(){let e=B(e=>e.viewContextPath),t=B(e=>e.groupProgress),n=B(e=>e.subworkflowContexts);return(0,v.useMemo)(()=>e.length===0?t:jh(n,e)?.groupProgress??t,[e,t,n])}function Fh(){let e=B(e=>e.viewContextPath),t=B(e=>e.subworkflowContexts);return(0,v.useMemo)(()=>e.length===0?t:jh(t,e)?.children??[],[e,t])}function Ih(){let e=B(e=>e.viewContextPath),t=B(e=>e.agents),n=B(e=>e.routes),r=B(e=>e.parallelGroups),i=B(e=>e.forEachGroups),a=B(e=>e.nodes),o=B(e=>e.groupProgress),s=B(e=>e.entryPoint),c=B(e=>e.subworkflowContexts);return(0,v.useMemo)(()=>{if(e.length===0)return{agents:t,routes:n,parallelGroups:r,forEachGroups:i,nodes:a,groupProgress:o,entryPoint:s,subworkflowContexts:c,parentAgent:null,basePath:[]};let l=jh(c,e);return l?{agents:l.agents,routes:l.routes,parallelGroups:l.parallelGroups,forEachGroups:l.forEachGroups,nodes:l.nodes,groupProgress:l.groupProgress,entryPoint:l.entryPoint,subworkflowContexts:l.children,parentAgent:l.parentAgent,basePath:e}:{agents:t,routes:n,parallelGroups:r,forEachGroups:i,nodes:a,groupProgress:o,entryPoint:s,subworkflowContexts:c,parentAgent:null,basePath:[]}},[e,t,n,r,i,a,o,s,c])}var Lh=o(((e,t)=>{var n=`\0`,r=`\0`,i=``,a=class{_isDirected=!0;_isMultigraph=!1;_isCompound=!1;_label;_defaultNodeLabelFn=()=>void 0;_defaultEdgeLabelFn=()=>void 0;_nodes={};_in={};_preds={};_out={};_sucs={};_edgeObjs={};_edgeLabels={};_nodeCount=0;_edgeCount=0;_parent;_children;constructor(e){e&&(this._isDirected=Object.hasOwn(e,`directed`)?e.directed:!0,this._isMultigraph=Object.hasOwn(e,`multigraph`)?e.multigraph:!1,this._isCompound=Object.hasOwn(e,`compound`)?e.compound:!1),this._isCompound&&(this._parent={},this._children={},this._children[r]={})}isDirected(){return this._isDirected}isMultigraph(){return this._isMultigraph}isCompound(){return this._isCompound}setGraph(e){return this._label=e,this}graph(){return this._label}setDefaultNodeLabel(e){return this._defaultNodeLabelFn=e,typeof e!=`function`&&(this._defaultNodeLabelFn=()=>e),this}nodeCount(){return this._nodeCount}nodes(){return Object.keys(this._nodes)}sources(){var e=this;return this.nodes().filter(t=>Object.keys(e._in[t]).length===0)}sinks(){var e=this;return this.nodes().filter(t=>Object.keys(e._out[t]).length===0)}setNodes(e,t){var n=arguments,r=this;return e.forEach(function(e){n.length>1?r.setNode(e,t):r.setNode(e)}),this}setNode(e,t){return Object.hasOwn(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]=r,this._children[e]={},this._children[r][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)}node(e){return this._nodes[e]}hasNode(e){return Object.hasOwn(this._nodes,e)}removeNode(e){var t=this;if(Object.hasOwn(this._nodes,e)){var n=e=>t.removeEdge(t._edgeObjs[e]);delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],this.children(e).forEach(function(e){t.setParent(e)}),delete this._children[e]),Object.keys(this._in[e]).forEach(n),delete this._in[e],delete this._preds[e],Object.keys(this._out[e]).forEach(n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this}setParent(e,t){if(!this._isCompound)throw Error(`Cannot set parent in a non-compound graph`);if(t===void 0)t=r;else{t+=``;for(var n=t;n!==void 0;n=this.parent(n))if(n===e)throw Error(`Setting `+t+` as parent of `+e+` would create a cycle`);this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this}_removeFromParentsChildList(e){delete this._children[this._parent[e]][e]}parent(e){if(this._isCompound){var t=this._parent[e];if(t!==r)return t}}children(e=r){if(this._isCompound){var t=this._children[e];if(t)return Object.keys(t)}else if(e===r)return this.nodes();else if(this.hasNode(e))return[]}predecessors(e){var t=this._preds[e];if(t)return Object.keys(t)}successors(e){var t=this._sucs[e];if(t)return Object.keys(t)}neighbors(e){var t=this.predecessors(e);if(t){let r=new Set(t);for(var n of this.successors(e))r.add(n);return Array.from(r.values())}}isLeaf(e){return(this.isDirected()?this.successors(e):this.neighbors(e)).length===0}filterNodes(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;Object.entries(this._nodes).forEach(function([n,r]){e(n)&&t.setNode(n,r)}),Object.values(this._edgeObjs).forEach(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))});var r={};function i(e){var a=n.parent(e);return a===void 0||t.hasNode(a)?(r[e]=a,a):a in r?r[a]:i(a)}return this._isCompound&&t.nodes().forEach(e=>t.setParent(e,i(e))),t}setDefaultEdgeLabel(e){return this._defaultEdgeLabelFn=e,typeof e!=`function`&&(this._defaultEdgeLabelFn=()=>e),this}edgeCount(){return this._edgeCount}edges(){return Object.values(this._edgeObjs)}setPath(e,t){var n=this,r=arguments;return e.reduce(function(e,i){return r.length>1?n.setEdge(e,i,t):n.setEdge(e,i),i}),this}setEdge(){var e,t,n,r,i=!1,a=arguments[0];typeof a==`object`&&a&&`v`in a?(e=a.v,t=a.w,n=a.name,arguments.length===2&&(r=arguments[1],i=!0)):(e=a,t=arguments[1],n=arguments[3],arguments.length>2&&(r=arguments[2],i=!0)),e=``+e,t=``+t,n!==void 0&&(n=``+n);var s=c(this._isDirected,e,t,n);if(Object.hasOwn(this._edgeLabels,s))return i&&(this._edgeLabels[s]=r),this;if(n!==void 0&&!this._isMultigraph)throw Error(`Cannot set a named edge when isMultigraph = false`);this.setNode(e),this.setNode(t),this._edgeLabels[s]=i?r:this._defaultEdgeLabelFn(e,t,n);var u=l(this._isDirected,e,t,n);return e=u.v,t=u.w,Object.freeze(u),this._edgeObjs[s]=u,o(this._preds[t],e),o(this._sucs[e],t),this._in[t][s]=u,this._out[e][s]=u,this._edgeCount++,this}edge(e,t,n){var r=arguments.length===1?u(this._isDirected,arguments[0]):c(this._isDirected,e,t,n);return this._edgeLabels[r]}edgeAsObj(){let e=this.edge(...arguments);return typeof e==`object`?e:{label:e}}hasEdge(e,t,n){var r=arguments.length===1?u(this._isDirected,arguments[0]):c(this._isDirected,e,t,n);return Object.hasOwn(this._edgeLabels,r)}removeEdge(e,t,n){var r=arguments.length===1?u(this._isDirected,arguments[0]):c(this._isDirected,e,t,n),i=this._edgeObjs[r];return i&&(e=i.v,t=i.w,delete this._edgeLabels[r],delete this._edgeObjs[r],s(this._preds[t],e),s(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this}inEdges(e,t){var n=this._in[e];if(n){var r=Object.values(n);return t?r.filter(e=>e.v===t):r}}outEdges(e,t){var n=this._out[e];if(n){var r=Object.values(n);return t?r.filter(e=>e.w===t):r}}nodeEdges(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}};function o(e,t){e[t]?e[t]++:e[t]=1}function s(e,t){--e[t]||delete e[t]}function c(e,t,r,a){var o=``+t,s=``+r;if(!e&&o>s){var c=o;o=s,s=c}return o+i+s+i+(a===void 0?n:a)}function l(e,t,n,r){var i=``+t,a=``+n;if(!e&&i>a){var o=i;i=a,a=o}var s={v:i,w:a};return r&&(s.name=r),s}function u(e,t){return c(e,t.v,t.w,t.name)}t.exports=a})),Rh=o(((e,t)=>{t.exports=`2.2.4`})),zh=o(((e,t)=>{t.exports={Graph:Lh(),version:Rh()}})),Bh=o(((e,t)=>{var n=Lh();t.exports={write:r,read:o};function r(e){var t={options:{directed:e.isDirected(),multigraph:e.isMultigraph(),compound:e.isCompound()},nodes:i(e),edges:a(e)};return e.graph()!==void 0&&(t.value=structuredClone(e.graph())),t}function i(e){return e.nodes().map(function(t){var n=e.node(t),r=e.parent(t),i={v:t};return n!==void 0&&(i.value=n),r!==void 0&&(i.parent=r),i})}function a(e){return e.edges().map(function(t){var n=e.edge(t),r={v:t.v,w:t.w};return t.name!==void 0&&(r.name=t.name),n!==void 0&&(r.value=n),r})}function o(e){var t=new n(e.options).setGraph(e.value);return e.nodes.forEach(function(e){t.setNode(e.v,e.value),e.parent&&t.setParent(e.v,e.parent)}),e.edges.forEach(function(e){t.setEdge({v:e.v,w:e.w,name:e.name},e.value)}),t}})),Vh=o(((e,t)=>{t.exports=n;function n(e){var t={},n=[],r;function i(n){Object.hasOwn(t,n)||(t[n]=!0,r.push(n),e.successors(n).forEach(i),e.predecessors(n).forEach(i))}return e.nodes().forEach(function(e){r=[],i(e),r.length&&n.push(r)}),n}})),Hh=o(((e,t)=>{t.exports=class{_arr=[];_keyIndices={};size(){return this._arr.length}keys(){return this._arr.map(function(e){return e.key})}has(e){return Object.hasOwn(this._keyIndices,e)}priority(e){var t=this._keyIndices[e];if(t!==void 0)return this._arr[t].priority}min(){if(this.size()===0)throw Error(`Queue underflow`);return this._arr[0].key}add(e,t){var n=this._keyIndices;if(e=String(e),!Object.hasOwn(n,e)){var r=this._arr,i=r.length;return n[e]=i,r.push({key:e,priority:t}),this._decrease(i),!0}return!1}removeMin(){this._swap(0,this._arr.length-1);var e=this._arr.pop();return delete this._keyIndices[e.key],this._heapify(0),e.key}decrease(e,t){var n=this._keyIndices[e];if(t>this._arr[n].priority)throw Error(`New priority is greater than current priority. Key: `+e+` Old: `+this._arr[n].priority+` New: `+t);this._arr[n].priority=t,this._decrease(n)}_heapify(e){var t=this._arr,n=2*e,r=n+1,i=e;n>1,!(t[r].priority{var n=Hh();t.exports=i;var r=()=>1;function i(e,t,n,i){return a(e,String(t),n||r,i||function(t){return e.outEdges(t)})}function a(e,t,r,i){var a={},o=new n,s,c,l=function(e){var t=e.v===s?e.w:e.v,n=a[t],i=r(e),l=c.distance+i;if(i<0)throw Error(`dijkstra does not allow negative edge weights. Bad edge: `+e+` Weight: `+i);l0&&(s=o.removeMin(),c=a[s],c.distance!==1/0);)i(s).forEach(l);return a}})),Wh=o(((e,t)=>{var n=Uh();t.exports=r;function r(e,t,r){return e.nodes().reduce(function(i,a){return i[a]=n(e,a,t,r),i},{})}})),Gh=o(((e,t)=>{t.exports=n;function n(e){var t=0,n=[],r={},i=[];function a(o){var s=r[o]={onStack:!0,lowlink:t,index:t++};if(n.push(o),e.successors(o).forEach(function(e){Object.hasOwn(r,e)?r[e].onStack&&(s.lowlink=Math.min(s.lowlink,r[e].index)):(a(e),s.lowlink=Math.min(s.lowlink,r[e].lowlink))}),s.lowlink===s.index){var c=[],l;do l=n.pop(),r[l].onStack=!1,c.push(l);while(o!==l);i.push(c)}}return e.nodes().forEach(function(e){Object.hasOwn(r,e)||a(e)}),i}})),Kh=o(((e,t)=>{var n=Gh();t.exports=r;function r(e){return n(e).filter(function(t){return t.length>1||t.length===1&&e.hasEdge(t[0],t[0])})}})),qh=o(((e,t)=>{t.exports=r;var n=()=>1;function r(e,t,r){return i(e,t||n,r||function(t){return e.outEdges(t)})}function i(e,t,n){var r={},i=e.nodes();return i.forEach(function(e){r[e]={},r[e][e]={distance:0},i.forEach(function(t){e!==t&&(r[e][t]={distance:1/0})}),n(e).forEach(function(n){var i=n.v===e?n.w:n.v,a=t(n);r[e][i]={distance:a,predecessor:e}})}),i.forEach(function(e){var t=r[e];i.forEach(function(n){var a=r[n];i.forEach(function(n){var r=a[e],i=t[n],o=a[n],s=r.distance+i.distance;s{function n(e){var t={},n={},i=[];function a(o){if(Object.hasOwn(n,o))throw new r;Object.hasOwn(t,o)||(n[o]=!0,t[o]=!0,e.predecessors(o).forEach(a),delete n[o],i.push(o))}if(e.sinks().forEach(a),Object.keys(t).length!==e.nodeCount())throw new r;return i}var r=class extends Error{constructor(){super(...arguments)}};t.exports=n,n.CycleException=r})),Yh=o(((e,t)=>{var n=Jh();t.exports=r;function r(e){try{n(e)}catch(e){if(e instanceof n.CycleException)return!1;throw e}return!0}})),Xh=o(((e,t)=>{t.exports=n;function n(e,t,n){Array.isArray(t)||(t=[t]);var a=e.isDirected()?t=>e.successors(t):t=>e.neighbors(t),o=n===`post`?r:i,s=[],c={};return t.forEach(t=>{if(!e.hasNode(t))throw Error(`Graph does not have node: `+t);o(t,a,c,s)}),s}function r(e,t,n,r){for(var i=[[e,!1]];i.length>0;){var o=i.pop();o[1]?r.push(o[0]):Object.hasOwn(n,o[0])||(n[o[0]]=!0,i.push([o[0],!0]),a(t(o[0]),e=>i.push([e,!1])))}}function i(e,t,n,r){for(var i=[e];i.length>0;){var o=i.pop();Object.hasOwn(n,o)||(n[o]=!0,r.push(o),a(t(o),e=>i.push(e)))}}function a(e,t){for(var n=e.length;n--;)t(e[n],n,e);return e}})),Zh=o(((e,t)=>{var n=Xh();t.exports=r;function r(e,t){return n(e,t,`post`)}})),Qh=o(((e,t)=>{var n=Xh();t.exports=r;function r(e,t){return n(e,t,`pre`)}})),$h=o(((e,t)=>{var n=Lh(),r=Hh();t.exports=i;function i(e,t){var i=new n,a={},o=new r,s;function c(e){var n=e.v===s?e.w:e.v,r=o.priority(n);if(r!==void 0){var i=t(e);i0;){if(s=o.removeMin(),Object.hasOwn(a,s))i.setEdge(s,a[s]);else if(l)throw Error(`Input graph is not connected: `+e);else l=!0;e.nodeEdges(s).forEach(c)}return i}})),eg=o(((e,t)=>{t.exports={components:Vh(),dijkstra:Uh(),dijkstraAll:Wh(),findCycles:Kh(),floydWarshall:qh(),isAcyclic:Yh(),postorder:Zh(),preorder:Qh(),prim:$h(),tarjan:Gh(),topsort:Jh()}})),tg=o(((e,t)=>{var n=zh();t.exports={Graph:n.Graph,json:Bh(),alg:eg(),version:n.version}})),ng=o(((e,t)=>{var n=class{constructor(){let e={};e._next=e._prev=e,this._sentinel=e}dequeue(){let e=this._sentinel,t=e._prev;if(t!==e)return r(t),t}enqueue(e){let t=this._sentinel;e._prev&&e._next&&r(e),e._next=t._next,t._next._prev=e,t._next=e,e._prev=t}toString(){let e=[],t=this._sentinel,n=t._prev;for(;n!==t;)e.push(JSON.stringify(n,i)),n=n._prev;return`[`+e.join(`, `)+`]`}};function r(e){e._prev._next=e._next,e._next._prev=e._prev,delete e._next,delete e._prev}function i(e,t){if(e!==`_next`&&e!==`_prev`)return t}t.exports=n})),rg=o(((e,t)=>{var n=tg().Graph,r=ng();t.exports=a;var i=()=>1;function a(e,t){if(e.nodeCount()<=1)return[];let n=c(e,t||i);return o(n.graph,n.buckets,n.zeroIdx).flatMap(t=>e.outEdges(t.v,t.w))}function o(e,t,n){let r=[],i=t[t.length-1],a=t[0],o;for(;e.nodeCount();){for(;o=a.dequeue();)s(e,t,n,o);for(;o=i.dequeue();)s(e,t,n,o);if(e.nodeCount()){for(let i=t.length-2;i>0;--i)if(o=t[i].dequeue(),o){r=r.concat(s(e,t,n,o,!0));break}}}return r}function s(e,t,n,r,i){let a=i?[]:void 0;return e.inEdges(r.v).forEach(r=>{let o=e.edge(r),s=e.node(r.v);i&&a.push({v:r.v,w:r.w}),s.out-=o,l(t,n,s)}),e.outEdges(r.v).forEach(r=>{let i=e.edge(r),a=r.w,o=e.node(a);o.in-=i,l(t,n,o)}),e.removeNode(r.v),a}function c(e,t){let i=new n,a=0,o=0;e.nodes().forEach(e=>{i.setNode(e,{v:e,in:0,out:0})}),e.edges().forEach(e=>{let n=i.edge(e.v,e.w)||0,r=t(e),s=n+r;i.setEdge(e.v,e.w,s),o=Math.max(o,i.node(e.v).out+=r),a=Math.max(a,i.node(e.w).in+=r)});let s=u(o+a+3).map(()=>new r),c=a+1;return i.nodes().forEach(e=>{l(s,c,i.node(e))}),{graph:i,buckets:s,zeroIdx:c}}function l(e,t,n){n.out?n.in?e[n.out-n.in+t].enqueue(n):e[e.length-1].enqueue(n):e[0].enqueue(n)}function u(e){let t=[];for(let n=0;n{var n=tg().Graph;t.exports={addBorderNode:f,addDummyNode:r,applyWithChunking:h,asNonCompoundGraph:a,buildLayerMatrix:l,intersectRect:c,mapValues:w,maxRank:g,normalizeRanks:u,notime:y,partition:_,pick:C,predecessorWeights:s,range:S,removeEmptyRanks:d,simplify:i,successorWeights:o,time:v,uniqueId:x,zipObject:T};function r(e,t,n,r){for(var i=r;e.hasNode(i);)i=x(r);return n.dummy=t,e.setNode(i,n),i}function i(e){let t=new n().setGraph(e.graph());return e.nodes().forEach(n=>t.setNode(n,e.node(n))),e.edges().forEach(n=>{let r=t.edge(n.v,n.w)||{weight:0,minlen:1},i=e.edge(n);t.setEdge(n.v,n.w,{weight:r.weight+i.weight,minlen:Math.max(r.minlen,i.minlen)})}),t}function a(e){let t=new n({multigraph:e.isMultigraph()}).setGraph(e.graph());return e.nodes().forEach(n=>{e.children(n).length||t.setNode(n,e.node(n))}),e.edges().forEach(n=>{t.setEdge(n,e.edge(n))}),t}function o(e){let t=e.nodes().map(t=>{let n={};return e.outEdges(t).forEach(t=>{n[t.w]=(n[t.w]||0)+e.edge(t).weight}),n});return T(e.nodes(),t)}function s(e){let t=e.nodes().map(t=>{let n={};return e.inEdges(t).forEach(t=>{n[t.v]=(n[t.v]||0)+e.edge(t).weight}),n});return T(e.nodes(),t)}function c(e,t){let n=e.x,r=e.y,i=t.x-n,a=t.y-r,o=e.width/2,s=e.height/2;if(!i&&!a)throw Error(`Not possible to find intersection inside of the rectangle`);let c,l;return Math.abs(a)*o>Math.abs(i)*s?(a<0&&(s=-s),c=s*i/a,l=s):(i<0&&(o=-o),c=o,l=o*a/i),{x:n+c,y:r+l}}function l(e){let t=S(g(e)+1).map(()=>[]);return e.nodes().forEach(n=>{let r=e.node(n),i=r.rank;i!==void 0&&(t[i][r.order]=n)}),t}function u(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MAX_VALUE:n}),n=h(Math.min,t);e.nodes().forEach(t=>{let r=e.node(t);Object.hasOwn(r,`rank`)&&(r.rank-=n)})}function d(e){let t=e.nodes().map(t=>e.node(t).rank),n=h(Math.min,t),r=[];e.nodes().forEach(t=>{let i=e.node(t).rank-n;r[i]||(r[i]=[]),r[i].push(t)});let i=0,a=e.graph().nodeRankFactor;Array.from(r).forEach((t,n)=>{t===void 0&&n%a!==0?--i:t!==void 0&&i&&t.forEach(t=>e.node(t).rank+=i)})}function f(e,t,n,i){let a={width:0,height:0};return arguments.length>=4&&(a.rank=n,a.order=i),r(e,`border`,a,t)}function p(e,t=m){let n=[];for(let r=0;rm){let n=p(t);return e.apply(null,n.map(t=>e.apply(null,t)))}else return e.apply(null,t)}function g(e){let t=e.nodes().map(t=>{let n=e.node(t).rank;return n===void 0?Number.MIN_VALUE:n});return h(Math.max,t)}function _(e,t){let n={lhs:[],rhs:[]};return e.forEach(e=>{t(e)?n.lhs.push(e):n.rhs.push(e)}),n}function v(e,t){let n=Date.now();try{return t()}finally{console.log(e+` time: `+(Date.now()-n)+`ms`)}}function y(e,t){return t()}var b=0;function x(e){return e+(``+ ++b)}function S(e,t,n=1){t??(t=e,e=0);let r=e=>ete[t]),Object.entries(e).reduce((e,[t,r])=>(e[t]=n(r,t),e),{})}function T(e,t){return e.reduce((e,n,r)=>(e[n]=t[r],e),{})}})),ag=o(((e,t)=>{var n=rg(),r=ig().uniqueId;t.exports={run:i,undo:o};function i(e){(e.graph().acyclicer===`greedy`?n(e,t(e)):a(e)).forEach(t=>{let n=e.edge(t);e.removeEdge(t),n.forwardName=t.name,n.reversed=!0,e.setEdge(t.w,t.v,n,r(`rev`))});function t(e){return t=>e.edge(t).weight}}function a(e){let t=[],n={},r={};function i(a){Object.hasOwn(r,a)||(r[a]=!0,n[a]=!0,e.outEdges(a).forEach(e=>{Object.hasOwn(n,e.w)?t.push(e):i(e.w)}),delete n[a])}return e.nodes().forEach(i),t}function o(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.reversed){e.removeEdge(t);let r=n.forwardName;delete n.reversed,delete n.forwardName,e.setEdge(t.w,t.v,n,r)}})}})),og=o(((e,t)=>{var n=ig();t.exports={run:r,undo:a};function r(e){e.graph().dummyChains=[],e.edges().forEach(t=>i(e,t))}function i(e,t){let r=t.v,i=e.node(r).rank,a=t.w,o=e.node(a).rank,s=t.name,c=e.edge(t),l=c.labelRank;if(o===i+1)return;e.removeEdge(t);let u,d,f;for(f=0,++i;i{let n=e.node(t),r=n.edgeLabel,i;for(e.setEdge(n.edgeObj,r);n.dummy;)i=e.successors(t)[0],e.removeNode(t),r.points.push({x:n.x,y:n.y}),n.dummy===`edge-label`&&(r.x=n.x,r.y=n.y,r.width=n.width,r.height=n.height),t=i,n=e.node(t)})}})),sg=o(((e,t)=>{var{applyWithChunking:n}=ig();t.exports={longestPath:r,slack:i};function r(e){var t={};function r(i){var a=e.node(i);if(Object.hasOwn(t,i))return a.rank;t[i]=!0;let o=e.outEdges(i).map(t=>t==null?1/0:r(t.w)-e.edge(t).minlen);var s=n(Math.min,o);return s===1/0&&(s=0),a.rank=s}e.sources().forEach(r)}function i(e,t){return e.node(t.w).rank-e.node(t.v).rank-e.edge(t).minlen}})),cg=o(((e,t)=>{var n=tg().Graph,r=sg().slack;t.exports=i;function i(e){var t=new n({directed:!1}),i=e.nodes()[0],c=e.nodeCount();t.setNode(i,{});for(var l,u;a(t,e){var o=a.v,s=i===o?a.w:o;!e.hasNode(s)&&!r(t,a)&&(e.setNode(s,{}),e.setEdge(i,s,{}),n(s))})}return e.nodes().forEach(n),e.nodeCount()}function o(e,t){return t.edges().reduce((n,i)=>{let a=1/0;return e.hasNode(i.v)!==e.hasNode(i.w)&&(a=r(t,i)),at.node(e).rank+=n)}})),lg=o(((e,t)=>{var n=cg(),r=sg().slack,i=sg().longestPath,a=tg().alg.preorder,o=tg().alg.postorder,s=ig().simplify;t.exports=c,c.initLowLimValues=f,c.initCutValues=l,c.calcCutValue=d,c.leaveEdge=m,c.enterEdge=h,c.exchangeEdges=g;function c(e){e=s(e),i(e);var t=n(e);f(t),l(t,e);for(var r,a;r=m(t);)a=h(t,e,r),g(t,e,r,a)}function l(e,t){var n=o(e,e.nodes());n=n.slice(0,n.length-1),n.forEach(n=>u(e,t,n))}function u(e,t,n){var r=e.node(n).parent;e.edge(n,r).cutvalue=d(e,t,n)}function d(e,t,n){var r=e.node(n).parent,i=!0,a=t.edge(n,r),o=0;return a||=(i=!1,t.edge(r,n)),o=a.weight,t.nodeEdges(n).forEach(a=>{var s=a.v===n,c=s?a.w:a.v;if(c!==r){var l=s===i,u=t.edge(a).weight;if(o+=l?u:-u,v(e,n,c)){var d=e.edge(n,c).cutvalue;o+=l?-d:d}}}),o}function f(e,t){arguments.length<2&&(t=e.nodes()[0]),p(e,{},1,t)}function p(e,t,n,r,i){var a=n,o=e.node(r);return t[r]=!0,e.neighbors(r).forEach(i=>{Object.hasOwn(t,i)||(n=p(e,t,n,i,r))}),o.low=a,o.lim=n++,i?o.parent=i:delete o.parent,n}function m(e){return e.edges().find(t=>e.edge(t).cutvalue<0)}function h(e,t,n){var i=n.v,a=n.w;t.hasEdge(i,a)||(i=n.w,a=n.v);var o=e.node(i),s=e.node(a),c=o,l=!1;return o.lim>s.lim&&(c=s,l=!0),t.edges().filter(t=>l===y(e,e.node(t.v),c)&&l!==y(e,e.node(t.w),c)).reduce((e,n)=>r(t,n)!t.node(e).parent));n=n.slice(1),n.forEach(n=>{var r=e.node(n).parent,i=t.edge(n,r),a=!1;i||(i=t.edge(r,n),a=!0),t.node(n).rank=t.node(r).rank+(a?i.minlen:-i.minlen)})}function v(e,t,n){return e.hasEdge(t,n)}function y(e,t,n){return n.low<=t.lim&&t.lim<=n.lim}})),ug=o(((e,t)=>{var n=sg().longestPath,r=cg(),i=lg();t.exports=a;function a(e){var t=e.graph().ranker;if(t instanceof Function)return t(e);switch(e.graph().ranker){case`network-simplex`:c(e);break;case`tight-tree`:s(e);break;case`longest-path`:o(e);break;case`none`:break;default:c(e)}}var o=n;function s(e){n(e),r(e)}function c(e){i(e)}})),dg=o(((e,t)=>{t.exports=n;function n(e){let t=i(e);e.graph().dummyChains.forEach(n=>{let i=e.node(n),a=i.edgeObj,o=r(e,t,a.v,a.w),s=o.path,c=o.lca,l=0,u=s[l],d=!0;for(;n!==a.w;){if(i=e.node(n),d){for(;(u=s[l])!==c&&e.node(u).maxRanko||s>t[c].lim));for(l=c,c=r;(c=e.parent(c))!==l;)a.push(c);return{path:i.concat(a.reverse()),lca:l}}function i(e){let t={},n=0;function r(i){let a=n;e.children(i).forEach(r),t[i]={low:a,lim:n++}}return e.children().forEach(r),t}})),fg=o(((e,t)=>{var n=ig();t.exports={run:r,cleanup:s};function r(e){let t=n.addDummyNode(e,`root`,{},`_root`),r=a(e),s=Object.values(r),c=n.applyWithChunking(Math.max,s)-1,l=2*c+1;e.graph().nestingRoot=t,e.edges().forEach(t=>e.edge(t).minlen*=l);let u=o(e)+1;e.children().forEach(n=>i(e,t,l,u,c,r,n)),e.graph().nodeRankFactor=l}function i(e,t,r,a,o,s,c){let l=e.children(c);if(!l.length){c!==t&&e.setEdge(t,c,{weight:0,minlen:r});return}let u=n.addBorderNode(e,`_bt`),d=n.addBorderNode(e,`_bb`),f=e.node(c);e.setParent(u,c),f.borderTop=u,e.setParent(d,c),f.borderBottom=d,l.forEach(n=>{i(e,t,r,a,o,s,n);let l=e.node(n),f=l.borderTop?l.borderTop:n,p=l.borderBottom?l.borderBottom:n,m=l.borderTop?a:2*a,h=f===p?o-s[c]+1:1;e.setEdge(u,f,{weight:m,minlen:h,nestingEdge:!0}),e.setEdge(p,d,{weight:m,minlen:h,nestingEdge:!0})}),e.parent(c)||e.setEdge(t,u,{weight:0,minlen:o+s[c]})}function a(e){var t={};function n(r,i){var a=e.children(r);a&&a.length&&a.forEach(e=>n(e,i+1)),t[r]=i}return e.children().forEach(e=>n(e,1)),t}function o(e){return e.edges().reduce((t,n)=>t+e.edge(n).weight,0)}function s(e){var t=e.graph();e.removeNode(t.nestingRoot),delete t.nestingRoot,e.edges().forEach(t=>{e.edge(t).nestingEdge&&e.removeEdge(t)})}})),pg=o(((e,t)=>{var n=ig();t.exports=r;function r(e){function t(n){let r=e.children(n),a=e.node(n);if(r.length&&r.forEach(t),Object.hasOwn(a,`minRank`)){a.borderLeft=[],a.borderRight=[];for(let t=a.minRank,r=a.maxRank+1;t{t.exports={adjust:n,undo:r};function n(e){let t=e.graph().rankdir.toLowerCase();(t===`lr`||t===`rl`)&&i(e)}function r(e){let t=e.graph().rankdir.toLowerCase();(t===`bt`||t===`rl`)&&o(e),(t===`lr`||t===`rl`)&&(c(e),i(e))}function i(e){e.nodes().forEach(t=>a(e.node(t))),e.edges().forEach(t=>a(e.edge(t)))}function a(e){let t=e.width;e.width=e.height,e.height=t}function o(e){e.nodes().forEach(t=>s(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(s),Object.hasOwn(n,`y`)&&s(n)})}function s(e){e.y=-e.y}function c(e){e.nodes().forEach(t=>l(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);n.points.forEach(l),Object.hasOwn(n,`x`)&&l(n)})}function l(e){let t=e.x;e.x=e.y,e.y=t}})),hg=o(((e,t)=>{var n=ig();t.exports=r;function r(e){let t={},r=e.nodes().filter(t=>!e.children(t).length),i=r.map(t=>e.node(t).rank),a=n.applyWithChunking(Math.max,i),o=n.range(a+1).map(()=>[]);function s(n){t[n]||(t[n]=!0,o[e.node(n).rank].push(n),e.successors(n).forEach(s))}return r.sort((t,n)=>e.node(t).rank-e.node(n).rank).forEach(s),o}})),gg=o(((e,t)=>{var n=ig().zipObject;t.exports=r;function r(e,t){let n=0;for(let r=1;rt)),a=t.flatMap(t=>e.outEdges(t).map(t=>({pos:i[t.w],weight:e.edge(t).weight})).sort((e,t)=>e.pos-t.pos)),o=1;for(;o{let t=e.pos+o;c[t]+=e.weight;let n=0;for(;t>0;)t%2&&(n+=c[t+1]),t=t-1>>1,c[t]+=e.weight;l+=e.weight*n}),l}})),_g=o(((e,t)=>{t.exports=n;function n(e,t=[]){return t.map(t=>{let n=e.inEdges(t);if(n.length){let r=n.reduce((t,n)=>{let r=e.edge(n),i=e.node(n.v);return{sum:t.sum+r.weight*i.order,weight:t.weight+r.weight}},{sum:0,weight:0});return{v:t,barycenter:r.sum/r.weight,weight:r.weight}}else return{v:t}})}})),vg=o(((e,t)=>{var n=ig();t.exports=r;function r(e,t){let n={};return e.forEach((e,t)=>{let r=n[e.v]={indegree:0,in:[],out:[],vs:[e.v],i:t};e.barycenter!==void 0&&(r.barycenter=e.barycenter,r.weight=e.weight)}),t.edges().forEach(e=>{let t=n[e.v],r=n[e.w];t!==void 0&&r!==void 0&&(r.indegree++,t.out.push(n[e.w]))}),i(Object.values(n).filter(e=>!e.indegree))}function i(e){let t=[];function r(e){return t=>{t.merged||(t.barycenter===void 0||e.barycenter===void 0||t.barycenter>=e.barycenter)&&a(e,t)}}function i(t){return n=>{n.in.push(t),--n.indegree===0&&e.push(n)}}for(;e.length;){let n=e.pop();t.push(n),n.in.reverse().forEach(r(n)),n.out.forEach(i(n))}return t.filter(e=>!e.merged).map(e=>n.pick(e,[`vs`,`i`,`barycenter`,`weight`]))}function a(e,t){let n=0,r=0;e.weight&&(n+=e.barycenter*e.weight,r+=e.weight),t.weight&&(n+=t.barycenter*t.weight,r+=t.weight),e.vs=t.vs.concat(e.vs),e.barycenter=n/r,e.weight=r,e.i=Math.min(t.i,e.i),t.merged=!0}})),yg=o(((e,t)=>{var n=ig();t.exports=r;function r(e,t){let r=n.partition(e,e=>Object.hasOwn(e,`barycenter`)),o=r.lhs,s=r.rhs.sort((e,t)=>t.i-e.i),c=[],l=0,u=0,d=0;o.sort(a(!!t)),d=i(c,s,d),o.forEach(e=>{d+=e.vs.length,c.push(e.vs),l+=e.barycenter*e.weight,u+=e.weight,d=i(c,s,d)});let f={vs:c.flat(!0)};return u&&(f.barycenter=l/u,f.weight=u),f}function i(e,t,n){let r;for(;t.length&&(r=t[t.length-1]).i<=n;)t.pop(),e.push(r.vs),n++;return n}function a(e){return(t,n)=>t.barycentern.barycenter?1:e?n.i-t.i:t.i-n.i}})),bg=o(((e,t)=>{var n=_g(),r=vg(),i=yg();t.exports=a;function a(e,t,c,l){let u=e.children(t),d=e.node(t),f=d?d.borderLeft:void 0,p=d?d.borderRight:void 0,m={};f&&(u=u.filter(e=>e!==f&&e!==p));let h=n(e,u);h.forEach(t=>{if(e.children(t.v).length){let n=a(e,t.v,c,l);m[t.v]=n,Object.hasOwn(n,`barycenter`)&&s(t,n)}});let g=r(h,c);o(g,m);let _=i(g,l);if(f&&(_.vs=[f,_.vs,p].flat(!0),e.predecessors(f).length)){let t=e.node(e.predecessors(f)[0]),n=e.node(e.predecessors(p)[0]);Object.hasOwn(_,`barycenter`)||(_.barycenter=0,_.weight=0),_.barycenter=(_.barycenter*_.weight+t.order+n.order)/(_.weight+2),_.weight+=2}return _}function o(e,t){e.forEach(e=>{e.vs=e.vs.flatMap(e=>t[e]?t[e].vs:e)})}function s(e,t){e.barycenter===void 0?(e.barycenter=t.barycenter,e.weight=t.weight):(e.barycenter=(e.barycenter*e.weight+t.barycenter*t.weight)/(e.weight+t.weight),e.weight+=t.weight)}})),xg=o(((e,t)=>{var n=tg().Graph,r=ig();t.exports=i;function i(e,t,r,i){i||=e.nodes();let o=a(e),s=new n({compound:!0}).setGraph({root:o}).setDefaultNodeLabel(t=>e.node(t));return i.forEach(n=>{let i=e.node(n),a=e.parent(n);(i.rank===t||i.minRank<=t&&t<=i.maxRank)&&(s.setNode(n),s.setParent(n,a||o),e[r](n).forEach(t=>{let r=t.v===n?t.w:t.v,i=s.edge(r,n),a=i===void 0?0:i.weight;s.setEdge(r,n,{weight:e.edge(t).weight+a})}),Object.hasOwn(i,`minRank`)&&s.setNode(n,{borderLeft:i.borderLeft[t],borderRight:i.borderRight[t]}))}),s}function a(e){for(var t;e.hasNode(t=r.uniqueId(`_root`)););return t}})),Sg=o(((e,t)=>{t.exports=n;function n(e,t,n){let r={},i;n.forEach(n=>{let a=e.parent(n),o,s;for(;a;){if(o=e.parent(a),o?(s=r[o],r[o]=a):(s=i,i=a),s&&s!==a){t.setEdge(s,a);return}a=o}})}})),Cg=o(((e,t)=>{var n=hg(),r=gg(),i=bg(),a=xg(),o=Sg(),s=tg().Graph,c=ig();t.exports=l;function l(e,t){if(t&&typeof t.customOrder==`function`){t.customOrder(e,l);return}let i=c.maxRank(e),a=u(e,c.range(1,i+1),`inEdges`),o=u(e,c.range(i-1,-1,-1),`outEdges`),s=n(e);if(f(e,s),t&&t.disableOptimalOrderHeuristic)return;let p=1/0,m;for(let t=0,n=0;n<4;++t,++n){d(t%2?a:o,t%4>=2),s=c.buildLayerMatrix(e);let i=r(e,s);i{r.has(e)||r.set(e,[]),r.get(e).push(t)};for(let t of e.nodes()){let n=e.node(t);if(typeof n.rank==`number`&&i(n.rank,t),typeof n.minRank==`number`&&typeof n.maxRank==`number`)for(let e=n.minRank;e<=n.maxRank;e++)e!==n.rank&&i(e,t)}return t.map(function(t){return a(e,t,n,r.get(t)||[])})}function d(e,t){let n=new s;e.forEach(function(e){let r=e.graph().root,a=i(e,r,n,t);a.vs.forEach((t,n)=>e.node(t).order=n),o(e,n,a.vs)})}function f(e,t){Object.values(t).forEach(t=>t.forEach((t,n)=>e.node(t).order=n))}})),wg=o(((e,t)=>{var n=tg().Graph,r=ig();t.exports={positionX:h,findType1Conflicts:i,findType2Conflicts:a,addConflict:s,hasConflict:c,verticalAlignment:l,horizontalCompaction:u,alignCoordinates:p,findSmallestWidthAlignment:f,balance:m};function i(e,t){let n={};function r(t,r){let i=0,a=0,c=t.length,l=r[r.length-1];return r.forEach((t,u)=>{let d=o(e,t),f=d?e.node(d).order:c;(d||t===l)&&(r.slice(a,u+1).forEach(t=>{e.predecessors(t).forEach(r=>{let a=e.node(r),o=a.order;(o{l=t[r],e.node(l).dummy&&e.predecessors(l).forEach(t=>{let r=e.node(t);r.dummy&&(r.orderc)&&s(n,t,l)})})}function a(t,n){let r=-1,a,o=0;return n.forEach((s,c)=>{if(e.node(s).dummy===`border`){let t=e.predecessors(s);t.length&&(a=e.node(t[0]).order,i(n,o,c,r,a),o=c,r=a)}i(n,o,n.length,a,t.length)}),n}return t.length&&t.reduce(a),n}function o(e,t){if(e.node(t).dummy)return e.predecessors(t).find(t=>e.node(t).dummy)}function s(e,t,n){if(t>n){let e=t;t=n,n=e}let r=e[t];r||(e[t]=r={}),r[n]=!0}function c(e,t,n){if(t>n){let e=t;t=n,n=e}return!!e[t]&&Object.hasOwn(e[t],n)}function l(e,t,n,r){let i={},a={},o={};return t.forEach(e=>{e.forEach((e,t)=>{i[e]=e,a[e]=e,o[e]=t})}),t.forEach(e=>{let t=-1;e.forEach(e=>{let s=r(e);if(s.length){s=s.sort((e,t)=>o[e]-o[t]);let r=(s.length-1)/2;for(let l=Math.floor(r),u=Math.ceil(r);l<=u;++l){let r=s[l];a[e]===e&&tMath.max(e,a[t.v]+o.edge(t)),0)}function u(t){let n=o.outEdges(t).reduce((e,t)=>Math.min(e,a[t.w]-o.edge(t)),1/0),r=e.node(t);n!==1/0&&r.borderType!==s&&(a[t]=Math.max(a[t],n))}return c(l,o.predecessors.bind(o)),c(u,o.successors.bind(o)),Object.keys(r).forEach(e=>a[e]=a[n[e]]),a}function d(e,t,r,i){let a=new n,o=e.graph(),s=g(o.nodesep,o.edgesep,i);return t.forEach(t=>{let n;t.forEach(t=>{let i=r[t];if(a.setNode(i),n){var o=r[n],c=a.edge(o,i);a.setEdge(o,i,Math.max(s(e,t,n),c||0))}n=t})}),a}function f(e,t){return Object.values(t).reduce((t,n)=>{let r=-1/0,i=1/0;Object.entries(n).forEach(([t,n])=>{let a=_(e,t)/2;r=Math.max(n+a,r),i=Math.min(n-a,i)});let a=r-i;return a{[`l`,`r`].forEach(o=>{let s=n+o,c=e[s];if(c===t)return;let l=Object.values(c),u=i-r.applyWithChunking(Math.min,l);o!==`l`&&(u=a-r.applyWithChunking(Math.max,l)),u&&(e[s]=r.mapValues(c,e=>e+u))})})}function m(e,t){return r.mapValues(e.ul,(n,r)=>{if(t)return e[t.toLowerCase()][r];{let t=Object.values(e).map(e=>e[r]).sort((e,t)=>e-t);return(t[1]+t[2])/2}})}function h(e){let t=r.buildLayerMatrix(e),n=Object.assign(i(e,t),a(e,t)),o={},s;return[`u`,`d`].forEach(i=>{s=i===`u`?t:Object.values(t).reverse(),[`l`,`r`].forEach(t=>{t===`r`&&(s=s.map(e=>Object.values(e).reverse()));let a=(i===`u`?e.predecessors:e.successors).bind(e),c=l(e,s,n,a),d=u(e,s,c.root,c.align,t===`r`);t===`r`&&(d=r.mapValues(d,e=>-e)),o[i+t]=d})}),p(o,f(e,o)),m(o,e.graph().align)}function g(e,t,n){return(r,i,a)=>{let o=r.node(i),s=r.node(a),c=0,l;if(c+=o.width/2,Object.hasOwn(o,`labelpos`))switch(o.labelpos.toLowerCase()){case`l`:l=-o.width/2;break;case`r`:l=o.width/2;break}if(l&&(c+=n?l:-l),l=0,c+=(o.dummy?t:e)/2,c+=(s.dummy?t:e)/2,c+=s.width/2,Object.hasOwn(s,`labelpos`))switch(s.labelpos.toLowerCase()){case`l`:l=s.width/2;break;case`r`:l=-s.width/2;break}return l&&(c+=n?l:-l),l=0,c}}function _(e,t){return e.node(t).width}})),Tg=o(((e,t)=>{var n=ig(),r=wg().positionX;t.exports=i;function i(e){e=n.asNonCompoundGraph(e),a(e),Object.entries(r(e)).forEach(([t,n])=>e.node(t).x=n)}function a(e){let t=n.buildLayerMatrix(e),r=e.graph().ranksep,i=0;t.forEach(t=>{let n=t.reduce((t,n)=>{let r=e.node(n).height;return t>r?t:r},0);t.forEach(t=>e.node(t).y=i+n/2),i+=n+r})}})),Eg=o(((e,t)=>{var n=ag(),r=og(),i=ug(),a=ig().normalizeRanks,o=dg(),s=ig().removeEmptyRanks,c=fg(),l=pg(),u=mg(),d=Cg(),f=Tg(),p=ig(),m=tg().Graph;t.exports=h;function h(e,t){let n=t&&t.debugTiming?p.time:p.notime;n(`layout`,()=>{let r=n(` buildLayoutGraph`,()=>E(e));n(` runLayout`,()=>g(r,n,t)),n(` updateInputGraph`,()=>_(e,r))})}function g(e,t,m){t(` makeSpaceForEdgeLabels`,()=>D(e)),t(` removeSelfEdges`,()=>P(e)),t(` acyclic`,()=>n.run(e)),t(` nestingGraph.run`,()=>c.run(e)),t(` rank`,()=>i(p.asNonCompoundGraph(e))),t(` injectEdgeLabelProxies`,()=>O(e)),t(` removeEmptyRanks`,()=>s(e)),t(` nestingGraph.cleanup`,()=>c.cleanup(e)),t(` normalizeRanks`,()=>a(e)),t(` assignRankMinMax`,()=>k(e)),t(` removeEdgeLabelProxies`,()=>A(e)),t(` normalize.run`,()=>r.run(e)),t(` parentDummyChains`,()=>o(e)),t(` addBorderSegments`,()=>l(e)),t(` order`,()=>d(e,m)),t(` insertSelfEdges`,()=>F(e)),t(` adjustCoordinateSystem`,()=>u.adjust(e)),t(` position`,()=>f(e)),t(` positionSelfEdges`,()=>ne(e)),t(` removeBorderNodes`,()=>te(e)),t(` normalize.undo`,()=>r.undo(e)),t(` fixupEdgeLabelCoords`,()=>N(e)),t(` undoCoordinateSystem`,()=>u.undo(e)),t(` translateGraph`,()=>j(e)),t(` assignNodeIntersects`,()=>M(e)),t(` reversePoints`,()=>ee(e)),t(` acyclic.undo`,()=>n.undo(e))}function _(e,t){e.nodes().forEach(n=>{let r=e.node(n),i=t.node(n);r&&(r.x=i.x,r.y=i.y,r.rank=i.rank,t.children(n).length&&(r.width=i.width,r.height=i.height))}),e.edges().forEach(n=>{let r=e.edge(n),i=t.edge(n);r.points=i.points,Object.hasOwn(i,`x`)&&(r.x=i.x,r.y=i.y)}),e.graph().width=t.graph().width,e.graph().height=t.graph().height}var v=[`nodesep`,`edgesep`,`ranksep`,`marginx`,`marginy`],y={ranksep:50,edgesep:20,nodesep:50,rankdir:`tb`},b=[`acyclicer`,`ranker`,`rankdir`,`align`],x=[`width`,`height`,`rank`],S={width:0,height:0},C=[`minlen`,`weight`,`width`,`height`,`labeloffset`],w={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:`r`},T=[`labelpos`];function E(e){let t=new m({multigraph:!0,compound:!0}),n=ie(e.graph());return t.setGraph(Object.assign({},y,re(n,v),p.pick(n,b))),e.nodes().forEach(n=>{let r=re(ie(e.node(n)),x);Object.keys(S).forEach(e=>{r[e]===void 0&&(r[e]=S[e])}),t.setNode(n,r),t.setParent(n,e.parent(n))}),e.edges().forEach(n=>{let r=ie(e.edge(n));t.setEdge(n,Object.assign({},w,re(r,C),p.pick(r,T)))}),t}function D(e){let t=e.graph();t.ranksep/=2,e.edges().forEach(n=>{let r=e.edge(n);r.minlen*=2,r.labelpos.toLowerCase()!==`c`&&(t.rankdir===`TB`||t.rankdir===`BT`?r.width+=r.labeloffset:r.height+=r.labeloffset)})}function O(e){e.edges().forEach(t=>{let n=e.edge(t);if(n.width&&n.height){let n=e.node(t.v),r={rank:(e.node(t.w).rank-n.rank)/2+n.rank,e:t};p.addDummyNode(e,`edge-proxy`,r,`_ep`)}})}function k(e){let t=0;e.nodes().forEach(n=>{let r=e.node(n);r.borderTop&&(r.minRank=e.node(r.borderTop).rank,r.maxRank=e.node(r.borderBottom).rank,t=Math.max(t,r.maxRank))}),e.graph().maxRank=t}function A(e){e.nodes().forEach(t=>{let n=e.node(t);n.dummy===`edge-proxy`&&(e.edge(n.e).labelRank=n.rank,e.removeNode(t))})}function j(e){let t=1/0,n=0,r=1/0,i=0,a=e.graph(),o=a.marginx||0,s=a.marginy||0;function c(e){let a=e.x,o=e.y,s=e.width,c=e.height;t=Math.min(t,a-s/2),n=Math.max(n,a+s/2),r=Math.min(r,o-c/2),i=Math.max(i,o+c/2)}e.nodes().forEach(t=>c(e.node(t))),e.edges().forEach(t=>{let n=e.edge(t);Object.hasOwn(n,`x`)&&c(n)}),t-=o,r-=s,e.nodes().forEach(n=>{let i=e.node(n);i.x-=t,i.y-=r}),e.edges().forEach(n=>{let i=e.edge(n);i.points.forEach(e=>{e.x-=t,e.y-=r}),Object.hasOwn(i,`x`)&&(i.x-=t),Object.hasOwn(i,`y`)&&(i.y-=r)}),a.width=n-t+o,a.height=i-r+s}function M(e){e.edges().forEach(t=>{let n=e.edge(t),r=e.node(t.v),i=e.node(t.w),a,o;n.points?(a=n.points[0],o=n.points[n.points.length-1]):(n.points=[],a=i,o=r),n.points.unshift(p.intersectRect(r,a)),n.points.push(p.intersectRect(i,o))})}function N(e){e.edges().forEach(t=>{let n=e.edge(t);if(Object.hasOwn(n,`x`))switch((n.labelpos===`l`||n.labelpos===`r`)&&(n.width-=n.labeloffset),n.labelpos){case`l`:n.x-=n.width/2+n.labeloffset;break;case`r`:n.x+=n.width/2+n.labeloffset;break}})}function ee(e){e.edges().forEach(t=>{let n=e.edge(t);n.reversed&&n.points.reverse()})}function te(e){e.nodes().forEach(t=>{if(e.children(t).length){let n=e.node(t),r=e.node(n.borderTop),i=e.node(n.borderBottom),a=e.node(n.borderLeft[n.borderLeft.length-1]),o=e.node(n.borderRight[n.borderRight.length-1]);n.width=Math.abs(o.x-a.x),n.height=Math.abs(i.y-r.y),n.x=a.x+n.width/2,n.y=r.y+n.height/2}}),e.nodes().forEach(t=>{e.node(t).dummy===`border`&&e.removeNode(t)})}function P(e){e.edges().forEach(t=>{if(t.v===t.w){var n=e.node(t.v);n.selfEdges||=[],n.selfEdges.push({e:t,label:e.edge(t)}),e.removeEdge(t)}})}function F(e){p.buildLayerMatrix(e).forEach(t=>{var n=0;t.forEach((t,r)=>{var i=e.node(t);i.order=r+n,(i.selfEdges||[]).forEach(t=>{p.addDummyNode(e,`selfedge`,{width:t.label.width,height:t.label.height,rank:i.rank,order:r+ ++n,e:t.e,label:t.label},`_se`)}),delete i.selfEdges})})}function ne(e){e.nodes().forEach(t=>{var n=e.node(t);if(n.dummy===`selfedge`){var r=e.node(n.e.v),i=r.x+r.width/2,a=r.y,o=n.x-i,s=r.height/2;e.setEdge(n.e,n.label),e.removeNode(t),n.label.points=[{x:i+2*o/3,y:a-s},{x:i+5*o/6,y:a-s},{x:i+o,y:a},{x:i+5*o/6,y:a+s},{x:i+2*o/3,y:a+s}],n.label.x=n.x,n.label.y=n.y}})}function re(e,t){return p.mapValues(p.pick(e,t),Number)}function ie(e){var t={};return e&&Object.entries(e).forEach(([e,n])=>{typeof e==`string`&&(e=e.toLowerCase()),t[e]=n}),t}})),Dg=o(((e,t)=>{var n=ig(),r=tg().Graph;t.exports={debugOrdering:i};function i(e){let t=n.buildLayerMatrix(e),i=new r({compound:!0,multigraph:!0}).setGraph({});return e.nodes().forEach(t=>{i.setNode(t,{label:t}),i.setParent(t,`layer`+e.node(t).rank)}),e.edges().forEach(e=>i.setEdge(e.v,e.w,{},e.name)),t.forEach((e,t)=>{let n=`layer`+t;i.setNode(n,{rank:`same`}),e.reduce((e,t)=>(i.setEdge(e,t,{style:`invis`}),t))}),i}})),Og=o(((e,t)=>{t.exports=`1.1.8`})),kg=l(o(((e,t)=>{t.exports={graphlib:tg(),layout:Eg(),debug:Dg(),util:{time:ig().time,notime:ig().notime},version:Og()}}))(),1),Ag=200,jg=56,Mg=20,Ng=40,Pg=20,Fg=12,Ig=16,Lg=46,Rg=16,zg=Ag,Bg=14;function Vg(e){return{agents:e.agents,routes:e.routes,parallelGroups:e.parallelGroups,forEachGroups:e.forEachGroups,nodes:e.nodes,groupProgress:e.groupProgress,entryPoint:e.entryPoint,parentAgent:e.parentAgent,children:e.children}}function Hg(e,t,n){let{nodes:r,edges:i}=qg(e,t,n);return{nodes:r,edges:i}}function Ug(e,t,n){let r=[],i=(e,t,n)=>{for(let a of e){if((a.type||`agent`)!==`workflow`)continue;let e=-1;for(let n=t.length-1;n>=0;n--)if(t[n].slotKey===a.name){e=n;break}if(e<0)continue;let o=t[e];o.agents.length!==0&&(r.push(Th([...n,e])),i(o.agents,o.children,[...n,e]))}let a=new Set;for(let e of t){let t=Ah(e.slotKey);!t||a.has(t.group)||(a.add(t.group),r.push(Oh(n,t.group)))}};return i(e,t,n),r}function Wg(e,t){let n=[],r=e,i=[];for(let e of t){let t=r[e];if(!t)break;let a=Ah(t.slotKey);a&&n.push(Oh(i,a.group)),i.push(e),n.push(Th(i)),r=t.children}return n}function Gg(e,t){let n=[];for(let r=0;r0,m=p&&r.has(u),h={label:f?f.key:c.slotKey,name:c.slotKey,contextPath:t,type:`workflow`,status:c.status||`pending`,canExpand:p,expanded:m,childContextKey:u,childName:c.workflowName||void 0,iterationContextPath:e,isForEachIteration:!0};if(m){let t=qg(Vg(c),e,r,!0),l=t.width+Ig*2,u=t.height+Lg+Rg;i.push({id:d,type:`workflowNode`,position:{x:Ig,y:o},parentId:n,extent:`parent`,data:h,style:{width:l,height:u}});for(let e of t.nodes)e.parentId||(e.parentId=d,e.extent=`parent`,e.position={x:e.position.x+Ig,y:e.position.y+Lg}),i.push(e);for(let e of t.edges)a.push(e);o+=u+Bg,s=Math.max(s,l)}else i.push({id:d,type:`workflowNode`,position:{x:Ig,y:o},parentId:n,extent:`parent`,data:h}),o+=70}return{nodes:i,edges:a,width:s+Ig*2,height:(e.length>0?o-Bg:Lg)+Rg}}function qg(e,t,n,r=!1){let i=[],a=[],o=new Set,s=new Set,c=e.parentAgent!=null,l=e=>Eh(t,e),u=[],d=[],f=[],p=new Map;for(let t of e.parallelGroups)for(let e of t.agents)s.add(e),p.set(e,t.name);for(let n of e.parallelGroups){let r=e.nodes[n.name],a=n.agents.length,s=Ng+a*jg+(a-1)*Fg+Pg;i.push({id:l(n.name),type:`groupNode`,position:{x:0,y:0},data:{label:n.name,name:n.name,contextPath:t,type:`parallel_group`,status:r?.status||`pending`,groupName:n.name,progress:e.groupProgress[n.name]},style:{width:240,height:s}});for(let r=0;r0,u=Oh(t,r.name);if(c&&n.has(u)){let o=Kg(s,t,u,n);i.push({id:l(r.name),type:`groupNode`,position:{x:0,y:0},data:{label:r.name,name:r.name,contextPath:t,type:`for_each_group`,status:a?.status||`pending`,groupName:r.name,progress:e.groupProgress[r.name],expanded:!0,canExpand:!0,groupExpansionKey:u},style:{width:o.width,height:o.height}});for(let e of o.nodes)d.push(e);for(let e of o.edges)f.push(e)}else i.push({id:l(r.name),type:`groupNode`,position:{x:0,y:0},data:{label:r.name,name:r.name,contextPath:t,type:`for_each_group`,status:a?.status||`pending`,groupName:r.name,progress:e.groupProgress[r.name],expanded:!1,canExpand:c,groupExpansionKey:c?u:void 0}});o.add(r.name)}for(let r of e.agents){if(o.has(r.name)||s.has(r.name))continue;let a=r.type||`agent`,c=e.nodes[r.name],d=`agentNode`;if(a===`script`?d=`scriptNode`:a===`set`?d=`setNode`:a===`human_gate`?d=`gateNode`:a===`workflow`?d=`workflowNode`:a===`wait`?d=`waitNode`:a===`terminate`&&(d=`terminateNode`),a===`workflow`){let s=-1;for(let t=e.children.length-1;t>=0;t--)if(e.children[t].slotKey===r.name){s=t;break}let d=s>=0?e.children[s]:void 0,f=s>=0?Th([...t,s]):void 0,p=!!d&&d.agents.length>0;if(p&&f!=null&&n.has(f)&&d){let e=qg(Vg(d),[...t,s],n,!0),o=e.width+Ig*2,p=e.height+Lg+Rg;i.push({id:l(r.name),type:`workflowNode`,position:{x:0,y:0},data:{label:r.name,name:r.name,contextPath:t,type:a,status:c?.status||`pending`,expanded:!0,canExpand:!0,childContextKey:f,childName:d.workflowName||void 0},style:{width:o,height:p}}),u.push({containerId:l(r.name),sub:e})}else i.push({id:l(r.name),type:`workflowNode`,position:{x:0,y:0},data:{label:r.name,name:r.name,contextPath:t,type:a,status:c?.status||`pending`,expanded:!1,canExpand:p,childContextKey:f,childName:d?.workflowName||void 0}});o.add(r.name);continue}i.push({id:l(r.name),type:d,position:{x:0,y:0},data:{label:r.name,name:r.name,contextPath:t,type:a,status:c?.status||`pending`}}),o.add(r.name)}let m=!1;for(let t of e.routes)t.to===`$end`&&(m=!0);if(m){let n=e.nodes.$end;i.push({id:l(`$end`),type:c?`egressNode`:`endNode`,position:{x:0,y:0},data:{label:`$end`,name:`$end`,contextPath:t,type:c?`egress`:`end`,status:n?.status||`pending`,...c&&!r?{parentAgent:e.parentAgent??void 0}:{}}})}if(e.entryPoint){let n=e.nodes.$start;i.push({id:l(`$start`),type:c?`ingressNode`:`startNode`,position:{x:0,y:0},data:{label:`$start`,name:`$start`,contextPath:t,type:c?`ingress`:`start`,status:n?.status||`pending`,...c&&!r?{parentAgent:e.parentAgent??void 0}:{}}}),a.push({id:`${l(`$start`)}->@entry`,source:l(`$start`),target:l(e.entryPoint),type:`animatedEdge`,data:{},animated:!1})}let h=new Set(i.map(e=>e.id)),g=new Map;for(let e of i)e.parentId&&g.set(e.id,e.parentId);let _=new Map;for(let t of e.routes){let e=g.get(l(t.from))??l(t.from),n=g.get(l(t.to))??l(t.to);if(!h.has(e)||!h.has(n)||e===n)continue;let r=`${e}->${n}`,i=_.get(r);if(i){i.when!==t.when&&(a[i.idx].data={when:void 0});continue}let o=a.length;_.set(r,{when:t.when,idx:o});let s=`${r}${t.when?`[${t.when}]`:``}`;a.push({id:s,source:e,target:n,type:`animatedEdge`,data:{when:t.when},animated:!1})}let{width:v,height:y}=Xg(i,a,Jg(i,a,l(`$start`)));for(let{containerId:e,sub:t}of u){for(let n of t.nodes)n.parentId||(n.parentId=e,n.extent=`parent`,n.position={x:n.position.x+Ig,y:n.position.y+Lg}),i.push(n);for(let e of t.edges)a.push(e)}for(let e of d)i.push(e);for(let e of f)a.push(e);return{nodes:i,edges:a,width:v,height:y}}function Jg(e,t,n){let r=new Set(e.filter(e=>!e.parentId).map(e=>e.id)),i=new Map;for(let e of t)!r.has(e.source)||!r.has(e.target)||(i.has(e.source)||i.set(e.source,[]),i.get(e.source).push({target:e.target,edgeId:e.id}));for(let e of i.values())e.sort((e,t)=>e.targett.target));let a=new Set,o=new Set,s=new Set,c=e=>{s.add(e),o.add(e);for(let{target:t,edgeId:n}of i.get(e)??[])o.has(t)?a.add(n):s.has(t)||c(t);o.delete(e)};r.has(n)&&c(n);for(let e of[...i.keys()].sort())s.has(e)||c(e);return a}function Yg(e){let t=e.style?.width,n=e.style?.height;return typeof t==`number`&&typeof n==`number`?{w:t,h:n}:{w:Ag,h:jg}}function Xg(e,t,n){let r=new kg.default.graphlib.Graph;r.setDefaultEdgeLabel(()=>({})),r.setGraph({rankdir:`TB`,nodesep:50,ranksep:70,marginx:30,marginy:30});for(let t of e){if(t.parentId)continue;let{w:e,h:n}=Yg(t);r.setNode(t.id,{width:e,height:n})}for(let e of t)!r.hasNode(e.source)||!r.hasNode(e.target)||(n.has(e.id)?r.setEdge(e.target,e.source):r.setEdge(e.source,e.target));kg.default.layout(r);let i=1/0,a=1/0,o=-1/0,s=-1/0;for(let t of e){if(t.parentId)continue;let e=r.node(t.id);if(!e)continue;let{w:n,h:c}=Yg(t),l=e.x-n/2,u=e.y-c/2;t.position={x:l,y:u},i=Math.min(i,l),a=Math.min(a,u),o=Math.max(o,l+n),s=Math.max(s,u+c)}if(!Number.isFinite(i))return{width:Ag,height:jg};for(let t of e)t.parentId||(t.position={x:t.position.x-i,y:t.position.y-a});return{width:o-i,height:s-a}}function Zg(){let e=new URLSearchParams(window.location.search);return{subworkflowPath:e.get(`subworkflow`),agent:e.get(`agent`)}}function Qg(e,t){let n=[],r=e;for(let e of t){let t=-1;for(let n=r.length-1;n>=0;n--)if(r[n].slotKey===e){t=n;break}if(t===-1){for(let n=r.length-1;n>=0;n--)if(r[n].parentAgent===e){t=n;break}}if(t===-1)return{path:n,failedSegment:e};n.push(t),r=r[t].children}return{path:n,failedSegment:null}}function $g(e,t){let n=e,r=null;for(let e of t){if(r=n[e]??null,!r)return null;n=r.children}return r}function e_(e,t,n=[]){let r=[];for(let i=0;ie.name===t)&&r.push({path:o,ctx:a}),a.children.length>0&&r.push(...e_(a.children,t,o))}return r}function t_(e){return e.length===0?null:[...e].sort((e,t)=>{let n=+(e.ctx.status===`running`),r=+(t.ctx.status===`running`);if(n!==r)return r-n;if(e.path.length!==t.path.length)return t.path.length-e.path.length;for(let n=0;n{if(n.current||!s)return;let e=null,c=null,l=null,u=null,d=(e,t)=>{let n=B.getState(),r=n.subworkflowContexts;e.length>0&&!$g(r,e)&&console.warn(`[use-deep-link] reveal target path is not fully materialized; expanding only the resolved prefix`,e),n.expandContexts(Wg(r,e)),B.setState({viewContextPath:[],selectedNode:t})},f=e=>{let t=0,n=()=>{l=null;let a=i(e)?.measured;a?.width&&a?.height?r({nodes:[{id:e}],padding:.5,duration:400}):t++<40?l=requestAnimationFrame(n):(console.warn(`[use-deep-link] node "${e}" was not measured in time; fitting the whole graph instead`),r({padding:.2,duration:400}))};l=requestAnimationFrame(n)},p=()=>{if(n.current)return;n.current=!0,e&&clearTimeout(e),c&&clearTimeout(c),u&&u();let r=B.getState();if(r.agents.length===0){t({message:`Workflow state did not load.`});return}let i=[];if(a){let e=a.split(`/`).filter(Boolean),n=Qg(r.subworkflowContexts,e);if(n.failedSegment){let r=e.slice(0,n.path.length).join(`/`);d(n.path,null),t({message:`Subworkflow "${n.failedSegment}" not found${r?` (resolved: ${r})`:``}. It may not have started yet.`});return}i=n.path}if(o){if((i.length===0?r.agents:$g(r.subworkflowContexts,i)?.agents??[]).some(e=>e.name===o)){let e=Eh(i,o);d(i,e),f(e);return}let e=e_(r.subworkflowContexts,o);if(e.length===0){let e=a||`root workflow`;d(i,null),t({message:`Agent "${o}" not found in ${e}.`});return}if(a){let n=e.slice(0,5).map(e=>n_(r.subworkflowContexts,e.path)).join(`, `),s=e.length>5?`, and ${e.length-5} more`:``;d(i,null),t({message:`Agent "${o}" not found in ${a}. Found in: ${n}${s}`});return}let n=t_(e),s=Eh(n.path,o);d(n.path,s),f(s);return}if(d(i,null),i.length>0){let e=$g(r.subworkflowContexts,i);e&&f(Eh(i.slice(0,-1),e.slotKey))}},m=()=>{try{p()}catch(e){console.warn(`[use-deep-link] failed to apply deep-link target`,e),t({message:`Could not resolve the deep-link target.`})}},h=()=>{let e=B.getState();if(e.agents.length===0)return!1;if(e.workflowStatus!==`running`&&e.workflowStatus!==`pending`)return!0;if(a){let t=a.split(`/`).filter(Boolean),{failedSegment:n}=Qg(e.subworkflowContexts,t);if(n)return!1}return!(o&&!a&&!e.agents.some(e=>e.name===o)&&e_(e.subworkflowContexts,o).length===0)},g=()=>{e&&clearTimeout(e),e=setTimeout(()=>{n.current||h()&&m()},200)};return u=B.subscribe(g),c=setTimeout(()=>{n.current||m()},5e3),g(),()=>{e&&clearTimeout(e),c&&clearTimeout(c),l!=null&&cancelAnimationFrame(l),u&&u()}},[s,a,o,r,i]),e}var X={pending:`#6b7280`,running:`#3b82f6`,completed:`#22c55e`,failed:`#ef4444`,paused:`#f59e0b`,idle:`#6b7280`,waiting:`#a855f7`};function i_({data:e,children:t}){let[n,r]=(0,v.useState)(!1),i=(0,v.useRef)(null),a=(0,v.useCallback)(()=>{i.current=setTimeout(()=>r(!0),200)},[]),o=(0,v.useCallback)(()=>{i.current&&clearTimeout(i.current),r(!1)},[]),s=X[e.status]||X.pending;return(0,H.jsxs)(`div`,{className:`relative`,onMouseEnter:a,onMouseLeave:o,children:[t,n&&(0,H.jsxs)(`div`,{className:U(`absolute z-50 bottom-full left-1/2 -translate-x-1/2 mb-2`,`bg-[var(--surface-raised)] border border-[var(--border)] shadow-lg`,`rounded-lg px-3 py-2 max-w-[260px] pointer-events-none`,`animate-[tooltip-in_150ms_ease-out]`),children:[(0,H.jsx)(`div`,{className:`absolute top-full left-1/2 -translate-x-1/2 w-0 h-0 border-x-[6px] border-x-transparent border-t-[6px] border-t-[var(--border)]`}),(0,H.jsxs)(`div`,{className:`flex flex-col gap-1.5 text-[11px]`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,H.jsx)(`span`,{className:`w-2 h-2 rounded-full flex-shrink-0`,style:{backgroundColor:s}}),(0,H.jsx)(`span`,{className:`font-medium text-[var(--text)] capitalize`,children:e.status}),e.iteration!=null&&e.iteration>1&&(0,H.jsxs)(`span`,{className:`text-[var(--text-muted)] ml-auto`,children:[`iter `,e.iteration]})]}),(0,H.jsx)(`div`,{className:`h-px bg-[var(--border)]`}),(0,H.jsxs)(`div`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-0.5`,children:[e.elapsed!=null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Elapsed`}),(0,H.jsx)(`span`,{className:`text-[var(--text)] font-mono`,children:st(e.elapsed)})]}),e.model&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Model`}),(0,H.jsx)(`span`,{className:`text-[var(--text)] truncate`,children:e.model})]}),e.tokens!=null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Tokens`}),(0,H.jsxs)(`span`,{className:`text-[var(--text)] font-mono`,children:[ct(e.tokens),e.inputTokens!=null&&e.outputTokens!=null&&(0,H.jsxs)(`span`,{className:`text-[var(--text-muted)]`,children:[` `,`(`,ct(e.inputTokens),`↑ `,ct(e.outputTokens),`↓)`]})]})]}),e.costUsd!=null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Cost`}),(0,H.jsx)(`span`,{className:`text-[var(--text)] font-mono`,children:lt(e.costUsd)})]}),e.exitCode!=null&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Exit code`}),(0,H.jsx)(`span`,{className:U(`font-mono`,e.exitCode===0?`text-[var(--completed)]`:`text-[var(--failed)]`),children:e.exitCode})]}),e.selectedOption&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Selected`}),(0,H.jsx)(`span`,{className:`text-[var(--text)] truncate`,children:e.selectedOption})]}),e.terminationStatus&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)]`,children:`Termination`}),(0,H.jsx)(`span`,{className:U(`font-mono capitalize`,e.terminationStatus===`success`?`text-[var(--completed)]`:`text-[var(--failed)]`),children:e.terminationStatus})]})]}),e.reason&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`h-px bg-[var(--border)]`}),(0,H.jsxs)(`div`,{className:U(`leading-tight break-words`,e.terminationStatus===`failed`?`text-red-400`:`text-[var(--text)]`),children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] mr-1`,children:`Reason:`}),e.reason.slice(0,160),e.reason.length>160?`...`:``]})]}),e.errorMessage&&(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:`h-px bg-[var(--border)]`}),(0,H.jsxs)(`div`,{className:`text-red-400 leading-tight`,children:[e.errorType&&(0,H.jsxs)(`span`,{className:`font-medium`,children:[e.errorType,`: `]}),(0,H.jsxs)(`span`,{className:`break-words`,children:[e.errorMessage.slice(0,120),e.errorMessage.length>120?`...`:``]})]})]})]})]})]})}var a_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.elapsed,s=r?.model,c=r?.tokens,l=r?.input_tokens,u=r?.output_tokens,d=r?.cost_usd,f=r?.iteration,p=r?.error_type,m=r?.error_message,h=r?.context_pct,g=r?.provider_tier,_=r?.provider_name,v=o_(r?.startedAt,i),y=s_(i),b=(()=>{if(i===`failed`&&m)return{text:m.length>40?m.slice(0,37)+`...`:m,className:`text-red-400`};if(i===`running`)return{text:v,className:`text-[var(--text-muted)]`};if(i===`completed`){let e=[];return o!=null&&e.push(st(o)),c!=null&&e.push(`${ct(c)} tok`),d!=null&&e.push(lt(d)),{text:e.join(` · `)||null,className:`text-[var(--text-muted)]`}}return{text:null,className:``}})();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,elapsed:o,model:s,tokens:c,inputTokens:l,outputTokens:u,costUsd:d,iteration:f,errorType:p,errorMessage:m},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`,y),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`running`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(O,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),f!=null&&f>1&&(0,H.jsxs)(`span`,{className:`flex-shrink-0 inline-flex items-center justify-center px-1.5 py-0.5 rounded-full text-[9px] font-bold leading-none`,style:{backgroundColor:`${a}25`,color:a},children:[`x`,f]}),g===`experimental`&&(0,H.jsx)(`span`,{className:`flex-shrink-0 inline-flex items-center justify-center px-1.5 py-0.5 rounded-full text-[9px] font-bold leading-none uppercase tracking-wide`,style:{backgroundColor:`rgba(245, 158, 11, 0.18)`,color:`#f59e0b`},title:`Experimental provider: ${_??`unknown`}`,children:`exp`})]}),b.text&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight`,b.className),children:b.text})]}),h!=null&&(0,H.jsx)(`div`,{className:`absolute bottom-0 left-0 right-0 h-[2px] rounded-b-lg overflow-hidden`,style:{backgroundColor:`rgba(255,255,255,0.06)`},children:(0,H.jsx)(`div`,{className:U(`h-full transition-all duration-500`,h>=90?`animate-[context-pulse_2s_ease-in-out_infinite]`:``),style:{width:`${Math.min(h,100)}%`,backgroundColor:h>=90?`#ef4444`:h>=70?`#f59e0b`:`#22c55e`}})})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function o_(e,t){let n=B(e=>e.replayMode),r=B(e=>e.lastEventTime),[i,a]=(0,v.useState)(`0.0s`),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(t===`running`){if(n){o.current&&clearInterval(o.current);let t=e??r??0;a(st((r??t)-t));return}let t=e==null?Date.now():e*1e3,i=()=>{a(st((Date.now()-t)/1e3))};return i(),o.current=setInterval(i,1e3),()=>{o.current&&clearInterval(o.current)}}else o.current&&clearInterval(o.current)},[t,e,n,r]),i}function s_(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`?r(`node-activate`):n===`running`&&(e===`completed`||e===`failed`)&&r(e===`completed`?`node-complete`:`node-fail`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var c_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.elapsed,s=r?.exit_code,c=r?.error_type,l=r?.error_message,u=l_(r?.startedAt,i),d=u_(i),f=(()=>{if(i===`failed`&&l)return{text:l.length>40?l.slice(0,37)+`...`:l,className:`text-red-400`};if(i===`running`)return{text:u,className:`text-[var(--text-muted)]`};if(i===`completed`){let e=[];return o!=null&&e.push(st(o)),s!=null&&e.push(`exit ${s}`),{text:e.join(` · `)||null,className:`text-[var(--text-muted)]`}}return{text:null,className:``}})();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,elapsed:o,exitCode:s,errorType:c,errorMessage:l},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`,d),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`running`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(Se,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),f.text&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight`,f.className),children:f.text})]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function l_(e,t){let n=B(e=>e.replayMode),r=B(e=>e.lastEventTime),[i,a]=(0,v.useState)(`0.0s`),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(t===`running`){if(n){o.current&&clearInterval(o.current);let t=e??r??0;a(st((r??t)-t));return}let t=e==null?Date.now():e*1e3,i=()=>{a(st((Date.now()-t)/1e3))};return i(),o.current=setInterval(i,1e3),()=>{o.current&&clearInterval(o.current)}}else o.current&&clearInterval(o.current)},[t,e,n,r]),i}function u_(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`?r(`node-activate`):n===`running`&&(e===`completed`||e===`failed`)&&r(e===`completed`?`node-complete`:`node-fail`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var d_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.elapsed,s=r?.set_output_keys,c=r?.set_value_repr,l=r?.error_type,u=r?.error_message,d=f_(r?.startedAt,i),f=p_(i),p=(()=>{if(i===`failed`&&u)return{text:u.length>40?u.slice(0,37)+`...`:u,className:`text-red-400`};if(i===`running`)return{text:d,className:`text-[var(--text-muted)]`};if(i===`completed`){let e=[];if(o!=null&&e.push(st(o)),s&&s.length>0)e.push(`${s.length} key${s.length===1?``:`s`}`);else if(c){let t=c.length>24?c.slice(0,21)+`…`:c;e.push(t)}return{text:e.join(` · `)||null,className:`text-[var(--text-muted)]`}}return{text:null,className:``}})();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,elapsed:o,errorType:l,errorMessage:u},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`,f),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`running`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(we,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),p.text&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight`,p.className),children:p.text})]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function f_(e,t){let n=B(e=>e.replayMode),r=B(e=>e.lastEventTime),[i,a]=(0,v.useState)(`0.0s`),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(t===`running`){if(n){o.current&&clearInterval(o.current);let t=e??r??0;a(st((r??t)-t));return}let t=e==null?Date.now():e*1e3,i=()=>{a(st((Date.now()-t)/1e3))};return i(),o.current=setInterval(i,1e3),()=>{o.current&&clearInterval(o.current)}}else o.current&&clearInterval(o.current)},[t,e,n,r]),i}function p_(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`?r(`node-activate`):n===`running`&&(e===`completed`||e===`failed`)&&r(e===`completed`?`node-complete`:`node-fail`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var m_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.selected_option,s=h_(i);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,selectedOption:o},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 border-dashed bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`waiting`&&`shadow-[0_0_12px_var(--waiting-muted)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`,s),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`waiting`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(ye,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),i===`waiting`&&(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--waiting)] truncate leading-tight`,children:`Awaiting input...`}),i===`completed`&&o&&(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] truncate leading-tight`,children:o})]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function h_(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`||e===`waiting`?r(`node-activate`):(n===`running`||n===`waiting`)&&e===`completed`&&r(`node-complete`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var g_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=n.type===`for_each_group`?ge:se,i=n.progress,a=Mh(n)?.status||n.status||`pending`,o=X[a]||X.pending,s=__(a),c=B(e=>e.toggleContextExpanded),l=n.expanded===!0,u=n.canExpand===!0,d=n.groupExpansionKey,f=e=>{e.stopPropagation(),d!=null&&c(d)},p=i?`${i.completed+i.failed}/${i.total}${i.failed>0?` (${i.failed} failed)`:``}`:null,m=i&&i.total>0?(i.completed+i.failed)/i.total*100:0,h=i!=null&&i.failed>0;return l?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(`div`,{className:U(`w-full h-full rounded-xl border-2 border-dashed bg-[var(--surface)]/40 transition-all duration-300 animate-[subflow-expand-in_200ms_ease-out]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,a===`running`&&`shadow-[0_0_16px_var(--running-glow)]`,s),style:{borderColor:o,minHeight:`100%`},children:(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2`,children:[(0,H.jsx)(`button`,{onClick:f,className:`nodrag flex items-center justify-center w-5 h-5 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0`,title:`Collapse for-each iterations`,children:(0,H.jsx)(A,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(r,{className:`w-3.5 h-3.5 flex-shrink-0`,style:{color:o}}),(0,H.jsx)(`span`,{className:`text-xs font-semibold text-[var(--text)] truncate`,children:n.label}),p&&(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] font-mono flex-shrink-0`,children:p})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsxs)(`div`,{className:U(`flex flex-col gap-1 px-4 py-3 rounded-xl border-2 border-dashed bg-[var(--surface)]/80 min-w-[180px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,a===`running`&&`shadow-[0_0_16px_var(--running-glow)]`,s),style:{borderColor:o,minHeight:`100%`},children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[u&&(0,H.jsx)(`button`,{onClick:f,className:`nodrag flex items-center justify-center w-5 h-5 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0 -ml-1`,title:`Expand for-each iterations inline`,children:(0,H.jsx)(j,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(r,{className:`w-3.5 h-3.5`,style:{color:o}}),(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text-secondary)]`,children:n.label})]}),p&&(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] font-mono`,children:p}),i&&i.total>0&&a===`running`&&(0,H.jsx)(`div`,{className:`w-full h-1 rounded-full bg-[var(--border)] overflow-hidden mt-0.5`,children:(0,H.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500 ease-out`,style:{width:`${m}%`,backgroundColor:h?`var(--failed)`:`var(--completed)`}})})]}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function __(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`?r(`node-activate`):n===`running`&&(e===`completed`||e===`failed`)&&r(e===`completed`?`node-complete`:`node-fail`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var v_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.elapsed,s=r?.error_message,c=B(e=>e.toggleContextExpanded),l=n.expanded===!0,u=n.canExpand===!0,d=n.childContextKey,f=n.childName,p=e=>{e.stopPropagation(),d!=null&&c(d)};if(l)return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(`div`,{className:U(`w-full h-full rounded-xl border-2 border-dashed bg-[var(--surface)]/40 transition-all duration-300 animate-[subflow-expand-in_200ms_ease-out]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_16px_var(--running-glow)]`),style:{borderColor:a,minHeight:`100%`},children:(0,H.jsxs)(`div`,{className:`flex items-center gap-1.5 px-3 py-2`,children:[(0,H.jsx)(`button`,{onClick:p,className:`nodrag flex items-center justify-center w-5 h-5 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0`,title:`Collapse subworkflow`,children:(0,H.jsx)(A,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(le,{className:`w-3.5 h-3.5 flex-shrink-0`,style:{color:a}}),(0,H.jsx)(`span`,{className:`text-xs font-semibold text-[var(--text)] truncate`,children:n.label}),f&&(0,H.jsxs)(`span`,{className:`text-[10px] text-[var(--text-muted)] truncate`,children:[`· `,f]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]});let m=(()=>{if(i===`failed`&&s)return{text:s.length>35?s.slice(0,32)+`...`:s,className:`text-red-400`};if(i===`running`)return{text:f||`Running subworkflow…`,className:`text-[var(--text-muted)]`};if(i===`completed`){let e=[];return f&&e.push(f),o!=null&&e.push(`${o.toFixed(1)}s`),{text:e.join(` · `)||`Done`,className:`text-[var(--text-muted)]`}}return{text:f||null,className:`text-[var(--text-muted)]`}})();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,elapsed:o,errorType:void 0,errorMessage:s,iteration:void 0},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[240px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`),style:{borderColor:a,borderStyle:`dashed`},children:[u?(0,H.jsx)(`button`,{onClick:p,className:`nodrag flex items-center justify-center w-5 h-5 rounded hover:bg-[var(--surface-hover)] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors flex-shrink-0`,title:`Expand subworkflow inline (double-click to focus)`,children:(0,H.jsx)(j,{className:`w-3.5 h-3.5`})}):(0,H.jsx)(`div`,{className:`flex items-center justify-center w-5 h-5 flex-shrink-0 text-[var(--text-muted)] opacity-25`,title:`Subworkflow structure not yet known (will be expandable once it starts)`,"aria-hidden":`true`,children:(0,H.jsx)(j,{className:`w-3.5 h-3.5`})}),(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`running`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(le,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`div`,{className:`flex items-center gap-1`,children:(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label})}),m.text&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight`,m.className),children:m.text})]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})}),y_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.duration_seconds??r?.requested_seconds,s=r?.waited_seconds,c=r?.elapsed,l=r?.interrupted,u=r?.error_type,d=r?.error_message,f=b_(r?.startedAt,i),p=x_(i),m=(()=>{if(i===`failed`&&d)return{text:d.length>40?d.slice(0,37)+`...`:d,className:`text-red-400`};if(i===`running`)return{text:`${f}${typeof o==`number`?` / ${st(o)}`:``}`,className:`text-[var(--text-muted)]`};if(i===`completed`){let e=[];return s==null?c!=null&&e.push(st(c)):e.push(st(s)),l&&e.push(`interrupted`),{text:e.join(` · `)||null,className:`text-[var(--text-muted)]`}}return i===`pending`&&typeof o==`number`?{text:st(o),className:`text-[var(--text-muted)]`}:{text:null,className:``}})();return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,elapsed:s??c,errorType:u,errorMessage:d},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[220px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`running`&&`shadow-[0_0_12px_var(--running-glow)]`,p),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,i===`running`&&`animate-pulse`),style:{backgroundColor:`${a}20`},children:(0,H.jsx)(F,{className:`w-3.5 h-3.5`,style:{color:a}})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),m.text&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight`,m.className),children:m.text})]})]})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})});function b_(e,t){let n=B(e=>e.replayMode),r=B(e=>e.lastEventTime),[i,a]=(0,v.useState)(`0.0s`),o=(0,v.useRef)(null);return(0,v.useEffect)(()=>{if(t===`running`){if(n){o.current&&clearInterval(o.current);let t=e??r??0;a(st((r??t)-t));return}let t=e==null?Date.now():e*1e3,i=()=>{a(st((Date.now()-t)/1e3))};return i(),o.current=setInterval(i,1e3),()=>{o.current&&clearInterval(o.current)}}else o.current&&clearInterval(o.current)},[t,e,n,r]),i}function x_(e){let t=(0,v.useRef)(e),[n,r]=(0,v.useState)(``);return(0,v.useEffect)(()=>{let n=t.current;if(t.current=e,n===e)return;e===`running`?r(`node-activate`):n===`running`&&(e===`completed`||e===`failed`)&&r(e===`completed`?`node-complete`:`node-fail`);let i=setTimeout(()=>r(``),400);return()=>clearTimeout(i)},[e]),n}var S_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=Mh(n),i=r?.status||n.status||`pending`,a=X[i]||X.pending,o=r?.termination_reason,s=r?.termination_status,c=r?.error_message,l=r?.error_type,u=o||c,d=i===`failed`?`text-red-400`:i===`completed`?`text-green-400`:`text-[var(--text-muted)]`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(i_,{data:{status:i,reason:o,terminationStatus:s,errorType:l,errorMessage:c},children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-3 py-1.5 rounded-lg border-2 bg-[var(--node-bg)] min-w-[140px] max-w-[260px] transition-all duration-300`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i===`completed`&&`shadow-[0_0_12px_var(--completed-muted)]`,i===`failed`&&`shadow-[0_0_12px_var(--failed-muted)]`),style:{borderColor:a},children:[(0,H.jsx)(`div`,{className:`flex items-center justify-center w-6 h-6 rounded-md flex-shrink-0`,style:{backgroundColor:`${a}20`},children:(0,H.jsx)(pe,{className:`w-3.5 h-3.5`,style:{color:a},fill:i===`completed`||i===`failed`?a:`transparent`,fillOpacity:.2})}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0 flex-1`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-[var(--text)] truncate`,children:n.label}),(0,H.jsxs)(`span`,{className:`text-[10px] uppercase tracking-wide text-[var(--text-muted)] truncate leading-tight`,children:[`terminate`,s?` · ${s}`:``]}),u&&(0,H.jsx)(`span`,{className:U(`text-[10px] truncate leading-tight mt-0.5`,d),title:u,children:u.length>50?u.slice(0,47)+`...`:u})]})]})})]})}),C_=(0,v.memo)(function({data:e,selected:t}){let n=e.status||`pending`,r=n===`completed`,i=n===`failed`,a=!r&&!i,o=r?X.completed:i?X.failed:X.pending;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300`,r?`bg-[var(--completed)] shadow-[0_0_16px_var(--completed-muted)]`:i?`bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]`:`bg-[var(--node-bg)]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`),style:{borderColor:o},children:r?(0,H.jsx)(k,{className:`w-5 h-5 text-white`,strokeWidth:3}):i?(0,H.jsx)(xe,{className:`w-3.5 h-3.5 text-white`,fill:`white`}):(0,H.jsx)(k,{className:`w-5 h-5`,strokeWidth:2.5,style:{color:a?X.pending:o}})})]})}),w_=(0,v.memo)(function({data:e,selected:t}){let n=e.status||`pending`,r=X[n]||X.pending,i=n===`running`||n===`completed`;return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-11 h-11 rounded-full border-2 transition-all duration-300`,i?`bg-[var(--completed)]`:`bg-[var(--node-bg)]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i&&`shadow-[0_0_12px_var(--completed-muted)]`),style:{borderColor:r},children:(0,H.jsx)(he,{className:`w-4 h-4 ml-0.5`,style:{color:i?`white`:r}})}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})}),T_=`#a78bfa`,E_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=n.status||`pending`,i=r===`running`||r===`completed`,a=i?T_:X[r]||T_,o=n.parentAgent,s=B(e=>e.navigateUp);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer`,i?`bg-[#a78bfa]`:`bg-[var(--node-bg)]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`,i&&`shadow-[0_0_12px_rgba(167,139,250,0.4)]`),style:{borderColor:a},onDoubleClick:e=>{e.stopPropagation(),s()},children:(0,H.jsx)(E,{className:`w-4 h-4`,style:{color:i?`white`:a}})}),o&&(0,H.jsxs)(`span`,{className:`text-[10px] text-[var(--text-muted)] whitespace-nowrap`,children:[`from `,(0,H.jsx)(`span`,{className:`font-medium text-[var(--text)]`,children:o})]})]}),(0,H.jsx)(cp,{type:`source`,position:K.Bottom,className:`!bg-[var(--border)] !border-none !w-2 !h-2`})]})}),D_=`#a78bfa`,O_=(0,v.memo)(function({data:e,selected:t}){let n=e,r=n.status||`pending`,i=r===`completed`,a=r===`failed`,o=i?D_:a?X.failed:D_,s=n.parentAgent,c=B(e=>e.navigateUp);return(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(cp,{type:`target`,position:K.Top,className:`!bg-[var(--border)] !border-none !w-2 !h-2`}),(0,H.jsxs)(`div`,{className:`flex flex-col items-center gap-1`,children:[(0,H.jsx)(`div`,{className:U(`flex items-center justify-center w-11 h-11 rounded-full border-2 border-dashed transition-all duration-300 cursor-pointer`,i?`bg-[#a78bfa] shadow-[0_0_12px_rgba(167,139,250,0.4)]`:a?`bg-[var(--failed)] shadow-[0_0_16px_var(--failed-muted)]`:`bg-[var(--node-bg)]`,t&&`ring-2 ring-[var(--accent)] ring-offset-1 ring-offset-[var(--bg)]`),style:{borderColor:o},onDoubleClick:e=>{e.stopPropagation(),c()},children:(0,H.jsx)(D,{className:`w-4 h-4`,style:{color:i||a?`white`:o}})}),s&&(0,H.jsxs)(`span`,{className:`text-[10px] text-[var(--text-muted)] whitespace-nowrap`,children:[`return to `,(0,H.jsx)(`span`,{className:`font-medium text-[var(--text)]`,children:s})]})]})]})}),k_=(0,v.memo)(function({id:e,sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o,data:s}){let[c,l,u]=Ql({sourceX:t,sourceY:n,targetX:r,targetY:i,sourcePosition:a,targetPosition:o}),d=s?.when,f=s?.highlightState,p=!!d,m=f===`taken`,h=f===`highlighted`,g=f===`failed`,_=`var(--edge-color)`,v=2,y;return g?(_=`var(--failed)`,v=3):m?(_=`var(--edge-taken)`,v=3):h&&(_=`var(--edge-active)`,v=3),p&&!m&&!h&&!g&&(y=`6 3`),(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(Hp,{id:e,path:c,style:{stroke:_,strokeWidth:v,strokeDasharray:y,transition:`stroke 0.3s ease, stroke-width 0.3s ease`},markerEnd:`url(#arrow-${g?`failed`:m?`taken`:h?`active`:`default`})`}),p&&(0,H.jsx)(Hm,{children:(0,H.jsx)(`div`,{className:`nodrag nopan`,style:{position:`absolute`,transform:`translate(-50%, -50%) translate(${l}px,${u}px)`,pointerEvents:`all`},children:(0,H.jsx)(`span`,{className:`inline-block px-1.5 py-0.5 rounded-full text-[9px] font-mono leading-tight max-w-[140px] truncate`,style:{backgroundColor:g?`var(--failed)`:m?`var(--edge-taken)`:`var(--surface)`,color:g||m?`var(--bg)`:`var(--text-muted)`,border:`1px solid ${g?`var(--failed)`:m?`var(--edge-taken)`:`var(--border)`}`},title:d,children:d})})}),m&&(0,H.jsx)(`circle`,{r:`3`,fill:`var(--edge-taken)`,children:(0,H.jsx)(`animateMotion`,{dur:`1s`,repeatCount:`indefinite`,path:c})}),g&&(0,H.jsx)(`circle`,{r:`3`,fill:`var(--failed)`,opacity:`0.8`,children:(0,H.jsx)(`animateMotion`,{dur:`1.5s`,repeatCount:`indefinite`,path:c})})]})});function A_(){let e=B(e=>e.workflowStatus),t=B(e=>e.workflowFailure),n=B(e=>e.workflowFailedAgent),r=B(e=>e.workflowTermination),i=B(e=>e.selectNode);if(e!==`failed`||!t)return null;if(t.stopped_by_user){let e=t.checkpoint_path?.split(`/`).pop();return(0,H.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]`,children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-4 py-2 rounded-lg`,`bg-slate-900/90 border border-slate-500/40 shadow-lg shadow-slate-500/10`,`backdrop-blur-sm max-w-[560px]`),children:[(0,H.jsx)(xe,{className:`w-4 h-4 text-slate-300 flex-shrink-0`}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-slate-200`,children:`Workflow Stopped`}),t.checkpoint_path?(0,H.jsxs)(H.Fragment,{children:[(0,H.jsxs)(`span`,{className:`text-[11px] text-slate-300/80 truncate`,title:t.checkpoint_path,children:[`Checkpoint saved: `,e]}),(0,H.jsx)(`span`,{className:`text-[10px] text-slate-400/70 truncate`,children:`Resume from the CLI with: conductor resume`})]}):t.checkpoint_unavailable_reason?(0,H.jsxs)(`span`,{className:`text-[11px] text-amber-300/80 truncate`,title:t.checkpoint_unavailable_reason,children:[`No checkpoint could be saved — `,t.checkpoint_unavailable_reason]}):(0,H.jsx)(`span`,{className:`text-[11px] text-slate-400/70 truncate`,children:`Saving checkpoint…`})]}),n&&(0,H.jsxs)(`button`,{onClick:()=>i(Eh([],n)),className:`flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium text-slate-200 bg-slate-500/20 hover:bg-slate-500/30 transition-colors flex-shrink-0 ml-1`,children:[(0,H.jsx)(ae,{className:`w-3 h-3`}),`View`]})]})})}let a=r?.is_explicit&&r.status===`failed`,o=a?r.termination_reason||t.message||`Workflow terminated`:t.message||t.error_type||`Unknown error`,s=a?`Workflow Terminated`:`Workflow Failed`,c=t.error_type===`TimeoutError`;return(0,H.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]`,children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-4 py-2 rounded-lg`,`bg-red-950/90 border border-red-500/40 shadow-lg shadow-red-500/10`,`backdrop-blur-sm max-w-[560px]`),children:[(0,H.jsx)(Ce,{className:`w-4 h-4 text-red-400 flex-shrink-0`}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-red-300`,children:s}),(0,H.jsx)(`span`,{className:`text-[11px] text-red-400/80 truncate`,children:o}),a&&r?.terminated_by&&(0,H.jsxs)(`span`,{className:`text-[10px] text-red-400/60 truncate`,children:[`Terminated by: `,r.terminated_by]}),c&&t.current_agent&&(0,H.jsxs)(`span`,{className:`text-[10px] text-red-400/60 truncate`,children:[`Timed out on agent: `,t.current_agent]}),t.checkpoint_path&&(0,H.jsxs)(`span`,{className:`text-[10px] text-red-400/50 truncate`,title:t.checkpoint_path,children:[`Checkpoint: `,t.checkpoint_path.split(`/`).pop()]})]}),n&&(0,H.jsxs)(`button`,{onClick:()=>i(Eh([],n)),className:`flex items-center gap-1 px-2 py-1 rounded text-[10px] font-medium text-red-300 bg-red-500/20 hover:bg-red-500/30 transition-colors flex-shrink-0 ml-1`,children:[(0,H.jsx)(ae,{className:`w-3 h-3`}),`View`]})]})})}function j_(){let[e,t]=(0,v.useState)(!1),n=B(e=>e.workflowStatus),r=B(e=>e.workflowTermination),i=B(e=>e.totalCost),a=B(e=>e.totalTokens),o=B(e=>e.agentsCompleted),s=B(e=>e.agentsTotal),c=ft();if(n!==`completed`||e)return null;let l=r?.is_explicit&&r.status===`success`;return(0,H.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]`,children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-3 px-4 py-2 rounded-lg`,`bg-green-950/90 border border-green-500/40 shadow-lg shadow-green-500/10`,`backdrop-blur-sm max-w-[560px]`),children:[(0,H.jsx)(te,{className:`w-4 h-4 text-green-400 flex-shrink-0`}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-green-300`,children:l?`Workflow Terminated`:`Completed`}),l&&r?.termination_reason&&(0,H.jsx)(`span`,{className:`text-[11px] text-green-400/80 truncate`,children:r.termination_reason}),l&&r?.terminated_by&&(0,H.jsxs)(`span`,{className:`text-[10px] text-green-400/60 truncate`,children:[`Terminated by: `,r.terminated_by]})]}),(0,H.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-green-400/80 font-mono flex-shrink-0 ml-auto`,children:[(0,H.jsx)(`span`,{children:c}),s>0&&(0,H.jsxs)(`span`,{children:[o,`/`,s,` agents`]}),a>0&&(0,H.jsxs)(`span`,{children:[ct(a),` tok`]}),i>0&&(0,H.jsx)(`span`,{children:lt(i)})]}),(0,H.jsx)(`button`,{onClick:()=>t(!0),className:`p-0.5 rounded text-green-500/60 hover:text-green-300 transition-colors flex-shrink-0 ml-1`,children:(0,H.jsx)(De,{className:`w-3.5 h-3.5`})})]})})}var M_=6e4;function N_({wsStatus:e,wsDisconnectedSince:t,workflowStatus:n,replayMode:r,now:i=Date.now(),thresholdMs:a=M_}){return r||n!==`running`||e===`connected`||t==null?!1:i-t>=a}function P_(){let e=B(e=>e.wsStatus),t=B(e=>e.wsDisconnectedSince),n=B(e=>e.workflowStatus),r=B(e=>e.replayMode),[i,a]=(0,v.useState)(()=>Date.now());return(0,v.useEffect)(()=>{if(t==null||e===`connected`)return;let n=()=>a(Date.now());n();let r=setInterval(n,1e3);return()=>clearInterval(r)},[t,e]),{stuck:N_({wsStatus:e,wsDisconnectedSince:t,workflowStatus:n,replayMode:r,now:i}),elapsedMs:t==null?0:Math.max(0,i-t)}}function F_(){let{stuck:e,elapsedMs:t}=P_(),n=B(e=>e.bgStderrLog),r=B(e=>e.bgStdoutLog),i=B(e=>e.systemLogFile);if(!e)return null;let a=n?`Check the captured logs: ${n}${r?` (and ${r})`:``}`:i?`Check the event log: ${i}`:"Check the terminal where `conductor run` was launched, or re-run with --log-file to capture one.";return(0,H.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]`,children:(0,H.jsxs)(`div`,{className:U(`flex items-center gap-2 px-4 py-2 rounded-lg`,`bg-amber-950/90 border border-amber-500/40 shadow-lg shadow-amber-500/10`,`backdrop-blur-sm max-w-[560px]`),children:[(0,H.jsx)(Ce,{className:`w-4 h-4 text-amber-400 flex-shrink-0`}),(0,H.jsxs)(`div`,{className:`flex flex-col min-w-0`,children:[(0,H.jsx)(`span`,{className:`text-xs font-medium text-amber-300`,children:`Connection lost — workflow may have stopped responding`}),(0,H.jsxs)(`span`,{className:`text-[11px] text-amber-400/80 truncate`,children:[`Reconnecting for `,st(t/1e3),` with no success. The Conductor process may have crashed.`]}),(0,H.jsx)(`span`,{className:`text-[10px] text-amber-400/60 truncate`,title:n??i??void 0,children:a})]})]})})}var I_={agentNode:a_,scriptNode:c_,setNode:d_,gateNode:m_,groupNode:g_,workflowNode:v_,waitNode:y_,terminateNode:S_,endNode:C_,startNode:w_,ingressNode:E_,egressNode:O_},L_={animatedEdge:k_},R_={type:`animatedEdge`};function z_(){return(0,H.jsx)(`svg`,{style:{position:`absolute`,width:0,height:0},children:(0,H.jsxs)(`defs`,{children:[(0,H.jsx)(`marker`,{id:`arrow-default`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto-start-reverse`,children:(0,H.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`var(--edge-color)`})}),(0,H.jsx)(`marker`,{id:`arrow-active`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto-start-reverse`,children:(0,H.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`var(--edge-active)`})}),(0,H.jsx)(`marker`,{id:`arrow-taken`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto-start-reverse`,children:(0,H.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`var(--edge-taken)`})}),(0,H.jsx)(`marker`,{id:`arrow-failed`,viewBox:`0 0 10 10`,refX:`8`,refY:`5`,markerWidth:`8`,markerHeight:`8`,orient:`auto-start-reverse`,children:(0,H.jsx)(`path`,{d:`M 0 0 L 10 5 L 0 10 z`,fill:`var(--failed)`})})]})})}function B_(e,t){if(t.length===0)return null;let n=e[t[0]];for(let e=1;ee.viewContextPath),n=B(e=>e.selectNode),r=B(e=>e.selectedNode),i=B(e=>e.workflowStatus),a=B(e=>e.wsStatus),o=B(e=>e.workflowFailedAgent),s=B(e=>e.navigateIntoSubworkflow),{agents:c,routes:l,parallelGroups:u,forEachGroups:d,nodes:f,groupProgress:p,entryPoint:m,subworkflowContexts:h,parentAgent:g,basePath:_}=e,y=B(e=>e.expandedContexts),b=B(e=>e.nodes),x=B(e=>e.groupProgress),S=B(e=>e.subworkflowContexts),C=B(e=>e.highlightedEdges),[w,T,E]=Um([]),[D,O,k]=Wm([]),A=(0,v.useRef)(``),j=JSON.stringify(t),M=(0,v.useMemo)(()=>{let e=[`${j}#${c.map(e=>e.name).join(`,`)}`];for(let t of[...y].sort()){if(kh(t)){let{contextPath:n,name:r}=Dh(t),i=n.length===0?null:B_(S,n),a=(n.length===0?S:i?.children??[]).filter(e=>{let t=Ah(e.slotKey);return t!=null&&t.group===r}).map(e=>`${e.slotKey}:${e.entryPoint??``}:${e.agents.map(e=>e.name).join(`,`)}`);e.push(`${t}=>${a.join(`|`)}`);continue}let n=B_(S,t.split(`.`).filter(Boolean).map(Number));e.push(`${t}:${n?.entryPoint??``}:${n?.agents.map(e=>e.name).join(`,`)??``}`)}return e.join(`||`)},[j,c,y,S]);(0,v.useEffect)(()=>{if(c.length===0){A.current!==M&&(A.current=M,T([]),O([]));return}if(A.current===M)return;A.current=M;let{nodes:e,edges:t}=Hg({agents:c,routes:l,parallelGroups:u,forEachGroups:d,nodes:f,groupProgress:p,entryPoint:m,parentAgent:g,children:h},_,y);T(e),O(t)},[M,c,l,u,d,f,p,m,g,h,_,y,T,O]),(0,v.useEffect)(()=>{T(e=>e.map(e=>{let t=e.data,n=t.iterationContextPath;if(n&&n.length>0){let r=B_(S,n)?.status;return!r||r===t.status?e:{...e,data:{...t,status:r}}}let r=t.contextPath??[],i=r.length===0?null:B_(S,r),a=r.length===0?b:i?.nodes,o=r.length===0?x:i?.groupProgress,s=t.name??e.id,c=a?a[s]:void 0;if(!c)return e;let l=t,u=!1,d=c.status||`pending`;if(d!==t.status&&(l={...l,status:d},u=!0),t.groupName&&o&&o[t.groupName]){let e=o[t.groupName],n=l.progress;e&&(!n||n.completed!==e.completed||n.failed!==e.failed)&&(l={...l,progress:e},u=!0)}return u?{...e,data:l}:e}))},[b,x,S,T]),(0,v.useEffect)(()=>{O(e=>e.map(e=>{let{contextPath:t,name:n}=Dh(e.source),r=Dh(e.target).name,i=t.length===0?null:B_(S,t),a=(t.length===0?C:i?.highlightedEdges??[]).find(e=>e.from===n&&e.to===r)?.state;return e.data?.highlightState===a?e:{...e,data:{...e.data,highlightState:a}}}))},[C,S,O]);let N=(0,v.useCallback)((e,t)=>{t.type===`groupNode`&&t.data.type!==`for_each_group`||n(t.id)},[n]),ee=(0,v.useCallback)((e,n)=>{let r=n.data;if(r.type!==`workflow`||(r.contextPath??[]).join(`.`)!==t.join(`.`))return;let i=r.name;i&&h.some(e=>e.slotKey===i||e.parentAgent===i)&&s(i)},[h,s,t]),te=(0,v.useCallback)(()=>{n(null)},[n]),P=(0,v.useCallback)(e=>X[e.data?.status||`pending`]??X.pending??`#6b7280`,[]);(0,v.useEffect)(()=>{T(e=>e.map(e=>({...e,selected:e.id===r})))},[r,T]),(0,v.useEffect)(()=>{i===`failed`&&o&&n(Eh([],o))},[i,o,n]);let F=i===`pending`&&c.length===0,ne=(()=>{switch(a){case`connecting`:return`Connecting to workflow…`;case`reconnecting`:return`Reconnecting…`;case`disconnected`:return`Connection lost. Retrying…`;default:return`Waiting for workflow…`}})();return(0,H.jsxs)(`div`,{className:`w-full h-full relative`,children:[(0,H.jsx)(z_,{}),(0,H.jsx)(A_,{}),(0,H.jsx)(j_,{}),(0,H.jsx)(F_,{}),F&&(0,H.jsxs)(`div`,{className:`absolute inset-0 z-10 flex flex-col items-center justify-center pointer-events-none`,children:[(0,H.jsxs)(`div`,{className:`relative mb-3`,children:[(0,H.jsx)(Oe,{className:`w-8 h-8 text-[var(--accent)] opacity-20`}),(0,H.jsx)(ue,{className:`w-8 h-8 text-[var(--text-muted)] animate-spin absolute inset-0 opacity-40`})]}),(0,H.jsx)(`p`,{className:`text-sm text-[var(--text-muted)] animate-pulse`,children:ne})]}),(0,H.jsxs)(Bm,{nodes:w,edges:D,onNodesChange:E,onEdgesChange:k,onNodeClick:N,onNodeDoubleClick:ee,onPaneClick:te,nodeTypes:I_,edgeTypes:L_,defaultEdgeOptions:R_,fitView:!0,fitViewOptions:{padding:.2},minZoom:.2,maxZoom:2,proOptions:{hideAttribution:!0},nodesDraggable:!0,nodesConnectable:!1,elementsSelectable:!0,children:[(0,H.jsx)(Zm,{variant:qm.Dots,gap:20,size:1,color:`var(--border-subtle)`}),(0,H.jsx)(xh,{nodeColor:P,maskColor:`var(--minimap-mask)`,style:{background:`var(--minimap-bg)`},pannable:!0,zoomable:!0}),(0,H.jsxs)(oh,{showInteractive:!1,children:[(0,H.jsx)(U_,{}),(0,H.jsx)(H_,{})]}),(0,H.jsx)(W_,{}),(0,H.jsx)(G_,{viewPathKey:j}),(0,H.jsx)(K_,{})]})]})}function H_(){let{fitView:e}=zf();return(0,H.jsx)(`button`,{onClick:(0,v.useCallback)(()=>{e({padding:.2,duration:300})},[e]),className:`react-flow__controls-button`,title:`Fit view (F)`,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:(0,H.jsx)(de,{className:`w-3.5 h-3.5`})})}function U_(){let{agents:e,subworkflowContexts:t,basePath:n}=Ih(),r=B(e=>e.expandedContexts),i=B(e=>e.expandContexts),a=B(e=>e.collapseContexts),o=(0,v.useMemo)(()=>Ug(e,t,n),[e,t,n]),s=(0,v.useMemo)(()=>o.some(e=>r.has(e)),[o,r]),c=(0,v.useCallback)(()=>{o.length!==0&&(s?a(o):i(o))},[o,s,a,i]);if((0,v.useEffect)(()=>{let e=e=>{let t=e.target?.tagName;t===`INPUT`||t===`TEXTAREA`||t===`SELECT`||e.key===`e`&&!e.ctrlKey&&!e.metaKey&&!e.altKey&&c()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[c]),o.length===0)return null;let l=s?`Collapse all subworkflows`:`Expand all subworkflows`;return(0,H.jsx)(`button`,{onClick:c,className:`react-flow__controls-button`,title:`${l} (E)`,"aria-label":l,style:{display:`flex`,alignItems:`center`,justifyContent:`center`},children:s?(0,H.jsx)(N,{className:`w-3.5 h-3.5`}):(0,H.jsx)(ee,{className:`w-3.5 h-3.5`})})}function W_(){let{fitView:e}=zf();return(0,v.useEffect)(()=>{let t=t=>{let n=t.target?.tagName;n===`INPUT`||n===`TEXTAREA`||n===`SELECT`||t.key===`f`&&!t.ctrlKey&&!t.metaKey&&!t.altKey&&e({padding:.2,duration:300})};return window.addEventListener(`keydown`,t),()=>window.removeEventListener(`keydown`,t)},[e]),null}function G_({viewPathKey:e}){let{fitView:t}=zf(),n=(0,v.useRef)(e);return(0,v.useEffect)(()=>{n.current!==e&&(n.current=e,setTimeout(()=>t({padding:.2,duration:300}),50))},[e,t]),null}function K_(){let e=r_();return e?(0,H.jsx)(`div`,{className:`absolute top-3 left-1/2 -translate-x-1/2 z-20 animate-[banner-in_200ms_ease-out]`,children:(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-2 rounded-lg bg-amber-950/90 border border-amber-500/40 shadow-lg shadow-amber-500/10 backdrop-blur-sm max-w-[560px]`,children:[(0,H.jsx)(`span`,{className:`text-xs text-amber-300`,children:`⚠`}),(0,H.jsx)(`span`,{className:`text-[11px] text-amber-400/80`,children:e.message}),(0,H.jsx)(`a`,{href:window.location.pathname,className:`px-2 py-0.5 rounded text-[10px] font-medium text-amber-300 bg-amber-500/20 hover:bg-amber-500/30 transition-colors flex-shrink-0 ml-1`,children:`Root`})]})}):null}function q_({items:e}){let t=e.filter(e=>e.value!=null&&e.value!==``);return t.length===0?null:(0,H.jsx)(`dl`,{className:`grid grid-cols-[auto_1fr] gap-x-3 gap-y-1.5 text-xs`,children:t.map(({label:e,value:t})=>(0,H.jsxs)(`div`,{className:`contents`,children:[(0,H.jsx)(`dt`,{className:`text-[var(--text-muted)] whitespace-nowrap`,children:e}),(0,H.jsx)(`dd`,{className:`text-[var(--text)] break-words`,children:typeof t==`object`?JSON.stringify(t):String(t)})]},e))})}function J_(e){let t=[];return e.elapsed!=null&&t.push({label:`Elapsed`,value:st(e.elapsed)}),e.model&&t.push({label:`Model`,value:e.model}),e.reasoning_effort&&t.push({label:`Reasoning`,value:e.reasoning_effort}),e.tokens!=null&&t.push({label:`Tokens`,value:ct(e.tokens)}),e.input_tokens!=null&&e.output_tokens!=null&&t.push({label:`In / Out`,value:`${ct(e.input_tokens)} / ${ct(e.output_tokens)}`}),e.cost_usd!=null&&t.push({label:`Cost`,value:lt(e.cost_usd)}),e.context_window_used!=null&&e.context_window_max!=null&&t.push({label:`Context`,value:dt(e.context_window_used,e.context_window_max)}),e.iteration!=null&&t.push({label:`Iteration`,value:e.iteration}),e.error_type&&t.push({label:`Error`,value:e.error_type}),e.error_message&&t.push({label:`Message`,value:e.error_message}),t}function Y_({output:e,title:t=`Output`,defaultExpanded:n=!0,maxHeight:r=`300px`}){let[i,a]=(0,v.useState)(n),[o,s]=(0,v.useState)(!1),c=ut(e);if(!c)return null;let l=typeof e==`object`&&!!e;return(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,H.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold`,children:[i?(0,H.jsx)(A,{className:`w-3 h-3`}):(0,H.jsx)(j,{className:`w-3 h-3`}),t]}),i&&(0,H.jsx)(`button`,{onClick:async()=>{await navigator.clipboard.writeText(c),s(!0),setTimeout(()=>s(!1),2e3)},className:`flex items-center gap-1 text-[10px] text-[var(--text-muted)] hover:text-[var(--text)] transition-colors`,title:`Copy to clipboard`,children:o?(0,H.jsx)(k,{className:`w-3 h-3 text-[var(--completed)]`}):(0,H.jsx)(re,{className:`w-3 h-3`})})]}),i&&(0,H.jsx)(`pre`,{className:`bg-[var(--bg)] border border-[var(--border)] rounded-md p-3 font-mono text-[11px] leading-relaxed text-[var(--text)] overflow-auto whitespace-pre-wrap break-words`,style:{maxHeight:r},children:l?(0,H.jsx)(X_,{text:c}):c})]})}function X_({text:e}){let t=e.split(/("(?:[^"\\]|\\.)*")/g);return(0,H.jsx)(H.Fragment,{children:t.map((e,n)=>{if(n%2==1){let r=t.slice(n+1).join(``);return(0,H.jsx)(`span`,{className:/^\s*:/.test(r)?`text-blue-400`:`text-green-400`,children:e},n)}return(0,H.jsx)(`span`,{dangerouslySetInnerHTML:{__html:e.replace(/\b(true|false|null)\b|(-?\d+\.?\d*(?:e[+-]?\d+)?)/gi,(e,t,n)=>t?`${e}`:n?`${e}`:e)}},n)})})}function Z_({activity:e,defaultExpanded:t=!0}){let[n,r]=(0,v.useState)(t),i=(0,v.useRef)(null);return(0,v.useEffect)(()=>{i.current&&n&&(i.current.scrollTop=i.current.scrollHeight)},[e.length,n]),e.length===0?null:(0,H.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,H.jsxs)(`button`,{onClick:()=>r(!n),className:`flex items-center gap-1 text-[10px] uppercase tracking-wider text-[var(--text-muted)] hover:text-[var(--text)] transition-colors font-semibold`,children:[n?(0,H.jsx)(A,{className:`w-3 h-3`}):(0,H.jsx)(j,{className:`w-3 h-3`}),`Activity (`,e.length,`)`]}),n&&(0,H.jsx)(`div`,{ref:i,className:`max-h-[400px] overflow-y-auto space-y-0.5`,children:e.map((e,t)=>(0,H.jsx)(Q_,{entry:e},t))})]})}function Q_({entry:e}){return(0,H.jsxs)(`div`,{className:U(`py-1.5 px-2 rounded text-[11px] leading-relaxed border-b border-[var(--border-subtle)] last:border-b-0`),children:[(0,H.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,H.jsx)(`span`,{className:`w-4 text-center flex-shrink-0`,children:e.icon}),(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] uppercase text-[9px] font-semibold tracking-wider w-12 flex-shrink-0 pt-px`,children:e.label}),(0,H.jsx)(`span`,{className:U(`break-words`,{reasoning:`text-indigo-400/70`,"tool-start":`text-blue-400`,"tool-complete":`text-green-400`,turn:`text-amber-400`,message:`text-[var(--text)]`,"parse-recovery":`text-yellow-400`}[e.type]||`text-[var(--text)]`),children:typeof e.text==`object`?JSON.stringify(e.text):e.text})]}),e.detail&&(0,H.jsx)(`div`,{className:`mt-1 ml-[4.25rem] px-2 py-1 bg-[var(--bg)] rounded text-[10px] font-mono text-[var(--text-muted)] whitespace-pre-wrap break-words max-h-24 overflow-y-auto`,children:typeof e.detail==`object`?JSON.stringify(e.detail,null,2):e.detail})]})}var $_={running:{label:`Validating…`,color:`#3b82f6`},passed:{label:`Passed`,color:`#22c55e`},failed:{label:`Failed`,color:`#f59e0b`},error:{label:`Validator error (treated as pass)`,color:`#f59e0b`}};function ev({node:e}){let t=e.validator_state;if(!t)return null;let n=$_[t]??{label:`Validating…`,color:`#3b82f6`},r=e.validator_issues??[],i=(t===`failed`||t===`error`)&&r.length>0;return(0,H.jsxs)(`div`,{className:`border border-[var(--border)] rounded-lg overflow-hidden`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2 px-3 py-2 bg-[var(--bg)]`,children:[(0,H.jsx)(`span`,{className:`text-xs font-semibold text-[var(--text)]`,children:`Validation`}),(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider ml-auto`,style:{backgroundColor:`${n.color}20`,color:n.color},children:n.label})]}),(0,H.jsxs)(`div`,{className:`px-3 py-3 space-y-2 border-t border-[var(--border)]`,children:[(0,H.jsxs)(`div`,{className:`flex flex-wrap gap-x-4 gap-y-1 text-[10px] text-[var(--text-muted)]`,children:[e.validator_model&&(0,H.jsxs)(`span`,{children:[`model: `,e.validator_model]}),e.validator_cost_usd!=null&&(0,H.jsxs)(`span`,{children:[`cost: $`,e.validator_cost_usd.toFixed(4)]}),e.validator_attempts!=null&&e.validator_attempts>1&&(0,H.jsxs)(`span`,{children:[`runs: `,e.validator_attempts]})]}),i&&(0,H.jsxs)(`div`,{className:`space-y-1`,children:[(0,H.jsx)(`div`,{className:`text-[10px] font-semibold uppercase tracking-wider text-[var(--text-muted)]`,children:`Issues`}),(0,H.jsx)(`ul`,{className:`space-y-1`,children:r.map((e,t)=>(0,H.jsxs)(`li`,{className:`text-xs text-[var(--text)] flex gap-1.5`,children:[(0,H.jsx)(`span`,{className:`text-[var(--text-muted)] flex-shrink-0`,children:`•`}),(0,H.jsx)(`span`,{children:e})]},t))})]}),e.validator_will_retry&&(0,H.jsx)(`div`,{className:`text-[10px] text-[var(--text-muted)] italic`,children:`Primary agent re-run once with this feedback appended.`})]})]})}function tv({node:e}){let t=e.status,n=X[t]||X.pending,r=e.iterationHistory&&e.iterationHistory.length>0;return(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider`,style:{backgroundColor:`${n}20`,color:n},children:t}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--text-muted)]`,children:`Agent`})]}),(0,H.jsx)(ev,{node:e}),r?(0,H.jsx)(nv,{label:`Iteration ${e.iteration??`?`} (current)`,defaultExpanded:!0,status:t,snapshot:{iteration:e.iteration??0,prompt:e.prompt,output:e.output,elapsed:e.elapsed,model:e.model,reasoning_effort:e.reasoning_effort,tokens:e.tokens,input_tokens:e.input_tokens,output_tokens:e.output_tokens,cost_usd:e.cost_usd,activity:e.activity,error_type:e.error_type,error_message:e.error_message}}):(0,H.jsxs)(H.Fragment,{children:[(0,H.jsx)(q_,{items:J_(e)}),e.prompt&&(0,H.jsx)(Y_,{output:e.prompt,title:`Input / Prompt`,defaultExpanded:!0}),(0,H.jsx)(Z_,{activity:e.activity,defaultExpanded:t!==`completed`}),e.output!=null&&(0,H.jsx)(Y_,{output:e.output,title:`Output`})]}),r&&[...e.iterationHistory].reverse().map(e=>(0,H.jsx)(nv,{label:`Iteration ${e.iteration}`,defaultExpanded:!1,status:t,snapshot:e},e.iteration))]})}function nv({label:e,defaultExpanded:t,snapshot:n,status:r}){let[i,a]=(0,v.useState)(t);return(0,H.jsxs)(`div`,{className:`border border-[var(--border)] rounded-lg overflow-hidden`,children:[(0,H.jsxs)(`button`,{onClick:()=>a(!i),className:`flex items-center gap-2 w-full px-3 py-2 bg-[var(--bg)] hover:bg-[var(--node-bg)] transition-colors text-left`,children:[i?(0,H.jsx)(A,{className:`w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0`}):(0,H.jsx)(j,{className:`w-3.5 h-3.5 text-[var(--text-muted)] flex-shrink-0`}),(0,H.jsx)(`span`,{className:`text-xs font-semibold text-[var(--text)]`,children:e}),n.elapsed!=null&&(0,H.jsx)(`span`,{className:`text-[10px] text-[var(--text-muted)] ml-auto`,children:rv(n.elapsed)})]}),i&&(0,H.jsxs)(`div`,{className:`px-3 py-3 space-y-3 border-t border-[var(--border)]`,children:[(0,H.jsx)(q_,{items:J_(n)}),n.prompt&&(0,H.jsx)(Y_,{output:n.prompt,title:`Input / Prompt`,defaultExpanded:!1}),(0,H.jsx)(Z_,{activity:n.activity,defaultExpanded:t&&r!==`completed`}),n.output!=null&&(0,H.jsx)(Y_,{output:n.output,title:`Output`,defaultExpanded:!0}),n.error_type&&(0,H.jsxs)(`div`,{className:`text-xs text-red-400`,children:[(0,H.jsx)(`span`,{className:`font-semibold`,children:n.error_type}),n.error_message&&(0,H.jsxs)(`span`,{className:`ml-1`,children:[`— `,n.error_message]})]})]})]})}function rv(e){return e<1?`${(e*1e3).toFixed(0)}ms`:e<60?`${e.toFixed(1)}s`:`${Math.floor(e/60)}m ${(e%60).toFixed(0)}s`}function iv({node:e}){let t=e.status,n=X[t]||X.pending,r=[];e.elapsed!=null&&r.push({label:`Elapsed`,value:st(e.elapsed)}),e.exit_code!=null&&r.push({label:`Exit Code`,value:e.exit_code}),e.error_type&&r.push({label:`Error`,value:e.error_type}),e.error_message&&r.push({label:`Message`,value:e.error_message});let i=``;return e.stdout&&(i+=e.stdout),e.stderr&&(i+=(i?` --- stderr --- `:``)+e.stderr),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider`,style:{backgroundColor:`${n}20`,color:n},children:t}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--text-muted)]`,children:`Script`})]}),(0,H.jsx)(q_,{items:r}),i&&(0,H.jsx)(Y_,{output:i,title:`Output`})]})}function av({node:e}){let t=e.status,n=X[t]||X.pending,r=e.set_output_type,i=e.set_output_keys,a=e.set_value_repr,o=i?.length??0,s=[];return e.elapsed!=null&&s.push({label:`Elapsed`,value:st(e.elapsed)}),r&&s.push({label:`Output Type`,value:r}),o>0?s.push({label:`Bindings`,value:i.join(`, `)}):t===`completed`&&s.push({label:`Bindings`,value:`scalar`}),e.error_type&&s.push({label:`Error`,value:e.error_type}),e.error_message&&s.push({label:`Message`,value:e.error_message}),(0,H.jsxs)(`div`,{className:`space-y-4`,children:[(0,H.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,H.jsx)(`span`,{className:`inline-flex items-center px-2 py-0.5 rounded text-[10px] font-bold uppercase tracking-wider`,style:{backgroundColor:`${n}20`,color:n},children:t}),(0,H.jsx)(`span`,{className:`text-xs text-[var(--text-muted)]`,children:`Set`})]}),(0,H.jsx)(q_,{items:s}),a&&(0,H.jsx)(Y_,{output:a,title:`Value preview`})]})}function ov(e,t){let n=t||{};return(e[e.length-1]===``?[...e,``]:e).join((n.padRight?` `:``)+`,`+(n.padLeft===!1?``:` `)).trim()}var sv=/^[$_\p{ID_Start}][$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,cv=/^[$_\p{ID_Start}][-$_\u{200C}\u{200D}\p{ID_Continue}]*$/u,lv={};function uv(e,t){return((t||lv).jsx?cv:sv).test(e)}var dv=/[ \t\n\f\r]/g;function fv(e){return typeof e==`object`?e.type===`text`?pv(e.value):!1:pv(e)}function pv(e){return e.replace(dv,``)===``}var mv=class{constructor(e,t,n){this.normal=t,this.property=e,n&&(this.space=n)}};mv.prototype.normal={},mv.prototype.property={},mv.prototype.space=void 0;function hv(e,t){let n={},r={};for(let t of e)Object.assign(n,t.property),Object.assign(r,t.normal);return new mv(n,r,t)}function gv(e){return e.toLowerCase()}var _v=class{constructor(e,t){this.attribute=t,this.property=e}};_v.prototype.attribute=``,_v.prototype.booleanish=!1,_v.prototype.boolean=!1,_v.prototype.commaOrSpaceSeparated=!1,_v.prototype.commaSeparated=!1,_v.prototype.defined=!1,_v.prototype.mustUseProperty=!1,_v.prototype.number=!1,_v.prototype.overloadedBoolean=!1,_v.prototype.property=``,_v.prototype.spaceSeparated=!1,_v.prototype.space=void 0;var vv=s({boolean:()=>Z,booleanish:()=>bv,commaOrSpaceSeparated:()=>wv,commaSeparated:()=>Cv,number:()=>Q,overloadedBoolean:()=>xv,spaceSeparated:()=>Sv}),yv=0,Z=Tv(),bv=Tv(),xv=Tv(),Q=Tv(),Sv=Tv(),Cv=Tv(),wv=Tv();function Tv(){return 2**++yv}var Ev=Object.keys(vv),Dv=class extends _v{constructor(e,t,n,r){let i=-1;if(super(e,t),Ov(this,`space`,r),typeof n==`number`)for(;++i4&&n.slice(0,4)===`data`&&Vv.test(t)){if(t.charAt(4)===`-`){let e=t.slice(5).replace(Bv,Wv);r=`data`+e.charAt(0).toUpperCase()+e.slice(1)}else{let e=t.slice(4);if(!Bv.test(e)){let n=e.replace(zv,Uv);n.charAt(0)!==`-`&&(n=`-`+n),t=`data`+n}}i=Dv}return new i(r,t)}function Uv(e){return`-`+e.toLowerCase()}function Wv(e){return e.charAt(1).toUpperCase()}var Gv=hv([Av,Nv,Fv,Iv,Lv],`html`),Kv=hv([Av,Pv,Fv,Iv,Lv],`svg`);function qv(e){return e.join(` `).trim()}var Jv=o(((e,t)=>{var n=/\/\*[^*]*\*+([^/*][^*]*\*+)*\//g,r=/\n/g,i=/^\s*/,a=/^(\*?[-#/*\\\w]+(\[[0-9a-z_-]+\])?)\s*/,o=/^:\s*/,s=/^((?:'(?:\\'|.)*?'|"(?:\\"|.)*?"|\([^)]*?\)|[^};])+)/,c=/^[;\s]*/,l=/^\s+|\s+$/g,u=` diff --git a/src/conductor/web/static/index.html b/src/conductor/web/static/index.html index 0c96c03c..449fd563 100644 --- a/src/conductor/web/static/index.html +++ b/src/conductor/web/static/index.html @@ -5,7 +5,7 @@ Conductor Dashboard - +