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