@workflow/web 5.0.0-beta.0 → 5.0.0-beta.2
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/README.md +1 -1
- package/build/client/assets/encryption-80GMP4r0.js +26 -0
- package/build/client/assets/entry.client-BWsSsWQm.js +11899 -0
- package/build/client/assets/highlighted-body-B3W2YXNL-DPWdt39H.js +18 -0
- package/build/client/assets/home-OcN-ARTU.js +3992 -0
- package/build/client/assets/index-DQa-BExo.js +9432 -0
- package/build/client/assets/{manifest-f539c63d.js → manifest-62352cd9.js} +1 -1
- package/build/client/assets/mermaid-3ZIDBTTL-B9v3aKRl.js +48141 -0
- package/build/client/assets/root-BrnNveEi.css +1 -0
- package/build/client/assets/root-ClRrWHkX.js +690 -0
- package/build/client/assets/run-detail-BdYMODbi.js +6710 -0
- package/build/client/assets/{server-build-CiTtikBY.css → server-build-DKWv59Tp.css} +1 -1
- package/build/client/assets/worker-CqHKTA7D.js +115 -0
- package/build/client/assets/workflow-graph-viewer-BdFIMYrh.js +16175 -0
- package/build/server/assets/{app-1J46XJy_.js → app-coxrYAYu.js} +1 -1
- package/build/server/assets/{highlighted-body-B3W2YXNL-I0QqkET4.js → highlighted-body-B3W2YXNL-DhGWas67.js} +3 -3
- package/build/server/assets/{index-C2mzCybK.js → index-DJ8Yt9MV.js} +31 -29
- package/build/server/assets/{mermaid-3ZIDBTTL-SEARynp_.js → mermaid-3ZIDBTTL-DJkW_cc4.js} +4 -4
- package/build/server/assets/{server-build-BxBXwQkv.js → server-build-dCNkWo2d.js} +51274 -51634
- package/build/server/assets/{token-Ciwcps8o.js → token-Bi1ru9oe.js} +2 -2
- package/build/server/assets/{token-util-CdmCt7b7.js → token-util-Bwj_Mj31.js} +2 -2
- package/build/server/index.js +1 -1
- package/package.json +7 -7
- package/build/client/assets/encryption-8OvC6eoJ.js +0 -1
- package/build/client/assets/entry.client-BiVEcoV8.js +0 -29
- package/build/client/assets/highlighted-body-B3W2YXNL-uFZFLPnf.js +0 -1
- package/build/client/assets/home-uJObYcer.js +0 -40
- package/build/client/assets/index-BmZS3y7B.js +0 -59
- package/build/client/assets/mermaid-3ZIDBTTL-CsKo7Yup.js +0 -172
- package/build/client/assets/root-CfvTqR04.js +0 -26
- package/build/client/assets/root-aMfmV5uh.css +0 -1
- package/build/client/assets/run-detail-DzPk1eyg.js +0 -37
- package/build/client/assets/worker-D-HfgUMl.js +0 -1
- package/build/client/assets/workflow-graph-viewer-BmYB4k6X.js +0 -161
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import{j as t,r as a,f as Ut,C as Os,A as $s,B as Pr,z as Ws,w as Hs,G as Bs}from"./index-BmZS3y7B.js";import{O as rt,C as Fr,Q as st,B as ze,j as Kt,q as Or,U as $r,Z as Vs,S as Wr,R as Hr,p as zs,o as Us,X as Ks,N as Qe,V as qs,G as Gs,I as ue,u as ht,W as _e,Y as Zs,v as je,_ as yt,$ as Ys,t as Br,a0 as Xs,s as Js,a1 as It,w as qt,l as Qs,m as en,a2 as tn,a3 as rn,a4 as sn,r as nn,A as on,c as an,d as ln,a as Ae,a5 as cn,F as dn,e as un,b as ut,T as fn,K as mn,L as Tt,M as Rt,y as pn,a6 as hn}from"./workflow-graph-viewer-BmYB4k6X.js";import{c as Nt,h as Ue,M as Q,Y as xn,N as ye,O as sr,U as vt,_ as gn,W as yn,X as Le,Z as vn,$ as wn,a0 as Vr,a1 as Pe,a2 as ve,a3 as G,a4 as bn,a5 as jn,a6 as At,a7 as ce,a8 as ft,a9 as wt,aa as We,ab as Se,ac as zr,ad as Xe,ae as Dt,af as kn,ag as Nn,ah as Cn,ai as En,aj as Sn,ak as In,al as Tn,am as He,an as me,ao as Ur,l as Be,F as Wt,ap as Rn,aq as An,ar as Gt,E as Ie,as as Dn,d as de,at as Kr,au as nr,av as or,aw as Mn,T as qr,a as Gr,b as Zr,ax as _n,u as Ln,ay as ar,az as Pn,t as De,L as Fn,aA as On}from"./mermaid-3ZIDBTTL-CsKo7Yup.js";import{decrypt as $n,importKey as Wn}from"./encryption-8OvC6eoJ.js";/**
|
|
2
|
-
* @license lucide-react v0.575.0 - ISC
|
|
3
|
-
*
|
|
4
|
-
* This source code is licensed under the ISC license.
|
|
5
|
-
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
-
*/const Hn=[["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"}]],Bn=Nt("circle-question-mark",Hn);/**
|
|
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 Vn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],zn=Nt("info",Vn);/**
|
|
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 Un=[["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"}]],Mt=Nt("list",Un);/**
|
|
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 Kn=[["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"}]],qn=Nt("type",Kn),Gn="@keyframes wf-spinner-fade{0%{opacity:1}100%{opacity:.15}}";function Zt({size:e=14,color:r}){const s=e<=12?{angle:45,delays:[-875,-750,-625,-500,-375,-250,-125,0],duration:1e3,lineW:3,lineH:1.5}:e<=16?{angle:36,delays:[-900,-800,-700,-600,-500,-400,-300,-200,-100,0],duration:1e3,lineW:4,lineH:1.5}:{angle:30,delays:[-1100,-1e3,-900,-800,-700,-600,-500,-400,-300,-200,-100,0],duration:1200,lineW:e*.24,lineH:e*.08};return t.jsxs("span",{style:{display:"inline-flex",position:"relative",width:e,height:e},children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:Gn}}),s.delays.map((n,o)=>t.jsx("span",{style:{position:"absolute",left:"50%",top:"50%",width:s.lineW,height:s.lineH,marginLeft:-s.lineW/2,marginTop:-s.lineH/2,borderRadius:1,backgroundColor:r??"var(--ds-gray-700)",transform:`rotate(${o*s.angle}deg) translate(${e*.36}px)`,animation:`wf-spinner-fade ${s.duration}ms linear infinite`,animationDelay:`${n}ms`}},n))]})}const Zn=".wf-decrypt-btn{appearance:none;-webkit-appearance:none;border:none;display:inline-flex;align-items:center;justify-content:center;height:40px;padding:0 12px;border-radius:6px;font-size:14px;font-weight:500;line-height:20px;cursor:pointer;white-space:nowrap;gap:6px;transition:background 150ms}.wf-decrypt-idle{color:var(--ds-gray-1000);background:var(--ds-background-100);box-shadow:0 0 0 1px var(--ds-gray-400)}.wf-decrypt-idle:hover{background:var(--ds-gray-alpha-200)}.wf-decrypt-done{color:var(--ds-green-900);background:var(--ds-green-100);box-shadow:0 0 0 1px var(--ds-green-400);cursor:default}";function Yt({decrypted:e=!1,loading:r=!1,onClick:s}){return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:Zn}}),t.jsxs("button",{type:"button",onClick:e?void 0:s,disabled:e||r,className:`wf-decrypt-btn ${e?"wf-decrypt-done":"wf-decrypt-idle"}`,children:[r?t.jsx(Zt,{size:14}):e?t.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 9.9-1"})]}):t.jsxs("svg",{width:14,height:14,viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:2,strokeLinecap:"round",strokeLinejoin:"round",children:[t.jsx("rect",{x:"3",y:"11",width:"18",height:"11",rx:"2",ry:"2"}),t.jsx("path",{d:"M7 11V7a5 5 0 0 1 10 0v4"})]}),r?"Decrypting…":e?"Decrypted":"Decrypt"]})]})}function et(e){return e!=null&&typeof e=="object"&&"stack"in e&&typeof e.stack=="string"}function bt({value:e}){const r=Ue(),s=e.stack,n=typeof e.message=="string"?e.message:void 0,o=n?`${n}
|
|
22
|
-
|
|
23
|
-
${s}`:s;return t.jsxs("div",{className:"relative overflow-hidden rounded-md border",style:{borderColor:"var(--ds-red-400)",background:"var(--ds-red-100)"},children:[t.jsx("button",{type:"button","aria-label":"Copy error",title:"Copy",className:"!absolute !right-2 !top-2 !flex !h-6 !w-6 !items-center !justify-center !rounded-md !border transition-transform transition-colors duration-100 hover:!bg-[var(--ds-red-200)] active:!scale-95",style:{borderColor:"var(--ds-red-400)",background:"var(--ds-red-100)",color:"var(--ds-red-900)"},onClick:()=>{navigator.clipboard.writeText(o).then(()=>{r.success("Copied to clipboard")}).catch(()=>{r.error("Failed to copy")})},children:t.jsx(rt,{size:12})}),n&&t.jsxs("div",{className:"flex items-start gap-2 px-3 py-2.5 pr-10",style:{color:"var(--ds-red-900)",borderBottom:"1px solid var(--ds-red-400)"},children:[t.jsx(Fr,{className:"h-4 w-4 shrink-0",style:{marginTop:1}}),t.jsx("p",{className:"text-xs font-semibold m-0 break-words",children:n})]}),t.jsx("pre",{className:"px-3 py-2.5 text-xs font-mono whitespace-pre-wrap break-words overflow-auto m-0",style:{color:"var(--ds-red-900)",background:"var(--ds-red-200)"},children:s})]})}const Yn=".wf-load-more{appearance:none;-webkit-appearance:none;border:none;display:inline-flex;align-items:center;justify-content:center;height:32px;padding:0 12px;border-radius:6px;font-size:13px;font-weight:500;line-height:20px;color:var(--ds-gray-1000);background:var(--ds-background-100);box-shadow:0 0 0 1px var(--ds-gray-400);cursor:pointer;white-space:nowrap;gap:6px;transition:background 150ms}.wf-load-more:hover{background:var(--ds-gray-alpha-200)}.wf-load-more:disabled{opacity:.6;cursor:default}.wf-load-more:disabled:hover{background:var(--ds-background-100)}";function Xn({loading:e=!1,onClick:r,label:s="Load more",loadingLabel:n="Loading..."}){return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:Yn}}),t.jsxs("button",{type:"button",onClick:r,disabled:e,className:"wf-load-more",children:[e&&t.jsx(Zt,{size:14}),e?n:s]})]})}const Jn=".wf-menu-btn{appearance:none;-webkit-appearance:none;border:none;display:inline-flex;align-items:center;justify-content:center;height:40px;padding:0 12px;border-radius:6px;font-size:14px;font-weight:500;line-height:20px;color:var(--ds-gray-1000);background:var(--ds-background-100);box-shadow:0 0 0 1px var(--ds-gray-400);cursor:pointer;white-space:nowrap;transition:background 150ms}.wf-menu-btn:hover{background:var(--ds-gray-alpha-200)}.wf-menu-item{appearance:none;-webkit-appearance:none;border:none;display:flex;align-items:center;width:100%;height:40px;padding:0 8px;border-radius:6px;font-size:14px;color:var(--ds-gray-1000);background:transparent;cursor:pointer;transition:background 150ms}.wf-menu-item:hover{background:var(--ds-gray-alpha-100)}";function Qn({options:e,value:r,onChange:s}){var c,u;const[n,o]=a.useState(!1),i=a.useRef(null),l=((c=e.find(d=>d.value===r))==null?void 0:c.label)??((u=e[0])==null?void 0:u.label)??"";return a.useEffect(()=>{if(!n)return;function d(p){i.current&&!i.current.contains(p.target)&&o(!1)}return document.addEventListener("mousedown",d),()=>document.removeEventListener("mousedown",d)},[n]),t.jsxs("div",{ref:i,style:{position:"relative",flexShrink:0},children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:Jn}}),t.jsxs("button",{type:"button",className:"wf-menu-btn",onClick:()=>o(!n),children:[t.jsx("span",{children:l}),t.jsx("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none",style:{marginLeft:16,marginRight:-4,color:"var(--ds-gray-900)"},children:t.jsx("path",{d:"M4.5 6L8 9.5L11.5 6",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})]}),n&&t.jsx("div",{style:{position:"absolute",right:0,top:"100%",marginTop:4,minWidth:140,padding:4,borderRadius:12,background:"var(--ds-background-100)",boxShadow:"var(--ds-shadow-menu, var(--ds-shadow-medium))",zIndex:2001},role:"menu",children:e.map(d=>t.jsx("button",{type:"button",role:"menuitem",className:"wf-menu-item",style:{fontWeight:d.value===r?500:400},onClick:()=>{s(d.value),o(!1)},children:d.label},d.value))})]})}const eo=[{unit:"year",ms:31536e6},{unit:"month",ms:2628e6},{unit:"day",ms:864e5},{unit:"hour",ms:36e5},{unit:"minute",ms:6e4},{unit:"second",ms:1e3}];function to(e){let r=Math.abs(e);const s=[];for(const{unit:n,ms:o}of eo){const i=Math.floor(r/o);if((i>0||s.length>0)&&(s.push(`${i} ${n}${i!==1?"s":""}`),r%=o),s.length===3)break}return s.join(", ")}function ro(e){const[r,s]=a.useState("");return a.useEffect(()=>{const n=()=>{const i=Date.now()-e,l=to(i);s(l?`${l} ago`:"Just now")};n();const o=setInterval(n,1e3);return()=>clearInterval(o)},[e]),r}function ir({date:e,zone:r}){var l;const s=new Date(e),n=((l=new Intl.DateTimeFormat("en-US",{timeZone:r,timeZoneName:"short"}).formatToParts(s).find(c=>c.type==="timeZoneName"))==null?void 0:l.value)||r,o=s.toLocaleString("en-US",{timeZone:r,year:"numeric",month:"long",day:"numeric"}),i=s.toLocaleTimeString("en-US",{timeZone:r,hour:"2-digit",minute:"2-digit",second:"2-digit"});return t.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",gap:12},children:[t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6},children:[t.jsx("div",{style:{display:"inline-flex",alignItems:"center",justifyContent:"center",height:16,padding:"0 6px",backgroundColor:"var(--ds-gray-200)",borderRadius:3,fontSize:11,fontFamily:"var(--font-mono, monospace)",fontWeight:500,color:"var(--ds-gray-900)",whiteSpace:"nowrap"},children:n}),t.jsx("span",{style:{fontSize:13,color:"var(--ds-gray-1000)",whiteSpace:"nowrap"},children:o})]}),t.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",fontVariantNumeric:"tabular-nums",color:"var(--ds-gray-900)",whiteSpace:"nowrap"},children:i})]})}function so({date:e}){const r=Intl.DateTimeFormat().resolvedOptions().timeZone,s=ro(e);return t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:12,minWidth:300,padding:"12px 14px"},children:[t.jsx("span",{style:{fontSize:13,fontVariantNumeric:"tabular-nums",color:"var(--ds-gray-900)"},children:s}),t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:8},children:[t.jsx(ir,{date:e,zone:"UTC"}),t.jsx(ir,{date:e,zone:r})]})]})}const no=330,mt=8;function oo({triggerRect:e,onMouseEnter:r,onMouseLeave:s,date:n}){const o=a.useRef(null),[i,l]=a.useState({position:"fixed",zIndex:9999,visibility:"hidden"});return a.useEffect(()=>{const c=e.top>240?"above":"below",u=e.left+e.width/2,d=o.current,p=d?d.offsetWidth:no,h=d?d.offsetHeight:100;let m=u-p/2;m=Math.max(mt,Math.min(m,window.innerWidth-p-mt));let f;c==="above"?(f=e.top-h-6,f<mt&&(f=e.bottom+6)):(f=e.bottom+6,f+h>window.innerHeight-mt&&(f=e.top-h-6)),l({position:"fixed",left:m,top:f,zIndex:9999,borderRadius:10,border:"1px solid var(--ds-gray-alpha-200)",backgroundColor:"var(--ds-background-100)",boxShadow:"0 4px 12px rgba(0,0,0,0.08), 0 1px 3px rgba(0,0,0,0.06)",visibility:"visible"})},[e]),Ut.createPortal(t.jsx("div",{ref:o,onMouseEnter:r,onMouseLeave:s,style:i,children:t.jsx(so,{date:n})}),document.body)}function Yr({date:e,children:r}){const[s,n]=a.useState(!1),[o,i]=a.useState(null),l=a.useRef(null),c=a.useRef(null);a.useEffect(()=>()=>{c.current&&clearTimeout(c.current)},[]);const u=e==null?null:typeof e=="number"?e:new Date(e).getTime();if(u==null||Number.isNaN(u))return t.jsx(t.Fragment,{children:r});const d=()=>{c.current&&(clearTimeout(c.current),c.current=null)},p=()=>{d(),c.current=setTimeout(()=>n(!1),120)},h=()=>{d(),l.current&&i(l.current.getBoundingClientRect()),n(!0)};return t.jsxs("span",{ref:l,onMouseEnter:h,onMouseLeave:p,style:{display:"inline-flex"},children:[r,s&&o&&t.jsx(oo,{triggerRect:o,onMouseEnter:d,onMouseLeave:p,date:u})]})}const ao=new Set(["step_failed","step_retrying","run_failed","workflow_failed"]),Xr={appearance:"none",WebkitAppearance:"none",border:"none",background:"transparent"},Jr="workflow-dot-pulse 1.25s cubic-bezier(0, 0, 0.2, 1) infinite";function io(e){return e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})+"."+e.getMilliseconds().toString().padStart(3,"0")}function Qr(e){return e.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function lo(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 co(e,r){var o,i;const s=new Map;if(e){for(const l of e)if(l.eventType==="step_created"&&l.correlationId){const c=((o=l.eventData)==null?void 0:o.stepName)??"",u=st(String(c));s.set(l.correlationId,(u==null?void 0:u.shortName)??c)}}const n=r!=null&&r.workflowName?((i=ze(r.workflowName))==null?void 0:i.shortName)??r.workflowName:null;return{correlationNameMap:s,workflowName:n}}function uo(e){const r=new Map,s=new Map,n=new Map;for(const o of e){const i=new Date(o.createdAt).getTime(),l=o.correlationId??"__run__",c=o.eventType;if((c==="step_created"||c==="run_created")&&r.set(l,i),c==="step_started"||c==="run_started"||c==="workflow_started"){s.set(l,i),r.has(l)||r.set(l,i);const u=r.get(l),d=n.get(l)??{};u!==void 0&&(d.queued=i-u),n.set(l,d)}if(c==="step_completed"||c==="step_failed"||c==="run_completed"||c==="run_failed"||c==="run_cancelled"||c==="workflow_completed"||c==="workflow_failed"||c==="wait_completed"||c==="hook_disposed"){const u=s.get(l),d=n.get(l)??{};u!==void 0&&(d.ran=i-u),n.set(l,d)}}return n}function Ht(e){if(!e||typeof e!="object")return!1;for(const r of Object.values(e))if(ye(r))return!0;return!1}function jt(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 tt=36,fo=20,_t="var(--ds-gray-500)";function lr({isFirst:e,isLast:r,isRunLevel:s,statusDotColor:n,pulse:o=!1,hasSelection:i,showBranch:l,showLaneLine:c,isLaneStart:u,isLaneEnd:d,continuationOnly:p=!1}){const h=s?8:6,m=s?5:6,f=i&&!l&&!s?.3:1;return t.jsxs("div",{className:"relative flex-shrink-0 self-stretch",style:{width:tt,minHeight:p?0:void 0},children:[t.jsx("div",{style:{position:"absolute",left:8,top:p?0:e?"50%":0,bottom:p?0:r?"50%":0,width:2,backgroundColor:_t,zIndex:0}}),!p&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{position:"absolute",left:m,top:"50%",transform:"translateY(-50%)",width:h,height:h,zIndex:2},children:[t.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:"var(--ds-background-100)",zIndex:0}}),o&&t.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:n,opacity:.75*f,animation:Jr,zIndex:1}}),t.jsx("div",{style:{position:"relative",width:"100%",height:"100%",borderRadius:"50%",backgroundColor:n,opacity:f,transition:"opacity 150ms",zIndex:2}})]}),l&&t.jsx("div",{style:{position:"absolute",left:9,top:"50%",width:tt-9,height:2,backgroundColor:_t,zIndex:0}})]}),c&&t.jsx("div",{style:{position:"absolute",left:fo,top:p?0:u?"50%":0,bottom:p?0:d?"50%":0,width:2,backgroundColor:_t,zIndex:0}})]})}function cr({value:e,className:r,style:s}){const[n,o]=a.useState(!1),i=a.useRef(null);a.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]);const l=a.useCallback(c=>{c.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{o(!0),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{o(!1),i.current=null},1500)})},[e]);return t.jsxs("div",{className:`group/copy flex items-center gap-1 min-w-0 px-4 ${r??""}`,style:s,children:[t.jsx("span",{className:"overflow-hidden text-ellipsis whitespace-nowrap",children:e||"-"}),e?t.jsx("button",{type:"button",onClick:l,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:Xr,"aria-label":`Copy ${e}`,children:n?t.jsx(Or,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}):t.jsx(rt,{className:"h-3 w-3",style:{color:"var(--ds-gray-700)"}})}):null]})}function xt(e){if(typeof e=="string"){const r=e.trim();if(r.startsWith("{")&&r.endsWith("}")||r.startsWith("[")&&r.endsWith("]")||r.startsWith('"')&&r.endsWith('"'))try{return xt(JSON.parse(r))}catch{return e}return e}if(Array.isArray(e))return e.map(xt);if(e!==null&&typeof e=="object"){if(e.constructor!==Object)return e;const r={};for(const[s,n]of Object.entries(e))r[s]=xt(n);return r}return e}function mo(e,r){if(!r||!ao.has(r)||e==null||typeof e!="object")return null;const s=e;return et(s.error)?s.error:et(s)?s:null}function po({data:e,eventType:r}){const s=a.useMemo(()=>mo(e,r),[e,r]),[n,o]=a.useState(!1),i=a.useRef(null),l=a.useMemo(()=>xt(e),[e]);a.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]);const c=a.useMemo(()=>{try{return JSON.stringify(l,null,2)}catch{return String(l)}},[l]),u=a.useCallback(d=>{d.stopPropagation(),navigator.clipboard.writeText(c).then(()=>{o(!0),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{o(!1),i.current=null},1500)})},[c]);return s?t.jsx("div",{className:"p-2",children:t.jsx(bt,{value:s})}):t.jsxs("div",{className:"relative group/payload",children:[t.jsx("div",{className:"overflow-x-auto p-2 text-[11px]",style:{color:"var(--ds-gray-1000)"},children:t.jsx(vt,{data:l,expandLevel:2})}),t.jsx("button",{type:"button",onClick:u,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:{...Xr,color:"var(--ds-gray-700)"},"aria-label":"Copy payload",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Or,{className:"h-3 w-3",style:{color:"var(--ds-green-700)"}}),t.jsx("span",{style:{color:"var(--ds-green-700)"},children:"Copied"})]}):t.jsxs(t.Fragment,{children:[t.jsx(rt,{className:"h-3 w-3"}),t.jsx("span",{children:"Copy"})]})})]})}const ho=[{value:"desc",label:"Newest"},{value:"asc",label:"Oldest"}];function dr(){return t.jsx("div",{className:"flex-1 overflow-hidden",children:Array.from({length:16},(e,r)=>t.jsxs("div",{className:"flex items-center gap-0",style:{height:40},children:[t.jsxs("div",{className:"relative flex-shrink-0 self-stretch flex items-center",style:{width:tt},children:[t.jsx("div",{style:{position:"absolute",left:8,top:r===0?"50%":0,bottom:0,width:2},children:t.jsx(Q,{className:"w-full h-full",style:{borderRadius:1}})}),t.jsx(Q,{className:"flex-shrink-0",style:{width:r%4===0?8:6,height:r%4===0?8:6,borderRadius:"50%",marginLeft:r%4===0?5:6}})]}),t.jsx("div",{className:"w-5 flex-shrink-0 flex items-center justify-center",children:t.jsx(Q,{className:"w-5 h-5",style:{borderRadius:4}})}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:t.jsx(Q,{className:"h-3",style:{width:"70%"}})}),t.jsxs("div",{className:"min-w-0 px-4 flex items-center gap-1.5",style:{flex:"2 1 0%"},children:[t.jsx(Q,{className:"flex-shrink-0",style:{width:6,height:6,borderRadius:"50%"}}),t.jsx(Q,{className:"h-3",style:{width:"60%"}})]}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:t.jsx(Q,{className:"h-3",style:{width:"50%"}})}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"3 1 0%"},children:t.jsx(Q,{className:"h-3",style:{width:"75%"}})}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"3 1 0%"},children:t.jsx(Q,{className:"h-3",style:{width:"75%"}})})]},r))})}function xo({event:e,index:r,isFirst:s,isLast:n,isExpanded:o,onToggleExpand:i,activeGroupKey:l,selectedGroupKey:c,selectedGroupRange:u,correlationNameMap:d,workflowName:p,durationMap:h,onSelectGroup:m,onHoverGroup:f,onLoadEventData:R,cachedEventData:C,onCacheEventData:x,encryptionKey:k,onEncryptedDataDetected:v}){const[_,T]=a.useState(!1),[P,E]=a.useState(C),[N,w]=a.useState(null),[g,y]=a.useState(C!==null);a.useEffect(()=>{C!==null&&!k&&Ht(C)&&(v==null||v())},[]);const M=jt(e.eventType)?"__run__":e.correlationId??void 0,S=lo(e.eventType),I=new Date(e.createdAt),O="eventData"in e&&e.eventData!=null,$=jt(e.eventType),L=$?p??"-":e.correlationId?d.get(e.correlationId)??"-":"-",A=e.correlationId??($?"__run__":""),b=A?h.get(A):void 0,F=l!==void 0,U=M!==void 0&&M===l,W=F&&!U,K=F&&U,J=F&&U&&!$,X=u!==null&&r>=u.first&&r<=u.last,j=u!==null&&r===u.first,D=u!==null&&r===u.last,B=a.useCallback(async()=>{if(!(P!==null||O)){T(!0),w(null);try{if(!R){w("Event details unavailable");return}const H=await R(e);H!=null&&(E(H),x(e.eventId,H),!k&&Ht(H)&&(v==null||v()))}catch(H){w(H instanceof Error?H.message:"Failed to load event details")}finally{T(!1),y(!0)}}},[e,P,O,R,x,k,v]);a.useEffect(()=>{o&&P===null&&!O&&!_&&!g&&B()},[]),a.useEffect(()=>{k&&g&&R&&(E(null),y(!1),R(e).then(H=>{H!=null&&(E(H),x(e.eventId,H)),y(!0)}).catch(()=>{y(!0)}))},[k]);const z=a.useCallback(()=>{m(M===c?void 0:M),i(e.eventId),!o&&P===null&&!O&&B()},[c,M,m,i,e.eventId,o,P,O,B]),ee=O?e.eventData:P,V=W?.3:1;return t.jsxs("div",{"data-event-id":e.eventId,onMouseEnter:()=>f(M),onMouseLeave:()=>f(void 0),children:[t.jsxs("div",{role:"button",tabIndex:0,onClick:z,onKeyDown:H=>{(H.key==="Enter"||H.key===" ")&&z()},className:"w-full text-left flex items-center gap-0 text-[13px] hover:bg-[var(--ds-gray-alpha-100)] transition-colors cursor-pointer",style:{minHeight:40},children:[t.jsx(lr,{isFirst:s,isLast:n&&!o,isRunLevel:$,statusDotColor:S,pulse:K,hasSelection:F,showBranch:J,showLaneLine:X,isLaneStart:j,isLaneEnd:D}),t.jsxs("div",{className:"flex items-center flex-1 min-w-0",style:{opacity:V,transition:"opacity 150ms"},children:[t.jsx("div",{className:"flex items-center justify-center w-5 h-5 flex-shrink-0 rounded",style:{border:"1px solid var(--ds-gray-400)"},children:t.jsx(Kt,{className:"h-3 w-3 transition-transform",style:{color:"var(--ds-gray-900)",transform:o?"rotate(90deg)":"rotate(0deg)"}})}),t.jsx("div",{className:"tabular-nums min-w-0 px-4",style:{color:"var(--ds-gray-900)",flex:"2 1 0%"},children:t.jsx(Yr,{date:I,children:t.jsx("span",{children:io(I)})})}),t.jsx("div",{className:"font-medium min-w-0 px-4",style:{flex:"2 1 0%"},children:t.jsxs("span",{className:"inline-flex items-center gap-1.5",style:{color:"var(--ds-gray-900)"},children:[t.jsxs("span",{style:{position:"relative",display:"inline-flex",width:6,height:6,flexShrink:0},children:[K&&t.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:S,opacity:.75,animation:Jr}}),t.jsx("span",{style:{position:"relative",width:6,height:6,borderRadius:"50%",backgroundColor:S}})]}),Qr(e.eventType)]})}),t.jsx("div",{className:"min-w-0 px-4 overflow-hidden text-ellipsis whitespace-nowrap",style:{flex:"2 1 0%"},title:L!=="-"?L:void 0,children:L}),t.jsx(cr,{value:e.correlationId||"",className:"font-mono",style:{flex:"3 1 0%"}}),t.jsx(cr,{value:e.eventId,className:"font-mono",style:{flex:"3 1 0%"}})]})]}),o&&t.jsxs("div",{className:"flex",children:[t.jsx(lr,{isFirst:!1,isLast:n,isRunLevel:$,hasSelection:F,showBranch:!1,showLaneLine:X&&!D,isLaneStart:!1,isLaneEnd:!1,continuationOnly:!0}),t.jsx("div",{className:"w-5 flex-shrink-0"}),t.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:V,transition:"opacity 150ms"},children:[((b==null?void 0:b.queued)!==void 0||(b==null?void 0:b.ran)!==void 0)&&t.jsxs("div",{className:"px-2 pb-1.5 text-xs flex gap-3",style:{color:"var(--ds-gray-900)"},children:[b.queued!==void 0&&b.queued>0&&t.jsxs("span",{children:["Queued for"," ",t.jsx("span",{className:"font-mono tabular-nums",children:sr(b.queued)})]}),b.ran!==void 0&&t.jsxs("span",{children:["Ran for"," ",t.jsx("span",{className:"font-mono tabular-nums",children:sr(b.ran)})]})]}),ee!=null?t.jsx(po,{data:ee,eventType:e.eventType}):N?t.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:N}):_||!O&&!g&&e.correlationId?t.jsxs("div",{className:"flex flex-col gap-2 p-3",children:[t.jsx(Q,{className:"h-3",style:{width:"75%"}}),t.jsx(Q,{className:"h-3",style:{width:"50%"}}),t.jsx(Q,{className:"h-3",style:{width:"60%"}})]}):t.jsx("div",{className:"p-2 text-xs",style:{color:"var(--ds-gray-900)"},children:"No data"})]})]})]})}function go({events:e,run:r,onLoadEventData:s,hasMoreEvents:n=!1,isLoadingMoreEvents:o=!1,onLoadMoreEvents:i,encryptionKey:l,isLoading:c=!1,sortOrder:u,onSortOrderChange:d,onDecrypt:p,isDecrypting:h=!1}){const[m,f]=a.useState("asc"),R=u??m,C=a.useCallback(V=>{d?d(V):f(V)},[d]),x=a.useMemo(()=>{if(!e||e.length===0)return[];const V=R==="desc"?-1:1;return[...e].sort((H,Y)=>V*(new Date(H.createdAt).getTime()-new Date(Y.createdAt).getTime()))},[e,R]),k=a.useMemo(()=>{if(!e)return!1;for(const V of e){const H=V.eventData;if(Ht(H))return!0}return!1},[e]),[v,_]=a.useState(!1),T=a.useCallback(()=>{_(!0)},[]),P=k||v,{correlationNameMap:E,workflowName:N}=a.useMemo(()=>co(e??null,r??null),[e,r]),w=a.useMemo(()=>uo(x),[x]),[g,y]=a.useState(void 0),[M,S]=a.useState(void 0),I=a.useCallback(V=>{y(V)},[]),O=a.useCallback(V=>{S(V)},[]),$=g??M,[L,A]=a.useState(()=>new Set),b=a.useCallback(V=>{A(H=>{const Y=new Set(H);return Y.has(V)?Y.delete(V):Y.add(V),Y})},[]),F=a.useRef(new Map),U=a.useCallback((V,H)=>{F.current.set(V,H)},[]),W=a.useMemo(()=>{const V=new Map;for(const H of x){const Y=jt(H.eventType)?"__run__":H.correlationId??"";Y&&V.set(H.eventId,Y)}return V},[x]);a.useEffect(()=>{g!==void 0&&A(V=>{if(V.size===0)return V;let H=!1;const Y=new Set;for(const Z of V)W.get(Z)===g?Y.add(Z):H=!0;return H?Y:V})},[g,W]);const K=a.useMemo(()=>{if(!$||$==="__run__")return null;let V=-1,H=-1;for(let Y=0;Y<x.length;Y++)x[Y].correlationId===$&&(V===-1&&(V=Y),H=Y);return V>=0?{first:V,last:H}:null},[$,x]),[J,X]=a.useState(""),j=a.useRef(null),D=a.useMemo(()=>{const V=[];for(let H=0;H<x.length;H++){const Y=x[H],Z=jt(Y.eventType),se=Z?N??"":Y.correlationId?E.get(Y.correlationId)??"":"";V.push({fields:[Y.eventId,Y.correlationId??"",Y.eventType,Qr(Y.eventType),se].map(oe=>oe.toLowerCase()),groupKey:Y.correlationId??(Z?"__run__":void 0),eventId:Y.eventId,index:H})}return V},[x,E,N]);a.useEffect(()=>{var Z;const V=J.trim().toLowerCase();if(!V){y(void 0);return}let H=null,Y=0;for(const se of D)for(const oe of se.fields)if(oe&&oe.includes(V)){const fe=V.length/oe.length;fe>Y&&(Y=fe,H=se)}H&&(y(H.groupKey),(Z=j.current)==null||Z.scrollToIndex({index:H.index,align:"center",behavior:"smooth"}))},[J,D]);const B=a.useRef(!1);x.length>0&&(B.current=!0);const z=c&&!B.current,ee=c&&B.current&&x.length===0;return z?t.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[t.jsx("div",{style:{padding:6},children:t.jsx(Q,{style:{height:40,borderRadius:6}})}),t.jsxs("div",{className:"flex items-center gap-0 h-10 border-b flex-shrink-0",style:{borderColor:"var(--ds-gray-alpha-200)"},children:[t.jsx("div",{className:"flex-shrink-0",style:{width:tt}}),t.jsx("div",{className:"w-5 flex-shrink-0"}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:t.jsx(Q,{className:"h-3",style:{width:40}})}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:t.jsx(Q,{className:"h-3",style:{width:72}})}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:t.jsx(Q,{className:"h-3",style:{width:44}})}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"3 1 0%"},children:t.jsx(Q,{className:"h-3",style:{width:92}})}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"3 1 0%"},children:t.jsx(Q,{className:"h-3",style:{width:60}})})]}),t.jsx(dr,{})]}):!c&&(!e||e.length===0)?t.jsx("div",{className:"flex items-center justify-center h-full text-sm",style:{color:"var(--ds-gray-700)"},children:"No events found"}):t.jsxs("div",{className:"h-full flex flex-col overflow-hidden",children:[t.jsx("style",{children:"@keyframes workflow-dot-pulse{0%{transform:scale(1);opacity:.7}70%,100%{transform:scale(2.2);opacity:0}}"}),t.jsxs("div",{style:{padding:6,backgroundColor:"var(--ds-background-100)",display:"flex",gap:6},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",justifyContent:"center",borderRadius:6,boxShadow:"0 0 0 1px var(--ds-gray-alpha-400)",background:"var(--ds-background-100)",height:40,flex:1,minWidth:0},children:[t.jsx("div",{style:{width:40,height:40,display:"flex",alignItems:"center",justifyContent:"center",color:"var(--ds-gray-800)",flexShrink:0},children:t.jsxs("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:[t.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M11.5 11.5L14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}),t.jsx("input",{type:"search",placeholder:"Search by name, event type, or ID…",value:J,onChange:V=>X(V.target.value),style:{marginLeft:-16,paddingInline:12,fontFamily:"inherit",fontSize:14,background:"transparent",border:"none",outline:"none",height:40,width:"100%"}})]}),t.jsx(Qn,{options:ho,value:R,onChange:C}),(P||l)&&p&&t.jsx(Yt,{decrypted:!!l,loading:h,onClick:p})]}),t.jsxs("div",{className:"flex items-center gap-0 text-[13px] font-medium h-10 border-b flex-shrink-0",style:{borderColor:"var(--ds-gray-alpha-200)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:[t.jsx("div",{className:"flex-shrink-0",style:{width:tt}}),t.jsx("div",{className:"w-5 flex-shrink-0"}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:"Time"}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:"Event Type"}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"2 1 0%"},children:"Name"}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"3 1 0%"},children:"Correlation ID"}),t.jsx("div",{className:"min-w-0 px-4",style:{flex:"3 1 0%"},children:"Event ID"})]}),ee?t.jsx(dr,{}):t.jsx(xn,{ref:j,totalCount:x.length,overscan:20,defaultItemHeight:40,endReached:()=>{!n||o||i==null||i()},itemContent:V=>{const H=x[V];return t.jsx(xo,{event:H,index:V,isFirst:V===0,isLast:V===x.length-1,isExpanded:L.has(H.eventId),onToggleExpand:b,activeGroupKey:$,selectedGroupKey:g,selectedGroupRange:K,correlationNameMap:E,workflowName:N,durationMap:w,onSelectGroup:I,onHoverGroup:O,onLoadEventData:s,cachedEventData:F.current.get(H.eventId)??null,onCacheEventData:U,encryptionKey:l,onEncryptedDataDetected:T})},style:{flex:1,minHeight:0}}),t.jsxs("div",{className:"relative flex-shrink-0 flex items-center h-10 border-t px-4 text-xs",style:{borderColor:"var(--ds-gray-alpha-200)",color:"var(--ds-gray-900)",backgroundColor:"var(--ds-background-100)"},children:[t.jsxs("span",{children:[x.length," event",x.length!==1?"s":""," loaded"]}),n&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center pointer-events-none",children:t.jsx("div",{className:"pointer-events-auto",children:t.jsx(Xn,{loading:o,onClick:()=>void(i==null?void 0:i())})})})]})]})}function yo({messages:e}){return e.length===0?t.jsx("div",{className:"text-center py-8 text-[11px]",style:{color:"var(--ds-gray-600)"},children:"No messages"}):t.jsx("div",{className:"flex flex-col gap-3 p-3",children:e.map((r,s)=>t.jsx(vo,{message:r},s))})}function vo({message:e}){const r=e.role,s=jo(e.content),n=bo(r);return t.jsxs("div",{className:"rounded-md border text-[11px]",style:{backgroundColor:n.bg,borderColor:n.border},children:[t.jsx("div",{className:"px-2.5 py-1 border-b text-[10px] font-medium uppercase tracking-wide",style:{borderColor:n.border,color:n.label},children:r}),t.jsx("div",{className:"px-2.5 py-2 space-y-2",children:s.map((o,i)=>t.jsx(wo,{part:o,role:r},i))})]})}function wo({part:e,role:r}){return e.type==="text"?e.text?r==="assistant"?t.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:t.jsx(gn,{children:e.text})}):t.jsx("div",{className:"whitespace-pre-wrap break-words",style:{color:"var(--ds-gray-1000)"},children:e.text}):null:e.type==="tool-call"?t.jsxs("div",{className:"rounded border px-2 py-1.5",style:{backgroundColor:"var(--ds-purple-100)",borderColor:"var(--ds-purple-300)"},children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium",children:[t.jsx("span",{children:"🔧"}),t.jsx("span",{style:{color:"var(--ds-purple-900)"},children:e.toolName})]}),e.input!=null&&t.jsx("div",{className:"mt-1.5 overflow-x-auto p-1.5 rounded",style:{backgroundColor:"var(--ds-gray-100)"},children:typeof e.input=="string"?t.jsx("pre",{className:"text-[10px]",style:{color:"var(--ds-gray-800)"},children:e.input}):t.jsx(vt,{data:e.input})})]}):e.type==="tool-result"?t.jsxs("div",{className:"rounded border px-2 py-1.5",style:{backgroundColor:"var(--ds-green-100)",borderColor:"var(--ds-green-300)"},children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-[10px] font-medium",children:[t.jsx("span",{children:"✓"}),t.jsxs("span",{style:{color:"var(--ds-green-900)"},children:[e.toolName," result"]})]}),e.output!=null&&t.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"?t.jsx("pre",{className:"text-[10px]",style:{color:"var(--ds-gray-800)"},children:e.output}):t.jsx(vt,{data:e.output,expandLevel:1})})]}):null}function bo(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 jo(e){return typeof e=="string"?[{type:"text",text:e}]:Array.isArray(e)?e.map(r=>typeof r=="string"?{type:"text",text:r}:(r==null?void 0:r.type)==="text"?{type:"text",text:String(r.text??"")}:(r==null?void 0:r.type)==="tool-call"?{type:"tool-call",toolName:r.toolName,input:r.input}:(r==null?void 0:r.type)==="tool-result"?{type:"tool-result",toolName:r.toolName,output:r.output}:{type:"text",text:""}):[]}const ko=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 es({data:e}){const r=Ue();return t.jsxs("div",{className:"relative overflow-x-auto rounded-md border p-3 pt-9",style:{borderColor:"var(--ds-gray-300)"},children:[t.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(ko(e)).then(()=>{r.success("Copied to clipboard")}).catch(()=>{r.error("Failed to copy")})},children:t.jsx(rt,{size:12})}),t.jsx(vt,{data:e})]})}function ie({summary:e,children:r,onToggle:s,disabled:n=!1,summaryClassName:o,contentClassName:i}){return n?t.jsx("div",{className:`rounded-md border px-2.5 py-1.5 text-xs ${o??""}`,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)",cursor:"not-allowed",opacity:.8},children:e}):t.jsxs("details",{className:"group",onToggle:l=>s==null?void 0:s(l.target.open),children:[t.jsx("summary",{className:`cursor-pointer rounded-md border px-2.5 py-1.5 text-xs hover:brightness-95 [&::-webkit-details-marker]:hidden ${o??""}`,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-900)",listStyle:"none"},children:t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx(Kt,{size:14,className:"shrink-0 transition-transform group-open:rotate-90"}),e]})}),t.jsxs("div",{className:`relative pl-6 mt-3 ${i??""}`,children:[t.jsx("div",{className:"absolute left-3 -top-3 w-px h-3",style:{backgroundColor:"var(--ds-gray-400)"}}),t.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)"}}),t.jsx("div",{className:"absolute left-6 top-3 w-0 h-px -translate-y-px",style:{backgroundColor:"var(--ds-gray-400)"}}),t.jsx("div",{children:r})]})]})}function No({active:e,onClick:r,children:s}){return t.jsx("button",{type:"button",role:"tab","aria-selected":e,tabIndex:e?0:-1,onClick:r,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:s})}function Co({tabs:e,activeTab:r,onTabChange:s,ariaLabel:n,children:o}){const i=a.useCallback(l=>{if(l.key!=="ArrowRight"&&l.key!=="ArrowLeft")return;l.preventDefault();const c=e.findIndex(d=>d.id===r),u=l.key==="ArrowRight"?(c+1)%e.length:(c-1+e.length)%e.length;s(e[u].id)},[e,r,s]);return t.jsxs("div",{className:"rounded-md border",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:[t.jsx("div",{className:"flex gap-1 border-b",role:"tablist","aria-label":n,onKeyDown:i,style:{borderColor:"var(--ds-gray-300)",backgroundColor:"transparent"},children:e.map(l=>t.jsx(No,{active:r===l.id,onClick:()=>s(l.id),children:l.label},l.id))}),t.jsx("div",{role:"tabpanel",children:o})]})}const Eo=[{id:"conversation",label:"Conversation"},{id:"json",label:"Raw JSON"}];function So({conversation:e,args:r}){const[s,n]=a.useState("conversation");return t.jsx(ie,{summary:`Input (${e.length} messages)`,children:t.jsx(Co,{tabs:Eo,activeTab:s,onTabChange:n,ariaLabel:"Conversation view",children:s==="conversation"?t.jsx(yo,{messages:e}):t.jsx("div",{className:"p-3",children:Array.isArray(r)?r.map((o,i)=>t.jsx("div",{className:"mt-2 first:mt-0",children:le(o)},i)):le(r)})})})}function Ze(){return t.jsxs("div",{className:"flex items-center gap-1.5 rounded-md border px-3 py-2 text-xs",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)"},children:[t.jsx(Vr,{className:"h-3 w-3"}),t.jsx("span",{className:"font-medium",children:"Encrypted"})]})}function Ye(){return t.jsx("div",{className:"flex items-center gap-1.5 rounded-md border px-3 py-2 text-xs",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)"},children:t.jsx("span",{className:"font-medium",children:"Data expired"})})}function le(e){return t.jsx(es,{data:e})}const be=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,ur=["workflowName","moduleSpecifier","stepName","status","stepId","hookId","eventId","runId","attempt","token","receivedCount","lastReceivedAt","disposedAt","correlationId","eventType","deploymentId","specVersion","workflowCoreVersion","ownerId","projectId","environment","executionContext","createdAt","startedAt","updatedAt","completedAt","expiredAt","retryAfter","error","metadata","eventData","input","output","resumeAt"],Lt=(e,r)=>{const s=ur.indexOf(e)||0,n=ur.indexOf(r)||0;return s-n},Io={workflowCoreVersion:"@workflow/core version",receivedCount:"times resolved"},To=e=>Io[e]??e,Ro=e=>{const r=String(e),s=st(r);if(s)return s.moduleSpecifier;const n=ze(r);return n?n.moduleSpecifier:r},Xt=e=>{if(e==null)return null;if(e instanceof Date)return Number.isNaN(e.getTime())?null:e;if(typeof e=="string"&&e.trim().length===0)return null;const r=typeof e=="number"?new Date(e):new Date(String(e));return Number.isNaN(r.getTime())?null:r},Jt=e=>e.toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}),Ao=e=>{const r=Xt(e);return r?Jt(r):"-"},fr=e=>{const r=Xt(e);return r?Jt(r):null},Me=e=>{const r=Xt(e);return r?t.jsx(Yr,{date:r,children:t.jsx("span",{children:Jt(r)})}):null},Je={workflowName:e=>{var r;return((r=ze(String(e)))==null?void 0:r.shortName)??"?"},moduleSpecifier:e=>Ro(e),stepName:e=>{var r;return((r=st(String(e)))==null?void 0:r.shortName)??"?"},runId:e=>String(e),stepId:e=>String(e),hookId:e=>String(e),eventId:e=>String(e),status:e=>String(e),attempt:e=>String(e),token:e=>String(e),isWebhook:e=>String(e),receivedCount:e=>String(e),lastReceivedAt:fr,disposedAt:fr,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:Me,startedAt:Me,updatedAt:Me,completedAt:Me,expiredAt:Me,retryAfter:Me,resumeAt:Me,metadata:e=>be(e)?ye(e)?t.jsx(Ze,{}):Le(e)?t.jsx(Ye,{}):le(e):null,input:(e,r)=>{if(ye(e))return t.jsx(Ze,{});if(Le(e))return t.jsx(Ye,{});if(e&&typeof e=="object"&&"args"in e){const{args:o,closureVars:i,thisVal:l}=e,c=Array.isArray(o)?o.length:0,u=c===1?"argument":"arguments",d=be(i),p=be(l),h=be(o);if(r!=null&&r.stepName&&vn(r.stepName)){const m=wn(o);if(m&&m.length>0)return t.jsxs(t.Fragment,{children:[t.jsx(So,{conversation:m,args:o}),d&&t.jsx(ie,{summary:"Closure Variables",children:le(i)}),p&&t.jsx(ie,{summary:"This Value",children:le(l)})]})}return!h&&!d&&!p?t.jsx(ie,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"}):t.jsxs(t.Fragment,{children:[t.jsx(ie,{summary:`Input (${c} ${u})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(o)?o.map((m,f)=>t.jsx("div",{className:"mt-2 first:mt-0",children:le(m)},f)):le(o)}),d&&t.jsx(ie,{summary:"Closure Variables",children:le(i)}),p&&t.jsx(ie,{summary:"this",children:le(l)})]})}const s=Array.isArray(e)?e.length:0,n=s===1?"argument":"arguments";return be(e)?t.jsx(ie,{summary:`Input (${s} ${n})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(e)?e.map((o,i)=>t.jsx("div",{className:"mt-2 first:mt-0",children:le(o)},i)):le(e)}):t.jsx(ie,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"})},output:e=>be(e)?ye(e)?t.jsx(Ze,{}):Le(e)?t.jsx(Ye,{}):t.jsx(ie,{summary:"Output",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:le(e)}):null,error:e=>ye(e)?t.jsx(Ze,{}):Le(e)?t.jsx(Ye,{}):be(e)?et(e)?t.jsx(ie,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:t.jsx(bt,{value:e})}):t.jsx(ie,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:le(e)}):null,eventData:e=>ye(e)?t.jsx(Ze,{}):Le(e)?t.jsx(Ye,{}):be(e)?t.jsx(ie,{summary:"Event Data",children:le(e)}):null},mr=["input","output","error","metadata","eventData"],Do=()=>t.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:t.jsx("span",{children:"The data for this run has expired and is no longer available."})}),Mo=({attribute:e,value:r,isLoading:s,inline:n=!1,context:o})=>{if(s&&(e==="input"||e==="output"||e==="eventData")&&!be(r))return t.jsxs("div",{className:`my-2 flex flex-col ${e==="input"||e==="output"?"gap-2 my-3.5":"gap-0"}`,children:[t.jsx("span",{className:`${e==="input"||e==="output"?"text-base":"text-xs"} font-medium first-letter:uppercase`,style:{color:"var(--ds-gray-700)"},children:e}),t.jsx(Q,{className:"h-9 w-full rounded-md"})]});const l=Je[e];if(!l)return null;const c=l(r,o);return c?n?t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-medium",style:{color:"var(--ds-gray-700)"},children:e}),t.jsx("span",{className:"text-[11px]",style:{color:"var(--ds-gray-1000)"},children:c})]}):t.jsxs("div",{className:"relative",children:[typeof s=="boolean"&&s&&t.jsx("div",{className:"absolute top-9 right-4",children:t.jsx("div",{className:"animate-spin rounded-full h-4 w-4 border-b-2",style:{borderColor:"var(--ds-gray-900)"}})}),t.jsxs("div",{className:`my-2 flex flex-col ${e==="input"||e==="output"||e==="error"?"gap-2 my-3.5":"gap-0"}`,children:[t.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}),t.jsx("span",{className:"text-xs",style:{color:"var(--ds-gray-1000)"},children:c})]},e)]}):null},_o=({data:e,moduleSpecifier:r,isLoading:s,error:n,expiredAt:o,onStreamClick:i,resource:l})=>{const c=Ue(),u=a.useMemo(()=>{const x={...e},k=e.executionContext;return k!=null&&k.workflowCoreVersion&&(x.workflowCoreVersion=k.workflowCoreVersion),r?x.moduleSpecifier=r:typeof e.stepName=="string"?x.moduleSpecifier=e.stepName:typeof e.workflowName=="string"&&(x.moduleSpecifier=e.workflowName),x},[e,r]),d=o!=null&&new Date(o)<new Date,p=Object.keys(u).filter(x=>!mr.includes(x)).sort(Lt),h=a.useMemo(()=>{const x=Object.keys(u).filter(v=>mr.includes(v)).sort(Lt);if(!s)return x;const k=["input","output"];for(const v of k)x.includes(v)||x.push(v);return x.sort(Lt)},[u,s]),m=p.filter(x=>{const k=Je[x];return k?k(u[x])!==null:!1}),f=a.useMemo(()=>{const x=[...m],k=x.indexOf("moduleSpecifier");if(k===-1)return x;x.splice(k,1);const v=x.indexOf("workflowName");if(v!==-1)return x.splice(v+1,0,"moduleSpecifier"),x;const _=x.indexOf("stepName");return _!==-1?(x.splice(_+1,0,"moduleSpecifier"),x):(x.unshift("moduleSpecifier"),x)},[m]),R=a.useMemo(()=>({stepName:u.stepName}),[u.stepName]),C=a.useCallback(x=>{navigator.clipboard.writeText(x).then(()=>{c.success("moduleSpecifier copied")}).catch(()=>{c.error("Failed to copy moduleSpecifier")})},[]);return t.jsx(yn.Provider,{value:i,children:t.jsxs("div",{children:[m.length>0&&t.jsxs("div",{className:"mb-3 flex flex-col overflow-hidden rounded-lg border",style:{borderColor:"var(--ds-gray-300)"},children:[f.map((x,k)=>{var w;const v=(w=Je[x])==null?void 0:w.call(Je,u[x]),_=x==="moduleSpecifier",T=typeof v=="string"?v:String(v??u.moduleSpecifier??""),P=x!=="workflowCoreVersion",E=s&&l==="sleep"&&!u.resumeAt,N=k<f.length-1||E;return t.jsxs("div",{className:"py-1",children:[t.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 rounded-sm px-2.5 py-1",children:[t.jsx("span",{className:P?"text-[14px] first-letter:uppercase":"text-[14px]",style:{color:"var(--ds-gray-700)"},children:To(x)}),_?t.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:T,onClick:()=>C(T),children:T}):t.jsx("span",{className:"min-w-0 max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},children:v})]}),N?t.jsx("div",{className:"mx-2.5 border-b",style:{borderColor:"var(--ds-gray-300)"}}):null]},x)}),s&&l==="sleep"&&!u.resumeAt&&t.jsx("div",{className:"py-1",children:t.jsxs("div",{className:"flex min-h-[32px] items-center justify-between gap-4 rounded-sm px-2.5 py-1",children:[t.jsx("span",{className:"text-[14px] first-letter:uppercase",style:{color:"var(--ds-gray-700)"},children:"resumeAt"}),t.jsx(Q,{className:"h-4 w-[55%]"})]})})]}),n?t.jsx($r,{title:"Failed to load resource details",details:n.message,className:"my-4"}):d?t.jsx(Do,{}):t.jsx(t.Fragment,{children:h.map(x=>t.jsx(Mo,{isLoading:s,attribute:x,value:u[x],context:R},x))})]})})},Lo=new Set(["step_failed","step_retrying"]),Po=new Set(["step_created","step_completed","step_failed","step_retrying","hook_created","hook_received","run_created","run_completed","run_failed","wait_created","wait_completed"]);function Fo({event:e,onLoadEventData:r,encryptionKey:s}){const[n,o]=a.useState(null),[i,l]=a.useState(!1),[c,u]=a.useState(null),d=a.useRef(!1),p="eventData"in e&&e.eventData!=null?e.eventData:null,h=p??n,m=Po.has(e.eventType),f=a.useCallback(async()=>{if(!(!r||!e.correlationId||!e.eventId))try{l(!0),u(null);const x=await r(e.correlationId,e.eventId);o(x)}catch(x){u(x instanceof Error?x.message:String(x))}finally{l(!1)}},[r,e.correlationId,e.eventId]),R=a.useCallback(async()=>{p||n!==null||i||(d.current=!0,await f())},[p,n,i,f]);a.useEffect(()=>{s&&d.current&&n!==null&&(o(null),f())},[s]);const C=new Date(e.createdAt);return t.jsxs(ie,{summaryClassName:"text-base py-2",summary:t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"font-medium",style:{color:"var(--ds-gray-1000)"},children:e.eventType})," ","-"," ",t.jsx("span",{style:{color:"var(--ds-gray-700)"},children:Ao(C.getTime())})]}),onToggle:m?x=>{x&&R()}:void 0,children:[t.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:[t.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:[t.jsx("span",{className:"text-[14px]",style:{color:"var(--ds-gray-700)"},children:"eventId"}),t.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&&t.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:[t.jsx("span",{className:"text-[14px]",style:{color:"var(--ds-gray-700)"},children:"correlationId"}),t.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})]})]}),i&&t.jsxs("div",{className:"mt-2 rounded-md border p-3",style:{borderColor:"var(--ds-gray-300)"},children:[t.jsx(Q,{className:"h-4 w-[35%]"}),t.jsx(Q,{className:"mt-2 h-4 w-[90%]"}),t.jsx(Q,{className:"mt-2 h-4 w-[75%]"})]}),c&&t.jsx($r,{title:"Failed to load event data",details:c,className:"mt-2"}),h!=null&&t.jsx("div",{className:"mt-2",children:t.jsx($o,{eventType:e.eventType,data:h})})]})}function Oo(e){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const r=e,n=["result","input","output","metadata","payload"].filter(o=>o in r);return n.length>0&&n.every(o=>Le(r[o]))}function $o({eventType:e,data:r}){if(Le(r)||Oo(r))return t.jsx("div",{className:"flex items-center gap-1.5 rounded-md border px-3 py-2 text-xs",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)"},children:t.jsx("span",{className:"font-medium",children:"Data expired"})});if(Lo.has(e)&&r!=null&&typeof r=="object"){const s=r;if(et(s.error))return t.jsx(bt,{value:s.error});if(et(s))return t.jsx(bt,{value:s})}return t.jsx(es,{data:r})}function Wo({events:e,isLoading:r=!1,error:s,onLoadEventData:n,encryptionKey:o}){const i=a.useMemo(()=>[...e].sort((l,c)=>new Date(l.createdAt).getTime()-new Date(c.createdAt).getTime()),[e]);return t.jsxs("div",{className:"mt-2",style:{color:"var(--ds-gray-1000)"},children:[t.jsxs("h3",{className:"text-heading-16 font-medium mt-4 mb-2",style:{color:"var(--ds-gray-1000)"},children:["Events ",!r&&`(${i.length})`]}),r?t.jsxs("div",{className:"flex flex-col gap-4",children:[t.jsx(Q,{className:"h-9 w-full rounded-md"}),t.jsx(Q,{className:"h-9 w-full rounded-md"}),t.jsx(Q,{className:"h-9 w-full rounded-md"})]}):null,!r&&!s&&i.length===0&&t.jsx("div",{className:"text-sm",children:"No events found"}),i.length>0&&!s?t.jsx("div",{className:"flex flex-col gap-4",children:i.map(l=>t.jsx(Fo,{event:l,onLoadEventData:n,encryptionKey:o},l.eventId))}):null]})}function Ho(e){return e!==null&&typeof e=="object"&&"stepId"in e}function Bo(e){return e!==null&&typeof e=="object"&&"runId"in e}function pt(e){return e!==null&&typeof e=="object"&&"hookId"in e}function Vo({run:e,onStreamClick:r,spanDetailData:s,spanDetailError:n,spanDetailLoading:o,onSpanSelect:i,onWakeUpSleep:l,onLoadEventData:c,onResolveHook:u,encryptionKey:d,onDecrypt:p,isDecrypting:h=!1,selectedSpan:m}){const f=Ue(),[R,C]=a.useState(!1),[x,k]=a.useState(!1),[v,_]=a.useState(!1),[T,P]=a.useState(new Set),E=m==null?void 0:m.data,N=m==null?void 0:m.rawEvents,w=(N==null?void 0:N.length)??0,{resource:g,resourceId:y,runId:M}=a.useMemo(()=>{if(!m)return{resource:void 0,resourceId:void 0,runId:void 0};const D=m.resource;if(D==="step"&&Ho(E))return{resource:"step",resourceId:E.stepId,runId:E.runId};if(D==="run"&&Bo(E))return{resource:"run",resourceId:E.runId,runId:void 0};if(D==="hook"&&pt(E))return{resource:"hook",resourceId:E.hookId,runId:void 0};if(D==="sleep"){const B=E;return{resource:"sleep",resourceId:m.spanId,runId:B==null?void 0:B.runId}}return{resource:void 0,resourceId:void 0,runId:void 0}},[m,E]),S=a.useRef(i);S.current=i,a.useEffect(()=>{g&&y&&["run","step","hook","sleep"].includes(g)&&S.current({resource:g,resourceId:y,runId:M})},[g,y,M]);const I=a.useMemo(()=>g!=="sleep"||!N||["completed","failed","cancelled"].includes(e.status)||!N.some(ee=>ee.eventType==="wait_created")?!1:!N.some(ee=>ee.eventType==="wait_completed"),[g,N,w,e.status]),O=a.useMemo(()=>!(g!=="hook"||!N||!y||T.has(y)||["completed","failed","cancelled"].includes(e.status)||N.some(z=>z.eventType==="hook_disposed")),[g,y,N,w,e.status,T]),$=n??void 0,L=o??!1,A=a.useMemo(()=>{if(!s)return!1;const D=s;return ye(D.input)||ye(D.output)||ye(D.error)||ye(D.metadata)},[s]),b=a.useMemo(()=>{if(!(g!=="hook"||!y)){if(pt(s)&&s.token)return s.token;if(pt(E)&&E.token)return E.token}},[g,y,s,E]);a.useEffect(()=>{$&&m&&g&&f.error(`Failed to load ${g} details`,{description:$.message})},[$,g,m]);const F=async()=>{if(!(R||!y)){if(!l){f.error("Unable to wake up sleep",{description:"No wake-up handler provided."});return}try{C(!0),(await l(e.runId,y)).stoppedCount>0?f.success("Run woken up",{description:"The sleep call has been interrupted and the run woken up."}):f.info("Sleep already completed",{description:"This sleep call has already finished."})}catch(D){console.error("Failed to wake up run:",D),f.error("Failed to wake up run",{description:D instanceof Error?D.message:"An unknown error occurred"})}finally{C(!1)}}},U=a.useCallback(async D=>{if(!v){if(!u){f.error("Unable to resolve hook",{description:"No resolve handler provided."});return}if(!b){f.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{_(!0);const B=s??E,z=pt(B)?B:void 0;await u(b,D,z),f.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),k(!1),y&&P(ee=>new Set(ee).add(y))}catch(B){console.error("Failed to resolve hook:",B),f.error("Failed to resolve hook",{description:B instanceof Error?B.message:"An unknown error occurred"})}finally{_(!1)}}},[u,b,v,s,E]),W=s??E,K=a.useMemo(()=>{const D=W,B=D.stepName,z=D.workflowName;if(typeof B=="string")return B;if(typeof z=="string")return z;if(typeof e.workflowName=="string")return e.workflowName},[W,e.workflowName]);if(!m||!g||!y)return null;const J=g.charAt(0).toUpperCase()+g.slice(1),X=g==="sleep"&&I||g==="hook"&&O,j=e.completedAt?"Completed":"Live";return t.jsxs("div",{className:"flex h-full flex-col",children:[t.jsx("div",{className:"border-b px-3 py-3",style:{borderColor:"var(--ds-gray-200)"},children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.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:J}),t.jsx("span",{className:"text-[13px]",style:{color:e.completedAt?"var(--ds-gray-700)":"var(--ds-green-800)"},children:j})]}),t.jsx("p",{className:"mt-1 truncate font-mono text-[13px]",style:{color:"var(--ds-gray-700)"},title:y,children:y})]}),(A||d)&&p&&t.jsx(Yt,{decrypted:!!d,loading:h,onClick:p})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pt-3 pb-8",children:[X&&t.jsxs("div",{className:"mb-4 rounded-lg border p-2",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:[t.jsx("p",{className:"mb-2 px-1 text-[13px] font-medium uppercase tracking-wide",style:{color:"var(--ds-gray-700)"},children:"Actions"}),t.jsxs("div",{className:"flex flex-col gap-2",children:[g==="sleep"&&I&&t.jsxs("button",{type:"button",onClick:F,disabled:R,className:Pe("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",R?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-amber-200)",color:"var(--ds-amber-900)"},children:[t.jsx(Vs,{className:"h-4 w-4"}),R?"Waking up...":"Wake Up Sleep"]}),g==="hook"&&O&&t.jsxs("button",{type:"button",onClick:()=>k(!0),disabled:v,className:Pe("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",v?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-gray-1000)",color:"var(--ds-background-100)"},children:[t.jsx(Wr,{className:"h-4 w-4"}),"Resolve Hook"]})]})]}),t.jsxs("div",{className:"space-y-4",children:[t.jsxs("section",{children:[t.jsx("h3",{className:"mb-2 text-[13px] font-medium uppercase tracking-wide",style:{color:"var(--ds-gray-700)"},children:"Details"}),t.jsx(_o,{data:W,moduleSpecifier:K,expiredAt:e.expiredAt,isLoading:L,error:$??void 0,onStreamClick:r,resource:g})]}),g!=="run"&&N&&t.jsx("section",{children:t.jsx(Wo,{events:N,onLoadEventData:c,encryptionKey:d})})]})]}),t.jsx(Hr,{isOpen:x,onClose:()=>k(!1),onSubmit:U,isSubmitting:v})]})}function zo(e){const r=a.useRef(e);r.current=e,a.useEffect(()=>{let s=0,n=0;const o=()=>{r.current(s),s=0},i=l=>{if(!l.ctrlKey&&!l.metaKey)return;l.preventDefault();let c=-l.deltaY;switch(l.deltaMode){case WheelEvent.DOM_DELTA_PAGE:c*=window.innerHeight;break;case WheelEvent.DOM_DELTA_LINE:c*=20;break}s+=c,cancelAnimationFrame(n),n=requestAnimationFrame(o)};return window.addEventListener("wheel",i,{passive:!1}),()=>{window.removeEventListener("wheel",i),cancelAnimationFrame(n)}},[])}function pr(e){if(e<=0)return 1;const s=10**Math.floor(Math.log10(e)),n=e/s;return n<=1.5?s:n<=3.5?2*s:n<=7.5?5*s:10*s}function Uo({scale:e,isLive:r=!1}){const{state:{root:s}}=ve(),[,n]=a.useState(0);a.useEffect(()=>{if(!r)return;const m=setInterval(()=>n(f=>f+1),1e3);return()=>clearInterval(m)},[r]);const o=s.duration,i=e>0?e:o>0?1/o:1;let c=pr(50/i);c=Math.max(1,c);let u=c*i;const d=1e3;o/c>d&&(c=pr(o/d),u=c*i);const p=Math.ceil(o/c),h=Math.ceil(100/u)||1;return t.jsx("div",{className:G.markersContainer,children:t.jsx("div",{"aria-hidden":!0,className:G.markers,style:{width:Math.floor(s.duration*e+15),visibility:e!==-1?"visible":"hidden","--marker-width":`${u}px`},children:new Array(p).fill(null).map((m,f)=>{const R=f%h===0;return t.jsx("span",{className:Pe(G.marker,!R&&G.notch),children:R?t.jsxs("span",{className:G.markerLabel,children:[bn(c*f),t.jsx("span",{className:G.markerClockTime,children:jn(s.startTime+c*f)})]}):null},String(f))})})})}function Ko({events:e,root:r,scale:s}){const n=a.useMemo(()=>e.filter(o=>o.event.showVerticalLine!==!1),[e]);return t.jsx("div",{className:G.eventMarkersContainer,children:t.jsx("div",{"aria-hidden":!0,className:G.eventMarkers,style:{width:Math.floor(r.duration*s)},children:n.map(o=>t.jsx("span",{className:Pe(G.eventMarker),style:{left:Math.floor((o.timestamp-r.startTime)*s),...o.event.color&&{borderLeftColor:o.event.color}}},o.key))})})}const hr=2;function qo({memoCacheRef:e,timelineRef:r,root:s,spans:n,events:o,scale:i,dispatch:l,scrollSnapshotRef:c}){const u=a.useRef(!1),d=a.useRef(n);d.current=n;const p=a.useRef(o);p.current=o;const h=a.useRef(null),{style:m,setStyle:f}=At(h),R=a.useRef(null),C=a.useRef(null),{style:x,setStyle:k}=At(C),v=a.useRef(void 0),_=a.useRef(null),{style:T,setStyle:P}=At(_),E=a.useRef(0);a.useEffect(()=>{const w=r.current;if(!w)return;let g=E.current,y=0,M=!1,S=!1,I=!1,O=!1,$=0,L=0;const A=Date.now()+500,b=()=>{v.current||(v.current=w.getBoundingClientRect())},F=Z=>v.current?(Z-wt-ce)/(We+Se):0,U=()=>{const Z=e.current;for(const se of d.current)se.isHovered&&(se.isHovered=!1,Z.set(se.span.spanId,{}));l({type:"forceRender"})};let W=0;const K=()=>{var Ke,ot,at,xe,it,lt,ct,dt;if(!u.current)return;v.current||b();const Z=v.current;if(!Z)return;const{scrollLeft:se,scrollTop:oe}=w,fe=Math.max(0,Math.min(g+se-Z.left-ce,s.duration*i)),Oe=`${fe-se+ce}px`;k("left",Oe),f("left",Oe);const we=s.startTime+fe/i,Ce=we-s.startTime;if(Ce<0||Ce>s.duration?(Ke=R.current)==null||Ke.removeAttribute("data-text"):(ot=R.current)==null||ot.setAttribute("data-text",ft(Ce)),M){const Te=g-y,qe=Math.abs(Te);if(!I){if(qe<4)return;I=!0,P("display","flex"),U()}Te>0?(P("left",""),P("right","0")):(P("left","0"),P("right","")),P("width",`${qe}px`);const Re=Math.max(0,Math.min(y+se-Z.left-ce,s.duration*i))/i;let q,te;Re<Ce?(q=Re,te=Ce):(q=Ce,te=Re),(at=_.current)==null||at.setAttribute("data-range",`${ft(q)} — ${ft(te)}`),(xe=_.current)==null||xe.setAttribute("data-duration",`${ft(te-q)} selected`)}if(Date.now()<A){W=requestAnimationFrame(K);return}if(se!==$||oe!==L){$=se,L=oe,W=requestAnimationFrame(K);return}if(g-Z.left<128?(it=R.current)==null||it.setAttribute("data-align","left"):g-Z.left>Z.width-128?(lt=R.current)==null||lt.setAttribute("data-align","right"):(ct=R.current)==null||ct.removeAttribute("data-align"),!I&&!S){const Te=e.current,qe=F(oe)-hr,St=F(oe+Z.height)+hr;for(const re of d.current){const ae=re.row>=qe&&re.row<=St&&we>=re.startTime&&we<=re.endTime;re.isHovered!==ae&&(re.isHovered=ae,Te.set(re.span.spanId,{}))}const q=12/i;let te=null,ne=1/0;for(const re of p.current){const ae=Math.abs(re.timestamp-we);ae<=q&&ae<ne&&(ne=ae,te=re)}for(const re of p.current){const ae=re===te;if(re.isHovered===ae)continue;re.isHovered=ae;const Ge=(dt=re.ref)==null?void 0:dt.current;Ge&&Ge.setAttribute("data-hovered",String(ae))}l({type:"forceRender"})}};W=requestAnimationFrame(K);const J=Z=>{Z.pointerType==="mouse"&&(u.current=!0)},X=()=>{u.current&&(u.current=!1,U())},j=({clientX:Z})=>{g=Z,E.current=g,cancelAnimationFrame(W),W=requestAnimationFrame(K)},D=Z=>{Z.preventDefault()},B=Z=>{var se;if(Z.button===2)O=!0,Z.preventDefault();else{if(Z.button!==0)return;O=!1}(se=r.current)!=null&&se.contains(Z.target)?(y=g,M=!0):(S=!0,requestAnimationFrame(U))},z=Z=>{if(S=!1,!M||(M=!1,!I))return;if(I=!1,P("display",""),P("left",""),P("right",""),P("width",""),Z.preventDefault(),Z.stopImmediatePropagation(),O){O=!1;return}v.current||b();const se=v.current;if(!se)return;const{scrollLeft:oe}=w,fe=Math.max(0,Math.min((y+oe-se.left-ce)/i,s.duration)),Oe=Math.max(0,Math.min((g+oe-se.left-ce)/i,s.duration));l({type:"scaleToRange",t1:fe+s.startTime,t2:Oe+s.startTime})},ee=Z=>{M&&Z.key==="Escape"&&(O=!0,z(Z))},V=()=>{v.current=void 0,N.current=void 0,cancelAnimationFrame(W),W=requestAnimationFrame(K)},H=()=>{cancelAnimationFrame(W),W=requestAnimationFrame(K)},Y=new ResizeObserver(()=>{v.current=void 0});return Y.observe(w),window.addEventListener("mousemove",j),w.addEventListener("contextmenu",D),window.addEventListener("mousedown",B),window.addEventListener("mouseup",z),window.addEventListener("blur",z),window.addEventListener("keydown",ee,!0),window.addEventListener("scroll",V),w.addEventListener("scroll",H),w.addEventListener("pointerenter",J),w.addEventListener("pointerleave",X),()=>{Y.disconnect(),window.removeEventListener("mousemove",j),w.removeEventListener("contextmenu",D),window.removeEventListener("mousedown",B),window.removeEventListener("mouseup",z),window.removeEventListener("blur",z),window.removeEventListener("keydown",ee,!0),window.removeEventListener("scroll",V),w.removeEventListener("scroll",H),w.removeEventListener("pointerenter",J),w.removeEventListener("pointerleave",X),cancelAnimationFrame(W),E.current=g,U()}},[l,s,i,k,f,P,e,r,c]);const N=a.useRef(void 0);return zo(w=>{const g=r.current;if(!g)return;v.current??(v.current=g.getBoundingClientRect());const y=v.current,M=Math.max(0,Math.min(E.current-y.left-ce,y.width-2*ce));let S=0,I=N.current;(I==null?void 0:I.anchorX)===M?S=I.anchorT:(S=(g.scrollLeft+M)/i,I={anchorT:S,anchorX:M},N.current=I),l({type:"trackpadScale",delta:w/64,anchorT:S,anchorX:M})}),t.jsxs(t.Fragment,{children:[t.jsx("div",{className:G.cursorMarkerStickyParent,children:t.jsx("div",{className:G.cursorMarkerLabelContainer,ref:h,style:m,children:t.jsx("div",{className:G.cursorMarkerLabel,ref:R})})}),t.jsx("div",{className:G.cursorMarkerStickyParent,children:t.jsx("div",{className:G.cursorMarkerContainer,ref:C,style:x,children:t.jsx("div",{className:G.cursorMarker,children:t.jsx("div",{className:G.cursorSelection,ref:_,style:T})})})})]})}function Go({height:e,width:r,value:s,placeholder:n,onChange:o}){return t.jsxs("label",{className:G.searchInputLabel,children:[t.jsx("div",{className:G.searchInputPrefix,children:t.jsx(Zo,{})}),t.jsx("input",{type:"search",value:s,placeholder:n,onChange:o,style:{height:e,width:r}})]})}function Zo(){return t.jsxs("svg",{width:16,height:16,viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",focusable:"false",children:[t.jsx("circle",{cx:"7",cy:"7",r:"4.5",stroke:"currentColor",strokeWidth:"1.5"}),t.jsx("path",{d:"M11.5 11.5L14 14",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round"})]})}function Yo(){return t.jsx("nav",{className:G.searchBar,children:t.jsx(Xo,{})})}function Xo(){const{dispatch:e}=ve(),[r,s]=a.useState("");return a.useEffect(()=>{const n=setTimeout(()=>e({type:"setFilter",filter:r}),100);return()=>{clearTimeout(n)}},[e,r]),t.jsx("div",{className:G.searchInput,children:t.jsx(Go,{height:zr,onChange:n=>s(n.target.value),placeholder:"Search spans…",value:r,width:"100%"})})}function Jo({size:e=16}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[t.jsx("title",{children:"Zoom In"}),t.jsx("path",{d:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",stroke:"currentColor",strokeWidth:"2"}),t.jsx("path",{d:"M11 8v6M8 11h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),t.jsx("path",{d:"M20 20l-3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function Qo({size:e=16}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[t.jsx("title",{children:"Zoom Out"}),t.jsx("path",{d:"M11 19a8 8 0 1 0 0-16 8 8 0 0 0 0 16Z",stroke:"currentColor",strokeWidth:"2"}),t.jsx("path",{d:"M8 11h6",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"}),t.jsx("path",{d:"M20 20l-3.5-3.5",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function ea({size:e=16}){return t.jsxs("svg",{width:e,height:e,viewBox:"0 0 24 24",fill:"none","aria-hidden":!0,children:[t.jsx("title",{children:"Minus"}),t.jsx("path",{d:"M6 12h12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round"})]})}function ta(){const{dispatch:e}=ve(),r=a.useCallback(()=>{e({type:"adjustScaleRatio",direction:1})},[e]),s=a.useCallback(()=>{e({type:"adjustScaleRatio",direction:-1})},[e]),n=a.useCallback(()=>{e({type:"adjustScaleRatio",direction:0})},[e]);return t.jsxs("div",{className:G.zoomButtonGroup,children:[t.jsx("button",{"aria-label":"Zoom Out",className:G.zoomButton,onClick:s,type:"button",children:t.jsx(Qo,{size:18})}),t.jsx("div",{className:G.divider}),t.jsx("button",{"aria-label":"Reset Zoom",className:G.zoomButton,onClick:n,type:"button",children:t.jsx(ea,{size:18})}),t.jsx("div",{className:G.divider}),t.jsx("button",{"aria-label":"Zoom In",className:G.zoomButton,onClick:r,type:"button",children:t.jsx(Jo,{size:18})})]})}const ra=e=>{const{spans:r}=e,s={startTime:0,endTime:0,duration:0,depth:0,children:[]},n={},o=new Map,i=h=>{const m=o.get(h);if(m)return m;const f=o.size+1;return o.set(h,f),f};let l=!1;for(const h of r){const m=Xe(h.startTime),f=Xe(h.endTime),R=Xe(h.duration);f>s.endTime&&(s.endTime=f,s.duration=f-s.startTime),(s.startTime===0||m<s.startTime)&&(s.startTime=m,s.duration=s.endTime-m);const C=h.resource.startsWith("vercel.");C||(l=!0);const x=C&&(h.resource!=="vercel.serverless-runtime"||!("http.method"in h.attributes)),k=x?0:i(h.resource);let v;x&&(v=`▲ ${h.name}`),n[h.spanId]={parent:null,startTime:m,endTime:f,duration:R,span:h,depth:0,label:v,events:sa(h),isVercel:x,children:[],resourceIndex:k,activeStartTime:h.activeStartTime?Xe(h.activeStartTime):void 0}}const c=(h,m)=>{let f;m?(f=n[m],f||(f=s)):f=s,h.parent=f,f.children.push(h)},u=h=>{"parent"in h&&(h.depth=h.parent.depth+1);for(const m of h.children)u(m)};let d=1;const p=(h,m)=>{if("parent"in h&&h.span.name===m){let f=h.endTime;const R=E=>E.children.length?E.children.map(R).sort((N,w)=>N.duration-w.duration)[0]||E:E.span.name==="waitUntil"?(f=E.startTime,E.parent):E,C=R(h),x=`instrumentation-hint-${d++}`,k=h.duration*.05,v=h.startTime+k,_=Math.max(v+k,Math.min(f-h.duration*.01,h.endTime-k)),T=_-v,P={parent:C,startTime:v,endTime:_,duration:T,span:{spanId:x,name:"Add your spans here",resource:"",kind:0,library:{name:""},status:{code:200},traceFlags:0,attributes:{},links:[],events:[],startTime:Dt(v),endTime:Dt(_),duration:Dt(T)},depth:h.depth+1,isVercel:!1,isInstrumentationHint:!0,children:[],resourceIndex:1};return C.children.push(P),n[x]=P,!0}for(const f of h.children)if(p(f,m))return!0;return!1};for(const h of Object.values(n))c(h,h.span.parentSpanId);if(u(s),!l){for(const h of["Invoke Function","Invoke Middleware","Vercel Runtime"])if(p(s,h))break}return{root:s,map:n}},sa=e=>{if(!e.events.length)return;const r=`${e.spanId}:ev`;return e.events.map((s,n)=>({key:`${r}${n}`,timestamp:Xe(s.timestamp),event:s})).sort((s,n)=>s.timestamp-n.timestamp)},xr=(e,r)=>(e.isVisible=!0,e.isHovered=!1,e.isVisible);function Pt(){return[]}const na=(e,r=!1)=>{const{state:s,dispatch:n}=ve(),{root:o,filter:i,scale:l,timelineRef:c,timelineWidth:u,spanMap:d,scrollSnapshotRef:p,selected:h,memoCacheRef:m}=s,f=oa(s.timelineHeight),R=a.useRef(0),[C,x]=a.useState(Pt),[k,v]=a.useState(Pt),[_,T]=a.useState(Pt),[P,E]=a.useState(-1),N=a.useRef(void 0);return a.useEffect(()=>{var w;return(w=N.current)==null?void 0:w.call(N,i)},[i]),a.useEffect(()=>{if(e!=null&&e.length){for(const w of C)for(const g of w){const y=e.includes(g.span.spanId);g.isHighlighted!==y&&(g.isHighlighted=y,m.current.set(g.span.spanId,{}))}n({type:"forceRender"})}},[C,e,n,m]),a.useEffect(()=>{if(!o.startTime)return;const w=new Worker(new URL("/assets/worker-D-HfgUMl.js",import.meta.url),{type:"module"});let g=++R.current;const y=S=>{var O;const I=S.data;switch(I.type){case"setRowsResult":{if((I==null?void 0:I.requestId)!==g)return;if(I.isEnd)for(const $ of I.rows)for(const L of $)L.span=((O=d[L.span.spanId])==null?void 0:O.span)??L.span;x(I.rows);break}case"updateHighlight":{if((I==null?void 0:I.requestId)!==g)return;const{matches:$}=I;x(L=>{for(const A of L)for(const b of A){const F=$.has(b.span.spanId);b.isHighlighted!==F&&(b.isHighlighted=F,m.current.set(b.span.spanId,{}))}return L}),n({type:"forceRender"});break}}};w.addEventListener("message",y);const M={requestId:g,type:"calculateSpanPositions",root:o};return w.postMessage(M),N.current=S=>{const I=S.trim().toLocaleLowerCase();if(!I){x($=>$.map(L=>L.map(A=>(A.isHighlighted=void 0,{...A}))));return}g=++R.current;const O={type:"filterSpans",requestId:g,root:o,filter:I};w.postMessage(O)},()=>{w.terminate()}},[o,d,n,m]),a.useEffect(()=>{if(!C.length)return;if(r){const j=[],D=[];for(const B of C)for(const z of B)xr(z)&&(j.push(z),z.events&&D.push(...z.events));v(j),T(D),E(l);return}const w=c.current;let g=p.current,y=!1,M=!1,S=0,I=0;const O=Math.max(500,u*.5),$=new Array(C.length).fill(null),L=()=>{M=!0;const j=Math.min(1+I+Math.ceil((g==null?void 0:g.endRow)??Number.POSITIVE_INFINITY),C.length);for(let D=j;D--;){if($[D])continue;const B=A(D);if(Math.abs(B)>I){if(M=!1,B>0)continue;break}const z=[],ee=C[D];if(ee){for(const V of ee){if(!xr(V))continue;const H=b(V);S=Math.max(H,S),z.push({d:H,span:V})}$[D]=z}}},A=j=>g?j<g.startRow?j-g.startRow:j>g.endRow?j-g.endRow:0:0,b=j=>{if(!g)return 0;let D=0;j.endTime<g.startTime?D=g.startTime-j.endTime:j.startTime>g.endTime&&(D=j.startTime-g.endTime);const B=Math.abs(A(j.row));return!D&&!B?0:Math.sqrt((D/l)**2+(B*We+Se)**2)},F=()=>{if(!w)return;const{scrollLeft:j,scrollTop:D}=w,B=0,z=j/l,ee=(D-wt-ce)/(We+Se),V=ee+Math.ceil(f/(We+Se));g={anchorT:z,anchorX:B,scrollLeft:j,scrollTop:D,startTime:o.startTime+j/l,endTime:o.startTime+(j+u)/l,startRow:ee,endRow:V,scale:l},p.current=g;for(let H=$.length;H--;)$[H]=null};let U=0;const W=()=>{(y||!g)&&(y=!1,F()),L();const j=[],D=[];for(const B of $)if(B)for(const{d:z,span:ee}of B)z>I||(j.push(ee),ee.events&&D.push(...ee.events));I<O&&(!M||I<S)&&(I=Math.min(O,I+100),U=requestAnimationFrame(W)),v(j),T(D),E(l)};W();let K=Date.now();const J=j=>{(j.ctrlKey||j.metaKey)&&(K=Date.now())};w==null||w.addEventListener("wheel",J);const X=()=>{Date.now()-K<=50||(y=!0,cancelAnimationFrame(U),U=requestAnimationFrame(W))};return w==null||w.addEventListener("scroll",X),()=>{cancelAnimationFrame(U),w==null||w.removeEventListener("wheel",J),w==null||w.removeEventListener("scroll",X)}},[C,o,l,p,c,u,f,r]),a.useEffect(()=>{var y;if(!h)return;let w;for(const M of k)if(M.span.spanId===h.span.spanId){w=M;break}const g=(y=w==null?void 0:w.ref)==null?void 0:y.current;if(!(!w||!g))return w.isSelected=!0,g.setAttribute("data-selected",""),()=>{w.isSelected=!1,g.removeAttribute("data-selected")}},[k,h]),{rows:C,spans:k,events:_,scale:P}};function oa(e){const[r,s]=a.useState(e);return a.useEffect(()=>{if(r===e)return;let n=0,o=0;const i=()=>{if(++n<=3){o=requestAnimationFrame(i);return}s(e)};return i(),()=>{cancelAnimationFrame(o)}},[r,e]),r}const gr={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 aa({trace:e=gr,className:r="",scrollLock:s=!1,height:n,withPanel:o=!1,highlightedSpans:i,eagerRender:l=!1,isLive:c=!1,footer:u,knownDurationMs:d,hasMoreData:p=!1}){const h=e===gr,{state:m,dispatch:f}=ve(),{timelineRef:R,scrollSnapshotRef:C}=m,x=m.memoCacheRef.current,k=((i==null?void 0:i.length)??0)>0,v=a.useRef(!1),_=a.useRef(""),T=a.useRef(null),P=a.useRef({}),E=a.useRef(null);a.useEffect(()=>{const{root:L,map:A}=ra(e),b=!v.current;v.current=!0;const F=Object.keys(A).sort().map(U=>{const W=A[U].events,K=(W==null?void 0:W.length)??0,J=K?W==null?void 0:W[0]:void 0,X=K?W==null?void 0:W[K-1]:void 0,j=`${(J==null?void 0:J.event.name)??"none"}@${(J==null?void 0:J.timestamp)??0}|${(X==null?void 0:X.event.name)??"none"}@${(X==null?void 0:X.timestamp)??0}`;return`${U}:${K}:${j}`}).join(",");if(!b&&F===_.current&&T.current){const U=T.current,W=P.current;let K=!1;(U.endTime!==L.endTime||U.duration!==L.duration)&&(U.endTime=L.endTime,U.duration=L.duration,K=!0);for(const[J,X]of Object.entries(A)){const j=W[J];j&&((j.endTime!==X.endTime||j.duration!==X.duration)&&(j.endTime=X.endTime,j.duration=X.duration,K=!0),Object.assign(j.span,X.span))}if(!K)return;f({type:"forceRender"});return}_.current=F,T.current=L,P.current=A,f({type:b?"setRoot":"updateRoot",root:L,spanMap:A,resources:e.resources||[]})},[f,e]);const{rows:N,spans:w,events:g,scale:y}=na(i,l),M=a.useRef(null);a.useLayoutEffect(()=>{const L=M.current;if(!L)return;const A=()=>{const F=2*ce,U=L.getBoundingClientRect(),W=U.width-F,K=U.height,J=E.current;J&&J.width===W&&J.height===K||(E.current={width:W,height:K},f({type:"setSize",width:W,height:K}))};A();const b=new ResizeObserver(A);return b.observe(L),window.addEventListener("resize",A),()=>{b.disconnect(),window.removeEventListener("resize",A)}},[f]);const S=a.useRef({t:0,x:-1,y:-1,spanId:""}),I=a.useCallback(L=>{const A=S.current,b=Date.now(),{clientX:F,clientY:U}=L,W=Math.sqrt((F-A.x)**2+(U-A.y)**2);if(b-A.t<=500&&W<=8){if(L.stopPropagation(),L.preventDefault(),!A.spanId){f({type:"resetScale"});return}f({type:"select",id:A.spanId}),f({type:"scaleToNode",id:A.spanId});return}const K=L.target;if(!K.closest(`.${String(G.timeline)}`))return;const J=K.closest("[data-span-id]"),X=(J==null?void 0:J.dataset.spanId)||"";S.current={x:F,y:U,t:b,spanId:X},X&&(f({type:"toggleSelection",id:X}),L.stopPropagation())},[f]);a.useLayoutEffect(()=>{const L=R.current;if(!L)return;const A=C.current;A&&(L.scrollLeft=A.anchorT*y-A.anchorX,C.current=void 0)},[C,R,y]),a.useEffect(()=>{var b;const L=(b=m.selected)==null?void 0:b.span.spanId;if(!L)return;const A=setTimeout(()=>{const F=m.timelineRef.current,U=F==null?void 0:F.querySelector(`[data-span-id="${L}"]`);if(!F||!U)return;const W=F.getBoundingClientRect(),K=U.getBoundingClientRect();K.width<W.width&&(K.left<W.left||K.right>W.right||K.top<W.top||K.bottom>W.bottom)&&U.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})},500);return()=>{clearTimeout(A)}},[m.selected,m.timelineRef]),a.useEffect(()=>{const L=A=>{A.key==="Escape"&&f({type:"escape"})};return window.addEventListener("keydown",L),()=>{window.removeEventListener("keydown",L)}},[f]),a.useEffect(()=>{if(!s)return;const L=document.documentElement,A=document.body;L.style.overflow="clip",A.style.overflow="clip";const b=F=>{F!=null&&F.cancelable?F.preventDefault():window.scrollTo({left:0,top:0,behavior:"instant"})};return b(),window.addEventListener("scroll",b,{passive:!1}),()=>{L.style.overflow="",A.style.overflow="",window.removeEventListener("scroll",b)}},[s]);const O=Math.max(m.timelineHeight-m.scrollbarWidth,wt+Se+N.length*(We+Se)-Se+84),$=!!(m.isMobile&&m.selected);return t.jsxs("div",{className:Pe(G.traceViewer,h&&G.skeleton,r),onClickCapture:I,ref:M,style:{height:n,"--timeline-padding":`${ce}px`,"--row-height":`${We}px`,"--row-padding":`${Se}px`,"--search-height":`${k?0:zr}px`,"--search-gap":`${k?2:Cn}px`,"--map-height":`${Nn}px`,"--timeline-width":`${m.timelineWidth}px`,"--timeline-height":`${m.timelineHeight}px`,"--timeline-scroll-width":`${Math.round(m.root.duration*m.scale)}px`,"--panel-width":`${m.panelWidth}px`,"--panel-height":`${m.panelHeight}px`,"--height":`${m.height}px`,"--scrollbar-width":`${m.scrollbarWidth}px`,"--marker-height":`${wt}px`,"--marker-notch-height":`${kn}px`},children:[k?null:t.jsx(Yo,{}),t.jsx(En,{rows:N,scale:y,timelineRef:R}),t.jsxs("div",{className:Pe(G.traceViewerContent,$&&G.inert),children:[t.jsxs("div",{className:G.timeline,ref:R,children:[t.jsx("div",{style:{position:"relative",width:m.timelineWidth,minHeight:m.timelineHeight-ce*2,padding:ce,paddingBottom:0},children:t.jsxs("div",{className:G.traceNode,style:{width:m.root.duration*y||void 0,height:O-ce*2},children:[t.jsx(Uo,{scale:y,isLive:c}),t.jsx(Ko,{events:g,root:m.root,scale:y}),t.jsx(qo,{dispatch:f,events:g,memoCacheRef:m.memoCacheRef,root:m.root,scale:y,scrollSnapshotRef:C,spans:w,timelineRef:R}),t.jsx(Sn,{cacheKey:x.get(""),cache:x,customSpanClassNameFunc:m.customSpanClassNameFunc,customSpanEventClassNameFunc:m.customSpanEventClassNameFunc,isLive:c,root:m.root,scale:y,scrollSnapshotRef:C,spans:w}),d!=null&&d>0&&(p||c)&&m.root.duration>0&&(()=>{const L=d*y,b=m.root.duration*y-L;if(b<4)return null;const F=Math.min(b*.05,20);return t.jsx("div",{style:{position:"absolute",top:0,left:L+F,width:b-F,height:"100%",pointerEvents:"none",zIndex:1,maskImage:"linear-gradient(to right, transparent 1%, black 3%)",WebkitMaskImage:"linear-gradient(to right, transparent 1%, black 3%)",background:"repeating-linear-gradient(-45deg, var(--ds-background-200) 0, var(--ds-background-200) 11px, var(--ds-gray-200) 11px, var(--ds-gray-200) 12px)"}})})()]})}),u]}),t.jsx("div",{className:G.zoomButtonTraceViewer,children:t.jsx(ta,{})})]}),o?t.jsx("div",{className:Pe(G.spanDetailPanelTraceViewer,!m.selected&&G.hidden,m.isMobile&&G.mobile),children:t.jsx(In,{attached:!0})}):null]})}function yr(e,r=!1){if(r&&e==="pending")return G.spanPendingStriped;switch(e){case"running":return G.spanRunning;case"pending":return G.spanPending;case"completed":return G.spanCompleted;case"cancelled":return G.spanCancelled;case"failed":return G.spanFailed;default:return""}}function ia(e){return String(e).toLowerCase().endsWith("sleep")}const la=e=>{const r=e.span.attributes,s=r==null?void 0:r.resource;if(s==="step"){const n=r.data,o=n==null?void 0:n.stepName;if(o&&ia(o))return G.spanSleep;const i=(n==null?void 0:n.status)==="pending";return yr(n==null?void 0:n.status,i)}if(s==="run"){const n=r.data;return yr(n==null?void 0:n.status,!1)}return s==="hook"?G.spanHook:s==="sleep"?G.spanSleep:""},ca=e=>{const r=e.event.name;return r==="step_failed"||r==="run_failed"?G.eventFailed:r==="step_retrying"?G.eventRetrying:r==="hook_created"||r==="hook_received"||r==="hook_disposed"?G.eventHook:G.eventDefault};function da(e){return e==="hook_created"||e==="hook_received"||e==="hook_disposed"}function pe(e){if(typeof e=="string"&&(e=new Date(e)),!e||!(e instanceof Date))return[0,0];const r=e.getTime(),s=Math.floor(r/1e3),n=r%1e3*1e6;return[s,n]}function Bt(e){const r=e[0]*1e3,s=e[1]/1e6;return r+s}function Ct(e,r){if(typeof e=="string"&&(e=new Date(e)),typeof r=="string"&&(r=new Date(r)),!e||!(e instanceof Date))return[0,0];const n=(r&&r instanceof Date?r:new Date).getTime()-e.getTime(),o=Math.floor(n/1e3),i=n%1e3*1e6;return[o,i]}const nt={name:"workflow-development-kit",version:"4.0.0"},ua=new Set(["hook_created","hook_received","hook_disposed","step_started","step_retrying","step_failed","run_failed","wait_created","wait_completed"]);function Et(e,r=!0){return e.filter(s=>r?ua.has(s.eventType):!0).map(s=>({name:s.eventType,timestamp:pe(s.createdAt),attributes:{eventId:s.eventId,correlationId:s.correlationId,eventData:"eventData"in s?s.eventData:void 0},showVerticalLine:da(s.eventType)}))}const ts=e=>{var n;const r=e.find(o=>o.eventType==="wait_created");if(!r)return null;const s=e.find(o=>o.eventType==="wait_completed");return{waitId:r.correlationId,runId:r.runId,createdAt:r.createdAt,resumeAt:(n=r.eventData)==null?void 0:n.resumeAt,completedAt:s==null?void 0:s.createdAt}};function fa(e,r){const s=ts(e);if(!s)return null;const n=s.createdAt,o=s.completedAt??r,i=pe(n),l=pe(o),c=Ct(n,o),u=Et(e,!1);return{spanId:s.waitId,name:"sleep",kind:1,resource:"sleep",library:nt,status:{code:0},traceFlags:1,attributes:{resource:"sleep",data:s},links:[],events:u,duration:c,startTime:i,endTime:l}}const ma=e=>{var u;const r=e.find(d=>d.eventType==="step_created"),s=r??e[0];if(!s)return null;let n="pending",o=0,i,l;for(const d of e)switch(d.eventType){case"step_started":n="running",o+=1,i||(i=d.createdAt),l=void 0;break;case"step_completed":n="completed",l=d.createdAt;break;case"step_failed":n="failed",l=d.createdAt;break;case"step_retrying":n="pending",l=void 0;break}o===0&&(o=1);const c=e[e.length-1];return{stepId:s.correlationId??"",runId:s.runId,stepName:((u=r==null?void 0:r.eventData)==null?void 0:u.stepName)??"",status:n,attempt:o,createdAt:s.createdAt,updatedAt:(c==null?void 0:c.createdAt)??s.createdAt,startedAt:i,completedAt:l,specVersion:s.specVersion}};function pa(e,r){const s=ma(e);if(!s)return null;const n=st(String(s.stepName)),o={resource:"step",data:s},i="step",l=new Date(s.completedAt??r),c=Et(e,!1),u=new Date(s.createdAt);let d=s.startedAt?new Date(s.startedAt):void 0;const p=e.find(h=>h.eventType==="step_started");return p&&(d=new Date(p.createdAt)),{spanId:String(s.stepId),name:(n==null?void 0:n.shortName)??"",kind:1,resource:i,library:nt,status:{code:0},traceFlags:1,attributes:o,links:[],events:c,startTime:pe(u),endTime:pe(l),duration:Ct(u,l),activeStartTime:d&&d.getTime()>u.getTime()?pe(d):void 0}}const ha=e=>{var i,l;const r=e.find(c=>c.eventType==="hook_created");if(!r)return null;const s=e.filter(c=>c.eventType==="hook_received"),n=e.filter(c=>c.eventType==="hook_disposed"),o=s.at(-1);return{hookId:r.correlationId,runId:r.runId,token:(i=r.eventData)==null?void 0:i.token,createdAt:r.createdAt,receivedCount:s.length,lastReceivedAt:(o==null?void 0:o.createdAt)||void 0,disposedAt:((l=n.at(-1))==null?void 0:l.createdAt)||void 0}};function xa(e,r){const s=ha(e);if(!s)return null;const n=Et(e,!1),o=s.disposedAt||r;return{spanId:String(s.hookId),name:String(s.hookId),kind:1,resource:"hook",library:nt,status:{code:1},traceFlags:1,attributes:{resource:"hook",data:s},links:[],events:n,startTime:pe(s.createdAt),endTime:pe(o),duration:Ct(s.createdAt,o)}}function ga(e,r,s){var f;const n=s??new Date,{input:o,output:i,error:l,...c}=e,u={resource:"run",data:c},d=new Date(e.createdAt),p=e.startedAt?new Date(e.startedAt):void 0,h=e.completedAt??n,m=Et(r,!1);return{spanId:String(e.runId),name:String(((f=ze(e.workflowName))==null?void 0:f.shortName)??"?"),kind:1,resource:"run",library:nt,status:{code:0},traceFlags:1,attributes:u,links:[],events:m,startTime:pe(d),endTime:pe(h),duration:Ct(d,h),activeStartTime:p&&p.getTime()>d.getTime()?pe(p):void 0}}const ya=e=>e.startsWith("step_"),va=e=>e==="wait_created"||e==="wait_completed",wa=e=>e==="hook_received"||e==="hook_created"||e==="hook_disposed";function Ft(e,r,s){const n=e.get(r);if(n){n.push(s);return}e.set(r,[s])}function ba(e){const r=new Map,s=[],n=new Map,o=new Map;for(const i of e){const l=i.correlationId;if(!l){s.push(i);continue}if(va(i.eventType)){Ft(n,l,i);continue}if(wa(i.eventType)){Ft(o,l,i);continue}if(ya(i.eventType)){Ft(r,l,i);continue}s.push(i)}return{eventsByStepId:r,runLevelEvents:s,timerEvents:n,hookEvents:o}}function ja(e,r){let s=new Date(r.createdAt).getTime();for(const n of e){const o=new Date(n.createdAt).getTime();o>s&&(s=o)}return new Date(s)}function ka(e,r,s,n){const o=n,i=Array.from(r.eventsByStepId.values()).map(u=>pa(u,o)).filter(u=>u!==null),l=Array.from(r.hookEvents.values()).map(u=>xa(u,o)).filter(u=>u!==null),c=Array.from(r.timerEvents.values()).map(u=>fa(u,o)).filter(u=>u!==null);return{runSpan:ga(e,r.runLevelEvents,s),spans:[...i,...l,...c]}}function Na(e,r){const s=[e,...r.slice().sort((n,o)=>{const i=Bt(n.startTime),l=Bt(o.startTime);return i-l})];return s.map((n,o)=>{const i=o===0?void 0:String(s[o-1].spanId);return{...n,parentSpanId:i}})}function Ca(e,r,s){const n=ba(r),o=ja(r,e),{runSpan:i,spans:l}=ka(e,n,s,o),c=Na(i,l),u=Bt(i.startTime),d=o.getTime()-u;return{traceId:e.runId,rootSpanId:e.runId,spans:c,resources:[{name:"workflow",attributes:{"service.name":nt.name}}],knownDurationMs:Math.max(0,d)}}function Ea(e){const{state:r,dispatch:s}=ve(),n=a.useRef(r);n.current=r,a.useEffect(()=>{if(!e)return;let o=0;const i=()=>{const{root:d}=n.current;if(d.startTime){const p=Date.now();p>d.endTime&&(d.endTime=p,d.duration=d.endTime-d.startTime)}o=requestAnimationFrame(i)};o=requestAnimationFrame(i);let l=0,c=0;const u=()=>{const d=n.current;if(d.root.duration>0){const p=(d.width-d.scrollbarWidth)/d.root.duration;(Math.abs(p-c)>c*.001||c===0)&&(c=p,s({type:"detectBaseScale"}))}l=requestAnimationFrame(u)};return l=requestAnimationFrame(u),()=>{cancelAnimationFrame(o),cancelAnimationFrame(l)}},[e,s])}const Sa=450,Ia=240;function Ta({menu:e,items:r,onClose:s}){const n=a.useRef(null);a.useEffect(()=>{const l=p=>{n.current&&!n.current.contains(p.target)&&s()},c=p=>{p.key==="Escape"&&s()},u=()=>{s()},d=setTimeout(()=>{window.addEventListener("mousedown",l),window.addEventListener("keydown",c),window.addEventListener("scroll",u,!0)},0);return()=>{clearTimeout(d),window.removeEventListener("mousedown",l),window.removeEventListener("keydown",c),window.removeEventListener("scroll",u,!0)}},[s]);const[o,i]=a.useState({x:e.x,y:e.y});return a.useEffect(()=>{const l=n.current;if(!l)return;const c=l.getBoundingClientRect();let{x:u,y:d}=e;c.right>window.innerWidth&&(u=window.innerWidth-c.width-8),c.bottom>window.innerHeight&&(d=window.innerHeight-c.height-8),(u!==e.x||d!==e.y)&&i({x:u,y:d})},[e]),r.length===0?null:Ut.createPortal(t.jsxs("div",{ref:n,style:{position:"fixed",left:o.x,top:o.y,zIndex:99999,boxShadow:"var(--ds-shadow-menu)",borderRadius:12,background:"var(--ds-background-100)",padding:"var(--geist-space-gap-quarter, 4px)",fontSize:14,minWidth:180,overflowX:"hidden",overflowY:"auto"},children:[t.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}),r.map(l=>t.jsxs("button",{type:"button",style:{outline:"none",cursor:l.disabled?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:8,padding:"0 var(--geist-space-2x, 8px)",height:40,textDecoration:"none",borderRadius:6,color:l.destructive?"var(--ds-red-900)":"var(--ds-gray-1000)",width:"100%",background:"transparent",border:"none",fontSize:14,textAlign:"left",opacity:l.disabled?.4:1,transition:"background 0.15s"},disabled:l.disabled,onMouseEnter:c=>{c.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:c=>{c.currentTarget.style.background="transparent"},onClick:()=>{l.action(),s()},children:[l.icon??null,l.label]},l.label))]}),document.body)}function Ra({trace:e,run:r,isLive:s,onWakeUpSleep:n,onCancelRun:o,onResolveHook:i,onLoadMoreSpans:l,hasMoreSpans:c=!1,isLoadingMoreSpans:u=!1,children:d}){const p=Ue(),{state:h,dispatch:m}=ve();Ea(s);const[f,R]=a.useState(null),[C,x]=a.useState(null),[k,v]=a.useState(!1),[_,T]=a.useState(new Set),P=a.useMemo(()=>{const S=new Map;for(const I of e.spans)S.set(I.spanId,I);return S},[e.spans]),E=a.useCallback(async S=>{if(!(k||!C||!i)){if(!C.token){p.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{v(!0),await i(C.token,S),p.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),T(I=>new Set(I).add(C.hookId)),x(null)}catch(I){console.error("Failed to resolve hook:",I),p.error("Failed to resolve hook",{description:I instanceof Error?I.message:"An unknown error occurred"})}finally{v(!1)}}},[i,C,k]),N=a.useCallback(S=>{const O=S.target.closest("[data-span-id]");if(!O)return;const $=O.dataset.spanId;if(!$)return;S.preventDefault(),S.stopPropagation();const L=P.get($);if(!L)return;const A=L.attributes.resource??"unknown",b=L.attributes.data,F=!(b!=null&&b.completedAt)&&!(b!=null&&b.disposedAt);R({x:S.clientX,y:S.clientY,spanId:$,spanName:L.name,resourceType:A,isActive:F})},[P]),w=a.useRef(null);a.useEffect(()=>{const S=w.current;if(!S)return;const I=O=>{N(O)};return S.addEventListener("contextmenu",I),()=>{S.removeEventListener("contextmenu",I)}},[N]);const g=a.useRef(!1);a.useEffect(()=>{const S=h.timelineRef.current;if(!S||!l||!c)return;const I=200,O=()=>{g.current||u||!c||S.scrollHeight-S.scrollTop-S.clientHeight>I||(g.current=!0,Promise.resolve(l()).finally(()=>{g.current=!1}))};return S.addEventListener("scroll",O),O(),()=>{S.removeEventListener("scroll",O)}},[h.timelineRef,l,c,u]);const y=a.useCallback(()=>{R(null)},[]),M=a.useCallback(S=>{var $,L;const I=[],O=!r.completedAt;if(S.resourceType==="sleep"&&S.isActive&&O&&n&&I.push({label:"Wake Up Sleep",icon:t.jsx(qs,{className:"h-3.5 w-3.5"}),action:()=>{n(r.runId,S.spanId).then(A=>{A.stoppedCount>0?p.success("Sleep woken up",{description:`Woke up ${String(A.stoppedCount)} sleep${A.stoppedCount>1?"s":""}`}):p.info("No active sleeps found",{description:"The sleep may have already completed."})}).catch(A=>{p.error("Failed to wake up sleep",{description:A instanceof Error?A.message:"An unknown error occurred"})})}}),S.resourceType==="hook"&&O&&i){const A=P.get(S.spanId),b=($=A==null?void 0:A.attributes)==null?void 0:$.data,F=!!(b!=null&&b.disposedAt)||!!((L=A==null?void 0:A.events)!=null&&L.some(U=>U.name==="hook_disposed"))||_.has(S.spanId);b!=null&&b.token&&!F&&I.push({label:"Resolve Hook",icon:t.jsx(Wr,{className:"h-3.5 w-3.5"}),action:()=>{x({hookId:S.spanId,token:b.token})}})}return S.resourceType==="run"&&O&&o&&I.push({label:"Cancel Run",icon:t.jsx(Gs,{className:"h-3.5 w-3.5"}),destructive:!0,action:()=>{o(r.runId).catch(A=>{p.error("Failed to cancel run",{description:A instanceof Error?A.message:"An unknown error occurred"})})}}),I.push({label:"View Details",icon:t.jsx(zn,{className:"h-3.5 w-3.5"}),action:()=>{m({type:"select",id:S.spanId})}}),I.push({label:"Copy Name",icon:t.jsx(qn,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(S.spanName).then(()=>{p.success("Name copied to clipboard")}).catch(()=>{p.error("Failed to copy name")})}}),I.push({label:"Copy ID",icon:t.jsx(rt,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(S.spanId).then(()=>{p.success("ID copied to clipboard")}).catch(()=>{p.error("Failed to copy ID")})}}),I},[m,n,o,i,P,_,r.runId,r.completedAt]);return t.jsxs("div",{className:"relative w-full h-full",ref:w,children:[d,f?t.jsx(Ta,{menu:f,items:M(f),onClose:y}):null,t.jsx(Hr,{isOpen:C!==null,onClose:()=>x(null),onSubmit:E,isSubmitting:k})]})}function Aa({onSelectionChange:e}){const{state:r}=ve(),{selected:s}=r,n=a.useRef(e);n.current=e;const o=a.useRef(void 0);return a.useEffect(()=>{var l,c;const i=s==null?void 0:s.span.spanId;i!==o.current&&(o.current=i,s?n.current({data:(l=s.span.attributes)==null?void 0:l.data,resource:(c=s.span.attributes)==null?void 0:c.resource,spanId:s.span.spanId}):n.current(null))},[s]),null}function Da({triggerDeselect:e}){const{dispatch:r}=ve();return a.useEffect(()=>{e>0&&r({type:"deselect"})},[e,r]),null}function Ma({selectRequest:e}){const{dispatch:r}=ve();return a.useEffect(()=>{e!=null&&e.id&&r({type:"select",id:e.id})},[r,e]),null}function _a({onResize:e}){const r=a.useCallback(s=>{s.preventDefault();let n=s.clientX;const o=l=>{const c=n-l.clientX;n=l.clientX,e(c)},i=()=>{document.removeEventListener("pointermove",o),document.removeEventListener("pointerup",i)};document.addEventListener("pointermove",o),document.addEventListener("pointerup",i)},[e]);return t.jsx("div",{className:"absolute left-0 top-0 bottom-0 w-1 cursor-col-resize hover:bg-blue-400/50 z-10",onPointerDown:r})}function La({hasMore:e,isLive:r,isInitialLoading:s}){const n={color:"var(--ds-gray-900)"};return e||s?t.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-xs",style:n,children:[t.jsx(Zt,{size:14}),"Loading more events…"]}):r?t.jsx("div",{className:"flex items-center justify-center py-3 text-xs",style:n,children:"Waiting for more events…"}):t.jsx("div",{className:"flex items-center justify-center py-3 text-xs",style:n,children:"End of run"})}const Pa=({run:e,events:r,isLoading:s,error:n,spanDetailData:o,spanDetailLoading:i,spanDetailError:l,onWakeUpSleep:c,onResolveHook:u,onCancelRun:d,onStreamClick:p,onSpanSelect:h,onLoadEventData:m,onLoadMoreSpans:f,hasMoreSpans:R=!1,isLoadingMoreSpans:C=!1,encryptionKey:x,onDecrypt:k,isDecrypting:v=!1})=>{const _=Ue(),[T,P]=a.useState(null),[E,N]=a.useState(Sa),[w,g]=a.useState(0),[y,M]=a.useState(null),S=!!(e&&!e.completedAt),I=a.useMemo(()=>{if(e!=null&&e.runId)return Ca(e,r,new Date)},[e,r]),O=I;a.useEffect(()=>{n&&!s&&(console.error(n),_.error("Error loading workflow trace data",{description:n.message}))},[n,s]);const $=a.useCallback(j=>{h==null||h(j)},[h]),L=a.useCallback(j=>{if(j){const D=j.spanId,B=D?r.filter(z=>z.correlationId===D):[];P({...j,rawEvents:B})}else P(null)},[r]);a.useEffect(()=>{const j=T==null?void 0:T.spanId;if(!j)return;const D=r.filter(B=>B.correlationId===j);P(B=>{if(!B||B.spanId!==j)return B;const z=B.rawEvents??[];return z.length===D.length&&z.every((V,H)=>{var Y;return V.eventId===((Y=D[H])==null?void 0:Y.eventId)})?B:{...B,rawEvents:D}})},[r,T==null?void 0:T.spanId]);const A=a.useCallback(()=>{P(null),g(j=>j+1)},[]),b=a.useCallback(j=>{N(D=>Math.max(Ia,D+j))},[]),F=a.useMemo(()=>!(T!=null&&T.spanId)||!O?-1:O.spans.findIndex(j=>j.spanId===T.spanId),[T==null?void 0:T.spanId,O]),U=F>0,W=F>=0&&O!=null&&F<O.spans.length-1,K=a.useCallback(()=>{var D;if(!O||F<=0)return;const j=(D=O.spans[F-1])==null?void 0:D.spanId;j&&M({id:j,token:Date.now()})},[F,O]),J=a.useCallback(()=>{var D;if(!O||F<0)return;const j=(D=O.spans[F+1])==null?void 0:D.spanId;j&&M({id:j,token:Date.now()})},[F,O]),X=a.useMemo(()=>{var z,ee;if(!(T!=null&&T.data))return;const j=T.data,D=j.stepName,B=j.workflowName;return(D?(z=st(D))==null?void 0:z.shortName:void 0)??(B?(ee=ze(B))==null?void 0:ee.shortName:void 0)??D??B??j.hookId??"Details"},[T==null?void 0:T.data]);return O?t.jsxs("div",{className:"relative w-full h-full flex",children:[t.jsx("div",{className:"flex-1 min-w-0 relative",children:t.jsxs(Tn,{customSpanClassNameFunc:la,customSpanEventClassNameFunc:ca,children:[t.jsx(Aa,{onSelectionChange:L}),t.jsx(Da,{triggerDeselect:w}),t.jsx(Ma,{selectRequest:y}),t.jsx(Ra,{trace:O,run:e,isLive:S,onWakeUpSleep:c,onCancelRun:d,onResolveHook:u,onLoadMoreSpans:f,hasMoreSpans:R,isLoadingMoreSpans:C,children:t.jsx(aa,{eagerRender:!0,height:"100%",isLive:S,trace:O,knownDurationMs:I==null?void 0:I.knownDurationMs,hasMoreData:R||!!s,footer:t.jsx(La,{hasMore:R,isLive:S,isInitialLoading:!!s})})})]})}),T&&t.jsxs("div",{className:"relative border-l flex-shrink-0 flex flex-col",style:{width:E,borderColor:"var(--ds-gray-200)",backgroundColor:"var(--ds-background-100)"},children:[t.jsx(_a,{onResize:b}),t.jsxs("div",{className:"flex items-center justify-between px-3 py-2 border-y flex-shrink-0",style:{borderColor:"var(--ds-gray-200)"},children:[t.jsx("div",{className:"min-w-0 flex-1",children:t.jsx("div",{className:"text-sm font-medium truncate",style:{color:"var(--ds-gray-1000)"},title:X,children:X})}),t.jsxs("div",{className:"flex items-center",children:[t.jsx("button",{type:"button","aria-label":"Previous span",onClick:K,disabled:!U,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:U?"pointer":"not-allowed",opacity:U?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:j=>{U&&(j.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:j=>{j.currentTarget.style.background="transparent"},children:t.jsx(zs,{size:16})}),t.jsx("button",{type:"button","aria-label":"Next span",onClick:J,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:j=>{W&&(j.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:j=>{j.currentTarget.style.background="transparent"},children:t.jsx(Us,{size:16})})]}),t.jsx("div",{className:"flex items-center",style:{borderLeft:"1px solid var(--ds-gray-300)",marginLeft:6},children:t.jsx("button",{type:"button","aria-label":"Close panel",onClick:A,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:j=>{j.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:j=>{j.currentTarget.style.background="transparent"},children:t.jsx(Ks,{size:16})})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(Qe,{title:"Failed to load entity details",children:t.jsx(Vo,{run:e,onStreamClick:p,spanDetailData:o??null,spanDetailError:l,spanDetailLoading:i,onSpanSelect:$,onWakeUpSleep:c,onLoadEventData:m,onResolveHook:u,encryptionKey:x,onDecrypt:k,isDecrypting:v,selectedSpan:T})})})]})]}):t.jsxs("div",{className:"relative w-full h-full",children:[t.jsx("div",{className:"border-b border-gray-alpha-400 w-full"}),t.jsx(Q,{className:"w-full ml-2 mt-1 mb-1 h-[56px]"}),t.jsxs("div",{className:"p-2 relative w-full",children:[t.jsx(Q,{className:"w-full mt-6 h-[20px]"}),t.jsx(Q,{className:"w-[10%] mt-2 ml-6 h-[20px]"}),t.jsx(Q,{className:"w-[10%] mt-2 ml-12 h-[20px]"}),t.jsx(Q,{className:"w-[20%] mt-2 ml-16 h-[20px]"})]})]})};async function Fa(e,r,s,n={}){const o=n.resolveData??"all";let i,l;if(r==="run")i=await ht(Wt(e,s,o)),l=i.runId;else if(r==="step"){const{runId:c}=n;if(!c)throw new _e("runId is required for step resource",{layer:"client"});i=await ht(Rn(e,c,s,o)),l=i.stepId}else if(r==="hook")i=await ht(Ur(e,s,o)),l=i.hookId;else throw new _e(`Unknown resource type: ${r}`,{layer:"client"});return{data:i,correlationId:l}}function Oa(e,r,s,n={}){const{refreshInterval:o=0,runId:i,enabled:l=!0,encryptionKey:c}=n,[u,d]=a.useState(null),[p,h]=a.useState(l),[m,f]=a.useState(null),R=a.useCallback(async k=>c?He(k,c):me(k),[c]),C=a.useRef(""),x=a.useCallback(async()=>{if(!l){h(!1);return}const k=`${r}:${s}`;if(k!==C.current&&(d(null),C.current=k),f(null),h(!0),r==="hook"){try{const{error:v,result:_}=await ue(Ur(e,s,"all"));if(v){f(v);return}try{d(await R(_))}catch(T){f(T instanceof Error?T:new Error(String(T)))}}finally{h(!1)}return}if(r==="sleep"){try{if(!i){f(new Error("runId is required for loading sleep details"));return}const{error:v,result:_}=await ue(Be(e,i,{sortOrder:"asc",limit:1e3,withData:!0}));if(v){f(v);return}try{const T=_.data.map(me),P=await Promise.all(T.filter(N=>N.correlationId===s).map(R)),E=ts(P);if(E===null){f(new Error(`Failed to load ${r} details: missing required event data`));return}d(E)}catch(T){f(T instanceof Error?T:new Error(String(T)))}}finally{h(!1)}return}try{const{data:v}=await Fa(e,r,s,{runId:i});d(await R(v))}catch(v){v instanceof Error?f(v):f(new Error(String(v)));return}finally{h(!1)}},[e,r,s,i,l,R]);return a.useEffect(()=>{x()},[x]),a.useEffect(()=>{if(!o||o<=0)return;const k=setInterval(x,o);return()=>clearInterval(k)},[o,x]),{data:u,loading:p,error:m,refresh:x}}function Vt(e,r,s){const n=[...e,...r],o=new Map(n.map(i=>[i[s],i]));return Array.from(o.values())}async function $a(e){const{fetchFn:r,setItems:s,setCursor:n,setError:o,idKey:i,cursorStrategy:l="always",transform:c}=e,{error:u,result:d}=await r();if(u)return o(u),!1;if(d.data.length>0){const p=c?d.data.map(c):d.data;return s(m=>Vt(m,p,i)),(l==="onHasMore"?!!(d.cursor&&d.hasMore):!!d.cursor)&&n(d.cursor),!0}return!1}const Wa=100,Ha=500,Ba=100,Va=5e3;function za(e,r,s={}){const{live:n=!1}=s,[o,i]=a.useState(null),[l,c]=a.useState([]),[u,d]=a.useState(!0),[p,h]=a.useState(null),[m,f]=a.useState(),[R,C]=a.useState(!1),[x,k]=a.useState(!1),v=a.useRef(!1),[_,T]=a.useState(!1),P=a.useCallback(async()=>{if(v.current)return;v.current=!0,d(!0),h(null);const[y,M]=await Promise.all([ue(Wt(e,r,"none")),ue(Be(e,r,{sortOrder:"asc",limit:Ha,withData:!1}))]);y.error?h(y.error):i(me(y.result));const S=M.error?[]:M.result.data.map(me);c(Vt([],S,"eventId")),f(M.error||!M.result.hasMore?void 0:M.result.cursor),C(!!(!M.error&&M.result.hasMore)),d(!1),T(!0),v.current=!1,!y.error&&M.error&&h(M.error)},[e,r]),E=a.useCallback(async()=>{if(!(v.current||!_||x||!R)){k(!0);try{const y=await ue(Be(e,r,{cursor:m,sortOrder:"asc",limit:Ba,withData:!1}));if(y.error)h(y.error);else{const M=y.result.data.map(me);M.length>0&&c(S=>Vt(S,M,"eventId")),C(!!y.result.hasMore),f(y.result.hasMore?y.result.cursor:void 0)}}finally{k(!1)}}},[e,r,_,x,R,m]),N=a.useCallback(async()=>{if(o!=null&&o.completedAt)return!1;const{error:y,result:M}=await ue(Wt(e,r,"none"));return y?(h(y),!1):(h(null),i(me(M)),!0)},[e,r,o==null?void 0:o.completedAt]),w=a.useCallback(()=>$a({fetchFn:()=>ue(Be(e,r,{cursor:m,sortOrder:"asc",limit:Wa,withData:!1})),setItems:c,setCursor:f,setError:h,idKey:"eventId",transform:me}),[e,r,m]),g=a.useCallback(async()=>{if(v.current||!_)return{foundNewItems:!1};let y=!1;try{const[M,S]=await Promise.all([N(),w()]);y=S}catch(M){console.error("Update error:",M)}return{foundNewItems:y}},[w,_,N]);return a.useEffect(()=>{P()},[P]),a.useEffect(()=>{if(!n||!_||o!=null&&o.completedAt)return;const y=setInterval(()=>{g()},Va);return()=>{clearInterval(y)}},[n,_,g,o==null?void 0:o.completedAt]),{run:o??{},events:l,loading:u,error:p,update:g,loadMoreTraceData:E,hasMoreTraceData:R,isLoadingMoreTraceData:x}}function Ua(e){return typeof e=="object"&&e!==null&&"message"in e&&"layer"in e&&"cause"in e&&"request"in e}async function Ka(e,r,s,n,o){try{const i=new URLSearchParams({runId:s});o&&i.set("cursor",o);const l=`/api/stream/${encodeURIComponent(r)}?${i.toString()}`,c=await fetch(l,{signal:n});if(!c.ok){const p=await c.json().catch(()=>null);throw p&&Ua(p)?new _e(p.message,{layer:"client",cause:p.cause,request:p.request}):new _e(`Failed to read stream: ${c.status}`,{layer:"client"})}if(!c.body)throw new _e("Failed to read stream: no body",{layer:"client"});const u=c.headers.get("X-Stream-Cursor"),d=c.headers.get("X-Stream-Done")==="true";return{body:c.body,cursor:u,done:d}}catch(i){throw i instanceof _e?i:new _e("Failed to read stream",{layer:"client",cause:i})}}async function qa(e,r){return ht(An(e,r))}const Ga=1e4;function Za(e,r,s=Ga){const[n,o]=a.useState([]),[i,l]=a.useState(!0),[c,u]=a.useState(null),d=a.useRef(!1),p=a.useCallback(async()=>{d.current||l(!0),u(null);try{const h=await qa(e,r);o(h)}catch(h){u(h instanceof Error?h:new Error(String(h)))}finally{d.current=!0,l(!1)}},[e,r]);return a.useEffect(()=>{d.current=!1,p()},[p]),a.useEffect(()=>{if(!s||s<=0)return;const h=setInterval(p,s);return()=>clearInterval(h)},[s,p]),{streams:n,loading:i,error:c,refresh:p}}var Ya=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],ke=Ya.reduce((e,r)=>{const s=a.forwardRef((n,o)=>{const{asChild:i,...l}=n,c=i?Gt:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(c,{...l,ref:o})});return s.displayName=`Primitive.${r}`,{...e,[r]:s}},{});function Xa(e,r){e&&Ut.flushSync(()=>e.dispatchEvent(r))}var Ja="DismissableLayer",zt="dismissableLayer.update",Qa="dismissableLayer.pointerDownOutside",ei="dismissableLayer.focusOutside",vr,rs=a.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),ss=a.forwardRef((e,r)=>{const{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:n,onPointerDownOutside:o,onFocusOutside:i,onInteractOutside:l,onDismiss:c,...u}=e,d=a.useContext(rs),[p,h]=a.useState(null),m=(p==null?void 0:p.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,f]=a.useState({}),R=Ie(r,N=>h(N)),C=Array.from(d.layers),[x]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),k=C.indexOf(x),v=p?C.indexOf(p):-1,_=d.layersWithOutsidePointerEventsDisabled.size>0,T=v>=k,P=si(N=>{const w=N.target,g=[...d.branches].some(y=>y.contains(w));!T||g||(o==null||o(N),l==null||l(N),N.defaultPrevented||c==null||c())},m),E=ni(N=>{const w=N.target;[...d.branches].some(y=>y.contains(w))||(i==null||i(N),l==null||l(N),N.defaultPrevented||c==null||c())},m);return Zs(N=>{v===d.layers.size-1&&(n==null||n(N),!N.defaultPrevented&&c&&(N.preventDefault(),c()))},m),a.useEffect(()=>{if(p)return s&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(vr=m.body.style.pointerEvents,m.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(p)),d.layers.add(p),wr(),()=>{s&&d.layersWithOutsidePointerEventsDisabled.size===1&&(m.body.style.pointerEvents=vr)}},[p,m,s,d]),a.useEffect(()=>()=>{p&&(d.layers.delete(p),d.layersWithOutsidePointerEventsDisabled.delete(p),wr())},[p,d]),a.useEffect(()=>{const N=()=>f({});return document.addEventListener(zt,N),()=>document.removeEventListener(zt,N)},[]),t.jsx(ke.div,{...u,ref:R,style:{pointerEvents:_?T?"auto":"none":void 0,...e.style},onFocusCapture:je(e.onFocusCapture,E.onFocusCapture),onBlurCapture:je(e.onBlurCapture,E.onBlurCapture),onPointerDownCapture:je(e.onPointerDownCapture,P.onPointerDownCapture)})});ss.displayName=Ja;var ti="DismissableLayerBranch",ri=a.forwardRef((e,r)=>{const s=a.useContext(rs),n=a.useRef(null),o=Ie(r,n);return a.useEffect(()=>{const i=n.current;if(i)return s.branches.add(i),()=>{s.branches.delete(i)}},[s.branches]),t.jsx(ke.div,{...e,ref:o})});ri.displayName=ti;function si(e,r=globalThis==null?void 0:globalThis.document){const s=yt(e),n=a.useRef(!1),o=a.useRef(()=>{});return a.useEffect(()=>{const i=c=>{if(c.target&&!n.current){let u=function(){ns(Qa,s,d,{discrete:!0})};const d={originalEvent:c};c.pointerType==="touch"?(r.removeEventListener("click",o.current),o.current=u,r.addEventListener("click",o.current,{once:!0})):u()}else r.removeEventListener("click",o.current);n.current=!1},l=window.setTimeout(()=>{r.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(l),r.removeEventListener("pointerdown",i),r.removeEventListener("click",o.current)}},[r,s]),{onPointerDownCapture:()=>n.current=!0}}function ni(e,r=globalThis==null?void 0:globalThis.document){const s=yt(e),n=a.useRef(!1);return a.useEffect(()=>{const o=i=>{i.target&&!n.current&&ns(ei,s,{originalEvent:i},{discrete:!1})};return r.addEventListener("focusin",o),()=>r.removeEventListener("focusin",o)},[r,s]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function wr(){const e=new CustomEvent(zt);document.dispatchEvent(e)}function ns(e,r,s,{discrete:n}){const o=s.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});r&&o.addEventListener(e,r,{once:!0}),n?Xa(o,i):o.dispatchEvent(i)}var Ot="focusScope.autoFocusOnMount",$t="focusScope.autoFocusOnUnmount",br={bubbles:!1,cancelable:!0},oi="FocusScope",os=a.forwardRef((e,r)=>{const{loop:s=!1,trapped:n=!1,onMountAutoFocus:o,onUnmountAutoFocus:i,...l}=e,[c,u]=a.useState(null),d=yt(o),p=yt(i),h=a.useRef(null),m=Ie(r,C=>u(C)),f=a.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;a.useEffect(()=>{if(n){let C=function(_){if(f.paused||!c)return;const T=_.target;c.contains(T)?h.current=T:Ee(h.current,{select:!0})},x=function(_){if(f.paused||!c)return;const T=_.relatedTarget;T!==null&&(c.contains(T)||Ee(h.current,{select:!0}))},k=function(_){if(document.activeElement===document.body)for(const P of _)P.removedNodes.length>0&&Ee(c)};document.addEventListener("focusin",C),document.addEventListener("focusout",x);const v=new MutationObserver(k);return c&&v.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",C),document.removeEventListener("focusout",x),v.disconnect()}}},[n,c,f.paused]),a.useEffect(()=>{if(c){kr.add(f);const C=document.activeElement;if(!c.contains(C)){const k=new CustomEvent(Ot,br);c.addEventListener(Ot,d),c.dispatchEvent(k),k.defaultPrevented||(ai(ui(as(c)),{select:!0}),document.activeElement===C&&Ee(c))}return()=>{c.removeEventListener(Ot,d),setTimeout(()=>{const k=new CustomEvent($t,br);c.addEventListener($t,p),c.dispatchEvent(k),k.defaultPrevented||Ee(C??document.body,{select:!0}),c.removeEventListener($t,p),kr.remove(f)},0)}}},[c,d,p,f]);const R=a.useCallback(C=>{if(!s&&!n||f.paused)return;const x=C.key==="Tab"&&!C.altKey&&!C.ctrlKey&&!C.metaKey,k=document.activeElement;if(x&&k){const v=C.currentTarget,[_,T]=ii(v);_&&T?!C.shiftKey&&k===T?(C.preventDefault(),s&&Ee(_,{select:!0})):C.shiftKey&&k===_&&(C.preventDefault(),s&&Ee(T,{select:!0})):k===v&&C.preventDefault()}},[s,n,f.paused]);return t.jsx(ke.div,{tabIndex:-1,...l,ref:m,onKeyDown:R})});os.displayName=oi;function ai(e,{select:r=!1}={}){const s=document.activeElement;for(const n of e)if(Ee(n,{select:r}),document.activeElement!==s)return}function ii(e){const r=as(e),s=jr(r,e),n=jr(r.reverse(),e);return[s,n]}function as(e){const r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const o=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||o?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)r.push(s.currentNode);return r}function jr(e,r){for(const s of e)if(!li(s,{upTo:r}))return s}function li(e,{upTo:r}){if(getComputedStyle(e).visibility==="hidden")return!0;for(;e;){if(r!==void 0&&e===r)return!1;if(getComputedStyle(e).display==="none")return!0;e=e.parentElement}return!1}function ci(e){return e instanceof HTMLInputElement&&"select"in e}function Ee(e,{select:r=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&ci(e)&&r&&e.select()}}var kr=di();function di(){let e=[];return{add(r){const s=e[0];r!==s&&(s==null||s.pause()),e=Nr(e,r),e.unshift(r)},remove(r){var s;e=Nr(e,r),(s=e[0])==null||s.resume()}}}function Nr(e,r){const s=[...e],n=s.indexOf(r);return n!==-1&&s.splice(n,1),s}function ui(e){return e.filter(r=>r.tagName!=="A")}var fi="Portal",is=a.forwardRef((e,r)=>{var c;const{container:s,...n}=e,[o,i]=a.useState(!1);Ys(()=>i(!0),[]);const l=s||o&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return l?Os.createPortal(t.jsx(ke.div,{...n,ref:r}),l):null});is.displayName=fi;var Qt="Dialog",[ls,cs]=Br(Qt),[mi,he]=ls(Qt),ds=e=>{const{__scopeDialog:r,children:s,open:n,defaultOpen:o,onOpenChange:i,modal:l=!0}=e,c=a.useRef(null),u=a.useRef(null),[d=!1,p]=Js({prop:n,defaultProp:o,onChange:i});return t.jsx(mi,{scope:r,triggerRef:c,contentRef:u,contentId:It(),titleId:It(),descriptionId:It(),open:d,onOpenChange:p,onOpenToggle:a.useCallback(()=>p(h=>!h),[p]),modal:l,children:s})};ds.displayName=Qt;var us="DialogTrigger",fs=a.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,o=he(us,s),i=Ie(r,o.triggerRef);return t.jsx(ke.button,{type:"button","aria-haspopup":"dialog","aria-expanded":o.open,"aria-controls":o.contentId,"data-state":rr(o.open),...n,ref:i,onClick:je(e.onClick,o.onOpenToggle)})});fs.displayName=us;var er="DialogPortal",[pi,ms]=ls(er,{forceMount:void 0}),ps=e=>{const{__scopeDialog:r,forceMount:s,children:n,container:o}=e,i=he(er,r);return t.jsx(pi,{scope:r,forceMount:s,children:a.Children.map(n,l=>t.jsx(qt,{present:s||i.open,children:t.jsx(is,{asChild:!0,container:o,children:l})}))})};ps.displayName=er;var kt="DialogOverlay",hs=a.forwardRef((e,r)=>{const s=ms(kt,e.__scopeDialog),{forceMount:n=s.forceMount,...o}=e,i=he(kt,e.__scopeDialog);return i.modal?t.jsx(qt,{present:n||i.open,children:t.jsx(hi,{...o,ref:r})}):null});hs.displayName=kt;var hi=a.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,o=he(kt,s);return t.jsx(en,{as:Gt,allowPinchZoom:!0,shards:[o.contentRef],children:t.jsx(ke.div,{"data-state":rr(o.open),...n,ref:r,style:{pointerEvents:"auto",...n.style}})})}),Fe="DialogContent",xs=a.forwardRef((e,r)=>{const s=ms(Fe,e.__scopeDialog),{forceMount:n=s.forceMount,...o}=e,i=he(Fe,e.__scopeDialog);return t.jsx(qt,{present:n||i.open,children:i.modal?t.jsx(xi,{...o,ref:r}):t.jsx(gi,{...o,ref:r})})});xs.displayName=Fe;var xi=a.forwardRef((e,r)=>{const s=he(Fe,e.__scopeDialog),n=a.useRef(null),o=Ie(r,s.contentRef,n);return a.useEffect(()=>{const i=n.current;if(i)return Qs(i)},[]),t.jsx(gs,{...e,ref:o,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:je(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),(l=s.triggerRef.current)==null||l.focus()}),onPointerDownOutside:je(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&i.preventDefault()}),onFocusOutside:je(e.onFocusOutside,i=>i.preventDefault())})}),gi=a.forwardRef((e,r)=>{const s=he(Fe,e.__scopeDialog),n=a.useRef(!1),o=a.useRef(!1);return t.jsx(gs,{...e,ref:r,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var l,c;(l=e.onCloseAutoFocus)==null||l.call(e,i),i.defaultPrevented||(n.current||(c=s.triggerRef.current)==null||c.focus(),i.preventDefault()),n.current=!1,o.current=!1},onInteractOutside:i=>{var u,d;(u=e.onInteractOutside)==null||u.call(e,i),i.defaultPrevented||(n.current=!0,i.detail.originalEvent.type==="pointerdown"&&(o.current=!0));const l=i.target;((d=s.triggerRef.current)==null?void 0:d.contains(l))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&o.current&&i.preventDefault()}})}),gs=a.forwardRef((e,r)=>{const{__scopeDialog:s,trapFocus:n,onOpenAutoFocus:o,onCloseAutoFocus:i,...l}=e,c=he(Fe,s),u=a.useRef(null),d=Ie(r,u);return tn(),t.jsxs(t.Fragment,{children:[t.jsx(os,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:o,onUnmountAutoFocus:i,children:t.jsx(ss,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":rr(c.open),...l,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),t.jsxs(t.Fragment,{children:[t.jsx(vi,{titleId:c.titleId}),t.jsx(bi,{contentRef:u,descriptionId:c.descriptionId})]})]})}),tr="DialogTitle",ys=a.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,o=he(tr,s);return t.jsx(ke.h2,{id:o.titleId,...n,ref:r})});ys.displayName=tr;var vs="DialogDescription",ws=a.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,o=he(vs,s);return t.jsx(ke.p,{id:o.descriptionId,...n,ref:r})});ws.displayName=vs;var bs="DialogClose",js=a.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,o=he(bs,s);return t.jsx(ke.button,{type:"button",...n,ref:r,onClick:je(e.onClick,()=>o.onOpenChange(!1))})});js.displayName=bs;function rr(e){return e?"open":"closed"}var ks="DialogTitleWarning",[yi,Ns]=Xs(ks,{contentName:Fe,titleName:tr,docsSlug:"dialog"}),vi=({titleId:e})=>{const r=Ns(ks),s=`\`${r.contentName}\` requires a \`${r.titleName}\` for the component to be accessible for screen reader users.
|
|
24
|
-
|
|
25
|
-
If you want to hide the \`${r.titleName}\`, you can wrap it with our VisuallyHidden component.
|
|
26
|
-
|
|
27
|
-
For more information, see https://radix-ui.com/primitives/docs/components/${r.docsSlug}`;return a.useEffect(()=>{e&&(document.getElementById(e)||console.error(s))},[s,e]),null},wi="DialogDescriptionWarning",bi=({contentRef:e,descriptionId:r})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Ns(wi).contentName}}.`;return a.useEffect(()=>{var i;const o=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");r&&o&&(document.getElementById(r)||console.warn(n))},[n,e,r]),null},ji=ds,ki=fs,Ni=ps,Ci=hs,Ei=xs,Si=ys,Ii=ws,Cs=js,Es="AlertDialog",[Ti]=Br(Es,[cs]),Ne=cs(),Ss=e=>{const{__scopeAlertDialog:r,...s}=e,n=Ne(r);return t.jsx(ji,{...n,...s,modal:!0})};Ss.displayName=Es;var Ri="AlertDialogTrigger",Ai=a.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=Ne(s);return t.jsx(ki,{...o,...n,ref:r})});Ai.displayName=Ri;var Di="AlertDialogPortal",Is=e=>{const{__scopeAlertDialog:r,...s}=e,n=Ne(r);return t.jsx(Ni,{...n,...s})};Is.displayName=Di;var Mi="AlertDialogOverlay",Ts=a.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=Ne(s);return t.jsx(Ci,{...o,...n,ref:r})});Ts.displayName=Mi;var Ve="AlertDialogContent",[_i,Li]=Ti(Ve),Rs=a.forwardRef((e,r)=>{const{__scopeAlertDialog:s,children:n,...o}=e,i=Ne(s),l=a.useRef(null),c=Ie(r,l),u=a.useRef(null);return t.jsx(yi,{contentName:Ve,titleName:As,docsSlug:"alert-dialog",children:t.jsx(_i,{scope:s,cancelRef:u,children:t.jsxs(Ei,{role:"alertdialog",...i,...o,ref:c,onOpenAutoFocus:je(o.onOpenAutoFocus,d=>{var p;d.preventDefault(),(p=u.current)==null||p.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[t.jsx(Dn,{children:n}),t.jsx(Fi,{contentRef:l})]})})})});Rs.displayName=Ve;var As="AlertDialogTitle",Ds=a.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=Ne(s);return t.jsx(Si,{...o,...n,ref:r})});Ds.displayName=As;var Ms="AlertDialogDescription",_s=a.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=Ne(s);return t.jsx(Ii,{...o,...n,ref:r})});_s.displayName=Ms;var Pi="AlertDialogAction",Ls=a.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,o=Ne(s);return t.jsx(Cs,{...o,...n,ref:r})});Ls.displayName=Pi;var Ps="AlertDialogCancel",Fs=a.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,{cancelRef:o}=Li(Ps,s),i=Ne(s),l=Ie(r,o);return t.jsx(Cs,{...i,...n,ref:l})});Fs.displayName=Ps;var Fi=({contentRef:e})=>{const r=`\`${Ve}\` requires a description for the component to be accessible for screen reader users.
|
|
28
|
-
|
|
29
|
-
You can add a description to the \`${Ve}\` by passing a \`${Ms}\` 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 \`${Ve}\`. 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 a.useEffect(()=>{var n;document.getElementById((n=e.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(r)},[r,e]),null},Oi=Ss,$i=Is,Wi=Ts,Hi=Rs,Bi=Ls,Vi=Fs,zi=Ds,Ui=_s;function Cr({...e}){return t.jsx(Oi,{"data-slot":"alert-dialog",...e})}function Ki({...e}){return t.jsx($i,{"data-slot":"alert-dialog-portal",...e})}function qi({className:e,...r}){return t.jsx(Wi,{"data-slot":"alert-dialog-overlay",className:de("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),...r})}function Er({className:e,onSubmit:r,...s}){return t.jsxs(Ki,{children:[t.jsx(qi,{}),t.jsx(Hi,{"data-slot":"alert-dialog-content",className:de("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:n=>{n.preventDefault(),r==null||r(n)},...s})]})}function Sr({className:e,...r}){return t.jsx("div",{"data-slot":"alert-dialog-header",className:de("flex flex-col gap-2 text-center sm:text-left",e),...r})}function Ir({className:e,...r}){return t.jsx("div",{"data-slot":"alert-dialog-footer",className:de("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function Tr({className:e,...r}){return t.jsx(zi,{"data-slot":"alert-dialog-title",className:de("text-lg font-semibold",e),...r})}function Rr({className:e,...r}){return t.jsx(Ui,{"data-slot":"alert-dialog-description",className:de("text-muted-foreground text-sm",e),...r})}function Ar({className:e,...r}){return t.jsx(Bi,{className:de(Kr(),e),...r})}function Dr({className:e,...r}){return t.jsx(Vi,{className:de(Kr({variant:"outline"}),e),...r})}function Gi({...e}){return t.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...e})}function Zi({className:e,...r}){return t.jsx("ol",{"data-slot":"breadcrumb-list",className:de("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",e),...r})}function Mr({className:e,...r}){return t.jsx("li",{"data-slot":"breadcrumb-item",className:de("inline-flex items-center gap-1.5",e),...r})}function Yi({asChild:e,className:r,...s}){const n=e?Gt:"a";return t.jsx(n,{"data-slot":"breadcrumb-link",className:de("hover:text-foreground transition-colors",r),...s})}function Xi({className:e,...r}){return t.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:de("text-foreground font-normal",e),...r})}function Ji({children:e,className:r,...s}){return t.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:de("[&>svg]:size-3.5",r),...s,children:e??t.jsx(Kt,{})})}const ge=4,Qi="[Encrypted]",_r=3e3;function Lr(e){return e==="pending"||e==="running"}const $e=200,el=6;function gt(e,r=0){if(e==null)return e;if(ArrayBuffer.isView(e)&&!(e instanceof DataView)){const s=e,n=s.constructor.name,o=Array.from({length:Math.min(s.length,8)},(l,c)=>s[c]),i=s.length>8?", …":"";return`${n}(${s.length}) [${o.join(", ")}${i}]`}if(e instanceof ArrayBuffer)return`ArrayBuffer(${e.byteLength})`;if(r>=el)return Array.isArray(e)?`Array(${e.length})`:typeof e=="object"?"{…}":e;if(Array.isArray(e)){if(e.length<=$e)return e.map(n=>gt(n,r+1));const s=e.slice(0,$e).map(n=>gt(n,r+1));return s.push(`… ${e.length-$e} more items`),s}if(typeof e=="object"){const s=Object.keys(e),n={},o=Math.min(s.length,$e);for(let i=0;i<o;i++)n[s[i]]=gt(e[s[i]],r+1);return s.length>$e&&(n[`… ${s.length-$e} more keys`]="…"),n}return e}const tl=()=>new Promise(e=>setTimeout(e,0)),rl=64;function sl(e){if(e.length<ge)return"framed";const s=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);return s>0&&s<=10*1024*1024?"framed":"legacy"}function nl(e,r,s,n,o){const[i,l]=a.useState([]),[c,u]=a.useState(!1),[d,p]=a.useState(null),h=a.useRef(null),m=a.useRef(0),f=a.useRef(0),R=a.useRef(null),C=a.useRef(o);C.current=o;const x=a.useRef(null),k=a.useCallback(async(v,_,T)=>{let P=v;if(P.length>=ge+4&&!nr(P)){const y=new DataView(P.buffer,P.byteOffset,P.byteLength).getUint32(0,!1);y>0&&y<=10*1024*1024&&y===P.length-ge&&(P=P.slice(ge))}let E;try{if(nr(P)){if(!_)return{encrypted:!0};const g=P.slice(4);E=or(await $n(_,g),T)}else E=or(P,T)}catch{E=Qi}let N;try{if(typeof E=="string")N=E;else{const g=gt(E);N=JSON.stringify(g,null,2)}}catch{N="[Serialization Error]"}return{encrypted:!1,chunk:{id:m.current++,text:N}}},[]);return a.useEffect(()=>{if(l([]),p(null),m.current=0,f.current=0,x.current=null,R.current&&(clearTimeout(R.current),R.current=null),!r||!s){u(!1);return}let v=!0;const _=new AbortController;h.current=_,u(!0);const T=Mn(),P=w=>{const g=m.current++;let y;try{const M=JSON.parse(w);y=JSON.stringify(M,null,2)}catch{y=w}return{id:g,text:y}},E=async(w,g,y)=>{const M=await Ka(e,r,s,_.signal,y==null?void 0:y.cursor),S=(y==null?void 0:y.skipFrames)??0,I=M.body.getReader(),O=new TextDecoder;let $=new Uint8Array(0),L=null,A="",b=0;const F=U=>{const W=new Uint8Array($.length+U.length);W.set($,0),W.set(U,$.length),$=W};for(;!_.signal.aborted;){const{value:U,done:W}=await I.read();if(W){L==="legacy"&&A.trim()&&(b++,b>S&&w.push(P(A.trim())),A="");break}if(L===null?(F(U),$.length>=ge&&(L=sl($)),L==="legacy"&&(A=O.decode($,{stream:!0}),$=new Uint8Array(0))):L==="legacy"?A+=O.decode(U,{stream:!0}):F(U),L==="legacy"){const X=A.split(`
|
|
34
|
-
`);A=X.pop()??"";for(const j of X){const D=j.trim();D&&(b++,b>S&&w.push(P(D)))}continue}let K=0,J=0;for(;K+ge<=$.length;){const j=new DataView($.buffer,$.byteOffset+K,$.byteLength-K).getUint32(0,!1);if(j===0||j>10*1024*1024||K+ge+j>$.length)break;const D=$.slice(K+ge,K+ge+j);if(K+=ge+j,b++,b<=S)continue;const B=await k(D,g,T);if(B.encrypted)return I.cancel().catch(()=>{}),{encrypted:!0};if(w.push(B.chunk),J++,J%rl===0&&(await tl(),_.signal.aborted||!v))break}$=$.slice(K)}return{encrypted:!1,frameCount:b,cursor:M.cursor,done:M.done}};return(async()=>{try{const w=n?await Wn(n):void 0,g=[],y=await E(g,w);if(y.encrypted){v&&(p("This stream is encrypted. Click Decrypt to view."),u(!1));return}if(f.current=y.frameCount,x.current=y.cursor,!v||_.signal.aborted)return;if(l(g),y.done){u(!1);return}if(Lr(C.current)){const M=async()=>{if(!(!v||_.signal.aborted)){try{const S=[],I=await E(S,w,{cursor:x.current,skipFrames:f.current});if(!I.encrypted&&(f.current=I.frameCount,I.cursor&&(x.current=I.cursor),S.length>0&&v&&l(O=>[...O,...S]),I.done)){u(!1);return}}catch(S){console.warn("Stream poll error:",S)}v&&!_.signal.aborted&&(R.current=setTimeout(M,_r))}};R.current=setTimeout(M,_r)}else u(!1)}catch(w){if(_.signal.aborted)return;v&&(p(w instanceof Error?w.message:String(w)),u(!1))}})(),()=>{v=!1,_.abort(),R.current&&(clearTimeout(R.current),R.current=null)}},[e,r,s,n,k]),a.useEffect(()=>{!Lr(o)&&R.current&&(clearTimeout(R.current),R.current=null,u(!1))},[o]),{chunks:i,isLive:c,error:d}}const ol=100,al=100;function il(e,r,s={}){const{sortOrder:n="asc",encryptionKey:o,enabled:i=!0}=s,[l,c]=a.useState([]),[u,d]=a.useState(!0),[p,h]=a.useState(null),[m,f]=a.useState(),[R,C]=a.useState(!1),[x,k]=a.useState(!1),v=a.useRef(!1),_=a.useRef(o);_.current=o;const T=a.useCallback(async()=>{if(!v.current){v.current=!0,d(!0),h(null),c([]),f(void 0),C(!1);try{const{error:E,result:N}=await ue(Be(e,r,{sortOrder:n,limit:ol,withData:!1}));if(E)h(E);else{const w=N.data.map(me),g=_.current;if(g){const y=await Promise.all(w.map(M=>He(M,g)));c(y)}else c(w);f(N.hasMore?N.cursor:void 0),C(!!N.hasMore)}}catch(E){h(E)}finally{d(!1),v.current=!1}}},[e,r,n]);a.useEffect(()=>{i&&T()},[T,i]),a.useEffect(()=>{if(!o||l.length===0)return;let E=!1;return Promise.all(l.map(N=>He(N,o))).then(N=>{E||c(N)}).catch(()=>{}),()=>{E=!0}},[o]);const P=a.useCallback(async()=>{if(!(x||!m)){k(!0);try{const{error:E,result:N}=await ue(Be(e,r,{cursor:m,sortOrder:n,limit:al,withData:!1}));if(E)h(E);else{if(N.data.length>0){const w=N.data.map(me),g=_.current;if(g){const y=await Promise.all(w.map(M=>He(M,g)));c(M=>[...M,...y])}else c(y=>[...y,...w])}f(N.hasMore?N.cursor:void 0),C(!!N.hasMore)}}catch(E){h(E)}finally{k(!1)}}},[e,r,n,m,x]);return{events:l,loading:u,error:p,hasMore:R,loadingMore:x,loadMore:P}}function ll({hasError:e,errorMessage:r}){return t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs(qr,{children:[t.jsx(Gr,{asChild:!0,children:t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("div",{className:`w-2 h-2 rounded-full ${e?"bg-red-500":"bg-green-500 animate-pulse"}`}),t.jsx("span",{className:`text-xs $
|
|
35
|
-
hasError
|
|
36
|
-
? 'text-red-600 dark:text-red-400'
|
|
37
|
-
: 'text-muted-foreground'`,children:e?"Error":"Live"})]})}),t.jsx(Zr,{children:t.jsx("p",{children:e?`Error updating data: ${r}`:`Content updates every ${_n/1e3} seconds`})})]})})}({...rn});function cl({runId:e,selectedId:r}){var Re;const s=$s(),[n]=Pr(),{serverConfig:o}=Ln(),[i,l]=a.useState(!1),[c,u]=a.useState(!1),[d,p]=a.useState(!1),[h,m]=a.useState(!1),f=a.useMemo(()=>({}),[]),R=n.get("tab")||"trace",C=R==="graph"?"trace":R,x=n.get("streamId"),k=a.useCallback(q=>{const te=new URLSearchParams(n.toString());for(const[ne,re]of Object.entries(q))re===null?te.delete(ne):te.set(ne,re);s(`?${te.toString()}`,{preventScrollReset:!0})},[s,n]),v=a.useCallback(q=>{k(q!=="streams"?{tab:q,streamId:null}:{tab:q})},[k]),_=a.useCallback(q=>{k({streamId:q})},[k]),T=a.useCallback(q=>{k({tab:"streams",streamId:q})},[k]),P=a.useCallback(async(q,te)=>sn(f,q,{correlationIds:[te]}),[f]),E=a.useRef(null),N=a.useCallback(async(q,te)=>{await nn(f,q,te)},[f]),w=a.useCallback(async q=>{const{error:te,result:ne}=await ue(ar(f,q.runId,q.eventId,"all"));if(te)throw te;const re=E.current?await He(ne,E.current):me(ne);return"eventData"in re?re.eventData:null},[f]),g=a.useCallback(async(q,te)=>{const{error:ne,result:re}=await ue(ar(f,e,te,"all"));if(ne)throw ne;const ae=E.current?await He(re,E.current):me(re);return"eventData"in ae?ae.eventData:null},[f,e]);o.backendId==="local"||o.backendId;const{run:y,events:M,loading:S,error:I,update:O,loadMoreTraceData:$,hasMoreTraceData:L,isLoadingMoreTraceData:A}=za(f,e,{live:!0}),b=y??{},[F,U]=a.useState(null);E.current=F;const[W,K]=a.useState("asc"),{events:J,loading:X,hasMore:j,loadingMore:D,loadMore:B}=il(f,e,{sortOrder:W,encryptionKey:F??void 0,enabled:C==="events"}),[z,ee]=a.useState(null),{data:V,loading:H,error:Y,refresh:Z}=Oa(f,(z==null?void 0:z.resource)??"run",(z==null?void 0:z.resourceId)??"",{runId:z==null?void 0:z.runId,enabled:!!(z!=null&&z.resource&&(z!=null&&z.resourceId)&&z.resource!=="hook"),encryptionKey:F??void 0}),[se,oe]=a.useState(!1),fe=a.useCallback(async()=>{if(F){Z();return}oe(!0);try{const{error:q,result:te}=await ue(Pn(f,e));if(q){De.error(`Failed to fetch encryption key: ${q.message}`);return}if(!te){De.error("Encryption is not configured for this deployment.");return}U(te),De.success("Run data decrypted successfully")}finally{oe(!1)}},[F,f,e,Z]),Oe=a.useCallback(q=>{ee(q)},[]),{streams:we,loading:Ce,error:Ke}=Za(f,e),{chunks:ot,isLive:at,error:xe}=nl(f,x,e,F,b.status),it=()=>{p(!0)},lt=async()=>{if(!i)try{l(!0),p(!1),await pn(f,e),await O(),De.success("Run cancelled successfully")}catch(q){console.error("Failed to cancel run:",q),De.error("Failed to cancel run",{description:q instanceof Error?q.message:"An unknown error occurred"})}finally{l(!1)}},ct=()=>{m(!0)},dt=async()=>{if(!c)try{u(!0),m(!1);const q=await hn(f,b.runId);De.success("New run started successfully",{description:`Run ID: ${q}`}),s(`/run/${q}`)}catch(q){console.error("Failed to re-run workflow:",q),De.error("Failed to start new run",{description:q instanceof Error?q.message:"An unknown error occurred"})}finally{u(!1),m(!1)}};if(I&&!y)return t.jsxs(on,{variant:"destructive",className:"m-4",children:[t.jsx(Fr,{className:"h-4 w-4"}),t.jsx(an,{children:"Error loading workflow run"}),t.jsx(ln,{children:I.message})]});const Te=(Re=ze(b.workflowName))==null?void 0:Re.shortName;return t.jsxs(t.Fragment,{children:[t.jsx(Cr,{open:d,onOpenChange:p,children:t.jsxs(Er,{children:[t.jsxs(Sr,{children:[t.jsx(Tr,{children:"Cancel Workflow Run?"}),t.jsx(Rr,{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?"})]}),t.jsxs(Ir,{children:[t.jsx(Dr,{children:"Keep Running"}),t.jsx(Ar,{onClick:lt,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Run"})]})]})}),t.jsx(Cr,{open:h,onOpenChange:m,children:t.jsxs(Er,{children:[t.jsxs(Sr,{children:[t.jsx(Tr,{children:"Replay Run?"}),t.jsx(Rr,{children:"This can potentially re-run code that is meant to only execute once. Are you sure you want to replay the workflow run?"})]}),t.jsxs(Ir,{children:[t.jsx(Dr,{children:"Cancel"}),t.jsx(Ar,{onClick:dt,children:"Replay Run"})]})]})}),t.jsxs("div",{className:"flex flex-col h-[calc(100vh-97px)]",children:[t.jsxs("div",{className:"flex-none space-y-4",children:[t.jsx(Gi,{children:t.jsxs(Zi,{children:[t.jsx(Mr,{children:t.jsx(Yi,{asChild:!0,children:t.jsx(Ws,{to:"/",children:"Runs"})})}),t.jsx(Ji,{}),t.jsx(Mr,{children:t.jsx(Xi,{className:"font-mono text-xs",children:e})})]})}),t.jsxs("div",{className:"space-y-4 p-6 border rounded-lg",children:[t.jsxs("div",{className:"flex items-start justify-between",children:[t.jsx("div",{className:"mb-4",children:t.jsx("h1",{className:"text-xl font-semibold",children:Te||t.jsx(Ae,{className:"w-[260px] h-[28px]"})})}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(ll,{hasError:!1,errorMessage:""}),t.jsx(cn,{env:f,runId:e,runStatus:b.status,events:M,eventsLoading:S,loading:S,onRerunClick:ct,onCancelClick:it,callbacks:{onSuccess:O}})]})]}),t.jsxs("div",{className:"flex items-start gap-8",children:[t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Status"}),b.status?t.jsx(dn,{status:b.status,context:b}):t.jsx(Ae,{className:"w-[55px] h-[24px]"})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Duration"}),t.jsx("div",{className:"text-xs",children:b.runId?b.startedAt?(()=>{const q=(b.completedAt?new Date(b.completedAt).getTime():Date.now())-new Date(b.startedAt).getTime(),te=Math.floor(q/1e3);if(te<60)return`${te}s`;const ne=Math.floor(te/60),re=te%60;if(ne<60)return re>0?`${ne}m ${re}s`:`${ne}m`;const ae=Math.floor(ne/60),Ge=ne%60;return Ge>0?`${ae}h ${Ge}m`:`${ae}h`})():"-":t.jsx(Ae,{className:"w-[60px] h-[20px]"})})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Run ID"}),b.runId?t.jsx(un,{text:b.runId,children:t.jsx("div",{className:"text-xs mt-0.5 font-mono",children:b.runId})}):t.jsx(Ae,{className:"w-[280px] h-[20px]"})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Queued"}),b.createdAt?t.jsx("div",{className:"text-xs",children:t.jsx(ut,{date:b.createdAt})}):t.jsx(Ae,{className:"w-[110px] h-[20px]"})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Started"}),t.jsx("div",{className:"text-xs",children:b.runId?b.startedAt?t.jsx(ut,{date:b.startedAt}):"-":t.jsx(Ae,{className:"w-[110px] h-[20px]"})})]}),t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsx("div",{className:"text-xs text-muted-foreground",children:"Completed"}),t.jsx("div",{className:"text-xs",children:b.runId?b.completedAt?t.jsx(ut,{date:b.completedAt}):"-":t.jsx(Ae,{className:"w-[110px] h-[20px]"})})]}),b.expiredAt!=null&&t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(qr,{children:[t.jsx(Gr,{asChild:!0,children:t.jsxs("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",t.jsx(Bn,{className:"w-3 h-3"})]})}),t.jsx(Zr,{children:t.jsx("p",{children:"The storage data for this run has expired and is no longer available."})})]}),t.jsx("div",{className:"text-xs",children:t.jsx(ut,{date:b.expiredAt})})]})]})]})]}),t.jsx("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:t.jsxs(fn,{value:C,onValueChange:q=>v(q),className:"flex-1 flex flex-col min-h-0",children:[t.jsxs(mn,{className:"mb-4 flex-none",children:[t.jsxs(Tt,{value:"trace",className:"gap-2",children:[t.jsx(Mt,{className:"h-4 w-4"}),"Trace"]}),!1,t.jsxs(Tt,{value:"events",className:"gap-2",children:[t.jsx(Mt,{className:"h-4 w-4"}),"Events"]}),t.jsxs(Tt,{value:"streams",className:"gap-2",children:[t.jsx(Mt,{className:"h-4 w-4"}),"Streams"]})]}),t.jsx(Rt,{value:"trace",className:"mt-0 flex-1 min-h-0",children:t.jsx(Qe,{title:"Failed to load trace viewer",children:t.jsx("div",{className:"h-full",children:t.jsx(Pa,{error:I,events:M,run:b,isLoading:S,spanDetailData:V,spanDetailLoading:H,spanDetailError:Y,onSpanSelect:Oe,onStreamClick:T,onWakeUpSleep:P,onResolveHook:N,onLoadEventData:g,onLoadMoreSpans:$,hasMoreSpans:L,isLoadingMoreSpans:A,encryptionKey:F??void 0,onDecrypt:fe,isDecrypting:se})})})}),t.jsx(Rt,{value:"events",className:"mt-0 flex-1 min-h-0",children:t.jsx(Qe,{title:"Failed to load events list",children:t.jsx("div",{className:"h-full",children:t.jsx(go,{events:J,run:b,onLoadEventData:w,hasMoreEvents:j,isLoadingMoreEvents:D,onLoadMoreEvents:B,encryptionKey:F??void 0,isLoading:X,sortOrder:W,onSortOrderChange:K,onDecrypt:fe,isDecrypting:se})})})}),t.jsx(Rt,{value:"streams",className:"mt-0 flex-1 min-h-0",children:t.jsx(Qe,{title:"Failed to load stream data",children:t.jsxs("div",{className:"h-full flex gap-4",children:[t.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:[t.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 (",we.length,")"]}),t.jsx("div",{className:"overflow-auto max-h-[calc(100vh-400px)]",children:Ce?t.jsx("div",{className:"p-4 flex items-center justify-center",children:t.jsx(Fn,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):Ke?t.jsx("div",{className:"p-4 text-xs text-destructive",children:Ke.message}):we.length===0?t.jsx("div",{className:"p-4 text-xs",style:{color:"var(--ds-gray-600)"},children:"No streams found for this run"}):we.map(q=>t.jsx("button",{type:"button",onClick:()=>_(q),className:"w-full text-left px-3 py-2 text-xs font-mono truncate hover:bg-accent transition-colors",style:{backgroundColor:x===q?"var(--ds-gray-200)":"transparent",color:"var(--ds-gray-1000)"},title:q,children:q},q))})]}),t.jsx("div",{className:"flex-1 min-w-0",children:x?xe!=null&&xe.includes("encrypted")&&!F?t.jsxs("div",{className:"h-full flex flex-col items-center justify-center gap-3 rounded-lg border p-4",style:{borderColor:"var(--ds-gray-300)",backgroundColor:"var(--ds-gray-100)"},children:[t.jsx(Vr,{className:"h-6 w-6",style:{color:"var(--ds-gray-700)"}}),t.jsx("div",{className:"text-sm",style:{color:"var(--ds-gray-900)"},children:"This stream is encrypted."}),t.jsx(Yt,{onClick:fe,loading:se})]}):t.jsx(On,{streamId:x,chunks:ot,isLive:at,error:xe!=null&&xe.includes("encrypted")?null:xe}):t.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:t.jsx("div",{className:"text-sm",style:{color:"var(--ds-gray-600)"},children:we.length>0?"Select a stream to view its data":"No streams available"})})})]})})}),!1]})})]})]})}const pl=Hs(function(){const r=Bs(),[s]=Pr(),n=r.runId,o=s.get("stepId"),i=s.get("eventId"),l=s.get("hookId"),c=o||i||l||void 0;return t.jsx(Qe,{title:"Failed to load run details",children:t.jsx(cl,{runId:n,selectedId:c})})});export{pl as default};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
(function(){"use strict";const w=(s,e,r)=>{const t=e.parent;for(let o=((t==null?void 0:t.row)||-1)+1;;++o){let n=s[o];if(!n)n=[],s.push(n);else if(!n.every(({startTime:i,endTime:l})=>i+r>e.endTime||l-r<e.startTime))continue;e.row=o,n.push(e);break}};let h=0;self.addEventListener("message",s=>{const e=s.data;switch(h=Math.max(h,(e==null?void 0:e.requestId)||0),e.type){case"calculateSpanPositions":g(e.root);break;case"filterSpans":T(e.root,e.filter);break}});const p=(s,e)=>{if("parent"in s){const t=s;t.row=-1,t.isVisible=!0,e.push(t)}const r=s.children.slice().sort((t,o)=>t.startTime-o.startTime||o.duration-t.duration);for(const t of r)p(t,e)},g=s=>{const e=h,r=[],t=[];p(s,t);let o=Date.now()-10,n=-64,i=0;const l=()=>{for(const a of r)a.sort((c,f)=>c.startTime-f.startTime);const u={requestId:e,type:"setRowsResult",rows:r,isEnd:!t.length};postMessage(u),o=Date.now(),n=i};for(;;){const u=t.shift();if(!u){l();return}w(r,u,.001),++i,(Date.now()-o>=15||i-n>=256)&&l()}},d=new RegExp("(?<=^|\\s)(?<pair>(?<key>[\\w.]+):(?<value>\\S*))","g"),T=(s,e)=>{const r=h,t=new Set,o=e.replace(d,"").replace(/\s{2,}/g," ").trim(),n=[];for(const a of e.matchAll(d)){const{key:c="",value:f=""}=a.groups||{};n.push([c,f.toLocaleLowerCase()])}const i=a=>a.name.toLocaleLowerCase().includes(o)||a.spanId.toLocaleLowerCase().includes(o)?n.every(([f,L])=>{const m=a.attributes[f];return m?String(m).toLocaleLowerCase().includes(L):!1}):!1,l=a=>{for(const c of a.children)i(c.span)&&t.add(c.span.spanId),l(c)};l(s),postMessage({requestId:r,type:"updateHighlight",matches:t})}})();
|