@workflow/web 4.1.0-beta.37 → 4.1.0-beta.38

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 (20) hide show
  1. package/build/client/assets/{highlighted-body-B3W2YXNL-BO6bNJzI.js → highlighted-body-B3W2YXNL-Rt-vkvmE.js} +1 -1
  2. package/build/client/assets/{home-bWDrLREI.js → home-Cpz2_ZDM.js} +1 -1
  3. package/build/client/assets/manifest-069935e6.js +1 -0
  4. package/build/client/assets/{mermaid-3ZIDBTTL-CJ6mkUFN.js → mermaid-3ZIDBTTL-DcdZu9sS.js} +3 -3
  5. package/build/client/assets/{root-Ckv-c9_b.js → root-DZgYUaDo.js} +1 -1
  6. package/build/client/assets/run-detail-xcvWVR2B.js +41 -0
  7. package/build/client/assets/{use-workflow-graph-JKiMb5g6.js → use-workflow-graph-CF7nLapT.js} +1 -1
  8. package/build/server/assets/{app-CatvtWxS.js → app-B9Eg2ZwJ.js} +1 -1
  9. package/build/server/assets/{highlighted-body-B3W2YXNL-DoOhy3wX.js → highlighted-body-B3W2YXNL-CppXFHRG.js} +3 -3
  10. package/build/server/assets/{mermaid-3ZIDBTTL-uuxw6-ur.js → mermaid-3ZIDBTTL-DB0PiTjt.js} +3 -3
  11. package/build/server/assets/{server-build-XXW48t5z.js → server-build-HMYt9inG.js} +314 -278
  12. package/build/server/assets/{token-CLFHo1Az.js → token-CBxSSoxh.js} +2 -2
  13. package/build/server/assets/{token-C58qysN7.js → token-COnBvzNW.js} +3 -3
  14. package/build/server/assets/{token-util-CcopqG1U.js → token-util-7Q4_oN66.js} +2 -2
  15. package/build/server/assets/{token-util-C6iVpF77.js → token-util-CagM_XOH.js} +2 -2
  16. package/build/server/assets/{token-util-CbxhzlWz.js → token-util-QvbM3ECv.js} +1 -1
  17. package/build/server/index.js +1 -1
  18. package/package.json +6 -6
  19. package/build/client/assets/manifest-daa82ff1.js +0 -1
  20. package/build/client/assets/run-detail-EcdnCjQk.js +0 -41
@@ -0,0 +1,41 @@
1
+ import{R as X,j as n,r as m,A as Yo,f as Zo,x as Aa,y as Xo,z as Da,w as Ma,C as _a}from"./index-DklpUtP3.js";import{U as cr,V as dr,B as It,j as Jo,q as Qo,Y as La,Z as Oa,S as es,R as ts,p as Ha,o as Fa,X as rs,Q as Bt,_ as Pa,G as Ba,$ as Re,u as jr,W as Rt,a0 as za,v as ht,a1 as Er,a2 as Wa,t as ns,a3 as $a,s as Va,a4 as Kr,w as En,l as Ga,m as Ua,a5 as Ka,a6 as qa,a7 as Ya,a8 as Za,a9 as Xa,aa as Ja,ab as Qa,ac as ei,ad as Yn,J as Rr,ae as os,af as ti,ag as ri,ah as Zn,ai as ct,aj as dt,F as un,ak as ni,al as oi,am as si,an as ai,r as ii,A as fn,C as mn,c as pn,d as hn,a as Tt,ao as li,e as ci,b as gr,T as di,M as ui,N as xr,K as fi,O as vr,y as mi,ap as pi,I as hi}from"./use-workflow-graph-CF7nLapT.js";import{c as ur,t as he,I as Dt,J as He,M as Ar,_ as gi,N as xi,O as lt,U as vi,W as yi,X as ss,Y as Mt,Z as ft,$ as re,a0 as bi,a1 as wi,a2 as qr,a3 as Ve,a4 as yr,a5 as Dr,a6 as zt,a7 as wt,a8 as as,a9 as Yt,aa as Yr,ab as Ii,ac as Ni,ad as ji,ae as ki,af as Si,ag as Ci,ah as Ti,ai as kr,aj as Oe,ak as is,k as Mr,E as gn,al as Ei,am as Zr,i as Xr,F as Jt,an as Ri,ao as Rn,z as jt,ap as Ai,d as qe,aq as ls,ar as Di,as as Mi,at as _i,au as Li,T as xn,a as vn,b as yn,av as Oi,L as _r,u as Hi,aw as Fi,B as Pi,ax as Bi}from"./mermaid-3ZIDBTTL-DcdZu9sS.js";import{importKey as zi,decrypt as Wi}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 $i=[["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"}]],Vi=ur("circle-question-mark",$i);/**
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 Gi=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ui=ur("info",Gi);/**
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 Ki=[["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"}]],Jr=ur("list",Ki);/**
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 qi=[["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=ur("lock-open",qi);/**
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 Zi=[["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"}]],Xi=ur("type",Zi),zr=0,kt=1,Gt=2,cs=4;function Xn(e){return()=>e}function Ji(e){e()}function ds(e,t){return r=>e(t(r))}function Jn(e,t){return()=>e(t)}function Qi(e,t){return r=>e(t,r)}function An(e){return e!==void 0}function el(...e){return()=>{e.map(Ji)}}function Ut(){}function Wr(e,t){return t(e),e}function tl(e,t){return t(e)}function we(...e){return e}function ve(e,t){return e(kt,t)}function le(e,t){e(zr,t)}function Dn(e){e(Gt)}function Se(e){return e(cs)}function J(e,t){return ve(e,Qi(t,zr))}function tt(e,t){const r=e(kt,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 us(e,t){return e===t}function be(e=us){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=>ds(t,e)}function it(e){return t=>()=>{t(e)}}function L(e,...t){const r=rl(...t);return((o,s)=>{switch(o){case Gt:Dn(e);return;case kt:return ve(e,r(s))}})}function ut(e,t){return r=>o=>{r(t=e(t,o))}}function _t(e){return t=>r=>{e>0?e--:t(r)}}function pt(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 rl(...e){return t=>e.reduceRight(tl,t)}function nl(e){let t,r;const o=()=>t==null?void 0:t();return function(s,a){switch(s){case kt:return a?r===a?void 0:(o(),r=a,t=ve(e,a),t):(o(),Ut);case Gt:o(),r=null;return}}}function F(e){let t=e;const r=fe();return((o,s)=>{switch(o){case zr:t=s;break;case kt:{s(t);break}case cs:return t}return r(o,s)})}function Be(e,t){return Wr(F(t),r=>J(e,r))}function fe(){const e=[];return((t,r)=>{switch(t){case zr:e.slice().forEach(o=>{o(r)});return;case Gt:e.splice(0,e.length);return;case kt:return e.push(r),()=>{const o=e.indexOf(r);o>-1&&e.splice(o,1)}}})}function Ke(e){return Wr(fe(),t=>J(e,t))}function xe(e,t=[],{singleton:r}={singleton:!0}){return{constructor:e,dependencies:t,id:ol(),singleton:r}}const ol=()=>Symbol();function sl(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 Gt:{Dn(t);return}case kt:return o===s&&i(r),ve(t,i)}}}function oe(e,t=us){return L(e,be(t))}function bn(...e){return function(t,r){switch(t){case Gt:return;case kt:return el(...e.map(o=>ve(o,r)))}}}var Ge=(e=>(e[e.DEBUG=0]="DEBUG",e[e.INFO=1]="INFO",e[e.WARN=2]="WARN",e[e.ERROR=3]="ERROR",e))(Ge||{});const al={0:"debug",3:"error",1:"log",2:"warn"},il=()=>typeof globalThis>"u"?window:globalThis,St=xe(()=>{const e=F(3);return{log:F((t,r,o=1)=>{var s;const a=(s=il().VIRTUOSO_LOG_LEVEL)!=null?s:Se(e);o>=a&&console[al[o]]("%creact-virtuoso: %c%s %o","color: #0253b3; font-weight: bold","color: initial",t,r)}),logLevel:e}},[],{singleton:!0});function Ot(e,t,r){return Mn(e,t,r).callbackRef}function Mn(e,t,r){const o=X.useRef(null);let s=i=>{};const a=X.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 ll(e,t,r,o,s,a,i,l,d){const c=X.useCallback(f=>{const u=cl(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 N=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(N,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 Mn(c,r,d)}function cl(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},Ge.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,Ge.WARN),t==="normal"?0:parseInt(t??"0",10)}function fs(e,t,r){const o=X.useRef(null),s=X.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}=Mn(s,!0,r),l=X.useCallback(()=>{s(i.current)},[s,i]);return X.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 We=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),N=F(!1);return J(L(e,G(({scrollTop:b})=>b)),t),J(L(e,G(({scrollHeight:b})=>b)),i),J(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:N,smoothScrollTargetReached:o,statefulScrollTop:s,viewportHeight:a}},[],{singleton:!0}),tr={lvl:0};function ms(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===tr}function rr(e,t){if(!ye(e))return t===e.k?e.v:t<e.k?rr(e.l,t):rr(e.r,t)}function nt(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=nt(e.r,t,r);return o[0]===-1/0?[e.k,e.v]:o}return nt(e.l,t,r)}function Ue(e,t,r){return ye(e)?gs(t,r,1):t===e.k?Ae(e,{k:t,v:r}):t<e.k?to(Ae(e,{l:Ue(e.l,t,r)})):to(Ae(e,{r:Ue(e.r,t,r)}))}function Wt(){return tr}function $t(e,t,r){if(ye(e))return[];const o=nt(e,t)[0];return dl(In(e,o,r))}function wn(e,t){if(ye(e))return tr;const{k:r,l:o,r:s}=e;if(t===r){if(ye(o))return s;if(ye(s))return o;{const[a,i]=hs(o);return Sr(Ae(e,{k:a,l:ps(o),v:i}))}}else return t<r?Sr(Ae(e,{l:wn(o,t)})):Sr(Ae(e,{r:wn(s,t)}))}function At(e){return ye(e)?[]:[...At(e.l),{k:e.k,v:e.v},...At(e.r)]}function In(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(In(s,t,r))),o>=t&&o<=r&&l.push({k:o,v:i}),o<=r&&(l=l.concat(In(a,t,r))),l}function Sr(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(Qr(t))return xs(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(Qr(e))return Nn(Ae(e,{lvl:r-1}));if(!ye(o)&&!ye(o.l)){const s=o.l,a=Qr(s)?o.lvl-1:o.lvl;return Ae(s,{l:Ae(e,{lvl:r-1,r:s.l}),lvl:s.lvl+1,r:Nn(Ae(o,{l:s.r,lvl:a}))})}else throw new Error("Unexpected empty nodes")}}function Ae(e,t){return gs(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 ps(e){return ye(e.r)?e.l:Sr(Ae(e,{r:ps(e.r)}))}function Qr(e){return ye(e)||e.lvl>e.r.lvl}function hs(e){return ye(e.r)?[e.k,e.v]:hs(e.r)}function gs(e,t,r,o=tr,s=tr){return{k:e,l:o,lvl:r,r:s,v:t}}function to(e){return Nn(xs(e))}function xs(e){const{l:t}=e;return!ye(t)&&t.lvl===e.lvl?Ae(t,{r:Ae(e,{l:t.r})}):e}function Nn(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 dl(e){return ms(e,({k:t,v:r})=>({index:t,value:r}))}function vs(e,t){return!!(e&&e.startIndex===t.startIndex&&e.endIndex===t.endIndex)}function nr(e,t){return!!(e&&e[0]===t[0]&&e[1]===t[1])}const _n=xe(()=>({recalcInProgress:F(!1)}),[],{singleton:!0});function ys(e,t,r){return e[Lr(e,t,r)]}function Lr(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 ul(e,t,r,o){const s=Lr(e,t,o),a=Lr(e,r,o,s);return e.slice(s,a+1)}function Nt(e,t){return Math.round(e.getBoundingClientRect()[t])}function $r(e){return!ye(e.groupOffsetTree)}function Ln({index:e},t){return t===e?0:t<e?-1:1}function fl(){return{groupIndices:[],groupOffsetTree:Wt(),lastIndex:0,lastOffset:0,lastSize:0,offsetTree:[],sizeTree:Wt()}}function ml(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=Ue(e,0,a);continue}const l=$t(e,i-1,s+1);if(l.some(bl(o)))continue;let d=!1,c=!1;for(const{end:f,start:u,value:p}of l)d?(s>=u||a===p)&&(e=wn(e,u)):(c=p!==a,d=!0),f>s&&s>=u&&p!==a&&(e=Ue(e,s+1,p));c&&(e=Ue(e,i,a))}return[e,r]}function pl(e){return typeof e.groupIndex<"u"}function hl({offset:e},t){return t===e?0:t<e?-1:1}function or(e,t,r){if(t.length===0)return 0;const{index:o,offset:s,size:a}=ys(t,e,Ln),i=e-o,l=a*i+(i-1)*r+s;return l>0?l+r:l}function bs(e,t){if(!$r(t))return e;let r=0;for(;t.groupIndices[r]<=e+r;)r++;return e+r}function ws(e,t,r){if(pl(e))return t.groupIndices[e.groupIndex]+1;{const o=e.index==="LAST"?r:e.index;let s=bs(o,t);return s=Math.max(0,s,Math.min(r,s)),s}}function gl(e,t,r,o=0){return o>0&&(t=Math.max(t,ys(e,o,Ln).offset)),ms(ul(e,t,r,hl),yl)}function xl(e,[t,r,o,s]){t.length>0&&o("received item sizes",t,Ge.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,N)=>Ue(Ue(w,N,p),N+1,x),i)}else[i,l]=ml(i,t);if(i===a)return e;const{lastIndex:d,lastOffset:c,lastSize:f,offsetTree:u}=jn(e.offsetTree,l,i,s);return{groupIndices:r,groupOffsetTree:r.reduce((p,x)=>Ue(p,x,or(x,u,s)),Wt()),lastIndex:d,lastOffset:c,lastSize:f,offsetTree:u,sizeTree:i}}function vl(e){return At(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 jn(e,t,r,o){let s=e,a=0,i=0,l=0,d=0;if(t!==0){d=Lr(s,t-1,Ln),l=s[d].offset;const c=nt(r,t-1);a=c[0],i=c[1],s.length&&s[d].size===nt(r,t)[1]&&(d-=1),s=s.slice(0,d+1)}else s=[];for(const{start:c,value:f}of $t(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 yl(e){return{index:e.index,value:e}}function bl(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 wl={offsetHeight:"height",offsetWidth:"width"},mt=xe(([{log:e},{recalcInProgress:t}])=>{const r=fe(),o=fe(),s=Be(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)=>Nt(h,wl[y])),w=F(void 0),N=F(0),b=fl(),g=Be(L(r,de(d,e,N),ut(xl,b),be()),b),v=Be(L(d,be(),ut((h,y)=>({current:y,prev:h.current}),{current:[],prev:[]}),G(({prev:h})=>h)),[]);J(L(d,se(h=>h.length>0),de(g,N),G(([h,y,k])=>{const T=h.reduce((D,M,C)=>Ue(D,M,or(M,y.offsetTree,k)||C),Wt());return{...y,groupIndices:h,groupOffsetTree:T}})),g),J(L(o,de(g),se(([h,{lastIndex:y}])=>h<y),G(([h,{lastIndex:y,lastSize:k}])=>[{endIndex:y,size:k,startIndex:h}])),r),J(c,f);const I=Be(L(c,G(h=>h===void 0)),!0);J(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),J(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),J(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=Ke(L(r,de(g),ut(({sizes:h},[y,k])=>({changed:k!==h,sizes:k}),{changed:!1,sizes:b}),G(h=>h.changed)));ve(L(l,ut((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},Ge.ERROR)});const S=Ke(a);J(L(a,de(g),G(([h,y])=>{const k=y.groupIndices.length>0,T=[],D=y.lastSize;if(k){const M=rr(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 _=At(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 At(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=Ke(L(i,de(g,N),G(([h,{offsetTree:y},k])=>{const T=-h;return or(T,y,k)})));return J(L(i,de(g,N),G(([h,y,k])=>{if(y.groupIndices.length>0){if(ye(y.sizeTree))return y;let T=Wt();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=At(y.sizeTree).reduce((_,{k:O,v:H})=>Ue(_,Math.max(0,O+h),H),T),M!==-h){const _=rr(y.sizeTree,E);T=Ue(T,0,_);const O=nt(y.sizeTree,-h+1)[1];T=Ue(T,1,O)}return{...y,sizeTree:T,...jn(y.offsetTree,0,T,k)}}else{const T=At(y.sizeTree).reduce((D,{k:M,v:C})=>Ue(D,Math.max(0,M+h),C),Wt());return{...y,sizeTree:T,...jn(y.offsetTree,0,T,k)}}})),g),{beforeUnshiftWith:S,data:w,defaultItemSize:f,firstItemIndex:l,fixedItemSize:c,fixedGroupSize:u,gap:N,groupIndices:d,heightEstimates:p,itemSize:x,listRefresh:j,shiftWith:i,shiftWithOffset:R,sizeRanges:r,sizes:g,statefulTotalCount:s,totalCount:o,trackItemSizes:I,unshiftWith:a}},we(St,_n),{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=Ke(L(a,G(Il)));return J(L(l,G(d=>d.totalCount)),r),J(L(l,G(d=>d.groupIndices)),e),J(L(Ee(s,t,o),se(([d,c])=>$r(c)),G(([d,c,f])=>nt(c.groupOffsetTree,Math.max(d-f,0),"v")[0]),be(),G(d=>[d])),i),{groupCounts:a,topItemsIndexes:i}},we(mt,We)),Ct=xe(([{log:e}])=>{const t=F(!1),r=Ke(L(t,se(o=>o),be()));return ve(t,o=>{o&&Se(e)("props updated",{},Ge.DEBUG)}),{didMount:r,propsReady:t}},we(St),{singleton:!0}),Nl=typeof document<"u"&&"scrollBehavior"in document.documentElement.style;function Ns(e){const t=typeof e=="number"?{index:e}:e;return t.align||(t.align="start"),(!t.behavior||!Nl)&&(t.behavior="auto"),t.offset||(t.offset=0),t}const fr=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(),N=F(0);let b=null,g=null,v=null;function I(){b&&(b(),b=null),v&&(v(),v=null),g&&(clearTimeout(g),g=null),le(d,!1)}return J(L(x,de(r,u,o,N,l,i,p),de(e,a,s),G(([[j,S,R,h,y,k,T,D],M,C,E])=>{const _=Ns(j),{align:O,behavior:H,offset:z}=_,V=h-1,Q=ws(_,S,V);let P=or(Q,S.offsetTree,M)+k;O==="end"?(P+=C+nt(S.sizeTree,Q)[1]-R+E,Q===V&&(P+=T)):O==="center"?P+=(C+nt(S.sizeTree,Q)[1]-R+E)/2:P-=y,z&&(P+=z);const $=W=>{I(),W?(D("retrying to scroll to",{location:j},Ge.DEBUG),le(x,j)):(le(w,!0),D("list did not change, scroll successful",{},Ge.DEBUG))};if(I(),H==="smooth"){let W=!1;v=ve(t,K=>{W=W||K}),b=tt(f,()=>{$(W)})}else b=tt(L(t,jl(150)),$);return g=setTimeout(()=>{I()},1200),le(d,!0),D("scrolling from index to",{behavior:H,index:Q,top:P},Ge.DEBUG),{behavior:H,top:P}})),c),{scrollTargetReached:w,scrollToIndex:x,topListHeight:N}},we(mt,We,St),{singleton:!0});function jl(e){return t=>{const r=setTimeout(()=>{t(!1)},e);return o=>{o&&(t(!0),clearTimeout(r))}}}function On(e,t){e==0?t():requestAnimationFrame(()=>{On(e-1,t)})}function Hn(e,t){const r=t-1;return typeof e=="number"?e:e.index==="LAST"?r:e.index}const mr=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 J(L(i,de(d),se(([f,u])=>!!u),it(!1)),l),J(L(i,de(d),se(([f,u])=>!!u),it(!1)),c),ve(L(Ee(t,i),de(l,r,e,c),se(([[,f],u,{sizeTree:p},x,w])=>f&&(!ye(p)||An(x))&&!u&&!w),de(d)),([,f])=>{tt(s,()=>{le(c,!0)}),On(4,()=>{tt(o,()=>{le(l,!0)}),le(a,f)})}),{initialItemFinalLocationReached:c,initialTopMostItemIndex:d,scrolledToInitialItem:l}},we(mt,We,fr,Ct),{singleton:!0});function js(e,t){return Math.abs(e-t)<1.01}const sr="up",Qt="down",kl="none",Sl={atBottom:!1,notAtBottomBecause:"NOT_SHOWING_LAST_ITEM",state:{offsetBottom:0,scrollHeight:0,scrollTop:0,viewportHeight:0}},Cl=0,pr=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(Cl),p=Be(L(bn(L(oe(s),_t(1),it(!0)),L(oe(s),_t(1),it(!1),Qn(100))),be()),!1),x=Be(L(bn(L(r,it(!0)),L(r,it(!1),Qn(200))),be()),!1);J(L(Ee(oe(s),oe(u)),G(([v,I])=>v<=I),be()),l),J(L(l,pt(50)),c);const w=Ke(L(Ee(o,oe(a),oe(t),oe(e),oe(f)),ut((v,[{scrollHeight:I,scrollTop:j},S,R,h,y])=>{const k=j+S-I>-y,T={scrollHeight:I,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}},Sl),be((v,I)=>v&&v.atBottom===I.atBottom))),N=Be(L(o,ut((v,{scrollHeight:I,scrollTop:j,viewportHeight:S})=>{if(js(v.scrollHeight,I))return{changed:!1,jump:0,scrollHeight:I,scrollTop:j};{const R=I-(j+S)<1;return v.scrollTop!==j&&R?{changed:!0,jump:v.scrollTop-j,scrollHeight:I,scrollTop:j}:{changed:!0,jump:0,scrollHeight:I,scrollTop:j}}},{changed:!1,jump:0,scrollHeight:0,scrollTop:0}),se(v=>v.changed),G(v=>v.jump)),0);J(L(w,G(v=>v.atBottom)),i),J(L(i,pt(50)),d);const b=F(Qt);J(L(o,G(({scrollTop:v})=>v),be(),ut((v,I)=>Se(x)?{direction:v.direction,prevScrollTop:I}:{direction:I<v.prevScrollTop?sr:Qt,prevScrollTop:I},{direction:Qt,prevScrollTop:0}),G(v=>v.direction)),b),J(L(o,pt(50),it(kl)),b);const g=F(0);return J(L(p,se(v=>!v),it(0)),g),J(L(s,pt(100),de(p),se(([v,I])=>I),ut(([v,I],[j])=>[I,j],[0,0]),G(([v,I])=>I-v)),g),{atBottomState:w,atBottomStateChange:d,atBottomThreshold:f,atTopStateChange:c,atTopThreshold:u,isAtBottom:i,isAtTop:l,isScrolling:p,lastJumpDueToItemResize:N,scrollDirection:b,scrollVelocity:g}},we(We)),ar="top",ir="bottom",no="none";function oo(e,t,r){return typeof e=="number"?r===sr&&t===ar||r===Qt&&t===ir?e:0:r===sr?t===ar?e.main:e.reverse:t===ir?e.main:e.reverse}function so(e,t){var r;return typeof e=="number"?e:(r=e[t])!=null?r:0}const Fn=xe(([{deviation:e,fixedHeaderHeight:t,headerHeight:r,scrollTop:o,viewportHeight:s}])=>{const a=fe(),i=F(0),l=F(0),d=F(0),c=Be(L(Ee(oe(o),oe(s),oe(r),oe(a,nr),oe(d),oe(i),oe(t),oe(e),oe(l)),G(([f,u,p,[x,w],N,b,g,v,I])=>{const j=f-v,S=b+g,R=Math.max(p-j,0);let h=no;const y=so(I,ar),k=so(I,ir);return x-=v,x+=p+g,w+=p+g,w-=v,x>f+S-y&&(h=sr),w<f-R+u+k&&(h=Qt),h!==no?[Math.max(j-p-oo(N,ar,h)-y,0),j-R-g+u+oo(N,ir,h)+k]:null}),se(f=>f!=null),be(nr)),[0,0]);return{increaseViewportBy:l,listBoundary:a,overscan:d,topListHeight:i,visibleRange:c}},we(We),{singleton:!0});function Tl(e,t,r){if($r(t)){const o=bs(e,t);return[{index:nt(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 en={bottom:0,firstItemIndex:0,items:[],offsetBottom:0,offsetTop:0,top:0,topItems:[],topListHeight:0,totalCount:0};function Cr(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 N=e[e.length-1];f=N.offset+N.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((N,b)=>b.size+N,0),totalCount:r}}function ks(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=Hn(t,l),c=Array.from({length:l}).map((f,u)=>({data:a[u+d],index:u+d,offset:0,size:0}));return Cr(c,[],l,s,r,o)}function ao(e,t,r){if(e.length===0)return[];if(!$r(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=$t(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 Ht=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 N=F([]),b=F(0),g=fe(),v=F(0);J(a.topItemsIndexes,N);const I=Be(L(Ee(x,w,oe(d,nr),oe(s),oe(o),oe(c),f,oe(N),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,Q,P;const $=T,{offsetTree:W,sizeTree:K}=$,U=Se(b);if(k===0)return{...en,totalCount:k};if(h===0&&y===0)return U===0?{...en,totalCount:k}:ks(U,D,T,E,_,H||[]);if(ye(K))return U>0?null:Cr(Tl(Hn(D,k),$,H),[],k,_,$,E);const Y=[];if(C.length>0){const q=C[0],te=C[C.length-1];let me=0;for(const pe of $t(K,q,te)){const ce=pe.value,ie=Math.max(pe.start,q),Ie=Math.min(pe.end,te);for(let Ne=ie;Ne<=Ie;Ne++)Y.push({data:H==null?void 0:H[Ne],index:Ne,offset:me,size:ce}),me+=ce}}if(!M)return Cr([],Y,k,_,$,E);const ee=C.length>0?C[C.length-1]+1:0,A=gl(W,h,y,ee);if(A.length===0)return null;const B=k-1,ne=Wr([],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 Ne=ce-te.start;pe+=Ne*ie+Ne*_}ce<ee&&(pe+=(ee-ce)*ie,ce=ee);const Ie=Math.min(te.end,B);for(let Ne=ce;Ne<=Ie&&!(pe>=y);Ne++)q.push({data:H==null?void 0:H[Ne],index:Ne,offset:pe,size:ie}),pe+=ie+_}}),ue=io(O,ar),ge=io(O,ir);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=$t(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=(Q=$t(K,ce,ce)[0])==null?void 0:Q.value)!=null?P:te.size;ne.push({data:H==null?void 0:H[ce],index:ce,offset:pe,size:ie}),pe+=ie+_}}}return Cr(ne,Y,k,_,$,E)}),se(h=>h!==null),be()),en);J(L(e,se(An),G(h=>h==null?void 0:h.length)),s),J(L(I,G(h=>h.topListHeight)),u),J(u,l),J(L(I,G(h=>[h.top,h.bottom])),i),J(L(I,G(h=>h.items)),g);const j=Ke(L(I,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]),be(nr),G(([h])=>h))),S=Ke(L(I,pt(200),se(({items:h,topItems:y})=>h.length>0&&h[0].originalIndex===y.length),G(({items:h})=>h[0].index),be())),R=Ke(L(I,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}}),be(vs)));return{endReached:j,initialItemCount:b,itemsRendered:g,listState:I,minOverscanItemCount:v,rangeChanged:R,startReached:S,topItemsIndexes:N,...p}},we(mt,Is,Fn,mr,fr,pr,Ct,_n),{singleton:!0}),Ss=xe(([{fixedFooterHeight:e,fixedHeaderHeight:t,footerHeight:r,headerHeight:o},{listState:s}])=>{const a=fe(),i=Be(L(Ee(r,e,o,t,s),G(([l,d,c,f,u])=>l+d+c+f+u.offsetBottom+u.bottom)),0);return J(oe(i),a),{totalListHeight:i,totalListHeightChanged:a}},we(We,Ht),{singleton:!0}),El=xe(([{viewportHeight:e},{totalListHeight:t}])=>{const r=F(!1),o=Be(L(Ee(r,e,t),se(([s])=>s),G(([,s,a])=>Math.max(0,s-a)),pt(0),be()),0);return{alignToBottom:r,paddingTopAddition:o}},we(We,Ss),{singleton:!0}),Cs=xe(()=>({context:F(null)})),Rl=({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,Ts=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 J(L(f,de(t,d,r,a,s,o,l),de(e),G(([[u,p,x,w,N,b,g,v],I])=>{const{align:j,behavior:S,calculateViewLocation:R=Rl,done:h,...y}=u,k=ws(u,p,w-1),T=or(k,p.offsetTree,I)+N+b,D=T+nt(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&&tt(L(i,se(_=>!_),_t(Se(i)?1:2)),h):h==null||h(),E}),se(u=>u!==null)),c),{scrollIntoView:f}},we(mt,We,fr,Ht,St),{singleton:!0});function lo(e){return e?e==="smooth"?"smooth":"auto":!1}const Al=(e,t)=>typeof e=="function"?lo(e(t)):t&&lo(e),Dl=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),N=fe();let b=null;function g(S){le(i,{align:"end",behavior:S,index:"LAST"})}ve(L(Ee(L(oe(t),_t(1)),d),de(oe(w),a,l,u),G(([[S,R],h,y,k,T])=>{let D=R&&k,M="auto";return D&&(M=Al(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},Ge.DEBUG),g(S)}):b=tt(e,()=>{Se(f)("following output to ",{totalCount:R},Ge.DEBUG),g(S),b=null})});function v(S){const R=tt(s,h=>{S&&!h.atBottom&&h.notAtBottomBecause==="SIZE_INCREASED"&&!b&&(Se(f)("scrolling to bottom due to increased size",{},Ge.DEBUG),g("auto"))});setTimeout(R,100)}ve(L(Ee(oe(w),t,c),se(([S,,R])=>S&&R),ut(({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(N,()=>{v(Se(w)!==!1)}),ve(Ee(oe(w),s),([S,R])=>{S&&!R.atBottom&&R.notAtBottomBecause==="VIEWPORT_HEIGHT_DECREASING"&&g("auto")});const I=F(null),j=fe();return J(bn(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,_t(1)),d),de(oe(I),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),pt(0)),S=>{b&&(b(),b=null),Se(r)?requestAnimationFrame(()=>{Se(f)("scrolling into view",{}),le(x,S)}):b=tt(e,()=>{Se(f)("scrolling into view",{}),le(x,S),b=null})}),{autoscrollToBottom:N,followOutput:w,scrollIntoViewOnChange:I}},we(mt,pr,fr,mr,Ct,St,We,Cs,Ts)),Ml=xe(([{data:e,firstItemIndex:t,gap:r,sizes:o},{initialTopMostItemIndex:s},{initialItemCount:a,listState:i},{didMount:l}])=>(J(L(l,de(a),se(([,d])=>d!==0),de(s,o,t,r,e),G(([[,d],c,f,u,p,x=[]])=>ks(d,c,f,u,p,x))),i),{}),we(mt,mr,Ht,Ct),{singleton:!0}),_l=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=>{tt(L(r,_t(1),se(a=>a.items.length>1)),()=>{requestAnimationFrame(()=>{le(t,s)})})}),{initialScrollTop:o}},we(Ct,We,Ht),{singleton:!0}),Es=xe(([{scrollVelocity:e}])=>{const t=F(!1),r=fe(),o=F(!1);return J(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}),be()),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}},we(pr),{singleton:!0}),Pn=xe(([{scrollContainerState:e,scrollTo:t}])=>{const r=fe(),o=fe(),s=fe(),a=F(!1),i=F(void 0);return J(L(Ee(r,o),G(([{scrollHeight:l,scrollTop:d,viewportHeight:c},{offsetTop:f}])=>({scrollHeight:l,scrollTop:Math.max(0,d-f),viewportHeight:c}))),e),J(L(t,de(o),G(([l,{offsetTop:d}])=>({...l,top:l.top+d}))),s),{customScrollParent:i,useWindowScroll:a,windowScrollContainerState:r,windowScrollTo:s,windowViewportRect:o}},we(We)),Ll=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 J(l,u),J(d,p),ve(L(c,de(t,o,i,u,p,r)),([x,w,N,b,g,v,I])=>{const j=vl(w.sizeTree);b&&g!==null&&v!==null&&(N=g.scrollTop-v.offsetTop),N-=I,x({ranges:j,scrollTop:N})}),J(L(f,se(An),G(Ol)),s),J(L(a,de(f),se(([,x])=>x!==void 0),be(),G(([,x])=>x.ranges)),e),{getState:c,restoreStateFrom:f}},we(mt,We,mr,Ct,Pn));function Ol(e){return{align:"start",index:0,offset:e.scrollTop}}const Hl=xe(([{topItemsIndexes:e}])=>{const t=F(0);return J(L(t,se(r=>r>=0),G(r=>Array.from({length:r}).map((o,s)=>s))),e),{topItemCount:t}},we(Ht));function Rs(e){let t=!1,r;return(()=>(t||(t=!0,r=e()),r))}const Fl=Rs(()=>/iP(ad|od|hone)/i.test(navigator.userAgent)&&/WebKit/i.test(navigator.userAgent)),Pl=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 N=Ke(L(d,de(i),ut(([,g,v,I],[{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-I,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,I,,,j])=>!j&&!I&&g!==0&&v===sr),G(([[g],,,,,v])=>(v("Upward scrolling compensation",{amount:g},Ge.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(N,de(e,a)),([g,v,I])=>{I&&Fl()?le(e,v-g):b(-g)}),ve(L(Ee(Be(a,!1),e,w),se(([g,v,I])=>!g&&!I&&v!==0),G(([g,v])=>v),pt(1)),b),J(L(u,G(g=>({top:-g}))),t),ve(L(c,de(p,f),G(([g,{groupIndices:v,lastSize:I,sizeTree:j},S])=>{function R(h){return h*(I+S)}if(v.length===0)return R(g);{let h=0;const y=rr(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}},we(We,pr,Ht,mt,St,_n)),Bl=xe(([e,t,r,o,s,a,i,l,d,c,f])=>({...e,...t,...r,...o,...s,...a,...i,...l,...d,...c,...f}),we(Fn,Ml,Ct,Es,Ss,_l,El,Pn,Ts,St,Cs)),As=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:N,scrolledToInitialItem:b},g,v,I,j,{scrollToIndex:S},R,{topItemCount:h},{groupCounts:y},k])=>{const{listState:T,minOverscanItemCount:D,topItemsIndexes:M,rangeChanged:C,...E}=j;return J(C,k.scrollSeekRangeChanged),J(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:N,scrolledToInitialItem:b,sizeRanges:c,topItemCount:h,topItemsIndexes:M,totalCount:p,...I,groupIndices:i,itemSize:d,listState:T,minOverscanItemCount:D,scrollToIndex:S,statefulTotalCount:u,trackItemSizes:x,rangeChanged:C,...E,...k,...g,sizes:f,...v}},we(mt,mr,We,Ll,Dl,Ht,fr,Pl,Hl,Is,Bl));function zl(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 br=typeof document<"u"?X.useLayoutEffect:X.useEffect;function Ds(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=X.createContext({});function d(b,g){b.propsReady&&le(b.propsReady,!1);for(const v of o){const I=b[t.required[v]];le(I,g[v])}for(const v of s)if(v in g){const I=b[t.optional[v]];le(I,g[v])}b.propsReady&&le(b.propsReady,!0)}function c(b){return a.reduce((g,v)=>(g[v]=I=>{const j=b[t.methods[v]];le(j,I)},g),{})}function f(b){return i.reduce((g,v)=>(g[v]=nl(b[t.events[v]]),g),{})}const u=X.forwardRef((b,g)=>{const{children:v,...I}=b,[j]=X.useState(()=>Wr(sl(e),h=>{d(h,I)})),[S]=X.useState(Jn(f,j));br(()=>{for(const h of i)h in I&&ve(S[h],I[h]);return()=>{Object.values(S).map(Dn)}},[I,S,j]),br(()=>{d(j,I)}),X.useImperativeHandle(g,Xn(c(j)));const R=r;return n.jsx(l.Provider,{value:j,children:r?n.jsx(R,{...zl([...o,...s,...i],I),children:v}):v})}),p=b=>{const g=X.useContext(l);return X.useCallback(v=>{le(g[b],v)},[g,b])},x=b=>{const g=X.useContext(l)[b],v=X.useCallback(I=>ve(g,I),[g]);return X.useSyncExternalStore(v,()=>Se(g),()=>Se(g))},w=b=>{const g=X.useContext(l)[b],[v,I]=X.useState(Jn(Se,g));return br(()=>ve(g,j=>{j!==v&&I(Xn(j))}),[g,v]),v},N=X.version.startsWith("18")?x:w;return{Component:u,useEmitter:(b,g)=>{const v=X.useContext(l)[b];br(()=>ve(v,g),[g,v])},useEmitterValue:N,usePublisher:p}}const Ms=X.createContext(void 0),_s=X.createContext(void 0),Ls=typeof document<"u"?X.useLayoutEffect:X.useEffect;function tn(e){return"self"in e}function Wl(e){return"body"in e}function Os(e,t,r,o=Ut,s,a){const i=X.useRef(null),l=X.useRef(null),d=X.useRef(null),c=X.useCallback(p=>{let x,w,N;const b=p.target;if(Wl(b)||tn(b)){const v=tn(b)?b:b.defaultView;N=a?v.scrollX:v.scrollY,x=a?v.document.documentElement.scrollWidth:v.document.documentElement.scrollHeight,w=a?v.innerWidth:v.innerHeight}else N=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(N,0),viewportHeight:w})};p.suppressFlushSync?g():Yo.flushSync(g),l.current!==null&&(N===l.current||N<=0||N===x-w)&&(l.current=null,t(!0),d.current&&(clearTimeout(d.current),d.current=null))},[e,t,a]);X.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 N,b,g;tn(x)?(b=Math.max(Nt(x.document.documentElement,a?"width":"height"),a?x.document.documentElement.scrollWidth:x.document.documentElement.scrollHeight),N=a?x.innerWidth:x.innerHeight,g=a?window.scrollX:window.scrollY):(b=x[a?"scrollWidth":"scrollHeight"],N=Nt(x,a?"width":"height"),g=x[a?"scrollLeft":"scrollTop"]);const v=b-N;if(p.top=Math.ceil(Math.max(Math.min(v,p.top),0)),js(N,b)||p.top===g){e({scrollHeight:b,scrollTop:g,viewportHeight:N}),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 rn="-webkit-sticky",co="sticky",Bn=Rs(()=>{if(typeof document>"u")return co;const e=document.createElement("div");return e.style.position=rn,e.style.position===rn?rn:co});function zn(e){return e}const $l=xe(()=>{const e=F(l=>`Item ${l}`),t=F(l=>`Group ${l}`),r=F({}),o=F(zn),s=F("div"),a=F(Ut),i=(l,d=null)=>Be(L(r,G(c=>c[l]),be()),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")}}),Vl=xe(([e,t])=>({...e,...t}),we(As,$l)),Gl=({height:e})=>n.jsx("div",{style:{height:e}}),Ul={overflowAnchor:"none",position:Bn(),zIndex:1},Hs={overflowAnchor:"none"},Kl={...Hs,display:"inline-block",height:"100%"},uo=X.memo(function({showTopList:e=!1}){const t=ae("listState"),r=Xe("sizeRanges"),o=ae("useWindowScroll"),s=ae("customScrollParent"),a=Xe("windowScrollContainerState"),i=Xe("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=Xe("gap"),N=ae("horizontalDirection"),{callbackRef:b}=ll(r,p,u,e?Ut:l,x,w,s,N,ae("skipAnimationFrameInResizeObserver")),[g,v]=X.useState(0);Wn("deviation",E=>{g!==E&&v(E)});const I=ae("EmptyPlaceholder"),j=ae("ScrollSeekPlaceholder")||Gl,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",...N?{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&&I?n.jsx(I,{...Pe(I,c)}):n.jsx(S,{...Pe(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,{...Pe(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,{...Pe(h,c),"data-index":_,"data-item-index":E.index,"data-known-size":E.size,key:O,style:Ul},f(E.index,c)):m.createElement(R,{...Pe(R,c),...Xl(R,E.data),"data-index":_,"data-item-group-index":E.groupIndex,"data-item-index":E.index,"data-known-size":E.size,key:O,style:N?Kl:Hs},T?d(E.index,E.groupIndex,E.data,c):d(E.index,E.data,c))})})}),ql={height:"100%",outline:"none",overflowY:"auto",position:"relative",WebkitOverflowScrolling:"touch"},Yl={outline:"none",overflowX:"auto",position:"relative"},Vr=e=>({height:"100%",position:"absolute",top:0,width:"100%",...e?{display:"flex",flexDirection:"column"}:{}}),Zl={position:Bn(),top:0,width:"100%",zIndex:1};function Pe(e,t){if(typeof e!="string")return{context:t}}function Xl(e,t){return{item:typeof e=="string"?void 0:t}}const Jl=X.memo(function(){const e=ae("HeaderComponent"),t=Xe("headerHeight"),r=ae("HeaderFooterTag"),o=Ot(X.useMemo(()=>a=>{t(Nt(a,"height"))},[t]),!0,ae("skipAnimationFrameInResizeObserver")),s=ae("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Pe(e,s)})}):null}),Ql=X.memo(function(){const e=ae("FooterComponent"),t=Xe("footerHeight"),r=ae("HeaderFooterTag"),o=Ot(X.useMemo(()=>a=>{t(Nt(a,"height"))},[t]),!0,ae("skipAnimationFrameInResizeObserver")),s=ae("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Pe(e,s)})}):null});function Fs({useEmitter:e,useEmitterValue:t,usePublisher:r}){return X.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}=Os(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:ql,...s},tabIndex:0,...i,...Pe(d,a),children:o})})}function Ps({useEmitter:e,useEmitterValue:t,usePublisher:r}){return X.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=X.useRef(null),w=t("scrollerRef"),{scrollByCallback:N,scrollerRef:b,scrollToCallback:g}=Os(l,c,d,w,p);return Ls(()=>{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",N),n.jsx(d,{ref:x,"data-virtuoso-scroller":!0,style:{position:"relative",...s,...f!==0?{height:f+u}:{}},...i,...Pe(d,a),children:o})})}const ec=({children:e})=>{const t=X.useContext(Ms),r=Xe("viewportHeight"),o=Xe("fixedItemHeight"),s=ae("alignToBottom"),a=ae("horizontalDirection"),i=X.useMemo(()=>ds(r,d=>Nt(d,a?"width":"height")),[r,a]),l=Ot(i,!0,ae("skipAnimationFrameInResizeObserver"));return X.useEffect(()=>{t&&(r(t.viewportHeight),o(t.itemHeight))},[t,r,o]),n.jsx("div",{"data-viewport-type":"element",ref:l,style:Vr(s),children:e})},tc=({children:e})=>{const t=X.useContext(Ms),r=Xe("windowViewportRect"),o=Xe("fixedItemHeight"),s=ae("customScrollParent"),a=fs(r,s,ae("skipAnimationFrameInResizeObserver")),i=ae("alignToBottom");return X.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:Vr(i),children:e})},rc=({children:e})=>{const t=ae("TopItemListComponent")||"div",r=ae("headerHeight"),o={...Zl,marginTop:`${r}px`},s=ae("context");return n.jsx(t,{style:o,...Pe(t,s),children:e})},nc=X.memo(function(e){const t=ae("useWindowScroll"),r=ae("topItemsIndexes").length>0,o=ae("customScrollParent"),s=ae("context");return n.jsxs(o||t?ac:sc,{...e,context:s,children:[r&&n.jsx(rc,{children:n.jsx(uo,{showTopList:!0})}),n.jsxs(o||t?tc:ec,{children:[n.jsx(Jl,{}),n.jsx(uo,{}),n.jsx(Ql,{})]})]})}),{Component:oc,useEmitter:Wn,useEmitterValue:ae,usePublisher:Xe}=Ds(Vl,{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"}},nc),sc=Fs({useEmitter:Wn,useEmitterValue:ae,usePublisher:Xe}),ac=Ps({useEmitter:Wn,useEmitterValue:ae,usePublisher:Xe}),ic=oc,lc=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(zn),l=F(Ut),d=(c,f=null)=>Be(L(a,G(u=>u[c]),be()),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")}});we(As,lc);Bn();const fo={bottom:0,itemHeight:0,items:[],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},cc={bottom:0,itemHeight:0,items:[{index:0}],itemWidth:0,offsetBottom:0,offsetTop:0,top:0},{ceil:mo,floor:Or,max:er,min:nn,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 dc(e){return{...cc,items:e}}function wr(e,t){return e&&e.width===t.width&&e.height===t.height}function uc(e,t){return e&&e.column===t.column&&e.row===t.row}const fc=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:N},{customScrollParent:b,useWindowScroll:g,windowScrollContainerState:v,windowScrollTo:I,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),Q=F(!0),P=F(!1),$=F(!1);ve(L(w,de(V),se(([A,B])=>!!B)),()=>{le(Q,!1)}),ve(L(Ee(w,Q,T,k,V,P),se(([A,B,ne,ue,,ge])=>A&&!B&&ne.height!==0&&ue.height!==0&&!ge)),([,,,,A])=>{le(P,!0),On(1,()=>{le(D,A)}),tt(L(c),()=>{le(t,[0,0]),le(Q,!0)})}),J(L(H,se(A=>A!=null&&A.scrollTop>0),it(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),tt(L(c,_t(1)),B=>{le(z,!1)}),le(d,{top:A.scrollTop})))}),J(L(k,G(({height:A})=>A)),u),J(L(Ee(oe(k,wr),oe(T,wr),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),J(L(Ee(oe(R),o,oe(_,uc),oe(T,wr),oe(k,wr),oe(E),oe(h),oe(z),oe(Q),oe(V)),se(([,,,,,,,A])=>!A),G(([A,[B,ne],ue,ge,q,te,me,,pe,ce])=>{const{column:ie,row:Ie}=ue,{height:Ne,width:Qe}=ge,{width:st}=q;if(me===0&&(A===0||st===0))return fo;if(Qe===0){const Fe=Hn(ce,A),De=Fe+Math.max(me-1,0);return dc(ho(Fe,De,te))}const at=Bs(st,Qe,ie);let Ye,Ce;pe?B===0&&ne===0&&me>0?(Ye=0,Ce=me-1):(Ye=at*Or((B+Ie)/(Ne+Ie)),Ce=at*mo((ne+Ie)/(Ne+Ie))-1,Ce=nn(A-1,er(Ce,at-1)),Ye=nn(Ce,er(0,Ye))):(Ye=0,Ce=-1);const Z=ho(Ye,Ce,te),{bottom:je,top:Te}=go(q,ue,ge,Z),_e=mo(A/at),Le=_e*Ne+(_e-1)*Ie-je;return{bottom:je,itemHeight:Ne,items:Z,itemWidth:Qe,offsetBottom:Le,offsetTop:Te,top:Te}})),y),J(L(E,se(A=>A!==null),G(A=>A.length)),R),J(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]}),be(nr)),t);const W=F(!1);J(L(c,de(W),G(([A,B])=>B||A!==0)),W);const K=Ke(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),be())),U=Ke(L(oe(y),se(({items:A})=>A.length>0&&A[0].index===0),it(0),be())),Y=Ke(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})),be(vs),pt(0)));J(Y,x.scrollSeekRangeChanged),J(L(D,de(k,T,R,_),G(([A,B,ne,ue,ge])=>{const q=Ns(A),{align:te,behavior:me,offset:pe}=q;let ce=q.index;ce==="LAST"&&(ce=ue-1),ce=er(0,ce,nn(ue-1,ce));let ie=kn(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=Be(L(y,G(A=>A.offsetBottom+A.bottom)),0);return J(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:I,windowViewportRect:j,...x,gridState:y,horizontalDirection:$,initialTopMostItemIndex:V,totalListHeight:ee,...p,endReached:K,propsReady:N,rangeChanged:Y,startReached:U,stateChanged:O,stateRestoreInProgress:z,...S}},we(Fn,We,pr,Es,Ct,Pn,St));function Bs(e,t,r){return er(1,Or((e+r)/(Or(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=kn(e,t,r,o[0].index);return{bottom:kn(e,t,r,o[o.length-1].index)+s,top:a}}function kn(e,t,r,o){const s=Bs(e.width,r.width,t.column),a=Or(o/s),i=a*r.height+er(0,a-1)*t.row;return i>0?i+t.row:i}const mc=xe(()=>{const e=F(u=>`Item ${u}`),t=F({}),r=F(null),o=F("virtuoso-grid-item"),s=F("virtuoso-grid-list"),a=F(zn),i=F("div"),l=F(Ut),d=(u,p=null)=>Be(L(t,G(x=>x[u]),be()),p),c=F(!1),f=F(!1);return J(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")}}),pc=xe(([e,t])=>({...e,...t}),we(fc,mc)),hc=X.memo(function(){const e=ke("gridState"),t=ke("listClassName"),r=ke("itemClassName"),o=ke("itemContent"),s=ke("computeItemKey"),a=ke("isSeeking"),i=Je("scrollHeight"),l=ke("ItemComponent"),d=ke("ListComponent"),c=ke("ScrollSeekPlaceholder"),f=ke("context"),u=Je("itemDimensions"),p=Je("gap"),x=ke("log"),w=ke("stateRestoreInProgress"),N=Je("reportReadyState"),b=Ot(X.useMemo(()=>g=>{const v=g.parentElement.parentElement.scrollHeight;i(v);const I=g.firstChild;if(I){const{height:j,width:S}=I.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 Ls(()=>{e.itemHeight>0&&e.itemWidth>0&&N(!0)},[e]),w?null:n.jsx(d,{className:t,ref:b,...Pe(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,{...Pe(c,f),height:e.itemHeight,index:g.index,width:e.itemWidth},v):m.createElement(l,{...Pe(l,f),className:r,"data-index":g.index,key:v},o(g.index,g.data,f))})})}),gc=X.memo(function(){const e=ke("HeaderComponent"),t=Je("headerHeight"),r=ke("headerFooterTag"),o=Ot(X.useMemo(()=>a=>{t(Nt(a,"height"))},[t]),!0,!1),s=ke("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Pe(e,s)})}):null}),xc=X.memo(function(){const e=ke("FooterComponent"),t=Je("footerHeight"),r=ke("headerFooterTag"),o=Ot(X.useMemo(()=>a=>{t(Nt(a,"height"))},[t]),!0,!1),s=ke("context");return e?n.jsx(r,{ref:o,children:n.jsx(e,{...Pe(e,s)})}):null}),vc=({children:e})=>{const t=X.useContext(_s),r=Je("itemDimensions"),o=Je("viewportDimensions"),s=Ot(X.useMemo(()=>a=>{o(a.getBoundingClientRect())},[o]),!0,!1);return X.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:Vr(!1),children:e})},yc=({children:e})=>{const t=X.useContext(_s),r=Je("windowViewportRect"),o=Je("itemDimensions"),s=ke("customScrollParent"),a=fs(r,s,!1);return X.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:Vr(!1),children:e})},bc=X.memo(function({...e}){const t=ke("useWindowScroll"),r=ke("customScrollParent"),o=r||t?Ic:wc,s=r||t?yc:vc,a=ke("context");return n.jsx(o,{...e,...Pe(o,a),children:n.jsxs(s,{children:[n.jsx(gc,{}),n.jsx(hc,{}),n.jsx(xc,{})]})})}),{useEmitter:zs,useEmitterValue:ke,usePublisher:Je}=Ds(pc,{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"}},bc),wc=Fs({useEmitter:zs,useEmitterValue:ke,usePublisher:Je}),Ic=Ps({useEmitter:zs,useEmitterValue:ke,usePublisher:Je});function xo(e,t,r){return t!=="normal"&&!(t!=null&&t.endsWith("px"))&&r(`${e} was not resolved to pixel value correctly`,t,Ge.WARN),t==="normal"?0:parseInt(t??"0",10)}function lr(e){return e!=null&&typeof e=="object"&&"stack"in e&&typeof e.stack=="string"}function Hr({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(cr,{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 Nc=new Set(["step_failed","step_retrying","run_failed","workflow_failed"]),$n={appearance:"none",WebkitAppearance:"none",border:"none",background:"transparent"},Ws="workflow-dot-pulse 1.25s cubic-bezier(0, 0, 0.2, 1) infinite";function jc(e){return e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})+"."+e.getMilliseconds().toString().padStart(3,"0")}function kc(e){return e.split("_").map(t=>t.charAt(0).toUpperCase()+t.slice(1)).join(" ")}function Sc(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 Cc(e,t){var s;const r=new Map;if(e)for(const a of e){const i=dr(String(a.stepName));r.set(a.stepId,(i==null?void 0:i.shortName)??a.stepName)}const o=t!=null&&t.workflowName?((s=It(t.workflowName))==null?void 0:s.shortName)??t.workflowName:null;return{correlationNameMap:r,workflowName:o}}function Tc(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 Sn(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 Cn=36,Ec=20,on="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:Cn,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:on,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:Ws,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:Cn-9,height:2,backgroundColor:on,zIndex:0}})]}),l&&n.jsx("div",{style:{position:"absolute",left:Ec,top:f?0:d?"50%":0,bottom:f?0:c?"50%":0,width:2,backgroundColor:on,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:$n,"aria-label":`Copy ${e}`,children:r?n.jsx(Qo,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}):n.jsx(cr,{className:"h-3 w-3",style:{color:"var(--ds-gray-700)"}})}):null]})}function Tr(e){if(typeof e=="string"){const t=e.trim();if(t.startsWith("{")&&t.endsWith("}")||t.startsWith("[")&&t.endsWith("]")||t.startsWith('"')&&t.endsWith('"'))try{return Tr(JSON.parse(t))}catch{return e}return e}if(Array.isArray(e))return e.map(Tr);if(e!==null&&typeof e=="object"){if(e.constructor!==Object)return e;const t={};for(const[r,o]of Object.entries(e))t[r]=Tr(o);return t}return e}function Rc(e,t){if(!t||!Nc.has(t)||e==null||typeof e!="object")return null;const r=e;return lr(r.error)?r.error:lr(r)?r:null}function Ac({data:e,eventType:t}){const r=m.useMemo(()=>Rc(e,t),[e,t]),[o,s]=m.useState(!1),a=m.useRef(null),i=m.useMemo(()=>Tr(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(Hr,{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(Ar,{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:{...$n,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(cr,{className:"h-3 w-3"}),n.jsx("span",{children:"Copy"})]})})]})}function Dc({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,N]=m.useState(!1),[b,g]=m.useState(!1),[v,I]=m.useState(null),[j,S]=m.useState(null),[R,h]=m.useState(!1),y=e.correlationId??(Sn(e.eventType)?"__run__":void 0);m.useEffect(()=>{a!==void 0&&a!==y&&N(!1)},[a,y]);const k=Sc(e.eventType),T=new Date(e.createdAt),D="eventData"in e&&e.eventData!=null,M=Sn(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,Q=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&&I(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&&(I(null),h(!1),p(e).then(B=>{B!=null&&I(B),h(!0)}).catch(()=>{h(!0)}))},[x]);const U=m.useCallback(B=>{B.stopPropagation();const ne=!w;N(ne),ne&&v===null&&!D&&K()},[w,v,D,K]),Y=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:Y,onKeyDown:B=>{(B.key==="Enter"||B.key===" ")&&Y()},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:Q,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:{...$n,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:jc(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:Ws}}),n.jsx("span",{style:{position:"relative",width:6,height:6,borderRadius:"50%",backgroundColor:k}})]}),kc(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:Dt(_.queued)})]}),_.ran!==void 0&&n.jsxs("span",{children:["Ran for"," ",n.jsx("span",{className:"font-mono tabular-nums",children:Dt(_.ran)})]})]}),ee!=null?n.jsx(Ac,{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(He,{className:"h-3",style:{width:"75%"}}),n.jsx(He,{className:"h-3",style:{width:"50%"}}),n.jsx(He,{className:"h-3",style:{width:"60%"}})]}):n.jsx("div",{className:"p-2 text-xs",style:{color:"var(--ds-gray-900)"},children:"No data"})]})]})]})}function Mc({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(()=>Cc(t??null,r??null),[t,r]),u=m.useMemo(()=>Tc(d),[d]),[p,x]=m.useState(void 0),[w,N]=m.useState(void 0),b=m.useCallback(y=>{x(y)},[]),g=m.useCallback(y=>{N(y)},[]),v=p??w,I=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??(Sn(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:Cn}}),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(ic,{ref:R,totalCount:d.length,overscan:20,defaultItemHeight:40,endReached:()=>{!s||a||i==null||i()},itemContent:y=>n.jsx(Dc,{event:d[y],index:y,isFirst:y===0,isLast:y===d.length-1,activeGroupKey:v,selectedGroupKey:p,selectedGroupRange:I,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 _c({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(Lc,{message:t},r))})}function Lc({message:e}){const t=e.role,r=Fc(e.content),o=Hc(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(Oc,{part:s,role:t},a))})]})}function Oc({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(gi,{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(Ar,{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(Ar,{data:e.output,expandLevel:1})})]}):null}function Hc(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 Fc(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 Pc=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 $s({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(Pc(e)).then(()=>{he.success("Copied to clipboard")}).catch(()=>{he.error("Failed to copy")})},children:n.jsx(cr,{size:12})}),n.jsx(Ar,{data:e})]})}function ze({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 Bc({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 zc({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(Bc,{active:t===i.id,onClick:()=>r(i.id),children:i.label},i.id))}),n.jsx("div",{role:"tabpanel",children:s})]})}const Wc=[{id:"conversation",label:"Conversation"},{id:"json",label:"Raw JSON"}];function $c({conversation:e,args:t}){const[r,o]=m.useState("conversation");return n.jsx(ze,{summary:`Input (${e.length} messages)`,children:n.jsx(zc,{tabs:Wc,activeTab:r,onTabChange:o,ariaLabel:"Conversation view",children:r==="conversation"?n.jsx(_c,{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:$e(s)},a)):$e(t)})})})}function Kt(){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 $e(e){return n.jsx($s,{data:e})}const yt=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},Vc={workflowCoreVersion:"@workflow/core version"},Gc=e=>Vc[e]??e,Uc=e=>{const t=String(e),r=dr(t);if(r)return r.moduleSpecifier;const o=It(t);return o?o.moduleSpecifier:t},Vs=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},Gs=e=>e.toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}),Kc=e=>{const t=Vs(e);return t?Gs(t):"-"},Et=e=>{const t=Vs(e);return t?Gs(t):null},Zt={workflowName:e=>{var t;return((t=It(String(e)))==null?void 0:t.shortName)??"?"},moduleSpecifier:e=>Uc(e),stepName:e=>{var t;return((t=dr(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:Et,startedAt:Et,updatedAt:Et,completedAt:Et,expiredAt:Et,retryAfter:Et,resumeAt:Et,metadata:e=>yt(e)?lt(e)?n.jsx(Kt,{}):$e(e):null,input:(e,t)=>{if(lt(e))return n.jsx(Kt,{});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=yt(a),f=yt(i),u=yt(s);if(t!=null&&t.stepName&&vi(t.stepName)){const p=yi(s);if(p&&p.length>0)return n.jsxs(n.Fragment,{children:[n.jsx($c,{conversation:p,args:s}),c&&n.jsx(ze,{summary:"Closure Variables",children:$e(a)}),f&&n.jsx(ze,{summary:"This Value",children:$e(i)})]})}return!u&&!c&&!f?n.jsx(ze,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"}):n.jsxs(n.Fragment,{children:[n.jsx(ze,{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:$e(p)},x)):$e(s)}),c&&n.jsx(ze,{summary:"Closure Variables",children:$e(a)}),f&&n.jsx(ze,{summary:"this",children:$e(i)})]})}const r=Array.isArray(e)?e.length:0,o=r===1?"argument":"arguments";return yt(e)?n.jsx(ze,{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:$e(s)},a)):$e(e)}):n.jsx(ze,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"})},output:e=>yt(e)?lt(e)?n.jsx(Kt,{}):n.jsx(ze,{summary:"Output",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:$e(e)}):null,error:e=>lt(e)?n.jsx(Kt,{}):yt(e)?lr(e)?n.jsx(ze,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:n.jsx(Hr,{value:e})}):n.jsx(ze,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:$e(e)}):null,eventData:e=>lt(e)?n.jsx(Kt,{}):yt(e)?n.jsx(ze,{summary:"Event Data",children:$e(e)}):null},Io=["input","output","error","metadata","eventData"],qc=()=>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(ze,{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(He,{className:"h-4 w-[38%]"}),n.jsx(He,{className:"mt-2 h-4 w-[88%]"}),n.jsx(He,{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},Zc=({data:e,moduleSpecifier:t,isLoading:r,error:o,expiredAt:s,onStreamClick:a})=>{const i=m.useMemo(()=>{const w={...e},N=e.executionContext;return N!=null&&N.workflowCoreVersion&&(w.workflowCoreVersion=N.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=>!Io.includes(w)).sort(wo),c=Object.keys(i).filter(w=>Io.includes(w)).sort(wo),f=d.filter(w=>{const N=Zt[w];return N?N(i[w])!==null:!1}),u=m.useMemo(()=>{const w=[...f],N=w.indexOf("moduleSpecifier");if(N===-1)return w;w.splice(N,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(xi.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,N)=>{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??""),I=N<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:Gc(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})]}),I?n.jsx("div",{className:"mx-2.5 border-b",style:{borderColor:"var(--ds-gray-300)"}}):null]},w)})}),o?n.jsx(La,{title:"Failed to load resource details",details:o.message,className:"my-4"}):l?n.jsx(qc,{}):n.jsx(n.Fragment,{children:c.map(w=>n.jsx(Yc,{isLoading:r,attribute:w,value:i[w],context:p},w))})]})})},Xc=new Set(["step_failed","step_retrying"]),Jc=new Set(["step_created","step_completed","step_failed","hook_created","hook_received","run_created","run_completed"]);function Qc({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=Jc.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 N=new Date(e.createdAt);return n.jsxs(ze,{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:Kc(N.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(He,{className:"h-4 w-[35%]"}),n.jsx(He,{className:"mt-2 h-4 w-[90%]"}),n.jsx(He,{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(ed,{eventType:e.eventType,data:u})})]})}function ed({eventType:e,data:t}){if(Xc.has(e)&&t!=null&&typeof t=="object"){const r=t;if(lr(r.error))return n.jsx(Hr,{value:r.error});if(lr(r))return n.jsx(Hr,{value:r})}return n.jsx($s,{data:t})}function td({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(He,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(He,{className:"h-[48px] w-full rounded-lg border"}),n.jsx(He,{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(Qc,{event:i,onLoadEventData:o,encryptionKey:s},i.eventId))}):null]})}function rd(e){return e!==null&&typeof e=="object"&&"stepId"in e}function nd(e){return e!==null&&typeof e=="object"&&"runId"in e}function Ir(e){return e!==null&&typeof e=="object"&&"hookId"in e}function od({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,N]=m.useState(!1),[b,g]=m.useState(!1),[v,I]=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"&&rd(j)?{resource:"step",resourceId:j.stepId,runId:j.runId}:$==="run"&&nd(j)?{resource:"run",resourceId:j.runId,runId:void 0}:$==="hook"&&Ir(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(Ir(o)&&o.token)return o.token;const $=t==null?void 0:t.find(W=>W.hookId===y);if($!=null&&$.token)return $.token;if(Ir(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=Ir(W)?W:void 0;await c(E,$,K),he.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),N(!1),y&&I(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),Q=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:[Q&&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:Mt("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(Oa,{className:"h-4 w-4"}),p?"Waking up...":"Wake Up Sleep"]}),h==="hook"&&D&&n.jsxs("button",{type:"button",onClick:()=>N(!0),disabled:b,className:Mt("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(Zc,{data:H,moduleSpecifier:z,expiredAt:e.expiredAt,isLoading:C,error:M??void 0,onStreamClick:r})]}),h!=="run"&&S&&n.jsx("section",{children:n.jsx(td,{events:S,onLoadEventData:d,encryptionKey:f})})]})]}),n.jsx(ts,{isOpen:w,onClose:()=>N(!1),onSubmit:O,isSubmitting:b})]})}function sd(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 No(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 ad({scale:e,isLive:t=!1}){const{state:{root:r}}=ft(),[,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=No(50/a);l=Math.max(1,l);let d=l*a;const c=1e3;s/l>c&&(l=No(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:Mt(re.marker,!w&&re.notch),children:w?n.jsxs("span",{className:re.markerLabel,children:[bi(l*x),n.jsx("span",{className:re.markerClockTime,children:wi(r.startTime+l*x)})]}):null},String(x))})})})}function id({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:Mt(re.eventMarker),style:{left:Math.floor((s.timestamp-t.startTime)*r),...s.event.color&&{borderLeftColor:s.event.color}}},s.key))})})}const jo=2;function ld({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}=qr(u),w=m.useRef(null),N=m.useRef(null),{style:b,setStyle:g}=qr(N),v=m.useRef(void 0),I=m.useRef(null),{style:j,setStyle:S}=qr(I),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-Dr-Ve)/(zt+wt):0,Q=()=>{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 Ne,Qe,st,at,Ye,Ce,Z,je;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-Ve,r.duration*a)),ce=`${pe-te+Ve}px`;g("left",ce),x("left",ce);const ie=r.startTime+pe/a,Ie=ie-r.startTime;if(Ie<0||Ie>r.duration?(Ne=w.current)==null||Ne.removeAttribute("data-text"):(Qe=w.current)==null||Qe.setAttribute("data-text",yr(Ie)),D){const Te=k-T,_e=Math.abs(Te);if(!C){if(_e<4)return;C=!0,S("display","flex"),Q()}Te>0?(S("left",""),S("right","0")):(S("left","0"),S("right","")),S("width",`${_e}px`);const Fe=Math.max(0,Math.min(T+te-q.left-Ve,r.duration*a))/a;let De,et;Fe<Ie?(De=Fe,et=Ie):(De=Ie,et=Fe),(st=I.current)==null||st.setAttribute("data-range",`${yr(De)} — ${yr(et)}`),(at=I.current)==null||at.setAttribute("data-duration",`${yr(et-De)} selected`)}if(Date.now()<H){P=requestAnimationFrame($);return}if(te!==_||me!==O){_=te,O=me,P=requestAnimationFrame($);return}if(k-q.left<128?(Ye=w.current)==null||Ye.setAttribute("data-align","left"):k-q.left>q.width-128?(Ce=w.current)==null||Ce.setAttribute("data-align","right"):(Z=w.current)==null||Z.removeAttribute("data-align"),!C&&!M){const Te=e.current,_e=V(me)-jo,Le=V(me+q.height)+jo;for(const Me of c.current){const Ze=Me.row>=_e&&Me.row<=Le&&ie>=Me.startTime&&ie<=Me.endTime;Me.isHovered!==Ze&&(Me.isHovered=Ze,Te.set(Me.span.spanId,{}))}const De=12/a;let et=null,vt=1/0;for(const Me of f.current){const Ze=Math.abs(Me.timestamp-ie);Ze<=De&&Ze<vt&&(vt=Ze,et=Me)}for(const Me of f.current){const Ze=Me===et;if(Me.isHovered===Ze)continue;Me.isHovered=Ze;const qn=(je=Me.ref)==null?void 0:je.current;qn&&qn.setAttribute("data-hovered",String(Ze))}i({type:"forceRender"})}};P=requestAnimationFrame($);const W=q=>{q.pointerType==="mouse"&&(d.current=!0)},K=()=>{d.current&&(d.current=!1,Q())},U=({clientX:q})=>{k=q,R.current=k,cancelAnimationFrame(P),P=requestAnimationFrame($)},Y=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(Q))},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-Ve)/a,r.duration)),ce=Math.max(0,Math.min((k+me-te.left-Ve)/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",Y),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",Y),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,Q()}},[i,r,a,g,x,S,e,t,l]);const h=m.useRef(void 0);return sd(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-Ve,T.width-2*Ve));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:N,style:b,children:n.jsx("div",{className:re.cursorMarker,children:n.jsx("div",{className:re.cursorSelection,ref:I,style:j})})})})]})}function cd({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(dd,{})}),n.jsx("input",{type:"search",value:r,placeholder:o,onChange:s,style:{height:e,width:t}})]})}function dd(){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 ud(){return n.jsx("nav",{className:re.searchBar,children:n.jsx(fd,{})})}function fd(){const{dispatch:e}=ft(),[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(cd,{height:as,onChange:o=>r(o.target.value),placeholder:"Search spans…",value:t,width:"100%"})})}function md({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 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 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 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:"Minus"}),n.jsx("path",{d:"M6 12h12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function gd(){const{dispatch:e}=ft(),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(pd,{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(hd,{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(md,{size:18})})]})}const xd=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=Yt(u.startTime),x=Yt(u.endTime),w=Yt(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 N=u.resource.startsWith("vercel.");N||(i=!0);const b=N&&(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:vd(u),isVercel:b,children:[],resourceIndex:g,activeStartTime:u.activeStartTime?Yt(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,N=w(u),b=`instrumentation-hint-${c++}`,g=u.duration*.05,v=u.startTime+g,I=Math.max(v+g,Math.min(x-u.duration*.01,u.endTime-g)),j=I-v,S={parent:N,startTime:v,endTime:I,duration:j,span:{spanId:b,name:"Add your spans here",resource:"",kind:0,library:{name:""},status:{code:200},traceFlags:0,attributes:{},links:[],events:[],startTime:Yr(v),endTime:Yr(I),duration:Yr(j)},depth:u.depth+1,isVercel:!1,isInstrumentationHint:!0,children:[],resourceIndex:1};return N.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}},vd=e=>{if(!e.events.length)return;const t=`${e.spanId}:ev`;return e.events.map((r,o)=>({key:`${t}${o}`,timestamp:Yt(r.timestamp),event:r})).sort((r,o)=>r.timestamp-o.timestamp)},ko=(e,t)=>(e.isVisible=!0,e.isHovered=!1,e.isVisible);function sn(){return[]}const yd=(e,t=!1)=>{const{state:r,dispatch:o}=ft(),{root:s,filter:a,scale:i,timelineRef:l,timelineWidth:d,spanMap:c,scrollSnapshotRef:f,selected:u,memoCacheRef:p}=r,x=bd(r.timelineHeight),w=m.useRef(0),[N,b]=m.useState(sn),[g,v]=m.useState(sn),[I,j]=m.useState(sn),[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 N)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"})}},[N,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(!N.length)return;if(t){const U=[],Y=[];for(const ee of N)for(const A of ee)ko(A)&&(U.push(A),A.events&&Y.push(...A.events));v(U),j(Y),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(N.length).fill(null),O=()=>{D=!0;const U=Math.min(1+C+Math.ceil((k==null?void 0:k.endRow)??Number.POSITIVE_INFINITY),N.length);for(let Y=U;Y--;){if(_[Y])continue;const ee=H(Y);if(Math.abs(ee)>C){if(D=!1,ee>0)continue;break}const A=[],B=N[Y];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})}_[Y]=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 Y=0;U.endTime<k.startTime?Y=k.startTime-U.endTime:U.startTime>k.endTime&&(Y=U.startTime-k.endTime);const ee=Math.abs(H(U.row));return!Y&&!ee?0:Math.sqrt((Y/i)**2+(ee*zt+wt)**2)},V=()=>{if(!y)return;const{scrollLeft:U,scrollTop:Y}=y,ee=0,A=U/i,B=(Y-Dr-Ve)/(zt+wt),ne=B+Math.ceil(x/(zt+wt));k={anchorT:A,anchorX:ee,scrollLeft:U,scrollTop:Y,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 Q=0;const P=()=>{(T||!k)&&(T=!1,V()),O();const U=[],Y=[];for(const ee of _)if(ee)for(const{d:A,span:B}of ee)A>C||(U.push(B),B.events&&Y.push(...B.events));C<E&&(!D||C<M)&&(C=Math.min(E,C+100),Q=requestAnimationFrame(P)),v(U),j(Y),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(Q),Q=requestAnimationFrame(P))};return y==null||y.addEventListener("scroll",K),()=>{cancelAnimationFrame(Q),y==null||y.removeEventListener("wheel",W),y==null||y.removeEventListener("scroll",K)}},[N,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:N,spans:g,events:I,scale:S}};function bd(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 wd({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}=ft(),{timelineRef:u,scrollSnapshotRef:p}=c,x=c.memoCacheRef.current,w=((a==null?void 0:a.length)??0)>0,N=m.useRef(!1),b=m.useRef(""),g=m.useRef(null),v=m.useRef({}),I=m.useRef(null);m.useEffect(()=>{const{root:C,map:E}=xd(e),_=!N.current;N.current=!0;const O=Object.keys(E).sort().map(H=>{const z=E[H].events,V=(z==null?void 0:z.length)??0,Q=V?z==null?void 0:z[0]:void 0,P=V?z==null?void 0:z[V-1]:void 0,$=`${(Q==null?void 0:Q.event.name)??"none"}@${(Q==null?void 0:Q.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[Q,P]of Object.entries(E)){const $=z[Q];$&&(($.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}=yd(a,i),y=m.useRef(null);m.useLayoutEffect(()=>{const C=y.current;if(!C)return;const E=()=>{const O=2*Ve,H=C.getBoundingClientRect(),z=H.width-O,V=H.height,Q=I.current;Q&&Q.width===z&&Q.height===V||(I.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 Q=V.closest("[data-span-id]"),P=(Q==null?void 0:Q.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,Dr+wt+j.length*(zt+wt)-wt+84),M=!!(c.isMobile&&c.selected);return n.jsxs("div",{className:Mt(re.traceViewer,d&&re.skeleton,t),onClickCapture:T,ref:y,style:{height:o,"--timeline-padding":`${Ve}px`,"--row-height":`${zt}px`,"--row-padding":`${wt}px`,"--search-height":`${w?0:as}px`,"--search-gap":`${w?2:ji}px`,"--map-height":`${Ni}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":`${Dr}px`,"--marker-notch-height":`${Ii}px`},children:[w?null:n.jsx(ud,{}),n.jsx(ki,{rows:j,scale:h,timelineRef:u}),n.jsxs("div",{className:Mt(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-Ve*2,padding:Ve,paddingBottom:0},children:n.jsxs("div",{className:re.traceNode,style:{width:c.root.duration*h||void 0,height:D-Ve*2},children:[n.jsx(ad,{scale:h,isLive:l}),n.jsx(id,{events:R,root:c.root,scale:h}),n.jsx(ld,{dispatch:f,events:R,memoCacheRef:c.memoCacheRef,root:c.root,scale:h,scrollSnapshotRef:p,spans:S,timelineRef:u}),n.jsx(Si,{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(gd,{})})]}),s?n.jsx("div",{className:Mt(re.spanDetailPanelTraceViewer,!c.selected&&re.hidden,c.isMobile&&re.mobile),children:n.jsx(Ci,{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 Nd=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:""},jd=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 kd(e){return e==="hook_created"||e==="hook_received"||e==="hook_disposed"}function rt(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 Gr(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 hr={name:"workflow-development-kit",version:"4.0.0"},Sd=new Set(["hook_created","hook_received","hook_disposed","step_started","step_retrying","step_failed","run_failed","wait_created","wait_completed"]);function Ur(e,t=!0){return e.filter(r=>t?Sd.has(r.eventType):!0).map(r=>({name:r.eventType,timestamp:rt(r.createdAt),attributes:{eventId:r.eventId,correlationId:r.correlationId,eventData:"eventData"in r?r.eventData:void 0},showVerticalLine:kd(r.eventType)}))}const Us=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 Cd(e,t,r){const o=Us(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=rt(a),d=rt(i),c=Gr(a,i),f=Ur(e,!1);return{spanId:o.waitId,name:"sleep",kind:1,resource:"sleep",library:hr,status:{code:0},traceFlags:1,attributes:{resource:"sleep",data:o},links:[],events:f,duration:c,startTime:l,endTime:d}}function Td(e,t,r,o){const s=r??new Date,a=dr(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=Ur(t,!1),w=new Date(e.createdAt);let N=e.startedAt?new Date(e.startedAt):void 0;const b=t.find(g=>g.eventType==="step_started");return b&&(N=new Date(b.createdAt)),{spanId:String(e.stepId),name:(a==null?void 0:a.shortName)??"",kind:1,resource:u,library:hr,status:{code:0},traceFlags:1,attributes:f,links:[],events:x,startTime:rt(w),endTime:rt(p),duration:Gr(w,p),activeStartTime:N&&N.getTime()>w.getTime()?rt(N):void 0}}const Ed=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 Rd(e,t,r){const o=Ed(e);if(!o)return null;const s=Ur(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:hr,status:{code:1},traceFlags:1,attributes:{resource:"hook",data:o},links:[],events:s,startTime:rt(o.createdAt),endTime:rt(i),duration:Gr(o.createdAt,i)}}function Ad(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=Ur(t,!1);return{spanId:String(e.runId),name:String(((x=It(e.workflowName))==null?void 0:x.shortName)??"?"),kind:1,resource:"run",library:hr,status:{code:0},traceFlags:1,attributes:d,links:[],events:p,startTime:rt(c),endTime:rt(u),duration:Gr(c,u),activeStartTime:f&&f.getTime()>c.getTime()?rt(f):void 0}}function Dd(e){const{state:t,dispatch:r}=ft(),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 Md=450,_d=240;function Ld({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:Zo.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 Od({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}=ft();Dd(o);const[x,w]=m.useState(null),[N,b]=m.useState(null),[g,v]=m.useState(!1),[I,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||!N||!i)){if(!N.token){he.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{v(!0),await i(N.token,C,N),he.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),j(E=>new Set(E).add(N.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,N,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,Q=!(V!=null&&V.completedAt)&&!(V!=null&&V.disposedAt);w({x:C.clientX,y:C.clientY,spanId:O,spanName:H.name,resourceType:z,isActive:Q})},[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(Pa,{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),Q=(O=V==null?void 0:V.attributes)==null?void 0:O.data,P=!!(Q!=null&&Q.disposedAt)||!!((H=V==null?void 0:V.events)!=null&&H.some($=>$.name==="hook_disposed"))||I.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(Ba,{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(Ui,{className:"h-3.5 w-3.5"}),action:()=>{p({type:"select",id:C.spanId})}}),E.push({label:"Copy Name",icon:n.jsx(Xi,{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(cr,{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,I,t.runId,t.completedAt]);return n.jsxs("div",{className:"relative w-full h-full",ref:k,children:[f,x?n.jsx(Ld,{menu:x,items:M(x),onClose:D}):null,n.jsx(ts,{isOpen:N!==null,onClose:()=>b(null),onSubmit:h,isSubmitting:g})]})}const Hd=e=>e==="wait_created"||e==="wait_completed",Fd=e=>e==="hook_received"||e==="hook_created"||e==="hook_disposed",Nr=(e,t,r)=>{const o=e.get(t);if(o){o.push(r);return}e.set(t,[r])},Pd=(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(Hd(f.eventType)){Nr(i,u,f);continue}if(Fd(f.eventType)){Nr(l,u,f);continue}if(d.has(u)){Nr(o,u,f);continue}if(c.has(u)){Nr(s,u,f);continue}a.push(f)}return{eventsByStepId:o,eventsByHookId:s,runLevelEvents:a,timerEvents:i,hookEvents:l}},Bd=(e,t,r,o)=>{const s=new Date(e.completedAt||o),a=t.map(d=>{const c=r.eventsByStepId.get(d.stepId)||[];return Td(d,c,o,s)}),i=Array.from(r.hookEvents.values()).map(d=>Rd(d,e,o)).filter(d=>d!==null),l=Array.from(r.timerEvents.values()).map(d=>Cd(d,e,o)).filter(d=>d!==null);return{runSpan:Ad(e,r.runLevelEvents,o),spans:[...a,...i,...l]}},zd=(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}})},Wd=(e,t,r,o,s)=>{const a=Pd(o,t,r),{runSpan:i,spans:l}=Bd(e,t,a,s),d=zd(i,l);return{traceId:e.runId,rootSpanId:e.runId,spans:d,resources:[{name:"workflow",attributes:{"service.name":hr.name}}]}};function $d({onSelectionChange:e}){const{state:t}=ft(),{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 Vd({triggerDeselect:e}){const{dispatch:t}=ft();return m.useEffect(()=>{e>0&&t({type:"deselect"})},[e,t]),null}function Gd({selectRequest:e}){const{dispatch:t}=ft();return m.useEffect(()=>{e!=null&&e.id&&t({type:"select",id:e.id})},[t,e]),null}function Ud({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 Kd=({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:N,hasMoreSpans:b=!1,isLoadingMoreSpans:g=!1,encryptionKey:v})=>{const[I,j]=m.useState(null),[S,R]=m.useState(Md),[h,y]=m.useState(0),[k,T]=m.useState(null),D=!!(e&&!e.completedAt),M=m.useMemo(()=>{if(e)return Wd(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(Y=>Y.correlationId===K):[];j({...W,rawEvents:U})}else j(null)},[o]);m.useEffect(()=>{const W=I==null?void 0:I.spanId;if(!W)return;const K=o.filter(U=>U.correlationId===W);j(U=>{if(!U||U.spanId!==W)return U;const Y=U.rawEvents??[];return Y.length===K.length&&Y.every((A,B)=>{var ne;return A.eventId===((ne=K[B])==null?void 0:ne.eventId)})?U:{...U,rawEvents:K}})},[o,I==null?void 0:I.spanId]);const _=m.useCallback(()=>{j(null),y(W=>W+1)},[]),O=m.useCallback(W=>{R(K=>Math.max(_d,K+W))},[]),H=m.useMemo(()=>!(I!=null&&I.spanId)||!M?-1:M.spans.findIndex(W=>W.spanId===I.spanId),[I==null?void 0:I.spanId,M]),z=H>0,V=H>=0&&M!=null&&H<M.spans.length-1,Q=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 Y,ee;if(!(I!=null&&I.data))return;const W=I.data,K=W.stepName,U=W.workflowName;return(K?(Y=dr(K))==null?void 0:Y.shortName:void 0)??(U?(ee=It(U))==null?void 0:ee.shortName:void 0)??K??U??W.hookId??"Details"},[I==null?void 0:I.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(He,{className:"w-full ml-2 mt-1 mb-1 h-[56px]"}),n.jsxs("div",{className:"p-2 relative w-full",children:[n.jsx(He,{className:"w-full mt-6 h-[20px]"}),n.jsx(He,{className:"w-[10%] mt-2 ml-6 h-[20px]"}),n.jsx(He,{className:"w-[10%] mt-2 ml-12 h-[20px]"}),n.jsx(He,{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(Ti,{customSpanClassNameFunc:Nd,customSpanEventClassNameFunc:jd,children:[n.jsx($d,{onSelectionChange:E}),n.jsx(Vd,{triggerDeselect:h}),n.jsx(Gd,{selectRequest:k}),n.jsx(Od,{trace:M,run:e,hooks:r,isLive:D,onWakeUpSleep:c,onCancelRun:u,onResolveHook:f,onLoadMoreSpans:N,hasMoreSpans:b,isLoadingMoreSpans:g,children:n.jsx(wd,{eagerRender:!0,height:"100%",isLive:D,trace:M})})]})}),I&&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(Ud,{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:Q,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(Ha,{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(Fa,{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(Bt,{title:"Failed to load entity details",children:n.jsx(od,{run:e,hooks:r,onStreamClick:p,spanDetailData:i??null,spanDetailError:d,spanDetailLoading:l,onSpanSelect:C,onWakeUpSleep:c,onLoadEventData:w,onResolveHook:f,encryptionKey:v,selectedSpan:I})})})]})]})};async function qd(e,t,r,o={}){const s=o.resolveData??"all";let a,i;if(t==="run")a=await jr(gn(e,r,s)),i=a.runId;else if(t==="step"){const{runId:l}=o;if(!l)throw new Rt("runId is required for step resource",{layer:"client"});a=await jr(Ei(e,l,r,s)),i=a.stepId}else if(t==="hook")a=await jr(is(e,r,s)),i=a.hookId;else throw new Rt(`Unknown resource type: ${t}`,{layer:"client"});return{data:a,correlationId:i}}function Ks(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?kr(b,l):Oe(b),[l]),N=m.useCallback(async()=>{if(!i){u(!1);return}if(c(null),x(null),t==="hook"){const{error:b,result:g}=await Re(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 Re(Mr(e,r,{sortOrder:"asc",limit:100,withData:!0}));if(b){x(b);return}try{const v=await Promise.all(g.data.map(w)),I=Us(v);if(I===null){x(new Error(`Failed to load ${t} details: missing required event data`));return}c(I)}catch(v){x(v instanceof Error?v:new Error(String(v)))}return}u(!0);try{const{data:b}=await qd(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(()=>{N()},[N]),m.useEffect(()=>{if(!s||s<=0)return;const b=setInterval(N,s);return()=>clearInterval(b)},[s,N]),{data:d,loading:f,error:p,refresh:N}}const Yd=1e3;function Xt(e,t,r){const o=[...e,...t],s=new Map(o.map(a=>[a[r],a]));return Array.from(s.values())}async function an(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=>Xt(p,f,a)),(i==="onHasMore"?!!(c.cursor&&c.hasMore):!!c.cursor)&&o(c.cursor),!0}return!1}const ln=10,Ft=50,Zd=2e3,Xd=5e3;async function Jd(e,t){let r=[],o;for(;;){const{error:s,result:a}=await Re(Mr(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=>Jd(e,o)))).flat()}function Qd(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,N]=m.useState(!1),[b,g]=m.useState(null),[v,I]=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),N(!0),g(null);const[Y,ee,A,B]=await Promise.all([Re(gn(e,t,"none")),Re(Zr(e,t,{sortOrder:"asc",limit:Ft})),Re(Xr(e,{runId:t,sortOrder:"asc",limit:Ft})),Re(Jt(e,t,{sortOrder:"asc",limit:Ft}))]);Y.error?g(Y.error):a(Oe(Y.result));const ne=ee.error?[]:ee.result.data.map(Oe),ue=A.error?[]:A.result.data.map(Oe),ge=B.error?[]:B.result.data.map(Oe),q=[...ne.map(ie=>ie.stepId),...ue.map(ie=>ie.hookId)],me=(await Eo(e,q)).map(Oe);l(ne),c(ue),u(Xt([],[...ge,...me],"eventId")),I(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=[Y,ee,A,B];if(x(!1),N(!1),z(!0),O.current=!1,!Y.error){const ie=(ce=pe.find(Ie=>Ie.error))==null?void 0:ce.error;ie&&g(ie)}},[e,t]),Q=m.useCallback(async()=>{var Y,ee,A,B,ne,ue;if(!(O.current||!H||E)&&!(!y&&!T&&!M)){_(!0);try{const[ge,q,te]=await Promise.all([y?Re(Zr(e,t,{cursor:v,sortOrder:"asc",limit:Ft})):Promise.resolve({error:null,result:null}),T?Re(Xr(e,{runId:t,cursor:j,sortOrder:"asc",limit:Ft})):Promise.resolve({error:null,result:null}),M?Re(Jt(e,t,{cursor:R,sortOrder:"asc",limit:Ft})):Promise.resolve({error:null,result:null})]);ge.error&&g(ge.error),q.error&&g(q.error),te.error&&g(te.error);const me=((Y=ge.result)==null?void 0:Y.data.map(Oe))??[],pe=((ee=q.result)==null?void 0:ee.data.map(Oe))??[],ce=((A=te.result)==null?void 0:A.data.map(Oe))??[];me.length>0&&l(Ce=>Xt(Ce,me,"stepId")),pe.length>0&&c(Ce=>Xt(Ce,pe,"hookId"));const ie=[...me.map(Ce=>Ce.stepId),...pe.map(Ce=>Ce.hookId)],Ne=(await Eo(e,ie)).map(Oe),Qe=[...ce,...Ne];Qe.length>0&&u(Ce=>Xt(Ce,Qe,"eventId"));const st=ge.error?y:!!(ge.result&&ge.result.hasMore),at=q.error?T:!!(q.result&&q.result.hasMore),Ye=te.error?M:!!(te.result&&te.result.hasMore);k(st),D(at),C(Ye),ge.error||I((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:Y,result:ee}=await Re(gn(e,t,"none"));return Y?(g(Y),!1):(g(null),a(Oe(ee)),!0)},[e,t,s==null?void 0:s.completedAt]),$=m.useCallback(()=>an({fetchFn:()=>Re(Zr(e,t,{cursor:v,sortOrder:"asc",limit:ln})),setItems:l,setCursor:I,setError:g,idKey:"stepId",cursorStrategy:"onHasMore",transform:Oe}),[e,t,v]),W=m.useCallback(()=>an({fetchFn:()=>Re(Xr(e,{runId:t,cursor:j,sortOrder:"asc",limit:ln})),setItems:c,setCursor:S,setError:g,idKey:"hookId",transform:Oe}),[e,t,j]),K=m.useCallback(()=>an({fetchFn:()=>Re(Jt(e,t,{cursor:R,sortOrder:"asc",limit:ln})),setItems:u,setCursor:h,setError:g,idKey:"eventId",transform:Oe}),[e,t,R]),U=m.useCallback(async(Y=!1)=>{if(O.current||!H)return{foundNewItems:!1};let ee=!1;try{const[A,B,ne,ue]=await Promise.all([Y?Promise.resolve(!1):P(),$(),Y?Promise.resolve(!1):W(),Y?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 Y=setInterval(()=>{U()},Xd),ee=setInterval(()=>{U(!0)},Zd);return()=>{clearInterval(Y),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:Q,hasMoreTraceData:y||T||M,isLoadingMoreTraceData:E}}function eu(e){return typeof e=="object"&&e!==null&&"message"in e&&"layer"in e&&"cause"in e&&"request"in e}async function tu(e,t,r,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&&eu(i)?new Rt(i.message,{layer:"client",cause:i.cause,request:i.request}):new Rt(`Failed to read stream: ${a.status}`,{layer:"client"})}if(!a.body)throw new Rt("Failed to read stream: no body",{layer:"client"});return a.body}catch(s){throw s instanceof Rt?s:new Rt("Failed to read stream",{layer:"client",cause:s})}}async function ru(e,t){return jr(Ri(e,t))}const nu=1e4;function ou(e,t,r=nu){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 ru(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 su=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],gt=su.reduce((e,t)=>{const r=m.forwardRef((o,s)=>{const{asChild:a,...i}=o,l=a?Rn: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 au(e,t){e&&Zo.flushSync(()=>e.dispatchEvent(t))}var iu="DismissableLayer",Tn="dismissableLayer.update",lu="dismissableLayer.pointerDownOutside",cu="dismissableLayer.focusOutside",Ro,qs=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(qs),[f,u]=m.useState(null),p=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,x]=m.useState({}),w=jt(t,h=>u(h)),N=Array.from(c.layers),[b]=[...c.layersWithOutsidePointerEventsDisabled].slice(-1),g=N.indexOf(b),v=f?N.indexOf(f):-1,I=c.layersWithOutsidePointerEventsDisabled.size>0,j=v>=g,S=fu(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=mu(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 za(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(Tn,h),()=>document.removeEventListener(Tn,h)},[]),n.jsx(gt.div,{...d,ref:w,style:{pointerEvents:I?j?"auto":"none":void 0,...e.style},onFocusCapture:ht(e.onFocusCapture,R.onFocusCapture),onBlurCapture:ht(e.onBlurCapture,R.onBlurCapture),onPointerDownCapture:ht(e.onPointerDownCapture,S.onPointerDownCapture)})});Ys.displayName=iu;var du="DismissableLayerBranch",uu=m.forwardRef((e,t)=>{const r=m.useContext(qs),o=m.useRef(null),s=jt(t,o);return m.useEffect(()=>{const a=o.current;if(a)return r.branches.add(a),()=>{r.branches.delete(a)}},[r.branches]),n.jsx(gt.div,{...e,ref:s})});uu.displayName=du;function fu(e,t=globalThis==null?void 0:globalThis.document){const r=Er(e),o=m.useRef(!1),s=m.useRef(()=>{});return m.useEffect(()=>{const a=l=>{if(l.target&&!o.current){let d=function(){Zs(lu,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 mu(e,t=globalThis==null?void 0:globalThis.document){const r=Er(e),o=m.useRef(!1);return m.useEffect(()=>{const s=a=>{a.target&&!o.current&&Zs(cu,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(Tn);document.dispatchEvent(e)}function Zs(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?au(s,a):s.dispatchEvent(a)}var cn="focusScope.autoFocusOnMount",dn="focusScope.autoFocusOnUnmount",Do={bubbles:!1,cancelable:!0},pu="FocusScope",Xs=m.forwardRef((e,t)=>{const{loop:r=!1,trapped:o=!1,onMountAutoFocus:s,onUnmountAutoFocus:a,...i}=e,[l,d]=m.useState(null),c=Er(s),f=Er(a),u=m.useRef(null),p=jt(t,N=>d(N)),x=m.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;m.useEffect(()=>{if(o){let N=function(I){if(x.paused||!l)return;const j=I.target;l.contains(j)?u.current=j:bt(u.current,{select:!0})},b=function(I){if(x.paused||!l)return;const j=I.relatedTarget;j!==null&&(l.contains(j)||bt(u.current,{select:!0}))},g=function(I){if(document.activeElement===document.body)for(const S of I)S.removedNodes.length>0&&bt(l)};document.addEventListener("focusin",N),document.addEventListener("focusout",b);const v=new MutationObserver(g);return l&&v.observe(l,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",N),document.removeEventListener("focusout",b),v.disconnect()}}},[o,l,x.paused]),m.useEffect(()=>{if(l){_o.add(x);const N=document.activeElement;if(!l.contains(N)){const g=new CustomEvent(cn,Do);l.addEventListener(cn,c),l.dispatchEvent(g),g.defaultPrevented||(hu(bu(Js(l)),{select:!0}),document.activeElement===N&&bt(l))}return()=>{l.removeEventListener(cn,c),setTimeout(()=>{const g=new CustomEvent(dn,Do);l.addEventListener(dn,f),l.dispatchEvent(g),g.defaultPrevented||bt(N??document.body,{select:!0}),l.removeEventListener(dn,f),_o.remove(x)},0)}}},[l,c,f,x]);const w=m.useCallback(N=>{if(!r&&!o||x.paused)return;const b=N.key==="Tab"&&!N.altKey&&!N.ctrlKey&&!N.metaKey,g=document.activeElement;if(b&&g){const v=N.currentTarget,[I,j]=gu(v);I&&j?!N.shiftKey&&g===j?(N.preventDefault(),r&&bt(I,{select:!0})):N.shiftKey&&g===I&&(N.preventDefault(),r&&bt(j,{select:!0})):g===v&&N.preventDefault()}},[r,o,x.paused]);return n.jsx(gt.div,{tabIndex:-1,...i,ref:p,onKeyDown:w})});Xs.displayName=pu;function hu(e,{select:t=!1}={}){const r=document.activeElement;for(const o of e)if(bt(o,{select:t}),document.activeElement!==r)return}function gu(e){const t=Js(e),r=Mo(t,e),o=Mo(t.reverse(),e);return[r,o]}function Js(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(!xu(r,{upTo:t}))return r}function xu(e,{upTo:t}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(t!==void 0&&e===t)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function vu(e){return e instanceof HTMLInputElement&&"select"in e}function bt(e,{select:t=!1}={}){if(e&&e.focus){const r=document.activeElement;e.focus({preventScroll:!0}),e!==r&&vu(e)&&t&&e.select()}}var _o=yu();function yu(){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 bu(e){return e.filter(t=>t.tagName!=="A")}var wu="Portal",Qs=m.forwardRef((e,t)=>{var l;const{container:r,...o}=e,[s,a]=m.useState(!1);Wa(()=>a(!0),[]);const i=r||s&&((l=globalThis==null?void 0:globalThis.document)==null?void 0:l.body);return i?Yo.createPortal(n.jsx(gt.div,{...o,ref:t}),i):null});Qs.displayName=wu;var Vn="Dialog",[ea,ta]=ns(Vn),[Iu,ot]=ea(Vn),ra=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]=Va({prop:o,defaultProp:s,onChange:a});return n.jsx(Iu,{scope:t,triggerRef:l,contentRef:d,contentId:Kr(),titleId:Kr(),descriptionId:Kr(),open:c,onOpenChange:f,onOpenToggle:m.useCallback(()=>f(u=>!u),[f]),modal:i,children:r})};ra.displayName=Vn;var na="DialogTrigger",oa=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=ot(na,r),a=jt(t,s.triggerRef);return n.jsx(gt.button,{type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":Kn(s.open),...o,ref:a,onClick:ht(e.onClick,s.onOpenToggle)})});oa.displayName=na;var Gn="DialogPortal",[Nu,sa]=ea(Gn,{forceMount:void 0}),aa=e=>{const{__scopeDialog:t,forceMount:r,children:o,container:s}=e,a=ot(Gn,t);return n.jsx(Nu,{scope:t,forceMount:r,children:m.Children.map(o,i=>n.jsx(En,{present:r||a.open,children:n.jsx(Qs,{asChild:!0,container:s,children:i})}))})};aa.displayName=Gn;var Fr="DialogOverlay",ia=m.forwardRef((e,t)=>{const r=sa(Fr,e.__scopeDialog),{forceMount:o=r.forceMount,...s}=e,a=ot(Fr,e.__scopeDialog);return a.modal?n.jsx(En,{present:o||a.open,children:n.jsx(ju,{...s,ref:t})}):null});ia.displayName=Fr;var ju=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=ot(Fr,r);return n.jsx(Ua,{as:Rn,allowPinchZoom:!0,shards:[s.contentRef],children:n.jsx(gt.div,{"data-state":Kn(s.open),...o,ref:t,style:{pointerEvents:"auto",...o.style}})})}),Lt="DialogContent",la=m.forwardRef((e,t)=>{const r=sa(Lt,e.__scopeDialog),{forceMount:o=r.forceMount,...s}=e,a=ot(Lt,e.__scopeDialog);return n.jsx(En,{present:o||a.open,children:a.modal?n.jsx(ku,{...s,ref:t}):n.jsx(Su,{...s,ref:t})})});la.displayName=Lt;var ku=m.forwardRef((e,t)=>{const r=ot(Lt,e.__scopeDialog),o=m.useRef(null),s=jt(t,r.contentRef,o);return m.useEffect(()=>{const a=o.current;if(a)return Ga(a)},[]),n.jsx(ca,{...e,ref:s,trapFocus:r.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ht(e.onCloseAutoFocus,a=>{var i;a.preventDefault(),(i=r.triggerRef.current)==null||i.focus()}),onPointerDownOutside:ht(e.onPointerDownOutside,a=>{const i=a.detail.originalEvent,l=i.button===0&&i.ctrlKey===!0;(i.button===2||l)&&a.preventDefault()}),onFocusOutside:ht(e.onFocusOutside,a=>a.preventDefault())})}),Su=m.forwardRef((e,t)=>{const r=ot(Lt,e.__scopeDialog),o=m.useRef(!1),s=m.useRef(!1);return n.jsx(ca,{...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()}})}),ca=m.forwardRef((e,t)=>{const{__scopeDialog:r,trapFocus:o,onOpenAutoFocus:s,onCloseAutoFocus:a,...i}=e,l=ot(Lt,r),d=m.useRef(null),c=jt(t,d);return Ka(),n.jsxs(n.Fragment,{children:[n.jsx(Xs,{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":Kn(l.open),...i,ref:c,onDismiss:()=>l.onOpenChange(!1)})}),n.jsxs(n.Fragment,{children:[n.jsx(Tu,{titleId:l.titleId}),n.jsx(Ru,{contentRef:d,descriptionId:l.descriptionId})]})]})}),Un="DialogTitle",da=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=ot(Un,r);return n.jsx(gt.h2,{id:s.titleId,...o,ref:t})});da.displayName=Un;var ua="DialogDescription",fa=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=ot(ua,r);return n.jsx(gt.p,{id:s.descriptionId,...o,ref:t})});fa.displayName=ua;var ma="DialogClose",pa=m.forwardRef((e,t)=>{const{__scopeDialog:r,...o}=e,s=ot(ma,r);return n.jsx(gt.button,{type:"button",...o,ref:t,onClick:ht(e.onClick,()=>s.onOpenChange(!1))})});pa.displayName=ma;function Kn(e){return e?"open":"closed"}var ha="DialogTitleWarning",[Cu,ga]=$a(ha,{contentName:Lt,titleName:Un,docsSlug:"dialog"}),Tu=({titleId:e})=>{const t=ga(ha),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},Eu="DialogDescriptionWarning",Ru=({contentRef:e,descriptionId:t})=>{const o=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${ga(Eu).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},Au=ra,Du=oa,Mu=aa,_u=ia,Lu=la,Ou=da,Hu=fa,xa=pa,va="AlertDialog",[Fu]=ns(va,[ta]),xt=ta(),ya=e=>{const{__scopeAlertDialog:t,...r}=e,o=xt(t);return n.jsx(Au,{...o,...r,modal:!0})};ya.displayName=va;var Pu="AlertDialogTrigger",Bu=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=xt(r);return n.jsx(Du,{...s,...o,ref:t})});Bu.displayName=Pu;var zu="AlertDialogPortal",ba=e=>{const{__scopeAlertDialog:t,...r}=e,o=xt(t);return n.jsx(Mu,{...o,...r})};ba.displayName=zu;var Wu="AlertDialogOverlay",wa=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=xt(r);return n.jsx(_u,{...s,...o,ref:t})});wa.displayName=Wu;var Vt="AlertDialogContent",[$u,Vu]=Fu(Vt),Ia=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,children:o,...s}=e,a=xt(r),i=m.useRef(null),l=jt(t,i),d=m.useRef(null);return n.jsx(Cu,{contentName:Vt,titleName:Na,docsSlug:"alert-dialog",children:n.jsx($u,{scope:r,cancelRef:d,children:n.jsxs(Lu,{role:"alertdialog",...a,...s,ref:l,onOpenAutoFocus:ht(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(Ai,{children:o}),n.jsx(Uu,{contentRef:i})]})})})});Ia.displayName=Vt;var Na="AlertDialogTitle",ja=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=xt(r);return n.jsx(Ou,{...s,...o,ref:t})});ja.displayName=Na;var ka="AlertDialogDescription",Sa=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=xt(r);return n.jsx(Hu,{...s,...o,ref:t})});Sa.displayName=ka;var Gu="AlertDialogAction",Ca=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,s=xt(r);return n.jsx(xa,{...s,...o,ref:t})});Ca.displayName=Gu;var Ta="AlertDialogCancel",Ea=m.forwardRef((e,t)=>{const{__scopeAlertDialog:r,...o}=e,{cancelRef:s}=Vu(Ta,r),a=xt(r),i=jt(t,s);return n.jsx(xa,{...a,...o,ref:i})});Ea.displayName=Ta;var Uu=({contentRef:e})=>{const t=`\`${Vt}\` requires a description for the component to be accessible for screen reader users.
33
+
34
+ You can add a description to the \`${Vt}\` by passing a \`${ka}\` 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 \`${Vt}\`. 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},Ku=ya,qu=ba,Yu=wa,Zu=Ia,Xu=Ca,Ju=Ea,Qu=ja,ef=Sa;function Oo({...e}){return n.jsx(Ku,{"data-slot":"alert-dialog",...e})}function tf({...e}){return n.jsx(qu,{"data-slot":"alert-dialog-portal",...e})}function rf({className:e,...t}){return n.jsx(Yu,{"data-slot":"alert-dialog-overlay",className:qe("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(tf,{children:[n.jsx(rf,{}),n.jsx(Zu,{"data-slot":"alert-dialog-content",className:qe("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:qe("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:qe("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...t})}function Bo({className:e,...t}){return n.jsx(Qu,{"data-slot":"alert-dialog-title",className:qe("text-lg font-semibold",e),...t})}function zo({className:e,...t}){return n.jsx(ef,{"data-slot":"alert-dialog-description",className:qe("text-muted-foreground text-sm",e),...t})}function Wo({className:e,...t}){return n.jsx(Xu,{className:qe(ls(),e),...t})}function $o({className:e,...t}){return n.jsx(Ju,{className:qe(ls({variant:"outline"}),e),...t})}function nf({...e}){return n.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...e})}function of({className:e,...t}){return n.jsx("ol",{"data-slot":"breadcrumb-list",className:qe("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:qe("inline-flex items-center gap-1.5",e),...t})}function sf({asChild:e,className:t,...r}){const o=e?Rn:"a";return n.jsx(o,{"data-slot":"breadcrumb-link",className:qe("hover:text-foreground transition-colors",t),...r})}function af({className:e,...t}){return n.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:qe("text-foreground font-normal",e),...t})}function lf({children:e,className:t,...r}){return n.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:qe("[&>svg]:size-3.5",t),...r,children:e??n.jsx(Jo,{})})}const Pt={sleep:"sleep",createHook:"createHook",createWebhook:"createWebhook",awaitWebhook:"awaitWebhook"};function Pr(e){return e.replace(/\/\/\.\.\//g,"//")}function cf(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 Br(e){const t=e.split("//");return t.length>=3?t[t.length-1]:null}function df(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=Pr(i.data.stepId),d=t.get(l)||[];d.push(i),t.set(l,d);const c=Br(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=Br(Pr(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 uf(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,N;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 I=new Date(v.completedAt);(!N||I<N)&&(N=I,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(I=>I.id===p.source),w=t.nodes.find(I=>I.id===p.target);if(!x||!w)continue;const N=s.has(p.source),b=s.has(p.target);if(!N&&!b)continue;if(p.type==="conditional"){N&&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):(N&&b||N&&p.type==="parallel"&&b)&&l(p)}return o}function ff(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 mf(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 pf(e,t,r,o,s,a,i){const l=Pr(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=Br(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,N)=>cf(w,u.id,N,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 hf(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(Pt.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 I=a.get(g)||[],j=a.get(v)||[],S=(h=I.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)||[],I=v.find(C=>C.eventType==="wait_created"),j=v.find(C=>C.eventType==="wait_completed");if(!I)continue;const S=s.get(Pt.sleep)||0;s.set(Pt.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(I.createdAt).toISOString(),k=j?new Date(j.createdAt).toISOString():void 0,T=j?new Date(j.createdAt).getTime()-new Date(I.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(Pt.createHook)||[],...t.get(Pt.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 I=a.get(g)||[],j=a.get(v)||[],S=(h=I.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 I=(a.get(g)||[]).find(T=>T.eventType==="hook_created");if(!I)continue;const j=f.length===1?f[0]:f[x];if(x++,!j)continue;const S="completed",R=new Date(I.createdAt).toISOString(),h=new Date(I.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(Pt.awaitWebhook)||[],N=new Set;for(const g of e)g.eventType==="hook_received"&&g.correlationId&&N.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 I=a.get(g)||[],j=I.find(M=>M.eventType==="hook_created"),S=I.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 gf(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=Br(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,N={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,N]),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 xf(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(N=>t.has(N.id)),w=p.elseNodes.some(N=>t.has(N.id));if(x||w){const N=[...p.thenNodes,...p.elseNodes];if(!t.has(c.id)){let b;for(const I of N){const j=t.get(I.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=N.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 vf(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}),ff(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}=df(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?Pr(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=[],N=null,b=null;for(let j=0;j<=l.length;j++){const S=l[j];if(!S||S.stepId!==N){if(w.length>0&&b){const h=pf(w,b,d,c,x,s,a);h&&(i=h)}S&&(w=[S],N=S.stepId,b=S.stepName)}else w.push(S)}const g=hf(r,f,s,a);g&&(i=g),gf(e,l,u,p,s,a,o.nodes),xf(o,s,a,e),mf(e,o,a,s);const v=uf(a,o,s),I={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}})}),I}const qt=4;function yf(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=Li();return(async()=>{try{const b=await tu(e,t,void 0,x.signal),g=o?await zi(o):void 0,v=b.getReader();let I=new Uint8Array(0);const j=S=>{const R=new Uint8Array(I.length+S.length);R.set(I,0),R.set(S,I.length),I=R};for(;!x.signal.aborted;){const{value:S,done:R}=await v.read();if(R){p&&l(!1);break}for(j(S);I.length>=qt;){const y=new DataView(I.buffer,I.byteOffset,I.byteLength).getUint32(0,!1);if(I.length<qt+y)break;const k=I.slice(qt,qt+y);I=I.slice(qt+y);try{const{format:T,payload:D}=Di(k);let M;if(T===Mi.ENCRYPTED){if(!g){p&&(c("This stream is encrypted. Click Decrypt to view."),l(!1)),v.cancel().catch(()=>{});return}M=await Wi(g,D)}else M=k;const C=_i(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 bf({hasError:e,errorMessage:t}){return n.jsx("div",{className:"flex items-center gap-2",children:n.jsxs(xn,{children:[n.jsx(vn,{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(yn,{children:n.jsx("p",{children:e?`Error updating data: ${t}`:`Content updates every ${Oi/1e3} seconds`})})]})})}function Go(e){return e==="retrying"?"running":e}function wf({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(ct,{type:"target",position:dt.Top,className:"!bg-purple-500"}),n.jsx(ct,{type:"source",position:dt.Bottom,className:"!bg-purple-500"}),n.jsx(ct,{type:"source",position:dt.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(ct,{type:"target",position:dt.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(ct,{type:"target",position:dt.Top,className:"!bg-muted"}),!s&&n.jsx(ct,{type:"source",position:dt.Bottom,className:"!bg-muted"})]})}function Nf({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(ct,{type:"target",position:dt.Top,className:"!bg-red-500"}),n.jsx(ct,{type:"source",position:dt.Bottom,id:"bottom",className:"!bg-red-500"}),n.jsx(ct,{type:"source",position:dt.Left,id:"left",className:"!bg-red-500"}),n.jsx(ct,{type:"source",position:dt.Right,id:"right",className:"!bg-red-500"})]})}const jf={loopNode:wf,parallelGroup:Ja,executionNode:If,diamondNode:Nf},kf=Xa(si);function Sf(e,t){const r=ni(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:oi(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(Rr,{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(Rr,{variant:"secondary",className:"text-xs px-1.5 py-0 bg-black/10 dark:bg-white/15 border-0",children:["⏱ ",Dt(s.duration,!0)]})]})]}):o}const Ra={...ti};function Ko(e,t){var d,c,f;const{nodes:r,groupNodes:o}=os(e,Ra),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=Sf(u.data.nodeKind,p),w=(t==null?void 0:t.currentNode)===u.id,N=!!((c=u.metadata)!=null&&c.loopId),b=!!((f=u.metadata)!=null&&f.loopIsAwait),g=u.data.nodeKind==="conditional",v=g?"diamondNode":N?"loopNode":"executionNode",I=s.get(u.id);let j=u.position;if(I){const R=a.get(I);R&&(j={x:u.position.x-R.x,y:u.position.y-R.y})}const S=w?"animate-pulse-subtle":"";N?i.push({id:u.id,type:v,position:j,parentId:I,extent:I?"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:I,extent:I?"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:I,extent:I?"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,Ra),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 ri(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,I=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(Rr,{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:["~",Dt(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:I,stroke:b,opacity:v,strokeDasharray:g}}})}function Cf({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}=Ks(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:Dt(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(un,{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:Dt(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(_r,{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(un,{status:Go(w.status)}),w.duration!==void 0&&w.duration>0&&n.jsx("span",{className:"font-mono text-muted-foreground",children:Dt(w.duration)})]})]},w.attemptNumber))})]})]})]})]})}function Tf({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]=qa(l),[p,x,w]=Ya(d);m.useEffect(()=>{f(g=>{const v=Ko(e,t),I=new Map(g.map(j=>[j.id,j.position]));return v.map(j=>({...j,position:I.get(j.id)??j.position}))}),x(qo(e,t))},[e,t,f,x]);const N=m.useCallback((g,v)=>{const I=e.nodes.find(j=>j.id===v.id);if(I){const j=v.data.executions||[],S=j[j.length-1];a({nodeId:v.id,node:I,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(Za,{nodes:c,edges:p,onNodesChange:u,onEdgesChange:w,onNodeClick:N,nodeTypes:jf,edgeTypes:kf,fitView:!0,minZoom:.1,maxZoom:2,defaultViewport:{x:0,y:0,zoom:1},proOptions:{hideAttribution:!0},children:[n.jsx(Qa,{}),n.jsx(ei,{}),n.jsx(Yn,{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(Yn,{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(Rr,{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(Cf,{selectedNode:s,env:r,onClose:b})})]})}function Ef({run:e,allSteps:t,allEvents:r,env:o}){const{manifest:s,loading:a,error:i}=hi(),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=It(c))==null?void 0:x.shortName;return Object.values(s.workflows).find(w=>{var N;return w.workflowId===c||w.workflowName===c?!0:u?((N=It(w.workflowName))==null?void 0:N.shortName)===u:!1})??null},[s,e.workflowName]),d=m.useMemo(()=>!l||!e.runId?null:vf(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(_r,{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(fn,{variant:"destructive",className:"max-w-lg",children:[n.jsx(mn,{className:"h-4 w-4"}),n.jsx(pn,{children:"Error Loading Workflow Graph"}),n.jsx(hn,{children:i.message})]})}):l?n.jsx(Tf,{workflow:l,execution:d||void 0,env:o}):n.jsx("div",{className:"flex items-center justify-center w-full h-full",children:n.jsxs(fn,{className:"max-w-lg",children:[n.jsx(mn,{className:"h-4 w-4"}),n.jsx(pn,{children:"Workflow Graph Not Found"}),n.jsx(hn,{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."})]})})}const Rf=new Set(["run_created","run_started","run_completed","run_failed","run_cancelled"]);function Af({runId:e,selectedId:t}){var Ce;const r=Aa(),[o]=Xo(),{serverConfig:s}=Hi(),[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",N=o.get("streamId"),b=m.useCallback(Z=>{const je=new URLSearchParams(o.toString());for(const[Te,_e]of Object.entries(Z))_e===null?je.delete(Te):je.set(Te,_e);r(`?${je.toString()}`,{preventScrollReset:!0})},[r,o]),g=m.useCallback(Z=>{b(Z==="trace"||Z==="graph"?{tab:Z,streamId:null}:{tab:Z})},[b]),v=m.useCallback(Z=>{b({streamId:Z})},[b]),I=m.useCallback(Z=>{b({tab:"streams",streamId:Z})},[b]),j=m.useCallback(async(Z,je)=>ai(x,Z,{correlationIds:[je]}),[x]),S=m.useRef(null),R=m.useCallback(async(Z,je)=>{await ii(x,Z,je)},[x]),h=m.useCallback(async Z=>{if(!Rf.has(Z.eventType)&&Z.correlationId){const{error:De,result:et}=await Re(Mr(x,Z.correlationId,{sortOrder:"asc",limit:100,withData:!0}));if(De)throw De;const vt=et.data.find(Ze=>Ze.eventId===Z.eventId);if(!vt)return null;const Me=S.current?await kr(vt,S.current):Oe(vt);return"eventData"in Me?Me.eventData:null}const{error:Te,result:_e}=await Re(Jt(x,Z.runId,{sortOrder:"desc",limit:1e3,withData:!0}));if(Te)throw Te;let Le=_e.data.find(De=>De.eventId===Z.eventId);if(!Le){const{error:De,result:et}=await Re(Jt(x,Z.runId,{sortOrder:"asc",limit:1e3,withData:!0}));if(De)throw De;Le=et.data.find(vt=>vt.eventId===Z.eventId)}if(!Le)return null;const Fe=S.current?await kr(Le,S.current):Oe(Le);return"eventData"in Fe?Fe.eventData:null},[x]),y=m.useCallback(async(Z,je)=>{const{error:Te,result:_e}=await Re(Mr(x,Z,{sortOrder:"asc",limit:100,withData:!0}));if(Te)throw Te;const Le=_e.data.find(De=>De.eventId===je);if(!Le)return null;const Fe=S.current?await kr(Le,S.current):Oe(Le);return"eventData"in Fe?Fe.eventData:null},[x]),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:Q}=Qd(x,e,{live:!0}),P=T??{},[$,W]=m.useState(null);S.current=$;const[K,U]=m.useState(null),{data:Y,loading:ee,error:A,refresh:B}=Ks(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:Z,result:je}=await Re(Fi(x,e));if(Z){he.error(`Failed to fetch encryption key: ${Z.message}`);return}if(!je){he.error("Encryption is not configured for this deployment.");return}W(je)},[$,x,e,B]),ue=m.useCallback(Z=>{U(Z)},[]),{streams:ge,loading:q,error:te}=ou(x,e),{chunks:me,isLive:pe,error:ce}=yf(x,N,e,$),ie=()=>{f(!0)},Ie=async()=>{if(!a)try{i(!0),f(!1),await mi(x,e),await H(),he.success("Run cancelled successfully")}catch(Z){console.error("Failed to cancel run:",Z),he.error("Failed to cancel run",{description:Z instanceof Error?Z.message:"An unknown error occurred"})}finally{i(!1)}},Ne=()=>{p(!0)},Qe=async()=>{if(!l)try{d(!0),p(!1);const Z=await pi(x,P.runId);he.success("New run started successfully",{description:`Run ID: ${Z}`}),r(`/run/${Z}`)}catch(Z){console.error("Failed to re-run workflow:",Z),he.error("Failed to start new run",{description:Z instanceof Error?Z.message:"An unknown error occurred"})}finally{d(!1),p(!1)}};if(O&&!T)return n.jsxs(fn,{variant:"destructive",className:"m-4",children:[n.jsx(mn,{className:"h-4 w-4"}),n.jsx(pn,{children:"Error loading workflow run"}),n.jsx(hn,{children:O.message})]});const st=(Ce=It(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:Qe,children:"Replay Run"})]})]})}),n.jsxs("div",{className:"flex flex-col h-[calc(100vh-97px)]",children:[n.jsxs("div",{className:"flex-none space-y-4",children:[n.jsx(nf,{children:n.jsxs(of,{children:[n.jsx(Vo,{children:n.jsx(sf,{asChild:!0,children:n.jsx(Da,{to:"/",children:"Runs"})})}),n.jsx(lf,{}),n.jsx(Vo,{children:n.jsx(af,{className:"font-mono text-xs",children:e})})]})}),n.jsxs("div",{className:"space-y-4 p-6 border rounded-lg",children:[n.jsxs("div",{className:"flex items-start justify-between",children:[n.jsx("div",{className:"mb-4",children:n.jsx("h1",{className:"text-xl font-semibold",children:st||n.jsx(Tt,{className:"w-[260px] h-[28px]"})})}),n.jsxs("div",{className:"flex items-center justify-between gap-2",children:[n.jsx(bf,{hasError:!1,errorMessage:""}),(lt(P.input)||lt(P.output)||lt(P.error)||D.some(Z=>lt(Z.input)||lt(Z.output)))&&n.jsxs(xn,{children:[n.jsx(vn,{asChild:!0,children:n.jsx("span",{children:n.jsxs(Pi,{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(yn,{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(li,{env:x,runId:e,runStatus:P.status,events:C,eventsLoading:_,loading:E,onRerunClick:Ne,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(un,{status:P.status,context:P}):n.jsx(Tt,{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 Z=(P.completedAt?new Date(P.completedAt).getTime():Date.now())-new Date(P.startedAt).getTime(),je=Math.floor(Z/1e3);if(je<60)return`${je}s`;const Te=Math.floor(je/60),_e=je%60;if(Te<60)return _e>0?`${Te}m ${_e}s`:`${Te}m`;const Le=Math.floor(Te/60),Fe=Te%60;return Fe>0?`${Le}h ${Fe}m`:`${Le}h`})():"-":n.jsx(Tt,{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(ci,{text:P.runId,children:n.jsx("div",{className:"text-xs mt-0.5 font-mono",children:P.runId})}):n.jsx(Tt,{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(gr,{date:P.createdAt})}):n.jsx(Tt,{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(gr,{date:P.startedAt}):"-":n.jsx(Tt,{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(gr,{date:P.completedAt}):"-":n.jsx(Tt,{className:"w-[110px] h-[20px]"})})]}),P.expiredAt!=null&&n.jsxs("div",{className:"flex flex-col gap-1",children:[n.jsxs(xn,{children:[n.jsx(vn,{asChild:!0,children:n.jsxs("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",n.jsx(Vi,{className:"w-3 h-3"})]})}),n.jsx(yn,{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(gr,{date:P.expiredAt})})]})]})]})]}),n.jsxs("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:[n.jsxs(di,{value:w,onValueChange:Z=>g(Z),className:"flex-1 flex flex-col min-h-0",children:[n.jsxs(ui,{className:"mb-4 flex-none",children:[n.jsxs(xr,{value:"trace",className:"gap-2",children:[n.jsx(Jr,{className:"h-4 w-4"}),"Trace"]}),k&&n.jsxs(xr,{value:"graph",className:"gap-2",children:[n.jsx(fi,{className:"h-4 w-4"}),"Graph"]}),n.jsxs(xr,{value:"events",className:"gap-2",children:[n.jsx(Jr,{className:"h-4 w-4"}),"Events"]}),n.jsxs(xr,{value:"streams",className:"gap-2",children:[n.jsx(Jr,{className:"h-4 w-4"}),"Streams"]})]}),n.jsx(vr,{value:"trace",className:"mt-0 flex-1 min-h-0",children:n.jsx(Bt,{title:"Failed to load trace viewer",children:n.jsx("div",{className:"h-full",children:n.jsx(Kd,{error:O,steps:D,events:C,hooks:M,run:P,isLoading:E,spanDetailData:Y,spanDetailLoading:ee,spanDetailError:A,onSpanSelect:ue,onStreamClick:I,onWakeUpSleep:j,onResolveHook:R,onLoadEventData:y,onLoadMoreSpans:z,hasMoreSpans:V,isLoadingMoreSpans:Q,encryptionKey:$??void 0})})})}),n.jsx(vr,{value:"events",className:"mt-0 flex-1 min-h-0",children:n.jsx(Bt,{title:"Failed to load events list",children:n.jsx("div",{className:"h-full",children:n.jsx(Mc,{events:C,steps:D,run:P,onLoadEventData:h,encryptionKey:$??void 0})})})}),n.jsx(vr,{value:"streams",className:"mt-0 flex-1 min-h-0",children:n.jsx(Bt,{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(_r,{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(Z=>n.jsx("button",{type:"button",onClick:()=>v(Z),className:"w-full text-left px-3 py-2 text-xs font-mono truncate hover:bg-accent transition-colors",style:{backgroundColor:N===Z?"var(--ds-gray-200)":"transparent",color:"var(--ds-gray-1000)"},title:Z,children:Z},Z))})]}),n.jsx("div",{className:"flex-1 min-w-0",children:N?n.jsx(Bi,{streamId:N,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(vr,{value:"graph",className:"mt-0 flex-1 min-h-0",children:n.jsx(Bt,{title:"Failed to load execution graph",children:n.jsx("div",{className:"h-full min-h-[500px]",children:n.jsx(Ef,{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(_r,{className:"size-4 animate-spin"}),n.jsx("span",{className:"text-sm",children:"Fetching data..."})]})]})]})]})}const Of=Ma(function(){const t=_a(),[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(Bt,{title:"Failed to load run details",children:n.jsx(Af,{runId:o,selectedId:l})})});export{Of as default};