lenso-cli 0.1.11

Lenso command-line interface for scaffolding and operating Lenso backend projects.
1
2
import{r as e}from"../../assets/rolldown-runtime-BAsxdqIR.js";import{i as t,r as n}from"../../assets/react-GKCtUGqo.js";import{a as r,n as i,r as a}from"../../assets/tanstack-Bzl_TyMc.js";import{A as o,B as s,C as c,D as l,E as u,F as d,H as f,J as p,K as m,L as ee,Q as te,S as h,Y as g,ct as _,dt as ne,f as v,h as y,ht as b,it as x,j as S,k as C,mt as w,n as T,nt as E,p as D,q as O,r as re,t as ie,tt as ae,ut as oe,w as se,z as ce}from"../../assets/ui-vendor-BOiB7gS2.js";import{$ as le,H as ue,J as de,Q as fe,St as pe,Tt as me,Y as he,_ as k,_t as ge,a as A,b as _e,bt as ve,c as ye,ct as be,d as xe,dt as Se,et as Ce,f as j,g as we,gt as Te,ht as Ee,i as M,l as De,mt as N,n as P,o as F,r as Oe,s as ke,t as Ae,u as je,ut as Me,v as Ne,vt as Pe,wt as Fe,x as Ie,yt as Le}from"../../assets/runtime-status-badge-Cc7AaPcV.js";import{t as I}from"../../assets/gsap-D_956-p2.js";var Re=[{id:`overview`,label:`Overview`},{id:`payload`,label:`Payload`},{id:`activity`,label:`Activity`},{id:`logs`,label:`Logs`},{id:`failures`,label:`Failures`},{id:`context`,label:`Context`},{id:`technical`,label:`Technical`}];function ze(e){let t=e.payload,n=Ye(t)?t:void 0,r=L(n,[`input`,`input_json`,`inputJson`,`request`,`request_json`,`requestJson`,`request_payload`,`requestPayload`,`payload`]),i=L(n,[`output`,`output_json`,`outputJson`,`response`,`response_json`,`responseJson`,`response_payload`,`responsePayload`]),a=L(n,[`metadata`,`meta`,`headers`]);return{input:r??(n&&!(r!==void 0||i!==void 0)?n:void 0),metadata:a??(n&&Object.keys(e.attributes).length>0?e.attributes:void 0),output:i}}function Be(e){return e.status===`failed`||e.status===`dead`?`failures`:qe(e)?`payload`:`overview`}function Ve(e,t){let n=e.timelineItems?.filter(e=>e.detailId===t.id||e.id===t.id).map(t=>({id:t.id,kind:t.type,label:t.name,status:t.status,timestampMs:tt(e.timestamp,t.startedAt??t.createdAt),...t.attempts>1?{detail:`attempt ${t.attempts}/${t.maxAttempts}`}:{}}))??[],r=t.events.map(e=>({id:`${t.id}:${e.name}:${e.timestampMs}`,kind:`event`,label:e.name,status:t.status,timestampMs:e.timestampMs,...e.attributes?{detail:JSON.stringify(e.attributes)}:{}}));return[...n,...r].sort((e,t)=>e.timestampMs-t.timestampMs||e.label.localeCompare(t.label))}function He(e){let t=e.status===`failed`||e.status===`dead`;if(!t)return[];let n=e.logs.at(-1),r=[];return t&&r.push({id:`current-error`,label:`current error`,value:n??`${e.status} execution`}),n&&r.push({id:`last-error`,label:`last error`,value:n}),((e.attempts??1)>1||e.retryable)&&r.push({id:`retry-history`,label:`retry history`,value:`${e.attempts??1}/${e.maxAttempts??1} attempts`}),r}function Ue(e){let t=Xe(e.attributes.source_metadata);if(!Ze(t))return;let n=[R(t.method),R(t.declared_path)].filter(e=>e!==void 0).join(` `),r=Qe(t.remote_status),i=$e(t.retryable),a=Qe(t.duration_ms)??e.durationMs,o=[[`result`,et(e.status,i)],[`module`,R(t.module_name)??e.service],[`declared route`,n||`-`],[`remote path`,R(t.remote_path)??`-`],[`remote status`,r??`-`],[`duration`,P(a)],[`request id`,R(t.request_id)??`-`],[`trace id`,R(t.trace_id)??`-`],[`span id`,R(t.span_id)??`-`],[`error code`,R(t.error_code)??`-`],[`retryability`,i?`retryable`:`not retryable`]];return{...t.error_details===void 0?{}:{errorDetails:t.error_details},...t.path_params===void 0?{}:{pathParams:t.path_params},rows:o}}function We(e,t){let n=z(e,t,`upstream`),r=z(e,t,`downstream`),i=typeof t.context.causation_id==`string`?t.context.causation_id:t.parentId,a=t.context.actor??n.find(e=>e.context.actor)?.context.actor??e.service,o=t.attributes.aggregate_id??t.attributes.aggregateId??t.payload?.aggregate_id??t.payload?.aggregateId,s=t.context.trigger_source??t.attributes.trigger_source??t.attributes.triggerSource??t.kind;return{downstream:r,rows:[[`correlation id`,e.correlationId],[`causation id`,i??`-`],[`actor`,a??`-`],[`aggregate`,o??`-`],[`trigger source`,s??`-`],[`related executions`,n.length+r.length]],upstream:n}}function Ge(e,t){return{activity:Ve(e,t).length,context:z(e,t,`upstream`).length+z(e,t,`downstream`).length,failures:He(t).length,logs:t.logs.length,overview:0,payload:Ke(t),technical:0}}function Ke(e){let t=ze(e);return[t.input,t.metadata,t.output].filter(e=>Je(e)).length}function qe(e){let t=ze(e);return Je(t.input)||Je(t.output)}function L(e,t){if(e){for(let n of t)if(e[n]!==void 0)return e[n]}}function Je(e){return e==null?!1:Array.isArray(e)?e.length>0:Ye(e)?Object.keys(e).length>0:!0}function Ye(e){return!!(e&&typeof e==`object`&&!Array.isArray(e))}function Xe(e){return Ye(e)?e:{}}function Ze(e){return typeof e.remote_proxy_call_id==`string`?!0:typeof e.module_name==`string`&&typeof e.method==`string`&&typeof e.declared_path==`string`}function R(e){return typeof e==`string`&&e.length>0?e:void 0}function Qe(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function $e(e){return typeof e==`boolean`?e:!1}function et(e,t){return e===`failed`||e===`dead`?t?`retryable failure`:`failed`:e===`completed`||e===`published`?`ok`:e}function z(e,t,n){let r=(e.edges??[]).filter(e=>n===`upstream`?e.target===t.id:e.source===t.id).map(e=>n===`upstream`?e.source:e.target),i=n===`upstream`?t.parentId:void 0,a=n===`downstream`?e.nodes.filter(e=>e.parentId===t.id).map(e=>e.id):[],o=new Set([...r,...i?[i]:[],...a]);return e.nodes.filter(e=>o.has(e.id))}function tt(e,t){let n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(r)?Math.max(0,r-n):0}var B=n();function nt({children:e,className:t,contentClassName:n,viewportClassName:r}){return(0,B.jsx)(re,{className:k(`relative min-w-0`,t),overflowEdgeThreshold:1,children:(0,B.jsx)(T,{className:k(`scrollbar-none min-w-0 overflow-x-auto overflow-y-hidden`,r),onWheel:it,children:(0,B.jsx)(ie,{className:k(`w-max min-w-full`,n),children:e})})})}function rt({children:e}){return(0,B.jsx)(nt,{className:`h-8`,contentClassName:`h-full`,viewportClassName:`h-full`,children:e})}function it(e){let t=e.currentTarget,n=t.scrollWidth-t.clientWidth;if(n<=0)return;let r=Math.abs(e.deltaX)>Math.abs(e.deltaY)?e.deltaX:e.deltaY;if(r===0)return;let i=Math.max(0,Math.min(n,t.scrollLeft+r));i!==t.scrollLeft&&(e.preventDefault(),t.scrollLeft=i)}function at({activeTab:e,onClearSelection:t,selectedNode:n,setActiveTab:r,story:i}){let a=n,o=a.parentId?i.nodes.find(e=>e.id===a.parentId):null,s=Ct(i,a),c=i.nodes.filter(e=>e.parentId===a.id).length,l=Ge(i,a);return(0,B.jsxs)(`aside`,{className:`grid h-full min-h-0 w-full min-w-0 max-w-full grid-rows-[auto_auto_auto_minmax(0,1fr)] overflow-hidden bg-(--bg-panel-header)`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 overflow-hidden border-b border-(--line) bg-(--bg-panel)`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2 px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`mb-1 flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[(0,B.jsx)(`span`,{className:k(`shrink-0 rounded-xs border px-1.5 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-[0.08em]`,`border-(--line) bg-(--bg-control) text-(--accent)`),children:U(a)}),(0,B.jsx)(`span`,{className:`min-w-0 truncate rounded-xs border px-1.5 py-0.5 font-mono text-[10px] font-medium uppercase tracking-wide`,style:{backgroundColor:`${M(a.service)}14`,borderColor:`${M(a.service)}28`,color:M(a.service)},children:a.service})]}),(0,B.jsx)(`h2`,{className:`truncate font-mono text-sm font-semibold leading-tight text-(--fg-primary)`,children:a.name})]}),(0,B.jsx)(`button`,{"aria-label":`Clear inspector selection`,className:`grid size-6 shrink-0 place-items-center rounded-xs border border-(--line) bg-(--bg-control) text-(--fg-tertiary) transition hover:text-(--fg-primary)`,onClick:t,type:`button`,children:(0,B.jsx)(v,{size:13})})]}),(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2 overflow-hidden border-t border-(--line) px-3 py-1.5 font-mono text-[11px] text-(--fg-tertiary)`,children:[(0,B.jsxs)(`button`,{className:`group flex min-w-10.5 flex-1 items-center gap-1 overflow-hidden text-left transition hover:text-(--fg-secondary)`,type:`button`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:a.id.slice(0,16)}),(0,B.jsx)(te,{className:`size-2.5 shrink-0 opacity-0 transition group-hover:opacity-100`})]}),(0,B.jsx)(`span`,{className:`shrink-0 text-(--accent)`,children:P(a.durationMs)}),(0,B.jsx)(Ae,{className:`shrink-0`,status:a.status,variant:`label`}),(0,B.jsxs)(`span`,{className:`min-w-0 truncate`,children:[c,` children`]})]})]}),(0,B.jsx)(`div`,{className:`min-w-0 overflow-hidden border-b border-(--line) bg-(--bg-canvas) px-3 py-1.5`,children:(0,B.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(0,1fr)_auto] items-center gap-2 font-mono text-[11px] text-(--fg-tertiary)`,children:[(0,B.jsx)(nt,{className:`h-5`,contentClassName:`h-full`,viewportClassName:`h-full`,children:(0,B.jsxs)(`div`,{className:`flex h-full w-max min-w-full items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`shrink-0 text-(--fg-quaternary)`,children:`path`}),s.map((e,t)=>(0,B.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[t>0?(0,B.jsx)(b,{className:`size-3 shrink-0 text-(--fg-quaternary)`}):null,(0,B.jsx)(`span`,{className:k(e.id===a.id?`text-(--fg-primary)`:`text-(--fg-secondary)`),title:e.name,children:e.name})]},e.id))]})}),o?(0,B.jsx)(`span`,{className:`shrink-0 text-(--fg-tertiary)`,children:P(o.durationMs)}):null]})}),(0,B.jsx)(`div`,{className:`min-w-0 overflow-hidden border-b border-(--line) bg-(--bg-panel-muted)`,children:(0,B.jsx)(rt,{children:(0,B.jsx)(`div`,{className:`flex h-full w-max min-w-full items-stretch pr-10`,children:Re.map(t=>(0,B.jsxs)(`button`,{className:k(`inline-flex h-full shrink-0 items-center gap-1.5 whitespace-nowrap border-b border-transparent px-2 font-mono text-[10px] font-semibold uppercase tracking-[0.06em] text-(--fg-tertiary) transition hover:border-(--border) hover:text-(--fg-secondary) disabled:text-(--fg-quaternary)`,e===t.id&&`border-(--line-strong) bg-(--bg-row-hover) text-(--fg-primary)`),onClick:()=>r(t.id),type:`button`,children:[(0,B.jsx)(`span`,{children:t.label}),l[t.id]>0?(0,B.jsx)(`span`,{className:k(`grid h-4.5 min-w-4.5 place-items-center border px-1 font-mono text-[10px] leading-none shadow-[inset_0_1px_0_rgba(255,255,255,0.03)]`,e===t.id?`border-[var(--tone-info-border)] bg-[var(--tone-info-bg)] text-(--tone-info-fg)`:`border-(--line) bg-(--bg-canvas) text-(--fg-tertiary)`),children:l[t.id]}):null]},t.id))})})}),(0,B.jsx)(`div`,{className:`min-h-0 min-w-0 overflow-auto bg-(--bg-canvas)`,children:(0,B.jsx)(ot,{activeTab:e,node:a,story:i})})]})}function ot({activeTab:e,node:t,story:n}){let{openRemoteCalls:r,openRetry:i}=_e(),a=le(n,t.id,e===`payload`),o=fe(n,t.id,e===`logs`),s=Ce(t.id),c=Se(n.correlationId);if(e===`overview`){let e=N(t),a=Ue(t);return(0,B.jsxs)(`div`,{className:`font-mono text-xs`,children:[(0,B.jsx)(st,{node:t,story:n}),(0,B.jsx)(V,{rows:[[`display name`,t.name],[`execution name`,t.canonicalName??t.name],[`execution type`,U(t)],[`status`,t.status],[`duration`,P(t.durationMs)],[`start time`,P(t.startMs)],[`completion time`,P(t.startMs+t.durationMs)],[`retry count`,Math.max(0,(t.attempts??1)-1)],[`attempt`,`${t.attempts??1}/${t.maxAttempts??1}`],[`parent count`,wt(n,t)],[`child count`,Tt(n,t)],[`service`,t.service]]}),a?(0,B.jsx)(ct,{detail:a,onOpenRemoteCalls:()=>r(n.correlationId)}):null,e?(0,B.jsx)(`div`,{className:`border-b border-(--line) px-3 py-2`,children:(0,B.jsxs)(`button`,{className:`inline-flex h-8 w-fit items-center gap-2 rounded-xs border border-[var(--tone-error-border)] bg-[var(--tone-error-bg)] px-2 font-mono text-[11px] text-(--tone-error-fg)`,onClick:()=>i(e),type:`button`,children:[(0,B.jsx)(l,{size:12}),`Retry execution`]})}):null]})}if(e===`activity`)return(0,B.jsx)(pt,{activity:Ve(n,t)});if(e===`payload`)return(0,B.jsx)(ht,{error:a.error,isError:a.isError,isLoading:a.isLoading,payload:a.data});if(e===`failures`)return(0,B.jsx)(mt,{failures:He(t),node:t});if(e===`logs`)return(0,B.jsx)(gt,{error:o.error,isError:o.isError,isLoading:o.isLoading,logs:o.data??[],story:n});if(e===`context`){let e=We(n,t);return(0,B.jsxs)(`div`,{className:`grid min-w-full`,children:[(0,B.jsx)(V,{rows:e.rows}),(0,B.jsx)(xt,{label:`upstream references`,nodes:e.upstream}),(0,B.jsx)(xt,{label:`downstream references`,nodes:e.downstream}),(0,B.jsx)(j,{defaultExpanded:!0,title:`execution context`,value:{attributes:t.attributes,context:t.context}})]})}return(0,B.jsx)(lt,{executionOperations:s.data??[],error:s.error??c.error,isError:s.isError||c.isError,isLoading:s.isLoading||c.isLoading,node:t,story:n,storyOperations:c.data??[]})}function st({node:e,story:t}){return(0,B.jsx)(`div`,{className:`border-b border-(--line) bg-(--bg-panel-muted) p-3`,children:(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2`,children:[(0,B.jsx)(`span`,{className:`mt-1 size-2 shrink-0 rounded-xs`,style:{backgroundColor:M(e.service)}}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`truncate text-[13px] font-semibold text-(--fg-primary)`,children:e.name}),(0,B.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-1.5 text-[11px] text-(--fg-tertiary)`,children:[(0,B.jsx)(`span`,{children:U(e)}),(0,B.jsx)(`span`,{children:`·`}),(0,B.jsx)(`span`,{children:e.status}),(0,B.jsx)(`span`,{children:`·`}),(0,B.jsx)(`span`,{children:P(e.durationMs)})]}),(0,B.jsx)(`div`,{className:`mt-2 truncate text-[11px] text-(--fg-quaternary)`,children:t.correlationId})]})]})})}function ct({detail:e,onOpenRemoteCalls:t}){return e?(0,B.jsxs)(`section`,{className:`grid min-w-full border-b border-(--line)`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 bg-(--bg-panel-header) px-3 py-1.5 font-mono text-[11px] text-(--fg-tertiary)`,children:[(0,B.jsx)(`span`,{children:`remote proxy`}),(0,B.jsxs)(`button`,{className:`ml-auto inline-flex h-5 items-center gap-1 border border-(--line) bg-(--bg-control) px-1.5 text-[10px] text-(--fg-secondary) hover:text-(--fg-primary)`,onClick:t,type:`button`,children:[(0,B.jsx)(d,{size:11}),`Remote Calls`]})]}),(0,B.jsx)(V,{rows:e.rows}),bt(e.pathParams)?(0,B.jsx)(j,{title:`path params`,value:e.pathParams}):null,bt(e.errorDetails)?(0,B.jsx)(j,{title:`error details`,value:e.errorDetails}):null]}):null}function lt({executionOperations:e,error:t,isError:n,isLoading:r,node:i,story:a,storyOperations:o}){let s=ke({executionOperations:e,selectedNodeId:i.id,storyOperations:o,storyTimestamp:a.timestamp});return s.length===0||r||n?(0,B.jsx)(`div`,{className:`grid min-w-full`,children:(0,B.jsx)(H,{label:De({error:t,isError:n,isLoading:r})})}):(0,B.jsx)(`div`,{className:`grid min-w-full`,children:s.map(e=>(0,B.jsx)(ut,{group:e},e.id))})}function ut({group:e}){return(0,B.jsxs)(`section`,{className:`border-b border-(--line)`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 bg-(--bg-panel-header) px-3 py-1.5 font-mono text-[11px] text-(--fg-tertiary)`,children:[(0,B.jsx)(`span`,{children:e.label}),(0,B.jsx)(`span`,{className:`rounded-xs border border-(--line) bg-(--bg-canvas) px-1.5 py-0.5 text-[10px] text-(--fg-tertiary)`,children:e.operations.length})]}),e.operations.map(e=>(0,B.jsx)(dt,{operation:e},e.id))]})}function dt({operation:e}){let{openAdminActions:t,openRemoteCalls:n}=_e(),r=ye(e);return(0,B.jsxs)(`div`,{className:`border-t border-(--line) bg-(--bg-canvas)`,children:[(0,B.jsxs)(`div`,{className:`grid min-w-full grid-cols-[72px_82px_minmax(180px,1fr)_72px_64px_58px_24px] items-start gap-2 px-3 py-2 font-mono text-xs`,children:[(0,B.jsx)(`span`,{className:`w-fit rounded-xs border border-(--line) bg-(--bg-control) px-1.5 py-0.5 text-[10px] font-semibold uppercase text-(--accent)`,children:e.category}),(0,B.jsx)(`span`,{className:k(`w-fit rounded-xs border px-1.5 py-0.5 text-[10px] font-semibold uppercase`,ft(e)),children:e.sourceLabel}),(0,B.jsxs)(`div`,{className:`min-w-0`,children:[(0,B.jsx)(`div`,{className:`truncate text-(--fg-primary)`,title:e.name,children:e.name}),e.summary?(0,B.jsx)(`div`,{className:`mt-1 truncate text-[11px] text-(--fg-tertiary)`,title:e.summary,children:e.summary}):null]}),(0,B.jsx)(`span`,{className:k(`text-[11px] leading-5`,e.status===`error`?`text-(--tone-error-fg)`:`text-(--fg-tertiary)`),children:e.status}),(0,B.jsx)(`span`,{className:`text-right text-[11px] leading-5 text-(--fg-tertiary)`,children:P(e.durationMs)}),(0,B.jsxs)(`span`,{className:`text-right text-[11px] leading-5 text-(--fg-tertiary)`,children:[`+`,P(e.relativeStartMs)]}),r?(0,B.jsx)(`button`,{"aria-label":`Open ${e.sourceLabel} operations`,className:`grid size-5 place-items-center rounded-xs border border-(--line) bg-(--bg-control) text-(--fg-tertiary) hover:text-(--fg-primary)`,onClick:()=>{if(r.kind===`remote_calls`){n(r.correlationId,r.selectedId);return}t(r.correlationId,r.selectedId)},title:`Open ${e.sourceLabel} operations`,type:`button`,children:(0,B.jsx)(g,{size:11})}):(0,B.jsx)(`span`,{})]}),(0,B.jsx)(j,{title:`safe attributes`,value:e.safeAttributes})]})}function ft(e){return e.source===`remote_proxy`?`tint tint-warning`:e.source===`remote_runtime`||e.source===`admin_action`?`tint tint-info`:`border-(--line) bg-(--bg-control) text-(--fg-tertiary)`}function V({rows:e}){return e.length===0?(0,B.jsx)(H,{label:`No execution details recorded`}):(0,B.jsx)(`div`,{className:`w-max min-w-full border-b border-(--line) font-mono text-xs`,children:e.map(([e,t])=>(0,B.jsxs)(`div`,{className:`grid w-max min-w-full grid-cols-[124px_minmax(220px,max-content)] border-b border-(--line) last:border-b-0`,children:[(0,B.jsx)(`div`,{className:`bg-(--bg-panel-header) px-3 py-1.5 text-(--fg-tertiary)`,children:e}),(0,B.jsx)(`div`,{className:`whitespace-pre-wrap px-3 py-1.5 text-(--fg-secondary)`,children:St(t)})]},e))})}function pt({activity:e}){return e.length===0?(0,B.jsx)(H,{label:`No activity recorded`}):(0,B.jsx)(`div`,{className:`w-max min-w-full font-mono text-xs`,children:e.map(e=>(0,B.jsxs)(`div`,{className:`grid w-max min-w-full grid-cols-[58px_minmax(220px,max-content)] gap-2 border-b border-(--line) px-3 py-2`,children:[(0,B.jsxs)(`span`,{className:`whitespace-nowrap text-(--fg-tertiary)`,children:[`+`,P(e.timestampMs)]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`div`,{className:`whitespace-nowrap text-(--fg-primary)`,children:e.label}),(0,B.jsx)(`div`,{className:`whitespace-nowrap text-[11px] text-(--fg-tertiary)`,children:e.detail??`${e.kind} · ${e.status}`})]})]},e.id))})}function mt({failures:e,node:t}){return e.length===0?(0,B.jsx)(H,{label:`No failures recorded`}):(0,B.jsxs)(`div`,{className:`grid min-w-full`,children:[(0,B.jsx)(V,{rows:e.map(e=>[e.label,e.value])}),(0,B.jsx)(V,{rows:[[`dead letter state`,t.status===`dead`?`dead`:`-`],[`retryability`,t.retryable?`retryable`:`not retryable`],[`failure timeline`,t.logs.join(`
`)||`-`]]})]})}function ht({error:e,isError:t,isLoading:n,payload:r}){if(n)return(0,B.jsx)(H,{label:`Loading captured execution payload...`});if(t)return(0,B.jsx)(H,{label:`Execution payload could not be loaded. ${yt(e)}`});let i=[[`Input`,r?.input],[`Output`,r?.output],[`Metadata`,r?.metadata]].filter(([,e])=>bt(e));return i.length===0?(0,B.jsx)(H,{label:`No payload captured for this execution. Story details stay lightweight; payload is only available for runtime records that persisted it.`}):(0,B.jsxs)(`div`,{className:`grid min-w-full`,children:[r&&r.redactedFields.length>0?(0,B.jsxs)(`div`,{className:`border-b border-(--line) tint-soft tint-warning px-3 py-2 font-mono text-[11px] leading-5 tint-text`,children:[`Redacted `,r.redactedFields.length,` sensitive field`,r.redactedFields.length===1?``:`s`,`:`,` `,r.redactedFields.join(`, `)]}):null,i.map(([e,t],n)=>(0,B.jsx)(j,{defaultExpanded:n===0,title:e,value:t},e))]})}function gt({error:e,isError:t,isLoading:n,logs:r,story:i}){return n?(0,B.jsx)(H,{label:`Loading execution logs...`}):t?(0,B.jsx)(H,{label:`Execution logs could not be loaded. ${yt(e)}`}):r.length===0?(0,B.jsx)(H,{label:`No runtime logs recorded for this execution yet. Runtime lifecycle logs are recorded for work processed after execution logging was enabled.`}):(0,B.jsx)(`div`,{className:`w-max min-w-full font-mono text-xs`,children:r.map(e=>(0,B.jsxs)(`div`,{className:`grid w-max min-w-full grid-cols-[58px_58px_minmax(220px,max-content)_minmax(180px,max-content)] gap-2 border-b border-(--line) px-3 py-1.5`,children:[(0,B.jsxs)(`span`,{className:`whitespace-nowrap text-(--fg-tertiary)`,children:[`+`,P(_t(i.timestamp,e.occurredAt))]}),(0,B.jsx)(`span`,{className:k(`uppercase`,vt(e.severity)),children:e.severity}),(0,B.jsx)(`span`,{className:`whitespace-nowrap text-(--fg-secondary)`,children:e.body||`-`}),(0,B.jsxs)(`span`,{className:`whitespace-nowrap text-[11px] text-(--fg-tertiary)`,children:[e.serviceName,e.traceId?` · trace ${e.traceId.slice(0,12)}`:``]}),Object.keys(e.attributes).length>0||e.redactedFields.length>0?(0,B.jsx)(`div`,{className:`col-span-4 -mx-3 mt-1 border-t border-(--line)`,children:(0,B.jsx)(j,{title:e.redactedFields.length>0?`attributes · redacted ${e.redactedFields.length}`:`attributes`,value:{attributes:e.attributes,...e.redactedFields.length>0?{redacted_fields:e.redactedFields}:{},...e.spanId?{span_id:e.spanId}:{},...e.traceId?{trace_id:e.traceId}:{}}})}):null]},e.id))})}function _t(e,t){let n=Date.parse(e),r=Date.parse(t);return Number.isFinite(n)&&Number.isFinite(r)?Math.max(0,r-n):0}function vt(e){switch(e){case`error`:return`text-(--tone-error-fg)`;case`warn`:return`tint-text tint-warning`;case`debug`:case`trace`:return`text-(--fg-tertiary)`;default:return`text-(--tone-success-fg)`}}function H({label:e}){return(0,B.jsx)(`div`,{className:`p-4 font-mono text-xs text-(--fg-tertiary)`,children:e})}function yt(e){return e instanceof Error?e.message:`Unknown error`}function bt(e){return e==null?!1:Array.isArray(e)?e.length>0:typeof e==`object`?Object.keys(e).length>0:!0}function xt({label:e,nodes:t}){return(0,B.jsxs)(`div`,{className:`w-max min-w-full border-b border-(--line) font-mono text-xs`,children:[(0,B.jsx)(`div`,{className:`bg-(--bg-panel-header) px-3 py-1.5 text-(--fg-tertiary)`,children:e}),t.length===0?(0,B.jsx)(`div`,{className:`border-t border-(--line) px-3 py-1.5 text-(--fg-tertiary)`,children:`None`}):t.map(e=>(0,B.jsxs)(`div`,{className:`grid w-max min-w-full grid-cols-[124px_minmax(220px,max-content)] border-t border-(--line)`,children:[(0,B.jsx)(`div`,{className:`px-3 py-1.5 text-(--fg-tertiary)`,children:U(e)}),(0,B.jsx)(`div`,{className:`whitespace-pre-wrap px-3 py-1.5 text-(--fg-secondary)`,children:e.name})]},e.id))]})}function St(e){return typeof e==`string`?e:e==null?`-`:typeof e==`number`||typeof e==`boolean`?String(e):JSON.stringify(e)}function Ct(e,t){let n=[],r=new Map(e.nodes.map(e=>[e.id,e])),i=t;for(;i;){n.unshift(i);let e=i.parentId;i=e?r.get(e):void 0}return n}function U(e){return e.kind===`external`?`provider`:e.kind===`function`?`function`:e.kind===`http`?`http`:e.kind===`event`?`outbox`:`node`}function wt(e,t){return e.nodes.filter(e=>e.id===t.parentId).length}function Tt(e,t){return e.nodes.filter(e=>e.parentId===t.id).length}function Et(e){let t=new Map,n=new Set(e.map(e=>e.id));e.forEach(e=>{let n=t.get(e.parentId)??[];n.push(e),t.set(e.parentId,n)});let r=[],i=(e,n)=>{r[n]=[...r[n]??[],e],(t.get(e.id)??[]).forEach(e=>i(e,n+1))};return e.filter(e=>!e.parentId||!n.has(e.parentId)).sort(Dt).forEach(e=>i(e,0)),r}function Dt(e,t){return e.startMs-t.startMs||e.name.localeCompare(t.name)}var Ot=`flex min-w-0 items-center justify-between gap-3 overflow-hidden border-b border-(--line) bg-(--bg-panel-header) px-3 py-2`,kt=`flex min-w-0 items-center gap-2 overflow-hidden`,At=`font-sans text-[11px] font-semibold uppercase tracking-[0.04em] text-(--fg-tertiary)`,jt=`min-w-0 truncate font-mono text-[11px] text-(--fg-tertiary)`,Mt=`shrink-0 font-mono text-[11px] text-(--fg-tertiary)`;function W({children:e,title:t,summary:n,meta:r}){return(0,B.jsxs)(`div`,{className:Ot,children:[(0,B.jsxs)(`div`,{className:kt,children:[(0,B.jsx)(`span`,{className:At,children:t}),n?(0,B.jsx)(`span`,{className:jt,children:n}):null]}),r?(0,B.jsx)(`div`,{className:Mt,children:r}):null,e?(0,B.jsx)(`div`,{className:Mt,children:e}):null]})}function Nt({selectedNodeId:e,story:t,onSelectNode:n}){let r=Et(t.nodes),i=Oe(t);return(0,B.jsxs)(`div`,{className:`isolate flex h-full min-w-0 flex-col overflow-hidden bg-(--bg-canvas)`,children:[(0,B.jsx)(W,{meta:P(i),summary:`color by service and status`,title:`Flame`}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:r.map(t=>(0,B.jsx)(`div`,{className:`relative isolate h-9 overflow-hidden border-b border-[color-mix(in_srgb,var(--line)_60%,transparent)]`,children:t.map(t=>{let r=F({durationMs:t.durationMs,minWidthPercent:3,startMs:t.startMs,timelineEnd:i});return(0,B.jsx)(`button`,{className:k(`absolute top-1 h-7 overflow-hidden rounded-xs border px-2 text-left font-mono text-[12px] text-(--fg-primary) transition hover:brightness-125`,e===t.id&&`shadow-[0_0_0_1px_var(--line-strong)]`),onClick:()=>n(t),style:{backgroundColor:t.status===`failed`||t.status===`dead`?`var(--error)`:`${M(t.service)}cc`,borderColor:t.status===`failed`||t.status===`dead`?`var(--error)`:`${M(t.service)}99`,left:`${r.left}%`,width:`${r.width}%`},type:`button`,children:(0,B.jsxs)(`span`,{className:`truncate`,children:[t.name,` · `,P(t.durationMs)]})},t.id)})},t.map(e=>e.id).join(`:`)))})]})}var G=e(t(),1);function Pt(e){let t=e.nodes.flatMap(e=>{let t=Ft(e);if(!t)return[];let n=zt(e);return[{...n?{error:n}:{},...e.parentId?{parentId:e.parentId}:{},duration:e.durationMs,id:e.id,name:Rt(e,t),service:e.service,node:e,status:e.status,timestamp:e.startMs,type:t,typeLabel:K(t)}]}),n=Array.from(new Set(e.nodes.map(e=>e.service))),r=Vt(t.map(e=>e.type)),i=Bt(t);return{...i?{rootError:i}:{},correlationId:e.correlationId,duration:e.durationMs,errorCount:e.nodes.filter(Ht).length,id:e.correlationId,nodeCount:t.length,nodes:t,pattern:r,patternLabel:r.map(K).join(` -> `),services:n,status:e.status,title:Lt(e,t)}}function Ft(e){return e.kind===`http`?`request`:e.kind===`command`||e.kind===`function`?`function`:e.kind===`event`?`event`:e.kind===`handler`||e.kind===`runtime`?`worker`:e.kind===`external`?`external`:null}function K(e){switch(e){case`request`:return`Request`;case`function`:return`Function`;case`event`:return`Outbox`;case`worker`:return`Worker`;case`external`:return`External`;default:return e}}function It(e){return e===`dead`?`dead`:e===`failed`?`failed`:e===`pending`||e===`processing`?`retrying`:e===`running`?`running`:`success`}function Lt(e,t){let n=t[0]?.node??e.nodes[0];return n?.kind===`http`&&n.name.includes(`/identity/users`)?`User Registration`:e.name.includes(`object_uploaded`)?`File Upload`:e.name.includes(`cleanup_expired_sessions`)?`Session Cleanup`:Ut(e.name)}function Rt(e,t){return t===`external`&&Ht(e)&&zt(e)?.toLowerCase().includes(`smtp`)?`smtp.provider`:Ut(e.name)}function zt(e){if(!Ht(e))return;let t=e.logs.at(-1);return t?.toLowerCase().includes(`smtp`)?`smtp timeout`:t||`${e.status} runtime work`}function Bt(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.error)return n.error}}function Vt(e){return e.filter((t,n)=>n===0||e[n-1]!==t)}function Ht(e){let t=typeof e==`string`?e:e.status;return t===`failed`||t===`dead`}function Ut(e){return e.replace(/\.v\d+$/u,``)}var q={fitPadding:128,maxZoom:1.8,minZoom:.55,zoomStep:.15};function Wt(e){return Math.min(q.maxZoom,Math.max(q.minZoom,Xt(e)))}function Gt({canvasHeight:e,canvasWidth:t,viewportHeight:n,viewportWidth:r}){let i=Math.max(1,r-q.fitPadding),a=Math.max(1,n-q.fitPadding);return Wt(Math.min(i/t,a/e))}function Kt({canvasHeight:e,canvasWidth:t,viewportHeight:n,viewportWidth:r,zoom:i}){let a=Math.round(r/2),o=Math.round(n/2),s=t*i,c=e*i;return{marginLeft:a,marginTop:o,scaledCanvasHeight:c,scaledCanvasWidth:s,workspaceHeight:Math.round(c+o*2),workspaceWidth:Math.round(s+a*2)}}function qt({bounds:e,marginLeft:t,marginTop:n,viewportHeight:r,viewportWidth:i,zoom:a}){return{scrollLeft:Math.max(0,J(t+(e.x+e.width/2)*a-i/2)),scrollTop:Math.max(0,J(n+(e.y+e.height/2)*a-r/2))}}function Jt(e,t=240,n=72){if(e.length===0)return{height:n,width:t,x:0,y:0};let r=Math.min(...e.map(e=>e.x)),i=Math.min(...e.map(e=>e.y)),a=Math.max(...e.map(e=>e.x+t));return{height:Math.max(...e.map(e=>e.y+n))-i,width:a-r,x:r,y:i}}function Yt({currentZoom:e,nextZoom:t,pointerX:n,pointerY:r,scrollLeft:i,scrollTop:a}){let o=Wt(t),s=o/e;return{scrollLeft:J((i+n)*s-n),scrollTop:J((a+r)*s-r),zoom:o}}function J(e){return Math.round(e)}function Xt(e){return Math.round(e*100)/100}var Zt=350;function Y(e){let t=$t(e,new Map(e.nodes.map(e=>[e.id,e]))),n=[];for(let[e,r]of t){let t=[...r].sort(tn);for(let r of en(t,Zt)){let t=r.filter(e=>r.some(t=>t.id!==e.id&&nn(e,t)));if(t.length<2)continue;let[i]=[...t].sort((e,t)=>t.durationMs-e.durationMs||t.startMs+t.durationMs-(e.startMs+e.durationMs)||e.name.localeCompare(t.name));if(!i)continue;let a=Math.min(...t.map(e=>e.startMs));n.push({branchCount:t.length,childIds:t.map(e=>e.id),id:`parallel:${e}:${a}`,longestBranchId:i.id,longestBranchName:i.name,parentId:e,startMs:a})}}return n.sort((e,t)=>e.startMs-t.startMs||e.parentId.localeCompare(t.parentId))}function Qt(e){return Y(e).map(e=>({branchCount:e.branchCount,firstNodeId:e.childIds[0],id:e.id,label:`${e.branchCount} parallel executions started`,parentId:e.parentId,startMs:e.startMs}))}function $t(e,t){let n=new Map;if(e.edges!==void 0){for(let r of e.edges){let e=t.get(r.target);!e||!t.has(r.source)||n.set(r.source,[...n.get(r.source)??[],e])}return n}for(let r of e.nodes)!r.parentId||!t.has(r.parentId)||n.set(r.parentId,[...n.get(r.parentId)??[],r]);return n}function en(e,t){let n=[],r=[],i=0;for(let a of e){if(r.length===0){r=[a],i=a.startMs;continue}if(a.startMs-i<=t){r.push(a);continue}n.push(r),r=[a],i=a.startMs}return r.length>0&&n.push(r),n}function tn(e,t){return e.startMs-t.startMs||e.name.localeCompare(t.name)}function nn(e,t){return e.startMs<t.startMs+t.durationMs&&t.startMs<e.startMs+e.durationMs}function rn(e){return e.edges===void 0?{edges:on(e.nodes),source:`derived`,state:e.nodes.length===0?`empty-nodes`:`ready`}:{edges:e.edges,source:`backend`,state:e.nodes.length>0&&e.edges.length===0?`missing-edges`:`ready`}}function an(e){let t=rn(e),n=sn(e.nodes,t.edges),r=new Map(e.nodes.map(e=>[e.id,e])),i=new Map,a=new Map;for(let e of t.edges){let t=r.get(e.source),n=r.get(e.target);!t||!n||a.has(n.id)||(a.set(n.id,t.id),i.set(t.id,[...i.get(t.id)??[],n]))}for(let e of i.values())e.sort(cn);let o=new Set;for(let[e,t]of i){o.add(e);for(let e of t)o.add(e.id)}let s=e.nodes.filter(e=>o.has(e.id)&&!a.has(e.id)).sort(cn),c=[],l=new Set,u=e=>{if(l.has(e.id))return;l.add(e.id);let t=a.get(e.id);c.push({depth:n.get(e.id)??0,node:e,...t===void 0?{}:{parentId:t},row:c.length});for(let t of i.get(e.id)??[])u(t)};for(let e of s)u(e);for(let t of e.nodes.filter(e=>!l.has(e.id)).sort(cn)){let e=a.get(t.id);c.push({depth:n.get(t.id)??0,node:t,...e===void 0?{}:{parentId:e},row:c.length})}return{edges:t.edges,nodes:c}}function on(e){return e.filter(e=>!!e.parentId).map(e=>({id:`${e.parentId}:${e.id}:parent`,source:e.parentId,target:e.id,type:`sequence`}))}function sn(e,t){let n=new Map;for(let e of t)n.set(e.target,[...n.get(e.target)??[],e.source]);let r=new Map,i=(e,t=new Set)=>{if(r.has(e))return r.get(e);if(t.has(e))return 0;let a=new Set(t).add(e),o=n.get(e)??[],s=o.length===0?0:Math.max(...o.map(e=>i(e,a)))+1;return r.set(e,s),s};for(let t of e)i(t.id);return r}function cn(e,t){return e.startMs-t.startMs||e.name.localeCompare(t.name)}var ln=240,un=72,dn=280,fn=92,pn=64,mn=140,hn=100;function gn({selectedNodeId:e,story:t,onSelectNode:n}){let r=(0,G.useRef)(null),i=(0,G.useRef)(null),a=(0,G.useRef)(!1),s=(0,G.useRef)(null),[c,l]=(0,G.useState)(!1),[u,d]=(0,G.useState)({height:0,width:0}),[f,p]=(0,G.useState)(1),m=(0,G.useMemo)(()=>rn(t),[t]),{edges:te}=m,h=(0,G.useMemo)(()=>an(t),[t]),g=(0,G.useMemo)(()=>Y(t),[t]),_=(0,G.useMemo)(()=>new Map(g.map(e=>[e.parentId,e])),[g]),ne=(0,G.useMemo)(()=>new Map(g.flatMap(e=>e.childIds.map(t=>[t,e]))),[g]),v=(0,G.useMemo)(()=>h.nodes.map(e=>({fanoutGroup:_.get(e.node.id),node:e.node,parallelGroup:ne.get(e.node.id),parentId:e.parentId,x:e.depth*dn,y:e.row*fn})),[h.nodes,ne,_]),y=(0,G.useMemo)(()=>new Map(v.map(e=>[e.node.id,e])),[v]),b=(0,G.useMemo)(()=>Jt(v,ln,un),[v]),x=Math.max(980,Math.max(0,...v.map(e=>e.x+ln))+pn*2),S=Math.max(420,v.length*fn),C=Kt({canvasHeight:S,canvasWidth:x,viewportHeight:u.height,viewportWidth:u.width,zoom:f}),w=Math.min((mn-16)/x,(hn-16)/S),T=(0,G.useCallback)(e=>{let t=r.current;if(!t)return;let n=Kt({canvasHeight:S,canvasWidth:x,viewportHeight:t.clientHeight,viewportWidth:t.clientWidth,zoom:e}),i=qt({bounds:b,marginLeft:n.marginLeft,marginTop:n.marginTop,viewportHeight:t.clientHeight,viewportWidth:t.clientWidth,zoom:e});requestAnimationFrame(()=>{t.scrollTo({left:i.scrollLeft,top:i.scrollTop})})},[S,x,b]),E=(0,G.useCallback)(e=>{if(s.current?.disconnect(),s.current=null,r.current=e,!e)return;let t=()=>{d({height:e.clientHeight,width:e.clientWidth})},n=new ResizeObserver(t);t(),n.observe(e),s.current=n},[]);(0,G.useLayoutEffect)(()=>{a.current||u.height<=0||u.width<=0||(a.current=!0,T(f))},[T,u.height,u.width,f]);let D=(0,G.useCallback)(()=>{let e=r.current;if(!e)return;let t=Gt({canvasHeight:S,canvasWidth:x,viewportHeight:e.clientHeight,viewportWidth:e.clientWidth});p(t),T(t)},[S,x,T]),O=(0,G.useCallback)(e=>{let t=r.current;if(!t){p(t=>Wt(t+e));return}p(n=>{let r=Yt({currentZoom:n,nextZoom:n+e,pointerX:t.clientWidth/2,pointerY:t.clientHeight/2,scrollLeft:t.scrollLeft,scrollTop:t.scrollTop});return requestAnimationFrame(()=>{t.scrollTo({left:r.scrollLeft,top:r.scrollTop})}),r.zoom})},[]),re=e=>{if(!(e.metaKey||e.ctrlKey))return;e.preventDefault();let t=r.current;if(!t)return;let n=t.getBoundingClientRect();p(r=>{let i=Yt({currentZoom:r,nextZoom:r+(e.deltaY>0?-.08:.08),pointerX:e.clientX-n.left,pointerY:e.clientY-n.top,scrollLeft:t.scrollLeft,scrollTop:t.scrollTop});return requestAnimationFrame(()=>{t.scrollTo({left:i.scrollLeft,top:i.scrollTop})}),i.zoom})},ie=e=>{if(e.button!==0||e.target.closest(`button`))return;let t=r.current;t&&(i.current={pointerId:e.pointerId,scrollLeft:t.scrollLeft,scrollTop:t.scrollTop,x:e.clientX,y:e.clientY},t.setPointerCapture(e.pointerId),l(!0))},ae=e=>{let t=i.current,n=r.current;!t||!n||t.pointerId!==e.pointerId||(n.scrollLeft=t.scrollLeft-(e.clientX-t.x),n.scrollTop=t.scrollTop-(e.clientY-t.y))},oe=e=>{let t=r.current,n=i.current;t&&n?.pointerId===e.pointerId&&t.releasePointerCapture(e.pointerId),i.current=null,l(!1)};return(0,B.jsxs)(`div`,{className:`isolate relative h-full min-w-0 overflow-hidden bg-(--sidebar)`,children:[(0,B.jsx)(`div`,{className:`absolute top-0 right-0 left-0 z-2`,children:(0,B.jsx)(W,{summary:`${v.length} nodes · ${te.length} ${m.source===`backend`?`backend`:`derived`} edges · ${Math.round(f*100)}%`,title:`Execution Graph`,children:(0,B.jsxs)(`button`,{className:`flex items-center gap-1.5 transition hover:text-(--fg-primary)`,onClick:D,type:`button`,children:[(0,B.jsx)(ce,{size:12}),`Frame`]})})}),m.state===`missing-edges`?(0,B.jsx)(`div`,{className:`absolute top-12 left-1/2 z-3 w-[min(520px,calc(100%-32px))] -translate-x-1/2 border tint-border tint-warning bg-[color-mix(in_srgb,var(--bg-canvas)_92%,transparent)] p-3 font-mono text-[11px] tint-text shadow-(--elevation-overlay)`,children:`This story includes execution nodes, but the backend did not return graph edges.`}):null,m.state===`empty-nodes`?(0,B.jsx)(`div`,{className:`absolute inset-0 z-3 grid place-items-center p-4`,children:(0,B.jsx)(`div`,{className:`border border-(--line) bg-(--bg-panel) p-4 font-mono text-xs text-(--fg-tertiary)`,children:`This story does not include execution nodes yet.`})}):null,(0,B.jsx)(`div`,{className:k(`relative z-0 h-full overflow-auto`,c?`cursor-grabbing select-none`:`cursor-grab`),onPointerCancel:oe,onPointerDown:ie,onPointerMove:ae,onPointerUp:oe,onWheel:re,ref:E,children:(0,B.jsx)(`div`,{className:`relative`,style:{height:C.workspaceHeight,width:C.workspaceWidth},children:(0,B.jsxs)(`div`,{className:`absolute top-0 left-0`,style:{height:S,left:C.marginLeft,top:C.marginTop,transform:`scale(${f})`,transformOrigin:`top left`,width:x},children:[(0,B.jsxs)(`svg`,{"aria-label":`Story flow connectors`,className:`pointer-events-none absolute inset-0 size-full`,children:[(0,B.jsx)(`title`,{children:`Story flow connectors`}),te.map(e=>{let t=y.get(e.source),n=y.get(e.target);if(!t||!n)return null;let r=t.x+ln,i=t.y+un/2,a=n.x,o=n.y+un/2,s=(r+a)/2;return(0,B.jsx)(`path`,{d:`M ${r} ${i} C ${s} ${i}, ${s} ${o}, ${a} ${o}`,fill:`none`,opacity:`0.72`,stroke:`var(--fg-quaternary)`,strokeDasharray:e.type===`causation`?`none`:`6 4`,strokeWidth:`1.5`},e.id)})]}),v.map(({fanoutGroup:t,node:r,parallelGroup:i,x:a,y:o})=>{let s=M(r.service),c=e===r.id,l=r.status===`failed`||r.status===`dead`;return(0,B.jsxs)(`button`,{"aria-label":`Select graph node ${r.name}`,className:k(`absolute h-18 w-60 cursor-pointer rounded-sm border bg-(--bg-control) text-left transition hover:bg-(--bg-row-hover)`,c&&`border-(--line-strong) ring-1 ring-(--line-strong)`,!c&&l&&`border-[color-mix(in_srgb,var(--error)_45%,transparent)]`,!c&&!l&&`border-(--line) hover:border-(--fg-quaternary)`),onClick:()=>n(r),style:{left:a,top:o},type:`button`,children:[(0,B.jsx)(`span`,{className:`absolute top-0 right-0 left-0 h-0.75 rounded-t-sm`,style:{backgroundColor:s}}),(0,B.jsxs)(`span`,{className:`flex h-full flex-col justify-between px-3 pt-2.5 pb-2`,children:[(0,B.jsxs)(`span`,{className:`flex items-start justify-between gap-2`,children:[(0,B.jsx)(`span`,{className:`rounded-xs border px-1.5 py-0.5 font-mono text-[10px] font-bold uppercase tracking-[0.06em]`,style:{backgroundColor:`${s}18`,borderColor:`${s}30`,color:s},children:r.service}),(0,B.jsx)(`span`,{className:k(`rounded-xs px-1.5 py-0.5 font-mono text-[10px] uppercase tracking-[0.06em]`,l?`bg-[color-mix(in_srgb,var(--error)_10%,transparent)] text-(--error)`:`bg-(--bg-row-hover) text-(--fg-secondary)`),children:_n(r)})]}),(0,B.jsxs)(`span`,{className:`min-w-0`,children:[(0,B.jsx)(`span`,{className:`block truncate font-mono text-[13px] text-(--fg-primary)`,children:r.name}),(0,B.jsxs)(`span`,{className:`mt-1 flex min-w-0 items-center gap-1.5 font-mono text-[11px] text-(--fg-tertiary)`,children:[(0,B.jsx)(`span`,{children:P(r.durationMs)}),t?(0,B.jsxs)(`span`,{className:`shrink-0 rounded-xs px-1 py-0 text-[10px] tint tint-info`,children:[`fan-out `,t.branchCount]}):null,!t&&i?(0,B.jsx)(`span`,{className:`shrink-0 rounded-xs px-1 py-0 text-[10px] tint tint-info`,children:`parallel`}):null]})]})]}),l?(0,B.jsx)(`span`,{className:`absolute -top-1 -right-1 size-2.5 rounded-full border border-(--bg-control) bg-[var(--error)]`}):null]},r.id)})]})})}),(0,B.jsxs)(`div`,{className:`absolute bottom-10 left-4 z-2 flex flex-col gap-1`,children:[(0,B.jsx)(`button`,{"aria-label":`Zoom graph in`,className:`grid size-7 place-items-center rounded-xs border border-(--line) bg-(--bg-control) text-(--fg-secondary) transition hover:border-(--fg-quaternary) hover:text-(--fg-primary)`,onClick:()=>O(q.zoomStep),type:`button`,children:(0,B.jsx)(o,{size:14})}),(0,B.jsx)(`button`,{"aria-label":`Zoom graph out`,className:`grid size-7 place-items-center rounded-xs border border-(--line) bg-(--bg-control) text-(--fg-secondary) transition hover:border-(--fg-quaternary) hover:text-(--fg-primary)`,onClick:()=>O(-q.zoomStep),type:`button`,children:(0,B.jsx)(ee,{size:14})}),(0,B.jsx)(`button`,{"aria-label":`Frame graph`,className:`grid size-7 place-items-center rounded-xs border border-(--line) bg-(--bg-control) text-(--fg-secondary) transition hover:border-(--fg-quaternary) hover:text-(--fg-primary)`,onClick:D,type:`button`,children:(0,B.jsx)(ce,{size:14})})]}),(0,B.jsx)(`div`,{className:`absolute right-4 bottom-10 z-2 h-25 w-35 overflow-hidden rounded-xs border border-(--line) bg-(--bg-panel)`,children:(0,B.jsx)(`div`,{className:`absolute top-2 left-2`,style:{height:S,transform:`scale(${w})`,transformOrigin:`top left`,width:x},children:v.map(({node:t,x:n,y:r})=>(0,B.jsx)(`div`,{className:`absolute h-18 w-60 rounded-sm`,style:{backgroundColor:M(t.service),left:n,opacity:e===t.id?1:.45,top:r}},t.id))})}),(0,B.jsxs)(`div`,{className:`absolute bottom-2 left-1/2 z-2 flex -translate-x-1/2 items-center gap-4 rounded-xs border border-(--line) bg-(--bg-panel) px-3 py-1.5 font-mono text-[11px] text-(--fg-tertiary)`,children:[(0,B.jsx)(`span`,{children:`Select nodes`}),(0,B.jsxs)(`span`,{children:[Math.round(f*100),`%`]}),(0,B.jsx)(`span`,{children:`Ctrl wheel zoom`}),(0,B.jsx)(`span`,{children:`Drag canvas`})]})]})}function _n(e){let t=Ft(e);return t?K(t):`Node`}function vn({children:e,className:t}){return(0,B.jsx)(`div`,{className:k(`grid place-items-center gap-2 p-12 text-center text-(--fg-tertiary)`,t),children:e})}function yn({children:e}){return(0,B.jsx)(`div`,{className:`text-(--fg-tertiary)`,children:e})}function bn({children:e}){return(0,B.jsx)(`h2`,{className:`text-base font-semibold text-(--fg-primary)`,children:e})}function xn({children:e}){return(0,B.jsx)(`p`,{className:`max-w-md text-sm leading-6 text-(--fg-tertiary)`,children:e})}var X=Object.assign(vn,{Icon:yn,Title:bn,Description:xn});function Sn(e,t){return`${e.bucketStart}:${e.service}:${e.nodeType}:${t}`}function Cn({cell:e,story:t}){let n=Date.parse(e.bucketStart),r=Date.parse(e.bucketEnd),i=Date.parse(t.timestamp),a=Number.isFinite(n)&&Number.isFinite(r)&&Number.isFinite(i)&&r>n;return t.nodes.filter(t=>{if(t.service!==e.service||wn(t)!==e.nodeType)return!1;if(!a)return!0;let o=i+t.startMs;return o>=n&&o<r}).sort((e,t)=>e.startMs-t.startMs)}function wn(e){return e.kind===`event`?`event`:e.kind===`http`?`http`:`function`}function Tn({heatmap:e,loading:t,selectedNodeId:n,story:r,queryError:i,onSelectNode:a}){let[o,s]=(0,G.useState)(null),c=!!(r&&a),l=(0,G.useMemo)(()=>{if(!(e&&r&&o))return null;let t=e.cells.findIndex((e,t)=>Sn(e,t)===o),n=e.cells[t];return n?{cell:n,key:o,nodes:Cn({cell:n,story:r})}:null},[e,o,r]);if(t)return(0,B.jsxs)(`div`,{className:`isolate flex h-full min-w-0 flex-col overflow-hidden bg-(--bg-canvas)`,children:[(0,B.jsx)(W,{meta:`loading`,summary:`Backend runtime heatmap`,title:`Heatmap`}),(0,B.jsx)(`div`,{className:`grid grid-cols-[repeat(20,minmax(0,1fr))] gap-0.5 p-3`,children:Array.from({length:120},(e,t)=>(0,B.jsx)(`div`,{className:`aspect-5/4 rounded-[1px] border border-(--line) bg-(--bg-control)`},t))})]});if(i)return(0,B.jsxs)(`div`,{className:`isolate flex h-full min-w-0 flex-col overflow-hidden bg-(--bg-canvas)`,children:[(0,B.jsx)(W,{meta:`error`,summary:`Backend runtime heatmap`,title:`Heatmap`}),(0,B.jsxs)(X,{className:`h-full bg-(--bg-panel)`,children:[(0,B.jsx)(X.Title,{children:`Heatmap unavailable`}),(0,B.jsx)(X.Description,{children:i.message})]})]});if(!e||e.cells.length===0)return(0,B.jsxs)(`div`,{className:`isolate flex h-full min-w-0 flex-col overflow-hidden bg-(--bg-canvas)`,children:[(0,B.jsx)(W,{meta:e?`${e.bucketSeconds}s buckets`:`no data`,summary:`Backend runtime heatmap`,title:`Heatmap`}),(0,B.jsxs)(X,{className:`h-full bg-(--bg-panel)`,children:[(0,B.jsx)(X.Title,{children:`No runtime heatmap data`}),(0,B.jsx)(X.Description,{children:`The backend returned an empty heatmap for the current runtime window.`})]})]});let u=Math.max(1,...e.cells.map(e=>e.totalCount));return(0,B.jsxs)(`div`,{className:`isolate flex h-full min-w-0 flex-col overflow-hidden bg-(--bg-canvas)`,children:[(0,B.jsx)(W,{meta:`${e.bucketSeconds}s buckets`,summary:`${e.cells.length} backend cells`,title:`Heatmap`}),(0,B.jsxs)(`div`,{className:k(`grid min-h-0 flex-1 overflow-hidden`,c&&l?`grid-cols-[minmax(0,1fr)_minmax(0,280px)] max-xl:grid-cols-1`:`grid-cols-1`),children:[(0,B.jsx)(`div`,{className:`min-h-0 overflow-auto bg-(--bg-canvas) p-3`,children:(0,B.jsx)(`div`,{className:`grid grid-cols-[repeat(20,minmax(0,1fr))] gap-0.5`,children:e.cells.map((e,t)=>{let i=Sn(e,t),l=r===void 0?[]:Cn({cell:e,story:r}),d=i===o,f=c&&l.length===1,p=c&&l.length>1;return(0,B.jsxs)(`button`,{"aria-label":`${e.service} ${e.nodeType} heatmap cell with ${e.totalCount} executions`,className:k(`relative aspect-5/4 rounded-[1px] border border-(--line) transition hover:z-1 hover:border-(--fg-secondary) focus-visible:z-1 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-(--accent)`,Dn(e),d&&`border-(--line-strong)`,c?`cursor-pointer`:`cursor-default`),disabled:!c,onClick:()=>{if(c){if(l.length===1&&l[0]){a?.(l[0]),s(null);return}s(d?null:i)}},style:{opacity:Math.max(.28,e.totalCount/u)},title:`${e.service} · ${e.nodeType} · ${e.totalCount} executions`,type:`button`,children:[p?(0,B.jsx)(`span`,{className:`absolute right-0.5 bottom-0.5 rounded-[1px] bg-(--bg-canvas)/80 px-1 font-mono text-[9px] text-(--fg-primary)`,children:l.length}):null,f&&n&&n===l[0]?.id?(0,B.jsx)(`span`,{className:`absolute inset-1 border border-(--bg-canvas)`}):null]},i)})})}),c&&l?(0,B.jsx)(En,{selected:l,selectedNodeId:n??null,onClear:()=>s(null),onSelectNode:e=>a?.(e)}):null]})]})}function En({selected:e,selectedNodeId:t,onClear:n,onSelectNode:r}){return(0,B.jsxs)(`aside`,{className:`min-h-0 overflow-hidden border-l border-(--line) bg-(--bg-panel)`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-2 border-b border-(--line) px-3 py-2`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`truncate font-mono text-[11px] font-semibold text-(--fg-primary)`,children:[e.cell.service,` · `,e.cell.nodeType]}),(0,B.jsxs)(`div`,{className:`mt-0.5 truncate font-mono text-[10px] text-(--fg-tertiary)`,children:[e.cell.totalCount,` total · `,e.cell.errorCount,` errors`]})]}),(0,B.jsx)(we,{"aria-label":`Clear heatmap cell selection`,className:`size-7 p-0`,onClick:n,variant:`ghost`,children:(0,B.jsx)(v,{size:13})})]}),(0,B.jsx)(`div`,{className:`min-h-0 overflow-auto`,children:e.nodes.length===0?(0,B.jsx)(`div`,{className:`p-3 font-mono text-[11px] text-(--fg-tertiary)`,children:`No matching story nodes were found for this cell.`}):e.nodes.map(e=>(0,B.jsxs)(`button`,{"aria-label":`Open heatmap node ${e.name}`,className:k(`grid w-full min-w-0 gap-1 border-b border-(--line) px-3 py-2 text-left transition hover:bg-(--bg-row-hover)`,t===e.id&&`bg-(--bg-row-hover)`),onClick:()=>r(e),type:`button`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full`,style:{backgroundColor:A(e.status)}}),(0,B.jsx)(`span`,{className:`truncate text-[12px] font-semibold text-(--fg-primary)`,children:e.name})]}),(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2 font-mono text-[10px] text-(--fg-tertiary)`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:e.service}),(0,B.jsx)(`span`,{className:`ml-auto shrink-0`,children:P(e.durationMs)})]})]},e.id))})]})}function Dn(e){return e.errorCount>0||e.deadCount>0?`bg-(--error)`:e.avgDurationMs&&e.avgDurationMs>1e3?`bg-(--data-accent)`:e.avgDurationMs&&e.avgDurationMs>200?`bg-(--data-success)`:`bg-(--data-info)`}function On({selectedNodeId:e,story:t,onRetryNode:n,onSelectNode:r}){let i=Pt(t);return(0,B.jsxs)(`div`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden bg-(--bg-canvas)`,children:[(0,B.jsx)(W,{meta:`${i.nodeCount} nodes · ${P(i.duration)}`,summary:i.patternLabel||`No execution pattern`,title:`Runtime Story`}),(0,B.jsx)(`div`,{className:`min-h-0 overflow-auto px-4 py-4`,children:(0,B.jsxs)(`div`,{className:`mx-auto grid w-full max-w-4xl gap-2`,children:[i.nodes.length===0?(0,B.jsx)(`div`,{className:`border border-(--line) bg-(--bg-panel) p-4 font-mono text-xs text-(--fg-tertiary)`,children:`No runtime story nodes were derived for this story.`}):null,i.nodes.map((t,a)=>(0,B.jsx)(kn,{node:t,onRetry:()=>n(t),onSelect:()=>r(t.node),selected:e===t.node.id,showConnector:a<i.nodes.length-1},t.id))]})})]})}function kn({node:e,selected:t,showConnector:n,onRetry:r,onSelect:i}){let a=jn[e.type],o=Mn[It(e.status)],s=a.icon,c=o.icon,l=N(e.node)!==null;return(0,B.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[40px_minmax(0,1fr)] gap-3`,children:[(0,B.jsxs)(`div`,{className:`relative flex justify-center`,children:[(0,B.jsxs)(`span`,{className:k(`relative z-10 mt-1 grid size-9 place-items-center border bg-(--bg-panel)`,a.iconClass,t&&`ring-1 ring-(--line-strong)`),children:[(0,B.jsx)(s,{size:16,strokeWidth:1.8}),(0,B.jsx)(`span`,{className:k(`-right-1 -bottom-1 absolute grid size-4 place-items-center rounded-full border border-(--bg-canvas)`,o.badgeClass),title:o.label,children:(0,B.jsx)(c,{size:10,strokeWidth:2.2})})]}),n?(0,B.jsx)(`span`,{className:`absolute top-11 bottom-[-0.5rem] w-px bg-[linear-gradient(180deg,var(--line)_0%,var(--line)_100%)]`}):null]}),(0,B.jsxs)(`div`,{className:k(`group relative min-w-0 border bg-(--bg-panel) px-3 py-2.5 text-left shadow-(--elevation-raised) transition hover:border-(--line) hover:bg-(--bg-control)`,a.cardClass,t&&`border-(--line-strong) bg-(--bg-row-hover)`,(e.status===`failed`||e.status===`dead`)&&`shadow-[inset_0_0_0_1px_color-mix(in_srgb,var(--error)_20%,transparent),var(--elevation-raised)]`),children:[(0,B.jsx)(`button`,{"aria-label":`Select ${e.typeLabel} ${e.name}`,className:`absolute inset-0 z-0 cursor-pointer focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--focus-ring)`,onClick:i,type:`button`}),(0,B.jsxs)(`span`,{className:`flex min-w-0 items-start gap-3`,children:[(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:k(`shrink-0 border px-1.5 py-0.5 font-mono text-[10px] font-semibold uppercase tracking-[0.06em]`,a.labelClass),children:e.typeLabel}),(0,B.jsx)(`span`,{className:k(`font-mono text-[10px]`,o.textClass),children:o.label}),(0,B.jsx)(`span`,{className:`ml-auto shrink-0 font-mono text-[10px] text-(--fg-tertiary)`,children:P(e.duration)})]}),(0,B.jsx)(`span`,{className:`mt-1.5 block truncate text-[14px] font-semibold text-(--fg-primary)`,children:e.name}),(0,B.jsxs)(`span`,{className:`mt-1 flex min-w-0 items-center gap-2 font-mono text-[10px] text-(--fg-tertiary)`,children:[(0,B.jsx)(`span`,{className:`truncate`,children:e.service}),(0,B.jsx)(`span`,{className:`text-(--fg-quaternary)`,children:`·`}),(0,B.jsx)(`span`,{className:`shrink-0`,title:e.id,children:An(e.id)})]}),e.error?(0,B.jsx)(`span`,{className:`mt-2 block truncate font-mono text-[11px] text-[var(--tone-error-fg)]`,children:e.error}):null]}),l?(0,B.jsx)(`span`,{className:`relative z-10 shrink-0`,children:(0,B.jsxs)(we,{onClick:e=>{e.stopPropagation(),r()},variant:`danger`,children:[(0,B.jsx)(C,{size:13}),`Retry`]})}):null]})]})]})}function An(e){let t=e.split(`-`).at(-1)??e;return t.length>12?`…${t.slice(-12)}`:`…${t}`}var jn={event:{cardClass:`tint-border tint-info`,icon:s,iconClass:`border-dashed tint-border tint-text tint-info`,labelClass:`tint tint-info`},external:{cardClass:`tint-border tint-error`,icon:ae,iconClass:`tint-border tint-text tint-error`,labelClass:`tint tint-error`},function:{cardClass:`tint-border tint-success`,icon:D,iconClass:`tint-border tint-text tint-success`,labelClass:`tint tint-success`},request:{cardClass:`tint-border tint-info`,icon:u,iconClass:`tint-border tint-text tint-info`,labelClass:`tint tint-info`},worker:{cardClass:`tint-border tint-warning`,icon:c,iconClass:`border-double tint-border tint-text tint-warning`,labelClass:`tint tint-warning`}},Mn={dead:{badgeClass:`bg-(--error) text-white`,icon:x,label:`dead`,textClass:`text-[var(--tone-error-fg)]`},failed:{badgeClass:`bg-(--warning) text-white`,icon:y,label:`failed`,textClass:`tint-text tint-warning`},retrying:{badgeClass:`bg-(--info) text-white`,icon:C,label:`retrying`,textClass:`tint-text tint-info`},running:{badgeClass:`bg-(--info) text-white`,icon:S,label:`running`,textClass:`tint-text tint-info`},success:{badgeClass:`bg-(--success) text-white`,icon:ne,label:`success`,textClass:`tint-text tint-success`}},Nn=[{id:`story`,label:`Story`,icon:D},{id:`graph`,label:`Graph`,icon:O},{id:`timeline`,label:`Timeline`,icon:D},{id:`heatmap`,label:`Heatmap`,icon:m},{id:`waterfall`,label:`Waterfall`,icon:f},{id:`flame`,label:`Flame`,icon:p}];function Pn({mode:e,onChange:t}){return(0,B.jsx)(`div`,{className:`min-w-0 border-b border-(--line) bg-(--bg-panel-header)`,children:(0,B.jsx)(rt,{children:(0,B.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center gap-1 px-2`,children:Nn.map(({icon:n,id:r,label:i})=>(0,B.jsxs)(`button`,{className:k(`relative flex h-6 shrink-0 items-center gap-1.5 whitespace-nowrap rounded-[var(--radius-control)] px-2 text-[11px] font-medium transition-colors`,e===r?`native-selection`:`text-(--fg-tertiary) hover:bg-(--bg-row-hover) hover:text-(--fg-primary)`),onClick:()=>t(r),type:`button`,children:[(0,B.jsx)(n,{...e===r?{className:`text-(--accent)`}:{},size:12,strokeWidth:1.75}),i]},r))})})})}function Fn(e){return e.timelineItems===void 0?e.nodes.map(zn):e.timelineItems.map((t,n)=>Rn(e,t,n))}function In(e,t){return t.node?t.node:e.nodes.find(e=>e.id===t.id)??e.nodes.find(e=>e.id===t.id.replace(/^timeline:/,``))??null}function Ln(e){let t=Fn(e),n=Math.max(0,...t.map(e=>e.startMs+e.durationMs));return Math.max(e.durationMs,n,1)}function Rn(e,t,n){let r=e.nodes.find(e=>e.id===t.detailId)??e.nodes.find(e=>e.id===t.id),i=t.startedAt?Bn(e.timestamp,t.startedAt,n):Bn(e.timestamp,t.createdAt,n),a=t.completedAt?Bn(e.timestamp,t.completedAt,n):i+(r?.durationMs??1);return{...t.lastError?{error:t.lastError}:{},...r?{node:r}:{},attempts:t.attempts,durationMs:Math.max(0,a-i),id:t.id,kind:t.type,maxAttempts:t.maxAttempts,metaParts:Hn({kind:t.type,...r?{node:r}:{},service:r?.service??Vn(t.type),status:t.status}),name:t.name,service:r?.service??Vn(t.type),source:`backend`,startMs:i,status:t.status}}function zn(e){let t=e.logs.at(-1);return{...t?{error:t}:{},...e.attempts===void 0?{}:{attempts:e.attempts},...e.maxAttempts===void 0?{}:{maxAttempts:e.maxAttempts},durationMs:e.durationMs,id:e.id,kind:e.kind,metaParts:Hn({kind:e.kind,node:e,service:e.service,status:e.status}),name:e.name,node:e,service:e.service,source:`node`,startMs:e.startMs,status:e.status}}function Bn(e,t,n){let r=Date.parse(e),i=Date.parse(t);return Number.isFinite(r)&&Number.isFinite(i)?Math.max(0,i-r):n}function Vn(e){return e===`outbox_event`?`outbox`:e===`function_run`?`runtime.functions`:e===`http_request`?`http`:`runtime`}function Hn(e){let t=Kn(e.node?.attributes.source_metadata);return e.kind===`remote_proxy_call`||Wn(t)?Un(e):[e.service]}function Un(e){let t=Kn(e.node?.attributes.source_metadata),n=qn(t.module_name)??e.service,r=qn(t.method),i=qn(t.declared_path),a=Jn(t.remote_status),o=[r,i].filter(Boolean).join(` `);return[Gn(e.status,t),n,o||void 0,typeof a==`number`?`status ${a}`:void 0].filter(e=>e!==void 0)}function Wn(e){return typeof e.remote_proxy_call_id==`string`?!0:typeof e.module_name==`string`&&typeof e.method==`string`&&typeof e.declared_path==`string`}function Gn(e,t){return e===`failed`||e===`dead`?Yn(t.retryable)?`retryable`:`failed`:e===`completed`||e===`published`?`ok`:e}function Kn(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{}}function qn(e){return typeof e==`string`&&e.length>0?e:void 0}function Jn(e){return typeof e==`number`&&Number.isFinite(e)?e:void 0}function Yn(e){return typeof e==`boolean`?e:!1}var Xn=`grid min-w-0 gap-4 border-b border-(--line) bg-(--bg-panel-header) px-3 py-2 font-sans text-[11px] font-semibold uppercase tracking-[0.04em] text-(--fg-tertiary)`,Zn=`${Xn} grid-cols-[minmax(180px,260px)_minmax(0,1fr)] max-md:grid-cols-1`,Qn=`${Xn} grid-cols-[minmax(260px,340px)_minmax(0,1fr)]`;function $n({selectedNodeId:e,story:t,onSelectNode:n}){let r=Fn(t),i=Qt(t),a=new Map(i.map(e=>[e.firstNodeId,e])),o=Ln(t),s=t.timelineItems===void 0?`execution nodes`:`backend timeline`;return(0,B.jsxs)(`div`,{className:`isolate flex h-full min-w-0 flex-col overflow-hidden bg-(--bg-canvas)`,children:[(0,B.jsx)(W,{meta:`total ${P(o)}`,summary:`${r.length} rows from ${s}`,title:`Business Timeline`}),(0,B.jsxs)(`div`,{className:Zn,children:[(0,B.jsx)(`span`,{children:`Story Flow`}),(0,B.jsx)(`div`,{className:`grid min-w-0 grid-cols-5 overflow-hidden font-mono`,children:[0,25,50,75,100].map(e=>(0,B.jsx)(`span`,{className:`normal-case`,children:P(o*e/100)},e))})]}),(0,B.jsx)(`div`,{className:`min-h-0 flex-1 overflow-auto p-4`,children:(0,B.jsx)(`div`,{className:`mx-auto w-full max-w-5xl`,children:r.length===0?(0,B.jsx)(`div`,{className:`border border-(--line) bg-(--bg-panel) p-4 font-mono text-xs text-(--fg-tertiary)`,children:`No timeline items were returned for this story.`}):(0,B.jsx)(`div`,{className:`grid gap-3`,children:r.map((r,i)=>{let s=In(t,r),c=s?a.get(s.id):void 0;return(0,B.jsxs)(`div`,{className:`grid gap-2`,children:[c?(0,B.jsx)(tr,{label:c.label}):null,(0,B.jsx)(er,{index:i,onSelectNode:n,row:r,selected:e===r.node?.id,story:t,timelineEnd:o})]},r.id)})})})})]})}function er({index:e,row:t,selected:n,story:r,timelineEnd:i,onSelectNode:a}){let o=In(r,t),s=rr(t.kind),c=nr(t.kind),l=F({durationMs:t.durationMs,minWidthPercent:1.5,startMs:t.startMs,timelineEnd:i}),u=t.status===`failed`||t.status===`dead`;return(0,B.jsxs)(`button`,{"aria-label":`Open ${t.kind} ${t.name}`,className:k(`group grid min-w-0 grid-cols-[minmax(180px,260px)_minmax(0,1fr)] gap-4 text-left transition max-md:grid-cols-1`,n&&`scale-[1.004]`,!o&&`cursor-default`),disabled:!o,onClick:()=>{o&&a(o)},type:`button`,children:[(0,B.jsxs)(`span`,{className:k(`relative min-w-0 border bg-(--bg-panel) px-3 py-2.5 shadow-(--elevation-raised) transition group-hover:border-(--line)`,c.card,n&&`border-(--line-strong) bg-(--bg-row-hover)`),children:[e>0?(0,B.jsx)(`span`,{className:`-top-3.5 absolute left-6 h-3.5 w-px bg-(--line)`}):null,(0,B.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2`,children:[(0,B.jsx)(`span`,{className:k(`grid size-8 shrink-0 place-items-center border`,c.icon),children:(0,B.jsx)(s,{size:15,strokeWidth:1.8})}),(0,B.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`span`,{className:`truncate font-mono text-[10px] font-semibold uppercase tracking-[0.06em]`,children:ir(t.kind)}),(0,B.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full`,style:{backgroundColor:A(t.status)}})]}),(0,B.jsx)(`span`,{className:`mt-1 block truncate text-[13px] font-semibold text-(--fg-primary)`,children:t.name}),(0,B.jsxs)(`span`,{className:`mt-1 flex min-w-0 items-center gap-1.5 overflow-hidden font-mono text-[10px] text-(--fg-tertiary)`,children:[t.metaParts.map((e,n)=>(0,B.jsx)(`span`,{className:k(`min-w-0 truncate`,n>0&&`before:mr-1.5 before:content-['/']`,n>2&&`max-lg:hidden`),children:e},`${t.id}:${n}:${e}`)),(0,B.jsx)(`span`,{className:`ml-auto shrink-0`,children:P(t.durationMs)})]})]})]}),t.error?(0,B.jsx)(`span`,{className:`mt-2 block truncate border-l-2 border-[var(--error)] pl-2 font-mono text-[11px] text-[var(--tone-error-fg)]`,children:t.error}):null]}),(0,B.jsx)(`span`,{className:`grid min-h-18 min-w-0 items-center max-md:hidden`,children:(0,B.jsx)(`span`,{className:`relative h-9 min-w-0 overflow-hidden border border-(--line) bg-[linear-gradient(90deg,transparent_0%,transparent_24.8%,var(--line)_25%,transparent_25.2%,transparent_49.8%,var(--line)_50%,transparent_50.2%,transparent_74.8%,var(--line)_75%,transparent_75.2%)]`,children:(0,B.jsx)(`span`,{className:k(`absolute top-2 h-5 min-w-1 transition`,u&&`opacity-90`),style:{backgroundColor:u?`var(--error)`:M(t.service),left:`${l.left}%`,opacity:n?1:.82,transform:n?`scaleY(1.22)`:void 0,width:`${l.width}%`}})})})]})}function tr({label:e}){return(0,B.jsxs)(`div`,{className:`grid min-w-0 grid-cols-[minmax(180px,260px)_minmax(0,1fr)] gap-4 max-md:grid-cols-1`,children:[(0,B.jsx)(`div`,{className:`tint tint-info px-3 py-1.5 font-mono text-[11px]`,children:e}),(0,B.jsx)(`div`,{className:`grid min-w-0 items-center max-md:hidden`,children:(0,B.jsx)(`div`,{className:`h-px tint-soft tint-info`})})]})}var Z={event:{card:`tint-border tint-text tint-info`,icon:`tint tint-info`},external:{card:`tint-border tint-text tint-error`,icon:`tint tint-error`},function:{card:`tint-border tint-text tint-success`,icon:`tint tint-success`},request:{card:`tint-border tint-text tint-info`,icon:`tint tint-info`},worker:{card:`tint-border tint-text tint-warning`,icon:`tint tint-warning`}};function nr(e){return e===`outbox_event`||e===`event`?Z.event:e===`function_run`||e===`function`||e===`command`?Z.function:e===`http_request`||e===`http`?Z.request:e===`external_provider_call`||e===`remote_proxy_call`||e===`external`?Z.external:Z.worker}function rr(e){return e===`outbox_event`||e===`event`?s:e===`function_run`||e===`function`||e===`command`?D:e===`http_request`||e===`http`?u:e===`external_provider_call`||e===`remote_proxy_call`||e===`external`?ae:c}function ir(e){return e===`outbox_event`||e===`event`?`Outbox`:e===`function_run`||e===`function`||e===`command`?`Function`:e===`http_request`||e===`http`?`Request`:e===`remote_proxy_call`?`Remote Call`:e===`external_provider_call`||e===`external`?`External`:`Worker`}function ar(e){let t=lr(e),n=new Set,r=new Map(t.map(e=>[e.node?.id??e.id,e]));for(let t of e.timelineItems??[]){let i=pr(e,t);if(!i)continue;let a=r.get(i.id);a&&(a.markers.push(fr(e,t,i)),n.add(t.id))}for(let e of t)e.markers.sort(hr);let i=e.timelineItems?.filter(e=>!n.has(e.id)).map((t,n)=>dr(e,t,n)).sort(mr)??[];return[...t,...i]}function or(e){return e.node??null}function sr(e){let t=ar(e),n=Math.max(0,...t.map(e=>e.startMs+e.durationMs),...t.flatMap(e=>e.markers.map(e=>e.startMs+e.durationMs)));return Math.max(e.durationMs,n,1)}function cr({durationMs:e,minWidthPercent:t,startMs:n,timelineEnd:r}){return F({durationMs:e,minWidthPercent:t,startMs:n,timelineEnd:r})}function lr(e){let t=rn(e),n=Y(e),r=new Map(n.map(e=>[e.parentId,e.branchCount])),i=new Map(n.flatMap(e=>e.childIds.map(t=>[t,e.branchCount]))),a=new Map,o=new Map;for(let n of t.edges){let t=e.nodes.find(e=>e.id===n.source),r=e.nodes.find(e=>e.id===n.target);!t||!r||o.has(r.id)||(o.set(r.id,t.id),a.set(t.id,[...a.get(t.id)??[],r]))}for(let e of a.values())e.sort(gr);let s=new Set;for(let[e,t]of a){s.add(e);for(let e of t)s.add(e.id)}let c=e.nodes.filter(e=>s.has(e.id)&&!o.has(e.id)).sort(gr),l=[],u=new Set,d=(e,t)=>{if(u.has(e.id))return;u.add(e.id);let n=o.get(e.id),s=r.get(e.id),c=i.get(e.id);l.push(ur(e,t,`linked`,{...s===void 0?{}:{fanoutGroupSize:s},...c===void 0?{}:{parallelGroupSize:c},...n===void 0?{}:{parentId:n}}));for(let n of a.get(e.id)??[])d(n,t+1)};for(let e of c)d(e,0);let f=e.nodes.filter(e=>!u.has(e.id)).sort(gr);for(let e of f){let t=o.get(e.id),n=r.get(e.id),a=i.get(e.id);l.push(ur(e,0,`unlinked`,{...n===void 0?{}:{fanoutGroupSize:n},...a===void 0?{}:{parallelGroupSize:a},...t===void 0?{}:{parentId:t}}))}return l}function ur(e,t,n,r={}){return{durationMs:e.durationMs,...r.fanoutGroupSize===void 0?{}:{fanoutGroupSize:r.fanoutGroupSize},id:e.id,kind:e.kind,markers:[],name:e.name,node:e,...r.parallelGroupSize===void 0?{}:{parallelGroupSize:r.parallelGroupSize},...r.parentId===void 0?{}:{parentId:r.parentId},service:e.service,startMs:e.startMs,status:e.status,depth:t,group:n}}function dr(e,t,n){let r=fr(e,t);return{durationMs:r.durationMs,group:`unlinked`,id:`unlinked:${t.id}`,kind:t.type,markers:[r],name:t.name,service:vr(t.type),startMs:r.startMs+n/1e3,status:t.status,depth:0}}function fr(e,t,n){let r=t.startedAt?_r(e.timestamp,t.startedAt,n?.startMs??0):_r(e.timestamp,t.createdAt,n?.startMs??0),i=t.completedAt?_r(e.timestamp,t.completedAt,r):r+(n?.durationMs??1);return{durationMs:Math.max(0,i-r),id:t.id,kind:t.type,matchesRowTiming:n!==void 0&&r===n.startMs&&Math.max(0,i-r)===n.durationMs,name:t.name,startMs:r,status:t.status}}function pr(e,t){return e.nodes.find(e=>e.id===t.detailId)??e.nodes.find(e=>e.id===t.id)??null}function mr(e,t){return e.startMs-t.startMs||e.name.localeCompare(t.name)}function hr(e,t){return e.startMs-t.startMs||e.name.localeCompare(t.name)}function gr(e,t){return e.startMs-t.startMs||e.name.localeCompare(t.name)}function _r(e,t,n){let r=Date.parse(e),i=Date.parse(t);return Number.isFinite(r)&&Number.isFinite(i)?Math.max(0,i-r):n}function vr(e){return e===`outbox_event`?`outbox`:e===`function_run`?`runtime.functions`:e===`http_request`?`http`:`runtime`}function yr({selectedNodeId:e,story:t,onSelectNode:n}){let r=ar(t),i=sr(t),a=r.filter(e=>e.group===`unlinked`).length;return(0,B.jsxs)(`div`,{className:`isolate flex h-full min-w-0 flex-col overflow-hidden bg-(--background)`,children:[(0,B.jsx)(W,{meta:`total ${P(i)}`,summary:`${r.length} execution rows${a>0?` · ${a} unlinked`:``}`,title:`Waterfall`}),(0,B.jsxs)(`div`,{className:Qn,children:[(0,B.jsx)(`span`,{children:`Node`}),(0,B.jsx)(`div`,{className:`grid min-w-0 grid-cols-5 overflow-hidden`,children:[0,25,50,75,100].map(e=>(0,B.jsx)(`span`,{className:`font-mono normal-case`,children:P(i*e/100)},e))})]}),(0,B.jsxs)(`div`,{className:`min-h-0 flex-1 overflow-auto`,children:[r.length===0?(0,B.jsx)(`div`,{className:`border-b border-(--border-subtle) p-4 font-mono text-xs text-(--muted)`,children:`No waterfall rows were returned for this story.`}):null,r.map((t,a)=>{let o=r[a-1];return(0,B.jsxs)(`div`,{children:[t.group===`unlinked`&&o?.group!==`unlinked`?(0,B.jsx)(`div`,{className:`border-y border-(--border-subtle) bg-(--sidebar) px-3 py-1.5 font-mono text-[10px] font-semibold uppercase tracking-[0.08em] text-(--muted)`,children:`Unlinked`}):null,(0,B.jsx)(br,{onSelectNode:n,row:t,selectedNodeId:e,timelineEnd:i})]},t.id)})]})]})}function br({row:e,selectedNodeId:t,timelineEnd:n,onSelectNode:r}){let i=or(e),a=cr({durationMs:e.durationMs,minWidthPercent:.8,startMs:e.startMs,timelineEnd:n}),o=t===i?.id,s=M(e.service);return(0,B.jsxs)(`button`,{"aria-label":`Select row ${e.name}`,className:k(`grid w-full min-w-0 grid-cols-[minmax(260px,340px)_minmax(0,1fr)] items-center gap-4 px-3 py-1.5 text-left transition hover:bg-(--bg-row-hover) disabled:cursor-default`,o&&`bg-(--bg-row-hover)`,e.group===`unlinked`&&`opacity-82`),disabled:!i,onClick:()=>{i&&r(i)},type:`button`,children:[(0,B.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5 overflow-hidden`,children:[(0,B.jsxs)(`span`,{className:`grid h-7 shrink-0 grid-cols-[1px_minmax(0,1fr)]`,style:{marginLeft:e.depth*16,width:e.depth>0?18:2},children:[(0,B.jsx)(`span`,{className:`h-full bg-(--border-subtle)`}),e.depth>0?(0,B.jsx)(`span`,{className:`mt-3 h-px bg-(--border-subtle)`}):null]}),(0,B.jsx)(`span`,{className:`size-2 shrink-0 rounded-xs`,style:{backgroundColor:A(e.status)}}),(0,B.jsx)(`span`,{className:`max-w-28 shrink-0 truncate whitespace-nowrap rounded-xs border px-1.5 py-0.5 font-mono text-[11px] leading-3.5`,style:{backgroundColor:`${s}12`,borderColor:`${s}24`,color:s},children:e.service}),(0,B.jsx)(`span`,{className:`max-w-26 shrink-0 truncate font-mono text-[11px] text-(--muted)`,children:e.kind}),e.fanoutGroupSize?(0,B.jsxs)(`span`,{className:`shrink-0 rounded-xs px-1.5 py-0.5 font-mono text-[10px] leading-3.5 tint tint-info`,children:[`fan-out `,e.fanoutGroupSize]}):null,!e.fanoutGroupSize&&e.parallelGroupSize?(0,B.jsx)(`span`,{className:`shrink-0 rounded-xs px-1.5 py-0.5 font-mono text-[10px] leading-3.5 tint tint-info`,children:`parallel group`}):null,(0,B.jsx)(`span`,{className:`truncate font-mono text-[13px] text-(--foreground)`,children:e.name}),(0,B.jsx)(`span`,{className:`ml-auto font-mono text-xs text-(--muted)`,children:P(e.durationMs)})]}),(0,B.jsxs)(`span`,{className:`relative isolate h-8 min-w-0 overflow-hidden rounded-xs bg-[linear-gradient(90deg,transparent_0%,transparent_24.8%,var(--border-subtle)_25%,transparent_25.2%,transparent_49.8%,var(--border-subtle)_50%,transparent_50.2%,transparent_74.8%,var(--border-subtle)_75%,transparent_75.2%)]`,children:[(0,B.jsx)(`span`,{className:`absolute top-2 h-4 min-w-0.75 rounded-xs transition-transform`,style:{backgroundColor:e.status===`failed`||e.status===`dead`?`var(--error)`:s,left:`${a.left}%`,opacity:o?1:.82,transform:o?`scaleY(1.25)`:void 0,width:`${a.width}%`}}),xr(e,n)]})]})}function xr(e,t){let n=[];for(let r of e.markers)r.matchesRowTiming||n.push((0,B.jsx)(Sr,{marker:r,timelineEnd:t},r.id));return n}function Sr({marker:e,timelineEnd:t}){let n=cr({durationMs:e.durationMs,minWidthPercent:.6,startMs:e.startMs,timelineEnd:t}),r=e.status===`failed`||e.status===`dead`;return(0,B.jsx)(`span`,{className:k(`absolute top-1 h-1.5 rounded-xs bg-(--foreground)`,r&&`bg-(--error)`),style:{left:`${n.left}%`,opacity:r?.9:.5,width:`${n.width}%`},title:`${e.kind}: ${e.name} · ${P(e.durationMs)}`})}function Cr({mode:e,selectedNodeId:t,setMode:n,story:r,onRetryNode:i,onSelectNode:a}){let o=Me(r);return(0,B.jsxs)(`section`,{className:`isolate grid h-full min-h-0 min-w-0 grid-rows-[32px_minmax(0,1fr)] overflow-hidden`,children:[(0,B.jsx)(Pn,{mode:e,onChange:n}),(0,B.jsxs)(`div`,{className:`min-h-0 min-w-0 overflow-hidden`,children:[e===`story`?(0,B.jsx)(On,{onRetryNode:e=>i(e.node),onSelectNode:a,selectedNodeId:t,story:r}):null,e===`graph`?(0,B.jsx)(gn,{onSelectNode:a,selectedNodeId:t,story:r}):null,e===`timeline`?(0,B.jsx)($n,{onSelectNode:a,selectedNodeId:t,story:r}):null,e===`waterfall`?(0,B.jsx)(yr,{onSelectNode:a,selectedNodeId:t,story:r}):null,e===`flame`?(0,B.jsx)(Nt,{onSelectNode:a,selectedNodeId:t,story:r}):null,e===`heatmap`?(0,B.jsx)(Tn,{heatmap:o.data,loading:o.isLoading,onSelectNode:a,queryError:o.error,selectedNodeId:t,story:r}):null]})]})}function wr({expanded:e,headerHeight:t=28,height:n=144}){let r=Math.max(t,n);return{contentHeight:e?Math.max(0,r-t):0,panelHeight:e?r:t}}I.registerPlugin(Te);function Tr({expanded:e,height:t,onExpandedChange:n,story:r}){let i=(0,G.useRef)(null),a=(0,G.useRef)(null),o=(0,G.useRef)(!1),s=(0,G.useRef)(null),c=(0,G.useRef)(e),l=wr({expanded:e,height:t}),u=(0,G.useRef)(l),d=Array.from(new Set(r.nodes.map(e=>e.service))).map(e=>{let t=r.nodes.filter(t=>t.service===e),n=t.map(e=>e.durationMs);return{duration:n.reduce((e,t)=>e+t,0),errors:t.filter(e=>e.status===`failed`||e.status===`dead`).length,p50:Q(n,50),p95:Q(n,95),p99:Q(n,99),service:e,nodes:t.length}});return Te(()=>{let t=i.current,n=a.current,r=s.current;if(!t||!n||!r)return;let u=window.matchMedia(`(prefers-reduced-motion: reduce)`).matches,d=c.current!==e,f=o.current&&d;if(c.current=e,o.current=!0,I.killTweensOf([t,n,r]),u||!f){I.set(t,{height:l.panelHeight}),I.set(n,{height:l.contentHeight,opacity:+!!e}),I.set(r,{rotate:e?0:-90});return}I.to(r,{duration:.22,ease:`power2.out`,rotate:e?0:-90}),I.to(t,{duration:e?.32:.24,ease:e?`power3.out`:`power2.inOut`,height:l.panelHeight}),I.to(n,{duration:e?.32:.2,ease:e?`power3.out`:`power2.inOut`,height:l.contentHeight,opacity:+!!e})},{dependencies:[e,t??null,l.contentHeight,l.panelHeight,d.length],scope:i}),(0,B.jsxs)(`div`,{ref:i,className:`grid min-w-0 grid-rows-[auto_minmax(0,1fr)] overflow-hidden border-t border-(--border-subtle) bg-(--surface)`,style:{height:u.current.panelHeight},children:[(0,B.jsxs)(`div`,{className:k(`flex h-7 min-w-0 items-center gap-2 px-3`,e&&`border-b border-(--border-subtle)`),children:[(0,B.jsxs)(`button`,{"aria-expanded":e,"aria-label":e?`Collapse services`:`Expand services`,className:`flex min-w-0 items-center gap-1.5 text-left transition hover:text-(--foreground)`,onClick:()=>n(!e),type:`button`,children:[(0,B.jsx)(oe,{ref:s,className:`shrink-0 text-(--muted)`,size:13}),(0,B.jsx)(`span`,{className:`font-sans text-[11px] font-semibold uppercase tracking-[0.08em] text-(--secondary)`,children:`Services`}),(0,B.jsx)(`span`,{className:`rounded-[2px] border border-(--border-subtle) bg-(--elevated) px-1 font-mono text-[10px] text-(--muted)`,children:d.length})]}),(0,B.jsxs)(`div`,{className:`ml-auto flex min-w-0 items-center gap-3 overflow-hidden font-mono text-[11px] text-(--muted)`,children:[(0,B.jsxs)(`span`,{children:[`p50`,` `,P(Q(r.nodes.map(e=>e.durationMs),50))]}),(0,B.jsxs)(`span`,{children:[`p95`,` `,P(Q(r.nodes.map(e=>e.durationMs),95))]}),(0,B.jsxs)(`span`,{children:[`max`,` `,P(Math.max(...r.nodes.map(e=>e.durationMs)))]})]})]}),(0,B.jsx)(`div`,{ref:a,className:`min-h-0 overflow-hidden`,style:{height:u.current.contentHeight,opacity:+(u.current.contentHeight>0)},children:(0,B.jsx)(`div`,{className:`h-full min-h-0 overflow-auto`,children:d.map(e=>(0,B.jsxs)(`div`,{className:`grid min-w-175 grid-cols-[12px_minmax(150px,1fr)_64px_82px_82px_82px_minmax(104px,190px)] items-center gap-2 border-b border-(--border-subtle) px-3 py-1.5 font-mono text-[11px] last:border-b-0`,children:[(0,B.jsx)(`div`,{className:`size-2 rounded-xs`,style:{backgroundColor:M(e.service)}}),(0,B.jsx)(`span`,{className:`min-w-0 truncate text-xs font-medium text-(--foreground)`,children:e.service}),(0,B.jsxs)(`span`,{className:`text-(--muted)`,children:[e.nodes,` nodes`]}),(0,B.jsxs)(`span`,{className:`text-(--muted)`,children:[`p50 `,P(e.p50)]}),(0,B.jsxs)(`span`,{className:`text-(--muted)`,children:[`p95 `,P(e.p95)]}),(0,B.jsxs)(`span`,{className:`text-(--muted)`,children:[`p99 `,P(e.p99)]}),(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsxs)(`span`,{className:e.errors>0?`w-10 text-(--error)`:`w-10 text-(--muted)`,children:[e.errors,` err`]}),(0,B.jsx)(`div`,{className:`h-1 flex-1 overflow-hidden rounded-[1px] bg-(--elevated)`,children:(0,B.jsx)(`div`,{className:`h-full rounded-[1px]`,style:{backgroundColor:M(e.service),opacity:.7,width:`${Math.max(2,e.duration/r.durationMs*100)}%`}})})]})]},e.service))})})]})}function Q(e,t){if(e.length===0)return 0;let n=[...e].sort((e,t)=>e-t),r=Math.ceil(t/100*n.length)-1;return n[Math.max(0,r)]??0}function Er({onClose:e,onSelectNode:t,story:n}){let r=Pt(n),[i]=Y(n).sort((e,t)=>t.branchCount-e.branchCount||e.startMs-t.startMs),a=r.status===`failed`||r.status===`dead`;return(0,B.jsxs)(`header`,{className:`min-w-0 overflow-hidden border-b border-(--border-subtle) bg-(--surface)`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-start gap-3 px-3 pt-2 pb-1.5`,children:[(0,B.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,B.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,B.jsx)(`h1`,{className:`min-w-0 truncate text-[16px] font-semibold leading-tight text-(--foreground)`,children:r.title}),(0,B.jsx)(Ae,{status:r.status,variant:`label`})]}),(0,B.jsxs)(`div`,{className:`mt-1 flex min-w-0 flex-wrap items-center gap-1.5 font-mono text-[10px] text-(--secondary)`,children:[(0,B.jsx)($,{icon:(0,B.jsx)(E,{size:10}),tone:`accent`,children:P(r.duration)}),(0,B.jsxs)($,{icon:(0,B.jsx)(w,{size:10}),children:[r.nodeCount,` nodes`]}),(0,B.jsxs)($,{icon:(0,B.jsx)(_,{size:10}),tone:r.errorCount>0?`error`:`muted`,children:[r.errorCount,` errors`]}),(0,B.jsxs)($,{icon:(0,B.jsx)(h,{size:10}),children:[r.services.length,` services`]}),i?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsxs)($,{icon:(0,B.jsx)(O,{size:10}),tone:`accent`,children:[`fan-out `,i.branchCount]}),(0,B.jsxs)($,{icon:(0,B.jsx)(E,{size:10}),children:[`longest `,i.longestBranchName]})]}):null]})]}),(0,B.jsx)(`button`,{"aria-label":`Close story detail`,className:`grid size-5 shrink-0 place-items-center rounded-xs text-(--muted) transition hover:bg-(--hover) hover:text-(--foreground)`,onClick:e,type:`button`,children:(0,B.jsx)(v,{size:13})})]}),(0,B.jsx)(`div`,{className:`min-w-0 px-3 pb-1.5`,children:(0,B.jsx)(nt,{className:`h-6`,viewportClassName:`h-full`,children:(0,B.jsx)(`div`,{className:`flex h-full w-max min-w-full items-center gap-1.5`,children:r.services.map(e=>(0,B.jsx)(`span`,{className:`shrink-0 border border-(--border-subtle) bg-(--elevated) px-1.5 py-0.5 font-mono text-[10px] text-(--secondary)`,children:e},e))})})}),(0,B.jsxs)(`div`,{className:`flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 px-3 pb-1.5 font-mono text-[10px]`,children:[(0,B.jsx)(`span`,{className:`min-w-0 truncate text-(--secondary)`,children:r.patternLabel||`No execution pattern`}),(0,B.jsx)(`span`,{className:`text-(--muted-deep)`,children:`·`}),(0,B.jsx)(`span`,{className:`min-w-0 truncate text-(--muted)`,children:r.correlationId}),r.rootError?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-(--muted-deep)`,children:`·`}),(0,B.jsx)(`button`,{className:k(`min-w-0 truncate text-left text-(--tone-error-fg) transition hover:text-(--error)`,a&&`font-semibold`),onClick:()=>{let e=Dr(r.nodes);e&&t(e.node)},type:`button`,children:r.rootError})]}):null]})]})}function Dr(e){for(let t=e.length-1;t>=0;--t){let n=e[t];if(n?.error)return n}return null}function $({children:e,icon:t,tone:n=`muted`}){let r={accent:`text-(--accent)`,error:`text-(--tone-error-fg)`,muted:`text-(--secondary)`}[n];return(0,B.jsxs)(`span`,{className:k(`inline-flex items-center gap-1`,r),children:[t,e]})}function Or({query:e,selectedStoryId:t,setQuery:n,stories:r,onSelect:i}){return(0,B.jsxs)(`aside`,{className:`grid h-full min-h-0 min-w-0 grid-rows-[auto_auto_auto_minmax(0,1fr)] overflow-hidden bg-(--bg-panel)`,children:[(0,B.jsx)(`div`,{className:`flex min-h-10 items-center justify-between gap-2 border-b border-(--line) bg-(--bg-panel) px-3 py-2`,children:(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h2`,{className:`text-sm font-semibold tracking-tight text-(--fg-primary)`,children:`Stories`}),(0,B.jsxs)(`p`,{className:`text-xs text-(--fg-tertiary)`,children:[r.length,` correlations`]})]})}),(0,B.jsxs)(`div`,{className:`flex h-8 items-center gap-2 border-b border-(--line) px-3 text-(--fg-tertiary)`,children:[(0,B.jsx)(se,{size:12}),(0,B.jsx)(`input`,{"aria-label":`Search stories`,className:`mono w-full bg-transparent text-xs text-(--fg-primary) outline-hidden placeholder:text-(--fg-quaternary)`,onChange:e=>n(e.target.value),placeholder:`filter story / service / correlation...`,value:e})]}),(0,B.jsxs)(`div`,{className:`grid h-6 grid-cols-[12px_minmax(0,1fr)_58px] items-center gap-2 border-b border-(--line) bg-(--bg-panel-header) px-3 text-[10px] font-semibold uppercase text-(--fg-tertiary)`,children:[(0,B.jsx)(`span`,{}),(0,B.jsx)(`span`,{children:`story`}),(0,B.jsx)(`span`,{className:`text-right`,children:`state`})]}),(0,B.jsxs)(`div`,{className:`min-h-0 overflow-auto`,children:[r.length===0?(0,B.jsx)(`div`,{className:`p-4 text-[12px] leading-5 text-(--fg-tertiary)`,children:`No stories match the current filter.`}):null,r.map(e=>{let n=Pt(e),r=n.status===`failed`||n.status===`dead`,a=t===e.id;return(0,B.jsxs)(`button`,{className:k(`relative w-full border-b border-(--line) py-2.5 pr-3 pl-4 text-left transition`,r&&`before:absolute before:inset-y-0 before:left-0 before:w-0.5 before:bg-(--error)`,a?`native-selection`:`hover:bg-(--bg-row-hover)`),onClick:()=>i(e),type:`button`,children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,B.jsx)(`span`,{className:`size-1.5 shrink-0 rounded-full`,style:{backgroundColor:A(n.status)}}),(0,B.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-semibold text-(--fg-primary)`,children:n.title}),(0,B.jsx)(`span`,{className:k(`text-[10px] font-medium`,r?`text-(--tone-error-fg)`:`text-(--fg-tertiary)`),children:n.status})]}),(0,B.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-2 text-[11px] text-(--fg-secondary)`,children:[(0,B.jsx)(Ar,{icon:(0,B.jsx)(E,{size:10}),children:P(n.duration)}),(0,B.jsx)(`span`,{className:`text-(--line)`,children:`·`}),(0,B.jsx)(Ar,{icon:(0,B.jsx)(w,{size:10}),children:n.nodeCount}),n.errorCount>0?(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`span`,{className:`text-(--line)`,children:`·`}),(0,B.jsx)(Ar,{className:`text-(--tone-error-fg)`,icon:(0,B.jsx)(_,{size:10}),children:n.errorCount})]}):null,(0,B.jsx)(`span`,{className:`ml-auto truncate text-[10px] text-(--fg-tertiary)`,title:n.correlationId,children:kr(n.correlationId)})]}),r&&n.rootError?(0,B.jsx)(`div`,{className:`mt-1.5 truncate text-[11px] leading-4 text-(--tone-error-fg)`,children:n.rootError}):(0,B.jsx)(`div`,{className:`mt-1.5 truncate text-[11px] leading-4 text-(--fg-secondary)`,children:n.patternLabel||`No execution pattern`}),(0,B.jsxs)(`div`,{className:`mt-1.5 flex min-w-0 flex-wrap gap-1`,children:[n.services.slice(0,4).map(e=>(0,B.jsx)(`span`,{className:`max-w-24 truncate rounded border border-(--line) bg-(--bg-control) px-1.5 py-0.5 text-[10px] text-(--fg-tertiary)`,children:e},e)),n.services.length>4?(0,B.jsxs)(`span`,{className:`rounded border border-(--line) bg-(--bg-control) px-1.5 py-0.5 text-[10px] text-(--fg-tertiary)`,children:[`+`,n.services.length-4]}):null]})]},e.id)})]})]})}function kr(e){let t=e.split(`-`).at(-1)??e;return t.length>12?`…${t.slice(-12)}`:`…${t}`}function Ar({children:e,className:t,icon:n}){return(0,B.jsxs)(`span`,{className:k(`inline-flex items-center gap-1`,t),children:[n,e]})}function jr({entityName:e,limit:t=50,moduleName:n}){return a({enabled:me(),queryKey:[`admin-data`,`list`,n,e,t],queryFn:()=>Fe.get(`admin/data/${encodeURIComponent(n)}/${encodeURIComponent(e)}?limit=${t}`).json()})}function Mr(){let e=r();return i({mutationFn:({actionName:e,input:t,moduleName:n})=>Fe.post(`admin/data/${encodeURIComponent(n)}/actions/${encodeURIComponent(e)}`,{json:{input:t}}).json(),onSuccess:async(t,n)=>{await e.invalidateQueries({queryKey:[`admin-data`,`list`,n.moduleName]}),await e.invalidateQueries({queryKey:[`runtime`,`admin-actions`]})}})}var Nr={adminData:{useInvokeAction:Mr,useRecords:jr},modules:{useMetadata:pe},context:{useRuntimeConsole:_e},data:{retryTargetForNode:N,runtimeStories:Ee},hooks:{useBrowserUrlPopState:de,useListKeyboard:je,usePersistedLayout:Ne,writeBrowserUrl:he},queries:{useRuntimeStories:be},routing:{buildPath:ue},story:{executionInspectorTabs:Re,findStoryByCorrelation:Ie},ui:{common:{EmptyState:X},runtime:{ExecutionInspector:at,ResizeHandle:xe,RuntimeStoryVisualization:Cr,ServiceSummaryStrip:Tr,StoryHeader:Er,StoryList:Or,defaultExecutionInspectorTab:Be}}};export{ge as consoleSurfaceFromPackageManifest,Pe as consoleSurfacesFromPackageManifest,Le as defineConsoleModule,ve as defineConsolePackageManifest,Nr as runtimeConsoleHostApi};