specrails-desktop 2.46.0 → 2.48.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (259) hide show
  1. package/README.md +2 -0
  2. package/client/dist/assets/{ActivityFeedPage-CsHQPpvl.js → ActivityFeedPage-CGq6QhP5.js} +1 -1
  3. package/client/dist/assets/AgentBrowserCapture-C4GZ-kdf.js +1 -0
  4. package/client/dist/assets/AgentModeAnalyticsPane-_IPmL0ZS.js +2 -0
  5. package/client/dist/assets/AgentModeCodePane-B5WG5DOP.js +2 -0
  6. package/client/dist/assets/{AgentModeJobsPane-rnD-EPMd.js → AgentModeJobsPane-w1N_HIXh.js} +1 -1
  7. package/client/dist/assets/AgentsPage-CmwnnT46.js +87 -0
  8. package/client/dist/assets/AnalyticsPage-BUMsKtsJ.js +1 -0
  9. package/client/dist/assets/CodePage-PjgywJPS.js +3 -0
  10. package/client/dist/assets/DesktopAnalyticsPage-BXY1pH4y.js +1 -0
  11. package/client/dist/assets/DocsDialog-ccQETHKB.js +11 -0
  12. package/client/dist/assets/DocsPage-DzEgplB3.js +11 -0
  13. package/client/dist/assets/{ExportDropdown-pWZGYCv3.js → ExportDropdown-B8bBGopr.js} +1 -1
  14. package/client/dist/assets/InteractiveJobComposer-CEwGkJ8F.js +19 -0
  15. package/client/dist/assets/JobDetailModal-BYXmuTDe.js +1 -0
  16. package/client/dist/assets/JobDetailPage-CWp6MwJj.js +1 -0
  17. package/client/dist/assets/JobsPage-D1O1uyG8.js +1 -0
  18. package/client/dist/assets/{LoopBuilderPage-CtmOE4-b.js → LoopBuilderPage-DQE-7Vby.js} +2 -2
  19. package/client/dist/assets/{LoopPreviewModal-BYeLjQbr.js → LoopPreviewModal-Bk7zIXD5.js} +1 -1
  20. package/client/dist/assets/LoopsPage-CqG7mx56.js +1 -0
  21. package/client/dist/assets/MinimizedChatsContext-UpnqccPx.js +1 -0
  22. package/client/dist/assets/PluginsPage-CjgVvmpW.js +2 -0
  23. package/client/dist/assets/{ProjectSettingsDialog-DsCRIc4v.js → ProjectSettingsDialog-D6vBCoay.js} +1 -1
  24. package/client/dist/assets/{RepositoryDeliveries-BQm_3TO8.js → RepositoryDeliveries-C36ipKp_.js} +1 -1
  25. package/client/dist/assets/{RepositoryScopeSelector-DnAFtjTz.js → RepositoryScopeSelector-0Gz_fR1E.js} +1 -1
  26. package/client/dist/assets/ReviewPacketPage-Dr9RYs7q.js +1 -0
  27. package/client/dist/assets/TemplatePreviewModal-sCMHYFJo.js +1 -0
  28. package/client/dist/assets/TicketDetailModalContext-C5GgJlEt.js +14 -0
  29. package/client/dist/assets/{Trans-BwLgX6n7.js → Trans-9pHTy2fH.js} +1 -1
  30. package/client/dist/assets/{addspec-D2YIQ0GU.js → addspec-BOvgmcgk.js} +1 -1
  31. package/client/dist/assets/{addspec-B_TPJt-R.js → addspec-Clmyfn_R.js} +1 -1
  32. package/client/dist/assets/{addspec-A1lDQa4M.js → addspec-CsNaBpHp.js} +1 -1
  33. package/client/dist/assets/{addspec-CQBjzt24.js → addspec-D2tvWmmV.js} +1 -1
  34. package/client/dist/assets/{addspec-CLYLvaVP.js → addspec-D3nFwvD0.js} +1 -1
  35. package/client/dist/assets/{addspec-BPpZ_olp.js → addspec-DVLEhK3w.js} +1 -1
  36. package/client/dist/assets/{addspec-iFdQ6D99.js → addspec-DXbK-tb0.js} +1 -1
  37. package/client/dist/assets/{addspec-BHZd0N5F.js → addspec-OHG8DFEn.js} +1 -1
  38. package/client/dist/assets/agentRuntime-BUimiX__.js +1 -0
  39. package/client/dist/assets/agentRuntime-BcN97sAB.js +1 -0
  40. package/client/dist/assets/agentRuntime-Ckyg-ahT.js +1 -0
  41. package/client/dist/assets/agentRuntime-DJCwyX4t.js +1 -0
  42. package/client/dist/assets/agentRuntime-DVzPJOl0.js +1 -0
  43. package/client/dist/assets/agentRuntime-V9AZTG3c.js +1 -0
  44. package/client/dist/assets/agentRuntime-bAAjw1vw.js +1 -0
  45. package/client/dist/assets/agentRuntime-v4qKAYH-.js +1 -0
  46. package/client/dist/assets/{agents-45GbINfh.js → agents-CA5eT1d0.js} +1 -1
  47. package/client/dist/assets/{agents-DMKFStHL.js → agents-CAgy-5uS.js} +1 -1
  48. package/client/dist/assets/{agents-IUOgqT5t.js → agents-CNm6Qzlv.js} +1 -1
  49. package/client/dist/assets/{agents-ms7TwG16.js → agents-CTwbx-fb.js} +1 -1
  50. package/client/dist/assets/{agents-DaYcxAr1.js → agents-DEGV1Vao.js} +1 -1
  51. package/client/dist/assets/{agents-BHp0_FQt.js → agents-HsDF1aQU.js} +1 -1
  52. package/client/dist/assets/{agents-Bvyi3y6R.js → agents-IQjdA-z9.js} +1 -1
  53. package/client/dist/assets/{agents-rzPnqoBR.js → agents-RkGoteXh.js} +1 -1
  54. package/client/dist/assets/analytics-BNgZ1Nj7.js +1 -0
  55. package/client/dist/assets/analytics-BlypLLR6.js +1 -0
  56. package/client/dist/assets/analytics-CoEzWPx4.js +1 -0
  57. package/client/dist/assets/analytics-DFh5lSOl.js +1 -0
  58. package/client/dist/assets/analytics-DZp-DS2U.js +1 -0
  59. package/client/dist/assets/analytics-DjLlE7jS.js +1 -0
  60. package/client/dist/assets/analytics-jzCkOec3.js +1 -0
  61. package/client/dist/assets/analytics-nZIjjtCc.js +1 -0
  62. package/client/dist/assets/{dashboard-BK_mez-z.js → dashboard-C29Qwa-L.js} +1 -1
  63. package/client/dist/assets/{dashboard-BwkjxI6H.js → dashboard-CSJzf5OT.js} +1 -1
  64. package/client/dist/assets/{dashboard-C3bDKf7s.js → dashboard-CTfEtkqX.js} +1 -1
  65. package/client/dist/assets/{dashboard-Bt0cCzeG.js → dashboard-Cr4D8oMn.js} +1 -1
  66. package/client/dist/assets/{dashboard-fRrP0Kv0.js → dashboard-Csf1yGSN.js} +1 -1
  67. package/client/dist/assets/{dashboard-CdvjGfog.js → dashboard-D40HP2ks.js} +1 -1
  68. package/client/dist/assets/dashboard-DBAP2_SQ.js +1 -0
  69. package/client/dist/assets/{dashboard-B14uYXkG.js → dashboard-DMklepmz.js} +1 -1
  70. package/client/dist/assets/file-text-CFT-xXKN.js +1 -0
  71. package/client/dist/assets/{formatDistanceToNow-CeZv93iR.js → formatDistanceToNow-w_2U5pm0.js} +1 -1
  72. package/client/dist/assets/{getTimezoneOffsetInMilliseconds-DxAkjvJb.js → getTimezoneOffsetInMilliseconds-BRymg1Kk.js} +1 -1
  73. package/client/dist/assets/index-D0ScFZvR.css +2 -0
  74. package/client/dist/assets/index-DORCrgbI.js +77 -0
  75. package/client/dist/assets/jira-api-BqHbSdxK.js +1 -0
  76. package/client/dist/assets/jobs-C6qmvUAi.js +1 -0
  77. package/client/dist/assets/jobs-C9j2PuwW.js +1 -0
  78. package/client/dist/assets/jobs-DLHdDkHc.js +1 -0
  79. package/client/dist/assets/jobs-DSp9DoD_.js +1 -0
  80. package/client/dist/assets/jobs-DTQO08nJ.js +1 -0
  81. package/client/dist/assets/jobs-DoFaEl9g.js +1 -0
  82. package/client/dist/assets/jobs-Dpw6AEOP.js +1 -0
  83. package/client/dist/assets/jobs-DrF8Do8s.js +1 -0
  84. package/client/dist/assets/{narration-BSldQfjd.js → narration--hUhjM5v.js} +1 -1
  85. package/client/dist/assets/{narration-DKLjXIFI.js → narration-CHI06czm.js} +1 -1
  86. package/client/dist/assets/{narration-4OSg0b5-.js → narration-DjKB3pQZ.js} +1 -1
  87. package/client/dist/assets/{narration-BPMOQPFe.js → narration-DtCYvRLM.js} +1 -1
  88. package/client/dist/assets/{narration-D-e9ssxA.js → narration-DvLQBW9U.js} +1 -1
  89. package/client/dist/assets/{narration-DnrKC3mF.js → narration-eSx3gR0W.js} +1 -1
  90. package/client/dist/assets/{narration-Dypjxeel.js → narration-n3hOA7LY.js} +1 -1
  91. package/client/dist/assets/{narration-CvQdWdR5.js → narration-thJOeT2-.js} +1 -1
  92. package/client/dist/assets/packet-BNW8ODQw.js +1 -0
  93. package/client/dist/assets/packet-CXYvfdjy.js +1 -0
  94. package/client/dist/assets/packet-CtIlB8YE.js +1 -0
  95. package/client/dist/assets/packet-DA1SJkMH.js +1 -0
  96. package/client/dist/assets/packet-DYcWfBip.js +1 -0
  97. package/client/dist/assets/packet-DseX9yKC.js +1 -0
  98. package/client/dist/assets/packet-_m5aOy_d.js +1 -0
  99. package/client/dist/assets/packet-qOemUAm3.js +1 -0
  100. package/client/dist/assets/{project-repositories-BvBj9XH9.js → project-repositories-BsCs1PPA.js} +1 -1
  101. package/client/dist/assets/provider-capabilities-Vi1ZGvAK.js +1 -0
  102. package/client/dist/assets/settings-BsehKpty.js +1 -0
  103. package/client/dist/assets/settings-CQWob3SB.js +1 -0
  104. package/client/dist/assets/settings-CgCl0hzy.js +1 -0
  105. package/client/dist/assets/settings-DLRLd22L.js +1 -0
  106. package/client/dist/assets/settings-Dn5prAFl.js +1 -0
  107. package/client/dist/assets/settings-HZSu-K4l.js +1 -0
  108. package/client/dist/assets/{settings-DEgcA0jd.js → settings-p4OVIyRh.js} +1 -1
  109. package/client/dist/assets/settings-rddaldUp.js +1 -0
  110. package/client/dist/assets/setup-B5FHuxvB.js +1 -0
  111. package/client/dist/assets/setup-BihzXadx.js +1 -0
  112. package/client/dist/assets/setup-BtC6Hg4K.js +1 -0
  113. package/client/dist/assets/setup-C9Fy9PKQ.js +1 -0
  114. package/client/dist/assets/setup-CROyqD5N.js +1 -0
  115. package/client/dist/assets/setup-DpqzaEEA.js +1 -0
  116. package/client/dist/assets/setup-Dwzt5nO1.js +1 -0
  117. package/client/dist/assets/setup-zLEDnG7N.js +1 -0
  118. package/client/dist/assets/{spending-DNM6NAoA.js → spending-hcgxHP4O.js} +1 -1
  119. package/client/dist/assets/{useDesktop-mxHVQOdx.js → useDesktop-CAisjKWC.js} +1 -1
  120. package/client/dist/assets/{useSharedWebSocket-DnxHj8jP.js → useSharedWebSocket-BHIfW4QT.js} +2 -2
  121. package/client/dist/assets/wrench-BfmNO9Vw.js +1 -0
  122. package/client/dist/index.html +27 -26
  123. package/docs/guide/de/integrations/7-local-engines.md +37 -0
  124. package/docs/guide/en/integrations/7-local-engines.md +37 -0
  125. package/docs/guide/es/integrations/7-local-engines.md +37 -0
  126. package/docs/guide/fr/integrations/7-local-engines.md +37 -0
  127. package/docs/guide/it/integrations/7-local-engines.md +37 -0
  128. package/docs/guide/ja/integrations/7-local-engines.md +37 -0
  129. package/docs/guide/pt/integrations/7-local-engines.md +37 -0
  130. package/docs/guide/zh/integrations/7-local-engines.md +37 -0
  131. package/docs/internals/adding-a-provider.md +12 -0
  132. package/docs/internals/local-agent-runner.md +153 -0
  133. package/docs/internals/review-packet.md +8 -0
  134. package/docs/local-providers.md +215 -0
  135. package/docs/plans/implementation-efficiency-artifact.json +18 -0
  136. package/docs/plans/implementation-efficiency-evaluation.json +1817 -0
  137. package/docs/plans/implementation-efficiency-evaluation.md +41 -0
  138. package/docs/plans/implementation-efficiency-progress.md +48 -0
  139. package/docs/plans/implementation-efficiency-release.md +41 -0
  140. package/docs/plans/implementation-efficiency.md +124 -0
  141. package/local-runner/dist/specrails-local-runner.js +15815 -0
  142. package/package.json +7 -5
  143. package/server/dist/agent-chat-manager.js +8 -1
  144. package/server/dist/agent-chat-router.js +5 -2
  145. package/server/dist/agent-fence-promotion.js +53 -0
  146. package/server/dist/agent-mcp-config.js +4 -1
  147. package/server/dist/agent-runtime-bridge.js +35 -26
  148. package/server/dist/agent-runtime-controls-router.js +20 -1
  149. package/server/dist/agent-runtime-controls.js +94 -12
  150. package/server/dist/agent-runtime-effective-config.js +53 -0
  151. package/server/dist/agent-runtime-events.js +46 -0
  152. package/server/dist/agent-runtime-history.js +47 -0
  153. package/server/dist/agent-runtime-loader.js +84 -5
  154. package/server/dist/agent-runtime-metrics.js +77 -1
  155. package/server/dist/agent-runtime-package.js +205 -0
  156. package/server/dist/agent-runtime-settings-router.js +96 -5
  157. package/server/dist/agent-runtime-settings.js +163 -7
  158. package/server/dist/agent-spec-framing.js +10 -4
  159. package/server/dist/binary-probe.js +12 -0
  160. package/server/dist/blueprint-router.js +3 -2
  161. package/server/dist/chat-manager.js +5 -1
  162. package/server/dist/desktop-router.js +87 -4
  163. package/server/dist/index.js +13 -0
  164. package/server/dist/interactive-job-session.js +3 -1
  165. package/server/dist/local-engine-detection.js +118 -0
  166. package/server/dist/loop-executors.js +4 -3
  167. package/server/dist/loop-role-engines.js +129 -0
  168. package/server/dist/loop-run-manager.js +14 -6
  169. package/server/dist/mcp/tools/app-settings.js +30 -4
  170. package/server/dist/mcp/tools/rails.js +2 -1
  171. package/server/dist/pr-body.js +11 -2
  172. package/server/dist/pricing.js +15 -0
  173. package/server/dist/provider-detection.js +63 -1
  174. package/server/dist/provider-selection.js +26 -1
  175. package/server/dist/providers/index.js +4 -1
  176. package/server/dist/providers/local-adapter-registry.js +56 -0
  177. package/server/dist/providers/local-adapter.js +426 -0
  178. package/server/dist/providers/registry.js +39 -4
  179. package/server/dist/rail-isolated-launch.js +4 -3
  180. package/server/dist/rails-router.js +90 -8
  181. package/server/dist/result-event.js +17 -0
  182. package/server/dist/review-packet.js +1 -0
  183. package/server/dist/schemas/agent-runtime.schema.json +28 -3
  184. package/server/dist/schemas/fixtures/runtime-efficiency-summary.v1.json +790 -0
  185. package/server/dist/setup-manager.js +5 -1
  186. package/server/dist/spec-models.js +14 -2
  187. package/server/dist/worktree-node-modules.js +97 -65
  188. package/client/dist/assets/AgentBrowserCapture-BVcCK7x0.js +0 -1
  189. package/client/dist/assets/AgentModeAnalyticsPane-C5F3m29G.js +0 -2
  190. package/client/dist/assets/AgentModeCodePane-C5QuKsu0.js +0 -2
  191. package/client/dist/assets/AgentsPage-DiyJWZcU.js +0 -87
  192. package/client/dist/assets/AnalyticsPage-Dkmb0dnd.js +0 -1
  193. package/client/dist/assets/CodePage-C0dH99-t.js +0 -3
  194. package/client/dist/assets/DesktopAnalyticsPage-DuTjr2n8.js +0 -1
  195. package/client/dist/assets/DocsDialog-BVZJZHVR.js +0 -11
  196. package/client/dist/assets/DocsPage-D6KHTv8V.js +0 -11
  197. package/client/dist/assets/InteractiveJobComposer-Ck3PQxjN.js +0 -19
  198. package/client/dist/assets/JobDetailModal-DkoMH3ie.js +0 -1
  199. package/client/dist/assets/JobDetailPage-CBVivcl2.js +0 -1
  200. package/client/dist/assets/JobsPage-CzxEeca9.js +0 -1
  201. package/client/dist/assets/LoopsPage-6iW7g25k.js +0 -1
  202. package/client/dist/assets/MinimizedChatsContext-B6wVevPq.js +0 -1
  203. package/client/dist/assets/PluginsPage-Bf1z3WPF.js +0 -2
  204. package/client/dist/assets/ReviewPacketPage-CaXAwtR7.js +0 -1
  205. package/client/dist/assets/TemplatePreviewModal-9aRFpJ_J.js +0 -1
  206. package/client/dist/assets/TicketDetailModalContext-B1X5glzV.js +0 -14
  207. package/client/dist/assets/agentRuntime-BUagD2I_.js +0 -1
  208. package/client/dist/assets/agentRuntime-BkL70WtX.js +0 -1
  209. package/client/dist/assets/agentRuntime-CWXVqgqE.js +0 -1
  210. package/client/dist/assets/agentRuntime-CvNBdUAe.js +0 -1
  211. package/client/dist/assets/agentRuntime-D4RmeuNY.js +0 -1
  212. package/client/dist/assets/agentRuntime-DTidBWKg.js +0 -1
  213. package/client/dist/assets/agentRuntime-DhKYfyaU.js +0 -1
  214. package/client/dist/assets/agentRuntime-LL8_GLx9.js +0 -1
  215. package/client/dist/assets/analytics-47pYygtV.js +0 -1
  216. package/client/dist/assets/analytics-B0vt1g5U.js +0 -1
  217. package/client/dist/assets/analytics-BMzCvrCU.js +0 -1
  218. package/client/dist/assets/analytics-BlFN3Zwx.js +0 -1
  219. package/client/dist/assets/analytics-CZYzL-nR.js +0 -1
  220. package/client/dist/assets/analytics-DAsb9MJ8.js +0 -1
  221. package/client/dist/assets/analytics-FXQlQ2Yt.js +0 -1
  222. package/client/dist/assets/analytics-RnFCNkah.js +0 -1
  223. package/client/dist/assets/dashboard-BfBir_6o.js +0 -1
  224. package/client/dist/assets/file-text-BcLCfcWZ.js +0 -1
  225. package/client/dist/assets/index-Cfh9aaep.css +0 -2
  226. package/client/dist/assets/index-DYoyDWim.js +0 -76
  227. package/client/dist/assets/jira-api-ChjVGJx_.js +0 -1
  228. package/client/dist/assets/jobs-5PQJbdOf.js +0 -1
  229. package/client/dist/assets/jobs-B2B08Oy9.js +0 -1
  230. package/client/dist/assets/jobs-BJZtBbwb.js +0 -1
  231. package/client/dist/assets/jobs-BlWEsQb7.js +0 -1
  232. package/client/dist/assets/jobs-ConfD8xD.js +0 -1
  233. package/client/dist/assets/jobs-DMPU64ms.js +0 -1
  234. package/client/dist/assets/jobs-DojASiTp.js +0 -1
  235. package/client/dist/assets/jobs-kVHkNpB-.js +0 -1
  236. package/client/dist/assets/packet-BQ2tXfJI.js +0 -1
  237. package/client/dist/assets/packet-BdpOJ1Cy.js +0 -1
  238. package/client/dist/assets/packet-C3Ievb9R.js +0 -1
  239. package/client/dist/assets/packet-C4zJIG0Y.js +0 -1
  240. package/client/dist/assets/packet-Cx-zRuWn.js +0 -1
  241. package/client/dist/assets/packet-DUTGX52M.js +0 -1
  242. package/client/dist/assets/packet-DhsKtUPB.js +0 -1
  243. package/client/dist/assets/packet-z3LJ8Zyy.js +0 -1
  244. package/client/dist/assets/provider-capabilities-CXipwrXJ.js +0 -1
  245. package/client/dist/assets/settings-B3rWEwOx.js +0 -1
  246. package/client/dist/assets/settings-BcVoiMyw.js +0 -1
  247. package/client/dist/assets/settings-BlYvaQ7w.js +0 -1
  248. package/client/dist/assets/settings-CD5uEBiL.js +0 -1
  249. package/client/dist/assets/settings-CyhS0DLJ.js +0 -1
  250. package/client/dist/assets/settings-DCMFUGDs.js +0 -1
  251. package/client/dist/assets/settings-DmbYKyMJ.js +0 -1
  252. package/client/dist/assets/setup-2xGgu4Sk.js +0 -1
  253. package/client/dist/assets/setup-Ba11l2JA.js +0 -1
  254. package/client/dist/assets/setup-BzW4kMok.js +0 -1
  255. package/client/dist/assets/setup-COzwYhkJ.js +0 -1
  256. package/client/dist/assets/setup-CRVULhtF.js +0 -1
  257. package/client/dist/assets/setup-DgvlxwpE.js +0 -1
  258. package/client/dist/assets/setup-Dw_wYeEY.js +0 -1
  259. package/client/dist/assets/setup-ZPtEeJPW.js +0 -1
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{d as r,n as i,u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{it as o,n as s}from"./TicketDetailModalContext-B1X5glzV.js";import{m as ee,r as c}from"./useSharedWebSocket-DnxHj8jP.js";import{n as l}from"./createLucideIcon-Bjbbp_KS.js";import{a as u,r as d,s as f}from"./useDesktop-mxHVQOdx.js";import{l as p,u as m}from"./MinimizedChatsContext-B6wVevPq.js";import{n as h}from"./file-text-BcLCfcWZ.js";import{a as g,c as _,i as te,n as v,o as y,r as ne,s as b,t as re}from"./InteractiveJobComposer-Ck3PQxjN.js";import{t as ie}from"./circle-x-CMYsN4ZH.js";import{t as x}from"./download-CFHyyHcw.js";import{t as S}from"./loader-circle-DcygOQpC.js";import{t as C}from"./utils-BC4DHlz2.js";import{t as ae}from"./formatDistanceToNow-CeZv93iR.js";import{t as w}from"./button-Ccc9Dc-D.js";import{B as T,C as E,Ct as D,Nt as O,R as oe,U as k,V as A,f as j,ft as se,m as M,v as ce}from"./index-DYoyDWim.js";import{n as N}from"./job-time-BCL7wee9.js";import{t as le}from"./format-command-C0D9IPmV.js";var P=e(t(),1),F=n();function I(e,t){let n=N(e),r=(typeof t==`number`?t:N(t)?.getTime()??NaN)-(n?.getTime()??NaN);if(!Number.isFinite(r)||r<0)return`—`;let i=Math.round(r/1e3);if(i<60)return`${i}s`;let a=Math.floor(i/60),o=i%60;return a<60?`${a}m ${o}s`:`${Math.floor(a/60)}h ${a%60}m`}function L(e){let t=new Set;for(let n of e)if(n.event_type===`log`)try{let e=(JSON.parse(n.payload).line??``).match(/(?:Writing|Editing|Created?|Updated?)\s+(?:file:\s*)?([\w./\-]+\.\w+)/i);e&&t.add(e[1])}catch{}return Array.from(t).slice(0,20)}var R={steps:0,actionKey:``,actionArg:``,lastSeenIdx:0};function z(e,t){if(t.type===`reset`)return R;if(t.type===`consume`){let{events:n}=t,r=e.lastSeenIdx>n.length?n.length:e.lastSeenIdx;if(n.length<=r)return r===e.lastSeenIdx?e:{...e,lastSeenIdx:r};let{steps:i,actionKey:a,actionArg:o}=e;for(let e=r;e<n.length;e++){let t=M(n[e]);t.step&&(i+=t.stepCount??1),t.actionKey&&(a=t.actionKey,o=t.actionArg??``)}return{steps:i,actionKey:a,actionArg:o,lastSeenIdx:n.length}}return e}function ue({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=l(`jobs`),[s,ee]=(0,P.useState)(n),c=(0,P.useMemo)(()=>L(t),[t]),u=e.status===`running`,d=e.status===`completed`,[f,p]=(0,P.useState)(()=>Date.now());(0,P.useEffect)(()=>{if(!u)return;let e=window.setInterval(()=>p(Date.now()),1e3);return()=>window.clearInterval(e)},[u]);let[h,g]=(0,P.useReducer)(z,R),_=(0,P.useRef)(e.id);(0,P.useEffect)(()=>{_.current!==e.id&&(_.current=e.id,g({type:`reset`})),g({type:`consume`,events:t})},[e.id,t]);let[te,v]=(0,P.useState)(!0);(0,P.useEffect)(()=>{if(!u)return;v(!0);let e=window.setTimeout(()=>v(!1),8e3);return()=>window.clearTimeout(e)},[u,e.id]);let y=e.finished_at?I(e.started_at,e.finished_at):u?I(e.started_at,f):`—`,ne=!!e.total_cost_usd_estimated,b=e.total_cost_usd==null?null:`${ne?`~`:``}$${e.total_cost_usd.toFixed(4)}`,re=e.num_turns==null?null:String(e.num_turns),x=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),ae=x==null?null:`${(x/1e3).toFixed(1)}k`,w=(0,P.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),T=u&&h.steps===0?`connecting`:h.actionKey||`thinking`,E=j.has(T)&&h.actionArg!==``,D=j.has(T)&&!E?`working`:T,oe=E?o(`statusPanel.activity.${D}`,{arg:h.actionArg}):o(`statusPanel.activity.${D}`),k=w??(u&&h.steps===0?o(`statusPanel.activity.starting`):null),A=h.steps>0?o(`statusPanel.steps`,{count:h.steps}):null,se=o(u?`statusPanel.inProgress`:d?`statusPanel.completed`:`statusPanel.failed`),M=u?`border-accent-info/20 bg-accent-info/5`:d?`border-emerald-500/20 aurora-light:border-accent-success/30 bg-emerald-500/5 aurora-light:bg-accent-success/5`:`border-red-500/20 aurora-light:border-destructive/30 bg-red-500/5 aurora-light:bg-destructive/5`,ce=u?S:d?O:ie,N=u?`w-4 h-4 text-accent-info shrink-0 animate-spin`:d?`w-4 h-4 text-emerald-400 aurora-light:text-accent-success shrink-0`:`w-4 h-4 text-red-400 aurora-light:text-destructive shrink-0`;return(0,F.jsxs)(`div`,{className:C(`mx-4 my-2 rounded-xl border transition-colors duration-500`,M),children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>ee(!s),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,F.jsx)(ce,{className:N,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:se}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`tabular-nums`,children:y}),u?A&&(0,F.jsx)(`span`,{className:`tabular-nums`,children:A}):(0,F.jsxs)(F.Fragment,{children:[b&&(0,F.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:b}),c.length>0&&(0,F.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:c.length})})]})]}),(0,F.jsx)(m,{className:C(`w-4 h-4 text-muted-foreground/40 transition-transform duration-150 shrink-0`,s&&`rotate-180`)})]}),s&&(0,F.jsx)(`div`,{className:`px-4 pb-4 space-y-3 border-t border-border/20`,children:u?(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneInProgress`)}),(0,F.jsxs)(`div`,{className:`flex flex-col sm:flex-row gap-3 sm:items-stretch`,children:[(0,F.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 sm:w-44 shrink-0`,children:[(0,F.jsxs)(`p`,{className:`flex items-center gap-1.5 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[o(`statusPanel.duration`),(0,F.jsx)(`span`,{className:`inline-block w-1.5 h-1.5 rounded-full bg-accent-info animate-pulse`,title:o(`statusPanel.liveTooltip`),"aria-label":o(`statusPanel.liveTooltip`)})]}),(0,F.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-accent-info`,children:y})]}),(0,F.jsxs)(`div`,{className:`flex-1 flex items-center gap-2 bg-muted/10 rounded-lg px-3 py-2 min-w-0`,children:[(0,F.jsx)(S,{className:`w-3.5 h-3.5 text-accent-info shrink-0 animate-spin`,"aria-hidden":`true`}),k&&(0,F.jsx)(`span`,{className:`text-[11px] font-medium px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info shrink-0`,children:k}),(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:oe}),A&&(0,F.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,A]})]})]}),te&&(0,F.jsx)(`p`,{className:`text-[11px] text-muted-foreground/40 leading-snug`,children:o(`statusPanel.explainer`)}),(0,F.jsx)(`p`,{className:`pt-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider border-t border-accent-info/10 mt-1`,children:o(`statusPanel.zoneFinalPending`)}),(0,F.jsxs)(`div`,{className:`grid grid-cols-3 gap-2`,children:[(0,F.jsx)(H,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,F.jsx)(H,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,F.jsx)(H,{label:o(`statusPanel.tokens`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)})]})]}):(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`p`,{className:`pt-3 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:o(`statusPanel.zoneFinal`)}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 sm:grid-cols-4 gap-2`,children:[(0,F.jsx)(B,{label:o(`statusPanel.duration`),value:y}),(0,F.jsx)(V,{label:o(`statusPanel.cost`),value:b,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,F.jsx)(V,{label:o(`statusPanel.turns`),value:re,naCaption:o(`statusPanel.notAvailable`)}),(0,F.jsx)(V,{label:o(`statusPanel.tokens`),value:ae,naCaption:o(`statusPanel.notAvailable`)})]}),r&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.pipelineTotal`,{count:r.jobCount})}),(0,F.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,F.jsx)(B,{label:o(`statusPanel.totalCost`),value:r.costUnavailable?`—`:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,F.jsx)(B,{label:o(`statusPanel.totalTokens`),value:r.tokensUnavailable?`—`:`${(r.nullTokenCount??0)>0?`≥`:``}${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&!r.costUnavailable&&(0,F.jsx)(`p`,{"data-testid":`pipeline-partial-hint`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,title:o(`statusPanel.pipelinePartialTooltip`),children:o(`statusPanel.pipelinePartial`,{count:r.nullCostCount??0})}),r.costUnavailable&&(0,F.jsx)(`p`,{"data-testid":`pipeline-cost-unavailable`,className:`text-[10px] text-muted-foreground/70 mt-1.5`,children:o(`statusPanel.pipelineCostUnavailable`)}),(r.nullTokenCount??0)>0&&(0,F.jsx)(`p`,{"data-testid":`pipeline-usage-coverage-hint`,className:`text-[10px] text-muted-foreground/70 mt-1`,title:o(`statusPanel.pipelineUsageTooltip`),children:r.tokensUnavailable?o(`statusPanel.pipelineUsageUnavailable`):o(`statusPanel.pipelineUsagePartial`,{count:r.nullTokenCount??0})})]}),c.length>0&&(0,F.jsxs)(`div`,{children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider mb-1.5`,children:o(`statusPanel.filesModified`)}),(0,F.jsx)(`div`,{className:`flex flex-wrap gap-1.5`,children:c.map(e=>(0,F.jsx)(`code`,{className:`text-[10px] font-mono bg-muted/30 px-2 py-0.5 rounded text-cyan-400/80 aurora-light:text-accent-info`,children:e},e))})]})]})})]})}function B({label:e,value:t,valueClass:n}){return(0,F.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,F.jsx)(`p`,{className:C(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function V({label:e,value:t,valueClass:n,naCaption:r}){return(0,F.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2`,children:[(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:e}),(0,F.jsx)(`p`,{className:C(`text-sm font-semibold tabular-nums mt-0.5`,t==null?`text-muted-foreground`:n),children:t??`—`}),t==null&&(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:r})]})}function H({label:e,caption:t,tooltip:n}){return(0,F.jsxs)(`div`,{className:`bg-muted/20 rounded-lg px-3 py-2 ring-1 ring-accent-info/10`,title:n,children:[(0,F.jsxs)(`p`,{className:`flex items-center gap-1 text-[10px] text-muted-foreground/50 uppercase tracking-wider`,children:[e,(0,F.jsx)(_,{className:`w-2.5 h-2.5 text-muted-foreground/30`,"aria-hidden":`true`})]}),(0,F.jsx)(`p`,{className:`text-sm font-semibold tabular-nums mt-0.5 text-muted-foreground/40`,children:`—`}),(0,F.jsx)(`p`,{className:`text-[10px] text-muted-foreground/30 mt-0.5`,children:t})]})}var U=4;function de({tickets:e,onTicketClick:t}){let{t:n}=l(`jobs`),[r,i]=(0,P.useState)(!1);if(e.length===0)return null;let a=e.length>=U&&!r?e.slice(0,1):e,o=e.length-a.length;return(0,F.jsxs)(`div`,{className:`rounded-xl border border-border/40 bg-card/40 px-4 py-3 space-y-1.5`,children:[a.map(e=>(0,F.jsx)(fe,{ticket:e,onClick:()=>t(e.id)},e.id)),o>0&&(0,F.jsxs)(`button`,{type:`button`,onClick:()=>i(!0),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showMore`,{count:o}),(0,F.jsx)(m,{className:`w-3 h-3`})]}),r&&e.length>=U&&(0,F.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),className:`flex items-center gap-1 text-xs text-muted-foreground hover:text-foreground transition-colors`,children:[n(`ticketHeader.showLess`),(0,F.jsx)(p,{className:`w-3 h-3`})]})]})}function fe({ticket:e,onClick:t}){let{t:n}=l(`jobs`),r=e.title==null,i=`inline-flex items-center px-1.5 py-0.5 rounded-md text-[11px] font-mono tabular-nums shrink-0`;return r?(0,F.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:(0,F.jsx)(`span`,{className:C(i,`text-muted-foreground bg-muted/20 select-none`),title:n(`ticketHeader.deletedTooltip`),children:n(`ticketHeader.deletedTicket`,{id:e.id})})}):(0,F.jsxs)(`button`,{type:`button`,onClick:t,className:`flex items-center gap-2 min-w-0 w-full text-left group`,title:e.title??void 0,children:[(0,F.jsxs)(`span`,{className:C(i,`text-accent-primary bg-accent-primary/10 group-hover:bg-accent-primary/20 transition-colors`),children:[`#`,e.id]}),(0,F.jsx)(`span`,{className:`text-lg font-semibold text-foreground truncate group-hover:text-accent-primary transition-colors`,children:e.title})]})}var pe={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.completed`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queued`}};function W(){let{t:e}=l(`jobs`),{t}=l(`narration`),{id:n}=r(),{activeProjectId:p,projects:m}=d(),_=m.find(e=>e.id===p)?.provider,ie=a(),{openTicketDetail:S}=s(),[O,j]=(0,P.useState)(null),[M,N]=(0,P.useState)([]),[I,L]=(0,P.useState)([]),[R,z]=(0,P.useState)({}),[B,V]=(0,P.useState)([]),[H,U]=(0,P.useState)(!0),[fe,W]=(0,P.useState)(!1),[G,me]=(0,P.useState)(v),[he,K]=(0,P.useState)(null),ge=(0,P.useCallback)(e=>{me(e),ne(e)},[]),q=O?.command??null;(0,P.useEffect)(()=>{if(!o||G!==`narrated`||!p||!q)return;let e=!1,t=`command=${encodeURIComponent(q)}`;try{Promise.resolve(fetch(`${u()}/run-duration-range?${t}`)).then(e=>e&&e.ok?e.json():null).then(t=>{e||K(t?.range??null)}).catch(()=>{e||K(null)})}catch{K(null)}return()=>{e=!0}},[p,q,G]);let[_e,J]=(0,P.useState)(!1),Y=(0,P.useRef)(!1),X=(0,P.useRef)(null);(0,P.useEffect)(()=>{Y.current=!1,X.current=null,J(!1)},[n]),(0,P.useEffect)(()=>{if(!n)return;let e=new AbortController;j(null),N([]),L([]),z({}),U(!0),W(!1);async function t(){try{let t=await fetch(`${u()}/jobs/${n}`,{signal:e.signal});if(t.status===404){W(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let r=await t.json();j(r.job),N(r.events)}catch(e){if(e.name===`AbortError`)return;W(!0)}finally{e.signal.aborted||U(!1)}}return t(),()=>e.abort()},[n,p]),(0,P.useEffect)(()=>{if(!O?.pipeline_id){V([]);return}let e=O.pipeline_id;fetch(`${u()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&V(e.jobs)}).catch(()=>{})},[O?.pipeline_id,O?.status]);let Z=(0,P.useRef)(p);Z.current=p;let ve=(0,P.useRef)(null);ve.current=O?.status??null;let Q=(0,P.useRef)([]),$=(0,P.useRef)(null),ye=(0,P.useCallback)(()=>{$.current=null;let e=Q.current;e.length!==0&&(Q.current=[],N(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),be=(0,P.useCallback)(e=>{let t=Q.current;t.push(e),t.length>1e4&&(Q.current=t.slice(-8e3)),$.current||=requestAnimationFrame(ye)},[ye]);(0,P.useEffect)(()=>()=>{$.current&&cancelAnimationFrame($.current)},[]);let xe=(0,P.useCallback)(e=>{let t=e;if(!(Z.current&&t.projectId&&t.projectId!==Z.current)){if(t.type===`init`){let e=t.phaseDefinitions??[];L(e);let n={};for(let r of e)n[r.key]=t.phases?.[r.key]??`idle`;z(n)}else if(t.type===`event`&&t.jobId===n){let e={id:Date.now(),job_id:n??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp};be(e)}else if(t.type===`log`&&t.processId===n){let e={id:Date.now(),job_id:n??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp};be(e)}else if(t.type===`job.finalized`&&t.jobId===n||t.type===`runtime.continuation`&&t.jobId===n||t.type===`job.interactive`&&t.jobId===n||(t.type===`loop.run_paused`||t.type===`loop.run_resumed`)&&t.loopRunId===n)fetch(`${u()}/jobs/${n}`).then(e=>e.json()).then(e=>j(e.job)).catch(()=>{});else if(t.type===`phase`){let e=t.phase,n=t.state;z(t=>({...t,[e]:n}))}else if(t.type===`queue`){let e=t.jobs?.find(e=>e.id===n);if(e){let t=e.status,r=ve.current;j(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`||t===`running`&&r!==`running`)&&fetch(`${u()}/jobs/${n}`).then(e=>e.json()).then(e=>j(e.job)).catch(()=>{})}}}},[n,be]),{registerHandler:Se,unregisterHandler:Ce}=c();(0,P.useEffect)(()=>(Se(`job-detail-${n}`,xe),()=>Ce(`job-detail-${n}`)),[n,xe,Se,Ce]),(0,P.useEffect)(()=>{if(!n||!O||O.status!==`running`||O.hasTelemetry)return;let e=setInterval(()=>{fetch(`${u()}/jobs/${n}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&j(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[n,O?.status,O?.hasTelemetry]);async function we(){if(!n)return;let t=await oe({projectId:null,jobId:n});t.ok?f.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):t.httpStatus===null?f.error(e(`detail.toast.networkError`)):f.error(e(`detail.toast.failed`),{description:t.error})}async function Te(){if(O)try{let t=await fetch(`${u()}/jobs/${O.id}/diagnostic`);if(!t.ok){let n=await t.json().catch(()=>({}));throw Error(n.error??e(`detail.toast.exportFailedHttp`,{status:t.status}))}let n=await t.blob(),r=URL.createObjectURL(n),i=new Date().toISOString().slice(0,10),a=document.createElement(`a`);a.href=r,a.download=`specrails-diagnostic-${O.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){f.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function Ee(){if(!(!O||Y.current)){Y.current=!0,J(!0),X.current||=typeof globalThis.crypto?.randomUUID==`function`?globalThis.crypto.randomUUID():`rerun-${O.id}-${Date.now()}-${Math.random().toString(36).slice(2)}`;try{let t=await fetch(`${u()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`,"Idempotency-Key":X.current},body:JSON.stringify({rerunOfJobId:O.id})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));X.current=null,f.success(e(`detail.toast.jobRequeued`)),ie(`/jobs/${n.jobId}`)}catch(e){f.error(e.message)}finally{Y.current=!1,J(!1)}}}if(H)return(0,F.jsx)(`div`,{className:`max-w-5xl mx-auto px-4 py-6`,children:(0,F.jsxs)(`div`,{className:`space-y-3`,children:[(0,F.jsx)(`div`,{className:`h-4 w-48 bg-muted/30 rounded animate-pulse`}),(0,F.jsx)(`div`,{className:`h-20 bg-muted/30 rounded-lg animate-pulse`}),(0,F.jsx)(`div`,{className:`h-64 bg-muted/30 rounded-lg animate-pulse`})]})});if(fe||!O)return(0,F.jsxs)(`div`,{className:`max-w-5xl mx-auto px-4 py-6 flex flex-col items-center gap-3 mt-12`,children:[(0,F.jsx)(`p`,{className:`text-lg font-semibold`,children:e(`detail.notFound`)}),(0,F.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:e(`detail.notFoundDescription`,{id:n})}),(0,F.jsx)(w,{asChild:!0,variant:`outline`,size:`sm`,children:(0,F.jsxs)(i,{to:`/`,children:[(0,F.jsx)(D,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let De=pe[O.status]??pe.queued,Oe=O.status===`running`,ke=O.status===`completed`||O.status===`failed`,Ae=!!O.interactive,je=Ae&&Oe,Me=(O.tickets?.length??0)>0,Ne=O.command.startsWith(`loop:`),Pe=B.length>1?{totalCostUsd:B.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:B.some(e=>e.total_cost_usd==null),costEstimated:B.some(e=>!!e.total_cost_usd_estimated),nullCostCount:B.filter(e=>e.total_cost_usd==null).length,costUnavailable:B.every(e=>e.total_cost_usd==null),totalTokensIn:B.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:B.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:B.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:B.reduce((e,t)=>e+(t.tokens_cache_create??0),0),nullTokenCount:B.filter(e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null).length,tokensUnavailable:B.every(e=>e.tokens_in==null&&e.tokens_out==null&&e.tokens_cache_read==null&&e.tokens_cache_create==null),jobCount:B.length}:null;return(0,F.jsxs)(`div`,{"data-job-detail-surface":!0,className:`flex flex-col h-full max-w-5xl mx-auto w-full`,children:[(0,F.jsxs)(`div`,{className:`px-4 py-4 border-b border-border space-y-3`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-1 text-xs text-muted-foreground`,children:[(0,F.jsxs)(i,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,F.jsx)(D,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,F.jsx)(h,{className:`w-3 h-3`}),(0,F.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:n?.slice(0,8)})})]}),Me&&(0,F.jsx)(de,{tickets:O.tickets??[],onTicketClick:S}),(0,F.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,F.jsxs)(`div`,{className:`space-y-1 min-w-0`,children:[(0,F.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,F.jsxs)(T,{children:[(0,F.jsx)(k,{asChild:!0,children:(0,F.jsx)(`div`,{children:(0,F.jsx)(E,{variant:De.variant,children:e(De.labelKey)})})}),(0,F.jsx)(A,{children:e(De.tooltipKey)})]}),(0,F.jsx)(`code`,{className:C(`font-mono text-foreground/90 truncate`,Me?`text-xs text-muted-foreground`:`text-sm`),children:le(O.command,_)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,F.jsx)(`span`,{children:O.started_at?e(`detail.startedAgo`,{timeAgo:ae(new Date(O.started_at),{addSuffix:!0,locale:ee()})}):e(`detail.queuedWaiting`)}),O.model&&(0,F.jsx)(`span`,{className:`text-muted-foreground/40`,children:O.model})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[O.hasTelemetry&&(0,F.jsxs)(T,{children:[(0,F.jsx)(k,{asChild:!0,children:(0,F.jsxs)(w,{variant:`outline`,size:`sm`,className:`h-7`,onClick:Te,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,F.jsx)(x,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,F.jsx)(A,{children:e(`detail.exportDiagnosticTooltip`)})]}),ke&&(0,F.jsxs)(T,{children:[(0,F.jsx)(k,{asChild:!0,children:(0,F.jsxs)(w,{variant:`outline`,size:`sm`,onClick:Ee,disabled:_e,"aria-busy":_e,className:`h-7`,children:[(0,F.jsx)(se,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,F.jsx)(A,{children:e(`detail.reExecuteTooltip`)})]}),Oe&&(0,F.jsxs)(T,{children:[(0,F.jsx)(k,{asChild:!0,children:(0,F.jsx)(w,{variant:`outline`,size:`sm`,onClick:we,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(Ae?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,F.jsx)(A,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,F.jsx)(b,{phases:R,phaseDefinitions:I})]}),p&&n&&(0,F.jsx)(ce,{projectId:p,jobId:n,contextual:!0}),(O.status===`running`||O.status===`completed`||O.status===`failed`)&&(0,F.jsx)(ue,{job:O,events:M,defaultOpen:O.status===`completed`||O.status===`running`,pipelineTotals:Pe??void 0,phases:R,phaseDefinitions:I}),(0,F.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:o?(0,F.jsxs)(`div`,{className:`flex h-full flex-col`,children:[(0,F.jsx)(`div`,{className:`flex items-center gap-1 border-b border-border/50 px-3 py-1.5`,children:[`narrated`,`log`].map(e=>(0,F.jsx)(`button`,{type:`button`,onClick:()=>ge(e),"aria-pressed":G===e,"data-testid":`job-narration-mode-${e}`,className:`rounded-md px-2 py-0.5 text-[11px] font-medium transition-colors ${G===e?`bg-accent-primary/15 text-accent-primary`:`text-muted-foreground hover:bg-surface`}`,children:t(e===`narrated`?`modeNarrated`:`modeLog`)},e))}),(0,F.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:G===`narrated`?(0,F.jsx)(te,{events:M,settled:O.status!==`running`&&O.status!==`queued`,durationRange:he,elapsedMs:O.duration_ms??null,variant:`page`}):Ne?(0,F.jsx)(g,{events:M,jobStatus:O.status,variant:`page`}):(0,F.jsx)(y,{events:M})})]}):Ne?(0,F.jsx)(g,{events:M,jobStatus:O.status,variant:`page`}):(0,F.jsx)(y,{events:M})}),je&&(0,F.jsx)(re,{jobId:O.id,settleMode:O.interactiveSettleMode,initialAcceptingTurns:O.interactiveAcceptingTurns,kind:O.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{W as default};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{u as r}from"./chunk-KS7C4IRE-DEKu087k.js";import{l as i,m as a,r as o}from"./useSharedWebSocket-DnxHj8jP.js";import{n as s,t as c}from"./createLucideIcon-Bjbbp_KS.js";import{a as l,i as u,r as d,s as f}from"./useDesktop-mxHVQOdx.js";import{t as p}from"./circle-x-CMYsN4ZH.js";import{t as m}from"./trash-2-BOU3WdZZ.js";import{t as h}from"./triangle-alert-H9T4jAmh.js";import{t as g}from"./x-CBMI9ejn.js";import{M as _,a as v,i as y,j as b,l as x,o as ee,r as te,t as ne}from"./dialog-xXB2q5HJ.js";import{n as re,t as ie}from"./lib-CGdyxIWg.js";import{t as S}from"./formatDistanceToNow-CeZv93iR.js";import{t as C}from"./button-Ccc9Dc-D.js";import{B as w,C as ae,Mt as T,Nt as E,U as D,V as O,t as k,v as A,xt as j}from"./index-DYoyDWim.js";import{n as M,t as N}from"./job-time-BCL7wee9.js";import{t as P}from"./format-command-C0D9IPmV.js";import{t as F}from"./ExportDropdown-pWZGYCv3.js";var oe=c(`git-compare-arrows`,[[`circle`,{cx:`5`,cy:`6`,r:`3`,key:`1qnov2`}],[`path`,{d:`M12 6h5a2 2 0 0 1 2 2v7`,key:`1yj91y`}],[`path`,{d:`m15 9-3-3 3-3`,key:`1lwv8l`}],[`circle`,{cx:`19`,cy:`18`,r:`3`,key:`1qljk2`}],[`path`,{d:`M12 18H7a2 2 0 0 1-2-2V9`,key:`16sdep`}],[`path`,{d:`m9 15 3 3-3 3`,key:`1m3kbl`}]]),I=e(t(),1),L=n();function R(e){if(e==null)return`—`;let t=Math.round(e/1e3);return t<60?`${t}s`:`${Math.floor(t/60)}m ${t%60}s`}function z(e){return e==null?`—`:e===0?`$0`:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function B(e){return e==null?`—`:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function V({label:e,a:t,b:n,highlight:r}){return(0,L.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 py-2 border-b border-border/20 last:border-0 text-xs`,children:[(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:e}),(0,L.jsx)(`span`,{className:`font-mono text-right ${r===`a`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:t}),(0,L.jsx)(`span`,{className:`font-mono text-right ${r===`b`?`text-emerald-400 aurora-light:text-accent-success font-semibold`:``}`,children:n})]})}function H(e,t,n=!0){return e==null||t==null||e===t?null:n?e<t?`a`:`b`:e>t?`a`:`b`}function se({jobIds:e,onClose:t}){let{t:n}=s(`jobs`),[r,i]=(0,I.useState)(null),[a,o]=(0,I.useState)(!0),[c,u]=(0,I.useState)(null),{panelRef:d,panelStyle:f,headerHandleProps:m,resizeHandles:h,isFloating:v,guardBackdrop:y}=_();(0,I.useEffect)(()=>{let t=new AbortController;return fetch(`${l()}/jobs/compare?jobIds=${e.join(`,`)}`,{signal:t.signal}).then(e=>{if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i(e),o(!1)}).catch(e=>{e.name!==`AbortError`&&(u(e.message),o(!1))}),()=>t.abort()},[e]);function x(e,t){return(0,L.jsxs)(`div`,{className:`text-center space-y-1`,children:[(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-medium uppercase tracking-wider`,children:n(`comparison.jobN`,{n:t+1})}),(0,L.jsx)(`code`,{className:`text-[10px] text-foreground/70 block truncate max-w-[160px] mx-auto`,children:e.command}),(0,L.jsxs)(`div`,{className:`flex items-center justify-center gap-1 text-[10px]`,children:[e.status===`completed`?(0,L.jsx)(E,{className:`w-3 h-3 text-emerald-400 aurora-light:text-accent-success`}):(0,L.jsx)(p,{className:`w-3 h-3 text-rose-400 aurora-light:text-destructive`}),(0,L.jsx)(`span`,{className:`capitalize text-muted-foreground`,children:n(`statusLabel.${e.status}`,{defaultValue:e.status})})]}),(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground font-mono`,children:e.id.slice(0,8)})]})}return(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:y(t),children:[(0,L.jsxs)(`div`,{ref:d,className:`w-full max-w-lg rounded-xl border border-border/30 bg-popover p-5 shadow-xl space-y-4 mx-4`,onClick:e=>e.stopPropagation(),style:f,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between ${v?`cursor-grab active:cursor-grabbing`:``}`,...m,children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold`,children:n(`comparison.title`)}),(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`text-muted-foreground hover:text-foreground transition-colors`,children:(0,L.jsx)(g,{className:`w-4 h-4`})})]}),a&&(0,L.jsx)(`div`,{className:`space-y-2`,children:[0,1,2,3].map(e=>(0,L.jsx)(`div`,{className:`h-8 bg-muted/20 rounded animate-pulse`},e))}),c&&(0,L.jsx)(`p`,{className:`text-xs text-red-400 aurora-light:text-destructive`,children:n(`comparison.loadFailed`,{error:c})}),r&&(()=>{let[e,t]=r.jobs,i=H(e.durationMs,t.durationMs,!0),a=H(e.totalCostUsd,t.totalCostUsd,!0),o=H(e.tokensOut==null?null:e.tokensOut,t.tokensOut==null?null:t.tokensOut,!0);return(0,L.jsxs)(`div`,{children:[(0,L.jsxs)(`div`,{className:`grid grid-cols-3 gap-2 pb-3 border-b border-border/30 mb-1`,children:[(0,L.jsx)(`div`,{}),x(e,0),x(t,1)]}),(0,L.jsx)(V,{label:n(`comparison.duration`),a:R(e.durationMs),b:R(t.durationMs),highlight:i}),(0,L.jsx)(V,{label:n(`comparison.cost`),a:z(e.totalCostUsd),b:z(t.totalCostUsd),highlight:a}),(0,L.jsx)(V,{label:n(`comparison.tokensOut`),a:B(e.tokensOut),b:B(t.tokensOut),highlight:o}),(0,L.jsx)(V,{label:n(`comparison.tokensIn`),a:B(e.tokensIn),b:B(t.tokensIn),highlight:null}),(0,L.jsx)(V,{label:n(`comparison.cacheRead`),a:B(e.tokensCacheRead),b:B(t.tokensCacheRead),highlight:null}),(0,L.jsx)(V,{label:n(`comparison.model`),a:e.model??`—`,b:t.model??`—`,highlight:null}),(0,L.jsx)(V,{label:n(`comparison.phasesDone`),a:e.phasesCompleted.length>0?e.phasesCompleted.join(`, `):`—`,b:t.phasesCompleted.length>0?t.phasesCompleted.join(`, `):`—`,highlight:null})]})})(),r&&(0,L.jsx)(`p`,{className:`text-[10px] text-muted-foreground/60 text-center`,children:n(`comparison.betterValueHint`)})]}),(0,L.jsx)(b,{handles:h})]})}var ce={running:{variant:`running`,labelKey:`statusLabel.running`,tooltipKey:`statusTooltip.running`},completed:{variant:`success`,labelKey:`statusLabel.done`,tooltipKey:`statusTooltip.completed`},failed:{variant:`failed`,labelKey:`statusLabel.failed`,tooltipKey:`statusTooltip.failed`},canceled:{variant:`canceled`,labelKey:`statusLabel.canceled`,tooltipKey:`statusTooltip.canceled`},queued:{variant:`queued`,labelKey:`statusLabel.queued`,tooltipKey:`statusTooltip.queuedToRun`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`},skipped:{variant:`warning`,labelKey:`statusLabel.skipped`,tooltipKey:`statusTooltip.skipped`}},le=[`running`,`completed`,`failed`,`canceled`,`zombie_terminated`,`queued`,`skipped`],ue={critical:{className:`bg-red-500/15 aurora-light:bg-destructive/10 text-red-400 aurora-light:text-destructive border-red-500/30 aurora-light:border-destructive/30`,labelKey:`recent.priority.critical`},high:{className:`bg-orange-500/15 aurora-light:bg-accent-warning/10 text-orange-400 aurora-light:text-accent-warning border-orange-500/30 aurora-light:border-accent-warning/30`,labelKey:`recent.priority.high`},normal:{className:``,labelKey:`recent.priority.normal`},low:{className:`bg-gray-500/15 aurora-light:bg-muted text-gray-400 aurora-light:text-muted-foreground border-gray-500/30 aurora-light:border-border`,labelKey:`recent.priority.low`}};function de(e){return e==null||e===0?null:e<.01?`$${e.toFixed(4)}`:`$${e.toFixed(3)}`}function fe(e,t){let n=M(e),r=M(t);if(!n||!r)return null;let i=r.getTime()-n.getTime();if(i<0)return null;let a=Math.round(i/1e3);if(a<60)return`${a}s`;let o=Math.floor(a/60),s=a%60;return o<60?`${o}m ${s}s`:`${Math.floor(o/60)}h ${o%60}m`}function pe(e){return e==null||e===0?null:e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function me(e){let t=M(e);return t?S(t,{addSuffix:!0,locale:a()}):`—`}function he(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r).getTime()}function ge(e){let[t,n,r]=e.split(`-`).map(Number);return new Date(t,n-1,r+1).getTime()-1}function _e(e,t,n){if(!t&&!n)return!0;let r=M(e);if(!r)return!0;let i=r.getTime();return!(t&&i<he(t)||n&&i>ge(n))}var U=10;function W({jobs:e,isLoading:t,error:n,onRetry:i,onJobsCleared:a,onProposalClick:o,onProposalDelete:c}){let{t:u}=s(`jobs`),p=r(),{activeProjectId:g,projects:re}=d(),ie=re.find(e=>e.id===g)?.provider,[S,E]=(0,I.useState)(null),[k,A]=(0,I.useState)(``),[M,F]=(0,I.useState)(``),[R,z]=(0,I.useState)(!1),[B,V]=(0,I.useState)(``),[H,W]=(0,I.useState)(``),[G,K]=(0,I.useState)(!1),[q,J]=(0,I.useState)(null),[Y,ve]=(0,I.useState)(U),[X,ye]=(0,I.useState)(!1),[Z,Q]=(0,I.useState)([]),[be,$]=(0,I.useState)(null),{panelRef:xe,panelStyle:Se,headerHandleProps:Ce,resizeHandles:we,isFloating:Te,guardBackdrop:Ee}=_();(0,I.useEffect)(()=>{ve(U)},[e.length]);function De(){ye(e=>!e),Q([])}function Oe(e){Q(t=>{if(t.includes(e))return t.filter(t=>t!==e);if(t.length>=2)return t;let n=[...t,e];return n.length===2&&$(n),n})}let ke=e.filter(e=>S&&e.status!==S?!1:_e(N(e),k,M)),Ae=e.filter(e=>_e(N(e),B,H)).length;async function je(e){K(!0);try{let t={};e===`range`&&(B&&(t.from=new Date(he(B)).toISOString()),H&&(t.to=new Date(ge(H)).toISOString()));let n=await fetch(`${l()}/jobs`,{method:`DELETE`,headers:{"Content-Type":`application/json`},body:JSON.stringify(t)});if(n.ok){let e=await n.json();f.success(u(`recent.toast.cleared`,{count:e.deleted})),z(!1),V(``),W(``),a?.()}else f.error(u(`recent.toast.clearFailed`))}catch{f.error(u(`recent.toast.networkError`))}finally{K(!1)}}let Me=n?(0,L.jsxs)(`div`,{role:`alert`,"data-testid":`jobs-load-error`,className:`flex items-center gap-2 rounded-md border border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-destructive`,children:[(0,L.jsx)(h,{className:`h-4 w-4 shrink-0`}),(0,L.jsx)(`span`,{className:`flex-1`,children:u(`recent.loadFailed`)}),i&&(0,L.jsx)(C,{type:`button`,variant:`outline`,size:`sm`,className:`h-7`,onClick:i,disabled:t,children:u(`common:actions.retry`)})]}):null;return n&&e.length===0?(0,L.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:Me}):t&&e.length===0?(0,L.jsx)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-1`,children:[0,1,2].map(e=>(0,L.jsx)(`div`,{className:`h-9 bg-muted/30 rounded-md animate-pulse`},e))}):e.length===0?(0,L.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border/40 bg-card/50 p-8 text-center space-y-2`,children:[(0,L.jsx)(T,{className:`w-8 h-8 text-muted-foreground/30 mx-auto`}),(0,L.jsx)(`p`,{className:`text-sm font-medium text-muted-foreground`,children:u(`recent.emptyTitle`)}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground/60`,children:u(`recent.emptyDescription`)})]}):(0,L.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4 space-y-2`,children:[Me,(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:()=>E(null),className:`px-2 py-0.5 rounded text-[10px] font-medium transition-colors ${S===null?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:u(`recent.filterAll`,{count:e.length})}),le.map(t=>{let n=e.filter(e=>e.status===t).length;return n===0?null:(0,L.jsx)(`button`,{type:`button`,onClick:()=>E(S===t?null:t),className:`px-2 py-0.5 rounded text-[10px] font-medium capitalize transition-colors ${S===t?`bg-accent text-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent/50`}`,children:u(`recent.filterStatus`,{status:u(`statusName.${t}`),count:n})},t)})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(`input`,{type:`date`,value:k,onChange:e=>A(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:u(`recent.fromDate`)}),(0,L.jsx)(`input`,{type:`date`,value:M,onChange:e=>F(e.target.value),className:`h-6 rounded border border-border bg-input px-1.5 text-[10px] text-foreground`,title:u(`recent.toDate`)}),(k||M)&&(0,L.jsx)(`button`,{type:`button`,onClick:()=>{A(``),F(``)},className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors`,children:u(`recent.clear`)}),(0,L.jsxs)(w,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 transition-colors ${X?`text-foreground bg-accent`:`text-muted-foreground hover:text-foreground`}`,onClick:De,children:(0,L.jsx)(oe,{className:`w-3.5 h-3.5`})})}),(0,L.jsx)(O,{children:u(X?`recent.exitCompareMode`:`recent.compareTwoJobs`)})]}),(0,L.jsxs)(w,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(C,{variant:`ghost`,size:`sm`,className:`h-6 w-6 p-0 text-muted-foreground hover:text-destructive`,onClick:()=>z(!0),children:(0,L.jsx)(m,{className:`w-3.5 h-3.5`})})}),(0,L.jsx)(O,{children:u(`recent.clearJobs`)})]})]})]}),X&&(0,L.jsxs)(`div`,{className:`flex items-center justify-between rounded-md bg-accent/40 px-3 py-1.5 text-[10px] text-muted-foreground`,children:[(0,L.jsxs)(`span`,{children:[Z.length===0&&u(`recent.selectTwoToCompare`),Z.length===1&&u(`recent.selectOneMore`),Z.length===2&&u(`recent.readyToCompare`)]}),Z.length===2&&(0,L.jsx)(`button`,{type:`button`,className:`text-[10px] font-medium text-foreground hover:underline`,onClick:()=>$(Z),children:u(`recent.compareAction`)})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 px-3 py-1 text-[10px] font-medium text-muted-foreground uppercase tracking-wider`,children:[(0,L.jsx)(`span`,{className:`w-14`,children:u(`recent.colStatus`)}),(0,L.jsx)(`span`,{className:`flex-1 min-w-0`,children:u(`recent.colCommand`)}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 shrink-0`,children:[(0,L.jsx)(`span`,{className:`w-14 text-right`,children:u(`recent.colDuration`)}),(0,L.jsx)(`span`,{className:`w-12 text-right`,children:u(`recent.colTokens`)}),(0,L.jsx)(`span`,{className:`w-12 text-right`,children:u(`recent.colCost`)}),(0,L.jsx)(`span`,{className:`w-20 text-right`,children:u(`recent.colStarted`)})]})]}),(0,L.jsx)(`div`,{className:`space-y-0.5`,children:ke.slice(0,Y).map(e=>{let t=ce[e.status]??ce.queued,n=de(e.total_cost_usd),r=fe(e.started_at,e.finished_at),i=pe((e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0)||null),a=e.id.startsWith(`proposal:`),s=a?e.id.replace(`proposal:`,``):null,c=Z.includes(e.id),l=X&&!a&&Z.length===2&&!c,d=()=>{if(X&&!a){Oe(e.id);return}a&&s?o?.(s):p(`/jobs/${e.id}`)};return(0,L.jsxs)(`div`,{role:`button`,tabIndex:0,className:`flex items-center gap-3 px-3 py-2 rounded-md transition-colors cursor-pointer group ${c?`bg-accent/70 ring-1 ring-border`:l?`opacity-40 cursor-not-allowed`:`hover:bg-accent/50`}`,onClick:d,onKeyDown:e=>{e.target===e.currentTarget&&(e.key!==`Enter`&&e.key!==` `||(e.preventDefault(),d()))},children:[(0,L.jsxs)(w,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(`div`,{children:(0,L.jsx)(ae,{variant:t.variant,children:u(t.labelKey)})})}),(0,L.jsx)(O,{children:u(t.tooltipKey)})]}),e.priority&&e.priority!==`normal`&&(0,L.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border ${ue[e.priority].className}`,children:u(ue[e.priority].labelKey)}),e.profile_name&&(0,L.jsxs)(w,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(`span`,{className:`inline-flex items-center rounded px-1.5 py-0.5 text-[9px] font-medium border border-accent-primary/40 bg-accent-primary/10 text-accent-primary/90`,children:e.profile_name})}),(0,L.jsx)(O,{children:u(`recent.profileTooltip`,{name:e.profile_name})})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-1 flex-1 min-w-0`,children:[e.pipeline_id&&(0,L.jsxs)(w,{children:[(0,L.jsx)(D,{asChild:!0,children:(0,L.jsx)(j,{className:`w-3 h-3 text-accent-primary/60 shrink-0`})}),(0,L.jsxs)(O,{children:[u(`recent.pipelinePart`),e.depends_on_job_id&&` ${u(`recent.pipelineDependsOn`)}`,e.skip_reason&&` — ${e.skip_reason}`]})]}),(0,L.jsx)(`code`,{className:`text-xs text-foreground/80 truncate`,children:P(e.command,ie)})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3 text-[10px] text-muted-foreground shrink-0`,children:[(0,L.jsx)(`span`,{className:`w-14 text-right`,children:r??`—`}),(0,L.jsx)(`span`,{className:`w-12 text-right`,children:i?`${i}`:`—`}),(0,L.jsx)(`span`,{className:`w-12 text-right`,children:n??`—`}),(0,L.jsx)(`span`,{className:`w-20 text-right`,children:e.status===`queued`?`—`:me(e.started_at)}),a&&s&&(0,L.jsx)(`button`,{type:`button`,className:`w-4 h-4 md:opacity-0 md:group-hover:opacity-100 text-muted-foreground hover:text-destructive transition-all`,onClick:e=>{e.stopPropagation(),J(s)},title:u(`recent.deleteProposal`),children:(0,L.jsx)(m,{className:`w-3 h-3`})})]})]},e.id)})}),ke.length>Y&&(0,L.jsx)(`div`,{className:`pt-1 text-center`,children:(0,L.jsx)(`button`,{type:`button`,onClick:()=>ve(e=>e+U),className:`text-[10px] text-muted-foreground hover:text-foreground transition-colors px-3 py-1 rounded hover:bg-accent/50`,children:u(`recent.loadMore`,{count:ke.length-Y})})}),R&&(0,L.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/60 backdrop-blur-sm`,onClick:Ee(()=>z(!1)),children:[(0,L.jsxs)(`div`,{ref:xe,className:`w-80 rounded-xl border border-border/30 bg-popover p-4 shadow-lg space-y-4`,onClick:e=>e.stopPropagation(),style:Se,children:[(0,L.jsxs)(`div`,{...Ce,className:Te?`cursor-grab active:cursor-grabbing`:void 0,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:u(`recent.clearModal.title`)}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:u(`recent.clearModal.jobsInHistory`,{count:e.length})})]}),(0,L.jsx)(C,{variant:`destructive`,size:`sm`,className:`w-full`,disabled:G,onClick:()=>je(`all`),children:u(`recent.clearModal.clearAll`,{count:e.length})}),(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:u(`recent.clearModal.orByRange`)}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`input`,{type:`date`,value:B,onChange:e=>V(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:u(`recent.clearModal.fromPlaceholder`)}),(0,L.jsx)(`input`,{type:`date`,value:H,onChange:e=>W(e.target.value),className:`flex-1 h-7 rounded-md border border-border bg-input px-2 text-xs text-foreground`,placeholder:u(`recent.clearModal.toPlaceholder`)})]}),(0,L.jsx)(C,{variant:`outline`,size:`sm`,className:`w-full`,disabled:G||!B&&!H,onClick:()=>je(`range`),children:B||H?u(`recent.clearModal.clearInRange`,{count:Ae}):u(`recent.clearModal.clearRange`)})]}),(0,L.jsx)(C,{variant:`ghost`,size:`sm`,className:`w-full`,onClick:()=>z(!1),children:u(`common:actions.cancel`)})]}),(0,L.jsx)(b,{handles:we})]}),(0,L.jsx)(ne,{open:q!==null,onOpenChange:e=>!e&&J(null),children:(0,L.jsxs)(te,{className:`max-w-sm`,children:[(0,L.jsxs)(ee,{children:[(0,L.jsx)(x,{children:u(`recent.deleteProposalConfirm.title`)}),(0,L.jsx)(y,{children:u(`recent.deleteProposalConfirm.description`)})]}),(0,L.jsxs)(v,{children:[(0,L.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>J(null),children:u(`common:actions.cancel`)}),(0,L.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{q&&c?.(q),J(null)},children:u(`common:actions.delete`)})]})]})}),be&&(0,L.jsx)(se,{jobIds:be,onClose:()=>{$(null),Q([]),ye(!1)}})]})}var G={input:`page.proposal.status.input`,exploring:`page.proposal.status.exploring`,review:`page.proposal.status.review`,refining:`page.proposal.status.refining`,creating_issue:`page.proposal.status.creatingIssue`,created:`page.proposal.status.created`,cancelled:`page.proposal.status.cancelled`};function K(e){return`${i}/api/projects/${encodeURIComponent(e)}`}function q(){let[e,t]=(0,I.useState)(!1),{registerHandler:n,unregisterHandler:r}=o(),{t:i}=s(`jobs`),{activeProjectId:a}=d(),{recentJobs:c}=k(a),{data:p,isFirstLoad:m,isLoading:h,error:g,refresh:_}=u({namespace:`jobs`,projectId:a,initialValue:c,fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${K(e)}/jobs?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch jobs: ${n.status}`);return(await n.json()).jobs},pollInterval:1e4});(0,I.useEffect)(()=>(n(`jobs-runtime-continuation`,e=>{let t=e;t.type===`runtime.continuation`&&t.projectId===a&&_()}),()=>r(`jobs-runtime-continuation`)),[a,_,n,r]);let{data:y,isFirstLoad:b,isLoading:S,error:w,refresh:T}=u({namespace:`proposals`,projectId:a,initialValue:[],fetcher:async({projectId:e,signal:t})=>{let n=await fetch(`${K(e)}/propose?limit=10`,{signal:t});if(!n.ok)throw Error(`Failed to fetch proposals: ${n.status}`);return(await n.json()).proposals},pollInterval:1e4}),E={input:`queued`,exploring:`running`,review:`running`,refining:`running`,creating_issue:`running`,created:`completed`,cancelled:`canceled`},D=y.map(e=>({id:`proposal:${e.id}`,command:`/specrails:propose-feature ${e.idea.length>60?e.idea.slice(0,57)+`...`:e.idea}`,started_at:e.created_at,enqueued_at:e.created_at,status:E[e.status]??`queued`})),O=[...p,...D].sort((e,t)=>(M(N(t))?.getTime()??0)-(M(N(e))?.getTime()??0)),[j,P]=(0,I.useState)(null),oe=(0,I.useCallback)(async e=>{try{let t=await fetch(`${l()}/propose/${e}`);if(!t.ok)return;let n=await t.json();P(n.proposal)}catch{}},[]),R=(0,I.useCallback)(async e=>{try{(await fetch(`${l()}/propose/${e}`,{method:`DELETE`})).ok&&(f.success(i(`page.proposalDeleted`)),await T())}catch{}},[T,i]);return(0,L.jsxs)(`div`,{className:`max-w-4xl mx-auto px-4 py-6`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between mb-4`,children:[(0,L.jsx)(`h1`,{className:`text-sm font-semibold`,children:i(`page.title`)}),(0,L.jsx)(F,{baseUrl:`${l()}/jobs/export`,label:i(`page.exportJobs`)})]}),a&&(0,L.jsxs)(`details`,{className:`mb-4 rounded-lg border border-border`,onToggle:e=>t(e.currentTarget.open),children:[(0,L.jsx)(`summary`,{className:`cursor-pointer p-3 text-sm`,children:i(`agentRuntime:runs.title`)}),e&&(0,L.jsx)(A,{projectId:a})]}),(0,L.jsx)(W,{jobs:O,isLoading:m||b||h||S,error:g??w,onRetry:()=>{Promise.all([_(),T()])},onJobsCleared:_,onProposalClick:oe,onProposalDelete:R}),(0,L.jsx)(ne,{open:j!==null,onOpenChange:e=>!e&&P(null),children:(0,L.jsx)(te,{className:`max-w-3xl glass-card`,children:j&&(0,L.jsxs)(L.Fragment,{children:[(0,L.jsx)(ee,{children:(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(x,{className:`flex-1 min-w-0`,children:i(`page.proposal.title`)}),(0,L.jsx)(ae,{variant:j.status===`created`?`success`:j.status===`cancelled`?`destructive`:`secondary`,children:i(G[j.status]??`page.proposal.status.unknown`,{status:j.status})})]})}),(0,L.jsx)(`div`,{className:`text-xs text-muted-foreground bg-muted/20 rounded px-2 py-1 italic`,children:j.idea}),j.result_markdown?(0,L.jsx)(`div`,{className:`max-h-[400px] overflow-y-auto rounded-lg px-3 py-2 text-xs bg-muted/40`,children:(0,L.jsx)(`div`,{className:`prose prose-invert prose-xs max-w-none prose-p:my-1 prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold prose-ul:my-1 prose-ol:my-1 prose-li:my-0 prose-code:text-cyan-300 prose-code:text-[10px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded text-foreground/80`,children:(0,L.jsx)(re,{remarkPlugins:[ie],children:j.result_markdown})})}):(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground py-4 text-center`,children:i(`page.proposal.noContent`)}),j.issue_url&&(0,L.jsxs)(`div`,{className:`text-xs`,children:[i(`page.proposal.githubIssue`),` `,(0,L.jsx)(`a`,{href:j.issue_url,target:`_blank`,rel:`noopener noreferrer`,className:`text-accent-primary hover:underline`,children:j.issue_url})]}),(0,L.jsxs)(v,{children:[(0,L.jsx)(C,{variant:`destructive`,size:`sm`,onClick:()=>{R(j.id),P(null)},children:i(`common:actions.delete`)}),(0,L.jsx)(C,{variant:`ghost`,size:`sm`,onClick:()=>P(null),children:i(`common:actions.close`)})]})]})})})]})}export{q as default};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{u as r}from"./chunk-KS7C4IRE-DEKu087k.js";import{n as i,t as a}from"./createLucideIcon-Bjbbp_KS.js";import{n as o,r as s,s as c}from"./useDesktop-mxHVQOdx.js";import{t as l}from"./download-CFHyyHcw.js";import{t as u}from"./pencil-C9RkrIPZ.js";import{n as d}from"./square-Ci-PFcFe.js";import{t as f}from"./plus-CsnjfkmX.js";import{t as p}from"./sparkles-DrY8hb0X.js";import{t as m}from"./trash-2-BOU3WdZZ.js";import{t as h}from"./upload-DYMjAQ6M.js";import{a as g,i as _,l as ee,o as te,r as v,t as ne}from"./dialog-xXB2q5HJ.js";import{t as y}from"./utils-BC4DHlz2.js";import{t as b}from"./button-Ccc9Dc-D.js";import{t as re}from"./RepositoryScopeSelector-DnAFtjTz.js";import{o as x,p as ie,r as S,t as C}from"./provider-capabilities-CXipwrXJ.js";import{At as w,G as ae,S as oe,W as T,_ as E,g as D,h as O,jt as k,nt as A,x as j}from"./index-DYoyDWim.js";import{n as M}from"./TemplatePreviewModal-9aRFpJ_J.js";var N=a(`file-down`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 18v-6`,key:`17g6i2`}],[`path`,{d:`m9 15 3 3 3-3`,key:`1npd3o`}]]),P=a(`file-up`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M14 2v5a1 1 0 0 0 1 1h5`,key:`wfsgrz`}],[`path`,{d:`M12 12v6`,key:`3ahymv`}],[`path`,{d:`m15 15-3-3-3 3`,key:`15xj92`}]]),F=e(t(),1);function I(e){return{specrailsLoops:1,loops:e.map(e=>({name:e.name,description:e.description,graph:e.graph}))}}function L(e){let t=e;return!!t&&typeof t.name==`string`&&!!t.graph&&typeof t.graph==`object`}function se(e){let t;try{t=JSON.parse(e)}catch{throw Error(`invalid-json`)}let n=(Array.isArray(t)?t:Array.isArray(t?.loops)?t.loops:L(t)?[t]:[]).filter(L);if(n.length===0)throw Error(`no-loops`);return n.map(e=>({name:e.name,description:e.description??null,graph:e.graph}))}function ce(e){return e.length===1?`${e[0].name.trim().toLowerCase().replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``)||`loop`}.loop.json`:`specrails-loops-${e.length}.json`}var R=[`API`,`Automation`,`CI`,`Database`,`Debugging`,`DevOps`,`Docs`,`Git`,`Maintenance`,`Performance`,`Planning`,`Quality`,`Review`,`Security`,`Testing`];function le(e,t){let n=t.query.trim().toLowerCase(),r=t.categories;return e.filter(e=>r.length>0&&!(e.category&&r.includes(e.category))?!1:!n||`${e.name} ${e.description} ${e.tags.join(` `)} ${e.category??``} ${e.searchTerms??``}`.toLowerCase().includes(n))}function ue(e){let t=new Map;for(let n of e)n.category&&t.set(n.category,(t.get(n.category)??0)+1);let n=[];for(let e of R){let r=t.get(e);r&&(n.push({category:e,count:r}),t.delete(e))}for(let e of[...t.keys()].sort())n.push({category:e,count:t.get(e)});return n}var z=n();function de({loop:e,projects:t,onClose:n,onExecute:r}){let{t:a}=i(`loops`),o=e!==null,[s,c]=(0,F.useState)(``),[l,u]=(0,F.useState)(``),[f,p]=(0,F.useState)(``),[m,h]=(0,F.useState)(``),[y,w]=(0,F.useState)(),E=t.find(e=>e.id===(s||t[0]?.id)),D=(0,F.useMemo)(()=>E?.providers??(E?.provider?[E.provider]:[]),[E]),O=l||D[0]||``,k=(0,F.useMemo)(()=>oe(O),[O]),A=x(O),M=f&&(k.some(e=>e.value===f)||A&&ae(f))?f:j(O),N=ie(O,M),P=N.includes(m)?m:C(O,M)??``,I=N.length>0;return(0,z.jsx)(ne,{open:o,onOpenChange:e=>{e||n()},children:(0,z.jsx)(v,{movableResizable:!0,className:`max-w-sm`,children:e&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsxs)(te,{children:[(0,z.jsx)(ee,{children:a(`run.title`,{name:e.name})}),(0,z.jsx)(_,{children:a(`run.subtitle`)})]}),(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.project`)}),t.length===0?(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`run.noProjects`)}):(0,z.jsx)(`select`,{"aria-label":a(`run.project`),"data-testid":`run-project-select`,value:s||t[0]?.id,onChange:e=>{c(e.target.value),u(``),p(``),h(``),w(void 0)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:t.map(e=>(0,z.jsx)(`option`,{value:e.id,children:e.name},e.id))}),(0,z.jsx)(re,{repositories:E?.repositories??[],value:y,onChange:w}),D.length>1&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.provider`)}),(0,z.jsx)(`select`,{"aria-label":a(`run.provider`),value:O,onChange:e=>{u(e.target.value),p(``),h(``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:D.map(e=>(0,z.jsx)(`option`,{value:e,children:S(e)},e))})]}),k.length>0&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.model`)}),A?(0,z.jsx)(T,{value:M,options:k,ariaLabel:a(`run.model`),testId:`run-model-select`,className:`w-full px-2 py-1 text-xs`,onCommit:e=>{p(e),h(C(O,e)??``)}}):(0,z.jsx)(`select`,{"aria-label":a(`run.model`),"data-testid":`run-model-select`,value:M,onChange:e=>{let t=e.target.value;p(t),h(C(O,t)??``)},className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:k.map(e=>(0,z.jsx)(`option`,{value:e.value,children:e.label},e.value))})]}),I&&(0,z.jsxs)(z.Fragment,{children:[(0,z.jsx)(`label`,{className:`block text-[11px] font-medium text-muted-foreground`,children:a(`run.effort`)}),(0,z.jsx)(`select`,{"aria-label":a(`run.effort`),value:P,onChange:e=>h(e.target.value),className:`w-full text-xs rounded border border-border bg-transparent px-2 py-1 text-foreground focus:outline-none focus:ring-1 focus:ring-accent-primary/40`,children:N.map(e=>(0,z.jsx)(`option`,{value:e,children:e},e))})]}),(0,z.jsxs)(g,{children:[(0,z.jsx)(b,{variant:`ghost`,onClick:n,children:a(`common:actions.cancel`)}),(0,z.jsxs)(b,{onClick:()=>{let e=s||t[0]?.id;e&&r({projectId:e,...y?{repositoryIds:y}:{},provider:D.length>1?O:void 0,model:k.length>0?M:void 0,effort:I?P:void 0})},disabled:t.length===0,children:[(0,z.jsx)(d,{className:`w-3.5 h-3.5 mr-1.5`}),a(`run.execute`)]})]})]})})})}var B={draft:`bg-accent-secondary/15 text-accent-secondary ring-accent-secondary/40`,published:`bg-accent-success/15 text-accent-success ring-accent-success/40`};function V({status:e}){let{t}=i(`loops`);return(0,z.jsx)(`span`,{className:y(`inline-flex items-center px-1.5 py-0.5 rounded text-[10px] font-medium ring-1 ring-inset`,B[e]),children:t(`status.${e}`)})}function H({onOpenBuilder:e}={}){let{t}=i(`loops`),n=r(),a=(0,F.useCallback)(e=>e.replace(/:/g,`_`),[]),u=(0,F.useCallback)((e,n)=>t(`catalog.${a(e)}.name`,{defaultValue:n}),[t,a]),d=(0,F.useCallback)((e,n)=>t(`catalog.${a(e)}.description`,{defaultValue:n}),[t,a]),[h,re]=(0,F.useState)([]),[x,ie]=(0,F.useState)([]),[S,C]=(0,F.useState)([]),[ae,oe]=(0,F.useState)(!0),[T,j]=(0,F.useState)(null),[L,R]=(0,F.useState)(null),[B,V]=(0,F.useState)(`use`),[H,W]=(0,F.useState)(null),[G,pe]=(0,F.useState)(new Set),me=`specrails-desktop:loop-template-filter`,he=(()=>{try{let e=localStorage.getItem(me),t=e?JSON.parse(e):null;return{query:typeof t?.query==`string`?t.query:``,categories:Array.isArray(t?.categories)?t.categories:[]}}catch{return{query:``,categories:[]}}})(),[K,ge]=(0,F.useState)(he.query),[q,_e]=(0,F.useState)(he.categories);(0,F.useEffect)(()=>{try{localStorage.setItem(me,JSON.stringify({query:K,categories:q}))}catch{}},[K,q]);let ve=(0,F.useCallback)(e=>{_e(t=>t.includes(e)?t.filter(t=>t!==e):[...t,e])},[]),ye=(0,F.useCallback)(()=>{ge(``),_e([])},[]),be=(0,F.useRef)(null),{projects:xe,setActiveProjectId:Se}=s(),Ce=(0,F.useCallback)(e=>{pe(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),J=(0,F.useCallback)(e=>{if(e.length===0)return;let t=new Blob([JSON.stringify(I(e),null,2)],{type:`application/json`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=ce(e),r.click(),URL.revokeObjectURL(n)},[]),Y=(0,F.useCallback)(async()=>{try{let[e,t]=await Promise.all([E.list(),E.templates()]);re(e),ie(t)}catch{c.error(t(`errors.load`))}finally{oe(!1)}try{C(await E.factoryLoops())}catch{C([])}},[t]);(0,F.useEffect)(()=>{Y()},[Y]);let we=(0,F.useCallback)(async e=>{try{let n=se(await e.text()),{imported:r,skipped:i}=await E.importLoops(n);await Y(),r.length&&c.success(t(`import.done`,{count:r.length})),i.length&&c.warning(t(`import.skipped`,{count:i.length,names:i.join(`, `)})),!r.length&&!i.length&&c.warning(t(`import.invalid`))}catch(e){let n=e instanceof Error?e.message:``;c.error(t(n===`invalid-json`||n===`no-loops`?`import.invalid`:`errors.save`))}},[Y,t]),X=(0,F.useCallback)(t=>{e?e(t):n(`/loops/${t}/edit`)},[e,n]),Te=(0,F.useCallback)(async()=>{try{let e=await E.create({name:t(`newLoopName`)});X(e.id)}catch{c.error(t(`errors.save`))}},[t,X]),Z=(0,F.useCallback)(async e=>{try{let t=await E.fromTemplate(e);X(t.id)}catch{c.error(t(`errors.save`))}},[t,X]),Ee=(0,F.useCallback)(async e=>{try{let t=await E.forkFactory(e);X(t.id)}catch{c.error(t(`errors.save`))}},[t,X]),De=(0,F.useCallback)(async({projectId:e,provider:r,model:i,effort:a,repositoryIds:o})=>{let s=H;if(s){W(null);try{let{loopRunId:l}=await E.runStandalone(e,s.id,{aiEngine:r,model:i,reasoning_effort:a,...o?{repositoryIds:o}:{}});Se(e),n(`/jobs/${l}`),c.success(t(`run.launched`,{name:s.name}))}catch{c.error(t(`errors.save`))}}},[H,n,Se,t]),Oe=(0,F.useCallback)(e=>{V(`fork`),R({id:e.id,name:u(e.id,e.name),description:d(e.id,e.description),tags:e.requiredCapability?[e.requiredCapability]:e.claudeOnly?[`claude-only`]:[],graph:e.graph})},[u,d]),ke=(0,F.useCallback)(async e=>{try{await E.publish(e),await Y()}catch(e){e instanceof D?c.error(t(`errors.publishInvalid`)):c.error(t(`errors.save`))}},[t,Y]),Ae=(0,F.useCallback)(async e=>{try{await E.unpublish(e),await Y()}catch{c.error(t(`errors.save`))}},[t,Y]),je=(0,F.useCallback)(async e=>{try{await E.duplicate(e),await Y()}catch{c.error(t(`errors.save`))}},[t,Y]),Me=(0,F.useCallback)(e=>j(e),[]),Ne=(0,F.useCallback)(async()=>{let e=T;if(e){j(null);try{await E.remove(e),await Y()}catch{c.error(t(`errors.save`))}}},[T,t,Y]),Q=h.filter(e=>e.status===`draft`),$=h.filter(e=>e.status===`published`),Pe=ue(x),Fe=le(x.map(e=>({...e,searchTerms:`${u(e.id,e.name)} ${d(e.id,e.description)} ${e.category?t(`categories.${e.category}`,{defaultValue:e.category}):``}`})),{query:K,categories:q}),Ie=K.trim()!==``||q.length>0;return(0,z.jsxs)(`div`,{className:`h-full overflow-y-auto`,children:[(0,z.jsxs)(`div`,{className:`max-w-5xl mx-auto px-6 py-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-start justify-between mb-6`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2.5`,children:[(0,z.jsx)(A,{className:`w-5 h-5 text-accent-primary`}),(0,z.jsxs)(`div`,{children:[(0,z.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:t(`title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-0.5`,children:t(`subtitle`)})]})]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[G.size>0&&(0,z.jsxs)(`button`,{type:`button`,onClick:()=>J(h.filter(e=>G.has(e.id))),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,z.jsx)(N,{className:`w-3.5 h-3.5`}),t(`actions.export`),` (`,G.size,`)`]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>be.current?.click(),className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium border border-border text-foreground hover:bg-muted`,children:[(0,z.jsx)(P,{className:`w-3.5 h-3.5`}),t(`actions.import`)]}),(0,z.jsx)(`input`,{ref:be,type:`file`,accept:`application/json,.json`,className:`hidden`,onChange:e=>{let t=e.target.files?.[0];t&&we(t),e.target.value=``}}),(0,z.jsxs)(`button`,{type:`button`,onClick:Te,className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-md text-xs font-medium bg-accent-primary text-white hover:bg-accent-primary/90`,children:[(0,z.jsx)(f,{className:`w-3.5 h-3.5`}),t(`newLoop`)]})]})]}),ae?(0,z.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`…`}):(0,z.jsxs)(`div`,{className:`space-y-8`,children:[Q.length===0&&$.length===0&&(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-8 text-center`,children:[(0,z.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:t(`empty.title`)}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:t(`empty.body`)})]}),$.length>0&&(0,z.jsx)(U,{title:t(`sections.published`),children:$.map(e=>(0,z.jsx)(fe,{loop:e,selected:G.has(e.id),onToggleSelect:()=>Ce(e.id),onEdit:()=>X(e.id),onUnpublish:()=>Ae(e.id),onDuplicate:()=>je(e.id),onExport:()=>J([e]),onDelete:()=>Me(e.id),onRun:O(e.graph)?void 0:()=>W(e)},e.id))}),Q.length>0&&(0,z.jsx)(U,{title:t(`sections.drafts`),children:Q.map(e=>(0,z.jsx)(fe,{loop:e,selected:G.has(e.id),onToggleSelect:()=>Ce(e.id),onEdit:()=>X(e.id),onPublish:()=>ke(e.id),onDuplicate:()=>je(e.id),onExport:()=>J([e]),onDelete:()=>Me(e.id)},e.id))}),S.length>0&&(0,z.jsx)(U,{title:t(`sections.builtIn`),children:S.map(e=>(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`factory-loop-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(A,{className:`w-3.5 h-3.5 text-accent-primary`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground`,children:u(e.id,e.name)}),(0,z.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:t(`builtInBadge`)})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:d(e.id,e.description)}),e.launchable===!1&&(0,z.jsxs)(`p`,{className:`text-[11px] text-accent-info/90 flex items-start gap-1.5`,"data-testid":`factory-loop-automatic`,children:[(0,z.jsx)(p,{className:`w-3 h-3 mt-0.5 shrink-0`,"aria-hidden":!0}),t(`automaticOnly`)]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Oe(e),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(w,{className:`w-3 h-3`}),t(`actions.preview`)]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>void Ee(e.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(k,{className:`w-3 h-3`}),t(`actions.fork`)]})]})]},e.id))}),x.length>0&&(0,z.jsxs)(`section`,{children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 mb-2 flex-wrap`,children:[(0,z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground`,children:t(`sections.templates`)}),(0,z.jsx)(`input`,{type:`search`,value:K,onChange:e=>ge(e.target.value),placeholder:t(`gallery.search`),"aria-label":t(`gallery.search`),"data-testid":`template-search`,className:`h-7 w-48 max-w-full rounded-md border border-border bg-surface/40 px-2.5 text-xs text-foreground placeholder:text-muted-foreground/70 focus:outline-none focus:ring-1 focus:ring-accent-primary`})]}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5 mb-3`,"data-testid":`category-chips`,children:[Pe.map(({category:e,count:n})=>{let r=q.includes(e);return(0,z.jsxs)(`button`,{type:`button`,"aria-pressed":r,onClick:()=>ve(e),className:y(`inline-flex items-center gap-1 h-6 px-2 rounded-full text-[11px] border transition-colors`,r?`border-accent-primary bg-accent-primary/15 text-accent-primary`:`border-border bg-surface/40 text-muted-foreground hover:text-foreground hover:bg-muted`),children:[t(`categories.${e}`,{defaultValue:e}),(0,z.jsx)(`span`,{className:`opacity-60 tabular-nums`,children:n})]},e)}),Ie&&(0,z.jsx)(`button`,{type:`button`,onClick:ye,className:`inline-flex items-center h-6 px-2 rounded-full text-[11px] text-accent-primary hover:underline`,children:t(`gallery.clearFilter`)})]}),Fe.length===0?(0,z.jsxs)(`div`,{className:`rounded-lg border border-dashed border-border p-6 text-center`,"data-testid":`template-empty`,children:[(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`gallery.noResults`)}),(0,z.jsx)(`button`,{type:`button`,onClick:ye,className:`mt-2 text-xs text-accent-primary hover:underline`,children:t(`gallery.clearFilter`)})]}):(0,z.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:Fe.map(e=>(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`template-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,z.jsx)(p,{className:`w-3.5 h-3.5 text-accent-highlight flex-shrink-0`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:u(e.id,e.name)}),e.category&&(0,z.jsx)(`span`,{className:`ml-auto px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info flex-shrink-0`,children:t(`categories.${e.category}`,{defaultValue:e.category})})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground flex-1`,children:d(e.id,e.description)}),(0,z.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1`,children:[O(e.graph)?(0,z.jsx)(`span`,{title:t(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:t(`gallery.needsSpec`)}):(0,z.jsx)(`span`,{title:t(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:t(`gallery.standalone`)}),e.tags.map(e=>(0,z.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>{V(`use`),R({...e,name:u(e.id,e.name),description:d(e.id,e.description)})},className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(w,{className:`w-3 h-3`}),t(`actions.preview`)]}),(0,z.jsxs)(`button`,{type:`button`,onClick:()=>Z(e.id),className:`inline-flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs border border-border hover:bg-muted text-foreground`,children:[(0,z.jsx)(l,{className:`w-3 h-3`}),t(`actions.use`)]})]})]},e.id))})]})]})]}),(0,z.jsx)(ne,{open:T!==null,onOpenChange:e=>{e||j(null)},children:(0,z.jsxs)(v,{className:`max-w-sm`,children:[(0,z.jsxs)(te,{children:[(0,z.jsxs)(ee,{className:`flex items-center gap-2`,children:[(0,z.jsx)(m,{className:`w-4 h-4 text-destructive`}),h.find(e=>e.id===T)?.name??t(`actions.delete`)]}),(0,z.jsx)(_,{children:t(`confirmDelete`)})]}),(0,z.jsxs)(g,{children:[(0,z.jsx)(b,{variant:`ghost`,onClick:()=>j(null),children:t(`common:actions.cancel`)}),(0,z.jsx)(b,{variant:`destructive`,onClick:()=>void Ne(),children:t(`common:actions.delete`)})]})]})}),(0,z.jsx)(M,{template:L,mode:B,onClose:()=>R(null),onUse:e=>{R(null),B===`fork`?Ee(e):Z(e)}}),(0,z.jsx)(de,{loop:H?{id:H.id,name:H.name}:null,projects:xe.map(e=>({id:e.id,name:e.name,providers:o(e),repositories:e.repositories})),onClose:()=>W(null),onExecute:De})]})}function U({title:e,children:t}){return(0,z.jsxs)(`section`,{children:[(0,z.jsx)(`h2`,{className:`text-xs font-semibold uppercase tracking-wide text-muted-foreground mb-2`,children:e}),(0,z.jsx)(`div`,{className:`grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-3`,children:t})]})}function fe({loop:e,selected:t,onToggleSelect:n,onEdit:r,onPublish:a,onUnpublish:o,onDuplicate:s,onExport:c,onDelete:f,onRun:p}){let{t:g}=i(`loops`),_=e.graph?.nodes?.length??0;return(0,z.jsxs)(`div`,{className:`rounded-lg border border-border bg-card p-3 flex flex-col gap-2`,"data-testid":`loop-card`,children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-2 min-w-0`,children:[(0,z.jsx)(`input`,{type:`checkbox`,checked:t,onChange:n,"aria-label":g(`actions.select`,{name:e.name}),className:`accent-accent-primary flex-shrink-0`}),(0,z.jsx)(`span`,{className:`text-sm font-medium text-foreground truncate`,children:e.name})]}),(0,z.jsx)(V,{status:e.status})]}),(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:g(`card.nodes`,{count:_})}),(0,z.jsxs)(`div`,{className:`flex items-center gap-1 flex-wrap`,children:[p&&(0,z.jsx)(W,{icon:d,label:g(`actions.run`),onClick:p}),(0,z.jsx)(W,{icon:u,label:g(`actions.edit`),onClick:r}),a&&(0,z.jsx)(W,{icon:h,label:g(`actions.publish`),onClick:a}),o&&(0,z.jsx)(W,{icon:l,label:g(`actions.unpublish`),onClick:o}),(0,z.jsx)(W,{icon:k,label:g(`actions.duplicate`),onClick:s}),(0,z.jsx)(W,{icon:N,label:g(`actions.export`),onClick:c}),(0,z.jsx)(W,{icon:m,label:g(`actions.delete`),onClick:f,danger:!0})]})]})}function W({icon:e,label:t,onClick:n,danger:r}){return(0,z.jsx)(`button`,{type:`button`,onClick:n,title:t,"aria-label":t,className:y(`inline-flex items-center justify-center w-7 h-7 rounded-md transition-colors`,r?`text-muted-foreground hover:text-destructive hover:bg-destructive/10`:`text-muted-foreground hover:text-foreground hover:bg-muted`),children:(0,z.jsx)(e,{className:`w-3.5 h-3.5`})})}export{H as default};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{t as r}from"./react-dom-DiWzBDP9.js";import{u as i}from"./chunk-KS7C4IRE-DEKu087k.js";import{r as a}from"./useSharedWebSocket-DnxHj8jP.js";import{n as o,t as s}from"./createLucideIcon-Bjbbp_KS.js";import{r as c}from"./useDesktop-mxHVQOdx.js";import{t as l}from"./sparkles-DrY8hb0X.js";import{t as u}from"./x-CBMI9ejn.js";var d=s(`arrow-up`,[[`path`,{d:`m5 12 7-7 7 7`,key:`hav0vg`}],[`path`,{d:`M12 19V5`,key:`x0mq9r`}]]),f=s(`check`,[[`path`,{d:`M20 6 9 17l-5-5`,key:`1gmf2c`}]]),p=s(`chevron-down`,[[`path`,{d:`m6 9 6 6 6-6`,key:`qrunsl`}]]),m=s(`chevron-up`,[[`path`,{d:`m18 15-6-6-6 6`,key:`153udz`}]]),h=s(`external-link`,[[`path`,{d:`M15 3h6v6`,key:`1q9fwt`}],[`path`,{d:`M10 14 21 3`,key:`gplh6r`}],[`path`,{d:`M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6`,key:`a6xqqp`}]]),g=s(`messages-square`,[[`path`,{d:`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,key:`1n2ejm`}],[`path`,{d:`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`,key:`1qfcsi`}]]),_=e(t(),1),v=[`title`,`description`,`labels`,`priority`,`acceptanceCriteria`,`repositoryIds`],y={title:``,description:``,labels:[],priority:`medium`,acceptanceCriteria:[]};function b(e){return!e||typeof e!=`object`?!1:e.type===`spec_draft.update`}var x=e(r(),1),S=n(),C=42;function w(e){let t=e.replace(/\s+/g,` `).trim();return t.length<=C?t:t.slice(0,C-1).trimEnd()+`…`}function T({chat:e,projectName:t,onRestore:n,onClose:r}){let{t:i}=o(`chat`),a=w(e.label);return(0,S.jsxs)(`div`,{"data-testid":`minimized-chat-chip-${e.id}`,className:`grid items-start gap-2 w-full max-w-full`,style:{gridTemplateColumns:`auto minmax(0, 1fr) auto`},children:[(0,S.jsx)(E,{kind:e.kind}),(0,S.jsxs)(`button`,{type:`button`,onClick:n,className:`min-w-0 text-left focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50 rounded overflow-hidden`,"aria-label":i(`chip.restore`,{label:e.label}),title:e.label,children:[(0,S.jsx)(`div`,{className:`text-sm font-medium text-foreground truncate`,children:a}),(0,S.jsx)(`div`,{className:`text-[11px] text-muted-foreground mt-0.5 truncate`,children:i(`chip.continueEditing`,{projectName:t})})]}),(0,S.jsx)(`button`,{type:`button`,onClick:r,className:`flex items-center justify-center w-6 h-6 rounded text-muted-foreground hover:text-foreground hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-accent-primary/50`,"aria-label":i(`chip.close`,{label:e.label}),children:(0,S.jsx)(u,{className:`w-3.5 h-3.5`})})]})}function E({kind:e}){let{t}=o(`chat`);return(0,S.jsx)(e===`ai-edit`?l:g,{className:`w-4 h-4 text-accent-primary flex-shrink-0 mt-0.5`,"aria-label":t(e===`ai-edit`?`chip.kindAiEdit`:`chip.kindExploreSpec`)})}function D({chats:e,projects:t,hidden:n,onRestore:r,onClose:i}){let{t:a}=o(`chat`),s=(0,_.useMemo)(()=>{let e=new Map;for(let n of t)e.set(n.id,n.name);return e},[t]),c=(0,_.useMemo)(()=>[...e].sort((e,t)=>t.createdAt-e.createdAt),[e]);return n||c.length===0?null:(0,x.createPortal)((0,S.jsxs)(`div`,{"data-testid":`minimized-chats-dock`,"aria-label":a(`dock.minimizedSessions`,{count:c.length}),className:`fixed bottom-4 right-14 z-[70] flex flex-col-reverse gap-2 w-[320px] max-w-[calc(100vw-15rem)] max-h-[70vh] overflow-y-auto pointer-events-none`,children:[c.map(e=>(0,S.jsx)(`div`,{className:`pointer-events-auto glass-card border border-border/30 rounded-lg p-3 shadow-lg w-full`,children:(0,S.jsx)(T,{chat:e,projectName:s.get(e.projectId)??a(`dock.unknownProject`),onRestore:()=>r(e.id),onClose:()=>i(e.id)})},e.id)),c.length>1&&(0,S.jsxs)(`div`,{className:`pointer-events-auto self-end inline-flex items-center gap-1 rounded-full bg-card/80 border border-border/40 px-2 py-0.5 text-[10px] text-muted-foreground backdrop-blur-sm`,children:[(0,S.jsx)(m,{className:`w-3 h-3`}),a(`dock.minimizedCount`,{count:c.length})]})]}),document.body)}var O=(0,_.createContext)(null),k=`specrails-desktop:minimized-chats`,A=`specrails-desktop:minimized-chats-pending`,j=50,M=8e3;function N(){return L(k)}function P(e){z(k,e)}function F(){return L(A)}function I(e){z(A,e)}function L(e){if(typeof window>`u`)return[];try{let t=window.localStorage.getItem(e);if(!t)return[];let n=JSON.parse(t);return Array.isArray(n)?n.filter(B):[]}catch{return[]}}function R(e){return e.length<=j?e:[...e].sort((e,t)=>e.createdAt-t.createdAt).slice(e.length-j)}function z(e,t){if(!(typeof window>`u`))try{window.localStorage.setItem(e,JSON.stringify(R(t)))}catch{}}function B(e){if(!e||typeof e!=`object`)return!1;let t=e;return!(typeof t.id!=`string`||typeof t.projectId!=`string`||typeof t.label!=`string`||typeof t.restoreRoute!=`string`||typeof t.createdAt!=`number`||t.kind!==`explore-spec`&&t.kind!==`ai-edit`||!t.params||typeof t.params!=`object`)}function V(){return typeof crypto<`u`&&`randomUUID`in crypto?crypto.randomUUID():`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function H(e){return e.kind===`explore-spec`?e.params.resumeConversationId??`pending:${e.params.pendingSpecId}`:e.params.resumeRefineId??`agent:${e.params.agentId}`}function U(e,t){return e.kind!==t.kind||e.projectId!==t.projectId?!1:H(e)===H(t)}function W({children:e}){let{projects:t,activeProjectId:n,setActiveProjectId:r}=c(),o=i(),{registerHandler:s,unregisterHandler:l}=a(),[u,d]=(0,_.useState)(()=>N()),[f,p]=(0,_.useState)([]),m=(0,_.useRef)(u);m.current=u;let h=(0,_.useRef)(f);h.current=f;let g=(0,_.useRef)(new Map),v=(0,_.useRef)(t);v.current=t;let y=(0,_.useRef)(!1);(0,_.useEffect)(()=>{if(y.current)return;y.current=!0;let e=F();I([]),e.length!==0&&d(t=>{let n=[...t];for(let t of e)n.some(e=>e.id===t.id||U(e,t))||n.push(t);return P(n),m.current=n,n})},[]),(0,_.useEffect)(()=>{let e=g.current;return()=>{for(let t of e.values())clearTimeout(t);e.clear()}},[]),(0,_.useEffect)(()=>{P(u)},[u]),(0,_.useEffect)(()=>{I(f)},[f]);let x=(0,_.useRef)(()=>{}),C=(0,_.useRef)(()=>{});(0,_.useEffect)(()=>{let e=`minimized-chats:spec-draft`;return s(e,e=>{if(!b(e))return;let t=e.conversationId,n=m.current.find(e=>e.kind===`explore-spec`&&e.params.resumeConversationId===t);if(!n)return;let r=e.draft;r.title?.trim()&&x.current(n.id,r.title);let i={};r.title!==void 0&&(i.title=r.title),r.description!==void 0&&(i.description=r.description),r.priority!==void 0&&(i.priority=r.priority),r.labels!==void 0&&(i.labels=r.labels),r.repositoryIds!==void 0&&(i.repositoryIds=r.repositoryIds),r.acceptanceCriteria!==void 0&&(i.acceptanceCriteria=r.acceptanceCriteria),Object.keys(i).length>0&&C.current(n.id,i)}),()=>l(e)},[s,l]),(0,_.useEffect)(()=>{if(t.length===0)return;let e=new Set(t.map(e=>e.id));d(t=>{let n=t.filter(t=>e.has(t.projectId));return n.length===t.length?t:(P(n),m.current=n,n)}),p(t=>{let n=t.filter(t=>e.has(t.projectId));return n.length===t.length?t:(I(n),h.current=n,n)})},[t]);let w=(0,_.useCallback)(e=>{let t=V(),n={...e,id:t,createdAt:Date.now()};if(d(e=>{let t=R([...e.filter(e=>!U(e,n)),n]);return P(t),m.current=t,t}),e.kind===`explore-spec`){let t=e.params.resumeConversationId;t&&fetch(`/api/projects/${e.projectId}/chat/conversations/${t}/minimize`,{method:`POST`}).catch(()=>{})}return t},[]),T=(0,_.useCallback)(e=>{let t=g.current.get(e);t&&(clearTimeout(t),g.current.delete(e))},[]),E=(0,_.useCallback)(e=>{T(e),d(t=>{let n=t.filter(t=>t.id!==e);return P(n),m.current=n,n}),p(t=>{let n=t.filter(t=>t.id!==e);return n.length===t.length?t:(I(n),h.current=n,n)})},[T]),k=(0,_.useCallback)((e,t)=>{let n=t.trim();n&&d(t=>{let r=t.map(t=>t.id===e&&t.label!==n?{...t,label:n}:t);return r===t?t:(m.current=r,r)})},[]),A=(0,_.useCallback)((e,t)=>{d(n=>{let r=n.map(n=>{if(n.id!==e||n.kind!==`explore-spec`)return n;let r={...n.params.draftOverrides??{},...t};return{...n,params:{...n.params,draftOverrides:r}}});return m.current=r,r})},[]),j=(0,_.useCallback)(e=>{let t=m.current.find(t=>t.id===e);if(!t||v.current.length>0&&!v.current.some(e=>e.id===t.projectId))return;if(t.kind===`explore-spec`){let e=t.params.resumeConversationId;e&&fetch(`/api/projects/${t.projectId}/chat/conversations/${e}/restore`,{method:`POST`}).catch(()=>{})}n!==t.projectId&&r(t.projectId),o(t.restoreRoute),p(n=>{let r=[...n.filter(t=>t.id!==e),t];return I(r),h.current=r,r}),d(t=>{let n=t.filter(t=>t.id!==e);return P(n),m.current=n,n}),T(e);let i=setTimeout(()=>{g.current.delete(e),h.current.some(t=>t.id===e)&&(p(t=>{let n=t.filter(t=>t.id!==e);return I(n),h.current=n,n}),d(n=>{if(n.some(n=>n.id===e||U(n,t)))return n;let r=[...n,t];return P(r),m.current=r,r}))},M);g.current.set(e,i)},[n,r,o,T]),L=(0,_.useRef)(j);L.current=j;let z=(0,_.useRef)(E);z.current=E,x.current=k,C.current=A;let B=(0,_.useCallback)((e,t)=>{let n=h.current,r=n.findIndex(n=>n.kind===e&&n.projectId===t);if(r===-1)return null;let i=n[r];return T(i.id),p(e=>{let t=e.filter(e=>e.id!==i.id);return I(t),t}),h.current=n.filter(e=>e.id!==i.id),i},[T]),H=(0,_.useCallback)(e=>{let t=V(),i={...e,id:t,createdAt:Date.now()};n!==e.projectId&&r(e.projectId),o(e.restoreRoute),p(e=>{let t=[...e,i];return I(t),h.current=t,t}),T(t);let a=setTimeout(()=>{g.current.delete(t),h.current.some(e=>e.id===t)&&(p(e=>{let n=e.filter(e=>e.id!==t);return I(n),h.current=n,n}),d(e=>{if(e.some(e=>e.id===t||U(e,i)))return e;let n=[...e,i];return P(n),m.current=n,n}))},M);g.current.set(t,a)},[n,r,o,T]),W=(0,_.useMemo)(()=>({chats:u,pendingRestores:f,minimize:w,updateLabel:k,patchExploreSpecDraft:A,close:E,restore:j,takePendingRestore:B,triggerResume:H}),[u,f,w,k,A,E,j,B,H]);return(0,S.jsxs)(O.Provider,{value:W,children:[e,(0,S.jsx)(D,{chats:u,projects:t,hidden:!1,onRestore:j,onClose:E})]})}function G(){return(0,_.useContext)(O)||{chats:[],pendingRestores:[],minimize:()=>``,updateLabel:()=>{},patchExploreSpecDraft:()=>{},close:()=>{},restore:()=>{},takePendingRestore:()=>null,triggerResume:()=>{}}}function K(e,t,n){let{pendingRestores:r,takePendingRestore:i}=G(),a=(0,_.useRef)(n);a.current=n,(0,_.useEffect)(()=>{if(!t)return;let n=i(e,t);n&&a.current(n)},[r,e,t,i])}export{v as a,h as c,f as d,d as f,y as i,m as l,G as n,b as o,K as r,g as s,W as t,p as u};
@@ -1,2 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{l as r,r as i}from"./useSharedWebSocket-DnxHj8jP.js";import{n as a,t as o}from"./createLucideIcon-Bjbbp_KS.js";import{n as s,r as c,s as l}from"./useDesktop-mxHVQOdx.js";import{t as u}from"./download-CFHyyHcw.js";import{t as d}from"./loader-circle-DcygOQpC.js";import{t as f}from"./search-Cq_gE3Ik.js";import{t as p}from"./trash-2-BOU3WdZZ.js";import{t as m}from"./triangle-alert-H9T4jAmh.js";import{n as h,t as g}from"./jira-api-ChjVGJx_.js";import{i as _,l as v,o as y,r as b,t as x}from"./dialog-xXB2q5HJ.js";import{t as S}from"./utils-BC4DHlz2.js";import{t as C}from"./button-Ccc9Dc-D.js";import{r as w}from"./provider-capabilities-CXipwrXJ.js";import{Ft as T,L as E,Nt as D,ct as O,ht as k,lt as A,st as j}from"./index-DYoyDWim.js";var M=o(`earth`,[[`path`,{d:`M21.54 15H17a2 2 0 0 0-2 2v4.54`,key:`1djwo0`}],[`path`,{d:`M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17`,key:`1tzkfa`}],[`path`,{d:`M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05`,key:`14pb5j`}],[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}]]),ee=o(`folder-kanban`,[[`path`,{d:`M4 20h16a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.93a2 2 0 0 1-1.66-.9l-.82-1.2A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13c0 1.1.9 2 2 2Z`,key:`1fr9dc`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M12 10v2`,key:`hh53o1`}],[`path`,{d:`M16 10v6`,key:`1d6xys`}]]),N=o(`plug-zap`,[[`path`,{d:`M6.3 20.3a2.4 2.4 0 0 0 3.4 0L12 18l-6-6-2.3 2.3a2.4 2.4 0 0 0 0 3.4Z`,key:`goz73y`}],[`path`,{d:`m2 22 3-3`,key:`19mgm9`}],[`path`,{d:`M7.5 13.5 10 11`,key:`7xgeeb`}],[`path`,{d:`M10.5 16.5 13 14`,key:`10btkg`}],[`path`,{d:`m18 3-4 4h6l-4 4`,key:`16psg9`}]]),P=o(`power`,[[`path`,{d:`M12 2v10`,key:`mnfbl`}],[`path`,{d:`M18.4 6.6a9 9 0 1 1-12.77.04`,key:`obofu9`}]]),F=o(`settings-2`,[[`path`,{d:`M14 17H5`,key:`gfn3mx`}],[`path`,{d:`M19 7h-9`,key:`6i9tg`}],[`circle`,{cx:`17`,cy:`17`,r:`3`,key:`18b49y`}],[`circle`,{cx:`7`,cy:`7`,r:`3`,key:`dfmy0x`}]]),I=e(t(),1),L=n(),te=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],R={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function z({onConnected:e,onSkip:t,apiBase:n}){let{t:r}=a(`jira`),[i,o]=(0,I.useState)(1),[s,c]=(0,I.useState)(``),[u,d]=(0,I.useState)(``),[f,p]=(0,I.useState)(``),[m,h]=(0,I.useState)(`idle`),[_,v]=(0,I.useState)(null),[y,b]=(0,I.useState)(`cloud`),[x,S]=(0,I.useState)([]),[w,T]=(0,I.useState)(``),[D,O]=(0,I.useState)(``),[k,A]=(0,I.useState)(``),[j,M]=(0,I.useState)(!1),[ee,N]=(0,I.useState)([]),[P,F]=(0,I.useState)({}),[z,ne]=(0,I.useState)(``),[U,W]=(0,I.useState)(!1),G=()=>({baseUrl:s.trim(),accountEmail:u.trim()||null,token:f});async function K(){h(`testing`);try{let e=await g.test(G(),n);h(`ok`),v(e.displayName),b(e.deployment)}catch(e){h(`error`),l.error(H(e,r))}}async function q(){o(2),M(!0);try{let{projects:e}=await g.discoverProjects({...G(),query:w.trim()||void 0},n);S(e)}catch(e){l.error(H(e,r))}finally{M(!1)}}async function J(){if(o(3),D)try{let{statuses:e}=await g.discoverStatuses({...G(),projectKey:D},n);N(e)}catch{N([])}}async function Y(){W(!0);try{let t=Object.fromEntries(Object.entries(P).filter(([,e])=>e));await g.connect({...G(),jiraProjectKey:D.trim(),statusMap:Object.keys(t).length?t:null,discardStatus:z.trim()||null},n),l.success(r(`status.connected`,{key:D.trim()})),e()}catch(e){l.error(H(e,r))}finally{W(!1)}}return(0,L.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-wizard`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`wizard.step`,{current:i,total:4})}),t&&(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`text-xs text-muted-foreground hover:text-foreground hover:underline`,"data-testid":`jira-later`,children:r(`wizard.later`)})]}),i===1&&(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step1Title`)}),(0,L.jsx)(B,{label:r(`creds.baseUrlLabel`),help:r(`creds.baseUrlHelp`),children:(0,L.jsx)(E,{value:s,onChange:e=>{c(e.target.value),h(`idle`)},placeholder:r(`creds.baseUrlPlaceholder`)})}),(0,L.jsx)(B,{label:r(`creds.emailLabel`),help:r(`creds.emailHelp`),children:(0,L.jsx)(E,{value:u,onChange:e=>{d(e.target.value),h(`idle`)},placeholder:r(`creds.emailPlaceholder`)})}),(0,L.jsx)(B,{label:r(`creds.tokenLabel`),help:r(`creds.tokenHelp`),children:(0,L.jsx)(E,{type:`password`,value:f,onChange:e=>{p(e.target.value),h(`idle`)}})}),(0,L.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,L.jsx)(C,{size:`sm`,variant:`outline`,onClick:K,disabled:!s.trim()||!f.trim()||m===`testing`,children:r(m===`testing`?`creds.testing`:m===`ok`?`creds.retest`:`creds.test`)}),m===`ok`&&(0,L.jsxs)(`span`,{className:`text-xs text-accent-success`,"data-testid":`jira-test-ok`,children:[`✓ `,r(`creds.testOk`,{name:_??``}),` · `,r(y===`cloud`?`review.cloud`:`review.dc`)]})]}),(0,L.jsx)(`div`,{className:`flex justify-end`,children:(0,L.jsx)(C,{size:`sm`,onClick:q,disabled:m!==`ok`,children:r(`wizard.next`)})})]}),i===2&&(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step2Title`)}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(E,{value:w,onChange:e=>T(e.target.value),placeholder:r(`project.searchPlaceholder`)}),(0,L.jsx)(C,{size:`sm`,variant:`outline`,onClick:q,children:r(`project.searchPlaceholder`)})]}),j?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.loading`)}):x.length===0?(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`project.none`)}):(0,L.jsx)(`div`,{className:`max-h-48 space-y-1 overflow-y-auto`,"data-testid":`jira-project-list`,children:x.map(e=>(0,L.jsxs)(`button`,{type:`button`,onClick:()=>{O(e.key),A(e.name)},className:`flex w-full items-center justify-between rounded px-2 py-1.5 text-left text-sm hover:bg-muted ${D===e.key?`bg-muted`:``}`,children:[(0,L.jsx)(`span`,{className:`font-medium`,children:e.key}),(0,L.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e.name})]},e.id))}),(0,L.jsx)(B,{label:r(`project.manualLabel`),children:(0,L.jsx)(E,{value:D,onChange:e=>{O(e.target.value.toUpperCase()),A(``)},placeholder:r(`project.manualPlaceholder`)})}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>o(1),children:r(`wizard.back`)}),(0,L.jsx)(C,{size:`sm`,onClick:J,disabled:!D.trim(),children:r(`wizard.next`)})]})]}),i===3&&(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step3Title`)}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`mapping.intro`)}),te.map(e=>(0,L.jsx)(B,{label:r(`mapping.${R[e]}`),children:(0,L.jsxs)(`select`,{value:P[e]??``,onChange:t=>F(n=>({...n,[e]:t.target.value||void 0})),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,children:[(0,L.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),ee.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.name},e.id))]})},e)),(0,L.jsx)(B,{label:r(`discard.configLabel`),help:r(`discard.configHelp`),children:(0,L.jsxs)(`select`,{value:z,onChange:e=>ne(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,L.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),ee.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.name},e.id))]})}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>o(2),children:r(`wizard.back`)}),(0,L.jsx)(C,{size:`sm`,onClick:()=>o(4),children:r(`wizard.next`)})]})]}),i===4&&(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:r(`wizard.step4Title`)}),(0,L.jsxs)(`dl`,{className:`space-y-1 text-sm`,children:[(0,L.jsx)(V,{label:r(`review.site`),value:s}),(0,L.jsx)(V,{label:r(`review.project`),value:k?`${D} — ${k}`:D}),(0,L.jsx)(V,{label:r(`review.account`),value:_??u}),(0,L.jsx)(V,{label:r(`review.type`),value:r(y===`cloud`?`review.cloud`:`review.dc`)}),(0,L.jsx)(V,{label:r(`discard.reviewLabel`),value:z||r(`discard.configNone`)})]}),(0,L.jsxs)(`div`,{className:`flex justify-between`,children:[(0,L.jsx)(C,{size:`sm`,variant:`ghost`,onClick:()=>o(3),children:r(`wizard.back`)}),(0,L.jsx)(C,{size:`sm`,onClick:Y,disabled:U,children:r(U?`wizard.connecting`:`wizard.connect`)})]})]})]})}function B({label:e,help:t,children:n}){return(0,L.jsxs)(`label`,{className:`block space-y-1`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium text-foreground`,children:e}),n,t&&(0,L.jsx)(`span`,{className:`block text-[11px] text-muted-foreground`,children:t})]})}function V({label:e,value:t}){return(0,L.jsxs)(`div`,{className:`flex justify-between gap-4`,children:[(0,L.jsx)(`dt`,{className:`text-muted-foreground`,children:e}),(0,L.jsx)(`dd`,{className:`truncate text-right font-medium`,children:t})]})}function H(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var ne=[`todo`,`in_progress`,`on_review`,`done`,`cancelled`],U={todo:`todo`,in_progress:`inProgress`,on_review:`onReview`,done:`done`,cancelled:`cancelled`};function W({state:e,onChanged:t,apiBase:n}){let{t:r}=a(`jira`),i=e.connection,[o,s]=(0,I.useState)(i.enabled),[c,u]=(0,I.useState)(!1),[d,f]=(0,I.useState)(!1),[p,m]=(0,I.useState)([]),[h,_]=(0,I.useState)([]),[v,y]=(0,I.useState)(i.discardStatus??``),[b,x]=(0,I.useState)(i.statusMap??{}),S=e.outbox??{pending:0,inflight:0,done:0,dead:0},w=(0,I.useCallback)(async()=>{try{let{ops:e}=n?await g.listOutbox(`dead`,n):await g.listOutbox(`dead`);m(e)}catch{m([])}},[n]);(0,I.useEffect)(()=>{w()},[w]),(0,I.useEffect)(()=>{let e=!1;return g.listStatuses(n).then(({statuses:t})=>{e||_(t)}).catch(()=>{e||_([])}),()=>{e=!0}},[n]);async function T(e){let i=v;y(e);try{n?await g.patchConnection({discardStatus:e||null},n):await g.patchConnection({discardStatus:e||null}),t()}catch(e){y(i),l.error(K(e,r))}}async function E(e,i){let a=b,o={...b,[e]:i||void 0};x(o);let s=Object.fromEntries(Object.entries(o).filter(([,e])=>e));try{n?await g.patchConnection({statusMap:Object.keys(s).length?s:null},n):await g.patchConnection({statusMap:Object.keys(s).length?s:null}),t()}catch(e){x(a),l.error(K(e,r))}}async function D(){let e=!o;s(e),f(!0);try{n?await g.setEnabled(e,n):await g.setEnabled(e)}catch(t){s(!e),l.error(K(t,r))}finally{f(!1)}}async function O(){u(!0);try{let e=n?await g.syncNow(n):await g.syncNow();l.success(r(`status.syncedToast`,{count:e.upserted}))}catch(e){l.error(K(e,r))}finally{u(!1)}}async function k(){if(window.confirm(r(`status.disconnectConfirm`))){f(!0);try{n?await g.disconnect(n):await g.disconnect(),l.success(r(`status.disconnectedToast`)),t()}catch(e){l.error(K(e,r))}finally{f(!1)}}}async function A(e){try{n?await g.retryOutbox(e,n):await g.retryOutbox(e),await w()}catch(e){l.error(K(e,r))}}let j=S.pending+S.inflight;return(0,L.jsxs)(`div`,{className:`space-y-4`,"data-testid":`jira-connected`,children:[(0,L.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium text-foreground`,children:r(`status.connected`,{key:i.jiraProjectKey})}),(0,L.jsxs)(`p`,{className:`text-xs text-muted-foreground`,children:[i.baseUrl,` · `,i.deployment===`cloud`?r(`review.cloud`):r(`review.dc`)]})]}),(0,L.jsx)(`a`,{href:`${i.baseUrl}/browse/${i.jiraProjectKey}`,target:`_blank`,rel:`noreferrer`,className:`text-xs text-accent-primary hover:underline`,children:r(`badge.openInJira`)})]}),(0,L.jsxs)(`div`,{className:`flex items-center justify-between rounded-md border border-border p-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:r(`status.enabledLabel`)}),(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(o?`status.enabledHelp`:`status.pausedHelp`)})]}),(0,L.jsx)(`button`,{type:`button`,role:`switch`,"aria-checked":o,"aria-label":r(`status.enabledLabel`),disabled:d,onClick:D,className:`relative inline-flex h-5 w-9 shrink-0 items-center rounded-full transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${o?`bg-accent-success`:`bg-input`}`,children:(0,L.jsx)(`span`,{className:`inline-block h-3.5 w-3.5 rounded-full bg-background shadow-sm transition-transform ${o?`translate-x-4`:`translate-x-0.5`}`})})]}),(0,L.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-status-map`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:r(`wizard.step3Title`)}),(0,L.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`mapping.intro`)}),(0,L.jsx)(`div`,{className:`space-y-2`,children:ne.map(e=>(0,L.jsxs)(`label`,{className:`flex items-center justify-between gap-3`,children:[(0,L.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:r(`mapping.${U[e]}`)}),(0,L.jsxs)(`select`,{value:b[e]??``,onChange:t=>void E(e,t.target.value),className:`w-44 rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-statusmap-${e}`,children:[(0,L.jsx)(`option`,{value:``,children:r(`mapping.auto`)}),h.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.name},e.id)),b[e]&&!h.some(t=>t.name===b[e])&&(0,L.jsx)(`option`,{value:b[e],children:b[e]})]})]},e))})]}),(0,L.jsxs)(`div`,{className:`rounded-md border border-border p-3`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:r(`discard.configLabel`)}),(0,L.jsx)(`p`,{className:`mt-0.5 mb-2 text-xs text-muted-foreground`,children:r(`discard.configHelp`)}),(0,L.jsxs)(`select`,{value:v,onChange:e=>void T(e.target.value),className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-sm`,"data-testid":`jira-discard-status-select`,children:[(0,L.jsx)(`option`,{value:``,children:r(`discard.configNone`)}),h.map(e=>(0,L.jsx)(`option`,{value:e.name,children:e.name},e.id)),v&&!h.some(e=>e.name===v)&&(0,L.jsx)(`option`,{value:v,children:v})]})]}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,L.jsx)(C,{variant:`outline`,size:`sm`,onClick:O,disabled:c,children:r(c?`status.syncing`:`status.syncNow`)}),(0,L.jsx)(C,{variant:`ghost`,size:`sm`,onClick:k,disabled:d,className:`text-destructive`,children:r(`status.disconnect`)})]}),(0,L.jsxs)(`div`,{className:`rounded-md border border-border p-3`,"data-testid":`jira-outbox`,children:[(0,L.jsx)(`p`,{className:`text-sm font-medium`,children:r(`outbox.title`)}),S.dead>0?(0,L.jsx)(`p`,{className:`mt-1 text-xs text-accent-warning`,children:r(`outbox.dead`,{count:S.dead})}):j>0?(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:r(`outbox.pending`,{count:j})}):(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:r(`outbox.allSynced`)}),p.length>0&&(0,L.jsxs)(`div`,{className:`mt-2 space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`outbox.deadHelp`)}),p.map(e=>(0,L.jsxs)(`div`,{className:`flex items-center justify-between gap-2 rounded border border-border/60 px-2 py-1`,children:[(0,L.jsxs)(`span`,{className:`truncate text-xs`,children:[G(e,r),` · `,e.deadReason??e.lastError??``]}),(0,L.jsx)(C,{variant:`outline`,size:`sm`,onClick:()=>A(e.id),children:r(`outbox.retry`)})]},e.id))]})]})]})}function G(e,t){return e.opType===`transition`?t(`outbox.opTransition`):e.opType===`comment`?t(`outbox.opComment`):t(`outbox.opCreate`)}function K(e,t){return e instanceof Error?e.message:t(`errors.generic`)}var q=new Set([`claude`,`codex`,`kimi`]);function J(e){return{provider:e,label:e===`codex`?`Codex`:`Claude`,active:!1,available:!1,detectedRoute:!1,requests:0,inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0,outputSavingsPercent:0,outputSavingsMethod:`none`,outputSavingsAllocated:!1}}function Y(){return{updatedAt:null,proxyStatsAvailable:!1,durableSavingsAvailable:!1,outputSavingsAvailable:!1,outputSavingsMethod:null,outputConfidence:null,providers:{codex:J(`codex`),claude:J(`claude`)},lastIssue:null}}var X={installed:!1,installSource:null,version:null,executablePath:null,uvPath:null,port:8787,phase:`idle`,activeProviders:{codex:!1,claude:!1},availableProviders:{codex:!1,claude:!1},detectedRoutes:{codex:!1,claude:!1},proxyRunning:!1,proxyPid:null,learning:{enabled:!1,baselineReady:!1,baselineSamples:0,updatedAt:null,lastIssue:null},metrics:Y(),lastIssue:null,updatedAt:null};function re(e){let t=e?.metrics??Y();return{...X,...e,activeProviders:{...X.activeProviders,...e?.activeProviders},availableProviders:{...X.availableProviders,...e?.availableProviders},detectedRoutes:{...X.detectedRoutes,...e?.detectedRoutes},learning:{...X.learning,...e?.learning},metrics:{...Y(),...t,providers:{codex:{...J(`codex`),...t.providers?.codex},claude:{...J(`claude`),...t.providers?.claude}}}}}async function Z(e){let t=await e.text(),n=t?JSON.parse(t):{};if(!e.ok){let t=n.issue;throw Object.assign(Error(t?.title??n.error??`HTTP ${e.status}`),{payload:n})}return n}function Q(e){return`${r}/api/projects/${e}`}function ie(e,t=`en`){if(!Number.isFinite(e))return`0`;try{return Intl.NumberFormat(t,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}catch{return Intl.NumberFormat(`en`,{notation:`compact`,maximumFractionDigits:1}).format(Math.max(0,e))}}function $(e,t,n){return`${ie(e,t)} ${n}`}function ae(){let{t:e}=a(`integrations`),{projects:t}=c(),{registerHandler:n,unregisterHandler:o}=i(),[s,l]=(0,I.useState)(``),[u,d]=(0,I.useState)(`all`),[p,m]=(0,I.useState)(X),[h,g]=(0,I.useState)(!0),[C,w]=(0,I.useState)(null),[T,E]=(0,I.useState)([]),[D,M]=(0,I.useState)(!1),[P,F]=(0,I.useState)(!1),[te,R]=(0,I.useState)(null),[z,B]=(0,I.useState)({jira:0,serena:0,projects:0}),V=(0,I.useCallback)(async()=>{try{let e=await fetch(`${r}/api/global-plugins/headroom`).then(e=>Z(e));m(re(e.state))}finally{g(!1)}},[]);(0,I.useEffect)(()=>{V()},[V]),(0,I.useEffect)(()=>(n(`plugins-page`,e=>{let t=e;t.type===`plugin.headroom_progress`&&(t.line&&E(e=>[...e.slice(-80),t.line]),V())}),()=>o(`plugins-page`)),[n,o,V]),(0,I.useEffect)(()=>{let e=!1;async function n(){let n=await Promise.all(t.map(async e=>{let[t,n]=await Promise.all([fetch(`${Q(e.id)}/jira/connection`).then(e=>Z(e)).catch(()=>({connected:!1})),fetch(`${Q(e.id)}/plugins`).then(e=>Z(e)).catch(()=>({plugins:[]}))]),r=n.plugins.find(e=>e.name===`serena`);return{jira:+!!t.connected,serena:r&&r.status!==`not-installed`&&r.status!==`orphan`?1:0}}));e||B({jira:n.reduce((e,t)=>e+t.jira,0),serena:n.reduce((e,t)=>e+t.serena,0),projects:t.length})}return n(),()=>{e=!0}},[t]);async function H(e,t){w(e),E([]);try{let e=(await t()).state;e&&m(re(e))}catch(e){let t=e.payload;t?.state&&m(re(t.state))}finally{w(null),V()}}let ne=(0,I.useMemo)(()=>[{id:`headroom-ai`,title:`Headroom AI`,scope:`global`,icon:N,description:e(`plugins.catalog.headroom.description`),installed:p.installed,status:p.lastIssue?`attention`:p.installed?p.activeProviders.codex||p.activeProviders.claude?p.installSource===`system`?`external-active`:`active`:p.installSource===`system`?`external`:`installed`:`available`,statusLabel:p.lastIssue?e(`plugins.status.attention`):p.installed?p.activeProviders.codex||p.activeProviders.claude?p.installSource===`system`?e(`plugins.status.externalActive`):e(`plugins.status.active`):p.installSource===`system`?e(`plugins.status.external`):e(`plugins.status.installed`):e(`plugins.status.available`),actionKind:p.lastIssue?`review`:p.installed?`manage`:`install`,actionLabel:p.lastIssue?e(`plugins.actions.review`):p.installed?e(`plugins.actions.manage`):e(`plugins.actions.install`),busy:C===`install`,action:()=>{if(p.lastIssue||p.installed){M(!0);return}H(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>Z(e)))}}],[p,C,e]),U=(0,I.useMemo)(()=>[{id:`jira`,title:`Jira`,scope:`project`,icon:ee,description:e(`plugins.catalog.jira.description`),installed:z.jira>0,status:z.jira>0?`configured`:`available`,statusLabel:z.jira>0?e(`plugins.status.configuredCount`,{count:z.jira}):e(`plugins.status.available`),actionKind:z.jira>0?`manage`:`install`,actionLabel:z.jira>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>R(`jira`)},{id:`serena`,title:`Serena`,scope:`project`,icon:j,description:e(`plugins.catalog.serena.description`),installed:z.serena>0,status:z.serena>0?`installed`:`available`,statusLabel:z.serena>0?e(`plugins.status.installedCount`,{count:z.serena}):e(`plugins.status.available`),actionKind:z.serena>0?`manage`:`install`,actionLabel:z.serena>0?e(`plugins.actions.manage`):e(`plugins.actions.install`),action:()=>R(`serena`)}],[z,e]),W=s.trim().toLowerCase(),G=t=>`${t.title} ${t.description} ${t.statusLabel} ${e(`plugins.scope.${t.scope}`)}`.toLowerCase().includes(W),K=[...ne,...U].filter(e=>u!==`all`&&e.scope!==u?!1:G(e)),q=K.filter(e=>e.scope===`global`&&e.installed),J=K.filter(e=>e.scope===`project`&&e.installed),Y=K.filter(e=>e.scope===`global`&&!e.installed),ie=K.filter(e=>e.scope===`project`&&!e.installed),$=q.length>0||J.length>0,ae=Y.length>0||ie.length>0,ce=[p.installed,z.jira>0,z.serena>0].filter(Boolean).length;return(0,L.jsxs)(`div`,{className:`flex h-full flex-col bg-background`,children:[(0,L.jsxs)(`div`,{className:`border-b border-border px-6 py-4`,children:[(0,L.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,L.jsx)(`div`,{className:`grid h-9 w-9 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,L.jsx)(k,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`h1`,{className:`text-lg font-semibold tracking-normal`,children:e(`plugins.page.title`)}),(0,L.jsx)(`p`,{className:`mt-0.5 text-xs text-muted-foreground`,children:e(`plugins.page.subtitle`)})]}),(0,L.jsxs)(`div`,{className:`mr-12 flex items-center gap-2 rounded-lg border border-border bg-card/60 px-3 py-2 text-xs`,children:[(0,L.jsx)(A,{className:`h-3.5 w-3.5 text-accent-success`}),(0,L.jsx)(`span`,{className:`text-muted-foreground`,children:e(`plugins.page.readyCount`,{count:ce})})]})]}),(0,L.jsxs)(`div`,{className:`mt-4 flex flex-col gap-3 md:flex-row md:items-center`,children:[(0,L.jsxs)(`label`,{className:`relative flex-1`,children:[(0,L.jsx)(f,{className:`pointer-events-none absolute left-3 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-muted-foreground`}),(0,L.jsx)(`input`,{value:s,onChange:e=>l(e.target.value),placeholder:e(`plugins.search.placeholder`),className:`h-9 w-full rounded-lg border border-border bg-background pl-9 pr-3 text-sm outline-none transition-colors focus:border-accent-primary/60`})]}),(0,L.jsx)(`div`,{className:`inline-flex h-9 rounded-lg border border-border bg-card p-1`,children:[`all`,`global`,`project`].map(t=>(0,L.jsx)(`button`,{type:`button`,onClick:()=>d(t),className:S(`rounded-md px-3 text-xs capitalize transition-colors`,u===t?`bg-muted text-foreground`:`text-muted-foreground hover:text-foreground`),children:e(`plugins.filters.${t}`)},t))})]})]}),(0,L.jsxs)(`div`,{className:`flex-1 overflow-auto px-6 py-5`,children:[(0,L.jsxs)(`section`,{className:`mb-6`,children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,L.jsx)(O,{className:`h-3.5 w-3.5`}),e(`plugins.sections.installed`)]}),$?(0,L.jsx)(oe,{globalPlugins:q,projectPlugins:J}):(0,L.jsx)(se,{text:e(W?`plugins.empty.installedSearch`:`plugins.empty.installed`)})]}),(0,L.jsxs)(`section`,{children:[(0,L.jsxs)(`div`,{className:`mb-3 flex items-center gap-2 text-xs font-medium text-muted-foreground`,children:[(0,L.jsx)(k,{className:`h-3.5 w-3.5`}),e(`plugins.sections.available`)]}),ae?(0,L.jsx)(oe,{globalPlugins:Y,projectPlugins:ie}):(0,L.jsx)(se,{text:e(W?`plugins.empty.availableSearch`:`plugins.empty.allInstalled`)})]})]}),(0,L.jsx)(x,{open:D,onOpenChange:M,children:(0,L.jsxs)(b,{className:`w-[calc(100vw-2rem)] max-w-xl overflow-x-hidden p-4 sm:p-6`,children:[(0,L.jsxs)(y,{children:[(0,L.jsx)(v,{children:e(`plugins.headroom.title`)}),(0,L.jsx)(_,{children:e(`plugins.headroom.dialogDescription`)})]}),(0,L.jsx)(de,{state:p,loading:h,busy:C,logs:T,onInstall:()=>H(`install`,()=>fetch(`${r}/api/global-plugins/headroom/install`,{method:`POST`}).then(e=>Z(e))),onToggleProvider:(e,t)=>H(`${t?`deactivate`:`activate`}-${e}`,()=>fetch(`${r}/api/global-plugins/headroom/${t?`deactivate`:`activate`}`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:e})}).then(e=>Z(e))),onDeactivateAll:()=>H(`deactivate-all`,async()=>{let e={state:p};for(let t of[`codex`,`claude`])p.activeProviders[t]&&(e=await fetch(`${r}/api/global-plugins/headroom/deactivate`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:t})}).then(e=>Z(e)));return e}),onUninstall:()=>H(`uninstall`,()=>fetch(`${r}/api/global-plugins/headroom/uninstall`,{method:`POST`}).then(e=>Z(e))),onSetPort:e=>H(`port`,()=>fetch(`${r}/api/global-plugins/headroom/port`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({port:e})}).then(e=>Z(e))),onOpenDiagnostics:()=>F(!0)})]})}),(0,L.jsx)(ve,{plugin:te,projects:t,onClose:()=>R(null)}),(0,L.jsx)(xe,{open:P,onClose:()=>F(!1)})]})}function oe({globalPlugins:e,projectPlugins:t}){let{t:n}=a(`integrations`);return(0,L.jsxs)(`div`,{className:S(`grid grid-cols-1 gap-4`,e.length>0&&t.length>0&&`xl:grid-cols-2`),children:[e.length>0&&(0,L.jsxs)(`section`,{children:[(0,L.jsx)(le,{title:n(`plugins.groups.global.title`),detail:n(`plugins.groups.global.detail`),scope:`global`}),(0,L.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:e.map(e=>(0,L.jsx)(ue,{plugin:e},e.id))})]}),t.length>0&&(0,L.jsxs)(`section`,{children:[(0,L.jsx)(le,{title:n(`plugins.groups.project.title`),detail:n(`plugins.groups.project.detail`),scope:`project`}),(0,L.jsx)(`div`,{className:`grid grid-cols-[repeat(auto-fill,minmax(260px,320px))] justify-start gap-3`,children:t.map(e=>(0,L.jsx)(ue,{plugin:e},e.id))})]})]})}function se({text:e}){return(0,L.jsx)(`div`,{className:`flex h-[74px] max-w-[320px] items-center rounded-lg border border-dashed border-border bg-card/35 px-3 text-xs text-muted-foreground`,children:e})}function ce({scope:e}){let{t}=a(`integrations`);return(0,L.jsx)(`span`,{className:S(`rounded px-1.5 py-0.5 text-[10px] uppercase tracking-wide`,e===`global`?`bg-accent-primary/10 text-accent-primary`:`bg-accent-info/10 text-accent-info`),children:t(`plugins.scope.${e}`)})}function le({title:e,detail:t,scope:n}){return(0,L.jsxs)(`div`,{className:`mb-2 flex items-center gap-2`,children:[(0,L.jsx)(`div`,{className:S(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)}),(0,L.jsxs)(`div`,{className:`flex items-center gap-2 rounded-md border border-border bg-card/70 px-2 py-1`,children:[(0,L.jsx)(ce,{scope:n}),(0,L.jsx)(`span`,{className:`text-xs font-medium`,children:e}),(0,L.jsx)(`span`,{className:`hidden text-[11px] text-muted-foreground sm:inline`,children:t})]}),(0,L.jsx)(`div`,{className:S(`h-px flex-1`,n===`global`?`bg-accent-primary/30`:`bg-accent-info/30`)})]})}function ue({plugin:e}){let{t}=a(`integrations`),n=e.icon,r=e.scope===`global`,i=e.status===`attention`,o=e.busy?d:e.actionKind===`install`?u:e.actionKind===`review`?m:F,s=S(`shrink-0 rounded border px-1.5 py-0.5 text-[10px] leading-none`,i?`border-accent-warning/30 bg-accent-warning/10 text-accent-warning`:e.installed?`border-accent-success/25 bg-accent-success/10 text-accent-success`:`border-border bg-muted text-muted-foreground`);return(0,L.jsxs)(`article`,{className:`grid h-[88px] w-full grid-cols-[38px_minmax(0,1fr)_auto] items-center gap-3 rounded-lg border border-border bg-card/70 px-3 transition-colors hover:border-accent-primary/35 hover:bg-card`,children:[(0,L.jsx)(`div`,{className:S(`grid h-[38px] w-[38px] shrink-0 place-items-center rounded-lg border`,r?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-accent-info/25 bg-accent-info/10 text-accent-info`),children:(0,L.jsx)(n,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`h2`,{className:`truncate text-sm font-semibold leading-5`,children:e.title}),(0,L.jsx)(`p`,{className:`mt-1 truncate text-[11px] leading-4 text-muted-foreground`,children:e.description}),(0,L.jsxs)(`div`,{className:`mt-1.5 flex items-center gap-1.5`,children:[(0,L.jsx)(ce,{scope:e.scope}),(0,L.jsx)(`span`,{className:s,children:e.statusLabel})]})]}),(0,L.jsxs)(`button`,{type:`button`,disabled:e.busy,onClick:e.action,className:`flex h-7 shrink-0 items-center gap-1.5 rounded-md border border-border bg-background px-2.5 text-xs font-medium transition-colors hover:bg-muted disabled:opacity-50`,children:[(0,L.jsx)(o,{className:S(`h-3.5 w-3.5`,e.busy&&`animate-spin`)}),e.busy?t(`plugins.actions.installing`):e.actionLabel]})]})}function de({state:e,loading:t,busy:n,logs:r,onInstall:i,onToggleProvider:o,onDeactivateAll:s,onUninstall:c,onSetPort:l,onOpenDiagnostics:f}){let{t:m}=a(`integrations`),[g,_]=(0,I.useState)(String(e.port)),[v,y]=(0,I.useState)(!1);(0,I.useEffect)(()=>_(String(e.port)),[e.port]),(0,I.useEffect)(()=>{e.installed||y(!1)},[e.installed]);let b=e.activeProviders.codex||e.activeProviders.claude,x=e.installSource===`system`;return(0,L.jsxs)(`aside`,{className:`w-full min-w-0 overflow-hidden rounded-lg border border-border bg-card/80 p-4`,children:[(0,L.jsxs)(`div`,{className:`mb-4 flex items-start gap-3`,children:[(0,L.jsx)(`div`,{className:`grid h-10 w-10 place-items-center rounded-lg border border-accent-primary/25 bg-accent-primary/10 text-accent-primary`,children:(0,L.jsx)(N,{className:`h-4 w-4`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`h2`,{className:`text-sm font-semibold`,children:m(`plugins.headroom.title`)}),(0,L.jsx)(`p`,{className:`mt-1 text-xs leading-relaxed text-muted-foreground`,children:m(`plugins.headroom.panelDescription`)})]})]}),(0,L.jsxs)(`div`,{className:`mb-4 grid grid-cols-3 gap-2 text-xs`,children:[(0,L.jsx)(fe,{label:m(`plugins.headroom.metrics.install`),value:t?m(`plugins.headroom.metrics.checking`):e.installed?m(`plugins.headroom.metrics.ready`):m(`plugins.headroom.metrics.missing`),good:e.installed}),(0,L.jsx)(fe,{label:m(`plugins.headroom.metrics.source`),value:e.installSource===`system`?m(`plugins.headroom.metrics.system`):e.installSource===`managed`?m(`plugins.headroom.metrics.specrails`):m(`plugins.headroom.metrics.none`),good:e.installed}),(0,L.jsx)(fe,{label:m(`plugins.headroom.metrics.proxy`),value:e.proxyRunning?`:${e.port}`:m(b?`plugins.headroom.metrics.starting`:`plugins.headroom.metrics.off`),good:e.proxyRunning||!b})]}),e.lastIssue&&(0,L.jsx)(pe,{issue:e.lastIssue}),e.installed?(0,L.jsxs)(`div`,{className:`mb-4 space-y-2`,children:[(0,L.jsx)(_e,{provider:`codex`,active:e.activeProviders.codex,available:e.availableProviders.codex,detectedRoute:e.detectedRoutes.codex,busy:n===`activate-codex`||n===`deactivate-codex`,onClick:()=>o(`codex`,e.activeProviders.codex)}),(0,L.jsx)(_e,{provider:`claude`,active:e.activeProviders.claude,available:e.availableProviders.claude,detectedRoute:e.detectedRoutes.claude,busy:n===`activate-claude`||n===`deactivate-claude`,onClick:()=>o(`claude`,e.activeProviders.claude)}),b&&(0,L.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:s,className:`flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border bg-background/45 text-xs hover:bg-muted/50 disabled:opacity-50`,children:[n===`deactivate-all`?(0,L.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,L.jsx)(P,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.disableAllRoutes`)]})]}):(0,L.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:i,className:`mb-3 flex h-9 w-full items-center justify-center gap-2 rounded-lg bg-accent-primary px-3 text-xs font-medium text-white disabled:opacity-50`,children:[n===`install`?(0,L.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,L.jsx)(u,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.installWithUv`)]}),e.installed&&(0,L.jsx)(me,{state:e}),(0,L.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,L.jsx)(`label`,{className:`mb-1 block text-[11px] font-medium text-muted-foreground`,children:m(`plugins.headroom.port.label`)}),(0,L.jsxs)(`div`,{className:`flex gap-2`,children:[(0,L.jsx)(`input`,{value:g,onChange:e=>_(e.target.value),className:`h-8 min-w-0 flex-1 rounded-md border border-border bg-background px-2 text-sm`}),(0,L.jsx)(`button`,{type:`button`,disabled:!!n||Number(g)===e.port,onClick:()=>l(Number(g)),className:`rounded-md border border-border px-2 text-xs hover:bg-muted disabled:opacity-50`,children:m(`plugins.headroom.port.apply`)})]})]}),r.length>0&&(0,L.jsx)(`pre`,{className:`mb-3 max-h-32 overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background/60 p-2 text-[10px] text-muted-foreground`,children:r.join(`
2
- `)}),(0,L.jsxs)(`button`,{type:`button`,onClick:f,className:`mb-2 flex h-8 w-full items-center justify-center gap-2 rounded-lg border border-border text-xs hover:bg-muted/50`,children:[(0,L.jsx)(h,{className:`h-3.5 w-3.5`}),m(`plugins.headroom.actions.viewDiagnostics`)]}),e.installed&&(0,L.jsx)(`div`,{className:`rounded-lg border border-destructive/25 bg-destructive/5 p-3`,children:v?(0,L.jsxs)(`div`,{className:`space-y-2`,children:[(0,L.jsx)(`p`,{className:`text-[11px] leading-relaxed text-muted-foreground`,children:m(x?`plugins.headroom.confirmDetach`:`plugins.headroom.confirmUninstall`)}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,disabled:!!n,onClick:()=>y(!1),className:`h-8 rounded-md border border-border text-xs hover:bg-muted/50 disabled:opacity-50`,children:m(`plugins.actions.cancel`)}),(0,L.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:c,className:`flex h-8 items-center justify-center gap-2 rounded-md bg-destructive px-2 text-xs font-medium text-destructive-foreground disabled:opacity-50`,children:[n===`uninstall`?(0,L.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,L.jsx)(p,{className:`h-3.5 w-3.5`}),m(x?`plugins.headroom.actions.detach`:`plugins.headroom.actions.uninstall`)]})]})]}):(0,L.jsxs)(`button`,{type:`button`,disabled:!!n,onClick:()=>y(!0),className:`flex h-8 w-full items-center justify-center gap-2 rounded-md text-xs font-medium text-destructive hover:bg-destructive/10 disabled:opacity-50`,children:[(0,L.jsx)(p,{className:`h-3.5 w-3.5`}),m(x?`plugins.headroom.actions.detachHeadroom`:`plugins.headroom.actions.uninstallHeadroom`)]})})]})}function fe({label:e,value:t,good:n}){return(0,L.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-2`,children:[(0,L.jsx)(`div`,{className:`text-[10px] text-muted-foreground`,children:e}),(0,L.jsx)(`div`,{className:S(`mt-0.5 font-medium`,n?`text-foreground`:`text-accent-warning`),children:t})]})}function pe({issue:e}){let{t}=a(`integrations`),n=`plugins.headroom.issues.${e.code}`,r=t(`${n}.title`,{defaultValue:e.title}),i=t(`${n}.guidance`,{defaultValue:e.guidance});return(0,L.jsx)(`div`,{className:`mb-3 rounded-lg border border-accent-warning/35 bg-accent-warning/10 p-3`,children:(0,L.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,L.jsx)(m,{className:`mt-0.5 h-3.5 w-3.5 shrink-0 text-accent-warning`}),(0,L.jsxs)(`div`,{className:`min-w-0`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium`,children:r}),(0,L.jsx)(`p`,{className:`mt-1 text-[11px] leading-relaxed text-muted-foreground`,children:i}),(0,L.jsx)(`div`,{className:`mt-1 text-[10px] text-muted-foreground`,children:t(`plugins.headroom.issueCode`,{code:e.code})})]})]})})}function me({state:e}){let{t,i18n:n}=a(`integrations`),r=e.metrics,i=r.outputSavingsAvailable,o=[`codex`,`claude`].map(e=>({provider:e,metric:r.providers[e]})),s=t(`plugins.headroom.savings.tokens`),c=o.reduce((e,{metric:t})=>({inputTokens:e.inputTokens+t.inputTokens,inputTokensSaved:e.inputTokensSaved+t.inputTokensSaved,outputTokens:e.outputTokens+t.outputTokens,outputTokensSaved:e.outputTokensSaved+t.outputTokensSaved}),{inputTokens:0,inputTokensSaved:0,outputTokens:0,outputTokensSaved:0}),l=o.some(({metric:e})=>e.inputTokensSaved>0),u=o.some(({metric:e})=>e.active),d=t(i?`plugins.headroom.savings.statusInputOutput`:l?`plugins.headroom.savings.statusInputOnly`:u?`plugins.headroom.savings.statusRouting`:`plugins.headroom.savings.statusInactive`),f=i||l;return(0,L.jsxs)(`div`,{className:`mb-4 rounded-lg border border-border bg-background/45 p-3`,children:[(0,L.jsxs)(`div`,{className:`mb-2 flex items-center justify-between gap-2`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,L.jsx)(T,{className:`h-3.5 w-3.5 text-accent-primary`}),(0,L.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t(`plugins.headroom.savings.title`)})]}),(0,L.jsx)(`span`,{className:S(`shrink-0 rounded border px-1.5 py-0.5 text-[10px]`,f?`border-accent-success/25 bg-accent-success/10 text-accent-success`:u?`border-accent-primary/25 bg-accent-primary/10 text-accent-primary`:`border-border bg-muted text-muted-foreground`),children:d})]}),(0,L.jsxs)(`div`,{className:`mb-2 rounded-md bg-muted/35 px-2.5 py-2`,children:[(0,L.jsx)(`div`,{className:`mb-1.5 text-[10px] font-medium uppercase text-muted-foreground`,children:t(`plugins.headroom.savings.totals`)}),(0,L.jsxs)(`div`,{className:`grid grid-cols-2 gap-3`,children:[(0,L.jsx)(he,{label:t(`plugins.headroom.savings.input`),processed:c.inputTokens>0?$(c.inputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:$(c.inputTokensSaved,n.language,s)}),(0,L.jsx)(he,{align:`right`,label:t(`plugins.headroom.savings.output`),processed:c.outputTokens>0?$(c.outputTokens,n.language,s):t(`plugins.headroom.savings.noData`),saved:i?$(c.outputTokensSaved,n.language,s):t(`plugins.headroom.savings.noData`)})]})]}),(0,L.jsx)(`div`,{className:`grid gap-2`,children:o.map(({provider:e,metric:t})=>(0,L.jsx)(ge,{metric:t,outputAvailable:r.outputSavingsAvailable},e))}),(0,L.jsx)(`div`,{className:`mt-2 flex items-center justify-end gap-2 text-[10px] text-muted-foreground`,children:r.updatedAt?t(`plugins.headroom.savings.updatedLive`):t(`plugins.headroom.savings.baselineSamples`,{count:e.learning.baselineSamples})})]})}function he({label:e,processed:t,saved:n,detail:r,align:i=`left`}){let{t:o}=a(`integrations`);return(0,L.jsxs)(`div`,{className:S(`min-w-0`,i===`right`&&`text-right`),children:[(0,L.jsx)(`div`,{className:`text-[10px] font-medium uppercase text-muted-foreground`,children:e}),(0,L.jsxs)(`div`,{className:`mt-1 space-y-0.5 text-[11px]`,children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.processed`)}),(0,L.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:t})]}),(0,L.jsxs)(`div`,{className:`flex min-w-0 items-baseline justify-between gap-2`,children:[(0,L.jsx)(`span`,{className:`shrink-0 text-muted-foreground`,children:o(`plugins.headroom.savings.saved`)}),(0,L.jsx)(`span`,{className:`truncate font-semibold tabular-nums text-foreground`,children:n})]})]}),r&&(0,L.jsx)(`div`,{className:`mt-1 truncate text-[10px] text-muted-foreground`,children:r})]})}function ge({metric:e,outputAvailable:t}){let{t:n,i18n:r}=a(`integrations`),i=!e.available,o=i||!e.active,s=n(`plugins.headroom.savings.tokens`),c=e.inputTokens>0?$(e.inputTokens,r.language,s):n(`plugins.headroom.savings.noData`),l=$(e.inputTokensSaved,r.language,s),u=e.outputTokens>0?$(e.outputTokens,r.language,s):n(`plugins.headroom.savings.noData`),d=t?$(e.outputTokensSaved,r.language,s):e.active?n(`plugins.headroom.savings.noData`):n(`plugins.headroom.savings.off`),f=e.requests>0?n(`plugins.headroom.savings.requestCount`,{count:ie(e.requests,r.language)}):i?n(`plugins.headroom.provider.noProjectUsesProvider`):e.active?n(`plugins.headroom.savings.inputSavingsActive`):n(`plugins.headroom.savings.routeDisabled`);return(0,L.jsxs)(`div`,{className:S(`rounded-md border border-border bg-card/45 px-2.5 py-2`,o&&`opacity-70`),children:[(0,L.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium`,children:e.label}),e.detectedRoute&&(0,L.jsx)(`span`,{className:`rounded bg-accent-primary/10 px-1.5 py-0.5 text-[9px] uppercase text-accent-primary`,children:n(`plugins.headroom.savings.detected`)})]}),(0,L.jsx)(`div`,{className:`mt-0.5 truncate text-[10px] text-muted-foreground`,children:f}),(0,L.jsxs)(`div`,{className:`mt-2 grid grid-cols-2 gap-3`,children:[(0,L.jsx)(he,{label:n(`plugins.headroom.savings.input`),processed:c,saved:l}),(0,L.jsx)(he,{align:`right`,label:n(`plugins.headroom.savings.output`),processed:u,saved:d})]})]})}function _e({provider:e,active:t,available:n,detectedRoute:r,busy:i,onClick:o}){let{t:s}=a(`integrations`),c=s(n?t?`plugins.headroom.provider.routedThroughHeadroom`:r?`plugins.headroom.provider.detectedExternalRoute`:`plugins.headroom.provider.notRouted`:`plugins.headroom.provider.noProjectUsesProvider`);return(0,L.jsxs)(`button`,{type:`button`,onClick:o,disabled:i||!n,className:`flex w-full items-center gap-3 rounded-lg border border-border bg-background/45 p-3 text-left hover:bg-muted/35 disabled:opacity-50`,children:[(0,L.jsx)(`div`,{className:S(`grid h-8 w-8 place-items-center rounded-md`,t?`bg-accent-success/15 text-accent-success`:`bg-muted text-muted-foreground`),children:i?(0,L.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,L.jsx)(M,{className:`h-3.5 w-3.5`})}),(0,L.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium capitalize`,children:e}),(0,L.jsx)(`div`,{className:`text-[11px] text-muted-foreground`,children:c})]}),(0,L.jsx)(`span`,{className:S(`h-5 w-9 rounded-full p-0.5 transition-colors`,t?`bg-accent-success`:`bg-muted`),children:(0,L.jsx)(`span`,{className:S(`block h-4 w-4 rounded-full bg-white shadow transition-transform`,t&&`translate-x-4`)})})]})}function ve({plugin:e,projects:t,onClose:n}){let{t:r}=a(`integrations`),[i,o]=(0,I.useState)(``);(0,I.useEffect)(()=>o(``),[e]);let c=t.find(e=>e.id===i)??null;return(0,L.jsx)(x,{open:!!e,onOpenChange:e=>{e||n()},children:(0,L.jsxs)(b,{className:`w-[calc(100vw-2rem)] max-w-3xl overflow-x-hidden p-4 sm:p-6`,children:[(0,L.jsxs)(y,{children:[(0,L.jsx)(v,{children:r(e===`jira`?`plugins.projectWizard.configureJira`:`plugins.projectWizard.installSerena`)}),(0,L.jsx)(_,{children:r(`plugins.projectWizard.description`)})]}),(0,L.jsxs)(`div`,{className:`grid gap-4 md:grid-cols-[260px_minmax(0,1fr)]`,children:[(0,L.jsxs)(`div`,{className:`rounded-lg border border-border bg-card/70 p-3`,children:[(0,L.jsx)(`div`,{className:`mb-2 text-xs font-medium text-muted-foreground`,children:r(`plugins.projectWizard.chooseProject`)}),(0,L.jsx)(`div`,{className:`max-h-[52vh] space-y-1 overflow-auto`,children:t.map(t=>{let n=e===`serena`&&!s(t).some(e=>q.has(e));return(0,L.jsxs)(`button`,{type:`button`,disabled:n,onClick:()=>o(t.id),className:S(`w-full rounded-md px-2 py-2 text-left transition-colors`,t.id===i?`bg-muted text-foreground`:`text-muted-foreground hover:bg-muted/45 hover:text-foreground`,n&&`cursor-not-allowed opacity-45`),children:[(0,L.jsx)(`div`,{className:`truncate text-xs font-medium`,children:t.name}),(0,L.jsx)(`div`,{className:`truncate text-[10px]`,children:n?r(`plugins.projectWizard.requiresSupportedProvider`,{defaultValue:`Requires Claude, Codex, or Kimi`}):t.path})]},t.id)})})]}),(0,L.jsx)(`div`,{className:`min-h-[360px] rounded-lg border border-border bg-card/70 p-4`,children:c?e===`jira`?(0,L.jsx)(ye,{project:c,onDone:n}):(0,L.jsx)(be,{project:c,onDone:n}):(0,L.jsx)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:r(`plugins.projectWizard.selectProjectToContinue`)})})]})]})})}function ye({project:e,onDone:t}){let{t:n}=a(`integrations`),r=Q(e.id),[i,o]=(0,I.useState)(null),[s,c]=(0,I.useState)(!0),[l,u]=(0,I.useState)(null),f=(0,I.useCallback)(async()=>{c(!0),u(null);try{let e=await fetch(`${r}/jira/connection`).then(e=>Z(e));o(e)}catch(e){o({connected:!1}),u(e.message)}finally{c(!1)}},[r]);return(0,I.useEffect)(()=>{f()},[f]),s?(0,L.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,L.jsx)(d,{className:`mr-2 h-4 w-4 animate-spin`}),n(`plugins.jira.loading`,{defaultValue:`Loading Jira...`})]}):i?.connected&&i.connection?(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.jira.configuredDescription`,{defaultValue:`Manage the Jira project, status mapping, discard status, sync, and connection state.`})})]}),(0,L.jsx)(W,{state:i,apiBase:r,onChanged:()=>{f()}})]}):(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.jira.titleForProject`,{name:e.name,defaultValue:`Jira for ${e.name}`})}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:l?n(`plugins.jira.loadFailed`,{message:l,defaultValue:`Could not load the current Jira configuration: ${l}`}):n(`plugins.jira.notConfiguredDescription`,{defaultValue:`Connect this project to Jira.`})})]}),(0,L.jsx)(z,{apiBase:r,onConnected:()=>{f()},onSkip:t})]})}function be({project:e,onDone:t}){let{t:n}=a(`integrations`),r=(0,I.useMemo)(()=>s(e).filter(e=>q.has(e)),[e]),i=r.includes(e.provider)?e.provider:r[0]??e.provider,[o,c]=(0,I.useState)(i),[l,f]=(0,I.useState)(null),[p,h]=(0,I.useState)(null),[g,_]=(0,I.useState)(!1),[v,y]=(0,I.useState)(null),b=(0,I.useRef)(0);(0,I.useEffect)(()=>{c(i),f(null),h(null)},[e.id,i]);let x=(0,I.useCallback)(async()=>{let t=++b.current;y(null);try{let n=`?provider=${encodeURIComponent(o)}`,r=await fetch(`${Q(e.id)}/plugins${n}`).then(e=>Z(e));if(t!==b.current)return;let i=r.plugins.find(e=>e.name===`serena`)??null;if(f(i),h(null),i?.status===`not-installed`){let r=await fetch(`${Q(e.id)}/plugins/serena/preview-install${n}`).then(e=>Z(e));t===b.current&&h(r)}}catch(e){t===b.current&&y(e.message)}},[e.id,o]);(0,I.useEffect)(()=>{x()},[x]);async function S(){_(!0),y(null);try{await fetch(`${Q(e.id)}/plugins/serena/install`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({provider:o})}).then(e=>Z(e)),await x(),t()}catch(e){y(e.message)}finally{_(!1)}}let C=(p?.requirements??[]).every(e=>e.installed&&e.executable&&e.meetsMinimum),T=l?n(`plugins.projectStatus.${l.status}`,{defaultValue:l.status}):``,E=l?.name===`serena`?n(`plugins.catalog.serena.description`):l?.description;return!l&&!v?(0,L.jsxs)(`div`,{className:`flex h-full items-center justify-center text-sm text-muted-foreground`,children:[(0,L.jsx)(d,{className:`mr-2 h-4 w-4 animate-spin`}),` `,n(`plugins.serena.loading`)]}):(0,L.jsxs)(`div`,{className:`space-y-4`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`h3`,{className:`text-sm font-semibold`,children:n(`plugins.serena.titleForProject`,{name:e.name})}),(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:n(`plugins.serena.description`)})]}),(0,L.jsxs)(`label`,{className:`block space-y-1`,children:[(0,L.jsx)(`span`,{className:`text-xs font-medium`,children:n(`plugins.serena.provider`,{defaultValue:`AI provider`})}),(0,L.jsx)(`select`,{"aria-label":n(`plugins.serena.provider`,{defaultValue:`AI provider`}),value:o,disabled:g,onChange:e=>{f(null),h(null),c(e.target.value)},className:`w-full rounded-md border border-border bg-background px-2 py-1.5 text-xs`,children:r.map(e=>(0,L.jsx)(`option`,{value:e,children:w(e)},e))})]}),l&&(0,L.jsxs)(`div`,{className:`rounded-lg border border-border bg-background/45 p-3`,children:[(0,L.jsx)(`div`,{className:`text-xs font-medium`,children:n(`plugins.serena.status`,{status:T})}),E&&(0,L.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:E})]}),p&&(0,L.jsxs)(`div`,{className:`space-y-3`,children:[(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.files`)}),(0,L.jsx)(`ul`,{className:`space-y-1 text-xs font-mono`,children:p.files.map(e=>(0,L.jsxs)(`li`,{className:e.op===`create`?`text-accent-success`:`text-accent-info`,children:[e.op===`create`?`+ `:`~ `,e.path]},e.path))})]}),(0,L.jsxs)(`div`,{children:[(0,L.jsx)(`div`,{className:`mb-1 text-xs font-medium`,children:n(`plugins.serena.prerequisites`)}),(0,L.jsx)(`ul`,{className:`space-y-1 text-xs`,children:p.requirements.map(e=>(0,L.jsxs)(`li`,{className:`flex items-center gap-2`,children:[e.installed&&e.executable&&e.meetsMinimum?(0,L.jsx)(D,{className:`h-3 w-3 text-accent-success`}):(0,L.jsx)(m,{className:`h-3 w-3 text-accent-warning`}),(0,L.jsxs)(`span`,{children:[e.name,e.minVersion?` >= ${e.minVersion}`:``]}),e.version&&(0,L.jsxs)(`span`,{className:`text-muted-foreground`,children:[`(`,e.version,`)`]})]},e.name))})]})]}),v&&(0,L.jsx)(`div`,{className:`rounded-lg border border-destructive/30 bg-destructive/10 p-3 text-xs text-destructive`,children:v}),(0,L.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,L.jsx)(`button`,{type:`button`,onClick:t,className:`rounded-md border border-border px-3 py-1.5 text-xs`,children:n(`plugins.actions.cancel`)}),(0,L.jsxs)(`button`,{type:`button`,disabled:g||l?.status!==`not-installed`||!C,onClick:S,className:`flex items-center gap-2 rounded-md bg-accent-primary px-3 py-1.5 text-xs text-white disabled:opacity-50`,children:[g?(0,L.jsx)(d,{className:`h-3.5 w-3.5 animate-spin`}):(0,L.jsx)(u,{className:`h-3.5 w-3.5`}),n(`plugins.actions.install`)]})]})]})}function xe({open:e,onClose:t}){let{t:n}=a(`integrations`),[i,o]=(0,I.useState)(null);return(0,I.useEffect)(()=>{e&&fetch(`${r}/api/global-plugins/headroom/diagnostics`).then(e=>Z(e)).then(o).catch(e=>o({error:e.message}))},[e]),(0,L.jsx)(x,{open:e,onOpenChange:e=>{e||t()},children:(0,L.jsxs)(b,{className:`max-w-3xl`,children:[(0,L.jsxs)(y,{children:[(0,L.jsxs)(v,{className:`flex items-center gap-2`,children:[(0,L.jsx)(F,{className:`h-4 w-4`}),` `,n(`plugins.diagnostics.title`)]}),(0,L.jsx)(_,{children:n(`plugins.diagnostics.description`)})]}),(0,L.jsx)(`pre`,{className:`max-h-[62vh] overflow-y-auto overflow-x-hidden whitespace-pre-wrap break-words rounded-lg border border-border bg-background p-3 text-xs`,children:JSON.stringify(i,null,2)})]})})}export{ae as default};
@@ -1 +0,0 @@
1
- import{a as e}from"./rolldown-runtime-CNC7AqOf.js";import{n as t,t as n}from"./jsx-runtime-zu2_FqZY.js";import{d as r,f as i,u as a}from"./chunk-KS7C4IRE-DEKu087k.js";import{B as ee,U as te,n as ne}from"./TicketDetailModalContext-B1X5glzV.js";import{n as o,t as s}from"./createLucideIcon-Bjbbp_KS.js";import{a as c,r as re}from"./useDesktop-mxHVQOdx.js";import{C as ie,S as ae,T as oe,b as se,r as ce,t as le}from"./RepositoryDeliveries-BQm_3TO8.js";import{n as ue}from"./save-B6wGWwBR.js";import{d as de,u as l}from"./MinimizedChatsContext-B6wVevPq.js";import{n as u}from"./file-text-BcLCfcWZ.js";import{t as d}from"./loader-circle-DcygOQpC.js";import{t as f}from"./sparkles-DrY8hb0X.js";import{t as p}from"./triangle-alert-H9T4jAmh.js";import{d as fe,lt as m,wt as pe,zt as me}from"./index-DYoyDWim.js";var he=s(`circle-dollar-sign`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M16 8h-6a2 2 0 1 0 0 4h4a2 2 0 1 1 0 4H8`,key:`1h4pet`}],[`path`,{d:`M12 18V6`,key:`zqpxq5`}]]),h=s(`file-diff`,[[`path`,{d:`M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z`,key:`1oefj6`}],[`path`,{d:`M9 10h6`,key:`9gxzsh`}],[`path`,{d:`M12 13V7`,key:`h0r20n`}],[`path`,{d:`M9 17h6`,key:`r8uit2`}]]),g=e(t(),1),_=(e={})=>({verbs:[],acceptMeaning:null,fineControlOnly:!1,inFlight:!1,terminal:!1,requiresIrreversibleConfirm:!1,...e});function ge(e){let{decision:t,presentation:n,prUrl:r,canCreatePr:i}=e;if(t===`building`)return _({inFlight:!0});if(t===`merged`||t===`discarded`||n.superseded)return _({terminal:!0});if(n.manualRecovery||n.recoveryUnavailable||n.recoveryRecheck||n.retryablePush||n.retryablePrCreation||n.closed||n.deliveryBlocked&&!n.implementationFailed)return _({fineControlOnly:!0});if(n.noChanges)return _({verbs:[`accept`,`request-changes`],acceptMeaning:`mark-done`});if(n.implementationFailed)return _({verbs:n.succeededCount>0?[`request-changes`,`discard`]:[`discard`]});if(t===`pr_draft`)return _(r?{verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:`publish`}:{fineControlOnly:!0});if(t===`pr_ready`)return _({verbs:[`request-changes`,`discard`]});if(t===`on_review`){let e=i?`create-pr`:`merge-local`;return _({verbs:[`accept`,`request-changes`,`discard`],acceptMeaning:e,requiresIrreversibleConfirm:e===`merge-local`})}return _({fineControlOnly:!0})}function _e(e,t){if(e===`discard`)return`discard`;if(e===`request-changes`)return null;switch(t.acceptMeaning){case`create-pr`:return`create-pr`;case`publish`:return`publish`;case`merge-local`:return`merge-local`;case`mark-done`:return`acknowledge-no-changes`;default:return null}}var v=n(),ve=[`app-verified`,`ai-reported`,`reviewer-score`],ye={"app-verified":m,"ai-reported":f,"reviewer-score":h},be={"app-verified":`text-accent-success border-accent-success/30 bg-accent-success/5`,"ai-reported":`text-accent-highlight border-accent-highlight/30 bg-accent-highlight/5`,"reviewer-score":`text-accent-info border-accent-info/30 bg-accent-info/5`};function y({item:e}){let{t}=o(`packet`);return(0,v.jsxs)(`li`,{className:`flex flex-col gap-1 py-1.5`,children:[(0,v.jsx)(`span`,{className:`text-sm text-foreground`,children:t(e.code,{...e.values??{},defaultValue:e.code})}),e.rawExcerpt?(0,v.jsx)(`pre`,{className:`max-h-32 overflow-auto rounded border border-border/60 bg-background-deep/60 p-2 text-[11px] leading-relaxed text-muted-foreground whitespace-pre-wrap`,children:e.rawExcerpt}):null]})}function b({title:e,children:t,defaultOpen:n=!1,badge:r}){let[i,a]=(0,g.useState)(n);return(0,v.jsxs)(`div`,{className:`rounded-lg border border-border/60 bg-surface/40`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>a(e=>!e),className:`flex w-full items-center gap-2 px-4 py-3 text-left`,"aria-expanded":i,children:[i?(0,v.jsx)(l,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}):(0,v.jsx)(u,{className:`size-4 shrink-0 text-muted-foreground`,"aria-hidden":!0}),(0,v.jsx)(`span`,{className:`flex-1 text-sm font-medium text-foreground`,children:e}),r]}),i?(0,v.jsx)(`div`,{className:`border-t border-border/60 px-4 py-3`,children:t}):null]})}function x(e={}){let t=r(),n=e.prDeliveryId??t.prDeliveryId,{t:s}=o([`packet`,`common`]),l=a(),[u,f]=i(),m=u.get(`repositoryId`),h=(0,g.useRef)(0),_=e.onClose??(()=>l(`/`)),{activeProjectId:x}=re(),xe=ce(x),Se=n?xe.has(n):!1,{act:S,checkout:Ce}=fe(),{openTicketDetail:we}=ne(),C=JSON.stringify([x,n,m]),w=(0,g.useRef)({key:C,epoch:0});w.current.key!==C&&(w.current={key:C,epoch:w.current.epoch+1});let T=w.current.epoch,E=(0,g.useRef)(!0);(0,g.useEffect)(()=>(E.current=!0,()=>{E.current=!1}),[]);let D=(0,g.useCallback)(()=>E.current&&w.current.key===C&&w.current.epoch===T,[C,T]),[O,k]=(0,g.useState)(null),A=O?.key===C&&O.epoch===T?O:null,j=A?.data??null,M=A?.loading??!0,N=A?.error??null,[P,F]=(0,g.useState)(null),[Te,I]=(0,g.useState)(!1),[L,R]=(0,g.useState)(null),[z,B]=(0,g.useState)(``),[V,H]=(0,g.useState)(!1),[U,W]=(0,g.useState)(null),[G,K]=(0,g.useState)(!1),q=(0,g.useCallback)(async()=>{if(!n||!x||!D())return;let e=++h.current,t=()=>D()&&h.current===e;k(e=>({key:C,epoch:T,data:e?.key===C&&e.epoch===T?e.data:null,loading:!0,error:null}));try{let e=m?`?repositoryId=${encodeURIComponent(m)}`:``,r=await fetch(`${c()}/rails/pr-deliveries/${n}/packet${e}`);if(!t())return;if(!r.ok){k({key:C,epoch:T,data:null,loading:!1,error:r.status===404?`notFound`:`loadFailed`});return}let i=await r.json();if(!t())return;k({key:C,epoch:T,data:i,loading:!1,error:null})}catch{if(!t())return;k({key:C,epoch:T,data:null,loading:!1,error:`loadFailed`})}},[n,x,m,C,T,D]);(0,g.useEffect)(()=>(q(),I(!1),K(!1),F(null),R(null),W(null),H(!1),B(``),()=>{h.current++}),[q]);let J=(0,g.useMemo)(()=>ie(j?.snapshot),[j?.snapshot]),Y=j?.packet??null,X=M||P!==null||V||!!J?.operation,Z=j?.acceptCapability??null,Q=(0,g.useMemo)(()=>{if(!Y)return null;let e=oe({decision:Y.decision,ticketIds:Y.ticketIds,prState:Y.prUrl?`pr-created`:`none`,statusCode:Y.statusCode,prUrl:Y.prUrl,runIds:Y.runIds});return ge({decision:Y.decision,presentation:e,prUrl:Y.prUrl,canCreatePr:Z?.target===`create-pr`})},[Y,Z]),$=(0,g.useCallback)(async e=>{if(!Y||!Q||X||!D())return;let t=_e(e,Q);if(t){R(null),F(e);try{let e=await(m&&J?S(J.railIndex,t,J.decision,J.prDeliveryId,m):S(Y.railIndex,t,Y.decision,Y.prDeliveryId));if(!D())return;e.ok?x&&se(x):R(e.status===409&&e.error===`stale_decision`?`alreadyResolved`:`actionFailed`),await q()}finally{D()&&(F(null),I(!1))}}},[S,x,q,Y,Q,J,m,X,D]),Ee=(0,g.useCallback)(async()=>{if(!(!Y||!z.trim()||!x||X||!D())){W(null),H(!0);try{let e=await fetch(`${c()}/rails/${Y.railIndex}/launch`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({revisionOfDeliveryId:J?.prDeliveryId??Y.prDeliveryId,revisionNote:z.trim(),...J?.executionManifest?{repositoryIds:J.executionManifest.selectedRepositoryIds}:{}})});if(!D())return;if(!e.ok){let t=await e.json().catch(()=>null);if(!D())return;W(t?.error===`invalid_revision_target`?`revisionStale`:`revisionFailed`);return}B(``),K(!1),await q()}catch{D()&&W(`revisionFailed`)}finally{D()&&H(!1)}}},[x,q,Y,z,J,X,D]);if(M&&!Y)return(0,v.jsxs)(`div`,{className:`flex h-full items-center justify-center text-muted-foreground`,children:[(0,v.jsx)(d,{className:`mr-2 size-4 animate-spin`,"aria-hidden":!0}),s(`common:states.loading`)]});if(N||!Y||!Q)return(0,v.jsxs)(`div`,{className:`mx-auto flex max-w-2xl flex-col items-center gap-4 p-10 text-center`,children:[(0,v.jsx)(p,{className:`size-6 text-accent-warning`,"aria-hidden":!0}),(0,v.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:s(N===`notFound`?`error.notFound`:`error.loadFailed`)}),(0,v.jsx)(`button`,{type:`button`,onClick:_,className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface`,children:s(`backToBoard`)})]});let De=ve.map(e=>({tier:e,items:Y.proof.filter(t=>t.tier===e)})).filter(e=>e.items.length>0),Oe=Y.cost.totalUsd===null?`—`:`${Y.cost.estimated?`~`:``}$${Y.cost.totalUsd.toFixed(2)}`;return(0,v.jsxs)(`div`,{className:`mx-auto flex w-full max-w-3xl flex-col gap-4 p-6`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:_,className:`flex w-fit items-center gap-1.5 text-xs text-muted-foreground hover:text-foreground`,children:[(0,v.jsx)(ue,{className:`size-3.5`,"aria-hidden":!0}),s(`backToBoard`)]}),J?.repositoryDeliveries?.length?(0,v.jsxs)(v.Fragment,{children:[(0,v.jsxs)(`label`,{className:`flex items-center gap-2 text-xs`,children:[s(`common:repositories.select`),(0,v.jsxs)(`select`,{value:m??``,onChange:e=>{let t=new URLSearchParams(u);e.target.value?t.set(`repositoryId`,e.target.value):t.delete(`repositoryId`),f(t,{replace:!0})},className:`rounded border border-border bg-background px-2 py-1`,children:[(0,v.jsx)(`option`,{value:``,children:s(`common:repositories.all`)}),J.repositoryDeliveries.map(e=>(0,v.jsx)(`option`,{value:e.repositoryId,children:e.name},e.repositoryId))]})]}),(0,v.jsx)(le,{deliveryId:J.prDeliveryId,repositories:J.repositoryDeliveries,busy:X,onAct:async(e,t)=>{if(!(X||!D())){F(`accept`);try{let n=await S(J.railIndex,e,J.decision,J.prDeliveryId,t);if(!D())return;n.ok||R(`actionFailed`),await q()}finally{D()&&F(null)}}},onCheckout:async e=>{if(!(X||!D())){F(`accept`);try{let t=await Ce(J.railIndex,J.prDeliveryId,e);if(!D())return;t.ok||R(`actionFailed`),await q()}finally{D()&&F(null)}}}})]}):null,(0,v.jsxs)(`div`,{className:`rounded-xl border border-border/70 bg-surface/60 p-5 shadow-sm`,children:[(0,v.jsx)(`h1`,{className:`text-lg font-semibold text-foreground`,children:s(Y.headlineCode,{count:Y.totalCount,succeeded:Y.succeededCount,total:Y.totalCount,defaultValue:Y.headlineCode})}),(0,v.jsxs)(`div`,{className:`mt-2 flex flex-wrap items-center gap-2 text-xs`,children:[Y.confidence?.overall!==null&&Y.confidence?.overall!==void 0?(0,v.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-accent-info/30 bg-accent-info/10 px-2 py-0.5 text-accent-info`,title:s(`confidence.tooltip`),children:s(`confidence.pill`,{overall:Y.confidence.overall})}):(0,v.jsx)(`span`,{className:`inline-flex items-center gap-1 rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-muted-foreground`,children:s(`confidence.unavailable`)}),(0,v.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-muted-foreground`,children:[(0,v.jsx)(he,{className:`size-3.5`,"aria-hidden":!0}),s(`cost.thisBuild`,{amount:Oe})]}),Y.prUrl?(0,v.jsxs)(`a`,{href:Y.prUrl,target:`_blank`,rel:`noreferrer`,className:`inline-flex items-center gap-1 text-accent-info hover:underline`,children:[(0,v.jsx)(te,{className:`size-3.5`,"aria-hidden":!0}),s(`openPr`,{number:Y.prNumber??``})]}):null]}),Q.fineControlOnly?(0,v.jsx)(`p`,{className:`mt-4 rounded-md border border-accent-warning/30 bg-accent-warning/5 px-3 py-2 text-xs text-accent-warning`,children:s(`fineControlOnly`)}):Q.inFlight?(0,v.jsxs)(`p`,{className:`mt-4 flex items-center gap-2 text-sm text-muted-foreground`,children:[(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}),s(`stillWorking`)]}):Q.terminal?(0,v.jsx)(`p`,{className:`mt-4 text-sm text-muted-foreground`,children:s(`alreadyResolved`)}):(0,v.jsxs)(`div`,{className:`mt-4 flex flex-wrap items-center gap-2`,children:[Q.verbs.includes(`accept`)&&(!J?.repositoryDeliveries?.length||m)?Te?(0,v.jsxs)(`div`,{className:`flex w-full flex-col gap-2 rounded-md border border-destructive/40 bg-destructive/5 p-3`,children:[(0,v.jsx)(`p`,{className:`text-xs text-foreground`,children:s(`accept.irreversibleWarning`)}),(0,v.jsxs)(`div`,{className:`flex gap-2`,children:[(0,v.jsx)(`button`,{type:`button`,onClick:()=>void $(`accept`),disabled:X,className:`rounded-md bg-destructive px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-accept-confirm`,children:s(`accept.irreversibleConfirm`)}),(0,v.jsx)(`button`,{type:`button`,onClick:()=>I(!1),className:`rounded-md border border-border px-3 py-1.5 text-sm text-foreground`,children:s(`common:actions.cancel`)})]})]}):(0,v.jsxs)(`button`,{type:`button`,onClick:()=>{Q.requiresIrreversibleConfirm?I(!0):$(`accept`)},disabled:X,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-success px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-accept`,children:[P===`accept`?(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,v.jsx)(de,{className:`size-4`,"aria-hidden":!0}),s(`accept.${Q.acceptMeaning??`generic`}`)]}):null,Q.verbs.includes(`request-changes`)?(0,v.jsxs)(`button`,{type:`button`,onClick:()=>K(e=>!e),disabled:X||V,"aria-expanded":G,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface disabled:opacity-50`,"data-testid":`packet-request-changes`,children:[(0,v.jsx)(ee,{className:`size-4`,"aria-hidden":!0}),s(`requestChanges.label`)]}):null,Q.verbs.includes(`discard`)?(0,v.jsxs)(`button`,{type:`button`,onClick:()=>void $(`discard`),disabled:X,className:`inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-sm text-foreground hover:bg-surface disabled:opacity-50`,"data-testid":`packet-discard`,children:[P===`discard`?(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,v.jsx)(me,{className:`size-4`,"aria-hidden":!0}),s(`discard.label`)]}):null]}),Se&&Q.verbs.includes(`discard`)?(0,v.jsx)(`p`,{className:`mt-3 rounded-md border border-accent-warning/40 bg-accent-warning/10 px-3 py-2 text-xs text-accent-warning`,"data-testid":`packet-discard-stacked-note`,children:s(`discard.stackedNote`)}):null,L?(0,v.jsx)(`p`,{className:`mt-3 text-xs text-accent-warning`,children:s(`error.${L}`)}):null,G?(0,v.jsxs)(`div`,{className:`mt-4 flex flex-col gap-2 rounded-md border border-border/70 bg-background-deep/40 p-3`,children:[(0,v.jsx)(`label`,{htmlFor:`packet-revision-note`,className:`text-xs font-medium text-foreground`,children:s(`requestChanges.prompt`)}),(0,v.jsx)(`textarea`,{id:`packet-revision-note`,value:z,onChange:e=>B(e.target.value),rows:2,placeholder:s(`requestChanges.placeholder`),className:`resize-y rounded-md border border-border bg-surface px-2 py-1.5 text-sm text-foreground placeholder:text-muted-foreground`,"data-testid":`packet-revision-input`}),(0,v.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>void Ee(),disabled:X||z.trim().length===0,className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary px-3 py-1.5 text-sm font-medium text-white disabled:opacity-50`,"data-testid":`packet-revision-submit`,children:[V?(0,v.jsx)(d,{className:`size-4 animate-spin`,"aria-hidden":!0}):(0,v.jsx)(ae,{className:`size-4`,"aria-hidden":!0}),s(`requestChanges.submit`)]}),(0,v.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:s(`requestChanges.hint`)})]}),U?(0,v.jsx)(`p`,{className:`text-xs text-accent-warning`,children:s(`error.${U}`)}):null]}):null]}),Y.driftNudges.length>0?(0,v.jsxs)(`div`,{className:`rounded-lg border border-accent-highlight/30 bg-accent-highlight/5 p-4`,"data-testid":`packet-drift-nudges`,children:[(0,v.jsx)(`h2`,{className:`mb-1 text-sm font-medium text-accent-highlight`,children:s(`drift.title`)}),(0,v.jsx)(`ul`,{className:`space-y-1 text-xs text-foreground`,children:Y.driftNudges.map(e=>(0,v.jsx)(`li`,{children:s(e.code,{...e.values,defaultValue:e.code})},e.code))}),(0,v.jsx)(`p`,{className:`mt-2 text-[11px] text-muted-foreground`,children:s(`drift.advisory`)})]}):null,Y.versions.length>1?(0,v.jsxs)(b,{title:s(`versions.title`,{count:Y.versions.length}),badge:(0,v.jsx)(pe,{className:`size-3.5 text-muted-foreground`,"aria-hidden":!0}),children:[(0,v.jsx)(`ol`,{className:`space-y-2`,"data-testid":`packet-versions`,children:Y.versions.map(e=>(0,v.jsxs)(`li`,{className:`flex flex-col gap-0.5 text-sm`,children:[(0,v.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,v.jsx)(`span`,{className:e.current?`font-medium text-foreground`:`text-muted-foreground`,children:s(`versions.label`,{version:e.version})}),e.current?(0,v.jsx)(`span`,{className:`rounded-full border border-accent-primary/40 bg-accent-primary/10 px-1.5 text-[10px] text-accent-primary`,children:s(`versions.current`)}):null,(0,v.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:e.costUsd===null?`—`:`${e.costEstimated?`~`:``}$${e.costUsd.toFixed(2)}`})]}),(0,v.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:e.revisionNote??s(`versions.originalBuild`)})]},e.prDeliveryId))}),(0,v.jsx)(`p`,{className:`mt-3 text-xs text-muted-foreground`,children:s(`cost.allVersions`,{amount:Y.chainCostUsd===null?`—`:`${Y.chainCostEstimated?`~`:``}$${Y.chainCostUsd.toFixed(2)}`})})]}):null,Y.watchOut.length>0?(0,v.jsxs)(`div`,{className:`rounded-lg border border-accent-warning/30 bg-accent-warning/5 p-4`,children:[(0,v.jsxs)(`h2`,{className:`mb-2 flex items-center gap-1.5 text-sm font-medium text-accent-warning`,children:[(0,v.jsx)(p,{className:`size-4`,"aria-hidden":!0}),s(`watchOut.title`)]}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:Y.watchOut.map((e,t)=>(0,v.jsx)(y,{item:e},`${e.code}-${t}`))})]}):null,(0,v.jsx)(b,{title:s(`sections.whatYouAsked`),defaultOpen:!0,children:(0,v.jsx)(`ul`,{className:`space-y-3`,children:Y.sections.map(e=>(0,v.jsxs)(`li`,{className:`text-sm`,children:[(0,v.jsxs)(`button`,{type:`button`,onClick:()=>we(e.ticketId),className:`text-accent-primary hover:underline`,children:[`#`,e.ticketId,` `,e.title??``]}),e.problem?(0,v.jsx)(`p`,{className:`mt-1 text-muted-foreground`,children:e.problem}):null]},e.ticketId))})}),(0,v.jsx)(b,{title:s(`sections.whatIDid`),children:(0,v.jsx)(`ul`,{className:`space-y-3`,children:Y.sections.map(e=>(0,v.jsxs)(`li`,{className:`text-sm`,children:[(0,v.jsxs)(`span`,{className:`font-medium text-foreground`,children:[`#`,e.ticketId]}),` `,e.solution??(0,v.jsx)(`span`,{className:`text-muted-foreground`,children:s(`noSolutionRecorded`)}),e.churn?(0,v.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s(`churn.line`,{files:e.churn.filesTouched,added:e.churn.addedLines,removed:e.churn.removedLines})}):(0,v.jsx)(`p`,{className:`mt-1 text-xs text-muted-foreground`,children:s(`churn.batchNotSplittable`)})]},e.ticketId))})}),(0,v.jsx)(b,{title:s(`sections.howItWasChecked`),badge:Y.evidenceUnavailable?(0,v.jsx)(`span`,{className:`rounded-full border border-border bg-background-deep/50 px-2 py-0.5 text-[10px] text-muted-foreground`,children:s(`proof.evidenceUnavailable`)}):void 0,children:(0,v.jsx)(`div`,{className:`space-y-4`,children:De.map(({tier:e,items:t})=>{let n=ye[e];return(0,v.jsxs)(`div`,{className:`rounded-md border px-3 py-2 ${be[e]}`,children:[(0,v.jsxs)(`h3`,{className:`mb-1 flex items-center gap-1.5 text-xs font-medium`,children:[(0,v.jsx)(n,{className:`size-3.5`,"aria-hidden":!0}),s(`tier.${e}.title`)]}),(0,v.jsx)(`p`,{className:`mb-2 text-[11px] opacity-80`,children:s(`tier.${e}.caveat`)}),(0,v.jsx)(`ul`,{className:`space-y-1`,children:t.map((e,t)=>(0,v.jsx)(y,{item:e},`${e.code}-${t}`))})]},e)})})})]})}export{x as default};
@@ -1 +0,0 @@
1
- import{t as e}from"./jsx-runtime-zu2_FqZY.js";import{n as t}from"./createLucideIcon-Bjbbp_KS.js";import{t as n}from"./brain-DI9lHkKY.js";import{t as r}from"./download-CFHyyHcw.js";import{t as i}from"./git-branch-BRM0F5GN.js";import{n as a,t as o}from"./square-Ci-PFcFe.js";import{a as s,i as c,l,o as u,r as d,t as f}from"./dialog-xXB2q5HJ.js";import{t as p}from"./button-Ccc9Dc-D.js";import{at as m,h,jt as g}from"./index-DYoyDWim.js";var _=e(),v={start:a,"ai-step":n,shell:m,decider:i,condition:i,end:o};function y(e){return e.type===`ai-step`?typeof e.data?.prompt==`string`?e.data.prompt:null:e.type===`shell`?typeof e.data?.command==`string`?e.data.command:null:e.type===`decider`?typeof e.data?.goal==`string`?e.data.goal:null:e.type===`end`?e.data?.outcome===`failure`?`failure`:`success`:null}function b({template:e,onClose:i,onUse:a,mode:m=`use`}){let{t:b}=t(`loops`);return(0,_.jsx)(f,{open:e!==null,onOpenChange:e=>{e||i()},children:(0,_.jsx)(d,{movableResizable:!0,className:`max-w-lg`,children:e&&(0,_.jsxs)(_.Fragment,{children:[(0,_.jsxs)(u,{children:[(0,_.jsxs)(l,{className:`flex items-center gap-2`,children:[(0,_.jsx)(n,{className:`w-4 h-4 text-accent-highlight`}),e.name]}),(0,_.jsx)(c,{children:e.description})]}),(0,_.jsxs)(`div`,{className:`flex flex-wrap gap-1.5`,children:[h(e.graph)?(0,_.jsx)(`span`,{title:b(`gallery.needsSpecHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-secondary/15 text-accent-secondary`,children:b(`gallery.needsSpec`)}):(0,_.jsx)(`span`,{title:b(`gallery.standaloneHint`),className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-success/15 text-accent-success`,children:b(`gallery.standalone`)}),e.category&&(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-accent-info/15 text-accent-info`,children:b(`categories.${e.category}`,{defaultValue:e.category})}),e.tags.map(e=>(0,_.jsx)(`span`,{className:`px-1.5 py-0.5 rounded text-[10px] bg-muted text-muted-foreground`,children:e},e))]}),(0,_.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:e.graph.config.timeoutMinutes>0?b(`preview.limits`,{iterations:e.graph.config.maxIterations,timeout:e.graph.config.timeoutMinutes}):b(`preview.limitsNoTimeout`,{iterations:e.graph.config.maxIterations})}),(0,_.jsxs)(`div`,{className:`max-h-[50vh] overflow-y-auto space-y-1.5 pr-1`,children:[(0,_.jsx)(`span`,{className:`block text-[10px] font-medium uppercase tracking-wide text-muted-foreground`,children:b(`preview.steps`)}),e.graph.nodes.map((e,t)=>{let n=v[e.type]??o,r=y(e);return(0,_.jsxs)(`div`,{className:`rounded border border-border bg-surface/30 p-2`,children:[(0,_.jsxs)(`div`,{className:`flex items-center gap-1.5 text-xs font-medium text-foreground`,children:[(0,_.jsxs)(`span`,{className:`text-[10px] text-muted-foreground tabular-nums`,children:[t+1,`.`]}),(0,_.jsx)(n,{className:`w-3.5 h-3.5 text-accent-primary`}),b(`builder.nodes.${e.type}`)]}),r&&(0,_.jsx)(`pre`,{className:`mt-1 whitespace-pre-wrap break-words text-[11px] text-muted-foreground font-mono`,children:r})]},e.id)})]}),(0,_.jsxs)(s,{children:[(0,_.jsx)(p,{variant:`ghost`,onClick:i,children:b(`common:actions.cancel`)}),(0,_.jsxs)(p,{onClick:()=>a(e.id),children:[m===`fork`?(0,_.jsx)(g,{className:`w-3.5 h-3.5 mr-1.5`}):(0,_.jsx)(r,{className:`w-3.5 h-3.5 mr-1.5`}),b(m===`fork`?`actions.fork`:`actions.use`)]})]})]})})})}export{b as n,y as r,v as t};