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