@workflow/web 4.1.1 → 4.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/build/client/assets/encryption-80GMP4r0.js +26 -0
  2. package/build/client/assets/entry.client-BWsSsWQm.js +11899 -0
  3. package/build/client/assets/highlighted-body-B3W2YXNL-CdV7thm2.js +18 -0
  4. package/build/client/assets/home-BMWyCqWy.js +3984 -0
  5. package/build/client/assets/index-DQa-BExo.js +9432 -0
  6. package/build/client/assets/{manifest-8cfb1d31.js → manifest-c0697365.js} +1 -1
  7. package/build/client/assets/mermaid-3ZIDBTTL-B_qZU5zW.js +48064 -0
  8. package/build/client/assets/root-CLs7COa2.js +690 -0
  9. package/build/client/assets/run-detail-D7xkVxzE.js +6699 -0
  10. package/build/client/assets/worker-CqHKTA7D.js +115 -0
  11. package/build/client/assets/workflow-graph-viewer-D5yEggTb.js +16175 -0
  12. package/build/server/assets/{app-BjALV8M8.js → app-fdUHF124.js} +1 -1
  13. package/build/server/assets/{highlighted-body-B3W2YXNL-CPKrO4kT.js → highlighted-body-B3W2YXNL-2WxWqSYU.js} +2 -2
  14. package/build/server/assets/{index-DbMFm9t3.js → index-C64kz8oy.js} +8 -7
  15. package/build/server/assets/{mermaid-3ZIDBTTL-DGuUhvM4.js → mermaid-3ZIDBTTL-FF5ZIJp-.js} +2 -2
  16. package/build/server/assets/{server-build-DfI2avTQ.js → server-build-Mddyhj54.js} +109 -47
  17. package/build/server/assets/{token-BBou_ahS.js → token-D_Q6dhhy.js} +2 -2
  18. package/build/server/assets/{token-util-CdxtEAt7.js → token-util-BAhz4ocz.js} +2 -2
  19. package/build/server/index.js +1 -1
  20. package/package.json +7 -7
  21. package/build/client/assets/encryption-8OvC6eoJ.js +0 -1
  22. package/build/client/assets/entry.client-BiVEcoV8.js +0 -29
  23. package/build/client/assets/highlighted-body-B3W2YXNL-YMQAPcBs.js +0 -1
  24. package/build/client/assets/home-CBUniDnp.js +0 -40
  25. package/build/client/assets/index-BmZS3y7B.js +0 -59
  26. package/build/client/assets/mermaid-3ZIDBTTL-B00nsi3k.js +0 -210
  27. package/build/client/assets/root-CHWaz-_g.js +0 -26
  28. package/build/client/assets/run-detail-DHdCNGRJ.js +0 -37
  29. package/build/client/assets/worker-D-HfgUMl.js +0 -1
  30. package/build/client/assets/workflow-graph-viewer-Cb_2KEX3.js +0 -161
@@ -1,26 +0,0 @@
1
- import{r as l,j as e,w as z,v as B,M as F,L as q,S as G,x as J,O as Q,y as X,i as Y,z as _,A as ee,B as te}from"./index-BmZS3y7B.js";import{c as C,u as se,T as W,a as P,b as I,r as re,t as H,B as A,L as ne,d as R,e as oe,S as ae,f as ie}from"./mermaid-3ZIDBTTL-B00nsi3k.js";var ce=(t,r,s,n,a,i,u,h)=>{let o=document.documentElement,c=["light","dark"];function d(f){(Array.isArray(t)?t:[t]).forEach(x=>{let k=x==="class",S=k&&i?a.map(b=>i[b]||b):a;k?(o.classList.remove(...S),o.classList.add(i&&i[f]?i[f]:f)):o.setAttribute(x,f)}),v(f)}function v(f){h&&c.includes(f)&&(o.style.colorScheme=f)}function m(){return window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}if(n)d(n);else try{let f=localStorage.getItem(r)||s,x=u&&f==="system"?m():f;d(x)}catch{}},O=["light","dark"],K="(prefers-color-scheme: dark)",le=typeof window>"u",$=l.createContext(void 0),de={setTheme:t=>{},themes:[]},T=()=>{var t;return(t=l.useContext($))!=null?t:de},ue=t=>l.useContext($)?l.createElement(l.Fragment,null,t.children):l.createElement(me,{...t}),he=["light","dark"],me=({forcedTheme:t,disableTransitionOnChange:r=!1,enableSystem:s=!0,enableColorScheme:n=!0,storageKey:a="theme",themes:i=he,defaultTheme:u=s?"system":"light",attribute:h="data-theme",value:o,children:c,nonce:d,scriptProps:v})=>{let[m,f]=l.useState(()=>pe(a,u)),[x,k]=l.useState(()=>m==="system"?E():m),S=o?Object.values(o):i,b=l.useCallback(p=>{let g=p;if(!g)return;p==="system"&&s&&(g=E());let j=o?o[g]:g,V=r?ge(d):null,w=document.documentElement,M=y=>{y==="class"?(w.classList.remove(...S),j&&w.classList.add(j)):y.startsWith("data-")&&(j?w.setAttribute(y,j):w.removeAttribute(y))};if(Array.isArray(h)?h.forEach(M):M(h),n){let y=O.includes(u)?u:null,U=O.includes(g)?g:y;w.style.colorScheme=U}V==null||V()},[d]),L=l.useCallback(p=>{let g=typeof p=="function"?p(m):p;f(g);try{localStorage.setItem(a,g)}catch{}},[m]),N=l.useCallback(p=>{let g=E(p);k(g),m==="system"&&s&&!t&&b("system")},[m,t]);l.useEffect(()=>{let p=window.matchMedia(K);return p.addListener(N),N(p),()=>p.removeListener(N)},[N]),l.useEffect(()=>{let p=g=>{g.key===a&&(g.newValue?f(g.newValue):L(u))};return window.addEventListener("storage",p),()=>window.removeEventListener("storage",p)},[L]),l.useEffect(()=>{b(t??m)},[t,m]);let D=l.useMemo(()=>({theme:m,setTheme:L,forcedTheme:t,resolvedTheme:m==="system"?x:m,themes:s?[...i,"system"]:i,systemTheme:s?x:void 0}),[m,L,t,x,s,i]);return l.createElement($.Provider,{value:D},l.createElement(fe,{forcedTheme:t,storageKey:a,attribute:h,enableSystem:s,enableColorScheme:n,defaultTheme:u,value:o,themes:i,nonce:d,scriptProps:v}),c)},fe=l.memo(({forcedTheme:t,storageKey:r,attribute:s,enableSystem:n,enableColorScheme:a,defaultTheme:i,value:u,themes:h,nonce:o,scriptProps:c})=>{let d=JSON.stringify([s,r,i,t,h,u,n,a]).slice(1,-1);return l.createElement("script",{...c,suppressHydrationWarning:!0,nonce:typeof window>"u"?o:"",dangerouslySetInnerHTML:{__html:`(${ce.toString()})(${d})`}})}),pe=(t,r)=>{if(le)return;let s;try{s=localStorage.getItem(t)||void 0}catch{}return s||r},ge=t=>{let r=document.createElement("style");return t&&r.setAttribute("nonce",t),r.appendChild(document.createTextNode("*,*::before,*::after{-webkit-transition:none!important;-moz-transition:none!important;-o-transition:none!important;-ms-transition:none!important;transition:none!important}")),document.head.appendChild(r),()=>{window.getComputedStyle(document.body),setTimeout(()=>{document.head.removeChild(r)},1)}},E=t=>(t||(t=window.matchMedia(K)),t.matches?"dark":"light");/**
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 xe=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],ve=C("activity",xe);/**
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 ye=[["path",{d:"M7 7h10v10",key:"1tivn9"}],["path",{d:"M7 17 17 7",key:"1vkiza"}]],be=C("arrow-up-right",ye);/**
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 je=[["rect",{width:"20",height:"14",x:"2",y:"3",rx:"2",key:"48i651"}],["line",{x1:"8",x2:"16",y1:"21",y2:"21",key:"1svkeh"}],["line",{x1:"12",x2:"12",y1:"17",y2:"21",key:"vw1qmm"}]],we=C("monitor",je);/**
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 Ce=[["path",{d:"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401",key:"kfwtm"}]],ke=C("moon",Ce);/**
22
- * @license lucide-react v0.575.0 - ISC
23
- *
24
- * This source code is licensed under the ISC license.
25
- * See the LICENSE file in the root directory of this source tree.
26
- */const Le=[["circle",{cx:"12",cy:"12",r:"4",key:"4exip2"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"m4.93 4.93 1.41 1.41",key:"149t6j"}],["path",{d:"m17.66 17.66 1.41 1.41",key:"ptbguv"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"m6.34 17.66-1.41 1.41",key:"1m8zz5"}],["path",{d:"m19.07 4.93-1.41 1.41",key:"1shlcs"}]],Ne=C("sun",Le);function Z(t){return t==null?void 0:t["local.shortName"]}function He(t,r){return(t==="local"||t==="@workflow/world-local")&&Z(r)==="packages/web"}function Se(t){const r=t.WORKFLOW_VERCEL_ENV||"production",s=t.WORKFLOW_VERCEL_TEAM,n=t.WORKFLOW_VERCEL_PROJECT,a=s&&n?`${s}/${n}`:n||s||"Unknown";return`Connected to Vercel ${r} (${a})`}function Ee(t){const r=t==null?void 0:t["derived.WORKFLOW_POSTGRES_URL.hostname"],s=t==null?void 0:t["derived.WORKFLOW_POSTGRES_URL.database"];return r?`Connected to Postgres (${r}${s?`/${s}`:""})`:"Connected to Postgres"}function $e(t){const{backendDisplayName:r,backendId:s,displayInfo:n,publicEnv:a}=t;switch(s){case"local":case"@workflow/world-local":return`Local Dev: ${Z(n)||"Unknown"}`;case"vercel":case"@workflow/world-vercel":return Se(a);case"postgres":case"@workflow/world-postgres":return Ee(n);default:return`Connected to: ${r}`}}function Te(t){return e.jsx("div",{className:"grid grid-cols-[auto,1fr] gap-x-4 gap-y-1",children:t.map(({key:r,value:s})=>e.jsxs("div",{className:"contents",children:[e.jsx("div",{className:"font-mono text-xs text-muted-foreground",children:r}),e.jsx("div",{className:"font-mono text-xs text-foreground break-all",children:s})]},r))})}function Ve(){const{serverConfig:t}=se(),r=$e(t),{backendId:s}=t,n=He(s,t.displayInfo),a=Object.entries(t.publicEnv).sort(([o],[c])=>o.localeCompare(c)),i=[...t.sensitiveEnvKeys].sort(),u=a.length>0||i.length>0||n,h=e.jsx("div",{className:"text-md whitespace-nowrap",children:e.jsx("span",{className:"font-medium",children:r})});return u?e.jsxs(W,{children:[e.jsx(P,{asChild:!0,children:h}),e.jsx(I,{children:e.jsxs("div",{className:"flex flex-col gap-2 max-w-[640px]",children:[n&&e.jsxs("div",{className:"mb-2",children:[e.jsx("div",{className:"font-medium text-foreground",children:"Local data directory looks misconfigured"}),e.jsxs("div",{className:"text-muted-foreground",children:["This UI appears to be pointing at ",e.jsx("code",{children:"packages/web"}),". Configure the local data directory / working directory and restart the web UI. See"," ",e.jsx("a",{className:"underline",href:"https://useworkflow.dev/docs/observability",target:"_blank",rel:"noopener noreferrer",children:"docs"}),"."]})]}),Te([...a.map(([o,c])=>({key:o,value:c})),...i.map(o=>({key:o,value:"*****"}))])]})})]}):h}function Me(){const[t,r]=l.useState(!1),s=l.useMemo(()=>({}),[]),n=l.useCallback(async()=>{r(!0);const a=["workflow","step"],i=[];try{for(const o of a){const c=await re(s,o,{timeout:3e4});c.success&&i.push({endpoint:o,result:c.data})}const u=i.every(o=>o.result.healthy),h=i.some(o=>o.result.healthy);if(u){const o=i.reduce((c,d)=>c+(d.result.latencyMs??0),0);H.success("All endpoints healthy",{description:`Workflow and Step endpoints are responding (${o}ms total)`})}else if(h){const o=i.filter(d=>d.result.healthy),c=i.filter(d=>!d.result.healthy);H.warning("Partial health check success",{description:`${o.map(d=>d.endpoint).join(", ")} OK; ${c.map(d=>`${d.endpoint}: ${d.result.error||"failed"}`).join(", ")}`})}else{const o=i.map(c=>`${c.endpoint}: ${c.result.error||"failed"}`).join("; ");H.error("Health check failed",{description:o})}}catch(u){const h=u instanceof Error?u.message:String(u);H.error("Health check error",{description:h})}finally{r(!1)}},[s]);return e.jsxs(W,{children:[e.jsx(P,{asChild:!0,children:e.jsxs(A,{variant:"ghost",size:"sm",onClick:n,disabled:t,className:"gap-1.5",children:[t?e.jsx(ne,{className:"h-4 w-4 animate-spin"}):e.jsx(ve,{className:"h-4 w-4"}),e.jsx("span",{className:"hidden sm:inline",children:t?"Checking...":"Health Check"})]})}),e.jsx(I,{children:e.jsxs("p",{children:["Run a queue-based health check on workflow and step endpoints.",e.jsx("br",{}),"This bypasses Deployment Protection."]})})]})}function Re({value:t,onValueChange:r,options:s,className:n}){return e.jsx("div",{className:R("inline-flex h-9 items-center justify-center rounded-lg bg-muted p-1 text-muted-foreground",n),children:s.map(a=>e.jsxs("button",{type:"button",onClick:()=>r(a.value),className:R("inline-flex items-center justify-center whitespace-nowrap rounded-md px-3 py-1 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50",t===a.value?"bg-background text-foreground shadow":"hover:bg-background/50"),children:[a.icon,a.label&&e.jsx("span",{className:"ml-2",children:a.label})]},a.value))})}function Oe(){const{theme:t,setTheme:r}=T(),s=t||"system";return e.jsx(Re,{value:s,onValueChange:n=>r(n),options:[{value:"system",icon:e.jsx(we,{className:"h-4 w-4"})},{value:"light",icon:e.jsx(Ne,{className:"h-4 w-4"})},{value:"dark",icon:e.jsx(ke,{className:"h-4 w-4"})}],className:"h-8"})}function _e(){return e.jsx(A,{asChild:!0,variant:"outline",size:"sm",children:e.jsxs("a",{href:"https://useworkflow.dev/docs/observability",target:"_blank",rel:"noopener noreferrer",className:"gap-1",children:[e.jsx("span",{children:"Docs"}),e.jsx(be,{className:"h-4 w-4"})]})})}const We=({...t})=>{const{theme:r="system"}=T();return e.jsx(oe,{theme:r,className:"toaster group",toastOptions:{classNames:{toast:"group toast group-[.toaster]:bg-background group-[.toaster]:text-foreground group-[.toaster]:border-border group-[.toaster]:shadow-lg",description:"group-[.toast]:text-muted-foreground",actionButton:"group-[.toast]:bg-primary group-[.toast]:text-primary-foreground",cancelButton:"group-[.toast]:bg-muted group-[.toast]:text-muted-foreground",error:"group-[.toaster]:bg-destructive group-[.toaster]:text-destructive-foreground group-[.toaster]:border-destructive",success:"group-[.toaster]:bg-green-600 group-[.toaster]:text-white group-[.toaster]:border-green-600"}},...t})};function Pe({className:t}={}){return e.jsxs("svg",{viewBox:"0 0 1792 240",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:t||"h-6 w-auto",role:"img","aria-label":"Workflow Logo",children:[e.jsx("title",{children:"Workflow Logo"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M753.933 55.627C806.249 55.627 840.685 91.718 840.685 147.345C840.685 202.971 806.249 239.062 753.933 239.062C701.286 239.062 666.851 202.971 666.851 147.345C666.851 91.7181 701.286 55.6271 753.933 55.627ZM753.933 90.0625C726.451 90.0626 710.889 111.254 710.889 147.345C710.889 183.436 726.451 204.627 753.933 204.627C781.084 204.627 796.978 183.436 796.978 147.345C796.978 111.254 781.084 90.0625 753.933 90.0625Z",className:"fill-foreground"}),e.jsx("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M1445.65 55.627C1497.96 55.627 1532.4 91.718 1532.4 147.345C1532.4 202.971 1497.96 239.062 1445.65 239.062C1393 239.062 1358.56 202.971 1358.56 147.345C1358.56 91.718 1393 55.627 1445.65 55.627ZM1445.65 90.0625C1418.16 90.0625 1402.6 111.254 1402.6 147.345C1402.6 183.436 1418.16 204.627 1445.65 204.627C1472.8 204.627 1488.69 183.436 1488.69 147.345C1488.69 111.254 1472.8 90.0626 1445.65 90.0625Z",className:"fill-foreground"}),e.jsx("path",{d:"M902.473 94.0361C909.095 70.8584 922.34 59.5997 944.855 59.5996H961.079V92.3799H944.524C916.38 92.38 904.128 106.949 904.128 135.094V235.089H861.746V59.5996H901.48L902.473 94.0361Z",className:"fill-foreground"}),e.jsx("path",{d:"M1019.25 138.735L1091.11 59.5996H1143.09L1074.55 132.113L1146.4 235.089H1098.72L1046.74 157.609L1019.25 187.078V235.089H976.872V0H1019.25V138.735Z",className:"fill-foreground"}),e.jsx("path",{d:"M1263.63 32.7803H1235.82C1224.89 32.7803 1217.28 41.3893 1217.28 54.9648V59.5996H1260.98V92.3799H1217.28V235.089H1174.56V92.3799H1149.4V59.5996H1174.56V54.9648C1174.56 19.5359 1191.78 0 1230.85 0H1263.63V32.7803Z",className:"fill-foreground"}),e.jsx("path",{d:"M1322.58 189.396C1322.58 197.673 1327.22 202.309 1335.5 202.31H1348.74V235.089H1324.57C1298.08 235.089 1280.2 218.534 1280.2 191.052V0H1322.58V189.396Z",className:"fill-foreground"}),e.jsx("path",{d:"M1604.59 186.416L1641.02 59.5996H1677.77L1713.86 186.416L1749.95 59.5996H1791.34L1737.7 235.089H1694.32L1659.56 116.883L1624.79 235.089H1581.42L1527.77 59.5996H1568.83L1604.59 186.416Z",className:"fill-foreground"}),e.jsx("path",{d:"M472.173 174.847L514.895 0.671875H554.66L598.038 174.847L640.432 0.671875H685.454L623.015 234H575.692L534.942 77.5713L493.863 234H446.869L384.1 0.671875H429.122L472.173 174.847Z",className:"fill-foreground"}),e.jsx("path",{d:"M125.776 0C120.929 1.64945e-05 117 3.9291 117 8.77539V61.4248C117 66.2711 120.929 70.2002 125.776 70.2002H160.875L161.253 70.2051C169.032 70.4023 175.301 76.6734 175.495 84.4531L175.5 84.8252V143.325C175.5 148.171 179.429 152.101 184.276 152.101H219.375L219.753 152.105C227.53 152.303 233.798 158.571 233.995 166.348L234 166.726V225.225C234 230.071 237.929 234 242.776 234H295.425C300.271 234 304.2 230.071 304.2 225.225V172.575C304.2 167.729 300.271 163.8 295.425 163.8H260.25C252.334 163.76 245.905 157.43 245.705 149.553L245.7 149.176V90.6758C245.7 85.8295 241.771 81.9004 236.925 81.9004H201.825C193.874 81.9004 187.405 75.5551 187.205 67.6523L187.2 67.2754V8.77539C187.2 3.9291 183.271 1.64951e-05 178.425 0H125.776Z",className:"fill-foreground"}),e.jsx("path",{d:"M67.2755 81.9004C62.4293 81.9004 58.5002 85.8295 58.5002 90.6758V143.325C58.5004 148.171 62.4294 152.101 67.2755 152.101H102.375L102.753 152.105C110.53 152.303 116.798 158.571 116.995 166.348L117 166.726V225.225C117 230.071 120.929 234 125.776 234H178.425C183.271 234 187.2 230.071 187.2 225.225V172.575C187.2 167.729 183.271 163.8 178.425 163.8H143.25C135.334 163.76 128.905 157.43 128.705 149.553L128.7 149.176V90.6758C128.7 85.8295 124.771 81.9004 119.925 81.9004H67.2755Z",className:"fill-foreground"}),e.jsx("path",{d:"M8.77454 163.8C3.92844 163.8 0.00012207 167.729 0.00012207 172.575V225.225C0.00012207 230.071 3.92844 234 8.77454 234H61.4249C66.2712 234 70.2003 230.071 70.2003 225.225V172.575C70.2003 167.729 66.2712 163.8 61.4249 163.8H8.77454Z",className:"fill-foreground"})]})}function Ue({children:t}){return e.jsxs("html",{lang:"en",suppressHydrationWarning:!0,children:[e.jsxs("head",{children:[e.jsx("meta",{charSet:"utf-8"}),e.jsx("meta",{name:"viewport",content:"width=device-width, initial-scale=1"}),e.jsx("link",{rel:"icon",href:"/favicon.ico"}),e.jsx("title",{children:"Workflow Observability UI"}),e.jsx("meta",{name:"description",content:"Web interface for inspecting flow runs, steps, streams, and events"}),e.jsx(F,{}),e.jsx(q,{})]}),e.jsxs("body",{className:"antialiased",children:[t,e.jsx(G,{}),e.jsx(J,{})]})]})}function Ie(t){const{runId:r,stepId:s,hookId:n}=t;return s?`/run/${r}?sidebar=step&stepId=${s}`:n?`/run/${r}?sidebar=hook&hookId=${n}`:`/run/${r}`}function Ae(t){const{resource:r,id:s,runId:n}=t;switch(r){case"run":return`/run/${s}`;case"step":return n?`/run/${n}?sidebar=step&stepId=${s}`:null;case"stream":return n?`/run/${n}?sidebar=stream&streamId=${s}`:null;case"event":return n?`/run/${n}?sidebar=event&eventId=${s}`:null;case"hook":return n?`/run/${n}?sidebar=hook&hookId=${s}`:`/?sidebar=hook&hookId=${s}`;default:return null}}function Ke({children:t}){const r=ee(),[s]=te(),{setTheme:n}=T(),a=s.get("id"),i=s.get("runId"),u=s.get("stepId"),h=s.get("hookId"),o=s.get("resource"),c=s.get("theme"),d=l.useRef(!1);return l.useEffect(()=>{c&&(c==="light"||c==="dark"||c==="system")&&n(c)},[c,n]),l.useEffect(()=>{const v=window.location.pathname;if(v.startsWith("/run/")){d.current=!0;return}if(!(v!=="/"&&d.current)){if(o){if(!a)return;const m=Ae({resource:o,id:a,runId:i});m?(d.current=!0,r(m)):console.warn(`Can't deep-link to ${o} ${a}.`);return}if(i){d.current=!0,r(Ie({runId:i,stepId:u,hookId:h}));return}}},[o,a,i,u,h,r]),e.jsxs("div",{className:"min-h-screen flex flex-col",children:[e.jsxs(ie,{delayDuration:0,children:[e.jsx("div",{className:"sticky top-0 z-50 bg-background border-b px-6 py-4",children:e.jsxs("div",{className:"flex items-center justify-between w-full",children:[e.jsxs("div",{className:"flex items-center gap-4",children:[e.jsx(_,{to:"/",children:e.jsx("h1",{className:"flex items-center gap-2",title:"Workflow Observability",children:e.jsx(Pe,{})})}),e.jsx("div",{className:"h-6 w-px bg-border","aria-hidden":"true"}),e.jsx(Ve,{})]}),e.jsxs("div",{className:"ml-auto flex items-center gap-2",children:[e.jsx(Me,{}),e.jsx("div",{className:"h-6 w-px bg-border","aria-hidden":"true"}),e.jsx(Oe,{}),e.jsx(_e,{})]})]})}),e.jsx("div",{className:"flex-1 px-6 pt-6",children:t})]}),e.jsx(We,{})]})}const ze=z(function({loaderData:r}){return e.jsx(ue,{attribute:"class",defaultTheme:"system",enableSystem:!0,disableTransitionOnChange:!0,storageKey:"workflow-theme",children:e.jsx(ae,{serverConfig:r.serverConfig,children:e.jsx(Ke,{children:e.jsx(Q,{})})})})}),Be=B(function(){const r=X(),s=Y(r)&&r.status===404;return e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"text-4xl font-bold mb-4",children:s?"404":"Error"}),e.jsx("p",{className:"text-muted-foreground mb-6",children:s?"This page does not exist.":"Something went wrong."}),e.jsx(_,{to:"/",className:"text-primary underline",children:"Go to dashboard"})]})})});export{Be as ErrorBoundary,Ue as Layout,ze as default};
@@ -1,37 +0,0 @@
1
- import{j as t,r as o,f as Kt,C as Ws,A as Hs,B as $r,z as Bs,w as Vs,G as zs}from"./index-BmZS3y7B.js";import{O as rt,C as Wr,Q as st,B as Ue,j as qt,q as Hr,U as Br,Z as Us,S as Vr,R as zr,p as Ks,o as qs,X as Gs,N as Qe,V as Zs,G as Ys,I as de,u as ht,W as _e,Y as Xs,v as ke,_ as yt,$ as Js,t as Ur,a0 as Qs,s as en,a1 as Tt,w as Gt,l as tn,m as rn,a2 as sn,a3 as nn,a4 as on,r as an,A as ln,c as cn,d as dn,a as Ae,a5 as un,F as fn,e as mn,b as ut,T as pn,K as hn,L as It,M as Rt,y as xn,a6 as gn}from"./workflow-graph-viewer-Cb_2KEX3.js";import{c as Nt,h as Ke,M as Q,N as Zt,Y as yn,O as ve,U as ar,W as vt,_ as vn,X as wn,Z as Le,$ as bn,a0 as jn,a1 as Wt,a2 as kn,a3 as Fe,a4 as we,a5 as Z,a6 as Nn,a7 as Cn,a8 as At,a9 as le,aa as ft,ab as wt,ac as Be,ad as Te,ae as Kr,af as Xe,ag as Dt,ah as En,ai as Sn,aj as Tn,ak as In,al as Rn,am as An,an as Dn,ao as Ve,ap as fe,aq as qr,l as Pe,F as Ht,ar as Mn,as as _n,at as Ln,au as Yt,E as Ie,av as Pn,d as ue,aw as Gr,ax as ir,ay as lr,az as Fn,T as Zr,a as Yr,b as Xr,aA as On,u as $n,aB as cr,aC as Wn,t as De,L as Hn,aD as Bn}from"./mermaid-3ZIDBTTL-B00nsi3k.js";import{decrypt as Vn,importKey as zn}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 Un=[["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"}]],Kn=Nt("circle-question-mark",Un);/**
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 qn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Gn=Nt("info",qn);/**
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 Zn=[["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",Zn);/**
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 Yn=[["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"}]],Xn=Nt("type",Yn),Jn="@keyframes wf-spinner-fade{0%{opacity:1}100%{opacity:.15}}";function Xt({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:Jn}}),s.delays.map((n,a)=>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(${a*s.angle}deg) translate(${e*.36}px)`,animation:`wf-spinner-fade ${s.duration}ms linear infinite`,animationDelay:`${n}ms`}},n))]})}const Qn=".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 Jt({decrypted:e=!1,loading:r=!1,onClick:s}){return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:Qn}}),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(Xt,{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=Ke(),s=e.stack,n=typeof e.message=="string"?e.message:void 0,a=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(a).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(Wr,{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 eo=".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 to({loading:e=!1,onClick:r,label:s="Load more",loadingLabel:n="Loading..."}){return t.jsxs(t.Fragment,{children:[t.jsx("style",{dangerouslySetInnerHTML:{__html:eo}}),t.jsxs("button",{type:"button",onClick:r,disabled:e,className:"wf-load-more",children:[e&&t.jsx(Xt,{size:14}),e?n:s]})]})}const ro=".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 so({options:e,value:r,onChange:s}){var c,u;const[n,a]=o.useState(!1),i=o.useRef(null),l=((c=e.find(d=>d.value===r))==null?void 0:c.label)??((u=e[0])==null?void 0:u.label)??"";return o.useEffect(()=>{if(!n)return;function d(f){i.current&&!i.current.contains(f.target)&&a(!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:ro}}),t.jsxs("button",{type:"button",className:"wf-menu-btn",onClick:()=>a(!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),a(!1)},children:d.label},d.value))})]})}const no=[{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 oo(e){let r=Math.abs(e);const s=[];for(const{unit:n,ms:a}of no){const i=Math.floor(r/a);if((i>0||s.length>0)&&(s.push(`${i} ${n}${i!==1?"s":""}`),r%=a),s.length===3)break}return s.join(", ")}function ao(e){const[r,s]=o.useState("");return o.useEffect(()=>{const n=()=>{const i=Date.now()-e,l=oo(i);s(l?`${l} ago`:"Just now")};n();const a=setInterval(n,1e3);return()=>clearInterval(a)},[e]),r}function dr({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,a=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:a})]}),t.jsx("span",{style:{fontSize:11,fontFamily:"var(--font-mono, monospace)",fontVariantNumeric:"tabular-nums",color:"var(--ds-gray-900)",whiteSpace:"nowrap"},children:i})]})}function io({date:e}){const r=Intl.DateTimeFormat().resolvedOptions().timeZone,s=ao(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(dr,{date:e,zone:"UTC"}),t.jsx(dr,{date:e,zone:r})]})]})}const lo=330,mt=8;function co({triggerRect:e,onMouseEnter:r,onMouseLeave:s,date:n}){const a=o.useRef(null),[i,l]=o.useState({position:"fixed",zIndex:9999,visibility:"hidden"});return o.useEffect(()=>{const c=e.top>240?"above":"below",u=e.left+e.width/2,d=a.current,f=d?d.offsetWidth:lo,x=d?d.offsetHeight:100;let h=u-f/2;h=Math.max(mt,Math.min(h,window.innerWidth-f-mt));let p;c==="above"?(p=e.top-x-6,p<mt&&(p=e.bottom+6)):(p=e.bottom+6,p+x>window.innerHeight-mt&&(p=e.top-x-6)),l({position:"fixed",left:h,top:p,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]),Kt.createPortal(t.jsx("div",{ref:a,onMouseEnter:r,onMouseLeave:s,style:i,children:t.jsx(io,{date:n})}),document.body)}function Jr({date:e,children:r}){const[s,n]=o.useState(!1),[a,i]=o.useState(null),l=o.useRef(null),c=o.useRef(null);o.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)},f=()=>{d(),c.current=setTimeout(()=>n(!1),120)},x=()=>{d(),l.current&&i(l.current.getBoundingClientRect()),n(!0)};return t.jsxs("span",{ref:l,onMouseEnter:x,onMouseLeave:f,style:{display:"inline-flex"},children:[r,s&&a&&t.jsx(co,{triggerRect:a,onMouseEnter:d,onMouseLeave:f,date:u})]})}const uo=new Set(["step_failed","step_retrying","run_failed","workflow_failed"]),Qr={appearance:"none",WebkitAppearance:"none",border:"none",background:"transparent"},es="workflow-dot-pulse 1.25s cubic-bezier(0, 0, 0.2, 1) infinite";function fo(e){return e.toLocaleTimeString("en-US",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1})+"."+e.getMilliseconds().toString().padStart(3,"0")}function ts(e){return e.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join(" ")}function mo(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 po(e,r){var a,i;const s=new Map;if(e){for(const l of e)if(l.eventType==="step_created"&&l.correlationId){const c=((a=l.eventData)==null?void 0:a.stepName)??"",u=st(String(c));s.set(l.correlationId,(u==null?void 0:u.shortName)??c)}}const n=r!=null&&r.workflowName?((i=Ue(r.workflowName))==null?void 0:i.shortName)??r.workflowName:null;return{correlationNameMap:s,workflowName:n}}function ho(e){const r=new Map,s=new Map,n=new Map;for(const a of e){const i=new Date(a.createdAt).getTime(),l=a.correlationId??"__run__",c=a.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 Bt(e){if(!e||typeof e!="object")return!1;for(const r of Object.values(e))if(ve(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,xo=20,_t="var(--ds-gray-500)";function ur({isFirst:e,isLast:r,isRunLevel:s,statusDotColor:n,pulse:a=!1,hasSelection:i,showBranch:l,showLaneLine:c,isLaneStart:u,isLaneEnd:d,continuationOnly:f=!1}){const x=s?8:6,h=s?5:6,p=i&&!l&&!s?.3:1;return t.jsxs("div",{className:"relative flex-shrink-0 self-stretch",style:{width:tt,minHeight:f?0:void 0},children:[t.jsx("div",{style:{position:"absolute",left:8,top:f?0:e?"50%":0,bottom:f?0:r?"50%":0,width:2,backgroundColor:_t,zIndex:0}}),!f&&t.jsxs(t.Fragment,{children:[t.jsxs("div",{style:{position:"absolute",left:h,top:"50%",transform:"translateY(-50%)",width:x,height:x,zIndex:2},children:[t.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:"var(--ds-background-100)",zIndex:0}}),a&&t.jsx("div",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:n,opacity:.75*p,animation:es,zIndex:1}}),t.jsx("div",{style:{position:"relative",width:"100%",height:"100%",borderRadius:"50%",backgroundColor:n,opacity:p,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:xo,top:f?0:u?"50%":0,bottom:f?0:d?"50%":0,width:2,backgroundColor:_t,zIndex:0}})]})}function fr({value:e,className:r,style:s}){const[n,a]=o.useState(!1),i=o.useRef(null);o.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]);const l=o.useCallback(c=>{c.stopPropagation(),navigator.clipboard.writeText(e).then(()=>{a(!0),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{a(!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:Qr,"aria-label":`Copy ${e}`,children:n?t.jsx(Hr,{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 go(e,r){if(!r||!uo.has(r)||e==null||typeof e!="object")return null;const s=e;return et(s.error)?s.error:et(s)?s:null}function yo({data:e,eventType:r}){const s=o.useMemo(()=>go(e,r),[e,r]),[n,a]=o.useState(!1),i=o.useRef(null),l=o.useMemo(()=>xt(e),[e]);o.useEffect(()=>()=>{i.current!==null&&window.clearTimeout(i.current)},[]);const c=o.useMemo(()=>{try{return JSON.stringify(l,null,2)}catch{return String(l)}},[l]),u=o.useCallback(d=>{d.stopPropagation(),navigator.clipboard.writeText(c).then(()=>{a(!0),i.current!==null&&window.clearTimeout(i.current),i.current=window.setTimeout(()=>{a(!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:{...Qr,color:"var(--ds-gray-700)"},"aria-label":"Copy payload",children:n?t.jsxs(t.Fragment,{children:[t.jsx(Hr,{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 vo=[{value:"desc",label:"Newest"},{value:"asc",label:"Oldest"}];function mr(){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 wo({event:e,index:r,isFirst:s,isLast:n,isExpanded:a,onToggleExpand:i,activeGroupKey:l,selectedGroupKey:c,selectedGroupRange:u,correlationNameMap:d,workflowName:f,durationMap:x,onSelectGroup:h,onHoverGroup:p,onLoadEventData:E,cachedEventData:w,onCacheEventData:O,encryptionKey:b,onEncryptedDataDetected:m}){const[k,D]=o.useState(!1),[j,I]=o.useState(w),[N,g]=o.useState(null),[C,y]=o.useState(w!==null);o.useEffect(()=>{w!==null&&!b&&Bt(w)&&(m==null||m())},[]);const P=jt(e.eventType)?"__run__":e.correlationId??void 0,T=mo(e.eventType),v=new Date(e.createdAt),$="eventData"in e&&e.eventData!=null,_=jt(e.eventType),S=_?f??"-":e.correlationId?d.get(e.correlationId)??"-":"-",R=e.correlationId??(_?"__run__":""),M=R?x.get(R):void 0,A=l!==void 0,W=P!==void 0&&P===l,z=A&&!W,V=A&&W,J=A&&W&&!_,X=u!==null&&r>=u.first&&r<=u.last,U=u!==null&&r===u.first,L=u!==null&&r===u.last,F=o.useCallback(async()=>{if(j===null){if(w!==null){I(w),y(!0);return}if(!k){D(!0),g(null);try{if(!E){g("Event details unavailable");return}const q=await E(e);q!=null&&(I(q),O(e.eventId,q),!b&&Bt(q)&&(m==null||m()))}catch(q){g(q instanceof Error?q.message:"Failed to load event details")}finally{D(!1),y(!0)}}}},[e,j,k,E,O,b,m,w]);o.useEffect(()=>{!a||k||F()},[]),o.useEffect(()=>{b&&C&&E&&(I(null),y(!1),E(e).then(q=>{q!=null&&(I(q),O(e.eventId,q)),y(!0)}).catch(()=>{y(!0)}))},[b]);const K=o.useCallback(()=>{h(P===c?void 0:P),i(e.eventId),a||F()},[c,P,h,i,e.eventId,a,F]),Y=j??($?e.eventData:null),re=k?j:Y,B=z?.3:1;return t.jsxs("div",{"data-event-id":e.eventId,onMouseEnter:()=>p(P),onMouseLeave:()=>p(void 0),children:[t.jsxs("div",{role:"button",tabIndex:0,onClick:K,onKeyDown:q=>{(q.key==="Enter"||q.key===" ")&&K()},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(ur,{isFirst:s,isLast:n&&!a,isRunLevel:_,statusDotColor:T,pulse:V,hasSelection:A,showBranch:J,showLaneLine:X,isLaneStart:U,isLaneEnd:L}),t.jsxs("div",{className:"flex items-center flex-1 min-w-0",style:{opacity:B,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(qt,{className:"h-3 w-3 transition-transform",style:{color:"var(--ds-gray-900)",transform:a?"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(Jr,{date:v,children:t.jsx("span",{children:fo(v)})})}),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:[V&&t.jsx("span",{style:{position:"absolute",inset:0,borderRadius:"50%",backgroundColor:T,opacity:.75,animation:es}}),t.jsx("span",{style:{position:"relative",width:6,height:6,borderRadius:"50%",backgroundColor:T}})]}),ts(e.eventType)]})}),t.jsx("div",{className:"min-w-0 px-4 overflow-hidden text-ellipsis whitespace-nowrap",style:{flex:"2 1 0%"},title:S!=="-"?S:void 0,children:S}),t.jsx(fr,{value:e.correlationId||"",className:"font-mono",style:{flex:"3 1 0%"}}),t.jsx(fr,{value:e.eventId,className:"font-mono",style:{flex:"3 1 0%"}})]})]}),a&&t.jsxs("div",{className:"flex",children:[t.jsx(ur,{isFirst:!1,isLast:n,isRunLevel:_,hasSelection:A,showBranch:!1,showLaneLine:X&&!L,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:B,transition:"opacity 150ms"},children:[((M==null?void 0:M.queued)!==void 0||(M==null?void 0:M.ran)!==void 0)&&t.jsxs("div",{className:"px-2 pb-1.5 text-xs flex gap-3",style:{color:"var(--ds-gray-900)"},children:[M.queued!==void 0&&M.queued>0&&t.jsxs("span",{children:["Queued for"," ",t.jsx("span",{className:"font-mono tabular-nums",children:ar(M.queued)})]}),M.ran!==void 0&&t.jsxs("span",{children:["Ran for"," ",t.jsx("span",{className:"font-mono tabular-nums",children:ar(M.ran)})]})]}),re!=null?t.jsx(yo,{data:re,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}):k||j===null&&!C&&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 bo({events:e,run:r,onLoadEventData:s,hasMoreEvents:n=!1,isLoadingMoreEvents:a=!1,onLoadMoreEvents:i,encryptionKey:l,isLoading:c=!1,sortOrder:u,onSortOrderChange:d,onDecrypt:f,isDecrypting:x=!1,hasEncryptedData:h=!1}){const[p,E]=o.useState("asc"),w=u??p,O=o.useCallback(B=>{d?d(B):E(B)},[d]),b=o.useMemo(()=>{if(!e||e.length===0)return[];const B=w==="desc"?-1:1;return[...e].sort((q,H)=>B*(new Date(q.createdAt).getTime()-new Date(H.createdAt).getTime()))},[e,w]),m=o.useMemo(()=>{if(!e)return!1;for(const B of e){const q=B.eventData;if(Bt(q))return!0}return!1},[e]),[k,D]=o.useState(!1),j=o.useCallback(()=>{D(!0)},[]),I=h||m||k,{correlationNameMap:N,workflowName:g}=o.useMemo(()=>po(e??null,r??null),[e,r]),C=o.useMemo(()=>ho(b),[b]),[y,P]=o.useState(void 0),[T,v]=o.useState(void 0),$=o.useCallback(B=>{P(B)},[]),_=o.useCallback(B=>{v(B)},[]),S=y??T,[R,M]=o.useState(()=>new Set),A=o.useCallback(B=>{M(q=>{const H=new Set(q);return H.has(B)?H.delete(B):H.add(B),H})},[]),W=o.useRef(new Map),z=o.useCallback((B,q)=>{W.current.set(B,q)},[]),V=o.useMemo(()=>{const B=new Map;for(const q of b){const H=jt(q.eventType)?"__run__":q.correlationId??"";H&&B.set(q.eventId,H)}return B},[b]);o.useEffect(()=>{y!==void 0&&M(B=>{if(B.size===0)return B;let q=!1;const H=new Set;for(const te of B)V.get(te)===y?H.add(te):q=!0;return q?H:B})},[y,V]);const J=o.useMemo(()=>{if(!S||S==="__run__")return null;let B=-1,q=-1;for(let H=0;H<b.length;H++)b[H].correlationId===S&&(B===-1&&(B=H),q=H);return B>=0?{first:B,last:q}:null},[S,b]),[X,U]=o.useState(""),L=o.useRef(null),F=o.useMemo(()=>{const B=[];for(let q=0;q<b.length;q++){const H=b[q],te=jt(H.eventType),oe=te?g??"":H.correlationId?N.get(H.correlationId)??"":"";B.push({fields:[H.eventId,H.correlationId??"",H.eventType,ts(H.eventType),oe].map(ce=>ce.toLowerCase()),groupKey:H.correlationId??(te?"__run__":void 0),eventId:H.eventId,index:q})}return B},[b,N,g]);o.useEffect(()=>{var te;const B=X.trim().toLowerCase();if(!B){P(void 0);return}let q=null,H=0;for(const oe of F)for(const ce of oe.fields)if(ce&&ce.includes(B)){const me=B.length/ce.length;me>H&&(H=me,q=oe)}q&&(P(q.groupKey),(te=L.current)==null||te.scrollToIndex({index:q.index,align:"center",behavior:"smooth"}))},[X,F]);const K=o.useRef(!1);b.length>0&&(K.current=!0);const Y=c&&!K.current,re=c&&K.current&&b.length===0;return Y?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(mr,{})]}):!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.jsx(Zt.Provider,{value:f?{onDecrypt:f,isDecrypting:x}:void 0,children: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:X,onChange:B=>U(B.target.value),style:{marginLeft:-16,paddingInline:12,fontFamily:"inherit",fontSize:14,background:"transparent",border:"none",outline:"none",height:40,width:"100%"}})]}),t.jsx(so,{options:vo,value:w,onChange:O}),(I||l)&&f&&t.jsx(Jt,{decrypted:!!l,loading:x,onClick:f})]}),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"})]}),re?t.jsx(mr,{}):t.jsx(yn,{ref:L,totalCount:b.length,overscan:20,defaultItemHeight:40,endReached:()=>{!n||a||i==null||i()},itemContent:B=>{const q=b[B];return t.jsx(wo,{event:q,index:B,isFirst:B===0,isLast:B===b.length-1,isExpanded:R.has(q.eventId),onToggleExpand:A,activeGroupKey:S,selectedGroupKey:y,selectedGroupRange:J,correlationNameMap:N,workflowName:g,durationMap:C,onSelectGroup:$,onHoverGroup:_,onLoadEventData:s,cachedEventData:W.current.get(q.eventId)??null,onCacheEventData:z,encryptionKey:l,onEncryptedDataDetected:j})},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:[b.length," event",b.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(to,{loading:a,onClick:()=>void(i==null?void 0:i())})})})]})]})})}function jo({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(ko,{message:r},s))})}function ko({message:e}){const r=e.role,s=Eo(e.content),n=Co(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((a,i)=>t.jsx(No,{part:a,role:r},i))})]})}function No({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(vn,{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 Co(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 Eo(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 So=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 rs({data:e}){const r=Ke();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(So(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 ae({summary:e,children:r,onToggle:s,disabled:n=!1,summaryClassName:a,contentClassName:i}){return n?t.jsx("div",{className:`rounded-md border px-2.5 py-1.5 text-xs ${a??""}`,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 ${a??""}`,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(qt,{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 To({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 Io({tabs:e,activeTab:r,onTabChange:s,ariaLabel:n,children:a}){const i=o.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(To,{active:r===l.id,onClick:()=>s(l.id),children:l.label},l.id))}),t.jsx("div",{role:"tabpanel",children:a})]})}const Ro=[{id:"conversation",label:"Conversation"},{id:"json",label:"Raw JSON"}];function Ao({conversation:e,args:r}){const[s,n]=o.useState("conversation");return t.jsx(ae,{summary:`Input (${e.length} messages)`,children:t.jsx(Io,{tabs:Ro,activeTab:s,onTabChange:n,ariaLabel:"Conversation view",children:s==="conversation"?t.jsx(jo,{messages:e}):t.jsx("div",{className:"p-3",children:Array.isArray(r)?r.map((a,i)=>t.jsx("div",{className:"mt-2 first:mt-0",children:ie(a)},i)):ie(r)})})})}function Ze(){const e=o.useContext(Zt);return e?t.jsxs("button",{type:"button",onClick:e.onDecrypt,disabled:e.isDecrypting,className:"flex w-full items-center justify-center gap-1.5 rounded-md border px-3 py-2 text-xs cursor-pointer transition-colors",style:{borderColor:"var(--ds-gray-400)",backgroundColor:"var(--ds-gray-100)",color:"var(--ds-gray-700)",opacity:e.isDecrypting?.6:1},title:"Click to decrypt",children:[e.isDecrypting?t.jsx("span",{className:"h-3 w-3 animate-spin rounded-full border-2",style:{borderColor:"var(--ds-gray-400)",borderTopColor:"var(--ds-gray-700)"}}):t.jsx(Wt,{className:"h-3 w-3"}),t.jsx("span",{className:"font-medium",children:e.isDecrypting?"Decrypting…":"Decrypt"})]}):t.jsxs("div",{className:"flex w-full items-center justify-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(Wt,{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 ie(e){return t.jsx(rs,{data:e})}const je=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,pr=["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=pr.indexOf(e)||0,n=pr.indexOf(r)||0;return s-n},Do={workflowCoreVersion:"@workflow/core version",receivedCount:"times resolved"},Mo=e=>Do[e]??e,_o=e=>{const r=String(e),s=st(r);if(s)return s.moduleSpecifier;const n=Ue(r);return n?n.moduleSpecifier:r},Qt=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},er=e=>e.toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",fractionalSecondDigits:3}),Lo=e=>{const r=Qt(e);return r?er(r):"-"},hr=e=>{const r=Qt(e);return r?er(r):null},Me=e=>{const r=Qt(e);return r?t.jsx(Jr,{date:r,children:t.jsx("span",{children:er(r)})}):null},Je={workflowName:e=>{var r;return((r=Ue(String(e)))==null?void 0:r.shortName)??"?"},moduleSpecifier:e=>_o(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:hr,disposedAt:hr,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=>je(e)?ve(e)?t.jsx(Ze,{}):Le(e)?t.jsx(Ye,{}):ie(e):null,input:(e,r)=>{if(ve(e))return t.jsx(Ze,{});if(Le(e))return t.jsx(Ye,{});if(e&&typeof e=="object"&&"args"in e){const{args:a,closureVars:i,thisVal:l}=e,c=Array.isArray(a)?a.length:0,u=c===1?"argument":"arguments",d=je(i),f=je(l),x=je(a);if(r!=null&&r.stepName&&bn(r.stepName)){const h=jn(a);if(h&&h.length>0)return t.jsxs(t.Fragment,{children:[t.jsx(Ao,{conversation:h,args:a}),d&&t.jsx(ae,{summary:"Closure Variables",children:ie(i)}),f&&t.jsx(ae,{summary:"This Value",children:ie(l)})]})}return!x&&!d&&!f?t.jsx(ae,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"}):t.jsxs(t.Fragment,{children:[t.jsx(ae,{summary:`Input (${c} ${u})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(a)?a.map((h,p)=>t.jsx("div",{className:"mt-2 first:mt-0",children:ie(h)},p)):ie(a)}),d&&t.jsx(ae,{summary:"Closure Variables",children:ie(i)}),f&&t.jsx(ae,{summary:"this",children:ie(l)})]})}const s=Array.isArray(e)?e.length:0,n=s===1?"argument":"arguments";return je(e)?t.jsx(ae,{summary:`Input (${s} ${n})`,summaryClassName:"text-base py-2",contentClassName:"mt-0",children:Array.isArray(e)?e.map((a,i)=>t.jsx("div",{className:"mt-2 first:mt-0",children:ie(a)},i)):ie(e)}):t.jsx(ae,{summary:"Input (no data)",disabled:!0,summaryClassName:"text-base py-2"})},output:e=>je(e)?ve(e)?t.jsx(Ze,{}):Le(e)?t.jsx(Ye,{}):t.jsx(ae,{summary:"Output",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:ie(e)}):null,error:e=>ve(e)?t.jsx(Ze,{}):Le(e)?t.jsx(Ye,{}):je(e)?et(e)?t.jsx(ae,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:t.jsx(bt,{value:e})}):t.jsx(ae,{summary:"Error",summaryClassName:"text-base py-2",contentClassName:"mt-0",children:ie(e)}):null,eventData:e=>ve(e)?t.jsx(Ze,{}):Le(e)?t.jsx(Ye,{}):je(e)?t.jsx(ae,{summary:"Event Data",children:ie(e)}):null},xr=["input","output","error","metadata","eventData"],Po=()=>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."})}),Fo=({attribute:e,value:r,isLoading:s,inline:n=!1,context:a})=>{if(s&&(e==="input"||e==="output"||e==="eventData")&&!je(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,a);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},Oo=({data:e,moduleSpecifier:r,isLoading:s,error:n,expiredAt:a,onStreamClick:i,onDecrypt:l,isDecrypting:c=!1,resource:u})=>{const d=Ke(),f=o.useMemo(()=>{const m={...e},k=e.executionContext;return k!=null&&k.workflowCoreVersion&&(m.workflowCoreVersion=k.workflowCoreVersion),r?m.moduleSpecifier=r:typeof e.stepName=="string"?m.moduleSpecifier=e.stepName:typeof e.workflowName=="string"&&(m.moduleSpecifier=e.workflowName),m},[e,r]),x=a!=null&&new Date(a)<new Date,h=Object.keys(f).filter(m=>!xr.includes(m)).sort(Lt),p=o.useMemo(()=>{const m=Object.keys(f).filter(D=>xr.includes(D)).sort(Lt);if(!s)return m;const k=["input","output"];for(const D of k)m.includes(D)||m.push(D);return m.sort(Lt)},[f,s]),E=h.filter(m=>{const k=Je[m];return k?k(f[m])!==null:!1}),w=o.useMemo(()=>{const m=[...E],k=m.indexOf("moduleSpecifier");if(k===-1)return m;m.splice(k,1);const D=m.indexOf("workflowName");if(D!==-1)return m.splice(D+1,0,"moduleSpecifier"),m;const j=m.indexOf("stepName");return j!==-1?(m.splice(j+1,0,"moduleSpecifier"),m):(m.unshift("moduleSpecifier"),m)},[E]),O=o.useMemo(()=>({stepName:f.stepName}),[f.stepName]),b=o.useCallback(m=>{navigator.clipboard.writeText(m).then(()=>{d.success("moduleSpecifier copied")}).catch(()=>{d.error("Failed to copy moduleSpecifier")})},[]);return t.jsx(wn.Provider,{value:i,children:t.jsx(Zt.Provider,{value:l?{onDecrypt:l,isDecrypting:c}:void 0,children:t.jsxs("div",{children:[E.length>0&&t.jsxs("div",{className:"mb-3 flex flex-col overflow-hidden rounded-lg border",style:{borderColor:"var(--ds-gray-300)"},children:[w.map((m,k)=>{var y;const D=(y=Je[m])==null?void 0:y.call(Je,f[m]),j=m==="moduleSpecifier",I=typeof D=="string"?D:String(D??f.moduleSpecifier??""),N=m!=="workflowCoreVersion",g=s&&u==="sleep"&&!f.resumeAt,C=k<w.length-1||g;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:N?"text-[14px] first-letter:uppercase":"text-[14px]",style:{color:"var(--ds-gray-700)"},children:Mo(m)}),j?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:I,onClick:()=>b(I),children:I}):t.jsx("span",{className:"min-w-0 max-w-[70%] truncate text-right text-[13px] font-mono",style:{color:"var(--ds-gray-1000)"},children:D})]}),C?t.jsx("div",{className:"mx-2.5 border-b",style:{borderColor:"var(--ds-gray-300)"}}):null]},m)}),s&&u==="sleep"&&!f.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(Br,{title:"Failed to load resource details",details:n.message,className:"my-4"}):x?t.jsx(Po,{}):t.jsx(t.Fragment,{children:p.map(m=>t.jsx(Fo,{isLoading:s,attribute:m,value:f[m],context:O},m))})]})})})},$o=new Set(["step_failed","step_retrying"]),Wo=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 Ho({event:e,onLoadEventData:r,encryptionKey:s}){const[n,a]=o.useState(null),[i,l]=o.useState(!1),[c,u]=o.useState(null),d=o.useRef(!1),f=o.useRef(null),x="eventData"in e&&e.eventData!=null?e.eventData:null,h=n??x,p=Wo.has(e.eventType),E=o.useCallback(async m=>{if(!(!r||!e.correlationId||!e.eventId)&&!(!(m!=null&&m.force)&&f.current!==null))try{l(!0),u(null);const k=await r(e.correlationId,e.eventId);f.current=k,a(k)}catch(k){u(k instanceof Error?k.message:String(k))}finally{l(!1)}},[r,e.correlationId,e.eventId]),w=o.useCallback(async()=>{i||(d.current=!0,await E())},[i,E]);o.useEffect(()=>{!s||!d.current||(f.current=null,a(null),E({force:!0}))},[s,E]);const O=new Date(e.createdAt),b=i?n:h;return t.jsxs(ae,{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:Lo(O.getTime())})]}),onToggle:p?m=>{m&&w()}: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(Br,{title:"Failed to load event data",details:c,className:"mt-2"}),b!=null&&t.jsx("div",{className:"mt-2",children:t.jsx(Vo,{eventType:e.eventType,data:b})})]})}function Bo(e,r){if(e===null||typeof e!="object"||Array.isArray(e))return!1;const s=e,a=(kn[r]??[]).filter(i=>i in s);return a.length>0&&a.every(i=>Le(s[i]))}function Vo({eventType:e,data:r}){if(Le(r)||Bo(r,e))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($o.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(rs,{data:r})}function zo({events:e,isLoading:r=!1,error:s,onLoadEventData:n,encryptionKey:a}){const i=o.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(Ho,{event:l,onLoadEventData:n,encryptionKey:a},l.eventId))}):null]})}function Uo(e){return e!==null&&typeof e=="object"&&"stepId"in e}function Ko(e){return e!==null&&typeof e=="object"&&"runId"in e}function pt(e){return e!==null&&typeof e=="object"&&"hookId"in e}function qo({run:e,onStreamClick:r,spanDetailData:s,spanDetailError:n,spanDetailLoading:a,onSpanSelect:i,onWakeUpSleep:l,onLoadEventData:c,onResolveHook:u,encryptionKey:d,onDecrypt:f,isDecrypting:x=!1,selectedSpan:h,hasEncryptedData:p=!1}){const E=Ke(),[w,O]=o.useState(!1),[b,m]=o.useState(!1),[k,D]=o.useState(!1),[j,I]=o.useState(new Set),N=h==null?void 0:h.data,g=h==null?void 0:h.rawEvents,C=(g==null?void 0:g.length)??0,{resource:y,resourceId:P,runId:T}=o.useMemo(()=>{if(!h)return{resource:void 0,resourceId:void 0,runId:void 0};const F=h.resource;if(F==="step"&&Uo(N))return{resource:"step",resourceId:N.stepId,runId:N.runId};if(F==="run"&&Ko(N))return{resource:"run",resourceId:N.runId,runId:void 0};if(F==="hook"&&pt(N))return{resource:"hook",resourceId:N.hookId,runId:void 0};if(F==="sleep"){const K=N;return{resource:"sleep",resourceId:h.spanId,runId:K==null?void 0:K.runId}}return{resource:void 0,resourceId:void 0,runId:void 0}},[h,N]),v=o.useRef(i);v.current=i,o.useEffect(()=>{y&&P&&["run","step","hook","sleep"].includes(y)&&v.current({resource:y,resourceId:P,runId:T})},[y,P,T]);const $=o.useMemo(()=>y!=="sleep"||!g||["completed","failed","cancelled"].includes(e.status)||!g.some(re=>re.eventType==="wait_created")?!1:!g.some(re=>re.eventType==="wait_completed"),[y,g,C,e.status]),_=o.useMemo(()=>!(y!=="hook"||!g||!P||j.has(P)||["completed","failed","cancelled"].includes(e.status)||g.some(Y=>Y.eventType==="hook_disposed")),[y,P,g,C,e.status,j]),S=n??void 0,R=a??!1,M=o.useMemo(()=>{if(!s)return!1;const F=s;return ve(F.input)||ve(F.output)||ve(F.error)||ve(F.metadata)},[s]),A=o.useMemo(()=>{if(!(y!=="hook"||!P)){if(pt(s)&&s.token)return s.token;if(pt(N)&&N.token)return N.token}},[y,P,s,N]);o.useEffect(()=>{S&&h&&y&&E.error(`Failed to load ${y} details`,{description:S.message})},[S,y,h]);const W=async()=>{if(!(w||!P)){if(!l){E.error("Unable to wake up sleep",{description:"No wake-up handler provided."});return}try{O(!0),(await l(e.runId,P)).stoppedCount>0?E.success("Run woken up",{description:"The sleep call has been interrupted and the run woken up."}):E.info("Sleep already completed",{description:"This sleep call has already finished."})}catch(F){console.error("Failed to wake up run:",F),E.error("Failed to wake up run",{description:F instanceof Error?F.message:"An unknown error occurred"})}finally{O(!1)}}},z=o.useCallback(async F=>{if(!k){if(!u){E.error("Unable to resolve hook",{description:"No resolve handler provided."});return}if(!A){E.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{D(!0);const K=s??N,Y=pt(K)?K:void 0;await u(A,F,Y),E.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),m(!1),P&&I(re=>new Set(re).add(P))}catch(K){console.error("Failed to resolve hook:",K),E.error("Failed to resolve hook",{description:K instanceof Error?K.message:"An unknown error occurred"})}finally{D(!1)}}},[u,A,k,s,N]),V=s??N,J=o.useMemo(()=>{const F=V,K=F.stepName,Y=F.workflowName;if(typeof K=="string")return K;if(typeof Y=="string")return Y;if(typeof e.workflowName=="string")return e.workflowName},[V,e.workflowName]);if(!h||!y||!P)return null;const X=y.charAt(0).toUpperCase()+y.slice(1),U=y==="sleep"&&$||y==="hook"&&_,L=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:X}),t.jsx("span",{className:"text-[13px]",style:{color:e.completedAt?"var(--ds-gray-700)":"var(--ds-green-800)"},children:L})]}),t.jsx("p",{className:"mt-1 truncate font-mono text-[13px]",style:{color:"var(--ds-gray-700)"},title:P,children:P})]}),(M||p||d)&&f&&t.jsx(Jt,{decrypted:!!d,loading:x,onClick:f})]})}),t.jsxs("div",{className:"flex-1 overflow-y-auto px-3 pt-3 pb-8",children:[U&&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:[y==="sleep"&&$&&t.jsxs("button",{type:"button",onClick:W,disabled:w,className:Fe("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",w?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-amber-200)",color:"var(--ds-amber-900)"},children:[t.jsx(Us,{className:"h-4 w-4"}),w?"Waking up...":"Wake Up Sleep"]}),y==="hook"&&_&&t.jsxs("button",{type:"button",onClick:()=>m(!0),disabled:k,className:Fe("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",k?"opacity-50 cursor-not-allowed":"cursor-pointer"),style:{background:"var(--ds-gray-1000)",color:"var(--ds-background-100)"},children:[t.jsx(Vr,{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(Oo,{data:V,moduleSpecifier:J,expiredAt:e.expiredAt,isLoading:R,error:S??void 0,onStreamClick:r,onDecrypt:f,isDecrypting:x,resource:y})]}),y!=="run"&&g&&t.jsx("section",{children:t.jsx(zo,{events:g,onLoadEventData:c,encryptionKey:d})})]})]}),t.jsx(zr,{isOpen:b,onClose:()=>m(!1),onSubmit:z,isSubmitting:k})]})}function Go(e){const r=o.useRef(e);r.current=e,o.useEffect(()=>{let s=0,n=0;const a=()=>{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(a)};return window.addEventListener("wheel",i,{passive:!1}),()=>{window.removeEventListener("wheel",i),cancelAnimationFrame(n)}},[])}function gr(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 Zo({scale:e,isLive:r=!1}){const{state:{root:s}}=we(),[,n]=o.useState(0);o.useEffect(()=>{if(!r)return;const h=setInterval(()=>n(p=>p+1),1e3);return()=>clearInterval(h)},[r]);const a=s.duration,i=e>0?e:a>0?1/a:1;let c=gr(50/i);c=Math.max(1,c);let u=c*i;const d=1e3;a/c>d&&(c=gr(a/d),u=c*i);const f=Math.ceil(a/c),x=Math.ceil(100/u)||1;return t.jsx("div",{className:Z.markersContainer,children:t.jsx("div",{"aria-hidden":!0,className:Z.markers,style:{width:Math.floor(s.duration*e+15),visibility:e!==-1?"visible":"hidden","--marker-width":`${u}px`},children:new Array(f).fill(null).map((h,p)=>{const E=p%x===0;return t.jsx("span",{className:Fe(Z.marker,!E&&Z.notch),children:E?t.jsxs("span",{className:Z.markerLabel,children:[Nn(c*p),t.jsx("span",{className:Z.markerClockTime,children:Cn(s.startTime+c*p)})]}):null},String(p))})})})}function Yo({events:e,root:r,scale:s}){const n=o.useMemo(()=>e.filter(a=>a.event.showVerticalLine!==!1),[e]);return t.jsx("div",{className:Z.eventMarkersContainer,children:t.jsx("div",{"aria-hidden":!0,className:Z.eventMarkers,style:{width:Math.floor(r.duration*s)},children:n.map(a=>t.jsx("span",{className:Fe(Z.eventMarker),style:{left:Math.floor((a.timestamp-r.startTime)*s),...a.event.color&&{borderLeftColor:a.event.color}}},a.key))})})}const yr=2;function Xo({memoCacheRef:e,timelineRef:r,root:s,spans:n,events:a,scale:i,dispatch:l,scrollSnapshotRef:c}){const u=o.useRef(!1),d=o.useRef(n);d.current=n;const f=o.useRef(a);f.current=a;const x=o.useRef(null),{style:h,setStyle:p}=At(x),E=o.useRef(null),w=o.useRef(null),{style:O,setStyle:b}=At(w),m=o.useRef(void 0),k=o.useRef(null),{style:D,setStyle:j}=At(k),I=o.useRef(0);o.useEffect(()=>{const g=r.current;if(!g)return;let C=I.current,y=0,P=!1,T=!1,v=!1,$=!1,_=0,S=0;const R=Date.now()+500,M=()=>{m.current||(m.current=g.getBoundingClientRect())},A=H=>m.current?(H-wt-le)/(Be+Te):0,W=()=>{const H=e.current;for(const te of d.current)te.isHovered&&(te.isHovered=!1,H.set(te.span.spanId,{}));l({type:"forceRender"})};let z=0;const V=()=>{var ot,qe,at,it,ge,lt,ct,dt;if(!u.current)return;m.current||M();const H=m.current;if(!H)return;const{scrollLeft:te,scrollTop:oe}=g,ce=Math.max(0,Math.min(C+te-H.left-le,s.duration*i)),me=`${ce-te+le}px`;b("left",me),p("left",me);const $e=s.startTime+ce/i,pe=$e-s.startTime;if(pe<0||pe>s.duration?(ot=E.current)==null||ot.removeAttribute("data-text"):(qe=E.current)==null||qe.setAttribute("data-text",ft(pe)),P){const We=C-y,Re=Math.abs(We);if(!v){if(Re<4)return;v=!0,j("display","flex"),W()}We>0?(j("left",""),j("right","0")):(j("left","0"),j("right","")),j("width",`${Re}px`);const Ge=Math.max(0,Math.min(y+te-H.left-le,s.duration*i))/i;let be,G;Ge<pe?(be=Ge,G=pe):(be=pe,G=Ge),(at=k.current)==null||at.setAttribute("data-range",`${ft(be)} — ${ft(G)}`),(it=k.current)==null||it.setAttribute("data-duration",`${ft(G-be)} selected`)}if(Date.now()<R){z=requestAnimationFrame(V);return}if(te!==_||oe!==S){_=te,S=oe,z=requestAnimationFrame(V);return}if(C-H.left<128?(ge=E.current)==null||ge.setAttribute("data-align","left"):C-H.left>H.width-128?(lt=E.current)==null||lt.setAttribute("data-align","right"):(ct=E.current)==null||ct.removeAttribute("data-align"),!v&&!T){const We=e.current,Re=A(oe)-yr,St=A(oe+H.height)+yr;for(const ee of d.current){const ne=ee.row>=Re&&ee.row<=St&&$e>=ee.startTime&&$e<=ee.endTime;ee.isHovered!==ne&&(ee.isHovered=ne,We.set(ee.span.spanId,{}))}const be=12/i;let G=null,se=1/0;for(const ee of f.current){const ne=Math.abs(ee.timestamp-$e);ne<=be&&ne<se&&(se=ne,G=ee)}for(const ee of f.current){const ne=ee===G;if(ee.isHovered===ne)continue;ee.isHovered=ne;const Ee=(dt=ee.ref)==null?void 0:dt.current;Ee&&Ee.setAttribute("data-hovered",String(ne))}l({type:"forceRender"})}};z=requestAnimationFrame(V);const J=H=>{H.pointerType==="mouse"&&(u.current=!0)},X=()=>{u.current&&(u.current=!1,W())},U=({clientX:H})=>{C=H,I.current=C,cancelAnimationFrame(z),z=requestAnimationFrame(V)},L=H=>{H.preventDefault()},F=H=>{var te;if(H.button===2)$=!0,H.preventDefault();else{if(H.button!==0)return;$=!1}(te=r.current)!=null&&te.contains(H.target)?(y=C,P=!0):(T=!0,requestAnimationFrame(W))},K=H=>{if(T=!1,!P||(P=!1,!v))return;if(v=!1,j("display",""),j("left",""),j("right",""),j("width",""),H.preventDefault(),H.stopImmediatePropagation(),$){$=!1;return}m.current||M();const te=m.current;if(!te)return;const{scrollLeft:oe}=g,ce=Math.max(0,Math.min((y+oe-te.left-le)/i,s.duration)),me=Math.max(0,Math.min((C+oe-te.left-le)/i,s.duration));l({type:"scaleToRange",t1:ce+s.startTime,t2:me+s.startTime})},Y=H=>{P&&H.key==="Escape"&&($=!0,K(H))},re=()=>{m.current=void 0,N.current=void 0,cancelAnimationFrame(z),z=requestAnimationFrame(V)},B=()=>{cancelAnimationFrame(z),z=requestAnimationFrame(V)},q=new ResizeObserver(()=>{m.current=void 0});return q.observe(g),window.addEventListener("mousemove",U),g.addEventListener("contextmenu",L),window.addEventListener("mousedown",F),window.addEventListener("mouseup",K),window.addEventListener("blur",K),window.addEventListener("keydown",Y,!0),window.addEventListener("scroll",re),g.addEventListener("scroll",B),g.addEventListener("pointerenter",J),g.addEventListener("pointerleave",X),()=>{q.disconnect(),window.removeEventListener("mousemove",U),g.removeEventListener("contextmenu",L),window.removeEventListener("mousedown",F),window.removeEventListener("mouseup",K),window.removeEventListener("blur",K),window.removeEventListener("keydown",Y,!0),window.removeEventListener("scroll",re),g.removeEventListener("scroll",B),g.removeEventListener("pointerenter",J),g.removeEventListener("pointerleave",X),cancelAnimationFrame(z),I.current=C,W()}},[l,s,i,b,p,j,e,r,c]);const N=o.useRef(void 0);return Go(g=>{const C=r.current;if(!C)return;m.current??(m.current=C.getBoundingClientRect());const y=m.current,P=Math.max(0,Math.min(I.current-y.left-le,y.width-2*le));let T=0,v=N.current;(v==null?void 0:v.anchorX)===P?T=v.anchorT:(T=(C.scrollLeft+P)/i,v={anchorT:T,anchorX:P},N.current=v),l({type:"trackpadScale",delta:g/64,anchorT:T,anchorX:P})}),t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Z.cursorMarkerStickyParent,children:t.jsx("div",{className:Z.cursorMarkerLabelContainer,ref:x,style:h,children:t.jsx("div",{className:Z.cursorMarkerLabel,ref:E})})}),t.jsx("div",{className:Z.cursorMarkerStickyParent,children:t.jsx("div",{className:Z.cursorMarkerContainer,ref:w,style:O,children:t.jsx("div",{className:Z.cursorMarker,children:t.jsx("div",{className:Z.cursorSelection,ref:k,style:D})})})})]})}function Jo({height:e,width:r,value:s,placeholder:n,onChange:a}){return t.jsxs("label",{className:Z.searchInputLabel,children:[t.jsx("div",{className:Z.searchInputPrefix,children:t.jsx(Qo,{})}),t.jsx("input",{type:"search",value:s,placeholder:n,onChange:a,style:{height:e,width:r}})]})}function Qo(){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 ea(){return t.jsx("nav",{className:Z.searchBar,children:t.jsx(ta,{})})}function ta(){const{dispatch:e}=we(),[r,s]=o.useState("");return o.useEffect(()=>{const n=setTimeout(()=>e({type:"setFilter",filter:r}),100);return()=>{clearTimeout(n)}},[e,r]),t.jsx("div",{className:Z.searchInput,children:t.jsx(Jo,{height:Kr,onChange:n=>s(n.target.value),placeholder:"Search spans…",value:r,width:"100%"})})}function ra({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 sa({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 na({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 oa(){const{dispatch:e}=we(),r=o.useCallback(()=>{e({type:"adjustScaleRatio",direction:1})},[e]),s=o.useCallback(()=>{e({type:"adjustScaleRatio",direction:-1})},[e]),n=o.useCallback(()=>{e({type:"adjustScaleRatio",direction:0})},[e]);return t.jsxs("div",{className:Z.zoomButtonGroup,children:[t.jsx("button",{"aria-label":"Zoom Out",className:Z.zoomButton,onClick:s,type:"button",children:t.jsx(sa,{size:18})}),t.jsx("div",{className:Z.divider}),t.jsx("button",{"aria-label":"Reset Zoom",className:Z.zoomButton,onClick:n,type:"button",children:t.jsx(na,{size:18})}),t.jsx("div",{className:Z.divider}),t.jsx("button",{"aria-label":"Zoom In",className:Z.zoomButton,onClick:r,type:"button",children:t.jsx(ra,{size:18})})]})}const aa=e=>{const{spans:r}=e,s={startTime:0,endTime:0,duration:0,depth:0,children:[]},n={},a=new Map,i=x=>{const h=a.get(x);if(h)return h;const p=a.size+1;return a.set(x,p),p};let l=!1;for(const x of r){const h=Xe(x.startTime),p=Xe(x.endTime),E=Xe(x.duration);p>s.endTime&&(s.endTime=p,s.duration=p-s.startTime),(s.startTime===0||h<s.startTime)&&(s.startTime=h,s.duration=s.endTime-h);const w=x.resource.startsWith("vercel.");w||(l=!0);const O=w&&(x.resource!=="vercel.serverless-runtime"||!("http.method"in x.attributes)),b=O?0:i(x.resource);let m;O&&(m=`▲ ${x.name}`),n[x.spanId]={parent:null,startTime:h,endTime:p,duration:E,span:x,depth:0,label:m,events:ia(x),isVercel:O,children:[],resourceIndex:b,activeStartTime:x.activeStartTime?Xe(x.activeStartTime):void 0}}const c=(x,h)=>{let p;h?(p=n[h],p||(p=s)):p=s,x.parent=p,p.children.push(x)},u=x=>{"parent"in x&&(x.depth=x.parent.depth+1);for(const h of x.children)u(h)};let d=1;const f=(x,h)=>{if("parent"in x&&x.span.name===h){let p=x.endTime;const E=I=>I.children.length?I.children.map(E).sort((N,g)=>N.duration-g.duration)[0]||I:I.span.name==="waitUntil"?(p=I.startTime,I.parent):I,w=E(x),O=`instrumentation-hint-${d++}`,b=x.duration*.05,m=x.startTime+b,k=Math.max(m+b,Math.min(p-x.duration*.01,x.endTime-b)),D=k-m,j={parent:w,startTime:m,endTime:k,duration:D,span:{spanId:O,name:"Add your spans here",resource:"",kind:0,library:{name:""},status:{code:200},traceFlags:0,attributes:{},links:[],events:[],startTime:Dt(m),endTime:Dt(k),duration:Dt(D)},depth:x.depth+1,isVercel:!1,isInstrumentationHint:!0,children:[],resourceIndex:1};return w.children.push(j),n[O]=j,!0}for(const p of x.children)if(f(p,h))return!0;return!1};for(const x of Object.values(n))c(x,x.span.parentSpanId);if(u(s),!l){for(const x of["Invoke Function","Invoke Middleware","Vercel Runtime"])if(f(s,x))break}return{root:s,map:n}},ia=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)},vr=(e,r)=>(e.isVisible=!0,e.isHovered=!1,e.isVisible);function Pt(){return[]}const la=(e,r=!1)=>{const{state:s,dispatch:n}=we(),{root:a,filter:i,scale:l,timelineRef:c,timelineWidth:u,spanMap:d,scrollSnapshotRef:f,selected:x,memoCacheRef:h}=s,p=ca(s.timelineHeight),E=o.useRef(0),[w,O]=o.useState(Pt),[b,m]=o.useState(Pt),[k,D]=o.useState(Pt),[j,I]=o.useState(-1),N=o.useRef(void 0);return o.useEffect(()=>{var g;return(g=N.current)==null?void 0:g.call(N,i)},[i]),o.useEffect(()=>{if(e!=null&&e.length){for(const g of w)for(const C of g){const y=e.includes(C.span.spanId);C.isHighlighted!==y&&(C.isHighlighted=y,h.current.set(C.span.spanId,{}))}n({type:"forceRender"})}},[w,e,n,h]),o.useEffect(()=>{if(!a.startTime)return;const g=new Worker(new URL("/assets/worker-D-HfgUMl.js",import.meta.url),{type:"module"});let C=++E.current;const y=T=>{var $;const v=T.data;switch(v.type){case"setRowsResult":{if((v==null?void 0:v.requestId)!==C)return;if(v.isEnd)for(const _ of v.rows)for(const S of _)S.span=(($=d[S.span.spanId])==null?void 0:$.span)??S.span;O(v.rows);break}case"updateHighlight":{if((v==null?void 0:v.requestId)!==C)return;const{matches:_}=v;O(S=>{for(const R of S)for(const M of R){const A=_.has(M.span.spanId);M.isHighlighted!==A&&(M.isHighlighted=A,h.current.set(M.span.spanId,{}))}return S}),n({type:"forceRender"});break}}};g.addEventListener("message",y);const P={requestId:C,type:"calculateSpanPositions",root:a};return g.postMessage(P),N.current=T=>{const v=T.trim().toLocaleLowerCase();if(!v){O(_=>_.map(S=>S.map(R=>(R.isHighlighted=void 0,{...R}))));return}C=++E.current;const $={type:"filterSpans",requestId:C,root:a,filter:v};g.postMessage($)},()=>{g.terminate()}},[a,d,n,h]),o.useEffect(()=>{if(!w.length)return;if(r){const U=[],L=[];for(const F of w)for(const K of F)vr(K)&&(U.push(K),K.events&&L.push(...K.events));m(U),D(L),I(l);return}const g=c.current;let C=f.current,y=!1,P=!1,T=0,v=0;const $=Math.max(500,u*.5),_=new Array(w.length).fill(null),S=()=>{P=!0;const U=Math.min(1+v+Math.ceil((C==null?void 0:C.endRow)??Number.POSITIVE_INFINITY),w.length);for(let L=U;L--;){if(_[L])continue;const F=R(L);if(Math.abs(F)>v){if(P=!1,F>0)continue;break}const K=[],Y=w[L];if(Y){for(const re of Y){if(!vr(re))continue;const B=M(re);T=Math.max(B,T),K.push({d:B,span:re})}_[L]=K}}},R=U=>C?U<C.startRow?U-C.startRow:U>C.endRow?U-C.endRow:0:0,M=U=>{if(!C)return 0;let L=0;U.endTime<C.startTime?L=C.startTime-U.endTime:U.startTime>C.endTime&&(L=U.startTime-C.endTime);const F=Math.abs(R(U.row));return!L&&!F?0:Math.sqrt((L/l)**2+(F*Be+Te)**2)},A=()=>{if(!g)return;const{scrollLeft:U,scrollTop:L}=g,F=0,K=U/l,Y=(L-wt-le)/(Be+Te),re=Y+Math.ceil(p/(Be+Te));C={anchorT:K,anchorX:F,scrollLeft:U,scrollTop:L,startTime:a.startTime+U/l,endTime:a.startTime+(U+u)/l,startRow:Y,endRow:re,scale:l},f.current=C;for(let B=_.length;B--;)_[B]=null};let W=0;const z=()=>{(y||!C)&&(y=!1,A()),S();const U=[],L=[];for(const F of _)if(F)for(const{d:K,span:Y}of F)K>v||(U.push(Y),Y.events&&L.push(...Y.events));v<$&&(!P||v<T)&&(v=Math.min($,v+100),W=requestAnimationFrame(z)),m(U),D(L),I(l)};z();let V=Date.now();const J=U=>{(U.ctrlKey||U.metaKey)&&(V=Date.now())};g==null||g.addEventListener("wheel",J);const X=()=>{Date.now()-V<=50||(y=!0,cancelAnimationFrame(W),W=requestAnimationFrame(z))};return g==null||g.addEventListener("scroll",X),()=>{cancelAnimationFrame(W),g==null||g.removeEventListener("wheel",J),g==null||g.removeEventListener("scroll",X)}},[w,a,l,f,c,u,p,r]),o.useEffect(()=>{var y;if(!x)return;let g;for(const P of b)if(P.span.spanId===x.span.spanId){g=P;break}const C=(y=g==null?void 0:g.ref)==null?void 0:y.current;if(!(!g||!C))return g.isSelected=!0,C.setAttribute("data-selected",""),()=>{g.isSelected=!1,C.removeAttribute("data-selected")}},[b,x]),{rows:w,spans:b,events:k,scale:j}};function ca(e){const[r,s]=o.useState(e);return o.useEffect(()=>{if(r===e)return;let n=0,a=0;const i=()=>{if(++n<=3){a=requestAnimationFrame(i);return}s(e)};return i(),()=>{cancelAnimationFrame(a)}},[r,e]),r}const wr={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 da({trace:e=wr,className:r="",scrollLock:s=!1,height:n,withPanel:a=!1,highlightedSpans:i,eagerRender:l=!1,isLive:c=!1,footer:u,knownDurationMs:d,hasMoreData:f=!1}){const x=e===wr,{state:h,dispatch:p}=we(),{timelineRef:E,scrollSnapshotRef:w}=h,O=h.memoCacheRef.current,b=((i==null?void 0:i.length)??0)>0,m=o.useRef(!1),k=o.useRef(""),D=o.useRef(null),j=o.useRef({}),I=o.useRef(null);o.useEffect(()=>{const{root:S,map:R}=aa(e),M=!m.current;m.current=!0;const A=Object.keys(R).sort().map(W=>{const z=R[W].events,V=(z==null?void 0:z.length)??0,J=V?z==null?void 0:z[0]:void 0,X=V?z==null?void 0:z[V-1]:void 0,U=`${(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`${W}:${V}:${U}`}).join(",");if(!M&&A===k.current&&D.current){const W=D.current,z=j.current;let V=!1;(W.endTime!==S.endTime||W.duration!==S.duration)&&(W.endTime=S.endTime,W.duration=S.duration,V=!0);for(const[J,X]of Object.entries(R)){const U=z[J];U&&((U.endTime!==X.endTime||U.duration!==X.duration)&&(U.endTime=X.endTime,U.duration=X.duration,V=!0),Object.assign(U.span,X.span))}if(!V)return;p({type:"forceRender"});return}k.current=A,D.current=S,j.current=R,p({type:M?"setRoot":"updateRoot",root:S,spanMap:R,resources:e.resources||[]})},[p,e]);const{rows:N,spans:g,events:C,scale:y}=la(i,l),P=o.useRef(null);o.useLayoutEffect(()=>{const S=P.current;if(!S)return;const R=()=>{const A=2*le,W=S.getBoundingClientRect(),z=W.width-A,V=W.height,J=I.current;J&&J.width===z&&J.height===V||(I.current={width:z,height:V},p({type:"setSize",width:z,height:V}))};R();const M=new ResizeObserver(R);return M.observe(S),window.addEventListener("resize",R),()=>{M.disconnect(),window.removeEventListener("resize",R)}},[p]);const T=o.useRef({t:0,x:-1,y:-1,spanId:""}),v=o.useCallback(S=>{const R=T.current,M=Date.now(),{clientX:A,clientY:W}=S,z=Math.sqrt((A-R.x)**2+(W-R.y)**2);if(M-R.t<=500&&z<=8){if(S.stopPropagation(),S.preventDefault(),!R.spanId){p({type:"resetScale"});return}p({type:"select",id:R.spanId}),p({type:"scaleToNode",id:R.spanId});return}const V=S.target;if(!V.closest(`.${String(Z.timeline)}`))return;const J=V.closest("[data-span-id]"),X=(J==null?void 0:J.dataset.spanId)||"";T.current={x:A,y:W,t:M,spanId:X},X&&(p({type:"toggleSelection",id:X}),S.stopPropagation())},[p]);o.useLayoutEffect(()=>{const S=E.current;if(!S)return;const R=w.current;R&&(S.scrollLeft=R.anchorT*y-R.anchorX,w.current=void 0)},[w,E,y]),o.useEffect(()=>{var M;const S=(M=h.selected)==null?void 0:M.span.spanId;if(!S)return;const R=setTimeout(()=>{const A=h.timelineRef.current,W=A==null?void 0:A.querySelector(`[data-span-id="${S}"]`);if(!A||!W)return;const z=A.getBoundingClientRect(),V=W.getBoundingClientRect();V.width<z.width&&(V.left<z.left||V.right>z.right||V.top<z.top||V.bottom>z.bottom)&&W.scrollIntoView({block:"nearest",inline:"center",behavior:"smooth"})},500);return()=>{clearTimeout(R)}},[h.selected,h.timelineRef]),o.useEffect(()=>{const S=R=>{R.key==="Escape"&&p({type:"escape"})};return window.addEventListener("keydown",S),()=>{window.removeEventListener("keydown",S)}},[p]),o.useEffect(()=>{if(!s)return;const S=document.documentElement,R=document.body;S.style.overflow="clip",R.style.overflow="clip";const M=A=>{A!=null&&A.cancelable?A.preventDefault():window.scrollTo({left:0,top:0,behavior:"instant"})};return M(),window.addEventListener("scroll",M,{passive:!1}),()=>{S.style.overflow="",R.style.overflow="",window.removeEventListener("scroll",M)}},[s]);const $=Math.max(h.timelineHeight-h.scrollbarWidth,wt+Te+N.length*(Be+Te)-Te+84),_=!!(h.isMobile&&h.selected);return t.jsxs("div",{className:Fe(Z.traceViewer,x&&Z.skeleton,r),onClickCapture:v,ref:P,style:{height:n,"--timeline-padding":`${le}px`,"--row-height":`${Be}px`,"--row-padding":`${Te}px`,"--search-height":`${b?0:Kr}px`,"--search-gap":`${b?2:Tn}px`,"--map-height":`${Sn}px`,"--timeline-width":`${h.timelineWidth}px`,"--timeline-height":`${h.timelineHeight}px`,"--timeline-scroll-width":`${Math.round(h.root.duration*h.scale)}px`,"--panel-width":`${h.panelWidth}px`,"--panel-height":`${h.panelHeight}px`,"--height":`${h.height}px`,"--scrollbar-width":`${h.scrollbarWidth}px`,"--marker-height":`${wt}px`,"--marker-notch-height":`${En}px`},children:[b?null:t.jsx(ea,{}),t.jsx(In,{rows:N,scale:y,timelineRef:E}),t.jsxs("div",{className:Fe(Z.traceViewerContent,_&&Z.inert),children:[t.jsxs("div",{className:Z.timeline,ref:E,children:[t.jsx("div",{style:{position:"relative",width:h.timelineWidth,minHeight:h.timelineHeight-le*2,padding:le,paddingBottom:0},children:t.jsxs("div",{className:Z.traceNode,style:{width:h.root.duration*y||void 0,height:$-le*2},children:[t.jsx(Zo,{scale:y,isLive:c}),t.jsx(Yo,{events:C,root:h.root,scale:y}),t.jsx(Xo,{dispatch:p,events:C,memoCacheRef:h.memoCacheRef,root:h.root,scale:y,scrollSnapshotRef:w,spans:g,timelineRef:E}),t.jsx(Rn,{cacheKey:O.get(""),cache:O,customSpanClassNameFunc:h.customSpanClassNameFunc,customSpanEventClassNameFunc:h.customSpanEventClassNameFunc,isLive:c,root:h.root,scale:y,scrollSnapshotRef:w,spans:g}),d!=null&&d>0&&(f||c)&&h.root.duration>0&&(()=>{const S=d*y,M=h.root.duration*y-S;if(M<4)return null;const A=Math.min(M*.05,20);return t.jsx("div",{style:{position:"absolute",top:0,left:S+A,width:M-A,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:Z.zoomButtonTraceViewer,children:t.jsx(oa,{})})]}),a?t.jsx("div",{className:Fe(Z.spanDetailPanelTraceViewer,!h.selected&&Z.hidden,h.isMobile&&Z.mobile),children:t.jsx(An,{attached:!0})}):null]})}function br(e,r=!1){if(r&&e==="pending")return Z.spanPendingStriped;switch(e){case"running":return Z.spanRunning;case"pending":return Z.spanPending;case"completed":return Z.spanCompleted;case"cancelled":return Z.spanCancelled;case"failed":return Z.spanFailed;default:return""}}function ua(e){return String(e).toLowerCase().endsWith("sleep")}const fa=e=>{const r=e.span.attributes,s=r==null?void 0:r.resource;if(s==="step"){const n=r.data,a=n==null?void 0:n.stepName;if(a&&ua(a))return Z.spanSleep;const i=(n==null?void 0:n.status)==="pending";return br(n==null?void 0:n.status,i)}if(s==="run"){const n=r.data;return br(n==null?void 0:n.status,!1)}return s==="hook"?Z.spanHook:s==="sleep"?Z.spanSleep:""},ma=e=>{const r=e.event.name;return r==="step_failed"||r==="run_failed"?Z.eventFailed:r==="step_retrying"?Z.eventRetrying:r==="hook_created"||r==="hook_received"||r==="hook_disposed"?Z.eventHook:Z.eventDefault};function pa(e){return e==="hook_created"||e==="hook_received"||e==="hook_disposed"}function he(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 Vt(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(),a=Math.floor(n/1e3),i=n%1e3*1e6;return[a,i]}const nt={name:"workflow-development-kit",version:"4.0.0"},ha=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?ha.has(s.eventType):!0).map(s=>({name:s.eventType,timestamp:he(s.createdAt),attributes:{eventId:s.eventId,correlationId:s.correlationId,eventData:"eventData"in s?s.eventData:void 0},showVerticalLine:pa(s.eventType)}))}const ss=e=>{var n;const r=e.find(a=>a.eventType==="wait_created");if(!r)return null;const s=e.find(a=>a.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 xa(e,r){const s=ss(e);if(!s)return null;const n=s.createdAt,a=s.completedAt??r,i=he(n),l=he(a),c=Ct(n,a),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 ga=e=>{var u;const r=e.find(d=>d.eventType==="step_created"),s=r??e[0];if(!s)return null;let n="pending",a=0,i,l;for(const d of e)switch(d.eventType){case"step_started":n="running",a+=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}a===0&&(a=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:a,createdAt:s.createdAt,updatedAt:(c==null?void 0:c.createdAt)??s.createdAt,startedAt:i,completedAt:l,specVersion:s.specVersion}};function ya(e,r){const s=ga(e);if(!s)return null;const n=st(String(s.stepName)),a={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 f=e.find(x=>x.eventType==="step_started");return f&&(d=new Date(f.createdAt)),{spanId:String(s.stepId),name:(n==null?void 0:n.shortName)??"",kind:1,resource:i,library:nt,status:{code:0},traceFlags:1,attributes:a,links:[],events:c,startTime:he(u),endTime:he(l),duration:Ct(u,l),activeStartTime:d&&d.getTime()>u.getTime()?he(d):void 0}}const va=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"),a=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:(a==null?void 0:a.createdAt)||void 0,disposedAt:((l=n.at(-1))==null?void 0:l.createdAt)||void 0}};function wa(e,r){const s=va(e);if(!s)return null;const n=Et(e,!1),a=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:he(s.createdAt),endTime:he(a),duration:Ct(s.createdAt,a)}}function ba(e,r,s){var p;const n=s??new Date,{input:a,output:i,error:l,...c}=e,u={resource:"run",data:c},d=new Date(e.createdAt),f=e.startedAt?new Date(e.startedAt):void 0,x=e.completedAt??n,h=Et(r,!1);return{spanId:String(e.runId),name:String(((p=Ue(e.workflowName))==null?void 0:p.shortName)??"?"),kind:1,resource:"run",library:nt,status:{code:0},traceFlags:1,attributes:u,links:[],events:h,startTime:he(d),endTime:he(x),duration:Ct(d,x),activeStartTime:f&&f.getTime()>d.getTime()?he(f):void 0}}const ja=e=>e.startsWith("step_"),ka=e=>e==="wait_created"||e==="wait_completed",Na=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 Ca(e){const r=new Map,s=[],n=new Map,a=new Map;for(const i of e){const l=i.correlationId;if(!l){s.push(i);continue}if(ka(i.eventType)){Ft(n,l,i);continue}if(Na(i.eventType)){Ft(a,l,i);continue}if(ja(i.eventType)){Ft(r,l,i);continue}s.push(i)}return{eventsByStepId:r,runLevelEvents:s,timerEvents:n,hookEvents:a}}function Ea(e,r){let s=new Date(r.createdAt).getTime();for(const n of e){const a=new Date(n.createdAt).getTime();a>s&&(s=a)}return new Date(s)}function Sa(e,r,s,n){const a=n,i=Array.from(r.eventsByStepId.values()).map(u=>ya(u,a)).filter(u=>u!==null),l=Array.from(r.hookEvents.values()).map(u=>wa(u,a)).filter(u=>u!==null),c=Array.from(r.timerEvents.values()).map(u=>xa(u,a)).filter(u=>u!==null);return{runSpan:ba(e,r.runLevelEvents,s),spans:[...i,...l,...c]}}function Ta(e,r){const s=[e,...r.slice().sort((n,a)=>{const i=Vt(n.startTime),l=Vt(a.startTime);return i-l})];return s.map((n,a)=>{const i=a===0?void 0:String(s[a-1].spanId);return{...n,parentSpanId:i}})}function Ia(e,r,s){const n=Ca(r),a=Ea(r,e),{runSpan:i,spans:l}=Sa(e,n,s,a),c=Ta(i,l),u=Vt(i.startTime),d=a.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 Ra(e){const{state:r,dispatch:s}=we(),n=o.useRef(r);n.current=r,o.useEffect(()=>{if(!e)return;let a=0;const i=()=>{const{root:d}=n.current;if(d.startTime){const f=Date.now();f>d.endTime&&(d.endTime=f,d.duration=d.endTime-d.startTime)}a=requestAnimationFrame(i)};a=requestAnimationFrame(i);let l=0,c=0;const u=()=>{const d=n.current;if(d.root.duration>0){const f=(d.width-d.scrollbarWidth)/d.root.duration;(Math.abs(f-c)>c*.001||c===0)&&(c=f,s({type:"detectBaseScale"}))}l=requestAnimationFrame(u)};return l=requestAnimationFrame(u),()=>{cancelAnimationFrame(a),cancelAnimationFrame(l)}},[e,s])}const Aa=450,Da=240;function Ma({menu:e,items:r,onClose:s}){const n=o.useRef(null);o.useEffect(()=>{const l=f=>{n.current&&!n.current.contains(f.target)&&s()},c=f=>{f.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[a,i]=o.useState({x:e.x,y:e.y});return o.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:Kt.createPortal(t.jsxs("div",{ref:n,style:{position:"fixed",left:a.x,top:a.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 _a({trace:e,run:r,isLive:s,onWakeUpSleep:n,onCancelRun:a,onResolveHook:i,onLoadMoreSpans:l,hasMoreSpans:c=!1,isLoadingMoreSpans:u=!1,children:d}){const f=Ke(),{state:x,dispatch:h}=we();Ra(s);const[p,E]=o.useState(null),[w,O]=o.useState(null),[b,m]=o.useState(!1),[k,D]=o.useState(new Set),j=o.useMemo(()=>{const T=new Map;for(const v of e.spans)T.set(v.spanId,v);return T},[e.spans]),I=o.useCallback(async T=>{if(!(b||!w||!i)){if(!w.token){f.error("Unable to resolve hook",{description:"Missing hook token. Try refreshing the run data and retry."});return}try{m(!0),await i(w.token,T),f.success("Hook resolved",{description:"The payload has been sent and the hook resolved."}),D(v=>new Set(v).add(w.hookId)),O(null)}catch(v){console.error("Failed to resolve hook:",v),f.error("Failed to resolve hook",{description:v instanceof Error?v.message:"An unknown error occurred"})}finally{m(!1)}}},[i,w,b]),N=o.useCallback(T=>{const $=T.target.closest("[data-span-id]");if(!$)return;const _=$.dataset.spanId;if(!_)return;T.preventDefault(),T.stopPropagation();const S=j.get(_);if(!S)return;const R=S.attributes.resource??"unknown",M=S.attributes.data,A=!(M!=null&&M.completedAt)&&!(M!=null&&M.disposedAt);E({x:T.clientX,y:T.clientY,spanId:_,spanName:S.name,resourceType:R,isActive:A})},[j]),g=o.useRef(null);o.useEffect(()=>{const T=g.current;if(!T)return;const v=$=>{N($)};return T.addEventListener("contextmenu",v),()=>{T.removeEventListener("contextmenu",v)}},[N]);const C=o.useRef(!1);o.useEffect(()=>{const T=x.timelineRef.current;if(!T||!l||!c)return;const v=200,$=()=>{C.current||u||!c||T.scrollHeight-T.scrollTop-T.clientHeight>v||(C.current=!0,Promise.resolve(l()).finally(()=>{C.current=!1}))};return T.addEventListener("scroll",$),$(),()=>{T.removeEventListener("scroll",$)}},[x.timelineRef,l,c,u]);const y=o.useCallback(()=>{E(null)},[]),P=o.useCallback(T=>{var _,S;const v=[],$=!r.completedAt;if(T.resourceType==="sleep"&&T.isActive&&$&&n&&v.push({label:"Wake Up Sleep",icon:t.jsx(Zs,{className:"h-3.5 w-3.5"}),action:()=>{n(r.runId,T.spanId).then(R=>{R.stoppedCount>0?f.success("Sleep woken up",{description:`Woke up ${String(R.stoppedCount)} sleep${R.stoppedCount>1?"s":""}`}):f.info("No active sleeps found",{description:"The sleep may have already completed."})}).catch(R=>{f.error("Failed to wake up sleep",{description:R instanceof Error?R.message:"An unknown error occurred"})})}}),T.resourceType==="hook"&&$&&i){const R=j.get(T.spanId),M=(_=R==null?void 0:R.attributes)==null?void 0:_.data,A=!!(M!=null&&M.disposedAt)||!!((S=R==null?void 0:R.events)!=null&&S.some(W=>W.name==="hook_disposed"))||k.has(T.spanId);M!=null&&M.token&&!A&&v.push({label:"Resolve Hook",icon:t.jsx(Vr,{className:"h-3.5 w-3.5"}),action:()=>{O({hookId:T.spanId,token:M.token})}})}return T.resourceType==="run"&&$&&a&&v.push({label:"Cancel Run",icon:t.jsx(Ys,{className:"h-3.5 w-3.5"}),destructive:!0,action:()=>{a(r.runId).catch(R=>{f.error("Failed to cancel run",{description:R instanceof Error?R.message:"An unknown error occurred"})})}}),v.push({label:"View Details",icon:t.jsx(Gn,{className:"h-3.5 w-3.5"}),action:()=>{h({type:"select",id:T.spanId})}}),v.push({label:"Copy Name",icon:t.jsx(Xn,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(T.spanName).then(()=>{f.success("Name copied to clipboard")}).catch(()=>{f.error("Failed to copy name")})}}),v.push({label:"Copy ID",icon:t.jsx(rt,{className:"h-3.5 w-3.5"}),action:()=>{navigator.clipboard.writeText(T.spanId).then(()=>{f.success("ID copied to clipboard")}).catch(()=>{f.error("Failed to copy ID")})}}),v},[h,n,a,i,j,k,r.runId,r.completedAt]);return t.jsxs("div",{className:"relative w-full h-full",ref:g,children:[d,p?t.jsx(Ma,{menu:p,items:P(p),onClose:y}):null,t.jsx(zr,{isOpen:w!==null,onClose:()=>O(null),onSubmit:I,isSubmitting:b})]})}function La({onSelectionChange:e}){const{state:r}=we(),{selected:s}=r,n=o.useRef(e);n.current=e;const a=o.useRef(void 0);return o.useEffect(()=>{var l,c;const i=s==null?void 0:s.span.spanId;i!==a.current&&(a.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 Pa({triggerDeselect:e}){const{dispatch:r}=we();return o.useEffect(()=>{e>0&&r({type:"deselect"})},[e,r]),null}function Fa({selectRequest:e}){const{dispatch:r}=we();return o.useEffect(()=>{e!=null&&e.id&&r({type:"select",id:e.id})},[r,e]),null}function Oa({onResize:e}){const r=o.useCallback(s=>{s.preventDefault();let n=s.clientX;const a=l=>{const c=n-l.clientX;n=l.clientX,e(c)},i=()=>{document.removeEventListener("pointermove",a),document.removeEventListener("pointerup",i)};document.addEventListener("pointermove",a),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 $a({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(Xt,{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 Wa=({run:e,events:r,isLoading:s,error:n,spanDetailData:a,spanDetailLoading:i,spanDetailError:l,onWakeUpSleep:c,onResolveHook:u,onCancelRun:d,onStreamClick:f,onSpanSelect:x,onLoadEventData:h,onLoadMoreSpans:p,hasMoreSpans:E=!1,isLoadingMoreSpans:w=!1,encryptionKey:O,onDecrypt:b,isDecrypting:m=!1,hasEncryptedData:k=!1})=>{const D=Ke(),[j,I]=o.useState(null),[N,g]=o.useState(Aa),[C,y]=o.useState(0),[P,T]=o.useState(null),v=!!(e&&!e.completedAt),$=o.useMemo(()=>{if(e!=null&&e.runId)return Ia(e,r,new Date)},[e,r]),_=$;o.useEffect(()=>{n&&!s&&(console.error(n),D.error("Error loading workflow trace data",{description:n.message}))},[n,s]);const S=o.useCallback(L=>{x==null||x(L)},[x]),R=o.useCallback(L=>{if(L){const F=L.spanId,K=F?r.filter(Y=>Y.correlationId===F):[];I({...L,rawEvents:K})}else I(null)},[r]);o.useEffect(()=>{const L=j==null?void 0:j.spanId;if(!L)return;const F=r.filter(K=>K.correlationId===L);I(K=>{if(!K||K.spanId!==L)return K;const Y=K.rawEvents??[];return Y.length===F.length&&Y.every((B,q)=>{var H;return B.eventId===((H=F[q])==null?void 0:H.eventId)})?K:{...K,rawEvents:F}})},[r,j==null?void 0:j.spanId]);const M=o.useCallback(()=>{I(null),y(L=>L+1)},[]),A=o.useCallback(L=>{g(F=>Math.max(Da,F+L))},[]),W=o.useMemo(()=>!(j!=null&&j.spanId)||!_?-1:_.spans.findIndex(L=>L.spanId===j.spanId),[j==null?void 0:j.spanId,_]),z=W>0,V=W>=0&&_!=null&&W<_.spans.length-1,J=o.useCallback(()=>{var F;if(!_||W<=0)return;const L=(F=_.spans[W-1])==null?void 0:F.spanId;L&&T({id:L,token:Date.now()})},[W,_]),X=o.useCallback(()=>{var F;if(!_||W<0)return;const L=(F=_.spans[W+1])==null?void 0:F.spanId;L&&T({id:L,token:Date.now()})},[W,_]),U=o.useMemo(()=>{var Y,re;if(!(j!=null&&j.data))return;const L=j.data,F=L.stepName,K=L.workflowName;return(F?(Y=st(F))==null?void 0:Y.shortName:void 0)??(K?(re=Ue(K))==null?void 0:re.shortName:void 0)??F??K??L.hookId??"Details"},[j==null?void 0:j.data]);return _?t.jsxs("div",{className:"relative w-full h-full flex",children:[t.jsx("div",{className:"flex-1 min-w-0 relative",children:t.jsxs(Dn,{customSpanClassNameFunc:fa,customSpanEventClassNameFunc:ma,children:[t.jsx(La,{onSelectionChange:R}),t.jsx(Pa,{triggerDeselect:C}),t.jsx(Fa,{selectRequest:P}),t.jsx(_a,{trace:_,run:e,isLive:v,onWakeUpSleep:c,onCancelRun:d,onResolveHook:u,onLoadMoreSpans:p,hasMoreSpans:E,isLoadingMoreSpans:w,children:t.jsx(da,{eagerRender:!0,height:"100%",isLive:v,trace:_,knownDurationMs:$==null?void 0:$.knownDurationMs,hasMoreData:E||!!s,footer:t.jsx($a,{hasMore:E,isLive:v,isInitialLoading:!!s})})})]})}),j&&t.jsxs("div",{className:"relative border-l flex-shrink-0 flex flex-col",style:{width:N,borderColor:"var(--ds-gray-200)",backgroundColor:"var(--ds-background-100)"},children:[t.jsx(Oa,{onResize:A}),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:U,children:U})}),t.jsxs("div",{className:"flex items-center",children:[t.jsx("button",{type:"button","aria-label":"Previous span",onClick:J,disabled:!z,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:6,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:z?"pointer":"not-allowed",opacity:z?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:L=>{z&&(L.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:t.jsx(Ks,{size:16})}),t.jsx("button",{type:"button","aria-label":"Next span",onClick:X,disabled:!V,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:2,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:V?"pointer":"not-allowed",opacity:V?1:.45,flexShrink:0,transition:"background 0.15s"},onMouseEnter:L=>{V&&(L.currentTarget.style.background="var(--ds-gray-alpha-100)")},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:t.jsx(qs,{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:M,style:{display:"flex",alignItems:"center",justifyContent:"center",marginLeft:6,width:24,height:24,padding:0,borderRadius:6,border:"none",background:"transparent",color:"var(--ds-gray-700)",cursor:"pointer",flexShrink:0,transition:"background 0.15s"},onMouseEnter:L=>{L.currentTarget.style.background="var(--ds-gray-alpha-100)"},onMouseLeave:L=>{L.currentTarget.style.background="transparent"},children:t.jsx(Gs,{size:16})})})]}),t.jsx("div",{className:"flex-1 overflow-y-auto",children:t.jsx(Qe,{title:"Failed to load entity details",children:t.jsx(qo,{run:e,onStreamClick:f,spanDetailData:a??null,spanDetailError:l,spanDetailLoading:i,onSpanSelect:S,onWakeUpSleep:c,onLoadEventData:h,onResolveHook:u,encryptionKey:O,onDecrypt:b,isDecrypting:m,selectedSpan:j,hasEncryptedData:k})})})]})]}):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 Ha(e,r,s,n={}){const a=n.resolveData??"all";let i,l;if(r==="run")i=await ht(Ht(e,s,a)),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(Mn(e,c,s,a)),l=i.stepId}else if(r==="hook")i=await ht(qr(e,s,a)),l=i.hookId;else throw new _e(`Unknown resource type: ${r}`,{layer:"client"});return{data:i,correlationId:l}}function Ba(e,r,s,n={}){const{refreshInterval:a=0,runId:i,enabled:l=!0,encryptionKey:c}=n,[u,d]=o.useState(null),[f,x]=o.useState(l),[h,p]=o.useState(null),E=o.useCallback(async b=>c?Ve(b,c):fe(b),[c]),w=o.useRef(""),O=o.useCallback(async()=>{if(!l){x(!1);return}const b=`${r}:${s}`;if(b!==w.current&&(d(null),w.current=b),p(null),x(!0),r==="hook"){try{const{error:m,result:k}=await de(qr(e,s,"all"));if(m){p(m);return}try{d(await E(k))}catch(D){p(D instanceof Error?D:new Error(String(D)))}}finally{x(!1)}return}if(r==="sleep"){try{if(!i){p(new Error("runId is required for loading sleep details"));return}const{error:m,result:k}=await de(Pe(e,i,{sortOrder:"asc",limit:1e3,withData:!0}));if(m){p(m);return}try{const D=k.data.map(fe),j=await Promise.all(D.filter(N=>N.correlationId===s).map(E)),I=ss(j);if(I===null){p(new Error(`Failed to load ${r} details: missing required event data`));return}d(I)}catch(D){p(D instanceof Error?D:new Error(String(D)))}}finally{x(!1)}return}try{const{data:m}=await Ha(e,r,s,{runId:i});d(await E(m))}catch(m){m instanceof Error?p(m):p(new Error(String(m)));return}finally{x(!1)}},[e,r,s,i,l,E]);return o.useEffect(()=>{O()},[O]),o.useEffect(()=>{if(!a||a<=0)return;const b=setInterval(O,a);return()=>clearInterval(b)},[a,O]),{data:u,loading:f,error:h,refresh:O}}function zt(e,r,s){const n=[...e,...r],a=new Map(n.map(i=>[i[s],i]));return Array.from(a.values())}async function Va(e){const{fetchFn:r,setItems:s,setCursor:n,setError:a,idKey:i,cursorStrategy:l="always",transform:c}=e,{error:u,result:d}=await r();if(u)return a(u),!1;if(d.data.length>0){const f=c?d.data.map(c):d.data;return s(h=>zt(h,f,i)),(l==="onHasMore"?!!(d.cursor&&d.hasMore):!!d.cursor)&&n(d.cursor),!0}return!1}const za=100,Ua=500,Ka=100,qa=5e3;function Ga(e,r,s={}){const{live:n=!1}=s,[a,i]=o.useState(null),[l,c]=o.useState([]),[u,d]=o.useState(!0),[f,x]=o.useState(null),[h,p]=o.useState(),[E,w]=o.useState(!1),[O,b]=o.useState(!1),[m,k]=o.useState(!1),D=o.useRef(!1),j=o.useRef(!0),[I,N]=o.useState(!1),g=o.useCallback(async()=>{if(D.current)return;D.current=!0,d(!0),x(null);const[v,$]=await Promise.all([de(Ht(e,r,"none")),de(Pe(e,r,{sortOrder:"asc",limit:Ua,withData:!1}))]);v.error?x(v.error):i(fe(v.result));const _=$.error?[]:$.result.data.map(fe);if(c(zt([],_,"eventId")),p($.error||!$.result.hasMore?void 0:$.result.cursor),w(!!(!$.error&&$.result.hasMore)),d(!1),N(!0),D.current=!1,!v.error&&$.error&&x($.error),!v.error){const S=v.result.executionContext;S!=null&&S.features&&S.features.encryption?k(!0):de(Pe(e,r,{sortOrder:"asc",limit:1,withData:!0})).then(R=>{j.current&&!R.error&&R.result.data.some(M=>_n(fe(M)))&&k(!0)}).catch(()=>{})}},[e,r]),C=o.useCallback(async()=>{if(!(D.current||!I||O||!E)){b(!0);try{const v=await de(Pe(e,r,{cursor:h,sortOrder:"asc",limit:Ka,withData:!1}));if(v.error)x(v.error);else{const $=v.result.data.map(fe);$.length>0&&c(_=>zt(_,$,"eventId")),w(!!v.result.hasMore),p(v.result.hasMore?v.result.cursor:void 0)}}finally{b(!1)}}},[e,r,I,O,E,h]),y=o.useCallback(async()=>{if(a!=null&&a.completedAt)return!1;const{error:v,result:$}=await de(Ht(e,r,"none"));return v?(x(v),!1):(x(null),i(fe($)),!0)},[e,r,a==null?void 0:a.completedAt]),P=o.useCallback(()=>Va({fetchFn:()=>de(Pe(e,r,{cursor:h,sortOrder:"asc",limit:za,withData:!1})),setItems:c,setCursor:p,setError:x,idKey:"eventId",transform:fe}),[e,r,h]),T=o.useCallback(async()=>{if(D.current||!I)return{foundNewItems:!1};let v=!1;try{const[$,_]=await Promise.all([y(),P()]);v=_}catch($){console.error("Update error:",$)}return{foundNewItems:v}},[P,I,y]);return o.useEffect(()=>{g()},[g]),o.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]),o.useEffect(()=>{if(!n||!I||a!=null&&a.completedAt)return;const v=setInterval(()=>{T()},qa);return()=>{clearInterval(v)}},[n,I,T,a==null?void 0:a.completedAt]),{run:a??{},events:l,loading:u,error:f,update:T,loadMoreTraceData:C,hasMoreTraceData:E,isLoadingMoreTraceData:O,hasEncryptedData:m}}function Za(e){return typeof e=="object"&&e!==null&&"message"in e&&"layer"in e&&"cause"in e&&"request"in e}async function Ya(e,r,s,n,a){try{const i=new URLSearchParams({runId:s});a&&i.set("cursor",a);const l=`/api/stream/${encodeURIComponent(r)}?${i.toString()}`,c=await fetch(l,{signal:n});if(!c.ok){const f=await c.json().catch(()=>null);throw f&&Za(f)?new _e(f.message,{layer:"client",cause:f.cause,request:f.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 Xa(e,r){return ht(Ln(e,r))}const Ja=1e4;function Qa(e,r,s=Ja){const[n,a]=o.useState([]),[i,l]=o.useState(!0),[c,u]=o.useState(null),d=o.useRef(!1),f=o.useCallback(async()=>{d.current||l(!0),u(null);try{const x=await Xa(e,r);a(x)}catch(x){u(x instanceof Error?x:new Error(String(x)))}finally{d.current=!0,l(!1)}},[e,r]);return o.useEffect(()=>{d.current=!1,f()},[f]),o.useEffect(()=>{if(!s||s<=0)return;const x=setInterval(f,s);return()=>clearInterval(x)},[s,f]),{streams:n,loading:i,error:c,refresh:f}}var ei=["a","button","div","form","h2","h3","img","input","label","li","nav","ol","p","span","svg","ul"],Ne=ei.reduce((e,r)=>{const s=o.forwardRef((n,a)=>{const{asChild:i,...l}=n,c=i?Yt:r;return typeof window<"u"&&(window[Symbol.for("radix-ui")]=!0),t.jsx(c,{...l,ref:a})});return s.displayName=`Primitive.${r}`,{...e,[r]:s}},{});function ti(e,r){e&&Kt.flushSync(()=>e.dispatchEvent(r))}var ri="DismissableLayer",Ut="dismissableLayer.update",si="dismissableLayer.pointerDownOutside",ni="dismissableLayer.focusOutside",jr,ns=o.createContext({layers:new Set,layersWithOutsidePointerEventsDisabled:new Set,branches:new Set}),os=o.forwardRef((e,r)=>{const{disableOutsidePointerEvents:s=!1,onEscapeKeyDown:n,onPointerDownOutside:a,onFocusOutside:i,onInteractOutside:l,onDismiss:c,...u}=e,d=o.useContext(ns),[f,x]=o.useState(null),h=(f==null?void 0:f.ownerDocument)??(globalThis==null?void 0:globalThis.document),[,p]=o.useState({}),E=Ie(r,N=>x(N)),w=Array.from(d.layers),[O]=[...d.layersWithOutsidePointerEventsDisabled].slice(-1),b=w.indexOf(O),m=f?w.indexOf(f):-1,k=d.layersWithOutsidePointerEventsDisabled.size>0,D=m>=b,j=ii(N=>{const g=N.target,C=[...d.branches].some(y=>y.contains(g));!D||C||(a==null||a(N),l==null||l(N),N.defaultPrevented||c==null||c())},h),I=li(N=>{const g=N.target;[...d.branches].some(y=>y.contains(g))||(i==null||i(N),l==null||l(N),N.defaultPrevented||c==null||c())},h);return Xs(N=>{m===d.layers.size-1&&(n==null||n(N),!N.defaultPrevented&&c&&(N.preventDefault(),c()))},h),o.useEffect(()=>{if(f)return s&&(d.layersWithOutsidePointerEventsDisabled.size===0&&(jr=h.body.style.pointerEvents,h.body.style.pointerEvents="none"),d.layersWithOutsidePointerEventsDisabled.add(f)),d.layers.add(f),kr(),()=>{s&&d.layersWithOutsidePointerEventsDisabled.size===1&&(h.body.style.pointerEvents=jr)}},[f,h,s,d]),o.useEffect(()=>()=>{f&&(d.layers.delete(f),d.layersWithOutsidePointerEventsDisabled.delete(f),kr())},[f,d]),o.useEffect(()=>{const N=()=>p({});return document.addEventListener(Ut,N),()=>document.removeEventListener(Ut,N)},[]),t.jsx(Ne.div,{...u,ref:E,style:{pointerEvents:k?D?"auto":"none":void 0,...e.style},onFocusCapture:ke(e.onFocusCapture,I.onFocusCapture),onBlurCapture:ke(e.onBlurCapture,I.onBlurCapture),onPointerDownCapture:ke(e.onPointerDownCapture,j.onPointerDownCapture)})});os.displayName=ri;var oi="DismissableLayerBranch",ai=o.forwardRef((e,r)=>{const s=o.useContext(ns),n=o.useRef(null),a=Ie(r,n);return o.useEffect(()=>{const i=n.current;if(i)return s.branches.add(i),()=>{s.branches.delete(i)}},[s.branches]),t.jsx(Ne.div,{...e,ref:a})});ai.displayName=oi;function ii(e,r=globalThis==null?void 0:globalThis.document){const s=yt(e),n=o.useRef(!1),a=o.useRef(()=>{});return o.useEffect(()=>{const i=c=>{if(c.target&&!n.current){let u=function(){as(si,s,d,{discrete:!0})};const d={originalEvent:c};c.pointerType==="touch"?(r.removeEventListener("click",a.current),a.current=u,r.addEventListener("click",a.current,{once:!0})):u()}else r.removeEventListener("click",a.current);n.current=!1},l=window.setTimeout(()=>{r.addEventListener("pointerdown",i)},0);return()=>{window.clearTimeout(l),r.removeEventListener("pointerdown",i),r.removeEventListener("click",a.current)}},[r,s]),{onPointerDownCapture:()=>n.current=!0}}function li(e,r=globalThis==null?void 0:globalThis.document){const s=yt(e),n=o.useRef(!1);return o.useEffect(()=>{const a=i=>{i.target&&!n.current&&as(ni,s,{originalEvent:i},{discrete:!1})};return r.addEventListener("focusin",a),()=>r.removeEventListener("focusin",a)},[r,s]),{onFocusCapture:()=>n.current=!0,onBlurCapture:()=>n.current=!1}}function kr(){const e=new CustomEvent(Ut);document.dispatchEvent(e)}function as(e,r,s,{discrete:n}){const a=s.originalEvent.target,i=new CustomEvent(e,{bubbles:!1,cancelable:!0,detail:s});r&&a.addEventListener(e,r,{once:!0}),n?ti(a,i):a.dispatchEvent(i)}var Ot="focusScope.autoFocusOnMount",$t="focusScope.autoFocusOnUnmount",Nr={bubbles:!1,cancelable:!0},ci="FocusScope",is=o.forwardRef((e,r)=>{const{loop:s=!1,trapped:n=!1,onMountAutoFocus:a,onUnmountAutoFocus:i,...l}=e,[c,u]=o.useState(null),d=yt(a),f=yt(i),x=o.useRef(null),h=Ie(r,w=>u(w)),p=o.useRef({paused:!1,pause(){this.paused=!0},resume(){this.paused=!1}}).current;o.useEffect(()=>{if(n){let w=function(k){if(p.paused||!c)return;const D=k.target;c.contains(D)?x.current=D:Se(x.current,{select:!0})},O=function(k){if(p.paused||!c)return;const D=k.relatedTarget;D!==null&&(c.contains(D)||Se(x.current,{select:!0}))},b=function(k){if(document.activeElement===document.body)for(const j of k)j.removedNodes.length>0&&Se(c)};document.addEventListener("focusin",w),document.addEventListener("focusout",O);const m=new MutationObserver(b);return c&&m.observe(c,{childList:!0,subtree:!0}),()=>{document.removeEventListener("focusin",w),document.removeEventListener("focusout",O),m.disconnect()}}},[n,c,p.paused]),o.useEffect(()=>{if(c){Er.add(p);const w=document.activeElement;if(!c.contains(w)){const b=new CustomEvent(Ot,Nr);c.addEventListener(Ot,d),c.dispatchEvent(b),b.defaultPrevented||(di(hi(ls(c)),{select:!0}),document.activeElement===w&&Se(c))}return()=>{c.removeEventListener(Ot,d),setTimeout(()=>{const b=new CustomEvent($t,Nr);c.addEventListener($t,f),c.dispatchEvent(b),b.defaultPrevented||Se(w??document.body,{select:!0}),c.removeEventListener($t,f),Er.remove(p)},0)}}},[c,d,f,p]);const E=o.useCallback(w=>{if(!s&&!n||p.paused)return;const O=w.key==="Tab"&&!w.altKey&&!w.ctrlKey&&!w.metaKey,b=document.activeElement;if(O&&b){const m=w.currentTarget,[k,D]=ui(m);k&&D?!w.shiftKey&&b===D?(w.preventDefault(),s&&Se(k,{select:!0})):w.shiftKey&&b===k&&(w.preventDefault(),s&&Se(D,{select:!0})):b===m&&w.preventDefault()}},[s,n,p.paused]);return t.jsx(Ne.div,{tabIndex:-1,...l,ref:h,onKeyDown:E})});is.displayName=ci;function di(e,{select:r=!1}={}){const s=document.activeElement;for(const n of e)if(Se(n,{select:r}),document.activeElement!==s)return}function ui(e){const r=ls(e),s=Cr(r,e),n=Cr(r.reverse(),e);return[s,n]}function ls(e){const r=[],s=document.createTreeWalker(e,NodeFilter.SHOW_ELEMENT,{acceptNode:n=>{const a=n.tagName==="INPUT"&&n.type==="hidden";return n.disabled||n.hidden||a?NodeFilter.FILTER_SKIP:n.tabIndex>=0?NodeFilter.FILTER_ACCEPT:NodeFilter.FILTER_SKIP}});for(;s.nextNode();)r.push(s.currentNode);return r}function Cr(e,r){for(const s of e)if(!fi(s,{upTo:r}))return s}function fi(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 mi(e){return e instanceof HTMLInputElement&&"select"in e}function Se(e,{select:r=!1}={}){if(e&&e.focus){const s=document.activeElement;e.focus({preventScroll:!0}),e!==s&&mi(e)&&r&&e.select()}}var Er=pi();function pi(){let e=[];return{add(r){const s=e[0];r!==s&&(s==null||s.pause()),e=Sr(e,r),e.unshift(r)},remove(r){var s;e=Sr(e,r),(s=e[0])==null||s.resume()}}}function Sr(e,r){const s=[...e],n=s.indexOf(r);return n!==-1&&s.splice(n,1),s}function hi(e){return e.filter(r=>r.tagName!=="A")}var xi="Portal",cs=o.forwardRef((e,r)=>{var c;const{container:s,...n}=e,[a,i]=o.useState(!1);Js(()=>i(!0),[]);const l=s||a&&((c=globalThis==null?void 0:globalThis.document)==null?void 0:c.body);return l?Ws.createPortal(t.jsx(Ne.div,{...n,ref:r}),l):null});cs.displayName=xi;var tr="Dialog",[ds,us]=Ur(tr),[gi,xe]=ds(tr),fs=e=>{const{__scopeDialog:r,children:s,open:n,defaultOpen:a,onOpenChange:i,modal:l=!0}=e,c=o.useRef(null),u=o.useRef(null),[d=!1,f]=en({prop:n,defaultProp:a,onChange:i});return t.jsx(gi,{scope:r,triggerRef:c,contentRef:u,contentId:Tt(),titleId:Tt(),descriptionId:Tt(),open:d,onOpenChange:f,onOpenToggle:o.useCallback(()=>f(x=>!x),[f]),modal:l,children:s})};fs.displayName=tr;var ms="DialogTrigger",ps=o.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,a=xe(ms,s),i=Ie(r,a.triggerRef);return t.jsx(Ne.button,{type:"button","aria-haspopup":"dialog","aria-expanded":a.open,"aria-controls":a.contentId,"data-state":nr(a.open),...n,ref:i,onClick:ke(e.onClick,a.onOpenToggle)})});ps.displayName=ms;var rr="DialogPortal",[yi,hs]=ds(rr,{forceMount:void 0}),xs=e=>{const{__scopeDialog:r,forceMount:s,children:n,container:a}=e,i=xe(rr,r);return t.jsx(yi,{scope:r,forceMount:s,children:o.Children.map(n,l=>t.jsx(Gt,{present:s||i.open,children:t.jsx(cs,{asChild:!0,container:a,children:l})}))})};xs.displayName=rr;var kt="DialogOverlay",gs=o.forwardRef((e,r)=>{const s=hs(kt,e.__scopeDialog),{forceMount:n=s.forceMount,...a}=e,i=xe(kt,e.__scopeDialog);return i.modal?t.jsx(Gt,{present:n||i.open,children:t.jsx(vi,{...a,ref:r})}):null});gs.displayName=kt;var vi=o.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,a=xe(kt,s);return t.jsx(rn,{as:Yt,allowPinchZoom:!0,shards:[a.contentRef],children:t.jsx(Ne.div,{"data-state":nr(a.open),...n,ref:r,style:{pointerEvents:"auto",...n.style}})})}),Oe="DialogContent",ys=o.forwardRef((e,r)=>{const s=hs(Oe,e.__scopeDialog),{forceMount:n=s.forceMount,...a}=e,i=xe(Oe,e.__scopeDialog);return t.jsx(Gt,{present:n||i.open,children:i.modal?t.jsx(wi,{...a,ref:r}):t.jsx(bi,{...a,ref:r})})});ys.displayName=Oe;var wi=o.forwardRef((e,r)=>{const s=xe(Oe,e.__scopeDialog),n=o.useRef(null),a=Ie(r,s.contentRef,n);return o.useEffect(()=>{const i=n.current;if(i)return tn(i)},[]),t.jsx(vs,{...e,ref:a,trapFocus:s.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:ke(e.onCloseAutoFocus,i=>{var l;i.preventDefault(),(l=s.triggerRef.current)==null||l.focus()}),onPointerDownOutside:ke(e.onPointerDownOutside,i=>{const l=i.detail.originalEvent,c=l.button===0&&l.ctrlKey===!0;(l.button===2||c)&&i.preventDefault()}),onFocusOutside:ke(e.onFocusOutside,i=>i.preventDefault())})}),bi=o.forwardRef((e,r)=>{const s=xe(Oe,e.__scopeDialog),n=o.useRef(!1),a=o.useRef(!1);return t.jsx(vs,{...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,a.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"&&(a.current=!0));const l=i.target;((d=s.triggerRef.current)==null?void 0:d.contains(l))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&a.current&&i.preventDefault()}})}),vs=o.forwardRef((e,r)=>{const{__scopeDialog:s,trapFocus:n,onOpenAutoFocus:a,onCloseAutoFocus:i,...l}=e,c=xe(Oe,s),u=o.useRef(null),d=Ie(r,u);return sn(),t.jsxs(t.Fragment,{children:[t.jsx(is,{asChild:!0,loop:!0,trapped:n,onMountAutoFocus:a,onUnmountAutoFocus:i,children:t.jsx(os,{role:"dialog",id:c.contentId,"aria-describedby":c.descriptionId,"aria-labelledby":c.titleId,"data-state":nr(c.open),...l,ref:d,onDismiss:()=>c.onOpenChange(!1)})}),t.jsxs(t.Fragment,{children:[t.jsx(ki,{titleId:c.titleId}),t.jsx(Ci,{contentRef:u,descriptionId:c.descriptionId})]})]})}),sr="DialogTitle",ws=o.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,a=xe(sr,s);return t.jsx(Ne.h2,{id:a.titleId,...n,ref:r})});ws.displayName=sr;var bs="DialogDescription",js=o.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,a=xe(bs,s);return t.jsx(Ne.p,{id:a.descriptionId,...n,ref:r})});js.displayName=bs;var ks="DialogClose",Ns=o.forwardRef((e,r)=>{const{__scopeDialog:s,...n}=e,a=xe(ks,s);return t.jsx(Ne.button,{type:"button",...n,ref:r,onClick:ke(e.onClick,()=>a.onOpenChange(!1))})});Ns.displayName=ks;function nr(e){return e?"open":"closed"}var Cs="DialogTitleWarning",[ji,Es]=Qs(Cs,{contentName:Oe,titleName:sr,docsSlug:"dialog"}),ki=({titleId:e})=>{const r=Es(Cs),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 o.useEffect(()=>{e&&(document.getElementById(e)||console.error(s))},[s,e]),null},Ni="DialogDescriptionWarning",Ci=({contentRef:e,descriptionId:r})=>{const n=`Warning: Missing \`Description\` or \`aria-describedby={undefined}\` for {${Es(Ni).contentName}}.`;return o.useEffect(()=>{var i;const a=(i=e.current)==null?void 0:i.getAttribute("aria-describedby");r&&a&&(document.getElementById(r)||console.warn(n))},[n,e,r]),null},Ei=fs,Si=ps,Ti=xs,Ii=gs,Ri=ys,Ai=ws,Di=js,Ss=Ns,Ts="AlertDialog",[Mi]=Ur(Ts,[us]),Ce=us(),Is=e=>{const{__scopeAlertDialog:r,...s}=e,n=Ce(r);return t.jsx(Ei,{...n,...s,modal:!0})};Is.displayName=Ts;var _i="AlertDialogTrigger",Li=o.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,a=Ce(s);return t.jsx(Si,{...a,...n,ref:r})});Li.displayName=_i;var Pi="AlertDialogPortal",Rs=e=>{const{__scopeAlertDialog:r,...s}=e,n=Ce(r);return t.jsx(Ti,{...n,...s})};Rs.displayName=Pi;var Fi="AlertDialogOverlay",As=o.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,a=Ce(s);return t.jsx(Ii,{...a,...n,ref:r})});As.displayName=Fi;var ze="AlertDialogContent",[Oi,$i]=Mi(ze),Ds=o.forwardRef((e,r)=>{const{__scopeAlertDialog:s,children:n,...a}=e,i=Ce(s),l=o.useRef(null),c=Ie(r,l),u=o.useRef(null);return t.jsx(ji,{contentName:ze,titleName:Ms,docsSlug:"alert-dialog",children:t.jsx(Oi,{scope:s,cancelRef:u,children:t.jsxs(Ri,{role:"alertdialog",...i,...a,ref:c,onOpenAutoFocus:ke(a.onOpenAutoFocus,d=>{var f;d.preventDefault(),(f=u.current)==null||f.focus({preventScroll:!0})}),onPointerDownOutside:d=>d.preventDefault(),onInteractOutside:d=>d.preventDefault(),children:[t.jsx(Pn,{children:n}),t.jsx(Hi,{contentRef:l})]})})})});Ds.displayName=ze;var Ms="AlertDialogTitle",_s=o.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,a=Ce(s);return t.jsx(Ai,{...a,...n,ref:r})});_s.displayName=Ms;var Ls="AlertDialogDescription",Ps=o.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,a=Ce(s);return t.jsx(Di,{...a,...n,ref:r})});Ps.displayName=Ls;var Wi="AlertDialogAction",Fs=o.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,a=Ce(s);return t.jsx(Ss,{...a,...n,ref:r})});Fs.displayName=Wi;var Os="AlertDialogCancel",$s=o.forwardRef((e,r)=>{const{__scopeAlertDialog:s,...n}=e,{cancelRef:a}=$i(Os,s),i=Ce(s),l=Ie(r,a);return t.jsx(Ss,{...i,...n,ref:l})});$s.displayName=Os;var Hi=({contentRef:e})=>{const r=`\`${ze}\` requires a description for the component to be accessible for screen reader users.
28
-
29
- You can add a description to the \`${ze}\` by passing a \`${Ls}\` 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 \`${ze}\`. 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 o.useEffect(()=>{var n;document.getElementById((n=e.current)==null?void 0:n.getAttribute("aria-describedby"))||console.warn(r)},[r,e]),null},Bi=Is,Vi=Rs,zi=As,Ui=Ds,Ki=Fs,qi=$s,Gi=_s,Zi=Ps;function Tr({...e}){return t.jsx(Bi,{"data-slot":"alert-dialog",...e})}function Yi({...e}){return t.jsx(Vi,{"data-slot":"alert-dialog-portal",...e})}function Xi({className:e,...r}){return t.jsx(zi,{"data-slot":"alert-dialog-overlay",className:ue("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 Ir({className:e,onSubmit:r,...s}){return t.jsxs(Yi,{children:[t.jsx(Xi,{}),t.jsx(Ui,{"data-slot":"alert-dialog-content",className:ue("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 Rr({className:e,...r}){return t.jsx("div",{"data-slot":"alert-dialog-header",className:ue("flex flex-col gap-2 text-center sm:text-left",e),...r})}function Ar({className:e,...r}){return t.jsx("div",{"data-slot":"alert-dialog-footer",className:ue("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",e),...r})}function Dr({className:e,...r}){return t.jsx(Gi,{"data-slot":"alert-dialog-title",className:ue("text-lg font-semibold",e),...r})}function Mr({className:e,...r}){return t.jsx(Zi,{"data-slot":"alert-dialog-description",className:ue("text-muted-foreground text-sm",e),...r})}function _r({className:e,...r}){return t.jsx(Ki,{className:ue(Gr(),e),...r})}function Lr({className:e,...r}){return t.jsx(qi,{className:ue(Gr({variant:"outline"}),e),...r})}function Ji({...e}){return t.jsx("nav",{"aria-label":"breadcrumb","data-slot":"breadcrumb",...e})}function Qi({className:e,...r}){return t.jsx("ol",{"data-slot":"breadcrumb-list",className:ue("text-muted-foreground flex flex-wrap items-center gap-1.5 text-sm break-words sm:gap-2.5",e),...r})}function Pr({className:e,...r}){return t.jsx("li",{"data-slot":"breadcrumb-item",className:ue("inline-flex items-center gap-1.5",e),...r})}function el({asChild:e,className:r,...s}){const n=e?Yt:"a";return t.jsx(n,{"data-slot":"breadcrumb-link",className:ue("hover:text-foreground transition-colors",r),...s})}function tl({className:e,...r}){return t.jsx("span",{"data-slot":"breadcrumb-page",role:"link","aria-disabled":"true","aria-current":"page",className:ue("text-foreground font-normal",e),...r})}function rl({children:e,className:r,...s}){return t.jsx("li",{"data-slot":"breadcrumb-separator",role:"presentation","aria-hidden":"true",className:ue("[&>svg]:size-3.5",r),...s,children:e??t.jsx(qt,{})})}const ye=4,sl="[Encrypted]",Fr=3e3;function Or(e){return e==="pending"||e==="running"}const He=200,nl=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,a=Array.from({length:Math.min(s.length,8)},(l,c)=>s[c]),i=s.length>8?", …":"";return`${n}(${s.length}) [${a.join(", ")}${i}]`}if(e instanceof ArrayBuffer)return`ArrayBuffer(${e.byteLength})`;if(r>=nl)return Array.isArray(e)?`Array(${e.length})`:typeof e=="object"?"{…}":e;if(Array.isArray(e)){if(e.length<=He)return e.map(n=>gt(n,r+1));const s=e.slice(0,He).map(n=>gt(n,r+1));return s.push(`… ${e.length-He} more items`),s}if(typeof e=="object"){const s=Object.keys(e),n={},a=Math.min(s.length,He);for(let i=0;i<a;i++)n[s[i]]=gt(e[s[i]],r+1);return s.length>He&&(n[`… ${s.length-He} more keys`]="…"),n}return e}const ol=()=>new Promise(e=>setTimeout(e,0)),al=64;function il(e){if(e.length<ye)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 ll(e,r,s,n,a){const[i,l]=o.useState([]),[c,u]=o.useState(!1),[d,f]=o.useState(null),x=o.useRef(null),h=o.useRef(0),p=o.useRef(0),E=o.useRef(null),w=o.useRef(a);w.current=a;const O=o.useRef(null),b=o.useCallback(async(m,k,D)=>{let j=m;if(j.length>=ye+4&&!ir(j)){const y=new DataView(j.buffer,j.byteOffset,j.byteLength).getUint32(0,!1);y>0&&y<=10*1024*1024&&y===j.length-ye&&(j=j.slice(ye))}let I;try{if(ir(j)){if(!k)return{encrypted:!0};const C=j.slice(4);I=lr(await Vn(k,C),D)}else I=lr(j,D)}catch{I=sl}let N;try{if(typeof I=="string")N=I;else{const C=gt(I);N=JSON.stringify(C,null,2)}}catch{N="[Serialization Error]"}return{encrypted:!1,chunk:{id:h.current++,text:N}}},[]);return o.useEffect(()=>{if(l([]),f(null),h.current=0,p.current=0,O.current=null,E.current&&(clearTimeout(E.current),E.current=null),!r||!s){u(!1);return}let m=!0;const k=new AbortController;x.current=k,u(!0);const D=Fn(),j=g=>{const C=h.current++;let y;try{const P=JSON.parse(g);y=JSON.stringify(P,null,2)}catch{y=g}return{id:C,text:y}},I=async(g,C,y)=>{const P=await Ya(e,r,s,k.signal,y==null?void 0:y.cursor),T=(y==null?void 0:y.skipFrames)??0,v=P.body.getReader(),$=new TextDecoder;let _=new Uint8Array(0),S=null,R="",M=0;const A=W=>{const z=new Uint8Array(_.length+W.length);z.set(_,0),z.set(W,_.length),_=z};for(;!k.signal.aborted;){const{value:W,done:z}=await v.read();if(z){S==="legacy"&&R.trim()&&(M++,M>T&&g.push(j(R.trim())),R="");break}if(S===null?(A(W),_.length>=ye&&(S=il(_)),S==="legacy"&&(R=$.decode(_,{stream:!0}),_=new Uint8Array(0))):S==="legacy"?R+=$.decode(W,{stream:!0}):A(W),S==="legacy"){const X=R.split(`
34
- `);R=X.pop()??"";for(const U of X){const L=U.trim();L&&(M++,M>T&&g.push(j(L)))}continue}let V=0,J=0;for(;V+ye<=_.length;){const U=new DataView(_.buffer,_.byteOffset+V,_.byteLength-V).getUint32(0,!1);if(U===0||U>10*1024*1024||V+ye+U>_.length)break;const L=_.slice(V+ye,V+ye+U);if(V+=ye+U,M++,M<=T)continue;const F=await b(L,C,D);if(F.encrypted)return v.cancel().catch(()=>{}),{encrypted:!0};if(g.push(F.chunk),J++,J%al===0&&(await ol(),k.signal.aborted||!m))break}_=_.slice(V)}return{encrypted:!1,frameCount:M,cursor:P.cursor,done:P.done}};return(async()=>{try{const g=n?await zn(n):void 0,C=[],y=await I(C,g);if(y.encrypted){m&&(f("This stream is encrypted. Click Decrypt to view."),u(!1));return}if(p.current=y.frameCount,O.current=y.cursor,!m||k.signal.aborted)return;if(l(C),y.done){u(!1);return}if(Or(w.current)){const P=async()=>{if(!(!m||k.signal.aborted)){try{const T=[],v=await I(T,g,{cursor:O.current,skipFrames:p.current});if(!v.encrypted&&(p.current=v.frameCount,v.cursor&&(O.current=v.cursor),T.length>0&&m&&l($=>[...$,...T]),v.done)){u(!1);return}}catch(T){console.warn("Stream poll error:",T)}m&&!k.signal.aborted&&(E.current=setTimeout(P,Fr))}};E.current=setTimeout(P,Fr)}else u(!1)}catch(g){if(k.signal.aborted)return;m&&(f(g instanceof Error?g.message:String(g)),u(!1))}})(),()=>{m=!1,k.abort(),E.current&&(clearTimeout(E.current),E.current=null)}},[e,r,s,n,b]),o.useEffect(()=>{!Or(a)&&E.current&&(clearTimeout(E.current),E.current=null,u(!1))},[a]),{chunks:i,isLive:c,error:d}}const cl=100,dl=100;function ul(e,r,s={}){const{sortOrder:n="asc",encryptionKey:a,enabled:i=!0}=s,[l,c]=o.useState([]),[u,d]=o.useState(!0),[f,x]=o.useState(null),[h,p]=o.useState(),[E,w]=o.useState(!1),[O,b]=o.useState(!1),m=o.useRef(!1),k=o.useRef(a);k.current=a;const D=o.useCallback(async()=>{if(!m.current){m.current=!0,d(!0),x(null),c([]),p(void 0),w(!1);try{const{error:I,result:N}=await de(Pe(e,r,{sortOrder:n,limit:cl,withData:!1}));if(I)x(I);else{const g=N.data.map(fe),C=k.current;if(C){const y=await Promise.all(g.map(P=>Ve(P,C)));c(y)}else c(g);p(N.hasMore?N.cursor:void 0),w(!!N.hasMore)}}catch(I){x(I)}finally{d(!1),m.current=!1}}},[e,r,n]);o.useEffect(()=>{i&&D()},[D,i]),o.useEffect(()=>{if(!a||l.length===0)return;let I=!1;return Promise.all(l.map(N=>Ve(N,a))).then(N=>{I||c(N)}).catch(()=>{}),()=>{I=!0}},[a]);const j=o.useCallback(async()=>{if(!(O||!h)){b(!0);try{const{error:I,result:N}=await de(Pe(e,r,{cursor:h,sortOrder:n,limit:dl,withData:!1}));if(I)x(I);else{if(N.data.length>0){const g=N.data.map(fe),C=k.current;if(C){const y=await Promise.all(g.map(P=>Ve(P,C)));c(P=>[...P,...y])}else c(y=>[...y,...g])}p(N.hasMore?N.cursor:void 0),w(!!N.hasMore)}}catch(I){x(I)}finally{b(!1)}}},[e,r,n,h,O]);return{events:l,loading:u,error:f,hasMore:E,loadingMore:O,loadMore:j}}function fl({hasError:e,errorMessage:r}){return t.jsx("div",{className:"flex items-center gap-2",children:t.jsxs(Zr,{children:[t.jsx(Yr,{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(Xr,{children:t.jsx("p",{children:e?`Error updating data: ${r}`:`Content updates every ${On/1e3} seconds`})})]})})}({...nn});function ml({runId:e,selectedId:r}){var be;const s=Hs(),[n]=$r(),{serverConfig:a}=$n(),[i,l]=o.useState(!1),[c,u]=o.useState(!1),[d,f]=o.useState(!1),[x,h]=o.useState(!1),p=o.useMemo(()=>({}),[]),E=n.get("tab")||"trace",w=E==="graph"?"trace":E,O=n.get("streamId"),b=o.useCallback(G=>{const se=new URLSearchParams(n.toString());for(const[ee,ne]of Object.entries(G))ne===null?se.delete(ee):se.set(ee,ne);s(`?${se.toString()}`,{preventScrollReset:!0})},[s,n]),m=o.useCallback(G=>{b(G!=="streams"?{tab:G,streamId:null}:{tab:G})},[b]),k=o.useCallback(G=>{b({streamId:G})},[b]),D=o.useCallback(G=>{b({tab:"streams",streamId:G})},[b]),j=o.useCallback(async(G,se)=>on(p,G,{correlationIds:[se]}),[p]),I=o.useRef(null),N=o.useCallback(async(G,se)=>{await an(p,G,se)},[p]),g=o.useCallback(async G=>{const{error:se,result:ee}=await de(cr(p,G.runId,G.eventId,"all"));if(se)throw se;const ne=I.current?await Ve(ee,I.current):fe(ee);return"eventData"in ne?ne.eventData:null},[p]),C=o.useCallback(async(G,se)=>{const{error:ee,result:ne}=await de(cr(p,e,se,"all"));if(ee)throw ee;const Ee=I.current?await Ve(ne,I.current):fe(ne);return"eventData"in Ee?Ee.eventData:null},[p,e]);a.backendId==="local"||a.backendId;const{run:y,events:P,loading:T,error:v,update:$,loadMoreTraceData:_,hasMoreTraceData:S,isLoadingMoreTraceData:R,hasEncryptedData:M}=Ga(p,e,{live:!0}),A=y??{},[W,z]=o.useState(null);I.current=W;const[V,J]=o.useState("asc"),{events:X,loading:U,hasMore:L,loadingMore:F,loadMore:K}=ul(p,e,{sortOrder:V,encryptionKey:W??void 0,enabled:w==="events"}),[Y,re]=o.useState(null),{data:B,loading:q,error:H,refresh:te}=Ba(p,(Y==null?void 0:Y.resource)??"run",(Y==null?void 0:Y.resourceId)??"",{runId:Y==null?void 0:Y.runId,enabled:!!(Y!=null&&Y.resource&&(Y!=null&&Y.resourceId)&&Y.resource!=="hook"),encryptionKey:W??void 0}),[oe,ce]=o.useState(!1),me=o.useCallback(async()=>{if(W){te();return}ce(!0);try{const{error:G,result:se}=await de(Wn(p,e));if(G){De.error(`Failed to fetch encryption key: ${G.message}`);return}if(!se){De.error("Encryption is not configured for this deployment.");return}z(se),De.success("Run data decrypted successfully")}finally{ce(!1)}},[W,p,e,te]),$e=o.useCallback(G=>{re(G)},[]),{streams:pe,loading:ot,error:qe}=Qa(p,e),{chunks:at,isLive:it,error:ge}=ll(p,O,e,W,A.status),lt=()=>{f(!0)},ct=async()=>{if(!i)try{l(!0),f(!1),await xn(p,e),await $(),De.success("Run cancelled successfully")}catch(G){console.error("Failed to cancel run:",G),De.error("Failed to cancel run",{description:G instanceof Error?G.message:"An unknown error occurred"})}finally{l(!1)}},dt=()=>{h(!0)},We=async()=>{if(!c)try{u(!0),h(!1);const G=await gn(p,A.runId);De.success("New run started successfully",{description:`Run ID: ${G}`}),s(`/run/${G}`)}catch(G){console.error("Failed to re-run workflow:",G),De.error("Failed to start new run",{description:G instanceof Error?G.message:"An unknown error occurred"})}finally{u(!1),h(!1)}};if(v&&!y)return t.jsxs(ln,{variant:"destructive",className:"m-4",children:[t.jsx(Wr,{className:"h-4 w-4"}),t.jsx(cn,{children:"Error loading workflow run"}),t.jsx(dn,{children:v.message})]});const Re=(be=Ue(A.workflowName))==null?void 0:be.shortName;return t.jsxs(t.Fragment,{children:[t.jsx(Tr,{open:d,onOpenChange:f,children:t.jsxs(Ir,{children:[t.jsxs(Rr,{children:[t.jsx(Dr,{children:"Cancel Workflow Run?"}),t.jsx(Mr,{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(Ar,{children:[t.jsx(Lr,{children:"Keep Running"}),t.jsx(_r,{onClick:ct,className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Cancel Run"})]})]})}),t.jsx(Tr,{open:x,onOpenChange:h,children:t.jsxs(Ir,{children:[t.jsxs(Rr,{children:[t.jsx(Dr,{children:"Replay Run?"}),t.jsx(Mr,{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(Ar,{children:[t.jsx(Lr,{children:"Cancel"}),t.jsx(_r,{onClick:We,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(Ji,{children:t.jsxs(Qi,{children:[t.jsx(Pr,{children:t.jsx(el,{asChild:!0,children:t.jsx(Bs,{to:"/",children:"Runs"})})}),t.jsx(rl,{}),t.jsx(Pr,{children:t.jsx(tl,{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:Re||t.jsx(Ae,{className:"w-[260px] h-[28px]"})})}),t.jsxs("div",{className:"flex items-center justify-between gap-2",children:[t.jsx(fl,{hasError:!1,errorMessage:""}),t.jsx(un,{env:p,runId:e,runStatus:A.status,events:P,eventsLoading:T,loading:T,onRerunClick:dt,onCancelClick:lt,callbacks:{onSuccess:$}})]})]}),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"}),A.status?t.jsx(fn,{status:A.status,context:A}):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:A.runId?A.startedAt?(()=>{const G=(A.completedAt?new Date(A.completedAt).getTime():Date.now())-new Date(A.startedAt).getTime(),se=Math.floor(G/1e3);if(se<60)return`${se}s`;const ee=Math.floor(se/60),ne=se%60;if(ee<60)return ne>0?`${ee}m ${ne}s`:`${ee}m`;const Ee=Math.floor(ee/60),or=ee%60;return or>0?`${Ee}h ${or}m`:`${Ee}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"}),A.runId?t.jsx(mn,{text:A.runId,children:t.jsx("div",{className:"text-xs mt-0.5 font-mono",children:A.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"}),A.createdAt?t.jsx("div",{className:"text-xs",children:t.jsx(ut,{date:A.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:A.runId?A.startedAt?t.jsx(ut,{date:A.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:A.runId?A.completedAt?t.jsx(ut,{date:A.completedAt}):"-":t.jsx(Ae,{className:"w-[110px] h-[20px]"})})]}),A.expiredAt!=null&&t.jsxs("div",{className:"flex flex-col gap-1",children:[t.jsxs(Zr,{children:[t.jsx(Yr,{asChild:!0,children:t.jsxs("div",{className:"text-xs text-muted-foreground cursor-help flex items-center gap-1",children:["Expired",t.jsx(Kn,{className:"w-3 h-3"})]})}),t.jsx(Xr,{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:A.expiredAt})})]})]})]})]}),t.jsx("div",{className:"mt-4 flex-1 flex flex-col min-h-0",children:t.jsxs(pn,{value:w,onValueChange:G=>m(G),className:"flex-1 flex flex-col min-h-0",children:[t.jsxs(hn,{className:"mb-4 flex-none",children:[t.jsxs(It,{value:"trace",className:"gap-2",children:[t.jsx(Mt,{className:"h-4 w-4"}),"Trace"]}),!1,t.jsxs(It,{value:"events",className:"gap-2",children:[t.jsx(Mt,{className:"h-4 w-4"}),"Events"]}),t.jsxs(It,{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(Wa,{error:v,events:P,run:A,isLoading:T,spanDetailData:B,spanDetailLoading:q,spanDetailError:H,onSpanSelect:$e,onStreamClick:D,onWakeUpSleep:j,onResolveHook:N,onLoadEventData:C,onLoadMoreSpans:_,hasMoreSpans:S,isLoadingMoreSpans:R,encryptionKey:W??void 0,onDecrypt:me,isDecrypting:oe,hasEncryptedData:M})})})}),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(bo,{events:X,run:A,onLoadEventData:g,hasMoreEvents:L,isLoadingMoreEvents:F,onLoadMoreEvents:K,encryptionKey:W??void 0,isLoading:U,sortOrder:V,onSortOrderChange:J,onDecrypt:me,isDecrypting:oe,hasEncryptedData:M})})})}),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 (",pe.length,")"]}),t.jsx("div",{className:"overflow-auto max-h-[calc(100vh-400px)]",children:ot?t.jsx("div",{className:"p-4 flex items-center justify-center",children:t.jsx(Hn,{className:"h-4 w-4 animate-spin text-muted-foreground"})}):qe?t.jsx("div",{className:"p-4 text-xs text-destructive",children:qe.message}):pe.length===0?t.jsx("div",{className:"p-4 text-xs",style:{color:"var(--ds-gray-600)"},children:"No streams found for this run"}):pe.map(G=>t.jsx("button",{type:"button",onClick:()=>k(G),className:"w-full text-left px-3 py-2 text-xs font-mono truncate hover:bg-accent transition-colors",style:{backgroundColor:O===G?"var(--ds-gray-200)":"transparent",color:"var(--ds-gray-1000)"},title:G,children:G},G))})]}),t.jsx("div",{className:"flex-1 min-w-0",children:O?ge!=null&&ge.includes("encrypted")&&!W?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(Wt,{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(Jt,{onClick:me,loading:oe})]}):t.jsx(Bn,{streamId:O,chunks:at,isLive:it,error:ge!=null&&ge.includes("encrypted")?null:ge}):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:pe.length>0?"Select a stream to view its data":"No streams available"})})})]})})}),!1]})})]})]})}const yl=Vs(function(){const r=zs(),[s]=$r(),n=r.runId,a=s.get("stepId"),i=s.get("eventId"),l=s.get("hookId"),c=a||i||l||void 0;return t.jsx(Qe,{title:"Failed to load run details",children:t.jsx(ml,{runId:n,selectedId:c})})});export{yl 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})}})();