specrails-hub 1.41.1 → 1.42.0

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.
@@ -1 +1 @@
1
- import{n as e,o as t,r as n,t as r}from"./createLucideIcon-Cg9402G2.js";import{$ as i,B as a,N as o,V as s,it as c,j as l,rt as u,ut as d}from"./index-geDvjEca.js";var f=r(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),p=t(n(),1);function m(e){let t=new Set;return e.filter(e=>{let n=`${e.type}:${e.jobId}`;return t.has(n)?!1:(t.add(n),!0)})}function h({activeProjectId:e,limit:t=50}){let[n,r]=(0,p.useState)([]),[i,s]=(0,p.useState)(!1),[c,l]=(0,p.useState)(!0),u=(0,p.useRef)(e);(0,p.useEffect)(()=>{u.current=e},[e]);let{registerHandler:d,unregisterHandler:f}=o();(0,p.useEffect)(()=>{if(!e){r([]),l(!0);return}let n=!1;s(!0),r([]),l(!0);async function i(){let e=a();try{let i=await fetch(`${e}/activity?limit=${t}`);if(!i.ok||n)return;let a=await i.json();if(n)return;r(a),l(a.length===t)}catch{}finally{n||s(!1)}}return i(),()=>{n=!0}},[e,t]);let h=(0,p.useCallback)(async()=>{if(i||!c)return;s(!0);let e=a();try{r(n=>{let i=n[n.length-1];if(!i)return n;let a=encodeURIComponent(i.timestamp);return fetch(`${e}/activity?limit=${t}&before=${a}`).then(e=>e.json()).then(e=>{r(t=>m([...t,...e])),l(e.length===t),s(!1)}).catch(()=>s(!1)),n})}catch{s(!1)}},[i,c,t]),g=(0,p.useCallback)(e=>{let t=e,n=u.current;if(!(!t||typeof t.type!=`string`)&&!(t.projectId&&t.projectId!==n)){if(t.type===`queue`&&Array.isArray(t.jobs)){let e=[];for(let n of t.jobs){let t=n.status===`completed`?`job_completed`:n.status===`failed`?`job_failed`:n.status===`canceled`?`job_canceled`:`job_started`;e.push({id:`${t}:${n.id}`,type:t,jobId:n.id,jobCommand:n.command??``,timestamp:n.startedAt??new Date().toISOString(),summary:`${t.replace(`_`,` `)}: ${n.command??``}`,costUsd:null})}e.length>0&&r(t=>m([...e,...t]))}if(t.type===`phase`&&t.phase&&t.state&&t.timestamp){let e={id:`phase:${t.phase}:${t.state}:${t.timestamp}`,type:`job_started`,jobId:`phase-${t.phase}`,jobCommand:`Phase: ${t.phase} → ${t.state}`,timestamp:t.timestamp,summary:`Phase ${t.phase} is ${t.state}`,costUsd:null};r(t=>m([e,...t]))}}},[]);return(0,p.useLayoutEffect)(()=>(d(`activity`,g),()=>f(`activity`)),[g,d,f]),{items:n,loading:i,hasMore:c,loadMore:h}}var g=e();function _(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function v({type:e}){switch(e){case`job_completed`:return(0,g.jsx)(c,{className:`w-4 h-4 text-green-500 flex-shrink-0`});case`job_failed`:return(0,g.jsx)(u,{className:`w-4 h-4 text-red-500 flex-shrink-0`});case`job_canceled`:return(0,g.jsx)(f,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`});default:return(0,g.jsx)(s,{className:`w-4 h-4 text-blue-500 flex-shrink-0`})}}function y(e){switch(e){case`job_completed`:return`Completed`;case`job_failed`:return`Failed`;case`job_canceled`:return`Canceled`;default:return`Started`}}function b(e){switch(e){case`job_completed`:return`text-green-500`;case`job_failed`:return`text-red-500`;case`job_canceled`:return`text-muted-foreground`;default:return`text-blue-500`}}function x(){let{activeProjectId:e}=l(),{items:t,loading:n,hasMore:r,loadMore:a}=h({activeProjectId:e}),o=(0,p.useRef)(null);return(0,p.useEffect)(()=>{let e=o.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&r&&!n&&a()},{threshold:.1});return t.observe(e),()=>t.disconnect()},[r,n,a]),(0,g.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border bg-background/50`,children:[(0,g.jsx)(d,{className:`w-4 h-4 text-muted-foreground`}),(0,g.jsx)(`h1`,{className:`text-sm font-medium`,children:`Activity`})]}),(0,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[n&&t.length===0?(0,g.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,g.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):t.length===0?(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-2 text-muted-foreground`,children:[(0,g.jsx)(d,{className:`w-8 h-8 opacity-40`}),(0,g.jsx)(`p`,{className:`text-sm`,children:`No activity yet`}),(0,g.jsx)(`p`,{className:`text-xs opacity-70`,children:`Job events will appear here when jobs run`})]}):(0,g.jsx)(`ul`,{className:`divide-y divide-border/50`,children:t.map(e=>(0,g.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5 hover:bg-accent/30 transition-colors`,children:[(0,g.jsx)(v,{type:e.type}),(0,g.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,g.jsx)(`p`,{className:`text-xs text-foreground truncate`,title:e.jobCommand,children:e.jobCommand}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,g.jsx)(`span`,{className:`text-xs font-medium ${b(e.type)}`,children:y(e.type)}),e.costUsd!=null&&(0,g.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`$`,e.costUsd.toFixed(4)]})]})]}),(0,g.jsx)(`span`,{className:`text-xs text-muted-foreground flex-shrink-0 tabular-nums`,children:_(e.timestamp)})]},`${e.type}:${e.jobId}`))}),(0,g.jsx)(`div`,{ref:o,className:`h-1`}),n&&t.length>0&&(0,g.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,g.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!r&&t.length>0&&(0,g.jsx)(`p`,{className:`text-center text-xs text-muted-foreground py-3`,children:`All activity loaded`})]})]})}export{x as default};
1
+ import{n as e,o as t,r as n,t as r}from"./createLucideIcon-Cg9402G2.js";import{$ as i,B as a,N as o,V as s,it as c,j as l,rt as u,ut as d}from"./index-W5VPSfMl.js";var f=r(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),p=t(n(),1);function m(e){let t=new Set;return e.filter(e=>{let n=`${e.type}:${e.jobId}`;return t.has(n)?!1:(t.add(n),!0)})}function h({activeProjectId:e,limit:t=50}){let[n,r]=(0,p.useState)([]),[i,s]=(0,p.useState)(!1),[c,l]=(0,p.useState)(!0),u=(0,p.useRef)(e);(0,p.useEffect)(()=>{u.current=e},[e]);let{registerHandler:d,unregisterHandler:f}=o();(0,p.useEffect)(()=>{if(!e){r([]),l(!0);return}let n=!1;s(!0),r([]),l(!0);async function i(){let e=a();try{let i=await fetch(`${e}/activity?limit=${t}`);if(!i.ok||n)return;let a=await i.json();if(n)return;r(a),l(a.length===t)}catch{}finally{n||s(!1)}}return i(),()=>{n=!0}},[e,t]);let h=(0,p.useCallback)(async()=>{if(i||!c)return;s(!0);let e=a();try{r(n=>{let i=n[n.length-1];if(!i)return n;let a=encodeURIComponent(i.timestamp);return fetch(`${e}/activity?limit=${t}&before=${a}`).then(e=>e.json()).then(e=>{r(t=>m([...t,...e])),l(e.length===t),s(!1)}).catch(()=>s(!1)),n})}catch{s(!1)}},[i,c,t]),g=(0,p.useCallback)(e=>{let t=e,n=u.current;if(!(!t||typeof t.type!=`string`)&&!(t.projectId&&t.projectId!==n)){if(t.type===`queue`&&Array.isArray(t.jobs)){let e=[];for(let n of t.jobs){let t=n.status===`completed`?`job_completed`:n.status===`failed`?`job_failed`:n.status===`canceled`?`job_canceled`:`job_started`;e.push({id:`${t}:${n.id}`,type:t,jobId:n.id,jobCommand:n.command??``,timestamp:n.startedAt??new Date().toISOString(),summary:`${t.replace(`_`,` `)}: ${n.command??``}`,costUsd:null})}e.length>0&&r(t=>m([...e,...t]))}if(t.type===`phase`&&t.phase&&t.state&&t.timestamp){let e={id:`phase:${t.phase}:${t.state}:${t.timestamp}`,type:`job_started`,jobId:`phase-${t.phase}`,jobCommand:`Phase: ${t.phase} → ${t.state}`,timestamp:t.timestamp,summary:`Phase ${t.phase} is ${t.state}`,costUsd:null};r(t=>m([e,...t]))}}},[]);return(0,p.useLayoutEffect)(()=>(d(`activity`,g),()=>f(`activity`)),[g,d,f]),{items:n,loading:i,hasMore:c,loadMore:h}}var g=e();function _(e){let t=Date.now()-new Date(e).getTime(),n=Math.floor(t/1e3);if(n<60)return`${n}s ago`;let r=Math.floor(n/60);if(r<60)return`${r}m ago`;let i=Math.floor(r/60);return i<24?`${i}h ago`:`${Math.floor(i/24)}d ago`}function v({type:e}){switch(e){case`job_completed`:return(0,g.jsx)(c,{className:`w-4 h-4 text-green-500 flex-shrink-0`});case`job_failed`:return(0,g.jsx)(u,{className:`w-4 h-4 text-red-500 flex-shrink-0`});case`job_canceled`:return(0,g.jsx)(f,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`});default:return(0,g.jsx)(s,{className:`w-4 h-4 text-blue-500 flex-shrink-0`})}}function y(e){switch(e){case`job_completed`:return`Completed`;case`job_failed`:return`Failed`;case`job_canceled`:return`Canceled`;default:return`Started`}}function b(e){switch(e){case`job_completed`:return`text-green-500`;case`job_failed`:return`text-red-500`;case`job_canceled`:return`text-muted-foreground`;default:return`text-blue-500`}}function x(){let{activeProjectId:e}=l(),{items:t,loading:n,hasMore:r,loadMore:a}=h({activeProjectId:e}),o=(0,p.useRef)(null);return(0,p.useEffect)(()=>{let e=o.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&r&&!n&&a()},{threshold:.1});return t.observe(e),()=>t.disconnect()},[r,n,a]),(0,g.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border bg-background/50`,children:[(0,g.jsx)(d,{className:`w-4 h-4 text-muted-foreground`}),(0,g.jsx)(`h1`,{className:`text-sm font-medium`,children:`Activity`})]}),(0,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[n&&t.length===0?(0,g.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,g.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):t.length===0?(0,g.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-2 text-muted-foreground`,children:[(0,g.jsx)(d,{className:`w-8 h-8 opacity-40`}),(0,g.jsx)(`p`,{className:`text-sm`,children:`No activity yet`}),(0,g.jsx)(`p`,{className:`text-xs opacity-70`,children:`Job events will appear here when jobs run`})]}):(0,g.jsx)(`ul`,{className:`divide-y divide-border/50`,children:t.map(e=>(0,g.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5 hover:bg-accent/30 transition-colors`,children:[(0,g.jsx)(v,{type:e.type}),(0,g.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,g.jsx)(`p`,{className:`text-xs text-foreground truncate`,title:e.jobCommand,children:e.jobCommand}),(0,g.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,g.jsx)(`span`,{className:`text-xs font-medium ${b(e.type)}`,children:y(e.type)}),e.costUsd!=null&&(0,g.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`$`,e.costUsd.toFixed(4)]})]})]}),(0,g.jsx)(`span`,{className:`text-xs text-muted-foreground flex-shrink-0 tabular-nums`,children:_(e.timestamp)})]},`${e.type}:${e.jobId}`))}),(0,g.jsx)(`div`,{ref:o,className:`h-1`}),n&&t.length>0&&(0,g.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,g.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!r&&t.length>0&&(0,g.jsx)(`p`,{className:`text-center text-xs text-muted-foreground py-3`,children:`All activity loaded`})]})]})}export{x as default};
@@ -1,4 +1,4 @@
1
- import{n as e,o as t,r as n,t as r}from"./createLucideIcon-Cg9402G2.js";import{t as i}from"./copy-C1m2IjcW.js";import{$ as a,A as o,B as s,C as c,D as l,E as u,G as d,H as f,K as p,O as m,S as h,T as g,U as _,W as v,X as y,Z as b,_ as x,b as S,et as C,f as w,g as T,h as E,k as D,lt as O,m as k,mt as A,n as j,p as M,q as N,tt as P,w as F,x as I,y as L,z as R}from"./index-geDvjEca.js";var z=r(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),B=r(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),ee=r(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),V=r(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),te=r(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),H=r(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),ne=r(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),U=r(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),W=t(n(),1),G=e(),re=/^[a-z0-9][a-z0-9-]*$/;function K({open:e,mode:t=`add`,initial:n,chainAgents:r,onConfirm:i,onCancel:a}){let[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(r[0]??``);(0,W.useEffect)(()=>{e&&(t===`edit`&&n?(s(n.tags.join(`, `)),l(r.includes(n.agent)?n.agent:r[0]??``)):(s(``),l(r[0]??``)))},[e,t,n,r]);let u=o.split(`,`).map(e=>e.trim()).filter(Boolean),d=u.filter(e=>!re.test(e)),f=u.length>0&&d.length===0&&r.includes(c);return(0,G.jsx)(w,{open:e,onOpenChange:e=>{e||a()},children:(0,G.jsxs)(M,{className:`max-w-md`,children:[(0,G.jsxs)(T,{children:[(0,G.jsx)(x,{children:t===`edit`?`Edit routing rule`:`Add routing rule`}),(0,G.jsx)(k,{children:t===`edit`?`Update the tags or target agent for this rule.`:`Add a tag-matched routing rule using lowercase kebab-case tags.`})]}),(0,G.jsxs)(`div`,{className:`py-2 space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Tags`}),(0,G.jsx)(j,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),placeholder:`frontend, ui`,"aria-label":`Tags`,className:`text-sm font-mono`}),(0,G.jsxs)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:[`Comma-separated. Use lowercase kebab-case like `,(0,G.jsx)(`code`,{children:`frontend`}),` or `,(0,G.jsx)(`code`,{children:`api-design`}),`.`]}),d.length>0&&(0,G.jsxs)(`p`,{className:`text-[11px] text-red-400 mt-1`,children:[`Invalid tag`,d.length===1?``:`s`,`: `,d.join(`, `),`. Tags must use lowercase letters, digits, and hyphens only.`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Route to`}),(0,G.jsx)(`select`,{value:c,onChange:e=>l(e.target.value),"aria-label":`Route to`,className:`w-full h-9 px-2 text-sm rounded-md border border-border bg-background`,children:r.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:`Only agents in this profile's chain can be routing targets.`})]})]}),(0,G.jsxs)(E,{children:[(0,G.jsx)(R,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,G.jsx)(R,{size:`sm`,onClick:()=>i(u,c),disabled:!f,children:t===`edit`?`Save changes`:`Add rule`})]})]})})}var q=new Set([`sr-architect`,`sr-developer`,`sr-reviewer`,`sr-merge-resolver`]),J=[`sonnet`,`opus`,`haiku`],Y=/^[a-z0-9][a-z0-9-]*$/;function ie({profile:e,onChange:t,footer:n,onValidityChange:r,onSoftWarningsChange:i}){let[a,o]=(0,W.useState)([]),[d,p]=(0,W.useState)(!1),[h,_]=(0,W.useState)(!1),[v,b]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=!1;return fetch(`${s()}/profiles/catalog`).then(e=>e.ok?e.json():{agents:[]}).then(t=>{e||o(t.agents)}).catch(()=>{e||o([])}),()=>{e=!0}},[]);let x=n=>{let r=JSON.parse(JSON.stringify(e));n(r),t(r)},C=new Set(e.agents.map(e=>e.id)),w=a.filter(e=>!C.has(e.id)),T=(0,W.useMemo)(()=>{let t=[];for(let n of q)e.agents.some(e=>e.id===n)||t.push(`Missing required baseline agent: ${n}`);let n=e.routing.filter(e=>`default`in e&&e.default===!0);if(n.length>1&&t.push(`Routing may have at most one default rule (found ${n.length})`),n.length===1){let n=e.routing[e.routing.length-1];`default`in n&&n.default===!0||t.push(`The default routing rule must be the last entry`)}for(let n of e.routing)if(e.agents.some(e=>e.id===n.agent)||t.push(`Routing references agent not in the chain: ${n.agent}`),`tags`in n){let e=n.tags.filter(e=>!Y.test(e));e.length>0&&t.push(`Routing rule ${n.agent} has invalid tags: ${e.join(`, `)} (use lowercase kebab-case)`)}return t},[e]),E=(0,W.useMemo)(()=>{if(e.routing.length===0)return[];let t=new Set(e.routing.map(e=>e.agent));return e.agents.filter(e=>!q.has(e.id)&&!t.has(e.id)).map(e=>e.id)},[e]),O=(0,W.useMemo)(()=>e.routing.some(e=>`default`in e&&e.default===!0),[e.routing]);(0,W.useEffect)(()=>{r&&r(T)},[T,r]),(0,W.useEffect)(()=>{i&&i({agentsMissingRouting:E})},[E,i]);let k=e=>{x(t=>{let n={id:e,model:`sonnet`},r=t.agents.findIndex(e=>e.id===`sr-merge-resolver`);r>=0?t.agents.splice(r,0,n):t.agents.push(n)}),p(!1)},A=t=>{let n=e.agents[t];q.has(n.id)||x(e=>{e.agents.splice(t,1),e.routing=e.routing.filter(e=>e.agent!==n.id)})},M=(t,n)=>{if(t===n)return;let r=e.agents.findIndex(e=>e.id===t),i=e.agents.findIndex(e=>e.id===n);if(r<0||i<0)return;let a=S(e.agents,r,i),o=a.findIndex(e=>e.id===`sr-architect`);if(o>0){let[e]=a.splice(o,1);a.unshift(e)}let s=a.findIndex(e=>e.id===`sr-merge-resolver`);if(s>=0&&s!==a.length-1){let[e]=a.splice(s,1);a.push(e)}x(e=>{e.agents=a})},N=D(m(u,{activationConstraint:{distance:4}}),m(g,{coordinateGetter:I})),P=e=>{let{active:t,over:n}=e;n&&M(String(t.id),String(n.id))},z=(e,t)=>{x(n=>{n.agents[e].model=t})},B=(e,t)=>{x(n=>{let r={tags:e,agent:t},i=n.routing.findIndex(e=>`default`in e&&e.default===!0);i>=0?n.routing.splice(i,0,r):n.routing.push(r)}),_(!1)},ee=()=>{x(e=>{e.routing.some(e=>`default`in e&&e.default===!0)||e.agents.some(e=>e.id===`sr-developer`)&&e.routing.push({default:!0,agent:`sr-developer`})})},V=e=>`default`in e&&e.default===!0,te=(e,t)=>{x(n=>{let r=n.routing[e];r&&(V(r)||(r.agent=t))})},H=(e,t,n)=>{x(r=>{let i=r.routing[e];i&&(V(i)||(i.tags=t,i.agent=n))})},ne=e=>{x(t=>{let n=t.routing[e];n&&(V(n)||t.routing.splice(e,1))})},U=(t,n)=>{let r=t+n;if(r<0||r>=e.routing.length)return;let i=e.routing[t],a=e.routing[r];V(i)||V(a)||x(e=>{let[n]=e.routing.splice(t,1);e.routing.splice(r,0,n)})};return(0,G.jsxs)(`div`,{className:`p-6 space-y-6 max-w-3xl`,children:[(0,G.jsx)(K,{open:h,mode:`add`,chainAgents:e.agents.map(e=>e.id),onConfirm:B,onCancel:()=>_(!1)}),(0,G.jsx)(K,{open:v!==null,mode:`edit`,initial:v!==null&&e.routing[v]&&!(`default`in e.routing[v])?{tags:e.routing[v].tags,agent:e.routing[v].agent}:void 0,chainAgents:e.agents.map(e=>e.id),onConfirm:(e,t)=>{v!==null&&(H(v,e,t),b(null))},onCancel:()=>b(null)}),T.length>0&&(0,G.jsxs)(`div`,{className:`px-3 py-2 text-xs rounded-md border border-yellow-500/30 bg-yellow-500/10 text-yellow-500`,children:[(0,G.jsxs)(`div`,{className:`font-medium mb-1`,children:[T.length,` validation `,T.length===1?`issue`:`issues`]}),(0,G.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:T.map((e,t)=>(0,G.jsx)(`li`,{children:e},t))})]}),(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Name`}),(0,G.jsx)(j,{value:e.name,disabled:!0,className:`text-sm`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Description`}),(0,G.jsx)(j,{value:e.description??``,onChange:e=>x(t=>{t.description=e.target.value}),className:`text-sm`,placeholder:`What is this profile for?`})]})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2`,children:`Orchestrator`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-md border border-border`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-sm font-mono text-foreground truncate`,children:`/specrails:implement · /specrails:batch-implement`}),(0,G.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:`Top-level model for both commands. batch-implement delegates to implement per feature, so every rail it spawns inherits this profile's agent chain.`})]}),(0,G.jsx)(oe,{value:e.orchestrator.model,onChange:e=>x(t=>{t.orchestrator.model=e})})]})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[`Agent chain (`,e.agents.length,`)`]}),(0,G.jsxs)(R,{size:`sm`,variant:`ghost`,onClick:()=>p(e=>!e),disabled:w.length===0,title:w.length===0?`All catalog agents are already in the chain`:`Add an agent from the catalog`,children:[(0,G.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` Add`]})]}),d&&(0,G.jsxs)(`div`,{className:`mb-2 p-2 rounded-md border border-border bg-muted/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 px-1`,children:[(0,G.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`Pick from catalog (`,w.length,` available)`]}),(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:()=>p(!1),title:`Close`,children:(0,G.jsx)(f,{className:`w-3 h-3`})})]}),w.length===0?(0,G.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:`No more agents in the catalog. Add custom agents from the Agents Catalog tab.`}):(0,G.jsx)(`div`,{className:`space-y-0.5 max-h-64 overflow-auto`,children:w.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>k(e.id),className:`w-full flex items-center justify-between gap-2 px-2 py-1.5 text-left rounded hover:bg-accent transition-colors`,children:[(0,G.jsx)(`span`,{className:`text-sm font-mono`,children:e.id}),(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded `+(e.kind===`custom`?`bg-purple-500/15 text-purple-400`:`bg-muted text-muted-foreground`),children:e.kind})]},e.id))})]}),(0,G.jsx)(F,{sensors:N,collisionDetection:l,onDragEnd:P,children:(0,G.jsx)(L,{items:e.agents.map(e=>e.id),strategy:c,children:(0,G.jsx)(`div`,{className:`space-y-1.5`,children:e.agents.map((e,t)=>(0,G.jsx)(X,{agent:e,canRemove:!q.has(e.id),onModel:e=>z(t,e),onRemove:()=>A(t)},e.id))})})})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[`Routing (`,e.routing.length,`)`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!O&&(0,G.jsxs)(R,{size:`sm`,variant:`ghost`,onClick:ee,disabled:e.agents.length===0,title:e.agents.length===0?`Add at least one agent before creating routing rules`:void 0,children:[(0,G.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` Add default`]}),(0,G.jsxs)(R,{size:`sm`,variant:`ghost`,onClick:()=>_(!0),disabled:e.agents.length===0,title:e.agents.length===0?`Add at least one agent before creating routing rules`:void 0,children:[(0,G.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` Add rule`]})]})]}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-2`,children:`First matching rule wins. Rules are editable and removable, and the default catch-all stays last when present. If you leave routing empty, the pipeline falls back to the first developer-shaped agent in the chain.`}),E.length>0&&(0,G.jsxs)(`div`,{className:`mb-2 px-3 py-2 text-xs rounded-md border border-yellow-500/30 bg-yellow-500/10 text-yellow-500`,children:[(0,G.jsx)(`div`,{className:`font-medium mb-1`,children:`Untargeted agents in the chain`}),(0,G.jsxs)(`div`,{children:[`No routing rule points to: `,(0,G.jsx)(`span`,{className:`font-mono`,children:E.join(`, `)}),`. Add a tag rule or retarget the default rule if you want them to run.`]})]}),(0,G.jsx)(`div`,{className:`space-y-1.5`,children:e.routing.map((t,n)=>{let r=`default`in t&&t.default===!0;return(0,G.jsx)(ae,{rule:t,ordinal:n+1,isLast:n===e.routing.length-1,canMove:!r,canRemove:!r,canEdit:!r,chainAgents:e.agents.map(e=>e.id),onAgentChange:e=>te(n,e),onEdit:()=>b(n),onUp:()=>U(n,-1),onDown:()=>U(n,1),onRemove:()=>ne(n)},n)})})]}),n&&(0,G.jsx)(`div`,{className:`pt-3 border-t border-border`,children:n})]})}function X({agent:e,canRemove:t,onModel:n,onRemove:r}){let i=q.has(e.id),a=e.id===`sr-architect`,s=e.id===`sr-merge-resolver`,{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:p,isDragging:m}=h({id:e.id});return(0,G.jsxs)(`div`,{ref:u,style:{transform:o.Transform.toString(d),transition:p,opacity:m?.5:void 0,zIndex:m?10:void 0},className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors bg-background`,children:[(0,G.jsx)(`button`,{type:`button`,className:`flex-shrink-0 p-0.5 rounded text-muted-foreground cursor-grab active:cursor-grabbing hover:text-foreground`,title:`Drag to reorder`,"aria-label":`Drag handle`,...c,...l,children:(0,G.jsx)(C,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`span`,{className:`text-sm font-mono flex-1 truncate`,children:e.id}),a&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-dracula-purple/15 text-dracula-purple`,title:`Pinned to first position — pipeline always starts with sr-architect`,children:[(0,G.jsx)(H,{className:`w-2.5 h-2.5 rotate-[135deg]`}),` first`]}),s&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-dracula-purple/15 text-dracula-purple`,title:`Pinned to last position — merge phase always runs last`,children:[(0,G.jsx)(H,{className:`w-2.5 h-2.5 rotate-45`}),` last`]}),i&&!a&&!s&&(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:`required`}),(0,G.jsx)(oe,{value:e.model??`sonnet`,onChange:n}),(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 rounded disabled:opacity-30 disabled:cursor-not-allowed opacity-0 group-hover:opacity-100 transition-opacity`,onClick:r,disabled:!t,title:t?`Remove`:`Required baseline agent — the pipeline depends on this row`,children:(0,G.jsx)(f,{className:`w-3 h-3`})})]})}function ae({rule:e,ordinal:t,isLast:n,canMove:r,canRemove:i,canEdit:a,chainAgents:o,onAgentChange:s,onEdit:c,onUp:l,onDown:u,onRemove:d}){let p=`default`in e&&e.default===!0;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground w-5 text-center flex-shrink-0`,children:[t,`.`]}),p?(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:`everything else`}):(0,G.jsx)(`span`,{className:`text-xs flex-1 flex gap-1 flex-wrap items-center`,children:e.tags.map(e=>(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-muted font-mono text-[11px]`,children:e},e))}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),p?(0,G.jsx)(`span`,{className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-muted/40 text-muted-foreground inline-flex items-center`,"aria-label":`Default routing target (core, read-only)`,title:`Core fallback — not editable`,children:e.agent}):(0,G.jsx)(`select`,{value:e.agent,onChange:e=>s(e.target.value),"aria-label":`Routing target for rule ${t}`,className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-background`,children:o.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[a&&(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:c,title:`Edit rule`,"aria-label":`Edit rule ${t}`,children:(0,G.jsx)(b,{className:`w-3 h-3`})}),r&&!n&&(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:u,title:`Move down`,children:(0,G.jsx)(z,{className:`w-3 h-3`})}),r&&t>1&&(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:l,title:`Move up`,children:(0,G.jsx)(B,{className:`w-3 h-3`})}),i&&(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 rounded`,onClick:d,title:`Remove`,children:(0,G.jsx)(f,{className:`w-3 h-3`})})]}),p&&(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,title:`Core fallback — the pipeline's last-resort rule, pinned to sr-developer`,children:`core · default`})]})}function oe({value:e,onChange:t}){return(0,G.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-7 px-2 text-xs rounded border border-border bg-background`,children:J.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})}function se({open:e,title:t,description:n,placeholder:r,initialValue:i=``,confirmLabel:a=`Confirm`,inputPattern:o,inputInvalidHint:s,onConfirm:c,onCancel:l}){let[u,d]=(0,W.useState)(i);(0,W.useEffect)(()=>{e&&d(i)},[e,i]);let f=u.trim(),p=!o||o.test(f),m=f.length>0&&p;return(0,G.jsx)(w,{open:e,onOpenChange:e=>{e||l()},children:(0,G.jsxs)(M,{className:`max-w-md`,children:[(0,G.jsx)(T,{children:(0,G.jsx)(x,{children:t})}),(0,G.jsxs)(`div`,{className:`py-2 space-y-2`,children:[n&&(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}),(0,G.jsx)(j,{autoFocus:!0,value:u,placeholder:r,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m&&c(f)},className:`text-sm font-mono`}),f.length>0&&!p&&s&&(0,G.jsx)(`p`,{className:`text-[11px] text-yellow-500`,children:s})]}),(0,G.jsxs)(E,{children:[(0,G.jsx)(R,{variant:`ghost`,size:`sm`,onClick:l,children:`Cancel`}),(0,G.jsx)(R,{size:`sm`,onClick:()=>c(f),disabled:!m,children:a})]})]})})}function ce({open:e,title:t,description:n,confirmLabel:r=`Confirm`,destructive:i=!1,onConfirm:a,onCancel:o}){return(0,G.jsx)(w,{open:e,onOpenChange:e=>{e||o()},children:(0,G.jsxs)(M,{className:`max-w-md`,children:[(0,G.jsx)(T,{children:(0,G.jsx)(x,{children:t})}),n&&(0,G.jsx)(`div`,{className:`py-2`,children:(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})}),(0,G.jsxs)(E,{children:[(0,G.jsx)(R,{variant:`ghost`,size:`sm`,onClick:o,children:`Cancel`}),(0,G.jsx)(R,{size:`sm`,onClick:a,className:i?`bg-red-500 hover:bg-red-600 text-white`:void 0,children:r})]})]})})}function le(){let[e,t]=(0,W.useState)([]),[n,r]=(0,W.useState)(null),[a,o]=(0,W.useState)(null),[c,l]=(0,W.useState)(!0),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)([]),[g,_]=(0,W.useState)([]),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),E=(0,W.useCallback)(async()=>{l(!0),d(null);try{let e=await fetch(`${s()}/profiles`);if(!e.ok)throw Error(`List failed: ${e.status}`);let i=await e.json();t(i.profiles),i.profiles.length>0&&!n&&r(i.profiles[0].name)}catch(e){d(e.message)}finally{l(!1)}},[n]);(0,W.useEffect)(()=>{E()},[E]),(0,W.useEffect)(()=>{if(!n){o(null);return}let e=!1;return fetch(`${s()}/profiles/${encodeURIComponent(n)}`).then(e=>{if(!e.ok)throw Error(`Load failed: ${e.status}`);return e.json()}).then(t=>{e||o(t.profile)}).catch(t=>{e||d(t.message)}),()=>{e=!0}},[n]);let D=(0,W.useCallback)(async()=>{p(!0),d(null);try{let e=await fetch(`${s()}/profiles/migrate-from-settings`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Migration failed: ${e.status}`)}await E(),r(`default`),A.success(`Profile migrated`,{description:`default profile created from your current agents`})}catch(e){let t=e.message;d(t),A.error(`Migration failed`,{description:t})}finally{p(!1)}},[E]),O=(0,W.useCallback)(async e=>{x(!1),p(!0),d(null);try{let t={schemaVersion:1,name:e,description:``,orchestrator:{model:`sonnet`},agents:[{id:`sr-architect`,model:`sonnet`,required:!0},{id:`sr-developer`,model:`sonnet`,required:!0},{id:`sr-reviewer`,model:`sonnet`,required:!0},{id:`sr-merge-resolver`,model:`sonnet`,required:!0}],routing:[{default:!0,agent:`sr-developer`}]},n=await fetch(`${s()}/profiles`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`Create failed: ${n.status}`)}await E(),r(e),A.success(`Profile created`,{description:e})}catch(e){let t=e.message;d(t),A.error(`Failed to create profile`,{description:t})}finally{p(!1)}},[E]),k=(0,W.useCallback)(async(e,t)=>{C(null),p(!0),d(null);try{let n=await fetch(`${s()}/profiles/${encodeURIComponent(e)}/duplicate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`Duplicate failed: ${n.status}`)}await E(),r(t),A.success(`Profile duplicated`,{description:`${e} → ${t}`})}catch(e){let t=e.message;d(t),A.error(`Failed to duplicate profile`,{description:t})}finally{p(!1)}},[E]),j=(0,W.useCallback)(async e=>{T(null),p(!0),d(null);try{let t=await fetch(`${s()}/profiles/${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Delete failed: ${t.status}`)}r(t=>t===e?null:t),await E(),A.success(`Profile deleted`,{description:e})}catch(e){let t=e.message;d(t),A.error(`Failed to delete profile`,{description:t})}finally{p(!1)}},[E]),M=(0,W.useCallback)(()=>x(!0),[]),P=(0,W.useCallback)(e=>C({from:e}),[]),F=(0,W.useCallback)(e=>T({name:e}),[]),I=(0,W.useCallback)(async(e,t)=>{p(!0),d(null);try{let n=await fetch(`${s()}/profiles/${encodeURIComponent(e.name)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`Save failed: ${n.status}`)}o(e),t.length>0?A.warning(`Profile saved with untargeted agents`,{description:`No routing rule points to: ${t.join(`, `)}. Add a tag rule or retarget the default rule if you want them to run.`,duration:6e3}):A.success(`Profile saved`,{description:e.name})}catch(e){let t=e.message;d(t),A.error(`Failed to save profile`,{description:t})}finally{p(!1)}},[]),L=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(se,{open:b,title:`New profile`,description:`Pick a lowercase kebab-case name (letters, digits, and hyphens).`,placeholder:`my-profile`,confirmLabel:`Create`,inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:`Must start with a letter or digit and contain only lowercase letters, digits, and hyphens.`,onConfirm:e=>void O(e),onCancel:()=>x(!1)}),S&&(0,G.jsx)(se,{open:!0,title:`Duplicate "${S.from}"`,description:`Name for the new profile.`,placeholder:`${S.from}-copy`,initialValue:`${S.from}-copy`,confirmLabel:`Duplicate`,inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:`Lowercase kebab-case only.`,onConfirm:e=>void k(S.from,e),onCancel:()=>C(null)}),w&&(0,G.jsx)(ce,{open:!0,title:`Delete profile "${w.name}"?`,description:`This cannot be undone. Jobs already launched with this profile keep their snapshot; future launches will fall back to the resolution order.`,confirmLabel:`Delete`,destructive:!0,onConfirm:()=>void j(w.name),onCancel:()=>T(null)})]});return c?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading profiles…`})}):e.length===0?(0,G.jsxs)(G.Fragment,{children:[L,(0,G.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,G.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`No profiles yet`}),(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1 mb-4`,children:`Profiles let you save orchestrator + agent + routing combinations and pick one per rail.`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 justify-center`,children:[(0,G.jsxs)(R,{size:`sm`,onClick:D,disabled:f,children:[(0,G.jsx)(U,{className:`w-3.5 h-3.5 mr-1.5`}),` Migrate from current agents`]}),(0,G.jsxs)(R,{size:`sm`,variant:`ghost`,onClick:M,disabled:f,children:[(0,G.jsx)(y,{className:`w-3.5 h-3.5 mr-1.5`}),` Blank profile`]})]}),(0,G.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-3`,children:[`"Migrate" reads your existing `,(0,G.jsx)(`code`,{className:`text-foreground`,children:`.claude/agents/`}),` `,`frontmatter models and creates a `,(0,G.jsx)(`code`,{className:`text-foreground`,children:`default`}),` profile mirroring today's behavior — zero-loss.`]}),u&&(0,G.jsx)(`div`,{className:`mt-3 text-xs text-red-400`,children:u})]})})]}):(0,G.jsxs)(`div`,{className:`flex flex-col h-full`,children:[L,(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,G.jsxs)(`aside`,{className:`w-64 flex-shrink-0 border-r border-border flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`p-3 flex items-center justify-between`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Profiles`}),(0,G.jsx)(R,{size:`sm`,variant:`ghost`,onClick:M,disabled:f,children:(0,G.jsx)(y,{className:`w-3.5 h-3.5`})})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-auto px-2 pb-3`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`group mb-1 rounded-md px-2 py-1.5 text-xs cursor-pointer transition-colors flex items-center justify-between `+(e.name===n?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>r(e.name),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&r(e.name)},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,G.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),e.isDefault&&(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`(team default)`})]}),(0,G.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,title:`Duplicate`,onClick:t=>{t.stopPropagation(),P(e.name)},children:(0,G.jsx)(i,{className:`w-3 h-3`})}),!e.isDefault&&(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 rounded`,title:`Delete`,onClick:t=>{t.stopPropagation(),F(e.name)},children:(0,G.jsx)(v,{className:`w-3 h-3`})})]})]},e.name))})]}),(0,G.jsxs)(`main`,{className:`flex-1 overflow-auto`,children:[u&&(0,G.jsx)(`div`,{className:`mx-4 mt-4 px-3 py-2 text-xs rounded border border-red-500/30 bg-red-500/10 text-red-400`,children:u}),a?(0,G.jsx)(ie,{profile:a,onChange:o,onValidityChange:h,onSoftWarningsChange:e=>_(e.agentsMissingRouting),footer:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(R,{size:`sm`,onClick:()=>void I(a,g),disabled:f||m.length>0,title:m.length>0?`Fix validation issues before saving`:void 0,children:[(0,G.jsx)(N,{className:`w-3.5 h-3.5 mr-1.5`}),`Save`]}),f&&(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving…`}),m.length>0&&(0,G.jsxs)(`span`,{className:`text-xs text-yellow-500`,children:[m.length,` `,m.length===1?`issue`:`issues`,` to resolve`]})]})},a.name):(0,G.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a profile to edit`})})]})]})]})}function Z(e){let t=e.workflow.map((e,t)=>`${t+1}. ${e}`).join(`
1
+ import{n as e,o as t,r as n,t as r}from"./createLucideIcon-Cg9402G2.js";import{t as i}from"./copy-C1m2IjcW.js";import{$ as a,A as o,B as s,C as c,D as l,E as u,G as d,H as f,K as p,O as m,S as h,T as g,U as _,W as v,X as y,Z as b,_ as x,b as S,et as C,f as w,g as T,h as E,k as D,lt as O,m as k,mt as A,n as j,p as M,q as N,tt as P,w as F,x as I,y as L,z as R}from"./index-W5VPSfMl.js";var z=r(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),B=r(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),ee=r(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),V=r(`flask-conical`,[[`path`,{d:`M14 2v6a2 2 0 0 0 .245.96l5.51 10.08A2 2 0 0 1 18 22H6a2 2 0 0 1-1.755-2.96l5.51-10.08A2 2 0 0 0 10 8V2`,key:`18mbvz`}],[`path`,{d:`M6.453 15h11.094`,key:`3shlmq`}],[`path`,{d:`M8.5 2h7`,key:`csnxdl`}]]),te=r(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),H=r(`pin`,[[`path`,{d:`M12 17v5`,key:`bb1du9`}],[`path`,{d:`M9 10.76a2 2 0 0 1-1.11 1.79l-1.78.9A2 2 0 0 0 5 15.24V16a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-.76a2 2 0 0 0-1.11-1.79l-1.78-.9A2 2 0 0 1 15 10.76V7a1 1 0 0 1 1-1 2 2 0 0 0 0-4H8a2 2 0 0 0 0 4 1 1 0 0 1 1 1z`,key:`1nkz8b`}]]),ne=r(`tag`,[[`path`,{d:`M12.586 2.586A2 2 0 0 0 11.172 2H4a2 2 0 0 0-2 2v7.172a2 2 0 0 0 .586 1.414l8.704 8.704a2.426 2.426 0 0 0 3.42 0l6.58-6.58a2.426 2.426 0 0 0 0-3.42z`,key:`vktsd0`}],[`circle`,{cx:`7.5`,cy:`7.5`,r:`.5`,fill:`currentColor`,key:`kqv944`}]]),U=r(`wand-sparkles`,[[`path`,{d:`m21.64 3.64-1.28-1.28a1.21 1.21 0 0 0-1.72 0L2.36 18.64a1.21 1.21 0 0 0 0 1.72l1.28 1.28a1.2 1.2 0 0 0 1.72 0L21.64 5.36a1.2 1.2 0 0 0 0-1.72`,key:`ul74o6`}],[`path`,{d:`m14 7 3 3`,key:`1r5n42`}],[`path`,{d:`M5 6v4`,key:`ilb8ba`}],[`path`,{d:`M19 14v4`,key:`blhpug`}],[`path`,{d:`M10 2v2`,key:`7u0qdc`}],[`path`,{d:`M7 8H3`,key:`zfb6yr`}],[`path`,{d:`M21 16h-4`,key:`1cnmox`}],[`path`,{d:`M11 3H9`,key:`1obp7u`}]]),W=t(n(),1),G=e(),re=/^[a-z0-9][a-z0-9-]*$/;function K({open:e,mode:t=`add`,initial:n,chainAgents:r,onConfirm:i,onCancel:a}){let[o,s]=(0,W.useState)(``),[c,l]=(0,W.useState)(r[0]??``);(0,W.useEffect)(()=>{e&&(t===`edit`&&n?(s(n.tags.join(`, `)),l(r.includes(n.agent)?n.agent:r[0]??``)):(s(``),l(r[0]??``)))},[e,t,n,r]);let u=o.split(`,`).map(e=>e.trim()).filter(Boolean),d=u.filter(e=>!re.test(e)),f=u.length>0&&d.length===0&&r.includes(c);return(0,G.jsx)(w,{open:e,onOpenChange:e=>{e||a()},children:(0,G.jsxs)(M,{className:`max-w-md`,children:[(0,G.jsxs)(T,{children:[(0,G.jsx)(x,{children:t===`edit`?`Edit routing rule`:`Add routing rule`}),(0,G.jsx)(k,{children:t===`edit`?`Update the tags or target agent for this rule.`:`Add a tag-matched routing rule using lowercase kebab-case tags.`})]}),(0,G.jsxs)(`div`,{className:`py-2 space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Tags`}),(0,G.jsx)(j,{autoFocus:!0,value:o,onChange:e=>s(e.target.value),placeholder:`frontend, ui`,"aria-label":`Tags`,className:`text-sm font-mono`}),(0,G.jsxs)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:[`Comma-separated. Use lowercase kebab-case like `,(0,G.jsx)(`code`,{children:`frontend`}),` or `,(0,G.jsx)(`code`,{children:`api-design`}),`.`]}),d.length>0&&(0,G.jsxs)(`p`,{className:`text-[11px] text-red-400 mt-1`,children:[`Invalid tag`,d.length===1?``:`s`,`: `,d.join(`, `),`. Tags must use lowercase letters, digits, and hyphens only.`]})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Route to`}),(0,G.jsx)(`select`,{value:c,onChange:e=>l(e.target.value),"aria-label":`Route to`,className:`w-full h-9 px-2 text-sm rounded-md border border-border bg-background`,children:r.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:`Only agents in this profile's chain can be routing targets.`})]})]}),(0,G.jsxs)(E,{children:[(0,G.jsx)(R,{variant:`ghost`,size:`sm`,onClick:a,children:`Cancel`}),(0,G.jsx)(R,{size:`sm`,onClick:()=>i(u,c),disabled:!f,children:t===`edit`?`Save changes`:`Add rule`})]})]})})}var q=new Set([`sr-architect`,`sr-developer`,`sr-reviewer`,`sr-merge-resolver`]),J=[`sonnet`,`opus`,`haiku`],Y=/^[a-z0-9][a-z0-9-]*$/;function ie({profile:e,onChange:t,footer:n,onValidityChange:r,onSoftWarningsChange:i}){let[a,o]=(0,W.useState)([]),[d,p]=(0,W.useState)(!1),[h,_]=(0,W.useState)(!1),[v,b]=(0,W.useState)(null);(0,W.useEffect)(()=>{let e=!1;return fetch(`${s()}/profiles/catalog`).then(e=>e.ok?e.json():{agents:[]}).then(t=>{e||o(t.agents)}).catch(()=>{e||o([])}),()=>{e=!0}},[]);let x=n=>{let r=JSON.parse(JSON.stringify(e));n(r),t(r)},C=new Set(e.agents.map(e=>e.id)),w=a.filter(e=>!C.has(e.id)),T=(0,W.useMemo)(()=>{let t=[];for(let n of q)e.agents.some(e=>e.id===n)||t.push(`Missing required baseline agent: ${n}`);let n=e.routing.filter(e=>`default`in e&&e.default===!0);if(n.length>1&&t.push(`Routing may have at most one default rule (found ${n.length})`),n.length===1){let n=e.routing[e.routing.length-1];`default`in n&&n.default===!0||t.push(`The default routing rule must be the last entry`)}for(let n of e.routing)if(e.agents.some(e=>e.id===n.agent)||t.push(`Routing references agent not in the chain: ${n.agent}`),`tags`in n){let e=n.tags.filter(e=>!Y.test(e));e.length>0&&t.push(`Routing rule ${n.agent} has invalid tags: ${e.join(`, `)} (use lowercase kebab-case)`)}return t},[e]),E=(0,W.useMemo)(()=>{if(e.routing.length===0)return[];let t=new Set(e.routing.map(e=>e.agent));return e.agents.filter(e=>!q.has(e.id)&&!t.has(e.id)).map(e=>e.id)},[e]),O=(0,W.useMemo)(()=>e.routing.some(e=>`default`in e&&e.default===!0),[e.routing]);(0,W.useEffect)(()=>{r&&r(T)},[T,r]),(0,W.useEffect)(()=>{i&&i({agentsMissingRouting:E})},[E,i]);let k=e=>{x(t=>{let n={id:e,model:`sonnet`},r=t.agents.findIndex(e=>e.id===`sr-merge-resolver`);r>=0?t.agents.splice(r,0,n):t.agents.push(n)}),p(!1)},A=t=>{let n=e.agents[t];q.has(n.id)||x(e=>{e.agents.splice(t,1),e.routing=e.routing.filter(e=>e.agent!==n.id)})},M=(t,n)=>{if(t===n)return;let r=e.agents.findIndex(e=>e.id===t),i=e.agents.findIndex(e=>e.id===n);if(r<0||i<0)return;let a=S(e.agents,r,i),o=a.findIndex(e=>e.id===`sr-architect`);if(o>0){let[e]=a.splice(o,1);a.unshift(e)}let s=a.findIndex(e=>e.id===`sr-merge-resolver`);if(s>=0&&s!==a.length-1){let[e]=a.splice(s,1);a.push(e)}x(e=>{e.agents=a})},N=D(m(u,{activationConstraint:{distance:4}}),m(g,{coordinateGetter:I})),P=e=>{let{active:t,over:n}=e;n&&M(String(t.id),String(n.id))},z=(e,t)=>{x(n=>{n.agents[e].model=t})},B=(e,t)=>{x(n=>{let r={tags:e,agent:t},i=n.routing.findIndex(e=>`default`in e&&e.default===!0);i>=0?n.routing.splice(i,0,r):n.routing.push(r)}),_(!1)},ee=()=>{x(e=>{e.routing.some(e=>`default`in e&&e.default===!0)||e.agents.some(e=>e.id===`sr-developer`)&&e.routing.push({default:!0,agent:`sr-developer`})})},V=e=>`default`in e&&e.default===!0,te=(e,t)=>{x(n=>{let r=n.routing[e];r&&(V(r)||(r.agent=t))})},H=(e,t,n)=>{x(r=>{let i=r.routing[e];i&&(V(i)||(i.tags=t,i.agent=n))})},ne=e=>{x(t=>{let n=t.routing[e];n&&(V(n)||t.routing.splice(e,1))})},U=(t,n)=>{let r=t+n;if(r<0||r>=e.routing.length)return;let i=e.routing[t],a=e.routing[r];V(i)||V(a)||x(e=>{let[n]=e.routing.splice(t,1);e.routing.splice(r,0,n)})};return(0,G.jsxs)(`div`,{className:`p-6 space-y-6 max-w-3xl`,children:[(0,G.jsx)(K,{open:h,mode:`add`,chainAgents:e.agents.map(e=>e.id),onConfirm:B,onCancel:()=>_(!1)}),(0,G.jsx)(K,{open:v!==null,mode:`edit`,initial:v!==null&&e.routing[v]&&!(`default`in e.routing[v])?{tags:e.routing[v].tags,agent:e.routing[v].agent}:void 0,chainAgents:e.agents.map(e=>e.id),onConfirm:(e,t)=>{v!==null&&(H(v,e,t),b(null))},onCancel:()=>b(null)}),T.length>0&&(0,G.jsxs)(`div`,{className:`px-3 py-2 text-xs rounded-md border border-yellow-500/30 bg-yellow-500/10 text-yellow-500`,children:[(0,G.jsxs)(`div`,{className:`font-medium mb-1`,children:[T.length,` validation `,T.length===1?`issue`:`issues`]}),(0,G.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:T.map((e,t)=>(0,G.jsx)(`li`,{children:e},t))})]}),(0,G.jsxs)(`section`,{className:`space-y-3`,children:[(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Name`}),(0,G.jsx)(j,{value:e.name,disabled:!0,className:`text-sm`})]}),(0,G.jsxs)(`div`,{children:[(0,G.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Description`}),(0,G.jsx)(j,{value:e.description??``,onChange:e=>x(t=>{t.description=e.target.value}),className:`text-sm`,placeholder:`What is this profile for?`})]})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2`,children:`Orchestrator`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-md border border-border`,children:[(0,G.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,G.jsx)(`div`,{className:`text-sm font-mono text-foreground truncate`,children:`/specrails:implement · /specrails:batch-implement`}),(0,G.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:`Top-level model for both commands. batch-implement delegates to implement per feature, so every rail it spawns inherits this profile's agent chain.`})]}),(0,G.jsx)(oe,{value:e.orchestrator.model,onChange:e=>x(t=>{t.orchestrator.model=e})})]})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[`Agent chain (`,e.agents.length,`)`]}),(0,G.jsxs)(R,{size:`sm`,variant:`ghost`,onClick:()=>p(e=>!e),disabled:w.length===0,title:w.length===0?`All catalog agents are already in the chain`:`Add an agent from the catalog`,children:[(0,G.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` Add`]})]}),d&&(0,G.jsxs)(`div`,{className:`mb-2 p-2 rounded-md border border-border bg-muted/30`,children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 px-1`,children:[(0,G.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`Pick from catalog (`,w.length,` available)`]}),(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:()=>p(!1),title:`Close`,children:(0,G.jsx)(f,{className:`w-3 h-3`})})]}),w.length===0?(0,G.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:`No more agents in the catalog. Add custom agents from the Agents Catalog tab.`}):(0,G.jsx)(`div`,{className:`space-y-0.5 max-h-64 overflow-auto`,children:w.map(e=>(0,G.jsxs)(`button`,{type:`button`,onClick:()=>k(e.id),className:`w-full flex items-center justify-between gap-2 px-2 py-1.5 text-left rounded hover:bg-accent transition-colors`,children:[(0,G.jsx)(`span`,{className:`text-sm font-mono`,children:e.id}),(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded `+(e.kind===`custom`?`bg-purple-500/15 text-purple-400`:`bg-muted text-muted-foreground`),children:e.kind})]},e.id))})]}),(0,G.jsx)(F,{sensors:N,collisionDetection:l,onDragEnd:P,children:(0,G.jsx)(L,{items:e.agents.map(e=>e.id),strategy:c,children:(0,G.jsx)(`div`,{className:`space-y-1.5`,children:e.agents.map((e,t)=>(0,G.jsx)(X,{agent:e,canRemove:!q.has(e.id),onModel:e=>z(t,e),onRemove:()=>A(t)},e.id))})})})]}),(0,G.jsxs)(`section`,{children:[(0,G.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,G.jsxs)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[`Routing (`,e.routing.length,`)`]}),(0,G.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!O&&(0,G.jsxs)(R,{size:`sm`,variant:`ghost`,onClick:ee,disabled:e.agents.length===0,title:e.agents.length===0?`Add at least one agent before creating routing rules`:void 0,children:[(0,G.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` Add default`]}),(0,G.jsxs)(R,{size:`sm`,variant:`ghost`,onClick:()=>_(!0),disabled:e.agents.length===0,title:e.agents.length===0?`Add at least one agent before creating routing rules`:void 0,children:[(0,G.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` Add rule`]})]})]}),(0,G.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-2`,children:`First matching rule wins. Rules are editable and removable, and the default catch-all stays last when present. If you leave routing empty, the pipeline falls back to the first developer-shaped agent in the chain.`}),E.length>0&&(0,G.jsxs)(`div`,{className:`mb-2 px-3 py-2 text-xs rounded-md border border-yellow-500/30 bg-yellow-500/10 text-yellow-500`,children:[(0,G.jsx)(`div`,{className:`font-medium mb-1`,children:`Untargeted agents in the chain`}),(0,G.jsxs)(`div`,{children:[`No routing rule points to: `,(0,G.jsx)(`span`,{className:`font-mono`,children:E.join(`, `)}),`. Add a tag rule or retarget the default rule if you want them to run.`]})]}),(0,G.jsx)(`div`,{className:`space-y-1.5`,children:e.routing.map((t,n)=>{let r=`default`in t&&t.default===!0;return(0,G.jsx)(ae,{rule:t,ordinal:n+1,isLast:n===e.routing.length-1,canMove:!r,canRemove:!r,canEdit:!r,chainAgents:e.agents.map(e=>e.id),onAgentChange:e=>te(n,e),onEdit:()=>b(n),onUp:()=>U(n,-1),onDown:()=>U(n,1),onRemove:()=>ne(n)},n)})})]}),n&&(0,G.jsx)(`div`,{className:`pt-3 border-t border-border`,children:n})]})}function X({agent:e,canRemove:t,onModel:n,onRemove:r}){let i=q.has(e.id),a=e.id===`sr-architect`,s=e.id===`sr-merge-resolver`,{attributes:c,listeners:l,setNodeRef:u,transform:d,transition:p,isDragging:m}=h({id:e.id});return(0,G.jsxs)(`div`,{ref:u,style:{transform:o.Transform.toString(d),transition:p,opacity:m?.5:void 0,zIndex:m?10:void 0},className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors bg-background`,children:[(0,G.jsx)(`button`,{type:`button`,className:`flex-shrink-0 p-0.5 rounded text-muted-foreground cursor-grab active:cursor-grabbing hover:text-foreground`,title:`Drag to reorder`,"aria-label":`Drag handle`,...c,...l,children:(0,G.jsx)(C,{className:`w-3.5 h-3.5`})}),(0,G.jsx)(`span`,{className:`text-sm font-mono flex-1 truncate`,children:e.id}),a&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-dracula-purple/15 text-dracula-purple`,title:`Pinned to first position — pipeline always starts with sr-architect`,children:[(0,G.jsx)(H,{className:`w-2.5 h-2.5 rotate-[135deg]`}),` first`]}),s&&(0,G.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-dracula-purple/15 text-dracula-purple`,title:`Pinned to last position — merge phase always runs last`,children:[(0,G.jsx)(H,{className:`w-2.5 h-2.5 rotate-45`}),` last`]}),i&&!a&&!s&&(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:`required`}),(0,G.jsx)(oe,{value:e.model??`sonnet`,onChange:n}),(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 rounded disabled:opacity-30 disabled:cursor-not-allowed opacity-0 group-hover:opacity-100 transition-opacity`,onClick:r,disabled:!t,title:t?`Remove`:`Required baseline agent — the pipeline depends on this row`,children:(0,G.jsx)(f,{className:`w-3 h-3`})})]})}function ae({rule:e,ordinal:t,isLast:n,canMove:r,canRemove:i,canEdit:a,chainAgents:o,onAgentChange:s,onEdit:c,onUp:l,onDown:u,onRemove:d}){let p=`default`in e&&e.default===!0;return(0,G.jsxs)(`div`,{className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors`,children:[(0,G.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground w-5 text-center flex-shrink-0`,children:[t,`.`]}),p?(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:`everything else`}):(0,G.jsx)(`span`,{className:`text-xs flex-1 flex gap-1 flex-wrap items-center`,children:e.tags.map(e=>(0,G.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-muted font-mono text-[11px]`,children:e},e))}),(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),p?(0,G.jsx)(`span`,{className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-muted/40 text-muted-foreground inline-flex items-center`,"aria-label":`Default routing target (core, read-only)`,title:`Core fallback — not editable`,children:e.agent}):(0,G.jsx)(`select`,{value:e.agent,onChange:e=>s(e.target.value),"aria-label":`Routing target for rule ${t}`,className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-background`,children:o.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))}),(0,G.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[a&&(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:c,title:`Edit rule`,"aria-label":`Edit rule ${t}`,children:(0,G.jsx)(b,{className:`w-3 h-3`})}),r&&!n&&(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:u,title:`Move down`,children:(0,G.jsx)(z,{className:`w-3 h-3`})}),r&&t>1&&(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:l,title:`Move up`,children:(0,G.jsx)(B,{className:`w-3 h-3`})}),i&&(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 rounded`,onClick:d,title:`Remove`,children:(0,G.jsx)(f,{className:`w-3 h-3`})})]}),p&&(0,G.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,title:`Core fallback — the pipeline's last-resort rule, pinned to sr-developer`,children:`core · default`})]})}function oe({value:e,onChange:t}){return(0,G.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-7 px-2 text-xs rounded border border-border bg-background`,children:J.map(e=>(0,G.jsx)(`option`,{value:e,children:e},e))})}function se({open:e,title:t,description:n,placeholder:r,initialValue:i=``,confirmLabel:a=`Confirm`,inputPattern:o,inputInvalidHint:s,onConfirm:c,onCancel:l}){let[u,d]=(0,W.useState)(i);(0,W.useEffect)(()=>{e&&d(i)},[e,i]);let f=u.trim(),p=!o||o.test(f),m=f.length>0&&p;return(0,G.jsx)(w,{open:e,onOpenChange:e=>{e||l()},children:(0,G.jsxs)(M,{className:`max-w-md`,children:[(0,G.jsx)(T,{children:(0,G.jsx)(x,{children:t})}),(0,G.jsxs)(`div`,{className:`py-2 space-y-2`,children:[n&&(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}),(0,G.jsx)(j,{autoFocus:!0,value:u,placeholder:r,onChange:e=>d(e.target.value),onKeyDown:e=>{e.key===`Enter`&&m&&c(f)},className:`text-sm font-mono`}),f.length>0&&!p&&s&&(0,G.jsx)(`p`,{className:`text-[11px] text-yellow-500`,children:s})]}),(0,G.jsxs)(E,{children:[(0,G.jsx)(R,{variant:`ghost`,size:`sm`,onClick:l,children:`Cancel`}),(0,G.jsx)(R,{size:`sm`,onClick:()=>c(f),disabled:!m,children:a})]})]})})}function ce({open:e,title:t,description:n,confirmLabel:r=`Confirm`,destructive:i=!1,onConfirm:a,onCancel:o}){return(0,G.jsx)(w,{open:e,onOpenChange:e=>{e||o()},children:(0,G.jsxs)(M,{className:`max-w-md`,children:[(0,G.jsx)(T,{children:(0,G.jsx)(x,{children:t})}),n&&(0,G.jsx)(`div`,{className:`py-2`,children:(0,G.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})}),(0,G.jsxs)(E,{children:[(0,G.jsx)(R,{variant:`ghost`,size:`sm`,onClick:o,children:`Cancel`}),(0,G.jsx)(R,{size:`sm`,onClick:a,className:i?`bg-red-500 hover:bg-red-600 text-white`:void 0,children:r})]})]})})}function le(){let[e,t]=(0,W.useState)([]),[n,r]=(0,W.useState)(null),[a,o]=(0,W.useState)(null),[c,l]=(0,W.useState)(!0),[u,d]=(0,W.useState)(null),[f,p]=(0,W.useState)(!1),[m,h]=(0,W.useState)([]),[g,_]=(0,W.useState)([]),[b,x]=(0,W.useState)(!1),[S,C]=(0,W.useState)(null),[w,T]=(0,W.useState)(null),E=(0,W.useCallback)(async()=>{l(!0),d(null);try{let e=await fetch(`${s()}/profiles`);if(!e.ok)throw Error(`List failed: ${e.status}`);let i=await e.json();t(i.profiles),i.profiles.length>0&&!n&&r(i.profiles[0].name)}catch(e){d(e.message)}finally{l(!1)}},[n]);(0,W.useEffect)(()=>{E()},[E]),(0,W.useEffect)(()=>{if(!n){o(null);return}let e=!1;return fetch(`${s()}/profiles/${encodeURIComponent(n)}`).then(e=>{if(!e.ok)throw Error(`Load failed: ${e.status}`);return e.json()}).then(t=>{e||o(t.profile)}).catch(t=>{e||d(t.message)}),()=>{e=!0}},[n]);let D=(0,W.useCallback)(async()=>{p(!0),d(null);try{let e=await fetch(`${s()}/profiles/migrate-from-settings`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Migration failed: ${e.status}`)}await E(),r(`default`),A.success(`Profile migrated`,{description:`default profile created from your current agents`})}catch(e){let t=e.message;d(t),A.error(`Migration failed`,{description:t})}finally{p(!1)}},[E]),O=(0,W.useCallback)(async e=>{x(!1),p(!0),d(null);try{let t={schemaVersion:1,name:e,description:``,orchestrator:{model:`sonnet`},agents:[{id:`sr-architect`,model:`sonnet`,required:!0},{id:`sr-developer`,model:`sonnet`,required:!0},{id:`sr-reviewer`,model:`sonnet`,required:!0},{id:`sr-merge-resolver`,model:`sonnet`,required:!0}],routing:[{default:!0,agent:`sr-developer`}]},n=await fetch(`${s()}/profiles`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`Create failed: ${n.status}`)}await E(),r(e),A.success(`Profile created`,{description:e})}catch(e){let t=e.message;d(t),A.error(`Failed to create profile`,{description:t})}finally{p(!1)}},[E]),k=(0,W.useCallback)(async(e,t)=>{C(null),p(!0),d(null);try{let n=await fetch(`${s()}/profiles/${encodeURIComponent(e)}/duplicate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:t})});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`Duplicate failed: ${n.status}`)}await E(),r(t),A.success(`Profile duplicated`,{description:`${e} → ${t}`})}catch(e){let t=e.message;d(t),A.error(`Failed to duplicate profile`,{description:t})}finally{p(!1)}},[E]),j=(0,W.useCallback)(async e=>{T(null),p(!0),d(null);try{let t=await fetch(`${s()}/profiles/${encodeURIComponent(e)}`,{method:`DELETE`});if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.error??`Delete failed: ${t.status}`)}r(t=>t===e?null:t),await E(),A.success(`Profile deleted`,{description:e})}catch(e){let t=e.message;d(t),A.error(`Failed to delete profile`,{description:t})}finally{p(!1)}},[E]),M=(0,W.useCallback)(()=>x(!0),[]),P=(0,W.useCallback)(e=>C({from:e}),[]),F=(0,W.useCallback)(e=>T({name:e}),[]),I=(0,W.useCallback)(async(e,t)=>{p(!0),d(null);try{let n=await fetch(`${s()}/profiles/${encodeURIComponent(e.name)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(e)});if(!n.ok){let e=await n.json().catch(()=>({}));throw Error(e.error??`Save failed: ${n.status}`)}o(e),t.length>0?A.warning(`Profile saved with untargeted agents`,{description:`No routing rule points to: ${t.join(`, `)}. Add a tag rule or retarget the default rule if you want them to run.`,duration:6e3}):A.success(`Profile saved`,{description:e.name})}catch(e){let t=e.message;d(t),A.error(`Failed to save profile`,{description:t})}finally{p(!1)}},[]),L=(0,G.jsxs)(G.Fragment,{children:[(0,G.jsx)(se,{open:b,title:`New profile`,description:`Pick a lowercase kebab-case name (letters, digits, and hyphens).`,placeholder:`my-profile`,confirmLabel:`Create`,inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:`Must start with a letter or digit and contain only lowercase letters, digits, and hyphens.`,onConfirm:e=>void O(e),onCancel:()=>x(!1)}),S&&(0,G.jsx)(se,{open:!0,title:`Duplicate "${S.from}"`,description:`Name for the new profile.`,placeholder:`${S.from}-copy`,initialValue:`${S.from}-copy`,confirmLabel:`Duplicate`,inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:`Lowercase kebab-case only.`,onConfirm:e=>void k(S.from,e),onCancel:()=>C(null)}),w&&(0,G.jsx)(ce,{open:!0,title:`Delete profile "${w.name}"?`,description:`This cannot be undone. Jobs already launched with this profile keep their snapshot; future launches will fall back to the resolution order.`,confirmLabel:`Delete`,destructive:!0,onConfirm:()=>void j(w.name),onCancel:()=>T(null)})]});return c?(0,G.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading profiles…`})}):e.length===0?(0,G.jsxs)(G.Fragment,{children:[L,(0,G.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,G.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,G.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`No profiles yet`}),(0,G.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1 mb-4`,children:`Profiles let you save orchestrator + agent + routing combinations and pick one per rail.`}),(0,G.jsxs)(`div`,{className:`flex items-center gap-2 justify-center`,children:[(0,G.jsxs)(R,{size:`sm`,onClick:D,disabled:f,children:[(0,G.jsx)(U,{className:`w-3.5 h-3.5 mr-1.5`}),` Migrate from current agents`]}),(0,G.jsxs)(R,{size:`sm`,variant:`ghost`,onClick:M,disabled:f,children:[(0,G.jsx)(y,{className:`w-3.5 h-3.5 mr-1.5`}),` Blank profile`]})]}),(0,G.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-3`,children:[`"Migrate" reads your existing `,(0,G.jsx)(`code`,{className:`text-foreground`,children:`.claude/agents/`}),` `,`frontmatter models and creates a `,(0,G.jsx)(`code`,{className:`text-foreground`,children:`default`}),` profile mirroring today's behavior — zero-loss.`]}),u&&(0,G.jsx)(`div`,{className:`mt-3 text-xs text-red-400`,children:u})]})})]}):(0,G.jsxs)(`div`,{className:`flex flex-col h-full`,children:[L,(0,G.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,G.jsxs)(`aside`,{className:`w-64 flex-shrink-0 border-r border-border flex flex-col`,children:[(0,G.jsxs)(`div`,{className:`p-3 flex items-center justify-between`,children:[(0,G.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Profiles`}),(0,G.jsx)(R,{size:`sm`,variant:`ghost`,onClick:M,disabled:f,children:(0,G.jsx)(y,{className:`w-3.5 h-3.5`})})]}),(0,G.jsx)(`div`,{className:`flex-1 overflow-auto px-2 pb-3`,children:e.map(e=>(0,G.jsxs)(`div`,{className:`group mb-1 rounded-md px-2 py-1.5 text-xs cursor-pointer transition-colors flex items-center justify-between `+(e.name===n?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>r(e.name),role:`button`,tabIndex:0,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&r(e.name)},children:[(0,G.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,G.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),e.isDefault&&(0,G.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`(team default)`})]}),(0,G.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,title:`Duplicate`,onClick:t=>{t.stopPropagation(),P(e.name)},children:(0,G.jsx)(i,{className:`w-3 h-3`})}),!e.isDefault&&(0,G.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 rounded`,title:`Delete`,onClick:t=>{t.stopPropagation(),F(e.name)},children:(0,G.jsx)(v,{className:`w-3 h-3`})})]})]},e.name))})]}),(0,G.jsxs)(`main`,{className:`flex-1 overflow-auto`,children:[u&&(0,G.jsx)(`div`,{className:`mx-4 mt-4 px-3 py-2 text-xs rounded border border-red-500/30 bg-red-500/10 text-red-400`,children:u}),a?(0,G.jsx)(ie,{profile:a,onChange:o,onValidityChange:h,onSoftWarningsChange:e=>_(e.agentsMissingRouting),footer:(0,G.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,G.jsxs)(R,{size:`sm`,onClick:()=>void I(a,g),disabled:f||m.length>0,title:m.length>0?`Fix validation issues before saving`:void 0,children:[(0,G.jsx)(N,{className:`w-3.5 h-3.5 mr-1.5`}),`Save`]}),f&&(0,G.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving…`}),m.length>0&&(0,G.jsxs)(`span`,{className:`text-xs text-yellow-500`,children:[m.length,` `,m.length===1?`issue`:`issues`,` to resolve`]})]})},a.name):(0,G.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,G.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a profile to edit`})})]})]})]})}function Z(e){let t=e.workflow.map((e,t)=>`${t+1}. ${e}`).join(`
2
2
  `);return`---
3
3
  name: ${e.id}
4
4
  description: "${e.descriptionOneLine}"
@@ -1,4 +1,4 @@
1
- import{i as e,n as t,o as n,r,t as i}from"./createLucideIcon-Cg9402G2.js";import{n as a,t as o}from"./utils-DNQKxVT4.js";import{$ as s,$t as c,A as l,At as u,B as d,Bt as f,C as p,Ct as m,D as h,Dt as g,E as _,Et as v,F as y,Ft as b,G as x,Gt as S,H as C,Ht as w,I as T,It as ee,J as te,Jt as ne,K as re,Kt as ie,L as ae,Lt as oe,M as se,Mt as E,N as ce,Nt as le,O as ue,Ot as de,P as fe,Pt as pe,Q as me,Qt as he,R as ge,Rt as D,S as _e,St as ve,T as ye,Tt as be,U as xe,Ut as O,V as Se,Vt as Ce,W as we,Wt as k,X as Te,Xt as A,Y as Ee,Yt as De,Z as Oe,Zt as ke,_ as Ae,_n as je,_t as Me,a as Ne,an as Pe,at as Fe,b as Ie,bn as Le,bt as Re,c as ze,cn as Be,ct as Ve,d as He,dn as Ue,dt as We,en as Ge,et as Ke,f as qe,fn as Je,ft as Ye,g as j,gn as Xe,gt as Ze,h as M,hn as Qe,ht as $e,i as et,in as tt,it as nt,j as rt,jt as it,k as at,kt as ot,l as st,ln as ct,lt as N,m as P,mn as F,mt as lt,n as I,nn as ut,nt as L,o as dt,on as ft,ot as pt,p as mt,pn as ht,pt as gt,q as _t,qt as vt,r as yt,rn as bt,rt as xt,s as St,sn as Ct,st as wt,t as Tt,tn as Et,tt as Dt,u as Ot,un as kt,ut as At,v as R,vn as jt,vt as Mt,w as Nt,wt as Pt,x as Ft,xn as It,xt as Lt,y as Rt,yn as zt,yt as Bt,z as Vt,zt as Ht}from"./dracula-colors-3Ah9nKDo.js";import{B as Ut,Q as Wt,Y as Gt,at as Kt,j as qt,st as Jt,vt as Yt}from"./index-geDvjEca.js";import{t as Xt}from"./ExportDropdown-C3CmmTWC.js";var Zt=i(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Qt=i(`trending-down`,[[`path`,{d:`M16 17h6v-6`,key:`t6n2it`}],[`path`,{d:`m22 17-8.5-8.5-5 5L2 7`,key:`x473p`}]]),z=n(r()),B=t();function $t(e){return`$${e.toFixed(4)}`}function en(e){if(e===null)return`—`;let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${r}s`}function tn(e){return`${(e*100).toFixed(1)}%`}function nn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function rn(e){return e===null?null:`${e>0?`+`:``}${e.toFixed(1)}%`}function V({delta:e,deltaPct:t,lowerIsBetter:n=!1,formatter:r}){if(e===null)return null;let i=e>0,a=n?e<0:e>0,s=e===0,c=r?r(Math.abs(e)):e>0?`+${e}`:`${e}`,l=rn(t);return(0,B.jsxs)(`span`,{className:o(`inline-flex items-center gap-0.5 text-[10px] font-medium px-1.5 py-0.5 rounded`,s?`text-muted-foreground bg-muted/40`:a?`text-green-400 bg-green-400/10`:`text-red-400 bg-red-400/10`),children:[s?(0,B.jsx)(Wt,{className:`w-2.5 h-2.5`}):i?(0,B.jsx)(It,{className:`w-2.5 h-2.5`}):(0,B.jsx)(Qt,{className:`w-2.5 h-2.5`}),l??c]})}function H({label:e,value:t,previousValue:n,badge:r}){return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e}),(0,B.jsxs)(`div`,{className:`flex items-end justify-between gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`text-xl font-semibold tabular-nums`,children:t}),n!=null&&(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`prev: `,n]})]}),r]})]})}function an({kpi:e}){let t=e.previousPeriod;return(0,B.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-5 gap-3`,children:[(0,B.jsx)(H,{label:`Total Cost`,value:$t(e.totalCostUsd),previousValue:t?$t(t.totalCostUsd):null,badge:(0,B.jsx)(V,{delta:e.costDelta,deltaPct:e.costDeltaPct,lowerIsBetter:!0,formatter:e=>`$${e.toFixed(4)}`})}),(0,B.jsx)(H,{label:`Total Jobs`,value:String(e.totalJobs),previousValue:t?String(t.totalJobs):null,badge:(0,B.jsx)(V,{delta:e.jobsDelta,deltaPct:e.jobsDeltaPct,lowerIsBetter:!1,formatter:e=>`+${e}`})}),(0,B.jsx)(H,{label:`Success Rate`,value:tn(e.successRate),previousValue:t?tn(t.successRate):null,badge:(0,B.jsx)(V,{delta:e.successRateDelta,deltaPct:e.successRateDeltaPct,lowerIsBetter:!1,formatter:e=>`${(e*100).toFixed(1)}%`})}),(0,B.jsx)(H,{label:`Avg Duration`,value:en(e.avgDurationMs),previousValue:t?en(t.avgDurationMs):null,badge:(0,B.jsx)(V,{delta:e.avgDurationDelta,deltaPct:e.avgDurationDeltaPct,lowerIsBetter:!0,formatter:e=>en(e)})}),(0,B.jsx)(H,{label:`Total Tokens`,value:nn(e.totalTokens),previousValue:t?nn(t.totalTokens):null,badge:(0,B.jsx)(V,{delta:e.totalTokensDelta,deltaPct:e.totalTokensDeltaPct,lowerIsBetter:!0,formatter:e=>nn(e)})})]})}function on(){return on=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},on.apply(null,arguments)}function sn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?sn(Object(n),!0).forEach(function(t){ln(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ln(e,t,n){return(t=un(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function un(e){var t=dn(e,`string`);return typeof t==`symbol`?t:t+``}function dn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var U=32,fn={align:`center`,iconSize:14,inactiveColor:`#ccc`,layout:`horizontal`,verticalAlign:`middle`,labelStyle:{}};function pn(e){if(typeof e==`object`&&e&&`strokeDasharray`in e)return String(e.strokeDasharray)}function mn(e){var{data:t,iconType:n,inactiveColor:r}=e,i=U/2,a=U/6,o=U/3,s=t.inactive?r:t.color,c=n??t.type;if(c===`none`)return null;if(c===`plainline`)return z.createElement(`line`,{strokeWidth:4,fill:`none`,stroke:s,strokeDasharray:pn(t.payload),x1:0,y1:i,x2:U,y2:i,className:`recharts-legend-icon`});if(c===`line`)return z.createElement(`path`,{strokeWidth:4,fill:`none`,stroke:s,d:`M0,${i}h${o}
1
+ import{i as e,n as t,o as n,r,t as i}from"./createLucideIcon-Cg9402G2.js";import{n as a,t as o}from"./utils-DNQKxVT4.js";import{$ as s,$t as c,A as l,At as u,B as d,Bt as f,C as p,Ct as m,D as h,Dt as g,E as _,Et as v,F as y,Ft as b,G as x,Gt as S,H as C,Ht as w,I as T,It as ee,J as te,Jt as ne,K as re,Kt as ie,L as ae,Lt as oe,M as se,Mt as E,N as ce,Nt as le,O as ue,Ot as de,P as fe,Pt as pe,Q as me,Qt as he,R as ge,Rt as D,S as _e,St as ve,T as ye,Tt as be,U as xe,Ut as O,V as Se,Vt as Ce,W as we,Wt as k,X as Te,Xt as A,Y as Ee,Yt as De,Z as Oe,Zt as ke,_ as Ae,_n as je,_t as Me,a as Ne,an as Pe,at as Fe,b as Ie,bn as Le,bt as Re,c as ze,cn as Be,ct as Ve,d as He,dn as Ue,dt as We,en as Ge,et as Ke,f as qe,fn as Je,ft as Ye,g as j,gn as Xe,gt as Ze,h as M,hn as Qe,ht as $e,i as et,in as tt,it as nt,j as rt,jt as it,k as at,kt as ot,l as st,ln as ct,lt as N,m as P,mn as F,mt as lt,n as I,nn as ut,nt as L,o as dt,on as ft,ot as pt,p as mt,pn as ht,pt as gt,q as _t,qt as vt,r as yt,rn as bt,rt as xt,s as St,sn as Ct,st as wt,t as Tt,tn as Et,tt as Dt,u as Ot,un as kt,ut as At,v as R,vn as jt,vt as Mt,w as Nt,wt as Pt,x as Ft,xn as It,xt as Lt,y as Rt,yn as zt,yt as Bt,z as Vt,zt as Ht}from"./dracula-colors-BbrPsQvf.js";import{B as Ut,Q as Wt,Y as Gt,at as Kt,j as qt,st as Jt,vt as Yt}from"./index-W5VPSfMl.js";import{t as Xt}from"./ExportDropdown-BLr8CD_h.js";var Zt=i(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Qt=i(`trending-down`,[[`path`,{d:`M16 17h6v-6`,key:`t6n2it`}],[`path`,{d:`m22 17-8.5-8.5-5 5L2 7`,key:`x473p`}]]),z=n(r()),B=t();function $t(e){return`$${e.toFixed(4)}`}function en(e){if(e===null)return`—`;let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${r}s`}function tn(e){return`${(e*100).toFixed(1)}%`}function nn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function rn(e){return e===null?null:`${e>0?`+`:``}${e.toFixed(1)}%`}function V({delta:e,deltaPct:t,lowerIsBetter:n=!1,formatter:r}){if(e===null)return null;let i=e>0,a=n?e<0:e>0,s=e===0,c=r?r(Math.abs(e)):e>0?`+${e}`:`${e}`,l=rn(t);return(0,B.jsxs)(`span`,{className:o(`inline-flex items-center gap-0.5 text-[10px] font-medium px-1.5 py-0.5 rounded`,s?`text-muted-foreground bg-muted/40`:a?`text-green-400 bg-green-400/10`:`text-red-400 bg-red-400/10`),children:[s?(0,B.jsx)(Wt,{className:`w-2.5 h-2.5`}):i?(0,B.jsx)(It,{className:`w-2.5 h-2.5`}):(0,B.jsx)(Qt,{className:`w-2.5 h-2.5`}),l??c]})}function H({label:e,value:t,previousValue:n,badge:r}){return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e}),(0,B.jsxs)(`div`,{className:`flex items-end justify-between gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`text-xl font-semibold tabular-nums`,children:t}),n!=null&&(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`prev: `,n]})]}),r]})]})}function an({kpi:e}){let t=e.previousPeriod;return(0,B.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-5 gap-3`,children:[(0,B.jsx)(H,{label:`Total Cost`,value:$t(e.totalCostUsd),previousValue:t?$t(t.totalCostUsd):null,badge:(0,B.jsx)(V,{delta:e.costDelta,deltaPct:e.costDeltaPct,lowerIsBetter:!0,formatter:e=>`$${e.toFixed(4)}`})}),(0,B.jsx)(H,{label:`Total Jobs`,value:String(e.totalJobs),previousValue:t?String(t.totalJobs):null,badge:(0,B.jsx)(V,{delta:e.jobsDelta,deltaPct:e.jobsDeltaPct,lowerIsBetter:!1,formatter:e=>`+${e}`})}),(0,B.jsx)(H,{label:`Success Rate`,value:tn(e.successRate),previousValue:t?tn(t.successRate):null,badge:(0,B.jsx)(V,{delta:e.successRateDelta,deltaPct:e.successRateDeltaPct,lowerIsBetter:!1,formatter:e=>`${(e*100).toFixed(1)}%`})}),(0,B.jsx)(H,{label:`Avg Duration`,value:en(e.avgDurationMs),previousValue:t?en(t.avgDurationMs):null,badge:(0,B.jsx)(V,{delta:e.avgDurationDelta,deltaPct:e.avgDurationDeltaPct,lowerIsBetter:!0,formatter:e=>en(e)})}),(0,B.jsx)(H,{label:`Total Tokens`,value:nn(e.totalTokens),previousValue:t?nn(t.totalTokens):null,badge:(0,B.jsx)(V,{delta:e.totalTokensDelta,deltaPct:e.totalTokensDeltaPct,lowerIsBetter:!0,formatter:e=>nn(e)})})]})}function on(){return on=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},on.apply(null,arguments)}function sn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?sn(Object(n),!0).forEach(function(t){ln(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ln(e,t,n){return(t=un(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function un(e){var t=dn(e,`string`);return typeof t==`symbol`?t:t+``}function dn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var U=32,fn={align:`center`,iconSize:14,inactiveColor:`#ccc`,layout:`horizontal`,verticalAlign:`middle`,labelStyle:{}};function pn(e){if(typeof e==`object`&&e&&`strokeDasharray`in e)return String(e.strokeDasharray)}function mn(e){var{data:t,iconType:n,inactiveColor:r}=e,i=U/2,a=U/6,o=U/3,s=t.inactive?r:t.color,c=n??t.type;if(c===`none`)return null;if(c===`plainline`)return z.createElement(`line`,{strokeWidth:4,fill:`none`,stroke:s,strokeDasharray:pn(t.payload),x1:0,y1:i,x2:U,y2:i,className:`recharts-legend-icon`});if(c===`line`)return z.createElement(`path`,{strokeWidth:4,fill:`none`,stroke:s,d:`M0,${i}h${o}
2
2
  A${a},${a},0,1,1,${2*o},${i}
3
3
  H${U}M${2*o},${i}
4
4
  A${a},${a},0,1,1,${o},${i}`,className:`recharts-legend-icon`});if(c===`rect`)return z.createElement(`path`,{stroke:`none`,fill:s,d:`M0,${U/8}h${U}v${U*3/4}h${-U}z`,className:`recharts-legend-icon`});if(z.isValidElement(t.legendIcon)){var l=cn({},t);return delete l.legendIcon,z.cloneElement(t.legendIcon,l)}return z.createElement(he,{fill:s,cx:i,cy:i,size:U,sizeType:`diameter`,type:c})}function hn(e){var{payload:t,iconSize:n,layout:r,formatter:i,inactiveColor:o,iconType:s,labelStyle:c}=e,l={x:0,y:0,width:U,height:U},u={display:r===`horizontal`?`inline-block`:`block`,marginRight:10},d={display:`inline-block`,verticalAlign:`middle`,marginRight:4};return t.map((t,r)=>{var f=t.formatter||i,p=a({"recharts-legend-item":!0,[`legend-item-${r}`]:!0,inactive:t.inactive});if(t.type===`none`)return null;var m=typeof c==`object`?cn({},c):{};m.color=t.inactive?o:m.color||t.color;var h=f?f(t.value,t,r):t.value;return z.createElement(`li`,on({className:p,style:u,key:`legend-item-${r}`},ke(e,t,r)),z.createElement(Qe,{width:n,height:n,viewBox:l,style:d,"aria-label":`${h} legend icon`},z.createElement(mn,{data:t,iconType:s,inactiveColor:o})),z.createElement(`span`,{className:`recharts-legend-item-text`,style:m},h))})}var gn=e=>{var t=A(e,fn),{payload:n,layout:r,align:i}=t;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r===`horizontal`?i:`left`};return z.createElement(`ul`,{className:`recharts-default-legend`,style:a},z.createElement(hn,on({},t,{payload:n})))};function _n(){return k(Ce)}var vn=n(Yt()),yn=[`contextPayload`];function bn(){return bn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bn.apply(null,arguments)}function xn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function W(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?xn(Object(n),!0).forEach(function(t){Sn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Sn(e,t,n){return(t=Cn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Cn(e){var t=wn(e,`string`);return typeof t==`symbol`?t:t+``}function wn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Tn(e,t){if(e==null)return{};var n,r,i=En(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function En(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Dn(e){return e.value}function On(e){var{contextPayload:t}=e,n=Tn(e,yn),r=S(t,e.payloadUniqBy,Dn),i=W(W({},n),{},{payload:r});return z.isValidElement(e.content)?z.cloneElement(e.content,i):typeof e.content==`function`?z.createElement(e.content,i):z.createElement(gn,i)}function kn(e,t,n,r,i,a){var{layout:o,align:s,verticalAlign:c}=t,l,u;return(!e||(e.left===void 0||e.left===null)&&(e.right===void 0||e.right===null))&&(l=s===`center`&&o===`vertical`?{left:((r||0)-a.width)/2}:s===`right`?{right:n&&n.right||0}:{left:n&&n.left||0}),(!e||(e.top===void 0||e.top===null)&&(e.bottom===void 0||e.bottom===null))&&(u=c===`middle`?{top:((i||0)-a.height)/2}:c===`bottom`?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),W(W({},l),u)}function An(e){var t=O();return(0,z.useEffect)(()=>{t(be(e))},[t,e]),null}function jn(e){var t=O();return(0,z.useEffect)(()=>(t(v(e)),()=>{t(v({width:0,height:0}))}),[t,e]),null}function Mn(e,t,n,r){return e===`vertical`&&t!=null?{height:t}:e===`horizontal`?{width:n||r}:null}var Nn={align:`center`,iconSize:14,inactiveColor:`#ccc`,itemSorter:`value`,layout:`horizontal`,verticalAlign:`bottom`};function Pn(e){var t=A(e,Nn),n=_n(),r=ht(),i=it(),{width:a,height:o,wrapperStyle:s,portal:c}=t,[l,d]=f([n]),p=u(),m=ot();if(p==null||m==null)return null;var h=p-(i?.left||0)-(i?.right||0),g=Mn(t.layout,o,a,h),_=c?s:W(W({position:`absolute`,width:g?.width||a||`auto`,height:g?.height||o||`auto`},kn(s,t,i,p,m,l)),s),v=c??r;return v==null||n==null?null:(0,vn.createPortal)(z.createElement(`div`,{className:`recharts-legend-wrapper`,style:_,ref:d},z.createElement(An,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!c&&z.createElement(jn,{width:l.width,height:l.height}),z.createElement(On,bn({},t,g,{margin:i,chartWidth:p,chartHeight:m,contextPayload:n}))),v)}var G=z.memo(Pn,Pt);G.displayName=`Legend`;var Fn=[`points`,`className`,`baseLinePoints`,`connectNulls`],In;function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K.apply(null,arguments)}function Ln(e,t){if(e==null)return{};var n,r,i=Rn(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Rn(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function zn(e,t){return t||=e.slice(0),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var Bn=e=>e!=null&&e.x===+e.x&&e.y===+e.y,Vn=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=[[]];e.forEach(e=>{var n=t[t.length-1];Bn(e)?n&&n.push(e):n&&n.length>0&&t.push([])});var n=e[0],r=t[t.length-1];Bn(n)&&r&&r.push(n);var i=t[t.length-1];return i&&i.length<=0&&(t=t.slice(0,-1)),t},q=(e,t)=>{var n=Vn(e);t&&(n=[n.reduce((e,t)=>[...e,...t],[])]);var r=n.map(e=>e.reduce((e,t,n)=>ft(In||=zn([``,``,``,`,`,``]),e,n===0?`M`:`L`,t.x,t.y),``)).join(``);return n.length===1?`${r}Z`:r},Hn=(e,t,n)=>{var r=q(e,n);return`${r.slice(-1)===`Z`?r.slice(0,-1):r}L${q(Array.from(t).reverse(),n).slice(1)}`},Un=e=>{var{points:t,className:n,baseLinePoints:r,connectNulls:i}=e,o=Ln(e,Fn);if(!t||!t.length)return null;var s=a(`recharts-polygon`,n);if(r&&r.length){var c=o.stroke&&o.stroke!==`none`,l=Hn(t,r,i);return z.createElement(`g`,{className:s},z.createElement(`path`,K({},Xe(o),{fill:l.slice(-1)===`Z`?o.fill:`none`,stroke:`none`,d:l})),c?z.createElement(`path`,K({},Xe(o),{fill:`none`,d:q(t,i)})):null,c?z.createElement(`path`,K({},Xe(o),{fill:`none`,d:q(r,i)})):null)}var u=q(t,i);return z.createElement(`path`,K({},Xe(o),{fill:u.slice(-1)===`Z`?o.fill:`none`,className:s,d:u}))},Wn=e=>e.graphicalItems.polarItems,Gn=w([Wn,L,w([N,Ve],Ke)],Oe),Kn=w([w([Gn],Te),Ye],te),qn=w([Kn,L,Gn],x);w([Kn,L,Gn],(e,t,n)=>n.length>0?e.flatMap(e=>n.flatMap(n=>({value:D(e,t.dataKey??n.dataKey),errorDomain:[]}))).filter(Boolean):t?.dataKey==null?e.map(e=>({value:e,errorDomain:[]})):e.map(e=>({value:D(e,t.dataKey),errorDomain:[]})));var Jn=()=>void 0,Yn=w([L,de,Kn,qn,We,N,w([L,xt,nt,Jn,w([Kn,L,Gn,Dt,N],Ee),Jn,de,N],s)],re);w([Fe,w([L,Yn,w([Yn,pt,Fe],me),N],_t)],wt);function Xn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xn(Object(n),!0).forEach(function(t){Qn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qn(e,t,n){return(t=$n(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $n(e){var t=er(e,`string`);return typeof t==`symbol`?t:t+``}function er(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var tr=w([Wn,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`pie`).find(e=>e.id===t)),nr=[],rr=(e,t,n)=>n?.length===0?nr:n,ir=w([Ye,tr,rr],(e,t,n)=>{var{chartData:r}=e;if(t!=null){var i=t?.data!=null&&t.data.length>0?t.data:r;if((!i||!i.length)&&n!=null&&(i=n.map(e=>Zn(Zn({},t.presentationProps),e.props))),i!=null)return i}}),ar=w([ir,tr,rr],(e,t,n)=>{if(!(e==null||t==null))return e.map((e,r)=>{var i,a=D(e,t.nameKey,t.name),o=n!=null&&(i=n[r])!=null&&(i=i.props)!=null&&i.fill?n[r].props.fill:typeof e==`object`&&e&&`fill`in e?e.fill:t.fill;return{value:oe(a,t.dataKey),color:o,payload:e,type:t.legendType}})}),or=w([ir,tr,rr,le],(e,t,n,r)=>{if(!(t==null||e==null))return Ar({offset:r,pieSettings:t,displayedData:e,cells:n})}),sr=n(Ct()),cr=[`key`],lr=[`onMouseEnter`,`onClick`,`onMouseLeave`],ur=[`id`],dr=[`id`];function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(null,arguments)}function fr(e,t){if(e==null)return{};var n,r,i=pr(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function pr(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function mr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?mr(Object(n),!0).forEach(function(t){hr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function hr(e,t,n){return(t=gr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gr(e){var t=_r(e,`string`);return typeof t==`symbol`?t:t+``}function _r(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function vr(e){var t=(0,z.useMemo)(()=>at(e.children,y),[e.children]),n=k(n=>ar(n,e.id,t));return n==null?null:z.createElement(_e,{legendPayload:n})}function yr(e){if(!(e==null||typeof e==`boolean`||typeof e==`function`)){if(z.isValidElement(e)){var t=e.props?.fill;return typeof t==`string`?t:void 0}var{fill:n}=e;return typeof n==`string`?n:void 0}}var br=z.memo(e=>{var{dataKey:t,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:s,hide:c,tooltipType:l,id:u,activeShape:d}=e,f=yr(d),m={dataDefinedOnItem:r.map(e=>{var t=e.tooltipPayload;return f==null||t==null?t:t.map(e=>Y(Y({},e),{},{color:f,fill:f}))}),getPosition:e=>r[Number(e)]?.tooltipPosition,settings:{stroke:i,strokeWidth:a,fill:o,dataKey:t,nameKey:n,name:oe(s,t),hide:c,type:l,color:o,unit:``,graphicalItemId:u}};return z.createElement(p,{tooltipEntrySettings:m})}),xr=(e,t)=>e>t?`start`:e<t?`end`:`middle`,Sr=(e,t,n)=>c(typeof t==`function`?t(e):t,n,n*.8),Cr=(e,t,n)=>{var{top:r,left:i,width:a,height:o}=t,s=lt(a,o);return{cx:i+c(e.cx,a,a/2),cy:r+c(e.cy,o,o/2),innerRadius:c(e.innerRadius,s,0),outerRadius:Sr(n,e.outerRadius,s),maxRadius:e.maxRadius||Math.sqrt(a*a+o*o)/2}},wr=(e,t)=>bt(t-e)*Math.min(Math.abs(t-e),360),Tr=(e,t)=>{if(z.isValidElement(e))return z.cloneElement(e,t);if(typeof e==`function`)return e(t);var n=a(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className),{key:r}=t,i=fr(t,cr);return z.createElement(Lt,J({},i,{type:`linear`,className:n}))},Er=(e,t,n)=>{if(z.isValidElement(e))return z.cloneElement(e,t);var r=n;if(typeof e==`function`&&(r=e(t),z.isValidElement(r)))return r;var i=a(`recharts-pie-label-text`,l(e));return z.createElement(ce,J({},t,{alignmentBaseline:`middle`,className:i}),r)};function Dr(e){var{sectors:t,props:n,showLabels:r}=e,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!t)return null;var s=je(n),c=jt(i),l=jt(a),u=typeof i==`object`&&`offsetRadius`in i&&typeof i.offsetRadius==`number`&&i.offsetRadius||20,d=t.map((e,t)=>{var n=(e.startAngle+e.endAngle)/2,r=$e(e.cx,e.cy,e.outerRadius+u,n),d=Y(Y(Y(Y({},s),e),{},{stroke:`none`},c),{},{index:t,textAnchor:xr(r.x,e.cx)},r),f=Y(Y(Y(Y({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:t,points:[$e(e.cx,e.cy,e.outerRadius,n),r],key:`line`});return z.createElement(Vt,{zIndex:At.label,key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${t}`},z.createElement(F,null,a&&Tr(a,f),Er(i,d,D(e,o))))});return z.createElement(F,{className:`recharts-pie-labels`},d)}function Or(e){var{sectors:t,props:n,showLabels:r}=e,{label:i}=n;return typeof i==`object`&&i&&`position`in i?z.createElement(rt,{label:i}):z.createElement(Dr,{sectors:t,props:n,showLabels:r})}function kr(e){var{sectors:t,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=e,s=k(C),c=k(d),l=k(Se),{onMouseEnter:u,onClick:f,onMouseLeave:p}=i,m=fr(i,lr),g=ye(u,i.dataKey,o),v=_(p),y=Nt(f,i.dataKey,o);return t==null||t.length===0?null:z.createElement(z.Fragment,null,t.map((e,u)=>{if(e?.startAngle===0&&e?.endAngle===0&&t.length!==1)return null;var d=l==null||l===o,f=String(u)===s&&(c==null||i.dataKey===c)&&d,p=n&&f?n:s?r:null,_=Y(Y({},e),{},{stroke:e.stroke,tabIndex:-1,[ee]:u,[b]:o});return z.createElement(F,J({key:`sector-${e?.startAngle}-${e?.endAngle}-${e.midAngle}-${u}`,tabIndex:-1,className:`recharts-pie-sector`},ke(m,e,u),{onMouseEnter:g(e,u),onMouseLeave:v(e,u),onClick:y(e,u)}),z.createElement(h,J({option:a??p,index:u,shapeType:`sector`,isActive:f},_)))}))}function Ar(e){var{pieSettings:t,displayedData:n,cells:r,offset:i}=e,{cornerRadius:a,startAngle:o,endAngle:s,dataKey:c,nameKey:l,tooltipType:u}=t,d=Math.abs(t.minAngle),f=wr(o,s),p=Math.abs(f),m=n.length<=1?0:t.paddingAngle??0,h=n.filter(e=>D(e,c,0)!==0).length,g=(p>=360?h:h-1)*m,_=p-h*d-g,v=n.reduce((e,t)=>{var n=D(t,c,0);return e+(ut(n)?n:0)},0),y;if(v>0){var b;y=n.map((e,n)=>{var s=D(e,c,0),p=D(e,l,n),h=Cr(t,i,e),g=(ut(s)?s:0)/v,y,x=Y(Y({},e),r&&r[n]&&r[n].props),S=x!=null&&`fill`in x&&typeof x.fill==`string`?x.fill:t.fill;y=n?b.endAngle+bt(f)*m*(s===0?0:1):o;var C=y+bt(f)*((s===0?0:d)+g*_),w=(y+C)/2,T=(h.innerRadius+h.outerRadius)/2,ee=[{name:p,value:s,payload:x,dataKey:c,type:u,color:S,fill:S,graphicalItemId:t.id}],te=$e(h.cx,h.cy,T,w);return b=Y(Y(Y(Y({},t.presentationProps),{},{percent:g,cornerRadius:typeof a==`string`?parseFloat(a):a,name:p,tooltipPayload:ee,midAngle:w,middleRadius:T,tooltipPosition:te},x),h),{},{value:s,dataKey:c,startAngle:y,endAngle:C,payload:x,paddingAngle:bt(f)*m}),b})}return y}function jr(e){var{showLabels:t,sectors:n,children:r}=e,i=(0,z.useMemo)(()=>!t||!n?[]:n.map(e=>({value:e.value,payload:e.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:e.cx,cy:e.cy,innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,clockWise:!1},fill:e.fill})),[n,t]);return z.createElement(se,{value:t?i:void 0},r)}function Mr(e){var{props:t,previousSectorsRef:n,id:r}=e,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,activeShape:l,inactiveShape:u,onAnimationStart:d,onAnimationEnd:f}=t,p=Me(t,`recharts-pie-`),m=n.current,[h,g]=(0,z.useState)(!1),_=(0,z.useCallback)(()=>{typeof f==`function`&&f(),g(!1)},[f]),v=(0,z.useCallback)(()=>{typeof d==`function`&&d(),g(!0)},[d]);return z.createElement(jr,{showLabels:!h,sectors:i},z.createElement(Mt,{animationId:p,begin:o,duration:s,isActive:a,easing:c,onAnimationStart:v,onAnimationEnd:_,key:p},e=>{var a=[],o=(i&&i[0])?.startAngle??0;return i?.forEach((t,n)=>{var r=m&&m[n],i=n>0?(0,sr.default)(t,`paddingAngle`,0):0;if(r){var s=Ge(r.endAngle-r.startAngle,t.endAngle-t.startAngle,e),c=Y(Y({},t),{},{startAngle:o+i,endAngle:o+s+i});a.push(c),o=c.endAngle}else{var{endAngle:l,startAngle:u}=t,d=Ge(0,l-u,e),f=Y(Y({},t),{},{startAngle:o+i,endAngle:o+d+i});a.push(f),o=f.endAngle}}),n.current=a,z.createElement(F,null,z.createElement(kr,{sectors:a,activeShape:l,inactiveShape:u,allOtherPieProps:t,shape:t.shape,id:r}))}),z.createElement(Or,{showLabels:!h,sectors:i,props:t}),t.children)}var Nr={animationBegin:400,animationDuration:1500,animationEasing:`ease`,cx:`50%`,cy:`50%`,dataKey:`value`,endAngle:360,fill:`#808080`,hide:!1,innerRadius:0,isAnimationActive:`auto`,label:!1,labelLine:!0,legendType:`rect`,minAngle:0,nameKey:`name`,outerRadius:`80%`,paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:`#fff`,zIndex:At.area};function Pr(e){var{id:t}=e,n=fr(e,ur),{hide:r,className:i,rootTabIndex:o}=e,s=(0,z.useMemo)(()=>at(e.children,y),[e.children]),c=k(e=>or(e,t,s)),l=(0,z.useRef)(null),u=a(`recharts-pie`,i);return r||c==null?(l.current=null,z.createElement(F,{tabIndex:o,className:u})):z.createElement(Vt,{zIndex:e.zIndex},z.createElement(br,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:c,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t,activeShape:e.activeShape}),z.createElement(F,{tabIndex:o,className:u},z.createElement(Mr,{props:Y(Y({},n),{},{sectors:c}),previousSectorsRef:l,id:t})))}function Fr(e){var t=A(e,Nr),{id:n}=t,r=fr(t,dr),i=je(r);return z.createElement(Ft,{id:n,type:`pie`},e=>z.createElement(z.Fragment,null,z.createElement(Ie,{type:`pie`,id:e,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:t.maxRadius}),z.createElement(vr,J({},r,{id:e})),z.createElement(Pr,J({},r,{id:e}))))}var Ir=Fr;Ir.displayName=`Pie`;var Lr={begin:0,duration:1e3,easing:`ease`,isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}};function Rr(e){var t=A(e,Lr),{animationId:n,from:r,to:i,attributeName:a,isActive:o,canBegin:s,duration:c,easing:l,begin:u,onAnimationEnd:d,onAnimationStart:f,children:p}=t,h=ve(),g=o===`auto`?!m.isSsr&&!h:o,_=Bt(n+a,t.animationManager),[v,y]=(0,z.useState)(()=>g?r:i),b=(0,z.useRef)(!1),x=(0,z.useCallback)(()=>{y(r),f()},[r,f]);return(0,z.useEffect)(()=>{if(!g||!s)return tt;b.current=!0;var e=_.subscribe(y);return _.start([x,u,i,c,d]),()=>{_.stop(),e&&e(),d()}},[g,s,c,l,u,x,d,_,i,r]),g?s&&b.current?p({transition:Re([a],c,l),[a]:v}):p({[a]:r}):p({[a]:i})}function zr(e){var t=O();return(0,z.useEffect)(()=>{t(mt(e))},[t,e]),null}var Br=[`layout`];function Vr(){return Vr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Vr.apply(null,arguments)}function Hr(e,t){if(e==null)return{};var n,r,i=Ur(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ur(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Wr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Gr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Wr(Object(n),!0).forEach(function(t){Kr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Kr(e,t,n){return(t=qr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qr(e){var t=Jr(e,`string`);return typeof t==`symbol`?t:t+``}function Jr(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Yr=Gr({accessibilityLayer:!0,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`,layout:`radial`,responsive:!1,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`},qe),Xr=(0,z.forwardRef)(function(e,t){var n=A(e.categoricalChartProps,Yr),{layout:r}=n,i=Hr(n,Br),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:s,tooltipPayloadSearcher:c}=e,l={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:s,tooltipPayloadSearcher:c,eventEmitter:void 0};return z.createElement(He,{preloadedState:{options:l},reduxStoreName:n.id??a},z.createElement(Rt,{chartData:n.data}),z.createElement(Ot,{layout:r,margin:n.margin}),z.createElement(ze,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),z.createElement(st,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),z.createElement(zr,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),z.createElement(dt,Vr({},i,{ref:t})))});function Zr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Zr(Object(n),!0).forEach(function(t){$r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $r(e,t,n){return(t=ei(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ei(e){var t=ti(e,`string`);return typeof t==`symbol`?t:t+``}function ti(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var ni=[`item`],ri=Qr(Qr({},Yr),{},{layout:`centric`,startAngle:0,endAngle:360}),ii=(0,z.forwardRef)((e,t)=>{var n=A(e,ri);return z.createElement(Xr,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:ni,tooltipPayloadSearcher:ae,categoricalChartProps:n,ref:t})}),ai=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}e.isBuffer=t})),oi=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){let t=e?.constructor;return e===(typeof t==`function`?t.prototype:Object.prototype)}e.isPrototype=t})),si=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=vt();function n(e){return t.isTypedArray(e)}e.isTypedArray=n})),ci=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=gt();function n(e){let n=t.toFinite(e),r=n%1;return r?n-r:n}e.toInteger=n})),li=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=ci();function n(e,n){if(e=t.toInteger(e),e<1||!Number.isSafeInteger(e))return[];let r=Array(e);for(let t=0;t<e;t++)r[t]=typeof n==`function`?n(t):t;return r}e.times=n})),ui=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=ai(),n=oi(),r=De(),i=si(),a=li();function o(e){if(e==null)return[];switch(typeof e){case`object`:case`function`:return r.isArrayLike(e)?l(e):n.isPrototype(e)?c(e):s(e);default:return s(Object(e))}}function s(e){let t=[];for(let n in e)t.push(n);return t}function c(e){return s(e).filter(e=>e!==`constructor`)}function l(e){let n=a.times(e.length,e=>`${e}`),r=new Set(n);t.isBuffer(e)&&(r.add(`offset`),r.add(`parent`)),i.isTypedArray(e)&&(r.add(`buffer`),r.add(`byteLength`),r.add(`byteOffset`));let o=s(e).filter(e=>!r.has(e));return Array.isArray(e)?[...n,...o]:[...n.filter(t=>Object.hasOwn(e,t)),...o]}e.keysIn=o})),di=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Be(),n=Je(),r=Ue(),i=kt(),a=ct();function o(e,t){if(e==null)return!0;switch(typeof t){case`symbol`:case`number`:case`object`:if(Array.isArray(t))return s(e,t);if(typeof t==`number`?t=i.toKey(t):typeof t==`object`&&(t=Object.is(t?.valueOf(),-0)?`-0`:String(t)),n.isUnsafeProperty(t))return!1;if(e?.[t]===void 0)return!0;try{return delete e[t],!0}catch{return!1}case`string`:if(e?.[t]===void 0&&r.isDeepKey(t))return s(e,a.toPath(t));if(n.isUnsafeProperty(t))return!1;try{return delete e[t],!0}catch{return!1}}}function s(e,r){let i=r.length===1?e:t.get(e,r.slice(0,-1)),a=r[r.length-1];if(i?.[a]===void 0)return!0;if(n.isUnsafeProperty(a))return!1;try{return delete i[a],!0}catch{return!1}}e.unset=o})),fi=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=ne();function n(e){let n=[];for(;e;)n.push(...t.getSymbols(e)),e=Object.getPrototypeOf(e);return n}e.getSymbolsIn=n})),pi=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=De();function n(e,n=1){let r=[],i=Math.floor(n);if(!t.isArrayLike(e))return r;let a=(e,t)=>{for(let n=0;n<e.length;n++){let o=e[n];t<i&&(Array.isArray(o)||o?.[Symbol.isConcatSpreadable]||typeof o==`object`&&o&&Object.prototype.toString.call(o)===`[object Arguments]`)?a(Array.isArray(o)?o:Array.from(o),t+1):r.push(o)}};return a(Array.from(e),0),r}e.flatten=n})),mi=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=ie(),n=ui(),r=di(),i=fi(),a=Ue(),o=pi(),s=ue();function c(e,...t){if(e==null)return{};t=o.flatten(t);let n=l(e,t);for(let e=0;e<t.length;e++){let i=t[e];switch(typeof i){case`object`:Array.isArray(i)||(i=Array.from(i));for(let e=0;e<i.length;e++){let t=i[e];r.unset(n,t)}break;case`string`:case`symbol`:case`number`:r.unset(n,i);break}}return n}function l(e,t){return t.some(e=>Array.isArray(e)||a.isDeepKey(e))?d(e):u(e)}function u(e){let t={},r=[...n.keysIn(e),...i.getSymbolsIn(e)];for(let n=0;n<r.length;n++){let i=r[n];t[i]=e[i]}return t}function d(e){let r={},a=[...n.keysIn(e),...i.getSymbolsIn(e)];for(let n=0;n<a.length;n++){let i=a[n];r[i]=t.cloneDeepWith(e[i],e=>{if(!s.isPlainObject(e))return e})}return r}e.omit=c})),hi=n(e(((e,t)=>{t.exports=mi().omit}))()),gi=[`width`,`height`,`className`,`style`,`children`,`type`];function _i(e,t){if(e==null)return{};var n,r,i=vi(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function vi(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function yi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?yi(Object(n),!0).forEach(function(t){Q(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Q(e,t,n){return(t=bi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bi(e){var t=xi(e,`string`);return typeof t==`symbol`?t:t+``}function xi(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Si=`value`;function Ci(e){return typeof e==`object`&&!!e&&`x`in e&&`y`in e&&`width`in e&&`height`in e&&typeof e.x==`number`&&typeof e.y==`number`&&typeof e.width==`number`&&typeof e.height==`number`}var wi=(e,t)=>{if(!(!e||!t))return(0,sr.default)(e,t)},Ti=function(e){return`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:``}children[${e}]`},Ei={chartName:`Treemap`,defaultTooltipEventType:`item`,validateTooltipEventTypes:[`item`],tooltipPayloadSearcher:wi,eventEmitter:void 0},Di=e=>{var{depth:t,node:n,index:r,dataKey:i,nameKey:a,nestedActiveTooltipIndex:o}=e,s=t===0?``:Ti(r,o),{children:c}=n,l=t+1,u=c&&c.length?c.map((e,t)=>Di({depth:l,node:e,index:t,dataKey:i,nameKey:a,nestedActiveTooltipIndex:s})):null,d;if(u&&u.length)d=u.reduce((e,t)=>e+t.value,0);else{var f=n[i],p=typeof f==`number`?f:0;d=Et(p)||p<=0?0:p}return Z(Z({},n),{},{children:u,name:D(n,a,``),[Si]:d,depth:t,index:r,tooltipIndex:s})},Oi=e=>({x:e.x,y:e.y,width:e.width,height:e.height}),ki=(e,t)=>{var n=t<0?0:t;return e.map(e=>{var t=e[Si]*n;return Z(Z({},e),{},{area:Et(t)||t<=0?0:t})})},Ai=(e,t,n)=>{var r=t*t,i=e.area*e.area,{min:a,max:o}=e.reduce((e,t)=>({min:Math.min(e.min,t.area),max:Math.max(e.max,t.area)}),{min:1/0,max:0});return i?Math.max(r*o*n/i,i/(r*a*n)):1/0},ji=(e,t,n,r)=>{var i=t?Math.round(e.area/t):0;(r||i>n.height)&&(i=n.height);for(var a=n.x,o,s=0,c=e.length;s<c;s++)o=e[s],o!=null&&(o.x=a,o.y=n.y,o.height=i,o.width=Math.min(i?Math.round(o.area/i):0,n.x+n.width-a),a+=o.width);return o!=null&&(o.width+=n.x+n.width-a),Z(Z({},n),{},{y:n.y+i,height:n.height-i})},Mi=(e,t,n,r)=>{var i=t?Math.round(e.area/t):0;(r||i>n.width)&&(i=n.width);for(var a=n.y,o,s=0,c=e.length;s<c;s++)o=e[s],o!=null&&(o.x=n.x,o.y=a,o.width=i,o.height=Math.min(i?Math.round(o.area/i):0,n.y+n.height-a),a+=o.height);return o&&(o.height+=n.y+n.height-a),Z(Z({},n),{},{x:n.x+i,width:n.width-i})},Ni=(e,t,n,r)=>t===n.width?ji(e,t,n,r):Mi(e,t,n,r),Pi=(e,t)=>{var{children:n}=e;if(n&&n.length){var r=Oi(e),i=[],a=1/0,o,s,c=Math.min(r.width,r.height),l=ki(n,r.width*r.height/e[Si]),u=l.slice();for(i.area=0;u.length>0;)[o]=u,o!=null&&(i.push(o),i.area+=o.area,s=Ai(i,c,t),s<=a?(u.shift(),a=s):(i.area-=i.pop()?.area??0,r=Ni(i,c,r,!1),c=Math.min(r.width,r.height),i.length=i.area=0,a=1/0));return i.length&&=(r=Ni(i,c,r,!0),i.area=0),Z(Z({},e),{},{children:l.map(e=>Pi(e,t))})}return e},Fi=Z({aspectRatio:.5*(1+Math.sqrt(5)),dataKey:`value`,nameKey:`name`,type:`flat`,isAnimationActive:`auto`,isUpdateAnimationActive:`auto`,animationBegin:0,animationDuration:1500,animationEasing:`linear`},qe),Ii={isAnimationFinished:!1,formatRoot:null,currentRoot:void 0,nestIndex:[],prevAspectRatio:Fi.aspectRatio,prevDataKey:Fi.dataKey};function Li(e){var{content:t,nodeProps:n,type:r,colorPanel:i,onMouseEnter:a,onMouseLeave:o,onClick:s}=e;if(z.isValidElement(t))return z.createElement(F,{onMouseEnter:a,onMouseLeave:o,onClick:s},z.cloneElement(t,n));if(typeof t==`function`)return z.createElement(F,{onMouseEnter:a,onMouseLeave:o,onClick:s},t(n));var{x:c,y:l,width:u,height:d,index:f}=n,p=null;u>10&&d>10&&n.children&&r===`nest`&&(p=z.createElement(Un,{points:[{x:c+2,y:l+d/2},{x:c+6,y:l+d/2+3},{x:c+2,y:l+d/2+6}]}));var m=null,h=fe(n.name);u>20&&d>20&&h.width<u&&h.height<d&&(m=z.createElement(`text`,{x:c+8,y:l+d/2+7,fontSize:14},n.name));var g=i||pe;return z.createElement(`g`,null,z.createElement(Ze,X({fill:n.depth<2?g[f%g.length]:`rgba(255,255,255,0)`,stroke:`#fff`},(0,hi.default)(n,[`children`]),{onMouseEnter:a,onMouseLeave:o,onClick:s,"data-recharts-item-index":n.tooltipIndex})),p,m)}function Ri(e){var t=O(),n={x:e.nodeProps.x+e.nodeProps.width/2,y:e.nodeProps.y+e.nodeProps.height/2};return z.createElement(Li,X({},e,{onMouseEnter:()=>{t(we({activeIndex:e.nodeProps.tooltipIndex,activeDataKey:e.dataKey,activeCoordinate:n,activeGraphicalItemId:e.id}))},onMouseLeave:()=>{},onClick:()=>{t(xe({activeIndex:e.nodeProps.tooltipIndex,activeDataKey:e.dataKey,activeCoordinate:n,activeGraphicalItemId:e.id}))}}))}var zi=z.memo(e=>{var{dataKey:t,nameKey:n,stroke:r,fill:i,currentRoot:a,id:o}=e,s={dataDefinedOnItem:a,getPosition:tt,settings:{stroke:r,strokeWidth:void 0,fill:i,dataKey:t,nameKey:n,name:void 0,hide:!1,type:void 0,color:i,unit:``,graphicalItemId:o}};return z.createElement(p,{tooltipEntrySettings:s})}),Bi={top:0,right:0,bottom:0,left:0};function Vi(e){var{content:t,nodeProps:n,isLeaf:r,treemapProps:i,onNestClick:a}=e,{id:o,isAnimationActive:s,animationBegin:c,animationDuration:l,animationEasing:u,isUpdateAnimationActive:d,type:f,colorPanel:p,dataKey:m,onAnimationStart:h,onAnimationEnd:g,onMouseEnter:_,onClick:v,onMouseLeave:y}=i,{width:b,height:x,x:S,y:C}=n,w=-S-b,T=0,ee=e=>{(r||f===`nest`)&&typeof _==`function`&&_(n,e)},te=e=>{(r||f===`nest`)&&typeof y==`function`&&y(n,e)},ne=()=>{f===`nest`&&a(n),(r||f===`nest`)&&typeof v==`function`&&v(n)},re=(0,z.useCallback)(()=>{typeof g==`function`&&g()},[g]),ie=(0,z.useCallback)(()=>{typeof h==`function`&&h()},[h]);return z.createElement(Rr,{animationId:`treemap-${n.tooltipIndex}`,from:`translate(${w}px, ${T}px)`,to:`translate(0, 0)`,attributeName:`transform`,begin:c,easing:u,isActive:s,duration:l,onAnimationStart:ie,onAnimationEnd:re},e=>z.createElement(F,{onMouseEnter:ee,onMouseLeave:te,onClick:ne,style:Z(Z({},e),{},{transformOrigin:`${S} ${C}`})},z.createElement(Ri,{id:o,content:t,dataKey:m,nodeProps:Z(Z({},n),{},{isAnimationActive:s,isUpdateAnimationActive:!d,width:b,height:x,x:S,y:C}),type:f,colorPanel:p})))}var Hi=class extends z.PureComponent{constructor(){super(...arguments),Q(this,`state`,Z({},Ii)),Q(this,`handleClick`,e=>{var{onClick:t,type:n}=this.props;if(n===`nest`&&e.children){var{width:r,height:i,dataKey:a,nameKey:o,aspectRatio:s}=this.props,c=Di({depth:0,node:Z(Z({},e),{},{x:0,y:0,width:r,height:i}),index:0,dataKey:a,nameKey:o,nestedActiveTooltipIndex:e.tooltipIndex}),l=Pi(c,s),{nestIndex:u}=this.state;u.push(e),this.setState({formatRoot:l,currentRoot:c,nestIndex:u})}t&&t(e)}),Q(this,`handleTouchMove`,e=>{var t=e.touches[0];if(t!=null){var n=document.elementFromPoint(t.clientX,t.clientY);if(!(!n||!n.getAttribute||this.state.formatRoot==null)){var r=n.getAttribute(`data-recharts-item-index`),i=wi(this.state.formatRoot,r);if(Ci(i)){var{dataKey:a,dispatch:o}=this.props;o(we({activeIndex:r,activeDataKey:a,activeCoordinate:{x:i.x+i.width/2,y:i.y+i.height/2},activeGraphicalItemId:this.props.id}))}}}})}static getDerivedStateFromProps(e,t){if(e.data!==t.prevData||e.type!==t.prevType||e.width!==t.prevWidth||e.height!==t.prevHeight||e.dataKey!==t.prevDataKey||e.aspectRatio!==t.prevAspectRatio){var n=Di({depth:0,node:{children:e.data,x:0,y:0,width:e.width,height:e.height},index:0,dataKey:e.dataKey,nameKey:e.nameKey}),r=Pi(n,e.aspectRatio);return Z(Z({},t),{},{formatRoot:r,currentRoot:n,nestIndex:[n],prevAspectRatio:e.aspectRatio,prevData:e.data,prevWidth:e.width,prevHeight:e.height,prevDataKey:e.dataKey,prevType:e.type})}return null}handleNestIndex(e,t){var{nestIndex:n}=this.state,{width:r,height:i,dataKey:a,nameKey:o,aspectRatio:s}=this.props,c=Pi(Di({depth:0,node:Z(Z({},e),{},{x:0,y:0,width:r,height:i}),index:0,dataKey:a,nameKey:o,nestedActiveTooltipIndex:e.tooltipIndex}),s);n=n.slice(0,t+1),this.setState({formatRoot:c,currentRoot:e,nestIndex:n})}renderNode(e,t){var{content:n,type:r}=this.props,i=Z(Z(Z({},je(this.props)),t),{},{root:e}),a=!t.children||!t.children.length,{currentRoot:o}=this.state;return!(o?.children||[]).filter(e=>e.depth===t.depth&&e.name===t.name).length&&e.depth&&r===`nest`?null:z.createElement(F,{key:`recharts-treemap-node-${i.x}-${i.y}-${i.name}`,className:`recharts-treemap-depth-${t.depth}`},z.createElement(Vi,{isLeaf:a,content:n,nodeProps:i,treemapProps:this.props,onNestClick:this.handleClick}),t.children&&t.children.length?t.children.map(e=>this.renderNode(t,e)):null)}renderAllNodes(){var{formatRoot:e}=this.state;return e?this.renderNode(e,e):null}renderNestIndex(){var{nameKey:e,nestIndexContent:t}=this.props,{nestIndex:n}=this.state;return z.createElement(`div`,{className:`recharts-treemap-nest-index-wrapper`,style:{marginTop:`8px`,textAlign:`center`}},n.map((n,r)=>{var i=(0,sr.default)(n,e,`root`),a=typeof i==`string`?i:`root`,o;return z.isValidElement(t)&&(o=z.cloneElement(t,n,r)),o=typeof t==`function`?t(n,r):a,z.createElement(`div`,{onClick:this.handleNestIndex.bind(this,n,r),key:`nest-index-${Pe()}`,className:`recharts-treemap-nest-index-box`,style:{cursor:`pointer`,display:`inline-block`,padding:`0 7px`,background:`#000`,color:`#fff`,marginRight:`3px`}},o)}))}render(){var e=this.props,{width:t,height:n,className:r,style:i,children:a,type:o}=e,s=je(_i(e,gi));return z.createElement(z.Fragment,null,z.createElement(zi,{dataKey:this.props.dataKey,nameKey:this.props.nameKey,stroke:this.props.stroke,fill:this.props.fill,currentRoot:this.state.currentRoot,id:this.props.id}),z.createElement(Qe,X({},s,{width:t,height:o===`nest`?n-30:n,onTouchMove:this.handleTouchMove}),this.renderAllNodes(),a),o===`nest`&&this.renderNestIndex())}};Q(Hi,`displayName`,`Treemap`);function Ui(e){var t=O(),n=u(),r=ot();if(!Ht(n)||!Ht(r))return null;var{id:i}=e;return z.createElement(Ft,{id:i,type:`treemap`},i=>z.createElement(Hi,X({},e,{id:i,width:n,height:r,dispatch:t})))}function Wi(e){var t=A(e,Fi),{className:n,style:r,width:i,height:a,throttleDelay:o,throttledEvents:s}=t,[c,l]=(0,z.useState)(null);return z.createElement(He,{preloadedState:{options:Ei},reduxStoreName:t.className??`Treemap`},z.createElement(g,{margin:Bi}),z.createElement(ze,{throttleDelay:o,throttledEvents:s}),z.createElement(St,{dispatchTouchEvents:!1,className:n,style:r,width:i,height:a,responsive:!1,ref:e=>{c==null&&e!=null&&l(e)},onMouseEnter:void 0,onMouseLeave:void 0,onClick:void 0,onMouseMove:void 0,onMouseDown:void 0,onMouseUp:void 0,onContextMenu:void 0,onDoubleClick:void 0,onTouchStart:void 0,onTouchMove:void 0,onTouchEnd:void 0},z.createElement(ge.Provider,{value:c},z.createElement(Ui,t))))}function Gi({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,B.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]})}function Ki(e){try{return Le(new Date(e),`MMM d`)}catch{return e}}function qi({data:e}){if(!(e.length>0&&e.some(e=>e.costUsd>0)))return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost Over Time`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No cost data for this period`})]});let t=Math.max(1,Math.floor(e.length/7)),n=e.filter((e,n)=>n%t===0).map(e=>e.date);return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost Over Time`}),(0,B.jsx)(E,{width:`100%`,height:220,children:(0,B.jsxs)(Ne,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,B.jsx)(R,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,B.jsx)(M,{dataKey:`date`,ticks:n,tickFormatter:Ki,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,B.jsx)(P,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,B.jsx)(T,{content:(0,B.jsx)(Gi,{})}),(0,B.jsx)(Ae,{type:`monotone`,dataKey:`costUsd`,stroke:I.purple,strokeWidth:2,dot:!1,activeDot:{r:3,fill:I.purple}})]})})]})}function Ji({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0];return(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`capitalize font-medium`,children:n.name}),(0,B.jsxs)(`p`,{className:`text-muted-foreground`,children:[n.value,` jobs`]})]})}function Yi({data:e}){if(e.length===0)return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Jobs by Status`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No jobs in this period`})]});let t=e.reduce((e,t)=>e+t.count,0);return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Jobs by Status`}),(0,B.jsx)(E,{width:`100%`,height:220,children:(0,B.jsxs)(ii,{children:[(0,B.jsx)(Ir,{data:e,dataKey:`count`,nameKey:`status`,cx:`50%`,cy:`50%`,innerRadius:60,outerRadius:90,paddingAngle:2,children:e.map(e=>(0,B.jsx)(y,{fill:yt[e.status]??`var(--color-muted-foreground)`},e.status))}),(0,B.jsx)(T,{content:(0,B.jsx)(Ji,{})}),(0,B.jsx)(G,{formatter:n=>{let r=e.find(e=>e.status===n),i=r?(r.count/t*100).toFixed(0):`0`;return(0,B.jsxs)(`span`,{className:`text-xs capitalize`,children:[n,` (`,r?.count??0,`, `,i,`%)`]})}})]})})]})}var Xi=[`<1m`,`1-3m`,`3-5m`,`5-10m`,`>10m`];function Zi(e){if(e===null)return`—`;let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${r}s`}function Qi({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,B.jsxs)(`p`,{className:`font-medium`,children:[t[0].value,` jobs`]})]})}function $i({data:e,percentiles:t}){let n=Xi.map(t=>({bucket:t,count:e.find(e=>e.bucket===t)?.count??0}));return n.some(e=>e.count>0)?(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Duration Distribution`}),(0,B.jsx)(E,{width:`100%`,height:180,children:(0,B.jsxs)(et,{data:n,margin:{top:4,right:8,left:0,bottom:0},children:[(0,B.jsx)(R,{strokeDasharray:`3 3`,stroke:`var(--color-border)`,vertical:!1}),(0,B.jsx)(M,{dataKey:`bucket`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,B.jsx)(P,{allowDecimals:!1,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:30}),(0,B.jsx)(T,{content:(0,B.jsx)(Qi,{})}),(0,B.jsx)(j,{dataKey:`count`,fill:I.cyan,radius:[3,3,0,0]})]})}),(0,B.jsx)(`div`,{className:`flex items-center gap-3 mt-2`,children:[`p50`,`p75`,`p95`].map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground uppercase`,children:[e,`:`]}),(0,B.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums`,children:Zi(t[e])})]},e))})]}):(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Duration Distribution`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No duration data available`})]})}function ea({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`text-muted-foreground mb-1 font-mono truncate max-w-48`,children:n}),t.map(e=>(0,B.jsxs)(`p`,{style:{color:e.color},children:[e.name,`: `,e.value.toLocaleString()]},e.name))]})}function ta({data:e}){if(e.length===0)return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Token Efficiency`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No token data for this period`})]});let t=e.map(e=>({...e,name:e.command.length>20?`…${e.command.slice(-18)}`:e.command}));return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Token Efficiency`}),(0,B.jsx)(E,{width:`100%`,height:220,children:(0,B.jsxs)(et,{layout:`vertical`,data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,B.jsx)(R,{strokeDasharray:`3 3`,stroke:`var(--color-border)`,horizontal:!1}),(0,B.jsx)(M,{type:`number`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,tickFormatter:e=>e>=1e3?`${(e/1e3).toFixed(0)}k`:String(e)}),(0,B.jsx)(P,{type:`category`,dataKey:`name`,width:110,tick:{fontSize:9,fill:`var(--color-muted-foreground)`,fontFamily:`monospace`},axisLine:!1,tickLine:!1}),(0,B.jsx)(T,{content:(0,B.jsx)(ea,{})}),(0,B.jsx)(G,{formatter:e=>(0,B.jsx)(`span`,{className:`text-xs`,children:e})}),(0,B.jsx)(j,{dataKey:`tokensOut`,name:`Output tokens`,fill:I.purple,stackId:`a`,radius:[0,3,3,0]}),(0,B.jsx)(j,{dataKey:`tokensCacheRead`,name:`Cached tokens`,fill:I.cyan,stackId:`a`,radius:[0,3,3,0]})]})})]})}function na(e){return e===null?`—`:`$${e.toFixed(4)}`}function ra(e){if(e===null)return`—`;let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${r}s`}function ia({rate:e}){let t=(e*100).toFixed(0);return(0,B.jsxs)(`span`,{className:o(`inline-block px-1.5 py-0.5 rounded text-[10px] font-medium`,e>=.8?`bg-green-400/10 text-green-400`:e>=.5?`bg-orange-400/10 text-orange-400`:`bg-red-400/10 text-red-400`),children:[t,`%`]})}function $({label:e,sortKey:t,current:n,dir:r,onSort:i}){return(0,B.jsx)(`th`,{onClick:()=>i(t),className:`px-3 py-2 text-left text-[10px] font-medium text-muted-foreground uppercase tracking-wide cursor-pointer select-none hover:text-foreground whitespace-nowrap`,children:(0,B.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e,n===t?r===`asc`?(0,B.jsx)(Kt,{className:`w-3 h-3`}):(0,B.jsx)(Jt,{className:`w-3 h-3`}):(0,B.jsx)(Zt,{className:`w-3 h-3 opacity-40`})]})})}function aa({data:e}){let[t,n]=(0,z.useState)(`totalCostUsd`),[r,i]=(0,z.useState)(`desc`);function a(e){e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))}let o=[...e].sort((e,n)=>{let i=e[t]??-1/0,a=n[t]??-1/0,o=typeof i==`string`?i.localeCompare(a):i-a;return r===`asc`?o:-o});return e.length===0?(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Command Performance`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No command data for this period`})]}):(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Command Performance`}),(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-border/30`,children:[(0,B.jsx)($,{label:`Command`,sortKey:`command`,current:t,dir:r,onSort:a}),(0,B.jsx)($,{label:`Runs`,sortKey:`totalRuns`,current:t,dir:r,onSort:a}),(0,B.jsx)($,{label:`Success Rate`,sortKey:`successRate`,current:t,dir:r,onSort:a}),(0,B.jsx)($,{label:`Avg Cost`,sortKey:`avgCostUsd`,current:t,dir:r,onSort:a}),(0,B.jsx)($,{label:`Avg Duration`,sortKey:`avgDurationMs`,current:t,dir:r,onSort:a}),(0,B.jsx)($,{label:`Total Cost`,sortKey:`totalCostUsd`,current:t,dir:r,onSort:a})]})}),(0,B.jsx)(`tbody`,{children:o.map(e=>(0,B.jsxs)(`tr`,{className:`border-b border-border/20 hover:bg-accent/20 transition-colors`,children:[(0,B.jsx)(`td`,{className:`px-3 py-2 font-mono text-[10px] text-foreground`,children:e.command}),(0,B.jsx)(`td`,{className:`px-3 py-2 tabular-nums`,children:e.totalRuns}),(0,B.jsx)(`td`,{className:`px-3 py-2`,children:(0,B.jsx)(ia,{rate:e.successRate})}),(0,B.jsx)(`td`,{className:`px-3 py-2 tabular-nums`,children:na(e.avgCostUsd)}),(0,B.jsx)(`td`,{className:`px-3 py-2 tabular-nums`,children:ra(e.avgDurationMs)}),(0,B.jsx)(`td`,{className:`px-3 py-2 tabular-nums font-medium`,children:na(e.totalCostUsd)})]},e.command))})]})})]})}function oa({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),t.map(e=>(0,B.jsxs)(`p`,{style:{color:e.color},children:[e.name,`: `,e.value]},e.name))]})}function sa(e){try{return Le(new Date(e),`MMM d`)}catch{return e}}function ca({data:e}){if(!(e.length>0&&e.some(e=>e.completed+e.failed+e.canceled>0)))return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Daily Throughput`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No throughput data for this period`})]});let t=Math.max(1,Math.floor(e.length/7)),n=e.filter((e,n)=>n%t===0).map(e=>e.date);return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Daily Throughput`}),(0,B.jsx)(E,{width:`100%`,height:220,children:(0,B.jsxs)(et,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,B.jsx)(R,{strokeDasharray:`3 3`,stroke:`var(--color-border)`,vertical:!1}),(0,B.jsx)(M,{dataKey:`date`,ticks:n,tickFormatter:sa,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,B.jsx)(P,{allowDecimals:!1,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:30}),(0,B.jsx)(T,{content:(0,B.jsx)(oa,{})}),(0,B.jsx)(G,{formatter:e=>(0,B.jsx)(`span`,{className:`text-xs capitalize`,children:e})}),(0,B.jsx)(j,{dataKey:`completed`,name:`Completed`,stackId:`a`,fill:I.purple}),(0,B.jsx)(j,{dataKey:`failed`,name:`Failed`,stackId:`a`,fill:I.pink}),(0,B.jsx)(j,{dataKey:`canceled`,name:`Canceled`,stackId:`a`,fill:I.orange,radius:[3,3,0,0]})]})})]})}function la({x:e=0,y:t=0,width:n=0,height:r=0,name:i=``,size:a=0,colorIndex:o=0}){let s=Tt[o%Tt.length];return(0,B.jsxs)(`g`,{children:[(0,B.jsx)(`rect`,{x:e,y:t,width:n,height:r,style:{fill:s,fillOpacity:.8,stroke:`var(--color-background)`,strokeWidth:2},rx:4}),n>50&&r>30&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`text`,{x:e+6,y:t+16,fill:`var(--color-background)`,fontSize:10,fontFamily:`monospace`,style:{overflow:`hidden`},children:i.length>Math.floor(n/6)?i.slice(0,Math.floor(n/6)-1)+`…`:i}),r>45&&(0,B.jsxs)(`text`,{x:e+6,y:t+30,fill:`hsl(231 15% 18% / 0.7)`,fontSize:9,children:[`$`,a.toFixed(4)]})]})]})}function ua({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return n?(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`font-mono font-medium mb-1`,children:n.name}),(0,B.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Cost: $`,n.size.toFixed(4)]}),(0,B.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Jobs: `,n.jobCount]})]}):null}function da({data:e}){let t=e.filter(e=>e.totalCostUsd>0);if(t.length===0)return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost per Command`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No cost data for this period`})]});let n=t.map((e,t)=>({name:e.command,size:e.totalCostUsd,jobCount:e.jobCount,colorIndex:t}));return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost per Command`}),(0,B.jsx)(E,{width:`100%`,height:220,children:(0,B.jsx)(Wi,{data:n,dataKey:`size`,content:(0,B.jsx)(la,{}),children:(0,B.jsx)(T,{content:(0,B.jsx)(ua,{})})})})]})}function fa({label:e,value:t}){return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-3 space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide`,children:e}),(0,B.jsx)(`p`,{className:`text-base font-semibold tabular-nums`,children:t})]})}function pa({data:e}){let t=e.costPerSuccess===null?`—`:`$${e.costPerSuccess.toFixed(4)}`,n=e.apiEfficiencyPct===null?`—`:`${e.apiEfficiencyPct.toFixed(0)}%`,r=`$${e.failureCostUsd.toFixed(4)}`;return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium`,children:`Bonus Metrics`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,B.jsx)(fa,{label:`Cost per Success`,value:t}),(0,B.jsx)(fa,{label:`API Efficiency`,value:n}),(0,B.jsx)(fa,{label:`Failure Cost`,value:r})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:`Model Breakdown`}),e.modelBreakdown.length===0?(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No model data for this period`}):(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-border/30`,children:[(0,B.jsx)(`th`,{className:`px-3 py-1.5 text-left text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Model`}),(0,B.jsx)(`th`,{className:`px-3 py-1.5 text-left text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Jobs`}),(0,B.jsx)(`th`,{className:`px-3 py-1.5 text-left text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Total Cost`})]})}),(0,B.jsx)(`tbody`,{children:e.modelBreakdown.map(e=>(0,B.jsxs)(`tr`,{className:`border-b border-border/20`,children:[(0,B.jsx)(`td`,{className:`px-3 py-1.5 font-mono text-[10px]`,children:e.model}),(0,B.jsx)(`td`,{className:`px-3 py-1.5 tabular-nums`,children:e.jobCount}),(0,B.jsxs)(`td`,{className:`px-3 py-1.5 tabular-nums`,children:[`$`,e.totalCostUsd.toFixed(4)]})]},e.model))})]})})]})]})}var ma=[{key:`cost`,label:`Avg Cost ($)`,color:I.purple},{key:`duration`,label:`Avg Duration (min)`,color:I.cyan},{key:`successRate`,label:`Success Rate (%)`,color:I.green}];function ha({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),t.map(e=>(0,B.jsxs)(`p`,{style:{color:e.color},children:[e.name,`: `,(0,B.jsx)(`span`,{className:`font-medium`,children:e.value})]},e.name))]})}function ga(e){try{return Le(new Date(e),`MMM d`)}catch{return e}}function _a({points:e}){let[t,n]=(0,z.useState)(new Set([`cost`,`successRate`])),r=e.some(e=>e.jobCount>0),i=e.map(e=>({date:e.date,cost:e.avgCostUsd===null?0:parseFloat(e.avgCostUsd.toFixed(4)),duration:e.avgDurationMs===null?0:parseFloat((e.avgDurationMs/6e4).toFixed(2)),successRate:parseFloat((e.successRate*100).toFixed(1)),jobCount:e.jobCount})),a=Math.max(1,Math.floor(e.length/7)),o=e.filter((e,t)=>t%a===0).map(e=>e.date);function s(e){n(t=>{let n=new Set(t);return n.has(e)?n.size>1&&n.delete(e):n.add(e),n})}return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium`,children:`Performance Trends`}),(0,B.jsx)(`div`,{className:`flex items-center gap-2`,children:ma.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(e.key),className:`flex items-center gap-1 text-[10px] px-2 py-0.5 rounded transition-colors ${t.has(e.key)?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full inline-block shrink-0`,style:{background:e.color}}),e.label]},e.key))})]}),r?(0,B.jsx)(E,{width:`100%`,height:220,children:(0,B.jsxs)(Ne,{data:i,margin:{top:4,right:8,left:0,bottom:0},children:[(0,B.jsx)(R,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,B.jsx)(M,{dataKey:`date`,ticks:o,tickFormatter:ga,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,B.jsx)(P,{tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:40}),(0,B.jsx)(T,{content:(0,B.jsx)(ha,{})}),(0,B.jsx)(G,{wrapperStyle:{fontSize:`10px`,paddingTop:`8px`}}),t.has(`cost`)&&(0,B.jsx)(Ae,{type:`monotone`,dataKey:`cost`,name:`Avg Cost ($)`,stroke:I.purple,strokeWidth:2,dot:!1,activeDot:{r:3,fill:I.purple}}),t.has(`duration`)&&(0,B.jsx)(Ae,{type:`monotone`,dataKey:`duration`,name:`Avg Duration (min)`,stroke:I.cyan,strokeWidth:2,dot:!1,activeDot:{r:3,fill:I.cyan}}),t.has(`successRate`)&&(0,B.jsx)(Ae,{type:`monotone`,dataKey:`successRate`,name:`Success Rate (%)`,stroke:I.green,strokeWidth:2,dot:!1,activeDot:{r:3,fill:I.green}})]})}):(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No job data for this period`})]})}function va(){return(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,B.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,B.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:Array.from({length:4}).map((e,t)=>(0,B.jsx)(`div`,{className:`h-[260px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,B.jsx)(`div`,{className:`h-[180px] rounded-lg border border-border/40 bg-card/50 animate-pulse`})]})}function ya({message:e,onRetry:t}){return(0,B.jsxs)(`div`,{className:`rounded-lg border border-red-400/30 bg-red-400/10 p-4 flex items-center justify-between`,children:[(0,B.jsx)(`p`,{className:`text-sm text-red-400`,children:e}),(0,B.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1.5 h-7 px-3 rounded-md text-xs text-red-400 border border-red-400/30 hover:bg-red-400/10 transition-colors`,children:[(0,B.jsx)(Gt,{className:`w-3 h-3`}),`Retry`]})]})}var ba=[{value:`1d`,label:`1d`},{value:`7d`,label:`7d`},{value:`30d`,label:`30d`}];function xa(){let{activeProjectId:e}=qt(),[t,n]=(0,z.useState)(`7d`),[r,i]=(0,z.useState)(``),[a,o]=(0,z.useState)(``),[s,c]=(0,z.useState)(null),[l,u]=(0,z.useState)(!0),[d,f]=(0,z.useState)(null),[p,m]=(0,z.useState)(0),[h,g]=(0,z.useState)(`7d`),[_,v]=(0,z.useState)(null),y=(0,z.useRef)(new Map);(0,z.useEffect)(()=>{if(e){let t=y.current.get(e);t&&(c(t),u(!1))}let n=new AbortController;!s&&!y.current.get(e??``)&&u(!0),f(null);let i=new URLSearchParams({period:t});if(t===`custom`){if(!r||!a){u(!1);return}i.set(`from`,r),i.set(`to`,a)}return fetch(`${Ut()}/analytics?${i}`,{signal:n.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{c(t),e&&y.current.set(e,t),u(!1)}).catch(e=>{e.name!==`AbortError`&&(f(e.message),u(!1))}),()=>n.abort()},[t,r,a,p,e]),(0,z.useEffect)(()=>{let e=new AbortController;return fetch(`${Ut()}/trends?period=${h}`,{signal:e.signal}).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>v(e)).catch(e=>{e.name!==`AbortError`&&console.warn(`[analytics] trends fetch failed:`,e.message)}),()=>e.abort()},[h,e]);function b(e,t,r){n(e),i(t??``),o(r??``)}function x(){m(e=>e+1)}return(0,B.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,B.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h1`,{className:`text-base font-semibold`,children:`Project Analytics`}),s&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:s.period.label})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(zt,{period:t,from:r,to:a,onChange:b}),(0,B.jsx)(Xt,{baseUrl:`${Ut()}/analytics/export`,params:{period:t,...r?{from:r}:{},...a?{to:a}:{}}})]})]}),l&&(0,B.jsx)(va,{}),!l&&d&&(0,B.jsx)(ya,{message:`Failed to load analytics: ${d}`,onRetry:x}),!l&&!d&&s&&(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsx)(an,{kpi:s.kpi}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,B.jsx)(qi,{data:s.costTimeline}),(0,B.jsx)(Yi,{data:s.statusBreakdown}),(0,B.jsx)($i,{data:s.durationHistogram,percentiles:s.durationPercentiles}),(0,B.jsx)(ta,{data:s.tokenEfficiency})]}),(0,B.jsx)(aa,{data:s.commandPerformance}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,B.jsx)(ca,{data:s.dailyThroughput}),(0,B.jsx)(da,{data:s.costPerCommand})]}),(0,B.jsx)(pa,{data:s.bonusMetrics}),_&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium`,children:`Trends`}),(0,B.jsx)(`div`,{className:`flex items-center gap-1`,children:ba.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>g(e.value),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${h===e.value?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:e.label},e.value))})]}),(0,B.jsx)(_a,{points:_.points})]})]})]})}export{xa as default};
@@ -1,4 +1,4 @@
1
- import{n as e,o as t,r as n}from"./createLucideIcon-Cg9402G2.js";import{t as r}from"./utils-DNQKxVT4.js";import{$ as i,F as a,P as o,ct as s,f as c,ot as l,p as u,tt as d}from"./index-geDvjEca.js";import{t as f}from"./lib-BjJ39703.js";/* empty css */var p=t(n(),1),m=e();function h({categories:e,activeCategory:t,activeSlug:n,onSelect:i,onHome:a}){return(0,m.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,m.jsxs)(`button`,{onClick:a,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,m.jsx)(s,{className:`w-3.5 h-3.5`}),`Documentation`]}),(0,m.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,m.jsxs)(`div`,{children:[(0,m.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,m.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,m.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:`No docs yet`}):(0,m.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(a=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{onClick:()=>i(e.slug,a.slug),className:r(`w-full flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors text-left`,t===e.slug&&n===a.slug?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,m.jsx)(d,{className:`w-3 h-3 flex-shrink-0`}),a.title]})},a.slug))})]},e.slug))})]})}function g({categories:e,onSelect:t}){let n=e.reduce((e,t)=>e+t.docs.length,0);return(0,m.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,m.jsxs)(`div`,{className:`mb-8`,children:[(0,m.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:`Documentation`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n===0?`No documents yet. Add Markdown files to ~/.specrails/docs/ to get started.`:`${n} document${n===1?``:`s`} across ${e.filter(e=>e.docs.length>0).length} categories.`})]}),(0,m.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:`No documents in this category yet.`}):(0,m.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(n=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group text-left`,children:[(0,m.jsx)(d,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,m.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:n.title}),(0,m.jsx)(l,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))})]})}function _({category:e,slug:t,onNotFound:n}){let[r,s]=(0,p.useState)(null),[c,l]=(0,p.useState)(!0),[u,d]=(0,p.useState)(null);return(0,p.useEffect)(()=>{l(!0),d(null),s(null),fetch(`/api/docs/${e}/${t}`).then(async e=>{if(e.status===404){n();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{e&&s(e)}).catch(e=>{d(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>l(!1))},[e,t,n]),c?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):r?(0,m.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,m.jsx)(`div`,{className:`prose prose-sm max-w-none
1
+ import{n as e,o as t,r as n}from"./createLucideIcon-Cg9402G2.js";import{t as r}from"./utils-DNQKxVT4.js";import{$ as i,F as a,P as o,ct as s,f as c,ot as l,p as u,tt as d}from"./index-W5VPSfMl.js";import{t as f}from"./lib-Cw2QKuE3.js";/* empty css */var p=t(n(),1),m=e();function h({categories:e,activeCategory:t,activeSlug:n,onSelect:i,onHome:a}){return(0,m.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,m.jsxs)(`button`,{onClick:a,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,m.jsx)(s,{className:`w-3.5 h-3.5`}),`Documentation`]}),(0,m.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,m.jsxs)(`div`,{children:[(0,m.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,m.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,m.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:`No docs yet`}):(0,m.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(a=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{onClick:()=>i(e.slug,a.slug),className:r(`w-full flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors text-left`,t===e.slug&&n===a.slug?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,m.jsx)(d,{className:`w-3 h-3 flex-shrink-0`}),a.title]})},a.slug))})]},e.slug))})]})}function g({categories:e,onSelect:t}){let n=e.reduce((e,t)=>e+t.docs.length,0);return(0,m.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,m.jsxs)(`div`,{className:`mb-8`,children:[(0,m.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:`Documentation`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n===0?`No documents yet. Add Markdown files to ~/.specrails/docs/ to get started.`:`${n} document${n===1?``:`s`} across ${e.filter(e=>e.docs.length>0).length} categories.`})]}),(0,m.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:`No documents in this category yet.`}):(0,m.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(n=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group text-left`,children:[(0,m.jsx)(d,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,m.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:n.title}),(0,m.jsx)(l,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))})]})}function _({category:e,slug:t,onNotFound:n}){let[r,s]=(0,p.useState)(null),[c,l]=(0,p.useState)(!0),[u,d]=(0,p.useState)(null);return(0,p.useEffect)(()=>{l(!0),d(null),s(null),fetch(`/api/docs/${e}/${t}`).then(async e=>{if(e.status===404){n();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{e&&s(e)}).catch(e=>{d(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>l(!1))},[e,t,n]),c?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):r?(0,m.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,m.jsx)(`div`,{className:`prose prose-sm max-w-none
2
2
  prose-headings:text-foreground prose-headings:font-bold
3
3
  prose-p:text-foreground/90
4
4
  prose-a:text-dracula-purple prose-a:no-underline hover:prose-a:underline
@@ -1,4 +1,4 @@
1
- import{n as e,o as t,r as n}from"./createLucideIcon-Cg9402G2.js";import{t as r}from"./utils-DNQKxVT4.js";import{$ as i,F as a,P as o,_t as s,ct as c,gt as l,ht as u,ot as d,tt as f}from"./index-geDvjEca.js";import{t as p}from"./lib-BjJ39703.js";/* empty css */var m=t(n(),1),h=e();function g({categories:e,activeCategory:t,activeSlug:n}){return(0,h.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,h.jsxs)(u,{to:`/docs`,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,h.jsx)(c,{className:`w-3.5 h-3.5`}),`Documentation`]}),(0,h.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,h.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,h.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:`No docs yet`}):(0,h.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(i=>{let a=t===e.slug&&n===i.slug;return(0,h.jsx)(`li`,{children:(0,h.jsxs)(u,{to:`/docs/${e.slug}/${i.slug}`,className:r(`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors`,a?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,h.jsx)(f,{className:`w-3 h-3 flex-shrink-0`}),i.title]})},i.slug)})})]},e.slug))})]})}function _({categories:e}){let t=e.reduce((e,t)=>e+t.docs.length,0);return(0,h.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:`Documentation`}),(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t===0?`No documents yet. Add Markdown files to ~/.specrails/docs/ to get started.`:`${t} document${t===1?``:`s`} across ${e.filter(e=>e.docs.length>0).length} categories.`})]}),(0,h.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:`No documents in this category yet.`}):(0,h.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(t=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(u,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group`,children:[(0,h.jsx)(f,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,h.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:t.title}),(0,h.jsx)(d,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))})]})}function v({category:e,slug:t}){let[n,r]=(0,m.useState)(null),[s,c]=(0,m.useState)(!0),[u,d]=(0,m.useState)(null),f=l();return(0,m.useEffect)(()=>{c(!0),d(null),r(null),fetch(`/api/docs/${e}/${t}`).then(async e=>{if(e.status===404){f(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{e&&r(e)}).catch(e=>{d(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>c(!1))},[e,t,f]),s?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):n?(0,h.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,h.jsx)(`div`,{className:`prose prose-sm max-w-none
1
+ import{n as e,o as t,r as n}from"./createLucideIcon-Cg9402G2.js";import{t as r}from"./utils-DNQKxVT4.js";import{$ as i,F as a,P as o,_t as s,ct as c,gt as l,ht as u,ot as d,tt as f}from"./index-W5VPSfMl.js";import{t as p}from"./lib-Cw2QKuE3.js";/* empty css */var m=t(n(),1),h=e();function g({categories:e,activeCategory:t,activeSlug:n}){return(0,h.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,h.jsxs)(u,{to:`/docs`,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,h.jsx)(c,{className:`w-3.5 h-3.5`}),`Documentation`]}),(0,h.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,h.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,h.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:`No docs yet`}):(0,h.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(i=>{let a=t===e.slug&&n===i.slug;return(0,h.jsx)(`li`,{children:(0,h.jsxs)(u,{to:`/docs/${e.slug}/${i.slug}`,className:r(`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors`,a?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,h.jsx)(f,{className:`w-3 h-3 flex-shrink-0`}),i.title]})},i.slug)})})]},e.slug))})]})}function _({categories:e}){let t=e.reduce((e,t)=>e+t.docs.length,0);return(0,h.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:`Documentation`}),(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t===0?`No documents yet. Add Markdown files to ~/.specrails/docs/ to get started.`:`${t} document${t===1?``:`s`} across ${e.filter(e=>e.docs.length>0).length} categories.`})]}),(0,h.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:`No documents in this category yet.`}):(0,h.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(t=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(u,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group`,children:[(0,h.jsx)(f,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,h.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:t.title}),(0,h.jsx)(d,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))})]})}function v({category:e,slug:t}){let[n,r]=(0,m.useState)(null),[s,c]=(0,m.useState)(!0),[u,d]=(0,m.useState)(null),f=l();return(0,m.useEffect)(()=>{c(!0),d(null),r(null),fetch(`/api/docs/${e}/${t}`).then(async e=>{if(e.status===404){f(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{e&&r(e)}).catch(e=>{d(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>c(!1))},[e,t,f]),s?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):n?(0,h.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,h.jsx)(`div`,{className:`prose prose-sm max-w-none
2
2
  prose-headings:text-foreground prose-headings:font-bold
3
3
  prose-p:text-foreground/90
4
4
  prose-a:text-dracula-purple prose-a:no-underline hover:prose-a:underline
@@ -1 +1 @@
1
- import{n as e,o as t,r as n}from"./createLucideIcon-Cg9402G2.js";import{nt as r}from"./index-geDvjEca.js";var i=t(n(),1),a=e();function o({baseUrl:e,params:t,label:n=`Export`}){let[o,s]=(0,i.useState)(!1),[c,l]=(0,i.useState)(!1),u=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(!o)return;function e(e){u.current&&!u.current.contains(e.target)&&s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);function d(n){return`${e}?${new URLSearchParams({format:n,...t}).toString()}`}function f(){s(!1),window.open(d(`csv`),`_blank`)}let p=(0,i.useCallback)(async()=>{s(!1),l(!0);try{let t=await fetch(d(`json`));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.split(`/`).filter(Boolean).pop()??`export`}.json`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] JSON download failed:`,e)}finally{l(!1)}},[e,t]);return(0,a.jsxs)(`div`,{ref:u,className:`relative`,children:[(0,a.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":o,disabled:c,onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,a.jsx)(r,{className:`w-3 h-3`}),c?`Downloading…`:n]}),o&&(0,a.jsxs)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[130px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:[(0,a.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:f,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,a.jsx)(r,{className:`w-3 h-3 shrink-0`}),`Export CSV`]}),(0,a.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:p,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,a.jsx)(r,{className:`w-3 h-3 shrink-0`}),`Export JSON`]})]})]})}export{o as t};
1
+ import{n as e,o as t,r as n}from"./createLucideIcon-Cg9402G2.js";import{nt as r}from"./index-W5VPSfMl.js";var i=t(n(),1),a=e();function o({baseUrl:e,params:t,label:n=`Export`}){let[o,s]=(0,i.useState)(!1),[c,l]=(0,i.useState)(!1),u=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(!o)return;function e(e){u.current&&!u.current.contains(e.target)&&s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);function d(n){return`${e}?${new URLSearchParams({format:n,...t}).toString()}`}function f(){s(!1),window.open(d(`csv`),`_blank`)}let p=(0,i.useCallback)(async()=>{s(!1),l(!0);try{let t=await fetch(d(`json`));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.split(`/`).filter(Boolean).pop()??`export`}.json`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] JSON download failed:`,e)}finally{l(!1)}},[e,t]);return(0,a.jsxs)(`div`,{ref:u,className:`relative`,children:[(0,a.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":o,disabled:c,onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,a.jsx)(r,{className:`w-3 h-3`}),c?`Downloading…`:n]}),o&&(0,a.jsxs)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[130px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:[(0,a.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:f,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,a.jsx)(r,{className:`w-3 h-3 shrink-0`}),`Export CSV`]}),(0,a.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:p,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,a.jsx)(r,{className:`w-3 h-3 shrink-0`}),`Export JSON`]})]})]})}export{o as t};
@@ -1 +1 @@
1
- import{n as e,o as t,r as n}from"./createLucideIcon-Cg9402G2.js";import{I as r,Mt as i,_ as a,a as o,bn as s,g as c,h as l,i as u,m as d,n as f,t as p,v as m,xn as h,yn as g}from"./dracula-colors-3Ah9nKDo.js";import{N as _,Y as v}from"./index-geDvjEca.js";var y=t(n(),1),b=e();function x({kpi:e}){return(0,b.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{label:`Total Cost`,value:`$${e.totalCostUsd.toFixed(4)}`,sub:`$${e.costToday.toFixed(4)} today`},{label:`Total Jobs`,value:e.totalJobs.toLocaleString(),sub:`${e.jobsToday} today`},{label:`Success Rate`,value:`${(e.successRate*100).toFixed(1)}%`,sub:`across all projects`},{label:`Avg Cost / Job`,value:e.totalJobs>0?`$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:`period average`}].map(e=>(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:e.label}),(0,b.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.label))})}function S({data:e}){let t=e.length>0&&e.some(e=>e.costUsd>0),n=Math.max(1,Math.floor(e.length/7)),c=e.filter((e,t)=>t%n===0).map(e=>e.date);return(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cross-Project Cost Over Time`}),t?(0,b.jsx)(i,{width:`100%`,height:200,children:(0,b.jsxs)(o,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,b.jsx)(m,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,b.jsx)(l,{dataKey:`date`,ticks:c,tickFormatter:e=>{try{return s(new Date(e),`MMM d`)}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,b.jsx)(d,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,b.jsx)(r,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,b.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,b.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,b.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,b.jsx)(a,{type:`monotone`,dataKey:`costUsd`,stroke:f.purple,strokeWidth:2,dot:!1,activeDot:{r:3,fill:f.purple}})]})}):(0,b.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:`No cost data for this period`})]})}function C({projects:e}){if(e.length===0)return(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Project Comparison`}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No projects registered.`})]});let t=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:`Project Comparison`}),(0,b.jsx)(`div`,{className:`space-y-3`,children:e.map((e,n)=>(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,b.jsx)(`span`,{className:`font-medium truncate max-w-[160px]`,title:e.projectName,children:e.projectName}),(0,b.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,b.jsxs)(`span`,{children:[e.totalJobs,` jobs`]}),(0,b.jsxs)(`span`,{children:[(e.successRate*100).toFixed(0),`% success`]}),(0,b.jsxs)(`span`,{className:`font-mono text-foreground`,children:[`$`,e.totalCostUsd.toFixed(4)]})]})]}),(0,b.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/t*100}%`,backgroundColor:p[n%p.length]}})})]},e.projectId))})]})}function w({projects:e}){if(e.length===0)return null;let t=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));return(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost by Project`}),(0,b.jsx)(i,{width:`100%`,height:180,children:(0,b.jsxs)(u,{data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,b.jsx)(m,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,b.jsx)(l,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,b.jsx)(d,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,b.jsx)(r,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,b.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,b.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,b.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,b.jsx)(c,{dataKey:`costUsd`,fill:f.cyan,radius:[3,3,0,0]})]})})]})}function T(){let[e,t]=(0,y.useState)(`7d`),[n,r]=(0,y.useState)(``),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(null),{registerHandler:f,unregisterHandler:p}=_(),m=(0,y.useCallback)(t=>{let r=t;r.type===`log`&&r.event_type===`job_done`&&T(e,n,i)},[e,n,i]);(0,y.useEffect)(()=>(f(`hub-analytics`,m),()=>p(`hub-analytics`)),[m,f,p]);async function T(e,t,n){l(!0),d(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/hub/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);s(await i.json())}catch(e){d(e.message)}finally{l(!1)}}(0,y.useEffect)(()=>{T(e,n,i)},[e,n,i]);function E(e,n,i){t(e),n!==void 0&&r(n),i!==void 0&&a(i)}return(0,b.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,b.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(h,{className:`w-4 h-4 text-muted-foreground`}),(0,b.jsx)(`h1`,{className:`text-sm font-semibold`,children:`Hub Analytics`}),o&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o.period.label})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(g,{period:e,from:n,to:i,onChange:E}),(0,b.jsx)(`button`,{onClick:()=>T(e,n,i),disabled:c,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":`Refresh analytics`,children:(0,b.jsx)(v,{className:`w-3 h-3 ${c?`animate-spin`:``}`})})]})]}),u&&(0,b.jsxs)(`div`,{className:`rounded-lg border border-red-400/30 bg-red-400/10 p-3 text-xs text-red-400`,children:[`Failed to load analytics: `,u]}),c&&!o&&(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,b.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,b.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,b.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),o&&(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsx)(x,{kpi:o.kpi}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,b.jsx)(S,{data:o.costTimeline}),(0,b.jsx)(w,{projects:o.projectBreakdown})]}),(0,b.jsx)(C,{projects:o.projectBreakdown})]})]})})}export{T as default};
1
+ import{n as e,o as t,r as n}from"./createLucideIcon-Cg9402G2.js";import{I as r,Mt as i,_ as a,a as o,bn as s,g as c,h as l,i as u,m as d,n as f,t as p,v as m,xn as h,yn as g}from"./dracula-colors-BbrPsQvf.js";import{N as _,Y as v}from"./index-W5VPSfMl.js";var y=t(n(),1),b=e();function x({kpi:e}){return(0,b.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{label:`Total Cost`,value:`$${e.totalCostUsd.toFixed(4)}`,sub:`$${e.costToday.toFixed(4)} today`},{label:`Total Jobs`,value:e.totalJobs.toLocaleString(),sub:`${e.jobsToday} today`},{label:`Success Rate`,value:`${(e.successRate*100).toFixed(1)}%`,sub:`across all projects`},{label:`Avg Cost / Job`,value:e.totalJobs>0?`$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:`period average`}].map(e=>(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1`,children:e.label}),(0,b.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.label))})}function S({data:e}){let t=e.length>0&&e.some(e=>e.costUsd>0),n=Math.max(1,Math.floor(e.length/7)),c=e.filter((e,t)=>t%n===0).map(e=>e.date);return(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cross-Project Cost Over Time`}),t?(0,b.jsx)(i,{width:`100%`,height:200,children:(0,b.jsxs)(o,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,b.jsx)(m,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,b.jsx)(l,{dataKey:`date`,ticks:c,tickFormatter:e=>{try{return s(new Date(e),`MMM d`)}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,b.jsx)(d,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,b.jsx)(r,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,b.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,b.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,b.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,b.jsx)(a,{type:`monotone`,dataKey:`costUsd`,stroke:f.purple,strokeWidth:2,dot:!1,activeDot:{r:3,fill:f.purple}})]})}):(0,b.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:`No cost data for this period`})]})}function C({projects:e}){if(e.length===0)return(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Project Comparison`}),(0,b.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No projects registered.`})]});let t=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:`Project Comparison`}),(0,b.jsx)(`div`,{className:`space-y-3`,children:e.map((e,n)=>(0,b.jsxs)(`div`,{className:`space-y-1`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,b.jsx)(`span`,{className:`font-medium truncate max-w-[160px]`,title:e.projectName,children:e.projectName}),(0,b.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,b.jsxs)(`span`,{children:[e.totalJobs,` jobs`]}),(0,b.jsxs)(`span`,{children:[(e.successRate*100).toFixed(0),`% success`]}),(0,b.jsxs)(`span`,{className:`font-mono text-foreground`,children:[`$`,e.totalCostUsd.toFixed(4)]})]})]}),(0,b.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,b.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/t*100}%`,backgroundColor:p[n%p.length]}})})]},e.projectId))})]})}function w({projects:e}){if(e.length===0)return null;let t=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));return(0,b.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,b.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost by Project`}),(0,b.jsx)(i,{width:`100%`,height:180,children:(0,b.jsxs)(u,{data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,b.jsx)(m,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,b.jsx)(l,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,b.jsx)(d,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,b.jsx)(r,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,b.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,b.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,b.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,b.jsx)(c,{dataKey:`costUsd`,fill:f.cyan,radius:[3,3,0,0]})]})})]})}function T(){let[e,t]=(0,y.useState)(`7d`),[n,r]=(0,y.useState)(``),[i,a]=(0,y.useState)(``),[o,s]=(0,y.useState)(null),[c,l]=(0,y.useState)(!0),[u,d]=(0,y.useState)(null),{registerHandler:f,unregisterHandler:p}=_(),m=(0,y.useCallback)(t=>{let r=t;r.type===`log`&&r.event_type===`job_done`&&T(e,n,i)},[e,n,i]);(0,y.useEffect)(()=>(f(`hub-analytics`,m),()=>p(`hub-analytics`)),[m,f,p]);async function T(e,t,n){l(!0),d(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/hub/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);s(await i.json())}catch(e){d(e.message)}finally{l(!1)}}(0,y.useEffect)(()=>{T(e,n,i)},[e,n,i]);function E(e,n,i){t(e),n!==void 0&&r(n),i!==void 0&&a(i)}return(0,b.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,b.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,b.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,b.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,b.jsx)(h,{className:`w-4 h-4 text-muted-foreground`}),(0,b.jsx)(`h1`,{className:`text-sm font-semibold`,children:`Hub Analytics`}),o&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:o.period.label})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(g,{period:e,from:n,to:i,onChange:E}),(0,b.jsx)(`button`,{onClick:()=>T(e,n,i),disabled:c,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":`Refresh analytics`,children:(0,b.jsx)(v,{className:`w-3 h-3 ${c?`animate-spin`:``}`})})]})]}),u&&(0,b.jsxs)(`div`,{className:`rounded-lg border border-red-400/30 bg-red-400/10 p-3 text-xs text-red-400`,children:[`Failed to load analytics: `,u]}),c&&!o&&(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,b.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,b.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,b.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),o&&(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsx)(x,{kpi:o.kpi}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,b.jsx)(S,{data:o.costTimeline}),(0,b.jsx)(w,{projects:o.projectBreakdown})]}),(0,b.jsx)(C,{projects:o.projectBreakdown})]})]})})}export{T as default};
@@ -1,4 +1,4 @@
1
- import{n as e,o as t,r as n,t as r}from"./createLucideIcon-Cg9402G2.js";import{t as i}from"./utils-DNQKxVT4.js";import{t as a}from"./copy-C1m2IjcW.js";import{$ as o,B as s,F as c,J as l,K as u,N as d,P as f,_t as p,dt as m,ft as h,gt as g,ht as _,it as v,j as y,mt as b,n as x,nt as S,ot as C,pt as w,r as T,rt as E,st as D,v as O,z as k}from"./index-geDvjEca.js";import{t as A}from"./lib-BjJ39703.js";var j=r(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),M=r(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),N=t(n(),1),P=e();function F({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,P.jsx)(`div`,{className:`flex items-center`,children:t.map((n,r)=>{let a=e[n.key]??`idle`,o=r<t.length-1?e[t[r+1].key]??`idle`:null;return(0,P.jsxs)(`div`,{className:`flex items-center`,children:[(0,P.jsxs)(m,{children:[(0,P.jsx)(w,{asChild:!0,children:(0,P.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,P.jsx)(I,{state:a}),(0,P.jsx)(`span`,{className:i(`text-xs font-medium transition-colors`,a===`running`?`text-blue-400`:a===`done`?`text-emerald-400`:a===`error`?`text-red-400`:`text-muted-foreground/40`),children:n.label})]})}),(0,P.jsxs)(h,{side:`bottom`,className:`max-w-[200px]`,children:[(0,P.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,P.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:n.description})]})]}),o!==null&&(0,P.jsx)(`div`,{className:i(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,o===`done`||a===`done`?`bg-emerald-500/30`:o===`running`?`bg-blue-400/40`:`bg-border/30`)})]},n.key)})})}function I({state:e}){return(0,P.jsxs)(`div`,{className:i(`flex items-center justify-center w-10 h-10 rounded-full transition-all duration-300`,e===`running`?`bg-blue-500/10 ring-1 ring-blue-400/30 animate-pulse`:e===`done`?`bg-emerald-500/10`:e===`error`?`bg-red-500/10`:`bg-muted/20`),children:[e===`running`&&(0,P.jsx)(o,{className:`w-6 h-6 text-blue-400 animate-spin`}),e===`done`&&(0,P.jsx)(v,{className:`w-6 h-6 text-emerald-400`}),e===`error`&&(0,P.jsx)(E,{className:`w-6 h-6 text-red-400`}),e===`idle`&&(0,P.jsx)(j,{className:`w-6 h-6 text-muted-foreground/20`})]})}function L(e,t){let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function R(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}function z({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r}){let[a,o]=(0,N.useState)(n),s=(0,N.useMemo)(()=>R(t),[t]),c=e.status===`completed`;return(0,P.jsxs)(`div`,{className:i(`mx-4 my-2 rounded-xl border`,c?`border-emerald-500/20 bg-emerald-500/5`:`border-red-500/20 bg-red-500/5`),children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`w-full flex items-center gap-3 px-4 py-3`,children:[c?(0,P.jsx)(v,{className:`w-4 h-4 text-emerald-400 shrink-0`}):(0,P.jsx)(E,{className:`w-4 h-4 text-red-400 shrink-0`}),(0,P.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:c?`Job completed`:`Job failed`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[e.finished_at&&(0,P.jsx)(`span`,{className:`tabular-nums`,children:L(e.started_at,e.finished_at)}),e.total_cost_usd!=null&&(0,P.jsxs)(`span`,{className:`tabular-nums text-yellow-400`,children:[`$`,e.total_cost_usd.toFixed(4)]}),s.length>0&&(0,P.jsxs)(`span`,{children:[s.length,` file`,s.length===1?``:`s`]})]}),(0,P.jsx)(D,{className:i(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,a&&`rotate-180`)})]}),a&&(0,P.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2 pt-3`,children:[(0,P.jsx)(B,{label:`Duration`,value:e.finished_at?L(e.started_at,e.finished_at):`—`}),(0,P.jsx)(B,{label:`Cost`,value:e.total_cost_usd==null?`—`:`$${e.total_cost_usd.toFixed(4)}`,valueClass:`text-yellow-400`}),(0,P.jsx)(B,{label:`Turns`,value:e.num_turns==null?`—`:`${e.num_turns}`}),(0,P.jsx)(B,{label:`Tokens`,value:e.tokens_in==null?`—`:`${(((e.tokens_in??0)+(e.tokens_out??0))/1e3).toFixed(1)}k`})]}),r&&(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:[`Pipeline total (`,r.jobCount,` phases)`]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,P.jsx)(B,{label:`Total cost`,value:`$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400`}),(0,P.jsx)(B,{label:`Total tokens`,value:`${((r.totalTokensIn+r.totalTokensOut)/1e3).toFixed(1)}k`})]})]}),s.length>0&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:`Files modified`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,P.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80`,children:e},e))})]})]})]})}function B({label:e,value:t,valueClass:n}){return(0,P.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,P.jsx)(`p`,{className:i(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function V(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}function H(e,t){let n=`${e.id??t}`,r=e.timestamp;if(e.event_type===`log`)try{let t=JSON.parse(e.payload).line??``;return t.trim()?t.startsWith(`▸`)||t.match(/^(architect|developer|reviewer|ship|analyst)\s*:/i)?{id:n,content:t,type:`phase`,timestamp:r}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:r}:V(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(`${t.num_turns} turns`),{id:n,content:`▸ Completed${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function U(e){let t=`none`,n=[];for(let r of e){let e=r.type;if(e!==`plain`&&e!==`log`){t=`none`,n.push(r);continue}let i=r.content;i.startsWith(`--- `)?(t=`saw_minus`,n.push({...r,type:`diff-meta`})):t===`saw_minus`&&i.startsWith(`+++ `)?(t=`active`,n.push({...r,type:`diff-meta`})):t===`active`&&i.startsWith(`@@ `)?n.push({...r,type:`diff-hunk`}):t===`active`&&i.startsWith(`+`)&&!i.startsWith(`+++`)?n.push({...r,type:`diff-add`}):t===`active`&&i.startsWith(`-`)&&!i.startsWith(`---`)?n.push({...r,type:`diff-remove`}):(t===`active`&&(i.startsWith(` `)||i===``)||(t=`none`),n.push(r))}return n}function W(e){let t=[{key:`__preamble__`,header:null,lines:[]}];for(let n of e)n.type===`phase`?t.push({key:n.id,header:n,lines:[]}):t[t.length-1].lines.push(n);return t.filter(e=>e.header!==null||e.lines.length>0)}function G({events:e,isLoading:t}){let[n,r]=(0,N.useState)(``),[i,o]=(0,N.useState)(!0),[s,c]=(0,N.useState)(new Set),l=(0,N.useRef)(null),d=(0,N.useRef)(null),{processedLines:f,groups:p,totalLines:m}=(0,N.useMemo)(()=>{let t=e.map((e,t)=>H(e,t)).filter(e=>e!==null),n=[];for(let e of t){let t=n.length>0?n[n.length-1]:null;e.type===`assistant`&&t?.type===`assistant`?t.content+=`
1
+ import{n as e,o as t,r as n,t as r}from"./createLucideIcon-Cg9402G2.js";import{t as i}from"./utils-DNQKxVT4.js";import{t as a}from"./copy-C1m2IjcW.js";import{$ as o,B as s,F as c,J as l,K as u,N as d,P as f,_t as p,dt as m,ft as h,gt as g,ht as _,it as v,j as y,mt as b,n as x,nt as S,ot as C,pt as w,r as T,rt as E,st as D,v as O,z as k}from"./index-W5VPSfMl.js";import{t as A}from"./lib-Cw2QKuE3.js";var j=r(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),M=r(`house`,[[`path`,{d:`M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8`,key:`5wwlr5`}],[`path`,{d:`M3 10a2 2 0 0 1 .709-1.528l7-6a2 2 0 0 1 2.582 0l7 6A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,key:`r6nss1`}]]),N=t(n(),1),P=e();function F({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,P.jsx)(`div`,{className:`flex items-center`,children:t.map((n,r)=>{let a=e[n.key]??`idle`,o=r<t.length-1?e[t[r+1].key]??`idle`:null;return(0,P.jsxs)(`div`,{className:`flex items-center`,children:[(0,P.jsxs)(m,{children:[(0,P.jsx)(w,{asChild:!0,children:(0,P.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,P.jsx)(I,{state:a}),(0,P.jsx)(`span`,{className:i(`text-xs font-medium transition-colors`,a===`running`?`text-blue-400`:a===`done`?`text-emerald-400`:a===`error`?`text-red-400`:`text-muted-foreground/40`),children:n.label})]})}),(0,P.jsxs)(h,{side:`bottom`,className:`max-w-[200px]`,children:[(0,P.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,P.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:n.description})]})]}),o!==null&&(0,P.jsx)(`div`,{className:i(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,o===`done`||a===`done`?`bg-emerald-500/30`:o===`running`?`bg-blue-400/40`:`bg-border/30`)})]},n.key)})})}function I({state:e}){return(0,P.jsxs)(`div`,{className:i(`flex items-center justify-center w-10 h-10 rounded-full transition-all duration-300`,e===`running`?`bg-blue-500/10 ring-1 ring-blue-400/30 animate-pulse`:e===`done`?`bg-emerald-500/10`:e===`error`?`bg-red-500/10`:`bg-muted/20`),children:[e===`running`&&(0,P.jsx)(o,{className:`w-6 h-6 text-blue-400 animate-spin`}),e===`done`&&(0,P.jsx)(v,{className:`w-6 h-6 text-emerald-400`}),e===`error`&&(0,P.jsx)(E,{className:`w-6 h-6 text-red-400`}),e===`idle`&&(0,P.jsx)(j,{className:`w-6 h-6 text-muted-foreground/20`})]})}function L(e,t){let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}function R(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}function z({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r}){let[a,o]=(0,N.useState)(n),s=(0,N.useMemo)(()=>R(t),[t]),c=e.status===`completed`;return(0,P.jsxs)(`div`,{className:i(`mx-4 my-2 rounded-xl border`,c?`border-emerald-500/20 bg-emerald-500/5`:`border-red-500/20 bg-red-500/5`),children:[(0,P.jsxs)(`button`,{type:`button`,onClick:()=>o(!a),className:`w-full flex items-center gap-3 px-4 py-3`,children:[c?(0,P.jsx)(v,{className:`w-4 h-4 text-emerald-400 shrink-0`}):(0,P.jsx)(E,{className:`w-4 h-4 text-red-400 shrink-0`}),(0,P.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:c?`Job completed`:`Job failed`}),(0,P.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[e.finished_at&&(0,P.jsx)(`span`,{className:`tabular-nums`,children:L(e.started_at,e.finished_at)}),e.total_cost_usd!=null&&(0,P.jsxs)(`span`,{className:`tabular-nums text-yellow-400`,children:[`$`,e.total_cost_usd.toFixed(4)]}),s.length>0&&(0,P.jsxs)(`span`,{children:[s.length,` file`,s.length===1?``:`s`]})]}),(0,P.jsx)(D,{className:i(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,a&&`rotate-180`)})]}),a&&(0,P.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:[(0,P.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2 pt-3`,children:[(0,P.jsx)(B,{label:`Duration`,value:e.finished_at?L(e.started_at,e.finished_at):`—`}),(0,P.jsx)(B,{label:`Cost`,value:e.total_cost_usd==null?`—`:`$${e.total_cost_usd.toFixed(4)}`,valueClass:`text-yellow-400`}),(0,P.jsx)(B,{label:`Turns`,value:e.num_turns==null?`—`:`${e.num_turns}`}),(0,P.jsx)(B,{label:`Tokens`,value:e.tokens_in==null?`—`:`${(((e.tokens_in??0)+(e.tokens_out??0))/1e3).toFixed(1)}k`})]}),r&&(0,P.jsxs)(`div`,{children:[(0,P.jsxs)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:[`Pipeline total (`,r.jobCount,` phases)`]}),(0,P.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,P.jsx)(B,{label:`Total cost`,value:`$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400`}),(0,P.jsx)(B,{label:`Total tokens`,value:`${((r.totalTokensIn+r.totalTokensOut)/1e3).toFixed(1)}k`})]})]}),s.length>0&&(0,P.jsxs)(`div`,{children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:`Files modified`}),(0,P.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:s.map(e=>(0,P.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80`,children:e},e))})]})]})]})}function B({label:e,value:t,valueClass:n}){return(0,P.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,P.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,P.jsx)(`p`,{className:i(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function V(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}function H(e,t){let n=`${e.id??t}`,r=e.timestamp;if(e.event_type===`log`)try{let t=JSON.parse(e.payload).line??``;return t.trim()?t.startsWith(`▸`)||t.match(/^(architect|developer|reviewer|ship|analyst)\s*:/i)?{id:n,content:t,type:`phase`,timestamp:r}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:r}:V(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(`${t.num_turns} turns`),{id:n,content:`▸ Completed${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function U(e){let t=`none`,n=[];for(let r of e){let e=r.type;if(e!==`plain`&&e!==`log`){t=`none`,n.push(r);continue}let i=r.content;i.startsWith(`--- `)?(t=`saw_minus`,n.push({...r,type:`diff-meta`})):t===`saw_minus`&&i.startsWith(`+++ `)?(t=`active`,n.push({...r,type:`diff-meta`})):t===`active`&&i.startsWith(`@@ `)?n.push({...r,type:`diff-hunk`}):t===`active`&&i.startsWith(`+`)&&!i.startsWith(`+++`)?n.push({...r,type:`diff-add`}):t===`active`&&i.startsWith(`-`)&&!i.startsWith(`---`)?n.push({...r,type:`diff-remove`}):(t===`active`&&(i.startsWith(` `)||i===``)||(t=`none`),n.push(r))}return n}function W(e){let t=[{key:`__preamble__`,header:null,lines:[]}];for(let n of e)n.type===`phase`?t.push({key:n.id,header:n,lines:[]}):t[t.length-1].lines.push(n);return t.filter(e=>e.header!==null||e.lines.length>0)}function G({events:e,isLoading:t}){let[n,r]=(0,N.useState)(``),[i,o]=(0,N.useState)(!0),[s,c]=(0,N.useState)(new Set),l=(0,N.useRef)(null),d=(0,N.useRef)(null),{processedLines:f,groups:p,totalLines:m}=(0,N.useMemo)(()=>{let t=e.map((e,t)=>H(e,t)).filter(e=>e!==null),n=[];for(let e of t){let t=n.length>0?n[n.length-1]:null;e.type===`assistant`&&t?.type===`assistant`?t.content+=`
2
2
  `+e.content:n.push({...e})}let r=U(n);return{processedLines:r,groups:W(r),totalLines:r.length}},[e]),h=(0,N.useMemo)(()=>{if(!n)return m;let e=n.toLowerCase();return f.filter(t=>t.content.toLowerCase().includes(e)).length},[n,f,m]),g=(0,N.useCallback)(()=>{let e=d.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,N.useEffect)(()=>{i&&g()},[e.length,i,g]);function _(){let e=d.current;e&&o(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function v(e){c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,P.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading logs...`})}):m===0?(0,P.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,P.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No log output yet`})}):(0,P.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,P.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,P.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,P.jsx)(u,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,P.jsx)(x,{placeholder:`Filter logs...`,value:n,onChange:e=>r(e.target.value),className:`pl-7 h-7`})]}),(0,P.jsx)(k,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=f.map(e=>e.content).join(`
3
3
  `);navigator.clipboard.writeText(e).then(()=>{b.success(`Log copied to clipboard`)}).catch(()=>{b.error(`Failed to copy log`)})},children:(0,P.jsx)(a,{className:`w-3.5 h-3.5`})}),(0,P.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[h,` / `,m,` lines`]})]}),(0,P.jsxs)(`div`,{ref:d,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:_,children:[p.map(e=>(0,P.jsx)(K,{group:e,filter:n,collapsed:s.has(e.key),onToggle:()=>v(e.key)},e.key)),(0,P.jsx)(`div`,{ref:l})]}),!i&&(0,P.jsxs)(k,{size:`sm`,variant:`secondary`,onClick:()=>{o(!0),g()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,P.jsx)(D,{className:`w-3 h-3`}),`Jump to bottom`]})]})}var K=(0,N.memo)(function({group:e,filter:t,collapsed:n,onToggle:r}){let a=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return a.length===0?null:(0,P.jsx)(`div`,{children:a.map((e,t)=>(0,P.jsx)(J,{line:e,even:t%2==0},e.id))});let o=e.header.content;return(0,P.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,P.jsxs)(`button`,{type:`button`,onClick:r,className:i(`flex items-center gap-2 w-full text-left px-3 py-2`,`bg-primary/5 border-b border-primary/20`,`hover:bg-primary/10 transition-colors duration-150 cursor-pointer`),children:[(0,P.jsx)(C,{className:i(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,P.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:o}),e.header.timestamp&&(0,P.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 font-mono tabular-nums shrink-0`,children:new Date(e.header.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),(0,P.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:[e.lines.length,` lines`]})]}),!n&&(0,P.jsx)(`div`,{className:`bg-muted/5`,children:a.length===0?(0,P.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:t?`No matching lines`:`No output`}):a.map((e,t)=>(0,P.jsx)(J,{line:e,even:t%2==0},e.id))})]})}),q=[A],J=(0,N.memo)(function({line:e,even:t}){let n=e.type===`assistant`,r=e.type===`diff-add`,a=e.type===`diff-remove`,o=e.type===`diff-meta`,s=e.type===`diff-hunk`;return(0,P.jsxs)(`div`,{className:i(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!(r||a||o||s)&&(t?`bg-muted/20`:`bg-transparent`),e.type===`result`&&`bg-emerald-500/5 border-l-2 border-emerald-500/40 mt-2 py-2`,r&&`bg-emerald-500/8 border-l-2 border-emerald-500/50`,a&&`bg-red-500/8 border-l-2 border-red-500/50`,o&&`bg-dracula-purple/5 border-l-2 border-dracula-purple/30`,s&&`bg-dracula-cyan/5 border-l-2 border-dracula-cyan/30`),children:[e.timestamp&&(0,P.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0 mt-0.5 w-[52px] font-mono tabular-nums`,children:new Date(e.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),n?(0,P.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
4
4
  prose-p:my-1 prose-p:leading-relaxed