@workflow/web 4.1.0-beta.41 → 4.1.0-beta.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (25) hide show
  1. package/build/client/assets/{highlighted-body-B3W2YXNL-DKVOCXmq.js → highlighted-body-B3W2YXNL-Zd0qPYE7.js} +1 -1
  2. package/build/client/assets/{home-MMGoJh7w.js → home-C-j1J39E.js} +1 -1
  3. package/build/client/assets/{manifest-678c3cbf.js → manifest-41615f41.js} +1 -1
  4. package/build/client/assets/mermaid-3ZIDBTTL-BMFG0Hnn.js +172 -0
  5. package/build/client/assets/{root-DQpGl57T.js → root-EzkmXyJV.js} +1 -1
  6. package/build/client/assets/root-SL7uvdv2.css +1 -0
  7. package/build/client/assets/run-detail-C0ZpSKc-.js +36 -0
  8. package/build/client/assets/server-build-d6BKG46c.css +1 -0
  9. package/build/client/assets/{use-workflow-graph-B8LKXrpA.js → use-workflow-graph-DXipnqlR.js} +1 -1
  10. package/build/server/assets/{app-Bdxmgv4c.js → app-BIqik-91.js} +1 -1
  11. package/build/server/assets/{highlighted-body-B3W2YXNL-uEj5-2nD.js → highlighted-body-B3W2YXNL-WkqeTqm-.js} +2 -2
  12. package/build/server/assets/{mermaid-3ZIDBTTL-BvjkIiuk.js → mermaid-3ZIDBTTL-ClaETQoK.js} +2 -2
  13. package/build/server/assets/{server-build-CKAakcyN.js → server-build-Cyb0dncG.js} +1310 -1063
  14. package/build/server/assets/{token-CNug9NIq.js → token-Bjyd4X_e.js} +3 -3
  15. package/build/server/assets/{token-DLqvw7I2.js → token-CTJIoJEi.js} +2 -2
  16. package/build/server/assets/{token-util-DMDYM1rE.js → token-util-D-4jXUkD.js} +2 -2
  17. package/build/server/assets/{token-util-DgFyM3ow.js → token-util-DoGNqK5w.js} +1 -1
  18. package/build/server/assets/{token-util-_HYGsI73.js → token-util-Dp_pg92C.js} +2 -2
  19. package/build/server/index.js +1 -1
  20. package/package.json +3 -3
  21. package/server.js +4 -2
  22. package/build/client/assets/mermaid-3ZIDBTTL-BPJg8vAL.js +0 -172
  23. package/build/client/assets/root-BMRA92qM.css +0 -1
  24. package/build/client/assets/run-detail-DZDSfYol.js +0 -46
  25. package/build/client/assets/server-build-ClfhJhzu.css +0 -1
@@ -1,46 +0,0 @@
1
- import{R as q,j as n,r as m,A as Ps,f as Bs,x as Ca,y as zs,z as Ta,w as Ea,C as Aa}from"./index-DklpUtP3.js";import{U as sr,C as kr,V as or,B as xt,j as yn,q as Ws,Y as Ra,Z as Da,S as $s,R as Vs,p as Ma,o as _a,X as Gs,Q as Ht,_ as La,G as Oa,$ as Qe,u as yr,W as Tt,a0 as Ha,v as ct,a1 as Ir,a2 as Fa,t as Us,a3 as Pa,s as Ba,a4 as Wr,w as bn,l as za,m as Wa,a5 as $a,a6 as Va,a7 as Ga,a8 as Ua,a9 as Ka,aa as qa,ab as Za,ac as Ya,ad as zn,J as Sr,ae as Ks,af as Xa,ag as Ja,ah as Wn,ai as et,aj as tt,F as rn,ak as Qa,al as ei,am as ti,an as ri,r as ni,A as nn,c as sn,d as on,a as Ct,ao as si,e as oi,b as fr,T as ai,M as ii,N as mr,K as li,O as pr,y as ci,ap as di,I as ui}from"./use-workflow-graph-B8LKXrpA.js";import{c as ar,t as fe,H as xe,I as At,J as Cr,_ as fi,M as mi,N as at,O as pi,U as hi,W as qs,X as Rt,Y as nt,Z as te,$ as gi,a0 as xi,a1 as $r,a2 as Fe,a3 as hr,a4 as Tr,a5 as Ft,a6 as gt,a7 as Zs,a8 as Ut,a9 as Vr,aa as vi,ab as yi,ac as bi,ad as wi,ae as Ni,af as ji,ag as ki,ah as an,ai as it,aj as Ys,k as br,E as ln,ak as Ii,al as Si,am as wn,z as yt,an as Ci,d as We,ao as Xs,ap as Ti,aq as Ei,ar as Ai,as as Ri,T as Js,a as Qs,b as eo,at as Di,L as Nn,u as Mi,au as $n,av as _i,aw as Li}from"./mermaid-3ZIDBTTL-BPJg8vAL.js";import{importKey as Oi,decrypt as Hi}from"./encryption-8OvC6eoJ.js";/**
2
- * @license lucide-react v0.575.0 - ISC
3
- *
4
- * This source code is licensed under the ISC license.
5
- * See the LICENSE file in the root directory of this source tree.
6
- */const Fi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],Pi=ar("circle-question-mark",Fi);/**
7
- * @license lucide-react v0.575.0 - ISC
8
- *
9
- * This source code is licensed under the ISC license.
10
- * See the LICENSE file in the root directory of this source tree.
11
- */const Bi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],zi=ar("info",Bi);/**
12
- * @license lucide-react v0.575.0 - ISC
13
- *
14
- * This source code is licensed under the ISC license.
15
- * See the LICENSE file in the root directory of this source tree.
16
- */const Wi=[["path",{d:"M3 5h.01",key:"18ugdj"}],["path",{d:"M3 12h.01",key:"nlz23k"}],["path",{d:"M3 19h.01",key:"noohij"}],["path",{d:"M8 5h13",key:"1pao27"}],["path",{d:"M8 12h13",key:"1za7za"}],["path",{d:"M8 19h13",key:"m83p4d"}]],Gr=ar("list",Wi);/**
17
- * @license lucide-react v0.575.0 - ISC
18
- *
19
- * This source code is licensed under the ISC license.
20
- * See the LICENSE file in the root directory of this source tree.
21
- */const $i=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 9.9-1",key:"1mm8w8"}]],Vi=ar("lock-open",$i);/**
22
- * @license lucide-react v0.575.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Gi=[["path",{d:"M12 4v16",key:"1654pz"}],["path",{d:"M4 7V5a1 1 0 0 1 1-1h14a1 1 0 0 1 1 1v2",key:"e0r10z"}],["path",{d:"M9 20h6",key:"s66wpe"}]],Ui=ar("type",Gi),Or=0,bt=1,Wt=2,to=4;function Vn(e){return()=>e}function Ki(e){e()}function ro(e,t){return r=>e(t(r))}function Gn(e,t){return()=>e(t)}function qi(e,t){return r=>e(t,r)}function jn(e){return e!==void 0}function Zi(...e){return()=>{e.map(Ki)}}function $t(){}function Hr(e,t){return t(e),e}function Yi(e,t){return t(e)}function je(...e){return e}function he(e,t){return e(bt,t)}function oe(e,t){e(Or,t)}function kn(e){e(Wt)}function Ie(e){return e(to)}function Z(e,t){return he(e,qi(t,Or))}function Ue(e,t){const r=e(bt,s=>{r(),t(s)});return r}function Un(e){let t,r;return s=>o=>{t=o,r&&clearTimeout(r),r=setTimeout(()=>{s(t)},e)}}function no(e,t){return e===t}function Ne(e=no){let t;return r=>s=>{e(t,s)||(t=s,r(s))}}function ne(e){return t=>r=>{e(r)&&t(r)}}function U(e){return t=>ro(t,e)}function Je(e){return t=>()=>{t(e)}}function O(e,...t){const r=Xi(...t);return((s,o)=>{switch(s){case Wt:kn(e);return;case bt:return he(e,r(o))}})}function rt(e,t){return r=>s=>{r(t=e(t,s))}}function Dt(e){return t=>r=>{e>0?e--:t(r)}}function lt(e){let t=null,r;return s=>o=>{t=o,!r&&(r=setTimeout(()=>{r=void 0,s(t)},e))}}function ie(...e){const t=new Array(e.length);let r=0,s=null;const o=Math.pow(2,e.length)-1;return e.forEach((a,i)=>{const l=Math.pow(2,i);he(a,d=>{const c=r;r=r|l,t[i]=d,c!==o&&r===o&&s&&(s(),s=null)})}),a=>i=>{const l=()=>{a([i].concat(t))};r===o?l():s=l}}function Xi(...e){return t=>e.reduceRight(Yi,t)}function Ji(e){let t,r;const s=()=>t==null?void 0:t();return function(o,a){switch(o){case bt:return a?r===a?void 0:(s(),r=a,t=he(e,a),t):(s(),$t);case Wt:s(),r=null;return}}}function z(e){let t=e;const r=ce();return((s,o)=>{switch(s){case Or:t=o;break;case bt:{o(t);break}case to:return t}return r(s,o)})}function Me(e,t){return Hr(z(t),r=>Z(e,r))}function ce(){const e=[];return((t,r)=>{switch(t){case Or:e.slice().forEach(s=>{s(r)});return;case Wt:e.splice(0,e.length);return;case bt:return e.push(r),()=>{const s=e.indexOf(r);s>-1&&e.splice(s,1)}}})}function ze(e){return Hr(ce(),t=>Z(e,t))}function me(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:Qi(),singleton:r}}const Qi=()=>Symbol();function el(e){const t=new Map,r=({constructor:s,dependencies:o,id:a,singleton:i})=>{if(i&&t.has(a))return t.get(a);const l=s(o.map(d=>r(d)));return i&&t.set(a,l),l};return r(e)}function Te(...e){const t=ce(),r=new Array(e.length);let s=0;const o=Math.pow(2,e.length)-1;return e.forEach((a,i)=>{const l=Math.pow(2,i);he(a,d=>{r[i]=d,s=s|l,s===o&&oe(t,r)})}),function(a,i){switch(a){case Wt:{kn(t);return}case bt:return s===o&&i(r),he(t,i)}}}function re(e,t=no){return O(e,Ne(t))}function cn(...e){return function(t,r){switch(t){case Wt:return;case bt:return Zi(...e.map(s=>he(s,r)))}}}var Pe=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Pe||{});const tl={0:"debug",3:"error",1:"log",2:"warn"},rl=()=>typeof globalThis>"u"?window:globalThis,wt=me(()=>{const e=z(3);return{log:z((t,r,s=1)=>{var o;const a=(o=rl().VIRTUOSO_LOG_LEVEL)!=null?o:Ie(e);s>=a&&console[tl[s]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function _t(e,t,r){return In(e,t,r).callbackRef}function In(e,t,r){const s=q.useRef(null);let o=i=>{};const a=q.useMemo(()=>typeof ResizeObserver<"u"?new ResizeObserver(i=>{const l=()=>{const d=i[0].target;d.offsetParent!==null&&e(d)};r?l():requestAnimationFrame(l)}):null,[e,r]);return o=i=>{i&&t?(a==null||a.observe(i),s.current=i):(s.current&&(a==null||a.unobserve(s.current)),s.current=null)},{callbackRef:o,ref:s}}function nl(e,t,r,s,o,a,i,l,d){const c=q.useCallback(p=>{const u=sl(p.children,t,l?"offsetWidth":"offsetHeight",o);let f=p.parentElement;for(;!f.dataset.virtuosoScroller;)f=f.parentElement;const g=f.lastElementChild.dataset.viewportType==="window";let y;g&&(y=f.ownerDocument.defaultView);const j=i?l?i.scrollLeft:i.scrollTop:g?l?y.scrollX||y.document.documentElement.scrollLeft:y.scrollY||y.document.documentElement.scrollTop:l?f.scrollLeft:f.scrollTop,b=i?l?i.scrollWidth:i.scrollHeight:g?l?y.document.documentElement.scrollWidth:y.document.documentElement.scrollHeight:l?f.scrollWidth:f.scrollHeight,v=i?l?i.offsetWidth:i.offsetHeight:g?l?y.innerWidth:y.innerHeight:l?f.offsetWidth:f.offsetHeight;s({scrollHeight:b,scrollTop:Math.max(j,0),viewportHeight:v}),a==null||a(l?Kn("column-gap",getComputedStyle(p).columnGap,o):Kn("row-gap",getComputedStyle(p).rowGap,o)),u!==null&&e(u)},[e,t,o,a,i,s,l]);return In(c,r,d)}function sl(e,t,r,s){const o=e.length;if(o===0)return null;const a=[];for(let i=0;i<o;i++){const l=e.item(i);if(l.dataset.index===void 0)continue;const d=parseInt(l.dataset.index),c=parseFloat(l.dataset.knownSize),p=t(l,r);if(p===0&&s("Zero-sized element, this should not happen",{child:l},Pe.ERROR),p===c)continue;const u=a[a.length-1];a.length===0||u.size!==p||u.endIndex!==d-1?a.push({endIndex:d,size:p,startIndex:d}):a[a.length-1].endIndex++}return a}function Kn(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,Pe.WARN),t==="normal"?0:parseInt(t??"0",10)}function so(e,t,r){const s=q.useRef(null),o=q.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;const c=d.getBoundingClientRect(),p=c.width;let u,f;if(t){const g=t.getBoundingClientRect(),y=c.top-g.top;f=g.height-Math.max(0,y),u=y+t.scrollTop}else{const g=i.current.ownerDocument.defaultView;f=g.innerHeight-Math.max(0,c.top),u=c.top+g.scrollY}s.current={offsetTop:u,visibleHeight:f,visibleWidth:p},e(s.current)},[e,t]),{callbackRef:a,ref:i}=In(o,!0,r),l=q.useCallback(()=>{o(i.current)},[o,i]);return q.useEffect(()=>{var d;if(t){t.addEventListener("scroll",l);const c=new ResizeObserver(()=>{requestAnimationFrame(l)});return c.observe(t),()=>{t.removeEventListener("scroll",l),c.unobserve(t)}}else{const c=(d=i.current)==null?void 0:d.ownerDocument.defaultView;return c==null||c.addEventListener("scroll",l),c==null||c.addEventListener("resize",l),()=>{c==null||c.removeEventListener("scroll",l),c==null||c.removeEventListener("resize",l)}}},[l,t,i]),a}const Oe=me(()=>{const e=ce(),t=ce(),r=z(0),s=ce(),o=z(0),a=ce(),i=ce(),l=z(0),d=z(0),c=z(0),p=z(0),u=ce(),f=ce(),g=z(!1),y=z(!1),j=z(!1);return Z(O(e,U(({scrollTop:b})=>b)),t),Z(O(e,U(({scrollHeight:b})=>b)),i),Z(t,o),{deviation:r,fixedFooterHeight:c,fixedHeaderHeight:d,footerHeight:p,headerHeight:l,horizontalDirection:y,scrollBy:f,scrollContainerState:e,scrollHeight:i,scrollingInProgress:g,scrollTo:u,scrollTop:t,skipAnimationFrameInResizeObserver:j,smoothScrollTargetReached:s,statefulScrollTop:o,viewportHeight:a}},[],{singleton:!0}),Yt={lvl:0};function oo(e,t){const r=e.length;if(r===0)return[];let{index:s,value:o}=t(e[0]);const a=[];for(let i=1;i<r;i++){const{index:l,value:d}=t(e[i]);a.push({end:l-1,start:s,value:o}),s=l,o=d}return a.push({end:1/0,start:s,value:o}),a}function ye(e){return e===Yt}function Xt(e,t){if(!ye(e))return t===e.k?e.v:t<e.k?Xt(e.l,t):Xt(e.r,t)}function qe(e,t,r="k"){if(ye(e))return[-1/0,void 0];if(Number(e[r])===t)return[e.k,e.v];if(Number(e[r])<t){const s=qe(e.r,t,r);return s[0]===-1/0?[e.k,e.v]:s}return qe(e.l,t,r)}function Be(e,t,r){return ye(e)?lo(t,r,1):t===e.k?Ee(e,{k:t,v:r}):t<e.k?qn(Ee(e,{l:Be(e.l,t,r)})):qn(Ee(e,{r:Be(e.r,t,r)}))}function Pt(){return Yt}function Bt(e,t,r){if(ye(e))return[];const s=qe(e,t)[0];return ol(un(e,s,r))}function dn(e,t){if(ye(e))return Yt;const{k:r,l:s,r:o}=e;if(t===r){if(ye(s))return o;if(ye(o))return s;{const[a,i]=io(s);return wr(Ee(e,{k:a,l:ao(s),v:i}))}}else return t<r?wr(Ee(e,{l:dn(s,t)})):wr(Ee(e,{r:dn(o,t)}))}function Et(e){return ye(e)?[]:[...Et(e.l),{k:e.k,v:e.v},...Et(e.r)]}function un(e,t,r){if(ye(e))return[];const{k:s,l:o,r:a,v:i}=e;let l=[];return s>t&&(l=l.concat(un(o,t,r))),s>=t&&s<=r&&l.push({k:s,v:i}),s<=r&&(l=l.concat(un(a,t,r))),l}function wr(e){const{l:t,lvl:r,r:s}=e;if(s.lvl>=r-1&&t.lvl>=r-1)return e;if(r>s.lvl+1){if(Ur(t))return co(Ee(e,{lvl:r-1}));if(!ye(t)&&!ye(t.r))return Ee(t.r,{l:Ee(t,{r:t.r.l}),lvl:r,r:Ee(e,{l:t.r.r,lvl:r-1})});throw new Error("Unexpected empty nodes")}else{if(Ur(e))return fn(Ee(e,{lvl:r-1}));if(!ye(s)&&!ye(s.l)){const o=s.l,a=Ur(o)?s.lvl-1:s.lvl;return Ee(o,{l:Ee(e,{lvl:r-1,r:o.l}),lvl:o.lvl+1,r:fn(Ee(s,{l:o.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function Ee(e,t){return lo(t.k!==void 0?t.k:e.k,t.v!==void 0?t.v:e.v,t.lvl!==void 0?t.lvl:e.lvl,t.l!==void 0?t.l:e.l,t.r!==void 0?t.r:e.r)}function ao(e){return ye(e.r)?e.l:wr(Ee(e,{r:ao(e.r)}))}function Ur(e){return ye(e)||e.lvl>e.r.lvl}function io(e){return ye(e.r)?[e.k,e.v]:io(e.r)}function lo(e,t,r,s=Yt,o=Yt){return{k:e,l:s,lvl:r,r:o,v:t}}function qn(e){return fn(co(e))}function co(e){const{l:t}=e;return!ye(t)&&t.lvl===e.lvl?Ee(t,{r:Ee(e,{l:t.r})}):e}function fn(e){const{lvl:t,r}=e;return!ye(r)&&!ye(r.r)&&r.lvl===t&&r.r.lvl===t?Ee(r,{l:Ee(e,{r:r.l}),lvl:t+1}):e}function ol(e){return oo(e,({k:t,v:r})=>({index:t,value:r}))}function uo(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function Jt(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Sn=me(()=>({recalcInProgress:z(!1)}),[],{singleton:!0});function fo(e,t,r){return e[Er(e,t,r)]}function Er(e,t,r,s=0){let o=e.length-1;for(;s<=o;){const a=Math.floor((s+o)/2),i=e[a],l=r(i,t);if(l===0)return a;if(l===-1){if(o-s<2)return a-1;o=a-1}else{if(o===s)return a;s=a+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function al(e,t,r,s){const o=Er(e,t,s),a=Er(e,r,s,o);return e.slice(o,a+1)}function vt(e,t){return Math.round(e.getBoundingClientRect()[t])}function Fr(e){return!ye(e.groupOffsetTree)}function Cn({index:e},t){return t===e?0:t<e?-1:1}function il(){return{groupIndices:[],groupOffsetTree:Pt(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Pt()}}function ll(e,t){let r=ye(e)?0:1/0;for(const s of t){const{endIndex:o,size:a,startIndex:i}=s;if(r=Math.min(r,i),ye(e)){e=Be(e,0,a);continue}const l=Bt(e,i-1,o+1);if(l.some(hl(s)))continue;let d=!1,c=!1;for(const{end:p,start:u,value:f}of l)d?(o>=u||a===f)&&(e=dn(e,u)):(c=f!==a,d=!0),p>o&&o>=u&&f!==a&&(e=Be(e,o+1,f));c&&(e=Be(e,i,a))}return[e,r]}function cl(e){return typeof e.groupIndex<"u"}function dl({offset:e},t){return t===e?0:t<e?-1:1}function Qt(e,t,r){if(t.length===0)return 0;const{index:s,offset:o,size:a}=fo(t,e,Cn),i=e-s,l=a*i+(i-1)*r+o;return l>0?l+r:l}function mo(e,t){if(!Fr(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function po(e,t,r){if(cl(e))return t.groupIndices[e.groupIndex]+1;{const s=e.index==="LAST"?r:e.index;let o=mo(s,t);return o=Math.max(0,o,Math.min(r,o)),o}}function ul(e,t,r,s=0){return s>0&&(t=Math.max(t,fo(e,s,Cn).offset)),oo(al(e,t,r,dl),pl)}function fl(e,[t,r,s,o]){t.length>0&&s("received item sizes",t,Pe.DEBUG);const a=e.sizeTree;let i=a,l=0;if(r.length>0&&ye(a)&&t.length===2){const f=t[0].size,g=t[1].size;i=r.reduce((y,j)=>Be(Be(y,j,f),j+1,g),i)}else[i,l]=ll(i,t);if(i===a)return e;const{lastIndex:d,lastOffset:c,lastSize:p,offsetTree:u}=mn(e.offsetTree,l,i,o);return{groupIndices:r,groupOffsetTree:r.reduce((f,g)=>Be(f,g,Qt(g,u,o)),Pt()),lastIndex:d,lastOffset:c,lastSize:p,offsetTree:u,sizeTree:i}}function ml(e){return Et(e).map(({k:t,v:r},s,o)=>{const a=o[s+1];return{endIndex:a?a.k-1:1/0,size:r,startIndex:t}})}function Zn(e,t){let r=0,s=0;for(;r<e;)r+=t[s+1]-t[s]-1,s++;return s-(r===e?0:1)}function mn(e,t,r,s){let o=e,a=0,i=0,l=0,d=0;if(t!==0){d=Er(o,t-1,Cn),l=o[d].offset;const c=qe(r,t-1);a=c[0],i=c[1],o.length&&o[d].size===qe(r,t)[1]&&(d-=1),o=o.slice(0,d+1)}else o=[];for(const{start:c,value:p}of Bt(r,t,1/0)){const u=c-a,f=u*i+l+u*s;o.push({index:c,offset:f,size:p}),a=c,l=f,i=p}return{lastIndex:a,lastOffset:l,lastSize:i,offsetTree:o}}function pl(e){return{index:e.index,value:e}}function hl(e){const{endIndex:t,size:r,startIndex:s}=e;return o=>o.start===s&&(o.end===t||o.end===1/0)&&o.value===r}const gl={offsetHeight:"height",offsetWidth:"width"},st=me(([{log:e},{recalcInProgress:t}])=>{const r=ce(),s=ce(),o=Me(s,0),a=ce(),i=ce(),l=z(0),d=z([]),c=z(void 0),p=z(void 0),u=z(void 0),f=z(void 0),g=z((x,w)=>vt(x,gl[w])),y=z(void 0),j=z(0),b=il(),v=Me(O(r,ie(d,e,j),rt(fl,b),Ne()),b),h=Me(O(d,Ne(),rt((x,w)=>({current:w,prev:x.current}),{current:[],prev:[]}),U(({prev:x})=>x)),[]);Z(O(d,ne(x=>x.length>0),ie(v,j),U(([x,w,S])=>{const T=x.reduce((C,A,R)=>Be(C,A,Qt(A,w.offsetTree,S)||R),Pt());return{...w,groupIndices:x,groupOffsetTree:T}})),v),Z(O(s,ie(v),ne(([x,{lastIndex:w}])=>x<w),U(([x,{lastIndex:w,lastSize:S}])=>[{endIndex:w,size:S,startIndex:x}])),r),Z(c,p);const k=Me(O(c,U(x=>x===void 0)),!0);Z(O(p,ne(x=>x!==void 0&&ye(Ie(v).sizeTree)),U(x=>{const w=Ie(u),S=Ie(d).length>0;return w?S?[{endIndex:0,size:w,startIndex:0},{endIndex:1,size:x,startIndex:1}]:[]:[{endIndex:0,size:x,startIndex:0}]})),r),Z(O(f,ne(x=>x!==void 0&&x.length>0&&ye(Ie(v).sizeTree)),U(x=>{const w=[];let S=x[0],T=0;for(let C=1;C<x.length;C++){const A=x[C];A!==S&&(w.push({endIndex:C-1,size:S,startIndex:T}),S=A,T=C)}return w.push({endIndex:x.length-1,size:S,startIndex:T}),w})),r),Z(O(d,ie(u,p),ne(([,x,w])=>x!==void 0&&w!==void 0),U(([x,w,S])=>{const T=[];for(let C=0;C<x.length;C++){const A=x[C],R=x[C+1];T.push({startIndex:A,endIndex:A,size:w}),R!==void 0&&T.push({startIndex:A+1,endIndex:R-1,size:S})}return T})),r);const N=ze(O(r,ie(v),rt(({sizes:x},[w,S])=>({changed:S!==x,sizes:S}),{changed:!1,sizes:b}),U(x=>x.changed)));he(O(l,rt((x,w)=>({diff:x.prev-w,prev:w}),{diff:0,prev:0}),U(x=>x.diff)),x=>{const{groupIndices:w}=Ie(v);if(x>0)oe(t,!0),oe(a,x+Zn(x,w));else if(x<0){const S=Ie(h);S.length>0&&(x-=Zn(-x,S)),oe(i,x)}}),he(O(l,ie(e)),([x,w])=>{x<0&&w("`firstItemIndex` prop should not be set to less than zero. If you don't know the total count, just use a very high value",{firstItemIndex:l},Pe.ERROR)});const I=ze(a);Z(O(a,ie(v),U(([x,w])=>{const S=w.groupIndices.length>0,T=[],C=w.lastSize;if(S){const A=Xt(w.sizeTree,0);let R=0,F=0;for(;R<x;){const M=w.groupIndices[F],D=w.groupIndices.length===F+1?1/0:w.groupIndices[F+1]-M-1;T.push({endIndex:M,size:A,startIndex:M}),T.push({endIndex:M+1+D-1,size:C,startIndex:M+1}),F++,R+=D+1}const $=Et(w.sizeTree);return R!==x&&$.shift(),$.reduce((M,{k:D,v:P})=>{let K=M.ranges;return M.prevSize!==0&&(K=[...M.ranges,{endIndex:D+x-1,size:M.prevSize,startIndex:M.prevIndex}]),{prevIndex:D+x,prevSize:P,ranges:K}},{prevIndex:x,prevSize:0,ranges:T}).ranges}return Et(w.sizeTree).reduce((A,{k:R,v:F})=>({prevIndex:R+x,prevSize:F,ranges:[...A.ranges,{endIndex:R+x-1,size:A.prevSize,startIndex:A.prevIndex}]}),{prevIndex:0,prevSize:C,ranges:[]}).ranges})),r);const E=ze(O(i,ie(v,j),U(([x,{offsetTree:w},S])=>{const T=-x;return Qt(T,w,S)})));return Z(O(i,ie(v,j),U(([x,w,S])=>{if(w.groupIndices.length>0){if(ye(w.sizeTree))return w;let T=Pt();const C=Ie(h);let A=0,R=0,F=0;for(;A<-x;){F=C[R];const $=C[R+1]-F-1;R++,A+=$+1}if(T=Et(w.sizeTree).reduce(($,{k:M,v:D})=>Be($,Math.max(0,M+x),D),T),A!==-x){const $=Xt(w.sizeTree,F);T=Be(T,0,$);const M=qe(w.sizeTree,-x+1)[1];T=Be(T,1,M)}return{...w,sizeTree:T,...mn(w.offsetTree,0,T,S)}}else{const T=Et(w.sizeTree).reduce((C,{k:A,v:R})=>Be(C,Math.max(0,A+x),R),Pt());return{...w,sizeTree:T,...mn(w.offsetTree,0,T,S)}}})),v),{beforeUnshiftWith:I,data:y,defaultItemSize:p,firstItemIndex:l,fixedItemSize:c,fixedGroupSize:u,gap:j,groupIndices:d,heightEstimates:f,itemSize:g,listRefresh:N,shiftWith:i,shiftWithOffset:E,sizeRanges:r,sizes:v,statefulTotalCount:o,totalCount:s,trackItemSizes:k,unshiftWith:a}},je(wt,Sn),{singleton:!0});function xl(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const ho=me(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:s,scrollTop:o}])=>{const a=ce(),i=ce(),l=ze(O(a,U(xl)));return Z(O(l,U(d=>d.totalCount)),r),Z(O(l,U(d=>d.groupIndices)),e),Z(O(Te(o,t,s),ne(([d,c])=>Fr(c)),U(([d,c,p])=>qe(c.groupOffsetTree,Math.max(d-p,0),"v")[0]),Ne(),U(d=>[d])),i),{groupCounts:a,topItemsIndexes:i}},je(st,Oe)),Nt=me(([{log:e}])=>{const t=z(!1),r=ze(O(t,ne(s=>s),Ne()));return he(t,s=>{s&&Ie(e)("props updated",{},Pe.DEBUG)}),{didMount:r,propsReady:t}},je(wt),{singleton:!0}),vl=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function go(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!vl)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const ir=me(([{gap:e,listRefresh:t,sizes:r,totalCount:s},{fixedFooterHeight:o,fixedHeaderHeight:a,footerHeight:i,headerHeight:l,scrollingInProgress:d,scrollTo:c,smoothScrollTargetReached:p,viewportHeight:u},{log:f}])=>{const g=ce(),y=ce(),j=z(0);let b=null,v=null,h=null;function k(){b&&(b(),b=null),h&&(h(),h=null),v&&(clearTimeout(v),v=null),oe(d,!1)}return Z(O(g,ie(r,u,s,j,l,i,f),ie(e,a,o),U(([[N,I,E,x,w,S,T,C],A,R,F])=>{const $=go(N),{align:M,behavior:D,offset:P}=$,K=x-1,B=po($,I,K);let _=Qt(B,I.offsetTree,A)+S;M==="end"?(_+=R+qe(I.sizeTree,B)[1]-E+F,B===K&&(_+=T)):M==="center"?_+=(R+qe(I.sizeTree,B)[1]-E+F)/2:_-=w,P&&(_+=P);const W=L=>{k(),L?(C("retrying to scroll to",{location:N},Pe.DEBUG),oe(g,N)):(oe(y,!0),C("list did not change, scroll successful",{},Pe.DEBUG))};if(k(),D==="smooth"){let L=!1;h=he(t,G=>{L=L||G}),b=Ue(p,()=>{W(L)})}else b=Ue(O(t,yl(150)),W);return v=setTimeout(()=>{k()},1200),oe(d,!0),C("scrolling from index to",{behavior:D,index:B,top:_},Pe.DEBUG),{behavior:D,top:_}})),c),{scrollTargetReached:y,scrollToIndex:g,topListHeight:j}},je(st,Oe,wt),{singleton:!0});function yl(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return s=>{s&&(t(!0),clearTimeout(r))}}}function Tn(e,t){e==0?t():requestAnimationFrame(()=>{Tn(e-1,t)})}function En(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const lr=me(([{defaultItemSize:e,listRefresh:t,sizes:r},{scrollTop:s},{scrollTargetReached:o,scrollToIndex:a},{didMount:i}])=>{const l=z(!0),d=z(0),c=z(!0);return Z(O(i,ie(d),ne(([p,u])=>!!u),Je(!1)),l),Z(O(i,ie(d),ne(([p,u])=>!!u),Je(!1)),c),he(O(Te(t,i),ie(l,r,e,c),ne(([[,p],u,{sizeTree:f},g,y])=>p&&(!ye(f)||jn(g))&&!u&&!y),ie(d)),([,p])=>{Ue(o,()=>{oe(c,!0)}),Tn(4,()=>{Ue(s,()=>{oe(l,!0)}),oe(a,p)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:d,scrolledToInitialItem:l}},je(st,Oe,ir,Nt),{singleton:!0});function xo(e,t){return Math.abs(e-t)<1.01}const er="up",qt="down",bl="none",wl={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Nl=0,cr=me(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:s,scrollTop:o,viewportHeight:a}])=>{const i=z(!1),l=z(!0),d=ce(),c=ce(),p=z(4),u=z(Nl),f=Me(O(cn(O(re(o),Dt(1),Je(!0)),O(re(o),Dt(1),Je(!1),Un(100))),Ne()),!1),g=Me(O(cn(O(r,Je(!0)),O(r,Je(!1),Un(200))),Ne()),!1);Z(O(Te(re(o),re(u)),U(([h,k])=>h<=k),Ne()),l),Z(O(l,lt(50)),c);const y=ze(O(Te(s,re(a),re(t),re(e),re(p)),rt((h,[{scrollHeight:k,scrollTop:N},I,E,x,w])=>{const S=N+I-k>-w,T={scrollHeight:k,scrollTop:N,viewportHeight:I};if(S){let A,R;return N>h.state.scrollTop?(A="SCROLLED_DOWN",R=h.state.scrollTop-N):(A="SIZE_DECREASED",R=h.state.scrollTop-N||h.scrollTopDelta),{atBottom:!0,atBottomBecause:A,scrollTopDelta:R,state:T}}let C;return T.scrollHeight>h.state.scrollHeight?C="SIZE_INCREASED":I<h.state.viewportHeight?C="VIEWPORT_HEIGHT_DECREASING":N<h.state.scrollTop?C="SCROLLING_UPWARDS":C="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:C,state:T}},wl),Ne((h,k)=>h&&h.atBottom===k.atBottom))),j=Me(O(s,rt((h,{scrollHeight:k,scrollTop:N,viewportHeight:I})=>{if(xo(h.scrollHeight,k))return{changed:!1,jump:0,scrollHeight:k,scrollTop:N};{const E=k-(N+I)<1;return h.scrollTop!==N&&E?{changed:!0,jump:h.scrollTop-N,scrollHeight:k,scrollTop:N}:{changed:!0,jump:0,scrollHeight:k,scrollTop:N}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),ne(h=>h.changed),U(h=>h.jump)),0);Z(O(y,U(h=>h.atBottom)),i),Z(O(i,lt(50)),d);const b=z(qt);Z(O(s,U(({scrollTop:h})=>h),Ne(),rt((h,k)=>Ie(g)?{direction:h.direction,prevScrollTop:k}:{direction:k<h.prevScrollTop?er:qt,prevScrollTop:k},{direction:qt,prevScrollTop:0}),U(h=>h.direction)),b),Z(O(s,lt(50),Je(bl)),b);const v=z(0);return Z(O(f,ne(h=>!h),Je(0)),v),Z(O(o,lt(100),ie(f),ne(([h,k])=>k),rt(([h,k],[N])=>[k,N],[0,0]),U(([h,k])=>k-h)),v),{atBottomState:y,atBottomStateChange:d,atBottomThreshold:p,atTopStateChange:c,atTopThreshold:u,isAtBottom:i,isAtTop:l,isScrolling:f,lastJumpDueToItemResize:j,scrollDirection:b,scrollVelocity:v}},je(Oe)),tr="top",rr="bottom",Yn="none";function Xn(e,t,r){return typeof e=="number"?r===er&&t===tr||r===qt&&t===rr?e:0:r===er?t===tr?e.main:e.reverse:t===rr?e.main:e.reverse}function Jn(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const An=me(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:s,viewportHeight:o}])=>{const a=ce(),i=z(0),l=z(0),d=z(0),c=Me(O(Te(re(s),re(o),re(r),re(a,Jt),re(d),re(i),re(t),re(e),re(l)),U(([p,u,f,[g,y],j,b,v,h,k])=>{const N=p-h,I=b+v,E=Math.max(f-N,0);let x=Yn;const w=Jn(k,tr),S=Jn(k,rr);return g-=h,g+=f+v,y+=f+v,y-=h,g>p+I-w&&(x=er),y<p-E+u+S&&(x=qt),x!==Yn?[Math.max(N-f-Xn(j,tr,x)-w,0),N-E-v+u+Xn(j,rr,x)+S]:null}),ne(p=>p!=null),Ne(Jt)),[0,0]);return{increaseViewportBy:l,listBoundary:a,overscan:d,topListHeight:i,visibleRange:c}},je(Oe),{singleton:!0});function jl(e,t,r){if(Fr(t)){const s=mo(e,t);return[{index:qe(t.groupOffsetTree,s)[0],offset:0,size:0},{data:r==null?void 0:r[0],index:s,offset:0,size:0}]}return[{data:r==null?void 0:r[0],index:e,offset:0,size:0}]}const Kr={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Nr(e,t,r,s,o,a){const{lastIndex:i,lastOffset:l,lastSize:d}=o;let c=0,p=0;if(e.length>0){c=e[0].offset;const j=e[e.length-1];p=j.offset+j.size}const u=r-i,f=l+u*d+(u-1)*s,g=c,y=f-p;return{bottom:p,firstItemIndex:a,items:Qn(e,o,a),offsetBottom:y,offsetTop:c,top:g,topItems:Qn(t,o,a),topListHeight:t.reduce((j,b)=>b.size+j,0),totalCount:r}}function vo(e,t,r,s,o,a){let i=0;if(r.groupIndices.length>0)for(const p of r.groupIndices){if(p-i>=e)break;i++}const l=e+i,d=En(t,l),c=Array.from({length:l}).map((p,u)=>({data:a[u+d],index:u+d,offset:0,size:0}));return Nr(c,[],l,o,r,s)}function Qn(e,t,r){if(e.length===0)return[];if(!Fr(t))return e.map(c=>({...c,index:c.index+r,originalIndex:c.index}));const s=e[0].index,o=e[e.length-1].index,a=[],i=Bt(t.groupOffsetTree,s,o);let l,d=0;for(const c of e){(!l||l.end<c.index)&&(l=i.shift(),d=t.groupIndices.indexOf(l.start));let p;c.index===l.start?p={index:d,type:"group"}:p={groupIndex:d,index:c.index-(d+1)+r},a.push({...p,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return a}function es(e,t){var r;return e===void 0?0:typeof e=="number"?e:(r=e[t])!=null?r:0}const Lt=me(([{data:e,firstItemIndex:t,gap:r,sizes:s,totalCount:o},a,{listBoundary:i,topListHeight:l,visibleRange:d},{initialTopMostItemIndex:c,scrolledToInitialItem:p},{topListHeight:u},f,{didMount:g},{recalcInProgress:y}])=>{const j=z([]),b=z(0),v=ce(),h=z(0);Z(a.topItemsIndexes,j);const k=Me(O(Te(g,y,re(d,Jt),re(o),re(s),re(c),p,re(j),re(t),re(r),re(h),e),ne(([x,w,,S,,,,,,,,T])=>{const C=T&&T.length!==S;return x&&!w&&!C}),U(([,,[x,w],S,T,C,A,R,F,$,M,D])=>{var P,K,B,_;const W=T,{offsetTree:L,sizeTree:G}=W,V=Ie(b);if(S===0)return{...Kr,totalCount:S};if(x===0&&w===0)return V===0?{...Kr,totalCount:S}:vo(V,C,T,F,$,D||[]);if(ye(G))return V>0?null:Nr(jl(En(C,S),W,D),[],S,$,W,F);const J=[];if(R.length>0){const ee=R[0],ae=R[R.length-1];let ve=0;for(const be of Bt(G,ee,ae)){const le=be.value,ue=Math.max(be.start,ee),Se=Math.min(be.end,ae);for(let Ce=ue;Ce<=Se;Ce++)J.push({data:D==null?void 0:D[Ce],index:Ce,offset:ve,size:le}),ve+=le}}if(!A)return Nr([],J,S,$,W,F);const de=R.length>0?R[R.length-1]+1:0,H=ul(L,x,w,de);if(H.length===0)return null;const Y=S-1,X=Hr([],ee=>{for(const ae of H){const ve=ae.value;let be=ve.offset,le=ae.start;const ue=ve.size;if(ve.offset<x){le+=Math.floor((x-ve.offset+$)/(ue+$));const Ce=le-ae.start;be+=Ce*ue+Ce*$}le<de&&(be+=(de-le)*ue,le=de);const Se=Math.min(ae.end,Y);for(let Ce=le;Ce<=Se&&!(be>=w);Ce++)ee.push({data:D==null?void 0:D[Ce],index:Ce,offset:be,size:ue}),be+=ue+$}}),ge=es(M,tr),Ae=es(M,rr);if(X.length>0&&(ge>0||Ae>0)){const ee=X[0],ae=X[X.length-1];if(ge>0&&ee.index>de){const ve=Math.min(ge,ee.index-de),be=[];let le=ee.offset;for(let ue=ee.index-1;ue>=ee.index-ve;ue--){const Se=(K=(P=Bt(G,ue,ue)[0])==null?void 0:P.value)!=null?K:ee.size;le-=Se+$,be.unshift({data:D==null?void 0:D[ue],index:ue,offset:le,size:Se})}X.unshift(...be)}if(Ae>0&&ae.index<Y){const ve=Math.min(Ae,Y-ae.index);let be=ae.offset+ae.size+$;for(let le=ae.index+1;le<=ae.index+ve;le++){const ue=(_=(B=Bt(G,le,le)[0])==null?void 0:B.value)!=null?_:ae.size;X.push({data:D==null?void 0:D[le],index:le,offset:be,size:ue}),be+=ue+$}}}return Nr(X,J,S,$,W,F)}),ne(x=>x!==null),Ne()),Kr);Z(O(e,ne(jn),U(x=>x==null?void 0:x.length)),o),Z(O(k,U(x=>x.topListHeight)),u),Z(u,l),Z(O(k,U(x=>[x.top,x.bottom])),i),Z(O(k,U(x=>x.items)),v);const N=ze(O(k,ne(({items:x})=>x.length>0),ie(o,e),ne(([{items:x},w])=>x[x.length-1].originalIndex===w-1),U(([,x,w])=>[x-1,w]),Ne(Jt),U(([x])=>x))),I=ze(O(k,lt(200),ne(({items:x,topItems:w})=>x.length>0&&x[0].originalIndex===w.length),U(({items:x})=>x[0].index),Ne())),E=ze(O(k,ne(({items:x})=>x.length>0),U(({items:x})=>{let w=0,S=x.length-1;for(;x[w].type==="group"&&w<S;)w++;for(;x[S].type==="group"&&S>w;)S--;return{endIndex:x[S].index,startIndex:x[w].index}}),Ne(uo)));return{endReached:N,initialItemCount:b,itemsRendered:v,listState:k,minOverscanItemCount:h,rangeChanged:E,startReached:I,topItemsIndexes:j,...f}},je(st,ho,An,lr,ir,cr,Nt,Sn),{singleton:!0}),yo=me(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:s},{listState:o}])=>{const a=ce(),i=Me(O(Te(r,e,s,t,o),U(([l,d,c,p,u])=>l+d+c+p+u.offsetBottom+u.bottom)),0);return Z(re(i),a),{totalListHeight:i,totalListHeightChanged:a}},je(Oe,Lt),{singleton:!0}),kl=me(([{viewportHeight:e},{totalListHeight:t}])=>{const r=z(!1),s=Me(O(Te(r,e,t),ne(([o])=>o),U(([,o,a])=>Math.max(0,o-a)),lt(0),Ne()),0);return{alignToBottom:r,paddingTopAddition:s}},je(Oe,yo),{singleton:!0}),bo=me(()=>({context:z(null)})),Il=({itemBottom:e,itemTop:t,locationParams:{align:r,behavior:s,...o},viewportBottom:a,viewportTop:i})=>t<i?{...o,align:r??"start",behavior:s}:e>a?{...o,align:r??"end",behavior:s}:null,wo=me(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:s,fixedHeaderHeight:o,headerHeight:a,scrollingInProgress:i,scrollTop:l,viewportHeight:d},{scrollToIndex:c}])=>{const p=ce();return Z(O(p,ie(t,d,r,a,o,s,l),ie(e),U(([[u,f,g,y,j,b,v,h],k])=>{const{align:N,behavior:I,calculateViewLocation:E=Il,done:x,...w}=u,S=po(u,f,y-1),T=Qt(S,f.offsetTree,k)+j+b,C=T+qe(f.sizeTree,S)[1],A=h+b,R=h+g-v,F=E({itemBottom:C,itemTop:T,locationParams:{align:N,behavior:I,...w},viewportBottom:R,viewportTop:A});return F?x&&Ue(O(i,ne($=>!$),Dt(Ie(i)?1:2)),x):x==null||x(),F}),ne(u=>u!==null)),c),{scrollIntoView:p}},je(st,Oe,ir,Lt,wt),{singleton:!0});function ts(e){return e?e==="smooth"?"smooth":"auto":!1}const Sl=(e,t)=>typeof e=="function"?ts(e(t)):t&&ts(e),Cl=me(([{listRefresh:e,totalCount:t,fixedItemSize:r,data:s},{atBottomState:o,isAtBottom:a},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:d,propsReady:c},{log:p},{scrollingInProgress:u},{context:f},{scrollIntoView:g}])=>{const y=z(!1),j=ce();let b=null;function v(I){oe(i,{align:"end",behavior:I,index:"LAST"})}he(O(Te(O(re(t),Dt(1)),d),ie(re(y),a,l,u),U(([[I,E],x,w,S,T])=>{let C=E&&S,A="auto";return C&&(A=Sl(x,w||T),C=C&&!!A),{followOutputBehavior:A,shouldFollow:C,totalCount:I}}),ne(({shouldFollow:I})=>I)),({followOutputBehavior:I,totalCount:E})=>{b&&(b(),b=null),Ie(r)?requestAnimationFrame(()=>{Ie(p)("following output to ",{totalCount:E},Pe.DEBUG),v(I)}):b=Ue(e,()=>{Ie(p)("following output to ",{totalCount:E},Pe.DEBUG),v(I),b=null})});function h(I){const E=Ue(o,x=>{I&&!x.atBottom&&x.notAtBottomBecause==="SIZE_INCREASED"&&!b&&(Ie(p)("scrolling to bottom due to increased size",{},Pe.DEBUG),v("auto"))});setTimeout(E,100)}he(O(Te(re(y),t,c),ne(([I,,E])=>I&&E),rt(({value:I},[,E])=>({refreshed:I===E,value:E}),{refreshed:!1,value:0}),ne(({refreshed:I})=>I),ie(y,t)),([,I])=>{Ie(l)&&h(I!==!1)}),he(j,()=>{h(Ie(y)!==!1)}),he(Te(re(y),o),([I,E])=>{I&&!E.atBottom&&E.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&v("auto")});const k=z(null),N=ce();return Z(cn(O(re(s),U(I=>{var E;return(E=I==null?void 0:I.length)!=null?E:0})),O(re(t))),N),he(O(Te(O(N,Dt(1)),d),ie(re(k),l,u,f),U(([[I,E],x,w,S,T])=>E&&w&&(x==null?void 0:x({context:T,totalCount:I,scrollingInProgress:S}))),ne(I=>!!I),lt(0)),I=>{b&&(b(),b=null),Ie(r)?requestAnimationFrame(()=>{Ie(p)("scrolling into view",{}),oe(g,I)}):b=Ue(e,()=>{Ie(p)("scrolling into view",{}),oe(g,I),b=null})}),{autoscrollToBottom:j,followOutput:y,scrollIntoViewOnChange:k}},je(st,cr,ir,lr,Nt,wt,Oe,bo,wo)),Tl=me(([{data:e,firstItemIndex:t,gap:r,sizes:s},{initialTopMostItemIndex:o},{initialItemCount:a,listState:i},{didMount:l}])=>(Z(O(l,ie(a),ne(([,d])=>d!==0),ie(o,s,t,r,e),U(([[,d],c,p,u,f,g=[]])=>vo(d,c,p,u,f,g))),i),{}),je(st,lr,Lt,Nt),{singleton:!0}),El=me(([{didMount:e},{scrollTo:t},{listState:r}])=>{const s=z(0);return he(O(e,ie(s),ne(([,o])=>o!==0),U(([,o])=>({top:o}))),o=>{Ue(O(r,Dt(1),ne(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{oe(t,o)})})}),{initialScrollTop:s}},je(Nt,Oe,Lt),{singleton:!0}),No=me(([{scrollVelocity:e}])=>{const t=z(!1),r=ce(),s=z(!1);return Z(O(e,ie(s,t,r),ne(([o,a])=>!!a),U(([o,a,i,l])=>{const{enter:d,exit:c}=a;if(i){if(c(o,l))return!1}else if(d(o,l))return!0;return i}),Ne()),t),he(O(Te(t,e,r),ie(s)),([[o,a,i],l])=>{o&&l&&l.change&&l.change(a,i)}),{isSeeking:t,scrollSeekConfiguration:s,scrollSeekRangeChanged:r,scrollVelocity:e}},je(cr),{singleton:!0}),Rn=me(([{scrollContainerState:e,scrollTo:t}])=>{const r=ce(),s=ce(),o=ce(),a=z(!1),i=z(void 0);return Z(O(Te(r,s),U(([{scrollHeight:l,scrollTop:d,viewportHeight:c},{offsetTop:p}])=>({scrollHeight:l,scrollTop:Math.max(0,d-p),viewportHeight:c}))),e),Z(O(t,ie(s),U(([l,{offsetTop:d}])=>({...l,top:l.top+d}))),o),{customScrollParent:i,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:o,windowViewportRect:s}},je(Oe)),Al=me(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:s},{initialTopMostItemIndex:o},{didMount:a},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:d}])=>{const c=ce(),p=z(void 0),u=z(null),f=z(null);return Z(l,u),Z(d,f),he(O(c,ie(t,s,i,u,f,r)),([g,y,j,b,v,h,k])=>{const N=ml(y.sizeTree);b&&v!==null&&h!==null&&(j=v.scrollTop-h.offsetTop),j-=k,g({ranges:N,scrollTop:j})}),Z(O(p,ne(jn),U(Rl)),o),Z(O(a,ie(p),ne(([,g])=>g!==void 0),Ne(),U(([,g])=>g.ranges)),e),{getState:c,restoreStateFrom:p}},je(st,Oe,lr,Nt,Rn));function Rl(e){return{align:"start",index:0,offset:e.scrollTop}}const Dl=me(([{topItemsIndexes:e}])=>{const t=z(0);return Z(O(t,ne(r=>r>=0),U(r=>Array.from({length:r}).map((s,o)=>o))),e),{topItemCount:t}},je(Lt));function jo(e){let t=!1,r;return(()=>(t||(t=!0,r=e()),r))}const Ml=jo(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),_l=me(([{deviation:e,scrollBy:t,scrollingInProgress:r,scrollTop:s},{isAtBottom:o,isScrolling:a,lastJumpDueToItemResize:i,scrollDirection:l},{listState:d},{beforeUnshiftWith:c,gap:p,shiftWithOffset:u,sizes:f},{log:g},{recalcInProgress:y}])=>{const j=ze(O(d,ie(i),rt(([,v,h,k],[{bottom:N,items:I,offsetBottom:E,totalCount:x},w])=>{const S=N+E;let T=0;return h===x&&v.length>0&&I.length>0&&(I[0].originalIndex===0&&v[0].originalIndex===0||(T=S-k,T!==0&&(T+=w))),[T,I,x,S]},[0,[],0,0]),ne(([v])=>v!==0),ie(s,l,r,o,g,y),ne(([,v,h,k,,,N])=>!N&&!k&&v!==0&&h===er),U(([[v],,,,,h])=>(h("Upward scrolling compensation",{amount:v},Pe.DEBUG),v))));function b(v){v>0?(oe(t,{behavior:"auto",top:-v}),oe(e,0)):(oe(e,0),oe(t,{behavior:"auto",top:-v}))}return he(O(j,ie(e,a)),([v,h,k])=>{k&&Ml()?oe(e,h-v):b(-v)}),he(O(Te(Me(a,!1),e,y),ne(([v,h,k])=>!v&&!k&&h!==0),U(([v,h])=>h),lt(1)),b),Z(O(u,U(v=>({top:-v}))),t),he(O(c,ie(f,p),U(([v,{groupIndices:h,lastSize:k,sizeTree:N},I])=>{function E(x){return x*(k+I)}if(h.length===0)return E(v);{let x=0;const w=Xt(N,0);let S=0,T=0;for(;S<v;){S++,x+=w;let C=h.length===T+1?1/0:h[T+1]-h[T]-1;S+C>v&&(x-=w,C=v-S+1),S+=C,x+=E(C),T++}return x}})),v=>{oe(e,v),requestAnimationFrame(()=>{oe(t,{top:v}),requestAnimationFrame(()=>{oe(e,0),oe(y,!1)})})}),{deviation:e}},je(Oe,cr,Lt,st,wt,Sn)),Ll=me(([e,t,r,s,o,a,i,l,d,c,p])=>({...e,...t,...r,...s,...o,...a,...i,...l,...d,...c,...p}),je(An,Tl,Nt,No,yo,El,kl,Rn,wo,wt,bo)),ko=me(([{data:e,defaultItemSize:t,firstItemIndex:r,fixedItemSize:s,fixedGroupSize:o,gap:a,groupIndices:i,heightEstimates:l,itemSize:d,sizeRanges:c,sizes:p,statefulTotalCount:u,totalCount:f,trackItemSizes:g},{initialItemFinalLocationReached:y,initialTopMostItemIndex:j,scrolledToInitialItem:b},v,h,k,N,{scrollToIndex:I},E,{topItemCount:x},{groupCounts:w},S])=>{const{listState:T,minOverscanItemCount:C,topItemsIndexes:A,rangeChanged:R,...F}=N;return Z(R,S.scrollSeekRangeChanged),Z(O(S.windowViewportRect,U($=>$.visibleHeight)),v.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:r,fixedItemHeight:s,fixedGroupHeight:o,gap:a,groupCounts:w,heightEstimates:l,initialItemFinalLocationReached:y,initialTopMostItemIndex:j,scrolledToInitialItem:b,sizeRanges:c,topItemCount:x,topItemsIndexes:A,totalCount:f,...k,groupIndices:i,itemSize:d,listState:T,minOverscanItemCount:C,scrollToIndex:I,statefulTotalCount:u,trackItemSizes:g,rangeChanged:R,...F,...S,...v,sizes:p,...h}},je(st,lr,Oe,Al,Cl,Lt,ir,_l,Dl,ho,Ll));function Ol(e,t){const r={},s={};let o=0;const a=e.length;for(;o<a;)s[e[o]]=1,o+=1;for(const i in t)Object.hasOwn(s,i)||(r[i]=t[i]);return r}const gr=typeof document<"u"?q.useLayoutEffect:q.useEffect;function Io(e,t,r){const s=Object.keys(t.required||{}),o=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),l=q.createContext({});function d(b,v){b.propsReady&&oe(b.propsReady,!1);for(const h of s){const k=b[t.required[h]];oe(k,v[h])}for(const h of o)if(h in v){const k=b[t.optional[h]];oe(k,v[h])}b.propsReady&&oe(b.propsReady,!0)}function c(b){return a.reduce((v,h)=>(v[h]=k=>{const N=b[t.methods[h]];oe(N,k)},v),{})}function p(b){return i.reduce((v,h)=>(v[h]=Ji(b[t.events[h]]),v),{})}const u=q.forwardRef((b,v)=>{const{children:h,...k}=b,[N]=q.useState(()=>Hr(el(e),x=>{d(x,k)})),[I]=q.useState(Gn(p,N));gr(()=>{for(const x of i)x in k&&he(I[x],k[x]);return()=>{Object.values(I).map(kn)}},[k,I,N]),gr(()=>{d(N,k)}),q.useImperativeHandle(v,Vn(c(N)));const E=r;return n.jsx(l.Provider,{value:N,children:r?n.jsx(E,{...Ol([...s,...o,...i],k),children:h}):h})}),f=b=>{const v=q.useContext(l);return q.useCallback(h=>{oe(v[b],h)},[v,b])},g=b=>{const v=q.useContext(l)[b],h=q.useCallback(k=>he(v,k),[v]);return q.useSyncExternalStore(h,()=>Ie(v),()=>Ie(v))},y=b=>{const v=q.useContext(l)[b],[h,k]=q.useState(Gn(Ie,v));return gr(()=>he(v,N=>{N!==h&&k(Vn(N))}),[v,h]),h},j=q.version.startsWith("18")?g:y;return{Component:u,useEmitter:(b,v)=>{const h=q.useContext(l)[b];gr(()=>he(h,v),[v,h])},useEmitterValue:j,usePublisher:f}}const So=q.createContext(void 0),Co=q.createContext(void 0),To=typeof document<"u"?q.useLayoutEffect:q.useEffect;function qr(e){return"self"in e}function Hl(e){return"body"in e}function Eo(e,t,r,s=$t,o,a){const i=q.useRef(null),l=q.useRef(null),d=q.useRef(null),c=q.useCallback(f=>{let g,y,j;const b=f.target;if(Hl(b)||qr(b)){const h=qr(b)?b:b.defaultView;j=a?h.scrollX:h.scrollY,g=a?h.document.documentElement.scrollWidth:h.document.documentElement.scrollHeight,y=a?h.innerWidth:h.innerHeight}else j=a?b.scrollLeft:b.scrollTop,g=a?b.scrollWidth:b.scrollHeight,y=a?b.offsetWidth:b.offsetHeight;const v=()=>{e({scrollHeight:g,scrollTop:Math.max(j,0),viewportHeight:y})};f.suppressFlushSync?v():Ps.flushSync(v),l.current!==null&&(j===l.current||j<=0||j===g-y)&&(l.current=null,t(!0),d.current&&(clearTimeout(d.current),d.current=null))},[e,t,a]);q.useEffect(()=>{const f=o||i.current;return s(o||i.current),c({suppressFlushSync:!0,target:f}),f.addEventListener("scroll",c,{passive:!0}),()=>{s(null),f.removeEventListener("scroll",c)}},[i,c,r,s,o]);function p(f){const g=i.current;if(!g||(a?"offsetWidth"in g&&g.offsetWidth===0:"offsetHeight"in g&&g.offsetHeight===0))return;const y=f.behavior==="smooth";let j,b,v;qr(g)?(b=Math.max(vt(g.document.documentElement,a?"width":"height"),a?g.document.documentElement.scrollWidth:g.document.documentElement.scrollHeight),j=a?g.innerWidth:g.innerHeight,v=a?window.scrollX:window.scrollY):(b=g[a?"scrollWidth":"scrollHeight"],j=vt(g,a?"width":"height"),v=g[a?"scrollLeft":"scrollTop"]);const h=b-j;if(f.top=Math.ceil(Math.max(Math.min(h,f.top),0)),xo(j,b)||f.top===v){e({scrollHeight:b,scrollTop:v,viewportHeight:j}),y&&t(!0);return}y?(l.current=f.top,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,l.current=null,t(!0)},1e3)):l.current=null,a&&(f={behavior:f.behavior,left:f.top}),g.scrollTo(f)}function u(f){a&&(f={behavior:f.behavior,left:f.top}),i.current.scrollBy(f)}return{scrollByCallback:u,scrollerRef:i,scrollToCallback:p}}const Zr="-webkit-sticky",rs="sticky",Dn=jo(()=>{if(typeof document>"u")return rs;const e=document.createElement("div");return e.style.position=Zr,e.style.position===Zr?Zr:rs});function Mn(e){return e}const Fl=me(()=>{const e=z(l=>`Item ${l}`),t=z(l=>`Group ${l}`),r=z({}),s=z(Mn),o=z("div"),a=z($t),i=(l,d=null)=>Me(O(r,U(c=>c[l]),Ne()),d);return{components:r,computeItemKey:s,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:o,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),Pl=me(([e,t])=>({...e,...t}),je(ko,Fl)),Bl=({height:e})=>n.jsx("div",{style:{height:e}}),zl={overflowAnchor:"none",position:Dn(),zIndex:1},Ao={overflowAnchor:"none"},Wl={...Ao,display:"inline-block",height:"100%"},ns=q.memo(function({showTopList:e=!1}){const t=se("listState"),r=$e("sizeRanges"),s=se("useWindowScroll"),o=se("customScrollParent"),a=$e("windowScrollContainerState"),i=$e("scrollContainerState"),l=o||s?a:i,d=se("itemContent"),c=se("context"),p=se("groupContent"),u=se("trackItemSizes"),f=se("itemSize"),g=se("log"),y=$e("gap"),j=se("horizontalDirection"),{callbackRef:b}=nl(r,f,u,e?$t:l,g,y,o,j,se("skipAnimationFrameInResizeObserver")),[v,h]=q.useState(0);_n("deviation",F=>{v!==F&&h(F)});const k=se("EmptyPlaceholder"),N=se("ScrollSeekPlaceholder")||Bl,I=se("ListComponent"),E=se("ItemComponent"),x=se("GroupComponent"),w=se("computeItemKey"),S=se("isSeeking"),T=se("groupIndices").length>0,C=se("alignToBottom"),A=se("initialItemFinalLocationReached"),R=e?{}:{boxSizing:"border-box",...j?{display:"inline-block",height:"100%",marginLeft:v!==0?v:C?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:v!==0?v:C?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...A?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&k?n.jsx(k,{...De(k,c)}):n.jsx(I,{...De(I,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:b,style:R,children:(e?t.topItems:t.items).map(F=>{const $=F.originalIndex,M=w($+t.firstItemIndex,F.data,c);return S?m.createElement(N,{...De(N,c),height:F.size,index:F.index,key:M,type:F.type||"item",...F.type==="group"?{}:{groupIndex:F.groupIndex}}):F.type==="group"?m.createElement(x,{...De(x,c),"data-index":$,"data-item-index":F.index,"data-known-size":F.size,key:M,style:zl},p(F.index,c)):m.createElement(E,{...De(E,c),...Ul(E,F.data),"data-index":$,"data-item-group-index":F.groupIndex,"data-item-index":F.index,"data-known-size":F.size,key:M,style:j?Wl:Ao},T?d(F.index,F.groupIndex,F.data,c):d(F.index,F.data,c))})})}),$l={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Vl={outline:"none",overflowX:"auto",position:"relative"},Pr=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Gl={position:Dn(),top:0,width:"100%",zIndex:1};function De(e,t){if(typeof e!="string")return{context:t}}function Ul(e,t){return{item:typeof e=="string"?void 0:t}}const Kl=q.memo(function(){const e=se("HeaderComponent"),t=$e("headerHeight"),r=se("HeaderFooterTag"),s=_t(q.useMemo(()=>a=>{t(vt(a,"height"))},[t]),!0,se("skipAnimationFrameInResizeObserver")),o=se("context");return e?n.jsx(r,{ref:s,children:n.jsx(e,{...De(e,o)})}):null}),ql=q.memo(function(){const e=se("FooterComponent"),t=$e("footerHeight"),r=se("HeaderFooterTag"),s=_t(q.useMemo(()=>a=>{t(vt(a,"height"))},[t]),!0,se("skipAnimationFrameInResizeObserver")),o=se("context");return e?n.jsx(r,{ref:s,children:n.jsx(e,{...De(e,o)})}):null});function Ro({useEmitter:e,useEmitterValue:t,usePublisher:r}){return q.memo(function({children:s,style:o,context:a,...i}){const l=r("scrollContainerState"),d=t("ScrollerComponent"),c=r("smoothScrollTargetReached"),p=t("scrollerRef"),u=t("horizontalDirection")||!1,{scrollByCallback:f,scrollerRef:g,scrollToCallback:y}=Eo(l,c,d,p,void 0,u);return e("scrollTo",y),e("scrollBy",f),n.jsx(d,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:g,style:{...u?Vl:$l,...o},tabIndex:0,...i,...De(d,a),children:s})})}function Do({useEmitter:e,useEmitterValue:t,usePublisher:r}){return q.memo(function({children:s,style:o,context:a,...i}){const l=r("windowScrollContainerState"),d=t("ScrollerComponent"),c=r("smoothScrollTargetReached"),p=t("totalListHeight"),u=t("deviation"),f=t("customScrollParent"),g=q.useRef(null),y=t("scrollerRef"),{scrollByCallback:j,scrollerRef:b,scrollToCallback:v}=Eo(l,c,d,y,f);return To(()=>{var h;return b.current=f||((h=g.current)==null?void 0:h.ownerDocument.defaultView),()=>{b.current=null}},[b,f]),e("windowScrollTo",v),e("scrollBy",j),n.jsx(d,{ref:g,"data-virtuoso-scroller":!0,style:{position:"relative",...o,...p!==0?{height:p+u}:{}},...i,...De(d,a),children:s})})}const Zl=({children:e})=>{const t=q.useContext(So),r=$e("viewportHeight"),s=$e("fixedItemHeight"),o=se("alignToBottom"),a=se("horizontalDirection"),i=q.useMemo(()=>ro(r,d=>vt(d,a?"width":"height")),[r,a]),l=_t(i,!0,se("skipAnimationFrameInResizeObserver"));return q.useEffect(()=>{t&&(r(t.viewportHeight),s(t.itemHeight))},[t,r,s]),n.jsx("div",{"data-viewport-type":"element",ref:l,style:Pr(o),children:e})},Yl=({children:e})=>{const t=q.useContext(So),r=$e("windowViewportRect"),s=$e("fixedItemHeight"),o=se("customScrollParent"),a=so(r,o,se("skipAnimationFrameInResizeObserver")),i=se("alignToBottom");return q.useEffect(()=>{t&&(s(t.itemHeight),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,r,s]),n.jsx("div",{"data-viewport-type":"window",ref:a,style:Pr(i),children:e})},Xl=({children:e})=>{const t=se("TopItemListComponent")||"div",r=se("headerHeight"),s={...Gl,marginTop:`${r}px`},o=se("context");return n.jsx(t,{style:s,...De(t,o),children:e})},Jl=q.memo(function(e){const t=se("useWindowScroll"),r=se("topItemsIndexes").length>0,s=se("customScrollParent"),o=se("context");return n.jsxs(s||t?tc:ec,{...e,context:o,children:[r&&n.jsx(Xl,{children:n.jsx(ns,{showTopList:!0})}),n.jsxs(s||t?Yl:Zl,{children:[n.jsx(Kl,{}),n.jsx(ns,{}),n.jsx(ql,{})]})]})}),{Component:Ql,useEmitter:_n,useEmitterValue:se,usePublisher:$e}=Io(Pl,{required:{},optional:{restoreStateFrom:"restoreStateFrom",context:"context",followOutput:"followOutput",scrollIntoViewOnChange:"scrollIntoViewOnChange",itemContent:"itemContent",groupContent:"groupContent",overscan:"overscan",increaseViewportBy:"increaseViewportBy",minOverscanItemCount:"minOverscanItemCount",totalCount:"totalCount",groupCounts:"groupCounts",topItemCount:"topItemCount",firstItemIndex:"firstItemIndex",initialTopMostItemIndex:"initialTopMostItemIndex",components:"components",atBottomThreshold:"atBottomThreshold",atTopThreshold:"atTopThreshold",computeItemKey:"computeItemKey",defaultItemHeight:"defaultItemHeight",fixedGroupHeight:"fixedGroupHeight",fixedItemHeight:"fixedItemHeight",heightEstimates:"heightEstimates",itemSize:"itemSize",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"HeaderFooterTag",data:"data",initialItemCount:"initialItemCount",initialScrollTop:"initialScrollTop",alignToBottom:"alignToBottom",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",horizontalDirection:"horizontalDirection",skipAnimationFrameInResizeObserver:"skipAnimationFrameInResizeObserver"},methods:{scrollToIndex:"scrollToIndex",scrollIntoView:"scrollIntoView",scrollTo:"scrollTo",scrollBy:"scrollBy",autoscrollToBottom:"autoscrollToBottom",getState:"getState"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",totalListHeightChanged:"totalListHeightChanged",itemsRendered:"itemsRendered",groupIndices:"groupIndices"}},Jl),ec=Ro({useEmitter:_n,useEmitterValue:se,usePublisher:$e}),tc=Do({useEmitter:_n,useEmitterValue:se,usePublisher:$e}),rc=Ql,nc=me(()=>{const e=z(c=>n.jsxs("td",{children:["Item $",c]})),t=z(null),r=z(c=>n.jsxs("td",{colSpan:1e3,children:["Group ",c]})),s=z(null),o=z(null),a=z({}),i=z(Mn),l=z($t),d=(c,p=null)=>Me(O(a,U(u=>u[c]),Ne()),p);return{components:a,computeItemKey:i,context:t,EmptyPlaceholder:d("EmptyPlaceholder"),FillerRow:d("FillerRow"),fixedFooterContent:o,fixedHeaderContent:s,itemContent:e,groupContent:r,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder"),TableBodyComponent:d("TableBody","tbody"),TableComponent:d("Table","table"),TableFooterComponent:d("TableFoot","tfoot"),TableHeadComponent:d("TableHead","thead"),TableRowComponent:d("TableRow","tr"),GroupComponent:d("Group","tr")}});je(ko,nc);Dn();const ss={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},sc={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:os,floor:Ar,max:Zt,min:Yr,round:as}=Math;function is(e,t,r){return Array.from({length:t-e+1}).map((s,o)=>({data:r===null?null:r[o+e],index:o+e}))}function oc(e){return{...sc,items:e}}function xr(e,t){return e&&e.width===t.width&&e.height===t.height}function ac(e,t){return e&&e.column===t.column&&e.row===t.row}const ic=me(([{increaseViewportBy:e,listBoundary:t,overscan:r,visibleRange:s},{footerHeight:o,headerHeight:a,scrollBy:i,scrollContainerState:l,scrollTo:d,scrollTop:c,smoothScrollTargetReached:p,viewportHeight:u},f,g,{didMount:y,propsReady:j},{customScrollParent:b,useWindowScroll:v,windowScrollContainerState:h,windowScrollTo:k,windowViewportRect:N},I])=>{const E=z(0),x=z(0),w=z(ss),S=z({height:0,width:0}),T=z({height:0,width:0}),C=ce(),A=ce(),R=z(0),F=z(null),$=z({column:0,row:0}),M=ce(),D=ce(),P=z(!1),K=z(0),B=z(!0),_=z(!1),W=z(!1);he(O(y,ie(K),ne(([H,Y])=>!!Y)),()=>{oe(B,!1)}),he(O(Te(y,B,T,S,K,_),ne(([H,Y,X,ge,,Ae])=>H&&!Y&&X.height!==0&&ge.height!==0&&!Ae)),([,,,,H])=>{oe(_,!0),Tn(1,()=>{oe(C,H)}),Ue(O(c),()=>{oe(t,[0,0]),oe(B,!0)})}),Z(O(D,ne(H=>H!=null&&H.scrollTop>0),Je(0)),x),he(O(y,ie(D),ne(([,H])=>H!=null)),([,H])=>{H&&(oe(S,H.viewport),oe(T,H.item),oe($,H.gap),H.scrollTop>0&&(oe(P,!0),Ue(O(c,Dt(1)),Y=>{oe(P,!1)}),oe(d,{top:H.scrollTop})))}),Z(O(S,U(({height:H})=>H)),u),Z(O(Te(re(S,xr),re(T,xr),re($,(H,Y)=>H&&H.column===Y.column&&H.row===Y.row),re(c)),U(([H,Y,X,ge])=>({gap:X,item:Y,scrollTop:ge,viewport:H}))),M),Z(O(Te(re(E),s,re($,ac),re(T,xr),re(S,xr),re(F),re(x),re(P),re(B),re(K)),ne(([,,,,,,,H])=>!H),U(([H,[Y,X],ge,Ae,ee,ae,ve,,be,le])=>{const{column:ue,row:Se}=ge,{height:Ce,width:jt}=Ae,{width:ft}=ee;if(ve===0&&(H===0||ft===0))return ss;if(jt===0){const It=En(le,H),mt=It+Math.max(ve-1,0);return oc(is(It,mt,ae))}const Q=Mo(ft,jt,ue);let pe,we;be?Y===0&&X===0&&ve>0?(pe=0,we=ve-1):(pe=Q*Ar((Y+Se)/(Ce+Se)),we=Q*os((X+Se)/(Ce+Se))-1,we=Yr(H-1,Zt(we,Q-1)),pe=Yr(we,Zt(0,pe))):(pe=0,we=-1);const Re=is(pe,we,ae),{bottom:Ge,top:Ye}=ls(ee,ge,Ae,Re),kt=os(H/Q),ur=kt*Ce+(kt-1)*Se-Ge;return{bottom:Ge,itemHeight:Ce,items:Re,itemWidth:jt,offsetBottom:ur,offsetTop:Ye,top:Ye}})),w),Z(O(F,ne(H=>H!==null),U(H=>H.length)),E),Z(O(Te(S,T,w,$),ne(([H,Y,{items:X}])=>X.length>0&&Y.height!==0&&H.height!==0),U(([H,Y,{items:X},ge])=>{const{bottom:Ae,top:ee}=ls(H,ge,Y,X);return[ee,Ae]}),Ne(Jt)),t);const L=z(!1);Z(O(c,ie(L),U(([H,Y])=>Y||H!==0)),L);const G=ze(O(Te(w,E),ne(([{items:H}])=>H.length>0),ie(L),ne(([[H,Y],X])=>{const ge=H.items[H.items.length-1].index===Y-1;return(X||H.bottom>0&&H.itemHeight>0&&H.offsetBottom===0&&H.items.length===Y)&&ge}),U(([[,H]])=>H-1),Ne())),V=ze(O(re(w),ne(({items:H})=>H.length>0&&H[0].index===0),Je(0),Ne())),J=ze(O(re(w),ie(P),ne(([{items:H},Y])=>H.length>0&&!Y),U(([{items:H}])=>({endIndex:H[H.length-1].index,startIndex:H[0].index})),Ne(uo),lt(0)));Z(J,g.scrollSeekRangeChanged),Z(O(C,ie(S,T,E,$),U(([H,Y,X,ge,Ae])=>{const ee=go(H),{align:ae,behavior:ve,offset:be}=ee;let le=ee.index;le==="LAST"&&(le=ge-1),le=Zt(0,le,Yr(ge-1,le));let ue=pn(Y,Ae,X,le);return ae==="end"?ue=as(ue-Y.height+X.height):ae==="center"&&(ue=as(ue-Y.height/2+X.height/2)),be&&(ue+=be),{behavior:ve,top:ue}})),d);const de=Me(O(w,U(H=>H.offsetBottom+H.bottom)),0);return Z(O(N,U(H=>({height:H.visibleHeight,width:H.visibleWidth}))),S),{customScrollParent:b,data:F,deviation:R,footerHeight:o,gap:$,headerHeight:a,increaseViewportBy:e,initialItemCount:x,itemDimensions:T,overscan:r,restoreStateFrom:D,scrollBy:i,scrollContainerState:l,scrollHeight:A,scrollTo:d,scrollToIndex:C,scrollTop:c,smoothScrollTargetReached:p,totalCount:E,useWindowScroll:v,viewportDimensions:S,windowScrollContainerState:h,windowScrollTo:k,windowViewportRect:N,...g,gridState:w,horizontalDirection:W,initialTopMostItemIndex:K,totalListHeight:de,...f,endReached:G,propsReady:j,rangeChanged:J,startReached:V,stateChanged:M,stateRestoreInProgress:P,...I}},je(An,Oe,cr,No,Nt,Rn,wt));function Mo(e,t,r){return Zt(1,Ar((e+r)/(Ar(t)+r)))}function ls(e,t,r,s){const{height:o}=r;if(o===void 0||s.length===0)return{bottom:0,top:0};const a=pn(e,t,r,s[0].index);return{bottom:pn(e,t,r,s[s.length-1].index)+o,top:a}}function pn(e,t,r,s){const o=Mo(e.width,r.width,t.column),a=Ar(s/o),i=a*r.height+Zt(0,a-1)*t.row;return i>0?i+t.row:i}const lc=me(()=>{const e=z(u=>`Item ${u}`),t=z({}),r=z(null),s=z("virtuoso-grid-item"),o=z("virtuoso-grid-list"),a=z(Mn),i=z("div"),l=z($t),d=(u,f=null)=>Me(O(t,U(g=>g[u]),Ne()),f),c=z(!1),p=z(!1);return Z(re(p),c),{components:t,computeItemKey:a,context:r,FooterComponent:d("Footer"),HeaderComponent:d("Header"),headerFooterTag:i,itemClassName:s,ItemComponent:d("Item","div"),itemContent:e,listClassName:o,ListComponent:d("List","div"),readyStateChanged:c,reportReadyState:p,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}),cc=me(([e,t])=>({...e,...t}),je(ic,lc)),dc=q.memo(function(){const e=ke("gridState"),t=ke("listClassName"),r=ke("itemClassName"),s=ke("itemContent"),o=ke("computeItemKey"),a=ke("isSeeking"),i=Ve("scrollHeight"),l=ke("ItemComponent"),d=ke("ListComponent"),c=ke("ScrollSeekPlaceholder"),p=ke("context"),u=Ve("itemDimensions"),f=Ve("gap"),g=ke("log"),y=ke("stateRestoreInProgress"),j=Ve("reportReadyState"),b=_t(q.useMemo(()=>v=>{const h=v.parentElement.parentElement.scrollHeight;i(h);const k=v.firstChild;if(k){const{height:N,width:I}=k.getBoundingClientRect();u({height:N,width:I})}f({column:cs("column-gap",getComputedStyle(v).columnGap,g),row:cs("row-gap",getComputedStyle(v).rowGap,g)})},[i,u,f,g]),!0,!1);return To(()=>{e.itemHeight>0&&e.itemWidth>0&&j(!0)},[e]),y?null:n.jsx(d,{className:t,ref:b,...De(d,p),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(v=>{const h=o(v.index,v.data,p);return a?n.jsx(c,{...De(c,p),height:e.itemHeight,index:v.index,width:e.itemWidth},h):m.createElement(l,{...De(l,p),className:r,"data-index":v.index,key:h},s(v.index,v.data,p))})})}),uc=q.memo(function(){const e=ke("HeaderComponent"),t=Ve("headerHeight"),r=ke("headerFooterTag"),s=_t(q.useMemo(()=>a=>{t(vt(a,"height"))},[t]),!0,!1),o=ke("context");return e?n.jsx(r,{ref:s,children:n.jsx(e,{...De(e,o)})}):null}),fc=q.memo(function(){const e=ke("FooterComponent"),t=Ve("footerHeight"),r=ke("headerFooterTag"),s=_t(q.useMemo(()=>a=>{t(vt(a,"height"))},[t]),!0,!1),o=ke("context");return e?n.jsx(r,{ref:s,children:n.jsx(e,{...De(e,o)})}):null}),mc=({children:e})=>{const t=q.useContext(Co),r=Ve("itemDimensions"),s=Ve("viewportDimensions"),o=_t(q.useMemo(()=>a=>{s(a.getBoundingClientRect())},[s]),!0,!1);return q.useEffect(()=>{t&&(s({height:t.viewportHeight,width:t.viewportWidth}),r({height:t.itemHeight,width:t.itemWidth}))},[t,s,r]),n.jsx("div",{ref:o,style:Pr(!1),children:e})},pc=({children:e})=>{const t=q.useContext(Co),r=Ve("windowViewportRect"),s=Ve("itemDimensions"),o=ke("customScrollParent"),a=so(r,o,!1);return q.useEffect(()=>{t&&(s({height:t.itemHeight,width:t.itemWidth}),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,r,s]),n.jsx("div",{ref:a,style:Pr(!1),children:e})},hc=q.memo(function({...e}){const t=ke("useWindowScroll"),r=ke("customScrollParent"),s=r||t?xc:gc,o=r||t?pc:mc,a=ke("context");return n.jsx(s,{...e,...De(s,a),children:n.jsxs(o,{children:[n.jsx(uc,{}),n.jsx(dc,{}),n.jsx(fc,{})]})})}),{useEmitter:_o,useEmitterValue:ke,usePublisher:Ve}=Io(cc,{optional:{context:"context",totalCount:"totalCount",overscan:"overscan",itemContent:"itemContent",components:"components",computeItemKey:"computeItemKey",data:"data",initialItemCount:"initialItemCount",scrollSeekConfiguration:"scrollSeekConfiguration",headerFooterTag:"headerFooterTag",listClassName:"listClassName",itemClassName:"itemClassName",useWindowScroll:"useWindowScroll",customScrollParent:"customScrollParent",scrollerRef:"scrollerRef",logLevel:"logLevel",restoreStateFrom:"restoreStateFrom",initialTopMostItemIndex:"initialTopMostItemIndex",increaseViewportBy:"increaseViewportBy"},methods:{scrollTo:"scrollTo",scrollBy:"scrollBy",scrollToIndex:"scrollToIndex"},events:{isScrolling:"isScrolling",endReached:"endReached",startReached:"startReached",rangeChanged:"rangeChanged",atBottomStateChange:"atBottomStateChange",atTopStateChange:"atTopStateChange",stateChanged:"stateChanged",readyStateChanged:"readyStateChanged"}},hc),gc=Ro({useEmitter:_o,useEmitterValue:ke,usePublisher:Ve}),xc=Do({useEmitter:_o,useEmitterValue:ke,usePublisher:Ve});function cs(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,Pe.WARN),t==="normal"?0:parseInt(t??"0",10)}function nr(e){return e!=null&&typeof e=="object"&&"stack"in e&&typeof e.stack=="string"}function Rr({value:e}){const t=e.stack,r=typeof e.message=="string"?e.message:void 0,s=r?`${r}
27
-
28
- ${t}`:t;return n.jsxs("div",{className:"relative overflow-hidden rounded-md border",style:{borderColor:"var(--ds-red-400)",background:"var(--ds-red-100)"},children:[n.jsx("button",{type:"button","aria-label":"Copy error",title:"Copy",className:"!absolute !right-2 !top-2 !flex !h-6 !w-6 !items-center !justify-center !rounded-md !border transition-transform transition-colors duration-100 hover:!bg-[var(--ds-red-200)] active:!scale-95",style:{borderColor:"var(--ds-red-400)",background:"var(--ds-red-100)",color:"var(--ds-red-900)"},onClick:()=>{navigator.clipboard.writeText(s).then(()=>{fe.success("Copied to clipboard")}).catch(()=>{fe.error("Failed to copy")})},children:n.jsx(sr,{size:12})}),r&&n.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 pr-10",style:{color:"var(--ds-red-900)",borderBottom:"1px solid var(--ds-red-400)"},children:[n.jsx(kr,{className:"h-4 w-4 shrink-0",style:{marginTop:1}}),n.jsx("p",{className:"text-xs font-semibold m-0 break-words",children:r})]}),n.jsx("pre",{className:"px-3 py-2.5 text-xs font-mono whitespace-pre-wrap break-words overflow-auto m-0",style:{color:"var(--ds-red-900)",background:"var(--ds-red-200)"},children:t})]})}function vc({options:e,value:t,onChange:r}){var l,d;const[s,o]=m.useState(!1),a=m.useRef(null),i=((l=e.find(c=>c.value===t))==null?void 0:l.label)??((d=e[0])==null?void 0:d.label)??"";return m.useEffect(()=>{if(!s)return;function c(p){a.current&&!a.current.contains(p.target)&&o(!1)}return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[s]),n.jsxs("div",{ref:a,style:{position:"relative",flexShrink:0},children:[n.jsx("style",{children:`
29
- .wf-menu-btn{appearance:none;-webkit-appearance:none;border:none;display:inline-flex;align-items:center;justify-content:center;height:40px;padding:0 12px;border-radius:6px;font-size:14px;font-weight:500;line-height:20px;color:var(--ds-gray-1000);background:var(--ds-background-100);box-shadow:0 0 0 1px var(--ds-gray-400);cursor:pointer;white-space:nowrap;transition:background 150ms}
30
- .wf-menu-btn:hover{background:var(--ds-gray-alpha-200)}
31
- .wf-menu-item{appearance:none;-webkit-appearance:none;border:none;display:flex;align-items:center;width:100%;height:40px;padding:0 8px;border-radius:6px;font-size:14px;color:var(--ds-gray-1000);background:transparent;cursor:pointer;transition:background 150ms}
32
- .wf-menu-item:hover{background:var(--ds-gray-alpha-100)}
33
- `}),n.jsxs("button",{type:"button",className:"wf-menu-btn",onClick:()=>o(!s),children:[n.jsx("span",{children:i}),n.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",style:{marginLeft:16,marginRight:-4,color:"var(--ds-gray-900)"},children:n.jsx("path",{d:"M4.5 6L8 9.5L11.5 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),s&&n.jsx("div",{style:{position:"absolute",right:0,top:"100%",marginTop:4,minWidth:140,padding:4,borderRadius:12,background:"var(--ds-background-100)",boxShadow:"var(--ds-shadow-menu, var(--ds-shadow-medium))",zIndex:2001},role:"menu",children:e.map(c=>n.jsx("button",{type:"button",role:"menuitem",className:"wf-menu-item",style:{fontWeight:c.value===t?500:400},onClick:()=>{r(c.value),o(!1)},children:c.label},c.value))})]})}const yc=new Set(["step_failed","step_retrying","run_failed","workflow_failed"]),Lo={appearance:"none",WebkitAppearance:"none",border:"none",background:"transparent"},Oo="workflow-dot-pulse 1.25s cubic-bezier(0, 0, 0.2, 1) infinite";function bc(e){return e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})+"."+e.getMilliseconds().toString().padStart(3,"0")}function Ho(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function wc(e){return e==="step_failed"||e==="run_failed"||e==="workflow_failed"?"var(--ds-red-700)":e==="run_cancelled"||e==="step_retrying"?"var(--ds-amber-700)":e==="step_completed"||e==="run_completed"||e==="workflow_completed"||e==="hook_disposed"||e==="wait_completed"?"var(--ds-green-700)":e==="step_started"||e==="run_started"||e==="workflow_started"||e==="hook_received"?"var(--ds-blue-700)":"var(--ds-gray-600)"}function Nc(e,t){var o,a;const r=new Map;if(e){for(const i of e)if(i.eventType==="step_created"&&i.correlationId){const l=((o=i.eventData)==null?void 0:o.stepName)??"",d=or(String(l));r.set(i.correlationId,(d==null?void 0:d.shortName)??l)}}const s=t!=null&&t.workflowName?((a=xt(t.workflowName))==null?void 0:a.shortName)??t.workflowName:null;return{correlationNameMap:r,workflowName:s}}function jc(e){const t=new Map,r=new Map,s=new Map;for(const o of e){const a=new Date(o.createdAt).getTime(),i=o.correlationId??"__run__",l=o.eventType;if((l==="step_created"||l==="run_created")&&t.set(i,a),l==="step_started"||l==="run_started"||l==="workflow_started"){r.set(i,a),t.has(i)||t.set(i,a);const d=t.get(i),c=s.get(i)??{};d!==void 0&&(c.queued=a-d),s.set(i,c)}if(l==="step_completed"||l==="step_failed"||l==="run_completed"||l==="run_failed"||l==="run_cancelled"||l==="workflow_completed"||l==="workflow_failed"||l==="wait_completed"||l==="hook_disposed"){const d=r.get(i),c=s.get(i)??{};d!==void 0&&(c.ran=a-d),s.set(i,c)}}return s}function Dr(e){return e==="run_created"||e==="run_started"||e==="run_completed"||e==="run_failed"||e==="run_cancelled"||e==="workflow_started"||e==="workflow_completed"||e==="workflow_failed"}const hn=36,kc=20,Xr="var(--ds-gray-500)";function ds({isFirst:e,isLast:t,isRunLevel:r,statusDotColor:s,pulse:o=!1,hasSelection:a,showBranch:i,showLaneLine:l,isLaneStart:d,isLaneEnd:c,continuationOnly:p=!1}){const u=r?8:6,f=r?5:6,g=a&&!i&&!r?.3:1;return n.jsxs("div",{className:"relative flex-shrink-0 self-stretch",style:{width:hn,minHeight:p?0:void 0},children:[n.jsx("div",{style:{position:"absolute",left:8,top:p?0:e?"50%":0,bottom:p?0:t?"50%":0,width:2,backgroundColor:Xr,zIndex:0}}),!p&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{position:"absolute",left:f,top:"50%",transform:"translateY(-50%)",width:u,height:u,zIndex:2},children:[n.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:"var(--ds-background-100)",zIndex:0}}),o&&n.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:s,opacity:.75*g,animation:Oo,zIndex:1}}),n.jsx("div",{style:{position:"relative",width:"100%",height:"100%",borderRadius:"50%",backgroundColor:s,opacity:g,transition:"opacity 150ms",zIndex:2}})]}),i&&n.jsx("div",{style:{position:"absolute",left:9,top:"50%",width:hn-9,height:2,backgroundColor:Xr,zIndex:0}})]}),l&&n.jsx("div",{style:{position:"absolute",left:kc,top:p?0:d?"50%":0,bottom:p?0:c?"50%":0,width:2,backgroundColor:Xr,zIndex:0}})]})}function us({value:e,className:t,style:r}){const[s,o]=m.useState(!1),a=m.useRef(null);m.useEffect(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const i=m.useCallback(l=>{l.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{o(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{o(!1),a.current=null},1500)})},[e]);return n.jsxs("div",{className:`group/copy flex items-center gap-1 min-w-0 px-4 ${t??""}`,style:r,children:[n.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:e||"-"}),e?n.jsx("button",{type:"button",onClick:i,className:"flex-shrink-0 opacity-0 group-hover/copy:opacity-100 transition-opacity p-0.5 rounded hover:bg-[var(--ds-gray-alpha-200)]",style:Lo,"aria-label":`Copy ${e}`,children:s?n.jsx(Ws,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}):n.jsx(sr,{className:"h-3 w-3",style:{color:"var(--ds-gray-700)"}})}):null]})}function jr(e){if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")||t.startsWith('"')&&t.endsWith('"'))try{return jr(JSON.parse(t))}catch{return e}return e}if(Array.isArray(e))return e.map(jr);if(e!==null&&typeof e=="object"){if(e.constructor!==Object)return e;const t={};for(const[r,s]of Object.entries(e))t[r]=jr(s);return t}return e}function Ic(e,t){if(!t||!yc.has(t)||e==null||typeof e!="object")return null;const r=e;return nr(r.error)?r.error:nr(r)?r:null}function Sc({data:e,eventType:t}){const r=m.useMemo(()=>Ic(e,t),[e,t]),[s,o]=m.useState(!1),a=m.useRef(null),i=m.useMemo(()=>jr(e),[e]);m.useEffect(()=>()=>{a.current!==null&&window.clearTimeout(a.current)},[]);const l=m.useMemo(()=>{try{return JSON.stringify(i,null,2)}catch{return String(i)}},[i]),d=m.useCallback(c=>{c.stopPropagation(),navigator.clipboard.writeText(l).then(()=>{o(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{o(!1),a.current=null},1500)})},[l]);return r?n.jsx("div",{className:"p-2",children:n.jsx(Rr,{value:r})}):n.jsxs("div",{className:"relative group/payload",children:[n.jsx("div",{className:"overflow-x-auto p-2 text-[11px]",style:{color:"var(--ds-gray-1000)"},children:n.jsx(Cr,{data:i,expandLevel:2})}),n.jsx("button",{type:"button",onClick:d,className:"absolute bottom-2 right-2 opacity-0 group-hover/payload:opacity-100 transition-opacity flex items-center gap-1 px-2 py-1 rounded-md text-xs hover:bg-[var(--ds-gray-alpha-200)]",style:{...Lo,color:"var(--ds-gray-700)"},"aria-label":"Copy payload",children:s?n.jsxs(n.Fragment,{children:[n.jsx(Ws,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}),n.jsx("span",{style:{color:"var(--ds-green-700)"},children:"Copied"})]}):n.jsxs(n.Fragment,{children:[n.jsx(sr,{className:"h-3 w-3"}),n.jsx("span",{children:"Copy"})]})})]})}const Cc=[{value:"desc",label:"Newest"},{value:"asc",label:"Oldest"}];function Tc({event:e,index:t,isFirst:r,isLast:s,isExpanded:o,onToggleExpand:a,activeGroupKey:i,selectedGroupKey:l,selectedGroupRange:d,correlationNameMap:c,workflowName:p,durationMap:u,onSelectGroup:f,onHoverGroup:g,onLoadEventData:y,cachedEventData:j,onCacheEventData:b,encryptionKey:v}){const[h,k]=m.useState(!1),[N,I]=m.useState(j),[E,x]=m.useState(null),[w,S]=m.useState(j!==null),T=Dr(e.eventType)?"__run__":e.correlationId??void 0,C=wc(e.eventType),A=new Date(e.createdAt),R="eventData"in e&&e.eventData!=null,F=Dr(e.eventType),$=F?p??"-":e.correlationId?c.get(e.correlationId)??"-":"-",M=e.correlationId??(F?"__run__":""),D=M?u.get(M):void 0,P=i!==void 0,K=T!==void 0&&T===i,B=P&&!K,_=P&&K,W=P&&K&&!F,L=d!==null&&t>=d.first&&t<=d.last,G=d!==null&&t===d.first,V=d!==null&&t===d.last,J=m.useCallback(async()=>{if(!(N!==null||R)){k(!0),x(null);try{if(!y){x("Event details unavailable");return}const X=await y(e);X!=null&&(I(X),b(e.eventId,X))}catch(X){x(X instanceof Error?X.message:"Failed to load event details")}finally{k(!1),S(!0)}}},[e,N,R,y,b]);m.useEffect(()=>{o&&N===null&&!R&&!h&&!w&&J()},[]),m.useEffect(()=>{v&&w&&y&&(I(null),S(!1),y(e).then(X=>{X!=null&&(I(X),b(e.eventId,X)),S(!0)}).catch(()=>{S(!0)}))},[v]);const de=m.useCallback(()=>{f(T===l?void 0:T),a(e.eventId),!o&&N===null&&!R&&J()},[l,T,f,a,e.eventId,o,N,R,J]),H=R?e.eventData:N,Y=B?.3:1;return n.jsxs("div",{"data-event-id":e.eventId,onMouseEnter:()=>g(T),onMouseLeave:()=>g(void 0),children:[n.jsxs("div",{role:"button",tabIndex:0,onClick:de,onKeyDown:X=>{(X.key==="Enter"||X.key===" ")&&de()},className:"w-full text-left flex items-center gap-0 text-[13px] hover:bg-[var(--ds-gray-alpha-100)] transition-colors cursor-pointer",style:{minHeight:40},children:[n.jsx(ds,{isFirst:r,isLast:s&&!o,isRunLevel:F,statusDotColor:C,pulse:_,hasSelection:P,showBranch:W,showLaneLine:L,isLaneStart:G,isLaneEnd:V}),n.jsxs("div",{className:"flex items-center flex-1 min-w-0",style:{opacity:Y,transition:"opacity 150ms"},children:[n.jsx("div",{className:"flex items-center justify-center w-5 h-5 flex-shrink-0 rounded",style:{border:"1px solid var(--ds-gray-400)"},children:n.jsx(yn,{className:"h-3 w-3 transition-transform",style:{color:"var(--ds-gray-900)",transform:o?"rotate(90deg)":"rotate(0deg)"}})}),n.jsx("div",{className:"tabular-nums min-w-0 px-4",style:{color:"var(--ds-gray-900)",flex:"2 1 0%"},children:bc(A)}),n.jsx("div",{className:"font-medium min-w-0 px-4",style:{flex:"2 1 0%"},children:n.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--ds-gray-900)"},children:[n.jsxs("span",{style:{position:"relative",display:"inline-flex",width:6,height:6,flexShrink:0},children:[_&&n.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:C,opacity:.75,animation:Oo}}),n.jsx("span",{style:{position:"relative",width:6,height:6,borderRadius:"50%",backgroundColor:C}})]}),Ho(e.eventType)]})}),n.jsx("div",{className:"min-w-0 px-4 overflow-hidden text-ellipsis whitespace-nowrap",style:{flex:"2 1 0%"},title:$!=="-"?$:void 0,children:$}),n.jsx(us,{value:e.correlationId||"",className:"font-mono",style:{flex:"3 1 0%"}}),n.jsx(us,{value:e.eventId,className:"font-mono",style:{flex:"3 1 0%"}})]})]}),o&&n.jsxs("div",{className:"flex",children:[n.jsx(ds,{isFirst:!1,isLast:s,isRunLevel:F,hasSelection:P,showBranch:!1,showLaneLine:L&&!V,isLaneStart:!1,isLaneEnd:!1,continuationOnly:!0}),n.jsx("div",{className:"w-5 flex-shrink-0"}),n.jsxs("div",{className:"flex-1 my-1.5 mr-3 ml-2 py-2 rounded-md border overflow-hidden",style:{borderColor:"var(--ds-gray-alpha-200)",opacity:Y,transition:"opacity 150ms"},children:[((D==null?void 0:D.queued)!==void 0||(D==null?void 0:D.ran)!==void 0)&&n.jsxs("div",{className:"px-2 pb-1.5 text-xs flex gap-3",style:{color:"var(--ds-gray-900)"},children:[D.queued!==void 0&&D.queued>0&&n.jsxs("span",{children:["Queued for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:At(D.queued)})]}),D.ran!==void 0&&n.jsxs("span",{children:["Ran for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:At(D.ran)})]})]}),H!=null?n.jsx(Sc,{data:H,eventType:e.eventType}):E?n.jsx("div",{className:"rounded-md border p-3 text-xs",style:{borderColor:"var(--ds-red-400)",backgroundColor:"var(--ds-red-100)",color:"var(--ds-red-900)"},children:E}):h||!R&&!w&&e.correlationId?n.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[n.jsx(xe,{className:"h-3",style:{width:"75%"}}),n.jsx(xe,{className:"h-3",style:{width:"50%"}}),n.jsx(xe,{className:"h-3",style:{width:"60%"}})]}):n.jsx("div",{className:"p-2 text-xs",style:{color:"var(--ds-gray-900)"},children:"No data"})]})]})]})}function Ec({events:e,run:t,onLoadEventData:r,hasMoreEvents:s=!1,isLoadingMoreEvents:o=!1,onLoadMoreEvents:a,encryptionKey:i,isLoading:l=!1,sortOrder:d,onSortOrderChange:c}){const[p,u]=m.useState("asc"),f=d??p,g=m.useCallback(B=>{c?c(B):u(B)},[c]),y=m.useMemo(()=>{if(!e||e.length===0)return[];const B=f==="desc"?-1:1;return[...e].sort((_,W)=>B*(new Date(_.createdAt).getTime()-new Date(W.createdAt).getTime()))},[e,f]),{correlationNameMap:j,workflowName:b}=m.useMemo(()=>Nc(e??null,t??null),[e,t]),v=m.useMemo(()=>jc(y),[y]),[h,k]=m.useState(void 0),[N,I]=m.useState(void 0),E=m.useCallback(B=>{k(B)},[]),x=m.useCallback(B=>{I(B)},[]),w=h??N,[S,T]=m.useState(()=>new Set),C=m.useCallback(B=>{T(_=>{const W=new Set(_);return W.has(B)?W.delete(B):W.add(B),W})},[]),A=m.useRef(new Map),R=m.useCallback((B,_)=>{A.current.set(B,_)},[]),F=m.useMemo(()=>{const B=new Map;for(const _ of y){const W=Dr(_.eventType)?"__run__":_.correlationId??"";W&&B.set(_.eventId,W)}return B},[y]);m.useEffect(()=>{h!==void 0&&T(B=>{if(B.size===0)return B;let _=!1;const W=new Set;for(const L of B)F.get(L)===h?W.add(L):_=!0;return _?W:B})},[h,F]);const $=m.useMemo(()=>{if(!w||w==="__run__")return null;let B=-1,_=-1;for(let W=0;W<y.length;W++)y[W].correlationId===w&&(B===-1&&(B=W),_=W);return B>=0?{first:B,last:_}:null},[w,y]),[M,D]=m.useState(""),P=m.useRef(null),K=m.useMemo(()=>{const B=[];for(let _=0;_<y.length;_++){const W=y[_],L=Dr(W.eventType),G=L?b??"":W.correlationId?j.get(W.correlationId)??"":"";B.push({fields:[W.eventId,W.correlationId??"",W.eventType,Ho(W.eventType),G].map(V=>V.toLowerCase()),groupKey:W.correlationId??(L?"__run__":void 0),eventId:W.eventId,index:_})}return B},[y,j,b]);return m.useEffect(()=>{var L;const B=M.trim().toLowerCase();if(!B){k(void 0);return}let _=null,W=0;for(const G of K)for(const V of G.fields)if(V&&V.includes(B)){const J=B.length/V.length;J>W&&(W=J,_=G)}_&&(k(_.groupKey),(L=P.current)==null||L.scrollToIndex({index:_.index,align:"center",behavior:"smooth"}))},[M,K]),!e||e.length===0?l?n.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[n.jsx("div",{style:{padding:6},children:n.jsx(xe,{style:{height:40,borderRadius:6}})}),n.jsxs("div",{className:"flex items-center gap-0 h-10 border-b flex-shrink-0 px-4",style:{borderColor:"var(--ds-gray-alpha-200)"},children:[n.jsx(xe,{className:"h-3",style:{width:60}}),n.jsx("div",{style:{flex:1}}),n.jsx(xe,{className:"h-3",style:{width:80}}),n.jsx("div",{style:{flex:1}}),n.jsx(xe,{className:"h-3",style:{width:50}}),n.jsx("div",{style:{flex:1}}),n.jsx(xe,{className:"h-3",style:{width:90}}),n.jsx("div",{style:{flex:1}}),n.jsx(xe,{className:"h-3",style:{width:70}})]}),n.jsx("div",{className:"flex-1 overflow-hidden",children:Array.from({length:8},(B,_)=>n.jsxs("div",{className:"flex items-center gap-3 px-4",style:{height:40},children:[n.jsx(xe,{className:"h-2 w-2 flex-shrink-0",style:{borderRadius:"50%"}}),n.jsx(xe,{className:"h-3",style:{width:90}}),n.jsx(xe,{className:"h-3",style:{width:100}}),n.jsx(xe,{className:"h-3",style:{width:80}}),n.jsx(xe,{className:"h-3 flex-1"}),n.jsx(xe,{className:"h-3 flex-1"})]},_))})]}):n.jsx("div",{className:"flex items-center justify-center h-full text-sm",style:{color:"var(--ds-gray-700)"},children:"No events found"}):n.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[n.jsx("style",{children:"@keyframes workflow-dot-pulse{0%{transform:scale(1);opacity:.7}70%,100%{transform:scale(2.2);opacity:0}}"}),n.jsxs("div",{style:{padding:6,backgroundColor:"var(--ds-background-100)",display:"flex",gap:6},children:[n.jsxs("label",{style:{display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,boxShadow:"0 0 0 1px var(--ds-gray-alpha-400)",background:"var(--ds-background-100)",height:40,flex:1,minWidth:0},children:[n.jsx("div",{style:{width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ds-gray-800)",flexShrink:0},children:n.jsxs("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),n.jsx("path",{d:"M11.5 11.5L14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),n.jsx("input",{type:"search",placeholder:"Search by name, event type, or ID…",value:M,onChange:B=>D(B.target.value),style:{marginLeft:-16,paddingInline:12,fontFamily:"inherit",fontSize:14,background:"transparent",border:"none",outline:"none",height:40,width:"100%"}})]}),n.jsx(vc,{options:Cc,value:f,onChange:g})]}),n.jsxs("div",{className:"flex items-center gap-0 text-[13px] font-medium h-10 border-b flex-shrink-0",style:{borderColor:"var(--ds-gray-alpha-200)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:[n.jsx("div",{className:"flex-shrink-0",style:{width:hn}}),n.jsx("div",{className:"w-5 flex-shrink-0"}),n.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:"Time"}),n.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:"Event Type"}),n.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:"Name"}),n.jsx("div",{className:"min-w-0 px-4",style:{flex:"3 1 0%"},children:"Correlation ID"}),n.jsx("div",{className:"min-w-0 px-4",style:{flex:"3 1 0%"},children:"Event ID"})]}),n.jsx(rc,{ref:P,totalCount:y.length,overscan:20,defaultItemHeight:40,endReached:()=>{!s||o||a==null||a()},itemContent:B=>{const _=y[B];return n.jsx(Tc,{event:_,index:B,isFirst:B===0,isLast:B===y.length-1,isExpanded:S.has(_.eventId),onToggleExpand:C,activeGroupKey:w,selectedGroupKey:h,selectedGroupRange:$,correlationNameMap:j,workflowName:b,durationMap:v,onSelectGroup:E,onHoverGroup:x,onLoadEventData:r,cachedEventData:A.current.get(_.eventId)??null,onCacheEventData:R,encryptionKey:i})},components:{Footer:s?()=>n.jsx("div",{className:"px-3 pt-3 flex justify-center",children:n.jsx("button",{type:"button",onClick:()=>void(a==null?void 0:a()),disabled:o,className:"h-8 px-3 text-xs rounded-md border transition-colors disabled:opacity-60 disabled:cursor-not-allowed",style:{borderColor:"var(--ds-gray-alpha-400)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:o?"Loading more events...":"Load more"})}):void 0},style:{flex:1,minHeight:0}}),n.jsxs("div",{className:"flex-shrink-0 border-t text-xs px-3 py-2",style:{borderColor:"var(--ds-gray-alpha-200)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:[y.length," event",y.length!==1?"s":""," total"]})]})}function Ac({messages:e}){return e.length===0?n.jsx("div",{className:"text-center py-8 text-[11px]",style:{color:"var(--ds-gray-600)"},children:"No messages"}):n.jsx("div",{className:"flex flex-col gap-3 p-3",children:e.map((t,r)=>n.jsx(Rc,{message:t},r))})}function Rc({message:e}){const t=e.role,r=_c(e.content),s=Mc(t);return n.jsxs("div",{className:"rounded-md border text-[11px]",style:{backgroundColor:s.bg,borderColor:s.border},children:[n.jsx("div",{className:"px-2.5 py-1 border-b text-[10px] font-medium uppercase tracking-wide",style:{borderColor:s.border,color:s.label},children:t}),n.jsx("div",{className:"px-2.5 py-2 space-y-2",children:r.map((o,a)=>n.jsx(Dc,{part:o,role:t},a))})]})}function Dc({part:e,role:t}){return e.type==="text"?e.text?t==="assistant"?n.jsx("div",{className:"prose prose-sm max-w-none text-[11px] [&>*:first-child]:mt-0 [&>*:last-child]:mb-0",style:{color:"var(--ds-gray-1000)"},children:n.jsx(fi,{children:e.text})}):n.jsx("div",{className:"whitespace-pre-wrap break-words",style:{color:"var(--ds-gray-1000)"},children:e.text}):null:e.type==="tool-call"?n.jsxs("div",{className:"rounded border px-2 py-1.5",style:{backgroundColor:"var(--ds-purple-100)",borderColor:"var(--ds-purple-300)"},children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium",children:[n.jsx("span",{children:"🔧"}),n.jsx("span",{style:{color:"var(--ds-purple-900)"},children:e.toolName})]}),e.input!=null&&n.jsx("div",{className:"mt-1.5 overflow-x-auto p-1.5 rounded",style:{backgroundColor:"var(--ds-gray-100)"},children:typeof e.input=="string"?n.jsx("pre",{className:"text-[10px]",style:{color:"var(--ds-gray-800)"},children:e.input}):n.jsx(Cr,{data:e.input})})]}):e.type==="tool-result"?n.jsxs("div",{className:"rounded border px-2 py-1.5",style:{backgroundColor:"var(--ds-green-100)",borderColor:"var(--ds-green-300)"},children:[n.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium",children:[n.jsx("span",{children:"✓"}),n.jsxs("span",{style:{color:"var(--ds-green-900)"},children:[e.toolName," result"]})]}),e.output!=null&&n.jsx("div",{className:"mt-1.5 overflow-x-auto max-h-[200px] overflow-y-auto p-1.5 rounded",style:{backgroundColor:"var(--ds-gray-100)"},children:typeof e.output=="string"?n.jsx("pre",{className:"text-[10px]",style:{color:"var(--ds-gray-800)"},children:e.output}):n.jsx(Cr,{data:e.output,expandLevel:1})})]}):null}function Mc(e){switch(e){case"user":return{bg:"var(--ds-blue-100)",border:"var(--ds-blue-300)",label:"var(--ds-blue-700)"};case"assistant":return{bg:"var(--ds-gray-100)",border:"var(--ds-gray-300)",label:"var(--ds-gray-700)"};case"system":return{bg:"var(--ds-amber-100)",border:"var(--ds-amber-300)",label:"var(--ds-amber-700)"};case"tool":return{bg:"var(--ds-green-50)",border:"var(--ds-green-300)",label:"var(--ds-green-700)"};default:return{bg:"var(--ds-gray-100)",border:"var(--ds-gray-300)",label:"var(--ds-gray-700)"}}}function _c(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.map(t=>typeof t=="string"?{type:"text",text:t}:(t==null?void 0:t.type)==="text"?{type:"text",text:String(t.text??"")}:(t==null?void 0:t.type)==="tool-call"?{type:"tool-call",toolName:t.toolName,input:t.input}:(t==null?void 0:t.type)==="tool-result"?{type:"tool-result",toolName:t.toolName,output:t.output}:{type:"text",text:""}):[]}const Lc=e=>{if(typeof e=="string")return e;if(typeof e=="number"||typeof e=="boolean"||e===null)return String(e);try{return JSON.stringify(e,null,2)}catch{return String(e)}};function Fo({data:e}){return n.jsxs("div",{className:"relative overflow-x-auto rounded-md border p-3 pt-9",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("button",{type:"button","aria-label":"Copy data",title:"Copy",className:"!absolute !right-2 !top-2 !flex !h-6 !w-6 !items-center !justify-center !rounded-md !border !bg-[var(--ds-background-100)] !text-[var(--ds-gray-800)] transition-transform transition-colors duration-100 hover:!bg-[var(--ds-gray-alpha-200)] active:!scale-95 active:!bg-[var(--ds-gray-alpha-300)]",style:{borderColor:"var(--ds-gray-300)"},onClick:()=>{navigator.clipboard.writeText(Lc(e)).then(()=>{fe.success("Copied to clipboard")}).catch(()=>{fe.error("Failed to copy")})},children:n.jsx(sr,{size:12})}),n.jsx(Cr,{data:e})]})}function Le({summary:e,children:t,onToggle:r,disabled:s=!1,summaryClassName:o,contentClassName:a}){return s?n.jsx("div",{className:`rounded-md border px-2.5 py-1.5 text-xs ${o??""}`,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)",cursor:"not-allowed",opacity:.8},children:e}):n.jsxs("details",{className:"group",onToggle:i=>r==null?void 0:r(i.target.open),children:[n.jsx("summary",{className:`cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 [&::-webkit-details-marker]:hidden ${o??""}`,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-900)",listStyle:"none"},children:n.jsxs("span",{className:"flex items-center gap-1.5",children:[n.jsx(yn,{size:14,className:"shrink-0 transition-transform group-open:rotate-90"}),e]})}),n.jsxs("div",{className:`relative pl-6 mt-3 ${a??""}`,children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3",style:{backgroundColor:"var(--ds-gray-400)"}}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg",style:{borderColor:"var(--ds-gray-400)"}}),n.jsx("div",{className:"absolute left-6 top-3 w-0 h-px -translate-y-px",style:{backgroundColor:"var(--ds-gray-400)"}}),n.jsx("div",{children:t})]})]})}function Oc({active:e,onClick:t,children:r}){return n.jsx("button",{type:"button",role:"tab","aria-selected":e,tabIndex:e?0:-1,onClick:t,className:"px-3 py-1.5 text-[11px] font-medium transition-colors -mb-px",style:{backgroundColor:"transparent",borderTop:"none",borderLeft:"none",borderRight:"none",borderBottom:`2px solid ${e?"var(--ds-blue-600)":"transparent"}`,borderRadius:0,outline:"none",boxShadow:"none",cursor:"pointer",color:e?"var(--ds-gray-1000)":"var(--ds-gray-600)"},children:r})}function Hc({tabs:e,activeTab:t,onTabChange:r,ariaLabel:s,children:o}){const a=m.useCallback(i=>{if(i.key!=="ArrowRight"&&i.key!=="ArrowLeft")return;i.preventDefault();const l=e.findIndex(c=>c.id===t),d=i.key==="ArrowRight"?(l+1)%e.length:(l-1+e.length)%e.length;r(e[d].id)},[e,t,r]);return n.jsxs("div",{className:"rounded-md border",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:[n.jsx("div",{className:"flex gap-1 border-b",role:"tablist","aria-label":s,onKeyDown:a,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:e.map(i=>n.jsx(Oc,{active:t===i.id,onClick:()=>r(i.id),children:i.label},i.id))}),n.jsx("div",{role:"tabpanel",children:o})]})}const Fc=[{id:"conversation",label:"Conversation"},{id:"json",label:"Raw JSON"}];function Pc({conversation:e,args:t}){const[r,s]=m.useState("conversation");return n.jsx(Le,{summary:`Input (${e.length} messages)`,children:n.jsx(Hc,{tabs:Fc,activeTab:r,onTabChange:s,ariaLabel:"Conversation view",children:r==="conversation"?n.jsx(Ac,{messages:e}):n.jsx("div",{className:"p-3",children:Array.isArray(t)?t.map((o,a)=>n.jsx("div",{className:"mt-2 first:mt-0",children:He(o)},a)):He(t)})})})}function Vt(){return n.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border px-3 py-2 text-xs",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)"},children:[n.jsx(qs,{className:"h-3 w-3"}),n.jsx("span",{className:"font-medium",children:"Encrypted"})]})}function He(e){return n.jsx(Fo,{data:e})}const pt=e=>e==null?!1:typeof e=="string"?e.trim().length>0:Array.isArray(e)?e.length>0:typeof e=="object"?Object.keys(e).length>0:!0,fs=["workflowName","moduleSpecifier","stepName","status","stepId","hookId","eventId","runId","attempt","token","receivedCount","lastReceivedAt","disposedAt","correlationId","eventType","deploymentId","specVersion","workflowCoreVersion","ownerId","projectId","environment","executionContext","createdAt","startedAt","updatedAt","completedAt","expiredAt","retryAfter","error","metadata","eventData","input","output","resumeAt"],ms=(e,t)=>{const r=fs.indexOf(e)||0,s=fs.indexOf(t)||0;return r-s},Bc={workflowCoreVersion:"@workflow/core version",receivedCount:"times resolved"},zc=e=>Bc[e]??e,Wc=e=>{const t=String(e),r=or(t);if(r)return r.moduleSpecifier;const s=xt(t);return s?s.moduleSpecifier:t},Po=e=>{if(e==null)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e=="string"&&e.trim().length===0)return null;const t=typeof e=="number"?new Date(e):new Date(String(e));return Number.isNaN(t.getTime())?null:t},Bo=e=>e.toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}),$c=e=>{const t=Po(e);return t?Bo(t):"-"},ot=e=>{const t=Po(e);return t?Bo(t):null},Kt={workflowName:e=>{var t;return((t=xt(String(e)))==null?void 0:t.shortName)??"?"},moduleSpecifier:e=>Wc(e),stepName:e=>{var t;return((t=or(String(e)))==null?void 0:t.shortName)??"?"},runId:e=>String(e),stepId:e=>String(e),hookId:e=>String(e),eventId:e=>String(e),status:e=>String(e),attempt:e=>String(e),token:e=>String(e),isWebhook:e=>String(e),receivedCount:e=>String(e),lastReceivedAt:ot,disposedAt:ot,eventType:e=>String(e),correlationId:e=>String(e),deploymentId:e=>String(e),specVersion:e=>String(e),workflowCoreVersion:e=>String(e),ownerId:e=>null,projectId:e=>null,environment:e=>null,executionContext:e=>null,createdAt:ot,startedAt:ot,updatedAt:ot,completedAt:ot,expiredAt:ot,retryAfter:ot,resumeAt:ot,metadata:e=>pt(e)?at(e)?n.jsx(Vt,{}):He(e):null,input:(e,t)=>{if(at(e))return n.jsx(Vt,{});if(e&&typeof e=="object"&&"args"in e){const{args:o,closureVars:a,thisVal:i}=e,l=Array.isArray(o)?o.length:0,d=l===1?"argument":"arguments",c=pt(a),p=pt(i),u=pt(o);if(t!=null&&t.stepName&&pi(t.stepName)){const f=hi(o);if(f&&f.length>0)return n.jsxs(n.Fragment,{children:[n.jsx(Pc,{conversation:f,args:o}),c&&n.jsx(Le,{summary:"Closure Variables",children:He(a)}),p&&n.jsx(Le,{summary:"This Value",children:He(i)})]})}return!u&&!c&&!p?n.jsx(Le,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"}):n.jsxs(n.Fragment,{children:[n.jsx(Le,{summary:`Input (${l} ${d})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(o)?o.map((f,g)=>n.jsx("div",{className:"mt-2 first:mt-0",children:He(f)},g)):He(o)}),c&&n.jsx(Le,{summary:"Closure Variables",children:He(a)}),p&&n.jsx(Le,{summary:"this",children:He(i)})]})}const r=Array.isArray(e)?e.length:0,s=r===1?"argument":"arguments";return pt(e)?n.jsx(Le,{summary:`Input (${r} ${s})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(e)?e.map((o,a)=>n.jsx("div",{className:"mt-2 first:mt-0",children:He(o)},a)):He(e)}):n.jsx(Le,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"})},output:e=>pt(e)?at(e)?n.jsx(Vt,{}):n.jsx(Le,{summary:"Output",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:He(e)}):null,error:e=>at(e)?n.jsx(Vt,{}):pt(e)?nr(e)?n.jsx(Le,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:n.jsx(Rr,{value:e})}):n.jsx(Le,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:He(e)}):null,eventData:e=>at(e)?n.jsx(Vt,{}):pt(e)?n.jsx(Le,{summary:"Event Data",children:He(e)}):null},ps=["input","output","error","metadata","eventData"],Vc=()=>n.jsx("div",{className:"text-copy-12 rounded-md border p-4 my-2",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)"},children:n.jsx("span",{children:"The data for this run has expired and is no longer available."})}),Gc=({attribute:e,value:t,isLoading:r,inline:s=!1,context:o})=>{if(r&&(e==="input"||e==="output"||e==="eventData")){const d=e==="eventData"?"Event Data":e==="output"?"Output":"Input";return n.jsxs("div",{className:`my-2 flex flex-col ${e==="input"||e==="output"?"gap-2 my-3.5":"gap-0"}`,children:[n.jsx("span",{className:`${e==="input"||e==="output"?"text-base":"text-xs"} font-medium first-letter:uppercase`,style:{color:"var(--ds-gray-700)"},children:e}),n.jsx(Le,{summary:d,summaryClassName:"text-base py-2",disabled:!0}),n.jsxs("div",{className:"overflow-x-auto rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx(xe,{className:"h-4 w-[38%]"}),n.jsx(xe,{className:"mt-2 h-4 w-[88%]"}),n.jsx(xe,{className:"mt-2 h-4 w-[72%]"})]})]})}const i=Kt[e];if(!i)return null;const l=i(t,o);return l?s?n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--ds-gray-700)"},children:e}),n.jsx("span",{className:"text-[11px]",style:{color:"var(--ds-gray-1000)"},children:l})]}):n.jsxs("div",{className:"relative",children:[typeof r=="boolean"&&r&&n.jsx("div",{className:"absolute top-9 right-4",children:n.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2",style:{borderColor:"var(--ds-gray-900)"}})}),n.jsxs("div",{className:`my-2 flex flex-col ${e==="input"||e==="output"||e==="error"?"gap-2 my-3.5":"gap-0"}`,children:[n.jsx("span",{className:`${e==="input"||e==="output"||e==="error"?"text-base":"text-xs"} font-medium first-letter:uppercase`,style:{color:"var(--ds-gray-700)"},children:e}),n.jsx("span",{className:"text-xs",style:{color:"var(--ds-gray-1000)"},children:l})]},e)]}):null},Uc=({data:e,moduleSpecifier:t,isLoading:r,error:s,expiredAt:o,onStreamClick:a})=>{const i=m.useMemo(()=>{const y={...e},j=e.executionContext;return j!=null&&j.workflowCoreVersion&&(y.workflowCoreVersion=j.workflowCoreVersion),t?y.moduleSpecifier=t:typeof e.stepName=="string"?y.moduleSpecifier=e.stepName:typeof e.workflowName=="string"&&(y.moduleSpecifier=e.workflowName),y},[e,t]),l=o!=null&&new Date(o)<new Date,d=Object.keys(i).filter(y=>!ps.includes(y)).sort(ms),c=Object.keys(i).filter(y=>ps.includes(y)).sort(ms),p=d.filter(y=>{const j=Kt[y];return j?j(i[y])!==null:!1}),u=m.useMemo(()=>{const y=[...p],j=y.indexOf("moduleSpecifier");if(j===-1)return y;y.splice(j,1);const b=y.indexOf("workflowName");if(b!==-1)return y.splice(b+1,0,"moduleSpecifier"),y;const v=y.indexOf("stepName");return v!==-1?(y.splice(v+1,0,"moduleSpecifier"),y):(y.unshift("moduleSpecifier"),y)},[p]),f=m.useMemo(()=>({stepName:i.stepName}),[i.stepName]),g=m.useCallback(y=>{navigator.clipboard.writeText(y).then(()=>{fe.success("moduleSpecifier copied")}).catch(()=>{fe.error("Failed to copy moduleSpecifier")})},[]);return n.jsx(mi.Provider,{value:a,children:n.jsxs("div",{children:[p.length>0&&n.jsx("div",{className:"mb-3 flex flex-col overflow-hidden rounded-lg border",style:{borderColor:"var(--ds-gray-300)"},children:u.map((y,j)=>{var I;const b=(I=Kt[y])==null?void 0:I.call(Kt,i[y]),v=y==="moduleSpecifier",h=typeof b=="string"?b:String(b??i.moduleSpecifier??""),k=y!=="workflowCoreVersion",N=j<u.length-1;return n.jsxs("div",{className:"py-1",children:[n.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 rounded-sm px-2.5 py-1",children:[n.jsx("span",{className:k?"text-[14px] first-letter:uppercase":"text-[14px]",style:{color:"var(--ds-gray-700)"},children:zc(y)}),v?n.jsx("button",{type:"button",className:"min-w-0 max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)",background:"transparent",border:"none",padding:0},title:h,onClick:()=>g(h),children:h}):n.jsx("span",{className:"min-w-0 max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},children:b})]}),N?n.jsx("div",{className:"mx-2.5 border-b",style:{borderColor:"var(--ds-gray-300)"}}):null]},y)})}),s?n.jsx(Ra,{title:"Failed to load resource details",details:s.message,className:"my-4"}):l?n.jsx(Vc,{}):n.jsx(n.Fragment,{children:c.map(y=>n.jsx(Gc,{isLoading:r,attribute:y,value:i[y],context:f},y))})]})})},Kc=new Set(["step_failed","step_retrying"]),qc=new Set(["step_created","step_completed","step_failed","hook_created","hook_received","run_created","run_completed"]);function Zc({event:e,onLoadEventData:t,encryptionKey:r}){const[s,o]=m.useState(null),[a,i]=m.useState(!1),[l,d]=m.useState(null),c=m.useRef(!1),p="eventData"in e&&e.eventData!=null?e.eventData:null,u=p??s,f=qc.has(e.eventType),g=m.useCallback(async()=>{if(!(!t||!e.correlationId||!e.eventId))try{i(!0),d(null);const b=await t(e.correlationId,e.eventId);o(b)}catch(b){d(b instanceof Error?b.message:String(b))}finally{i(!1)}},[t,e.correlationId,e.eventId]),y=m.useCallback(async()=>{p||s!==null||a||(c.current=!0,await g())},[p,s,a,g]);m.useEffect(()=>{r&&c.current&&s!==null&&(o(null),g())},[r]);const j=new Date(e.createdAt);return n.jsxs(Le,{summaryClassName:"text-base py-2",summary:n.jsxs(n.Fragment,{children:[n.jsx("span",{className:"font-medium",style:{color:"var(--ds-gray-1000)"},children:e.eventType})," ","-"," ",n.jsx("span",{style:{color:"var(--ds-gray-700)"},children:$c(j.getTime())})]}),onToggle:f?b=>{b&&y()}:void 0,children:[n.jsxs("div",{className:"flex flex-col divide-y rounded-md border overflow-hidden",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:[n.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 px-2.5 py-1.5",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("span",{className:"text-[14px]",style:{color:"var(--ds-gray-700)"},children:"eventId"}),n.jsx("span",{className:"max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},title:e.eventId,children:e.eventId})]}),e.correlationId&&n.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 px-2.5 py-1.5",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx("span",{className:"text-[14px]",style:{color:"var(--ds-gray-700)"},children:"correlationId"}),n.jsx("span",{className:"max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},title:e.correlationId,children:e.correlationId})]})]}),a&&n.jsxs("div",{className:"mt-2 rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)"},children:[n.jsx(xe,{className:"h-4 w-[35%]"}),n.jsx(xe,{className:"mt-2 h-4 w-[90%]"}),n.jsx(xe,{className:"mt-2 h-4 w-[75%]"})]}),l&&n.jsx("div",{className:"mt-2 rounded-md border p-2 text-sm",style:{borderColor:"var(--ds-red-300)",color:"var(--ds-red-700)"},children:l}),u!=null&&n.jsx("div",{className:"mt-2",children:n.jsx(Yc,{eventType:e.eventType,data:u})})]})}function Yc({eventType:e,data:t}){if(Kc.has(e)&&t!=null&&typeof t=="object"){const r=t;if(nr(r.error))return n.jsx(Rr,{value:r.error});if(nr(r))return n.jsx(Rr,{value:r})}return n.jsx(Fo,{data:t})}function Xc({events:e,isLoading:t=!1,error:r,onLoadEventData:s,encryptionKey:o}){const a=m.useMemo(()=>[...e].sort((i,l)=>new Date(i.createdAt).getTime()-new Date(l.createdAt).getTime()),[e]);return n.jsxs("div",{className:"mt-2",style:{color:"var(--ds-gray-1000)"},children:[n.jsxs("h3",{className:"text-heading-16 font-medium mt-4 mb-2",style:{color:"var(--ds-gray-1000)"},children:["Events ",!t&&`(${a.length})`]}),t?n.jsxs("div",{className:"flex flex-col gap-3",children:[n.jsx(xe,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(xe,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(xe,{className:"h-[48px] w-full rounded-lg border"})]}):null,!t&&!r&&a.length===0&&n.jsx("div",{className:"text-sm",children:"No events found"}),a.length>0&&!r?n.jsx("div",{className:"flex flex-col gap-4",children:a.map(i=>n.jsx(Zc,{event:i,onLoadEventData:s,encryptionKey:o},i.eventId))}):null]})}function Jc(e){return e!==null&&typeof e=="object"&&"stepId"in e}function Qc(e){return e!==null&&typeof e=="object"&&"runId"in e}function vr(e){return e!==null&&typeof e=="object"&&"hookId"in e}function ed({run:e,onStreamClick:t,spanDetailData:r,spanDetailError:s,spanDetailLoading:o,onSpanSelect:a,onWakeUpSleep:i,onLoadEventData:l,onResolveHook:d,encryptionKey:c,onDecrypt:p,selectedSpan:u}){const[f,g]=m.useState(!1),[y,j]=m.useState(!1),[b,v]=m.useState(!1),[h,k]=m.useState(new Set),N=u==null?void 0:u.data,I=u==null?void 0:u.rawEvents,E=(I==null?void 0:I.length)??0,{resource:x,resourceId:w,runId:S}=m.useMemo(()=>{if(!u)return{resource:void 0,resourceId:void 0,runId:void 0};const L=u.resource;if(L==="step"&&Jc(N))return{resource:"step",resourceId:N.stepId,runId:N.runId};if(L==="run"&&Qc(N))return{resource:"run",resourceId:N.runId,runId:void 0};if(L==="hook"&&vr(N))return{resource:"hook",resourceId:N.hookId,runId:void 0};if(L==="sleep"){const G=N;return{resource:"sleep",resourceId:u.spanId,runId:G==null?void 0:G.runId}}return{resource:void 0,resourceId:void 0,runId:void 0}},[u,N]);m.useEffect(()=>{x&&w&&["run","step","hook","sleep"].includes(x)&&a({resource:x,resourceId:w,runId:S})},[x,w,S,a]);const T=m.useMemo(()=>x!=="sleep"||!I||["completed","failed","cancelled"].includes(e.status)||!I.some(J=>J.eventType==="wait_created")?!1:!I.some(J=>J.eventType==="wait_completed"),[x,I,E,e.status]),C=m.useMemo(()=>!(x!=="hook"||!I||!w||h.has(w)||["completed","failed","cancelled"].includes(e.status)||I.some(V=>V.eventType==="hook_disposed")),[x,w,I,E,e.status,h]),A=s??void 0,R=o??!1,F=m.useMemo(()=>{if(!r)return!1;const L=r;return at(L.input)||at(L.output)||at(L.error)||at(L.metadata)},[r]),$=m.useMemo(()=>{if(!(x!=="hook"||!w)){if(vr(r)&&r.token)return r.token;if(vr(N)&&N.token)return N.token}},[x,w,r,N]);m.useEffect(()=>{A&&u&&x&&fe.error(`Failed to load ${x} details`,{description:A.message})},[A,x,u]);const M=async()=>{if(!(f||!w)){if(!i){fe.error("Unable to wake up sleep",{description:"No wake-up handler provided."});return}try{g(!0),(await i(e.runId,w)).stoppedCount>0?fe.success("Run woken up",{description:"The sleep call has been interrupted and the run woken up."}):fe.info("Sleep already completed",{description:"This sleep call has already finished."})}catch(L){console.error("Failed to wake up run:",L),fe.error("Failed to wake up run",{description:L instanceof Error?L.message:"An unknown error occurred"})}finally{g(!1)}}},D=m.useCallback(async L=>{if(!b){if(!d){fe.error("Unable to resolve hook",{description:"No resolve handler provided."});return}if(!$){fe.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{v(!0);const G=r??N,V=vr(G)?G:void 0;await d($,L,V),fe.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),j(!1),w&&k(J=>new Set(J).add(w))}catch(G){console.error("Failed to resolve hook:",G),fe.error("Failed to resolve hook",{description:G instanceof Error?G.message:"An unknown error occurred"})}finally{v(!1)}}},[d,$,b,r,N]),P=r??N,K=m.useMemo(()=>{const L=P,G=L.stepName,V=L.workflowName;if(typeof G=="string")return G;if(typeof V=="string")return V;if(typeof e.workflowName=="string")return e.workflowName},[P,e.workflowName]);if(!u||!x||!w)return null;const B=x.charAt(0).toUpperCase()+x.slice(1),_=x==="sleep"&&T||x==="hook"&&C,W=e.completedAt?"Completed":"Live";return n.jsxs("div",{className:"flex h-full flex-col",children:[n.jsx("div",{className:"border-b px-3 py-3",style:{borderColor:"var(--ds-gray-200)"},children:n.jsxs("div",{className:"flex items-start justify-between gap-2",children:[n.jsxs("div",{className:"min-w-0",children:[n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"inline-flex items-center rounded-full border px-2 py-0.5 text-[13px] font-medium",style:{borderColor:"var(--ds-gray-300)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:B}),n.jsx("span",{className:"text-[13px]",style:{color:e.completedAt?"var(--ds-gray-700)":"var(--ds-green-800)"},children:W})]}),n.jsx("p",{className:"mt-1 truncate font-mono text-[13px]",style:{color:"var(--ds-gray-700)"},title:w,children:w})]}),(F||c)&&p&&n.jsxs("button",{type:"button",onClick:p,disabled:!!c,className:"inline-flex items-center gap-1 rounded-md border px-2 py-1 text-xs font-medium transition-colors flex-shrink-0",style:{borderColor:c?"var(--ds-green-400)":"var(--ds-gray-300)",color:c?"var(--ds-green-900)":"var(--ds-gray-900)",backgroundColor:c?"var(--ds-green-100)":"var(--ds-background-100)",cursor:c?"default":"pointer"},children:[c?n.jsx(Vi,{className:"h-3 w-3"}):n.jsx(qs,{className:"h-3 w-3"}),c?"Decrypted":"Decrypt"]})]})}),n.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pt-3 pb-8",children:[_&&n.jsxs("div",{className:"mb-4 rounded-lg border p-2",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:[n.jsx("p",{className:"mb-2 px-1 text-[13px] font-medium uppercase tracking-wide",style:{color:"var(--ds-gray-700)"},children:"Actions"}),n.jsxs("div",{className:"flex flex-col gap-2",children:[x==="sleep"&&T&&n.jsxs("button",{type:"button",onClick:M,disabled:f,className:Rt("flex items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium","disabled:opacity-50 disabled:cursor-not-allowed transition-colors",f?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-amber-200)",color:"var(--ds-amber-900)"},children:[n.jsx(Da,{className:"h-4 w-4"}),f?"Waking up...":"Wake Up Sleep"]}),x==="hook"&&C&&n.jsxs("button",{type:"button",onClick:()=>j(!0),disabled:b,className:Rt("flex items-center justify-center gap-2 rounded-md px-3 py-2 text-sm font-medium","disabled:opacity-50 disabled:cursor-not-allowed transition-colors",b?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-gray-1000)",color:"var(--ds-background-100)"},children:[n.jsx($s,{className:"h-4 w-4"}),"Resolve Hook"]})]})]}),n.jsxs("div",{className:"space-y-4",children:[n.jsxs("section",{children:[n.jsx("h3",{className:"mb-2 text-[13px] font-medium uppercase tracking-wide",style:{color:"var(--ds-gray-700)"},children:"Details"}),n.jsx(Uc,{data:P,moduleSpecifier:K,expiredAt:e.expiredAt,isLoading:R,error:A??void 0,onStreamClick:t})]}),x!=="run"&&I&&n.jsx("section",{children:n.jsx(Xc,{events:I,onLoadEventData:l,encryptionKey:c})})]})]}),n.jsx(Vs,{isOpen:y,onClose:()=>j(!1),onSubmit:D,isSubmitting:b})]})}function td(e){const t=m.useRef(e);t.current=e,m.useEffect(()=>{let r=0,s=0;const o=()=>{t.current(r),r=0},a=i=>{if(!i.ctrlKey&&!i.metaKey)return;i.preventDefault();let l=-i.deltaY;switch(i.deltaMode){case WheelEvent.DOM_DELTA_PAGE:l*=window.innerHeight;break;case WheelEvent.DOM_DELTA_LINE:l*=20;break}r+=l,cancelAnimationFrame(s),s=requestAnimationFrame(o)};return window.addEventListener("wheel",a,{passive:!1}),()=>{window.removeEventListener("wheel",a),cancelAnimationFrame(s)}},[])}function hs(e){if(e<=0)return 1;const r=10**Math.floor(Math.log10(e)),s=e/r;return s<=1.5?r:s<=3.5?2*r:s<=7.5?5*r:10*r}function rd({scale:e,isLive:t=!1}){const{state:{root:r}}=nt(),[,s]=m.useState(0);m.useEffect(()=>{if(!t)return;const f=setInterval(()=>s(g=>g+1),1e3);return()=>clearInterval(f)},[t]);const o=r.duration,a=e>0?e:o>0?1/o:1;let l=hs(50/a);l=Math.max(1,l);let d=l*a;const c=1e3;o/l>c&&(l=hs(o/c),d=l*a);const p=Math.ceil(o/l),u=Math.ceil(100/d)||1;return n.jsx("div",{className:te.markersContainer,children:n.jsx("div",{"aria-hidden":!0,className:te.markers,style:{width:Math.floor(r.duration*e+15),visibility:e!==-1?"visible":"hidden","--marker-width":`${d}px`},children:new Array(p).fill(null).map((f,g)=>{const y=g%u===0;return n.jsx("span",{className:Rt(te.marker,!y&&te.notch),children:y?n.jsxs("span",{className:te.markerLabel,children:[gi(l*g),n.jsx("span",{className:te.markerClockTime,children:xi(r.startTime+l*g)})]}):null},String(g))})})})}function nd({events:e,root:t,scale:r}){const s=m.useMemo(()=>e.filter(o=>o.event.showVerticalLine!==!1),[e]);return n.jsx("div",{className:te.eventMarkersContainer,children:n.jsx("div",{"aria-hidden":!0,className:te.eventMarkers,style:{width:Math.floor(t.duration*r)},children:s.map(o=>n.jsx("span",{className:Rt(te.eventMarker),style:{left:Math.floor((o.timestamp-t.startTime)*r),...o.event.color&&{borderLeftColor:o.event.color}}},o.key))})})}const gs=2;function sd({memoCacheRef:e,timelineRef:t,root:r,spans:s,events:o,scale:a,dispatch:i,scrollSnapshotRef:l}){const d=m.useRef(!1),c=m.useRef(s);c.current=s;const p=m.useRef(o);p.current=o;const u=m.useRef(null),{style:f,setStyle:g}=$r(u),y=m.useRef(null),j=m.useRef(null),{style:b,setStyle:v}=$r(j),h=m.useRef(void 0),k=m.useRef(null),{style:N,setStyle:I}=$r(k),E=m.useRef(0);m.useEffect(()=>{const w=t.current;if(!w)return;let S=E.current,T=0,C=!1,A=!1,R=!1,F=!1,$=0,M=0;const D=Date.now()+500,P=()=>{h.current||(h.current=w.getBoundingClientRect())},K=ee=>h.current?(ee-Tr-Fe)/(Ft+gt):0,B=()=>{const ee=e.current;for(const ae of c.current)ae.isHovered&&(ae.isHovered=!1,ee.set(ae.span.spanId,{}));i({type:"forceRender"})};let _=0;const W=()=>{var Ce,jt,ft,Q,pe,we,Re,Ge;if(!d.current)return;h.current||P();const ee=h.current;if(!ee)return;const{scrollLeft:ae,scrollTop:ve}=w,be=Math.max(0,Math.min(S+ae-ee.left-Fe,r.duration*a)),le=`${be-ae+Fe}px`;v("left",le),g("left",le);const ue=r.startTime+be/a,Se=ue-r.startTime;if(Se<0||Se>r.duration?(Ce=y.current)==null||Ce.removeAttribute("data-text"):(jt=y.current)==null||jt.setAttribute("data-text",hr(Se)),C){const Ye=S-T,kt=Math.abs(Ye);if(!R){if(kt<4)return;R=!0,I("display","flex"),B()}Ye>0?(I("left",""),I("right","0")):(I("left","0"),I("right","")),I("width",`${kt}px`);const It=Math.max(0,Math.min(T+ae-ee.left-Fe,r.duration*a))/a;let mt,St;It<Se?(mt=It,St=Se):(mt=Se,St=It),(ft=k.current)==null||ft.setAttribute("data-range",`${hr(mt)} — ${hr(St)}`),(Q=k.current)==null||Q.setAttribute("data-duration",`${hr(St-mt)} selected`)}if(Date.now()<D){_=requestAnimationFrame(W);return}if(ae!==$||ve!==M){$=ae,M=ve,_=requestAnimationFrame(W);return}if(S-ee.left<128?(pe=y.current)==null||pe.setAttribute("data-align","left"):S-ee.left>ee.width-128?(we=y.current)==null||we.setAttribute("data-align","right"):(Re=y.current)==null||Re.removeAttribute("data-align"),!R&&!A){const Ye=e.current,kt=K(ve)-gs,ur=K(ve+ee.height)+gs;for(const _e of c.current){const Xe=_e.row>=kt&&_e.row<=ur&&ue>=_e.startTime&&ue<=_e.endTime;_e.isHovered!==Xe&&(_e.isHovered=Xe,Ye.set(_e.span.spanId,{}))}const mt=12/a;let St=null,Pn=1/0;for(const _e of p.current){const Xe=Math.abs(_e.timestamp-ue);Xe<=mt&&Xe<Pn&&(Pn=Xe,St=_e)}for(const _e of p.current){const Xe=_e===St;if(_e.isHovered===Xe)continue;_e.isHovered=Xe;const Bn=(Ge=_e.ref)==null?void 0:Ge.current;Bn&&Bn.setAttribute("data-hovered",String(Xe))}i({type:"forceRender"})}};_=requestAnimationFrame(W);const L=ee=>{ee.pointerType==="mouse"&&(d.current=!0)},G=()=>{d.current&&(d.current=!1,B())},V=({clientX:ee})=>{S=ee,E.current=S,cancelAnimationFrame(_),_=requestAnimationFrame(W)},J=ee=>{ee.preventDefault()},de=ee=>{var ae;if(ee.button===2)F=!0,ee.preventDefault();else{if(ee.button!==0)return;F=!1}(ae=t.current)!=null&&ae.contains(ee.target)?(T=S,C=!0):(A=!0,requestAnimationFrame(B))},H=ee=>{if(A=!1,!C||(C=!1,!R))return;if(R=!1,I("display",""),I("left",""),I("right",""),I("width",""),ee.preventDefault(),ee.stopImmediatePropagation(),F){F=!1;return}h.current||P();const ae=h.current;if(!ae)return;const{scrollLeft:ve}=w,be=Math.max(0,Math.min((T+ve-ae.left-Fe)/a,r.duration)),le=Math.max(0,Math.min((S+ve-ae.left-Fe)/a,r.duration));i({type:"scaleToRange",t1:be+r.startTime,t2:le+r.startTime})},Y=ee=>{C&&ee.key==="Escape"&&(F=!0,H(ee))},X=()=>{h.current=void 0,x.current=void 0,cancelAnimationFrame(_),_=requestAnimationFrame(W)},ge=()=>{cancelAnimationFrame(_),_=requestAnimationFrame(W)},Ae=new ResizeObserver(()=>{h.current=void 0});return Ae.observe(w),window.addEventListener("mousemove",V),w.addEventListener("contextmenu",J),window.addEventListener("mousedown",de),window.addEventListener("mouseup",H),window.addEventListener("blur",H),window.addEventListener("keydown",Y,!0),window.addEventListener("scroll",X),w.addEventListener("scroll",ge),w.addEventListener("pointerenter",L),w.addEventListener("pointerleave",G),()=>{Ae.disconnect(),window.removeEventListener("mousemove",V),w.removeEventListener("contextmenu",J),window.removeEventListener("mousedown",de),window.removeEventListener("mouseup",H),window.removeEventListener("blur",H),window.removeEventListener("keydown",Y,!0),window.removeEventListener("scroll",X),w.removeEventListener("scroll",ge),w.removeEventListener("pointerenter",L),w.removeEventListener("pointerleave",G),cancelAnimationFrame(_),E.current=S,B()}},[i,r,a,v,g,I,e,t,l]);const x=m.useRef(void 0);return td(w=>{const S=t.current;if(!S)return;h.current??(h.current=S.getBoundingClientRect());const T=h.current,C=Math.max(0,Math.min(E.current-T.left-Fe,T.width-2*Fe));let A=0,R=x.current;(R==null?void 0:R.anchorX)===C?A=R.anchorT:(A=(S.scrollLeft+C)/a,R={anchorT:A,anchorX:C},x.current=R),i({type:"trackpadScale",delta:w/64,anchorT:A,anchorX:C})}),n.jsxs(n.Fragment,{children:[n.jsx("div",{className:te.cursorMarkerStickyParent,children:n.jsx("div",{className:te.cursorMarkerLabelContainer,ref:u,style:f,children:n.jsx("div",{className:te.cursorMarkerLabel,ref:y})})}),n.jsx("div",{className:te.cursorMarkerStickyParent,children:n.jsx("div",{className:te.cursorMarkerContainer,ref:j,style:b,children:n.jsx("div",{className:te.cursorMarker,children:n.jsx("div",{className:te.cursorSelection,ref:k,style:N})})})})]})}function od({height:e,width:t,value:r,placeholder:s,onChange:o}){return n.jsxs("label",{className:te.searchInputLabel,children:[n.jsx("div",{className:te.searchInputPrefix,children:n.jsx(ad,{})}),n.jsx("input",{type:"search",value:r,placeholder:s,onChange:o,style:{height:e,width:t}})]})}function ad(){return n.jsxs("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:[n.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),n.jsx("path",{d:"M11.5 11.5L14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function id(){return n.jsx("nav",{className:te.searchBar,children:n.jsx(ld,{})})}function ld(){const{dispatch:e}=nt(),[t,r]=m.useState("");return m.useEffect(()=>{const s=setTimeout(()=>e({type:"setFilter",filter:t}),100);return()=>{clearTimeout(s)}},[e,t]),n.jsx("div",{className:te.searchInput,children:n.jsx(od,{height:Zs,onChange:s=>r(s.target.value),placeholder:"Search spans…",value:t,width:"100%"})})}function cd({size:e=16}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[n.jsx("title",{children:"Zoom In"}),n.jsx("path",{d:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",stroke:"currentColor",strokeWidth:"2"}),n.jsx("path",{d:"M11 8v6M8 11h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),n.jsx("path",{d:"M20 20l-3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function dd({size:e=16}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[n.jsx("title",{children:"Zoom Out"}),n.jsx("path",{d:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",stroke:"currentColor",strokeWidth:"2"}),n.jsx("path",{d:"M8 11h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),n.jsx("path",{d:"M20 20l-3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function ud({size:e=16}){return n.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[n.jsx("title",{children:"Minus"}),n.jsx("path",{d:"M6 12h12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function fd(){const{dispatch:e}=nt(),t=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:1})},[e]),r=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:-1})},[e]),s=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:0})},[e]);return n.jsxs("div",{className:te.zoomButtonGroup,children:[n.jsx("button",{"aria-label":"Zoom Out",className:te.zoomButton,onClick:r,type:"button",children:n.jsx(dd,{size:18})}),n.jsx("div",{className:te.divider}),n.jsx("button",{"aria-label":"Reset Zoom",className:te.zoomButton,onClick:s,type:"button",children:n.jsx(ud,{size:18})}),n.jsx("div",{className:te.divider}),n.jsx("button",{"aria-label":"Zoom In",className:te.zoomButton,onClick:t,type:"button",children:n.jsx(cd,{size:18})})]})}const md=e=>{const{spans:t}=e,r={startTime:0,endTime:0,duration:0,depth:0,children:[]},s={},o=new Map,a=u=>{const f=o.get(u);if(f)return f;const g=o.size+1;return o.set(u,g),g};let i=!1;for(const u of t){const f=Ut(u.startTime),g=Ut(u.endTime),y=Ut(u.duration);g>r.endTime&&(r.endTime=g,r.duration=g-r.startTime),(r.startTime===0||f<r.startTime)&&(r.startTime=f,r.duration=r.endTime-f);const j=u.resource.startsWith("vercel.");j||(i=!0);const b=j&&(u.resource!=="vercel.serverless-runtime"||!("http.method"in u.attributes)),v=b?0:a(u.resource);let h;b&&(h=`▲ ${u.name}`),s[u.spanId]={parent:null,startTime:f,endTime:g,duration:y,span:u,depth:0,label:h,events:pd(u),isVercel:b,children:[],resourceIndex:v,activeStartTime:u.activeStartTime?Ut(u.activeStartTime):void 0}}const l=(u,f)=>{let g;f?(g=s[f],g||(g=r)):g=r,u.parent=g,g.children.push(u)},d=u=>{"parent"in u&&(u.depth=u.parent.depth+1);for(const f of u.children)d(f)};let c=1;const p=(u,f)=>{if("parent"in u&&u.span.name===f){let g=u.endTime;const y=E=>E.children.length?E.children.map(y).sort((x,w)=>x.duration-w.duration)[0]||E:E.span.name==="waitUntil"?(g=E.startTime,E.parent):E,j=y(u),b=`instrumentation-hint-${c++}`,v=u.duration*.05,h=u.startTime+v,k=Math.max(h+v,Math.min(g-u.duration*.01,u.endTime-v)),N=k-h,I={parent:j,startTime:h,endTime:k,duration:N,span:{spanId:b,name:"Add your spans here",resource:"",kind:0,library:{name:""},status:{code:200},traceFlags:0,attributes:{},links:[],events:[],startTime:Vr(h),endTime:Vr(k),duration:Vr(N)},depth:u.depth+1,isVercel:!1,isInstrumentationHint:!0,children:[],resourceIndex:1};return j.children.push(I),s[b]=I,!0}for(const g of u.children)if(p(g,f))return!0;return!1};for(const u of Object.values(s))l(u,u.span.parentSpanId);if(d(r),!i){for(const u of["Invoke Function","Invoke Middleware","Vercel Runtime"])if(p(r,u))break}return{root:r,map:s}},pd=e=>{if(!e.events.length)return;const t=`${e.spanId}:ev`;return e.events.map((r,s)=>({key:`${t}${s}`,timestamp:Ut(r.timestamp),event:r})).sort((r,s)=>r.timestamp-s.timestamp)},xs=(e,t)=>(e.isVisible=!0,e.isHovered=!1,e.isVisible);function Jr(){return[]}const hd=(e,t=!1)=>{const{state:r,dispatch:s}=nt(),{root:o,filter:a,scale:i,timelineRef:l,timelineWidth:d,spanMap:c,scrollSnapshotRef:p,selected:u,memoCacheRef:f}=r,g=gd(r.timelineHeight),y=m.useRef(0),[j,b]=m.useState(Jr),[v,h]=m.useState(Jr),[k,N]=m.useState(Jr),[I,E]=m.useState(-1),x=m.useRef(void 0);return m.useEffect(()=>{var w;return(w=x.current)==null?void 0:w.call(x,a)},[a]),m.useEffect(()=>{if(e!=null&&e.length){for(const w of j)for(const S of w){const T=e.includes(S.span.spanId);S.isHighlighted!==T&&(S.isHighlighted=T,f.current.set(S.span.spanId,{}))}s({type:"forceRender"})}},[j,e,s,f]),m.useEffect(()=>{if(!o.startTime)return;const w=new Worker(new URL("/assets/worker-D-HfgUMl.js",import.meta.url),{type:"module"});let S=++y.current;const T=A=>{var F;const R=A.data;switch(R.type){case"setRowsResult":{if((R==null?void 0:R.requestId)!==S)return;if(R.isEnd)for(const $ of R.rows)for(const M of $)M.span=((F=c[M.span.spanId])==null?void 0:F.span)??M.span;b(R.rows);break}case"updateHighlight":{if((R==null?void 0:R.requestId)!==S)return;const{matches:$}=R;b(M=>{for(const D of M)for(const P of D){const K=$.has(P.span.spanId);P.isHighlighted!==K&&(P.isHighlighted=K,f.current.set(P.span.spanId,{}))}return M}),s({type:"forceRender"});break}}};w.addEventListener("message",T);const C={requestId:S,type:"calculateSpanPositions",root:o};return w.postMessage(C),x.current=A=>{const R=A.trim().toLocaleLowerCase();if(!R){b($=>$.map(M=>M.map(D=>(D.isHighlighted=void 0,{...D}))));return}S=++y.current;const F={type:"filterSpans",requestId:S,root:o,filter:R};w.postMessage(F)},()=>{w.terminate()}},[o,c,s,f]),m.useEffect(()=>{if(!j.length)return;if(t){const V=[],J=[];for(const de of j)for(const H of de)xs(H)&&(V.push(H),H.events&&J.push(...H.events));h(V),N(J),E(i);return}const w=l.current;let S=p.current,T=!1,C=!1,A=0,R=0;const F=Math.max(500,d*.5),$=new Array(j.length).fill(null),M=()=>{C=!0;const V=Math.min(1+R+Math.ceil((S==null?void 0:S.endRow)??Number.POSITIVE_INFINITY),j.length);for(let J=V;J--;){if($[J])continue;const de=D(J);if(Math.abs(de)>R){if(C=!1,de>0)continue;break}const H=[],Y=j[J];if(Y){for(const X of Y){if(!xs(X))continue;const ge=P(X);A=Math.max(ge,A),H.push({d:ge,span:X})}$[J]=H}}},D=V=>S?V<S.startRow?V-S.startRow:V>S.endRow?V-S.endRow:0:0,P=V=>{if(!S)return 0;let J=0;V.endTime<S.startTime?J=S.startTime-V.endTime:V.startTime>S.endTime&&(J=V.startTime-S.endTime);const de=Math.abs(D(V.row));return!J&&!de?0:Math.sqrt((J/i)**2+(de*Ft+gt)**2)},K=()=>{if(!w)return;const{scrollLeft:V,scrollTop:J}=w,de=0,H=V/i,Y=(J-Tr-Fe)/(Ft+gt),X=Y+Math.ceil(g/(Ft+gt));S={anchorT:H,anchorX:de,scrollLeft:V,scrollTop:J,startTime:o.startTime+V/i,endTime:o.startTime+(V+d)/i,startRow:Y,endRow:X,scale:i},p.current=S;for(let ge=$.length;ge--;)$[ge]=null};let B=0;const _=()=>{(T||!S)&&(T=!1,K()),M();const V=[],J=[];for(const de of $)if(de)for(const{d:H,span:Y}of de)H>R||(V.push(Y),Y.events&&J.push(...Y.events));R<F&&(!C||R<A)&&(R=Math.min(F,R+100),B=requestAnimationFrame(_)),h(V),N(J),E(i)};_();let W=Date.now();const L=V=>{(V.ctrlKey||V.metaKey)&&(W=Date.now())};w==null||w.addEventListener("wheel",L);const G=()=>{Date.now()-W<=50||(T=!0,cancelAnimationFrame(B),B=requestAnimationFrame(_))};return w==null||w.addEventListener("scroll",G),()=>{cancelAnimationFrame(B),w==null||w.removeEventListener("wheel",L),w==null||w.removeEventListener("scroll",G)}},[j,o,i,p,l,d,g,t]),m.useEffect(()=>{var T;if(!u)return;let w;for(const C of v)if(C.span.spanId===u.span.spanId){w=C;break}const S=(T=w==null?void 0:w.ref)==null?void 0:T.current;if(!(!w||!S))return w.isSelected=!0,S.setAttribute("data-selected",""),()=>{w.isSelected=!1,S.removeAttribute("data-selected")}},[v,u]),{rows:j,spans:v,events:k,scale:I}};function gd(e){const[t,r]=m.useState(e);return m.useEffect(()=>{if(t===e)return;let s=0,o=0;const a=()=>{if(++s<=3){o=requestAnimationFrame(a);return}r(e)};return a(),()=>{cancelAnimationFrame(o)}},[t,e]),t}const vs={traceId:"skeleton",spans:[{parentSpanId:"",spanId:"root",name:"root span",kind:1,resource:"vercel.runtime",startTime:[5e3,0],endTime:[6e3,0],duration:[1e3,0],library:{name:"vercel-site"},status:{code:1},attributes:{"vercel.ownerId":"team_abc"},traceFlags:1,events:[],links:[]}],resources:[{name:"vercel.runtime",attributes:{}}],rootSpanId:"root"};function xd({trace:e=vs,className:t="",scrollLock:r=!1,height:s,withPanel:o=!1,highlightedSpans:a,eagerRender:i=!1,isLive:l=!1,footer:d,knownDurationMs:c,hasMoreData:p=!1}){const u=e===vs,{state:f,dispatch:g}=nt(),{timelineRef:y,scrollSnapshotRef:j}=f,b=f.memoCacheRef.current,v=((a==null?void 0:a.length)??0)>0,h=m.useRef(!1),k=m.useRef(""),N=m.useRef(null),I=m.useRef({}),E=m.useRef(null);m.useEffect(()=>{const{root:M,map:D}=md(e),P=!h.current;h.current=!0;const K=Object.keys(D).sort().map(B=>{const _=D[B].events,W=(_==null?void 0:_.length)??0,L=W?_==null?void 0:_[0]:void 0,G=W?_==null?void 0:_[W-1]:void 0,V=`${(L==null?void 0:L.event.name)??"none"}@${(L==null?void 0:L.timestamp)??0}|${(G==null?void 0:G.event.name)??"none"}@${(G==null?void 0:G.timestamp)??0}`;return`${B}:${W}:${V}`}).join(",");if(!P&&K===k.current&&N.current){const B=N.current,_=I.current;let W=!1;(B.endTime!==M.endTime||B.duration!==M.duration)&&(B.endTime=M.endTime,B.duration=M.duration,W=!0);for(const[L,G]of Object.entries(D)){const V=_[L];V&&((V.endTime!==G.endTime||V.duration!==G.duration)&&(V.endTime=G.endTime,V.duration=G.duration,W=!0),Object.assign(V.span,G.span))}if(!W)return;g({type:"forceRender"});return}k.current=K,N.current=M,I.current=D,g({type:P?"setRoot":"updateRoot",root:M,spanMap:D,resources:e.resources||[]})},[g,e]);const{rows:x,spans:w,events:S,scale:T}=hd(a,i),C=m.useRef(null);m.useLayoutEffect(()=>{const M=C.current;if(!M)return;const D=()=>{const K=2*Fe,B=M.getBoundingClientRect(),_=B.width-K,W=B.height,L=E.current;L&&L.width===_&&L.height===W||(E.current={width:_,height:W},g({type:"setSize",width:_,height:W}))};D();const P=new ResizeObserver(D);return P.observe(M),window.addEventListener("resize",D),()=>{P.disconnect(),window.removeEventListener("resize",D)}},[g]);const A=m.useRef({t:0,x:-1,y:-1,spanId:""}),R=m.useCallback(M=>{const D=A.current,P=Date.now(),{clientX:K,clientY:B}=M,_=Math.sqrt((K-D.x)**2+(B-D.y)**2);if(P-D.t<=500&&_<=8){if(M.stopPropagation(),M.preventDefault(),!D.spanId){g({type:"resetScale"});return}g({type:"select",id:D.spanId}),g({type:"scaleToNode",id:D.spanId});return}const W=M.target;if(!W.closest(`.${String(te.timeline)}`))return;const L=W.closest("[data-span-id]"),G=(L==null?void 0:L.dataset.spanId)||"";A.current={x:K,y:B,t:P,spanId:G},G&&(g({type:"toggleSelection",id:G}),M.stopPropagation())},[g]);m.useLayoutEffect(()=>{const M=y.current;if(!M)return;const D=j.current;D&&(M.scrollLeft=D.anchorT*T-D.anchorX,j.current=void 0)},[j,y,T]),m.useEffect(()=>{var P;const M=(P=f.selected)==null?void 0:P.span.spanId;if(!M)return;const D=setTimeout(()=>{const K=f.timelineRef.current,B=K==null?void 0:K.querySelector(`[data-span-id="${M}"]`);if(!K||!B)return;const _=K.getBoundingClientRect(),W=B.getBoundingClientRect();W.width<_.width&&(W.left<_.left||W.right>_.right||W.top<_.top||W.bottom>_.bottom)&&B.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})},500);return()=>{clearTimeout(D)}},[f.selected,f.timelineRef]),m.useEffect(()=>{const M=D=>{D.key==="Escape"&&g({type:"escape"})};return window.addEventListener("keydown",M),()=>{window.removeEventListener("keydown",M)}},[g]),m.useEffect(()=>{if(!r)return;const M=document.documentElement,D=document.body;M.style.overflow="clip",D.style.overflow="clip";const P=K=>{K!=null&&K.cancelable?K.preventDefault():window.scrollTo({left:0,top:0,behavior:"instant"})};return P(),window.addEventListener("scroll",P,{passive:!1}),()=>{M.style.overflow="",D.style.overflow="",window.removeEventListener("scroll",P)}},[r]);const F=Math.max(f.timelineHeight-f.scrollbarWidth,Tr+gt+x.length*(Ft+gt)-gt+84),$=!!(f.isMobile&&f.selected);return n.jsxs("div",{className:Rt(te.traceViewer,u&&te.skeleton,t),onClickCapture:R,ref:C,style:{height:s,"--timeline-padding":`${Fe}px`,"--row-height":`${Ft}px`,"--row-padding":`${gt}px`,"--search-height":`${v?0:Zs}px`,"--search-gap":`${v?2:bi}px`,"--map-height":`${yi}px`,"--timeline-width":`${f.timelineWidth}px`,"--timeline-height":`${f.timelineHeight}px`,"--timeline-scroll-width":`${Math.round(f.root.duration*f.scale)}px`,"--panel-width":`${f.panelWidth}px`,"--panel-height":`${f.panelHeight}px`,"--height":`${f.height}px`,"--scrollbar-width":`${f.scrollbarWidth}px`,"--marker-height":`${Tr}px`,"--marker-notch-height":`${vi}px`},children:[v?null:n.jsx(id,{}),n.jsx(wi,{rows:x,scale:T,timelineRef:y}),n.jsxs("div",{className:Rt(te.traceViewerContent,$&&te.inert),children:[n.jsxs("div",{className:te.timeline,ref:y,children:[n.jsx("div",{style:{position:"relative",width:f.timelineWidth,minHeight:f.timelineHeight-Fe*2,padding:Fe,paddingBottom:0},children:n.jsxs("div",{className:te.traceNode,style:{width:f.root.duration*T||void 0,height:F-Fe*2},children:[n.jsx(rd,{scale:T,isLive:l}),n.jsx(nd,{events:S,root:f.root,scale:T}),n.jsx(sd,{dispatch:g,events:S,memoCacheRef:f.memoCacheRef,root:f.root,scale:T,scrollSnapshotRef:j,spans:w,timelineRef:y}),n.jsx(Ni,{cacheKey:b.get(""),cache:b,customSpanClassNameFunc:f.customSpanClassNameFunc,customSpanEventClassNameFunc:f.customSpanEventClassNameFunc,isLive:l,root:f.root,scale:T,scrollSnapshotRef:j,spans:w}),c!=null&&c>0&&(p||l)&&f.root.duration>0&&(()=>{const M=c*T,P=f.root.duration*T-M;if(P<4)return null;const K=Math.min(P*.05,20);return n.jsx("div",{style:{position:"absolute",top:0,left:M+K,width:P-K,height:"100%",pointerEvents:"none",zIndex:1,maskImage:"linear-gradient(to right, transparent 1%, black 3%)",WebkitMaskImage:"linear-gradient(to right, transparent 1%, black 3%)",background:"repeating-linear-gradient(-45deg, var(--ds-background-200) 0, var(--ds-background-200) 11px, var(--ds-gray-200) 11px, var(--ds-gray-200) 12px)"}})})()]})}),d]}),n.jsx("div",{className:te.zoomButtonTraceViewer,children:n.jsx(fd,{})})]}),o?n.jsx("div",{className:Rt(te.spanDetailPanelTraceViewer,!f.selected&&te.hidden,f.isMobile&&te.mobile),children:n.jsx(ji,{attached:!0})}):null]})}function ys(e,t=!1){if(t&&e==="pending")return te.spanPendingStriped;switch(e){case"running":return te.spanRunning;case"pending":return te.spanPending;case"completed":return te.spanCompleted;case"cancelled":return te.spanCancelled;case"failed":return te.spanFailed;default:return""}}function vd(e){return String(e).toLowerCase().endsWith("sleep")}const yd=e=>{const t=e.span.attributes,r=t==null?void 0:t.resource;if(r==="step"){const s=t.data,o=s==null?void 0:s.stepName;if(o&&vd(o))return te.spanSleep;const a=(s==null?void 0:s.status)==="pending";return ys(s==null?void 0:s.status,a)}if(r==="run"){const s=t.data;return ys(s==null?void 0:s.status,!1)}return r==="hook"?te.spanHook:r==="sleep"?te.spanSleep:""},bd=e=>{const t=e.event.name;return t==="step_failed"||t==="run_failed"?te.eventFailed:t==="step_retrying"?te.eventRetrying:t==="hook_created"||t==="hook_received"||t==="hook_disposed"?te.eventHook:te.eventDefault};function wd(e){return e==="hook_created"||e==="hook_received"||e==="hook_disposed"}function Ke(e){if(typeof e=="string"&&(e=new Date(e)),!e||!(e instanceof Date))return[0,0];const t=e.getTime(),r=Math.floor(t/1e3),s=t%1e3*1e6;return[r,s]}function gn(e){const t=e[0]*1e3,r=e[1]/1e6;return t+r}function Br(e,t){if(typeof e=="string"&&(e=new Date(e)),typeof t=="string"&&(t=new Date(t)),!e||!(e instanceof Date))return[0,0];const s=(t&&t instanceof Date?t:new Date).getTime()-e.getTime(),o=Math.floor(s/1e3),a=s%1e3*1e6;return[o,a]}const dr={name:"workflow-development-kit",version:"4.0.0"},Nd=new Set(["hook_created","hook_received","hook_disposed","step_started","step_retrying","step_failed","run_failed","wait_created","wait_completed"]);function zr(e,t=!0){return e.filter(r=>t?Nd.has(r.eventType):!0).map(r=>({name:r.eventType,timestamp:Ke(r.createdAt),attributes:{eventId:r.eventId,correlationId:r.correlationId,eventData:"eventData"in r?r.eventData:void 0},showVerticalLine:wd(r.eventType)}))}const zo=e=>{var s;const t=e.find(o=>o.eventType==="wait_created");if(!t)return null;const r=e.find(o=>o.eventType==="wait_completed");return{waitId:t.correlationId,runId:t.runId,createdAt:t.createdAt,resumeAt:(s=t.eventData)==null?void 0:s.resumeAt,completedAt:r==null?void 0:r.createdAt}};function jd(e,t){const r=zo(e);if(!r)return null;const s=r.createdAt,o=r.completedAt??t,a=Ke(s),i=Ke(o),l=Br(s,o),d=zr(e,!1);return{spanId:r.waitId,name:"sleep",kind:1,resource:"sleep",library:dr,status:{code:0},traceFlags:1,attributes:{resource:"sleep",data:r},links:[],events:d,duration:l,startTime:a,endTime:i}}const Wo=e=>{var l;const t=e.find(d=>d.eventType==="step_created");if(!t)return null;let r="pending",s=0,o,a;for(const d of e)switch(d.eventType){case"step_started":r="running",s+=1,o||(o=d.createdAt),a=void 0;break;case"step_completed":r="completed",a=d.createdAt;break;case"step_failed":r="failed",a=d.createdAt;break;case"step_retrying":r="pending",a=void 0;break}s===0&&(s=1);const i=e[e.length-1];return{stepId:t.correlationId,runId:t.runId,stepName:((l=t.eventData)==null?void 0:l.stepName)??"",status:r,attempt:s,createdAt:t.createdAt,updatedAt:(i==null?void 0:i.createdAt)??t.createdAt,startedAt:o,completedAt:a,specVersion:t.specVersion}};function kd(e,t){const r=Wo(e);if(!r)return null;const s=or(String(r.stepName)),o={resource:"step",data:r},a="step",i=new Date(r.completedAt??t),l=zr(e,!1),d=new Date(r.createdAt);let c=r.startedAt?new Date(r.startedAt):void 0;const p=e.find(u=>u.eventType==="step_started");return p&&(c=new Date(p.createdAt)),{spanId:String(r.stepId),name:(s==null?void 0:s.shortName)??"",kind:1,resource:a,library:dr,status:{code:0},traceFlags:1,attributes:o,links:[],events:l,startTime:Ke(d),endTime:Ke(i),duration:Br(d,i),activeStartTime:c&&c.getTime()>d.getTime()?Ke(c):void 0}}const Id=e=>{var a,i;const t=e.find(l=>l.eventType==="hook_created");if(!t)return null;const r=e.filter(l=>l.eventType==="hook_received"),s=e.filter(l=>l.eventType==="hook_disposed"),o=r.at(-1);return{hookId:t.correlationId,runId:t.runId,token:(a=t.eventData)==null?void 0:a.token,createdAt:t.createdAt,receivedCount:r.length,lastReceivedAt:(o==null?void 0:o.createdAt)||void 0,disposedAt:((i=s.at(-1))==null?void 0:i.createdAt)||void 0}};function Sd(e,t){const r=Id(e);if(!r)return null;const s=zr(e,!1),o=r.disposedAt||t;return{spanId:String(r.hookId),name:String(r.hookId),kind:1,resource:"hook",library:dr,status:{code:1},traceFlags:1,attributes:{resource:"hook",data:r},links:[],events:s,startTime:Ke(r.createdAt),endTime:Ke(o),duration:Br(r.createdAt,o)}}function Cd(e,t,r){var g;const s=r??new Date,{input:o,output:a,error:i,...l}=e,d={resource:"run",data:l},c=new Date(e.createdAt),p=e.startedAt?new Date(e.startedAt):void 0,u=e.completedAt??s,f=zr(t,!1);return{spanId:String(e.runId),name:String(((g=xt(e.workflowName))==null?void 0:g.shortName)??"?"),kind:1,resource:"run",library:dr,status:{code:0},traceFlags:1,attributes:d,links:[],events:f,startTime:Ke(c),endTime:Ke(u),duration:Br(c,u),activeStartTime:p&&p.getTime()>c.getTime()?Ke(p):void 0}}const Td=e=>e.startsWith("step_"),Ed=e=>e==="wait_created"||e==="wait_completed",Ad=e=>e==="hook_received"||e==="hook_created"||e==="hook_disposed";function Qr(e,t,r){const s=e.get(t);if(s){s.push(r);return}e.set(t,[r])}function Rd(e){const t=new Map,r=[],s=new Map,o=new Map;for(const a of e){const i=a.correlationId;if(!i){r.push(a);continue}if(Ed(a.eventType)){Qr(s,i,a);continue}if(Ad(a.eventType)){Qr(o,i,a);continue}if(Td(a.eventType)){Qr(t,i,a);continue}r.push(a)}return{eventsByStepId:t,runLevelEvents:r,timerEvents:s,hookEvents:o}}function Dd(e,t){let r=new Date(t.createdAt).getTime();for(const s of e){const o=new Date(s.createdAt).getTime();o>r&&(r=o)}return new Date(r)}function Md(e,t,r,s){const o=s,a=Array.from(t.eventsByStepId.values()).map(d=>kd(d,o)).filter(d=>d!==null),i=Array.from(t.hookEvents.values()).map(d=>Sd(d,o)).filter(d=>d!==null),l=Array.from(t.timerEvents.values()).map(d=>jd(d,o)).filter(d=>d!==null);return{runSpan:Cd(e,t.runLevelEvents,r),spans:[...a,...i,...l]}}function _d(e,t){const r=[e,...t.slice().sort((s,o)=>{const a=gn(s.startTime),i=gn(o.startTime);return a-i})];return r.map((s,o)=>{const a=o===0?void 0:String(r[o-1].spanId);return{...s,parentSpanId:a}})}function Ld(e,t,r){const s=Rd(t),o=Dd(t,e),{runSpan:a,spans:i}=Md(e,s,r,o),l=_d(a,i),d=gn(a.startTime),c=o.getTime()-d;return{traceId:e.runId,rootSpanId:e.runId,spans:l,resources:[{name:"workflow",attributes:{"service.name":dr.name}}],knownDurationMs:Math.max(0,c)}}function Od(e){const{state:t,dispatch:r}=nt(),s=m.useRef(t);s.current=t,m.useEffect(()=>{if(!e)return;let o=0;const a=()=>{const{root:c}=s.current;if(c.startTime){const p=Date.now();p>c.endTime&&(c.endTime=p,c.duration=c.endTime-c.startTime)}o=requestAnimationFrame(a)};o=requestAnimationFrame(a);let i=0,l=0;const d=()=>{const c=s.current;if(c.root.duration>0){const p=(c.width-c.scrollbarWidth)/c.root.duration;(Math.abs(p-l)>l*.001||l===0)&&(l=p,r({type:"detectBaseScale"}))}i=requestAnimationFrame(d)};return i=requestAnimationFrame(d),()=>{cancelAnimationFrame(o),cancelAnimationFrame(i)}},[e,r])}const Hd=450,Fd=240;function Pd({menu:e,items:t,onClose:r}){const s=m.useRef(null);m.useEffect(()=>{const i=p=>{s.current&&!s.current.contains(p.target)&&r()},l=p=>{p.key==="Escape"&&r()},d=()=>{r()},c=setTimeout(()=>{window.addEventListener("mousedown",i),window.addEventListener("keydown",l),window.addEventListener("scroll",d,!0)},0);return()=>{clearTimeout(c),window.removeEventListener("mousedown",i),window.removeEventListener("keydown",l),window.removeEventListener("scroll",d,!0)}},[r]);const[o,a]=m.useState({x:e.x,y:e.y});return m.useEffect(()=>{const i=s.current;if(!i)return;const l=i.getBoundingClientRect();let{x:d,y:c}=e;l.right>window.innerWidth&&(d=window.innerWidth-l.width-8),l.bottom>window.innerHeight&&(c=window.innerHeight-l.height-8),(d!==e.x||c!==e.y)&&a({x:d,y:c})},[e]),t.length===0?null:Bs.createPortal(n.jsxs("div",{ref:s,style:{position:"fixed",left:o.x,top:o.y,zIndex:99999,boxShadow:"var(--ds-shadow-menu)",borderRadius:12,background:"var(--ds-background-100)",padding:"var(--geist-space-gap-quarter, 4px)",fontSize:14,minWidth:180,overflowX:"hidden",overflowY:"auto"},children:[n.jsx("div",{style:{display:"block",color:"var(--ds-gray-900)",fontSize:"0.75rem",padding:"var(--geist-gap-quarter, 4px) var(--geist-space-2x, 8px)",fontWeight:500,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",maxWidth:240,borderBottom:"1px solid var(--ds-gray-alpha-400)",marginBottom:4},children:e.spanName}),t.map(i=>n.jsxs("button",{type:"button",style:{outline:"none",cursor:i.disabled?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:8,padding:"0 var(--geist-space-2x, 8px)",height:40,textDecoration:"none",borderRadius:6,color:i.destructive?"var(--ds-red-900)":"var(--ds-gray-1000)",width:"100%",background:"transparent",border:"none",fontSize:14,textAlign:"left",opacity:i.disabled?.4:1,transition:"background 0.15s"},disabled:i.disabled,onMouseEnter:l=>{l.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:l=>{l.currentTarget.style.background="transparent"},onClick:()=>{i.action(),r()},children:[i.icon??null,i.label]},i.label))]}),document.body)}function Bd({trace:e,run:t,isLive:r,onWakeUpSleep:s,onCancelRun:o,onResolveHook:a,onLoadMoreSpans:i,hasMoreSpans:l=!1,isLoadingMoreSpans:d=!1,children:c}){const{state:p,dispatch:u}=nt();Od(r);const[f,g]=m.useState(null),[y,j]=m.useState(null),[b,v]=m.useState(!1),[h,k]=m.useState(new Set),N=m.useMemo(()=>{const C=new Map;for(const A of e.spans)C.set(A.spanId,A);return C},[e.spans]),I=m.useCallback(async C=>{if(!(b||!y||!a)){if(!y.token){fe.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{v(!0),await a(y.token,C),fe.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),k(A=>new Set(A).add(y.hookId)),j(null)}catch(A){console.error("Failed to resolve hook:",A),fe.error("Failed to resolve hook",{description:A instanceof Error?A.message:"An unknown error occurred"})}finally{v(!1)}}},[a,y,b]),E=m.useCallback(C=>{const R=C.target.closest("[data-span-id]");if(!R)return;const F=R.dataset.spanId;if(!F)return;C.preventDefault(),C.stopPropagation();const $=N.get(F);if(!$)return;const M=$.attributes.resource??"unknown",D=$.attributes.data,P=!(D!=null&&D.completedAt)&&!(D!=null&&D.disposedAt);g({x:C.clientX,y:C.clientY,spanId:F,spanName:$.name,resourceType:M,isActive:P})},[N]),x=m.useRef(null);m.useEffect(()=>{const C=x.current;if(!C)return;const A=R=>{E(R)};return C.addEventListener("contextmenu",A),()=>{C.removeEventListener("contextmenu",A)}},[E]);const w=m.useRef(!1);m.useEffect(()=>{const C=p.timelineRef.current;if(!C||!i||!l)return;const A=200,R=()=>{w.current||d||!l||C.scrollHeight-C.scrollTop-C.clientHeight>A||(w.current=!0,Promise.resolve(i()).finally(()=>{w.current=!1}))};return C.addEventListener("scroll",R),R(),()=>{C.removeEventListener("scroll",R)}},[p.timelineRef,i,l,d]);const S=m.useCallback(()=>{g(null)},[]),T=m.useCallback(C=>{var F,$;const A=[],R=!t.completedAt;if(C.resourceType==="sleep"&&C.isActive&&R&&s&&A.push({label:"Wake Up Sleep",icon:n.jsx(La,{className:"h-3.5 w-3.5"}),action:()=>{s(t.runId,C.spanId).then(M=>{M.stoppedCount>0?fe.success("Sleep woken up",{description:`Woke up ${String(M.stoppedCount)} sleep${M.stoppedCount>1?"s":""}`}):fe.info("No active sleeps found",{description:"The sleep may have already completed."})}).catch(M=>{fe.error("Failed to wake up sleep",{description:M instanceof Error?M.message:"An unknown error occurred"})})}}),C.resourceType==="hook"&&R&&a){const M=N.get(C.spanId),D=(F=M==null?void 0:M.attributes)==null?void 0:F.data,P=!!(D!=null&&D.disposedAt)||!!(($=M==null?void 0:M.events)!=null&&$.some(K=>K.name==="hook_disposed"))||h.has(C.spanId);D!=null&&D.token&&!P&&A.push({label:"Resolve Hook",icon:n.jsx($s,{className:"h-3.5 w-3.5"}),action:()=>{j({hookId:C.spanId,token:D.token})}})}return C.resourceType==="run"&&R&&o&&A.push({label:"Cancel Run",icon:n.jsx(Oa,{className:"h-3.5 w-3.5"}),destructive:!0,action:()=>{o(t.runId).catch(M=>{fe.error("Failed to cancel run",{description:M instanceof Error?M.message:"An unknown error occurred"})})}}),A.push({label:"View Details",icon:n.jsx(zi,{className:"h-3.5 w-3.5"}),action:()=>{u({type:"select",id:C.spanId})}}),A.push({label:"Copy Name",icon:n.jsx(Ui,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(C.spanName).then(()=>{fe.success("Name copied to clipboard")}).catch(()=>{fe.error("Failed to copy name")})}}),A.push({label:"Copy ID",icon:n.jsx(sr,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(C.spanId).then(()=>{fe.success("ID copied to clipboard")}).catch(()=>{fe.error("Failed to copy ID")})}}),A},[u,s,o,a,N,h,t.runId,t.completedAt]);return n.jsxs("div",{className:"relative w-full h-full",ref:x,children:[c,f?n.jsx(Pd,{menu:f,items:T(f),onClose:S}):null,n.jsx(Vs,{isOpen:y!==null,onClose:()=>j(null),onSubmit:I,isSubmitting:b})]})}function zd({onSelectionChange:e}){const{state:t}=nt(),{selected:r}=t,s=m.useRef(e);return s.current=e,m.useEffect(()=>{var o,a;r?s.current({data:(o=r.span.attributes)==null?void 0:o.data,resource:(a=r.span.attributes)==null?void 0:a.resource,spanId:r.span.spanId}):s.current(null)},[r]),null}function Wd({triggerDeselect:e}){const{dispatch:t}=nt();return m.useEffect(()=>{e>0&&t({type:"deselect"})},[e,t]),null}function $d({selectRequest:e}){const{dispatch:t}=nt();return m.useEffect(()=>{e!=null&&e.id&&t({type:"select",id:e.id})},[t,e]),null}function Vd({onResize:e}){const t=m.useCallback(r=>{r.preventDefault();let s=r.clientX;const o=i=>{const l=s-i.clientX;s=i.clientX,e(l)},a=()=>{document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",a)};document.addEventListener("pointermove",o),document.addEventListener("pointerup",a)},[e]);return n.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-400/50 z-10",onPointerDown:t})}function Gd({hasMore:e,isLive:t,isInitialLoading:r}){const s={color:"var(--ds-gray-900)"};return e||r?n.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-xs",style:s,children:[n.jsxs("svg",{className:"h-3.5 w-3.5 animate-spin",viewBox:"0 0 24 24",fill:"none",children:[n.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),n.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),"Loading more events…"]}):t?n.jsx("div",{className:"flex items-center justify-center py-3 text-xs",style:s,children:"Waiting for more events…"}):n.jsx("div",{className:"flex items-center justify-center py-3 text-xs",style:s,children:"End of run"})}const Ud=({run:e,events:t,isLoading:r,error:s,spanDetailData:o,spanDetailLoading:a,spanDetailError:i,onWakeUpSleep:l,onResolveHook:d,onCancelRun:c,onStreamClick:p,onSpanSelect:u,onLoadEventData:f,onLoadMoreSpans:g,hasMoreSpans:y=!1,isLoadingMoreSpans:j=!1,encryptionKey:b,onDecrypt:v})=>{const[h,k]=m.useState(null),[N,I]=m.useState(Hd),[E,x]=m.useState(0),[w,S]=m.useState(null),T=!!(e&&!e.completedAt),C=m.useMemo(()=>{if(e!=null&&e.runId)return Ld(e,t,new Date)},[e,t]),A=C;m.useEffect(()=>{s&&!r&&(console.error(s),fe.error("Error loading workflow trace data",{description:s.message}))},[s,r]);const R=m.useCallback(L=>{u==null||u(L)},[u]),F=m.useCallback(L=>{if(L){const G=L.spanId,V=G?t.filter(J=>J.correlationId===G):[];k({...L,rawEvents:V})}else k(null)},[t]);m.useEffect(()=>{const L=h==null?void 0:h.spanId;if(!L)return;const G=t.filter(V=>V.correlationId===L);k(V=>{if(!V||V.spanId!==L)return V;const J=V.rawEvents??[];return J.length===G.length&&J.every((H,Y)=>{var X;return H.eventId===((X=G[Y])==null?void 0:X.eventId)})?V:{...V,rawEvents:G}})},[t,h==null?void 0:h.spanId]);const $=m.useCallback(()=>{k(null),x(L=>L+1)},[]),M=m.useCallback(L=>{I(G=>Math.max(Fd,G+L))},[]),D=m.useMemo(()=>!(h!=null&&h.spanId)||!A?-1:A.spans.findIndex(L=>L.spanId===h.spanId),[h==null?void 0:h.spanId,A]),P=D>0,K=D>=0&&A!=null&&D<A.spans.length-1,B=m.useCallback(()=>{var G;if(!A||D<=0)return;const L=(G=A.spans[D-1])==null?void 0:G.spanId;L&&S({id:L,token:Date.now()})},[D,A]),_=m.useCallback(()=>{var G;if(!A||D<0)return;const L=(G=A.spans[D+1])==null?void 0:G.spanId;L&&S({id:L,token:Date.now()})},[D,A]),W=m.useMemo(()=>{var J,de;if(!(h!=null&&h.data))return;const L=h.data,G=L.stepName,V=L.workflowName;return(G?(J=or(G))==null?void 0:J.shortName:void 0)??(V?(de=xt(V))==null?void 0:de.shortName:void 0)??G??V??L.hookId??"Details"},[h==null?void 0:h.data]);return A?n.jsxs("div",{className:"relative w-full h-full flex",children:[n.jsx("div",{className:"flex-1 min-w-0 relative",children:n.jsxs(ki,{customSpanClassNameFunc:yd,customSpanEventClassNameFunc:bd,children:[n.jsx(zd,{onSelectionChange:F}),n.jsx(Wd,{triggerDeselect:E}),n.jsx($d,{selectRequest:w}),n.jsx(Bd,{trace:A,run:e,isLive:T,onWakeUpSleep:l,onCancelRun:c,onResolveHook:d,onLoadMoreSpans:g,hasMoreSpans:y,isLoadingMoreSpans:j,children:n.jsx(xd,{eagerRender:!0,height:"100%",isLive:T,trace:A,knownDurationMs:C==null?void 0:C.knownDurationMs,hasMoreData:y||!!r,footer:n.jsx(Gd,{hasMore:y,isLive:T,isInitialLoading:!!r})})})]})}),h&&n.jsxs("div",{className:"relative border-l flex-shrink-0 flex flex-col",style:{width:N,borderColor:"var(--ds-gray-200)",backgroundColor:"var(--ds-background-100)"},children:[n.jsx(Vd,{onResize:M}),n.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-y flex-shrink-0",style:{borderColor:"var(--ds-gray-200)"},children:[n.jsx("div",{className:"min-w-0 flex-1",children:n.jsx("div",{className:"text-sm font-medium truncate",style:{color:"var(--ds-gray-1000)"},title:W,children:W})}),n.jsxs("div",{className:"flex items-center",children:[n.jsx("button",{type:"button","aria-label":"Previous span",onClick:B,disabled:!P,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:6,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:P?"pointer":"not-allowed",opacity:P?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:L=>{P&&(L.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:n.jsx(Ma,{size:16})}),n.jsx("button",{type:"button","aria-label":"Next span",onClick:_,disabled:!K,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:2,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:K?"pointer":"not-allowed",opacity:K?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:L=>{K&&(L.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:n.jsx(_a,{size:16})})]}),n.jsx("div",{className:"flex items-center",style:{borderLeft:"1px solid var(--ds-gray-300)",marginLeft:6},children:n.jsx("button",{type:"button","aria-label":"Close panel",onClick:$,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:6,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:"pointer",flexShrink:0,transition:"background 0.15s"},onMouseEnter:L=>{L.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:n.jsx(Gs,{size:16})})})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:n.jsx(Ht,{title:"Failed to load entity details",children:n.jsx(ed,{run:e,onStreamClick:p,spanDetailData:o??null,spanDetailError:i,spanDetailLoading:a,onSpanSelect:R,onWakeUpSleep:l,onLoadEventData:f,onResolveHook:d,encryptionKey:b,onDecrypt:v,selectedSpan:h})})})]})]}):n.jsxs("div",{className:"relative w-full h-full",children:[n.jsx("div",{className:"border-b border-gray-alpha-400 w-full"}),n.jsx(xe,{className:"w-full ml-2 mt-1 mb-1 h-[56px]"}),n.jsxs("div",{className:"p-2 relative w-full",children:[n.jsx(xe,{className:"w-full mt-6 h-[20px]"}),n.jsx(xe,{className:"w-[10%] mt-2 ml-6 h-[20px]"}),n.jsx(xe,{className:"w-[10%] mt-2 ml-12 h-[20px]"}),n.jsx(xe,{className:"w-[20%] mt-2 ml-16 h-[20px]"})]})]})};async function Kd(e,t,r,s={}){const o=s.resolveData??"all";let a,i;if(t==="run")a=await yr(ln(e,r,o)),i=a.runId;else if(t==="step"){const{runId:l}=s;if(!l)throw new Tt("runId is required for step resource",{layer:"client"});a=await yr(Ii(e,l,r,o)),i=a.stepId}else if(t==="hook")a=await yr(Ys(e,r,o)),i=a.hookId;else throw new Tt(`Unknown resource type: ${t}`,{layer:"client"});return{data:a,correlationId:i}}function $o(e,t,r,s={}){const{refreshInterval:o=0,runId:a,enabled:i=!0,encryptionKey:l}=s,[d,c]=m.useState(null),[p,u]=m.useState(i),[f,g]=m.useState(null),y=m.useCallback(async b=>l?an(b,l):it(b),[l]),j=m.useCallback(async()=>{if(!i){u(!1);return}if(c(null),g(null),u(!0),t==="hook"){try{const{error:b,result:v}=await Qe(Ys(e,r,"all"));if(b){g(b);return}try{c(await y(v))}catch(h){g(h instanceof Error?h:new Error(String(h)))}}finally{u(!1)}return}if(t==="sleep"){try{if(!a){g(new Error("runId is required for loading sleep details"));return}const{error:b,result:v}=await Qe(br(e,a,{sortOrder:"asc",limit:1e3,withData:!0}));if(b){g(b);return}try{const h=v.data.map(it),k=await Promise.all(h.filter(I=>I.correlationId===r).map(y)),N=zo(k);if(N===null){g(new Error(`Failed to load ${t} details: missing required event data`));return}c(N)}catch(h){g(h instanceof Error?h:new Error(String(h)))}}finally{u(!1)}return}try{const{data:b}=await Kd(e,t,r,{runId:a});c(await y(b))}catch(b){b instanceof Error?g(b):g(new Error(String(b)));return}finally{u(!1)}},[e,t,r,a,i,y]);return m.useEffect(()=>{j()},[j]),m.useEffect(()=>{if(!o||o<=0)return;const b=setInterval(j,o);return()=>clearInterval(b)},[o,j]),{data:d,loading:p,error:f,refresh:j}}function xn(e,t,r){const s=[...e,...t],o=new Map(s.map(a=>[a[r],a]));return Array.from(o.values())}async function qd(e){const{fetchFn:t,setItems:r,setCursor:s,setError:o,idKey:a,cursorStrategy:i="always",transform:l}=e,{error:d,result:c}=await t();if(d)return o(d),!1;if(c.data.length>0){const p=l?c.data.map(l):c.data;return r(f=>xn(f,p,a)),(i==="onHasMore"?!!(c.cursor&&c.hasMore):!!c.cursor)&&s(c.cursor),!0}return!1}const Zd=100,Yd=500,Xd=100,Jd=5e3;function Qd(e,t,r={}){const{live:s=!1}=r,[o,a]=m.useState(null),[i,l]=m.useState([]),[d,c]=m.useState(!0),[p,u]=m.useState(null),[f,g]=m.useState(),[y,j]=m.useState(!1),[b,v]=m.useState(!1),h=m.useRef(!1),[k,N]=m.useState(!1),I=m.useCallback(async()=>{if(h.current)return;h.current=!0,c(!0),u(null);const[T,C]=await Promise.all([Qe(ln(e,t,"none")),Qe(br(e,t,{sortOrder:"asc",limit:Yd,withData:!0}))]);T.error?u(T.error):a(it(T.result));const A=C.error?[]:C.result.data.map(it);l(xn([],A,"eventId")),g(C.error||!C.result.hasMore?void 0:C.result.cursor),j(!!(!C.error&&C.result.hasMore)),c(!1),N(!0),h.current=!1,!T.error&&C.error&&u(C.error)},[e,t]),E=m.useCallback(async()=>{if(!(h.current||!k||b||!y)){v(!0);try{const T=await Qe(br(e,t,{cursor:f,sortOrder:"asc",limit:Xd,withData:!0}));if(T.error)u(T.error);else{const C=T.result.data.map(it);C.length>0&&l(A=>xn(A,C,"eventId")),j(!!T.result.hasMore),g(T.result.hasMore?T.result.cursor:void 0)}}finally{v(!1)}}},[e,t,k,b,y,f]),x=m.useCallback(async()=>{if(o!=null&&o.completedAt)return!1;const{error:T,result:C}=await Qe(ln(e,t,"none"));return T?(u(T),!1):(u(null),a(it(C)),!0)},[e,t,o==null?void 0:o.completedAt]),w=m.useCallback(()=>qd({fetchFn:()=>Qe(br(e,t,{cursor:f,sortOrder:"asc",limit:Zd,withData:!0})),setItems:l,setCursor:g,setError:u,idKey:"eventId",transform:it}),[e,t,f]),S=m.useCallback(async()=>{if(h.current||!k)return{foundNewItems:!1};let T=!1;try{const[C,A]=await Promise.all([x(),w()]);T=A}catch(C){console.error("Update error:",C)}return{foundNewItems:T}},[w,k,x]);return m.useEffect(()=>{I()},[I]),m.useEffect(()=>{if(!s||!k||o!=null&&o.completedAt)return;const T=setInterval(()=>{S()},Jd);return()=>{clearInterval(T)}},[s,k,S,o==null?void 0:o.completedAt]),{run:o??{},events:i,loading:d,error:p,update:S,loadMoreTraceData:E,hasMoreTraceData:y,isLoadingMoreTraceData:b}}function eu(e){return typeof e=="object"&&e!==null&&"message"in e&&"layer"in e&&"cause"in e&&"request"in e}async function tu(e,t,r,s){try{const o=`/api/stream/${encodeURIComponent(t)}${r!=null?`?startIndex=${r}`:""}`,a=await fetch(o,{signal:s});if(!a.ok){const i=await a.json().catch(()=>null);throw i&&eu(i)?new Tt(i.message,{layer:"client",cause:i.cause,request:i.request}):new Tt(`Failed to read stream: ${a.status}`,{layer:"client"})}if(!a.body)throw new Tt("Failed to read stream: no body",{layer:"client"});return a.body}catch(o){throw o instanceof Tt?o:new Tt("Failed to read stream",{layer:"client",cause:o})}}async function ru(e,t){return yr(Si(e,t))}const nu=1e4;function su(e,t,r=nu){const[s,o]=m.useState([]),[a,i]=m.useState(!0),[l,d]=m.useState(null),c=m.useCallback(async()=>{i(!0),d(null);try{const p=await ru(e,t);o(p)}catch(p){d(p instanceof Error?p:new Error(String(p)))}finally{i(!1)}},[e,t]);return m.useEffect(()=>{c()},[c]),m.useEffect(()=>{if(!r||r<=0)return;const p=setInterval(c,r);return()=>clearInterval(p)},[r,c]),{streams:s,loading:a,error:l,refresh:c}}var ou=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],dt=ou.reduce((e,t)=>{const r=m.forwardRef((s,o)=>{const{asChild:a,...i}=s,l=a?wn:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(l,{...i,ref:o})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function au(e,t){e&&Bs.flushSync(()=>e.dispatchEvent(t))}var iu="DismissableLayer",vn="dismissableLayer.update",lu="dismissableLayer.pointerDownOutside",cu="dismissableLayer.focusOutside",bs,Vo=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Go=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:s,onPointerDownOutside:o,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...d}=e,c=m.useContext(Vo),[p,u]=m.useState(null),f=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,g]=m.useState({}),y=yt(t,x=>u(x)),j=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),v=j.indexOf(b),h=p?j.indexOf(p):-1,k=c.layersWithOutsidePointerEventsDisabled.size>0,N=h>=v,I=fu(x=>{const w=x.target,S=[...c.branches].some(T=>T.contains(w));!N||S||(o==null||o(x),i==null||i(x),x.defaultPrevented||l==null||l())},f),E=mu(x=>{const w=x.target;[...c.branches].some(T=>T.contains(w))||(a==null||a(x),i==null||i(x),x.defaultPrevented||l==null||l())},f);return Ha(x=>{h===c.layers.size-1&&(s==null||s(x),!x.defaultPrevented&&l&&(x.preventDefault(),l()))},f),m.useEffect(()=>{if(p)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(bs=f.body.style.pointerEvents,f.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(p)),c.layers.add(p),ws(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(f.body.style.pointerEvents=bs)}},[p,f,r,c]),m.useEffect(()=>()=>{p&&(c.layers.delete(p),c.layersWithOutsidePointerEventsDisabled.delete(p),ws())},[p,c]),m.useEffect(()=>{const x=()=>g({});return document.addEventListener(vn,x),()=>document.removeEventListener(vn,x)},[]),n.jsx(dt.div,{...d,ref:y,style:{pointerEvents:k?N?"auto":"none":void 0,...e.style},onFocusCapture:ct(e.onFocusCapture,E.onFocusCapture),onBlurCapture:ct(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:ct(e.onPointerDownCapture,I.onPointerDownCapture)})});Go.displayName=iu;var du="DismissableLayerBranch",uu=m.forwardRef((e,t)=>{const r=m.useContext(Vo),s=m.useRef(null),o=yt(t,s);return m.useEffect(()=>{const a=s.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),n.jsx(dt.div,{...e,ref:o})});uu.displayName=du;function fu(e,t=globalThis==null?void 0:globalThis.document){const r=Ir(e),s=m.useRef(!1),o=m.useRef(()=>{});return m.useEffect(()=>{const a=l=>{if(l.target&&!s.current){let d=function(){Uo(lu,r,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",o.current),o.current=d,t.addEventListener("click",o.current,{once:!0})):d()}else t.removeEventListener("click",o.current);s.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",o.current)}},[t,r]),{onPointerDownCapture:()=>s.current=!0}}function mu(e,t=globalThis==null?void 0:globalThis.document){const r=Ir(e),s=m.useRef(!1);return m.useEffect(()=>{const o=a=>{a.target&&!s.current&&Uo(cu,r,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",o),()=>t.removeEventListener("focusin",o)},[t,r]),{onFocusCapture:()=>s.current=!0,onBlurCapture:()=>s.current=!1}}function ws(){const e=new CustomEvent(vn);document.dispatchEvent(e)}function Uo(e,t,r,{discrete:s}){const o=r.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&o.addEventListener(e,t,{once:!0}),s?au(o,a):o.dispatchEvent(a)}var en="focusScope.autoFocusOnMount",tn="focusScope.autoFocusOnUnmount",Ns={bubbles:!1,cancelable:!0},pu="FocusScope",Ko=m.forwardRef((e,t)=>{const{loop:r=!1,trapped:s=!1,onMountAutoFocus:o,onUnmountAutoFocus:a,...i}=e,[l,d]=m.useState(null),c=Ir(o),p=Ir(a),u=m.useRef(null),f=yt(t,j=>d(j)),g=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(s){let j=function(k){if(g.paused||!l)return;const N=k.target;l.contains(N)?u.current=N:ht(u.current,{select:!0})},b=function(k){if(g.paused||!l)return;const N=k.relatedTarget;N!==null&&(l.contains(N)||ht(u.current,{select:!0}))},v=function(k){if(document.activeElement===document.body)for(const I of k)I.removedNodes.length>0&&ht(l)};document.addEventListener("focusin",j),document.addEventListener("focusout",b);const h=new MutationObserver(v);return l&&h.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",j),document.removeEventListener("focusout",b),h.disconnect()}}},[s,l,g.paused]),m.useEffect(()=>{if(l){ks.add(g);const j=document.activeElement;if(!l.contains(j)){const v=new CustomEvent(en,Ns);l.addEventListener(en,c),l.dispatchEvent(v),v.defaultPrevented||(hu(bu(qo(l)),{select:!0}),document.activeElement===j&&ht(l))}return()=>{l.removeEventListener(en,c),setTimeout(()=>{const v=new CustomEvent(tn,Ns);l.addEventListener(tn,p),l.dispatchEvent(v),v.defaultPrevented||ht(j??document.body,{select:!0}),l.removeEventListener(tn,p),ks.remove(g)},0)}}},[l,c,p,g]);const y=m.useCallback(j=>{if(!r&&!s||g.paused)return;const b=j.key==="Tab"&&!j.altKey&&!j.ctrlKey&&!j.metaKey,v=document.activeElement;if(b&&v){const h=j.currentTarget,[k,N]=gu(h);k&&N?!j.shiftKey&&v===N?(j.preventDefault(),r&&ht(k,{select:!0})):j.shiftKey&&v===k&&(j.preventDefault(),r&&ht(N,{select:!0})):v===h&&j.preventDefault()}},[r,s,g.paused]);return n.jsx(dt.div,{tabIndex:-1,...i,ref:f,onKeyDown:y})});Ko.displayName=pu;function hu(e,{select:t=!1}={}){const r=document.activeElement;for(const s of e)if(ht(s,{select:t}),document.activeElement!==r)return}function gu(e){const t=qo(e),r=js(t,e),s=js(t.reverse(),e);return[r,s]}function qo(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:s=>{const o=s.tagName==="INPUT"&&s.type==="hidden";return s.disabled||s.hidden||o?NodeFilter.FILTER_SKIP:s.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function js(e,t){for(const r of e)if(!xu(r,{upTo:t}))return r}function xu(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function vu(e){return e instanceof HTMLInputElement&&"select"in e}function ht(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&vu(e)&&t&&e.select()}}var ks=yu();function yu(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=Is(e,t),e.unshift(t)},remove(t){var r;e=Is(e,t),(r=e[0])==null||r.resume()}}}function Is(e,t){const r=[...e],s=r.indexOf(t);return s!==-1&&r.splice(s,1),r}function bu(e){return e.filter(t=>t.tagName!=="A")}var wu="Portal",Zo=m.forwardRef((e,t)=>{var l;const{container:r,...s}=e,[o,a]=m.useState(!1);Fa(()=>a(!0),[]);const i=r||o&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?Ps.createPortal(n.jsx(dt.div,{...s,ref:t}),i):null});Zo.displayName=wu;var Ln="Dialog",[Yo,Xo]=Us(Ln),[Nu,Ze]=Yo(Ln),Jo=e=>{const{__scopeDialog:t,children:r,open:s,defaultOpen:o,onOpenChange:a,modal:i=!0}=e,l=m.useRef(null),d=m.useRef(null),[c=!1,p]=Ba({prop:s,defaultProp:o,onChange:a});return n.jsx(Nu,{scope:t,triggerRef:l,contentRef:d,contentId:Wr(),titleId:Wr(),descriptionId:Wr(),open:c,onOpenChange:p,onOpenToggle:m.useCallback(()=>p(u=>!u),[p]),modal:i,children:r})};Jo.displayName=Ln;var Qo="DialogTrigger",ea=m.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,o=Ze(Qo,r),a=yt(t,o.triggerRef);return n.jsx(dt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":Fn(o.open),...s,ref:a,onClick:ct(e.onClick,o.onOpenToggle)})});ea.displayName=Qo;var On="DialogPortal",[ju,ta]=Yo(On,{forceMount:void 0}),ra=e=>{const{__scopeDialog:t,forceMount:r,children:s,container:o}=e,a=Ze(On,t);return n.jsx(ju,{scope:t,forceMount:r,children:m.Children.map(s,i=>n.jsx(bn,{present:r||a.open,children:n.jsx(Zo,{asChild:!0,container:o,children:i})}))})};ra.displayName=On;var Mr="DialogOverlay",na=m.forwardRef((e,t)=>{const r=ta(Mr,e.__scopeDialog),{forceMount:s=r.forceMount,...o}=e,a=Ze(Mr,e.__scopeDialog);return a.modal?n.jsx(bn,{present:s||a.open,children:n.jsx(ku,{...o,ref:t})}):null});na.displayName=Mr;var ku=m.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,o=Ze(Mr,r);return n.jsx(Wa,{as:wn,allowPinchZoom:!0,shards:[o.contentRef],children:n.jsx(dt.div,{"data-state":Fn(o.open),...s,ref:t,style:{pointerEvents:"auto",...s.style}})})}),Mt="DialogContent",sa=m.forwardRef((e,t)=>{const r=ta(Mt,e.__scopeDialog),{forceMount:s=r.forceMount,...o}=e,a=Ze(Mt,e.__scopeDialog);return n.jsx(bn,{present:s||a.open,children:a.modal?n.jsx(Iu,{...o,ref:t}):n.jsx(Su,{...o,ref:t})})});sa.displayName=Mt;var Iu=m.forwardRef((e,t)=>{const r=Ze(Mt,e.__scopeDialog),s=m.useRef(null),o=yt(t,r.contentRef,s);return m.useEffect(()=>{const a=s.current;if(a)return za(a)},[]),n.jsx(oa,{...e,ref:o,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ct(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ct(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:ct(e.onFocusOutside,a=>a.preventDefault())})}),Su=m.forwardRef((e,t)=>{const r=Ze(Mt,e.__scopeDialog),s=m.useRef(!1),o=m.useRef(!1);return n.jsx(oa,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(s.current||(l=r.triggerRef.current)==null||l.focus(),a.preventDefault()),s.current=!1,o.current=!1},onInteractOutside:a=>{var d,c;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(s.current=!0,a.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const i=a.target;((c=r.triggerRef.current)==null?void 0:c.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&o.current&&a.preventDefault()}})}),oa=m.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:s,onOpenAutoFocus:o,onCloseAutoFocus:a,...i}=e,l=Ze(Mt,r),d=m.useRef(null),c=yt(t,d);return $a(),n.jsxs(n.Fragment,{children:[n.jsx(Ko,{asChild:!0,loop:!0,trapped:s,onMountAutoFocus:o,onUnmountAutoFocus:a,children:n.jsx(Go,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Fn(l.open),...i,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),n.jsxs(n.Fragment,{children:[n.jsx(Tu,{titleId:l.titleId}),n.jsx(Au,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Hn="DialogTitle",aa=m.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,o=Ze(Hn,r);return n.jsx(dt.h2,{id:o.titleId,...s,ref:t})});aa.displayName=Hn;var ia="DialogDescription",la=m.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,o=Ze(ia,r);return n.jsx(dt.p,{id:o.descriptionId,...s,ref:t})});la.displayName=ia;var ca="DialogClose",da=m.forwardRef((e,t)=>{const{__scopeDialog:r,...s}=e,o=Ze(ca,r);return n.jsx(dt.button,{type:"button",...s,ref:t,onClick:ct(e.onClick,()=>o.onOpenChange(!1))})});da.displayName=ca;function Fn(e){return e?"open":"closed"}var ua="DialogTitleWarning",[Cu,fa]=Pa(ua,{contentName:Mt,titleName:Hn,docsSlug:"dialog"}),Tu=({titleId:e})=>{const t=fa(ua),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
34
-
35
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
36
-
37
- For more information, see https://radix-ui.com/primitives/docs/components/${t.docsSlug}`;return m.useEffect(()=>{e&&(document.getElementById(e)||console.error(r))},[r,e]),null},Eu="DialogDescriptionWarning",Au=({contentRef:e,descriptionId:t})=>{const s=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${fa(Eu).contentName}}.`;return m.useEffect(()=>{var a;const o=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&o&&(document.getElementById(t)||console.warn(s))},[s,e,t]),null},Ru=Jo,Du=ea,Mu=ra,_u=na,Lu=sa,Ou=aa,Hu=la,ma=da,pa="AlertDialog",[Fu]=Us(pa,[Xo]),ut=Xo(),ha=e=>{const{__scopeAlertDialog:t,...r}=e,s=ut(t);return n.jsx(Ru,{...s,...r,modal:!0})};ha.displayName=pa;var Pu="AlertDialogTrigger",Bu=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,o=ut(r);return n.jsx(Du,{...o,...s,ref:t})});Bu.displayName=Pu;var zu="AlertDialogPortal",ga=e=>{const{__scopeAlertDialog:t,...r}=e,s=ut(t);return n.jsx(Mu,{...s,...r})};ga.displayName=zu;var Wu="AlertDialogOverlay",xa=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,o=ut(r);return n.jsx(_u,{...o,...s,ref:t})});xa.displayName=Wu;var zt="AlertDialogContent",[$u,Vu]=Fu(zt),va=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,children:s,...o}=e,a=ut(r),i=m.useRef(null),l=yt(t,i),d=m.useRef(null);return n.jsx(Cu,{contentName:zt,titleName:ya,docsSlug:"alert-dialog",children:n.jsx($u,{scope:r,cancelRef:d,children:n.jsxs(Lu,{role:"alertdialog",...a,...o,ref:l,onOpenAutoFocus:ct(o.onOpenAutoFocus,c=>{var p;c.preventDefault(),(p=d.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:[n.jsx(Ci,{children:s}),n.jsx(Uu,{contentRef:i})]})})})});va.displayName=zt;var ya="AlertDialogTitle",ba=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,o=ut(r);return n.jsx(Ou,{...o,...s,ref:t})});ba.displayName=ya;var wa="AlertDialogDescription",Na=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,o=ut(r);return n.jsx(Hu,{...o,...s,ref:t})});Na.displayName=wa;var Gu="AlertDialogAction",ja=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,o=ut(r);return n.jsx(ma,{...o,...s,ref:t})});ja.displayName=Gu;var ka="AlertDialogCancel",Ia=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...s}=e,{cancelRef:o}=Vu(ka,r),a=ut(r),i=yt(t,o);return n.jsx(ma,{...a,...s,ref:i})});Ia.displayName=ka;var Uu=({contentRef:e})=>{const t=`\`${zt}\` requires a description for the component to be accessible for screen reader users.
38
-
39
- You can add a description to the \`${zt}\` by passing a \`${wa}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
40
-
41
- Alternatively, you can use your own component as a description by assigning it an \`id\` and passing the same value to the \`aria-describedby\` prop in \`${zt}\`. If the description is confusing or duplicative for sighted users, you can use the \`@radix-ui/react-visually-hidden\` primitive as a wrapper around your description component.
42
-
43
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return m.useEffect(()=>{var s;document.getElementById((s=e.current)==null?void 0:s.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},Ku=ha,qu=ga,Zu=xa,Yu=va,Xu=ja,Ju=Ia,Qu=ba,ef=Na;function Ss({...e}){return n.jsx(Ku,{"data-slot":"alert-dialog",...e})}function tf({...e}){return n.jsx(qu,{"data-slot":"alert-dialog-portal",...e})}function rf({className:e,...t}){return n.jsx(Zu,{"data-slot":"alert-dialog-overlay",className:We("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",e),...t})}function Cs({className:e,onSubmit:t,...r}){return n.jsxs(tf,{children:[n.jsx(rf,{}),n.jsx(Yu,{"data-slot":"alert-dialog-content",className:We("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",e),onSubmit:s=>{s.preventDefault(),t==null||t(s)},...r})]})}function Ts({className:e,...t}){return n.jsx("div",{"data-slot":"alert-dialog-header",className:We("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Es({className:e,...t}){return n.jsx("div",{"data-slot":"alert-dialog-footer",className:We("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function As({className:e,...t}){return n.jsx(Qu,{"data-slot":"alert-dialog-title",className:We("text-lg font-semibold",e),...t})}function Rs({className:e,...t}){return n.jsx(ef,{"data-slot":"alert-dialog-description",className:We("text-muted-foreground text-sm",e),...t})}function Ds({className:e,...t}){return n.jsx(Xu,{className:We(Xs(),e),...t})}function Ms({className:e,...t}){return n.jsx(Ju,{className:We(Xs({variant:"outline"}),e),...t})}function nf({...e}){return n.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...e})}function sf({className:e,...t}){return n.jsx("ol",{"data-slot":"breadcrumb-list",className:We("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",e),...t})}function _s({className:e,...t}){return n.jsx("li",{"data-slot":"breadcrumb-item",className:We("inline-flex items-center gap-1.5",e),...t})}function of({asChild:e,className:t,...r}){const s=e?wn:"a";return n.jsx(s,{"data-slot":"breadcrumb-link",className:We("hover:text-foreground transition-colors",t),...r})}function af({className:e,...t}){return n.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:We("text-foreground font-normal",e),...t})}function lf({children:e,className:t,...r}){return n.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:We("[&>svg]:size-3.5",t),...r,children:e??n.jsx(yn,{})})}const Ot={sleep:"sleep",createHook:"createHook",createWebhook:"createWebhook",awaitWebhook:"awaitWebhook"};function _r(e){return e.replace(/\/\/\.\.\//g,"//")}function cf(e,t,r,s){let o;switch(e.status){case"completed":o="completed";break;case"failed":o=r<s-1?"retrying":"failed";break;case"running":o="running";break;case"cancelled":o="cancelled";break;case"pending":default:o="pending";break}const a=e.completedAt&&e.startedAt?new Date(e.completedAt).getTime()-new Date(e.startedAt).getTime():void 0;return{nodeId:t,stepId:e.stepId,attemptNumber:e.attempt,status:o,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt?new Date(e.completedAt).toISOString():void 0,duration:a,input:e.input,output:e.output,error:e.error?{message:e.error.message,stack:e.error.stack||""}:void 0}}function Lr(e){const t=e.split("//");return t.length>=3?t[t.length-1]:null}function df(e){const t=new Map,r=new Map,s=new Map,o=[],a=new Map;for(const i of e){if(i.data.stepId){const l=_r(i.data.stepId),d=t.get(l)||[];d.push(i),t.set(l,d);const c=Lr(l);if(c){const p=r.get(c)||[];p.push(i),r.set(c,p)}}if(i.data.nodeKind==="primitive"){const l=i.data.label,d=s.get(l)||[];d.push(i),s.set(l,d)}if(i.data.nodeKind==="agent"&&o.push(i),i.data.nodeKind==="tool"){const d=i.data.label.replace(/ \(tool\)$/,""),c=a.get(d)||[];if(c.push(i),a.set(d,c),i.data.stepId){const p=Lr(_r(i.data.stepId));if(p){const u=a.get(p)||[];u.includes(i)||(u.push(i),a.set(p,u))}}}}return{byStepId:t,byFunctionName:r,primitivesByLabel:s,agentNodes:o,toolNodes:a}}function uf(e,t,r){var d,c,p,u;const s=new Map,o=new Set(e),a=new Map;for(const f of t.nodes){const g=(d=f.metadata)==null?void 0:d.parallelGroupId;if(g){const y=a.get(g)||{nodes:[]};y.nodes.push(f),y.method=(c=f.metadata)==null?void 0:c.parallelMethod,a.set(g,y)}}const i=new Map;for(const[f,g]of a)if(g.method==="race"){let y,j;for(const b of g.nodes){const v=r.get(b.id);if(v){for(const h of v)if(h.status==="completed"&&h.completedAt){const k=new Date(h.completedAt);(!j||k<j)&&(j=k,y=b.id)}}}y&&i.set(f,y)}const l=f=>{const g=s.get(f.id);g?g.traversalCount++:s.set(f.id,{edgeId:f.id,traversalCount:1,timings:[]})};for(const f of t.edges){const g=t.nodes.find(k=>k.id===f.source),y=t.nodes.find(k=>k.id===f.target);if(!g||!y)continue;const j=o.has(f.source),b=o.has(f.target);if(!j&&!b)continue;if(f.type==="conditional"){j&&b&&l(f);continue}const v=(p=g.metadata)==null?void 0:p.parallelGroupId,h=(u=g.metadata)==null?void 0:u.parallelMethod;v&&h==="race"?i.get(v)===f.source&&b&&l(f):(j&&b||j&&f.type==="parallel"&&b)&&l(f)}return s}function ff(e,t,r,s){const o=t.nodes.find(a=>a.data.nodeKind==="workflow_start");o&&(r.push(o.id),s.set(o.id,[{nodeId:o.id,attemptNumber:1,status:"completed",startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0}]))}function mf(e,t,r,s){const o=t.nodes.find(i=>i.data.nodeKind==="workflow_end");if(!o||r.includes(o.id))return;let a;switch(e.status){case"completed":a="completed";break;case"failed":a="failed";break;case"cancelled":a="cancelled";break;case"running":a="running";break;case"pending":default:return}r.push(o.id),s.set(o.id,[{nodeId:o.id,attemptNumber:1,status:a,startedAt:e.completedAt?new Date(e.completedAt).toISOString():void 0,completedAt:e.completedAt?new Date(e.completedAt).toISOString():void 0}])}function pf(e,t,r,s,o,a,i){const l=_r(t),d=o.get(l)||0;o.set(l,d+1);let c=r.get(l)||[],p="step-id";if(c.length===0){const y=Lr(l);y&&(c=s.get(y)||[],p="function-name")}const u=c.length===1?c[0]:c[d];if(console.log("[Graph Mapper] Processing step group:",{stepName:t,normalizedStepName:l,attempts:e.length,occurrenceIndex:d,totalNodesWithStepId:c.length,selectedNode:u==null?void 0:u.id,allNodesWithStepId:c.map(y=>y.id),matchStrategy:p,strategy:c.length===1?"single-node-multiple-invocations":"occurrence-based"}),!u)return;const f=e.map((y,j)=>cf(y,u.id,j,e.length));if(c.length===1){const y=a.get(u.id)||[];a.set(u.id,[...y,...f])}else a.set(u.id,f);return i.includes(u.id)||i.push(u.id),f[f.length-1].status==="running"?u.id:void 0}function hf(e,t,r,s){const o=new Map,a=new Map;for(const v of e){if(!v.correlationId)continue;const h=a.get(v.correlationId)||[];h.push(v),a.set(v.correlationId,h)}let i;const l=t.get(Ot.sleep)||[],d=new Set;for(const v of e)v.eventType==="wait_created"&&v.correlationId&&d.add(v.correlationId);const c=Array.from(d).sort((v,h)=>{var x,w;const k=a.get(v)||[],N=a.get(h)||[],I=(x=k.find(S=>S.eventType==="wait_created"))==null?void 0:x.createdAt,E=(w=N.find(S=>S.eventType==="wait_created"))==null?void 0:w.createdAt;return!I||!E?0:new Date(I).getTime()-new Date(E).getTime()});for(const v of c){const h=a.get(v)||[],k=h.find(R=>R.eventType==="wait_created"),N=h.find(R=>R.eventType==="wait_completed");if(!k)continue;const I=o.get(Ot.sleep)||0;o.set(Ot.sleep,I+1);const E=l.length===1?l[0]:l[I];if(!E)continue;let x="running";N&&(x="completed");const w=new Date(k.createdAt).toISOString(),S=N?new Date(N.createdAt).toISOString():void 0,T=N?new Date(N.createdAt).getTime()-new Date(k.createdAt).getTime():void 0,C={nodeId:E.id,attemptNumber:1,status:x,startedAt:w,completedAt:S,duration:T},A=r.get(E.id)||[];r.set(E.id,[...A,C]),s.includes(E.id)||s.push(E.id),x==="running"&&(i=E.id)}const p=[...t.get(Ot.createHook)||[],...t.get(Ot.createWebhook)||[]],u=new Set;for(const v of e)v.eventType==="hook_created"&&v.correlationId&&u.add(v.correlationId);const f=Array.from(u).sort((v,h)=>{var x,w;const k=a.get(v)||[],N=a.get(h)||[],I=(x=k.find(S=>S.eventType==="hook_created"))==null?void 0:x.createdAt,E=(w=N.find(S=>S.eventType==="hook_created"))==null?void 0:w.createdAt;return!I||!E?0:new Date(I).getTime()-new Date(E).getTime()});let g=0;for(const v of f){const k=(a.get(v)||[]).find(T=>T.eventType==="hook_created");if(!k)continue;const N=p.length===1?p[0]:p[g];if(g++,!N)continue;const I="completed",E=new Date(k.createdAt).toISOString(),x=new Date(k.createdAt).toISOString(),w={nodeId:N.id,attemptNumber:1,status:I,startedAt:E,completedAt:x,duration:0},S=r.get(N.id)||[];r.set(N.id,[...S,w]),s.includes(N.id)||s.push(N.id)}const y=t.get(Ot.awaitWebhook)||[],j=new Set;for(const v of e)v.eventType==="hook_received"&&v.correlationId&&j.add(v.correlationId);let b=0;for(const v of f){const h=y.length===1?y[0]:y[b];if(b++,!h)continue;const k=a.get(v)||[],N=k.find(A=>A.eventType==="hook_created"),I=k.find(A=>A.eventType==="hook_received");let E,x,w,S=0;I?(E="completed",x=N?new Date(N.createdAt).toISOString():new Date(I.createdAt).toISOString(),w=new Date(I.createdAt).toISOString(),S=new Date(w).getTime()-new Date(x).getTime()):N?(E="running",x=new Date(N.createdAt).toISOString()):E="pending";const T={nodeId:h.id,attemptNumber:1,status:E,startedAt:x,completedAt:w,duration:S},C=r.get(h.id)||[];r.set(h.id,[...C,T]),s.includes(h.id)||s.push(h.id)}return i}function gf(e,t,r,s,o,a,i){var d;let l="pending";e.status==="completed"?l="completed":e.status==="failed"?l="failed":e.status==="running"&&(l="running");for(const c of r){const p={nodeId:c.id,attemptNumber:1,status:l,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt&&(l==="completed"||l==="failed")?new Date(e.completedAt).toISOString():void 0};o.set(c.id,[p]),a.includes(c.id)||a.push(c.id)}for(const c of t){const p=Lr(c.stepName);if(!p)continue;const u=s.get(p);if(!u||u.length===0)continue;const f=u[0];let g;switch(c.status){case"completed":g="completed";break;case"failed":g="failed";break;case"running":g="running";break;case"cancelled":g="cancelled";break;case"pending":default:g="pending";break}const y=c.completedAt&&c.startedAt?new Date(c.completedAt).getTime()-new Date(c.startedAt).getTime():void 0,j={nodeId:f.id,stepId:c.stepId,attemptNumber:c.attempt,status:g,startedAt:c.startedAt?new Date(c.startedAt).toISOString():void 0,completedAt:c.completedAt?new Date(c.completedAt).toISOString():void 0,duration:y,input:c.input,output:c.output,error:c.error},b=o.get(f.id)||[];o.set(f.id,[...b,j]),a.includes(f.id)||a.push(f.id)}for(const c of i){const p=((d=c.metadata)==null?void 0:d.isToolsCollection)===!0;if(c.data.nodeKind==="tool"&&p&&!o.has(c.id)){const u={nodeId:c.id,attemptNumber:1,status:l,startedAt:e.startedAt?new Date(e.startedAt).toISOString():void 0,completedAt:e.completedAt&&(l==="completed"||l==="failed")?new Date(e.completedAt).toISOString():void 0};o.set(c.id,[u]),a.includes(c.id)||a.push(c.id)}}}function xf(e,t,r,s){var i,l,d;const o=e.nodes.filter(c=>c.data.nodeKind==="conditional"),a=new Map;for(const c of e.nodes){const p=(i=c.metadata)==null?void 0:i.conditionalId;if(p){const u=a.get(p)||{thenNodes:[],elseNodes:[]};((l=c.metadata)==null?void 0:l.conditionalBranch)==="Then"?u.thenNodes.push(c):((d=c.metadata)==null?void 0:d.conditionalBranch)==="Else"&&u.elseNodes.push(c),a.set(p,u)}}for(const c of o){const p=c.id.match(/^(cond_\d+)_node$/);if(!p)continue;const u=p[1],f=a.get(u);if(!f)continue;const g=f.thenNodes.some(j=>t.has(j.id)),y=f.elseNodes.some(j=>t.has(j.id));if(g||y){const j=[...f.thenNodes,...f.elseNodes];if(!t.has(c.id)){let b;for(const k of j){const N=t.get(k.id);if(N&&N.length>0){const I=N[0];I.startedAt&&(!b||I.startedAt<b)&&(b=I.startedAt)}}const v=s.startedAt?new Date(s.startedAt).toISOString():void 0,h={nodeId:c.id,attemptNumber:1,status:"completed",startedAt:b||v,completedAt:b||v};t.set(c.id,[h])}if(!r.includes(c.id)){const b=j.map(v=>r.indexOf(v.id)).filter(v=>v>=0);if(b.length>0){const v=Math.min(...b);v>=0&&v<r.length?r.splice(v,0,c.id):r.push(c.id)}else r.push(c.id)}}}}function vf(e,t,r,s){const o=new Map,a=[];let i;console.log("[Graph Mapper] Mapping run to execution:",{runId:e.runId,workflowName:e.workflowName,graphNodes:s.nodes.length,stepsCount:t.length}),ff(e,s,a,o);const l=[...t].sort((N,I)=>new Date(N.createdAt).getTime()-new Date(I.createdAt).getTime());console.log("[Graph Mapper] Sorted steps:",l.map(N=>({stepId:N.stepId,stepName:N.stepName,attempt:N.attempt,status:N.status,createdAt:N.createdAt})));const{byStepId:d,byFunctionName:c,primitivesByLabel:p,agentNodes:u,toolNodes:f}=df(s.nodes);console.log("[Graph Mapper] Graph nodes by stepId:",{allGraphNodes:s.nodes.map(N=>({id:N.id,stepId:N.data.stepId,normalizedStepId:N.data.stepId?_r(N.data.stepId):void 0,nodeKind:N.data.nodeKind})),nodesByStepId:Array.from(d.entries()).map(([N,I])=>({stepId:N,nodeIds:I.map(E=>E.id)}))});const g=new Map;let y=[],j=null,b=null;for(let N=0;N<=l.length;N++){const I=l[N];if(!I||I.stepId!==j){if(y.length>0&&b){const x=pf(y,b,d,c,g,o,a);x&&(i=x)}I&&(y=[I],j=I.stepId,b=I.stepName)}else y.push(I)}const v=hf(r,p,o,a);v&&(i=v),gf(e,l,u,f,o,a,s.nodes),xf(s,o,a,e),mf(e,s,a,o);const h=uf(a,s,o),k={runId:e.runId,status:e.status,nodeExecutions:o,edgeTraversals:h,currentNode:i,executionPath:a};return console.log("[Graph Mapper] Mapping complete:",{executionPath:a,nodeExecutionsCount:o.size,nodeExecutions:Array.from(o.entries()).map(([N,I])=>{var E;return{nodeId:N,executionCount:I.length,latestStatus:(E=I[I.length-1])==null?void 0:E.status}})}),k}const Gt=4;function yf(e,t,r,s){const[o,a]=m.useState([]),[i,l]=m.useState(!1),[d,c]=m.useState(null),p=m.useRef(null),u=m.useRef(0);return m.useEffect(()=>{if(a([]),c(null),u.current=0,!t){l(!1);return}let f=!0;const g=new AbortController;p.current=g,l(!0);const y=Ri();return(async()=>{try{const b=await tu(e,t,void 0,g.signal),v=s?await Oi(s):void 0,h=b.getReader();let k=new Uint8Array(0);const N=I=>{const E=new Uint8Array(k.length+I.length);E.set(k,0),E.set(I,k.length),k=E};for(;!g.signal.aborted;){const{value:I,done:E}=await h.read();if(E){f&&l(!1);break}for(N(I);k.length>=Gt;){const w=new DataView(k.buffer,k.byteOffset,k.byteLength).getUint32(0,!1);if(k.length<Gt+w)break;const S=k.slice(Gt,Gt+w);k=k.slice(Gt+w);try{const{format:T,payload:C}=Ti(S);let A;if(T===Ei.ENCRYPTED){if(!v){f&&(c("This stream is encrypted. Click Decrypt to view."),l(!1)),h.cancel().catch(()=>{});return}A=await Hi(v,C)}else A=S;const R=Ai(A,y);if(f&&R!==void 0&&R!==null){const F=u.current++,$=typeof R=="string"?R:JSON.stringify(R,null,2);a(M=>[...M,{id:F,text:$}])}}catch(T){console.error("Failed to process stream frame:",T)}}}}catch(b){if(g.signal.aborted)return;f&&(c(b instanceof Error?b.message:String(b)),l(!1))}})(),()=>{f=!1,p.current&&p.current.abort()}},[e,t,r,s]),{chunks:o,isLive:i,error:d}}function bf({hasError:e,errorMessage:t}){return n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(Js,{children:[n.jsx(Qs,{asChild:!0,children:n.jsxs("div",{className:"flex items-center gap-1.5",children:[n.jsx("div",{className:`w-2 h-2 rounded-full ${e?"bg-red-500":"bg-green-500 animate-pulse"}`}),n.jsx("span",{className:`text-xs $
44
- hasError
45
- ? 'text-red-600 dark:text-red-400'
46
- : 'text-muted-foreground'`,children:e?"Error":"Live"})]})}),n.jsx(eo,{children:n.jsx("p",{children:e?`Error updating data: ${t}`:`Content updates every ${Di/1e3} seconds`})})]})})}function Ls(e){return e==="retrying"?"running":e}function wf({data:e,selected:t}){var s,o,a,i;const r=e;return n.jsxs("div",{className:`relative ${r.className||""}`,style:{borderWidth:((s=r.nodeStyle)==null?void 0:s.borderWidth)??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:(o=r.nodeStyle)==null?void 0:o.backgroundColor,borderColor:((a=r.nodeStyle)==null?void 0:a.borderColor)??"#9ca3af",opacity:(i=r.nodeStyle)==null?void 0:i.opacity,boxShadow:t?"0 0 0 2px rgba(168, 85, 247, 0.5)":void 0},children:[r.label,n.jsx(et,{type:"target",position:tt.Top,className:"!bg-purple-500"}),n.jsx(et,{type:"source",position:tt.Bottom,className:"!bg-purple-500"}),n.jsx(et,{type:"source",position:tt.Left,id:"loop-out",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"30%"}}),n.jsx(et,{type:"target",position:tt.Left,id:"loop-in",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"70%"}})]})}function Nf({data:e,selected:t}){var a,i,l,d;const r=e,s=r.nodeKind==="workflow_start",o=r.nodeKind==="workflow_end";return n.jsxs("div",{className:`relative ${r.className||""}`,style:{borderWidth:((a=r.nodeStyle)==null?void 0:a.borderWidth)??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:(i=r.nodeStyle)==null?void 0:i.backgroundColor,borderColor:((l=r.nodeStyle)==null?void 0:l.borderColor)??"#9ca3af",opacity:(d=r.nodeStyle)==null?void 0:d.opacity,boxShadow:t?"0 0 0 2px rgba(59, 130, 246, 0.35)":void 0},children:[r.label,!s&&n.jsx(et,{type:"target",position:tt.Top,className:"!bg-muted"}),!o&&n.jsx(et,{type:"source",position:tt.Bottom,className:"!bg-muted"})]})}function jf({data:e,selected:t}){var o,a,i;const r=e,s=160;return n.jsxs("div",{className:`relative flex items-center justify-center ${r.className||""}`,style:{width:s,height:s},children:[n.jsx("div",{style:{width:s*.7,height:s*.7,transform:"rotate(45deg)",borderWidth:2,borderStyle:"solid",borderRadius:4,backgroundColor:(o=r.nodeStyle)==null?void 0:o.backgroundColor,borderColor:((a=r.nodeStyle)==null?void 0:a.borderColor)??"#ef4444",opacity:(i=r.nodeStyle)==null?void 0:i.opacity,boxShadow:t?"0 0 0 2px rgba(239, 68, 68, 0.5)":void 0}}),n.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-auto",style:{fontSize:11,fontWeight:600,padding:s*.25},title:typeof r.label=="string"?r.label:void 0,children:n.jsx("span",{className:"text-center line-clamp-3 overflow-hidden",children:r.label})}),n.jsx(et,{type:"target",position:tt.Top,className:"!bg-red-500"}),n.jsx(et,{type:"source",position:tt.Bottom,id:"bottom",className:"!bg-red-500"}),n.jsx(et,{type:"source",position:tt.Left,id:"left",className:"!bg-red-500"}),n.jsx(et,{type:"source",position:tt.Right,id:"right",className:"!bg-red-500"})]})}const kf={loopNode:wf,parallelGroup:qa,executionNode:Nf,diamondNode:jf},If=Ka(ti);function Sf(e,t){const r=Qa(e);if(!t||t.length===0)return{color:"hsl(var(--card-foreground))",backgroundColor:r,borderColor:"#9ca3af",opacity:.4};const s=t[t.length-1];let o="#9ca3af",a=2;switch(s.status){case"completed":o="#22c55e";break;case"failed":o="#ef4444",a=3;break;case"running":o="#3b82f6",a=2;break;case"retrying":o="#f97316";break;case"cancelled":o="#eab308";break;case"pending":o="#9ca3af";break}return{color:"hsl(var(--card-foreground))",backgroundColor:r,borderColor:o,borderWidth:a}}function Os(e,t,r){const s=n.jsxs("div",{className:"flex items-start gap-2 w-full overflow-hidden",children:[n.jsx("div",{className:"flex-shrink-0",children:ei(e.nodeKind,e.label)}),n.jsx("span",{className:"text-sm font-medium break-words whitespace-normal leading-tight flex-1 min-w-0",children:e.label})]});if(!r||r.length===0)return s;const o=r[r.length-1],a=r.length,i=a>1;return i||o.duration&&o.duration>0?n.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[s,n.jsxs("div",{className:"flex flex-wrap gap-1 text-xs",children:[i&&n.jsxs(Sr,{variant:"outline",className:"text-xs px-1.5 py-0 border-orange-500 text-orange-700 dark:text-orange-300",children:["↻ ",a,"x"]}),o.duration&&o.duration>0&&n.jsxs(Sr,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-black/10 dark:bg-white/15 border-0",children:["⏱ ",At(o.duration,!0)]})]})]}):s}const Sa={...Xa};function Hs(e,t){var d,c,p;const{nodes:r,groupNodes:s}=Ks(e,Sa),o=new Map,a=new Map;for(const u of s)u.id.startsWith("group_")&&a.set(u.id,u.position);for(const u of r){const f=(d=u.metadata)!=null&&d.parallelGroupId?`group_${u.metadata.parallelGroupId}`:null;f&&a.has(f)&&o.set(u.id,f)}const i=[],l=s.filter(u=>u.id.startsWith("group_"));for(const u of l)i.push({id:u.id,type:"parallelGroup",position:u.position,style:{...u.style,cursor:"grab",zIndex:-1},data:u.data,selectable:!0,draggable:!0});for(const u of r){const f=t==null?void 0:t.nodeExecutions.get(u.id),g=Sf(u.data.nodeKind,f),y=(t==null?void 0:t.currentNode)===u.id,j=!!((c=u.metadata)!=null&&c.loopId),b=!!((p=u.metadata)!=null&&p.loopIsAwait),v=u.data.nodeKind==="conditional",h=v?"diamondNode":j?"loopNode":"executionNode",k=o.get(u.id);let N=u.position;if(k){const E=a.get(k);E&&(N={x:u.position.x-E.x,y:u.position.y-E.y})}const I=y?"animate-pulse-subtle":"";j?i.push({id:u.id,type:h,position:N,parentId:k,extent:k?"parent":void 0,expandParent:!0,data:{...u.data,label:Os(u.data,u.metadata,f),executions:f,isLoopNode:!0,isAwaitLoop:b,nodeStyle:g,className:I}}):v?i.push({id:u.id,type:h,position:N,parentId:k,extent:k?"parent":void 0,expandParent:!0,data:{...u.data,label:u.data.label,executions:f,nodeStyle:g,className:I}}):i.push({id:u.id,type:h,position:N,parentId:k,extent:k?"parent":void 0,expandParent:!0,data:{...u.data,label:Os(u.data,u.metadata,f),executions:f,nodeStyle:g,className:I},style:{width:220}})}return i}function Fs(e,t){const{additionalEdges:r}=Ks(e,Sa),o=[...e.edges.map(i=>i.type==="loop"?{...i,id:`loop_back_${i.source}_${i.target}`,isOriginal:!0}:{...i,isOriginal:!0}),...r.map(i=>({...i,isOriginal:!1}))];return Ja(o,e.nodes).map(i=>{if(i.type==="selfLoop")return{id:i.id,source:i.source,target:i.target,sourceHandle:i.sourceHandle,targetHandle:i.targetHandle,type:"selfLoop",label:i.label,markerEnd:{type:Wn.ArrowClosed,width:12,height:12,color:"#a855f7"}};let l=t==null?void 0:t.edgeTraversals.get(i.id);if(!l&&i.isConsolidated&&i.originalEdgeIds)for(const x of i.originalEdgeIds){const w=t==null?void 0:t.edgeTraversals.get(x);if(w&&w.traversalCount>0){l=w;break}}const d=l&&l.traversalCount>0,c=!!t,p=l!=null&&l.timings.length?l.timings.reduce((x,w)=>x+w,0)/l.timings.length:void 0;let u="bezier",f,g=i.label,y=!1;switch(i.type){case"parallel":u="smoothstep",f="4,4",g=void 0;break;case"loop":u="step",f="8,4";break;case"conditional":u="smoothstep",f="8,4",y=!0;break;default:u="bezier"}const b=d?"#22c55e":"#6b7280",v=d?void 0:f,h=c&&!d?.35:1,k=d?2.5:1,N=y?"#ffffff":"#6b7280",I=y?"#374151":"#f3f4f6",E=y?"#4b5563":"#d1d5db";return{id:i.id,source:i.source,target:i.target,type:u,animated:d&&(t==null?void 0:t.status)==="running",label:l&&l.traversalCount>1?n.jsxs("div",{className:"flex flex-col items-center gap-0.5",children:[n.jsxs(Sr,{variant:"secondary",className:"text-xs px-1.5 py-0",children:[l.traversalCount,"×"]}),p&&p>0&&n.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["~",At(p,!0)]})]}):g,labelStyle:{fill:N,fontWeight:500,fontSize:"11px"},labelBgStyle:{fill:I,fillOpacity:.95,stroke:E,strokeWidth:1},labelBgPadding:[4,6],labelBgBorderRadius:4,markerEnd:{type:Wn.ArrowClosed,width:d?14:10,height:d?14:10,color:b},style:{strokeWidth:k,stroke:b,opacity:h,strokeDasharray:v}}})}function Cf({selectedNode:e,env:t,onClose:r}){const{node:s,executions:o,stepId:a,runId:i}=e,l=o[o.length-1],d=o.length>1,{data:c,loading:p}=$o(t??{},"step",a??"",{runId:i}),u=(c==null?void 0:c.input)??(l==null?void 0:l.input),f=(c==null?void 0:c.output)??(l==null?void 0:l.output),g=(c==null?void 0:c.error)??(l==null?void 0:l.error);return n.jsxs("div",{className:"h-full flex flex-col bg-background border-l",children:[n.jsxs("div",{className:"flex items-center justify-between gap-2 px-3 py-2 border-b flex-none",children:[n.jsx("span",{className:"text-xs font-medium truncate flex-1",title:s.data.label,children:s.data.label}),n.jsxs("div",{className:"flex items-center gap-2 flex-none",children:[(l==null?void 0:l.duration)!==void 0&&l.duration>0&&n.jsx("span",{className:"text-[10px] font-mono text-muted-foreground bg-muted px-1.5 py-0.5 rounded",children:At(l.duration)}),n.jsx("div",{className:"w-px h-4 bg-border"}),n.jsx("button",{type:"button",onClick:r,className:"p-1 rounded hover:bg-muted transition-colors","aria-label":"Close panel",children:n.jsx(Gs,{className:"h-4 w-4 text-muted-foreground"})})]})]}),n.jsxs("div",{className:"flex-1 overflow-y-auto p-3 min-h-0",children:[n.jsxs("div",{className:"flex flex-col divide-y rounded-lg border overflow-hidden mb-3",children:[n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"type"}),n.jsx("span",{className:"text-[11px] font-mono",children:s.data.nodeKind})]}),l&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"status"}),n.jsx(rn,{status:Ls(l.status)})]}),l.duration!==void 0&&l.duration>0&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"duration"}),n.jsx("span",{className:"text-[11px] font-mono",children:At(l.duration)})]}),d&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"attempts"}),n.jsx("span",{className:"text-[11px] font-mono",children:o.length})]}),l.startedAt&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"startedAt"}),n.jsx("span",{className:"text-[11px] font-mono",children:new Date(l.startedAt).toLocaleString()})]}),l.completedAt&&n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5",children:[n.jsx("span",{className:"text-[11px] font-medium text-muted-foreground",children:"completedAt"}),n.jsx("span",{className:"text-[11px] font-mono",children:new Date(l.completedAt).toLocaleString()})]})]})]}),p&&a&&n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-3",children:[n.jsx(Nn,{className:"h-3 w-3 animate-spin"}),n.jsx("span",{children:"Loading step data..."})]}),u!==void 0&&n.jsxs("details",{className:"group mb-3",children:[n.jsxs("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[n.jsx("span",{className:"font-medium",children:"Input"}),n.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",Array.isArray(u)?u.length:1," args)"]})]}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),n.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:n.jsx("code",{children:JSON.stringify(u,null,2)})})]})]}),f!==void 0&&n.jsxs("details",{className:"group mb-3",children:[n.jsx("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:n.jsx("span",{className:"font-medium",children:"Output"})}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),n.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border p-2.5 bg-muted/30 max-h-64 overflow-y-auto",children:n.jsx("code",{children:JSON.stringify(f,null,2)})})]})]}),g&&n.jsxs("details",{className:"group mb-3",open:!0,children:[n.jsx("summary",{className:"cursor-pointer rounded-md border border-red-300 bg-red-50 dark:bg-red-950/20 px-2.5 py-1.5 text-xs hover:brightness-95",children:n.jsx("span",{className:"font-medium text-red-600 dark:text-red-400",children:"Error"})}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-red-300"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-red-300"}),n.jsx("pre",{className:"text-[11px] overflow-x-auto rounded-md border border-red-200 p-2.5 bg-red-50 dark:bg-red-950/20 text-red-700 dark:text-red-300 whitespace-pre-wrap max-h-64 overflow-y-auto",children:n.jsx("code",{children:typeof g=="object"?JSON.stringify(g,null,2):String(g)})})]})]}),d&&n.jsxs("details",{className:"group",children:[n.jsxs("summary",{className:"cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 bg-muted/50",children:[n.jsx("span",{className:"font-medium",children:"Attempt History"}),n.jsxs("span",{className:"text-muted-foreground ml-1",children:["(",o.length," attempts)"]})]}),n.jsxs("div",{className:"relative pl-6 mt-3",children:[n.jsx("div",{className:"absolute left-3 -top-3 w-px h-3 bg-border"}),n.jsx("div",{className:"absolute left-3 top-0 w-3 h-3 border-l border-b rounded-bl-lg border-border"}),n.jsx("div",{className:"flex flex-col divide-y rounded-md border overflow-hidden",children:o.map(y=>n.jsxs("div",{className:"flex items-center justify-between px-2.5 py-1.5 text-[11px]",children:[n.jsxs("span",{className:"text-muted-foreground",children:["Attempt ",y.attemptNumber]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(rn,{status:Ls(y.status)}),y.duration!==void 0&&y.duration>0&&n.jsx("span",{className:"font-mono text-muted-foreground",children:At(y.duration)})]})]},y.attemptNumber))})]})]})]})]})}function Tf({workflow:e,execution:t,env:r,onNodeClick:s}){const[o,a]=m.useState(null),i=320,l=m.useMemo(()=>Hs(e,t),[e,t]),d=m.useMemo(()=>Fs(e,t),[e,t]),[c,p,u]=Va(l),[f,g,y]=Ga(d);m.useEffect(()=>{p(v=>{const h=Hs(e,t),k=new Map(v.map(N=>[N.id,N.position]));return h.map(N=>({...N,position:k.get(N.id)??N.position}))}),g(Fs(e,t))},[e,t,p,g]);const j=m.useCallback((v,h)=>{const k=e.nodes.find(N=>N.id===h.id);if(k){const N=h.data.executions||[],I=N[N.length-1];a({nodeId:h.id,node:k,executions:N,stepId:I==null?void 0:I.stepId,runId:t==null?void 0:t.runId}),s&&N.length>0&&s(h.id,N)}},[e.nodes,t==null?void 0:t.runId,s]),b=m.useCallback(()=>{a(null)},[]);return n.jsxs("div",{className:"h-full w-full border rounded-lg bg-background relative overflow-hidden flex",children:[n.jsx("div",{className:"h-full flex-1 min-w-0",style:{width:o?`calc(100% - ${i}px)`:"100%"},children:n.jsxs(Ua,{nodes:c,edges:f,onNodesChange:u,onEdgesChange:y,onNodeClick:j,nodeTypes:kf,edgeTypes:If,fitView:!0,minZoom:.1,maxZoom:2,defaultViewport:{x:0,y:0,zoom:1},proOptions:{hideAttribution:!0},children:[n.jsx(Za,{}),n.jsx(Ya,{}),n.jsx(zn,{position:"top-left",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-2 text-xs",children:n.jsxs("div",{className:"space-y-1.5",children:[n.jsx("div",{className:"font-semibold text-[10px] text-muted-foreground mb-1",children:"Status"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-green-500 bg-background"}),n.jsx("span",{children:"Completed"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-red-500 bg-background"}),n.jsx("span",{children:"Failed"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-blue-500 bg-background"}),n.jsx("span",{children:"Running"})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-yellow-500 bg-background"}),n.jsx("span",{children:"Cancelled"})]}),n.jsxs("div",{className:"flex items-center gap-2 opacity-50",children:[n.jsx("div",{className:"w-6 h-4 rounded border-2 border-gray-400 bg-background"}),n.jsx("span",{children:"Pending"})]})]})}),t&&n.jsxs(zn,{position:"top-right",className:"bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/60 border rounded-lg p-3 text-xs space-y-1.5",children:[n.jsx("div",{className:"font-semibold text-sm",children:"Execution"}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-muted-foreground",children:"Status:"}),n.jsx(Sr,{variant:t.status==="completed"?"default":t.status==="failed"?"destructive":t.status==="cancelled"?"outline":"secondary",className:"text-xs",children:t.status})]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx("span",{className:"text-muted-foreground",children:"Progress:"}),n.jsxs("span",{className:"font-mono",children:[t.executionPath.length," / ",e.nodes.length]})]})]})]})}),o&&n.jsx("div",{className:"h-full flex-none",style:{width:i},children:n.jsx(Cf,{selectedNode:o,env:r,onClose:b})})]})}function Ef({run:e,allEvents:t,env:r}){const{manifest:s,loading:o,error:a}=ui(),i=m.useMemo(()=>{var g;if(!s||!e.workflowName)return null;const c=String(e.workflowName).trim(),p=s.workflows[c];if(p)return p;const u=(g=xt(c))==null?void 0:g.shortName;return Object.values(s.workflows).find(y=>{var j;return y.workflowId===c||y.workflowName===c?!0:u?((j=xt(y.workflowName))==null?void 0:j.shortName)===u:!1})??null},[s,e.workflowName]),l=m.useMemo(()=>{if(!t)return[];const c=new Map;for(const p of t)if(p.eventType.startsWith("step_")&&p.correlationId){const u=c.get(p.correlationId);u?u.push(p):c.set(p.correlationId,[p])}return Array.from(c.values()).map(Wo).filter(p=>p!==null)},[t]),d=m.useMemo(()=>!i||!e.runId?null:vf(e,l,t||[],i),[i,e,l,t]);return o?n.jsxs("div",{className:"flex items-center justify-center w-full h-full",children:[n.jsx(Nn,{className:"h-8 w-8 animate-spin text-muted-foreground"}),n.jsx("span",{className:"ml-4 text-muted-foreground",children:"Loading workflow graph..."})]}):a?n.jsx("div",{className:"flex items-center justify-center w-full h-full p-4",children:n.jsxs(nn,{variant:"destructive",className:"max-w-lg",children:[n.jsx(kr,{className:"h-4 w-4"}),n.jsx(sn,{children:"Error Loading Workflow Graph"}),n.jsx(on,{children:a.message})]})}):i?n.jsx(Tf,{workflow:i,execution:d||void 0,env:r}):n.jsx("div",{className:"flex items-center justify-center w-full h-full",children:n.jsxs(nn,{className:"max-w-lg",children:[n.jsx(kr,{className:"h-4 w-4"}),n.jsx(sn,{children:"Workflow Graph Not Found"}),n.jsx(on,{children:"Could not find the workflow graph for this run. The workflow may have been deleted or the graph manifest may need to be regenerated."})]})})}function Af({runId:e,selectedId:t}){var ft;const r=Ca(),[s]=zs(),{serverConfig:o}=Mi(),[a,i]=m.useState(!1),[l,d]=m.useState(!1),[c,p]=m.useState(!1),[u,f]=m.useState(!1),g=m.useMemo(()=>({}),[]),y=s.get("tab")||"trace",j=s.get("streamId"),b=m.useCallback(Q=>{const pe=new URLSearchParams(s.toString());for(const[we,Re]of Object.entries(Q))Re===null?pe.delete(we):pe.set(we,Re);r(`?${pe.toString()}`,{preventScrollReset:!0})},[r,s]),v=m.useCallback(Q=>{b(Q==="trace"||Q==="graph"?{tab:Q,streamId:null}:{tab:Q})},[b]),h=m.useCallback(Q=>{b({streamId:Q})},[b]),k=m.useCallback(Q=>{b({tab:"streams",streamId:Q})},[b]),N=m.useCallback(async(Q,pe)=>ri(g,Q,{correlationIds:[pe]}),[g]),I=m.useRef(null),E=m.useCallback(async(Q,pe)=>{await ni(g,Q,pe)},[g]),x=m.useCallback(async Q=>{const{error:pe,result:we}=await Qe($n(g,Q.runId,Q.eventId,"all"));if(pe)throw pe;const Re=I.current?await an(we,I.current):it(we);return"eventData"in Re?Re.eventData:null},[g]),w=m.useCallback(async(Q,pe)=>{const{error:we,result:Re}=await Qe($n(g,e,pe,"all"));if(we)throw we;const Ge=I.current?await an(Re,I.current):it(Re);return"eventData"in Ge?Ge.eventData:null},[g,e]),S=o.backendId==="local"||o.backendId==="@workflow/world-local",{run:T,events:C,loading:A,error:R,update:F,loadMoreTraceData:$,hasMoreTraceData:M,isLoadingMoreTraceData:D}=Qd(g,e,{live:!0}),P=T??{},[K,B]=m.useState(null);I.current=K;const[_,W]=m.useState(null),{data:L,loading:G,error:V,refresh:J}=$o(g,(_==null?void 0:_.resource)??"run",(_==null?void 0:_.resourceId)??"",{runId:_==null?void 0:_.runId,enabled:!!(_!=null&&_.resource&&(_!=null&&_.resourceId)&&_.resource!=="hook"),encryptionKey:K??void 0}),de=m.useCallback(async()=>{if(K){J();return}const{error:Q,result:pe}=await Qe(_i(g,e));if(Q){fe.error(`Failed to fetch encryption key: ${Q.message}`);return}if(!pe){fe.error("Encryption is not configured for this deployment.");return}B(pe)},[K,g,e,J]),H=m.useCallback(Q=>{W(Q)},[]),{streams:Y,loading:X,error:ge}=su(g,e),{chunks:Ae,isLive:ee,error:ae}=yf(g,j,e,K),ve=()=>{p(!0)},be=async()=>{if(!a)try{i(!0),p(!1),await ci(g,e),await F(),fe.success("Run cancelled successfully")}catch(Q){console.error("Failed to cancel run:",Q),fe.error("Failed to cancel run",{description:Q instanceof Error?Q.message:"An unknown error occurred"})}finally{i(!1)}},le=()=>{f(!0)},ue=async()=>{if(!l)try{d(!0),f(!1);const Q=await di(g,P.runId);fe.success("New run started successfully",{description:`Run ID: ${Q}`}),r(`/run/${Q}`)}catch(Q){console.error("Failed to re-run workflow:",Q),fe.error("Failed to start new run",{description:Q instanceof Error?Q.message:"An unknown error occurred"})}finally{d(!1),f(!1)}};if(R&&!T)return n.jsxs(nn,{variant:"destructive",className:"m-4",children:[n.jsx(kr,{className:"h-4 w-4"}),n.jsx(sn,{children:"Error loading workflow run"}),n.jsx(on,{children:R.message})]});const Se=(ft=xt(P.workflowName))==null?void 0:ft.shortName;return n.jsxs(n.Fragment,{children:[n.jsx(Ss,{open:c,onOpenChange:p,children:n.jsxs(Cs,{children:[n.jsxs(Ts,{children:[n.jsx(As,{children:"Cancel Workflow Run?"}),n.jsx(Rs,{children:"This will stop the workflow execution immediately, and no further steps will be executed. Partial workflow execution may occur. Are you sure you want to cancel the run?"})]}),n.jsxs(Es,{children:[n.jsx(Ms,{children:"Keep Running"}),n.jsx(Ds,{onClick:be,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Run"})]})]})}),n.jsx(Ss,{open:u,onOpenChange:f,children:n.jsxs(Cs,{children:[n.jsxs(Ts,{children:[n.jsx(As,{children:"Replay Run?"}),n.jsx(Rs,{children:"This can potentially re-run code that is meant to only execute once. Are you sure you want to replay the workflow run?"})]}),n.jsxs(Es,{children:[n.jsx(Ms,{children:"Cancel"}),n.jsx(Ds,{onClick:ue,children:"Replay Run"})]})]})}),n.jsxs("div",{className:"flex flex-col h-[calc(100vh-97px)]",children:[n.jsxs("div",{className:"flex-none space-y-4",children:[n.jsx(nf,{children:n.jsxs(sf,{children:[n.jsx(_s,{children:n.jsx(of,{asChild:!0,children:n.jsx(Ta,{to:"/",children:"Runs"})})}),n.jsx(lf,{}),n.jsx(_s,{children:n.jsx(af,{className:"font-mono text-xs",children:e})})]})}),n.jsxs("div",{className:"space-y-4 p-6 border rounded-lg",children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsx("div",{className:"mb-4",children:n.jsx("h1",{className:"text-xl font-semibold",children:Se||n.jsx(Ct,{className:"w-[260px] h-[28px]"})})}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx(bf,{hasError:!1,errorMessage:""}),n.jsx(si,{env:g,runId:e,runStatus:P.status,events:C,eventsLoading:A,loading:A,onRerunClick:le,onCancelClick:ve,callbacks:{onSuccess:F}})]})]}),n.jsxs("div",{className:"flex items-start gap-8",children:[n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Status"}),P.status?n.jsx(rn,{status:P.status,context:P}):n.jsx(Ct,{className:"w-[55px] h-[24px]"})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Duration"}),n.jsx("div",{className:"text-xs",children:P.runId?P.startedAt?(()=>{const Q=(P.completedAt?new Date(P.completedAt).getTime():Date.now())-new Date(P.startedAt).getTime(),pe=Math.floor(Q/1e3);if(pe<60)return`${pe}s`;const we=Math.floor(pe/60),Re=pe%60;if(we<60)return Re>0?`${we}m ${Re}s`:`${we}m`;const Ge=Math.floor(we/60),Ye=we%60;return Ye>0?`${Ge}h ${Ye}m`:`${Ge}h`})():"-":n.jsx(Ct,{className:"w-[60px] h-[20px]"})})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Run ID"}),P.runId?n.jsx(oi,{text:P.runId,children:n.jsx("div",{className:"text-xs mt-0.5 font-mono",children:P.runId})}):n.jsx(Ct,{className:"w-[280px] h-[20px]"})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Queued"}),P.createdAt?n.jsx("div",{className:"text-xs",children:n.jsx(fr,{date:P.createdAt})}):n.jsx(Ct,{className:"w-[110px] h-[20px]"})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Started"}),n.jsx("div",{className:"text-xs",children:P.runId?P.startedAt?n.jsx(fr,{date:P.startedAt}):"-":n.jsx(Ct,{className:"w-[110px] h-[20px]"})})]}),n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsx("div",{className:"text-xs text-muted-foreground",children:"Completed"}),n.jsx("div",{className:"text-xs",children:P.runId?P.completedAt?n.jsx(fr,{date:P.completedAt}):"-":n.jsx(Ct,{className:"w-[110px] h-[20px]"})})]}),P.expiredAt!=null&&n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs(Js,{children:[n.jsx(Qs,{asChild:!0,children:n.jsxs("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",n.jsx(Pi,{className:"w-3 h-3"})]})}),n.jsx(eo,{children:n.jsx("p",{children:"The storage data for this run has expired and is no longer available."})})]}),n.jsx("div",{className:"text-xs",children:n.jsx(fr,{date:P.expiredAt})})]})]})]})]}),n.jsx("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:n.jsxs(ai,{value:y,onValueChange:Q=>v(Q),className:"flex-1 flex flex-col min-h-0",children:[n.jsxs(ii,{className:"mb-4 flex-none",children:[n.jsxs(mr,{value:"trace",className:"gap-2",children:[n.jsx(Gr,{className:"h-4 w-4"}),"Trace"]}),S&&n.jsxs(mr,{value:"graph",className:"gap-2",children:[n.jsx(li,{className:"h-4 w-4"}),"Graph"]}),n.jsxs(mr,{value:"events",className:"gap-2",children:[n.jsx(Gr,{className:"h-4 w-4"}),"Events"]}),n.jsxs(mr,{value:"streams",className:"gap-2",children:[n.jsx(Gr,{className:"h-4 w-4"}),"Streams"]})]}),n.jsx(pr,{value:"trace",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ht,{title:"Failed to load trace viewer",children:n.jsx("div",{className:"h-full",children:n.jsx(Ud,{error:R,events:C,run:P,isLoading:A,spanDetailData:L,spanDetailLoading:G,spanDetailError:V,onSpanSelect:H,onStreamClick:k,onWakeUpSleep:N,onResolveHook:E,onLoadEventData:w,onLoadMoreSpans:$,hasMoreSpans:M,isLoadingMoreSpans:D,encryptionKey:K??void 0,onDecrypt:de})})})}),n.jsx(pr,{value:"events",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ht,{title:"Failed to load events list",children:n.jsx("div",{className:"h-full",children:n.jsx(Ec,{events:C,run:P,onLoadEventData:x,encryptionKey:K??void 0,isLoading:A})})})}),n.jsx(pr,{value:"streams",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ht,{title:"Failed to load stream data",children:n.jsxs("div",{className:"h-full flex gap-4",children:[n.jsxs("div",{className:"w-64 flex-shrink-0 border rounded-lg overflow-hidden",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-background-100)"},children:[n.jsxs("div",{className:"px-3 py-2 border-b text-xs font-medium",style:{borderColor:"var(--ds-gray-300)",color:"var(--ds-gray-900)"},children:["Streams (",Y.length,")"]}),n.jsx("div",{className:"overflow-auto max-h-[calc(100vh-400px)]",children:X?n.jsx("div",{className:"p-4 flex items-center justify-center",children:n.jsx(Nn,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):ge?n.jsx("div",{className:"p-4 text-xs text-destructive",children:ge.message}):Y.length===0?n.jsx("div",{className:"p-4 text-xs",style:{color:"var(--ds-gray-600)"},children:"No streams found for this run"}):Y.map(Q=>n.jsx("button",{type:"button",onClick:()=>h(Q),className:"w-full text-left px-3 py-2 text-xs font-mono truncate hover:bg-accent transition-colors",style:{backgroundColor:j===Q?"var(--ds-gray-200)":"transparent",color:"var(--ds-gray-1000)"},title:Q,children:Q},Q))})]}),n.jsx("div",{className:"flex-1 min-w-0",children:j?n.jsx(Li,{streamId:j,chunks:Ae,isLive:ee,error:ae}):n.jsx("div",{className:"h-full flex items-center justify-center rounded-lg border",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:n.jsx("div",{className:"text-sm",style:{color:"var(--ds-gray-600)"},children:Y.length>0?"Select a stream to view its data":"No streams available"})})})]})})}),S&&n.jsx(pr,{value:"graph",className:"mt-0 flex-1 min-h-0",children:n.jsx(Ht,{title:"Failed to load execution graph",children:n.jsx("div",{className:"h-full min-h-[500px]",children:n.jsx(Ef,{run:P,allEvents:C,env:g})})})})]})})]})]})}const Lf=Ea(function(){const t=Aa(),[r]=zs(),s=t.runId,o=r.get("stepId"),a=r.get("eventId"),i=r.get("hookId"),l=o||a||i||void 0;return n.jsx(Ht,{title:"Failed to load run details",children:n.jsx(Af,{runId:s,selectedId:l})})});export{Lf as default};