@hearsay-tools/squawk 0.19.0-pr4562.9049 → 0.19.0-pr4563.9056

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 (173) hide show
  1. package/dist/contract/index.d.ts +0 -1
  2. package/dist/contract/index.js +1 -127
  3. package/dist/contract/workspace.d.ts +0 -10
  4. package/dist/delegation/routes.d.ts +4 -4
  5. package/dist/delegation/transport.d.ts +14 -14
  6. package/dist/features/automations/tools.d.ts +8 -8
  7. package/dist/home/entry-authorization.js +1 -1
  8. package/dist/home/entry-authorization.js.map +1 -1
  9. package/dist/home/home.d.ts +0 -2
  10. package/dist/home/home.js +0 -1
  11. package/dist/home/home.js.map +1 -1
  12. package/dist/home/migration-plan.js +1 -1
  13. package/dist/home/migration-plan.js.map +1 -1
  14. package/dist/runs/run-decode.d.ts +72 -72
  15. package/dist/server/live-routes.d.ts +6 -6
  16. package/dist/server/runs-routes.d.ts +18 -18
  17. package/dist/server/server.d.ts +1674 -1693
  18. package/dist/server/server.js +1 -1
  19. package/dist/server/server.js.map +1 -1
  20. package/dist/server/workspace-live-routes.d.ts +7 -28
  21. package/dist/server/workspace-live-routes.js +1 -5
  22. package/dist/server/workspace-live-routes.js.map +1 -1
  23. package/dist/workflows/continuation-admission.d.ts +72 -72
  24. package/dist/workflows/run/wait-engine.d.ts +72 -72
  25. package/dist/workspace/backups.d.ts +1 -1
  26. package/dist/workspace/backups.js +1 -1
  27. package/dist/workspace/backups.js.map +1 -1
  28. package/package.json +4 -4
  29. package/web/dist/assets/accounts-section-DaBblF-c.js +1 -0
  30. package/web/dist/assets/activity-motion-MB52xRs-.js +1 -0
  31. package/web/dist/assets/{activity-route-DdwSinTQ.js → activity-route-CqwI5fne.js} +1 -1
  32. package/web/dist/assets/agent-accounts-BuceIkTR.js +1 -0
  33. package/web/dist/assets/{agent-config-section-DnlY8Xbm.js → agent-config-section-CSvSM3Zw.js} +1 -1
  34. package/web/dist/assets/agent-defaults-section-Cb-JGyZe.js +1 -0
  35. package/web/dist/assets/{appearance-n_gwtyLp.js → appearance-CJKz8mL1.js} +1 -1
  36. package/web/dist/assets/{archive-on-merge-field-DERpOUSW.js → archive-on-merge-field-COQBarEO.js} +1 -1
  37. package/web/dist/assets/ask-card-DvFq3BVf.js +9 -0
  38. package/web/dist/assets/attention-xl4bwNkx.js +1 -0
  39. package/web/dist/assets/automations-route-1nMvkGVt.js +2 -0
  40. package/web/dist/assets/{badge-B6B-xYQQ.js → badge-DVxxThpb.js} +1 -1
  41. package/web/dist/assets/{button-C8jUIs8Q.js → button-B22ANdCY.js} +1 -1
  42. package/web/dist/assets/{command-BiBq24zL.js → command-B2Y0By1v.js} +1 -1
  43. package/web/dist/assets/commit-list-K3D9p5PO.js +1 -0
  44. package/web/dist/assets/control-locations-kCPVEtOM.js +1 -0
  45. package/web/dist/assets/{dialog-DRZuXvul.js → dialog-rpNyAWGb.js} +1 -1
  46. package/web/dist/assets/diff-controls-D8wGIcHf.js +1 -0
  47. package/web/dist/assets/diff-view-BteEhAsF.js +11 -0
  48. package/web/dist/assets/diff-wEs0f18C.js +3 -0
  49. package/web/dist/assets/discard-changes-dialog-CvpFLU5C.js +1 -0
  50. package/web/dist/assets/{file-preview-19dGBVJX.js → file-preview-CpDN9d_c.js} +2 -2
  51. package/web/dist/assets/{folder-browser-TThsZhk0.js → folder-browser-CUUWpb8F.js} +1 -1
  52. package/web/dist/assets/{git-toolbar-DBujlKow.js → git-toolbar-Cnn_j4CT.js} +1 -1
  53. package/web/dist/assets/github-DZOab6Bi.js +1 -0
  54. package/web/dist/assets/{global-activity-route-CIVosoix.js → global-activity-route-DDXyktcZ.js} +2 -2
  55. package/web/dist/assets/index-18CFQ-Aq.css +1 -0
  56. package/web/dist/assets/index-CGDZRQo6.js +21 -0
  57. package/web/dist/assets/{label-BXrhRQd2.js → label-DRXJ8ljY.js} +1 -1
  58. package/web/dist/assets/markdown-BNtZVUvm.js +2 -0
  59. package/web/dist/assets/{open-in-menu-BMkr5oG0.js → open-in-menu-CxD3RKm9.js} +1 -1
  60. package/web/dist/assets/{option-select-Da93ehWa.js → option-select-Dq2k1AU_.js} +1 -1
  61. package/web/dist/assets/page-shell-BgabWJ3w.js +1 -0
  62. package/web/dist/assets/{page-shell-DQPYcKyL.css → page-shell-CEIoW56O.css} +1 -1
  63. package/web/dist/assets/{preferences-section-B61tMP9F.js → preferences-section-BYHloZlu.js} +1 -1
  64. package/web/dist/assets/preview-pane-connected-s2T1ATma.js +3 -0
  65. package/web/dist/assets/{project-location-BxI-ZznW.js → project-location-ByLh86MR.js} +1 -1
  66. package/web/dist/assets/{project-router-C9kvPm0I.js → project-router-C53GCY_8.js} +1 -1
  67. package/web/dist/assets/projects-section-B4qKE8dn.js +1 -0
  68. package/web/dist/assets/{prompt-templates-section-DEW2ZnZN.js → prompt-templates-section-DyP0A_Wu.js} +2 -2
  69. package/web/dist/assets/{queries-DiD4Q1Wu.js → queries-jsRcJKo6.js} +1 -1
  70. package/web/dist/assets/read-state-DOIKdUqa.js +1 -0
  71. package/web/dist/assets/{reference-chip-BKBFx58a.js → reference-chip-95DURw1q.js} +1 -1
  72. package/web/dist/assets/{remote-settings-notice-VMKnQhpL.js → remote-settings-notice-DRBM8wRQ.js} +1 -1
  73. package/web/dist/assets/repo-git-Db2EP-vo.js +1 -0
  74. package/web/dist/assets/report-reader-CocpWpOy.js +1 -0
  75. package/web/dist/assets/{report-selection-Bh4oD7_H.js → report-selection-DAPzf1Aa.js} +1 -1
  76. package/web/dist/assets/{reports-Kg2iWyJ-.js → reports-0iAT6sUi.js} +1 -1
  77. package/web/dist/assets/{resources-section-C53gZAXt.js → resources-section-DS5i01N-.js} +1 -1
  78. package/web/dist/assets/review-notes-drafts-CL7ZMCUR.js +1 -0
  79. package/web/dist/assets/review-panel-DovJHRRn.js +1 -0
  80. package/web/dist/assets/review-strip-BNNGccZA.js +1 -0
  81. package/web/dist/assets/{run-detail-refresh-DunSTM2R.js → run-detail-refresh-DYY7EWeq.js} +1 -1
  82. package/web/dist/assets/run-diff-D9eUBBuA.js +3 -0
  83. package/web/dist/assets/run-header-BgMH6B__.js +2 -0
  84. package/web/dist/assets/{select-DXc-QPv8.js → select-k6LTVNcZ.js} +1 -1
  85. package/web/dist/assets/selected-file-CfBWFB6p.js +1 -0
  86. package/web/dist/assets/{session-context-section-D3-UzL9i.js → session-context-section-BAMpdQ3R.js} +2 -2
  87. package/web/dist/assets/{settings-agent-picker-CoEypfgX.js → settings-agent-picker-CMerbFjs.js} +1 -1
  88. package/web/dist/assets/{settings-list-detail-Dn5CWzHj.js → settings-list-detail-D3ibaYUj.js} +1 -1
  89. package/web/dist/assets/{settings-save-bar-DcWNDjHM.js → settings-save-bar-DtDilgCt.js} +1 -1
  90. package/web/dist/assets/settings-shell-BEsg7sbY.js +1 -0
  91. package/web/dist/assets/settings-shell-Bvje3VDf.css +1 -0
  92. package/web/dist/assets/sidebar-section-z-PmzPTp.js +1 -0
  93. package/web/dist/assets/skills-DONvkAok.js +1 -0
  94. package/web/dist/assets/{status-dot-BXf-Ubd0.js → status-dot-Drd4-nfa.js} +1 -1
  95. package/web/dist/assets/{tab-link-BAAxhYEU.js → tab-link-BGfSJ-ah.js} +1 -1
  96. package/web/dist/assets/task-changes-5T82pYZ4.js +5 -0
  97. package/web/dist/assets/task-commits-BkY9pJHf.js +1 -0
  98. package/web/dist/assets/task-file-scope-BzA9IipF.js +1 -0
  99. package/web/dist/assets/task-files-L1fLTFwQ.js +1 -0
  100. package/web/dist/assets/{task-github-item-Dhr5xFce.js → task-github-item-TB4z5a5e.js} +1 -1
  101. package/web/dist/assets/{task-groups-DhYlsi5m.js → task-groups-7p6Gvpg8.js} +1 -1
  102. package/web/dist/assets/task-thread-D0Tz7iUB.js +2 -0
  103. package/web/dist/assets/task-thread-i16nxSQv.css +1 -0
  104. package/web/dist/assets/thread-state-DB7a9ttM.js +4 -0
  105. package/web/dist/assets/{toaster-CVP6q4Vk.js → toaster-C1BFyQ8i.js} +1 -1
  106. package/web/dist/assets/use-finish-run-Cj0GCWgE.js +1 -0
  107. package/web/dist/assets/use-hand-to-agent-state-BSM9EGsW.css +1 -0
  108. package/web/dist/assets/use-hand-to-agent-state-BYrF2FhK.js +1 -0
  109. package/web/dist/assets/use-path-bases-DTquoUDk.js +1 -0
  110. package/web/dist/assets/use-workspace-config-save-D2fOudMd.js +1 -0
  111. package/web/dist/assets/workflows-D7bXUmGa.css +1 -0
  112. package/web/dist/assets/workflows-a3Uw4pFl.js +7 -0
  113. package/web/dist/assets/workspace-tools-CPIxvvy9.js +1 -0
  114. package/web/dist/assets/{worktrees-section-6bEgqVh9.js → worktrees-section-M0kZNzy1.js} +1 -1
  115. package/web/dist/index.html +24 -20
  116. package/dist/contract/hosts.d.ts +0 -141
  117. package/dist/features/hosts/cli.d.ts +0 -8
  118. package/dist/features/hosts/cli.js +0 -172
  119. package/dist/features/hosts/cli.js.map +0 -1
  120. package/dist/features/hosts/index.d.ts +0 -12
  121. package/dist/features/hosts/index.js +0 -34
  122. package/dist/features/hosts/index.js.map +0 -1
  123. package/dist/features/hosts/registry.d.ts +0 -52
  124. package/dist/features/hosts/registry.js +0 -198
  125. package/dist/features/hosts/registry.js.map +0 -1
  126. package/dist/features/hosts/routes.d.ts +0 -348
  127. package/dist/features/hosts/routes.js +0 -113
  128. package/dist/features/hosts/routes.js.map +0 -1
  129. package/dist/features/hosts/ssh-config.d.ts +0 -9
  130. package/dist/features/hosts/ssh-config.js +0 -59
  131. package/dist/features/hosts/ssh-config.js.map +0 -1
  132. package/dist/server/workspace-identity-routes.d.ts +0 -29
  133. package/dist/server/workspace-identity-routes.js +0 -21
  134. package/dist/server/workspace-identity-routes.js.map +0 -1
  135. package/web/dist/assets/accounts-section-COsAMTyo.js +0 -1
  136. package/web/dist/assets/activity-motion-76L1dElc.js +0 -1
  137. package/web/dist/assets/agent-defaults-section-CTqsSyJl.js +0 -1
  138. package/web/dist/assets/attention-W6-bv4kF.js +0 -1
  139. package/web/dist/assets/automations-route-0LAhg_x5.js +0 -2
  140. package/web/dist/assets/commit-list-CadGnHIA.js +0 -1
  141. package/web/dist/assets/diff-CBzW3VnD.js +0 -3
  142. package/web/dist/assets/diff-controls-xM4G82ba.js +0 -1
  143. package/web/dist/assets/diff-view-CsOtiJCz.js +0 -11
  144. package/web/dist/assets/discard-changes-dialog-CNqUNfUn.js +0 -1
  145. package/web/dist/assets/github-ZwURT9M2.js +0 -1
  146. package/web/dist/assets/index-D103Um8l.js +0 -21
  147. package/web/dist/assets/index-aGnZVJo_.css +0 -1
  148. package/web/dist/assets/markdown-LhFEpE4H.js +0 -2
  149. package/web/dist/assets/page-shell-Dky5crRl.js +0 -1
  150. package/web/dist/assets/preview-pane-connected-Ck1twV31.js +0 -3
  151. package/web/dist/assets/projects-section-DmTebwNS.js +0 -1
  152. package/web/dist/assets/repo-git-C5psU7Pd.js +0 -1
  153. package/web/dist/assets/report-reader-8cCY5bW-.js +0 -1
  154. package/web/dist/assets/review-panel-MYGp4HC0.js +0 -11
  155. package/web/dist/assets/run-header-C4vK0P6B.js +0 -2
  156. package/web/dist/assets/settings-shell-CgnhBNeW.js +0 -1
  157. package/web/dist/assets/settings-shell-Ct_qn_MM.css +0 -1
  158. package/web/dist/assets/sidebar-section-C2OqOS5F.js +0 -1
  159. package/web/dist/assets/skills-qgUk6jpv.js +0 -1
  160. package/web/dist/assets/task-changes-DotOEkRZ.js +0 -1
  161. package/web/dist/assets/task-commits-567GPEpw.js +0 -1
  162. package/web/dist/assets/task-file-scope-DuyZU3G4.js +0 -1
  163. package/web/dist/assets/task-files-BjW6TUBB.js +0 -1
  164. package/web/dist/assets/task-thread-1mNL_5FP.css +0 -1
  165. package/web/dist/assets/task-thread-rYoDnc1T.js +0 -2
  166. package/web/dist/assets/thread-state-B_k1TffK.js +0 -4
  167. package/web/dist/assets/use-hand-to-agent-state-BCazCBg5.js +0 -1
  168. package/web/dist/assets/use-hand-to-agent-state-DZZUsUAd.css +0 -1
  169. package/web/dist/assets/use-path-bases-Br5NgJFk.js +0 -1
  170. package/web/dist/assets/use-workspace-config-save-DBbFEKc0.js +0 -1
  171. package/web/dist/assets/workflows-B2Sw8qQa.css +0 -1
  172. package/web/dist/assets/workflows-DTT8SRqH.js +0 -7
  173. package/web/dist/assets/workspace-tools-C2UU3h3_.js +0 -1
@@ -0,0 +1,9 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{m as r,o as i}from"./dist-C_rn70hE.js";import{N as a,Yt as o,nn as s}from"./queries-jsRcJKo6.js";import{mr as c}from"./toaster-C1BFyQ8i.js";import{f as l,n as u,p as d}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{J as f,Q as p,V as m,c as h,d as g,mt as _,pt as v,st as y,y as b}from"./design-icons-QbNMZniQ.js";import{t as x}from"./createLucideIcon-BHp8sXmF.js";import{t as S}from"./check-OP-CVgZG.js";import{t as C}from"./chevron-right-BENZ-1ZN.js";import{n as w}from"./smartphone-Lr8Ug2z_.js";import{t as T}from"./loader-circle-CPBhhDbB.js";import{t as ee}from"./message-square-B-MD-8rD.js";import{n as te,t as ne}from"./tool-display-B9NN44oU.js";import{t as E}from"./square-terminal-B6RYYieR.js";import{t as D}from"./button-B22ANdCY.js";import{n as O,r as k,t as A}from"./collapsible-Bx2vViFx.js";import{t as j}from"./project-router-C53GCY_8.js";import{a as M,c as re,i as ie,l as ae,o as oe,s as se,t as ce}from"./report-selection-DAPzf1Aa.js";import{r as le}from"./html-report-BX3msvci.js";import{En as ue,Sr as de,T as fe,dr as pe,fn as me,gr as N,w as he}from"./index-CGDZRQo6.js";import{t as ge}from"./zoomable-image-BUTgYpld.js";import{t as P}from"./textarea-vEsJAUAV.js";import{t as F}from"./markdown-BNtZVUvm.js";import{t as _e}from"./task-file-scope-BzA9IipF.js";import{t as ve}from"./report-title-D4Mbu2Er.js";var ye=x(`anchor`,[[`path`,{d:`M12 6v16`,key:`nqf5sj`}],[`path`,{d:`m19 13 2-1a9 9 0 0 1-18 0l2 1`,key:`y7qv08`}],[`path`,{d:`M9 11h6`,key:`1fldmi`}],[`circle`,{cx:`12`,cy:`4`,r:`2`,key:`muu5ef`}]]),be=x(`brain`,[[`path`,{d:`M12 18V5`,key:`adv99a`}],[`path`,{d:`M15 13a4.17 4.17 0 0 1-3-4 4.17 4.17 0 0 1-3 4`,key:`1e3is1`}],[`path`,{d:`M17.598 6.5A3 3 0 1 0 12 5a3 3 0 1 0-5.598 1.5`,key:`1gqd8o`}],[`path`,{d:`M17.997 5.125a4 4 0 0 1 2.526 5.77`,key:`iwvgf7`}],[`path`,{d:`M18 18a4 4 0 0 0 2-7.464`,key:`efp6ie`}],[`path`,{d:`M19.967 17.483A4 4 0 1 1 12 18a4 4 0 1 1-7.967-.517`,key:`1gq6am`}],[`path`,{d:`M6 18a4 4 0 0 1-2-7.464`,key:`k1g0md`}],[`path`,{d:`M6.003 5.125a4 4 0 0 0-2.526 5.77`,key:`q97ue3`}]]),xe=x(`folder-input`,[[`path`,{d:`M2 9V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H20a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-1`,key:`fm4g5t`}],[`path`,{d:`M2 13h10`,key:`pgb2dq`}],[`path`,{d:`m9 16 3-3-3-3`,key:`6m91ic`}]]),I=x(`message-square-text`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}],[`path`,{d:`M7 11h10`,key:`1twpyw`}],[`path`,{d:`M7 15h6`,key:`d9of3u`}],[`path`,{d:`M7 7h8`,key:`af5zfr`}]]),Se=x(`square-pen`,[[`path`,{d:`M12 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7`,key:`1m0v6g`}],[`path`,{d:`M18.375 2.625a1 1 0 0 1 3 3l-9.013 9.014a2 2 0 0 1-.853.505l-2.873.84a.5.5 0 0 1-.62-.62l.84-2.873a2 2 0 0 1 .506-.852z`,key:`ohrbg2`}]]),L=e(t(),1),R=n();function Ce(e,t){if(e.length===1)return[t.replace(RegExp(`^${we(e[0].header)}: ?`),``)];let n=t,r=[];for(let[t,i]of e.entries()){let a=`${i.header}: `;if(!n.startsWith(a))return;n=n.slice(a.length);let o=e[t+1],s=o?n.indexOf(`\n${o.header}: `):n.length;if(s<0)return;r.push(n.slice(0,s)),n=n.slice(s+1)}return r}function we(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function Te(e,t){if(t===void 0)return[];let n=e.options??[];if(!e.multiSelect)return n.filter(e=>e.label===t).map(e=>e.label);let r=[];function i(e,t){for(let{label:a}of n)t.includes(a)||(e===a?r.push([...t,a]):e.startsWith(`${a}, `)&&i(e.slice(a.length+2),[...t,a]))}return i(t,[]),r.length===1?r[0]:[]}var Ee=`
2
+
3
+ Additional comments:
4
+ `;function De(e){let t=e.indexOf(Ee);if(t<0)return{body:e,comment:void 0};let n=e.slice(t+23).trim();return{body:e.slice(0,t),comment:n||void 0}}function Oe({ask:e}){let t=e.answer===void 0?void 0:De(e.answer),n=t===void 0?void 0:Ce(e.questions,t.body);return(0,R.jsxs)(`div`,{"data-slot":`ask-answers`,className:`flex flex-col gap-4 text-sm`,children:[e.questions.map((t,r)=>{let i=n?.[r],a=Te(t,i),o=i!==void 0&&a.length===0;return(0,R.jsxs)(`section`,{className:`flex flex-col gap-2`,"aria-label":t.question,children:[(0,R.jsxs)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:[t.header,` · Question `,r+1,` of `,e.questions.length]}),(0,R.jsx)(`p`,{className:`break-words font-semibold`,children:t.question}),t.options?(0,R.jsxs)(`ul`,{className:`flex list-none flex-col gap-1.5`,children:[t.options.map(e=>(0,R.jsxs)(`li`,{"data-selected":a.includes(e.label),className:`flex items-start gap-2 rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border data-[selected=true]:bg-message-user-accent/5`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`shrink-0 text-message-user-accent`,children:a.includes(e.label)?`✓`:`○`}),(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 break-words`,children:[(0,R.jsx)(`span`,{className:`font-medium`,children:e.label}),e.description?(0,R.jsx)(`span`,{className:`block text-xs text-muted-foreground`,children:e.description}):null]}),a.includes(e.label)?(0,R.jsx)(`span`,{className:`shrink-0 text-xs text-message-user-accent`,children:`Selected`}):null]},e.label)),(0,R.jsxs)(`li`,{"data-selected":o,className:`rounded-md border border-border px-3 py-2 data-[selected=true]:border-message-user-border`,children:[(0,R.jsxs)(`p`,{className:`flex items-start gap-2 font-medium`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`text-message-user-accent`,children:o?`✓`:`○`}),(0,R.jsx)(`span`,{className:`flex-1`,children:`Other`}),o?(0,R.jsx)(`span`,{className:`text-xs text-message-user-accent`,children:`Selected`}):null]}),o?(0,R.jsx)(z,{text:i}):null]})]}):i===void 0?null:(0,R.jsx)(z,{text:i})]},t.id??r)}),n&&t?.comment?(0,R.jsxs)(`section`,{className:`flex flex-col gap-1`,"aria-label":`Additional comments`,children:[(0,R.jsx)(`p`,{className:`text-xs font-medium text-muted-foreground`,children:`Additional comments`}),(0,R.jsx)(z,{text:t.comment})]}):null,!n&&e.answer!==void 0?(0,R.jsx)(z,{text:e.answer}):null]})}function z({text:e}){return(0,R.jsx)(`blockquote`,{className:`[margin-block-start:0.5rem] border-s-2 border-message-user-accent ps-3 break-words whitespace-pre-wrap`,children:e})}function B(e,t,n){let r=n[e];return r===void 0?(t[e]?.length??0)>0:r.trim().length>0}function ke(e,t,n){let r=n[e]?.trim();if(r)return r;let i=t[e]??[];return i.length>0?i.join(`, `):`Not answered yet`}function Ae({stepped:e,mode:t,onModeChange:n,showModeSwitch:r,stepLabel:a,hasSheetContext:o,showContextButtonRef:s,onOpenContext:c,onShowOrigin:l}){return(0,R.jsxs)(`div`,{"data-slot":`ask-header`,className:`flex shrink-0 flex-wrap items-center gap-x-2 gap-y-1 border-b border-border/70 px-2.5 py-1.5 md:px-3 md:py-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-semibold text-link-foreground`,children:`Needs your answer`}),e&&t===`options`?(0,R.jsx)(`span`,{"data-slot":`ask-step-indicator`,className:`rounded-full bg-accent-strong/15 px-2 py-0.5 text-xs font-semibold text-foreground tabular-nums`,children:a}):null,(0,R.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-1.5`,children:[o?(0,R.jsxs)(D,{ref:s,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,onClick:c,children:[(0,R.jsx)(N,{"aria-hidden":`true`,className:`size-3.5`}),`Show context`]}):l?(0,R.jsx)(Le,{onShowOrigin:l}):null,r?(0,R.jsxs)(`div`,{"data-slot":`ask-mode-switch`,role:`group`,"aria-label":`Reply mode`,className:`inline-flex items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,R.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-options`,"aria-pressed":t===`options`,onClick:()=>n(`options`),className:i(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,t===`options`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Options`}),(0,R.jsx)(`button`,{type:`button`,"data-slot":`ask-mode-reply`,"aria-pressed":t===`reply`,onClick:()=>n(`reply`),className:i(`min-h-11 rounded-md px-2.5 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring md:min-h-7`,t===`reply`?`bg-accent-strong text-accent-strong-foreground`:`text-foreground hover:bg-muted/60`),children:`Write a reply`})]}):null]})]})}function je({questions:e,stepIndex:t,selections:n,otherAnswers:r,hasComment:a,onSelectStep:o}){let s=e.length;return(0,R.jsxs)(`div`,{"data-slot":`ask-step-pills`,role:`group`,"aria-label":`Question steps`,className:`hidden shrink-0 flex-wrap items-center gap-1.5 border-b border-border/60 px-3 py-1.5 md:flex`,children:[e.map((e,a)=>{let s=t===a,c=B(a,n,r);return(0,R.jsxs)(`button`,{type:`button`,"aria-current":s?`step`:void 0,onClick:()=>o(a),className:i(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,s?`border-accent-strong bg-accent-strong/15 text-foreground`:c?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(`span`,{className:`tabular-nums text-xs font-semibold`,children:c?(0,R.jsx)(S,{"aria-hidden":`true`,className:`size-3 text-semantic-green`}):`${a+1}.`}),(0,R.jsx)(`span`,{className:`max-w-[140px] truncate`,children:e.header})]},e.id??a)}),(0,R.jsxs)(`button`,{type:`button`,"aria-current":t===s?`step`:void 0,onClick:()=>o(s),className:i(`inline-flex min-h-8 items-center gap-1.5 rounded-full border px-2.5 py-1 text-xs font-medium transition-colors focus-visible:outline-2 focus-visible:outline-ring`,t===s?`border-accent-strong bg-accent-strong/15 text-foreground`:a?`border-border bg-card text-foreground hover:border-accent-strong/50`:`border-dashed border-border bg-transparent text-muted-foreground hover:text-foreground`),children:[(0,R.jsx)(I,{"aria-hidden":`true`,className:`size-3`}),(0,R.jsx)(`span`,{children:`Comment`})]})]})}function Me({questions:e,selections:t,otherAnswers:n,comment:r,disabled:a,onCommentChange:o,onJumpToQuestion:s}){let c=(0,L.useId)();return(0,R.jsxs)(`div`,{"data-slot":`ask-comment-step`,className:`flex flex-col gap-2.5`,children:[(0,R.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-2.5`,children:[(0,R.jsx)(`p`,{className:`mb-1.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:`Selected answers`}),(0,R.jsx)(`ul`,{className:`flex flex-col gap-1`,children:e.map((e,r)=>{let a=B(r,t,n);return(0,R.jsxs)(`li`,{className:`flex items-baseline justify-between gap-2 text-xs`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>s(r),className:`min-h-11 text-start font-medium text-link-foreground underline-offset-4 hover:underline md:min-h-6`,children:e.header}),(0,R.jsx)(`span`,{className:i(`min-w-0 truncate text-end`,a?`text-foreground`:`text-semantic-red`),children:ke(r,t,n)})]},e.id??r)})})]}),(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:c,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,R.jsx)(P,{id:c,"data-slot":`ask-additional-comment`,rows:2,value:r,disabled:a,placeholder:`Optional extra notes to send with your selections…`,onChange:e=>o(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}function Ne({value:e,onValueChange:t,disabled:n,renderFreeTextReply:r}){let i=(0,L.useId)();return r?(0,R.jsx)(`div`,{"data-slot":`ask-free-text`,children:r({value:e,onValueChange:t,disabled:n})}):(0,R.jsxs)(`div`,{"data-slot":`ask-free-text`,className:`flex flex-col gap-2`,children:[(0,R.jsx)(`label`,{htmlFor:i,className:`text-xs font-medium text-foreground`,children:`Reply to the agent`}),(0,R.jsx)(P,{id:i,rows:2,value:e,disabled:n,placeholder:`Write a free-text reply…`,onChange:e=>t(e.target.value),className:`bg-card text-base md:text-[13px]`})]})}function Pe({stepIndex:e,questionCount:t,answeredCount:n,allAnswered:r,hasComment:a,resuming:o,disabled:s,onBack:c,onNext:l,onOpenComment:u,onSend:d,questions:f,selections:p,otherAnswers:m,stopControl:h}){let g=e===t-1,_=e===t,v=o?`Send answer & reopen`:`Send answer`;return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e>0?(0,R.jsxs)(D,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:c,children:[(0,R.jsx)(de,{"aria-hidden":`true`,className:`size-4`}),`Back`]}):null,(0,R.jsxs)(`span`,{"data-slot":`ask-progress-dots`,"aria-hidden":`true`,className:`flex items-center gap-1.5 px-1 md:hidden`,children:[f.map((t,n)=>{let r=n===e,a=B(n,p,m);return(0,R.jsx)(`span`,{className:i(`size-2 rounded-full motion-safe:transition-colors`,r?`bg-accent-strong`:a?`bg-success`:`bg-border`)},t.id??n)}),(0,R.jsx)(`span`,{className:i(`size-2 rounded-full motion-safe:transition-colors`,_?`bg-accent-strong`:a?`bg-success`:`bg-border/60`)})]}),(0,R.jsxs)(`span`,{"data-slot":`ask-progress-summary`,className:`hidden text-xs text-soft-foreground tabular-nums sm:inline`,children:[n,` of `,t,` answered`]}),o?(0,R.jsx)(`span`,{"data-slot":`ask-resume-hint`,className:`text-xs text-soft-foreground`,children:`Reopens the closed session.`}):null,(0,R.jsxs)(`div`,{className:`ms-auto flex flex-wrap items-center gap-2`,children:[h,!g&&!_?(0,R.jsxs)(D,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:l,children:[`Next`,(0,R.jsx)(C,{"aria-hidden":`true`,className:`size-4`})]}):null,g?(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,className:`px-3`,onClick:u,children:a?`Edit comment`:`+ Comment`}):null,g||_||r?(0,R.jsx)(D,{type:`button`,size:`sm`,className:`px-3.5`,disabled:s||!r,onClick:d,children:v}):null]})]})}function Fe({oneTap:e,hasOtherAnswer:t,allowComment:n,commentOpen:r,hasComment:i,resuming:a,disabled:o,onToggleComment:s,onSend:c,stopControl:l}){return(0,R.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[n?(0,R.jsxs)(D,{type:`button`,variant:`ghost`,size:`sm`,className:`px-2 text-xs text-muted-foreground hover:text-foreground`,onClick:s,children:[(0,R.jsx)(I,{"aria-hidden":`true`,className:`size-3.5`}),r?`Hide comment`:i?`Edit comment`:`+ Add comment`]}):null,(0,R.jsx)(`span`,{"data-slot":a?`ask-resume-hint`:`ask-hint`,className:`text-xs text-soft-foreground`,children:a?`Reopens the closed session.`:e?`Tap an option to send.`:`Choose an answer, then send.`}),(0,R.jsxs)(`div`,{className:`ms-auto flex items-center gap-2`,children:[l,!e||t||r||i?(0,R.jsx)(D,{type:`button`,size:`sm`,className:`px-3.5`,disabled:o,onClick:c,children:a?`Send answer & reopen`:`Send answer`}):null]})]})}function Ie({blockedBy:e,reason:t,error:n}){return(0,R.jsxs)(R.Fragment,{children:[t?(0,R.jsxs)(`p`,{"data-slot":`ask-blocked-reason`,className:`text-xs text-muted-foreground`,children:[t,` `,e===`provider`?(0,R.jsx)(j,{to:`/settings/agent-defaults#providers`,className:`font-medium text-foreground underline underline-offset-4`,children:`Configure providers`}):null]}):null,n?(0,R.jsx)(`p`,{role:`alert`,className:`text-xs text-semantic-red`,children:n}):null]})}function Le({onShowOrigin:e,className:t}){return(0,R.jsx)(D,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-origin`,onClick:e,className:i(`px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,t),children:`Show where it was asked`})}function Re({open:e,onOpenChange:t,runId:n,context:r,onShowOrigin:i,returnFocusRef:a}){let o=(0,L.useRef)(!1);return(0,R.jsx)(ie,{open:e,onOpenChange:t,children:(0,R.jsxs)(oe,{side:`right`,showCloseButton:!1,"data-slot":`ask-context-sheet`,className:`flex w-full max-w-[540px] flex-col gap-0 p-0 sm:max-w-[540px]`,onCloseAutoFocus:e=>{if(e.preventDefault(),o.current){o.current=!1,i?.();return}a?.current?.focus()},children:[(0,R.jsxs)(re,{className:`relative shrink-0 border-b border-border px-5 py-4 pr-14`,children:[(0,R.jsx)(ae,{children:`Question context`}),(0,R.jsx)(se,{children:`Your selections and drafts stay intact while you read.`}),(0,R.jsx)(M,{asChild:!0,children:(0,R.jsx)(D,{type:`button`,variant:`ghost`,size:`icon`,"aria-label":`Close`,className:`absolute inset-bs-2 end-2`,children:(0,R.jsx)(_,{"aria-hidden":`true`,className:`size-4`})})})]}),(0,R.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`min-h-0 flex-1 overflow-y-auto overscroll-contain break-words px-5 py-4 text-sm text-foreground`,children:(0,R.jsx)(_e,{runId:n,children:(0,R.jsx)(F,{breaks:!0,children:r})})}),i?(0,R.jsx)(`div`,{className:`flex shrink-0 items-center justify-end border-t border-border px-5 py-3`,children:(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-show-origin`,onClick:()=>{o.current=!0,t(!1),i()},children:`Show where it was asked`})}):null]})})}function ze(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var Be=/^[A-Za-z0-9_./:=+,@%-]+$/;function Ve(e){return e.replaceAll(`'`,`'\\''`)}function He(e){return e===``?`''`:Be.test(e)?e:`\u0027${Ve(e)}\u0027`}function Ue(e){if(!ze(e))return;let t=e.command;if(typeof t==`string`&&t!==``)return t;if(Array.isArray(t)){let e=t.filter(e=>typeof e==`string`);if(e.length>0)return e.map(He).join(` `)}}function We(e){let t="`".repeat(3),n=`~`.repeat(3);return e.split(t).filter((e,t)=>t%2==0).join(` `).split(n).filter((e,t)=>t%2==0).join(` `).split("`").filter((e,t)=>t%2==0).join(` `)}function Ge(e){return e.replace(/!\[(?:\\.|[^\]\\])*\]\([^)\s]*(?:\s+"[^"]*")?\)/g,` `)}function Ke(e){return e.replace(/(?<!\\)(?:\*\*|\*|__|~~|`)/g,``).replace(/\\([!"#$%&'()*+,\-./:;<=>?@[\]\\^_`{|}~])/g,`$1`)}function V(e){let t=e.trim();return t===``||t.startsWith(`#`)||/^(https?:|mailto:)/i.test(t)?!0:!/^[a-z][a-z0-9+.-]*:/i.test(t)}function qe(e){let t=We(Ge(e)),n=new Map;for(let e of t.matchAll(/^\s*\[([^\]]+)\]:\s*(\S+)/gm))V(e[2])&&n.set(e[1].toLowerCase(),e[2]);let r=t.replace(/^\s*\[[^\]]+\]:\s*\S+.*$/gm,` `),i=[];for(let e of r.matchAll(/(?<!!)\[((?:\\.|[^\]\\])+)\](?:\(((?:[^()\s]|\([^)]*\))+)(?:\s+"[^"]*")?\)|\[([^\]]*)\])|<(https?:\/\/[^>\s]+)>|(https?:\/\/[^\s<]+)/g)){if(e[2]){V(e[2])&&i.push({label:Ke(e[1]),href:e[2]});continue}if(e[1]!==void 0&&e[3]!==void 0){let t=(e[3].length>0?e[3]:e[1]).toLowerCase(),r=n.get(t);r&&i.push({label:Ke(e[1]),href:r});continue}let t=(e[4]??e[5])?.replace(/[.,;:!?]+$/,``);t&&V(t)&&i.push({label:t,href:t})}return i}var Je=(0,L.createContext)(void 0),Ye=(0,L.createContext)(void 0);function H(e,t){let n=new Map;for(let r of qe(e)){let e=fe(r.href,t);if(!e)continue;let i=new URL(e,`https://cockpit.invalid`),a=/^\/p\/([^/]+)\/tasks\/([^/]+)\/report$/.exec(i.pathname),o=/^\/tasks\/([^/]+)\/report$/.exec(i.pathname),s=i.searchParams.get(`artifact`);if(!s||(a?decodeURIComponent(a[1])!==t.projectId:!o))continue;let c=decodeURIComponent(a?a[2]:o[1]),l=`${c}:${s}`;n.has(l)||n.set(l,{runId:c,artifactId:s,label:r.label,href:e})}return[...n.values()]}function U(e,t){return`report-card-${encodeURIComponent(e)}-${t}`}function Xe({text:e,messageKey:t}){let n=(0,L.useContext)(he),r=(0,L.useContext)(Ye),i=t??r;if(!n||i===void 0)return null;let a=H(e,n);return a.length===0?null:(0,R.jsx)(`div`,{"data-slot":`report-cards`,className:`flex flex-col gap-3 [margin-block-start:1rem]`,children:a.map(e=>(0,R.jsx)(Ze,{reference:e,messageKey:i},`${e.runId}:${e.artifactId}`))})}function Ze({reference:e,messageKey:t}){let{artifactId:n,runId:r,label:i,href:o}=e,s=(0,L.useContext)(Je),c=(0,L.useContext)(ce);(0,L.useLayoutEffect)(()=>c?.register(n,r),[c,n,r]);let f=a(r,n),p=l(),m=d();if(f.isError)return(0,R.jsx)(u,{id:U(t,n),"data-slot":`report-card-fallback`,to:o,state:{readerFrom:p.pathname+p.search},children:i});let h=f.data?.artifact;if(h&&!le(h.name))return null;let g=new URLSearchParams(p.search);g.set(`report`,n),g.set(`card`,t);let _=new URLSearchParams(p.search).has(`report`)?p.state:null,v=new URLSearchParams(p.search);v.delete(`report`),v.delete(`card`);let y=`${p.pathname}${v.size?`?${v}`:``}`,b=window.navigation,x={reportCardEntry:!0,reportReturnTo:_?.reportReturnTo??y,reportReturnKey:_?.reportReturnKey??b?.currentEntry?.key,reportScrollTop:_?.reportScrollTop},S={pathname:p.pathname,search:`?${g}`,hash:new URL(o,`https://cockpit.invalid`).hash};return(0,R.jsxs)(`section`,{"data-slot":`report-card`,"data-artifact-id":n,"data-report-run-id":r,"aria-busy":f.isPending,className:`flex min-w-0 flex-col gap-2 rounded-lg border border-border bg-card p-3 text-foreground`,children:[(0,R.jsx)(`h3`,{className:`break-words text-sm font-medium`,children:h?ve(h):i}),(0,R.jsx)(`p`,{className:`text-xs text-soft-foreground`,children:`HTML report`}),(0,R.jsx)(u,{id:U(t,n),to:S,state:x,onClick:e=>{if(e.button!==0||e.metaKey||e.ctrlKey||e.altKey||e.shiftKey)return;e.preventDefault(),s?.(t);let n=x.reportScrollTop??(document.querySelector(`[data-slot="thread-transcript"]`)??document.querySelector(`[data-slot="main"]`))?.scrollTop;m(S,{state:{...x,reportScrollTop:n}})},className:`inline-flex min-h-11 min-w-11 items-center self-start rounded-md border border-border px-3 text-sm active:bg-muted focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring ${f.isPending?`text-soft-foreground`:`text-accent-text`}`,children:`Read report`})]})}var Qe={message:!0,reasoning:!0,tool:!0,hook:!0};function $e(e){return Object.hasOwn(Qe,e)&&Qe[e]}var W=e=>e.kind===`tool`,et=e=>e.kind===`conversation`,tt=e=>(e.toolKind===`read`||e.toolKind===`search`)&&e.status===`completed`,nt=(e,t,n)=>`${e} ${e===1?t:n}`;function rt(e,t){let n=[];return e>0&&n.push(nt(e,`file`,`files`)),t>0&&n.push(nt(t,`search`,`searches`)),`Explored ${n.join(` · `)}`}function it(e){return`${e} earlier tool call${e===1?``:`s`}`}var at=[`Web search`,`Ran`,`Edit`,`Write`,`Read`,`Search`,`Fetch`,`Task:`];function ot(e){for(let t of at)if(e.startsWith(`${t} `)&&e.length>t.length+1)return{verb:t===`Task:`?`Task`:t,detail:e.slice(t.length+1)};return{verb:e}}var st=new WeakMap;function ct(e){let t=st.get(e);if(t)return t;let n=lt(e);return st.set(e,n),n}function lt(e){let t=e.filter(e=>!(e.kind===`tool`&&e.toolKind===`plan`)&&!((e.kind===`reasoning`||e.kind===`message`)&&e.text.trim()===``)),n=new Set(t.filter(W).map(e=>e.id)),r=new Map,i=[];for(let e of t){let t=$e(e.kind)&&`parentItemId`in e&&e.parentItemId!==void 0&&e.parentItemId!==e.id&&n.has(e.parentItemId)?e.parentItemId:void 0;if(t===void 0)i.push(e);else{let n=r.get(t);n?n.push(e):r.set(t,[e])}}let a=[],o=[],s=()=>{if(o.length>=2){let e=o.filter(e=>e.toolKind===`read`).length;a.push({kind:`context-group`,id:`group:${o[0].id}`,tools:o,files:e,searches:o.length-e,label:rt(e,o.length-e)})}else for(let e of o)a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]});o=[]},c=[],l=()=>{if(c.length!==0){for(let e of ut(c).batches)a.push({kind:`worker-conversation`,id:`worker:${e.messages[0].id}`,batches:[e]});c=[]}};for(let e of i){if(et(e)){s(),c.push(e);continue}l(),W(e)&&tt(e)&&!r.has(e.id)?o.push(e):(s(),W(e)?a.push({kind:`tool-card`,id:e.id,item:e,children:r.get(e.id)??[]}):a.push({kind:`entry`,id:e.id,entry:e}))}s(),l();let u=e=>e.kind===`context-group`||e.kind===`tool-card`&&e.item.status===`completed`,d=e=>e.kind===`context-group`?e.tools.length:1,f=[],p=[],m=()=>{if(p.length>3){let e=p.slice(0,p.length-3);f.push({kind:`streak`,id:`streak:${e[0].id}`,count:e.reduce((e,t)=>e+d(t),0),blocks:e}),f.push(...p.slice(p.length-3))}else f.push(...p);p=[]};for(let e of a)u(e)?p.push(e):(m(),f.push(e));return m(),f}function ut(e){let t=[];for(let n of e){let e=t.at(-1);n.messageKind===`request`&&e?.kind===`request`&&e.senderRunId===n.senderRunId&&e.text===n.text&&e.messages[0].relationship===`peer`==(n.relationship===`peer`)&&!e.messages.some(e=>e.recipientRunId===n.recipientRunId)?e.messages.push(n):t.push({id:`worker-batch:${n.messageId}`,kind:n.messageKind,text:n.text,senderRunId:n.senderRunId,messages:[n]})}return{kind:`worker-conversation`,id:`worker:${e[0].id}`,batches:t}}var G=new Map,dt=(0,L.createContext)(null);function K(){return(0,L.useContext)(dt)}function ft({runId:e,children:t}){let n=(0,L.useMemo)(()=>({get:t=>G.get(e)?.get(t),set:(t,n)=>{let r=G.get(e)??new Map;r.set(t,n),G.set(e,r)}}),[e]);return(0,R.jsx)(dt.Provider,{value:n,children:t})}function pt(e){return e.scrollTop<Math.max(600,e.clientHeight)}function mt(e,t){let n=t.find(({bottom:t})=>t>e);return n===void 0?void 0:{key:n.key,offset:n.top-e}}function ht(e,t,n,r,i){if(n===void 0)return i;let a=r.find(({key:e})=>e===n.key);return a===void 0?i:e+(a.top-t-n.offset)}function gt(e,t=24){return e.scrollHeight-e.scrollTop-e.clientHeight<t}function _t(e,t){let n=new URLSearchParams(e).get(`thread`);return n===`flat`||n===`virtual`?n:t>300?`virtual`:`flat`}var vt=new Map;function yt(e,t){vt.set(e,t)}function bt(e){return vt.get(e)}var q=new Map;function xt(e,t){q.set(e,{...t,...t.rowKeys?{rowKeys:[...t.rowKeys]}:{}})}function St(e){return q.get(e)}function Ct(e,t,n){let r=q.get(e);if(!r||r.rows!==t)return;let i=r.rowKeys;if(!(n&&i&&(n.length!==t||i.length!==t||!n.every((e,t)=>e===i[t]))))return r.cache}var wt=new Intl.DateTimeFormat(void 0,{hour:`2-digit`,minute:`2-digit`,hourCycle:`h23`}),Tt=new Intl.DateTimeFormat(void 0,{dateStyle:`medium`,timeStyle:`medium`}),Et=new Intl.DateTimeFormat(void 0,{weekday:`short`,month:`short`,day:`numeric`}),Dt=new Intl.DateTimeFormat(void 0,{weekday:`short`,year:`numeric`,month:`short`,day:`numeric`}),Ot=new Intl.DateTimeFormat(void 0,{dateStyle:`full`});function J(e){if(typeof e!=`string`||e===``)return;let t=new Date(e);return Number.isFinite(t.getTime())?t:void 0}function Y(e){let t=J(e);return t===void 0?void 0:wt.format(t)}function kt(e){let t=J(e);return t===void 0?void 0:Tt.format(t)}var X=e=>`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,`0`)}-${String(e.getDate()).padStart(2,`0`)}`;function At(e){let t=J(e);return t===void 0?void 0:X(t)}function jt(e,t=new Date){let n=J(e);if(n===void 0)return;let r=X(n);return r===X(t)?`Today`:r===X(new Date(t.getFullYear(),t.getMonth(),t.getDate()-1))?`Yesterday`:(n.getFullYear()===t.getFullYear()?Et:Dt).format(n)}function Mt(e,t){let n=J(e),r=J(t);if(n===void 0||r===void 0)return;let i=Math.round((r.getTime()-n.getTime())/1e3);if(i<0)return;if(i<60)return`${i}s`;let a=Math.floor(i/60);return a<60?`${a}m ${String(i%60).padStart(2,`0`)}s`:`${Math.floor(a/60)}h ${String(a%60).padStart(2,`0`)}m`}function Nt({ts:e}){let t=Y(e);return t===void 0?null:(0,R.jsx)(`time`,{"data-slot":`message-time`,dateTime:e,title:kt(e),className:`text-xs leading-none text-soft-foreground`,children:t})}function Pt({startedAt:e,completedAt:t}){let n=Y(t);if(n===void 0)return null;let r=Mt(e,t);return(0,R.jsxs)(`div`,{"data-slot":`turn-time`,className:`flex items-center gap-1.5 px-0.5 text-xs leading-none text-soft-foreground`,children:[(0,R.jsx)(`time`,{dateTime:t,title:kt(t),children:n}),r===void 0?null:(0,R.jsxs)(`span`,{title:`Replied in ${r}`,children:[`· `,r]})]})}function Ft({ts:e}){let t=jt(e),n=J(e);if(t===void 0||n===void 0)return null;let r=Ot.format(n);return(0,R.jsxs)(`div`,{"data-slot":`day-separator`,role:`separator`,"aria-label":t===`Today`||t===`Yesterday`?`${t}, ${r}`:r,className:`flex items-center gap-3 py-1 text-xs font-medium text-soft-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`}),(0,R.jsx)(`time`,{dateTime:At(e),title:r,children:t}),(0,R.jsx)(`span`,{"aria-hidden":!0,className:`h-px flex-1 bg-border`})]})}var It={assistant:`Agent message`,error:`Runner error`,"session.error":`Session error`,"step-end":`Step status`,lifecycle:`Run status`};function Lt({note:e}){return e.icon===`handoff`?(0,R.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,"data-icon":`handoff`,className:`flex items-start gap-2 px-0.5 text-xs text-muted-foreground`,children:[(0,R.jsx)(`span`,{"aria-hidden":`true`,className:`mt-[-1px] flex size-5 shrink-0 items-center justify-center rounded-full border border-border text-success`,children:(0,R.jsx)(pe,{className:`size-3`})}),(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.text})]}):e.details&&e.details.length>0?(0,R.jsxs)(A,{"data-slot":`note-line`,"data-tone":e.tone,className:`group/failure min-w-0 px-0.5 text-xs`,children:[(0,R.jsxs)(`div`,{className:i(`flex items-start gap-2`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[(0,R.jsxs)(`span`,{className:`min-w-0 flex-1 whitespace-pre-wrap wrap-anywhere`,children:[e.tone===`danger`?`✗ `:null,e.text]}),(0,R.jsxs)(k,{"data-slot":`note-details-toggle`,className:`inline-flex shrink-0 items-center gap-1 rounded-sm px-1.5 py-0.5 text-xs font-medium text-muted-foreground hover:bg-muted/50 hover:text-foreground focus-visible:outline-2 focus-visible:outline-ring max-md:min-h-11 max-md:min-w-11 max-md:justify-center pointer-coarse:min-h-11 pointer-coarse:min-w-11 pointer-coarse:justify-center`,children:[(0,R.jsx)(g,{"aria-hidden":`true`,className:`size-3 shrink-0 motion-safe:transition-transform group-data-[state=open]/failure:rotate-90`}),`Details`]})]}),(0,R.jsx)(O,{children:(0,R.jsx)(`ul`,{"data-slot":`note-details`,className:`mbs-1.5 flex flex-col gap-1 border-s border-border ps-3 font-mono text-xs text-muted-foreground`,children:e.details.map((e,t)=>(0,R.jsxs)(`li`,{className:`min-w-0 whitespace-pre-wrap wrap-anywhere`,children:[(0,R.jsxs)(`span`,{className:`font-sans font-medium text-foreground`,children:[It[e.source],`:`,` `]}),e.text]},`${e.source}:${t}`))})})]}):(0,R.jsxs)(`div`,{"data-slot":`note-line`,"data-tone":e.tone,className:i(`px-0.5 text-xs`,e.tone===`danger`?`text-semantic-red`:`text-soft-foreground`),children:[e.tone===`danger`?`✗ `:null,e.text]})}var Rt={user:{label:`YOUR MESSAGE`,speaker:`Your message`,classes:`border-message-user-border bg-message-user-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-user-accent`,accent:`text-message-user-accent`,body:`max-md:text-[12px]`},agent:{label:`AGENT RESPONSE`,speaker:`Agent response`,classes:`border-message-agent-border bg-message-agent-bg [html:not(.light)_&]:border-s-[3px] [html:not(.light)_&]:border-s-message-agent-accent`,accent:`text-message-agent-accent`,body:`text-[15px] md:text-[14px]`}};function Z({role:e,children:t,className:n,ts:r,headerActions:a,...o}){let s=Rt[e],c=r===void 0?void 0:Y(r);return(0,R.jsxs)(`article`,{...o,"data-role":e,"aria-label":s.speaker,className:i(`flex w-full min-w-0 flex-col gap-2 self-stretch rounded-[8px] border p-3 md:px-4 md:py-[14px]`,s.classes,n),children:[(0,R.jsxs)(`p`,{className:i(`m-0 flex w-full min-w-0 items-start gap-2 text-xs leading-[1.2] font-semibold tracking-[0.6px] uppercase`,s.accent),children:[(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 flex-1 flex-wrap items-center gap-x-2 gap-y-1 normal-case tracking-normal`,children:[(0,R.jsxs)(`span`,{className:`inline-flex min-w-0 items-center gap-2 uppercase tracking-[0.6px]`,children:[(0,R.jsx)(ee,{"aria-hidden":`true`,className:`size-4 shrink-0`}),s.label]}),a]}),c===void 0?null:(0,R.jsx)(`span`,{className:`shrink-0 font-normal tracking-normal normal-case`,children:(0,R.jsx)(Nt,{ts:r})})]}),(0,R.jsx)(`div`,{className:i(`min-w-0 break-words text-[14px] text-foreground select-text [overflow-wrap:anywhere]`,s.body,`leading-[1.6]`),children:t})]})}var zt=[],Bt=(0,L.memo)(function({text:e,imageCount:t=0,images:n=zt,ts:i,onEdit:a,onRemove:o,editLabel:s=`Edit message`,removeLabel:l=`Remove message`,children:u}){let d=t-n.length,[p,m]=(0,L.useState)(!1),[h,g]=(0,L.useState)(e),[_,v]=(0,L.useState)(!1),[b,x]=(0,L.useState)(),S=()=>{g(e),x(void 0),m(!0)},C=async()=>{let t=h.trim();if(!t||t===e){m(!1);return}v(!0),x(void 0);try{await a?.(t),m(!1)}catch(e){x(e instanceof Error?e.message:`Could not save the message`)}finally{v(!1)}},w=async()=>{v(!0),x(void 0);try{await o?.()}catch(e){x(e instanceof Error?e.message:`Could not remove the message`)}finally{v(!1)}};return p?(0,R.jsxs)(Z,{role:`user`,ts:i,"data-slot":`user-bubble`,"data-editing":`true`,children:[(0,R.jsx)(`textarea`,{autoFocus:!0,"aria-label":`Edit the message`,value:h,onChange:e=>g(e.target.value),onKeyDown:e=>{e.key===`Escape`?(e.stopPropagation(),m(!1)):e.key===`Enter`&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),C())},className:`block max-h-[220px] min-h-[60px] w-full resize-none rounded-md bg-background px-2 py-1.5 text-[14px] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50`}),(0,R.jsxs)(`span`,{className:`mt-1.5 flex justify-end gap-1.5`,children:[(0,R.jsx)(`button`,{type:`button`,onClick:()=>m(!1),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm px-2 text-xs font-medium text-muted-foreground hover:bg-background hover:text-foreground focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:`Cancel`}),(0,R.jsx)(`button`,{type:`button`,onClick:()=>void C(),disabled:_,className:`inline-flex min-h-11 min-w-11 items-center justify-center rounded-sm bg-action px-2 text-xs font-semibold text-action-foreground hover:brightness-[0.96] focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:_?(0,R.jsx)(T,{className:`size-3.5 animate-spin`}):`Save`})]}),b?(0,R.jsx)(`p`,{role:`alert`,className:`mt-1.5 text-xs text-danger`,children:b}):null]}):(0,R.jsxs)(Z,{role:`user`,ts:i,"data-slot":`user-bubble`,className:`group`,children:[a||o?(0,R.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`mb-1 flex justify-end gap-0.5 opacity-0 transition-opacity group-hover:opacity-100 focus-within:opacity-100`,children:[a?(0,R.jsx)(`button`,{type:`button`,"aria-label":s,onClick:S,disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,R.jsx)(Se,{className:`size-3.5`})}):null,o?(0,R.jsx)(`button`,{type:`button`,"aria-label":l,onClick:()=>void w(),disabled:_,className:`inline-flex size-11 items-center justify-center rounded-sm text-soft-foreground hover:bg-background hover:text-danger focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,children:(0,R.jsx)(y,{className:`size-3.5`})}):null]}):null,b?(0,R.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:b}):null,u??(0,R.jsx)(F,{breaks:!0,children:e}),n.length>0?(0,R.jsx)(`span`,{"data-slot":`user-images`,className:`mt-2 flex flex-wrap items-center justify-end gap-1.5`,children:n.map(e=>c(e.split(`/`).pop()??``)?(0,R.jsx)(ge,{src:e,alt:`attached`,className:`max-h-40 max-w-[220px] rounded-md border border-border object-contain`},e):(0,R.jsxs)(`a`,{href:r(e),download:!0,"data-slot":`user-file`,className:`inline-flex min-h-11 min-w-11 max-w-[220px] items-center gap-1.5 rounded-md border border-border bg-background/60 px-2 py-1 text-xs text-muted-foreground hover:text-foreground`,children:[(0,R.jsx)(f,{"aria-hidden":`true`,className:`size-3.5 shrink-0`}),(0,R.jsx)(`span`,{className:`truncate`,children:e.split(`/`).pop()})]},e))}):null,d>0?(0,R.jsxs)(`span`,{className:`mt-1 block text-xs text-soft-foreground`,children:[d,` image`,d>1?`s`:``,` attached`]}):null]})}),Vt=`inline-flex h-11 min-w-11 items-center justify-center gap-1 rounded-sm px-2 text-xs font-medium text-soft-foreground hover:bg-background hover:text-foreground focus-visible:opacity-100 focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`,Ht=[`[data-streamdown="code-block-actions"]`,`[data-streamdown="code-copy-button"]`,`[data-streamdown="code-block-copy-button"]`,`[data-streamdown="code-block-header"]`].join(`,`);function Ut(e,t){let n=e.cloneNode(!0);n.querySelectorAll(Ht).forEach(e=>e.remove());let r=qe(t);return[...n.querySelectorAll(`button[data-streamdown="link"]`)].forEach(e=>{let t=e.textContent??``,i=r.findIndex(e=>e.label===t);if(i<0)return;let a=r.splice(i,1)[0];if(!a||!V(a.href))return;let o=n.ownerDocument.createElement(`a`);o.setAttribute(`href`,a.href),o.setAttribute(`data-streamdown`,`link`),o.textContent=e.textContent,e.replaceWith(o)}),n.innerHTML}async function Wt(e,t,n){if(e===`markdown`){if(!navigator.clipboard?.writeText)throw Error(`Clipboard unavailable`);await navigator.clipboard.writeText(t);return}if(!navigator.clipboard?.write||typeof ClipboardItem>`u`||!n)throw Error(`Clipboard unavailable`);let r=Ut(n,t);await navigator.clipboard.write([new ClipboardItem({"text/html":new Blob([r],{type:`text/html`}),"text/plain":new Blob([t],{type:`text/plain`})})])}var Gt=(0,L.memo)(function({text:e,ts:t,messageKey:n}){let r=(0,L.useRef)(null),[i,a]=(0,L.useState)(null),[o,s]=(0,L.useState)(null),c=(0,L.useRef)(null);(0,L.useEffect)(()=>()=>{c.current!==null&&clearTimeout(c.current)},[]);let l=async t=>{c.current!==null&&clearTimeout(c.current),a(null),s(null);try{await Wt(t,e,r.current),a(t),c.current=setTimeout(()=>a(null),2e3)}catch{s(`Couldn't copy to the clipboard`)}};return(0,R.jsxs)(Z,{role:`agent`,ts:t,"data-slot":`assistant-message`,headerActions:(0,R.jsxs)(`span`,{"data-slot":`bubble-actions`,className:`flex items-center gap-0.5`,children:[(0,R.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply`,onClick:()=>void l(`html`),className:Vt,children:[(0,R.jsx)(b,{className:`size-3.5`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{"aria-live":`polite`,children:i===`html`?`Copied`:`Copy`})]}),(0,R.jsxs)(`button`,{type:`button`,"aria-label":`Copy reply as markdown`,onClick:()=>void l(`markdown`),className:Vt,children:[(0,R.jsx)(N,{className:`size-3.5`,"aria-hidden":`true`}),(0,R.jsx)(`span`,{"aria-live":`polite`,children:i===`markdown`?`Copied`:`Copy markdown`})]})]}),children:[o?(0,R.jsx)(`p`,{role:`alert`,className:`mb-1 text-xs text-danger`,children:o}):null,(0,R.jsx)(`div`,{ref:r,children:(0,R.jsx)(F,{breaks:!0,children:e})}),(0,R.jsx)(Xe,{text:e,messageKey:n})]})});function Kt({incident:e}){let t=s().data;if(!t)return null;let n=o(t,e.provider);return(0,R.jsxs)(`div`,{role:`alert`,"data-slot":`provider-auth-required`,className:`rounded-md border border-danger/30 bg-danger/5 px-3.5 py-3`,children:[(0,R.jsxs)(`p`,{className:`text-[13px] font-semibold text-foreground`,children:[`This run needed `,n,` authorization`]}),(0,R.jsxs)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:[`Review `,n,` settings before retrying.`]}),(0,R.jsx)(j,{to:`/settings/agent-defaults#providers`,className:`mt-2 inline-flex text-xs font-medium text-foreground underline-offset-2 hover:underline`,children:`Open provider settings`})]})}var qt=(0,L.memo)(function({text:e}){let t=(0,L.useId)();if(e.trim()===``)return null;let n=e.split(`
5
+ `,1)[0]??``,r=n.length<e.length;return(0,R.jsxs)(A,{"data-slot":`reasoning`,className:`group/reasoning min-w-0`,children:[(0,R.jsxs)(`div`,{id:t,className:`relative flex w-full items-center gap-1.5 rounded-md p-0.5 text-left text-[13px] text-soft-foreground hover:text-muted-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]/reasoning:rotate-90`}),(0,R.jsx)(`span`,{className:`shrink-0`,children:`Thinking — `}),(0,R.jsx)(`div`,{className:`min-w-0 truncate text-muted-foreground`,children:(0,R.jsx)(F,{inline:!0,children:n})}),r?(0,R.jsx)(`span`,{"aria-hidden":!0,children:`…`}):null,(0,R.jsx)(k,{"aria-labelledby":t,className:`absolute inset-0 rounded-md focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-none`})]}),(0,R.jsx)(O,{children:(0,R.jsx)(`div`,{className:`px-6 py-1.5 text-[13px] leading-[1.6] text-soft-foreground`,children:(0,R.jsx)(F,{children:e})})})]})});function Jt(){return(0,R.jsxs)(`div`,{"data-slot":`working-indicator`,className:`flex items-center gap-2 py-1 text-[13px] text-soft-foreground`,children:[(0,R.jsx)(T,{role:`status`,"aria-label":`Working`,className:`size-3.5 shrink-0 animate-spin`}),(0,R.jsx)(`span`,{className:`shimmer font-medium`,children:`Working…`})]})}var Yt={read:N,edit:Se,delete:y,move:xe,search:p,execute:E,think:be,fetch:w,task:h,plan:m,other:v},Xt=e=>e.split(`
6
+ `).length;function Zt({text:e,streaming:t}){let[n,r]=(0,L.useState)(!1),a=(0,L.useRef)(null),o=(0,L.useRef)(!0);(0,L.useEffect)(()=>{let e=a.current;t&&e&&o.current&&(e.scrollTop=e.scrollHeight)},[e,t]);let s=Xt(e),c=!t&&!n&&s>12;return(0,R.jsxs)(`div`,{"data-slot":`tool-output`,"data-clamped":c?`true`:void 0,children:[(0,R.jsxs)(`div`,{className:`relative`,children:[(0,R.jsx)(`div`,{ref:a,onScroll:t?e=>{o.current=gt(e.currentTarget)}:void 0,className:i(`overflow-x-auto`,t&&`max-h-[216px] overflow-y-auto`,c&&`max-h-[216px] overflow-y-hidden`),children:(0,R.jsx)(`pre`,{className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre text-muted-foreground`,children:e})}),c?(0,R.jsx)(`div`,{"data-slot":`tool-output-fade`,"aria-hidden":!0,className:`pointer-events-none absolute inset-x-0 bottom-0 h-14 bg-gradient-to-b from-transparent to-card-2`}):null]}),!t&&s>12?(0,R.jsx)(`button`,{type:`button`,"data-slot":`tool-output-toggle`,onClick:()=>r(e=>!e),className:`block w-full border-t border-border/50 px-4 py-1.5 text-left text-xs font-medium text-soft-foreground hover:text-foreground`,children:n?`Show less`:`Show all ${s} lines`}):null]})}function Qt({diffs:e}){return(0,R.jsx)(R.Fragment,{children:e.map((e,t)=>(0,R.jsxs)(`div`,{"data-slot":`diff-preview`,className:`min-w-0`,children:[(0,R.jsx)(`div`,{className:`border-b border-border/50 px-4 py-1.5 font-mono text-xs wrap-anywhere text-muted-foreground`,children:e.path}),(0,R.jsx)(`pre`,{className:`overflow-x-auto py-2 font-mono text-xs leading-[1.7] whitespace-pre`,children:e.unified===void 0?[...$t(e.oldText).map((e,t)=>(0,R.jsxs)(`span`,{className:`block bg-diff-del px-4 text-muted-foreground`,children:[`- `,e]},`old-${t}`)),...$t(e.newText).map((e,t)=>(0,R.jsxs)(`span`,{className:`block bg-diff-add px-4`,children:[`+ `,e]},`new-${t}`))]:e.unified.split(`
7
+ `).map((e,t)=>(0,R.jsx)(en,{text:e},t))})]},`${e.path}:${t}`))})}function $t(e){return e==null||e===``?[]:e.replace(/\n$/,``).split(`
8
+ `)}function en({text:e}){return(0,R.jsx)(`span`,{className:i(`block px-4`,e.startsWith(`+`)&&`bg-diff-add`,e.startsWith(`-`)&&`bg-diff-del text-muted-foreground`,e.startsWith(`@@`)&&`text-soft-foreground`),children:e})}function tn(e){return e.toolKind===`execute`&&e.status===`running`&&e.output!==void 0}function nn(e){let t=e.status===`running`||e.status===`pending`,n=ot(e.title),{verb:r,detail:i}=e.toolKind===`execute`&&n.detail===void 0?{verb:`Ran`,detail:e.title}:n;return{busy:t,verb:r,detail:i,expandedCommand:(e.toolKind===`execute`?Ue(e.input):te(e.name).toolKind===e.toolKind?ne(e.name,e.input):void 0)??i,Icon:Yt[e.toolKind]??v}}function rn(e,t){return e.output!==void 0&&e.output!==``||e.error!==void 0&&e.error!==``||e.diffs!==void 0&&e.diffs.length>0||t>0}function an({item:e,busy:t}){return(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[t?(0,R.jsx)(T,{role:`status`,"aria-label":`Running`,className:`size-3.5 animate-spin text-soft-foreground`}):null,e.status===`failed`?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:`failed`}):null,e.status===`declined`?(0,R.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`declined`}):null,e.toolKind===`execute`&&typeof e.exitCode==`number`?(0,R.jsx)(`span`,{"data-slot":`tool-exit`,className:i(`rounded-full px-2 py-px font-mono text-xs font-semibold`,e.exitCode===0?`bg-success/10 text-success`:`bg-danger/10 text-danger`),children:e.exitCode}):null]})}function on({item:e,command:t,busy:n,nested:r,cacheKey:i,renderNested:a}){return(0,R.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[t===void 0?null:(0,R.jsx)(`pre`,{"data-slot":`tool-command`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap break-words [overflow-wrap:anywhere]`,children:t}),e.error!==void 0&&e.error!==``?(0,R.jsx)(`div`,{"data-slot":`tool-error`,className:`px-4 py-3 font-mono text-xs leading-[1.7] whitespace-pre-wrap wrap-anywhere text-signal-word-red`,children:e.error}):null,e.diffs!==void 0&&e.diffs.length>0?(0,R.jsx)(Qt,{diffs:e.diffs}):null,e.output!==void 0&&e.output!==``?(0,R.jsx)(Zt,{text:e.output,streaming:n}):null,r.length>0?(0,R.jsx)(`div`,{"data-slot":`tool-nested`,className:`flex flex-col gap-2 border-l-2 border-border py-2.5 pr-3 pl-3 ml-4 my-2`,children:a?.(r,i??e.id)}):null]})}function sn({item:e,nested:t=[],cacheKey:n,renderNested:r}){let a=K(),[o,s]=(0,L.useState)(()=>n===void 0?null:a?.get(n)??null),c=e=>{n!==void 0&&a?.set(n,e),s(e)},{busy:l,verb:u,detail:d,expandedCommand:f,Icon:p}=nn(e),m=rn(e,t.length),h=f!==void 0||m,_=h&&(o??(m&&tn(e)));return(0,R.jsxs)(A,{"data-slot":`tool-card`,"data-status":e.status,"data-kind":e.toolKind,open:_,onOpenChange:c,className:i(`min-w-0 overflow-hidden rounded-md border bg-card`,e.status===`failed`?`border-danger/25`:`border-border`),children:[(0,R.jsxs)(k,{disabled:!h,className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] enabled:hover:bg-muted`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:i(`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`,!h&&`invisible`)}),(0,R.jsx)(p,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:i(`shrink-0 font-semibold`,l&&`shimmer`,e.status===`declined`&&`text-muted-foreground`),children:u}),d===void 0?null:(0,R.jsx)(`code`,{title:d,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:d}),(0,R.jsx)(an,{item:e,busy:l})]}),(0,R.jsx)(O,{children:(0,R.jsx)(on,{item:e,command:f,busy:l,nested:t,cacheKey:n,renderNested:r})})]})}function cn(e){let t=e.name??e.event,n=t.indexOf(`:`);return n>0?`${t.slice(0,n)} · ${t.slice(n+1)}`:t}function ln({item:e,cacheKey:t}){let n=K(),[r,a]=(0,L.useState)(()=>t===void 0?!1:n?.get(t)??!1),o=e=>{t!==void 0&&n?.set(t,e),a(e)},s=e.status!==`completed`,c=e.entries.some(e=>e.kind===`context`),l=(e.stdout??``)!==``||(e.stderr??``)!==``,u=cn(e);return(0,R.jsxs)(A,{"data-slot":`hook-card`,"data-status":e.status,open:r,onOpenChange:o,className:i(`min-w-0 overflow-hidden rounded-md border bg-card`,s?`border-danger/25`:`border-border`),children:[(0,R.jsxs)(k,{className:`group flex min-h-[28px] w-full items-center gap-1.5 px-2.5 py-0.5 text-left text-[13px] hover:bg-muted`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),(0,R.jsx)(ye,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-muted-foreground`}),(0,R.jsx)(`span`,{className:`shrink-0 font-semibold`,children:`Hook`}),(0,R.jsx)(`code`,{title:u,className:`block min-w-0 flex-1 truncate font-mono text-xs text-muted-foreground`,children:u}),(0,R.jsxs)(`span`,{className:`ml-auto flex shrink-0 items-center gap-2 pl-2`,children:[s?(0,R.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.status}):c?(0,R.jsx)(`span`,{className:`text-xs text-soft-foreground`,children:`context`}):null,s&&typeof e.exitCode==`number`&&e.exitCode!==0?(0,R.jsx)(`span`,{"data-slot":`hook-exit`,className:`rounded-full bg-danger/10 px-2 py-px font-mono text-xs font-semibold text-danger`,children:e.exitCode}):null]})]}),(0,R.jsx)(O,{children:(0,R.jsxs)(`div`,{className:`border-t border-border bg-card-2`,children:[e.entries.map((e,t)=>(0,R.jsx)(`pre`,{"data-slot":`hook-entry`,"data-kind":e.kind,className:i(`px-3 py-2 font-mono text-xs leading-[1.7] whitespace-pre-wrap [overflow-wrap:anywhere]`,(e.kind===`error`||e.kind===`stop`)&&`text-signal-word-red`),children:e.text},t)),e.source===void 0?null:(0,R.jsx)(`p`,{"data-slot":`hook-source`,className:`px-3 pb-2 font-mono text-xs text-muted-foreground [overflow-wrap:anywhere]`,children:e.source}),l?(0,R.jsxs)(A,{className:`border-t border-border`,children:[(0,R.jsxs)(k,{"data-slot":`hook-raw-toggle`,className:`group flex w-full items-center gap-1 px-3 py-1 text-left text-xs text-muted-foreground hover:text-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),`Raw output${typeof e.exitCode==`number`?` · exit ${e.exitCode}`:``}`]}),(0,R.jsxs)(O,{children:[e.stdout?(0,R.jsx)(`pre`,{"data-slot":`hook-stdout`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap [overflow-wrap:anywhere]`,children:e.stdout}):null,e.stderr?(0,R.jsx)(`pre`,{"data-slot":`hook-stderr`,className:`px-3 py-2 font-mono text-xs whitespace-pre-wrap text-signal-word-red [overflow-wrap:anywhere]`,children:e.stderr}):null]})]}):null]})})]})}function un({group:e,scope:t}){return(0,R.jsxs)(A,{"data-slot":`ctx-group`,className:`min-w-0`,children:[(0,R.jsxs)(k,{className:`group flex h-[34px] tabular-nums w-full items-center gap-2 rounded-md px-2 -mx-2 text-left text-[13px] font-medium text-muted-foreground hover:bg-muted hover:text-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 text-soft-foreground transition-transform group-data-[state=open]:rotate-90`}),e.label]}),(0,R.jsx)(O,{children:(0,R.jsx)(`div`,{className:`flex flex-col gap-1.5 pt-1.5 pl-4`,children:e.tools.map(e=>(0,R.jsx)(sn,{item:e,cacheKey:t===void 0?void 0:`${t}:${e.id}`},e.id))})})]})}function dn({count:e,children:t}){return(0,R.jsxs)(A,{"data-slot":`tool-streak`,className:`min-w-0`,children:[(0,R.jsxs)(k,{className:`group flex items-center gap-1.5 rounded-md p-0.5 tabular-nums text-left text-xs text-soft-foreground hover:text-muted-foreground`,children:[(0,R.jsx)(g,{"aria-hidden":!0,className:`size-3.5 shrink-0 transition-transform group-data-[state=open]:rotate-90`}),it(e)]}),(0,R.jsx)(O,{children:(0,R.jsx)(`div`,{className:`flex flex-col gap-2 pt-2`,children:t})})]})}function fn({image:e}){return(0,R.jsx)(ge,{"data-slot":`thread-image`,src:e.url,alt:e.name??`image from the agent session`,className:`max-h-72 max-w-full self-start rounded-lg border border-border`})}var pn={finish:`Closed when the task finished`,superseded:`Closed when the worker went on`,"parent-stopped":`Closed when the parent stopped`,"worker-stopped":`Closed when the worker stopped`,undeliverable:`Closed: not delivered`};function mn(e,t,n){return`${e.header}: ${n?.trim()||t.join(`, `)}`}function hn(e,t,n,r=``){let i=e.map((e,r)=>mn(e,t[r]??[],n[r])).join(`
9
+ `),a=r.trim();return a?`${i}\n\nAdditional comments:\n${a}`:i}function gn({ask:e,run:t,projectId:n,onShowOrigin:r,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s=!1,onFinish:c,finishing:l=!1,mode:u,onModeChange:d,hideReplyBody:f=!1,delivery:p,surface:m=`transcript`}){let h=m===`transcript`&&e.context?(0,R.jsx)(Q,{text:e.context}):null;if(e.resolved)return(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[e.context?(0,R.jsx)(Q,{text:e.context}):null,(0,R.jsxs)(Z,{role:`user`,"data-slot":`ask-card`,"data-resolved":`true`,children:[(0,R.jsx)(`span`,{className:`text-soft-foreground`,children:e.closed?pn[e.closed]:e.answeredBy===`parent`?`Answered by parent`:`Answered`}),(0,R.jsx)(Oe,{ask:e})]})]});let g=e.placement===`pinned`&&r?r:void 0;return e.routedToParent?(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[h,(0,R.jsx)(_n,{ask:e,runId:t.id,surface:m,onShowOrigin:g})]}):(0,R.jsxs)(`div`,{className:`flex flex-col gap-3`,children:[h,(0,R.jsx)(xn,{ask:e,run:t,projectId:n,surface:m,onShowOrigin:g,onAnswered:i,renderFreeTextReply:a,onStop:o,stopping:s,onFinish:c,finishing:l,controlledMode:u,onModeChange:d,hideReplyBody:f,delivery:p})]})}function Q({text:e}){return(0,R.jsx)(Z,{role:`agent`,children:(0,R.jsx)(`div`,{"data-slot":`ask-context`,role:`region`,"aria-label":`Context`,className:`break-words text-sm text-foreground`,children:(0,R.jsx)(F,{breaks:!0,children:e})})})}function _n({ask:e,runId:t,surface:n,onShowOrigin:r}){let[i,a]=(0,L.useState)(!1),o=(0,L.useRef)(null),s=n===`decision-zone`&&!!e.context;return(0,R.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-routed":`parent`,className:`rounded-xl border border-card-edge bg-card shadow-card px-3 py-2.5`,children:[(0,R.jsxs)(`div`,{className:`mb-2 flex flex-wrap items-center gap-2`,children:[(0,R.jsx)(`span`,{className:`text-xs font-medium text-link-foreground`,children:`The agent is asking its parent`}),s?(0,R.jsx)(D,{ref:o,type:`button`,variant:`ghost`,size:`sm`,"data-slot":`ask-show-context`,className:`ms-auto px-2 text-xs font-medium text-link-foreground underline underline-offset-4`,onClick:()=>a(!0),children:`Show context`}):null]}),(0,R.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-3`,children:e.questions.map((e,t)=>(0,R.jsxs)(`div`,{role:`group`,"aria-label":e.question,children:[(0,R.jsx)(`div`,{className:`mb-0.5 flex items-center gap-2`,children:(0,R.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:e.header})}),(0,R.jsx)(`p`,{className:`mb-1.5 break-words text-sm font-semibold text-foreground`,children:e.question}),e.options?(0,R.jsx)(`ul`,{className:`flex list-disc flex-col gap-0.5 pl-5 text-[13px] text-muted-foreground`,children:e.options.map(e=>(0,R.jsxs)(`li`,{className:`break-words`,children:[(0,R.jsx)(`span`,{className:`text-foreground`,children:e.label}),e.description?(0,R.jsxs)(`span`,{children:[`: `,e.description]}):null]},e.label))}):(0,R.jsx)(`p`,{"data-slot":`ask-open-routed`,className:`text-[13px] text-muted-foreground`,children:`Open question: answered in words, with no options.`})]},e.id??t))}),(0,R.jsxs)(`div`,{"data-slot":`ask-footer`,className:`mt-2.5 flex flex-wrap items-center gap-2`,children:[(0,R.jsxs)(`p`,{"data-slot":`ask-routed-hint`,className:`text-xs text-muted-foreground`,children:[`Routed to parent: answer it in the`,` `,e.parentRunId?(0,R.jsx)(j,{to:`/tasks/${e.parentRunId}`,className:`font-medium text-foreground underline underline-offset-4`,children:`parent task`}):`parent task`,`.`]}),!s&&r?(0,R.jsx)(Le,{onShowOrigin:r,className:`ms-auto`}):null]}),s&&e.context?(0,R.jsx)(Re,{open:i,onOpenChange:a,runId:t,context:e.context,onShowOrigin:r,returnFocusRef:o}):null]})}function vn(e,t,n,r,i){let a=t.blockedBy!==void 0,o=e.questions,s=o.length>1,c=o.length,[l,u]=(0,L.useState)(`options`),d=n??l,f=e=>{u(e),r?.(e)},[p,m]=(0,L.useState)(0),[h,g]=(0,L.useState)({}),[_,v]=(0,L.useState)({}),[y,b]=(0,L.useState)(``),[x,S]=(0,L.useState)(!1),[C,w]=(0,L.useState)(``),[T,ee]=(0,L.useState)(!1),te=s&&p===c,ne=o.length===1&&o[0]?.options!==void 0&&o[0]?.multiSelect!==!0&&!x&&y.trim()===``;ue(Object.values(h).some(e=>e.length>0)||Object.values(_).some(e=>e.trim()!==``)||y.trim()!==``||C.trim()!==``);let E=(e,t)=>g(n=>({...n,[e]:t})),D=e=>v(t=>{if(t[e]===void 0)return t;let n={...t};return delete n[e],n}),O=e=>{E(e,[]),v(t=>({...t,[e]:t[e]??``}))},k=o.some((e,t)=>!e.options||_[t]!==void 0),A=o.filter((e,t)=>B(t,h,_)).length,j=A===o.length,M=async e=>{let n=await t.send(e);return n===void 0&&i?.(),n};return{delivery:t,blocked:a,questions:o,stepped:s,commentStepIndex:c,mode:d,setMode:f,stepIndex:p,setStepIndex:m,selections:h,otherAnswers:_,setOtherAnswers:v,additionalComment:y,setAdditionalComment:b,singleCommentOpen:x,setSingleCommentOpen:S,freeTextDraft:C,setFreeTextDraft:w,contextOpen:T,setContextOpen:ee,onCommentStep:te,oneTap:ne,setQuestion:E,clearOtherAnswer:D,selectOther:O,hasOtherAnswer:k,answeredCount:A,allAnswered:j,deliver:M,sendAll:()=>void M(hn(o,h,_,y)),sendFreeText:()=>{let e=C.trim();e&&M(e).then(e=>{e===void 0&&w(``)})}}}function yn({state:e,renderFreeTextReply:t}){let n=(0,L.useId)(),r=e.delivery.isPending||e.blocked;if(e.mode===`reply`)return(0,R.jsx)(Ne,{value:e.freeTextDraft,onValueChange:e.setFreeTextDraft,disabled:r,renderFreeTextReply:t});if(e.onCommentStep)return(0,R.jsx)(Me,{questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,comment:e.additionalComment,disabled:r,onCommentChange:e.setAdditionalComment,onJumpToQuestion:e.setStepIndex});let i=e.stepped?Math.min(e.stepIndex,e.questions.length-1):0,a=e.questions[i];return a?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(wn,{question:a,disabled:r,selected:e.selections[i]??[],isOther:e.otherAnswers[i]!==void 0,otherAnswer:e.otherAnswers[i]??``,onSelect:t=>{e.blocked||(e.clearOtherAnswer(i),e.oneTap?e.deliver(mn(a,t)):e.setQuestion(i,t))},onOtherToggle:()=>{e.blocked||(e.otherAnswers[i]===void 0?e.selectOther(i):e.clearOtherAnswer(i))},onOtherChange:t=>e.setOtherAnswers(e=>({...e,[i]:t}))},a.id??i),!e.stepped&&e.singleCommentOpen?(0,R.jsxs)(`div`,{className:`pt-1`,children:[(0,R.jsx)(`label`,{htmlFor:n,className:`mb-1 block text-xs font-medium text-foreground`,children:`Additional comments (optional)`}),(0,R.jsx)(P,{id:n,"data-slot":`ask-additional-comment`,rows:2,value:e.additionalComment,disabled:r,placeholder:`Optional extra notes for the agent…`,onChange:t=>e.setAdditionalComment(t.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):null}function bn({onFinish:e,finishing:t,onStop:n,stopping:r,onActionError:i}){if(!e&&!n)return null;let a=e=>{i(void 0),Promise.resolve(e()).catch(e=>{i(e instanceof Error?e.message:String(e))})};return(0,R.jsxs)(R.Fragment,{children:[e?(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`ask-finish`,disabled:t||r,title:`Close the session and mark this task done`,className:`px-3`,onClick:()=>a(e),children:t?`Finishing…`:`Finish`}):null,n?(0,R.jsx)(D,{type:`button`,variant:`outline`,size:`sm`,disabled:r||t,className:`px-3`,onClick:()=>a(n),children:r?`Stopping…`:`Stop`}):null]})}function xn(e){return e.delivery===void 0?(0,R.jsx)(Sn,{...e}):(0,R.jsx)($,{...e,delivery:e.delivery})}function Sn(e){let t=me(e.run,e.projectId);return(0,R.jsx)($,{...e,delivery:t})}function $({ask:e,run:t,surface:n,onShowOrigin:r,onAnswered:a,renderFreeTextReply:o,onStop:s,stopping:c,onFinish:l,finishing:u,controlledMode:d,onModeChange:f,hideReplyBody:p,delivery:m}){let h=vn(e,m,d,f,a),[g,_]=(0,L.useState)(void 0),v=(0,L.useRef)(null),y=h.delivery.mode===`resume`,b=n===`decision-zone`||o!==void 0,x=n===`decision-zone`&&!!e.context,S=h.additionalComment.trim()!==``,C=h.mode===`reply`&&p,w=(0,R.jsx)(bn,{onFinish:l,finishing:u,onStop:s,stopping:c,onActionError:_});return(0,R.jsxs)(`div`,{"data-slot":`ask-card`,"data-resolved":`false`,"data-ask-id":e.id,"data-ask-mode":h.mode,"data-pinned":e.placement===`pinned`?`true`:void 0,"data-delivery":h.delivery.mode,className:i(`rounded-xl border border-accent-strong/30 bg-accent-strong/[0.04] [html:not(.light)_&]:bg-card`,C&&`rounded-b-none border-b-0`),children:[(0,R.jsx)(Ae,{stepped:h.stepped,mode:h.mode,onModeChange:h.setMode,showModeSwitch:b,stepLabel:h.onCommentStep?`Comment (optional)`:`${h.stepIndex+1} of ${h.questions.length}`,hasSheetContext:x,showContextButtonRef:v,onOpenContext:()=>h.setContextOpen(!0),onShowOrigin:x?void 0:r}),h.stepped&&h.mode===`options`?(0,R.jsx)(je,{questions:h.questions,stepIndex:h.stepIndex,selections:h.selections,otherAnswers:h.otherAnswers,hasComment:S,onSelectStep:h.setStepIndex}):null,C?null:(0,R.jsxs)(R.Fragment,{children:[(0,R.jsx)(`div`,{"data-slot":`ask-body`,className:`flex flex-col gap-2.5 px-3 py-2.5`,children:(0,R.jsx)(yn,{state:h,renderFreeTextReply:o})}),(0,R.jsxs)(`div`,{"data-slot":`ask-footer`,className:`flex shrink-0 flex-col gap-2 border-t border-border/70 px-3 py-2`,children:[(0,R.jsx)(Cn,{state:h,hasComment:S,resuming:y,hasCustomReply:o!==void 0,stopControl:w}),(0,R.jsx)(Ie,{blockedBy:h.delivery.blockedBy,reason:h.delivery.reason,error:h.delivery.error??g})]})]}),x&&e.context?(0,R.jsx)(Re,{open:h.contextOpen,onOpenChange:h.setContextOpen,runId:t.id,context:e.context,onShowOrigin:r,returnFocusRef:v}):null]})}function Cn({state:e,hasComment:t,resuming:n,hasCustomReply:r,stopControl:i}){return e.mode===`reply`?r?null:(0,R.jsxs)(`div`,{className:`flex items-center justify-end gap-2`,children:[i,(0,R.jsx)(D,{type:`button`,size:`sm`,className:`px-3.5`,disabled:e.delivery.isPending||e.blocked||e.freeTextDraft.trim()===``,onClick:e.sendFreeText,children:`Send reply`})]}):e.stepped?(0,R.jsx)(Pe,{stepIndex:e.stepIndex,questionCount:e.questions.length,answeredCount:e.answeredCount,allAnswered:e.allAnswered,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked,onBack:()=>e.setStepIndex(e=>Math.max(0,e-1)),onNext:()=>e.setStepIndex(t=>Math.min(e.commentStepIndex,t+1)),onOpenComment:()=>e.setStepIndex(e.commentStepIndex),onSend:e.sendAll,questions:e.questions,selections:e.selections,otherAnswers:e.otherAnswers,stopControl:i}):(0,R.jsx)(Fe,{oneTap:e.oneTap,hasOtherAnswer:e.hasOtherAnswer,allowComment:e.questions[0]?.allowFreeText!==!1,commentOpen:e.singleCommentOpen,hasComment:t,resuming:n,disabled:e.delivery.isPending||e.blocked||!e.allAnswered,onToggleComment:()=>e.setSingleCommentOpen(e=>!e),onSend:e.sendAll,stopControl:i})}function wn({question:e,disabled:t,selected:n,isOther:r,otherAnswer:a,onSelect:o,onOtherToggle:s,onOtherChange:c}){let l=(0,L.useId)(),u=(0,L.useRef)(null),d=(0,L.useRef)(r),f=e.options,p=f!==void 0,m=p&&e.multiSelect===!0;(0,L.useEffect)(()=>{let e=r&&!d.current;d.current=r,e&&p&&u.current?.focus()},[r,p]);let h=e=>{if(!m){o([e]);return}o(n.includes(e)?n.filter(t=>t!==e):[...n,e])};return(0,R.jsxs)(`div`,{"data-slot":`ask-question`,role:`group`,"aria-label":e.question,children:[(0,R.jsxs)(`div`,{className:`mb-1.5 flex flex-wrap items-baseline gap-x-2 gap-y-0.5`,children:[(0,R.jsx)(`span`,{className:`shrink-0 rounded-md bg-accent-strong px-1.5 py-0.5 text-xs font-semibold uppercase tracking-wide text-accent-strong-foreground`,children:e.header}),(0,R.jsx)(`p`,{className:`min-w-0 flex-1 break-words text-sm font-semibold text-foreground`,children:e.question}),m?(0,R.jsx)(`span`,{className:`ms-auto text-xs text-soft-foreground`,children:`select all that apply`}):null]}),f?(0,R.jsxs)(R.Fragment,{children:[(0,R.jsxs)(`div`,{"data-slot":`ask-options`,className:`grid grid-cols-1 gap-1.5 sm:grid-cols-2 sm:gap-2`,children:[f.map(e=>{let r=n.includes(e.label);return(0,R.jsxs)(`button`,{type:`button`,disabled:t,"aria-pressed":r,onClick:()=>h(e.label),className:i(`flex min-h-11 w-full flex-col items-start justify-start content-start gap-0.5 rounded-md border px-2.5 py-1.5 text-left transition-colors focus-visible:outline-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50`,r?`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`:`border-border bg-card pointer-hover:border-accent-strong/50 pointer-hover:bg-accent-strong/[0.08]`),children:[(0,R.jsxs)(`span`,{className:`flex min-w-0 items-start gap-2 text-[13px] font-semibold text-foreground`,children:[m?(0,R.jsx)(`span`,{"aria-hidden":`true`,className:i(`flex size-4 shrink-0 items-center justify-center rounded border text-[12px]`,r?`border-accent-strong bg-accent-strong text-accent-strong-foreground`:`border-soft-foreground`),children:r?`✓`:``}):null,(0,R.jsx)(`span`,{className:`min-w-0 break-words`,children:e.label})]}),e.description?(0,R.jsx)(`span`,{className:`min-w-0 break-words text-xs text-muted-foreground`,children:e.description}):null]},e.label)}),e.allowFreeText===!1?null:(0,R.jsx)(D,{type:`button`,variant:`outline`,"aria-pressed":r,"aria-expanded":r,"aria-controls":r?l:void 0,disabled:t,onClick:s,size:`block`,className:i(`px-2.5`,f.length%2==0&&`sm:col-span-2`,r&&`border-accent-strong bg-accent-strong/15 ring-1 ring-accent-strong/30 pointer-hover:border-accent-strong pointer-hover:bg-accent-strong/15`),children:`Other`})]}),e.allowFreeText!==!1&&r?(0,R.jsxs)(`div`,{className:`mt-2`,children:[(0,R.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,R.jsx)(P,{ref:u,id:l,rows:2,value:a,disabled:t,placeholder:`Type your custom answer…`,onChange:e=>c(e.target.value),className:`bg-card text-base md:text-[13px]`})]}):null]}):(0,R.jsxs)(`div`,{children:[(0,R.jsx)(`label`,{htmlFor:l,className:`mb-1.5 block text-xs font-medium text-foreground`,children:`Your answer`}),(0,R.jsx)(P,{id:l,rows:2,value:a,disabled:t,placeholder:`Type your answer…`,onChange:e=>c(e.target.value),className:`bg-card text-base md:text-[13px]`})]})]})}export{K as A,Ct as C,ht as D,yt as E,Je as F,U as I,H as L,ot as M,$e as N,_t as O,Ye as P,Oe as R,St as S,xt as T,Y as _,ln as a,gt as b,qt as c,Bt as d,Jt as f,Pt as g,Nt as h,un as i,ct as j,ft as k,sn as l,Ft as m,Q as n,fn as o,Lt as p,Gt as r,Kt as s,gn as t,dn as u,At as v,bt as w,pt as x,mt as y,I as z};
@@ -0,0 +1 @@
1
+ import{Nn as e,On as t}from"./toaster-C1BFyQ8i.js";function n(n){return t[e(n).bucket]<=t.waiting}export{n as t};
@@ -0,0 +1,2 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{en as i,g as a,k as o,nn as s,on as c,tn as l}from"./queries-jsRcJKo6.js";import{H as u,Kr as d,Rn as f,U as p,V as m,W as h,_ as g,ai as _,ar as v,c as y,cr as b,d as x,g as ee,ii as te,o as ne,s as re,sr as ie,ur as ae,v as oe}from"./toaster-C1BFyQ8i.js";import{B as S,G as se,H as C,I as w,K as ce,N as T,P as E,V as le,W as D,j as O,z as k}from"./live-protocol-DMhTnCmf.js";import{h as ue,n as de}from"./chunk-KS7C4IRE-Cg8l-LDN.js";import{r as fe,t as A}from"./label-DRXJ8ljY.js";import{L as pe,X as me,Z as he,b as ge,ft as _e,ht as ve,nt as ye,ot as be,u as xe}from"./design-icons-QbNMZniQ.js";import{t as Se}from"./check-OP-CVgZG.js";import{t as j}from"./button-B22ANdCY.js";import{n as Ce,r as we,t as Te}from"./collapsible-Bx2vViFx.js";import{a as M,i as N,n as P,r as Ee,t as De}from"./select-k6LTVNcZ.js";import{t as Oe}from"./switch-CAKeV99j.js";import{c as ke,s as Ae,t as F}from"./project-router-C53GCY_8.js";import{c as I,d as L,f as je,l as Me,n as Ne,o as Pe}from"./page-shell-BgabWJ3w.js";import{a as Fe}from"./agent-accounts-BuceIkTR.js";import{r as Ie}from"./agents-settings-path-7X6_cvUg.js";import{t as Le}from"./centered-state-BgSV4e79.js";import{$ as Re,Dn as ze,F as Be,I as Ve,Kn as He,P as Ue,V as We,br as Ge,et as Ke,jn as qe,nt as Je,qn as Ye,r as Xe,sr as R,t as Ze}from"./index-CGDZRQo6.js";import{t as Qe}from"./textarea-vEsJAUAV.js";import{_ as $e,a as et,c as tt,d as nt,f as rt,g as it,h as at,i as ot,l as st,m as ct,n as lt,o as ut,p as dt,r as ft,s as pt,t as z,u as mt,v as ht}from"./automation-format-DB34jUyF.js";var B=e(t(),1),V=O([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),gt=S({includeExisting:E().optional(),authors:T(D()).optional(),assignees:T(D()).optional(),requireCurrentLabels:E().optional(),allLabels:T(D()).optional(),anyLabels:T(D()).optional(),excludeLabels:T(D()).optional(),changedLabels:T(D()).optional(),lookbackDays:k(),maxRecords:k()}),_t=O([`github`,`schedule`]),vt=v.omit({task:!0,images:!0,systemPrompt:!0}).extend({prompt:D(),variants:se([w(1),w(2),w(3)]).optional(),systemPrompt:D().optional()}),yt=S({at:D(),outcome:O([`launched`,`cancelled`]),runId:D().optional(),receiptId:D().optional(),trigger:O([`schedule`,`late`,`manual`,`retry`]).optional()}),H=S({id:D(),revision:k(),name:D(),description:D().optional(),enabled:E(),kind:_t,events:T(V).optional(),intervalSeconds:k().optional(),filters:gt.optional(),schedule:tt.optional(),task:vt,archived:yt.optional(),createdAt:D(),updatedAt:D()}),U=S({timestamp:D(),tieBreaker:D().optional()}),bt=S({since:D().datetime(),until:D().datetime(),source:k().int().min(0).max(2),page:k().int().min(1).max(10),item:k().int().min(0).max(100),event:k().int().min(0).max(1e3),cursor:U.optional()}),xt={lastError:D().max(1e3).optional(),lastErrorAt:D().datetime().optional()},St=S({revision:k().optional(),baselineAt:D().optional(),armedAt:D().optional(),historyScan:bt.optional(),cursor:U.optional(),frozenHighWatermark:U.extend({tieBreaker:D()}).optional(),backlogAfter:U.extend({tieBreaker:D()}).optional(),nextCheckAt:D().optional(),lastSuccessAt:D().optional(),nextRunAt:D().optional(),lastRunAt:D().optional(),etags:C(D(),D()).optional(),backoffUntil:D().optional(),consecutiveFailures:k().optional(),...xt,onceOutcome:O([`failed`,`missed`]).optional()});function Ct(e){let t=e?.consecutiveFailures??0;if(!(t<3||!e?.lastError))return{consecutiveFailures:t,lastError:e.lastError,...e.lastErrorAt?{lastErrorAt:e.lastErrorAt}:{},...e.backoffUntil?{retryAt:e.backoffUntil}:{}}}var wt=O([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]),Tt=S({seq:k(),ts:D(),automationId:D(),revision:k(),event:V.optional(),result:wt,reason:D().optional(),durationMs:k().optional(),receiptId:D().optional(),runId:D().optional(),githubNumber:k().optional(),githubTitle:D().optional(),githubUrl:D().optional(),rateLimit:S({bucket:O([`core`,`search`]),remaining:k().optional(),resetAt:D().optional()}).optional()}),Et=S({matches:k(),launched:k(),duplicates:k(),errors:k()}),Dt=H.extend({state:St.optional(),latestLog:Tt.optional(),counts:Et,nextRunAt:D().optional(),onceStatus:dt.optional()});S({available:E(),reason:D().optional(),timeZone:D(),scheduler:S({state:O([`scheduled`,`idle`]),nextDue:D().optional()}),automations:T(Dt)}),S({automation:H}).extend({once:S({dueAt:D(),timeZone:D(),resolvedInstant:D(),note:D()}).optional()}),S({automation:H,state:St.optional(),latestLog:Tt.optional(),onceStatus:dt.optional()}),S({id:D(),automationId:D(),mode:O([`preview`,`execute`]),status:O([`queued`,`running`,`complete`,`error`]),createdAt:D(),completedAt:D().optional(),matches:k().optional(),truncated:E().optional(),error:D().optional()}),S({checkId:D()}),S({records:T(Tt)}),S({receiptId:D(),runId:D()}),S({runId:D()}),H.omit({id:!0,revision:!0,createdAt:!0,updatedAt:!0,enabled:!0,kind:!0,archived:!0}).extend({kind:_t.optional(),task:vt.omit({variants:!0}).strict(),enable:E().optional()}).omit({enable:!0}).extend({enabled:E().optional(),expectedRevision:k()}),S({archived:O([`include`,`only`]).optional()}),S({mode:O([`preview`,`execute`])});var W=n();function G({text:e}){return(0,W.jsx)(`div`,{role:`status`,className:`rounded-xl border border-border bg-card p-6 text-sm text-muted-foreground`,children:e})}var Ot={launched:`success`,manual:`success`,"catch-up":`success`,skipped:`neutral`,missed:`pending`,"no-match":`neutral`,preview:`neutral`,baseline:`neutral`,duplicate:`neutral`,failed:`danger`,error:`danger`,"rate-limited":`danger`},kt={launched:`Launched`,manual:`Manual`,"catch-up":`Catch up`,skipped:`Skipped`,missed:`Missed`,"no-match":`No match`,preview:`Preview`,baseline:`Baseline`,duplicate:`Duplicate`,failed:`Failed`,error:`Error`,"rate-limited":`Rate limited`};function At(e){let[t,n]=(0,B.useState)(),[r,i]=(0,B.useState)(``),a=(0,B.useCallback)(t=>g(e,{signal:t}).then(({records:e})=>{t?.aborted||(n(e),i(``))}).catch(e=>{t?.aborted||i(String(e))}),[e]);return(0,B.useEffect)(()=>{a()},[a]),(0,B.useEffect)(()=>d(a),[a]),(0,B.useEffect)(()=>fe((t,n)=>{t===`automation-change`&&n.automationId===e&&a()}),[e,a]),{records:t,error:r,refresh:a}}function jt(e,t){return e.result!==`failed`&&e.result!==`error`||!e.receiptId||e.runId?!1:!t.some(t=>t.receiptId===e.receiptId&&(t.runId||t.seq>e.seq))}function Mt({records:e,all:t,timeZone:n,onRetried:r,readOnly:i=!1}){let a=e=>!i&&jt(e,t),[o,s]=(0,B.useState)(),[c,l]=(0,B.useState)(),u=Date.now(),d=async e=>{s(e),l(void 0);try{await m(e),r()}catch(t){l({receiptId:e,message:t instanceof Error?t.message:String(t)})}finally{s(void 0)}};return(0,W.jsx)(`ol`,{className:`grid gap-3`,"aria-label":`Automation execution log`,children:e.map(e=>(0,W.jsxs)(`li`,{className:`min-w-0 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2`,children:[(0,W.jsx)(Xe,{dot:Ot[e.result],children:kt[e.result]}),(0,W.jsx)(`time`,{className:`text-xs text-muted-foreground`,dateTime:e.ts,title:e.ts,children:lt(e.ts,n,u)})]}),e.reason?(0,W.jsx)(`p`,{className:`mt-2 text-sm break-words text-muted-foreground`,children:e.reason}):null,e.githubUrl||e.runId||a(e)?(0,W.jsxs)(`div`,{className:`mt-3 flex flex-wrap items-center gap-x-4 gap-y-2 text-sm`,children:[e.githubUrl?(0,W.jsx)(`a`,{className:`inline-flex min-h-11 items-center underline underline-offset-4 break-all`,href:e.githubUrl,target:`_blank`,rel:`noreferrer`,children:e.githubTitle??`GitHub #${e.githubNumber??``}`}):null,e.runId?(0,W.jsx)(F,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`}):null,a(e)?(0,W.jsx)(j,{variant:`outline`,disabled:o===e.receiptId,onClick:()=>void d(e.receiptId),children:`Retry task`}):null]}):null,c&&c.receiptId===e.receiptId?(0,W.jsx)(`p`,{role:`alert`,className:`mt-2 text-sm break-words text-destructive`,children:c.message}):null]},e.seq))})}var K=`all`;function Nt({label:e,value:t,onChange:n,options:r}){return(0,W.jsxs)(De,{value:t,onValueChange:n,children:[(0,W.jsx)(N,{"aria-label":e,className:`w-full sm:w-52`,children:(0,W.jsx)(M,{})}),(0,W.jsx)(P,{children:r.map(e=>(0,W.jsx)(Ee,{value:e.value,children:e.label},e.value))})]})}function Pt({automationId:e,automationName:t,timeZone:n,readOnly:r=!1}){let{records:i,error:a,refresh:o}=At(e),[s,c]=(0,B.useState)(K),[l,u]=(0,B.useState)(K),d=(0,B.useMemo)(()=>(i??[]).filter(e=>(s===K||e.result===s)&&(l===K||e.event===l)),[i,s,l]),f=(i??[]).some(e=>e.event);return(0,W.jsx)(Me,{route:`automations`,density:i?je(d.length):`full`,header:{title:`Execution log`,subtitle:t??`Automation activity`,secondaryActions:(0,W.jsx)(I,{variant:`outline`,asChild:!0,children:(0,W.jsx)(F,{to:`/automations`,children:`Back to automations`})})},children:a&&!i?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(G,{text:a}),(0,W.jsx)(j,{variant:`outline`,onClick:()=>void o(),children:`Retry`})]}):i?i.length===0?(0,W.jsx)(G,{text:`Nothing has run yet.`}):(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(Nt,{label:`Result`,value:s,onChange:c,options:[{value:K,label:`All results`},...wt.options.map(e=>({value:e,label:kt[e]}))]}),f?(0,W.jsx)(Nt,{label:`Event`,value:l,onChange:u,options:[{value:K,label:`All events`},...V.options.map(e=>({value:e,label:e}))]}):null]}),d.length===0?(0,W.jsx)(G,{text:`No rows match these filters.`}):(0,W.jsx)(Mt,{records:d,all:i,timeZone:n,onRetried:()=>void o(),readOnly:r})]}):(0,W.jsx)(G,{text:`Loading execution log…`})})}function Ft({automationId:e,automationName:t,timeZone:n,showName:r=!1,readOnly:i=!1}){let{records:a,error:o,refresh:s}=At(e),c=`Recent activity${r&&t?` · ${t}`:``}`;return!o&&a&&a.length===0?(0,W.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`flex flex-wrap items-center gap-x-2 border-t border-border pt-2.5 text-xs text-muted-foreground`,children:[(0,W.jsx)(`h3`,{className:`font-medium text-foreground`,children:c}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,W.jsx)(`p`,{children:`Nothing has run yet.`})]}):(0,W.jsxs)(`section`,{"data-slot":`automation-inline-log`,className:`min-w-0 border-t border-border pt-2.5`,children:[(0,W.jsx)(`h3`,{className:`mb-1.5 text-xs font-medium text-muted-foreground`,children:c}),o&&!a?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,W.jsx)(G,{text:o}),(0,W.jsx)(j,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]}):a?(0,W.jsx)(Mt,{records:a.slice(0,5),all:a,timeZone:n,onRetried:()=>void s(),readOnly:i}):(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Loading activity…`})]})}function It({automation:e,timeZone:t,onDeleted:n}){let r=e.archived,i=e.schedule,a=i?ft(i):null,[o,s]=(0,B.useState)(!1),[c,l]=(0,B.useState)(!1),[u,d]=(0,B.useState)(``),f=(0,B.useRef)(null),p=(0,B.useRef)(null),m=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=m.current===`keep`?p.current:m.current===`delete`?f.current:null;m.current=null,e?.focus()},[o]);let h=async()=>{l(!0);try{await x(e.id),n()}catch(e){d(e instanceof Error?e.message:String(e)),l(!1)}},g=[[`Workflow`,e.task.workflow],[`Runner`,e.task.runner],[`Model`,e.task.model],[`Effort`,e.task.effort]];return(0,W.jsx)(Me,{route:`automations`,density:`sparse`,header:{title:e.name,subtitle:`Archived one-time schedule. It cannot change; delete it when you no longer need the record.`},children:(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-5`,children:[(0,W.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,W.jsxs)(`p`,{className:`text-sm break-words`,children:[(0,W.jsx)(`span`,{children:r.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`}),r.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(F,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${r.runId}`,children:`Open task`})]}):null]}),(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Archived ${z(r.at,t)} (${t}).`}),a&&i?.timeZone?(0,W.jsx)(`p`,{className:`mt-1 text-sm text-muted-foreground`,children:`Was due ${a.date} ${a.time} (${i.timeZone}).`}):null]}),(0,W.jsxs)(`section`,{"aria-labelledby":`archived-inputs`,className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-4`,children:[(0,W.jsx)(`h2`,{id:`archived-inputs`,className:`mb-3 text-[15px] font-medium`,children:`What it ran with`}),(0,W.jsxs)(`dl`,{className:`grid gap-3 text-sm`,children:[(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`dt`,{className:`text-muted-foreground`,children:`Prompt`}),(0,W.jsx)(`dd`,{className:`break-words whitespace-pre-wrap`,children:e.task.prompt})]}),g.filter(([,e])=>e).map(([e,t])=>(0,W.jsxs)(`div`,{className:`grid gap-1`,children:[(0,W.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,W.jsx)(`dd`,{className:`break-words`,children:t})]},e))]})]}),(0,W.jsxs)(`section`,{className:`min-w-0`,children:[(0,W.jsx)(Ft,{automationId:e.id,automationName:e.name,timeZone:t,readOnly:!0}),(0,W.jsx)(j,{variant:`outline`,asChild:!0,className:`mt-3`,children:(0,W.jsx)(F,{to:`/automations/${e.id}/log`,children:`Execution log`})})]}),(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[o?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? Its record and log are removed; the task stays.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(j,{variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:c,onClick:()=>void h(),children:`Delete schedule`}),(0,W.jsx)(j,{ref:p,variant:`outline`,disabled:c,onClick:()=>{m.current=`delete`,s(!1)},children:`Keep`})]})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(j,{ref:f,variant:`outline`,"data-action":`automation-delete`,onClick:()=>{m.current=`keep`,s(!0)},children:`Delete`}),(0,W.jsx)(j,{variant:`outline`,asChild:!0,children:(0,W.jsx)(F,{to:`/automations`,children:`Back to automations`})})]}),u?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:u}):null]})]})})}var Lt=O([`pull_request.opened`,`issue.opened`,`issue.labeled`,`issue.unlabeled`]),q=T(D().trim().min(1).max(200)).max(100).optional(),Rt=S({includeExisting:E().optional(),requireCurrentLabels:E().optional(),authors:q,assignees:q,allLabels:q,anyLabels:q,excludeLabels:q,changedLabels:q,lookbackDays:k().int().min(1).max(90).default(7),maxRecords:k().int().min(1).max(100).default(25)}).passthrough(),zt=S({prompt:D().min(1).max(1e5),workflow:D().trim().min(1).max(200).optional(),steps:T(ie).min(1).max(100).optional(),runner:te.optional(),model:D().trim().min(1).max(200).optional(),effort:D().trim().min(1).max(32).optional(),variants:se([w(1),w(2),w(3)]).optional(),worktree:E().optional(),autonomous:E().optional(),...b,...ae,systemPrompt:D().max(1e5).optional()}).passthrough().refine(e=>!(e.workflow&&e.steps),{message:`task selects either a named workflow or inline steps, not both`}),Bt=new Set(Object.keys(zt.shape).filter(e=>e!==`variants`));function Vt(e){return Object.fromEntries(Object.entries(e).filter(([e])=>Bt.has(e)))}le(e=>{if(!e||typeof e!=`object`||Array.isArray(e))return e;let t=e;return t.kind===`schedule`?e:{...t,intervalSeconds:t.intervalSeconds??300,filters:t.filters??{}}},S({id:D().min(1).max(100),revision:k().int().positive(),name:D().trim().min(1).max(200),description:D().max(2e3).optional(),enabled:E().default(!1),kind:_t.default(`github`),events:T(Lt).min(1).max(4).optional(),intervalSeconds:k().int().min(60).max(86400).optional(),filters:Rt.optional(),schedule:tt.passthrough().optional(),task:zt,archived:S({at:D().datetime(),outcome:O([`launched`,`cancelled`]),runId:D().optional(),receiptId:D().optional(),trigger:O([`schedule`,`late`,`manual`,`retry`]).optional()}).passthrough().optional(),createdAt:D().datetime(),updatedAt:D().datetime()}).passthrough().superRefine((e,t)=>{if(e.kind===`schedule`){e.schedule||t.addIssue({code:_.custom,path:[`schedule`],message:`a scheduled automation needs a schedule`});return}e.events?.length||t.addIssue({code:_.custom,path:[`events`],message:`a GitHub automation needs at least one event`}),e.intervalSeconds===void 0&&t.addIssue({code:_.custom,path:[`intervalSeconds`],message:`a GitHub automation needs a poll interval`}),e.filters||t.addIssue({code:_.custom,path:[`filters`],message:`a GitHub automation needs its bounded filter`}),e.events?.some(e=>e===`issue.labeled`||e===`issue.unlabeled`)&&!e.filters?.changedLabels?.length&&t.addIssue({code:_.custom,path:[`filters`,`changedLabels`],message:`changedLabels is required for issue label events`})})),S({version:w(1).default(1),automations:T(ce()).default([]),tombstones:C(D(),D().datetime()).optional()}).passthrough();var J=S({timestamp:D().datetime(),tieBreaker:D().optional()}).passthrough(),Ht=bt.extend({cursor:J.optional()}),Ut=S({revision:k().int().positive().optional(),baselineAt:D().datetime().optional(),armedAt:D().datetime().optional(),historyScan:Ht.optional(),cursor:J.optional(),frozenHighWatermark:J.extend({tieBreaker:D()}).optional(),backlogAfter:J.extend({tieBreaker:D()}).optional(),nextCheckAt:D().datetime().optional(),lastSuccessAt:D().datetime().optional(),nextRunAt:D().datetime().optional(),lastRunAt:D().datetime().optional(),etags:C(D(),D()).optional(),backoffUntil:D().datetime().optional(),consecutiveFailures:k().int().nonnegative().optional(),...xt,onceOutcome:O([`failed`,`missed`]).optional()}).passthrough();S({version:w(1).default(1),states:C(D(),Ut).default({})}).passthrough(),S({receiptId:D().min(1),receiptKey:D().min(1),eventId:D().min(1),automationId:D().min(1),revision:k().int().positive(),status:O([`reserved`,`launched`,`launch-error`,`released`]),runId:D().optional(),observedAt:D().datetime(),updatedAt:D().datetime(),error:D().max(2e3).optional(),occurrenceAt:D().datetime().optional(),candidate:S({eventId:D(),event:Lt,timestamp:D().datetime(),tieBreaker:D(),repo:D(),nodeId:D(),number:k().int().positive(),title:D().max(500),url:D().url(),author:D().max(200),assignees:T(D().max(200)).max(100),labels:T(D().max(200)).max(100),changedLabel:D().max(200).optional()}).passthrough().optional()}).passthrough();var Wt=O([`launched`,`no-match`,`duplicate`,`rate-limited`,`error`,`baseline`,`preview`,`skipped`,`manual`,`catch-up`,`failed`,`missed`]);S({seq:k().int().positive(),ts:D().datetime(),automationId:D().min(1),revision:k().int().positive(),event:Lt.optional(),result:Wt,reason:D().max(2e3).optional(),durationMs:k().int().nonnegative().optional(),receiptId:D().optional(),runId:D().optional(),githubNumber:k().int().positive().optional(),githubTitle:D().max(500).optional(),githubUrl:D().url().optional(),rateLimit:S({bucket:O([`core`,`search`]),remaining:k().int().nonnegative().optional(),resetAt:D().datetime().optional()}).passthrough().optional()}).passthrough();var Gt=`quick-task`;function Kt(e={}){let{prompt:t,workflow:n,runner:r,model:i,autonomous:a,archiveWhenDone:o,autoMergePr:s,allowWorkers:c,allowMessaging:l,...u}=Vt(e.task??{prompt:``}),d=e.task===void 0;return{name:e.name??``,description:e.description??``,kind:e.kind??`schedule`,schedule:mt(e.schedule??{type:`daily`}),events:e.events??[V.options[0]],intervalSeconds:e.intervalSeconds??300,filters:e.filters??{lookbackDays:7,maxRecords:25},prompt:t,...n===void 0?d?{workflow:Gt}:{}:{workflow:n},...r===void 0?{}:{runner:r},...i===void 0?{}:{model:i},autonomous:a??!0,archiveWhenDone:o??!1,autoMergePr:s??!1,allowWorkers:c!==!1,allowMessaging:l!==!1,enabled:e.enabled??e.enable??!1,taskExtra:u}}function qt(e){switch(e.type){case`daily`:case`weekdays`:return{type:e.type,hour:e.hour,minute:e.minute};case`weekly`:return{type:`weekly`,hour:e.hour,minute:e.minute,day:e.day};case`hours`:return{type:`hours`,every:e.every};case`once`:return{type:`once`,at:e.at??``,timeZone:e.timeZone??``,...e.latestStartMinutes===void 0?{}:{latestStartMinutes:e.latestStartMinutes}}}}function Jt(e){return{...e.taskExtra,prompt:e.prompt,...e.workflow?{workflow:e.workflow}:{},...e.runner?{runner:e.runner}:{},...e.model?{model:e.model}:{},autonomous:e.autonomous,...e.archiveWhenDone?{archiveWhenDone:!0}:{},...e.autoMergePr?{autoMergePr:!0}:{},...e.allowWorkers?{}:{allowWorkers:!1},...e.allowMessaging?{}:{allowMessaging:!1}}}function Yt(e){return{name:e.name.trim(),...e.description.trim()?{description:e.description.trim()}:{},kind:e.kind,...e.kind===`schedule`?{schedule:qt(e.schedule)}:{events:e.events,intervalSeconds:e.intervalSeconds,filters:e.filters},task:Jt(e)}}function Xt(e){return{...Yt(e),enable:e.enabled}}function Zt(e,t){return{...Yt(e),task:{...Jt(e),archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging},enabled:e.enabled,expectedRevision:t}}function Y(e){return`'${e.replace(/'/g,`'\\''`)}'`}var Qt=new Set([`prompt`,`workflow`,`runner`,`model`,`autonomous`,`worktree`,`archiveWhenDone`,`autoMergePr`,`allowWorkers`,`allowMessaging`]),$t=new Set([`anyLabels`,`authors`,`changedLabels`]);function en(e){if(e.description!==void 0||!e.name.trim()||!e.task.prompt.trim())return!1;let t=e.task;if(Object.keys(t).some(e=>!Qt.has(e))||t.archiveWhenDone===!1||t.autoMergePr===!1||t.allowWorkers===!0||t.allowMessaging===!0||t.worktree!==!0)return!1;if(e.kind===`schedule`)return e.schedule!==void 0;let{events:n,filters:r}=e;return!n?.length||n.some(e=>e.includes(`,`))||!r||r.lookbackDays!==7||r.maxRecords!==25?!1:Object.entries(r).every(([e,t])=>e===`lookbackDays`||e===`maxRecords`||e===`includeExisting`&&t===!0||$t.has(e)&&Array.isArray(t)&&t.length>0)}function tn(e){return e%3600==0?`${e/3600}h`:e%60==0?`${e/60}m`:`${e}s`}function nn(e){return e%1440==0?`${e/1440}d`:e%60==0?`${e/60}h`:`${e}m`}function X(e,t){return t.startsWith(`-`)?`--${e}=${Y(t)}`:`--${e} ${Y(t)}`}function rn(e){let t=[`${ze()} automation add`,X(`name`,e.name)];if(e.schedule?.type===`once`)t.push(X(`at`,e.schedule.at),X(`tz`,e.schedule.timeZone)),e.schedule.latestStartMinutes!==void 0&&t.push(X(`latest-start`,nn(e.schedule.latestStartMinutes)));else if(e.kind===`schedule`)t.push(X(`cron`,st(e.schedule)));else{t.push(X(`on`,e.events.join(`,`)),`--every ${tn(e.intervalSeconds??300)}`),e.filters?.includeExisting&&t.push(`--include-existing`);for(let n of e.filters?.anyLabels??[])t.push(X(`label`,n));for(let n of e.filters?.authors??[])t.push(X(`author`,n));for(let n of e.filters?.changedLabels??[])t.push(X(`changed-label`,n))}return t.push(...an(e.task)),e.enable===!0&&t.push(`--enable`),t.push(X(`prompt`,e.task.prompt)),t.join(` `)}function an(e){let t=[];return e.workflow&&t.push(X(`workflow`,e.workflow)),e.runner&&t.push(X(`runner`,e.runner)),e.model&&t.push(X(`model`,e.model)),e.autonomous===!1&&t.push(`--no-autonomous`),e.archiveWhenDone&&t.push(`--archive-when-done`),e.autoMergePr&&t.push(`--auto-merge-pr`),e.allowWorkers===!1&&t.push(`--no-workers`),e.allowMessaging===!1&&t.push(`--no-messaging`),t}function on(e,t){let n=Xt(e),r=en(n)?rn(n):`${ze()} automation create --json ${Y(JSON.stringify(n))}`;return t?`CEZ_COCKPIT_URL=${Y(t.origin)} CEZ_PROJECT_ID=${Y(t.projectId)} HSQ_COCKPIT_URL=${Y(t.origin)} HSQ_PROJECT_ID=${Y(t.projectId)} ${r}`:r}function sn(e){let t=[],n=!1;for(let r of cn(e)){let e=t.length-1;!n&&/^[A-Z_][A-Z0-9_]*=/.test(r)?t.push(r):r.startsWith(`--`)||!n?(t.push(r),n=!0):t[e]=`${t[e]} ${r}`}return t.map((e,t)=>t===0?e:` ${e}`).join(` \\
2
+ `)}function cn(e){let t=[],n=``,r=!1;for(let i=0;i<e.length;i+=1){let a=e[i];!r&&a===`\\`&&i+1<e.length?(n+=a+e[i+1],i+=1):a===`'`?(r=!r,n+=a):a===` `&&!r?(n&&t.push(n),n=``):n+=a}return n&&t.push(n),t}function ln({draft:e,saveLabel:t,editing:n}){let i=Ae(),a=window.location.origin,o=(0,B.useMemo)(()=>{let t=on(e);return i?`HSQ_COCKPIT_URL=${Y(a)} HSQ_PROJECT_ID=${Y(i)} ${t}`:t},[e,a,i]),s=(0,B.useMemo)(()=>sn(o),[o]),[c,l]=(0,B.useState)(`idle`),[u,d]=(0,B.useState)(!1),f=(0,B.useId)(),p=(0,B.useRef)(void 0);(0,B.useEffect)(()=>()=>clearTimeout(p.current),[]),(0,B.useEffect)(()=>l(`idle`),[o]);let m=async()=>{clearTimeout(p.current);try{await navigator.clipboard.writeText(s),l(`copied`),p.current=setTimeout(()=>l(`idle`),1600)}catch{l(`failed`)}};return(0,W.jsxs)(`section`,{"aria-labelledby":`copy-as-cli-heading`,"data-slot":`copy-as-cli`,className:`min-w-0 max-w-full overflow-hidden rounded-xl border border-card-edge bg-card shadow-card px-4 py-3.5`,children:[(0,W.jsxs)(`div`,{className:`flex min-h-8 min-w-0 flex-nowrap items-center justify-between gap-x-2`,children:[(0,W.jsx)(`h2`,{id:`copy-as-cli-heading`,className:`shrink-0 text-[13px] font-medium text-muted-foreground`,children:`Copy as CLI`}),(0,W.jsxs)(j,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`copy-as-cli-toggle`,"aria-expanded":u,"aria-controls":f,"aria-label":u?`Hide command`:`Show command`,className:`min-w-0 shrink gap-1 px-1.5 text-[12px] font-medium`,onClick:()=>d(e=>!e),children:[(0,W.jsx)(`span`,{className:`truncate`,children:u?`Hide`:`Show`}),(0,W.jsx)(xe,{"aria-hidden":`true`,className:r(`size-3.5 transition-transform`,u&&`rotate-180`)})]}),(0,W.jsxs)(j,{type:`button`,variant:`outline`,size:`sm`,className:`ms-auto gap-1.5 px-2 text-[12px] font-medium`,onClick:()=>void m(),children:[c===`copied`?(0,W.jsx)(Se,{"aria-hidden":`true`,className:`size-3.5`}):(0,W.jsx)(Ge,{"aria-hidden":`true`,className:`size-3.5`}),c===`copied`?`Copied`:`Copy`]})]}),(0,W.jsx)(`div`,{id:f,hidden:!u,className:`mbs-2 max-w-full rounded-lg border border-border bg-muted has-[:focus-visible]:outline-2 has-[:focus-visible]:outline-ring`,children:(0,W.jsx)(`pre`,{"data-slot":`copy-as-cli-line`,tabIndex:0,"aria-label":`Command line`,className:`m-0 max-w-full px-3 pt-2.5 pb-3 font-mono text-xs leading-5 break-all whitespace-pre-wrap text-muted-foreground outline-none`,children:s})}),(0,W.jsx)(`p`,{role:`status`,className:`mbs-2 text-xs break-words text-muted-foreground`,children:c===`failed`?`Could not copy — select the line and copy it by hand.`:(0,W.jsxs)(W.Fragment,{children:[`The definition ${t} would ${n?`save`:`create`}.`,` `,(0,W.jsx)(`code`,{className:`rounded-sm bg-muted px-1 py-px font-mono text-xs whitespace-nowrap text-foreground [word-spacing:-0.2em]`,children:`${ze()} automation schema`}),` prints its shape.`]})})]})}function un({pressed:e,onClick:t,disabled:n,children:i}){return(0,W.jsx)(`button`,{type:`button`,"aria-pressed":e,disabled:n,onClick:t,className:r(`inline-flex min-h-11 items-center justify-center rounded-md border px-3.5 text-[13px] font-medium transition-colors outline-hidden focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50`,e?`border-border bg-card font-semibold text-foreground shadow-xs`:`border-transparent bg-transparent text-muted-foreground hover:text-foreground`),children:i})}var dn={"pull_request.opened":`a pull request opens`,"issue.opened":`an issue opens`,"issue.labeled":`an issue is labeled`,"issue.unlabeled":`an issue is unlabeled`},fn={"pull_request.opened":`Pull request opened`,"issue.opened":`Issue opened`,"issue.labeled":`Issue labeled`,"issue.unlabeled":`Issue unlabeled`};function pn(e){let t=e.map(e=>dn[e]);if(t.length===0)return`When GitHub changes`;let n=t.slice(0,-1),r=t[t.length-1];return`When ${n.length>0?`${n.join(`, `)} or ${r}`:r}`}var mn=V.options,hn=[{seconds:60,label:`1 minute`},{seconds:300,label:`5 minutes`},{seconds:900,label:`15 minutes`},{seconds:1800,label:`30 minutes`},{seconds:3600,label:`1 hour`}],gn=[{key:`authors`,label:`Authors`},{key:`assignees`,label:`Assignees`},{key:`allLabels`,label:`Has all labels`},{key:`anyLabels`,label:`Has any label`},{key:`excludeLabels`,label:`Excludes labels`},{key:`changedLabels`,label:`Changed labels`,hint:`Required for the two label events.`}],_n=e=>(e??[]).join(`, `),vn=e=>e.split(`,`).map(e=>e.trim()).filter(Boolean);function yn(e){return e?`Existing matches within the lookback are eligible on the next check. Previously processed matches will not run again.`:`Enabling starts from a current-time baseline. Existing matches will not launch tasks.`}function bn(e){let t=Math.max(1,Math.round(e.intervalSeconds/60));return`Polls GitHub every ${t} minute${t===1?``:`s`} for ${e.events.join(`, `)||`no events`}. ${yn(e.filters.includeExisting)}`}function xn({draft:e,onChange:t,disabledReason:n}){let r=n=>{t({events:e.events.includes(n)?e.events.filter(e=>e!==n):[...e.events,n]})},i=n=>t({filters:{...e.filters,...n}}),a=(n,r)=>{let i=vn(r),{[n]:a,...o}=e.filters;t({filters:i.length?{...o,[n]:i}:o})},o=hn.some(t=>t.seconds===e.intervalSeconds)?hn:[...hn,{seconds:e.intervalSeconds,label:`${Math.round(e.intervalSeconds/60)} minutes`}].sort((e,t)=>e.seconds-t.seconds);return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[n?(0,W.jsx)(`p`,{className:`text-xs text-pending-strong`,children:`GitHub unavailable · ${n}`}):null,(0,W.jsx)(`div`,{role:`group`,"aria-label":`GitHub events`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:mn.map(t=>(0,W.jsx)(un,{pressed:e.events.includes(t),onClick:()=>r(t),children:fn[t]},t))}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-interval`,children:`Check every`}),(0,W.jsxs)(De,{value:String(e.intervalSeconds),onValueChange:e=>t({intervalSeconds:Number(e)}),children:[(0,W.jsx)(N,{id:`automation-interval`,className:`w-full sm:w-48`,"aria-label":`Check every`,children:(0,W.jsx)(M,{})}),(0,W.jsx)(P,{children:o.map(e=>(0,W.jsx)(Ee,{value:String(e.seconds),children:e.label},e.seconds))})]})]}),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsxs)(`label`,{className:`flex min-h-11 items-center gap-3 text-sm`,children:[(0,W.jsx)(Oe,{"aria-label":`Include existing items`,"aria-describedby":`automation-history-hint`,checked:e.filters.includeExisting??!1,onCheckedChange:e=>i({includeExisting:e})}),(0,W.jsx)(`span`,{children:`Include existing items`})]}),(0,W.jsx)(`p`,{id:`automation-history-hint`,className:`text-xs text-muted-foreground`,children:yn(e.filters.includeExisting)})]}),(0,W.jsxs)(Te,{children:[(0,W.jsxs)(we,{className:`group flex min-h-11 items-center gap-2 text-sm font-medium`,children:[`Filters`,(0,W.jsx)(xe,{"aria-hidden":`true`,className:`size-4 text-soft-foreground transition-transform motion-reduce:transition-none group-data-[state=open]:rotate-180`})]}),(0,W.jsx)(Ce,{children:(0,W.jsxs)(`div`,{className:`grid gap-4 pt-2 sm:grid-cols-2`,children:[gn.map(t=>(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-filter-${t.key}`,children:t.label}),(0,W.jsx)(R,{id:`automation-filter-${t.key}`,className:`border-border`,placeholder:`comma separated`,value:_n(e.filters[t.key]),onChange:e=>a(t.key,e.target.value)}),t.hint?(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t.hint}):null]},t.key)),(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-filter-lookback`,children:`Look back (days)`}),(0,W.jsx)(R,{id:`automation-filter-lookback`,className:`border-border`,type:`number`,min:1,value:e.filters.lookbackDays,onChange:e=>i({lookbackDays:Math.max(1,Number(e.target.value)||1)})})]}),(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-filter-max`,children:`Max records per check`}),(0,W.jsx)(R,{id:`automation-filter-max`,className:`border-border`,type:`number`,min:1,value:e.filters.maxRecords,onChange:e=>i({maxRecords:Math.max(1,Number(e.target.value)||1)})})]})]})})]})]})}var Sn=e=>String(e).padStart(2,`0`);function Z({label:e,value:t,max:n,onCommit:r}){let[i,a]=(0,B.useState)(Sn(t)),o=(0,B.useRef)(null),s=!(/^\d{1,2}$/.test(i)&&Number(i)===t),c=`${e} must be 00–${Sn(n)}.`,l=(0,B.useId)();return(0,B.useEffect)(()=>{o.current?.setCustomValidity(s?c:``)},[s,c]),(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(R,{ref:o,"aria-label":e,"aria-invalid":s||void 0,"aria-describedby":s?l:void 0,inputMode:`numeric`,maxLength:2,className:`w-20 border-border text-center tabular-nums`,value:i,onChange:e=>{a(e.target.value),/^\d{1,2}$/.test(e.target.value)&&Number(e.target.value)<=n&&r(Number(e.target.value))},onBlur:()=>a(Sn(t))}),s?(0,W.jsx)(`p`,{id:l,className:`order-last basis-full text-xs text-destructive`,children:c}):null]})}var Cn=[{minutes:void 0,label:`No limit`},{minutes:30,label:`30 minutes`},{minutes:120,label:`2 hours`},{minutes:360,label:`6 hours`},{minutes:1440,label:`1 day`},{minutes:10080,label:`7 days`}],wn=`none`,Tn=e=>String(e).padStart(2,`0`);function En(e,t=Date.now()){let n=ht(t,e)??ht(t,`UTC`),r=new Date(Date.UTC(n.year,n.month-1,n.day+1));return`${r.getUTCFullYear()}-${Tn(r.getUTCMonth()+1)}-${Tn(r.getUTCDate())}T09:00`}function Dn(){let e=typeof Intl.supportedValuesOf==`function`?Intl.supportedValuesOf(`timeZone`):[];return e.includes(`UTC`)?e:[`UTC`,...e]}function On({value:e,stored:t,onChange:n}){let r=t=>n({...e,...t}),i=e.at?ct(e.at):null,a=e.at?.slice(0,10)??``,o=i?.hour??9,s=i?.minute??0,c=(e,t,n)=>r({at:`${e}T${Tn(t)}:${Tn(n)}`}),l=(0,B.useRef)(null),u=(0,B.useId)(),d=rt(e),f=!(t?.type===`once`&&t.at===e.at&&t.timeZone===e.timeZone)&&d!==null&&d<=Date.now();(0,B.useEffect)(()=>{l.current?.setCustomValidity(f?et:``)},[f]);let p=ft(e);return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsxs)(`div`,{className:`flex flex-wrap items-end gap-x-4 gap-y-3`,children:[(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-once-date`,children:`Date`}),(0,W.jsx)(R,{ref:l,id:`automation-once-date`,type:`date`,className:`w-44 max-w-full border-border`,value:a,"aria-invalid":f||void 0,"aria-describedby":f?u:void 0,onChange:e=>{/^\d{4}-\d{2}-\d{2}$/.test(e.target.value)&&c(e.target.value,o,s)},required:!0})]}),(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,W.jsx)(Z,{label:`Hour`,value:o,max:23,onCommit:e=>c(a,e,s)}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,W.jsx)(Z,{label:`Minute`,value:s,max:59,onCommit:e=>c(a,o,e)})]})]}),f?(0,W.jsx)(`p`,{id:u,className:`text-xs text-destructive`,children:et}):null,(0,W.jsx)(An,{value:e.timeZone??``,onCommit:e=>r({timeZone:e})}),(0,W.jsx)(jn,{value:e.latestStartMinutes,onChange:t=>n(kn(e,t))}),p?(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Runs once at ${p.time} on ${p.date} (${e.timeZone}). ${p.note?`${p.note} `:``}Squawk must be running then.`}):null]})}function kn(e,t){let{latestStartMinutes:n,...r}=e;return t===void 0?r:{...r,latestStartMinutes:t}}function An({value:e,onCommit:t}){let[n,r]=(0,B.useState)(e),i=(0,B.useRef)(null),a=(0,B.useId)(),o=(0,B.useId)(),[s]=(0,B.useState)(Dn),c=n!==e||!$e(n),l=it(n);return(0,B.useEffect)(()=>{i.current?.setCustomValidity(c?l:``)},[c,l]),(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-once-zone`,children:`Time zone`}),(0,W.jsx)(R,{ref:i,id:`automation-once-zone`,list:a,autoComplete:`off`,spellCheck:!1,className:`w-full border-border sm:w-72`,value:n,"aria-invalid":c||void 0,"aria-describedby":c?o:void 0,onChange:e=>{r(e.target.value),$e(e.target.value)&&t(e.target.value)}}),(0,W.jsx)(`datalist`,{id:a,children:s.map(e=>(0,W.jsx)(`option`,{value:e},e))}),c?(0,W.jsx)(`p`,{id:o,className:`text-xs break-words text-destructive`,children:l}):null]})}function jn({value:e,onChange:t}){let n=Cn.some(t=>t.minutes===e)||e===void 0?Cn:[...Cn,{minutes:e,label:`${e} minutes`}];return(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-once-latest`,children:`Latest start`}),(0,W.jsxs)(De,{value:e===void 0?wn:String(e),onValueChange:e=>t(e===wn?void 0:Number(e)),children:[(0,W.jsx)(N,{id:`automation-once-latest`,className:`w-full sm:w-48`,"aria-label":`Latest start`,children:(0,W.jsx)(M,{})}),(0,W.jsx)(P,{children:n.map(e=>(0,W.jsx)(Ee,{value:e.minutes===void 0?wn:String(e.minutes),children:e.label},e.label))})]}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`If Squawk was not running at the time, it still starts the task this long afterwards; later, the schedule is marked missed.`})]})}var Mn=[{type:`daily`,label:`Every day`},{type:`weekdays`,label:`Weekdays`},{type:`weekly`,label:`Weekly`},{type:`hours`,label:`Every N hours`},{type:`once`,label:`Once`}];function Nn({value:e,stored:t,onChange:n,timeZone:r}){let i=t=>n({...e,...t}),a=t=>i(t===`once`?{type:t,at:e.at??En(r),timeZone:e.timeZone??r}:{type:t});return(0,W.jsxs)(`div`,{className:`grid gap-4`,children:[(0,W.jsx)(`div`,{role:`group`,"aria-label":`Repeat`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:Mn.map(t=>(0,W.jsx)(un,{pressed:e.type===t.type,onClick:()=>a(t.type),children:t.label},t.type))}),e.type===`once`?(0,W.jsx)(On,{value:e,stored:t,onChange:n}):null,e.type===`weekly`?(0,W.jsx)(`div`,{role:`group`,"aria-label":`Day of the week`,className:`inline-flex w-fit max-w-full flex-wrap gap-1 rounded-lg border border-border bg-muted/60 p-1`,children:pt.map((t,n)=>(0,W.jsx)(un,{pressed:e.day===n+1,onClick:()=>i({day:n+1}),children:t},t))}):null,e.type===`once`?null:e.type===`hours`?(0,W.jsxs)(`div`,{className:`grid gap-2`,children:[(0,W.jsx)(A,{htmlFor:`automation-every`,children:`Run every`}),(0,W.jsxs)(De,{value:String(e.every),onValueChange:e=>i({every:Number(e)}),children:[(0,W.jsx)(N,{id:`automation-every`,className:`w-full sm:w-48`,"aria-label":`Run every`,children:(0,W.jsx)(M,{})}),(0,W.jsx)(P,{children:ut.map(e=>(0,W.jsx)(Ee,{value:String(e),children:e===1?`hour`:`${e} hours`},e))})]}),(0,W.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:`Counted from midnight, so “every 6 hours” runs at 00:00, 06:00, 12:00 and 18:00.`})]}):(0,W.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(`span`,{className:`text-sm text-muted-foreground`,children:`at`}),(0,W.jsx)(Z,{label:`Hour`,value:e.hour,max:23,onCommit:e=>i({hour:e})}),(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`:`}),(0,W.jsx)(Z,{label:`Minute`,value:e.minute,max:59,onCommit:e=>i({minute:e})}),(0,W.jsx)(`span`,{className:`text-sm break-all text-muted-foreground`,children:r})]}),e.type===`once`?null:(0,W.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[`Cron: `,(0,W.jsx)(`code`,{className:`font-mono text-foreground`,children:st(e)})]})]})}var Pn=40*864e5,Fn=5;function In({schedule:e,timeZone:t,now:n=Date.now()}){if(e.type===`once`)return(0,W.jsx)(Ln,{schedule:e,now:n});let r=nt(e,n+1,n+Pn,t,Fn);return(0,W.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,W.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-2 text-base font-semibold`,children:`Next 5 runs`}),r.length===0?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`No runs in the next 40 days.`}):(0,W.jsx)(`ol`,{"aria-label":`Next 5 runs`,className:`grid divide-y divide-border text-sm`,children:r.map((e,r)=>(0,W.jsxs)(`li`,{className:`flex min-h-10 items-center justify-between gap-3 py-1.5`,children:[(0,W.jsx)(`span`,{className:r===0?`font-semibold tabular-nums text-foreground`:`font-medium tabular-nums`,children:z(new Date(e).toISOString(),t)}),(0,W.jsx)(`span`,{className:r===0?`font-medium text-accent-text`:`text-muted-foreground`,children:ot(n,e)})]},e))}),(0,W.jsxs)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:[`Times are in `,t,`, the zone this Squawk runs in.`]})]})}function Ln({schedule:e,now:t}){let n=rt(e),r=ft(e);return(0,W.jsxs)(`section`,{"aria-labelledby":`next-runs-heading`,"data-slot":`next-runs`,className:`min-w-0 rounded-xl border bg-card p-5`,children:[(0,W.jsx)(`h2`,{id:`next-runs-heading`,className:`mb-3 text-base font-semibold`,children:`Runs once`}),n===null||!r?(0,W.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`Pick a date, a time and a time zone.`}):(0,W.jsxs)(`p`,{className:`flex flex-wrap items-baseline justify-between gap-x-3 text-sm`,children:[(0,W.jsx)(`span`,{className:`font-medium tabular-nums`,children:`${r.date} ${r.time}`}),n>t?(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:ot(t,n)}):null]}),r?.note?(0,W.jsx)(`p`,{className:`mt-2 text-sm break-words`,children:r.note}):null,n!==null&&n<=t?(0,W.jsx)(`p`,{className:`mt-2 text-sm text-destructive`,children:`The due time has passed.`}):null,(0,W.jsx)(`p`,{className:`mt-3 text-xs break-words text-muted-foreground`,children:`Times are in ${e.timeZone??`UTC`}. Squawk must be running then; afterwards the schedule is archived with its task.`})]})}var Rn={schedule:`On a schedule`,github:`When GitHub changes`};function zn(e){return/time zone|due time/i.test(e)?`when`:/autonomous/i.test(e)?`execution`:/placeholder|prompt|workflow|runner|model|task/i.test(e)?`run`:/\bname\b/i.test(e)?`name`:/schedule|github|event|filter|label|interval|remote|forge|lookback|records?|hour|minute|poll|kind|archived/i.test(e)?`when`:`form`}function Q({title:e,icon:t,hideLegend:n=!1,failure:r,section:i,children:a}){let o=(0,B.useId)();return(0,W.jsxs)(`section`,{role:n?void 0:`group`,"aria-labelledby":n?void 0:o,className:`grid min-w-0 gap-3.5 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[n?null:t?(0,W.jsxs)(`h2`,{id:o,className:`flex items-center gap-2 text-base font-semibold text-foreground`,children:[t,e]}):(0,W.jsx)(`h2`,{id:o,className:`text-sm font-semibold text-foreground`,children:e}),a,r?.section===i&&!r.conflict?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:r.message}):null]})}function Bn({draft:e,patch:t,forge:n,automation:r}){return(0,W.jsx)(W.Fragment,{children:r?(0,W.jsxs)(`p`,{className:`text-sm`,children:[(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:`Trigger · `}),Rn[e.kind]]}):(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,W.jsx)(Ze,{slot:`automation-kind`,label:`Trigger`,size:`touch`,value:e.kind,onChange:e=>t({kind:e}),options:[{value:`schedule`,label:Rn.schedule},{value:`github`,label:Rn.github,disabled:!n.available,...n.available?{}:{title:n.reason??`GitHub is unavailable`}}]}),n.available?null:(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`GitHub unavailable · ${n.reason??`no GitHub access`}`})]})})}function Vn({draft:e,patch:t,forge:n,timeZone:r,automation:i}){return e.kind===`schedule`?(0,W.jsx)(Nn,{value:e.schedule,stored:i?.schedule,onChange:e=>t({schedule:e}),timeZone:r}):(0,W.jsx)(xn,{draft:e,onChange:t,...n.available?{}:{disabledReason:n.reason??`no GitHub access`}})}function Hn({draft:e,patch:t}){let n=e.kind===`schedule`?[`date`,`time`,`project`,`automation`]:[`github.kind`,`github.number`,`github.title`,`github.url`,`github.author`,`github.assignees`,`github.labels`,`github.event`],r=[...new Set([...e.prompt.matchAll(/\{\{([^{}]+)\}\}/g)].map(e=>e[1]))].filter(e=>!n.includes(e));return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,W.jsx)(A,{htmlFor:`automation-prompt`,children:`Prompt`}),(0,W.jsx)(Qe,{id:`automation-prompt`,value:e.prompt,onChange:e=>t({prompt:e.target.value}),rows:3,className:`[field-sizing:fixed] min-h-[88px] resize-none border-border bg-background`,required:!0}),(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:e.kind===`schedule`?(0,W.jsxs)(W.Fragment,{children:[`Available: `,`{{date}}`,` `,`{{time}}`,` `,`{{project}}`,` `,`{{automation}}`,`. A run-context block is appended automatically.`]}):(0,W.jsxs)(W.Fragment,{children:[`Available: `,`{{github.number}}`,` `,`{{github.title}}`,` `,`{{github.url}}`,` `,`{{github.labels}}`,`. GitHub content is appended as untrusted context.`]})})]}),r.length?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:`Unavailable for this trigger: ${r.map(e=>`{{${e}}}`).join(`, `)}`}):null,(0,W.jsx)(Xn,{draft:e,patch:t})]})}function Un({label:e,help:t,checked:n,onChange:r}){let i=(0,B.useId)();return(0,W.jsxs)(`label`,{htmlFor:i,className:`completion-control flex min-h-11 min-w-0 items-center justify-between gap-3 rounded-md text-sm`,children:[(0,W.jsxs)(`span`,{className:`min-w-0 break-words`,children:[(0,W.jsx)(`span`,{id:`${i}-label`,children:e}),(0,W.jsx)(`span`,{id:`${i}-help`,className:`completion-control-help`,children:t})]}),(0,W.jsx)(Oe,{id:i,className:`completion-switch shrink-0`,checked:n,"aria-labelledby":`${i}-label`,"aria-describedby":`${i}-help`,onCheckedChange:r})]})}function Wn({draft:e,patch:t,saving:n,automation:r}){let i=e.kind===`schedule`,a=r?`Enabled`:`Enable after saving`,o=i&&e.schedule.type===`once`?`It runs once at the time set under When, then moves to Archived with its task.`:i?`The first run is the next occurrence in Next 5 runs.`:yn(e.filters.includeExisting);return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`Each run is an ordinary task in its own worktree, queued behind the parallel cap.`}),(0,W.jsxs)(`div`,{"data-embedded":``,className:`grid min-w-0`,children:[(0,W.jsx)(Un,{label:`Autonomous`,help:`Runs without waiting for answers.`,checked:e.autonomous,onChange:e=>t({autonomous:e})}),(0,W.jsx)(Ve,{embedded:!0,archiveWhenDone:e.archiveWhenDone,autoMergePr:e.autoMergePr,onChange:t,disabled:n}),(0,W.jsx)(Be,{embedded:!0,allowWorkers:e.allowWorkers,allowMessaging:e.allowMessaging,onChange:t,disabled:n}),(0,W.jsx)(Un,{label:a,help:o,checked:e.enabled,onChange:e=>t({enabled:e})})]}),r?(0,W.jsx)(`p`,{className:`text-xs break-words text-muted-foreground`,children:`These settings apply to future tasks. Existing tasks keep their settings.`}):null]})}function Gn({automation:e,forge:t,timeZone:n,onSaved:r,onReload:i}){let[a,o]=(0,B.useState)(()=>Kt(e)),[s,c]=(0,B.useState)(e?.revision),[l,u]=(0,B.useState)(),[d,m]=(0,B.useState)(!1),g=e=>o(t=>({...t,...e})),_=async t=>{if(t.preventDefault(),d)return;let n=t.currentTarget;if(n instanceof HTMLFormElement&&!n.checkValidity()){n.reportValidity();return}m(!0),u(void 0);let i=`save`;try{if(e&&s!==void 0){let{automation:t}=await h(e.id,Zt({...a,enabled:e.enabled},s));c(t.revision),a.enabled!==e.enabled&&(i=`enable`,await p(e.id,a.enabled))}else await y(Xt(a));r()}catch(t){let n=t instanceof Error?t.message:String(t);i===`save`&&e&&t instanceof f&&t.status===409&&/revision conflict/i.test(n)?u({section:`form`,message:`Edited elsewhere — reload to see the latest version`,conflict:!0}):u({section:i===`enable`?`execution`:zn(n),message:n})}finally{m(!1)}},v=(0,B.useId)(),b=(0,B.useId)(),x=a.kind===`schedule`;return(0,W.jsx)(Pe,{route:`automations`,density:a.name.trim()===``&&a.prompt.trim()===``?`sparse`:`full`,header:Yn({automation:e,draft:a,formId:v,saveHintId:b,saving:d}),children:(0,W.jsxs)(`form`,{id:v,className:`automation-editor grid min-w-0 gap-4 md:grid-cols-[minmax(0,1fr)_320px] md:grid-rows-[auto_1fr] md:items-start`,onSubmit:_,children:[(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-3.5`,children:[(0,W.jsx)(Q,{title:`Name`,hideLegend:!0,section:`name`,failure:l,children:(0,W.jsxs)(`div`,{className:`grid gap-1.5`,children:[(0,W.jsx)(A,{htmlFor:`automation-name`,className:`text-sm font-semibold text-foreground`,children:`Name`}),(0,W.jsx)(R,{id:`automation-name`,className:`border-border`,value:a.name,placeholder:`Daily dependency audit`,onChange:e=>g({name:e.target.value}),required:!0})]})}),(0,W.jsxs)(Q,{title:`When`,section:`when`,failure:l,children:[(0,W.jsx)(Bn,{draft:a,patch:g,forge:t,automation:e}),(0,W.jsx)(Vn,{draft:a,patch:g,forge:t,timeZone:n,automation:e})]}),(0,W.jsx)(Q,{title:`What to run`,section:`run`,failure:l,children:(0,W.jsx)(Hn,{draft:a,patch:g})})]}),(0,W.jsxs)(`aside`,{className:`grid min-w-0 max-w-full grid-cols-[minmax(0,1fr)] gap-4 md:sticky md:top-4 md:col-start-2 md:row-span-2 md:row-start-1`,children:[(0,W.jsx)(Q,{title:`Execution settings`,icon:(0,W.jsx)(ye,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`}),section:`execution`,failure:l,children:(0,W.jsx)(Wn,{draft:a,patch:g,saving:d,automation:e})}),x?(0,W.jsx)(In,{schedule:a.schedule,timeZone:n}):(0,W.jsxs)(`section`,{className:`min-w-0 rounded-xl border border-card-edge bg-card shadow-card p-5`,children:[(0,W.jsx)(`h2`,{className:`mb-2 text-base font-semibold`,children:`How it polls`}),(0,W.jsx)(`p`,{className:`text-sm break-words text-muted-foreground`,children:bn(a)})]}),(0,W.jsx)(ln,{draft:a,saveLabel:qn(e,a),editing:e!==void 0})]}),l?.section===`form`||e?(0,W.jsxs)(`div`,{className:`grid min-w-0 gap-3.5 md:col-start-1`,children:[l?.section===`form`?(0,W.jsxs)(`div`,{role:`alert`,className:`flex flex-wrap items-center gap-3 text-sm text-destructive`,children:[(0,W.jsx)(`span`,{className:`break-words`,children:l.message}),l.conflict&&i?(0,W.jsx)(j,{type:`button`,variant:`outline`,onClick:i,children:`Reload`}):null]}):null,e?(0,W.jsx)(Kn,{automation:e,onDeleted:r}):null]}):null]})})}function Kn({automation:e,onDeleted:t}){let[n,r]=(0,B.useState)(!1),[i,a]=(0,B.useState)(!1),[o,s]=(0,B.useState)(``),c=async()=>{if(!i){a(!0),s(``);try{await x(e.id),t()}catch(e){s(e instanceof Error?e.message:String(e))}finally{a(!1)}}};return(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2 border-t pt-4`,children:[n?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Delete “${e.name}”? It will stop running and cannot be restored.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(j,{type:`button`,variant:`danger-ghost`,"data-action":`automation-delete-confirm`,disabled:i,onClick:()=>void c(),children:`Delete automation`}),(0,W.jsx)(j,{type:`button`,variant:`outline`,disabled:i,onClick:()=>{r(!1),s(``)},children:`Keep`})]})]}):(0,W.jsx)(j,{type:`button`,variant:`outline`,"data-action":`automation-delete`,onClick:()=>r(!0),children:`Delete`}),o?(0,W.jsx)(`p`,{role:`alert`,className:`text-sm break-words text-destructive`,children:o}):null]})}function qn(e,t){return e?`Save changes`:t.enabled?`Save and enable`:`Save paused`}function Jn(e){let t=[!e.name.trim()&&`a name`,!e.prompt.trim()&&`a prompt`].filter(Boolean);return t.length?`Add ${t.join(` and `)} to save.`:``}function Yn({automation:e,draft:t,formId:n,saveHintId:r,saving:i}){let a=t.name.trim()?t.prompt.trim()?``:`Prompt`:`Name`,o=Jn(t),s=qn(e,t);return{title:e?`Edit automation`:`New automation`,subtitle:`Define when it runs and the ordinary task it launches.`,status:(0,W.jsx)(`p`,{id:r,"data-slot":`automation-save-hint`,className:`min-h-[1lh] text-xs text-muted-foreground`,children:o}),secondaryActions:(0,W.jsx)(I,{type:`button`,variant:`outline`,asChild:!0,children:(0,W.jsx)(F,{to:`/automations`,children:`Cancel`})}),primaryAction:(0,W.jsx)(I,{type:`submit`,form:n,variant:`primary`,disabled:i||a!==``,title:a?`${a} is required`:void 0,"aria-describedby":o?r:void 0,children:i?`Saving…`:s})}}function Xn({draft:e,patch:t}){let n=o(),r=Fe(),{runners:u,signedOut:d}=r.runnersOn(e=>r.repoAccount?.[e]),f=a(),p=s(),{runner:m,ready:h}=l(e.runner??f.data?.defaultRunner??`claude`),g=c(m,h,r.repoAccount?.[m]),_=[...new Set([...(n.data?.workflows??[]).map(e=>e.name),...e.workflow?[e.workflow]:[]])],v=[...new Set([...u,...e.runner?[e.runner]:[]])],y=We(m,p.data,g.data,[e.model]),b=y.find(t=>t.id===(e.model??``))?.label??e.model??`Runner default`,x=e=>(0,W.jsx)(e,{"aria-hidden":`true`,className:`size-[18px] shrink-0 text-accent-text`});return(0,W.jsx)(Ke,{children:(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(Re,{slot:`automation-workflow-pill`,icon:x(_e),fieldLabel:!0,ariaLabel:`Workflow`,label:e.workflow??`inline steps`,value:e.workflow??``,disabled:e.workflow===void 0,disabledHint:`This automation carries its own steps.`,options:_.map(e=>({value:e,label:e})),onPick:e=>t({workflow:e})}),(0,W.jsx)(Re,{slot:`automation-runner-pill`,icon:x(be),fieldLabel:!0,ariaLabel:`Runner`,label:e.runner?i(p.data,e.runner):`default`,value:e.runner??``,disabled:!p.data,options:[{value:``,label:`default`,desc:`The project’s default runner`},...v.map(e=>({value:e,label:i(p.data,e)}))],footer:(0,W.jsx)(Je,{uninstalled:r.uninstalled,signedOut:d.filter(t=>t!==e.runner)}),onPick:e=>{t({runner:e||void 0,model:void 0})}}),(0,W.jsx)(Re,{slot:`automation-model-pill`,icon:x(ge),fieldLabel:!0,ariaLabel:`Model`,label:b,value:e.model??``,options:y.map(e=>({value:e.id,label:e.label,desc:e.desc})),onPick:e=>t({model:e||void 0})})]})})}function Zn(e){return{text:/\bauth\b|sign.?in|\blogin\b|\btoken\b|credentials|HTTP 401/i.test(e)?`GitHub CLI is not signed in`:/ENOENT|not found.*gh|gh.*not found/i.test(e)?`GitHub CLI is not installed`:`GitHub filter check failed`,tone:`error`,details:e}}function Qn({data:e,error:t,refresh:n,archived:i=!1,onArchivedChange:a}){let[o,s]=(0,B.useState)({}),[c,l]=(0,B.useState)({}),d=(e,t)=>s(n=>{let{[e]:r,...i}=n;return t?{...i,[e]:t}:i}),f=async(e,t,n=!1)=>{l(t=>({...t,[e]:!0}));try{await t()}catch(t){let r=t instanceof Error?t.message:String(t);d(e,n?Zn(r):{text:r,tone:`error`})}finally{l(t=>({...t,[e]:!1}))}},m=e=>f(e.id,async()=>{d(e.id,{text:`Starting…`,tone:`info`});let{runId:t}=await u(e.id);d(e.id,{text:`Started task`,tone:`info`,runId:t}),n()}),h=e=>f(e.id,async()=>{d(e.id,void 0),await p(e.id,!e.enabled),await n()}),g=e=>f(e.id,async()=>{d(e.id,void 0),await ne(e.id),await n()}),_=e=>f(e.id,async()=>{d(e.id,{text:`Checking…`,tone:`info`});let{checkId:t}=await re(e.id,`preview`);for(let r=0;r<60;r+=1){let r=await ee(t);if(r.status===`complete`){d(e.id,{text:`${r.matches??0} filter match${r.matches===1?``:`es`} found; no tasks launched. Counts can include closed items and previously processed events.`,tone:`info`}),n();return}if(r.status===`error`){let t=r.error??`Preview failed`;d(e.id,Zn(t));return}await new Promise(e=>setTimeout(e,500))}throw Error(`Preview is still running`)},!0),v=e?.automations??[],y=v.filter(e=>!e.archived),b=v.filter(e=>!!e.archived),x=i?b:y;return(0,W.jsx)(L,{route:`automations`,density:e?je(x.length):`full`,headerSpacing:`compact`,header:{title:`Automations`,subtitle:`Schedules and GitHub checks run while Squawk is open.`,primaryAction:(0,W.jsx)(I,{variant:`primary`,asChild:!0,children:(0,W.jsxs)(F,{to:`/automations/new`,children:[(0,W.jsx)(me,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})},sparseFooter:e&&x.length>0&&!i?(0,W.jsx)(Ne,{summary:`${x.length} active ${x.length===1?`automation`:`automations`} configured. New automations start paused so you can test filters before enabling them.`,actions:(0,W.jsx)(j,{variant:`outline`,size:`sm`,asChild:!0,children:(0,W.jsx)(F,{to:`/automations/new`,children:`Add another`})})}):void 0,children:t&&!e?(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(G,{text:t}),(0,W.jsx)(j,{variant:`outline`,onClick:()=>void n(),children:`Retry`})]}):e?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`div`,{className:`mb-4 flex flex-wrap items-end justify-between gap-3 border-b border-border`,children:[a?(0,W.jsxs)(`div`,{className:`flex gap-6`,role:`group`,"aria-label":`Filter automations`,children:[(0,W.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`active`,"aria-pressed":!i,onClick:()=>a(!1),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,!i&&`border-accent-text text-foreground`),children:[`Current`,(0,W.jsx)($n,{count:y.length})]}),(0,W.jsxs)(`button`,{type:`button`,"data-slot":`automations-tab`,"data-view":`archived`,"aria-pressed":i,onClick:()=>a(!0),className:r(`-mb-px flex min-h-11 items-center justify-center gap-1.5 border-b-2 border-transparent text-[13px] font-medium text-muted-foreground transition-colors hover:text-foreground`,i&&`border-accent-text text-foreground`),children:[`Archived`,(0,W.jsx)($n,{count:b.length})]})]}):(0,W.jsx)(`span`,{}),(0,W.jsx)(`div`,{className:`pb-2.5`,children:(0,W.jsx)(er,{data:e})})]}),i&&x.length===0?(0,W.jsx)(G,{text:`No archived automations.`}):x.length===0?(0,W.jsx)(Le,{icon:(0,W.jsx)(ve,{}),tone:`neutral`,title:`No automations yet`,subtitle:`Create one paused, preview it, then enable it.`,heading:`h2`,actions:(0,W.jsx)(j,{variant:`primary`,asChild:!0,children:(0,W.jsxs)(F,{to:`/automations/new`,children:[(0,W.jsx)(me,{"aria-hidden":`true`,className:`size-4`}),`New automation`]})})}):(0,W.jsx)(`ul`,{className:`grid gap-3`,"aria-label":`Automations`,children:x.map(t=>(0,W.jsx)(lr,{automation:t,timeZone:e.timeZone,note:o[t.id],busy:c[t.id]===!0,onRun:()=>void m(t),onToggle:()=>void h(t),onPreview:()=>void _(t),onCancel:()=>void g(t)},t.id))})]}):(0,W.jsx)(G,{text:`Loading automations…`})})}function $n({count:e}){return e===0?null:(0,W.jsx)(`span`,{"data-slot":`automations-tab-count`,className:`tabular-nums text-muted-foreground`,children:`· ${e}`})}function er({data:e}){return(0,W.jsx)(`p`,{"data-slot":`automation-scheduler`,className:r(`text-xs break-words`,e.scheduler.state===`scheduled`?`text-success`:`text-muted-foreground`),children:`Scheduler ${e.scheduler.state===`scheduled`?`running`:`idle`} · GitHub ${e.available?`available`:`unavailable`}${e.reason?` · ${e.reason}`:``} · ${e.timeZone}`})}function tr(e){return e.kind===`schedule`&&e.schedule?at(e.schedule):`${pn(e.events??[])} · every ${Math.round((e.intervalSeconds??300)/60)} min`}function nr({automation:e,nextRun:t}){let n=e.kind===`schedule`?he:pe,r=qe(e);return(0,W.jsxs)(`div`,{className:`flex flex-wrap items-start justify-between gap-3`,children:[(0,W.jsxs)(`div`,{className:`min-w-0`,children:[(0,W.jsxs)(`h2`,{className:`flex items-center gap-2 font-semibold break-words`,children:[(0,W.jsx)(n,{"aria-hidden":`true`,className:`size-4 shrink-0 text-muted-foreground`}),e.name]}),(0,W.jsxs)(`p`,{"data-slot":`automation-meta`,className:`mt-1 flex flex-wrap items-baseline gap-x-1.5 ps-6 text-xs break-words text-muted-foreground`,children:[(0,W.jsx)(`span`,{children:tr(e)}),t?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),t]}):null]})]}),(0,W.jsx)(Xe,{dot:r.tone,shape:r.shape,pulse:r.pulse,children:r.label})]})}function rr({automation:e,archive:t}){return(0,W.jsxs)(W.Fragment,{children:[(0,W.jsxs)(`p`,{className:`text-sm break-words`,children:[t.outcome===`launched`?`Started its task.`:`Cancelled — no task was started.`,t.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(F,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${t.runId}`,children:`Open task`})]}):null]}),(0,W.jsx)(`div`,{className:`flex flex-wrap gap-2`,children:(0,W.jsx)(j,{variant:`outline`,asChild:!0,children:(0,W.jsx)(F,{to:`/automations/${e.id}`,children:`Details`})})})]})}function ir({automation:e,timeZone:t}){let n=e.kind===`schedule`,r=e.enabled&&n?e.nextRunAt:void 0;return!n&&e.enabled?(0,W.jsx)(`span`,{children:`continuous`}):r?(0,W.jsxs)(W.Fragment,{children:[(0,W.jsx)(`span`,{className:`text-foreground`,children:`Next run: ${z(r,t)}`}),(0,W.jsx)(`span`,{children:`· ${ot(Date.now(),Date.parse(r))}`})]}):(0,W.jsx)(`span`,{children:`Next run: —`})}function ar({automation:e,timeZone:t}){let n=e.enabled?Ct(e.state):void 0;return n?(0,W.jsxs)(`p`,{role:`alert`,"data-slot":`automation-failing`,className:`text-sm break-words text-destructive`,children:[`The last ${n.consecutiveFailures} checks failed: ${n.lastError}`,n.retryAt?(0,W.jsx)(`span`,{className:`text-muted-foreground`,children:` · Next try ${z(n.retryAt,t)}`}):null]}):null}var $=`px-3`;function or({automation:e,busy:t,confirmingCancel:n,cancelRef:i,onToggle:a,onRun:o,onPreview:s,onOpenCancel:c}){let l=e.kind===`schedule`,u=e.schedule?.type===`once`;return(0,W.jsxs)(`div`,{"data-slot":`automation-actions`,className:`flex flex-wrap items-center gap-2`,children:[(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-toggle`,disabled:t,onClick:a,children:e.enabled?`Pause`:`Enable`}),l?(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-run`,disabled:t,onClick:o,children:`Run now`}):(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:$,"data-action":`automation-preview`,disabled:t,onClick:s,children:`Test filter`}),(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:$,asChild:!0,children:(0,W.jsx)(F,{to:`/automations/${e.id}`,children:`Edit`})}),u&&!n?(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:r($,`text-destructive`),ref:i,"data-action":`automation-cancel`,disabled:t,onClick:c,children:`Cancel`}):null,(0,W.jsx)(j,{variant:`outline`,size:`sm`,className:r($,`sm:ms-auto`),asChild:!0,children:(0,W.jsx)(F,{to:`/automations/${e.id}/log`,children:`Execution log`})})]})}function sr({automation:e,busy:t,keepRef:n,onConfirm:r,onKeep:i}){return(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-2`,children:[(0,W.jsx)(`p`,{className:`text-sm break-words`,children:`Cancel “${e.name}”? It will never run, and it moves to Archived.`}),(0,W.jsxs)(`div`,{className:`flex flex-wrap gap-2`,children:[(0,W.jsx)(j,{variant:`danger-ghost`,"data-action":`automation-cancel-confirm`,disabled:t,onClick:r,children:`Cancel schedule`}),(0,W.jsx)(j,{ref:n,variant:`outline`,disabled:t,onClick:i,children:`Keep`})]})]})}function cr({note:e}){return(0,W.jsxs)(`div`,{role:e.tone===`error`?`alert`:`status`,className:r(`text-sm break-words`,e.tone===`error`?`text-destructive`:`text-muted-foreground`),children:[e.text,e.details?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(de,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:Ie(`gh`),children:`Set up`}),(0,W.jsxs)(`details`,{children:[(0,W.jsx)(`summary`,{className:`min-h-11 cursor-pointer`,children:`Command details`}),(0,W.jsx)(`pre`,{className:`whitespace-pre-wrap break-words`,children:e.details})]})]}):null,e.runId?(0,W.jsxs)(W.Fragment,{children:[` · `,(0,W.jsx)(F,{className:`inline-flex min-h-11 items-center underline underline-offset-4`,to:`/tasks/${e.runId}`,children:`Open task`})]}):null]})}function lr({automation:e,timeZone:t,note:n,busy:r,onRun:i,onToggle:a,onPreview:o,onCancel:s}){let[c,l]=(0,B.useState)(!1),u=(0,B.useRef)(null),d=(0,B.useRef)(null),f=(0,B.useRef)(null);(0,B.useEffect)(()=>{let e=f.current===`keep`?d.current:f.current===`cancel`?u.current:null;f.current=null,e?.focus()},[c]);let p=()=>{f.current=`keep`,l(!0)},m=()=>{f.current=`cancel`,l(!1)},h=e.archived;return(0,W.jsxs)(`li`,{"data-slot":`automation-card`,"data-kind":e.kind,className:`flex min-w-0 flex-col gap-2.5 rounded-xl border border-card-edge bg-card p-4 shadow-card`,children:[(0,W.jsx)(nr,{automation:e,nextRun:h?void 0:(0,W.jsx)(ir,{automation:e,timeZone:t})}),h?(0,W.jsx)(rr,{automation:e,archive:h}):null,h?null:(0,W.jsx)(ar,{automation:e,timeZone:t}),h?null:(0,W.jsx)(or,{automation:e,busy:r,confirmingCancel:c,cancelRef:u,onToggle:a,onRun:i,onPreview:o,onOpenCancel:p}),e.schedule?.type===`once`&&!h&&c?(0,W.jsx)(sr,{automation:e,busy:r,keepRef:d,onConfirm:()=>{l(!1),s()},onKeep:m}):null,n?(0,W.jsx)(cr,{note:n}):null,(0,W.jsx)(Ft,{automationId:e.id,automationName:e.name,timeZone:t})]})}function ur(e){let t=Ae(),n=Ye(),[r,i]=(0,B.useState)(),[a,o]=(0,B.useState)(``),s=(0,B.useCallback)(t=>oe({signal:t,...e?{archived:e}:{}}).then(e=>{t?.aborted||(i(e),o(``))}).catch(e=>{t?.aborted||o(String(e))}),[e]);return(0,B.useEffect)(()=>{n&&s()},[n,s]),(0,B.useEffect)(()=>d(async e=>{n&&await s(e)}),[n,s]),(0,B.useEffect)(()=>fe((e,n)=>{if(e!==`automation-change`)return;let r=n;typeof r.project==`string`&&(t===null||r.project===t)&&s()}),[t,s]),{data:r,error:a,refresh:s}}function dr({mode:e=`list`}){let{automationId:t}=ue(),n=ke(),[r,i]=(0,B.useState)(!1),{data:a,error:o,refresh:s}=ur(`include`),[c,l]=(0,B.useState)(0),u=He();if(u===`unknown`)return(0,W.jsx)(L,{route:`automations`,density:`empty`,children:(0,W.jsx)(G,{text:`Loading automations…`})});if(u===`absent`)return(0,W.jsx)(Ue,{});if(u===`disabled`)return(0,W.jsx)(L,{route:`automations`,density:`empty`,children:(0,W.jsx)(Le,{icon:(0,W.jsx)(ve,{}),tone:`neutral`,title:`Automations are off`,subtitle:`This server does not run schedules, poll GitHub or launch tasks from them. Unset CEZ_AUTOMATIONS or set it to 1 and restart Squawk to turn automations on.`,heading:`h2`})});let d=()=>{n(`/automations`),s()},f=a?.automations.find(e=>e.id===t);if(e===`list`)return(0,W.jsx)(Qn,{data:a,error:o,refresh:s,archived:r,onArchivedChange:i});if(!a)return o?(0,W.jsx)(L,{route:`automations`,density:`empty`,header:{title:`Automations`,subtitle:`Could not load automations.`},children:(0,W.jsxs)(`div`,{className:`grid justify-items-start gap-3`,children:[(0,W.jsx)(G,{text:o}),(0,W.jsx)(j,{variant:`outline`,onClick:()=>void s(),children:`Retry`})]})}):(0,W.jsx)(L,{route:`automations`,density:`empty`,children:(0,W.jsx)(G,{text:`Loading automations…`})});let p={available:a.available,...a.reason?{reason:a.reason}:{}};return e===`new`?(0,W.jsx)(Gn,{forge:p,timeZone:a.timeZone,onSaved:d}):e===`edit`?f?f.archived?(0,W.jsx)(It,{automation:f,timeZone:a.timeZone,onDeleted:d}):(0,W.jsx)(Gn,{automation:f,forge:p,timeZone:a.timeZone,onSaved:d,onReload:()=>void s().then(()=>l(e=>e+1))},`${f.id}:${c}`):(0,W.jsx)(L,{route:`automations`,density:`empty`,header:{title:`Automation not found`,subtitle:`This automation may have been removed.`},children:(0,W.jsx)(j,{asChild:!0,variant:`outline`,children:(0,W.jsx)(F,{to:`/automations`,children:`Back to automations`})})}):t?(0,W.jsx)(Pt,{automationId:t,automationName:f?.name,timeZone:a.timeZone,readOnly:!!f?.archived}):(0,W.jsx)(G,{text:`Automation not found.`})}export{dr as AutomationsRoute};
@@ -1 +1 @@
1
- import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{o as n,t as r}from"./dist-C_rn70hE.js";import{r as i}from"./button-C8jUIs8Q.js";e();var a=t(),o=i(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-accent-strong text-accent-strong-foreground [a&]:hover:bg-accent-strong/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-destructive-foreground focus-visible:ring-destructive/20 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-link-foreground underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function s({className:e,variant:t=`default`,asChild:i=!1,...s}){return(0,a.jsx)(i?r:`span`,{"data-slot":`badge`,"data-variant":t,className:n(o({variant:t}),e),...s})}export{s as t};
1
+ import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{o as n,t as r}from"./dist-C_rn70hE.js";import{r as i}from"./button-B22ANdCY.js";e();var a=t(),o=i(`inline-flex w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-full border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 [&>svg]:pointer-events-none [&>svg]:size-3`,{variants:{variant:{default:`bg-accent-strong text-accent-strong-foreground [a&]:hover:bg-accent-strong/90`,secondary:`bg-secondary text-secondary-foreground [a&]:hover:bg-secondary/90`,destructive:`bg-destructive text-destructive-foreground focus-visible:ring-destructive/20 [a&]:hover:bg-destructive/90`,outline:`border-border text-foreground [a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,ghost:`[a&]:hover:bg-accent [a&]:hover:text-accent-foreground`,link:`text-link-foreground underline-offset-4 [a&]:hover:underline`}},defaultVariants:{variant:`default`}});function s({className:e,variant:t=`default`,asChild:i=!1,...s}){return(0,a.jsx)(i?r:`span`,{"data-slot":`badge`,"data-variant":t,className:n(o({variant:t}),e),...s})}export{s as t};
@@ -1 +1 @@
1
- import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{o as n,t as r}from"./dist-C_rn70hE.js";import{r as i}from"./bundle-mjs-rHxsej31.js";e();var a=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,o=i,s=(e,t)=>n=>{if(t?.variants==null)return o(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,s=Object.keys(r).map(e=>{let t=n?.[e],o=i?.[e];if(t===null)return null;let s=a(t)||a(o);return r[e][s]}),c=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return o(e,s,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...c}[t]):{...i,...c}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},c=t(),l=s(`inline-flex shrink-0 items-center justify-center gap-[7px] rounded-md font-semibold whitespace-nowrap transition-[background-color,border-color,opacity,filter] outline-hidden focus-visible:ring-[3px] focus-visible:ring-ring/50 enabled:active:brightness-90 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{primary:`bg-action text-action-foreground pointer-hover:brightness-[0.96] disabled:border disabled:border-border disabled:bg-muted/80 disabled:text-muted-foreground disabled:opacity-100`,contrast:`bg-contrast text-contrast-foreground pointer-hover:brightness-[0.96]`,outline:`border border-border bg-card text-foreground pointer-hover:bg-muted`,ghost:`text-muted-foreground pointer-hover:bg-muted pointer-hover:text-foreground`,"danger-ghost":`text-danger pointer-hover:bg-danger/10`},size:{default:`h-11 px-3.5 text-[13px]`,sm:`h-[30px] rounded-sm px-2.5 text-[13px]`,icon:`size-9 text-[13px]`,"icon-sm":`size-[30px] rounded-sm text-[13px]`}},defaultVariants:{variant:`primary`,size:`default`}});function u({className:e,variant:t=`primary`,size:i=`default`,asChild:a=!1,...o}){return(0,c.jsx)(a?r:`button`,{"data-slot":`button`,"data-variant":t,"data-size":i,className:n(l({variant:t,size:i,className:e})),...o})}export{l as n,s as r,u as t};
1
+ import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{o as n,t as r}from"./dist-C_rn70hE.js";import{r as i}from"./bundle-mjs-rHxsej31.js";e();var a=e=>typeof e==`boolean`?`${e}`:e===0?`0`:e,o=i,s=(e,t)=>n=>{if(t?.variants==null)return o(e,n?.class,n?.className);let{variants:r,defaultVariants:i}=t,s=Object.keys(r).map(e=>{let t=n?.[e],o=i?.[e];if(t===null)return null;let s=a(t)||a(o);return r[e][s]}),c=n&&Object.entries(n).reduce((e,t)=>{let[n,r]=t;return r===void 0||(e[n]=r),e},{});return o(e,s,t?.compoundVariants?.reduce((e,t)=>{let{class:n,className:r,...a}=t;return Object.entries(a).every(e=>{let[t,n]=e;return Array.isArray(n)?n.includes({...i,...c}[t]):{...i,...c}[t]===n})?[...e,n,r]:e},[]),n?.class,n?.className)},c=t(),l=s(`inline-flex shrink-0 items-center justify-center gap-[7px] rounded-md font-semibold whitespace-nowrap transition-[background-color,border-color,opacity,filter] outline-hidden focus-visible:ring-[3px] focus-visible:ring-ring/50 enabled:active:brightness-90 disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,{variants:{variant:{primary:`bg-action text-action-foreground pointer-hover:brightness-[0.96] disabled:border disabled:border-border disabled:bg-muted/80 disabled:text-muted-foreground disabled:opacity-100`,contrast:`bg-contrast text-contrast-foreground pointer-hover:brightness-[0.96]`,outline:`border border-border bg-card text-foreground pointer-hover:bg-muted`,ghost:`text-muted-foreground pointer-hover:bg-muted pointer-hover:text-foreground`,"danger-ghost":`text-danger pointer-hover:bg-danger/10`},size:{default:`h-9 px-3 text-[13px] touch:h-11 touch:min-w-11`,sm:`h-8 rounded-sm px-2.5 text-[13px] touch:h-11 touch:min-w-11`,icon:`size-9 text-[13px] touch:size-11`,"icon-sm":`size-8 rounded-sm text-[13px] touch:size-11`,block:`h-auto min-h-9 w-full justify-start px-3 py-1.5 text-start text-[13px] whitespace-normal touch:min-h-11`}},defaultVariants:{variant:`primary`,size:`default`}});function u({className:e,variant:t=`primary`,size:i=`default`,asChild:a=!1,...o}){return(0,c.jsx)(a?r:`button`,{"data-slot":`button`,"data-variant":t,"data-button-size":i,className:n(l({variant:t,size:i,className:e})),...o})}export{l as n,s as r,u 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,i,o as a}from"./dist-C_rn70hE.js";import{Q as o}from"./design-icons-QbNMZniQ.js";import{h as s,l as c}from"./es2015-CUEfzDjB.js";import{a as l,o as u,r as d,t as f}from"./dist--f2yFdPY.js";import{i as p,o as m,r as h,s as g,t as _}from"./dialog-DRZuXvul.js";var v=e(t(),1),y=1,b=.9,x=.8,S=.17,C=.1,w=.999,T=.9999,E=.99,D=/[\\\/_+.#"@\[\(\{&]/,O=/[\\\/_+.#"@\[\(\{&]/g,k=/[\s-]/,A=/[\s-]/g;function j(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?y:E;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=j(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=y:D.test(e.charAt(l-1))?(d*=x,p=e.slice(i,l-1).match(O),p&&i>0&&(d*=w**+p.length)):k.test(e.charAt(l-1))?(d*=b,m=e.slice(i,l-1).match(A),m&&i>0&&(d*=w**+m.length)):(d*=S,i>0&&(d*=w**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=T)),(d<C&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=j(e,t,n,r,l+1,a+2,o),f*C>d&&(d=f*C)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function M(e){return e.toLowerCase().replace(A,` `)}function N(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,j(e,t,M(e),M(t),0,0,{})}var P=`[cmdk-group=""]`,F=`[cmdk-group-items=""]`,ee=`[cmdk-group-heading=""]`,I=`[cmdk-item=""]`,L=`${I}:not([aria-disabled="true"])`,R=`cmdk-item-select`,z=`data-value`,te=(e,t,n)=>N(e,t,n),ne=v.createContext(void 0),B=()=>v.useContext(ne),re=v.createContext(void 0),V=()=>v.useContext(re),H=v.createContext(void 0),U=v.forwardRef((e,t)=>{let n=X(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=X(()=>new Set),i=X(()=>new Map),a=X(()=>new Map),o=X(()=>new Set),l=J(e),{label:u,children:d,value:f,onValueChange:p,filter:m,shouldFilter:h,loop:g,disablePointerSelection:_=!1,vimBindings:y=!0,...b}=e,x=c(),S=c(),C=c(),w=v.useRef(null),T=fe();Y(()=>{if(f!==void 0){let e=f.trim();n.current.value=e,E.emit()}},[f]),Y(()=>{T(6,M)},[]);let E=v.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)j(),k(),T(1,A);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(C);e?e.focus():(i=document.getElementById(x))==null||i.focus()}if(T(7,()=>{n.current.selectedItemId=N()?.id,E.emit()}),r||T(5,M),l.current?.value!==void 0){let e=t??``;(o=(a=l.current).onValueChange)==null||o.call(a,e);return}}E.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),D=v.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,O(t,r)),T(2,()=>{k(),E.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),T(3,()=>{j(),k(),n.current.value||A(),E.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=N();T(4,()=>{j(),t?.getAttribute(`id`)===e&&A(),E.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>l.current.shouldFilter,label:u||e[`aria-label`],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:x,inputId:C,labelId:S,listInnerRef:w}),[]);function O(e,t){let r=l.current?.filter??te;return e?r(e,n.current.search,t):0}function k(){if(!n.current.search||l.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=w.current;B().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(F);t?t.appendChild(e.parentElement===t?e:e.closest(`${F} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${F} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=w.current?.querySelector(`${P}[${z}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function A(){let e=B().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(z);E.setState(`value`,e||void 0)}function j(){if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=O(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function M(){var e;let t=N();t&&(t.parentElement?.firstChild===t&&((e=t.closest(P)?.querySelector(ee))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function N(){return w.current?.querySelector(`${I}[aria-selected="true"]`)}function B(){return Array.from(w.current?.querySelectorAll(L)||[])}function V(e){let t=B()[e];t&&E.setState(`value`,t.getAttribute(z))}function H(e){var t;let n=N(),r=B(),i=r.findIndex(e=>e===n),a=r[i+e];(t=l.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&E.setState(`value`,a.getAttribute(z))}function U(e){let t=N()?.closest(P),n;for(;t&&!n;)t=e>0?le(t,P):ue(t,P),n=t?.querySelector(L);n?E.setState(`value`,n.getAttribute(z)):H(e)}let W=()=>V(B().length-1),G=e=>{e.preventDefault(),e.metaKey?W():e.altKey?U(1):H(1)},K=e=>{e.preventDefault(),e.metaKey?V(0):e.altKey?U(-1):H(-1)};return v.createElement(s.div,{ref:t,tabIndex:-1,...b,"cmdk-root":``,onKeyDown:e=>{var t;(t=b.onKeyDown)==null||t.call(b,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:y&&e.ctrlKey&&G(e);break;case`ArrowDown`:G(e);break;case`p`:case`k`:y&&e.ctrlKey&&K(e);break;case`ArrowUp`:K(e);break;case`Home`:e.preventDefault(),V(0);break;case`End`:e.preventDefault(),W();break;case`Enter`:{e.preventDefault();let t=N();if(t){let e=new Event(R);t.dispatchEvent(e)}}}}},v.createElement(`label`,{"cmdk-label":``,htmlFor:D.inputId,id:D.labelId,style:me},u),Q(e,e=>v.createElement(re.Provider,{value:E},v.createElement(ne.Provider,{value:D},e))))}),W=v.forwardRef((e,t)=>{let n=c(),r=v.useRef(null),a=v.useContext(H),o=B(),l=J(e),u=l.current?.forceMount??a?.forceMount;Y(()=>{if(!u)return o.item(n,a?.id)},[u]);let d=de(n,r,[e.value,e.children,r],e.keywords),f=V(),p=Z(e=>e.value&&e.value===d.current),m=Z(e=>u||o.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);v.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(R,h),()=>t.removeEventListener(R,h)},[m,e.onSelect,e.disabled]);function h(){var e,t;g(),(t=(e=l.current).onSelect)==null||t.call(e,d.current)}function g(){f.setState(`value`,d.current,!0)}if(!m)return null;let{disabled:_,value:y,onSelect:b,forceMount:x,keywords:S,...C}=e;return v.createElement(s.div,{ref:i(r,t),...C,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!_,"aria-selected":!!p,"data-disabled":!!_,"data-selected":!!p,onPointerMove:_||o.getDisablePointerSelection()?void 0:g,onClick:_?void 0:h},e.children)}),G=v.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:a,...o}=e,l=c(),u=v.useRef(null),d=v.useRef(null),f=c(),p=B(),m=Z(e=>a||p.filter()===!1?!0:!e.search||e.filtered.groups.has(l));Y(()=>p.group(l),[]),de(l,u,[e.value,e.heading,d]);let h=v.useMemo(()=>({id:l,forceMount:a}),[a]);return v.createElement(s.div,{ref:i(u,t),...o,"cmdk-group":``,role:`presentation`,hidden:!m||void 0},n&&v.createElement(`div`,{ref:d,"cmdk-group-heading":``,"aria-hidden":!0,id:f},n),Q(e,e=>v.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?f:void 0},v.createElement(H.Provider,{value:h},e))))}),K=v.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,a=v.useRef(null),o=Z(e=>!e.search);return!n&&!o?null:v.createElement(s.div,{ref:i(a,t),...r,"cmdk-separator":``,role:`separator`})}),ie=v.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=V(),o=Z(e=>e.search),c=Z(e=>e.selectedItemId),l=B();return v.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),v.createElement(s.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":c,id:l.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),ae=v.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...a}=e,o=v.useRef(null),c=v.useRef(null),l=Z(e=>e.selectedItemId),u=B();return v.useEffect(()=>{if(c.current&&o.current){let e=c.current,t=o.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),v.createElement(s.div,{ref:i(o,t),...a,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:u.listId},Q(e,e=>v.createElement(`div`,{ref:i(c,u.listInnerRef),"cmdk-list-sizer":``},e)))}),oe=v.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return v.createElement(f,{open:n,onOpenChange:r},v.createElement(u,{container:o},v.createElement(l,{"cmdk-overlay":``,className:i}),v.createElement(d,{"aria-label":e.label,"cmdk-dialog":``,className:a},v.createElement(U,{ref:t,...s}))))}),se=v.forwardRef((e,t)=>Z(e=>e.filtered.count===0)?v.createElement(s.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),ce=v.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return v.createElement(s.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Q(e,e=>v.createElement(`div`,{"aria-hidden":!0},e)))}),q=Object.assign(U,{List:ae,Item:W,Input:ie,Group:G,Separator:K,Dialog:oe,Empty:se,Loading:ce});function le(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ue(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function J(e){let t=v.useRef(e);return Y(()=>{t.current=e}),t}var Y=typeof window>`u`?v.useEffect:v.useLayoutEffect;function X(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function Z(e){let t=V(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function de(e,t,n,r=[]){let i=v.useRef(),a=B();return Y(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(z,s),i.current=s}),i}var fe=()=>{let[e,t]=v.useState(),n=X(()=>new Map);return Y(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function pe(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Q({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(pe(t),{ref:t.ref},n(t.props.children)):n(t)}var me={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},$=n();function he({className:e,...t}){return(0,$.jsx)(q,{"data-slot":`command`,className:a(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function ge({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:i,showCloseButton:o=!0,filter:s,...c}){return(0,$.jsxs)(_,{...c,children:[(0,$.jsxs)(m,{className:`sr-only`,children:[(0,$.jsx)(g,{children:e}),(0,$.jsx)(p,{children:t})]}),(0,$.jsx)(h,{className:a(`overflow-hidden p-0`,i),showCloseButton:o,children:(0,$.jsx)(he,{...r({filter:s}),className:`**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:n})})]})}function _e({className:e,...t}){return(0,$.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex min-h-11 shrink-0 items-center gap-2 rounded-ss-[inherit] rounded-se-[inherit] border-b px-3`,children:[(0,$.jsx)(o,{className:`size-4 shrink-0 opacity-50`}),(0,$.jsx)(q.Input,{"data-slot":`command-input`,className:a(`flex h-11 min-w-0 flex-1 rounded-md bg-transparent py-3 text-base md:text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function ve({className:e,onPointerMoveCapture:t,...n}){return(0,$.jsx)(q.List,{"data-slot":`command-list`,onPointerMoveCapture:e=>{t?.(e),e.pointerType===`touch`&&e.stopPropagation()},className:a(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...n})}function ye({...e}){return(0,$.jsx)(q.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function be({className:e,...t}){return(0,$.jsx)(q.Group,{"data-slot":`command-group`,className:a(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function xe({className:e,...t}){return(0,$.jsx)(q.Separator,{"data-slot":`command-separator`,className:a(`-mx-1 h-px bg-border`,e),...t})}function Se({className:e,...t}){return(0,$.jsx)(q.Item,{"data-slot":`command-item`,className:a(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function Ce({className:e,...t}){return(0,$.jsx)(`span`,{"data-slot":`command-shortcut`,className:a(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t})}export{_e as a,xe as c,be as i,Ce as l,ge as n,Se as o,ye as r,ve as s,he 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,i,o as a}from"./dist-C_rn70hE.js";import{Q as o}from"./design-icons-QbNMZniQ.js";import{h as s,l as c}from"./es2015-CUEfzDjB.js";import{a as l,o as u,r as d,t as f}from"./dist--f2yFdPY.js";import{i as p,o as m,r as h,s as g,t as _}from"./dialog-rpNyAWGb.js";var v=e(t(),1),y=1,b=.9,x=.8,S=.17,C=.1,w=.999,T=.9999,E=.99,D=/[\\\/_+.#"@\[\(\{&]/,O=/[\\\/_+.#"@\[\(\{&]/g,k=/[\s-]/,A=/[\s-]/g;function j(e,t,n,r,i,a,o){if(a===t.length)return i===e.length?y:E;var s=`${i},${a}`;if(o[s]!==void 0)return o[s];for(var c=r.charAt(a),l=n.indexOf(c,i),u=0,d,f,p,m;l>=0;)d=j(e,t,n,r,l+1,a+1,o),d>u&&(l===i?d*=y:D.test(e.charAt(l-1))?(d*=x,p=e.slice(i,l-1).match(O),p&&i>0&&(d*=w**+p.length)):k.test(e.charAt(l-1))?(d*=b,m=e.slice(i,l-1).match(A),m&&i>0&&(d*=w**+m.length)):(d*=S,i>0&&(d*=w**+(l-i))),e.charAt(l)!==t.charAt(a)&&(d*=T)),(d<C&&n.charAt(l-1)===r.charAt(a+1)||r.charAt(a+1)===r.charAt(a)&&n.charAt(l-1)!==r.charAt(a))&&(f=j(e,t,n,r,l+1,a+2,o),f*C>d&&(d=f*C)),d>u&&(u=d),l=n.indexOf(c,l+1);return o[s]=u,u}function M(e){return e.toLowerCase().replace(A,` `)}function N(e,t,n){return e=n&&n.length>0?`${e+` `+n.join(` `)}`:e,j(e,t,M(e),M(t),0,0,{})}var P=`[cmdk-group=""]`,F=`[cmdk-group-items=""]`,ee=`[cmdk-group-heading=""]`,I=`[cmdk-item=""]`,L=`${I}:not([aria-disabled="true"])`,R=`cmdk-item-select`,z=`data-value`,te=(e,t,n)=>N(e,t,n),ne=v.createContext(void 0),B=()=>v.useContext(ne),re=v.createContext(void 0),V=()=>v.useContext(re),H=v.createContext(void 0),U=v.forwardRef((e,t)=>{let n=X(()=>({search:``,value:e.value??e.defaultValue??``,selectedItemId:void 0,filtered:{count:0,items:new Map,groups:new Set}})),r=X(()=>new Set),i=X(()=>new Map),a=X(()=>new Map),o=X(()=>new Set),l=J(e),{label:u,children:d,value:f,onValueChange:p,filter:m,shouldFilter:h,loop:g,disablePointerSelection:_=!1,vimBindings:y=!0,...b}=e,x=c(),S=c(),C=c(),w=v.useRef(null),T=fe();Y(()=>{if(f!==void 0){let e=f.trim();n.current.value=e,E.emit()}},[f]),Y(()=>{T(6,M)},[]);let E=v.useMemo(()=>({subscribe:e=>(o.current.add(e),()=>o.current.delete(e)),snapshot:()=>n.current,setState:(e,t,r)=>{var i,a,o;if(!Object.is(n.current[e],t)){if(n.current[e]=t,e===`search`)j(),k(),T(1,A);else if(e===`value`){if(document.activeElement.hasAttribute(`cmdk-input`)||document.activeElement.hasAttribute(`cmdk-root`)){let e=document.getElementById(C);e?e.focus():(i=document.getElementById(x))==null||i.focus()}if(T(7,()=>{n.current.selectedItemId=N()?.id,E.emit()}),r||T(5,M),l.current?.value!==void 0){let e=t??``;(o=(a=l.current).onValueChange)==null||o.call(a,e);return}}E.emit()}},emit:()=>{o.current.forEach(e=>e())}}),[]),D=v.useMemo(()=>({value:(e,t,r)=>{t!==a.current.get(e)?.value&&(a.current.set(e,{value:t,keywords:r}),n.current.filtered.items.set(e,O(t,r)),T(2,()=>{k(),E.emit()}))},item:(e,t)=>(r.current.add(e),t&&(i.current.has(t)?i.current.get(t).add(e):i.current.set(t,new Set([e]))),T(3,()=>{j(),k(),n.current.value||A(),E.emit()}),()=>{a.current.delete(e),r.current.delete(e),n.current.filtered.items.delete(e);let t=N();T(4,()=>{j(),t?.getAttribute(`id`)===e&&A(),E.emit()})}),group:e=>(i.current.has(e)||i.current.set(e,new Set),()=>{a.current.delete(e),i.current.delete(e)}),filter:()=>l.current.shouldFilter,label:u||e[`aria-label`],getDisablePointerSelection:()=>l.current.disablePointerSelection,listId:x,inputId:C,labelId:S,listInnerRef:w}),[]);function O(e,t){let r=l.current?.filter??te;return e?r(e,n.current.search,t):0}function k(){if(!n.current.search||l.current.shouldFilter===!1)return;let e=n.current.filtered.items,t=[];n.current.filtered.groups.forEach(n=>{let r=i.current.get(n),a=0;r.forEach(t=>{let n=e.get(t);a=Math.max(n,a)}),t.push([n,a])});let r=w.current;B().sort((t,n)=>{let r=t.getAttribute(`id`),i=n.getAttribute(`id`);return(e.get(i)??0)-(e.get(r)??0)}).forEach(e=>{let t=e.closest(F);t?t.appendChild(e.parentElement===t?e:e.closest(`${F} > *`)):r.appendChild(e.parentElement===r?e:e.closest(`${F} > *`))}),t.sort((e,t)=>t[1]-e[1]).forEach(e=>{let t=w.current?.querySelector(`${P}[${z}="${encodeURIComponent(e[0])}"]`);t?.parentElement.appendChild(t)})}function A(){let e=B().find(e=>e.getAttribute(`aria-disabled`)!==`true`)?.getAttribute(z);E.setState(`value`,e||void 0)}function j(){if(!n.current.search||l.current.shouldFilter===!1){n.current.filtered.count=r.current.size;return}n.current.filtered.groups=new Set;let e=0;for(let t of r.current){let r=O(a.current.get(t)?.value??``,a.current.get(t)?.keywords??[]);n.current.filtered.items.set(t,r),r>0&&e++}for(let[e,t]of i.current)for(let r of t)if(n.current.filtered.items.get(r)>0){n.current.filtered.groups.add(e);break}n.current.filtered.count=e}function M(){var e;let t=N();t&&(t.parentElement?.firstChild===t&&((e=t.closest(P)?.querySelector(ee))==null||e.scrollIntoView({block:`nearest`})),t.scrollIntoView({block:`nearest`}))}function N(){return w.current?.querySelector(`${I}[aria-selected="true"]`)}function B(){return Array.from(w.current?.querySelectorAll(L)||[])}function V(e){let t=B()[e];t&&E.setState(`value`,t.getAttribute(z))}function H(e){var t;let n=N(),r=B(),i=r.findIndex(e=>e===n),a=r[i+e];(t=l.current)!=null&&t.loop&&(a=i+e<0?r[r.length-1]:i+e===r.length?r[0]:r[i+e]),a&&E.setState(`value`,a.getAttribute(z))}function U(e){let t=N()?.closest(P),n;for(;t&&!n;)t=e>0?le(t,P):ue(t,P),n=t?.querySelector(L);n?E.setState(`value`,n.getAttribute(z)):H(e)}let W=()=>V(B().length-1),G=e=>{e.preventDefault(),e.metaKey?W():e.altKey?U(1):H(1)},K=e=>{e.preventDefault(),e.metaKey?V(0):e.altKey?U(-1):H(-1)};return v.createElement(s.div,{ref:t,tabIndex:-1,...b,"cmdk-root":``,onKeyDown:e=>{var t;(t=b.onKeyDown)==null||t.call(b,e);let n=e.nativeEvent.isComposing||e.keyCode===229;if(!(e.defaultPrevented||n))switch(e.key){case`n`:case`j`:y&&e.ctrlKey&&G(e);break;case`ArrowDown`:G(e);break;case`p`:case`k`:y&&e.ctrlKey&&K(e);break;case`ArrowUp`:K(e);break;case`Home`:e.preventDefault(),V(0);break;case`End`:e.preventDefault(),W();break;case`Enter`:{e.preventDefault();let t=N();if(t){let e=new Event(R);t.dispatchEvent(e)}}}}},v.createElement(`label`,{"cmdk-label":``,htmlFor:D.inputId,id:D.labelId,style:me},u),Q(e,e=>v.createElement(re.Provider,{value:E},v.createElement(ne.Provider,{value:D},e))))}),W=v.forwardRef((e,t)=>{let n=c(),r=v.useRef(null),a=v.useContext(H),o=B(),l=J(e),u=l.current?.forceMount??a?.forceMount;Y(()=>{if(!u)return o.item(n,a?.id)},[u]);let d=de(n,r,[e.value,e.children,r],e.keywords),f=V(),p=Z(e=>e.value&&e.value===d.current),m=Z(e=>u||o.filter()===!1?!0:!e.search||e.filtered.items.get(n)>0);v.useEffect(()=>{let t=r.current;if(!(!t||e.disabled))return t.addEventListener(R,h),()=>t.removeEventListener(R,h)},[m,e.onSelect,e.disabled]);function h(){var e,t;g(),(t=(e=l.current).onSelect)==null||t.call(e,d.current)}function g(){f.setState(`value`,d.current,!0)}if(!m)return null;let{disabled:_,value:y,onSelect:b,forceMount:x,keywords:S,...C}=e;return v.createElement(s.div,{ref:i(r,t),...C,id:n,"cmdk-item":``,role:`option`,"aria-disabled":!!_,"aria-selected":!!p,"data-disabled":!!_,"data-selected":!!p,onPointerMove:_||o.getDisablePointerSelection()?void 0:g,onClick:_?void 0:h},e.children)}),G=v.forwardRef((e,t)=>{let{heading:n,children:r,forceMount:a,...o}=e,l=c(),u=v.useRef(null),d=v.useRef(null),f=c(),p=B(),m=Z(e=>a||p.filter()===!1?!0:!e.search||e.filtered.groups.has(l));Y(()=>p.group(l),[]),de(l,u,[e.value,e.heading,d]);let h=v.useMemo(()=>({id:l,forceMount:a}),[a]);return v.createElement(s.div,{ref:i(u,t),...o,"cmdk-group":``,role:`presentation`,hidden:!m||void 0},n&&v.createElement(`div`,{ref:d,"cmdk-group-heading":``,"aria-hidden":!0,id:f},n),Q(e,e=>v.createElement(`div`,{"cmdk-group-items":``,role:`group`,"aria-labelledby":n?f:void 0},v.createElement(H.Provider,{value:h},e))))}),K=v.forwardRef((e,t)=>{let{alwaysRender:n,...r}=e,a=v.useRef(null),o=Z(e=>!e.search);return!n&&!o?null:v.createElement(s.div,{ref:i(a,t),...r,"cmdk-separator":``,role:`separator`})}),ie=v.forwardRef((e,t)=>{let{onValueChange:n,...r}=e,i=e.value!=null,a=V(),o=Z(e=>e.search),c=Z(e=>e.selectedItemId),l=B();return v.useEffect(()=>{e.value!=null&&a.setState(`search`,e.value)},[e.value]),v.createElement(s.input,{ref:t,...r,"cmdk-input":``,autoComplete:`off`,autoCorrect:`off`,spellCheck:!1,"aria-autocomplete":`list`,role:`combobox`,"aria-expanded":!0,"aria-controls":l.listId,"aria-labelledby":l.labelId,"aria-activedescendant":c,id:l.inputId,type:`text`,value:i?e.value:o,onChange:e=>{i||a.setState(`search`,e.target.value),n?.(e.target.value)}})}),ae=v.forwardRef((e,t)=>{let{children:n,label:r=`Suggestions`,...a}=e,o=v.useRef(null),c=v.useRef(null),l=Z(e=>e.selectedItemId),u=B();return v.useEffect(()=>{if(c.current&&o.current){let e=c.current,t=o.current,n,r=new ResizeObserver(()=>{n=requestAnimationFrame(()=>{let n=e.offsetHeight;t.style.setProperty(`--cmdk-list-height`,n.toFixed(1)+`px`)})});return r.observe(e),()=>{cancelAnimationFrame(n),r.unobserve(e)}}},[]),v.createElement(s.div,{ref:i(o,t),...a,"cmdk-list":``,role:`listbox`,tabIndex:-1,"aria-activedescendant":l,"aria-label":r,id:u.listId},Q(e,e=>v.createElement(`div`,{ref:i(c,u.listInnerRef),"cmdk-list-sizer":``},e)))}),oe=v.forwardRef((e,t)=>{let{open:n,onOpenChange:r,overlayClassName:i,contentClassName:a,container:o,...s}=e;return v.createElement(f,{open:n,onOpenChange:r},v.createElement(u,{container:o},v.createElement(l,{"cmdk-overlay":``,className:i}),v.createElement(d,{"aria-label":e.label,"cmdk-dialog":``,className:a},v.createElement(U,{ref:t,...s}))))}),se=v.forwardRef((e,t)=>Z(e=>e.filtered.count===0)?v.createElement(s.div,{ref:t,...e,"cmdk-empty":``,role:`presentation`}):null),ce=v.forwardRef((e,t)=>{let{progress:n,children:r,label:i=`Loading...`,...a}=e;return v.createElement(s.div,{ref:t,...a,"cmdk-loading":``,role:`progressbar`,"aria-valuenow":n,"aria-valuemin":0,"aria-valuemax":100,"aria-label":i},Q(e,e=>v.createElement(`div`,{"aria-hidden":!0},e)))}),q=Object.assign(U,{List:ae,Item:W,Input:ie,Group:G,Separator:K,Dialog:oe,Empty:se,Loading:ce});function le(e,t){let n=e.nextElementSibling;for(;n;){if(n.matches(t))return n;n=n.nextElementSibling}}function ue(e,t){let n=e.previousElementSibling;for(;n;){if(n.matches(t))return n;n=n.previousElementSibling}}function J(e){let t=v.useRef(e);return Y(()=>{t.current=e}),t}var Y=typeof window>`u`?v.useEffect:v.useLayoutEffect;function X(e){let t=v.useRef();return t.current===void 0&&(t.current=e()),t}function Z(e){let t=V(),n=()=>e(t.snapshot());return v.useSyncExternalStore(t.subscribe,n,n)}function de(e,t,n,r=[]){let i=v.useRef(),a=B();return Y(()=>{var o;let s=(()=>{for(let e of n){if(typeof e==`string`)return e.trim();if(typeof e==`object`&&`current`in e)return e.current?e.current.textContent?.trim():i.current}})(),c=r.map(e=>e.trim());a.value(e,s,c),(o=t.current)==null||o.setAttribute(z,s),i.current=s}),i}var fe=()=>{let[e,t]=v.useState(),n=X(()=>new Map);return Y(()=>{n.current.forEach(e=>e()),n.current=new Map},[e]),(e,r)=>{n.current.set(e,r),t({})}};function pe(e){let t=e.type;return typeof t==`function`?t(e.props):`render`in t?t.render(e.props):e}function Q({asChild:e,children:t},n){return e&&v.isValidElement(t)?v.cloneElement(pe(t),{ref:t.ref},n(t.props.children)):n(t)}var me={position:`absolute`,width:`1px`,height:`1px`,padding:`0`,margin:`-1px`,overflow:`hidden`,clip:`rect(0, 0, 0, 0)`,whiteSpace:`nowrap`,borderWidth:`0`},$=n();function he({className:e,...t}){return(0,$.jsx)(q,{"data-slot":`command`,className:a(`flex h-full w-full flex-col overflow-hidden rounded-md bg-popover text-popover-foreground`,e),...t})}function ge({title:e=`Command Palette`,description:t=`Search for a command to run...`,children:n,className:i,showCloseButton:o=!0,filter:s,...c}){return(0,$.jsxs)(_,{...c,children:[(0,$.jsxs)(m,{className:`sr-only`,children:[(0,$.jsx)(g,{children:e}),(0,$.jsx)(p,{children:t})]}),(0,$.jsx)(h,{className:a(`overflow-hidden p-0`,i),showCloseButton:o,children:(0,$.jsx)(he,{...r({filter:s}),className:`**:data-[slot=command-input-wrapper]:h-12 [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground [&_[cmdk-group]]:px-2 [&_[cmdk-group]:not([hidden])_~[cmdk-group]]:pt-0 [&_[cmdk-input-wrapper]_svg]:h-5 [&_[cmdk-input-wrapper]_svg]:w-5 [&_[cmdk-input]]:h-12 [&_[cmdk-item]]:px-2 [&_[cmdk-item]]:py-3 [&_[cmdk-item]_svg]:h-5 [&_[cmdk-item]_svg]:w-5`,children:n})})]})}function _e({className:e,...t}){return(0,$.jsxs)(`div`,{"data-slot":`command-input-wrapper`,className:`flex min-h-11 shrink-0 items-center gap-2 rounded-ss-[inherit] rounded-se-[inherit] border-b px-3`,children:[(0,$.jsx)(o,{className:`size-4 shrink-0 opacity-50`}),(0,$.jsx)(q.Input,{"data-slot":`command-input`,className:a(`flex h-11 min-w-0 flex-1 rounded-md bg-transparent py-3 text-base md:text-sm placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50`,e),...t})]})}function ve({className:e,onPointerMoveCapture:t,...n}){return(0,$.jsx)(q.List,{"data-slot":`command-list`,onPointerMoveCapture:e=>{t?.(e),e.pointerType===`touch`&&e.stopPropagation()},className:a(`max-h-[300px] scroll-py-1 overflow-x-hidden overflow-y-auto`,e),...n})}function ye({...e}){return(0,$.jsx)(q.Empty,{"data-slot":`command-empty`,className:`py-6 text-center text-sm`,...e})}function be({className:e,...t}){return(0,$.jsx)(q.Group,{"data-slot":`command-group`,className:a(`overflow-hidden p-1 text-foreground [&_[cmdk-group-heading]]:px-2 [&_[cmdk-group-heading]]:py-1.5 [&_[cmdk-group-heading]]:text-xs [&_[cmdk-group-heading]]:font-medium [&_[cmdk-group-heading]]:text-muted-foreground`,e),...t})}function xe({className:e,...t}){return(0,$.jsx)(q.Separator,{"data-slot":`command-separator`,className:a(`-mx-1 h-px bg-border`,e),...t})}function Se({className:e,...t}){return(0,$.jsx)(q.Item,{"data-slot":`command-item`,className:a(`relative flex cursor-default items-center gap-2 rounded-sm px-2 py-1.5 text-sm outline-hidden select-none data-[disabled=true]:pointer-events-none data-[disabled=true]:opacity-50 data-[selected=true]:bg-accent data-[selected=true]:text-accent-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 [&_svg:not([class*='text-'])]:text-muted-foreground`,e),...t})}function Ce({className:e,...t}){return(0,$.jsx)(`span`,{"data-slot":`command-shortcut`,className:a(`ml-auto text-xs tracking-widest text-muted-foreground`,e),...t})}export{_e as a,xe as c,be as i,Ce as l,ge as n,Se as o,ye as r,ve as s,he as t};
@@ -0,0 +1 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{Rn as i}from"./toaster-C1BFyQ8i.js";import{M as a,Q as o,ct as s,r as c}from"./design-icons-QbNMZniQ.js";import{n as l,r as u}from"./diff-controls-D8wGIcHf.js";import{t as d}from"./search-x-I9Q8pgUa.js";import{t as f}from"./button-B22ANdCY.js";import{t as p}from"./project-router-C53GCY_8.js";import{m}from"./page-shell-BgabWJ3w.js";import{t as h}from"./centered-state-BgSV4e79.js";import{$t as g,Hn as _,Qt as v,s as y,sr as b,zn as x}from"./index-CGDZRQo6.js";import{t as S}from"./diff-wEs0f18C.js";var C=e(t(),1),w=n();function T({commit:e,sha:t,slot:n,heading:o=`h2`,diffRef:c,loadFileText:f,className:p}){let g=m(),[y,b]=(0,C.useState)(`unified`),[T,D]=(0,C.useState)(!0),O=(0,C.useRef)(null);E(O,t);let k=e.isError&&e.error instanceof i&&e.error.status===409;return(0,w.jsx)(`section`,{ref:O,"data-slot":n,"data-sha":t,"aria-label":`Selected commit`,className:r(`min-w-0 flex-1 scroll-mt-4 overflow-clip rounded-xl border border-border bg-card`,p),children:e.isPending?(0,w.jsx)(`p`,{"data-slot":`commit-loading`,className:`px-4 py-8 text-center text-xs text-muted-foreground`,children:`Loading commit diff…`}):e.isError?(0,w.jsx)(h,{icon:k?(0,w.jsx)(d,{}):(0,w.jsx)(s,{size:16}),tone:k?`neutral`:`danger`,heading:`h2`,title:k?`Commit not found`:`Could not load commit diff`,subtitle:e.error.message}):(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`div`,{"data-slot":`commit-meta`,className:`flex flex-wrap items-start gap-x-3 gap-y-2 border-b border-border px-4 py-3`,children:[(0,w.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(o,{className:`break-words text-sm leading-snug font-semibold text-foreground`,children:e.data.subject}),(0,w.jsxs)(`p`,{className:`mt-0.5 flex flex-wrap items-center gap-x-1.5 text-xs text-muted-foreground`,children:[(0,w.jsx)(`span`,{children:e.data.author}),(0,w.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,w.jsx)(`span`,{title:e.data.when,children:v(e.data.when)}),(0,w.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,w.jsx)(_,{sha:e.data.sha,variant:`inline`}),(0,w.jsx)(`span`,{"aria-hidden":`true`,children:`·`}),(0,w.jsx)(`span`,{"data-slot":`commit-stat`,children:(0,w.jsx)(x,{stat:e.data.stat})})]})]}),(0,w.jsxs)(`span`,{className:`flex shrink-0 items-center gap-1.5`,children:[(0,w.jsx)(u,{mode:y,wrap:T,onModeChange:b,onWrapChange:D}),(0,w.jsx)(l,{wrap:T,onWrapChange:D})]})]}),e.data.files.length===0?(0,w.jsx)(h,{icon:(0,w.jsx)(a,{size:16}),tone:`neutral`,heading:`h2`,title:`No file changes`,subtitle:`This commit carries no diff of its own — a merge commit's changes live on the commits it merged.`}):(0,w.jsx)(`div`,{className:`p-4 [--diff-sticky-top:0px]`,children:(0,w.jsx)(S,{...c?{viewRef:c}:{},...f?{loadFileText:f}:{},files:e.data.files,mode:g?y:`unified`,wrap:T,totals:!1,className:`min-w-0`},t)})]})})}function E(e,t){let n=(0,C.useRef)(t);(0,C.useLayoutEffect)(()=>{if(n.current===t)return;n.current=``;let r=e.current,i=r?.closest(`[data-slot="main"]`);if(!(!r||!i)&&r.getBoundingClientRect().top<i.getBoundingClientRect().top){let e=typeof window.matchMedia==`function`&&window.matchMedia(`(prefers-reduced-motion: reduce)`).matches;r.scrollIntoView?.({block:`start`,behavior:e?`auto`:`smooth`})}},[e,t])}function D({commit:e,sha:t,backTo:n,backLabel:r,slot:i,loadFileText:a,diffRef:o}){return(0,w.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col`,children:[(0,w.jsx)(`div`,{className:`mx-4 border-b border-border py-2`,children:(0,w.jsx)(f,{asChild:!0,variant:`ghost`,size:`sm`,"data-slot":`commit-back`,children:(0,w.jsxs)(p,{to:n,children:[(0,w.jsx)(c,{size:16,"aria-hidden":`true`}),r]})})}),(0,w.jsx)(T,{commit:e,sha:t,slot:i,loadFileText:a,...o?{diffRef:o}:{},className:`rounded-none border-0 bg-transparent`})]})}var O=56;function k({slot:e,commits:t,selectedSha:n,className:i,heading:a}){let[s,c]=(0,C.useState)(``),l=s.trim().toLowerCase(),u=l?t.filter(e=>e.subject.toLowerCase().includes(l)):t,d=u.length>150,f=(0,C.useRef)(null),p=(0,C.useRef)(null),[m,h]=(0,C.useState)(0);(0,C.useLayoutEffect)(()=>{if(!d)return;let e=()=>{let e=f.current,t=p.current;!e||!t||h(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[d]);let g=u.map(e=>(0,w.jsx)(A,{commit:e,selected:n!==void 0&&e.sha===n},e.sha));return(0,w.jsxs)(w.Fragment,{children:[(0,w.jsxs)(`label`,{className:`relative mb-3 block`,children:[(0,w.jsx)(o,{size:16,"aria-hidden":`true`,className:`pointer-events-none absolute top-3 left-3 size-4 text-muted-foreground`}),(0,w.jsx)(b,{"aria-label":`Search commit messages`,placeholder:`Search commit messages…`,value:s,onChange:e=>c(e.target.value),className:`h-10 rounded-lg border-border bg-card pl-10`})]}),(0,w.jsxs)(`div`,{ref:e=>{f.current=e,e&&(p.current=e.closest(`[data-slot="main"]`))},"data-slot":e,"data-virtualized":d,className:r(`flex flex-col divide-y divide-border rounded-xl border border-border bg-card px-3 py-1 md:px-4`,i),children:[a?(0,w.jsx)(`div`,{className:`flex min-h-11 flex-wrap items-center gap-2 py-2.5`,children:a}):null,u.length===0?(0,w.jsx)(`p`,{role:`status`,className:`py-5 text-sm text-muted-foreground`,children:`No loaded commits match your search.`}):null,d?(0,w.jsx)(y,{scrollRef:p,startMargin:m,itemSize:O,children:g}):g]})]})}function A({commit:e,selected:t}){return(0,w.jsx)(`div`,{className:`[contain-intrinsic-block-size:auto_56px] [content-visibility:auto]`,children:(0,w.jsxs)(p,{"data-slot":`commit-row`,"data-sha":e.sha,"data-selected":t?`true`:void 0,"aria-current":t?`true`:void 0,to:e.href,className:r(`flex min-h-11 min-w-0 items-start gap-2.5 rounded-md px-2 py-2.5 transition-colors hover:bg-muted`,t&&`bg-muted/70`),children:[(0,w.jsx)(a,{size:16,"aria-hidden":`true`,className:`mt-px size-4 shrink-0 text-accent-text`}),(0,w.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,w.jsx)(`span`,{"data-slot":`commit-row-subject`,title:e.subject,className:`line-clamp-2 text-[13px] leading-snug font-medium break-words text-foreground`,children:e.subject}),(0,w.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-xs text-muted-foreground`,children:[(0,w.jsx)(j,{sha:e.sha}),(0,w.jsxs)(`span`,{className:`min-w-0 truncate`,children:[e.author,` · `,(0,w.jsx)(`span`,{title:g(e.when,e.at),children:v(e.when,e.at)})]}),e.stat?(0,w.jsx)(x,{stat:e.stat}):null]})]})]})})}function j({sha:e}){return(0,w.jsx)(_,{"data-slot":`commit-sha`,sha:e,variant:`chip`})}export{T as i,j as n,D as r,k as t};
@@ -0,0 +1 @@
1
+ var e={general:[`Settings`,`General`],webhooks:[`Settings`,`General`,`Webhooks`],providers:[`Settings`,`Agent defaults`,`Providers`],projects:[`Settings`,`Projects`],worktrees:[`Settings`,`Worktrees`],sidebar:[`Settings`,`Sidebar`]};function t(t,n=` → `){return e[t].join(n)}export{t};
@@ -1 +1 @@
1
- import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{o as n}from"./dist-C_rn70hE.js";import{mt as r}from"./design-icons-QbNMZniQ.js";import{t as i}from"./button-C8jUIs8Q.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist--f2yFdPY.js";e();var f=t();function p({...e}){return(0,f.jsx)(d,{"data-slot":`dialog`,...e})}function m({...e}){return(0,f.jsx)(c,{"data-slot":`dialog-portal`,...e})}function h({className:e,...t}){return(0,f.jsx)(a,{"data-slot":`dialog-overlay`,className:n(`fixed inset-0 z-50 bg-black/50 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function g({className:e,children:t,showCloseButton:i=!0,overlayClassName:a,...o}){return(0,f.jsxs)(m,{"data-slot":`dialog-portal`,children:[(0,f.jsx)(h,{className:a}),(0,f.jsxs)(l,{"data-slot":`dialog-content`,className:n(`fixed inset-bs-[50%] start-[50%] z-50 grid max-h-[calc(100dvh-2rem)] overflow-y-auto overscroll-contain w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-hidden motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...o,children:[t,i&&(0,f.jsxs)(s,{"data-slot":`dialog-close`,className:`absolute inset-bs-4 end-4 rounded-sm opacity-70 ring-offset-background transition-opacity pointer-hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,f.jsx)(r,{}),(0,f.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function _({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`dialog-header`,className:n(`flex shrink-0 flex-col gap-2 text-center sm:text-start`,e),...t})}function v({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`dialog-body`,className:n(`min-h-0 min-w-0 overflow-y-auto overscroll-contain`,e),...t})}function y({className:e,showCloseButton:t=!1,children:r,...a}){return(0,f.jsxs)(`div`,{"data-slot":`dialog-footer`,className:n(`flex shrink-0 flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...a,children:[r,t&&(0,f.jsx)(s,{asChild:!0,children:(0,f.jsx)(i,{variant:`outline`,children:`Close`})})]})}function b({className:e,...t}){return(0,f.jsx)(u,{"data-slot":`dialog-title`,className:n(`text-lg leading-none font-semibold`,e),...t})}function x({className:e,...t}){return(0,f.jsx)(o,{"data-slot":`dialog-description`,className:n(`text-sm text-muted-foreground`,e),...t})}export{y as a,x as i,v as n,_ as o,g as r,b as s,p as t};
1
+ import"./rolldown-runtime-QTnfLwEv.js";import{i as e,t}from"./react-runtime-CCIEwYL0.js";import{o as n}from"./dist-C_rn70hE.js";import{mt as r}from"./design-icons-QbNMZniQ.js";import{t as i}from"./button-B22ANdCY.js";import{a,i as o,n as s,o as c,r as l,s as u,t as d}from"./dist--f2yFdPY.js";e();var f=t();function p({...e}){return(0,f.jsx)(d,{"data-slot":`dialog`,...e})}function m({...e}){return(0,f.jsx)(c,{"data-slot":`dialog-portal`,...e})}function h({className:e,...t}){return(0,f.jsx)(a,{"data-slot":`dialog-overlay`,className:n(`fixed inset-0 z-50 bg-black/50 motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0`,e),...t})}function g({className:e,children:t,showCloseButton:i=!0,overlayClassName:a,...o}){return(0,f.jsxs)(m,{"data-slot":`dialog-portal`,children:[(0,f.jsx)(h,{className:a}),(0,f.jsxs)(l,{"data-slot":`dialog-content`,className:n(`fixed inset-bs-[50%] start-[50%] z-50 grid max-h-[calc(100dvh-2rem)] overflow-y-auto overscroll-contain w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border bg-card p-6 shadow-modal duration-200 outline-hidden motion-safe:data-[state=closed]:animate-out data-[state=closed]:fade-out-0 motion-safe:data-[state=closed]:zoom-out-95 motion-safe:data-[state=open]:animate-in data-[state=open]:fade-in-0 motion-safe:data-[state=open]:zoom-in-95 sm:max-w-lg`,e),...o,children:[t,i&&(0,f.jsxs)(s,{"data-slot":`dialog-close`,className:`absolute inset-bs-4 end-4 rounded-sm opacity-70 ring-offset-background transition-opacity pointer-hover:opacity-100 focus:ring-2 focus:ring-ring focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4`,children:[(0,f.jsx)(r,{}),(0,f.jsx)(`span`,{className:`sr-only`,children:`Close`})]})]})]})}function _({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`dialog-header`,className:n(`flex shrink-0 flex-col gap-2 text-center sm:text-start`,e),...t})}function v({className:e,...t}){return(0,f.jsx)(`div`,{"data-slot":`dialog-body`,className:n(`min-h-0 min-w-0 overflow-y-auto overscroll-contain`,e),...t})}function y({className:e,showCloseButton:t=!1,children:r,...a}){return(0,f.jsxs)(`div`,{"data-slot":`dialog-footer`,className:n(`flex shrink-0 flex-col-reverse gap-2 sm:flex-row sm:justify-end`,e),...a,children:[r,t&&(0,f.jsx)(s,{asChild:!0,children:(0,f.jsx)(i,{variant:`outline`,children:`Close`})})]})}function b({className:e,...t}){return(0,f.jsx)(u,{"data-slot":`dialog-title`,className:n(`text-lg leading-none font-semibold`,e),...t})}function x({className:e,...t}){return(0,f.jsx)(o,{"data-slot":`dialog-description`,className:n(`text-sm text-muted-foreground`,e),...t})}export{y as a,x as i,v as n,_ as o,g as r,b as s,p as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{o as t}from"./dist-C_rn70hE.js";import{j as n,nt as r,u as i,v as a}from"./design-icons-QbNMZniQ.js";import{t as o}from"./createLucideIcon-BHp8sXmF.js";import{t as s}from"./button-B22ANdCY.js";import{n as c,p as l,r as u,t as d}from"./dropdown-menu-DjtKUK8F.js";import{gr as f}from"./index-CGDZRQo6.js";var p=o(`rows-2`,[[`rect`,{width:`18`,height:`18`,x:`3`,y:`3`,rx:`2`,key:`afitv7`}],[`path`,{d:`M3 12h18`,key:`1i2n21`}]]),m=o(`text-wrap`,[[`path`,{d:`m16 16-3 3 3 3`,key:`117b85`}],[`path`,{d:`M3 12h14.5a1 1 0 0 1 0 7H13`,key:`18xa6z`}],[`path`,{d:`M3 19h6`,key:`1ygdsz`}],[`path`,{d:`M3 5h18`,key:`1u36vt`}]]),h=e();function g({mode:e,wrap:t,onModeChange:n,onWrapChange:r,disabled:i=!1}){return(0,h.jsxs)(`span`,{className:`flex items-center gap-1.5 max-md:hidden`,children:[(0,h.jsxs)(`span`,{"data-slot":`diff-mode-toggle`,role:`group`,"aria-label":`Diff layout`,className:`inline-flex items-center rounded-lg border border-border bg-card p-0.5`,children:[(0,h.jsx)(S,{current:e,value:`unified`,onModeChange:n,disabled:i}),(0,h.jsx)(S,{current:e,value:`split`,onModeChange:n,disabled:i})]}),(0,h.jsx)(b,{wrap:t,onWrapChange:r,disabled:i,labelled:!0,className:`gap-1.5 rounded-lg px-3 text-xs font-medium`})]})}function _({wrap:e,onWrapChange:t,preview:n=!1,onPreviewChange:a,disabled:o=!1}){return(0,h.jsxs)(d,{children:[(0,h.jsx)(l,{asChild:!0,children:(0,h.jsxs)(s,{variant:`outline`,size:`sm`,"data-slot":`diff-view-menu`,className:`gap-1.5 rounded-lg px-3 text-xs font-medium md:hidden`,children:[(0,h.jsx)(r,{size:16,"aria-hidden":`true`,className:`size-4`}),`View`,(0,h.jsx)(i,{size:16,"aria-hidden":`true`,className:`size-3.5 text-muted-foreground`})]})}),(0,h.jsxs)(u,{align:`end`,"data-slot":`diff-view-menu-content`,children:[(0,h.jsx)(c,{"data-slot":`diff-view-wrap`,className:`min-h-11`,checked:e,disabled:o,onCheckedChange:e=>t(e===!0),children:`Wrap long lines`}),a?(0,h.jsx)(c,{"data-slot":`diff-view-preview`,className:`min-h-11`,checked:n,onCheckedChange:e=>a(e===!0),children:`Preview Markdown`}):null]})]})}var v=`Unavailable while Markdown preview is on`;function y(){return(0,h.jsx)(`span`,{"data-slot":`markdown-preview-hint`,role:`status`,className:`text-xs text-muted-foreground max-sm:sr-only`,children:`Full-document preview — layout and wrap are off`})}function b({wrap:e,onWrapChange:n,className:r=`rounded-lg`,disabled:i=!1,labelled:a=!1}){return(0,h.jsxs)(s,{variant:`outline`,size:a?`default`:`icon-sm`,"data-slot":`wrap-toggle`,"aria-pressed":e,"aria-label":`Wrap long lines`,title:i?v:`Wrap long lines`,disabled:i,className:t(r,e?`border-accent-text/40 bg-muted text-accent-text`:`text-muted-foreground hover:text-foreground`),onClick:()=>n(!e),children:[(0,h.jsx)(m,{"aria-hidden":`true`}),a?(0,h.jsx)(`span`,{"aria-hidden":`true`,children:`Wrap`}):null]})}function x({preview:e,onPreviewChange:n}){return(0,h.jsxs)(s,{variant:`outline`,size:`default`,"data-slot":`markdown-preview-toggle`,"aria-pressed":e,"aria-label":`Preview Markdown`,title:e?`Show Markdown as a diff`:`Preview Markdown`,className:t(`gap-1.5 rounded-lg px-0 text-xs font-medium sm:px-3`,e?`border-accent-text/40 bg-muted text-accent-text`:`text-muted-foreground hover:text-foreground`),onClick:()=>n(!e),children:[(0,h.jsx)(f,{"aria-hidden":`true`,className:`size-4`}),(0,h.jsx)(`span`,{"aria-hidden":`true`,className:`max-sm:hidden`,children:`Preview MD`})]})}function S({current:e,value:n,onModeChange:r,disabled:i}){let o=e===n;return(0,h.jsxs)(`button`,{type:`button`,"data-mode":n,"aria-pressed":o,disabled:i,title:i?v:void 0,onClick:()=>r(n),className:t(`inline-flex h-[30px] items-center gap-1.5 rounded-md px-3 text-xs font-medium capitalize transition-colors outline-hidden focus-visible:ring-2 focus-visible:ring-ring/50 disabled:opacity-50`,o?`bg-muted text-foreground`:`text-muted-foreground pointer-hover:text-foreground`),children:[n===`unified`?(0,h.jsx)(p,{"aria-hidden":`true`,className:`size-4`}):(0,h.jsx)(a,{size:16,"aria-hidden":`true`,className:`size-4`}),n]})}function C({branch:e}){return(0,h.jsxs)(`span`,{"data-slot":`branch-chip`,className:`flex min-w-0 items-center gap-1 rounded-sm border border-border bg-card px-1.5 py-px font-mono text-xs font-medium`,children:[(0,h.jsx)(n,{size:16,"aria-hidden":`true`,className:`size-3 shrink-0`}),(0,h.jsx)(`span`,{className:`truncate`,children:e})]})}export{x as a,y as i,_ as n,b as o,g as r,C as t};
@@ -0,0 +1,11 @@
1
+ import{r as e}from"./rolldown-runtime-QTnfLwEv.js";import{i as t,t as n}from"./react-runtime-CCIEwYL0.js";import{o as r}from"./dist-C_rn70hE.js";import{t as i}from"./chevron-right-BENZ-1ZN.js";import{t as a}from"./eye-B8okNWXU.js";import{t as o}from"./button-B22ANdCY.js";import{t as s}from"./diff-stat-Dy4uLuyP.js";import{En as c,at as l,s as u}from"./index-CGDZRQo6.js";import{a as d,i as f,r as p}from"./highlighter-Cfo7mLVB.js";import{n as m,r as h,t as g}from"./image-preview-CeEKI2T5.js";import{t as _}from"./textarea-vEsJAUAV.js";import{n as v,t as y}from"./markdown-BBDDg-4t.js";import{t as b}from"./markdown-BNtZVUvm.js";var x=e(t(),1),S=44;function C(e){if(e.binary===!0||e.patch===``)return 1;let t=e.patch.split(`
2
+ `),n=t.findIndex(e=>e.startsWith(`@@`));return n===-1?t.length:t.length-n}function ee(e){return C(e)*20+S}function te(e){return e.reduce((e,t)=>e+C(t),0)}function ne(e,t){let n=new URLSearchParams(e).get(`diff`);return n===`flat`||n===`virtual`?n:t>1500?`virtual`:`flat`}function w(e){return`${e.oldPath??``}→${e.path}`}function T(e){let t=0;for(let n of e.split(`
3
+ `))n.length>t&&(t=n.length);return t}var E=n();function D({path:e,side:t,line:n,hunk:r}){let i=typeof n==`number`?String(n):`${n.start}-${n.end}`;return`${r?`hunk`:`line`}:${t}:${i}:${e}`}function O(e,t){return t.kind===`del`||t.newLine===void 0?{path:e,side:`old`,line:t.oldLine??0,hunk:!1}:{path:e,side:`new`,line:t.newLine,hunk:!1}}function k(e,t){let[n,r,i]=t.newCount===0?[t.oldStart,t.oldCount,`old`]:[t.newStart,t.newCount,`new`];return{path:e,side:i,line:{start:n,end:n+Math.max(r,1)-1},hunk:!0}}function A(e){return e.hunk?`Add a note on this hunk`:`Add a note on ${e.side===`old`?`old `:``}line ${String(e.line)}`}function j(e){return typeof e.line==`number`?`Note on ${e.side===`old`?`old `:``}line ${e.line} of ${e.path}`:`Note on lines ${e.line.start}–${e.line.end} of ${e.path}`}function re(e){let[t,n]=(0,x.useState)(()=>new Map),r=(0,x.useRef)(null);if(c([...t.values()].some(e=>e.text.trim()!==``)),!e)return;let i=e=>n(t=>{let n=new Map(t);return n.delete(e),n});return{drafts:t,open:e=>{let t=D(e);r.current=t,n(n=>new Map(n).set(t,n.get(t)??{anchor:e,text:``}))},change:(e,t)=>n(n=>{let r=n.get(e);return r?new Map(n).set(e,{...r,text:t}):n}),close:i,save:n=>{let r=t.get(n);!r||r.text.trim()===``||(e(r.anchor,r.text),i(n))},takeFocus:e=>r.current===e?(r.current=null,!0):!1}}var M=r(`cursor-pointer pointer-coarse:min-h-11 pointer-coarse:min-w-11 hover:text-foreground hover:underline`,`focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`);function N({noteKey:e,draft:t,notes:n}){let r=(0,x.useRef)(null);(0,x.useEffect)(()=>{n.takeFocus(e)&&r.current?.focus()});let i=t.text.trim()===``;return(0,E.jsxs)(`div`,{"data-slot":`diff-note-editor`,className:`sticky left-0 flex w-full max-w-[100cqi] flex-col gap-2 border-y border-border bg-card px-3 py-2 font-sans`,children:[(0,E.jsx)(_,{ref:r,"data-slot":`diff-note-text`,"aria-label":j(t.anchor),placeholder:`What should change here?`,rows:2,value:t.text,onChange:t=>n.change(e,t.target.value),onKeyDown:t=>{if(t.key===`Escape`){t.preventDefault(),t.stopPropagation(),n.close(e);return}l(t)&&(t.preventDefault(),n.save(e))},className:`min-h-11 text-base md:text-[13px]`}),(0,E.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,E.jsx)(o,{type:`button`,variant:`ghost`,size:`sm`,"data-slot":`diff-note-cancel`,onClick:()=>n.close(e),children:`Cancel`}),(0,E.jsx)(o,{type:`button`,variant:`outline`,size:`sm`,"data-slot":`diff-note-save`,disabled:i,onClick:()=>n.save(e),children:`Save`})]})]})}var P=/[A-Za-z0-9_]+|\s+|[^\sA-Za-z0-9_]+/g,F=300,I=.3;function L(e,t){if(e===t)return null;let n=e.match(P)??[],r=t.match(P)??[];if(n.length===0||r.length===0||n.length>F||r.length>F)return null;let i=ie(n,r),a=r.length+1;return(i[n.length*a+r.length]??0)/Math.max(n.length,r.length)<I?null:ae(n,r,i)}function ie(e,t){let n=t.length+1,r=new Uint16Array((e.length+1)*n);for(let i=1;i<=e.length;i++)for(let a=1;a<=t.length;a++)r[i*n+a]=e[i-1]===t[a-1]?(r[(i-1)*n+(a-1)]??0)+1:Math.max(r[(i-1)*n+a]??0,r[i*n+(a-1)]??0);return r}function ae(e,t,n){let r=t.length+1,i=Array.from({length:e.length},()=>!1),a=Array.from({length:t.length},()=>!1),o=e.length,s=t.length;for(;o>0&&s>0;)e[o-1]===t[s-1]?(i[o-1]=!0,a[s-1]=!0,o--,s--):(n[(o-1)*r+s]??0)>=(n[o*r+(s-1)]??0)?o--:s--;return{del:R(e,i),add:R(t,a)}}function R(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 oe(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 se=/^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@/,ce=`… (patch truncated)`;function z(e){let t=[],n=!1,r=null,i=0,a=0,o=e.split(`
4
+ `);o.at(-1)===``&&o.pop();for(let e of o){let o=se.exec(e);if(o){r={header:e,oldStart:Number(o[1]),oldCount:o[2]===void 0?1:Number(o[2]),newStart:Number(o[3]),newCount:o[4]===void 0?1:Number(o[4]),lines:[]},i=r.oldStart,a=r.newStart,t.push(r);continue}if(e.includes(ce)){n=!0,r=null;continue}r&&(e.startsWith(`+`)?r.lines.push({kind:`add`,text:e.slice(1),newLine:a++}):e.startsWith(`-`)?r.lines.push({kind:`del`,text:e.slice(1),oldLine:i++}):e.startsWith(`\\`)||r.lines.push({kind:`context`,text:e.slice(1),oldLine:i++,newLine:a++}))}return{hunks:t,truncated:n}}function le(e,t=!1){let n=[],r=e[0];if(!r)return n;r.newStart>1&&n.push({beforeHunk:0,count:r.newStart-1,oldStart:1,newStart:1});for(let t=1;t<e.length;t++){let r=e[t-1],i=e[t],a=r.oldStart+r.oldCount,o=r.newStart+r.newCount,s=i.newStart-o;s>0&&n.push({beforeHunk:t,count:s,oldStart:a,newStart:o})}if(t){let t=e[e.length-1];n.push({beforeHunk:e.length,oldStart:t.oldStart+t.oldCount,newStart:t.newStart+t.newCount})}return n}function ue(e,t){let n=e.count===void 0?t.length:e.newStart+e.count-1,r=e.oldStart-e.newStart,i=[];for(let a=e.newStart;a<=Math.min(n,t.length);a++)i.push({kind:`context`,text:t[a-1]??``,oldLine:a+r,newLine:a});return i}function de(e,t){let n=Array.from({length:e.length}),r=Array.from({length:t.length}),i=Math.min(e.length,t.length);for(let a=0;a<i;a++){let i=L(e[a].text,t[a].text);i&&(n[a]=i.del,r[a]=i.add)}return{dels:e,adds:t,delSpans:n,addSpans:r}}function B(e,t,n){let r=0;for(;r<e.lines.length;){let i=e.lines[r];if(i.kind===`del`||i.kind===`add`){let t=[],i=[];for(;r<e.lines.length&&e.lines[r].kind===`del`;)t.push(e.lines[r++]);for(;r<e.lines.length&&e.lines[r].kind===`add`;)i.push(e.lines[r++]);n(de(t,i))}else t(i),r++}}function fe(e,t=[],n){let r=new Map(t.map(e=>[e.beforeHunk,e])),i=[],a=e=>{let t=r.get(e);if(!t)return;let a=n?.get(e);if(a)for(let e of a)i.push({type:`line`,cell:{line:e}});else i.push({type:`gap`,gap:t})};return e.forEach((e,t)=>{a(t),i.push({type:`hunk`,hunk:e}),B(e,e=>i.push({type:`line`,cell:{line:e}}),e=>{e.dels.forEach((t,n)=>i.push({type:`line`,cell:{line:t,spans:e.delSpans[n]}})),e.adds.forEach((t,n)=>i.push({type:`line`,cell:{line:t,spans:e.addSpans[n]}}))})}),a(e.length),i}function pe(e,t=[],n){let r=new Map(t.map(e=>[e.beforeHunk,e])),i=[],a=e=>{let t=r.get(e);if(!t)return;let a=n?.get(e);if(a)for(let e of a)i.push({type:`pair`,left:{line:e},right:{line:e}});else i.push({type:`gap`,gap:t})};return e.forEach((e,t)=>{a(t),i.push({type:`hunk`,hunk:e}),B(e,e=>i.push({type:`pair`,left:{line:e},right:{line:e}}),e=>{let t=Math.max(e.dels.length,e.adds.length);for(let n=0;n<t;n++){let t=e.dels[n],r=e.adds[n];i.push({type:`pair`,...t?{left:{line:t,spans:e.delSpans[n]}}:{},...r?{right:{line:r,spans:e.addSpans[n]}}:{}})}})}),a(e.length),i}function me({file:e,loadFileText:t,imageSrc:n}){let r=(0,x.useMemo)(()=>he(e),[e]),i=(0,x.useRef)(t);i.current=t;let a=(0,x.useRef)(n);a.current=n;let o=t!==void 0,[s,c]=(0,x.useState)(null);(0,x.useEffect)(()=>{let t=i.current;if(!t)return;let n=!1;return t(e.path).then(t=>!n&&c({path:e.path,text:t}),()=>!n&&c({path:e.path,text:null})),()=>{n=!0}},[e.path,e.patch,o]);let l=(0,x.useCallback)(t=>{let n=a.current,r=n?v(e.path,t):null;return r===null||!n?null:n(r)},[e.path]),u=s?.path===e.path?s:null;if(o&&u===null)return(0,E.jsx)(`p`,{role:`status`,className:`px-4 py-2.5 text-xs text-muted-foreground`,children:`Loading preview…`});let d=u?.text??null;if(d===null&&r.text===``)return(0,E.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-muted-foreground`,children:`No content changes to preview.`});let f=d!==null||r.complete?null:o?`The full file could not be loaded. Showing the changed sections only.`:`Showing the changed sections only.`;return(0,E.jsx)(`div`,{"data-slot":`diff-markdown-preview`,className:`px-4 py-5 md:px-6`,children:(0,E.jsxs)(`div`,{className:`mx-auto max-w-[72ch]`,children:[f?(0,E.jsx)(`p`,{className:`mb-4 text-xs text-muted-foreground`,children:f}):null,(0,E.jsx)(b,{document:!0,imageSrc:l,children:d??r.text})]})})}function he(e){let t=z(e.patch);return{text:t.hunks.map(e=>e.lines.filter(e=>e.kind!==`del`).map(e=>e.text).join(`
5
+ `)).join(`
6
+
7
+ ---
8
+
9
+ `),complete:e.status===`added`&&!t.truncated}}var V=`[data-scroll-root], [data-slot="main"]`,ge=1500,H=new Map;function _e(e,t){if(e){for(let n of e.querySelectorAll(`[data-slot="diff-file"]`))if(n.dataset.path===t)return n}}function ve({files:e,mode:t=`unified`,wrap:n=!1,preview:i,loadFileText:a,imageSrc:o,onOpenInApp:s,onNote:c,viewRef:l,totals:u=!0,actions:d,className:f}){let p=(0,x.useMemo)(()=>({adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length}),[e]),[m,g]=(0,x.useState)(()=>new Set),[_,v]=(0,x.useState)(()=>new Map),[b,S]=(0,x.useState)(()=>new Map),[C,T]=(0,x.useState)(i);C!==i&&(T(i),S(new Map));let D=(0,x.useCallback)((e,t)=>{S(n=>new Map(n).set(e,t))},[]),O=(0,x.useCallback)(e=>{g(t=>{let n=new Set(t);return n.delete(e)||n.add(e),n})},[]),k=(0,x.useCallback)(async(e,t)=>{if(!a)return;let n=await a(e.path);if(n===null)return;let r=ue(t,n.split(`
10
+ `));v(n=>{let i=w(e);return new Map(n).set(i,new Map(n.get(i)??H).set(t.beforeHunk,r))})},[a]),A=re(c),j=(0,x.useMemo)(()=>te(e),[e]),[M]=(0,x.useState)(()=>typeof window>`u`?``:window.location.search),N=ne(M,j),P=(0,x.useRef)(null),F=(0,x.useRef)(null),I=(0,x.useRef)(null);(0,x.useImperativeHandle)(l,()=>({scrollToPath:t=>{let n=e.findIndex(e=>e.path===t);if(n===-1)return;let r=F.current;r?r.scrollToIndex(n,{align:`start`}):_e(I.current,t)?.scrollIntoView({block:`start`,behavior:`smooth`})}}),[e]);let L=e=>{let r=w(e),c=i!==void 0&&y(e),l=c&&(b.get(r)??i);return(0,E.jsx)(xe,{file:e,open:!m.has(r),onToggle:()=>O(r),preview:l,onPreviewChange:c?e=>D(r,e):void 0,loadFileText:a,expanded:_.get(r)??H,onExpand:t=>void k(e,t),mode:t,wrap:n,canExpand:a!==void 0,imageSrc:o,onOpenInApp:s,notes:A})};return(0,E.jsxs)(`div`,{ref:e=>{I.current=e,e&&(P.current=e.closest(V))},"data-slot":`diff`,"data-mode":t,className:r(`flex min-w-0 flex-col`,f),children:[(0,E.jsxs)(`div`,{"data-slot":`diff-header`,hidden:!u&&!d,className:`flex min-h-9 flex-wrap items-center gap-x-2 gap-y-1.5 px-1 pb-3`,children:[(0,E.jsx)(h,{stat:p,hidden:!u}),d?(0,E.jsx)(`div`,{"data-slot":`diff-actions`,className:`ms-auto flex items-center gap-1.5`,children:d}):null]}),N===`virtual`?(0,E.jsx)(ye,{files:e,handleRef:F,scrollElRef:P,card:L}):(0,E.jsx)(`div`,{"data-slot":`diff-files`,"data-virtualized":`false`,children:e.map(e=>(0,E.jsx)(`div`,{"data-slot":`diff-file-slot`,style:{containIntrinsicBlockSize:`auto ${ee(e)}px`},className:`pb-3 [content-visibility:auto]`,children:L(e)},w(e)))})]})}function ye({files:e,handleRef:t,scrollElRef:n,card:r}){let i=(0,x.useRef)(null),[a,o]=(0,x.useState)(0);return(0,x.useLayoutEffect)(()=>{let e=()=>{let e=i.current,t=n.current;!e||!t||o(Math.max(0,Math.round(e.getBoundingClientRect().top-t.getBoundingClientRect().top+t.scrollTop)))};return e(),window.addEventListener(`resize`,e),()=>window.removeEventListener(`resize`,e)},[n]),(0,E.jsx)(`div`,{ref:e=>{i.current=e,e&&(n.current=e.closest(V))},"data-slot":`diff-files`,"data-virtualized":`true`,children:(0,E.jsx)(u,{ref:t,scrollRef:n,startMargin:a,children:e.map(e=>(0,E.jsx)(`div`,{"data-slot":`diff-file-slot`,className:`pb-3`,children:r(e)},w(e)))})})}var be={added:`added`,deleted:`deleted`,renamed:`renamed`,copied:`copied`};function xe({file:e,open:t,onToggle:n,expanded:o,onExpand:c,mode:l,wrap:u,preview:d,onPreviewChange:f,loadFileText:p,canExpand:m,imageSrc:h,onOpenInApp:g,notes:_}){let v=be[e.status],y=e.oldPath?`${e.oldPath} → ${e.path}`:e.path;return(0,E.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 overflow-clip rounded-md border border-border bg-card`,children:[(0,E.jsxs)(`header`,{className:`sticky top-[var(--diff-sticky-top,0px)] z-10 flex items-center rounded-t-md border-b border-border bg-card`,children:[(0,E.jsxs)(`button`,{type:`button`,"data-slot":`diff-file-header`,"aria-expanded":t,onClick:n,className:`flex min-w-0 flex-1 items-start gap-2 px-3 py-2 text-left hover:bg-muted/50`,children:[(0,E.jsx)(i,{className:r(`mbs-[1px] size-3.5 shrink-0 text-muted-foreground motion-safe:transition-transform`,t&&`rotate-90`),"aria-hidden":`true`}),(0,E.jsx)(`span`,{"data-slot":`diff-file-path`,title:y,className:`min-w-0 wrap-anywhere font-mono text-xs font-medium`,children:e.oldPath?(0,E.jsxs)(E.Fragment,{children:[(0,E.jsxs)(`span`,{className:`text-muted-foreground`,children:[e.oldPath,` → `]}),e.path]}):e.path}),v?(0,E.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:v}):null,e.image?(0,E.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:`image`}):e.binary?(0,E.jsx)(`span`,{className:`shrink-0 rounded-sm bg-muted px-1.5 py-px text-[12px] font-medium text-muted-foreground`,children:`binary`}):null,(0,E.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,E.jsx)(s,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-xs`})})]}),f?(0,E.jsxs)(`button`,{type:`button`,"data-slot":`diff-file-preview-toggle`,"aria-pressed":d,"aria-label":`Preview ${e.path} as a document`,title:d?`Show this file as a diff`:`Preview this file as a document`,onClick:()=>f(!d),className:r(`mr-1.5 inline-flex h-7 shrink-0 items-center gap-1.5 rounded-md px-2 text-[12px] font-medium max-md:h-11 max-md:px-3 pointer-coarse:h-11 pointer-coarse:px-3`,`focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-ring`,d?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/50 hover:text-foreground`),children:[(0,E.jsx)(a,{"aria-hidden":`true`,className:`size-3.5`}),`Preview`]}):null]}),t&&d?(0,E.jsx)(me,{file:e,loadFileText:p,imageSrc:h}):t?(0,E.jsx)(Se,{file:e,expanded:o,onExpand:c,mode:l,wrap:u,canExpand:m,imageSrc:h,onOpenInApp:g,notes:_}):null]})}function Se({file:e,expanded:t,onExpand:n,mode:i,wrap:a,canExpand:o,imageSrc:s,onOpenInApp:c,notes:l}){let u=(0,x.useMemo)(()=>z(e.patch),[e.patch]),d=o&&e.status!==`added`&&e.status!==`deleted`,f=(0,x.useMemo)(()=>le(u.hunks,d),[u.hunks,d]),p=(0,x.useMemo)(()=>{let e=[];u.hunks.forEach((n,r)=>{let i=t.get(r);i&&e.push(...i),e.push(...n.lines)});let n=t.get(u.hunks.length);return n&&e.push(...n),e},[u.hunks,t]),h=(0,x.useMemo)(()=>new Map(p.map((e,t)=>[e,t])),[p]),_=Ce(e.path,p),v=(0,x.useMemo)(()=>i===`unified`?fe(u.hunks,f,t):null,[i,u.hunks,f,t]),y=(0,x.useMemo)(()=>i===`split`?pe(u.hunks,f,t):null,[i,u.hunks,f,t]),b=(0,x.useMemo)(()=>i===`unified`&&!a?{minInlineSize:`calc(${T(e.patch)}ch + 7rem)`}:void 0,[i,a,e.patch]);if(m(e))return(0,E.jsx)(g,{file:e,imageSrc:s,onOpenInApp:c});if(e.binary)return(0,E.jsx)(U,{children:`Binary file — no text diff.`});if(u.hunks.length===0)return(0,E.jsx)(U,{children:u.truncated?`Patch truncated by the server.`:`No content changes (metadata only).`});let S=e=>{if(!_)return null;let t=h.get(e);return t===void 0?null:_[t]??null};return(0,E.jsxs)(`div`,{"data-slot":`diff-file-body`,"data-wrap":a||void 0,className:r(`py-1 font-mono text-xs leading-[1.7]`,!a&&`overflow-x-auto`,l&&`@container`),children:[(0,E.jsxs)(`div`,{"data-slot":`diff-rows`,style:b,className:`[&>*]:[contain-intrinsic-block-size:auto_20px] [&>*]:[content-visibility:auto]`,children:[v?v.map((t,r)=>(0,E.jsxs)(x.Fragment,{children:[(0,E.jsx)(De,{row:t,wrap:a,tokensFor:S,onExpand:d?n:void 0,path:e.path,notes:l}),(0,E.jsx)(Q,{anchors:Te(e.path,t),notes:l})]},r)):null,y?y.map((t,r)=>(0,E.jsxs)(x.Fragment,{children:[(0,E.jsx)(Oe,{row:t,wrap:a,tokensFor:S,onExpand:d?n:void 0,path:e.path,notes:l}),(0,E.jsx)(Q,{anchors:Ee(e.path,t),notes:l})]},r)):null]}),u.truncated?(0,E.jsx)(U,{children:`Patch truncated by the server — counts above remain exact.`}):null]})}function Ce(e,t){let n=(0,x.useMemo)(()=>t.length>ge?null:t.map(e=>e.text).join(`
11
+ `),[t]),r=(0,x.useMemo)(()=>d(e),[e]),[i,a]=(0,x.useState)(null);return(0,x.useEffect)(()=>{if(n===null||r===null)return;let e=!1;return p(n,r).then(t=>{e||a({text:n,tokens:t.tokens})}),()=>{e=!0}},[n,r]),n===null||r===null?null:i?.text===n?i.tokens:f(n,r)?.tokens??null}function U({children:e}){return(0,E.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-muted-foreground`,children:e})}var W={add:`bg-diff-add`,del:`bg-diff-del`,context:void 0},we={add:`+`,del:`−`,context:` `};function G({hunk:e,wrap:t,onNote:n}){let i=r(`border-y border-border/70 bg-muted/60 px-4 py-0.5 text-muted-foreground max-sm:px-2`,t?`break-words whitespace-pre-wrap`:`truncate`);return n?(0,E.jsx)(`button`,{type:`button`,"data-slot":`diff-hunk`,"aria-label":`Add a note on this hunk`,title:e.header,onClick:n,className:r(i,M,`block w-full text-left hover:bg-muted hover:no-underline`),children:e.header}):(0,E.jsx)(`div`,{"data-slot":`diff-hunk`,title:t?void 0:e.header,className:i,children:e.header})}function K({gap:e,onExpand:t}){let n=e.count===void 0?`⋯ unchanged lines to end of file`:`⋯ ${e.count} unchanged ${e.count===1?`line`:`lines`}`;return t?(0,E.jsxs)(`button`,{type:`button`,"data-slot":`diff-gap`,"aria-label":e.count===void 0?`Expand unchanged lines to end of file`:`Expand ${e.count} unchanged ${e.count===1?`line`:`lines`}`,onClick:()=>t(e),className:`block w-full border-y border-border/70 bg-muted/40 px-4 py-1 text-left text-xs text-muted-foreground hover:bg-muted hover:text-foreground`,children:[n,` — expand`]}):(0,E.jsx)(`div`,{"data-slot":`diff-gap`,className:`border-y border-border/70 bg-muted/40 px-4 py-1 text-xs text-muted-foreground`,children:n})}function q({cell:e,tokens:t,wrap:n}){let i=oe(t,e.spans,e.line.text),a=e.line.kind===`add`?`bg-diff-add-strong`:`bg-diff-del-strong`;return(0,E.jsxs)(`span`,{className:r(`min-w-0 flex-1 pr-4 max-sm:pr-1 max-sm:pl-1.5`,n?`break-words whitespace-pre-wrap`:`whitespace-pre`),children:[i.map((t,n)=>(0,E.jsx)(`span`,{"data-word":t.changed?e.line.kind:void 0,style:t.color===void 0?void 0:{color:t.color},className:t.changed?r(`rounded-[2px]`,a):void 0,children:t.text},n)),e.line.text===``?` `:``]})}function J({value:e,className:t,onNote:n}){return n&&e!==void 0?(0,E.jsx)(`button`,{type:`button`,"data-slot":`diff-gutter`,"aria-label":A(n.anchor),onClick:()=>n.notes.open(n.anchor),className:r(`flex w-10 shrink-0 items-start justify-end pr-2 text-right text-muted-foreground tabular-nums select-none max-sm:w-7 max-sm:pr-1.5`,M,t),children:e}):(0,E.jsx)(`span`,{"data-slot":`diff-gutter`,className:r(`w-10 shrink-0 pr-2 text-right text-muted-foreground tabular-nums select-none max-sm:w-7 max-sm:pr-1.5`,t),children:e??``})}function Y({kind:e}){return(0,E.jsx)(`span`,{"data-slot":`diff-marker`,className:`w-4 shrink-0 text-muted-foreground select-none max-sm:text-center`,children:we[e]})}function X(e,t,n){return n?()=>n.open(k(e,t)):void 0}function Z(e,t,n,r){if(!r)return;let i=O(e,t);return i.side===n?{anchor:i,notes:r}:void 0}function Te(e,t){return t.type===`hunk`?[k(e,t.hunk)]:t.type===`gap`?[]:[O(e,t.cell.line)]}function Ee(e,t){if(t.type===`hunk`)return[k(e,t.hunk)];if(t.type===`gap`)return[];let n=[t.left,t.right].flatMap(t=>t?[O(e,t.line)]:[]);return n.filter((e,t)=>n.findIndex(t=>D(t)===D(e))===t)}function Q({anchors:e,notes:t}){return t?e.map(e=>{let n=D(e),r=t.drafts.get(n);return r?(0,E.jsx)(N,{noteKey:n,draft:r,notes:t},n):null}):null}function De({row:e,wrap:t,tokensFor:n,onExpand:i,path:a,notes:o}){if(e.type===`hunk`)return(0,E.jsx)(G,{hunk:e.hunk,wrap:t,onNote:X(a,e.hunk,o)});if(e.type===`gap`)return(0,E.jsx)(K,{gap:e.gap,onExpand:i});let{line:s}=e.cell;return(0,E.jsxs)(`div`,{"data-slot":`diff-line`,"data-line":s.kind,className:r(`flex`,W[s.kind]),children:[(0,E.jsx)(J,{value:s.oldLine,className:`max-sm:hidden`,onNote:Z(a,s,`old`,o)}),(0,E.jsx)(J,{value:s.newLine,className:`max-sm:hidden`,onNote:Z(a,s,`new`,o)}),(0,E.jsx)(J,{value:s.newLine??s.oldLine,className:`sm:hidden`,onNote:o?{anchor:O(a,s),notes:o}:void 0}),(0,E.jsx)(Y,{kind:s.kind}),(0,E.jsx)(q,{cell:e.cell,tokens:n(s),wrap:t})]})}function Oe({row:e,wrap:t,tokensFor:n,onExpand:r,path:i,notes:a}){return e.type===`hunk`?(0,E.jsx)(G,{hunk:e.hunk,wrap:t,onNote:X(i,e.hunk,a)}):e.type===`gap`?(0,E.jsx)(K,{gap:e.gap,onExpand:r}):(0,E.jsxs)(`div`,{"data-slot":`diff-pair`,className:`grid grid-cols-2`,children:[(0,E.jsx)($,{cell:e.left,side:`old`,tokensFor:n,wrap:t,path:i,notes:a}),(0,E.jsx)($,{cell:e.right,side:`new`,tokensFor:n,wrap:t,path:i,notes:a})]})}function $({cell:e,side:t,tokensFor:n,wrap:i,path:a,notes:o}){if(!e)return(0,E.jsx)(`div`,{"data-slot":`diff-cell-empty`,className:r(`bg-muted/20`,t===`new`&&`border-l border-border/70`)});let{line:s}=e;return(0,E.jsxs)(`div`,{"data-slot":`diff-cell`,"data-line":s.kind,className:r(`flex min-w-0 overflow-x-auto`,W[s.kind],t===`new`&&`border-l border-border/70`),children:[(0,E.jsx)(J,{value:t===`old`?s.oldLine:s.newLine,onNote:Z(a,s,t,o)}),(0,E.jsx)(Y,{kind:s.kind}),(0,E.jsx)(q,{cell:e,tokens:n(s),wrap:i})]})}export{ve as DiffView};
@@ -0,0 +1,3 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/diff-view-BteEhAsF.js","assets/rolldown-runtime-QTnfLwEv.js","assets/react-runtime-CCIEwYL0.js","assets/dist-C_rn70hE.js","assets/bundle-mjs-rHxsej31.js","assets/chevron-right-BENZ-1ZN.js","assets/createLucideIcon-BHp8sXmF.js","assets/eye-B8okNWXU.js","assets/button-B22ANdCY.js","assets/diff-stat-Dy4uLuyP.js","assets/index-CGDZRQo6.js","assets/queries-jsRcJKo6.js","assets/toaster-C1BFyQ8i.js","assets/live-protocol-DMhTnCmf.js","assets/preload-helper-Czpn1I53.js","assets/chunk-KS7C4IRE-Cg8l-LDN.js","assets/label-DRXJ8ljY.js","assets/cez-idle-CdswdDRd.js","assets/run-detail-refresh-DYY7EWeq.js","assets/es2015-CUEfzDjB.js","assets/reference-chip-95DURw1q.js","assets/design-icons-QbNMZniQ.js","assets/popover-CvL6hQ5c.js","assets/dist-DudPJH39.js","assets/dist-BuF3mvCA.js","assets/attention-xl4bwNkx.js","assets/task-groups-7p6Gvpg8.js","assets/open-in-menu-CxD3RKm9.js","assets/bot-TkDIw4y-.js","assets/external-link-BE6y205O.js","assets/folder-o-AvL3y3.js","assets/smartphone-Lr8Ug2z_.js","assets/square-terminal-B6RYYieR.js","assets/dropdown-menu-DjtKUK8F.js","assets/dist-BSUJIXeE.js","assets/own-lookup-DS54wXvD.js","assets/check-OP-CVgZG.js","assets/chevron-down-CHGyCDBH.js","assets/nav-row-styles-CgP5uNp4.js","assets/folder-browser-CUUWpb8F.js","assets/loader-circle-CPBhhDbB.js","assets/play-CmVAj_fu.js","assets/search-x-I9Q8pgUa.js","assets/dist--f2yFdPY.js","assets/switch-CAKeV99j.js","assets/dist-Czz3Y5qH.js","assets/badge-DVxxThpb.js","assets/dialog-rpNyAWGb.js","assets/project-router-C53GCY_8.js","assets/read-state-DOIKdUqa.js","assets/status-dot-Drd4-nfa.js","assets/report-selection-DAPzf1Aa.js","assets/use-search-params-writer-ClMScnNe.js","assets/page-shell-BgabWJ3w.js","assets/page-shell-CEIoW56O.css","assets/format-BU7D3IfE.js","assets/command-B2Y0By1v.js","assets/project-order-AcHI4Dcl.js","assets/skills-pM_PouEs.js","assets/agent-accounts-BuceIkTR.js","assets/control-locations-kCPVEtOM.js","assets/agents-settings-path-7X6_cvUg.js","assets/centered-state-BgSV4e79.js","assets/html-report-BX3msvci.js","assets/index-18CFQ-Aq.css","assets/highlighter-Cfo7mLVB.js","assets/image-preview-CeEKI2T5.js","assets/zoomable-image-BUTgYpld.js","assets/textarea-vEsJAUAV.js","assets/markdown-BBDDg-4t.js","assets/markdown-BNtZVUvm.js","assets/chunk-BO2N2NFS-DQrpGzb-.js","assets/lib-DrPFkMXk.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{o as r}from"./dist-C_rn70hE.js";import{t as i}from"./preload-helper-Czpn1I53.js";import{t as a}from"./diff-stat-Dy4uLuyP.js";import{n as o,r as s,t as c}from"./image-preview-CeEKI2T5.js";var l=e(t(),1),u=n();function d(e){let[t,n]=(0,l.useState)(null);return(0,l.useEffect)(()=>{let e=!1;return i(()=>import(`./diff-view-BteEhAsF.js`).then(t=>{e||n({View:t.DiffView})},()=>{e||n(`failed`)}),__vite__mapDeps([0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72])),()=>{e=!0}},[]),e.files.length===0?(0,u.jsx)(`p`,{"data-slot":`diff-empty`,className:r(`px-1 text-xs text-muted-foreground`,e.className),children:`No changes.`}):t===`failed`?(0,u.jsx)(f,{...e}):t===null?(0,u.jsx)(`p`,{"data-slot":`diff-loading`,className:r(`px-1 text-xs text-muted-foreground`,e.className),children:`Loading diff…`}):(0,u.jsx)(t.View,{...e})}function f({files:e,wrap:t=!1,imageSrc:n,onOpenInApp:i,viewRef:a,totals:o=!0,actions:c,className:d}){let f={adds:e.reduce((e,t)=>e+t.adds,0),dels:e.reduce((e,t)=>e+t.dels,0),files:e.length},m=(0,l.useRef)(null);return(0,l.useImperativeHandle)(a,()=>({scrollToPath:e=>{for(let t of m.current?.querySelectorAll(`[data-slot="diff-file"]`)??[])if(t.dataset.path===e){t.scrollIntoView({block:`start`,behavior:`smooth`});return}}})),(0,u.jsxs)(`div`,{ref:m,"data-slot":`diff`,"data-fallback":`true`,className:r(`flex min-w-0 flex-col gap-3`,d),children:[(0,u.jsxs)(`div`,{"data-slot":`diff-header`,hidden:!o&&!c,className:`flex min-h-9 flex-wrap items-center gap-x-2 gap-y-1.5 px-1`,children:[(0,u.jsx)(s,{stat:f,hidden:!o}),c?(0,u.jsx)(`div`,{"data-slot":`diff-actions`,className:`ms-auto flex items-center gap-1.5`,children:c}):null]}),e.map(e=>(0,u.jsx)(p,{file:e,wrap:t,imageSrc:n,onOpenInApp:i},`${e.oldPath??``}→${e.path}`))]})}function p({file:e,wrap:t,imageSrc:n,onOpenInApp:i}){let s=e.oldPath?`${e.oldPath} → ${e.path}`:e.path;return(0,u.jsxs)(`section`,{"data-slot":`diff-file`,"data-path":e.path,className:`min-w-0 overflow-clip rounded-md border border-border bg-card`,children:[(0,u.jsxs)(`header`,{className:`flex items-start gap-2 border-b border-border px-3 py-2`,children:[(0,u.jsx)(`span`,{"data-slot":`diff-file-path`,title:s,className:`min-w-0 wrap-anywhere font-mono text-xs font-medium`,children:s}),(0,u.jsx)(`span`,{className:`ml-auto shrink-0`,children:(0,u.jsx)(a,{stat:{adds:e.adds,dels:e.dels,files:1},className:`text-xs`})})]}),o(e)?(0,u.jsx)(c,{file:e,imageSrc:n,onOpenInApp:i}):e.binary?(0,u.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-muted-foreground`,children:`Binary file — no text diff.`}):e.patch===``?(0,u.jsx)(`p`,{className:`px-4 py-2.5 text-xs text-muted-foreground`,children:`No content changes (metadata only).`}):(0,u.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
+ `).map((e,t)=>(0,u.jsxs)(`span`,{className:r(`block px-4`,e.startsWith(`+`)&&!e.startsWith(`+++`)&&`bg-diff-add`,e.startsWith(`-`)&&!e.startsWith(`---`)&&`bg-diff-del`,e.startsWith(`@@`)&&`text-muted-foreground`),children:[e,e===``?` `:``]},t))})]})}export{d as t};
@@ -0,0 +1 @@
1
+ import{t as e}from"./react-runtime-CCIEwYL0.js";import{an as t,cn as n,in as r,nn as i,on as a,rn as o,sn as s,tn as c}from"./index-CGDZRQo6.js";var l=e();function u({open:e,subject:u,onKeep:d,onDiscard:f}){return(0,l.jsx)(c,{open:e,onOpenChange:e=>!e&&d(),children:(0,l.jsxs)(r,{"data-slot":`discard-changes-dialog`,className:`sm:max-w-[560px]`,children:[(0,l.jsxs)(s,{children:[(0,l.jsx)(n,{children:`Discard unsaved changes?`}),(0,l.jsxs)(t,{children:[`Your edits to `,(0,l.jsx)(`span`,{className:`font-medium text-foreground`,children:u}),` are not saved. They are lost if you continue.`]})]}),(0,l.jsxs)(a,{children:[(0,l.jsx)(o,{"data-slot":`discard-changes-keep`,children:`Keep editing`}),(0,l.jsx)(i,{"data-slot":`discard-changes-confirm`,className:`bg-danger text-danger-foreground hover:brightness-[0.96]`,onClick:f,children:`Discard changes`})]})]})})}export{u as t};