specrails-hub 1.35.0 → 1.36.1

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-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{n as i,r as a}from"./useHub-DWD4MWhf.js";import{n as o}from"./useSharedWebSocket-B3JjQYKi.js";import{B as s,E as c,F as l,M as u,P as d}from"./index-Dr38pDlk.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)(l,{className:`w-4 h-4 text-green-500 flex-shrink-0`});case`job_failed`:return(0,g.jsx)(d,{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)(c,{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}=i(),{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)(s,{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)(u,{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)(s,{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)(u,{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-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{n as i,r as a}from"./useHub-DWD4MWhf.js";import{n as o}from"./useSharedWebSocket-B3JjQYKi.js";import{B as s,E as c,F as l,M as u,P as d}from"./index-BvxpERop.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)(l,{className:`w-4 h-4 text-green-500 flex-shrink-0`});case`job_failed`:return(0,g.jsx)(d,{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)(c,{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}=i(),{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)(s,{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)(u,{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)(s,{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)(u,{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{i as e,n as t,o as n,r,t as i}from"./createLucideIcon-j4o5em8U.js";import{t as a}from"./react-dom-CzrF8Nvy.js";import{n as o,r as s}from"./useHub-DWD4MWhf.js";import{n as c,t as l}from"./utils-DSsSbmuB.js";import{$ as u,$t as d,A as f,At as p,B as m,Bt as h,C as g,Ct as _,D as v,Dt as y,E as b,Et as x,F as S,Ft as C,G as ee,Gt as te,H as ne,Ht as w,I as T,It as re,J as ie,Jt as ae,K as oe,Kt as se,L as ce,Lt as le,M as ue,Mt as E,N as de,Nt as fe,O as pe,Ot as me,P as he,Pt as ge,Q as _e,Qt as ve,R as ye,Rt as D,S as be,St as xe,T as Se,Tt as Ce,U as we,Ut as O,V as Te,Vt as Ee,W as De,Wt as k,X as Oe,Xt as A,Y as ke,Yt as Ae,Z as je,Zt as Me,_ as Ne,_n as Pe,_t as Fe,a as Ie,an as Le,at as Re,b as ze,bn as Be,bt as Ve,c as He,cn as Ue,ct as We,d as Ge,dn as Ke,dt as qe,en as Je,et as Ye,f as Xe,fn as Ze,ft as Qe,g as j,gn as $e,gt as et,h as M,hn as tt,ht as nt,i as rt,in as it,it as at,j as ot,jt as st,k as ct,kt as lt,l as ut,ln as dt,lt as N,m as P,mn as F,mt as ft,n as I,nn as pt,nt as L,o as mt,on as ht,ot as gt,p as _t,pn as vt,pt as yt,q as bt,qt as xt,r as St,rn as Ct,rt as wt,s as Tt,sn as Et,st as Dt,t as Ot,tn as kt,tt as At,u as jt,un as Mt,ut as Nt,v as R,vn as Pt,vt as Ft,w as It,wt as Lt,x as Rt,xn as zt,xt as Bt,y as Vt,yn as Ht,yt as Ut,z as Wt,zt as Gt}from"./dracula-colors-DWjGyExf.js";import"./useSharedWebSocket-B3JjQYKi.js";import{I as Kt,R as qt,j as Jt}from"./index-Dr38pDlk.js";import{t as Yt}from"./ExportDropdown-DH8dHkah.js";var Xt=i(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Zt=i(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),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,o=e===0,s=r?r(Math.abs(e)):e>0?`+${e}`:`${e}`,c=rn(t);return(0,B.jsxs)(`span`,{className:l(`inline-flex items-center gap-0.5 text-[10px] font-medium px-1.5 py-0.5 rounded`,o?`text-muted-foreground bg-muted/40`:a?`text-green-400 bg-green-400/10`:`text-red-400 bg-red-400/10`),children:[o?(0,B.jsx)(Zt,{className:`w-2.5 h-2.5`}):i?(0,B.jsx)(zt,{className:`w-2.5 h-2.5`}):(0,B.jsx)(Qt,{className:`w-2.5 h-2.5`}),c??s]})}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-j4o5em8U.js";import{t as a}from"./react-dom-CzrF8Nvy.js";import{n as o,r as s}from"./useHub-DWD4MWhf.js";import{n as c,t as l}from"./utils-DSsSbmuB.js";import{$ as u,$t as d,A as f,At as p,B as m,Bt as h,C as g,Ct as _,D as v,Dt as y,E as b,Et as x,F as S,Ft as C,G as ee,Gt as te,H as ne,Ht as w,I as T,It as re,J as ie,Jt as ae,K as oe,Kt as se,L as ce,Lt as le,M as ue,Mt as E,N as de,Nt as fe,O as pe,Ot as me,P as he,Pt as ge,Q as _e,Qt as ve,R as ye,Rt as D,S as be,St as xe,T as Se,Tt as Ce,U as we,Ut as O,V as Te,Vt as Ee,W as De,Wt as k,X as Oe,Xt as A,Y as ke,Yt as Ae,Z as je,Zt as Me,_ as Ne,_n as Pe,_t as Fe,a as Ie,an as Le,at as Re,b as ze,bn as Be,bt as Ve,c as He,cn as Ue,ct as We,d as Ge,dn as Ke,dt as qe,en as Je,et as Ye,f as Xe,fn as Ze,ft as Qe,g as j,gn as $e,gt as et,h as M,hn as tt,ht as nt,i as rt,in as it,it as at,j as ot,jt as st,k as ct,kt as lt,l as ut,ln as dt,lt as N,m as P,mn as F,mt as ft,n as I,nn as pt,nt as L,o as mt,on as ht,ot as gt,p as _t,pn as vt,pt as yt,q as bt,qt as xt,r as St,rn as Ct,rt as wt,s as Tt,sn as Et,st as Dt,t as Ot,tn as kt,tt as At,u as jt,un as Mt,ut as Nt,v as R,vn as Pt,vt as Ft,w as It,wt as Lt,x as Rt,xn as zt,xt as Bt,y as Vt,yn as Ht,yt as Ut,z as Wt,zt as Gt}from"./dracula-colors-1nlBMakf.js";import"./useSharedWebSocket-B3JjQYKi.js";import{I as Kt,R as qt,j as Jt}from"./index-BvxpERop.js";import{t as Yt}from"./ExportDropdown-DH8dHkah.js";var Xt=i(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Zt=i(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),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,o=e===0,s=r?r(Math.abs(e)):e>0?`+${e}`:`${e}`,c=rn(t);return(0,B.jsxs)(`span`,{className:l(`inline-flex items-center gap-0.5 text-[10px] font-medium px-1.5 py-0.5 rounded`,o?`text-muted-foreground bg-muted/40`:a?`text-green-400 bg-green-400/10`:`text-red-400 bg-red-400/10`),children:[o?(0,B.jsx)(Zt,{className:`w-2.5 h-2.5`}):i?(0,B.jsx)(zt,{className:`w-2.5 h-2.5`}):(0,B.jsx)(Qt,{className:`w-2.5 h-2.5`}),c??s]})}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(ve,{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:a,iconType:o,labelStyle:s}=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=c({"recharts-legend-item":!0,[`legend-item-${r}`]:!0,inactive:t.inactive});if(t.type===`none`)return null;var m=typeof s==`object`?cn({},s):{};m.color=t.inactive?a: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}`},Me(e,t,r)),z.createElement(tt,{width:n,height:n,viewBox:l,style:d,"aria-label":`${h} legend icon`},z.createElement(mn,{data:t,iconType:o,inactiveColor:a})),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(Ee)}var vn=n(a()),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=te(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(Ce(e))},[t,e]),null}function jn(e){var t=O();return(0,z.useEffect)(()=>(t(x(e)),()=>{t(x({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=vt(),i=st(),{width:a,height:o,wrapperStyle:s,portal:c}=t,[l,u]=h([n]),d=p(),f=lt();if(d==null||f==null)return null;var m=d-(i?.left||0)-(i?.right||0),g=Mn(t.layout,o,a,m),_=c?s:W(W({position:`absolute`,width:g?.width||a||`auto`,height:g?.height||o||`auto`},kn(s,t,i,d,f,l)),s),v=c??r;return v==null||n==null?null:(0,vn.createPortal)(z.createElement(`div`,{className:`recharts-legend-wrapper`,style:_,ref:u},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:d,chartHeight:f,contextPayload:n}))),v)}var G=z.memo(Pn,Lt);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)=>ht(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,a=Ln(e,Fn);if(!t||!t.length)return null;var o=c(`recharts-polygon`,n);if(r&&r.length){var s=a.stroke&&a.stroke!==`none`,l=Hn(t,r,i);return z.createElement(`g`,{className:o},z.createElement(`path`,K({},$e(a),{fill:l.slice(-1)===`Z`?a.fill:`none`,stroke:`none`,d:l})),s?z.createElement(`path`,K({},$e(a),{fill:`none`,d:q(t,i)})):null,s?z.createElement(`path`,K({},$e(a),{fill:`none`,d:q(r,i)})):null)}var u=q(t,i);return z.createElement(`path`,K({},$e(a),{fill:u.slice(-1)===`Z`?a.fill:`none`,className:o,d:u}))},Wn=e=>e.graphicalItems.polarItems,Gn=w([Wn,L,w([N,We],Ye)],je),Kn=w([w([Gn],Oe),Qe],ie),qn=w([Kn,L,Gn],ee);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,me,Kn,qn,qe,N,w([L,wt,at,Jn,w([Kn,L,Gn,At,N],ke),Jn,me,N],u)],oe);w([Re,w([L,Yn,w([Yn,gt,Re],_e),N],bt)],Dt);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([Qe,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:le(a,t.dataKey),color:o,payload:e,type:t.legendType}})}),or=w([ir,tr,rr,fe],(e,t,n,r)=>{if(!(t==null||e==null))return Ar({offset:r,pieSettings:t,displayedData:e,cells:n})}),sr=n(Et()),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)(()=>ct(e.children,S),[e.children]),n=k(n=>ar(n,e.id,t));return n==null?null:z.createElement(be,{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),p={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:le(s,t),hide:c,type:l,color:o,unit:``,graphicalItemId:u}};return z.createElement(g,{tooltipEntrySettings:p})}),xr=(e,t)=>e>t?`start`:e<t?`end`:`middle`,Sr=(e,t,n)=>d(typeof t==`function`?t(e):t,n,n*.8),Cr=(e,t,n)=>{var{top:r,left:i,width:a,height:o}=t,s=ft(a,o);return{cx:i+d(e.cx,a,a/2),cy:r+d(e.cy,o,o/2),innerRadius:d(e.innerRadius,s,0),outerRadius:Sr(n,e.outerRadius,s),maxRadius:e.maxRadius||Math.sqrt(a*a+o*o)/2}},wr=(e,t)=>Ct(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=c(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className),{key:r}=t,i=fr(t,cr);return z.createElement(Bt,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=c(`recharts-pie-label-text`,f(e));return z.createElement(de,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=Pe(n),c=Pt(i),l=Pt(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=nt(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:[nt(e.cx,e.cy,e.outerRadius,n),r],key:`line`});return z.createElement(Wt,{zIndex:Nt.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(ot,{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(ne),c=k(m),l=k(Te),{onMouseEnter:u,onClick:d,onMouseLeave:f}=i,p=fr(i,lr),h=Se(u,i.dataKey,o),g=b(f),_=It(d,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,m=n&&f?n:s?r:null,y=Y(Y({},e),{},{stroke:e.stroke,tabIndex:-1,[re]:u,[C]:o});return z.createElement(F,J({key:`sector-${e?.startAngle}-${e?.endAngle}-${e.midAngle}-${u}`,tabIndex:-1,className:`recharts-pie-sector`},Me(p,e,u),{onMouseEnter:h(e,u),onMouseLeave:g(e,u),onClick:_(e,u)}),z.createElement(v,J({option:a??m,index:u,shapeType:`sector`,isActive:f},y)))}))}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+(pt(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=(pt(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+Ct(f)*m*(s===0?0:1):o;var C=y+Ct(f)*((s===0?0:d)+g*_),ee=(y+C)/2,te=(h.innerRadius+h.outerRadius)/2,ne=[{name:p,value:s,payload:x,dataKey:c,type:u,color:S,fill:S,graphicalItemId:t.id}],w=nt(h.cx,h.cy,te,ee);return b=Y(Y(Y(Y({},t.presentationProps),{},{percent:g,cornerRadius:typeof a==`string`?parseFloat(a):a,name:p,tooltipPayload:ne,midAngle:ee,middleRadius:te,tooltipPosition:w},x),h),{},{value:s,dataKey:c,startAngle:y,endAngle:C,payload:x,paddingAngle:Ct(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(ue,{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=Fe(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(Ft,{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=Je(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=Je(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:Nt.area};function Pr(e){var{id:t}=e,n=fr(e,ur),{hide:r,className:i,rootTabIndex:a}=e,o=(0,z.useMemo)(()=>ct(e.children,S),[e.children]),s=k(e=>or(e,t,o)),l=(0,z.useRef)(null),u=c(`recharts-pie`,i);return r||s==null?(l.current=null,z.createElement(F,{tabIndex:a,className:u})):z.createElement(Wt,{zIndex:e.zIndex},z.createElement(br,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:s,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:a,className:u},z.createElement(Mr,{props:Y(Y({},n),{},{sectors:s}),previousSectorsRef:l,id:t})))}function Fr(e){var t=A(e,Nr),{id:n}=t,r=fr(t,dr),i=Pe(r);return z.createElement(Rt,{id:n,type:`pie`},e=>z.createElement(z.Fragment,null,z.createElement(ze,{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,m=xe(),h=o===`auto`?!_.isSsr&&!m:o,g=Ut(n+a,t.animationManager),[v,y]=(0,z.useState)(()=>h?r:i),b=(0,z.useRef)(!1),x=(0,z.useCallback)(()=>{y(r),f()},[r,f]);return(0,z.useEffect)(()=>{if(!h||!s)return it;b.current=!0;var e=g.subscribe(y);return g.start([x,u,i,c,d]),()=>{g.stop(),e&&e(),d()}},[h,s,c,l,u,x,d,g,i,r]),h?s&&b.current?p({transition:Ve([a],c,l),[a]:v}):p({[a]:r}):p({[a]:i})}function zr(e){var t=O();return(0,z.useEffect)(()=>{t(_t(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%`},Xe),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(Ge,{preloadedState:{options:l},reduxStoreName:n.id??a},z.createElement(Vt,{chartData:n.data}),z.createElement(jt,{layout:r,margin:n.margin}),z.createElement(He,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),z.createElement(ut,{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(mt,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:ce,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=xt();function n(e){return t.isTypedArray(e)}e.isTypedArray=n})),ci=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=yt();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=Ae(),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=Ue(),n=Ze(),r=Ke(),i=Mt(),a=dt();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=ae();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=Ae();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=se(),n=ui(),r=di(),i=fi(),a=Ke(),o=pi(),s=pe();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=kt(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:kt(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`},Xe),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=he(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||ge;return z.createElement(`g`,null,z.createElement(et,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(De({activeIndex:e.nodeProps.tooltipIndex,activeDataKey:e.dataKey,activeCoordinate:n,activeGraphicalItemId:e.id}))},onMouseLeave:()=>{},onClick:()=>{t(we({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:it,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(g,{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,ee=-S-b,te=0,ne=e=>{(r||f===`nest`)&&typeof _==`function`&&_(n,e)},w=e=>{(r||f===`nest`)&&typeof y==`function`&&y(n,e)},T=()=>{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(${ee}px, ${te}px)`,to:`translate(0, 0)`,attributeName:`transform`,begin:c,easing:u,isActive:s,duration:l,onAnimationStart:ie,onAnimationEnd:re},e=>z.createElement(F,{onMouseEnter:ne,onMouseLeave:w,onClick:T,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(De({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({},Pe(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-${Le()}`,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=Pe(_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(tt,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=p(),r=lt();if(!Gt(n)||!Gt(r))return null;var{id:i}=e;return z.createElement(Rt,{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(Ge,{preloadedState:{options:Ei},reduxStoreName:t.className??`Treemap`},z.createElement(y,{margin:Bi}),z.createElement(He,{throttleDelay:o,throttledEvents:s}),z.createElement(Tt,{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(ye.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 Be(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)(Ie,{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)(Ne,{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)(S,{fill:St[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)(rt,{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)(rt,{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:l(`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)(qt,{className:`w-3 h-3`}):(0,B.jsx)(Xt,{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 Be(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)(rt,{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=Ot[o%Ot.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 Be(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)(Ie,{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)(Ne,{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)(Ne,{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)(Ne,{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)(Jt,{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}=o(),[t,n]=(0,z.useState)(`7d`),[r,i]=(0,z.useState)(``),[a,c]=(0,z.useState)(``),[l,u]=(0,z.useState)(null),[d,f]=(0,z.useState)(!0),[p,m]=(0,z.useState)(null),[h,g]=(0,z.useState)(0),[_,v]=(0,z.useState)(`7d`),[y,b]=(0,z.useState)(null),x=(0,z.useRef)(new Map);(0,z.useEffect)(()=>{if(e){let t=x.current.get(e);t&&(u(t),f(!1))}let n=new AbortController;!l&&!x.current.get(e??``)&&f(!0),m(null);let i=new URLSearchParams({period:t});if(t===`custom`){if(!r||!a){f(!1);return}i.set(`from`,r),i.set(`to`,a)}return fetch(`${s()}/analytics?${i}`,{signal:n.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(t=>{u(t),e&&x.current.set(e,t),f(!1)}).catch(e=>{e.name!==`AbortError`&&(m(e.message),f(!1))}),()=>n.abort()},[t,r,a,h,e]),(0,z.useEffect)(()=>{let e=new AbortController;return fetch(`${s()}/trends?period=${_}`,{signal:e.signal}).then(e=>e.ok?e.json():Promise.reject(Error(`HTTP ${e.status}`))).then(e=>b(e)).catch(e=>{e.name!==`AbortError`&&console.warn(`[analytics] trends fetch failed:`,e.message)}),()=>e.abort()},[_,e]);function S(e,t,r){n(e),i(t??``),c(r??``)}function C(){g(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`}),l&&(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l.period.label})]}),(0,B.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,B.jsx)(Ht,{period:t,from:r,to:a,onChange:S}),(0,B.jsx)(Yt,{baseUrl:`${s()}/analytics/export`,params:{period:t,...r?{from:r}:{},...a?{to:a}:{}}})]})]}),d&&(0,B.jsx)(va,{}),!d&&p&&(0,B.jsx)(ya,{message:`Failed to load analytics: ${p}`,onRetry:C}),!d&&!p&&l&&(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsx)(an,{kpi:l.kpi}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,B.jsx)(qi,{data:l.costTimeline}),(0,B.jsx)(Yi,{data:l.statusBreakdown}),(0,B.jsx)($i,{data:l.durationHistogram,percentiles:l.durationPercentiles}),(0,B.jsx)(ta,{data:l.tokenEfficiency})]}),(0,B.jsx)(aa,{data:l.commandPerformance}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,B.jsx)(ca,{data:l.dailyThroughput}),(0,B.jsx)(da,{data:l.costPerCommand})]}),(0,B.jsx)(pa,{data:l.bonusMetrics}),y&&(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:()=>v(e.value),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${_===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:y.points})]})]})]})}export{xa as default};
@@ -1,4 +1,4 @@
1
- import{n as e,o as t,r as n}from"./createLucideIcon-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{t as r}from"./utils-DSsSbmuB.js";import{L as i,M as a,N as o,b as s,f as c,p as l,x as u,z as d}from"./index-Dr38pDlk.js";import{t as f}from"./lib-DUX8yn0z.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)(d,{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)(o,{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)(o,{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)(i,{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,i]=(0,p.useState)(null),[o,c]=(0,p.useState)(!0),[l,d]=(0,p.useState)(null);return(0,p.useEffect)(()=>{c(!0),d(null),i(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&&i(e)}).catch(e=>{d(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>c(!1))},[e,t,n]),o?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(a,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):l?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(`p`,{className:`text-sm text-destructive`,children:l})}):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-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{t as r}from"./utils-DSsSbmuB.js";import{L as i,M as a,N as o,b as s,f as c,p as l,x as u,z as d}from"./index-BvxpERop.js";import{t as f}from"./lib-BFJHU2-H.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)(d,{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)(o,{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)(o,{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)(i,{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,i]=(0,p.useState)(null),[o,c]=(0,p.useState)(!0),[l,d]=(0,p.useState)(null);return(0,p.useEffect)(()=>{c(!0),d(null),i(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&&i(e)}).catch(e=>{d(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>c(!1))},[e,t,n]),o?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(a,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):l?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(`p`,{className:`text-sm text-destructive`,children:l})}):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-j4o5em8U.js";import{t as r}from"./utils-DSsSbmuB.js";import{G as i,K as a,L as o,M as s,N as c,W as l,b as u,x as d,z as f}from"./index-Dr38pDlk.js";import{t as p}from"./lib-DUX8yn0z.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)(l,{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)(f,{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)(l,{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)(c,{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)(l,{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)(c,{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)(o,{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),[a,o]=(0,m.useState)(!0),[c,l]=(0,m.useState)(null),f=i();return(0,m.useEffect)(()=>{o(!0),l(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=>{l(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>o(!1))},[e,t,f]),a?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):c?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(`p`,{className:`text-sm text-destructive`,children:c})}):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-j4o5em8U.js";import{t as r}from"./utils-DSsSbmuB.js";import{G as i,K as a,L as o,M as s,N as c,W as l,b as u,x as d,z as f}from"./index-BvxpERop.js";import{t as p}from"./lib-BFJHU2-H.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)(l,{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)(f,{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)(l,{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)(c,{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)(l,{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)(c,{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)(o,{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),[a,o]=(0,m.useState)(!0),[c,l]=(0,m.useState)(null),f=i();return(0,m.useEffect)(()=>{o(!0),l(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=>{l(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>o(!1))},[e,t,f]),a?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):c?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(`p`,{className:`text-sm text-destructive`,children:c})}):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-j4o5em8U.js";import"./react-dom-CzrF8Nvy.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-DWjGyExf.js";import{n as _}from"./useSharedWebSocket-B3JjQYKi.js";import{j as v}from"./index-Dr38pDlk.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-j4o5em8U.js";import"./react-dom-CzrF8Nvy.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-1nlBMakf.js";import{n as _}from"./useSharedWebSocket-B3JjQYKi.js";import{j as v}from"./index-BvxpERop.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-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{n as i,o as a,r as o}from"./useHub-DWD4MWhf.js";import{t as s}from"./utils-DSsSbmuB.js";import{t as c}from"./download-D8ISop3h.js";import{n as l}from"./useSharedWebSocket-B3JjQYKi.js";import{A as u,F as d,G as f,H as p,K as m,L as h,M as g,P as _,R as v,T as y,U as b,V as x,W as S,b as C,k as w,n as T,r as E,v as D,x as O}from"./index-Dr38pDlk.js";import{t as k}from"./lib-DUX8yn0z.js";var A=r(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),j=r(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),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 i=e[n.key]??`idle`,a=r<t.length-1?e[t[r+1].key]??`idle`:null;return(0,P.jsxs)(`div`,{className:`flex items-center`,children:[(0,P.jsxs)(x,{children:[(0,P.jsx)(b,{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:i}),(0,P.jsx)(`span`,{className:s(`text-xs font-medium transition-colors`,i===`running`?`text-blue-400`:i===`done`?`text-emerald-400`:i===`error`?`text-red-400`:`text-muted-foreground/40`),children:n.label})]})}),(0,P.jsxs)(p,{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})]})]}),a!==null&&(0,P.jsx)(`div`,{className:s(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,a===`done`||i===`done`?`bg-emerald-500/30`:a===`running`?`bg-blue-400/40`:`bg-border/30`)})]},n.key)})})}function I({state:e}){return(0,P.jsxs)(`div`,{className:s(`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)(g,{className:`w-6 h-6 text-blue-400 animate-spin`}),e===`done`&&(0,P.jsx)(d,{className:`w-6 h-6 text-emerald-400`}),e===`error`&&(0,P.jsx)(_,{className:`w-6 h-6 text-red-400`}),e===`idle`&&(0,P.jsx)(A,{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[i,a]=(0,N.useState)(n),o=(0,N.useMemo)(()=>R(t),[t]),c=e.status===`completed`;return(0,P.jsxs)(`div`,{className:s(`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:()=>a(!i),className:`w-full flex items-center gap-3 px-4 py-3`,children:[c?(0,P.jsx)(d,{className:`w-4 h-4 text-emerald-400 shrink-0`}):(0,P.jsx)(_,{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)]}),o.length>0&&(0,P.jsxs)(`span`,{children:[o.length,` file`,o.length===1?``:`s`]})]}),(0,P.jsx)(v,{className:s(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,i&&`rotate-180`)})]}),i&&(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`})]})]}),o.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:o.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:s(`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),u=(0,N.useRef)(null),{processedLines:d,groups:f,totalLines:p}=(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-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{n as i,o as a,r as o}from"./useHub-DWD4MWhf.js";import{t as s}from"./utils-DSsSbmuB.js";import{t as c}from"./download-D8ISop3h.js";import{n as l}from"./useSharedWebSocket-B3JjQYKi.js";import{A as u,F as d,G as f,H as p,K as m,L as h,M as g,P as _,R as v,T as y,U as b,V as x,W as S,b as C,k as w,n as T,r as E,v as D,x as O}from"./index-BvxpERop.js";import{t as k}from"./lib-BFJHU2-H.js";var A=r(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),j=r(`copy`,[[`rect`,{width:`14`,height:`14`,x:`8`,y:`8`,rx:`2`,ry:`2`,key:`17jyea`}],[`path`,{d:`M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2`,key:`zix9uf`}]]),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 i=e[n.key]??`idle`,a=r<t.length-1?e[t[r+1].key]??`idle`:null;return(0,P.jsxs)(`div`,{className:`flex items-center`,children:[(0,P.jsxs)(x,{children:[(0,P.jsx)(b,{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:i}),(0,P.jsx)(`span`,{className:s(`text-xs font-medium transition-colors`,i===`running`?`text-blue-400`:i===`done`?`text-emerald-400`:i===`error`?`text-red-400`:`text-muted-foreground/40`),children:n.label})]})}),(0,P.jsxs)(p,{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})]})]}),a!==null&&(0,P.jsx)(`div`,{className:s(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,a===`done`||i===`done`?`bg-emerald-500/30`:a===`running`?`bg-blue-400/40`:`bg-border/30`)})]},n.key)})})}function I({state:e}){return(0,P.jsxs)(`div`,{className:s(`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)(g,{className:`w-6 h-6 text-blue-400 animate-spin`}),e===`done`&&(0,P.jsx)(d,{className:`w-6 h-6 text-emerald-400`}),e===`error`&&(0,P.jsx)(_,{className:`w-6 h-6 text-red-400`}),e===`idle`&&(0,P.jsx)(A,{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[i,a]=(0,N.useState)(n),o=(0,N.useMemo)(()=>R(t),[t]),c=e.status===`completed`;return(0,P.jsxs)(`div`,{className:s(`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:()=>a(!i),className:`w-full flex items-center gap-3 px-4 py-3`,children:[c?(0,P.jsx)(d,{className:`w-4 h-4 text-emerald-400 shrink-0`}):(0,P.jsx)(_,{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)]}),o.length>0&&(0,P.jsxs)(`span`,{children:[o.length,` file`,o.length===1?``:`s`]})]}),(0,P.jsx)(v,{className:s(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,i&&`rotate-180`)})]}),i&&(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`})]})]}),o.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:o.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:s(`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),u=(0,N.useRef)(null),{processedLines:d,groups:f,totalLines:p}=(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]),m=(0,N.useMemo)(()=>{if(!n)return p;let e=n.toLowerCase();return d.filter(t=>t.content.toLowerCase().includes(e)).length},[n,d,p]),h=(0,N.useCallback)(()=>{let e=u.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,N.useEffect)(()=>{i&&h()},[e.length,i,h]);function g(){let e=u.current;e&&o(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function _(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...`})}):p===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)(w,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,P.jsx)(T,{placeholder:`Filter logs...`,value:n,onChange:e=>r(e.target.value),className:`pl-7 h-7`})]}),(0,P.jsx)(y,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=d.map(e=>e.content).join(`
3
3
  `);navigator.clipboard.writeText(e).then(()=>{a.success(`Log copied to clipboard`)}).catch(()=>{a.error(`Failed to copy log`)})},children:(0,P.jsx)(j,{className:`w-3.5 h-3.5`})}),(0,P.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[m,` / `,p,` lines`]})]}),(0,P.jsxs)(`div`,{ref:u,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:g,children:[f.map(e=>(0,P.jsx)(K,{group:e,filter:n,collapsed:s.has(e.key),onToggle:()=>_(e.key)},e.key)),(0,P.jsx)(`div`,{ref:l})]}),!i&&(0,P.jsxs)(y,{size:`sm`,variant:`secondary`,onClick:()=>{o(!0),h()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,P.jsx)(v,{className:`w-3 h-3`}),`Jump to bottom`]})]})}var K=(0,N.memo)(function({group:e,filter:t,collapsed:n,onToggle:r}){let i=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return i.length===0?null:(0,P.jsx)(`div`,{children:i.map((e,t)=>(0,P.jsx)(J,{line:e,even:t%2==0},e.id))});let a=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:s(`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)(h,{className:s(`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:a}),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:i.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`}):i.map((e,t)=>(0,P.jsx)(J,{line:e,even:t%2==0},e.id))})]})}),q=[k],J=(0,N.memo)(function({line:e,even:t}){let n=e.type===`assistant`,r=e.type===`diff-add`,i=e.type===`diff-remove`,a=e.type===`diff-meta`,o=e.type===`diff-hunk`;return(0,P.jsxs)(`div`,{className:s(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!(r||i||a||o)&&(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`,i&&`bg-red-500/8 border-l-2 border-red-500/50`,a&&`bg-dracula-purple/5 border-l-2 border-dracula-purple/30`,o&&`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
@@ -1 +1 @@
1
- import{n as e,o as t,r as n,t as r}from"./createLucideIcon-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{n as i,o as a,r as o}from"./useHub-DWD4MWhf.js";import"./useSharedWebSocket-B3JjQYKi.js";import{D as s,F as c,G as l,H as u,O as d,P as f,T as p,U as m,V as h,_ as g,b as _,f as v,g as y,h as b,m as x,p as S,r as C,v as w,x as T,y as E}from"./index-Dr38pDlk.js";import{t as D}from"./ExportDropdown-DH8dHkah.js";var ee=r(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),te=r(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),ne=r(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),O=t(n(),1),k=new Map;function A(e,t){return`${e}:${t}`}function j({namespace:e,projectId:t,initialValue:n,fetcher:r,pollInterval:i=0}){let a=t?A(t,e):null,[o,s]=(0,O.useState)(()=>a&&k.has(a)?k.get(a):n),[c,l]=(0,O.useState)(()=>a?!k.has(a):!0),[u,d]=(0,O.useState)(c),f=(0,O.useRef)(r);return f.current=r,(0,O.useEffect)(()=>{if(!a)return;let e=k.get(a);e===void 0?(s(n),l(!0),d(!0)):(s(e),l(!1),d(!1));let t=!1;async function r(){try{let e=await f.current();if(t)return;k.set(a,e),s(e)}catch{}finally{t||(d(!1),l(!1))}}r();let o;return i>0&&(o=setInterval(r,i)),()=>{t=!0,o&&clearInterval(o)}},[a,i]),{data:o,isLoading:u,isFirstLoad:c,refresh:(0,O.useCallback)(()=>{a&&f.current().then(e=>{k.set(a,e),s(e)}).catch(()=>{})},[a])}}var M=e();function N(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function P(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function F(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function I({label:e,a:t,b:n,highlight:r}){return(0,M.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,M.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 font-semibold`:``}`,children:t}),(0,M.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 font-semibold`:``}`,children:n})]})}function L(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function R({jobIds:e,onClose:t}){let[n,r]=(0,O.useState)(null),[i,a]=(0,O.useState)(!0),[l,u]=(0,O.useState)(null);(0,O.useEffect)(()=>{let t=new AbortController;return fetch(`${o()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{r(e),a(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),a(!1))}),()=>t.abort()},[e]);function d(e,t){return(0,M.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,M.jsxs)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:[`Job `,t+1]}),(0,M.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,M.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,M.jsx)(c,{className:`w-3 h-3 text-emerald-400`}):(0,M.jsx)(f,{className:`w-3 h-3 text-rose-400`}),(0,M.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:e.status})]}),(0,M.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:(0,M.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Job Comparison`}),(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,M.jsx)(s,{className:`w-4 h-4`})})]}),i&&(0,M.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,M.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,M.jsxs)(`p`,{className:`text-xs text-red-400`,children:[`Failed to load comparison: `,l]}),n&&(()=>{let[e,t]=n.jobs,r=L(e.durationMs,t.durationMs,!0),i=L(e.totalCostUsd,t.totalCostUsd,!0),a=L(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,M.jsx)(`div`,{}),d(e,0),d(t,1)]}),(0,M.jsx)(I,{label:`Duration`,a:N(e.durationMs),b:N(t.durationMs),highlight:r}),(0,M.jsx)(I,{label:`Cost`,a:P(e.totalCostUsd),b:P(t.totalCostUsd),highlight:i}),(0,M.jsx)(I,{label:`Tokens out`,a:F(e.tokensOut),b:F(t.tokensOut),highlight:a}),(0,M.jsx)(I,{label:`Tokens in`,a:F(e.tokensIn),b:F(t.tokensIn),highlight:null}),(0,M.jsx)(I,{label:`Cache read`,a:F(e.tokensCacheRead),b:F(t.tokensCacheRead),highlight:null}),(0,M.jsx)(I,{label:`Model`,a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,M.jsx)(I,{label:`Phases done`,a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),n&&(0,M.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:`Green highlights indicate better value`})]})})}var z={running:{variant:`running`,label:`running`,tooltip:`Job is actively executing`},completed:{variant:`success`,label:`done`,tooltip:`Job completed successfully`},failed:{variant:`failed`,label:`failed`,tooltip:`Job exited with a non-zero exit code`},canceled:{variant:`canceled`,label:`canceled`,tooltip:`Job was manually canceled`},queued:{variant:`queued`,label:`queued`,tooltip:`Job is waiting to run`},zombie_terminated:{variant:`failed`,label:`zombie`,tooltip:`Job was auto-terminated after prolonged inactivity`},skipped:{variant:`warning`,label:`skipped`,tooltip:`Job was skipped because a parent job in the pipeline failed`}},re=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],B={critical:{className:`bg-red-500/15 text-red-400 border-red-500/30`,label:`critical`},high:{className:`bg-orange-500/15 text-orange-400 border-orange-500/30`,label:`high`},normal:{className:``,label:`normal`},low:{className:`bg-gray-500/15 text-gray-400 border-gray-500/30`,label:`low`}};function ie(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function ae(e,t){if(!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;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 oe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function se(e){try{return C(new Date(e),{addSuffix:!0})}catch{return e}}var V=10;function H({jobs:e,isLoading:t,onJobsCleared:n,onProposalClick:r,onProposalDelete:i}){let s=l(),[c,f]=(0,O.useState)(null),[_,C]=(0,O.useState)(``),[T,E]=(0,O.useState)(``),[D,k]=(0,O.useState)(!1),[A,j]=(0,O.useState)(``),[N,P]=(0,O.useState)(``),[F,I]=(0,O.useState)(!1),[L,H]=(0,O.useState)(null),[U,W]=(0,O.useState)(V),[G,K]=(0,O.useState)(!1),[q,J]=(0,O.useState)([]),[Y,X]=(0,O.useState)(null);(0,O.useEffect)(()=>{W(V)},[e.length]);function ce(){K(e=>!e),J([])}function le(e){J(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&X(n),n})}let Z=e.filter(e=>!(c&&e.status!==c||_&&e.started_at<_||T&&e.started_at>`${T}T23:59:59`)),Q=e.filter(e=>!(A&&e.started_at<A||N&&e.started_at>`${N}T23:59:59`)).length;async function $(e){I(!0);try{let t={};e===`range`&&(A&&(t.from=A),N&&(t.to=N));let r=await fetch(`${o()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.ok){let e=await r.json();a.success(`Cleared ${e.deleted} job(s)`),k(!1),j(``),P(``),n?.()}else a.error(`Failed to clear jobs`)}catch{a.error(`Network error`)}finally{I(!1)}}return t?(0,M.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,M.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,M.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,M.jsx)(ee,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,M.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`No jobs yet`}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`Run a command above to see your job history here`})]}):(0,M.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>f(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${c===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:[`All (`,e.length,`)`]}),re.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,M.jsxs)(`button`,{type:`button`,onClick:()=>f(c===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${c===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:[t,` (`,n,`)`]},t)})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`input`,{type:`date`,value:_,onChange:e=>C(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:`From date`}),(0,M.jsx)(`input`,{type:`date`,value:T,onChange:e=>E(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:`To date`}),(_||T)&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>{C(``),E(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:`Clear`}),(0,M.jsxs)(h,{children:[(0,M.jsx)(m,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${G?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:ce,children:(0,M.jsx)(te,{className:`w-3.5 h-3.5`})})}),(0,M.jsx)(u,{children:G?`Exit compare mode`:`Compare 2 jobs`})]}),(0,M.jsxs)(h,{children:[(0,M.jsx)(m,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>k(!0),children:(0,M.jsx)(d,{className:`w-3.5 h-3.5`})})}),(0,M.jsx)(u,{children:`Clear jobs`})]})]})]}),G&&(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,M.jsxs)(`span`,{children:[q.length===0&&`Select 2 jobs to compare`,q.length===1&&`Select 1 more job`,q.length===2&&`Ready — click compare`]}),q.length===2&&(0,M.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>X(q),children:`Compare →`})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,M.jsx)(`span`,{className:`w-14`,children:`Status`}),(0,M.jsx)(`span`,{className:`flex-1 min-w-0`,children:`Command`}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,M.jsx)(`span`,{className:`w-14 text-right`,children:`Duration`}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:`Tokens`}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:`Cost`}),(0,M.jsx)(`span`,{className:`w-20 text-right`,children:`Started`})]})]}),(0,M.jsx)(`div`,{className:`space-y-0.5`,children:Z.slice(0,U).map(e=>{let t=z[e.status]??z.queued,n=ie(e.total_cost_usd),i=ae(e.started_at,e.finished_at),a=oe((e.tokens_in??0)+(e.tokens_out??0)||null),o=e.id.startsWith(`proposal:`),c=o?e.id.replace(`proposal:`,``):null,l=q.includes(e.id),f=G&&!o&&q.length===2&&!l;return(0,M.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${l?`bg-accent/70 ring-1 ring-border`:f?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(G&&!o){le(e.id);return}o&&c?r?.(c):s(`/jobs/${e.id}`)},children:[(0,M.jsxs)(h,{children:[(0,M.jsx)(m,{asChild:!0,children:(0,M.jsx)(`div`,{children:(0,M.jsx)(w,{variant:t.variant,children:t.label})})}),(0,M.jsx)(u,{children:t.tooltip})]}),e.priority&&e.priority!==`normal`&&(0,M.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${B[e.priority].className}`,children:B[e.priority].label}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,M.jsxs)(h,{children:[(0,M.jsx)(m,{asChild:!0,children:(0,M.jsx)(ne,{className:`w-3 h-3 text-dracula-purple/60 shrink-0`})}),(0,M.jsxs)(u,{children:[`Part of a pipeline`,e.depends_on_job_id&&` (depends on previous step)`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,M.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:e.command})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,M.jsx)(`span`,{className:`w-14 text-right`,children:i??`—`}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:a?`${a}`:`—`}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,M.jsx)(`span`,{className:`w-20 text-right`,children:se(e.started_at)}),o&&c&&(0,M.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),H(c)},title:`Delete proposal`,children:(0,M.jsx)(d,{className:`w-3 h-3`})})]})]},e.id)})}),Z.length>U&&(0,M.jsx)(`div`,{className:`pt-1 text-center`,children:(0,M.jsxs)(`button`,{type:`button`,onClick:()=>W(e=>e+V),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:[`Load more (`,Z.length-U,` remaining)`]})}),D&&(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:()=>k(!1),children:(0,M.jsxs)(`div`,{className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Clear Jobs`}),(0,M.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[e.length,` job`,e.length===1?``:`s`,` in history`]})]}),(0,M.jsxs)(p,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:F,onClick:()=>$(`all`),children:[`Clear all `,e.length,` job`,e.length===1?``:`s`]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Or clear by date range:`}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`input`,{type:`date`,value:A,onChange:e=>j(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:`From`}),(0,M.jsx)(`input`,{type:`date`,value:N,onChange:e=>P(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:`To`})]}),(0,M.jsx)(p,{variant:`outline`,size:`sm`,className:`w-full`,disabled:F||!A&&!N,onClick:()=>$(`range`),children:A||N?`Clear ${Q} job${Q===1?``:`s`} in range`:`Clear range`})]}),(0,M.jsx)(p,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>k(!1),children:`Cancel`})]})}),(0,M.jsx)(v,{open:L!==null,onOpenChange:e=>!e&&H(null),children:(0,M.jsxs)(S,{className:`max-w-sm`,children:[(0,M.jsxs)(y,{children:[(0,M.jsx)(g,{children:`Delete proposal?`}),(0,M.jsx)(x,{children:`This will permanently delete 1 proposal. This action cannot be undone.`})]}),(0,M.jsxs)(b,{children:[(0,M.jsx)(p,{variant:`ghost`,size:`sm`,onClick:()=>H(null),children:`Cancel`}),(0,M.jsx)(p,{variant:`destructive`,size:`sm`,onClick:()=>{L&&i?.(L),H(null)},children:`Delete`})]})]})}),Y&&(0,M.jsx)(R,{jobIds:Y,onClose:()=>{X(null),J([]),K(!1)}})]})}function U(){let{activeProjectId:e}=i(),{recentJobs:t}=E(e),{data:n,isFirstLoad:r,refresh:s}=j({namespace:`jobs`,projectId:e,initialValue:t,fetcher:async()=>{let e=await fetch(`${o()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:c}=j({namespace:`proposals`,projectId:e,initialValue:[],fetcher:async()=>{let e=await fetch(`${o()}/propose?limit=10`);return e.ok?(await e.json()).proposals:[]},pollInterval:1e4}),l={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},u=c.map(e=>({id:`proposal:${e.id}`,command:`/sr:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,status:l[e.status]??`queued`})),d=[...n,...u].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[f,m]=(0,O.useState)(null),h=(0,O.useCallback)(async e=>{try{let t=await fetch(`${o()}/propose/${e}`);if(!t.ok)return;m((await t.json()).proposal)}catch{}},[]),x=(0,O.useCallback)(async e=>{try{(await fetch(`${o()}/propose/${e}`,{method:`DELETE`})).ok&&(a.success(`Proposal deleted`),s())}catch{}},[s]);return(0,M.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,M.jsx)(`h1`,{className:`text-sm font-semibold`,children:`Jobs`}),(0,M.jsx)(D,{baseUrl:`${o()}/jobs/export`,label:`Export Jobs`})]}),(0,M.jsx)(H,{jobs:d,isLoading:r,onJobsCleared:s,onProposalClick:h,onProposalDelete:x}),(0,M.jsx)(v,{open:f!==null,onOpenChange:e=>!e&&m(null),children:(0,M.jsx)(S,{className:`max-w-3xl glass-card`,children:f&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y,{children:(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(g,{className:`flex-1 min-w-0`,children:`Proposal`}),(0,M.jsx)(w,{variant:f.status===`created`?`success`:f.status===`cancelled`?`destructive`:`secondary`,children:f.status})]})}),(0,M.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:f.idea}),f.result_markdown?(0,M.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,M.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,M.jsx)(T,{remarkPlugins:[_],children:f.result_markdown})})}):(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:`No proposal content yet.`}),f.issue_url&&(0,M.jsxs)(`div`,{className:`text-xs`,children:[`GitHub Issue:`,` `,(0,M.jsx)(`a`,{href:f.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-dracula-purple hover:underline`,children:f.issue_url})]}),(0,M.jsxs)(b,{children:[(0,M.jsx)(p,{variant:`destructive`,size:`sm`,onClick:()=>{x(f.id),m(null)},children:`Delete`}),(0,M.jsx)(p,{variant:`ghost`,size:`sm`,onClick:()=>m(null),children:`Close`})]})]})})})]})}export{U as default};
1
+ import{n as e,o as t,r as n,t as r}from"./createLucideIcon-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{n as i,o as a,r as o}from"./useHub-DWD4MWhf.js";import"./useSharedWebSocket-B3JjQYKi.js";import{D as s,F as c,G as l,H as u,O as d,P as f,T as p,U as m,V as h,_ as g,b as _,f as v,g as y,h as b,m as x,p as S,r as C,v as w,x as T,y as E}from"./index-BvxpERop.js";import{t as D}from"./ExportDropdown-DH8dHkah.js";var ee=r(`clipboard-list`,[[`rect`,{width:`8`,height:`4`,x:`8`,y:`2`,rx:`1`,ry:`1`,key:`tgr4d6`}],[`path`,{d:`M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2`,key:`116196`}],[`path`,{d:`M12 11h4`,key:`1jrz19`}],[`path`,{d:`M12 16h4`,key:`n85exb`}],[`path`,{d:`M8 11h.01`,key:`1dfujw`}],[`path`,{d:`M8 16h.01`,key:`18s6g9`}]]),te=r(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),ne=r(`link-2`,[[`path`,{d:`M9 17H7A5 5 0 0 1 7 7h2`,key:`8i5ue5`}],[`path`,{d:`M15 7h2a5 5 0 1 1 0 10h-2`,key:`1b9ql8`}],[`line`,{x1:`8`,x2:`16`,y1:`12`,y2:`12`,key:`1jonct`}]]),O=t(n(),1),k=new Map;function A(e,t){return`${e}:${t}`}function j({namespace:e,projectId:t,initialValue:n,fetcher:r,pollInterval:i=0}){let a=t?A(t,e):null,[o,s]=(0,O.useState)(()=>a&&k.has(a)?k.get(a):n),[c,l]=(0,O.useState)(()=>a?!k.has(a):!0),[u,d]=(0,O.useState)(c),f=(0,O.useRef)(r);return f.current=r,(0,O.useEffect)(()=>{if(!a)return;let e=k.get(a);e===void 0?(s(n),l(!0),d(!0)):(s(e),l(!1),d(!1));let t=!1;async function r(){try{let e=await f.current();if(t)return;k.set(a,e),s(e)}catch{}finally{t||(d(!1),l(!1))}}r();let o;return i>0&&(o=setInterval(r,i)),()=>{t=!0,o&&clearInterval(o)}},[a,i]),{data:o,isLoading:u,isFirstLoad:c,refresh:(0,O.useCallback)(()=>{a&&f.current().then(e=>{k.set(a,e),s(e)}).catch(()=>{})},[a])}}var M=e();function N(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function P(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function F(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function I({label:e,a:t,b:n,highlight:r}){return(0,M.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,M.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,M.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 font-semibold`:``}`,children:t}),(0,M.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 font-semibold`:``}`,children:n})]})}function L(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function R({jobIds:e,onClose:t}){let[n,r]=(0,O.useState)(null),[i,a]=(0,O.useState)(!0),[l,u]=(0,O.useState)(null);(0,O.useEffect)(()=>{let t=new AbortController;return fetch(`${o()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{r(e),a(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),a(!1))}),()=>t.abort()},[e]);function d(e,t){return(0,M.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,M.jsxs)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:[`Job `,t+1]}),(0,M.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,M.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,M.jsx)(c,{className:`w-3 h-3 text-emerald-400`}):(0,M.jsx)(f,{className:`w-3 h-3 text-rose-400`}),(0,M.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:e.status})]}),(0,M.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:t,children:(0,M.jsxs)(`div`,{className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,M.jsx)(`h2`,{className:`text-sm font-semibold`,children:`Job Comparison`}),(0,M.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,M.jsx)(s,{className:`w-4 h-4`})})]}),i&&(0,M.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,M.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),l&&(0,M.jsxs)(`p`,{className:`text-xs text-red-400`,children:[`Failed to load comparison: `,l]}),n&&(()=>{let[e,t]=n.jobs,r=L(e.durationMs,t.durationMs,!0),i=L(e.totalCostUsd,t.totalCostUsd,!0),a=L(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,M.jsxs)(`div`,{children:[(0,M.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,M.jsx)(`div`,{}),d(e,0),d(t,1)]}),(0,M.jsx)(I,{label:`Duration`,a:N(e.durationMs),b:N(t.durationMs),highlight:r}),(0,M.jsx)(I,{label:`Cost`,a:P(e.totalCostUsd),b:P(t.totalCostUsd),highlight:i}),(0,M.jsx)(I,{label:`Tokens out`,a:F(e.tokensOut),b:F(t.tokensOut),highlight:a}),(0,M.jsx)(I,{label:`Tokens in`,a:F(e.tokensIn),b:F(t.tokensIn),highlight:null}),(0,M.jsx)(I,{label:`Cache read`,a:F(e.tokensCacheRead),b:F(t.tokensCacheRead),highlight:null}),(0,M.jsx)(I,{label:`Model`,a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,M.jsx)(I,{label:`Phases done`,a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),n&&(0,M.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:`Green highlights indicate better value`})]})})}var z={running:{variant:`running`,label:`running`,tooltip:`Job is actively executing`},completed:{variant:`success`,label:`done`,tooltip:`Job completed successfully`},failed:{variant:`failed`,label:`failed`,tooltip:`Job exited with a non-zero exit code`},canceled:{variant:`canceled`,label:`canceled`,tooltip:`Job was manually canceled`},queued:{variant:`queued`,label:`queued`,tooltip:`Job is waiting to run`},zombie_terminated:{variant:`failed`,label:`zombie`,tooltip:`Job was auto-terminated after prolonged inactivity`},skipped:{variant:`warning`,label:`skipped`,tooltip:`Job was skipped because a parent job in the pipeline failed`}},re=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],B={critical:{className:`bg-red-500/15 text-red-400 border-red-500/30`,label:`critical`},high:{className:`bg-orange-500/15 text-orange-400 border-orange-500/30`,label:`high`},normal:{className:``,label:`normal`},low:{className:`bg-gray-500/15 text-gray-400 border-gray-500/30`,label:`low`}};function ie(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function ae(e,t){if(!t)return null;let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return null;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 oe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function se(e){try{return C(new Date(e),{addSuffix:!0})}catch{return e}}var V=10;function H({jobs:e,isLoading:t,onJobsCleared:n,onProposalClick:r,onProposalDelete:i}){let s=l(),[c,f]=(0,O.useState)(null),[_,C]=(0,O.useState)(``),[T,E]=(0,O.useState)(``),[D,k]=(0,O.useState)(!1),[A,j]=(0,O.useState)(``),[N,P]=(0,O.useState)(``),[F,I]=(0,O.useState)(!1),[L,H]=(0,O.useState)(null),[U,W]=(0,O.useState)(V),[G,K]=(0,O.useState)(!1),[q,J]=(0,O.useState)([]),[Y,X]=(0,O.useState)(null);(0,O.useEffect)(()=>{W(V)},[e.length]);function ce(){K(e=>!e),J([])}function le(e){J(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&X(n),n})}let Z=e.filter(e=>!(c&&e.status!==c||_&&e.started_at<_||T&&e.started_at>`${T}T23:59:59`)),Q=e.filter(e=>!(A&&e.started_at<A||N&&e.started_at>`${N}T23:59:59`)).length;async function $(e){I(!0);try{let t={};e===`range`&&(A&&(t.from=A),N&&(t.to=N));let r=await fetch(`${o()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(r.ok){let e=await r.json();a.success(`Cleared ${e.deleted} job(s)`),k(!1),j(``),P(``),n?.()}else a.error(`Failed to clear jobs`)}catch{a.error(`Network error`)}finally{I(!1)}}return t?(0,M.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,M.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,M.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,M.jsx)(ee,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,M.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:`No jobs yet`}),(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:`Run a command above to see your job history here`})]}):(0,M.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,M.jsxs)(`button`,{type:`button`,onClick:()=>f(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${c===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:[`All (`,e.length,`)`]}),re.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,M.jsxs)(`button`,{type:`button`,onClick:()=>f(c===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${c===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:[t,` (`,n,`)`]},t)})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`input`,{type:`date`,value:_,onChange:e=>C(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:`From date`}),(0,M.jsx)(`input`,{type:`date`,value:T,onChange:e=>E(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:`To date`}),(_||T)&&(0,M.jsx)(`button`,{type:`button`,onClick:()=>{C(``),E(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:`Clear`}),(0,M.jsxs)(h,{children:[(0,M.jsx)(m,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${G?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:ce,children:(0,M.jsx)(te,{className:`w-3.5 h-3.5`})})}),(0,M.jsx)(u,{children:G?`Exit compare mode`:`Compare 2 jobs`})]}),(0,M.jsxs)(h,{children:[(0,M.jsx)(m,{asChild:!0,children:(0,M.jsx)(p,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>k(!0),children:(0,M.jsx)(d,{className:`w-3.5 h-3.5`})})}),(0,M.jsx)(u,{children:`Clear jobs`})]})]})]}),G&&(0,M.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,M.jsxs)(`span`,{children:[q.length===0&&`Select 2 jobs to compare`,q.length===1&&`Select 1 more job`,q.length===2&&`Ready — click compare`]}),q.length===2&&(0,M.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>X(q),children:`Compare →`})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,M.jsx)(`span`,{className:`w-14`,children:`Status`}),(0,M.jsx)(`span`,{className:`flex-1 min-w-0`,children:`Command`}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,M.jsx)(`span`,{className:`w-14 text-right`,children:`Duration`}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:`Tokens`}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:`Cost`}),(0,M.jsx)(`span`,{className:`w-20 text-right`,children:`Started`})]})]}),(0,M.jsx)(`div`,{className:`space-y-0.5`,children:Z.slice(0,U).map(e=>{let t=z[e.status]??z.queued,n=ie(e.total_cost_usd),i=ae(e.started_at,e.finished_at),a=oe((e.tokens_in??0)+(e.tokens_out??0)||null),o=e.id.startsWith(`proposal:`),c=o?e.id.replace(`proposal:`,``):null,l=q.includes(e.id),f=G&&!o&&q.length===2&&!l;return(0,M.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${l?`bg-accent/70 ring-1 ring-border`:f?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:()=>{if(G&&!o){le(e.id);return}o&&c?r?.(c):s(`/jobs/${e.id}`)},children:[(0,M.jsxs)(h,{children:[(0,M.jsx)(m,{asChild:!0,children:(0,M.jsx)(`div`,{children:(0,M.jsx)(w,{variant:t.variant,children:t.label})})}),(0,M.jsx)(u,{children:t.tooltip})]}),e.priority&&e.priority!==`normal`&&(0,M.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${B[e.priority].className}`,children:B[e.priority].label}),(0,M.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,M.jsxs)(h,{children:[(0,M.jsx)(m,{asChild:!0,children:(0,M.jsx)(ne,{className:`w-3 h-3 text-dracula-purple/60 shrink-0`})}),(0,M.jsxs)(u,{children:[`Part of a pipeline`,e.depends_on_job_id&&` (depends on previous step)`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,M.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:e.command})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,M.jsx)(`span`,{className:`w-14 text-right`,children:i??`—`}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:a?`${a}`:`—`}),(0,M.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,M.jsx)(`span`,{className:`w-20 text-right`,children:se(e.started_at)}),o&&c&&(0,M.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),H(c)},title:`Delete proposal`,children:(0,M.jsx)(d,{className:`w-3 h-3`})})]})]},e.id)})}),Z.length>U&&(0,M.jsx)(`div`,{className:`pt-1 text-center`,children:(0,M.jsxs)(`button`,{type:`button`,onClick:()=>W(e=>e+V),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:[`Load more (`,Z.length-U,` remaining)`]})}),D&&(0,M.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:()=>k(!1),children:(0,M.jsxs)(`div`,{className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`h3`,{className:`text-sm font-semibold`,children:`Clear Jobs`}),(0,M.jsxs)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:[e.length,` job`,e.length===1?``:`s`,` in history`]})]}),(0,M.jsxs)(p,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:F,onClick:()=>$(`all`),children:[`Clear all `,e.length,` job`,e.length===1?``:`s`]}),(0,M.jsxs)(`div`,{className:`space-y-2`,children:[(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Or clear by date range:`}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`input`,{type:`date`,value:A,onChange:e=>j(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:`From`}),(0,M.jsx)(`input`,{type:`date`,value:N,onChange:e=>P(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:`To`})]}),(0,M.jsx)(p,{variant:`outline`,size:`sm`,className:`w-full`,disabled:F||!A&&!N,onClick:()=>$(`range`),children:A||N?`Clear ${Q} job${Q===1?``:`s`} in range`:`Clear range`})]}),(0,M.jsx)(p,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>k(!1),children:`Cancel`})]})}),(0,M.jsx)(v,{open:L!==null,onOpenChange:e=>!e&&H(null),children:(0,M.jsxs)(S,{className:`max-w-sm`,children:[(0,M.jsxs)(y,{children:[(0,M.jsx)(g,{children:`Delete proposal?`}),(0,M.jsx)(x,{children:`This will permanently delete 1 proposal. This action cannot be undone.`})]}),(0,M.jsxs)(b,{children:[(0,M.jsx)(p,{variant:`ghost`,size:`sm`,onClick:()=>H(null),children:`Cancel`}),(0,M.jsx)(p,{variant:`destructive`,size:`sm`,onClick:()=>{L&&i?.(L),H(null)},children:`Delete`})]})]})}),Y&&(0,M.jsx)(R,{jobIds:Y,onClose:()=>{X(null),J([]),K(!1)}})]})}function U(){let{activeProjectId:e}=i(),{recentJobs:t}=E(e),{data:n,isFirstLoad:r,refresh:s}=j({namespace:`jobs`,projectId:e,initialValue:t,fetcher:async()=>{let e=await fetch(`${o()}/jobs?limit=10`);return e.ok?(await e.json()).jobs:[]},pollInterval:1e4}),{data:c}=j({namespace:`proposals`,projectId:e,initialValue:[],fetcher:async()=>{let e=await fetch(`${o()}/propose?limit=10`);return e.ok?(await e.json()).proposals:[]},pollInterval:1e4}),l={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},u=c.map(e=>({id:`proposal:${e.id}`,command:`/sr:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,status:l[e.status]??`queued`})),d=[...n,...u].sort((e,t)=>new Date(t.started_at).getTime()-new Date(e.started_at).getTime()),[f,m]=(0,O.useState)(null),h=(0,O.useCallback)(async e=>{try{let t=await fetch(`${o()}/propose/${e}`);if(!t.ok)return;m((await t.json()).proposal)}catch{}},[]),x=(0,O.useCallback)(async e=>{try{(await fetch(`${o()}/propose/${e}`,{method:`DELETE`})).ok&&(a.success(`Proposal deleted`),s())}catch{}},[s]);return(0,M.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,M.jsx)(`h1`,{className:`text-sm font-semibold`,children:`Jobs`}),(0,M.jsx)(D,{baseUrl:`${o()}/jobs/export`,label:`Export Jobs`})]}),(0,M.jsx)(H,{jobs:d,isLoading:r,onJobsCleared:s,onProposalClick:h,onProposalDelete:x}),(0,M.jsx)(v,{open:f!==null,onOpenChange:e=>!e&&m(null),children:(0,M.jsx)(S,{className:`max-w-3xl glass-card`,children:f&&(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(y,{children:(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(g,{className:`flex-1 min-w-0`,children:`Proposal`}),(0,M.jsx)(w,{variant:f.status===`created`?`success`:f.status===`cancelled`?`destructive`:`secondary`,children:f.status})]})}),(0,M.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:f.idea}),f.result_markdown?(0,M.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,M.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,M.jsx)(T,{remarkPlugins:[_],children:f.result_markdown})})}):(0,M.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:`No proposal content yet.`}),f.issue_url&&(0,M.jsxs)(`div`,{className:`text-xs`,children:[`GitHub Issue:`,` `,(0,M.jsx)(`a`,{href:f.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-dracula-purple hover:underline`,children:f.issue_url})]}),(0,M.jsxs)(b,{children:[(0,M.jsx)(p,{variant:`destructive`,size:`sm`,onClick:()=>{x(f.id),m(null)},children:`Delete`}),(0,M.jsx)(p,{variant:`ghost`,size:`sm`,onClick:()=>m(null),children:`Close`})]})]})})})]})}export{U as default};
@@ -0,0 +1 @@
1
+ import{t as e}from"./index-BvxpERop.js";async function t(t={}){return typeof t==`object`&&Object.freeze(t),await e(`plugin:dialog|open`,{options:t})}export{t as open};