@open-mercato/cezar 0.16.0 → 0.16.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/contract/agent-profiles.d.ts +2 -2
- package/dist/contract/index.js +3 -0
- package/dist/contract/projects.d.ts +4 -0
- package/dist/core/backend-detect.js +10 -0
- package/dist/core/backend-detect.js.map +1 -1
- package/dist/core/codex-app-server-runner.d.ts +3 -0
- package/dist/core/codex-app-server-runner.js +46 -4
- package/dist/core/codex-app-server-runner.js.map +1 -1
- package/dist/core/cursor-bin.d.ts +7 -0
- package/dist/core/cursor-bin.js +11 -0
- package/dist/core/cursor-bin.js.map +1 -1
- package/dist/core/provider-auth.d.ts +25 -7
- package/dist/core/provider-auth.js +141 -17
- package/dist/core/provider-auth.js.map +1 -1
- package/dist/core/usage-limit.js +51 -6
- package/dist/core/usage-limit.js.map +1 -1
- package/dist/runs/agent-error-telemetry.d.ts +3 -2
- package/dist/runs/agent-error-telemetry.js +24 -3
- package/dist/runs/agent-error-telemetry.js.map +1 -1
- package/dist/self-update/checkouts.js +8 -4
- package/dist/self-update/checkouts.js.map +1 -1
- package/dist/server/provider-auth-runtime.js +6 -3
- package/dist/server/provider-auth-runtime.js.map +1 -1
- package/dist/server/server.d.ts +10 -0
- package/dist/server/server.js +12 -3
- package/dist/server/server.js.map +1 -1
- package/dist/server/terminal/detected-urls.js +6 -1
- package/dist/server/terminal/detected-urls.js.map +1 -1
- package/dist/workspace/projects.d.ts +2 -0
- package/dist/workspace/projects.js.map +1 -1
- package/package.json +3 -3
- package/web/dist/assets/{agent-task-pickers-DXaIqpJo.js → agent-task-pickers-B5I-IyLy.js} +1 -1
- package/web/dist/assets/{alert-dialog-BRafiUQO.js → alert-dialog-DvPnvVvK.js} +1 -1
- package/web/dist/assets/arrow-left-BELOeFyX.js +1 -0
- package/web/dist/assets/{automation-format-DeGsIrRc.js → automation-format-BL4n19a2.js} +1 -1
- package/web/dist/assets/{automations-route-CwLG2JNr.js → automations-route-BXxP0xWu.js} +1 -1
- package/web/dist/assets/{button-ZPJ84lSe.js → button-Clwd6u4_.js} +1 -1
- package/web/dist/assets/{centered-state-DPvWqO6I.js → centered-state-nM7v9xtl.js} +1 -1
- package/web/dist/assets/check-Dt8U0Zvm.js +1 -0
- package/web/dist/assets/chevron-left-Df5IsPem.js +1 -0
- package/web/dist/assets/chevron-right-VbYrJ_st.js +1 -0
- package/web/dist/assets/circle-check-DnEaQ9Rj.js +1 -0
- package/web/dist/assets/{collapsible-D5nsq_lY.js → collapsible-Bdyuw-he.js} +1 -1
- package/web/dist/assets/{commit-list-Cj_rtptn.js → commit-list-xMdmPYbz.js} +1 -1
- package/web/dist/assets/{compare-variants-DI8e5hXy.js → compare-variants-BWaSra3R.js} +1 -1
- package/web/dist/assets/{dashboard-Bq8Zgcct.js → dashboard-i4GP_SB1.js} +1 -1
- package/web/dist/assets/{diff-Dzk_1Vj_.js → diff-CJKocK17.js} +2 -2
- package/web/dist/assets/{diff-stat-CG6Qr4ac.js → diff-stat-CiWUpWY0.js} +1 -1
- package/web/dist/assets/{diff-view-CnRMn9fw.js → diff-view-DqWj0yYe.js} +1 -1
- package/web/dist/assets/{download-CAIBRPES.js → download-DOJ8Dqfh.js} +1 -1
- package/web/dist/assets/{file-BuJHbBa7.js → file-1a6_DhLG.js} +1 -1
- package/web/dist/assets/{file-preview-Dy3TYcU4.js → file-preview-iucr8WDo.js} +1 -1
- package/web/dist/assets/{file-text-DYR0Kxgo.js → file-text-DmMQx3hx.js} +1 -1
- package/web/dist/assets/{git-pull-request-draft-tzNd17hB.js → git-pull-request-draft-Cn24ayXz.js} +1 -1
- package/web/dist/assets/git-tab-loading-BfC2ir8N.js +1 -0
- package/web/dist/assets/{git-toolbar-Dc6kAzPv.js → git-toolbar-DU5Ca6RI.js} +1 -1
- package/web/dist/assets/{github-k0H4K2Xv.js → github-uQ7k7SEK.js} +1 -1
- package/web/dist/assets/{host-usage-BmL2kzAM.js → host-usage-DjDYDU0A.js} +1 -1
- package/web/dist/assets/{icon-tooltip-BEOrU9g6.js → icon-tooltip-YXzUubMO.js} +1 -1
- package/web/dist/assets/{index-B7LeGGi2.js → index-Cse8uyXO.js} +4 -4
- package/web/dist/assets/{input-NF_gJ6fV.js → input-DIWTlsx6.js} +1 -1
- package/web/dist/assets/{layout-cards-Cx4pRGy3.js → layout-cards-Sur4EWtx.js} +1 -1
- package/web/dist/assets/loader-circle-D-ter0qP.js +1 -0
- package/web/dist/assets/{markdown-D27e_KDW.js → markdown-BzqT8I8y.js} +1 -1
- package/web/dist/assets/{markdown-DUNEzJJg.js → markdown-Rbaca31B.js} +1 -1
- package/web/dist/assets/{message-square-DHEW7I0Y.js → message-square-EWpWB_Gr.js} +1 -1
- package/web/dist/assets/plus-CBVm02wz.js +1 -0
- package/web/dist/assets/{project-router-CIOAbq2D.js → project-router-DZsR9P9C.js} +1 -1
- package/web/dist/assets/{queries-B--Cyn_0.js → queries-CI0EmEcH.js} +1 -1
- package/web/dist/assets/{reference-chip-C0KB59wJ.js → reference-chip-DnemrSPW.js} +1 -1
- package/web/dist/assets/{repo-git-BlEiXMbR.js → repo-git-CxAx2JBB.js} +1 -1
- package/web/dist/assets/{run-diff-C_AD_Pms.js → run-diff-BPZ85gAE.js} +1 -1
- package/web/dist/assets/{save-Ct323V7q.js → save-B8DEQI2V.js} +1 -1
- package/web/dist/assets/{scroll-within-DVYNEANz.js → scroll-within-Cm6fjjNd.js} +1 -1
- package/web/dist/assets/{search-x-7tkSEIRx.js → search-x-CuinYQnl.js} +1 -1
- package/web/dist/assets/{settings-2-CmkgM6rX.js → settings-2-COky68xN.js} +1 -1
- package/web/dist/assets/{skills-DKqFJCnx.js → skills-B1z9gRg4.js} +1 -1
- package/web/dist/assets/{square-Du4NO0cr.js → square-8OFxLPoA.js} +1 -1
- package/web/dist/assets/{tabs-BhcbXPq1.js → tabs-BUk8rSoE.js} +1 -1
- package/web/dist/assets/{tag-DczwHOyX.js → tag-yruQH0i-.js} +1 -1
- package/web/dist/assets/{task-commits-DtSkB1UU.js → task-commits-W1ZZiEt4.js} +1 -1
- package/web/dist/assets/{task-graph-DalcExDj.js → task-graph-fkOtF8MX.js} +1 -1
- package/web/dist/assets/{task-notes-BHYduZ1z.js → task-notes-lmvd1UM7.js} +1 -1
- package/web/dist/assets/{task-workspace-LhAGqT6q.js → task-workspace-DA3mFwL9.js} +3 -3
- package/web/dist/assets/{terminal-tordSBUt.js → terminal-F3ZJ5fI8.js} +1 -1
- package/web/dist/assets/{terminal-drawer-Cvbqz2QG.js → terminal-drawer-DAkquqSe.js} +2 -2
- package/web/dist/assets/{textarea-Dy9f469S.js → textarea-ewNKsXDa.js} +1 -1
- package/web/dist/assets/{token-metrics-edH1Iifj.js → token-metrics-Dk2ZNHb_.js} +1 -1
- package/web/dist/assets/{tooltip-tycRJnh-.js → tooltip-B628Gs7C.js} +1 -1
- package/web/dist/assets/{tracker-BNqQ5hFE.js → tracker-wxG0l2wk.js} +1 -1
- package/web/dist/assets/{triangle-alert-BDB8QKSV.js → triangle-alert-BqI_9MkV.js} +1 -1
- package/web/dist/assets/{upload-H7_s70Ro.js → upload-J0hBTVF7.js} +1 -1
- package/web/dist/assets/{use-automations-7Eect_3d.js → use-automations-v77gHYDG.js} +1 -1
- package/web/dist/assets/{use-now-DUGH_55J.js → use-now-pBdvhv13.js} +1 -1
- package/web/dist/assets/{use-submit-shortcut-D4G7Y1CV.js → use-submit-shortcut-hAaAH4HY.js} +1 -1
- package/web/dist/assets/{workflow-graph-4GB6HfLn.js → workflow-graph-Bo72pTbt.js} +1 -1
- package/web/dist/assets/worktree-lifecycle-operation-DOTiqQFx.js +18 -0
- package/web/dist/assets/x-DMIsmLBt.js +1 -0
- package/web/dist/index.html +37 -37
- package/web/dist/assets/arrow-left-BfLRAgF_.js +0 -1
- package/web/dist/assets/check-Blje0ysd.js +0 -1
- package/web/dist/assets/chevron-left-CwNUPSrV.js +0 -1
- package/web/dist/assets/chevron-right-dAzuginM.js +0 -1
- package/web/dist/assets/circle-check-B_-oU6Lf.js +0 -1
- package/web/dist/assets/git-tab-loading-BL6wGQi_.js +0 -1
- package/web/dist/assets/loader-circle-i7B5PoZa.js +0 -1
- package/web/dist/assets/plus-CUeDPNAL.js +0 -1
- package/web/dist/assets/worktree-lifecycle-operation-C6S6Hgiq.js +0 -18
- package/web/dist/assets/x-PavsP4k3.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{r as t}from"./button-
|
|
1
|
+
import{t as e}from"./react-runtime-CCIEwYL0.js";import{r as t}from"./button-Clwd6u4_.js";var n=e(),r={primary:`border-primary/25 bg-primary/15 text-primary`,neutral:`border-border bg-card text-foreground shadow-xs`,danger:`border-danger/20 bg-danger/15 text-danger`};function i({icon:e,tone:i=`neutral`,title:a,subtitle:o,children:c,actions:l,backdrop:u=!1,heading:d=`h1`,className:f}){return(0,n.jsxs)(`div`,{"data-slot":`centered-state`,"data-tone":i,className:t(`relative isolate flex min-h-full flex-1 flex-col items-center justify-center px-6 py-12 text-center`,f),children:[u?(0,n.jsx)(s,{}):null,(0,n.jsxs)(`div`,{className:`flex w-full max-w-md flex-col items-center gap-4`,children:[(0,n.jsx)(`div`,{"data-slot":`centered-state-tile`,className:t(`flex size-[72px] items-center justify-center rounded-[18px] border [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-7`,r[i]),children:e}),(0,n.jsx)(d,{className:`text-2xl font-semibold text-balance text-foreground`,children:a}),o?(0,n.jsx)(`p`,{className:`text-sm text-pretty text-muted-foreground`,children:o}):null,c?(0,n.jsx)(`div`,{className:`w-full pt-2`,children:c}):null,l?(0,n.jsx)(`div`,{className:`flex items-center justify-center gap-3 pt-2`,children:l}):null]})]})}var a=[{top:`6%`,left:`14%`,size:2,tone:`violet`,opacity:.5},{top:`11%`,left:`31%`,size:3,tone:`violet`,opacity:.45},{top:`8%`,left:`52%`,size:2,tone:`pending`,opacity:.4},{top:`15%`,left:`71%`,size:2,tone:`violet`,opacity:.5},{top:`9%`,left:`86%`,size:3,tone:`primary`,opacity:.4},{top:`22%`,left:`8%`,size:2,tone:`pending`,opacity:.4},{top:`27%`,left:`24%`,size:2,tone:`primary`,opacity:.35},{top:`20%`,left:`44%`,size:3,tone:`violet`,opacity:.35},{top:`25%`,left:`62%`,size:2,tone:`violet`,opacity:.4},{top:`30%`,left:`79%`,size:2,tone:`primary`,opacity:.35},{top:`36%`,left:`12%`,size:3,tone:`violet`,opacity:.3},{top:`42%`,left:`35%`,size:2,tone:`pending`,opacity:.28},{top:`47%`,left:`58%`,size:2,tone:`primary`,opacity:.28},{top:`52%`,left:`88%`,size:2,tone:`violet`,opacity:.25},{top:`60%`,left:`29%`,size:3,tone:`violet`,opacity:.22}],o={violet:`bg-violet`,primary:`bg-primary`,pending:`bg-pending`};function s({className:e}){return(0,n.jsx)(`div`,{"data-slot":`twinkle-backdrop`,"aria-hidden":`true`,className:t(`pointer-events-none absolute inset-0 -z-10 overflow-hidden [mask-image:linear-gradient(to_bottom,black_25%,transparent_88%)]`,e),children:a.map((e,r)=>(0,n.jsx)(`span`,{className:t(`absolute rounded-[1px] motion-safe:animate-pulse`,e.size===3?`size-[3px]`:`size-0.5`,o[e.tone]),style:{top:e.top,left:e.left,opacity:e.opacity,animationDuration:`3.5s`,animationDelay:`${r%5*700}ms`}},r))})}export{s as n,i as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as e}from"./button-Clwd6u4_.js";var t=e(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as e}from"./button-Clwd6u4_.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as e}from"./button-Clwd6u4_.js";var t=e(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]);export{t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{F as e}from"./button-Clwd6u4_.js";var t=e(`circle-check`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`m9 12 2 2 4-4`,key:`dzmm74`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{C as r,D as i,E as a,N as o,S as s,T as c,r as l,w as u,x as d}from"./button-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{C as r,D as i,E as a,N as o,S as s,T as c,r as l,w as u,x as d}from"./button-Clwd6u4_.js";import{i as f,n as p}from"./token-metrics-Dk2ZNHb_.js";var m=e(t(),1),h=n(),g=`Collapsible`,[_,v]=a(g),[y,b]=_(g),x=m.forwardRef((e,t)=>{let{__scopeCollapsible:n,open:a,defaultOpen:o,disabled:s,onOpenChange:c,...l}=e,[u,f]=r({prop:a,defaultProp:o??!1,onChange:c,caller:g});return(0,h.jsx)(y,{scope:n,disabled:s,contentId:d(),open:u,onOpenToggle:m.useCallback(()=>f(e=>!e),[f]),children:(0,h.jsx)(i.div,{"data-state":D(u),"data-disabled":s?``:void 0,...l,ref:t})})});x.displayName=g;var S=`CollapsibleTrigger`,C=m.forwardRef((e,t)=>{let{__scopeCollapsible:n,...r}=e,a=b(S,n);return(0,h.jsx)(i.button,{type:`button`,"aria-controls":a.open?a.contentId:void 0,"aria-expanded":a.open||!1,"data-state":D(a.open),"data-disabled":a.disabled?``:void 0,disabled:a.disabled,...r,ref:t,onClick:c(e.onClick,a.onOpenToggle)})});C.displayName=S;var w=`CollapsibleContent`,T=m.forwardRef((e,t)=>{let{forceMount:n,...r}=e,i=b(w,e.__scopeCollapsible);return(0,h.jsx)(s,{present:n||i.open,children:({present:e})=>(0,h.jsx)(E,{...r,ref:t,present:e})})});T.displayName=w;var E=m.forwardRef((e,t)=>{let{__scopeCollapsible:n,present:r,children:a,...s}=e,c=b(w,n),[l,d]=m.useState(r),f=m.useRef(null),p=o(t,f),g=m.useRef(0),_=g.current,v=m.useRef(0),y=v.current,x=c.open||l,S=m.useRef(x),C=m.useRef(void 0);return m.useEffect(()=>{let e=requestAnimationFrame(()=>S.current=!1);return()=>cancelAnimationFrame(e)},[]),u(()=>{let e=f.current;if(e){C.current=C.current||{transitionDuration:e.style.transitionDuration,animationName:e.style.animationName},e.style.transitionDuration=`0s`,e.style.animationName=`none`;let t=e.getBoundingClientRect();g.current=t.height,v.current=t.width,S.current||(e.style.transitionDuration=C.current.transitionDuration,e.style.animationName=C.current.animationName),d(r)}},[c.open,r]),(0,h.jsx)(i.div,{"data-state":D(c.open),"data-disabled":c.disabled?``:void 0,id:c.contentId,hidden:!x,...s,ref:p,style:{"--radix-collapsible-content-height":_?`${_}px`:void 0,"--radix-collapsible-content-width":y?`${y}px`:void 0,...e.style},children:x&&a})});function D(e){return e?`open`:`closed`}var O=x;function k({className:e,dot:t,pulse:n=!1,children:r,...i}){return(0,h.jsxs)(`span`,{"data-slot":`pill`,className:l(`inline-flex items-center gap-1.5 rounded-full bg-muted px-2.5 py-[3px] text-xs font-medium whitespace-nowrap text-muted-foreground`,e),...i,children:[t?(0,h.jsx)(f,{tone:t,pulse:n}):null,r]})}function A(e){return e===void 0?`unknown`:new Intl.NumberFormat().format(e)}function j(e,t){return`Input tokens: ${A(e)}; output tokens: ${A(t)}`}function M(e,t,n=`compact`){let r=e===void 0?`—`:p(e),i=t===void 0?`—`:p(t);return n===`table`?`${r} / ${i}`:`IN ${r} · OUT ${i}`}function N({inputTokens:e,outputTokens:t,variant:n=`compact`,omitWhenUnknown:r=!0,className:i}){return r&&e===void 0&&t===void 0?null:(0,h.jsx)(`span`,{"data-slot":`directional-usage`,"aria-label":j(e,t),className:l(`font-mono tabular-nums`,i),children:M(e,t,n)})}function P({...e}){return(0,h.jsx)(O,{"data-slot":`collapsible`,...e})}function F({...e}){return(0,h.jsx)(C,{"data-slot":`collapsible-trigger`,...e})}function I({...e}){return(0,h.jsx)(T,{"data-slot":`collapsible-content`,...e})}export{M as a,N as i,I as n,k as o,F as r,P as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-Clwd6u4_.js";import{t as i}from"./project-router-DZsR9P9C.js";import{o as a}from"./scroll-within-Cm6fjjNd.js";var o=e(t(),1),s=n(),c=41;function l({slot:e,commits:t,className:n,onSelect:i}){let l=t.length>150,d=(0,o.useRef)(null),f=(0,o.useRef)(null),[p,m]=(0,o.useState)(0);(0,o.useLayoutEffect)(()=>{if(!l)return;let e=()=>{let e=d.current,t=f.current;!e||!t||m(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[l]);let h=t.map(e=>(0,s.jsx)(u,{commit:e,onSelect:i},e.sha));return(0,s.jsx)(`div`,{ref:e=>{d.current=e,e&&(f.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":l,className:r(`flex flex-col divide-y divide-border px-2 py-1 md:px-4`,n),children:l?(0,s.jsx)(a,{scrollRef:f,startMargin:p,itemSize:c,children:h}):h})}function u({commit:e,onSelect:t}){return(0,s.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_41px] [content-visibility:auto]`,children:(0,s.jsxs)(i,{"data-slot":`commit-row`,"data-sha":e.sha,to:e.href,onClick:t?n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.button!==0||(n.preventDefault(),t(e.sha))}:void 0,className:`flex min-w-0 items-baseline gap-3 rounded-sm px-2 py-2.5 hover:bg-muted`,children:[(0,s.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-muted-foreground`,children:e.shaLabel}),(0,s.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-[13px] font-medium`,children:e.subject}),e.sync?(0,s.jsx)(`span`,{"data-slot":`commit-sync`,"data-sync":e.sync,title:e.sync===`outgoing`?`Not pushed yet`:`On the remote, not pulled yet`,className:r(`shrink-0 rounded-sm border px-1 font-mono text-[10px]`,e.sync===`outgoing`?`border-primary/40 text-primary`:`border-border text-muted-foreground`),children:e.sync===`outgoing`?`↑ local`:`↓ incoming`}):null,(0,s.jsxs)(`span`,{className:`hidden shrink-0 text-[11px] text-soft-foreground sm:inline`,children:[e.author,` · `,e.when]})]})})}export{l as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,Cn as i,Ln as a,Sa as o,Yn as s,fi as c,j as l,r as u,rn as d,sn as f,wt as p,ya as m}from"./queries-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{A as r,Cn as i,Ln as a,Sa as o,Yn as s,fi as c,j as l,r as u,rn as d,sn as f,wt as p,ya as m}from"./queries-CI0EmEcH.js";import{r as h,t as g}from"./button-Clwd6u4_.js";import{c as _,f as v,t as y,w as b}from"./project-router-DZsR9P9C.js";import{t as x}from"./check-Dt8U0Zvm.js";import{t as S}from"./chevron-right-VbYrJ_st.js";import{t as C}from"./search-x-CuinYQnl.js";import{i as w,n as T,o as E,r as D,t as O}from"./collapsible-Bdyuw-he.js";import{a as k,c as A,i as j,n as M,o as N,r as P,s as F,t as I}from"./alert-dialog-DvPnvVvK.js";import{t as L}from"./token-metrics-Dk2ZNHb_.js";import{t as R}from"./centered-state-nM7v9xtl.js";import{t as z}from"./markdown-Rbaca31B.js";import{N as B,b as V}from"./index-Cse8uyXO.js";import{t as H}from"./run-diff-BPZ85gAE.js";var U=e(t(),1),W=n();function G(){let{groupId:e}=b(),t=r(e),n=L(l().data),i=o();if((0,U.useEffect)(()=>{e&&i.invalidateQueries({queryKey:u.groups.detail(e)})},[i,e,(p().data??[]).filter(t=>t.groupId===e).map(e=>`${e.id}:${e.status}:${e.archived}`).sort().join(`,`)]),t.isPending)return(0,W.jsx)(V,{});if(t.isError){let e=t.error instanceof s&&t.error.status===404;return(0,W.jsx)(`div`,{"data-route":`compare`,className:`flex min-h-full flex-col`,children:(0,W.jsx)(R,{icon:e?(0,W.jsx)(C,{}):(0,W.jsx)(B,{}),tone:e?`neutral`:`danger`,title:e?`No such variant group`:`Could not load the variants`,subtitle:e?`No runs share this group id. The group may have been deleted, or a winner was already picked and the others removed.`:t.error.message,actions:(0,W.jsx)(g,{asChild:!0,variant:`outline`,children:(0,W.jsx)(y,{to:`/`,children:`Back to tasks`})})})})}return(0,W.jsx)(K,{groupId:e,variants:t.data.runs,showTokens:n.tokens,showCost:n.cost})}function K({groupId:e,variants:t,showTokens:n,showCost:r}){let a=_(),s=o(),[l,f]=(0,U.useState)(null),p=t.every(e=>d.has(e.status)),g=t[0]?i(t[0]):``,y=m({mutationFn:t=>c(e,t),onSuccess:(t,n)=>{s.invalidateQueries({queryKey:u.runs.all}),s.invalidateQueries({queryKey:u.groups.detail(e)}),a(`/tasks/${t.winner?.id??n}`)},onError:e=>v(e.message,{tone:`danger`})});return(0,W.jsxs)(`div`,{"data-route":`compare`,className:`mx-auto flex w-full max-w-6xl flex-col gap-4 px-4 py-5 md:px-6`,children:[(0,W.jsxs)(`header`,{className:`flex flex-col gap-1`,children:[(0,W.jsxs)(`h1`,{className:`flex items-center gap-2 text-xl font-semibold`,children:[(0,W.jsx)(B,{className:`size-5 shrink-0 text-violet`,"aria-hidden":`true`}),(0,W.jsx)(`span`,{className:`min-w-0 truncate`,title:g,children:g})]}),(0,W.jsxs)(`p`,{className:`text-[13px] text-muted-foreground`,children:[t.length,` variants of the same task, each in its own worktree — pick the diff you want to keep. The others are cancelled and archived, their worktrees and branches removed.`]})]}),(0,W.jsx)(`div`,{"data-slot":`compare-columns`,className:h(`grid grid-cols-1 gap-3`,t.length>=3?`md:grid-cols-3`:`md:grid-cols-2`),children:t.map(e=>(0,W.jsx)(q,{variant:e,allTerminal:p,pickPending:y.isPending,onPick:()=>f(e),showTokens:n,showCost:r},e.id))}),(0,W.jsx)(`section`,{"aria-label":`Full diffs`,className:`flex flex-col gap-2`,children:t.map(e=>(0,W.jsx)(J,{variant:e},e.id))}),(0,W.jsx)(I,{open:l!==null,onOpenChange:e=>!e&&f(null),children:(0,W.jsxs)(j,{children:[(0,W.jsxs)(F,{children:[(0,W.jsxs)(A,{children:[`Pick variant `,l?.variant,`?`]}),(0,W.jsxs)(k,{children:[`Variant `,l?.variant,`'s changes go to the review gate. The other`,` `,t.length-1==1?`variant is`:`${t.length-1} variants are`,` `,`cancelled if still open, archived, and their worktrees and branches removed. There is no undo.`]})]}),(0,W.jsxs)(N,{children:[(0,W.jsx)(P,{children:`Keep comparing`}),(0,W.jsxs)(M,{"data-slot":`confirm-pick`,onClick:()=>{l&&y.mutate(l.id),f(null)},children:[(0,W.jsx)(x,{"aria-hidden":`true`}),`Pick variant `,l?.variant]})]})]})})]})}function q({variant:e,allTerminal:t,pickPending:n,onPick:r,showTokens:i,showCost:o}){let s=a(e),c=f(e.costUsd),l=e.inputTokens!==void 0||e.outputTokens!==void 0;return(0,W.jsxs)(`article`,{"data-slot":`variant-column`,"data-variant":e.variant,className:`flex min-w-0 flex-col gap-3 rounded-lg border border-border bg-card p-3.5 shadow-xs`,children:[(0,W.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,W.jsx)(`span`,{"data-slot":`variant-letter`,"aria-label":`Variant ${e.variant}`,className:`inline-flex size-6 shrink-0 items-center justify-center rounded-full bg-violet/15 font-mono text-xs font-semibold text-violet`,children:e.variant}),(0,W.jsx)(E,{dot:s.tone,pulse:s.pulse,children:s.label}),i&&l||o&&c?(0,W.jsxs)(`span`,{"data-slot":`variant-token-metrics`,className:`ml-auto flex shrink-0 items-center gap-1.5 text-[11px] text-soft-foreground`,children:[i?(0,W.jsx)(w,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):null,i&&l&&o&&c?(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,o&&c?(0,W.jsx)(`span`,{className:`font-mono tabular-nums`,children:c}):null]}):null]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`git diff --stat`}),(0,W.jsx)(`pre`,{"data-slot":`variant-diffstat`,className:`max-h-36 overflow-auto rounded-md bg-muted/60 px-2.5 py-2 font-mono text-[11px] leading-[1.6] whitespace-pre text-muted-foreground`,children:e.diffStat.trimEnd()||`(no changes)`})]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-1 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`text-[10.5px] font-semibold tracking-[0.04em] text-soft-foreground uppercase`,children:`Progress`}),e.handoffExcerpt?(0,W.jsx)(`div`,{"data-slot":`variant-progress`,className:`max-h-28 min-w-0 overflow-hidden text-[12.5px] text-muted-foreground [mask-image:linear-gradient(to_bottom,black_75%,transparent)]`,children:(0,W.jsx)(z,{children:e.handoffExcerpt})}):(0,W.jsx)(`p`,{"data-slot":`variant-progress`,className:`text-xs text-soft-foreground`,children:`(no progress notes)`})]}),(0,W.jsxs)(g,{"data-slot":`variant-pick`,title:t?`Keep variant ${e.variant}'s changes and archive the others`:`Every variant must finish before you can pick`,disabled:!t||n,onClick:r,children:[(0,W.jsx)(x,{"aria-hidden":`true`}),`Pick this one`]})]})}function J({variant:e}){let[t,n]=(0,U.useState)(!1);return(0,W.jsxs)(O,{open:t,onOpenChange:n,"data-slot":`variant-diff`,"data-variant":e.variant,className:`min-w-0 overflow-hidden rounded-lg border border-border bg-card`,children:[(0,W.jsxs)(D,{className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left text-[13px] font-medium hover:bg-muted/50`,children:[(0,W.jsx)(S,{className:h(`size-3.5 shrink-0 text-soft-foreground transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),`Variant `,e.variant,` — full diff`]}),(0,W.jsx)(T,{children:(0,W.jsx)(`div`,{className:`border-t border-border/50 px-3 py-3`,children:(0,W.jsx)(H,{runId:e.id})})})]})}export{G as CompareVariantsRoute};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$r as r,Ci as i,G as a,Ln as o,Qt as s,Sa as c,Xt as l,Yn as u,ba as d,ea as f,gn as p,ir as m,j as h,zn as g}from"./queries-B--Cyn_0.js";import{$ as _,F as v,Q as y,Z as b,et as x,it as S,nt as C,t as w,tt as T,vt as E}from"./button-ZPJ84lSe.js";import{T as ee,m as D,x as te}from"./project-router-CIOAbq2D.js";import{S as ne,a as re,o as ie,r as ae,t as oe}from"./reference-chip-C0KB59wJ.js";import{A as O,C as se,E as k,M as A,N as j,O as ce,P as le,T as ue,_ as de,b as fe,c as pe,d as me,f as he,g as ge,h as _e,i as ve,j as ye,m as be,p as xe,v as Se,w as Ce,x as we,y as Te}from"./use-automations-7Eect_3d.js";import{a as Ee,i as De,n as Oe,o as ke,s as Ae,t as je}from"./use-now-DUGH_55J.js";import{a as Me,f as M,p as Ne,r as Pe}from"./automation-format-DeGsIrRc.js";import{f as Fe,i as Ie,n as Le,r as Re,t as ze}from"./tooltip-tycRJnh-.js";import{t as Be}from"./chevron-right-dAzuginM.js";import{t as Ve}from"./download-CAIBRPES.js";import{i as N,r as P,t as He}from"./token-metrics-edH1Iifj.js";import{t as Ue}from"./index-B7LeGGi2.js";var We=v(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Ge=v(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),Ke=v(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),qe=v(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Je=v(`grip-horizontal`,[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]),Ye=v(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),F=e(t(),1);function Xe(e){let t=Date.parse(e.nextRunAt??``),n=Date.parse(e.state?.backoffUntil??``);return Number.isFinite(t)?Math.max(t,Number.isFinite(n)?n:t):null}function Ze(e){return e.flatMap(e=>(e.data?.automations??[]).filter(e=>e.enabled).map(t=>({project:e,automation:t,at:Xe(t)}))).sort((e,t)=>(e.at??1/0)-(t.at??1/0)||e.project.id.localeCompare(t.project.id)||e.automation.id.localeCompare(t.automation.id))}function Qe(e){let t=a(),n=c(),r=t.data?.projects??[],i=t.data?.bootProject,o=i&&!r.some(e=>e.id===i)?[...r,{id:i,name:i,status:`ok`}]:r,l=d({queryKey:[...s.dashboard,`automations`,o.map(e=>[e.id,e.name,e.status])],enabled:e&&!!t.data,queryFn:async({signal:e})=>{let t=0,n=[];return await Promise.all([0,1].map(async()=>{for(;t<o.length&&!e.aborted;){let r=o[t++];if(r.status===`missing`){n.push({...r,error:`Project folder unavailable`});continue}try{let t=S.parse(await f(await m.api.v1.workspace.dashboard.automations.$get({query:{projectId:r.id}},{init:{signal:e}}),`/workspace/dashboard/automations`));n.push({id:r.id,name:r.name,data:t})}catch{n.push({id:r.id,name:r.name,error:`Could not load automations`})}}})),n}});return(0,F.useEffect)(()=>{if(e)return ce(e=>{e===`automation-change`&&n.invalidateQueries({queryKey:[...s.dashboard,`automations`]})})},[n,e]),{...l,registry:t,retry:()=>{t.refetch(),l.refetch()}}}var I=n();function L({rows:e}){return(0,I.jsx)(`span`,{hidden:!0,"data-dashboard-export":JSON.stringify(e)})}var R=`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,z=`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,$e=`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden`;function B(){return(0,I.jsx)(Be,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground transition-transform duration-150 motion-reduce:transition-none [details[open]>summary>&]:rotate-90`})}var et=`flex items-center gap-2 text-xs text-muted-foreground`;function tt({className:e=``,...t}){return(0,I.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,I.jsx)(`select`,{...t,className:`h-9 cursor-pointer appearance-none rounded-md border bg-card-2 pr-8 pl-3 font-mono text-xs text-foreground outline-none transition-colors hover:border-foreground/20 hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 no-hover:min-h-11 ${e}`}),(0,I.jsx)(Fe,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 right-2.5 size-3.5 -translate-y-1/2 text-soft-foreground`})]})}var nt=`relative min-w-0 overflow-hidden rounded-lg border bg-card-2 p-4 transition-colors before:absolute before:inset-x-0 before:top-0 before:h-px before:opacity-80 hover:border-foreground/20 hover:bg-muted/40 sm:p-5`,V={violet:`before:bg-violet`,info:`before:bg-info`,success:`before:bg-success`,danger:`before:bg-danger`,primary:`before:bg-primary`,neutral:`before:bg-border`};function rt({label:e,value:t,icon:n,children:r}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[11px] font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,I.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:n})]}),(0,I.jsx)(`span`,{className:`mt-4 block text-4xl font-semibold leading-none tracking-tight tabular-nums`,children:t}),(0,I.jsx)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:r})]})}function it({at:e}){return(0,I.jsxs)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:[`Updated `,P(e),` ago`]})}function at(){let e=ve(),t=Qe(e.known&&!e.off),n=je(3e4),[r,i]=(0,F.useState)(!1),a=Ze(t.data??[]),o=r?a:a.slice(0,3),s=t.data?.filter(e=>e.error)??[],c=!e.known||!t.registry.isError&&(t.registry.isPending||t.isPending),l=t.isError||t.registry.isError||s.length>0;return(0,I.jsxs)(M,{"data-export-context":`Enabled automations · showing ${o.length} of ${a.length} loaded · ${l?`partial coverage`:`available projects`}`,className:`min-w-0 gap-0 py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsxs)(`h2`,{className:`flex items-center ${R}`,children:[`Automations`,(0,I.jsx)(Ne,{className:`ml-2 size-3.5 text-soft-foreground`,"aria-hidden":`true`})]}),!e.off&&t.data&&(0,I.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[a.length,` enabled`,l?` · partial`:``]})]}),!e.off&&t.data&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{rows:[{section:`automations`,metric:`enabled`,value:a.length,unit:`automations`,note:l?`Partial project coverage`:`Loaded projects`}]}),t.dataUpdatedAt>0&&(0,I.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:new Date(t.dataUpdatedAt).toISOString()})})]}),e.off?(0,I.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,I.jsxs)(I.Fragment,{children:[c&&(0,I.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading automations…`}),l&&(0,I.jsxs)(`div`,{role:`alert`,className:`p-4 text-sm`,children:[(0,I.jsx)(`p`,{children:`Some automation data could not be refreshed. Available results are shown.`}),s.map(e=>(0,I.jsxs)(`p`,{children:[e.name,`: `,e.error]},e.id)),(0,I.jsx)(w,{variant:`ghost`,onClick:t.retry,children:`Retry automations`})]}),!c&&!l&&a.length===0&&(0,I.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No enabled automations. Enable one in a project's Automations page.`}),o.map(({project:e,automation:t,at:r})=>{let i=(t.state?.consecutiveFailures??0)>0?`Recent checks failed`:void 0,a=r===null?`Next time not available`:r<=n?`Due — awaiting scheduler`:Me(r,n),o=t.kind===`schedule`?`Next run`:`Next check`;return(0,I.jsxs)(`div`,{"data-export-row":!0,className:`border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,I.jsx)(D,{className:`block min-h-11 text-sm font-medium hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations/${encodeURIComponent(t.id)}`,children:t.name}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.name,` · `,o,`: `,a]}),r!==null&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:(0,I.jsxs)(`time`,{dateTime:new Date(r).toISOString(),children:[Pe(r,e.data.timeZone),` · `,e.data.timeZone]})}),t.kind!==`schedule`&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Checks for matching events; a task may not be started.`}),i&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:i}),(0,I.jsx)(L,{rows:[{section:`automation`,entity:`${e.id}:${t.id}`,metric:`name`,value:t.name},{section:`automation`,entity:`${e.id}:${t.id}`,metric:t.kind===`schedule`?`nextRunAt`:`nextCheckAt`,value:r===null?null:new Date(r).toISOString(),note:[a,i].filter(Boolean).join(` · `)}]})]},`${e.id}:${t.id}`)}),a.length>3&&(0,I.jsx)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>i(!r),children:r?`Show fewer`:`Show all ${a.length} enabled`}),!c&&(0,I.jsxs)(`details`,{className:`border-t px-4 py-2 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden min-h-11`,"data-export-heading":`Project automations`,children:[(0,I.jsx)(B,{}),`Manage automations by project`]}),t.data?.map(e=>(0,I.jsx)(D,{className:`block min-h-11 py-3 hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations`,children:e.name},e.id))]})]})]})}function ot(e,t,n){let r=new Set,i=new Map(e.map((e,t)=>[n(e),{r:e,i:t}]));return t.forEach((e,t)=>{let a=i.get(n(e));(!a||a.i!==t||JSON.stringify(a.r)!==JSON.stringify(e))&&r.add(n(e)),i.delete(n(e))}),i.forEach((e,t)=>r.add(t)),r}function st(e,t,n){let r=new Map(t.map(e=>[n(e),e]));return e.map(e=>({row:r.get(n(e))??e,removed:!r.has(n(e))}))}var ct=(0,F.createContext)(``),lt=(0,F.createContext)(!0),H=new Map;function ut(e,t,n=``,r=0,i){let a=(0,F.useContext)(ct),o=`${a}:${n}`,[s,c]=(0,F.useState)(()=>H.get(o)),[l,u]=(0,F.useState)(o),d=(0,F.useRef)(r),f=(0,F.useRef)(!1);l!==o&&(u(o),c(H.get(o)),d.current=r,f.current=!1),d.current!==r&&(d.current=r,f.current=!0),(0,F.useEffect)(()=>{e&&(!s||f.current)&&(c(e),f.current=!1)},[s,e]);let p=(0,F.useMemo)(()=>({current:s}),[o]);p.current=s,(0,F.useEffect)(()=>()=>{!a||!p.current||(H.delete(o),H.set(o,p.current),H.size>60&&H.delete(H.keys().next().value))},[a,o,p]);let m=s??e??[],h=new Set((e??m).map(t)),g=i?m.filter(e=>h.has(t(e))||i(e)):m;return{rows:st(g,e??m,t),updates:e?ot(g,e,t).size:0,show:()=>c(e)}}var dt=new Map;function ft(e){return dt.get(e)}function pt(e,t){dt.delete(e),dt.set(e,t),dt.size>20&&dt.delete(dt.keys().next().value)}var U=new Map;function mt(e,t){return U.get(e)?.[t]}function ht(e,t,n){let r=U.get(e)??{};r[t]=n,U.delete(e),U.set(e,r),U.size>20&&U.delete(U.keys().next().value)}var W=e=>`${e.projectId}:${e.id}`;function gt({row:e,removed:t=!1,queue:n=!1,checking:r=!1,checkFailed:i=!1,kicker:a}){let s=(0,F.useContext)(lt)&&!r&&!i,c=le(e);t=t||c===null||n&&c?.archived===!0,c&&(e={...e,status:c.status,awaitingAnswerSince:c.awaitingAnswerSince});let l=o(e),u=n&&!g(e),d=t||u||!s;return(0,I.jsxs)(`div`,{"data-dashboard-row":W(e),className:`min-w-0 border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,I.jsx)(L,{rows:[{section:`task`,entity:W(e),metric:`title`,value:e.titleSummary||e.title},{section:`task`,entity:W(e),metric:`status`,value:d?`Not currently actionable`:e.status},{section:`task`,entity:W(e),metric:`createdAt`,value:e.createdAt}]}),a&&(0,I.jsx)(`p`,{className:`mb-1 pl-[15px] font-mono text-[10.5px] uppercase tracking-[0.1em] text-soft-foreground`,children:a}),(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(N,{tone:l.tone,className:`mt-[7px]`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(D,{tabIndex:d?-1:void 0,"aria-disabled":d||void 0,onClick:e=>{d&&e.preventDefault()},to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,className:`block break-words text-sm font-medium leading-relaxed hover:underline no-hover:min-h-11`,children:e.titleSummary||e.title}),(0,I.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:e.projectId}),(0,I.jsx)(`span`,{children:i?`Could not check current state`:s?t?n&&c!==null?`No longer needs you`:`Task removed`:u?`No longer needs you`:l.label:`Checking current state…`}),(0,I.jsx)(`span`,{children:P(e.createdAt)}),e.dispatch&&(0,I.jsx)(`span`,{children:`Subtask`}),!d&&p(e).map(t=>(0,I.jsx)(oe,{reference:t,taskTitle:e.title,projectId:e.projectId,className:`no-hover:min-h-11`},`${t.kind}:${t.number}`))]})]})]})]})}function G({coverage:e,count:t,retry:n}){let r=e.projects.filter(e=>e.state!==`complete`);return r.length?(0,I.jsxs)(`div`,{className:`rounded-lg border border-pending/40 bg-card-2 p-3 text-sm`,role:`status`,children:[(0,I.jsxs)(`p`,{children:[t===void 0?``:`${t} tasks need you in the available data. Complete coverage: ${e.projects.length-r.length} of ${e.projects.length} projects. `,r.length===1?r[0].state===`unavailable`?`One project is unavailable.`:`One project has incomplete coverage.`:`${r.length} projects have incomplete coverage.`]}),(0,I.jsxs)(`details`,{className:`mt-2`,children:[(0,I.jsxs)(`summary`,{className:`${$e} min-h-11`,children:[(0,I.jsx)(B,{}),`View unavailable `,r.length===1?`project`:`projects`]}),r.map(e=>(0,I.jsxs)(`p`,{children:[e.projectId,`: `,e.reason??e.state,e.omittedRuns>0?` · ${e.omittedRuns} omitted tasks`:``]},e.projectId))]}),(0,I.jsx)(w,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Retry`})]}):null}function _t(e,t=!1){return e==null?`Unavailable`:t?`$${e.toFixed(e===0||e>=1?2:Math.min(20,Math.max(4,Math.ceil(-Math.log10(e))+1)))}`:e.toLocaleString(`en-US`)}function K(e){return e===null?`Unavailable`:e<1?`${Math.round(e*60)}m`:e<48?`${e.toFixed(1)}h`:`${(e/24).toFixed(1)}d`}function vt(e,t,n){let r=te(),i=r.state?.dashboardEntry??r.key,[a,o]=ee(),s=a.get(e);return[s!==null&&t.includes(s)?s:n,t=>o(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0,state:{...r.state,dashboardEntry:i}})]}var yt=e=>`Last ${e===`7d`?7:30} calendar days`,bt=`font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,xt=`min-w-0 rounded-lg border bg-card-2 p-4`,q=`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground`;function St(){let e=a().data?.projects;return t=>e?.find(e=>e.id===t)?.name??t}var Ct=(e,t)=>`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`;function wt({label:e,value:t,onChange:n}){return(0,I.jsxs)(`label`,{className:et,children:[e,(0,I.jsxs)(tt,{value:t,onChange:e=>n(e.target.value===`30d`?`30d`:`7d`),children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})}function Tt({query:e}){return e.isPending?(0,I.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading insights…`}):e.isError?(0,I.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[e.data?`Showing previous results. `:``,`Could not refresh insights.`,` `,(0,I.jsx)(w,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry insights`})]}):null}function Et({period:e,active:t}){let n=Ue(e,t),r=n.data;return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(Tt,{query:n}),r&&(0,I.jsx)(G,{coverage:r.coverage,retry:()=>void n.refetch()}),r&&(0,I.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,I.jsx)(Dt,{data:r}),(0,I.jsx)(Ot,{data:r})]})]})}function Dt({data:e}){let t=e.delivered,n=[{label:`PRs opened`,value:t.prsOpened,note:`${t.prsTouched} touched`},{label:`Lines`,value:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`text-success`,children:[`+`,t.additions.toLocaleString(`en-US`)]}),` `,(0,I.jsxs)(`span`,{className:`text-danger`,children:[`−`,t.deletions.toLocaleString(`en-US`)]})]})},{label:`Files`,value:t.files.toLocaleString(`en-US`)},{label:`Issues`,value:t.issues}];return(0,I.jsxs)(`section`,{className:xt,"aria-label":`Delivered`,children:[(0,I.jsx)(L,{rows:Object.entries(t).map(([t,n])=>({section:`delivered`,metric:t,value:n,unit:[`additions`,`deletions`].includes(t)?`lines`:t===`files`?`files`:`count`,asOf:e.asOf,note:`Completed since ${e.windowStart}`}))}),(0,I.jsx)(`h3`,{className:bt,children:`Delivered`}),(0,I.jsx)(`dl`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-4`,children:n.map(e=>(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`dt`,{className:`text-xs text-soft-foreground`,children:e.label}),(0,I.jsx)(`dd`,{className:`mt-1 truncate text-xl font-semibold tracking-tight tabular-nums`,children:e.value}),e.note&&(0,I.jsx)(`dd`,{className:`text-xs text-soft-foreground`,children:e.note})]},e.label))}),(0,I.jsxs)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:[`From `,t.completedTasks,` completed `,t.completedTasks===1?`task`:`tasks`,` ·`,` `,t.measuredTasks,` with a stored diff`]})]})}function Ot({data:e}){let t=St(),{total:n,reasons:r}=e.failures;return(0,I.jsxs)(`section`,{className:xt,"aria-label":`Why tasks failed`,children:[(0,I.jsx)(L,{rows:r.map(t=>({section:`failures`,entity:t.label,metric:t.category,value:t.count,unit:`tasks`,asOf:e.asOf,note:t.latest.message}))}),(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,I.jsx)(`h3`,{className:bt,children:`Why tasks failed`}),n>0&&(0,I.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[n,` failed`]})]}),n===0?(0,I.jsxs)(`span`,{className:`mt-4 flex items-center gap-2.5 text-sm text-muted-foreground`,children:[(0,I.jsx)(N,{tone:`success`}),`No failed outcomes in this period`]}):(0,I.jsx)(`ul`,{className:`mt-3 space-y-3`,children:r.map(e=>(0,I.jsx)(kt,{reason:e,total:n,projectName:t},`${e.category}:${e.label}`))})]})}function kt({reason:e,total:t,projectName:n}){let{latest:r}=e;return(0,I.jsxs)(`li`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate font-medium`,title:e.label,children:e.label}),(0,I.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:e.count})]}),(0,I.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full bg-danger/70`,style:{width:`${e.count/t*100}%`}})}),(0,I.jsxs)(`span`,{className:`mt-1.5 block truncate text-xs text-soft-foreground`,title:r.message,children:[`Latest:`,` `,(0,I.jsx)(D,{className:`text-muted-foreground hover:text-foreground hover:underline`,to:Ct(r.projectId,r.id),children:r.title}),` `,`· `,n(r.projectId),r.step?` · ${r.step}`:``,` · `,P(r.at),` ago`]})]})}var At={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,cursor:`Cursor`,pi:`Pi`,unknown:`Unknown backend`,mixed:`Mixed backends`},jt=e=>At[e]??e,Mt=(e,t)=>t?Math.round(e/t*100):0;function Nt(){let[e,t]=vt(`backends`,[`7d`,`30d`],`7d`),n=Ue(e),r=n.data,i=r?.visibility.cost;return(0,I.jsx)(`section`,{"data-dashboard-module":`backends`,className:`min-w-0`,children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Backends: ${yt(e)}; finished tasks`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Backends & models`}),(0,I.jsx)(wt,{label:`Finished`,value:e,onChange:t})]}),(0,I.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,I.jsx)(Tt,{query:n}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Tasks that finished done or failed in the period, by the backend and model their steps ran on. Includes subtasks. Cost is reported USD only.`}),(0,I.jsx)(G,{coverage:r.coverage,retry:()=>void n.refetch()}),r.backends.length?(0,I.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Backend comparison`,tabIndex:0,children:(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:q,children:`Backend`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Finished`}),(0,I.jsx)(`th`,{className:q,children:`Success`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Median cycle`}),i&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Reported USD`}),i&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Per completed`})]})}),(0,I.jsx)(`tbody`,{children:r.backends.map(e=>(0,I.jsx)(Pt,{stat:e,cost:!!i},`${e.backend}:${e.model??``}`))})]})}):(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No finished tasks in this period.`}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,I.jsx)(it,{at:r.asOf})}),(0,I.jsx)(L,{rows:r.backends.flatMap(e=>[`finished`,`done`,`failed`,`medianCycleHours`].map(t=>({section:`backends`,entity:`${e.backend}${e.model?`:${e.model}`:``}`,metric:t,value:e[t],unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:r.asOf})))})]})]})]})})}function Pt({stat:e,cost:t}){let n=Mt(e.done,e.finished),r=e.costUsd?.value;return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,I.jsx)(`span`,{className:`block font-medium`,children:jt(e.backend)}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:e.backend===`mixed`?`steps ran on different backends`:e.model??`default model`})]}),(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.finished}),(0,I.jsxs)(`td`,{className:`min-w-40 px-3 py-2.5`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-danger/40`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{className:`block h-full rounded-full bg-success`,style:{width:`${n}%`}})}),(0,I.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs tabular-nums`,children:[n,`%`]})]}),(0,I.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.done,` done · `,e.failed,` failed`]})]}),(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.timedTasks?K(e.medianCycleHours):`—`}),t&&(0,I.jsxs)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:[r==null?`—`:_t(r,!0),(0,I.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.costUsd?.reportedTasks??0,`/`,e.finished,` reported`]})]}),t&&(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:r==null||!e.done?`—`:_t(r/e.done,!0)})]})}function Ft(){let[e,t]=vt(`automations`,[`7d`,`30d`],`7d`),n=ve(),r=Ue(e),i=Qe(n.known&&!n.off),a=St(),o=r.data,s=o?.visibility.cost,c=new Map;for(let e of i.data??[])for(let t of e.data?.automations??[])c.set(`${e.id}\u0000${t.id}`,{projectId:e.id,automationId:t.id,name:t.name,enabled:t.enabled,definition:`known`});let l=new Set((i.data??[]).flatMap(e=>e.data&&!e.error?[e.id]:[])),u=i.isError||i.registry.isError||(i.data??[]).some(e=>e.error);for(let e of o?.automations??[]){let t=`${e.projectId}\u0000${e.automationId}`,n=c.get(t);c.set(t,n?{...n,stat:e}:{...e,name:e.automationId,definition:l.has(e.projectId)?`removed`:`unknown`,stat:e})}let d=[...c.values()].sort((e,t)=>(t.stat?.tasks??0)-(e.stat?.tasks??0)||Number(t.enabled??!1)-Number(e.enabled??!1)||e.name.localeCompare(t.name));return(0,I.jsx)(`section`,{"data-dashboard-module":`automation-outcomes`,className:`min-w-0`,children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Automation outcomes: tasks created in ${yt(e)}`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Automation outcomes`}),(0,I.jsx)(wt,{label:`Launched`,value:e,onChange:t})]}),(0,I.jsx)(`div`,{className:`space-y-3 p-4`,children:n.off?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Tt,{query:r}),o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Tasks each automation created in the period and how they ended. Active means still running, queued, waiting on you, or waiting to resume after a usage limit.`}),(0,I.jsx)(G,{coverage:o.coverage,retry:()=>void r.refetch()}),u&&(0,I.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Some automation details could not be loaded. Their outcomes are shown by id.`,` `,(0,I.jsx)(w,{variant:`ghost`,onClick:i.retry,children:`Retry automations`})]}),d.length?(0,I.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Automation outcomes`,tabIndex:0,children:(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:q,children:`Automation`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Tasks`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Done`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Failed`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Active`}),(0,I.jsx)(`th`,{className:q,children:`Last run`}),s&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Reported USD`})]})}),(0,I.jsx)(`tbody`,{children:d.map(e=>(0,I.jsx)(It,{row:e,cost:!!s,projectName:a},`${e.projectId}:${e.automationId}`))})]})}):(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No automations yet. Create one in a project's Automations page.`}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,I.jsx)(it,{at:o.asOf})}),(0,I.jsx)(L,{rows:d.flatMap(e=>[`tasks`,`done`,`failed`,`active`].map(t=>({section:`automation-outcomes`,entity:`${e.projectId}:${e.automationId}`,metric:t,value:e.stat?.[t]??0,unit:`tasks`,asOf:o.asOf,note:e.name})))})]})]})})]})})}function It({row:e,cost:t,projectName:n}){let r=e.stat,i=`px-3 py-2.5 text-right tabular-nums`,a=e=>e||(0,I.jsx)(`span`,{className:`text-soft-foreground`,children:`0`});return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2.5`,children:[e.definition===`removed`?(0,I.jsx)(`span`,{className:`block font-medium`,children:e.name}):(0,I.jsx)(D,{className:`block font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/automations/${encodeURIComponent(e.automationId)}`,children:e.name}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,I.jsx)(N,{tone:e.enabled?`success`:`neutral`}),n(e.projectId),` ·`,` `,e.definition===`removed`?`Removed`:e.definition===`unknown`?`Details unavailable`:e.enabled?`Enabled`:`Disabled`]})]}),(0,I.jsx)(`td`,{className:i,children:a(r?.tasks)}),(0,I.jsx)(`td`,{className:i,children:a(r?.done)}),(0,I.jsx)(`td`,{className:`${i} ${r?.failed?`text-danger`:``}`,children:a(r?.failed)}),(0,I.jsx)(`td`,{className:i,children:a(r?.active)}),(0,I.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-xs text-muted-foreground`,children:r?.lastRunAt?(0,I.jsxs)(`time`,{dateTime:r.lastRunAt,title:new Date(r.lastRunAt).toLocaleString(),children:[P(r.lastRunAt),` ago · `,r.lastStatus]}):`—`}),t&&(0,I.jsx)(`td`,{className:i,children:r?.costUsd?.value==null?`—`:_t(r.costUsd.value,!0)})]})}var Lt=0,Rt=()=>++Lt,J=new Map;function Y(e,t){let n=(0,F.useContext)(ct),r=()=>{let r=n?J.get(n):void 0;return r?.has(e)?r.get(e):typeof t==`function`?t():t},[i,a]=(0,F.useState)(r),o=`${n}:${e}`,[s,c]=(0,F.useState)(o);o!==s&&(c(o),a(()=>r()));let l=(0,F.useMemo)(()=>({value:i}),[n,e]);return l.value=i,(0,F.useEffect)(()=>()=>{if(!n)return;let t=J.get(n)??new Map;t.set(e,l.value),t.size>80&&t.delete(t.keys().next().value),J.delete(n),J.set(n,t),J.size>20&&J.delete(J.keys().next().value)},[n,e,l]),[i,a]}var zt=`a[href], button, select, input, [tabindex]`;function Bt(e){let[t]=Y(`${e}:position`,()=>({scroll:0})),n=(0,F.useCallback)(e=>{let n=[...e.querySelectorAll(zt)],r=t.href?n.find(e=>e.getAttribute(`href`)===t.href):t.index===void 0?void 0:n[t.index];return r&&r.getAttribute(`aria-disabled`)!==`true`&&r.focus({preventScroll:!0}),e.scrollTop=t.scroll,!!r&&r.getAttribute(`aria-disabled`)!==`true`},[t]),r=(0,F.useMemo)(()=>({restore:()=>!1}),[t]);return{ref:(0,F.useCallback)(e=>{if(!e)return;let i=t.href!==void 0||t.index!==void 0,a=()=>{if(!i)return!1;let r=n(e);return r?(i=!1,o.disconnect()):e.querySelector(`[data-sheet-loading="false"]`)&&(i=!1,o.disconnect(),e.querySelector(`button:not([disabled]), select, [tabindex="0"]`)?.focus({preventScroll:!0}),e.scrollTop=t.scroll),r};r.restore=a;let o=new MutationObserver(a);i&&o.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-sheet-loading`]});let s=()=>{i=!1,o.disconnect()},c=()=>{i||(t.scroll=e.scrollTop)},l=n=>{i||!(n.target instanceof HTMLElement)||(t.href=n.target.getAttribute(`href`)??void 0,t.index=[...e.querySelectorAll(zt)].indexOf(n.target))};return e.addEventListener(`pointerdown`,s),e.addEventListener(`keydown`,s),e.addEventListener(`wheel`,s,{passive:!0}),e.addEventListener(`scroll`,c),e.addEventListener(`focusin`,l),()=>{o.disconnect(),e.removeEventListener(`pointerdown`,s),e.removeEventListener(`keydown`,s),e.removeEventListener(`wheel`,s),e.removeEventListener(`scroll`,c),e.removeEventListener(`focusin`,l)}},[t,n,r]),onOpenAutoFocus:e=>{(t.href!==void 0||t.index!==void 0)&&(e.preventDefault(),r.restore())}}}function Vt(e,t){let n=(0,F.useRef)(null),[r,i]=Y(`${e}:trigger`,null);return{capture:()=>{let e=document.activeElement;n.current=e instanceof HTMLElement&&e!==document.body?e:null,i(n.current?{label:n.current.getAttribute(`aria-label`),text:n.current.textContent}:null)},restore:()=>{((n.current?.isConnected?n.current:r?[...document.querySelectorAll(`button`)].find(e=>!e.closest(`[role="dialog"]`)&&!e.hasAttribute(`disabled`)&&(r.label?e.getAttribute(`aria-label`)===r.label:e.textContent===r.text)):void 0)??document.querySelector(t))?.focus({preventScroll:!0})}}}function Ht(e,t=!0){return d({queryKey:[...s.dashboard,`overview`,e],enabled:t,staleTime:5e3,refetchInterval:t&&!e.snapshotId?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>b.parse(await f(await m.api.v1.workspace.dashboard.overview.$get({query:{period:e.period??`7d`,group:e.group??`completed`,tzOffsetMinutes:String(e.tzOffsetMinutes??new Date().getTimezoneOffset()),...e.snapshotId?{snapshotId:e.snapshotId}:{},...e.projectId?{projectId:e.projectId}:{},offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/overview`))})}var Ut={running:`Running now`,"needs-you":`Needs you`,completed:`Completed`,failed:`Failed outcomes`},Wt={"needs-you":V.violet,running:V.info,completed:V.success,failed:V.danger},Gt={"needs-you":qe,running:We,completed:k,failed:Ke};function Kt({active:e,children:t,onCurrent:n}){let[r,i]=vt(`period`,[`7d`,`30d`],`7d`),o=Vt(`outcome`,`[data-outcome-trigger]`),s=a().data?.projects,c=e=>s?.find(t=>t.id===e)?.name??e,l=Ht({period:r},e),[u,d]=Y(`outcome:selection`,null),f=Bt(`outcome:${u?.identity??`closed`}`),p=ye();if((0,F.useEffect)(()=>{e||d(null)},[e]),!e)return t({});let m=l.data,h=(e,t)=>{o.capture(),m&&d({identity:Rt(),snapshot:m,group:e,projectId:t})},g=m?.coverage.projects.every(e=>e.state===`complete`);return(0,I.jsxs)(I.Fragment,{children:[t({overview:(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Workspace overview`}),(0,I.jsxs)(`label`,{className:et,children:[`Outcomes period`,(0,I.jsxs)(tt,{value:r,onChange:e=>{i(e.target.value===`30d`?`30d`:`7d`),d(null)},children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4 p-4`,children:[l.isPending&&(0,I.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading overview…`}),l.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[m?`Showing previous results. `:``,`Could not refresh overview.`,` `,(0,I.jsx)(w,{variant:`outline`,onClick:()=>void l.refetch(),children:`Retry overview`})]}),m&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[m.metrics.needsYou?`${m.metrics.needsYou} tasks require your input or review.`:g&&p.connected&&!l.isError?`No tasks currently require your input or review.`:`No waiting tasks found in the available data.`,` `,m.metrics.failed,` failed `,m.metrics.failed===1?`outcome`:`outcomes`,` `,`in this period. Includes subtasks; completed does not mean accepted or deployed.`]}),(0,I.jsx)(G,{coverage:m.coverage,retry:()=>void l.refetch()}),(0,I.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[`needs-you`,`running`,`completed`,`failed`].map(e=>{let t=m.metrics[e===`needs-you`?`needsYou`:e],i=Gt[e];return(0,I.jsxs)(w,{"data-outcome-trigger":!0,"data-export-keep":!0,variant:`outline`,className:`relative min-w-0 overflow-hidden rounded-lg border bg-card-2 p-4 transition-colors before:absolute before:inset-x-0 before:top-0 before:h-px before:opacity-80 hover:border-foreground/20 hover:bg-muted/40 sm:p-5 group/metric h-auto min-h-24 flex-col items-start gap-0 whitespace-normal text-left font-normal ${t===0?V.neutral:Wt[e]}`,onClick:t=>{n&&(e===`running`||e===`needs-you`)?n(e,t.currentTarget):h(e)},"aria-label":`${Ut[e]}: ${t}`,children:[(0,I.jsx)(rt,{label:Ut[e],value:t,icon:(0,I.jsx)(i,{className:`size-4`}),children:e===`running`||e===`needs-you`?`Current state`:`Last ${r===`7d`?7:30} calendar days`}),(0,I.jsxs)(`span`,{"data-export-exclude":!0,className:`mt-4 flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors group-hover/metric:text-foreground`,children:[`View tasks`,` `,(0,I.jsx)(Be,{className:`size-3 transition-transform group-hover/metric:translate-x-0.5 motion-reduce:transition-none`,"aria-hidden":`true`})]})]},e)})}),(0,I.jsx)(Et,{period:r,active:e}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 border-t pt-3`,children:[(0,I.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Median cycle time`,` `,(0,I.jsx)(`strong`,{className:`font-mono font-semibold text-foreground`,children:K(m.metrics.medianCycleHours)}),` `,`· `,m.metrics.timedTasks,`/`,m.metrics.completed,` completed tasks have valid timings.`,` `,(0,I.jsx)(w,{variant:`ghost`,className:`h-auto px-1.5 py-1 text-sm text-foreground underline-offset-4 hover:underline`,onClick:()=>h(`completed`),children:`Inspect completed tasks`})]}),(0,I.jsx)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,children:(0,I.jsxs)(`time`,{dateTime:m.asOf,title:new Date(m.asOf).toLocaleString(),children:[`Updated `,P(m.asOf),` ago`]})})]}),(0,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-1`,children:[(0,I.jsx)(B,{}),`How these metrics work`]}),(0,I.jsx)(`p`,{className:`mt-1 max-w-prose pl-5 leading-relaxed`,children:`Outcomes use finish dates, including archived tasks. Scheduled retries are excluded from failed outcomes. Period includes today at your current fixed UTC offset.`})]}),(0,I.jsx)(L,{rows:Object.entries(m.metrics).map(([e,t])=>({section:`overview`,metric:e,value:t,unit:e===`medianCycleHours`?`hours`:`tasks`,asOf:m.asOf,note:e===`running`||e===`needsYou`?`Current non-archived state`:`Finished since ${m.windowStart}`}))})]})]})]}),portfolio:m&&(0,I.jsx)(`div`,{children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Outcomes: Last ${r===`7d`?7:30} calendar days; workload: current state`,children:[(0,I.jsx)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,children:(0,I.jsx)(`h2`,{className:`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Projects`})}),(0,I.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:`Current workload and outcomes for the selected period. Sorted by tasks needing you, then running tasks. Counts include subtasks.`}),(0,I.jsxs)(`div`,{className:`overflow-x-auto px-1 pb-2`,role:`region`,"aria-label":`Project outcomes`,tabIndex:0,children:[(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:[`Project`,`Needs you`,`Running`,`Completed`,`Failed`,`Median cycle`].map(e=>(0,I.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground ${e===`Project`?``:`text-right`}`,children:e},e))})}),(0,I.jsx)(`tbody`,{children:m.projects.map(e=>{let t=m.coverage.projects.find(t=>t.projectId===e.projectId);return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,I.jsx)(D,{className:`font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks`,children:c(e.projectId)}),t?.state!==`complete`&&(0,I.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Incomplete data`})]}),[`needs-you`,`running`,`completed`,`failed`].map(n=>(0,I.jsx)(`td`,{className:`px-3 py-1 text-right`,children:(0,I.jsx)(w,{"data-export-keep":!0,variant:`ghost`,className:`min-h-11 tabular-nums`,"aria-label":`${c(e.projectId)}: ${Ut[n]}: ${t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]}`,disabled:t?.state===`unavailable`,onClick:()=>h(n,e.projectId),children:t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]})},n)),(0,I.jsxs)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:[K(e.medianCycleHours),(0,I.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.timedTasks,`/`,e.completed,` timed`]})]})]},e.projectId)})})]}),!m.projects.length&&(0,I.jsx)(`p`,{className:`py-4`,children:`No projects to compare yet.`})]}),(0,I.jsx)(L,{rows:m.projects.flatMap(({projectId:e,...t})=>Object.entries(t).map(([t,n])=>({section:`portfolio`,entity:e,metric:t,value:m.coverage.projects.find(t=>t.projectId===e)?.state===`unavailable`?null:n,unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:m.asOf,note:`Outcomes since ${m.windowStart}; running and needsYou are current state`})))})]})})}),(0,I.jsx)(Oe,{open:!!u,onOpenChange:e=>{e||d(null)},children:(0,I.jsxs)(De,{...f,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),o.restore()},children:[(0,I.jsxs)(ke,{children:[(0,I.jsxs)(Ae,{children:[u?Ut[u.group]:`Tasks`,u?.projectId?` · ${u.projectId}`:``]}),(0,I.jsx)(Ee,{children:`Tasks behind the selected metric. Includes subtasks. Snapshot keeps counts and rows consistent.`})]}),u&&(0,I.jsx)(qt,{selection:u,projectName:c,refresh:()=>{d(null),l.refetch()}},u.identity)]})})]})}function qt({selection:e,refresh:t,projectName:n}){let[r,i]=Y(`outcome:${e.identity}:offset`,0),a=Ht({period:e.snapshot.period,snapshotId:e.snapshot.snapshotId,group:e.group,projectId:e.projectId,offset:r}),o=(0,F.useRef)(null),s=(0,F.useRef)(null);(0,F.useEffect)(()=>{a.data&&s.current===r&&(o.current?.focus(),s.current=null)},[a.data,r]);let c=e=>{s.current=e,i(e)};return(0,I.jsxs)(`div`,{className:`space-y-3 p-4`,"data-sheet-loading":a.isFetching,children:[a.isPending&&(0,I.jsx)(`p`,{children:`Loading tasks…`}),a.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[`This snapshot may have expired or become unavailable.`,` `,(0,I.jsx)(w,{onClick:t,children:`Refresh overview`})]}),a.data&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{ref:o,tabIndex:-1,className:`text-xs text-muted-foreground`,children:[a.data.page.total,` tasks · Snapshot from`,` `,(0,I.jsxs)(`time`,{dateTime:a.data.asOf,title:new Date(a.data.asOf).toLocaleString(),children:[P(a.data.asOf),` ago`]})]}),a.data.page.rows.map(t=>(0,I.jsx)(Jt,{row:t,group:e.group,projectName:n},`${t.projectId}:${t.id}`)),!a.data.page.rows.length&&(0,I.jsx)(`p`,{children:`No tasks in this group.`})]}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(w,{variant:`outline`,disabled:!r||a.isFetching,onClick:()=>c(Math.max(0,r-20)),children:`Previous`}),(0,I.jsx)(w,{variant:`outline`,disabled:!a.data||a.data.page.nextOffset===null||a.isFetching,onClick:()=>c(a.data.page.nextOffset),children:`Next`})]})]})}function Jt({row:e,group:t,projectName:n}){let r=le(e),i=t===`running`||t===`needs-you`;i&&r&&(e={...e,...r});let a=r===null,s=i&&(e.archived||(t===`running`?e.status!==`running`:!g(e))),c=a||s,l=o(e),u=i&&a?`Task removed`:s?t===`running`?`No longer running`:`No longer needs you`:l.label;return(0,I.jsxs)(`div`,{className:`border-b py-3`,children:[(0,I.jsx)(D,{"aria-disabled":c||void 0,tabIndex:c?-1:void 0,onClick:e=>{c&&e.preventDefault()},className:`block min-h-11 font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,children:e.titleSummary||e.title}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsx)(N,{tone:l.tone}),` `,n(e.projectId),` ·`,` `,u,` · `,e.archived?`Archived · `:``,(0,I.jsxs)(`time`,{dateTime:e.finishedAt??e.createdAt,title:new Date(e.finishedAt??e.createdAt).toLocaleString(),children:[e.finishedAt?`Finished`:`Created`,` `,P(e.finishedAt??e.createdAt),` ago`]})]})]})}var X={snapshot:[...s.dashboard,`snapshot`],feed:e=>[...s.dashboard,`feed`,e],telemetry:[...s.dashboard,`telemetry`]},Yt=new Map;async function Xt(e){let t=A(),n=x.parse(await f(await m.api.v1.workspace.dashboard.$get({},{init:{signal:e}}),`/workspace/dashboard`));return Yt.has(n.snapshotId)||Yt.set(n.snapshotId,t),Yt.size>60&&Yt.delete(Yt.keys().next().value),j(t,[...n.questions.rows,...n.reviews.rows]),n}async function Zt(e,t,n=0,r=20,i){let a=T.parse(await f(await m.api.v1.workspace.dashboard.tasks.$get({query:{snapshotId:e,group:t,offset:String(n),limit:String(r)}},{init:{signal:i}}),`/workspace/dashboard/tasks`)),o=Yt.get(e);return o!==void 0&&j(o,a.page.rows),a}function Qt(e){return d({queryKey:X.snapshot,queryFn:({signal:e})=>Xt(e),enabled:e,staleTime:5e3,refetchOnMount:`always`,refetchInterval:e?15e3:!1,refetchIntervalInBackground:!1,retry:!1})}function $t(e){return d({queryKey:X.telemetry,enabled:e,staleTime:0,queryFn:async({signal:e})=>{let t=C.parse(await f(await m.api.v1.workspace.dashboard.telemetry.$get({},{init:{signal:e}}),`/workspace/dashboard/telemetry`));return O.seed(t.samples,t.asOf),t}})}function en(e,t){let n=d({queryKey:X.feed(e),queryFn:async({signal:t})=>{let n=A(),r=_.parse(await f(await m.api.v1.workspace.dashboard.feed.$get({query:{filter:e}},{init:{signal:t}}),`/workspace/dashboard/feed`));return j(n,r.rows.flatMap(e=>e.kind===`task-result`?[e.run]:[])),r},enabled:t,staleTime:15e3,refetchInterval:t&&e!==`github`?15e3:!1,retry:!1}),r=(0,F.useRef)(!1);return(0,F.useEffect)(()=>{r.current=!1},[e,t]),(0,F.useEffect)(()=>{if(!t||r.current||!n.data?.sources.some(e=>e.reason===`Still loading GitHub`))return;let e=setTimeout(()=>{document.visibilityState!==`hidden`&&(r.current=!0,n.refetch())},5e3);return()=>clearTimeout(e)},[t,n.data,n.refetch]),n}function tn(e,t){let n=en(`tasks`,t&&e!==`github`),r=en(`github`,t&&e!==`tasks`),i=(0,F.useMemo)(()=>{if(e===`tasks`)return n.data;if(e===`github`)return r.data;let t=n.data,i=r.data;if(!t&&!i)return;let a=t??i,o=new Date(Math.max(Date.parse(t?.asOf??a.asOf),Date.parse(i?.asOf??a.asOf))).toISOString(),s=new Date(Date.parse(o)-10080*60*1e3).toISOString(),c=[...t?.rows??[],...i?.rows??[]].filter(e=>Date.parse(e.at)>=Date.parse(s)&&Date.parse(e.at)<=Date.parse(o)).sort((e,t)=>nn(e,t)),l=new Set(c.slice(60).map(e=>e.kind===`task-result`?`tasks:${e.run.projectId}`:e.key.slice(0,e.key.lastIndexOf(`:`)))),u=[...t?.sources??[],...i?.sources??[]].map(e=>l.has(e.key)?{...e,truncated:!0}:e);return{...a,asOf:o,windowStart:s,filter:`all`,rows:c.slice(0,60),sources:u,coverage:t?.coverage??a.coverage,truncated:c.length>60||!!t?.truncated||!!i?.truncated}},[e,n.data,r.data]),a=e===`github`?r:n;return{...a,data:i,githubError:r.isError,githubFetching:r.isFetching,retryTasks:()=>n.refetch(),retryFailed:()=>e===`github`?r.refetch():e===`tasks`?n.refetch():Promise.all([...n.isError?[n.refetch()]:[],...r.isError?[r.refetch()]:[]]),isPending:!i&&a.isPending,isError:a.isError||e===`all`&&r.isError,isFetching:a.isFetching||e===`all`&&r.isFetching,refetch:()=>e===`tasks`?n.refetch():r.refetch()}}function nn(e,t){return Date.parse(t.at)-Date.parse(e.at)||e.key.localeCompare(t.key)}var rn=[...s.dashboard,`costs`];function an(){let e=0,t=0,n,r=new Set;return{subscribe:e=>(r.add(e),()=>{r.delete(e)}),getSnapshot:()=>n,async read(i,a){let o=++e,s=await un(i,a);return!a?.aborted&&o>t&&(t=o,(n?.cost!==s.visibility.cost||n?.tokens!==s.visibility.tokens)&&(n=s.visibility,r.forEach(e=>e()))),s}}}var on=new WeakMap;function sn(e){let t=on.get(e);return t||(t=an(),on.set(e,t)),t}function cn(){let e=sn(c());return(0,F.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}var ln=new Map;async function un(e,t){let n=A(),r=y.parse(await f(await m.api.v1.workspace.dashboard.costs.$get({query:{...e,offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/costs`));!e.snapshotId&&!ln.has(r.snapshotId)&&ln.set(r.snapshotId,n),ln.size>60&&ln.delete(ln.keys().next().value);let i=ln.get(r.snapshotId);return i!==void 0&&j(i,r.tasks.rows),r}function dn(e,t,n){let r=sn(c());return d({queryKey:[...rn,e,t,n],queryFn:({signal:n})=>r.read({period:e,sort:t,tzOffsetMinutes:new Date().getTimezoneOffset()},n),staleTime:5e3,refetchOnMount:`always`,refetchInterval:15e3,refetchIntervalInBackground:!1,retry:!1})}function fn(e,t,n,r){let i=sn(c());return d({queryKey:[...rn,`tasks`,e.snapshotId,t,n,r,e.visibility],retry:!1,queryFn:async({signal:a})=>{let o=e.tzOffsetMinutes??new Date().getTimezoneOffset(),s=async s=>{let c=await i.read({period:e.period,sort:n,snapshotId:s,projectId:t,tzOffsetMinutes:o},a),l=[...c.tasks.rows];for(;c.tasks.nextOffset!==null&&l.length<r;)c=await i.read({period:e.period,sort:n,snapshotId:c.snapshotId,projectId:t,offset:c.tasks.nextOffset},a),l.push(...c.tasks.rows);return{...c,tasks:{...c.tasks,rows:l}}};try{return await s(e.snapshotId)}catch(e){if(e instanceof u&&e.status===409)return s();throw e}}})}var pn={cost:{text:`text-primary`,fill:`bg-primary`,tint:V.primary,icon:ue},input:{text:`text-violet`,fill:`bg-violet`,tint:V.violet,icon:Ge},output:{text:`text-info`,fill:`bg-info`,tint:V.info,icon:ne}};function mn({metric:e,label:t,value:n,reported:r,total:i}){let a=pn[e],o=a.icon,s=i?Math.min(100,r/i*100):0;return(0,I.jsxs)(`div`,{className:`${nt} ${a.tint}`,children:[(0,I.jsxs)(rt,{label:t,value:n,icon:(0,I.jsx)(o,{className:`size-4 ${a.text}`}),children:[r,` of `,i,` tasks report this metric`]}),(0,I.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full ${a.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${s}%`}})})]})}function hn({projects:e,currentProjects:t,metric:n,field:r,label:i,format:a,onSelect:o}){let s=e.reduce((e,t)=>Math.max(e,t[r]?.value??0),0),c=pn[n];return(0,I.jsxs)(Re,{delayDuration:150,children:[(0,I.jsxs)(`div`,{className:`space-y-1 rounded-xl border p-2`,"aria-label":`Projects ranked by ${i}`,children:[e.length===0&&(0,I.jsx)(`p`,{className:`px-3 py-4 text-muted-foreground`,children:`No projects to compare in this cohort.`}),e.slice(0,5).map((e,n)=>{let l=e[r],u=l?.value,d=u==null||s===0?0:u/s*100,f=u!=null;return(0,I.jsxs)(ze,{children:[(0,I.jsx)(Ie,{asChild:!0,children:(0,I.jsxs)(`button`,{"data-export-row":!0,"data-export-keep":!0,className:`group w-full rounded-lg px-3 py-3 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 motion-reduce:transition-none`,disabled:!t.some(t=>t.projectId===e.projectId),onClick:()=>o(e.projectId),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`w-4 shrink-0 text-xs tabular-nums text-muted-foreground`,"aria-hidden":`true`,children:n+1}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium`,children:e.projectId}),(0,I.jsx)(`span`,{className:`shrink-0 font-semibold tabular-nums`,children:a(u)}),(0,I.jsx)(Be,{"data-export-exclude":!0,className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`mt-2 ml-7 h-2 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{"data-project-bar":e.projectId,className:`h-full rounded-full ${c.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${d}%`}})}),(0,I.jsxs)(`p`,{className:`mt-1.5 ml-7 text-xs text-muted-foreground`,children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric`,f?``:` · No measured value`]})]})}),(0,I.jsxs)(Le,{className:`max-w-64`,children:[(0,I.jsxs)(`p`,{className:`font-medium`,children:[e.projectId,` · `,i,`: `,a(u)]}),(0,I.jsxs)(`p`,{children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric.`]}),(0,I.jsx)(`p`,{children:`Open project tasks`})]})]},e.projectId)})]}),e.length>0&&(0,I.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[e.length>5?`Top 5 of ${e.length} projects. `:``,`Bar lengths compare reported values; the largest is the reference.`]})]})}var Z={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},gn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function _n(e,t){return JSON.stringify([e.totals,e.projects,e.tasks,e.visibility,e.coverage,e.invalidDateTasks])!==JSON.stringify([t.totals,t.projects,t.tasks,t.visibility,t.coverage,t.invalidDateTasks])}var vn=(e,t)=>_t(e,t===`cost`);function Q(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}function yn({value:e,onChange:t,visibility:n}){return(0,I.jsxs)(`label`,{className:et,children:[`Sort by`,(0,I.jsx)(tt,{value:e,onChange:e=>t(e.target.value),children:Q(n).map(e=>(0,I.jsx)(`option`,{value:e,children:gn[e]},e))})]})}function bn(){return(0,I.jsx)(xn,{visibility:He(h().data)})}function xn({visibility:e}){return(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsx)(`div`,{className:z,children:(0,I.jsx)(`h2`,{className:R,children:`Usage & cost`})}),!e.cost&&!e.tokens?(0,I.jsx)(`p`,{className:`p-4 text-sm`,children:`Usage metrics are hidden by workspace settings`}):(0,I.jsx)(Sn,{visibility:e},`${e.cost}:${e.tokens}`)]})}function Sn({visibility:e}){let[t,n]=vt(`usagePeriod`,[`all`,`7d`,`30d`],`all`),[r,i]=vt(`usageSort`,Q(e),e.cost?`cost`:`input`);return(0,I.jsx)(Cn,{period:t,setPeriod:n,sort:r,setSort:i,visibility:e})}function Cn({period:e,setPeriod:t,sort:n,setSort:r,visibility:i}){let a=dn(e,n,`${i.cost}:${i.tokens}`),[o,s]=Y(`usage:accepted`,void 0),c=o??a.data,l=a.data??c,[u,d]=Y(`usage:panel`,null),[f,p]=(0,F.useState)(e);f!==e&&(p(e),s(void 0),d(null));let m=Bt(`usage:${u?.identity??`closed`}`),h=Vt(`usage`,`[data-usage-trigger]`),g=e=>{h.capture(),c&&d({identity:Rt(),projectId:e,snapshot:c,latestId:l?.snapshotId??c.snapshotId})},_=cn()??i,v={cost:i.cost&&_.cost,tokens:i.tokens&&_.tokens},y=Q(v).includes(n)?n:Q(v)[0]??`cost`,b=[...c?.projects??[]].sort((e,t)=>{let n=e[Z[y]]?.value,r=t[Z[y]]?.value;return(n==null?r==null?0:1:r==null?-1:r-n)||e.projectId.localeCompare(t.projectId)});!o&&a.data&&s(a.data);let x=c&&l&&_n(c,l),S=c?.coverage.projects.some(e=>e.state!==`complete`),C=l?.coverage.projects.some(e=>e.state!==`complete`),T=JSON.stringify(c?.coverage)!==JSON.stringify(l?.coverage),E=c?.totals.tasks===0&&!S&&!C;return(0,I.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[c&&(0,I.jsx)(L,{rows:E?[]:[...Q(v).map(e=>({section:`totals`,metric:Z[e],value:c.totals[Z[e]]?.value??null,unit:e===`cost`?`USD`:`tokens`,reportedTasks:c.totals[Z[e]]?.reportedTasks??0,totalTasks:c.totals.tasks,asOf:c.asOf})),...(v.cost||v.tokens?b.slice(0,5):[]).map(e=>({section:`project`,entity:e.projectId,metric:Z[y],value:e[Z[y]]?.value??null,unit:y===`cost`?`USD`:`tokens`,reportedTasks:e[Z[y]]?.reportedTasks??0,totalTasks:e.tasks,asOf:c.asOf}))]}),c&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:c.asOf})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`font-medium`,children:`Lifetime totals of retained tasks`}),(0,I.jsxs)(`details`,{className:`mt-1 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${$e} min-h-11`,children:[(0,I.jsx)(B,{}),`How these metrics work`]}),(0,I.jsxs)(`p`,{children:[`Includes archived tasks and subtasks.`,` `,v.cost&&`Reported USD is not an invoice. `,`Missing reports are excluded, not treated as zero. Calendar days use your current UTC offset, including today.`]})]})]}),(0,I.jsxs)(`label`,{className:et,children:[`Tasks created`,(0,I.jsxs)(tt,{value:e,onChange:e=>t(e.target.value),children:[(0,I.jsx)(`option`,{value:`all`,children:`All time`}),(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),e!==`all`&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Lifetime usage of tasks created in this period — not spending during the period.`}),a.isPending&&(0,I.jsx)(`p`,{children:`Loading usage…`}),a.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[c?`Showing stale usage. Could not refresh.`:`Could not load usage.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}),x&&(0,I.jsx)(`p`,{role:`status`,children:`Newer usage data is available; displayed values use the previous snapshot.`}),x&&(0,I.jsx)(w,{className:`min-h-11`,variant:`outline`,onClick:()=>s(l),children:`Updates available — Show`}),c&&S&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed usage:`}),(0,I.jsx)(G,{coverage:c.coverage,retry:()=>void a.refetch()})]}),l&&C&&T&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,I.jsx)(G,{coverage:l.coverage,retry:()=>void a.refetch()})]}),c&&(0,I.jsxs)(I.Fragment,{children:[!E&&(0,I.jsx)(`div`,{className:`report-cost-metrics grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:Q(v).map(e=>(0,I.jsx)(mn,{metric:e,label:gn[e],value:vn(c.totals[Z[e]]?.value,e),reported:c.totals[Z[e]]?.reportedTasks??0,total:c.totals.tasks},e))}),!v.cost&&!v.tokens&&(0,I.jsx)(`p`,{children:`Usage metrics are hidden by workspace settings`}),c.totals.tasks===0?(0,I.jsx)(`p`,{children:S||C?`No retained tasks could be read from available sources.`:`No retained tasks in this cohort.`}):Q(v).every(e=>!c.totals[Z[e]]?.reportedTasks)&&(0,I.jsx)(`p`,{children:`No reports for the visible metrics in this cohort.`}),E&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Usage appears when tasks report cost or tokens.`}),(0,I.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Deleted tasks are excluded from retained history.`,c.invalidDateTasks?` ${c.invalidDateTasks} tasks have missing or invalid creation dates${e===`all`?`; included in All time`:`; excluded from this period`}.`:``]}),!E&&(v.cost||v.tokens)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`font-medium`,children:`Top projects`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Ranking uses reported metrics only.`})]}),(0,I.jsx)(yn,{value:y,onChange:r,visibility:v})]}),(0,I.jsx)(hn,{projects:b,metric:y,label:gn[y],field:Z[y],format:e=>vn(e,y),currentProjects:l?.projects??[],onSelect:g}),(0,I.jsx)(w,{"data-usage-trigger":!0,className:`min-h-11`,variant:`outline`,onClick:()=>g(``),children:`View tasks`})]})]}),(0,I.jsx)(Oe,{open:u!==null&&(v.cost||v.tokens),onOpenChange:e=>{e||d(null)},children:(0,I.jsxs)(De,{...m,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),h.restore()},children:[(0,I.jsxs)(ke,{children:[(0,I.jsx)(Ae,{children:u?.projectId?`${u.projectId} tasks`:`All tasks`}),(0,I.jsx)(Ee,{children:`Lifetime usage of retained tasks. Missing reports are unavailable.`})]}),u!==null&&(0,I.jsx)(wn,{identity:`usage:${u.identity}`,snapshot:l&&l.snapshotId!==u.latestId?l:u.snapshot,projectId:u.projectId||void 0,visibility:v},u.identity)]})})]})}function wn({identity:e,snapshot:t,projectId:n,visibility:r}){let[i,a]=Y(`${e}:sort`,t.sort);return(0,I.jsx)(Tn,{identity:e,snapshot:t,projectId:n,visibility:r,sort:Q(r).includes(i)?i:Q(r)[0]??`cost`,setSort:a})}function Tn({identity:e,snapshot:t,projectId:n,visibility:r,sort:i,setSort:a}){let[o,s]=Y(`${e}:count`,20),[c,l]=Y(`${e}:paging`,void 0),[u,d]=(0,F.useState)(t.snapshotId);u!==t.snapshotId&&(d(t.snapshotId),l(void 0));let f=fn(c??t,n,i,o),p=cn()??r,m={cost:r.cost&&p.cost,tokens:r.tokens&&p.tokens},h=Q(m).includes(i)?i:Q(m)[0]??`cost`,[g,_]=Y(`${e}:accepted`,void 0),[v,y]=Y(`${e}:acceptedCount`,o),[b,x]=Y(`${e}:acceptedSort`,i),[S,C]=(0,F.useState)(i);S!==i&&(C(i),s(20),l(g??c??t)),f.data&&(!g||(v!==o||b!==i)&&g.snapshotId===f.data.snapshotId)&&(_(f.data),y(o),x(i));let T=g??f.data,E=f.data&&T&&_n(f.data,T),ee=T?.coverage.projects.some(e=>e.state!==`complete`),D=f.data?.coverage.projects.some(e=>e.state!==`complete`),te=JSON.stringify(T?.coverage)!==JSON.stringify(f.data?.coverage),ne=!n||t.projects.some(e=>e.projectId===n);return(0,I.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,"data-sheet-loading":f.isFetching,children:[(0,I.jsx)(yn,{value:h,onChange:a,visibility:m}),f.isPending&&(0,I.jsx)(`p`,{children:`Loading tasks…`}),f.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[`Could not refresh tasks. `,T?`Showing stale usage.`:``,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void f.refetch(),children:`Retry`})]}),E&&(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{_(f.data),y(o),x(i)},children:`Updates available — Show`}),T&&ee&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed tasks:`}),(0,I.jsx)(G,{coverage:T.coverage,retry:()=>void f.refetch()})]}),f.data&&D&&te&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,I.jsx)(G,{coverage:f.data.coverage,retry:()=>void f.refetch()})]}),T&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`border-b pb-2 font-mono text-[11px] text-soft-foreground`,children:[T.tasks.rows.length,` of `,T.tasks.total,` retained tasks`]}),T.tasks.total===0&&(0,I.jsx)(`p`,{children:T.coverage.projects.some(e=>e.state!==`complete`)?`No tasks could be read from available sources.`:`No retained tasks in this cohort.`}),T.tasks.rows.map(e=>(0,I.jsx)(En,{row:e,sort:h,visibility:m,disabled:!ne||!f.data||!!(E&&!f.data?.tasks.rows.some(t=>t.id===e.id&&t.projectId===e.projectId))},`${e.projectId}:${e.id}`)),T.tasks.nextOffset!==null&&(0,I.jsx)(w,{className:`min-h-11`,disabled:f.isFetching,onClick:()=>{l(T),s(e=>e+20)},children:`Show 20 more tasks`})]})]})}function En({row:e,sort:t,visibility:n,disabled:r}){let i=le(e);r||=i===null;let a=o(i?{status:i.status,awaitingAnswerSince:i.awaitingAnswerSince}:e),s=Q(n).filter(e=>e!==t),c=t=>{let n=e[Z[t]];return n==null?`—`:vn(n,t)},l=t=>`${gn[t]}: ${vn(e[Z[t]],t)}`;return(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 border-b py-3 last:border-0`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(N,{tone:a.tone,pulse:a.pulse,className:`mt-[7px]`}),(0,I.jsx)(D,{className:`line-clamp-2 break-words font-medium leading-snug hover:underline no-hover:min-h-11`,title:e.title,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,"aria-disabled":r||void 0,tabIndex:r?-1:void 0,onClick:e=>{r&&e.preventDefault()},children:e.title})]}),(0,I.jsxs)(`p`,{className:`mt-1 pl-[15px] font-mono text-[11px] text-soft-foreground`,children:[e.projectId,` · `,r?`Checking current state…`:i?.status??e.status,e.archived?` · Archived`:``,e.subtask?` · Subtask`:``]})]}),(0,I.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,I.jsx)(`span`,{"aria-label":l(t),className:`block font-semibold ${e[Z[t]]==null?`text-soft-foreground`:``}`,children:c(t)}),s.length>0&&(0,I.jsx)(`span`,{className:`mt-1 flex justify-end gap-3 font-mono text-[11px] text-soft-foreground`,children:s.map(e=>(0,I.jsxs)(`span`,{"aria-label":l(e),children:[c(e),` `,e===`cost`?``:e===`input`?`in`:`out`]},e))})]})]})}var Dn={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},On={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function kn(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}var An=(e,t)=>_t(e,t===`cost`);function jn(e){return new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Mn({series:e,height:t,accent:n,renderTooltip:r,describe:i}){let a=Math.max(1,...e.map(t));return(0,I.jsxs)(Re,{delayDuration:150,children:[(0,I.jsx)(`div`,{className:`flex h-20 items-end gap-0.5`,role:`group`,"aria-label":`Daily trend`,children:e.map(e=>{let o=t(e),s=Math.max(o>0?4:0,o/a*100);return(0,I.jsxs)(ze,{children:[(0,I.jsx)(Ie,{asChild:!0,children:(0,I.jsx)(`button`,{"data-export-keep":!0,"aria-label":i(e),type:`button`,className:`min-w-0 flex-1 rounded-t-sm transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,style:{height:`100%`,display:`flex`,alignItems:`end`},children:(0,I.jsx)(`span`,{style:{height:`${s}%`},className:`block w-full rounded-t-sm ${n}`})})}),(0,I.jsx)(Le,{children:r(e)})]},e.date)})}),(0,I.jsxs)(`div`,{className:`mt-1 flex justify-between text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:jn(e[0].date)}),(0,I.jsx)(`span`,{children:jn(e.at(-1).date)})]})]})}function Nn({metrics:e,series:t}){return(0,I.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`border-b`,children:[(0,I.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Date`}),e.map(e=>(0,I.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:On[e]},e)),(0,I.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:`Completed`}),(0,I.jsx)(`th`,{className:`py-1 text-right font-medium`,children:`Avg cycle`})]})}),(0,I.jsx)(`tbody`,{children:t.map(t=>(0,I.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,I.jsx)(`td`,{className:`py-1 pr-2`,children:jn(t.date)}),e.map(e=>(0,I.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:An(t[Dn[e]]?.value,e)},e)),(0,I.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:t.completed}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.avgCycleHours===null?`—`:K(t.avgCycleHours)})]},t.date))})]})}function Pn({metric:e,series:t}){let n=pn[e],r=Dn[e],i=t.reduce((e,t)=>e+(t[r]?.reportedTasks??0),0);return(0,I.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium ${n.text}`,children:On[e]}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(Mn,{series:t,describe:t=>`${t.date}, ${On[e]}: ${An(t[r]?.value,e)}, ${t[r]?.reportedTasks??0} of ${t.tasks} tasks reported`,height:e=>e[r]?.value??0,accent:n.fill,renderTooltip:t=>(0,I.jsxs)(`p`,{children:[jn(t.date),` · `,An(t[r]?.value,e),` ·`,` `,t[r]?.reportedTasks??0,`/`,t.tasks,` tasks reported`]})})}),i===0&&(0,I.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No reports in this period.`})]})}function Fn({series:e}){let t=e.reduce((e,t)=>e+t.completed,0),n=e.reduce((e,t)=>e+(t.avgCycleHours??0)*(t.cycleReportedTasks??t.completed),0),r=e.reduce((e,t)=>e+(t.cycleReportedTasks??t.completed),0),i=r?n/r:null;return(0,I.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-success`,children:`Completed tasks`}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` done · avg cycle`,` `,i===null?`unavailable`:K(i)]})]}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r,`/`,t,` completed tasks have valid cycle times.`]}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(Mn,{series:e,describe:e=>`${e.date}: ${e.completed} completed tasks, average cycle ${e.avgCycleHours==null?`Unavailable`:K(e.avgCycleHours)}`,height:e=>e.completed,accent:`bg-success`,renderTooltip:e=>(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`p`,{children:[jn(e.date),` · `,e.completed,` completed`]}),(0,I.jsxs)(`p`,{children:[`Avg cycle`,` `,e.avgCycleHours===null?`unavailable`:K(e.avgCycleHours),` · Median`,` `,e.medianCycleHours===null?`unavailable`:K(e.medianCycleHours)]})]})})}),t===0&&(0,I.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No tasks finished in this period.`})]})}function In(){return(0,I.jsx)(Ln,{visibility:He(h().data)})}function Ln({visibility:e}){let[t,n]=vt(`trendPeriod`,[`7d`,`30d`],`7d`),r=dn(t,e.cost?`cost`:`input`,`${e.cost}:${e.tokens}`),i=r.data,a=i&&i.totals.tasks===0&&i.coverage.projects.every(e=>e.state===`complete`)&&i.series.every(e=>e.tasks===0&&e.completed===0),o=kn({cost:e.cost&&i?.visibility.cost!==!1,tokens:e.tokens&&i?.visibility.tokens!==!1});return(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Trends`}),(0,I.jsxs)(`label`,{className:et,children:[`Period`,(0,I.jsxs)(tt,{value:t,onChange:e=>n(e.target.value),children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[i&&(0,I.jsx)(L,{rows:a?[]:i.series.flatMap(e=>[...o.map(t=>({section:`daily-creation-cohort`,entity:e.date,metric:Dn[t],value:e[Dn[t]]?.value??null,unit:t===`cost`?`USD`:`tokens`,reportedTasks:e[Dn[t]]?.reportedTasks??0,totalTasks:e.tasks,asOf:i.asOf,note:`Lifetime usage grouped by task creation date; not daily spend`})),{section:`daily-completions`,entity:e.date,metric:`completed`,value:e.completed,unit:`tasks`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`avgCycleHours`,value:e.avgCycleHours,reportedTasks:e.cycleReportedTasks??e.completed,totalTasks:e.completed,unit:`hours`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`medianCycleHours`,value:e.medianCycleHours,unit:`hours`,asOf:i.asOf}])}),(0,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${$e} py-2`,children:[(0,I.jsx)(B,{}),`How these metrics work`]}),(0,I.jsx)(`p`,{children:`Usage is grouped by creation date, not spending date. Completed tasks are grouped by finish date. Calendar days use your current UTC offset (fixed across the period), including today.`})]}),r.isPending&&(0,I.jsx)(`p`,{children:`Loading trends…`}),r.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[i?`Showing stale trends. Could not refresh.`:`Could not load trends.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry`})]}),i&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:i.asOf})}),i&&(0,I.jsx)(G,{coverage:i.coverage,retry:()=>void r.refetch()}),i&&a&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`No retained tasks in this period yet.`}),i&&!a&&i.series.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`space-y-4`,children:[o.length>0&&(0,I.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))]`,children:o.map(e=>(0,I.jsx)(Pn,{metric:e,series:i.series},e))}),(0,I.jsx)(Fn,{series:i.series})]}),(0,I.jsxs)(`details`,{className:`group rounded-lg border bg-muted/20 print:block`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Daily data`,className:`flex min-h-11 cursor-pointer list-none items-center gap-2 px-3 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:[(0,I.jsx)(Ye,{className:`size-4`,"aria-hidden":`true`}),` View data table`,(0,I.jsx)(Fe,{className:`ml-auto size-4 transition-transform group-open:rotate-180`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`max-h-80 overflow-auto border-t p-3 print:max-h-none print:overflow-visible`,role:`region`,"aria-label":`Daily trend values`,tabIndex:0,children:(0,I.jsx)(Nn,{metrics:o,series:i.series})})]})]})]})]})}function Rn(e,t,n,r=!0){let i=c();return d({queryKey:[...X.snapshot,e?.snapshotId,t,n],enabled:r&&!!e,retry:!1,queryFn:async({signal:r})=>{if(!e)throw Error(`Dashboard not loaded`);let a=[];try{for(let i=0;i<n;){let o=await Zt(e.snapshotId,t,i,Math.min(20,n-i),r);if(a.push(...o.page.rows),o.page.nextOffset===null)break;i=o.page.nextOffset}return a}catch(e){if(e instanceof u&&e.status===409){let e=await Xt(r);i.setQueryData(X.snapshot,e)}throw e}}})}function zn(e,t,n,r){let i=c(),a=t===`questions`||t===`reviews`?`needs-you`:t,o=a===`needs-you`?0:n,s=r.map(e=>`${e.projectId}:${e.id}`).sort();return d({queryKey:[...X.snapshot,e.snapshotId,t,`displaced`,...s],enabled:s.length>0,retry:!1,queryFn:async({signal:t})=>{let n=new Set(s),r=new Map;try{for(let i=o;i!==null&&n.size;){let o=await Zt(e.snapshotId,a,i,20,t);for(let e of o.page.rows){let t=`${e.projectId}:${e.id}`;n.delete(t)&&r.set(t,e)}i=o.page.nextOffset}return r}catch(e){throw e instanceof u&&e.status===409&&i.setQueryData(X.snapshot,await Xt(t)),e}}})}function Bn({snapshot:e,questions:t,reviews:n,more:r,healthy:i=!0}){let a=ye();return(0,I.jsxs)(M,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsxs)(`h2`,{id:`dashboard-needs-you`,tabIndex:-1,className:R,children:[`Needs you · `,e.counts.questions+e.counts.reviews]}),(0,I.jsxs)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,children:[e.counts.questions,` questions · `,e.counts.reviews,` reviews`]})]}),i&&a.connected&&e.counts.questions+e.counts.reviews===0&&e.coverage.projects.every(e=>e.state===`complete`)?(0,I.jsxs)(`p`,{className:`flex items-center gap-2.5 px-4 py-8 text-sm text-muted-foreground`,children:[(0,I.jsx)(N,{tone:`success`}),`All caught up — no tasks need your input`]}):null,(0,I.jsx)(Vn,{snapshot:e,group:`questions`,count:t,more:r}),(0,I.jsx)(Vn,{snapshot:e,group:`reviews`,count:n,more:r})]})}function Vn({snapshot:e,group:t,count:n,more:r}){let i=e[t],a=Math.max(n,i.rows.length),o=Rn(e,t,a,a>i.rows.length),s=a>i.rows.length?o.data:i.rows,c=ut(s,W,t,n),l=zn(e,t,a,c.rows.filter(e=>e.removed).map(e=>e.row)),u=(0,F.useRef)(null);return!i.total&&!c.rows.length?null:(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`h3`,{ref:u,tabIndex:-1,className:`border-b bg-card-2 px-4 py-2 font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[t===`questions`?`Questions`:`Reviews`,` · `,i.total]}),c.updates>0&&(0,I.jsxs)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>{c.show(),u.current?.focus()},children:[c.updates,` updates — Show`]}),c.rows.map(({row:e,removed:t})=>(0,I.jsx)(gt,{row:l.data?.get(W(e))??e,removed:t&&!!l.data&&!l.data.has(W(e)),checking:s===void 0||t&&!l.data,checkFailed:s===void 0&&o.isError||t&&!l.data&&l.isError,queue:!0},W(e))),(o.isError||l.isError)&&(0,I.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not check current task state.`,` `,(0,I.jsx)(w,{variant:`ghost`,className:`min-h-11`,onClick:()=>{o.refetch(),l.refetch()},children:`Retry`})]}),a<i.total&&(0,I.jsxs)(w,{variant:`ghost`,className:`m-2 min-h-11`,disabled:o.isFetching,onClick:()=>r(t,a+Math.min(20,i.total-a)),children:[`Show `,Math.min(20,i.total-a),` more `,t]})]})}function Hn(e){if(!e.startsWith(`github:`))return e===`tasks`?`Task results`:e;let t=e.slice(7).split(`:`),n=t.pop()===`pr`?`Pull requests`:`Issues`;return`${t.join(`:`).replace(/^project:/,`Project `).replace(/^github.com\//,``)} · ${n}`}var Un=e=>e.key;function Wn({filter:e,setFilter:t,count:n,more:r}){let i=tn(e,!0),a=ut(i.data?.rows,Un,`feed:${e}`,0,e=>e.kind===`task-result`),o=a.rows,s=a.updates,c=(0,F.useContext)(ct),l=(0,F.useRef)(null),u=`feed:${e}`,d=(0,F.useMemo)(()=>({scroll:mt(c,u)?.scroll??0,done:!1}),[c,u]);(0,F.useLayoutEffect)(()=>{!l.current||d.done||(l.current.scrollTop=d.scroll,d.done=Math.abs(l.current.scrollTop-d.scroll)<1||!!i.data&&!i.isPending&&!i.isFetching)},[d,o.length,n,i.data,i.isPending,i.isFetching]);let f=(0,F.useRef)(null),p=i.data?.sources.filter(e=>e.key.startsWith(`github:`))??[],m=p.flatMap(e=>e.fetchedAt?[e.fetchedAt]:[]).sort()[0],h=i.githubError,g=p.filter(e=>e.reason===`No GitHub remote`),_=p.some(e=>e.reason===`Still loading GitHub`),v=p.length>0&&g.length===p.length&&!h,y=p.filter(e=>e.state!==`ready`&&e.reason!==`No GitHub remote`&&e.reason!==`Still loading GitHub`),b=v&&e===`all`;return(0,I.jsxs)(M,{"data-export-context":`Results source: ${e}; Last 7 days; loaded ${Math.min(n,o.length)} rows`,className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2 border-b px-4 pt-2.5 pb-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-2`,children:[(0,I.jsx)(`h2`,{ref:f,tabIndex:-1,className:R,children:b?`Recent results`:`Recent results & GitHub`}),(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:`Last 7 days`})]}),!b&&(0,I.jsx)(pe,{slot:`dashboard-feed`,label:`Results source`,value:e,options:[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`github`,label:`GitHub`}],onChange:t}),b&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Task results · No GitHub repositories configured`}),e!==`tasks`&&!b&&(0,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,open:y.length||h?!0:void 0,children:[(0,I.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-1.5`,children:[(0,I.jsx)(B,{}),y.length||h?`GitHub needs attention`:_?`Checking GitHub…`:v?`GitHub not configured`:m?`GitHub checked ${P(m)} ago`:`GitHub source`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3`,children:[(0,I.jsx)(`p`,{children:y.length||h?m?`Could not refresh GitHub. Showing results from ${new Date(m).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}.`:`Could not load one or more GitHub sources.`:_?`Checking repository sources. Available results remain visible.`:v?`No GitHub repositories configured. Select Tasks to see task results.`:m?`GitHub checked ${P(m)} ago`:`GitHub snapshot`}),!v&&(0,I.jsx)(w,{variant:`ghost`,className:`min-h-11 px-0`,disabled:i.githubFetching,onClick:()=>{i.refetch()},children:i.githubFetching?`Refreshing…`:y.length||h?`Retry GitHub`:`Refresh GitHub`})]})]})]}),(0,I.jsxs)(`div`,{role:`region`,"aria-label":`Recent results list`,ref:l,onWheel:()=>{d.done=!0},onTouchStart:()=>{d.done=!0},onKeyDown:()=>{d.done=!0},onScroll:e=>{c&&d.done&&ht(c,u,{count:n,scroll:e.currentTarget.scrollTop})},tabIndex:0,className:`max-h-80 overflow-y-auto overscroll-contain focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[i.isError&&(0,I.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not load results.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{i.retryFailed()},children:`Retry`})]}),i.isPending&&(0,I.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading results…`}),s>0&&(0,I.jsxs)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>{a.show(),f.current?.focus()},children:[s,` updates — Show`]}),o.slice(0,n).map(({row:e,removed:t})=>e.kind===`task-result`?(0,I.jsx)(gt,{row:e.run,kicker:t?`Outside current results`:`Latest result: ${e.run.status===`failed`?`Failed`:`Completed`}`},e.key):(0,I.jsxs)(`div`,{className:`border-b px-4 py-3 transition-colors hover:bg-muted/30`,children:[(0,I.jsx)(L,{rows:[{section:`github`,entity:`${e.repo}#${e.number}`,metric:e.itemKind,value:e.title,asOf:e.at,note:e.url}]}),(0,I.jsx)(`a`,{className:`block break-words text-sm font-medium hover:underline no-hover:min-h-11`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.title}),(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.repo,` · `,e.itemKind===`pr`?`PR`:`Issue`,` #`,e.number,` created ·`,` `,P(e.at)]})]},e.key)),i.data&&!i.data.rows.length&&!o.length&&!i.isFetching&&!i.isError&&!y.length&&!_&&i.data.coverage.projects.every(e=>e.state===`complete`)&&(0,I.jsx)(`p`,{className:`px-4 py-8 text-sm text-muted-foreground`,children:`No results in the last 7 days`}),n<o.length&&(0,I.jsxs)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:r,children:[`Show `,Math.min(20,o.length-n),` more results`]}),i.data?.truncated&&(0,I.jsx)(`p`,{className:`p-4 text-xs`,children:`Showing the latest 60 results`}),i.data&&(0,I.jsx)(G,{coverage:i.data.coverage,retry:()=>{i.retryTasks()}}),!b&&i.data?.sources.some(e=>e.state!==`ready`||e.truncated)&&(0,I.jsxs)(`details`,{className:`p-4 text-xs`,children:[(0,I.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden min-h-11`,children:[(0,I.jsx)(B,{}),`Source details`]}),i.data.sources.map(e=>(0,I.jsxs)(`p`,{className:`break-words py-1`,children:[Hn(e.key),`:`,` `,e.reason===`No GitHub remote`?`Not configured`:e.reason===`Still loading GitHub`?`Checking…`:e.reason??(e.state===`ready`?`Up to date`:e.state),e.truncated?` · capped`:``,e.fetchedAt?` · checked ${P(e.fetchedAt)}`:``]},e.key))]})]})]})}var $=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),Gn=`Visible modules and loaded rows only. Filters and report availability apply. Retained task usage is not an invoice or a complete history.`,Kn=`Confidential — internal distribution only`,qn={costUsd:{label:`Reported cost`,usd:!0},inputTokens:{label:`Input tokens`},outputTokens:{label:`Output tokens`},needsYou:{label:`Needs you`},running:{label:`Running now`},completed:{label:`Completed in period`},failed:{label:`Failed outcomes in period`},medianCycleHours:{label:`Median cycle (hours)`}};function Jn(e,t){return e==null?`Unavailable`:typeof e==`string`?e:_t(e,t)}function Yn(e){let t=new Set,n=[];for(let r of e.modules)for(let e of r.rows){if(e.section!==`totals`&&e.section!==`fleet`&&e.section!==`overview`)continue;let i=qn[e.metric];!i||t.has(e.metric)||(t.add(e.metric),n.push({label:i.label,value:Jn(e.value,i.usd),note:[e.metric===`needsYou`||e.metric===`running`?e.note||`Current non-archived state`:r.filters,e.asOf?`Data as of ${e.asOf}`:``,e.reportedTasks==null?``:`${e.reportedTasks} of ${e.totalTasks} tasks reported`].filter(Boolean).join(` · `)}))}return n}function Xn(e){let t=e.cloneNode(!0);t.querySelectorAll(`script,style,link,img,iframe,object,embed,input,[hidden],[data-dashboard-export],[data-export-exclude]`).forEach(e=>e.remove()),t.querySelectorAll(`select`).forEach((t,n)=>{let r=e.querySelectorAll(`select`)[n];t.replaceWith(document.createTextNode(`: `+(r?.selectedOptions[0]?.textContent??``)))}),t.querySelectorAll(`[data-export-row],[data-dashboard-row]`).forEach(e=>e.classList.add(`report-row`)),t.querySelectorAll(`summary`).forEach(e=>{let t=document.createElement(`h3`);t.textContent=e.getAttribute(`data-export-heading`)||e.textContent,e.replaceWith(t)}),t.querySelectorAll(`button`).forEach(e=>{if(e.hasAttribute(`data-export-keep`)){let t=document.createElement(`div`);for(let n of[...e.attributes])[`class`,`style`,`title`].includes(n.name)&&t.setAttribute(n.name,n.value);t.append(...e.childNodes),e.replaceWith(t)}else e.remove()}),t.querySelectorAll(`details`).forEach(e=>{let t=document.createElement(`div`);t.className=e.className,t.append(...e.childNodes),e.replaceWith(t)});for(let e of[t,...t.querySelectorAll(`*`)])for(let t of[...e.attributes])(t.name.startsWith(`on`)||[`href`,`src`,`srcset`,`action`,`formaction`,`tabindex`].includes(t.name)||t.name.startsWith(`data-`))&&e.removeAttribute(t.name);return t.removeAttribute(`style`),t.innerHTML}function Zn(e,t,n,r){return{generatedAt:t,source:n,title:r||void 0,notices:[...e.querySelectorAll(`[role=alert],[role=status]`)].filter(e=>!e.closest(`[data-dashboard-module]`)).map(e=>e.textContent?.trim()??``).filter(Boolean),modules:[...e.querySelectorAll(`[data-dashboard-module]`)].map(e=>{let t=[...e.querySelectorAll(`select`)].map(e=>`${e.closest(`label`)?.childNodes[0]?.textContent?.trim()??`Filter`}: ${e.selectedOptions[0]?.textContent}`).concat([...e.querySelectorAll(`[data-export-context]`)].map(e=>e.dataset.exportContext)).join(`; `),n=[...new Set([...e.querySelectorAll(`p,[role="alert"],[role="status"]`)].filter(e=>!e.closest(`table,[data-export-exclude]`)&&!e.querySelector(`p,[role="alert"],[role="status"]`)).map(e=>{let t=e.cloneNode(!0);return t.querySelectorAll(`table,button,select,summary,[data-export-exclude]`).forEach(e=>e.remove()),t.textContent?.trim()}).filter(Boolean))].join(` | `);return{id:e.dataset.dashboardModule,title:e.querySelector(`h2`)?.textContent??e.dataset.dashboardModule,filters:t,notes:n,html:Xn(e),rows:[...e.querySelectorAll(`[data-dashboard-export]`)].flatMap(e=>JSON.parse(e.dataset.dashboardExport))}})}}function Qn(e){let t=e==null?``:String(e);return typeof e==`string`&&/^[\s\uFEFF]*[=+@\-]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function $n(e){let t=[[`generated_at`,`source`,`module`,`filters`,`section`,`entity`,`metric`,`value`,`unit`,`availability`,`reported_tasks`,`total_tasks`,`as_of`,`notes`]];for(let n of e.modules){t.push([e.generatedAt,e.source,n.title,n.filters,`context`,``,`scope`,Gn,``,``,``,``,``,[...e.title?[`Report title: ${e.title}`]:[],...e.notices,n.notes].join(` | `)]);for(let r of n.rows)t.push([e.generatedAt,e.source,n.title,n.filters,r.section,r.entity,r.metric,r.value,r.unit,r.value===null?`unavailable`:typeof r.value==`number`?`measured`:`reported`,r.reportedTasks,r.totalTasks,r.asOf,r.note])}return``+t.map(e=>e.map(Qn).join(`,`)).join(`\r
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{$r as r,Ci as i,G as a,Ln as o,Qt as s,Sa as c,Xt as l,Yn as u,ba as d,ea as f,gn as p,ir as m,j as h,zn as g}from"./queries-CI0EmEcH.js";import{$ as _,F as v,Q as y,Z as b,et as x,it as S,nt as C,t as w,tt as T,vt as E}from"./button-Clwd6u4_.js";import{T as ee,m as D,x as te}from"./project-router-DZsR9P9C.js";import{S as ne,a as re,o as ie,r as ae,t as oe}from"./reference-chip-DnemrSPW.js";import{A as O,C as se,E as k,M as A,N as j,O as ce,P as le,T as ue,_ as de,b as fe,c as pe,d as me,f as he,g as ge,h as _e,i as ve,j as ye,m as be,p as xe,v as Se,w as Ce,x as we,y as Te}from"./use-automations-v77gHYDG.js";import{a as Ee,i as De,n as Oe,o as ke,s as Ae,t as je}from"./use-now-pBdvhv13.js";import{a as Me,f as M,p as Ne,r as Pe}from"./automation-format-BL4n19a2.js";import{f as Fe,i as Ie,n as Le,r as Re,t as ze}from"./tooltip-B628Gs7C.js";import{t as Be}from"./chevron-right-VbYrJ_st.js";import{t as Ve}from"./download-DOJ8Dqfh.js";import{i as N,r as P,t as He}from"./token-metrics-Dk2ZNHb_.js";import{t as Ue}from"./index-Cse8uyXO.js";var We=v(`activity`,[[`path`,{d:`M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2`,key:`169zse`}]]),Ge=v(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),Ke=v(`circle-alert`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`line`,{x1:`12`,x2:`12`,y1:`8`,y2:`12`,key:`1pkeuh`}],[`line`,{x1:`12`,x2:`12.01`,y1:`16`,y2:`16`,key:`4dfq90`}]]),qe=v(`circle-question-mark`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3`,key:`1u773s`}],[`path`,{d:`M12 17h.01`,key:`p32p05`}]]),Je=v(`grip-horizontal`,[[`circle`,{cx:`12`,cy:`9`,r:`1`,key:`124mty`}],[`circle`,{cx:`19`,cy:`9`,r:`1`,key:`1ruzo2`}],[`circle`,{cx:`5`,cy:`9`,r:`1`,key:`1a8b28`}],[`circle`,{cx:`12`,cy:`15`,r:`1`,key:`1e56xg`}],[`circle`,{cx:`19`,cy:`15`,r:`1`,key:`1a92ep`}],[`circle`,{cx:`5`,cy:`15`,r:`1`,key:`5r1jwy`}]]),Ye=v(`table-2`,[[`path`,{d:`M9 3H5a2 2 0 0 0-2 2v4m6-6h10a2 2 0 0 1 2 2v4M9 3v18m0 0h10a2 2 0 0 0 2-2V9M9 21H5a2 2 0 0 1-2-2V9m0 0h18`,key:`gugj83`}]]),F=e(t(),1);function Xe(e){let t=Date.parse(e.nextRunAt??``),n=Date.parse(e.state?.backoffUntil??``);return Number.isFinite(t)?Math.max(t,Number.isFinite(n)?n:t):null}function Ze(e){return e.flatMap(e=>(e.data?.automations??[]).filter(e=>e.enabled).map(t=>({project:e,automation:t,at:Xe(t)}))).sort((e,t)=>(e.at??1/0)-(t.at??1/0)||e.project.id.localeCompare(t.project.id)||e.automation.id.localeCompare(t.automation.id))}function Qe(e){let t=a(),n=c(),r=t.data?.projects??[],i=t.data?.bootProject,o=i&&!r.some(e=>e.id===i)?[...r,{id:i,name:i,status:`ok`}]:r,l=d({queryKey:[...s.dashboard,`automations`,o.map(e=>[e.id,e.name,e.status])],enabled:e&&!!t.data,queryFn:async({signal:e})=>{let t=0,n=[];return await Promise.all([0,1].map(async()=>{for(;t<o.length&&!e.aborted;){let r=o[t++];if(r.status===`missing`){n.push({...r,error:`Project folder unavailable`});continue}try{let t=S.parse(await f(await m.api.v1.workspace.dashboard.automations.$get({query:{projectId:r.id}},{init:{signal:e}}),`/workspace/dashboard/automations`));n.push({id:r.id,name:r.name,data:t})}catch{n.push({id:r.id,name:r.name,error:`Could not load automations`})}}})),n}});return(0,F.useEffect)(()=>{if(e)return ce(e=>{e===`automation-change`&&n.invalidateQueries({queryKey:[...s.dashboard,`automations`]})})},[n,e]),{...l,registry:t,retry:()=>{t.refetch(),l.refetch()}}}var I=n();function L({rows:e}){return(0,I.jsx)(`span`,{hidden:!0,"data-dashboard-export":JSON.stringify(e)})}var R=`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,z=`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,$e=`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden`;function B(){return(0,I.jsx)(Be,{"aria-hidden":`true`,className:`size-3.5 shrink-0 text-soft-foreground transition-transform duration-150 motion-reduce:transition-none [details[open]>summary>&]:rotate-90`})}var et=`flex items-center gap-2 text-xs text-muted-foreground`;function tt({className:e=``,...t}){return(0,I.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,I.jsx)(`select`,{...t,className:`h-9 cursor-pointer appearance-none rounded-md border bg-card-2 pr-8 pl-3 font-mono text-xs text-foreground outline-none transition-colors hover:border-foreground/20 hover:bg-muted focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 no-hover:min-h-11 ${e}`}),(0,I.jsx)(Fe,{"aria-hidden":`true`,className:`pointer-events-none absolute top-1/2 right-2.5 size-3.5 -translate-y-1/2 text-soft-foreground`})]})}var nt=`relative min-w-0 overflow-hidden rounded-lg border bg-card-2 p-4 transition-colors before:absolute before:inset-x-0 before:top-0 before:h-px before:opacity-80 hover:border-foreground/20 hover:bg-muted/40 sm:p-5`,V={violet:`before:bg-violet`,info:`before:bg-info`,success:`before:bg-success`,danger:`before:bg-danger`,primary:`before:bg-primary`,neutral:`before:bg-border`};function rt({label:e,value:t,icon:n,children:r}){return(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[11px] font-medium uppercase tracking-[0.12em] text-muted-foreground`,children:e}),(0,I.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:n})]}),(0,I.jsx)(`span`,{className:`mt-4 block text-4xl font-semibold leading-none tracking-tight tabular-nums`,children:t}),(0,I.jsx)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:r})]})}function it({at:e}){return(0,I.jsxs)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:[`Updated `,P(e),` ago`]})}function at(){let e=ve(),t=Qe(e.known&&!e.off),n=je(3e4),[r,i]=(0,F.useState)(!1),a=Ze(t.data??[]),o=r?a:a.slice(0,3),s=t.data?.filter(e=>e.error)??[],c=!e.known||!t.registry.isError&&(t.registry.isPending||t.isPending),l=t.isError||t.registry.isError||s.length>0;return(0,I.jsxs)(M,{"data-export-context":`Enabled automations · showing ${o.length} of ${a.length} loaded · ${l?`partial coverage`:`available projects`}`,className:`min-w-0 gap-0 py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsxs)(`h2`,{className:`flex items-center ${R}`,children:[`Automations`,(0,I.jsx)(Ne,{className:`ml-2 size-3.5 text-soft-foreground`,"aria-hidden":`true`})]}),!e.off&&t.data&&(0,I.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[a.length,` enabled`,l?` · partial`:``]})]}),!e.off&&t.data&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(L,{rows:[{section:`automations`,metric:`enabled`,value:a.length,unit:`automations`,note:l?`Partial project coverage`:`Loaded projects`}]}),t.dataUpdatedAt>0&&(0,I.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:new Date(t.dataUpdatedAt).toISOString()})})]}),e.off?(0,I.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,I.jsxs)(I.Fragment,{children:[c&&(0,I.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading automations…`}),l&&(0,I.jsxs)(`div`,{role:`alert`,className:`p-4 text-sm`,children:[(0,I.jsx)(`p`,{children:`Some automation data could not be refreshed. Available results are shown.`}),s.map(e=>(0,I.jsxs)(`p`,{children:[e.name,`: `,e.error]},e.id)),(0,I.jsx)(w,{variant:`ghost`,onClick:t.retry,children:`Retry automations`})]}),!c&&!l&&a.length===0&&(0,I.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`No enabled automations. Enable one in a project's Automations page.`}),o.map(({project:e,automation:t,at:r})=>{let i=(t.state?.consecutiveFailures??0)>0?`Recent checks failed`:void 0,a=r===null?`Next time not available`:r<=n?`Due — awaiting scheduler`:Me(r,n),o=t.kind===`schedule`?`Next run`:`Next check`;return(0,I.jsxs)(`div`,{"data-export-row":!0,className:`border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,I.jsx)(D,{className:`block min-h-11 text-sm font-medium hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations/${encodeURIComponent(t.id)}`,children:t.name}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.name,` · `,o,`: `,a]}),r!==null&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:(0,I.jsxs)(`time`,{dateTime:new Date(r).toISOString(),children:[Pe(r,e.data.timeZone),` · `,e.data.timeZone]})}),t.kind!==`schedule`&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Checks for matching events; a task may not be started.`}),i&&(0,I.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:i}),(0,I.jsx)(L,{rows:[{section:`automation`,entity:`${e.id}:${t.id}`,metric:`name`,value:t.name},{section:`automation`,entity:`${e.id}:${t.id}`,metric:t.kind===`schedule`?`nextRunAt`:`nextCheckAt`,value:r===null?null:new Date(r).toISOString(),note:[a,i].filter(Boolean).join(` · `)}]})]},`${e.id}:${t.id}`)}),a.length>3&&(0,I.jsx)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>i(!r),children:r?`Show fewer`:`Show all ${a.length} enabled`}),!c&&(0,I.jsxs)(`details`,{className:`border-t px-4 py-2 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden min-h-11`,"data-export-heading":`Project automations`,children:[(0,I.jsx)(B,{}),`Manage automations by project`]}),t.data?.map(e=>(0,I.jsx)(D,{className:`block min-h-11 py-3 hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations`,children:e.name},e.id))]})]})]})}function ot(e,t,n){let r=new Set,i=new Map(e.map((e,t)=>[n(e),{r:e,i:t}]));return t.forEach((e,t)=>{let a=i.get(n(e));(!a||a.i!==t||JSON.stringify(a.r)!==JSON.stringify(e))&&r.add(n(e)),i.delete(n(e))}),i.forEach((e,t)=>r.add(t)),r}function st(e,t,n){let r=new Map(t.map(e=>[n(e),e]));return e.map(e=>({row:r.get(n(e))??e,removed:!r.has(n(e))}))}var ct=(0,F.createContext)(``),lt=(0,F.createContext)(!0),H=new Map;function ut(e,t,n=``,r=0,i){let a=(0,F.useContext)(ct),o=`${a}:${n}`,[s,c]=(0,F.useState)(()=>H.get(o)),[l,u]=(0,F.useState)(o),d=(0,F.useRef)(r),f=(0,F.useRef)(!1);l!==o&&(u(o),c(H.get(o)),d.current=r,f.current=!1),d.current!==r&&(d.current=r,f.current=!0),(0,F.useEffect)(()=>{e&&(!s||f.current)&&(c(e),f.current=!1)},[s,e]);let p=(0,F.useMemo)(()=>({current:s}),[o]);p.current=s,(0,F.useEffect)(()=>()=>{!a||!p.current||(H.delete(o),H.set(o,p.current),H.size>60&&H.delete(H.keys().next().value))},[a,o,p]);let m=s??e??[],h=new Set((e??m).map(t)),g=i?m.filter(e=>h.has(t(e))||i(e)):m;return{rows:st(g,e??m,t),updates:e?ot(g,e,t).size:0,show:()=>c(e)}}var dt=new Map;function ft(e){return dt.get(e)}function pt(e,t){dt.delete(e),dt.set(e,t),dt.size>20&&dt.delete(dt.keys().next().value)}var U=new Map;function mt(e,t){return U.get(e)?.[t]}function ht(e,t,n){let r=U.get(e)??{};r[t]=n,U.delete(e),U.set(e,r),U.size>20&&U.delete(U.keys().next().value)}var W=e=>`${e.projectId}:${e.id}`;function gt({row:e,removed:t=!1,queue:n=!1,checking:r=!1,checkFailed:i=!1,kicker:a}){let s=(0,F.useContext)(lt)&&!r&&!i,c=le(e);t=t||c===null||n&&c?.archived===!0,c&&(e={...e,status:c.status,awaitingAnswerSince:c.awaitingAnswerSince});let l=o(e),u=n&&!g(e),d=t||u||!s;return(0,I.jsxs)(`div`,{"data-dashboard-row":W(e),className:`min-w-0 border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,I.jsx)(L,{rows:[{section:`task`,entity:W(e),metric:`title`,value:e.titleSummary||e.title},{section:`task`,entity:W(e),metric:`status`,value:d?`Not currently actionable`:e.status},{section:`task`,entity:W(e),metric:`createdAt`,value:e.createdAt}]}),a&&(0,I.jsx)(`p`,{className:`mb-1 pl-[15px] font-mono text-[10.5px] uppercase tracking-[0.1em] text-soft-foreground`,children:a}),(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(N,{tone:l.tone,className:`mt-[7px]`}),(0,I.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,I.jsx)(D,{tabIndex:d?-1:void 0,"aria-disabled":d||void 0,onClick:e=>{d&&e.preventDefault()},to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,className:`block break-words text-sm font-medium leading-relaxed hover:underline no-hover:min-h-11`,children:e.titleSummary||e.title}),(0,I.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:e.projectId}),(0,I.jsx)(`span`,{children:i?`Could not check current state`:s?t?n&&c!==null?`No longer needs you`:`Task removed`:u?`No longer needs you`:l.label:`Checking current state…`}),(0,I.jsx)(`span`,{children:P(e.createdAt)}),e.dispatch&&(0,I.jsx)(`span`,{children:`Subtask`}),!d&&p(e).map(t=>(0,I.jsx)(oe,{reference:t,taskTitle:e.title,projectId:e.projectId,className:`no-hover:min-h-11`},`${t.kind}:${t.number}`))]})]})]})]})}function G({coverage:e,count:t,retry:n}){let r=e.projects.filter(e=>e.state!==`complete`);return r.length?(0,I.jsxs)(`div`,{className:`rounded-lg border border-pending/40 bg-card-2 p-3 text-sm`,role:`status`,children:[(0,I.jsxs)(`p`,{children:[t===void 0?``:`${t} tasks need you in the available data. Complete coverage: ${e.projects.length-r.length} of ${e.projects.length} projects. `,r.length===1?r[0].state===`unavailable`?`One project is unavailable.`:`One project has incomplete coverage.`:`${r.length} projects have incomplete coverage.`]}),(0,I.jsxs)(`details`,{className:`mt-2`,children:[(0,I.jsxs)(`summary`,{className:`${$e} min-h-11`,children:[(0,I.jsx)(B,{}),`View unavailable `,r.length===1?`project`:`projects`]}),r.map(e=>(0,I.jsxs)(`p`,{children:[e.projectId,`: `,e.reason??e.state,e.omittedRuns>0?` · ${e.omittedRuns} omitted tasks`:``]},e.projectId))]}),(0,I.jsx)(w,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Retry`})]}):null}function _t(e,t=!1){return e==null?`Unavailable`:t?`$${e.toFixed(e===0||e>=1?2:Math.min(20,Math.max(4,Math.ceil(-Math.log10(e))+1)))}`:e.toLocaleString(`en-US`)}function K(e){return e===null?`Unavailable`:e<1?`${Math.round(e*60)}m`:e<48?`${e.toFixed(1)}h`:`${(e/24).toFixed(1)}d`}function vt(e,t,n){let r=te(),i=r.state?.dashboardEntry??r.key,[a,o]=ee(),s=a.get(e);return[s!==null&&t.includes(s)?s:n,t=>o(n=>{let r=new URLSearchParams(n);return r.set(e,t),r},{replace:!0,state:{...r.state,dashboardEntry:i}})]}var yt=e=>`Last ${e===`7d`?7:30} calendar days`,bt=`font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,xt=`min-w-0 rounded-lg border bg-card-2 p-4`,q=`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground`;function St(){let e=a().data?.projects;return t=>e?.find(e=>e.id===t)?.name??t}var Ct=(e,t)=>`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`;function wt({label:e,value:t,onChange:n}){return(0,I.jsxs)(`label`,{className:et,children:[e,(0,I.jsxs)(tt,{value:t,onChange:e=>n(e.target.value===`30d`?`30d`:`7d`),children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})}function Tt({query:e}){return e.isPending?(0,I.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading insights…`}):e.isError?(0,I.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[e.data?`Showing previous results. `:``,`Could not refresh insights.`,` `,(0,I.jsx)(w,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry insights`})]}):null}function Et({period:e,active:t}){let n=Ue(e,t),r=n.data;return(0,I.jsxs)(`div`,{className:`space-y-3`,children:[(0,I.jsx)(Tt,{query:n}),r&&(0,I.jsx)(G,{coverage:r.coverage,retry:()=>void n.refetch()}),r&&(0,I.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,I.jsx)(Dt,{data:r}),(0,I.jsx)(Ot,{data:r})]})]})}function Dt({data:e}){let t=e.delivered,n=[{label:`PRs opened`,value:t.prsOpened,note:`${t.prsTouched} touched`},{label:`Lines`,value:(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`span`,{className:`text-success`,children:[`+`,t.additions.toLocaleString(`en-US`)]}),` `,(0,I.jsxs)(`span`,{className:`text-danger`,children:[`−`,t.deletions.toLocaleString(`en-US`)]})]})},{label:`Files`,value:t.files.toLocaleString(`en-US`)},{label:`Issues`,value:t.issues}];return(0,I.jsxs)(`section`,{className:xt,"aria-label":`Delivered`,children:[(0,I.jsx)(L,{rows:Object.entries(t).map(([t,n])=>({section:`delivered`,metric:t,value:n,unit:[`additions`,`deletions`].includes(t)?`lines`:t===`files`?`files`:`count`,asOf:e.asOf,note:`Completed since ${e.windowStart}`}))}),(0,I.jsx)(`h3`,{className:bt,children:`Delivered`}),(0,I.jsx)(`dl`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-4`,children:n.map(e=>(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsx)(`dt`,{className:`text-xs text-soft-foreground`,children:e.label}),(0,I.jsx)(`dd`,{className:`mt-1 truncate text-xl font-semibold tracking-tight tabular-nums`,children:e.value}),e.note&&(0,I.jsx)(`dd`,{className:`text-xs text-soft-foreground`,children:e.note})]},e.label))}),(0,I.jsxs)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:[`From `,t.completedTasks,` completed `,t.completedTasks===1?`task`:`tasks`,` ·`,` `,t.measuredTasks,` with a stored diff`]})]})}function Ot({data:e}){let t=St(),{total:n,reasons:r}=e.failures;return(0,I.jsxs)(`section`,{className:xt,"aria-label":`Why tasks failed`,children:[(0,I.jsx)(L,{rows:r.map(t=>({section:`failures`,entity:t.label,metric:t.category,value:t.count,unit:`tasks`,asOf:e.asOf,note:t.latest.message}))}),(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,I.jsx)(`h3`,{className:bt,children:`Why tasks failed`}),n>0&&(0,I.jsxs)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:[n,` failed`]})]}),n===0?(0,I.jsxs)(`span`,{className:`mt-4 flex items-center gap-2.5 text-sm text-muted-foreground`,children:[(0,I.jsx)(N,{tone:`success`}),`No failed outcomes in this period`]}):(0,I.jsx)(`ul`,{className:`mt-3 space-y-3`,children:r.map(e=>(0,I.jsx)(kt,{reason:e,total:n,projectName:t},`${e.category}:${e.label}`))})]})}function kt({reason:e,total:t,projectName:n}){let{latest:r}=e;return(0,I.jsxs)(`li`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,I.jsx)(`span`,{className:`min-w-0 truncate font-medium`,title:e.label,children:e.label}),(0,I.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:e.count})]}),(0,I.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full bg-danger/70`,style:{width:`${e.count/t*100}%`}})}),(0,I.jsxs)(`span`,{className:`mt-1.5 block truncate text-xs text-soft-foreground`,title:r.message,children:[`Latest:`,` `,(0,I.jsx)(D,{className:`text-muted-foreground hover:text-foreground hover:underline`,to:Ct(r.projectId,r.id),children:r.title}),` `,`· `,n(r.projectId),r.step?` · ${r.step}`:``,` · `,P(r.at),` ago`]})]})}var At={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,cursor:`Cursor`,pi:`Pi`,unknown:`Unknown backend`,mixed:`Mixed backends`},jt=e=>At[e]??e,Mt=(e,t)=>t?Math.round(e/t*100):0;function Nt(){let[e,t]=vt(`backends`,[`7d`,`30d`],`7d`),n=Ue(e),r=n.data,i=r?.visibility.cost;return(0,I.jsx)(`section`,{"data-dashboard-module":`backends`,className:`min-w-0`,children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Backends: ${yt(e)}; finished tasks`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Backends & models`}),(0,I.jsx)(wt,{label:`Finished`,value:e,onChange:t})]}),(0,I.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,I.jsx)(Tt,{query:n}),r&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Tasks that finished done or failed in the period, by the backend and model their steps ran on. Includes subtasks. Cost is reported USD only.`}),(0,I.jsx)(G,{coverage:r.coverage,retry:()=>void n.refetch()}),r.backends.length?(0,I.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Backend comparison`,tabIndex:0,children:(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:q,children:`Backend`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Finished`}),(0,I.jsx)(`th`,{className:q,children:`Success`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Median cycle`}),i&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Reported USD`}),i&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Per completed`})]})}),(0,I.jsx)(`tbody`,{children:r.backends.map(e=>(0,I.jsx)(Pt,{stat:e,cost:!!i},`${e.backend}:${e.model??``}`))})]})}):(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No finished tasks in this period.`}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,I.jsx)(it,{at:r.asOf})}),(0,I.jsx)(L,{rows:r.backends.flatMap(e=>[`finished`,`done`,`failed`,`medianCycleHours`].map(t=>({section:`backends`,entity:`${e.backend}${e.model?`:${e.model}`:``}`,metric:t,value:e[t],unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:r.asOf})))})]})]})]})})}function Pt({stat:e,cost:t}){let n=Mt(e.done,e.finished),r=e.costUsd?.value;return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,I.jsx)(`span`,{className:`block font-medium`,children:jt(e.backend)}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:e.backend===`mixed`?`steps ran on different backends`:e.model??`default model`})]}),(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.finished}),(0,I.jsxs)(`td`,{className:`min-w-40 px-3 py-2.5`,children:[(0,I.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,I.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-danger/40`,"aria-hidden":`true`,children:(0,I.jsx)(`span`,{className:`block h-full rounded-full bg-success`,style:{width:`${n}%`}})}),(0,I.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs tabular-nums`,children:[n,`%`]})]}),(0,I.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.done,` done · `,e.failed,` failed`]})]}),(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.timedTasks?K(e.medianCycleHours):`—`}),t&&(0,I.jsxs)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:[r==null?`—`:_t(r,!0),(0,I.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.costUsd?.reportedTasks??0,`/`,e.finished,` reported`]})]}),t&&(0,I.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:r==null||!e.done?`—`:_t(r/e.done,!0)})]})}function Ft(){let[e,t]=vt(`automations`,[`7d`,`30d`],`7d`),n=ve(),r=Ue(e),i=Qe(n.known&&!n.off),a=St(),o=r.data,s=o?.visibility.cost,c=new Map;for(let e of i.data??[])for(let t of e.data?.automations??[])c.set(`${e.id}\u0000${t.id}`,{projectId:e.id,automationId:t.id,name:t.name,enabled:t.enabled,definition:`known`});let l=new Set((i.data??[]).flatMap(e=>e.data&&!e.error?[e.id]:[])),u=i.isError||i.registry.isError||(i.data??[]).some(e=>e.error);for(let e of o?.automations??[]){let t=`${e.projectId}\u0000${e.automationId}`,n=c.get(t);c.set(t,n?{...n,stat:e}:{...e,name:e.automationId,definition:l.has(e.projectId)?`removed`:`unknown`,stat:e})}let d=[...c.values()].sort((e,t)=>(t.stat?.tasks??0)-(e.stat?.tasks??0)||Number(t.enabled??!1)-Number(e.enabled??!1)||e.name.localeCompare(t.name));return(0,I.jsx)(`section`,{"data-dashboard-module":`automation-outcomes`,className:`min-w-0`,children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Automation outcomes: tasks created in ${yt(e)}`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Automation outcomes`}),(0,I.jsx)(wt,{label:`Launched`,value:e,onChange:t})]}),(0,I.jsx)(`div`,{className:`space-y-3 p-4`,children:n.off?(0,I.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(Tt,{query:r}),o&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Tasks each automation created in the period and how they ended. Active means still running, queued, waiting on you, or waiting to resume after a usage limit.`}),(0,I.jsx)(G,{coverage:o.coverage,retry:()=>void r.refetch()}),u&&(0,I.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Some automation details could not be loaded. Their outcomes are shown by id.`,` `,(0,I.jsx)(w,{variant:`ghost`,onClick:i.retry,children:`Retry automations`})]}),d.length?(0,I.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Automation outcomes`,tabIndex:0,children:(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{children:[(0,I.jsx)(`th`,{className:q,children:`Automation`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Tasks`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Done`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Failed`}),(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Active`}),(0,I.jsx)(`th`,{className:q,children:`Last run`}),s&&(0,I.jsx)(`th`,{className:`${q} text-right`,children:`Reported USD`})]})}),(0,I.jsx)(`tbody`,{children:d.map(e=>(0,I.jsx)(It,{row:e,cost:!!s,projectName:a},`${e.projectId}:${e.automationId}`))})]})}):(0,I.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No automations yet. Create one in a project's Automations page.`}),(0,I.jsx)(`span`,{className:`block font-mono text-[11px] text-soft-foreground`,children:(0,I.jsx)(it,{at:o.asOf})}),(0,I.jsx)(L,{rows:d.flatMap(e=>[`tasks`,`done`,`failed`,`active`].map(t=>({section:`automation-outcomes`,entity:`${e.projectId}:${e.automationId}`,metric:t,value:e.stat?.[t]??0,unit:`tasks`,asOf:o.asOf,note:e.name})))})]})]})})]})})}function It({row:e,cost:t,projectName:n}){let r=e.stat,i=`px-3 py-2.5 text-right tabular-nums`,a=e=>e||(0,I.jsx)(`span`,{className:`text-soft-foreground`,children:`0`});return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2.5`,children:[e.definition===`removed`?(0,I.jsx)(`span`,{className:`block font-medium`,children:e.name}):(0,I.jsx)(D,{className:`block font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/automations/${encodeURIComponent(e.automationId)}`,children:e.name}),(0,I.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,I.jsx)(N,{tone:e.enabled?`success`:`neutral`}),n(e.projectId),` ·`,` `,e.definition===`removed`?`Removed`:e.definition===`unknown`?`Details unavailable`:e.enabled?`Enabled`:`Disabled`]})]}),(0,I.jsx)(`td`,{className:i,children:a(r?.tasks)}),(0,I.jsx)(`td`,{className:i,children:a(r?.done)}),(0,I.jsx)(`td`,{className:`${i} ${r?.failed?`text-danger`:``}`,children:a(r?.failed)}),(0,I.jsx)(`td`,{className:i,children:a(r?.active)}),(0,I.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-xs text-muted-foreground`,children:r?.lastRunAt?(0,I.jsxs)(`time`,{dateTime:r.lastRunAt,title:new Date(r.lastRunAt).toLocaleString(),children:[P(r.lastRunAt),` ago · `,r.lastStatus]}):`—`}),t&&(0,I.jsx)(`td`,{className:i,children:r?.costUsd?.value==null?`—`:_t(r.costUsd.value,!0)})]})}var Lt=0,Rt=()=>++Lt,J=new Map;function Y(e,t){let n=(0,F.useContext)(ct),r=()=>{let r=n?J.get(n):void 0;return r?.has(e)?r.get(e):typeof t==`function`?t():t},[i,a]=(0,F.useState)(r),o=`${n}:${e}`,[s,c]=(0,F.useState)(o);o!==s&&(c(o),a(()=>r()));let l=(0,F.useMemo)(()=>({value:i}),[n,e]);return l.value=i,(0,F.useEffect)(()=>()=>{if(!n)return;let t=J.get(n)??new Map;t.set(e,l.value),t.size>80&&t.delete(t.keys().next().value),J.delete(n),J.set(n,t),J.size>20&&J.delete(J.keys().next().value)},[n,e,l]),[i,a]}var zt=`a[href], button, select, input, [tabindex]`;function Bt(e){let[t]=Y(`${e}:position`,()=>({scroll:0})),n=(0,F.useCallback)(e=>{let n=[...e.querySelectorAll(zt)],r=t.href?n.find(e=>e.getAttribute(`href`)===t.href):t.index===void 0?void 0:n[t.index];return r&&r.getAttribute(`aria-disabled`)!==`true`&&r.focus({preventScroll:!0}),e.scrollTop=t.scroll,!!r&&r.getAttribute(`aria-disabled`)!==`true`},[t]),r=(0,F.useMemo)(()=>({restore:()=>!1}),[t]);return{ref:(0,F.useCallback)(e=>{if(!e)return;let i=t.href!==void 0||t.index!==void 0,a=()=>{if(!i)return!1;let r=n(e);return r?(i=!1,o.disconnect()):e.querySelector(`[data-sheet-loading="false"]`)&&(i=!1,o.disconnect(),e.querySelector(`button:not([disabled]), select, [tabindex="0"]`)?.focus({preventScroll:!0}),e.scrollTop=t.scroll),r};r.restore=a;let o=new MutationObserver(a);i&&o.observe(e,{childList:!0,subtree:!0,attributes:!0,attributeFilter:[`data-sheet-loading`]});let s=()=>{i=!1,o.disconnect()},c=()=>{i||(t.scroll=e.scrollTop)},l=n=>{i||!(n.target instanceof HTMLElement)||(t.href=n.target.getAttribute(`href`)??void 0,t.index=[...e.querySelectorAll(zt)].indexOf(n.target))};return e.addEventListener(`pointerdown`,s),e.addEventListener(`keydown`,s),e.addEventListener(`wheel`,s,{passive:!0}),e.addEventListener(`scroll`,c),e.addEventListener(`focusin`,l),()=>{o.disconnect(),e.removeEventListener(`pointerdown`,s),e.removeEventListener(`keydown`,s),e.removeEventListener(`wheel`,s),e.removeEventListener(`scroll`,c),e.removeEventListener(`focusin`,l)}},[t,n,r]),onOpenAutoFocus:e=>{(t.href!==void 0||t.index!==void 0)&&(e.preventDefault(),r.restore())}}}function Vt(e,t){let n=(0,F.useRef)(null),[r,i]=Y(`${e}:trigger`,null);return{capture:()=>{let e=document.activeElement;n.current=e instanceof HTMLElement&&e!==document.body?e:null,i(n.current?{label:n.current.getAttribute(`aria-label`),text:n.current.textContent}:null)},restore:()=>{((n.current?.isConnected?n.current:r?[...document.querySelectorAll(`button`)].find(e=>!e.closest(`[role="dialog"]`)&&!e.hasAttribute(`disabled`)&&(r.label?e.getAttribute(`aria-label`)===r.label:e.textContent===r.text)):void 0)??document.querySelector(t))?.focus({preventScroll:!0})}}}function Ht(e,t=!0){return d({queryKey:[...s.dashboard,`overview`,e],enabled:t,staleTime:5e3,refetchInterval:t&&!e.snapshotId?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>b.parse(await f(await m.api.v1.workspace.dashboard.overview.$get({query:{period:e.period??`7d`,group:e.group??`completed`,tzOffsetMinutes:String(e.tzOffsetMinutes??new Date().getTimezoneOffset()),...e.snapshotId?{snapshotId:e.snapshotId}:{},...e.projectId?{projectId:e.projectId}:{},offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/overview`))})}var Ut={running:`Running now`,"needs-you":`Needs you`,completed:`Completed`,failed:`Failed outcomes`},Wt={"needs-you":V.violet,running:V.info,completed:V.success,failed:V.danger},Gt={"needs-you":qe,running:We,completed:k,failed:Ke};function Kt({active:e,children:t,onCurrent:n}){let[r,i]=vt(`period`,[`7d`,`30d`],`7d`),o=Vt(`outcome`,`[data-outcome-trigger]`),s=a().data?.projects,c=e=>s?.find(t=>t.id===e)?.name??e,l=Ht({period:r},e),[u,d]=Y(`outcome:selection`,null),f=Bt(`outcome:${u?.identity??`closed`}`),p=ye();if((0,F.useEffect)(()=>{e||d(null)},[e]),!e)return t({});let m=l.data,h=(e,t)=>{o.capture(),m&&d({identity:Rt(),snapshot:m,group:e,projectId:t})},g=m?.coverage.projects.every(e=>e.state===`complete`);return(0,I.jsxs)(I.Fragment,{children:[t({overview:(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Workspace overview`}),(0,I.jsxs)(`label`,{className:et,children:[`Outcomes period`,(0,I.jsxs)(tt,{value:r,onChange:e=>{i(e.target.value===`30d`?`30d`:`7d`),d(null)},children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4 p-4`,children:[l.isPending&&(0,I.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading overview…`}),l.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[m?`Showing previous results. `:``,`Could not refresh overview.`,` `,(0,I.jsx)(w,{variant:`outline`,onClick:()=>void l.refetch(),children:`Retry overview`})]}),m&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[m.metrics.needsYou?`${m.metrics.needsYou} tasks require your input or review.`:g&&p.connected&&!l.isError?`No tasks currently require your input or review.`:`No waiting tasks found in the available data.`,` `,m.metrics.failed,` failed `,m.metrics.failed===1?`outcome`:`outcomes`,` `,`in this period. Includes subtasks; completed does not mean accepted or deployed.`]}),(0,I.jsx)(G,{coverage:m.coverage,retry:()=>void l.refetch()}),(0,I.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[`needs-you`,`running`,`completed`,`failed`].map(e=>{let t=m.metrics[e===`needs-you`?`needsYou`:e],i=Gt[e];return(0,I.jsxs)(w,{"data-outcome-trigger":!0,"data-export-keep":!0,variant:`outline`,className:`relative min-w-0 overflow-hidden rounded-lg border bg-card-2 p-4 transition-colors before:absolute before:inset-x-0 before:top-0 before:h-px before:opacity-80 hover:border-foreground/20 hover:bg-muted/40 sm:p-5 group/metric h-auto min-h-24 flex-col items-start gap-0 whitespace-normal text-left font-normal ${t===0?V.neutral:Wt[e]}`,onClick:t=>{n&&(e===`running`||e===`needs-you`)?n(e,t.currentTarget):h(e)},"aria-label":`${Ut[e]}: ${t}`,children:[(0,I.jsx)(rt,{label:Ut[e],value:t,icon:(0,I.jsx)(i,{className:`size-4`}),children:e===`running`||e===`needs-you`?`Current state`:`Last ${r===`7d`?7:30} calendar days`}),(0,I.jsxs)(`span`,{"data-export-exclude":!0,className:`mt-4 flex items-center gap-1 text-xs font-medium text-muted-foreground transition-colors group-hover/metric:text-foreground`,children:[`View tasks`,` `,(0,I.jsx)(Be,{className:`size-3 transition-transform group-hover/metric:translate-x-0.5 motion-reduce:transition-none`,"aria-hidden":`true`})]})]},e)})}),(0,I.jsx)(Et,{period:r,active:e}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 border-t pt-3`,children:[(0,I.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Median cycle time`,` `,(0,I.jsx)(`strong`,{className:`font-mono font-semibold text-foreground`,children:K(m.metrics.medianCycleHours)}),` `,`· `,m.metrics.timedTasks,`/`,m.metrics.completed,` completed tasks have valid timings.`,` `,(0,I.jsx)(w,{variant:`ghost`,className:`h-auto px-1.5 py-1 text-sm text-foreground underline-offset-4 hover:underline`,onClick:()=>h(`completed`),children:`Inspect completed tasks`})]}),(0,I.jsx)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,children:(0,I.jsxs)(`time`,{dateTime:m.asOf,title:new Date(m.asOf).toLocaleString(),children:[`Updated `,P(m.asOf),` ago`]})})]}),(0,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-1`,children:[(0,I.jsx)(B,{}),`How these metrics work`]}),(0,I.jsx)(`p`,{className:`mt-1 max-w-prose pl-5 leading-relaxed`,children:`Outcomes use finish dates, including archived tasks. Scheduled retries are excluded from failed outcomes. Period includes today at your current fixed UTC offset.`})]}),(0,I.jsx)(L,{rows:Object.entries(m.metrics).map(([e,t])=>({section:`overview`,metric:e,value:t,unit:e===`medianCycleHours`?`hours`:`tasks`,asOf:m.asOf,note:e===`running`||e===`needsYou`?`Current non-archived state`:`Finished since ${m.windowStart}`}))})]})]})]}),portfolio:m&&(0,I.jsx)(`div`,{children:(0,I.jsxs)(M,{className:`gap-0 py-0`,"data-export-context":`Outcomes: Last ${r===`7d`?7:30} calendar days; workload: current state`,children:[(0,I.jsx)(`div`,{className:`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,children:(0,I.jsx)(`h2`,{className:`section-mark font-mono text-[11px] font-semibold uppercase tracking-[0.14em] text-muted-foreground`,children:`Projects`})}),(0,I.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:`Current workload and outcomes for the selected period. Sorted by tasks needing you, then running tasks. Counts include subtasks.`}),(0,I.jsxs)(`div`,{className:`overflow-x-auto px-1 pb-2`,role:`region`,"aria-label":`Project outcomes`,tabIndex:0,children:[(0,I.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsx)(`tr`,{children:[`Project`,`Needs you`,`Running`,`Completed`,`Failed`,`Median cycle`].map(e=>(0,I.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 font-mono text-[11px] font-medium uppercase tracking-[0.1em] text-soft-foreground ${e===`Project`?``:`text-right`}`,children:e},e))})}),(0,I.jsx)(`tbody`,{children:m.projects.map(e=>{let t=m.coverage.projects.find(t=>t.projectId===e.projectId);return(0,I.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,I.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,I.jsx)(D,{className:`font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks`,children:c(e.projectId)}),t?.state!==`complete`&&(0,I.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Incomplete data`})]}),[`needs-you`,`running`,`completed`,`failed`].map(n=>(0,I.jsx)(`td`,{className:`px-3 py-1 text-right`,children:(0,I.jsx)(w,{"data-export-keep":!0,variant:`ghost`,className:`min-h-11 tabular-nums`,"aria-label":`${c(e.projectId)}: ${Ut[n]}: ${t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]}`,disabled:t?.state===`unavailable`,onClick:()=>h(n,e.projectId),children:t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]})},n)),(0,I.jsxs)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:[K(e.medianCycleHours),(0,I.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.timedTasks,`/`,e.completed,` timed`]})]})]},e.projectId)})})]}),!m.projects.length&&(0,I.jsx)(`p`,{className:`py-4`,children:`No projects to compare yet.`})]}),(0,I.jsx)(L,{rows:m.projects.flatMap(({projectId:e,...t})=>Object.entries(t).map(([t,n])=>({section:`portfolio`,entity:e,metric:t,value:m.coverage.projects.find(t=>t.projectId===e)?.state===`unavailable`?null:n,unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:m.asOf,note:`Outcomes since ${m.windowStart}; running and needsYou are current state`})))})]})})}),(0,I.jsx)(Oe,{open:!!u,onOpenChange:e=>{e||d(null)},children:(0,I.jsxs)(De,{...f,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),o.restore()},children:[(0,I.jsxs)(ke,{children:[(0,I.jsxs)(Ae,{children:[u?Ut[u.group]:`Tasks`,u?.projectId?` · ${u.projectId}`:``]}),(0,I.jsx)(Ee,{children:`Tasks behind the selected metric. Includes subtasks. Snapshot keeps counts and rows consistent.`})]}),u&&(0,I.jsx)(qt,{selection:u,projectName:c,refresh:()=>{d(null),l.refetch()}},u.identity)]})})]})}function qt({selection:e,refresh:t,projectName:n}){let[r,i]=Y(`outcome:${e.identity}:offset`,0),a=Ht({period:e.snapshot.period,snapshotId:e.snapshot.snapshotId,group:e.group,projectId:e.projectId,offset:r}),o=(0,F.useRef)(null),s=(0,F.useRef)(null);(0,F.useEffect)(()=>{a.data&&s.current===r&&(o.current?.focus(),s.current=null)},[a.data,r]);let c=e=>{s.current=e,i(e)};return(0,I.jsxs)(`div`,{className:`space-y-3 p-4`,"data-sheet-loading":a.isFetching,children:[a.isPending&&(0,I.jsx)(`p`,{children:`Loading tasks…`}),a.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[`This snapshot may have expired or become unavailable.`,` `,(0,I.jsx)(w,{onClick:t,children:`Refresh overview`})]}),a.data&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{ref:o,tabIndex:-1,className:`text-xs text-muted-foreground`,children:[a.data.page.total,` tasks · Snapshot from`,` `,(0,I.jsxs)(`time`,{dateTime:a.data.asOf,title:new Date(a.data.asOf).toLocaleString(),children:[P(a.data.asOf),` ago`]})]}),a.data.page.rows.map(t=>(0,I.jsx)(Jt,{row:t,group:e.group,projectName:n},`${t.projectId}:${t.id}`)),!a.data.page.rows.length&&(0,I.jsx)(`p`,{children:`No tasks in this group.`})]}),(0,I.jsxs)(`div`,{className:`flex gap-2`,children:[(0,I.jsx)(w,{variant:`outline`,disabled:!r||a.isFetching,onClick:()=>c(Math.max(0,r-20)),children:`Previous`}),(0,I.jsx)(w,{variant:`outline`,disabled:!a.data||a.data.page.nextOffset===null||a.isFetching,onClick:()=>c(a.data.page.nextOffset),children:`Next`})]})]})}function Jt({row:e,group:t,projectName:n}){let r=le(e),i=t===`running`||t===`needs-you`;i&&r&&(e={...e,...r});let a=r===null,s=i&&(e.archived||(t===`running`?e.status!==`running`:!g(e))),c=a||s,l=o(e),u=i&&a?`Task removed`:s?t===`running`?`No longer running`:`No longer needs you`:l.label;return(0,I.jsxs)(`div`,{className:`border-b py-3`,children:[(0,I.jsx)(D,{"aria-disabled":c||void 0,tabIndex:c?-1:void 0,onClick:e=>{c&&e.preventDefault()},className:`block min-h-11 font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,children:e.titleSummary||e.title}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsx)(N,{tone:l.tone}),` `,n(e.projectId),` ·`,` `,u,` · `,e.archived?`Archived · `:``,(0,I.jsxs)(`time`,{dateTime:e.finishedAt??e.createdAt,title:new Date(e.finishedAt??e.createdAt).toLocaleString(),children:[e.finishedAt?`Finished`:`Created`,` `,P(e.finishedAt??e.createdAt),` ago`]})]})]})}var X={snapshot:[...s.dashboard,`snapshot`],feed:e=>[...s.dashboard,`feed`,e],telemetry:[...s.dashboard,`telemetry`]},Yt=new Map;async function Xt(e){let t=A(),n=x.parse(await f(await m.api.v1.workspace.dashboard.$get({},{init:{signal:e}}),`/workspace/dashboard`));return Yt.has(n.snapshotId)||Yt.set(n.snapshotId,t),Yt.size>60&&Yt.delete(Yt.keys().next().value),j(t,[...n.questions.rows,...n.reviews.rows]),n}async function Zt(e,t,n=0,r=20,i){let a=T.parse(await f(await m.api.v1.workspace.dashboard.tasks.$get({query:{snapshotId:e,group:t,offset:String(n),limit:String(r)}},{init:{signal:i}}),`/workspace/dashboard/tasks`)),o=Yt.get(e);return o!==void 0&&j(o,a.page.rows),a}function Qt(e){return d({queryKey:X.snapshot,queryFn:({signal:e})=>Xt(e),enabled:e,staleTime:5e3,refetchOnMount:`always`,refetchInterval:e?15e3:!1,refetchIntervalInBackground:!1,retry:!1})}function $t(e){return d({queryKey:X.telemetry,enabled:e,staleTime:0,queryFn:async({signal:e})=>{let t=C.parse(await f(await m.api.v1.workspace.dashboard.telemetry.$get({},{init:{signal:e}}),`/workspace/dashboard/telemetry`));return O.seed(t.samples,t.asOf),t}})}function en(e,t){let n=d({queryKey:X.feed(e),queryFn:async({signal:t})=>{let n=A(),r=_.parse(await f(await m.api.v1.workspace.dashboard.feed.$get({query:{filter:e}},{init:{signal:t}}),`/workspace/dashboard/feed`));return j(n,r.rows.flatMap(e=>e.kind===`task-result`?[e.run]:[])),r},enabled:t,staleTime:15e3,refetchInterval:t&&e!==`github`?15e3:!1,retry:!1}),r=(0,F.useRef)(!1);return(0,F.useEffect)(()=>{r.current=!1},[e,t]),(0,F.useEffect)(()=>{if(!t||r.current||!n.data?.sources.some(e=>e.reason===`Still loading GitHub`))return;let e=setTimeout(()=>{document.visibilityState!==`hidden`&&(r.current=!0,n.refetch())},5e3);return()=>clearTimeout(e)},[t,n.data,n.refetch]),n}function tn(e,t){let n=en(`tasks`,t&&e!==`github`),r=en(`github`,t&&e!==`tasks`),i=(0,F.useMemo)(()=>{if(e===`tasks`)return n.data;if(e===`github`)return r.data;let t=n.data,i=r.data;if(!t&&!i)return;let a=t??i,o=new Date(Math.max(Date.parse(t?.asOf??a.asOf),Date.parse(i?.asOf??a.asOf))).toISOString(),s=new Date(Date.parse(o)-10080*60*1e3).toISOString(),c=[...t?.rows??[],...i?.rows??[]].filter(e=>Date.parse(e.at)>=Date.parse(s)&&Date.parse(e.at)<=Date.parse(o)).sort((e,t)=>nn(e,t)),l=new Set(c.slice(60).map(e=>e.kind===`task-result`?`tasks:${e.run.projectId}`:e.key.slice(0,e.key.lastIndexOf(`:`)))),u=[...t?.sources??[],...i?.sources??[]].map(e=>l.has(e.key)?{...e,truncated:!0}:e);return{...a,asOf:o,windowStart:s,filter:`all`,rows:c.slice(0,60),sources:u,coverage:t?.coverage??a.coverage,truncated:c.length>60||!!t?.truncated||!!i?.truncated}},[e,n.data,r.data]),a=e===`github`?r:n;return{...a,data:i,githubError:r.isError,githubFetching:r.isFetching,retryTasks:()=>n.refetch(),retryFailed:()=>e===`github`?r.refetch():e===`tasks`?n.refetch():Promise.all([...n.isError?[n.refetch()]:[],...r.isError?[r.refetch()]:[]]),isPending:!i&&a.isPending,isError:a.isError||e===`all`&&r.isError,isFetching:a.isFetching||e===`all`&&r.isFetching,refetch:()=>e===`tasks`?n.refetch():r.refetch()}}function nn(e,t){return Date.parse(t.at)-Date.parse(e.at)||e.key.localeCompare(t.key)}var rn=[...s.dashboard,`costs`];function an(){let e=0,t=0,n,r=new Set;return{subscribe:e=>(r.add(e),()=>{r.delete(e)}),getSnapshot:()=>n,async read(i,a){let o=++e,s=await un(i,a);return!a?.aborted&&o>t&&(t=o,(n?.cost!==s.visibility.cost||n?.tokens!==s.visibility.tokens)&&(n=s.visibility,r.forEach(e=>e()))),s}}}var on=new WeakMap;function sn(e){let t=on.get(e);return t||(t=an(),on.set(e,t)),t}function cn(){let e=sn(c());return(0,F.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}var ln=new Map;async function un(e,t){let n=A(),r=y.parse(await f(await m.api.v1.workspace.dashboard.costs.$get({query:{...e,offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/costs`));!e.snapshotId&&!ln.has(r.snapshotId)&&ln.set(r.snapshotId,n),ln.size>60&&ln.delete(ln.keys().next().value);let i=ln.get(r.snapshotId);return i!==void 0&&j(i,r.tasks.rows),r}function dn(e,t,n){let r=sn(c());return d({queryKey:[...rn,e,t,n],queryFn:({signal:n})=>r.read({period:e,sort:t,tzOffsetMinutes:new Date().getTimezoneOffset()},n),staleTime:5e3,refetchOnMount:`always`,refetchInterval:15e3,refetchIntervalInBackground:!1,retry:!1})}function fn(e,t,n,r){let i=sn(c());return d({queryKey:[...rn,`tasks`,e.snapshotId,t,n,r,e.visibility],retry:!1,queryFn:async({signal:a})=>{let o=e.tzOffsetMinutes??new Date().getTimezoneOffset(),s=async s=>{let c=await i.read({period:e.period,sort:n,snapshotId:s,projectId:t,tzOffsetMinutes:o},a),l=[...c.tasks.rows];for(;c.tasks.nextOffset!==null&&l.length<r;)c=await i.read({period:e.period,sort:n,snapshotId:c.snapshotId,projectId:t,offset:c.tasks.nextOffset},a),l.push(...c.tasks.rows);return{...c,tasks:{...c.tasks,rows:l}}};try{return await s(e.snapshotId)}catch(e){if(e instanceof u&&e.status===409)return s();throw e}}})}var pn={cost:{text:`text-primary`,fill:`bg-primary`,tint:V.primary,icon:ue},input:{text:`text-violet`,fill:`bg-violet`,tint:V.violet,icon:Ge},output:{text:`text-info`,fill:`bg-info`,tint:V.info,icon:ne}};function mn({metric:e,label:t,value:n,reported:r,total:i}){let a=pn[e],o=a.icon,s=i?Math.min(100,r/i*100):0;return(0,I.jsxs)(`div`,{className:`${nt} ${a.tint}`,children:[(0,I.jsxs)(rt,{label:t,value:n,icon:(0,I.jsx)(o,{className:`size-4 ${a.text}`}),children:[r,` of `,i,` tasks report this metric`]}),(0,I.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{className:`h-full rounded-full ${a.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${s}%`}})})]})}function hn({projects:e,currentProjects:t,metric:n,field:r,label:i,format:a,onSelect:o}){let s=e.reduce((e,t)=>Math.max(e,t[r]?.value??0),0),c=pn[n];return(0,I.jsxs)(Re,{delayDuration:150,children:[(0,I.jsxs)(`div`,{className:`space-y-1 rounded-xl border p-2`,"aria-label":`Projects ranked by ${i}`,children:[e.length===0&&(0,I.jsx)(`p`,{className:`px-3 py-4 text-muted-foreground`,children:`No projects to compare in this cohort.`}),e.slice(0,5).map((e,n)=>{let l=e[r],u=l?.value,d=u==null||s===0?0:u/s*100,f=u!=null;return(0,I.jsxs)(ze,{children:[(0,I.jsx)(Ie,{asChild:!0,children:(0,I.jsxs)(`button`,{"data-export-row":!0,"data-export-keep":!0,className:`group w-full rounded-lg px-3 py-3 text-left transition-colors hover:bg-muted/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring disabled:opacity-50 motion-reduce:transition-none`,disabled:!t.some(t=>t.projectId===e.projectId),onClick:()=>o(e.projectId),children:[(0,I.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,I.jsx)(`span`,{className:`w-4 shrink-0 text-xs tabular-nums text-muted-foreground`,"aria-hidden":`true`,children:n+1}),(0,I.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium`,children:e.projectId}),(0,I.jsx)(`span`,{className:`shrink-0 font-semibold tabular-nums`,children:a(u)}),(0,I.jsx)(Be,{"data-export-exclude":!0,className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`mt-2 ml-7 h-2 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,I.jsx)(`div`,{"data-project-bar":e.projectId,className:`h-full rounded-full ${c.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${d}%`}})}),(0,I.jsxs)(`p`,{className:`mt-1.5 ml-7 text-xs text-muted-foreground`,children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric`,f?``:` · No measured value`]})]})}),(0,I.jsxs)(Le,{className:`max-w-64`,children:[(0,I.jsxs)(`p`,{className:`font-medium`,children:[e.projectId,` · `,i,`: `,a(u)]}),(0,I.jsxs)(`p`,{children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric.`]}),(0,I.jsx)(`p`,{children:`Open project tasks`})]})]},e.projectId)})]}),e.length>0&&(0,I.jsxs)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:[e.length>5?`Top 5 of ${e.length} projects. `:``,`Bar lengths compare reported values; the largest is the reference.`]})]})}var Z={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},gn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function _n(e,t){return JSON.stringify([e.totals,e.projects,e.tasks,e.visibility,e.coverage,e.invalidDateTasks])!==JSON.stringify([t.totals,t.projects,t.tasks,t.visibility,t.coverage,t.invalidDateTasks])}var vn=(e,t)=>_t(e,t===`cost`);function Q(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}function yn({value:e,onChange:t,visibility:n}){return(0,I.jsxs)(`label`,{className:et,children:[`Sort by`,(0,I.jsx)(tt,{value:e,onChange:e=>t(e.target.value),children:Q(n).map(e=>(0,I.jsx)(`option`,{value:e,children:gn[e]},e))})]})}function bn(){return(0,I.jsx)(xn,{visibility:He(h().data)})}function xn({visibility:e}){return(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsx)(`div`,{className:z,children:(0,I.jsx)(`h2`,{className:R,children:`Usage & cost`})}),!e.cost&&!e.tokens?(0,I.jsx)(`p`,{className:`p-4 text-sm`,children:`Usage metrics are hidden by workspace settings`}):(0,I.jsx)(Sn,{visibility:e},`${e.cost}:${e.tokens}`)]})}function Sn({visibility:e}){let[t,n]=vt(`usagePeriod`,[`all`,`7d`,`30d`],`all`),[r,i]=vt(`usageSort`,Q(e),e.cost?`cost`:`input`);return(0,I.jsx)(Cn,{period:t,setPeriod:n,sort:r,setSort:i,visibility:e})}function Cn({period:e,setPeriod:t,sort:n,setSort:r,visibility:i}){let a=dn(e,n,`${i.cost}:${i.tokens}`),[o,s]=Y(`usage:accepted`,void 0),c=o??a.data,l=a.data??c,[u,d]=Y(`usage:panel`,null),[f,p]=(0,F.useState)(e);f!==e&&(p(e),s(void 0),d(null));let m=Bt(`usage:${u?.identity??`closed`}`),h=Vt(`usage`,`[data-usage-trigger]`),g=e=>{h.capture(),c&&d({identity:Rt(),projectId:e,snapshot:c,latestId:l?.snapshotId??c.snapshotId})},_=cn()??i,v={cost:i.cost&&_.cost,tokens:i.tokens&&_.tokens},y=Q(v).includes(n)?n:Q(v)[0]??`cost`,b=[...c?.projects??[]].sort((e,t)=>{let n=e[Z[y]]?.value,r=t[Z[y]]?.value;return(n==null?r==null?0:1:r==null?-1:r-n)||e.projectId.localeCompare(t.projectId)});!o&&a.data&&s(a.data);let x=c&&l&&_n(c,l),S=c?.coverage.projects.some(e=>e.state!==`complete`),C=l?.coverage.projects.some(e=>e.state!==`complete`),T=JSON.stringify(c?.coverage)!==JSON.stringify(l?.coverage),E=c?.totals.tasks===0&&!S&&!C;return(0,I.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[c&&(0,I.jsx)(L,{rows:E?[]:[...Q(v).map(e=>({section:`totals`,metric:Z[e],value:c.totals[Z[e]]?.value??null,unit:e===`cost`?`USD`:`tokens`,reportedTasks:c.totals[Z[e]]?.reportedTasks??0,totalTasks:c.totals.tasks,asOf:c.asOf})),...(v.cost||v.tokens?b.slice(0,5):[]).map(e=>({section:`project`,entity:e.projectId,metric:Z[y],value:e[Z[y]]?.value??null,unit:y===`cost`?`USD`:`tokens`,reportedTasks:e[Z[y]]?.reportedTasks??0,totalTasks:e.tasks,asOf:c.asOf}))]}),c&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:c.asOf})}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`font-medium`,children:`Lifetime totals of retained tasks`}),(0,I.jsxs)(`details`,{className:`mt-1 text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${$e} min-h-11`,children:[(0,I.jsx)(B,{}),`How these metrics work`]}),(0,I.jsxs)(`p`,{children:[`Includes archived tasks and subtasks.`,` `,v.cost&&`Reported USD is not an invoice. `,`Missing reports are excluded, not treated as zero. Calendar days use your current UTC offset, including today.`]})]})]}),(0,I.jsxs)(`label`,{className:et,children:[`Tasks created`,(0,I.jsxs)(tt,{value:e,onChange:e=>t(e.target.value),children:[(0,I.jsx)(`option`,{value:`all`,children:`All time`}),(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),e!==`all`&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Lifetime usage of tasks created in this period — not spending during the period.`}),a.isPending&&(0,I.jsx)(`p`,{children:`Loading usage…`}),a.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[c?`Showing stale usage. Could not refresh.`:`Could not load usage.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}),x&&(0,I.jsx)(`p`,{role:`status`,children:`Newer usage data is available; displayed values use the previous snapshot.`}),x&&(0,I.jsx)(w,{className:`min-h-11`,variant:`outline`,onClick:()=>s(l),children:`Updates available — Show`}),c&&S&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed usage:`}),(0,I.jsx)(G,{coverage:c.coverage,retry:()=>void a.refetch()})]}),l&&C&&T&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,I.jsx)(G,{coverage:l.coverage,retry:()=>void a.refetch()})]}),c&&(0,I.jsxs)(I.Fragment,{children:[!E&&(0,I.jsx)(`div`,{className:`report-cost-metrics grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:Q(v).map(e=>(0,I.jsx)(mn,{metric:e,label:gn[e],value:vn(c.totals[Z[e]]?.value,e),reported:c.totals[Z[e]]?.reportedTasks??0,total:c.totals.tasks},e))}),!v.cost&&!v.tokens&&(0,I.jsx)(`p`,{children:`Usage metrics are hidden by workspace settings`}),c.totals.tasks===0?(0,I.jsx)(`p`,{children:S||C?`No retained tasks could be read from available sources.`:`No retained tasks in this cohort.`}):Q(v).every(e=>!c.totals[Z[e]]?.reportedTasks)&&(0,I.jsx)(`p`,{children:`No reports for the visible metrics in this cohort.`}),E&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Usage appears when tasks report cost or tokens.`}),(0,I.jsxs)(`p`,{className:`text-muted-foreground`,children:[`Deleted tasks are excluded from retained history.`,c.invalidDateTasks?` ${c.invalidDateTasks} tasks have missing or invalid creation dates${e===`all`?`; included in All time`:`; excluded from this period`}.`:``]}),!E&&(v.cost||v.tokens)&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`h3`,{className:`font-medium`,children:`Top projects`}),(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Ranking uses reported metrics only.`})]}),(0,I.jsx)(yn,{value:y,onChange:r,visibility:v})]}),(0,I.jsx)(hn,{projects:b,metric:y,label:gn[y],field:Z[y],format:e=>vn(e,y),currentProjects:l?.projects??[],onSelect:g}),(0,I.jsx)(w,{"data-usage-trigger":!0,className:`min-h-11`,variant:`outline`,onClick:()=>g(``),children:`View tasks`})]})]}),(0,I.jsx)(Oe,{open:u!==null&&(v.cost||v.tokens),onOpenChange:e=>{e||d(null)},children:(0,I.jsxs)(De,{...m,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),h.restore()},children:[(0,I.jsxs)(ke,{children:[(0,I.jsx)(Ae,{children:u?.projectId?`${u.projectId} tasks`:`All tasks`}),(0,I.jsx)(Ee,{children:`Lifetime usage of retained tasks. Missing reports are unavailable.`})]}),u!==null&&(0,I.jsx)(wn,{identity:`usage:${u.identity}`,snapshot:l&&l.snapshotId!==u.latestId?l:u.snapshot,projectId:u.projectId||void 0,visibility:v},u.identity)]})})]})}function wn({identity:e,snapshot:t,projectId:n,visibility:r}){let[i,a]=Y(`${e}:sort`,t.sort);return(0,I.jsx)(Tn,{identity:e,snapshot:t,projectId:n,visibility:r,sort:Q(r).includes(i)?i:Q(r)[0]??`cost`,setSort:a})}function Tn({identity:e,snapshot:t,projectId:n,visibility:r,sort:i,setSort:a}){let[o,s]=Y(`${e}:count`,20),[c,l]=Y(`${e}:paging`,void 0),[u,d]=(0,F.useState)(t.snapshotId);u!==t.snapshotId&&(d(t.snapshotId),l(void 0));let f=fn(c??t,n,i,o),p=cn()??r,m={cost:r.cost&&p.cost,tokens:r.tokens&&p.tokens},h=Q(m).includes(i)?i:Q(m)[0]??`cost`,[g,_]=Y(`${e}:accepted`,void 0),[v,y]=Y(`${e}:acceptedCount`,o),[b,x]=Y(`${e}:acceptedSort`,i),[S,C]=(0,F.useState)(i);S!==i&&(C(i),s(20),l(g??c??t)),f.data&&(!g||(v!==o||b!==i)&&g.snapshotId===f.data.snapshotId)&&(_(f.data),y(o),x(i));let T=g??f.data,E=f.data&&T&&_n(f.data,T),ee=T?.coverage.projects.some(e=>e.state!==`complete`),D=f.data?.coverage.projects.some(e=>e.state!==`complete`),te=JSON.stringify(T?.coverage)!==JSON.stringify(f.data?.coverage),ne=!n||t.projects.some(e=>e.projectId===n);return(0,I.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,"data-sheet-loading":f.isFetching,children:[(0,I.jsx)(yn,{value:h,onChange:a,visibility:m}),f.isPending&&(0,I.jsx)(`p`,{children:`Loading tasks…`}),f.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[`Could not refresh tasks. `,T?`Showing stale usage.`:``,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void f.refetch(),children:`Retry`})]}),E&&(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{_(f.data),y(o),x(i)},children:`Updates available — Show`}),T&&ee&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed tasks:`}),(0,I.jsx)(G,{coverage:T.coverage,retry:()=>void f.refetch()})]}),f.data&&D&&te&&(0,I.jsxs)(`div`,{children:[(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,I.jsx)(G,{coverage:f.data.coverage,retry:()=>void f.refetch()})]}),T&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`p`,{className:`border-b pb-2 font-mono text-[11px] text-soft-foreground`,children:[T.tasks.rows.length,` of `,T.tasks.total,` retained tasks`]}),T.tasks.total===0&&(0,I.jsx)(`p`,{children:T.coverage.projects.some(e=>e.state!==`complete`)?`No tasks could be read from available sources.`:`No retained tasks in this cohort.`}),T.tasks.rows.map(e=>(0,I.jsx)(En,{row:e,sort:h,visibility:m,disabled:!ne||!f.data||!!(E&&!f.data?.tasks.rows.some(t=>t.id===e.id&&t.projectId===e.projectId))},`${e.projectId}:${e.id}`)),T.tasks.nextOffset!==null&&(0,I.jsx)(w,{className:`min-h-11`,disabled:f.isFetching,onClick:()=>{l(T),s(e=>e+20)},children:`Show 20 more tasks`})]})]})}function En({row:e,sort:t,visibility:n,disabled:r}){let i=le(e);r||=i===null;let a=o(i?{status:i.status,awaitingAnswerSince:i.awaitingAnswerSince}:e),s=Q(n).filter(e=>e!==t),c=t=>{let n=e[Z[t]];return n==null?`—`:vn(n,t)},l=t=>`${gn[t]}: ${vn(e[Z[t]],t)}`;return(0,I.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 border-b py-3 last:border-0`,children:[(0,I.jsxs)(`div`,{className:`min-w-0`,children:[(0,I.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,I.jsx)(N,{tone:a.tone,pulse:a.pulse,className:`mt-[7px]`}),(0,I.jsx)(D,{className:`line-clamp-2 break-words font-medium leading-snug hover:underline no-hover:min-h-11`,title:e.title,to:`/p/${encodeURIComponent(e.projectId)}/tasks/${encodeURIComponent(e.id)}`,"aria-disabled":r||void 0,tabIndex:r?-1:void 0,onClick:e=>{r&&e.preventDefault()},children:e.title})]}),(0,I.jsxs)(`p`,{className:`mt-1 pl-[15px] font-mono text-[11px] text-soft-foreground`,children:[e.projectId,` · `,r?`Checking current state…`:i?.status??e.status,e.archived?` · Archived`:``,e.subtask?` · Subtask`:``]})]}),(0,I.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,I.jsx)(`span`,{"aria-label":l(t),className:`block font-semibold ${e[Z[t]]==null?`text-soft-foreground`:``}`,children:c(t)}),s.length>0&&(0,I.jsx)(`span`,{className:`mt-1 flex justify-end gap-3 font-mono text-[11px] text-soft-foreground`,children:s.map(e=>(0,I.jsxs)(`span`,{"aria-label":l(e),children:[c(e),` `,e===`cost`?``:e===`input`?`in`:`out`]},e))})]})]})}var Dn={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},On={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function kn(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}var An=(e,t)=>_t(e,t===`cost`);function jn(e){return new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Mn({series:e,height:t,accent:n,renderTooltip:r,describe:i}){let a=Math.max(1,...e.map(t));return(0,I.jsxs)(Re,{delayDuration:150,children:[(0,I.jsx)(`div`,{className:`flex h-20 items-end gap-0.5`,role:`group`,"aria-label":`Daily trend`,children:e.map(e=>{let o=t(e),s=Math.max(o>0?4:0,o/a*100);return(0,I.jsxs)(ze,{children:[(0,I.jsx)(Ie,{asChild:!0,children:(0,I.jsx)(`button`,{"data-export-keep":!0,"aria-label":i(e),type:`button`,className:`min-w-0 flex-1 rounded-t-sm transition-opacity hover:opacity-80 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring`,style:{height:`100%`,display:`flex`,alignItems:`end`},children:(0,I.jsx)(`span`,{style:{height:`${s}%`},className:`block w-full rounded-t-sm ${n}`})})}),(0,I.jsx)(Le,{children:r(e)})]},e.date)})}),(0,I.jsxs)(`div`,{className:`mt-1 flex justify-between text-xs text-muted-foreground`,children:[(0,I.jsx)(`span`,{children:jn(e[0].date)}),(0,I.jsx)(`span`,{children:jn(e.at(-1).date)})]})]})}function Nn({metrics:e,series:t}){return(0,I.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,I.jsx)(`thead`,{children:(0,I.jsxs)(`tr`,{className:`border-b`,children:[(0,I.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Date`}),e.map(e=>(0,I.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:On[e]},e)),(0,I.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:`Completed`}),(0,I.jsx)(`th`,{className:`py-1 text-right font-medium`,children:`Avg cycle`})]})}),(0,I.jsx)(`tbody`,{children:t.map(t=>(0,I.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,I.jsx)(`td`,{className:`py-1 pr-2`,children:jn(t.date)}),e.map(e=>(0,I.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:An(t[Dn[e]]?.value,e)},e)),(0,I.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:t.completed}),(0,I.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.avgCycleHours===null?`—`:K(t.avgCycleHours)})]},t.date))})]})}function Pn({metric:e,series:t}){let n=pn[e],r=Dn[e],i=t.reduce((e,t)=>e+(t[r]?.reportedTasks??0),0);return(0,I.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium ${n.text}`,children:On[e]}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(Mn,{series:t,describe:t=>`${t.date}, ${On[e]}: ${An(t[r]?.value,e)}, ${t[r]?.reportedTasks??0} of ${t.tasks} tasks reported`,height:e=>e[r]?.value??0,accent:n.fill,renderTooltip:t=>(0,I.jsxs)(`p`,{children:[jn(t.date),` · `,An(t[r]?.value,e),` ·`,` `,t[r]?.reportedTasks??0,`/`,t.tasks,` tasks reported`]})})}),i===0&&(0,I.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No reports in this period.`})]})}function Fn({series:e}){let t=e.reduce((e,t)=>e+t.completed,0),n=e.reduce((e,t)=>e+(t.avgCycleHours??0)*(t.cycleReportedTasks??t.completed),0),r=e.reduce((e,t)=>e+(t.cycleReportedTasks??t.completed),0),i=r?n/r:null;return(0,I.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,I.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,I.jsx)(`p`,{className:`text-xs font-medium text-success`,children:`Completed tasks`}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` done · avg cycle`,` `,i===null?`unavailable`:K(i)]})]}),(0,I.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r,`/`,t,` completed tasks have valid cycle times.`]}),(0,I.jsx)(`div`,{className:`mt-2`,children:(0,I.jsx)(Mn,{series:e,describe:e=>`${e.date}: ${e.completed} completed tasks, average cycle ${e.avgCycleHours==null?`Unavailable`:K(e.avgCycleHours)}`,height:e=>e.completed,accent:`bg-success`,renderTooltip:e=>(0,I.jsxs)(`div`,{children:[(0,I.jsxs)(`p`,{children:[jn(e.date),` · `,e.completed,` completed`]}),(0,I.jsxs)(`p`,{children:[`Avg cycle`,` `,e.avgCycleHours===null?`unavailable`:K(e.avgCycleHours),` · Median`,` `,e.medianCycleHours===null?`unavailable`:K(e.medianCycleHours)]})]})})}),t===0&&(0,I.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No tasks finished in this period.`})]})}function In(){return(0,I.jsx)(Ln,{visibility:He(h().data)})}function Ln({visibility:e}){let[t,n]=vt(`trendPeriod`,[`7d`,`30d`],`7d`),r=dn(t,e.cost?`cost`:`input`,`${e.cost}:${e.tokens}`),i=r.data,a=i&&i.totals.tasks===0&&i.coverage.projects.every(e=>e.state===`complete`)&&i.series.every(e=>e.tasks===0&&e.completed===0),o=kn({cost:e.cost&&i?.visibility.cost!==!1,tokens:e.tokens&&i?.visibility.tokens!==!1});return(0,I.jsxs)(M,{className:`gap-0 py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsx)(`h2`,{className:R,children:`Trends`}),(0,I.jsxs)(`label`,{className:et,children:[`Period`,(0,I.jsxs)(tt,{value:t,onChange:e=>n(e.target.value),children:[(0,I.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,I.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,I.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[i&&(0,I.jsx)(L,{rows:a?[]:i.series.flatMap(e=>[...o.map(t=>({section:`daily-creation-cohort`,entity:e.date,metric:Dn[t],value:e[Dn[t]]?.value??null,unit:t===`cost`?`USD`:`tokens`,reportedTasks:e[Dn[t]]?.reportedTasks??0,totalTasks:e.tasks,asOf:i.asOf,note:`Lifetime usage grouped by task creation date; not daily spend`})),{section:`daily-completions`,entity:e.date,metric:`completed`,value:e.completed,unit:`tasks`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`avgCycleHours`,value:e.avgCycleHours,reportedTasks:e.cycleReportedTasks??e.completed,totalTasks:e.completed,unit:`hours`,asOf:i.asOf},{section:`daily-completions`,entity:e.date,metric:`medianCycleHours`,value:e.medianCycleHours,unit:`hours`,asOf:i.asOf}])}),(0,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${$e} py-2`,children:[(0,I.jsx)(B,{}),`How these metrics work`]}),(0,I.jsx)(`p`,{children:`Usage is grouped by creation date, not spending date. Completed tasks are grouped by finish date. Calendar days use your current UTC offset (fixed across the period), including today.`})]}),r.isPending&&(0,I.jsx)(`p`,{children:`Loading trends…`}),r.isError&&(0,I.jsxs)(`p`,{role:`alert`,children:[i?`Showing stale trends. Could not refresh.`:`Could not load trends.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry`})]}),i&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,I.jsx)(it,{at:i.asOf})}),i&&(0,I.jsx)(G,{coverage:i.coverage,retry:()=>void r.refetch()}),i&&a&&(0,I.jsx)(`p`,{className:`text-muted-foreground`,children:`No retained tasks in this period yet.`}),i&&!a&&i.series.length>0&&(0,I.jsxs)(I.Fragment,{children:[(0,I.jsxs)(`div`,{className:`space-y-4`,children:[o.length>0&&(0,I.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))]`,children:o.map(e=>(0,I.jsx)(Pn,{metric:e,series:i.series},e))}),(0,I.jsx)(Fn,{series:i.series})]}),(0,I.jsxs)(`details`,{className:`group rounded-lg border bg-muted/20 print:block`,children:[(0,I.jsxs)(`summary`,{"data-export-heading":`Daily data`,className:`flex min-h-11 cursor-pointer list-none items-center gap-2 px-3 text-xs font-medium text-muted-foreground hover:text-foreground [&::-webkit-details-marker]:hidden`,children:[(0,I.jsx)(Ye,{className:`size-4`,"aria-hidden":`true`}),` View data table`,(0,I.jsx)(Fe,{className:`ml-auto size-4 transition-transform group-open:rotate-180`,"aria-hidden":`true`})]}),(0,I.jsx)(`div`,{className:`max-h-80 overflow-auto border-t p-3 print:max-h-none print:overflow-visible`,role:`region`,"aria-label":`Daily trend values`,tabIndex:0,children:(0,I.jsx)(Nn,{metrics:o,series:i.series})})]})]})]})]})}function Rn(e,t,n,r=!0){let i=c();return d({queryKey:[...X.snapshot,e?.snapshotId,t,n],enabled:r&&!!e,retry:!1,queryFn:async({signal:r})=>{if(!e)throw Error(`Dashboard not loaded`);let a=[];try{for(let i=0;i<n;){let o=await Zt(e.snapshotId,t,i,Math.min(20,n-i),r);if(a.push(...o.page.rows),o.page.nextOffset===null)break;i=o.page.nextOffset}return a}catch(e){if(e instanceof u&&e.status===409){let e=await Xt(r);i.setQueryData(X.snapshot,e)}throw e}}})}function zn(e,t,n,r){let i=c(),a=t===`questions`||t===`reviews`?`needs-you`:t,o=a===`needs-you`?0:n,s=r.map(e=>`${e.projectId}:${e.id}`).sort();return d({queryKey:[...X.snapshot,e.snapshotId,t,`displaced`,...s],enabled:s.length>0,retry:!1,queryFn:async({signal:t})=>{let n=new Set(s),r=new Map;try{for(let i=o;i!==null&&n.size;){let o=await Zt(e.snapshotId,a,i,20,t);for(let e of o.page.rows){let t=`${e.projectId}:${e.id}`;n.delete(t)&&r.set(t,e)}i=o.page.nextOffset}return r}catch(e){throw e instanceof u&&e.status===409&&i.setQueryData(X.snapshot,await Xt(t)),e}}})}function Bn({snapshot:e,questions:t,reviews:n,more:r,healthy:i=!0}){let a=ye();return(0,I.jsxs)(M,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,I.jsxs)(`div`,{className:z,children:[(0,I.jsxs)(`h2`,{id:`dashboard-needs-you`,tabIndex:-1,className:R,children:[`Needs you · `,e.counts.questions+e.counts.reviews]}),(0,I.jsxs)(`p`,{className:`font-mono text-[11px] text-soft-foreground`,children:[e.counts.questions,` questions · `,e.counts.reviews,` reviews`]})]}),i&&a.connected&&e.counts.questions+e.counts.reviews===0&&e.coverage.projects.every(e=>e.state===`complete`)?(0,I.jsxs)(`p`,{className:`flex items-center gap-2.5 px-4 py-8 text-sm text-muted-foreground`,children:[(0,I.jsx)(N,{tone:`success`}),`All caught up — no tasks need your input`]}):null,(0,I.jsx)(Vn,{snapshot:e,group:`questions`,count:t,more:r}),(0,I.jsx)(Vn,{snapshot:e,group:`reviews`,count:n,more:r})]})}function Vn({snapshot:e,group:t,count:n,more:r}){let i=e[t],a=Math.max(n,i.rows.length),o=Rn(e,t,a,a>i.rows.length),s=a>i.rows.length?o.data:i.rows,c=ut(s,W,t,n),l=zn(e,t,a,c.rows.filter(e=>e.removed).map(e=>e.row)),u=(0,F.useRef)(null);return!i.total&&!c.rows.length?null:(0,I.jsxs)(`section`,{children:[(0,I.jsxs)(`h3`,{ref:u,tabIndex:-1,className:`border-b bg-card-2 px-4 py-2 font-mono text-[11px] font-semibold uppercase tracking-[0.12em] text-muted-foreground`,children:[t===`questions`?`Questions`:`Reviews`,` · `,i.total]}),c.updates>0&&(0,I.jsxs)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>{c.show(),u.current?.focus()},children:[c.updates,` updates — Show`]}),c.rows.map(({row:e,removed:t})=>(0,I.jsx)(gt,{row:l.data?.get(W(e))??e,removed:t&&!!l.data&&!l.data.has(W(e)),checking:s===void 0||t&&!l.data,checkFailed:s===void 0&&o.isError||t&&!l.data&&l.isError,queue:!0},W(e))),(o.isError||l.isError)&&(0,I.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not check current task state.`,` `,(0,I.jsx)(w,{variant:`ghost`,className:`min-h-11`,onClick:()=>{o.refetch(),l.refetch()},children:`Retry`})]}),a<i.total&&(0,I.jsxs)(w,{variant:`ghost`,className:`m-2 min-h-11`,disabled:o.isFetching,onClick:()=>r(t,a+Math.min(20,i.total-a)),children:[`Show `,Math.min(20,i.total-a),` more `,t]})]})}function Hn(e){if(!e.startsWith(`github:`))return e===`tasks`?`Task results`:e;let t=e.slice(7).split(`:`),n=t.pop()===`pr`?`Pull requests`:`Issues`;return`${t.join(`:`).replace(/^project:/,`Project `).replace(/^github.com\//,``)} · ${n}`}var Un=e=>e.key;function Wn({filter:e,setFilter:t,count:n,more:r}){let i=tn(e,!0),a=ut(i.data?.rows,Un,`feed:${e}`,0,e=>e.kind===`task-result`),o=a.rows,s=a.updates,c=(0,F.useContext)(ct),l=(0,F.useRef)(null),u=`feed:${e}`,d=(0,F.useMemo)(()=>({scroll:mt(c,u)?.scroll??0,done:!1}),[c,u]);(0,F.useLayoutEffect)(()=>{!l.current||d.done||(l.current.scrollTop=d.scroll,d.done=Math.abs(l.current.scrollTop-d.scroll)<1||!!i.data&&!i.isPending&&!i.isFetching)},[d,o.length,n,i.data,i.isPending,i.isFetching]);let f=(0,F.useRef)(null),p=i.data?.sources.filter(e=>e.key.startsWith(`github:`))??[],m=p.flatMap(e=>e.fetchedAt?[e.fetchedAt]:[]).sort()[0],h=i.githubError,g=p.filter(e=>e.reason===`No GitHub remote`),_=p.some(e=>e.reason===`Still loading GitHub`),v=p.length>0&&g.length===p.length&&!h,y=p.filter(e=>e.state!==`ready`&&e.reason!==`No GitHub remote`&&e.reason!==`Still loading GitHub`),b=v&&e===`all`;return(0,I.jsxs)(M,{"data-export-context":`Results source: ${e}; Last 7 days; loaded ${Math.min(n,o.length)} rows`,className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,I.jsxs)(`div`,{className:`space-y-2 border-b px-4 pt-2.5 pb-2`,children:[(0,I.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-2`,children:[(0,I.jsx)(`h2`,{ref:f,tabIndex:-1,className:R,children:b?`Recent results`:`Recent results & GitHub`}),(0,I.jsx)(`span`,{className:`font-mono text-[11px] text-soft-foreground`,children:`Last 7 days`})]}),!b&&(0,I.jsx)(pe,{slot:`dashboard-feed`,label:`Results source`,value:e,options:[{value:`all`,label:`All`},{value:`tasks`,label:`Tasks`},{value:`github`,label:`GitHub`}],onChange:t}),b&&(0,I.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Task results · No GitHub repositories configured`}),e!==`tasks`&&!b&&(0,I.jsxs)(`details`,{className:`text-xs text-muted-foreground`,open:y.length||h?!0:void 0,children:[(0,I.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden py-1.5`,children:[(0,I.jsx)(B,{}),y.length||h?`GitHub needs attention`:_?`Checking GitHub…`:v?`GitHub not configured`:m?`GitHub checked ${P(m)} ago`:`GitHub source`]}),(0,I.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3`,children:[(0,I.jsx)(`p`,{children:y.length||h?m?`Could not refresh GitHub. Showing results from ${new Date(m).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`})}.`:`Could not load one or more GitHub sources.`:_?`Checking repository sources. Available results remain visible.`:v?`No GitHub repositories configured. Select Tasks to see task results.`:m?`GitHub checked ${P(m)} ago`:`GitHub snapshot`}),!v&&(0,I.jsx)(w,{variant:`ghost`,className:`min-h-11 px-0`,disabled:i.githubFetching,onClick:()=>{i.refetch()},children:i.githubFetching?`Refreshing…`:y.length||h?`Retry GitHub`:`Refresh GitHub`})]})]})]}),(0,I.jsxs)(`div`,{role:`region`,"aria-label":`Recent results list`,ref:l,onWheel:()=>{d.done=!0},onTouchStart:()=>{d.done=!0},onKeyDown:()=>{d.done=!0},onScroll:e=>{c&&d.done&&ht(c,u,{count:n,scroll:e.currentTarget.scrollTop})},tabIndex:0,className:`max-h-80 overflow-y-auto overscroll-contain focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring`,children:[i.isError&&(0,I.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not load results.`,` `,(0,I.jsx)(w,{className:`min-h-11`,onClick:()=>{i.retryFailed()},children:`Retry`})]}),i.isPending&&(0,I.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading results…`}),s>0&&(0,I.jsxs)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>{a.show(),f.current?.focus()},children:[s,` updates — Show`]}),o.slice(0,n).map(({row:e,removed:t})=>e.kind===`task-result`?(0,I.jsx)(gt,{row:e.run,kicker:t?`Outside current results`:`Latest result: ${e.run.status===`failed`?`Failed`:`Completed`}`},e.key):(0,I.jsxs)(`div`,{className:`border-b px-4 py-3 transition-colors hover:bg-muted/30`,children:[(0,I.jsx)(L,{rows:[{section:`github`,entity:`${e.repo}#${e.number}`,metric:e.itemKind,value:e.title,asOf:e.at,note:e.url}]}),(0,I.jsx)(`a`,{className:`block break-words text-sm font-medium hover:underline no-hover:min-h-11`,href:e.url,target:`_blank`,rel:`noreferrer`,children:e.title}),(0,I.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.repo,` · `,e.itemKind===`pr`?`PR`:`Issue`,` #`,e.number,` created ·`,` `,P(e.at)]})]},e.key)),i.data&&!i.data.rows.length&&!o.length&&!i.isFetching&&!i.isError&&!y.length&&!_&&i.data.coverage.projects.every(e=>e.state===`complete`)&&(0,I.jsx)(`p`,{className:`px-4 py-8 text-sm text-muted-foreground`,children:`No results in the last 7 days`}),n<o.length&&(0,I.jsxs)(w,{variant:`ghost`,className:`m-2 min-h-11`,onClick:r,children:[`Show `,Math.min(20,o.length-n),` more results`]}),i.data?.truncated&&(0,I.jsx)(`p`,{className:`p-4 text-xs`,children:`Showing the latest 60 results`}),i.data&&(0,I.jsx)(G,{coverage:i.data.coverage,retry:()=>{i.retryTasks()}}),!b&&i.data?.sources.some(e=>e.state!==`ready`||e.truncated)&&(0,I.jsxs)(`details`,{className:`p-4 text-xs`,children:[(0,I.jsxs)(`summary`,{className:`flex w-fit cursor-pointer list-none items-center gap-1.5 rounded-sm text-muted-foreground transition-colors select-none hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/50 [&::-webkit-details-marker]:hidden min-h-11`,children:[(0,I.jsx)(B,{}),`Source details`]}),i.data.sources.map(e=>(0,I.jsxs)(`p`,{className:`break-words py-1`,children:[Hn(e.key),`:`,` `,e.reason===`No GitHub remote`?`Not configured`:e.reason===`Still loading GitHub`?`Checking…`:e.reason??(e.state===`ready`?`Up to date`:e.state),e.truncated?` · capped`:``,e.fetchedAt?` · checked ${P(e.fetchedAt)}`:``]},e.key))]})]})]})}var $=e=>e.replace(/[&<>"']/g,e=>({"&":`&`,"<":`<`,">":`>`,'"':`"`,"'":`'`})[e]),Gn=`Visible modules and loaded rows only. Filters and report availability apply. Retained task usage is not an invoice or a complete history.`,Kn=`Confidential — internal distribution only`,qn={costUsd:{label:`Reported cost`,usd:!0},inputTokens:{label:`Input tokens`},outputTokens:{label:`Output tokens`},needsYou:{label:`Needs you`},running:{label:`Running now`},completed:{label:`Completed in period`},failed:{label:`Failed outcomes in period`},medianCycleHours:{label:`Median cycle (hours)`}};function Jn(e,t){return e==null?`Unavailable`:typeof e==`string`?e:_t(e,t)}function Yn(e){let t=new Set,n=[];for(let r of e.modules)for(let e of r.rows){if(e.section!==`totals`&&e.section!==`fleet`&&e.section!==`overview`)continue;let i=qn[e.metric];!i||t.has(e.metric)||(t.add(e.metric),n.push({label:i.label,value:Jn(e.value,i.usd),note:[e.metric===`needsYou`||e.metric===`running`?e.note||`Current non-archived state`:r.filters,e.asOf?`Data as of ${e.asOf}`:``,e.reportedTasks==null?``:`${e.reportedTasks} of ${e.totalTasks} tasks reported`].filter(Boolean).join(` · `)}))}return n}function Xn(e){let t=e.cloneNode(!0);t.querySelectorAll(`script,style,link,img,iframe,object,embed,input,[hidden],[data-dashboard-export],[data-export-exclude]`).forEach(e=>e.remove()),t.querySelectorAll(`select`).forEach((t,n)=>{let r=e.querySelectorAll(`select`)[n];t.replaceWith(document.createTextNode(`: `+(r?.selectedOptions[0]?.textContent??``)))}),t.querySelectorAll(`[data-export-row],[data-dashboard-row]`).forEach(e=>e.classList.add(`report-row`)),t.querySelectorAll(`summary`).forEach(e=>{let t=document.createElement(`h3`);t.textContent=e.getAttribute(`data-export-heading`)||e.textContent,e.replaceWith(t)}),t.querySelectorAll(`button`).forEach(e=>{if(e.hasAttribute(`data-export-keep`)){let t=document.createElement(`div`);for(let n of[...e.attributes])[`class`,`style`,`title`].includes(n.name)&&t.setAttribute(n.name,n.value);t.append(...e.childNodes),e.replaceWith(t)}else e.remove()}),t.querySelectorAll(`details`).forEach(e=>{let t=document.createElement(`div`);t.className=e.className,t.append(...e.childNodes),e.replaceWith(t)});for(let e of[t,...t.querySelectorAll(`*`)])for(let t of[...e.attributes])(t.name.startsWith(`on`)||[`href`,`src`,`srcset`,`action`,`formaction`,`tabindex`].includes(t.name)||t.name.startsWith(`data-`))&&e.removeAttribute(t.name);return t.removeAttribute(`style`),t.innerHTML}function Zn(e,t,n,r){return{generatedAt:t,source:n,title:r||void 0,notices:[...e.querySelectorAll(`[role=alert],[role=status]`)].filter(e=>!e.closest(`[data-dashboard-module]`)).map(e=>e.textContent?.trim()??``).filter(Boolean),modules:[...e.querySelectorAll(`[data-dashboard-module]`)].map(e=>{let t=[...e.querySelectorAll(`select`)].map(e=>`${e.closest(`label`)?.childNodes[0]?.textContent?.trim()??`Filter`}: ${e.selectedOptions[0]?.textContent}`).concat([...e.querySelectorAll(`[data-export-context]`)].map(e=>e.dataset.exportContext)).join(`; `),n=[...new Set([...e.querySelectorAll(`p,[role="alert"],[role="status"]`)].filter(e=>!e.closest(`table,[data-export-exclude]`)&&!e.querySelector(`p,[role="alert"],[role="status"]`)).map(e=>{let t=e.cloneNode(!0);return t.querySelectorAll(`table,button,select,summary,[data-export-exclude]`).forEach(e=>e.remove()),t.textContent?.trim()}).filter(Boolean))].join(` | `);return{id:e.dataset.dashboardModule,title:e.querySelector(`h2`)?.textContent??e.dataset.dashboardModule,filters:t,notes:n,html:Xn(e),rows:[...e.querySelectorAll(`[data-dashboard-export]`)].flatMap(e=>JSON.parse(e.dataset.dashboardExport))}})}}function Qn(e){let t=e==null?``:String(e);return typeof e==`string`&&/^[\s\uFEFF]*[=+@\-]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function $n(e){let t=[[`generated_at`,`source`,`module`,`filters`,`section`,`entity`,`metric`,`value`,`unit`,`availability`,`reported_tasks`,`total_tasks`,`as_of`,`notes`]];for(let n of e.modules){t.push([e.generatedAt,e.source,n.title,n.filters,`context`,``,`scope`,Gn,``,``,``,``,``,[...e.title?[`Report title: ${e.title}`]:[],...e.notices,n.notes].join(` | `)]);for(let r of n.rows)t.push([e.generatedAt,e.source,n.title,n.filters,r.section,r.entity,r.metric,r.value,r.unit,r.value===null?`unavailable`:typeof r.value==`number`?`measured`:`reported`,r.reportedTasks,r.totalTasks,r.asOf,r.note])}return``+t.map(e=>e.map(Qn).join(`,`)).join(`\r
|
|
2
2
|
`)+`\r
|
|
3
3
|
`}function er(e,t){let n=Yn(e);return`<!doctype html><html class="light"><head><meta charset="utf-8"><title>${$(e.title||`Dashboard`)} ${$(e.generatedAt.slice(0,10))}</title>${t.join(``)}<style>
|
|
4
4
|
@page {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-
|
|
2
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-DqWj0yYe.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/button-Clwd6u4_.js","assets/bundle-mjs-BT31bpU6.js","assets/chevron-right-VbYrJ_st.js","assets/use-submit-shortcut-hAaAH4HY.js","assets/plus-CBVm02wz.js","assets/diff-stat-CiWUpWY0.js","assets/chunk-BO2N2NFS-MDrqQfMl.js","assets/lib-BxQXEXDF.js","assets/markdown-Rbaca31B.js","assets/alert-dialog-DvPnvVvK.js","assets/scroll-within-Cm6fjjNd.js","assets/markdown-BzqT8I8y.js","assets/message-square-EWpWB_Gr.js","assets/types-BTlmexWF.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{r}from"./button-Clwd6u4_.js";import{i}from"./bundle-mjs-BT31bpU6.js";import{t as a}from"./diff-stat-CiWUpWY0.js";import{i as o,n as s,r as c,t as l}from"./scroll-within-Cm6fjjNd.js";var u=e(t(),1),d=n(),f=null,p=null;function m(){return p??=i(()=>import(`./diff-view-DqWj0yYe.js`).then(e=>f={View:e.DiffView},()=>(p=null,`failed`)),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16])),p}function h(e){let[t,n]=(0,u.useState)(f);return(0,u.useEffect)(()=>{if(f)return;let e=!1;return m().then(t=>{e||n(t)}),()=>{e=!0}},[]),e.files.length===0?(0,d.jsx)(`p`,{"data-slot":`diff-empty`,className:r(`px-1 text-xs text-soft-foreground`,e.className),children:`No changes.`}):t===`failed`?(0,d.jsx)(g,{...e}):t===null?(0,d.jsx)(`p`,{"data-slot":`diff-loading`,className:r(`px-1 text-xs text-soft-foreground`,e.className),children:`Loading diff…`}):(0,d.jsx)(t.View,{...e})}function g({files:e,wrap:t=!1,imageSrc:n,onOpenInApp:i,viewRef:o,className:c}){let f={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},p=(0,u.useRef)(null);return(0,u.useImperativeHandle)(o,()=>({scrollToPath:e=>{for(let t of p.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){let e=l(t);e&&s(e,t,Number.parseFloat(getComputedStyle(t).scrollMarginTop)||0);return}}})),(0,d.jsxs)(`div`,{ref:p,"data-slot":`diff`,"data-fallback":`true`,className:r(`flex min-w-0 flex-col gap-3`,c),children:[(0,d.jsxs)(`p`,{"data-slot":`diff-totals`,className:`flex items-center gap-2 px-1 text-xs text-muted-foreground`,children:[(0,d.jsxs)(`span`,{children:[f.files,` `,f.files===1?`file`:`files`,` changed`]}),(0,d.jsx)(a,{stat:f})]}),e.map(e=>(0,d.jsx)(_,{file:e,wrap:t,imageSrc:n,onOpenInApp:i},`${e.oldPath??``}→${e.path}`))]})}function _({file:e,wrap:t,imageSrc:n,onOpenInApp:i}){return(0,d.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 scroll-mt-[var(--diff-sticky-top,0px)] overflow-clip rounded-md border border-border bg-card`,children:[(0,d.jsxs)(`header`,{className:`flex items-center gap-2 border-b border-border/50 px-3 py-2`,children:[(0,d.jsx)(`span`,{"data-slot":`diff-file-path`,className:`min-w-0 truncate font-mono text-xs font-medium`,children:e.oldPath?`${e.oldPath} → ${e.path}`:e.path}),(0,d.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,d.jsx)(a,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-[11px]`})})]}),o(e)?(0,d.jsx)(c,{file:e,imageSrc:n,onOpenInApp:i}):e.binary?(0,d.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,d.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-soft-foreground`,children:`No content changes (metadata only).`}):(0,d.jsx)(`pre`,{className:r(`py-2 font-mono text-xs leading-[1.7]`,t?`break-words whitespace-pre-wrap`:`overflow-x-auto whitespace-pre`),children:e.patch.split(`
|
|
3
3
|
`).map((e,t)=>(0,d.jsxs)(`span`,{className:r(`block px-4`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-diff-add`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-soft-foreground`),children:[e,e===``?` `:``]},t))})]})}export{h as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./react-runtime-CCIEwYL0.js";import{r as t}from"./button-
|
|
1
|
+
import{t as e}from"./react-runtime-CCIEwYL0.js";import{r as t}from"./button-Clwd6u4_.js";var n=e();function r({stat:e,className:r}){let i=`+${e.adds} −${e.dels} across ${e.files} ${e.files===1?`file`:`files`}`,a=e.repointed?`${i} — measured against another branch checked out in this task's worktree, as this task found it`:void 0;return(0,n.jsxs)(`span`,{"data-slot":`diff-stat`,...a?{"data-repointed":`true`,"aria-label":a}:{},title:a??i,className:t(`font-mono text-xs font-semibold tabular-nums`,e.repointed&&`cursor-help underline decoration-dotted underline-offset-2`,r),children:[(0,n.jsxs)(`span`,{className:`text-success`,children:[`+`,e.adds]}),` `,(0,n.jsxs)(`span`,{className:`text-danger`,children:[`−`,e.dels]})]})}export{r as t};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{F as r,r as i,t as a}from"./button-
|
|
1
|
+
import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{F as r,r as i,t as a}from"./button-Clwd6u4_.js";import{t as o}from"./chevron-right-VbYrJ_st.js";import{r as s,t as c}from"./use-submit-shortcut-hAaAH4HY.js";import{t as l}from"./plus-CBVm02wz.js";import{t as u}from"./diff-stat-CiWUpWY0.js";import{o as d}from"./chunk-BO2N2NFS-MDrqQfMl.js";import{a as f,o as p,r as m,t as h}from"./markdown-Rbaca31B.js";import{i as g,n as _,o as v,r as ee,t as y}from"./scroll-within-Cm6fjjNd.js";import{n as te,t as ne}from"./markdown-BzqT8I8y.js";import{n as b,t as x}from"./types-BTlmexWF.js";var S=r(`message-square-off`,[[`path`,{d:`M19 19H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.7.7 0 0 1 2 21.286V5a2 2 0 0 1 1.184-1.826`,key:`1wyg69`}],[`path`,{d:`m2 2 20 20`,key:`1ooewy`}],[`path`,{d:`M8.656 3H20a2 2 0 0 1 2 2v11.344`,key:`mhl4k6`}]]),C=e(t(),1),w=20.4,re=44;function T(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
|
|
2
2
|
`),n=t.findIndex(e=>e.startsWith(`@@`));return n===-1?t.length:t.length-n}function ie(e,t=!0){return Math.round((t?T(e):1)*w)+re}function ae(e){return e.reduce((e,t)=>e+T(t),0)}var E=/(^|\/)(package-lock\.json|npm-shrinkwrap\.json|yarn\.lock|pnpm-lock\.yaml|bun\.lockb?|Cargo\.lock|poetry\.lock|uv\.lock|composer\.lock|Gemfile\.lock|go\.sum)$|\.min\.(js|css)$|\.map$/;function oe(e){return e.binary===!0||e.image===!0?!1:e.adds+e.dels>400||E.test(e.path)}function se(e,t){let n=new URLSearchParams(e).get(`diff`);return n===`flat`||n===`virtual`?n:t>1500?`virtual`:`flat`}function D(e){return`${e.oldPath??``}→${e.path}`}function O(e){let t=0;for(let n of e.split(`
|
|
3
3
|
`))n.length>t&&(t=n.length);return t}function k(e,t){let n=Array(e.length);for(let r of B(e)){let i=[e=>e.kind!==`add`,e=>e.kind!==`del`];for(let a of i){let i=r.filter(t=>a(e[t]));if(i.length===0)continue;let o=t(i.map(t=>e[t].text).join(`
|
|
4
4
|
`));if(!o)return null;i.forEach((t,r)=>{n[t]=o.tokens[r]??[{content:e[t].text}]})}}return n}var A=2e6,j=new Map,M=0;function N(e,t){let n=e;for(let e of t)n+=`\n${e.kind[0]}${e.oldLine??``},${e.newLine??``}\t${e.text}`;return n}function P(e){let t=j.get(e);return t!==void 0&&(j.delete(e),j.set(e,t)),t}function F(e,t){if(!(e.length>A/4||j.has(e))){j.set(e,t),M+=e.length;for(let e of j.keys()){if(M<=A)break;M-=e.length,j.delete(e)}}}var I=8,L=[],R=!1;function z(){let e=performance.now();for(;L.length>0&&performance.now()-e<I;){let e=L.shift();e.cancelled||e.run()}L.length>0?setTimeout(z,0):R=!1}function ce(e){let t={run:e,cancelled:!1};return L.push(t),R||(R=!0,setTimeout(z,0)),()=>{t.cancelled=!0}}function B(e){let t=[],n=[],r,i;return e.forEach((e,a)=>{!(n.length>0&&(e.oldLine===void 0||r===void 0||e.oldLine===r+1)&&(e.newLine===void 0||i===void 0||e.newLine===i+1))&&n.length>0&&(t.push(n),n=[],r=void 0,i=void 0),n.push(a),e.oldLine!==void 0&&(r=e.oldLine),e.newLine!==void 0&&(i=e.newLine)}),n.length>0&&t.push(n),t}var V=/[A-Za-z0-9_]+|\s+|[^\sA-Za-z0-9_]+/g,H=300,U=.3;function le(e,t){if(e===t)return null;let n=e.match(V)??[],r=t.match(V)??[];if(n.length===0||r.length===0||n.length>H||r.length>H)return null;let i=r.length+1,a=new Uint16Array((n.length+1)*i);for(let e=1;e<=n.length;e++)for(let t=1;t<=r.length;t++)a[e*i+t]=n[e-1]===r[t-1]?(a[(e-1)*i+(t-1)]??0)+1:Math.max(a[(e-1)*i+t]??0,a[e*i+(t-1)]??0);if((a[n.length*i+r.length]??0)/Math.max(n.length,r.length)<U)return null;let o=Array(n.length).fill(!1),s=Array(r.length).fill(!1),c=n.length,l=r.length;for(;c>0&&l>0;)n[c-1]===r[l-1]?(o[c-1]=!0,s[l-1]=!0,c--,l--):(a[(c-1)*i+l]??0)>=(a[c*i+(l-1)]??0)?c--:l--;return{del:ue(n,o),add:ue(r,s)}}function ue(e,t){let n=[];return e.forEach((e,r)=>{let i=!(t[r]??!1),a=n[n.length-1];a&&a.changed===i?a.text+=e:n.push({text:e,changed:i})}),n}function de(e,t,n){if(!t||t.length===0)return e?e.map(e=>({text:e.content,color:e.color,changed:!1})):n===``?[]:[{text:n,changed:!1}];if(!e||e.length===0)return t.map(e=>({text:e.text,changed:e.changed}));let r=[],i=0,a=0,o=0,s=0;for(;i<e.length&&o<t.length;){let n=e[i],c=t[o],l=n.content.length-a,u=c.text.length-s,d=Math.min(l,u);d>0&&(r.push({text:n.content.slice(a,a+d),color:n.color,changed:c.changed}),a+=d,s+=d),n.content.length-a<=0&&(i++,a=0),c.text.length-s<=0&&(o++,s=0)}for(;i<e.length;){let t=e[i],n=t.content.slice(a);n!==``&&r.push({text:n,color:t.color,changed:!1}),i++,a=0}return r}var fe=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,W=`… (patch truncated)`;function G(e){let t=[],n=!1,r=null,i=0,a=0,o=e.split(`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e}from"./button-
|
|
1
|
+
import{F as e}from"./button-Clwd6u4_.js";var t=e(`download`,[[`path`,{d:`M12 15V3`,key:`m9g1x1`}],[`path`,{d:`M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4`,key:`ih7n3h`}],[`path`,{d:`m7 10 5 5 5-5`,key:`brsn70`}]]);export{t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{F as e}from"./button-
|
|
1
|
+
import{F as e}from"./button-Clwd6u4_.js";var t=e(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),n=e(`file`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}]]);export{t as n,n as t};
|