@open-mercato/cezar 0.18.0 → 0.19.0-pr1815.4229

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (122) hide show
  1. package/dist/automations/automation-cli.js +12 -6
  2. package/dist/automations/automation-cli.js.map +1 -1
  3. package/dist/automations/prompts.js +3 -1
  4. package/dist/automations/prompts.js.map +1 -1
  5. package/dist/automations/schedule-runner.js +18 -4
  6. package/dist/automations/schedule-runner.js.map +1 -1
  7. package/dist/automations/store.js +9 -2
  8. package/dist/automations/store.js.map +1 -1
  9. package/dist/automations/templates.js +1 -0
  10. package/dist/automations/templates.js.map +1 -1
  11. package/dist/automations/types.d.ts +28 -0
  12. package/dist/automations/types.js +6 -2
  13. package/dist/automations/types.js.map +1 -1
  14. package/dist/contract/automation-schedule.d.ts +28 -0
  15. package/dist/contract/automations.d.ts +126 -0
  16. package/dist/contract/github.d.ts +56 -0
  17. package/dist/contract/index.js +63 -0
  18. package/dist/contract/workspace.d.ts +18 -0
  19. package/dist/server/forge/github-issue-metadata.d.ts +6 -0
  20. package/dist/server/forge/github-issue-metadata.js +66 -0
  21. package/dist/server/forge/github-issue-metadata.js.map +1 -0
  22. package/dist/server/forge/github.d.ts +1 -1
  23. package/dist/server/forge/github.js +38 -4
  24. package/dist/server/forge/github.js.map +1 -1
  25. package/dist/server/forge/types.d.ts +2 -17
  26. package/dist/server/server.d.ts +320 -36
  27. package/dist/server/server.js +21 -20
  28. package/dist/server/server.js.map +1 -1
  29. package/dist/workflows/run.js +7 -0
  30. package/dist/workflows/run.js.map +1 -1
  31. package/package.json +3 -3
  32. package/web/dist/assets/{agent-task-pickers-DbNIzx20.js → agent-task-pickers-_i7QNEVz.js} +1 -1
  33. package/web/dist/assets/{alert-dialog-4Kna6Hd7.js → alert-dialog-BZU09BVw.js} +1 -1
  34. package/web/dist/assets/arrow-down-BQxdXW9w.js +1 -0
  35. package/web/dist/assets/arrow-left-CvmEanh8.js +1 -0
  36. package/web/dist/assets/automation-format-CEBKDGz8.js +1 -0
  37. package/web/dist/assets/automations-route-Cg1sWvtN.js +1 -0
  38. package/web/dist/assets/button-BvYDiOkd.js +100 -0
  39. package/web/dist/assets/{centered-state-D-wDs7Y1.js → centered-state-Bpq40Y_t.js} +1 -1
  40. package/web/dist/assets/check-DC3eAaS2.js +1 -0
  41. package/web/dist/assets/chevron-left-BW4WDtiS.js +1 -0
  42. package/web/dist/assets/chevron-right-DuM1UAhq.js +1 -0
  43. package/web/dist/assets/circle-check-DiPv45P_.js +1 -0
  44. package/web/dist/assets/{clipboard-DQGL_gUp.js → clipboard-7kWKIj7k.js} +1 -1
  45. package/web/dist/assets/{collapsible-D7qsttC5.js → collapsible-OE3rGS50.js} +1 -1
  46. package/web/dist/assets/{commit-list-DTMGEn0-.js → commit-list-DalU6p3i.js} +1 -1
  47. package/web/dist/assets/{compare-variants-DqlkpLFs.js → compare-variants-CuCfgtyG.js} +1 -1
  48. package/web/dist/assets/dashboard-BYBop-ZJ.js +44 -0
  49. package/web/dist/assets/{diff-DY-_mmb0.js → diff-DfTKq2z2.js} +2 -2
  50. package/web/dist/assets/{diff-view-oTEcZZ_O.js → diff-view-Du2463vL.js} +1 -1
  51. package/web/dist/assets/{download-BBtWFvsh.js → download-_KH0gJo8.js} +1 -1
  52. package/web/dist/assets/facet-filter-BSS2vFA8.js +5 -0
  53. package/web/dist/assets/{file-CbWEaOku.js → file-d2ABwdSR.js} +1 -1
  54. package/web/dist/assets/file-preview-BURiO97x.js +2 -0
  55. package/web/dist/assets/{git-pull-request-draft-Dwhm6Vhn.js → git-pull-request-draft-DIdbQZ0O.js} +1 -1
  56. package/web/dist/assets/git-tab-loading-8Y0ID8J2.js +1 -0
  57. package/web/dist/assets/{git-toolbar-C3vpZJaZ.js → git-toolbar-CSrf6Ux9.js} +1 -1
  58. package/web/dist/assets/github-DQ8J0EYw.js +1 -0
  59. package/web/dist/assets/{host-usage-CI_ZlJQu.js → host-usage-EK6T4fAW.js} +1 -1
  60. package/web/dist/assets/{icon-tooltip-CgAWLDxo.js → icon-tooltip-nRvCJxOH.js} +1 -1
  61. package/web/dist/assets/index-BVPhzJ3k.js +31 -0
  62. package/web/dist/assets/index-HmrjUHlJ.css +2 -0
  63. package/web/dist/assets/{input-Br4NQpZK.js → input-90eli0Uk.js} +1 -1
  64. package/web/dist/assets/{layout-cards-fdJa2H62.js → layout-cards-n-2Pwe6c.js} +1 -1
  65. package/web/dist/assets/{lib-w_5wfsBF.js → lib-C4vuyY62.js} +1 -1
  66. package/web/dist/assets/loader-circle-DAforPX2.js +1 -0
  67. package/web/dist/assets/{markdown-G3dvGJao.js → markdown-BBnagS_c.js} +1 -1
  68. package/web/dist/assets/{markdown-BfZORc0a.js → markdown-DLB6o6YD.js} +1 -1
  69. package/web/dist/assets/{message-square-Dl-ol3uz.js → message-square-WCEmfkiD.js} +1 -1
  70. package/web/dist/assets/plus-BJEPAJjW.js +1 -0
  71. package/web/dist/assets/{project-router-DgQSavhI.js → project-router-7DKoABD3.js} +1 -1
  72. package/web/dist/assets/queries-DsfjHsrp.js +1 -0
  73. package/web/dist/assets/{reference-chip-BxUGeHDa.js → reference-chip-frnxjI-K.js} +1 -1
  74. package/web/dist/assets/repo-git-DVREyQYa.js +1 -0
  75. package/web/dist/assets/{run-diff-CqXLVaDj.js → run-diff-CmqQmGTJ.js} +1 -1
  76. package/web/dist/assets/{save-ByUa-aAl.js → save-CCb1fwTJ.js} +1 -1
  77. package/web/dist/assets/{scroll-within-Dexi68h1.js → scroll-within-CNcaqKGp.js} +1 -1
  78. package/web/dist/assets/{search-x-CLuL49ms.js → search-x-Cm22V3TC.js} +1 -1
  79. package/web/dist/assets/{settings-2-BvalJGW-.js → settings-2-CWK1otJs.js} +1 -1
  80. package/web/dist/assets/skills-B0OolFqS.js +1 -0
  81. package/web/dist/assets/{square-FwRsgrg-.js → square-B-gfdc5r.js} +1 -1
  82. package/web/dist/assets/{tabs-nC1VLjcX.js → tabs-D3hCl7A6.js} +1 -1
  83. package/web/dist/assets/{tag-CteJEZQp.js → tag-C5TeSwBA.js} +1 -1
  84. package/web/dist/assets/{task-commits-CYcqwz-f.js → task-commits-DIrIWA6g.js} +1 -1
  85. package/web/dist/assets/{task-graph-CJfTnzUp.js → task-graph-Diq4xAP_.js} +1 -1
  86. package/web/dist/assets/{task-notes-DxH2q3Hr.js → task-notes-DnIcoZgS.js} +1 -1
  87. package/web/dist/assets/task-workspace-DhUBQLGl.js +29 -0
  88. package/web/dist/assets/{terminal-aoRx5eKS.js → terminal-BIKtPgmL.js} +1 -1
  89. package/web/dist/assets/{terminal-drawer-CuGVJS-l.js → terminal-drawer-f0Tw3yHw.js} +2 -2
  90. package/web/dist/assets/{textarea-X_NVmVlZ.js → textarea-D6BGJB7j.js} +1 -1
  91. package/web/dist/assets/{token-metrics-CdH7TbLP.js → token-metrics-CMdTXREP.js} +1 -1
  92. package/web/dist/assets/{tooltip-C2bzSwbQ.js → tooltip-Bb7ddw0_.js} +1 -1
  93. package/web/dist/assets/{tracker-BYs-vq6-.js → tracker-BDiIqG2R.js} +2 -2
  94. package/web/dist/assets/{triangle-alert-BdMPm9Jb.js → triangle-alert-BhQYv6Is.js} +1 -1
  95. package/web/dist/assets/{upload-DrvICo_K.js → upload-Crivm77f.js} +1 -1
  96. package/web/dist/assets/{use-now-Byfm730u.js → use-now-BW1HO2p_.js} +1 -1
  97. package/web/dist/assets/{use-submit-shortcut-B41NLqM4.js → use-submit-shortcut-oBvmLiAo.js} +1 -1
  98. package/web/dist/assets/{workflow-graph-ppdi5xyK.js → workflow-graph-DJLPSGD3.js} +3 -3
  99. package/web/dist/assets/{worktree-lifecycle-operation-CvU6xu3u.js → worktree-lifecycle-operation-DL-RTic4.js} +2 -2
  100. package/web/dist/index.html +39 -39
  101. package/dist/telemetry-service.json +0 -1
  102. package/web/dist/assets/arrow-left-B1Ed0tpu.js +0 -1
  103. package/web/dist/assets/automation-format-CXffJGqm.js +0 -1
  104. package/web/dist/assets/automations-route-ruFF7d59.js +0 -1
  105. package/web/dist/assets/button-wdWSPx_B.js +0 -100
  106. package/web/dist/assets/check-DvAMBXJe.js +0 -1
  107. package/web/dist/assets/chevron-left-Dqb1lvgZ.js +0 -1
  108. package/web/dist/assets/chevron-right-DDQuVTY1.js +0 -1
  109. package/web/dist/assets/circle-check-BiVc-j8x.js +0 -1
  110. package/web/dist/assets/dashboard-BX4228zB.js +0 -44
  111. package/web/dist/assets/facet-filter-B_AsFqFx.js +0 -5
  112. package/web/dist/assets/file-preview-DEKEA-Hk.js +0 -2
  113. package/web/dist/assets/git-tab-loading-w5Ne43J6.js +0 -1
  114. package/web/dist/assets/github-Hshin4wG.js +0 -1
  115. package/web/dist/assets/index-CQ1cB3qE.css +0 -2
  116. package/web/dist/assets/index-D-pGbO9R.js +0 -31
  117. package/web/dist/assets/loader-circle-CwT0JWiv.js +0 -1
  118. package/web/dist/assets/plus-BwQyZgNP.js +0 -1
  119. package/web/dist/assets/queries-BTgOLNTK.js +0 -1
  120. package/web/dist/assets/repo-git-B47L82oV.js +0 -1
  121. package/web/dist/assets/skills-Bu12y3Zp.js +0 -1
  122. package/web/dist/assets/task-workspace-7NHIdOyT.js +0 -29
@@ -0,0 +1 @@
1
+ import{F as e}from"./button-BvYDiOkd.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-BvYDiOkd.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{F as e}from"./button-wdWSPx_B.js";var t=e(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);async function n(e){let t=typeof navigator>`u`?void 0:navigator.clipboard;if(t?.writeText)try{await t.writeText(e);return}catch(t){if(r(e))return;throw t}if(!r(e))throw Error(`Clipboard unavailable`)}function r(e){if(typeof document>`u`||typeof document.execCommand!=`function`)return!1;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.position=`fixed`,n.style.top=`0`,n.style.left=`-9999px`,n.style.opacity=`0`,document.body.appendChild(n);try{return n.select(),n.setSelectionRange(0,e.length),document.execCommand(`copy`)}catch{return!1}finally{n.remove(),t?.focus()}}export{t as n,n as t};
1
+ import{F as e}from"./button-BvYDiOkd.js";var t=e(`x`,[[`path`,{d:`M18 6 6 18`,key:`1bl5f8`}],[`path`,{d:`m6 6 12 12`,key:`d8bk6v`}]]);async function n(e){let t=typeof navigator>`u`?void 0:navigator.clipboard;if(t?.writeText)try{await t.writeText(e);return}catch(t){if(r(e))return;throw t}if(!r(e))throw Error(`Clipboard unavailable`)}function r(e){if(typeof document>`u`||typeof document.execCommand!=`function`)return!1;let t=document.activeElement instanceof HTMLElement?document.activeElement:null,n=document.createElement(`textarea`);n.value=e,n.setAttribute(`readonly`,``),n.style.position=`fixed`,n.style.top=`0`,n.style.left=`-9999px`,n.style.opacity=`0`,document.body.appendChild(n);try{return n.select(),n.setSelectionRange(0,e.length),document.execCommand(`copy`)}catch{return!1}finally{n.remove(),t?.focus()}}export{t as n,n 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{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-wdWSPx_B.js";import{i as f,n as p}from"./token-metrics-CdH7TbLP.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
+ 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-BvYDiOkd.js";import{i as f,n as p}from"./token-metrics-CMdTXREP.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-wdWSPx_B.js";import{t as i}from"./project-router-DgQSavhI.js";import{t as a}from"./lib-w_5wfsBF.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-meta text-muted-foreground`,children:e.shaLabel}),(0,s.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-ui 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-micro`,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-meta text-soft-foreground sm:inline`,children:[e.author,` · `,e.when]})]})})}export{l as t};
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-BvYDiOkd.js";import{t as i}from"./project-router-7DKoABD3.js";import{t as a}from"./lib-C4vuyY62.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-meta text-muted-foreground`,children:e.shaLabel}),(0,s.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-ui 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-micro`,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-meta 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{Dn as r,Fa as i,M as a,Ma as o,Ot as s,Si as c,Vn as l,dn as u,er as d,j as f,r as p,sn as m}from"./queries-BTgOLNTK.js";import{r as h,t as g}from"./button-wdWSPx_B.js";import{c as _,f as v,t as y,w as b}from"./project-router-DgQSavhI.js";import{t as x}from"./check-DvAMBXJe.js";import{t as S}from"./chevron-right-DDQuVTY1.js";import{t as C}from"./search-x-CLuL49ms.js";import{i as w,n as T,o as E,r as D,t as O}from"./collapsible-D7qsttC5.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-4Kna6Hd7.js";import{t as L}from"./token-metrics-CdH7TbLP.js";import{t as R}from"./centered-state-D-wDs7Y1.js";import{t as z}from"./markdown-G3dvGJao.js";import{Z as B,b as V}from"./index-D-pGbO9R.js";import{t as H}from"./run-diff-CqXLVaDj.js";var U=e(t(),1),W=n();function G(){let{groupId:e}=b(),t=f(e),n=L(a().data),r=i();if((0,U.useEffect)(()=>{e&&r.invalidateQueries({queryKey:p.groups.detail(e)})},[r,e,(s().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 d&&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:a}){let s=_(),l=i(),[u,d]=(0,U.useState)(null),f=t.every(e=>m.has(e.status)),g=t[0]?r(t[0]):``,y=o({mutationFn:t=>c(e,t),onSuccess:(t,n)=>{l.invalidateQueries({queryKey:p.runs.all}),l.invalidateQueries({queryKey:p.groups.detail(e)}),s(`/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-ui 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:f,pickPending:y.isPending,onPick:()=>d(e),showTokens:n,showCost:a},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:u!==null,onOpenChange:e=>!e&&d(null),children:(0,W.jsxs)(j,{children:[(0,W.jsxs)(F,{children:[(0,W.jsxs)(A,{children:[`Pick variant `,u?.variant,`?`]}),(0,W.jsxs)(k,{children:[`Variant `,u?.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:()=>{u&&y.mutate(u.id),d(null)},children:[(0,W.jsx)(x,{"aria-hidden":`true`}),`Pick variant `,u?.variant]})]})]})})]})}function q({variant:e,allTerminal:t,pickPending:n,onPick:r,showTokens:i,showCost:a}){let o=l(e),s=u(e.costUsd),c=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:o.tone,pulse:o.pulse,children:o.label}),i&&c||a&&s?(0,W.jsxs)(`span`,{"data-slot":`variant-token-metrics`,className:`ml-auto flex shrink-0 items-center gap-1.5 text-meta text-soft-foreground`,children:[i?(0,W.jsx)(w,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):null,i&&c&&a&&s?(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,a&&s?(0,W.jsx)(`span`,{className:`font-mono tabular-nums`,children:s}):null]}):null]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`eyebrow text-soft-foreground`,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-meta 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:`eyebrow text-soft-foreground`,children:`Progress`}),e.handoffExcerpt?(0,W.jsx)(`div`,{"data-slot":`variant-progress`,className:`max-h-28 min-w-0 overflow-hidden text-label 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-ui 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
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Ci as r,Dn as i,Ia as a,M as o,Na as s,Ot as c,Vn as l,dn as u,er as d,j as f,r as p,sn as m}from"./queries-DsfjHsrp.js";import{r as h,t as g}from"./button-BvYDiOkd.js";import{c as _,f as v,t as y,w as b}from"./project-router-7DKoABD3.js";import{t as x}from"./check-DC3eAaS2.js";import{t as S}from"./chevron-right-DuM1UAhq.js";import{t as C}from"./search-x-Cm22V3TC.js";import{i as w,n as T,o as E,r as D,t as O}from"./collapsible-OE3rGS50.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-BZU09BVw.js";import{t as L}from"./token-metrics-CMdTXREP.js";import{t as R}from"./centered-state-Bpq40Y_t.js";import{t as z}from"./markdown-BBnagS_c.js";import{Z as B,b as V}from"./index-BVPhzJ3k.js";import{t as H}from"./run-diff-CmqQmGTJ.js";var U=e(t(),1),W=n();function G(){let{groupId:e}=b(),t=f(e),n=L(o().data),r=a();if((0,U.useEffect)(()=>{e&&r.invalidateQueries({queryKey:p.groups.detail(e)})},[r,e,(c().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 d&&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:o}){let c=_(),l=a(),[u,d]=(0,U.useState)(null),f=t.every(e=>m.has(e.status)),g=t[0]?i(t[0]):``,y=s({mutationFn:t=>r(e,t),onSuccess:(t,n)=>{l.invalidateQueries({queryKey:p.runs.all}),l.invalidateQueries({queryKey:p.groups.detail(e)}),c(`/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-ui 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:f,pickPending:y.isPending,onPick:()=>d(e),showTokens:n,showCost:o},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:u!==null,onOpenChange:e=>!e&&d(null),children:(0,W.jsxs)(j,{children:[(0,W.jsxs)(F,{children:[(0,W.jsxs)(A,{children:[`Pick variant `,u?.variant,`?`]}),(0,W.jsxs)(k,{children:[`Variant `,u?.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:()=>{u&&y.mutate(u.id),d(null)},children:[(0,W.jsx)(x,{"aria-hidden":`true`}),`Pick variant `,u?.variant]})]})]})})]})}function q({variant:e,allTerminal:t,pickPending:n,onPick:r,showTokens:i,showCost:a}){let o=l(e),s=u(e.costUsd),c=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:o.tone,pulse:o.pulse,children:o.label}),i&&c||a&&s?(0,W.jsxs)(`span`,{"data-slot":`variant-token-metrics`,className:`ml-auto flex shrink-0 items-center gap-1.5 text-meta text-soft-foreground`,children:[i?(0,W.jsx)(w,{inputTokens:e.inputTokens,outputTokens:e.outputTokens}):null,i&&c&&a&&s?(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}):null,a&&s?(0,W.jsx)(`span`,{className:`font-mono tabular-nums`,children:s}):null]}):null]}),(0,W.jsxs)(`div`,{className:`flex min-w-0 flex-col gap-1`,children:[(0,W.jsx)(`span`,{className:`eyebrow text-soft-foreground`,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-meta 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:`eyebrow text-soft-foreground`,children:`Progress`}),e.handoffExcerpt?(0,W.jsx)(`div`,{"data-slot":`variant-progress`,className:`max-h-28 min-w-0 overflow-hidden text-label 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-ui 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};
@@ -0,0 +1,44 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{Fi as r,Ia as i,M as a,Pa as o,Un as s,Vn as c,bn as l,en as u,er as d,fa as f,li as p,nn as m,q as h,ur as g}from"./queries-DsfjHsrp.js";import{F as _,at as v,et as y,it as b,nt as ee,rt as x,st as S,t as C,tt as w,wt as T}from"./button-BvYDiOkd.js";import{T as te,m as E,x as ne}from"./project-router-7DKoABD3.js";import{S as re,a as ie,o as ae,r as oe,t as se}from"./reference-chip-frnxjI-K.js";import{B as D,D as ce,E as O,I as k,L as le,R as A,S as ue,T as de,_ as fe,b as pe,c as me,d as he,f as ge,h as _e,k as ve,m as ye,n as be,p as xe,v as Se,w as Ce,x as we,y as Te,z as Ee}from"./facet-filter-BSS2vFA8.js";import{a as De,i as Oe,n as ke,o as Ae,s as je,t as Me}from"./use-now-BW1HO2p_.js";import{a as Ne,f as j,m as Pe,p as Fe,r as Ie}from"./automation-format-CEBKDGz8.js";import{f as Le,i as Re,n as ze,r as Be,t as Ve}from"./tooltip-Bb7ddw0_.js";import{t as He}from"./chevron-right-DuM1UAhq.js";import{t as Ue}from"./download-_KH0gJo8.js";import{i as M,n as We,r as N,t as Ge}from"./token-metrics-CMdTXREP.js";import{t as Ke}from"./index-BVPhzJ3k.js";var qe=_(`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`}]]),Je=_(`arrow-down-left`,[[`path`,{d:`M17 7 7 17`,key:`15tmo1`}],[`path`,{d:`M17 17H7V7`,key:`1org7z`}]]),Ye=_(`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`}]]),Xe=_(`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`}]]),Ze=_(`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`}]]),P=e(t(),1);function Qe(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 $e(e){return e.flatMap(e=>(e.data?.automations??[]).filter(e=>e.enabled).map(t=>({project:e,automation:t,at:Qe(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 et(e){let t=h(),n=i(),r=t.data?.projects??[],a=t.data?.bootProject,s=a&&!r.some(e=>e.id===a)?[...r,{id:a,name:a,status:`ok`}]:r,c=o({queryKey:[...m.dashboard,`automations`,s.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<s.length&&!e.aborted;){let r=s[t++];if(r.status===`missing`){n.push({...r,error:`Project folder unavailable`});continue}try{let t=S.parse(await f(await g.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,P.useEffect)(()=>{if(e)return ve(e=>{e===`automation-change`&&n.invalidateQueries({queryKey:[...m.dashboard,`automations`]})})},[n,e]),{...c,registry:t,retry:()=>{t.refetch(),c.refetch()}}}var F=n();function I({rows:e}){return(0,F.jsx)(`span`,{hidden:!0,"data-dashboard-export":JSON.stringify(e)})}var L=`section-mark eyebrow text-muted-foreground`,R=`flex min-h-12 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b px-4 py-2.5`,tt=`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 z(){return(0,F.jsx)(He,{"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 nt=`flex items-center gap-2 text-xs text-muted-foreground`;function rt({className:e=``,...t}){return(0,F.jsxs)(`span`,{className:`relative inline-flex`,children:[(0,F.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,F.jsx)(Le,{"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 it=`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`,B={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 at({label:e,value:t,icon:n,children:r}){return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`span`,{className:`flex w-full items-center justify-between gap-2`,children:[(0,F.jsx)(`span`,{className:`eyebrow text-muted-foreground`,children:e}),(0,F.jsx)(`span`,{className:`text-soft-foreground`,"aria-hidden":`true`,children:n})]}),(0,F.jsx)(`span`,{className:`mt-4 block text-4xl font-semibold leading-none tracking-tight tabular-nums`,children:t}),(0,F.jsx)(`span`,{className:`mt-3 block text-xs text-soft-foreground`,children:r})]})}function ot({at:e}){return(0,F.jsxs)(`time`,{dateTime:e,title:new Date(e).toLocaleString(),children:[`Updated `,N(e),` ago`]})}function st(){let e=me(),t=et(e.known&&!e.off),n=Me(3e4),[r,i]=(0,P.useState)(!1),a=$e(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,F.jsxs)(j,{"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,F.jsxs)(`div`,{className:R,children:[(0,F.jsxs)(`h2`,{className:`flex items-center ${L}`,children:[`Automations`,(0,F.jsx)(Pe,{className:`ml-2 size-3.5 text-soft-foreground`,"aria-hidden":`true`})]}),!e.off&&t.data&&(0,F.jsxs)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:[a.length,` enabled`,l?` · partial`:``]})]}),!e.off&&t.data&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(I,{rows:[{section:`automations`,metric:`enabled`,value:a.length,unit:`automations`,note:l?`Partial project coverage`:`Loaded projects`}]}),t.dataUpdatedAt>0&&(0,F.jsx)(`p`,{className:`px-4 pt-3 text-xs text-muted-foreground`,children:(0,F.jsx)(ot,{at:new Date(t.dataUpdatedAt).toISOString()})})]}),e.off?(0,F.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,F.jsxs)(F.Fragment,{children:[c&&(0,F.jsx)(`p`,{className:`p-4 text-sm text-muted-foreground`,children:`Loading automations…`}),l&&(0,F.jsxs)(`div`,{role:`alert`,className:`p-4 text-sm`,children:[(0,F.jsx)(`p`,{children:`Some automation data could not be refreshed. Available results are shown.`}),s.map(e=>(0,F.jsxs)(`p`,{children:[e.name,`: `,e.error]},e.id)),(0,F.jsx)(C,{variant:`ghost`,onClick:t.retry,children:`Retry automations`})]}),!c&&!l&&a.length===0&&(0,F.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`:Ne(r,n),o=t.kind===`schedule`?`Next run`:`Next check`;return(0,F.jsxs)(`div`,{"data-export-row":!0,className:`border-b px-4 py-3 transition-colors last:border-0 hover:bg-muted/30`,children:[(0,F.jsx)(E,{className:`block min-h-11 text-sm font-medium hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations/${encodeURIComponent(t.id)}`,children:t.name}),(0,F.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[e.name,` · `,o,`: `,a]}),r!==null&&(0,F.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:(0,F.jsxs)(`time`,{dateTime:new Date(r).toISOString(),children:[Ie(r,e.data.timeZone),` · `,e.data.timeZone]})}),t.kind!==`schedule`&&(0,F.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:`Checks for matching events; a task may not be started.`}),i&&(0,F.jsx)(`p`,{className:`mt-1 text-xs text-warning`,children:i}),(0,F.jsx)(I,{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,F.jsx)(C,{variant:`ghost`,className:`m-2 min-h-11`,onClick:()=>i(!r),children:r?`Show fewer`:`Show all ${a.length} enabled`}),!c&&(0,F.jsxs)(`details`,{className:`border-t px-4 py-2 text-xs text-muted-foreground`,children:[(0,F.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,F.jsx)(z,{}),`Manage automations by project`]}),t.data?.map(e=>(0,F.jsx)(E,{className:`block min-h-11 py-3 hover:underline`,to:`/p/${encodeURIComponent(e.id)}/automations`,children:e.name},e.id))]})]})]})}function ct(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 lt(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 ut=(0,P.createContext)(``),dt=(0,P.createContext)(!0),V=new Map;function ft(e,t,n=``,r=0,i){let a=(0,P.useContext)(ut),o=`${a}:${n}`,[s,c]=(0,P.useState)(()=>V.get(o)),[l,u]=(0,P.useState)(o),d=(0,P.useRef)(r),f=(0,P.useRef)(!1);l!==o&&(u(o),c(V.get(o)),d.current=r,f.current=!1),d.current!==r&&(d.current=r,f.current=!0),(0,P.useEffect)(()=>{e&&(!s||f.current)&&(c(e),f.current=!1)},[s,e]);let p=(0,P.useMemo)(()=>({current:s}),[o]);p.current=s,(0,P.useEffect)(()=>()=>{!a||!p.current||(V.delete(o),V.set(o,p.current),V.size>60&&V.delete(V.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:lt(g,e??m,t),updates:e?ct(g,e,t).size:0,show:()=>c(e)}}var H=new Map;function pt(e){return H.get(e)}function mt(e,t){H.delete(e),H.set(e,t),H.size>20&&H.delete(H.keys().next().value)}var U=new Map;function ht(e,t){return U.get(e)?.[t]}function gt(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 _t({row:e,removed:t=!1,queue:n=!1,checking:r=!1,checkFailed:i=!1,kicker:a}){let o=(0,P.useContext)(dt)&&!r&&!i,u=D(e);t=t||u===null||n&&u?.archived===!0,u&&(e={...e,status:u.status,awaitingAnswerSince:u.awaitingAnswerSince});let d=c(e),f=n&&!s(e),p=t||f||!o;return(0,F.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,F.jsx)(I,{rows:[{section:`task`,entity:W(e),metric:`title`,value:e.titleSummary||e.title},{section:`task`,entity:W(e),metric:`status`,value:p?`Not currently actionable`:e.status},{section:`task`,entity:W(e),metric:`createdAt`,value:e.createdAt}]}),a&&(0,F.jsx)(`p`,{className:`mb-1 pl-[15px] eyebrow text-soft-foreground`,children:a}),(0,F.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,F.jsx)(M,{tone:d.tone,className:`mt-[7px]`}),(0,F.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,F.jsx)(E,{tabIndex:p?-1:void 0,"aria-disabled":p||void 0,onClick:e=>{p&&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,F.jsxs)(`div`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-1 text-xs text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:e.projectId}),(0,F.jsx)(`span`,{children:i?`Could not check current state`:o?t?n&&u!==null?`No longer needs you`:`Task removed`:f?`No longer needs you`:d.label:`Checking current state…`}),(0,F.jsx)(`span`,{children:N(e.createdAt)}),e.dispatch&&(0,F.jsx)(`span`,{children:`Subtask`}),!p&&l(e).map(t=>(0,F.jsx)(se,{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,F.jsxs)(`div`,{className:`rounded-lg border border-pending/40 bg-card-2 p-3 text-sm`,role:`status`,children:[(0,F.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,F.jsxs)(`details`,{className:`mt-2`,children:[(0,F.jsxs)(`summary`,{className:`${tt} min-h-11`,children:[(0,F.jsx)(z,{}),`View unavailable `,r.length===1?`project`:`projects`]}),r.map(e=>(0,F.jsxs)(`p`,{children:[e.projectId,`: `,e.reason??e.state,e.omittedRuns>0?` · ${e.omittedRuns} omitted tasks`:``]},e.projectId))]}),(0,F.jsx)(C,{variant:`outline`,onClick:n,className:`min-h-11`,children:`Retry`})]}):null}function vt(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 yt(e,t,n){let r=ne(),i=r.state?.dashboardEntry??r.key,[a,o]=te(),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 bt=e=>`Last ${e===`7d`?7:30} calendar days`,xt=`eyebrow text-muted-foreground`,St=`min-w-0 rounded-lg border bg-card-2 p-4`,q=`whitespace-nowrap px-3 py-2 eyebrow text-soft-foreground`;function Ct(){let e=h().data?.projects;return t=>e?.find(e=>e.id===t)?.name??t}var wt=(e,t)=>`/p/${encodeURIComponent(e)}/tasks/${encodeURIComponent(t)}`;function Tt({label:e,value:t,onChange:n}){return(0,F.jsxs)(`label`,{className:nt,children:[e,(0,F.jsxs)(rt,{value:t,onChange:e=>n(e.target.value===`30d`?`30d`:`7d`),children:[(0,F.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,F.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})}function Et({query:e}){return e.isPending?(0,F.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading insights…`}):e.isError?(0,F.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[e.data?`Showing previous results. `:``,`Could not refresh insights.`,` `,(0,F.jsx)(C,{variant:`outline`,onClick:()=>void e.refetch(),children:`Retry insights`})]}):null}function Dt({period:e,active:t}){let n=Ke(e,t),r=n.data;return(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(Et,{query:n}),r&&(0,F.jsx)(G,{coverage:r.coverage,retry:()=>void n.refetch()}),r&&(0,F.jsxs)(`div`,{className:`grid gap-3 lg:grid-cols-2`,children:[(0,F.jsx)(kt,{data:r}),(0,F.jsx)(At,{data:r})]})]})}function Ot({value:e,prefix:t=``,className:n}){let r=`${t}${e.toLocaleString(`en-US`)}`;return e<1e4?(0,F.jsx)(`span`,{className:n,children:r}):(0,F.jsxs)(`span`,{className:n,title:r,children:[t,We(e)]})}function kt({data:e}){let t=e.delivered,n=[{label:`PRs opened`,value:t.prsOpened,note:`${t.prsTouched} touched`},{label:`Lines`,value:(0,F.jsxs)(`span`,{className:`flex flex-wrap gap-x-1.5`,children:[(0,F.jsx)(Ot,{value:t.additions,prefix:`+`,className:`text-success`}),(0,F.jsx)(Ot,{value:t.deletions,prefix:`−`,className:`text-danger`})]})},{label:`Files`,value:(0,F.jsx)(Ot,{value:t.files})},{label:`Issues`,value:(0,F.jsx)(Ot,{value:t.issues})}];return(0,F.jsxs)(`section`,{className:St,"aria-label":`Delivered`,children:[(0,F.jsx)(I,{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,F.jsx)(`h3`,{className:xt,children:`Delivered`}),(0,F.jsx)(`dl`,{className:`mt-3 grid grid-cols-2 gap-x-4 gap-y-3 sm:grid-cols-4`,children:n.map(e=>(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`dt`,{className:`text-xs text-soft-foreground`,children:e.label}),(0,F.jsx)(`dd`,{className:`mt-1 truncate text-xl font-semibold tracking-tight tabular-nums`,children:e.value}),e.note&&(0,F.jsx)(`dd`,{className:`text-xs text-soft-foreground`,children:e.note})]},e.label))}),(0,F.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 At({data:e}){let t=Ct(),{total:n,reasons:r}=e.failures;return(0,F.jsxs)(`section`,{className:St,"aria-label":`Why tasks failed`,children:[(0,F.jsx)(I,{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,F.jsxs)(`div`,{className:`flex items-baseline justify-between gap-2`,children:[(0,F.jsx)(`h3`,{className:xt,children:`Why tasks failed`}),n>0&&(0,F.jsxs)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:[n,` failed`]})]}),n===0?(0,F.jsxs)(`span`,{className:`mt-4 flex items-center gap-2.5 text-sm text-muted-foreground`,children:[(0,F.jsx)(M,{tone:`success`}),`No failed outcomes in this period`]}):(0,F.jsx)(`ul`,{className:`mt-3 space-y-3`,children:r.map(e=>(0,F.jsx)(jt,{reason:e,total:n,projectName:t},`${e.category}:${e.label}`))})]})}function jt({reason:e,total:t,projectName:n}){let{latest:r}=e;return(0,F.jsxs)(`li`,{className:`min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-baseline justify-between gap-3 text-sm`,children:[(0,F.jsx)(`span`,{className:`min-w-0 truncate font-medium`,title:e.label,children:e.label}),(0,F.jsx)(`span`,{className:`font-mono text-xs tabular-nums text-muted-foreground`,children:e.count})]}),(0,F.jsx)(`div`,{className:`mt-1.5 h-1 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full bg-danger/70`,style:{width:`${e.count/t*100}%`}})}),(0,F.jsxs)(`span`,{className:`mt-1.5 block truncate text-xs text-soft-foreground`,title:r.message,children:[`Latest:`,` `,(0,F.jsx)(E,{className:`text-muted-foreground hover:text-foreground hover:underline`,to:wt(r.projectId,r.id),children:r.title}),` `,`· `,n(r.projectId),r.step?` · ${r.step}`:``,` · `,N(r.at),` ago`]})]})}var Mt={claude:`Claude Code`,codex:`Codex`,opencode:`OpenCode`,cursor:`Cursor`,pi:`Pi`,unknown:`Unknown backend`,mixed:`Mixed backends`},Nt=e=>Mt[e]??e,Pt=(e,t)=>t?Math.round(e/t*100):0;function Ft(){let[e,t]=yt(`backends`,[`7d`,`30d`],`7d`),n=Ke(e),r=n.data,i=r?.visibility.cost;return(0,F.jsx)(`section`,{"data-dashboard-module":`backends`,className:`min-w-0`,children:(0,F.jsxs)(j,{className:`gap-0 py-0`,"data-export-context":`Backends: ${bt(e)}; finished tasks`,children:[(0,F.jsxs)(`div`,{className:R,children:[(0,F.jsx)(`h2`,{className:L,children:`Backends & models`}),(0,F.jsx)(Tt,{label:`Finished`,value:e,onChange:t})]}),(0,F.jsxs)(`div`,{className:`space-y-3 p-4`,children:[(0,F.jsx)(Et,{query:n}),r&&(0,F.jsxs)(F.Fragment,{children:[(0,F.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,F.jsx)(G,{coverage:r.coverage,retry:()=>void n.refetch()}),r.backends.length?(0,F.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Backend comparison`,tabIndex:0,children:(0,F.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:q,children:`Backend`}),(0,F.jsx)(`th`,{className:`${q} text-right`,children:`Finished`}),(0,F.jsx)(`th`,{className:q,children:`Success`}),(0,F.jsx)(`th`,{className:`${q} text-right`,children:`Median cycle`}),i&&(0,F.jsx)(`th`,{className:`${q} text-right`,children:`Reported USD`}),i&&(0,F.jsx)(`th`,{className:`${q} text-right`,children:`Per completed`})]})}),(0,F.jsx)(`tbody`,{children:r.backends.map(e=>(0,F.jsx)(It,{stat:e,cost:!!i},`${e.backend}:${e.model??``}`))})]})}):(0,F.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No finished tasks in this period.`}),(0,F.jsx)(`span`,{className:`block font-mono text-meta text-soft-foreground`,children:(0,F.jsx)(ot,{at:r.asOf})}),(0,F.jsx)(I,{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 It({stat:e,cost:t}){let n=Pt(e.done,e.finished),r=e.costUsd?.value;return(0,F.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,F.jsxs)(`td`,{className:`px-3 py-2.5`,children:[(0,F.jsx)(`span`,{className:`block font-medium`,children:Nt(e.backend)}),(0,F.jsx)(`span`,{className:`block font-mono text-meta text-soft-foreground`,children:e.backend===`mixed`?`steps ran on different backends`:e.model??`default model`})]}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.finished}),(0,F.jsxs)(`td`,{className:`min-w-40 px-3 py-2.5`,children:[(0,F.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,F.jsx)(`span`,{className:`h-1.5 flex-1 overflow-hidden rounded-full bg-danger/40`,"aria-hidden":`true`,children:(0,F.jsx)(`span`,{className:`block h-full rounded-full bg-success`,style:{width:`${n}%`}})}),(0,F.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs tabular-nums`,children:[n,`%`]})]}),(0,F.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.done,` done · `,e.failed,` failed`]})]}),(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:e.timedTasks?K(e.medianCycleHours):`—`}),t&&(0,F.jsxs)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:[r==null?`—`:vt(r,!0),(0,F.jsxs)(`span`,{className:`block text-xs text-soft-foreground`,children:[e.costUsd?.reportedTasks??0,`/`,e.finished,` reported`]})]}),t&&(0,F.jsx)(`td`,{className:`px-3 py-2.5 text-right tabular-nums`,children:r==null||!e.done?`—`:vt(r/e.done,!0)})]})}function Lt(){let[e,t]=yt(`automations`,[`7d`,`30d`],`7d`),n=me(),r=Ke(e),i=et(n.known&&!n.off),a=Ct(),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,F.jsx)(`section`,{"data-dashboard-module":`automation-outcomes`,className:`min-w-0`,children:(0,F.jsxs)(j,{className:`gap-0 py-0`,"data-export-context":`Automation outcomes: tasks created in ${bt(e)}`,children:[(0,F.jsxs)(`div`,{className:R,children:[(0,F.jsx)(`h2`,{className:L,children:`Automation outcomes`}),(0,F.jsx)(Tt,{label:`Launched`,value:e,onChange:t})]}),(0,F.jsx)(`div`,{className:`space-y-3 p-4`,children:n.off?(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Automations are disabled in this workspace.`}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(Et,{query:r}),o&&(0,F.jsxs)(F.Fragment,{children:[(0,F.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,F.jsx)(G,{coverage:o.coverage,retry:()=>void r.refetch()}),u&&(0,F.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Some automation details could not be loaded. Their outcomes are shown by id.`,` `,(0,F.jsx)(C,{variant:`ghost`,onClick:i.retry,children:`Retry automations`})]}),d.length?(0,F.jsx)(`div`,{className:`overflow-x-auto`,role:`region`,"aria-label":`Automation outcomes`,tabIndex:0,children:(0,F.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{children:[(0,F.jsx)(`th`,{className:q,children:`Automation`}),(0,F.jsx)(`th`,{className:`${q} text-right`,children:`Tasks`}),(0,F.jsx)(`th`,{className:`${q} text-right`,children:`Done`}),(0,F.jsx)(`th`,{className:`${q} text-right`,children:`Failed`}),(0,F.jsx)(`th`,{className:`${q} text-right`,children:`Active`}),(0,F.jsx)(`th`,{className:q,children:`Last run`}),s&&(0,F.jsx)(`th`,{className:`${q} text-right`,children:`Reported USD`})]})}),(0,F.jsx)(`tbody`,{children:d.map(e=>(0,F.jsx)(Rt,{row:e,cost:!!s,projectName:a},`${e.projectId}:${e.automationId}`))})]})}):(0,F.jsx)(`p`,{className:`py-4 text-sm text-muted-foreground`,children:`No automations yet. Create one in a project's Automations page.`}),(0,F.jsx)(`span`,{className:`block font-mono text-meta text-soft-foreground`,children:(0,F.jsx)(ot,{at:o.asOf})}),(0,F.jsx)(I,{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 Rt({row:e,cost:t,projectName:n}){let r=e.stat,i=`px-3 py-2.5 text-right tabular-nums`,a=e=>e||(0,F.jsx)(`span`,{className:`text-soft-foreground`,children:`0`});return(0,F.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,F.jsxs)(`td`,{className:`px-3 py-2.5`,children:[e.definition===`removed`?(0,F.jsx)(`span`,{className:`block font-medium`,children:e.name}):(0,F.jsx)(E,{className:`block font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}/automations/${encodeURIComponent(e.automationId)}`,children:e.name}),(0,F.jsxs)(`span`,{className:`flex items-center gap-1.5 text-xs text-soft-foreground`,children:[(0,F.jsx)(M,{tone:e.enabled?`success`:`neutral`}),n(e.projectId),` ·`,` `,e.definition===`removed`?`Removed`:e.definition===`unknown`?`Details unavailable`:e.enabled?`Enabled`:`Disabled`]})]}),(0,F.jsx)(`td`,{className:i,children:a(r?.tasks)}),(0,F.jsx)(`td`,{className:i,children:a(r?.done)}),(0,F.jsx)(`td`,{className:`${i} ${r?.failed?`text-danger`:``}`,children:a(r?.failed)}),(0,F.jsx)(`td`,{className:i,children:a(r?.active)}),(0,F.jsx)(`td`,{className:`whitespace-nowrap px-3 py-2.5 text-xs text-muted-foreground`,children:r?.lastRunAt?(0,F.jsxs)(`time`,{dateTime:r.lastRunAt,title:new Date(r.lastRunAt).toLocaleString(),children:[N(r.lastRunAt),` ago · `,r.lastStatus]}):`—`}),t&&(0,F.jsx)(`td`,{className:i,children:r?.costUsd?.value==null?`—`:vt(r.costUsd.value,!0)})]})}var zt=0,Bt=()=>++zt,J=new Map;function Y(e,t){let n=(0,P.useContext)(ut),r=()=>{let r=n?J.get(n):void 0;return r?.has(e)?r.get(e):typeof t==`function`?t():t},[i,a]=(0,P.useState)(r),o=`${n}:${e}`,[s,c]=(0,P.useState)(o);o!==s&&(c(o),a(()=>r()));let l=(0,P.useMemo)(()=>({value:i}),[n,e]);return l.value=i,(0,P.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 Vt=`a[href], button, select, input, [tabindex]`;function Ht(e){let[t]=Y(`${e}:position`,()=>({scroll:0})),n=(0,P.useCallback)(e=>{let n=[...e.querySelectorAll(Vt)],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,P.useMemo)(()=>({restore:()=>!1}),[t]);return{ref:(0,P.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(Vt)].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 Ut(e,t){let n=(0,P.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 Wt(e,t=!0){return o({queryKey:[...m.dashboard,`overview`,e],enabled:t,staleTime:5e3,refetchInterval:t&&!e.snapshotId?15e3:!1,refetchIntervalInBackground:!1,retry:!1,queryFn:async({signal:t})=>y.parse(await f(await g.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 Gt={running:`Running now`,"needs-you":`Needs you`,completed:`Completed`,failed:`Failed outcomes`},Kt={"needs-you":B.violet,running:B.info,completed:B.success,failed:B.danger},qt={"needs-you":Fe,running:qe,completed:ce,failed:Ye};function Jt({active:e,children:t,onCurrent:n}){let[r,i]=yt(`period`,[`7d`,`30d`],`7d`),a=Ut(`outcome`,`[data-outcome-trigger]`),o=h().data?.projects,s=e=>o?.find(t=>t.id===e)?.name??e,c=Wt({period:r},e),[l,u]=Y(`outcome:selection`,null),d=Ht(`outcome:${l?.identity??`closed`}`),f=le();if((0,P.useEffect)(()=>{e||u(null)},[e]),!e)return t({});let p=c.data,m=(e,t)=>{a.capture(),p&&u({identity:Bt(),snapshot:p,group:e,projectId:t})},g=p?.coverage.projects.every(e=>e.state===`complete`);return(0,F.jsxs)(F.Fragment,{children:[t({overview:(0,F.jsxs)(j,{className:`gap-0 py-0`,children:[(0,F.jsxs)(`div`,{className:R,children:[(0,F.jsx)(`h2`,{className:L,children:`Workspace overview`}),(0,F.jsxs)(`label`,{className:nt,children:[`Outcomes period`,(0,F.jsxs)(rt,{value:r,onChange:e=>{i(e.target.value===`30d`?`30d`:`7d`),u(null)},children:[(0,F.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,F.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-4 p-4`,children:[c.isPending&&(0,F.jsx)(`p`,{role:`status`,className:`text-sm text-muted-foreground`,children:`Loading overview…`}),c.isError&&(0,F.jsxs)(`p`,{role:`alert`,children:[p?`Showing previous results. `:``,`Could not refresh overview.`,` `,(0,F.jsx)(C,{variant:`outline`,onClick:()=>void c.refetch(),children:`Retry overview`})]}),p&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[p.metrics.needsYou?`${p.metrics.needsYou} tasks require your input or review.`:g&&f.connected&&!c.isError?`No tasks currently require your input or review.`:`No waiting tasks found in the available data.`,` `,p.metrics.failed,` failed `,p.metrics.failed===1?`outcome`:`outcomes`,` `,`in this period. Includes subtasks; completed does not mean accepted or deployed.`]}),(0,F.jsx)(G,{coverage:p.coverage,retry:()=>void c.refetch()}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 gap-3 lg:grid-cols-4`,children:[`needs-you`,`running`,`completed`,`failed`].map(e=>{let t=p.metrics[e===`needs-you`?`needsYou`:e],i=qt[e];return(0,F.jsxs)(C,{"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?B.neutral:Kt[e]}`,onClick:t=>{n&&(e===`running`||e===`needs-you`)?n(e,t.currentTarget):m(e)},"aria-label":`${Gt[e]}: ${t}`,children:[(0,F.jsx)(at,{label:Gt[e],value:t,icon:(0,F.jsx)(i,{className:`size-4`}),children:e===`running`||e===`needs-you`?`Current state`:`Last ${r===`7d`?7:30} calendar days`}),(0,F.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,F.jsx)(He,{className:`size-3 transition-transform group-hover/metric:translate-x-0.5 motion-reduce:transition-none`,"aria-hidden":`true`})]})]},e)})}),(0,F.jsx)(Dt,{period:r,active:e}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-4 gap-y-1 border-t pt-3`,children:[(0,F.jsxs)(`p`,{className:`text-sm text-muted-foreground`,children:[`Median cycle time`,` `,(0,F.jsx)(`strong`,{className:`font-mono font-semibold text-foreground`,children:K(p.metrics.medianCycleHours)}),` `,`· `,p.metrics.timedTasks,`/`,p.metrics.completed,` completed tasks have valid timings.`,` `,(0,F.jsx)(C,{variant:`ghost`,className:`h-auto px-1.5 py-1 text-sm text-foreground underline-offset-4 hover:underline`,onClick:()=>m(`completed`),children:`Inspect completed tasks`})]}),(0,F.jsx)(`p`,{className:`font-mono text-meta text-soft-foreground`,children:(0,F.jsxs)(`time`,{dateTime:p.asOf,title:new Date(p.asOf).toLocaleString(),children:[`Updated `,N(p.asOf),` ago`]})})]}),(0,F.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,F.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,F.jsx)(z,{}),`How these metrics work`]}),(0,F.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,F.jsx)(I,{rows:Object.entries(p.metrics).map(([e,t])=>({section:`overview`,metric:e,value:t,unit:e===`medianCycleHours`?`hours`:`tasks`,asOf:p.asOf,note:e===`running`||e===`needsYou`?`Current non-archived state`:`Finished since ${p.windowStart}`}))})]})]})]}),portfolio:p&&(0,F.jsx)(`div`,{children:(0,F.jsxs)(j,{className:`gap-0 py-0`,"data-export-context":`Outcomes: Last ${r===`7d`?7:30} calendar days; workload: current state`,children:[(0,F.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,F.jsx)(`h2`,{className:`section-mark eyebrow text-muted-foreground`,children:`Projects`})}),(0,F.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,F.jsxs)(`div`,{className:`overflow-x-auto px-1 pb-2`,role:`region`,"aria-label":`Project outcomes`,tabIndex:0,children:[(0,F.jsxs)(`table`,{className:`w-full text-left text-sm`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsx)(`tr`,{children:[`Project`,`Needs you`,`Running`,`Completed`,`Failed`,`Median cycle`].map(e=>(0,F.jsx)(`th`,{className:`whitespace-nowrap px-3 py-2 eyebrow text-soft-foreground ${e===`Project`?``:`text-right`}`,children:e},e))})}),(0,F.jsx)(`tbody`,{children:p.projects.map(e=>{let t=p.coverage.projects.find(t=>t.projectId===e.projectId);return(0,F.jsxs)(`tr`,{className:`border-t transition-colors hover:bg-muted/30`,children:[(0,F.jsxs)(`td`,{className:`px-3 py-2`,children:[(0,F.jsx)(E,{className:`font-medium hover:underline`,to:`/p/${encodeURIComponent(e.projectId)}`,children:s(e.projectId)}),t?.state!==`complete`&&(0,F.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:`Incomplete data`})]}),[`needs-you`,`running`,`completed`,`failed`].map(n=>(0,F.jsx)(`td`,{className:`px-3 py-1 text-right`,children:(0,F.jsx)(C,{"data-export-keep":!0,variant:`ghost`,className:`min-h-11 tabular-nums`,"aria-label":`${s(e.projectId)}: ${Gt[n]}: ${t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]}`,disabled:t?.state===`unavailable`,onClick:()=>m(n,e.projectId),children:t?.state===`unavailable`?`Unavailable`:e[n===`needs-you`?`needsYou`:n]})},n)),(0,F.jsxs)(`td`,{className:`px-3 py-2 text-right tabular-nums`,children:[K(e.medianCycleHours),(0,F.jsxs)(`span`,{className:`block text-xs text-muted-foreground`,children:[e.timedTasks,`/`,e.completed,` timed`]})]})]},e.projectId)})})]}),!p.projects.length&&(0,F.jsx)(`p`,{className:`py-4`,children:`No projects to compare yet.`})]}),(0,F.jsx)(I,{rows:p.projects.flatMap(({projectId:e,...t})=>Object.entries(t).map(([t,n])=>({section:`portfolio`,entity:e,metric:t,value:p.coverage.projects.find(t=>t.projectId===e)?.state===`unavailable`?null:n,unit:t===`medianCycleHours`?`hours`:`tasks`,asOf:p.asOf,note:`Outcomes since ${p.windowStart}; running and needsYou are current state`})))})]})})}),(0,F.jsx)(ke,{open:!!l,onOpenChange:e=>{e||u(null)},children:(0,F.jsxs)(Oe,{...d,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),a.restore()},children:[(0,F.jsxs)(Ae,{children:[(0,F.jsxs)(je,{children:[l?Gt[l.group]:`Tasks`,l?.projectId?` · ${l.projectId}`:``]}),(0,F.jsx)(De,{children:`Tasks behind the selected metric. Includes subtasks. Snapshot keeps counts and rows consistent.`})]}),l&&(0,F.jsx)(Yt,{selection:l,projectName:s,refresh:()=>{u(null),c.refetch()}},l.identity)]})})]})}function Yt({selection:e,refresh:t,projectName:n}){let[r,i]=Y(`outcome:${e.identity}:offset`,0),a=Wt({period:e.snapshot.period,snapshotId:e.snapshot.snapshotId,group:e.group,projectId:e.projectId,offset:r}),o=(0,P.useRef)(null),s=(0,P.useRef)(null);(0,P.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,F.jsxs)(`div`,{className:`space-y-3 p-4`,"data-sheet-loading":a.isFetching,children:[a.isPending&&(0,F.jsx)(`p`,{children:`Loading tasks…`}),a.isError&&(0,F.jsxs)(`p`,{role:`alert`,children:[`This snapshot may have expired or become unavailable.`,` `,(0,F.jsx)(C,{onClick:t,children:`Refresh overview`})]}),a.data&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{ref:o,tabIndex:-1,className:`text-xs text-muted-foreground`,children:[a.data.page.total,` tasks · Snapshot from`,` `,(0,F.jsxs)(`time`,{dateTime:a.data.asOf,title:new Date(a.data.asOf).toLocaleString(),children:[N(a.data.asOf),` ago`]})]}),a.data.page.rows.map(t=>(0,F.jsx)(Xt,{row:t,group:e.group,projectName:n},`${t.projectId}:${t.id}`)),!a.data.page.rows.length&&(0,F.jsx)(`p`,{children:`No tasks in this group.`})]}),(0,F.jsxs)(`div`,{className:`flex gap-2`,children:[(0,F.jsx)(C,{variant:`outline`,disabled:!r||a.isFetching,onClick:()=>c(Math.max(0,r-20)),children:`Previous`}),(0,F.jsx)(C,{variant:`outline`,disabled:!a.data||a.data.page.nextOffset===null||a.isFetching,onClick:()=>c(a.data.page.nextOffset),children:`Next`})]})]})}function Xt({row:e,group:t,projectName:n}){let r=D(e),i=t===`running`||t===`needs-you`;i&&r&&(e={...e,...r});let a=r===null,o=i&&(e.archived||(t===`running`?e.status!==`running`:!s(e))),l=a||o,u=c(e),d=i&&a?`Task removed`:o?t===`running`?`No longer running`:`No longer needs you`:u.label;return(0,F.jsxs)(`div`,{className:`border-b py-3`,children:[(0,F.jsx)(E,{"aria-disabled":l||void 0,tabIndex:l?-1:void 0,onClick:e=>{l&&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,F.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[(0,F.jsx)(M,{tone:u.tone}),` `,n(e.projectId),` ·`,` `,d,` · `,e.archived?`Archived · `:``,(0,F.jsxs)(`time`,{dateTime:e.finishedAt??e.createdAt,title:new Date(e.finishedAt??e.createdAt).toLocaleString(),children:[e.finishedAt?`Finished`:`Created`,` `,N(e.finishedAt??e.createdAt),` ago`]})]})]})}var X={snapshot:[...m.dashboard,`snapshot`],feed:e=>[...m.dashboard,`feed`,e],telemetry:[...m.dashboard,`telemetry`]},Zt=new Map;async function Qt(e){let t=A(),n=x.parse(await f(await g.api.v1.workspace.dashboard.$get({},{init:{signal:e}}),`/workspace/dashboard`));return Zt.has(n.snapshotId)||Zt.set(n.snapshotId,t),Zt.size>60&&Zt.delete(Zt.keys().next().value),Ee(t,[...n.questions.rows,...n.reviews.rows]),n}async function $t(e,t,n=0,r=20,i){let a=b.parse(await f(await g.api.v1.workspace.dashboard.tasks.$get({query:{snapshotId:e,group:t,offset:String(n),limit:String(r)}},{init:{signal:i}}),`/workspace/dashboard/tasks`)),o=Zt.get(e);return o!==void 0&&Ee(o,a.page.rows),a}function en(e){return o({queryKey:X.snapshot,queryFn:({signal:e})=>Qt(e),enabled:e,staleTime:5e3,refetchOnMount:`always`,refetchInterval:e?15e3:!1,refetchIntervalInBackground:!1,retry:!1})}function tn(e){return o({queryKey:X.telemetry,enabled:e,staleTime:0,queryFn:async({signal:e})=>{let t=v.parse(await f(await g.api.v1.workspace.dashboard.telemetry.$get({},{init:{signal:e}}),`/workspace/dashboard/telemetry`));return k.seed(t.samples,t.asOf),t}})}function nn(e,t){let n=o({queryKey:X.feed(e),queryFn:async({signal:t})=>{let n=A(),r=ee.parse(await f(await g.api.v1.workspace.dashboard.feed.$get({query:{filter:e}},{init:{signal:t}}),`/workspace/dashboard/feed`));return Ee(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,P.useRef)(!1);return(0,P.useEffect)(()=>{r.current=!1},[e,t]),(0,P.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 rn(e,t){let n=nn(`tasks`,t&&e!==`github`),r=nn(`github`,t&&e!==`tasks`),i=(0,P.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)=>an(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 an(e,t){return Date.parse(t.at)-Date.parse(e.at)||e.key.localeCompare(t.key)}var on=[...m.dashboard,`costs`];function sn(){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 fn(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 cn=new WeakMap;function ln(e){let t=cn.get(e);return t||(t=sn(),cn.set(e,t)),t}function un(){let e=ln(i());return(0,P.useSyncExternalStore)(e.subscribe,e.getSnapshot,e.getSnapshot)}var dn=new Map;async function fn(e,t){let n=A(),r=w.parse(await f(await g.api.v1.workspace.dashboard.costs.$get({query:{...e,offset:String(e.offset??0),limit:`20`}},{init:{signal:t}}),`/workspace/dashboard/costs`));!e.snapshotId&&!dn.has(r.snapshotId)&&dn.set(r.snapshotId,n),dn.size>60&&dn.delete(dn.keys().next().value);let i=dn.get(r.snapshotId);return i!==void 0&&Ee(i,r.tasks.rows),r}function pn(e,t,n){let r=ln(i());return o({queryKey:[...on,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 mn(e,t,n,r){let a=ln(i());return o({queryKey:[...on,`tasks`,e.snapshotId,t,n,r,e.visibility],retry:!1,queryFn:async({signal:i})=>{let o=e.tzOffsetMinutes??new Date().getTimezoneOffset(),s=async s=>{let c=await a.read({period:e.period,sort:n,snapshotId:s,projectId:t,tzOffsetMinutes:o},i),l=[...c.tasks.rows];for(;c.tasks.nextOffset!==null&&l.length<r;)c=await a.read({period:e.period,sort:n,snapshotId:c.snapshotId,projectId:t,offset:c.tasks.nextOffset},i),l.push(...c.tasks.rows);return{...c,tasks:{...c.tasks,rows:l}}};try{return await s(e.snapshotId)}catch(e){if(e instanceof d&&e.status===409)return s();throw e}}})}var hn={cost:{text:`text-primary`,fill:`bg-primary`,tint:B.primary,icon:O},input:{text:`text-violet`,fill:`bg-violet`,tint:B.violet,icon:Je},output:{text:`text-info`,fill:`bg-info`,tint:B.info,icon:re}};function gn({metric:e,label:t,value:n,reported:r,total:i}){let a=hn[e],o=a.icon,s=i?Math.min(100,r/i*100):0;return(0,F.jsxs)(`div`,{className:`${it} ${a.tint}`,children:[(0,F.jsxs)(at,{label:t,value:n,icon:(0,F.jsx)(o,{className:`size-4 ${a.text}`}),children:[r,` of `,i,` tasks report this metric`]}),(0,F.jsx)(`div`,{className:`mt-2 h-1.5 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,F.jsx)(`div`,{className:`h-full rounded-full ${a.fill} transition-[width] duration-300 motion-reduce:transition-none`,style:{width:`${s}%`}})})]})}function _n({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=hn[n];return(0,F.jsxs)(Be,{delayDuration:150,children:[(0,F.jsxs)(`div`,{className:`space-y-1 rounded-xl border p-2`,"aria-label":`Projects ranked by ${i}`,children:[e.length===0&&(0,F.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,F.jsxs)(Ve,{children:[(0,F.jsx)(Re,{asChild:!0,children:(0,F.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,F.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,F.jsx)(`span`,{className:`w-4 shrink-0 text-xs tabular-nums text-muted-foreground`,"aria-hidden":`true`,children:n+1}),(0,F.jsx)(`span`,{className:`min-w-0 flex-1 break-words font-medium`,children:e.projectId}),(0,F.jsx)(`span`,{className:`shrink-0 font-semibold tabular-nums`,children:a(u)}),(0,F.jsx)(He,{"data-export-exclude":!0,className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":`true`})]}),(0,F.jsx)(`div`,{className:`mt-2 ml-7 h-2 overflow-hidden rounded-full bg-muted`,"aria-hidden":`true`,children:(0,F.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,F.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,F.jsxs)(ze,{className:`max-w-64`,children:[(0,F.jsxs)(`p`,{className:`font-medium`,children:[e.projectId,` · `,i,`: `,a(u)]}),(0,F.jsxs)(`p`,{children:[l?.reportedTasks??0,` of `,e.tasks,` tasks report this metric.`]}),(0,F.jsx)(`p`,{children:`Open project tasks`})]})]},e.projectId)})]}),e.length>0&&(0,F.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`},vn={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function yn(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 bn=(e,t)=>vt(e,t===`cost`);function Q(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}function xn({value:e,onChange:t,visibility:n}){return(0,F.jsxs)(`label`,{className:nt,children:[`Sort by`,(0,F.jsx)(rt,{value:e,onChange:e=>t(e.target.value),children:Q(n).map(e=>(0,F.jsx)(`option`,{value:e,children:vn[e]},e))})]})}function Sn(){return(0,F.jsx)(Cn,{visibility:Ge(a().data)})}function Cn({visibility:e}){return(0,F.jsxs)(j,{className:`gap-0 py-0`,children:[(0,F.jsx)(`div`,{className:R,children:(0,F.jsx)(`h2`,{className:L,children:`Usage & cost`})}),!e.cost&&!e.tokens?(0,F.jsx)(`p`,{className:`p-4 text-sm`,children:`Usage metrics are hidden by workspace settings`}):(0,F.jsx)(wn,{visibility:e},`${e.cost}:${e.tokens}`)]})}function wn({visibility:e}){let[t,n]=yt(`usagePeriod`,[`all`,`7d`,`30d`],`all`),[r,i]=yt(`usageSort`,Q(e),e.cost?`cost`:`input`);return(0,F.jsx)(Tn,{period:t,setPeriod:n,sort:r,setSort:i,visibility:e})}function Tn({period:e,setPeriod:t,sort:n,setSort:r,visibility:i}){let a=pn(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,P.useState)(e);f!==e&&(p(e),s(void 0),d(null));let m=Ht(`usage:${u?.identity??`closed`}`),h=Ut(`usage`,`[data-usage-trigger]`),g=e=>{h.capture(),c&&d({identity:Bt(),projectId:e,snapshot:c,latestId:l?.snapshotId??c.snapshotId})},_=un()??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 ee=c&&l&&yn(c,l),x=c?.coverage.projects.some(e=>e.state!==`complete`),S=l?.coverage.projects.some(e=>e.state!==`complete`),w=JSON.stringify(c?.coverage)!==JSON.stringify(l?.coverage),T=c?.totals.tasks===0&&!x&&!S;return(0,F.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[c&&(0,F.jsx)(I,{rows:T?[]:[...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,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,F.jsx)(ot,{at:c.asOf})}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-medium`,children:`Lifetime totals of retained tasks`}),(0,F.jsxs)(`details`,{className:`mt-1 text-xs text-muted-foreground`,children:[(0,F.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${tt} min-h-11`,children:[(0,F.jsx)(z,{}),`How these metrics work`]}),(0,F.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,F.jsxs)(`label`,{className:nt,children:[`Tasks created`,(0,F.jsxs)(rt,{value:e,onChange:e=>t(e.target.value),children:[(0,F.jsx)(`option`,{value:`all`,children:`All time`}),(0,F.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,F.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),e!==`all`&&(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Lifetime usage of tasks created in this period — not spending during the period.`}),a.isPending&&(0,F.jsx)(`p`,{children:`Loading usage…`}),a.isError&&(0,F.jsxs)(`p`,{role:`alert`,children:[c?`Showing stale usage. Could not refresh.`:`Could not load usage.`,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>void a.refetch(),children:`Retry`})]}),ee&&(0,F.jsx)(`p`,{role:`status`,children:`Newer usage data is available; displayed values use the previous snapshot.`}),ee&&(0,F.jsx)(C,{className:`min-h-11`,variant:`outline`,onClick:()=>s(l),children:`Updates available — Show`}),c&&x&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed usage:`}),(0,F.jsx)(G,{coverage:c.coverage,retry:()=>void a.refetch()})]}),l&&S&&w&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,F.jsx)(G,{coverage:l.coverage,retry:()=>void a.refetch()})]}),c&&(0,F.jsxs)(F.Fragment,{children:[!T&&(0,F.jsx)(`div`,{className:`report-cost-metrics grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(220px,1fr))]`,children:Q(v).map(e=>(0,F.jsx)(gn,{metric:e,label:vn[e],value:bn(c.totals[Z[e]]?.value,e),reported:c.totals[Z[e]]?.reportedTasks??0,total:c.totals.tasks},e))}),!v.cost&&!v.tokens&&(0,F.jsx)(`p`,{children:`Usage metrics are hidden by workspace settings`}),c.totals.tasks===0?(0,F.jsx)(`p`,{children:x||S?`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,F.jsx)(`p`,{children:`No reports for the visible metrics in this cohort.`}),T&&(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Usage appears when tasks report cost or tokens.`}),(0,F.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`}.`:``]}),!T&&(v.cost||v.tokens)&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`h3`,{className:`font-medium`,children:`Top projects`}),(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Ranking uses reported metrics only.`})]}),(0,F.jsx)(xn,{value:y,onChange:r,visibility:v})]}),(0,F.jsx)(_n,{projects:b,metric:y,label:vn[y],field:Z[y],format:e=>bn(e,y),currentProjects:l?.projects??[],onSelect:g}),(0,F.jsx)(C,{"data-usage-trigger":!0,className:`min-h-11`,variant:`outline`,onClick:()=>g(``),children:`View tasks`})]})]}),(0,F.jsx)(ke,{open:u!==null&&(v.cost||v.tokens),onOpenChange:e=>{e||d(null)},children:(0,F.jsxs)(Oe,{...m,className:`w-full overflow-y-auto sm:max-w-xl`,onCloseAutoFocus:e=>{e.preventDefault(),h.restore()},children:[(0,F.jsxs)(Ae,{children:[(0,F.jsx)(je,{children:u?.projectId?`${u.projectId} tasks`:`All tasks`}),(0,F.jsx)(De,{children:`Lifetime usage of retained tasks. Missing reports are unavailable.`})]}),u!==null&&(0,F.jsx)(En,{identity:`usage:${u.identity}`,snapshot:l&&l.snapshotId!==u.latestId?l:u.snapshot,projectId:u.projectId||void 0,visibility:v},u.identity)]})})]})}function En({identity:e,snapshot:t,projectId:n,visibility:r}){let[i,a]=Y(`${e}:sort`,t.sort);return(0,F.jsx)(Dn,{identity:e,snapshot:t,projectId:n,visibility:r,sort:Q(r).includes(i)?i:Q(r)[0]??`cost`,setSort:a})}function Dn({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,P.useState)(t.snapshotId);u!==t.snapshotId&&(d(t.snapshotId),l(void 0));let f=mn(c??t,n,i,o),p=un()??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,ee]=Y(`${e}:acceptedSort`,i),[x,S]=(0,P.useState)(i);x!==i&&(S(i),s(20),l(g??c??t)),f.data&&(!g||(v!==o||b!==i)&&g.snapshotId===f.data.snapshotId)&&(_(f.data),y(o),ee(i));let w=g??f.data,T=f.data&&w&&yn(f.data,w),te=w?.coverage.projects.some(e=>e.state!==`complete`),E=f.data?.coverage.projects.some(e=>e.state!==`complete`),ne=JSON.stringify(w?.coverage)!==JSON.stringify(f.data?.coverage),re=!n||t.projects.some(e=>e.projectId===n);return(0,F.jsxs)(`div`,{className:`space-y-3 p-4 text-sm`,"data-sheet-loading":f.isFetching,children:[(0,F.jsx)(xn,{value:h,onChange:a,visibility:m}),f.isPending&&(0,F.jsx)(`p`,{children:`Loading tasks…`}),f.isError&&(0,F.jsxs)(`p`,{role:`alert`,children:[`Could not refresh tasks. `,w?`Showing stale usage.`:``,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>void f.refetch(),children:`Retry`})]}),T&&(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>{_(f.data),y(o),ee(i)},children:`Updates available — Show`}),w&&te&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Coverage of displayed tasks:`}),(0,F.jsx)(G,{coverage:w.coverage,retry:()=>void f.refetch()})]}),f.data&&E&&ne&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`Current source availability:`}),(0,F.jsx)(G,{coverage:f.data.coverage,retry:()=>void f.refetch()})]}),w&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`p`,{className:`border-b pb-2 font-mono text-meta text-soft-foreground`,children:[w.tasks.rows.length,` of `,w.tasks.total,` retained tasks`]}),w.tasks.total===0&&(0,F.jsx)(`p`,{children:w.coverage.projects.some(e=>e.state!==`complete`)?`No tasks could be read from available sources.`:`No retained tasks in this cohort.`}),w.tasks.rows.map(e=>(0,F.jsx)(On,{row:e,sort:h,visibility:m,disabled:!re||!f.data||!!(T&&!f.data?.tasks.rows.some(t=>t.id===e.id&&t.projectId===e.projectId))},`${e.projectId}:${e.id}`)),w.tasks.nextOffset!==null&&(0,F.jsx)(C,{className:`min-h-11`,disabled:f.isFetching,onClick:()=>{l(w),s(e=>e+20)},children:`Show 20 more tasks`})]})]})}function On({row:e,sort:t,visibility:n,disabled:r}){let i=D(e);r||=i===null;let a=c(i?{status:i.status,awaitingAnswerSince:i.awaitingAnswerSince}:e),o=Q(n).filter(e=>e!==t),s=t=>{let n=e[Z[t]];return n==null?`—`:bn(n,t)},l=t=>`${vn[t]}: ${bn(e[Z[t]],t)}`;return(0,F.jsxs)(`div`,{className:`grid grid-cols-[minmax(0,1fr)_auto] items-start gap-x-4 border-b py-3 last:border-0`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,F.jsx)(M,{tone:a.tone,pulse:a.pulse,className:`mt-[7px]`}),(0,F.jsx)(E,{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,F.jsxs)(`p`,{className:`mt-1 pl-[15px] font-mono text-meta text-soft-foreground`,children:[e.projectId,` · `,r?`Checking current state…`:i?.status??e.status,e.archived?` · Archived`:``,e.subtask?` · Subtask`:``]})]}),(0,F.jsxs)(`div`,{className:`text-right tabular-nums`,children:[(0,F.jsx)(`span`,{"aria-label":l(t),className:`block font-semibold ${e[Z[t]]==null?`text-soft-foreground`:``}`,children:s(t)}),o.length>0&&(0,F.jsx)(`span`,{className:`mt-1 flex justify-end gap-3 font-mono text-meta text-soft-foreground`,children:o.map(e=>(0,F.jsxs)(`span`,{"aria-label":l(e),children:[s(e),` `,e===`cost`?``:e===`input`?`in`:`out`]},e))})]})]})}var kn={cost:`costUsd`,input:`inputTokens`,output:`outputTokens`},An={cost:`Reported USD`,input:`Input tokens`,output:`Output tokens`};function jn(e){return[...e.cost?[`cost`]:[],...e.tokens?[`input`,`output`]:[]]}var Mn=(e,t)=>vt(e,t===`cost`);function Nn(e){return new Date(`${e}T00:00:00`).toLocaleDateString(void 0,{month:`short`,day:`numeric`})}function Pn({series:e,height:t,accent:n,renderTooltip:r,describe:i}){let a=Math.max(1,...e.map(t));return(0,F.jsxs)(Be,{delayDuration:150,children:[(0,F.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,F.jsxs)(Ve,{children:[(0,F.jsx)(Re,{asChild:!0,children:(0,F.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,F.jsx)(`span`,{style:{height:`${s}%`},className:`block w-full rounded-t-sm ${n}`})})}),(0,F.jsx)(ze,{children:r(e)})]},e.date)})}),(0,F.jsxs)(`div`,{className:`mt-1 flex justify-between text-xs text-muted-foreground`,children:[(0,F.jsx)(`span`,{children:Nn(e[0].date)}),(0,F.jsx)(`span`,{children:Nn(e.at(-1).date)})]})]})}function Fn({metrics:e,series:t}){return(0,F.jsxs)(`table`,{className:`w-full text-left text-xs`,children:[(0,F.jsx)(`thead`,{children:(0,F.jsxs)(`tr`,{className:`border-b`,children:[(0,F.jsx)(`th`,{className:`py-1 pr-2 font-medium`,children:`Date`}),e.map(e=>(0,F.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:An[e]},e)),(0,F.jsx)(`th`,{className:`py-1 pr-2 text-right font-medium`,children:`Completed`}),(0,F.jsx)(`th`,{className:`py-1 text-right font-medium`,children:`Avg cycle`})]})}),(0,F.jsx)(`tbody`,{children:t.map(t=>(0,F.jsxs)(`tr`,{className:`border-b last:border-0`,children:[(0,F.jsx)(`td`,{className:`py-1 pr-2`,children:Nn(t.date)}),e.map(e=>(0,F.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:Mn(t[kn[e]]?.value,e)},e)),(0,F.jsx)(`td`,{className:`py-1 pr-2 text-right tabular-nums`,children:t.completed}),(0,F.jsx)(`td`,{className:`py-1 text-right tabular-nums`,children:t.avgCycleHours===null?`—`:K(t.avgCycleHours)})]},t.date))})]})}function In({metric:e,series:t}){let n=hn[e],r=kn[e],i=t.reduce((e,t)=>e+(t[r]?.reportedTasks??0),0);return(0,F.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium ${n.text}`,children:An[e]}),(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(Pn,{series:t,describe:t=>`${t.date}, ${An[e]}: ${Mn(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,F.jsxs)(`p`,{children:[Nn(t.date),` · `,Mn(t[r]?.value,e),` ·`,` `,t[r]?.reportedTasks??0,`/`,t.tasks,` tasks reported`]})})}),i===0&&(0,F.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No reports in this period.`})]})}function Ln({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,F.jsxs)(`div`,{className:`rounded-xl border p-3`,children:[(0,F.jsxs)(`div`,{className:`flex flex-wrap items-baseline justify-between gap-2`,children:[(0,F.jsx)(`p`,{className:`text-xs font-medium text-success`,children:`Completed tasks`}),(0,F.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[t,` done · avg cycle`,` `,i===null?`unavailable`:K(i)]})]}),(0,F.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[r,`/`,t,` completed tasks have valid cycle times.`]}),(0,F.jsx)(`div`,{className:`mt-2`,children:(0,F.jsx)(Pn,{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,F.jsxs)(`div`,{children:[(0,F.jsxs)(`p`,{children:[Nn(e.date),` · `,e.completed,` completed`]}),(0,F.jsxs)(`p`,{children:[`Avg cycle`,` `,e.avgCycleHours===null?`unavailable`:K(e.avgCycleHours),` · Median`,` `,e.medianCycleHours===null?`unavailable`:K(e.medianCycleHours)]})]})})}),t===0&&(0,F.jsx)(`p`,{className:`mt-2 text-xs text-muted-foreground`,children:`No tasks finished in this period.`})]})}function Rn(){return(0,F.jsx)(zn,{visibility:Ge(a().data)})}function zn({visibility:e}){let[t,n]=yt(`trendPeriod`,[`7d`,`30d`],`7d`),r=pn(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=jn({cost:e.cost&&i?.visibility.cost!==!1,tokens:e.tokens&&i?.visibility.tokens!==!1});return(0,F.jsxs)(j,{className:`gap-0 py-0`,children:[(0,F.jsxs)(`div`,{className:R,children:[(0,F.jsx)(`h2`,{className:L,children:`Trends`}),(0,F.jsxs)(`label`,{className:nt,children:[`Period`,(0,F.jsxs)(rt,{value:t,onChange:e=>n(e.target.value),children:[(0,F.jsx)(`option`,{value:`7d`,children:`Last 7 days`}),(0,F.jsx)(`option`,{value:`30d`,children:`Last 30 days`})]})]})]}),(0,F.jsxs)(`div`,{className:`space-y-4 p-4 text-sm`,children:[i&&(0,F.jsx)(I,{rows:a?[]:i.series.flatMap(e=>[...o.map(t=>({section:`daily-creation-cohort`,entity:e.date,metric:kn[t],value:e[kn[t]]?.value??null,unit:t===`cost`?`USD`:`tokens`,reportedTasks:e[kn[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,F.jsxs)(`details`,{className:`text-xs text-muted-foreground`,children:[(0,F.jsxs)(`summary`,{"data-export-heading":`Metric definitions`,className:`${tt} py-2`,children:[(0,F.jsx)(z,{}),`How these metrics work`]}),(0,F.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,F.jsx)(`p`,{children:`Loading trends…`}),r.isError&&(0,F.jsxs)(`p`,{role:`alert`,children:[i?`Showing stale trends. Could not refresh.`:`Could not load trends.`,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>void r.refetch(),children:`Retry`})]}),i&&(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:(0,F.jsx)(ot,{at:i.asOf})}),i&&(0,F.jsx)(G,{coverage:i.coverage,retry:()=>void r.refetch()}),i&&a&&(0,F.jsx)(`p`,{className:`text-muted-foreground`,children:`No retained tasks in this period yet.`}),i&&!a&&i.series.length>0&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`div`,{className:`space-y-4`,children:[o.length>0&&(0,F.jsx)(`div`,{className:`grid gap-3 sm:grid-cols-[repeat(auto-fit,minmax(200px,1fr))]`,children:o.map(e=>(0,F.jsx)(In,{metric:e,series:i.series},e))}),(0,F.jsx)(Ln,{series:i.series})]}),(0,F.jsxs)(`details`,{className:`group rounded-lg border bg-muted/20 print:block`,children:[(0,F.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,F.jsx)(Ze,{className:`size-4`,"aria-hidden":`true`}),` View data table`,(0,F.jsx)(Le,{className:`ml-auto size-4 transition-transform group-open:rotate-180`,"aria-hidden":`true`})]}),(0,F.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,F.jsx)(Fn,{metrics:o,series:i.series})})]})]})]})]})}function Bn(e,t,n,r=!0){let a=i();return o({queryKey:[...X.snapshot,e?.snapshotId,t,n],enabled:r&&!!e,retry:!1,queryFn:async({signal:r})=>{if(!e)throw Error(`Dashboard not loaded`);let i=[];try{for(let a=0;a<n;){let o=await $t(e.snapshotId,t,a,Math.min(20,n-a),r);if(i.push(...o.page.rows),o.page.nextOffset===null)break;a=o.page.nextOffset}return i}catch(e){if(e instanceof d&&e.status===409){let e=await Qt(r);a.setQueryData(X.snapshot,e)}throw e}}})}function Vn(e,t,n,r){let a=i(),s=t===`questions`||t===`reviews`?`needs-you`:t,c=s===`needs-you`?0:n,l=r.map(e=>`${e.projectId}:${e.id}`).sort();return o({queryKey:[...X.snapshot,e.snapshotId,t,`displaced`,...l],enabled:l.length>0,retry:!1,queryFn:async({signal:t})=>{let n=new Set(l),r=new Map;try{for(let i=c;i!==null&&n.size;){let a=await $t(e.snapshotId,s,i,20,t);for(let e of a.page.rows){let t=`${e.projectId}:${e.id}`;n.delete(t)&&r.set(t,e)}i=a.page.nextOffset}return r}catch(e){throw e instanceof d&&e.status===409&&a.setQueryData(X.snapshot,await Qt(t)),e}}})}function Hn({snapshot:e,questions:t,reviews:n,more:r,healthy:i=!0}){let a=le();return(0,F.jsxs)(j,{className:`min-w-0 gap-0 overflow-hidden py-0`,children:[(0,F.jsxs)(`div`,{className:R,children:[(0,F.jsxs)(`h2`,{id:`dashboard-needs-you`,tabIndex:-1,className:L,children:[`Needs you · `,e.counts.questions+e.counts.reviews]}),(0,F.jsxs)(`p`,{className:`font-mono text-meta 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,F.jsxs)(`p`,{className:`flex items-center gap-2.5 px-4 py-8 text-sm text-muted-foreground`,children:[(0,F.jsx)(M,{tone:`success`}),`All caught up — no tasks need your input`]}):null,(0,F.jsx)(Un,{snapshot:e,group:`questions`,count:t,more:r}),(0,F.jsx)(Un,{snapshot:e,group:`reviews`,count:n,more:r})]})}function Un({snapshot:e,group:t,count:n,more:r}){let i=e[t],a=Math.max(n,i.rows.length),o=Bn(e,t,a,a>i.rows.length),s=a>i.rows.length?o.data:i.rows,c=ft(s,W,t,n),l=Vn(e,t,a,c.rows.filter(e=>e.removed).map(e=>e.row)),u=(0,P.useRef)(null);return!i.total&&!c.rows.length?null:(0,F.jsxs)(`section`,{children:[(0,F.jsxs)(`h3`,{ref:u,tabIndex:-1,className:`border-b bg-card-2 px-4 py-2 eyebrow text-muted-foreground`,children:[t===`questions`?`Questions`:`Reviews`,` · `,i.total]}),c.updates>0&&(0,F.jsxs)(C,{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,F.jsx)(_t,{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,F.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not check current task state.`,` `,(0,F.jsx)(C,{variant:`ghost`,className:`min-h-11`,onClick:()=>{o.refetch(),l.refetch()},children:`Retry`})]}),a<i.total&&(0,F.jsxs)(C,{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 Wn(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 Gn=e=>e.key;function Kn({filter:e,setFilter:t,count:n,more:r}){let i=rn(e,!0),a=ft(i.data?.rows,Gn,`feed:${e}`,0,e=>e.kind===`task-result`),o=a.rows,s=a.updates,c=(0,P.useContext)(ut),l=(0,P.useRef)(null),u=`feed:${e}`,d=(0,P.useMemo)(()=>({scroll:ht(c,u)?.scroll??0,done:!1}),[c,u]);(0,P.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,P.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,F.jsxs)(j,{"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,F.jsxs)(`div`,{className:`space-y-2 border-b px-4 pt-2.5 pb-2`,children:[(0,F.jsxs)(`div`,{className:`flex min-h-9 flex-wrap items-center justify-between gap-2`,children:[(0,F.jsx)(`h2`,{ref:f,tabIndex:-1,className:L,children:b?`Recent results`:`Recent results & GitHub`}),(0,F.jsx)(`span`,{className:`font-mono text-meta text-soft-foreground`,children:`Last 7 days`})]}),!b&&(0,F.jsx)(be,{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,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Task results · No GitHub repositories configured`}),e!==`tasks`&&!b&&(0,F.jsxs)(`details`,{className:`text-xs text-muted-foreground`,open:y.length||h?!0:void 0,children:[(0,F.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,F.jsx)(z,{}),y.length||h?`GitHub needs attention`:_?`Checking GitHub…`:v?`GitHub not configured`:m?`GitHub checked ${N(m)} ago`:`GitHub source`]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-x-3`,children:[(0,F.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 ${N(m)} ago`:`GitHub snapshot`}),!v&&(0,F.jsx)(C,{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,F.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&&gt(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,F.jsxs)(`p`,{role:`alert`,className:`p-4 text-sm`,children:[`Could not load results.`,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>{i.retryFailed()},children:`Retry`})]}),i.isPending&&(0,F.jsx)(`p`,{className:`p-4 text-sm`,children:`Loading results…`}),s>0&&(0,F.jsxs)(C,{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,F.jsx)(_t,{row:e.run,kicker:t?`Outside current results`:`Latest result: ${e.run.status===`failed`?`Failed`:`Completed`}`},e.key):(0,F.jsxs)(`div`,{className:`border-b px-4 py-3 transition-colors hover:bg-muted/30`,children:[(0,F.jsx)(I,{rows:[{section:`github`,entity:`${e.repo}#${e.number}`,metric:e.itemKind,value:e.title,asOf:e.at,note:e.url}]}),(0,F.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,F.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[e.repo,` · `,e.itemKind===`pr`?`PR`:`Issue`,` #`,e.number,` created ·`,` `,N(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,F.jsx)(`p`,{className:`px-4 py-8 text-sm text-muted-foreground`,children:`No results in the last 7 days`}),n<o.length&&(0,F.jsxs)(C,{variant:`ghost`,className:`m-2 min-h-11`,onClick:r,children:[`Show `,Math.min(20,o.length-n),` more results`]}),i.data?.truncated&&(0,F.jsx)(`p`,{className:`p-4 text-xs`,children:`Showing the latest 60 results`}),i.data&&(0,F.jsx)(G,{coverage:i.data.coverage,retry:()=>{i.retryTasks()}}),!b&&i.data?.sources.some(e=>e.state!==`ready`||e.truncated)&&(0,F.jsxs)(`details`,{className:`p-4 text-xs`,children:[(0,F.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,F.jsx)(z,{}),`Source details`]}),i.data.sources.map(e=>(0,F.jsxs)(`p`,{className:`break-words py-1`,children:[Wn(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 ${N(e.fetchedAt)}`:``]},e.key))]})]})]})}var $=e=>e.replace(/[&<>"']/g,e=>({"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`})[e]),qn=`Visible modules and loaded rows only. Filters and report availability apply. Retained task usage is not an invoice or a complete history.`,Jn=`Confidential — internal distribution only`,Yn={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 Xn(e,t){return e==null?`Unavailable`:typeof e==`string`?e:vt(e,t)}function Zn(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=Yn[e.metric];!i||t.has(e.metric)||(t.add(e.metric),n.push({label:i.label,value:Xn(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 Qn(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 $n(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:Qn(e),rows:[...e.querySelectorAll(`[data-dashboard-export]`)].flatMap(e=>JSON.parse(e.dataset.dashboardExport))}})}}function er(e){let t=e==null?``:String(e);return typeof e==`string`&&/^[\s\uFEFF]*[=+@\-]/.test(t)&&(t=`'${t}`),`"${t.replaceAll(`"`,`""`)}"`}function tr(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`,qn,``,``,``,``,``,[...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(er).join(`,`)).join(`\r
2
+ `)+`\r
3
+ `}function nr(e,t){let n=Zn(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
+ @page {
5
+ size:A4; margin:14mm 14mm 18mm;
6
+ @bottom-left { content:"${Jn}"; font-family:system-ui,sans-serif; font-size:9px; color:var(--muted-foreground); }
7
+ @bottom-right { content:"Page " counter(page) " of " counter(pages); font-family:system-ui,sans-serif; font-size:9px; color:var(--muted-foreground); }
8
+ }
9
+ html,body { height:auto!important; overflow:visible!important; background:var(--background)!important; color:var(--foreground)!important; }
10
+ * { -webkit-print-color-adjust:exact; print-color-adjust:exact; }
11
+ body { margin:0; font:12px/1.5 system-ui,sans-serif; }
12
+ .report-heading { border-bottom:2px solid var(--violet); padding-bottom:16px; margin-bottom:20px; }
13
+ .report-heading h1 { font-size:26px; margin:0 0 8px; }
14
+ .report-heading p { margin:4px 0; color:var(--muted-foreground); }
15
+ .report-confidential { display:inline-block; margin:6px 0; padding:2px 8px; border:1px solid var(--destructive); border-radius:4px; color:var(--destructive); font-size:11px; font-weight:600; letter-spacing:.03em; text-transform:uppercase; }
16
+ .report-summary { margin:0 0 24px; }
17
+ .report-summary h2 { font-size:12px; margin:0 0 10px; text-transform:uppercase; letter-spacing:.04em; color:var(--muted-foreground); }
18
+ .summary-grid { display:flex; flex-wrap:wrap; gap:12px; }
19
+ .summary-tile { flex:1 1 140px; border:1px solid var(--border); border-radius:8px; padding:12px 14px; break-inside:avoid; }
20
+ .summary-value { display:block; font-size:22px; font-weight:600; }
21
+ .summary-label { display:block; font-size:11px; color:var(--muted-foreground); margin-top:2px; }
22
+ .summary-note { display:block; font-size:10px; color:var(--soft-foreground); margin-top:4px; }
23
+ .report-module { margin:0 0 20px; break-before:auto; }
24
+ .report-module h2,.report-module h3 { break-after:avoid; }
25
+ .report-module-usage, .report-module-fleet { break-inside:avoid; }
26
+ .report-module-usage label { min-height:0!important; }
27
+ .report-module-usage .space-y-4 > :not(:last-child) { margin-block-end:8px!important; }
28
+ .report-module-usage .report-row { padding-top:5px!important; padding-bottom:5px!important; }
29
+ .report-cost-metrics { grid-template-columns:repeat(3,minmax(0,1fr))!important; }
30
+ .report-cost-metrics > div { padding:12px!important; break-inside:avoid; }
31
+ .report-cost-metrics .text-3xl { font-size:22px!important; }
32
+ .report-module > :first-child, .report-module header, .report-context { break-after:avoid; }
33
+ .report-module .report-row, .report-module tr { break-inside:avoid; }
34
+ .report-module thead { display:table-header-group; }
35
+ .report-module .report-row { padding-top:8px!important; padding-bottom:8px!important; }
36
+ .report-module a { min-height:0!important; }
37
+ .report-module > div { padding-top:12px!important; padding-bottom:12px!important; }
38
+ .report-module * { overflow:visible !important; max-height: none !important; animation:none!important; transition:none!important; box-shadow:none!important; }
39
+ .report-module a { color:inherit; text-decoration:none; }
40
+ .report-module svg { max-width:24px; }
41
+ .report-module [role=region] > div, .report-module [role=region] > p { break-inside:avoid; }
42
+ .report-module .sr-only { display:none!important; }
43
+ .report-context { font-size:11px; color:var(--muted-foreground); margin:0 0 8px; }
44
+ </style></head><body><header class="report-heading"><h1>${$(e.title||`Dashboard report`)}</h1><p>${$(e.generatedAt)} · ${$(e.source)}</p><span class="report-confidential">${Jn}</span><p>${$(qn)}</p>${e.notices.map(e=>`<p>${$(e)}</p>`).join(``)}</header>${n.length?`<section class="report-summary"><h2>Executive summary</h2><div class="summary-grid">${n.map(e=>`<div class="summary-tile"><span class="summary-value">${$(e.value)}</span><span class="summary-label">${$(e.label)}</span>${e.note?`<span class="summary-note">${$(e.note)}</span>`:``}</div>`).join(``)}</div></section>`:``}${e.modules.map(e=>`<section class="report-module${e.id===`usage`?` report-module-usage`:e.id===`fleet`?` report-module-fleet`:``}"><p class="report-context">${$(e.filters)}</p>${e.html}</section>`).join(``)}</body></html>`}function rr({dashboard:e}){let[t,n]=(0,P.useState)(!1),[r,i]=(0,P.useState)(``),[a,o]=(0,P.useState)(!1),[s,c]=(0,P.useState)(``),l=t=>{i(``);try{if(!e.current)return;let r=$n(e.current,new Date().toISOString(),location.origin,s.trim());if(!r.modules.length){i(`Show at least one dashboard module before exporting.`);return}if(t===`csv`){let e=URL.createObjectURL(new Blob([tr(r)],{type:`text/csv;charset=utf-8`})),t=document.createElement(`a`);t.href=e,t.download=`dashboard-${r.generatedAt.replaceAll(`:`,`-`)}.csv`,document.body.append(t),t.click(),t.remove(),setTimeout(()=>URL.revokeObjectURL(e),1e3),n(!1)}else{o(!0);let e=[...document.querySelectorAll(`link[rel="stylesheet"],style`)].flatMap(e=>{if(e.tagName===`STYLE`)return[e.outerHTML];let t=e.href;if(new URL(t).origin!==location.origin)return[];let n=document.createElement(`link`);return n.rel=`stylesheet`,n.href=t,[n.outerHTML]}),t=document.createElement(`iframe`);t.title=`Dashboard PDF report`,t.style.cssText=`position:fixed;width:1000px;height:1px;bottom:0;left:0;border:0;opacity:0;pointer-events:none`;let a,s=()=>{clearTimeout(a),t.remove(),o(!1)};t.onload=async()=>{try{let e=t.contentWindow;await e.document.fonts.ready,e.addEventListener(`afterprint`,s,{once:!0}),e.focus(),e.print(),n(!1),o(!1)}catch{s(),i(`Could not open the print dialog. Please try again.`)}},a=setTimeout(s,12e4),t.srcdoc=nr(r,e),document.body.append(t)}}catch{o(!1),i(`Could not prepare the export. Please try again.`)}};return(0,F.jsxs)(oe,{open:t,onOpenChange:n,children:[(0,F.jsx)(ae,{asChild:!0,children:(0,F.jsxs)(C,{variant:`outline`,className:`min-h-11`,disabled:a,children:[(0,F.jsx)(Ue,{className:`size-4`}),a?`Preparing report…`:`Export`]})}),(0,F.jsxs)(ie,{align:`end`,className:`max-w-[calc(100vw-2rem)] space-y-3`,children:[(0,F.jsx)(`p`,{className:`text-sm font-medium`,children:`Export current dashboard`}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Visible modules, current filters and loaded rows. Hidden metrics are excluded.`}),(0,F.jsxs)(`label`,{className:`block space-y-1 text-xs text-muted-foreground`,children:[`Report title (optional)`,(0,F.jsx)(`input`,{className:`min-h-11 w-full rounded-md border bg-background px-3 text-sm text-foreground`,placeholder:`e.g. Fleet review for leadership`,value:s,onChange:e=>c(e.target.value)})]}),(0,F.jsx)(C,{className:`min-h-11 w-full`,onClick:()=>l(`pdf`),children:`PDF report…`}),(0,F.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Choose Save as PDF in the print dialog.`}),(0,F.jsx)(C,{variant:`outline`,className:`min-h-11 w-full`,onClick:()=>l(`csv`),children:`Download CSV`}),r&&(0,F.jsx)(`p`,{role:`alert`,className:`text-sm`,children:r})]})]})}var ir={overview:`Workspace overview`,portfolio:`Projects`,automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`};function ar({id:e,children:t,wide:n}){let{attributes:r,listeners:i,setNodeRef:a,setActivatorNodeRef:o,transform:s,isDragging:c}=_e({id:e});return(0,F.jsxs)(`section`,{ref:a,"data-dashboard-module":e,className:`group/module relative min-w-0 ${n?`lg:col-span-2`:``} ${c?`z-20 opacity-80`:``}`,style:{transform:s?`translate3d(${s.x}px, ${s.y}px, 0)`:void 0},children:[(0,F.jsx)(C,{ref:o,variant:`ghost`,className:`absolute -top-[22px] left-1/2 z-10 min-h-11 min-w-11 -translate-x-1/2 cursor-grab touch-none p-0 opacity-0 transition-opacity hover:bg-transparent focus-visible:opacity-100 active:cursor-grabbing group-hover/module:opacity-100 no-hover:opacity-100`,...r,...i,"aria-label":`Move ${ir[e]}`,children:(0,F.jsx)(`span`,{className:`flex h-4 w-8 items-center justify-center rounded-full border bg-card text-muted-foreground shadow-xs`,children:(0,F.jsx)(Xe,{className:`size-3.5`,"aria-hidden":`true`})})}),t]})}function or({order:e,modules:t,onOrder:n}){let r=ue(we(Te,{activationConstraint:{distance:8}}),we(Se,{coordinateGetter:ye})),i=e.filter(e=>t[e]),a=new Set([`overview`,`portfolio`,`usage`,`trends`]),o;for(let e of i)a.has(e)?(o&&a.add(o),o=void 0):o=o?void 0:e;o&&a.add(o);let s=e=>`${ir[e]}, position ${i.indexOf(e)+1} of ${i.length}`;return(0,F.jsx)(fe,{sensors:r,collisionDetection:pe,accessibility:{announcements:{onDragStart:({active:e})=>`Picked up ${s(e.id)}.`,onDragOver:({active:e,over:t})=>t?`${ir[e.id]} moved to position ${i.indexOf(t.id)+1} of ${i.length}.`:void 0,onDragEnd:({active:e,over:t})=>t?`${ir[e.id]} dropped at position ${i.indexOf(t.id)+1} of ${i.length}.`:`Order unchanged. ${s(e.id)}.`,onDragCancel:({active:e})=>`Reordering cancelled. ${s(e.id)}.`},screenReaderInstructions:{draggable:`Press Space to pick up a module, use arrow keys to move, Space to drop, or Escape to cancel.`}},onDragEnd:({active:t,over:r})=>{!r||t.id===r.id||n(ge(e,e.indexOf(t.id),e.indexOf(r.id)))},children:(0,F.jsx)(he,{items:i,strategy:xe,children:(0,F.jsx)(`div`,{className:`grid items-start gap-5 lg:grid-cols-2`,children:i.map(e=>(0,F.jsx)(ar,{id:e,wide:a.has(e),children:t[e]},e))})})})}var sr=[`overview`,`needsYou`,`recent`,`fleet`,`automations`,`portfolio`,`usage`,`trends`],cr=e=>sr.includes(e);function lr(e=[]){let t=e.filter(cr);return(e=>t.length===e.length&&t.every((t,n)=>t===e[n]))(sr.filter(e=>e!==`automations`))?[...sr]:[...new Set([...t.includes(`overview`)?[]:[`overview`],...t,...sr])]}function ur(e=[],t){let n=0;return[...e.map(e=>cr(e)?t[n++]:e),...t.slice(n)]}function dr(){let e=u(),t=i(),[n,a]=(0,P.useState)(),[o,s]=(0,P.useState)(!1),c=(0,P.useRef)(void 0),l=(0,P.useRef)(!1),d=T.parse(e.data?.dashboard??{}),f=(0,P.useRef)(d);f.current=d;let h=n?.tiles??{automations:d.tiles?.automations??!0,fleet:d.tiles?.fleet??!0,needsYou:d.tiles?.needsYou??!0,recent:d.tiles?.recent??!0,usage:d.tiles?.usage??!0,trends:d.tiles?.trends??!0},g=lr(n?.order??d.order),_=(0,P.useRef)({tiles:h,order:g});_.current=n??{tiles:h,order:g};let v=e=>{let t={..._.current,...e};_.current=t,a(t),c.current=t},y=async()=>{if(!(l.current||!c.current)){for(l.current=!0;c.current;){let n=c.current;c.current=void 0;try{e.data||(f.current=T.parse((await p()).dashboard??{}));let i=await r({dashboard:{...f.current,order:ur(f.current.order,n.order),tiles:{...f.current?.tiles,...n.tiles}}});t.setQueryData(m.uiState,i),f.current=T.parse(i.dashboard??{}),s(!1),a(e=>e===n?void 0:e)}catch{s(!0),c.current||=n;break}}l.current=!1}},b=(0,P.useRef)(y);return b.current=y,(0,P.useEffect)(()=>()=>{b.current()},[]),(0,P.useEffect)(()=>{if(!n)return;let e=setTimeout(()=>{y()},250);return()=>clearTimeout(e)},[n]),{tiles:h,order:g,setOrder:e=>v({order:lr(e)}),failed:o,ready:e.data!==void 0||e.isError,setTiles(e){v({tiles:e})},retry:()=>{y()}}}function fr(e,t){let n=sr.filter(e=>t.includes(e)),r=0;return e.map(e=>t.includes(e)?n[r++]:e)}var pr=[[`overview`,`Overview`],[`costs`,`Usage & cost`],[`automations`,`Automations`]];function mr(){let e=ne(),t=e.state?.dashboardEntry??e.key;return(0,F.jsx)(hr,{entryKey:t},t)}function hr({entryKey:e}){let t=ne(),[n,r]=te(),i=(0,P.useRef)(pt(e)).current,[a,o]=(0,P.useState)(i?.questions??0),[s,c]=(0,P.useState)(i?.reviews??0),[l,u]=(0,P.useState)(i?.feed??6),d=(0,P.useRef)(null),f=(0,P.useRef)(null),[p,m]=(0,P.useState)(!1),h=dr(),[g,_]=(0,P.useState)(!1),v=n.get(`view`)===`costs`?`costs`:n.get(`view`)===`automations`?`automations`:`overview`,y=pr.find(([e])=>e===v)[1],b=v===`costs`?[`usage`,`trends`]:v===`automations`?[`automations`]:[`fleet`,`needsYou`,`recent`],ee=v===`overview`?[`overview`,`portfolio`,...b]:[...b],x=fr(h.order,ee),S=()=>h.setTiles({...h.tiles,...Object.fromEntries(b.map(e=>[e,!0]))}),w=h.tiles,T={...w,automations:v===`automations`&&w.automations,fleet:v===`overview`&&w.fleet,needsYou:v===`overview`&&w.needsYou,recent:v===`overview`&&w.recent,usage:v===`costs`&&w.usage,trends:v===`costs`&&w.trends},re=n.get(`feed`)===`tasks`?`tasks`:n.get(`feed`)===`github`?`github`:`all`,se=n.get(`panel`),D=se&&[`running`,`queued`,`scheduled`,`needs-you`].includes(se)?se:null,ce=T.fleet||T.needsYou||T.recent&&re!==`github`||!!D,O=en(h.ready&&ce),k=le();tn(h.ready&&T.fleet&&g);let A=(0,P.useRef)({questions:a,reviews:s,feed:l,scroll:i?.scroll??0,focus:i?.focus});A.current={...A.current,questions:a,reviews:s,feed:l},(0,P.useEffect)(()=>{let t=d.current?.closest(`main`)??d.current,n=()=>{A.current.scroll=t?.scrollTop??0},r=()=>{A.current.focus=document.activeElement?.closest(`[data-dashboard-row]`)?.getAttribute(`data-dashboard-row`)??void 0};return t?.addEventListener(`scroll`,n),document.addEventListener(`focusin`,r),()=>{mt(e,A.current),t?.removeEventListener(`scroll`,n),document.removeEventListener(`focusin`,r)}},[e]);let ue=(0,P.useRef)(!1),fe=h.ready&&(!ce||!!O.data&&!O.isFetching);(0,P.useEffect)(()=>{if(!i||ue.current||!fe)return;let e=!1,t=()=>{if(e)return!0;let t=d.current?.closest(`main`)??d.current;t&&(t.scrollTop=i.scroll);let n=!!t&&Math.abs(t.scrollTop-i.scroll)<1;if(!i.focus)return n;let r=document.querySelector(`[data-dashboard-row="${CSS.escape(i.focus)}"] a`);return r?(r.focus({preventScroll:!0}),n):(document.getElementById(`dashboard-needs-you`)?.focus({preventScroll:!0}),!1)},n=()=>{t()&&o()},r=new MutationObserver(n),a=typeof ResizeObserver>`u`?null:new ResizeObserver(n),o=()=>{e=!0,ue.current=!0,r.disconnect(),a?.disconnect()},s=requestAnimationFrame(()=>{n(),e||(r.observe(document.body,{childList:!0,subtree:!0}),d.current&&a?.observe(d.current))}),c=setTimeout(o,5e3),l=[`pointerdown`,`keydown`,`wheel`,`touchstart`];for(let e of l)document.addEventListener(e,o,{once:!0});return()=>{cancelAnimationFrame(s),clearTimeout(c),e=!0,r.disconnect(),a?.disconnect();for(let e of l)document.removeEventListener(e,o)}},[i,fe]);let pe=i=>{let a=new URLSearchParams(n);i?a.set(`panel`,i):a.delete(`panel`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}})},me=(e,t)=>{f.current=t,pe(e)},he=O.data?O.data.counts.questions+O.data.counts.reviews:0;return(0,F.jsx)(ut.Provider,{value:e,children:(0,F.jsx)(dt.Provider,{value:!i||!O.isFetching&&!O.isError,children:(0,F.jsxs)(`div`,{ref:d,"data-route":`dashboard`,className:`mx-auto w-full max-w-[1440px] space-y-6 p-4 md:px-8 md:py-7`,children:[(0,F.jsxs)(`header`,{className:`flex flex-wrap items-end justify-between gap-4`,children:[(0,F.jsxs)(`div`,{className:`min-w-0`,children:[(0,F.jsx)(`h1`,{className:`text-2xl font-semibold tracking-tight`,children:`Dashboard`}),(0,F.jsxs)(`p`,{className:`mt-1 flex flex-wrap items-center gap-x-2 text-xs text-muted-foreground`,children:[`Across your workspace · Includes subtasks`,(0,F.jsxs)(`span`,{"data-export-exclude":!0,className:`inline-flex items-center gap-1.5 rounded-full border px-2 py-0.5 eyebrow`,children:[(0,F.jsx)(M,{tone:k.connected?`success`:`neutral`,pulse:k.connected}),k.connected?`Live`:`Offline`]})]})]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,F.jsx)(rr,{dashboard:d}),(0,F.jsxs)(oe,{open:p,onOpenChange:m,children:[(0,F.jsx)(ae,{asChild:!0,children:(0,F.jsxs)(C,{variant:`outline`,className:`min-h-11`,children:[(0,F.jsx)(Ce,{className:`size-4`}),`Customize`]})}),(0,F.jsxs)(ie,{align:`end`,className:`max-h-[min(32rem,80dvh)] max-w-[calc(100vw-2rem)] overflow-y-auto`,children:[(0,F.jsx)(`p`,{className:`mb-3 text-sm font-medium`,children:`Optional modules in this view`}),b.map(e=>(0,F.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,F.jsx)(`input`,{type:`checkbox`,checked:w[e],disabled:!h.ready,onChange:t=>h.setTiles({...w,[e]:t.target.checked})}),{automations:`Automations`,fleet:`Queue & scheduling`,needsYou:`Needs you`,recent:`Recent results & GitHub`,usage:`Usage & cost`,trends:`Trends`}[e]]},e)),(0,F.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:`Drag a module by its handle. With keyboard: Space, arrow keys, Space. Escape cancels.`}),h.order.some((e,t)=>e!==x[t])&&(0,F.jsxs)(C,{variant:`ghost`,className:`min-h-11`,onClick:()=>h.setOrder(x),children:[`Reset `,y,` order`]}),(0,F.jsx)(`p`,{className:`my-3 text-xs text-muted-foreground`,children:`Shared across browsers using this workspace`}),b.some(e=>!w[e])&&(0,F.jsxs)(C,{variant:`outline`,className:`min-h-11`,disabled:!h.ready,onClick:()=>{S(),m(!1)},children:[`Show all in `,y]})]})]})]})]}),(0,F.jsx)(`nav`,{"aria-label":`Dashboard views`,className:`-mt-2 flex flex-wrap gap-5 border-b`,children:pr.map(([r,i])=>{let a=new URLSearchParams(n);return a.set(`view`,r),a.delete(`panel`),(0,F.jsx)(C,{asChild:!0,variant:`ghost`,className:`-mb-px min-h-11 rounded-none border-b-2 px-0.5 hover:bg-transparent ${v===r?`border-primary text-foreground`:`border-transparent`}`,children:(0,F.jsx)(E,{"aria-current":v===r?`page`:void 0,to:`?${a}`,replace:v===r,state:{...t.state,dashboardEntry:v===r?e:void 0},children:i})},r)})}),h.failed&&(0,F.jsxs)(`p`,{role:`alert`,className:`text-sm`,children:[`Layout changed for this session, but could not be saved.`,` `,(0,F.jsx)(C,{variant:`ghost`,className:`min-h-11`,onClick:h.retry,children:`Retry saving`})]}),ce&&!k.connected&&O.data&&(0,F.jsxs)(`p`,{role:`status`,className:`text-xs text-muted-foreground`,children:[`Tasks disconnected · Last updated `,N(O.data.asOf),` ago`]}),ce&&O.isError&&(0,F.jsxs)(`p`,{role:`alert`,className:`rounded-md border p-4 text-sm`,children:[`Could not refresh dashboard.`,` `,O.data?`Showing the last available task state.`:``,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>{O.refetch()},children:`Retry`})]}),v===`costs`&&!Object.values(T).some(Boolean)?(0,F.jsxs)(`p`,{role:`status`,className:`flex flex-wrap items-center gap-2 text-sm text-muted-foreground`,children:[(0,F.jsx)(de,{className:`size-4`,"aria-hidden":`true`}),`Optional modules in this view are hidden.`,(0,F.jsxs)(C,{variant:`outline`,className:`min-h-11`,onClick:()=>S(),children:[`Show all in `,y]})]}):null,O.isPending&&(T.fleet||T.needsYou)&&(0,F.jsx)(`p`,{className:`text-sm`,children:`Loading dashboard…`}),ce&&O.data&&(0,F.jsx)(G,{coverage:O.data.coverage,count:he,retry:()=>void O.refetch()}),v===`automations`&&(0,F.jsx)(Lt,{}),(0,F.jsx)(Jt,{active:v===`overview`,onCurrent:me,children:i=>h.ready&&(0,F.jsx)(or,{order:h.order,onOrder:h.setOrder,modules:{...i,automations:T.automations?(0,F.jsx)(st,{}):null,fleet:T.fleet&&O.data?(0,F.jsxs)(j,{className:`gap-0 py-0`,children:[(0,F.jsx)(I,{rows:Object.entries({queued:O.data.counts.queued,scheduled:O.data.counts.scheduled,monitoring:O.data.counts.monitoring}).map(([e,t])=>({section:`fleet`,metric:e,value:t,unit:`tasks`,asOf:O.data.asOf}))}),(0,F.jsxs)(`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,F.jsx)(`h2`,{className:`section-mark eyebrow text-muted-foreground`,children:`Queue & scheduling`}),(0,F.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,F.jsx)(M,{tone:k.connected?`success`:`neutral`}),k.connected?`Tasks connected`:`Tasks disconnected`]})]}),(0,F.jsx)(`div`,{className:`grid grid-cols-2 divide-x`,children:[[`queued`,`Queued`,O.data.counts.queued],[`scheduled`,`Scheduled`,O.data.counts.scheduled]].map(([e,t,n])=>(0,F.jsxs)(`button`,{"data-export-keep":!0,"aria-label":`${t}: ${n}`,className:`min-h-24 p-4 text-left transition-colors hover:bg-muted/40 focus-visible:outline-ring`,onClick:t=>me(e,t.currentTarget),children:[(0,F.jsx)(`span`,{className:`block eyebrow text-muted-foreground`,children:t}),(0,F.jsx)(`span`,{className:`mt-3 block text-3xl font-semibold leading-none tracking-tight tabular-nums`,children:n})]},e))}),(0,F.jsxs)(`details`,{open:g,onToggle:e=>_(e.currentTarget.open),className:`border-t px-4 py-3 text-xs text-muted-foreground`,children:[(0,F.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-2`,children:[(0,F.jsx)(z,{}),`Technical details`]}),(0,F.jsxs)(`div`,{className:`flex flex-wrap gap-x-5 gap-y-2`,children:[(0,F.jsxs)(`span`,{children:[O.data.counts.monitoring,` monitoring (included in Running)`]}),(0,F.jsx)(`span`,{children:`Agent processes`}),g&&(0,F.jsx)(gr,{running:O.data.counts.running})]})]})]}):null,needsYou:T.needsYou&&O.data?(0,F.jsx)(Hn,{healthy:!O.isError,snapshot:O.data,questions:a,reviews:s,more:(e,t)=>e===`questions`?o(t):c(t)}):null,recent:T.recent?(0,F.jsx)(Kn,{filter:re,setFilter:i=>{let a=new URLSearchParams(n);a.set(`feed`,i||`all`),r(a,{replace:!0,state:{...t.state,dashboardEntry:e}}),u(6)},count:l,more:()=>u(e=>Math.min(60,e+20))}):null,usage:T.usage?(0,F.jsx)(Sn,{}):null,trends:T.trends?(0,F.jsx)(Rn,{}):null}})}),v===`costs`&&(0,F.jsx)(Ft,{}),(0,F.jsx)(ke,{open:!!D,onOpenChange:e=>{e||pe(null)},children:(0,F.jsxs)(Oe,{className:`w-full overflow-y-auto sm:max-w-lg`,onCloseAutoFocus:e=>{e.preventDefault(),f.current?.focus()},children:[(0,F.jsxs)(Ae,{children:[(0,F.jsxs)(je,{children:[D===`needs-you`?`Needs you`:D?D[0].toUpperCase()+D.slice(1):`Tasks`,O.data&&D?` · ${D===`needs-you`?he:O.data.counts[D]}`:``]}),(0,F.jsx)(De,{children:`Includes subtasks. Open a task to continue in its project.`})]}),!O.data&&O.isPending&&(0,F.jsx)(`p`,{className:`p-4`,role:`status`,children:`Loading tasks…`}),!O.data&&O.isError&&(0,F.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not load tasks.`,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>{O.refetch()},children:`Retry`})]}),D&&O.data&&(0,F.jsx)(_r,{snapshot:O.data,group:D},D)]})})]})})})}function gr({running:e}){let{connected:t,samples:n}=le(),r=t?n:[],i=r.filter(e=>e.cpuPct!==null);return(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(I,{rows:[{section:`telemetry`,metric:`cpuPct`,value:i.length?i.reduce((e,t)=>e+(t.cpuPct??0),0):null,unit:`%`,reportedTasks:i.length,totalTasks:e,note:`Sum of sampled processes; may exceed 100%`},{section:`telemetry`,metric:`rssBytes`,value:r.length?r.reduce((e,t)=>e+t.rssBytes,0):null,unit:`bytes`,reportedTasks:r.length,totalTasks:e}]}),(0,F.jsxs)(`span`,{children:[`CPU`,` `,i.length?`${Math.round(i.reduce((e,t)=>e+(t.cpuPct??0),0))}%`:`unavailable`,` `,`· `,i.length,`/`,e,` measured`]}),(0,F.jsxs)(`span`,{children:[`RSS`,` `,r.length?`${(r.reduce((e,t)=>e+t.rssBytes,0)/1024**3).toFixed(1)} GiB`:`unavailable`,` `,`· `,r.length,`/`,e,` measured`]}),(0,F.jsx)(`span`,{children:`RSS sums process resident memory; CPU may exceed 100%.`})]})}function _r({snapshot:e,group:t}){let n=(0,P.useContext)(ut),r=(0,P.useRef)(ht(n,t)).current,[i,a]=(0,P.useState)(r?.count??20),o=(0,P.useRef)(null),s=(0,P.useRef)({count:i,scroll:r?.scroll??0});s.current.count=i,(0,P.useEffect)(()=>{let e=o.current?.closest(`[data-slot="sheet-content"]`),r=()=>{s.current.scroll=e?.scrollTop??0};return e?.addEventListener(`scroll`,r),()=>{gt(n,t,s.current),e?.removeEventListener(`scroll`,r)}},[n,t]);let c=Bn(e,t,i),l=ft(c.data,W,`panel:${t}`,i),u=Vn(e,t,i,l.rows.filter(e=>e.removed).map(e=>e.row)),d=(0,P.useRef)(null),f=(0,P.useRef)(!1);(0,P.useEffect)(()=>{if(!c.data||!r||f.current)return;f.current=!0;let e=o.current?.closest(`[data-slot="sheet-content"]`);e&&(e.scrollTop=r.scroll)},[c.data,r]);let p=t===`needs-you`?e.counts.questions+e.counts.reviews:e.counts[t];return(0,F.jsxs)(`div`,{ref:o,children:[(0,F.jsx)(`h3`,{ref:d,tabIndex:-1,className:`sr-only`,children:`Tasks`}),c.isPending&&(0,F.jsx)(`p`,{className:`p-4`,children:`Loading tasks…`}),(c.isError||u.isError)&&(0,F.jsxs)(`p`,{className:`p-4`,role:`alert`,children:[`Could not check current task state.`,` `,(0,F.jsx)(C,{className:`min-h-11`,onClick:()=>{c.refetch(),u.refetch()},children:`Retry`})]}),l.updates>0&&(0,F.jsxs)(C,{className:`m-4 min-h-11`,onClick:()=>{l.show(),d.current?.focus()},children:[l.updates,` updates — Show`]}),l.rows.map(({row:e,removed:n})=>(0,F.jsx)(_t,{row:u.data?.get(W(e))??e,removed:n&&!!u.data&&!u.data.has(W(e)),checking:!c.data||n&&!u.data,checkFailed:!c.data&&c.isError||n&&!u.data&&u.isError,queue:t===`needs-you`},W(e))),i<p&&(0,F.jsxs)(C,{className:`m-4 min-h-11`,disabled:c.isFetching,onClick:()=>a(e=>e+20),children:[`Show `,Math.min(20,p-i),` more tasks`]})]})}export{mr as DashboardRoute};
@@ -1,3 +1,3 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-oTEcZZ_O.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/button-wdWSPx_B.js","assets/bundle-mjs-rHxsej31.js","assets/chevron-right-DDQuVTY1.js","assets/use-submit-shortcut-B41NLqM4.js","assets/plus-BwQyZgNP.js","assets/lib-w_5wfsBF.js","assets/chunk-BO2N2NFS-Bde6epwZ.js","assets/preload-helper-Czpn1I53.js","assets/lib-BxQXEXDF.js","assets/markdown-G3dvGJao.js","assets/alert-dialog-4Kna6Hd7.js","assets/markdown-BfZORc0a.js","assets/message-square-Dl-ol3uz.js","assets/scroll-within-Dexi68h1.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-wdWSPx_B.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{n as a}from"./lib-w_5wfsBF.js";import{i as o,n as s,r as c,t as l}from"./scroll-within-Dexi68h1.js";var u=e(t(),1),d=n(),f=null,p=null;function m(){return p??=i(()=>import(`./diff-view-oTEcZZ_O.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,17])),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,oldImageSrc:i,onOpenInApp:o,viewRef:c,className:f}){let p={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},m=(0,u.useRef)(null);return(0,u.useImperativeHandle)(c,()=>({scrollToPath:e=>{for(let t of m.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:m,"data-slot":`diff`,"data-fallback":`true`,className:r(`flex min-w-0 flex-col gap-3`,f),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:[p.files,` `,p.files===1?`file`:`files`,` changed`]}),(0,d.jsx)(a,{stat:p})]}),e.map(e=>(0,d.jsx)(_,{file:e,wrap:t,imageSrc:n,onOpenInApp:o,oldImageSrc:i},`${e.oldPath??``}→${e.path}`))]})}function _({file:e,wrap:t,imageSrc:n,onOpenInApp:i,oldImageSrc:s}){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-meta`})})]}),o(e)?(0,d.jsx)(c,{file:e,imageSrc:n,oldImageSrc:s,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(`
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-Du2463vL.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/button-BvYDiOkd.js","assets/bundle-mjs-rHxsej31.js","assets/chevron-right-DuM1UAhq.js","assets/use-submit-shortcut-oBvmLiAo.js","assets/plus-BJEPAJjW.js","assets/lib-C4vuyY62.js","assets/chunk-BO2N2NFS-Bde6epwZ.js","assets/preload-helper-Czpn1I53.js","assets/lib-BxQXEXDF.js","assets/markdown-BBnagS_c.js","assets/alert-dialog-BZU09BVw.js","assets/markdown-DLB6o6YD.js","assets/message-square-WCEmfkiD.js","assets/scroll-within-CNcaqKGp.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-BvYDiOkd.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{n as a}from"./lib-C4vuyY62.js";import{i as o,n as s,r as c,t as l}from"./scroll-within-CNcaqKGp.js";var u=e(t(),1),d=n(),f=null,p=null;function m(){return p??=i(()=>import(`./diff-view-Du2463vL.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,17])),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,oldImageSrc:i,onOpenInApp:o,viewRef:c,className:f}){let p={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},m=(0,u.useRef)(null);return(0,u.useImperativeHandle)(c,()=>({scrollToPath:e=>{for(let t of m.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:m,"data-slot":`diff`,"data-fallback":`true`,className:r(`flex min-w-0 flex-col gap-3`,f),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:[p.files,` `,p.files===1?`file`:`files`,` changed`]}),(0,d.jsx)(a,{stat:p})]}),e.map(e=>(0,d.jsx)(_,{file:e,wrap:t,imageSrc:n,onOpenInApp:o,oldImageSrc:i},`${e.oldPath??``}→${e.path}`))]})}function _({file:e,wrap:t,imageSrc:n,onOpenInApp:i,oldImageSrc:s}){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-meta`})})]}),o(e)?(0,d.jsx)(c,{file:e,imageSrc:n,oldImageSrc:s,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,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-wdWSPx_B.js";import{t as o}from"./chevron-right-DDQuVTY1.js";import{r as s,t as c}from"./use-submit-shortcut-B41NLqM4.js";import{t as l}from"./plus-BwQyZgNP.js";import{n as u,t as d}from"./lib-w_5wfsBF.js";import{o as f}from"./chunk-BO2N2NFS-Bde6epwZ.js";import{a as p,o as m,r as h,t as g}from"./markdown-G3dvGJao.js";import{n as _,t as v}from"./markdown-BfZORc0a.js";import{i as ee,n as y,r as te,t as b}from"./scroll-within-Dexi68h1.js";import{n as x,t as S}from"./types-BTlmexWF.js";var C=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`}]]),w=e(t(),1),T=20.4,E=44;function ne(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
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-BvYDiOkd.js";import{t as o}from"./chevron-right-DuM1UAhq.js";import{r as s,t as c}from"./use-submit-shortcut-oBvmLiAo.js";import{t as l}from"./plus-BJEPAJjW.js";import{n as u,t as d}from"./lib-C4vuyY62.js";import{o as f}from"./chunk-BO2N2NFS-Bde6epwZ.js";import{a as p,o as m,r as h,t as g}from"./markdown-BBnagS_c.js";import{n as _,t as v}from"./markdown-DLB6o6YD.js";import{i as ee,n as y,r as te,t as b}from"./scroll-within-CNcaqKGp.js";import{n as x,t as S}from"./types-BTlmexWF.js";var C=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`}]]),w=e(t(),1),T=20.4,E=44;function ne(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 re(e,t=!0){return Math.round((t?ne(e):1)*T)+E}function ie(e){return e.reduce((e,t)=>e+ne(t),0)}var D=/(^|\/)(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 ae(e){return e.binary===!0||e.image===!0?!1:e.adds+e.dels>400||D.test(e.path)}function oe(e,t){let n=new URLSearchParams(e).get(`diff`);return n===`flat`||n===`virtual`?n:t>1500?`virtual`:`flat`}function O(e){return`${e.oldPath??``}→${e.path}`}function k(e){let t=0;for(let n of e.split(`
3
3
  `))n.length>t&&(t=n.length);return t}function A(e,t){let n=Array(e.length);for(let r of ce(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 j=2e6,M=new Map,N=0;function P(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 F(e){let t=M.get(e);return t!==void 0&&(M.delete(e),M.set(e,t)),t}function I(e,t){if(!(e.length>j/4||M.has(e))){M.set(e,t),N+=e.length;for(let e of M.keys()){if(N<=j)break;N-=e.length,M.delete(e)}}}var L=8,R=[],z=!1;function B(){let e=performance.now();for(;R.length>0&&performance.now()-e<L;){let e=R.shift();e.cancelled||e.run()}R.length>0?setTimeout(B,0):z=!1}function se(e){let t={run:e,cancelled:!1};return R.push(t),z||(z=!0,setTimeout(B,0)),()=>{t.cancelled=!0}}function ce(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 W(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:le(n,o),add:le(r,s)}}function le(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 ue(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 de=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,fe=`… (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-wdWSPx_B.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
+ import{F as e}from"./button-BvYDiOkd.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};