specrails-hub 1.16.0 → 1.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/client/dist/assets/{ActivityFeedPage-DvpAfivV.js → ActivityFeedPage-BQp5YHIn.js} +1 -1
  2. package/client/dist/assets/AnalyticsPage-C6ZZDQ9W.js +4 -0
  3. package/client/dist/assets/DocsDialog-BV4tNX26.js +11 -0
  4. package/client/dist/assets/DocsPage-DIF_yezN.js +11 -0
  5. package/client/dist/assets/{HubAnalyticsPage-D9F8nZ_X.js → HubAnalyticsPage-BVBS5e-X.js} +1 -1
  6. package/client/dist/assets/HubOverviewPage-BJWo2G8c.js +1 -0
  7. package/client/dist/assets/JobDetailPage-Y25p4mlH.js +18 -0
  8. package/client/dist/assets/{PeriodSelector-7HRnFLW-.js → PeriodSelector-DVzKD-q5.js} +1 -1
  9. package/client/dist/assets/index-CEuyp795.css +2 -0
  10. package/client/dist/assets/index-CZaTispp.js +116 -0
  11. package/client/dist/assets/{lib-DXK1W_fF.js → lib-C4q71VYc.js} +1 -1
  12. package/client/dist/assets/{useHub-DCoRS6Ot.js → useHub-C2hzU_Gs.js} +1 -1
  13. package/client/dist/index.html +6 -6
  14. package/package.json +1 -1
  15. package/server/dist/analytics.js +36 -2
  16. package/server/dist/db.js +25 -1
  17. package/server/dist/hub-analytics.js +82 -1
  18. package/server/dist/hub-router.js +71 -2
  19. package/server/dist/project-registry.js +10 -0
  20. package/server/dist/project-router.js +218 -3
  21. package/server/dist/queue-manager.js +186 -20
  22. package/server/dist/types.js +8 -0
  23. package/client/dist/assets/AnalyticsPage-CA1eAHfv.js +0 -4
  24. package/client/dist/assets/DocsDialog-C2cAoeZy.js +0 -11
  25. package/client/dist/assets/DocsPage-KoFUiSEv.js +0 -11
  26. package/client/dist/assets/HubOverviewPage-B28dUwp2.js +0 -1
  27. package/client/dist/assets/JobDetailPage-CoxS1_CW.js +0 -18
  28. package/client/dist/assets/atom-one-dark-Cj7OxAEC.js +0 -1
  29. package/client/dist/assets/index-CeE2UUBA.js +0 -116
  30. package/client/dist/assets/index-DFiT278u.css +0 -2
  31. /package/client/dist/assets/{CategoricalChart-7_Mi_kjI.js → CategoricalChart-DNk2ac4U.js} +0 -0
  32. /package/client/dist/assets/{useSharedWebSocket-mH5cNEha.js → useSharedWebSocket-j0gqXR8o.js} +0 -0
  33. /package/client/dist/assets/{x-lzRk0dr5.js → x-C53vXlx8.js} +0 -0
@@ -1 +1 @@
1
- import{n as e,o as t,r as n}from"./createLucideIcon-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{n as r}from"./useHub-DCoRS6Ot.js";import"./useSharedWebSocket-mH5cNEha.js";import{A as i,N as a,P as o,R as s,T as c,t as l,z as u}from"./index-CeE2UUBA.js";var d=t(n(),1),f=e();function p(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 m({type:e}){switch(e){case`job_completed`:return(0,f.jsx)(o,{className:`w-4 h-4 text-green-500 flex-shrink-0`});case`job_failed`:return(0,f.jsx)(a,{className:`w-4 h-4 text-red-500 flex-shrink-0`});case`job_canceled`:return(0,f.jsx)(s,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`});default:return(0,f.jsx)(c,{className:`w-4 h-4 text-blue-500 flex-shrink-0`})}}function h(e){switch(e){case`job_completed`:return`Completed`;case`job_failed`:return`Failed`;case`job_canceled`:return`Canceled`;default:return`Started`}}function g(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 _(){let{activeProjectId:e}=r(),{items:t,loading:n,hasMore:a,loadMore:o}=l({activeProjectId:e}),s=(0,d.useRef)(null);return(0,d.useEffect)(()=>{let e=s.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&a&&!n&&o()},{threshold:.1});return t.observe(e),()=>t.disconnect()},[a,n,o]),(0,f.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border bg-background/50`,children:[(0,f.jsx)(u,{className:`w-4 h-4 text-muted-foreground`}),(0,f.jsx)(`h1`,{className:`text-sm font-medium`,children:`Activity`})]}),(0,f.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[n&&t.length===0?(0,f.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,f.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):t.length===0?(0,f.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-2 text-muted-foreground`,children:[(0,f.jsx)(u,{className:`w-8 h-8 opacity-40`}),(0,f.jsx)(`p`,{className:`text-sm`,children:`No activity yet`}),(0,f.jsx)(`p`,{className:`text-xs opacity-70`,children:`Job events will appear here when jobs run`})]}):(0,f.jsx)(`ul`,{className:`divide-y divide-border/50`,children:t.map(e=>(0,f.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5 hover:bg-accent/30 transition-colors`,children:[(0,f.jsx)(m,{type:e.type}),(0,f.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,f.jsx)(`p`,{className:`text-xs text-foreground truncate`,title:e.jobCommand,children:e.jobCommand}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,f.jsx)(`span`,{className:`text-xs font-medium ${g(e.type)}`,children:h(e.type)}),e.costUsd!=null&&(0,f.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`$`,e.costUsd.toFixed(4)]})]})]}),(0,f.jsx)(`span`,{className:`text-xs text-muted-foreground flex-shrink-0 tabular-nums`,children:p(e.timestamp)})]},`${e.type}:${e.jobId}`))}),(0,f.jsx)(`div`,{ref:s,className:`h-1`}),n&&t.length>0&&(0,f.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,f.jsx)(i,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!a&&t.length>0&&(0,f.jsx)(`p`,{className:`text-center text-xs text-muted-foreground py-3`,children:`All activity loaded`})]})]})}export{_ as default};
1
+ import{n as e,o as t,r as n}from"./createLucideIcon-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{n as r}from"./useHub-C2hzU_Gs.js";import"./useSharedWebSocket-j0gqXR8o.js";import{E as i,H as a,I as o,L as s,U as c,j as l,t as u}from"./index-CZaTispp.js";var d=t(n(),1),f=e();function p(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 m({type:e}){switch(e){case`job_completed`:return(0,f.jsx)(s,{className:`w-4 h-4 text-green-500 flex-shrink-0`});case`job_failed`:return(0,f.jsx)(o,{className:`w-4 h-4 text-red-500 flex-shrink-0`});case`job_canceled`:return(0,f.jsx)(a,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`});default:return(0,f.jsx)(i,{className:`w-4 h-4 text-blue-500 flex-shrink-0`})}}function h(e){switch(e){case`job_completed`:return`Completed`;case`job_failed`:return`Failed`;case`job_canceled`:return`Canceled`;default:return`Started`}}function g(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 _(){let{activeProjectId:e}=r(),{items:t,loading:n,hasMore:i,loadMore:a}=u({activeProjectId:e}),o=(0,d.useRef)(null);return(0,d.useEffect)(()=>{let e=o.current;if(!e)return;let t=new IntersectionObserver(e=>{e[0].isIntersecting&&i&&!n&&a()},{threshold:.1});return t.observe(e),()=>t.disconnect()},[i,n,a]),(0,f.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,f.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border bg-background/50`,children:[(0,f.jsx)(c,{className:`w-4 h-4 text-muted-foreground`}),(0,f.jsx)(`h1`,{className:`text-sm font-medium`,children:`Activity`})]}),(0,f.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[n&&t.length===0?(0,f.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,f.jsx)(l,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):t.length===0?(0,f.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-2 text-muted-foreground`,children:[(0,f.jsx)(c,{className:`w-8 h-8 opacity-40`}),(0,f.jsx)(`p`,{className:`text-sm`,children:`No activity yet`}),(0,f.jsx)(`p`,{className:`text-xs opacity-70`,children:`Job events will appear here when jobs run`})]}):(0,f.jsx)(`ul`,{className:`divide-y divide-border/50`,children:t.map(e=>(0,f.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5 hover:bg-accent/30 transition-colors`,children:[(0,f.jsx)(m,{type:e.type}),(0,f.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,f.jsx)(`p`,{className:`text-xs text-foreground truncate`,title:e.jobCommand,children:e.jobCommand}),(0,f.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,f.jsx)(`span`,{className:`text-xs font-medium ${g(e.type)}`,children:h(e.type)}),e.costUsd!=null&&(0,f.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`$`,e.costUsd.toFixed(4)]})]})]}),(0,f.jsx)(`span`,{className:`text-xs text-muted-foreground flex-shrink-0 tabular-nums`,children:p(e.timestamp)})]},`${e.type}:${e.jobId}`))}),(0,f.jsx)(`div`,{ref:o,className:`h-1`}),n&&t.length>0&&(0,f.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,f.jsx)(l,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!i&&t.length>0&&(0,f.jsx)(`p`,{className:`text-center text-xs text-muted-foreground py-3`,children:`All activity loaded`})]})]})}export{_ as default};
@@ -0,0 +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-C2hzU_Gs.js";import{n as c,t as l}from"./utils-DSsSbmuB.js";import{$ as u,A as d,An as f,Ar as p,B as m,Bn as h,Cn as g,Cr as _,D as v,Dn as y,Dr as b,En as x,Er as S,F as C,Fn as w,Fr as T,G as ee,Hn as te,I as ne,Ir as re,J as ie,L as ae,Lr as oe,M as se,Mn as ce,Mr as le,N as ue,Nn as de,Nr as E,O as fe,Or as pe,P as me,Q as he,Sn as ge,Sr as _e,Tn as ve,Tr as ye,V as be,Vn as xe,X as Se,Xn as Ce,Y as D,Z as we,Zn as O,_n as Te,_r as Ee,ar as k,bn as De,br as Oe,cr as ke,dr as A,er as Ae,et as je,gn as Me,gr as Ne,hn as Pe,hr as Fe,ir as j,j as Ie,jr as M,kr as Le,ln as Re,lr as ze,mn as Be,mr as Ve,n as He,nn as Ue,nr as We,nt as Ge,o as Ke,or as qe,pn as Je,pr as Ye,q as Xe,r as Ze,rr as Qe,rt as $e,s as et,sr as tt,tr as nt,tt as rt,ur as it,vn as at,wn as ot,wr as st,xn as ct,xr as lt,yn as ut,yr as dt,zn as ft}from"./CategoricalChart-DNk2ac4U.js";import{a as N,c as P,d as pt,i as F,l as mt,n as ht,o as I,r as gt,s as _t,t as vt,u as yt}from"./PeriodSelector-DVzKD-q5.js";import"./useSharedWebSocket-j0gqXR8o.js";import{B as bt,a as xt,i as St,n as Ct,r as wt}from"./index-CZaTispp.js";import{n as L,r as Tt,t as Et}from"./dracula-colors-Ihy2wjP_.js";var Dt=i(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),Ot=i(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),kt=i(`minus`,[[`path`,{d:`M5 12h14`,key:`1ays0h`}]]),At=i(`trending-down`,[[`path`,{d:`M16 17h6v-6`,key:`t6n2it`}],[`path`,{d:`m22 17-8.5-8.5-5 5L2 7`,key:`x473p`}]]),R=n(r());function jt(){return jt=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},jt.apply(null,arguments)}function Mt(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 Nt(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Mt(Object(n),!0).forEach(function(t){Pt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Mt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Pt(e,t,n){return(t=Ft(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Ft(e){var t=It(e,`string`);return typeof t==`symbol`?t:t+``}function It(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 z=32,Lt={align:`center`,iconSize:14,inactiveColor:`#ccc`,layout:`horizontal`,verticalAlign:`middle`,labelStyle:{}};function Rt(e){if(typeof e==`object`&&e&&`strokeDasharray`in e)return String(e.strokeDasharray)}function zt(e){var{data:t,iconType:n,inactiveColor:r}=e,i=z/2,a=z/6,o=z/3,s=t.inactive?r:t.color,c=n??t.type;if(c===`none`)return null;if(c===`plainline`)return R.createElement(`line`,{strokeWidth:4,fill:`none`,stroke:s,strokeDasharray:Rt(t.payload),x1:0,y1:i,x2:z,y2:i,className:`recharts-legend-icon`});if(c===`line`)return R.createElement(`path`,{strokeWidth:4,fill:`none`,stroke:s,d:`M0,${i}h${o}
2
+ A${a},${a},0,1,1,${2*o},${i}
3
+ H${z}M${2*o},${i}
4
+ A${a},${a},0,1,1,${o},${i}`,className:`recharts-legend-icon`});if(c===`rect`)return R.createElement(`path`,{stroke:`none`,fill:s,d:`M0,${z/8}h${z}v${z*3/4}h${-z}z`,className:`recharts-legend-icon`});if(R.isValidElement(t.legendIcon)){var l=Nt({},t);return delete l.legendIcon,R.cloneElement(t.legendIcon,l)}return R.createElement(Ve,{fill:s,cx:i,cy:i,size:z,sizeType:`diameter`,type:c})}function Bt(e){var{payload:t,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o,labelStyle:s}=e,l={x:0,y:0,width:z,height:z},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`?Nt({},s):{};m.color=t.inactive?a:m.color||t.color;var h=f?f(t.value,t,r):t.value;return R.createElement(`li`,jt({className:p,style:u,key:`legend-item-${r}`},Ye(e,t,r)),R.createElement(le,{width:n,height:n,viewBox:l,style:d,"aria-label":`${h} legend icon`},R.createElement(zt,{data:t,iconType:o,inactiveColor:a})),R.createElement(`span`,{className:`recharts-legend-item-text`,style:m},h))})}var Vt=e=>{var t=A(e,Lt),{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 R.createElement(`ul`,{className:`recharts-default-legend`,style:a},R.createElement(Bt,jt({},t,{payload:n})))};function Ht(){return k(We)}var Ut=n(a()),Wt=[`contextPayload`];function Gt(){return Gt=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},Gt.apply(null,arguments)}function Kt(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 B(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Kt(Object(n),!0).forEach(function(t){qt(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Kt(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function qt(e,t,n){return(t=Jt(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Jt(e){var t=Yt(e,`string`);return typeof t==`symbol`?t:t+``}function Yt(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 Xt(e,t){if(e==null)return{};var n,r,i=Zt(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 Zt(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 Qt(e){return e.value}function $t(e){var{contextPayload:t}=e,n=Xt(e,Wt),r=qe(t,e.payloadUniqBy,Qt),i=B(B({},n),{},{payload:r});return R.isValidElement(e.content)?R.cloneElement(e.content,i):typeof e.content==`function`?R.createElement(e.content,i):R.createElement(Vt,i)}function en(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}),B(B({},l),u)}function tn(e){var t=j();return(0,R.useEffect)(()=>{t(ve(e))},[t,e]),null}function nn(e){var t=j();return(0,R.useEffect)(()=>(t(x(e)),()=>{t(x({width:0,height:0}))}),[t,e]),null}function rn(e,t,n,r){return e===`vertical`&&t!=null?{height:t}:e===`horizontal`?{width:n||r}:null}var an={align:`center`,iconSize:14,inactiveColor:`#ccc`,itemSorter:`value`,layout:`horizontal`,verticalAlign:`bottom`};function on(e){var t=A(e,an),n=Ht(),r=p(),i=de(),{width:a,height:o,wrapperStyle:s,portal:c}=t,[l,u]=nt([n]),d=ce(),m=f();if(d==null||m==null)return null;var h=d-(i?.left||0)-(i?.right||0),g=rn(t.layout,o,a,h),_=c?s:B(B({position:`absolute`,width:g?.width||a||`auto`,height:g?.height||o||`auto`},en(s,t,i,d,m,l)),s),v=c??r;return v==null||n==null?null:(0,Ut.createPortal)(R.createElement(`div`,{className:`recharts-legend-wrapper`,style:_,ref:u},R.createElement(tn,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!c&&R.createElement(nn,{width:l.width,height:l.height}),R.createElement($t,Gt({},t,g,{margin:i,chartWidth:d,chartHeight:m,contextPayload:n}))),v)}var V=R.memo(on,ot);V.displayName=`Legend`;var sn=[`points`,`className`,`baseLinePoints`,`connectNulls`],cn;function H(){return H=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},H.apply(null,arguments)}function ln(e,t){if(e==null)return{};var n,r,i=un(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 un(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,t){return t||=e.slice(0),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var fn=e=>e!=null&&e.x===+e.x&&e.y===+e.y,pn=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=[[]];e.forEach(e=>{var n=t[t.length-1];fn(e)?n&&n.push(e):n&&n.length>0&&t.push([])});var n=e[0],r=t[t.length-1];fn(n)&&r&&r.push(n);var i=t[t.length-1];return i&&i.length<=0&&(t=t.slice(0,-1)),t},U=(e,t)=>{var n=pn(e);t&&(n=[n.reduce((e,t)=>[...e,...t],[])]);var r=n.map(e=>e.reduce((e,t,n)=>_(cn||=dn([``,``,``,`,`,``]),e,n===0?`M`:`L`,t.x,t.y),``)).join(``);return n.length===1?`${r}Z`:r},mn=(e,t,n)=>{var r=U(e,n);return`${r.slice(-1)===`Z`?r.slice(0,-1):r}L${U(Array.from(t).reverse(),n).slice(1)}`},hn=e=>{var{points:t,className:n,baseLinePoints:r,connectNulls:i}=e,a=ln(e,sn);if(!t||!t.length)return null;var o=c(`recharts-polygon`,n);if(r&&r.length){var s=a.stroke&&a.stroke!==`none`,l=mn(t,r,i);return R.createElement(`g`,{className:o},R.createElement(`path`,H({},E(a),{fill:l.slice(-1)===`Z`?a.fill:`none`,stroke:`none`,d:l})),s?R.createElement(`path`,H({},E(a),{fill:`none`,d:U(t,i)})):null,s?R.createElement(`path`,H({},E(a),{fill:`none`,d:U(r,i)})):null)}var u=U(t,i);return R.createElement(`path`,H({},E(a),{fill:u.slice(-1)===`Z`?a.fill:`none`,className:o,d:u}))};function gn(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 _n(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?gn(Object(n),!0).forEach(function(t){vn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):gn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function vn(e,t,n){return(t=yn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function yn(e){var t=bn(e,`string`);return typeof t==`symbol`?t:t+``}function bn(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 xn=Qe([xt,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`pie`).find(e=>e.id===t)),Sn=[],Cn=(e,t,n)=>n?.length===0?Sn:n,wn=Qe([Re,xn,Cn],(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=>_n(_n({},t.presentationProps),e.props))),i!=null)return i}}),Tn=Qe([wn,xn,Cn],(e,t,n)=>{if(!(e==null||t==null))return e.map((e,r)=>{var i,a=O(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:Ce(a,t.dataKey),color:o,payload:e,type:t.legendType}})}),En=Qe([wn,xn,Cn,ft],(e,t,n,r)=>{if(!(t==null||e==null))return Xn({offset:r,pieSettings:t,displayedData:e,cells:n})}),Dn=n(st()),On=[`key`],kn=[`onMouseEnter`,`onClick`,`onMouseLeave`],An=[`id`],jn=[`id`];function W(){return W=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},W.apply(null,arguments)}function Mn(e,t){if(e==null)return{};var n,r,i=Nn(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 Nn(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 Pn(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 G(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Pn(Object(n),!0).forEach(function(t){Fn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Pn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Fn(e,t,n){return(t=In(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function In(e){var t=Ln(e,`string`);return typeof t==`symbol`?t:t+``}function Ln(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 Rn(e){var t=(0,R.useMemo)(()=>ae(e.children,ie),[e.children]),n=k(n=>Tn(n,e.id,t));return n==null?null:R.createElement(d,{legendPayload:n})}function zn(e){if(!(e==null||typeof e==`boolean`||typeof e==`function`)){if(R.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 Bn=R.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=zn(d),p={dataDefinedOnItem:r.map(e=>{var t=e.tooltipPayload;return f==null||t==null?t:t.map(e=>G(G({},e),{},{color:f,fill:f}))}),getPosition:e=>r[Number(e)]?.tooltipPosition,settings:{stroke:i,strokeWidth:a,fill:o,dataKey:t,nameKey:n,name:Ce(s,t),hide:c,type:l,color:o,unit:``,graphicalItemId:u}};return R.createElement(Ie,{tooltipEntrySettings:p})}),Vn=(e,t)=>e>t?`start`:e<t?`end`:`middle`,Hn=(e,t,n)=>Fe(typeof t==`function`?t(e):t,n,n*.8),Un=(e,t,n)=>{var{top:r,left:i,width:a,height:o}=t,s=Be(a,o);return{cx:i+Fe(e.cx,a,a/2),cy:r+Fe(e.cy,o,o/2),innerRadius:Fe(e.innerRadius,s,0),outerRadius:Hn(n,e.outerRadius,s),maxRadius:e.maxRadius||Math.sqrt(a*a+o*o)/2}},Wn=(e,t)=>Oe(t-e)*Math.min(Math.abs(t-e),360),Gn=(e,t)=>{if(R.isValidElement(e))return R.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=Mn(t,On);return R.createElement(ct,W({},i,{type:`linear`,className:n}))},Kn=(e,t,n)=>{if(R.isValidElement(e))return R.cloneElement(e,t);var r=n;if(typeof e==`function`&&(r=e(t),R.isValidElement(r)))return r;var i=c(`recharts-pie-label-text`,mt(e));return R.createElement(ee,W({},t,{alignmentBaseline:`middle`,className:i}),r)};function qn(e){var{sectors:t,props:n,showLabels:r}=e,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!t)return null;var s=T(n),c=re(i),l=re(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=Pe(e.cx,e.cy,e.outerRadius+u,n),d=G(G(G(G({},s),e),{},{stroke:`none`},c),{},{index:t,textAnchor:Vn(r.x,e.cx)},r),f=G(G(G(G({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:t,points:[Pe(e.cx,e.cy,e.outerRadius,n),r],key:`line`});return R.createElement(he,{zIndex:Ue.label,key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${t}`},R.createElement(M,null,a&&Gn(a,f),Kn(i,d,O(e,o))))});return R.createElement(M,{className:`recharts-pie-labels`},d)}function Jn(e){var{sectors:t,props:n,showLabels:r}=e,{label:i}=n;return typeof i==`object`&&i&&`position`in i?R.createElement(m,{label:i}):R.createElement(qn,{sectors:t,props:n,showLabels:r})}function Yn(e){var{sectors:t,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:o}=e,s=k(rt),c=k(u),l=k(je),{onMouseEnter:d,onClick:f,onMouseLeave:p}=i,m=Mn(i,kn),h=ue(d,i.dataKey,o),g=me(p),_=se(f,i.dataKey,o);return t==null||t.length===0?null:R.createElement(R.Fragment,null,t.map((e,u)=>{if(e?.startAngle===0&&e?.endAngle===0&&t.length!==1)return null;var d=l==null||l===o,f=String(u)===s&&(c==null||i.dataKey===c)&&d,p=n&&f?n:s?r:null,v=G(G({},e),{},{stroke:e.stroke,tabIndex:-1,[te]:u,[xe]:o});return R.createElement(M,W({key:`sector-${e?.startAngle}-${e?.endAngle}-${e.midAngle}-${u}`,tabIndex:-1,className:`recharts-pie-sector`},Ye(m,e,u),{onMouseEnter:h(e,u),onMouseLeave:g(e,u),onClick:_(e,u)}),R.createElement(C,W({option:a??p,index:u,shapeType:`sector`,isActive:f},v)))}))}function Xn(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=Wn(o,s),p=Math.abs(f),m=n.length<=1?0:t.paddingAngle??0,h=n.filter(e=>O(e,c,0)!==0).length,g=(p>=360?h:h-1)*m,_=p-h*d-g,v=n.reduce((e,t)=>{var n=O(t,c,0);return e+(dt(n)?n:0)},0),y;if(v>0){var b;y=n.map((e,n)=>{var s=O(e,c,0),p=O(e,l,n),h=Un(t,i,e),g=(dt(s)?s:0)/v,y,x=G(G({},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+Oe(f)*m*(s===0?0:1):o;var C=y+Oe(f)*((s===0?0:d)+g*_),w=(y+C)/2,T=(h.innerRadius+h.outerRadius)/2,ee=[{name:p,value:s,payload:x,dataKey:c,type:u,color:S,fill:S,graphicalItemId:t.id}],te=Pe(h.cx,h.cy,T,w);return b=G(G(G(G({},t.presentationProps),{},{percent:g,cornerRadius:typeof a==`string`?parseFloat(a):a,name:p,tooltipPayload:ee,midAngle:w,middleRadius:T,tooltipPosition:te},x),h),{},{value:s,dataKey:c,startAngle:y,endAngle:C,payload:x,paddingAngle:Oe(f)*m}),b})}return y}function Zn(e){var{showLabels:t,sectors:n,children:r}=e,i=(0,R.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 R.createElement(be,{value:t?i:void 0},r)}function Qn(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=Te(t,`recharts-pie-`),m=n.current,[h,g]=(0,R.useState)(!1),_=(0,R.useCallback)(()=>{typeof f==`function`&&f(),g(!1)},[f]),v=(0,R.useCallback)(()=>{typeof d==`function`&&d(),g(!0)},[d]);return R.createElement(Zn,{showLabels:!h,sectors:i},R.createElement(at,{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,Dn.default)(t,`paddingAngle`,0):0;if(r){var s=Ne(r.endAngle-r.startAngle,t.endAngle-t.startAngle,e),c=G(G({},t),{},{startAngle:o+i,endAngle:o+s+i});a.push(c),o=c.endAngle}else{var{endAngle:l,startAngle:u}=t,d=Ne(0,l-u,e),f=G(G({},t),{},{startAngle:o+i,endAngle:o+d+i});a.push(f),o=f.endAngle}}),n.current=a,R.createElement(M,null,R.createElement(Yn,{sectors:a,activeShape:l,inactiveShape:u,allOtherPieProps:t,shape:t.shape,id:r}))}),R.createElement(Jn,{showLabels:!h,sectors:i,props:t}),t.children)}var $n={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:Ue.area};function er(e){var{id:t}=e,n=Mn(e,An),{hide:r,className:i,rootTabIndex:a}=e,o=(0,R.useMemo)(()=>ae(e.children,ie),[e.children]),s=k(e=>En(e,t,o)),l=(0,R.useRef)(null),u=c(`recharts-pie`,i);return r||s==null?(l.current=null,R.createElement(M,{tabIndex:a,className:u})):R.createElement(he,{zIndex:e.zIndex},R.createElement(Bn,{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}),R.createElement(M,{tabIndex:a,className:u},R.createElement(Qn,{props:G(G({},n),{},{sectors:s}),previousSectorsRef:l,id:t})))}function tr(e){var t=A(e,$n),{id:n}=t,r=Mn(t,jn),i=T(r);return R.createElement(fe,{id:n,type:`pie`},e=>R.createElement(R.Fragment,null,R.createElement(v,{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}),R.createElement(Rn,W({},r,{id:e})),R.createElement(er,W({},r,{id:e}))))}var nr=tr;nr.displayName=`Pie`;var rr={begin:0,duration:1e3,easing:`ease`,isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}};function ir(e){var t=A(e,rr),{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=ge(),h=o===`auto`?!g.isSsr&&!m:o,_=ut(n+a,t.animationManager),[v,y]=(0,R.useState)(()=>h?r:i),b=(0,R.useRef)(!1),x=(0,R.useCallback)(()=>{y(r),f()},[r,f]);return(0,R.useEffect)(()=>{if(!h||!s)return lt;b.current=!0;var e=_.subscribe(y);return _.start([x,u,i,c,d]),()=>{_.stop(),e&&e(),d()}},[h,s,c,l,u,x,d,_,i,r]),h?s&&b.current?p({transition:De([a],c,l),[a]:v}):p({[a]:r}):p({[a]:i})}function ar(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 or(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?ar(Object(n),!0).forEach(function(t){sr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):ar(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function sr(e,t,n){return(t=cr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function cr(e){var t=lr(e,`string`);return typeof t==`symbol`?t:t+``}function lr(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 ur=[`item`],dr=or(or({},St),{},{layout:`centric`,startAngle:0,endAngle:360}),fr=(0,R.forwardRef)((e,t)=>{var n=A(e,dr);return R.createElement(wt,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:ur,tooltipPayloadSearcher:Se,categoricalChartProps:n,ref:t})}),pr=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}e.isBuffer=t})),mr=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})),hr=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=ke();function n(e){return t.isTypedArray(e)}e.isTypedArray=n})),gr=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Je();function n(e){let n=t.toFinite(e),r=n%1;return r?n-r:n}e.toInteger=n})),_r=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=gr();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})),vr=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=pr(),n=mr(),r=it(),i=hr(),a=_r();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})),yr=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=ye(),n=Le(),r=pe(),i=b(),a=S();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})),br=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=ze();function n(e){let n=[];for(;e;)n.push(...t.getSymbols(e)),e=Object.getPrototypeOf(e);return n}e.getSymbolsIn=n})),xr=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=it();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})),Sr=e((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=tt(),n=vr(),r=yr(),i=br(),a=pe(),o=xr(),s=ne();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})),Cr=n(e(((e,t)=>{t.exports=Sr().omit}))()),wr=[`width`,`height`,`className`,`style`,`children`,`type`];function Tr(e,t){if(e==null)return{};var n,r,i=Er(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 Er(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 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 Dr(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 q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Dr(Object(n),!0).forEach(function(t){J(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Dr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function J(e,t,n){return(t=Or(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Or(e){var t=kr(e,`string`);return typeof t==`symbol`?t:t+``}function kr(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 Ar=`value`;function jr(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 Mr=(e,t)=>{if(!(!e||!t))return(0,Dn.default)(e,t)},Nr=function(e){return`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:``}children[${e}]`},Pr={chartName:`Treemap`,defaultTooltipEventType:`item`,validateTooltipEventTypes:[`item`],tooltipPayloadSearcher:Mr,eventEmitter:void 0},Fr=e=>{var{depth:t,node:n,index:r,dataKey:i,nameKey:a,nestedActiveTooltipIndex:o}=e,s=t===0?``:Nr(r,o),{children:c}=n,l=t+1,u=c&&c.length?c.map((e,t)=>Fr({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=Ee(p)||p<=0?0:p}return q(q({},n),{},{children:u,name:O(n,a,``),[Ar]:d,depth:t,index:r,tooltipIndex:s})},Ir=e=>({x:e.x,y:e.y,width:e.width,height:e.height}),Lr=(e,t)=>{var n=t<0?0:t;return e.map(e=>{var t=e[Ar]*n;return q(q({},e),{},{area:Ee(t)||t<=0?0:t})})},Rr=(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},zr=(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),q(q({},n),{},{y:n.y+i,height:n.height-i})},Br=(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),q(q({},n),{},{x:n.x+i,width:n.width-i})},Vr=(e,t,n,r)=>t===n.width?zr(e,t,n,r):Br(e,t,n,r),Y=(e,t)=>{var{children:n}=e;if(n&&n.length){var r=Ir(e),i=[],a=1/0,o,s,c=Math.min(r.width,r.height),l=Lr(n,r.width*r.height/e[Ar]),u=l.slice();for(i.area=0;u.length>0;)[o]=u,o!=null&&(i.push(o),i.area+=o.area,s=Rr(i,c,t),s<=a?(u.shift(),a=s):(i.area-=i.pop()?.area??0,r=Vr(i,c,r,!1),c=Math.min(r.width,r.height),i.length=i.area=0,a=1/0));return i.length&&=(r=Vr(i,c,r,!0),i.area=0),q(q({},e),{},{children:l.map(e=>Y(e,t))})}return e},Hr=q({aspectRatio:.5*(1+Math.sqrt(5)),dataKey:`value`,nameKey:`name`,type:`flat`,isAnimationActive:`auto`,isUpdateAnimationActive:`auto`,animationBegin:0,animationDuration:1500,animationEasing:`linear`},et),Ur={isAnimationFinished:!1,formatRoot:null,currentRoot:void 0,nestIndex:[],prevAspectRatio:Hr.aspectRatio,prevDataKey:Hr.dataKey};function Wr(e){var{content:t,nodeProps:n,type:r,colorPanel:i,onMouseEnter:a,onMouseLeave:o,onClick:s}=e;if(R.isValidElement(t))return R.createElement(M,{onMouseEnter:a,onMouseLeave:o,onClick:s},R.cloneElement(t,n));if(typeof t==`function`)return R.createElement(M,{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=R.createElement(hn,{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,g=Xe(n.name);u>20&&d>20&&g.width<u&&g.height<d&&(m=R.createElement(`text`,{x:c+8,y:l+d/2+7,fontSize:14},n.name));var _=i||h;return R.createElement(`g`,null,R.createElement(Me,K({fill:n.depth<2?_[f%_.length]:`rgba(255,255,255,0)`,stroke:`#fff`},(0,Cr.default)(n,[`children`]),{onMouseEnter:a,onMouseLeave:o,onClick:s,"data-recharts-item-index":n.tooltipIndex})),p,m)}function Gr(e){var t=j(),n={x:e.nodeProps.x+e.nodeProps.width/2,y:e.nodeProps.y+e.nodeProps.height/2};return R.createElement(Wr,K({},e,{onMouseEnter:()=>{t($e({activeIndex:e.nodeProps.tooltipIndex,activeDataKey:e.dataKey,activeCoordinate:n,activeGraphicalItemId:e.id}))},onMouseLeave:()=>{},onClick:()=>{t(Ge({activeIndex:e.nodeProps.tooltipIndex,activeDataKey:e.dataKey,activeCoordinate:n,activeGraphicalItemId:e.id}))}}))}var Kr=R.memo(e=>{var{dataKey:t,nameKey:n,stroke:r,fill:i,currentRoot:a,id:o}=e,s={dataDefinedOnItem:a,getPosition:lt,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 R.createElement(Ie,{tooltipEntrySettings:s})}),qr={top:0,right:0,bottom:0,left:0};function Jr(e){var{content:t,nodeProps:n,isLeaf:r,treemapProps:i,onNestClick:a}=e,{id:o,isAnimationActive:s,animationBegin:c,animationDuration:l,animationEasing:u,isUpdateAnimationActive:d,type:f,colorPanel:p,dataKey:m,onAnimationStart:h,onAnimationEnd:g,onMouseEnter:_,onClick:v,onMouseLeave:y}=i,{width:b,height:x,x:S,y:C}=n,w=-S-b,T=0,ee=e=>{(r||f===`nest`)&&typeof _==`function`&&_(n,e)},te=e=>{(r||f===`nest`)&&typeof y==`function`&&y(n,e)},ne=()=>{f===`nest`&&a(n),(r||f===`nest`)&&typeof v==`function`&&v(n)},re=(0,R.useCallback)(()=>{typeof g==`function`&&g()},[g]),ie=(0,R.useCallback)(()=>{typeof h==`function`&&h()},[h]);return R.createElement(ir,{animationId:`treemap-${n.tooltipIndex}`,from:`translate(${w}px, ${T}px)`,to:`translate(0, 0)`,attributeName:`transform`,begin:c,easing:u,isActive:s,duration:l,onAnimationStart:ie,onAnimationEnd:re},e=>R.createElement(M,{onMouseEnter:ee,onMouseLeave:te,onClick:ne,style:q(q({},e),{},{transformOrigin:`${S} ${C}`})},R.createElement(Gr,{id:o,content:t,dataKey:m,nodeProps:q(q({},n),{},{isAnimationActive:s,isUpdateAnimationActive:!d,width:b,height:x,x:S,y:C}),type:f,colorPanel:p})))}var Yr=class extends R.PureComponent{constructor(){super(...arguments),J(this,`state`,q({},Ur)),J(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=Fr({depth:0,node:q(q({},e),{},{x:0,y:0,width:r,height:i}),index:0,dataKey:a,nameKey:o,nestedActiveTooltipIndex:e.tooltipIndex}),l=Y(c,s),{nestIndex:u}=this.state;u.push(e),this.setState({formatRoot:l,currentRoot:c,nestIndex:u})}t&&t(e)}),J(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=Mr(this.state.formatRoot,r);if(jr(i)){var{dataKey:a,dispatch:o}=this.props;o($e({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=Fr({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=Y(n,e.aspectRatio);return q(q({},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=Y(Fr({depth:0,node:q(q({},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=q(q(q({},T(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:R.createElement(M,{key:`recharts-treemap-node-${i.x}-${i.y}-${i.name}`,className:`recharts-treemap-depth-${t.depth}`},R.createElement(Jr,{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 R.createElement(`div`,{className:`recharts-treemap-nest-index-wrapper`,style:{marginTop:`8px`,textAlign:`center`}},n.map((n,r)=>{var i=(0,Dn.default)(n,e,`root`),a=typeof i==`string`?i:`root`,o;return R.isValidElement(t)&&(o=R.cloneElement(t,n,r)),o=typeof t==`function`?t(n,r):a,R.createElement(`div`,{onClick:this.handleNestIndex.bind(this,n,r),key:`nest-index-${_e()}`,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=T(Tr(e,wr));return R.createElement(R.Fragment,null,R.createElement(Kr,{dataKey:this.props.dataKey,nameKey:this.props.nameKey,stroke:this.props.stroke,fill:this.props.fill,currentRoot:this.state.currentRoot,id:this.props.id}),R.createElement(le,K({},s,{width:t,height:o===`nest`?n-30:n,onTouchMove:this.handleTouchMove}),this.renderAllNodes(),a),o===`nest`&&this.renderNestIndex())}};J(Yr,`displayName`,`Treemap`);function Xr(e){var t=j(),n=ce(),r=f();if(!Ae(n)||!Ae(r))return null;var{id:i}=e;return R.createElement(fe,{id:i,type:`treemap`},i=>R.createElement(Yr,K({},e,{id:i,width:n,height:r,dispatch:t})))}function Zr(e){var t=A(e,Hr),{className:n,style:r,width:i,height:a,throttleDelay:o,throttledEvents:s}=t,[c,l]=(0,R.useState)(null);return R.createElement(Ke,{preloadedState:{options:Pr},reduxStoreName:t.className??`Treemap`},R.createElement(y,{margin:qr}),R.createElement(Ze,{throttleDelay:o,throttledEvents:s}),R.createElement(He,{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},R.createElement(we.Provider,{value:c},R.createElement(Xr,t))))}var X=t();function Qr(e){return`$${e.toFixed(4)}`}function $r(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 ei(e){return`${(e*100).toFixed(1)}%`}function ti(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function ni(e){return e===null?null:`${e>0?`+`:``}${e.toFixed(1)}%`}function Z({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=ni(t);return(0,X.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,X.jsx)(kt,{className:`w-2.5 h-2.5`}):i?(0,X.jsx)(pt,{className:`w-2.5 h-2.5`}):(0,X.jsx)(At,{className:`w-2.5 h-2.5`}),c??s]})}function Q({label:e,value:t,previousValue:n,badge:r}){return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e}),(0,X.jsxs)(`div`,{className:`flex items-end justify-between gap-2`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`p`,{className:`text-xl font-semibold tabular-nums`,children:t}),n!=null&&(0,X.jsxs)(`p`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`prev: `,n]})]}),r]})]})}function ri({kpi:e}){let t=e.previousPeriod;return(0,X.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-5 gap-3`,children:[(0,X.jsx)(Q,{label:`Total Cost`,value:Qr(e.totalCostUsd),previousValue:t?Qr(t.totalCostUsd):null,badge:(0,X.jsx)(Z,{delta:e.costDelta,deltaPct:e.costDeltaPct,lowerIsBetter:!0,formatter:e=>`$${e.toFixed(4)}`})}),(0,X.jsx)(Q,{label:`Total Jobs`,value:String(e.totalJobs),previousValue:t?String(t.totalJobs):null,badge:(0,X.jsx)(Z,{delta:e.jobsDelta,deltaPct:e.jobsDeltaPct,lowerIsBetter:!1,formatter:e=>`+${e}`})}),(0,X.jsx)(Q,{label:`Success Rate`,value:ei(e.successRate),previousValue:t?ei(t.successRate):null,badge:(0,X.jsx)(Z,{delta:e.successRateDelta,deltaPct:e.successRateDeltaPct,lowerIsBetter:!1,formatter:e=>`${(e*100).toFixed(1)}%`})}),(0,X.jsx)(Q,{label:`Avg Duration`,value:$r(e.avgDurationMs),previousValue:t?$r(t.avgDurationMs):null,badge:(0,X.jsx)(Z,{delta:e.avgDurationDelta,deltaPct:e.avgDurationDeltaPct,lowerIsBetter:!0,formatter:e=>$r(e)})}),(0,X.jsx)(Q,{label:`Total Tokens`,value:ti(e.totalTokens),previousValue:t?ti(t.totalTokens):null,badge:(0,X.jsx)(Z,{delta:e.totalTokensDelta,deltaPct:e.totalTokensDeltaPct,lowerIsBetter:!0,formatter:e=>ti(e)})})]})}function ii({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,X.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,X.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]})}function ai(e){try{return yt(new Date(e),`MMM d`)}catch{return e}}function oi({data:e}){if(!(e.length>0&&e.some(e=>e.costUsd>0)))return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost Over Time`}),(0,X.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,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost Over Time`}),(0,X.jsx)(w,{width:`100%`,height:220,children:(0,X.jsxs)(gt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,X.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,X.jsx)(N,{dataKey:`date`,ticks:n,tickFormatter:ai,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,X.jsx)(F,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,X.jsx)(D,{content:(0,X.jsx)(ii,{})}),(0,X.jsx)(_t,{type:`monotone`,dataKey:`costUsd`,stroke:L.purple,strokeWidth:2,dot:!1,activeDot:{r:3,fill:L.purple}})]})})]})}function si({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0];return(0,X.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,X.jsx)(`p`,{className:`capitalize font-medium`,children:n.name}),(0,X.jsxs)(`p`,{className:`text-muted-foreground`,children:[n.value,` jobs`]})]})}function ci({data:e}){if(e.length===0)return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Jobs by Status`}),(0,X.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,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Jobs by Status`}),(0,X.jsx)(w,{width:`100%`,height:220,children:(0,X.jsxs)(fr,{children:[(0,X.jsx)(nr,{data:e,dataKey:`count`,nameKey:`status`,cx:`50%`,cy:`50%`,innerRadius:60,outerRadius:90,paddingAngle:2,children:e.map(e=>(0,X.jsx)(ie,{fill:Tt[e.status]??`var(--color-muted-foreground)`},e.status))}),(0,X.jsx)(D,{content:(0,X.jsx)(si,{})}),(0,X.jsx)(V,{formatter:n=>{let r=e.find(e=>e.status===n),i=r?(r.count/t*100).toFixed(0):`0`;return(0,X.jsxs)(`span`,{className:`text-xs capitalize`,children:[n,` (`,r?.count??0,`, `,i,`%)`]})}})]})})]})}var li=[`<1m`,`1-3m`,`3-5m`,`5-10m`,`>10m`];function ui(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 di({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,X.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,X.jsxs)(`p`,{className:`font-medium`,children:[t[0].value,` jobs`]})]})}function fi({data:e,percentiles:t}){let n=li.map(t=>({bucket:t,count:e.find(e=>e.bucket===t)?.count??0}));return n.some(e=>e.count>0)?(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Duration Distribution`}),(0,X.jsx)(w,{width:`100%`,height:180,children:(0,X.jsxs)(ht,{data:n,margin:{top:4,right:8,left:0,bottom:0},children:[(0,X.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`,vertical:!1}),(0,X.jsx)(N,{dataKey:`bucket`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,X.jsx)(F,{allowDecimals:!1,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:30}),(0,X.jsx)(D,{content:(0,X.jsx)(di,{})}),(0,X.jsx)(I,{dataKey:`count`,fill:L.cyan,radius:[3,3,0,0]})]})}),(0,X.jsx)(`div`,{className:`flex items-center gap-3 mt-2`,children:[`p50`,`p75`,`p95`].map(e=>(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsxs)(`span`,{className:`text-[10px] text-muted-foreground uppercase`,children:[e,`:`]}),(0,X.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums`,children:ui(t[e])})]},e))})]}):(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Duration Distribution`}),(0,X.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No duration data available`})]})}function pi({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,X.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground mb-1 font-mono truncate max-w-48`,children:n}),t.map(e=>(0,X.jsxs)(`p`,{style:{color:e.color},children:[e.name,`: `,e.value.toLocaleString()]},e.name))]})}function mi({data:e}){if(e.length===0)return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Token Efficiency`}),(0,X.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,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Token Efficiency`}),(0,X.jsx)(w,{width:`100%`,height:220,children:(0,X.jsxs)(ht,{layout:`vertical`,data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,X.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`,horizontal:!1}),(0,X.jsx)(N,{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,X.jsx)(F,{type:`category`,dataKey:`name`,width:110,tick:{fontSize:9,fill:`var(--color-muted-foreground)`,fontFamily:`monospace`},axisLine:!1,tickLine:!1}),(0,X.jsx)(D,{content:(0,X.jsx)(pi,{})}),(0,X.jsx)(V,{formatter:e=>(0,X.jsx)(`span`,{className:`text-xs`,children:e})}),(0,X.jsx)(I,{dataKey:`tokensOut`,name:`Output tokens`,fill:L.purple,stackId:`a`,radius:[0,3,3,0]}),(0,X.jsx)(I,{dataKey:`tokensCacheRead`,name:`Cached tokens`,fill:L.cyan,stackId:`a`,radius:[0,3,3,0]})]})})]})}function hi(e){return e===null?`—`:`$${e.toFixed(4)}`}function gi(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 _i({rate:e}){let t=(e*100).toFixed(0);return(0,X.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,X.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,X.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[e,n===t?r===`asc`?(0,X.jsx)(Dt,{className:`w-3 h-3`}):(0,X.jsx)(bt,{className:`w-3 h-3`}):(0,X.jsx)(Ot,{className:`w-3 h-3 opacity-40`})]})})}function vi({data:e}){let[t,n]=(0,R.useState)(`totalCostUsd`),[r,i]=(0,R.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,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Command Performance`}),(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No command data for this period`})]}):(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Command Performance`}),(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-border/30`,children:[(0,X.jsx)($,{label:`Command`,sortKey:`command`,current:t,dir:r,onSort:a}),(0,X.jsx)($,{label:`Runs`,sortKey:`totalRuns`,current:t,dir:r,onSort:a}),(0,X.jsx)($,{label:`Success Rate`,sortKey:`successRate`,current:t,dir:r,onSort:a}),(0,X.jsx)($,{label:`Avg Cost`,sortKey:`avgCostUsd`,current:t,dir:r,onSort:a}),(0,X.jsx)($,{label:`Avg Duration`,sortKey:`avgDurationMs`,current:t,dir:r,onSort:a}),(0,X.jsx)($,{label:`Total Cost`,sortKey:`totalCostUsd`,current:t,dir:r,onSort:a})]})}),(0,X.jsx)(`tbody`,{children:o.map(e=>(0,X.jsxs)(`tr`,{className:`border-b border-border/20 hover:bg-accent/20 transition-colors`,children:[(0,X.jsx)(`td`,{className:`px-3 py-2 font-mono text-[10px] text-foreground`,children:e.command}),(0,X.jsx)(`td`,{className:`px-3 py-2 tabular-nums`,children:e.totalRuns}),(0,X.jsx)(`td`,{className:`px-3 py-2`,children:(0,X.jsx)(_i,{rate:e.successRate})}),(0,X.jsx)(`td`,{className:`px-3 py-2 tabular-nums`,children:hi(e.avgCostUsd)}),(0,X.jsx)(`td`,{className:`px-3 py-2 tabular-nums`,children:gi(e.avgDurationMs)}),(0,X.jsx)(`td`,{className:`px-3 py-2 tabular-nums font-medium`,children:hi(e.totalCostUsd)})]},e.command))})]})})]})}function yi({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,X.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),t.map(e=>(0,X.jsxs)(`p`,{style:{color:e.color},children:[e.name,`: `,e.value]},e.name))]})}function bi(e){try{return yt(new Date(e),`MMM d`)}catch{return e}}function xi({data:e}){if(!(e.length>0&&e.some(e=>e.completed+e.failed+e.canceled>0)))return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Daily Throughput`}),(0,X.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,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Daily Throughput`}),(0,X.jsx)(w,{width:`100%`,height:220,children:(0,X.jsxs)(ht,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,X.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`,vertical:!1}),(0,X.jsx)(N,{dataKey:`date`,ticks:n,tickFormatter:bi,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,X.jsx)(F,{allowDecimals:!1,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:30}),(0,X.jsx)(D,{content:(0,X.jsx)(yi,{})}),(0,X.jsx)(V,{formatter:e=>(0,X.jsx)(`span`,{className:`text-xs capitalize`,children:e})}),(0,X.jsx)(I,{dataKey:`completed`,name:`Completed`,stackId:`a`,fill:L.purple}),(0,X.jsx)(I,{dataKey:`failed`,name:`Failed`,stackId:`a`,fill:L.pink}),(0,X.jsx)(I,{dataKey:`canceled`,name:`Canceled`,stackId:`a`,fill:L.orange,radius:[3,3,0,0]})]})})]})}function Si({x:e=0,y:t=0,width:n=0,height:r=0,name:i=``,size:a=0,colorIndex:o=0}){let s=Et[o%Et.length];return(0,X.jsxs)(`g`,{children:[(0,X.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,X.jsxs)(X.Fragment,{children:[(0,X.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,X.jsxs)(`text`,{x:e+6,y:t+30,fill:`hsl(231 15% 18% / 0.7)`,fontSize:9,children:[`$`,a.toFixed(4)]})]})]})}function Ci({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return n?(0,X.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,X.jsx)(`p`,{className:`font-mono font-medium mb-1`,children:n.name}),(0,X.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Cost: $`,n.size.toFixed(4)]}),(0,X.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Jobs: `,n.jobCount]})]}):null}function wi({data:e}){let t=e.filter(e=>e.totalCostUsd>0);if(t.length===0)return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost per Command`}),(0,X.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,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost per Command`}),(0,X.jsx)(w,{width:`100%`,height:220,children:(0,X.jsx)(Zr,{data:n,dataKey:`size`,content:(0,X.jsx)(Si,{}),children:(0,X.jsx)(D,{content:(0,X.jsx)(Ci,{})})})})]})}function Ti({label:e,value:t}){return(0,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-3 space-y-1`,children:[(0,X.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide`,children:e}),(0,X.jsx)(`p`,{className:`text-base font-semibold tabular-nums`,children:t})]})}function Ei({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,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-4`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:`Bonus Metrics`}),(0,X.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,X.jsx)(Ti,{label:`Cost per Success`,value:t}),(0,X.jsx)(Ti,{label:`API Efficiency`,value:n}),(0,X.jsx)(Ti,{label:`Failure Cost`,value:r})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:`Model Breakdown`}),e.modelBreakdown.length===0?(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No model data for this period`}):(0,X.jsx)(`div`,{className:`overflow-x-auto`,children:(0,X.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,X.jsx)(`thead`,{children:(0,X.jsxs)(`tr`,{className:`border-b border-border/30`,children:[(0,X.jsx)(`th`,{className:`px-3 py-1.5 text-left text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Model`}),(0,X.jsx)(`th`,{className:`px-3 py-1.5 text-left text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Jobs`}),(0,X.jsx)(`th`,{className:`px-3 py-1.5 text-left text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Total Cost`})]})}),(0,X.jsx)(`tbody`,{children:e.modelBreakdown.map(e=>(0,X.jsxs)(`tr`,{className:`border-b border-border/20`,children:[(0,X.jsx)(`td`,{className:`px-3 py-1.5 font-mono text-[10px]`,children:e.model}),(0,X.jsx)(`td`,{className:`px-3 py-1.5 tabular-nums`,children:e.jobCount}),(0,X.jsxs)(`td`,{className:`px-3 py-1.5 tabular-nums`,children:[`$`,e.totalCostUsd.toFixed(4)]})]},e.model))})]})})]})]})}var Di=[{key:`cost`,label:`Avg Cost ($)`,color:L.purple},{key:`duration`,label:`Avg Duration (min)`,color:L.cyan},{key:`successRate`,label:`Success Rate (%)`,color:L.green}];function Oi({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,X.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg space-y-1`,children:[(0,X.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),t.map(e=>(0,X.jsxs)(`p`,{style:{color:e.color},children:[e.name,`: `,(0,X.jsx)(`span`,{className:`font-medium`,children:e.value})]},e.name))]})}function ki(e){try{return yt(new Date(e),`MMM d`)}catch{return e}}function Ai({points:e}){let[t,n]=(0,R.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,X.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,X.jsx)(`h3`,{className:`text-sm font-medium`,children:`Performance Trends`}),(0,X.jsx)(`div`,{className:`flex items-center gap-2`,children:Di.map(e=>(0,X.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,X.jsx)(`span`,{className:`w-2 h-2 rounded-full inline-block shrink-0`,style:{background:e.color}}),e.label]},e.key))})]}),r?(0,X.jsx)(w,{width:`100%`,height:220,children:(0,X.jsxs)(gt,{data:i,margin:{top:4,right:8,left:0,bottom:0},children:[(0,X.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,X.jsx)(N,{dataKey:`date`,ticks:o,tickFormatter:ki,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,X.jsx)(F,{tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:40}),(0,X.jsx)(D,{content:(0,X.jsx)(Oi,{})}),(0,X.jsx)(V,{wrapperStyle:{fontSize:`10px`,paddingTop:`8px`}}),t.has(`cost`)&&(0,X.jsx)(_t,{type:`monotone`,dataKey:`cost`,name:`Avg Cost ($)`,stroke:L.purple,strokeWidth:2,dot:!1,activeDot:{r:3,fill:L.purple}}),t.has(`duration`)&&(0,X.jsx)(_t,{type:`monotone`,dataKey:`duration`,name:`Avg Duration (min)`,stroke:L.cyan,strokeWidth:2,dot:!1,activeDot:{r:3,fill:L.cyan}}),t.has(`successRate`)&&(0,X.jsx)(_t,{type:`monotone`,dataKey:`successRate`,name:`Success Rate (%)`,stroke:L.green,strokeWidth:2,dot:!1,activeDot:{r:3,fill:L.green}})]})}):(0,X.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No job data for this period`})]})}function ji(){return(0,X.jsxs)(`div`,{className:`space-y-4`,children:[(0,X.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,X.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,X.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:Array.from({length:4}).map((e,t)=>(0,X.jsx)(`div`,{className:`h-[260px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,X.jsx)(`div`,{className:`h-[180px] rounded-lg border border-border/40 bg-card/50 animate-pulse`})]})}function Mi({message:e,onRetry:t}){return(0,X.jsxs)(`div`,{className:`rounded-lg border border-red-400/30 bg-red-400/10 p-4 flex items-center justify-between`,children:[(0,X.jsx)(`p`,{className:`text-sm text-red-400`,children:e}),(0,X.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,X.jsx)(oe,{className:`w-3 h-3`}),`Retry`]})]})}var Ni=[{value:`1d`,label:`1d`},{value:`7d`,label:`7d`},{value:`30d`,label:`30d`}];function Pi(){let{activeProjectId:e}=o(),[t,n]=(0,R.useState)(`7d`),[r,i]=(0,R.useState)(``),[a,c]=(0,R.useState)(``),[l,u]=(0,R.useState)(null),[d,f]=(0,R.useState)(!0),[p,m]=(0,R.useState)(null),[h,g]=(0,R.useState)(0),[_,v]=(0,R.useState)(`7d`),[y,b]=(0,R.useState)(null),x=(0,R.useRef)(new Map);(0,R.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,R.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,X.jsxs)(`div`,{className:`flex flex-col gap-4 p-4`,children:[(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`h1`,{className:`text-base font-semibold`,children:`Analytics`}),l&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:l.period.label})]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(vt,{period:t,from:r,to:a,onChange:S}),(0,X.jsx)(Ct,{baseUrl:`${s()}/analytics/export`,params:{period:t,...r?{from:r}:{},...a?{to:a}:{}}})]})]}),d&&(0,X.jsx)(ji,{}),!d&&p&&(0,X.jsx)(Mi,{message:`Failed to load analytics: ${p}`,onRetry:C}),!d&&!p&&l&&(0,X.jsxs)(`div`,{className:`space-y-6`,children:[(0,X.jsx)(ri,{kpi:l.kpi}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,X.jsx)(oi,{data:l.costTimeline}),(0,X.jsx)(ci,{data:l.statusBreakdown}),(0,X.jsx)(fi,{data:l.durationHistogram,percentiles:l.durationPercentiles}),(0,X.jsx)(mi,{data:l.tokenEfficiency})]}),(0,X.jsx)(vi,{data:l.commandPerformance}),(0,X.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,X.jsx)(xi,{data:l.dailyThroughput}),(0,X.jsx)(wi,{data:l.costPerCommand})]}),(0,X.jsx)(Ei,{data:l.bonusMetrics}),y&&(0,X.jsxs)(`div`,{children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-medium`,children:`Trends`}),(0,X.jsx)(`div`,{className:`flex items-center gap-1`,children:Ni.map(e=>(0,X.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,X.jsx)(Ai,{points:y.points})]})]})]})}export{Pi as default};
@@ -0,0 +1,11 @@
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{P as i,V as a,b as o,c as s,j as c,s as l,x as u,z as d}from"./index-CZaTispp.js";import{t as f}from"./lib-C4q71VYc.js";/* empty css */var p=t(n(),1),m=e();function h({categories:e,activeCategory:t,activeSlug:n,onSelect:o,onHome:s}){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:s,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)(a,{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:()=>o(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)(i,{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)(i,{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)(d,{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),[a,s]=(0,p.useState)(!0),[l,d]=(0,p.useState)(null);return(0,p.useEffect)(()=>{s(!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(()=>s(!1))},[e,t,n]),a?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(c,{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
+ prose-headings:text-foreground prose-headings:font-bold
3
+ prose-p:text-foreground/90
4
+ prose-a:text-dracula-purple prose-a:no-underline hover:prose-a:underline
5
+ prose-strong:text-foreground
6
+ prose-code:text-dracula-cyan prose-code:bg-card prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-xs
7
+ prose-pre:bg-card prose-pre:border prose-pre:border-border prose-pre:rounded-md prose-pre:p-0 prose-pre:overflow-x-auto
8
+ prose-blockquote:border-l-dracula-purple prose-blockquote:text-muted-foreground
9
+ prose-hr:border-border
10
+ prose-th:text-foreground prose-td:text-foreground/90
11
+ prose-li:text-foreground/90`,children:(0,m.jsx)(u,{remarkPlugins:[o],rehypePlugins:[f],children:r.content})})}):null}function v({open:e,onClose:t}){let[n,r]=(0,p.useState)(null),[i,a]=(0,p.useState)(!0),[o,u]=(0,p.useState)(),[d,f]=(0,p.useState)();(0,p.useEffect)(()=>{e&&(a(!0),fetch(`/api/docs`).then(e=>e.json()).then(e=>r(e)).catch(()=>r({categories:[]})).finally(()=>a(!1)))},[e]);function v(e,t){u(e),f(t)}function y(){u(void 0),f(void 0)}let b=!!(o&&d);return(0,m.jsx)(l,{open:e,onOpenChange:e=>{e||t()},children:(0,m.jsx)(s,{className:`max-w-5xl max-h-[90vh] overflow-hidden p-0 flex flex-col`,children:(0,m.jsxs)(`div`,{className:`flex flex-1 overflow-hidden`,children:[i?(0,m.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,m.jsx)(c,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,m.jsx)(h,{categories:n?.categories??[],activeCategory:o,activeSlug:d,onSelect:v,onHome:y}),(0,m.jsx)(`main`,{className:`flex-1 overflow-y-auto`,children:b&&o&&d?(0,m.jsx)(_,{category:o,slug:d,onNotFound:y}):n&&(0,m.jsx)(g,{categories:n.categories,onSelect:v})})]})})})}export{v as default};
@@ -0,0 +1,11 @@
1
+ import{n as e,o as t,r as n}from"./createLucideIcon-j4o5em8U.js";import{t as r}from"./utils-DSsSbmuB.js";import{J as i,P as a,V as o,Y as s,b as c,j as l,q as u,x as d,z as f}from"./index-CZaTispp.js";import{t as p}from"./lib-C4q71VYc.js";/* empty css */var m=t(n(),1),h=e();function g({categories:e,activeCategory:t,activeSlug:n}){return(0,h.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,h.jsxs)(u,{to:`/docs`,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,h.jsx)(o,{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 o=t===e.slug&&n===i.slug;return(0,h.jsx)(`li`,{children:(0,h.jsxs)(u,{to:`/docs/${e.slug}/${i.slug}`,className:r(`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors`,o?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,h.jsx)(a,{className:`w-3 h-3 flex-shrink-0`}),i.title]})},i.slug)})})]},e.slug))})]})}function _({categories:e}){let t=e.reduce((e,t)=>e+t.docs.length,0);return(0,h.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:`Documentation`}),(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t===0?`No documents yet. Add Markdown files to ~/.specrails/docs/ to get started.`:`${t} document${t===1?``:`s`} across ${e.filter(e=>e.docs.length>0).length} categories.`})]}),(0,h.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:`No documents in this category yet.`}):(0,h.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(t=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(u,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group`,children:[(0,h.jsx)(a,{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)(f,{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),[s,u]=(0,m.useState)(null),f=i();return(0,m.useEffect)(()=>{o(!0),u(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=>{u(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)(l,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):s?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(`p`,{className:`text-sm text-destructive`,children:s})}):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
+ prose-headings:text-foreground prose-headings:font-bold
3
+ prose-p:text-foreground/90
4
+ prose-a:text-dracula-purple prose-a:no-underline hover:prose-a:underline
5
+ prose-strong:text-foreground
6
+ prose-code:text-dracula-cyan prose-code:bg-card prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-xs
7
+ prose-pre:bg-card prose-pre:border prose-pre:border-border prose-pre:rounded-md prose-pre:p-0 prose-pre:overflow-x-auto
8
+ prose-blockquote:border-l-dracula-purple prose-blockquote:text-muted-foreground
9
+ prose-hr:border-border
10
+ prose-th:text-foreground prose-td:text-foreground/90
11
+ prose-li:text-foreground/90`,children:(0,h.jsx)(d,{remarkPlugins:[c],rehypePlugins:[p],children:n.content})})}):null}function y(){let{category:e,slug:t}=s(),[n,r]=(0,m.useState)(null),[i,a]=(0,m.useState)(!0);(0,m.useEffect)(()=>{fetch(`/api/docs`).then(e=>e.json()).then(e=>r(e)).catch(()=>r({categories:[]})).finally(()=>a(!1))},[]);let o=!!(e&&t);return(0,h.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[i?(0,h.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,h.jsx)(l,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,h.jsx)(g,{categories:n?.categories??[],activeCategory:e,activeSlug:t}),(0,h.jsx)(`main`,{className:`flex-1 overflow-y-auto`,children:o&&e&&t?(0,h.jsx)(v,{category:e,slug:t}):n&&(0,h.jsx)(_,{categories:n.categories})})]})}export{y as default};
@@ -1 +1 @@
1
- import{n as e,o as t,r as n}from"./createLucideIcon-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{Fn as r,Lr as i,Y as a}from"./CategoricalChart-7_Mi_kjI.js";import{a as o,c as s,d as c,i as l,n as u,o as d,r as f,s as p,t as m,u as h}from"./PeriodSelector-7HRnFLW-.js";import{n as g}from"./useSharedWebSocket-mH5cNEha.js";import{n as _,t as v}from"./dracula-colors-Ihy2wjP_.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)),i=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)(r,{width:`100%`,height:200,children:(0,b.jsxs)(f,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,b.jsx)(s,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,b.jsx)(o,{dataKey:`date`,ticks:i,tickFormatter:e=>{try{return h(new Date(e),`MMM d`)}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,b.jsx)(l,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,b.jsx)(a,{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)(p,{type:`monotone`,dataKey:`costUsd`,stroke:_.purple,strokeWidth:2,dot:!1,activeDot:{r:3,fill:_.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:v[n%v.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)(r,{width:`100%`,height:180,children:(0,b.jsxs)(u,{data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,b.jsx)(s,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,b.jsx)(o,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,b.jsx)(l,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,b.jsx)(a,{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)(d,{dataKey:`costUsd`,fill:_.cyan,radius:[3,3,0,0]})]})})]})}function T(){let[e,t]=(0,y.useState)(`7d`),[n,r]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(!0),[f,p]=(0,y.useState)(null),{registerHandler:h,unregisterHandler:_}=g(),v=(0,y.useCallback)(t=>{let r=t;r.type===`log`&&r.event_type===`job_done`&&T(e,n,a)},[e,n,a]);(0,y.useEffect)(()=>(h(`hub-analytics`,v),()=>_(`hub-analytics`)),[v,h,_]);async function T(e,t,n){d(!0),p(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}`);l(await i.json())}catch(e){p(e.message)}finally{d(!1)}}(0,y.useEffect)(()=>{T(e,n,a)},[e,n,a]);function E(e,n,i){t(e),n!==void 0&&r(n),i!==void 0&&o(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)(c,{className:`w-4 h-4 text-muted-foreground`}),(0,b.jsx)(`h1`,{className:`text-sm font-semibold`,children:`Hub Analytics`}),s&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.period.label})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(m,{period:e,from:n,to:a,onChange:E}),(0,b.jsx)(`button`,{onClick:()=>T(e,n,a),disabled:u,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)(i,{className:`w-3 h-3 ${u?`animate-spin`:``}`})})]})]}),f&&(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: `,f]}),u&&!s&&(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))})]}),s&&(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsx)(x,{kpi:s.kpi}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,b.jsx)(S,{data:s.costTimeline}),(0,b.jsx)(w,{projects:s.projectBreakdown})]}),(0,b.jsx)(C,{projects:s.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{Fn as r,Lr as i,Y as a}from"./CategoricalChart-DNk2ac4U.js";import{a as o,c as s,d as c,i as l,n as u,o as d,r as f,s as p,t as m,u as h}from"./PeriodSelector-DVzKD-q5.js";import{n as g}from"./useSharedWebSocket-j0gqXR8o.js";import{n as _,t as v}from"./dracula-colors-Ihy2wjP_.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)),i=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)(r,{width:`100%`,height:200,children:(0,b.jsxs)(f,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,b.jsx)(s,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,b.jsx)(o,{dataKey:`date`,ticks:i,tickFormatter:e=>{try{return h(new Date(e),`MMM d`)}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,b.jsx)(l,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,b.jsx)(a,{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)(p,{type:`monotone`,dataKey:`costUsd`,stroke:_.purple,strokeWidth:2,dot:!1,activeDot:{r:3,fill:_.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:v[n%v.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)(r,{width:`100%`,height:180,children:(0,b.jsxs)(u,{data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,b.jsx)(s,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,b.jsx)(o,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,b.jsx)(l,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,b.jsx)(a,{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)(d,{dataKey:`costUsd`,fill:_.cyan,radius:[3,3,0,0]})]})})]})}function T(){let[e,t]=(0,y.useState)(`7d`),[n,r]=(0,y.useState)(``),[a,o]=(0,y.useState)(``),[s,l]=(0,y.useState)(null),[u,d]=(0,y.useState)(!0),[f,p]=(0,y.useState)(null),{registerHandler:h,unregisterHandler:_}=g(),v=(0,y.useCallback)(t=>{let r=t;r.type===`log`&&r.event_type===`job_done`&&T(e,n,a)},[e,n,a]);(0,y.useEffect)(()=>(h(`hub-analytics`,v),()=>_(`hub-analytics`)),[v,h,_]);async function T(e,t,n){d(!0),p(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}`);l(await i.json())}catch(e){p(e.message)}finally{d(!1)}}(0,y.useEffect)(()=>{T(e,n,a)},[e,n,a]);function E(e,n,i){t(e),n!==void 0&&r(n),i!==void 0&&o(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)(c,{className:`w-4 h-4 text-muted-foreground`}),(0,b.jsx)(`h1`,{className:`text-sm font-semibold`,children:`Hub Analytics`}),s&&(0,b.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:s.period.label})]}),(0,b.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,b.jsx)(m,{period:e,from:n,to:a,onChange:E}),(0,b.jsx)(`button`,{onClick:()=>T(e,n,a),disabled:u,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)(i,{className:`w-3 h-3 ${u?`animate-spin`:``}`})})]})]}),f&&(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: `,f]}),u&&!s&&(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))})]}),s&&(0,b.jsxs)(`div`,{className:`space-y-3`,children:[(0,b.jsx)(x,{kpi:s.kpi}),(0,b.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,b.jsx)(S,{data:s.costTimeline}),(0,b.jsx)(w,{projects:s.projectBreakdown})]}),(0,b.jsx)(C,{projects:s.projectBreakdown})]})]})})}export{T as default};
@@ -0,0 +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}from"./useHub-C2hzU_Gs.js";import{t as a}from"./x-C53vXlx8.js";import"./useSharedWebSocket-j0gqXR8o.js";import{D as o,E as s,F as c,I as l,M as u,N as d,O as f,R as p,U as m,n as h,u as g}from"./index-CZaTispp.js";import{r as _}from"./dracula-colors-Ihy2wjP_.js";var v=r(`circle-check-big`,[[`path`,{d:`M21.801 10A10 10 0 1 1 17 3.335`,key:`yps3ct`}],[`path`,{d:`m9 11 3 3L22 4`,key:`1pflzl`}]]),y=r(`dollar-sign`,[[`line`,{x1:`12`,x2:`12`,y1:`2`,y2:`22`,key:`7eqyqh`}],[`path`,{d:`M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6`,key:`1b0p4s`}]]),b=r(`loader`,[[`path`,{d:`M12 2v4`,key:`3427ic`}],[`path`,{d:`m16.2 7.8 2.9-2.9`,key:`r700ao`}],[`path`,{d:`M18 12h4`,key:`wj9ykh`}],[`path`,{d:`m16.2 16.2 2.9 2.9`,key:`1bxg5t`}],[`path`,{d:`M12 18v4`,key:`jadmvz`}],[`path`,{d:`m4.9 19.1 2.9-2.9`,key:`bwix9q`}],[`path`,{d:`M2 12h4`,key:`j09sii`}],[`path`,{d:`m4.9 4.9 2.9 2.9`,key:`giyufr`}]]),x=t(n(),1),S=e(),C={green:{color:`#22c55e`,bg:`rgba(34,197,94,0.10)`,label:`Healthy`},yellow:{color:`#eab308`,bg:`rgba(234,179,8,0.10)`,label:`Warning`},red:{color:`#ef4444`,bg:`rgba(239,68,68,0.10)`,label:`Critical`}};function w({status:e}){let t=C[e];return(0,S.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 py-0.5 rounded-full text-xs font-medium`,style:{color:t.color,backgroundColor:t.bg},"data-testid":`traffic-light-${e}`,children:[(0,S.jsx)(`span`,{className:`w-2 h-2 rounded-full`,style:{backgroundColor:t.color}}),t.label]})}function T(e){try{return g(new Date(e),{addSuffix:!0})}catch{return e}}function E({project:e,onClick:t}){let n=C[e.healthStatus];return(0,S.jsxs)(`button`,{type:`button`,onClick:t,className:`w-full text-left rounded-lg border border-border/40 bg-card/50 p-4 hover:bg-card/80 transition-colors`,style:{borderLeftWidth:3,borderLeftColor:n.color},"data-testid":`health-card`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-3`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium truncate`,children:e.projectName}),(0,S.jsx)(w,{status:e.healthStatus})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-2 text-xs`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,S.jsx)(p,{className:`w-3 h-3 flex-shrink-0`}),(0,S.jsx)(`span`,{children:`Success`}),(0,S.jsxs)(`span`,{className:`ml-auto font-mono text-foreground/80`,children:[(e.successRate24h*100).toFixed(0),`%`]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,S.jsx)(y,{className:`w-3 h-3 flex-shrink-0`}),(0,S.jsx)(`span`,{children:`Cost 24h`}),(0,S.jsxs)(`span`,{className:`ml-auto font-mono text-foreground/80`,children:[`$`,e.totalCost24h.toFixed(2)]})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,S.jsx)(b,{className:`w-3 h-3 flex-shrink-0`}),(0,S.jsx)(`span`,{children:`Pending`}),(0,S.jsx)(`span`,{className:`ml-auto font-mono text-foreground/80`,children:e.pendingJobsCount})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,S.jsx)(c,{className:`w-3 h-3 flex-shrink-0`}),(0,S.jsx)(`span`,{children:`Last OK`}),(0,S.jsx)(`span`,{className:`ml-auto font-mono text-foreground/80 truncate max-w-[80px]`,title:e.lastSuccessfulJobAt??`never`,children:e.lastSuccessfulJobAt?T(e.lastSuccessfulJobAt):`never`})]})]})]})}function D({projects:e,onSelectProject:t}){return e.length===0?(0,S.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-6 text-center`,children:(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No projects registered yet.`})}):(0,S.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 xl:grid-cols-4 gap-3`,"data-testid":`health-grid`,children:e.map(e=>(0,S.jsx)(E,{project:e,onClick:()=>t(e.projectId)},e.projectId))})}function O({data:e}){return(0,S.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{icon:(0,S.jsx)(u,{className:`w-4 h-4`}),label:`Projects`,value:e.totalCount.toString()},{icon:(0,S.jsx)(s,{className:`w-4 h-4 text-[#f1fa8c]`}),label:`Active Jobs`,value:e.activeJobs.toString()},{icon:(0,S.jsx)(m,{className:`w-4 h-4`}),label:`Jobs Today`,value:e.jobsToday.toString()},{icon:(0,S.jsx)(v,{className:`w-4 h-4 text-[#50fa7b]`}),label:`Healthy`,value:e.healthyCount.toString(),sub:`${e.warningCount} warning · ${e.criticalCount} critical`}].map(e=>(0,S.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground mb-2`,children:[e.icon,(0,S.jsx)(`p`,{className:`text-xs`,children:e.label})]}),(0,S.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),e.sub&&(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.label))})}function k({costToday:e,budget:t}){if(t==null)return null;let n=Math.min(e/t*100,100),r=n>=90?`#ff5555`:n>=60?`#f1fa8c`:`#50fa7b`;return(0,S.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 text-muted-foreground`,children:[(0,S.jsx)(y,{className:`w-4 h-4`}),(0,S.jsx)(`p`,{className:`text-xs`,children:`Daily Budget`})]}),(0,S.jsxs)(`p`,{className:`text-xs font-mono text-muted-foreground`,children:[n.toFixed(0),`%`]})]}),(0,S.jsxs)(`p`,{className:`text-xl font-semibold font-mono`,children:[`$`,e.toFixed(2),` `,(0,S.jsxs)(`span`,{className:`text-sm text-muted-foreground`,children:[`/ $`,t.toFixed(2)]})]}),(0,S.jsx)(`div`,{className:`mt-2 h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full transition-all`,style:{width:`${n}%`,backgroundColor:r}})})]})}function A({score:e}){return e>=60?(0,S.jsxs)(`span`,{className:`flex items-center gap-1 text-[#50fa7b] text-xs font-medium`,children:[(0,S.jsx)(v,{className:`w-3 h-3`}),e]}):e>=30?(0,S.jsxs)(`span`,{className:`flex items-center gap-1 text-[#f1fa8c] text-xs font-medium`,children:[(0,S.jsx)(o,{className:`w-3 h-3`}),e]}):(0,S.jsxs)(`span`,{className:`flex items-center gap-1 text-[#ff5555] text-xs font-medium`,children:[(0,S.jsx)(l,{className:`w-3 h-3`}),e]})}function j(e){return(0,S.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full flex-shrink-0`,style:{backgroundColor:_[e]??`hsl(225 27% 51%)`}})}function M(e){try{return g(new Date(e),{addSuffix:!0})}catch{return e}}function N({project:e,onSwitch:t}){return(0,S.jsxs)(`button`,{type:`button`,onClick:t,className:`w-full text-left rounded-lg border border-border/40 border-l-2 ${e.healthScore>=60?`border-l-[#50fa7b]/60`:e.healthScore>=30?`border-l-[#f1fa8c]/60`:`border-l-[#ff5555]/60`} bg-card/50 p-4 hover:bg-card/80 transition-colors group`,children:[(0,S.jsxs)(`div`,{className:`flex items-start justify-between gap-2 mb-3`,children:[(0,S.jsx)(`p`,{className:`text-sm font-medium truncate group-hover:text-foreground transition-colors`,children:e.projectName}),(0,S.jsx)(A,{score:e.healthScore})]}),(0,S.jsxs)(`div`,{className:`grid grid-cols-2 gap-x-4 gap-y-1.5 text-xs text-muted-foreground`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(m,{className:`w-3 h-3 flex-shrink-0`}),(0,S.jsx)(`span`,{children:e.activeJobs>0?(0,S.jsxs)(`span`,{className:`text-[#f1fa8c]`,children:[e.activeJobs,` running`]}):`idle`})]}),(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,S.jsx)(s,{className:`w-3 h-3 flex-shrink-0`}),(0,S.jsxs)(`span`,{children:[e.jobsToday,` today`]})]}),e.coveragePct!==null&&(0,S.jsxs)(`div`,{className:`flex items-center gap-1.5 col-span-2`,children:[(0,S.jsx)(`span`,{className:`text-muted-foreground/60`,children:`cov`}),(0,S.jsx)(`div`,{className:`flex-1 h-1 rounded-full bg-border/30 overflow-hidden`,children:(0,S.jsx)(`div`,{className:`h-full rounded-full`,style:{width:`${Math.min(100,e.coveragePct)}%`,backgroundColor:e.coveragePct>=70?`#50fa7b`:e.coveragePct>=50?`#f1fa8c`:`#ff5555`}})}),(0,S.jsxs)(`span`,{className:`font-mono text-foreground/70`,children:[e.coveragePct.toFixed(0),`%`]})]})]}),e.lastRunAt&&(0,S.jsxs)(`div`,{className:`mt-3 pt-2.5 border-t border-border/20 flex items-center gap-1.5 text-xs text-muted-foreground`,children:[e.lastRunStatus&&j(e.lastRunStatus),(0,S.jsx)(`span`,{className:`truncate font-mono text-[10px]`,children:e.lastRunCommand}),(0,S.jsxs)(`span`,{className:`flex-shrink-0 flex items-center gap-0.5 ml-auto`,children:[(0,S.jsx)(c,{className:`w-2.5 h-2.5`}),M(e.lastRunAt)]})]})]})}function P({projects:e,onSwitchProject:t}){return e.length===0?(0,S.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-6 text-center`,children:(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No projects registered yet.`})}):(0,S.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:e.map(e=>(0,S.jsx)(N,{project:e,onSwitch:()=>t(e.projectId)},e.projectId))})}function F({jobs:e}){return e.length===0?(0,S.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Recent Activity`}),(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:`No jobs yet across any project.`})]}):(0,S.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,S.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Recent Activity`}),(0,S.jsx)(`div`,{className:`space-y-2`,children:e.map(e=>(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[j(e.status),(0,S.jsx)(`span`,{className:`text-muted-foreground flex-shrink-0 max-w-[80px] truncate`,title:e.projectName,children:e.projectName}),(0,S.jsx)(`span`,{className:`flex-1 truncate font-mono text-foreground/80`,title:e.command,children:e.command}),(0,S.jsx)(`span`,{className:`text-muted-foreground flex-shrink-0`,children:M(e.started_at)})]},`${e.projectId}-${e.id}`))})]})}function I({results:e,onClear:t}){return e.total===0?(0,S.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:(0,S.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,S.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`No results for "`,e.query,`"`]}),(0,S.jsx)(`button`,{onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Clear search`,children:(0,S.jsx)(a,{className:`w-3.5 h-3.5`})})]})}):(0,S.jsxs)(`div`,{className:`space-y-3`,children:[(0,S.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,S.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.total,` result`,e.total===1?``:`s`,` for "`,e.query,`"`]}),(0,S.jsx)(`button`,{onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,"aria-label":`Clear search`,children:(0,S.jsx)(a,{className:`w-3.5 h-3.5`})})]}),e.groups.map(e=>(0,S.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-3`,children:[(0,S.jsx)(`p`,{className:`text-xs font-semibold text-foreground`,children:e.projectName}),e.jobs.length>0&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:`Jobs`}),(0,S.jsx)(`div`,{className:`space-y-1`,children:e.jobs.map(e=>(0,S.jsxs)(`div`,{className:`flex items-center gap-2 text-xs`,children:[j(e.status),(0,S.jsx)(`span`,{className:`font-mono truncate text-foreground/80`,children:e.command})]},e.id))})]}),e.proposals.length>0&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:`Proposals`}),(0,S.jsx)(`div`,{className:`space-y-1`,children:e.proposals.map(e=>(0,S.jsx)(`div`,{className:`text-xs truncate text-foreground/80`,children:e.idea},e.id))})]}),e.messages.length>0&&(0,S.jsxs)(`div`,{children:[(0,S.jsx)(`p`,{className:`text-xs text-muted-foreground mb-1.5`,children:`Chat messages`}),(0,S.jsx)(`div`,{className:`space-y-1`,children:e.messages.map(e=>(0,S.jsxs)(`div`,{className:`text-xs truncate text-foreground/60 italic`,children:[`"`,e.content.slice(0,100),e.content.length>100?`…`:``,`"`]},e.id))})]})]},e.projectId))]})}function L(){let{projects:e,setActiveProjectId:t}=i(),[n,r]=(0,x.useState)(null),[a,o]=(0,x.useState)(null),[s,c]=(0,x.useState)(``),[l,p]=(0,x.useState)(null),[m,g]=(0,x.useState)(!1),[_,v]=(0,x.useState)(!0),y=(0,x.useRef)(null),b=(0,x.useCallback)(async()=>{v(!0);try{let[e,t]=await Promise.all([fetch(`/api/hub/overview`),fetch(`/api/hub/health`)]);e.ok&&r(await e.json()),t.ok&&o(await t.json())}finally{v(!1)}},[]);(0,x.useEffect)(()=>{b()},[b]),(0,x.useEffect)(()=>{if(y.current&&clearTimeout(y.current),!s.trim()||s.trim().length<2){p(null);return}return y.current=setTimeout(async()=>{g(!0);try{let e=await fetch(`/api/hub/search?q=${encodeURIComponent(s.trim())}`);e.ok&&p(await e.json())}finally{g(!1)}},350),()=>{y.current&&clearTimeout(y.current)}},[s]);function C(){c(``),p(null)}function w(n){e.find(e=>e.id===n)&&t(n)}return(0,S.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,S.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,S.jsx)(u,{className:`w-4 h-4 text-muted-foreground`}),(0,S.jsx)(`h1`,{className:`text-sm font-semibold`,children:`Hub Overview`}),(0,S.jsx)(`div`,{className:`ml-auto`,children:(0,S.jsx)(h,{baseUrl:`/api/hub/export`,label:`Export All`})})]}),(0,S.jsxs)(`div`,{className:`relative`,children:[(0,S.jsx)(f,{className:`absolute left-3 top-1/2 -translate-y-1/2 w-3.5 h-3.5 text-muted-foreground pointer-events-none`}),(0,S.jsx)(`input`,{type:`search`,value:s,onChange:e=>c(e.target.value),placeholder:`Search across all projects: jobs, proposals, chat…`,className:`w-full h-9 pl-8 pr-4 rounded-lg border border-border/60 bg-card/50 text-xs placeholder:text-muted-foreground focus:outline-none focus:ring-1 focus:ring-ring transition-colors`}),m&&(0,S.jsx)(`div`,{className:`absolute right-3 top-1/2 -translate-y-1/2 w-3 h-3 border border-current border-t-transparent rounded-full animate-spin text-muted-foreground`})]}),l?(0,S.jsx)(I,{results:l,onClear:C}):(0,S.jsxs)(S.Fragment,{children:[_&&(0,S.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,S.jsx)(`div`,{className:`h-[76px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),!_&&n&&(0,S.jsx)(O,{data:n.aggregated}),!_&&n&&(0,S.jsx)(k,{costToday:n.aggregated.costToday,budget:n.aggregated.hubDailyBudgetUsd}),_&&(0,S.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-3`,children:Array.from({length:Math.max(2,e.length)}).map((e,t)=>(0,S.jsx)(`div`,{className:`h-[120px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),!_&&n&&(0,S.jsx)(P,{projects:n.projects,onSwitchProject:w}),!_&&a&&a.projects.length>0&&(0,S.jsxs)(`div`,{children:[(0,S.jsxs)(`div`,{className:`flex items-center gap-2 mb-3`,children:[(0,S.jsx)(d,{className:`w-4 h-4 text-muted-foreground`}),(0,S.jsx)(`h2`,{className:`text-sm font-medium`,children:`Project Health`}),(0,S.jsxs)(`span`,{className:`text-xs text-muted-foreground ml-auto`,children:[a.aggregated.greenCount,` healthy · `,a.aggregated.yellowCount,` warning · `,a.aggregated.redCount,` critical`]})]}),(0,S.jsx)(D,{projects:a.projects,onSelectProject:w})]}),_&&(0,S.jsx)(`div`,{className:`h-[120px] rounded-lg border border-border/40 bg-card/50 animate-pulse`}),_&&(0,S.jsx)(`div`,{className:`h-[180px] rounded-lg border border-border/40 bg-card/50 animate-pulse`}),!_&&n&&(0,S.jsx)(F,{jobs:n.recentJobs})]})]})})}export{L as default};
@@ -0,0 +1,18 @@
1
+ import{n as e,o as t,r as n,t as r}from"./createLucideIcon-j4o5em8U.js";import"./react-dom-CzrF8Nvy.js";import{a as i,n as a,r as o}from"./useHub-C2hzU_Gs.js";import{t as s}from"./utils-DSsSbmuB.js";import{n as c}from"./useSharedWebSocket-j0gqXR8o.js";import{A as l,B as u,G as d,I as f,J as p,K as m,L as h,O as g,T as _,W as v,Y as y,b,j as x,k as S,l as C,o as w,q as T,u as E,x as D,y as O,z as k}from"./index-CZaTispp.js";import{t as A}from"./lib-C4q71VYc.js";var j=r(`circle`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),M=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`}]]),N=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`}]]),P=t(n(),1),F=e();function I({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,F.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,F.jsxs)(`div`,{className:`flex items-center`,children:[(0,F.jsxs)(v,{children:[(0,F.jsx)(m,{asChild:!0,children:(0,F.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,F.jsx)(L,{state:i}),(0,F.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,F.jsxs)(d,{side:`bottom`,className:`max-w-[200px]`,children:[(0,F.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,F.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:n.description})]})]}),a!==null&&(0,F.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 L({state:e}){return(0,F.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,F.jsx)(x,{className:`w-6 h-6 text-blue-400 animate-spin`}),e===`done`&&(0,F.jsx)(h,{className:`w-6 h-6 text-emerald-400`}),e===`error`&&(0,F.jsx)(f,{className:`w-6 h-6 text-red-400`}),e===`idle`&&(0,F.jsx)(j,{className:`w-6 h-6 text-muted-foreground/20`})]})}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}){let[r,i]=(0,P.useState)(n),a=(0,P.useMemo)(()=>R(t),[t]),o=e.status===`completed`;return(0,F.jsxs)(`div`,{className:s(`mx-4 my-2 rounded-xl border`,o?`border-emerald-500/20 bg-emerald-500/5`:`border-red-500/20 bg-red-500/5`),children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>i(!r),className:`w-full flex items-center gap-3 px-4 py-3`,children:[o?(0,F.jsx)(h,{className:`w-4 h-4 text-emerald-400 shrink-0`}):(0,F.jsx)(f,{className:`w-4 h-4 text-red-400 shrink-0`}),(0,F.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:o?`Job completed`:`Job failed`}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[e.duration_ms!=null&&(0,F.jsxs)(`span`,{className:`tabular-nums`,children:[(e.duration_ms/1e3).toFixed(1),`s`]}),e.total_cost_usd!=null&&(0,F.jsxs)(`span`,{className:`tabular-nums text-yellow-400`,children:[`$`,e.total_cost_usd.toFixed(4)]}),a.length>0&&(0,F.jsxs)(`span`,{children:[a.length,` file`,a.length===1?``:`s`]})]}),(0,F.jsx)(u,{className:s(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,r&&`rotate-180`)})]}),r&&(0,F.jsxs)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:[(0,F.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2 pt-3`,children:[(0,F.jsx)(B,{label:`Duration`,value:e.duration_ms==null?`—`:`${(e.duration_ms/1e3).toFixed(1)}s`}),(0,F.jsx)(B,{label:`Cost`,value:e.total_cost_usd==null?`—`:`$${e.total_cost_usd.toFixed(4)}`,valueClass:`text-yellow-400`}),(0,F.jsx)(B,{label:`Turns`,value:e.num_turns==null?`—`:`${e.num_turns}`}),(0,F.jsx)(B,{label:`Tokens`,value:e.tokens_in==null?`—`:`${(((e.tokens_in??0)+(e.tokens_out??0))/1e3).toFixed(1)}k`})]}),a.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:`Files modified`}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:a.map(e=>(0,F.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,F.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,F.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,P.useState)(``),[a,o]=(0,P.useState)(!0),[s,c]=(0,P.useState)(new Set),l=(0,P.useRef)(null),d=(0,P.useRef)(null),f=e.map((e,t)=>H(e,t)).filter(e=>e!==null),p=[];for(let e of f){let t=p.length>0?p[p.length-1]:null;e.type===`assistant`&&t?.type===`assistant`?t.content+=`
2
+ `+e.content:p.push({...e})}let m=U(p),h=W(m),v=m.length,y=n?m.filter(e=>e.content.toLowerCase().includes(n.toLowerCase())).length:v,b=(0,P.useCallback)(()=>{l.current?.scrollIntoView({behavior:`smooth`})},[]);(0,P.useEffect)(()=>{a&&b()},[e.length,a,b]);function x(){let e=d.current;e&&o(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function S(e){c(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading logs...`})}):v===0?(0,F.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No log output yet`})}):(0,F.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,F.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,F.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,F.jsx)(g,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,F.jsx)(w,{placeholder:`Filter logs...`,value:n,onChange:e=>r(e.target.value),className:`pl-7 h-7`})]}),(0,F.jsx)(_,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=m.map(e=>e.content).join(`
3
+ `);navigator.clipboard.writeText(e).then(()=>{i.success(`Log copied to clipboard`)}).catch(()=>{i.error(`Failed to copy log`)})},children:(0,F.jsx)(M,{className:`w-3.5 h-3.5`})}),(0,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[y,` / `,v,` lines`]})]}),(0,F.jsxs)(`div`,{ref:d,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:x,children:[h.map(e=>(0,F.jsx)(K,{group:e,filter:n,collapsed:s.has(e.key),onToggle:()=>S(e.key)},e.key)),(0,F.jsx)(`div`,{ref:l})]}),!a&&(0,F.jsxs)(_,{size:`sm`,variant:`secondary`,onClick:()=>{o(!0),b()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,F.jsx)(u,{className:`w-3 h-3`}),`Jump to bottom`]})]})}var K=(0,P.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,F.jsx)(`div`,{children:i.map((e,t)=>(0,F.jsx)(J,{line:e,even:t%2==0},e.id))});let a=e.header.content;return(0,F.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,F.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,F.jsx)(k,{className:s(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,F.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:a}),e.header.timestamp&&(0,F.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,F.jsxs)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:[e.lines.length,` lines`]})]}),!n&&(0,F.jsx)(`div`,{className:`bg-muted/5`,children:i.length===0?(0,F.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,F.jsx)(J,{line:e,even:t%2==0},e.id))})]})}),q=[A],J=(0,P.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,F.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,F.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,F.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
4
+ prose-p:my-1 prose-p:leading-relaxed
5
+ prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold
6
+ prose-ul:my-1 prose-ol:my-1 prose-li:my-0
7
+ prose-code:text-cyan-300 prose-code:text-[11px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded
8
+ prose-pre:my-1 prose-pre:bg-muted/30 prose-pre:rounded-md prose-pre:p-2 prose-pre:text-[11px]
9
+ prose-strong:text-foreground prose-em:text-foreground/70
10
+ prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline
11
+ prose-table:my-2 prose-table:text-[11px]
12
+ prose-thead:border-border prose-thead:bg-muted/30
13
+ prose-th:px-3 prose-th:py-1.5 prose-th:text-left prose-th:font-semibold prose-th:text-foreground/90
14
+ prose-td:px-3 prose-td:py-1.5 prose-td:border-border
15
+ prose-tr:border-border
16
+ text-foreground/80`,children:(0,F.jsx)(D,{remarkPlugins:[b],rehypePlugins:q,children:e.content})}):(0,F.jsx)(`span`,{className:s(`flex-1 break-all leading-relaxed whitespace-pre-wrap font-mono`,e.type===`tool-use`&&`text-cyan-400/80 text-[11px]`,e.type===`stderr`&&`text-orange-400`,e.type===`result`&&`text-emerald-400 font-medium`,e.type===`log`&&`text-foreground/60`,e.type===`plain`&&`text-foreground/70`,e.type===`tool-result`&&`text-muted-foreground/50`,r&&`text-emerald-400`,i&&`text-red-400`,a&&`text-dracula-purple/80`,o&&`text-dracula-cyan/80`),children:e.content})]})}),Y={running:{variant:`running`,label:`running`,tooltip:`Job is actively executing`},completed:{variant:`success`,label:`completed`,tooltip:`Job completed successfully`},failed:{variant:`failed`,label:`failed`,tooltip:`Job exited with a non-zero code`},canceled:{variant:`canceled`,label:`canceled`,tooltip:`Job was manually canceled`},queued:{variant:`queued`,label:`queued`,tooltip:`Job is waiting in the queue`}};function X(e,t){let n=e.status,r=e.duration_ms==null?`unknown`:`${(e.duration_ms/1e3).toFixed(1)}s`,i=e.total_cost_usd==null?`unknown`:`$${e.total_cost_usd.toFixed(4)}`,a=e.model??`unknown`,o=e.tokens_in==null?null:`${e.tokens_in} in / ${e.tokens_out??0} out`,s=[];for(let e of t)if(e.event_type===`log`)try{let t=JSON.parse(e.payload);t.line&&s.push(t.line)}catch{}let c=s.slice(-150).join(`
17
+ `);return`Please explain this SpecRails job:\n\n**Command:** \`${e.command}\`\n**Status:** ${n}\n**Duration:** ${r}\n**Cost:** ${i}\n**Model:** ${a}\n`+(o?`**Tokens:** ${o}\n`:``)+(c?`\n**Log output (last 150 lines):**\n\`\`\`\n${c}\n\`\`\`\n`:``)+`
18
+ What happened in this job? Were there any errors or notable events? What did Claude accomplish?`}function Z(){let{id:e}=y(),{activeProjectId:t}=a(),n=p(),r=O(),[s,u]=(0,P.useState)(null),[f,h]=(0,P.useState)([]),[g,b]=(0,P.useState)([]),[x,w]=(0,P.useState)({}),[D,A]=(0,P.useState)(!0),[j,M]=(0,P.useState)(!1);(0,P.useEffect)(()=>{if(!e)return;let t=new AbortController;u(null),h([]),b([]),w({}),A(!0),M(!1);async function n(){try{let n=await fetch(`${o()}/jobs/${e}`,{signal:t.signal});if(n.status===404){M(!0);return}if(!n.ok)throw Error(`Failed to fetch job`);let r=await n.json();u(r.job),h(r.events)}catch(e){if(e.name===`AbortError`)return;M(!0)}finally{t.signal.aborted||A(!1)}}return n(),()=>t.abort()},[e,t]);let L=(0,P.useRef)(t);L.current=t;let R=(0,P.useCallback)(t=>{let n=t;if(!(L.current&&n.projectId&&n.projectId!==L.current)){if(n.type===`init`){let e=n.phaseDefinitions??[];b(e);let t={};for(let r of e)t[r.key]=n.phases?.[r.key]??`idle`;w(t)}else if(n.type===`log`&&n.processId===e){let t={id:Date.now(),job_id:e??``,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};h(e=>{let n=[...e,t];return n.length>1e4?n.slice(n.length-8e3):n})}else if(n.type===`phase`){let e=n.phase,t=n.state;w(n=>({...n,[e]:t}))}else if(n.type===`queue`){let t=n.jobs?.find(t=>t.id===e);t&&u(e=>e&&{...e,status:t.status})}}},[e]),{registerHandler:B,unregisterHandler:V}=c();(0,P.useEffect)(()=>(B(`job-detail-${e}`,R),()=>V(`job-detail-${e}`)),[e,R,B,V]);async function H(){if(e)try{let t=await fetch(`${o()}/jobs/${e}`,{method:`DELETE`});if(t.ok)i.success(`Cancel signal sent`,{description:`Job will stop at the next safe point`});else{let e=await t.json();i.error(`Failed to cancel`,{description:e.error})}}catch{i.error(`Network error`)}}async function U(){if(!s||!r)return;let e=X(s,f);r.isPanelOpen||r.togglePanel(),await r.startWithMessage(e)}async function W(){if(s)try{let e=await fetch(`${o()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:s.command})}),t=await e.json();if(!e.ok)throw Error(t.error??`Failed to spawn job`);i.success(`Job re-queued`),n(`/jobs/${t.jobId}`)}catch(e){i.error(e.message)}}if(D)return(0,F.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,F.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,F.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(j||!s)return(0,F.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,F.jsx)(`p`,{className:`text-lg font-semibold`,children:`Job not found`}),(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`The job ID "`,e,`" doesn't exist`]}),(0,F.jsx)(_,{asChild:!0,variant:`outline`,size:`sm`,children:(0,F.jsxs)(T,{to:`/`,children:[(0,F.jsx)(N,{className:`w-3.5 h-3.5 mr-1.5`}),`Back to Dashboard`]})})]});let K=Y[s.status]??Y.queued,q=s.status===`running`,J=s.status===`completed`||s.status===`failed`;return(0,F.jsxs)(`div`,{className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,F.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,F.jsxs)(T,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,F.jsx)(N,{className:`w-3 h-3`}),`Dashboard`]}),(0,F.jsx)(k,{className:`w-3 h-3`}),(0,F.jsxs)(`span`,{className:`text-foreground font-mono`,children:[`Job #`,e?.slice(0,8)]})]}),(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsxs)(v,{children:[(0,F.jsx)(m,{asChild:!0,children:(0,F.jsx)(`div`,{children:(0,F.jsx)(C,{variant:K.variant,children:K.label})})}),(0,F.jsx)(d,{children:K.tooltip})]}),(0,F.jsx)(`code`,{className:`text-sm font-mono text-foreground/90 truncate`,children:s.command})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,F.jsxs)(`span`,{children:[`Started `,E(new Date(s.started_at),{addSuffix:!0})]}),s.model&&(0,F.jsx)(`span`,{className:`text-muted-foreground/40`,children:s.model})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[J&&r&&(0,F.jsxs)(v,{children:[(0,F.jsx)(m,{asChild:!0,children:(0,F.jsxs)(_,{variant:`outline`,size:`sm`,onClick:U,className:`h-7`,children:[(0,F.jsx)(l,{className:`w-3.5 h-3.5 mr-1.5`}),`Explain this job`]})}),(0,F.jsx)(d,{children:`Ask Claude to explain what happened in this job`})]}),J&&(0,F.jsxs)(v,{children:[(0,F.jsx)(m,{asChild:!0,children:(0,F.jsxs)(_,{variant:`outline`,size:`sm`,onClick:W,className:`h-7`,children:[(0,F.jsx)(S,{className:`w-3.5 h-3.5 mr-1.5`}),`Re-execute`]})}),(0,F.jsx)(d,{children:`Spawn a new job with the same command`})]}),q&&(0,F.jsxs)(v,{children:[(0,F.jsx)(m,{asChild:!0,children:(0,F.jsx)(_,{variant:`outline`,size:`sm`,onClick:H,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:`Cancel Job`})}),(0,F.jsx)(d,{children:`Send SIGTERM to the running process. The job will be marked as canceled.`})]})]})]}),(0,F.jsx)(I,{phases:x,phaseDefinitions:g})]}),(s.status===`completed`||s.status===`failed`)&&(0,F.jsx)(z,{job:s,events:f,defaultOpen:s.status===`completed`}),(0,F.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:(0,F.jsx)(G,{events:f})})]})}export{Z as default};