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

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/README.md +5 -0
  2. package/build/client/assets/{highlighted-body-B3W2YXNL-BlI_3W94.js → highlighted-body-B3W2YXNL-DKVOCXmq.js} +1 -1
  3. package/build/client/assets/home-MMGoJh7w.js +35 -0
  4. package/build/client/assets/{manifest-ef94afe1.js → manifest-678c3cbf.js} +1 -1
  5. package/build/client/assets/{mermaid-3ZIDBTTL-BhkyG8Sq.js → mermaid-3ZIDBTTL-BPJg8vAL.js} +11 -11
  6. package/build/client/assets/root-BMRA92qM.css +1 -0
  7. package/build/client/assets/{root-B2fanH6r.js → root-DQpGl57T.js} +1 -1
  8. package/build/client/assets/run-detail-DZDSfYol.js +46 -0
  9. package/build/client/assets/server-build-ClfhJhzu.css +1 -0
  10. package/build/client/assets/{use-workflow-graph-D6xsvBGu.js → use-workflow-graph-B8LKXrpA.js} +1 -1
  11. package/build/server/assets/{app-YwmyVuwT.js → app-Bdxmgv4c.js} +1 -1
  12. package/build/server/assets/{highlighted-body-B3W2YXNL-Dqsnck2u.js → highlighted-body-B3W2YXNL-uEj5-2nD.js} +2 -2
  13. package/build/server/assets/{mermaid-3ZIDBTTL-mfJ74Epj.js → mermaid-3ZIDBTTL-BvjkIiuk.js} +2 -2
  14. package/build/server/assets/{server-build-B3ijdJBL.js → server-build-CKAakcyN.js} +972 -862
  15. package/build/server/assets/{token-CWWXwMh8.js → token-CNug9NIq.js} +3 -3
  16. package/build/server/assets/{token-DJXheGCg.js → token-DLqvw7I2.js} +2 -2
  17. package/build/server/assets/{token-util-CvLiUUQD.js → token-util-DMDYM1rE.js} +2 -2
  18. package/build/server/assets/{token-util-REQ15piK.js → token-util-DgFyM3ow.js} +1 -1
  19. package/build/server/assets/{token-util-l0RNhdPG.js → token-util-_HYGsI73.js} +2 -2
  20. package/build/server/index.js +1 -1
  21. package/package.json +6 -8
  22. package/build/client/assets/home-B4MMr7LP.js +0 -35
  23. package/build/client/assets/root-Dr_TuMgh.css +0 -1
  24. package/build/client/assets/run-detail-D40YBNgh.js +0 -41
  25. package/build/client/assets/server-build-CgcbAXmU.css +0 -1
@@ -1,41 +0,0 @@
1
- import{R as Y,j as n,r as m,A as Zo,f as Yo,x as Da,y as Xo,z as Ma,w as _a,C as La}from"./index-DklpUtP3.js";import{U as ir,V as lr,B as bt,j as Jo,q as Qo,Y as Oa,Z as Ha,S as es,R as ts,p as Fa,o as Pa,X as rs,Q as Pt,_ as Ba,G as za,$ as De,u as Nr,W as Et,a0 as Wa,v as mt,a1 as Sr,a2 as $a,t as ns,a3 as Va,s as Ga,a4 as $r,w as Cn,l as Ua,m as Ka,a5 as qa,a6 as Za,a7 as Ya,a8 as Xa,a9 as Ja,aa as Qa,ab as ei,ac as ti,ad as qn,J as Cr,ae as os,af as ri,ag as ni,ah as Zn,ai as it,aj as lt,F as ln,ak as oi,al as si,am as ai,an as ii,r as li,A as cn,C as dn,c as un,d as fn,a as Ct,ao as ci,e as di,b as pr,T as ui,M as fi,N as hr,K as mi,O as gr,y as pi,ap as hi,I as gi}from"./use-workflow-graph-D6xsvBGu.js";import{c as cr,t as he,I as At,J as Me,M as Tr,_ as xi,N as vi,O as at,U as yi,W as bi,X as ss,Y as Dt,Z as dt,$ as re,a0 as wi,a1 as Ni,a2 as Vr,a3 as ze,a4 as xr,a5 as Er,a6 as Bt,a7 as yt,a8 as as,a9 as qt,aa as Gr,ab as Ii,ac as ji,ad as ki,ae as Si,af as Ci,ag as Ti,ah as Ei,ai as mn,aj as _e,ak as is,k as ls,E as pn,al as Ri,am as Ur,i as Kr,F as qr,an as Ai,ao as Tn,z as Nt,ap as Di,d as Ge,aq as cs,ar as Mi,as as _i,at as Li,au as Oi,T as hn,a as gn,b as xn,av as Hi,L as Rr,u as Fi,aw as Yn,ax as Pi,B as Bi,ay as zi}from"./mermaid-3ZIDBTTL-BhkyG8Sq.js";import{importKey as Wi,decrypt as $i}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 Vi=[["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"}]],Gi=cr("circle-question-mark",Vi);/**
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 Ui=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ki=cr("info",Ui);/**
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 qi=[["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"}]],Zr=cr("list",qi);/**
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 Zi=[["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"}]],Yi=cr("lock-open",Zi);/**
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 Xi=[["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"}]],Ji=cr("type",Xi),Hr=0,It=1,Vt=2,ds=4;function Xn(e){return()=>e}function Qi(e){e()}function us(e,t){return r=>e(t(r))}function Jn(e,t){return()=>e(t)}function el(e,t){return r=>e(t,r)}function En(e){return e!==void 0}function tl(...e){return()=>{e.map(Qi)}}function Gt(){}function Fr(e,t){return t(e),e}function rl(e,t){return t(e)}function Ne(...e){return e}function ve(e,t){return e(It,t)}function le(e,t){e(Hr,t)}function Rn(e){e(Vt)}function Se(e){return e(ds)}function X(e,t){return ve(e,el(t,Hr))}function Ye(e,t){const r=e(It,o=>{r(),t(o)});return r}function Qn(e){let t,r;return o=>s=>{t=s,r&&clearTimeout(r),r=setTimeout(()=>{o(t)},e)}}function fs(e,t){return e===t}function we(e=fs){let t;return r=>o=>{e(t,o)||(t=o,r(o))}}function se(e){return t=>r=>{e(r)&&t(r)}}function G(e){return t=>us(t,e)}function st(e){return t=>()=>{t(e)}}function L(e,...t){const r=nl(...t);return((o,s)=>{switch(o){case Vt:Rn(e);return;case It:return ve(e,r(s))}})}function ct(e,t){return r=>o=>{r(t=e(t,o))}}function Mt(e){return t=>r=>{e>0?e--:t(r)}}function ft(e){let t=null,r;return o=>s=>{t=s,!r&&(r=setTimeout(()=>{r=void 0,o(t)},e))}}function de(...e){const t=new Array(e.length);let r=0,o=null;const s=Math.pow(2,e.length)-1;return e.forEach((a,i)=>{const l=Math.pow(2,i);ve(a,d=>{const c=r;r=r|l,t[i]=d,c!==s&&r===s&&o&&(o(),o=null)})}),a=>i=>{const l=()=>{a([i].concat(t))};r===s?l():o=l}}function nl(...e){return t=>e.reduceRight(rl,t)}function ol(e){let t,r;const o=()=>t==null?void 0:t();return function(s,a){switch(s){case It:return a?r===a?void 0:(o(),r=a,t=ve(e,a),t):(o(),Gt);case Vt:o(),r=null;return}}}function F(e){let t=e;const r=fe();return((o,s)=>{switch(o){case Hr:t=s;break;case It:{s(t);break}case ds:return t}return r(o,s)})}function Oe(e,t){return Fr(F(t),r=>X(e,r))}function fe(){const e=[];return((t,r)=>{switch(t){case Hr:e.slice().forEach(o=>{o(r)});return;case Vt:e.splice(0,e.length);return;case It:return e.push(r),()=>{const o=e.indexOf(r);o>-1&&e.splice(o,1)}}})}function Ve(e){return Fr(fe(),t=>X(e,t))}function xe(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:sl(),singleton:r}}const sl=()=>Symbol();function al(e){const t=new Map,r=({constructor:o,dependencies:s,id:a,singleton:i})=>{if(i&&t.has(a))return t.get(a);const l=o(s.map(d=>r(d)));return i&&t.set(a,l),l};return r(e)}function Ee(...e){const t=fe(),r=new Array(e.length);let o=0;const s=Math.pow(2,e.length)-1;return e.forEach((a,i)=>{const l=Math.pow(2,i);ve(a,d=>{r[i]=d,o=o|l,o===s&&le(t,r)})}),function(a,i){switch(a){case Vt:{Rn(t);return}case It:return o===s&&i(r),ve(t,i)}}}function oe(e,t=fs){return L(e,we(t))}function vn(...e){return function(t,r){switch(t){case Vt:return;case It:return tl(...e.map(o=>ve(o,r)))}}}var We=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(We||{});const il={0:"debug",3:"error",1:"log",2:"warn"},ll=()=>typeof globalThis>"u"?window:globalThis,jt=xe(()=>{const e=F(3);return{log:F((t,r,o=1)=>{var s;const a=(s=ll().VIRTUOSO_LOG_LEVEL)!=null?s:Se(e);o>=a&&console[il[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function Lt(e,t,r){return An(e,t,r).callbackRef}function An(e,t,r){const o=Y.useRef(null);let s=i=>{};const a=Y.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 s=i=>{i&&t?(a==null||a.observe(i),o.current=i):(o.current&&(a==null||a.unobserve(o.current)),o.current=null)},{callbackRef:s,ref:o}}function cl(e,t,r,o,s,a,i,l,d){const c=Y.useCallback(f=>{const u=dl(f.children,t,l?"offsetWidth":"offsetHeight",s);let p=f.parentElement;for(;!p.dataset.virtuosoScroller;)p=p.parentElement;const x=p.lastElementChild.dataset.viewportType==="window";let w;x&&(w=p.ownerDocument.defaultView);const I=i?l?i.scrollLeft:i.scrollTop:x?l?w.scrollX||w.document.documentElement.scrollLeft:w.scrollY||w.document.documentElement.scrollTop:l?p.scrollLeft:p.scrollTop,b=i?l?i.scrollWidth:i.scrollHeight:x?l?w.document.documentElement.scrollWidth:w.document.documentElement.scrollHeight:l?p.scrollWidth:p.scrollHeight,g=i?l?i.offsetWidth:i.offsetHeight:x?l?w.innerWidth:w.innerHeight:l?p.offsetWidth:p.offsetHeight;o({scrollHeight:b,scrollTop:Math.max(I,0),viewportHeight:g}),a==null||a(l?eo("column-gap",getComputedStyle(f).columnGap,s):eo("row-gap",getComputedStyle(f).rowGap,s)),u!==null&&e(u)},[e,t,s,a,i,o,l]);return An(c,r,d)}function dl(e,t,r,o){const s=e.length;if(s===0)return null;const a=[];for(let i=0;i<s;i++){const l=e.item(i);if(l.dataset.index===void 0)continue;const d=parseInt(l.dataset.index),c=parseFloat(l.dataset.knownSize),f=t(l,r);if(f===0&&o("Zero-sized element, this should not happen",{child:l},We.ERROR),f===c)continue;const u=a[a.length-1];a.length===0||u.size!==f||u.endIndex!==d-1?a.push({endIndex:d,size:f,startIndex:d}):a[a.length-1].endIndex++}return a}function eo(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,We.WARN),t==="normal"?0:parseInt(t??"0",10)}function ms(e,t,r){const o=Y.useRef(null),s=Y.useCallback(d=>{if(!(d!=null&&d.offsetParent))return;const c=d.getBoundingClientRect(),f=c.width;let u,p;if(t){const x=t.getBoundingClientRect(),w=c.top-x.top;p=x.height-Math.max(0,w),u=w+t.scrollTop}else{const x=i.current.ownerDocument.defaultView;p=x.innerHeight-Math.max(0,c.top),u=c.top+x.scrollY}o.current={offsetTop:u,visibleHeight:p,visibleWidth:f},e(o.current)},[e,t]),{callbackRef:a,ref:i}=An(s,!0,r),l=Y.useCallback(()=>{s(i.current)},[s,i]);return Y.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 Pe=xe(()=>{const e=fe(),t=fe(),r=F(0),o=fe(),s=F(0),a=fe(),i=fe(),l=F(0),d=F(0),c=F(0),f=F(0),u=fe(),p=fe(),x=F(!1),w=F(!1),I=F(!1);return X(L(e,G(({scrollTop:b})=>b)),t),X(L(e,G(({scrollHeight:b})=>b)),i),X(t,s),{deviation:r,fixedFooterHeight:c,fixedHeaderHeight:d,footerHeight:f,headerHeight:l,horizontalDirection:w,scrollBy:p,scrollContainerState:e,scrollHeight:i,scrollingInProgress:x,scrollTo:u,scrollTop:t,skipAnimationFrameInResizeObserver:I,smoothScrollTargetReached:o,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),Qt={lvl:0};function ps(e,t){const r=e.length;if(r===0)return[];let{index:o,value:s}=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:o,value:s}),o=l,s=d}return a.push({end:1/0,start:o,value:s}),a}function ye(e){return e===Qt}function er(e,t){if(!ye(e))return t===e.k?e.v:t<e.k?er(e.l,t):er(e.r,t)}function Je(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 o=Je(e.r,t,r);return o[0]===-1/0?[e.k,e.v]:o}return Je(e.l,t,r)}function $e(e,t,r){return ye(e)?xs(t,r,1):t===e.k?Ae(e,{k:t,v:r}):t<e.k?to(Ae(e,{l:$e(e.l,t,r)})):to(Ae(e,{r:$e(e.r,t,r)}))}function zt(){return Qt}function Wt(e,t,r){if(ye(e))return[];const o=Je(e,t)[0];return ul(bn(e,o,r))}function yn(e,t){if(ye(e))return Qt;const{k:r,l:o,r:s}=e;if(t===r){if(ye(o))return s;if(ye(s))return o;{const[a,i]=gs(o);return Ir(Ae(e,{k:a,l:hs(o),v:i}))}}else return t<r?Ir(Ae(e,{l:yn(o,t)})):Ir(Ae(e,{r:yn(s,t)}))}function Rt(e){return ye(e)?[]:[...Rt(e.l),{k:e.k,v:e.v},...Rt(e.r)]}function bn(e,t,r){if(ye(e))return[];const{k:o,l:s,r:a,v:i}=e;let l=[];return o>t&&(l=l.concat(bn(s,t,r))),o>=t&&o<=r&&l.push({k:o,v:i}),o<=r&&(l=l.concat(bn(a,t,r))),l}function Ir(e){const{l:t,lvl:r,r:o}=e;if(o.lvl>=r-1&&t.lvl>=r-1)return e;if(r>o.lvl+1){if(Yr(t))return vs(Ae(e,{lvl:r-1}));if(!ye(t)&&!ye(t.r))return Ae(t.r,{l:Ae(t,{r:t.r.l}),lvl:r,r:Ae(e,{l:t.r.r,lvl:r-1})});throw new Error("Unexpected empty nodes")}else{if(Yr(e))return wn(Ae(e,{lvl:r-1}));if(!ye(o)&&!ye(o.l)){const s=o.l,a=Yr(s)?o.lvl-1:o.lvl;return Ae(s,{l:Ae(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:wn(Ae(o,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function Ae(e,t){return xs(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 hs(e){return ye(e.r)?e.l:Ir(Ae(e,{r:hs(e.r)}))}function Yr(e){return ye(e)||e.lvl>e.r.lvl}function gs(e){return ye(e.r)?[e.k,e.v]:gs(e.r)}function xs(e,t,r,o=Qt,s=Qt){return{k:e,l:o,lvl:r,r:s,v:t}}function to(e){return wn(vs(e))}function vs(e){const{l:t}=e;return!ye(t)&&t.lvl===e.lvl?Ae(t,{r:Ae(e,{l:t.r})}):e}function wn(e){const{lvl:t,r}=e;return!ye(r)&&!ye(r.r)&&r.lvl===t&&r.r.lvl===t?Ae(r,{l:Ae(e,{r:r.l}),lvl:t+1}):e}function ul(e){return ps(e,({k:t,v:r})=>({index:t,value:r}))}function ys(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function tr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const Dn=xe(()=>({recalcInProgress:F(!1)}),[],{singleton:!0});function bs(e,t,r){return e[Ar(e,t,r)]}function Ar(e,t,r,o=0){let s=e.length-1;for(;o<=s;){const a=Math.floor((o+s)/2),i=e[a],l=r(i,t);if(l===0)return a;if(l===-1){if(s-o<2)return a-1;s=a-1}else{if(s===o)return a;o=a+1}}throw new Error(`Failed binary finding record in array - ${e.join(",")}, searched for ${t}`)}function fl(e,t,r,o){const s=Ar(e,t,o),a=Ar(e,r,o,s);return e.slice(s,a+1)}function wt(e,t){return Math.round(e.getBoundingClientRect()[t])}function Pr(e){return!ye(e.groupOffsetTree)}function Mn({index:e},t){return t===e?0:t<e?-1:1}function ml(){return{groupIndices:[],groupOffsetTree:zt(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:zt()}}function pl(e,t){let r=ye(e)?0:1/0;for(const o of t){const{endIndex:s,size:a,startIndex:i}=o;if(r=Math.min(r,i),ye(e)){e=$e(e,0,a);continue}const l=Wt(e,i-1,s+1);if(l.some(wl(o)))continue;let d=!1,c=!1;for(const{end:f,start:u,value:p}of l)d?(s>=u||a===p)&&(e=yn(e,u)):(c=p!==a,d=!0),f>s&&s>=u&&p!==a&&(e=$e(e,s+1,p));c&&(e=$e(e,i,a))}return[e,r]}function hl(e){return typeof e.groupIndex<"u"}function gl({offset:e},t){return t===e?0:t<e?-1:1}function rr(e,t,r){if(t.length===0)return 0;const{index:o,offset:s,size:a}=bs(t,e,Mn),i=e-o,l=a*i+(i-1)*r+s;return l>0?l+r:l}function ws(e,t){if(!Pr(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function Ns(e,t,r){if(hl(e))return t.groupIndices[e.groupIndex]+1;{const o=e.index==="LAST"?r:e.index;let s=ws(o,t);return s=Math.max(0,s,Math.min(r,s)),s}}function xl(e,t,r,o=0){return o>0&&(t=Math.max(t,bs(e,o,Mn).offset)),ps(fl(e,t,r,gl),bl)}function vl(e,[t,r,o,s]){t.length>0&&o("received item sizes",t,We.DEBUG);const a=e.sizeTree;let i=a,l=0;if(r.length>0&&ye(a)&&t.length===2){const p=t[0].size,x=t[1].size;i=r.reduce((w,I)=>$e($e(w,I,p),I+1,x),i)}else[i,l]=pl(i,t);if(i===a)return e;const{lastIndex:d,lastOffset:c,lastSize:f,offsetTree:u}=Nn(e.offsetTree,l,i,s);return{groupIndices:r,groupOffsetTree:r.reduce((p,x)=>$e(p,x,rr(x,u,s)),zt()),lastIndex:d,lastOffset:c,lastSize:f,offsetTree:u,sizeTree:i}}function yl(e){return Rt(e).map(({k:t,v:r},o,s)=>{const a=s[o+1];return{endIndex:a?a.k-1:1/0,size:r,startIndex:t}})}function ro(e,t){let r=0,o=0;for(;r<e;)r+=t[o+1]-t[o]-1,o++;return o-(r===e?0:1)}function Nn(e,t,r,o){let s=e,a=0,i=0,l=0,d=0;if(t!==0){d=Ar(s,t-1,Mn),l=s[d].offset;const c=Je(r,t-1);a=c[0],i=c[1],s.length&&s[d].size===Je(r,t)[1]&&(d-=1),s=s.slice(0,d+1)}else s=[];for(const{start:c,value:f}of Wt(r,t,1/0)){const u=c-a,p=u*i+l+u*o;s.push({index:c,offset:p,size:f}),a=c,l=p,i=f}return{lastIndex:a,lastOffset:l,lastSize:i,offsetTree:s}}function bl(e){return{index:e.index,value:e}}function wl(e){const{endIndex:t,size:r,startIndex:o}=e;return s=>s.start===o&&(s.end===t||s.end===1/0)&&s.value===r}const Nl={offsetHeight:"height",offsetWidth:"width"},ut=xe(([{log:e},{recalcInProgress:t}])=>{const r=fe(),o=fe(),s=Oe(o,0),a=fe(),i=fe(),l=F(0),d=F([]),c=F(void 0),f=F(void 0),u=F(void 0),p=F(void 0),x=F((h,y)=>wt(h,Nl[y])),w=F(void 0),I=F(0),b=ml(),g=Oe(L(r,de(d,e,I),ct(vl,b),we()),b),v=Oe(L(d,we(),ct((h,y)=>({current:y,prev:h.current}),{current:[],prev:[]}),G(({prev:h})=>h)),[]);X(L(d,se(h=>h.length>0),de(g,I),G(([h,y,k])=>{const T=h.reduce((D,M,C)=>$e(D,M,rr(M,y.offsetTree,k)||C),zt());return{...y,groupIndices:h,groupOffsetTree:T}})),g),X(L(o,de(g),se(([h,{lastIndex:y}])=>h<y),G(([h,{lastIndex:y,lastSize:k}])=>[{endIndex:y,size:k,startIndex:h}])),r),X(c,f);const N=Oe(L(c,G(h=>h===void 0)),!0);X(L(f,se(h=>h!==void 0&&ye(Se(g).sizeTree)),G(h=>{const y=Se(u),k=Se(d).length>0;return y?k?[{endIndex:0,size:y,startIndex:0},{endIndex:1,size:h,startIndex:1}]:[]:[{endIndex:0,size:h,startIndex:0}]})),r),X(L(p,se(h=>h!==void 0&&h.length>0&&ye(Se(g).sizeTree)),G(h=>{const y=[];let k=h[0],T=0;for(let D=1;D<h.length;D++){const M=h[D];M!==k&&(y.push({endIndex:D-1,size:k,startIndex:T}),k=M,T=D)}return y.push({endIndex:h.length-1,size:k,startIndex:T}),y})),r),X(L(d,de(u,f),se(([,h,y])=>h!==void 0&&y!==void 0),G(([h,y,k])=>{const T=[];for(let D=0;D<h.length;D++){const M=h[D],C=h[D+1];T.push({startIndex:M,endIndex:M,size:y}),C!==void 0&&T.push({startIndex:M+1,endIndex:C-1,size:k})}return T})),r);const j=Ve(L(r,de(g),ct(({sizes:h},[y,k])=>({changed:k!==h,sizes:k}),{changed:!1,sizes:b}),G(h=>h.changed)));ve(L(l,ct((h,y)=>({diff:h.prev-y,prev:y}),{diff:0,prev:0}),G(h=>h.diff)),h=>{const{groupIndices:y}=Se(g);if(h>0)le(t,!0),le(a,h+ro(h,y));else if(h<0){const k=Se(v);k.length>0&&(h-=ro(-h,k)),le(i,h)}}),ve(L(l,de(e)),([h,y])=>{h<0&&y("`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},We.ERROR)});const S=Ve(a);X(L(a,de(g),G(([h,y])=>{const k=y.groupIndices.length>0,T=[],D=y.lastSize;if(k){const M=er(y.sizeTree,0);let C=0,E=0;for(;C<h;){const O=y.groupIndices[E],H=y.groupIndices.length===E+1?1/0:y.groupIndices[E+1]-O-1;T.push({endIndex:O,size:M,startIndex:O}),T.push({endIndex:O+1+H-1,size:D,startIndex:O+1}),E++,C+=H+1}const _=Rt(y.sizeTree);return C!==h&&_.shift(),_.reduce((O,{k:H,v:z})=>{let V=O.ranges;return O.prevSize!==0&&(V=[...O.ranges,{endIndex:H+h-1,size:O.prevSize,startIndex:O.prevIndex}]),{prevIndex:H+h,prevSize:z,ranges:V}},{prevIndex:h,prevSize:0,ranges:T}).ranges}return Rt(y.sizeTree).reduce((M,{k:C,v:E})=>({prevIndex:C+h,prevSize:E,ranges:[...M.ranges,{endIndex:C+h-1,size:M.prevSize,startIndex:M.prevIndex}]}),{prevIndex:0,prevSize:D,ranges:[]}).ranges})),r);const R=Ve(L(i,de(g,I),G(([h,{offsetTree:y},k])=>{const T=-h;return rr(T,y,k)})));return X(L(i,de(g,I),G(([h,y,k])=>{if(y.groupIndices.length>0){if(ye(y.sizeTree))return y;let T=zt();const D=Se(v);let M=0,C=0,E=0;for(;M<-h;){E=D[C];const _=D[C+1]-E-1;C++,M+=_+1}if(T=Rt(y.sizeTree).reduce((_,{k:O,v:H})=>$e(_,Math.max(0,O+h),H),T),M!==-h){const _=er(y.sizeTree,E);T=$e(T,0,_);const O=Je(y.sizeTree,-h+1)[1];T=$e(T,1,O)}return{...y,sizeTree:T,...Nn(y.offsetTree,0,T,k)}}else{const T=Rt(y.sizeTree).reduce((D,{k:M,v:C})=>$e(D,Math.max(0,M+h),C),zt());return{...y,sizeTree:T,...Nn(y.offsetTree,0,T,k)}}})),g),{beforeUnshiftWith:S,data:w,defaultItemSize:f,firstItemIndex:l,fixedItemSize:c,fixedGroupSize:u,gap:I,groupIndices:d,heightEstimates:p,itemSize:x,listRefresh:j,shiftWith:i,shiftWithOffset:R,sizeRanges:r,sizes:g,statefulTotalCount:s,totalCount:o,trackItemSizes:N,unshiftWith:a}},Ne(jt,Dn),{singleton:!0});function Il(e){return e.reduce((t,r)=>(t.groupIndices.push(t.totalCount),t.totalCount+=r+1,t),{groupIndices:[],totalCount:0})}const Is=xe(([{groupIndices:e,sizes:t,totalCount:r},{headerHeight:o,scrollTop:s}])=>{const a=fe(),i=fe(),l=Ve(L(a,G(Il)));return X(L(l,G(d=>d.totalCount)),r),X(L(l,G(d=>d.groupIndices)),e),X(L(Ee(s,t,o),se(([d,c])=>Pr(c)),G(([d,c,f])=>Je(c.groupOffsetTree,Math.max(d-f,0),"v")[0]),we(),G(d=>[d])),i),{groupCounts:a,topItemsIndexes:i}},Ne(ut,Pe)),kt=xe(([{log:e}])=>{const t=F(!1),r=Ve(L(t,se(o=>o),we()));return ve(t,o=>{o&&Se(e)("props updated",{},We.DEBUG)}),{didMount:r,propsReady:t}},Ne(jt),{singleton:!0}),jl=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function js(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!jl)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const dr=xe(([{gap:e,listRefresh:t,sizes:r,totalCount:o},{fixedFooterHeight:s,fixedHeaderHeight:a,footerHeight:i,headerHeight:l,scrollingInProgress:d,scrollTo:c,smoothScrollTargetReached:f,viewportHeight:u},{log:p}])=>{const x=fe(),w=fe(),I=F(0);let b=null,g=null,v=null;function N(){b&&(b(),b=null),v&&(v(),v=null),g&&(clearTimeout(g),g=null),le(d,!1)}return X(L(x,de(r,u,o,I,l,i,p),de(e,a,s),G(([[j,S,R,h,y,k,T,D],M,C,E])=>{const _=js(j),{align:O,behavior:H,offset:z}=_,V=h-1,J=Ns(_,S,V);let P=rr(J,S.offsetTree,M)+k;O==="end"?(P+=C+Je(S.sizeTree,J)[1]-R+E,J===V&&(P+=T)):O==="center"?P+=(C+Je(S.sizeTree,J)[1]-R+E)/2:P-=y,z&&(P+=z);const $=W=>{N(),W?(D("retrying to scroll to",{location:j},We.DEBUG),le(x,j)):(le(w,!0),D("list did not change, scroll successful",{},We.DEBUG))};if(N(),H==="smooth"){let W=!1;v=ve(t,K=>{W=W||K}),b=Ye(f,()=>{$(W)})}else b=Ye(L(t,kl(150)),$);return g=setTimeout(()=>{N()},1200),le(d,!0),D("scrolling from index to",{behavior:H,index:J,top:P},We.DEBUG),{behavior:H,top:P}})),c),{scrollTargetReached:w,scrollToIndex:x,topListHeight:I}},Ne(ut,Pe,jt),{singleton:!0});function kl(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return o=>{o&&(t(!0),clearTimeout(r))}}}function _n(e,t){e==0?t():requestAnimationFrame(()=>{_n(e-1,t)})}function Ln(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const ur=xe(([{defaultItemSize:e,listRefresh:t,sizes:r},{scrollTop:o},{scrollTargetReached:s,scrollToIndex:a},{didMount:i}])=>{const l=F(!0),d=F(0),c=F(!0);return X(L(i,de(d),se(([f,u])=>!!u),st(!1)),l),X(L(i,de(d),se(([f,u])=>!!u),st(!1)),c),ve(L(Ee(t,i),de(l,r,e,c),se(([[,f],u,{sizeTree:p},x,w])=>f&&(!ye(p)||En(x))&&!u&&!w),de(d)),([,f])=>{Ye(s,()=>{le(c,!0)}),_n(4,()=>{Ye(o,()=>{le(l,!0)}),le(a,f)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:d,scrolledToInitialItem:l}},Ne(ut,Pe,dr,kt),{singleton:!0});function ks(e,t){return Math.abs(e-t)<1.01}const nr="up",Xt="down",Sl="none",Cl={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Tl=0,fr=xe(([{footerHeight:e,headerHeight:t,scrollBy:r,scrollContainerState:o,scrollTop:s,viewportHeight:a}])=>{const i=F(!1),l=F(!0),d=fe(),c=fe(),f=F(4),u=F(Tl),p=Oe(L(vn(L(oe(s),Mt(1),st(!0)),L(oe(s),Mt(1),st(!1),Qn(100))),we()),!1),x=Oe(L(vn(L(r,st(!0)),L(r,st(!1),Qn(200))),we()),!1);X(L(Ee(oe(s),oe(u)),G(([v,N])=>v<=N),we()),l),X(L(l,ft(50)),c);const w=Ve(L(Ee(o,oe(a),oe(t),oe(e),oe(f)),ct((v,[{scrollHeight:N,scrollTop:j},S,R,h,y])=>{const k=j+S-N>-y,T={scrollHeight:N,scrollTop:j,viewportHeight:S};if(k){let M,C;return j>v.state.scrollTop?(M="SCROLLED_DOWN",C=v.state.scrollTop-j):(M="SIZE_DECREASED",C=v.state.scrollTop-j||v.scrollTopDelta),{atBottom:!0,atBottomBecause:M,scrollTopDelta:C,state:T}}let D;return T.scrollHeight>v.state.scrollHeight?D="SIZE_INCREASED":S<v.state.viewportHeight?D="VIEWPORT_HEIGHT_DECREASING":j<v.state.scrollTop?D="SCROLLING_UPWARDS":D="NOT_FULLY_SCROLLED_TO_LAST_ITEM_BOTTOM",{atBottom:!1,notAtBottomBecause:D,state:T}},Cl),we((v,N)=>v&&v.atBottom===N.atBottom))),I=Oe(L(o,ct((v,{scrollHeight:N,scrollTop:j,viewportHeight:S})=>{if(ks(v.scrollHeight,N))return{changed:!1,jump:0,scrollHeight:N,scrollTop:j};{const R=N-(j+S)<1;return v.scrollTop!==j&&R?{changed:!0,jump:v.scrollTop-j,scrollHeight:N,scrollTop:j}:{changed:!0,jump:0,scrollHeight:N,scrollTop:j}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),se(v=>v.changed),G(v=>v.jump)),0);X(L(w,G(v=>v.atBottom)),i),X(L(i,ft(50)),d);const b=F(Xt);X(L(o,G(({scrollTop:v})=>v),we(),ct((v,N)=>Se(x)?{direction:v.direction,prevScrollTop:N}:{direction:N<v.prevScrollTop?nr:Xt,prevScrollTop:N},{direction:Xt,prevScrollTop:0}),G(v=>v.direction)),b),X(L(o,ft(50),st(Sl)),b);const g=F(0);return X(L(p,se(v=>!v),st(0)),g),X(L(s,ft(100),de(p),se(([v,N])=>N),ct(([v,N],[j])=>[N,j],[0,0]),G(([v,N])=>N-v)),g),{atBottomState:w,atBottomStateChange:d,atBottomThreshold:f,atTopStateChange:c,atTopThreshold:u,isAtBottom:i,isAtTop:l,isScrolling:p,lastJumpDueToItemResize:I,scrollDirection:b,scrollVelocity:g}},Ne(Pe)),or="top",sr="bottom",no="none";function oo(e,t,r){return typeof e=="number"?r===nr&&t===or||r===Xt&&t===sr?e:0:r===nr?t===or?e.main:e.reverse:t===sr?e.main:e.reverse}function so(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const On=xe(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:o,viewportHeight:s}])=>{const a=fe(),i=F(0),l=F(0),d=F(0),c=Oe(L(Ee(oe(o),oe(s),oe(r),oe(a,tr),oe(d),oe(i),oe(t),oe(e),oe(l)),G(([f,u,p,[x,w],I,b,g,v,N])=>{const j=f-v,S=b+g,R=Math.max(p-j,0);let h=no;const y=so(N,or),k=so(N,sr);return x-=v,x+=p+g,w+=p+g,w-=v,x>f+S-y&&(h=nr),w<f-R+u+k&&(h=Xt),h!==no?[Math.max(j-p-oo(I,or,h)-y,0),j-R-g+u+oo(I,sr,h)+k]:null}),se(f=>f!=null),we(tr)),[0,0]);return{increaseViewportBy:l,listBoundary:a,overscan:d,topListHeight:i,visibleRange:c}},Ne(Pe),{singleton:!0});function El(e,t,r){if(Pr(t)){const o=ws(e,t);return[{index:Je(t.groupOffsetTree,o)[0],offset:0,size:0},{data:r==null?void 0:r[0],index:o,offset:0,size:0}]}return[{data:r==null?void 0:r[0],index:e,offset:0,size:0}]}const Xr={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function jr(e,t,r,o,s,a){const{lastIndex:i,lastOffset:l,lastSize:d}=s;let c=0,f=0;if(e.length>0){c=e[0].offset;const I=e[e.length-1];f=I.offset+I.size}const u=r-i,p=l+u*d+(u-1)*o,x=c,w=p-f;return{bottom:f,firstItemIndex:a,items:ao(e,s,a),offsetBottom:w,offsetTop:c,top:x,topItems:ao(t,s,a),topListHeight:t.reduce((I,b)=>b.size+I,0),totalCount:r}}function Ss(e,t,r,o,s,a){let i=0;if(r.groupIndices.length>0)for(const f of r.groupIndices){if(f-i>=e)break;i++}const l=e+i,d=Ln(t,l),c=Array.from({length:l}).map((f,u)=>({data:a[u+d],index:u+d,offset:0,size:0}));return jr(c,[],l,s,r,o)}function ao(e,t,r){if(e.length===0)return[];if(!Pr(t))return e.map(c=>({...c,index:c.index+r,originalIndex:c.index}));const o=e[0].index,s=e[e.length-1].index,a=[],i=Wt(t.groupOffsetTree,o,s);let l,d=0;for(const c of e){(!l||l.end<c.index)&&(l=i.shift(),d=t.groupIndices.indexOf(l.start));let f;c.index===l.start?f={index:d,type:"group"}:f={groupIndex:d,index:c.index-(d+1)+r},a.push({...f,data:c.data,offset:c.offset,originalIndex:c.index,size:c.size})}return a}function io(e,t){var r;return e===void 0?0:typeof e=="number"?e:(r=e[t])!=null?r:0}const Ot=xe(([{data:e,firstItemIndex:t,gap:r,sizes:o,totalCount:s},a,{listBoundary:i,topListHeight:l,visibleRange:d},{initialTopMostItemIndex:c,scrolledToInitialItem:f},{topListHeight:u},p,{didMount:x},{recalcInProgress:w}])=>{const I=F([]),b=F(0),g=fe(),v=F(0);X(a.topItemsIndexes,I);const N=Oe(L(Ee(x,w,oe(d,tr),oe(s),oe(o),oe(c),f,oe(I),oe(t),oe(r),oe(v),e),se(([h,y,,k,,,,,,,,T])=>{const D=T&&T.length!==k;return h&&!y&&!D}),G(([,,[h,y],k,T,D,M,C,E,_,O,H])=>{var z,V,J,P;const $=T,{offsetTree:W,sizeTree:K}=$,U=Se(b);if(k===0)return{...Xr,totalCount:k};if(h===0&&y===0)return U===0?{...Xr,totalCount:k}:Ss(U,D,T,E,_,H||[]);if(ye(K))return U>0?null:jr(El(Ln(D,k),$,H),[],k,_,$,E);const Z=[];if(C.length>0){const q=C[0],te=C[C.length-1];let me=0;for(const pe of Wt(K,q,te)){const ce=pe.value,ie=Math.max(pe.start,q),Ie=Math.min(pe.end,te);for(let je=ie;je<=Ie;je++)Z.push({data:H==null?void 0:H[je],index:je,offset:me,size:ce}),me+=ce}}if(!M)return jr([],Z,k,_,$,E);const ee=C.length>0?C[C.length-1]+1:0,A=xl(W,h,y,ee);if(A.length===0)return null;const B=k-1,ne=Fr([],q=>{for(const te of A){const me=te.value;let pe=me.offset,ce=te.start;const ie=me.size;if(me.offset<h){ce+=Math.floor((h-me.offset+_)/(ie+_));const je=ce-te.start;pe+=je*ie+je*_}ce<ee&&(pe+=(ee-ce)*ie,ce=ee);const Ie=Math.min(te.end,B);for(let je=ce;je<=Ie&&!(pe>=y);je++)q.push({data:H==null?void 0:H[je],index:je,offset:pe,size:ie}),pe+=ie+_}}),ue=io(O,or),ge=io(O,sr);if(ne.length>0&&(ue>0||ge>0)){const q=ne[0],te=ne[ne.length-1];if(ue>0&&q.index>ee){const me=Math.min(ue,q.index-ee),pe=[];let ce=q.offset;for(let ie=q.index-1;ie>=q.index-me;ie--){const Ie=(V=(z=Wt(K,ie,ie)[0])==null?void 0:z.value)!=null?V:q.size;ce-=Ie+_,pe.unshift({data:H==null?void 0:H[ie],index:ie,offset:ce,size:Ie})}ne.unshift(...pe)}if(ge>0&&te.index<B){const me=Math.min(ge,B-te.index);let pe=te.offset+te.size+_;for(let ce=te.index+1;ce<=te.index+me;ce++){const ie=(P=(J=Wt(K,ce,ce)[0])==null?void 0:J.value)!=null?P:te.size;ne.push({data:H==null?void 0:H[ce],index:ce,offset:pe,size:ie}),pe+=ie+_}}}return jr(ne,Z,k,_,$,E)}),se(h=>h!==null),we()),Xr);X(L(e,se(En),G(h=>h==null?void 0:h.length)),s),X(L(N,G(h=>h.topListHeight)),u),X(u,l),X(L(N,G(h=>[h.top,h.bottom])),i),X(L(N,G(h=>h.items)),g);const j=Ve(L(N,se(({items:h})=>h.length>0),de(s,e),se(([{items:h},y])=>h[h.length-1].originalIndex===y-1),G(([,h,y])=>[h-1,y]),we(tr),G(([h])=>h))),S=Ve(L(N,ft(200),se(({items:h,topItems:y})=>h.length>0&&h[0].originalIndex===y.length),G(({items:h})=>h[0].index),we())),R=Ve(L(N,se(({items:h})=>h.length>0),G(({items:h})=>{let y=0,k=h.length-1;for(;h[y].type==="group"&&y<k;)y++;for(;h[k].type==="group"&&k>y;)k--;return{endIndex:h[k].index,startIndex:h[y].index}}),we(ys)));return{endReached:j,initialItemCount:b,itemsRendered:g,listState:N,minOverscanItemCount:v,rangeChanged:R,startReached:S,topItemsIndexes:I,...p}},Ne(ut,Is,On,ur,dr,fr,kt,Dn),{singleton:!0}),Cs=xe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:o},{listState:s}])=>{const a=fe(),i=Oe(L(Ee(r,e,o,t,s),G(([l,d,c,f,u])=>l+d+c+f+u.offsetBottom+u.bottom)),0);return X(oe(i),a),{totalListHeight:i,totalListHeightChanged:a}},Ne(Pe,Ot),{singleton:!0}),Rl=xe(([{viewportHeight:e},{totalListHeight:t}])=>{const r=F(!1),o=Oe(L(Ee(r,e,t),se(([s])=>s),G(([,s,a])=>Math.max(0,s-a)),ft(0),we()),0);return{alignToBottom:r,paddingTopAddition:o}},Ne(Pe,Cs),{singleton:!0}),Ts=xe(()=>({context:F(null)})),Al=({itemBottom:e,itemTop:t,locationParams:{align:r,behavior:o,...s},viewportBottom:a,viewportTop:i})=>t<i?{...s,align:r??"start",behavior:o}:e>a?{...s,align:r??"end",behavior:o}:null,Es=xe(([{gap:e,sizes:t,totalCount:r},{fixedFooterHeight:o,fixedHeaderHeight:s,headerHeight:a,scrollingInProgress:i,scrollTop:l,viewportHeight:d},{scrollToIndex:c}])=>{const f=fe();return X(L(f,de(t,d,r,a,s,o,l),de(e),G(([[u,p,x,w,I,b,g,v],N])=>{const{align:j,behavior:S,calculateViewLocation:R=Al,done:h,...y}=u,k=Ns(u,p,w-1),T=rr(k,p.offsetTree,N)+I+b,D=T+Je(p.sizeTree,k)[1],M=v+b,C=v+x-g,E=R({itemBottom:D,itemTop:T,locationParams:{align:j,behavior:S,...y},viewportBottom:C,viewportTop:M});return E?h&&Ye(L(i,se(_=>!_),Mt(Se(i)?1:2)),h):h==null||h(),E}),se(u=>u!==null)),c),{scrollIntoView:f}},Ne(ut,Pe,dr,Ot,jt),{singleton:!0});function lo(e){return e?e==="smooth"?"smooth":"auto":!1}const Dl=(e,t)=>typeof e=="function"?lo(e(t)):t&&lo(e),Ml=xe(([{listRefresh:e,totalCount:t,fixedItemSize:r,data:o},{atBottomState:s,isAtBottom:a},{scrollToIndex:i},{scrolledToInitialItem:l},{didMount:d,propsReady:c},{log:f},{scrollingInProgress:u},{context:p},{scrollIntoView:x}])=>{const w=F(!1),I=fe();let b=null;function g(S){le(i,{align:"end",behavior:S,index:"LAST"})}ve(L(Ee(L(oe(t),Mt(1)),d),de(oe(w),a,l,u),G(([[S,R],h,y,k,T])=>{let D=R&&k,M="auto";return D&&(M=Dl(h,y||T),D=D&&!!M),{followOutputBehavior:M,shouldFollow:D,totalCount:S}}),se(({shouldFollow:S})=>S)),({followOutputBehavior:S,totalCount:R})=>{b&&(b(),b=null),Se(r)?requestAnimationFrame(()=>{Se(f)("following output to ",{totalCount:R},We.DEBUG),g(S)}):b=Ye(e,()=>{Se(f)("following output to ",{totalCount:R},We.DEBUG),g(S),b=null})});function v(S){const R=Ye(s,h=>{S&&!h.atBottom&&h.notAtBottomBecause==="SIZE_INCREASED"&&!b&&(Se(f)("scrolling to bottom due to increased size",{},We.DEBUG),g("auto"))});setTimeout(R,100)}ve(L(Ee(oe(w),t,c),se(([S,,R])=>S&&R),ct(({value:S},[,R])=>({refreshed:S===R,value:R}),{refreshed:!1,value:0}),se(({refreshed:S})=>S),de(w,t)),([,S])=>{Se(l)&&v(S!==!1)}),ve(I,()=>{v(Se(w)!==!1)}),ve(Ee(oe(w),s),([S,R])=>{S&&!R.atBottom&&R.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")});const N=F(null),j=fe();return X(vn(L(oe(o),G(S=>{var R;return(R=S==null?void 0:S.length)!=null?R:0})),L(oe(t))),j),ve(L(Ee(L(j,Mt(1)),d),de(oe(N),l,u,p),G(([[S,R],h,y,k,T])=>R&&y&&(h==null?void 0:h({context:T,totalCount:S,scrollingInProgress:k}))),se(S=>!!S),ft(0)),S=>{b&&(b(),b=null),Se(r)?requestAnimationFrame(()=>{Se(f)("scrolling into view",{}),le(x,S)}):b=Ye(e,()=>{Se(f)("scrolling into view",{}),le(x,S),b=null})}),{autoscrollToBottom:I,followOutput:w,scrollIntoViewOnChange:N}},Ne(ut,fr,dr,ur,kt,jt,Pe,Ts,Es)),_l=xe(([{data:e,firstItemIndex:t,gap:r,sizes:o},{initialTopMostItemIndex:s},{initialItemCount:a,listState:i},{didMount:l}])=>(X(L(l,de(a),se(([,d])=>d!==0),de(s,o,t,r,e),G(([[,d],c,f,u,p,x=[]])=>Ss(d,c,f,u,p,x))),i),{}),Ne(ut,ur,Ot,kt),{singleton:!0}),Ll=xe(([{didMount:e},{scrollTo:t},{listState:r}])=>{const o=F(0);return ve(L(e,de(o),se(([,s])=>s!==0),G(([,s])=>({top:s}))),s=>{Ye(L(r,Mt(1),se(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{le(t,s)})})}),{initialScrollTop:o}},Ne(kt,Pe,Ot),{singleton:!0}),Rs=xe(([{scrollVelocity:e}])=>{const t=F(!1),r=fe(),o=F(!1);return X(L(e,de(o,t,r),se(([s,a])=>!!a),G(([s,a,i,l])=>{const{enter:d,exit:c}=a;if(i){if(c(s,l))return!1}else if(d(s,l))return!0;return i}),we()),t),ve(L(Ee(t,e,r),de(o)),([[s,a,i],l])=>{s&&l&&l.change&&l.change(a,i)}),{isSeeking:t,scrollSeekConfiguration:o,scrollSeekRangeChanged:r,scrollVelocity:e}},Ne(fr),{singleton:!0}),Hn=xe(([{scrollContainerState:e,scrollTo:t}])=>{const r=fe(),o=fe(),s=fe(),a=F(!1),i=F(void 0);return X(L(Ee(r,o),G(([{scrollHeight:l,scrollTop:d,viewportHeight:c},{offsetTop:f}])=>({scrollHeight:l,scrollTop:Math.max(0,d-f),viewportHeight:c}))),e),X(L(t,de(o),G(([l,{offsetTop:d}])=>({...l,top:l.top+d}))),s),{customScrollParent:i,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:o}},Ne(Pe)),Ol=xe(([{sizeRanges:e,sizes:t},{headerHeight:r,scrollTop:o},{initialTopMostItemIndex:s},{didMount:a},{useWindowScroll:i,windowScrollContainerState:l,windowViewportRect:d}])=>{const c=fe(),f=F(void 0),u=F(null),p=F(null);return X(l,u),X(d,p),ve(L(c,de(t,o,i,u,p,r)),([x,w,I,b,g,v,N])=>{const j=yl(w.sizeTree);b&&g!==null&&v!==null&&(I=g.scrollTop-v.offsetTop),I-=N,x({ranges:j,scrollTop:I})}),X(L(f,se(En),G(Hl)),s),X(L(a,de(f),se(([,x])=>x!==void 0),we(),G(([,x])=>x.ranges)),e),{getState:c,restoreStateFrom:f}},Ne(ut,Pe,ur,kt,Hn));function Hl(e){return{align:"start",index:0,offset:e.scrollTop}}const Fl=xe(([{topItemsIndexes:e}])=>{const t=F(0);return X(L(t,se(r=>r>=0),G(r=>Array.from({length:r}).map((o,s)=>s))),e),{topItemCount:t}},Ne(Ot));function As(e){let t=!1,r;return(()=>(t||(t=!0,r=e()),r))}const Pl=As(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Bl=xe(([{deviation:e,scrollBy:t,scrollingInProgress:r,scrollTop:o},{isAtBottom:s,isScrolling:a,lastJumpDueToItemResize:i,scrollDirection:l},{listState:d},{beforeUnshiftWith:c,gap:f,shiftWithOffset:u,sizes:p},{log:x},{recalcInProgress:w}])=>{const I=Ve(L(d,de(i),ct(([,g,v,N],[{bottom:j,items:S,offsetBottom:R,totalCount:h},y])=>{const k=j+R;let T=0;return v===h&&g.length>0&&S.length>0&&(S[0].originalIndex===0&&g[0].originalIndex===0||(T=k-N,T!==0&&(T+=y))),[T,S,h,k]},[0,[],0,0]),se(([g])=>g!==0),de(o,l,r,s,x,w),se(([,g,v,N,,,j])=>!j&&!N&&g!==0&&v===nr),G(([[g],,,,,v])=>(v("Upward scrolling compensation",{amount:g},We.DEBUG),g))));function b(g){g>0?(le(t,{behavior:"auto",top:-g}),le(e,0)):(le(e,0),le(t,{behavior:"auto",top:-g}))}return ve(L(I,de(e,a)),([g,v,N])=>{N&&Pl()?le(e,v-g):b(-g)}),ve(L(Ee(Oe(a,!1),e,w),se(([g,v,N])=>!g&&!N&&v!==0),G(([g,v])=>v),ft(1)),b),X(L(u,G(g=>({top:-g}))),t),ve(L(c,de(p,f),G(([g,{groupIndices:v,lastSize:N,sizeTree:j},S])=>{function R(h){return h*(N+S)}if(v.length===0)return R(g);{let h=0;const y=er(j,0);let k=0,T=0;for(;k<g;){k++,h+=y;let D=v.length===T+1?1/0:v[T+1]-v[T]-1;k+D>g&&(h-=y,D=g-k+1),k+=D,h+=R(D),T++}return h}})),g=>{le(e,g),requestAnimationFrame(()=>{le(t,{top:g}),requestAnimationFrame(()=>{le(e,0),le(w,!1)})})}),{deviation:e}},Ne(Pe,fr,Ot,ut,jt,Dn)),zl=xe(([e,t,r,o,s,a,i,l,d,c,f])=>({...e,...t,...r,...o,...s,...a,...i,...l,...d,...c,...f}),Ne(On,_l,kt,Rs,Cs,Ll,Rl,Hn,Es,jt,Ts)),Ds=xe(([{data:e,defaultItemSize:t,firstItemIndex:r,fixedItemSize:o,fixedGroupSize:s,gap:a,groupIndices:i,heightEstimates:l,itemSize:d,sizeRanges:c,sizes:f,statefulTotalCount:u,totalCount:p,trackItemSizes:x},{initialItemFinalLocationReached:w,initialTopMostItemIndex:I,scrolledToInitialItem:b},g,v,N,j,{scrollToIndex:S},R,{topItemCount:h},{groupCounts:y},k])=>{const{listState:T,minOverscanItemCount:D,topItemsIndexes:M,rangeChanged:C,...E}=j;return X(C,k.scrollSeekRangeChanged),X(L(k.windowViewportRect,G(_=>_.visibleHeight)),g.viewportHeight),{data:e,defaultItemHeight:t,firstItemIndex:r,fixedItemHeight:o,fixedGroupHeight:s,gap:a,groupCounts:y,heightEstimates:l,initialItemFinalLocationReached:w,initialTopMostItemIndex:I,scrolledToInitialItem:b,sizeRanges:c,topItemCount:h,topItemsIndexes:M,totalCount:p,...N,groupIndices:i,itemSize:d,listState:T,minOverscanItemCount:D,scrollToIndex:S,statefulTotalCount:u,trackItemSizes:x,rangeChanged:C,...E,...k,...g,sizes:f,...v}},Ne(ut,ur,Pe,Ol,Ml,Ot,dr,Bl,Fl,Is,zl));function Wl(e,t){const r={},o={};let s=0;const a=e.length;for(;s<a;)o[e[s]]=1,s+=1;for(const i in t)Object.hasOwn(o,i)||(r[i]=t[i]);return r}const vr=typeof document<"u"?Y.useLayoutEffect:Y.useEffect;function Ms(e,t,r){const o=Object.keys(t.required||{}),s=Object.keys(t.optional||{}),a=Object.keys(t.methods||{}),i=Object.keys(t.events||{}),l=Y.createContext({});function d(b,g){b.propsReady&&le(b.propsReady,!1);for(const v of o){const N=b[t.required[v]];le(N,g[v])}for(const v of s)if(v in g){const N=b[t.optional[v]];le(N,g[v])}b.propsReady&&le(b.propsReady,!0)}function c(b){return a.reduce((g,v)=>(g[v]=N=>{const j=b[t.methods[v]];le(j,N)},g),{})}function f(b){return i.reduce((g,v)=>(g[v]=ol(b[t.events[v]]),g),{})}const u=Y.forwardRef((b,g)=>{const{children:v,...N}=b,[j]=Y.useState(()=>Fr(al(e),h=>{d(h,N)})),[S]=Y.useState(Jn(f,j));vr(()=>{for(const h of i)h in N&&ve(S[h],N[h]);return()=>{Object.values(S).map(Rn)}},[N,S,j]),vr(()=>{d(j,N)}),Y.useImperativeHandle(g,Xn(c(j)));const R=r;return n.jsx(l.Provider,{value:j,children:r?n.jsx(R,{...Wl([...o,...s,...i],N),children:v}):v})}),p=b=>{const g=Y.useContext(l);return Y.useCallback(v=>{le(g[b],v)},[g,b])},x=b=>{const g=Y.useContext(l)[b],v=Y.useCallback(N=>ve(g,N),[g]);return Y.useSyncExternalStore(v,()=>Se(g),()=>Se(g))},w=b=>{const g=Y.useContext(l)[b],[v,N]=Y.useState(Jn(Se,g));return vr(()=>ve(g,j=>{j!==v&&N(Xn(j))}),[g,v]),v},I=Y.version.startsWith("18")?x:w;return{Component:u,useEmitter:(b,g)=>{const v=Y.useContext(l)[b];vr(()=>ve(v,g),[g,v])},useEmitterValue:I,usePublisher:p}}const _s=Y.createContext(void 0),Ls=Y.createContext(void 0),Os=typeof document<"u"?Y.useLayoutEffect:Y.useEffect;function Jr(e){return"self"in e}function $l(e){return"body"in e}function Hs(e,t,r,o=Gt,s,a){const i=Y.useRef(null),l=Y.useRef(null),d=Y.useRef(null),c=Y.useCallback(p=>{let x,w,I;const b=p.target;if($l(b)||Jr(b)){const v=Jr(b)?b:b.defaultView;I=a?v.scrollX:v.scrollY,x=a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight,w=a?v.innerWidth:v.innerHeight}else I=a?b.scrollLeft:b.scrollTop,x=a?b.scrollWidth:b.scrollHeight,w=a?b.offsetWidth:b.offsetHeight;const g=()=>{e({scrollHeight:x,scrollTop:Math.max(I,0),viewportHeight:w})};p.suppressFlushSync?g():Zo.flushSync(g),l.current!==null&&(I===l.current||I<=0||I===x-w)&&(l.current=null,t(!0),d.current&&(clearTimeout(d.current),d.current=null))},[e,t,a]);Y.useEffect(()=>{const p=s||i.current;return o(s||i.current),c({suppressFlushSync:!0,target:p}),p.addEventListener("scroll",c,{passive:!0}),()=>{o(null),p.removeEventListener("scroll",c)}},[i,c,r,o,s]);function f(p){const x=i.current;if(!x||(a?"offsetWidth"in x&&x.offsetWidth===0:"offsetHeight"in x&&x.offsetHeight===0))return;const w=p.behavior==="smooth";let I,b,g;Jr(x)?(b=Math.max(wt(x.document.documentElement,a?"width":"height"),a?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight),I=a?x.innerWidth:x.innerHeight,g=a?window.scrollX:window.scrollY):(b=x[a?"scrollWidth":"scrollHeight"],I=wt(x,a?"width":"height"),g=x[a?"scrollLeft":"scrollTop"]);const v=b-I;if(p.top=Math.ceil(Math.max(Math.min(v,p.top),0)),ks(I,b)||p.top===g){e({scrollHeight:b,scrollTop:g,viewportHeight:I}),w&&t(!0);return}w?(l.current=p.top,d.current&&clearTimeout(d.current),d.current=setTimeout(()=>{d.current=null,l.current=null,t(!0)},1e3)):l.current=null,a&&(p={behavior:p.behavior,left:p.top}),x.scrollTo(p)}function u(p){a&&(p={behavior:p.behavior,left:p.top}),i.current.scrollBy(p)}return{scrollByCallback:u,scrollerRef:i,scrollToCallback:f}}const Qr="-webkit-sticky",co="sticky",Fn=As(()=>{if(typeof document>"u")return co;const e=document.createElement("div");return e.style.position=Qr,e.style.position===Qr?Qr:co});function Pn(e){return e}const Vl=xe(()=>{const e=F(l=>`Item ${l}`),t=F(l=>`Group ${l}`),r=F({}),o=F(Pn),s=F("div"),a=F(Gt),i=(l,d=null)=>Oe(L(r,G(c=>c[l]),we()),d);return{components:r,computeItemKey:o,EmptyPlaceholder:i("EmptyPlaceholder"),FooterComponent:i("Footer"),GroupComponent:i("Group","div"),groupContent:t,HeaderComponent:i("Header"),HeaderFooterTag:s,ItemComponent:i("Item","div"),itemContent:e,ListComponent:i("List","div"),ScrollerComponent:i("Scroller","div"),scrollerRef:a,ScrollSeekPlaceholder:i("ScrollSeekPlaceholder"),TopItemListComponent:i("TopItemList")}}),Gl=xe(([e,t])=>({...e,...t}),Ne(Ds,Vl)),Ul=({height:e})=>n.jsx("div",{style:{height:e}}),Kl={overflowAnchor:"none",position:Fn(),zIndex:1},Fs={overflowAnchor:"none"},ql={...Fs,display:"inline-block",height:"100%"},uo=Y.memo(function({showTopList:e=!1}){const t=ae("listState"),r=Ke("sizeRanges"),o=ae("useWindowScroll"),s=ae("customScrollParent"),a=Ke("windowScrollContainerState"),i=Ke("scrollContainerState"),l=s||o?a:i,d=ae("itemContent"),c=ae("context"),f=ae("groupContent"),u=ae("trackItemSizes"),p=ae("itemSize"),x=ae("log"),w=Ke("gap"),I=ae("horizontalDirection"),{callbackRef:b}=cl(r,p,u,e?Gt:l,x,w,s,I,ae("skipAnimationFrameInResizeObserver")),[g,v]=Y.useState(0);Bn("deviation",E=>{g!==E&&v(E)});const N=ae("EmptyPlaceholder"),j=ae("ScrollSeekPlaceholder")||Ul,S=ae("ListComponent"),R=ae("ItemComponent"),h=ae("GroupComponent"),y=ae("computeItemKey"),k=ae("isSeeking"),T=ae("groupIndices").length>0,D=ae("alignToBottom"),M=ae("initialItemFinalLocationReached"),C=e?{}:{boxSizing:"border-box",...I?{display:"inline-block",height:"100%",marginLeft:g!==0?g:D?"auto":0,paddingLeft:t.offsetTop,paddingRight:t.offsetBottom,whiteSpace:"nowrap"}:{marginTop:g!==0?g:D?"auto":0,paddingBottom:t.offsetBottom,paddingTop:t.offsetTop},...M?{}:{visibility:"hidden"}};return!e&&t.totalCount===0&&N?n.jsx(N,{...Le(N,c)}):n.jsx(S,{...Le(S,c),"data-testid":e?"virtuoso-top-item-list":"virtuoso-item-list",ref:b,style:C,children:(e?t.topItems:t.items).map(E=>{const _=E.originalIndex,O=y(_+t.firstItemIndex,E.data,c);return k?m.createElement(j,{...Le(j,c),height:E.size,index:E.index,key:O,type:E.type||"item",...E.type==="group"?{}:{groupIndex:E.groupIndex}}):E.type==="group"?m.createElement(h,{...Le(h,c),"data-index":_,"data-item-index":E.index,"data-known-size":E.size,key:O,style:Kl},f(E.index,c)):m.createElement(R,{...Le(R,c),...Jl(R,E.data),"data-index":_,"data-item-group-index":E.groupIndex,"data-item-index":E.index,"data-known-size":E.size,key:O,style:I?ql:Fs},T?d(E.index,E.groupIndex,E.data,c):d(E.index,E.data,c))})})}),Zl={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Yl={outline:"none",overflowX:"auto",position:"relative"},Br=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Xl={position:Fn(),top:0,width:"100%",zIndex:1};function Le(e,t){if(typeof e!="string")return{context:t}}function Jl(e,t){return{item:typeof e=="string"?void 0:t}}const Ql=Y.memo(function(){const e=ae("HeaderComponent"),t=Ke("headerHeight"),r=ae("HeaderFooterTag"),o=Lt(Y.useMemo(()=>a=>{t(wt(a,"height"))},[t]),!0,ae("skipAnimationFrameInResizeObserver")),s=ae("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Le(e,s)})}):null}),ec=Y.memo(function(){const e=ae("FooterComponent"),t=Ke("footerHeight"),r=ae("HeaderFooterTag"),o=Lt(Y.useMemo(()=>a=>{t(wt(a,"height"))},[t]),!0,ae("skipAnimationFrameInResizeObserver")),s=ae("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Le(e,s)})}):null});function Ps({useEmitter:e,useEmitterValue:t,usePublisher:r}){return Y.memo(function({children:o,style:s,context:a,...i}){const l=r("scrollContainerState"),d=t("ScrollerComponent"),c=r("smoothScrollTargetReached"),f=t("scrollerRef"),u=t("horizontalDirection")||!1,{scrollByCallback:p,scrollerRef:x,scrollToCallback:w}=Hs(l,c,d,f,void 0,u);return e("scrollTo",w),e("scrollBy",p),n.jsx(d,{"data-testid":"virtuoso-scroller","data-virtuoso-scroller":!0,ref:x,style:{...u?Yl:Zl,...s},tabIndex:0,...i,...Le(d,a),children:o})})}function Bs({useEmitter:e,useEmitterValue:t,usePublisher:r}){return Y.memo(function({children:o,style:s,context:a,...i}){const l=r("windowScrollContainerState"),d=t("ScrollerComponent"),c=r("smoothScrollTargetReached"),f=t("totalListHeight"),u=t("deviation"),p=t("customScrollParent"),x=Y.useRef(null),w=t("scrollerRef"),{scrollByCallback:I,scrollerRef:b,scrollToCallback:g}=Hs(l,c,d,w,p);return Os(()=>{var v;return b.current=p||((v=x.current)==null?void 0:v.ownerDocument.defaultView),()=>{b.current=null}},[b,p]),e("windowScrollTo",g),e("scrollBy",I),n.jsx(d,{ref:x,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...f!==0?{height:f+u}:{}},...i,...Le(d,a),children:o})})}const tc=({children:e})=>{const t=Y.useContext(_s),r=Ke("viewportHeight"),o=Ke("fixedItemHeight"),s=ae("alignToBottom"),a=ae("horizontalDirection"),i=Y.useMemo(()=>us(r,d=>wt(d,a?"width":"height")),[r,a]),l=Lt(i,!0,ae("skipAnimationFrameInResizeObserver"));return Y.useEffect(()=>{t&&(r(t.viewportHeight),o(t.itemHeight))},[t,r,o]),n.jsx("div",{"data-viewport-type":"element",ref:l,style:Br(s),children:e})},rc=({children:e})=>{const t=Y.useContext(_s),r=Ke("windowViewportRect"),o=Ke("fixedItemHeight"),s=ae("customScrollParent"),a=ms(r,s,ae("skipAnimationFrameInResizeObserver")),i=ae("alignToBottom");return Y.useEffect(()=>{t&&(o(t.itemHeight),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:100}))},[t,r,o]),n.jsx("div",{"data-viewport-type":"window",ref:a,style:Br(i),children:e})},nc=({children:e})=>{const t=ae("TopItemListComponent")||"div",r=ae("headerHeight"),o={...Xl,marginTop:`${r}px`},s=ae("context");return n.jsx(t,{style:o,...Le(t,s),children:e})},oc=Y.memo(function(e){const t=ae("useWindowScroll"),r=ae("topItemsIndexes").length>0,o=ae("customScrollParent"),s=ae("context");return n.jsxs(o||t?ic:ac,{...e,context:s,children:[r&&n.jsx(nc,{children:n.jsx(uo,{showTopList:!0})}),n.jsxs(o||t?rc:tc,{children:[n.jsx(Ql,{}),n.jsx(uo,{}),n.jsx(ec,{})]})]})}),{Component:sc,useEmitter:Bn,useEmitterValue:ae,usePublisher:Ke}=Ms(Gl,{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"}},oc),ac=Ps({useEmitter:Bn,useEmitterValue:ae,usePublisher:Ke}),ic=Bs({useEmitter:Bn,useEmitterValue:ae,usePublisher:Ke}),lc=sc,cc=xe(()=>{const e=F(c=>n.jsxs("td",{children:["Item $",c]})),t=F(null),r=F(c=>n.jsxs("td",{colSpan:1e3,children:["Group ",c]})),o=F(null),s=F(null),a=F({}),i=F(Pn),l=F(Gt),d=(c,f=null)=>Oe(L(a,G(u=>u[c]),we()),f);return{components:a,computeItemKey:i,context:t,EmptyPlaceholder:d("EmptyPlaceholder"),FillerRow:d("FillerRow"),fixedFooterContent:s,fixedHeaderContent:o,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")}});Ne(Ds,cc);Fn();const fo={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},dc={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:mo,floor:Dr,max:Jt,min:en,round:po}=Math;function ho(e,t,r){return Array.from({length:t-e+1}).map((o,s)=>({data:r===null?null:r[s+e],index:s+e}))}function uc(e){return{...dc,items:e}}function yr(e,t){return e&&e.width===t.width&&e.height===t.height}function fc(e,t){return e&&e.column===t.column&&e.row===t.row}const mc=xe(([{increaseViewportBy:e,listBoundary:t,overscan:r,visibleRange:o},{footerHeight:s,headerHeight:a,scrollBy:i,scrollContainerState:l,scrollTo:d,scrollTop:c,smoothScrollTargetReached:f,viewportHeight:u},p,x,{didMount:w,propsReady:I},{customScrollParent:b,useWindowScroll:g,windowScrollContainerState:v,windowScrollTo:N,windowViewportRect:j},S])=>{const R=F(0),h=F(0),y=F(fo),k=F({height:0,width:0}),T=F({height:0,width:0}),D=fe(),M=fe(),C=F(0),E=F(null),_=F({column:0,row:0}),O=fe(),H=fe(),z=F(!1),V=F(0),J=F(!0),P=F(!1),$=F(!1);ve(L(w,de(V),se(([A,B])=>!!B)),()=>{le(J,!1)}),ve(L(Ee(w,J,T,k,V,P),se(([A,B,ne,ue,,ge])=>A&&!B&&ne.height!==0&&ue.height!==0&&!ge)),([,,,,A])=>{le(P,!0),_n(1,()=>{le(D,A)}),Ye(L(c),()=>{le(t,[0,0]),le(J,!0)})}),X(L(H,se(A=>A!=null&&A.scrollTop>0),st(0)),h),ve(L(w,de(H),se(([,A])=>A!=null)),([,A])=>{A&&(le(k,A.viewport),le(T,A.item),le(_,A.gap),A.scrollTop>0&&(le(z,!0),Ye(L(c,Mt(1)),B=>{le(z,!1)}),le(d,{top:A.scrollTop})))}),X(L(k,G(({height:A})=>A)),u),X(L(Ee(oe(k,yr),oe(T,yr),oe(_,(A,B)=>A&&A.column===B.column&&A.row===B.row),oe(c)),G(([A,B,ne,ue])=>({gap:ne,item:B,scrollTop:ue,viewport:A}))),O),X(L(Ee(oe(R),o,oe(_,fc),oe(T,yr),oe(k,yr),oe(E),oe(h),oe(z),oe(J),oe(V)),se(([,,,,,,,A])=>!A),G(([A,[B,ne],ue,ge,q,te,me,,pe,ce])=>{const{column:ie,row:Ie}=ue,{height:je,width:Ze}=ge,{width:et}=q;if(me===0&&(A===0||et===0))return fo;if(Ze===0){const nt=Ln(ce,A),gt=nt+Math.max(me-1,0);return uc(ho(nt,gt,te))}const tt=zs(et,Ze,ie);let Ue,Ce;pe?B===0&&ne===0&&me>0?(Ue=0,Ce=me-1):(Ue=tt*Dr((B+Ie)/(je+Ie)),Ce=tt*mo((ne+Ie)/(je+Ie))-1,Ce=en(A-1,Jt(Ce,tt-1)),Ue=en(Ce,Jt(0,Ue))):(Ue=0,Ce=-1);const Q=ho(Ue,Ce,te),{bottom:be,top:Te}=go(q,ue,ge,Q),Re=mo(A/tt),rt=Re*je+(Re-1)*Ie-be;return{bottom:be,itemHeight:je,items:Q,itemWidth:Ze,offsetBottom:rt,offsetTop:Te,top:Te}})),y),X(L(E,se(A=>A!==null),G(A=>A.length)),R),X(L(Ee(k,T,y,_),se(([A,B,{items:ne}])=>ne.length>0&&B.height!==0&&A.height!==0),G(([A,B,{items:ne},ue])=>{const{bottom:ge,top:q}=go(A,ue,B,ne);return[q,ge]}),we(tr)),t);const W=F(!1);X(L(c,de(W),G(([A,B])=>B||A!==0)),W);const K=Ve(L(Ee(y,R),se(([{items:A}])=>A.length>0),de(W),se(([[A,B],ne])=>{const ue=A.items[A.items.length-1].index===B-1;return(ne||A.bottom>0&&A.itemHeight>0&&A.offsetBottom===0&&A.items.length===B)&&ue}),G(([[,A]])=>A-1),we())),U=Ve(L(oe(y),se(({items:A})=>A.length>0&&A[0].index===0),st(0),we())),Z=Ve(L(oe(y),de(z),se(([{items:A},B])=>A.length>0&&!B),G(([{items:A}])=>({endIndex:A[A.length-1].index,startIndex:A[0].index})),we(ys),ft(0)));X(Z,x.scrollSeekRangeChanged),X(L(D,de(k,T,R,_),G(([A,B,ne,ue,ge])=>{const q=js(A),{align:te,behavior:me,offset:pe}=q;let ce=q.index;ce==="LAST"&&(ce=ue-1),ce=Jt(0,ce,en(ue-1,ce));let ie=In(B,ge,ne,ce);return te==="end"?ie=po(ie-B.height+ne.height):te==="center"&&(ie=po(ie-B.height/2+ne.height/2)),pe&&(ie+=pe),{behavior:me,top:ie}})),d);const ee=Oe(L(y,G(A=>A.offsetBottom+A.bottom)),0);return X(L(j,G(A=>({height:A.visibleHeight,width:A.visibleWidth}))),k),{customScrollParent:b,data:E,deviation:C,footerHeight:s,gap:_,headerHeight:a,increaseViewportBy:e,initialItemCount:h,itemDimensions:T,overscan:r,restoreStateFrom:H,scrollBy:i,scrollContainerState:l,scrollHeight:M,scrollTo:d,scrollToIndex:D,scrollTop:c,smoothScrollTargetReached:f,totalCount:R,useWindowScroll:g,viewportDimensions:k,windowScrollContainerState:v,windowScrollTo:N,windowViewportRect:j,...x,gridState:y,horizontalDirection:$,initialTopMostItemIndex:V,totalListHeight:ee,...p,endReached:K,propsReady:I,rangeChanged:Z,startReached:U,stateChanged:O,stateRestoreInProgress:z,...S}},Ne(On,Pe,fr,Rs,kt,Hn,jt));function zs(e,t,r){return Jt(1,Dr((e+r)/(Dr(t)+r)))}function go(e,t,r,o){const{height:s}=r;if(s===void 0||o.length===0)return{bottom:0,top:0};const a=In(e,t,r,o[0].index);return{bottom:In(e,t,r,o[o.length-1].index)+s,top:a}}function In(e,t,r,o){const s=zs(e.width,r.width,t.column),a=Dr(o/s),i=a*r.height+Jt(0,a-1)*t.row;return i>0?i+t.row:i}const pc=xe(()=>{const e=F(u=>`Item ${u}`),t=F({}),r=F(null),o=F("virtuoso-grid-item"),s=F("virtuoso-grid-list"),a=F(Pn),i=F("div"),l=F(Gt),d=(u,p=null)=>Oe(L(t,G(x=>x[u]),we()),p),c=F(!1),f=F(!1);return X(oe(f),c),{components:t,computeItemKey:a,context:r,FooterComponent:d("Footer"),HeaderComponent:d("Header"),headerFooterTag:i,itemClassName:o,ItemComponent:d("Item","div"),itemContent:e,listClassName:s,ListComponent:d("List","div"),readyStateChanged:c,reportReadyState:f,ScrollerComponent:d("Scroller","div"),scrollerRef:l,ScrollSeekPlaceholder:d("ScrollSeekPlaceholder","div")}}),hc=xe(([e,t])=>({...e,...t}),Ne(mc,pc)),gc=Y.memo(function(){const e=ke("gridState"),t=ke("listClassName"),r=ke("itemClassName"),o=ke("itemContent"),s=ke("computeItemKey"),a=ke("isSeeking"),i=qe("scrollHeight"),l=ke("ItemComponent"),d=ke("ListComponent"),c=ke("ScrollSeekPlaceholder"),f=ke("context"),u=qe("itemDimensions"),p=qe("gap"),x=ke("log"),w=ke("stateRestoreInProgress"),I=qe("reportReadyState"),b=Lt(Y.useMemo(()=>g=>{const v=g.parentElement.parentElement.scrollHeight;i(v);const N=g.firstChild;if(N){const{height:j,width:S}=N.getBoundingClientRect();u({height:j,width:S})}p({column:xo("column-gap",getComputedStyle(g).columnGap,x),row:xo("row-gap",getComputedStyle(g).rowGap,x)})},[i,u,p,x]),!0,!1);return Os(()=>{e.itemHeight>0&&e.itemWidth>0&&I(!0)},[e]),w?null:n.jsx(d,{className:t,ref:b,...Le(d,f),"data-testid":"virtuoso-item-list",style:{paddingBottom:e.offsetBottom,paddingTop:e.offsetTop},children:e.items.map(g=>{const v=s(g.index,g.data,f);return a?n.jsx(c,{...Le(c,f),height:e.itemHeight,index:g.index,width:e.itemWidth},v):m.createElement(l,{...Le(l,f),className:r,"data-index":g.index,key:v},o(g.index,g.data,f))})})}),xc=Y.memo(function(){const e=ke("HeaderComponent"),t=qe("headerHeight"),r=ke("headerFooterTag"),o=Lt(Y.useMemo(()=>a=>{t(wt(a,"height"))},[t]),!0,!1),s=ke("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Le(e,s)})}):null}),vc=Y.memo(function(){const e=ke("FooterComponent"),t=qe("footerHeight"),r=ke("headerFooterTag"),o=Lt(Y.useMemo(()=>a=>{t(wt(a,"height"))},[t]),!0,!1),s=ke("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Le(e,s)})}):null}),yc=({children:e})=>{const t=Y.useContext(Ls),r=qe("itemDimensions"),o=qe("viewportDimensions"),s=Lt(Y.useMemo(()=>a=>{o(a.getBoundingClientRect())},[o]),!0,!1);return Y.useEffect(()=>{t&&(o({height:t.viewportHeight,width:t.viewportWidth}),r({height:t.itemHeight,width:t.itemWidth}))},[t,o,r]),n.jsx("div",{ref:s,style:Br(!1),children:e})},bc=({children:e})=>{const t=Y.useContext(Ls),r=qe("windowViewportRect"),o=qe("itemDimensions"),s=ke("customScrollParent"),a=ms(r,s,!1);return Y.useEffect(()=>{t&&(o({height:t.itemHeight,width:t.itemWidth}),r({offsetTop:0,visibleHeight:t.viewportHeight,visibleWidth:t.viewportWidth}))},[t,r,o]),n.jsx("div",{ref:a,style:Br(!1),children:e})},wc=Y.memo(function({...e}){const t=ke("useWindowScroll"),r=ke("customScrollParent"),o=r||t?Ic:Nc,s=r||t?bc:yc,a=ke("context");return n.jsx(o,{...e,...Le(o,a),children:n.jsxs(s,{children:[n.jsx(xc,{}),n.jsx(gc,{}),n.jsx(vc,{})]})})}),{useEmitter:Ws,useEmitterValue:ke,usePublisher:qe}=Ms(hc,{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"}},wc),Nc=Ps({useEmitter:Ws,useEmitterValue:ke,usePublisher:qe}),Ic=Bs({useEmitter:Ws,useEmitterValue:ke,usePublisher:qe});function xo(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,We.WARN),t==="normal"?0:parseInt(t??"0",10)}function ar(e){return e!=null&&typeof e=="object"&&"stack"in e&&typeof e.stack=="string"}function Mr({value:e}){const t=e.stack,r=typeof e.message=="string"?e.message:void 0,o=r?`${r}
27
-
28
- ${t}`:t;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 error",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(o).then(()=>{he.success("Copied to clipboard")}).catch(()=>{he.error("Failed to copy")})},children:n.jsx(ir,{size:12})}),r&&n.jsx("p",{className:"pb-2 mb-2 text-xs font-semibold font-mono",style:{color:"var(--ds-red-900)",borderBottom:"1px solid var(--ds-gray-300)"},children:r}),n.jsx("pre",{className:"text-xs font-mono whitespace-pre-wrap break-words overflow-auto m-0",style:{color:"var(--ds-gray-1000)"},children:t})]})}const jc=new Set(["step_failed","step_retrying","run_failed","workflow_failed"]),zn={appearance:"none",WebkitAppearance:"none",border:"none",background:"transparent"},$s="workflow-dot-pulse 1.25s cubic-bezier(0, 0, 0.2, 1) infinite";function kc(e){return e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})+"."+e.getMilliseconds().toString().padStart(3,"0")}function Sc(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Cc(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 Tc(e,t){var s;const r=new Map;if(e)for(const a of e){const i=lr(String(a.stepName));r.set(a.stepId,(i==null?void 0:i.shortName)??a.stepName)}const o=t!=null&&t.workflowName?((s=bt(t.workflowName))==null?void 0:s.shortName)??t.workflowName:null;return{correlationNameMap:r,workflowName:o}}function Ec(e){const t=new Map,r=new Map,o=new Map;for(const s of e){const a=new Date(s.createdAt).getTime(),i=s.correlationId??"__run__",l=s.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=o.get(i)??{};d!==void 0&&(c.queued=a-d),o.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=o.get(i)??{};d!==void 0&&(c.ran=a-d),o.set(i,c)}}return o}function jn(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 kn=36,Rc=20,tn="var(--ds-gray-500)";function vo({isFirst:e,isLast:t,isRunLevel:r,statusDotColor:o,pulse:s=!1,hasSelection:a,showBranch:i,showLaneLine:l,isLaneStart:d,isLaneEnd:c,continuationOnly:f=!1}){const u=r?8:6,p=r?5:6,x=a&&!i&&!r?.3:1;return n.jsxs("div",{className:"relative flex-shrink-0 self-stretch",style:{width:kn,minHeight:f?0:void 0},children:[n.jsx("div",{style:{position:"absolute",left:8,top:f?0:e?"50%":0,bottom:f?0:t?"50%":0,width:2,backgroundColor:tn,zIndex:0}}),!f&&n.jsxs(n.Fragment,{children:[n.jsxs("div",{style:{position:"absolute",left:p,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}}),s&&n.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:o,opacity:.75*x,animation:$s,zIndex:1}}),n.jsx("div",{style:{position:"relative",width:"100%",height:"100%",borderRadius:"50%",backgroundColor:o,opacity:x,transition:"opacity 150ms",zIndex:2}})]}),i&&n.jsx("div",{style:{position:"absolute",left:9,top:"50%",width:kn-9,height:2,backgroundColor:tn,zIndex:0}})]}),l&&n.jsx("div",{style:{position:"absolute",left:Rc,top:f?0:d?"50%":0,bottom:f?0:c?"50%":0,width:2,backgroundColor:tn,zIndex:0}})]})}function yo({value:e,className:t}){const[r,o]=m.useState(!1),s=m.useRef(null);m.useEffect(()=>()=>{s.current!==null&&window.clearTimeout(s.current)},[]);const a=m.useCallback(i=>{i.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{o(!0),s.current!==null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{o(!1),s.current=null},1500)})},[e]);return n.jsxs("div",{className:`group/copy flex items-center gap-1 flex-1 min-w-0 px-4 ${t??""}`,children:[n.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:e||"-"}),e?n.jsx("button",{type:"button",onClick:a,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:zn,"aria-label":`Copy ${e}`,children:r?n.jsx(Qo,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}):n.jsx(ir,{className:"h-3 w-3",style:{color:"var(--ds-gray-700)"}})}):null]})}function kr(e){if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")||t.startsWith('"')&&t.endsWith('"'))try{return kr(JSON.parse(t))}catch{return e}return e}if(Array.isArray(e))return e.map(kr);if(e!==null&&typeof e=="object"){if(e.constructor!==Object)return e;const t={};for(const[r,o]of Object.entries(e))t[r]=kr(o);return t}return e}function Ac(e,t){if(!t||!jc.has(t)||e==null||typeof e!="object")return null;const r=e;return ar(r.error)?r.error:ar(r)?r:null}function Dc({data:e,eventType:t}){const r=m.useMemo(()=>Ac(e,t),[e,t]),[o,s]=m.useState(!1),a=m.useRef(null),i=m.useMemo(()=>kr(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(()=>{s(!0),a.current!==null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{s(!1),a.current=null},1500)})},[l]);return r?n.jsx("div",{className:"p-2",children:n.jsx(Mr,{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(Tr,{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:{...zn,color:"var(--ds-gray-700)"},"aria-label":"Copy payload",children:o?n.jsxs(n.Fragment,{children:[n.jsx(Qo,{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(ir,{className:"h-3 w-3"}),n.jsx("span",{children:"Copy"})]})})]})}function Mc({event:e,index:t,isFirst:r,isLast:o,activeGroupKey:s,selectedGroupKey:a,selectedGroupRange:i,correlationNameMap:l,workflowName:d,durationMap:c,onSelectGroup:f,onHoverGroup:u,onLoadEventData:p,encryptionKey:x}){const[w,I]=m.useState(!1),[b,g]=m.useState(!1),[v,N]=m.useState(null),[j,S]=m.useState(null),[R,h]=m.useState(!1),y=e.correlationId??(jn(e.eventType)?"__run__":void 0);m.useEffect(()=>{a!==void 0&&a!==y&&I(!1)},[a,y]);const k=Cc(e.eventType),T=new Date(e.createdAt),D="eventData"in e&&e.eventData!=null,M=jn(e.eventType),C=M?d??"-":e.correlationId?l.get(e.correlationId)??"-":"-",E=e.correlationId??(M?"__run__":""),_=E?c.get(E):void 0,O=s!==void 0,H=y!==void 0&&y===s,z=O&&!H,V=O&&H,J=O&&H&&!M,P=i!==null&&t>=i.first&&t<=i.last,$=i!==null&&t===i.first,W=i!==null&&t===i.last,K=m.useCallback(async()=>{if(!(v!==null||D)){g(!0),S(null);try{if(!p){S("Event details unavailable");return}const B=await p(e);B!=null&&N(B)}catch(B){S(B instanceof Error?B.message:"Failed to load event details")}finally{g(!1),h(!0)}}},[e,v,D,p]);m.useEffect(()=>{x&&R&&p&&(N(null),h(!1),p(e).then(B=>{B!=null&&N(B),h(!0)}).catch(()=>{h(!0)}))},[x]);const U=m.useCallback(B=>{B.stopPropagation();const ne=!w;I(ne),ne&&v===null&&!D&&K()},[w,v,D,K]),Z=m.useCallback(()=>{f(a===y?void 0:y)},[a,y,f]),ee=D?e.eventData:v,A=z?.3:1;return n.jsxs("div",{"data-event-id":e.eventId,onMouseEnter:()=>u(y),onMouseLeave:()=>u(void 0),children:[n.jsxs("div",{role:"button",tabIndex:0,onClick:Z,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&Z()},className:"w-full text-left flex items-center gap-0 text-sm hover:bg-[var(--ds-gray-alpha-100)] transition-colors cursor-pointer",style:{minHeight:40},children:[n.jsx(vo,{isFirst:r,isLast:o&&!w,isRunLevel:M,statusDotColor:k,pulse:V,hasSelection:O,showBranch:J,showLaneLine:P,isLaneStart:$,isLaneEnd:W}),n.jsxs("div",{className:"flex items-center flex-1 min-w-0",style:{opacity:A,transition:"opacity 150ms"},children:[n.jsx("button",{type:"button",onClick:U,className:"flex items-center justify-center w-5 h-5 flex-shrink-0 rounded hover:bg-[var(--ds-gray-alpha-200)] transition-colors",style:{...zn,border:"1px solid var(--ds-gray-alpha-400)"},"aria-label":w?"Collapse details":"Expand details",children:n.jsx(Jo,{className:"h-3 w-3 transition-transform",style:{color:"var(--ds-gray-700)",transform:w?"rotate(90deg)":"rotate(0deg)"}})}),n.jsx("div",{className:"text-xs tabular-nums flex-1 min-w-0 px-4",style:{color:"var(--ds-gray-900)"},children:kc(T)}),n.jsx("div",{className:"text-xs font-medium flex-1 min-w-0 px-4",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:[V&&n.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:k,opacity:.75,animation:$s}}),n.jsx("span",{style:{position:"relative",width:6,height:6,borderRadius:"50%",backgroundColor:k}})]}),Sc(e.eventType)]})}),n.jsx("div",{className:"text-xs flex-1 min-w-0 px-4 overflow-hidden text-ellipsis whitespace-nowrap",title:C!=="-"?C:void 0,children:C}),n.jsx(yo,{value:e.correlationId||"",className:"font-mono text-xs"}),n.jsx(yo,{value:e.eventId,className:"font-mono text-xs"})]})]}),w&&n.jsxs("div",{className:"flex",children:[n.jsx(vo,{isFirst:!1,isLast:o,isRunLevel:M,hasSelection:O,showBranch:!1,showLaneLine:P&&!W,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:A,transition:"opacity 150ms"},children:[((_==null?void 0:_.queued)!==void 0||(_==null?void 0:_.ran)!==void 0)&&n.jsxs("div",{className:"px-2 pb-1.5 text-xs flex gap-3",style:{color:"var(--ds-gray-900)"},children:[_.queued!==void 0&&_.queued>0&&n.jsxs("span",{children:["Queued for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:At(_.queued)})]}),_.ran!==void 0&&n.jsxs("span",{children:["Ran for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:At(_.ran)})]})]}),ee!=null?n.jsx(Dc,{data:ee,eventType:e.eventType}):j?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:j}):b||!D&&!R&&e.correlationId?n.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[n.jsx(Me,{className:"h-3",style:{width:"75%"}}),n.jsx(Me,{className:"h-3",style:{width:"50%"}}),n.jsx(Me,{className:"h-3",style:{width:"60%"}})]}):n.jsx("div",{className:"p-2 text-xs",style:{color:"var(--ds-gray-900)"},children:"No data"})]})]})]})}function _c({events:e,steps:t,run:r,onLoadEventData:o,hasMoreEvents:s=!1,isLoadingMoreEvents:a=!1,onLoadMoreEvents:i,encryptionKey:l}){const d=m.useMemo(()=>!e||e.length===0?[]:[...e].sort((y,k)=>new Date(y.createdAt).getTime()-new Date(k.createdAt).getTime()),[e]),{correlationNameMap:c,workflowName:f}=m.useMemo(()=>Tc(t??null,r??null),[t,r]),u=m.useMemo(()=>Ec(d),[d]),[p,x]=m.useState(void 0),[w,I]=m.useState(void 0),b=m.useCallback(y=>{x(y)},[]),g=m.useCallback(y=>{I(y)},[]),v=p??w,N=m.useMemo(()=>{if(!v||v==="__run__")return null;let y=-1,k=-1;for(let T=0;T<d.length;T++)d[T].correlationId===v&&(y===-1&&(y=T),k=T);return y>=0?{first:y,last:k}:null},[v,d]),[j,S]=m.useState(""),R=m.useRef(null),h=m.useMemo(()=>{const y=[];for(let k=0;k<d.length;k++){const T=d[k];y.push({text:[T.eventId,T.correlationId??""].join(" ").toLowerCase(),groupKey:T.correlationId??(jn(T.eventType)?"__run__":void 0),eventId:T.eventId,index:k})}return y},[d]);return m.useEffect(()=>{var T;const y=j.trim().toLowerCase();if(!y){x(void 0);return}const k=h.find(D=>D.text.includes(y));k&&(x(k.groupKey),(T=R.current)==null||T.scrollToIndex({index:k.index,align:"center",behavior:"smooth"}))},[j,h]),!e||e.length===0?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.jsx("div",{style:{padding:6,backgroundColor:"var(--ds-background-100)"},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},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 event ID or correlation ID…",value:j,onChange:y=>S(y.target.value),style:{marginLeft:-16,paddingInline:12,fontFamily:"inherit",fontSize:14,background:"transparent",border:"none",outline:"none",height:40,width:"100%"}})]})}),n.jsxs("div",{className:"flex items-center gap-0 text-sm 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:kn}}),n.jsx("div",{className:"w-5 flex-shrink-0"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Time"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Event Type"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Name"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Correlation ID"}),n.jsx("div",{className:"flex-1 min-w-0 px-4",children:"Event ID"})]}),n.jsx(lc,{ref:R,totalCount:d.length,overscan:20,defaultItemHeight:40,endReached:()=>{!s||a||i==null||i()},itemContent:y=>n.jsx(Mc,{event:d[y],index:y,isFirst:y===0,isLast:y===d.length-1,activeGroupKey:v,selectedGroupKey:p,selectedGroupRange:N,correlationNameMap:c,workflowName:f,durationMap:u,onSelectGroup:b,onHoverGroup:g,onLoadEventData:o,encryptionKey:l}),components:{Footer:()=>n.jsxs(n.Fragment,{children:[s&&n.jsx("div",{className:"px-3 pt-3 flex justify-center",children:n.jsx("button",{type:"button",onClick:()=>void(i==null?void 0:i()),disabled:a,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:a?"Loading more events...":"Load more"})}),n.jsxs("div",{className:"mt-4 pt-3 border-t text-xs px-3",style:{borderColor:"var(--ds-gray-alpha-200)",color:"var(--ds-gray-900)"},children:[d.length," event",d.length!==1?"s":""," total"]})]})},style:{flex:1,minHeight:0}})]})}function Lc({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(Oc,{message:t},r))})}function Oc({message:e}){const t=e.role,r=Pc(e.content),o=Fc(t);return n.jsxs("div",{className:"rounded-md border text-[11px]",style:{backgroundColor:o.bg,borderColor:o.border},children:[n.jsx("div",{className:"px-2.5 py-1 border-b text-[10px] font-medium uppercase tracking-wide",style:{borderColor:o.border,color:o.label},children:t}),n.jsx("div",{className:"px-2.5 py-2 space-y-2",children:r.map((s,a)=>n.jsx(Hc,{part:s,role:t},a))})]})}function Hc({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(xi,{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(Tr,{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(Tr,{data:e.output,expandLevel:1})})]}):null}function Fc(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 Pc(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 Bc=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 Vs({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(Bc(e)).then(()=>{he.success("Copied to clipboard")}).catch(()=>{he.error("Failed to copy")})},children:n.jsx(ir,{size:12})}),n.jsx(Tr,{data:e})]})}function Fe({summary:e,children:t,onToggle:r,disabled:o=!1,summaryClassName:s,contentClassName:a}){return o?n.jsx("div",{className:`rounded-md border px-2.5 py-1.5 text-xs ${s??""}`,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 ${s??""}`,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-900)"},children: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 zc({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 Wc({tabs:e,activeTab:t,onTabChange:r,ariaLabel:o,children:s}){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":o,onKeyDown:a,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:e.map(i=>n.jsx(zc,{active:t===i.id,onClick:()=>r(i.id),children:i.label},i.id))}),n.jsx("div",{role:"tabpanel",children:s})]})}const $c=[{id:"conversation",label:"Conversation"},{id:"json",label:"Raw JSON"}];function Vc({conversation:e,args:t}){const[r,o]=m.useState("conversation");return n.jsx(Fe,{summary:`Input (${e.length} messages)`,children:n.jsx(Wc,{tabs:$c,activeTab:r,onTabChange:o,ariaLabel:"Conversation view",children:r==="conversation"?n.jsx(Lc,{messages:e}):n.jsx("div",{className:"p-3",children:Array.isArray(t)?t.map((s,a)=>n.jsx("div",{className:"mt-2 first:mt-0",children:Be(s)},a)):Be(t)})})})}function Ut(){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(ss,{className:"h-3 w-3"}),n.jsx("span",{className:"font-medium",children:"Encrypted"})]})}function Be(e){return n.jsx(Vs,{data:e})}const xt=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,bo=["workflowName","moduleSpecifier","stepName","status","stepId","hookId","eventId","runId","attempt","token","correlationId","eventType","deploymentId","specVersion","workflowCoreVersion","ownerId","projectId","environment","executionContext","createdAt","startedAt","updatedAt","completedAt","expiredAt","retryAfter","error","metadata","eventData","input","output","resumeAt"],wo=(e,t)=>{const r=bo.indexOf(e)||0,o=bo.indexOf(t)||0;return r-o},Gc={workflowCoreVersion:"@workflow/core version"},Uc=e=>Gc[e]??e,Kc=e=>{const t=String(e),r=lr(t);if(r)return r.moduleSpecifier;const o=bt(t);return o?o.moduleSpecifier:t},Gs=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},Us=e=>e.toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}),qc=e=>{const t=Gs(e);return t?Us(t):"-"},Tt=e=>{const t=Gs(e);return t?Us(t):null},Zt={workflowName:e=>{var t;return((t=bt(String(e)))==null?void 0:t.shortName)??"?"},moduleSpecifier:e=>Kc(e),stepName:e=>{var t;return((t=lr(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),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:Tt,startedAt:Tt,updatedAt:Tt,completedAt:Tt,expiredAt:Tt,retryAfter:Tt,resumeAt:Tt,metadata:e=>xt(e)?at(e)?n.jsx(Ut,{}):Be(e):null,input:(e,t)=>{if(at(e))return n.jsx(Ut,{});if(e&&typeof e=="object"&&"args"in e){const{args:s,closureVars:a,thisVal:i}=e,l=Array.isArray(s)?s.length:0,d=l===1?"argument":"arguments",c=xt(a),f=xt(i),u=xt(s);if(t!=null&&t.stepName&&yi(t.stepName)){const p=bi(s);if(p&&p.length>0)return n.jsxs(n.Fragment,{children:[n.jsx(Vc,{conversation:p,args:s}),c&&n.jsx(Fe,{summary:"Closure Variables",children:Be(a)}),f&&n.jsx(Fe,{summary:"This Value",children:Be(i)})]})}return!u&&!c&&!f?n.jsx(Fe,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"}):n.jsxs(n.Fragment,{children:[n.jsx(Fe,{summary:`Input (${l} ${d})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(s)?s.map((p,x)=>n.jsx("div",{className:"mt-2 first:mt-0",children:Be(p)},x)):Be(s)}),c&&n.jsx(Fe,{summary:"Closure Variables",children:Be(a)}),f&&n.jsx(Fe,{summary:"this",children:Be(i)})]})}const r=Array.isArray(e)?e.length:0,o=r===1?"argument":"arguments";return xt(e)?n.jsx(Fe,{summary:`Input (${r} ${o})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(e)?e.map((s,a)=>n.jsx("div",{className:"mt-2 first:mt-0",children:Be(s)},a)):Be(e)}):n.jsx(Fe,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"})},output:e=>xt(e)?at(e)?n.jsx(Ut,{}):n.jsx(Fe,{summary:"Output",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Be(e)}):null,error:e=>at(e)?n.jsx(Ut,{}):xt(e)?ar(e)?n.jsx(Fe,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:n.jsx(Mr,{value:e})}):n.jsx(Fe,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Be(e)}):null,eventData:e=>at(e)?n.jsx(Ut,{}):xt(e)?n.jsx(Fe,{summary:"Event Data",children:Be(e)}):null},No=["input","output","error","metadata","eventData"],Zc=()=>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."})}),Yc=({attribute:e,value:t,isLoading:r,inline:o=!1,context:s})=>{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(Fe,{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(Me,{className:"h-4 w-[38%]"}),n.jsx(Me,{className:"mt-2 h-4 w-[88%]"}),n.jsx(Me,{className:"mt-2 h-4 w-[72%]"})]})]})}const i=Zt[e];if(!i)return null;const l=i(t,s);return l?o?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},Xc=({data:e,moduleSpecifier:t,isLoading:r,error:o,expiredAt:s,onStreamClick:a})=>{const i=m.useMemo(()=>{const w={...e},I=e.executionContext;return I!=null&&I.workflowCoreVersion&&(w.workflowCoreVersion=I.workflowCoreVersion),t?w.moduleSpecifier=t:typeof e.stepName=="string"?w.moduleSpecifier=e.stepName:typeof e.workflowName=="string"&&(w.moduleSpecifier=e.workflowName),w},[e,t]),l=s!=null&&new Date(s)<new Date,d=Object.keys(i).filter(w=>!No.includes(w)).sort(wo),c=Object.keys(i).filter(w=>No.includes(w)).sort(wo),f=d.filter(w=>{const I=Zt[w];return I?I(i[w])!==null:!1}),u=m.useMemo(()=>{const w=[...f],I=w.indexOf("moduleSpecifier");if(I===-1)return w;w.splice(I,1);const b=w.indexOf("workflowName");if(b!==-1)return w.splice(b+1,0,"moduleSpecifier"),w;const g=w.indexOf("stepName");return g!==-1?(w.splice(g+1,0,"moduleSpecifier"),w):(w.unshift("moduleSpecifier"),w)},[f]),p=m.useMemo(()=>({stepName:i.stepName}),[i.stepName]),x=m.useCallback(w=>{navigator.clipboard.writeText(w).then(()=>{he.success("moduleSpecifier copied")}).catch(()=>{he.error("Failed to copy moduleSpecifier")})},[]);return n.jsx(vi.Provider,{value:a,children:n.jsxs("div",{children:[f.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((w,I)=>{var j;const b=(j=Zt[w])==null?void 0:j.call(Zt,i[w]),g=w==="moduleSpecifier",v=typeof b=="string"?b:String(b??i.moduleSpecifier??""),N=I<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:"text-[14px] first-letter:uppercase",style:{color:"var(--ds-gray-700)"},children:Uc(w)}),g?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:v,onClick:()=>x(v),children:v}):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]},w)})}),o?n.jsx(Oa,{title:"Failed to load resource details",details:o.message,className:"my-4"}):l?n.jsx(Zc,{}):n.jsx(n.Fragment,{children:c.map(w=>n.jsx(Yc,{isLoading:r,attribute:w,value:i[w],context:p},w))})]})})},Jc=new Set(["step_failed","step_retrying"]),Qc=new Set(["step_created","step_completed","step_failed","hook_created","hook_received","run_created","run_completed"]);function ed({event:e,onLoadEventData:t,encryptionKey:r}){const[o,s]=m.useState(null),[a,i]=m.useState(!1),[l,d]=m.useState(null),c=m.useRef(!1),f="eventData"in e&&e.eventData!=null?e.eventData:null,u=f??o,p=Qc.has(e.eventType),x=m.useCallback(async()=>{if(!(!t||!e.correlationId||!e.eventId))try{i(!0),d(null);const b=await t(e.correlationId,e.eventId);s(b)}catch(b){d(b instanceof Error?b.message:String(b))}finally{i(!1)}},[t,e.correlationId,e.eventId]),w=m.useCallback(async()=>{f||o!==null||a||(c.current=!0,await x())},[f,o,a,x]);m.useEffect(()=>{r&&c.current&&o!==null&&(s(null),x())},[r]);const I=new Date(e.createdAt);return n.jsxs(Fe,{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:qc(I.getTime())})]}),onToggle:p?b=>{b&&w()}: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(Me,{className:"h-4 w-[35%]"}),n.jsx(Me,{className:"mt-2 h-4 w-[90%]"}),n.jsx(Me,{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(td,{eventType:e.eventType,data:u})})]})}function td({eventType:e,data:t}){if(Jc.has(e)&&t!=null&&typeof t=="object"){const r=t;if(ar(r.error))return n.jsx(Mr,{value:r.error});if(ar(r))return n.jsx(Mr,{value:r})}return n.jsx(Vs,{data:t})}function rd({events:e,isLoading:t=!1,error:r,onLoadEventData:o,encryptionKey:s}){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(Me,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(Me,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(Me,{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(ed,{event:i,onLoadEventData:o,encryptionKey:s},i.eventId))}):null]})}function nd(e){return e!==null&&typeof e=="object"&&"stepId"in e}function od(e){return e!==null&&typeof e=="object"&&"runId"in e}function br(e){return e!==null&&typeof e=="object"&&"hookId"in e}function sd({run:e,hooks:t,onStreamClick:r,spanDetailData:o,spanDetailError:s,spanDetailLoading:a,onSpanSelect:i,onWakeUpSleep:l,onLoadEventData:d,onResolveHook:c,encryptionKey:f,selectedSpan:u}){const[p,x]=m.useState(!1),[w,I]=m.useState(!1),[b,g]=m.useState(!1),[v,N]=m.useState(new Set),j=u==null?void 0:u.data,S=u==null?void 0:u.rawEvents,R=(S==null?void 0:S.length)??0,{resource:h,resourceId:y,runId:k}=m.useMemo(()=>{if(!u)return{resource:void 0,resourceId:void 0,runId:void 0};const $=u.resource;return $==="step"&&nd(j)?{resource:"step",resourceId:j.stepId,runId:j.runId}:$==="run"&&od(j)?{resource:"run",resourceId:j.runId,runId:void 0}:$==="hook"&&br(j)?{resource:"hook",resourceId:j.hookId,runId:void 0}:$==="sleep"?{resource:"sleep",resourceId:u.spanId,runId:void 0}:{resource:void 0,resourceId:void 0,runId:void 0}},[u,j]);m.useEffect(()=>{h&&y&&["run","step","hook","sleep"].includes(h)&&i({resource:h,resourceId:y,runId:k})},[h,y,k,i]);const T=m.useMemo(()=>h!=="sleep"||!S||["completed","failed","cancelled"].includes(e.status)||!S.some(U=>U.eventType==="wait_created")?!1:!S.some(U=>U.eventType==="wait_completed"),[h,S,R,e.status]),D=m.useMemo(()=>!(h!=="hook"||!S||!y||v.has(y)||["completed","failed","cancelled"].includes(e.status)||S.some(K=>K.eventType==="hook_disposed")),[h,y,S,R,e.status,v]),M=s??void 0,C=a??!1,E=m.useMemo(()=>{if(h!=="hook"||!y)return;if(br(o)&&o.token)return o.token;const $=t==null?void 0:t.find(W=>W.hookId===y);if($!=null&&$.token)return $.token;if(br(j)&&j.token)return j.token},[h,y,o,j,t]);m.useEffect(()=>{M&&u&&h&&he.error(`Failed to load ${h} details`,{description:M.message})},[M,h,u]);const _=async()=>{if(!(p||!y)){if(!l){he.error("Unable to wake up sleep",{description:"No wake-up handler provided."});return}try{x(!0),(await l(e.runId,y)).stoppedCount>0?he.success("Run woken up",{description:"The sleep call has been interrupted and the run woken up."}):he.info("Sleep already completed",{description:"This sleep call has already finished."})}catch($){console.error("Failed to wake up run:",$),he.error("Failed to wake up run",{description:$ instanceof Error?$.message:"An unknown error occurred"})}finally{x(!1)}}},O=m.useCallback(async $=>{if(!b){if(!c){he.error("Unable to resolve hook",{description:"No resolve handler provided."});return}if(!E){he.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{g(!0);const W=o??j,K=br(W)?W:void 0;await c(E,$,K),he.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),I(!1),y&&N(U=>new Set(U).add(y))}catch(W){console.error("Failed to resolve hook:",W),he.error("Failed to resolve hook",{description:W instanceof Error?W.message:"An unknown error occurred"})}finally{g(!1)}}},[c,E,b,o,j]);if(!u||!h||!y)return null;const H=h==="sleep"?j:o??j,z=m.useMemo(()=>{const $=H,W=$.stepName,K=$.workflowName;if(typeof W=="string")return W;if(typeof K=="string")return K;if(typeof e.workflowName=="string")return e.workflowName},[H,e.workflowName]),V=h.charAt(0).toUpperCase()+h.slice(1),J=h==="sleep"&&T||h==="hook"&&D,P=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.jsx("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:V}),n.jsx("span",{className:"text-[13px]",style:{color:e.completedAt?"var(--ds-gray-700)":"var(--ds-green-800)"},children:P})]}),n.jsx("p",{className:"mt-1 truncate font-mono text-[13px]",style:{color:"var(--ds-gray-700)"},title:y,children:y})]})})}),n.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pt-3 pb-8",children:[J&&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:[h==="sleep"&&T&&n.jsxs("button",{type:"button",onClick:_,disabled:p,className:Dt("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",p?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-amber-200)",color:"var(--ds-amber-900)"},children:[n.jsx(Ha,{className:"h-4 w-4"}),p?"Waking up...":"Wake Up Sleep"]}),h==="hook"&&D&&n.jsxs("button",{type:"button",onClick:()=>I(!0),disabled:b,className:Dt("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(es,{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(Xc,{data:H,moduleSpecifier:z,expiredAt:e.expiredAt,isLoading:C,error:M??void 0,onStreamClick:r})]}),h!=="run"&&S&&n.jsx("section",{children:n.jsx(rd,{events:S,onLoadEventData:d,encryptionKey:f})})]})]}),n.jsx(ts,{isOpen:w,onClose:()=>I(!1),onSubmit:O,isSubmitting:b})]})}function ad(e){const t=m.useRef(e);t.current=e,m.useEffect(()=>{let r=0,o=0;const s=()=>{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(o),o=requestAnimationFrame(s)};return window.addEventListener("wheel",a,{passive:!1}),()=>{window.removeEventListener("wheel",a),cancelAnimationFrame(o)}},[])}function Io(e){if(e<=0)return 1;const r=10**Math.floor(Math.log10(e)),o=e/r;return o<=1.5?r:o<=3.5?2*r:o<=7.5?5*r:10*r}function id({scale:e,isLive:t=!1}){const{state:{root:r}}=dt(),[,o]=m.useState(0);m.useEffect(()=>{if(!t)return;const p=setInterval(()=>o(x=>x+1),1e3);return()=>clearInterval(p)},[t]);const s=r.duration,a=e>0?e:s>0?1/s:1;let l=Io(50/a);l=Math.max(1,l);let d=l*a;const c=1e3;s/l>c&&(l=Io(s/c),d=l*a);const f=Math.ceil(s/l),u=Math.ceil(100/d)||1;return n.jsx("div",{className:re.markersContainer,children:n.jsx("div",{"aria-hidden":!0,className:re.markers,style:{width:Math.floor(r.duration*e+15),visibility:e!==-1?"visible":"hidden","--marker-width":`${d}px`},children:new Array(f).fill(null).map((p,x)=>{const w=x%u===0;return n.jsx("span",{className:Dt(re.marker,!w&&re.notch),children:w?n.jsxs("span",{className:re.markerLabel,children:[wi(l*x),n.jsx("span",{className:re.markerClockTime,children:Ni(r.startTime+l*x)})]}):null},String(x))})})})}function ld({events:e,root:t,scale:r}){const o=m.useMemo(()=>e.filter(s=>s.event.showVerticalLine!==!1),[e]);return n.jsx("div",{className:re.eventMarkersContainer,children:n.jsx("div",{"aria-hidden":!0,className:re.eventMarkers,style:{width:Math.floor(t.duration*r)},children:o.map(s=>n.jsx("span",{className:Dt(re.eventMarker),style:{left:Math.floor((s.timestamp-t.startTime)*r),...s.event.color&&{borderLeftColor:s.event.color}}},s.key))})})}const jo=2;function cd({memoCacheRef:e,timelineRef:t,root:r,spans:o,events:s,scale:a,dispatch:i,scrollSnapshotRef:l}){const d=m.useRef(!1),c=m.useRef(o);c.current=o;const f=m.useRef(s);f.current=s;const u=m.useRef(null),{style:p,setStyle:x}=Vr(u),w=m.useRef(null),I=m.useRef(null),{style:b,setStyle:g}=Vr(I),v=m.useRef(void 0),N=m.useRef(null),{style:j,setStyle:S}=Vr(N),R=m.useRef(0);m.useEffect(()=>{const y=t.current;if(!y)return;let k=R.current,T=0,D=!1,M=!1,C=!1,E=!1,_=0,O=0;const H=Date.now()+500,z=()=>{v.current||(v.current=y.getBoundingClientRect())},V=q=>v.current?(q-Er-ze)/(Bt+yt):0,J=()=>{const q=e.current;for(const te of c.current)te.isHovered&&(te.isHovered=!1,q.set(te.span.spanId,{}));i({type:"forceRender"})};let P=0;const $=()=>{var je,Ze,et,tt,Ue,Ce,Q,be;if(!d.current)return;v.current||z();const q=v.current;if(!q)return;const{scrollLeft:te,scrollTop:me}=y,pe=Math.max(0,Math.min(k+te-q.left-ze,r.duration*a)),ce=`${pe-te+ze}px`;g("left",ce),x("left",ce);const ie=r.startTime+pe/a,Ie=ie-r.startTime;if(Ie<0||Ie>r.duration?(je=w.current)==null||je.removeAttribute("data-text"):(Ze=w.current)==null||Ze.setAttribute("data-text",xr(Ie)),D){const Te=k-T,Re=Math.abs(Te);if(!C){if(Re<4)return;C=!0,S("display","flex"),J()}Te>0?(S("left",""),S("right","0")):(S("left","0"),S("right","")),S("width",`${Re}px`);const nt=Math.max(0,Math.min(T+te-q.left-ze,r.duration*a))/a;let gt,St;nt<Ie?(gt=nt,St=Ie):(gt=Ie,St=nt),(et=N.current)==null||et.setAttribute("data-range",`${xr(gt)} — ${xr(St)}`),(tt=N.current)==null||tt.setAttribute("data-duration",`${xr(St-gt)} selected`)}if(Date.now()<H){P=requestAnimationFrame($);return}if(te!==_||me!==O){_=te,O=me,P=requestAnimationFrame($);return}if(k-q.left<128?(Ue=w.current)==null||Ue.setAttribute("data-align","left"):k-q.left>q.width-128?(Ce=w.current)==null||Ce.setAttribute("data-align","right"):(Q=w.current)==null||Q.removeAttribute("data-align"),!C&&!M){const Te=e.current,Re=V(me)-jo,rt=V(me+q.height)+jo;for(const He of c.current){const ot=He.row>=Re&&He.row<=rt&&ie>=He.startTime&&ie<=He.endTime;He.isHovered!==ot&&(He.isHovered=ot,Te.set(He.span.spanId,{}))}const gt=12/a;let St=null,Un=1/0;for(const He of f.current){const ot=Math.abs(He.timestamp-ie);ot<=gt&&ot<Un&&(Un=ot,St=He)}for(const He of f.current){const ot=He===St;if(He.isHovered===ot)continue;He.isHovered=ot;const Kn=(be=He.ref)==null?void 0:be.current;Kn&&Kn.setAttribute("data-hovered",String(ot))}i({type:"forceRender"})}};P=requestAnimationFrame($);const W=q=>{q.pointerType==="mouse"&&(d.current=!0)},K=()=>{d.current&&(d.current=!1,J())},U=({clientX:q})=>{k=q,R.current=k,cancelAnimationFrame(P),P=requestAnimationFrame($)},Z=q=>{q.preventDefault()},ee=q=>{var te;if(q.button===2)E=!0,q.preventDefault();else{if(q.button!==0)return;E=!1}(te=t.current)!=null&&te.contains(q.target)?(T=k,D=!0):(M=!0,requestAnimationFrame(J))},A=q=>{if(M=!1,!D||(D=!1,!C))return;if(C=!1,S("display",""),S("left",""),S("right",""),S("width",""),q.preventDefault(),q.stopImmediatePropagation(),E){E=!1;return}v.current||z();const te=v.current;if(!te)return;const{scrollLeft:me}=y,pe=Math.max(0,Math.min((T+me-te.left-ze)/a,r.duration)),ce=Math.max(0,Math.min((k+me-te.left-ze)/a,r.duration));i({type:"scaleToRange",t1:pe+r.startTime,t2:ce+r.startTime})},B=q=>{D&&q.key==="Escape"&&(E=!0,A(q))},ne=()=>{v.current=void 0,h.current=void 0,cancelAnimationFrame(P),P=requestAnimationFrame($)},ue=()=>{cancelAnimationFrame(P),P=requestAnimationFrame($)},ge=new ResizeObserver(()=>{v.current=void 0});return ge.observe(y),window.addEventListener("mousemove",U),y.addEventListener("contextmenu",Z),window.addEventListener("mousedown",ee),window.addEventListener("mouseup",A),window.addEventListener("blur",A),window.addEventListener("keydown",B,!0),window.addEventListener("scroll",ne),y.addEventListener("scroll",ue),y.addEventListener("pointerenter",W),y.addEventListener("pointerleave",K),()=>{ge.disconnect(),window.removeEventListener("mousemove",U),y.removeEventListener("contextmenu",Z),window.removeEventListener("mousedown",ee),window.removeEventListener("mouseup",A),window.removeEventListener("blur",A),window.removeEventListener("keydown",B,!0),window.removeEventListener("scroll",ne),y.removeEventListener("scroll",ue),y.removeEventListener("pointerenter",W),y.removeEventListener("pointerleave",K),cancelAnimationFrame(P),R.current=k,J()}},[i,r,a,g,x,S,e,t,l]);const h=m.useRef(void 0);return ad(y=>{const k=t.current;if(!k)return;v.current??(v.current=k.getBoundingClientRect());const T=v.current,D=Math.max(0,Math.min(R.current-T.left-ze,T.width-2*ze));let M=0,C=h.current;(C==null?void 0:C.anchorX)===D?M=C.anchorT:(M=(k.scrollLeft+D)/a,C={anchorT:M,anchorX:D},h.current=C),i({type:"trackpadScale",delta:y/64,anchorT:M,anchorX:D})}),n.jsxs(n.Fragment,{children:[n.jsx("div",{className:re.cursorMarkerStickyParent,children:n.jsx("div",{className:re.cursorMarkerLabelContainer,ref:u,style:p,children:n.jsx("div",{className:re.cursorMarkerLabel,ref:w})})}),n.jsx("div",{className:re.cursorMarkerStickyParent,children:n.jsx("div",{className:re.cursorMarkerContainer,ref:I,style:b,children:n.jsx("div",{className:re.cursorMarker,children:n.jsx("div",{className:re.cursorSelection,ref:N,style:j})})})})]})}function dd({height:e,width:t,value:r,placeholder:o,onChange:s}){return n.jsxs("label",{className:re.searchInputLabel,children:[n.jsx("div",{className:re.searchInputPrefix,children:n.jsx(ud,{})}),n.jsx("input",{type:"search",value:r,placeholder:o,onChange:s,style:{height:e,width:t}})]})}function ud(){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 fd(){return n.jsx("nav",{className:re.searchBar,children:n.jsx(md,{})})}function md(){const{dispatch:e}=dt(),[t,r]=m.useState("");return m.useEffect(()=>{const o=setTimeout(()=>e({type:"setFilter",filter:t}),100);return()=>{clearTimeout(o)}},[e,t]),n.jsx("div",{className:re.searchInput,children:n.jsx(dd,{height:as,onChange:o=>r(o.target.value),placeholder:"Search spans…",value:t,width:"100%"})})}function pd({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 hd({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 gd({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 xd(){const{dispatch:e}=dt(),t=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:1})},[e]),r=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:-1})},[e]),o=m.useCallback(()=>{e({type:"adjustScaleRatio",direction:0})},[e]);return n.jsxs("div",{className:re.zoomButtonGroup,children:[n.jsx("button",{"aria-label":"Zoom Out",className:re.zoomButton,onClick:r,type:"button",children:n.jsx(hd,{size:18})}),n.jsx("div",{className:re.divider}),n.jsx("button",{"aria-label":"Reset Zoom",className:re.zoomButton,onClick:o,type:"button",children:n.jsx(gd,{size:18})}),n.jsx("div",{className:re.divider}),n.jsx("button",{"aria-label":"Zoom In",className:re.zoomButton,onClick:t,type:"button",children:n.jsx(pd,{size:18})})]})}const vd=e=>{const{spans:t}=e,r={startTime:0,endTime:0,duration:0,depth:0,children:[]},o={},s=new Map,a=u=>{const p=s.get(u);if(p)return p;const x=s.size+1;return s.set(u,x),x};let i=!1;for(const u of t){const p=qt(u.startTime),x=qt(u.endTime),w=qt(u.duration);x>r.endTime&&(r.endTime=x,r.duration=x-r.startTime),(r.startTime===0||p<r.startTime)&&(r.startTime=p,r.duration=r.endTime-p);const I=u.resource.startsWith("vercel.");I||(i=!0);const b=I&&(u.resource!=="vercel.serverless-runtime"||!("http.method"in u.attributes)),g=b?0:a(u.resource);let v;b&&(v=`▲ ${u.name}`),o[u.spanId]={parent:null,startTime:p,endTime:x,duration:w,span:u,depth:0,label:v,events:yd(u),isVercel:b,children:[],resourceIndex:g,activeStartTime:u.activeStartTime?qt(u.activeStartTime):void 0}}const l=(u,p)=>{let x;p?(x=o[p],x||(x=r)):x=r,u.parent=x,x.children.push(u)},d=u=>{"parent"in u&&(u.depth=u.parent.depth+1);for(const p of u.children)d(p)};let c=1;const f=(u,p)=>{if("parent"in u&&u.span.name===p){let x=u.endTime;const w=R=>R.children.length?R.children.map(w).sort((h,y)=>h.duration-y.duration)[0]||R:R.span.name==="waitUntil"?(x=R.startTime,R.parent):R,I=w(u),b=`instrumentation-hint-${c++}`,g=u.duration*.05,v=u.startTime+g,N=Math.max(v+g,Math.min(x-u.duration*.01,u.endTime-g)),j=N-v,S={parent:I,startTime:v,endTime:N,duration:j,span:{spanId:b,name:"Add your spans here",resource:"",kind:0,library:{name:""},status:{code:200},traceFlags:0,attributes:{},links:[],events:[],startTime:Gr(v),endTime:Gr(N),duration:Gr(j)},depth:u.depth+1,isVercel:!1,isInstrumentationHint:!0,children:[],resourceIndex:1};return I.children.push(S),o[b]=S,!0}for(const x of u.children)if(f(x,p))return!0;return!1};for(const u of Object.values(o))l(u,u.span.parentSpanId);if(d(r),!i){for(const u of["Invoke Function","Invoke Middleware","Vercel Runtime"])if(f(r,u))break}return{root:r,map:o}},yd=e=>{if(!e.events.length)return;const t=`${e.spanId}:ev`;return e.events.map((r,o)=>({key:`${t}${o}`,timestamp:qt(r.timestamp),event:r})).sort((r,o)=>r.timestamp-o.timestamp)},ko=(e,t)=>(e.isVisible=!0,e.isHovered=!1,e.isVisible);function rn(){return[]}const bd=(e,t=!1)=>{const{state:r,dispatch:o}=dt(),{root:s,filter:a,scale:i,timelineRef:l,timelineWidth:d,spanMap:c,scrollSnapshotRef:f,selected:u,memoCacheRef:p}=r,x=wd(r.timelineHeight),w=m.useRef(0),[I,b]=m.useState(rn),[g,v]=m.useState(rn),[N,j]=m.useState(rn),[S,R]=m.useState(-1),h=m.useRef(void 0);return m.useEffect(()=>{var y;return(y=h.current)==null?void 0:y.call(h,a)},[a]),m.useEffect(()=>{if(e!=null&&e.length){for(const y of I)for(const k of y){const T=e.includes(k.span.spanId);k.isHighlighted!==T&&(k.isHighlighted=T,p.current.set(k.span.spanId,{}))}o({type:"forceRender"})}},[I,e,o,p]),m.useEffect(()=>{if(!s.startTime)return;const y=new Worker(new URL("/assets/worker-D-HfgUMl.js",import.meta.url),{type:"module"});let k=++w.current;const T=M=>{var E;const C=M.data;switch(C.type){case"setRowsResult":{if((C==null?void 0:C.requestId)!==k)return;if(C.isEnd)for(const _ of C.rows)for(const O of _)O.span=((E=c[O.span.spanId])==null?void 0:E.span)??O.span;b(C.rows);break}case"updateHighlight":{if((C==null?void 0:C.requestId)!==k)return;const{matches:_}=C;b(O=>{for(const H of O)for(const z of H){const V=_.has(z.span.spanId);z.isHighlighted!==V&&(z.isHighlighted=V,p.current.set(z.span.spanId,{}))}return O}),o({type:"forceRender"});break}}};y.addEventListener("message",T);const D={requestId:k,type:"calculateSpanPositions",root:s};return y.postMessage(D),h.current=M=>{const C=M.trim().toLocaleLowerCase();if(!C){b(_=>_.map(O=>O.map(H=>(H.isHighlighted=void 0,{...H}))));return}k=++w.current;const E={type:"filterSpans",requestId:k,root:s,filter:C};y.postMessage(E)},()=>{y.terminate()}},[s,c,o,p]),m.useEffect(()=>{if(!I.length)return;if(t){const U=[],Z=[];for(const ee of I)for(const A of ee)ko(A)&&(U.push(A),A.events&&Z.push(...A.events));v(U),j(Z),R(i);return}const y=l.current;let k=f.current,T=!1,D=!1,M=0,C=0;const E=Math.max(500,d*.5),_=new Array(I.length).fill(null),O=()=>{D=!0;const U=Math.min(1+C+Math.ceil((k==null?void 0:k.endRow)??Number.POSITIVE_INFINITY),I.length);for(let Z=U;Z--;){if(_[Z])continue;const ee=H(Z);if(Math.abs(ee)>C){if(D=!1,ee>0)continue;break}const A=[],B=I[Z];if(B){for(const ne of B){if(!ko(ne))continue;const ue=z(ne);M=Math.max(ue,M),A.push({d:ue,span:ne})}_[Z]=A}}},H=U=>k?U<k.startRow?U-k.startRow:U>k.endRow?U-k.endRow:0:0,z=U=>{if(!k)return 0;let Z=0;U.endTime<k.startTime?Z=k.startTime-U.endTime:U.startTime>k.endTime&&(Z=U.startTime-k.endTime);const ee=Math.abs(H(U.row));return!Z&&!ee?0:Math.sqrt((Z/i)**2+(ee*Bt+yt)**2)},V=()=>{if(!y)return;const{scrollLeft:U,scrollTop:Z}=y,ee=0,A=U/i,B=(Z-Er-ze)/(Bt+yt),ne=B+Math.ceil(x/(Bt+yt));k={anchorT:A,anchorX:ee,scrollLeft:U,scrollTop:Z,startTime:s.startTime+U/i,endTime:s.startTime+(U+d)/i,startRow:B,endRow:ne,scale:i},f.current=k;for(let ue=_.length;ue--;)_[ue]=null};let J=0;const P=()=>{(T||!k)&&(T=!1,V()),O();const U=[],Z=[];for(const ee of _)if(ee)for(const{d:A,span:B}of ee)A>C||(U.push(B),B.events&&Z.push(...B.events));C<E&&(!D||C<M)&&(C=Math.min(E,C+100),J=requestAnimationFrame(P)),v(U),j(Z),R(i)};P();let $=Date.now();const W=U=>{(U.ctrlKey||U.metaKey)&&($=Date.now())};y==null||y.addEventListener("wheel",W);const K=()=>{Date.now()-$<=50||(T=!0,cancelAnimationFrame(J),J=requestAnimationFrame(P))};return y==null||y.addEventListener("scroll",K),()=>{cancelAnimationFrame(J),y==null||y.removeEventListener("wheel",W),y==null||y.removeEventListener("scroll",K)}},[I,s,i,f,l,d,x,t]),m.useEffect(()=>{var T;if(!u)return;let y;for(const D of g)if(D.span.spanId===u.span.spanId){y=D;break}const k=(T=y==null?void 0:y.ref)==null?void 0:T.current;if(!(!y||!k))return y.isSelected=!0,k.setAttribute("data-selected",""),()=>{y.isSelected=!1,k.removeAttribute("data-selected")}},[g,u]),{rows:I,spans:g,events:N,scale:S}};function wd(e){const[t,r]=m.useState(e);return m.useEffect(()=>{if(t===e)return;let o=0,s=0;const a=()=>{if(++o<=3){s=requestAnimationFrame(a);return}r(e)};return a(),()=>{cancelAnimationFrame(s)}},[t,e]),t}const So={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 Nd({trace:e=So,className:t="",scrollLock:r=!1,height:o,withPanel:s=!1,highlightedSpans:a,eagerRender:i=!1,isLive:l=!1}){const d=e===So,{state:c,dispatch:f}=dt(),{timelineRef:u,scrollSnapshotRef:p}=c,x=c.memoCacheRef.current,w=((a==null?void 0:a.length)??0)>0,I=m.useRef(!1),b=m.useRef(""),g=m.useRef(null),v=m.useRef({}),N=m.useRef(null);m.useEffect(()=>{const{root:C,map:E}=vd(e),_=!I.current;I.current=!0;const O=Object.keys(E).sort().map(H=>{const z=E[H].events,V=(z==null?void 0:z.length)??0,J=V?z==null?void 0:z[0]:void 0,P=V?z==null?void 0:z[V-1]:void 0,$=`${(J==null?void 0:J.event.name)??"none"}@${(J==null?void 0:J.timestamp)??0}|${(P==null?void 0:P.event.name)??"none"}@${(P==null?void 0:P.timestamp)??0}`;return`${H}:${V}:${$}`}).join(",");if(!_&&O===b.current&&g.current){const H=g.current,z=v.current;let V=!1;(H.endTime!==C.endTime||H.duration!==C.duration)&&(H.endTime=C.endTime,H.duration=C.duration,V=!0);for(const[J,P]of Object.entries(E)){const $=z[J];$&&(($.endTime!==P.endTime||$.duration!==P.duration)&&($.endTime=P.endTime,$.duration=P.duration,V=!0),Object.assign($.span,P.span))}if(!V)return;f({type:"forceRender"});return}b.current=O,g.current=C,v.current=E,f({type:_?"setRoot":"updateRoot",root:C,spanMap:E,resources:e.resources||[]})},[f,e]);const{rows:j,spans:S,events:R,scale:h}=bd(a,i),y=m.useRef(null);m.useLayoutEffect(()=>{const C=y.current;if(!C)return;const E=()=>{const O=2*ze,H=C.getBoundingClientRect(),z=H.width-O,V=H.height,J=N.current;J&&J.width===z&&J.height===V||(N.current={width:z,height:V},f({type:"setSize",width:z,height:V}))};E();const _=new ResizeObserver(E);return _.observe(C),window.addEventListener("resize",E),()=>{_.disconnect(),window.removeEventListener("resize",E)}},[f]);const k=m.useRef({t:0,x:-1,y:-1,spanId:""}),T=m.useCallback(C=>{const E=k.current,_=Date.now(),{clientX:O,clientY:H}=C,z=Math.sqrt((O-E.x)**2+(H-E.y)**2);if(_-E.t<=500&&z<=8){if(C.stopPropagation(),C.preventDefault(),!E.spanId){f({type:"resetScale"});return}f({type:"select",id:E.spanId}),f({type:"scaleToNode",id:E.spanId});return}const V=C.target;if(!V.closest(`.${String(re.timeline)}`))return;const J=V.closest("[data-span-id]"),P=(J==null?void 0:J.dataset.spanId)||"";k.current={x:O,y:H,t:_,spanId:P},P&&(f({type:"toggleSelection",id:P}),C.stopPropagation())},[f]);m.useLayoutEffect(()=>{const C=u.current;if(!C)return;const E=p.current;E&&(C.scrollLeft=E.anchorT*h-E.anchorX,p.current=void 0)},[p,u,h]),m.useEffect(()=>{var _;const C=(_=c.selected)==null?void 0:_.span.spanId;if(!C)return;const E=setTimeout(()=>{const O=c.timelineRef.current,H=O==null?void 0:O.querySelector(`[data-span-id="${C}"]`);if(!O||!H)return;const z=O.getBoundingClientRect(),V=H.getBoundingClientRect();V.width<z.width&&(V.left<z.left||V.right>z.right||V.top<z.top||V.bottom>z.bottom)&&H.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})},500);return()=>{clearTimeout(E)}},[c.selected,c.timelineRef]),m.useEffect(()=>{const C=E=>{E.key==="Escape"&&f({type:"escape"})};return window.addEventListener("keydown",C),()=>{window.removeEventListener("keydown",C)}},[f]),m.useEffect(()=>{if(!r)return;const C=document.documentElement,E=document.body;C.style.overflow="clip",E.style.overflow="clip";const _=O=>{O!=null&&O.cancelable?O.preventDefault():window.scrollTo({left:0,top:0,behavior:"instant"})};return _(),window.addEventListener("scroll",_,{passive:!1}),()=>{C.style.overflow="",E.style.overflow="",window.removeEventListener("scroll",_)}},[r]);const D=Math.max(c.timelineHeight-c.scrollbarWidth,Er+yt+j.length*(Bt+yt)-yt+84),M=!!(c.isMobile&&c.selected);return n.jsxs("div",{className:Dt(re.traceViewer,d&&re.skeleton,t),onClickCapture:T,ref:y,style:{height:o,"--timeline-padding":`${ze}px`,"--row-height":`${Bt}px`,"--row-padding":`${yt}px`,"--search-height":`${w?0:as}px`,"--search-gap":`${w?2:ki}px`,"--map-height":`${ji}px`,"--timeline-width":`${c.timelineWidth}px`,"--timeline-height":`${c.timelineHeight}px`,"--timeline-scroll-width":`${Math.round(c.root.duration*c.scale)}px`,"--panel-width":`${c.panelWidth}px`,"--panel-height":`${c.panelHeight}px`,"--height":`${c.height}px`,"--scrollbar-width":`${c.scrollbarWidth}px`,"--marker-height":`${Er}px`,"--marker-notch-height":`${Ii}px`},children:[w?null:n.jsx(fd,{}),n.jsx(Si,{rows:j,scale:h,timelineRef:u}),n.jsxs("div",{className:Dt(re.traceViewerContent,M&&re.inert),children:[n.jsx("div",{className:re.timeline,ref:u,children:n.jsx("div",{style:{position:"relative",width:c.timelineWidth,height:c.timelineHeight-ze*2,padding:ze,paddingBottom:0},children:n.jsxs("div",{className:re.traceNode,style:{width:c.root.duration*h||void 0,height:D-ze*2},children:[n.jsx(id,{scale:h,isLive:l}),n.jsx(ld,{events:R,root:c.root,scale:h}),n.jsx(cd,{dispatch:f,events:R,memoCacheRef:c.memoCacheRef,root:c.root,scale:h,scrollSnapshotRef:p,spans:S,timelineRef:u}),n.jsx(Ci,{cacheKey:x.get(""),cache:x,customSpanClassNameFunc:c.customSpanClassNameFunc,customSpanEventClassNameFunc:c.customSpanEventClassNameFunc,isLive:l,root:c.root,scale:h,scrollSnapshotRef:p,spans:S})]})})}),n.jsx("div",{className:re.zoomButtonTraceViewer,children:n.jsx(xd,{})})]}),s?n.jsx("div",{className:Dt(re.spanDetailPanelTraceViewer,!c.selected&&re.hidden,c.isMobile&&re.mobile),children:n.jsx(Ti,{attached:!0})}):null]})}function Co(e,t=!1){if(t&&e==="pending")return re.spanPendingStriped;switch(e){case"running":return re.spanRunning;case"pending":return re.spanPending;case"completed":return re.spanCompleted;case"cancelled":return re.spanCancelled;case"failed":return re.spanFailed;default:return""}}function Id(e){return String(e).toLowerCase().endsWith("sleep")}const jd=e=>{const t=e.span.attributes,r=t==null?void 0:t.resource;if(r==="step"){const o=t.data,s=o==null?void 0:o.stepName;if(s&&Id(s))return re.spanSleep;const a=(o==null?void 0:o.status)==="pending";return Co(o==null?void 0:o.status,a)}if(r==="run"){const o=t.data;return Co(o==null?void 0:o.status,!1)}return r==="hook"?re.spanHook:r==="sleep"?re.spanSleep:""},kd=e=>{const t=e.event.name;return t==="step_failed"||t==="run_failed"?re.eventFailed:t==="step_retrying"?re.eventRetrying:t==="hook_created"||t==="hook_received"||t==="hook_disposed"?re.eventHook:re.eventDefault};function Sd(e){return e==="hook_created"||e==="hook_received"||e==="hook_disposed"}function Xe(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),o=t%1e3*1e6;return[r,o]}function To(e){const t=e[0]*1e3,r=e[1]/1e6;return t+r}function zr(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 o=(t&&t instanceof Date?t:new Date).getTime()-e.getTime(),s=Math.floor(o/1e3),a=o%1e3*1e6;return[s,a]}const mr={name:"workflow-development-kit",version:"4.0.0"},Cd=new Set(["hook_created","hook_received","hook_disposed","step_started","step_retrying","step_failed","run_failed","wait_created","wait_completed"]);function Wr(e,t=!0){return e.filter(r=>t?Cd.has(r.eventType):!0).map(r=>({name:r.eventType,timestamp:Xe(r.createdAt),attributes:{eventId:r.eventId,correlationId:r.correlationId,eventData:"eventData"in r?r.eventData:void 0},showVerticalLine:Sd(r.eventType)}))}const Ks=e=>{var o;const t=e.find(s=>s.eventType==="wait_created");if(!t)return null;const r=e.find(s=>s.eventType==="wait_completed");return{waitId:t.correlationId,runId:t.runId,createdAt:t.createdAt,resumeAt:(o=t.eventData)==null?void 0:o.resumeAt,completedAt:r==null?void 0:r.createdAt}};function Td(e,t,r){const o=Ks(e);if(!o)return null;const s=new Date(t.completedAt||r)??r,a=(o==null?void 0:o.createdAt)??r,i=(o==null?void 0:o.completedAt)??s,l=Xe(a),d=Xe(i),c=zr(a,i),f=Wr(e,!1);return{spanId:o.waitId,name:"sleep",kind:1,resource:"sleep",library:mr,status:{code:0},traceFlags:1,attributes:{resource:"sleep",data:o},links:[],events:f,duration:c,startTime:l,endTime:d}}function Ed(e,t,r,o){const s=r??new Date,a=lr(String(e.stepName)),{input:i,output:l,error:d,...c}=e,f={resource:"step",data:c},u="step",p=new Date(e.completedAt??o??s),x=Wr(t,!1),w=new Date(e.createdAt);let I=e.startedAt?new Date(e.startedAt):void 0;const b=t.find(g=>g.eventType==="step_started");return b&&(I=new Date(b.createdAt)),{spanId:String(e.stepId),name:(a==null?void 0:a.shortName)??"",kind:1,resource:u,library:mr,status:{code:0},traceFlags:1,attributes:f,links:[],events:x,startTime:Xe(w),endTime:Xe(p),duration:zr(w,p),activeStartTime:I&&I.getTime()>w.getTime()?Xe(I):void 0}}const Rd=e=>{var a;const t=e.find(i=>i.eventType==="hook_created");if(!t)return null;const r=e.filter(i=>i.eventType==="hook_received"),o=e.filter(i=>i.eventType==="hook_disposed"),s=r.at(-1);return{hookId:t.correlationId,runId:t.runId,createdAt:t.createdAt,receivedCount:r.length,lastReceivedAt:(s==null?void 0:s.createdAt)||void 0,disposedAt:((a=o.at(-1))==null?void 0:a.createdAt)||void 0}};function Ad(e,t,r){const o=Rd(e);if(!o)return null;const s=Wr(e,!1),a=new Date(t.completedAt||r)??r,i=o.disposedAt||a;return{spanId:String(o.hookId),name:String(o.hookId),kind:1,resource:"hook",library:mr,status:{code:1},traceFlags:1,attributes:{resource:"hook",data:o},links:[],events:s,startTime:Xe(o.createdAt),endTime:Xe(i),duration:zr(o.createdAt,i)}}function Dd(e,t,r){var x;const o=r??new Date,{input:s,output:a,error:i,...l}=e,d={resource:"run",data:l},c=new Date(e.createdAt),f=e.startedAt?new Date(e.startedAt):void 0,u=e.completedAt??o,p=Wr(t,!1);return{spanId:String(e.runId),name:String(((x=bt(e.workflowName))==null?void 0:x.shortName)??"?"),kind:1,resource:"run",library:mr,status:{code:0},traceFlags:1,attributes:d,links:[],events:p,startTime:Xe(c),endTime:Xe(u),duration:zr(c,u),activeStartTime:f&&f.getTime()>c.getTime()?Xe(f):void 0}}function Md(e){const{state:t,dispatch:r}=dt(),o=m.useRef(t);o.current=t,m.useEffect(()=>{if(!e)return;let s=0;const a=()=>{const{root:c}=o.current;if(c.startTime){const f=Date.now();f>c.endTime&&(c.endTime=f,c.duration=c.endTime-c.startTime)}s=requestAnimationFrame(a)};s=requestAnimationFrame(a);let i=0,l=0;const d=()=>{const c=o.current;if(c.root.duration>0){const f=(c.width-c.scrollbarWidth)/c.root.duration;(Math.abs(f-l)>l*.001||l===0)&&(l=f,r({type:"detectBaseScale"}))}i=requestAnimationFrame(d)};return i=requestAnimationFrame(d),()=>{cancelAnimationFrame(s),cancelAnimationFrame(i)}},[e,r])}const _d=450,Ld=240;function Od({menu:e,items:t,onClose:r}){const o=m.useRef(null);m.useEffect(()=>{const i=f=>{o.current&&!o.current.contains(f.target)&&r()},l=f=>{f.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[s,a]=m.useState({x:e.x,y:e.y});return m.useEffect(()=>{const i=o.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:Yo.createPortal(n.jsxs("div",{ref:o,style:{position:"fixed",left:s.x,top:s.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 Hd({trace:e,run:t,hooks:r,isLive:o,onWakeUpSleep:s,onCancelRun:a,onResolveHook:i,onLoadMoreSpans:l,hasMoreSpans:d=!1,isLoadingMoreSpans:c=!1,children:f}){const{state:u,dispatch:p}=dt();Md(o);const[x,w]=m.useState(null),[I,b]=m.useState(null),[g,v]=m.useState(!1),[N,j]=m.useState(new Set),S=m.useMemo(()=>{const C=new Map;for(const E of e.spans)C.set(E.spanId,E);return C},[e.spans]),R=m.useMemo(()=>{const C=new Map;for(const E of r)C.set(E.hookId,E);return C},[r]),h=m.useCallback(async C=>{if(!(g||!I||!i)){if(!I.token){he.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{v(!0),await i(I.token,C,I),he.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),j(E=>new Set(E).add(I.hookId)),b(null)}catch(E){console.error("Failed to resolve hook:",E),he.error("Failed to resolve hook",{description:E instanceof Error?E.message:"An unknown error occurred"})}finally{v(!1)}}},[i,I,g]),y=m.useCallback(C=>{const _=C.target.closest("[data-span-id]");if(!_)return;const O=_.dataset.spanId;if(!O)return;C.preventDefault(),C.stopPropagation();const H=S.get(O);if(!H)return;const z=H.attributes.resource??"unknown",V=H.attributes.data,J=!(V!=null&&V.completedAt)&&!(V!=null&&V.disposedAt);w({x:C.clientX,y:C.clientY,spanId:O,spanName:H.name,resourceType:z,isActive:J})},[S]),k=m.useRef(null);m.useEffect(()=>{const C=k.current;if(!C)return;const E=_=>{y(_)};return C.addEventListener("contextmenu",E),()=>{C.removeEventListener("contextmenu",E)}},[y]);const T=m.useRef(!1);m.useEffect(()=>{const C=u.timelineRef.current;if(!C||!l||!d)return;const E=200,_=()=>{T.current||c||!d||C.scrollHeight-C.scrollTop-C.clientHeight>E||(T.current=!0,Promise.resolve(l()).finally(()=>{T.current=!1}))};return C.addEventListener("scroll",_),_(),()=>{C.removeEventListener("scroll",_)}},[u.timelineRef,l,d,c]);const D=m.useCallback(()=>{w(null)},[]),M=m.useCallback(C=>{var O,H;const E=[],_=!t.completedAt;if(C.resourceType==="sleep"&&C.isActive&&_&&s&&E.push({label:"Wake Up Sleep",icon:n.jsx(Ba,{className:"h-3.5 w-3.5"}),action:()=>{s(t.runId,C.spanId).then(z=>{z.stoppedCount>0?he.success("Sleep woken up",{description:`Woke up ${String(z.stoppedCount)} sleep${z.stoppedCount>1?"s":""}`}):he.info("No active sleeps found",{description:"The sleep may have already completed."})}).catch(z=>{he.error("Failed to wake up sleep",{description:z instanceof Error?z.message:"An unknown error occurred"})})}}),C.resourceType==="hook"&&_&&i){const z=R.get(C.spanId),V=S.get(C.spanId),J=(O=V==null?void 0:V.attributes)==null?void 0:O.data,P=!!(J!=null&&J.disposedAt)||!!((H=V==null?void 0:V.events)!=null&&H.some($=>$.name==="hook_disposed"))||N.has(C.spanId);z!=null&&z.token&&!P&&E.push({label:"Resolve Hook",icon:n.jsx(es,{className:"h-3.5 w-3.5"}),action:()=>{b(z)}})}return C.resourceType==="run"&&_&&a&&E.push({label:"Cancel Run",icon:n.jsx(za,{className:"h-3.5 w-3.5"}),destructive:!0,action:()=>{a(t.runId).catch(z=>{he.error("Failed to cancel run",{description:z instanceof Error?z.message:"An unknown error occurred"})})}}),E.push({label:"View Details",icon:n.jsx(Ki,{className:"h-3.5 w-3.5"}),action:()=>{p({type:"select",id:C.spanId})}}),E.push({label:"Copy Name",icon:n.jsx(Ji,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(C.spanName).then(()=>{he.success("Name copied to clipboard")}).catch(()=>{he.error("Failed to copy name")})}}),E.push({label:"Copy ID",icon:n.jsx(ir,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(C.spanId).then(()=>{he.success("ID copied to clipboard")}).catch(()=>{he.error("Failed to copy ID")})}}),E},[p,s,a,i,R,S,N,t.runId,t.completedAt]);return n.jsxs("div",{className:"relative w-full h-full",ref:k,children:[f,x?n.jsx(Od,{menu:x,items:M(x),onClose:D}):null,n.jsx(ts,{isOpen:I!==null,onClose:()=>b(null),onSubmit:h,isSubmitting:g})]})}const Fd=e=>e==="wait_created"||e==="wait_completed",Pd=e=>e==="hook_received"||e==="hook_created"||e==="hook_disposed",wr=(e,t,r)=>{const o=e.get(t);if(o){o.push(r);return}e.set(t,[r])},Bd=(e,t,r)=>{const o=new Map,s=new Map,a=[],i=new Map,l=new Map,d=new Set(t.map(f=>f.stepId)),c=new Set(r.map(f=>f.hookId));for(const f of e){const u=f.correlationId;if(!u){a.push(f);continue}if(Fd(f.eventType)){wr(i,u,f);continue}if(Pd(f.eventType)){wr(l,u,f);continue}if(d.has(u)){wr(o,u,f);continue}if(c.has(u)){wr(s,u,f);continue}a.push(f)}return{eventsByStepId:o,eventsByHookId:s,runLevelEvents:a,timerEvents:i,hookEvents:l}},zd=(e,t,r,o)=>{const s=new Date(e.completedAt||o),a=t.map(d=>{const c=r.eventsByStepId.get(d.stepId)||[];return Ed(d,c,o,s)}),i=Array.from(r.hookEvents.values()).map(d=>Ad(d,e,o)).filter(d=>d!==null),l=Array.from(r.timerEvents.values()).map(d=>Td(d,e,o)).filter(d=>d!==null);return{runSpan:Dd(e,r.runLevelEvents,o),spans:[...a,...i,...l]}},Wd=(e,t)=>{const r=[e,...t.slice().sort((o,s)=>{const a=To(o.startTime),i=To(s.startTime);return a-i})];return r.map((o,s)=>{const a=s===0?void 0:String(r[s-1].spanId);return{...o,parentSpanId:a}})},$d=(e,t,r,o,s)=>{const a=Bd(o,t,r),{runSpan:i,spans:l}=zd(e,t,a,s),d=Wd(i,l);return{traceId:e.runId,rootSpanId:e.runId,spans:d,resources:[{name:"workflow",attributes:{"service.name":mr.name}}]}};function Vd({onSelectionChange:e}){const{state:t}=dt(),{selected:r}=t,o=m.useRef(e);return o.current=e,m.useEffect(()=>{var s,a;r?o.current({data:(s=r.span.attributes)==null?void 0:s.data,resource:(a=r.span.attributes)==null?void 0:a.resource,spanId:r.span.spanId}):o.current(null)},[r]),null}function Gd({triggerDeselect:e}){const{dispatch:t}=dt();return m.useEffect(()=>{e>0&&t({type:"deselect"})},[e,t]),null}function Ud({selectRequest:e}){const{dispatch:t}=dt();return m.useEffect(()=>{e!=null&&e.id&&t({type:"select",id:e.id})},[t,e]),null}function Kd({onResize:e}){const t=m.useCallback(r=>{r.preventDefault();let o=r.clientX;const s=i=>{const l=o-i.clientX;o=i.clientX,e(l)},a=()=>{document.removeEventListener("pointermove",s),document.removeEventListener("pointerup",a)};document.addEventListener("pointermove",s),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})}const qd=({run:e,steps:t,hooks:r,events:o,isLoading:s,error:a,spanDetailData:i,spanDetailLoading:l,spanDetailError:d,onWakeUpSleep:c,onResolveHook:f,onCancelRun:u,onStreamClick:p,onSpanSelect:x,onLoadEventData:w,onLoadMoreSpans:I,hasMoreSpans:b=!1,isLoadingMoreSpans:g=!1,encryptionKey:v})=>{const[N,j]=m.useState(null),[S,R]=m.useState(_d),[h,y]=m.useState(0),[k,T]=m.useState(null),D=!!(e&&!e.completedAt),M=m.useMemo(()=>{if(e)return $d(e,t,r,o,new Date)},[e,t,r,o]);m.useEffect(()=>{a&&!s&&(console.error(a),he.error("Error loading workflow trace data",{description:a.message}))},[a,s]);const C=m.useCallback(W=>{x==null||x(W)},[x]),E=m.useCallback(W=>{if(W){const K=W.spanId,U=K?o.filter(Z=>Z.correlationId===K):[];j({...W,rawEvents:U})}else j(null)},[o]);m.useEffect(()=>{const W=N==null?void 0:N.spanId;if(!W)return;const K=o.filter(U=>U.correlationId===W);j(U=>{if(!U||U.spanId!==W)return U;const Z=U.rawEvents??[];return Z.length===K.length&&Z.every((A,B)=>{var ne;return A.eventId===((ne=K[B])==null?void 0:ne.eventId)})?U:{...U,rawEvents:K}})},[o,N==null?void 0:N.spanId]);const _=m.useCallback(()=>{j(null),y(W=>W+1)},[]),O=m.useCallback(W=>{R(K=>Math.max(Ld,K+W))},[]),H=m.useMemo(()=>!(N!=null&&N.spanId)||!M?-1:M.spans.findIndex(W=>W.spanId===N.spanId),[N==null?void 0:N.spanId,M]),z=H>0,V=H>=0&&M!=null&&H<M.spans.length-1,J=m.useCallback(()=>{var K;if(!M||H<=0)return;const W=(K=M.spans[H-1])==null?void 0:K.spanId;W&&T({id:W,token:Date.now()})},[H,M]),P=m.useCallback(()=>{var K;if(!M||H<0)return;const W=(K=M.spans[H+1])==null?void 0:K.spanId;W&&T({id:W,token:Date.now()})},[H,M]),$=m.useMemo(()=>{var Z,ee;if(!(N!=null&&N.data))return;const W=N.data,K=W.stepName,U=W.workflowName;return(K?(Z=lr(K))==null?void 0:Z.shortName:void 0)??(U?(ee=bt(U))==null?void 0:ee.shortName:void 0)??K??U??W.hookId??"Details"},[N==null?void 0:N.data]);return s||!M?n.jsxs("div",{className:"relative w-full h-full",children:[n.jsx("div",{className:"border-b border-gray-alpha-400 w-full"}),n.jsx(Me,{className:"w-full ml-2 mt-1 mb-1 h-[56px]"}),n.jsxs("div",{className:"p-2 relative w-full",children:[n.jsx(Me,{className:"w-full mt-6 h-[20px]"}),n.jsx(Me,{className:"w-[10%] mt-2 ml-6 h-[20px]"}),n.jsx(Me,{className:"w-[10%] mt-2 ml-12 h-[20px]"}),n.jsx(Me,{className:"w-[20%] mt-2 ml-16 h-[20px]"})]})]}):n.jsxs("div",{className:"relative w-full h-full flex",children:[n.jsx("div",{className:"flex-1 min-w-0 relative",children:n.jsxs(Ei,{customSpanClassNameFunc:jd,customSpanEventClassNameFunc:kd,children:[n.jsx(Vd,{onSelectionChange:E}),n.jsx(Gd,{triggerDeselect:h}),n.jsx(Ud,{selectRequest:k}),n.jsx(Hd,{trace:M,run:e,hooks:r,isLive:D,onWakeUpSleep:c,onCancelRun:u,onResolveHook:f,onLoadMoreSpans:I,hasMoreSpans:b,isLoadingMoreSpans:g,children:n.jsx(Nd,{eagerRender:!0,height:"100%",isLive:D,trace:M})})]})}),N&&n.jsxs("div",{className:"relative border-l flex-shrink-0 flex flex-col",style:{width:S,borderColor:"var(--ds-gray-200)",backgroundColor:"var(--ds-background-100)"},children:[n.jsx(Kd,{onResize:O}),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:$,children:$})}),n.jsxs("div",{className:"flex items-center",children:[n.jsx("button",{type:"button","aria-label":"Previous span",onClick:J,disabled:!z,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:z?"pointer":"not-allowed",opacity:z?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:W=>{z&&(W.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:W=>{W.currentTarget.style.background="transparent"},children:n.jsx(Fa,{size:16})}),n.jsx("button",{type:"button","aria-label":"Next span",onClick:P,disabled:!V,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:V?"pointer":"not-allowed",opacity:V?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:W=>{V&&(W.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:W=>{W.currentTarget.style.background="transparent"},children:n.jsx(Pa,{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:W=>{W.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:W=>{W.currentTarget.style.background="transparent"},children:n.jsx(rs,{size:16})})})]}),n.jsx("div",{className:"flex-1 overflow-y-auto",children:n.jsx(Pt,{title:"Failed to load entity details",children:n.jsx(sd,{run:e,hooks:r,onStreamClick:p,spanDetailData:i??null,spanDetailError:d,spanDetailLoading:l,onSpanSelect:C,onWakeUpSleep:c,onLoadEventData:w,onResolveHook:f,encryptionKey:v,selectedSpan:N})})})]})]})};async function Zd(e,t,r,o={}){const s=o.resolveData??"all";let a,i;if(t==="run")a=await Nr(pn(e,r,s)),i=a.runId;else if(t==="step"){const{runId:l}=o;if(!l)throw new Et("runId is required for step resource",{layer:"client"});a=await Nr(Ri(e,l,r,s)),i=a.stepId}else if(t==="hook")a=await Nr(is(e,r,s)),i=a.hookId;else throw new Et(`Unknown resource type: ${t}`,{layer:"client"});return{data:a,correlationId:i}}function qs(e,t,r,o={}){const{refreshInterval:s=0,runId:a,enabled:i=!0,encryptionKey:l}=o,[d,c]=m.useState(null),[f,u]=m.useState(i),[p,x]=m.useState(null),w=m.useCallback(async b=>l?mn(b,l):_e(b),[l]),I=m.useCallback(async()=>{if(!i){u(!1);return}if(c(null),x(null),t==="hook"){const{error:b,result:g}=await De(is(e,r,"all"));if(b){x(b);return}try{c(await w(g))}catch(v){x(v instanceof Error?v:new Error(String(v)))}return}if(t==="sleep"){const{error:b,result:g}=await De(ls(e,r,{sortOrder:"asc",limit:100,withData:!0}));if(b){x(b);return}try{const v=await Promise.all(g.data.map(w)),N=Ks(v);if(N===null){x(new Error(`Failed to load ${t} details: missing required event data`));return}c(N)}catch(v){x(v instanceof Error?v:new Error(String(v)))}return}u(!0);try{const{data:b}=await Zd(e,t,r,{runId:a});c(await w(b))}catch(b){b instanceof Error?x(b):x(new Error(String(b)));return}finally{u(!1)}},[e,t,r,a,i,w]);return m.useEffect(()=>{I()},[I]),m.useEffect(()=>{if(!s||s<=0)return;const b=setInterval(I,s);return()=>clearInterval(b)},[s,I]),{data:d,loading:f,error:p,refresh:I}}const Yd=1e3;function Yt(e,t,r){const o=[...e,...t],s=new Map(o.map(a=>[a[r],a]));return Array.from(s.values())}async function nn(e){const{fetchFn:t,setItems:r,setCursor:o,setError:s,idKey:a,cursorStrategy:i="always",transform:l}=e,{error:d,result:c}=await t();if(d)return s(d),!1;if(c.data.length>0){const f=l?c.data.map(l):c.data;return r(p=>Yt(p,f,a)),(i==="onHasMore"?!!(c.cursor&&c.hasMore):!!c.cursor)&&o(c.cursor),!0}return!1}const on=10,Ht=50,Xd=2e3,Jd=5e3;async function Qd(e,t){let r=[],o;for(;;){const{error:s,result:a}=await De(ls(e,t,{cursor:o,sortOrder:"asc",limit:1e3}));if(s||(r=[...r,...a.data],!a.hasMore||!a.cursor||r.length>=Yd))break;o=a.cursor}return r}async function Eo(e,t){return t.length===0?[]:(await Promise.all(t.map(o=>Qd(e,o)))).flat()}function eu(e,t,r={}){const{live:o=!1}=r,[s,a]=m.useState(null),[i,l]=m.useState([]),[d,c]=m.useState([]),[f,u]=m.useState([]),[p,x]=m.useState(!0),[w,I]=m.useState(!1),[b,g]=m.useState(null),[v,N]=m.useState(),[j,S]=m.useState(),[R,h]=m.useState(),[y,k]=m.useState(!1),[T,D]=m.useState(!1),[M,C]=m.useState(!1),[E,_]=m.useState(!1),O=m.useRef(!1),[H,z]=m.useState(!1),V=m.useCallback(async()=>{var ce;if(O.current)return;O.current=!0,x(!0),I(!0),g(null);const[Z,ee,A,B]=await Promise.all([De(pn(e,t,"none")),De(Ur(e,t,{sortOrder:"asc",limit:Ht})),De(Kr(e,{runId:t,sortOrder:"asc",limit:Ht})),De(qr(e,t,{sortOrder:"asc",limit:Ht}))]);Z.error?g(Z.error):a(_e(Z.result));const ne=ee.error?[]:ee.result.data.map(_e),ue=A.error?[]:A.result.data.map(_e),ge=B.error?[]:B.result.data.map(_e),q=[...ne.map(ie=>ie.stepId),...ue.map(ie=>ie.hookId)],me=(await Eo(e,q)).map(_e);l(ne),c(ue),u(Yt([],[...ge,...me],"eventId")),N(ee.error||!ee.result.hasMore?void 0:ee.result.cursor),S(A.error||!A.result.hasMore?void 0:A.result.cursor),h(B.error||!B.result.hasMore?void 0:B.result.cursor),k(!!(!ee.error&&ee.result.hasMore)),D(!!(!A.error&&A.result.hasMore)),C(!!(!B.error&&B.result.hasMore));const pe=[Z,ee,A,B];if(x(!1),I(!1),z(!0),O.current=!1,!Z.error){const ie=(ce=pe.find(Ie=>Ie.error))==null?void 0:ce.error;ie&&g(ie)}},[e,t]),J=m.useCallback(async()=>{var Z,ee,A,B,ne,ue;if(!(O.current||!H||E)&&!(!y&&!T&&!M)){_(!0);try{const[ge,q,te]=await Promise.all([y?De(Ur(e,t,{cursor:v,sortOrder:"asc",limit:Ht})):Promise.resolve({error:null,result:null}),T?De(Kr(e,{runId:t,cursor:j,sortOrder:"asc",limit:Ht})):Promise.resolve({error:null,result:null}),M?De(qr(e,t,{cursor:R,sortOrder:"asc",limit:Ht})):Promise.resolve({error:null,result:null})]);ge.error&&g(ge.error),q.error&&g(q.error),te.error&&g(te.error);const me=((Z=ge.result)==null?void 0:Z.data.map(_e))??[],pe=((ee=q.result)==null?void 0:ee.data.map(_e))??[],ce=((A=te.result)==null?void 0:A.data.map(_e))??[];me.length>0&&l(Ce=>Yt(Ce,me,"stepId")),pe.length>0&&c(Ce=>Yt(Ce,pe,"hookId"));const ie=[...me.map(Ce=>Ce.stepId),...pe.map(Ce=>Ce.hookId)],je=(await Eo(e,ie)).map(_e),Ze=[...ce,...je];Ze.length>0&&u(Ce=>Yt(Ce,Ze,"eventId"));const et=ge.error?y:!!(ge.result&&ge.result.hasMore),tt=q.error?T:!!(q.result&&q.result.hasMore),Ue=te.error?M:!!(te.result&&te.result.hasMore);k(et),D(tt),C(Ue),ge.error||N((B=ge.result)!=null&&B.hasMore?ge.result.cursor:void 0),q.error||S((ne=q.result)!=null&&ne.hasMore?q.result.cursor:void 0),te.error||h((ue=te.result)!=null&&ue.hasMore?te.result.cursor:void 0)}finally{_(!1)}}},[e,t,H,E,y,T,M,v,j,R]),P=m.useCallback(async()=>{if(s!=null&&s.completedAt)return!1;const{error:Z,result:ee}=await De(pn(e,t,"none"));return Z?(g(Z),!1):(g(null),a(_e(ee)),!0)},[e,t,s==null?void 0:s.completedAt]),$=m.useCallback(()=>nn({fetchFn:()=>De(Ur(e,t,{cursor:v,sortOrder:"asc",limit:on})),setItems:l,setCursor:N,setError:g,idKey:"stepId",cursorStrategy:"onHasMore",transform:_e}),[e,t,v]),W=m.useCallback(()=>nn({fetchFn:()=>De(Kr(e,{runId:t,cursor:j,sortOrder:"asc",limit:on})),setItems:c,setCursor:S,setError:g,idKey:"hookId",transform:_e}),[e,t,j]),K=m.useCallback(()=>nn({fetchFn:()=>De(qr(e,t,{cursor:R,sortOrder:"asc",limit:on})),setItems:u,setCursor:h,setError:g,idKey:"eventId",transform:_e}),[e,t,R]),U=m.useCallback(async(Z=!1)=>{if(O.current||!H)return{foundNewItems:!1};let ee=!1;try{const[A,B,ne,ue]=await Promise.all([Z?Promise.resolve(!1):P(),$(),Z?Promise.resolve(!1):W(),Z?Promise.resolve(!1):K()]);ee=B||ne||ue}catch(A){console.error("Update error:",A)}return{foundNewItems:ee}},[$,W,K,H,P]);return m.useEffect(()=>{V()},[V]),m.useEffect(()=>{if(!o||!H||s!=null&&s.completedAt)return;const Z=setInterval(()=>{U()},Jd),ee=setInterval(()=>{U(!0)},Xd);return()=>{clearInterval(Z),clearInterval(ee)}},[o,H,U,s==null?void 0:s.completedAt]),{run:s??{},steps:i,hooks:d,events:f,loading:p,auxiliaryDataLoading:w,error:b,update:U,loadMoreTraceData:J,hasMoreTraceData:y||T||M,isLoadingMoreTraceData:E}}function tu(e){return typeof e=="object"&&e!==null&&"message"in e&&"layer"in e&&"cause"in e&&"request"in e}async function ru(e,t,r,o){try{const s=`/api/stream/${encodeURIComponent(t)}${r!=null?`?startIndex=${r}`:""}`,a=await fetch(s,{signal:o});if(!a.ok){const i=await a.json().catch(()=>null);throw i&&tu(i)?new Et(i.message,{layer:"client",cause:i.cause,request:i.request}):new Et(`Failed to read stream: ${a.status}`,{layer:"client"})}if(!a.body)throw new Et("Failed to read stream: no body",{layer:"client"});return a.body}catch(s){throw s instanceof Et?s:new Et("Failed to read stream",{layer:"client",cause:s})}}async function nu(e,t){return Nr(Ai(e,t))}const ou=1e4;function su(e,t,r=ou){const[o,s]=m.useState([]),[a,i]=m.useState(!0),[l,d]=m.useState(null),c=m.useCallback(async()=>{i(!0),d(null);try{const f=await nu(e,t);s(f)}catch(f){d(f instanceof Error?f:new Error(String(f)))}finally{i(!1)}},[e,t]);return m.useEffect(()=>{c()},[c]),m.useEffect(()=>{if(!r||r<=0)return;const f=setInterval(c,r);return()=>clearInterval(f)},[r,c]),{streams:o,loading:a,error:l,refresh:c}}var au=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],pt=au.reduce((e,t)=>{const r=m.forwardRef((o,s)=>{const{asChild:a,...i}=o,l=a?Tn:t;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),n.jsx(l,{...i,ref:s})});return r.displayName=`Primitive.${t}`,{...e,[t]:r}},{});function iu(e,t){e&&Yo.flushSync(()=>e.dispatchEvent(t))}var lu="DismissableLayer",Sn="dismissableLayer.update",cu="dismissableLayer.pointerDownOutside",du="dismissableLayer.focusOutside",Ro,Zs=m.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),Ys=m.forwardRef((e,t)=>{const{disableOutsidePointerEvents:r=!1,onEscapeKeyDown:o,onPointerDownOutside:s,onFocusOutside:a,onInteractOutside:i,onDismiss:l,...d}=e,c=m.useContext(Zs),[f,u]=m.useState(null),p=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=m.useState({}),w=Nt(t,h=>u(h)),I=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=I.indexOf(b),v=f?I.indexOf(f):-1,N=c.layersWithOutsidePointerEventsDisabled.size>0,j=v>=g,S=mu(h=>{const y=h.target,k=[...c.branches].some(T=>T.contains(y));!j||k||(s==null||s(h),i==null||i(h),h.defaultPrevented||l==null||l())},p),R=pu(h=>{const y=h.target;[...c.branches].some(T=>T.contains(y))||(a==null||a(h),i==null||i(h),h.defaultPrevented||l==null||l())},p);return Wa(h=>{v===c.layers.size-1&&(o==null||o(h),!h.defaultPrevented&&l&&(h.preventDefault(),l()))},p),m.useEffect(()=>{if(f)return r&&(c.layersWithOutsidePointerEventsDisabled.size===0&&(Ro=p.body.style.pointerEvents,p.body.style.pointerEvents="none"),c.layersWithOutsidePointerEventsDisabled.add(f)),c.layers.add(f),Ao(),()=>{r&&c.layersWithOutsidePointerEventsDisabled.size===1&&(p.body.style.pointerEvents=Ro)}},[f,p,r,c]),m.useEffect(()=>()=>{f&&(c.layers.delete(f),c.layersWithOutsidePointerEventsDisabled.delete(f),Ao())},[f,c]),m.useEffect(()=>{const h=()=>x({});return document.addEventListener(Sn,h),()=>document.removeEventListener(Sn,h)},[]),n.jsx(pt.div,{...d,ref:w,style:{pointerEvents:N?j?"auto":"none":void 0,...e.style},onFocusCapture:mt(e.onFocusCapture,R.onFocusCapture),onBlurCapture:mt(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:mt(e.onPointerDownCapture,S.onPointerDownCapture)})});Ys.displayName=lu;var uu="DismissableLayerBranch",fu=m.forwardRef((e,t)=>{const r=m.useContext(Zs),o=m.useRef(null),s=Nt(t,o);return m.useEffect(()=>{const a=o.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),n.jsx(pt.div,{...e,ref:s})});fu.displayName=uu;function mu(e,t=globalThis==null?void 0:globalThis.document){const r=Sr(e),o=m.useRef(!1),s=m.useRef(()=>{});return m.useEffect(()=>{const a=l=>{if(l.target&&!o.current){let d=function(){Xs(cu,r,c,{discrete:!0})};const c={originalEvent:l};l.pointerType==="touch"?(t.removeEventListener("click",s.current),s.current=d,t.addEventListener("click",s.current,{once:!0})):d()}else t.removeEventListener("click",s.current);o.current=!1},i=window.setTimeout(()=>{t.addEventListener("pointerdown",a)},0);return()=>{window.clearTimeout(i),t.removeEventListener("pointerdown",a),t.removeEventListener("click",s.current)}},[t,r]),{onPointerDownCapture:()=>o.current=!0}}function pu(e,t=globalThis==null?void 0:globalThis.document){const r=Sr(e),o=m.useRef(!1);return m.useEffect(()=>{const s=a=>{a.target&&!o.current&&Xs(du,r,{originalEvent:a},{discrete:!1})};return t.addEventListener("focusin",s),()=>t.removeEventListener("focusin",s)},[t,r]),{onFocusCapture:()=>o.current=!0,onBlurCapture:()=>o.current=!1}}function Ao(){const e=new CustomEvent(Sn);document.dispatchEvent(e)}function Xs(e,t,r,{discrete:o}){const s=r.originalEvent.target,a=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:r});t&&s.addEventListener(e,t,{once:!0}),o?iu(s,a):s.dispatchEvent(a)}var sn="focusScope.autoFocusOnMount",an="focusScope.autoFocusOnUnmount",Do={bubbles:!1,cancelable:!0},hu="FocusScope",Js=m.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,d]=m.useState(null),c=Sr(s),f=Sr(a),u=m.useRef(null),p=Nt(t,I=>d(I)),x=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(o){let I=function(N){if(x.paused||!l)return;const j=N.target;l.contains(j)?u.current=j:vt(u.current,{select:!0})},b=function(N){if(x.paused||!l)return;const j=N.relatedTarget;j!==null&&(l.contains(j)||vt(u.current,{select:!0}))},g=function(N){if(document.activeElement===document.body)for(const S of N)S.removedNodes.length>0&&vt(l)};document.addEventListener("focusin",I),document.addEventListener("focusout",b);const v=new MutationObserver(g);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",I),document.removeEventListener("focusout",b),v.disconnect()}}},[o,l,x.paused]),m.useEffect(()=>{if(l){_o.add(x);const I=document.activeElement;if(!l.contains(I)){const g=new CustomEvent(sn,Do);l.addEventListener(sn,c),l.dispatchEvent(g),g.defaultPrevented||(gu(wu(Qs(l)),{select:!0}),document.activeElement===I&&vt(l))}return()=>{l.removeEventListener(sn,c),setTimeout(()=>{const g=new CustomEvent(an,Do);l.addEventListener(an,f),l.dispatchEvent(g),g.defaultPrevented||vt(I??document.body,{select:!0}),l.removeEventListener(an,f),_o.remove(x)},0)}}},[l,c,f,x]);const w=m.useCallback(I=>{if(!r&&!o||x.paused)return;const b=I.key==="Tab"&&!I.altKey&&!I.ctrlKey&&!I.metaKey,g=document.activeElement;if(b&&g){const v=I.currentTarget,[N,j]=xu(v);N&&j?!I.shiftKey&&g===j?(I.preventDefault(),r&&vt(N,{select:!0})):I.shiftKey&&g===N&&(I.preventDefault(),r&&vt(j,{select:!0})):g===v&&I.preventDefault()}},[r,o,x.paused]);return n.jsx(pt.div,{tabIndex:-1,...i,ref:p,onKeyDown:w})});Js.displayName=hu;function gu(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(vt(o,{select:t}),document.activeElement!==r)return}function xu(e){const t=Qs(e),r=Mo(t,e),o=Mo(t.reverse(),e);return[r,o]}function Qs(e){const t=[],r=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:o=>{const s=o.tagName==="INPUT"&&o.type==="hidden";return o.disabled||o.hidden||s?NodeFilter.FILTER_SKIP:o.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;r.nextNode();)t.push(r.currentNode);return t}function Mo(e,t){for(const r of e)if(!vu(r,{upTo:t}))return r}function vu(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 yu(e){return e instanceof HTMLInputElement&&"select"in e}function vt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&yu(e)&&t&&e.select()}}var _o=bu();function bu(){let e=[];return{add(t){const r=e[0];t!==r&&(r==null||r.pause()),e=Lo(e,t),e.unshift(t)},remove(t){var r;e=Lo(e,t),(r=e[0])==null||r.resume()}}}function Lo(e,t){const r=[...e],o=r.indexOf(t);return o!==-1&&r.splice(o,1),r}function wu(e){return e.filter(t=>t.tagName!=="A")}var Nu="Portal",ea=m.forwardRef((e,t)=>{var l;const{container:r,...o}=e,[s,a]=m.useState(!1);$a(()=>a(!0),[]);const i=r||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?Zo.createPortal(n.jsx(pt.div,{...o,ref:t}),i):null});ea.displayName=Nu;var Wn="Dialog",[ta,ra]=ns(Wn),[Iu,Qe]=ta(Wn),na=e=>{const{__scopeDialog:t,children:r,open:o,defaultOpen:s,onOpenChange:a,modal:i=!0}=e,l=m.useRef(null),d=m.useRef(null),[c=!1,f]=Ga({prop:o,defaultProp:s,onChange:a});return n.jsx(Iu,{scope:t,triggerRef:l,contentRef:d,contentId:$r(),titleId:$r(),descriptionId:$r(),open:c,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(u=>!u),[f]),modal:i,children:r})};na.displayName=Wn;var oa="DialogTrigger",sa=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=Qe(oa,r),a=Nt(t,s.triggerRef);return n.jsx(pt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":Gn(s.open),...o,ref:a,onClick:mt(e.onClick,s.onOpenToggle)})});sa.displayName=oa;var $n="DialogPortal",[ju,aa]=ta($n,{forceMount:void 0}),ia=e=>{const{__scopeDialog:t,forceMount:r,children:o,container:s}=e,a=Qe($n,t);return n.jsx(ju,{scope:t,forceMount:r,children:m.Children.map(o,i=>n.jsx(Cn,{present:r||a.open,children:n.jsx(ea,{asChild:!0,container:s,children:i})}))})};ia.displayName=$n;var _r="DialogOverlay",la=m.forwardRef((e,t)=>{const r=aa(_r,e.__scopeDialog),{forceMount:o=r.forceMount,...s}=e,a=Qe(_r,e.__scopeDialog);return a.modal?n.jsx(Cn,{present:o||a.open,children:n.jsx(ku,{...s,ref:t})}):null});la.displayName=_r;var ku=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=Qe(_r,r);return n.jsx(Ka,{as:Tn,allowPinchZoom:!0,shards:[s.contentRef],children:n.jsx(pt.div,{"data-state":Gn(s.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),_t="DialogContent",ca=m.forwardRef((e,t)=>{const r=aa(_t,e.__scopeDialog),{forceMount:o=r.forceMount,...s}=e,a=Qe(_t,e.__scopeDialog);return n.jsx(Cn,{present:o||a.open,children:a.modal?n.jsx(Su,{...s,ref:t}):n.jsx(Cu,{...s,ref:t})})});ca.displayName=_t;var Su=m.forwardRef((e,t)=>{const r=Qe(_t,e.__scopeDialog),o=m.useRef(null),s=Nt(t,r.contentRef,o);return m.useEffect(()=>{const a=o.current;if(a)return Ua(a)},[]),n.jsx(da,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:mt(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:mt(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:mt(e.onFocusOutside,a=>a.preventDefault())})}),Cu=m.forwardRef((e,t)=>{const r=Qe(_t,e.__scopeDialog),o=m.useRef(!1),s=m.useRef(!1);return n.jsx(da,{...e,ref:t,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:a=>{var i,l;(i=e.onCloseAutoFocus)==null||i.call(e,a),a.defaultPrevented||(o.current||(l=r.triggerRef.current)==null||l.focus(),a.preventDefault()),o.current=!1,s.current=!1},onInteractOutside:a=>{var d,c;(d=e.onInteractOutside)==null||d.call(e,a),a.defaultPrevented||(o.current=!0,a.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const i=a.target;((c=r.triggerRef.current)==null?void 0:c.contains(i))&&a.preventDefault(),a.detail.originalEvent.type==="focusin"&&s.current&&a.preventDefault()}})}),da=m.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,...i}=e,l=Qe(_t,r),d=m.useRef(null),c=Nt(t,d);return qa(),n.jsxs(n.Fragment,{children:[n.jsx(Js,{asChild:!0,loop:!0,trapped:o,onMountAutoFocus:s,onUnmountAutoFocus:a,children:n.jsx(Ys,{role:"dialog",id:l.contentId,"aria-describedby":l.descriptionId,"aria-labelledby":l.titleId,"data-state":Gn(l.open),...i,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),n.jsxs(n.Fragment,{children:[n.jsx(Eu,{titleId:l.titleId}),n.jsx(Au,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Vn="DialogTitle",ua=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=Qe(Vn,r);return n.jsx(pt.h2,{id:s.titleId,...o,ref:t})});ua.displayName=Vn;var fa="DialogDescription",ma=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=Qe(fa,r);return n.jsx(pt.p,{id:s.descriptionId,...o,ref:t})});ma.displayName=fa;var pa="DialogClose",ha=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=Qe(pa,r);return n.jsx(pt.button,{type:"button",...o,ref:t,onClick:mt(e.onClick,()=>s.onOpenChange(!1))})});ha.displayName=pa;function Gn(e){return e?"open":"closed"}var ga="DialogTitleWarning",[Tu,xa]=Va(ga,{contentName:_t,titleName:Vn,docsSlug:"dialog"}),Eu=({titleId:e})=>{const t=xa(ga),r=`\`${t.contentName}\` requires a \`${t.titleName}\` for the component to be accessible for screen reader users.
29
-
30
- If you want to hide the \`${t.titleName}\`, you can wrap it with our VisuallyHidden component.
31
-
32
- 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},Ru="DialogDescriptionWarning",Au=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${xa(Ru).contentName}}.`;return m.useEffect(()=>{var a;const s=(a=e.current)==null?void 0:a.getAttribute("aria-describedby");t&&s&&(document.getElementById(t)||console.warn(o))},[o,e,t]),null},Du=na,Mu=sa,_u=ia,Lu=la,Ou=ca,Hu=ua,Fu=ma,va=ha,ya="AlertDialog",[Pu]=ns(ya,[ra]),ht=ra(),ba=e=>{const{__scopeAlertDialog:t,...r}=e,o=ht(t);return n.jsx(Du,{...o,...r,modal:!0})};ba.displayName=ya;var Bu="AlertDialogTrigger",zu=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ht(r);return n.jsx(Mu,{...s,...o,ref:t})});zu.displayName=Bu;var Wu="AlertDialogPortal",wa=e=>{const{__scopeAlertDialog:t,...r}=e,o=ht(t);return n.jsx(_u,{...o,...r})};wa.displayName=Wu;var $u="AlertDialogOverlay",Na=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ht(r);return n.jsx(Lu,{...s,...o,ref:t})});Na.displayName=$u;var $t="AlertDialogContent",[Vu,Gu]=Pu($t),Ia=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,children:o,...s}=e,a=ht(r),i=m.useRef(null),l=Nt(t,i),d=m.useRef(null);return n.jsx(Tu,{contentName:$t,titleName:ja,docsSlug:"alert-dialog",children:n.jsx(Vu,{scope:r,cancelRef:d,children:n.jsxs(Ou,{role:"alertdialog",...a,...s,ref:l,onOpenAutoFocus:mt(s.onOpenAutoFocus,c=>{var f;c.preventDefault(),(f=d.current)==null||f.focus({preventScroll:!0})}),onPointerDownOutside:c=>c.preventDefault(),onInteractOutside:c=>c.preventDefault(),children:[n.jsx(Di,{children:o}),n.jsx(Ku,{contentRef:i})]})})})});Ia.displayName=$t;var ja="AlertDialogTitle",ka=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ht(r);return n.jsx(Hu,{...s,...o,ref:t})});ka.displayName=ja;var Sa="AlertDialogDescription",Ca=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ht(r);return n.jsx(Fu,{...s,...o,ref:t})});Ca.displayName=Sa;var Uu="AlertDialogAction",Ta=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=ht(r);return n.jsx(va,{...s,...o,ref:t})});Ta.displayName=Uu;var Ea="AlertDialogCancel",Ra=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,{cancelRef:s}=Gu(Ea,r),a=ht(r),i=Nt(t,s);return n.jsx(va,{...a,...o,ref:i})});Ra.displayName=Ea;var Ku=({contentRef:e})=>{const t=`\`${$t}\` requires a description for the component to be accessible for screen reader users.
33
-
34
- You can add a description to the \`${$t}\` by passing a \`${Sa}\` component as a child, which also benefits sighted users by adding visible context to the dialog.
35
-
36
- 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 \`${$t}\`. 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.
37
-
38
- For more information, see https://radix-ui.com/primitives/docs/components/alert-dialog`;return m.useEffect(()=>{var o;document.getElementById((o=e.current)==null?void 0:o.getAttribute("aria-describedby"))||console.warn(t)},[t,e]),null},qu=ba,Zu=wa,Yu=Na,Xu=Ia,Ju=Ta,Qu=Ra,ef=ka,tf=Ca;function Oo({...e}){return n.jsx(qu,{"data-slot":"alert-dialog",...e})}function rf({...e}){return n.jsx(Zu,{"data-slot":"alert-dialog-portal",...e})}function nf({className:e,...t}){return n.jsx(Yu,{"data-slot":"alert-dialog-overlay",className:Ge("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 Ho({className:e,onSubmit:t,...r}){return n.jsxs(rf,{children:[n.jsx(nf,{}),n.jsx(Xu,{"data-slot":"alert-dialog-content",className:Ge("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:o=>{o.preventDefault(),t==null||t(o)},...r})]})}function Fo({className:e,...t}){return n.jsx("div",{"data-slot":"alert-dialog-header",className:Ge("flex flex-col gap-2 text-center sm:text-left",e),...t})}function Po({className:e,...t}){return n.jsx("div",{"data-slot":"alert-dialog-footer",className:Ge("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Bo({className:e,...t}){return n.jsx(ef,{"data-slot":"alert-dialog-title",className:Ge("text-lg font-semibold",e),...t})}function zo({className:e,...t}){return n.jsx(tf,{"data-slot":"alert-dialog-description",className:Ge("text-muted-foreground text-sm",e),...t})}function Wo({className:e,...t}){return n.jsx(Ju,{className:Ge(cs(),e),...t})}function $o({className:e,...t}){return n.jsx(Qu,{className:Ge(cs({variant:"outline"}),e),...t})}function of({...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:Ge("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",e),...t})}function Vo({className:e,...t}){return n.jsx("li",{"data-slot":"breadcrumb-item",className:Ge("inline-flex items-center gap-1.5",e),...t})}function af({asChild:e,className:t,...r}){const o=e?Tn:"a";return n.jsx(o,{"data-slot":"breadcrumb-link",className:Ge("hover:text-foreground transition-colors",t),...r})}function lf({className:e,...t}){return n.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:Ge("text-foreground font-normal",e),...t})}function cf({children:e,className:t,...r}){return n.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:Ge("[&>svg]:size-3.5",t),...r,children:e??n.jsx(Jo,{})})}const Ft={sleep:"sleep",createHook:"createHook",createWebhook:"createWebhook",awaitWebhook:"awaitWebhook"};function Lr(e){return e.replace(/\/\/\.\.\//g,"//")}function df(e,t,r,o){let s;switch(e.status){case"completed":s="completed";break;case"failed":s=r<o-1?"retrying":"failed";break;case"running":s="running";break;case"cancelled":s="cancelled";break;case"pending":default:s="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:s,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 Or(e){const t=e.split("//");return t.length>=3?t[t.length-1]:null}function uf(e){const t=new Map,r=new Map,o=new Map,s=[],a=new Map;for(const i of e){if(i.data.stepId){const l=Lr(i.data.stepId),d=t.get(l)||[];d.push(i),t.set(l,d);const c=Or(l);if(c){const f=r.get(c)||[];f.push(i),r.set(c,f)}}if(i.data.nodeKind==="primitive"){const l=i.data.label,d=o.get(l)||[];d.push(i),o.set(l,d)}if(i.data.nodeKind==="agent"&&s.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 f=Or(Lr(i.data.stepId));if(f){const u=a.get(f)||[];u.includes(i)||(u.push(i),a.set(f,u))}}}}return{byStepId:t,byFunctionName:r,primitivesByLabel:o,agentNodes:s,toolNodes:a}}function ff(e,t,r){var d,c,f,u;const o=new Map,s=new Set(e),a=new Map;for(const p of t.nodes){const x=(d=p.metadata)==null?void 0:d.parallelGroupId;if(x){const w=a.get(x)||{nodes:[]};w.nodes.push(p),w.method=(c=p.metadata)==null?void 0:c.parallelMethod,a.set(x,w)}}const i=new Map;for(const[p,x]of a)if(x.method==="race"){let w,I;for(const b of x.nodes){const g=r.get(b.id);if(g){for(const v of g)if(v.status==="completed"&&v.completedAt){const N=new Date(v.completedAt);(!I||N<I)&&(I=N,w=b.id)}}}w&&i.set(p,w)}const l=p=>{const x=o.get(p.id);x?x.traversalCount++:o.set(p.id,{edgeId:p.id,traversalCount:1,timings:[]})};for(const p of t.edges){const x=t.nodes.find(N=>N.id===p.source),w=t.nodes.find(N=>N.id===p.target);if(!x||!w)continue;const I=s.has(p.source),b=s.has(p.target);if(!I&&!b)continue;if(p.type==="conditional"){I&&b&&l(p);continue}const g=(f=x.metadata)==null?void 0:f.parallelGroupId,v=(u=x.metadata)==null?void 0:u.parallelMethod;g&&v==="race"?i.get(g)===p.source&&b&&l(p):(I&&b||I&&p.type==="parallel"&&b)&&l(p)}return o}function mf(e,t,r,o){const s=t.nodes.find(a=>a.data.nodeKind==="workflow_start");s&&(r.push(s.id),o.set(s.id,[{nodeId:s.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 pf(e,t,r,o){const s=t.nodes.find(i=>i.data.nodeKind==="workflow_end");if(!s||r.includes(s.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(s.id),o.set(s.id,[{nodeId:s.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 hf(e,t,r,o,s,a,i){const l=Lr(t),d=s.get(l)||0;s.set(l,d+1);let c=r.get(l)||[],f="step-id";if(c.length===0){const w=Or(l);w&&(c=o.get(w)||[],f="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(w=>w.id),matchStrategy:f,strategy:c.length===1?"single-node-multiple-invocations":"occurrence-based"}),!u)return;const p=e.map((w,I)=>df(w,u.id,I,e.length));if(c.length===1){const w=a.get(u.id)||[];a.set(u.id,[...w,...p])}else a.set(u.id,p);return i.includes(u.id)||i.push(u.id),p[p.length-1].status==="running"?u.id:void 0}function gf(e,t,r,o){const s=new Map,a=new Map;for(const g of e){if(!g.correlationId)continue;const v=a.get(g.correlationId)||[];v.push(g),a.set(g.correlationId,v)}let i;const l=t.get(Ft.sleep)||[],d=new Set;for(const g of e)g.eventType==="wait_created"&&g.correlationId&&d.add(g.correlationId);const c=Array.from(d).sort((g,v)=>{var h,y;const N=a.get(g)||[],j=a.get(v)||[],S=(h=N.find(k=>k.eventType==="wait_created"))==null?void 0:h.createdAt,R=(y=j.find(k=>k.eventType==="wait_created"))==null?void 0:y.createdAt;return!S||!R?0:new Date(S).getTime()-new Date(R).getTime()});for(const g of c){const v=a.get(g)||[],N=v.find(C=>C.eventType==="wait_created"),j=v.find(C=>C.eventType==="wait_completed");if(!N)continue;const S=s.get(Ft.sleep)||0;s.set(Ft.sleep,S+1);const R=l.length===1?l[0]:l[S];if(!R)continue;let h="running";j&&(h="completed");const y=new Date(N.createdAt).toISOString(),k=j?new Date(j.createdAt).toISOString():void 0,T=j?new Date(j.createdAt).getTime()-new Date(N.createdAt).getTime():void 0,D={nodeId:R.id,attemptNumber:1,status:h,startedAt:y,completedAt:k,duration:T},M=r.get(R.id)||[];r.set(R.id,[...M,D]),o.includes(R.id)||o.push(R.id),h==="running"&&(i=R.id)}const f=[...t.get(Ft.createHook)||[],...t.get(Ft.createWebhook)||[]],u=new Set;for(const g of e)g.eventType==="hook_created"&&g.correlationId&&u.add(g.correlationId);const p=Array.from(u).sort((g,v)=>{var h,y;const N=a.get(g)||[],j=a.get(v)||[],S=(h=N.find(k=>k.eventType==="hook_created"))==null?void 0:h.createdAt,R=(y=j.find(k=>k.eventType==="hook_created"))==null?void 0:y.createdAt;return!S||!R?0:new Date(S).getTime()-new Date(R).getTime()});let x=0;for(const g of p){const N=(a.get(g)||[]).find(T=>T.eventType==="hook_created");if(!N)continue;const j=f.length===1?f[0]:f[x];if(x++,!j)continue;const S="completed",R=new Date(N.createdAt).toISOString(),h=new Date(N.createdAt).toISOString(),y={nodeId:j.id,attemptNumber:1,status:S,startedAt:R,completedAt:h,duration:0},k=r.get(j.id)||[];r.set(j.id,[...k,y]),o.includes(j.id)||o.push(j.id)}const w=t.get(Ft.awaitWebhook)||[],I=new Set;for(const g of e)g.eventType==="hook_received"&&g.correlationId&&I.add(g.correlationId);let b=0;for(const g of p){const v=w.length===1?w[0]:w[b];if(b++,!v)continue;const N=a.get(g)||[],j=N.find(M=>M.eventType==="hook_created"),S=N.find(M=>M.eventType==="hook_received");let R,h,y,k=0;S?(R="completed",h=j?new Date(j.createdAt).toISOString():new Date(S.createdAt).toISOString(),y=new Date(S.createdAt).toISOString(),k=new Date(y).getTime()-new Date(h).getTime()):j?(R="running",h=new Date(j.createdAt).toISOString()):R="pending";const T={nodeId:v.id,attemptNumber:1,status:R,startedAt:h,completedAt:y,duration:k},D=r.get(v.id)||[];r.set(v.id,[...D,T]),o.includes(v.id)||o.push(v.id)}return i}function xf(e,t,r,o,s,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 f={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};s.set(c.id,[f]),a.includes(c.id)||a.push(c.id)}for(const c of t){const f=Or(c.stepName);if(!f)continue;const u=o.get(f);if(!u||u.length===0)continue;const p=u[0];let x;switch(c.status){case"completed":x="completed";break;case"failed":x="failed";break;case"running":x="running";break;case"cancelled":x="cancelled";break;case"pending":default:x="pending";break}const w=c.completedAt&&c.startedAt?new Date(c.completedAt).getTime()-new Date(c.startedAt).getTime():void 0,I={nodeId:p.id,stepId:c.stepId,attemptNumber:c.attempt,status:x,startedAt:c.startedAt?new Date(c.startedAt).toISOString():void 0,completedAt:c.completedAt?new Date(c.completedAt).toISOString():void 0,duration:w,input:c.input,output:c.output,error:c.error},b=s.get(p.id)||[];s.set(p.id,[...b,I]),a.includes(p.id)||a.push(p.id)}for(const c of i){const f=((d=c.metadata)==null?void 0:d.isToolsCollection)===!0;if(c.data.nodeKind==="tool"&&f&&!s.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};s.set(c.id,[u]),a.includes(c.id)||a.push(c.id)}}}function vf(e,t,r,o){var i,l,d;const s=e.nodes.filter(c=>c.data.nodeKind==="conditional"),a=new Map;for(const c of e.nodes){const f=(i=c.metadata)==null?void 0:i.conditionalId;if(f){const u=a.get(f)||{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(f,u)}}for(const c of s){const f=c.id.match(/^(cond_\d+)_node$/);if(!f)continue;const u=f[1],p=a.get(u);if(!p)continue;const x=p.thenNodes.some(I=>t.has(I.id)),w=p.elseNodes.some(I=>t.has(I.id));if(x||w){const I=[...p.thenNodes,...p.elseNodes];if(!t.has(c.id)){let b;for(const N of I){const j=t.get(N.id);if(j&&j.length>0){const S=j[0];S.startedAt&&(!b||S.startedAt<b)&&(b=S.startedAt)}}const g=o.startedAt?new Date(o.startedAt).toISOString():void 0,v={nodeId:c.id,attemptNumber:1,status:"completed",startedAt:b||g,completedAt:b||g};t.set(c.id,[v])}if(!r.includes(c.id)){const b=I.map(g=>r.indexOf(g.id)).filter(g=>g>=0);if(b.length>0){const g=Math.min(...b);g>=0&&g<r.length?r.splice(g,0,c.id):r.push(c.id)}else r.push(c.id)}}}}function yf(e,t,r,o){const s=new Map,a=[];let i;console.log("[Graph Mapper] Mapping run to execution:",{runId:e.runId,workflowName:e.workflowName,graphNodes:o.nodes.length,stepsCount:t.length}),mf(e,o,a,s);const l=[...t].sort((j,S)=>new Date(j.createdAt).getTime()-new Date(S.createdAt).getTime());console.log("[Graph Mapper] Sorted steps:",l.map(j=>({stepId:j.stepId,stepName:j.stepName,attempt:j.attempt,status:j.status,createdAt:j.createdAt})));const{byStepId:d,byFunctionName:c,primitivesByLabel:f,agentNodes:u,toolNodes:p}=uf(o.nodes);console.log("[Graph Mapper] Graph nodes by stepId:",{allGraphNodes:o.nodes.map(j=>({id:j.id,stepId:j.data.stepId,normalizedStepId:j.data.stepId?Lr(j.data.stepId):void 0,nodeKind:j.data.nodeKind})),nodesByStepId:Array.from(d.entries()).map(([j,S])=>({stepId:j,nodeIds:S.map(R=>R.id)}))});const x=new Map;let w=[],I=null,b=null;for(let j=0;j<=l.length;j++){const S=l[j];if(!S||S.stepId!==I){if(w.length>0&&b){const h=hf(w,b,d,c,x,s,a);h&&(i=h)}S&&(w=[S],I=S.stepId,b=S.stepName)}else w.push(S)}const g=gf(r,f,s,a);g&&(i=g),xf(e,l,u,p,s,a,o.nodes),vf(o,s,a,e),pf(e,o,a,s);const v=ff(a,o,s),N={runId:e.runId,status:e.status,nodeExecutions:s,edgeTraversals:v,currentNode:i,executionPath:a};return console.log("[Graph Mapper] Mapping complete:",{executionPath:a,nodeExecutionsCount:s.size,nodeExecutions:Array.from(s.entries()).map(([j,S])=>{var R;return{nodeId:j,executionCount:S.length,latestStatus:(R=S[S.length-1])==null?void 0:R.status}})}),N}const Kt=4;function bf(e,t,r,o){const[s,a]=m.useState([]),[i,l]=m.useState(!1),[d,c]=m.useState(null),f=m.useRef(null),u=m.useRef(0);return m.useEffect(()=>{if(a([]),c(null),u.current=0,!t){l(!1);return}let p=!0;const x=new AbortController;f.current=x,l(!0);const w=Oi();return(async()=>{try{const b=await ru(e,t,void 0,x.signal),g=o?await Wi(o):void 0,v=b.getReader();let N=new Uint8Array(0);const j=S=>{const R=new Uint8Array(N.length+S.length);R.set(N,0),R.set(S,N.length),N=R};for(;!x.signal.aborted;){const{value:S,done:R}=await v.read();if(R){p&&l(!1);break}for(j(S);N.length>=Kt;){const y=new DataView(N.buffer,N.byteOffset,N.byteLength).getUint32(0,!1);if(N.length<Kt+y)break;const k=N.slice(Kt,Kt+y);N=N.slice(Kt+y);try{const{format:T,payload:D}=Mi(k);let M;if(T===_i.ENCRYPTED){if(!g){p&&(c("This stream is encrypted. Click Decrypt to view."),l(!1)),v.cancel().catch(()=>{});return}M=await $i(g,D)}else M=k;const C=Li(M,w);if(p&&C!==void 0&&C!==null){const E=u.current++,_=typeof C=="string"?C:JSON.stringify(C,null,2);a(O=>[...O,{id:E,text:_}])}}catch(T){console.error("Failed to process stream frame:",T)}}}}catch(b){if(x.signal.aborted)return;p&&(c(b instanceof Error?b.message:String(b)),l(!1))}})(),()=>{p=!1,f.current&&f.current.abort()}},[e,t,r,o]),{chunks:s,isLive:i,error:d}}function wf({hasError:e,errorMessage:t}){return n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(hn,{children:[n.jsx(gn,{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 $
39
- hasError
40
- ? 'text-red-600 dark:text-red-400'
41
- : 'text-muted-foreground'`,children:e?"Error":"Live"})]})}),n.jsx(xn,{children:n.jsx("p",{children:e?`Error updating data: ${t}`:`Content updates every ${Hi/1e3} seconds`})})]})})}function Go(e){return e==="retrying"?"running":e}function Nf({data:e,selected:t}){var o,s,a,i;const r=e;return n.jsxs("div",{className:`relative ${r.className||""}`,style:{borderWidth:((o=r.nodeStyle)==null?void 0:o.borderWidth)??2,borderRadius:8,padding:12,width:220,borderStyle:"solid",backgroundColor:(s=r.nodeStyle)==null?void 0:s.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(it,{type:"target",position:lt.Top,className:"!bg-purple-500"}),n.jsx(it,{type:"source",position:lt.Bottom,className:"!bg-purple-500"}),n.jsx(it,{type:"source",position:lt.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(it,{type:"target",position:lt.Left,id:"loop-in",className:"!bg-purple-500 !-left-1 !w-[6px] !h-[6px] !min-w-0 !min-h-0",style:{top:"70%"}})]})}function If({data:e,selected:t}){var a,i,l,d;const r=e,o=r.nodeKind==="workflow_start",s=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,!o&&n.jsx(it,{type:"target",position:lt.Top,className:"!bg-muted"}),!s&&n.jsx(it,{type:"source",position:lt.Bottom,className:"!bg-muted"})]})}function jf({data:e,selected:t}){var s,a,i;const r=e,o=160;return n.jsxs("div",{className:`relative flex items-center justify-center ${r.className||""}`,style:{width:o,height:o},children:[n.jsx("div",{style:{width:o*.7,height:o*.7,transform:"rotate(45deg)",borderWidth:2,borderStyle:"solid",borderRadius:4,backgroundColor:(s=r.nodeStyle)==null?void 0:s.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:o*.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(it,{type:"target",position:lt.Top,className:"!bg-red-500"}),n.jsx(it,{type:"source",position:lt.Bottom,id:"bottom",className:"!bg-red-500"}),n.jsx(it,{type:"source",position:lt.Left,id:"left",className:"!bg-red-500"}),n.jsx(it,{type:"source",position:lt.Right,id:"right",className:"!bg-red-500"})]})}const kf={loopNode:Nf,parallelGroup:Qa,executionNode:If,diamondNode:jf},Sf=Ja(ai);function Cf(e,t){const r=oi(e);if(!t||t.length===0)return{color:"hsl(var(--card-foreground))",backgroundColor:r,borderColor:"#9ca3af",opacity:.4};const o=t[t.length-1];let s="#9ca3af",a=2;switch(o.status){case"completed":s="#22c55e";break;case"failed":s="#ef4444",a=3;break;case"running":s="#3b82f6",a=2;break;case"retrying":s="#f97316";break;case"cancelled":s="#eab308";break;case"pending":s="#9ca3af";break}return{color:"hsl(var(--card-foreground))",backgroundColor:r,borderColor:s,borderWidth:a}}function Uo(e,t,r){const o=n.jsxs("div",{className:"flex items-start gap-2 w-full overflow-hidden",children:[n.jsx("div",{className:"flex-shrink-0",children:si(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 o;const s=r[r.length-1],a=r.length,i=a>1;return i||s.duration&&s.duration>0?n.jsxs("div",{className:"flex flex-col gap-1.5 w-full",children:[o,n.jsxs("div",{className:"flex flex-wrap gap-1 text-xs",children:[i&&n.jsxs(Cr,{variant:"outline",className:"text-xs px-1.5 py-0 border-orange-500 text-orange-700 dark:text-orange-300",children:["↻ ",a,"x"]}),s.duration&&s.duration>0&&n.jsxs(Cr,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-black/10 dark:bg-white/15 border-0",children:["⏱ ",At(s.duration,!0)]})]})]}):o}const Aa={...ri};function Ko(e,t){var d,c,f;const{nodes:r,groupNodes:o}=os(e,Aa),s=new Map,a=new Map;for(const u of o)u.id.startsWith("group_")&&a.set(u.id,u.position);for(const u of r){const p=(d=u.metadata)!=null&&d.parallelGroupId?`group_${u.metadata.parallelGroupId}`:null;p&&a.has(p)&&s.set(u.id,p)}const i=[],l=o.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 p=t==null?void 0:t.nodeExecutions.get(u.id),x=Cf(u.data.nodeKind,p),w=(t==null?void 0:t.currentNode)===u.id,I=!!((c=u.metadata)!=null&&c.loopId),b=!!((f=u.metadata)!=null&&f.loopIsAwait),g=u.data.nodeKind==="conditional",v=g?"diamondNode":I?"loopNode":"executionNode",N=s.get(u.id);let j=u.position;if(N){const R=a.get(N);R&&(j={x:u.position.x-R.x,y:u.position.y-R.y})}const S=w?"animate-pulse-subtle":"";I?i.push({id:u.id,type:v,position:j,parentId:N,extent:N?"parent":void 0,expandParent:!0,data:{...u.data,label:Uo(u.data,u.metadata,p),executions:p,isLoopNode:!0,isAwaitLoop:b,nodeStyle:x,className:S}}):g?i.push({id:u.id,type:v,position:j,parentId:N,extent:N?"parent":void 0,expandParent:!0,data:{...u.data,label:u.data.label,executions:p,nodeStyle:x,className:S}}):i.push({id:u.id,type:v,position:j,parentId:N,extent:N?"parent":void 0,expandParent:!0,data:{...u.data,label:Uo(u.data,u.metadata,p),executions:p,nodeStyle:x,className:S},style:{width:220}})}return i}function qo(e,t){const{additionalEdges:r}=os(e,Aa),s=[...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 ni(s,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:Zn.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 h of i.originalEdgeIds){const y=t==null?void 0:t.edgeTraversals.get(h);if(y&&y.traversalCount>0){l=y;break}}const d=l&&l.traversalCount>0,c=!!t,f=l!=null&&l.timings.length?l.timings.reduce((h,y)=>h+y,0)/l.timings.length:void 0;let u="bezier",p,x=i.label,w=!1;switch(i.type){case"parallel":u="smoothstep",p="4,4",x=void 0;break;case"loop":u="step",p="8,4";break;case"conditional":u="smoothstep",p="8,4",w=!0;break;default:u="bezier"}const b=d?"#22c55e":"#6b7280",g=d?void 0:p,v=c&&!d?.35:1,N=d?2.5:1,j=w?"#ffffff":"#6b7280",S=w?"#374151":"#f3f4f6",R=w?"#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(Cr,{variant:"secondary",className:"text-xs px-1.5 py-0",children:[l.traversalCount,"×"]}),f&&f>0&&n.jsxs("span",{className:"text-[10px] text-muted-foreground",children:["~",At(f,!0)]})]}):x,labelStyle:{fill:j,fontWeight:500,fontSize:"11px"},labelBgStyle:{fill:S,fillOpacity:.95,stroke:R,strokeWidth:1},labelBgPadding:[4,6],labelBgBorderRadius:4,markerEnd:{type:Zn.ArrowClosed,width:d?14:10,height:d?14:10,color:b},style:{strokeWidth:N,stroke:b,opacity:v,strokeDasharray:g}}})}function Tf({selectedNode:e,env:t,onClose:r}){const{node:o,executions:s,stepId:a,runId:i}=e,l=s[s.length-1],d=s.length>1,{data:c,loading:f}=qs(t??{},"step",a??"",{runId:i}),u=(c==null?void 0:c.input)??(l==null?void 0:l.input),p=(c==null?void 0:c.output)??(l==null?void 0:l.output),x=(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:o.data.label,children:o.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(rs,{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:o.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(ln,{status:Go(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:s.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()})]})]})]}),f&&a&&n.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground mb-3",children:[n.jsx(Rr,{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)})})]})]}),p!==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(p,null,2)})})]})]}),x&&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 x=="object"?JSON.stringify(x,null,2):String(x)})})]})]}),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:["(",s.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:s.map(w=>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 ",w.attemptNumber]}),n.jsxs("div",{className:"flex items-center gap-2",children:[n.jsx(ln,{status:Go(w.status)}),w.duration!==void 0&&w.duration>0&&n.jsx("span",{className:"font-mono text-muted-foreground",children:At(w.duration)})]})]},w.attemptNumber))})]})]})]})]})}function Ef({workflow:e,execution:t,env:r,onNodeClick:o}){const[s,a]=m.useState(null),i=320,l=m.useMemo(()=>Ko(e,t),[e,t]),d=m.useMemo(()=>qo(e,t),[e,t]),[c,f,u]=Za(l),[p,x,w]=Ya(d);m.useEffect(()=>{f(g=>{const v=Ko(e,t),N=new Map(g.map(j=>[j.id,j.position]));return v.map(j=>({...j,position:N.get(j.id)??j.position}))}),x(qo(e,t))},[e,t,f,x]);const I=m.useCallback((g,v)=>{const N=e.nodes.find(j=>j.id===v.id);if(N){const j=v.data.executions||[],S=j[j.length-1];a({nodeId:v.id,node:N,executions:j,stepId:S==null?void 0:S.stepId,runId:t==null?void 0:t.runId}),o&&j.length>0&&o(v.id,j)}},[e.nodes,t==null?void 0:t.runId,o]),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:s?`calc(100% - ${i}px)`:"100%"},children:n.jsxs(Xa,{nodes:c,edges:p,onNodesChange:u,onEdgesChange:w,onNodeClick:I,nodeTypes:kf,edgeTypes:Sf,fitView:!0,minZoom:.1,maxZoom:2,defaultViewport:{x:0,y:0,zoom:1},proOptions:{hideAttribution:!0},children:[n.jsx(ei,{}),n.jsx(ti,{}),n.jsx(qn,{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(qn,{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(Cr,{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]})]})]})]})}),s&&n.jsx("div",{className:"h-full flex-none",style:{width:i},children:n.jsx(Tf,{selectedNode:s,env:r,onClose:b})})]})}function Rf({run:e,allSteps:t,allEvents:r,env:o}){const{manifest:s,loading:a,error:i}=gi(),l=m.useMemo(()=>{var x;if(!s||!e.workflowName)return null;const c=String(e.workflowName).trim(),f=s.workflows[c];if(f)return f;const u=(x=bt(c))==null?void 0:x.shortName;return Object.values(s.workflows).find(w=>{var I;return w.workflowId===c||w.workflowName===c?!0:u?((I=bt(w.workflowName))==null?void 0:I.shortName)===u:!1})??null},[s,e.workflowName]),d=m.useMemo(()=>!l||!e.runId?null:yf(e,t||[],r||[],l),[l,e,t,r]);return a?n.jsxs("div",{className:"flex items-center justify-center w-full h-full",children:[n.jsx(Rr,{className:"h-8 w-8 animate-spin text-muted-foreground"}),n.jsx("span",{className:"ml-4 text-muted-foreground",children:"Loading workflow graph..."})]}):i?n.jsx("div",{className:"flex items-center justify-center w-full h-full p-4",children:n.jsxs(cn,{variant:"destructive",className:"max-w-lg",children:[n.jsx(dn,{className:"h-4 w-4"}),n.jsx(un,{children:"Error Loading Workflow Graph"}),n.jsx(fn,{children:i.message})]})}):l?n.jsx(Ef,{workflow:l,execution:d||void 0,env:o}):n.jsx("div",{className:"flex items-center justify-center w-full h-full",children:n.jsxs(cn,{className:"max-w-lg",children:[n.jsx(dn,{className:"h-4 w-4"}),n.jsx(un,{children:"Workflow Graph Not Found"}),n.jsx(fn,{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 Ce;const r=Da(),[o]=Xo(),{serverConfig:s}=Fi(),[a,i]=m.useState(!1),[l,d]=m.useState(!1),[c,f]=m.useState(!1),[u,p]=m.useState(!1),x=m.useMemo(()=>({}),[]),w=o.get("tab")||"trace",I=o.get("streamId"),b=m.useCallback(Q=>{const be=new URLSearchParams(o.toString());for(const[Te,Re]of Object.entries(Q))Re===null?be.delete(Te):be.set(Te,Re);r(`?${be.toString()}`,{preventScrollReset:!0})},[r,o]),g=m.useCallback(Q=>{b(Q==="trace"||Q==="graph"?{tab:Q,streamId:null}:{tab:Q})},[b]),v=m.useCallback(Q=>{b({streamId:Q})},[b]),N=m.useCallback(Q=>{b({tab:"streams",streamId:Q})},[b]),j=m.useCallback(async(Q,be)=>ii(x,Q,{correlationIds:[be]}),[x]),S=m.useRef(null),R=m.useCallback(async(Q,be)=>{await li(x,Q,be)},[x]),h=m.useCallback(async Q=>{const{error:be,result:Te}=await De(Yn(x,Q.runId,Q.eventId,"all"));if(be)throw be;const Re=S.current?await mn(Te,S.current):_e(Te);return"eventData"in Re?Re.eventData:null},[x]),y=m.useCallback(async(Q,be)=>{const{error:Te,result:Re}=await De(Yn(x,e,be,"all"));if(Te)throw Te;const rt=S.current?await mn(Re,S.current):_e(Re);return"eventData"in rt?rt.eventData:null},[x,e]),k=s.backendId==="local"||s.backendId==="@workflow/world-local",{run:T,steps:D,hooks:M,events:C,loading:E,auxiliaryDataLoading:_,error:O,update:H,loadMoreTraceData:z,hasMoreTraceData:V,isLoadingMoreTraceData:J}=eu(x,e,{live:!0}),P=T??{},[$,W]=m.useState(null);S.current=$;const[K,U]=m.useState(null),{data:Z,loading:ee,error:A,refresh:B}=qs(x,(K==null?void 0:K.resource)??"run",(K==null?void 0:K.resourceId)??"",{runId:K==null?void 0:K.runId,enabled:!!(K!=null&&K.resource&&(K!=null&&K.resourceId)&&K.resource!=="hook"),encryptionKey:$??void 0}),ne=m.useCallback(async()=>{if($){B();return}const{error:Q,result:be}=await De(Pi(x,e));if(Q){he.error(`Failed to fetch encryption key: ${Q.message}`);return}if(!be){he.error("Encryption is not configured for this deployment.");return}W(be)},[$,x,e,B]),ue=m.useCallback(Q=>{U(Q)},[]),{streams:ge,loading:q,error:te}=su(x,e),{chunks:me,isLive:pe,error:ce}=bf(x,I,e,$),ie=()=>{f(!0)},Ie=async()=>{if(!a)try{i(!0),f(!1),await pi(x,e),await H(),he.success("Run cancelled successfully")}catch(Q){console.error("Failed to cancel run:",Q),he.error("Failed to cancel run",{description:Q instanceof Error?Q.message:"An unknown error occurred"})}finally{i(!1)}},je=()=>{p(!0)},Ze=async()=>{if(!l)try{d(!0),p(!1);const Q=await hi(x,P.runId);he.success("New run started successfully",{description:`Run ID: ${Q}`}),r(`/run/${Q}`)}catch(Q){console.error("Failed to re-run workflow:",Q),he.error("Failed to start new run",{description:Q instanceof Error?Q.message:"An unknown error occurred"})}finally{d(!1),p(!1)}};if(O&&!T)return n.jsxs(cn,{variant:"destructive",className:"m-4",children:[n.jsx(dn,{className:"h-4 w-4"}),n.jsx(un,{children:"Error loading workflow run"}),n.jsx(fn,{children:O.message})]});const et=(Ce=bt(P.workflowName))==null?void 0:Ce.shortName;return n.jsxs(n.Fragment,{children:[n.jsx(Oo,{open:c,onOpenChange:f,children:n.jsxs(Ho,{children:[n.jsxs(Fo,{children:[n.jsx(Bo,{children:"Cancel Workflow Run?"}),n.jsx(zo,{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(Po,{children:[n.jsx($o,{children:"Keep Running"}),n.jsx(Wo,{onClick:Ie,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Run"})]})]})}),n.jsx(Oo,{open:u,onOpenChange:p,children:n.jsxs(Ho,{children:[n.jsxs(Fo,{children:[n.jsx(Bo,{children:"Replay Run?"}),n.jsx(zo,{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(Po,{children:[n.jsx($o,{children:"Cancel"}),n.jsx(Wo,{onClick:Ze,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(of,{children:n.jsxs(sf,{children:[n.jsx(Vo,{children:n.jsx(af,{asChild:!0,children:n.jsx(Ma,{to:"/",children:"Runs"})})}),n.jsx(cf,{}),n.jsx(Vo,{children:n.jsx(lf,{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:et||n.jsx(Ct,{className:"w-[260px] h-[28px]"})})}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx(wf,{hasError:!1,errorMessage:""}),(at(P.input)||at(P.output)||at(P.error)||D.some(Q=>at(Q.input)||at(Q.output)))&&n.jsxs(hn,{children:[n.jsx(gn,{asChild:!0,children:n.jsx("span",{children:n.jsxs(Bi,{variant:"outline",size:"sm",onClick:ne,disabled:!!$,children:[$?n.jsx(Yi,{className:"h-4 w-4"}):n.jsx(ss,{className:"h-4 w-4"}),$?"Decrypted":"Decrypt"]})})}),n.jsx(xn,{children:$?n.jsx("p",{children:"Data has been decrypted for this workflow run. All encrypted input, output, and event data is now visible across all tabs."}):n.jsx("p",{children:"This run's data is end-to-end encrypted. Decrypt to reveal input, output, and event data across all tabs for this workflow run."})})]}),n.jsx(ci,{env:x,runId:e,runStatus:P.status,events:C,eventsLoading:_,loading:E,onRerunClick:je,onCancelClick:ie,callbacks:{onSuccess:H}})]})]}),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(ln,{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(),be=Math.floor(Q/1e3);if(be<60)return`${be}s`;const Te=Math.floor(be/60),Re=be%60;if(Te<60)return Re>0?`${Te}m ${Re}s`:`${Te}m`;const rt=Math.floor(Te/60),nt=Te%60;return nt>0?`${rt}h ${nt}m`:`${rt}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(di,{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(pr,{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(pr,{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(pr,{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(hn,{children:[n.jsx(gn,{asChild:!0,children:n.jsxs("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",n.jsx(Gi,{className:"w-3 h-3"})]})}),n.jsx(xn,{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(pr,{date:P.expiredAt})})]})]})]})]}),n.jsxs("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:[n.jsxs(ui,{value:w,onValueChange:Q=>g(Q),className:"flex-1 flex flex-col min-h-0",children:[n.jsxs(fi,{className:"mb-4 flex-none",children:[n.jsxs(hr,{value:"trace",className:"gap-2",children:[n.jsx(Zr,{className:"h-4 w-4"}),"Trace"]}),k&&n.jsxs(hr,{value:"graph",className:"gap-2",children:[n.jsx(mi,{className:"h-4 w-4"}),"Graph"]}),n.jsxs(hr,{value:"events",className:"gap-2",children:[n.jsx(Zr,{className:"h-4 w-4"}),"Events"]}),n.jsxs(hr,{value:"streams",className:"gap-2",children:[n.jsx(Zr,{className:"h-4 w-4"}),"Streams"]})]}),n.jsx(gr,{value:"trace",className:"mt-0 flex-1 min-h-0",children:n.jsx(Pt,{title:"Failed to load trace viewer",children:n.jsx("div",{className:"h-full",children:n.jsx(qd,{error:O,steps:D,events:C,hooks:M,run:P,isLoading:E,spanDetailData:Z,spanDetailLoading:ee,spanDetailError:A,onSpanSelect:ue,onStreamClick:N,onWakeUpSleep:j,onResolveHook:R,onLoadEventData:y,onLoadMoreSpans:z,hasMoreSpans:V,isLoadingMoreSpans:J,encryptionKey:$??void 0})})})}),n.jsx(gr,{value:"events",className:"mt-0 flex-1 min-h-0",children:n.jsx(Pt,{title:"Failed to load events list",children:n.jsx("div",{className:"h-full",children:n.jsx(_c,{events:C,steps:D,run:P,onLoadEventData:h,encryptionKey:$??void 0})})})}),n.jsx(gr,{value:"streams",className:"mt-0 flex-1 min-h-0",children:n.jsx(Pt,{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 (",ge.length,")"]}),n.jsx("div",{className:"overflow-auto max-h-[calc(100vh-400px)]",children:q?n.jsx("div",{className:"p-4 flex items-center justify-center",children:n.jsx(Rr,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):te?n.jsx("div",{className:"p-4 text-xs text-destructive",children:te.message}):ge.length===0?n.jsx("div",{className:"p-4 text-xs",style:{color:"var(--ds-gray-600)"},children:"No streams found for this run"}):ge.map(Q=>n.jsx("button",{type:"button",onClick:()=>v(Q),className:"w-full text-left px-3 py-2 text-xs font-mono truncate hover:bg-accent transition-colors",style:{backgroundColor:I===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:I?n.jsx(zi,{streamId:I,chunks:me,isLive:pe,error:ce}):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:ge.length>0?"Select a stream to view its data":"No streams available"})})})]})})}),k&&n.jsx(gr,{value:"graph",className:"mt-0 flex-1 min-h-0",children:n.jsx(Pt,{title:"Failed to load execution graph",children:n.jsx("div",{className:"h-full min-h-[500px]",children:n.jsx(Rf,{run:P,allSteps:D,allEvents:C,env:x})})})})]}),_&&n.jsxs("div",{className:"fixed flex items-center gap-2 left-8 bottom-8 bg-background border rounded-md px-4 py-2 shadow-lg",children:[n.jsx(Rr,{className:"size-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Fetching data..."})]})]})]})]})}const Of=_a(function(){const t=La(),[r]=Xo(),o=t.runId,s=r.get("stepId"),a=r.get("eventId"),i=r.get("hookId"),l=s||a||i||void 0;return n.jsx(Pt,{title:"Failed to load run details",children:n.jsx(Af,{runId:o,selectedId:l})})});export{Of as default};