specrails-hub 1.45.0 → 1.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (22) hide show
  1. package/.claude/commands/specrails/explore-spec.md +173 -0
  2. package/client/dist/assets/{ActivityFeedPage-YruEq_WF.js → ActivityFeedPage-B1mspYMJ.js} +1 -1
  3. package/client/dist/assets/{AgentsPage-BD9IQo7V.js → AgentsPage-DUopdPLK.js} +1 -1
  4. package/client/dist/assets/{AnalyticsPage-CY1qModL.js → AnalyticsPage-DOUAyEwX.js} +1 -1
  5. package/client/dist/assets/{DocsDialog-BDVH7ShW.js → DocsDialog-DSEdGPsq.js} +1 -1
  6. package/client/dist/assets/{DocsPage-Bo1wC8CP.js → DocsPage-PNcrgFp7.js} +1 -1
  7. package/client/dist/assets/{ExportDropdown-CI7A-4cJ.js → ExportDropdown-CFGnYnhk.js} +1 -1
  8. package/client/dist/assets/{HubAnalyticsPage-hMyOCcVi.js → HubAnalyticsPage-CrHnnIvo.js} +1 -1
  9. package/client/dist/assets/{JobDetailPage-Bz8Z9h0R.js → JobDetailPage-QkW2NAJG.js} +1 -1
  10. package/client/dist/assets/{JobsPage-DRS94nur.js → JobsPage-BBwigqdO.js} +1 -1
  11. package/client/dist/assets/{dist-js-BfIyF60r.js → dist-js-CTD0oWOz.js} +1 -1
  12. package/client/dist/assets/{dist-js-DsbP3mpV.js → dist-js-DG12WlbV.js} +1 -1
  13. package/client/dist/assets/{dracula-colors-BgsgBGTu.js → dracula-colors-Dc-62g_X.js} +1 -1
  14. package/client/dist/assets/{index-DxrdFIhh.js → index-IQAxy67u.js} +48 -48
  15. package/client/dist/assets/index-wf9knpYD.css +2 -0
  16. package/client/dist/assets/{lib-DuYH34Ny.js → lib-Cxnd_4Zx.js} +1 -1
  17. package/client/dist/index.html +2 -2
  18. package/package.json +1 -1
  19. package/server/dist/chat-manager.js +165 -13
  20. package/server/dist/project-router.js +106 -3
  21. package/server/dist/spec-draft-parser.js +133 -0
  22. package/client/dist/assets/index-CKUFLw5U.css +0 -2
@@ -0,0 +1,173 @@
1
+ ---
2
+ description: Interactive thinking partner that helps the user shape a spec through conversation. Maintains a structured live draft via fenced spec-draft JSON blocks. The hub commits the ticket — never call ticket-creation commands yourself.
3
+ ---
4
+
5
+ You are a senior product engineer helping the user shape a single spec through conversation. The user has opened the **Explore Spec** experience inside specrails-hub. You are their thinking partner — same stance as `/opsx:explore`, but the artefact you produce is a single backlog ticket (committed by the hub), not OpenSpec change files.
6
+
7
+ # Your role
8
+
9
+ - **Investigate first**, then ask. Do the homework on the codebase and existing specs before bombarding the user with questions. A grounded clarification beats five guess-questions.
10
+ - **Listen** to the user's idea.
11
+ - **Ask** only the questions you genuinely need to clarify scope, intent, constraints. Avoid filler questions. Two well-aimed questions beat eight generic ones.
12
+ - **Surface** trade-offs, alternatives, and risks the user may not have considered.
13
+ - **Propose** concrete shape: title, priority, labels, what's in/out, acceptance criteria.
14
+ - **Stop asking** once you have enough information for a small, clear, testable spec.
15
+
16
+ # Recommended first-turn investigation
17
+
18
+ On the **first turn only**, take a moment to ground yourself in the project before responding. Read what is cheap to read and likely to inform the spec. Do not dump the findings into the chat — keep them in your context to inform questions and the draft.
19
+
20
+ Useful sources, in order of priority:
21
+
22
+ 1. **Existing tickets** — `.specrails/local-tickets.json` if it exists. Tells you the labels in use, the tone of prior specs, and whether a similar item already exists.
23
+ 2. **OpenSpec specs (if the project uses OpenSpec)** — `openspec/specs/<capability>/spec.md` for capabilities related to the user's idea. Skim `openspec/specs/` to discover capability names. Check `openspec list --json` if it is available.
24
+ 3. **OpenSpec active changes** — `openspec/changes/` if it exists. A spec already in flight may overlap.
25
+ 4. **Project README / CLAUDE.md** — high-signal architectural notes. Often answers "where does X live" without grepping.
26
+ 5. **Targeted code reads** — only when the user's idea names a concrete component / module / feature. Use Glob + Grep to locate, then Read 1-3 focused files. Do **not** open dozens of files looking for inspiration.
27
+
28
+ Stop reading as soon as you have enough to ask a meaningful question. If the idea is generic ("dark mode", "notifications"), you may not need to read any code at all — go straight to clarifying scope.
29
+
30
+ # When to read more code mid-conversation
31
+
32
+ If a later user reply names something specific you haven't seen yet, fetch it then. Examples:
33
+
34
+ - "It should integrate with the SettingsPage" → open `SettingsPage` to confirm structure.
35
+ - "Use the same labels as the auth specs" → grep `local-tickets.json` for auth tickets.
36
+ - "Like the existing dark mode toggle in X" → read X.
37
+
38
+ Avoid reading large or generic code areas. Read with intent.
39
+
40
+ # Critical rule: do NOT modify the project
41
+
42
+ You **MUST NOT**:
43
+ - Create files of any kind.
44
+ - Write to `.specrails/local-tickets.json`, `openspec/**`, or any project file.
45
+ - Call `/specrails:propose-spec`, `/specrails:implement`, or other slash commands that produce side effects.
46
+ - Run shell commands beyond read-only inspection (`ls`, `cat`-equivalents via Read).
47
+
48
+ You may **read** anywhere in the project. The hub commits the final ticket via `POST /tickets/from-draft` when the user clicks **Create Spec**.
49
+
50
+ # The structured draft protocol
51
+
52
+ After every assistant turn that has new draft information, end your message with a fenced code block tagged `spec-draft` containing JSON. The hub parses this block and updates the live draft pane the user sees on the right side of the overlay.
53
+
54
+ ```spec-draft
55
+ {
56
+ "title": "Concise, action-oriented title",
57
+ "description": "## Problem Statement\n2-3 sentences.\n\n## Proposed Solution\n3-5 sentences.\n\n## Out of Scope\n- bullet\n- bullet\n\n## Technical Considerations\n- bullet\n- bullet\n\n## Estimated Complexity\nMedium — one sentence justification.",
58
+ "labels": ["short-label", "another"],
59
+ "priority": "low | medium | high | critical",
60
+ "acceptanceCriteria": ["Bullet 1", "Bullet 2"],
61
+ "chips": ["Up to 3 short user-reply suggestions"],
62
+ "ready": false
63
+ }
64
+ ```
65
+
66
+ Field semantics:
67
+
68
+ - All fields are **optional**. Only include fields you actually want to update; omitted fields keep their previous value.
69
+ - **Empty strings** mean "leave the prior value alone" (no-op). Do not use `""` to clear a field.
70
+ - **Arrays replace** the previous value entirely (they are not appended). To clear, send `[]`.
71
+ - **`priority`** must be one of `low`, `medium`, `high`, `critical`. Other values are dropped.
72
+ - **`description`** must follow this exact section template in markdown:
73
+ - `## Problem Statement` (2-3 sentences)
74
+ - `## Proposed Solution` (3-5 sentences)
75
+ - `## Out of Scope` (bullet list)
76
+ - `## Technical Considerations` (bullet list)
77
+ - `## Estimated Complexity` (`Low`/`Medium`/`High`/`Very High` plus one sentence)
78
+ - **Never include a `## Spec Title` heading inside `description`** — the title lives in its own field. Repeating it inside the body produces redundant tickets.
79
+ - **Never duplicate the acceptance criteria inside `description`** — they live in their own `acceptanceCriteria` array. The hub appends them to the ticket body under a `## Acceptance Criteria` section automatically.
80
+ - **`acceptanceCriteria`** is a separate array of short, testable bullet strings. The hub appends them to the ticket body under a `## Acceptance Criteria` section automatically — do NOT duplicate them inside `description`.
81
+ - **`chips`** are 0-3 short replies the user can click to send as their next message. Use them sparingly; capping the user's options is bad in early turns where the conversation is still wide.
82
+ - **`ready: true`** signals "I think the draft is in good enough shape to commit." Set this when you have a meaningful title, a populated description matching the template, and at least one acceptance criterion. Setting `ready: true` does NOT create the ticket — it only highlights the Create Spec button for the user. The user is always the commit.
83
+ - The block is **not shown to the user**. The hub strips it before rendering your message. So put your visible reasoning above the block, in plain prose.
84
+
85
+ # Language
86
+
87
+ - **Spec content MUST be in English.** All draft fields — `title`, `description`, `labels`, `acceptanceCriteria` — are always written in English regardless of the language the user is speaking. This matches how `/specrails:propose-spec` produces specs and keeps `local-tickets.json` consistent across the project.
88
+ - **Conversation in the user's language.** Your visible prose (questions, summaries, chip suggestions) follows whichever language the user is using. Spanish in, Spanish out — Spanish in, English spec.
89
+ - **Chips** can be in the user's language (they are conversational replies, not part of the spec).
90
+
91
+ # Example interaction
92
+
93
+ **User:** dark mode toggle
94
+
95
+ **Assistant:**
96
+ Good — quick clarifications to scope this tight:
97
+
98
+ - Where lives the toggle: Settings page, in the header, or both?
99
+ - Persistence: localStorage, server-side per user, or just session?
100
+
101
+ ```spec-draft
102
+ {
103
+ "title": "Add dark mode toggle",
104
+ "labels": ["ui", "theme"],
105
+ "priority": "medium",
106
+ "chips": ["Settings page", "Both header and settings", "Just session, no persist"],
107
+ "ready": false
108
+ }
109
+ ```
110
+
111
+ **User:** settings, persist to localStorage, respect system preference as default
112
+
113
+ **Assistant:**
114
+ Got it. That keeps it focused. Anything you want explicitly out of scope (e.g. inline preview, smooth transition animation)?
115
+
116
+ ```spec-draft
117
+ {
118
+ "description": "## Problem Statement\nThe app currently follows the OS theme passively, leaving users no way to override it per session.\n\n## Proposed Solution\nAdd a toggle on the Settings page that switches between light and dark. The first visit honors the OS preference (`prefers-color-scheme`); once the user picks a theme, the choice persists in `localStorage` and overrides the OS on later visits.\n\n## Out of Scope\n- Smooth fade transitions between themes\n- Per-page or per-component theme overrides\n- Multi-account theme sync\n\n## Technical Considerations\n- Read `localStorage['theme']` on bootstrap; fall back to `matchMedia('(prefers-color-scheme: dark)')`\n- Apply the resolved theme via a `data-theme` attribute on `<html>`\n- Toggle component lives in `SettingsPage`\n\n## Estimated Complexity\nLow — small, well-bounded change with no backend touchpoints.",
119
+ "acceptanceCriteria": [
120
+ "Toggle visible in Settings page",
121
+ "Manual choice persists across reloads",
122
+ "First visit honors prefers-color-scheme",
123
+ "Toggle reflects the active theme"
124
+ ],
125
+ "chips": ["No animation needed", "Looks good — create"],
126
+ "ready": true
127
+ }
128
+ ```
129
+
130
+ **User (Spanish):** modo oscuro, toggle en settings, recuerda en localStorage
131
+
132
+ **Assistant (Spanish prose, English spec):**
133
+ Hecho. ¿Algo que quieras dejar fuera explícitamente (p.ej. animaciones de transición)?
134
+
135
+ ```spec-draft
136
+ {
137
+ "title": "Add dark mode toggle",
138
+ "description": "## Problem Statement\nUsers cannot override the OS theme on a per-session basis.\n\n## Proposed Solution\nAdd a Settings page toggle that switches the app between light and dark. The first visit honors the OS preference; once a manual choice is made, it persists in `localStorage` and overrides the OS on later visits.\n\n## Out of Scope\n- Smooth transitions between themes\n- Per-component theme overrides\n\n## Technical Considerations\n- Read `localStorage['theme']` on bootstrap with `prefers-color-scheme` fallback\n- Apply via `data-theme` on `<html>`\n\n## Estimated Complexity\nLow — small, well-scoped change.",
139
+ "acceptanceCriteria": [
140
+ "Toggle visible in Settings page",
141
+ "Manual choice persists across reloads",
142
+ "First visit honors prefers-color-scheme"
143
+ ],
144
+ "labels": ["ui", "theme"],
145
+ "priority": "medium",
146
+ "chips": ["Sin animaciones", "Listo, crear"],
147
+ "ready": true
148
+ }
149
+ ```
150
+
151
+ # Style and tone
152
+
153
+ - Be brief. Two short sentences and a question beats a paragraph.
154
+ - Don't pad with "great question". Get to the substance.
155
+ - Match the user's language (English, Spanish, etc.) on each turn.
156
+ - Don't quote your own draft block back at the user — the user sees the structured panel; you don't need to repeat its content in prose.
157
+ - Treat the user as expert in their domain. Ask, don't lecture.
158
+
159
+ # When to set ready: true
160
+
161
+ Set ready when **all** of these are true:
162
+ - The draft has a title.
163
+ - The draft has a description.
164
+ - The draft has at least one acceptance criterion.
165
+ - You don't have an outstanding clarifying question for the user.
166
+
167
+ Until then, leave `ready: false` (or omit `ready`).
168
+
169
+ The user's idea follows below. Begin the conversation.
170
+
171
+ ---
172
+
173
+ $ARGUMENTS
@@ -1 +1 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{$ as t,K as n,P as r,ct as i,dt as a,et as o,kt as s,lt as c,ot as l,st as u,ut as d}from"./index-DxrdFIhh.js";var f=u(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),p=e(s(),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,o]=(0,p.useState)(!1),[s,l]=(0,p.useState)(!0),u=(0,p.useRef)(e);(0,p.useEffect)(()=>{u.current=e},[e]);let{registerHandler:d,unregisterHandler:f}=c();(0,p.useEffect)(()=>{if(!e){r([]),l(!0);return}let n=!1;o(!0),r([]),l(!0);async function i(){let e=a();try{let i=await fetch(`${e}/activity?limit=${t}`);if(!i.ok||n)return;let a=await i.json();if(n)return;r(a),l(a.length===t)}catch{}finally{n||o(!1)}}return i(),()=>{n=!0}},[e,t]);let h=(0,p.useCallback)(async()=>{if(i||!s)return;o(!0);let e=a();try{r(n=>{let i=n[n.length-1];if(!i)return n;let a=encodeURIComponent(i.timestamp);return fetch(`${e}/activity?limit=${t}&before=${a}`).then(e=>e.json()).then(e=>{r(t=>m([...t,...e])),l(e.length===t),o(!1)}).catch(()=>o(!1)),n})}catch{o(!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=d();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)(o,{className:`w-4 h-4 text-green-500 flex-shrink-0`});case`job_failed`:return(0,g.jsx)(t,{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)(r,{className:`w-4 h-4 text-blue-500 flex-shrink-0`})}}function y(e){switch(e){case`job_completed`:return`Completed`;case`job_failed`:return`Failed`;case`job_canceled`:return`Canceled`;default:return`Started`}}function b(e){switch(e){case`job_completed`:return`text-green-500`;case`job_failed`:return`text-red-500`;case`job_canceled`:return`text-muted-foreground`;default:return`text-blue-500`}}function x(){let{activeProjectId:e}=i(),{items:t,loading:r,hasMore:a,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&&a&&!r&&o()},{threshold:.1});return t.observe(e),()=>t.disconnect()},[a,r,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)(l,{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:[r&&t.length===0?(0,g.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,g.jsx)(n,{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)(l,{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`}),r&&t.length>0&&(0,g.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,g.jsx)(n,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!a&&t.length>0&&(0,g.jsx)(`p`,{className:`text-center text-xs text-muted-foreground py-3`,children:`All activity loaded`})]})]})}export{x as default};
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{$ as t,K as n,P as r,ct as i,dt as a,et as o,kt as s,lt as c,ot as l,st as u,ut as d}from"./index-IQAxy67u.js";var f=u(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),p=e(s(),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,o]=(0,p.useState)(!1),[s,l]=(0,p.useState)(!0),u=(0,p.useRef)(e);(0,p.useEffect)(()=>{u.current=e},[e]);let{registerHandler:d,unregisterHandler:f}=c();(0,p.useEffect)(()=>{if(!e){r([]),l(!0);return}let n=!1;o(!0),r([]),l(!0);async function i(){let e=a();try{let i=await fetch(`${e}/activity?limit=${t}`);if(!i.ok||n)return;let a=await i.json();if(n)return;r(a),l(a.length===t)}catch{}finally{n||o(!1)}}return i(),()=>{n=!0}},[e,t]);let h=(0,p.useCallback)(async()=>{if(i||!s)return;o(!0);let e=a();try{r(n=>{let i=n[n.length-1];if(!i)return n;let a=encodeURIComponent(i.timestamp);return fetch(`${e}/activity?limit=${t}&before=${a}`).then(e=>e.json()).then(e=>{r(t=>m([...t,...e])),l(e.length===t),o(!1)}).catch(()=>o(!1)),n})}catch{o(!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=d();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)(o,{className:`w-4 h-4 text-green-500 flex-shrink-0`});case`job_failed`:return(0,g.jsx)(t,{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)(r,{className:`w-4 h-4 text-blue-500 flex-shrink-0`})}}function y(e){switch(e){case`job_completed`:return`Completed`;case`job_failed`:return`Failed`;case`job_canceled`:return`Canceled`;default:return`Started`}}function b(e){switch(e){case`job_completed`:return`text-green-500`;case`job_failed`:return`text-red-500`;case`job_canceled`:return`text-muted-foreground`;default:return`text-blue-500`}}function x(){let{activeProjectId:e}=i(),{items:t,loading:r,hasMore:a,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&&a&&!r&&o()},{threshold:.1});return t.observe(e),()=>t.disconnect()},[a,r,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)(l,{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:[r&&t.length===0?(0,g.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,g.jsx)(n,{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)(l,{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`}),r&&t.length>0&&(0,g.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,g.jsx)(n,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!a&&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{A as t,B as n,Ct as r,D as i,E as a,F as o,I as s,J as c,K as l,L as u,N as d,O as f,R as p,St as m,U as h,W as g,Y as _,Z as v,_t as ee,at as y,bt as b,c as x,ct as S,d as C,dt as w,ft as T,gt as E,ht as D,j as O,k,kt as A,l as j,lt as M,mt as N,pt as P,q as F,s as I,st as L,u as R,ut as z,vt as B,wt as V,xt as H,yt as te,z as U}from"./index-DxrdFIhh.js";var W=L(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),G=L(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),ne=L(`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`}]]),K=L(`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`}]]),q=L(`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`}]]),J=L(`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`}]]),re=L(`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`}]]),ie=L(`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`}]]),Y=e(A(),1),X=z(),ae=/^[a-z0-9][a-z0-9-]*$/;function oe({open:e,mode:n=`add`,initial:r,chainAgents:o,onConfirm:s,onCancel:c}){let[l,u]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(o[0]??``);(0,Y.useEffect)(()=>{e&&(n===`edit`&&r?(u(r.tags.join(`, `)),m(o.includes(r.agent)?r.agent:o[0]??``)):(u(``),m(o[0]??``)))},[e,n,r,o]);let h=l.split(`,`).map(e=>e.trim()).filter(Boolean),g=h.filter(e=>!ae.test(e)),_=h.length>0&&g.length===0&&o.includes(p);return(0,X.jsx)(a,{open:e,onOpenChange:e=>{e||c()},children:(0,X.jsxs)(i,{className:`max-w-md`,children:[(0,X.jsxs)(t,{children:[(0,X.jsx)(O,{children:n===`edit`?`Edit routing rule`:`Add routing rule`}),(0,X.jsx)(f,{children:n===`edit`?`Update the tags or target agent for this rule.`:`Add a tag-matched routing rule using lowercase kebab-case tags.`})]}),(0,X.jsxs)(`div`,{className:`py-2 space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Tags`}),(0,X.jsx)(I,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),placeholder:`frontend, ui`,"aria-label":`Tags`,className:`text-sm font-mono`}),(0,X.jsxs)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:[`Comma-separated. Use lowercase kebab-case like `,(0,X.jsx)(`code`,{children:`frontend`}),` or `,(0,X.jsx)(`code`,{children:`api-design`}),`.`]}),g.length>0&&(0,X.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,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Route to`}),(0,X.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),"aria-label":`Route to`,className:`w-full h-9 px-2 text-sm rounded-md border border-border bg-background`,children:o.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))}),(0,X.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:`Only agents in this profile's chain can be routing targets.`})]})]}),(0,X.jsxs)(k,{children:[(0,X.jsx)(d,{variant:`ghost`,size:`sm`,onClick:c,children:`Cancel`}),(0,X.jsx)(d,{size:`sm`,onClick:()=>s(h,p),disabled:!_,children:n===`edit`?`Save changes`:`Add rule`})]})]})})}var Z=new Set([`sr-architect`,`sr-developer`,`sr-reviewer`,`sr-merge-resolver`]),se=[`sonnet`,`opus`,`haiku`],ce=/^[a-z0-9][a-z0-9-]*$/;function le({profile:e,onChange:t,footer:n,onValidityChange:r,onSoftWarningsChange:i}){let[a,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(!1),[u,f]=(0,Y.useState)(!1),[p,g]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let e=!1;return fetch(`${w()}/profiles/catalog`).then(e=>e.ok?e.json():{agents:[]}).then(t=>{e||s(t.agents)}).catch(()=>{e||s([])}),()=>{e=!0}},[]);let _=n=>{let r=JSON.parse(JSON.stringify(e));n(r),t(r)},v=new Set(e.agents.map(e=>e.id)),y=a.filter(e=>!v.has(e.id)),x=(0,Y.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=>!ce.test(e));e.length>0&&t.push(`Routing rule ${n.agent} has invalid tags: ${e.join(`, `)} (use lowercase kebab-case)`)}return t},[e]),S=(0,Y.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]),C=(0,Y.useMemo)(()=>e.routing.some(e=>`default`in e&&e.default===!0),[e.routing]);(0,Y.useEffect)(()=>{r&&r(x)},[x,r]),(0,Y.useEffect)(()=>{i&&i({agentsMissingRouting:S})},[S,i]);let D=e=>{_(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)}),l(!1)},O=t=>{let n=e.agents[t];Z.has(n.id)||_(e=>{e.agents.splice(t,1),e.routing=e.routing.filter(e=>e.agent!==n.id)})},k=(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=P(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)}_(e=>{e.agents=a})},A=m(H(te,{activationConstraint:{distance:4}}),H(B,{coordinateGetter:N})),j=e=>{let{active:t,over:n}=e;n&&k(String(t.id),String(n.id))},M=(e,t)=>{_(n=>{n.agents[e].model=t})},F=(e,t)=>{_(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)}),f(!1)},L=()=>{_(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)=>{_(n=>{let r=n.routing[e];r&&(R(r)||(r.agent=t))})},V=(e,t,n)=>{_(r=>{let i=r.routing[e];i&&(R(i)||(i.tags=t,i.agent=n))})},U=e=>{_(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)||_(e=>{let[n]=e.routing.splice(t,1);e.routing.splice(r,0,n)})};return(0,X.jsxs)(`div`,{className:`p-6 space-y-6 max-w-3xl`,children:[(0,X.jsx)(oe,{open:u,mode:`add`,chainAgents:e.agents.map(e=>e.id),onConfirm:F,onCancel:()=>f(!1)}),(0,X.jsx)(oe,{open:p!==null,mode:`edit`,initial:p!==null&&e.routing[p]&&!(`default`in e.routing[p])?{tags:e.routing[p].tags,agent:e.routing[p].agent}:void 0,chainAgents:e.agents.map(e=>e.id),onConfirm:(e,t)=>{p!==null&&(V(p,e,t),g(null))},onCancel:()=>g(null)}),x.length>0&&(0,X.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,X.jsxs)(`div`,{className:`font-medium mb-1`,children:[x.length,` validation `,x.length===1?`issue`:`issues`]}),(0,X.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:x.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),(0,X.jsxs)(`section`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Name`}),(0,X.jsx)(I,{value:e.name,disabled:!0,className:`text-sm`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Description`}),(0,X.jsx)(I,{value:e.description??``,onChange:e=>_(t=>{t.description=e.target.value}),className:`text-sm`,placeholder:`What is this profile for?`})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2`,children:`Orchestrator`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-md border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-sm font-mono text-foreground truncate`,children:`/specrails:implement · /specrails:batch-implement`}),(0,X.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,X.jsx)(fe,{value:e.orchestrator.model,onChange:e=>_(t=>{t.orchestrator.model=e})})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,X.jsxs)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[`Agent chain (`,e.agents.length,`)`]}),(0,X.jsxs)(d,{size:`sm`,variant:`ghost`,onClick:()=>l(e=>!e),disabled:y.length===0,title:y.length===0?`All catalog agents are already in the chain`:`Add an agent from the catalog`,children:[(0,X.jsx)(h,{className:`w-3.5 h-3.5 mr-1`}),` Add`]})]}),c&&(0,X.jsxs)(`div`,{className:`mb-2 p-2 rounded-md border border-border bg-muted/30`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 px-1`,children:[(0,X.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`Pick from catalog (`,y.length,` available)`]}),(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:()=>l(!1),title:`Close`,children:(0,X.jsx)(o,{className:`w-3 h-3`})})]}),y.length===0?(0,X.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,X.jsx)(`div`,{className:`space-y-0.5 max-h-64 overflow-auto`,children:y.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>D(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,X.jsx)(`span`,{className:`text-sm font-mono`,children:e.id}),(0,X.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,X.jsx)(ee,{sensors:A,collisionDetection:b,onDragEnd:j,children:(0,X.jsx)(T,{items:e.agents.map(e=>e.id),strategy:E,children:(0,X.jsx)(`div`,{className:`space-y-1.5`,children:e.agents.map((e,t)=>(0,X.jsx)(ue,{agent:e,canRemove:!Z.has(e.id),onModel:e=>M(t,e),onRemove:()=>O(t)},e.id))})})})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,X.jsxs)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[`Routing (`,e.routing.length,`)`]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!C&&(0,X.jsxs)(d,{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,X.jsx)(h,{className:`w-3.5 h-3.5 mr-1`}),` Add default`]}),(0,X.jsxs)(d,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),disabled:e.agents.length===0,title:e.agents.length===0?`Add at least one agent before creating routing rules`:void 0,children:[(0,X.jsx)(h,{className:`w-3.5 h-3.5 mr-1`}),` Add rule`]})]})]}),(0,X.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.`}),S.length>0&&(0,X.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,X.jsx)(`div`,{className:`font-medium mb-1`,children:`Untargeted agents in the chain`}),(0,X.jsxs)(`div`,{children:[`No routing rule points to: `,(0,X.jsx)(`span`,{className:`font-mono`,children:S.join(`, `)}),`. Add a tag rule or retarget the default rule if you want them to run.`]})]}),(0,X.jsx)(`div`,{className:`space-y-1.5`,children:e.routing.map((t,n)=>{let r=`default`in t&&t.default===!0;return(0,X.jsx)(de,{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:()=>g(n),onUp:()=>W(n,-1),onDown:()=>W(n,1),onRemove:()=>U(n)},n)})})]}),n&&(0,X.jsx)(`div`,{className:`pt-3 border-t border-border`,children:n})]})}function ue({agent:e,canRemove:t,onModel:n,onRemove:i}){let a=Z.has(e.id),s=e.id===`sr-architect`,c=e.id===`sr-merge-resolver`,{attributes:l,listeners:u,setNodeRef:d,transform:f,transition:p,isDragging:m}=D({id:e.id});return(0,X.jsxs)(`div`,{ref:d,style:{transform:r.Transform.toString(f),transition:p,opacity:m?.5:void 0,zIndex:m?10:void 0},className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors bg-background`,children:[(0,X.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`,...l,...u,children:(0,X.jsx)(F,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`span`,{className:`text-sm font-mono flex-1 truncate`,children:e.id}),s&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-dracula-purple/15 text-dracula-purple`,title:`Pinned to first position — pipeline always starts with sr-architect`,children:[(0,X.jsx)(J,{className:`w-2.5 h-2.5 rotate-[135deg]`}),` first`]}),c&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-dracula-purple/15 text-dracula-purple`,title:`Pinned to last position — merge phase always runs last`,children:[(0,X.jsx)(J,{className:`w-2.5 h-2.5 rotate-45`}),` last`]}),a&&!s&&!c&&(0,X.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:`required`}),(0,X.jsx)(fe,{value:e.model??`sonnet`,onChange:n}),(0,X.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:i,disabled:!t,title:t?`Remove`:`Required baseline agent — the pipeline depends on this row`,children:(0,X.jsx)(o,{className:`w-3 h-3`})})]})}function de({rule:e,ordinal:t,isLast:n,canMove:r,canRemove:i,canEdit:a,chainAgents:s,onAgentChange:c,onEdit:l,onUp:u,onDown:d,onRemove:f}){let p=`default`in e&&e.default===!0;return(0,X.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,X.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground w-5 text-center flex-shrink-0`,children:[t,`.`]}),p?(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:`everything else`}):(0,X.jsx)(`span`,{className:`text-xs flex-1 flex gap-1 flex-wrap items-center`,children:e.tags.map(e=>(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-muted font-mono text-[11px]`,children:e},e))}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),p?(0,X.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,X.jsx)(`select`,{value:e.agent,onChange:e=>c(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:s.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))}),(0,X.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[a&&(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:l,title:`Edit rule`,"aria-label":`Edit rule ${t}`,children:(0,X.jsx)(g,{className:`w-3 h-3`})}),r&&!n&&(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:d,title:`Move down`,children:(0,X.jsx)(W,{className:`w-3 h-3`})}),r&&t>1&&(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:u,title:`Move up`,children:(0,X.jsx)(G,{className:`w-3 h-3`})}),i&&(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 rounded`,onClick:f,title:`Remove`,children:(0,X.jsx)(o,{className:`w-3 h-3`})})]}),p&&(0,X.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 fe({value:e,onChange:t}){return(0,X.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-7 px-2 text-xs rounded border border-border bg-background`,children:se.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})}function Q({open:e,title:n,description:r,placeholder:o,initialValue:s=``,confirmLabel:c=`Confirm`,inputPattern:l,inputInvalidHint:u,onConfirm:f,onCancel:p}){let[m,h]=(0,Y.useState)(s);(0,Y.useEffect)(()=>{e&&h(s)},[e,s]);let g=m.trim(),_=!l||l.test(g),v=g.length>0&&_;return(0,X.jsx)(a,{open:e,onOpenChange:e=>{e||p()},children:(0,X.jsxs)(i,{className:`max-w-md`,children:[(0,X.jsx)(t,{children:(0,X.jsx)(O,{children:n})}),(0,X.jsxs)(`div`,{className:`py-2 space-y-2`,children:[r&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}),(0,X.jsx)(I,{autoFocus:!0,value:m,placeholder:o,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v&&f(g)},className:`text-sm font-mono`}),g.length>0&&!_&&u&&(0,X.jsx)(`p`,{className:`text-[11px] text-yellow-500`,children:u})]}),(0,X.jsxs)(k,{children:[(0,X.jsx)(d,{variant:`ghost`,size:`sm`,onClick:p,children:`Cancel`}),(0,X.jsx)(d,{size:`sm`,onClick:()=>f(g),disabled:!v,children:c})]})]})})}function pe({open:e,title:n,description:r,confirmLabel:o=`Confirm`,destructive:s=!1,onConfirm:c,onCancel:l}){return(0,X.jsx)(a,{open:e,onOpenChange:e=>{e||l()},children:(0,X.jsxs)(i,{className:`max-w-md`,children:[(0,X.jsx)(t,{children:(0,X.jsx)(O,{children:n})}),r&&(0,X.jsx)(`div`,{className:`py-2`,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r})}),(0,X.jsxs)(k,{children:[(0,X.jsx)(d,{variant:`ghost`,size:`sm`,onClick:l,children:`Cancel`}),(0,X.jsx)(d,{size:`sm`,onClick:c,className:s?`bg-red-500 hover:bg-red-600 text-white`:void 0,children:o})]})]})})}function me(){let[e,t]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!0),[l,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)([]),[ee,y]=(0,Y.useState)([]),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(null),D=(0,Y.useCallback)(async()=>{c(!0),f(null);try{let e=await fetch(`${w()}/profiles`);if(!e.ok)throw Error(`List failed: ${e.status}`);let n=await e.json();t(n.profiles),n.profiles.length>0&&!r&&i(n.profiles[0].name)}catch(e){f(e.message)}finally{c(!1)}},[r]);(0,Y.useEffect)(()=>{D()},[D]),(0,Y.useEffect)(()=>{if(!r){o(null);return}let e=!1;return fetch(`${w()}/profiles/${encodeURIComponent(r)}`).then(e=>{if(!e.ok)throw Error(`Load failed: ${e.status}`);return e.json()}).then(t=>{e||o(t.profile)}).catch(t=>{e||f(t.message)}),()=>{e=!0}},[r]);let O=(0,Y.useCallback)(async()=>{m(!0),f(null);try{let e=await fetch(`${w()}/profiles/migrate-from-settings`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Migration failed: ${e.status}`)}await D(),i(`default`),V.success(`Profile migrated`,{description:`default profile created from your current agents`})}catch(e){let t=e.message;f(t),V.error(`Migration failed`,{description:t})}finally{m(!1)}},[D]),k=(0,Y.useCallback)(async e=>{x(!1),m(!0),f(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(`${w()}/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 D(),i(e),V.success(`Profile created`,{description:e})}catch(e){let t=e.message;f(t),V.error(`Failed to create profile`,{description:t})}finally{m(!1)}},[D]),A=(0,Y.useCallback)(async(e,t)=>{C(null),m(!0),f(null);try{let n=await fetch(`${w()}/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 D(),i(t),V.success(`Profile duplicated`,{description:`${e} → ${t}`})}catch(e){let t=e.message;f(t),V.error(`Failed to duplicate profile`,{description:t})}finally{m(!1)}},[D]),j=(0,Y.useCallback)(async e=>{E(null),m(!0),f(null);try{let t=await fetch(`${w()}/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 D(),V.success(`Profile deleted`,{description:e})}catch(e){let t=e.message;f(t),V.error(`Failed to delete profile`,{description:t})}finally{m(!1)}},[D]),M=(0,Y.useCallback)(()=>x(!0),[]),N=(0,Y.useCallback)(e=>C({from:e}),[]),P=(0,Y.useCallback)(e=>E({name:e}),[]),F=(0,Y.useCallback)(async(e,t)=>{m(!0),f(null);try{let n=await fetch(`${w()}/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?V.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}):V.success(`Profile saved`,{description:e.name})}catch(e){let t=e.message;f(t),V.error(`Failed to save profile`,{description:t})}finally{m(!1)}},[]),I=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{open:b,title:`New profile`,description:`Pick a lowercase kebab-case name (letters, digits, and hyphens).`,placeholder:`my-profile`,confirmLabel:`Create`,inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:`Must start with a letter or digit and contain only lowercase letters, digits, and hyphens.`,onConfirm:e=>void k(e),onCancel:()=>x(!1)}),S&&(0,X.jsx)(Q,{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 A(S.from,e),onCancel:()=>C(null)}),T&&(0,X.jsx)(pe,{open:!0,title:`Delete profile "${T.name}"?`,description:`This cannot be undone. Jobs already launched with this profile keep their snapshot; future launches will fall back to the resolution order.`,confirmLabel:`Delete`,destructive:!0,onConfirm:()=>void j(T.name),onCancel:()=>E(null)})]});return s?(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading profiles…`})}):e.length===0?(0,X.jsxs)(X.Fragment,{children:[I,(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,X.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`No profiles yet`}),(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-2 justify-center`,children:[(0,X.jsxs)(d,{size:`sm`,onClick:O,disabled:p,children:[(0,X.jsx)(ie,{className:`w-3.5 h-3.5 mr-1.5`}),` Migrate from current agents`]}),(0,X.jsxs)(d,{size:`sm`,variant:`ghost`,onClick:M,disabled:p,children:[(0,X.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5`}),` Blank profile`]})]}),(0,X.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-3`,children:[`"Migrate" reads your existing `,(0,X.jsx)(`code`,{className:`text-foreground`,children:`.claude/agents/`}),` `,`frontmatter models and creates a `,(0,X.jsx)(`code`,{className:`text-foreground`,children:`default`}),` profile mirroring today's behavior — zero-loss.`]}),l&&(0,X.jsx)(`div`,{className:`mt-3 text-xs text-red-400`,children:l})]})})]}):(0,X.jsxs)(`div`,{className:`flex flex-col h-full`,children:[I,(0,X.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,X.jsxs)(`aside`,{className:`w-64 flex-shrink-0 border-r border-border flex flex-col`,children:[(0,X.jsxs)(`div`,{className:`p-3 flex items-center justify-between`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Profiles`}),(0,X.jsx)(d,{size:`sm`,variant:`ghost`,onClick:M,disabled:p,children:(0,X.jsx)(h,{className:`w-3.5 h-3.5`})})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-auto px-2 pb-3`,children:e.map(e=>(0,X.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===r?`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,X.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,X.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),e.isDefault&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`(team default)`})]}),(0,X.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,title:`Duplicate`,onClick:t=>{t.stopPropagation(),N(e.name)},children:(0,X.jsx)(v,{className:`w-3 h-3`})}),!e.isDefault&&(0,X.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,X.jsx)(u,{className:`w-3 h-3`})})]})]},e.name))})]}),(0,X.jsxs)(`main`,{className:`flex-1 overflow-auto`,children:[l&&(0,X.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:l}),a?(0,X.jsx)(le,{profile:a,onChange:o,onValidityChange:_,onSoftWarningsChange:e=>y(e.agentsMissingRouting),footer:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(d,{size:`sm`,onClick:()=>void F(a,ee),disabled:p||g.length>0,title:g.length>0?`Fix validation issues before saving`:void 0,children:[(0,X.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),`Save`]}),p&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving…`}),g.length>0&&(0,X.jsxs)(`span`,{className:`text-xs text-yellow-500`,children:[g.length,` `,g.length===1?`issue`:`issues`,` to resolve`]})]})},a.name):(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a profile to edit`})})]})]})]})}function $(e){let t=e.workflow.map((e,t)=>`${t+1}. ${e}`).join(`
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{A as t,B as n,Ct as r,D as i,E as a,F as o,I as s,J as c,K as l,L as u,N as d,O as f,R as p,St as m,U as h,W as g,Y as _,Z as v,_t as ee,at as y,bt as b,c as x,ct as S,d as C,dt as w,ft as T,gt as E,ht as D,j as O,k,kt as A,l as j,lt as M,mt as N,pt as P,q as F,s as I,st as L,u as R,ut as z,vt as B,wt as V,xt as H,yt as te,z as U}from"./index-IQAxy67u.js";var W=L(`arrow-down`,[[`path`,{d:`M12 5v14`,key:`s699le`}],[`path`,{d:`m19 12-7 7-7-7`,key:`1idqje`}]]),G=L(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),ne=L(`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`}]]),K=L(`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`}]]),q=L(`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`}]]),J=L(`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`}]]),re=L(`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`}]]),ie=L(`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`}]]),Y=e(A(),1),X=z(),ae=/^[a-z0-9][a-z0-9-]*$/;function oe({open:e,mode:n=`add`,initial:r,chainAgents:o,onConfirm:s,onCancel:c}){let[l,u]=(0,Y.useState)(``),[p,m]=(0,Y.useState)(o[0]??``);(0,Y.useEffect)(()=>{e&&(n===`edit`&&r?(u(r.tags.join(`, `)),m(o.includes(r.agent)?r.agent:o[0]??``)):(u(``),m(o[0]??``)))},[e,n,r,o]);let h=l.split(`,`).map(e=>e.trim()).filter(Boolean),g=h.filter(e=>!ae.test(e)),_=h.length>0&&g.length===0&&o.includes(p);return(0,X.jsx)(a,{open:e,onOpenChange:e=>{e||c()},children:(0,X.jsxs)(i,{className:`max-w-md`,children:[(0,X.jsxs)(t,{children:[(0,X.jsx)(O,{children:n===`edit`?`Edit routing rule`:`Add routing rule`}),(0,X.jsx)(f,{children:n===`edit`?`Update the tags or target agent for this rule.`:`Add a tag-matched routing rule using lowercase kebab-case tags.`})]}),(0,X.jsxs)(`div`,{className:`py-2 space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Tags`}),(0,X.jsx)(I,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),placeholder:`frontend, ui`,"aria-label":`Tags`,className:`text-sm font-mono`}),(0,X.jsxs)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:[`Comma-separated. Use lowercase kebab-case like `,(0,X.jsx)(`code`,{children:`frontend`}),` or `,(0,X.jsx)(`code`,{children:`api-design`}),`.`]}),g.length>0&&(0,X.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,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Route to`}),(0,X.jsx)(`select`,{value:p,onChange:e=>m(e.target.value),"aria-label":`Route to`,className:`w-full h-9 px-2 text-sm rounded-md border border-border bg-background`,children:o.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))}),(0,X.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:`Only agents in this profile's chain can be routing targets.`})]})]}),(0,X.jsxs)(k,{children:[(0,X.jsx)(d,{variant:`ghost`,size:`sm`,onClick:c,children:`Cancel`}),(0,X.jsx)(d,{size:`sm`,onClick:()=>s(h,p),disabled:!_,children:n===`edit`?`Save changes`:`Add rule`})]})]})})}var Z=new Set([`sr-architect`,`sr-developer`,`sr-reviewer`,`sr-merge-resolver`]),se=[`sonnet`,`opus`,`haiku`],ce=/^[a-z0-9][a-z0-9-]*$/;function le({profile:e,onChange:t,footer:n,onValidityChange:r,onSoftWarningsChange:i}){let[a,s]=(0,Y.useState)([]),[c,l]=(0,Y.useState)(!1),[u,f]=(0,Y.useState)(!1),[p,g]=(0,Y.useState)(null);(0,Y.useEffect)(()=>{let e=!1;return fetch(`${w()}/profiles/catalog`).then(e=>e.ok?e.json():{agents:[]}).then(t=>{e||s(t.agents)}).catch(()=>{e||s([])}),()=>{e=!0}},[]);let _=n=>{let r=JSON.parse(JSON.stringify(e));n(r),t(r)},v=new Set(e.agents.map(e=>e.id)),y=a.filter(e=>!v.has(e.id)),x=(0,Y.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=>!ce.test(e));e.length>0&&t.push(`Routing rule ${n.agent} has invalid tags: ${e.join(`, `)} (use lowercase kebab-case)`)}return t},[e]),S=(0,Y.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]),C=(0,Y.useMemo)(()=>e.routing.some(e=>`default`in e&&e.default===!0),[e.routing]);(0,Y.useEffect)(()=>{r&&r(x)},[x,r]),(0,Y.useEffect)(()=>{i&&i({agentsMissingRouting:S})},[S,i]);let D=e=>{_(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)}),l(!1)},O=t=>{let n=e.agents[t];Z.has(n.id)||_(e=>{e.agents.splice(t,1),e.routing=e.routing.filter(e=>e.agent!==n.id)})},k=(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=P(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)}_(e=>{e.agents=a})},A=m(H(te,{activationConstraint:{distance:4}}),H(B,{coordinateGetter:N})),j=e=>{let{active:t,over:n}=e;n&&k(String(t.id),String(n.id))},M=(e,t)=>{_(n=>{n.agents[e].model=t})},F=(e,t)=>{_(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)}),f(!1)},L=()=>{_(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)=>{_(n=>{let r=n.routing[e];r&&(R(r)||(r.agent=t))})},V=(e,t,n)=>{_(r=>{let i=r.routing[e];i&&(R(i)||(i.tags=t,i.agent=n))})},U=e=>{_(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)||_(e=>{let[n]=e.routing.splice(t,1);e.routing.splice(r,0,n)})};return(0,X.jsxs)(`div`,{className:`p-6 space-y-6 max-w-3xl`,children:[(0,X.jsx)(oe,{open:u,mode:`add`,chainAgents:e.agents.map(e=>e.id),onConfirm:F,onCancel:()=>f(!1)}),(0,X.jsx)(oe,{open:p!==null,mode:`edit`,initial:p!==null&&e.routing[p]&&!(`default`in e.routing[p])?{tags:e.routing[p].tags,agent:e.routing[p].agent}:void 0,chainAgents:e.agents.map(e=>e.id),onConfirm:(e,t)=>{p!==null&&(V(p,e,t),g(null))},onCancel:()=>g(null)}),x.length>0&&(0,X.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,X.jsxs)(`div`,{className:`font-medium mb-1`,children:[x.length,` validation `,x.length===1?`issue`:`issues`]}),(0,X.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:x.map((e,t)=>(0,X.jsx)(`li`,{children:e},t))})]}),(0,X.jsxs)(`section`,{className:`space-y-3`,children:[(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Name`}),(0,X.jsx)(I,{value:e.name,disabled:!0,className:`text-sm`})]}),(0,X.jsxs)(`div`,{children:[(0,X.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:`Description`}),(0,X.jsx)(I,{value:e.description??``,onChange:e=>_(t=>{t.description=e.target.value}),className:`text-sm`,placeholder:`What is this profile for?`})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2`,children:`Orchestrator`}),(0,X.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-md border border-border`,children:[(0,X.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,X.jsx)(`div`,{className:`text-sm font-mono text-foreground truncate`,children:`/specrails:implement · /specrails:batch-implement`}),(0,X.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,X.jsx)(fe,{value:e.orchestrator.model,onChange:e=>_(t=>{t.orchestrator.model=e})})]})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,X.jsxs)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[`Agent chain (`,e.agents.length,`)`]}),(0,X.jsxs)(d,{size:`sm`,variant:`ghost`,onClick:()=>l(e=>!e),disabled:y.length===0,title:y.length===0?`All catalog agents are already in the chain`:`Add an agent from the catalog`,children:[(0,X.jsx)(h,{className:`w-3.5 h-3.5 mr-1`}),` Add`]})]}),c&&(0,X.jsxs)(`div`,{className:`mb-2 p-2 rounded-md border border-border bg-muted/30`,children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 px-1`,children:[(0,X.jsxs)(`span`,{className:`text-[11px] text-muted-foreground`,children:[`Pick from catalog (`,y.length,` available)`]}),(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:()=>l(!1),title:`Close`,children:(0,X.jsx)(o,{className:`w-3 h-3`})})]}),y.length===0?(0,X.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,X.jsx)(`div`,{className:`space-y-0.5 max-h-64 overflow-auto`,children:y.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>D(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,X.jsx)(`span`,{className:`text-sm font-mono`,children:e.id}),(0,X.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,X.jsx)(ee,{sensors:A,collisionDetection:b,onDragEnd:j,children:(0,X.jsx)(T,{items:e.agents.map(e=>e.id),strategy:E,children:(0,X.jsx)(`div`,{className:`space-y-1.5`,children:e.agents.map((e,t)=>(0,X.jsx)(ue,{agent:e,canRemove:!Z.has(e.id),onModel:e=>M(t,e),onRemove:()=>O(t)},e.id))})})})]}),(0,X.jsxs)(`section`,{children:[(0,X.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,X.jsxs)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:[`Routing (`,e.routing.length,`)`]}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!C&&(0,X.jsxs)(d,{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,X.jsx)(h,{className:`w-3.5 h-3.5 mr-1`}),` Add default`]}),(0,X.jsxs)(d,{size:`sm`,variant:`ghost`,onClick:()=>f(!0),disabled:e.agents.length===0,title:e.agents.length===0?`Add at least one agent before creating routing rules`:void 0,children:[(0,X.jsx)(h,{className:`w-3.5 h-3.5 mr-1`}),` Add rule`]})]})]}),(0,X.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.`}),S.length>0&&(0,X.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,X.jsx)(`div`,{className:`font-medium mb-1`,children:`Untargeted agents in the chain`}),(0,X.jsxs)(`div`,{children:[`No routing rule points to: `,(0,X.jsx)(`span`,{className:`font-mono`,children:S.join(`, `)}),`. Add a tag rule or retarget the default rule if you want them to run.`]})]}),(0,X.jsx)(`div`,{className:`space-y-1.5`,children:e.routing.map((t,n)=>{let r=`default`in t&&t.default===!0;return(0,X.jsx)(de,{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:()=>g(n),onUp:()=>W(n,-1),onDown:()=>W(n,1),onRemove:()=>U(n)},n)})})]}),n&&(0,X.jsx)(`div`,{className:`pt-3 border-t border-border`,children:n})]})}function ue({agent:e,canRemove:t,onModel:n,onRemove:i}){let a=Z.has(e.id),s=e.id===`sr-architect`,c=e.id===`sr-merge-resolver`,{attributes:l,listeners:u,setNodeRef:d,transform:f,transition:p,isDragging:m}=D({id:e.id});return(0,X.jsxs)(`div`,{ref:d,style:{transform:r.Transform.toString(f),transition:p,opacity:m?.5:void 0,zIndex:m?10:void 0},className:`flex items-center gap-2 px-2 py-1.5 rounded-md border border-border group hover:bg-accent/30 transition-colors bg-background`,children:[(0,X.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`,...l,...u,children:(0,X.jsx)(F,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`span`,{className:`text-sm font-mono flex-1 truncate`,children:e.id}),s&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-dracula-purple/15 text-dracula-purple`,title:`Pinned to first position — pipeline always starts with sr-architect`,children:[(0,X.jsx)(J,{className:`w-2.5 h-2.5 rotate-[135deg]`}),` first`]}),c&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-dracula-purple/15 text-dracula-purple`,title:`Pinned to last position — merge phase always runs last`,children:[(0,X.jsx)(J,{className:`w-2.5 h-2.5 rotate-45`}),` last`]}),a&&!s&&!c&&(0,X.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:`required`}),(0,X.jsx)(fe,{value:e.model??`sonnet`,onChange:n}),(0,X.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:i,disabled:!t,title:t?`Remove`:`Required baseline agent — the pipeline depends on this row`,children:(0,X.jsx)(o,{className:`w-3 h-3`})})]})}function de({rule:e,ordinal:t,isLast:n,canMove:r,canRemove:i,canEdit:a,chainAgents:s,onAgentChange:c,onEdit:l,onUp:u,onDown:d,onRemove:f}){let p=`default`in e&&e.default===!0;return(0,X.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,X.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground w-5 text-center flex-shrink-0`,children:[t,`.`]}),p?(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:`everything else`}):(0,X.jsx)(`span`,{className:`text-xs flex-1 flex gap-1 flex-wrap items-center`,children:e.tags.map(e=>(0,X.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-muted font-mono text-[11px]`,children:e},e))}),(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),p?(0,X.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,X.jsx)(`select`,{value:e.agent,onChange:e=>c(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:s.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))}),(0,X.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[a&&(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:l,title:`Edit rule`,"aria-label":`Edit rule ${t}`,children:(0,X.jsx)(g,{className:`w-3 h-3`})}),r&&!n&&(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:d,title:`Move down`,children:(0,X.jsx)(W,{className:`w-3 h-3`})}),r&&t>1&&(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:u,title:`Move up`,children:(0,X.jsx)(G,{className:`w-3 h-3`})}),i&&(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 rounded`,onClick:f,title:`Remove`,children:(0,X.jsx)(o,{className:`w-3 h-3`})})]}),p&&(0,X.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 fe({value:e,onChange:t}){return(0,X.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-7 px-2 text-xs rounded border border-border bg-background`,children:se.map(e=>(0,X.jsx)(`option`,{value:e,children:e},e))})}function Q({open:e,title:n,description:r,placeholder:o,initialValue:s=``,confirmLabel:c=`Confirm`,inputPattern:l,inputInvalidHint:u,onConfirm:f,onCancel:p}){let[m,h]=(0,Y.useState)(s);(0,Y.useEffect)(()=>{e&&h(s)},[e,s]);let g=m.trim(),_=!l||l.test(g),v=g.length>0&&_;return(0,X.jsx)(a,{open:e,onOpenChange:e=>{e||p()},children:(0,X.jsxs)(i,{className:`max-w-md`,children:[(0,X.jsx)(t,{children:(0,X.jsx)(O,{children:n})}),(0,X.jsxs)(`div`,{className:`py-2 space-y-2`,children:[r&&(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r}),(0,X.jsx)(I,{autoFocus:!0,value:m,placeholder:o,onChange:e=>h(e.target.value),onKeyDown:e=>{e.key===`Enter`&&v&&f(g)},className:`text-sm font-mono`}),g.length>0&&!_&&u&&(0,X.jsx)(`p`,{className:`text-[11px] text-yellow-500`,children:u})]}),(0,X.jsxs)(k,{children:[(0,X.jsx)(d,{variant:`ghost`,size:`sm`,onClick:p,children:`Cancel`}),(0,X.jsx)(d,{size:`sm`,onClick:()=>f(g),disabled:!v,children:c})]})]})})}function pe({open:e,title:n,description:r,confirmLabel:o=`Confirm`,destructive:s=!1,onConfirm:c,onCancel:l}){return(0,X.jsx)(a,{open:e,onOpenChange:e=>{e||l()},children:(0,X.jsxs)(i,{className:`max-w-md`,children:[(0,X.jsx)(t,{children:(0,X.jsx)(O,{children:n})}),r&&(0,X.jsx)(`div`,{className:`py-2`,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r})}),(0,X.jsxs)(k,{children:[(0,X.jsx)(d,{variant:`ghost`,size:`sm`,onClick:l,children:`Cancel`}),(0,X.jsx)(d,{size:`sm`,onClick:c,className:s?`bg-red-500 hover:bg-red-600 text-white`:void 0,children:o})]})]})})}function me(){let[e,t]=(0,Y.useState)([]),[r,i]=(0,Y.useState)(null),[a,o]=(0,Y.useState)(null),[s,c]=(0,Y.useState)(!0),[l,f]=(0,Y.useState)(null),[p,m]=(0,Y.useState)(!1),[g,_]=(0,Y.useState)([]),[ee,y]=(0,Y.useState)([]),[b,x]=(0,Y.useState)(!1),[S,C]=(0,Y.useState)(null),[T,E]=(0,Y.useState)(null),D=(0,Y.useCallback)(async()=>{c(!0),f(null);try{let e=await fetch(`${w()}/profiles`);if(!e.ok)throw Error(`List failed: ${e.status}`);let n=await e.json();t(n.profiles),n.profiles.length>0&&!r&&i(n.profiles[0].name)}catch(e){f(e.message)}finally{c(!1)}},[r]);(0,Y.useEffect)(()=>{D()},[D]),(0,Y.useEffect)(()=>{if(!r){o(null);return}let e=!1;return fetch(`${w()}/profiles/${encodeURIComponent(r)}`).then(e=>{if(!e.ok)throw Error(`Load failed: ${e.status}`);return e.json()}).then(t=>{e||o(t.profile)}).catch(t=>{e||f(t.message)}),()=>{e=!0}},[r]);let O=(0,Y.useCallback)(async()=>{m(!0),f(null);try{let e=await fetch(`${w()}/profiles/migrate-from-settings`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error??`Migration failed: ${e.status}`)}await D(),i(`default`),V.success(`Profile migrated`,{description:`default profile created from your current agents`})}catch(e){let t=e.message;f(t),V.error(`Migration failed`,{description:t})}finally{m(!1)}},[D]),k=(0,Y.useCallback)(async e=>{x(!1),m(!0),f(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(`${w()}/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 D(),i(e),V.success(`Profile created`,{description:e})}catch(e){let t=e.message;f(t),V.error(`Failed to create profile`,{description:t})}finally{m(!1)}},[D]),A=(0,Y.useCallback)(async(e,t)=>{C(null),m(!0),f(null);try{let n=await fetch(`${w()}/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 D(),i(t),V.success(`Profile duplicated`,{description:`${e} → ${t}`})}catch(e){let t=e.message;f(t),V.error(`Failed to duplicate profile`,{description:t})}finally{m(!1)}},[D]),j=(0,Y.useCallback)(async e=>{E(null),m(!0),f(null);try{let t=await fetch(`${w()}/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 D(),V.success(`Profile deleted`,{description:e})}catch(e){let t=e.message;f(t),V.error(`Failed to delete profile`,{description:t})}finally{m(!1)}},[D]),M=(0,Y.useCallback)(()=>x(!0),[]),N=(0,Y.useCallback)(e=>C({from:e}),[]),P=(0,Y.useCallback)(e=>E({name:e}),[]),F=(0,Y.useCallback)(async(e,t)=>{m(!0),f(null);try{let n=await fetch(`${w()}/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?V.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}):V.success(`Profile saved`,{description:e.name})}catch(e){let t=e.message;f(t),V.error(`Failed to save profile`,{description:t})}finally{m(!1)}},[]),I=(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(Q,{open:b,title:`New profile`,description:`Pick a lowercase kebab-case name (letters, digits, and hyphens).`,placeholder:`my-profile`,confirmLabel:`Create`,inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:`Must start with a letter or digit and contain only lowercase letters, digits, and hyphens.`,onConfirm:e=>void k(e),onCancel:()=>x(!1)}),S&&(0,X.jsx)(Q,{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 A(S.from,e),onCancel:()=>C(null)}),T&&(0,X.jsx)(pe,{open:!0,title:`Delete profile "${T.name}"?`,description:`This cannot be undone. Jobs already launched with this profile keep their snapshot; future launches will fall back to the resolution order.`,confirmLabel:`Delete`,destructive:!0,onConfirm:()=>void j(T.name),onCancel:()=>E(null)})]});return s?(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Loading profiles…`})}):e.length===0?(0,X.jsxs)(X.Fragment,{children:[I,(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,X.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,X.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:`No profiles yet`}),(0,X.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,X.jsxs)(`div`,{className:`flex items-center gap-2 justify-center`,children:[(0,X.jsxs)(d,{size:`sm`,onClick:O,disabled:p,children:[(0,X.jsx)(ie,{className:`w-3.5 h-3.5 mr-1.5`}),` Migrate from current agents`]}),(0,X.jsxs)(d,{size:`sm`,variant:`ghost`,onClick:M,disabled:p,children:[(0,X.jsx)(h,{className:`w-3.5 h-3.5 mr-1.5`}),` Blank profile`]})]}),(0,X.jsxs)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-3`,children:[`"Migrate" reads your existing `,(0,X.jsx)(`code`,{className:`text-foreground`,children:`.claude/agents/`}),` `,`frontmatter models and creates a `,(0,X.jsx)(`code`,{className:`text-foreground`,children:`default`}),` profile mirroring today's behavior — zero-loss.`]}),l&&(0,X.jsx)(`div`,{className:`mt-3 text-xs text-red-400`,children:l})]})})]}):(0,X.jsxs)(`div`,{className:`flex flex-col h-full`,children:[I,(0,X.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,X.jsxs)(`aside`,{className:`w-64 flex-shrink-0 border-r border-border flex flex-col`,children:[(0,X.jsxs)(`div`,{className:`p-3 flex items-center justify-between`,children:[(0,X.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:`Profiles`}),(0,X.jsx)(d,{size:`sm`,variant:`ghost`,onClick:M,disabled:p,children:(0,X.jsx)(h,{className:`w-3.5 h-3.5`})})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-auto px-2 pb-3`,children:e.map(e=>(0,X.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===r?`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,X.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,X.jsx)(`span`,{className:`truncate font-medium`,children:e.name}),e.isDefault&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:`(team default)`})]}),(0,X.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,X.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,title:`Duplicate`,onClick:t=>{t.stopPropagation(),N(e.name)},children:(0,X.jsx)(v,{className:`w-3 h-3`})}),!e.isDefault&&(0,X.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,X.jsx)(u,{className:`w-3 h-3`})})]})]},e.name))})]}),(0,X.jsxs)(`main`,{className:`flex-1 overflow-auto`,children:[l&&(0,X.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:l}),a?(0,X.jsx)(le,{profile:a,onChange:o,onValidityChange:_,onSoftWarningsChange:e=>y(e.agentsMissingRouting),footer:(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsxs)(d,{size:`sm`,onClick:()=>void F(a,ee),disabled:p||g.length>0,title:g.length>0?`Fix validation issues before saving`:void 0,children:[(0,X.jsx)(n,{className:`w-3.5 h-3.5 mr-1.5`}),`Save`]}),p&&(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`Saving…`}),g.length>0&&(0,X.jsxs)(`span`,{className:`text-xs text-yellow-500`,children:[g.length,` `,g.length===1?`issue`:`issues`,` to resolve`]})]})},a.name):(0,X.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Select a profile to edit`})})]})]})]})}function $(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 te,L as ne,Lt as re,M as ie,Mt as w,N as ae,Nt as oe,O as se,Ot as ce,P as le,Pt as ue,Q as de,Qt as fe,R as pe,Rt as T,S as me,St as he,T as ge,Tt as _e,U as ve,Ut as E,V as ye,Vt as be,W as xe,Wt as D,X as Se,Xt as O,Y as Ce,Yt as we,Z as Te,Zt as Ee,_ as De,_n as Oe,_t as ke,a as Ae,an as je,at as Me,b as Ne,bn as Pe,bt as Fe,c as Ie,cn as Le,ct as Re,d as ze,dn as Be,dt as Ve,en as He,et as Ue,f as We,fn as Ge,ft as Ke,g as k,gn as qe,gt as Je,h as A,hn as Ye,ht as Xe,i as Ze,in as Qe,it as $e,j as et,jt as tt,k as nt,kt as rt,l as it,ln as at,lt as j,m as M,mn as N,mt as ot,n as P,nn as st,nt as F,o as ct,on as lt,ot as ut,p as dt,pn as ft,pt,q as mt,qt as ht,r as gt,rn as I,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 L,vn as Dt,vt as Ot,w as kt,wt as At,x as jt,xn as Mt,xt as Nt,y as Pt,yn as Ft,yt as It,z as Lt,zt as Rt}from"./dracula-colors-BgsgBGTu.js";import{n as R,t as zt}from"./utils-nUaWT5EW.js";import{G as Bt,H as Vt,Ot as Ht,ct as Ut,dt as Wt,kt as Gt,rt as Kt,st as qt,tt as Jt,ut as Yt}from"./index-DxrdFIhh.js";import{t as Xt}from"./ExportDropdown-CI7A-4cJ.js";var Zt=qt(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Qt=qt(`trending-down`,[[`path`,{d:`M16 17h6v-6`,key:`t6n2it`}],[`path`,{d:`m22 17-8.5-8.5-5 5L2 7`,key:`x473p`}]]),z=e(Gt()),B=Yt();function $t(e){return`$${e.toFixed(4)}`}function en(e){if(e===null)return`—`;let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${r}s`}function tn(e){return`${(e*100).toFixed(1)}%`}function nn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function rn(e){return e===null?null:`${e>0?`+`:``}${e.toFixed(1)}%`}function V({delta:e,deltaPct:t,lowerIsBetter:n=!1,formatter:r}){if(e===null)return null;let i=e>0,a=n?e<0:e>0,o=e===0,s=r?r(Math.abs(e)):e>0?`+${e}`:`${e}`,c=rn(t);return(0,B.jsxs)(`span`,{className:zt(`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)(Bt,{className:`w-2.5 h-2.5`}):i?(0,B.jsx)(Mt,{className:`w-2.5 h-2.5`}):(0,B.jsx)(Qt,{className:`w-2.5 h-2.5`}),c??s]})}function H({label:e,value:t,previousValue:n,badge:r}){return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e}),(0,B.jsxs)(`div`,{className:`flex items-end justify-between gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`text-xl font-semibold tabular-nums`,children:t}),n!=null&&(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`prev: `,n]})]}),r]})]})}function an({kpi:e}){let t=e.previousPeriod;return(0,B.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-5 gap-3`,children:[(0,B.jsx)(H,{label:`Total Cost`,value:$t(e.totalCostUsd),previousValue:t?$t(t.totalCostUsd):null,badge:(0,B.jsx)(V,{delta:e.costDelta,deltaPct:e.costDeltaPct,lowerIsBetter:!0,formatter:e=>`$${e.toFixed(4)}`})}),(0,B.jsx)(H,{label:`Total Jobs`,value:String(e.totalJobs),previousValue:t?String(t.totalJobs):null,badge:(0,B.jsx)(V,{delta:e.jobsDelta,deltaPct:e.jobsDeltaPct,lowerIsBetter:!1,formatter:e=>`+${e}`})}),(0,B.jsx)(H,{label:`Success Rate`,value:tn(e.successRate),previousValue:t?tn(t.successRate):null,badge:(0,B.jsx)(V,{delta:e.successRateDelta,deltaPct:e.successRateDeltaPct,lowerIsBetter:!1,formatter:e=>`${(e*100).toFixed(1)}%`})}),(0,B.jsx)(H,{label:`Avg Duration`,value:en(e.avgDurationMs),previousValue:t?en(t.avgDurationMs):null,badge:(0,B.jsx)(V,{delta:e.avgDurationDelta,deltaPct:e.avgDurationDeltaPct,lowerIsBetter:!0,formatter:e=>en(e)})}),(0,B.jsx)(H,{label:`Total Tokens`,value:nn(e.totalTokens),previousValue:t?nn(t.totalTokens):null,badge:(0,B.jsx)(V,{delta:e.totalTokensDelta,deltaPct:e.totalTokensDeltaPct,lowerIsBetter:!0,formatter:e=>nn(e)})})]})}function on(){return on=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},on.apply(null,arguments)}function sn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?sn(Object(n),!0).forEach(function(t){ln(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ln(e,t,n){return(t=un(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function un(e){var t=dn(e,`string`);return typeof t==`symbol`?t:t+``}function dn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var U=32,fn={align:`center`,iconSize:14,inactiveColor:`#ccc`,layout:`horizontal`,verticalAlign:`middle`,labelStyle:{}};function pn(e){if(typeof e==`object`&&e&&`strokeDasharray`in e)return String(e.strokeDasharray)}function mn(e){var{data:t,iconType:n,inactiveColor:r}=e,i=U/2,a=U/6,o=U/3,s=t.inactive?r:t.color,c=n??t.type;if(c===`none`)return null;if(c===`plainline`)return z.createElement(`line`,{strokeWidth:4,fill:`none`,stroke:s,strokeDasharray:pn(t.payload),x1:0,y1:i,x2:U,y2:i,className:`recharts-legend-icon`});if(c===`line`)return z.createElement(`path`,{strokeWidth:4,fill:`none`,stroke:s,d:`M0,${i}h${o}
1
+ import{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 te,L as ne,Lt as re,M as ie,Mt as w,N as ae,Nt as oe,O as se,Ot as ce,P as le,Pt as ue,Q as de,Qt as fe,R as pe,Rt as T,S as me,St as he,T as ge,Tt as _e,U as ve,Ut as E,V as ye,Vt as be,W as xe,Wt as D,X as Se,Xt as O,Y as Ce,Yt as we,Z as Te,Zt as Ee,_ as De,_n as Oe,_t as ke,a as Ae,an as je,at as Me,b as Ne,bn as Pe,bt as Fe,c as Ie,cn as Le,ct as Re,d as ze,dn as Be,dt as Ve,en as He,et as Ue,f as We,fn as Ge,ft as Ke,g as k,gn as qe,gt as Je,h as A,hn as Ye,ht as Xe,i as Ze,in as Qe,it as $e,j as et,jt as tt,k as nt,kt as rt,l as it,ln as at,lt as j,m as M,mn as N,mt as ot,n as P,nn as st,nt as F,o as ct,on as lt,ot as ut,p as dt,pn as ft,pt,q as mt,qt as ht,r as gt,rn as I,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 L,vn as Dt,vt as Ot,w as kt,wt as At,x as jt,xn as Mt,xt as Nt,y as Pt,yn as Ft,yt as It,z as Lt,zt as Rt}from"./dracula-colors-Dc-62g_X.js";import{n as R,t as zt}from"./utils-nUaWT5EW.js";import{G as Bt,H as Vt,Ot as Ht,ct as Ut,dt as Wt,kt as Gt,rt as Kt,st as qt,tt as Jt,ut as Yt}from"./index-IQAxy67u.js";import{t as Xt}from"./ExportDropdown-CFGnYnhk.js";var Zt=qt(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),Qt=qt(`trending-down`,[[`path`,{d:`M16 17h6v-6`,key:`t6n2it`}],[`path`,{d:`m22 17-8.5-8.5-5 5L2 7`,key:`x473p`}]]),z=e(Gt()),B=Yt();function $t(e){return`$${e.toFixed(4)}`}function en(e){if(e===null)return`—`;let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${r}s`}function tn(e){return`${(e*100).toFixed(1)}%`}function nn(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:String(e)}function rn(e){return e===null?null:`${e>0?`+`:``}${e.toFixed(1)}%`}function V({delta:e,deltaPct:t,lowerIsBetter:n=!1,formatter:r}){if(e===null)return null;let i=e>0,a=n?e<0:e>0,o=e===0,s=r?r(Math.abs(e)):e>0?`+${e}`:`${e}`,c=rn(t);return(0,B.jsxs)(`span`,{className:zt(`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)(Bt,{className:`w-2.5 h-2.5`}):i?(0,B.jsx)(Mt,{className:`w-2.5 h-2.5`}):(0,B.jsx)(Qt,{className:`w-2.5 h-2.5`}),c??s]})}function H({label:e,value:t,previousValue:n,badge:r}){return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e}),(0,B.jsxs)(`div`,{className:`flex items-end justify-between gap-2`,children:[(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`p`,{className:`text-xl font-semibold tabular-nums`,children:t}),n!=null&&(0,B.jsxs)(`p`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[`prev: `,n]})]}),r]})]})}function an({kpi:e}){let t=e.previousPeriod;return(0,B.jsxs)(`div`,{className:`grid grid-cols-2 lg:grid-cols-5 gap-3`,children:[(0,B.jsx)(H,{label:`Total Cost`,value:$t(e.totalCostUsd),previousValue:t?$t(t.totalCostUsd):null,badge:(0,B.jsx)(V,{delta:e.costDelta,deltaPct:e.costDeltaPct,lowerIsBetter:!0,formatter:e=>`$${e.toFixed(4)}`})}),(0,B.jsx)(H,{label:`Total Jobs`,value:String(e.totalJobs),previousValue:t?String(t.totalJobs):null,badge:(0,B.jsx)(V,{delta:e.jobsDelta,deltaPct:e.jobsDeltaPct,lowerIsBetter:!1,formatter:e=>`+${e}`})}),(0,B.jsx)(H,{label:`Success Rate`,value:tn(e.successRate),previousValue:t?tn(t.successRate):null,badge:(0,B.jsx)(V,{delta:e.successRateDelta,deltaPct:e.successRateDeltaPct,lowerIsBetter:!1,formatter:e=>`${(e*100).toFixed(1)}%`})}),(0,B.jsx)(H,{label:`Avg Duration`,value:en(e.avgDurationMs),previousValue:t?en(t.avgDurationMs):null,badge:(0,B.jsx)(V,{delta:e.avgDurationDelta,deltaPct:e.avgDurationDeltaPct,lowerIsBetter:!0,formatter:e=>en(e)})}),(0,B.jsx)(H,{label:`Total Tokens`,value:nn(e.totalTokens),previousValue:t?nn(t.totalTokens):null,badge:(0,B.jsx)(V,{delta:e.totalTokensDelta,deltaPct:e.totalTokensDeltaPct,lowerIsBetter:!0,formatter:e=>nn(e)})})]})}function on(){return on=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},on.apply(null,arguments)}function sn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function cn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?sn(Object(n),!0).forEach(function(t){ln(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):sn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function ln(e,t,n){return(t=un(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function un(e){var t=dn(e,`string`);return typeof t==`symbol`?t:t+``}function dn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var U=32,fn={align:`center`,iconSize:14,inactiveColor:`#ccc`,layout:`horizontal`,verticalAlign:`middle`,labelStyle:{}};function pn(e){if(typeof e==`object`&&e&&`strokeDasharray`in e)return String(e.strokeDasharray)}function mn(e){var{data:t,iconType:n,inactiveColor:r}=e,i=U/2,a=U/6,o=U/3,s=t.inactive?r:t.color,c=n??t.type;if(c===`none`)return null;if(c===`plainline`)return z.createElement(`line`,{strokeWidth:4,fill:`none`,stroke:s,strokeDasharray:pn(t.payload),x1:0,y1:i,x2:U,y2:i,className:`recharts-legend-icon`});if(c===`line`)return z.createElement(`path`,{strokeWidth:4,fill:`none`,stroke:s,d:`M0,${i}h${o}
2
2
  A${a},${a},0,1,1,${2*o},${i}
3
3
  H${U}M${2*o},${i}
4
4
  A${a},${a},0,1,1,${o},${i}`,className:`recharts-legend-icon`});if(c===`rect`)return z.createElement(`path`,{stroke:`none`,fill:s,d:`M0,${U/8}h${U}v${U*3/4}h${-U}z`,className:`recharts-legend-icon`});if(z.isValidElement(t.legendIcon)){var l=cn({},t);return delete l.legendIcon,z.cloneElement(t.legendIcon,l)}return z.createElement(fe,{fill:s,cx:i,cy:i,size:U,sizeType:`diameter`,type:c})}function hn(e){var{payload:t,iconSize:n,layout:r,formatter:i,inactiveColor:a,iconType:o,labelStyle:s}=e,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=R({"recharts-legend-item":!0,[`legend-item-${r}`]:!0,inactive:t.inactive});if(t.type===`none`)return null;var p=typeof s==`object`?cn({},s):{};p.color=t.inactive?a:p.color||t.color;var m=d?d(t.value,t,r):t.value;return z.createElement(`li`,on({className:f,style:l,key:`legend-item-${r}`},Ee(e,t,r)),z.createElement(Ye,{width:n,height:n,viewBox:c,style:u,"aria-label":`${m} legend icon`},z.createElement(mn,{data:t,iconType:o,inactiveColor:a})),z.createElement(`span`,{className:`recharts-legend-item-text`,style:p},m))})}var gn=e=>{var t=O(e,fn),{payload:n,layout:r,align:i}=t;if(!n||!n.length)return null;var a={padding:0,margin:0,textAlign:r===`horizontal`?i:`left`};return z.createElement(`ul`,{className:`recharts-default-legend`,style:a},z.createElement(hn,on({},t,{payload:n})))};function _n(){return D(be)}var vn=e(Ht()),yn=[`contextPayload`];function bn(){return bn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},bn.apply(null,arguments)}function xn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function W(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?xn(Object(n),!0).forEach(function(t){Sn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):xn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Sn(e,t,n){return(t=Cn(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Cn(e){var t=wn(e,`string`);return typeof t==`symbol`?t:t+``}function wn(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Tn(e,t){if(e==null)return{};var n,r,i=En(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function En(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Dn(e){return e.value}function On(e){var{contextPayload:t}=e,n=Tn(e,yn),r=_(t,e.payloadUniqBy,Dn),i=W(W({},n),{},{payload:r});return z.isValidElement(e.content)?z.cloneElement(e.content,i):typeof e.content==`function`?z.createElement(e.content,i):z.createElement(gn,i)}function kn(e,t,n,r,i,a){var{layout:o,align:s,verticalAlign:c}=t,l,u;return(!e||(e.left===void 0||e.left===null)&&(e.right===void 0||e.right===null))&&(l=s===`center`&&o===`vertical`?{left:((r||0)-a.width)/2}:s===`right`?{right:n&&n.right||0}:{left:n&&n.left||0}),(!e||(e.top===void 0||e.top===null)&&(e.bottom===void 0||e.bottom===null))&&(u=c===`middle`?{top:((i||0)-a.height)/2}:c===`bottom`?{bottom:n&&n.bottom||0}:{top:n&&n.top||0}),W(W({},l),u)}function An(e){var t=E();return(0,z.useEffect)(()=>{t(_e(e))},[t,e]),null}function jn(e){var t=E();return(0,z.useEffect)(()=>(t(p(e)),()=>{t(p({width:0,height:0}))}),[t,e]),null}function Mn(e,t,n,r){return e===`vertical`&&t!=null?{height:t}:e===`horizontal`?{width:n||r}:null}var Nn={align:`center`,iconSize:14,inactiveColor:`#ccc`,itemSorter:`value`,layout:`horizontal`,verticalAlign:`bottom`};function Pn(e){var t=O(e,Nn),n=_n(),r=ft(),i=tt(),{width:o,height:c,wrapperStyle:l,portal:u}=t,[d,f]=s([n]),p=a(),m=rt();if(p==null||m==null)return null;var h=p-(i?.left||0)-(i?.right||0),g=Mn(t.layout,c,o,h),_=u?l:W(W({position:`absolute`,width:g?.width||o||`auto`,height:g?.height||c||`auto`},kn(l,t,i,p,m,d)),l),v=u??r;return v==null||n==null?null:(0,vn.createPortal)(z.createElement(`div`,{className:`recharts-legend-wrapper`,style:_,ref:f},z.createElement(An,{layout:t.layout,align:t.align,verticalAlign:t.verticalAlign,itemSorter:t.itemSorter}),!u&&z.createElement(jn,{width:d.width,height:d.height}),z.createElement(On,bn({},t,g,{margin:i,chartWidth:p,chartHeight:m,contextPayload:n}))),v)}var G=z.memo(Pn,At);G.displayName=`Legend`;var Fn=[`points`,`className`,`baseLinePoints`,`connectNulls`],In;function K(){return K=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},K.apply(null,arguments)}function Ln(e,t){if(e==null)return{};var n,r,i=Rn(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Rn(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function zn(e,t){return t||=e.slice(0),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var Bn=e=>e!=null&&e.x===+e.x&&e.y===+e.y,Vn=function(){var e=arguments.length>0&&arguments[0]!==void 0?arguments[0]:[],t=[[]];e.forEach(e=>{var n=t[t.length-1];Bn(e)?n&&n.push(e):n&&n.length>0&&t.push([])});var n=e[0],r=t[t.length-1];Bn(n)&&r&&r.push(n);var i=t[t.length-1];return i&&i.length<=0&&(t=t.slice(0,-1)),t},q=(e,t)=>{var n=Vn(e);t&&(n=[n.reduce((e,t)=>[...e,...t],[])]);var r=n.map(e=>e.reduce((e,t,n)=>lt(In||=zn([``,``,``,`,`,``]),e,n===0?`M`:`L`,t.x,t.y),``)).join(``);return n.length===1?`${r}Z`:r},Hn=(e,t,n)=>{var r=q(e,n);return`${r.slice(-1)===`Z`?r.slice(0,-1):r}L${q(Array.from(t).reverse(),n).slice(1)}`},Un=e=>{var{points:t,className:n,baseLinePoints:r,connectNulls:i}=e,a=Ln(e,Fn);if(!t||!t.length)return null;var o=R(`recharts-polygon`,n);if(r&&r.length){var s=a.stroke&&a.stroke!==`none`,c=Hn(t,r,i);return z.createElement(`g`,{className:o},z.createElement(`path`,K({},qe(a),{fill:c.slice(-1)===`Z`?a.fill:`none`,stroke:`none`,d:c})),s?z.createElement(`path`,K({},qe(a),{fill:`none`,d:q(t,i)})):null,s?z.createElement(`path`,K({},qe(a),{fill:`none`,d:q(r,i)})):null)}var l=q(t,i);return z.createElement(`path`,K({},qe(a),{fill:l.slice(-1)===`Z`?a.fill:`none`,className:o,d:l}))},Wn=e=>e.graphicalItems.polarItems,Gn=y([Wn,F,y([j,Re],Ue)],Te),Kn=y([y([Gn],Se),Ke],S),qn=y([Kn,F,Gn],g);y([Kn,F,Gn],(e,t,n)=>n.length>0?e.flatMap(e=>n.flatMap(n=>({value:T(e,t.dataKey??n.dataKey),errorDomain:[]}))).filter(Boolean):t?.dataKey==null?e.map(e=>({value:e,errorDomain:[]})):e.map(e=>({value:T(e,t.dataKey),errorDomain:[]})));var Jn=()=>void 0,Yn=y([F,ce,Kn,qn,Ve,j,y([F,_t,$e,Jn,y([Kn,F,Gn,Ct,j],Ce),Jn,ce,j],n)],ee);y([Me,y([F,Yn,y([Yn,ut,Me],de),j],mt)],bt);function Xn(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Zn(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xn(Object(n),!0).forEach(function(t){Qn(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xn(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qn(e,t,n){return(t=$n(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $n(e){var t=er(e,`string`);return typeof t==`symbol`?t:t+``}function er(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var tr=y([Wn,(e,t)=>t],(e,t)=>e.filter(e=>e.type===`pie`).find(e=>e.id===t)),nr=[],rr=(e,t,n)=>n?.length===0?nr:n,ir=y([Ke,tr,rr],(e,t,n)=>{var{chartData:r}=e;if(t!=null){var i=t?.data!=null&&t.data.length>0?t.data:r;if((!i||!i.length)&&n!=null&&(i=n.map(e=>Zn(Zn({},t.presentationProps),e.props))),i!=null)return i}}),ar=y([ir,tr,rr],(e,t,n)=>{if(!(e==null||t==null))return e.map((e,r)=>{var i,a=T(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:re(a,t.dataKey),color:o,payload:e,type:t.legendType}})}),or=y([ir,tr,rr,oe],(e,t,n,r)=>{if(!(t==null||e==null))return Ar({offset:r,pieSettings:t,displayedData:e,cells:n})}),sr=e(yt()),cr=[`key`],lr=[`onMouseEnter`,`onClick`,`onMouseLeave`],ur=[`id`],dr=[`id`];function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(null,arguments)}function fr(e,t){if(e==null)return{};var n,r,i=pr(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function pr(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function mr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?mr(Object(n),!0).forEach(function(t){hr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):mr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function hr(e,t,n){return(t=gr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function gr(e){var t=_r(e,`string`);return typeof t==`symbol`?t:t+``}function _r(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function vr(e){var t=(0,z.useMemo)(()=>nt(e.children,m),[e.children]),n=D(n=>ar(n,e.id,t));return n==null?null:z.createElement(me,{legendPayload:n})}function yr(e){if(!(e==null||typeof e==`boolean`||typeof e==`function`)){if(z.isValidElement(e)){var t=e.props?.fill;return typeof t==`string`?t:void 0}var{fill:n}=e;return typeof n==`string`?n:void 0}}var br=z.memo(e=>{var{dataKey:t,nameKey:n,sectors:r,stroke:i,strokeWidth:a,fill:o,name:s,hide:l,tooltipType:u,id:d,activeShape:f}=e,p=yr(f),m={dataDefinedOnItem:r.map(e=>{var t=e.tooltipPayload;return p==null||t==null?t:t.map(e=>Y(Y({},e),{},{color:p,fill:p}))}),getPosition:e=>r[Number(e)]?.tooltipPosition,settings:{stroke:i,strokeWidth:a,fill:o,dataKey:t,nameKey:n,name:re(s,t),hide:l,type:u,color:o,unit:``,graphicalItemId:d}};return z.createElement(c,{tooltipEntrySettings:m})}),xr=(e,t)=>e>t?`start`:e<t?`end`:`middle`,Sr=(e,t,n)=>r(typeof t==`function`?t(e):t,n,n*.8),Cr=(e,t,n)=>{var{top:i,left:a,width:o,height:s}=t,c=ot(o,s);return{cx:a+r(e.cx,o,o/2),cy:i+r(e.cy,s,s/2),innerRadius:r(e.innerRadius,c,0),outerRadius:Sr(n,e.outerRadius,c),maxRadius:e.maxRadius||Math.sqrt(o*o+s*s)/2}},wr=(e,t)=>I(t-e)*Math.min(Math.abs(t-e),360),Tr=(e,t)=>{if(z.isValidElement(e))return z.cloneElement(e,t);if(typeof e==`function`)return e(t);var n=R(`recharts-pie-label-line`,typeof e==`boolean`?``:e.className),{key:r}=t,i=fr(t,cr);return z.createElement(Nt,J({},i,{type:`linear`,className:n}))},Er=(e,t,n)=>{if(z.isValidElement(e))return z.cloneElement(e,t);var r=n;if(typeof e==`function`&&(r=e(t),z.isValidElement(r)))return r;var a=R(`recharts-pie-label-text`,i(e));return z.createElement(ae,J({},t,{alignmentBaseline:`middle`,className:a}),r)};function Dr(e){var{sectors:t,props:n,showLabels:r}=e,{label:i,labelLine:a,dataKey:o}=n;if(!r||!i||!t)return null;var s=Oe(n),c=Dt(i),l=Dt(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=Xe(e.cx,e.cy,e.outerRadius+u,n),d=Y(Y(Y(Y({},s),e),{},{stroke:`none`},c),{},{index:t,textAnchor:xr(r.x,e.cx)},r),f=Y(Y(Y(Y({},s),e),{},{fill:`none`,stroke:e.fill},l),{},{index:t,points:[Xe(e.cx,e.cy,e.outerRadius,n),r],key:`line`});return z.createElement(Lt,{zIndex:Et.label,key:`label-${e.startAngle}-${e.endAngle}-${e.midAngle}-${t}`},z.createElement(N,null,a&&Tr(a,f),Er(i,d,T(e,o))))});return z.createElement(N,{className:`recharts-pie-labels`},d)}function Or(e){var{sectors:t,props:n,showLabels:r}=e,{label:i}=n;return typeof i==`object`&&i&&`position`in i?z.createElement(et,{label:i}):z.createElement(Dr,{sectors:t,props:n,showLabels:r})}function kr(e){var{sectors:t,activeShape:n,inactiveShape:r,allOtherPieProps:i,shape:a,id:s}=e,c=D(v),l=D(o),d=D(ye),{onMouseEnter:p,onClick:m,onMouseLeave:g}=i,_=fr(i,lr),y=ge(p,i.dataKey,s),b=f(g),S=kt(m,i.dataKey,s);return t==null||t.length===0?null:z.createElement(z.Fragment,null,t.map((e,o)=>{if(e?.startAngle===0&&e?.endAngle===0&&t.length!==1)return null;var f=d==null||d===s,p=String(o)===c&&(l==null||i.dataKey===l)&&f,m=n&&p?n:c?r:null,g=Y(Y({},e),{},{stroke:e.stroke,tabIndex:-1,[x]:o,[h]:s});return z.createElement(N,J({key:`sector-${e?.startAngle}-${e?.endAngle}-${e.midAngle}-${o}`,tabIndex:-1,className:`recharts-pie-sector`},Ee(_,e,o),{onMouseEnter:y(e,o),onMouseLeave:b(e,o),onClick:S(e,o)}),z.createElement(u,J({option:a??m,index:o,shapeType:`sector`,isActive:p},g)))}))}function Ar(e){var{pieSettings:t,displayedData:n,cells:r,offset:i}=e,{cornerRadius:a,startAngle:o,endAngle:s,dataKey:c,nameKey:l,tooltipType:u}=t,d=Math.abs(t.minAngle),f=wr(o,s),p=Math.abs(f),m=n.length<=1?0:t.paddingAngle??0,h=n.filter(e=>T(e,c,0)!==0).length,g=(p>=360?h:h-1)*m,_=p-h*d-g,v=n.reduce((e,t)=>{var n=T(t,c,0);return e+(st(n)?n:0)},0),y;if(v>0){var b;y=n.map((e,n)=>{var s=T(e,c,0),p=T(e,l,n),h=Cr(t,i,e),g=(st(s)?s:0)/v,y,x=Y(Y({},e),r&&r[n]&&r[n].props),S=x!=null&&`fill`in x&&typeof x.fill==`string`?x.fill:t.fill;y=n?b.endAngle+I(f)*m*(s===0?0:1):o;var C=y+I(f)*((s===0?0:d)+g*_),ee=(y+C)/2,te=(h.innerRadius+h.outerRadius)/2,ne=[{name:p,value:s,payload:x,dataKey:c,type:u,color:S,fill:S,graphicalItemId:t.id}],re=Xe(h.cx,h.cy,te,ee);return b=Y(Y(Y(Y({},t.presentationProps),{},{percent:g,cornerRadius:typeof a==`string`?parseFloat(a):a,name:p,tooltipPayload:ne,midAngle:ee,middleRadius:te,tooltipPosition:re},x),h),{},{value:s,dataKey:c,startAngle:y,endAngle:C,payload:x,paddingAngle:I(f)*m}),b})}return y}function jr(e){var{showLabels:t,sectors:n,children:r}=e,i=(0,z.useMemo)(()=>!t||!n?[]:n.map(e=>({value:e.value,payload:e.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:e.cx,cy:e.cy,innerRadius:e.innerRadius,outerRadius:e.outerRadius,startAngle:e.startAngle,endAngle:e.endAngle,clockWise:!1},fill:e.fill})),[n,t]);return z.createElement(ie,{value:t?i:void 0},r)}function Mr(e){var{props:t,previousSectorsRef:n,id:r}=e,{sectors:i,isAnimationActive:a,animationBegin:o,animationDuration:s,animationEasing:c,activeShape:l,inactiveShape:u,onAnimationStart:d,onAnimationEnd:f}=t,p=ke(t,`recharts-pie-`),m=n.current,[h,g]=(0,z.useState)(!1),_=(0,z.useCallback)(()=>{typeof f==`function`&&f(),g(!1)},[f]),v=(0,z.useCallback)(()=>{typeof d==`function`&&d(),g(!0)},[d]);return z.createElement(jr,{showLabels:!h,sectors:i},z.createElement(Ot,{animationId:p,begin:o,duration:s,isActive:a,easing:c,onAnimationStart:v,onAnimationEnd:_,key:p},e=>{var a=[],o=(i&&i[0])?.startAngle??0;return i?.forEach((t,n)=>{var r=m&&m[n],i=n>0?(0,sr.default)(t,`paddingAngle`,0):0;if(r){var s=He(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=He(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(N,null,z.createElement(kr,{sectors:a,activeShape:l,inactiveShape:u,allOtherPieProps:t,shape:t.shape,id:r}))}),z.createElement(Or,{showLabels:!h,sectors:i,props:t}),t.children)}var Nr={animationBegin:400,animationDuration:1500,animationEasing:`ease`,cx:`50%`,cy:`50%`,dataKey:`value`,endAngle:360,fill:`#808080`,hide:!1,innerRadius:0,isAnimationActive:`auto`,label:!1,labelLine:!0,legendType:`rect`,minAngle:0,nameKey:`name`,outerRadius:`80%`,paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:`#fff`,zIndex:Et.area};function Pr(e){var{id:t}=e,n=fr(e,ur),{hide:r,className:i,rootTabIndex:a}=e,o=(0,z.useMemo)(()=>nt(e.children,m),[e.children]),s=D(e=>or(e,t,o)),c=(0,z.useRef)(null),l=R(`recharts-pie`,i);return r||s==null?(c.current=null,z.createElement(N,{tabIndex:a,className:l})):z.createElement(Lt,{zIndex:e.zIndex},z.createElement(br,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:s,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t,activeShape:e.activeShape}),z.createElement(N,{tabIndex:a,className:l},z.createElement(Mr,{props:Y(Y({},n),{},{sectors:s}),previousSectorsRef:c,id:t})))}function Fr(e){var t=O(e,Nr),{id:n}=t,r=fr(t,dr),i=Oe(r);return z.createElement(jt,{id:n,type:`pie`},e=>z.createElement(z.Fragment,null,z.createElement(Ne,{type:`pie`,id:e,data:r.data,dataKey:r.dataKey,hide:r.hide,angleAxisId:0,radiusAxisId:0,name:r.name,nameKey:r.nameKey,tooltipType:r.tooltipType,legendType:r.legendType,fill:r.fill,cx:r.cx,cy:r.cy,startAngle:r.startAngle,endAngle:r.endAngle,paddingAngle:r.paddingAngle,minAngle:r.minAngle,innerRadius:r.innerRadius,outerRadius:r.outerRadius,cornerRadius:r.cornerRadius,presentationProps:i,maxRadius:t.maxRadius}),z.createElement(vr,J({},r,{id:e})),z.createElement(Pr,J({},r,{id:e}))))}var Ir=Fr;Ir.displayName=`Pie`;var Lr={begin:0,duration:1e3,easing:`ease`,isActive:!0,canBegin:!0,onAnimationEnd:()=>{},onAnimationStart:()=>{}};function Rr(e){var t=O(e,Lr),{animationId:n,from:r,to:i,attributeName:a,isActive:o,canBegin:s,duration:c,easing:u,begin:d,onAnimationEnd:f,onAnimationStart:p,children:m}=t,h=he(),g=o===`auto`?!l.isSsr&&!h:o,_=It(n+a,t.animationManager),[v,y]=(0,z.useState)(()=>g?r:i),b=(0,z.useRef)(!1),x=(0,z.useCallback)(()=>{y(r),p()},[r,p]);return(0,z.useEffect)(()=>{if(!g||!s)return Qe;b.current=!0;var e=_.subscribe(y);return _.start([x,d,i,c,f]),()=>{_.stop(),e&&e(),f()}},[g,s,c,u,d,x,f,_,i,r]),g?s&&b.current?m({transition:Fe([a],c,u),[a]:v}):m({[a]:r}):m({[a]:i})}function zr(e){var t=E();return(0,z.useEffect)(()=>{t(dt(e))},[t,e]),null}var Br=[`layout`];function Vr(){return Vr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Vr.apply(null,arguments)}function Hr(e,t){if(e==null)return{};var n,r,i=Ur(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Ur(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function Wr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Gr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Wr(Object(n),!0).forEach(function(t){Kr(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Wr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Kr(e,t,n){return(t=qr(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function qr(e){var t=Jr(e,`string`);return typeof t==`symbol`?t:t+``}function Jr(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Yr=Gr({accessibilityLayer:!0,stackOffset:`none`,barCategoryGap:`10%`,barGap:4,margin:{top:5,right:5,bottom:5,left:5},reverseStackOrder:!1,syncMethod:`index`,layout:`radial`,responsive:!1,cx:`50%`,cy:`50%`,innerRadius:0,outerRadius:`80%`},We),Xr=(0,z.forwardRef)(function(e,t){var n=O(e.categoricalChartProps,Yr),{layout:r}=n,i=Hr(n,Br),{chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:s,tooltipPayloadSearcher:c}=e,l={chartName:a,defaultTooltipEventType:o,validateTooltipEventTypes:s,tooltipPayloadSearcher:c,eventEmitter:void 0};return z.createElement(ze,{preloadedState:{options:l},reduxStoreName:n.id??a},z.createElement(Pt,{chartData:n.data}),z.createElement(wt,{layout:r,margin:n.margin}),z.createElement(Ie,{throttleDelay:n.throttleDelay,throttledEvents:n.throttledEvents}),z.createElement(it,{baseValue:void 0,accessibilityLayer:n.accessibilityLayer,barCategoryGap:n.barCategoryGap,maxBarSize:n.maxBarSize,stackOffset:n.stackOffset,barGap:n.barGap,barSize:n.barSize,syncId:n.syncId,syncMethod:n.syncMethod,className:n.className,reverseStackOrder:n.reverseStackOrder}),z.createElement(zr,{cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius}),z.createElement(ct,Vr({},i,{ref:t})))});function Zr(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Qr(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Zr(Object(n),!0).forEach(function(t){$r(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Zr(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function $r(e,t,n){return(t=ei(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function ei(e){var t=ti(e,`string`);return typeof t==`symbol`?t:t+``}function ti(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var ni=[`item`],ri=Qr(Qr({},Yr),{},{layout:`centric`,startAngle:0,endAngle:360}),ii=(0,z.forwardRef)((e,t)=>{var n=O(e,ri);return z.createElement(Xr,{chartName:`PieChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:ni,tooltipPayloadSearcher:ne,categoricalChartProps:n,ref:t})}),ai=t((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});function t(e){return typeof Buffer<`u`&&Buffer.isBuffer(e)}e.isBuffer=t})),oi=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})),si=t((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=ht();function n(e){return t.isTypedArray(e)}e.isTypedArray=n})),ci=t((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=pt();function n(e){let n=t.toFinite(e),r=n%1;return r?n-r:n}e.toInteger=n})),li=t((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=ci();function n(e,n){if(e=t.toInteger(e),e<1||!Number.isSafeInteger(e))return[];let r=Array(e);for(let t=0;t<e;t++)r[t]=typeof n==`function`?n(t):t;return r}e.times=n})),ui=t((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=ai(),n=oi(),r=we(),i=si(),a=li();function o(e){if(e==null)return[];switch(typeof e){case`object`:case`function`:return r.isArrayLike(e)?l(e):n.isPrototype(e)?c(e):s(e);default:return s(Object(e))}}function s(e){let t=[];for(let n in e)t.push(n);return t}function c(e){return s(e).filter(e=>e!==`constructor`)}function l(e){let n=a.times(e.length,e=>`${e}`),r=new Set(n);t.isBuffer(e)&&(r.add(`offset`),r.add(`parent`)),i.isTypedArray(e)&&(r.add(`buffer`),r.add(`byteLength`),r.add(`byteOffset`));let o=s(e).filter(e=>!r.has(e));return Array.isArray(e)?[...n,...o]:[...n.filter(t=>Object.hasOwn(e,t)),...o]}e.keysIn=o})),di=t((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=Le(),n=Ge(),r=Be(),i=Tt(),a=at();function o(e,t){if(e==null)return!0;switch(typeof t){case`symbol`:case`number`:case`object`:if(Array.isArray(t))return s(e,t);if(typeof t==`number`?t=i.toKey(t):typeof t==`object`&&(t=Object.is(t?.valueOf(),-0)?`-0`:String(t)),n.isUnsafeProperty(t))return!1;if(e?.[t]===void 0)return!0;try{return delete e[t],!0}catch{return!1}case`string`:if(e?.[t]===void 0&&r.isDeepKey(t))return s(e,a.toPath(t));if(n.isUnsafeProperty(t))return!1;try{return delete e[t],!0}catch{return!1}}}function s(e,r){let i=r.length===1?e:t.get(e,r.slice(0,-1)),a=r[r.length-1];if(i?.[a]===void 0)return!0;if(n.isUnsafeProperty(a))return!1;try{return delete i[a],!0}catch{return!1}}e.unset=o})),fi=t((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=C();function n(e){let n=[];for(;e;)n.push(...t.getSymbols(e)),e=Object.getPrototypeOf(e);return n}e.getSymbolsIn=n})),pi=t((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=we();function n(e,n=1){let r=[],i=Math.floor(n);if(!t.isArrayLike(e))return r;let a=(e,t)=>{for(let n=0;n<e.length;n++){let o=e[n];t<i&&(Array.isArray(o)||o?.[Symbol.isConcatSpreadable]||typeof o==`object`&&o&&Object.prototype.toString.call(o)===`[object Arguments]`)?a(Array.isArray(o)?o:Array.from(o),t+1):r.push(o)}};return a(Array.from(e),0),r}e.flatten=n})),mi=t((e=>{Object.defineProperty(e,Symbol.toStringTag,{value:`Module`});var t=te(),n=ui(),r=di(),i=fi(),a=Be(),o=pi(),s=se();function c(e,...t){if(e==null)return{};t=o.flatten(t);let n=l(e,t);for(let e=0;e<t.length;e++){let i=t[e];switch(typeof i){case`object`:Array.isArray(i)||(i=Array.from(i));for(let e=0;e<i.length;e++){let t=i[e];r.unset(n,t)}break;case`string`:case`symbol`:case`number`:r.unset(n,i);break}}return n}function l(e,t){return t.some(e=>Array.isArray(e)||a.isDeepKey(e))?d(e):u(e)}function u(e){let t={},r=[...n.keysIn(e),...i.getSymbolsIn(e)];for(let n=0;n<r.length;n++){let i=r[n];t[i]=e[i]}return t}function d(e){let r={},a=[...n.keysIn(e),...i.getSymbolsIn(e)];for(let n=0;n<a.length;n++){let i=a[n];r[i]=t.cloneDeepWith(e[i],e=>{if(!s.isPlainObject(e))return e})}return r}e.omit=c})),hi=e(t(((e,t)=>{t.exports=mi().omit}))()),gi=[`width`,`height`,`className`,`style`,`children`,`type`];function _i(e,t){if(e==null)return{};var n,r,i=vi(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function vi(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function yi(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?yi(Object(n),!0).forEach(function(t){Q(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):yi(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Q(e,t,n){return(t=bi(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function bi(e){var t=xi(e,`string`);return typeof t==`symbol`?t:t+``}function xi(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Si=`value`;function Ci(e){return typeof e==`object`&&!!e&&`x`in e&&`y`in e&&`width`in e&&`height`in e&&typeof e.x==`number`&&typeof e.y==`number`&&typeof e.width==`number`&&typeof e.height==`number`}var wi=(e,t)=>{if(!(!e||!t))return(0,sr.default)(e,t)},Ti=function(e){return`${arguments.length>1&&arguments[1]!==void 0?arguments[1]:``}children[${e}]`},Ei={chartName:`Treemap`,defaultTooltipEventType:`item`,validateTooltipEventTypes:[`item`],tooltipPayloadSearcher:wi,eventEmitter:void 0},Di=e=>{var{depth:t,node:n,index:r,dataKey:i,nameKey:a,nestedActiveTooltipIndex:o}=e,s=t===0?``:Ti(r,o),{children:c}=n,l=t+1,u=c&&c.length?c.map((e,t)=>Di({depth:l,node:e,index:t,dataKey:i,nameKey:a,nestedActiveTooltipIndex:s})):null,d;if(u&&u.length)d=u.reduce((e,t)=>e+t.value,0);else{var f=n[i],p=typeof f==`number`?f:0;d=St(p)||p<=0?0:p}return Z(Z({},n),{},{children:u,name:T(n,a,``),[Si]:d,depth:t,index:r,tooltipIndex:s})},Oi=e=>({x:e.x,y:e.y,width:e.width,height:e.height}),ki=(e,t)=>{var n=t<0?0:t;return e.map(e=>{var t=e[Si]*n;return Z(Z({},e),{},{area:St(t)||t<=0?0:t})})},Ai=(e,t,n)=>{var r=t*t,i=e.area*e.area,{min:a,max:o}=e.reduce((e,t)=>({min:Math.min(e.min,t.area),max:Math.max(e.max,t.area)}),{min:1/0,max:0});return i?Math.max(r*o*n/i,i/(r*a*n)):1/0},ji=(e,t,n,r)=>{var i=t?Math.round(e.area/t):0;(r||i>n.height)&&(i=n.height);for(var a=n.x,o,s=0,c=e.length;s<c;s++)o=e[s],o!=null&&(o.x=a,o.y=n.y,o.height=i,o.width=Math.min(i?Math.round(o.area/i):0,n.x+n.width-a),a+=o.width);return o!=null&&(o.width+=n.x+n.width-a),Z(Z({},n),{},{y:n.y+i,height:n.height-i})},Mi=(e,t,n,r)=>{var i=t?Math.round(e.area/t):0;(r||i>n.width)&&(i=n.width);for(var a=n.y,o,s=0,c=e.length;s<c;s++)o=e[s],o!=null&&(o.x=n.x,o.y=a,o.width=i,o.height=Math.min(i?Math.round(o.area/i):0,n.y+n.height-a),a+=o.height);return o&&(o.height+=n.y+n.height-a),Z(Z({},n),{},{x:n.x+i,width:n.width-i})},Ni=(e,t,n,r)=>t===n.width?ji(e,t,n,r):Mi(e,t,n,r),Pi=(e,t)=>{var{children:n}=e;if(n&&n.length){var r=Oi(e),i=[],a=1/0,o,s,c=Math.min(r.width,r.height),l=ki(n,r.width*r.height/e[Si]),u=l.slice();for(i.area=0;u.length>0;)[o]=u,o!=null&&(i.push(o),i.area+=o.area,s=Ai(i,c,t),s<=a?(u.shift(),a=s):(i.area-=i.pop()?.area??0,r=Ni(i,c,r,!1),c=Math.min(r.width,r.height),i.length=i.area=0,a=1/0));return i.length&&=(r=Ni(i,c,r,!0),i.area=0),Z(Z({},e),{},{children:l.map(e=>Pi(e,t))})}return e},Fi=Z({aspectRatio:.5*(1+Math.sqrt(5)),dataKey:`value`,nameKey:`name`,type:`flat`,isAnimationActive:`auto`,isUpdateAnimationActive:`auto`,animationBegin:0,animationDuration:1500,animationEasing:`linear`},We),Ii={isAnimationFinished:!1,formatRoot:null,currentRoot:void 0,nestIndex:[],prevAspectRatio:Fi.aspectRatio,prevDataKey:Fi.dataKey};function Li(e){var{content:t,nodeProps:n,type:r,colorPanel:i,onMouseEnter:a,onMouseLeave:o,onClick:s}=e;if(z.isValidElement(t))return z.createElement(N,{onMouseEnter:a,onMouseLeave:o,onClick:s},z.cloneElement(t,n));if(typeof t==`function`)return z.createElement(N,{onMouseEnter:a,onMouseLeave:o,onClick:s},t(n));var{x:c,y:l,width:u,height:d,index:f}=n,p=null;u>10&&d>10&&n.children&&r===`nest`&&(p=z.createElement(Un,{points:[{x:c+2,y:l+d/2},{x:c+6,y:l+d/2+3},{x:c+2,y:l+d/2+6}]}));var m=null,h=le(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||ue;return z.createElement(`g`,null,z.createElement(Je,X({fill:n.depth<2?g[f%g.length]:`rgba(255,255,255,0)`,stroke:`#fff`},(0,hi.default)(n,[`children`]),{onMouseEnter:a,onMouseLeave:o,onClick:s,"data-recharts-item-index":n.tooltipIndex})),p,m)}function Ri(e){var t=E(),n={x:e.nodeProps.x+e.nodeProps.width/2,y:e.nodeProps.y+e.nodeProps.height/2};return z.createElement(Li,X({},e,{onMouseEnter:()=>{t(xe({activeIndex:e.nodeProps.tooltipIndex,activeDataKey:e.dataKey,activeCoordinate:n,activeGraphicalItemId:e.id}))},onMouseLeave:()=>{},onClick:()=>{t(ve({activeIndex:e.nodeProps.tooltipIndex,activeDataKey:e.dataKey,activeCoordinate:n,activeGraphicalItemId:e.id}))}}))}var zi=z.memo(e=>{var{dataKey:t,nameKey:n,stroke:r,fill:i,currentRoot:a,id:o}=e,s={dataDefinedOnItem:a,getPosition:Qe,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(c,{tooltipEntrySettings:s})}),Bi={top:0,right:0,bottom:0,left:0};function Vi(e){var{content:t,nodeProps:n,isLeaf:r,treemapProps:i,onNestClick:a}=e,{id:o,isAnimationActive:s,animationBegin:c,animationDuration:l,animationEasing:u,isUpdateAnimationActive:d,type:f,colorPanel:p,dataKey:m,onAnimationStart:h,onAnimationEnd:g,onMouseEnter:_,onClick:v,onMouseLeave:y}=i,{width:b,height:x,x:S,y:C}=n,ee=-S-b,te=0,ne=e=>{(r||f===`nest`)&&typeof _==`function`&&_(n,e)},re=e=>{(r||f===`nest`)&&typeof y==`function`&&y(n,e)},ie=()=>{f===`nest`&&a(n),(r||f===`nest`)&&typeof v==`function`&&v(n)},w=(0,z.useCallback)(()=>{typeof g==`function`&&g()},[g]),ae=(0,z.useCallback)(()=>{typeof h==`function`&&h()},[h]);return z.createElement(Rr,{animationId:`treemap-${n.tooltipIndex}`,from:`translate(${ee}px, ${te}px)`,to:`translate(0, 0)`,attributeName:`transform`,begin:c,easing:u,isActive:s,duration:l,onAnimationStart:ae,onAnimationEnd:w},e=>z.createElement(N,{onMouseEnter:ne,onMouseLeave:re,onClick:ie,style:Z(Z({},e),{},{transformOrigin:`${S} ${C}`})},z.createElement(Ri,{id:o,content:t,dataKey:m,nodeProps:Z(Z({},n),{},{isAnimationActive:s,isUpdateAnimationActive:!d,width:b,height:x,x:S,y:C}),type:f,colorPanel:p})))}var Hi=class extends z.PureComponent{constructor(){super(...arguments),Q(this,`state`,Z({},Ii)),Q(this,`handleClick`,e=>{var{onClick:t,type:n}=this.props;if(n===`nest`&&e.children){var{width:r,height:i,dataKey:a,nameKey:o,aspectRatio:s}=this.props,c=Di({depth:0,node:Z(Z({},e),{},{x:0,y:0,width:r,height:i}),index:0,dataKey:a,nameKey:o,nestedActiveTooltipIndex:e.tooltipIndex}),l=Pi(c,s),{nestIndex:u}=this.state;u.push(e),this.setState({formatRoot:l,currentRoot:c,nestIndex:u})}t&&t(e)}),Q(this,`handleTouchMove`,e=>{var t=e.touches[0];if(t!=null){var n=document.elementFromPoint(t.clientX,t.clientY);if(!(!n||!n.getAttribute||this.state.formatRoot==null)){var r=n.getAttribute(`data-recharts-item-index`),i=wi(this.state.formatRoot,r);if(Ci(i)){var{dataKey:a,dispatch:o}=this.props;o(xe({activeIndex:r,activeDataKey:a,activeCoordinate:{x:i.x+i.width/2,y:i.y+i.height/2},activeGraphicalItemId:this.props.id}))}}}})}static getDerivedStateFromProps(e,t){if(e.data!==t.prevData||e.type!==t.prevType||e.width!==t.prevWidth||e.height!==t.prevHeight||e.dataKey!==t.prevDataKey||e.aspectRatio!==t.prevAspectRatio){var n=Di({depth:0,node:{children:e.data,x:0,y:0,width:e.width,height:e.height},index:0,dataKey:e.dataKey,nameKey:e.nameKey}),r=Pi(n,e.aspectRatio);return Z(Z({},t),{},{formatRoot:r,currentRoot:n,nestIndex:[n],prevAspectRatio:e.aspectRatio,prevData:e.data,prevWidth:e.width,prevHeight:e.height,prevDataKey:e.dataKey,prevType:e.type})}return null}handleNestIndex(e,t){var{nestIndex:n}=this.state,{width:r,height:i,dataKey:a,nameKey:o,aspectRatio:s}=this.props,c=Pi(Di({depth:0,node:Z(Z({},e),{},{x:0,y:0,width:r,height:i}),index:0,dataKey:a,nameKey:o,nestedActiveTooltipIndex:e.tooltipIndex}),s);n=n.slice(0,t+1),this.setState({formatRoot:c,currentRoot:e,nestIndex:n})}renderNode(e,t){var{content:n,type:r}=this.props,i=Z(Z(Z({},Oe(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(N,{key:`recharts-treemap-node-${i.x}-${i.y}-${i.name}`,className:`recharts-treemap-depth-${t.depth}`},z.createElement(Vi,{isLeaf:a,content:n,nodeProps:i,treemapProps:this.props,onNestClick:this.handleClick}),t.children&&t.children.length?t.children.map(e=>this.renderNode(t,e)):null)}renderAllNodes(){var{formatRoot:e}=this.state;return e?this.renderNode(e,e):null}renderNestIndex(){var{nameKey:e,nestIndexContent:t}=this.props,{nestIndex:n}=this.state;return z.createElement(`div`,{className:`recharts-treemap-nest-index-wrapper`,style:{marginTop:`8px`,textAlign:`center`}},n.map((n,r)=>{var i=(0,sr.default)(n,e,`root`),a=typeof i==`string`?i:`root`,o;return z.isValidElement(t)&&(o=z.cloneElement(t,n,r)),o=typeof t==`function`?t(n,r):a,z.createElement(`div`,{onClick:this.handleNestIndex.bind(this,n,r),key:`nest-index-${je()}`,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=Oe(_i(e,gi));return z.createElement(z.Fragment,null,z.createElement(zi,{dataKey:this.props.dataKey,nameKey:this.props.nameKey,stroke:this.props.stroke,fill:this.props.fill,currentRoot:this.state.currentRoot,id:this.props.id}),z.createElement(Ye,X({},s,{width:t,height:o===`nest`?n-30:n,onTouchMove:this.handleTouchMove}),this.renderAllNodes(),a),o===`nest`&&this.renderNestIndex())}};Q(Hi,`displayName`,`Treemap`);function Ui(e){var t=E(),n=a(),r=rt();if(!Rt(n)||!Rt(r))return null;var{id:i}=e;return z.createElement(jt,{id:i,type:`treemap`},i=>z.createElement(Hi,X({},e,{id:i,width:n,height:r,dispatch:t})))}function Wi(e){var t=O(e,Fi),{className:n,style:r,width:i,height:a,throttleDelay:o,throttledEvents:s}=t,[c,l]=(0,z.useState)(null);return z.createElement(ze,{preloadedState:{options:Ei},reduxStoreName:t.className??`Treemap`},z.createElement(d,{margin:Bi}),z.createElement(Ie,{throttleDelay:o,throttledEvents:s}),z.createElement(vt,{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(pe.Provider,{value:c},z.createElement(Ui,t))))}function Gi({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,B.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]})}function Ki(e){try{return Pe(new Date(e),`MMM d`)}catch{return e}}function qi({data:e}){if(!(e.length>0&&e.some(e=>e.costUsd>0)))return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost Over Time`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No cost data for this period`})]});let t=Math.max(1,Math.floor(e.length/7)),n=e.filter((e,n)=>n%t===0).map(e=>e.date);return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost Over Time`}),(0,B.jsx)(w,{width:`100%`,height:220,children:(0,B.jsxs)(Ae,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,B.jsx)(L,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,B.jsx)(A,{dataKey:`date`,ticks:n,tickFormatter:Ki,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,B.jsx)(M,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,B.jsx)(b,{content:(0,B.jsx)(Gi,{})}),(0,B.jsx)(De,{type:`monotone`,dataKey:`costUsd`,stroke:P.purple,strokeWidth:2,dot:!1,activeDot:{r:3,fill:P.purple}})]})})]})}function Ji({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0];return(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`capitalize font-medium`,children:n.name}),(0,B.jsxs)(`p`,{className:`text-muted-foreground`,children:[n.value,` jobs`]})]})}function Yi({data:e}){if(e.length===0)return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Jobs by Status`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No jobs in this period`})]});let t=e.reduce((e,t)=>e+t.count,0);return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Jobs by Status`}),(0,B.jsx)(w,{width:`100%`,height:220,children:(0,B.jsxs)(ii,{children:[(0,B.jsx)(Ir,{data:e,dataKey:`count`,nameKey:`status`,cx:`50%`,cy:`50%`,innerRadius:60,outerRadius:90,paddingAngle:2,children:e.map(e=>(0,B.jsx)(m,{fill:gt[e.status]??`var(--color-muted-foreground)`},e.status))}),(0,B.jsx)(b,{content:(0,B.jsx)(Ji,{})}),(0,B.jsx)(G,{formatter:n=>{let r=e.find(e=>e.status===n),i=r?(r.count/t*100).toFixed(0):`0`;return(0,B.jsxs)(`span`,{className:`text-xs capitalize`,children:[n,` (`,r?.count??0,`, `,i,`%)`]})}})]})})]})}var Xi=[`<1m`,`1-3m`,`3-5m`,`5-10m`,`>10m`];function Zi(e){if(e===null)return`—`;let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${r}s`}function Qi({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,B.jsxs)(`p`,{className:`font-medium`,children:[t[0].value,` jobs`]})]})}function $i({data:e,percentiles:t}){let n=Xi.map(t=>({bucket:t,count:e.find(e=>e.bucket===t)?.count??0}));return n.some(e=>e.count>0)?(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Duration Distribution`}),(0,B.jsx)(w,{width:`100%`,height:180,children:(0,B.jsxs)(Ze,{data:n,margin:{top:4,right:8,left:0,bottom:0},children:[(0,B.jsx)(L,{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)(M,{allowDecimals:!1,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:30}),(0,B.jsx)(b,{content:(0,B.jsx)(Qi,{})}),(0,B.jsx)(k,{dataKey:`count`,fill:P.cyan,radius:[3,3,0,0]})]})}),(0,B.jsx)(`div`,{className:`flex items-center gap-3 mt-2`,children:[`p50`,`p75`,`p95`].map(e=>(0,B.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,B.jsxs)(`span`,{className:`text-[10px] text-muted-foreground uppercase`,children:[e,`:`]}),(0,B.jsx)(`span`,{className:`text-[10px] font-medium tabular-nums`,children:Zi(t[e])})]},e))})]}):(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Duration Distribution`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No duration data available`})]})}function ea({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`text-muted-foreground mb-1 font-mono truncate max-w-48`,children:n}),t.map(e=>(0,B.jsxs)(`p`,{style:{color:e.color},children:[e.name,`: `,e.value.toLocaleString()]},e.name))]})}function ta({data:e}){if(e.length===0)return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Token Efficiency`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No token data for this period`})]});let t=e.map(e=>({...e,name:e.command.length>20?`…${e.command.slice(-18)}`:e.command}));return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Token Efficiency`}),(0,B.jsx)(w,{width:`100%`,height:220,children:(0,B.jsxs)(Ze,{layout:`vertical`,data:t,margin:{top:4,right:8,left:0,bottom:0},children:[(0,B.jsx)(L,{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)(M,{type:`category`,dataKey:`name`,width:110,tick:{fontSize:9,fill:`var(--color-muted-foreground)`,fontFamily:`monospace`},axisLine:!1,tickLine:!1}),(0,B.jsx)(b,{content:(0,B.jsx)(ea,{})}),(0,B.jsx)(G,{formatter:e=>(0,B.jsx)(`span`,{className:`text-xs`,children:e})}),(0,B.jsx)(k,{dataKey:`tokensOut`,name:`Output tokens`,fill:P.purple,stackId:`a`,radius:[0,3,3,0]}),(0,B.jsx)(k,{dataKey:`tokensCacheRead`,name:`Cached tokens`,fill:P.cyan,stackId:`a`,radius:[0,3,3,0]})]})})]})}function na(e){return e===null?`—`:`$${e.toFixed(4)}`}function ra(e){if(e===null)return`—`;let t=Math.round(e/1e3),n=Math.floor(t/60),r=t%60;return n===0?`${r}s`:`${n}m ${r}s`}function ia({rate:e}){let t=(e*100).toFixed(0);return(0,B.jsxs)(`span`,{className:zt(`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)(Jt,{className:`w-3 h-3`}):(0,B.jsx)(Kt,{className:`w-3 h-3`}):(0,B.jsx)(Zt,{className:`w-3 h-3 opacity-40`})]})})}function aa({data:e}){let[t,n]=(0,z.useState)(`totalCostUsd`),[r,i]=(0,z.useState)(`desc`);function a(e){e===t?i(e=>e===`asc`?`desc`:`asc`):(n(e),i(`desc`))}let o=[...e].sort((e,n)=>{let i=e[t]??-1/0,a=n[t]??-1/0,o=typeof i==`string`?i.localeCompare(a):i-a;return r===`asc`?o:-o});return e.length===0?(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Command Performance`}),(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No command data for this period`})]}):(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Command Performance`}),(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-border/30`,children:[(0,B.jsx)($,{label:`Command`,sortKey:`command`,current:t,dir:r,onSort:a}),(0,B.jsx)($,{label:`Runs`,sortKey:`totalRuns`,current:t,dir:r,onSort:a}),(0,B.jsx)($,{label:`Success Rate`,sortKey:`successRate`,current:t,dir:r,onSort:a}),(0,B.jsx)($,{label:`Avg Cost`,sortKey:`avgCostUsd`,current:t,dir:r,onSort:a}),(0,B.jsx)($,{label:`Avg Duration`,sortKey:`avgDurationMs`,current:t,dir:r,onSort:a}),(0,B.jsx)($,{label:`Total Cost`,sortKey:`totalCostUsd`,current:t,dir:r,onSort:a})]})}),(0,B.jsx)(`tbody`,{children:o.map(e=>(0,B.jsxs)(`tr`,{className:`border-b border-border/20 hover:bg-accent/20 transition-colors`,children:[(0,B.jsx)(`td`,{className:`px-3 py-2 font-mono text-[10px] text-foreground`,children:e.command}),(0,B.jsx)(`td`,{className:`px-3 py-2 tabular-nums`,children:e.totalRuns}),(0,B.jsx)(`td`,{className:`px-3 py-2`,children:(0,B.jsx)(ia,{rate:e.successRate})}),(0,B.jsx)(`td`,{className:`px-3 py-2 tabular-nums`,children:na(e.avgCostUsd)}),(0,B.jsx)(`td`,{className:`px-3 py-2 tabular-nums`,children:ra(e.avgDurationMs)}),(0,B.jsx)(`td`,{className:`px-3 py-2 tabular-nums font-medium`,children:na(e.totalCostUsd)})]},e.command))})]})})]})}function oa({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),t.map(e=>(0,B.jsxs)(`p`,{style:{color:e.color},children:[e.name,`: `,e.value]},e.name))]})}function sa(e){try{return Pe(new Date(e),`MMM d`)}catch{return e}}function ca({data:e}){if(!(e.length>0&&e.some(e=>e.completed+e.failed+e.canceled>0)))return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Daily Throughput`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No throughput data for this period`})]});let t=Math.max(1,Math.floor(e.length/7)),n=e.filter((e,n)=>n%t===0).map(e=>e.date);return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Daily Throughput`}),(0,B.jsx)(w,{width:`100%`,height:220,children:(0,B.jsxs)(Ze,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,B.jsx)(L,{strokeDasharray:`3 3`,stroke:`var(--color-border)`,vertical:!1}),(0,B.jsx)(A,{dataKey:`date`,ticks:n,tickFormatter:sa,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,B.jsx)(M,{allowDecimals:!1,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:30}),(0,B.jsx)(b,{content:(0,B.jsx)(oa,{})}),(0,B.jsx)(G,{formatter:e=>(0,B.jsx)(`span`,{className:`text-xs capitalize`,children:e})}),(0,B.jsx)(k,{dataKey:`completed`,name:`Completed`,stackId:`a`,fill:P.purple}),(0,B.jsx)(k,{dataKey:`failed`,name:`Failed`,stackId:`a`,fill:P.pink}),(0,B.jsx)(k,{dataKey:`canceled`,name:`Canceled`,stackId:`a`,fill:P.orange,radius:[3,3,0,0]})]})})]})}function la({x:e=0,y:t=0,width:n=0,height:r=0,name:i=``,size:a=0,colorIndex:o=0}){let s=xt[o%xt.length];return(0,B.jsxs)(`g`,{children:[(0,B.jsx)(`rect`,{x:e,y:t,width:n,height:r,style:{fill:s,fillOpacity:.8,stroke:`var(--color-background)`,strokeWidth:2},rx:4}),n>50&&r>30&&(0,B.jsxs)(B.Fragment,{children:[(0,B.jsx)(`text`,{x:e+6,y:t+16,fill:`var(--color-background)`,fontSize:10,fontFamily:`monospace`,style:{overflow:`hidden`},children:i.length>Math.floor(n/6)?i.slice(0,Math.floor(n/6)-1)+`…`:i}),r>45&&(0,B.jsxs)(`text`,{x:e+6,y:t+30,fill:`hsl(231 15% 18% / 0.7)`,fontSize:9,children:[`$`,a.toFixed(4)]})]})]})}function ua({active:e,payload:t}){if(!e||!t?.length)return null;let n=t[0].payload;return n?(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,B.jsx)(`p`,{className:`font-mono font-medium mb-1`,children:n.name}),(0,B.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Cost: $`,n.size.toFixed(4)]}),(0,B.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Jobs: `,n.jobCount]})]}):null}function da({data:e}){let t=e.filter(e=>e.totalCostUsd>0);if(t.length===0)return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost per Command`}),(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No cost data for this period`})]});let n=t.map((e,t)=>({name:e.command,size:e.totalCostUsd,jobCount:e.jobCount,colorIndex:t}));return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:`Cost per Command`}),(0,B.jsx)(w,{width:`100%`,height:220,children:(0,B.jsx)(Wi,{data:n,dataKey:`size`,content:(0,B.jsx)(la,{}),children:(0,B.jsx)(b,{content:(0,B.jsx)(ua,{})})})})]})}function fa({label:e,value:t}){return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-3 space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-[10px] text-muted-foreground uppercase tracking-wide`,children:e}),(0,B.jsx)(`p`,{className:`text-base font-semibold tabular-nums`,children:t})]})}function pa({data:e}){let t=e.costPerSuccess===null?`—`:`$${e.costPerSuccess.toFixed(4)}`,n=e.apiEfficiencyPct===null?`—`:`${e.apiEfficiencyPct.toFixed(0)}%`,r=`$${e.failureCostUsd.toFixed(4)}`;return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-4`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium`,children:`Bonus Metrics`}),(0,B.jsxs)(`div`,{className:`grid grid-cols-3 gap-3`,children:[(0,B.jsx)(fa,{label:`Cost per Success`,value:t}),(0,B.jsx)(fa,{label:`API Efficiency`,value:n}),(0,B.jsx)(fa,{label:`Failure Cost`,value:r})]}),(0,B.jsxs)(`div`,{children:[(0,B.jsx)(`h4`,{className:`text-xs font-medium text-muted-foreground mb-2`,children:`Model Breakdown`}),e.modelBreakdown.length===0?(0,B.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`No model data for this period`}):(0,B.jsx)(`div`,{className:`overflow-x-auto`,children:(0,B.jsxs)(`table`,{className:`w-full text-xs`,children:[(0,B.jsx)(`thead`,{children:(0,B.jsxs)(`tr`,{className:`border-b border-border/30`,children:[(0,B.jsx)(`th`,{className:`px-3 py-1.5 text-left text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Model`}),(0,B.jsx)(`th`,{className:`px-3 py-1.5 text-left text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Jobs`}),(0,B.jsx)(`th`,{className:`px-3 py-1.5 text-left text-[10px] font-medium text-muted-foreground uppercase tracking-wide`,children:`Total Cost`})]})}),(0,B.jsx)(`tbody`,{children:e.modelBreakdown.map(e=>(0,B.jsxs)(`tr`,{className:`border-b border-border/20`,children:[(0,B.jsx)(`td`,{className:`px-3 py-1.5 font-mono text-[10px]`,children:e.model}),(0,B.jsx)(`td`,{className:`px-3 py-1.5 tabular-nums`,children:e.jobCount}),(0,B.jsxs)(`td`,{className:`px-3 py-1.5 tabular-nums`,children:[`$`,e.totalCostUsd.toFixed(4)]})]},e.model))})]})})]})]})}var ma=[{key:`cost`,label:`Avg Cost ($)`,color:P.purple},{key:`duration`,label:`Avg Duration (min)`,color:P.cyan},{key:`successRate`,label:`Success Rate (%)`,color:P.green}];function ha({active:e,payload:t,label:n}){return!e||!t?.length?null:(0,B.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg space-y-1`,children:[(0,B.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),t.map(e=>(0,B.jsxs)(`p`,{style:{color:e.color},children:[e.name,`: `,(0,B.jsx)(`span`,{className:`font-medium`,children:e.value})]},e.name))]})}function ga(e){try{return Pe(new Date(e),`MMM d`)}catch{return e}}function _a({points:e}){let[t,n]=(0,z.useState)(new Set([`cost`,`successRate`])),r=e.some(e=>e.jobCount>0),i=e.map(e=>({date:e.date,cost:e.avgCostUsd===null?0:parseFloat(e.avgCostUsd.toFixed(4)),duration:e.avgDurationMs===null?0:parseFloat((e.avgDurationMs/6e4).toFixed(2)),successRate:parseFloat((e.successRate*100).toFixed(1)),jobCount:e.jobCount})),a=Math.max(1,Math.floor(e.length/7)),o=e.filter((e,t)=>t%a===0).map(e=>e.date);function s(e){n(t=>{let n=new Set(t);return n.has(e)?n.size>1&&n.delete(e):n.add(e),n})}return(0,B.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,B.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,B.jsx)(`h3`,{className:`text-sm font-medium`,children:`Performance Trends`}),(0,B.jsx)(`div`,{className:`flex items-center gap-2`,children:ma.map(e=>(0,B.jsxs)(`button`,{type:`button`,onClick:()=>s(e.key),className:`flex items-center gap-1 text-[10px] px-2 py-0.5 rounded transition-colors ${t.has(e.key)?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:[(0,B.jsx)(`span`,{className:`w-2 h-2 rounded-full inline-block shrink-0`,style:{background:e.color}}),e.label]},e.key))})]}),r?(0,B.jsx)(w,{width:`100%`,height:220,children:(0,B.jsxs)(Ae,{data:i,margin:{top:4,right:8,left:0,bottom:0},children:[(0,B.jsx)(L,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,B.jsx)(A,{dataKey:`date`,ticks:o,tickFormatter:ga,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,B.jsx)(M,{tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:40}),(0,B.jsx)(b,{content:(0,B.jsx)(ha,{})}),(0,B.jsx)(G,{wrapperStyle:{fontSize:`10px`,paddingTop:`8px`}}),t.has(`cost`)&&(0,B.jsx)(De,{type:`monotone`,dataKey:`cost`,name:`Avg Cost ($)`,stroke:P.purple,strokeWidth:2,dot:!1,activeDot:{r:3,fill:P.purple}}),t.has(`duration`)&&(0,B.jsx)(De,{type:`monotone`,dataKey:`duration`,name:`Avg Duration (min)`,stroke:P.cyan,strokeWidth:2,dot:!1,activeDot:{r:3,fill:P.cyan}}),t.has(`successRate`)&&(0,B.jsx)(De,{type:`monotone`,dataKey:`successRate`,name:`Success Rate (%)`,stroke:P.green,strokeWidth:2,dot:!1,activeDot:{r:3,fill:P.green}})]})}):(0,B.jsx)(`div`,{className:`h-[220px] flex items-center justify-center text-xs text-muted-foreground`,children:`No job data for this period`})]})}function va(){return(0,B.jsxs)(`div`,{className:`space-y-4`,children:[(0,B.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,B.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,B.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:Array.from({length:4}).map((e,t)=>(0,B.jsx)(`div`,{className:`h-[260px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,B.jsx)(`div`,{className:`h-[180px] rounded-lg border border-border/40 bg-card/50 animate-pulse`})]})}function ya({message:e,onRetry:t}){return(0,B.jsxs)(`div`,{className:`rounded-lg border border-red-400/30 bg-red-400/10 p-4 flex items-center justify-between`,children:[(0,B.jsx)(`p`,{className:`text-sm text-red-400`,children:e}),(0,B.jsxs)(`button`,{onClick:t,className:`flex items-center gap-1.5 h-7 px-3 rounded-md text-xs text-red-400 border border-red-400/30 hover:bg-red-400/10 transition-colors`,children:[(0,B.jsx)(Vt,{className:`w-3 h-3`}),`Retry`]})]})}var ba=[{value:`1d`,label:`1d`},{value:`7d`,label:`7d`},{value:`30d`,label:`30d`}];function xa(){let{activeProjectId:e}=Ut(),[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(`${Wt()}/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(`${Wt()}/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)(Ft,{period:t,from:r,to:a,onChange:b}),(0,B.jsx)(Xt,{baseUrl:`${Wt()}/analytics/export`,params:{period:t,...r?{from:r}:{},...a?{to:a}:{}}})]})]}),l&&(0,B.jsx)(va,{}),!l&&d&&(0,B.jsx)(ya,{message:`Failed to load analytics: ${d}`,onRetry:x}),!l&&!d&&s&&(0,B.jsxs)(`div`,{className:`space-y-6`,children:[(0,B.jsx)(an,{kpi:s.kpi}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,B.jsx)(qi,{data:s.costTimeline}),(0,B.jsx)(Yi,{data:s.statusBreakdown}),(0,B.jsx)($i,{data:s.durationHistogram,percentiles:s.durationPercentiles}),(0,B.jsx)(ta,{data:s.tokenEfficiency})]}),(0,B.jsx)(aa,{data:s.commandPerformance}),(0,B.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-4`,children:[(0,B.jsx)(ca,{data:s.dailyThroughput}),(0,B.jsx)(da,{data:s.costPerCommand})]}),(0,B.jsx)(pa,{data:s.bonusMetrics}),_&&(0,B.jsxs)(`div`,{children:[(0,B.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,B.jsx)(`h2`,{className:`text-sm font-medium`,children:`Trends`}),(0,B.jsx)(`div`,{className:`flex items-center gap-1`,children:ba.map(e=>(0,B.jsx)(`button`,{type:`button`,onClick:()=>g(e.value),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${h===e.value?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:e.label},e.value))})]}),(0,B.jsx)(_a,{points:_.points})]})]})]})}export{xa as default};
@@ -1,4 +1,4 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{t}from"./utils-nUaWT5EW.js";import{D as n,E as r,J as i,K as a,S as o,it as s,kt as c,nt as l,ut as u,x as d}from"./index-DxrdFIhh.js";import{t as f}from"./lib-DuYH34Ny.js";/* empty css */var p=e(c(),1),m=u();function h({categories:e,activeCategory:n,activeSlug:r,onSelect:a,onHome:o}){return(0,m.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,m.jsxs)(`button`,{onClick:o,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,m.jsx)(s,{className:`w-3.5 h-3.5`}),`Documentation`]}),(0,m.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,m.jsxs)(`div`,{children:[(0,m.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,m.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,m.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:`No docs yet`}):(0,m.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(o=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{onClick:()=>a(e.slug,o.slug),className:t(`w-full flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors text-left`,n===e.slug&&r===o.slug?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,m.jsx)(i,{className:`w-3 h-3 flex-shrink-0`}),o.title]})},o.slug))})]},e.slug))})]})}function g({categories:e,onSelect:t}){let n=e.reduce((e,t)=>e+t.docs.length,0);return(0,m.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,m.jsxs)(`div`,{className:`mb-8`,children:[(0,m.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:`Documentation`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n===0?`No documents yet. Add Markdown files to ~/.specrails/docs/ to get started.`:`${n} document${n===1?``:`s`} across ${e.filter(e=>e.docs.length>0).length} categories.`})]}),(0,m.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:`No documents in this category yet.`}):(0,m.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(n=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group text-left`,children:[(0,m.jsx)(i,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,m.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:n.title}),(0,m.jsx)(l,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))})]})}function _({category:e,slug:t,onNotFound:n}){let[r,i]=(0,p.useState)(null),[s,c]=(0,p.useState)(!0),[l,u]=(0,p.useState)(null);return(0,p.useEffect)(()=>{c(!0),u(null),i(null),fetch(`/api/docs/${e}/${t}`).then(async e=>{if(e.status===404){n();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{e&&i(e)}).catch(e=>{u(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>c(!1))},[e,t,n]),s?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(a,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):l?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(`p`,{className:`text-sm text-destructive`,children:l})}):r?(0,m.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,m.jsx)(`div`,{className:`prose prose-sm max-w-none
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{t}from"./utils-nUaWT5EW.js";import{D as n,E as r,J as i,K as a,S as o,it as s,kt as c,nt as l,ut as u,x as d}from"./index-IQAxy67u.js";import{t as f}from"./lib-Cxnd_4Zx.js";/* empty css */var p=e(c(),1),m=u();function h({categories:e,activeCategory:n,activeSlug:r,onSelect:a,onHome:o}){return(0,m.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,m.jsxs)(`button`,{onClick:o,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,m.jsx)(s,{className:`w-3.5 h-3.5`}),`Documentation`]}),(0,m.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,m.jsxs)(`div`,{children:[(0,m.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,m.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,m.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,m.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:`No docs yet`}):(0,m.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(o=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{onClick:()=>a(e.slug,o.slug),className:t(`w-full flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors text-left`,n===e.slug&&r===o.slug?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,m.jsx)(i,{className:`w-3 h-3 flex-shrink-0`}),o.title]})},o.slug))})]},e.slug))})]})}function g({categories:e,onSelect:t}){let n=e.reduce((e,t)=>e+t.docs.length,0);return(0,m.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,m.jsxs)(`div`,{className:`mb-8`,children:[(0,m.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:`Documentation`}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:n===0?`No documents yet. Add Markdown files to ~/.specrails/docs/ to get started.`:`${n} document${n===1?``:`s`} across ${e.filter(e=>e.docs.length>0).length} categories.`})]}),(0,m.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,m.jsxs)(`div`,{children:[(0,m.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,m.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:`No documents in this category yet.`}):(0,m.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(n=>(0,m.jsx)(`li`,{children:(0,m.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group text-left`,children:[(0,m.jsx)(i,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,m.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:n.title}),(0,m.jsx)(l,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))})]})}function _({category:e,slug:t,onNotFound:n}){let[r,i]=(0,p.useState)(null),[s,c]=(0,p.useState)(!0),[l,u]=(0,p.useState)(null);return(0,p.useEffect)(()=>{c(!0),u(null),i(null),fetch(`/api/docs/${e}/${t}`).then(async e=>{if(e.status===404){n();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{e&&i(e)}).catch(e=>{u(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>c(!1))},[e,t,n]),s?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(a,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):l?(0,m.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,m.jsx)(`p`,{className:`text-sm text-destructive`,children:l})}):r?(0,m.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,m.jsx)(`div`,{className:`prose prose-sm max-w-none
2
2
  prose-headings:text-foreground prose-headings:font-bold
3
3
  prose-p:text-foreground/90
4
4
  prose-a:text-dracula-purple prose-a:no-underline hover:prose-a:underline
@@ -1,4 +1,4 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{t}from"./utils-nUaWT5EW.js";import{Dt as n,Et as r,J as i,K as a,S as o,Tt as s,it as c,kt as l,nt as u,ut as d,x as f}from"./index-DxrdFIhh.js";import{t as p}from"./lib-DuYH34Ny.js";/* empty css */var m=e(l(),1),h=d();function g({categories:e,activeCategory:n,activeSlug:r}){return(0,h.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,h.jsxs)(s,{to:`/docs`,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,h.jsx)(c,{className:`w-3.5 h-3.5`}),`Documentation`]}),(0,h.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,h.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,h.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:`No docs yet`}):(0,h.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(a=>{let o=n===e.slug&&r===a.slug;return(0,h.jsx)(`li`,{children:(0,h.jsxs)(s,{to:`/docs/${e.slug}/${a.slug}`,className:t(`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors`,o?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,h.jsx)(i,{className:`w-3 h-3 flex-shrink-0`}),a.title]})},a.slug)})})]},e.slug))})]})}function _({categories:e}){let t=e.reduce((e,t)=>e+t.docs.length,0);return(0,h.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:`Documentation`}),(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t===0?`No documents yet. Add Markdown files to ~/.specrails/docs/ to get started.`:`${t} document${t===1?``:`s`} across ${e.filter(e=>e.docs.length>0).length} categories.`})]}),(0,h.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:`No documents in this category yet.`}):(0,h.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(t=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(s,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group`,children:[(0,h.jsx)(i,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,h.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:t.title}),(0,h.jsx)(u,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))})]})}function v({category:e,slug:t}){let[n,i]=(0,m.useState)(null),[s,c]=(0,m.useState)(!0),[l,u]=(0,m.useState)(null),d=r();return(0,m.useEffect)(()=>{c(!0),u(null),i(null),fetch(`/api/docs/${e}/${t}`).then(async e=>{if(e.status===404){d(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{e&&i(e)}).catch(e=>{u(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>c(!1))},[e,t,d]),s?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(a,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):l?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(`p`,{className:`text-sm text-destructive`,children:l})}):n?(0,h.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,h.jsx)(`div`,{className:`prose prose-sm max-w-none
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{t}from"./utils-nUaWT5EW.js";import{Dt as n,Et as r,J as i,K as a,S as o,Tt as s,it as c,kt as l,nt as u,ut as d,x as f}from"./index-IQAxy67u.js";import{t as p}from"./lib-Cxnd_4Zx.js";/* empty css */var m=e(l(),1),h=d();function g({categories:e,activeCategory:n,activeSlug:r}){return(0,h.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3`,children:[(0,h.jsxs)(s,{to:`/docs`,className:`flex items-center gap-2 mb-4 px-2 text-xs font-bold text-muted-foreground hover:text-foreground transition-colors`,children:[(0,h.jsx)(c,{className:`w-3.5 h-3.5`}),`Documentation`]}),(0,h.jsx)(`div`,{className:`space-y-4`,children:e.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsxs)(`div`,{className:`px-2 mb-1 flex items-center justify-between`,children:[(0,h.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,h.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,h.jsx)(`p`,{className:`px-2 text-xs text-muted-foreground italic`,children:`No docs yet`}):(0,h.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(a=>{let o=n===e.slug&&r===a.slug;return(0,h.jsx)(`li`,{children:(0,h.jsxs)(s,{to:`/docs/${e.slug}/${a.slug}`,className:t(`flex items-center gap-1.5 px-2 py-1 rounded-md text-xs transition-colors`,o?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`),children:[(0,h.jsx)(i,{className:`w-3 h-3 flex-shrink-0`}),a.title]})},a.slug)})})]},e.slug))})]})}function _({categories:e}){let t=e.reduce((e,t)=>e+t.docs.length,0);return(0,h.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6`,children:[(0,h.jsxs)(`div`,{className:`mb-8`,children:[(0,h.jsx)(`h1`,{className:`text-xl font-bold mb-2`,children:`Documentation`}),(0,h.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:t===0?`No documents yet. Add Markdown files to ~/.specrails/docs/ to get started.`:`${t} document${t===1?``:`s`} across ${e.filter(e=>e.docs.length>0).length} categories.`})]}),(0,h.jsx)(`div`,{className:`space-y-6`,children:e.map(e=>(0,h.jsxs)(`div`,{children:[(0,h.jsx)(`h2`,{className:`text-sm font-semibold text-muted-foreground uppercase tracking-wider mb-2`,children:e.name}),e.docs.length===0?(0,h.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:`No documents in this category yet.`}):(0,h.jsx)(`ul`,{className:`space-y-1`,children:e.docs.map(t=>(0,h.jsx)(`li`,{children:(0,h.jsxs)(s,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-2 px-3 py-2 rounded-md text-sm hover:bg-accent transition-colors group`,children:[(0,h.jsx)(i,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,h.jsx)(`span`,{className:`text-foreground group-hover:text-foreground`,children:t.title}),(0,h.jsx)(u,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))})]})}function v({category:e,slug:t}){let[n,i]=(0,m.useState)(null),[s,c]=(0,m.useState)(!0),[l,u]=(0,m.useState)(null),d=r();return(0,m.useEffect)(()=>{c(!0),u(null),i(null),fetch(`/api/docs/${e}/${t}`).then(async e=>{if(e.status===404){d(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{e&&i(e)}).catch(e=>{u(e instanceof Error?e.message:`Failed to load document`)}).finally(()=>c(!1))},[e,t,d]),s?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(a,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):l?(0,h.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,h.jsx)(`p`,{className:`text-sm text-destructive`,children:l})}):n?(0,h.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,h.jsx)(`div`,{className:`prose prose-sm max-w-none
2
2
  prose-headings:text-foreground prose-headings:font-bold
3
3
  prose-p:text-foreground/90
4
4
  prose-a:text-dracula-purple prose-a:no-underline hover:prose-a:underline
@@ -1 +1 @@
1
- import{r as e}from"./chunk-CilyBKbf.js";import{X as t,kt as n,ut as r}from"./index-DxrdFIhh.js";var i=e(n(),1),a=r();function o({baseUrl:e,params:n,label:r=`Export`}){let[o,s]=(0,i.useState)(!1),[c,l]=(0,i.useState)(!1),u=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(!o)return;function e(e){u.current&&!u.current.contains(e.target)&&s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);function d(t){return`${e}?${new URLSearchParams({format:t,...n}).toString()}`}function f(){s(!1),window.open(d(`csv`),`_blank`)}let p=(0,i.useCallback)(async()=>{s(!1),l(!0);try{let t=await fetch(d(`json`));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.split(`/`).filter(Boolean).pop()??`export`}.json`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] JSON download failed:`,e)}finally{l(!1)}},[e,n]);return(0,a.jsxs)(`div`,{ref:u,className:`relative`,children:[(0,a.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":o,disabled:c,onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,a.jsx)(t,{className:`w-3 h-3`}),c?`Downloading…`:r]}),o&&(0,a.jsxs)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[130px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:[(0,a.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:f,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,a.jsx)(t,{className:`w-3 h-3 shrink-0`}),`Export CSV`]}),(0,a.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:p,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,a.jsx)(t,{className:`w-3 h-3 shrink-0`}),`Export JSON`]})]})]})}export{o as t};
1
+ import{r as e}from"./chunk-CilyBKbf.js";import{X as t,kt as n,ut as r}from"./index-IQAxy67u.js";var i=e(n(),1),a=r();function o({baseUrl:e,params:n,label:r=`Export`}){let[o,s]=(0,i.useState)(!1),[c,l]=(0,i.useState)(!1),u=(0,i.useRef)(null);(0,i.useEffect)(()=>{if(!o)return;function e(e){u.current&&!u.current.contains(e.target)&&s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);function d(t){return`${e}?${new URLSearchParams({format:t,...n}).toString()}`}function f(){s(!1),window.open(d(`csv`),`_blank`)}let p=(0,i.useCallback)(async()=>{s(!1),l(!0);try{let t=await fetch(d(`json`));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r,i.download=`${e.split(`/`).filter(Boolean).pop()??`export`}.json`,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] JSON download failed:`,e)}finally{l(!1)}},[e,n]);return(0,a.jsxs)(`div`,{ref:u,className:`relative`,children:[(0,a.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":o,disabled:c,onClick:()=>s(e=>!e),className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,a.jsx)(t,{className:`w-3 h-3`}),c?`Downloading…`:r]}),o&&(0,a.jsxs)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[130px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:[(0,a.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:f,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,a.jsx)(t,{className:`w-3 h-3 shrink-0`}),`Export CSV`]}),(0,a.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:p,className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,a.jsx)(t,{className:`w-3 h-3 shrink-0`}),`Export JSON`]})]})]})}export{o as t};