onepipeline-ui 0.37.0 → 0.38.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??wK,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)&&$U(e))return!1;let n=DK(e.code,s);if(a.current.add(e[n]),EK(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=DK(e.code,s);EK(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 EK(e,t,n){return e.filter(e=>n||e.length===t.size).some(e=>e.every(e=>t.has(e)))}function DK(e,t){return t.includes(e)?`code`:`key`}var OK=()=>{let e=ZG();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=BU(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 FU(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=IU(t,n);return{x:o.x+i,y:o.y+a}}}),[])};function kK(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)AK(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 AK(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 jK(e,t){return kK(e,t)}function MK(e,t){return kK(e,t)}function NK(e,t){return{id:e,type:`select`,selected:t}}function PK(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(NK(a.id,e)))}return r}function FK({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 IK(e){return{id:e.id,type:`remove`}}var LK=NU(`React Flow`,`https://reactflow.dev/`);function RK(e,t,n={}){return fW(e,t,{...n,onError:n.onError??LK})}var zK=e=>sU(e),BK=e=>oU(e);function VK(e){return(0,U.forwardRef)(e)}var HK=typeof window<`u`?U.useLayoutEffect:U.useEffect;function UK(e){let[t,n]=(0,U.useState)(BigInt(0)),[r]=(0,U.useState)(()=>WK(()=>n(e=>e+BigInt(1))));return HK(()=>{let t=r.get();t.length&&(e(t),r.reset())},[t]),r}function WK(e){let t=[];return{get:()=>t,reset:()=>{t=[]},push:n=>{t.push(n),e()}}}var GK=(0,U.createContext)(null);function KK({children:e}){let t=ZG(),n=UK((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=FK({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=UK((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(FK({items:s,lookup:o}))},[])),i=(0,U.useMemo)(()=>({nodeQueue:n,edgeQueue:r}),[]);return(0,G.jsx)(GK.Provider,{value:i,children:e})}function qK(){let e=(0,U.useContext)(GK);if(!e)throw Error(`useBatchContext must be used within a BatchProvider`);return e}var JK=e=>!!e.panZoom;function YK(){let e=OK(),t=ZG(),n=qK(),r=XG(JK),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=zK(e)?e:n.get(e.id),a=i.parentId?GU(i.position,i.measured,i.parentId,n,r):i.position;return EU({...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&&zK(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&&BK(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 _U({nodesToRemove:e,edgesToRemove:n,nodes:r,edges:i,onBeforeDelete:u}),p=f.length>0,m=d.length>0;if(p){let e=f.map(IK);o?.(f),c(e)}if(m){let e=d.map(IK);a?.(d),s(e)}return(m||p)&&l?.({nodes:d,edges:f}),{deletedNodes:d,deletedEdges:f}},getIntersectingNodes:(e,n=!0,r)=>{let i=jU(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=EU(s?r:a),l=AU(c,o);return n&&l>0||l>=c.width*c.height||l>=o.width*o.height}):[]},isNodeIntersecting:(e,t,n=!0)=>{let r=jU(e)?e:a(e);if(!r)return!1;let i=AU(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 uU(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??qU();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 XK=e=>e.selected,ZK=typeof window<`u`?window:void 0;function QK({deleteKeyCode:e,multiSelectionKeyCode:t}){let n=ZG(),{deleteElements:r}=YK(),i=TK(e,{actInsideInputWithModifier:!1}),a=TK(t,{target:ZK});(0,U.useEffect)(()=>{if(i){let{edges:e,nodes:t}=n.getState();r({nodes:t.filter(XK),edges:e.filter(XK)}),n.setState({nodesSelectionActive:!1})}},[i]),(0,U.useEffect)(()=>{n.setState({multiSelectionActive:a})},[a])}function $K(e){let t=ZG();(0,U.useEffect)(()=>{let n=()=>{if(!e.current||!(e.current.checkVisibility?.()??!0))return!1;let n=XU(e.current);(n.height===0||n.width===0)&&t.getState().onError?.(`004`,JH.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 eq={position:`absolute`,width:`100%`,height:`100%`,top:0,left:0},tq=e=>({userSelectionActive:e.userSelectionActive,lib:e.lib,connectionInProgress:e.connection.inProgress});function nq({onPaneContextMenu:e,zoomOnScroll:t=!0,zoomOnPinch:n=!0,panOnScroll:r=!1,panOnScrollSpeed:i=.5,panOnScrollMode:a=$H.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=ZG(),S=(0,U.useRef)(null),{userSelectionActive:C,lib:w,connectionInProgress:T}=XG(tq,KG),E=TK(f),D=(0,U.useRef)();$K(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=xG({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:eq,children:m})}var rq=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function iq(){let{userSelectionActive:e,userSelectionRect:t}=XG(rq,KG);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 aq=(e,t)=>n=>{n.target===t.current&&e?.(n)},oq=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging,panBy:e.panBy,autoPanSpeed:e.autoPanSpeed});function sq({isSelecting:e,selectionKeyPressed:t,selectionMode:n=eU.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),_=ZG(),{userSelectionActive:v,elementsSelectable:y,dragging:b,panBy:x,autoPanSpeed:S}=XG(oq,KG),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}=tW(n.nativeEvent,T.current),l=FU({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}=IU(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(fU(a,m,i,n===eU.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)}}KU(h,E.current)||c(PK(a,E.current,!0)),KU(g,D.current)||l(PK(o,D.current)),_.setState({userSelectionRect:m,userSelectionActive:!0,nodesSelectionActive:!1})}function L(){if(!i||!T.current)return;let[e,t]=SU(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:uL([`react-flow__pane`,{draggable:r===!0||Array.isArray(r)&&r.includes(0),dragging:b,selection:e}]),onClick:C?void 0:aq(M,w),onContextMenu:aq(N,w),onWheel:aq(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}=tW(e.nativeEvent,T.current);A.current={x:o,y:c};let l=IU({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:eq,children:[h,(0,G.jsx)(iq,{})]})}function cq({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`,JH.error012(e));return}t.setState({nodesSelectionActive:!1}),l.selected?(n||l.selected&&o)&&(a({nodes:[l],edges:[]}),requestAnimationFrame(()=>r?.current?.blur())):i([e])}function lq({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:i,isSelectable:a,nodeClickDistance:o}){let s=ZG(),[c,l]=(0,U.useState)(!1),u=(0,U.useRef)();return(0,U.useEffect)(()=>{if(!t)return u.current=XW({getStoreItems:()=>s.getState(),onNodeMouseDown:t=>{cq({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 uq=e=>t=>t.selected&&(t.draggable||e&&t.draggable===void 0);function dq(){let e=ZG();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=uq(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=PU(t,i));let{position:a,positionAbsolute:s}=gU({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 fq=(0,U.createContext)(null),pq=fq.Provider;fq.Consumer;var mq=()=>(0,U.useContext)(fq),hq=e=>({connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName,rfId:e.rfId}),gq=(0,U.createContext)(null);function _q({children:e}){let t=XG(hq,KG);return(0,G.jsx)(gq.Provider,{value:t,children:e})}function vq(){let e=(0,U.useContext)(gq);if(!e)throw Error(`useHandleConfig must be used within a HandleConfigProvider`);return e}var yq={connectingFrom:!1,connectingTo:!1,clickConnecting:!1,isPossibleEndHandle:!0,connectionInProcess:!1,clickConnectionInProcess:!1,valid:!1},bq=(e,t,n)=>r=>{let{connectionClickStartHandle:i,connectionMode:a,connection:o}=r,{fromHandle:s,toHandle:c,isValid:l}=o;if(!s&&!i)return yq;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===QH.Strict?s?.type!==n:e!==s?.nodeId||t!==s?.id,connectionInProcess:!!s,clickConnectionInProcess:!!i,valid:u&&l}};function xq({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=ZG(),_=mq(),{connectOnClick:v,noPanClassName:y,rfId:b}=vq(),{connectingFrom:x,connectingTo:S,clickConnecting:C,isPossibleEndHandle:w,connectionInProcess:T,clickConnectionInProcess:E,valid:D}=XG(bq(_,m,e),KG);_||g.getState().onError?.(`010`,JH.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(RK(i,e,{onError:n}))}n?.(i),s?.(i)},k=e=>{if(!_)return;let t=eW(e.nativeEvent);if(i&&(t&&e.button===0||!t)){let t=g.getState();oG.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:uL([`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=ZU(t.target),h=n||c,{connection:v,isValid:y}=oG.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 Sq=(0,U.memo)(VK(xq));function Cq({data:e,isConnectable:t,sourcePosition:n=$.Bottom}){return(0,G.jsxs)(G.Fragment,{children:[e?.label,(0,G.jsx)(Sq,{type:`source`,position:n,isConnectable:t})]})}function wq({data:e,isConnectable:t,targetPosition:n=$.Top,sourcePosition:r=$.Bottom}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Sq,{type:`target`,position:n,isConnectable:t}),e?.label,(0,G.jsx)(Sq,{type:`source`,position:r,isConnectable:t})]})}function Tq(){return null}function Eq({data:e,isConnectable:t,targetPosition:n=$.Top}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(Sq,{type:`target`,position:n,isConnectable:t}),e?.label]})}var Dq={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}},Oq={input:Cq,default:wq,output:Eq,group:Tq};function kq(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 Aq=e=>{let{width:t,height:n,x:r,y:i}=dU(e.nodeLookup,{filter:e=>!!e.selected});return{width:MU(t)?t:null,height:MU(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 jq({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){let r=ZG(),{width:i,height:a,transformString:o,userSelectionActive:s}=XG(Aq,KG),c=dq(),l=(0,U.useRef)(null);(0,U.useEffect)(()=>{n||l.current?.focus({preventScroll:!0})},[n]);let u=!s&&i!==null&&a!==null;if(lq({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:uL([`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(Dq,e.key)&&(e.preventDefault(),c({direction:Dq[e.key],factor:e.shiftKey?4:1}))},style:{width:i,height:a}})})}var Mq=typeof window<`u`?window:void 0,Nq=e=>({nodesSelectionActive:e.nodesSelectionActive,userSelectionActive:e.userSelectionActive});function Pq({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}=XG(Nq,KG),te=TK(l,{target:Mq}),ne=TK(h,{target:Mq}),re=ne||w,R=ne||b,ie=u&&re!==!0,ae=te||L||ie;return QK({deleteKeyCode:c,multiSelectionKeyCode:m}),(0,G.jsx)(nq,{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)(sq,{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)(jq,{onSelectionContextMenu:j,noPanClassName:N,disableKeyboardA11y:P})]})})}Pq.displayName=`FlowRenderer`;var Fq=(0,U.memo)(Pq),Iq=e=>t=>e?fU(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 Lq(e){return XG((0,U.useCallback)(Iq(e),[e]),KG)}var Rq=e=>e.updateNodeInternals;function zq(){let e=XG(Rq),[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 Bq({node:e,nodeType:t,hasDimensions:n,resizeObserver:r}){let i=ZG(),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 Vq({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}=XG(t=>{let n=t.nodeLookup.get(e),r=t.parentLookup.has(e);return{node:n,internals:n.internals,isParent:r}},KG),S=y.type||`default`,C=g?.[S]||Oq[S];C===void 0&&(v?.(`003`,JH.error003(S)),S=`default`,C=g?.default||Oq.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=ZG(),k=WU(y),A=Bq({node:y,nodeType:S,hasDimensions:k,resizeObserver:d}),j=lq({nodeRef:A,disabled:y.hidden||!w,noDragClassName:f,handleSelector:y.dragHandle,nodeId:e,isSelectable:T,nodeClickDistance:_}),M=dq();if(y.hidden)return null;let N=UU(y),P=kq(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)&&cq({id:e,store:O,nodeRef:A}),t&&t(n,{...b.userNode})},R=t=>{if(!($U(t.nativeEvent)||m)){if(XH.includes(t.key)&&T){let n=t.key===`Escape`;cq({id:e,store:O,unselect:n,nodeRef:A})}else if(w&&y.selected&&Object.prototype.hasOwnProperty.call(Dq,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:Dq[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&&(fU(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:uL([`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:`${eK}-${h}`,"aria-label":y.ariaLabel,...y.domAttributes,children:(0,G.jsx)(pq,{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 Hq=(0,U.memo)(Vq),Uq=e=>({nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,onError:e.onError});function Wq(e){let{nodesConnectable:t,nodesFocusable:n,elementsSelectable:r,onError:i}=XG(Uq,KG),a=Lq(e.onlyRenderVisibleElements),o=zq();return(0,G.jsx)(`div`,{className:`react-flow__nodes`,style:eq,children:a.map(a=>(0,G.jsx)(Hq,{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))})}Wq.displayName=`NodeRenderer`;var Gq=(0,U.memo)(Wq);function Kq(e){return XG((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&&lW({sourceNode:r,targetNode:i,width:t.width,height:t.height,transform:t.transform})&&n.push(e.id)}return n},[e]),KG)}var qq=({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`}),Jq=({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`}),Yq={[rU.Arrow]:qq,[rU.ArrowClosed]:Jq};function Xq(e){let t=ZG();return(0,U.useMemo)(()=>Object.prototype.hasOwnProperty.call(Yq,e)?Yq[e]:(t.getState().onError?.(`009`,JH.error009(e)),null),[e])}var Zq=({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=Xq(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},Qq=({defaultColor:e,rfId:t})=>{let n=XG(e=>e.edges),r=XG(e=>e.defaultEdgeOptions),i=(0,U.useMemo)(()=>EW(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)(Zq,{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};Qq.displayName=`MarkerDefinitions`;var $q=(0,U.memo)(Qq);function eJ({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=uL([`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}eJ.displayName=`EdgeText`;var tJ=(0,U.memo)(eJ);function nJ({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:uL([`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&&MU(t)&&MU(n)?(0,G.jsx)(tJ,{x:t,y:n,label:r,labelStyle:i,labelShowBg:a,labelBgStyle:o,labelBgPadding:s,labelBgBorderRadius:c}):null]})}function rJ({pos:e,x1:t,y1:n,x2:r,y2:i}){return e===$.Left||e===$.Right?[.5*(t+r),n]:[t,.5*(n+i)]}function iJ({sourceX:e,sourceY:t,sourcePosition:n=$.Bottom,targetX:r,targetY:i,targetPosition:a=$.Top}){let[o,s]=rJ({pos:n,x1:e,y1:t,x2:r,y2:i}),[c,l]=rJ({pos:a,x1:r,y1:i,x2:e,y2:t}),[u,d,f,p]=rW({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 aJ(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]=iJ({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s});return(0,G.jsx)(nJ,{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 oJ=aJ({isInternal:!1}),sJ=aJ({isInternal:!0});oJ.displayName=`SimpleBezierEdge`,sJ.displayName=`SimpleBezierEdgeInternal`;function cJ(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]=yW({sourceX:n,sourceY:r,sourcePosition:p,targetX:i,targetY:a,targetPosition:m,borderRadius:_?.borderRadius,offset:_?.offset,stepPosition:_?.stepPosition});return(0,G.jsx)(nJ,{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 lJ=cJ({isInternal:!1}),uJ=cJ({isInternal:!0});lJ.displayName=`SmoothStepEdge`,uJ.displayName=`SmoothStepEdgeInternal`;function dJ(e){return(0,U.memo)(({id:t,...n})=>{let r=e.isInternal?void 0:t;return(0,G.jsx)(lJ,{...n,id:r,pathOptions:(0,U.useMemo)(()=>({borderRadius:0,offset:n.pathOptions?.offset}),[n.pathOptions?.offset])})})}var fJ=dJ({isInternal:!1}),pJ=dJ({isInternal:!0});fJ.displayName=`StepEdge`,pJ.displayName=`StepEdgeInternal`;function mJ(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]=pW({sourceX:n,sourceY:r,targetX:i,targetY:a});return(0,G.jsx)(nJ,{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 hJ=mJ({isInternal:!1}),gJ=mJ({isInternal:!0});hJ.displayName=`StraightEdge`,gJ.displayName=`StraightEdgeInternal`;function _J(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]=oW({sourceX:n,sourceY:r,sourcePosition:o,targetX:i,targetY:a,targetPosition:s,curvature:_?.curvature});return(0,G.jsx)(nJ,{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 vJ=_J({isInternal:!1}),yJ=_J({isInternal:!0});vJ.displayName=`BezierEdge`,yJ.displayName=`BezierEdgeInternal`;var bJ={default:yJ,straight:gJ,step:pJ,smoothstep:uJ,simplebezier:sJ},xJ={sourceX:null,sourceY:null,targetX:null,targetY:null,sourcePosition:null,targetPosition:null,zIndex:void 0},SJ=(e,t,n)=>n===$.Left?e-t:n===$.Right?e+t:e,CJ=(e,t,n)=>n===$.Top?e-t:n===$.Bottom?e+t:e,wJ=`react-flow__edgeupdater`;function TJ({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:uL([wJ,`${wJ}-${s}`]),cx:SJ(t,r,e),cy:CJ(n,r,e),r,stroke:`transparent`,fill:`transparent`})}function EJ({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=ZG(),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`;oG.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)(TJ,{position:s,centerX:r,centerY:i,radius:t,onMouseDown:g,onMouseEnter:v,onMouseOut:y,type:`source`}),(e===!0||e===`target`)&&(0,G.jsx)(TJ,{position:c,centerX:a,centerY:o,radius:t,onMouseDown:_,onMouseEnter:v,onMouseOut:y,type:`target`})]})}function DJ({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=XG(t=>t.edgeLookup.get(e)),b=XG(e=>e.defaultEdgeOptions);y=b?{...b,...y}:y;let x=y.type||`default`,S=h?.[x]||bJ[x];S===void 0&&(_?.(`011`,JH.error011(x)),x=`default`,S=h?.default||bJ.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=ZG(),{zIndex:M=y.zIndex,sourceX:N,sourceY:P,targetX:ee,targetY:F,sourcePosition:I,targetPosition:L}=XG((0,U.useCallback)(t=>{let n=t.nodeLookup.get(y.source),r=t.nodeLookup.get(y.target);if(!n||!r)return xJ;let i=xW({id:e,sourceNode:n,targetNode:r,sourceHandle:y.sourceHandle||null,targetHandle:y.targetHandle||null,connectionMode:t.connectionMode,onError:_}),a=cW({selected:y.selected,zIndex:y.zIndex,sourceNode:n,targetNode:r,elevateOnSelect:t.elevateEdgesOnSelect,zIndexMode:t.zIndexMode});return{...i||xJ,zIndex:a}},[y.source,y.target,y.sourceHandle,y.targetHandle,y.selected,y.zIndex]),KG),te=(0,U.useMemo)(()=>y.markerStart?`url('#${TW(y.markerStart,m)}')`:void 0,[y.markerStart,m]),ne=(0,U.useMemo)(()=>y.markerEnd?`url('#${TW(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:uL([`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&&XH.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?`${tK}-${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)(EJ,{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 OJ=(0,U.memo)(DJ),kJ=e=>({edgesFocusable:e.edgesFocusable,edgesReconnectable:e.edgesReconnectable,elementsSelectable:e.elementsSelectable,connectionMode:e.connectionMode,onError:e.onError});function AJ({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}=XG(kJ,KG),b=Kq(t);return(0,G.jsxs)(`div`,{className:`react-flow__edges`,children:[(0,G.jsx)($q,{defaultColor:e,rfId:n}),b.map(e=>(0,G.jsx)(OJ,{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))]})}AJ.displayName=`EdgeRenderer`;var jJ=(0,U.memo)(AJ),MJ=e=>`translate(${e[0]}px,${e[1]}px) scale(${e[2]})`;function NJ({children:e}){let t=ZG(),n=(0,U.useRef)(null),[r]=(0,U.useState)(()=>t.getState().transform);return HK(()=>{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=MJ(r)))};return r(),t.subscribe(r)},[t]),(0,G.jsx)(`div`,{ref:n,className:`react-flow__viewport xyflow__viewport react-flow__container`,style:{transform:MJ(r)},children:e})}function PJ(e){let t=YK(),n=(0,U.useRef)(!1);(0,U.useEffect)(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}var FJ=e=>e.panZoom?.syncViewport;function IJ(e){let t=XG(FJ),n=ZG();return(0,U.useEffect)(()=>{e&&(t?.(e),n.setState({transform:[e.x,e.y,e.zoom]}))},[e,t]),null}function LJ(e){return e.connection.inProgress?{...e.connection,to:FU(e.connection.to,e.transform)}:{...e.connection}}function RJ(e){return e?t=>e(LJ(t)):LJ}function zJ(e){return XG(RJ(e),KG)}var BJ=e=>({nodesConnectable:e.nodesConnectable,isValid:e.connection.isValid,inProgress:e.connection.inProgress,width:e.width,height:e.height});function VJ({containerStyle:e,style:t,type:n,component:r}){let{nodesConnectable:i,width:a,height:o,isValid:s,inProgress:c}=XG(BJ,KG);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:uL([`react-flow__connection`,aU(s)]),children:(0,G.jsx)(HJ,{style:t,type:n,CustomComponent:r,isValid:s})})}):null}var HJ=({style:e,type:t=nU.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}=zJ();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:aU(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 nU.Bezier:[m]=oW(h);break;case nU.SimpleBezier:[m]=iJ(h);break;case nU.Step:[m]=yW({...h,borderRadius:0});break;case nU.SmoothStep:[m]=yW(h);break;default:[m]=pW(h)}return(0,G.jsx)(`path`,{d:m,fill:`none`,className:`react-flow__connection-path`,style:e})};HJ.displayName=`ConnectionLine`;var UJ={};function WJ(e=UJ){(0,U.useRef)(e),ZG(),(0,U.useEffect)(()=>{},[e])}function GJ(){ZG(),(0,U.useRef)(!1),(0,U.useEffect)(()=>{},[])}function KJ({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 WJ(e),WJ(t),GJ(),PJ(n),IJ(z),(0,G.jsx)(Fq,{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)(NJ,{children:[(0,G.jsx)(jJ,{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)(VJ,{style:h,type:m,component:g,containerStyle:_}),(0,G.jsx)(`div`,{className:`react-flow__edgelabel-renderer`}),(0,G.jsx)(Gq,{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`})]})})}KJ.displayName=`GraphView`;var qJ=(0,U.memo)(KJ),JJ=NU(`React Flow`,`https://reactflow.dev/`),YJ=({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??YH;WW(h,g,_);let{nodesInitialized:x}=FW(v,p,m,{nodeOrigin:y,nodeExtent:b,zIndexMode:f}),S=[0,0,1];if(o&&i&&a){let{x:e,y:t,zoom:n}=BU(dU(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:YH,nodeExtent:b,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionMode:QH.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:{...tU},connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:``,autoPanOnConnect:!0,autoPanOnNodeDrag:!0,autoPanOnNodeFocus:!0,autoPanSpeed:15,connectionRadius:20,onError:JJ,isValidConnection:void 0,onSelectionChangeHandlers:[],lib:`react`,debug:!1,ariaLabelConfig:ZH,zIndexMode:f,onNodesChangeMiddlewareMap:new Map,onEdgesChangeMiddlewareMap:new Map}},XJ=({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})=>GG((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 hU({nodes:e,width:i,height:a,panZoom:t,minZoom:o,maxZoom:s},n),r?.resolve(!0),p({fitViewResolver:null}))}return{...YJ({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}=FW(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();WW(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}=VW(e,n,r,i,a,o,l);d&&(MW(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=CW(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=BW(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(jK(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(MK(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=>NK(e,!0)));return}i(PK(r,new Set([...e]),!0)),a(PK(n))},addSelectedEdges:e=>{let{multiSelectionActive:t,edgeLookup:n,nodeLookup:r,triggerNodeChanges:i,triggerEdgeChanges:a}=m();if(t){a(e.map(e=>NK(e,!0)));return}a(PK(n,new Set([...e]))),i(PK(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(NK(e.id,!1))}let u=[];for(let e of c)e.selected&&u.push(NK(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,NK(t.id,!1)]:e,[]),o=e.reduce((e,t)=>t.selected?[...e,NK(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]||(FW(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 HW({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:{...tU}})},updateConnection:e=>{p({connection:e})},reset:()=>p({...YJ()})}},Object.is);function ZJ({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)(()=>XJ({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)(JG,{value:m,children:(0,G.jsx)(KK,{children:(0,G.jsx)(_q,{children:p})})})}function QJ({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)(qG)?(0,G.jsx)(G.Fragment,{children:e}):(0,G.jsx)(ZJ,{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 $J={width:`100%`,height:`100%`,overflow:`hidden`,position:`relative`,zIndex:0};function eY({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=nU.Bezier,connectionLineStyle:te,connectionLineComponent:ne,connectionLineContainerStyle:re,deleteKeyCode:R=`Backspace`,selectionKeyCode:ie=`Shift`,selectionOnDrag:ae=!1,selectionMode:oe=eU.Full,panActivationKeyCode:se=`Space`,multiSelectionKeyCode:ce=VU()?`Meta`:`Control`,zoomActivationKeyCode:le=VU()?`Meta`:`Control`,snapToGrid:ue,snapGrid:de,onlyRenderVisibleElements:fe=!1,selectNodesOnDrag:pe,nodesDraggable:me,autoPanOnNodeFocus:he,nodesConnectable:ge,nodesFocusable:_e,nodeOrigin:ve=gK,edgesFocusable:ye,edgesReconnectable:be,elementsSelectable:xe=!0,defaultViewport:Se=_K,minZoom:Ce=.5,maxZoom:z=2,translateExtent:we=YH,preventScrolling:Te=!0,nodeExtent:Ee,defaultMarkerColor:De=`#b1b1b7`,zoomOnScroll:Oe=!0,zoomOnPinch:ke=!0,panOnScroll:Ae=!1,panOnScrollSpeed:je=.5,panOnScrollMode:Me=$H.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=CK(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,...$J},ref:At,className:uL([`react-flow`,i,Mt]),id:_t,role:`application`,children:(0,G.jsxs)(QJ,{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)(xK,{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)(qJ,{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)(hK,{onSelectionChange:k}),V,(0,G.jsx)(lK,{proOptions:H,position:at}),(0,G.jsx)(oK,{rfId:jt,disableKeyboardA11y:lt})]})})}var tY=VK(eY);JH.error014();function nY({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:uL([`react-flow__background-pattern`,n,r])})}function rY({radius:e,className:t}){return(0,G.jsx)(`circle`,{cx:e,cy:e,r:e,className:uL([`react-flow__background-pattern`,`dots`,t])})}var iY;(function(e){e.Lines=`lines`,e.Dots=`dots`,e.Cross=`cross`})(iY||={});var aY={[iY.Dots]:1,[iY.Lines]:1,[iY.Cross]:6},oY=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function sY({id:e,variant:t=iY.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}=XG(oY,KG),m=r||aY[t],h=t===iY.Dots,g=t===iY.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:uL([`react-flow__background`,l]),style:{...c,...eq,"--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)(rY,{radius:y/2,className:u}):(0,G.jsx)(nY,{dimensions:x,lineWidth:i,variant:t,className:u})}),(0,G.jsx)(`rect`,{x:`0`,y:`0`,width:`100%`,height:`100%`,fill:`url(#${C})`})]})}sY.displayName=`Background`;var cY=(0,U.memo)(sY);function lY(){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 uY(){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 dY(){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 fY(){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 pY(){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 mY({children:e,className:t,...n}){return(0,G.jsx)(`button`,{type:`button`,className:uL([`react-flow__controls-button`,t]),...n,children:e})}var hY=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom,ariaLabelConfig:e.ariaLabelConfig});function gY({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=ZG(),{isInteractive:h,minZoomReached:g,maxZoomReached:_,ariaLabelConfig:v}=XG(hY,KG),{zoomIn:y,zoomOut:b,fitView:x}=YK();return(0,G.jsxs)(sK,{className:uL([`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)(mY,{onClick:()=>{y(),a?.()},className:`react-flow__controls-zoomin`,title:v[`controls.zoomIn.ariaLabel`],"aria-label":v[`controls.zoomIn.ariaLabel`],disabled:_,children:(0,G.jsx)(lY,{})}),(0,G.jsx)(mY,{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)(uY,{})})]}),n&&(0,G.jsx)(mY,{className:`react-flow__controls-fitview`,onClick:()=>{x(i),s?.()},title:v[`controls.fitView.ariaLabel`],"aria-label":v[`controls.fitView.ariaLabel`],children:(0,G.jsx)(dY,{})}),r&&(0,G.jsx)(mY,{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)(pY,{}):(0,G.jsx)(fY,{})}),u]})}gY.displayName=`Controls`;var _Y=(0,U.memo)(gY);function vY({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:uL([`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 yY=(0,U.memo)(vY),bY=e=>e.nodes.map(e=>e.id),xY=e=>e instanceof Function?e:()=>e;function SY({nodeStrokeColor:e,nodeColor:t,nodeClassName:n=``,nodeBorderRadius:r=5,nodeStrokeWidth:i,nodeComponent:a=yY,onClick:o}){let s=XG(bY,KG),c=xY(t),l=xY(e),u=xY(n),d=typeof window>`u`||window.chrome?`crispEdges`:`geometricPrecision`;return(0,G.jsx)(G.Fragment,{children:s.map(e=>(0,G.jsx)(wY,{id:e,nodeColorFunc:c,nodeStrokeColorFunc:l,nodeClassNameFunc:u,nodeBorderRadius:r,nodeStrokeWidth:i,NodeComponent:a,onClick:o,shapeRendering:d},e))})}function CY({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}=XG(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}=UU(r);return{node:r,x:i,y:a,width:o,height:s}},KG);return!l||l.hidden||!WU(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 wY=(0,U.memo)(CY),TY=(0,U.memo)(SY),EY=200,DY=150,OY=e=>!e.hidden,kY=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?OU(dU(e.nodeLookup,{filter:OY}),t):t,rfId:e.rfId,panZoom:e.panZoom,translateExtent:e.translateExtent,flowWidth:e.width,flowHeight:e.height,ariaLabelConfig:e.ariaLabelConfig}},AY=(e,t)=>e.x===t.x&&e.y===t.y&&e.width===t.width&&e.height===t.height,jY=(e,t)=>AY(e.viewBB,t.viewBB)&&AY(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,MY=`react-flow__minimap-desc`;function NY({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=ZG(),S=(0,U.useRef)(null),{boundingRect:C,viewBB:w,rfId:T,panZoom:E,translateExtent:D,flowWidth:O,flowHeight:k,ariaLabelConfig:A}=XG(kY,jY),j=e?.width??EY,M=e?.height??DY,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=`${MY}-${T}`,ae=(0,U.useRef)(0),oe=(0,U.useRef)();ae.current=ee,(0,U.useEffect)(()=>{if(S.current&&E)return oe.current=sG({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)(sK,{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:uL([`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)(TY,{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`})]})})}NY.displayName=`MiniMap`,(0,U.memo)(NY);var PY=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,FY={[SG.Line]:`right`,[SG.Handle]:`bottom-right`};function IY({nodeId:e,position:t,variant:n=SG.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=mq(),y=typeof e==`string`?e:v,b=ZG(),x=(0,U.useRef)(null),S=n===SG.Handle,C=XG((0,U.useCallback)(PY(S&&p),[S,p]),KG),w=(0,U.useRef)(null),T=t??FY[n];return(0,U.useEffect)(()=>{if(!(!x.current||!y))return w.current||=NG({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=BW([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...GU({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:uL([`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)(IY);function LY(e){return e.graph??void 0}function RY(e){return{run:e.run_node_sets??[],nodes:new Map(e.plan.tasks.map(e=>[e.id,e.sets??[]]))}}function zY(e){let t=LY(e);if(!t)return[];let n=new Map(e.run.nodes.map(e=>[e.node,e]));return t.plan.tasks.flatMap(r=>{let i=JY(r,`kind`)===`human`?`human`:YY(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:JY(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 BY(e){switch(e?.launcher){case`claude-code`:return`Claude`;case`codex`:return`Codex`;default:return`Unattributed`}}function VY(e){let t=BY(e);return e?.session_key===void 0?e===void 0?`Unattributed`:`${t} launch · ${XY(e.launch_id)}`:`${t} session · ${XY(e.session_key)}`}function HY(e){if(e.blockers.length>0&&WY.has(e.status))return`blocked by ${e.blockers.join(`, `)}`;if(GY.has(e.status))return UY(e)??`${e.status}, with no reason recorded`}function UY(e){return(e.failure?.detail||e.result?.detail||e.result?.error||e.telemetry?.outcome||e.result?.outcome)?.trim()||void 0}var WY=new Set([`blocked`,`skipped`,`waiting`]),GY=new Set([`failed`,`not-completed`,`cancelled`]);function KY(e){let t=tL,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 qY(e){return GY.has(e)||e===`blocked`||e===`skipped`}function JY(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function YY(e){return`repo`in e||`steps`in e}function XY(e){return e.length>12?`${e.slice(0,8)}…`:e}function ZY({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)(Sq,{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)(Sq,{type:`source`,position:$.Right})]})}function QY({data:e,id:t,markerEnd:n,style:r}){return(0,G.jsx)(nJ,{id:t,path:$Y(e?.points??[]),markerEnd:n,style:r})}function $Y(e){let[t,...n]=e;return t?`M ${t.x} ${t.y} ${n.map(e=>`L ${e.x} ${e.y}`).join(` `)}`:``}var eX={dagNode:ZY},tX={routed:QY};function nX({nodes:e,selectedNodeId:t,onSelectNode:n}){let r=(0,U.useMemo)(()=>{let t=new Map;for(let n of e)qY(n.status)&&t.set(n.id,HY(n));return t},[e]),{nodes:i,edges:a}=(0,U.useMemo)(()=>{let n=new Set(e.map(e=>e.id)),i=lL({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)}},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)(tY,{nodes:i,edges:a,colorMode:`dark`,nodeTypes:eX,edgeTypes:tX,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)(cY,{color:`var(--border)`,gap:22}),(0,G.jsx)(_Y,{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 rX({className:e,state:t}){let n=iX(t);return(0,G.jsxs)(Fa,{className:H(`gap-1.5 tracking-[.03em] uppercase`,n&&oX[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 iX(e){return fX[e]}var aX=e=>{let t=iX(e);return H(`size-2 shrink-0 rounded-full bg-current`,t===void 0?`text-muted-foreground`:sX[t])},oX={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`},sX={success:`text-success`,destructive:`text-destructive`,warning:`text-warning`,info:`text-info`},cX=`success`,lX=`destructive`,uX=`warning`,dX={blocked:uX,cancelled:lX,done:cX,failed:lX,"not-completed":lX,parked:void 0,pending:void 0,running:`info`,skipped:uX,unknown:void 0,waiting:void 0},fX={...dX,complete:dX.done,settled:dX.done,active:dX.running},pX={graph:`graph`,overall:`overall`,channel:`channel`,watch:`watch`,reads:`reads`,agents:`agents`};function mX(e){return e!==null&&Object.hasOwn(pX,e)}var hX={projects:`projects`,runs:`runs`};function gX(e){return e!==null&&Object.hasOwn(hX,e)}var _X=`none`,vX={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 yX(e){return e!==null&&Object.hasOwn(vX,e)}var bX={timeline:`Timeline`,task:`Task`,criteria:`Acceptance criteria`,dependencies:`Dependencies`,pr:`PR`,checks:`Checks`,agents:`Agents`};function xX(e){return e!==null&&Object.hasOwn(bX,e)}function SX(e){let t=[...e].some(e=>e.charCodeAt(0)<32);return e.length>0&&e.length<=512&&!t&&!/[/?#]/u.test(e)}function CX(e,t){let n=e.get(t);return n!==null&&SX(n)?n:void 0}function wX(){let e=(0,U.useSyncExternalStore)(TX,EX,EX),t=new URLSearchParams(e),n=t.get(`list`),r=gX(n)?n:`projects`,i=t.get(`project`),a=i!==null&&(i===`none`||Zj(i))?i:void 0,o=CX(t,`run`),s=CX(t,`node`),c=CX(t,`event`),l=t.get(`view`),u=t.get(`tab`),d=t.get(`detail`),f=yX(d)?d:`activity`,p=xX(u)?u:`timeline`,m=mX(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 TX(e){return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}function EX(){return window.location.search}var DX=`(no project)`;function OX(e){return e.project===null?DX:e.name??e.project}function kX(e){return e.project===null?e.name??void 0:e.name===null?void 0:e.project}function AX(e){return e.project??`none`}function jX(e,t){return e.find(e=>AX(e)===t)}function MX(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 NX(e){return`${e.length} ${e.length===1?`run`:`runs`}`}function PX(e){if(e.agent_count!==void 0)return`${e.agent_count} ${e.agent_count===1?`agent`:`agents`}`}function FX({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=AX(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:OX(e)})]}),(0,G.jsx)(wt,{"aria-hidden":`true`,size:14}),kX(e)!==void 0&&(0,G.jsx)(`span`,{className:`run-link-counts`,title:kX(e),children:kX(e)}),(0,G.jsx)(`span`,{className:`run-link-counts`,children:[NX(e.runs),MX(e.runs),PX(e)].filter(Boolean).join(` · `)}),(0,G.jsx)(`span`,{className:`run-link-tag`,children:e.last_write_at===null?`never written`:(0,G.jsx)(aF,{at:rF(e.last_write_at),relative:!0})})]})},r)})})}var IX={projects:`Projects`,runs:`Runs`};function LX({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(hX).map(n=>(0,G.jsx)(La,{"aria-pressed":e===n,onClick:()=>t(n),size:`sm`,type:`button`,variant:e===n?`default`:`outline`,children:IX[n]},n))]}),e===`projects`?n===void 0?(0,G.jsx)(`p`,{"aria-live":`polite`,className:`run-list-status`,children:`Loading projects…`}):(0,G.jsx)(FX,{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=KY(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`,aX(e.state)),"data-live":`true`,role:`img`})}),(0,G.jsx)(_m,{children:`Live`})]}):(0,G.jsx)(`span`,{"aria-label":`Historical`,className:H(`run-dot`,aX(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}),VY(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 RX({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)(VX,{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(AX(e)),type:`button`,children:[(0,G.jsx)(`span`,{className:`project-card-name`,children:OX(e)}),(0,G.jsx)(wt,{"aria-hidden":`true`,size:14})]}),kX(e)!==void 0&&(0,G.jsx)(`p`,{className:`project-card-id`,children:kX(e)}),(0,G.jsxs)(`p`,{className:`project-card-facts`,children:[NX(e.runs),e.runs.length>0&&` · ${MX(e.runs)}`,PX(e)!==void 0&&` · ${PX(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)(aF,{at:rF(e.last_write_at),relative:!0})]})})]})})},AX(e)))})]})})}function zX({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:OX(t)}),t!==void 0&&kX(t)!==void 0&&(0,G.jsx)(`p`,{className:`project-card-id`,children:kX(t)}),t&&(0,G.jsxs)(`p`,{className:`projects-lede`,children:[NX(t.runs),t.runs.length>0&&` · ${MX(t.runs)}`,PX(t)!==void 0&&` · ${PX(t)}`,t.last_write_at!==null&&(0,G.jsxs)(G.Fragment,{children:[` · last activity `,(0,G.jsx)(aF,{at:rF(t.last_write_at),relative:!0})]})]}),n&&(0,G.jsx)(VX,{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 ${OX(t)}`,className:`project-runs`,children:t.runs.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(BX,{onSelect:a,run:e})},e.run_id))}),i]}):null]})})}function BX({run:e,onSelect:t}){let n=KY(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)(rX,{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)(aF,{at:rF(e.last_progress_at*1e3),relative:!0})]})})]})]})}function VX({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 HX(e,t,n){let{value:r,error:i}=QM(n?`projects`:void 0,()=>e.listProjects(),t);return{list:r,error:i}}function UX(e,t,n){let{value:r,error:i,loading:a}=QM(t,()=>t===`none`?e.listProjects().then(e=>{let t=jX(e.projects,_X);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 WX(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(JX(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(JX(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=KX(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(GX).catch(e=>{o(()=>g(JX(e)))}),c=n===void 0?Promise.resolve():e.getTimeline(C,n.nodeId,r).then(e=>a(t=>({...t,timeline:e,timelineError:void 0}))).catch(GX).catch(e=>a(t=>({...t,timelineError:JX(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(UM(e.data)),A.current&&(b(e=>e+1),T(e=>e+1)),A.current=!0;return}let t=qX(e);t!==void 0&&(T(e=>e+1),ee(t).catch(e=>g(JX(e))),t===D.current&&b(e=>e+1))},onError:e=>{v(JX(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(Xj.parse(t))}(e.event===`conversation.changed`||e.event===`activity.changed`||e.event===`run.changed`)&&b(e=>e+1)}},onError:e=>v(JX(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 GX(e){if(!(e instanceof WM&&e.code===`run_not_found`))throw e}function KX(e,t,n){return[e,t??``,n??``].join(`\0`)}function qX(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 JX(e){return e instanceof Error?e:typeof Event<`u`&&e instanceof Event?Error(`Live telemetry stream disconnected`):Error(String(e))}var YX={minutes:60,seconds:1},XX=e=>Object.hasOwn(YX,e),ZX=600%YX.minutes==0?{amount:String(600/YX.minutes),unit:`minutes`}:{amount:`600`,unit:`seconds`};function QX(e){let t=e.amount.trim();if(!/^\d+$/u.test(t))return;let n=Number(t)*YX[e.unit];return Number.isSafeInteger(n)?n:void 0}function $X(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 eZ(e,t){let n=e?.session_key;return t!==null&&n!==void 0&&n===t}function tZ(e,t,n){let r=eZ(t,n);return{runId:e,owner:r?`this session (${VY(t)})`:VY(t),mine:r,unowned:t?.session_key===void 0}}function nZ(e,t,n){let r=t.map(e=>tZ(e.run_id,e.launch,n));return e===`mine`?r.filter(e=>e.mine):r}function rZ(e,t){return t instanceof WM&&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 iZ={dispatchStopped:`dispatch-stopped`,hostShutdown:`host-shutdown`};function aZ(e,t,n){let r=new Set(e.runs.map(({runId:e})=>e)),i=Object.values(iZ);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===iZ.hostShutdown?iZ.hostShutdown:iZ.dispatchStopped}]})}function oZ(e){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).format(e)}var sZ={run:`Shut down this run?`,mine:`Shut down all my runs?`,host:`Shut down the entire host?`},cZ=`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 lZ({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)(ZX),[d,f]=(0,U.useState)(!1),p=QX(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(ZX),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}?`:sZ[e]}),(0,G.jsx)(Dc,{children:cZ})]}),(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)(dZ,{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)(fZ,{caption:`It acts on the ${uZ(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)(fZ,{caption:`It acts on ${uZ(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)(fZ,{caption:`And on the ${uZ(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;XX(t)&&u({...l,unit:t})},value:l.unit,children:Object.keys(YX).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: ${$X(p)}. The engine's default is ${$X(QX(ZX)??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 uZ=e=>e===1?`1 run`:`${e} runs`;function dZ({run:e}){return e===void 0?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fZ,{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 fZ({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 pZ(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 mZ(e,t,n,r){let[i,a]=(0,U.useState)(),[o,s]=(0,U.useState)(0),c=QM(i===void 0?void 0:`acting-${o}`,()=>e.unwatched(),0),l=hZ(i!==void 0,t,n,r),{acting:u,blocked:d}=pZ(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:nZ(i,l.rows,u),blocked:d??l.blocked,unreadable:t?.unreadable?.length??0}}function hZ(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 gZ(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(rZ(s,e))).finally(()=>{i.current=!1})},[e,t]),dismiss:(0,U.useCallback)(()=>{i.current||r({phase:`idle`})},[])}}var _Z=[`mine`,`host`];function vZ({runId:e,launched:t,unwatched:n,shutdown:r}){let[i,a]=(0,U.useState)(!1),{acting:o,blocked:s}=pZ(n),c=o===void 0||t===void 0?void 0:[tZ(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)(lZ,{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 yZ(e,t){return gZ(`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 bZ(e){return{mine:gZ(`mine`,(0,U.useCallback)(t=>e.shutdown(`mine`,t),[e])),host:gZ(`host`,(0,U.useCallback)(t=>e.shutdown(`host`,t),[e]))}}function xZ({client:e,list:t,loadMore:n,loadingMore:r,shutdowns:i}){let{open:a,setOpen:o,opener:s,runs:c,blocked:l,unreadable:u}=mZ(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`]})]}),_Z.map(e=>(0,G.jsx)(lZ,{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 SZ=1e3;function CZ(e,t){let[n,r]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),SZ);return()=>clearInterval(e)},[]);let i=aZ(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===iZ.hostShutdown).length,deadline:e.sentAt+e.grace*1e3,asks:!e.force&&e.grace>0}}function wZ({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)(EZ,{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 `,oZ(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)(TZ,{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)(OZ,{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 TZ({sent:e}){return(0,G.jsxs)(`p`,{className:`channel-age`,children:[`Sent `,oZ(e.sentAt),` · scope `,e.scope,` · grace`,` `,$X(e.grace),e.force?` · forced`:``,` · `,e.runs.length,` `,e.runs.length===1?`run`:`runs`,` in scope`]})}function EZ({sent:e,rows:t}){let{now:n,progress:r,done:i,deadline:a,asks:o}=CZ(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, `,QP(Math.max(0,n-e.sentAt)),` after it was sent.`]}),(0,G.jsx)(TZ,{sent:e}),(0,G.jsx)(`p`,{children:o?n<a?`Waiting out the ${$X(e.grace)} grace until ${oZ(a)} (${QP(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 ${oZ(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===iZ.hostShutdown?`put down — host-shutdown recorded after its teardown and pushes`:`its dispatches are stopping — dispatch-stopped recorded`]},e))})]})}function DZ(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 OZ({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 `,$X(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`,` `,QP(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,`: `,DZ(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 kZ({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 AZ(e){return e.charAt(0).toUpperCase()+e.slice(1)}var jZ=[[`recovery`,[`retry`,`retried`,`requeued`,`fallback`,`resolution`,`interrupted`,`cron`]],[`failure`,[`failed`,`died`,`rejected`,`refused`,`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`,`landing`,`landed`]],[`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`]]],MZ={"change-retitled":`publication`,"title-unverified":`verification`,"node-restack-started":`repository`,"node-restacked":`repository`,"review-comments-read":`publication`,"node-absorbed":`publication`,"node-readjusted":`repository`,"completion-requested":`lifecycle`,"command-accepted":`planning`,"body-not-drafted":`publication`,"criterion-checked":`verification`,"pool-maintenance":`lifecycle`,"dispatch-stopped":`lifecycle`,"host-shutdown":`lifecycle`};function NZ(e){return e.toLowerCase().split(`-`).filter(e=>e.length>0)}function PZ(e){let t=MZ[e];if(t!==void 0)return t;let n=NZ(e);return jZ.find(([,e])=>e.some(e=>n.includes(e)))?.[0]??`activity`}var FZ={recovery:tn,failure:cn,human:un,planning:kt,contention:Rt,verification:on,publication:Lt,repository:It,session:Jt,lifecycle:Yt,activity:Ot};function IZ({category:e,className:t=`size-3`}){let n=FZ[e];return(0,G.jsx)(n,{"aria-hidden":`true`,className:t})}function LZ(e){return e===`human-step`?`human step`:e}function RZ(e){return e.style===`human-step`}function zZ(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 BZ(e){if(e!==void 0)return e?`yes — a later acknowledgement replaced this one`:`no`}function VZ(e){if(e!==void 0)return e===`live`?`Live — into the turn that was already running`:e===`next`?`Deferred — onto the node's next dispatch`:e}function HZ(e){return[e.identity,e.target].filter(Boolean).join(` · `)||e.dep}function UZ({release:e}){let t=[[`Dependency`,e.dep],[`Identity`,e.identity],[`Release target`,e.target],[`Style`,e.style===void 0?void 0:LZ(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`,BZ(e.superseded)],[`Landed as`,e.landing_commit],[`Adopted`,VZ(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:[RZ(e)?(0,G.jsxs)(ua,{children:[(0,G.jsx)(un,{}),(0,G.jsxs)(da,{children:[`Waiting on a person · `,HZ(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 · `,HZ(e)]}),(0,G.jsx)(`p`,{className:`detail-note`,children:[e.last_answer===void 0?void 0:zZ(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 WZ({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:LZ(t.style),t.version,n?t.identity:void 0].filter(e=>e!==void 0).join(` · `)})}function GZ(e){return{kind:e.displayKind,label:e.displayLabel,startedAt:e.startedAt,...e.durationMs===null?{}:{duration:QP(e.durationMs)},running:e.endedAt===null&&e.rowKind===`span`,...e.status?{status:e.status}:{}}}function KZ({row:e}){let t=GZ(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)(aF,{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 qZ(e){let t=GZ(e);return[t.kind,t.label,tF(t.startedAt),AZ(e.category),t.status].filter(e=>e!==void 0&&e.length>0).join(` · `)}function JZ({row:e}){return(0,G.jsx)(`span`,{className:`timeline-marker-reading`,"data-timeline-reading":qZ(e),children:(0,G.jsx)(IZ,{category:e.category})})}var YZ=`data-timeline-reading`;function XZ(e){let t=e.closest(`[${YZ}]`)??e.closest(`button`)?.querySelector(`[${YZ}]`);if(!(t instanceof HTMLElement))return;let n=t.getAttribute(YZ)?.trim();return n===void 0||n.length===0?void 0:{element:t,detail:n}}var ZZ={rows:[],total:0},QZ={queued:`Queued`,dispatch:`Dispatch`,verification:`Verification`,publication:`Publication`,"lock-waits":`Lock waits`,"human-wait":`Human wait`},$Z=`idle`,eQ=new Set([...Object.keys(QZ),$Z]),tQ=`member:`;function nQ(e){return eQ.has(e)?`${tQ}${e}`:e}var rQ=Object.entries(QZ).map(([e,t])=>({id:e,label:t}));function iQ(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=>DQ(e)===`dispatch`),[i,...a]=rQ;return[...i===void 0?[]:[i],...n.map(e=>({id:nQ(e),label:e})),...a.filter(({id:e})=>r||e!==`dispatch`)]}var aQ={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 oQ(e){return e===`agent`}function sQ(e,t){return e===void 0?t===void 0?QZ.dispatch:cQ(t):WQ(t)&&t!==e?`${e} · ${t}`:e}function cQ(e){return e===`llmlint`?`Lint`:`${e[0]?.toUpperCase()??``}${e.slice(1)}`}var lQ={"lock-wait":`Lock waits`};function uQ(e,t=rQ){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):fQ(e,t)<fQ(r,t)?a.has(r.id)?s.push(e):s[s.indexOf(r)]=e:dQ(e,r,o)||s.push(e)}return s}function dQ(e,t,n){return Math.abs(e.start-t.start)<=n&&Math.abs((e.end??e.start)-(t.end??t.start))<=n}function fQ(e,t){let n=e.laneId??``,r=t.findIndex(({id:e})=>e===n);return r<0?t.length:r}function pQ(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 mQ(e,t){let n=yQ(e,t).rows,r=_Q(n),i=_Q(n,!1).flatMap(e=>{let t=vQ(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)(JZ,{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:iQ(e),rows:r,tree:n}}function hQ(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 gQ(e,t){return`${e} more ${t} events`}function _Q(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 vQ(e){return e.rowKind===`event`?null:e.role===void 0?aQ[e.rowKind===`span`?e.span.kind:e.kind]??null:nQ(e.role)}function yQ(e,t){if(e===void 0)return ZZ;let n=e.spans.filter(e=>e.node_id===t);if(n.length===0){let n=KQ(e.spans,new Set,t);return n.length===0?ZZ:{rows:LQ(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=LQ(UQ(HQ([...o===void 0?[]:wQ(o,i),...a.filter(e=>e!==o).map(e=>TQ(e,i)),...KQ(e.spans,r,t)].sort(JQ))));return{span:o,rows:s,total:qQ(s)}}function bQ(e){return TQ(e,new Map)}function xQ(e){return IQ(e)}function SQ(e,t){return CQ(e,t).at(-1)}function CQ(e,t){for(let n of e){if(n.id===t)return[n];let e=CQ(n.children,t);if(e.length>0)return[n,...e]}return[]}function wQ(e,t){return[...(t.get(e.id)??[]).map(e=>TQ(e,t)),...e.events.map(IQ)].sort(JQ)}function TQ(e,t){let n=EQ(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??YQ(e.started_at,e.ended_at),children:LQ(wQ(e,t)),displayLabel:VQ(e,n,r),displayKind:RQ(e,n,r),...e.kind===`dispatch`&&e.label?{sessionName:e.label}:{}}}function EQ(e){return e.kind===`dispatch`?e.agent_role:void 0}function DQ(e){return e.agent_role===void 0?aQ[e.kind===`rollup`?e.label:e.kind]??null:nQ(e.agent_role)}function OQ(e,t=[]){let n=t.find(({id:t})=>t===e);return n===void 0?QZ[e]??(e.startsWith(tQ)?e.slice(7):e):n.label}function kQ(e){if(e.redirection!==void 0)return e.redirection.delivered?`Redirected into the running turn`:`Redirection deferred to the next dispatch`}var AQ=`Redirection`;function jQ(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 MQ=`Surface`,NQ=`Blocking surface`;function PQ(e){return e.kind.startsWith(`edit-`)?e.author:void 0}function FQ(e,t){let n=PQ(t);return n===void 0?e:`${e} · by ${n}`}function IQ(e){let t=kQ(e),n=jQ(e),r=t===void 0?e.surface===void 0?`Event`:e.surface.blocking===!0?NQ:MQ:AQ;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:FQ(t??n??(e.kind===`retry-requested`?`Retry requested`:e.step_id??e.kind),e),displayKind:r,category:PZ(e.kind)}}function LQ(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&&GQ(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:YQ(r.startedAt,o.endedAt),children:a,displayLabel:`${a.length} grouped ${r.displayKind.toLowerCase()} activities`,displayKind:r.displayKind}),n=i}return t}function RQ(e,t,n){if(e.kind===`step`)return`Lifecycle`;if(e.kind===`rollup`)return lQ[e.label]??e.label;if(e.kind===`dispatch`)return sQ(t,n);let r=aQ[e.kind];return r===null?e.kind:OQ(r)}function zQ(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 BQ(e){return e.map(zQ).join(` and `)}function VQ(e,t,n){if(e.kind===`step`)return e.label?`Lifecycle: ${e.label}`:`Lifecycle step`;if(e.kind===`queued`)return`Queued ${BQ(e.reasons??[])}`.trim();let r=RQ(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 HQ(e){let t=0;return e.map(e=>{e.rowKind===`event`&&e.event.kind===`retry-requested`&&(t+=1);let n=HQ(e.children);return!oQ(e.transport)||t===0?{...e,children:n}:{...e,children:n,displayLabel:`${e.displayLabel} · retry ${t}`}})}function UQ(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(oQ(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(WQ(a.transport)&&e?.dispatch!==void 0){t[n]={...e,children:[...e.children,i(a,e.dispatch)]};continue}t.push(a)}return t}function WQ(e){return e===`judge`||e===`llmlint`}function GQ(e,t){return t!==void 0&&e.rowKind!==`group`&&t.rowKind===e.rowKind&&e.kind===t.kind}function KQ(e,t,n){return e.filter(({id:e})=>!t.has(e)).flatMap(({events:e})=>e.filter(e=>e.node_id===n)).map(IQ)}function qQ(e){return e.reduce((e,t)=>e+(t.rowKind===`group`?0:1)+qQ(t.children),0)}function JQ(e,t){return e.startedAt.localeCompare(t.startedAt)}function YQ(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 XQ(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 ZQ=32;function QQ(e){return e===null?null:e.closest(`[data-slot="scroll-area-viewport"]`)??e.parentElement}function $Q(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<=ZQ)},[]),o=(0,U.useCallback)(e=>{n.current?.removeEventListener(`scroll`,a),n.current=QQ(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 e$=25;function t$({client:e,runId:t,node:n,row:r}){let i=r===void 0?void 0:y$(r),a=i?.kind===`conversation`?i.value:void 0,o=XQ(e,t,a,r===void 0?void 0:m$(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:$Q(a,h$(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)(KZ,{row:r}),(0,G.jsx)(Cf,{className:`my-4`}),(0,G.jsx)(n$,{client:e,runId:t,node:n,reference:i,row:r,transcript:o})]})})})})}function n$({client:e,runId:t,row:n,node:r,reference:i,transcript:a}){let o=g$(n);if(o!==void 0)return(0,G.jsx)(l$,{redirection:o,row:n});let s=_$(n);if(s!==void 0)return(0,G.jsx)(UZ,{release:s});let c=v$(n);return c===void 0?i?.kind===`conversation`?(0,G.jsx)(i$,{row:n,transcript:a}):x$(n)?(0,G.jsx)(a$,{client:e,runId:t,reference:i,row:n}):i?.kind===`worker_report`&&nN(i.value)!==void 0?(0,G.jsx)(o$,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):i?.kind===`oneharness_session`&&nN(i.value)!==void 0?(0,G.jsx)(s$,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):S$(n,i)&&r!==void 0?(0,G.jsx)(c$,{node:r,reference:i}):(0,G.jsx)(f$,{reference:i,row:n}):(0,G.jsx)(d$,{row:n,surface:c})}function r$({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 i$({row:e,transcript:t}){let[n,r]=(0,U.useState)(e$),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=C$(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)(r$,{turn:e})]},e.id))}),a.length>n&&(0,G.jsxs)(La,{onClick:()=>r(n+e$),size:`sm`,type:`button`,variant:`outline`,children:[`Show more of `,a.length,` turns`]})]})]})})}function a$({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)(tN,{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 o$({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(tN,{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)(f$,{reference:n,row:r})]})}function s$({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(tN,{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)(f$,{reference:n,row:r})]})}function c$({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)(p$,{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)(p$,{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 l$({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)(aF,{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)(u$,{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 u$({row:e}){let t=e.rowKind===`event`?PQ(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 d$({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)(aF,{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 f$({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)(aF,{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)(aF,{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`:QP(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(zQ).join(` and `)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Step`}),(0,G.jsx)(`dd`,{children:b$(n)??`None`})]}),(0,G.jsx)(u$,{row:e})]}),(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Reference`}),(0,G.jsx)(p$,{fallback:`This item points at no recorded artifact.`,reference:t})]})}function p$({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 m$(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 h$(e,t){return t.conversation===void 0?0:e?.rowKind===`event`?1:t.conversation.conversation.turns.length}function g$(e){return e.rowKind===`event`?e.event.redirection:void 0}function _$(e){return e.rowKind===`event`?e.event.release:void 0}function v$(e){return e.rowKind===`event`?e.event.surface:void 0}function y$(e){if(e.rowKind===`span`)return e.span.reference;if(e.rowKind===`event`)return e.event.reference}function b$(e){if(e?.rowKind===`span`)return e.span.step_id;if(e?.rowKind===`event`)return e.event.step_id}function x$(e){return e.kind===`verification`||e.kind.startsWith(`verification-`)}function S$(e,t){return t?.kind===`pr`||e.kind===`publication`||e.kind.startsWith(`pr-`)||e.kind.startsWith(`publication-`)}function C$(e,t){return sQ(e,t)}function w$({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)(()=>yQ(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)(rX,{className:`node-view-state`,state:n.status}),(0,G.jsx)(kZ,{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)(N$,{node:n}),(0,G.jsxs)(Cp,{className:`node-tabs`,onValueChange:e=>{xX(e)&&l(e)},value:c,children:[(0,G.jsx)(Tp,{"aria-label":`Node details`,variant:`line`,children:Object.entries(bX).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:A$(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:P$(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:j$(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)(M$,{node:n})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Release`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(WZ,{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)(T$,{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 T$({client:e,node:t,onSelectItem:n,runId:r,selectedItemId:i,timeline:a}){let o=(0,U.useMemo)(()=>mQ(a,t.id),[a,t.id]),[s,c]=(0,U.useState)(()=>new Set),l=(0,U.useMemo)(()=>{if(i!==void 0)return CQ(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)(()=>hQ(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)(()=>uQ(o.items,o.lanes),[o.items,o.lanes]),g=(0,U.useMemo)(()=>pQ(o.markers,o.items,i),[o.items,o.markers,i]),_=(0,U.useMemo)(()=>E$(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:SQ(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:D$(d).map(e=>{let t=e.entries.map(e=>e.entryKind===`row`?(0,G.jsx)(k$,{onOpen:b,register:f.register,row:e.row,selected:e.row.id===i},e.row.id):(0,G.jsx)(O$,{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)(t$,{client:e,node:t,row:y,runId:r})]})]})}function E$(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 D$(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 O$({entry:e,onToggle:t}){let n=gQ(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 k$({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)(IZ,{category:e.category}),e.displayKind]}),(0,G.jsx)(`strong`,{children:e.displayLabel}),(0,G.jsxs)(`span`,{className:`transcript-facts`,children:[(0,G.jsx)(aF,{at:e.startedAt}),e.durationMs!==null&&` · ${QP(e.durationMs)}`,` · ${e.status??`recorded`}`,e.sessionName!==void 0&&` · ${e.sessionName}`]})]})})}function A$(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`})]})})}NY.displayName=`MiniMap`,(0,U.memo)(NY);var PY=e=>t=>e?`${Math.max(1/t.transform[2],1)}`:void 0,FY={[SG.Line]:`right`,[SG.Handle]:`bottom-right`};function IY({nodeId:e,position:t,variant:n=SG.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=mq(),y=typeof e==`string`?e:v,b=ZG(),x=(0,U.useRef)(null),S=n===SG.Handle,C=XG((0,U.useCallback)(PY(S&&p),[S,p]),KG),w=(0,U.useRef)(null),T=t??FY[n];return(0,U.useEffect)(()=>{if(!(!x.current||!y))return w.current||=NG({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=BW([{id:c.id,parentId:c.parentId,rect:{width:n,height:l,...GU({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:uL([`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)(IY);function LY(e){return e.graph??void 0}function RY(e){return{run:e.run_node_sets??[],nodes:new Map(e.plan.tasks.map(e=>[e.id,e.sets??[]]))}}function zY(e){let t=LY(e);if(!t)return[];let n=new Map(e.run.nodes.map(e=>[e.node,e]));return t.plan.tasks.flatMap(r=>{let i=JY(r,`kind`)===`human`?`human`:YY(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:JY(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 BY(e){switch(e?.launcher){case`claude-code`:return`Claude`;case`codex`:return`Codex`;default:return`Unattributed`}}function VY(e){let t=BY(e);return e?.session_key===void 0?e===void 0?`Unattributed`:`${t} launch · ${XY(e.launch_id)}`:`${t} session · ${XY(e.session_key)}`}function HY(e){if(e.blockers.length>0&&WY.has(e.status))return`blocked by ${e.blockers.join(`, `)}`;if(GY.has(e.status))return UY(e)??`${e.status}, with no reason recorded`}function UY(e){return(e.failure?.detail||e.result?.detail||e.result?.error||e.telemetry?.outcome||e.result?.outcome)?.trim()||void 0}var WY=new Set([`blocked`,`skipped`,`waiting`]),GY=new Set([`failed`,`not-completed`,`cancelled`]);function KY(e){let t=tL,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 qY(e){return GY.has(e)||e===`blocked`||e===`skipped`}function JY(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:void 0}function YY(e){return`repo`in e||`steps`in e}function XY(e){return e.length>12?`${e.slice(0,8)}…`:e}function ZY({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)(Sq,{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)(Sq,{type:`source`,position:$.Right})]})}function QY({data:e,id:t,markerEnd:n,style:r}){return(0,G.jsx)(nJ,{id:t,path:$Y(e?.points??[]),markerEnd:n,style:r})}function $Y(e){let[t,...n]=e;return t?`M ${t.x} ${t.y} ${n.map(e=>`L ${e.x} ${e.y}`).join(` `)}`:``}var eX={dagNode:ZY},tX={routed:QY};function nX({nodes:e,selectedNodeId:t,onSelectNode:n}){let r=(0,U.useMemo)(()=>{let t=new Map;for(let n of e)qY(n.status)&&t.set(n.id,HY(n));return t},[e]),{nodes:i,edges:a}=(0,U.useMemo)(()=>{let n=new Set(e.map(e=>e.id)),i=lL({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)}},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)(tY,{nodes:i,edges:a,colorMode:`dark`,nodeTypes:eX,edgeTypes:tX,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)(cY,{color:`var(--border)`,gap:22}),(0,G.jsx)(_Y,{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 rX({className:e,state:t}){let n=iX(t);return(0,G.jsxs)(Fa,{className:H(`gap-1.5 tracking-[.03em] uppercase`,n&&oX[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 iX(e){return fX[e]}var aX=e=>{let t=iX(e);return H(`size-2 shrink-0 rounded-full bg-current`,t===void 0?`text-muted-foreground`:sX[t])},oX={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`},sX={success:`text-success`,destructive:`text-destructive`,warning:`text-warning`,info:`text-info`},cX=`success`,lX=`destructive`,uX=`warning`,dX={blocked:uX,cancelled:lX,done:cX,failed:lX,"not-completed":lX,parked:void 0,pending:void 0,running:`info`,skipped:uX,unknown:void 0,waiting:void 0},fX={...dX,complete:dX.done,settled:dX.done,active:dX.running},pX={graph:`graph`,overall:`overall`,channel:`channel`,watch:`watch`,reads:`reads`,agents:`agents`};function mX(e){return e!==null&&Object.hasOwn(pX,e)}var hX={projects:`projects`,runs:`runs`};function gX(e){return e!==null&&Object.hasOwn(hX,e)}var _X=`none`,vX={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 yX(e){return e!==null&&Object.hasOwn(vX,e)}var bX={timeline:`Timeline`,task:`Task`,criteria:`Acceptance criteria`,dependencies:`Dependencies`,pr:`PR`,checks:`Checks`,agents:`Agents`};function xX(e){return e!==null&&Object.hasOwn(bX,e)}function SX(e){let t=[...e].some(e=>e.charCodeAt(0)<32);return e.length>0&&e.length<=512&&!t&&!/[/?#]/u.test(e)}function CX(e,t){let n=e.get(t);return n!==null&&SX(n)?n:void 0}function wX(){let e=(0,U.useSyncExternalStore)(TX,EX,EX),t=new URLSearchParams(e),n=t.get(`list`),r=gX(n)?n:`projects`,i=t.get(`project`),a=i!==null&&(i===`none`||Zj(i))?i:void 0,o=CX(t,`run`),s=CX(t,`node`),c=CX(t,`event`),l=t.get(`view`),u=t.get(`tab`),d=t.get(`detail`),f=yX(d)?d:`activity`,p=xX(u)?u:`timeline`,m=mX(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 TX(e){return window.addEventListener(`popstate`,e),()=>window.removeEventListener(`popstate`,e)}function EX(){return window.location.search}var DX=`(no project)`;function OX(e){return e.project===null?DX:e.name??e.project}function kX(e){return e.project===null?e.name??void 0:e.name===null?void 0:e.project}function AX(e){return e.project??`none`}function jX(e,t){return e.find(e=>AX(e)===t)}function MX(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 NX(e){return`${e.length} ${e.length===1?`run`:`runs`}`}function PX(e){if(e.agent_count!==void 0)return`${e.agent_count} ${e.agent_count===1?`agent`:`agents`}`}function FX({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=AX(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:OX(e)})]}),(0,G.jsx)(wt,{"aria-hidden":`true`,size:14}),kX(e)!==void 0&&(0,G.jsx)(`span`,{className:`run-link-counts`,title:kX(e),children:kX(e)}),(0,G.jsx)(`span`,{className:`run-link-counts`,children:[NX(e.runs),MX(e.runs),PX(e)].filter(Boolean).join(` · `)}),(0,G.jsx)(`span`,{className:`run-link-tag`,children:e.last_write_at===null?`never written`:(0,G.jsx)(aF,{at:rF(e.last_write_at),relative:!0})})]})},r)})})}var IX={projects:`Projects`,runs:`Runs`};function LX({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(hX).map(n=>(0,G.jsx)(La,{"aria-pressed":e===n,onClick:()=>t(n),size:`sm`,type:`button`,variant:e===n?`default`:`outline`,children:IX[n]},n))]}),e===`projects`?n===void 0?(0,G.jsx)(`p`,{"aria-live":`polite`,className:`run-list-status`,children:`Loading projects…`}):(0,G.jsx)(FX,{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=KY(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`,aX(e.state)),"data-live":`true`,role:`img`})}),(0,G.jsx)(_m,{children:`Live`})]}):(0,G.jsx)(`span`,{"aria-label":`Historical`,className:H(`run-dot`,aX(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}),VY(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 RX({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)(VX,{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(AX(e)),type:`button`,children:[(0,G.jsx)(`span`,{className:`project-card-name`,children:OX(e)}),(0,G.jsx)(wt,{"aria-hidden":`true`,size:14})]}),kX(e)!==void 0&&(0,G.jsx)(`p`,{className:`project-card-id`,children:kX(e)}),(0,G.jsxs)(`p`,{className:`project-card-facts`,children:[NX(e.runs),e.runs.length>0&&` · ${MX(e.runs)}`,PX(e)!==void 0&&` · ${PX(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)(aF,{at:rF(e.last_write_at),relative:!0})]})})]})})},AX(e)))})]})})}function zX({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:OX(t)}),t!==void 0&&kX(t)!==void 0&&(0,G.jsx)(`p`,{className:`project-card-id`,children:kX(t)}),t&&(0,G.jsxs)(`p`,{className:`projects-lede`,children:[NX(t.runs),t.runs.length>0&&` · ${MX(t.runs)}`,PX(t)!==void 0&&` · ${PX(t)}`,t.last_write_at!==null&&(0,G.jsxs)(G.Fragment,{children:[` · last activity `,(0,G.jsx)(aF,{at:rF(t.last_write_at),relative:!0})]})]}),n&&(0,G.jsx)(VX,{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 ${OX(t)}`,className:`project-runs`,children:t.runs.map(e=>(0,G.jsx)(`li`,{children:(0,G.jsx)(BX,{onSelect:a,run:e})},e.run_id))}),i]}):null]})})}function BX({run:e,onSelect:t}){let n=KY(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)(rX,{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)(aF,{at:rF(e.last_progress_at*1e3),relative:!0})]})})]})]})}function VX({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 HX(e,t,n){let{value:r,error:i}=QM(n?`projects`:void 0,()=>e.listProjects(),t);return{list:r,error:i}}function UX(e,t,n){let{value:r,error:i,loading:a}=QM(t,()=>t===`none`?e.listProjects().then(e=>{let t=jX(e.projects,_X);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 WX(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(JX(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(JX(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=KX(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(GX).catch(e=>{o(()=>g(JX(e)))}),c=n===void 0?Promise.resolve():e.getTimeline(C,n.nodeId,r).then(e=>a(t=>({...t,timeline:e,timelineError:void 0}))).catch(GX).catch(e=>a(t=>({...t,timelineError:JX(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(UM(e.data)),A.current&&(b(e=>e+1),T(e=>e+1)),A.current=!0;return}let t=qX(e);t!==void 0&&(T(e=>e+1),ee(t).catch(e=>g(JX(e))),t===D.current&&b(e=>e+1))},onError:e=>{v(JX(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(Xj.parse(t))}(e.event===`conversation.changed`||e.event===`activity.changed`||e.event===`run.changed`)&&b(e=>e+1)}},onError:e=>v(JX(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 GX(e){if(!(e instanceof WM&&e.code===`run_not_found`))throw e}function KX(e,t,n){return[e,t??``,n??``].join(`\0`)}function qX(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 JX(e){return e instanceof Error?e:typeof Event<`u`&&e instanceof Event?Error(`Live telemetry stream disconnected`):Error(String(e))}var YX={minutes:60,seconds:1},XX=e=>Object.hasOwn(YX,e),ZX=600%YX.minutes==0?{amount:String(600/YX.minutes),unit:`minutes`}:{amount:`600`,unit:`seconds`};function QX(e){let t=e.amount.trim();if(!/^\d+$/u.test(t))return;let n=Number(t)*YX[e.unit];return Number.isSafeInteger(n)?n:void 0}function $X(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 eZ(e,t){let n=e?.session_key;return t!==null&&n!==void 0&&n===t}function tZ(e,t,n){let r=eZ(t,n);return{runId:e,owner:r?`this session (${VY(t)})`:VY(t),mine:r,unowned:t?.session_key===void 0}}function nZ(e,t,n){let r=t.map(e=>tZ(e.run_id,e.launch,n));return e===`mine`?r.filter(e=>e.mine):r}function rZ(e,t){return t instanceof WM&&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 iZ={dispatchStopped:`dispatch-stopped`,hostShutdown:`host-shutdown`};function aZ(e,t,n){let r=new Set(e.runs.map(({runId:e})=>e)),i=Object.values(iZ);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===iZ.hostShutdown?iZ.hostShutdown:iZ.dispatchStopped}]})}function oZ(e){return new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hourCycle:`h23`}).format(e)}var sZ={run:`Shut down this run?`,mine:`Shut down all my runs?`,host:`Shut down the entire host?`},cZ=`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 lZ({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)(ZX),[d,f]=(0,U.useState)(!1),p=QX(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(ZX),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}?`:sZ[e]}),(0,G.jsx)(Dc,{children:cZ})]}),(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)(dZ,{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)(fZ,{caption:`It acts on the ${uZ(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)(fZ,{caption:`It acts on ${uZ(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)(fZ,{caption:`And on the ${uZ(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;XX(t)&&u({...l,unit:t})},value:l.unit,children:Object.keys(YX).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: ${$X(p)}. The engine's default is ${$X(QX(ZX)??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 uZ=e=>e===1?`1 run`:`${e} runs`;function dZ({run:e}){return e===void 0?null:(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(fZ,{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 fZ({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 pZ(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 mZ(e,t,n,r){let[i,a]=(0,U.useState)(),[o,s]=(0,U.useState)(0),c=QM(i===void 0?void 0:`acting-${o}`,()=>e.unwatched(),0),l=hZ(i!==void 0,t,n,r),{acting:u,blocked:d}=pZ(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:nZ(i,l.rows,u),blocked:d??l.blocked,unreadable:t?.unreadable?.length??0}}function hZ(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 gZ(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(rZ(s,e))).finally(()=>{i.current=!1})},[e,t]),dismiss:(0,U.useCallback)(()=>{i.current||r({phase:`idle`})},[])}}var _Z=[`mine`,`host`];function vZ({runId:e,launched:t,unwatched:n,shutdown:r}){let[i,a]=(0,U.useState)(!1),{acting:o,blocked:s}=pZ(n),c=o===void 0||t===void 0?void 0:[tZ(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)(lZ,{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 yZ(e,t){return gZ(`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 bZ(e){return{mine:gZ(`mine`,(0,U.useCallback)(t=>e.shutdown(`mine`,t),[e])),host:gZ(`host`,(0,U.useCallback)(t=>e.shutdown(`host`,t),[e]))}}function xZ({client:e,list:t,loadMore:n,loadingMore:r,shutdowns:i}){let{open:a,setOpen:o,opener:s,runs:c,blocked:l,unreadable:u}=mZ(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`]})]}),_Z.map(e=>(0,G.jsx)(lZ,{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 SZ=1e3;function CZ(e,t){let[n,r]=(0,U.useState)(()=>Date.now());(0,U.useEffect)(()=>{let e=setInterval(()=>r(Date.now()),SZ);return()=>clearInterval(e)},[]);let i=aZ(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===iZ.hostShutdown).length,deadline:e.sentAt+e.grace*1e3,asks:!e.force&&e.grace>0}}function wZ({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)(EZ,{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 `,oZ(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)(TZ,{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)(OZ,{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 TZ({sent:e}){return(0,G.jsxs)(`p`,{className:`channel-age`,children:[`Sent `,oZ(e.sentAt),` · scope `,e.scope,` · grace`,` `,$X(e.grace),e.force?` · forced`:``,` · `,e.runs.length,` `,e.runs.length===1?`run`:`runs`,` in scope`]})}function EZ({sent:e,rows:t}){let{now:n,progress:r,done:i,deadline:a,asks:o}=CZ(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, `,QP(Math.max(0,n-e.sentAt)),` after it was sent.`]}),(0,G.jsx)(TZ,{sent:e}),(0,G.jsx)(`p`,{children:o?n<a?`Waiting out the ${$X(e.grace)} grace until ${oZ(a)} (${QP(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 ${oZ(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===iZ.hostShutdown?`put down — host-shutdown recorded after its teardown and pushes`:`its dispatches are stopping — dispatch-stopped recorded`]},e))})]})}function DZ(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 OZ({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 `,$X(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`,` `,QP(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,`: `,DZ(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 kZ({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 AZ(e){return e.charAt(0).toUpperCase()+e.slice(1)}var jZ=[[`recovery`,[`retry`,`retried`,`requeued`,`fallback`,`resolution`,`interrupted`,`cron`]],[`failure`,[`failed`,`died`,`rejected`,`refused`,`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`,`landing`,`landed`]],[`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`]]],MZ={"change-retitled":`publication`,"title-unverified":`verification`,"node-restack-started":`repository`,"node-restacked":`repository`,"review-comments-read":`publication`,"node-absorbed":`publication`,"node-readjusted":`repository`,"completion-requested":`lifecycle`,"command-accepted":`planning`,"body-not-drafted":`publication`,"criterion-checked":`verification`,"pool-maintenance":`lifecycle`,"dispatch-stopped":`lifecycle`,"host-shutdown":`lifecycle`,"scratch-removed":`lifecycle`,"scratch-retained":`lifecycle`};function NZ(e){return e.toLowerCase().split(`-`).filter(e=>e.length>0)}function PZ(e){let t=MZ[e];if(t!==void 0)return t;let n=NZ(e);return jZ.find(([,e])=>e.some(e=>n.includes(e)))?.[0]??`activity`}var FZ={recovery:tn,failure:cn,human:un,planning:kt,contention:Rt,verification:on,publication:Lt,repository:It,session:Jt,lifecycle:Yt,activity:Ot};function IZ({category:e,className:t=`size-3`}){let n=FZ[e];return(0,G.jsx)(n,{"aria-hidden":`true`,className:t})}function LZ(e){return e===`human-step`?`human step`:e}function RZ(e){return e.style===`human-step`}function zZ(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 BZ(e){if(e!==void 0)return e?`yes — a later acknowledgement replaced this one`:`no`}function VZ(e){if(e!==void 0)return e===`live`?`Live — into the turn that was already running`:e===`next`?`Deferred — onto the node's next dispatch`:e}function HZ(e){return[e.identity,e.target].filter(Boolean).join(` · `)||e.dep}function UZ({release:e}){let t=[[`Dependency`,e.dep],[`Identity`,e.identity],[`Release target`,e.target],[`Style`,e.style===void 0?void 0:LZ(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`,BZ(e.superseded)],[`Landed as`,e.landing_commit],[`Adopted`,VZ(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:[RZ(e)?(0,G.jsxs)(ua,{children:[(0,G.jsx)(un,{}),(0,G.jsxs)(da,{children:[`Waiting on a person · `,HZ(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 · `,HZ(e)]}),(0,G.jsx)(`p`,{className:`detail-note`,children:[e.last_answer===void 0?void 0:zZ(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 WZ({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:LZ(t.style),t.version,n?t.identity:void 0].filter(e=>e!==void 0).join(` · `)})}function GZ(e){return{kind:e.displayKind,label:e.displayLabel,startedAt:e.startedAt,...e.durationMs===null?{}:{duration:QP(e.durationMs)},running:e.endedAt===null&&e.rowKind===`span`,...e.status?{status:e.status}:{}}}function KZ({row:e}){let t=GZ(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)(aF,{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 qZ(e){let t=GZ(e);return[t.kind,t.label,tF(t.startedAt),AZ(e.category),t.status].filter(e=>e!==void 0&&e.length>0).join(` · `)}function JZ({row:e}){return(0,G.jsx)(`span`,{className:`timeline-marker-reading`,"data-timeline-reading":qZ(e),children:(0,G.jsx)(IZ,{category:e.category})})}var YZ=`data-timeline-reading`;function XZ(e){let t=e.closest(`[${YZ}]`)??e.closest(`button`)?.querySelector(`[${YZ}]`);if(!(t instanceof HTMLElement))return;let n=t.getAttribute(YZ)?.trim();return n===void 0||n.length===0?void 0:{element:t,detail:n}}var ZZ={rows:[],total:0},QZ={queued:`Queued`,dispatch:`Dispatch`,verification:`Verification`,publication:`Publication`,"lock-waits":`Lock waits`,"human-wait":`Human wait`},$Z=`idle`,eQ=new Set([...Object.keys(QZ),$Z]),tQ=`member:`;function nQ(e){return eQ.has(e)?`${tQ}${e}`:e}var rQ=Object.entries(QZ).map(([e,t])=>({id:e,label:t}));function iQ(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=>DQ(e)===`dispatch`),[i,...a]=rQ;return[...i===void 0?[]:[i],...n.map(e=>({id:nQ(e),label:e})),...a.filter(({id:e})=>r||e!==`dispatch`)]}var aQ={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 oQ(e){return e===`agent`}function sQ(e,t){return e===void 0?t===void 0?QZ.dispatch:cQ(t):WQ(t)&&t!==e?`${e} · ${t}`:e}function cQ(e){return e===`llmlint`?`Lint`:`${e[0]?.toUpperCase()??``}${e.slice(1)}`}var lQ={"lock-wait":`Lock waits`};function uQ(e,t=rQ){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):fQ(e,t)<fQ(r,t)?a.has(r.id)?s.push(e):s[s.indexOf(r)]=e:dQ(e,r,o)||s.push(e)}return s}function dQ(e,t,n){return Math.abs(e.start-t.start)<=n&&Math.abs((e.end??e.start)-(t.end??t.start))<=n}function fQ(e,t){let n=e.laneId??``,r=t.findIndex(({id:e})=>e===n);return r<0?t.length:r}function pQ(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 mQ(e,t){let n=yQ(e,t).rows,r=_Q(n),i=_Q(n,!1).flatMap(e=>{let t=vQ(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)(JZ,{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:iQ(e),rows:r,tree:n}}function hQ(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 gQ(e,t){return`${e} more ${t} events`}function _Q(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 vQ(e){return e.rowKind===`event`?null:e.role===void 0?aQ[e.rowKind===`span`?e.span.kind:e.kind]??null:nQ(e.role)}function yQ(e,t){if(e===void 0)return ZZ;let n=e.spans.filter(e=>e.node_id===t);if(n.length===0){let n=KQ(e.spans,new Set,t);return n.length===0?ZZ:{rows:LQ(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=LQ(UQ(HQ([...o===void 0?[]:wQ(o,i),...a.filter(e=>e!==o).map(e=>TQ(e,i)),...KQ(e.spans,r,t)].sort(JQ))));return{span:o,rows:s,total:qQ(s)}}function bQ(e){return TQ(e,new Map)}function xQ(e){return IQ(e)}function SQ(e,t){return CQ(e,t).at(-1)}function CQ(e,t){for(let n of e){if(n.id===t)return[n];let e=CQ(n.children,t);if(e.length>0)return[n,...e]}return[]}function wQ(e,t){return[...(t.get(e.id)??[]).map(e=>TQ(e,t)),...e.events.map(IQ)].sort(JQ)}function TQ(e,t){let n=EQ(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??YQ(e.started_at,e.ended_at),children:LQ(wQ(e,t)),displayLabel:VQ(e,n,r),displayKind:RQ(e,n,r),...e.kind===`dispatch`&&e.label?{sessionName:e.label}:{}}}function EQ(e){return e.kind===`dispatch`?e.agent_role:void 0}function DQ(e){return e.agent_role===void 0?aQ[e.kind===`rollup`?e.label:e.kind]??null:nQ(e.agent_role)}function OQ(e,t=[]){let n=t.find(({id:t})=>t===e);return n===void 0?QZ[e]??(e.startsWith(tQ)?e.slice(7):e):n.label}function kQ(e){if(e.redirection!==void 0)return e.redirection.delivered?`Redirected into the running turn`:`Redirection deferred to the next dispatch`}var AQ=`Redirection`;function jQ(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 MQ=`Surface`,NQ=`Blocking surface`;function PQ(e){return e.kind.startsWith(`edit-`)?e.author:void 0}function FQ(e,t){let n=PQ(t);return n===void 0?e:`${e} · by ${n}`}function IQ(e){let t=kQ(e),n=jQ(e),r=t===void 0?e.surface===void 0?`Event`:e.surface.blocking===!0?NQ:MQ:AQ;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:FQ(t??n??(e.kind===`retry-requested`?`Retry requested`:e.step_id??e.kind),e),displayKind:r,category:PZ(e.kind)}}function LQ(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&&GQ(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:YQ(r.startedAt,o.endedAt),children:a,displayLabel:`${a.length} grouped ${r.displayKind.toLowerCase()} activities`,displayKind:r.displayKind}),n=i}return t}function RQ(e,t,n){if(e.kind===`step`)return`Lifecycle`;if(e.kind===`rollup`)return lQ[e.label]??e.label;if(e.kind===`dispatch`)return sQ(t,n);let r=aQ[e.kind];return r===null?e.kind:OQ(r)}function zQ(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 BQ(e){return e.map(zQ).join(` and `)}function VQ(e,t,n){if(e.kind===`step`)return e.label?`Lifecycle: ${e.label}`:`Lifecycle step`;if(e.kind===`queued`)return`Queued ${BQ(e.reasons??[])}`.trim();let r=RQ(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 HQ(e){let t=0;return e.map(e=>{e.rowKind===`event`&&e.event.kind===`retry-requested`&&(t+=1);let n=HQ(e.children);return!oQ(e.transport)||t===0?{...e,children:n}:{...e,children:n,displayLabel:`${e.displayLabel} · retry ${t}`}})}function UQ(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(oQ(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(WQ(a.transport)&&e?.dispatch!==void 0){t[n]={...e,children:[...e.children,i(a,e.dispatch)]};continue}t.push(a)}return t}function WQ(e){return e===`judge`||e===`llmlint`}function GQ(e,t){return t!==void 0&&e.rowKind!==`group`&&t.rowKind===e.rowKind&&e.kind===t.kind}function KQ(e,t,n){return e.filter(({id:e})=>!t.has(e)).flatMap(({events:e})=>e.filter(e=>e.node_id===n)).map(IQ)}function qQ(e){return e.reduce((e,t)=>e+(t.rowKind===`group`?0:1)+qQ(t.children),0)}function JQ(e,t){return e.startedAt.localeCompare(t.startedAt)}function YQ(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 XQ(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 ZQ=32;function QQ(e){return e===null?null:e.closest(`[data-slot="scroll-area-viewport"]`)??e.parentElement}function $Q(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<=ZQ)},[]),o=(0,U.useCallback)(e=>{n.current?.removeEventListener(`scroll`,a),n.current=QQ(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 e$=25;function t$({client:e,runId:t,node:n,row:r}){let i=r===void 0?void 0:y$(r),a=i?.kind===`conversation`?i.value:void 0,o=XQ(e,t,a,r===void 0?void 0:m$(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:$Q(a,h$(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)(KZ,{row:r}),(0,G.jsx)(Cf,{className:`my-4`}),(0,G.jsx)(n$,{client:e,runId:t,node:n,reference:i,row:r,transcript:o})]})})})})}function n$({client:e,runId:t,row:n,node:r,reference:i,transcript:a}){let o=g$(n);if(o!==void 0)return(0,G.jsx)(l$,{redirection:o,row:n});let s=_$(n);if(s!==void 0)return(0,G.jsx)(UZ,{release:s});let c=v$(n);return c===void 0?i?.kind===`conversation`?(0,G.jsx)(i$,{row:n,transcript:a}):x$(n)?(0,G.jsx)(a$,{client:e,runId:t,reference:i,row:n}):i?.kind===`worker_report`&&nN(i.value)!==void 0?(0,G.jsx)(o$,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):i?.kind===`oneharness_session`&&nN(i.value)!==void 0?(0,G.jsx)(s$,{artifactId:i.value,client:e,reference:i,row:n,runId:t}):S$(n,i)&&r!==void 0?(0,G.jsx)(c$,{node:r,reference:i}):(0,G.jsx)(f$,{reference:i,row:n}):(0,G.jsx)(d$,{row:n,surface:c})}function r$({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 i$({row:e,transcript:t}){let[n,r]=(0,U.useState)(e$),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=C$(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)(r$,{turn:e})]},e.id))}),a.length>n&&(0,G.jsxs)(La,{onClick:()=>r(n+e$),size:`sm`,type:`button`,variant:`outline`,children:[`Show more of `,a.length,` turns`]})]})]})})}function a$({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)(tN,{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 o$({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(tN,{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)(f$,{reference:n,row:r})]})}function s$({artifactId:e,client:t,reference:n,row:r,runId:i}){return(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(tN,{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)(f$,{reference:n,row:r})]})}function c$({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)(p$,{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)(p$,{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 l$({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)(aF,{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)(u$,{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 u$({row:e}){let t=e.rowKind===`event`?PQ(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 d$({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)(aF,{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 f$({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)(aF,{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)(aF,{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`:QP(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(zQ).join(` and `)})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Step`}),(0,G.jsx)(`dd`,{children:b$(n)??`None`})]}),(0,G.jsx)(u$,{row:e})]}),(0,G.jsx)(`h3`,{className:`detail-heading`,children:`Reference`}),(0,G.jsx)(p$,{fallback:`This item points at no recorded artifact.`,reference:t})]})}function p$({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 m$(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 h$(e,t){return t.conversation===void 0?0:e?.rowKind===`event`?1:t.conversation.conversation.turns.length}function g$(e){return e.rowKind===`event`?e.event.redirection:void 0}function _$(e){return e.rowKind===`event`?e.event.release:void 0}function v$(e){return e.rowKind===`event`?e.event.surface:void 0}function y$(e){if(e.rowKind===`span`)return e.span.reference;if(e.rowKind===`event`)return e.event.reference}function b$(e){if(e?.rowKind===`span`)return e.span.step_id;if(e?.rowKind===`event`)return e.event.step_id}function x$(e){return e.kind===`verification`||e.kind.startsWith(`verification-`)}function S$(e,t){return t?.kind===`pr`||e.kind===`publication`||e.kind.startsWith(`pr-`)||e.kind.startsWith(`publication-`)}function C$(e,t){return sQ(e,t)}function w$({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)(()=>yQ(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)(rX,{className:`node-view-state`,state:n.status}),(0,G.jsx)(kZ,{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)(N$,{node:n}),(0,G.jsxs)(Cp,{className:`node-tabs`,onValueChange:e=>{xX(e)&&l(e)},value:c,children:[(0,G.jsx)(Tp,{"aria-label":`Node details`,variant:`line`,children:Object.entries(bX).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:A$(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:P$(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:j$(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)(M$,{node:n})})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`dt`,{children:`Release`}),(0,G.jsx)(`dd`,{children:(0,G.jsx)(WZ,{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)(T$,{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 T$({client:e,node:t,onSelectItem:n,runId:r,selectedItemId:i,timeline:a}){let o=(0,U.useMemo)(()=>mQ(a,t.id),[a,t.id]),[s,c]=(0,U.useState)(()=>new Set),l=(0,U.useMemo)(()=>{if(i!==void 0)return CQ(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)(()=>hQ(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)(()=>uQ(o.items,o.lanes),[o.items,o.lanes]),g=(0,U.useMemo)(()=>pQ(o.markers,o.items,i),[o.items,o.markers,i]),_=(0,U.useMemo)(()=>E$(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:SQ(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:D$(d).map(e=>{let t=e.entries.map(e=>e.entryKind===`row`?(0,G.jsx)(k$,{onOpen:b,register:f.register,row:e.row,selected:e.row.id===i},e.row.id):(0,G.jsx)(O$,{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)(t$,{client:e,node:t,row:y,runId:r})]})]})}function E$(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 D$(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 O$({entry:e,onToggle:t}){let n=gQ(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 k$({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)(IZ,{category:e.category}),e.displayKind]}),(0,G.jsx)(`strong`,{children:e.displayLabel}),(0,G.jsxs)(`span`,{className:`transcript-facts`,children:[(0,G.jsx)(aF,{at:e.startedAt}),e.durationMs!==null&&` · ${QP(e.durationMs)}`,` · ${e.status??`recorded`}`,e.sessionName!==void 0&&` · ${e.sessionName}`]})]})})}function A$(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 j$(e){let t=A$(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 M$({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 N$({node:e}){if(!qY(e.status))return null;let t=e.status===`blocked`||e.status===`skipped`,n=UY(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 P$(e){return e==null||e===``?`Not recorded`:typeof e==`string`?e:JSON.stringify(e,null,2)}var F$=`idle-`,I$=`row:run`,L$=e=>`row:node:${e}`,R$={id:$Z,label:`Idle`};function z$(e){return[...iQ(e),R$]}var B$=.005;function V$(e,t){let n=e?.spans??[],r=H$(e),i=z$(e),a=[U$({id:I$,kind:`run`,label:`Run-level`,range:r,spans:n.filter(e=>e.node_id===void 0),lanes:i}),...t.map(e=>U$({id:L$(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:[...q$(r,o,void 0),...uQ(o,i)],markers:pQ(a.flatMap(e=>[...e.markers]),o),lanes:i}}}function H$(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 U$({id:e,kind:t,label:n,nodeId:r,range:i,spans:a,lanes:o}){let s=a.flatMap(t=>{let a=DQ(t);if(a===null)return[];let s=Date.parse(t.started_at),c=W$(t,a,s,i),l=t.reference?.kind===`conversation`?t.reference.value:void 0;return[{id:t.id,label:`${n} · ${OQ(a,o)}${G$(t)}`,laneId:a,start:s,end:c,duration:c-s,status:t.status,payload:{id:t.id,kind:`work`,label:`${n} · ${OQ(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=q$(i,s,{rowId:e,nodeId:r}),l=K$(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,...uQ(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 W$(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 G$(e){return e.count!==void 0&&e.count>1?` · ${e.count} recorded`:``}function K$(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 q$(e,t,n){let r=K$(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>=B$).map(([e,t],r)=>{let i=`${F$}${n?.rowId??`graph`}-${r}`,a={id:i,kind:`idle`,label:`Idle · ${QP(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:$Z,start:e,end:t,duration:t-e,status:`idle`,payload:a}})}function J$({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)(()=>V$(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:xQ(f):bQ(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)(Z$,{icon:(0,G.jsx)(ht,{}),label:`Status`,value:t.run.state}),(0,G.jsx)(Z$,{icon:(0,G.jsx)(Bt,{}),label:`Nodes`,value:String(t.run.nodes.length)}),(0,G.jsx)(Z$,{icon:(0,G.jsx)(At,{}),label:`Wall time`,value:t.run.timing.wall_seconds===null?`not measured`:$P(t.run.timing.wall_seconds)}),(0,G.jsx)(Z$,{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)(Y$,{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)(t$,{client:e,row:p,runId:c})]})]})}function Y$({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)(X$,{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 X$({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:[QP(e.workedMs),` recorded · `,QP(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 Z$({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 Q$=6,$$=8,e1=`[aria-describedby^="timeline-detail-"]`,t1=e=>{if(!(e instanceof Element))return;let t=XZ(e);if(t!==void 0)return t;let n=e.closest(e1);if(!(n instanceof HTMLElement))return;let r=document.getElementById(n.getAttribute(`aria-describedby`)??``)?.textContent?.trim();return r?{element:n,detail:r}:void 0},n1=(e,t)=>t!==void 0&&e?.element===t.element&&e.detail===t.detail?e:t;function r1(){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=>n1(t,t1(e.target))),t=e=>i(t=>n1(t,t1(e.target))),r=e=>i(t=>n1(t,t1(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-$$,s=Math.min(Math.max(n.left,$$),Math.max($$,i)),c=n.bottom+Q$,l=n.top-r.height-Q$,u=Math.max($$,window.innerHeight-r.height-$$),d=c+r.height<=window.innerHeight-$$?c:l,f=Math.min(Math.max(d,$$),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 i1=new KM(window.location.origin,{fetch:window.fetch.bind(window)}),a1=Object.entries(vX);function o1({client:e=i1}){let t=wX(),n=(0,U.useMemo)(()=>t.view===`overall`?{}:t.nodeId===void 0?void 0:{nodeId:t.nodeId},[t.view,t.nodeId]),r=vX[t.detail].profile,i=WX(e,t.runId,n,r,t.list===`runs`),a=i.list?.runs??[],o=i.runId,s=i.detail,c=(0,U.useMemo)(()=>s?zY(s):[],[s]),l=HX(e,i.invalidations,t.list===`projects`),u=UX(e,o===void 0?t.projectKey:void 0,i.invalidations),d=t.projectKey===void 0?void 0:u.group??jX(l.list?.projects??[],t.projectKey),f=_F(e,o===void 0?d?.project??void 0:void 0,i.invalidations),p=iI(e,o,r,i.invalidations),m=yZ(e,o),h=bZ(e),g=s===void 0?void 0:LY(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)(r1,{}),(0,G.jsxs)(`div`,{className:`app-shell`,children:[(0,G.jsx)(LX,{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)(xZ,{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?OX(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?OX(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&&OX(d))??t.projectKey)})]})]}),(0,G.jsxs)(`div`,{className:`topbar-actions`,children:[o!==void 0&&(0,G.jsx)($F,{control:p,runId:o,children:(0,G.jsx)(vZ,{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)(aF,{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)(wZ,{label:`Run shutdown`,onDismiss:m.dismiss,rows:a,state:m.state}),(0,G.jsx)(wZ,{label:`Shutdown of all my runs`,onDismiss:h.mine.dismiss,rows:a,state:h.mine.state}),(0,G.jsx)(wZ,{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)(zX,{agents:d?.project==null?void 0:(0,G.jsx)(pF,{agents:f,client:e,count:d.agent_count,title:`Agents of ${OX(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)(RX,{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):mX(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`}),a1.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)(LF,{client:e,decisions:g?.decisions??[],filter:r,invalidations:i.invalidations,observedAt:s.observed_at,overrides:g&&RY(g),runId:o}):t.view===`watch`?(0,G.jsx)(aI,{onToggle:p.toggleWatch,runId:o,unwatched:p.unwatched.value,watch:p.watch}):t.view===`reads`?(0,G.jsx)(YF,{client:e,invalidations:i.invalidations,nodes:c,runId:o,status:p.status}):t.view===`agents`?(0,G.jsx)(vF,{client:e,count:s.run.agent_count,invalidations:i.invalidations,runId:o}):t.view===`overall`?(0,G.jsx)(J$,{client:e,detail:s,nodes:c,timeline:i.timeline,timelineError:i.timelineError,onSelectNode:t.selectNode,onSelectItem:t.selectItem,selectedItemId:t.itemId}):_?(0,G.jsx)(w$,{agents:(0,G.jsx)(yF,{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)(nX,{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 s1=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}},c1=document.getElementById(`root`);if(!c1)throw Error(`DAG UI root element is missing`);(0,CA.createRoot)(c1).render((0,G.jsx)(U.StrictMode,{children:(0,G.jsx)(s1,{children:(0,G.jsx)(o1,{})})}));
|
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-DPrwsehT.js"></script>
|
|
12
12
|
<link rel="stylesheet" crossorigin href="/assets/index-m7hUhIQ5.css">
|
|
13
13
|
</head>
|
|
14
14
|
<body>
|