specrails-desktop 2.30.2 → 2.30.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client/dist/assets/{ActivityFeedPage-9DZOvIcY.js → ActivityFeedPage-CcBOllqm.js} +1 -1
- package/client/dist/assets/{AgentBrowserCapture-DqyHbzk7.js → AgentBrowserCapture-BOJkZUj_.js} +1 -1
- package/client/dist/assets/{AgentModeCodePane-BAYyFRmY.js → AgentModeCodePane-BIh67rGi.js} +2 -2
- package/client/dist/assets/{AgentModeJobsPane-CTIHMUKN.js → AgentModeJobsPane-C5tkU2Ed.js} +1 -1
- package/client/dist/assets/{AgentsPage-DuyJuaFs.js → AgentsPage-CNlE_Uh4.js} +1 -1
- package/client/dist/assets/{AnalyticsPage-BY7gtCx6.js → AnalyticsPage-cYcJxWPn.js} +1 -1
- package/client/dist/assets/{CodePage-vyQr40Vl.js → CodePage-D4QYa4t1.js} +1 -1
- package/client/dist/assets/{DesktopAnalyticsPage-CkXUFj3F.js → DesktopAnalyticsPage-DCmgYV86.js} +1 -1
- package/client/dist/assets/{DocsDialog-PhdCJNVj.js → DocsDialog-BXnOgm7V.js} +1 -1
- package/client/dist/assets/{DocsPage-BY-wDthx.js → DocsPage-nFkHh-Dc.js} +1 -1
- package/client/dist/assets/{InteractiveJobComposer-C9I0A4KR.js → InteractiveJobComposer-qoeZjwVY.js} +1 -1
- package/client/dist/assets/{JobDetailModal-I_RoQJV4.js → JobDetailModal-ChRBB9bc.js} +1 -1
- package/client/dist/assets/{JobDetailPage-CU4FEnUC.js → JobDetailPage-BuOnlndB.js} +1 -1
- package/client/dist/assets/{JobsPage-DcllM4Ip.js → JobsPage-C_UEIXWA.js} +1 -1
- package/client/dist/assets/{LoopBuilderPage-DGm_iuff.js → LoopBuilderPage-BV_wge0g.js} +1 -1
- package/client/dist/assets/{LoopPreviewModal-BC-TeFdD.js → LoopPreviewModal-Qk_Jaxo8.js} +1 -1
- package/client/dist/assets/{LoopsPage-SqglnXlp.js → LoopsPage-lLi6ax0p.js} +1 -1
- package/client/dist/assets/{PluginsPage-B89S8o1a.js → PluginsPage-DZIFv9kw.js} +1 -1
- package/client/dist/assets/{ProjectSettingsDialog-nEs-ENrE.js → ProjectSettingsDialog-DEHcyt_I.js} +1 -1
- package/client/dist/assets/{TemplatePreviewModal-D4qW-J9B.js → TemplatePreviewModal-Bxbtnzob.js} +1 -1
- package/client/dist/assets/{TicketDetailModal-CI47Dq9E.js → TicketDetailModal-CqQ5gx7O.js} +2 -2
- package/client/dist/assets/{dist-js-jwoXo0YD.js → dist-js-CBhuoTO6.js} +1 -1
- package/client/dist/assets/{dist-js-Dj72W6qo.js → dist-js-eSxaoEw0.js} +1 -1
- package/client/dist/assets/{index-F9r8mWP_.js → index-CewRMo0W.js} +10 -10
- package/client/dist/index.html +2 -2
- package/package.json +1 -1
- package/server/dist/core-update-manager.js +17 -1
- package/server/dist/framework-manager.js +19 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{o as r}from"./i18n-Bf9Ckd10.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{t as o}from"./circle-x-CMYsN4ZH.js";import{t as s}from"./loader-circle-DcygOQpC.js";import{t as c}from"./zap-CHo3aCD1.js";import{n as l}from"./useSharedWebSocket-DaPh7QBL.js";import{t as u}from"./api-B2M7CtDw.js";import{r as d}from"./useDesktop-B4pSBIDd.js";import{Ft as f,kt as p}from"./index-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{o as r}from"./i18n-Bf9Ckd10.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{t as o}from"./circle-x-CMYsN4ZH.js";import{t as s}from"./loader-circle-DcygOQpC.js";import{t as c}from"./zap-CHo3aCD1.js";import{n as l}from"./useSharedWebSocket-DaPh7QBL.js";import{t as u}from"./api-B2M7CtDw.js";import{r as d}from"./useDesktop-B4pSBIDd.js";import{Ft as f,kt as p}from"./index-CewRMo0W.js";var m=a(`ban`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M4.929 4.929 19.07 19.071`,key:`196cmz`}]]),h=e(t(),1);function g(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 _({activeProjectId:e,limit:t=50}){let[n,i]=(0,h.useState)([]),[a,o]=(0,h.useState)(!1),[s,c]=(0,h.useState)(!0),d=(0,h.useRef)(e);(0,h.useEffect)(()=>{d.current=e},[e]);let{registerHandler:f,unregisterHandler:p}=l();(0,h.useEffect)(()=>{if(!e){i([]),c(!0);return}let n=!1;o(!0),i([]),c(!0);async function r(){let e=u();try{let r=await fetch(`${e}/activity?limit=${t}`);if(!r.ok||n)return;let a=await r.json();if(n)return;i(a),c(a.length===t)}catch{}finally{n||o(!1)}}return r(),()=>{n=!0}},[e,t]);let m=(0,h.useCallback)(async()=>{if(a||!s)return;o(!0);let e=u(),n=d.current;try{i(r=>{let a=r[r.length-1];if(!a)return r;let s=encodeURIComponent(a.timestamp);return fetch(`${e}/activity?limit=${t}&before=${s}`).then(e=>e.json()).then(e=>{if(d.current!==n){o(!1);return}i(t=>g([...t,...e])),c(e.length===t),o(!1)}).catch(()=>o(!1)),r})}catch{o(!1)}},[a,s,t]),_=(0,h.useCallback)(e=>{let t=e,n=d.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&&i(t=>g([...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:r.t(`activity:feed.phaseCommand`,{phase:t.phase,state:t.state}),timestamp:t.timestamp,summary:`Phase ${t.phase} is ${t.state}`,costUsd:null};i(t=>g([e,...t]))}}},[]);return(0,h.useLayoutEffect)(()=>(f(`activity`,_),()=>p(`activity`)),[_,f,p]),{items:n,loading:a,hasMore:s,loadMore:m}}var v=n();function y(e,t){let n=Date.now()-new Date(e).getTime(),r=Math.floor(n/1e3);if(r<60)return t(`feed.relativeTime.seconds`,{value:r});let i=Math.floor(r/60);if(i<60)return t(`feed.relativeTime.minutes`,{value:i});let a=Math.floor(i/60);return a<24?t(`feed.relativeTime.hours`,{value:a}):t(`feed.relativeTime.days`,{value:Math.floor(a/24)})}function b({type:e}){switch(e){case`job_completed`:return(0,v.jsx)(p,{className:`w-4 h-4 text-green-500 aurora-light:text-accent-success flex-shrink-0`});case`job_failed`:return(0,v.jsx)(o,{className:`w-4 h-4 text-red-500 aurora-light:text-destructive flex-shrink-0`});case`job_canceled`:return(0,v.jsx)(m,{className:`w-4 h-4 text-muted-foreground flex-shrink-0`});default:return(0,v.jsx)(c,{className:`w-4 h-4 text-blue-500 aurora-light:text-accent-info flex-shrink-0`})}}function x(e,t){switch(e){case`job_completed`:return t(`common:status.completed`);case`job_failed`:return t(`common:status.failed`);case`job_canceled`:return t(`common:status.canceled`);default:return t(`feed.typeStarted`)}}function S(e){switch(e){case`job_completed`:return`text-green-500 aurora-light:text-accent-success`;case`job_failed`:return`text-red-500 aurora-light:text-destructive`;case`job_canceled`:return`text-muted-foreground`;default:return`text-blue-500 aurora-light:text-accent-info`}}function C(){let{t:e}=i(`activity`),{activeProjectId:t}=d(),{items:n,loading:r,hasMore:a,loadMore:o}=_({activeProjectId:t}),c=(0,h.useRef)(null);return(0,h.useEffect)(()=>{let e=c.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,v.jsxs)(`div`,{className:`flex flex-col h-full overflow-hidden`,children:[(0,v.jsxs)(`div`,{className:`flex items-center gap-2 px-4 py-3 border-b border-border bg-background/50`,children:[(0,v.jsx)(f,{className:`w-4 h-4 text-muted-foreground`}),(0,v.jsx)(`h1`,{className:`text-sm font-medium`,children:e(`feed.title`)})]}),(0,v.jsxs)(`div`,{className:`flex-1 overflow-y-auto`,children:[r&&n.length===0?(0,v.jsx)(`div`,{className:`flex items-center justify-center h-32`,children:(0,v.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):n.length===0?(0,v.jsxs)(`div`,{className:`flex flex-col items-center justify-center h-48 gap-2 text-muted-foreground`,children:[(0,v.jsx)(f,{className:`w-8 h-8 opacity-40`}),(0,v.jsx)(`p`,{className:`text-sm`,children:e(`feed.emptyTitle`)}),(0,v.jsx)(`p`,{className:`text-xs opacity-70`,children:e(`feed.emptyHint`)})]}):(0,v.jsx)(`ul`,{className:`divide-y divide-border/50`,children:n.map(t=>(0,v.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-2.5 hover:bg-accent/30 transition-colors`,children:[(0,v.jsx)(b,{type:t.type}),(0,v.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,v.jsx)(`p`,{className:`text-xs text-foreground truncate`,title:t.jobCommand,children:t.jobCommand}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2 mt-0.5`,children:[(0,v.jsx)(`span`,{className:`text-xs font-medium ${S(t.type)}`,children:x(t.type,e)}),t.costUsd!=null&&(0,v.jsxs)(`span`,{className:`text-xs text-muted-foreground`,children:[`$`,t.costUsd.toFixed(4)]})]})]}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground flex-shrink-0 tabular-nums`,children:y(t.timestamp,e)})]},`${t.type}:${t.jobId}`))}),(0,v.jsx)(`div`,{ref:c,className:`h-1`}),r&&n.length>0&&(0,v.jsx)(`div`,{className:`flex justify-center py-3`,children:(0,v.jsx)(s,{className:`w-4 h-4 animate-spin text-muted-foreground`})}),!a&&n.length>0&&(0,v.jsx)(`p`,{className:`text-center text-xs text-muted-foreground py-3`,children:e(`feed.allLoaded`)})]})]})}export{C as default};
|
package/client/dist/assets/{AgentBrowserCapture-DqyHbzk7.js → AgentBrowserCapture-BOJkZUj_.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r}from"./createLucideIcon-Bjbbp_KS.js";import{n as i}from"./dist-bVqfYmby.js";import{A as a,i as o,l as s}from"./index-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{n as r}from"./createLucideIcon-Bjbbp_KS.js";import{n as i}from"./dist-bVqfYmby.js";import{A as a,i as o,l as s}from"./index-CewRMo0W.js";var c=e(t(),1);function l(e,t){let n=e.indexOf(`,`);if(!e.startsWith(`data:`)||n===-1)throw Error(`dataUrlToFile: not a data URL`);let r=e.slice(0,n),i=/^data:([^;,]+)/.exec(r)?.[1]||`application/octet-stream`,a=e.slice(n+1);if(/;base64$/i.test(r)){let e=atob(a),n=new Uint8Array(e.length);for(let t=0;t<e.length;t++)n[t]=e.charCodeAt(t);return new File([n],t,{type:i})}return new File([decodeURIComponent(a)],t,{type:i})}var u=n();function d({projectId:e,conversationId:t}){let{t:n}=r(`agent`),{closeBrowser:d,queueCapture:f}=o(),p=(0,c.useMemo)(()=>`agent-${t??`home`}-${Math.round(performance.now())}`,[t]),m=async e=>{if(!t){i.error(n(`workspace.requiresConversation`));return}try{let r=await s(t,l(e.screenshotDataUrl,`capture-${Date.now()}.png`));f(r),i.success(n(`workspace.browserCaptured`)),d()}catch(e){i.error(n(`workspace.uploadFailed`),{description:e instanceof Error?e.message:void 0})}};return(0,u.jsx)(a,{open:!0,onClose:d,projectId:e,pendingSpecId:p,confirmLabel:n(`workspace.browserConfirm`),onCaptured:e=>{m(e)}})}export{d as AgentBrowserCapture};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodePage-
|
|
2
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{n as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./x-CBMI9ejn.js";import{i as o,mt as s,pt as c}from"./index-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/CodePage-D4QYa4t1.js","assets/rolldown-runtime-CNC7AqOf.js","assets/jsx-runtime-zu2_FqZY.js","assets/react-dom-DiWzBDP9.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-Cx5sqopX.js","assets/createLucideIcon-Bjbbp_KS.js","assets/dist-bVqfYmby.js","assets/useBrowserCaptureSession-CkBJShUw.js","assets/i18n-Bf9Ckd10.js","assets/activity-DiyjsgQV.js","assets/addspec-Rw8uVBC1.js","assets/agent-BuUpgqVx.js","assets/agents-DhG7mg6-.js","assets/agentstudio-BIUe1Im2.js","assets/aiedit-iIjz2_Qk.js","assets/analytics-DZ8Aoq3I.js","assets/attachments-B53PG733.js","assets/browser-CXUcnTMI.js","assets/builder-Cc_Lf79C.js","assets/chat-BGD7MXAy.js","assets/code-BDXEM4ml.js","assets/commands-DyUZQ1FI.js","assets/common-DHsv9N5d.js","assets/dashboard-Cslu_GCH.js","assets/explore-DgBACn39.js","assets/integrations-mB-7zoyT.js","assets/jira-CmKWERE0.js","assets/jobs-DoSaFzAa.js","assets/loops-BzfXWEwO.js","assets/mcp-uDkXYu4L.js","assets/nav-myFaXRHD.js","assets/settings-B0ypw9uw.js","assets/setup-ajB4rYm-.js","assets/specs-DII0C8gw.js","assets/terminal-BFRZnMPP.js","assets/tickets-D_yDquEw.js","assets/auth-D_5bQv5W.js","assets/api-B2M7CtDw.js","assets/MinimizedChatsContext-Cs34FPTz.js","assets/sparkles-DrY8hb0X.js","assets/x-CBMI9ejn.js","assets/useSharedWebSocket-DaPh7QBL.js","assets/useDesktop-B4pSBIDd.js","assets/external-link-BcU5EWZp.js","assets/chevron-right-CViMxucY.js","assets/TicketDetailModal-CqQ5gx7O.js","assets/Trans-CPISVji8.js","assets/arrow-left-CpIR4j7G.js","assets/circle-x-CMYsN4ZH.js","assets/download-CFHyyHcw.js","assets/file-text-CFT-xXKN.js","assets/git-branch-BRM0F5GN.js","assets/loader-circle-DcygOQpC.js","assets/pencil-C9RkrIPZ.js","assets/play-DNlrawbS.js","assets/plus-CsnjfkmX.js","assets/save-28sIlCdr.js","assets/search-Cq_gE3Ik.js","assets/trash-2-BOU3WdZZ.js","assets/triangle-alert-H9T4jAmh.js","assets/zap-CHo3aCD1.js","assets/button-BUIIBQPT.js","assets/dist-Cez5CRkX.js","assets/clsx-CjueKrWZ.js","assets/utils-BC4DHlz2.js","assets/dialog-CzIekCw0.js","assets/jira-api-BgFIr8eD.js","assets/lib-CGdyxIWg.js","assets/formatDistanceToNow-ByKli7Q_.js","assets/getTimezoneOffsetInMilliseconds-qrcBaLW1.js","assets/spending-DMnCXy84.js","assets/index-CewRMo0W.js","assets/arrow-up-right-9DoMn7fD.js","assets/index-Dh9i4CnN.css"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./preload-helper-Czpn1I53.js";import{n as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./x-CBMI9ejn.js";import{i as o,mt as s,pt as c}from"./index-CewRMo0W.js";var l=e(t(),1),u=n(),d=(0,l.lazy)(()=>r(()=>import(`./CodePage-D4QYa4t1.js`),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74]))),f=new Map,p=420,m=560;function h({projectId:e,conversationId:t}){let{t:n}=i(`agent`),{closeCodePane:r}=o(),[h,g]=(0,l.useState)(m),[_,v]=(0,l.useState)(!1),y=(0,l.useRef)(null),b=`${e}:${t}`,x=(0,l.useCallback)(e=>{f.set(b,e)},[b]),S=(0,l.useCallback)(e=>{let t=e.clientX,n=h,r=window.innerWidth-p;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}let i=e=>{let i=Math.min(Math.max(n+(t-e.clientX),p),r);g(i)},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a)};window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},[h]);return(0,u.jsxs)(`div`,{ref:y,className:`flex h-full flex-col overflow-hidden border-l border-border bg-background${_?` absolute inset-0 z-30 border-l-0`:``}`,style:_?void 0:{width:h,flexShrink:0},children:[(0,u.jsx)(`div`,{className:`relative flex items-center`,children:!_&&(0,u.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:S,className:`absolute left-0 top-0 h-full w-1.5 -translate-x-full cursor-col-resize select-none touch-none hover:bg-accent-primary/20`,title:n(`workspace.resizeCode`)})}),(0,u.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 bg-surface/40 px-3 py-1.5`,children:[(0,u.jsx)(`span`,{className:`text-xs font-medium text-foreground/70`,children:n(`workspace.files`)}),(0,u.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,u.jsx)(`button`,{type:`button`,onClick:()=>v(e=>!e),"aria-label":n(_?`restore`:`maximize`),title:n(_?`restore`:`maximize`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:_?(0,u.jsx)(c,{className:`h-4 w-4`}):(0,u.jsx)(s,{className:`h-4 w-4`})}),(0,u.jsx)(`button`,{type:`button`,onClick:r,"aria-label":n(`workspace.closeFiles`),title:n(`workspace.closeFiles`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,u.jsx)(a,{className:`h-4 w-4`})})]})]}),(0,u.jsx)(`div`,{className:`min-h-0 flex-1 overflow-hidden`,children:(0,u.jsx)(l.Suspense,{fallback:(0,u.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:`…`}),children:(0,u.jsx)(d,{embedded:!0,initialPath:f.get(b)??null,onSelectedPathChange:x})})})]},b)}export{h as AgentModeCodePane};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{a as r}from"./i18n-Bf9Ckd10.js";import{n as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./loader-circle-DcygOQpC.js";import{t as o}from"./x-CBMI9ejn.js";import{n as s}from"./useSharedWebSocket-DaPh7QBL.js";import{t as c}from"./api-B2M7CtDw.js";import{i as l,r as u}from"./useDesktop-B4pSBIDd.js";import{t as d}from"./utils-BC4DHlz2.js";import{t as f}from"./formatDistanceToNow-ByKli7Q_.js";import{L as p,Mt as m,i as h,mt as g,pt as _}from"./index-
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{a as r}from"./i18n-Bf9Ckd10.js";import{n as i}from"./createLucideIcon-Bjbbp_KS.js";import{t as a}from"./loader-circle-DcygOQpC.js";import{t as o}from"./x-CBMI9ejn.js";import{n as s}from"./useSharedWebSocket-DaPh7QBL.js";import{t as c}from"./api-B2M7CtDw.js";import{i as l,r as u}from"./useDesktop-B4pSBIDd.js";import{t as d}from"./utils-BC4DHlz2.js";import{t as f}from"./formatDistanceToNow-ByKli7Q_.js";import{L as p,Mt as m,i as h,mt as g,pt as _}from"./index-CewRMo0W.js";import{n as v,t as y}from"./job-time-BCL7wee9.js";import{JobDetailModal as b}from"./JobDetailModal-ChRBB9bc.js";import{t as x}from"./format-command-Dfa1o2d-.js";var S=e(t(),1),C=n(),w=360,T=480,E={running:`running`,completed:`success`,failed:`failed`,canceled:`canceled`,queued:`queued`};function D({projectId:e}){let{t}=i(`agent`),{t:n}=i(`jobs`),{closeJobsPane:D}=h(),{projects:O}=u(),k=O.find(t=>t.id===e)?.provider,[A,j]=(0,S.useState)(T),[M,N]=(0,S.useState)(!1),[P,F]=(0,S.useState)(null),{data:I,isFirstLoad:L,refresh:R}=l({namespace:`agent-jobs`,projectId:e,initialValue:[],fetcher:async()=>{let e=await fetch(`${c()}/jobs?limit=50`);return e.ok?(await e.json()).jobs:[]},pollInterval:5e3}),{registerHandler:z,unregisterHandler:B}=s(),V=(0,S.useRef)(e);V.current=e;let H=(0,S.useRef)(R);H.current=R,(0,S.useEffect)(()=>(z(`agent-jobs-pane`,e=>{let t=e;t.type===`queue`&&(t.projectId&&t.projectId!==V.current||H.current())}),()=>B(`agent-jobs-pane`)),[z,B]);let U=(0,S.useCallback)(e=>{let t=e.clientX,n=A,r=window.innerWidth-w;try{e.currentTarget.setPointerCapture(e.pointerId)}catch{}let i=e=>{let i=Math.min(Math.max(n+(t-e.clientX),w),r);j(i)},a=()=>{window.removeEventListener(`pointermove`,i),window.removeEventListener(`pointerup`,a),window.removeEventListener(`pointercancel`,a)};window.addEventListener(`pointermove`,i),window.addEventListener(`pointerup`,a),window.addEventListener(`pointercancel`,a)},[A]);return(0,C.jsxs)(`div`,{className:d(`flex h-full flex-col overflow-hidden border-l border-border bg-background`,M&&`absolute inset-0 z-30 border-l-0`),style:M?void 0:{width:A,flexShrink:0},children:[(0,C.jsx)(`div`,{className:`relative flex items-center`,children:!M&&(0,C.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,onPointerDown:U,className:`absolute left-0 top-0 h-full w-1.5 -translate-x-full cursor-col-resize select-none touch-none hover:bg-accent-primary/20`,title:t(`workspace.resizeJobs`)})}),(0,C.jsxs)(`div`,{className:`flex items-center gap-2 border-b border-border/60 bg-surface/40 px-3 py-1.5`,children:[(0,C.jsx)(`span`,{className:`text-xs font-medium text-foreground/70`,children:t(`workspace.jobs`)}),(0,C.jsxs)(`div`,{className:`ml-auto flex items-center gap-1`,children:[(0,C.jsx)(`button`,{type:`button`,onClick:()=>N(e=>!e),"aria-label":t(M?`restore`:`maximize`),title:t(M?`restore`:`maximize`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:M?(0,C.jsx)(_,{className:`h-4 w-4`}):(0,C.jsx)(g,{className:`h-4 w-4`})}),(0,C.jsx)(`button`,{type:`button`,onClick:D,"aria-label":t(`workspace.closeJobs`),title:t(`workspace.closeJobs`),className:`rounded-md p-1 text-foreground/60 hover:bg-surface hover:text-foreground`,children:(0,C.jsx)(o,{className:`h-4 w-4`})})]})]}),(0,C.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto p-2`,children:L?(0,C.jsx)(`div`,{className:`flex h-24 items-center justify-center text-muted-foreground`,children:(0,C.jsx)(a,{className:`h-4 w-4 animate-spin`})}):I.length===0?(0,C.jsxs)(`div`,{className:`flex h-full flex-col items-center justify-center gap-2 text-center text-muted-foreground`,children:[(0,C.jsx)(m,{className:`h-6 w-6 opacity-40`}),(0,C.jsx)(`p`,{className:`text-xs`,children:t(`workspace.noJobs`)})]}):(0,C.jsx)(`ul`,{className:`space-y-1`,children:I.map(e=>(0,C.jsx)(`li`,{children:(0,C.jsxs)(`button`,{type:`button`,onClick:()=>F(e.id),className:d(`flex w-full flex-col gap-1 rounded-lg border border-border/50 bg-surface/30 px-2.5 py-2 text-left transition-colors`,`hover:border-accent-primary/40 hover:bg-surface/60`),children:[(0,C.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,C.jsx)(p,{variant:E[e.status]??`queued`,children:n(`statusLabel.${e.status in E?e.status:`queued`}`)}),e.status===`running`&&(0,C.jsx)(a,{className:`h-3 w-3 animate-spin text-accent-primary`}),(0,C.jsx)(`span`,{className:`ml-auto text-[10px] text-muted-foreground`,children:(()=>{let t=v(y(e));return t?f(t,{addSuffix:!0,locale:r()}):`—`})()})]}),(0,C.jsx)(`code`,{className:`truncate font-mono text-xs text-foreground/85`,children:x(e.command,k)})]})},e.id))})}),P&&(0,C.jsx)(b,{jobId:P,onClose:()=>F(null)})]})}export{D as AgentModeJobsPane};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{o as r}from"./i18n-Bf9Ckd10.js";import{t as i}from"./Trans-CPISVji8.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{n as s}from"./dist-bVqfYmby.js";import{t as c}from"./arrow-left-CpIR4j7G.js";import{l,n as u,r as d,u as f}from"./MinimizedChatsContext-Cs34FPTz.js";import{n as p,t as m}from"./external-link-BcU5EWZp.js";import{t as h}from"./chevron-right-CViMxucY.js";import{t as g}from"./file-text-CFT-xXKN.js";import{t as _}from"./loader-circle-DcygOQpC.js";import{t as v}from"./pencil-C9RkrIPZ.js";import{t as y}from"./plus-CsnjfkmX.js";import{t as b}from"./save-28sIlCdr.js";import{t as x}from"./search-Cq_gE3Ik.js";import{t as S}from"./sparkles-DrY8hb0X.js";import{t as C}from"./trash-2-BOU3WdZZ.js";import{t as w}from"./triangle-alert-H9T4jAmh.js";import{t as T}from"./x-CBMI9ejn.js";import{n as E}from"./useSharedWebSocket-DaPh7QBL.js";import{t as D}from"./api-B2M7CtDw.js";import{r as O}from"./useDesktop-B4pSBIDd.js";import{t as k}from"./button-BUIIBQPT.js";import{a as A,c as j,i as M,n as N,o as P,r as F,s as I,t as L}from"./dialog-CzIekCw0.js";import{$ as R,At as ee,B as z,Et as B,G as V,H,J as U,K as W,Pt as te,R as G,U as K,V as ne,W as re,Y as ie,bt as q,dt as ae,ft as oe,k as se,lt as ce,q as J,y as Y,yt as le,z as ue}from"./index-F9r8mWP_.js";var de=o(`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`}]]),fe=o(`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`}]]),X=e(t(),1),Z=n(),pe=/^[a-z0-9][a-z0-9-]*$/;function me({open:e,mode:t=`add`,initial:n,chainAgents:r,onConfirm:o,onCancel:s}){let{t:c}=a(`agents`),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(r[0]??``);(0,X.useEffect)(()=>{e&&(t===`edit`&&n?(u(n.tags.join(`, `)),f(r.includes(n.agent)?n.agent:r[0]??``)):(u(``),f(r[0]??``)))},[e,t,n,r]);let p=l.split(`,`).map(e=>e.trim()).filter(Boolean),m=p.filter(e=>!pe.test(e)),h=p.length>0&&m.length===0&&r.includes(d);return(0,Z.jsx)(L,{open:e,onOpenChange:e=>{e||s()},children:(0,Z.jsxs)(N,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsxs)(A,{children:[(0,Z.jsx)(P,{children:c(t===`edit`?`routingRule.editTitle`:`routingRule.addTitle`)}),(0,Z.jsx)(F,{children:c(t===`edit`?`routingRule.editDescription`:`routingRule.addDescription`)})]}),(0,Z.jsxs)(`div`,{className:`py-2 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:c(`routingRule.tagsLabel`)}),(0,Z.jsx)(Y,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),placeholder:`frontend, ui`,"aria-label":c(`routingRule.tagsLabel`),className:`text-sm font-mono`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:(0,Z.jsx)(i,{t:c,i18nKey:`routingRule.tagsHint`,components:{code:(0,Z.jsx)(`code`,{})}})}),m.length>0&&(0,Z.jsx)(`p`,{className:`text-[11px] text-red-400 aurora-light:text-destructive mt-1`,children:c(`routingRule.invalidTags`,{count:m.length,tags:m.join(`, `)})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:c(`routingRule.routeToLabel`)}),(0,Z.jsx)(`select`,{value:d,onChange:e=>f(e.target.value),"aria-label":c(`routingRule.routeToLabel`),className:`w-full h-9 px-2 text-sm rounded-md border border-border bg-background`,children:r.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:c(`routingRule.routeToHint`)})]})]}),(0,Z.jsxs)(M,{children:[(0,Z.jsx)(k,{variant:`ghost`,size:`sm`,onClick:s,children:c(`common:actions.cancel`)}),(0,Z.jsx)(k,{size:`sm`,onClick:()=>o(p,d),disabled:!h,children:c(t===`edit`?`routingRule.saveChanges`:`routingRule.addRule`)})]})]})})}var Q=new Set([`sr-architect`,`sr-developer`,`sr-reviewer`,`sr-merge-resolver`]),he=[`sonnet`,`fable`,`opus`,`haiku`],ge=/^[a-z0-9][a-z0-9-]*$/;function _e({profile:e,onChange:t,footer:n,onValidityChange:r,onSoftWarningsChange:o}){let{t:s}=a(`agentstudio`),[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null);(0,X.useEffect)(()=>{let e=!1;return fetch(`${D()}/profiles/catalog`).then(e=>e.ok?e.json():{agents:[]}).then(t=>{e||l(t.agents)}).catch(()=>{e||l([])}),()=>{e=!0}},[]);let g=n=>{let r=JSON.parse(JSON.stringify(e));n(r),t(r)},_=new Set(e.agents.map(e=>e.id)),v=c.filter(e=>!_.has(e.id)),b=(0,X.useMemo)(()=>{let t=[];for(let n of Q)e.agents.some(e=>e.id===n)||t.push(s(`profileEditor.validation.missingBaseline`,{agent:n}));let n=e.routing.filter(e=>`default`in e&&e.default===!0);if(n.length>1&&t.push(s(`profileEditor.validation.multipleDefaultRules`,{found:n.length})),n.length===1){let n=e.routing[e.routing.length-1];`default`in n&&n.default===!0||t.push(s(`profileEditor.validation.defaultRuleNotLast`))}for(let n of e.routing)if(e.agents.some(e=>e.id===n.agent)||t.push(s(`profileEditor.validation.unknownRoutingAgent`,{agent:n.agent})),`tags`in n){let e=n.tags.filter(e=>!ge.test(e));e.length>0&&t.push(s(`profileEditor.validation.invalidTags`,{agent:n.agent,tags:e.join(`, `)}))}return t},[e,s]),x=(0,X.useMemo)(()=>{if(e.routing.length===0)return[];let t=new Set(e.routing.map(e=>e.agent));return e.agents.filter(e=>!Q.has(e.id)&&!t.has(e.id)).map(e=>e.id)},[e]),S=(0,X.useMemo)(()=>e.routing.some(e=>`default`in e&&e.default===!0),[e.routing]);(0,X.useEffect)(()=>{r&&r(b)},[b,r]),(0,X.useEffect)(()=>{o&&o({agentsMissingRouting:x})},[x,o]);let C=e=>{g(t=>{let n={id:e,model:`sonnet`},r=t.agents.findIndex(e=>e.id===`sr-merge-resolver`);r>=0?t.agents.splice(r,0,n):t.agents.push(n)}),d(!1)},w=t=>{let n=e.agents[t];Q.has(n.id)||g(e=>{e.agents.splice(t,1),e.routing=e.routing.filter(e=>e.agent!==n.id)})},E=(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=ue(e.agents,r,i),o=a.findIndex(e=>e.id===`sr-architect`);if(o>0){let[e]=a.splice(o,1);a.unshift(e)}let s=a.findIndex(e=>e.id===`sr-merge-resolver`);if(s>=0&&s!==a.length-1){let[e]=a.splice(s,1);a.push(e)}g(e=>{e.agents=a})},O=U(J(V,{activationConstraint:{distance:4}}),J(re,{coordinateGetter:z})),A=e=>{let{active:t,over:n}=e;n&&E(String(t.id),String(n.id))},j=(e,t)=>{g(n=>{n.agents[e].model=t})},M=(e,t)=>{g(n=>{let r={tags:e,agent:t},i=n.routing.findIndex(e=>`default`in e&&e.default===!0);i>=0?n.routing.splice(i,0,r):n.routing.push(r)}),p(!1)},N=()=>{g(e=>{e.routing.some(e=>`default`in e&&e.default===!0)||e.agents.some(e=>e.id===`sr-developer`)&&e.routing.push({default:!0,agent:`sr-developer`})})},P=e=>`default`in e&&e.default===!0,F=(e,t)=>{g(n=>{let r=n.routing[e];r&&(P(r)||(r.agent=t))})},I=(e,t,n)=>{g(r=>{let i=r.routing[e];i&&(P(i)||(i.tags=t,i.agent=n))})},L=e=>{g(t=>{let n=t.routing[e];n&&(P(n)||t.routing.splice(e,1))})},R=(t,n)=>{let r=t+n;if(r<0||r>=e.routing.length)return;let i=e.routing[t],a=e.routing[r];P(i)||P(a)||g(e=>{let[n]=e.routing.splice(t,1);e.routing.splice(r,0,n)})};return(0,Z.jsxs)(`div`,{className:`p-6 space-y-6 max-w-3xl`,children:[(0,Z.jsx)(me,{open:f,mode:`add`,chainAgents:e.agents.map(e=>e.id),onConfirm:M,onCancel:()=>p(!1)}),(0,Z.jsx)(me,{open:m!==null,mode:`edit`,initial:m!==null&&e.routing[m]&&!(`default`in e.routing[m])?{tags:e.routing[m].tags,agent:e.routing[m].agent}:void 0,chainAgents:e.agents.map(e=>e.id),onConfirm:(e,t)=>{m!==null&&(I(m,e,t),h(null))},onCancel:()=>h(null)}),b.length>0&&(0,Z.jsxs)(`div`,{className:`px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Z.jsx)(`div`,{className:`font-medium mb-1`,children:s(`profileEditor.validationSummary`,{count:b.length})}),(0,Z.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:b.map((e,t)=>(0,Z.jsx)(`li`,{children:e},t))})]}),(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:s(`profileEditor.nameLabel`)}),(0,Z.jsx)(Y,{value:e.name,disabled:!0,className:`text-sm`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:s(`profileEditor.descriptionLabel`)}),(0,Z.jsx)(Y,{value:e.description??``,onChange:e=>g(t=>{t.description=e.target.value}),className:`text-sm`,placeholder:s(`profileEditor.descriptionPlaceholder`)})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2`,children:s(`profileEditor.orchestrator.heading`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-md border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-mono text-foreground truncate`,children:`/specrails:implement · /specrails:batch-implement`}),(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:s(`profileEditor.orchestrator.description`)})]}),(0,Z.jsx)(be,{value:e.orchestrator.model,onChange:e=>g(t=>{t.orchestrator.model=e})})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:s(`profileEditor.agentChain.heading`,{n:e.agents.length})}),(0,Z.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>d(e=>!e),disabled:v.length===0,title:v.length===0?s(`profileEditor.agentChain.addDisabledTitle`):s(`profileEditor.agentChain.addTitle`),children:[(0,Z.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`common:actions.add`)]})]}),u&&(0,Z.jsxs)(`div`,{className:`mb-2 p-2 rounded-md border border-border bg-muted/30`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 px-1`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:s(`profileEditor.agentChain.pickFromCatalog`,{n:v.length})}),(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:()=>d(!1),title:s(`common:actions.close`),children:(0,Z.jsx)(T,{className:`w-3 h-3`})})]}),v.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:s(`profileEditor.agentChain.emptyCatalog`)}):(0,Z.jsx)(`div`,{className:`space-y-0.5 max-h-64 overflow-auto`,children:v.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>C(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,Z.jsx)(`span`,{className:`text-sm font-mono`,children:e.id}),(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded `+(e.kind===`custom`?`bg-purple-500/15 aurora-light:bg-accent-secondary/15 text-purple-400 aurora-light:text-accent-secondary`:`bg-muted text-muted-foreground`),children:s(`profileEditor.agentChain.kind.${e.kind}`)})]},e.id))})]}),(0,Z.jsx)(K,{sensors:O,collisionDetection:W,onDragEnd:A,children:(0,Z.jsx)(G,{items:e.agents.map(e=>e.id),strategy:H,children:(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:e.agents.map((e,t)=>(0,Z.jsx)(ve,{agent:e,canRemove:!Q.has(e.id),onModel:e=>j(t,e),onRemove:()=>w(t)},e.id))})})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:s(`profileEditor.routing.heading`,{n:e.routing.length})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!S&&(0,Z.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:N,disabled:e.agents.length===0,title:e.agents.length===0?s(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Z.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`profileEditor.routing.addDefault`)]}),(0,Z.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>p(!0),disabled:e.agents.length===0,title:e.agents.length===0?s(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Z.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`profileEditor.routing.addRule`)]})]})]}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-2`,children:s(`profileEditor.routing.explainer`)}),x.length>0&&(0,Z.jsxs)(`div`,{className:`mb-2 px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Z.jsx)(`div`,{className:`font-medium mb-1`,children:s(`profileEditor.routing.untargetedTitle`)}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(i,{t:s,i18nKey:`profileEditor.routing.untargetedDetail`,values:{agents:x.join(`, `)},components:{mono:(0,Z.jsx)(`span`,{className:`font-mono`})}})})]}),(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:e.routing.map((t,n)=>{let r=`default`in t&&t.default===!0;return(0,Z.jsx)(ye,{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=>F(n,e),onEdit:()=>h(n),onUp:()=>R(n,-1),onDown:()=>R(n,1),onRemove:()=>L(n)},n)})})]}),n&&(0,Z.jsx)(`div`,{className:`pt-3 border-t border-border`,children:n})]})}function ve({agent:e,canRemove:t,onModel:n,onRemove:r}){let{t:i}=a(`agentstudio`),o=Q.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}=ne({id:e.id});return(0,Z.jsxs)(`div`,{ref:d,style:{transform:ie.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,Z.jsx)(`button`,{type:`button`,className:`flex-shrink-0 p-0.5 rounded text-muted-foreground cursor-grab active:cursor-grabbing hover:text-foreground`,title:i(`profileEditor.agentRow.dragTitle`),"aria-label":i(`profileEditor.agentRow.dragHandleAria`),...l,...u,children:(0,Z.jsx)(q,{className:`w-3.5 h-3.5`})}),(0,Z.jsx)(`span`,{className:`text-sm font-mono flex-1 truncate`,children:e.id}),s&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:i(`profileEditor.agentRow.pinnedFirstTitle`),children:[(0,Z.jsx)(ae,{className:`w-2.5 h-2.5 rotate-[135deg]`}),` `,i(`profileEditor.agentRow.pinnedFirst`)]}),c&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:i(`profileEditor.agentRow.pinnedLastTitle`),children:[(0,Z.jsx)(ae,{className:`w-2.5 h-2.5 rotate-45`}),` `,i(`profileEditor.agentRow.pinnedLast`)]}),o&&!s&&!c&&(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:i(`profileEditor.agentRow.required`)}),(0,Z.jsx)(be,{value:e.model??`sonnet`,onChange:n}),(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded disabled:opacity-30 disabled:cursor-not-allowed opacity-0 group-hover:opacity-100 transition-opacity`,onClick:r,disabled:!t,title:i(t?`common:actions.remove`:`profileEditor.agentRow.requiredRemoveTitle`),children:(0,Z.jsx)(T,{className:`w-3 h-3`})})]})}function ye({rule:e,ordinal:t,isLast:n,canMove:r,canRemove:i,canEdit:o,chainAgents:s,onAgentChange:c,onEdit:l,onUp:u,onDown:d,onRemove:p}){let{t:m}=a(`agentstudio`),h=`default`in e&&e.default===!0;return(0,Z.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,Z.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground w-5 text-center flex-shrink-0`,children:[t,`.`]}),h?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:m(`profileEditor.routingRow.everythingElse`)}):(0,Z.jsx)(`span`,{className:`text-xs flex-1 flex gap-1 flex-wrap items-center`,children:e.tags.map(e=>(0,Z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-muted font-mono text-[11px]`,children:e},e))}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),h?(0,Z.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":m(`profileEditor.routingRow.defaultTargetAria`),title:m(`profileEditor.routingRow.defaultTargetTitle`),children:e.agent}):(0,Z.jsx)(`select`,{value:e.agent,onChange:e=>c(e.target.value),"aria-label":m(`profileEditor.routingRow.targetAria`,{ordinal:t}),className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-background`,children:s.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),(0,Z.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[o&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:l,title:m(`profileEditor.routingRow.editTitle`),"aria-label":m(`profileEditor.routingRow.editAria`,{ordinal:t}),children:(0,Z.jsx)(v,{className:`w-3 h-3`})}),r&&!n&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:d,title:m(`profileEditor.routingRow.moveDown`),children:(0,Z.jsx)(te,{className:`w-3 h-3`})}),r&&t>1&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:u,title:m(`profileEditor.routingRow.moveUp`),children:(0,Z.jsx)(f,{className:`w-3 h-3`})}),i&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded`,onClick:p,title:m(`common:actions.remove`),children:(0,Z.jsx)(T,{className:`w-3 h-3`})})]}),h&&(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,title:m(`profileEditor.routingRow.coreDefaultTitle`),children:m(`profileEditor.routingRow.coreDefaultBadge`)})]})}function be({value:e,onChange:t}){return(0,Z.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-7 px-2 text-xs rounded border border-border bg-background`,children:he.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))})}function xe({open:e,title:t,description:n,placeholder:r,initialValue:i=``,confirmLabel:o,inputPattern:s,inputInvalidHint:c,onConfirm:l,onCancel:u}){let{t:d}=a(),[f,p]=(0,X.useState)(i);(0,X.useEffect)(()=>{e&&p(i)},[e,i]);let m=f.trim(),h=!s||s.test(m),g=m.length>0&&h;return(0,Z.jsx)(L,{open:e,onOpenChange:e=>{e||u()},children:(0,Z.jsxs)(N,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsx)(A,{children:(0,Z.jsx)(P,{children:t})}),(0,Z.jsxs)(`div`,{className:`py-2 space-y-2`,children:[n&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}),(0,Z.jsx)(Y,{autoFocus:!0,value:f,placeholder:r,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g&&l(m)},className:`text-sm font-mono`}),m.length>0&&!h&&c&&(0,Z.jsx)(`p`,{className:`text-[11px] text-yellow-500 aurora-light:text-accent-warning`,children:c})]}),(0,Z.jsxs)(M,{children:[(0,Z.jsx)(k,{variant:`ghost`,size:`sm`,onClick:u,children:d(`actions.cancel`)}),(0,Z.jsx)(k,{size:`sm`,onClick:()=>l(m),disabled:!g,children:o??d(`actions.confirm`)})]})]})})}function Se({open:e,title:t,description:n,confirmLabel:r,destructive:i=!1,onConfirm:o,onCancel:s}){let{t:c}=a();return(0,Z.jsx)(L,{open:e,onOpenChange:e=>{e||s()},children:(0,Z.jsxs)(N,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsx)(A,{children:(0,Z.jsx)(P,{children:t})}),n&&(0,Z.jsx)(`div`,{className:`py-2`,children:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})}),(0,Z.jsxs)(M,{children:[(0,Z.jsx)(k,{variant:`ghost`,size:`sm`,onClick:s,children:c(`actions.cancel`)}),(0,Z.jsx)(k,{size:`sm`,onClick:o,className:i?`bg-red-500 hover:bg-red-600 text-white`:void 0,children:r??c(`actions.confirm`)})]})]})})}function Ce(){let{t:e}=a(`agents`),[t,n]=(0,X.useState)([]),[r,o]=(0,X.useState)(null),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(!0),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)([]),[v,x]=(0,X.useState)([]),[S,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(null),[O,A]=(0,X.useState)(null),j=(0,X.useCallback)(async()=>{d(!0),p(null);try{let t=await fetch(`${D()}/profiles`);if(!t.ok)throw Error(e(`profiles.errors.listFailed`,{status:t.status}));let i=await t.json();n(i.profiles),i.profiles.length>0&&!r&&o(i.profiles[0].name)}catch(e){p(e.message)}finally{d(!1)}},[r]);(0,X.useEffect)(()=>{j()},[j]),(0,X.useEffect)(()=>{if(!r){l(null);return}let t=!1;return fetch(`${D()}/profiles/${encodeURIComponent(r)}`).then(t=>{if(!t.ok)throw Error(e(`profiles.errors.loadFailed`,{status:t.status}));return t.json()}).then(e=>{t||l(e.profile)}).catch(e=>{t||p(e.message)}),()=>{t=!0}},[r]);let M=(0,X.useCallback)(async()=>{h(!0),p(null);try{let t=await fetch(`${D()}/profiles/migrate-from-settings`,{method:`POST`});if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`profiles.errors.migrationFailed`,{status:t.status}))}await j(),o(`default`),s.success(e(`profiles.toasts.migrated`),{description:e(`profiles.toasts.migratedDescription`)})}catch(t){let n=t.message;p(n),s.error(e(`profiles.toasts.migrationFailed`),{description:n})}finally{h(!1)}},[j]),N=(0,X.useCallback)(async t=>{w(!1),h(!0),p(null);try{let n={schemaVersion:1,name:t,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`}]},r=await fetch(`${D()}/profiles`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.createFailed`,{status:r.status}))}await j(),o(t),s.success(e(`profiles.toasts.created`),{description:t})}catch(t){let n=t.message;p(n),s.error(e(`profiles.toasts.createFailed`),{description:n})}finally{h(!1)}},[j]),P=(0,X.useCallback)(async(t,n)=>{E(null),h(!0),p(null);try{let r=await fetch(`${D()}/profiles/${encodeURIComponent(t)}/duplicate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n})});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.duplicateFailed`,{status:r.status}))}await j(),o(n),s.success(e(`profiles.toasts.duplicated`),{description:e(`profiles.toasts.duplicatedDescription`,{from:t,to:n})})}catch(t){let n=t.message;p(n),s.error(e(`profiles.toasts.duplicateFailed`),{description:n})}finally{h(!1)}},[j]),F=(0,X.useCallback)(async t=>{A(null),h(!0),p(null);try{let n=await fetch(`${D()}/profiles/${encodeURIComponent(t)}`,{method:`DELETE`});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.deleteFailed`,{status:n.status}))}o(e=>e===t?null:e),await j(),s.success(e(`profiles.toasts.deleted`),{description:t})}catch(t){let n=t.message;p(n),s.error(e(`profiles.toasts.deleteFailed`),{description:n})}finally{h(!1)}},[j]),I=(0,X.useCallback)(()=>w(!0),[]),L=(0,X.useCallback)(e=>E({from:e}),[]),R=(0,X.useCallback)(e=>A({name:e}),[]),ee=(0,X.useCallback)(async(t,n)=>{h(!0),p(null);try{let r=await fetch(`${D()}/profiles/${encodeURIComponent(t.name)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.saveFailed`,{status:r.status}))}l(t),n.length>0?s.warning(e(`profiles.toasts.savedWithUntargeted`),{description:e(`profiles.toasts.savedWithUntargetedDescription`,{agents:n.join(`, `)}),duration:6e3}):s.success(e(`profiles.toasts.saved`),{description:t.name})}catch(t){let n=t.message;p(n),s.error(e(`profiles.toasts.saveFailed`),{description:n})}finally{h(!1)}},[e]),z=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xe,{open:S,title:e(`profiles.createDialog.title`),description:e(`profiles.createDialog.description`),placeholder:`my-profile`,confirmLabel:e(`profiles.createDialog.confirmLabel`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.createDialog.invalidHint`),onConfirm:e=>void N(e),onCancel:()=>w(!1)}),T&&(0,Z.jsx)(xe,{open:!0,title:e(`profiles.duplicateDialog.title`,{name:T.from}),description:e(`profiles.duplicateDialog.description`),placeholder:`${T.from}-copy`,initialValue:`${T.from}-copy`,confirmLabel:e(`common:actions.duplicate`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.duplicateDialog.invalidHint`),onConfirm:e=>void P(T.from,e),onCancel:()=>E(null)}),O&&(0,Z.jsx)(Se,{open:!0,title:e(`profiles.deleteDialog.title`,{name:O.name}),description:e(`profiles.deleteDialog.description`),confirmLabel:e(`common:actions.delete`),destructive:!0,onConfirm:()=>void F(O.name),onCancel:()=>A(null)})]});return u?(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.loading`)})}):t.length===0?(0,Z.jsxs)(Z.Fragment,{children:[z,(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e(`profiles.empty.title`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1 mb-4`,children:e(`profiles.empty.body`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 justify-center`,children:[(0,Z.jsxs)(k,{size:`sm`,onClick:M,disabled:m,children:[(0,Z.jsx)(fe,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.migrateButton`)]}),(0,Z.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:I,disabled:m,children:[(0,Z.jsx)(y,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.blankButton`)]})]}),(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-3`,children:(0,Z.jsx)(i,{t:e,i18nKey:`profiles.empty.migrateExplainer`,components:{code:(0,Z.jsx)(`code`,{className:`text-foreground`})}})}),f&&(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-red-400 aurora-light:text-destructive`,children:f})]})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[z,(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,Z.jsxs)(`aside`,{className:`w-64 flex-shrink-0 border-r border-border flex flex-col`,children:[(0,Z.jsxs)(`div`,{className:`p-3 flex items-center justify-between`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e(`profiles.sidebar.title`)}),(0,Z.jsx)(k,{size:`sm`,variant:`ghost`,onClick:I,disabled:m,children:(0,Z.jsx)(y,{className:`w-3.5 h-3.5`})})]}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-auto px-2 pb-3`,children:t.map(t=>(0,Z.jsxs)(`div`,{className:`group mb-1 rounded-md px-2 py-1.5 text-xs cursor-pointer transition-colors flex items-center justify-between `+(t.name===r?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>o(t.name),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o(t.name)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),t.isDefault&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`profiles.sidebar.teamDefault`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,title:e(`common:actions.duplicate`),onClick:e=>{e.stopPropagation(),L(t.name)},children:(0,Z.jsx)(B,{className:`w-3 h-3`})}),!t.isDefault&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 aurora-light:text-destructive rounded`,title:e(`common:actions.delete`),onClick:e=>{e.stopPropagation(),R(t.name)},children:(0,Z.jsx)(C,{className:`w-3 h-3`})})]})]},t.name))})]}),(0,Z.jsxs)(`main`,{className:`flex-1 overflow-auto`,children:[f&&(0,Z.jsx)(`div`,{className:`mx-4 mt-4 px-3 py-2 text-xs rounded border border-red-500/30 aurora-light:border-destructive/30 bg-red-500/10 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive`,children:f}),c?(0,Z.jsx)(_e,{profile:c,onChange:l,onValidityChange:_,onSoftWarningsChange:e=>x(e.agentsMissingRouting),footer:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(k,{size:`sm`,onClick:()=>void ee(c,v),disabled:m||g.length>0,title:g.length>0?e(`profiles.editorFooter.fixValidationIssues`):void 0,children:[(0,Z.jsx)(b,{className:`w-3.5 h-3.5 mr-1.5`}),e(`common:actions.save`)]}),m&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`common:states.saving`)}),g.length>0&&(0,Z.jsx)(`span`,{className:`text-xs text-yellow-500 aurora-light:text-accent-warning`,children:e(`profiles.editorFooter.issuesToResolve`,{count:g.length})})]})},c.name):(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.selectPrompt`)})})]})]})]})}function $(e){let t=e.workflow.map((e,t)=>`${t+1}. ${e}`).join(`
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{o as r}from"./i18n-Bf9Ckd10.js";import{t as i}from"./Trans-CPISVji8.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{n as s}from"./dist-bVqfYmby.js";import{t as c}from"./arrow-left-CpIR4j7G.js";import{l,n as u,r as d,u as f}from"./MinimizedChatsContext-Cs34FPTz.js";import{n as p,t as m}from"./external-link-BcU5EWZp.js";import{t as h}from"./chevron-right-CViMxucY.js";import{t as g}from"./file-text-CFT-xXKN.js";import{t as _}from"./loader-circle-DcygOQpC.js";import{t as v}from"./pencil-C9RkrIPZ.js";import{t as y}from"./plus-CsnjfkmX.js";import{t as b}from"./save-28sIlCdr.js";import{t as x}from"./search-Cq_gE3Ik.js";import{t as S}from"./sparkles-DrY8hb0X.js";import{t as C}from"./trash-2-BOU3WdZZ.js";import{t as w}from"./triangle-alert-H9T4jAmh.js";import{t as T}from"./x-CBMI9ejn.js";import{n as E}from"./useSharedWebSocket-DaPh7QBL.js";import{t as D}from"./api-B2M7CtDw.js";import{r as O}from"./useDesktop-B4pSBIDd.js";import{t as k}from"./button-BUIIBQPT.js";import{a as A,c as j,i as M,n as N,o as P,r as F,s as I,t as L}from"./dialog-CzIekCw0.js";import{$ as R,At as ee,B as z,Et as B,G as V,H,J as U,K as W,Pt as te,R as G,U as K,V as ne,W as re,Y as ie,bt as q,dt as ae,ft as oe,k as se,lt as ce,q as J,y as Y,yt as le,z as ue}from"./index-CewRMo0W.js";var de=o(`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`}]]),fe=o(`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`}]]),X=e(t(),1),Z=n(),pe=/^[a-z0-9][a-z0-9-]*$/;function me({open:e,mode:t=`add`,initial:n,chainAgents:r,onConfirm:o,onCancel:s}){let{t:c}=a(`agents`),[l,u]=(0,X.useState)(``),[d,f]=(0,X.useState)(r[0]??``);(0,X.useEffect)(()=>{e&&(t===`edit`&&n?(u(n.tags.join(`, `)),f(r.includes(n.agent)?n.agent:r[0]??``)):(u(``),f(r[0]??``)))},[e,t,n,r]);let p=l.split(`,`).map(e=>e.trim()).filter(Boolean),m=p.filter(e=>!pe.test(e)),h=p.length>0&&m.length===0&&r.includes(d);return(0,Z.jsx)(L,{open:e,onOpenChange:e=>{e||s()},children:(0,Z.jsxs)(N,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsxs)(A,{children:[(0,Z.jsx)(P,{children:c(t===`edit`?`routingRule.editTitle`:`routingRule.addTitle`)}),(0,Z.jsx)(F,{children:c(t===`edit`?`routingRule.editDescription`:`routingRule.addDescription`)})]}),(0,Z.jsxs)(`div`,{className:`py-2 space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:c(`routingRule.tagsLabel`)}),(0,Z.jsx)(Y,{autoFocus:!0,value:l,onChange:e=>u(e.target.value),placeholder:`frontend, ui`,"aria-label":c(`routingRule.tagsLabel`),className:`text-sm font-mono`}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:(0,Z.jsx)(i,{t:c,i18nKey:`routingRule.tagsHint`,components:{code:(0,Z.jsx)(`code`,{})}})}),m.length>0&&(0,Z.jsx)(`p`,{className:`text-[11px] text-red-400 aurora-light:text-destructive mt-1`,children:c(`routingRule.invalidTags`,{count:m.length,tags:m.join(`, `)})})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:c(`routingRule.routeToLabel`)}),(0,Z.jsx)(`select`,{value:d,onChange:e=>f(e.target.value),"aria-label":c(`routingRule.routeToLabel`),className:`w-full h-9 px-2 text-sm rounded-md border border-border bg-background`,children:r.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mt-1`,children:c(`routingRule.routeToHint`)})]})]}),(0,Z.jsxs)(M,{children:[(0,Z.jsx)(k,{variant:`ghost`,size:`sm`,onClick:s,children:c(`common:actions.cancel`)}),(0,Z.jsx)(k,{size:`sm`,onClick:()=>o(p,d),disabled:!h,children:c(t===`edit`?`routingRule.saveChanges`:`routingRule.addRule`)})]})]})})}var Q=new Set([`sr-architect`,`sr-developer`,`sr-reviewer`,`sr-merge-resolver`]),he=[`sonnet`,`fable`,`opus`,`haiku`],ge=/^[a-z0-9][a-z0-9-]*$/;function _e({profile:e,onChange:t,footer:n,onValidityChange:r,onSoftWarningsChange:o}){let{t:s}=a(`agentstudio`),[c,l]=(0,X.useState)([]),[u,d]=(0,X.useState)(!1),[f,p]=(0,X.useState)(!1),[m,h]=(0,X.useState)(null);(0,X.useEffect)(()=>{let e=!1;return fetch(`${D()}/profiles/catalog`).then(e=>e.ok?e.json():{agents:[]}).then(t=>{e||l(t.agents)}).catch(()=>{e||l([])}),()=>{e=!0}},[]);let g=n=>{let r=JSON.parse(JSON.stringify(e));n(r),t(r)},_=new Set(e.agents.map(e=>e.id)),v=c.filter(e=>!_.has(e.id)),b=(0,X.useMemo)(()=>{let t=[];for(let n of Q)e.agents.some(e=>e.id===n)||t.push(s(`profileEditor.validation.missingBaseline`,{agent:n}));let n=e.routing.filter(e=>`default`in e&&e.default===!0);if(n.length>1&&t.push(s(`profileEditor.validation.multipleDefaultRules`,{found:n.length})),n.length===1){let n=e.routing[e.routing.length-1];`default`in n&&n.default===!0||t.push(s(`profileEditor.validation.defaultRuleNotLast`))}for(let n of e.routing)if(e.agents.some(e=>e.id===n.agent)||t.push(s(`profileEditor.validation.unknownRoutingAgent`,{agent:n.agent})),`tags`in n){let e=n.tags.filter(e=>!ge.test(e));e.length>0&&t.push(s(`profileEditor.validation.invalidTags`,{agent:n.agent,tags:e.join(`, `)}))}return t},[e,s]),x=(0,X.useMemo)(()=>{if(e.routing.length===0)return[];let t=new Set(e.routing.map(e=>e.agent));return e.agents.filter(e=>!Q.has(e.id)&&!t.has(e.id)).map(e=>e.id)},[e]),S=(0,X.useMemo)(()=>e.routing.some(e=>`default`in e&&e.default===!0),[e.routing]);(0,X.useEffect)(()=>{r&&r(b)},[b,r]),(0,X.useEffect)(()=>{o&&o({agentsMissingRouting:x})},[x,o]);let C=e=>{g(t=>{let n={id:e,model:`sonnet`},r=t.agents.findIndex(e=>e.id===`sr-merge-resolver`);r>=0?t.agents.splice(r,0,n):t.agents.push(n)}),d(!1)},w=t=>{let n=e.agents[t];Q.has(n.id)||g(e=>{e.agents.splice(t,1),e.routing=e.routing.filter(e=>e.agent!==n.id)})},E=(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=ue(e.agents,r,i),o=a.findIndex(e=>e.id===`sr-architect`);if(o>0){let[e]=a.splice(o,1);a.unshift(e)}let s=a.findIndex(e=>e.id===`sr-merge-resolver`);if(s>=0&&s!==a.length-1){let[e]=a.splice(s,1);a.push(e)}g(e=>{e.agents=a})},O=U(J(V,{activationConstraint:{distance:4}}),J(re,{coordinateGetter:z})),A=e=>{let{active:t,over:n}=e;n&&E(String(t.id),String(n.id))},j=(e,t)=>{g(n=>{n.agents[e].model=t})},M=(e,t)=>{g(n=>{let r={tags:e,agent:t},i=n.routing.findIndex(e=>`default`in e&&e.default===!0);i>=0?n.routing.splice(i,0,r):n.routing.push(r)}),p(!1)},N=()=>{g(e=>{e.routing.some(e=>`default`in e&&e.default===!0)||e.agents.some(e=>e.id===`sr-developer`)&&e.routing.push({default:!0,agent:`sr-developer`})})},P=e=>`default`in e&&e.default===!0,F=(e,t)=>{g(n=>{let r=n.routing[e];r&&(P(r)||(r.agent=t))})},I=(e,t,n)=>{g(r=>{let i=r.routing[e];i&&(P(i)||(i.tags=t,i.agent=n))})},L=e=>{g(t=>{let n=t.routing[e];n&&(P(n)||t.routing.splice(e,1))})},R=(t,n)=>{let r=t+n;if(r<0||r>=e.routing.length)return;let i=e.routing[t],a=e.routing[r];P(i)||P(a)||g(e=>{let[n]=e.routing.splice(t,1);e.routing.splice(r,0,n)})};return(0,Z.jsxs)(`div`,{className:`p-6 space-y-6 max-w-3xl`,children:[(0,Z.jsx)(me,{open:f,mode:`add`,chainAgents:e.agents.map(e=>e.id),onConfirm:M,onCancel:()=>p(!1)}),(0,Z.jsx)(me,{open:m!==null,mode:`edit`,initial:m!==null&&e.routing[m]&&!(`default`in e.routing[m])?{tags:e.routing[m].tags,agent:e.routing[m].agent}:void 0,chainAgents:e.agents.map(e=>e.id),onConfirm:(e,t)=>{m!==null&&(I(m,e,t),h(null))},onCancel:()=>h(null)}),b.length>0&&(0,Z.jsxs)(`div`,{className:`px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Z.jsx)(`div`,{className:`font-medium mb-1`,children:s(`profileEditor.validationSummary`,{count:b.length})}),(0,Z.jsx)(`ul`,{className:`list-disc list-inside space-y-0.5`,children:b.map((e,t)=>(0,Z.jsx)(`li`,{children:e},t))})]}),(0,Z.jsxs)(`section`,{className:`space-y-3`,children:[(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:s(`profileEditor.nameLabel`)}),(0,Z.jsx)(Y,{value:e.name,disabled:!0,className:`text-sm`})]}),(0,Z.jsxs)(`div`,{children:[(0,Z.jsx)(`label`,{className:`block text-xs font-medium text-muted-foreground mb-1`,children:s(`profileEditor.descriptionLabel`)}),(0,Z.jsx)(Y,{value:e.description??``,onChange:e=>g(t=>{t.description=e.target.value}),className:`text-sm`,placeholder:s(`profileEditor.descriptionPlaceholder`)})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2`,children:s(`profileEditor.orchestrator.heading`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-3 p-3 rounded-md border border-border`,children:[(0,Z.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-mono text-foreground truncate`,children:`/specrails:implement · /specrails:batch-implement`}),(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:s(`profileEditor.orchestrator.description`)})]}),(0,Z.jsx)(be,{value:e.orchestrator.model,onChange:e=>g(t=>{t.orchestrator.model=e})})]})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:s(`profileEditor.agentChain.heading`,{n:e.agents.length})}),(0,Z.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>d(e=>!e),disabled:v.length===0,title:v.length===0?s(`profileEditor.agentChain.addDisabledTitle`):s(`profileEditor.agentChain.addTitle`),children:[(0,Z.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`common:actions.add`)]})]}),u&&(0,Z.jsxs)(`div`,{className:`mb-2 p-2 rounded-md border border-border bg-muted/30`,children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5 px-1`,children:[(0,Z.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:s(`profileEditor.agentChain.pickFromCatalog`,{n:v.length})}),(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:()=>d(!1),title:s(`common:actions.close`),children:(0,Z.jsx)(T,{className:`w-3 h-3`})})]}),v.length===0?(0,Z.jsx)(`div`,{className:`px-2 py-3 text-xs text-muted-foreground text-center`,children:s(`profileEditor.agentChain.emptyCatalog`)}):(0,Z.jsx)(`div`,{className:`space-y-0.5 max-h-64 overflow-auto`,children:v.map(e=>(0,Z.jsxs)(`button`,{type:`button`,onClick:()=>C(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,Z.jsx)(`span`,{className:`text-sm font-mono`,children:e.id}),(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded `+(e.kind===`custom`?`bg-purple-500/15 aurora-light:bg-accent-secondary/15 text-purple-400 aurora-light:text-accent-secondary`:`bg-muted text-muted-foreground`),children:s(`profileEditor.agentChain.kind.${e.kind}`)})]},e.id))})]}),(0,Z.jsx)(K,{sensors:O,collisionDetection:W,onDragEnd:A,children:(0,Z.jsx)(G,{items:e.agents.map(e=>e.id),strategy:H,children:(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:e.agents.map((e,t)=>(0,Z.jsx)(ve,{agent:e,canRemove:!Q.has(e.id),onModel:e=>j(t,e),onRemove:()=>w(t)},e.id))})})})]}),(0,Z.jsxs)(`section`,{children:[(0,Z.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Z.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:s(`profileEditor.routing.heading`,{n:e.routing.length})}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-1`,children:[!S&&(0,Z.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:N,disabled:e.agents.length===0,title:e.agents.length===0?s(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Z.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`profileEditor.routing.addDefault`)]}),(0,Z.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:()=>p(!0),disabled:e.agents.length===0,title:e.agents.length===0?s(`profileEditor.routing.needAgentsTitle`):void 0,children:[(0,Z.jsx)(y,{className:`w-3.5 h-3.5 mr-1`}),` `,s(`profileEditor.routing.addRule`)]})]})]}),(0,Z.jsx)(`p`,{className:`text-[11px] text-muted-foreground mb-2`,children:s(`profileEditor.routing.explainer`)}),x.length>0&&(0,Z.jsxs)(`div`,{className:`mb-2 px-3 py-2 text-xs rounded-md border border-yellow-500/30 aurora-light:border-accent-warning/30 bg-yellow-500/10 aurora-light:bg-accent-warning/10 text-yellow-500 aurora-light:text-accent-warning`,children:[(0,Z.jsx)(`div`,{className:`font-medium mb-1`,children:s(`profileEditor.routing.untargetedTitle`)}),(0,Z.jsx)(`div`,{children:(0,Z.jsx)(i,{t:s,i18nKey:`profileEditor.routing.untargetedDetail`,values:{agents:x.join(`, `)},components:{mono:(0,Z.jsx)(`span`,{className:`font-mono`})}})})]}),(0,Z.jsx)(`div`,{className:`space-y-1.5`,children:e.routing.map((t,n)=>{let r=`default`in t&&t.default===!0;return(0,Z.jsx)(ye,{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=>F(n,e),onEdit:()=>h(n),onUp:()=>R(n,-1),onDown:()=>R(n,1),onRemove:()=>L(n)},n)})})]}),n&&(0,Z.jsx)(`div`,{className:`pt-3 border-t border-border`,children:n})]})}function ve({agent:e,canRemove:t,onModel:n,onRemove:r}){let{t:i}=a(`agentstudio`),o=Q.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}=ne({id:e.id});return(0,Z.jsxs)(`div`,{ref:d,style:{transform:ie.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,Z.jsx)(`button`,{type:`button`,className:`flex-shrink-0 p-0.5 rounded text-muted-foreground cursor-grab active:cursor-grabbing hover:text-foreground`,title:i(`profileEditor.agentRow.dragTitle`),"aria-label":i(`profileEditor.agentRow.dragHandleAria`),...l,...u,children:(0,Z.jsx)(q,{className:`w-3.5 h-3.5`})}),(0,Z.jsx)(`span`,{className:`text-sm font-mono flex-1 truncate`,children:e.id}),s&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:i(`profileEditor.agentRow.pinnedFirstTitle`),children:[(0,Z.jsx)(ae,{className:`w-2.5 h-2.5 rotate-[135deg]`}),` `,i(`profileEditor.agentRow.pinnedFirst`)]}),c&&(0,Z.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-accent-primary/15 text-accent-primary`,title:i(`profileEditor.agentRow.pinnedLastTitle`),children:[(0,Z.jsx)(ae,{className:`w-2.5 h-2.5 rotate-45`}),` `,i(`profileEditor.agentRow.pinnedLast`)]}),o&&!s&&!c&&(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,children:i(`profileEditor.agentRow.required`)}),(0,Z.jsx)(be,{value:e.model??`sonnet`,onChange:n}),(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded disabled:opacity-30 disabled:cursor-not-allowed opacity-0 group-hover:opacity-100 transition-opacity`,onClick:r,disabled:!t,title:i(t?`common:actions.remove`:`profileEditor.agentRow.requiredRemoveTitle`),children:(0,Z.jsx)(T,{className:`w-3 h-3`})})]})}function ye({rule:e,ordinal:t,isLast:n,canMove:r,canRemove:i,canEdit:o,chainAgents:s,onAgentChange:c,onEdit:l,onUp:u,onDown:d,onRemove:p}){let{t:m}=a(`agentstudio`),h=`default`in e&&e.default===!0;return(0,Z.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,Z.jsxs)(`span`,{className:`text-[10px] font-mono text-muted-foreground w-5 text-center flex-shrink-0`,children:[t,`.`]}),h?(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground flex-1`,children:m(`profileEditor.routingRow.everythingElse`)}):(0,Z.jsx)(`span`,{className:`text-xs flex-1 flex gap-1 flex-wrap items-center`,children:e.tags.map(e=>(0,Z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded bg-muted font-mono text-[11px]`,children:e},e))}),(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`→`}),h?(0,Z.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":m(`profileEditor.routingRow.defaultTargetAria`),title:m(`profileEditor.routingRow.defaultTargetTitle`),children:e.agent}):(0,Z.jsx)(`select`,{value:e.agent,onChange:e=>c(e.target.value),"aria-label":m(`profileEditor.routingRow.targetAria`,{ordinal:t}),className:`h-7 max-w-[15rem] px-2 text-xs font-mono rounded border border-border bg-background`,children:s.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))}),(0,Z.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[o&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:l,title:m(`profileEditor.routingRow.editTitle`),"aria-label":m(`profileEditor.routingRow.editAria`,{ordinal:t}),children:(0,Z.jsx)(v,{className:`w-3 h-3`})}),r&&!n&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:d,title:m(`profileEditor.routingRow.moveDown`),children:(0,Z.jsx)(te,{className:`w-3 h-3`})}),r&&t>1&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,onClick:u,title:m(`profileEditor.routingRow.moveUp`),children:(0,Z.jsx)(f,{className:`w-3 h-3`})}),i&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 aurora-light:hover:bg-destructive/15 text-red-400 aurora-light:text-destructive rounded`,onClick:p,title:m(`common:actions.remove`),children:(0,Z.jsx)(T,{className:`w-3 h-3`})})]}),h&&(0,Z.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted text-muted-foreground`,title:m(`profileEditor.routingRow.coreDefaultTitle`),children:m(`profileEditor.routingRow.coreDefaultBadge`)})]})}function be({value:e,onChange:t}){return(0,Z.jsx)(`select`,{value:e,onChange:e=>t(e.target.value),className:`h-7 px-2 text-xs rounded border border-border bg-background`,children:he.map(e=>(0,Z.jsx)(`option`,{value:e,children:e},e))})}function xe({open:e,title:t,description:n,placeholder:r,initialValue:i=``,confirmLabel:o,inputPattern:s,inputInvalidHint:c,onConfirm:l,onCancel:u}){let{t:d}=a(),[f,p]=(0,X.useState)(i);(0,X.useEffect)(()=>{e&&p(i)},[e,i]);let m=f.trim(),h=!s||s.test(m),g=m.length>0&&h;return(0,Z.jsx)(L,{open:e,onOpenChange:e=>{e||u()},children:(0,Z.jsxs)(N,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsx)(A,{children:(0,Z.jsx)(P,{children:t})}),(0,Z.jsxs)(`div`,{className:`py-2 space-y-2`,children:[n&&(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n}),(0,Z.jsx)(Y,{autoFocus:!0,value:f,placeholder:r,onChange:e=>p(e.target.value),onKeyDown:e=>{e.key===`Enter`&&g&&l(m)},className:`text-sm font-mono`}),m.length>0&&!h&&c&&(0,Z.jsx)(`p`,{className:`text-[11px] text-yellow-500 aurora-light:text-accent-warning`,children:c})]}),(0,Z.jsxs)(M,{children:[(0,Z.jsx)(k,{variant:`ghost`,size:`sm`,onClick:u,children:d(`actions.cancel`)}),(0,Z.jsx)(k,{size:`sm`,onClick:()=>l(m),disabled:!g,children:o??d(`actions.confirm`)})]})]})})}function Se({open:e,title:t,description:n,confirmLabel:r,destructive:i=!1,onConfirm:o,onCancel:s}){let{t:c}=a();return(0,Z.jsx)(L,{open:e,onOpenChange:e=>{e||s()},children:(0,Z.jsxs)(N,{movableResizable:!0,className:`max-w-md`,children:[(0,Z.jsx)(A,{children:(0,Z.jsx)(P,{children:t})}),n&&(0,Z.jsx)(`div`,{className:`py-2`,children:(0,Z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:n})}),(0,Z.jsxs)(M,{children:[(0,Z.jsx)(k,{variant:`ghost`,size:`sm`,onClick:s,children:c(`actions.cancel`)}),(0,Z.jsx)(k,{size:`sm`,onClick:o,className:i?`bg-red-500 hover:bg-red-600 text-white`:void 0,children:r??c(`actions.confirm`)})]})]})})}function Ce(){let{t:e}=a(`agents`),[t,n]=(0,X.useState)([]),[r,o]=(0,X.useState)(null),[c,l]=(0,X.useState)(null),[u,d]=(0,X.useState)(!0),[f,p]=(0,X.useState)(null),[m,h]=(0,X.useState)(!1),[g,_]=(0,X.useState)([]),[v,x]=(0,X.useState)([]),[S,w]=(0,X.useState)(!1),[T,E]=(0,X.useState)(null),[O,A]=(0,X.useState)(null),j=(0,X.useCallback)(async()=>{d(!0),p(null);try{let t=await fetch(`${D()}/profiles`);if(!t.ok)throw Error(e(`profiles.errors.listFailed`,{status:t.status}));let i=await t.json();n(i.profiles),i.profiles.length>0&&!r&&o(i.profiles[0].name)}catch(e){p(e.message)}finally{d(!1)}},[r]);(0,X.useEffect)(()=>{j()},[j]),(0,X.useEffect)(()=>{if(!r){l(null);return}let t=!1;return fetch(`${D()}/profiles/${encodeURIComponent(r)}`).then(t=>{if(!t.ok)throw Error(e(`profiles.errors.loadFailed`,{status:t.status}));return t.json()}).then(e=>{t||l(e.profile)}).catch(e=>{t||p(e.message)}),()=>{t=!0}},[r]);let M=(0,X.useCallback)(async()=>{h(!0),p(null);try{let t=await fetch(`${D()}/profiles/migrate-from-settings`,{method:`POST`});if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`profiles.errors.migrationFailed`,{status:t.status}))}await j(),o(`default`),s.success(e(`profiles.toasts.migrated`),{description:e(`profiles.toasts.migratedDescription`)})}catch(t){let n=t.message;p(n),s.error(e(`profiles.toasts.migrationFailed`),{description:n})}finally{h(!1)}},[j]),N=(0,X.useCallback)(async t=>{w(!1),h(!0),p(null);try{let n={schemaVersion:1,name:t,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`}]},r=await fetch(`${D()}/profiles`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify(n)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.createFailed`,{status:r.status}))}await j(),o(t),s.success(e(`profiles.toasts.created`),{description:t})}catch(t){let n=t.message;p(n),s.error(e(`profiles.toasts.createFailed`),{description:n})}finally{h(!1)}},[j]),P=(0,X.useCallback)(async(t,n)=>{E(null),h(!0),p(null);try{let r=await fetch(`${D()}/profiles/${encodeURIComponent(t)}/duplicate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({name:n})});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.duplicateFailed`,{status:r.status}))}await j(),o(n),s.success(e(`profiles.toasts.duplicated`),{description:e(`profiles.toasts.duplicatedDescription`,{from:t,to:n})})}catch(t){let n=t.message;p(n),s.error(e(`profiles.toasts.duplicateFailed`),{description:n})}finally{h(!1)}},[j]),F=(0,X.useCallback)(async t=>{A(null),h(!0),p(null);try{let n=await fetch(`${D()}/profiles/${encodeURIComponent(t)}`,{method:`DELETE`});if(!n.ok){let t=await n.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.deleteFailed`,{status:n.status}))}o(e=>e===t?null:e),await j(),s.success(e(`profiles.toasts.deleted`),{description:t})}catch(t){let n=t.message;p(n),s.error(e(`profiles.toasts.deleteFailed`),{description:n})}finally{h(!1)}},[j]),I=(0,X.useCallback)(()=>w(!0),[]),L=(0,X.useCallback)(e=>E({from:e}),[]),R=(0,X.useCallback)(e=>A({name:e}),[]),ee=(0,X.useCallback)(async(t,n)=>{h(!0),p(null);try{let r=await fetch(`${D()}/profiles/${encodeURIComponent(t.name)}`,{method:`PATCH`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(!r.ok){let t=await r.json().catch(()=>({}));throw Error(t.error??e(`profiles.errors.saveFailed`,{status:r.status}))}l(t),n.length>0?s.warning(e(`profiles.toasts.savedWithUntargeted`),{description:e(`profiles.toasts.savedWithUntargetedDescription`,{agents:n.join(`, `)}),duration:6e3}):s.success(e(`profiles.toasts.saved`),{description:t.name})}catch(t){let n=t.message;p(n),s.error(e(`profiles.toasts.saveFailed`),{description:n})}finally{h(!1)}},[e]),z=(0,Z.jsxs)(Z.Fragment,{children:[(0,Z.jsx)(xe,{open:S,title:e(`profiles.createDialog.title`),description:e(`profiles.createDialog.description`),placeholder:`my-profile`,confirmLabel:e(`profiles.createDialog.confirmLabel`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.createDialog.invalidHint`),onConfirm:e=>void N(e),onCancel:()=>w(!1)}),T&&(0,Z.jsx)(xe,{open:!0,title:e(`profiles.duplicateDialog.title`,{name:T.from}),description:e(`profiles.duplicateDialog.description`),placeholder:`${T.from}-copy`,initialValue:`${T.from}-copy`,confirmLabel:e(`common:actions.duplicate`),inputPattern:/^[a-z0-9][a-z0-9-]*$/,inputInvalidHint:e(`profiles.duplicateDialog.invalidHint`),onConfirm:e=>void P(T.from,e),onCancel:()=>E(null)}),O&&(0,Z.jsx)(Se,{open:!0,title:e(`profiles.deleteDialog.title`,{name:O.name}),description:e(`profiles.deleteDialog.description`),confirmLabel:e(`common:actions.delete`),destructive:!0,onConfirm:()=>void F(O.name),onCancel:()=>A(null)})]});return u?(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.loading`)})}):t.length===0?(0,Z.jsxs)(Z.Fragment,{children:[z,(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsxs)(`div`,{className:`text-center max-w-md`,children:[(0,Z.jsx)(`div`,{className:`text-sm font-medium text-foreground`,children:e(`profiles.empty.title`)}),(0,Z.jsx)(`div`,{className:`text-xs text-muted-foreground mt-1 mb-4`,children:e(`profiles.empty.body`)}),(0,Z.jsxs)(`div`,{className:`flex items-center gap-2 justify-center`,children:[(0,Z.jsxs)(k,{size:`sm`,onClick:M,disabled:m,children:[(0,Z.jsx)(fe,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.migrateButton`)]}),(0,Z.jsxs)(k,{size:`sm`,variant:`ghost`,onClick:I,disabled:m,children:[(0,Z.jsx)(y,{className:`w-3.5 h-3.5 mr-1.5`}),` `,e(`profiles.empty.blankButton`)]})]}),(0,Z.jsx)(`div`,{className:`text-[11px] text-muted-foreground/70 mt-3`,children:(0,Z.jsx)(i,{t:e,i18nKey:`profiles.empty.migrateExplainer`,components:{code:(0,Z.jsx)(`code`,{className:`text-foreground`})}})}),f&&(0,Z.jsx)(`div`,{className:`mt-3 text-xs text-red-400 aurora-light:text-destructive`,children:f})]})})]}):(0,Z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[z,(0,Z.jsxs)(`div`,{className:`flex flex-1 min-h-0`,children:[(0,Z.jsxs)(`aside`,{className:`w-64 flex-shrink-0 border-r border-border flex flex-col`,children:[(0,Z.jsxs)(`div`,{className:`p-3 flex items-center justify-between`,children:[(0,Z.jsx)(`div`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wide`,children:e(`profiles.sidebar.title`)}),(0,Z.jsx)(k,{size:`sm`,variant:`ghost`,onClick:I,disabled:m,children:(0,Z.jsx)(y,{className:`w-3.5 h-3.5`})})]}),(0,Z.jsx)(`div`,{className:`flex-1 overflow-auto px-2 pb-3`,children:t.map(t=>(0,Z.jsxs)(`div`,{className:`group mb-1 rounded-md px-2 py-1.5 text-xs cursor-pointer transition-colors flex items-center justify-between `+(t.name===r?`bg-accent text-foreground`:`text-muted-foreground hover:bg-accent/50 hover:text-foreground`),onClick:()=>o(t.name),role:`button`,tabIndex:0,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&o(t.name)},children:[(0,Z.jsxs)(`div`,{className:`flex items-center gap-1.5 min-w-0`,children:[(0,Z.jsx)(`span`,{className:`truncate font-medium`,children:t.name}),t.isDefault&&(0,Z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:e(`profiles.sidebar.teamDefault`)})]}),(0,Z.jsxs)(`div`,{className:`flex gap-0.5 opacity-0 group-hover:opacity-100 transition-opacity`,children:[(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-accent rounded`,title:e(`common:actions.duplicate`),onClick:e=>{e.stopPropagation(),L(t.name)},children:(0,Z.jsx)(B,{className:`w-3 h-3`})}),!t.isDefault&&(0,Z.jsx)(`button`,{type:`button`,className:`p-1 hover:bg-red-500/20 text-red-400 aurora-light:text-destructive rounded`,title:e(`common:actions.delete`),onClick:e=>{e.stopPropagation(),R(t.name)},children:(0,Z.jsx)(C,{className:`w-3 h-3`})})]})]},t.name))})]}),(0,Z.jsxs)(`main`,{className:`flex-1 overflow-auto`,children:[f&&(0,Z.jsx)(`div`,{className:`mx-4 mt-4 px-3 py-2 text-xs rounded border border-red-500/30 aurora-light:border-destructive/30 bg-red-500/10 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive`,children:f}),c?(0,Z.jsx)(_e,{profile:c,onChange:l,onValidityChange:_,onSoftWarningsChange:e=>x(e.agentsMissingRouting),footer:(0,Z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Z.jsxs)(k,{size:`sm`,onClick:()=>void ee(c,v),disabled:m||g.length>0,title:g.length>0?e(`profiles.editorFooter.fixValidationIssues`):void 0,children:[(0,Z.jsx)(b,{className:`w-3.5 h-3.5 mr-1.5`}),e(`common:actions.save`)]}),m&&(0,Z.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e(`common:states.saving`)}),g.length>0&&(0,Z.jsx)(`span`,{className:`text-xs text-yellow-500 aurora-light:text-accent-warning`,children:e(`profiles.editorFooter.issuesToResolve`,{count:g.length})})]})},c.name):(0,Z.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,Z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`profiles.selectPrompt`)})})]})]})]})}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 +1 @@
|
|
|
1
|
-
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{d as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{t as i}from"./Trans-CPISVji8.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{t as s}from"./arrow-up-right-9DoMn7fD.js";import{n as c}from"./useSharedWebSocket-DaPh7QBL.js";import{t as l}from"./api-B2M7CtDw.js";import{n as u,r as d}from"./useDesktop-B4pSBIDd.js";import{t as f}from"./clsx-CjueKrWZ.js";import{n as p,t as m}from"./spending-DMnCXy84.js";import{j as h,lt as g}from"./index-F9r8mWP_.js";import{t as _}from"./ExportDropdown-BrtfWzEG.js";import{A as v,B as y,C as b,D as x,E as S,F as ee,G as te,H as C,I as w,J as T,K as E,L as D,M as O,N as k,O as A,P as j,Q as M,R as N,S as P,T as F,V as ne,X as I,Z as L,_ as R,_t as z,a as B,at as re,b as V,c as H,ct as ie,et as ae,f as oe,g as se,gt as U,h as ce,i as W,j as le,k as ue,l as de,lt as G,m as fe,n as pe,nt as me,o as he,ot as ge,p as _e,pt as K,q as ve,r as ye,rt as be,s as xe,st as Se,t as Ce,tt as we,ut as q,v as Te,x as Ee,y as De,z as Oe}from"./BarChart-nBOMNfiy.js";var ke=o(`arrow-down-right`,[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]),J=e(t(),1),Y=n();function X(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function Ae(e){return e>=1e3?`$${(e/1e3).toFixed(1)}k`:`$${e.toFixed(2)}`}function je(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}var Me=[`job`,`explore-spec`,`quick-spec`,`ai-edit`,`chat-sidebar`,`spec-launcher`,`proposal`,`agent-studio`,`setup`,`smash`,`file-summary`,`loop`];function Ne({data:e,loading:t,period:n}){let{t:r}=a(`analytics`),[i,o]=(0,J.useState)(0),c=(0,J.useRef)(0),l=(0,J.useRef)(null),u=(0,J.useRef)(0);if((0,J.useEffect)(()=>{if(!e)return;let t=e.summary.totalCostUsd,n=++u.current;if(l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),c.current===0&&t>0){let e=performance.now(),r=i=>{if(n!==u.current)return;let a=Math.min(1,(i-e)/600),s=1-(1-a)**3;o(0+(t-0)*s),a<1?l.current=requestAnimationFrame(r):l.current=null};l.current=requestAnimationFrame(r)}else o(t);return c.current=t,()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)}},[e]),t&&!e)return(0,Y.jsx)(`div`,{className:`h-44 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let d=e.summary.totalCostUsd,f=e.summary.totalRuns,h=e.summary.totalTokens??0,g=e.summary.totalEstimatedCostUsd??0,_=e.summary.deltaPct,v=e.trackingStartedAt,y=g>0,b=e.bySurface.map(e=>e.surface).filter(e=>!Me.includes(e)),x=[...Me,...b].map(t=>{let n=e.bySurface.find(e=>e.surface===t);return{surface:t,costUsd:n?.costUsd??0,count:n?.count??0}}),S=n?r(`windowLabels.${n}`):null;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-card/80 to-card/40 p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 mb-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground mb-1 flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{children:r(`hero.spending`)}),S&&(0,Y.jsxs)(`span`,{"data-testid":`hero-window-label`,className:`normal-case tracking-normal text-muted-foreground/70 font-normal`,children:[`· `,S]})]}),(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,Y.jsx)(`div`,{className:`text-5xl font-semibold tabular-nums tracking-tight`,children:Ae(i)}),_!==null&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs font-medium ${_>=0?`text-accent-warning`:`text-accent-success`}`,children:[_>=0?(0,Y.jsx)(s,{className:`w-3 h-3`}):(0,Y.jsx)(ke,{className:`w-3 h-3`}),r(`hero.vsPrev`,{pct:Math.abs(_).toFixed(0)})]})]}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 tabular-nums flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:r(`hero.invocations`,{count:f})}),h>0&&(0,Y.jsx)(`span`,{className:`text-muted-foreground/80`,title:r(`hero.tokensTooltip`),children:r(`hero.tokens`,{tokens:je(h)})}),y&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,title:r(`hero.includesEstimatedTooltip`,{amount:X(g)}),children:r(`hero.includesEstimated`,{amount:X(g)})})]})]}),f===0&&v&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`hero.trackingStarted`,{date:v.slice(0,10)})})]}),f===0?(0,Y.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-6 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`hero.emptyState`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:v?r(`hero.trackingStarted`,{date:v.slice(0,10)}):r(`hero.trackingStartedFallback`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-3 w-full rounded-full overflow-hidden bg-background-deep flex`,children:x.map(e=>{let t=d>0?e.costUsd/d*100:0;return t===0?null:(0,Y.jsx)(`div`,{className:`h-full ${m[e.surface].dot}`,style:{width:`${t}%`},title:r(`hero.segmentTitle`,{label:p[e.surface],value:X(e.costUsd)})},e.surface)})}),(0,Y.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs`,children:x.filter(e=>e.costUsd>0).map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 tabular-nums`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full ${m[e.surface].dot}`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:p[e.surface]}),(0,Y.jsx)(`span`,{className:`text-foreground font-medium`,children:X(e.costUsd)}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/80`,children:e.count})]},e.surface))})]})]})}var Pe={claude:`Claude`,codex:`Codex`,gemini:`Gemini`},Fe={claude:`bg-accent-info`,codex:`bg-accent-highlight`,gemini:`bg-accent-success`};function Ie(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=.01?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function Le(e){return Pe[e]??e}function Re(e){return Fe[e]??`bg-accent-secondary`}function ze({data:e,loading:t}){let{t:n}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-32 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e||e.byProvider.length===0||e.byProvider.length===1)return null;let r=e.byProvider.reduce((e,t)=>e+t.costUsd+t.estimatedCostUsd,0);return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsx)(`div`,{className:`flex items-baseline justify-between mb-3`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:n(`providerCard.title`)}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground/70 mt-0.5`,children:(0,Y.jsx)(i,{ns:`analytics`,i18nKey:`providerCard.description`,components:{tilde:(0,Y.jsx)(`span`,{className:`font-medium`})}})})]})}),r===0?(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:n(`providerCard.noCost`)}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-2 w-full rounded-full overflow-hidden bg-background-deep flex mb-3`,children:e.byProvider.map(e=>{let t=e.costUsd+e.estimatedCostUsd,i=r>0?t/r*100:0;if(i===0)return null;let a=`${e.costUsd===0&&e.estimatedCostUsd>0?`~`:``}${Ie(t)}`;return(0,Y.jsx)(`div`,{className:`h-full ${Re(e.provider)}`,style:{width:`${i}%`},title:n(`providerCard.segmentTitle`,{label:Le(e.provider),value:a,count:e.count})},e.provider)})}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.byProvider.map(e=>(0,Y.jsx)(Be,{entry:e},e.provider))})]})]})}function Be({entry:e}){let{t}=a(`analytics`),n=e.costUsd+e.estimatedCostUsd,r=e.costUsd===0&&e.estimatedCostUsd>0,i=e.count>0&&e.costUsd===0&&e.estimatedCostUsd===0;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md border border-border/30 px-2.5 py-1.5`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${Re(e.provider)}`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:Le(e.provider)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:t(`runs`,{count:e.count})}),i?(0,Y.jsx)(`span`,{className:`ml-auto text-xs font-medium text-muted-foreground/80 italic`,title:t(`providerCard.costUnavailableTooltip`),children:t(`providerCard.costUnavailable`)}):(0,Y.jsxs)(`span`,{className:`ml-auto text-xs font-medium tabular-nums`,children:[r?`~`:``,Ie(n)]})]})}var Ve=[`option`,`isActive`];function Z(){return Z=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},Z.apply(null,arguments)}function He(e,t){if(e==null)return{};var n,r,i=Ue(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 Ue(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 We(e){var{option:t,isActive:n}=e,r=He(e,Ve);return typeof t==`string`?J.createElement(P,Z({option:J.createElement(Se,Z({type:t},r)),isActive:n,shapeType:`symbols`},r)):J.createElement(P,Z({option:t,isActive:n,shapeType:`symbols`},r))}var Ge=ae([(e,t,n,r,i,a,o)=>N(e,void 0,void 0,o),(e,t,n,r,i,a,o)=>k(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>j(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>k(e,`yAxis`,n,o),(e,t,n,r,i,a,o)=>j(e,`yAxis`,n,o),(e,t,n,r)=>w(e,`zAxis`,r,!1),ae([ee,(e,t,n,r,i)=>i],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),(e,t,n,r,i,a)=>a],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=e;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(!(d==null||t==null||r==null||n==null||i==null||n?.length===0||i?.length===0))return st({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),Ke=[`id`],qe=[`onMouseEnter`,`onClick`,`onMouseLeave`],Je=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function Ye(e,t){if(e==null)return{};var n,r,i=Xe(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 Xe(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 Q(){return Q=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},Q.apply(null,arguments)}function Ze(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 $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ze(Object(n),!0).forEach(function(t){Qe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qe(e,t,n){return(t=$e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $e(e){var t=et(e,`string`);return typeof t==`symbol`?t:t+``}function et(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 tt=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:L(n,t),payload:e}]},nt=J.memo(e=>{var{dataKey:t,points:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:L(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return J.createElement(Te,{tooltipEntrySettings:u})});function rt(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=U(n),s=z(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var{xmin:u,xmax:d,a:f,b:p}=ie(t),m=e=>f*e+p;c=[{x:u,y:m(u)},{x:d,y:m(d)}]}var h=$($($({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=J.isValidElement(r)?J.cloneElement(r,h):typeof r==`function`?r(h):J.createElement(ne,Q({},h,{type:a})),J.createElement(K,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function it(e){var{showLabels:t,points:n,children:r}=e,i=te(),a=(0,J.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return $($({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return J.createElement(F,{value:t?a:void 0},r)}function at(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=Ye(n,Ke),c=me(le),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=Ye(n,qe),p=V(l,a,o),m=Ee(d),h=De(u,a,o);if(!ge(t))return null;var g=U(s);return J.createElement(J.Fragment,null,J.createElement(rt,{points:t,props:s}),t.map((e,t)=>{var n=i!=null&&i!==!1,a=n&&c===String(t),s=n&&a?i:r,l=$($($({},g),e),{},{index:t,[T]:String(o)});return J.createElement(v,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?D.activeDot:void 0},J.createElement(K,Q({className:`recharts-scatter-symbol`},re(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),J.createElement(We,Q({option:s,isActive:a},l))))}))}function ot(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=Oe(n,`recharts-scatter-`),[u,d]=(0,J.useState)(!1),f=(0,J.useCallback)(()=>{d(!1)},[]),p=(0,J.useCallback)(()=>{d(!0)},[]),m=!u;return J.createElement(it,{showLabels:m,points:r},n.children,J.createElement(y,{animationId:l,begin:a,duration:o,isActive:i,easing:s,onAnimationEnd:f,onAnimationStart:p,key:l},e=>{var i=e===1?r:r?.map((t,n)=>{var r=c&&c[n];return r?$($({},t),{},{cx:t.cx==null?void 0:G(r.cx,t.cx,e),cy:t.cy==null?void 0:G(r.cy,t.cy,e),size:G(r.size,t.size,e)}):$($({},t),{},{size:G(0,t.size,e)})});return e>0&&(t.current=i),J.createElement(K,null,J.createElement(at,{points:i,allOtherScatterProps:n,showLabels:m}))}),J.createElement(S,{label:n.label}))}function st(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=q(n.dataKey)?a.dataKey:n.dataKey,u=q(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:O.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=M(e,l),g=M(e,u),_=!q(d)&&M(e,d)||`-`,v=[{name:q(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:q(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=I({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=I({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,S=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return $($({},e),{},{cx:y,cy:b,x:y==null?void 0:y-S,y:b==null?void 0:b-S,width:2*S,height:2*S,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var ct=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:M(e,t)});function lt(e){var{hide:t,points:n,className:r,needClip:i,xAxisId:a,yAxisId:o,id:s}=e,c=(0,J.useRef)(null);if(t)return null;var l=f(`recharts-scatter`,r),u=s;return J.createElement(v,{zIndex:e.zIndex},J.createElement(K,{className:l,clipPath:i?`url(#clipPath-${u})`:void 0,id:s},i&&J.createElement(`defs`,null,J.createElement(he,{clipPathId:u,xAxisId:a,yAxisId:o})),J.createElement(H,{xAxisId:a,yAxisId:o,data:n,dataPointFormatter:ct,errorBarOffset:0},J.createElement(K,{key:`recharts-scatter-symbols`},J.createElement(ot,{props:e,previousPointsRef:c})))))}var ut={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,zIndex:D.scatter};function dt(e){var t=be(e,ut),{animationBegin:n,animationDuration:r,animationEasing:i,hide:a,isAnimationActive:o,legendType:s,lineJointType:c,lineType:l,shape:u,xAxisId:d,yAxisId:f,zAxisId:p}=t,m=Ye(t,Je),{needClip:h}=xe(d,f),g=(0,J.useMemo)(()=>b(e.children,x),[e.children]),_=ve(),v=me(t=>Ge(t,d,f,p,e.id,g,_));return h==null||v==null?null:J.createElement(J.Fragment,null,J.createElement(nt,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:e.id}),J.createElement(lt,Q({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function ft(e){var t=be(e,ut),n=ve();return J.createElement(se,{id:t.id,type:`scatter`},e=>J.createElement(J.Fragment,null,J.createElement(R,{legendPayload:tt(t)}),J.createElement(ce,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),J.createElement(dt,Q({},t,{id:e}))))}var pt=J.memo(ft,C);pt.displayName=`Scatter`;function mt(e){var t=we(),n=(0,J.useRef)(null);return(0,J.useLayoutEffect)(()=>{n.current===null?t(oe(e)):n.current!==e&&t(fe({prev:n.current,next:e})),n.current=e},[e,t]),(0,J.useLayoutEffect)(()=>()=>{n.current&&=(t(_e(n.current)),null)},[t]),null}var ht={zAxisId:0,range:O.range,scale:O.scale,type:O.type};function gt(e){var t=be(e,ht);return J.createElement(mt,{domain:t.domain,id:t.zAxisId,dataKey:t.dataKey,name:t.name,unit:t.unit,range:t.range,scale:t.scale,type:t.type,allowDuplicatedCategory:O.allowDuplicatedCategory,allowDataOverflow:O.allowDataOverflow,reversed:O.reversed,includeHidden:O.includeHidden})}gt.displayName=`ZAxis`;var _t=[`item`],vt=(0,J.forwardRef)((e,t)=>J.createElement(pe,{chartName:`ScatterChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:_t,tooltipPayloadSearcher:ue,categoricalChartProps:e,ref:t}));function yt({data:e,loading:t}){let{t:n}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let r={jobs:n(`surfaces.job`),explore:n(`surfaces.exploreSpec`),quick:n(`surfaces.quickSpec`),refine:n(`surfaces.aiEdit`),fileSummaries:n(`surfaces.fileSummary`),smash:n(`surfaces.smash`),loop:n(`surfaces.loop`)},i=e.dailyTimeline.map(e=>({date:e.date.slice(5),[r.jobs]:e.jobsCostUsd,[r.explore]:e.exploreCostUsd,[r.quick]:e.quickCostUsd,[r.refine]:e.aiEditCostUsd,[r.fileSummaries]:e.fileSummaryCostUsd??0,[r.smash]:e.smashCostUsd??0,[r.loop]:e.loopCostUsd??0})),o=e.dailyTimeline.every(e=>e.jobsCostUsd+e.exploreCostUsd+e.quickCostUsd+e.aiEditCostUsd+(e.fileSummaryCostUsd??0)+(e.smashCostUsd??0)+(e.loopCostUsd??0)===0);return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:n(`timeline.title`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:n(`timeline.subtitle`)})]}),o?(0,Y.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:n(`timeline.empty`)}):(0,Y.jsx)(`div`,{className:`h-[220px]`,children:(0,Y.jsx)(E,{width:`100%`,height:`100%`,children:(0,Y.jsxs)(Ce,{data:i,margin:{top:10,right:10,left:-8,bottom:0},children:[(0,Y.jsx)(de,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`,vertical:!1}),(0,Y.jsx)(W,{dataKey:`date`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`}),(0,Y.jsx)(ye,{tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e}`}),(0,Y.jsx)(A,{contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>[`$${typeof e==`number`?e.toFixed(2):`—`}`,String(t)]}),(0,Y.jsx)(B,{dataKey:r.jobs,stackId:`a`,fill:`var(--accent-info, #5fa8d3)`}),(0,Y.jsx)(B,{dataKey:r.explore,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,Y.jsx)(B,{dataKey:r.quick,stackId:`a`,fill:`var(--accent-secondary, #f7768e)`}),(0,Y.jsx)(B,{dataKey:r.refine,stackId:`a`,fill:`var(--accent-success, #50fa7b)`}),(0,Y.jsx)(B,{dataKey:r.fileSummaries,stackId:`a`,fill:`var(--accent-warning, #f1fa8c)`}),(0,Y.jsx)(B,{dataKey:r.smash,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,Y.jsx)(B,{dataKey:r.loop,stackId:`a`,fill:`var(--accent-primary, #7aa2f7)`})]})})})]})}function bt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function xt(e){return e==null?`—`:e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function St({values:e}){let t=Math.max(1e-4,...e);return(0,Y.jsx)(`div`,{className:`flex items-end gap-[1px] h-5`,children:e.map((e,n)=>(0,Y.jsx)(`div`,{className:`w-[3px] rounded-sm bg-foreground/40`,style:{height:`${Math.max(2,e/t*20)}px`}},n))})}function Ct({mode:e,label:t,accentClass:n}){let{t:r}=a(`analytics`),o=e.mode===`explore`&&e.totalRuns<5,s=(e.estimatedCostUsd??0)>0;return(0,Y.jsxs)(`div`,{className:`flex-1 p-4 first:pr-2 last:pl-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n}`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:t})]}),o?(0,Y.jsxs)(`div`,{className:`py-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-foreground`,children:r(`quickVsExplore.sparseCta`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:r(`quickVsExplore.runsSoFar`,{count:e.totalRuns})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,"data-estimated":s?`true`:void 0,title:s?r(`quickVsExplore.estimatedTooltip`):void 0,children:[s&&e.avgCostPerSpec!=null?`~`:``,bt(e.avgCostPerSpec)]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:r(`quickVsExplore.perSpec`)}),(0,Y.jsx)(`div`,{className:`mt-3`,children:(0,Y.jsx)(St,{values:e.sparkline.length>0?e.sparkline:[0]})}),(0,Y.jsxs)(`div`,{className:`mt-3 space-y-0.5 text-xs tabular-nums text-muted-foreground`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(i,{ns:`analytics`,i18nKey:`quickVsExplore.createdRuns`,values:{created:e.ticketsCreated,runs:e.totalRuns},components:{strong:(0,Y.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,Y.jsx)(`div`,{children:r(`quickVsExplore.avgDuration`,{duration:xt(e.avgDurationMs)})}),(0,Y.jsx)(`div`,{className:`truncate`,children:e.dominantModel??`—`})]})]})]})}function wt({data:e,loading:t}){let{t:n}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let r=e.byMode.find(e=>e.mode===`quick`),i=e.byMode.find(e=>e.mode===`explore`);if(!r||!i)return null;let o=r.avgCostPerSpec&&i.avgCostPerSpec&&r.avgCostPerSpec>0?i.avgCostPerSpec/r.avgCostPerSpec:null,s=o!==null&&r.totalRuns>=1&&i.totalRuns>=5,c=(r.estimatedCostUsd??0)>0||(i.estimatedCostUsd??0)>0;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40`,children:[(0,Y.jsx)(`div`,{className:`px-4 pt-3 pb-1`,children:(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:n(`quickVsExplore.title`)})}),(0,Y.jsxs)(`div`,{className:`flex divide-x divide-border/40`,children:[(0,Y.jsx)(Ct,{mode:r,label:n(`quickVsExplore.quick`),accentClass:`bg-accent-secondary`}),(0,Y.jsx)(Ct,{mode:i,label:n(`quickVsExplore.explore`),accentClass:`bg-accent-highlight`})]}),s&&(0,Y.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,children:(0,Y.jsx)(`div`,{className:`text-center text-[11px] text-muted-foreground tabular-nums`,children:(0,Y.jsxs)(`span`,{className:`px-2`,children:[`━━━━━━ `,n(`quickVsExplore.ratio`,{ratio:o.toFixed(1)}),` ━━━━━━`]})})}),c&&(0,Y.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,"data-testid":`quick-vs-explore-estimated-footnote`,children:(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:n(`quickVsExplore.estimatedFootnote`)})})]})}function Tt({data:e,loading:t,onSelectModel:n,activeModel:r}){let{t:i}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let o=e.summary.totalCostUsd,s=e.byModel.slice(0,5),c=s.reduce((e,t)=>e+t.costUsd,0),l=Math.max(0,o-c),u=l>=.005;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:i(`models.title`)}),s.length===0?(0,Y.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`models.empty`)}):(0,Y.jsxs)(`ul`,{className:`space-y-1.5`,children:[s.map(e=>{let t=o>0?e.costUsd/o*100:0,a=r===e.model,s=(e.estimatedCostUsd??0)>0;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e.model,e.provider),className:`w-full text-left group rounded-md px-2 py-1.5 transition-colors ${a?`bg-accent-highlight/10 ring-1 ring-accent-highlight/30`:`hover:bg-accent/30`}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.model}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,title:s?i(`models.estimatedTooltip`):void 0,children:[s?`~`:``,`$`,e.costUsd.toFixed(2),` · `,e.count]})]}),(0,Y.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`h-full ${a?`bg-accent-highlight`:`bg-foreground/40 group-hover:bg-foreground/60`} transition-colors`,style:{width:`${t}%`}})})]})},`${e.provider??`claude`}:${e.model}`)}),u&&(0,Y.jsx)(`li`,{"data-testid":`model-others`,children:(0,Y.jsxs)(`div`,{className:`w-full rounded-md px-2 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-muted-foreground`,children:i(`models.others`)}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`$`,l.toFixed(2)]})]}),(0,Y.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`h-full bg-foreground/25`,style:{width:`${o>0?l/o*100:0}%`}})})]})})]})]})}var Et={job:`var(--accent-info, #5fa8d3)`,"quick-spec":`var(--accent-secondary, #f7768e)`,"explore-spec":`var(--accent-highlight, #c084fc)`,"ai-edit":`var(--accent-success, #50fa7b)`,smash:`var(--accent-highlight, #c084fc)`,"file-summary":`var(--accent-warning, #f1fa8c)`,loop:`var(--accent-primary, #7aa2f7)`,"chat-sidebar":`var(--accent-info, #5fa8d3)`,"spec-launcher":`var(--accent-secondary, #f7768e)`,proposal:`var(--accent-highlight, #c084fc)`,"agent-studio":`var(--accent-success, #50fa7b)`,setup:`var(--accent-primary, #7aa2f7)`},Dt=Object.keys(p);function Ot({data:e,loading:t,onSelectPoint:n}){let{t:r}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[260px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=Dt,o=i.map(t=>({surface:t,points:e.scatter.filter(e=>e.surface===t).map(e=>({id:e.id,x:e.numTurns??Math.round((e.durationMs??0)/1e3),y:e.costUsd,surface:t,ticketId:e.ticketId,startedAt:e.startedAt,raw:e}))})),s=e.scatter.length===0,c=e.scatterTruncated===!0,l=e.scatterTotal??e.scatter.length;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`scatter.title`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-[10px]`,children:i.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:Et[e]}}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:p[e]})]},e))})]}),c&&!s&&(0,Y.jsx)(`div`,{"data-testid":`scatter-truncation-notice`,className:`mb-2 text-[10px] text-accent-warning`,children:r(`scatter.truncated`,{shown:e.scatter.length,total:l})}),s?(0,Y.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`scatter.empty`)}):(0,Y.jsx)(`div`,{className:`h-[260px]`,children:(0,Y.jsx)(E,{width:`100%`,height:`100%`,children:(0,Y.jsxs)(vt,{margin:{top:10,right:10,left:-8,bottom:5},children:[(0,Y.jsx)(de,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`}),(0,Y.jsx)(W,{type:`number`,dataKey:`x`,name:`turns`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,label:{value:r(`scatter.turnsLabel`),position:`insideBottomRight`,offset:-2,fontSize:10,fill:`currentColor`}}),(0,Y.jsx)(ye,{type:`number`,dataKey:`y`,name:`cost`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e.toFixed(e<1?2:0)}`}),(0,Y.jsx)(gt,{range:[40,80]}),(0,Y.jsx)(A,{cursor:{strokeDasharray:`3 3`},contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>{let n=String(t);return n===`cost`&&typeof e==`number`?[`$${e.toFixed(3)}`,r(`scatter.costLabel`)]:[String(e),n===`turns`?r(`scatter.turnsLabel`):n]}}),o.map(e=>(0,Y.jsx)(pt,{data:e.points,fill:Et[e.surface],onClick:e=>{let t=e;t?.raw&&n(t.raw)}},e.surface))]})})})]})}function kt({data:e,loading:t,onSelectTicket:n}){let{t:r}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-40 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=e.topTickets;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:r(`topTickets.title`)}),i.length===0?(0,Y.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`topTickets.empty`)}):(0,Y.jsx)(`ul`,{className:`divide-y divide-border/30`,children:i.map((e,t)=>{let i=Object.entries(e.bySurface).filter(([,e])=>e.count>0).map(([e,t])=>r(`topTickets.breakdownItem`,{n:t.count,label:p[e].toLowerCase()})).join(` + `),a=e.isUnattributed,o=a?r(`topTickets.unattributed`):e.ticketTitle?`#${e.ticketId} ${e.ticketTitle}`:r(`topTickets.deletedTicket`,{id:e.ticketId});return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e.ticketId),className:`w-full text-left flex items-center justify-between gap-3 py-2 px-1 hover:bg-accent/30 rounded transition-colors ${!e.ticketTitle&&!a?`opacity-50`:``}`,disabled:a,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`text-sm truncate`,children:o}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground truncate`,children:i||`—`})]}),(0,Y.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,Y.jsxs)(`div`,{className:`text-sm font-medium`,children:[`$`,e.totalCostUsd.toFixed(2)]}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`runs`,{count:e.totalRuns})})]})]})},`${e.ticketId??`u`}-${t}`)})})]})}var At={claude:`Claude`,codex:`Codex`,gemini:`Gemini`};function jt(e){return At[e]??e}function Mt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Nt(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Pt(e){return e.surface_ref_id?.startsWith(`contract-refine:`)?!0:e.surface===`explore-spec`&&e.ticket_id!=null&&e.conversation_id!=null&&e.surface_ref_id===e.conversation_id&&e.model==null}function Ft(e){let t=new Map;for(let n of e)n.model&&(n.conversation_id&&t.set(`conversation:${n.conversation_id}`,n.model),n.ticket_id!=null&&n.surface===`explore-spec`&&t.set(`ticket:${n.ticket_id}:explore-spec`,n.model),n.ticket_id!=null&&n.surface===`quick-spec`&&t.set(`ticket:${n.ticket_id}:quick-spec`,n.model));return t}function It(e,t){if(e.model)return e.model;if(!Pt(e))return null;if(e.conversation_id){let n=t.get(`conversation:${e.conversation_id}`);if(n)return n}return e.ticket_id==null?null:t.get(`ticket:${e.ticket_id}:${e.surface}`)??null}function Lt({rows:e,loading:t,truncated:n,totalAvailable:r,tableFilters:i,onTableFiltersChange:o}){let{t:s}=a(`analytics`),[c,l]=(0,J.useState)(null),u=Ft(e),d=new Set(e.map(e=>e.provider??`claude`)).size>1,f=n||r>e.length;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-3`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:s(`table.title`)}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,Y.jsxs)(`select`,{value:i.status??``,onChange:e=>o({...i,status:e.target.value||void 0}),className:`h-7 px-2 rounded-md bg-background-deep border border-border/60 text-xs`,"aria-label":s(`table.statusFilterAria`),children:[(0,Y.jsx)(`option`,{value:``,children:s(`table.allStatus`)}),(0,Y.jsx)(`option`,{value:`success`,children:s(`table.success`)}),(0,Y.jsx)(`option`,{value:`failed`,children:s(`table.failed`)}),(0,Y.jsx)(`option`,{value:`aborted`,children:s(`table.aborted`)})]}),(0,Y.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,placeholder:s(`table.minCostPlaceholder`),value:i.minCostUsd??``,onChange:e=>{let t=e.target.value===``?void 0:parseFloat(e.target.value);o({...i,minCostUsd:Number.isNaN(t)?void 0:t})},className:`h-7 w-24 px-2 rounded-md bg-background-deep border border-border/60 text-xs tabular-nums`,"aria-label":s(`table.minCostFilterAria`)})]})]}),t?(0,Y.jsx)(`div`,{className:`h-32 rounded bg-card/30 animate-pulse`}):e.length===0?(0,Y.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:s(`table.empty`)}):(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[12px] tabular-nums`,children:[(0,Y.jsx)(`thead`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:(0,Y.jsxs)(`tr`,{className:`text-left`,children:[(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colSurface`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colTicket`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colCost`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTurns`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTokens`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colModel`)}),d&&(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colProvider`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStatus`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStarted`)})]})}),(0,Y.jsx)(`tbody`,{children:e.map(e=>{let t=e.surface,n=m[t],r=(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),i=Pt(e),a=i?s(`table.contractLayer`):p[t],o=It(e,u);return(0,Y.jsxs)(`tr`,{onClick:()=>l(c===e.id?null:e.id),className:`border-t border-border/30 hover:bg-accent/30 cursor-pointer`,children:[(0,Y.jsx)(`td`,{className:`px-2 py-2`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 h-5 rounded-full text-[10px] font-medium ${n.bg} ${n.text}`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n.dot}`}),a]})}),(0,Y.jsx)(`td`,{className:`px-2 py-2 max-w-[260px]`,children:e.ticket_id==null?e.ticket_title?(0,Y.jsx)(`span`,{className:`truncate block text-muted-foreground/90 italic`,title:s(`table.provisionalTitleTooltip`),children:e.ticket_title}):(0,Y.jsx)(`span`,{className:`text-muted-foreground/70`,children:`—`}):(0,Y.jsxs)(`span`,{className:`truncate block`,children:[`#`,e.ticket_id,` `,i?(0,Y.jsx)(`span`,{className:`text-muted-foreground/90`,children:s(`table.contractLayerRefinement`)}):e.ticket_title??(0,Y.jsx)(`span`,{className:`text-muted-foreground/70 italic`,children:s(`table.deleted`)})]})}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-right font-medium`,children:e.total_cost_usd_estimated===1&&e.total_cost_usd!=null?(0,Y.jsxs)(`span`,{title:s(`table.estimatedCostTooltip`),className:`text-muted-foreground/90`,children:[`~`,Mt(e.total_cost_usd)]}):Mt(e.total_cost_usd)}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-right`,children:Nt(e.num_turns)}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-right`,children:r>0?Nt(r):`—`}),(0,Y.jsxs)(`td`,{className:`px-2 py-2 max-w-[180px] truncate`,children:[o??`—`,o&&!e.model?(0,Y.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground/70`,children:s(`table.inferred`)}):null]}),d&&(0,Y.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:jt(e.provider??`claude`)}),(0,Y.jsxs)(`td`,{className:`px-2 py-2`,children:[e.status===`success`?(0,Y.jsx)(`span`,{className:`text-accent-success/90`,children:`●`}):e.status===`failed`?(0,Y.jsx)(`span`,{className:`text-accent-warning`,children:`⚠`}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,Y.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:s(`table.statusValue.${e.status}`)})]}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.started_at.slice(0,16).replace(`T`,` `)})]},e.id)})})]})}),f&&e.length>0&&(0,Y.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-foreground/80`,children:s(`table.truncated`,{shown:e.length,total:r.toLocaleString()})})]})}var Rt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`}],zt=[{value:`all`,labelKey:`page.all`},{value:`job`,labelKey:`surfaces.job`},{value:`explore-spec`,labelKey:`surfaces.exploreSpec`},{value:`quick-spec`,labelKey:`surfaces.quickSpec`},{value:`ai-edit`,labelKey:`surfaces.aiEdit`},{value:`smash`,labelKey:`surfaces.smash`},{value:`file-summary`,labelKey:`surfaces.fileSummary`},{value:`loop`,labelKey:`surfaces.loop`}];function Bt(e){let t=new URLSearchParams;return e.period&&t.set(`period`,e.period),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.surface&&e.surface.length>0&&t.set(`surface`,e.surface.join(`,`)),e.provider&&e.provider.length>0&&t.set(`provider`,e.provider.join(`,`)),e.model&&e.model.length>0&&t.set(`model`,e.model.join(`,`)),e.modelKeys&&e.modelKeys.length>0&&e.model&&e.modelKeys.length===e.model.length&&t.set(`modelProvider`,e.modelKeys.map(e=>e.provider).join(`,`)),e.status&&t.set(`status`,e.status),typeof e.minCostUsd==`number`&&t.set(`minCostUsd`,String(e.minCostUsd)),typeof e.ticketId==`number`&&t.set(`ticketId`,String(e.ticketId)),typeof e.tzOffsetMinutes==`number`&&t.set(`tzOffsetMinutes`,String(e.tzOffsetMinutes)),e.sortBy&&t.set(`sortBy`,e.sortBy),t.toString()}function Vt(){let{t:e}=a(`analytics`),{activeProjectId:t,projects:n}=d(),[i,o]=r(),s=n.find(e=>e.id===t),f=s?u(s):[`claude`],p=f.length>1,m=i.get(`period`)??`30d`,v=(i.get(`surface`)??``).split(`,`).filter(Boolean),y=(i.get(`provider`)??``).split(`,`).filter(Boolean),b=i.get(`ticketId`),x=(i.get(`model`)??``).split(`,`).filter(Boolean),S=(i.get(`modelProvider`)??``).split(`,`).filter(Boolean),ee=x.length>0&&x.length===S.length?x.map((e,t)=>({provider:S[t],model:e})):void 0,te=(0,J.useMemo)(()=>-new Date().getTimezoneOffset(),[]),[C,w]=(0,J.useState)({period:m,surface:v.length>0?v:void 0,provider:y.length>0?y:void 0,ticketId:b?Number(b):void 0,model:x.length>0?x:void 0,modelKeys:ee,tzOffsetMinutes:te}),[T,E]=(0,J.useState)(null),[D,O]=(0,J.useState)(!0),[k,A]=(0,J.useState)(null),[j,M]=(0,J.useState)({}),[N,P]=(0,J.useState)(null),[F,ne]=(0,J.useState)(`recency`),I=(0,J.useRef)(new Map),L=(0,J.useRef)(0);(0,J.useEffect)(()=>{let e=new URLSearchParams;e.set(`period`,C.period),C.surface&&C.surface.length>0&&e.set(`surface`,C.surface.join(`,`)),C.provider&&C.provider.length>0&&e.set(`provider`,C.provider.join(`,`)),C.ticketId&&e.set(`ticketId`,String(C.ticketId)),C.model&&C.model.length>0&&(e.set(`model`,C.model.join(`,`)),C.modelKeys&&C.modelKeys.length===C.model.length&&e.set(`modelProvider`,C.modelKeys.map(e=>e.provider).join(`,`))),o(e,{replace:!0})},[C.period,C.surface,C.provider,C.ticketId,C.model,C.modelKeys,o]);let R=(0,J.useCallback)(async()=>{if(!t)return;let e=++L.current;A(null);let n=`${t}:${Bt(C)}`,r=I.current.get(n);r?(E(r),O(!1)):O(!0);try{let t=await fetch(`${l()}/spending?${Bt(C)}`);if(!t.ok)throw Error(`HTTP ${t.status}`);if(e!==L.current)return;let r=await t.json();I.current.set(n,r),E(r),O(!1)}catch(t){if(e!==L.current)return;A(t.message),O(!1)}},[t,C]),z=(0,J.useRef)(0),B=(0,J.useCallback)(async()=>{if(!t)return;let e=++z.current,n={...C};j.model&&(n.model=[j.model],n.modelKeys=void 0),j.status&&(n.status=j.status),typeof j.minCostUsd==`number`&&(n.minCostUsd=j.minCostUsd),n.sortBy=F;try{let t=await fetch(`${l()}/invocations?${Bt(n)}&limit=100`);if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();if(e!==z.current)return;P(r)}catch{if(e!==z.current)return;P(null)}},[t,C,j,F]),re=(0,J.useRef)(t);(0,J.useEffect)(()=>{re.current!==t&&(re.current=t,E(null),P(null),O(!0))},[t]),(0,J.useEffect)(()=>{R()},[R]),(0,J.useEffect)(()=>{B()},[B]);let V=(0,J.useRef)(null),H=c();(0,J.useEffect)(()=>{let e=`analytics-spending`;return H.registerHandler(e,e=>{let n=e;n.type===`spending.invalidated`&&n.projectId===t&&(V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{I.current.clear(),R(),B()},500))}),()=>{H.unregisterHandler(e),V.current&&clearTimeout(V.current)}},[H,t,R,B]);function ie(e){if(e===`all`){w(e=>({...e,surface:void 0}));return}w(t=>{let n=t.surface??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,surface:r.length>0?r:void 0}})}let ae=(0,J.useCallback)((e,t)=>{w(n=>{if(n.model?.length===1&&n.model[0]===e&&(t===void 0||n.modelKeys?.length===1&&n.modelKeys[0].provider===t))return{...n,model:void 0,modelKeys:void 0};let r=(T?.byModel??[]).filter(n=>n.model===e&&(t===void 0||n.provider===t)).map(e=>({provider:e.provider,model:e.model})),i=r.length>0?r.map(e=>e.model):[e];return{...n,model:i,modelKeys:r.length>0?r:void 0}})},[T]);function oe(){w(e=>({...e,model:void 0,modelKeys:void 0}))}function se(e){if(e===`all`){w(e=>({...e,provider:void 0}));return}w(t=>{let n=t.provider??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,provider:r.length>0?r:void 0}})}let U=C.surface,ce=!U||U.length===0,W=C.provider,le=!W||W.length===0,ue=(0,J.useMemo)(()=>{let e={period:C.period};return C.surface&&C.surface.length>0&&(e.surface=C.surface.join(`,`)),C.provider&&C.provider.length>0&&(e.provider=C.provider.join(`,`)),C.ticketId&&(e.ticketId=String(C.ticketId)),e},[C]),de=T?T.summary.totalRuns===0:!1;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 pb-12`,children:[(0,Y.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-4 px-4 py-3 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 border-b border-border/40`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`h1`,{className:`text-base font-semibold tracking-tight`,children:e(`page.title`)}),C.ticketId&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>w(e=>({...e,ticketId:void 0})),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:e(`page.ticketChip`,{id:C.ticketId})}),C.model&&C.model.length>0&&(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`analytics-model-chip`,onClick:oe,title:e(`page.clearModelFilter`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:[e(`page.modelChip`,{model:C.model[0]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`×`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-card/40 p-0.5`,children:Rt.map(t=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>w(e=>({...e,period:t.value})),className:`px-2.5 h-6 rounded text-[11px] font-medium transition-colors ${C.period===t.value?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e(t.labelKey)},t.value))}),(0,Y.jsx)(_,{baseUrl:`${l()}/analytics/export`,params:ue,disabled:de}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{I.current.clear(),R(),B()},className:`h-7 w-7 inline-flex items-center justify-center rounded-md border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60`,title:e(`common:actions.refresh`),children:(0,Y.jsx)(g,{className:`w-3 h-3`})})]})]}),(0,Y.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:zt.map(t=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ie(t.value),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${(t.value===`all`?ce:U?.includes(t.value)??!1)?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t.labelKey)},t.value))}),p&&(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`analytics-provider-chips`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`page.engine`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>se(`all`),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${le?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(`page.all`)}),f.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>se(e),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${W?.includes(e)??!1?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:h(e)},e))]})]}),k&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/10 p-4 flex items-center justify-between`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-accent-warning`,children:e(`page.failedToLoad`,{error:k})}),(0,Y.jsxs)(`button`,{onClick:()=>R(),className:`flex items-center gap-1.5 h-7 px-3 rounded-md text-xs text-accent-warning border border-accent-warning/30 hover:bg-accent-warning/10`,children:[(0,Y.jsx)(g,{className:`w-3 h-3`}),e(`common:actions.retry`)]})]}),(0,Y.jsx)(Ne,{data:T,loading:D,period:C.period}),(0,Y.jsx)(ze,{data:T,loading:D}),(0,Y.jsx)(yt,{data:T,loading:D}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,Y.jsx)(wt,{data:T,loading:D}),(0,Y.jsx)(Tt,{data:T,loading:D,onSelectModel:ae,activeModel:C.model?.[0]})]}),(0,Y.jsx)(Ot,{data:T,loading:D,onSelectPoint:e=>{M(e=>({...e})),w(t=>({...t,ticketId:e.ticketId??void 0}))}}),(0,Y.jsx)(kt,{data:T,loading:D,onSelectTicket:e=>w(t=>({...t,ticketId:e??void 0}))}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,"data-testid":`analytics-table-sort`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`table.sortLabel`)}),[`recency`,`cost`].map(t=>(0,Y.jsx)(`button`,{type:`button`,"data-testid":`analytics-table-sort-${t}`,"aria-pressed":F===t,onClick:()=>ne(t),className:`h-6 px-2.5 rounded-full text-[11px] font-medium transition-all ${F===t?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t===`recency`?`table.sortRecency`:`table.sortCost`)},t))]}),(0,Y.jsx)(Lt,{rows:N?.rows??[],loading:D&&!N,truncated:(N?.truncated??!1)||(N?.totalAvailable??0)>(N?.rows.length??0),totalAvailable:N?.totalAvailable??0,tableFilters:j,onTableFiltersChange:M})]})]})}export{Vt as default};
|
|
1
|
+
import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{d as r}from"./chunk-KS7C4IRE-Cx5sqopX.js";import{t as i}from"./Trans-CPISVji8.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{t as s}from"./arrow-up-right-9DoMn7fD.js";import{n as c}from"./useSharedWebSocket-DaPh7QBL.js";import{t as l}from"./api-B2M7CtDw.js";import{n as u,r as d}from"./useDesktop-B4pSBIDd.js";import{t as f}from"./clsx-CjueKrWZ.js";import{n as p,t as m}from"./spending-DMnCXy84.js";import{j as h,lt as g}from"./index-CewRMo0W.js";import{t as _}from"./ExportDropdown-BrtfWzEG.js";import{A as v,B as y,C as b,D as x,E as S,F as ee,G as te,H as C,I as w,J as T,K as E,L as D,M as O,N as k,O as A,P as j,Q as M,R as N,S as P,T as F,V as ne,X as I,Z as L,_ as R,_t as z,a as B,at as re,b as V,c as H,ct as ie,et as ae,f as oe,g as se,gt as U,h as ce,i as W,j as le,k as ue,l as de,lt as G,m as fe,n as pe,nt as me,o as he,ot as ge,p as _e,pt as K,q as ve,r as ye,rt as be,s as xe,st as Se,t as Ce,tt as we,ut as q,v as Te,x as Ee,y as De,z as Oe}from"./BarChart-nBOMNfiy.js";var ke=o(`arrow-down-right`,[[`path`,{d:`m7 7 10 10`,key:`1fmybs`}],[`path`,{d:`M17 7v10H7`,key:`6fjiku`}]]),J=e(t(),1),Y=n();function X(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:`$${e.toFixed(2)}`}function Ae(e){return e>=1e3?`$${(e/1e3).toFixed(1)}k`:`$${e.toFixed(2)}`}function je(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}k`:`${e}`}var Me=[`job`,`explore-spec`,`quick-spec`,`ai-edit`,`chat-sidebar`,`spec-launcher`,`proposal`,`agent-studio`,`setup`,`smash`,`file-summary`,`loop`];function Ne({data:e,loading:t,period:n}){let{t:r}=a(`analytics`),[i,o]=(0,J.useState)(0),c=(0,J.useRef)(0),l=(0,J.useRef)(null),u=(0,J.useRef)(0);if((0,J.useEffect)(()=>{if(!e)return;let t=e.summary.totalCostUsd,n=++u.current;if(l.current!==null&&(cancelAnimationFrame(l.current),l.current=null),c.current===0&&t>0){let e=performance.now(),r=i=>{if(n!==u.current)return;let a=Math.min(1,(i-e)/600),s=1-(1-a)**3;o(0+(t-0)*s),a<1?l.current=requestAnimationFrame(r):l.current=null};l.current=requestAnimationFrame(r)}else o(t);return c.current=t,()=>{l.current!==null&&(cancelAnimationFrame(l.current),l.current=null)}},[e]),t&&!e)return(0,Y.jsx)(`div`,{className:`h-44 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let d=e.summary.totalCostUsd,f=e.summary.totalRuns,h=e.summary.totalTokens??0,g=e.summary.totalEstimatedCostUsd??0,_=e.summary.deltaPct,v=e.trackingStartedAt,y=g>0,b=e.bySurface.map(e=>e.surface).filter(e=>!Me.includes(e)),x=[...Me,...b].map(t=>{let n=e.bySurface.find(e=>e.surface===t);return{surface:t,costUsd:n?.costUsd??0,count:n?.count??0}}),S=n?r(`windowLabels.${n}`):null;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-gradient-to-br from-card/80 to-card/40 p-5`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-end justify-between gap-3 mb-4`,children:[(0,Y.jsxs)(`div`,{children:[(0,Y.jsxs)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground mb-1 flex items-center gap-1.5`,children:[(0,Y.jsx)(`span`,{children:r(`hero.spending`)}),S&&(0,Y.jsxs)(`span`,{"data-testid":`hero-window-label`,className:`normal-case tracking-normal text-muted-foreground/70 font-normal`,children:[`· `,S]})]}),(0,Y.jsxs)(`div`,{className:`flex items-baseline gap-3`,children:[(0,Y.jsx)(`div`,{className:`text-5xl font-semibold tabular-nums tracking-tight`,children:Ae(i)}),_!==null&&(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-0.5 text-xs font-medium ${_>=0?`text-accent-warning`:`text-accent-success`}`,children:[_>=0?(0,Y.jsx)(s,{className:`w-3 h-3`}):(0,Y.jsx)(ke,{className:`w-3 h-3`}),r(`hero.vsPrev`,{pct:Math.abs(_).toFixed(0)})]})]}),(0,Y.jsxs)(`div`,{className:`text-xs text-muted-foreground mt-1 tabular-nums flex items-center gap-2`,children:[(0,Y.jsx)(`span`,{children:r(`hero.invocations`,{count:f})}),h>0&&(0,Y.jsx)(`span`,{className:`text-muted-foreground/80`,title:r(`hero.tokensTooltip`),children:r(`hero.tokens`,{tokens:je(h)})}),y&&(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70 italic`,title:r(`hero.includesEstimatedTooltip`,{amount:X(g)}),children:r(`hero.includesEstimated`,{amount:X(g)})})]})]}),f===0&&v&&(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground`,children:r(`hero.trackingStarted`,{date:v.slice(0,10)})})]}),f===0?(0,Y.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 p-6 text-center`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r(`hero.emptyState`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground/70 mt-1`,children:v?r(`hero.trackingStarted`,{date:v.slice(0,10)}):r(`hero.trackingStartedFallback`)})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-3 w-full rounded-full overflow-hidden bg-background-deep flex`,children:x.map(e=>{let t=d>0?e.costUsd/d*100:0;return t===0?null:(0,Y.jsx)(`div`,{className:`h-full ${m[e.surface].dot}`,style:{width:`${t}%`},title:r(`hero.segmentTitle`,{label:p[e.surface],value:X(e.costUsd)})},e.surface)})}),(0,Y.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-5 gap-y-1.5 text-xs`,children:x.filter(e=>e.costUsd>0).map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 tabular-nums`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full ${m[e.surface].dot}`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:p[e.surface]}),(0,Y.jsx)(`span`,{className:`text-foreground font-medium`,children:X(e.costUsd)}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/60`,children:`·`}),(0,Y.jsx)(`span`,{className:`text-muted-foreground/80`,children:e.count})]},e.surface))})]})]})}var Pe={claude:`Claude`,codex:`Codex`,gemini:`Gemini`},Fe={claude:`bg-accent-info`,codex:`bg-accent-highlight`,gemini:`bg-accent-success`};function Ie(e){return e>=100?`$${e.toFixed(0)}`:e>=10?`$${e.toFixed(1)}`:e>=.01?`$${e.toFixed(2)}`:`$${e.toFixed(4)}`}function Le(e){return Pe[e]??e}function Re(e){return Fe[e]??`bg-accent-secondary`}function ze({data:e,loading:t}){let{t:n}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-32 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e||e.byProvider.length===0||e.byProvider.length===1)return null;let r=e.byProvider.reduce((e,t)=>e+t.costUsd+t.estimatedCostUsd,0);return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsx)(`div`,{className:`flex items-baseline justify-between mb-3`,children:(0,Y.jsxs)(`div`,{children:[(0,Y.jsx)(`div`,{className:`text-[11px] uppercase tracking-wider text-muted-foreground`,children:n(`providerCard.title`)}),(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground/70 mt-0.5`,children:(0,Y.jsx)(i,{ns:`analytics`,i18nKey:`providerCard.description`,components:{tilde:(0,Y.jsx)(`span`,{className:`font-medium`})}})})]})}),r===0?(0,Y.jsx)(`div`,{className:`text-xs text-muted-foreground italic`,children:n(`providerCard.noCost`)}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsx)(`div`,{className:`h-2 w-full rounded-full overflow-hidden bg-background-deep flex mb-3`,children:e.byProvider.map(e=>{let t=e.costUsd+e.estimatedCostUsd,i=r>0?t/r*100:0;if(i===0)return null;let a=`${e.costUsd===0&&e.estimatedCostUsd>0?`~`:``}${Ie(t)}`;return(0,Y.jsx)(`div`,{className:`h-full ${Re(e.provider)}`,style:{width:`${i}%`},title:n(`providerCard.segmentTitle`,{label:Le(e.provider),value:a,count:e.count})},e.provider)})}),(0,Y.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 gap-2`,children:e.byProvider.map(e=>(0,Y.jsx)(Be,{entry:e},e.provider))})]})]})}function Be({entry:e}){let{t}=a(`analytics`),n=e.costUsd+e.estimatedCostUsd,r=e.costUsd===0&&e.estimatedCostUsd>0,i=e.count>0&&e.costUsd===0&&e.estimatedCostUsd===0;return(0,Y.jsxs)(`div`,{className:`flex items-center gap-2.5 rounded-md border border-border/30 px-2.5 py-1.5`,children:[(0,Y.jsx)(`span`,{className:`w-2 h-2 rounded-full shrink-0 ${Re(e.provider)}`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium`,children:Le(e.provider)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:t(`runs`,{count:e.count})}),i?(0,Y.jsx)(`span`,{className:`ml-auto text-xs font-medium text-muted-foreground/80 italic`,title:t(`providerCard.costUnavailableTooltip`),children:t(`providerCard.costUnavailable`)}):(0,Y.jsxs)(`span`,{className:`ml-auto text-xs font-medium tabular-nums`,children:[r?`~`:``,Ie(n)]})]})}var Ve=[`option`,`isActive`];function Z(){return Z=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},Z.apply(null,arguments)}function He(e,t){if(e==null)return{};var n,r,i=Ue(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 Ue(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 We(e){var{option:t,isActive:n}=e,r=He(e,Ve);return typeof t==`string`?J.createElement(P,Z({option:J.createElement(Se,Z({type:t},r)),isActive:n,shapeType:`symbols`},r)):J.createElement(P,Z({option:t,isActive:n,shapeType:`symbols`},r))}var Ge=ae([(e,t,n,r,i,a,o)=>N(e,void 0,void 0,o),(e,t,n,r,i,a,o)=>k(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>j(e,`xAxis`,t,o),(e,t,n,r,i,a,o)=>k(e,`yAxis`,n,o),(e,t,n,r,i,a,o)=>j(e,`yAxis`,n,o),(e,t,n,r)=>w(e,`zAxis`,r,!1),ae([ee,(e,t,n,r,i)=>i],(e,t)=>e.filter(e=>e.type===`scatter`).find(e=>e.id===t)),(e,t,n,r,i,a)=>a],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=e;if(o!=null){var d=o?.data!=null&&o.data.length>0?o.data:c?.slice(l,u+1);if(!(d==null||t==null||r==null||n==null||i==null||n?.length===0||i?.length===0))return st({displayedData:d,xAxis:t,yAxis:r,zAxis:a,scatterSettings:o,xAxisTicks:n,yAxisTicks:i,cells:s})}}),Ke=[`id`],qe=[`onMouseEnter`,`onClick`,`onMouseLeave`],Je=[`animationBegin`,`animationDuration`,`animationEasing`,`hide`,`isAnimationActive`,`legendType`,`lineJointType`,`lineType`,`shape`,`xAxisId`,`yAxisId`,`zAxisId`];function Ye(e,t){if(e==null)return{};var n,r,i=Xe(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 Xe(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 Q(){return Q=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},Q.apply(null,arguments)}function Ze(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 $(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Ze(Object(n),!0).forEach(function(t){Qe(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Ze(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Qe(e,t,n){return(t=$e(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function $e(e){var t=et(e,`string`);return typeof t==`symbol`?t:t+``}function et(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 tt=e=>{var{dataKey:t,name:n,fill:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:L(n,t),payload:e}]},nt=J.memo(e=>{var{dataKey:t,points:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,tooltipType:c,id:l}=e,u={dataDefinedOnItem:n?.map(e=>e.tooltipPayload),getPosition:e=>{var t;return n==null||(t=n[Number(e)])==null?void 0:t.tooltipPosition},settings:{stroke:r,strokeWidth:i,fill:a,nameKey:void 0,dataKey:t,name:L(o,t),hide:s,type:c,color:a,unit:``,graphicalItemId:l}};return J.createElement(Te,{tooltipEntrySettings:u})});function rt(e){var{points:t,props:n}=e,{line:r,lineType:i,lineJointType:a}=n;if(!r)return null;var o=U(n),s=z(r),c,l;if(i===`joint`)c=t.map(e=>({x:e.cx??null,y:e.cy??null}));else if(i===`fitting`){var{xmin:u,xmax:d,a:f,b:p}=ie(t),m=e=>f*e+p;c=[{x:u,y:m(u)},{x:d,y:m(d)}]}var h=$($($({},o),{},{fill:`none`,stroke:o&&o.fill},s),{},{points:c});return l=J.isValidElement(r)?J.cloneElement(r,h):typeof r==`function`?r(h):J.createElement(ne,Q({},h,{type:a})),J.createElement(K,{className:`recharts-scatter-line`,key:`recharts-scatter-line`},l)}function it(e){var{showLabels:t,points:n,children:r}=e,i=te(),a=(0,J.useMemo)(()=>n?.map(e=>{var t={x:e.x??0,y:e.y??0,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width};return $($({},t),{},{value:void 0,payload:e.payload,viewBox:t,parentViewBox:i,fill:void 0})}),[i,n]);return J.createElement(F,{value:t?a:void 0},r)}function at(e){var{points:t,allOtherScatterProps:n}=e,{shape:r,activeShape:i,dataKey:a}=n,{id:o}=n,s=Ye(n,Ke),c=me(le),{onMouseEnter:l,onClick:u,onMouseLeave:d}=n,f=Ye(n,qe),p=V(l,a,o),m=Ee(d),h=De(u,a,o);if(!ge(t))return null;var g=U(s);return J.createElement(J.Fragment,null,J.createElement(rt,{points:t,props:s}),t.map((e,t)=>{var n=i!=null&&i!==!1,a=n&&c===String(t),s=n&&a?i:r,l=$($($({},g),e),{},{index:t,[T]:String(o)});return J.createElement(v,{key:`symbol-${e?.cx}-${e?.cy}-${e?.size}-${t}`,zIndex:a?D.activeDot:void 0},J.createElement(K,Q({className:`recharts-scatter-symbol`},re(f,e,t),{onMouseEnter:p(e,t),onMouseLeave:m(e,t),onClick:h(e,t)}),J.createElement(We,Q({option:s,isActive:a},l))))}))}function ot(e){var{previousPointsRef:t,props:n}=e,{points:r,isAnimationActive:i,animationBegin:a,animationDuration:o,animationEasing:s}=n,c=t.current,l=Oe(n,`recharts-scatter-`),[u,d]=(0,J.useState)(!1),f=(0,J.useCallback)(()=>{d(!1)},[]),p=(0,J.useCallback)(()=>{d(!0)},[]),m=!u;return J.createElement(it,{showLabels:m,points:r},n.children,J.createElement(y,{animationId:l,begin:a,duration:o,isActive:i,easing:s,onAnimationEnd:f,onAnimationStart:p,key:l},e=>{var i=e===1?r:r?.map((t,n)=>{var r=c&&c[n];return r?$($({},t),{},{cx:t.cx==null?void 0:G(r.cx,t.cx,e),cy:t.cy==null?void 0:G(r.cy,t.cy,e),size:G(r.size,t.size,e)}):$($({},t),{},{size:G(0,t.size,e)})});return e>0&&(t.current=i),J.createElement(K,null,J.createElement(at,{points:i,allOtherScatterProps:n,showLabels:m}))}),J.createElement(S,{label:n.label}))}function st(e){var{displayedData:t,xAxis:n,yAxis:r,zAxis:i,scatterSettings:a,xAxisTicks:o,yAxisTicks:s,cells:c}=e,l=q(n.dataKey)?a.dataKey:n.dataKey,u=q(r.dataKey)?a.dataKey:r.dataKey,d=i&&i.dataKey,f=i?i.range:O.range,p=f&&f[0],m=n.scale.bandwidth?n.scale.bandwidth():0,h=r.scale.bandwidth?r.scale.bandwidth():0;return t.map((e,t)=>{var f=M(e,l),g=M(e,u),_=!q(d)&&M(e,d)||`-`,v=[{name:q(n.dataKey)?a.name:n.name||String(n.dataKey),unit:n.unit||``,value:f,payload:e,dataKey:l,type:a.tooltipType,graphicalItemId:a.id},{name:q(r.dataKey)?a.name:r.name||String(r.dataKey),unit:r.unit||``,value:g,payload:e,dataKey:u,type:a.tooltipType,graphicalItemId:a.id}];_!==`-`&&i!=null&&v.push({name:i.name||i.dataKey,unit:i.unit||``,value:_,payload:e,dataKey:d,type:a.tooltipType,graphicalItemId:a.id});var y=I({axis:n,ticks:o,bandSize:m,entry:e,index:t,dataKey:l}),b=I({axis:r,ticks:s,bandSize:h,entry:e,index:t,dataKey:u}),x=_!==`-`&&i!=null?i.scale.map(_):p,S=x==null?0:Math.sqrt(Math.max(x,0)/Math.PI);return $($({},e),{},{cx:y,cy:b,x:y==null?void 0:y-S,y:b==null?void 0:b-S,width:2*S,height:2*S,size:x,node:{x:f,y:g,z:_},tooltipPayload:v,tooltipPosition:{x:y,y:b},payload:e},c&&c[t]&&c[t].props)})}var ct=(e,t,n)=>({x:e.cx,y:e.cy,value:Number(n===`x`?e.node.x:e.node.y),errorVal:M(e,t)});function lt(e){var{hide:t,points:n,className:r,needClip:i,xAxisId:a,yAxisId:o,id:s}=e,c=(0,J.useRef)(null);if(t)return null;var l=f(`recharts-scatter`,r),u=s;return J.createElement(v,{zIndex:e.zIndex},J.createElement(K,{className:l,clipPath:i?`url(#clipPath-${u})`:void 0,id:s},i&&J.createElement(`defs`,null,J.createElement(he,{clipPathId:u,xAxisId:a,yAxisId:o})),J.createElement(H,{xAxisId:a,yAxisId:o,data:n,dataPointFormatter:ct,errorBarOffset:0},J.createElement(K,{key:`recharts-scatter-symbols`},J.createElement(ot,{props:e,previousPointsRef:c})))))}var ut={xAxisId:0,yAxisId:0,zAxisId:0,label:!1,line:!1,legendType:`circle`,lineType:`joint`,lineJointType:`linear`,shape:`circle`,hide:!1,isAnimationActive:`auto`,animationBegin:0,animationDuration:400,animationEasing:`linear`,zIndex:D.scatter};function dt(e){var t=be(e,ut),{animationBegin:n,animationDuration:r,animationEasing:i,hide:a,isAnimationActive:o,legendType:s,lineJointType:c,lineType:l,shape:u,xAxisId:d,yAxisId:f,zAxisId:p}=t,m=Ye(t,Je),{needClip:h}=xe(d,f),g=(0,J.useMemo)(()=>b(e.children,x),[e.children]),_=ve(),v=me(t=>Ge(t,d,f,p,e.id,g,_));return h==null||v==null?null:J.createElement(J.Fragment,null,J.createElement(nt,{dataKey:e.dataKey,points:v,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:e.id}),J.createElement(lt,Q({},m,{xAxisId:d,yAxisId:f,zAxisId:p,lineType:l,lineJointType:c,legendType:s,shape:u,hide:a,isAnimationActive:o,animationBegin:n,animationDuration:r,animationEasing:i,points:v,needClip:h})))}function ft(e){var t=be(e,ut),n=ve();return J.createElement(se,{id:t.id,type:`scatter`},e=>J.createElement(J.Fragment,null,J.createElement(R,{legendPayload:tt(t)}),J.createElement(ce,{type:`scatter`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:t.zAxisId,dataKey:t.dataKey,hide:t.hide,name:t.name,tooltipType:t.tooltipType,isPanorama:n}),J.createElement(dt,Q({},t,{id:e}))))}var pt=J.memo(ft,C);pt.displayName=`Scatter`;function mt(e){var t=we(),n=(0,J.useRef)(null);return(0,J.useLayoutEffect)(()=>{n.current===null?t(oe(e)):n.current!==e&&t(fe({prev:n.current,next:e})),n.current=e},[e,t]),(0,J.useLayoutEffect)(()=>()=>{n.current&&=(t(_e(n.current)),null)},[t]),null}var ht={zAxisId:0,range:O.range,scale:O.scale,type:O.type};function gt(e){var t=be(e,ht);return J.createElement(mt,{domain:t.domain,id:t.zAxisId,dataKey:t.dataKey,name:t.name,unit:t.unit,range:t.range,scale:t.scale,type:t.type,allowDuplicatedCategory:O.allowDuplicatedCategory,allowDataOverflow:O.allowDataOverflow,reversed:O.reversed,includeHidden:O.includeHidden})}gt.displayName=`ZAxis`;var _t=[`item`],vt=(0,J.forwardRef)((e,t)=>J.createElement(pe,{chartName:`ScatterChart`,defaultTooltipEventType:`item`,validateTooltipEventTypes:_t,tooltipPayloadSearcher:ue,categoricalChartProps:e,ref:t}));function yt({data:e,loading:t}){let{t:n}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let r={jobs:n(`surfaces.job`),explore:n(`surfaces.exploreSpec`),quick:n(`surfaces.quickSpec`),refine:n(`surfaces.aiEdit`),fileSummaries:n(`surfaces.fileSummary`),smash:n(`surfaces.smash`),loop:n(`surfaces.loop`)},i=e.dailyTimeline.map(e=>({date:e.date.slice(5),[r.jobs]:e.jobsCostUsd,[r.explore]:e.exploreCostUsd,[r.quick]:e.quickCostUsd,[r.refine]:e.aiEditCostUsd,[r.fileSummaries]:e.fileSummaryCostUsd??0,[r.smash]:e.smashCostUsd??0,[r.loop]:e.loopCostUsd??0})),o=e.dailyTimeline.every(e=>e.jobsCostUsd+e.exploreCostUsd+e.quickCostUsd+e.aiEditCostUsd+(e.fileSummaryCostUsd??0)+(e.smashCostUsd??0)+(e.loopCostUsd??0)===0);return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:n(`timeline.title`)}),(0,Y.jsx)(`span`,{className:`text-[10px] text-muted-foreground/70`,children:n(`timeline.subtitle`)})]}),o?(0,Y.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:n(`timeline.empty`)}):(0,Y.jsx)(`div`,{className:`h-[220px]`,children:(0,Y.jsx)(E,{width:`100%`,height:`100%`,children:(0,Y.jsxs)(Ce,{data:i,margin:{top:10,right:10,left:-8,bottom:0},children:[(0,Y.jsx)(de,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`,vertical:!1}),(0,Y.jsx)(W,{dataKey:`date`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`}),(0,Y.jsx)(ye,{tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e}`}),(0,Y.jsx)(A,{contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>[`$${typeof e==`number`?e.toFixed(2):`—`}`,String(t)]}),(0,Y.jsx)(B,{dataKey:r.jobs,stackId:`a`,fill:`var(--accent-info, #5fa8d3)`}),(0,Y.jsx)(B,{dataKey:r.explore,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,Y.jsx)(B,{dataKey:r.quick,stackId:`a`,fill:`var(--accent-secondary, #f7768e)`}),(0,Y.jsx)(B,{dataKey:r.refine,stackId:`a`,fill:`var(--accent-success, #50fa7b)`}),(0,Y.jsx)(B,{dataKey:r.fileSummaries,stackId:`a`,fill:`var(--accent-warning, #f1fa8c)`}),(0,Y.jsx)(B,{dataKey:r.smash,stackId:`a`,fill:`var(--accent-highlight, #c084fc)`}),(0,Y.jsx)(B,{dataKey:r.loop,stackId:`a`,fill:`var(--accent-primary, #7aa2f7)`})]})})})]})}function bt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:e<1?`$${e.toFixed(3)}`:`$${e.toFixed(2)}`}function xt(e){return e==null?`—`:e<1e3?`${e} ms`:e<6e4?`${(e/1e3).toFixed(1)}s`:`${Math.floor(e/6e4)}m ${Math.floor(e%6e4/1e3)}s`}function St({values:e}){let t=Math.max(1e-4,...e);return(0,Y.jsx)(`div`,{className:`flex items-end gap-[1px] h-5`,children:e.map((e,n)=>(0,Y.jsx)(`div`,{className:`w-[3px] rounded-sm bg-foreground/40`,style:{height:`${Math.max(2,e/t*20)}px`}},n))})}function Ct({mode:e,label:t,accentClass:n}){let{t:r}=a(`analytics`),o=e.mode===`explore`&&e.totalRuns<5,s=(e.estimatedCostUsd??0)>0;return(0,Y.jsxs)(`div`,{className:`flex-1 p-4 first:pr-2 last:pl-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-2 mb-2`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n}`}),(0,Y.jsx)(`span`,{className:`text-xs font-medium uppercase tracking-wider text-muted-foreground`,children:t})]}),o?(0,Y.jsxs)(`div`,{className:`py-3`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-foreground`,children:r(`quickVsExplore.sparseCta`)}),(0,Y.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:r(`quickVsExplore.runsSoFar`,{count:e.totalRuns})})]}):(0,Y.jsxs)(Y.Fragment,{children:[(0,Y.jsxs)(`div`,{className:`text-3xl font-semibold tabular-nums tracking-tight`,"data-estimated":s?`true`:void 0,title:s?r(`quickVsExplore.estimatedTooltip`):void 0,children:[s&&e.avgCostPerSpec!=null?`~`:``,bt(e.avgCostPerSpec)]}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5`,children:r(`quickVsExplore.perSpec`)}),(0,Y.jsx)(`div`,{className:`mt-3`,children:(0,Y.jsx)(St,{values:e.sparkline.length>0?e.sparkline:[0]})}),(0,Y.jsxs)(`div`,{className:`mt-3 space-y-0.5 text-xs tabular-nums text-muted-foreground`,children:[(0,Y.jsx)(`div`,{children:(0,Y.jsx)(i,{ns:`analytics`,i18nKey:`quickVsExplore.createdRuns`,values:{created:e.ticketsCreated,runs:e.totalRuns},components:{strong:(0,Y.jsx)(`span`,{className:`text-foreground font-medium`})}})}),(0,Y.jsx)(`div`,{children:r(`quickVsExplore.avgDuration`,{duration:xt(e.avgDurationMs)})}),(0,Y.jsx)(`div`,{className:`truncate`,children:e.dominantModel??`—`})]})]})]})}function wt({data:e,loading:t}){let{t:n}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let r=e.byMode.find(e=>e.mode===`quick`),i=e.byMode.find(e=>e.mode===`explore`);if(!r||!i)return null;let o=r.avgCostPerSpec&&i.avgCostPerSpec&&r.avgCostPerSpec>0?i.avgCostPerSpec/r.avgCostPerSpec:null,s=o!==null&&r.totalRuns>=1&&i.totalRuns>=5,c=(r.estimatedCostUsd??0)>0||(i.estimatedCostUsd??0)>0;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40`,children:[(0,Y.jsx)(`div`,{className:`px-4 pt-3 pb-1`,children:(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:n(`quickVsExplore.title`)})}),(0,Y.jsxs)(`div`,{className:`flex divide-x divide-border/40`,children:[(0,Y.jsx)(Ct,{mode:r,label:n(`quickVsExplore.quick`),accentClass:`bg-accent-secondary`}),(0,Y.jsx)(Ct,{mode:i,label:n(`quickVsExplore.explore`),accentClass:`bg-accent-highlight`})]}),s&&(0,Y.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,children:(0,Y.jsx)(`div`,{className:`text-center text-[11px] text-muted-foreground tabular-nums`,children:(0,Y.jsxs)(`span`,{className:`px-2`,children:[`━━━━━━ `,n(`quickVsExplore.ratio`,{ratio:o.toFixed(1)}),` ━━━━━━`]})})}),c&&(0,Y.jsx)(`div`,{className:`px-4 pb-3 -mt-1`,"data-testid":`quick-vs-explore-estimated-footnote`,children:(0,Y.jsx)(`p`,{className:`text-[10px] text-muted-foreground`,children:n(`quickVsExplore.estimatedFootnote`)})})]})}function Tt({data:e,loading:t,onSelectModel:n,activeModel:r}){let{t:i}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[220px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let o=e.summary.totalCostUsd,s=e.byModel.slice(0,5),c=s.reduce((e,t)=>e+t.costUsd,0),l=Math.max(0,o-c),u=l>=.005;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:i(`models.title`)}),s.length===0?(0,Y.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:i(`models.empty`)}):(0,Y.jsxs)(`ul`,{className:`space-y-1.5`,children:[s.map(e=>{let t=o>0?e.costUsd/o*100:0,a=r===e.model,s=(e.estimatedCostUsd??0)>0;return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e.model,e.provider),className:`w-full text-left group rounded-md px-2 py-1.5 transition-colors ${a?`bg-accent-highlight/10 ring-1 ring-accent-highlight/30`:`hover:bg-accent/30`}`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium`,children:e.model}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,title:s?i(`models.estimatedTooltip`):void 0,children:[s?`~`:``,`$`,e.costUsd.toFixed(2),` · `,e.count]})]}),(0,Y.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`h-full ${a?`bg-accent-highlight`:`bg-foreground/40 group-hover:bg-foreground/60`} transition-colors`,style:{width:`${t}%`}})})]})},`${e.provider??`claude`}:${e.model}`)}),u&&(0,Y.jsx)(`li`,{"data-testid":`model-others`,children:(0,Y.jsxs)(`div`,{className:`w-full rounded-md px-2 py-1.5`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between text-[12px] mb-1 tabular-nums`,children:[(0,Y.jsx)(`span`,{className:`truncate font-medium text-muted-foreground`,children:i(`models.others`)}),(0,Y.jsxs)(`span`,{className:`text-muted-foreground`,children:[`$`,l.toFixed(2)]})]}),(0,Y.jsx)(`div`,{className:`h-1.5 rounded-full bg-background-deep overflow-hidden`,children:(0,Y.jsx)(`div`,{className:`h-full bg-foreground/25`,style:{width:`${o>0?l/o*100:0}%`}})})]})})]})]})}var Et={job:`var(--accent-info, #5fa8d3)`,"quick-spec":`var(--accent-secondary, #f7768e)`,"explore-spec":`var(--accent-highlight, #c084fc)`,"ai-edit":`var(--accent-success, #50fa7b)`,smash:`var(--accent-highlight, #c084fc)`,"file-summary":`var(--accent-warning, #f1fa8c)`,loop:`var(--accent-primary, #7aa2f7)`,"chat-sidebar":`var(--accent-info, #5fa8d3)`,"spec-launcher":`var(--accent-secondary, #f7768e)`,proposal:`var(--accent-highlight, #c084fc)`,"agent-studio":`var(--accent-success, #50fa7b)`,setup:`var(--accent-primary, #7aa2f7)`},Dt=Object.keys(p);function Ot({data:e,loading:t,onSelectPoint:n}){let{t:r}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-[260px] rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=Dt,o=i.map(t=>({surface:t,points:e.scatter.filter(e=>e.surface===t).map(e=>({id:e.id,x:e.numTurns??Math.round((e.durationMs??0)/1e3),y:e.costUsd,surface:t,ticketId:e.ticketId,startedAt:e.startedAt,raw:e}))})),s=e.scatter.length===0,c=e.scatterTruncated===!0,l=e.scatterTotal??e.scatter.length;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:r(`scatter.title`)}),(0,Y.jsx)(`div`,{className:`flex flex-wrap items-center gap-2 text-[10px]`,children:i.map(e=>(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full`,style:{background:Et[e]}}),(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:p[e]})]},e))})]}),c&&!s&&(0,Y.jsx)(`div`,{"data-testid":`scatter-truncation-notice`,className:`mb-2 text-[10px] text-accent-warning`,children:r(`scatter.truncated`,{shown:e.scatter.length,total:l})}),s?(0,Y.jsx)(`div`,{className:`h-40 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`scatter.empty`)}):(0,Y.jsx)(`div`,{className:`h-[260px]`,children:(0,Y.jsx)(E,{width:`100%`,height:`100%`,children:(0,Y.jsxs)(vt,{margin:{top:10,right:10,left:-8,bottom:5},children:[(0,Y.jsx)(de,{strokeDasharray:`2 4`,stroke:`currentColor`,className:`text-border/30`}),(0,Y.jsx)(W,{type:`number`,dataKey:`x`,name:`turns`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,label:{value:r(`scatter.turnsLabel`),position:`insideBottomRight`,offset:-2,fontSize:10,fill:`currentColor`}}),(0,Y.jsx)(ye,{type:`number`,dataKey:`y`,name:`cost`,tick:{fontSize:10},stroke:`currentColor`,className:`text-muted-foreground`,tickFormatter:e=>`$${e.toFixed(e<1?2:0)}`}),(0,Y.jsx)(gt,{range:[40,80]}),(0,Y.jsx)(A,{cursor:{strokeDasharray:`3 3`},contentStyle:{backgroundColor:`var(--popover)`,border:`1px solid var(--border)`,fontSize:11,borderRadius:6},formatter:(e,t)=>{let n=String(t);return n===`cost`&&typeof e==`number`?[`$${e.toFixed(3)}`,r(`scatter.costLabel`)]:[String(e),n===`turns`?r(`scatter.turnsLabel`):n]}}),o.map(e=>(0,Y.jsx)(pt,{data:e.points,fill:Et[e.surface],onClick:e=>{let t=e;t?.raw&&n(t.raw)}},e.surface))]})})})]})}function kt({data:e,loading:t,onSelectTicket:n}){let{t:r}=a(`analytics`);if(t&&!e)return(0,Y.jsx)(`div`,{className:`h-40 rounded-xl border border-border/40 bg-card/40 animate-pulse`});if(!e)return null;let i=e.topTickets;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3`,children:r(`topTickets.title`)}),i.length===0?(0,Y.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:r(`topTickets.empty`)}):(0,Y.jsx)(`ul`,{className:`divide-y divide-border/30`,children:i.map((e,t)=>{let i=Object.entries(e.bySurface).filter(([,e])=>e.count>0).map(([e,t])=>r(`topTickets.breakdownItem`,{n:t.count,label:p[e].toLowerCase()})).join(` + `),a=e.isUnattributed,o=a?r(`topTickets.unattributed`):e.ticketTitle?`#${e.ticketId} ${e.ticketTitle}`:r(`topTickets.deletedTicket`,{id:e.ticketId});return(0,Y.jsx)(`li`,{children:(0,Y.jsxs)(`button`,{type:`button`,onClick:()=>n(e.ticketId),className:`w-full text-left flex items-center justify-between gap-3 py-2 px-1 hover:bg-accent/30 rounded transition-colors ${!e.ticketTitle&&!a?`opacity-50`:``}`,disabled:a,children:[(0,Y.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,Y.jsx)(`div`,{className:`text-sm truncate`,children:o}),(0,Y.jsx)(`div`,{className:`text-[11px] text-muted-foreground truncate`,children:i||`—`})]}),(0,Y.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,Y.jsxs)(`div`,{className:`text-sm font-medium`,children:[`$`,e.totalCostUsd.toFixed(2)]}),(0,Y.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:r(`runs`,{count:e.totalRuns})})]})]})},`${e.ticketId??`u`}-${t}`)})})]})}var At={claude:`Claude`,codex:`Codex`,gemini:`Gemini`};function jt(e){return At[e]??e}function Mt(e){return e==null?`—`:e<.005?`$${e.toFixed(4)}`:`$${e.toFixed(2)}`}function Nt(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Pt(e){return e.surface_ref_id?.startsWith(`contract-refine:`)?!0:e.surface===`explore-spec`&&e.ticket_id!=null&&e.conversation_id!=null&&e.surface_ref_id===e.conversation_id&&e.model==null}function Ft(e){let t=new Map;for(let n of e)n.model&&(n.conversation_id&&t.set(`conversation:${n.conversation_id}`,n.model),n.ticket_id!=null&&n.surface===`explore-spec`&&t.set(`ticket:${n.ticket_id}:explore-spec`,n.model),n.ticket_id!=null&&n.surface===`quick-spec`&&t.set(`ticket:${n.ticket_id}:quick-spec`,n.model));return t}function It(e,t){if(e.model)return e.model;if(!Pt(e))return null;if(e.conversation_id){let n=t.get(`conversation:${e.conversation_id}`);if(n)return n}return e.ticket_id==null?null:t.get(`ticket:${e.ticket_id}:${e.surface}`)??null}function Lt({rows:e,loading:t,truncated:n,totalAvailable:r,tableFilters:i,onTableFiltersChange:o}){let{t:s}=a(`analytics`),[c,l]=(0,J.useState)(null),u=Ft(e),d=new Set(e.map(e=>e.provider??`claude`)).size>1,f=n||r>e.length;return(0,Y.jsxs)(`div`,{className:`rounded-xl border border-border/50 bg-card/40 p-4`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3 mb-3`,children:[(0,Y.jsx)(`h2`,{className:`text-xs font-medium text-muted-foreground uppercase tracking-wider`,children:s(`table.title`)}),(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2 text-[11px]`,children:[(0,Y.jsxs)(`select`,{value:i.status??``,onChange:e=>o({...i,status:e.target.value||void 0}),className:`h-7 px-2 rounded-md bg-background-deep border border-border/60 text-xs`,"aria-label":s(`table.statusFilterAria`),children:[(0,Y.jsx)(`option`,{value:``,children:s(`table.allStatus`)}),(0,Y.jsx)(`option`,{value:`success`,children:s(`table.success`)}),(0,Y.jsx)(`option`,{value:`failed`,children:s(`table.failed`)}),(0,Y.jsx)(`option`,{value:`aborted`,children:s(`table.aborted`)})]}),(0,Y.jsx)(`input`,{type:`number`,step:`0.01`,min:`0`,placeholder:s(`table.minCostPlaceholder`),value:i.minCostUsd??``,onChange:e=>{let t=e.target.value===``?void 0:parseFloat(e.target.value);o({...i,minCostUsd:Number.isNaN(t)?void 0:t})},className:`h-7 w-24 px-2 rounded-md bg-background-deep border border-border/60 text-xs tabular-nums`,"aria-label":s(`table.minCostFilterAria`)})]})]}),t?(0,Y.jsx)(`div`,{className:`h-32 rounded bg-card/30 animate-pulse`}):e.length===0?(0,Y.jsx)(`div`,{className:`h-32 flex items-center justify-center text-xs text-muted-foreground/70`,children:s(`table.empty`)}):(0,Y.jsx)(`div`,{className:`overflow-x-auto`,children:(0,Y.jsxs)(`table`,{className:`w-full text-[12px] tabular-nums`,children:[(0,Y.jsx)(`thead`,{className:`text-[10px] uppercase tracking-wider text-muted-foreground`,children:(0,Y.jsxs)(`tr`,{className:`text-left`,children:[(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colSurface`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colTicket`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colCost`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTurns`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2 text-right`,children:s(`table.colTokens`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colModel`)}),d&&(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colProvider`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStatus`)}),(0,Y.jsx)(`th`,{className:`font-medium px-2 py-2`,children:s(`table.colStarted`)})]})}),(0,Y.jsx)(`tbody`,{children:e.map(e=>{let t=e.surface,n=m[t],r=(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),i=Pt(e),a=i?s(`table.contractLayer`):p[t],o=It(e,u);return(0,Y.jsxs)(`tr`,{onClick:()=>l(c===e.id?null:e.id),className:`border-t border-border/30 hover:bg-accent/30 cursor-pointer`,children:[(0,Y.jsx)(`td`,{className:`px-2 py-2`,children:(0,Y.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 px-2 h-5 rounded-full text-[10px] font-medium ${n.bg} ${n.text}`,children:[(0,Y.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full ${n.dot}`}),a]})}),(0,Y.jsx)(`td`,{className:`px-2 py-2 max-w-[260px]`,children:e.ticket_id==null?e.ticket_title?(0,Y.jsx)(`span`,{className:`truncate block text-muted-foreground/90 italic`,title:s(`table.provisionalTitleTooltip`),children:e.ticket_title}):(0,Y.jsx)(`span`,{className:`text-muted-foreground/70`,children:`—`}):(0,Y.jsxs)(`span`,{className:`truncate block`,children:[`#`,e.ticket_id,` `,i?(0,Y.jsx)(`span`,{className:`text-muted-foreground/90`,children:s(`table.contractLayerRefinement`)}):e.ticket_title??(0,Y.jsx)(`span`,{className:`text-muted-foreground/70 italic`,children:s(`table.deleted`)})]})}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-right font-medium`,children:e.total_cost_usd_estimated===1&&e.total_cost_usd!=null?(0,Y.jsxs)(`span`,{title:s(`table.estimatedCostTooltip`),className:`text-muted-foreground/90`,children:[`~`,Mt(e.total_cost_usd)]}):Mt(e.total_cost_usd)}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-right`,children:Nt(e.num_turns)}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-right`,children:r>0?Nt(r):`—`}),(0,Y.jsxs)(`td`,{className:`px-2 py-2 max-w-[180px] truncate`,children:[o??`—`,o&&!e.model?(0,Y.jsx)(`span`,{className:`ml-1 text-[10px] text-muted-foreground/70`,children:s(`table.inferred`)}):null]}),d&&(0,Y.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:jt(e.provider??`claude`)}),(0,Y.jsxs)(`td`,{className:`px-2 py-2`,children:[e.status===`success`?(0,Y.jsx)(`span`,{className:`text-accent-success/90`,children:`●`}):e.status===`failed`?(0,Y.jsx)(`span`,{className:`text-accent-warning`,children:`⚠`}):(0,Y.jsx)(`span`,{className:`text-muted-foreground`,children:`○`}),(0,Y.jsx)(`span`,{className:`ml-1 text-muted-foreground`,children:s(`table.statusValue.${e.status}`)})]}),(0,Y.jsx)(`td`,{className:`px-2 py-2 text-muted-foreground`,children:e.started_at.slice(0,16).replace(`T`,` `)})]},e.id)})})]})}),f&&e.length>0&&(0,Y.jsx)(`div`,{className:`mt-2 text-[11px] text-muted-foreground/80`,children:s(`table.truncated`,{shown:e.length,total:r.toLocaleString()})})]})}var Rt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`}],zt=[{value:`all`,labelKey:`page.all`},{value:`job`,labelKey:`surfaces.job`},{value:`explore-spec`,labelKey:`surfaces.exploreSpec`},{value:`quick-spec`,labelKey:`surfaces.quickSpec`},{value:`ai-edit`,labelKey:`surfaces.aiEdit`},{value:`smash`,labelKey:`surfaces.smash`},{value:`file-summary`,labelKey:`surfaces.fileSummary`},{value:`loop`,labelKey:`surfaces.loop`}];function Bt(e){let t=new URLSearchParams;return e.period&&t.set(`period`,e.period),e.from&&t.set(`from`,e.from),e.to&&t.set(`to`,e.to),e.surface&&e.surface.length>0&&t.set(`surface`,e.surface.join(`,`)),e.provider&&e.provider.length>0&&t.set(`provider`,e.provider.join(`,`)),e.model&&e.model.length>0&&t.set(`model`,e.model.join(`,`)),e.modelKeys&&e.modelKeys.length>0&&e.model&&e.modelKeys.length===e.model.length&&t.set(`modelProvider`,e.modelKeys.map(e=>e.provider).join(`,`)),e.status&&t.set(`status`,e.status),typeof e.minCostUsd==`number`&&t.set(`minCostUsd`,String(e.minCostUsd)),typeof e.ticketId==`number`&&t.set(`ticketId`,String(e.ticketId)),typeof e.tzOffsetMinutes==`number`&&t.set(`tzOffsetMinutes`,String(e.tzOffsetMinutes)),e.sortBy&&t.set(`sortBy`,e.sortBy),t.toString()}function Vt(){let{t:e}=a(`analytics`),{activeProjectId:t,projects:n}=d(),[i,o]=r(),s=n.find(e=>e.id===t),f=s?u(s):[`claude`],p=f.length>1,m=i.get(`period`)??`30d`,v=(i.get(`surface`)??``).split(`,`).filter(Boolean),y=(i.get(`provider`)??``).split(`,`).filter(Boolean),b=i.get(`ticketId`),x=(i.get(`model`)??``).split(`,`).filter(Boolean),S=(i.get(`modelProvider`)??``).split(`,`).filter(Boolean),ee=x.length>0&&x.length===S.length?x.map((e,t)=>({provider:S[t],model:e})):void 0,te=(0,J.useMemo)(()=>-new Date().getTimezoneOffset(),[]),[C,w]=(0,J.useState)({period:m,surface:v.length>0?v:void 0,provider:y.length>0?y:void 0,ticketId:b?Number(b):void 0,model:x.length>0?x:void 0,modelKeys:ee,tzOffsetMinutes:te}),[T,E]=(0,J.useState)(null),[D,O]=(0,J.useState)(!0),[k,A]=(0,J.useState)(null),[j,M]=(0,J.useState)({}),[N,P]=(0,J.useState)(null),[F,ne]=(0,J.useState)(`recency`),I=(0,J.useRef)(new Map),L=(0,J.useRef)(0);(0,J.useEffect)(()=>{let e=new URLSearchParams;e.set(`period`,C.period),C.surface&&C.surface.length>0&&e.set(`surface`,C.surface.join(`,`)),C.provider&&C.provider.length>0&&e.set(`provider`,C.provider.join(`,`)),C.ticketId&&e.set(`ticketId`,String(C.ticketId)),C.model&&C.model.length>0&&(e.set(`model`,C.model.join(`,`)),C.modelKeys&&C.modelKeys.length===C.model.length&&e.set(`modelProvider`,C.modelKeys.map(e=>e.provider).join(`,`))),o(e,{replace:!0})},[C.period,C.surface,C.provider,C.ticketId,C.model,C.modelKeys,o]);let R=(0,J.useCallback)(async()=>{if(!t)return;let e=++L.current;A(null);let n=`${t}:${Bt(C)}`,r=I.current.get(n);r?(E(r),O(!1)):O(!0);try{let t=await fetch(`${l()}/spending?${Bt(C)}`);if(!t.ok)throw Error(`HTTP ${t.status}`);if(e!==L.current)return;let r=await t.json();I.current.set(n,r),E(r),O(!1)}catch(t){if(e!==L.current)return;A(t.message),O(!1)}},[t,C]),z=(0,J.useRef)(0),B=(0,J.useCallback)(async()=>{if(!t)return;let e=++z.current,n={...C};j.model&&(n.model=[j.model],n.modelKeys=void 0),j.status&&(n.status=j.status),typeof j.minCostUsd==`number`&&(n.minCostUsd=j.minCostUsd),n.sortBy=F;try{let t=await fetch(`${l()}/invocations?${Bt(n)}&limit=100`);if(!t.ok)throw Error(`HTTP ${t.status}`);let r=await t.json();if(e!==z.current)return;P(r)}catch{if(e!==z.current)return;P(null)}},[t,C,j,F]),re=(0,J.useRef)(t);(0,J.useEffect)(()=>{re.current!==t&&(re.current=t,E(null),P(null),O(!0))},[t]),(0,J.useEffect)(()=>{R()},[R]),(0,J.useEffect)(()=>{B()},[B]);let V=(0,J.useRef)(null),H=c();(0,J.useEffect)(()=>{let e=`analytics-spending`;return H.registerHandler(e,e=>{let n=e;n.type===`spending.invalidated`&&n.projectId===t&&(V.current&&clearTimeout(V.current),V.current=setTimeout(()=>{I.current.clear(),R(),B()},500))}),()=>{H.unregisterHandler(e),V.current&&clearTimeout(V.current)}},[H,t,R,B]);function ie(e){if(e===`all`){w(e=>({...e,surface:void 0}));return}w(t=>{let n=t.surface??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,surface:r.length>0?r:void 0}})}let ae=(0,J.useCallback)((e,t)=>{w(n=>{if(n.model?.length===1&&n.model[0]===e&&(t===void 0||n.modelKeys?.length===1&&n.modelKeys[0].provider===t))return{...n,model:void 0,modelKeys:void 0};let r=(T?.byModel??[]).filter(n=>n.model===e&&(t===void 0||n.provider===t)).map(e=>({provider:e.provider,model:e.model})),i=r.length>0?r.map(e=>e.model):[e];return{...n,model:i,modelKeys:r.length>0?r:void 0}})},[T]);function oe(){w(e=>({...e,model:void 0,modelKeys:void 0}))}function se(e){if(e===`all`){w(e=>({...e,provider:void 0}));return}w(t=>{let n=t.provider??[],r=n.includes(e)?n.filter(t=>t!==e):[...n,e];return{...t,provider:r.length>0?r:void 0}})}let U=C.surface,ce=!U||U.length===0,W=C.provider,le=!W||W.length===0,ue=(0,J.useMemo)(()=>{let e={period:C.period};return C.surface&&C.surface.length>0&&(e.surface=C.surface.join(`,`)),C.provider&&C.provider.length>0&&(e.provider=C.provider.join(`,`)),C.ticketId&&(e.ticketId=String(C.ticketId)),e},[C]),de=T?T.summary.totalRuns===0:!1;return(0,Y.jsxs)(`div`,{className:`flex flex-col gap-6 p-4 pb-12`,children:[(0,Y.jsxs)(`div`,{className:`sticky top-0 z-10 -mx-4 px-4 py-3 bg-background/95 backdrop-blur supports-[backdrop-filter]:bg-background/80 border-b border-border/40`,children:[(0,Y.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-3`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,Y.jsx)(`h1`,{className:`text-base font-semibold tracking-tight`,children:e(`page.title`)}),C.ticketId&&(0,Y.jsx)(`button`,{type:`button`,onClick:()=>w(e=>({...e,ticketId:void 0})),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:e(`page.ticketChip`,{id:C.ticketId})}),C.model&&C.model.length>0&&(0,Y.jsxs)(`button`,{type:`button`,"data-testid":`analytics-model-chip`,onClick:oe,title:e(`page.clearModelFilter`),className:`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] font-medium bg-accent-highlight/15 text-accent-highlight ring-1 ring-accent-highlight/30 hover:bg-accent-highlight/25`,children:[e(`page.modelChip`,{model:C.model[0]}),(0,Y.jsx)(`span`,{"aria-hidden":!0,className:`opacity-70`,children:`×`})]})]}),(0,Y.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,Y.jsx)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/60 bg-card/40 p-0.5`,children:Rt.map(t=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>w(e=>({...e,period:t.value})),className:`px-2.5 h-6 rounded text-[11px] font-medium transition-colors ${C.period===t.value?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground`}`,children:e(t.labelKey)},t.value))}),(0,Y.jsx)(_,{baseUrl:`${l()}/analytics/export`,params:ue,disabled:de}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>{I.current.clear(),R(),B()},className:`h-7 w-7 inline-flex items-center justify-center rounded-md border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60`,title:e(`common:actions.refresh`),children:(0,Y.jsx)(g,{className:`w-3 h-3`})})]})]}),(0,Y.jsx)(`div`,{className:`mt-3 flex flex-wrap items-center gap-1.5`,children:zt.map(t=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>ie(t.value),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${(t.value===`all`?ce:U?.includes(t.value)??!1)?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t.labelKey)},t.value))}),p&&(0,Y.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-1.5`,"data-testid":`analytics-provider-chips`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`page.engine`)}),(0,Y.jsx)(`button`,{type:`button`,onClick:()=>se(`all`),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${le?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(`page.all`)}),f.map(e=>(0,Y.jsx)(`button`,{type:`button`,onClick:()=>se(e),className:`h-7 px-3 rounded-full text-[11px] font-medium transition-all ${W?.includes(e)??!1?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:h(e)},e))]})]}),k&&(0,Y.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/10 p-4 flex items-center justify-between`,children:[(0,Y.jsx)(`p`,{className:`text-sm text-accent-warning`,children:e(`page.failedToLoad`,{error:k})}),(0,Y.jsxs)(`button`,{onClick:()=>R(),className:`flex items-center gap-1.5 h-7 px-3 rounded-md text-xs text-accent-warning border border-accent-warning/30 hover:bg-accent-warning/10`,children:[(0,Y.jsx)(g,{className:`w-3 h-3`}),e(`common:actions.retry`)]})]}),(0,Y.jsx)(Ne,{data:T,loading:D,period:C.period}),(0,Y.jsx)(ze,{data:T,loading:D}),(0,Y.jsx)(yt,{data:T,loading:D}),(0,Y.jsxs)(`div`,{className:`grid grid-cols-1 lg:grid-cols-2 gap-4`,children:[(0,Y.jsx)(wt,{data:T,loading:D}),(0,Y.jsx)(Tt,{data:T,loading:D,onSelectModel:ae,activeModel:C.model?.[0]})]}),(0,Y.jsx)(Ot,{data:T,loading:D,onSelectPoint:e=>{M(e=>({...e})),w(t=>({...t,ticketId:e.ticketId??void 0}))}}),(0,Y.jsx)(kt,{data:T,loading:D,onSelectTicket:e=>w(t=>({...t,ticketId:e??void 0}))}),(0,Y.jsxs)(`div`,{className:`flex flex-col gap-2`,children:[(0,Y.jsxs)(`div`,{className:`flex items-center justify-end gap-1.5`,"data-testid":`analytics-table-sort`,children:[(0,Y.jsx)(`span`,{className:`text-[10px] uppercase tracking-wide text-muted-foreground/70 mr-1`,children:e(`table.sortLabel`)}),[`recency`,`cost`].map(t=>(0,Y.jsx)(`button`,{type:`button`,"data-testid":`analytics-table-sort-${t}`,"aria-pressed":F===t,onClick:()=>ne(t),className:`h-6 px-2.5 rounded-full text-[11px] font-medium transition-all ${F===t?`bg-foreground/10 text-foreground ring-1 ring-foreground/20`:`text-muted-foreground hover:text-foreground hover:bg-accent/40`}`,children:e(t===`recency`?`table.sortRecency`:`table.sortCost`)},t))]}),(0,Y.jsx)(Lt,{rows:N?.rows??[],loading:D&&!N,truncated:(N?.truncated??!1)||(N?.totalAvailable??0)>(N?.rows.length??0),totalAvailable:N?.totalAvailable??0,tableFilters:j,onTableFiltersChange:M})]})]})}export{Vt as default};
|