onepipeline-ui 0.14.0 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -93,6 +93,6 @@ https://github.com/highlightjs/highlight.js/issues/2277`),i=e,r=t),n===void 0&&(
|
|
|
93
93
|
`,`
|
|
94
94
|
+`).split(`
|
|
95
95
|
`));return[t,t.reduce((e,t)=>e.concat(...t),[])]}return[[],[]]},[e]);return(0,U.useEffect)(()=>{let n=t?.target??SK,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)&&ZU(e))return!1;let n=TK(e.code,s);if(a.current.add(e[n]),wK(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=TK(e.code,s);wK(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 wK(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function TK(e,t){return t.includes(e)?`code`:`key`}var EK=()=>{let e=YG();return(0,U.useMemo)(()=>({zoomIn:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1.2,t):!1},zoomOut:async t=>{let{panZoom:n}=e.getState();return n?n.scaleBy(1/1.2,t):!1},zoomTo:async(t,n)=>{let{panZoom:r}=e.getState();return r?r.scaleTo(t,n):!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),!0):!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=RU(t,r,i,a,o,n?.padding??.1);return s?(await s.setViewport(c,{duration:n?.duration,ease:n?.ease,interpolate:n?.interpolate}),!0):!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 NU(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=PU(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function DK(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)OK(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 OK(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 kK(e,t){return DK(e,t)}function AK(e,t){return DK(e,t)}function jK(e,t){return{id:e,type:`select`,selected:t}}function MK(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(jK(a.id,e)))}return r}function NK({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 PK(e){return{id:e.id,type:`remove`}}var FK=jU(`React Flow`,`https://reactflow.dev/`);function IK(e,t,n={}){return uW(e,t,{...n,onError:n.onError??FK})}var LK=e=>aU(e),RK=e=>iU(e);function zK(e){return(0,U.forwardRef)(e)}var BK=typeof window<`u`?U.useLayoutEffect:U.useEffect;function VK(e){let[t,n]=(0,U.useState)(BigInt(0)),[r]=(0,U.useState)(()=>HK(()=>n(e=>e+BigInt(1))));return BK(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function HK(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var UK=(0,U.createContext)(null);function WK({children:e}){let t=YG(),n=VK((0,U.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=NK({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=VK((0,U.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(NK({items:s,lookup:o}))},[])),i=(0,U.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,G.jsx)(UK.Provider,{value:i,children:e})}function GK(){let e=(0,U.useContext)(UK);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var KK=e=>!!e.panZoom;function qK(){let e=EK(),t=YG(),n=GK(),r=JG(KK),i=(0,U.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=LK(e)?e:n.get(e.id),a=i.parentId?UU(i.position,i.measured,i.parentId,n,r):i.position;return wU({...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&&LK(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&&RK(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 hU({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(PK);o?.(f),c(e)}if(m){let e=d.map(PK);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=kU(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=wU(s?r:a),l=OU(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=kU(e)?e:a(e);if(!r)return!1;let i=OU(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 cU(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??GU();return t.setState({fitViewQueued:!0,fitViewOptions:e,fitViewResolver:r}),n.nodeQueue.push(e=>[...e]),r.promise}}},[]);return(0,U.useMemo)(()=>({...i,...e,viewportInitialized:r}),[r])}var JK=e=>e.selected,YK=typeof window<`u`?window:void 0;function XK({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=YG(),{deleteElements:r}=qK(),i=CK(e,{actInsideInputWithModifier:!1}),a=CK(t,{target:YK});(0,U.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(JK),edges:e.filter(JK)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,U.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function ZK(e){let t=YG();(0,U.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=JU(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,KH.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 QK={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},$K=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function eq({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=ZH.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:v,paneClickDistance:y,selectionOnDrag:b}){let x=YG(),S=(0,U.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=JG($K,WG),E=CK(f),D=(0,U.useRef)();ZK(S);let O=(0,U.useCallback)(e=>{_?.({x:e[0],y:e[1],zoom:e[2]}),v||x.setState({transform:e})},[_,v]);return(0,U.useEffect)(()=>{if(S.current){D.current=yG({domNode:S.current,minZoom:u,maxZoom:d,translateExtent:l,viewport:c,onDraggingChange:e=>x.setState(t=>t.paneDragging===e?t:{paneDragging:e}),onPanZoomStart:(e,t)=>{let{onViewportChangeStart:n,onMoveStart:r}=x.getState();r?.(e,t),n?.(t)},onPanZoom:(e,t)=>{let{onViewportChange:n,onMove:r}=x.getState();r?.(e,t),n?.(t)},onPanZoomEnd:(e,t)=>{let{onViewportChangeEnd:n,onMoveEnd:r}=x.getState();r?.(e,t),n?.(t)}});let{x:e,y:t,zoom:n}=D.current.getViewport();return x.setState({panZoom:D.current,transform:[e,t,n],domNode:S.current.closest(`.react-flow`)}),()=>{D.current?.destroy()}}},[]),(0,U.useEffect)(()=>{D.current?.update({onPaneContextMenu:e,zoomOnScroll:t,zoomOnPinch:n,panOnScroll:r,panOnScrollSpeed:i,panOnScrollMode:a,zoomOnDoubleClick:o,panOnDrag:s,zoomActivationKeyPressed:E,preventScrolling:p,noPanClassName:g,userSelectionActive:C,noWheelClassName:h,lib:w,onTransformChange:O,connectionInProgress:T,selectionOnDrag:b,paneClickDistance:y})},[e,t,n,r,i,a,o,s,E,p,g,C,h,w,O,T,b,y]),(0,G.jsx)(`div`,{className:`react-flow__renderer`,ref:S,style:QK,children:m})}var tq=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function nq(){let{userSelectionActive:e,userSelectionRect:t}=JG(tq,WG);return e&&t?(0,G.jsx)(`div`,{className:`react-flow__selection react-flow__container`,style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}var rq=(e,t)=>n=>{n.target===t.current&&e?.(n)},iq=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function aq({isSelecting:e,selectionKeyPressed:t,selectionMode:n=QH.Full,panOnDrag:r,autoPanOnSelection:i,paneClickDistance:a,selectionOnDrag:o,onSelectionStart:s,onSelectionEnd:c,onPaneClick:l,onPaneContextMenu:u,onPaneScroll:d,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:m,children:h}){let g=(0,U.useRef)(0),_=YG(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=JG(iq,WG),C=y&&(e||v),w=(0,U.useRef)(null),T=(0,U.useRef)(),E=(0,U.useRef)(new Set),D=(0,U.useRef)(new Set),O=(0,U.useRef)(!1),k=(0,U.useRef)(!1),A=(0,U.useRef)({x:0,y:0}),j=(0,U.useRef)(!1),M=e=>{if(k.current||O.current||_.getState().connection.inProgress){k.current=!1,O.current=!1;return}l?.(e),_.getState().resetSelectedElements(),_.setState({nodesSelectionActive:!1})},N=e=>{if(Array.isArray(r)&&r?.includes(2)){e.preventDefault();return}u?.(e)},P=d?e=>d(e):void 0,ee=e=>{k.current&&=(e.stopPropagation(),!1)},F=n=>{let{domNode:r,transform:i}=_.getState();if(T.current=r?.getBoundingClientRect(),!T.current)return;let a=n.target===w.current;if(!a&&n.target.closest(`.nokey`)||!e||!(o&&a||t)||n.button!==0||!n.isPrimary)return;n.target?.setPointerCapture?.(n.pointerId),k.current=!1;let{x:s,y:c}=$U(n.nativeEvent,T.current),l=NU({x:s,y:c},i);_.setState({userSelectionRect:{width:0,height:0,startX:l.x,startY:l.y,x:s,y:c}}),a||(n.stopPropagation(),n.preventDefault())};function I(e,t){let{userSelectionRect:r}=_.getState();if(!r)return;let{transform:i,nodeLookup:a,edgeLookup:o,connectionLookup:s,triggerNodeChanges:c,triggerEdgeChanges:l,defaultEdgeOptions:u}=_.getState(),d={x:r.startX,y:r.startY},{x:f,y:p}=PU(d,i),m={startX:d.x,startY:d.y,x:e<f?e:f,y:t<p?t:p,width:Math.abs(e-f),height:Math.abs(t-p)},h=E.current,g=D.current;E.current=new Set(uU(a,m,i,n===QH.Partial,!0).map(e=>e.id)),D.current=new Set;let v=u?.selectable??!0;for(let e of E.current){let t=s.get(e);if(t)for(let{edgeId:e}of t.values()){let t=o.get(e);t&&(t.selectable??v)&&D.current.add(e)}}WU(h,E.current)||c(MK(a,E.current,!0)),WU(g,D.current)||l(MK(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!i||!T.current)return;let[e,t]=bU(A.current,T.current,S);x({x:e,y:t}).then(e=>{if(!k.current||!e){g.current=requestAnimationFrame(L);return}let{x:t,y:n}=A.current;I(t,n),g.current=requestAnimationFrame(L)})}let te=()=>{cancelAnimationFrame(g.current),g.current=0,j.current=!1};return(0,U.useEffect)(()=>()=>te(),[]),(0,G.jsxs)(`div`,{className:cL([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:b,selection:e}]),onClick:C?void 0:rq(M,w),onContextMenu:rq(N,w),onWheel:rq(P,w),onPointerEnter:C?void 0:f,onPointerMove:C?e=>{let{userSelectionRect:n,transform:r,resetSelectedElements:i}=_.getState();if(!T.current||!n)return;let{x:o,y:c}=$U(e.nativeEvent,T.current);A.current={x:o,y:c};let l=PU({x:n.startX,y:n.startY},r);if(!k.current){let n=t?0:a;if(Math.hypot(o-l.x,c-l.y)<=n)return;i(),s?.(e)}k.current=!0,j.current||=(L(),!0),I(o,c)}:p,onPointerUp:e=>{if(!C){e.target===w.current&&_.getState().connection.inProgress&&(O.current=!0);return}e.button===0&&(e.target?.releasePointerCapture?.(e.pointerId),!v&&e.target===w.current&&_.getState().userSelectionRect&&M?.(e),_.setState({userSelectionActive:!1,userSelectionRect:null}),k.current&&(c?.(e),_.setState({nodesSelectionActive:E.current.size>0})),te())},onPointerCancel:C?e=>{e.target?.releasePointerCapture?.(e.pointerId),te()}:void 0,onPointerDownCapture:C?F:void 0,onClickCapture:C?ee:void 0,onPointerLeave:m,ref:w,style:QK,children:[h,(0,G.jsx)(nq,{})]})}function oq({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`,KH.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function sq({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=YG(),[c,l]=(0,U.useState)(!1),u=(0,U.useRef)();return(0,U.useEffect)(()=>{if(!t)return u.current=JW({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{oq({id:t,store:s,nodeRef:e})},onDragStart:()=>{l(!0)},onDragStop:()=>{l(!1)}}),()=>{u.current?.destroy(),u.current=void 0}},[t,s,e]),(0,U.useEffect)(()=>{t||!e.current||!u.current||u.current.update({noDragClassName:n,handleSelector:r,domNode:e.current,isSelectable:a,nodeId:i,nodeClickDistance:o})},[n,r,t,a,e,i,o]),c}var cq=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function lq(){let e=YG();return(0,U.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=cq(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=MU(t,i));let{position:a,positionAbsolute:s}=mU({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 uq=(0,U.createContext)(null),dq=uq.Provider;uq.Consumer;var fq=()=>(0,U.useContext)(uq),pq=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),mq=(0,U.createContext)(null);function hq({children:e}){let t=JG(pq,WG);return(0,G.jsx)(mq.Provider,{value:t,children:e})}function gq(){let e=(0,U.useContext)(mq);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var _q={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},vq=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return _q;let 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===XH.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function yq({type:e=`source`,position:t=$.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=YG(),_=fq(),{connectOnClick:v,noPanClassName:y,rfId:b}=gq(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=JG(vq(_,m,e),WG);_||g.getState().onError?.(`010`,KH.error010());let O=e=>{let{defaultEdgeOptions:t,onConnect:n,hasDefaultEdges:r}=g.getState(),i={...t,...e};if(r){let{edges:e,setEdges:t,onError:n}=g.getState();t(IK(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=QU(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();iG.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,G.jsx)(`div`,{"data-handleid":m,"data-nodeid":_,"data-handlepos":t,"data-id":`${b}-${_}-${m}-${e}`,className:cL([`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=YU(t.target),h=n||c,{connection:v,isValid:y}=iG.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 bq=(0,U.memo)(zK(yq));function xq({data:e,isConnectable:t,sourcePosition:n=$.Bottom}){return(0,G.jsxs)(G.Fragment,{children:[e?.label,(0,G.jsx)(bq,{type:`source`,position:n,isConnectable:t})]})}function Sq({data:e,isConnectable:t,targetPosition:n=$.Top,sourcePosition:r=$.Bottom}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bq,{type:`target`,position:n,isConnectable:t}),e?.label,(0,G.jsx)(bq,{type:`source`,position:r,isConnectable:t})]})}function Cq(){return null}function wq({data:e,isConnectable:t,targetPosition:n=$.Top}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(bq,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Tq={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Eq={input:xq,default:Sq,output:wq,group:Cq};function Dq(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 Oq=e=>{let{width:t,height:n,x:r,y:i}=lU(e.nodeLookup,{filter:e=>!!e.selected});return{width:AU(t)?t:null,height:AU(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 kq({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=YG(),{width:i,height:a,transformString:o,userSelectionActive:s}=JG(Oq,WG),c=lq(),l=(0,U.useRef)(null);(0,U.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(sq({nodeRef:l,disabled:!u}),!u)return null;let d=e?t=>{e(t,r.getState().nodes.filter(e=>e.selected))}:void 0;return(0,G.jsx)(`div`,{className:cL([`react-flow__nodesselection`,`react-flow__container`,t]),style:{transform:o},children:(0,G.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(Tq,e.key)&&(e.preventDefault(),c({direction:Tq[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Aq=typeof window<`u`?window:void 0,jq=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Mq({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,autoPanOnSelection:T,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,preventScrolling:A,onSelectionContextMenu:j,noWheelClassName:M,noPanClassName:N,disableKeyboardA11y:P,onViewportChange:ee,isControlledViewport:F}){let{nodesSelectionActive:I,userSelectionActive:L}=JG(jq,WG),te=CK(l,{target:Aq}),ne=CK(h,{target:Aq}),re=ne||w,R=ne||b,ie=u&&re!==!0,ae=te||L||ie;return XK({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,G.jsx)(eq,{onPaneContextMenu:a,elementsSelectable:_,zoomOnScroll:v,zoomOnPinch:y,panOnScroll:R,panOnScrollSpeed:x,panOnScrollMode:S,zoomOnDoubleClick:C,panOnDrag:!te&&re,defaultViewport:E,translateExtent:D,minZoom:O,maxZoom:k,zoomActivationKeyCode:g,preventScrolling:A,noWheelClassName:M,noPanClassName:N,onViewportChange:ee,isControlledViewport:F,paneClickDistance:s,selectionOnDrag:ie,children:(0,G.jsxs)(aq,{onSelectionStart:f,onSelectionEnd:p,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:i,onPaneContextMenu:a,onPaneScroll:o,panOnDrag:re,autoPanOnSelection:T,isSelecting:!!ae,selectionMode:d,selectionKeyPressed:te,paneClickDistance:s,selectionOnDrag:ie,children:[e,I&&(0,G.jsx)(kq,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}Mq.displayName=`FlowRenderer`;var Nq=(0,U.memo)(Mq),Pq=e=>t=>e?uU(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 Fq(e){return JG((0,U.useCallback)(Pq(e),[e]),WG)}var Iq=e=>e.updateNodeInternals;function Lq(){let e=JG(Iq),[t]=(0,U.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,U.useEffect)(()=>()=>{t?.disconnect()},[t]),t}function Rq({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=YG(),a=(0,U.useRef)(null),o=(0,U.useRef)(null),s=(0,U.useRef)(e.sourcePosition),c=(0,U.useRef)(e.targetPosition),l=(0,U.useRef)(t),u=n&&!!e.internals.handleBounds;return(0,U.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,U.useEffect)(()=>()=>{o.current&&=(r?.unobserve(o.current),null)},[]),(0,U.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 zq({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}=JG(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},WG),S=y.type||`default`,C=g?.[S]||Eq[S];C===void 0&&(v?.(`003`,KH.error003(S)),S=`default`,C=g?.default||Eq.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=YG(),k=HU(y),A=Rq({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=sq({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=lq();if(y.hidden)return null;let N=VU(y),P=Dq(y),ee=T||w||t||n||r||i,F=n?e=>n(e,{...b.userNode}):void 0,I=r?e=>r(e,{...b.userNode}):void 0,L=i?e=>i(e,{...b.userNode}):void 0,te=a?e=>a(e,{...b.userNode}):void 0,ne=o?e=>o(e,{...b.userNode}):void 0,re=n=>{let{selectNodesOnDrag:r,nodeDragThreshold:i}=O.getState();T&&(!r||!w||i>0)&&oq({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},R=t=>{if(!(ZU(t.nativeEvent)||m)){if(JH.includes(t.key)&&T){let n=t.key===`Escape`;oq({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(Tq,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:Tq[t.key],factor:t.shiftKey?4:1})}}},ie=()=>{if(m||!A.current?.matches(`:focus-visible`))return;let{transform:t,width:n,height:r,autoPanOnNodeFocus:i,setCenter:a}=O.getState();i&&(uU(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,G.jsx)(`div`,{className:cL([`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:ee?`all`:`none`,visibility:k?`visible`:`hidden`,...y.style,...P},"data-id":e,"data-testid":`rf__node-${e}`,onMouseEnter:F,onMouseMove:I,onMouseLeave:L,onContextMenu:te,onClick:re,onDoubleClick:ne,onKeyDown:D?R:void 0,tabIndex:D?0:void 0,onFocus:D?ie:void 0,role:y.ariaRole??(D?`group`:void 0),"aria-roledescription":`node`,"aria-describedby":m?void 0:`${QG}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,G.jsx)(dq,{value:e,children:(0,G.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 Bq=(0,U.memo)(zq),Vq=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Hq(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=JG(Vq,WG),a=Fq(e.onlyRenderVisibleElements),o=Lq();return(0,G.jsx)(`div`,{className:`react-flow__nodes`,style:QK,children:a.map(a=>(0,G.jsx)(Bq,{id:a,nodeTypes:e.nodeTypes,nodeExtent:e.nodeExtent,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,resizeObserver:o,nodesDraggable:e.nodesDraggable??!0,nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,nodeClickDistance:e.nodeClickDistance,onError:i},a))})}Hq.displayName=`NodeRenderer`;var Uq=(0,U.memo)(Hq);function Wq(e){return JG((0,U.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&&sW({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),WG)}var Gq=({color:e=`none`,strokeWidth:t=1})=>(0,G.jsx)(`polyline`,{className:`arrow`,style:{strokeWidth:t,...e&&{stroke:e}},strokeLinecap:`round`,fill:`none`,strokeLinejoin:`round`,points:`-5,-4 0,0 -5,4`}),Kq=({color:e=`none`,strokeWidth:t=1})=>(0,G.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`}),qq={[tU.Arrow]:Gq,[tU.ArrowClosed]:Kq};function Jq(e){let t=YG();return(0,U.useMemo)(()=>Object.prototype.hasOwnProperty.call(qq,e)?qq[e]:(t.getState().onError?.(`009`,KH.error009(e)),null),[e])}var Yq=({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=Jq(t);return c?(0,G.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,G.jsx)(c,{color:n,strokeWidth:o})}):null},Xq=({defaultColor:e,rfId:t})=>{let n=JG(e=>e.edges),r=JG(e=>e.defaultEdgeOptions),i=(0,U.useMemo)(()=>wW(n,{id:t,defaultColor:e,defaultMarkerStart:r?.markerStart,defaultMarkerEnd:r?.markerEnd}),[n,r,t,e]);return i.length?(0,G.jsx)(`svg`,{className:`react-flow__marker`,"aria-hidden":`true`,children:(0,G.jsx)(`defs`,{children:i.map(e=>(0,G.jsx)(Yq,{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};Xq.displayName=`MarkerDefinitions`;var Zq=(0,U.memo)(Xq);function Qq({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,U.useState)({x:1,y:0,width:0,height:0}),p=cL([`react-flow__edge-textwrapper`,l]),m=(0,U.useRef)(null);return(0,U.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,G.jsxs)(`g`,{transform:`translate(${e-d.width/2} ${t-d.height/2})`,className:p,visibility:d.width?`visible`:`hidden`,...u,children:[i&&(0,G.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,G.jsx)(`text`,{className:`react-flow__edge-text`,y:d.height/2,dy:`0.3em`,ref:m,style:r,children:n}),c]}):null}Qq.displayName=`EdgeText`;var $q=(0,U.memo)(Qq);function eJ({path:e,labelX:t,labelY:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c,interactionWidth:l=20,...u}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`path`,{...u,d:e,fill:`none`,className:cL([`react-flow__edge-path`,u.className])}),l?(0,G.jsx)(`path`,{d:e,fill:`none`,strokeOpacity:0,strokeWidth:l,className:`react-flow__edge-interaction`}):null,r&&AU(t)&&AU(n)?(0,G.jsx)($q,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function tJ({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===$.Left||e===$.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function nJ({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top}){let[o,s]=tJ({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=tJ({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=tW({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 rJ(e){return(0,U.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]=nJ({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,G.jsx)(eJ,{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 iJ=rJ({isInternal:!1}),aJ=rJ({isInternal:!0});iJ.displayName=`SimpleBezierEdge`,aJ.displayName=`SimpleBezierEdgeInternal`;function oJ(e){return(0,U.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=$.Bottom,targetPosition:m=$.Top,markerEnd:h,markerStart:g,pathOptions:_,interactionWidth:v})=>{let[y,b,x]=_W({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,G.jsx)(eJ,{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 sJ=oJ({isInternal:!1}),cJ=oJ({isInternal:!0});sJ.displayName=`SmoothStepEdge`,cJ.displayName=`SmoothStepEdgeInternal`;function lJ(e){return(0,U.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,G.jsx)(sJ,{...n,id:r,pathOptions:(0,U.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var uJ=lJ({isInternal:!1}),dJ=lJ({isInternal:!0});uJ.displayName=`StepEdge`,dJ.displayName=`StepEdgeInternal`;function fJ(e){return(0,U.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]=dW({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,G.jsx)(eJ,{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 pJ=fJ({isInternal:!1}),mJ=fJ({isInternal:!0});pJ.displayName=`StraightEdge`,mJ.displayName=`StraightEdgeInternal`;function hJ(e){return(0,U.memo)(({id:t,sourceX:n,sourceY:r,targetX:i,targetY:a,sourcePosition:o=$.Bottom,targetPosition:s=$.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]=iW({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,G.jsx)(eJ,{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 gJ=hJ({isInternal:!1}),_J=hJ({isInternal:!0});gJ.displayName=`BezierEdge`,_J.displayName=`BezierEdgeInternal`;var vJ={default:_J,straight:mJ,step:dJ,smoothstep:cJ,simplebezier:aJ},yJ={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},bJ=(e,t,n)=>n===$.Left?e-t:n===$.Right?e+t:e,xJ=(e,t,n)=>n===$.Top?e-t:n===$.Bottom?e+t:e,SJ=`react-flow__edgeupdater`;function CJ({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:i,onMouseEnter:a,onMouseOut:o,type:s}){return(0,G.jsx)(`circle`,{onMouseDown:i,onMouseEnter:a,onMouseOut:o,className:cL([SJ,`${SJ}-${s}`]),cx:bJ(t,r,e),cy:xJ(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function wJ({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=YG(),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`;iG.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,G.jsxs)(G.Fragment,{children:[(e===!0||e===`source`)&&(0,G.jsx)(CJ,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,G.jsx)(CJ,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function TJ({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:v}){let y=JG(t=>t.edgeLookup.get(e)),b=JG(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||vJ[x];S===void 0&&(_?.(`011`,KH.error011(x)),x=`default`,S=h?.default||vJ.default);let C=!!(y.focusable||t&&y.focusable===void 0),w=d!==void 0&&(y.reconnectable||n&&y.reconnectable===void 0),T=!!(y.selectable||r&&y.selectable===void 0),E=(0,U.useRef)(null),[D,O]=(0,U.useState)(!1),[k,A]=(0,U.useState)(!1),j=YG(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:ee,targetY:F,sourcePosition:I,targetPosition:L}=JG((0,U.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return yJ;let i=yW({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=oW({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||yJ,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),WG),te=(0,U.useMemo)(()=>y.markerStart?`url('#${CW(y.markerStart,m)}')`:void 0,[y.markerStart,m]),ne=(0,U.useMemo)(()=>y.markerEnd?`url('#${CW(y.markerEnd,m)}')`:void 0,[y.markerEnd,m]);if(y.hidden||N===null||P===null||ee===null||F===null)return null;let re=t=>{let{addSelectedEdges:n,unselectNodesAndEdges:r,multiSelectionActive:a}=j.getState();T&&(j.setState({nodesSelectionActive:!1}),y.selected&&a?(r({nodes:[],edges:[y]}),E.current?.blur()):n([e])),i&&i(t,y)},R=a?e=>{a(e,{...y})}:void 0,ie=o?e=>{o(e,{...y})}:void 0,ae=s?e=>{s(e,{...y})}:void 0,oe=c?e=>{c(e,{...y})}:void 0,se=l?e=>{l(e,{...y})}:void 0;return(0,G.jsx)(`svg`,{style:{zIndex:M},children:(0,G.jsxs)(`g`,{className:cL([`react-flow__edge`,`react-flow__edge-${x}`,y.className,g,{selected:y.selected,animated:y.animated,inactive:!T&&!i,updating:D,selectable:T}]),onClick:re,onDoubleClick:R,onContextMenu:ie,onMouseEnter:ae,onMouseMove:oe,onMouseLeave:se,onKeyDown:C?t=>{if(!v&&JH.includes(t.key)&&T){let{unselectNodesAndEdges:n,addSelectedEdges:r}=j.getState();t.key===`Escape`?(E.current?.blur(),n({edges:[y]})):r([e])}}:void 0,tabIndex:C?0:void 0,role:y.ariaRole??(C?`group`:`img`),"aria-roledescription":`edge`,"data-id":e,"data-testid":`rf__edge-${e}`,"aria-label":y.ariaLabel===null?void 0:y.ariaLabel||`Edge from ${y.source} to ${y.target}`,"aria-describedby":C?`${$G}-${m}`:void 0,ref:E,...y.domAttributes,children:[!k&&(0,G.jsx)(S,{id:e,source:y.source,target:y.target,type:y.type,selected:y.selected,animated:y.animated,selectable:T,deletable:y.deletable??!0,label:y.label,labelStyle:y.labelStyle,labelShowBg:y.labelShowBg,labelBgStyle:y.labelBgStyle,labelBgPadding:y.labelBgPadding,labelBgBorderRadius:y.labelBgBorderRadius,sourceX:N,sourceY:P,targetX:ee,targetY:F,sourcePosition:I,targetPosition:L,data:y.data,style:y.style,sourceHandleId:y.sourceHandle,targetHandleId:y.targetHandle,markerStart:te,markerEnd:ne,pathOptions:`pathOptions`in y?y.pathOptions:void 0,interactionWidth:y.interactionWidth}),w&&(0,G.jsx)(wJ,{edge:y,isReconnectable:w,reconnectRadius:u,onReconnect:d,onReconnectStart:f,onReconnectEnd:p,sourceX:N,sourceY:P,targetX:ee,targetY:F,sourcePosition:I,targetPosition:L,setUpdateHover:O,setReconnecting:A})]})})}var EJ=(0,U.memo)(TJ),DJ=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function OJ({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}=JG(DJ,WG),b=Wq(t);return(0,G.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,G.jsx)(Zq,{defaultColor:e,rfId:n}),b.map(e=>(0,G.jsx)(EJ,{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))]})}OJ.displayName=`EdgeRenderer`;var kJ=(0,U.memo)(OJ),AJ=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function jJ({children:e}){let t=YG(),n=(0,U.useRef)(null),[r]=(0,U.useState)(()=>t.getState().transform);return BK(()=>{let e=null,r=()=>{let r=t.getState().transform;e&&r[0]===e[0]&&r[1]===e[1]&&r[2]===e[2]||(e=r,n.current&&(n.current.style.transform=AJ(r)))};return r(),t.subscribe(r)},[t]),(0,G.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:AJ(r)},children:e})}function MJ(e){let t=qK(),n=(0,U.useRef)(!1);(0,U.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var NJ=e=>e.panZoom?.syncViewport;function PJ(e){let t=JG(NJ),n=YG();return(0,U.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function FJ(e){return e.connection.inProgress?{...e.connection,to:NU(e.connection.to,e.transform)}:{...e.connection}}function IJ(e){return e?t=>e(FJ(t)):FJ}function LJ(e){return JG(IJ(e),WG)}var RJ=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function zJ({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=JG(RJ,WG);return a&&i&&c?(0,G.jsx)(`svg`,{style:e,width:a,height:o,className:`react-flow__connectionline react-flow__container`,children:(0,G.jsx)(`g`,{className:cL([`react-flow__connection`,rU(s)]),children:(0,G.jsx)(BJ,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var BJ=({style:e,type:t=eU.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}=LJ();if(!i)return;if(n)return(0,G.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:rU(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 eU.Bezier:[m]=iW(h);break;case eU.SimpleBezier:[m]=nJ(h);break;case eU.Step:[m]=_W({...h,borderRadius:0});break;case eU.SmoothStep:[m]=_W(h);break;default:[m]=dW(h)}return(0,G.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};BJ.displayName=`ConnectionLine`;var VJ={};function HJ(e=VJ){(0,U.useRef)(e),YG(),(0,U.useEffect)(()=>{},[e])}function UJ(){YG(),(0,U.useRef)(!1),(0,U.useEffect)(()=>{},[])}function WJ({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:P,panOnScroll:ee,panOnScrollSpeed:F,panOnScrollMode:I,zoomOnDoubleClick:L,panOnDrag:te,autoPanOnSelection:ne,onPaneClick:re,onPaneMouseEnter:R,onPaneMouseMove:ie,onPaneMouseLeave:ae,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:z,onViewportChange:we,nodesDraggable:Te}){return HJ(e),HJ(t),UJ(),MJ(n),PJ(z),(0,G.jsx)(Nq,{onPaneClick:re,onPaneMouseEnter:R,onPaneMouseMove:ie,onPaneMouseLeave:ae,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:P,zoomOnDoubleClick:L,panOnScroll:ee,panOnScrollSpeed:F,panOnScrollMode:I,panOnDrag:te,autoPanOnSelection:ne,defaultViewport:D,translateExtent:O,minZoom:k,maxZoom:A,onSelectionContextMenu:d,preventScrolling:j,noDragClassName:ve,noWheelClassName:ye,noPanClassName:be,disableKeyboardA11y:xe,onViewportChange:we,isControlledViewport:!!z,children:(0,G.jsxs)(jJ,{children:[(0,G.jsx)(kJ,{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,G.jsx)(zJ,{style:h,type:m,component:g,containerStyle:_}),(0,G.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,G.jsx)(Uq,{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,nodesDraggable:Te}),(0,G.jsx)(`div`,{className:`react-flow__viewport-portal`})]})})}WJ.displayName=`GraphView`;var GJ=(0,U.memo)(WJ),KJ=jU(`React Flow`,`https://reactflow.dev/`),qJ=({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??qH;HW(h,g,_);let{nodesInitialized:x}=NW(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=RU(lU(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:qH,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:XH.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:{...$H},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:KJ,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:YH,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},JJ=({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})=>UG((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 pU({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...qJ({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,nodesSelectionActive:s}=m(),{nodesInitialized:c,hasSelectedNodes:l}=NW(e,t,n,{nodeOrigin:r,nodeExtent:d,elevateNodesOnSelect:i,checkEquality:!0,zIndexMode:o}),u=s&&l;a&&c?(h(),p({nodes:e,nodesInitialized:c,fitViewQueued:!1,fitViewOptions:void 0,nodesSelectionActive:u})):p({nodes:e,nodesInitialized:c,nodesSelectionActive:u})},setEdges:e=>{let{connectionLookup:t,edgeLookup:n}=m();HW(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}=zW(e,n,r,i,a,o,l);d&&(AW(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=xW(e,o.fromHandle,$.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=RW(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(kK(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(AK(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=>jK(e,!0)));return}i(MK(r,new Set([...e]),!0)),a(MK(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>jK(e,!0)));return}a(MK(n,new Set([...e]))),i(MK(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(jK(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(jK(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,jK(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,jK(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]||(NW(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 BW({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!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}),!0},cancelConnection:()=>{p({connection:{...$H}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...qJ()})}},Object.is);function YJ({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,U.useState)(()=>JJ({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,G.jsx)(KG,{value:m,children:(0,G.jsx)(WK,{children:(0,G.jsx)(hq,{children:p})})})}function XJ({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,U.useContext)(GG)?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsx)(YJ,{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 ZJ={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function QJ({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:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onSelectionChange:k,onSelectionDragStart:A,onSelectionDrag:j,onSelectionDragStop:M,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:ee,onBeforeDelete:F,connectionMode:I,connectionLineType:L=eU.Bezier,connectionLineStyle:te,connectionLineComponent:ne,connectionLineContainerStyle:re,deleteKeyCode:R=`Backspace`,selectionKeyCode:ie=`Shift`,selectionOnDrag:ae=!1,selectionMode:oe=QH.Full,panActivationKeyCode:se=`Space`,multiSelectionKeyCode:ce=zU()?`Meta`:`Control`,zoomActivationKeyCode:le=zU()?`Meta`:`Control`,snapToGrid:ue,snapGrid:de,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:pe,nodesDraggable:me,autoPanOnNodeFocus:he,nodesConnectable:ge,nodesFocusable:_e,nodeOrigin:ve=mK,edgesFocusable:ye,edgesReconnectable:be,elementsSelectable:xe=!0,defaultViewport:Se=hK,minZoom:Ce=.5,maxZoom:z=2,translateExtent:we=qH,preventScrolling:Te=!0,nodeExtent:Ee,defaultMarkerColor:De=`#b1b1b7`,zoomOnScroll:Oe=!0,zoomOnPinch:ke=!0,panOnScroll:Ae=!1,panOnScrollSpeed:je=.5,panOnScrollMode:Me=ZH.Free,zoomOnDoubleClick:Ne=!0,panOnDrag:Pe=!0,onPaneClick:B,onPaneMouseEnter:Fe,onPaneMouseMove:Ie,onPaneMouseLeave:Le,onPaneScroll:Re,onPaneContextMenu:ze,paneClickDistance:Be=1,nodeClickDistance:Ve=0,children:V,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe=10,onNodesChange:Ze,onEdgesChange:Qe,noDragClassName:$e=`nodrag`,noWheelClassName:et=`nowheel`,noPanClassName:tt=`nopan`,fitView:nt,fitViewOptions:rt,connectOnClick:it,attributionPosition:at,proOptions:H,defaultEdgeOptions:ot,elevateNodesOnSelect:st=!0,elevateEdgesOnSelect:ct=!1,disableKeyboardA11y:lt=!1,autoPanOnConnect:ut,autoPanOnNodeDrag:dt,autoPanOnSelection:ft=!0,autoPanSpeed:pt,connectionRadius:mt,isValidConnection:W,onError:ht,style:gt,id:_t,nodeDragThreshold:vt,connectionDragThreshold:yt,viewport:bt,onViewportChange:xt,width:St,height:Ct,colorMode:wt=`light`,debug:Tt,onScroll:Et,ariaLabelConfig:Dt,zIndexMode:Ot=`basic`,...kt},At){let jt=_t||`1`,Mt=xK(wt),Nt=(0,U.useCallback)(e=>{e.currentTarget.scrollTo({top:0,left:0,behavior:`instant`}),Et?.(e)},[Et]);return(0,G.jsx)(`div`,{"data-testid":`rf__wrapper`,...kt,onScroll:Nt,style:{...gt,...ZJ},ref:At,className:cL([`react-flow`,i,Mt]),id:_t,role:`application`,children:(0,G.jsxs)(XJ,{nodes:e,edges:t,width:St,height:Ct,fitView:nt,fitViewOptions:rt,minZoom:Ce,maxZoom:z,nodeOrigin:ve,nodeExtent:Ee,zIndexMode:Ot,children:[(0,G.jsx)(yK,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:p,onConnectStart:m,onConnectEnd:h,onClickConnectStart:g,onClickConnectEnd:_,nodesDraggable:me,autoPanOnNodeFocus:he,nodesConnectable:ge,nodesFocusable:_e,edgesFocusable:ye,edgesReconnectable:be,elementsSelectable:xe,elevateNodesOnSelect:st,elevateEdgesOnSelect:ct,minZoom:Ce,maxZoom:z,nodeExtent:Ee,onNodesChange:Ze,onEdgesChange:Qe,snapToGrid:ue,snapGrid:de,connectionMode:I,translateExtent:we,connectOnClick:it,defaultEdgeOptions:ot,fitView:nt,fitViewOptions:rt,onNodesDelete:E,onEdgesDelete:D,onDelete:O,onNodeDragStart:C,onNodeDrag:w,onNodeDragStop:T,onSelectionDrag:j,onSelectionDragStart:A,onSelectionDragStop:M,onMove:u,onMoveStart:d,onMoveEnd:f,noPanClassName:tt,nodeOrigin:ve,rfId:jt,autoPanOnConnect:ut,autoPanOnNodeDrag:dt,autoPanSpeed:pt,onError:ht,connectionRadius:mt,isValidConnection:W,selectNodesOnDrag:pe,nodeDragThreshold:vt,connectionDragThreshold:yt,onBeforeDelete:F,debug:Tt,ariaLabelConfig:Dt,zIndexMode:Ot}),(0,G.jsx)(GJ,{onInit:l,onNodeClick:s,onEdgeClick:c,onNodeMouseEnter:v,onNodeMouseMove:y,onNodeMouseLeave:b,onNodeContextMenu:x,onNodeDoubleClick:S,nodeTypes:a,edgeTypes:o,connectionLineType:L,connectionLineStyle:te,connectionLineComponent:ne,connectionLineContainerStyle:re,selectionKeyCode:ie,selectionOnDrag:ae,selectionMode:oe,deleteKeyCode:R,multiSelectionKeyCode:ce,panActivationKeyCode:se,zoomActivationKeyCode:le,onlyRenderVisibleElements:fe,defaultViewport:Se,translateExtent:we,minZoom:Ce,maxZoom:z,preventScrolling:Te,zoomOnScroll:Oe,zoomOnPinch:ke,zoomOnDoubleClick:Ne,panOnScroll:Ae,panOnScrollSpeed:je,panOnScrollMode:Me,panOnDrag:Pe,autoPanOnSelection:ft,onPaneClick:B,onPaneMouseEnter:Fe,onPaneMouseMove:Ie,onPaneMouseLeave:Le,onPaneScroll:Re,onPaneContextMenu:ze,paneClickDistance:Be,nodeClickDistance:Ve,onSelectionContextMenu:N,onSelectionStart:P,onSelectionEnd:ee,onReconnect:He,onReconnectStart:Ue,onReconnectEnd:We,onEdgeContextMenu:Ge,onEdgeDoubleClick:Ke,onEdgeMouseEnter:qe,onEdgeMouseMove:Je,onEdgeMouseLeave:Ye,reconnectRadius:Xe,defaultMarkerColor:De,noDragClassName:$e,noWheelClassName:et,noPanClassName:tt,rfId:jt,disableKeyboardA11y:lt,nodeExtent:Ee,viewport:bt,onViewportChange:xt,nodesDraggable:me}),(0,G.jsx)(pK,{onSelectionChange:k}),V,(0,G.jsx)(sK,{proOptions:H,position:at}),(0,G.jsx)(iK,{rfId:jt,disableKeyboardA11y:lt})]})})}var $J=zK(QJ);KH.error014();function eY({dimensions:e,lineWidth:t,variant:n,className:r}){return(0,G.jsx)(`path`,{strokeWidth:t,d:`M${e[0]/2} 0 V${e[1]} M0 ${e[1]/2} H${e[0]}`,className:cL([`react-flow__background-pattern`,n,r])})}function tY({radius:e,className:t}){return(0,G.jsx)(`circle`,{cx:e,cy:e,r:e,className:cL([`react-flow__background-pattern`,`dots`,t])})}var nY;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(nY||={});var rY={[nY.Dots]:1,[nY.Lines]:1,[nY.Cross]:6},iY=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function aY({id:e,variant:t=nY.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,U.useRef)(null),{transform:f,patternId:p}=JG(iY,WG),m=r||rY[t],h=t===nY.Dots,g=t===nY.Cross,_=Array.isArray(n)?n:[n,n],v=[_[0]*f[2]||1,_[1]*f[2]||1],y=m*f[2],b=Array.isArray(a)?a:[a,a],x=g?[y,y]:v,S=[b[0]*f[2]||1+x[0]/2,b[1]*f[2]||1+x[1]/2],C=`${p}${e||``}`;return(0,G.jsxs)(`svg`,{className:cL([`react-flow__background`,l]),style:{...c,...QK,"--xy-background-color-props":s,"--xy-background-pattern-color-props":o},ref:d,"data-testid":`rf__background`,children:[(0,G.jsx)(`pattern`,{id:C,x:f[0]%v[0],y:f[1]%v[1],width:v[0],height:v[1],patternUnits:`userSpaceOnUse`,patternTransform:`translate(-${S[0]},-${S[1]})`,children:h?(0,G.jsx)(tY,{radius:y/2,className:u}):(0,G.jsx)(eY,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,G.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}aY.displayName=`Background`;var oY=(0,U.memo)(aY);function sY(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 32`,children:(0,G.jsx)(`path`,{d:`M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z`})})}function cY(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 5`,children:(0,G.jsx)(`path`,{d:`M0 0h32v4.2H0z`})})}function lY(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 32 30`,children:(0,G.jsx)(`path`,{d:`M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z`})})}function uY(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,G.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z`})})}function dY(){return(0,G.jsx)(`svg`,{xmlns:`http://www.w3.org/2000/svg`,viewBox:`0 0 25 32`,children:(0,G.jsx)(`path`,{d:`M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z`})})}function fY({children:e,className:t,...n}){return(0,G.jsx)(`button`,{type:`button`,className:cL([`react-flow__controls-button`,t]),...n,children:e})}var pY=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function mY({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=YG(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=JG(pY,WG),{zoomIn:y,zoomOut:b,fitView:x}=qK();return(0,G.jsxs)(aK,{className:cL([`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,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fY,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,G.jsx)(sY,{})}),(0,G.jsx)(fY,{onClick:()=>{b(),o?.()},className:`react-flow__controls-zoomout`,title:v[`controls.zoomOut.ariaLabel`],"aria-label":v[`controls.zoomOut.ariaLabel`],disabled:g,children:(0,G.jsx)(cY,{})})]}),n&&(0,G.jsx)(fY,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,G.jsx)(lY,{})}),r&&(0,G.jsx)(fY,{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,G.jsx)(dY,{}):(0,G.jsx)(uY,{})}),u]})}mY.displayName=`Controls`;var hY=(0,U.memo)(mY);function gY({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,G.jsx)(`rect`,{className:cL([`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 _Y=(0,U.memo)(gY),vY=e=>e.nodes.map(e=>e.id),yY=e=>e instanceof Function?e:()=>e;function bY({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=_Y,onClick:o}){let s=JG(vY,WG),c=yY(t),l=yY(e),u=yY(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,G.jsx)(G.Fragment,{children:s.map(e=>(0,G.jsx)(SY,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function xY({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}=JG(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}=VU(r);return{node:r,x:i,y:a,width:o,height:s}},WG);return!l||l.hidden||!HU(l)?null:(0,G.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 SY=(0,U.memo)(xY),CY=(0,U.memo)(bY),wY=200,TY=150,EY=e=>!e.hidden,DY=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?EU(lU(e.nodeLookup,{filter:EY}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},OY=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,kY=(e,t)=>OY(e.viewBB,t.viewBB)&&OY(e.boundingRect,t.boundingRect)&&e.rfId===t.rfId&&e.panZoom===t.panZoom&&e.translateExtent===t.translateExtent&&e.flowWidth===t.flowWidth&&e.flowHeight===t.flowHeight&&e.ariaLabelConfig===t.ariaLabelConfig,AY=`react-flow__minimap-desc`;function jY({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:v,zoomStep:y=1,offsetScale:b=5}){let x=YG(),S=(0,U.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=JG(DY,kY),j=e?.width??wY,M=e?.height??TY,N=C.width/j,P=C.height/M,ee=Math.max(N,P),F=ee*j,I=ee*M,L=b*ee,te=C.x-(F-C.width)/2-L,ne=C.y-(I-C.height)/2-L,re=F+L*2,R=I+L*2,ie=`${AY}-${T}`,ae=(0,U.useRef)(0),oe=(0,U.useRef)();ae.current=ee,(0,U.useEffect)(()=>{if(S.current&&E)return oe.current=aG({domNode:S.current,panZoom:E,getTransform:()=>x.getState().transform,getViewScale:()=>ae.current}),()=>{oe.current?.destroy()}},[E]),(0,U.useEffect)(()=>{oe.current?.update({translateExtent:D,width:O,height:k,inversePan:v,pannable:h,zoomStep:y,zoomable:g})},[h,g,v,y,D,O,k]);let se=p?e=>{let[t,n]=oe.current?.pointer(e)||[0,0];p(e,{x:t,y:n})}:void 0,ce=m?(0,U.useCallback)((e,t)=>{let n=x.getState().nodeLookup.get(t).internals.userNode;m(e,n)},[]):void 0,le=_??A[`minimap.ariaLabel`];return(0,G.jsx)(aK,{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*ee: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:cL([`react-flow__minimap`,t]),"data-testid":`rf__minimap`,children:(0,G.jsxs)(`svg`,{width:j,height:M,viewBox:`${te} ${ne} ${re} ${R}`,className:`react-flow__minimap-svg`,role:`img`,"aria-labelledby":ie,ref:S,onClick:se,children:[le&&(0,G.jsx)(`title`,{id:ie,children:le}),(0,G.jsx)(CY,{onClick:ce,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:a,nodeClassName:i,nodeStrokeWidth:o,nodeComponent:s}),(0,G.jsx)(`path`,{className:`react-flow__minimap-mask`,d:`M${te-L},${ne-L}h${re+L*2}v${R+L*2}h${-re-L*2}z
|
|
96
|
-
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}jY.displayName=`MiniMap`,(0,U.memo)(jY);var MY=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,NY={[bG.Line]:`right`,[bG.Handle]:`bottom-right`};function PY({nodeId:e,position:t,variant:n=bG.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 v=fq(),y=typeof e==`string`?e:v,b=YG(),x=(0,U.useRef)(null),S=n===bG.Handle,C=JG((0,U.useCallback)(MY(S&&p),[S,p]),WG),w=(0,U.useRef)(null),T=t??NY[n];return(0,U.useEffect)(()=>{if(!(!x.current||!y))return w.current||=jG({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.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}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);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=RW([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...UU({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:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,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:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,G.jsx)(`div`,{className:cL([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,U.memo)(PY);function FY(e){return e.graph??void 0}function IY(e){return{run:e.run_node_sets??[],nodes:new Map(e.plan.tasks.map(e=>[e.id,e.sets??[]]))}}function LY(e){let t=FY(e);if(!t)return[];let n=new Map(e.run.nodes.map(e=>[e.node,e]));return t.plan.tasks.flatMap(r=>{let i=KY(r,`kind`)===`human`?`human`:qY(r)?`lifecycle`:`agent`,a=t.node_results[r.id]??t.result?.results?.[r.id],o=t.node_status[r.id];return o===void 0?[]:[{id:r.id,label:KY(r,`name`)??r.id,status:o,kind:i,task:r,telemetry:n.get(r.id),result:a,detail:e.node_details[r.id],control:t.node_control[r.id],failure:n.get(r.id)?.failure,blockers:[...t.node_gated_by[r.id]??[],...a?.blocked_by??[]]}]})}function RY(e){switch(e?.launcher){case`claude-code`:return`Claude`;case`codex`:return`Codex`;default:return`Unattributed`}}function zY(e){let t=RY(e);return e?.session_key===void 0?e===void 0?`Unattributed`:`${t} launch · ${JY(e.launch_id)}`:`${t} session · ${JY(e.session_key)}`}function BY(e){if(e.blockers.length>0&&HY.has(e.status))return`blocked by ${e.blockers.join(`, `)}`;if(UY.has(e.status))return VY(e)??`${e.status}, with no reason recorded`}function VY(e){return(e.failure?.detail||e.result?.detail||e.result?.error||e.telemetry?.outcome||e.result?.outcome)?.trim()||void 0}var HY=new Set([`blocked`,`skipped`,`waiting`]),UY=new Set([`failed`,`not-completed`,`cancelled`]);function WY(e){let t=$I,n=t=>(e[t]??0)>0;return[...t.filter(n),...Object.keys(e).filter(e=>!t.includes(e)).sort().filter(n)].map(t=>`${e[t]} ${t}`).join(` · `)}function GY(e){return UY.has(e)||e===`blocked`||e===`skipped`}function KY(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function qY(e){return`repo`in e||`steps`in e}function JY(e){return e.length>12?`${e.slice(0,8)}…`:e}function YY({data:e}){let t=e.style===`success`?St:e.style===`danger`||e.style===`muted`?pn:e.style===`active`?Dt:At;return(0,G.jsxs)(`article`,{"aria-label":`${e.label}: ${e.state}`,className:H(`dag-node`,`state-${e.state}`,`token-${e.style}`),"data-selected":e.selected,children:[(0,G.jsx)(bq,{type:`target`,position:$.Left}),(0,G.jsxs)(`div`,{className:`node-heading`,children:[(0,G.jsx)(Fa,{className:`px-1.5 py-0 text-[9px] tracking-[.1em] uppercase`,variant:`outline`,children:e.kind}),(0,G.jsx)(t,{className:H(e.style===`active`&&`spin`),size:17})]}),(0,G.jsx)(`strong`,{children:e.label}),(0,G.jsx)(`span`,{className:`node-status`,children:e.state}),e.reason!==void 0&&(0,G.jsx)(`span`,{className:`node-reason`,title:e.reason,children:e.reason}),(0,G.jsx)(bq,{type:`source`,position:$.Right})]})}function XY({data:e,id:t,markerEnd:n,style:r}){return(0,G.jsx)(eJ,{id:t,path:ZY(e?.points??[]),markerEnd:n,style:r})}function ZY(e){let[t,...n]=e;return t?`M ${t.x} ${t.y} ${n.map(e=>`L ${e.x} ${e.y}`).join(` `)}`:``}var QY={dagNode:YY},$Y={routed:XY};function eX({nodes:e,selectedNodeId:t,onSelectNode:n}){let r=(0,U.useMemo)(()=>{let t=new Map;for(let n of e)GY(n.status)&&t.set(n.id,BY(n));return t},[e]),{nodes:i,edges:a}=(0,U.useMemo)(()=>{let n=new Set(e.map(e=>e.id)),i=sL({nodes:e.map(e=>({id:e.id,label:e.label,kind:e.kind,state:e.status})),edges:e.flatMap(e=>(e.task.deps??[]).filter(e=>n.has(e)).map(t=>({id:`${t}->${e.id}`,source:t,target:e.id})))});return{nodes:i.nodes.map(e=>({id:e.id,type:`dagNode`,position:{x:e.x,y:e.y},data:{label:e.label,kind:e.kind,state:e.state,style:e.style,selected:e.id===t,...r.get(e.id)===void 0?{}:{reason:r.get(e.id)}},style:{width:e.width,height:e.height}})),edges:i.edges.map(t=>({id:t.id,source:t.source,target:t.target,type:`routed`,data:{points:t.points},animated:e.find(({id:e})=>e===t.target)?.status===`running`}))}},[e,r,t]);return(0,G.jsxs)(`div`,{className:`graph-wrap`,children:[(0,G.jsxs)($J,{nodes:i,edges:a,colorMode:`dark`,nodeTypes:QY,edgeTypes:$Y,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,fitView:!0,minZoom:.05,onNodeClick:(e,t)=>n(t.id),"aria-label":`DAG execution graph`,children:[(0,G.jsx)(oY,{color:`var(--border)`,gap:22}),(0,G.jsx)(hY,{showInteractive:!1})]}),(0,G.jsx)(`ol`,{className:`accessible-node-list`,"aria-label":`DAG nodes`,children:e.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),children:[e.label,`: `,e.status,r.get(e.id)===void 0?``:` — ${r.get(e.id)}`]})},e.id))})]})}function tX({className:e,state:t}){let n=nX(t);return(0,G.jsxs)(Fa,{className:H(`gap-1.5 tracking-[.03em] uppercase`,n&&iX[n],e),variant:`outline`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:H(`size-1.5 rounded-full bg-current`,t===`running`&&`animate-pulse`)}),t]})}function nX(e){return uX[e]}var rX=e=>{let t=nX(e);return H(`size-2 shrink-0 rounded-full bg-current`,t===void 0?`text-muted-foreground`:aX[t])},iX={success:`border-success bg-success-surface text-success`,destructive:`border-destructive bg-destructive-surface text-destructive`,warning:`border-warning bg-warning-surface text-warning`,info:`border-info bg-info-surface text-info`},aX={success:`text-success`,destructive:`text-destructive`,warning:`text-warning`,info:`text-info`},oX=`success`,sX=`destructive`,cX=`warning`,lX={blocked:cX,cancelled:sX,done:oX,failed:sX,"not-completed":sX,parked:void 0,pending:void 0,running:`info`,skipped:cX,unknown:void 0,waiting:void 0},uX={...lX,complete:lX.done,settled:lX.done,active:lX.running},dX={graph:`graph`,overall:`overall`,channel:`channel`,watch:`watch`,reads:`reads`,agents:`agents`};function fX(e){return e!==null&&Object.hasOwn(dX,e)}var pX={projects:`projects`,runs:`runs`};function mX(e){return e!==null&&Object.hasOwn(pX,e)}var hX=`none`,gX={decisions:{label:`Decisions`,description:`Decision points and settlements only`,profile:jA.planner},activity:{label:`Detailed activity`,description:`Every record all three producers put on the stream`,profile:jA.detailed}};function _X(e){return e!==null&&Object.hasOwn(gX,e)}var vX={timeline:`Timeline`,task:`Task`,criteria:`Acceptance criteria`,dependencies:`Dependencies`,pr:`PR`,checks:`Checks`,agents:`Agents`};function yX(e){return e!==null&&Object.hasOwn(vX,e)}function bX(e){let t=[...e].some(e=>e.charCodeAt(0)<32);return e.length>0&&e.length<=512&&!t&&!/[/?#]/u.test(e)}function xX(e,t){let n=e.get(t);return n!==null&&bX(n)?n:void 0}function SX(){let e=(0,U.useSyncExternalStore)(CX,wX,wX),t=new URLSearchParams(e),n=t.get(`list`),r=mX(n)?n:`projects`,i=t.get(`project`),a=i!==null&&(i===`none`||Xj(i))?i:void 0,o=xX(t,`run`),s=xX(t,`node`),c=xX(t,`event`),l=t.get(`view`),u=t.get(`tab`),d=t.get(`detail`),f=_X(d)?d:`activity`,p=yX(u)?u:`timeline`,m=fX(l)?l:s===void 0?`overall`:`graph`,h=(0,U.useCallback)(e=>{let t=new URLSearchParams(window.location.search);e(t),window.history.pushState(null,``,`${window.location.pathname}?${t}`),window.dispatchEvent(new PopStateEvent(`popstate`))},[]);return{list:r,projectKey:a,runId:o,nodeId:s,itemId:c,view:m,detail:f,nodeTab:p,selectList:e=>h(t=>{e===`projects`?t.delete(`list`):t.set(`list`,e),t.delete(`project`)}),selectProject:e=>h(t=>{e===void 0?t.delete(`project`):t.set(`project`,e),t.delete(`list`),t.delete(`run`),t.delete(`node`),t.delete(`event`),t.delete(`tab`)}),selectRun:e=>h(t=>{t.set(`run`,e),t.delete(`node`),t.delete(`event`),t.delete(`tab`)}),selectNode:e=>h(t=>{e?t.set(`node`,e):t.delete(`node`),t.delete(`event`),t.delete(`tab`),t.set(`view`,`graph`)}),selectItem:e=>h(t=>{e?t.set(`event`,e):t.delete(`event`)}),showOverall:()=>h(e=>{e.set(`view`,`overall`),e.delete(`node`),e.delete(`event`),e.delete(`tab`)}),selectDetail:e=>h(t=>{e===`activity`?t.delete(`detail`):t.set(`detail`,e)}),selectNodeTab:e=>h(t=>{e===`timeline`?t.delete(`tab`):t.set(`tab`,e),e!==`timeline`&&t.delete(`event`)}),selectView:e=>h(t=>{t.set(`view`,e),t.delete(`node`),t.delete(`event`),t.delete(`tab`)})}}function CX(e){return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}function wX(){return window.location.search}var TX=`(no project)`;function EX(e){return e.project===null?TX:e.name??e.project}function DX(e){return e.project===null?e.name??void 0:e.name===null?void 0:e.project}function OX(e){return e.project??`none`}function kX(e,t){return e.find(e=>OX(e)===t)}function AX(e){let t=new Map;for(let n of e)t.set(n.state,(t.get(n.state)??0)+1);return[...t].map(([e,t])=>`${t} ${e}`).join(` · `)}function jX(e){return`${e.length} ${e.length===1?`run`:`runs`}`}function MX(e){if(e.agent_count!==void 0)return`${e.agent_count} ${e.agent_count===1?`agent`:`agents`}`}function NX({groups:e,selectedKey:t,onSelect:n}){return(0,G.jsx)(`ul`,{"aria-label":`Project rows`,className:`run-list project-rows`,children:e.map(e=>{let r=OX(e),i=t===r;return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{"aria-current":i?`page`:void 0,className:`run-link`,"data-active":i,onClick:()=>n(r),type:`button`,children:[(0,G.jsxs)(`span`,{className:`run-link-main`,children:[(0,G.jsx)(Ft,{"aria-hidden":`true`,size:13}),(0,G.jsx)(`span`,{children:EX(e)})]}),(0,G.jsx)(wt,{"aria-hidden":`true`,size:14}),DX(e)!==void 0&&(0,G.jsx)(`span`,{className:`run-link-counts`,title:DX(e),children:DX(e)}),(0,G.jsx)(`span`,{className:`run-link-counts`,children:[jX(e.runs),AX(e.runs),MX(e)].filter(Boolean).join(` · `)}),(0,G.jsx)(`span`,{className:`run-link-tag`,children:e.last_write_at===null?`never written`:(0,G.jsx)(iF,{at:nF(e.last_write_at),relative:!0})})]})},r)})})}var PX={projects:`Projects`,runs:`Runs`};function FX({list:e,onSelectList:t,projects:n,selectedProjectKey:r,onSelectProject:i,runs:a,selectedRunId:o,liveRunIds:s,onSelect:c,hasMore:l,loadingMore:u,onLoadMore:d,hostActions:f}){return(0,G.jsx)(`nav`,{"aria-label":e===`runs`?`DAG runs`:`Projects`,className:`run-nav`,onScrollCapture:e=>{let t=e.target;l&&t.scrollHeight-t.scrollTop<=t.clientHeight+80&&d()},children:(0,G.jsx)(uf,{className:`h-full`,children:(0,G.jsxs)(`div`,{className:`px-[18px] py-6 max-sm:px-2`,children:[(0,G.jsxs)(`div`,{className:`brand`,children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`brand-mark`,children:(0,G.jsx)(ht,{size:20})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`eyebrow`,children:`Local orchestration`}),(0,G.jsx)(`h1`,{children:`DAG Observatory`})]})]}),(0,G.jsx)(Cf,{className:`my-[22px]`}),f,(0,G.jsxs)(`fieldset`,{className:`detail-switch list-switch`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:`Which list`}),Object.values(pX).map(n=>(0,G.jsx)(La,{"aria-pressed":e===n,onClick:()=>t(n),size:`sm`,type:`button`,variant:e===n?`default`:`outline`,children:PX[n]},n))]}),e===`projects`?n===void 0?(0,G.jsx)(`p`,{"aria-live":`polite`,className:`run-list-status`,children:`Loading projects…`}):(0,G.jsx)(NX,{groups:n,onSelect:i,selectedKey:r}):(0,G.jsx)(`div`,{className:`run-list`,children:a.map(e=>{let t=o===e.run_id,n=s.has(e.run_id),r=WY(e.node_counts);return(0,G.jsxs)(`button`,{"aria-current":t?`page`:void 0,className:`run-link`,"data-active":t,onClick:()=>c(e.run_id),type:`button`,children:[(0,G.jsxs)(`span`,{className:`run-link-main`,children:[n?(0,G.jsxs)(hm,{children:[(0,G.jsx)(gm,{asChild:!0,children:(0,G.jsx)(`span`,{"aria-label":`Live`,className:H(`run-dot`,rX(e.state)),"data-live":`true`,role:`img`})}),(0,G.jsx)(_m,{children:`Live`})]}):(0,G.jsx)(`span`,{"aria-label":`Historical`,className:H(`run-dot`,rX(e.state)),role:`img`}),(0,G.jsx)(`span`,{children:e.run_id})]}),(0,G.jsx)(wt,{"aria-hidden":`true`,size:14}),(0,G.jsx)(`span`,{className:`run-link-counts`,title:r,children:[e.state,r].filter(Boolean).join(` · `)}),(0,G.jsxs)(`span`,{className:`run-link-tag`,children:[(0,G.jsx)(bt,{"aria-hidden":`true`,size:11}),zY(e.launch)]})]},e.run_id)})}),e===`runs`&&l&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{className:`sr-only`,onClick:()=>void d(),type:`button`,children:`Load more runs`}),(0,G.jsx)(`p`,{"aria-live":`polite`,className:`run-list-status`,children:u?`Loading more runs…`:``})]})]})})})}function IX({groups:e,error:t,onSelect:n}){return(0,G.jsx)(uf,{className:`h-full`,children:(0,G.jsxs)(`section`,{"aria-labelledby":`projects-heading`,className:`projects-landing`,children:[(0,G.jsx)(`h2`,{id:`projects-heading`,children:`Projects`}),(0,G.jsx)(`p`,{className:`projects-lede`,children:`Every project with a run under this root, newest activity first.`}),t&&(0,G.jsx)(zX,{error:t,what:`The project list`}),e===void 0?(0,G.jsxs)(`div`,{"aria-live":`polite`,className:`loading-state`,children:[(0,G.jsx)(wf,{className:`h-2 w-48`}),(0,G.jsx)(wf,{className:`h-2 w-32`}),`Loading projects…`]}):e.length===0?(0,G.jsxs)(`div`,{className:`empty-state`,children:[(0,G.jsx)(Ft,{size:34}),(0,G.jsx)(`h2`,{children:`No DAG runs found`}),(0,G.jsx)(`p`,{children:`Start an orchestrated run to see its project appear here.`})]}):(0,G.jsx)(`ul`,{"aria-label":`Projects`,className:`project-cards`,children:e.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(Ra,{className:`project-card`,children:(0,G.jsxs)(za,{children:[(0,G.jsxs)(`button`,{className:`project-card-open`,onClick:()=>n(OX(e)),type:`button`,children:[(0,G.jsx)(`span`,{className:`project-card-name`,children:EX(e)}),(0,G.jsx)(wt,{"aria-hidden":`true`,size:14})]}),DX(e)!==void 0&&(0,G.jsx)(`p`,{className:`project-card-id`,children:DX(e)}),(0,G.jsxs)(`p`,{className:`project-card-facts`,children:[jX(e.runs),e.runs.length>0&&` · ${AX(e.runs)}`,MX(e)!==void 0&&` · ${MX(e)}`]}),(0,G.jsx)(`p`,{className:`project-card-facts`,children:e.last_write_at===null?`never written`:(0,G.jsxs)(G.Fragment,{children:[`Last activity`,` `,(0,G.jsx)(iF,{at:nF(e.last_write_at),relative:!0})]})})]})})},OX(e)))})]})})}function LX({projectKey:e,group:t,error:n,loading:r,agents:i,onSelectRun:a}){return(0,G.jsx)(uf,{className:`h-full`,children:(0,G.jsxs)(`section`,{"aria-labelledby":`project-heading`,className:`projects-landing`,children:[(0,G.jsx)(`p`,{className:`eyebrow`,children:`Project`}),(0,G.jsx)(`h2`,{id:`project-heading`,children:t===void 0?e:EX(t)}),t!==void 0&&DX(t)!==void 0&&(0,G.jsx)(`p`,{className:`project-card-id`,children:DX(t)}),t&&(0,G.jsxs)(`p`,{className:`projects-lede`,children:[jX(t.runs),t.runs.length>0&&` · ${AX(t.runs)}`,MX(t)!==void 0&&` · ${MX(t)}`,t.last_write_at!==null&&(0,G.jsxs)(G.Fragment,{children:[` · last activity `,(0,G.jsx)(iF,{at:nF(t.last_write_at),relative:!0})]})]}),n&&(0,G.jsx)(zX,{error:n,what:`This project`}),r?(0,G.jsxs)(`div`,{"aria-live":`polite`,className:`loading-state`,children:[(0,G.jsx)(wf,{className:`h-2 w-48`}),(0,G.jsx)(wf,{className:`h-2 w-32`}),`Loading project…`]}):t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`ul`,{"aria-label":`Runs of ${EX(t)}`,className:`project-runs`,children:t.runs.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(RX,{onSelect:a,run:e})},e.run_id))}),i]}):null]})})}function RX({run:e,onSelect:t}){let n=WY(e.node_counts);return(0,G.jsxs)(`button`,{"aria-label":`Open ${e.run_id}`,className:`project-run`,onClick:()=>t(e.run_id),type:`button`,children:[(0,G.jsx)(`span`,{className:`project-run-id`,children:e.run_id}),(0,G.jsxs)(`span`,{className:`project-run-facts`,children:[(0,G.jsx)(tX,{state:e.state}),e.liveness!==void 0&&(0,G.jsx)(Fa,{variant:`outline`,children:e.liveness}),e.unread_surfaces!==void 0&&e.unread_surfaces>0&&(0,G.jsxs)(Fa,{variant:`secondary`,children:[e.unread_surfaces,` unread`,` `,e.unread_surfaces===1?`surface`:`surfaces`]})]}),(0,G.jsxs)(`span`,{className:`project-run-facts project-run-detail`,children:[n&&(0,G.jsx)(`span`,{children:n}),(0,G.jsx)(`span`,{children:e.last_progress_at===void 0?`never written`:(0,G.jsxs)(G.Fragment,{children:[`Last write`,` `,(0,G.jsx)(iF,{at:nF(e.last_progress_at*1e3),relative:!0})]})})]})]})}function zX({error:e,what:t}){return(0,G.jsxs)(ua,{className:`mb-4`,variant:`destructive`,children:[(0,G.jsx)(cn,{}),(0,G.jsxs)(da,{children:[t,` could not be read`]}),(0,G.jsx)(fa,{children:e.message})]})}function BX(e,t,n){let{value:r,error:i}=ZM(n?`projects`:void 0,()=>e.listProjects(),t);return{list:r,error:i}}function VX(e,t,n){let{value:r,error:i,loading:a}=ZM(t,()=>t===`none`?e.listProjects().then(e=>{let t=kX(e.projects,hX);if(t===void 0)throw Error(`no runs without a project`);return t}):e.getProject(t??``),n);return{group:r,error:i,loading:a}}function HX(e,t,n,r,i=!0){let[a,o]=(0,U.useState)(),[s,c]=(0,U.useState)(),[l,u]=(0,U.useState)(!0),[d,f]=(0,U.useState)(),[p,m]=(0,U.useState)([]),[h,g]=(0,U.useState)(),[_,v]=(0,U.useState)(),[y,b]=(0,U.useState)(0),[x,S]=(0,U.useState)(!1),C=a===void 0?void 0:a.runs.some(({run_id:e})=>e===t)?t:t!==void 0||i?a.runs.at(0)?.run_id:void 0,[w,T]=(0,U.useState)(0),E=n===void 0?void 0:n.nodeId??`run`,D=(0,U.useRef)(C);(0,U.useEffect)(()=>{D.current=C},[C]);let O=(0,U.useRef)(void 0),k=(0,U.useRef)(void 0),A=(0,U.useRef)(!1),j=(0,U.useCallback)(()=>{g(void 0),v(void 0)},[]),M=(0,U.useCallback)(async()=>{o(await e.listRuns(!0))},[e]),N=(0,U.useRef)(void 0),P=(0,U.useCallback)(async()=>{let t=a?.next_cursor;if(!(t===void 0||N.current===t)){N.current=t,S(!0);try{let n=await e.listRuns(!0,t);o(e=>e===void 0?n:{...n,runs:[...e.runs,...n.runs.filter(({run_id:t})=>!e.runs.some(e=>e.run_id===t))]}),j()}catch(e){g(KX(e))}finally{N.current=void 0,S(!1)}}},[e,a,j]),ee=(0,U.useCallback)(async t=>{let n=await e.selectRuns([t]);o(e=>{if(e===void 0)return e;if(n.missing?.includes(t)===!0)return{...e,runs:e.runs.filter(e=>e.run_id!==t)};let r=n.runs.find(e=>e.run_id===t);return r===void 0?e:{...e,runs:e.runs.some(e=>e.run_id===t)?e.runs.map(e=>e.run_id===t?r:e):[r,...e.runs]}})},[e]),F=(0,U.useCallback)(async()=>{try{await M(),j()}catch(e){g(KX(e))}finally{u(!1)}},[M,j]),I=(0,U.useCallback)(async()=>{await F(),b(e=>e+1)},[F]);(0,U.useEffect)(()=>{if(C===void 0){c(void 0),k.current=void 0;return}let t=e=>e.runId===C&&e.timelineScope===E&&e.filter===r,i=WX(C,E,r);O.current=i,c(e=>{if(e!==void 0&&t(e))return e;let n=e?.runId===C&&e.filter===r&&e.detail!==void 0?e.detail:void 0;return{runId:C,filter:r,timelineScope:E,...n===void 0?{}:{detail:n}}});let a=e=>{c(n=>n!==void 0&&t(n)?e(n):n)},o=e=>{O.current===i&&e()},s=k.current;if(s?.key===i){s.again=!0;return}let l=()=>{k.current={key:i,again:!1};let t=()=>{let e=k.current;if(e?.key===i){if(e.again){l();return}k.current=void 0}},s=e.getRun(C,{includeConversations:!1,filter:r}).then(e=>{a(t=>({...t,detail:e})),o(j)}).catch(UX).catch(e=>{o(()=>g(KX(e)))}),c=n===void 0?Promise.resolve():e.getTimeline(C,n.nodeId,r).then(e=>a(t=>({...t,timeline:e,timelineError:void 0}))).catch(UX).catch(e=>a(t=>({...t,timelineError:KX(e)})));Promise.all([s,c]).then(t,t)};l()},[e,C,y,n?.nodeId,E,r]),(0,U.useEffect)(()=>{F();let t=e.subscribe({onEvent:e=>{if(f(new Date().toISOString()),v(void 0),e.event===`snapshot`){o(HM(e.data)),A.current&&(b(e=>e+1),T(e=>e+1)),A.current=!0;return}let t=GX(e);t!==void 0&&(T(e=>e+1),ee(t).catch(e=>g(KX(e))),t===D.current&&b(e=>e+1))},onError:e=>{v(KX(e))}});return()=>t.close()},[e,ee,F]),(0,U.useEffect)(()=>{if(C===void 0){m([]);return}let t=e.subscribe({runId:C,filter:r,onEvent:e=>{if(f(new Date().toISOString()),v(void 0),e.event!==`snapshot`){if(e.event===`activity.changed`){let t=e.data.activity;m(Yj.parse(t))}(e.event===`conversation.changed`||e.event===`activity.changed`||e.event===`run.changed`)&&b(e=>e+1)}},onError:e=>v(KX(e))});return()=>t.close()},[e,C,r]);let L=s!==void 0&&s.runId===C&&s.filter===r?s:void 0;return(0,U.useMemo)(()=>({list:a,runId:C,detail:L?.detail,timeline:L?.timeline,timelineError:L?.timelineError,loading:l,lastUpdated:d,activity:p,error:h??_,refresh:I,loadMore:P,hasMore:a?.next_cursor!==void 0,loadingMore:x,invalidations:w}),[a,C,L,l,d,p,h,_,I,P,x,w])}function UX(e){if(!(e instanceof UM&&e.code===`run_not_found`))throw e}function WX(e,t,n){return[e,t??``,n??``].join(`\0`)}function GX(e){let t=`run_id`in e.data?e.data.run_id:void 0;return typeof t==`string`&&t.length>0?t:void 0}function KX(e){return e instanceof Error?e:typeof Event<`u`&&e instanceof Event?Error(`Live telemetry stream disconnected`):Error(String(e))}var qX={minutes:60,seconds:1},JX=e=>Object.hasOwn(qX,e),YX=600%qX.minutes==0?{amount:String(600/qX.minutes),unit:`minutes`}:{amount:`600`,unit:`seconds`};function XX(e){let t=e.amount.trim();if(!/^\d+$/u.test(t))return;let n=Number(t)*qX[e.unit];return Number.isSafeInteger(n)?n:void 0}function ZX(e){if(e===0)return`no grace`;let t=Math.floor(e/60),n=e%60,r=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return t===0?r(n,`second`):n===0?r(t,`minute`):`${r(t,`minute`)} ${r(n,`second`)}`}function QX(e,t){let n=e?.session_key;return t!==null&&n!==void 0&&n===t}function $X(e,t,n){let r=QX(t,n);return{runId:e,owner:r?`this session (${zY(t)})`:zY(t),mine:r,unowned:t?.session_key===void 0}}function eZ(e,t,n){let r=t.map(e=>$X(e.run_id,e.launch,n));return e===`mine`?r.filter(e=>e.mine):r}function tZ(e,t){return t instanceof UM&&t.status!==void 0&&t.code!==void 0?{phase:`refused`,sent:e,error:t}:{phase:`lost`,sent:e,error:t instanceof Error?t:Error(String(t))}}var nZ={dispatchStopped:`dispatch-stopped`,hostShutdown:`host-shutdown`};function rZ(e,t,n){let r=new Set(e.runs.map(({runId:e})=>e)),i=Object.values(nZ);return n.flatMap(e=>{if(!r.has(e.run_id))return[];let n=e.last_event;if(n===null||!i.includes(n))return[];let a=t.get(e.run_id);return a!==void 0&&a.last_event===n&&a.last_progress_at===e.last_progress_at?[]:[{runId:e.run_id,recorded:n===nZ.hostShutdown?nZ.hostShutdown:nZ.dispatchStopped}]})}function iZ(e){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).format(e)}var aZ={run:`Shut down this run?`,mine:`Shut down all my runs?`,host:`Shut down the entire host?`},oZ=`Each live dispatch is asked to stop and commit, and given the grace to end itself; whatever is still standing then is torn down, and every branch the run's records name is pushed to its origin. Nothing is sent until you confirm.`;function sZ({scope:e,open:t,onOpenChange:n,runs:r,blocked:i,runId:a,unreadable:o=0,onConfirm:s}){let c=(0,U.useId)(),[l,u]=(0,U.useState)(YX),[d,f]=(0,U.useState)(!1),p=XX(l),m=r!==void 0&&i===void 0,h=r?.filter(e=>!e.mine)??[],g=r?.filter(e=>e.mine)??[],_=h.filter(e=>e.unowned).length,v=()=>{u(YX),f(!1),n(!1)};return(0,G.jsx)(yc,{onOpenChange:e=>e?n(!0):v(),open:t,children:(0,G.jsxs)(Cc,{className:`shutdown-dialog`,children:[(0,G.jsxs)(wc,{children:[(0,G.jsx)(Ec,{children:e===`run`&&a!==void 0?`Shut down ${a}?`:aZ[e]}),(0,G.jsx)(Dc,{children:oZ})]}),(0,G.jsxs)(`div`,{className:`shutdown-dialog-body`,children:[i===void 0?r===void 0?(0,G.jsx)(`p`,{className:`shutdown-blocked`,role:`status`,children:`Reading which runs this acts on…`}):e===`run`?(0,G.jsx)(lZ,{run:r[0]}):e===`mine`?r.length===0?(0,G.jsx)(`p`,{className:`shutdown-scope-note`,children:`This session owns no run here, so this acts on none: nothing will be signalled and nothing pushed.`}):(0,G.jsx)(uZ,{caption:`It acts on the ${cZ(r.length)} this session owns, and on no other session's:`,label:`Runs this shutdown acts on`,runs:r}):(0,G.jsxs)(G.Fragment,{children:[h.length>0?(0,G.jsx)(uZ,{caption:`It acts on ${cZ(h.length)} other sessions own${_>0?` (or that no session is recorded as owning)`:``}, over their owners — each is interrupted, torn down and pushed as if it were yours:`,label:`Runs other sessions own`,runs:h,warning:!0}):(0,G.jsx)(`p`,{className:`shutdown-scope-note`,children:`No run here is another session's.`}),g.length>0&&(0,G.jsx)(uZ,{caption:`And on the ${cZ(g.length)} this session owns:`,label:`Runs this session owns`,runs:g}),r.length===0&&(0,G.jsx)(`p`,{className:`shutdown-scope-note`,children:`This view lists no run on this host, so this acts on none.`})]}):(0,G.jsx)(`p`,{className:`shutdown-blocked`,role:`status`,children:i}),e!==`run`&&o>0&&(0,G.jsxs)(`p`,{className:`shutdown-scope-note`,children:[o===1?`1 run root on this host could not be read`:`${o} run roots on this host could not be read`,`: the engine cannot read them either, so this shutdown signals nothing in them and pushes none of their branches.`]}),(0,G.jsxs)(`fieldset`,{className:`shutdown-grace`,children:[(0,G.jsx)(`legend`,{children:`Grace`}),(0,G.jsxs)(`div`,{className:`shutdown-grace-row`,children:[(0,G.jsx)(jc,{className:`sr-only`,htmlFor:`${c}-grace`,children:`Grace`}),(0,G.jsx)(Oc,{"aria-describedby":`${c}-grace-help`,"aria-invalid":p===void 0,id:`${c}-grace`,inputMode:`numeric`,min:0,onChange:e=>u({...l,amount:e.target.value}),step:1,type:`number`,value:l.amount}),(0,G.jsx)(jc,{className:`sr-only`,htmlFor:`${c}-unit`,children:`Grace unit`}),(0,G.jsx)(`select`,{className:`composer-select`,id:`${c}-unit`,onChange:e=>{let t=e.target.value;JX(t)&&u({...l,unit:t})},value:l.unit,children:Object.keys(qX).map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsx)(`p`,{className:`channel-age`,id:`${c}-grace-help`,children:p===void 0?`The grace is a whole number of minutes or seconds, 0 or more.`:`How long each live dispatch has to end itself once asked: ${ZX(p)}. The engine's default is ${ZX(XX(YX)??0)}.`})]}),(0,G.jsxs)(`div`,{className:`composer-check shutdown-force`,children:[(0,G.jsx)(`input`,{checked:d,id:`${c}-force`,onChange:e=>f(e.target.checked),type:`checkbox`}),(0,G.jsx)(jc,{htmlFor:`${c}-force`,children:`Force: skip the interrupt and the wait and go straight to the teardown — whatever a worker had not committed is lost.`})]})]}),(0,G.jsxs)(Tc,{children:[(0,G.jsx)(xc,{asChild:!0,children:(0,G.jsx)(La,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,G.jsx)(La,{disabled:!m||p===void 0,onClick:()=>{p!==void 0&&(s(p,d),v())},type:`button`,variant:`destructive`,children:e===`run`?`Shut down run`:e===`mine`?`Shut down my runs`:`Shut down the host`})]})]})})}var cZ=e=>e===1?`1 run`:`${e} runs`;function lZ({run:e}){return e===void 0?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(uZ,{caption:`It acts on this run alone:`,label:`Runs this shutdown acts on`,runs:[e]}),!e.mine&&(0,G.jsxs)(`p`,{className:`shutdown-scope-note`,role:`note`,children:[e.runId,` is owned by `,e.owner,`, not by this session, so the engine will refuse this shutdown and signal nothing. Shutting the entire host down is what acts on another session's run.`]})]})}function uZ({caption:e,label:t,runs:n,warning:r=!1}){return(0,G.jsxs)(`div`,{className:`shutdown-runs`,"data-warning":r,children:[(0,G.jsx)(`p`,{className:`shutdown-scope-note`,children:e}),(0,G.jsx)(`ul`,{"aria-label":t,children:n.map(e=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`shutdown-run-id`,children:e.runId}),` — owned by `,e.owner]},e.runId))})]})}function dZ(e){return e.value===void 0?e.error===void 0?{blocked:`Reading which session this server acts as…`}:{blocked:`Which session this server acts as could not be read (${e.error.message}), so the runs this acts on cannot be named. Nothing can be sent until they can.`}:{acting:e.value.session_key??null}}function fZ(e,t,n,r){let[i,a]=(0,U.useState)(),[o,s]=(0,U.useState)(0),c=ZM(i===void 0?void 0:`acting-${o}`,()=>e.unwatched(),0),l=pZ(i!==void 0,t,n,r),{acting:u,blocked:d}=dZ(c);return{open:i,setOpen:a,opener:e=>()=>{s(e=>e+1),a(e)},runs:u===void 0||l.rows===void 0||i===void 0?void 0:eZ(i,l.rows,u),blocked:d??l.blocked,unreadable:t?.unreadable?.length??0}}function pZ(e,t,n,r){let i=(0,U.useRef)(new Set),a=t?.next_cursor;return(0,U.useEffect)(()=>{if(!e){i.current.clear();return}a===void 0||r||i.current.has(a)||(i.current.add(a),n())},[e,a,r,n]),t===void 0?{blocked:`Reading the runs listing this view holds…`}:a===void 0?{rows:t.runs}:!r&&i.current.has(a)?{blocked:`The rest of the runs listing could not be read (${t.runs.length} runs read), so the runs this acts on cannot all be named. Close this and try again.`}:{blocked:`Reading the rest of the runs listing so every run this acts on can be named (${t.runs.length} read so far)…`}}function mZ(e,t){let[n,r]=(0,U.useState)({phase:`idle`}),i=(0,U.useRef)(!1);return{state:n,confirm:(0,U.useCallback)((n,a,o)=>{if(i.current)return;i.current=!0;let s={scope:e,runs:n,grace:a,force:o,sentAt:Date.now()};r({phase:`sending`,sent:s}),t({grace:a,force:o}).then(e=>r({phase:`answered`,sent:s,report:e}),e=>r(tZ(s,e))).finally(()=>{i.current=!1})},[e,t]),dismiss:(0,U.useCallback)(()=>{i.current||r({phase:`idle`})},[])}}var hZ=[`mine`,`host`];function gZ({runId:e,launched:t,unwatched:n,shutdown:r}){let[i,a]=(0,U.useState)(!1),{acting:o,blocked:s}=dZ(n),c=o===void 0||t===void 0?void 0:[$X(e,t.launch,o)];return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(La,{"aria-label":`Shut down this run`,disabled:r.state.phase===`sending`,onClick:()=>a(!0),size:`sm`,title:`Shut down this run`,type:`button`,variant:`destructive`,children:[(0,G.jsx)($t,{size:14}),(0,G.jsx)(`span`,{className:`run-action-label`,children:`Shut down`})]}),(0,G.jsx)(sZ,{blocked:s??(t===void 0?`Reading who launched ${e}…`:void 0),onConfirm:(e,t)=>c!==void 0&&r.confirm(c,e,t),onOpenChange:a,open:i,runId:e,runs:c,scope:`run`})]})}function _Z(e,t){return mZ(`run`,(0,U.useCallback)(n=>t===void 0?Promise.reject(Error(`No run is open to shut down`)):e.shutdownRun(t,n),[e,t]))}function vZ(e){return{mine:mZ(`mine`,(0,U.useCallback)(t=>e.shutdown(`mine`,t),[e])),host:mZ(`host`,(0,U.useCallback)(t=>e.shutdown(`host`,t),[e]))}}function yZ({client:e,list:t,loadMore:n,loadingMore:r,shutdowns:i}){let{open:a,setOpen:o,opener:s,runs:c,blocked:l,unreadable:u}=fZ(e,t,n,r),d=i.mine.state.phase===`sending`||i.host.state.phase===`sending`;return(0,G.jsxs)(`fieldset`,{"aria-label":`Shut down runs on this host`,className:`host-shutdown`,children:[(0,G.jsx)(`p`,{className:`eyebrow`,children:`This host`}),(0,G.jsxs)(`div`,{className:`host-shutdown-actions`,children:[(0,G.jsxs)(La,{disabled:d,onClick:s(`mine`),size:`sm`,type:`button`,variant:`outline`,children:[(0,G.jsx)($t,{size:14}),` Shut down all my runs`]}),(0,G.jsxs)(La,{disabled:d,onClick:s(`host`),size:`sm`,type:`button`,variant:`destructive`,children:[(0,G.jsx)($t,{size:14}),` Shut down the entire host`]})]}),hZ.map(e=>(0,G.jsx)(sZ,{blocked:l,onConfirm:(t,n)=>c!==void 0&&i[e].confirm(c,t,n),onOpenChange:t=>o(t?e:void 0),open:a===e,runs:a===e?c:void 0,scope:e,unreadable:u},e))]})}var bZ=1e3;function xZ(e,t){let[n,r]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),bZ);return()=>clearInterval(e)},[]);let i=rZ(e,(0,U.useRef)(new Map(t.filter(t=>e.runs.some(({runId:e})=>e===t.run_id)).map(e=>[e.run_id,e]))).current,t);return{now:n,progress:i,done:i.filter(({recorded:e})=>e===nZ.hostShutdown).length,deadline:e.sentAt+e.grace*1e3,asks:!e.force&&e.grace>0}}function SZ({label:e,state:t,rows:n,onDismiss:r}){return t.phase===`idle`?null:(0,G.jsxs)(`section`,{"aria-label":e,className:`shutdown-status`,children:[t.phase===`sending`?(0,G.jsx)(wZ,{rows:n,sent:t.sent}):t.phase===`lost`?(0,G.jsxs)(ua,{"aria-label":`${e} lost`,variant:`destructive`,children:[(0,G.jsx)(ln,{}),(0,G.jsx)(da,{children:`Shutdown lost: no answer came back`}),(0,G.jsxs)(fa,{children:[(0,G.jsxs)(`p`,{children:[`The request sent at `,iZ(t.sent.sentAt),` ended without an answer (`,t.error.message,`). The engine may still be carrying out the shutdown — check the runs before sending another.`]}),(0,G.jsx)(CZ,{sent:t.sent})]})]}):t.phase===`refused`?(0,G.jsxs)(ua,{"aria-label":`${e} refused`,variant:`destructive`,children:[(0,G.jsx)(cn,{}),(0,G.jsxs)(da,{children:[`Shutdown refused · `,t.error.status,` `,t.error.code]}),(0,G.jsxs)(fa,{children:[(0,G.jsx)(`pre`,{className:`verb-text`,children:t.error.message}),(0,G.jsx)(`p`,{children:`Nothing was signalled and nothing was pushed.`})]})]}):(0,G.jsx)(EZ,{label:e,report:t.report}),t.phase!==`sending`&&(0,G.jsx)(`div`,{className:`composer-actions`,children:(0,G.jsx)(La,{onClick:r,size:`sm`,type:`button`,variant:`outline`,children:`Dismiss`})})]})}function CZ({sent:e}){return(0,G.jsxs)(`p`,{className:`channel-age`,children:[`Sent `,iZ(e.sentAt),` · scope `,e.scope,` · grace`,` `,ZX(e.grace),e.force?` · forced`:``,` · `,e.runs.length,` `,e.runs.length===1?`run`:`runs`,` in scope`]})}function wZ({sent:e,rows:t}){let{now:n,progress:r,done:i,deadline:a,asks:o}=xZ(e,t);return(0,G.jsxs)(`div`,{"aria-live":`polite`,className:`shutdown-inflight`,role:`status`,children:[(0,G.jsxs)(`p`,{className:`shutdown-inflight-head`,children:[(0,G.jsx)(Ut,{"aria-hidden":`true`,className:`animate-spin`,size:14}),(0,G.jsx)(`strong`,{children:`Shutdown in progress`}),` — still waiting for the engine's answer, `,ZP(Math.max(0,n-e.sentAt)),` after it was sent.`]}),(0,G.jsx)(CZ,{sent:e}),(0,G.jsx)(`p`,{children:o?n<a?`Waiting out the ${ZX(e.grace)} grace until ${iZ(a)} (${ZP(a-n)} left) for each live dispatch to end itself; runs are worked through one after another, each with its own grace.`:`The first grace ran out at ${iZ(a)}; the engine is tearing down what is still standing and pushing branches, run by run.`:`Forced: nothing is asked or waited for; the engine is tearing the runs down and pushing their branches.`}),(0,G.jsxs)(`p`,{children:[i,` of `,e.runs.length,` `,e.runs.length===1?`run has`:`runs have`,` recorded their shutdown.`]}),r.length>0&&(0,G.jsx)(`ul`,{"aria-label":`Recorded so far`,children:r.map(({runId:e,recorded:t})=>(0,G.jsxs)(`li`,{children:[e,`:`,` `,t===nZ.hostShutdown?`put down — host-shutdown recorded after its teardown and pushes`:`its dispatches are stopping — dispatch-stopped recorded`]},e))})]})}function TZ(e){let t=e.remote===null?``:` to ${e.remote}`,n=e.commit===null?``:` at ${e.commit}`;switch(e.result){case`pushed`:return`pushed${t}${n}`;case`already-on-origin`:return`already on its origin${t}${n}; nothing was pushed`;case`no-remote`:return`not pushed: this identity has no origin${n}`;case`refused`:return`could not be preserved${n}`}}function EZ({label:e,report:t}){return(0,G.jsxs)(ua,{"aria-label":`${e} report`,variant:t.complete?`default`:`destructive`,children:[t.complete?(0,G.jsx)(Et,{}):(0,G.jsx)(cn,{}),(0,G.jsx)(da,{children:t.complete?`Shutdown complete`:`Shutdown incomplete`}),(0,G.jsxs)(fa,{className:`shutdown-report`,children:[!t.complete&&(0,G.jsx)(`p`,{children:`Not everything went as asked: a dispatch was killed at the deadline or is still running, a teardown was not clean, or a branch could not be preserved. Read the runs below.`}),(0,G.jsxs)(`p`,{className:`channel-age`,children:[`Scope `,t.scope,` · grace `,ZX(t.grace_seconds),t.forced?` · forced`:``,` · runs root `,t.root]}),t.runs.length===0?(0,G.jsx)(`p`,{children:`No run was selected: nothing was signalled.`}):t.runs.map(e=>(0,G.jsxs)(`section`,{"aria-label":`Shutdown of ${e.run_id}`,className:`shutdown-report-run`,children:[(0,G.jsxs)(`h4`,{children:[e.run_id,` · owner `,e.owner,e.forced_over_owner&&` — another session's run, acted on over its owner`]}),e.dispatches.length===0?(0,G.jsx)(`p`,{children:`No live dispatch to interrupt.`}):(0,G.jsx)(`ul`,{"aria-label":`Dispatches of ${e.run_id}`,children:e.dispatches.map(e=>(0,G.jsxs)(`li`,{children:[e.node,` (pid `,e.pid,`): interrupt`,` `,e.interrupt,`; ended `,e.ended,` after`,` `,ZP(e.waited_ms),(0,G.jsxs)(`span`,{className:`channel-age`,children:[` — `,e.detail]})]},`${e.node}-${e.pid}`))}),(0,G.jsxs)(`p`,{children:[`Teardown: `,e.teardown]}),e.branches.length===0?(0,G.jsx)(`p`,{children:`No branch this run's records name.`}):(0,G.jsx)(`ul`,{"aria-label":`Branches of ${e.run_id}`,children:e.branches.map(e=>(0,G.jsxs)(`li`,{children:[e.identity,`@`,e.branch,`: `,TZ(e),(0,G.jsxs)(`span`,{className:`channel-age`,children:[` — `,e.detail]})]},`${e.identity}@${e.branch}`))})]},e.run_id)),t.not_pushed_unread===null?t.not_pushed.length===0?(0,G.jsx)(`p`,{children:`Other unpublished branches on this host: none.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{children:[`Other unpublished branches on this host, which this shutdown did not push (`,t.not_pushed.length,`):`]}),(0,G.jsx)(`ul`,{"aria-label":`Branches not pushed`,children:t.not_pushed.map(({identity:e,branch:t})=>(0,G.jsxs)(`li`,{children:[e,`@`,t]},`${e}@${t}`))})]}):(0,G.jsxs)(`p`,{children:[`Other unpublished branches on this host: not read —`,` `,t.not_pushed_unread,`. This is not a count of zero: there may be work on this host nothing outside it carries.`]}),(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{children:`The engine's own report`}),(0,G.jsx)(`pre`,{className:`verb-text`,children:t.rendered})]})]})]})}function DZ({control:e}){if(e===void 0)return null;let t=e.addressable?`Turn reachable`:`No turn to reach`,n=e.addressable?`a planner's note can be delivered into the ${e.member??`member`} turn in flight`:e.reason,r=e.addressable?qt:Gt;return(0,G.jsxs)(Fa,{"aria-label":`${t}: ${n}`,className:H(`node-view-control gap-1.5`,e.addressable?`border-info bg-info-surface text-info`:`border-warning bg-warning-surface text-warning`),title:n,variant:`outline`,children:[(0,G.jsx)(r,{"aria-hidden":`true`,size:12}),t]})}function OZ(e){return e.charAt(0).toUpperCase()+e.slice(1)}var kZ=[[`recovery`,[`retry`,`retried`,`requeued`,`fallback`,`resolution`,`interrupted`,`cron`]],[`failure`,[`failed`,`died`,`rejected`,`exceeded`,`conflict`]],[`human`,[`human`]],[`planning`,[`planner`,`decision`,`note`]],[`contention`,[`lock`,`concurrent`,`quiet`,`wait`,`held`,`unheld`]],[`verification`,[`verification`,`gate`,`check`,`checks`,`coverage`,`judge`]],[`publication`,[`pr`,`publication`,`published`,`release`,`merge`,`merged`,`change`,`drafting`]],[`repository`,[`edit`,`fetch`,`push`,`branch`,`commit`]],[`session`,[`turn`,`member`,`session`,`heartbeat`,`conversation`]],[`lifecycle`,[`run`,`graph`,`node`,`round`,`step`,`edge`,`setup`,`cleanup`,`driver`,`cross`,`upstream`]]],AZ={"completion-requested":`lifecycle`,"command-accepted":`planning`,"body-not-drafted":`publication`,"criterion-checked":`verification`,"pool-maintenance":`lifecycle`,"dispatch-stopped":`lifecycle`,"host-shutdown":`lifecycle`};function jZ(e){return e.toLowerCase().split(`-`).filter(e=>e.length>0)}function MZ(e){let t=AZ[e];if(t!==void 0)return t;let n=jZ(e);return kZ.find(([,e])=>e.some(e=>n.includes(e)))?.[0]??`activity`}var NZ={recovery:tn,failure:cn,human:un,planning:kt,contention:Rt,verification:on,publication:Lt,repository:It,session:Jt,lifecycle:Yt,activity:Ot};function PZ({category:e,className:t=`size-3`}){let n=NZ[e];return(0,G.jsx)(n,{"aria-hidden":`true`,className:t})}function FZ(e){return e===`human-step`?`human step`:e}function IZ(e){return e.style===`human-step`}function LZ(e){switch(e){case`not-released`:return`not released yet`;case`awaiting-human-step`:return`waiting for the human step`;case`not-answered`:return`the registry did not answer`;case`not-landed`:return`released, but not carrying this work yet`;default:return e}}function RZ(e){if(e!==void 0)return e?`yes — a later acknowledgement replaced this one`:`no`}function zZ(e){if(e!==void 0)return e===`live`?`Live — into the turn that was already running`:e===`deferred`?`Deferred — onto the node's next dispatch`:e}function BZ(e){return[e.identity,e.target].filter(Boolean).join(` · `)||e.dep}function VZ({release:e}){let t=[[`Dependency`,e.dep],[`Identity`,e.identity],[`Release target`,e.target],[`Style`,e.style===void 0?void 0:FZ(e.style)],[`Version`,e.version],[`Probe outcome`,e.outcome],[`Probed through`,e.form],[`Probe took`,e.elapsed_ms===void 0?void 0:`${e.elapsed_ms} ms`],[`Acknowledged by`,e.actor],[`Superseded`,RZ(e.superseded)],[`Landed as`,e.landing_commit],[`Adopted`,zZ(e.delivery)]].filter(([,e])=>e!==void 0);return(0,G.jsxs)(G.Fragment,{children:[t.length>0&&(0,G.jsx)(`dl`,{className:`facts`,children:t.map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:e}),(0,G.jsx)(`dd`,{children:t})]},e))}),e.awaiting!==void 0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Held on`}),(0,G.jsx)(`ul`,{className:`release-awaiting`,children:e.awaiting.map(e=>(0,G.jsxs)(`li`,{children:[IZ(e)?(0,G.jsxs)(ua,{children:[(0,G.jsx)(un,{}),(0,G.jsxs)(da,{children:[`Waiting on a person · `,BZ(e)]}),(0,G.jsx)(fa,{children:e.action??`The release is a human step and the run recorded no action for it.`})]}):(0,G.jsxs)(`p`,{className:`detail-note`,children:[`Waiting on an automated release · `,BZ(e)]}),(0,G.jsx)(`p`,{className:`detail-note`,children:[e.last_answer===void 0?void 0:LZ(e.last_answer),e.waited_seconds===void 0?void 0:`waited ${e.waited_seconds}s`].filter(e=>e!==void 0).join(` · `)})]},`${e.dep}·${e.identity??``}·${e.target??``}`))})]}),e.versions!==void 0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Versions adopted`}),(0,G.jsx)(`ul`,{className:`release-awaiting`,children:e.versions.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`p`,{className:`detail-note`,children:[e.identity,` · `,e.target,` · `,e.version]})},`${e.identity}·${e.target}`))})]})]})}function HZ({node:e}){let t=e.result?.release??void 0;if(t===void 0)return(0,G.jsx)(G.Fragment,{children:`Not recorded`});let n=t.identity!==e.task.repo;return(0,G.jsx)(G.Fragment,{children:[t.target,t.style===void 0?void 0:FZ(t.style),t.version,n?t.identity:void 0].filter(e=>e!==void 0).join(` · `)})}function UZ(e){return{kind:e.displayKind,label:e.displayLabel,startedAt:e.startedAt,...e.durationMs===null?{}:{duration:ZP(e.durationMs)},running:e.endedAt===null&&e.rowKind===`span`,...e.status?{status:e.status}:{}}}function WZ({row:e}){let t=UZ(e);return(0,G.jsxs)(`header`,{className:`detail-title`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Fa,{className:`mb-1`,variant:`outline`,children:t.kind}),(0,G.jsx)(`h2`,{children:t.label}),(0,G.jsxs)(`p`,{className:`detail-when`,children:[(0,G.jsx)(iF,{at:t.startedAt}),t.duration!==void 0&&` · ${t.duration}`,t.running&&` · still running`]})]}),t.status!==void 0&&(0,G.jsx)(Fa,{variant:`secondary`,children:t.status})]})}function GZ(e){let t=UZ(e);return[t.kind,t.label,eF(t.startedAt),OZ(e.category),t.status].filter(e=>e!==void 0&&e.length>0).join(` · `)}function KZ({row:e}){return(0,G.jsx)(`span`,{className:`timeline-marker-reading`,"data-timeline-reading":GZ(e),children:(0,G.jsx)(PZ,{category:e.category})})}var qZ=`data-timeline-reading`;function JZ(e){let t=e.closest(`[${qZ}]`)??e.closest(`button`)?.querySelector(`[${qZ}]`);if(!(t instanceof HTMLElement))return;let n=t.getAttribute(qZ)?.trim();return n===void 0||n.length===0?void 0:{element:t,detail:n}}var YZ={rows:[],total:0},XZ={queued:`Queued`,dispatch:`Dispatch`,verification:`Verification`,publication:`Publication`,"lock-waits":`Lock waits`,"human-wait":`Human wait`},ZZ=`idle`,QZ=new Set([...Object.keys(XZ),ZZ]),$Z=`member:`;function eQ(e){return QZ.has(e)?`${$Z}${e}`:e}var tQ=Object.entries(XZ).map(([e,t])=>({id:e,label:t}));function nQ(e){let t=e?.spans??[],n=[];for(let e of t){let t=e.agent_role;t!==void 0&&!n.includes(t)&&n.push(t)}let r=t.some(e=>TQ(e)===`dispatch`),[i,...a]=tQ;return[...i===void 0?[]:[i],...n.map(e=>({id:eQ(e),label:e})),...a.filter(({id:e})=>r||e!==`dispatch`)]}var rQ={run:null,node:null,step:null,dispatch:`dispatch`,verification:`verification`,publication:`publication`,"pr-drafting":`dispatch`,"conflict-resolution":`publication`,"human-wait":`human-wait`,queued:`queued`,rollup:`lock-waits`};function iQ(e){return e===`agent`}function aQ(e,t){return e===void 0?t===void 0?XZ.dispatch:oQ(t):HQ(t)&&t!==e?`${e} · ${t}`:e}function oQ(e){return e===`llmlint`?`Lint`:`${e[0]?.toUpperCase()??``}${e.slice(1)}`}var sQ={"lock-wait":`Lock waits`};function cQ(e,t=tQ){let n=[...e].sort((e,t)=>e.start-t.start),r=n.at(0)?.start??0,i=Math.max(r+1,...n.map(e=>e.end??e.start)),a=new Set([n.at(0),n.reduce((e,t)=>e===void 0||(t.end??t.start)>(e.end??e.start)?t:e,void 0)].filter(e=>e!==void 0).map(({id:e})=>e)),o=(i-r)*.02,s=[];for(let e of n){let n=Math.max(e.end??e.start,e.start+o),r=s.findLast(t=>{let r=Math.max(t.end??t.start,t.start+o);return e.start<=r&&t.start<=n});r===void 0||a.has(e.id)?s.push(e):uQ(e,t)<uQ(r,t)?a.has(r.id)?s.push(e):s[s.indexOf(r)]=e:lQ(e,r,o)||s.push(e)}return s}function lQ(e,t,n){return Math.abs(e.start-t.start)<=n&&Math.abs((e.end??e.start)-(t.end??t.start))<=n}function uQ(e,t){let n=e.laneId??``,r=t.findIndex(({id:e})=>e===n);return r<0?t.length:r}function dQ(e,t,n){let r=[...e.map(({at:e})=>e),...t.flatMap(e=>[e.start,e.end??e.start])],i=Math.min(...r),a=(Math.max(...r)-i)*.02,o=[];for(let t of[...e].sort((e,t)=>e.at-t.at)){let e=o.findLast(e=>t.at-e.at<=a);e===void 0?o.push(t):t.id===n&&(o[o.indexOf(e)]=t)}return o}function fQ(e,t){let n=_Q(e,t).rows,r=hQ(n),i=hQ(n,!1).flatMap(e=>{let t=gQ(e);if(t===null)return[];let n=Date.parse(e.startedAt),r=e.endedAt===null?null:Date.parse(e.endedAt),i=e.rowKind===`span`&&e.span.total_duration_ms!==void 0?n+e.span.total_duration_ms:r;return[{id:e.id,label:e.displayLabel,laneId:t,payload:e,start:n,end:i,duration:i===null?null:i-n,status:e.status}]}),a=r.flatMap(e=>e.rowKind===`event`?[{id:e.id,label:e.displayLabel,at:Date.parse(e.startedAt),payload:e,status:e.status,icon:(0,U.createElement)(KZ,{row:e})}]:[]),o=Math.max(...i.map(e=>e.end??e.start),...a.map(e=>e.at));return{items:i.map(e=>e.end===null?{...e,end:o,duration:o-e.start}:e),markers:a,lanes:nQ(e),rows:r,tree:n}}function pQ(e,t){let n=new Set,r=[],i=e=>{for(let a of e){if(a.rowKind===`group`){let e=t.has(a.id),n=a.children,o=n.at(0),s=n.at(-1);o!==void 0&&i([o]),r.push({entryKind:`collapse`,group:a,hidden:Math.max(n.length-2,0),expanded:e}),e&&i(n.slice(1,-1)),s!==void 0&&s!==o&&i([s]);continue}n.has(a.id)||(n.add(a.id),r.push({entryKind:`row`,row:a})),i(a.children)}};return i(e),r}function mQ(e,t){return`${e} more ${t} events`}function hQ(e,t=!0){let n=new Set,r=[],i=e=>{for(let a of e)n.has(a.id)||(n.add(a.id),r.push(a)),(t||a.rowKind!==`group`)&&i(a.children)};return i(e),r}function gQ(e){return e.rowKind===`event`?null:e.role===void 0?rQ[e.rowKind===`span`?e.span.kind:e.kind]??null:eQ(e.role)}function _Q(e,t){if(e===void 0)return YZ;let n=e.spans.filter(e=>e.node_id===t);if(n.length===0){let n=WQ(e.spans,new Set,t);return n.length===0?YZ:{rows:FQ(n),total:n.length}}let r=new Set(n.map(({id:e})=>e)),i=new Map,a=[];for(let e of n){let t=e.parent_id!==void 0&&r.has(e.parent_id)?e.parent_id:void 0;t===void 0?a.push(e):i.set(t,[...i.get(t)??[],e])}let o=a.find(({kind:e})=>e===`node`),s=FQ(VQ(BQ([...o===void 0?[]:SQ(o,i),...a.filter(e=>e!==o).map(e=>CQ(e,i)),...WQ(e.spans,r,t)].sort(KQ))));return{span:o,rows:s,total:GQ(s)}}function vQ(e){return CQ(e,new Map)}function yQ(e){return PQ(e)}function bQ(e,t){return xQ(e,t).at(-1)}function xQ(e,t){for(let n of e){if(n.id===t)return[n];let e=xQ(n.children,t);if(e.length>0)return[n,...e]}return[]}function SQ(e,t){return[...(t.get(e.id)??[]).map(e=>CQ(e,t)),...e.events.map(PQ)].sort(KQ)}function CQ(e,t){let n=wQ(e),r=e.kind===`dispatch`?e.transport_role:void 0;return{rowKind:`span`,span:e,id:e.id,kind:e.kind,...n===void 0?{}:{role:n},...r===void 0?{}:{transport:r},label:e.label,startedAt:e.started_at,endedAt:e.ended_at,status:e.status,durationMs:e.total_duration_ms??qQ(e.started_at,e.ended_at),children:FQ(SQ(e,t)),displayLabel:zQ(e,n,r),displayKind:IQ(e,n,r),...e.kind===`dispatch`&&e.label?{sessionName:e.label}:{}}}function wQ(e){return e.kind===`dispatch`?e.agent_role:void 0}function TQ(e){return e.agent_role===void 0?rQ[e.kind===`rollup`?e.label:e.kind]??null:eQ(e.agent_role)}function EQ(e,t=[]){let n=t.find(({id:t})=>t===e);return n===void 0?XZ[e]??(e.startsWith($Z)?e.slice(7):e):n.label}function DQ(e){if(e.redirection!==void 0)return e.redirection.delivered?`Redirected into the running turn`:`Redirection deferred to the next dispatch`}var OQ=`Redirection`;function kQ(e){if(e.surface===void 0)return;let t=[e.surface.kind,e.surface.message].filter(e=>e!==void 0);return t.length===0?void 0:t.join(`: `)}var AQ=`Surface`,jQ=`Blocking surface`;function MQ(e){return e.kind.startsWith(`edit-`)?e.author:void 0}function NQ(e,t){let n=MQ(t);return n===void 0?e:`${e} · by ${n}`}function PQ(e){let t=DQ(e),n=kQ(e),r=t===void 0?e.surface===void 0?`Event`:e.surface.blocking===!0?jQ:AQ:OQ;return{rowKind:`event`,event:e,id:e.id,kind:e.kind,label:e.step_id??``,startedAt:e.at,endedAt:null,status:e.status,durationMs:null,children:[],displayLabel:NQ(t??n??(e.kind===`retry-requested`?`Retry requested`:e.step_id??e.kind),e),displayKind:r,category:MZ(e.kind)}}function FQ(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r===void 0)continue;let i=n;for(;i+1<e.length&&UQ(r,e[i+1]);)i+=1;let a=e.slice(n,i+1),o=a.at(-1);a.length<4||o===void 0?t.push(...a):t.push({rowKind:`group`,count:a.length,id:`group-${r.id}`,kind:r.kind,label:`${a.length} × ${r.kind}`,startedAt:r.startedAt,endedAt:o.endedAt,status:void 0,durationMs:qQ(r.startedAt,o.endedAt),children:a,displayLabel:`${a.length} grouped ${r.displayKind.toLowerCase()} activities`,displayKind:r.displayKind}),n=i}return t}function IQ(e,t,n){if(e.kind===`step`)return`Lifecycle`;if(e.kind===`rollup`)return sQ[e.label]??e.label;if(e.kind===`dispatch`)return aQ(t,n);let r=rQ[e.kind];return r===null?e.kind:EQ(r)}function LQ(e){let t=e=>(e??[]).join(`, `);switch(e.kind){case`concurrency`:return e.ahead===void 0?`behind the work already running`:`behind ${t(e.ahead)}`;case`dependencies`:return`waiting on ${t(e.blocking)}`;case`decision`:return`held by decision ${e.reference??`nobody named`}`;case`release`:return`awaiting the release of ${t(e.awaiting)}`;default:return`held by ${e.kind}`}}function RQ(e){return e.map(LQ).join(` and `)}function zQ(e,t,n){if(e.kind===`step`)return e.label?`Lifecycle: ${e.label}`:`Lifecycle step`;if(e.kind===`queued`)return`Queued ${RQ(e.reasons??[])}`.trim();let r=IQ(e,t,n);return e.kind===`rollup`?`${r}: ${e.count??0} recorded`:!e.label||e.label===r?r:e.kind===`dispatch`?`${r} (${e.label})`:`${r}: ${e.label}`}function BQ(e){let t=0;return e.map(e=>{e.rowKind===`event`&&e.event.kind===`retry-requested`&&(t+=1);let n=BQ(e.children);return!iQ(e.transport)||t===0?{...e,children:n}:{...e,children:n,displayLabel:`${e.displayLabel} · retry ${t}`}})}function VQ(e){let t=[],n=-1,r=0,i=(e,t)=>({...e,dispatch:t,children:e.children.map(e=>i(e,t))});for(let a of e){if(iQ(a.transport)){r+=1,n=t.length,t.push(i(a,{id:a.id,label:`Dispatch ${r}`}));continue}let e=n<0?void 0:t[n];if(HQ(a.transport)&&e?.dispatch!==void 0){t[n]={...e,children:[...e.children,i(a,e.dispatch)]};continue}t.push(a)}return t}function HQ(e){return e===`judge`||e===`llmlint`}function UQ(e,t){return t!==void 0&&e.rowKind!==`group`&&t.rowKind===e.rowKind&&e.kind===t.kind}function WQ(e,t,n){return e.filter(({id:e})=>!t.has(e)).flatMap(({events:e})=>e.filter(e=>e.node_id===n)).map(PQ)}function GQ(e){return e.reduce((e,t)=>e+(t.rowKind===`group`?0:1)+GQ(t.children),0)}function KQ(e,t){return e.startedAt.localeCompare(t.startedAt)}function qQ(e,t){if(t===null)return null;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?null:r-n}function JQ(e,t,n,r){let[i,a]=(0,U.useState)(),o=t===void 0||n===void 0?void 0:JSON.stringify([t,n]);(0,U.useEffect)(()=>{if(o===void 0||t===void 0||n===void 0)return;let r=!0;return e.getConversation(t,n).then(e=>{r&&a({key:o,conversation:e})}).catch(e=>{if(!r)return;let t=e instanceof Error?e:Error(String(e));a(e=>e?.key===o&&e.conversation!==void 0?e:{key:o,error:t})}),()=>{r=!1}},[e,t,n,o,r]);let s=i?.key===o?i:void 0;return(0,U.useMemo)(()=>({conversation:s?.conversation,error:s?.error,loading:o!==void 0&&s===void 0}),[s,o])}var YQ=32;function XQ(e){return e===null?null:e.closest(`[data-slot="scroll-area-viewport"]`)??e.parentElement}function ZQ(e,t){let n=(0,U.useRef)(null),r=(0,U.useRef)(!0),i=(0,U.useRef)({key:e,count:t}),a=(0,U.useCallback)(()=>{let e=n.current;e!==null&&(r.current=e.scrollHeight-e.scrollTop-e.clientHeight<=YQ)},[]),o=(0,U.useCallback)(e=>{n.current?.removeEventListener(`scroll`,a),n.current=XQ(e),n.current?.addEventListener(`scroll`,a,{passive:!0}),a()},[a]);return(0,U.useLayoutEffect)(()=>{let a=i.current;i.current={key:e,count:t};let o=a.key===e&&a.count>0&&t>a.count,s=n.current;!o||s===null||!r.current||(s.scrollTop=s.scrollHeight)},[e,t]),o}var QQ=25;function $Q({client:e,runId:t,node:n,row:r}){let i=r===void 0?void 0:_$(r),a=i?.kind===`conversation`?i.value:void 0,o=JQ(e,t,a,r===void 0?void 0:f$(r));return(0,G.jsx)(`section`,{"aria-label":`Timeline item detail`,className:`timeline-detail`,children:(0,G.jsx)(uf,{className:`h-full`,children:(0,G.jsx)(`div`,{className:`p-[22px] max-sm:p-3`,ref:ZQ(a,p$(r,o)),children:r===void 0?(0,G.jsxs)(`div`,{className:`detail-placeholder`,children:[(0,G.jsx)(Ht,{size:30}),(0,G.jsx)(`p`,{children:`Select an item in the timeline to read what it recorded.`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(WZ,{row:r}),(0,G.jsx)(Cf,{className:`my-4`}),(0,G.jsx)(e$,{client:e,runId:t,node:n,reference:i,row:r,transcript:o})]})})})})}function e$({client:e,runId:t,row:n,node:r,reference:i,transcript:a}){let o=m$(n);if(o!==void 0)return(0,G.jsx)(s$,{redirection:o,row:n});let s=h$(n);if(s!==void 0)return(0,G.jsx)(VZ,{release:s});let c=g$(n);return c===void 0?i?.kind===`conversation`?(0,G.jsx)(n$,{row:n,transcript:a}):y$(n)?(0,G.jsx)(r$,{client:e,runId:t,reference:i,row:n}):i?.kind===`worker_report`&&tN(i.value)!==void 0?(0,G.jsx)(i$,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):i?.kind===`oneharness_session`&&tN(i.value)!==void 0?(0,G.jsx)(a$,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):b$(n,i)&&r!==void 0?(0,G.jsx)(o$,{node:r,reference:i}):(0,G.jsx)(u$,{reference:i,row:n}):(0,G.jsx)(l$,{row:n,surface:c})}function t$({turn:e}){return e.judges===void 0||e.judges.length===0?null:(0,G.jsx)(`ul`,{"aria-label":`Judges on turn ${e.id}`,className:`judge-decisions`,children:e.judges.map(e=>(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`span`,{className:`judge-decision-who`,children:[e.judge,` (`,e.kind,`)`]}),` `,e.decision,` — `,e.reason]},e.judge))})}function n$({row:e,transcript:t}){let[n,r]=(0,U.useState)(QQ),i=t.conversation?.conversation.turns??[],a=e.rowKind===`event`?i.filter(({id:t})=>t===e.event.id):i,o=Om(a.map(e=>({id:e.id,time:Date.parse(e.timestamp)})));if(t.loading)return(0,G.jsxs)(`div`,{"aria-live":`polite`,className:`loading-inline`,children:[(0,G.jsx)(wf,{className:`h-2 w-40`}),(0,G.jsx)(wf,{className:`h-2 w-24`}),`Loading transcript…`]});if(t.conversation===void 0)return(0,G.jsxs)(ua,{variant:`destructive`,children:[(0,G.jsx)(cn,{}),(0,G.jsx)(da,{children:`Transcript unavailable`}),(0,G.jsx)(fa,{children:t.error?.message??`The server recorded no transcript.`})]});let{conversation:s,attribution:c}=t.conversation,l=x$(c.agentRole,c.transportRole);return(0,G.jsx)(Ra,{className:`gap-0 py-3`,children:(0,G.jsxs)(za,{className:`px-3`,children:[(0,G.jsxs)(`header`,{className:`transcript-header`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`p`,{className:`eyebrow`,children:[e.dispatch===void 0?``:`${e.dispatch.label} · `,l,c.persona?` · ${c.persona}`:``]}),(0,G.jsx)(`h4`,{children:s.name})]}),(0,G.jsx)(Am,{state:s.state})]}),(0,G.jsx)(Cf,{className:`my-2.5`}),(0,G.jsx)(`div`,{className:`conversation-timeline-sticky`,children:(0,G.jsx)(Dm,{cursor:o.cursor,onSelectTurn:o.scrollTo,turns:[...a]})}),a.length===0?(0,G.jsx)(`p`,{className:`detail-note`,children:`This turn is no longer part of the recorded transcript.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{ref:o.containerRef,children:a.slice(0,n).map(e=>(0,G.jsxs)(`div`,{ref:t=>o.register(e.id,t),children:[(0,G.jsx)(ww,{author:{label:l},turn:e}),(0,G.jsx)(t$,{turn:e})]},e.id))}),a.length>n&&(0,G.jsxs)(La,{onClick:()=>r(n+QQ),size:`sm`,type:`button`,variant:`outline`,children:[`Show more of `,a.length,` turns`]})]})]})})}function r$({row:e,client:t,runId:n,reference:r}){let i=e.rowKind===`span`?e.span.detail:void 0,a=i?.artifact_id??(r?.kind===`gate_log`?r.value:void 0);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Verification record`}),(0,G.jsx)(`dl`,{className:`facts`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Result`}),(0,G.jsx)(`dd`,{children:i?.ok===void 0?e.status??`in progress`:i.ok?`passed`:`failed`})]})}),i?.output_tail&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Output`}),(0,G.jsx)(`pre`,{children:i.output_tail})]}),(0,G.jsx)(eN,{artifactId:a,client:t,heading:`Full log`,missing:`No readable log was recorded.`,noun:`log`,runId:n,unreadable:`No readable log was recorded.`}),(0,G.jsxs)(`p`,{className:`detail-note`,children:[`Verification `,e.status??`in progress`,`.`]})]})}function i$({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(eN,{artifactId:e,client:t,heading:`Worker report`,missing:`This settlement recorded no report.`,noun:`report`,runId:i,unreadable:`This run kept no readable copy of that report.`}),(0,G.jsx)(u$,{reference:n,row:r})]})}function a$({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(eN,{artifactId:e,client:t,heading:`Oneharness conversation`,missing:`This record named no conversation.`,noun:`conversation`,runId:i,unreadable:`The history store holds no readable copy of that conversation.`}),(0,G.jsx)(u$,{reference:n,row:r})]})}function o$({node:e,reference:t}){let n=e.detail?.verification.checks??[],r=e.detail?.publication;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Publication`}),r?.pr_url&&(0,G.jsx)(d$,{fallback:``,reference:{kind:`pr`,value:r.pr_url}}),r?.merged&&r.commit_url?(0,G.jsx)(`p`,{className:`detail-link`,children:(0,G.jsxs)(`a`,{href:r.commit_url,rel:`noreferrer`,target:`_blank`,children:[`Merged commit `,r.commit?.slice(0,8),` `,(0,G.jsx)(Mt,{size:13})]})}):r?.branch_url?(0,G.jsx)(`p`,{className:`detail-link`,children:(0,G.jsxs)(`a`,{href:r.branch_url,rel:`noreferrer`,target:`_blank`,children:[`Branch `,r.branch,` `,(0,G.jsx)(Mt,{size:13})]})}):!r?.pr_url&&(0,G.jsx)(d$,{fallback:`No publication was recorded.`,reference:t}),(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Observed checks`}),n.length===0?(0,G.jsx)(`p`,{className:`detail-note`,children:`No checks were observed on this node.`}):(0,G.jsx)(`dl`,{className:`facts`,children:n.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:e.name}),(0,G.jsx)(`dd`,{children:e.url?(0,G.jsx)(`a`,{href:e.url,rel:`noreferrer`,target:`_blank`,children:e.state}):e.state})]},e.name))})]})}function s$({redirection:e,row:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Delivery`}),(0,G.jsx)(`dd`,{children:e.delivered?`Live — into the turn that was already running`:`Deferred — onto the node's next dispatch`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Redirected at`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(iF,{at:t.startedAt,relative:!0})})]}),e.member!==void 0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Member`}),(0,G.jsx)(`dd`,{children:e.member})]}),e.input_bytes!==void 0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Note`}),(0,G.jsxs)(`dd`,{children:[e.input_bytes,` bytes offered`]})]}),(0,G.jsx)(c$,{row:t})]}),e.reason!==void 0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Why it was not delivered`}),(0,G.jsx)(`p`,{className:`detail-note`,children:e.reason})]})]})}function c$({row:e}){let t=e.rowKind===`event`?MQ(e.event):void 0;return t===void 0?null:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Author`}),(0,G.jsx)(`dd`,{children:t})]})}function l$({surface:e,row:t}){let n=[[`Kind`,e.kind],[`Raised by`,e.source],[`Blocking`,e.blocking===void 0?void 0:e.blocking?`yes — dependents wait on the answer`:`no — nothing waits on it`]].filter(([,e])=>e!==void 0);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Recorded at`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(iF,{at:t.startedAt,relative:!0})})]}),n.map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:e}),(0,G.jsx)(`dd`,{children:t})]},e))]}),e.message!==void 0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Message`}),(0,G.jsx)(`p`,{className:`detail-note`,children:e.message})]})]})}function u$({row:e,reference:t}){let n=e.rowKind===`group`?void 0:e,r=e.rowKind===`span`&&e.span.count!==void 0?`${e.span.count} records`:void 0,i=(e.rowKind===`span`?e.span.reasons:void 0)??[];return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Recorded at`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(iF,{at:e.startedAt,relative:!0})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Ended`}),(0,G.jsx)(`dd`,{children:e.endedAt===null?`Still running`:(0,G.jsx)(iF,{at:e.endedAt,relative:!0})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Status`}),(0,G.jsx)(`dd`,{children:e.status??`Not recorded`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Duration`}),(0,G.jsx)(`dd`,{children:e.durationMs===null?`Not recorded`:ZP(e.durationMs)})]}),r!==void 0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Aggregated`}),(0,G.jsx)(`dd`,{children:r})]}),i.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Waiting on`}),(0,G.jsx)(`dd`,{children:i.map(LQ).join(` and `)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Step`}),(0,G.jsx)(`dd`,{children:v$(n)??`None`})]}),(0,G.jsx)(c$,{row:e})]}),(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Reference`}),(0,G.jsx)(d$,{fallback:`This item points at no recorded artifact.`,reference:t})]})}function d$({reference:e,fallback:t}){return e===void 0?(0,G.jsx)(`p`,{className:`detail-note`,children:t}):e.value.startsWith(`http`)?(0,G.jsx)(`p`,{className:`detail-link`,children:(0,G.jsxs)(`a`,{href:e.value,rel:`noreferrer`,target:`_blank`,children:[e.value,` `,(0,G.jsx)(Mt,{size:13})]})}):(0,G.jsxs)(`p`,{className:`detail-note`,children:[(0,G.jsx)(`span`,{className:`detail-reference-kind`,children:e.kind}),(0,G.jsx)(`code`,{children:e.value})]})}function f$(e){if(e.rowKind!==`span`)return e.id;let t=e.span.events.at(-1);return[e.span.id,e.span.status??``,e.span.ended_at??``,e.span.events.length,t?.id??``,t?.at??``,t?.status??``].join(`|`)}function p$(e,t){return t.conversation===void 0?0:e?.rowKind===`event`?1:t.conversation.conversation.turns.length}function m$(e){return e.rowKind===`event`?e.event.redirection:void 0}function h$(e){return e.rowKind===`event`?e.event.release:void 0}function g$(e){return e.rowKind===`event`?e.event.surface:void 0}function _$(e){if(e.rowKind===`span`)return e.span.reference;if(e.rowKind===`event`)return e.event.reference}function v$(e){if(e?.rowKind===`span`)return e.span.step_id;if(e?.rowKind===`event`)return e.event.step_id}function y$(e){return e.kind===`verification`||e.kind.startsWith(`verification-`)}function b$(e,t){return t?.kind===`pr`||e.kind===`publication`||e.kind.startsWith(`pr-`)||e.kind.startsWith(`publication-`)}function x$(e,t){return aQ(e,t)}function S$({client:e,runId:t,node:n,timeline:r,timelineError:i,selectedItemId:a,onSelectItem:o,onBack:s,selectedTab:c,onSelectTab:l,agents:u}){let d=(0,U.useMemo)(()=>_Q(r,n.id),[r,n.id]);(0,U.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(a===void 0?s():o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s,o,a]);let f=n.detail?.publication===void 0?n.result?.pr??void 0:n.detail.publication.pr_url;return(0,G.jsxs)(`section`,{"aria-label":`Timeline for ${n.label}`,className:`node-view`,children:[(0,G.jsxs)(`header`,{className:`node-view-head`,children:[(0,G.jsx)(`nav`,{"aria-label":`Breadcrumb`,children:(0,G.jsxs)(`ol`,{className:`breadcrumb`,children:[(0,G.jsx)(`li`,{children:(0,G.jsxs)(La,{onClick:s,size:`sm`,type:`button`,variant:`ghost`,children:[(0,G.jsx)(_t,{size:14}),` Graph`]})}),(0,G.jsx)(`li`,{"aria-current":`page`,children:(0,G.jsx)(`span`,{className:`breadcrumb-node`,children:n.label})})]})}),(0,G.jsxs)(`div`,{className:`node-view-facts`,children:[(0,G.jsx)(tX,{className:`node-view-state`,state:n.status}),(0,G.jsx)(DZ,{control:n.control}),(0,G.jsxs)(`span`,{className:`node-view-meta`,children:[n.kind,` node · `,n.telemetry?.turns??0,` turns ·`,` `,n.telemetry?.lint??0,` lint turns`]}),f!==void 0&&(0,G.jsxs)(`a`,{className:`node-view-pr`,href:f,rel:`noreferrer`,target:`_blank`,children:[`Pull request `,(0,G.jsx)(Mt,{size:12})]})]})]}),(0,G.jsx)(j$,{node:n}),(0,G.jsxs)(Cp,{className:`node-tabs`,onValueChange:e=>{yX(e)&&l(e)},value:c,children:[(0,G.jsx)(Tp,{"aria-label":`Node details`,variant:`line`,children:Object.entries(vX).map(([e,t])=>(0,G.jsx)(Ep,{value:e,children:t},e))}),(0,G.jsxs)(Dp,{className:`node-tab-panel`,value:`task`,children:[(0,G.jsx)(`pre`,{children:O$(n.task)}),(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Outcome`}),(0,G.jsx)(`dd`,{children:M$(n.result?.detail)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Graph overrides`}),(0,G.jsx)(`dd`,{children:(n.task.sets??[]).length===0?`None`:(0,G.jsx)(`ol`,{"aria-label":`Graph overrides`,className:`sets-served`,children:n.task.sets?.map((e,t)=>(0,G.jsx)(`li`,{children:(0,G.jsx)(`code`,{children:e})},t))})})]})]})]}),(0,G.jsx)(Dp,{className:`node-tab-panel`,value:`criteria`,children:(0,G.jsx)(`pre`,{children:k$(n.task)})}),(0,G.jsx)(Dp,{className:`node-tab-panel`,value:`dependencies`,children:(0,G.jsx)(`dl`,{className:`facts`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Dependencies`}),(0,G.jsx)(`dd`,{children:n.task.deps?.join(`, `)||`None`})]})})}),(0,G.jsx)(Dp,{className:`node-tab-panel`,value:`pr`,children:(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Publication`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(A$,{node:n})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Release`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(HZ,{node:n})})]})]})}),(0,G.jsx)(Dp,{className:`node-tab-panel`,value:`checks`,children:(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Verification coverage`}),(0,G.jsxs)(`dd`,{children:[`Hook:`,` `,n.detail?.verification.pre_push_hook?`present`:`not recorded`,` · `,`Required checks:`,` `,n.detail?.verification.required_checks?.join(`, `)||`none configured`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Observed checks`}),(0,G.jsx)(`dd`,{children:(n.detail?.verification.checks??[]).length===0?`No checks observed`:n.detail?.verification.checks?.map((e,t)=>(0,G.jsxs)(`span`,{children:[t>0&&` · `,e.url?(0,G.jsxs)(`a`,{href:e.url,rel:`noreferrer`,target:`_blank`,children:[e.name,`: `,e.state]}):`${e.name}: ${e.state}`]},e.name))})]})]})}),(0,G.jsx)(Dp,{className:`node-tab-panel`,value:`agents`,children:c===`agents`&&u}),(0,G.jsx)(Dp,{className:`node-timeline-panel`,value:`timeline`,children:i===void 0?r===void 0?(0,G.jsx)(`div`,{"aria-live":`polite`,className:`loading-state`,children:`Loading the recorded timeline…`}):d.rows.length===0?(0,G.jsxs)(Ra,{className:`m-5 items-center gap-2 p-8 text-muted-foreground`,children:[(0,G.jsx)(`p`,{className:`m-0`,children:`This node has no recorded timeline yet.`}),(0,G.jsx)(`p`,{className:`m-0 text-[11px]`,children:`Spans and events appear here as the run records them.`})]}):(0,G.jsx)(C$,{client:e,node:n,onSelectItem:o,runId:t,selectedItemId:a,timeline:r}):(0,G.jsxs)(ua,{className:`m-5 w-auto`,variant:`destructive`,children:[(0,G.jsx)(cn,{}),(0,G.jsx)(da,{children:`Timeline unavailable`}),(0,G.jsx)(fa,{children:i.message})]})})]})]})}function C$({client:e,node:t,onSelectItem:n,runId:r,selectedItemId:i,timeline:a}){let o=(0,U.useMemo)(()=>fQ(a,t.id),[a,t.id]),[s,c]=(0,U.useState)(()=>new Set),l=(0,U.useMemo)(()=>{if(i!==void 0)return xQ(o.tree,i).find(e=>e.rowKind===`group`)?.id},[o.tree,i]),u=(0,U.useMemo)(()=>l===void 0?s:new Set([...s,l]),[s,l]),d=(0,U.useMemo)(()=>pQ(o.tree,u),[o.tree,u]),f=Om((0,U.useMemo)(()=>d.flatMap(e=>e.entryKind===`row`?[{id:e.row.id,time:Date.parse(e.row.startedAt)}]:[]),[d])),[p,m]=(0,U.useState)(!1),h=(0,U.useMemo)(()=>cQ(o.items,o.lanes),[o.items,o.lanes]),g=(0,U.useMemo)(()=>dQ(o.markers,o.items,i),[o.items,o.markers,i]),_=(0,U.useMemo)(()=>w$(o.items),[o.items]),v=f.cursor===void 0?void 0:Math.min(Math.max(f.cursor,_[0]),_[1]),y=i===void 0?void 0:bQ(o.rows,i),b=e=>{n(e),f.scrollTo(e)};return(0,U.useEffect)(()=>{i!==void 0&&f.scrollTo(i)},[i,f]),(0,G.jsxs)(`div`,{className:`node-execution`,"data-expanded":p,children:[(0,G.jsx)(`section`,{"aria-label":`Node timeline`,className:`node-timeline-sticky`,"data-testid":`node-timeline`,children:(0,G.jsx)(En,{axis:{origin:_[0]},cursor:v,expanded:p,getFailureExcerpt:e=>e.payload.rowKind===`span`?e.payload.span.detail?.output_tail:void 0,items:p?o.items:h,lanes:o.lanes,markers:g,onExpandedChange:m,onSelect:e=>b(e.id),selectedId:i})}),(0,G.jsx)(`section`,{"aria-label":`Node transcript`,className:`node-transcript`,ref:f.containerRef,children:T$(d).map(e=>{let t=e.entries.map(e=>e.entryKind===`row`?(0,G.jsx)(D$,{onOpen:b,register:f.register,row:e.row,selected:e.row.id===i},e.row.id):(0,G.jsx)(E$,{entry:e,onToggle:()=>c(t=>{let n=new Set(t);return n.has(e.group.id)?n.delete(e.group.id):n.add(e.group.id),n})},`collapse-${e.group.id}`));return e.dispatch===void 0?(0,G.jsx)(U.Fragment,{children:t},e.id):(0,G.jsxs)(`section`,{"aria-label":e.dispatch.label,className:`transcript-dispatch`,children:[(0,G.jsx)(`h3`,{children:e.dispatch.label}),t]},e.id)})}),y!==void 0&&(0,G.jsxs)(`aside`,{"aria-label":`Item detail panel`,className:`detail-drawer`,children:[(0,G.jsx)(La,{"aria-label":`Close detail`,className:`drawer-close`,onClick:()=>n(),size:`icon`,variant:`ghost`,children:(0,G.jsx)(pn,{})}),(0,G.jsx)($Q,{client:e,node:t,row:y,runId:r})]})]})}function w$(e){let t=e.map(({start:e})=>e),n=e.map(e=>e.end??e.start);if(t.length===0)return[0,1];let r=Math.min(...t),i=Math.max(...n);return[r,i>r?i:r+1]}function T$(e){let t=[];for(let n of e){let e=n.entryKind===`row`?n.row:n.group,r=t.at(-1);e.dispatch!==void 0&&r?.dispatch!==void 0&&r.dispatch.id===e.dispatch.id?r.entries.push(n):t.push({id:e.id,dispatch:e.dispatch,entries:[n]})}return t}function E$({entry:e,onToggle:t}){let n=mQ(e.hidden,e.group.kind);return(0,G.jsx)(`p`,{className:`transcript-collapsed`,children:(0,G.jsxs)(`button`,{"aria-expanded":e.expanded,onClick:t,type:`button`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`…`}),e.expanded?`Collapse ${n}`:`Show ${n}`]})})}function D$({row:e,selected:t,register:n,onOpen:r}){return(0,G.jsx)(`article`,{"aria-label":e.displayLabel,className:`transcript-item`,"data-dispatch-group":e.dispatch?.label,"data-selected":t,ref:t=>n(e.id,t),children:(0,G.jsxs)(`button`,{"aria-label":`Open ${e.displayLabel}`,onClick:()=>r(e.id),type:`button`,children:[(0,G.jsxs)(`span`,{className:`eyebrow`,children:[e.rowKind===`event`&&(0,G.jsx)(PZ,{category:e.category}),e.displayKind]}),(0,G.jsx)(`strong`,{children:e.displayLabel}),(0,G.jsxs)(`span`,{className:`transcript-facts`,children:[(0,G.jsx)(iF,{at:e.startedAt}),e.durationMs!==null&&` · ${ZP(e.durationMs)}`,` · ${e.status??`recorded`}`,e.sessionName!==void 0&&` · ${e.sessionName}`]})]})})}function O$(e){if(e.task!==void 0)return e.task;let t=e.steps??[];return t.length===0?`No task prose recorded.`:t.map(e=>`## ${e.id}\n\n${e.task}`).join(`
|
|
96
|
+
M${w.x},${w.y}h${w.width}v${w.height}h${-w.width}z`,fillRule:`evenodd`,pointerEvents:`none`})]})})}jY.displayName=`MiniMap`,(0,U.memo)(jY);var MY=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,NY={[bG.Line]:`right`,[bG.Handle]:`bottom-right`};function PY({nodeId:e,position:t,variant:n=bG.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 v=fq(),y=typeof e==`string`?e:v,b=YG(),x=(0,U.useRef)(null),S=n===bG.Handle,C=JG((0,U.useCallback)(MY(S&&p),[S,p]),WG),w=(0,U.useRef)(null),T=t??NY[n];return(0,U.useEffect)(()=>{if(!(!x.current||!y))return w.current||=jG({domNode:x.current,nodeId:y,getStoreItems:()=>{let{nodeLookup:e,transform:t,snapGrid:n,snapToGrid:r,nodeOrigin:i,domNode:a}=b.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}=b.getState(),o=[],s={x:e.x,y:e.y},c=r.get(y);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=RW([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...UU({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:y,type:`position`,position:{...s}};o.push(e)}if(e.width!==void 0&&e.height!==void 0){let t={id:y,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:y,type:`dimensions`,resizing:!1,dimensions:{width:e,height:t}};b.getState().triggerNodeChanges([n])}}),w.current.update({controlPosition:T,boundaries:{minWidth:s,minHeight:c,maxWidth:l,maxHeight:u},keepAspectRatio:d,resizeDirection:f,onResizeStart:h,onResize:g,onResizeEnd:_,shouldResize:m}),()=>{w.current?.destroy()}},[T,s,c,l,u,d,h,g,_,m]),(0,G.jsx)(`div`,{className:cL([`react-flow__resize-control`,`nodrag`,...T.split(`-`),n,r]),ref:x,style:{...i,scale:C,...o&&{[S?`backgroundColor`:`borderColor`]:o}},children:a})}(0,U.memo)(PY);function FY(e){return e.graph??void 0}function IY(e){return{run:e.run_node_sets??[],nodes:new Map(e.plan.tasks.map(e=>[e.id,e.sets??[]]))}}function LY(e){let t=FY(e);if(!t)return[];let n=new Map(e.run.nodes.map(e=>[e.node,e]));return t.plan.tasks.flatMap(r=>{let i=KY(r,`kind`)===`human`?`human`:qY(r)?`lifecycle`:`agent`,a=t.node_results[r.id]??t.result?.results?.[r.id],o=t.node_status[r.id];return o===void 0?[]:[{id:r.id,label:KY(r,`name`)??r.id,status:o,kind:i,task:r,telemetry:n.get(r.id),result:a,detail:e.node_details[r.id],control:t.node_control[r.id],failure:n.get(r.id)?.failure,blockers:[...t.node_gated_by[r.id]??[],...a?.blocked_by??[]]}]})}function RY(e){switch(e?.launcher){case`claude-code`:return`Claude`;case`codex`:return`Codex`;default:return`Unattributed`}}function zY(e){let t=RY(e);return e?.session_key===void 0?e===void 0?`Unattributed`:`${t} launch · ${JY(e.launch_id)}`:`${t} session · ${JY(e.session_key)}`}function BY(e){if(e.blockers.length>0&&HY.has(e.status))return`blocked by ${e.blockers.join(`, `)}`;if(UY.has(e.status))return VY(e)??`${e.status}, with no reason recorded`}function VY(e){return(e.failure?.detail||e.result?.detail||e.result?.error||e.telemetry?.outcome||e.result?.outcome)?.trim()||void 0}var HY=new Set([`blocked`,`skipped`,`waiting`]),UY=new Set([`failed`,`not-completed`,`cancelled`]);function WY(e){let t=$I,n=t=>(e[t]??0)>0;return[...t.filter(n),...Object.keys(e).filter(e=>!t.includes(e)).sort().filter(n)].map(t=>`${e[t]} ${t}`).join(` · `)}function GY(e){return UY.has(e)||e===`blocked`||e===`skipped`}function KY(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function qY(e){return`repo`in e||`steps`in e}function JY(e){return e.length>12?`${e.slice(0,8)}…`:e}function YY({data:e}){let t=e.style===`success`?St:e.style===`danger`||e.style===`muted`?pn:e.style===`active`?Dt:At;return(0,G.jsxs)(`article`,{"aria-label":`${e.label}: ${e.state}`,className:H(`dag-node`,`state-${e.state}`,`token-${e.style}`),"data-selected":e.selected,children:[(0,G.jsx)(bq,{type:`target`,position:$.Left}),(0,G.jsxs)(`div`,{className:`node-heading`,children:[(0,G.jsx)(Fa,{className:`px-1.5 py-0 text-[9px] tracking-[.1em] uppercase`,variant:`outline`,children:e.kind}),(0,G.jsx)(t,{className:H(e.style===`active`&&`spin`),size:17})]}),(0,G.jsx)(`strong`,{children:e.label}),(0,G.jsx)(`span`,{className:`node-status`,children:e.state}),e.reason!==void 0&&(0,G.jsx)(`span`,{className:`node-reason`,title:e.reason,children:e.reason}),(0,G.jsx)(bq,{type:`source`,position:$.Right})]})}function XY({data:e,id:t,markerEnd:n,style:r}){return(0,G.jsx)(eJ,{id:t,path:ZY(e?.points??[]),markerEnd:n,style:r})}function ZY(e){let[t,...n]=e;return t?`M ${t.x} ${t.y} ${n.map(e=>`L ${e.x} ${e.y}`).join(` `)}`:``}var QY={dagNode:YY},$Y={routed:XY};function eX({nodes:e,selectedNodeId:t,onSelectNode:n}){let r=(0,U.useMemo)(()=>{let t=new Map;for(let n of e)GY(n.status)&&t.set(n.id,BY(n));return t},[e]),{nodes:i,edges:a}=(0,U.useMemo)(()=>{let n=new Set(e.map(e=>e.id)),i=sL({nodes:e.map(e=>({id:e.id,label:e.label,kind:e.kind,state:e.status})),edges:e.flatMap(e=>(e.task.deps??[]).filter(e=>n.has(e)).map(t=>({id:`${t}->${e.id}`,source:t,target:e.id})))});return{nodes:i.nodes.map(e=>({id:e.id,type:`dagNode`,position:{x:e.x,y:e.y},data:{label:e.label,kind:e.kind,state:e.state,style:e.style,selected:e.id===t,...r.get(e.id)===void 0?{}:{reason:r.get(e.id)}},style:{width:e.width,height:e.height}})),edges:i.edges.map(t=>({id:t.id,source:t.source,target:t.target,type:`routed`,data:{points:t.points},animated:e.find(({id:e})=>e===t.target)?.status===`running`}))}},[e,r,t]);return(0,G.jsxs)(`div`,{className:`graph-wrap`,children:[(0,G.jsxs)($J,{nodes:i,edges:a,colorMode:`dark`,nodeTypes:QY,edgeTypes:$Y,nodesDraggable:!1,nodesConnectable:!1,elementsSelectable:!0,fitView:!0,minZoom:.05,onNodeClick:(e,t)=>n(t.id),"aria-label":`DAG execution graph`,children:[(0,G.jsx)(oY,{color:`var(--border)`,gap:22}),(0,G.jsx)(hY,{showInteractive:!1})]}),(0,G.jsx)(`ol`,{className:`accessible-node-list`,"aria-label":`DAG nodes`,children:e.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{type:`button`,onClick:()=>n(e.id),children:[e.label,`: `,e.status,r.get(e.id)===void 0?``:` — ${r.get(e.id)}`]})},e.id))})]})}function tX({className:e,state:t}){let n=nX(t);return(0,G.jsxs)(Fa,{className:H(`gap-1.5 tracking-[.03em] uppercase`,n&&iX[n],e),variant:`outline`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,className:H(`size-1.5 rounded-full bg-current`,t===`running`&&`animate-pulse`)}),t]})}function nX(e){return uX[e]}var rX=e=>{let t=nX(e);return H(`size-2 shrink-0 rounded-full bg-current`,t===void 0?`text-muted-foreground`:aX[t])},iX={success:`border-success bg-success-surface text-success`,destructive:`border-destructive bg-destructive-surface text-destructive`,warning:`border-warning bg-warning-surface text-warning`,info:`border-info bg-info-surface text-info`},aX={success:`text-success`,destructive:`text-destructive`,warning:`text-warning`,info:`text-info`},oX=`success`,sX=`destructive`,cX=`warning`,lX={blocked:cX,cancelled:sX,done:oX,failed:sX,"not-completed":sX,parked:void 0,pending:void 0,running:`info`,skipped:cX,unknown:void 0,waiting:void 0},uX={...lX,complete:lX.done,settled:lX.done,active:lX.running},dX={graph:`graph`,overall:`overall`,channel:`channel`,watch:`watch`,reads:`reads`,agents:`agents`};function fX(e){return e!==null&&Object.hasOwn(dX,e)}var pX={projects:`projects`,runs:`runs`};function mX(e){return e!==null&&Object.hasOwn(pX,e)}var hX=`none`,gX={decisions:{label:`Decisions`,description:`Decision points and settlements only`,profile:jA.planner},activity:{label:`Detailed activity`,description:`Every record all three producers put on the stream`,profile:jA.detailed}};function _X(e){return e!==null&&Object.hasOwn(gX,e)}var vX={timeline:`Timeline`,task:`Task`,criteria:`Acceptance criteria`,dependencies:`Dependencies`,pr:`PR`,checks:`Checks`,agents:`Agents`};function yX(e){return e!==null&&Object.hasOwn(vX,e)}function bX(e){let t=[...e].some(e=>e.charCodeAt(0)<32);return e.length>0&&e.length<=512&&!t&&!/[/?#]/u.test(e)}function xX(e,t){let n=e.get(t);return n!==null&&bX(n)?n:void 0}function SX(){let e=(0,U.useSyncExternalStore)(CX,wX,wX),t=new URLSearchParams(e),n=t.get(`list`),r=mX(n)?n:`projects`,i=t.get(`project`),a=i!==null&&(i===`none`||Xj(i))?i:void 0,o=xX(t,`run`),s=xX(t,`node`),c=xX(t,`event`),l=t.get(`view`),u=t.get(`tab`),d=t.get(`detail`),f=_X(d)?d:`activity`,p=yX(u)?u:`timeline`,m=fX(l)?l:s===void 0?`overall`:`graph`,h=(0,U.useCallback)(e=>{let t=new URLSearchParams(window.location.search);e(t),window.history.pushState(null,``,`${window.location.pathname}?${t}`),window.dispatchEvent(new PopStateEvent(`popstate`))},[]);return{list:r,projectKey:a,runId:o,nodeId:s,itemId:c,view:m,detail:f,nodeTab:p,selectList:e=>h(t=>{e===`projects`?t.delete(`list`):t.set(`list`,e),t.delete(`project`)}),selectProject:e=>h(t=>{e===void 0?t.delete(`project`):t.set(`project`,e),t.delete(`list`),t.delete(`run`),t.delete(`node`),t.delete(`event`),t.delete(`tab`)}),selectRun:e=>h(t=>{t.set(`run`,e),t.delete(`node`),t.delete(`event`),t.delete(`tab`)}),selectNode:e=>h(t=>{e?t.set(`node`,e):t.delete(`node`),t.delete(`event`),t.delete(`tab`),t.set(`view`,`graph`)}),selectItem:e=>h(t=>{e?t.set(`event`,e):t.delete(`event`)}),showOverall:()=>h(e=>{e.set(`view`,`overall`),e.delete(`node`),e.delete(`event`),e.delete(`tab`)}),selectDetail:e=>h(t=>{e===`activity`?t.delete(`detail`):t.set(`detail`,e)}),selectNodeTab:e=>h(t=>{e===`timeline`?t.delete(`tab`):t.set(`tab`,e),e!==`timeline`&&t.delete(`event`)}),selectView:e=>h(t=>{t.set(`view`,e),t.delete(`node`),t.delete(`event`),t.delete(`tab`)})}}function CX(e){return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}function wX(){return window.location.search}var TX=`(no project)`;function EX(e){return e.project===null?TX:e.name??e.project}function DX(e){return e.project===null?e.name??void 0:e.name===null?void 0:e.project}function OX(e){return e.project??`none`}function kX(e,t){return e.find(e=>OX(e)===t)}function AX(e){let t=new Map;for(let n of e)t.set(n.state,(t.get(n.state)??0)+1);return[...t].map(([e,t])=>`${t} ${e}`).join(` · `)}function jX(e){return`${e.length} ${e.length===1?`run`:`runs`}`}function MX(e){if(e.agent_count!==void 0)return`${e.agent_count} ${e.agent_count===1?`agent`:`agents`}`}function NX({groups:e,selectedKey:t,onSelect:n}){return(0,G.jsx)(`ul`,{"aria-label":`Project rows`,className:`run-list project-rows`,children:e.map(e=>{let r=OX(e),i=t===r;return(0,G.jsx)(`li`,{children:(0,G.jsxs)(`button`,{"aria-current":i?`page`:void 0,className:`run-link`,"data-active":i,onClick:()=>n(r),type:`button`,children:[(0,G.jsxs)(`span`,{className:`run-link-main`,children:[(0,G.jsx)(Ft,{"aria-hidden":`true`,size:13}),(0,G.jsx)(`span`,{children:EX(e)})]}),(0,G.jsx)(wt,{"aria-hidden":`true`,size:14}),DX(e)!==void 0&&(0,G.jsx)(`span`,{className:`run-link-counts`,title:DX(e),children:DX(e)}),(0,G.jsx)(`span`,{className:`run-link-counts`,children:[jX(e.runs),AX(e.runs),MX(e)].filter(Boolean).join(` · `)}),(0,G.jsx)(`span`,{className:`run-link-tag`,children:e.last_write_at===null?`never written`:(0,G.jsx)(iF,{at:nF(e.last_write_at),relative:!0})})]})},r)})})}var PX={projects:`Projects`,runs:`Runs`};function FX({list:e,onSelectList:t,projects:n,selectedProjectKey:r,onSelectProject:i,runs:a,selectedRunId:o,liveRunIds:s,onSelect:c,hasMore:l,loadingMore:u,onLoadMore:d,hostActions:f}){return(0,G.jsx)(`nav`,{"aria-label":e===`runs`?`DAG runs`:`Projects`,className:`run-nav`,onScrollCapture:e=>{let t=e.target;l&&t.scrollHeight-t.scrollTop<=t.clientHeight+80&&d()},children:(0,G.jsx)(uf,{className:`h-full`,children:(0,G.jsxs)(`div`,{className:`px-[18px] py-6 max-sm:px-2`,children:[(0,G.jsxs)(`div`,{className:`brand`,children:[(0,G.jsx)(`div`,{"aria-hidden":`true`,className:`brand-mark`,children:(0,G.jsx)(ht,{size:20})}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`eyebrow`,children:`Local orchestration`}),(0,G.jsx)(`h1`,{children:`DAG Observatory`})]})]}),(0,G.jsx)(Cf,{className:`my-[22px]`}),f,(0,G.jsxs)(`fieldset`,{className:`detail-switch list-switch`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:`Which list`}),Object.values(pX).map(n=>(0,G.jsx)(La,{"aria-pressed":e===n,onClick:()=>t(n),size:`sm`,type:`button`,variant:e===n?`default`:`outline`,children:PX[n]},n))]}),e===`projects`?n===void 0?(0,G.jsx)(`p`,{"aria-live":`polite`,className:`run-list-status`,children:`Loading projects…`}):(0,G.jsx)(NX,{groups:n,onSelect:i,selectedKey:r}):(0,G.jsx)(`div`,{className:`run-list`,children:a.map(e=>{let t=o===e.run_id,n=s.has(e.run_id),r=WY(e.node_counts);return(0,G.jsxs)(`button`,{"aria-current":t?`page`:void 0,className:`run-link`,"data-active":t,onClick:()=>c(e.run_id),type:`button`,children:[(0,G.jsxs)(`span`,{className:`run-link-main`,children:[n?(0,G.jsxs)(hm,{children:[(0,G.jsx)(gm,{asChild:!0,children:(0,G.jsx)(`span`,{"aria-label":`Live`,className:H(`run-dot`,rX(e.state)),"data-live":`true`,role:`img`})}),(0,G.jsx)(_m,{children:`Live`})]}):(0,G.jsx)(`span`,{"aria-label":`Historical`,className:H(`run-dot`,rX(e.state)),role:`img`}),(0,G.jsx)(`span`,{children:e.run_id})]}),(0,G.jsx)(wt,{"aria-hidden":`true`,size:14}),(0,G.jsx)(`span`,{className:`run-link-counts`,title:r,children:[e.state,r].filter(Boolean).join(` · `)}),(0,G.jsxs)(`span`,{className:`run-link-tag`,children:[(0,G.jsx)(bt,{"aria-hidden":`true`,size:11}),zY(e.launch)]})]},e.run_id)})}),e===`runs`&&l&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`button`,{className:`sr-only`,onClick:()=>void d(),type:`button`,children:`Load more runs`}),(0,G.jsx)(`p`,{"aria-live":`polite`,className:`run-list-status`,children:u?`Loading more runs…`:``})]})]})})})}function IX({groups:e,error:t,onSelect:n}){return(0,G.jsx)(uf,{className:`h-full`,children:(0,G.jsxs)(`section`,{"aria-labelledby":`projects-heading`,className:`projects-landing`,children:[(0,G.jsx)(`h2`,{id:`projects-heading`,children:`Projects`}),(0,G.jsx)(`p`,{className:`projects-lede`,children:`Every project with a run under this root, newest activity first.`}),t&&(0,G.jsx)(zX,{error:t,what:`The project list`}),e===void 0?(0,G.jsxs)(`div`,{"aria-live":`polite`,className:`loading-state`,children:[(0,G.jsx)(wf,{className:`h-2 w-48`}),(0,G.jsx)(wf,{className:`h-2 w-32`}),`Loading projects…`]}):e.length===0?(0,G.jsxs)(`div`,{className:`empty-state`,children:[(0,G.jsx)(Ft,{size:34}),(0,G.jsx)(`h2`,{children:`No DAG runs found`}),(0,G.jsx)(`p`,{children:`Start an orchestrated run to see its project appear here.`})]}):(0,G.jsx)(`ul`,{"aria-label":`Projects`,className:`project-cards`,children:e.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(Ra,{className:`project-card`,children:(0,G.jsxs)(za,{children:[(0,G.jsxs)(`button`,{className:`project-card-open`,onClick:()=>n(OX(e)),type:`button`,children:[(0,G.jsx)(`span`,{className:`project-card-name`,children:EX(e)}),(0,G.jsx)(wt,{"aria-hidden":`true`,size:14})]}),DX(e)!==void 0&&(0,G.jsx)(`p`,{className:`project-card-id`,children:DX(e)}),(0,G.jsxs)(`p`,{className:`project-card-facts`,children:[jX(e.runs),e.runs.length>0&&` · ${AX(e.runs)}`,MX(e)!==void 0&&` · ${MX(e)}`]}),(0,G.jsx)(`p`,{className:`project-card-facts`,children:e.last_write_at===null?`never written`:(0,G.jsxs)(G.Fragment,{children:[`Last activity`,` `,(0,G.jsx)(iF,{at:nF(e.last_write_at),relative:!0})]})})]})})},OX(e)))})]})})}function LX({projectKey:e,group:t,error:n,loading:r,agents:i,onSelectRun:a}){return(0,G.jsx)(uf,{className:`h-full`,children:(0,G.jsxs)(`section`,{"aria-labelledby":`project-heading`,className:`projects-landing`,children:[(0,G.jsx)(`p`,{className:`eyebrow`,children:`Project`}),(0,G.jsx)(`h2`,{id:`project-heading`,children:t===void 0?e:EX(t)}),t!==void 0&&DX(t)!==void 0&&(0,G.jsx)(`p`,{className:`project-card-id`,children:DX(t)}),t&&(0,G.jsxs)(`p`,{className:`projects-lede`,children:[jX(t.runs),t.runs.length>0&&` · ${AX(t.runs)}`,MX(t)!==void 0&&` · ${MX(t)}`,t.last_write_at!==null&&(0,G.jsxs)(G.Fragment,{children:[` · last activity `,(0,G.jsx)(iF,{at:nF(t.last_write_at),relative:!0})]})]}),n&&(0,G.jsx)(zX,{error:n,what:`This project`}),r?(0,G.jsxs)(`div`,{"aria-live":`polite`,className:`loading-state`,children:[(0,G.jsx)(wf,{className:`h-2 w-48`}),(0,G.jsx)(wf,{className:`h-2 w-32`}),`Loading project…`]}):t?(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`ul`,{"aria-label":`Runs of ${EX(t)}`,className:`project-runs`,children:t.runs.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(RX,{onSelect:a,run:e})},e.run_id))}),i]}):null]})})}function RX({run:e,onSelect:t}){let n=WY(e.node_counts);return(0,G.jsxs)(`button`,{"aria-label":`Open ${e.run_id}`,className:`project-run`,onClick:()=>t(e.run_id),type:`button`,children:[(0,G.jsx)(`span`,{className:`project-run-id`,children:e.run_id}),(0,G.jsxs)(`span`,{className:`project-run-facts`,children:[(0,G.jsx)(tX,{state:e.state}),e.liveness!==void 0&&(0,G.jsx)(Fa,{variant:`outline`,children:e.liveness}),e.unread_surfaces!==void 0&&e.unread_surfaces>0&&(0,G.jsxs)(Fa,{variant:`secondary`,children:[e.unread_surfaces,` unread`,` `,e.unread_surfaces===1?`surface`:`surfaces`]})]}),(0,G.jsxs)(`span`,{className:`project-run-facts project-run-detail`,children:[n&&(0,G.jsx)(`span`,{children:n}),(0,G.jsx)(`span`,{children:e.last_progress_at===void 0?`never written`:(0,G.jsxs)(G.Fragment,{children:[`Last write`,` `,(0,G.jsx)(iF,{at:nF(e.last_progress_at*1e3),relative:!0})]})})]})]})}function zX({error:e,what:t}){return(0,G.jsxs)(ua,{className:`mb-4`,variant:`destructive`,children:[(0,G.jsx)(cn,{}),(0,G.jsxs)(da,{children:[t,` could not be read`]}),(0,G.jsx)(fa,{children:e.message})]})}function BX(e,t,n){let{value:r,error:i}=ZM(n?`projects`:void 0,()=>e.listProjects(),t);return{list:r,error:i}}function VX(e,t,n){let{value:r,error:i,loading:a}=ZM(t,()=>t===`none`?e.listProjects().then(e=>{let t=kX(e.projects,hX);if(t===void 0)throw Error(`no runs without a project`);return t}):e.getProject(t??``),n);return{group:r,error:i,loading:a}}function HX(e,t,n,r,i=!0){let[a,o]=(0,U.useState)(),[s,c]=(0,U.useState)(),[l,u]=(0,U.useState)(!0),[d,f]=(0,U.useState)(),[p,m]=(0,U.useState)([]),[h,g]=(0,U.useState)(),[_,v]=(0,U.useState)(),[y,b]=(0,U.useState)(0),[x,S]=(0,U.useState)(!1),C=a===void 0?void 0:a.runs.some(({run_id:e})=>e===t)?t:t!==void 0||i?a.runs.at(0)?.run_id:void 0,[w,T]=(0,U.useState)(0),E=n===void 0?void 0:n.nodeId??`run`,D=(0,U.useRef)(C);(0,U.useEffect)(()=>{D.current=C},[C]);let O=(0,U.useRef)(void 0),k=(0,U.useRef)(void 0),A=(0,U.useRef)(!1),j=(0,U.useCallback)(()=>{g(void 0),v(void 0)},[]),M=(0,U.useCallback)(async()=>{o(await e.listRuns(!0))},[e]),N=(0,U.useRef)(void 0),P=(0,U.useCallback)(async()=>{let t=a?.next_cursor;if(!(t===void 0||N.current===t)){N.current=t,S(!0);try{let n=await e.listRuns(!0,t);o(e=>e===void 0?n:{...n,runs:[...e.runs,...n.runs.filter(({run_id:t})=>!e.runs.some(e=>e.run_id===t))]}),j()}catch(e){g(KX(e))}finally{N.current=void 0,S(!1)}}},[e,a,j]),ee=(0,U.useCallback)(async t=>{let n=await e.selectRuns([t]);o(e=>{if(e===void 0)return e;if(n.missing?.includes(t)===!0)return{...e,runs:e.runs.filter(e=>e.run_id!==t)};let r=n.runs.find(e=>e.run_id===t);return r===void 0?e:{...e,runs:e.runs.some(e=>e.run_id===t)?e.runs.map(e=>e.run_id===t?r:e):[r,...e.runs]}})},[e]),F=(0,U.useCallback)(async()=>{try{await M(),j()}catch(e){g(KX(e))}finally{u(!1)}},[M,j]),I=(0,U.useCallback)(async()=>{await F(),b(e=>e+1)},[F]);(0,U.useEffect)(()=>{if(C===void 0){c(void 0),k.current=void 0;return}let t=e=>e.runId===C&&e.timelineScope===E&&e.filter===r,i=WX(C,E,r);O.current=i,c(e=>{if(e!==void 0&&t(e))return e;let n=e?.runId===C&&e.filter===r&&e.detail!==void 0?e.detail:void 0;return{runId:C,filter:r,timelineScope:E,...n===void 0?{}:{detail:n}}});let a=e=>{c(n=>n!==void 0&&t(n)?e(n):n)},o=e=>{O.current===i&&e()},s=k.current;if(s?.key===i){s.again=!0;return}let l=()=>{k.current={key:i,again:!1};let t=()=>{let e=k.current;if(e?.key===i){if(e.again){l();return}k.current=void 0}},s=e.getRun(C,{includeConversations:!1,filter:r}).then(e=>{a(t=>({...t,detail:e})),o(j)}).catch(UX).catch(e=>{o(()=>g(KX(e)))}),c=n===void 0?Promise.resolve():e.getTimeline(C,n.nodeId,r).then(e=>a(t=>({...t,timeline:e,timelineError:void 0}))).catch(UX).catch(e=>a(t=>({...t,timelineError:KX(e)})));Promise.all([s,c]).then(t,t)};l()},[e,C,y,n?.nodeId,E,r]),(0,U.useEffect)(()=>{F();let t=e.subscribe({onEvent:e=>{if(f(new Date().toISOString()),v(void 0),e.event===`snapshot`){o(HM(e.data)),A.current&&(b(e=>e+1),T(e=>e+1)),A.current=!0;return}let t=GX(e);t!==void 0&&(T(e=>e+1),ee(t).catch(e=>g(KX(e))),t===D.current&&b(e=>e+1))},onError:e=>{v(KX(e))}});return()=>t.close()},[e,ee,F]),(0,U.useEffect)(()=>{if(C===void 0){m([]);return}let t=e.subscribe({runId:C,filter:r,onEvent:e=>{if(f(new Date().toISOString()),v(void 0),e.event!==`snapshot`){if(e.event===`activity.changed`){let t=e.data.activity;m(Yj.parse(t))}(e.event===`conversation.changed`||e.event===`activity.changed`||e.event===`run.changed`)&&b(e=>e+1)}},onError:e=>v(KX(e))});return()=>t.close()},[e,C,r]);let L=s!==void 0&&s.runId===C&&s.filter===r?s:void 0;return(0,U.useMemo)(()=>({list:a,runId:C,detail:L?.detail,timeline:L?.timeline,timelineError:L?.timelineError,loading:l,lastUpdated:d,activity:p,error:h??_,refresh:I,loadMore:P,hasMore:a?.next_cursor!==void 0,loadingMore:x,invalidations:w}),[a,C,L,l,d,p,h,_,I,P,x,w])}function UX(e){if(!(e instanceof UM&&e.code===`run_not_found`))throw e}function WX(e,t,n){return[e,t??``,n??``].join(`\0`)}function GX(e){let t=`run_id`in e.data?e.data.run_id:void 0;return typeof t==`string`&&t.length>0?t:void 0}function KX(e){return e instanceof Error?e:typeof Event<`u`&&e instanceof Event?Error(`Live telemetry stream disconnected`):Error(String(e))}var qX={minutes:60,seconds:1},JX=e=>Object.hasOwn(qX,e),YX=600%qX.minutes==0?{amount:String(600/qX.minutes),unit:`minutes`}:{amount:`600`,unit:`seconds`};function XX(e){let t=e.amount.trim();if(!/^\d+$/u.test(t))return;let n=Number(t)*qX[e.unit];return Number.isSafeInteger(n)?n:void 0}function ZX(e){if(e===0)return`no grace`;let t=Math.floor(e/60),n=e%60,r=(e,t)=>`${e} ${t}${e===1?``:`s`}`;return t===0?r(n,`second`):n===0?r(t,`minute`):`${r(t,`minute`)} ${r(n,`second`)}`}function QX(e,t){let n=e?.session_key;return t!==null&&n!==void 0&&n===t}function $X(e,t,n){let r=QX(t,n);return{runId:e,owner:r?`this session (${zY(t)})`:zY(t),mine:r,unowned:t?.session_key===void 0}}function eZ(e,t,n){let r=t.map(e=>$X(e.run_id,e.launch,n));return e===`mine`?r.filter(e=>e.mine):r}function tZ(e,t){return t instanceof UM&&t.status!==void 0&&t.code!==void 0?{phase:`refused`,sent:e,error:t}:{phase:`lost`,sent:e,error:t instanceof Error?t:Error(String(t))}}var nZ={dispatchStopped:`dispatch-stopped`,hostShutdown:`host-shutdown`};function rZ(e,t,n){let r=new Set(e.runs.map(({runId:e})=>e)),i=Object.values(nZ);return n.flatMap(e=>{if(!r.has(e.run_id))return[];let n=e.last_event;if(n===null||!i.includes(n))return[];let a=t.get(e.run_id);return a!==void 0&&a.last_event===n&&a.last_progress_at===e.last_progress_at?[]:[{runId:e.run_id,recorded:n===nZ.hostShutdown?nZ.hostShutdown:nZ.dispatchStopped}]})}function iZ(e){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).format(e)}var aZ={run:`Shut down this run?`,mine:`Shut down all my runs?`,host:`Shut down the entire host?`},oZ=`Each live dispatch is asked to stop and commit, and given the grace to end itself; whatever is still standing then is torn down, and every branch the run's records name is pushed to its origin. Nothing is sent until you confirm.`;function sZ({scope:e,open:t,onOpenChange:n,runs:r,blocked:i,runId:a,unreadable:o=0,onConfirm:s}){let c=(0,U.useId)(),[l,u]=(0,U.useState)(YX),[d,f]=(0,U.useState)(!1),p=XX(l),m=r!==void 0&&i===void 0,h=r?.filter(e=>!e.mine)??[],g=r?.filter(e=>e.mine)??[],_=h.filter(e=>e.unowned).length,v=()=>{u(YX),f(!1),n(!1)};return(0,G.jsx)(yc,{onOpenChange:e=>e?n(!0):v(),open:t,children:(0,G.jsxs)(Cc,{className:`shutdown-dialog`,children:[(0,G.jsxs)(wc,{children:[(0,G.jsx)(Ec,{children:e===`run`&&a!==void 0?`Shut down ${a}?`:aZ[e]}),(0,G.jsx)(Dc,{children:oZ})]}),(0,G.jsxs)(`div`,{className:`shutdown-dialog-body`,children:[i===void 0?r===void 0?(0,G.jsx)(`p`,{className:`shutdown-blocked`,role:`status`,children:`Reading which runs this acts on…`}):e===`run`?(0,G.jsx)(lZ,{run:r[0]}):e===`mine`?r.length===0?(0,G.jsx)(`p`,{className:`shutdown-scope-note`,children:`This session owns no run here, so this acts on none: nothing will be signalled and nothing pushed.`}):(0,G.jsx)(uZ,{caption:`It acts on the ${cZ(r.length)} this session owns, and on no other session's:`,label:`Runs this shutdown acts on`,runs:r}):(0,G.jsxs)(G.Fragment,{children:[h.length>0?(0,G.jsx)(uZ,{caption:`It acts on ${cZ(h.length)} other sessions own${_>0?` (or that no session is recorded as owning)`:``}, over their owners — each is interrupted, torn down and pushed as if it were yours:`,label:`Runs other sessions own`,runs:h,warning:!0}):(0,G.jsx)(`p`,{className:`shutdown-scope-note`,children:`No run here is another session's.`}),g.length>0&&(0,G.jsx)(uZ,{caption:`And on the ${cZ(g.length)} this session owns:`,label:`Runs this session owns`,runs:g}),r.length===0&&(0,G.jsx)(`p`,{className:`shutdown-scope-note`,children:`This view lists no run on this host, so this acts on none.`})]}):(0,G.jsx)(`p`,{className:`shutdown-blocked`,role:`status`,children:i}),e!==`run`&&o>0&&(0,G.jsxs)(`p`,{className:`shutdown-scope-note`,children:[o===1?`1 run root on this host could not be read`:`${o} run roots on this host could not be read`,`: the engine cannot read them either, so this shutdown signals nothing in them and pushes none of their branches.`]}),(0,G.jsxs)(`fieldset`,{className:`shutdown-grace`,children:[(0,G.jsx)(`legend`,{children:`Grace`}),(0,G.jsxs)(`div`,{className:`shutdown-grace-row`,children:[(0,G.jsx)(jc,{className:`sr-only`,htmlFor:`${c}-grace`,children:`Grace`}),(0,G.jsx)(Oc,{"aria-describedby":`${c}-grace-help`,"aria-invalid":p===void 0,id:`${c}-grace`,inputMode:`numeric`,min:0,onChange:e=>u({...l,amount:e.target.value}),step:1,type:`number`,value:l.amount}),(0,G.jsx)(jc,{className:`sr-only`,htmlFor:`${c}-unit`,children:`Grace unit`}),(0,G.jsx)(`select`,{className:`composer-select`,id:`${c}-unit`,onChange:e=>{let t=e.target.value;JX(t)&&u({...l,unit:t})},value:l.unit,children:Object.keys(qX).map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})]}),(0,G.jsx)(`p`,{className:`channel-age`,id:`${c}-grace-help`,children:p===void 0?`The grace is a whole number of minutes or seconds, 0 or more.`:`How long each live dispatch has to end itself once asked: ${ZX(p)}. The engine's default is ${ZX(XX(YX)??0)}.`})]}),(0,G.jsxs)(`div`,{className:`composer-check shutdown-force`,children:[(0,G.jsx)(`input`,{checked:d,id:`${c}-force`,onChange:e=>f(e.target.checked),type:`checkbox`}),(0,G.jsx)(jc,{htmlFor:`${c}-force`,children:`Force: skip the interrupt and the wait and go straight to the teardown — whatever a worker had not committed is lost.`})]})]}),(0,G.jsxs)(Tc,{children:[(0,G.jsx)(xc,{asChild:!0,children:(0,G.jsx)(La,{type:`button`,variant:`outline`,children:`Cancel`})}),(0,G.jsx)(La,{disabled:!m||p===void 0,onClick:()=>{p!==void 0&&(s(p,d),v())},type:`button`,variant:`destructive`,children:e===`run`?`Shut down run`:e===`mine`?`Shut down my runs`:`Shut down the host`})]})]})})}var cZ=e=>e===1?`1 run`:`${e} runs`;function lZ({run:e}){return e===void 0?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(uZ,{caption:`It acts on this run alone:`,label:`Runs this shutdown acts on`,runs:[e]}),!e.mine&&(0,G.jsxs)(`p`,{className:`shutdown-scope-note`,role:`note`,children:[e.runId,` is owned by `,e.owner,`, not by this session, so the engine will refuse this shutdown and signal nothing. Shutting the entire host down is what acts on another session's run.`]})]})}function uZ({caption:e,label:t,runs:n,warning:r=!1}){return(0,G.jsxs)(`div`,{className:`shutdown-runs`,"data-warning":r,children:[(0,G.jsx)(`p`,{className:`shutdown-scope-note`,children:e}),(0,G.jsx)(`ul`,{"aria-label":t,children:n.map(e=>(0,G.jsxs)(`li`,{children:[(0,G.jsx)(`span`,{className:`shutdown-run-id`,children:e.runId}),` — owned by `,e.owner]},e.runId))})]})}function dZ(e){return e.value===void 0?e.error===void 0?{blocked:`Reading which session this server acts as…`}:{blocked:`Which session this server acts as could not be read (${e.error.message}), so the runs this acts on cannot be named. Nothing can be sent until they can.`}:{acting:e.value.session_key??null}}function fZ(e,t,n,r){let[i,a]=(0,U.useState)(),[o,s]=(0,U.useState)(0),c=ZM(i===void 0?void 0:`acting-${o}`,()=>e.unwatched(),0),l=pZ(i!==void 0,t,n,r),{acting:u,blocked:d}=dZ(c);return{open:i,setOpen:a,opener:e=>()=>{s(e=>e+1),a(e)},runs:u===void 0||l.rows===void 0||i===void 0?void 0:eZ(i,l.rows,u),blocked:d??l.blocked,unreadable:t?.unreadable?.length??0}}function pZ(e,t,n,r){let i=(0,U.useRef)(new Set),a=t?.next_cursor;return(0,U.useEffect)(()=>{if(!e){i.current.clear();return}a===void 0||r||i.current.has(a)||(i.current.add(a),n())},[e,a,r,n]),t===void 0?{blocked:`Reading the runs listing this view holds…`}:a===void 0?{rows:t.runs}:!r&&i.current.has(a)?{blocked:`The rest of the runs listing could not be read (${t.runs.length} runs read), so the runs this acts on cannot all be named. Close this and try again.`}:{blocked:`Reading the rest of the runs listing so every run this acts on can be named (${t.runs.length} read so far)…`}}function mZ(e,t){let[n,r]=(0,U.useState)({phase:`idle`}),i=(0,U.useRef)(!1);return{state:n,confirm:(0,U.useCallback)((n,a,o)=>{if(i.current)return;i.current=!0;let s={scope:e,runs:n,grace:a,force:o,sentAt:Date.now()};r({phase:`sending`,sent:s}),t({grace:a,force:o}).then(e=>r({phase:`answered`,sent:s,report:e}),e=>r(tZ(s,e))).finally(()=>{i.current=!1})},[e,t]),dismiss:(0,U.useCallback)(()=>{i.current||r({phase:`idle`})},[])}}var hZ=[`mine`,`host`];function gZ({runId:e,launched:t,unwatched:n,shutdown:r}){let[i,a]=(0,U.useState)(!1),{acting:o,blocked:s}=dZ(n),c=o===void 0||t===void 0?void 0:[$X(e,t.launch,o)];return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(La,{"aria-label":`Shut down this run`,disabled:r.state.phase===`sending`,onClick:()=>a(!0),size:`sm`,title:`Shut down this run`,type:`button`,variant:`destructive`,children:[(0,G.jsx)($t,{size:14}),(0,G.jsx)(`span`,{className:`run-action-label`,children:`Shut down`})]}),(0,G.jsx)(sZ,{blocked:s??(t===void 0?`Reading who launched ${e}…`:void 0),onConfirm:(e,t)=>c!==void 0&&r.confirm(c,e,t),onOpenChange:a,open:i,runId:e,runs:c,scope:`run`})]})}function _Z(e,t){return mZ(`run`,(0,U.useCallback)(n=>t===void 0?Promise.reject(Error(`No run is open to shut down`)):e.shutdownRun(t,n),[e,t]))}function vZ(e){return{mine:mZ(`mine`,(0,U.useCallback)(t=>e.shutdown(`mine`,t),[e])),host:mZ(`host`,(0,U.useCallback)(t=>e.shutdown(`host`,t),[e]))}}function yZ({client:e,list:t,loadMore:n,loadingMore:r,shutdowns:i}){let{open:a,setOpen:o,opener:s,runs:c,blocked:l,unreadable:u}=fZ(e,t,n,r),d=i.mine.state.phase===`sending`||i.host.state.phase===`sending`;return(0,G.jsxs)(`fieldset`,{"aria-label":`Shut down runs on this host`,className:`host-shutdown`,children:[(0,G.jsx)(`p`,{className:`eyebrow`,children:`This host`}),(0,G.jsxs)(`div`,{className:`host-shutdown-actions`,children:[(0,G.jsxs)(La,{disabled:d,onClick:s(`mine`),size:`sm`,type:`button`,variant:`outline`,children:[(0,G.jsx)($t,{size:14}),` Shut down all my runs`]}),(0,G.jsxs)(La,{disabled:d,onClick:s(`host`),size:`sm`,type:`button`,variant:`destructive`,children:[(0,G.jsx)($t,{size:14}),` Shut down the entire host`]})]}),hZ.map(e=>(0,G.jsx)(sZ,{blocked:l,onConfirm:(t,n)=>c!==void 0&&i[e].confirm(c,t,n),onOpenChange:t=>o(t?e:void 0),open:a===e,runs:a===e?c:void 0,scope:e,unreadable:u},e))]})}var bZ=1e3;function xZ(e,t){let[n,r]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),bZ);return()=>clearInterval(e)},[]);let i=rZ(e,(0,U.useRef)(new Map(t.filter(t=>e.runs.some(({runId:e})=>e===t.run_id)).map(e=>[e.run_id,e]))).current,t);return{now:n,progress:i,done:i.filter(({recorded:e})=>e===nZ.hostShutdown).length,deadline:e.sentAt+e.grace*1e3,asks:!e.force&&e.grace>0}}function SZ({label:e,state:t,rows:n,onDismiss:r}){return t.phase===`idle`?null:(0,G.jsxs)(`section`,{"aria-label":e,className:`shutdown-status`,children:[t.phase===`sending`?(0,G.jsx)(wZ,{rows:n,sent:t.sent}):t.phase===`lost`?(0,G.jsxs)(ua,{"aria-label":`${e} lost`,variant:`destructive`,children:[(0,G.jsx)(ln,{}),(0,G.jsx)(da,{children:`Shutdown lost: no answer came back`}),(0,G.jsxs)(fa,{children:[(0,G.jsxs)(`p`,{children:[`The request sent at `,iZ(t.sent.sentAt),` ended without an answer (`,t.error.message,`). The engine may still be carrying out the shutdown — check the runs before sending another.`]}),(0,G.jsx)(CZ,{sent:t.sent})]})]}):t.phase===`refused`?(0,G.jsxs)(ua,{"aria-label":`${e} refused`,variant:`destructive`,children:[(0,G.jsx)(cn,{}),(0,G.jsxs)(da,{children:[`Shutdown refused · `,t.error.status,` `,t.error.code]}),(0,G.jsxs)(fa,{children:[(0,G.jsx)(`pre`,{className:`verb-text`,children:t.error.message}),(0,G.jsx)(`p`,{children:`Nothing was signalled and nothing was pushed.`})]})]}):(0,G.jsx)(EZ,{label:e,report:t.report}),t.phase!==`sending`&&(0,G.jsx)(`div`,{className:`composer-actions`,children:(0,G.jsx)(La,{onClick:r,size:`sm`,type:`button`,variant:`outline`,children:`Dismiss`})})]})}function CZ({sent:e}){return(0,G.jsxs)(`p`,{className:`channel-age`,children:[`Sent `,iZ(e.sentAt),` · scope `,e.scope,` · grace`,` `,ZX(e.grace),e.force?` · forced`:``,` · `,e.runs.length,` `,e.runs.length===1?`run`:`runs`,` in scope`]})}function wZ({sent:e,rows:t}){let{now:n,progress:r,done:i,deadline:a,asks:o}=xZ(e,t);return(0,G.jsxs)(`div`,{"aria-live":`polite`,className:`shutdown-inflight`,role:`status`,children:[(0,G.jsxs)(`p`,{className:`shutdown-inflight-head`,children:[(0,G.jsx)(Ut,{"aria-hidden":`true`,className:`animate-spin`,size:14}),(0,G.jsx)(`strong`,{children:`Shutdown in progress`}),` — still waiting for the engine's answer, `,ZP(Math.max(0,n-e.sentAt)),` after it was sent.`]}),(0,G.jsx)(CZ,{sent:e}),(0,G.jsx)(`p`,{children:o?n<a?`Waiting out the ${ZX(e.grace)} grace until ${iZ(a)} (${ZP(a-n)} left) for each live dispatch to end itself; runs are worked through one after another, each with its own grace.`:`The first grace ran out at ${iZ(a)}; the engine is tearing down what is still standing and pushing branches, run by run.`:`Forced: nothing is asked or waited for; the engine is tearing the runs down and pushing their branches.`}),(0,G.jsxs)(`p`,{children:[i,` of `,e.runs.length,` `,e.runs.length===1?`run has`:`runs have`,` recorded their shutdown.`]}),r.length>0&&(0,G.jsx)(`ul`,{"aria-label":`Recorded so far`,children:r.map(({runId:e,recorded:t})=>(0,G.jsxs)(`li`,{children:[e,`:`,` `,t===nZ.hostShutdown?`put down — host-shutdown recorded after its teardown and pushes`:`its dispatches are stopping — dispatch-stopped recorded`]},e))})]})}function TZ(e){let t=e.remote===null?``:` to ${e.remote}`,n=e.commit===null?``:` at ${e.commit}`;switch(e.result){case`pushed`:return`pushed${t}${n}`;case`already-on-origin`:return`already on its origin${t}${n}; nothing was pushed`;case`no-remote`:return`not pushed: this identity has no origin${n}`;case`refused`:return`could not be preserved${n}`}}function EZ({label:e,report:t}){return(0,G.jsxs)(ua,{"aria-label":`${e} report`,variant:t.complete?`default`:`destructive`,children:[t.complete?(0,G.jsx)(Et,{}):(0,G.jsx)(cn,{}),(0,G.jsx)(da,{children:t.complete?`Shutdown complete`:`Shutdown incomplete`}),(0,G.jsxs)(fa,{className:`shutdown-report`,children:[!t.complete&&(0,G.jsx)(`p`,{children:`Not everything went as asked: a dispatch was killed at the deadline or is still running, a teardown was not clean, or a branch could not be preserved. Read the runs below.`}),(0,G.jsxs)(`p`,{className:`channel-age`,children:[`Scope `,t.scope,` · grace `,ZX(t.grace_seconds),t.forced?` · forced`:``,` · runs root `,t.root]}),t.runs.length===0?(0,G.jsx)(`p`,{children:`No run was selected: nothing was signalled.`}):t.runs.map(e=>(0,G.jsxs)(`section`,{"aria-label":`Shutdown of ${e.run_id}`,className:`shutdown-report-run`,children:[(0,G.jsxs)(`h4`,{children:[e.run_id,` · owner `,e.owner,e.forced_over_owner&&` — another session's run, acted on over its owner`]}),e.dispatches.length===0?(0,G.jsx)(`p`,{children:`No live dispatch to interrupt.`}):(0,G.jsx)(`ul`,{"aria-label":`Dispatches of ${e.run_id}`,children:e.dispatches.map(e=>(0,G.jsxs)(`li`,{children:[e.node,` (pid `,e.pid,`): interrupt`,` `,e.interrupt,`; ended `,e.ended,` after`,` `,ZP(e.waited_ms),(0,G.jsxs)(`span`,{className:`channel-age`,children:[` — `,e.detail]})]},`${e.node}-${e.pid}`))}),(0,G.jsxs)(`p`,{children:[`Teardown: `,e.teardown]}),e.branches.length===0?(0,G.jsx)(`p`,{children:`No branch this run's records name.`}):(0,G.jsx)(`ul`,{"aria-label":`Branches of ${e.run_id}`,children:e.branches.map(e=>(0,G.jsxs)(`li`,{children:[e.identity,`@`,e.branch,`: `,TZ(e),(0,G.jsxs)(`span`,{className:`channel-age`,children:[` — `,e.detail]})]},`${e.identity}@${e.branch}`))})]},e.run_id)),t.not_pushed_unread===null?t.not_pushed.length===0?(0,G.jsx)(`p`,{children:`Other unpublished branches on this host: none.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`p`,{children:[`Other unpublished branches on this host, which this shutdown did not push (`,t.not_pushed.length,`):`]}),(0,G.jsx)(`ul`,{"aria-label":`Branches not pushed`,children:t.not_pushed.map(({identity:e,branch:t})=>(0,G.jsxs)(`li`,{children:[e,`@`,t]},`${e}@${t}`))})]}):(0,G.jsxs)(`p`,{children:[`Other unpublished branches on this host: not read —`,` `,t.not_pushed_unread,`. This is not a count of zero: there may be work on this host nothing outside it carries.`]}),(0,G.jsxs)(`details`,{children:[(0,G.jsx)(`summary`,{children:`The engine's own report`}),(0,G.jsx)(`pre`,{className:`verb-text`,children:t.rendered})]})]})]})}function DZ({control:e}){if(e===void 0)return null;let t=e.addressable?`Turn reachable`:`No turn to reach`,n=e.addressable?`a planner's note can be delivered into the ${e.member??`member`} turn in flight`:e.reason,r=e.addressable?qt:Gt;return(0,G.jsxs)(Fa,{"aria-label":`${t}: ${n}`,className:H(`node-view-control gap-1.5`,e.addressable?`border-info bg-info-surface text-info`:`border-warning bg-warning-surface text-warning`),title:n,variant:`outline`,children:[(0,G.jsx)(r,{"aria-hidden":`true`,size:12}),t]})}function OZ(e){return e.charAt(0).toUpperCase()+e.slice(1)}var kZ=[[`recovery`,[`retry`,`retried`,`requeued`,`fallback`,`resolution`,`interrupted`,`cron`]],[`failure`,[`failed`,`died`,`rejected`,`exceeded`,`conflict`]],[`human`,[`human`]],[`planning`,[`planner`,`decision`,`note`]],[`contention`,[`lock`,`concurrent`,`quiet`,`wait`,`held`,`unheld`]],[`verification`,[`verification`,`gate`,`check`,`checks`,`coverage`,`judge`]],[`publication`,[`pr`,`publication`,`published`,`release`,`merge`,`merged`,`change`,`drafting`]],[`repository`,[`edit`,`fetch`,`push`,`branch`,`branches`,`commit`]],[`session`,[`turn`,`member`,`session`,`heartbeat`,`conversation`]],[`lifecycle`,[`run`,`graph`,`node`,`round`,`step`,`edge`,`setup`,`cleanup`,`driver`,`cross`,`upstream`]]],AZ={"completion-requested":`lifecycle`,"command-accepted":`planning`,"body-not-drafted":`publication`,"criterion-checked":`verification`,"pool-maintenance":`lifecycle`,"dispatch-stopped":`lifecycle`,"host-shutdown":`lifecycle`};function jZ(e){return e.toLowerCase().split(`-`).filter(e=>e.length>0)}function MZ(e){let t=AZ[e];if(t!==void 0)return t;let n=jZ(e);return kZ.find(([,e])=>e.some(e=>n.includes(e)))?.[0]??`activity`}var NZ={recovery:tn,failure:cn,human:un,planning:kt,contention:Rt,verification:on,publication:Lt,repository:It,session:Jt,lifecycle:Yt,activity:Ot};function PZ({category:e,className:t=`size-3`}){let n=NZ[e];return(0,G.jsx)(n,{"aria-hidden":`true`,className:t})}function FZ(e){return e===`human-step`?`human step`:e}function IZ(e){return e.style===`human-step`}function LZ(e){switch(e){case`not-released`:return`not released yet`;case`awaiting-human-step`:return`waiting for the human step`;case`not-answered`:return`the registry did not answer`;case`not-landed`:return`released, but not carrying this work yet`;default:return e}}function RZ(e){if(e!==void 0)return e?`yes — a later acknowledgement replaced this one`:`no`}function zZ(e){if(e!==void 0)return e===`live`?`Live — into the turn that was already running`:e===`deferred`?`Deferred — onto the node's next dispatch`:e}function BZ(e){return[e.identity,e.target].filter(Boolean).join(` · `)||e.dep}function VZ({release:e}){let t=[[`Dependency`,e.dep],[`Identity`,e.identity],[`Release target`,e.target],[`Style`,e.style===void 0?void 0:FZ(e.style)],[`Version`,e.version],[`Probe outcome`,e.outcome],[`Probed through`,e.form],[`Probe took`,e.elapsed_ms===void 0?void 0:`${e.elapsed_ms} ms`],[`Acknowledged by`,e.actor],[`Superseded`,RZ(e.superseded)],[`Landed as`,e.landing_commit],[`Adopted`,zZ(e.delivery)]].filter(([,e])=>e!==void 0);return(0,G.jsxs)(G.Fragment,{children:[t.length>0&&(0,G.jsx)(`dl`,{className:`facts`,children:t.map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:e}),(0,G.jsx)(`dd`,{children:t})]},e))}),e.awaiting!==void 0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Held on`}),(0,G.jsx)(`ul`,{className:`release-awaiting`,children:e.awaiting.map(e=>(0,G.jsxs)(`li`,{children:[IZ(e)?(0,G.jsxs)(ua,{children:[(0,G.jsx)(un,{}),(0,G.jsxs)(da,{children:[`Waiting on a person · `,BZ(e)]}),(0,G.jsx)(fa,{children:e.action??`The release is a human step and the run recorded no action for it.`})]}):(0,G.jsxs)(`p`,{className:`detail-note`,children:[`Waiting on an automated release · `,BZ(e)]}),(0,G.jsx)(`p`,{className:`detail-note`,children:[e.last_answer===void 0?void 0:LZ(e.last_answer),e.waited_seconds===void 0?void 0:`waited ${e.waited_seconds}s`].filter(e=>e!==void 0).join(` · `)})]},`${e.dep}·${e.identity??``}·${e.target??``}`))})]}),e.versions!==void 0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Versions adopted`}),(0,G.jsx)(`ul`,{className:`release-awaiting`,children:e.versions.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsxs)(`p`,{className:`detail-note`,children:[e.identity,` · `,e.target,` · `,e.version]})},`${e.identity}·${e.target}`))})]})]})}function HZ({node:e}){let t=e.result?.release??void 0;if(t===void 0)return(0,G.jsx)(G.Fragment,{children:`Not recorded`});let n=t.identity!==e.task.repo;return(0,G.jsx)(G.Fragment,{children:[t.target,t.style===void 0?void 0:FZ(t.style),t.version,n?t.identity:void 0].filter(e=>e!==void 0).join(` · `)})}function UZ(e){return{kind:e.displayKind,label:e.displayLabel,startedAt:e.startedAt,...e.durationMs===null?{}:{duration:ZP(e.durationMs)},running:e.endedAt===null&&e.rowKind===`span`,...e.status?{status:e.status}:{}}}function WZ({row:e}){let t=UZ(e);return(0,G.jsxs)(`header`,{className:`detail-title`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(Fa,{className:`mb-1`,variant:`outline`,children:t.kind}),(0,G.jsx)(`h2`,{children:t.label}),(0,G.jsxs)(`p`,{className:`detail-when`,children:[(0,G.jsx)(iF,{at:t.startedAt}),t.duration!==void 0&&` · ${t.duration}`,t.running&&` · still running`]})]}),t.status!==void 0&&(0,G.jsx)(Fa,{variant:`secondary`,children:t.status})]})}function GZ(e){let t=UZ(e);return[t.kind,t.label,eF(t.startedAt),OZ(e.category),t.status].filter(e=>e!==void 0&&e.length>0).join(` · `)}function KZ({row:e}){return(0,G.jsx)(`span`,{className:`timeline-marker-reading`,"data-timeline-reading":GZ(e),children:(0,G.jsx)(PZ,{category:e.category})})}var qZ=`data-timeline-reading`;function JZ(e){let t=e.closest(`[${qZ}]`)??e.closest(`button`)?.querySelector(`[${qZ}]`);if(!(t instanceof HTMLElement))return;let n=t.getAttribute(qZ)?.trim();return n===void 0||n.length===0?void 0:{element:t,detail:n}}var YZ={rows:[],total:0},XZ={queued:`Queued`,dispatch:`Dispatch`,verification:`Verification`,publication:`Publication`,"lock-waits":`Lock waits`,"human-wait":`Human wait`},ZZ=`idle`,QZ=new Set([...Object.keys(XZ),ZZ]),$Z=`member:`;function eQ(e){return QZ.has(e)?`${$Z}${e}`:e}var tQ=Object.entries(XZ).map(([e,t])=>({id:e,label:t}));function nQ(e){let t=e?.spans??[],n=[];for(let e of t){let t=e.agent_role;t!==void 0&&!n.includes(t)&&n.push(t)}let r=t.some(e=>TQ(e)===`dispatch`),[i,...a]=tQ;return[...i===void 0?[]:[i],...n.map(e=>({id:eQ(e),label:e})),...a.filter(({id:e})=>r||e!==`dispatch`)]}var rQ={run:null,node:null,step:null,dispatch:`dispatch`,verification:`verification`,publication:`publication`,"pr-drafting":`dispatch`,"conflict-resolution":`publication`,"human-wait":`human-wait`,queued:`queued`,rollup:`lock-waits`};function iQ(e){return e===`agent`}function aQ(e,t){return e===void 0?t===void 0?XZ.dispatch:oQ(t):HQ(t)&&t!==e?`${e} · ${t}`:e}function oQ(e){return e===`llmlint`?`Lint`:`${e[0]?.toUpperCase()??``}${e.slice(1)}`}var sQ={"lock-wait":`Lock waits`};function cQ(e,t=tQ){let n=[...e].sort((e,t)=>e.start-t.start),r=n.at(0)?.start??0,i=Math.max(r+1,...n.map(e=>e.end??e.start)),a=new Set([n.at(0),n.reduce((e,t)=>e===void 0||(t.end??t.start)>(e.end??e.start)?t:e,void 0)].filter(e=>e!==void 0).map(({id:e})=>e)),o=(i-r)*.02,s=[];for(let e of n){let n=Math.max(e.end??e.start,e.start+o),r=s.findLast(t=>{let r=Math.max(t.end??t.start,t.start+o);return e.start<=r&&t.start<=n});r===void 0||a.has(e.id)?s.push(e):uQ(e,t)<uQ(r,t)?a.has(r.id)?s.push(e):s[s.indexOf(r)]=e:lQ(e,r,o)||s.push(e)}return s}function lQ(e,t,n){return Math.abs(e.start-t.start)<=n&&Math.abs((e.end??e.start)-(t.end??t.start))<=n}function uQ(e,t){let n=e.laneId??``,r=t.findIndex(({id:e})=>e===n);return r<0?t.length:r}function dQ(e,t,n){let r=[...e.map(({at:e})=>e),...t.flatMap(e=>[e.start,e.end??e.start])],i=Math.min(...r),a=(Math.max(...r)-i)*.02,o=[];for(let t of[...e].sort((e,t)=>e.at-t.at)){let e=o.findLast(e=>t.at-e.at<=a);e===void 0?o.push(t):t.id===n&&(o[o.indexOf(e)]=t)}return o}function fQ(e,t){let n=_Q(e,t).rows,r=hQ(n),i=hQ(n,!1).flatMap(e=>{let t=gQ(e);if(t===null)return[];let n=Date.parse(e.startedAt),r=e.endedAt===null?null:Date.parse(e.endedAt),i=e.rowKind===`span`&&e.span.total_duration_ms!==void 0?n+e.span.total_duration_ms:r;return[{id:e.id,label:e.displayLabel,laneId:t,payload:e,start:n,end:i,duration:i===null?null:i-n,status:e.status}]}),a=r.flatMap(e=>e.rowKind===`event`?[{id:e.id,label:e.displayLabel,at:Date.parse(e.startedAt),payload:e,status:e.status,icon:(0,U.createElement)(KZ,{row:e})}]:[]),o=Math.max(...i.map(e=>e.end??e.start),...a.map(e=>e.at));return{items:i.map(e=>e.end===null?{...e,end:o,duration:o-e.start}:e),markers:a,lanes:nQ(e),rows:r,tree:n}}function pQ(e,t){let n=new Set,r=[],i=e=>{for(let a of e){if(a.rowKind===`group`){let e=t.has(a.id),n=a.children,o=n.at(0),s=n.at(-1);o!==void 0&&i([o]),r.push({entryKind:`collapse`,group:a,hidden:Math.max(n.length-2,0),expanded:e}),e&&i(n.slice(1,-1)),s!==void 0&&s!==o&&i([s]);continue}n.has(a.id)||(n.add(a.id),r.push({entryKind:`row`,row:a})),i(a.children)}};return i(e),r}function mQ(e,t){return`${e} more ${t} events`}function hQ(e,t=!0){let n=new Set,r=[],i=e=>{for(let a of e)n.has(a.id)||(n.add(a.id),r.push(a)),(t||a.rowKind!==`group`)&&i(a.children)};return i(e),r}function gQ(e){return e.rowKind===`event`?null:e.role===void 0?rQ[e.rowKind===`span`?e.span.kind:e.kind]??null:eQ(e.role)}function _Q(e,t){if(e===void 0)return YZ;let n=e.spans.filter(e=>e.node_id===t);if(n.length===0){let n=WQ(e.spans,new Set,t);return n.length===0?YZ:{rows:FQ(n),total:n.length}}let r=new Set(n.map(({id:e})=>e)),i=new Map,a=[];for(let e of n){let t=e.parent_id!==void 0&&r.has(e.parent_id)?e.parent_id:void 0;t===void 0?a.push(e):i.set(t,[...i.get(t)??[],e])}let o=a.find(({kind:e})=>e===`node`),s=FQ(VQ(BQ([...o===void 0?[]:SQ(o,i),...a.filter(e=>e!==o).map(e=>CQ(e,i)),...WQ(e.spans,r,t)].sort(KQ))));return{span:o,rows:s,total:GQ(s)}}function vQ(e){return CQ(e,new Map)}function yQ(e){return PQ(e)}function bQ(e,t){return xQ(e,t).at(-1)}function xQ(e,t){for(let n of e){if(n.id===t)return[n];let e=xQ(n.children,t);if(e.length>0)return[n,...e]}return[]}function SQ(e,t){return[...(t.get(e.id)??[]).map(e=>CQ(e,t)),...e.events.map(PQ)].sort(KQ)}function CQ(e,t){let n=wQ(e),r=e.kind===`dispatch`?e.transport_role:void 0;return{rowKind:`span`,span:e,id:e.id,kind:e.kind,...n===void 0?{}:{role:n},...r===void 0?{}:{transport:r},label:e.label,startedAt:e.started_at,endedAt:e.ended_at,status:e.status,durationMs:e.total_duration_ms??qQ(e.started_at,e.ended_at),children:FQ(SQ(e,t)),displayLabel:zQ(e,n,r),displayKind:IQ(e,n,r),...e.kind===`dispatch`&&e.label?{sessionName:e.label}:{}}}function wQ(e){return e.kind===`dispatch`?e.agent_role:void 0}function TQ(e){return e.agent_role===void 0?rQ[e.kind===`rollup`?e.label:e.kind]??null:eQ(e.agent_role)}function EQ(e,t=[]){let n=t.find(({id:t})=>t===e);return n===void 0?XZ[e]??(e.startsWith($Z)?e.slice(7):e):n.label}function DQ(e){if(e.redirection!==void 0)return e.redirection.delivered?`Redirected into the running turn`:`Redirection deferred to the next dispatch`}var OQ=`Redirection`;function kQ(e){if(e.surface===void 0)return;let t=[e.surface.kind,e.surface.message].filter(e=>e!==void 0);return t.length===0?void 0:t.join(`: `)}var AQ=`Surface`,jQ=`Blocking surface`;function MQ(e){return e.kind.startsWith(`edit-`)?e.author:void 0}function NQ(e,t){let n=MQ(t);return n===void 0?e:`${e} · by ${n}`}function PQ(e){let t=DQ(e),n=kQ(e),r=t===void 0?e.surface===void 0?`Event`:e.surface.blocking===!0?jQ:AQ:OQ;return{rowKind:`event`,event:e,id:e.id,kind:e.kind,label:e.step_id??``,startedAt:e.at,endedAt:null,status:e.status,durationMs:null,children:[],displayLabel:NQ(t??n??(e.kind===`retry-requested`?`Retry requested`:e.step_id??e.kind),e),displayKind:r,category:MZ(e.kind)}}function FQ(e){let t=[];for(let n=0;n<e.length;n+=1){let r=e[n];if(r===void 0)continue;let i=n;for(;i+1<e.length&&UQ(r,e[i+1]);)i+=1;let a=e.slice(n,i+1),o=a.at(-1);a.length<4||o===void 0?t.push(...a):t.push({rowKind:`group`,count:a.length,id:`group-${r.id}`,kind:r.kind,label:`${a.length} × ${r.kind}`,startedAt:r.startedAt,endedAt:o.endedAt,status:void 0,durationMs:qQ(r.startedAt,o.endedAt),children:a,displayLabel:`${a.length} grouped ${r.displayKind.toLowerCase()} activities`,displayKind:r.displayKind}),n=i}return t}function IQ(e,t,n){if(e.kind===`step`)return`Lifecycle`;if(e.kind===`rollup`)return sQ[e.label]??e.label;if(e.kind===`dispatch`)return aQ(t,n);let r=rQ[e.kind];return r===null?e.kind:EQ(r)}function LQ(e){let t=e=>(e??[]).join(`, `);switch(e.kind){case`concurrency`:return e.ahead===void 0?`behind the work already running`:`behind ${t(e.ahead)}`;case`dependencies`:return`waiting on ${t(e.blocking)}`;case`decision`:return`held by decision ${e.reference??`nobody named`}`;case`release`:return`awaiting the release of ${t(e.awaiting)}`;default:return`held by ${e.kind}`}}function RQ(e){return e.map(LQ).join(` and `)}function zQ(e,t,n){if(e.kind===`step`)return e.label?`Lifecycle: ${e.label}`:`Lifecycle step`;if(e.kind===`queued`)return`Queued ${RQ(e.reasons??[])}`.trim();let r=IQ(e,t,n);return e.kind===`rollup`?`${r}: ${e.count??0} recorded`:!e.label||e.label===r?r:e.kind===`dispatch`?`${r} (${e.label})`:`${r}: ${e.label}`}function BQ(e){let t=0;return e.map(e=>{e.rowKind===`event`&&e.event.kind===`retry-requested`&&(t+=1);let n=BQ(e.children);return!iQ(e.transport)||t===0?{...e,children:n}:{...e,children:n,displayLabel:`${e.displayLabel} · retry ${t}`}})}function VQ(e){let t=[],n=-1,r=0,i=(e,t)=>({...e,dispatch:t,children:e.children.map(e=>i(e,t))});for(let a of e){if(iQ(a.transport)){r+=1,n=t.length,t.push(i(a,{id:a.id,label:`Dispatch ${r}`}));continue}let e=n<0?void 0:t[n];if(HQ(a.transport)&&e?.dispatch!==void 0){t[n]={...e,children:[...e.children,i(a,e.dispatch)]};continue}t.push(a)}return t}function HQ(e){return e===`judge`||e===`llmlint`}function UQ(e,t){return t!==void 0&&e.rowKind!==`group`&&t.rowKind===e.rowKind&&e.kind===t.kind}function WQ(e,t,n){return e.filter(({id:e})=>!t.has(e)).flatMap(({events:e})=>e.filter(e=>e.node_id===n)).map(PQ)}function GQ(e){return e.reduce((e,t)=>e+(t.rowKind===`group`?0:1)+GQ(t.children),0)}function KQ(e,t){return e.startedAt.localeCompare(t.startedAt)}function qQ(e,t){if(t===null)return null;let n=Date.parse(e),r=Date.parse(t);return Number.isNaN(n)||Number.isNaN(r)?null:r-n}function JQ(e,t,n,r){let[i,a]=(0,U.useState)(),o=t===void 0||n===void 0?void 0:JSON.stringify([t,n]);(0,U.useEffect)(()=>{if(o===void 0||t===void 0||n===void 0)return;let r=!0;return e.getConversation(t,n).then(e=>{r&&a({key:o,conversation:e})}).catch(e=>{if(!r)return;let t=e instanceof Error?e:Error(String(e));a(e=>e?.key===o&&e.conversation!==void 0?e:{key:o,error:t})}),()=>{r=!1}},[e,t,n,o,r]);let s=i?.key===o?i:void 0;return(0,U.useMemo)(()=>({conversation:s?.conversation,error:s?.error,loading:o!==void 0&&s===void 0}),[s,o])}var YQ=32;function XQ(e){return e===null?null:e.closest(`[data-slot="scroll-area-viewport"]`)??e.parentElement}function ZQ(e,t){let n=(0,U.useRef)(null),r=(0,U.useRef)(!0),i=(0,U.useRef)({key:e,count:t}),a=(0,U.useCallback)(()=>{let e=n.current;e!==null&&(r.current=e.scrollHeight-e.scrollTop-e.clientHeight<=YQ)},[]),o=(0,U.useCallback)(e=>{n.current?.removeEventListener(`scroll`,a),n.current=XQ(e),n.current?.addEventListener(`scroll`,a,{passive:!0}),a()},[a]);return(0,U.useLayoutEffect)(()=>{let a=i.current;i.current={key:e,count:t};let o=a.key===e&&a.count>0&&t>a.count,s=n.current;!o||s===null||!r.current||(s.scrollTop=s.scrollHeight)},[e,t]),o}var QQ=25;function $Q({client:e,runId:t,node:n,row:r}){let i=r===void 0?void 0:_$(r),a=i?.kind===`conversation`?i.value:void 0,o=JQ(e,t,a,r===void 0?void 0:f$(r));return(0,G.jsx)(`section`,{"aria-label":`Timeline item detail`,className:`timeline-detail`,children:(0,G.jsx)(uf,{className:`h-full`,children:(0,G.jsx)(`div`,{className:`p-[22px] max-sm:p-3`,ref:ZQ(a,p$(r,o)),children:r===void 0?(0,G.jsxs)(`div`,{className:`detail-placeholder`,children:[(0,G.jsx)(Ht,{size:30}),(0,G.jsx)(`p`,{children:`Select an item in the timeline to read what it recorded.`})]}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(WZ,{row:r}),(0,G.jsx)(Cf,{className:`my-4`}),(0,G.jsx)(e$,{client:e,runId:t,node:n,reference:i,row:r,transcript:o})]})})})})}function e$({client:e,runId:t,row:n,node:r,reference:i,transcript:a}){let o=m$(n);if(o!==void 0)return(0,G.jsx)(s$,{redirection:o,row:n});let s=h$(n);if(s!==void 0)return(0,G.jsx)(VZ,{release:s});let c=g$(n);return c===void 0?i?.kind===`conversation`?(0,G.jsx)(n$,{row:n,transcript:a}):y$(n)?(0,G.jsx)(r$,{client:e,runId:t,reference:i,row:n}):i?.kind===`worker_report`&&tN(i.value)!==void 0?(0,G.jsx)(i$,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):i?.kind===`oneharness_session`&&tN(i.value)!==void 0?(0,G.jsx)(a$,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):b$(n,i)&&r!==void 0?(0,G.jsx)(o$,{node:r,reference:i}):(0,G.jsx)(u$,{reference:i,row:n}):(0,G.jsx)(l$,{row:n,surface:c})}function t$({turn:e}){return e.judges===void 0||e.judges.length===0?null:(0,G.jsx)(`ul`,{"aria-label":`Judges on turn ${e.id}`,className:`judge-decisions`,children:e.judges.map(e=>(0,G.jsxs)(`li`,{children:[(0,G.jsxs)(`span`,{className:`judge-decision-who`,children:[e.judge,` (`,e.kind,`)`]}),` `,e.decision,` — `,e.reason]},e.judge))})}function n$({row:e,transcript:t}){let[n,r]=(0,U.useState)(QQ),i=t.conversation?.conversation.turns??[],a=e.rowKind===`event`?i.filter(({id:t})=>t===e.event.id):i,o=Om(a.map(e=>({id:e.id,time:Date.parse(e.timestamp)})));if(t.loading)return(0,G.jsxs)(`div`,{"aria-live":`polite`,className:`loading-inline`,children:[(0,G.jsx)(wf,{className:`h-2 w-40`}),(0,G.jsx)(wf,{className:`h-2 w-24`}),`Loading transcript…`]});if(t.conversation===void 0)return(0,G.jsxs)(ua,{variant:`destructive`,children:[(0,G.jsx)(cn,{}),(0,G.jsx)(da,{children:`Transcript unavailable`}),(0,G.jsx)(fa,{children:t.error?.message??`The server recorded no transcript.`})]});let{conversation:s,attribution:c}=t.conversation,l=x$(c.agentRole,c.transportRole);return(0,G.jsx)(Ra,{className:`gap-0 py-3`,children:(0,G.jsxs)(za,{className:`px-3`,children:[(0,G.jsxs)(`header`,{className:`transcript-header`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsxs)(`p`,{className:`eyebrow`,children:[e.dispatch===void 0?``:`${e.dispatch.label} · `,l,c.persona?` · ${c.persona}`:``]}),(0,G.jsx)(`h4`,{children:s.name})]}),(0,G.jsx)(Am,{state:s.state})]}),(0,G.jsx)(Cf,{className:`my-2.5`}),(0,G.jsx)(`div`,{className:`conversation-timeline-sticky`,children:(0,G.jsx)(Dm,{cursor:o.cursor,onSelectTurn:o.scrollTo,turns:[...a]})}),a.length===0?(0,G.jsx)(`p`,{className:`detail-note`,children:`This turn is no longer part of the recorded transcript.`}):(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`div`,{ref:o.containerRef,children:a.slice(0,n).map(e=>(0,G.jsxs)(`div`,{ref:t=>o.register(e.id,t),children:[(0,G.jsx)(ww,{author:{label:l},turn:e}),(0,G.jsx)(t$,{turn:e})]},e.id))}),a.length>n&&(0,G.jsxs)(La,{onClick:()=>r(n+QQ),size:`sm`,type:`button`,variant:`outline`,children:[`Show more of `,a.length,` turns`]})]})]})})}function r$({row:e,client:t,runId:n,reference:r}){let i=e.rowKind===`span`?e.span.detail:void 0,a=i?.artifact_id??(r?.kind===`gate_log`?r.value:void 0);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Verification record`}),(0,G.jsx)(`dl`,{className:`facts`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Result`}),(0,G.jsx)(`dd`,{children:i?.ok===void 0?e.status??`in progress`:i.ok?`passed`:`failed`})]})}),i?.output_tail&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Output`}),(0,G.jsx)(`pre`,{children:i.output_tail})]}),(0,G.jsx)(eN,{artifactId:a,client:t,heading:`Full log`,missing:`No readable log was recorded.`,noun:`log`,runId:n,unreadable:`No readable log was recorded.`}),(0,G.jsxs)(`p`,{className:`detail-note`,children:[`Verification `,e.status??`in progress`,`.`]})]})}function i$({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(eN,{artifactId:e,client:t,heading:`Worker report`,missing:`This settlement recorded no report.`,noun:`report`,runId:i,unreadable:`This run kept no readable copy of that report.`}),(0,G.jsx)(u$,{reference:n,row:r})]})}function a$({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(eN,{artifactId:e,client:t,heading:`Oneharness conversation`,missing:`This record named no conversation.`,noun:`conversation`,runId:i,unreadable:`The history store holds no readable copy of that conversation.`}),(0,G.jsx)(u$,{reference:n,row:r})]})}function o$({node:e,reference:t}){let n=e.detail?.verification.checks??[],r=e.detail?.publication;return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Publication`}),r?.pr_url&&(0,G.jsx)(d$,{fallback:``,reference:{kind:`pr`,value:r.pr_url}}),r?.merged&&r.commit_url?(0,G.jsx)(`p`,{className:`detail-link`,children:(0,G.jsxs)(`a`,{href:r.commit_url,rel:`noreferrer`,target:`_blank`,children:[`Merged commit `,r.commit?.slice(0,8),` `,(0,G.jsx)(Mt,{size:13})]})}):r?.branch_url?(0,G.jsx)(`p`,{className:`detail-link`,children:(0,G.jsxs)(`a`,{href:r.branch_url,rel:`noreferrer`,target:`_blank`,children:[`Branch `,r.branch,` `,(0,G.jsx)(Mt,{size:13})]})}):!r?.pr_url&&(0,G.jsx)(d$,{fallback:`No publication was recorded.`,reference:t}),(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Observed checks`}),n.length===0?(0,G.jsx)(`p`,{className:`detail-note`,children:`No checks were observed on this node.`}):(0,G.jsx)(`dl`,{className:`facts`,children:n.map(e=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:e.name}),(0,G.jsx)(`dd`,{children:e.url?(0,G.jsx)(`a`,{href:e.url,rel:`noreferrer`,target:`_blank`,children:e.state}):e.state})]},e.name))})]})}function s$({redirection:e,row:t}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Delivery`}),(0,G.jsx)(`dd`,{children:e.delivered?`Live — into the turn that was already running`:`Deferred — onto the node's next dispatch`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Redirected at`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(iF,{at:t.startedAt,relative:!0})})]}),e.member!==void 0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Member`}),(0,G.jsx)(`dd`,{children:e.member})]}),e.input_bytes!==void 0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Note`}),(0,G.jsxs)(`dd`,{children:[e.input_bytes,` bytes offered`]})]}),(0,G.jsx)(c$,{row:t})]}),e.reason!==void 0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Why it was not delivered`}),(0,G.jsx)(`p`,{className:`detail-note`,children:e.reason})]})]})}function c$({row:e}){let t=e.rowKind===`event`?MQ(e.event):void 0;return t===void 0?null:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Author`}),(0,G.jsx)(`dd`,{children:t})]})}function l$({surface:e,row:t}){let n=[[`Kind`,e.kind],[`Raised by`,e.source],[`Blocking`,e.blocking===void 0?void 0:e.blocking?`yes — dependents wait on the answer`:`no — nothing waits on it`]].filter(([,e])=>e!==void 0);return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Recorded at`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(iF,{at:t.startedAt,relative:!0})})]}),n.map(([e,t])=>(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:e}),(0,G.jsx)(`dd`,{children:t})]},e))]}),e.message!==void 0&&(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Message`}),(0,G.jsx)(`p`,{className:`detail-note`,children:e.message})]})]})}function u$({row:e,reference:t}){let n=e.rowKind===`group`?void 0:e,r=e.rowKind===`span`&&e.span.count!==void 0?`${e.span.count} records`:void 0,i=(e.rowKind===`span`?e.span.reasons:void 0)??[];return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Recorded at`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(iF,{at:e.startedAt,relative:!0})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Ended`}),(0,G.jsx)(`dd`,{children:e.endedAt===null?`Still running`:(0,G.jsx)(iF,{at:e.endedAt,relative:!0})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Status`}),(0,G.jsx)(`dd`,{children:e.status??`Not recorded`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Duration`}),(0,G.jsx)(`dd`,{children:e.durationMs===null?`Not recorded`:ZP(e.durationMs)})]}),r!==void 0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Aggregated`}),(0,G.jsx)(`dd`,{children:r})]}),i.length>0&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Waiting on`}),(0,G.jsx)(`dd`,{children:i.map(LQ).join(` and `)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Step`}),(0,G.jsx)(`dd`,{children:v$(n)??`None`})]}),(0,G.jsx)(c$,{row:e})]}),(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Reference`}),(0,G.jsx)(d$,{fallback:`This item points at no recorded artifact.`,reference:t})]})}function d$({reference:e,fallback:t}){return e===void 0?(0,G.jsx)(`p`,{className:`detail-note`,children:t}):e.value.startsWith(`http`)?(0,G.jsx)(`p`,{className:`detail-link`,children:(0,G.jsxs)(`a`,{href:e.value,rel:`noreferrer`,target:`_blank`,children:[e.value,` `,(0,G.jsx)(Mt,{size:13})]})}):(0,G.jsxs)(`p`,{className:`detail-note`,children:[(0,G.jsx)(`span`,{className:`detail-reference-kind`,children:e.kind}),(0,G.jsx)(`code`,{children:e.value})]})}function f$(e){if(e.rowKind!==`span`)return e.id;let t=e.span.events.at(-1);return[e.span.id,e.span.status??``,e.span.ended_at??``,e.span.events.length,t?.id??``,t?.at??``,t?.status??``].join(`|`)}function p$(e,t){return t.conversation===void 0?0:e?.rowKind===`event`?1:t.conversation.conversation.turns.length}function m$(e){return e.rowKind===`event`?e.event.redirection:void 0}function h$(e){return e.rowKind===`event`?e.event.release:void 0}function g$(e){return e.rowKind===`event`?e.event.surface:void 0}function _$(e){if(e.rowKind===`span`)return e.span.reference;if(e.rowKind===`event`)return e.event.reference}function v$(e){if(e?.rowKind===`span`)return e.span.step_id;if(e?.rowKind===`event`)return e.event.step_id}function y$(e){return e.kind===`verification`||e.kind.startsWith(`verification-`)}function b$(e,t){return t?.kind===`pr`||e.kind===`publication`||e.kind.startsWith(`pr-`)||e.kind.startsWith(`publication-`)}function x$(e,t){return aQ(e,t)}function S$({client:e,runId:t,node:n,timeline:r,timelineError:i,selectedItemId:a,onSelectItem:o,onBack:s,selectedTab:c,onSelectTab:l,agents:u}){let d=(0,U.useMemo)(()=>_Q(r,n.id),[r,n.id]);(0,U.useEffect)(()=>{let e=e=>{e.key===`Escape`&&(a===void 0?s():o())};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s,o,a]);let f=n.detail?.publication===void 0?n.result?.pr??void 0:n.detail.publication.pr_url;return(0,G.jsxs)(`section`,{"aria-label":`Timeline for ${n.label}`,className:`node-view`,children:[(0,G.jsxs)(`header`,{className:`node-view-head`,children:[(0,G.jsx)(`nav`,{"aria-label":`Breadcrumb`,children:(0,G.jsxs)(`ol`,{className:`breadcrumb`,children:[(0,G.jsx)(`li`,{children:(0,G.jsxs)(La,{onClick:s,size:`sm`,type:`button`,variant:`ghost`,children:[(0,G.jsx)(_t,{size:14}),` Graph`]})}),(0,G.jsx)(`li`,{"aria-current":`page`,children:(0,G.jsx)(`span`,{className:`breadcrumb-node`,children:n.label})})]})}),(0,G.jsxs)(`div`,{className:`node-view-facts`,children:[(0,G.jsx)(tX,{className:`node-view-state`,state:n.status}),(0,G.jsx)(DZ,{control:n.control}),(0,G.jsxs)(`span`,{className:`node-view-meta`,children:[n.kind,` node · `,n.telemetry?.turns??0,` turns ·`,` `,n.telemetry?.lint??0,` lint turns`]}),f!==void 0&&(0,G.jsxs)(`a`,{className:`node-view-pr`,href:f,rel:`noreferrer`,target:`_blank`,children:[`Pull request `,(0,G.jsx)(Mt,{size:12})]})]})]}),(0,G.jsx)(j$,{node:n}),(0,G.jsxs)(Cp,{className:`node-tabs`,onValueChange:e=>{yX(e)&&l(e)},value:c,children:[(0,G.jsx)(Tp,{"aria-label":`Node details`,variant:`line`,children:Object.entries(vX).map(([e,t])=>(0,G.jsx)(Ep,{value:e,children:t},e))}),(0,G.jsxs)(Dp,{className:`node-tab-panel`,value:`task`,children:[(0,G.jsx)(`pre`,{children:O$(n.task)}),(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Outcome`}),(0,G.jsx)(`dd`,{children:M$(n.result?.detail)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Graph overrides`}),(0,G.jsx)(`dd`,{children:(n.task.sets??[]).length===0?`None`:(0,G.jsx)(`ol`,{"aria-label":`Graph overrides`,className:`sets-served`,children:n.task.sets?.map((e,t)=>(0,G.jsx)(`li`,{children:(0,G.jsx)(`code`,{children:e})},t))})})]})]})]}),(0,G.jsx)(Dp,{className:`node-tab-panel`,value:`criteria`,children:(0,G.jsx)(`pre`,{children:k$(n.task)})}),(0,G.jsx)(Dp,{className:`node-tab-panel`,value:`dependencies`,children:(0,G.jsx)(`dl`,{className:`facts`,children:(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Dependencies`}),(0,G.jsx)(`dd`,{children:n.task.deps?.join(`, `)||`None`})]})})}),(0,G.jsx)(Dp,{className:`node-tab-panel`,value:`pr`,children:(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Publication`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(A$,{node:n})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Release`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(HZ,{node:n})})]})]})}),(0,G.jsx)(Dp,{className:`node-tab-panel`,value:`checks`,children:(0,G.jsxs)(`dl`,{className:`facts`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Verification coverage`}),(0,G.jsxs)(`dd`,{children:[`Hook:`,` `,n.detail?.verification.pre_push_hook?`present`:`not recorded`,` · `,`Required checks:`,` `,n.detail?.verification.required_checks?.join(`, `)||`none configured`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Observed checks`}),(0,G.jsx)(`dd`,{children:(n.detail?.verification.checks??[]).length===0?`No checks observed`:n.detail?.verification.checks?.map((e,t)=>(0,G.jsxs)(`span`,{children:[t>0&&` · `,e.url?(0,G.jsxs)(`a`,{href:e.url,rel:`noreferrer`,target:`_blank`,children:[e.name,`: `,e.state]}):`${e.name}: ${e.state}`]},e.name))})]})]})}),(0,G.jsx)(Dp,{className:`node-tab-panel`,value:`agents`,children:c===`agents`&&u}),(0,G.jsx)(Dp,{className:`node-timeline-panel`,value:`timeline`,children:i===void 0?r===void 0?(0,G.jsx)(`div`,{"aria-live":`polite`,className:`loading-state`,children:`Loading the recorded timeline…`}):d.rows.length===0?(0,G.jsxs)(Ra,{className:`m-5 items-center gap-2 p-8 text-muted-foreground`,children:[(0,G.jsx)(`p`,{className:`m-0`,children:`This node has no recorded timeline yet.`}),(0,G.jsx)(`p`,{className:`m-0 text-[11px]`,children:`Spans and events appear here as the run records them.`})]}):(0,G.jsx)(C$,{client:e,node:n,onSelectItem:o,runId:t,selectedItemId:a,timeline:r}):(0,G.jsxs)(ua,{className:`m-5 w-auto`,variant:`destructive`,children:[(0,G.jsx)(cn,{}),(0,G.jsx)(da,{children:`Timeline unavailable`}),(0,G.jsx)(fa,{children:i.message})]})})]})]})}function C$({client:e,node:t,onSelectItem:n,runId:r,selectedItemId:i,timeline:a}){let o=(0,U.useMemo)(()=>fQ(a,t.id),[a,t.id]),[s,c]=(0,U.useState)(()=>new Set),l=(0,U.useMemo)(()=>{if(i!==void 0)return xQ(o.tree,i).find(e=>e.rowKind===`group`)?.id},[o.tree,i]),u=(0,U.useMemo)(()=>l===void 0?s:new Set([...s,l]),[s,l]),d=(0,U.useMemo)(()=>pQ(o.tree,u),[o.tree,u]),f=Om((0,U.useMemo)(()=>d.flatMap(e=>e.entryKind===`row`?[{id:e.row.id,time:Date.parse(e.row.startedAt)}]:[]),[d])),[p,m]=(0,U.useState)(!1),h=(0,U.useMemo)(()=>cQ(o.items,o.lanes),[o.items,o.lanes]),g=(0,U.useMemo)(()=>dQ(o.markers,o.items,i),[o.items,o.markers,i]),_=(0,U.useMemo)(()=>w$(o.items),[o.items]),v=f.cursor===void 0?void 0:Math.min(Math.max(f.cursor,_[0]),_[1]),y=i===void 0?void 0:bQ(o.rows,i),b=e=>{n(e),f.scrollTo(e)};return(0,U.useEffect)(()=>{i!==void 0&&f.scrollTo(i)},[i,f]),(0,G.jsxs)(`div`,{className:`node-execution`,"data-expanded":p,children:[(0,G.jsx)(`section`,{"aria-label":`Node timeline`,className:`node-timeline-sticky`,"data-testid":`node-timeline`,children:(0,G.jsx)(En,{axis:{origin:_[0]},cursor:v,expanded:p,getFailureExcerpt:e=>e.payload.rowKind===`span`?e.payload.span.detail?.output_tail:void 0,items:p?o.items:h,lanes:o.lanes,markers:g,onExpandedChange:m,onSelect:e=>b(e.id),selectedId:i})}),(0,G.jsx)(`section`,{"aria-label":`Node transcript`,className:`node-transcript`,ref:f.containerRef,children:T$(d).map(e=>{let t=e.entries.map(e=>e.entryKind===`row`?(0,G.jsx)(D$,{onOpen:b,register:f.register,row:e.row,selected:e.row.id===i},e.row.id):(0,G.jsx)(E$,{entry:e,onToggle:()=>c(t=>{let n=new Set(t);return n.has(e.group.id)?n.delete(e.group.id):n.add(e.group.id),n})},`collapse-${e.group.id}`));return e.dispatch===void 0?(0,G.jsx)(U.Fragment,{children:t},e.id):(0,G.jsxs)(`section`,{"aria-label":e.dispatch.label,className:`transcript-dispatch`,children:[(0,G.jsx)(`h3`,{children:e.dispatch.label}),t]},e.id)})}),y!==void 0&&(0,G.jsxs)(`aside`,{"aria-label":`Item detail panel`,className:`detail-drawer`,children:[(0,G.jsx)(La,{"aria-label":`Close detail`,className:`drawer-close`,onClick:()=>n(),size:`icon`,variant:`ghost`,children:(0,G.jsx)(pn,{})}),(0,G.jsx)($Q,{client:e,node:t,row:y,runId:r})]})]})}function w$(e){let t=e.map(({start:e})=>e),n=e.map(e=>e.end??e.start);if(t.length===0)return[0,1];let r=Math.min(...t),i=Math.max(...n);return[r,i>r?i:r+1]}function T$(e){let t=[];for(let n of e){let e=n.entryKind===`row`?n.row:n.group,r=t.at(-1);e.dispatch!==void 0&&r?.dispatch!==void 0&&r.dispatch.id===e.dispatch.id?r.entries.push(n):t.push({id:e.id,dispatch:e.dispatch,entries:[n]})}return t}function E$({entry:e,onToggle:t}){let n=mQ(e.hidden,e.group.kind);return(0,G.jsx)(`p`,{className:`transcript-collapsed`,children:(0,G.jsxs)(`button`,{"aria-expanded":e.expanded,onClick:t,type:`button`,children:[(0,G.jsx)(`span`,{"aria-hidden":`true`,children:`…`}),e.expanded?`Collapse ${n}`:`Show ${n}`]})})}function D$({row:e,selected:t,register:n,onOpen:r}){return(0,G.jsx)(`article`,{"aria-label":e.displayLabel,className:`transcript-item`,"data-dispatch-group":e.dispatch?.label,"data-selected":t,ref:t=>n(e.id,t),children:(0,G.jsxs)(`button`,{"aria-label":`Open ${e.displayLabel}`,onClick:()=>r(e.id),type:`button`,children:[(0,G.jsxs)(`span`,{className:`eyebrow`,children:[e.rowKind===`event`&&(0,G.jsx)(PZ,{category:e.category}),e.displayKind]}),(0,G.jsx)(`strong`,{children:e.displayLabel}),(0,G.jsxs)(`span`,{className:`transcript-facts`,children:[(0,G.jsx)(iF,{at:e.startedAt}),e.durationMs!==null&&` · ${ZP(e.durationMs)}`,` · ${e.status??`recorded`}`,e.sessionName!==void 0&&` · ${e.sessionName}`]})]})})}function O$(e){if(e.task!==void 0)return e.task;let t=e.steps??[];return t.length===0?`No task prose recorded.`:t.map(e=>`## ${e.id}\n\n${e.task}`).join(`
|
|
97
97
|
|
|
98
98
|
`)}function k$(e){let t=O$(e),n=/(?:^|\n)##[ \t]*acceptance[ \t]+criteria[ \t]*\r?\n([\s\S]*?)(?=\r?\n##[ \t]|$)/i.exec(t)?.[1]?.trim();return n===void 0||n.length===0?`No acceptance criteria recorded in this node's task.`:n}function A$({node:e}){let t=e.detail?.publication;if(t===void 0)return typeof e.result?.pr==`string`&&e.result.pr?(0,G.jsxs)(`a`,{className:`node-view-pr`,href:e.result.pr,rel:`noreferrer`,target:`_blank`,children:[`Pull request `,(0,G.jsx)(Mt,{size:12})]}):(0,G.jsx)(G.Fragment,{children:`Not recorded`});let n=(t.merged?[[t.pr_url,`Pull request`],[t.commit_url,`Commit ${t.commit?.slice(0,8)??``}`]]:[[t.pr_url,`Pull request`],[t.branch_url,t.branch??`Branch`]]).filter(([e])=>e);return n.length===0?(0,G.jsx)(G.Fragment,{children:`Not recorded`}):(0,G.jsx)(G.Fragment,{children:n.map(([e,t],n)=>(0,G.jsxs)(`span`,{children:[n>0&&` · `,(0,G.jsxs)(`a`,{className:`node-view-pr`,href:e,rel:`noreferrer`,target:`_blank`,children:[t,` `,(0,G.jsx)(Mt,{size:12})]})]},e))})}function j$({node:e}){if(!GY(e.status))return null;let t=e.status===`blocked`||e.status===`skipped`,n=VY(e),r=e.result?.error||void 0,i=e.result?.exit_code;return(0,G.jsxs)(ua,{className:H(`m-5 w-auto`,t&&`border-warning bg-warning-surface text-warning`),variant:t?`default`:`destructive`,children:[t?(0,G.jsx)(Xt,{}):(0,G.jsx)(cn,{}),(0,G.jsx)(da,{children:t?`This node is ${e.status}`:`This node ${e.status===`cancelled`?`was cancelled`:e.status===`not-completed`?`did not complete`:`failed`}${e.failure?`: ${e.failure.class}`:``}`}),(0,G.jsx)(fa,{children:(0,G.jsxs)(`dl`,{className:`facts`,children:[t&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:e.status===`skipped`?`Unmet`:`Blocked by`}),(0,G.jsx)(`dd`,{children:e.blockers.length>0?e.blockers.join(`, `):`Nothing recorded; the run has not written what holds it.`})]}),!t&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Detail`}),(0,G.jsx)(`dd`,{children:n??`No reason was recorded for this outcome.`})]}),r!==void 0&&r!==n&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Error`}),(0,G.jsx)(`dd`,{children:r})]}),typeof i==`number`&&(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Exit code`}),(0,G.jsx)(`dd`,{children:i})]})]})})]})}function M$(e){return e==null||e===``?`Not recorded`:typeof e==`string`?e:JSON.stringify(e,null,2)}var N$=`idle-`,P$=`row:run`,F$=e=>`row:node:${e}`,I$={id:ZZ,label:`Idle`};function L$(e){return[...nQ(e),I$]}var R$=.005;function z$(e,t){let n=e?.spans??[],r=B$(e),i=L$(e),a=[V$({id:P$,kind:`run`,label:`Run-level`,range:r,spans:n.filter(e=>e.node_id===void 0),lanes:i}),...t.map(e=>V$({id:F$(e.id),kind:`node`,label:e.label,nodeId:e.id,range:r,spans:n.filter(t=>t.node_id===e.id),lanes:i}))],o=a.flatMap(e=>e.items.filter(e=>e.payload.kind===`work`));return{range:r,live:n.some(e=>e.ended_at===null),rows:a,line:{items:[...G$(r,o,void 0),...cQ(o,i)],markers:dQ(a.flatMap(e=>[...e.markers]),o),lanes:i}}}function B$(e){let t=e?.spans??[],n=t.map(e=>Date.parse(e.started_at));if(n.length===0)return[0,1];let r=Math.min(...n),i=Math.max(...t.map(e=>e.ended_at===null?Date.parse(e.started_at):Date.parse(e.ended_at))),a=Date.parse(e?.observed_at??``),o=t.some(e=>e.ended_at===null)&&Number.isFinite(a)?Math.max(i,a):i;return[r,o>r?o:r+1]}function V$({id:e,kind:t,label:n,nodeId:r,range:i,spans:a,lanes:o}){let s=a.flatMap(t=>{let a=TQ(t);if(a===null)return[];let s=Date.parse(t.started_at),c=H$(t,a,s,i),l=t.reference?.kind===`conversation`?t.reference.value:void 0;return[{id:t.id,label:`${n} · ${EQ(a,o)}${U$(t)}`,laneId:a,start:s,end:c,duration:c-s,status:t.status,payload:{id:t.id,kind:`work`,label:`${n} · ${EQ(a,o)}`,rowId:e,...r===void 0?{}:{nodeId:r},...l===void 0?{}:{conversationId:l},startedAt:t.started_at,endedAt:t.ended_at,durationMs:c-s}}]}),c=G$(i,s,{rowId:e,nodeId:r}),l=W$(s).reduce((e,[t,n])=>e+(n-t),0);return{id:e,kind:t,label:n,...r===void 0?{}:{nodeId:r},lanes:o.filter(({id:e})=>[...s,...c].some(t=>t.laneId===e)),items:[...c,...s],line:[...c,...cQ(s,o)],markers:a.flatMap(t=>t.events.map(t=>({id:t.id,label:`${n} · ${t.step_id??t.kind}`,at:Date.parse(t.at),status:t.status,payload:{id:t.id,kind:`record`,label:t.kind,rowId:e,...r===void 0?{}:{nodeId:r},startedAt:t.at,endedAt:null,durationMs:0}}))),workedMs:l,idleMs:c.reduce((e,t)=>e+t.payload.durationMs,0)}}function H$(e,t,n,r){return t===`lock-waits`&&e.total_duration_ms!==void 0?n+e.total_duration_ms:e.ended_at===null?r[1]:Date.parse(e.ended_at)}function U$(e){return e.count!==void 0&&e.count>1?` · ${e.count} recorded`:``}function W$(e){let t=e.map(e=>[e.start,Math.max(e.end??e.start,e.start)]).filter(([e,t])=>Number.isFinite(e)&&Number.isFinite(t)).sort((e,t)=>e[0]-t[0]),n=[];for(let[e,r]of t){let t=n.at(-1);t!==void 0&&e<=t[1]?t[1]=Math.max(t[1],r):n.push([e,r])}return n}function G$(e,t,n){let r=W$(t),i=[],a=e[0];for(let[e,t]of r)e>a&&i.push([a,e]),a=Math.max(a,t);a<e[1]&&i.push([a,e[1]]);let o=Math.max(1,e[1]-e[0]);return i.filter(([e,t],n)=>n===0||n===i.length-1||(t-e)/o>=R$).map(([e,t],r)=>{let i=`${N$}${n?.rowId??`graph`}-${r}`,a={id:i,kind:`idle`,label:`Idle · ${ZP(t-e)}`,...n===void 0?{}:{rowId:n.rowId},...n?.nodeId===void 0?{}:{nodeId:n.nodeId},startedAt:new Date(e).toISOString(),endedAt:new Date(t).toISOString(),durationMs:t-e};return{id:i,label:a.label,laneId:ZZ,start:e,end:t,duration:t-e,status:`idle`,payload:a}})}function K$({client:e,detail:t,nodes:n,timeline:r,timelineError:i,onSelectNode:a,selectedItemId:o,onSelectItem:s}){let c=t.run.run_id,l=(0,U.useMemo)(()=>z$(r,n),[r,n]),u=(r?.spans??[]).filter(e=>e.node_id===void 0),d=u.find(e=>e.id===o),f=u.flatMap(e=>e.events).find(e=>e.id===o),p=d===void 0?f===void 0?void 0:yQ(f):vQ(d);return(0,U.useEffect)(()=>{let e=e=>{e.key===`Escape`&&o!==void 0&&s()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[s,o]),(0,G.jsxs)(`div`,{className:`overall-view`,children:[(0,G.jsx)(uf,{className:`h-full`,children:(0,G.jsxs)(`div`,{className:`p-[34px] max-sm:p-3`,children:[(0,G.jsxs)(`section`,{className:`overall-hero`,children:[(0,G.jsx)(`p`,{className:`eyebrow`,children:`Whole DAG`}),(0,G.jsx)(`h2`,{children:c}),t.graph?.plan.goal?.text&&(0,G.jsx)(`p`,{className:`run-goal`,children:t.graph.plan.goal.text}),(0,G.jsxs)(`p`,{children:[t.run.phase,` ·`,` `,t.run.last_event?`last event ${t.run.last_event}`:`no events recorded yet`]})]}),(0,G.jsxs)(`section`,{"aria-label":`Run metrics`,className:`metric-grid`,children:[(0,G.jsx)(Y$,{icon:(0,G.jsx)(ht,{}),label:`Status`,value:t.run.state}),(0,G.jsx)(Y$,{icon:(0,G.jsx)(Bt,{}),label:`Nodes`,value:String(t.run.nodes.length)}),(0,G.jsx)(Y$,{icon:(0,G.jsx)(At,{}),label:`Wall time`,value:t.run.timing.wall_seconds===null?`not measured`:QP(t.run.timing.wall_seconds)}),(0,G.jsx)(Y$,{icon:(0,G.jsx)(jt,{}),label:`Turns`,value:String(t.run.turns)})]}),(0,G.jsx)(Ra,{className:`gap-0 py-[15px]`,children:(0,G.jsxs)(za,{className:`px-[15px]`,children:[(0,G.jsxs)(`div`,{className:`section-heading`,children:[(0,G.jsx)(ht,{size:16}),(0,G.jsx)(`h3`,{children:`Graph timeline`})]}),i===void 0?r===void 0?(0,G.jsx)(`p`,{"aria-live":`polite`,className:`m-0 text-[11px] text-muted-foreground`,children:`Loading the run's timeline…`}):r.spans.length===0?(0,G.jsx)(`p`,{className:`m-0 text-[11px] text-muted-foreground`,children:`This run has recorded no timeline yet.`}):(0,G.jsx)(q$,{graph:l,onOpenNode:a,onOpenItem:s,selectedItemId:o}):(0,G.jsxs)(ua,{variant:`destructive`,children:[(0,G.jsx)(cn,{}),(0,G.jsx)(da,{children:`Timeline unavailable`}),(0,G.jsx)(fa,{children:i.message})]})]})})]})}),p!==void 0&&(0,G.jsxs)(`aside`,{"aria-label":`Item detail panel`,className:`detail-drawer`,children:[(0,G.jsx)(La,{"aria-label":`Close detail`,className:`drawer-close`,onClick:()=>s(),size:`icon`,variant:`ghost`,children:(0,G.jsx)(pn,{})}),(0,G.jsx)($Q,{client:e,row:p,runId:c})]})]})}function q$({graph:e,onOpenNode:t,onOpenItem:n,selectedItemId:r}){let[i,a]=(0,U.useState)(),[o,s]=(0,U.useState)(!1),[c,l]=(0,U.useState)(new Set),u=i??e.range,d=e=>{e.kind===`record`&&e.nodeId===void 0?n(e.id):e.nodeId===void 0?e.conversationId!==void 0&&n(e.id):t(e.nodeId)},f=e.line.lanes.filter(({id:t})=>e.line.items.some(e=>e.laneId===t));return(0,G.jsxs)(`div`,{className:`graph-timeline`,"data-rows-open":o,children:[(0,G.jsx)(En,{axis:{origin:e.range[0]},expanded:!1,items:e.line.items,label:`Graph timeline`,lanes:f,markers:e.line.markers,onExpandedChange:s,onRangeChange:a,onSelect:e=>d(e.payload),range:u,selectedId:r}),o&&(0,G.jsx)(`ol`,{className:`graph-rows`,children:e.rows.map(n=>(0,G.jsx)(J$,{onOpen:d,onOpenNode:t,onExpandedChange:e=>l(t=>{let r=new Set(t);return e?r.add(n.id):r.delete(n.id),r}),expanded:c.has(n.id),origin:e.range[0],range:u,onRangeChange:a,row:n,selectedItemId:r},n.id))})]})}function J$({row:e,range:t,origin:n,expanded:r,onExpandedChange:i,onRangeChange:a,onOpen:o,onOpenNode:s,selectedItemId:c}){let l=e.nodeId;return(0,G.jsxs)(`li`,{className:`graph-row`,"data-row-kind":e.kind,children:[(0,G.jsxs)(`header`,{className:`graph-row-head`,children:[l===void 0?(0,G.jsx)(`span`,{className:`graph-row-name`,children:e.label}):(0,G.jsx)(`button`,{className:`graph-row-name`,onClick:()=>s(l),type:`button`,children:e.label}),(0,G.jsxs)(`span`,{className:`graph-row-facts`,children:[ZP(e.workedMs),` recorded · `,ZP(e.idleMs),` `,`idle`]})]}),(0,G.jsx)(En,{axis:{origin:n},expanded:r,items:r?e.items:e.line,label:`${e.label} timeline`,lanes:e.lanes,markers:e.markers,onExpandedChange:i,onRangeChange:a,onSelect:e=>o(e.payload),range:t,selectedId:c})]})}function Y$({icon:e,label:t,value:n}){return(0,G.jsxs)(Ra,{"aria-label":t,className:`metric flex-row items-center gap-3 p-4`,role:`group`,children:[e,(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{children:t}),(0,G.jsx)(`strong`,{children:n})]})]})}var X$=6,Z$=8,Q$=`[aria-describedby^="timeline-detail-"]`,$$=e=>{if(!(e instanceof Element))return;let t=JZ(e);if(t!==void 0)return t;let n=e.closest(Q$);if(!(n instanceof HTMLElement))return;let r=document.getElementById(n.getAttribute(`aria-describedby`)??``)?.textContent?.trim();return r?{element:n,detail:r}:void 0},e1=(e,t)=>t!==void 0&&e?.element===t.element&&e.detail===t.detail?e:t;function t1(){let e=(0,U.useRef)(null),[t,n]=(0,U.useState)(),[r,i]=(0,U.useState)(),a=t??r,o=(0,U.useCallback)(()=>{n(void 0),i(void 0)},[]);(0,U.useEffect)(()=>{let e=e=>n(t=>e1(t,$$(e.target))),t=e=>i(t=>e1(t,$$(e.target))),r=e=>i(t=>e1(t,$$(e.relatedTarget))),a=()=>n(void 0);return document.addEventListener(`pointerover`,e),document.addEventListener(`pointerleave`,a),document.addEventListener(`focusin`,t),document.addEventListener(`focusout`,r),()=>{document.removeEventListener(`pointerover`,e),document.removeEventListener(`pointerleave`,a),document.removeEventListener(`focusin`,t),document.removeEventListener(`focusout`,r)}},[]);let s=(0,U.useCallback)(()=>{let t=e.current;if(t===null||a===void 0)return;if(!a.element.isConnected)return o();let n=a.element.getBoundingClientRect(),r=t.getBoundingClientRect(),i=window.innerWidth-r.width-Z$,s=Math.min(Math.max(n.left,Z$),Math.max(Z$,i)),c=n.bottom+X$,l=n.top-r.height-X$,u=Math.max(Z$,window.innerHeight-r.height-Z$),d=c+r.height<=window.innerHeight-Z$?c:l,f=Math.min(Math.max(d,Z$),u);t.style.left=`${Math.round(s)}px`,t.style.top=`${Math.round(f)}px`,t.style.visibility=`visible`},[a,o]);return(0,U.useLayoutEffect)(s,[s]),(0,U.useEffect)(()=>{if(a!==void 0)return window.addEventListener(`scroll`,s,!0),window.addEventListener(`resize`,s),()=>{window.removeEventListener(`scroll`,s,!0),window.removeEventListener(`resize`,s)}},[a,s]),a===void 0?null:(0,Pr.createPortal)((0,G.jsx)(`div`,{"aria-hidden":`true`,className:`timeline-popover`,"data-testid":`timeline-popover`,ref:e,style:{visibility:`hidden`},children:a.detail},a.detail),document.body)}var n1=new GM(window.location.origin,{fetch:window.fetch.bind(window)}),r1=Object.entries(gX);function i1({client:e=n1}){let t=SX(),n=(0,U.useMemo)(()=>t.view===`overall`?{}:t.nodeId===void 0?void 0:{nodeId:t.nodeId},[t.view,t.nodeId]),r=gX[t.detail].profile,i=HX(e,t.runId,n,r,t.list===`runs`),a=i.list?.runs??[],o=i.runId,s=i.detail,c=(0,U.useMemo)(()=>s?LY(s):[],[s]),l=BX(e,i.invalidations,t.list===`projects`),u=VX(e,o===void 0?t.projectKey:void 0,i.invalidations),d=t.projectKey===void 0?void 0:u.group??kX(l.list?.projects??[],t.projectKey),f=gF(e,o===void 0?d?.project??void 0:void 0,i.invalidations),p=nI(e,o,r,i.invalidations),m=_Z(e,o),h=vZ(e),g=s===void 0?void 0:FY(s),_=c.find(({id:e})=>e===t.nodeId),v=(0,U.useMemo)(()=>new Set((i.list?.runs??[]).filter(({state:e})=>![`complete`,`failed`,`cancelled`].includes(e)).map(({run_id:e})=>e)),[i.list]);return(0,U.useEffect)(()=>{if(o&&t.runId&&t.runId!==o){let e=new URLSearchParams(window.location.search);e.set(`run`,o),e.delete(`node`),e.delete(`event`),e.set(`view`,t.view),window.history.replaceState(null,``,`${window.location.pathname}?${e}`),window.dispatchEvent(new PopStateEvent(`popstate`))}},[t.runId,o,t.view]),(0,G.jsxs)(mm,{children:[(0,G.jsx)(t1,{}),(0,G.jsxs)(`div`,{className:`app-shell`,children:[(0,G.jsx)(FX,{list:t.list,onSelectList:t.selectList,projects:l.list?.projects,selectedProjectKey:t.projectKey,onSelectProject:t.selectProject,runs:a,selectedRunId:o,liveRunIds:v,hasMore:i.hasMore,loadingMore:i.loadingMore,onLoadMore:i.loadMore,onSelect:t.selectRun,hostActions:(0,G.jsx)(yZ,{client:e,list:i.list,loadMore:i.loadMore,loadingMore:i.loadingMore,shutdowns:h})}),(0,G.jsxs)(`main`,{className:`workspace`,children:[(0,G.jsxs)(`header`,{className:`topbar`,children:[(0,G.jsxs)(`div`,{className:`topbar-title`,children:[t.projectKey!==void 0&&o&&(0,G.jsxs)(La,{"aria-label":`Back to ${d?EX(d):`the project`}`,className:`topbar-back`,onClick:()=>t.selectProject(t.projectKey),size:`sm`,type:`button`,variant:`ghost`,children:[(0,G.jsx)(_t,{size:14}),d?EX(d):`Project`]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`p`,{className:`eyebrow`,children:`Execution telemetry`}),(0,G.jsx)(`h2`,{children:o??(t.projectKey===void 0?t.list===`projects`?`Projects`:`No DAG selected`:(d&&EX(d))??t.projectKey)})]})]}),(0,G.jsxs)(`div`,{className:`topbar-actions`,children:[o!==void 0&&(0,G.jsx)(ZF,{control:p,runId:o,children:(0,G.jsx)(gZ,{launched:a.find(({run_id:e})=>e===o)??(s?.run.run_id===o?s:void 0),runId:o,shutdown:m,unwatched:p.unwatched})}),(0,G.jsxs)(`span`,{className:`connection`,children:[(0,G.jsx)(rn,{size:15}),i.lastUpdated===void 0?`Waiting for first update`:(0,G.jsxs)(G.Fragment,{children:[`Last updated`,` `,(0,G.jsx)(iF,{at:i.lastUpdated,relative:!0})]})]}),i.activity.at(-1)!==void 0&&(0,G.jsxs)(`span`,{className:`connection`,"aria-live":`polite`,children:[i.activity.at(-1)?.node,`:`,` `,[i.activity.at(-1)?.name,i.activity.at(-1)?.detail].filter(Boolean).join(` `)||i.activity.at(-1)?.kind]}),(0,G.jsxs)(La,{onClick:()=>void i.refresh(),size:`sm`,type:`button`,variant:`outline`,children:[(0,G.jsx)(en,{size:14}),` Refresh`]})]})]}),i.error&&(0,G.jsxs)(ua,{className:`rounded-none border-x-0 border-t-0`,variant:`destructive`,children:[(0,G.jsx)(cn,{}),(0,G.jsx)(da,{children:`Live telemetry issue`}),(0,G.jsx)(fa,{children:i.error.message})]}),(0,G.jsx)(SZ,{label:`Run shutdown`,onDismiss:m.dismiss,rows:a,state:m.state}),(0,G.jsx)(SZ,{label:`Shutdown of all my runs`,onDismiss:h.mine.dismiss,rows:a,state:h.mine.state}),(0,G.jsx)(SZ,{label:`Shutdown of the entire host`,onDismiss:h.host.dismiss,rows:a,state:h.host.state}),o===void 0&&t.projectKey!==void 0?(0,G.jsx)(LX,{agents:d?.project==null?void 0:(0,G.jsx)(fF,{agents:f,client:e,count:d.agent_count,title:`Agents of ${EX(d)}`}),error:u.error,group:d,loading:u.loading&&d===void 0,onSelectRun:t.selectRun,projectKey:t.projectKey}):o===void 0&&t.list===`projects`&&!i.loading?(0,G.jsx)(IX,{error:l.error,groups:l.list?.projects,onSelect:t.selectProject}):(0,G.jsxs)(Cp,{className:`min-h-0 flex-1 gap-0`,onValueChange:e=>e===`overall`?t.showOverall():e===`graph`?t.selectNode(void 0):fX(e)?t.selectView(e):void 0,value:t.view,children:[(0,G.jsxs)(`div`,{className:`view-tabs`,children:[(0,G.jsxs)(Tp,{"aria-label":`DAG views`,variant:`line`,children:[(0,G.jsxs)(Ep,{value:`graph`,children:[(0,G.jsx)(fn,{size:15}),` Graph`]}),(0,G.jsxs)(Ep,{value:`overall`,children:[(0,G.jsx)(nn,{size:15}),` Overall`]}),(0,G.jsxs)(Ep,{value:`channel`,children:[(0,G.jsx)(zt,{size:15}),` Channel`]}),(0,G.jsxs)(Ep,{value:`watch`,children:[(0,G.jsx)(Pt,{size:15}),` Watch`]}),(0,G.jsxs)(Ep,{value:`reads`,children:[(0,G.jsx)(yt,{size:15}),` Reads`]}),(0,G.jsxs)(Ep,{value:`agents`,children:[(0,G.jsx)(bt,{size:15}),` Agents`]})]}),(0,G.jsxs)(`fieldset`,{className:`detail-switch`,children:[(0,G.jsx)(`legend`,{className:`sr-only`,children:`Level of detail`}),r1.map(([e,{label:n,description:r}])=>(0,G.jsx)(La,{"aria-pressed":t.detail===e,onClick:()=>t.selectDetail(e),size:`sm`,title:r,type:`button`,variant:t.detail===e?`default`:`outline`,children:n},e))]})]}),(0,G.jsx)(Dp,{className:`min-h-0`,value:t.view,children:!s&&(i.loading||o!==void 0)?(0,G.jsxs)(`div`,{"aria-live":`polite`,className:`loading-state`,children:[(0,G.jsx)(wf,{className:`h-2 w-48`}),(0,G.jsx)(wf,{className:`h-2 w-32`}),`Loading execution history…`]}):s&&o?t.view===`channel`?(0,G.jsx)(FF,{client:e,decisions:g?.decisions??[],filter:r,invalidations:i.invalidations,observedAt:s.observed_at,overrides:g&&IY(g),runId:o}):t.view===`watch`?(0,G.jsx)(rI,{onToggle:p.toggleWatch,runId:o,unwatched:p.unwatched.value,watch:p.watch}):t.view===`reads`?(0,G.jsx)(qF,{client:e,invalidations:i.invalidations,nodes:c,runId:o,status:p.status}):t.view===`agents`?(0,G.jsx)(_F,{client:e,count:s.run.agent_count,invalidations:i.invalidations,runId:o}):t.view===`overall`?(0,G.jsx)(K$,{client:e,detail:s,nodes:c,timeline:i.timeline,timelineError:i.timelineError,onSelectNode:t.selectNode,onSelectItem:t.selectItem,selectedItemId:t.itemId}):_?(0,G.jsx)(S$,{agents:(0,G.jsx)(vF,{client:e,invalidations:i.invalidations,nodeId:_.id,runId:o}),client:e,node:_,onBack:()=>t.selectNode(void 0),onSelectItem:t.selectItem,runId:o,selectedItemId:t.itemId,selectedTab:t.nodeTab,onSelectTab:t.selectNodeTab,timeline:i.timeline,timelineError:i.timelineError}):(0,G.jsx)(eX,{nodes:c,selectedNodeId:t.nodeId,onSelectNode:t.selectNode}):(0,G.jsxs)(`div`,{className:`empty-state`,children:[(0,G.jsx)(fn,{size:34}),(0,G.jsx)(`h2`,{children:`No DAG runs found`}),(0,G.jsx)(`p`,{children:`Start an orchestrated run to see it appear here.`})]})})]})]})]})]})}var a1=class extends U.Component{state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`DAG UI render failed`,e,t.componentStack)}render(){return this.state.error?(0,G.jsxs)(`main`,{className:`fatal-error`,role:`alert`,children:[(0,G.jsx)(`p`,{className:`eyebrow`,children:`Rendering error`}),(0,G.jsx)(`h1`,{children:`The DAG view could not be displayed.`}),(0,G.jsx)(`p`,{children:this.state.error.message}),(0,G.jsx)(La,{onClick:()=>(this.props.onReload??(()=>window.location.reload()))(),type:`button`,variant:`secondary`,children:`Reload`})]}):this.props.children}},o1=document.getElementById(`root`);if(!o1)throw Error(`DAG UI root element is missing`);(0,CA.createRoot)(o1).render((0,G.jsx)(U.StrictMode,{children:(0,G.jsx)(a1,{children:(0,G.jsx)(i1,{})})}));
|
package/dist/index.html
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
9
9
|
<meta name="theme-color" content="#111622" />
|
|
10
10
|
<title>DAG Observatory</title>
|
|
11
|
-
<script type="module" crossorigin src="/assets/index-
|
|
11
|
+
<script type="module" crossorigin src="/assets/index-CKY8gqZ4.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-m7hUhIQ5.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|