specrails-desktop 2.28.1 → 2.29.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (252) hide show
  1. package/client/dist/assets/{ActivityFeedPage-DcMmDAP3.js → ActivityFeedPage-D8RKRRoM.js} +1 -1
  2. package/client/dist/assets/AgentBrowserCapture-BUHPHNSN.js +1 -0
  3. package/client/dist/assets/{AgentModeCodePane-CM77ljte.js → AgentModeCodePane-GZc8bNGT.js} +2 -2
  4. package/client/dist/assets/AgentModeJobsPane-DWtQqj3k.js +1 -0
  5. package/client/dist/assets/AgentsPage-CKPtHkRP.js +86 -0
  6. package/client/dist/assets/{AnalyticsPage-B4qflNxi.js → AnalyticsPage-CZW8c77k.js} +1 -1
  7. package/client/dist/assets/{BarChart-Ckstq9fl.js → BarChart-DugEoe2q.js} +2 -2
  8. package/client/dist/assets/CodePage-CQ-uKETG.js +2 -0
  9. package/client/dist/assets/{DesktopAnalyticsPage-DbgMa8OO.js → DesktopAnalyticsPage-Bgo4SyCH.js} +1 -1
  10. package/client/dist/assets/{DocsDialog-BQc9Kwev.js → DocsDialog-DxpWw_La.js} +2 -2
  11. package/client/dist/assets/DocsPage-CmcOkK19.js +11 -0
  12. package/client/dist/assets/{ExportDropdown-a43XHO3Y.js → ExportDropdown-DvTS2wc7.js} +1 -1
  13. package/client/dist/assets/IntegrationsPage-B72WxJ3Z.js +1 -0
  14. package/client/dist/assets/InteractiveJobComposer-B5gh4Qoy.js +19 -0
  15. package/client/dist/assets/JobDetailModal-D-BeqsJ6.js +1 -0
  16. package/client/dist/assets/JobDetailPage-DwdozwLO.js +1 -0
  17. package/client/dist/assets/JobsPage-BDkinklt.js +1 -0
  18. package/client/dist/assets/LoopBuilderPage-CclJ3VZA.js +7 -0
  19. package/client/dist/assets/{LoopPreviewModal-B2wmifF6.js → LoopPreviewModal-Dw4UgoLu.js} +1 -1
  20. package/client/dist/assets/LoopsPage-D7ac4M24.js +1 -0
  21. package/client/dist/assets/PluginsPage-wdC-qa40.js +2 -0
  22. package/client/dist/assets/ProjectSettingsDialog-BlTlRtGI.js +1 -0
  23. package/client/dist/assets/TemplatePreviewModal-CeMx2Red.js +1 -0
  24. package/client/dist/assets/{agent-ostmMYNz2.js → agent-B8BXmlUQ2.js} +1 -1
  25. package/client/dist/assets/{agent-MaTxBlg5.js → agent-BEXYxDbs.js} +1 -1
  26. package/client/dist/assets/{agent-D4JAuEGN2.js → agent-BYc3-6Ln2.js} +1 -1
  27. package/client/dist/assets/{agent-DNQlI8EN.js → agent-BbJorPdT.js} +1 -1
  28. package/client/dist/assets/{agent-CxnRzL6Z.js → agent-CewFImgL.js} +1 -1
  29. package/client/dist/assets/{agent-BuYz6fJd.js → agent-DfhYoUmp.js} +1 -1
  30. package/client/dist/assets/{agent-DyzUH89R.js → agent-TK_rrK4d.js} +1 -1
  31. package/client/dist/assets/{agent-BRJCESkc2.js → agent-bHjA9R_j2.js} +1 -1
  32. package/client/dist/assets/{brain-BPbhM1Jx.js → brain-C92rjjYP.js} +1 -1
  33. package/client/dist/assets/{dist-js-Byjcju1W.js → dist-js-CgpP6tKI.js} +1 -1
  34. package/client/dist/assets/{dist-js-Dh-9lbLD.js → dist-js-DHiN-A_E.js} +1 -1
  35. package/client/dist/assets/index-BVbgKXUu.css +2 -0
  36. package/client/dist/assets/index-DyY1QyIn.js +158 -0
  37. package/client/dist/assets/{lib-yKyTNJ1c.js → lib-0PFDyMxJ.js} +1 -1
  38. package/client/dist/assets/{settings-Bp24JHlv2.js → settings-1w1O5Og82.js} +1 -1
  39. package/client/dist/assets/{settings-C_T0-j9d.js → settings-BSihkr0e.js} +1 -1
  40. package/client/dist/assets/{settings-DhaFKpcw2.js → settings-BiDOB3hV2.js} +1 -1
  41. package/client/dist/assets/{settings-BemR_e3F.js → settings-BoubJhDP2.js} +1 -1
  42. package/client/dist/assets/{settings-BvIwQ3A1.js → settings-CB-EZ_W8.js} +1 -1
  43. package/client/dist/assets/{settings-B_v3zgJf.js → settings-DNL68KTE.js} +1 -1
  44. package/client/dist/assets/{settings-Bx2ObkTR2.js → settings-Jc46vUhd.js} +1 -1
  45. package/client/dist/assets/{settings-BYCMtxOz.js → settings-cJNynGIZ.js} +1 -1
  46. package/client/dist/assets/{upload-Qh1NE3xi.js → upload-CmR4h9H1.js} +1 -1
  47. package/client/dist/assets/{value-BMPeyInx.js → value-JA3bf47v.js} +1 -1
  48. package/client/dist/index.html +4 -4
  49. package/package.json +1 -1
  50. package/server/dist/agent-operator-prompt.js +33 -1
  51. package/server/dist/headroom-manager.js +0 -1
  52. package/server/dist/loop-factory.js +15 -8
  53. package/server/dist/loop-graph.js +7 -0
  54. package/server/dist/loop-run-manager.js +115 -13
  55. package/server/dist/loop-runs-store.js +27 -8
  56. package/server/dist/loop-templates.js +10 -2
  57. package/server/dist/mcp/tools/jobs.js +3 -3
  58. package/server/dist/mcp/tools/rails.js +2 -1
  59. package/server/dist/project-registry.js +2 -0
  60. package/server/dist/project-router-jobs.js +15 -11
  61. package/server/dist/rail-isolated-launch.js +23 -9
  62. package/server/dist/rail-pr-decision.js +18 -6
  63. package/server/dist/rail-worktree-release.js +12 -6
  64. package/server/dist/rails-router.js +9 -2
  65. package/server/dist/worktree-manager.js +115 -19
  66. package/client/dist/assets/AgentBrowserCapture-CZ3oc1UL.js +0 -1
  67. package/client/dist/assets/AgentIntegrationsModal-DkqooCFn.js +0 -1
  68. package/client/dist/assets/AgentModeJobsPane-DbZzogbi.js +0 -1
  69. package/client/dist/assets/AgentsPage-BZIml7eL.js +0 -86
  70. package/client/dist/assets/CodePage-DFZXLbI1.js +0 -2
  71. package/client/dist/assets/DocsPage-OsV44ECy.js +0 -11
  72. package/client/dist/assets/IntegrationsPage-C3E8hZhB.js +0 -1
  73. package/client/dist/assets/InteractiveJobComposer-zj8SrOAl.js +0 -19
  74. package/client/dist/assets/JobDetailModal-Cm6ZeVoh.js +0 -1
  75. package/client/dist/assets/JobDetailPage-DN67LsdX.js +0 -1
  76. package/client/dist/assets/JobsPage-DF9wKGbw.js +0 -1
  77. package/client/dist/assets/LoopBuilderPage-RJ6GGjli.js +0 -7
  78. package/client/dist/assets/LoopsPage-DdlvH-dJ.js +0 -1
  79. package/client/dist/assets/PluginsPage-9DI0a6jI.js +0 -2
  80. package/client/dist/assets/ProjectSettingsDialog-dgy5hqPd.js +0 -1
  81. package/client/dist/assets/TemplatePreviewModal-CERf1IYB.js +0 -1
  82. package/client/dist/assets/index-89SuhD4Y.js +0 -158
  83. package/client/dist/assets/index-DOGzWJhO.css +0 -2
  84. /package/client/dist/assets/{activity-BbWiDfn-2.js → activity--iN4Ad2R2.js} +0 -0
  85. /package/client/dist/assets/{activity-DvECTYGt.js → activity-6hM_ZSg9.js} +0 -0
  86. /package/client/dist/assets/{activity-BZZlEG3a.js → activity-BZNfOdiS.js} +0 -0
  87. /package/client/dist/assets/{activity-DtzRy92x.js → activity-BuVo5sPB.js} +0 -0
  88. /package/client/dist/assets/{activity-D3Ic-HTS.js → activity-CIOLxGvh.js} +0 -0
  89. /package/client/dist/assets/{activity-FleOlK0l2.js → activity-D2r2h3SE2.js} +0 -0
  90. /package/client/dist/assets/{activity-DFbvNqhE2.js → activity-DtxrAUMo2.js} +0 -0
  91. /package/client/dist/assets/{addspec-CFxGvmJR2.js → addspec-BMtLZLW62.js} +0 -0
  92. /package/client/dist/assets/{addspec-DaA-CbTt.js → addspec-CP0HRuxY.js} +0 -0
  93. /package/client/dist/assets/{addspec-NBbcTbLc.js → addspec-CRuvWn8d.js} +0 -0
  94. /package/client/dist/assets/{addspec-BKrH2Ucz.js → addspec-D-JLDsUV.js} +0 -0
  95. /package/client/dist/assets/{addspec-B_LQMHW3.js → addspec-DfhDbg5c.js} +0 -0
  96. /package/client/dist/assets/{addspec-Bw_YQwo62.js → addspec-bsNDdqRm2.js} +0 -0
  97. /package/client/dist/assets/{addspec-CR8MB5Fr2.js → addspec-mgPOt5q02.js} +0 -0
  98. /package/client/dist/assets/{agents-BHgn--3j.js → agents-78bTZGZh.js} +0 -0
  99. /package/client/dist/assets/{agents-CV-_xBvX2.js → agents-BLhWCmDS2.js} +0 -0
  100. /package/client/dist/assets/{agents-B_qGaB0F.js → agents-BUdEi3-N.js} +0 -0
  101. /package/client/dist/assets/{agents-B9pFSJQI2.js → agents-BpoUaoW92.js} +0 -0
  102. /package/client/dist/assets/{agents-HFCqQH0Z.js → agents-CWo-KyAB.js} +0 -0
  103. /package/client/dist/assets/{agents-VsyFhGOS2.js → agents-DDtCJ5M02.js} +0 -0
  104. /package/client/dist/assets/{agents-CP8_ezYG.js → agents-bvyRLczL.js} +0 -0
  105. /package/client/dist/assets/{agentstudio-BEp7Sb46.js → agentstudio-BMQxc_bz.js} +0 -0
  106. /package/client/dist/assets/{agentstudio-RfZavULt2.js → agentstudio-COZriimI2.js} +0 -0
  107. /package/client/dist/assets/{agentstudio-D2A5peWV2.js → agentstudio-CWgXG5W52.js} +0 -0
  108. /package/client/dist/assets/{agentstudio-Br3WD7Xs.js → agentstudio-C_Jq8Tl4.js} +0 -0
  109. /package/client/dist/assets/{agentstudio-BOjG6tgJ.js → agentstudio-Dtq3dGYk.js} +0 -0
  110. /package/client/dist/assets/{agentstudio-RsxnZtUA.js → agentstudio-jKMTdT70.js} +0 -0
  111. /package/client/dist/assets/{agentstudio-CuTt3ZGe2.js → agentstudio-sI27TpBu2.js} +0 -0
  112. /package/client/dist/assets/{aiedit-CV520D4W2.js → aiedit-6CHdb_iv2.js} +0 -0
  113. /package/client/dist/assets/{aiedit-DrIjSojo.js → aiedit-B03pD_Na.js} +0 -0
  114. /package/client/dist/assets/{aiedit-a-Z-g5iC.js → aiedit-BtRqRxML.js} +0 -0
  115. /package/client/dist/assets/{aiedit-D0Syl-mC.js → aiedit-eMN4eQPF.js} +0 -0
  116. /package/client/dist/assets/{aiedit-DnBzjlVz2.js → aiedit-hknZlly82.js} +0 -0
  117. /package/client/dist/assets/{aiedit-26p5A_HY2.js → aiedit-igmw-ZoZ2.js} +0 -0
  118. /package/client/dist/assets/{aiedit-CcugGPbS.js → aiedit-pc5JDUq1.js} +0 -0
  119. /package/client/dist/assets/{analytics-Bpe41fnX2.js → analytics-BWMUZ2Pq2.js} +0 -0
  120. /package/client/dist/assets/{analytics-CpSTNfui.js → analytics-Bj-SmKHa.js} +0 -0
  121. /package/client/dist/assets/{analytics-4-eskbtX.js → analytics-C5dpiS0o.js} +0 -0
  122. /package/client/dist/assets/{analytics-DEe5BMz8.js → analytics-CCprAqk3.js} +0 -0
  123. /package/client/dist/assets/{analytics-4HvXb0Vn2.js → analytics-CR1TJqUi2.js} +0 -0
  124. /package/client/dist/assets/{analytics-DcOITHla2.js → analytics-DfNdXR0y2.js} +0 -0
  125. /package/client/dist/assets/{analytics-Bd9rHGjV.js → analytics-rmHuJv0V.js} +0 -0
  126. /package/client/dist/assets/{attachments-CgOQ9K-6.js → attachments-BgBNSqQd.js} +0 -0
  127. /package/client/dist/assets/{attachments-CA2f3qL3.js → attachments-BjyMmrwE.js} +0 -0
  128. /package/client/dist/assets/{attachments-DlEQu56g2.js → attachments-C9GTTJsx2.js} +0 -0
  129. /package/client/dist/assets/{attachments-CHDbhKeH.js → attachments-DCZOL1RU.js} +0 -0
  130. /package/client/dist/assets/{attachments-jVdKzAXn.js → attachments-DL-bPy9E.js} +0 -0
  131. /package/client/dist/assets/{attachments-D2jwJXQ42.js → attachments-DPCmkFZu2.js} +0 -0
  132. /package/client/dist/assets/{attachments-CKAY5aYG2.js → attachments-rNn1ekRy2.js} +0 -0
  133. /package/client/dist/assets/{browser-Cl-FwPXs.js → browser-BPkhILSJ.js} +0 -0
  134. /package/client/dist/assets/{browser-kA31eYhu2.js → browser-BijVYG0Y2.js} +0 -0
  135. /package/client/dist/assets/{browser-JsiohNmW.js → browser-BqLqJVVT.js} +0 -0
  136. /package/client/dist/assets/{browser-C4VJ5CW12.js → browser-Cc0iDqUi.js} +0 -0
  137. /package/client/dist/assets/{browser-BQFDxrRq.js → browser-Cvg-QHvd2.js} +0 -0
  138. /package/client/dist/assets/{browser-Do2jf8_N.js → browser-FRv8P02E.js} +0 -0
  139. /package/client/dist/assets/{browser-BbJ_q_OT2.js → browser-rWKj-RR_2.js} +0 -0
  140. /package/client/dist/assets/{chat-SaG-ng1x2.js → chat-BgL3zv6x2.js} +0 -0
  141. /package/client/dist/assets/{chat-n43nZGvn.js → chat-Bh3NdgJs.js} +0 -0
  142. /package/client/dist/assets/{chat-BalviUAD.js → chat-Bom6bqK3.js} +0 -0
  143. /package/client/dist/assets/{chat-BMWD_Rx12.js → chat-DdwZjT8K2.js} +0 -0
  144. /package/client/dist/assets/{chat-D5xEtsf3.js → chat-Dnwg-NpQ.js} +0 -0
  145. /package/client/dist/assets/{chat-CJddjN3D2.js → chat-DsbwJhus.js} +0 -0
  146. /package/client/dist/assets/{chat-Ds8GvCnv.js → chat-vylxqR0P2.js} +0 -0
  147. /package/client/dist/assets/{code-BotxM43N2.js → code-BRcDlze52.js} +0 -0
  148. /package/client/dist/assets/{code-CIPmDEd0.js → code-BdMy3Ffq.js} +0 -0
  149. /package/client/dist/assets/{code-HDK4P6Rx.js → code-CeQ0FZpC.js} +0 -0
  150. /package/client/dist/assets/{code-F_KjccGf.js → code-CwnBPPyA.js} +0 -0
  151. /package/client/dist/assets/{code-DUe1Bouz.js → code-DgeHz9CB.js} +0 -0
  152. /package/client/dist/assets/{code-Bit_z2Xd2.js → code-DzC1rMk12.js} +0 -0
  153. /package/client/dist/assets/{code-C9U6M5-e2.js → code-UPVvmAKM2.js} +0 -0
  154. /package/client/dist/assets/{commands-CzFSoIiq2.js → commands-C4Y3C-PF2.js} +0 -0
  155. /package/client/dist/assets/{commands-BllkJauO.js → commands-CSDs9q_2.js} +0 -0
  156. /package/client/dist/assets/{commands-BFQZc9AG.js → commands-DkU0qliq.js} +0 -0
  157. /package/client/dist/assets/{commands-KBbhsnw8.js → commands-JWMfGDmr.js} +0 -0
  158. /package/client/dist/assets/{commands-cKTaLwwV2.js → commands-RHOchN4n2.js} +0 -0
  159. /package/client/dist/assets/{commands-BMkC5-ki.js → commands-u-4eEHCN.js} +0 -0
  160. /package/client/dist/assets/{commands-CWX9WmDX2.js → commands-xHDDGfcP2.js} +0 -0
  161. /package/client/dist/assets/{common-DZbXlmq72.js → common-BM3LFLCE2.js} +0 -0
  162. /package/client/dist/assets/{common-Cfmwcrl52.js → common-Bwafujnc2.js} +0 -0
  163. /package/client/dist/assets/{common-D2cimsul.js → common-C-vU-j-I.js} +0 -0
  164. /package/client/dist/assets/{common-DH7fjyL1.js → common-C5HKSbbz.js} +0 -0
  165. /package/client/dist/assets/{common-CF8iGXrG.js → common-DhWTkocg.js} +0 -0
  166. /package/client/dist/assets/{common-DtXmzX2o2.js → common-DiPTT7V_2.js} +0 -0
  167. /package/client/dist/assets/{common-BfQD173j.js → common-DmqBPwZG.js} +0 -0
  168. /package/client/dist/assets/{dashboard-CiOyDh9L.js → dashboard-B5ang-ZS.js} +0 -0
  169. /package/client/dist/assets/{dashboard-BFfnCtq52.js → dashboard-CHHcOWVL2.js} +0 -0
  170. /package/client/dist/assets/{dashboard-BIC8KtRf2.js → dashboard-DBD4wPGY2.js} +0 -0
  171. /package/client/dist/assets/{dashboard-5C2FOZQX.js → dashboard-DSnztwWH.js} +0 -0
  172. /package/client/dist/assets/{dashboard-CEgg9NAr.js → dashboard-D_aP_InU.js} +0 -0
  173. /package/client/dist/assets/{dashboard-B6iQ-IL_.js → dashboard-DmBcdl1B.js} +0 -0
  174. /package/client/dist/assets/{dashboard-D6x5OnNj2.js → dashboard-RIcUKY1Y2.js} +0 -0
  175. /package/client/dist/assets/{explore-CAc8Qzu32.js → explore-B7fblXBb2.js} +0 -0
  176. /package/client/dist/assets/{explore-ELbrSZyQ2.js → explore-BHtEpoNN2.js} +0 -0
  177. /package/client/dist/assets/{explore-Bhy7WWXv.js → explore-C0k8HrkN.js} +0 -0
  178. /package/client/dist/assets/{explore-BO_OinBD.js → explore-CNBzrEPS.js} +0 -0
  179. /package/client/dist/assets/{explore-DCZL9gRN2.js → explore-D_mWBYCS2.js} +0 -0
  180. /package/client/dist/assets/{explore-DW_YTkQh.js → explore-Dahc1lOx.js} +0 -0
  181. /package/client/dist/assets/{explore-BEpIs343.js → explore-UvW1jEMa.js} +0 -0
  182. /package/client/dist/assets/{format-command-Db1viey1.js → format-command-CuWuRvka.js} +0 -0
  183. /package/client/dist/assets/{integrations-CWjh5VRk.js → integrations-2YcNyAl3.js} +0 -0
  184. /package/client/dist/assets/{integrations-RJfzXkPx2.js → integrations-BXCvXUlG2.js} +0 -0
  185. /package/client/dist/assets/{integrations-CUNe3t9l2.js → integrations-C1ThkTC52.js} +0 -0
  186. /package/client/dist/assets/{integrations-CAjq5tdW2.js → integrations-Crk2rFhL2.js} +0 -0
  187. /package/client/dist/assets/{integrations-CP_aiV_8.js → integrations-D9YrJ_Ep.js} +0 -0
  188. /package/client/dist/assets/{integrations-JOHSCvB3.js → integrations-Dn4JiGtW.js} +0 -0
  189. /package/client/dist/assets/{integrations-CG2dp3Kd.js → integrations-TAcYNh0b.js} +0 -0
  190. /package/client/dist/assets/{jira-C5UjxHE4.js → jira-BHAKtc4B.js} +0 -0
  191. /package/client/dist/assets/{jira-ZdKb-50F2.js → jira-Be369RIR2.js} +0 -0
  192. /package/client/dist/assets/{jira-DTYu3hJi2.js → jira-CPpgA-5z2.js} +0 -0
  193. /package/client/dist/assets/{jira-CQ7mrZde.js → jira-D5efgwp_.js} +0 -0
  194. /package/client/dist/assets/{jira-DtZpokjJ.js → jira-DS7ownDy.js} +0 -0
  195. /package/client/dist/assets/{jira-DIRkZk9U.js → jira-bDs7Im2C.js} +0 -0
  196. /package/client/dist/assets/{jira-B5wszJ1-2.js → jira-uNH1gETL2.js} +0 -0
  197. /package/client/dist/assets/{jobs-DAGiPVIS2.js → jobs-1GV2-4zd2.js} +0 -0
  198. /package/client/dist/assets/{jobs-DAU8C_tZ.js → jobs-26F9gGcE.js} +0 -0
  199. /package/client/dist/assets/{jobs-BJ-Gcao22.js → jobs-BgQzB0Sx2.js} +0 -0
  200. /package/client/dist/assets/{jobs-Da0GaaSc.js → jobs-BqWui9_f.js} +0 -0
  201. /package/client/dist/assets/{jobs-BFIdeDTw.js → jobs-CE8qeIYj.js} +0 -0
  202. /package/client/dist/assets/{jobs-p360zdf1.js → jobs-DzeuASRf.js} +0 -0
  203. /package/client/dist/assets/{jobs-P3unxtxo2.js → jobs-Wh7dn28q2.js} +0 -0
  204. /package/client/dist/assets/{loops-BjK8lmoZ2.js → loops-BvqQ-bHR2.js} +0 -0
  205. /package/client/dist/assets/{loops-Bi4ywYGn.js → loops-CvOWsi5r.js} +0 -0
  206. /package/client/dist/assets/{loops-DDs4KPu_.js → loops-D6D3XHjj.js} +0 -0
  207. /package/client/dist/assets/{loops-Du-bNVpc2.js → loops-DJNhp17p2.js} +0 -0
  208. /package/client/dist/assets/{loops-D3wdUkZV.js → loops-K5_HXfJa.js} +0 -0
  209. /package/client/dist/assets/{loops-DKzYFcq6.js → loops-LIgO_-eM.js} +0 -0
  210. /package/client/dist/assets/{loops-DvGbSfxw2.js → loops-vhJdbcz92.js} +0 -0
  211. /package/client/dist/assets/{mcp-DyULurYS2.js → mcp-CjVKXAhD2.js} +0 -0
  212. /package/client/dist/assets/{mcp-DfmzoT5t.js → mcp-Dcl-XxkR.js} +0 -0
  213. /package/client/dist/assets/{mcp-CbJ04oFS2.js → mcp-DtbxuH3V2.js} +0 -0
  214. /package/client/dist/assets/{mcp-Dd844F5_.js → mcp-H-gnQUdN.js} +0 -0
  215. /package/client/dist/assets/{mcp-zSJ2TsJj.js → mcp-N1nzp8oL.js} +0 -0
  216. /package/client/dist/assets/{mcp-BG-OCJca2.js → mcp-XJNRfxVp2.js} +0 -0
  217. /package/client/dist/assets/{mcp-CrWdq5db.js → mcp-sRmWE8WJ.js} +0 -0
  218. /package/client/dist/assets/{nav-DUuw9VIU2.js → nav-BElxljIF2.js} +0 -0
  219. /package/client/dist/assets/{nav-BY_4EWRv.js → nav-BXO7PJJG2.js} +0 -0
  220. /package/client/dist/assets/{nav-BAMkVEId.js → nav-C8kOuGh8.js} +0 -0
  221. /package/client/dist/assets/{nav-D0Erv9ZJ2.js → nav-COu2E_-L.js} +0 -0
  222. /package/client/dist/assets/{nav-CVXtv0wX2.js → nav-CW9pxWfC2.js} +0 -0
  223. /package/client/dist/assets/{nav-B2_ToNqS.js → nav-CXHUA4uf.js} +0 -0
  224. /package/client/dist/assets/{nav-S4HM94vW.js → nav-DdHF5VWJ.js} +0 -0
  225. /package/client/dist/assets/{setup-q0wRHUp1.js → setup-7J8TjG4O.js} +0 -0
  226. /package/client/dist/assets/{setup-DQWsu2TR.js → setup-BXpw07r-.js} +0 -0
  227. /package/client/dist/assets/{setup-mXnzww4f.js → setup-BiduSX9d.js} +0 -0
  228. /package/client/dist/assets/{setup-1vN48B-m2.js → setup-BuQNKztt2.js} +0 -0
  229. /package/client/dist/assets/{setup-BmJ0Kx16.js → setup-BwMovM9z2.js} +0 -0
  230. /package/client/dist/assets/{setup-JeBwoXoM.js → setup-D84y3wx-.js} +0 -0
  231. /package/client/dist/assets/{setup-T_ApeQDV2.js → setup-DU0ULX8q2.js} +0 -0
  232. /package/client/dist/assets/{specs-Ce5y2iFc2.js → specs-C9Sd7BhH2.js} +0 -0
  233. /package/client/dist/assets/{specs-C6J2zrLM.js → specs-CBDvEYKv.js} +0 -0
  234. /package/client/dist/assets/{specs-DZDoZsDq.js → specs-CIPr9reA2.js} +0 -0
  235. /package/client/dist/assets/{specs-BGRKhM8t.js → specs-CWtKcVDC.js} +0 -0
  236. /package/client/dist/assets/{specs-CT8exGOy2.js → specs-D2clrt2c2.js} +0 -0
  237. /package/client/dist/assets/{specs-GkiL-snY.js → specs-DTplt2XM.js} +0 -0
  238. /package/client/dist/assets/{specs-DbtIzV8a.js → specs-PozUNhqb.js} +0 -0
  239. /package/client/dist/assets/{terminal-Cvabyzm42.js → terminal-BRm03iFA2.js} +0 -0
  240. /package/client/dist/assets/{terminal-BTpE7iki.js → terminal-De2Brd23.js} +0 -0
  241. /package/client/dist/assets/{terminal-D0z12_sJ2.js → terminal-DxQWCqSD2.js} +0 -0
  242. /package/client/dist/assets/{terminal-a6Uq8B0p.js → terminal-WSAvHXoU.js} +0 -0
  243. /package/client/dist/assets/{terminal-DDk_bTw0.js → terminal-Z7KsDM_n.js} +0 -0
  244. /package/client/dist/assets/{terminal-DEyt0prF.js → terminal-cqfd3EDV.js} +0 -0
  245. /package/client/dist/assets/{terminal-BNSg2lR7.js → terminal-xGbCZJHg.js} +0 -0
  246. /package/client/dist/assets/{tickets-sVun0I6v.js → tickets-B7zT4IRf.js} +0 -0
  247. /package/client/dist/assets/{tickets-DZut8Ryt.js → tickets-BoXom7l8.js} +0 -0
  248. /package/client/dist/assets/{tickets-BIxU86j12.js → tickets-C3b8cHhd2.js} +0 -0
  249. /package/client/dist/assets/{tickets-dQfsc7Ph.js → tickets-CFXnJsYF.js} +0 -0
  250. /package/client/dist/assets/{tickets-LfK6LzKl2.js → tickets-CWYFvx1W2.js} +0 -0
  251. /package/client/dist/assets/{tickets-D1IeX2EW.js → tickets-DTHo9c3C.js} +0 -0
  252. /package/client/dist/assets/{tickets-C2BhwzwR.js → tickets-SuX_HkK4.js} +0 -0
@@ -0,0 +1,2 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/editor.main-C9J2ikJK.js","assets/chunk-BNv3lrIs.js","assets/preload-helper-DSXbuxSR.js","assets/editor.api2-C3B0tp2x.js","assets/editor-Br_kD0ds.css","assets/workers-U0UXyLUf.js","assets/monaco.contribution-Desq7oq4.js"])))=>i.map(i=>d[i]);
2
+ import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./preload-helper-DSXbuxSR.js";import{$n as n,An as r,C as i,F as a,Gt as o,Hn as s,Lt as c,Ot as l,P as u,Qn as d,Un as f,Wn as p,Yn as m,Zn as h,_n as g,b as _,bn as v,ct as y,et as b,fn as x,ft as S,gn as C,hn as w,jn as T,kn as E,lt as ee,mt as D,ot as O,pn as k,pt as A,tt as j,un as M,vn as N}from"./index-DyY1QyIn.js";var P=s(`funnel`,[[`path`,{d:`M10 20a1 1 0 0 0 .553.895l2 1A1 1 0 0 0 14 21v-7a2 2 0 0 1 .517-1.341L21.74 4.67A1 1 0 0 0 21 3H3a1 1 0 0 0-.742 1.67l7.225 7.989A2 2 0 0 1 10 14z`,key:`sc7q7i`}]]),F=e(n(),1),I=e(d(),1);function L(e,t,n){let r=Array(e);return new Proxy(r,{get(r,i,a){if(typeof i==`string`){let a=i.charCodeAt(0);if(a>=48&&a<=57){let a=+i;if(Number.isInteger(a)&&a>=0&&a<e){let e=r[a];if(!e){let i=t[a*2];e=r[a]={index:a,key:n(a),start:i,size:t[a*2+1],end:i+t[a*2+1],lane:0}}return e}}if(i===`length`)return e}return Reflect.get(r,i,a)}})}function R(e,t,n){let r=n.initialDeps??[],i,a=!0;function o(){let o=e();return o.length!==r.length||o.some((e,t)=>r[t]!==e)?(r=o,i=t(...o),n?.onChange&&!(a&&n.skipInitialOnChange)&&n.onChange(i),a=!1,i):i}return o.updateDeps=e=>{r=e},o}function te(e,t){if(e===void 0)throw Error(`Unexpected undefined${t?`: ${t}`:``}`);return e}var ne=(e,t)=>Math.abs(e-t)<1.01,re=(e,t,n)=>{let r;return function(...i){e.clearTimeout(r),r=e.setTimeout(()=>t.apply(this,i),n)}},z,B=()=>{if(z!==void 0)return z;if(typeof navigator>`u`)return z=!1;if(/iP(hone|od|ad)/.test(navigator.userAgent))return z=!0;let e=navigator.maxTouchPoints;return z=navigator.platform===`MacIntel`&&e!==void 0&&e>0},V=e=>{let{offsetWidth:t,offsetHeight:n}=e;return{width:t,height:n}},H=e=>e,U=e=>{let t=Math.max(e.startIndex-e.overscan,0),n=Math.min(e.endIndex+e.overscan,e.count-1)-t+1,r=Array(n);for(let e=0;e<n;e++)r[e]=t+e;return r},ie=(e,t)=>{let n=e.scrollElement;if(!n)return;let r=e.targetWindow;if(!r)return;let i=e=>{let{width:n,height:r}=e;t({width:Math.round(n),height:Math.round(r)})};if(i(V(n)),!r.ResizeObserver)return()=>{};let a=new r.ResizeObserver(t=>{let r=()=>{let e=t[0];if(e?.borderBoxSize){let t=e.borderBoxSize[0];if(t){i({width:t.inlineSize,height:t.blockSize});return}}i(V(n))};e.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(r):r()});return a.observe(n,{box:`border-box`}),()=>{a.unobserve(n)}},W={passive:!0},G=typeof window>`u`?!0:`onscrollend`in window,K=(e,t,n)=>{let r=e.scrollElement;if(!r)return;let i=e.targetWindow;if(!i)return;let a=e.options.useScrollendEvent&&G,o=0,s=a?null:re(i,()=>t(o,!1),e.options.isScrollingResetDelay),c=e=>()=>{o=n(r),s?.(),t(o,e)},l=c(!0),u=c(!1);return r.addEventListener(`scroll`,l,W),a&&r.addEventListener(`scrollend`,u,W),()=>{r.removeEventListener(`scroll`,l),a&&r.removeEventListener(`scrollend`,u)}},q=(e,t)=>K(e,t,t=>{let{horizontal:n,isRtl:r}=e.options;return n?t.scrollLeft*(r&&-1||1):t.scrollTop}),J=(e,t,n)=>{if(t?.borderBoxSize){let e=t.borderBoxSize[0];if(e)return Math.round(e[n.options.horizontal?`inlineSize`:`blockSize`])}return e[n.options.horizontal?`offsetWidth`:`offsetHeight`]},ae=(e,{adjustments:t=0,behavior:n},r)=>{var i,a;(a=(i=r.scrollElement)?.scrollTo)==null||a.call(i,{[r.options.horizontal?`left`:`top`]:e+t,behavior:n})},oe=class{constructor(e){this.unsubs=[],this.scrollElement=null,this.targetWindow=null,this.isScrolling=!1,this.scrollState=null,this.measurementsCache=[],this._flatMeasurements=null,this.itemSizeCache=new Map,this.itemSizeCacheVersion=0,this.laneAssignments=new Map,this.pendingMin=null,this.prevLanes=void 0,this.lanesChangedFlag=!1,this.lanesSettling=!1,this.scrollRect=null,this.scrollOffset=null,this.scrollDirection=null,this.scrollAdjustments=0,this._iosDeferredAdjustment=0,this._iosTouching=!1,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._intendedScrollOffset=null,this.elementsCache=new Map,this.now=()=>{var e;return((e=this.targetWindow?.performance)?.now)?.call(e)??Date.now()},this.observer=(()=>{let e=null,t=()=>e||(!this.targetWindow||!this.targetWindow.ResizeObserver?null:e=new this.targetWindow.ResizeObserver(e=>{e.forEach(e=>{let t=()=>{let t=e.target,n=this.indexFromElement(t);if(!t.isConnected){this.observer.unobserve(t);for(let[e,n]of this.elementsCache)if(n===t){this.elementsCache.delete(e);break}return}this.shouldMeasureDuringScroll(n)&&this.resizeItem(n,this.options.measureElement(t,e,this))};this.options.useAnimationFrameWithResizeObserver?requestAnimationFrame(t):t()})}));return{disconnect:()=>{var n;(n=t())==null||n.disconnect(),e=null},observe:e=>t()?.observe(e,{box:`border-box`}),unobserve:e=>t()?.unobserve(e)}})(),this.range=null,this.setOptions=e=>{let t={debug:!1,initialOffset:0,overscan:1,paddingStart:0,paddingEnd:0,scrollPaddingStart:0,scrollPaddingEnd:0,horizontal:!1,getItemKey:H,rangeExtractor:U,onChange:()=>{},measureElement:J,initialRect:{width:0,height:0},scrollMargin:0,gap:0,indexAttribute:`data-index`,initialMeasurementsCache:[],lanes:1,isScrollingResetDelay:150,enabled:!0,isRtl:!1,useScrollendEvent:!1,useAnimationFrameWithResizeObserver:!1,laneAssignmentMode:`estimate`};for(let n in e){let r=e[n];r!==void 0&&(t[n]=r)}this.options=t},this.notify=e=>{var t,n;(n=(t=this.options).onChange)==null||n.call(t,this,e)},this.maybeNotify=R(()=>(this.calculateRange(),[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]),e=>{this.notify(e)},{key:!1,debug:()=>this.options.debug,initialDeps:[this.isScrolling,this.range?this.range.startIndex:null,this.range?this.range.endIndex:null]}),this.cleanup=()=>{this.unsubs.filter(Boolean).forEach(e=>e()),this.unsubs=[],this.observer.disconnect(),this.rafId!=null&&this.targetWindow&&(this.targetWindow.cancelAnimationFrame(this.rafId),this.rafId=null),this.scrollState=null,this.scrollElement=null,this.targetWindow=null},this._didMount=()=>()=>{this.cleanup()},this._willUpdate=()=>{let e=this.options.enabled?this.options.getScrollElement():null;if(this.scrollElement!==e){if(this.cleanup(),!e){this.maybeNotify();return}if(this.scrollElement=e,this.scrollElement&&`ownerDocument`in this.scrollElement?this.targetWindow=this.scrollElement.ownerDocument.defaultView:this.targetWindow=this.scrollElement?.window??null,this.elementsCache.forEach(e=>{this.observer.observe(e)}),this.unsubs.push(this.options.observeElementRect(this,e=>{this.scrollRect=e,this.maybeNotify()})),this.unsubs.push(this.options.observeElementOffset(this,(e,t)=>{this._intendedScrollOffset!==null&&Math.abs(e-this._intendedScrollOffset)<1.5&&(e=this._intendedScrollOffset),this._intendedScrollOffset=null,this.scrollAdjustments=0,this.scrollDirection=t?this.getScrollOffset()<e?`forward`:`backward`:null,this.scrollOffset=e,this.isScrolling=t,this._flushIosDeferredIfReady(),this.scrollState&&this.scheduleScrollReconcile(),this.maybeNotify()})),`addEventListener`in this.scrollElement){let e=this.scrollElement,t=()=>{this._iosTouching=!0,this._iosJustTouchEnded=!1,this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)},n=()=>{this._iosTouching=!1,!(!B()||this.targetWindow==null)&&(this._iosJustTouchEnded=!0,this._iosTouchEndTimerId=this.targetWindow.setTimeout(()=>{this._iosJustTouchEnded=!1,this._iosTouchEndTimerId=null,this._flushIosDeferredIfReady()},150))};e.addEventListener(`touchstart`,t,W),e.addEventListener(`touchend`,n,W),this.unsubs.push(()=>{e.removeEventListener(`touchstart`,t),e.removeEventListener(`touchend`,n),this._iosTouchEndTimerId!==null&&this.targetWindow!=null&&(this.targetWindow.clearTimeout(this._iosTouchEndTimerId),this._iosTouchEndTimerId=null)})}this._scrollToOffset(this.getScrollOffset(),{adjustments:void 0,behavior:void 0})}},this._flushIosDeferredIfReady=()=>{if(this._iosDeferredAdjustment===0||this.isScrolling||this._iosTouching||this._iosJustTouchEnded)return;let e=this.getScrollOffset(),t=this.getMaxScrollOffset();if(e<0||e>t)return;let n=this._iosDeferredAdjustment;this._iosDeferredAdjustment=0,this._scrollToOffset(e,{adjustments:this.scrollAdjustments+=n,behavior:void 0})},this.rafId=null,this.getSize=()=>this.options.enabled?(this.scrollRect=this.scrollRect??this.options.initialRect,this.scrollRect[this.options.horizontal?`width`:`height`]):(this.scrollRect=null,0),this.getScrollOffset=()=>this.options.enabled?(this.scrollOffset=this.scrollOffset??(typeof this.options.initialOffset==`function`?this.options.initialOffset():this.options.initialOffset),this.scrollOffset):(this.scrollOffset=null,0),this.getFurthestMeasurement=(e,t)=>{let n=new Map,r=new Map;for(let i=t-1;i>=0;i--){let t=e[i];if(n.has(t.lane))continue;let a=r.get(t.lane);if(a==null||t.end>a.end?r.set(t.lane,t):t.end<a.end&&n.set(t.lane,!0),n.size===this.options.lanes)break}return r.size===this.options.lanes?Array.from(r.values()).sort((e,t)=>e.end===t.end?e.index-t.index:e.end-t.end)[0]:void 0},this.getMeasurementOptions=R(()=>[this.options.count,this.options.paddingStart,this.options.scrollMargin,this.options.getItemKey,this.options.enabled,this.options.lanes,this.options.laneAssignmentMode],(e,t,n,r,i,a,o)=>(this.prevLanes!==void 0&&this.prevLanes!==a&&(this.lanesChangedFlag=!0),this.prevLanes=a,this.pendingMin=null,{count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o}),{key:!1}),this.getMeasurements=R(()=>[this.getMeasurementOptions(),this.itemSizeCacheVersion],({count:e,paddingStart:t,scrollMargin:n,getItemKey:r,enabled:i,lanes:a,laneAssignmentMode:o},s)=>{let c=this.itemSizeCache;if(!i)return this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),[];if(this.laneAssignments.size>e)for(let t of this.laneAssignments.keys())t>=e&&this.laneAssignments.delete(t);this.lanesChangedFlag&&(this.lanesChangedFlag=!1,this.lanesSettling=!0,this.measurementsCache=[],this.itemSizeCache.clear(),this.laneAssignments.clear(),this.pendingMin=null),this.measurementsCache.length===0&&!this.lanesSettling&&(this.measurementsCache=this.options.initialMeasurementsCache,this.measurementsCache.forEach(e=>{this.itemSizeCache.set(e.key,e.size)}));let l=this.lanesSettling?0:this.pendingMin??0;if(this.pendingMin=null,this.lanesSettling&&this.measurementsCache.length===e&&(this.lanesSettling=!1),a===1){let i=this.options.gap,a=e*2,o=this._flatMeasurements;if(!o||o.length<a){let e=new Float64Array(a);o&&l>0&&e.set(o.subarray(0,l*2)),o=e,this._flatMeasurements=o}let s;if(l===0)s=t+n;else{let e=l-1;s=o[e*2]+o[e*2+1]+i}for(let t=l;t<e;t++){let e=r(t),n=c.get(e),a=typeof n==`number`?n:this.options.estimateSize(t);o[t*2]=s,o[t*2+1]=a,s+=a+i}let u=L(e,o,r);return this.measurementsCache=u,u}let u=this.measurementsCache.slice(0,l),d=Array(a).fill(void 0);for(let e=0;e<l;e++){let t=u[e];t&&(d[t.lane]=e)}for(let i=l;i<e;i++){let e=r(i),a=this.laneAssignments.get(i),s,l,f=o===`estimate`||c.has(e);if(a!==void 0&&this.options.lanes>1){s=a;let e=d[s],r=e===void 0?void 0:u[e];l=r?r.end+this.options.gap:t+n}else{let e=this.options.lanes===1?u[i-1]:this.getFurthestMeasurement(u,i);l=e?e.end+this.options.gap:t+n,s=e?e.lane:i%this.options.lanes,this.options.lanes>1&&f&&this.laneAssignments.set(i,s)}let p=c.get(e),m=typeof p==`number`?p:this.options.estimateSize(i),h=l+m;u[i]={index:i,start:l,size:m,end:h,key:e,lane:s},d[s]=i}return this.measurementsCache=u,u},{key:!1,debug:()=>this.options.debug}),this.calculateRange=R(()=>[this.getMeasurements(),this.getSize(),this.getScrollOffset(),this.options.lanes],(e,t,n,r)=>this.range=e.length>0&&t>0?se({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:r===1&&this._flatMeasurements!=null?this._flatMeasurements:null}):null,{key:!1,debug:()=>this.options.debug}),this.getVirtualIndexes=R(()=>{let e=null,t=null,n=this.calculateRange();return n&&(e=n.startIndex,t=n.endIndex),this.maybeNotify.updateDeps([this.isScrolling,e,t]),[this.options.rangeExtractor,this.options.overscan,this.options.count,e,t]},(e,t,n,r,i)=>r===null||i===null?[]:e({startIndex:r,endIndex:i,overscan:t,count:n}),{key:!1,debug:()=>this.options.debug}),this.indexFromElement=e=>{let t=this.options.indexAttribute,n=e.getAttribute(t);return n?parseInt(n,10):(console.warn(`Missing attribute name '${t}={index}' on measured element.`),-1)},this.shouldMeasureDuringScroll=e=>{if(!this.scrollState||this.scrollState.behavior!==`smooth`)return!0;let t=this.scrollState.index??this.getVirtualItemForOffset(this.scrollState.lastTargetOffset)?.index;if(t!==void 0&&this.range){let n=Math.max(this.options.overscan,Math.ceil((this.range.endIndex-this.range.startIndex)/2)),r=Math.max(0,t-n),i=Math.min(this.options.count-1,t+n);return e>=r&&e<=i}return!0},this.measureElement=e=>{if(!e){this.elementsCache.forEach((e,t)=>{e.isConnected||(this.observer.unobserve(e),this.elementsCache.delete(t))});return}let t=this.indexFromElement(e),n=this.options.getItemKey(t),r=this.elementsCache.get(n);r!==e&&(r&&this.observer.unobserve(r),this.observer.observe(e),this.elementsCache.set(n,e)),(!this.isScrolling||this.scrollState)&&this.shouldMeasureDuringScroll(t)&&this.resizeItem(t,this.options.measureElement(e,void 0,this))},this.resizeItem=(e,t)=>{if(e<0||e>=this.options.count)return;let n,r,i,a=this._flatMeasurements;if(this.options.lanes===1&&a!==null)i=this.options.getItemKey(e),r=a[e*2],n=a[e*2+1];else{let t=this.measurementsCache[e];if(!t)return;i=t.key,r=t.start,n=t.size}let o=t-(this.itemSizeCache.get(i)??n);o!==0&&(this.scrollState?.behavior!==`smooth`&&(this.shouldAdjustScrollPositionOnItemSizeChange===void 0?r<this.getScrollOffset()+this.scrollAdjustments&&this.scrollDirection!==`backward`:this.shouldAdjustScrollPositionOnItemSizeChange(this.measurementsCache[e]??{index:e,key:i,start:r,size:n,end:r+n,lane:0},o,this))&&(B()&&(this.isScrolling||this._iosTouching||this._iosJustTouchEnded)?this._iosDeferredAdjustment+=o:this._scrollToOffset(this.getScrollOffset(),{adjustments:this.scrollAdjustments+=o,behavior:void 0})),(this.pendingMin===null||e<this.pendingMin)&&(this.pendingMin=e),this.itemSizeCache.set(i,t),this.itemSizeCacheVersion++,this.notify(!1))},this.getVirtualItems=R(()=>[this.getVirtualIndexes(),this.getMeasurements()],(e,t)=>{let n=[];for(let r=0,i=e.length;r<i;r++){let i=t[e[r]];n.push(i)}return n},{key:!1,debug:()=>this.options.debug}),this.getVirtualItemForOffset=e=>{let t=this.getMeasurements();if(t.length===0)return;let n=this._flatMeasurements,r=this.options.lanes===1&&n!=null;return te(t[Y(0,t.length-1,r?e=>n[e*2]:e=>te(t[e]).start,e)])},this.getMaxScrollOffset=()=>{if(!this.scrollElement)return 0;if(`scrollHeight`in this.scrollElement)return this.options.horizontal?this.scrollElement.scrollWidth-this.scrollElement.clientWidth:this.scrollElement.scrollHeight-this.scrollElement.clientHeight;{let e=this.scrollElement.document.documentElement;return this.options.horizontal?e.scrollWidth-this.scrollElement.innerWidth:e.scrollHeight-this.scrollElement.innerHeight}},this.getOffsetForAlignment=(e,t,n=0)=>{if(!this.scrollElement)return 0;let r=this.getSize(),i=this.getScrollOffset();t===`auto`&&(t=e>=i+r?`end`:`start`),t===`center`?e+=(n-r)/2:t===`end`&&(e-=r);let a=this.getMaxScrollOffset();return Math.max(Math.min(a,e),0)},this.getOffsetForIndex=(e,t=`auto`)=>{e=Math.max(0,Math.min(e,this.options.count-1));let n=this.getSize(),r=this.getScrollOffset(),i=this.measurementsCache[e];if(!i)return;if(t===`auto`)if(i.end>=r+n-this.options.scrollPaddingEnd)t=`end`;else if(i.start<=r+this.options.scrollPaddingStart)t=`start`;else return[r,t];if(t===`end`&&e===this.options.count-1)return[this.getMaxScrollOffset(),t];let a=t===`end`?i.end+this.options.scrollPaddingEnd:i.start-this.options.scrollPaddingStart;return[this.getOffsetForAlignment(a,t,i.size),t]},this.scrollToOffset=(e,{align:t=`start`,behavior:n=`auto`}={})=>{let r=this.getOffsetForAlignment(e,t),i=this.now();this.scrollState={index:null,align:t,behavior:n,startedAt:i,lastTargetOffset:r,stableFrames:0},this._scrollToOffset(r,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollToIndex=(e,{align:t=`auto`,behavior:n=`auto`}={})=>{e=Math.max(0,Math.min(e,this.options.count-1));let r=this.getOffsetForIndex(e,t);if(!r)return;let[i,a]=r,o=this.now();this.scrollState={index:e,align:a,behavior:n,startedAt:o,lastTargetOffset:i,stableFrames:0},this._scrollToOffset(i,{adjustments:void 0,behavior:n}),this.scheduleScrollReconcile()},this.scrollBy=(e,{behavior:t=`auto`}={})=>{let n=this.getScrollOffset()+e,r=this.now();this.scrollState={index:null,align:`start`,behavior:t,startedAt:r,lastTargetOffset:n,stableFrames:0},this._scrollToOffset(n,{adjustments:void 0,behavior:t}),this.scheduleScrollReconcile()},this.getTotalSize=()=>{let e=this.getMeasurements(),t;if(e.length===0)t=this.options.paddingStart;else if(this.options.lanes===1){let n=e.length-1,r=this._flatMeasurements;t=r==null?e[n]?.end??0:r[n*2]+r[n*2+1]}else{let n=Array(this.options.lanes).fill(null),r=e.length-1;for(;r>=0&&n.some(e=>e===null);){let t=e[r];n[t.lane]===null&&(n[t.lane]=t.end),r--}t=Math.max(...n.filter(e=>e!==null))}return Math.max(t-this.options.scrollMargin+this.options.paddingEnd,0)},this.takeSnapshot=()=>{let e=[];if(this.itemSizeCache.size===0)return e;let t=this.getMeasurements();for(let n of t)n&&this.itemSizeCache.has(n.key)&&e.push({index:n.index,key:n.key,start:n.start,size:n.size,end:n.end,lane:n.lane});return e},this._scrollToOffset=(e,{adjustments:t,behavior:n})=>{this._intendedScrollOffset=e+(t??0),this.options.scrollToFn(e,{behavior:n,adjustments:t},this)},this.measure=()=>{this.pendingMin=null,this.itemSizeCache.clear(),this.laneAssignments.clear(),this.itemSizeCacheVersion++,this.notify(!1)},this.setOptions(e)}scheduleScrollReconcile(){if(!this.targetWindow){this.scrollState=null;return}this.rafId??=this.targetWindow.requestAnimationFrame(()=>{this.rafId=null,this.reconcileScroll()})}reconcileScroll(){if(!this.scrollState||!this.scrollElement)return;if(this.now()-this.scrollState.startedAt>5e3){this.scrollState=null;return}let e=this.scrollState.index==null?void 0:this.getOffsetForIndex(this.scrollState.index,this.scrollState.align),t=e?e[0]:this.scrollState.lastTargetOffset,n=t!==this.scrollState.lastTargetOffset;if(!n&&ne(t,this.getScrollOffset())){if(this.scrollState.stableFrames++,this.scrollState.stableFrames>=1){this.getScrollOffset()!==t&&this._scrollToOffset(t,{adjustments:void 0,behavior:`auto`}),this.scrollState=null;return}}else if(this.scrollState.stableFrames=0,n){let e=this.getSize()||600,n=Math.abs(t-this.getScrollOffset()),r=this.scrollState.behavior===`smooth`&&n>e;this.scrollState.lastTargetOffset=t,r||(this.scrollState.behavior=`auto`),this._scrollToOffset(t,{adjustments:void 0,behavior:r?`smooth`:`auto`})}this.scheduleScrollReconcile()}},Y=(e,t,n,r)=>{for(;e<=t;){let i=(e+t)/2|0,a=n(i);if(a<r)e=i+1;else if(a>r)t=i-1;else return i}return e>0?e-1:0};function se({measurements:e,outerSize:t,scrollOffset:n,lanes:r,flat:i}){let a=e.length-1,o=i?e=>i[e*2]:t=>e[t].start,s=i?e=>i[e*2]+i[e*2+1]:t=>e[t].end;if(e.length<=r)return{startIndex:0,endIndex:a};let c=Y(0,a,o,n),l=c;if(r===1)for(;l<a&&s(l)<n+t;)l++;else if(r>1){let i=Array(r).fill(0);for(;l<a&&i.some(e=>e<n+t);){let t=e[l];i[t.lane]=t.end,l++}let o=Array(r).fill(n+t);for(;c>=0&&o.some(e=>e>=n);){let t=e[c];o[t.lane]=t.start,c--}c=Math.max(0,c-c%r),l=Math.min(a,l+(r-1-l%r))}return{startIndex:c,endIndex:l}}var ce=typeof document<`u`?F.useLayoutEffect:F.useEffect;function le({useFlushSync:e=!0,...t}){let n=F.useReducer(e=>e+1,0)[1],r={...t,onChange:(r,i)=>{var a;e&&i?(0,I.flushSync)(n):n(),(a=t.onChange)==null||a.call(t,r,i)}},[i]=F.useState(()=>new oe(r));return i.setOptions(r),ce(()=>i._didMount(),[]),ce(()=>i._willUpdate()),i}function ue(e){return le({observeElementRect:ie,observeElementOffset:q,scrollToFn:ae,...e})}var X=A(),Z=e=>`specrails-desktop:code-tree-filter:${e}`,de=e=>`specrails-desktop:code-tree-collapsed:${e}`;function fe(e){return e.split(`/`).length-1}function pe(e){let t=e.lastIndexOf(`/`);return t>=0?e.slice(t+1):e}function me(e){return e?e.length>10?e.slice(0,10):e:null}function he(e){return e===`created`?`added`:e===`modified`?`changed`:e===`deleted`?`deleted`:null}function ge(e,t){if(t.size===0)return!1;let n=e.split(`/`);for(let e=1;e<n.length;e++)if(t.has(n.slice(0,e).join(`/`)))return!0;return!1}function _e({onOpenFile:e,selectedPath:t,filterJobId:n,filterTicketId:a}){let{t:o}=p(`code`),{activeProjectId:s}=y(),{openTicketDetail:c}=i(),{registerHandler:l,unregisterHandler:u}=S(),[d,f]=(0,F.useState)(()=>{if(!s)return`touched-by-ai`;try{let e=localStorage.getItem(Z(s));if(e===`all`||e===`touched-by-ai`)return e}catch{}return`touched-by-ai`});(0,F.useEffect)(()=>{if(s)try{localStorage.setItem(Z(s),d)}catch{}},[d,s]);let[m,h]=(0,F.useState)(()=>{if(!s)return new Set;try{let e=localStorage.getItem(de(s));if(!e)return new Set;let t=JSON.parse(e);if(Array.isArray(t))return new Set(t.filter(e=>typeof e==`string`))}catch{}return new Set});(0,F.useEffect)(()=>{if(s)try{localStorage.setItem(de(s),JSON.stringify([...m]))}catch{}},[m,s]);let g=(0,F.useCallback)(e=>{h(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),_=(0,F.useCallback)(()=>{h(new Set)},[]),{data:v,refresh:b,isFirstLoad:C}=ee({namespace:`code-tree:${d}:${d===`touched-by-ai`?`${n??`all-jobs`}:${a??`all-specs`}`:`all`}`,projectId:s,initialValue:[],fetcher:(0,F.useCallback)(async()=>{let e=[],t=null;for(let r=0;r<100;r+=1){let r=new URLSearchParams({withProvenance:`1`,filter:d});d===`touched-by-ai`&&n&&r.set(`jobId`,n),d===`touched-by-ai`&&typeof a==`number`&&r.set(`ticketId`,String(a)),t&&r.set(`cursor`,t);let i=await fetch(`${D()}/code/tree?${r.toString()}`);if(!i.ok)break;let o=await i.json().catch(()=>({}));if(Array.isArray(o.entries)&&e.push(...o.entries),!o.nextCursor)break;t=o.nextCursor}return e},[d,n,a])}),E=(0,F.useRef)(s);(0,F.useEffect)(()=>{E.current=s},[s]),(0,F.useEffect)(()=>{if(!s)return;let e=`code-tree-${s}`;return l(e,e=>{let t=e;t.projectId===E.current&&t.type===`file.provenance_updated`&&b()}),()=>u(e)},[s,l,u,b]);let A=(0,F.useRef)(null),j=(0,F.useMemo)(()=>(v??[]).filter(e=>!ge(e.path,m)),[v,m]),N=(0,F.useCallback)(()=>{h(new Set((v??[]).filter(e=>e.kind===`dir`).map(e=>e.path)))},[v]),P=ue({count:j.length,getScrollElement:()=>A.current,estimateSize:()=>28,overscan:12,initialRect:{width:320,height:600},observeElementRect:(e,t)=>{let n=e.scrollElement;if(!n)return()=>{};let r=()=>{let e=n.getBoundingClientRect(),r=e.height||n.clientHeight||600;t({width:e.width||n.clientWidth||320,height:r})};if(r(),typeof ResizeObserver<`u`){let e=new ResizeObserver(r);return e.observe(n),()=>e.disconnect()}return()=>{}}}),I=j.length===0,L=(0,F.useMemo)(()=>(v??[]).filter(e=>e.kind===`file`).length,[v]);return(0,X.jsxs)(`div`,{className:`flex flex-col h-full`,"data-testid":`file-tree`,children:[(0,X.jsxs)(`div`,{className:`px-2 py-2 border-b border-border text-xs space-y-2`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(`touched-by-ai`),className:O(`px-2 py-1 rounded-md transition-colors`,d===`touched-by-ai`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":d===`touched-by-ai`,children:o(n?`tree.jobFiles`:a?`tree.specFiles`:`tree.touchedByAi`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(`all`),className:O(`px-2 py-1 rounded-md transition-colors`,d===`all`?`bg-accent-primary/20 text-accent-primary`:`text-muted-foreground hover:text-foreground hover:bg-muted/50`),"aria-pressed":d===`all`,children:o(`tree.allFiles`)}),(0,X.jsx)(`div`,{className:`flex-1`}),(0,X.jsx)(`button`,{type:`button`,onClick:N,title:o(`tree.collapseAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":o(`tree.collapseAll`),children:(0,X.jsx)(r,{className:`w-3.5 h-3.5`})}),(0,X.jsx)(`button`,{type:`button`,onClick:_,title:o(`tree.expandAll`),className:`px-1.5 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,"aria-label":o(`tree.expandAll`),children:(0,X.jsx)(T,{className:`w-3.5 h-3.5`})})]}),d===`touched-by-ai`&&L>0&&(0,X.jsx)(`div`,{className:`flex items-center justify-between gap-2 text-[11px] text-muted-foreground`,children:(0,X.jsx)(`span`,{children:o(`tree.touchedCount`,{count:L})})})]}),I&&C?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center px-4 text-center`,"data-testid":`file-tree-loading`,children:(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground animate-pulse`,children:o(`tree.loadingFiles`)})}):I&&d===`touched-by-ai`?(0,X.jsxs)(`div`,{className:`flex-1 flex flex-col items-center justify-center px-4 text-center gap-3`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:o(`tree.emptyTouched`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>f(`all`),className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30`,children:o(`tree.showAllFiles`)})]}):I?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-xs text-muted-foreground px-4 text-center`,children:o(`tree.noFiles`)}):(0,X.jsx)(`div`,{ref:A,className:`flex-1 overflow-auto`,"data-testid":`file-tree-scroller`,children:(0,X.jsx)(`div`,{style:{height:P.getTotalSize(),position:`relative`,width:`100%`},children:P.getVirtualItems().map(n=>{let i=j[n.index],a=fe(i.path)*12,s=i.kind===`file`&&i.path===t,l=i.provenance?.createdByTicketId,u=i.provenance?.modifiedByTicketIds??[],d=i.provenance?.latest??null,f=me(d?.jobId),p=he(d?.kind),h=i.kind===`dir`,_=h&&m.has(i.path),v=i.provenance?.touchedFileCount??0;return(0,X.jsxs)(`div`,{style:{position:`absolute`,top:0,left:0,transform:`translateY(${n.start}px)`,height:n.size,width:`100%`},className:O(`flex items-center gap-2 px-2 text-xs cursor-pointer hover:bg-muted/50`,s&&`bg-muted text-foreground`),onClick:()=>{h?g(i.path):e(i.path)},role:`button`,tabIndex:0,"aria-expanded":h?!_:void 0,"data-testid":`file-tree-row-${i.path}`,children:[(0,X.jsxs)(`span`,{style:{paddingLeft:a},className:`flex items-center gap-1 min-w-0 flex-1`,children:[h?(0,X.jsxs)(X.Fragment,{children:[_?(0,X.jsx)(r,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}):(0,X.jsx)(T,{className:`w-3 h-3 text-muted-foreground flex-shrink-0`}),_?(0,X.jsx)(x,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`}):(0,X.jsx)(k,{className:`w-3.5 h-3.5 text-accent-info flex-shrink-0`})]}):(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`span`,{className:`w-3 flex-shrink-0`}),(0,X.jsx)(w,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`})]}),(0,X.jsx)(`span`,{className:`truncate ml-0.5`,children:pe(i.path)})]}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1 flex-shrink-0`,children:[h&&v>0&&(0,X.jsx)(`span`,{className:`text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground`,title:o(`tree.folderTouched`,{count:v}),children:v}),!h&&p&&(0,X.jsx)(`span`,{className:O(`text-[10px] px-1.5 py-0.5 rounded`,d?.kind===`created`&&`bg-accent-success/15 text-accent-success`,d?.kind===`modified`&&`bg-accent-info/15 text-accent-info`,d?.kind===`deleted`&&`bg-destructive/15 text-destructive`),title:d?.kind===`created`?o(`tree.latestTitleCreated`):d?.kind===`deleted`?o(`tree.latestTitleDeleted`):o(`tree.latestTitleModified`),children:o(`action.${p}`)}),!h&&f&&(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1 text-[10px] px-1.5 py-0.5 rounded bg-muted/60 text-muted-foreground font-mono`,title:o(`tree.jobTitle`,{jobId:d?.jobId??``}),children:[(0,X.jsx)(M,{className:`h-3 w-3`}),f]}),!h&&typeof l==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),c(l)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,"data-testid":`provenance-chip-created-${l}`,title:o(`tree.createdBySpec`,{id:l}),children:[`#`,l]}),!h&&u.slice(0,2).map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:t=>{t.stopPropagation(),c(e)},className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,"data-testid":`provenance-chip-modified-${e}`,title:o(`tree.modifiedBySpec`,{id:e}),children:[`#`,e]},e))]})]},i.path)})})})]})}function ve(e){return new Worker(`/assets/editor.worker-Bd9IXS8d.js`,{name:e?.name})}function ye(e){return new Worker(`/assets/json.worker-DzV-CpCQ.js`,{name:e?.name})}function be(e){return new Worker(`/assets/css.worker-Wv5dxAWO.js`,{name:e?.name})}function xe(e){return new Worker(`/assets/html.worker-CQP8QQsS.js`,{name:e?.name})}function Se(e){return new Worker(`/assets/ts.worker-METxwbDZ.js`,{name:e?.name})}var Ce=!1;function we(e){let t=e.trim().match(/^hsl\(\s*([-\d.]+)[\s,]+([\d.]+)%[\s,]+([\d.]+)%\s*\)$/i);return t?[parseFloat(t[1]),parseFloat(t[2]),parseFloat(t[3])]:null}function Q(e,t=`#1e1e1e`){if(e.startsWith(`#`))return e;let n=we(e);if(!n)return t;let[r,i,a]=n,o=i/100,s=a/100,c=(1-Math.abs(2*s-1))*o,l=(r%360+360)%360/60,u=c*(1-Math.abs(l%2-1)),d=0,f=0,p=0;l<1?(d=c,f=u):l<2?(d=u,f=c):l<3?(f=c,p=u):l<4?(f=u,p=c):l<5?(d=u,p=c):(d=c,p=u);let m=s-c/2,h=e=>Math.round((e+m)*255).toString(16).padStart(2,`0`);return`#${h(d)}${h(f)}${h(p)}`}function Te(e){return`specrails-${e}`}function Ee(e,t){let n=Te(t.id),r=t.xterm,i=Q(r.background),a=Q(r.foreground),o=Q(r.brightBlack),s=Q(r.magenta),c=Q(r.yellow),l=Q(r.cyan),u=Q(r.blue),d=Q(r.green),f=Q(r.brightBlack),p=Q(r.brightCyan),m=Q(r.red),h=Q(r.selectionBackground);return e.editor.defineTheme(n,{base:t.scheme===`light`?`vs`:`vs-dark`,inherit:!0,rules:[{token:``,foreground:a.slice(1)},{token:`comment`,foreground:f.slice(1),fontStyle:`italic`},{token:`keyword`,foreground:s.slice(1)},{token:`string`,foreground:c.slice(1)},{token:`number`,foreground:l.slice(1)},{token:`constant`,foreground:p.slice(1)},{token:`constant.numeric`,foreground:l.slice(1)},{token:`type`,foreground:d.slice(1)},{token:`type.identifier`,foreground:d.slice(1)},{token:`identifier`,foreground:a.slice(1)},{token:`function`,foreground:u.slice(1)},{token:`tag`,foreground:m.slice(1)},{token:`attribute.name`,foreground:p.slice(1)},{token:`attribute.value`,foreground:c.slice(1)},{token:`delimiter`,foreground:o.slice(1)},{token:`operator`,foreground:o.slice(1)}],colors:{"editor.background":i,"editor.foreground":a,"editorLineNumber.foreground":o,"editorLineNumber.activeForeground":a,"editorCursor.foreground":Q(r.cursor),"editor.selectionBackground":h,"editor.inactiveSelectionBackground":h,"editor.lineHighlightBackground":Q(r.black),"editor.lineHighlightBorder":Q(r.black),"editorGutter.background":i,"editorWhitespace.foreground":o,"editorIndentGuide.background1":Q(r.black),"editorIndentGuide.activeBackground1":o,"scrollbarSlider.background":`${o}55`,"scrollbarSlider.hoverBackground":`${o}88`,"scrollbarSlider.activeBackground":`${o}bb`,"minimap.background":i}}),n}function De(){Ce||=(self.MonacoEnvironment={getWorker(e,t){switch(t){case`json`:return new ye;case`css`:case`scss`:case`less`:return new be;case`html`:case`handlebars`:case`razor`:return new xe;case`typescript`:case`javascript`:return new Se;default:return new ve}}},!0)}function Oe({content:e,language:n,readOnly:r,onChange:i}){let{t:a}=p(`code`),o=_(),s=(0,F.useRef)(null),c=(0,F.useRef)(null),l=(0,F.useRef)(null),[u,d]=(0,F.useState)(!1),f=(0,F.useRef)(e),m=(0,F.useRef)(n),h=(0,F.useRef)(o),g=(0,F.useRef)(r),v=(0,F.useRef)(i);return(0,F.useEffect)(()=>{f.current=e},[e]),(0,F.useEffect)(()=>{m.current=n},[n]),(0,F.useEffect)(()=>{h.current=o},[o]),(0,F.useEffect)(()=>{g.current=r},[r]),(0,F.useEffect)(()=>{v.current=i},[i]),(0,F.useEffect)(()=>{let e=!1;return De(),t(()=>import(`./editor.main-C9J2ikJK.js`).then(t=>{if(e||!s.current)return;l.current=t;let n=Ee(t,h.current),r=t.editor.create(s.current,{value:f.current,language:m.current,readOnly:g.current,theme:n,minimap:{enabled:!1},lineNumbers:`on`,scrollBeyondLastLine:!1,automaticLayout:!0,fontSize:13});r.onDidChangeModelContent(()=>{v.current?.(r.getValue())}),c.current=r}),__vite__mapDeps([0,1,2,3,4,5,6])).catch(()=>{e||d(!0)}),()=>{e=!0,c.current?.dispose?.(),c.current=null}},[]),(0,F.useEffect)(()=>{let t=c.current;t&&t.getValue?.()!==e&&t.setValue?.(e)},[e]),(0,F.useEffect)(()=>{c.current?.updateOptions?.({readOnly:r})},[r]),(0,F.useEffect)(()=>{let e=l.current,t=c.current;if(!e||!t)return;let r=t.getModel?.();r&&e.editor.setModelLanguage(r,n)},[n]),(0,F.useEffect)(()=>{let e=l.current;if(!e)return;let t=Ee(e,o);e.editor.setTheme(t)},[o]),u?(0,X.jsxs)(`div`,{className:`w-full h-full flex flex-col items-center justify-center gap-2 text-sm text-muted-foreground`,"data-testid":`monaco-load-error`,children:[(0,X.jsx)(`span`,{children:a(`monaco.loadFailed`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`rounded-md bg-accent-primary/15 px-3 py-1 text-xs text-accent-primary hover:bg-accent-primary/25`,children:a(`monaco.reload`)})]}):(0,X.jsx)(`div`,{ref:s,className:`w-full h-full`,"data-testid":`monaco-host`})}var ke=(0,F.lazy)(async()=>({default:Oe}));function Ae({content:e,language:t,readOnly:n=!0,onChange:r}){let{t:i}=p(`code`);return(0,X.jsx)(F.Suspense,{fallback:(0,X.jsx)(`div`,{className:`w-full h-full flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:i(`monaco.loadingEditor`)}),children:(0,X.jsx)(ke,{content:e,language:t,readOnly:n,onChange:r})})}function je(e,t){if(!e)return null;let n=Date.parse(e);if(Number.isNaN(n))return null;let r=Math.round((n-Date.now())/1e3),i=new Intl.RelativeTimeFormat(t,{numeric:`auto`}),a=Math.abs(r);return a<60?i.format(r,`second`):a<3600?i.format(Math.round(r/60),`minute`):a<86400?i.format(Math.round(r/3600),`hour`):i.format(Math.round(r/86400),`day`)}function Me({path:e,summary:t,stale:n,regenerating:r,generateDisabledReason:a,onCollapse:o}){let{t:s,i18n:c}=p(`code`),{openTicketDetail:l}=i();if(!t)return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header-empty`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`flex flex-col gap-0.5 min-w-0`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),(0,X.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:a?s(`summary.unavailable`,{reason:a}):s(`summary.empty`)})]}),o&&(0,X.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(E,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})});let u=je(t.generatedAt,c.language),d=t.triggeredBy?.ticketId,f=t.triggeredBy?.modifiedTicketIds??[];return(0,X.jsx)(`div`,{className:`border-b border-border px-4 py-3 bg-surface`,"data-testid":`summary-header`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2 flex-wrap`,children:[(0,X.jsx)(`span`,{className:`text-xs text-muted-foreground truncate`,children:e}),n&&(0,X.jsx)(`span`,{className:O(`text-[10px] px-1.5 py-0.5 rounded bg-accent-warning/20 text-accent-warning font-medium`),"data-testid":`summary-stale-badge`,children:s(`summary.stale`)}),r&&(0,X.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full bg-accent-primary animate-pulse`,"aria-hidden":!0})]}),(0,X.jsx)(`p`,{className:`text-sm text-foreground mt-1`,children:t.summary}),(0,X.jsxs)(`div`,{className:`flex items-center gap-2 mt-2 flex-wrap`,children:[typeof d==`number`&&(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l(d),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-success/20 text-accent-success`,children:[`#`,d]}),f.map(e=>(0,X.jsxs)(`button`,{type:`button`,onClick:()=>l(e),className:`text-[10px] px-1.5 py-0.5 rounded bg-accent-info/15 text-accent-info`,children:[`#`,e]},e)),u&&(0,X.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:u})]})]}),o&&(0,X.jsxs)(`button`,{type:`button`,onClick:o,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(E,{className:`h-3.5 w-3.5`}),s(`summary.hide`)]})]})})}function Ne({content:e}){return(0,X.jsx)(a,{remarkPlugins:[u],children:e})}var Pe={done:`bg-accent-success/15 text-accent-success`,in_progress:`bg-accent-info/15 text-accent-info`,on_review:`bg-accent-warning/15 text-accent-warning`,todo:`bg-muted/60 text-muted-foreground`,draft:`bg-accent-secondary/15 text-accent-secondary`};function Fe(e){return e===`created`?g:e===`deleted`?N:C}function Ie({relPath:e,height:t,onOpenTicket:n,onFilterJob:r}){let{t:i}=p(`code`),{activeProjectId:a}=y(),{registerHandler:o,unregisterHandler:s}=S(),[c,l]=(0,F.useState)(null),[u,d]=(0,F.useState)(!1),[m,h]=(0,F.useState)({}),g=(0,F.useRef)(a);(0,F.useEffect)(()=>{g.current=a},[a]);let _=(0,F.useRef)(e);(0,F.useEffect)(()=>{_.current=e},[e]);let v=(0,F.useRef)(0),b=(0,F.useCallback)(async()=>{let t=++v.current;try{let n=await fetch(`${D()}/code/file/story?path=${encodeURIComponent(e)}`);if(t!==v.current)return;if(!n.ok){l([]),d(!0);return}let r=await n.json();if(t!==v.current)return;l(Array.isArray(r.story)?r.story:[]),d(!1)}catch{t===v.current&&(l([]),d(!0))}},[e,a]);(0,F.useEffect)(()=>{l(null),h({}),b()},[b]),(0,F.useEffect)(()=>{if(!a)return;let e=`code-story-${a}`;return o(e,e=>{let t=e;t.projectId===g.current&&t.path===_.current&&(t.type===`file.story_updated`||t.type===`file.provenance_updated`)&&b()}),()=>s(e)},[a,o,s,b]);let x=(0,F.useCallback)(async(t,n)=>{h(e=>({...e,[t.provenanceId]:`busy`}));try{let r=await fetch(`${D()}/code/file/story/explain?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({provenanceId:t.provenanceId,overrideBudget:n})}),a=await r.json().catch(()=>({}));if(a.skipped===`budget`){h(e=>({...e,[t.provenanceId]:`budget`}));return}if(!r.ok||!a.ok){f.error(i(`story.explainFailed`)),h(e=>{let n={...e};return delete n[t.provenanceId],n});return}await b(),h(e=>{let n={...e};return delete n[t.provenanceId],n})}catch{f.error(i(`story.explainFailed`)),h(e=>{let n={...e};return delete n[t.provenanceId],n})}},[b,e,i]);return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:t},"data-testid":`construction-story`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto`,children:c===null?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground animate-pulse py-2`,children:i(`story.loading`)}):u?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-failed`,children:i(`story.loadFailed`)}):c.length===0?(0,X.jsx)(`div`,{className:`text-[11px] text-muted-foreground py-2`,"data-testid":`story-empty`,children:i(`story.empty`)}):(0,X.jsx)(`ol`,{className:`relative ml-1.5 border-l border-border/60 space-y-3 py-1`,children:c.map(e=>(0,X.jsx)(Le,{entry:e,state:m[e.provenanceId],onOpenTicket:n,onFilterJob:r,onExplain:t=>{x(e,t)}},e.provenanceId))})})})}function Le({entry:e,state:t,onOpenTicket:n,onFilterJob:r,onExplain:i}){let{t:a}=p(`code`),o=Fe(e.kind),s=e.ticket?.status??null,l=e.ticket?.title?`#${e.ticket.id} · ${e.ticket.title}`:e.ticketId==null?null:a(`story.spec`,{ticketId:e.ticketId}),u=e.ticketId==null?`${e.kind}NoSpec`:e.kind;return(0,X.jsxs)(`li`,{className:`relative pl-4`,"data-testid":`story-card`,children:[(0,X.jsx)(`span`,{"aria-hidden":!0,className:`absolute -left-[5px] top-2 h-2.5 w-2.5 rounded-full border-2 border-background ${e.kind===`created`?`bg-accent-success`:e.kind===`deleted`?`bg-destructive`:`bg-accent-info`}`}),(0,X.jsxs)(`article`,{className:`rounded-lg border border-border/60 bg-card/60 px-3 py-2.5 backdrop-blur-sm transition-colors hover:border-border`,children:[(0,X.jsxs)(`header`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs text-muted-foreground`,children:[(0,X.jsx)(o,{className:`h-3.5 w-3.5 shrink-0`}),a(`story.kindLabel.${e.kind}`)]}),l!=null&&e.ticketId!=null&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e.ticketId),className:`min-w-0 max-w-full truncate rounded bg-accent-primary/15 px-1.5 py-0.5 text-left text-[11px] font-medium text-accent-primary hover:bg-accent-primary/25`,title:a(`story.openSpec`,{ticketId:e.ticketId}),children:l}),l==null&&(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:a(`story.unknownSpec`)}),s&&(0,X.jsx)(`span`,{className:`rounded px-1.5 py-0.5 text-[10px] ${Pe[s]??`bg-muted/60 text-muted-foreground`}`,"data-testid":`story-status-pill`,children:s}),(0,X.jsxs)(`span`,{className:`ml-auto inline-flex items-center gap-2`,children:[e.addedLines!=null&&e.addedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-accent-success`,title:a(`story.linesAdded`),children:[`+`,e.addedLines]}),e.removedLines!=null&&e.removedLines>0&&(0,X.jsxs)(`span`,{className:`font-mono text-[10px] text-destructive`,title:a(`story.linesRemoved`),children:[`−`,e.removedLines]}),(0,X.jsx)(`time`,{className:`text-[10px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]})]}),(0,X.jsx)(`div`,{className:`mt-1.5`,children:e.summary?(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`p`,{className:`text-sm leading-relaxed text-foreground/90`,"data-testid":`story-contribution`,children:e.summary}),e.summaryModel&&(0,X.jsx)(`p`,{className:`mt-1 text-[10px] text-muted-foreground/80`,children:a(`story.explainedBy`,{model:e.summaryModel})})]}):(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsx)(`p`,{className:`text-xs text-muted-foreground`,"data-testid":`story-fallback`,children:a(`story.fallback.${u}`)}),t===`budget`?(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,X.jsx)(`span`,{className:`text-[10px] text-accent-warning`,children:a(`story.budgetReached`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(!0),className:`rounded bg-accent-warning/15 px-1.5 py-0.5 text-[10px] text-accent-warning hover:bg-accent-warning/25`,children:a(`story.generateAnyway`)})]}):(0,X.jsxs)(`button`,{type:`button`,onClick:()=>i(!1),disabled:t===`busy`,className:`inline-flex items-center gap-1 rounded bg-accent-primary/10 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/20 disabled:opacity-60`,"data-testid":`story-explain`,children:[(0,X.jsx)(c,{className:t===`busy`?`h-3 w-3 animate-pulse`:`h-3 w-3`}),a(t===`busy`?`story.explaining`:`story.explain`)]})]})}),e.jobId&&r&&(0,X.jsx)(`footer`,{className:`mt-1.5`,children:(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.jobId),className:`font-mono text-[10px] text-muted-foreground hover:text-foreground`,title:a(`history.filterByJob`,{jobId:e.jobId}),children:e.jobId.length>12?e.jobId.slice(0,12):e.jobId})})]})]})}function Re(e,t){return t===`markdown`||t===`md`?!0:/\.(md|mdx|markdown)$/i.test(e)}var ze=180,Be=120,Ve=240;function He(e){return e?`specrails-desktop:code-summary-collapsed:${e}`:null}function Ue(e){return e?`specrails-desktop:code-history-height:${e}`:null}function We(e){return e?`specrails-desktop:code-history-collapsed:${e}`:null}function Ge(e){return e?`specrails-desktop:code-history-mode:${e}`:null}function Ke(e){let t=Ge(e);if(!t)return`story`;try{return localStorage.getItem(t)===`log`?`log`:`story`}catch{return`story`}}function qe(e,t){let n=Ge(e);if(n)try{localStorage.setItem(n,t)}catch{}}function Je(e){let t=Ue(e);if(!t)return ze;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:ze}catch{return ze}}function Ye(e,t){let n=Ue(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function Xe(e){let t=He(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function Ze(e,t){let n=He(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function Qe(e){let t=We(e);if(!t)return!1;try{return localStorage.getItem(t)===`true`}catch{return!1}}function $e(e,t){let n=We(e);if(n)try{localStorage.setItem(n,t?`true`:`false`)}catch{}}function et(e,t){let n=Math.max(Be,t-Ve);return Math.min(Math.max(e,Be),n)}function tt({relPath:e,onFilterJob:t,onSummaryActionChange:n,onCopyPathActionChange:r}){let{t:a}=p(`code`),{activeProjectId:o}=y(),{openTicketDetail:s}=i(),{registerHandler:c,unregisterHandler:l}=S(),u=j({allowMove:!1}),d=(0,F.useRef)(null),[m,h]=(0,F.useState)(null),[g,_]=(0,F.useState)(!0),[v,x]=(0,F.useState)(!1),[C,w]=(0,F.useState)(!1),[ee,O]=(0,F.useState)(()=>Xe(o)),[k,A]=(0,F.useState)(()=>Je(o)),[M,N]=(0,F.useState)(()=>Qe(o)),[P,I]=(0,F.useState)(()=>Ke(o)),L=(0,F.useRef)(o);(0,F.useEffect)(()=>{L.current=o},[o]);let R=(0,F.useRef)(e);(0,F.useEffect)(()=>{R.current=e},[e]),(0,F.useEffect)(()=>{let e=d.current?.clientHeight||window.innerHeight;O(Xe(o)),A(et(Je(o),e)),N(Qe(o)),I(Ke(o))},[o]);let te=(0,F.useCallback)(e=>{let t=e.clientY,n=k,r=d.current?.clientHeight||window.innerHeight,i=e.currentTarget;try{i.setPointerCapture(e.pointerId)}catch{}function a(e){A(et(n+(t-e.clientY),r))}function s(){window.removeEventListener(`pointermove`,a),window.removeEventListener(`pointerup`,s),window.removeEventListener(`pointercancel`,s),A(e=>{let t=et(e,r);return Ye(o,t),t})}window.addEventListener(`pointermove`,a),window.addEventListener(`pointerup`,s),window.addEventListener(`pointercancel`,s)},[o,k]),ne=(0,F.useCallback)(()=>{let e=et(ze,d.current?.clientHeight||window.innerHeight);A(e),Ye(o,e)},[o]),re=(0,F.useCallback)(()=>{O(e=>{let t=!e;return Ze(o,t),t})},[o]),z=(0,F.useCallback)(()=>{N(e=>{let t=!e;return $e(o,t),t})},[o]),B=(0,F.useCallback)(e=>{I(e),qe(o,e)},[o]);(0,F.useEffect)(()=>{x(!1),w(!1),K(`preview`),J(!1)},[e]);let V=(0,F.useRef)(0),H=(0,F.useCallback)(async()=>{let t=++V.current;_(!0);try{let n=await fetch(`${D()}/code/file?path=${encodeURIComponent(e)}`);if(t!==V.current)return;if(!n.ok){h(null);return}let r=await n.json();if(t!==V.current)return;h(r)}catch{t===V.current&&h(null)}finally{t===V.current&&_(!1)}},[e,o]);(0,F.useEffect)(()=>{H()},[H]),(0,F.useEffect)(()=>{if(!o)return;let e=`code-file-${o}`;return c(e,e=>{let t=e;t.projectId===L.current&&(t.type===`file.summary_updated`&&t.path===R.current?(x(!1),H()):t.type===`file.summary_failed`&&t.path===R.current?(f.error(t.reason??a(`summary.generationFailed`)),x(!1)):t.type===`file.summary_skipped`&&t.path===R.current&&(t.reason&&f(a(`summary.skipped`,{reason:t.reason})),x(!1)))}),()=>l(e)},[o,c,l,H,a]);let U=(0,F.useCallback)(async t=>{x(!0);try{let n=await fetch(`${D()}/code/file/regenerate-summary?path=${encodeURIComponent(e)}`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({overrideBudget:t})}),r=await n.json().catch(()=>({}));if(!n.ok){x(!1);let e=typeof r.skipped==`string`?r.skipped:null;f.error(e?a(`summary.skipped`,{reason:e}):a(`summary.generationFailed`));return}if(r.skipped===`budget`){x(!1),w(!0);return}if(r.skipped){x(!1),f(a(`summary.skipped`,{reason:r.skipped}));return}await H(),x(!1)}catch{x(!1),f.error(a(`summary.generationFailed`))}},[H,e,a]),ie=(0,F.useCallback)(async()=>{let t=m?.absolutePath??e;try{await navigator.clipboard?.writeText(t),f.success(a(`viewer.pathCopied`))}catch{f.error(a(`viewer.copyPathFailed`))}},[m,e,a]),W=(0,F.useMemo)(()=>Re(e,m?.language),[e,m?.language]),[G,K]=(0,F.useState)(`preview`),[q,J]=(0,F.useState)(!1),[ae,oe]=(0,F.useState)(``),[Y,se]=(0,F.useState)(!1),ce=m?.content!==void 0&&!m.binary&&!m.tooLarge&&m.reason!==`not-found`,le=(0,F.useCallback)(()=>{oe(m?.content??``),K(`raw`),J(!0)},[m]),ue=(0,F.useCallback)(async()=>{se(!0);try{let t=await fetch(`${D()}/code/file`,{method:`PUT`,headers:{"content-type":`application/json`},body:JSON.stringify({path:e,content:ae})});if(!t.ok){let e=await t.json().catch(()=>({}));f.error(e.error??a(`viewer.saveFailed`));return}f.success(a(`viewer.saved`)),J(!1),H()}catch{f.error(a(`viewer.saveFailed`))}finally{se(!1)}},[e,ae,a,H]),Z=m?.summary??null,de=!!m?.summaryStale,fe=m?.provenance??[],pe=m?.reason===`not-found`,me=pe?a(`summary.reason.missing`):m?.binary?a(`summary.reason.binary`):m?.tooLarge?a(`summary.reason.tooLarge`):null;return(0,F.useEffect)(()=>{if(n){if(g&&!m){n(null);return}return n({hasSummary:!!Z,regenerating:v,disabledReason:me,onClick:()=>U(!1)}),()=>n(null)}},[m,U,g,n,v,Z,me]),(0,F.useEffect)(()=>{if(r){if(g&&!m){r(null);return}return r({onClick:ie}),()=>r(null)}},[ie,m,g,r]),g&&!m?(0,X.jsx)(`div`,{className:`flex-1 flex items-center justify-center text-sm text-muted-foreground animate-pulse`,children:a(`viewer.loadingFile`)}):(0,X.jsxs)(`div`,{ref:d,className:`flex flex-col h-full`,"data-testid":`file-viewer`,children:[ee?(0,X.jsxs)(`div`,{className:`flex h-8 shrink-0 items-center justify-between border-b border-border bg-surface px-4`,"data-testid":`summary-header-collapsed`,children:[(0,X.jsx)(`span`,{className:`truncate text-xs text-muted-foreground`,children:e}),(0,X.jsxs)(`button`,{type:`button`,onClick:re,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(T,{className:`h-3.5 w-3.5`}),a(`viewer.showSummary`)]})]}):(0,X.jsx)(Me,{path:e,summary:Z,stale:de,regenerating:v,generateDisabledReason:me,onCollapse:re}),(0,X.jsxs)(`div`,{className:`px-4 py-1 border-b border-border flex items-center justify-between gap-3`,children:[(0,X.jsx)(`div`,{className:`flex items-center gap-2 min-w-0`,children:W&&m?.content!==void 0&&!m.binary&&!m.tooLarge&&(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px]`,role:`group`,"aria-label":a(`viewer.markdownViewMode`),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>K(`preview`),"aria-pressed":G===`preview`,className:G===`preview`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:a(`viewer.preview`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>K(`raw`),"aria-pressed":G===`raw`,className:G===`raw`?`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary`:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:a(`viewer.raw`)})]})}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 text-[11px] shrink-0`,children:[ce&&!q&&(0,X.jsx)(`button`,{type:`button`,onClick:le,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50`,children:a(`viewer.edit`)}),q&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>J(!1),disabled:Y,className:`px-2 py-1 rounded-md text-muted-foreground hover:text-foreground hover:bg-muted/50 disabled:opacity-50`,children:a(`actions.cancel`,{ns:`common`})}),(0,X.jsx)(`button`,{type:`button`,onClick:ue,disabled:Y,className:`px-2 py-1 rounded-md bg-accent-primary/20 text-accent-primary hover:bg-accent-primary/30 disabled:opacity-50`,children:a(Y?`viewer.saving`:`viewer.save`)})]})]})]}),(0,X.jsx)(`div`,{className:`flex-1 overflow-hidden`,children:pe?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-missing`,children:a(`viewer.missingFile`)}):m?.binary?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-binary`,children:a(`viewer.binaryFile`)}):m?.tooLarge?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,"data-testid":`file-too-large`,children:a(`viewer.tooLarge`,{size:Math.round((m.sizeBytes??0)/1024/1024)})}):m?.content===void 0?(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:a(`viewer.noContent`)}):q?(0,X.jsx)(Ae,{content:ae,language:m.language??`plaintext`,readOnly:!1,onChange:oe}):W&&G===`preview`?(0,X.jsx)(`div`,{className:`h-full overflow-auto px-6 py-4 prose prose-invert prose-sm max-w-none prose-p:my-2 prose-headings:mt-4 prose-headings:mb-2 prose-pre:bg-muted/40 prose-pre:rounded-md prose-code:before:content-none prose-code:after:content-none`,"data-testid":`markdown-preview`,children:(0,X.jsx)(Ne,{content:m.content})}):(0,X.jsx)(Ae,{content:m.content,language:m.language??`plaintext`})}),fe.length>0&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsxs)(`div`,{role:`separator`,"aria-orientation":`horizontal`,"aria-label":a(`history.resize`),onPointerDown:M?void 0:te,onDoubleClick:M?void 0:ne,className:M?`flex h-8 shrink-0 items-center justify-between border-t border-border bg-card/35 px-4`:`flex h-8 shrink-0 cursor-row-resize items-center justify-between border-y border-border/40 bg-card/35 px-4 hover:bg-accent-primary/10`,title:M?void 0:a(`resizer.hint`),"data-testid":`code-history-resizer`,children:[(0,X.jsx)(`span`,{className:`text-[11px] font-medium uppercase tracking-wider text-muted-foreground`,children:a(P===`story`?`story.title`:`history.title`,{count:fe.length})}),(0,X.jsxs)(`span`,{className:`flex items-center gap-1`,children:[!M&&(0,X.jsxs)(`span`,{className:`flex items-center gap-0.5 rounded-md bg-muted/40 p-0.5`,role:`group`,"aria-label":a(`story.viewMode`),onPointerDown:e=>e.stopPropagation(),children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>B(`story`),"aria-pressed":P===`story`,className:P===`story`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:a(`story.modeStory`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>B(`log`),"aria-pressed":P===`log`,className:P===`log`?`rounded px-2 py-0.5 text-[10px] bg-accent-primary/20 text-accent-primary`:`rounded px-2 py-0.5 text-[10px] text-muted-foreground hover:text-foreground`,children:a(`story.modeLog`)})]}),(0,X.jsxs)(`button`,{type:`button`,onPointerDown:e=>e.stopPropagation(),onClick:z,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[M?(0,X.jsx)(E,{className:`h-3.5 w-3.5`}):(0,X.jsx)(T,{className:`h-3.5 w-3.5`}),a(M?`history.show`:`history.hide`)]})]})]}),!M&&(P===`story`?(0,X.jsx)(Ie,{relPath:e,height:k,onOpenTicket:s,onFilterJob:t}):(0,X.jsx)(nt,{rows:fe,onOpenTicket:s,onFilterJob:t,height:k}))]}),C&&(0,X.jsxs)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center bg-black/50`,role:`dialog`,"aria-modal":`true`,"data-testid":`budget-prompt`,onClick:u.guardBackdrop(()=>w(!1)),children:[(0,X.jsxs)(`div`,{ref:u.panelRef,onClick:e=>e.stopPropagation(),className:`bg-card border border-border rounded-lg p-4 w-80 flex flex-col gap-3`,style:u.panelStyle,children:[(0,X.jsx)(`p`,{className:`text-sm text-foreground`,children:a(`viewer.budgetPrompt`)}),(0,X.jsxs)(`div`,{className:`flex justify-end gap-2`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>w(!1),className:`text-xs px-3 py-1.5 rounded-md text-muted-foreground hover:text-foreground`,children:a(`common:actions.cancel`)}),(0,X.jsx)(`button`,{type:`button`,onClick:()=>{w(!1),U(!0)},className:`text-xs px-3 py-1.5 rounded-md bg-accent-primary text-white`,children:a(`common:actions.confirm`)})]})]}),(0,X.jsx)(b,{handles:u.resizeHandles})]})]})}function nt({rows:e,onOpenTicket:t,onFilterJob:n,height:r}){let{t:i}=p(`code`),[a,o]=(0,F.useState)(null),[s,c]=(0,F.useState)({});if(e.length===0)return null;async function l(e,t){if(a===t){o(null);return}if(o(t),!(!e.jobId||s[t])){c(e=>({...e,[t]:`loading`}));try{let n=new URLSearchParams({jobId:e.jobId,path:e.path}),r=await fetch(`${D()}/code/diff?${n.toString()}`);if(r.status===404){c(e=>({...e,[t]:`missing`}));return}if(!r.ok)throw Error(`diff failed`);let i=await r.json();c(e=>({...e,[t]:{patch:i.patch??``,truncated:i.truncated===!0}}))}catch{c(e=>({...e,[t]:`missing`}))}}}return(0,X.jsx)(`div`,{className:`shrink-0 border-t border-border bg-card/40 px-4 py-3 overflow-hidden`,style:{height:r},"data-testid":`file-provenance-timeline`,children:(0,X.jsx)(`div`,{className:`h-full overflow-auto space-y-1`,children:e.map((e,r)=>{let o=e.kind===`created`?g:e.kind===`deleted`?N:C,c=e.jobId?e.jobId.length>12?e.jobId.slice(0,12):e.jobId:i(`history.unknownJob`),u=`${e.jobId??`job`}:${e.path}:${e.at}:${r}`,d=s[u];return(0,X.jsxs)(`div`,{className:`rounded-md hover:bg-muted/40`,children:[(0,X.jsxs)(`div`,{className:`grid grid-cols-[minmax(72px,auto)_minmax(0,1fr)_auto] items-center gap-2 text-xs px-2 py-1.5`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0`,children:[(0,X.jsx)(o,{className:`h-3.5 w-3.5 text-muted-foreground shrink-0`}),(0,X.jsx)(`span`,{className:`capitalize`,children:i(`kind.${e.kind}`)})]}),(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 min-w-0 text-muted-foreground`,children:[(0,X.jsx)(M,{className:`h-3.5 w-3.5 shrink-0`}),e.jobId&&n?(0,X.jsx)(`button`,{type:`button`,onClick:()=>n(e.jobId),className:`font-mono truncate hover:text-foreground`,title:i(`history.filterByJob`,{jobId:e.jobId}),children:c}):(0,X.jsx)(`span`,{className:`font-mono truncate`,title:e.jobId??void 0,children:c}),e.jobId&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>l(e,u),className:`shrink-0 rounded bg-muted/60 px-1.5 py-0.5 text-[10px] text-muted-foreground hover:bg-muted hover:text-foreground`,children:i(`history.diff`)}),typeof e.ticketId==`number`&&(0,X.jsx)(`button`,{type:`button`,onClick:()=>t(e.ticketId),className:`shrink-0 rounded bg-accent-primary/15 px-1.5 py-0.5 text-[10px] text-accent-primary hover:bg-accent-primary/25`,title:i(`history.openSpec`,{ticketId:e.ticketId}),children:i(`history.specChip`,{ticketId:e.ticketId})})]}),(0,X.jsx)(`time`,{className:`text-[11px] text-muted-foreground`,dateTime:new Date(e.at).toISOString(),children:new Date(e.at).toLocaleString()})]}),a===u&&(0,X.jsx)(`div`,{className:`px-2 pb-2`,children:d===`loading`?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.loadingDiff`)}):d===`missing`||!d?(0,X.jsx)(`div`,{className:`rounded-md bg-muted/35 px-2 py-2 text-[11px] text-muted-foreground`,children:i(`history.diffUnavailable`)}):(0,X.jsxs)(`pre`,{className:`max-h-72 overflow-auto rounded-md bg-muted/50 px-2 py-2 font-mono text-[11px] leading-relaxed text-foreground/85`,children:[d.patch,d.truncated?`\n${i(`history.diffTruncated`)}`:``]})})]},u)})})})}var rt=320,it=240,at=520;function ot(e){return e?`specrails-desktop:code-tree-width:${e}`:null}function st(e){let t=ot(e);if(!t)return rt;try{let e=localStorage.getItem(t),n=e?Number(e):NaN;return Number.isFinite(n)&&n>0?n:rt}catch{return rt}}function ct(e,t){let n=ot(e);if(n)try{localStorage.setItem(n,String(Math.round(t)))}catch{}}function $(e,t){let n=Math.max(it,t-at);return Math.min(Math.max(e,it),n)}function lt({embedded:e=!1,initialPath:t=null,onSelectedPathChange:n}={}){let{t:r}=p(`code`),{activeProjectId:i}=y(),[a]=h(),o=m(),s=(0,F.useRef)(null),[c,l]=(0,F.useState)(e?t:a.get(`path`)),u=(0,F.useCallback)(e=>{l(e),n?.(e)},[n]),[d,f]=(0,F.useState)(null),[g,_]=(0,F.useState)(null),[v,b]=(0,F.useState)(()=>st(i)),[x,S]=(0,F.useState)(null),[C,w]=(0,F.useState)(null),T=e?x:a.get(`jobId`),E=(0,F.useMemo)(()=>{if(e)return C;let t=a.get(`ticketId`);if(!t)return null;let n=Number(t);return Number.isInteger(n)&&n>0?n:null},[e,C,a]),[ee,D]=(0,F.useState)(E==null?``:String(E));(0,F.useEffect)(()=>{if(e)return;let t=a.get(`path`);t!==c&&l(t)},[a,e]),(0,F.useEffect)(()=>{D(E==null?``:String(E))},[E]),(0,F.useEffect)(()=>{let e=s.current?.clientWidth||window.innerWidth;b($(st(i),e))},[i]),(0,F.useEffect)(()=>{let e=s.current;if(!e||typeof ResizeObserver>`u`)return;let t=new ResizeObserver(e=>{let t=e[0]?.contentRect.width;typeof t==`number`&&b(e=>$(e,t))});return t.observe(e),()=>t.disconnect()},[]);let O=(0,F.useCallback)(e=>{let t=e.clientX,n=v,r=s.current?.clientWidth||window.innerWidth,a=e.currentTarget;try{a.setPointerCapture(e.pointerId)}catch{}function o(e){b($(n+(e.clientX-t),r))}function c(){window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,c),window.removeEventListener(`pointercancel`,c),b(e=>{let t=$(e,r);return ct(i,t),t})}window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,c),window.addEventListener(`pointercancel`,c)},[i,v]),k=(0,F.useCallback)(()=>{let e=$(rt,s.current?.clientWidth||window.innerWidth);b(e),ct(i,e)},[i]),A=(0,F.useCallback)(t=>{if(u(t),e)return;let n=new URLSearchParams(a);n.set(`path`,t),o({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,o,a,u]),j=(0,F.useCallback)(t=>{if(e){S(t),w(null);return}let n=new URLSearchParams(a);n.set(`jobId`,t),n.delete(`ticketId`),o({pathname:`/code`,search:`?${n.toString()}`},{replace:!0})},[e,o,a]),M=(0,F.useCallback)(()=>{if(e){S(null),w(null);return}let t=new URLSearchParams(a);t.delete(`jobId`),t.delete(`ticketId`),o({pathname:`/code`,search:t.toString()?`?${t.toString()}`:``},{replace:!0})},[e,o,a]),N=(0,F.useCallback)(t=>{let n=Number(t.trim());if(!Number.isInteger(n)||n<=0){M();return}if(e){w(n),S(null);return}let r=new URLSearchParams(a);r.set(`ticketId`,String(n)),r.delete(`jobId`),o({pathname:`/code`,search:`?${r.toString()}`},{replace:!0})},[M,e,o,a]);return(0,X.jsxs)(`div`,{ref:s,className:`flex h-full w-full`,"data-testid":`code-page`,children:[(0,X.jsx)(`aside`,{className:`overflow-hidden flex flex-col shrink-0`,style:{width:v},children:(0,X.jsx)(_e,{onOpenFile:A,selectedPath:c,filterJobId:T,filterTicketId:E},i??`no-project`)}),(0,X.jsx)(`div`,{role:`separator`,"aria-orientation":`vertical`,"aria-label":r(`page.resizeFileTree`),onPointerDown:O,onDoubleClick:k,className:`relative w-1.5 shrink-0 cursor-col-resize select-none touch-none border-x border-border/40 hover:bg-accent-primary/20 focus-visible:outline-none focus-visible:bg-accent-primary/30`,title:r(`resizer.hint`),"data-testid":`code-tree-resizer`}),(0,X.jsxs)(`main`,{className:`flex-1 overflow-hidden flex flex-col`,children:[(0,X.jsx)(ut,{jobId:T,ticketId:E,ticketInput:ee,onTicketInputChange:D,onApplyTicket:N,onClear:M,summaryAction:d,copyPathAction:g}),(T||E)&&(0,X.jsx)(dt,{jobId:T,ticketId:E,onOpenFile:A}),c?(0,X.jsx)(tt,{relPath:c,onFilterJob:j,onSummaryActionChange:f,onCopyPathActionChange:_}):(0,X.jsx)(`div`,{className:`h-full flex items-center justify-center text-sm text-muted-foreground`,children:r(`page.selectFile`)})]})]})}function ut({jobId:e,ticketId:t,ticketInput:n,onTicketInputChange:r,onApplyTicket:i,onClear:a,summaryAction:s,copyPathAction:c}){let{t:u}=p(`code`),d=t?`spec`:e?`job-context`:`all`;return(0,X.jsx)(`div`,{className:`border-b border-border bg-background/80 px-4 py-2`,"data-testid":`code-provenance-toolbar`,children:(0,X.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,X.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 text-xs font-medium text-muted-foreground`,children:[(0,X.jsx)(P,{className:`h-3.5 w-3.5`}),u(`toolbar.scope`)]}),(0,X.jsx)(`button`,{type:`button`,onClick:a,"aria-pressed":d===`all`,className:d===`all`?`rounded-md bg-accent-primary/20 px-2 py-1 text-xs text-accent-primary`:`rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:u(`toolbar.allAi`)}),(0,X.jsxs)(`div`,{className:`flex items-center gap-1 rounded-md border border-border/70 bg-card/40 px-1 py-1`,children:[(0,X.jsx)(`button`,{type:`button`,onClick:()=>i(n),"aria-pressed":d===`spec`,className:d===`spec`?`rounded bg-accent-success/20 px-2 py-0.5 text-xs text-accent-success`:`rounded px-2 py-0.5 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:u(`toolbar.spec`)}),(0,X.jsx)(`input`,{value:n,onChange:e=>r(e.target.value),onKeyDown:e=>{e.key===`Enter`&&i(n)},placeholder:u(`toolbar.ticketIdPlaceholder`),inputMode:`numeric`,className:`h-6 w-20 bg-transparent px-1 font-mono text-xs outline-none placeholder:text-muted-foreground/60`})]}),(0,X.jsx)(`div`,{className:`flex-1`}),c&&(0,X.jsx)(`button`,{type:`button`,onClick:c.onClick,className:`inline-flex items-center gap-1.5 rounded-md px-2.5 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:u(`toolbar.copyFilePath`)}),s&&(0,X.jsxs)(`button`,{type:`button`,onClick:s.onClick,disabled:s.regenerating||!!s.disabledReason,"aria-label":s.hasSummary?u(`toolbar.regenerateSummary`):u(`toolbar.generateSummary`),className:`inline-flex items-center gap-1.5 rounded-md bg-accent-primary/15 px-2.5 py-1 text-xs text-accent-primary hover:bg-accent-primary/25 disabled:opacity-50`,title:s.disabledReason?u(`toolbar.summaryUnavailable`,{reason:s.disabledReason}):void 0,children:[(0,X.jsx)(o,{className:s.regenerating?`h-3.5 w-3.5 animate-spin`:`h-3.5 w-3.5`}),s.hasSummary?s.regenerating?u(`toolbar.regenerating`):u(`toolbar.regenerateSummary`):s.regenerating?u(`toolbar.generating`):u(`toolbar.generateSummary`)]}),d===`job-context`&&(0,X.jsx)(`span`,{className:`rounded-md bg-accent-info/15 px-2 py-1 text-xs text-accent-info`,children:u(`toolbar.jobContext`)}),(e||t)&&(0,X.jsxs)(`button`,{type:`button`,onClick:a,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(l,{className:`h-3.5 w-3.5`}),u(`toolbar.clear`)]})]})})}function dt({jobId:e,ticketId:t,onOpenFile:n}){let{t:r}=p(`code`),[i,a]=(0,F.useState)(null);(0,F.useEffect)(()=>{let n=!1,r=new URLSearchParams;return e&&r.set(`jobId`,e),t&&r.set(`ticketId`,String(t)),fetch(`${D()}/code/provenance?${r.toString()}`).then(e=>e.ok?e.json():[]).then(e=>{n||a(Array.isArray(e)?e:[])}).catch(()=>{n||a([])}),()=>{n=!0}},[e,t]);let o=(0,F.useMemo)(()=>{let e=i??[];return{created:e.filter(e=>e.kind===`created`),modified:e.filter(e=>e.kind===`modified`),deleted:e.filter(e=>e.kind===`deleted`)}},[i]),s=i?.length??0;return(0,X.jsx)(`section`,{className:`border-b border-border bg-card/35 px-4 py-3`,"data-testid":`provenance-result-panel`,children:(0,X.jsxs)(`div`,{className:`flex items-start justify-between gap-3`,children:[(0,X.jsxs)(`div`,{className:`min-w-0`,children:[(0,X.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,X.jsx)(`h2`,{className:`text-sm font-semibold truncate`,children:e?r(`provenancePanel.jobTitle`,{jobId:e}):r(`provenancePanel.specTitle`,{ticketId:t})}),(0,X.jsx)(`span`,{className:`text-[11px] text-muted-foreground`,children:r(`provenancePanel.touchedFiles`,{count:s})})]}),(0,X.jsxs)(`div`,{className:`mt-2 flex flex-wrap gap-2`,children:[(0,X.jsx)(ft,{label:r(`action.added`),rows:o.created,icon:`created`,onOpenFile:n}),(0,X.jsx)(ft,{label:r(`action.changed`),rows:o.modified,icon:`modified`,onOpenFile:n}),(0,X.jsx)(ft,{label:r(`action.deleted`),rows:o.deleted,icon:`deleted`,onOpenFile:n})]})]}),(0,X.jsx)(`div`,{className:`flex items-center gap-1 shrink-0`,children:e&&(0,X.jsxs)(`a`,{href:`/jobs/${encodeURIComponent(e)}`,className:`inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs text-muted-foreground hover:bg-muted/50 hover:text-foreground`,children:[(0,X.jsx)(v,{className:`h-3.5 w-3.5`}),r(`provenancePanel.log`)]})})]})})}function ft({label:e,rows:t,icon:n,onOpenFile:r}){return(0,X.jsxs)(`details`,{className:`group min-w-[180px] max-w-[320px]`,children:[(0,X.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-center gap-1.5 rounded-md bg-muted/35 px-2 py-1 text-xs hover:bg-muted/55`,children:[(0,X.jsx)(n===`created`?g:n===`deleted`?N:C,{className:`h-3.5 w-3.5 text-muted-foreground`}),(0,X.jsx)(`span`,{children:e}),(0,X.jsx)(`span`,{className:`text-muted-foreground`,children:t.length})]}),t.length>0&&(0,X.jsx)(`div`,{className:`mt-1 max-h-28 overflow-auto rounded-md border border-border/60 bg-background/60 p-1`,children:t.map((e,t)=>(0,X.jsx)(`button`,{type:`button`,onClick:()=>r(e.path),className:`block w-full truncate rounded px-1.5 py-1 text-left font-mono text-[11px] text-muted-foreground hover:bg-muted/50 hover:text-foreground`,title:e.path,children:e.path},`${e.path}-${e.jobId??`job`}-${e.at}-${t}`))})]})}export{lt as default};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./clsx-CNmW0Nip.js";import{Bn as n,Rn as r,S as i,Wt as a,Yn as o,_ as s,ct as c,lt as l,nt as u,ot as d}from"./index-89SuhD4Y.js";import{$ as f,A as p,B as m,E as h,F as g,H as _,K as v,L as y,N as b,O as x,P as S,Q as C,R as w,S as T,T as ee,U as E,W as D,X as O,Y as te,Z as k,_ as ne,_t as A,a as re,c as ie,d as ae,dt as j,et as M,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as N,j as fe,k as pe,l as P,lt as F,mt as me,n as he,nt as I,o as ge,pt as L,q as R,r as z,rt as B,s as _e,t as ve,u as ye,ut as V,v as be,w as H,z as xe}from"./BarChart-Ckstq9fl.js";var Se=r(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),U=e(o());function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(null,arguments)}var G=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return j(n)&&j(r)&&j(i)?U.createElement(`circle`,W({},ce(e),N(e),{className:o,cx:n,cy:r,r:i})):null},Ce=[`points`];function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?K(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(null,arguments)}function De(e,t){if(e==null)return{};var n,r,i=Oe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Oe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ke(e){var{option:n,dotProps:r,className:i}=e;if((0,U.isValidElement)(n))return(0,U.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=De(o,Ce);return U.createElement(G,J({},c,{className:a}))}function Ae(e,t){return e==null?!1:t?!0:e.length===1}function je(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=y.scatter}=e;if(!Ae(t,n))return null;var u=H(n),d=ue(n),f=t.map((e,r)=>{var s=q(q(q({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return U.createElement(ke,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),U.createElement(p,{zIndex:l},U.createElement(L,J({className:r},m),f))}function Me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Me(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=Pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pe(e){var t=Fe(e,`string`);return typeof t==`symbol`?t:t+``}function Fe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Ie=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Y(Y(Y({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),A(i)),N(i)),c=(0,U.isValidElement)(i)?(0,U.cloneElement)(i,s):typeof i==`function`?i(s):U.createElement(G,s);return U.createElement(L,{className:`recharts-active-dot`,clipPath:o},c)};function Le(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=y.activeDot}=e,s=I(fe),c=ye();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return V(l)?null:U.createElement(p,{zIndex:o},U.createElement(Ie,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Re=(e,t,n,r)=>b(e,`xAxis`,t,r),ze=(e,t,n,r)=>S(e,`xAxis`,t,r),Be=(e,t,n,r)=>b(e,`yAxis`,n,r),Ve=(e,t,n,r)=>S(e,`yAxis`,n,r),He=M([E,Re,Be,ze,Ve],(e,t,n,r,i)=>f(e,`xAxis`)?te(t,r,!1):te(n,i,!1)),Ue=(e,t,n,r,i)=>i;function We(e){return e.type===`line`}var Ge=M([E,Re,Be,ze,Ve,M([g,Ue],(e,t)=>e.filter(We).find(e=>e.id===t)),He,w],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return gt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Ke(e){var t=A(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var qe=[`id`],Je=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Ye=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function Xe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xe(Object(n),!0).forEach(function(t){Ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ze(e,t,n){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qe(e){var t=$e(e,`string`);return typeof t==`symbol`?t:t+``}function $e(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Q(e,t){if(e==null)return{};var n,r,i=et(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function et(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var tt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},nt=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:oe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:k(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return U.createElement(be,{tooltipEntrySettings:d})}),rt=(e,t)=>`${t}px ${e}px`;function it(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var at=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return rt(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...it(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function ot(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ce(Q(r,qe));return U.createElement(je,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function st(e){var{showLabels:t,children:n,points:r}=e,i=(0,U.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return U.createElement(ee,{value:t?i:void 0},n)}function ct(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=Z(Z({},me(Q(a,Je))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return U.createElement(U.Fragment,null,r?.length>1&&U.createElement(T,X({shapeType:`curve`,option:u},d,{pathRef:n})),U.createElement(ot,{points:r,clipPathId:t,props:a}))}function lt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function ut(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:g,onAnimationEnd:_,onAnimationStart:v}=n,y=i.current,b=xe(o,`recharts-line-`),x=(0,U.useRef)(b),[S,C]=(0,U.useState)(!1),w=!S,T=(0,U.useCallback)(()=>{typeof _==`function`&&_(),C(!1)},[_]),ee=(0,U.useCallback)(()=>{typeof v==`function`&&v(),C(!0)},[v]),E=lt(r.current),D=(0,U.useRef)(0);x.current!==b&&(D.current=a.current,x.current=b);var O=D.current;return U.createElement(st,{points:o,showLabels:w},n.children,U.createElement(m,{animationId:b,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:T,onAnimationStart:ee,key:b},e=>{var l=F(O,E+O,e),u=Math.min(l,E),d=c?s?at(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):rt(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),y){var m=y.length/o.length,h=e===1?o:o.map((t,n)=>{var r=Math.floor(n*m);if(y[r]){var i=y[r];return Z(Z({},t),{},{x:F(i.x,t.x,e),y:F(i.y,t.y,e)})}return f?Z(Z({},t),{},{x:F(p*2,t.x,e),y:F(g/2,t.y,e)}):Z(Z({},t),{},{x:t.x,y:t.y})});return i.current=h,U.createElement(ct,{props:n,points:h,clipPathId:t,pathRef:r,strokeDasharray:d})}return U.createElement(ct,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),U.createElement(h,{label:n.label}))}function dt(e){var{clipPathId:t,props:n}=e,r=(0,U.useRef)(null),i=(0,U.useRef)(0),a=(0,U.useRef)(null);return U.createElement(ut,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ft=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:C(e.payload,t)}),pt=class extends U.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:s,left:c,width:l,height:u,id:d,needClip:f,zIndex:m}=this.props;if(e)return null;var h=t(`recharts-line`,i),g=d,{r:_,strokeWidth:v}=Ke(n),y=H(n),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${g})`:void 0;return U.createElement(p,{zIndex:m},U.createElement(L,{className:h},f&&U.createElement(`defs`,null,U.createElement(ge,{clipPathId:g,xAxisId:a,yAxisId:o}),!y&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:c-b/2,y:s-b/2,width:l+b,height:u+b}))),U.createElement(ie,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:ft,errorBarOffset:0},U.createElement(dt,{props:this.props,clipPathId:g}))),U.createElement(Le,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}},mt={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:y.line,type:`linear`};function ht(e){var t=B(e,mt),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Q(t,Ye),{needClip:_}=_e(p,m),v=ae(),y=D(),b=R(),x=I(e=>Ge(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return U.createElement(pt,X({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function gt(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=C(e,o);if(t===`horizontal`)return{x:O({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=O({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function _t(e){var t=B(e,mt),n=R();return U.createElement(se,{id:t.id,type:`line`},e=>U.createElement(U.Fragment,null,U.createElement(ne,{legendPayload:tt(t)}),U.createElement(nt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(le,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),U.createElement(ht,X({},t,{id:e}))))}var vt=U.memo(_t,_);vt.displayName=`Line`;var yt=[`axis`],bt=(0,U.forwardRef)((e,t)=>U.createElement(he,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:yt,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),$=l(),xt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function St({period:e,from:t,to:r,onChange:i}){let{t:a}=n(`analytics`);function o(e){e===`custom`?i(`custom`,t,r):i(e)}function s(e){i(`custom`,e,r)}function c(e){i(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:xt.map(t=>(0,$.jsx)(`button`,{onClick:()=>o(t.value),className:u(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:a(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":a(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:a(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:r,onChange:e=>c(e.target.value),"aria-label":a(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Ct({kpi:e,windowLabel:t}){let{t:r}=n(`analytics`),i=e.estimatedCostUsd??0,a=e.estimatedCostToday??0,o=e.includesEstimated??i>0,s=i>0,c=a>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:r(`desktop.totalCost`),value:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:r(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:r(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:r(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:r(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:r(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:r(`desktop.avgCostPerJob`),value:e.totalJobs>0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:r(`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),o&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:r(`desktop.includesEstimatedTooltip`,{amount:`$${i.toFixed(4)}`}),children:r(`desktop.includesEstimated`,{amount:`$${i.toFixed(4)}`})})]})}function wt({data:e}){let{t}=n(`analytics`),r=s(),a=e.length>0&&e.some(e=>e.costUsd>0),o=Math.max(1,Math.floor(e.length/7)),c=e.filter((e,t)=>t%o===0).map(e=>e.date),l=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),u=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),u&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)})]}),a?(0,$.jsx)(v,{width:`100%`,height:200,children:(0,$.jsxs)(bt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`date`,ticks:c,tickFormatter:e=>{try{return i(new Date(e),`MMM d`,{locale:d()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(l.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(vt,{type:`monotone`,dataKey:`costUsd`,stroke:r.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:r.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function Tt({projects:e}){let{t}=n(`analytics`),r=s();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let i=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,n)=>{let a=e.estimatedCostUsd??0,o=a>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsxs)(`span`,{className:`font-mono text-foreground`,children:[o?`~`:``,`$`,e.totalCostUsd.toFixed(4)]})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/i*100}%`,backgroundColor:r.chart[n%r.chart.length]}})})]},e.projectId)})})]})}function Et({projects:e}){let{t}=n(`analytics`),r=s();if(e.length===0)return null;let i=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),(0,$.jsx)(v,{width:`100%`,height:180,children:(0,$.jsxs)(ve,{data:i,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(re,{dataKey:`costUsd`,fill:r.chart[1],radius:[3,3,0,0]})]})})]})}function Dt(){let{t:e}=n(`analytics`),[t,r]=(0,U.useState)(`7d`),[i,o]=(0,U.useState)(``),[s,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(null),{registerHandler:g,unregisterHandler:_}=c(),v=(0,U.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,i,s)},[t,i,s]);(0,U.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);d(await i.json())}catch(e){h(e.message)}finally{p(!1)}}(0,U.useEffect)(()=>{y(t,i,s)},[t,i,s]);function b(e,t,n){r(e),t!==void 0&&o(t),n!==void 0&&l(n)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),u&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(St,{period:t,from:i,to:s,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,i,s),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(a,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ct,{kpi:u.kpi,windowLabel:t===`custom`?u.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(wt,{data:u.costTimeline}),(0,$.jsx)(Et,{projects:u.projectBreakdown})]}),(0,$.jsx)(Tt,{projects:u.projectBreakdown})]})]})})}export{Dt as default};
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./clsx-CNmW0Nip.js";import{$n as n,Hn as r,Jt as i,T as a,Wn as o,b as s,ft as c,ot as l,pt as u,ut as d}from"./index-DyY1QyIn.js";import{$ as f,A as p,B as m,E as h,F as g,H as _,K as v,L as y,N as b,O as x,P as S,Q as C,R as w,S as T,T as ee,U as E,W as D,X as O,Y as te,Z as k,_ as ne,_t as A,a as re,c as ie,d as ae,dt as j,et as M,ft as oe,g as se,gt as ce,h as le,ht as ue,i as de,it as N,j as fe,k as pe,l as P,lt as F,mt as me,n as he,nt as I,o as ge,pt as L,q as R,r as z,rt as B,s as _e,t as ve,u as ye,ut as V,v as be,w as H,z as xe}from"./BarChart-DugEoe2q.js";var Se=r(`trending-up`,[[`path`,{d:`M16 7h6v6`,key:`box55l`}],[`path`,{d:`m22 7-8.5 8.5-5-5L2 17`,key:`1t1m79`}]]),U=e(n());function W(){return W=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},W.apply(null,arguments)}var G=e=>{var{cx:n,cy:r,r:i,className:a}=e,o=t(`recharts-dot`,a);return j(n)&&j(r)&&j(i)?U.createElement(`circle`,W({},ce(e),N(e),{className:o,cx:n,cy:r,r:i})):null},Ce=[`points`];function K(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function q(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?K(Object(n),!0).forEach(function(t){we(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):K(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function we(e,t,n){return(t=Te(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Te(e){var t=Ee(e,`string`);return typeof t==`symbol`?t:t+``}function Ee(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function J(){return J=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},J.apply(null,arguments)}function De(e,t){if(e==null)return{};var n,r,i=Oe(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function Oe(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}function ke(e){var{option:n,dotProps:r,className:i}=e;if((0,U.isValidElement)(n))return(0,U.cloneElement)(n,r);if(typeof n==`function`)return n(r);var a=t(i,typeof n==`boolean`?``:n.className),o=r??{},{points:s}=o,c=De(o,Ce);return U.createElement(G,J({},c,{className:a}))}function Ae(e,t){return e==null?!1:t?!0:e.length===1}function je(e){var{points:t,dot:n,className:r,dotClassName:i,dataKey:a,baseProps:o,needClip:s,clipPathId:c,zIndex:l=y.scatter}=e;if(!Ae(t,n))return null;var u=H(n),d=ue(n),f=t.map((e,r)=>{var s=q(q(q({r:3},o),d),{},{index:r,cx:e.x??void 0,cy:e.y??void 0,dataKey:a,value:e.value,payload:e.payload,points:t});return U.createElement(ke,{key:`dot-${r}`,option:n,dotProps:s,className:i})}),m={};return s&&c!=null&&(m.clipPath=`url(#clipPath-${u?``:`dots-`}${c})`),U.createElement(p,{zIndex:l},U.createElement(L,J({className:r},m),f))}function Me(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Y(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Me(Object(n),!0).forEach(function(t){Ne(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Me(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ne(e,t,n){return(t=Pe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Pe(e){var t=Fe(e,`string`);return typeof t==`symbol`?t:t+``}function Fe(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}var Ie=e=>{var{point:t,childIndex:n,mainColor:r,activeDot:i,dataKey:a,clipPath:o}=e;if(i===!1||t.x==null||t.y==null)return null;var s=Y(Y(Y({},{index:n,dataKey:a,cx:t.x,cy:t.y,r:4,fill:r??`none`,strokeWidth:2,stroke:`#fff`,payload:t.payload,value:t.value}),A(i)),N(i)),c=(0,U.isValidElement)(i)?(0,U.cloneElement)(i,s):typeof i==`function`?i(s):U.createElement(G,s);return U.createElement(L,{className:`recharts-active-dot`,clipPath:o},c)};function Le(e){var{points:t,mainColor:n,activeDot:r,itemDataKey:i,clipPath:a,zIndex:o=y.activeDot}=e,s=I(fe),c=ye();if(t==null||c==null)return null;var l=t.find(e=>c.includes(e.payload));return V(l)?null:U.createElement(p,{zIndex:o},U.createElement(Ie,{point:l,childIndex:Number(s),mainColor:n,dataKey:i,activeDot:r,clipPath:a}))}var Re=(e,t,n,r)=>b(e,`xAxis`,t,r),ze=(e,t,n,r)=>S(e,`xAxis`,t,r),Be=(e,t,n,r)=>b(e,`yAxis`,n,r),Ve=(e,t,n,r)=>S(e,`yAxis`,n,r),He=M([E,Re,Be,ze,Ve],(e,t,n,r,i)=>f(e,`xAxis`)?te(t,r,!1):te(n,i,!1)),Ue=(e,t,n,r,i)=>i;function We(e){return e.type===`line`}var Ge=M([E,Re,Be,ze,Ve,M([g,Ue],(e,t)=>e.filter(We).find(e=>e.id===t)),He,w],(e,t,n,r,i,a,o,s)=>{var{chartData:c,dataStartIndex:l,dataEndIndex:u}=s;if(!(a==null||t==null||n==null||r==null||i==null||r.length===0||i.length===0||o==null||e!==`horizontal`&&e!==`vertical`)){var{dataKey:d,data:f}=a,p=f!=null&&f.length>0?f:c?.slice(l,u+1);if(p!=null)return gt({layout:e,xAxis:t,yAxis:n,xAxisTicks:r,yAxisTicks:i,dataKey:d,bandSize:o,displayedData:p})}});function Ke(e){var t=A(e),n=3,r=2;if(t!=null){var{r:i,strokeWidth:a}=t,o=Number(i),s=Number(a);return(Number.isNaN(o)||o<0)&&(o=n),(Number.isNaN(s)||s<0)&&(s=r),{r:o,strokeWidth:s}}return{r:n,strokeWidth:r}}var qe=[`id`],Je=[`type`,`layout`,`connectNulls`,`needClip`,`shape`],Ye=[`activeDot`,`animateNewValues`,`animationBegin`,`animationDuration`,`animationEasing`,`connectNulls`,`dot`,`hide`,`isAnimationActive`,`label`,`legendType`,`xAxisId`,`yAxisId`,`id`];function X(){return X=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)({}).hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},X.apply(null,arguments)}function Xe(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter(function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable})),n.push.apply(n,r)}return n}function Z(e){for(var t=1;t<arguments.length;t++){var n=arguments[t]==null?{}:arguments[t];t%2?Xe(Object(n),!0).forEach(function(t){Ze(e,t,n[t])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):Xe(Object(n)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))})}return e}function Ze(e,t,n){return(t=Qe(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function Qe(e){var t=$e(e,`string`);return typeof t==`symbol`?t:t+``}function $e(e,t){if(typeof e!=`object`||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var r=n.call(e,t||`default`);if(typeof r!=`object`)return r;throw TypeError(`@@toPrimitive must return a primitive value.`)}return(t===`string`?String:Number)(e)}function Q(e,t){if(e==null)return{};var n,r,i=et(e,t);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);for(r=0;r<a.length;r++)n=a[r],t.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(i[n]=e[n])}return i}function et(e,t){if(e==null)return{};var n={};for(var r in e)if({}.hasOwnProperty.call(e,r)){if(t.indexOf(r)!==-1)continue;n[r]=e[r]}return n}var tt=e=>{var{dataKey:t,name:n,stroke:r,legendType:i,hide:a}=e;return[{inactive:a,dataKey:t,type:i,color:r,value:k(n,t),payload:e}]},nt=U.memo(e=>{var{dataKey:t,data:n,stroke:r,strokeWidth:i,fill:a,name:o,hide:s,unit:c,tooltipType:l,id:u}=e,d={dataDefinedOnItem:n,getPosition:oe,settings:{stroke:r,strokeWidth:i,fill:a,dataKey:t,nameKey:void 0,name:k(o,t),hide:s,type:l,color:r,unit:c,graphicalItemId:u}};return U.createElement(be,{tooltipEntrySettings:d})}),rt=(e,t)=>`${t}px ${e}px`;function it(e,t){for(var n=e.length%2==0?e:[...e,0],r=[],i=0;i<t;++i)r.push(...n);return r}var at=(e,t,n)=>{var r=n.reduce((e,t)=>e+t,0);if(!r)return rt(t,e);for(var i=Math.floor(e/r),a=e%r,o=[],s=0,c=0;s<n.length;c+=(l=n[s])??0,++s){var l,u=n[s];if(u!=null&&c+u>a){o=[...n.slice(0,s),a-c];break}}var d=o.length%2==0?[0,t]:[t];return[...it(n,i),...o,...d].map(e=>`${e}px`).join(`, `)};function ot(e){var{clipPathId:t,points:n,props:r}=e,{dot:i,dataKey:a,needClip:o}=r,{id:s}=r,c=ce(Q(r,qe));return U.createElement(je,{points:n,dot:i,className:`recharts-line-dots`,dotClassName:`recharts-line-dot`,dataKey:a,baseProps:c,needClip:o,clipPathId:t})}function st(e){var{showLabels:t,children:n,points:r}=e,i=(0,U.useMemo)(()=>r?.map(e=>{var t={x:e.x??0,y:e.y??0,width:0,lowerWidth:0,upperWidth:0,height:0};return Z(Z({},t),{},{value:e.value,payload:e.payload,viewBox:t,parentViewBox:void 0,fill:void 0})}),[r]);return U.createElement(ee,{value:t?i:void 0},n)}function ct(e){var{clipPathId:t,pathRef:n,points:r,strokeDasharray:i,props:a}=e,{type:o,layout:s,connectNulls:c,needClip:l,shape:u}=a,d=Z(Z({},me(Q(a,Je))),{},{fill:`none`,className:`recharts-line-curve`,clipPath:l?`url(#clipPath-${t})`:void 0,points:r,type:o,layout:s,connectNulls:c,strokeDasharray:i??a.strokeDasharray});return U.createElement(U.Fragment,null,r?.length>1&&U.createElement(T,X({shapeType:`curve`,option:u},d,{pathRef:n})),U.createElement(ot,{points:r,clipPathId:t,props:a}))}function lt(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function ut(e){var{clipPathId:t,props:n,pathRef:r,previousPointsRef:i,longestAnimatedLengthRef:a}=e,{points:o,strokeDasharray:s,isAnimationActive:c,animationBegin:l,animationDuration:u,animationEasing:d,animateNewValues:f,width:p,height:g,onAnimationEnd:_,onAnimationStart:v}=n,y=i.current,b=xe(o,`recharts-line-`),x=(0,U.useRef)(b),[S,C]=(0,U.useState)(!1),w=!S,T=(0,U.useCallback)(()=>{typeof _==`function`&&_(),C(!1)},[_]),ee=(0,U.useCallback)(()=>{typeof v==`function`&&v(),C(!0)},[v]),E=lt(r.current),D=(0,U.useRef)(0);x.current!==b&&(D.current=a.current,x.current=b);var O=D.current;return U.createElement(st,{points:o,showLabels:w},n.children,U.createElement(m,{animationId:b,begin:l,duration:u,isActive:c,easing:d,onAnimationEnd:T,onAnimationStart:ee,key:b},e=>{var l=F(O,E+O,e),u=Math.min(l,E),d=c?s?at(u,E,`${s}`.split(/[,\s]+/gim).map(e=>parseFloat(e))):rt(E,u):s==null?void 0:String(s);if(e>0&&E>0&&(i.current=o,a.current=Math.max(a.current,u)),y){var m=y.length/o.length,h=e===1?o:o.map((t,n)=>{var r=Math.floor(n*m);if(y[r]){var i=y[r];return Z(Z({},t),{},{x:F(i.x,t.x,e),y:F(i.y,t.y,e)})}return f?Z(Z({},t),{},{x:F(p*2,t.x,e),y:F(g/2,t.y,e)}):Z(Z({},t),{},{x:t.x,y:t.y})});return i.current=h,U.createElement(ct,{props:n,points:h,clipPathId:t,pathRef:r,strokeDasharray:d})}return U.createElement(ct,{props:n,points:o,clipPathId:t,pathRef:r,strokeDasharray:d})}),U.createElement(h,{label:n.label}))}function dt(e){var{clipPathId:t,props:n}=e,r=(0,U.useRef)(null),i=(0,U.useRef)(0),a=(0,U.useRef)(null);return U.createElement(ut,{props:n,clipPathId:t,previousPointsRef:r,longestAnimatedLengthRef:i,pathRef:a})}var ft=(e,t)=>({x:e.x??void 0,y:e.y??void 0,value:e.value,errorVal:C(e.payload,t)}),pt=class extends U.Component{render(){var{hide:e,dot:n,points:r,className:i,xAxisId:a,yAxisId:o,top:s,left:c,width:l,height:u,id:d,needClip:f,zIndex:m}=this.props;if(e)return null;var h=t(`recharts-line`,i),g=d,{r:_,strokeWidth:v}=Ke(n),y=H(n),b=_*2+v,x=f?`url(#clipPath-${y?``:`dots-`}${g})`:void 0;return U.createElement(p,{zIndex:m},U.createElement(L,{className:h},f&&U.createElement(`defs`,null,U.createElement(ge,{clipPathId:g,xAxisId:a,yAxisId:o}),!y&&U.createElement(`clipPath`,{id:`clipPath-dots-${g}`},U.createElement(`rect`,{x:c-b/2,y:s-b/2,width:l+b,height:u+b}))),U.createElement(ie,{xAxisId:a,yAxisId:o,data:r,dataPointFormatter:ft,errorBarOffset:0},U.createElement(dt,{props:this.props,clipPathId:g}))),U.createElement(Le,{activeDot:this.props.activeDot,points:r,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:x}))}},mt={activeDot:!0,animateNewValues:!0,animationBegin:0,animationDuration:1500,animationEasing:`ease`,connectNulls:!1,dot:!0,fill:`#fff`,hide:!1,isAnimationActive:`auto`,label:!1,legendType:`line`,stroke:`#3182bd`,strokeWidth:1,xAxisId:0,yAxisId:0,zIndex:y.line,type:`linear`};function ht(e){var t=B(e,mt),{activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,connectNulls:s,dot:c,hide:l,isAnimationActive:u,label:d,legendType:f,xAxisId:p,yAxisId:m,id:h}=t,g=Q(t,Ye),{needClip:_}=_e(p,m),v=ae(),y=D(),b=R(),x=I(e=>Ge(e,p,m,b,h));if(y!==`horizontal`&&y!==`vertical`||x==null||v==null)return null;var{height:S,width:C,x:w,y:T}=v;return U.createElement(pt,X({},g,{id:h,connectNulls:s,dot:c,activeDot:n,animateNewValues:r,animationBegin:i,animationDuration:a,animationEasing:o,isAnimationActive:u,hide:l,label:d,legendType:f,xAxisId:p,yAxisId:m,points:x,layout:y,height:S,width:C,left:w,top:T,needClip:_}))}function gt(e){var{layout:t,xAxis:n,yAxis:r,xAxisTicks:i,yAxisTicks:a,dataKey:o,bandSize:s,displayedData:c}=e;return c.map((e,c)=>{var l=C(e,o);if(t===`horizontal`)return{x:O({axis:n,ticks:i,bandSize:s,entry:e,index:c}),y:(V(l)?null:r.scale.map(l))??null,value:l,payload:e};var u=V(l)?null:n.scale.map(l),d=O({axis:r,ticks:a,bandSize:s,entry:e,index:c});return u==null||d==null?null:{x:u,y:d,value:l,payload:e}}).filter(Boolean)}function _t(e){var t=B(e,mt),n=R();return U.createElement(se,{id:t.id,type:`line`},e=>U.createElement(U.Fragment,null,U.createElement(ne,{legendPayload:tt(t)}),U.createElement(nt,{dataKey:t.dataKey,data:t.data,stroke:t.stroke,strokeWidth:t.strokeWidth,fill:t.fill,name:t.name,hide:t.hide,unit:t.unit,tooltipType:t.tooltipType,id:e}),U.createElement(le,{type:`line`,id:e,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:n}),U.createElement(ht,X({},t,{id:e}))))}var vt=U.memo(_t,_);vt.displayName=`Line`;var yt=[`axis`],bt=(0,U.forwardRef)((e,t)=>U.createElement(he,{chartName:`LineChart`,defaultTooltipEventType:`axis`,validateTooltipEventTypes:yt,tooltipPayloadSearcher:pe,categoricalChartProps:e,ref:t})),$=u(),xt=[{value:`7d`,labelKey:`periods.d7`},{value:`30d`,labelKey:`periods.d30`},{value:`90d`,labelKey:`periods.d90`},{value:`all`,labelKey:`periods.all`},{value:`custom`,labelKey:`periods.custom`}];function St({period:e,from:t,to:n,onChange:r}){let{t:i}=o(`analytics`);function a(e){e===`custom`?r(`custom`,t,n):r(e)}function s(e){r(`custom`,e,n)}function c(e){r(`custom`,t,e)}return(0,$.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,$.jsx)(`div`,{className:`flex items-center gap-1`,children:xt.map(t=>(0,$.jsx)(`button`,{onClick:()=>a(t.value),className:l(`h-7 px-3 rounded-md text-xs font-medium transition-colors`,e===t.value?`bg-primary text-primary-foreground`:`text-muted-foreground hover:text-foreground hover:bg-accent`),children:i(t.labelKey)},t.value))}),e===`custom`&&(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(`input`,{type:`date`,value:t,onChange:e=>s(e.target.value),"aria-label":i(`periods.startDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`}),(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:i(`periods.to`)}),(0,$.jsx)(`input`,{type:`date`,value:n,onChange:e=>c(e.target.value),"aria-label":i(`periods.endDate`),className:`h-7 px-2 rounded-md text-xs bg-card border border-border text-foreground focus:outline-none focus:ring-1 focus:ring-primary`})]})]})}function Ct({kpi:e,windowLabel:t}){let{t:n}=o(`analytics`),r=e.estimatedCostUsd??0,i=e.estimatedCostToday??0,a=e.includesEstimated??r>0,s=r>0,c=i>0;return(0,$.jsxs)(`div`,{className:`space-y-2`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:[{key:`totalCost`,label:n(`desktop.totalCost`),value:`${s?`~`:``}$${e.totalCostUsd.toFixed(4)}`,sub:n(`desktop.costToday`,{value:`${c?`~`:``}$${e.costToday.toFixed(4)}`}),estimated:s,window:t},{key:`totalJobs`,label:n(`desktop.totalJobs`),value:e.totalJobs.toLocaleString(),sub:n(`desktop.jobsToday`,{n:e.jobsToday}),estimated:!1},{key:`successRate`,label:n(`desktop.successRate`),value:`${(e.successRate*100).toFixed(1)}%`,sub:n(`desktop.acrossAllProjects`),estimated:!1},{key:`avgCostPerJob`,label:n(`desktop.avgCostPerJob`),value:e.totalJobs>0?`${s?`~`:``}$${(e.totalCostUsd/e.totalJobs).toFixed(5)}`:`—`,sub:n(`desktop.periodAverage`),estimated:s&&e.totalJobs>0}].map(e=>(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,"data-estimated":e.estimated?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between gap-1 mb-1`,children:[(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:e.label}),`window`in e&&e.window&&(0,$.jsx)(`span`,{"data-testid":`kpi-window-label`,className:`text-[10px] text-muted-foreground/70 whitespace-nowrap`,children:e.window})]}),(0,$.jsx)(`p`,{className:`text-xl font-semibold font-mono`,children:e.value}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground mt-1`,children:e.sub})]},e.key))}),a&&(0,$.jsx)(`p`,{"data-testid":`kpi-estimated-footnote`,className:`text-[10px] text-muted-foreground/70 italic`,title:n(`desktop.includesEstimatedTooltip`,{amount:`$${r.toFixed(4)}`}),children:n(`desktop.includesEstimated`,{amount:`$${r.toFixed(4)}`})})]})}function wt({data:e}){let{t}=o(`analytics`),n=s(),r=e.length>0&&e.some(e=>e.costUsd>0),i=Math.max(1,Math.floor(e.length/7)),c=e.filter((e,t)=>t%i===0).map(e=>e.date),l=new Map(e.map(e=>[e.date,e.estimatedCostUsd??0])),u=e.some(e=>(e.estimatedCostUsd??0)>0);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between mb-3`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium`,children:t(`desktop.costOverTime`)}),u&&(0,$.jsx)(`span`,{"data-testid":`timeline-estimated-note`,className:`text-[10px] text-muted-foreground/70 italic`,title:t(`desktop.timelineEstimatedTooltip`),children:t(`desktop.includesEstimatedShort`)})]}),r?(0,$.jsx)(v,{width:`100%`,height:200,children:(0,$.jsxs)(bt,{data:e,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`date`,ticks:c,tickFormatter:e=>{try{return a(new Date(e),`MMM d`,{locale:d()})}catch{return e}},tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>{if(!e||!t?.length)return null;let r=(l.get(n)??0)>0;return(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[r?`~`:``,`$`,t[0].value.toFixed(4)]})]})}}),(0,$.jsx)(vt,{type:`monotone`,dataKey:`costUsd`,stroke:n.chart[0],strokeWidth:2,dot:!1,activeDot:{r:3,fill:n.chart[0]}})]})}):(0,$.jsx)(`div`,{className:`h-[200px] flex items-center justify-center text-xs text-muted-foreground`,children:t(`desktop.noCostData`)})]})}function Tt({projects:e}){let{t}=o(`analytics`),n=s();if(e.length===0)return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:t(`desktop.noProjects`)})]});let r=Math.max(...e.map(e=>e.totalCostUsd),1e-4);return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-4`,children:t(`desktop.projectComparison`)}),(0,$.jsx)(`div`,{className:`space-y-3`,children:e.map((e,i)=>{let a=e.estimatedCostUsd??0,o=a>0;return(0,$.jsxs)(`div`,{className:`space-y-1`,"data-estimated":o?`true`:void 0,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between text-xs`,children:[(0,$.jsxs)(`span`,{className:`font-medium truncate max-w-[160px] flex items-center gap-1`,title:e.projectName,children:[e.projectName,o&&(0,$.jsx)(`span`,{"data-testid":`project-estimated-badge`,className:`text-[9px] uppercase tracking-wide text-muted-foreground/70 not-italic border border-border/40 rounded px-1`,title:t(`desktop.projectEstimatedTooltip`,{amount:`$${a.toFixed(4)}`}),children:t(`desktop.estimatedBadge`)})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-4 text-muted-foreground`,children:[(0,$.jsx)(`span`,{children:t(`desktop.jobsCount`,{count:e.totalJobs})}),(0,$.jsx)(`span`,{children:t(`desktop.successPct`,{pct:(e.successRate*100).toFixed(0)})}),(0,$.jsxs)(`span`,{className:`font-mono text-foreground`,children:[o?`~`:``,`$`,e.totalCostUsd.toFixed(4)]})]})]}),(0,$.jsx)(`div`,{className:`h-1.5 rounded-full bg-border/30 overflow-hidden`,children:(0,$.jsx)(`div`,{className:`h-full rounded-full transition-all duration-500`,style:{width:`${e.totalCostUsd/r*100}%`,backgroundColor:n.chart[i%n.chart.length]}})})]},e.projectId)})})]})}function Et({projects:e}){let{t}=o(`analytics`),n=s();if(e.length===0)return null;let r=e.map(e=>({name:e.projectName.slice(0,12),costUsd:e.totalCostUsd}));return(0,$.jsxs)(`div`,{className:`rounded-lg border border-border/40 bg-card/50 p-4`,children:[(0,$.jsx)(`h3`,{className:`text-sm font-medium mb-3`,children:t(`desktop.costByProject`)}),(0,$.jsx)(v,{width:`100%`,height:180,children:(0,$.jsxs)(ve,{data:r,margin:{top:4,right:8,left:0,bottom:0},children:[(0,$.jsx)(P,{strokeDasharray:`3 3`,stroke:`var(--color-border)`}),(0,$.jsx)(de,{dataKey:`name`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1}),(0,$.jsx)(z,{tickFormatter:e=>`$${e.toFixed(2)}`,tick:{fontSize:10,fill:`var(--color-muted-foreground)`},axisLine:!1,tickLine:!1,width:55}),(0,$.jsx)(x,{content:({active:e,payload:t,label:n})=>e&&t?.length?(0,$.jsxs)(`div`,{className:`bg-popover border border-border/30 rounded-lg p-2 text-xs shadow-lg`,children:[(0,$.jsx)(`p`,{className:`text-muted-foreground mb-1`,children:n}),(0,$.jsxs)(`p`,{className:`font-medium`,children:[`$`,t[0].value.toFixed(4)]})]}):null}),(0,$.jsx)(re,{dataKey:`costUsd`,fill:n.chart[1],radius:[3,3,0,0]})]})})]})}function Dt(){let{t:e}=o(`analytics`),[t,n]=(0,U.useState)(`7d`),[r,a]=(0,U.useState)(``),[s,l]=(0,U.useState)(``),[u,d]=(0,U.useState)(null),[f,p]=(0,U.useState)(!0),[m,h]=(0,U.useState)(null),{registerHandler:g,unregisterHandler:_}=c(),v=(0,U.useCallback)(e=>{let n=e;(n.type===`spending.invalidated`||n.type===`rail.job_completed`)&&y(t,r,s)},[t,r,s]);(0,U.useEffect)(()=>(g(`desktop-analytics`,v),()=>_(`desktop-analytics`)),[v,g,_]);async function y(e,t,n){p(!0),h(null);try{let r=new URLSearchParams({period:e});e===`custom`&&t&&n&&(r.set(`from`,t),r.set(`to`,n));let i=await fetch(`/api/analytics?${r}`);if(!i.ok)throw Error(`HTTP ${i.status}`);d(await i.json())}catch(e){h(e.message)}finally{p(!1)}}(0,U.useEffect)(()=>{y(t,r,s)},[t,r,s]);function b(e,t,r){n(e),t!==void 0&&a(t),r!==void 0&&l(r)}return(0,$.jsx)(`div`,{className:`flex flex-col h-full overflow-auto bg-background`,children:(0,$.jsxs)(`div`,{className:`p-4 space-y-4`,children:[(0,$.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,$.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,$.jsx)(Se,{className:`w-4 h-4 text-muted-foreground`}),(0,$.jsx)(`h1`,{className:`text-sm font-semibold`,children:e(`desktop.title`)}),u&&(0,$.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:u.period.label})]}),(0,$.jsxs)(`div`,{className:`flex items-center gap-3 mr-8`,children:[(0,$.jsx)(St,{period:t,from:r,to:s,onChange:b}),(0,$.jsx)(`button`,{onClick:()=>y(t,r,s),disabled:f,className:`flex items-center gap-1.5 h-7 px-2 rounded-md text-xs text-muted-foreground hover:text-foreground hover:bg-accent transition-colors disabled:opacity-50`,"aria-label":e(`desktop.refreshAria`),children:(0,$.jsx)(i,{className:`w-3 h-3 ${f?`animate-spin`:``}`})})]})]}),m&&(0,$.jsx)(`div`,{className:`rounded-lg border border-red-400/30 aurora-light:border-destructive/30 bg-red-400/10 aurora-light:bg-destructive/10 p-3 text-xs text-red-400 aurora-light:text-destructive`,children:e(`desktop.failedToLoad`,{error:m})}),f&&!u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(`div`,{className:`grid grid-cols-2 lg:grid-cols-4 gap-3`,children:Array.from({length:4}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-20 rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))}),(0,$.jsx)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:Array.from({length:2}).map((e,t)=>(0,$.jsx)(`div`,{className:`h-[220px] rounded-lg border border-border/40 bg-card/50 animate-pulse`},t))})]}),u&&(0,$.jsxs)(`div`,{className:`space-y-3`,children:[(0,$.jsx)(Ct,{kpi:u.kpi,windowLabel:t===`custom`?u.period.label:e(`windowLabels.${t}`)}),(0,$.jsxs)(`div`,{className:`grid grid-cols-1 md:grid-cols-2 gap-3`,children:[(0,$.jsx)(wt,{data:u.costTimeline}),(0,$.jsx)(Et,{projects:u.projectBreakdown})]}),(0,$.jsx)(Tt,{projects:u.projectBreakdown})]})]})})}export{Dt as default};
@@ -1,4 +1,4 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{Bn as t,En as n,G as r,J as i,K as a,M as o,W as s,Y as c,Yn as l,en as u,fn as d,j as f,jn as p,lt as m,nt as h}from"./index-89SuhD4Y.js";import{t as g}from"./lib-yKyTNJ1c.js";import{t as _}from"./atom-one-dark-BMDPFwRZ.js";var v=e(l(),1),y=m();function b({categories:e,activeCategory:n,activeSlug:r,onSelect:i,onHome:a}){let{t:o}=t(`integrations`);return(0,y.jsxs)(`nav`,{className:`w-48 shrink-0 space-y-4 overflow-y-auto border-r border-border pr-2`,children:[(0,y.jsxs)(`button`,{onClick:a,className:h(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!n&&!r?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(p,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:o(`docs.title`)})]}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,y.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,y.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,y.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:o(`docs.sidebarEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(t=>{let a=n===e.slug&&r===t.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>i(e.slug,t.slug),title:t.title,className:h(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,a?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(d,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:t.title})]})},t.slug)})})]},e.slug))]})}function x({categories:e,onSelect:r}){let{t:i}=t(`integrations`),a=e.reduce((e,t)=>e+t.docs.length,0),o=e.filter(e=>e.docs.length>0).length;return(0,y.jsxs)(`div`,{className:`max-w-2xl mx-auto py-2 px-1 space-y-5`,children:[(0,y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:a===0?i(`docs.indexEmpty`):i(`docs.summary`,{documents:i(`docs.documentCount`,{count:a}),categories:i(`docs.categoryCount`,{count:o})})}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:i(`docs.categoryEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(t=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>r(e.slug,t.slug),className:`w-full flex items-center gap-3 p-2.5 rounded-md border border-border text-left transition-colors hover:bg-muted/40 group`,children:[(0,y.jsx)(d,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,y.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t.title}),(0,y.jsx)(n,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))]})}var S=(0,v.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,y.jsx)(o,{remarkPlugins:[f],rehypePlugins:[g],components:{a({href:e,children:r,...i}){return(0,y.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=_(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function C({category:e,slug:n,lang:r,onNotFound:i,onNavigate:a,scrollContainerRef:o}){let{t:s}=t(`integrations`),[c,l]=(0,v.useState)(null),[d,f]=(0,v.useState)(null),p=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let t=++p.current;f(null),fetch(`/api/docs/${e}/${n}?lang=${encodeURIComponent(r)}`).then(async e=>{if(e.status===404){i();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{t===p.current&&e&&(l(e),o.current&&(o.current.scrollTop=0))}).catch(e=>{t===p.current&&f(e instanceof Error?e.message:s(`docs.loadError`))})},[e,n,r,i,o]),!c&&!d?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(u,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):d&&!c?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:d})}):c?(0,y.jsx)(`article`,{className:`max-w-2xl mx-auto py-2 px-1`,children:(0,y.jsx)(`div`,{className:`prose prose-sm max-w-none
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{$ as t,$n as n,An as r,F as i,Fn as a,J as o,P as s,Q as c,Wn as l,X as u,Y as d,gn as f,in as p,ot as m,pt as h}from"./index-DyY1QyIn.js";import{t as g}from"./lib-0PFDyMxJ.js";import{t as _}from"./atom-one-dark-BMDPFwRZ.js";var v=e(n(),1),y=h();function b({categories:e,activeCategory:t,activeSlug:n,onSelect:r,onHome:i}){let{t:o}=l(`integrations`);return(0,y.jsxs)(`nav`,{className:`w-48 shrink-0 space-y-4 overflow-y-auto border-r border-border pr-2`,children:[(0,y.jsxs)(`button`,{onClick:i,className:m(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(a,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:o(`docs.title`)})]}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,y.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,y.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,y.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,y.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:o(`docs.sidebarEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(i=>{let a=t===e.slug&&n===i.slug;return(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>r(e.slug,i.slug),title:i.title,className:m(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,a?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,y.jsx)(f,{className:`w-3.5 h-3.5 shrink-0`}),(0,y.jsx)(`span`,{className:`truncate`,children:i.title})]})},i.slug)})})]},e.slug))]})}function x({categories:e,onSelect:t}){let{t:n}=l(`integrations`),i=e.reduce((e,t)=>e+t.docs.length,0),a=e.filter(e=>e.docs.length>0).length;return(0,y.jsxs)(`div`,{className:`max-w-2xl mx-auto py-2 px-1 space-y-5`,children:[(0,y.jsx)(`p`,{className:`text-[11px] text-muted-foreground`,children:i===0?n(`docs.indexEmpty`):n(`docs.summary`,{documents:n(`docs.documentCount`,{count:i}),categories:n(`docs.categoryCount`,{count:a})})}),e.map(e=>(0,y.jsxs)(`div`,{className:`space-y-2`,children:[(0,y.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,y.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:n(`docs.categoryEmpty`)}):(0,y.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(n=>(0,y.jsx)(`li`,{children:(0,y.jsxs)(`button`,{onClick:()=>t(e.slug,n.slug),className:`w-full flex items-center gap-3 p-2.5 rounded-md border border-border text-left transition-colors hover:bg-muted/40 group`,children:[(0,y.jsx)(f,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,y.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:n.title}),(0,y.jsx)(r,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},n.slug))})]},e.slug))]})}var S=(0,v.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,y.jsx)(i,{remarkPlugins:[s],rehypePlugins:[g],components:{a({href:e,children:r,...i}){return(0,y.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=_(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function C({category:e,slug:t,lang:n,onNotFound:r,onNavigate:i,scrollContainerRef:a}){let{t:o}=l(`integrations`),[s,c]=(0,v.useState)(null),[u,d]=(0,v.useState)(null),f=(0,v.useRef)(0);return(0,v.useEffect)(()=>{let i=++f.current;d(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){r();return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{i===f.current&&e&&(c(e),a.current&&(a.current.scrollTop=0))}).catch(e=>{i===f.current&&d(e instanceof Error?e.message:o(`docs.loadError`))})},[e,t,n,r,a]),!s&&!u?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(p,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):u&&!s?(0,y.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,y.jsx)(`p`,{className:`text-sm text-destructive`,children:u})}):s?(0,y.jsx)(`article`,{className:`max-w-2xl mx-auto py-2 px-1`,children:(0,y.jsx)(`div`,{className:`prose prose-sm max-w-none
2
2
  prose-headings:text-foreground prose-headings:font-bold
3
3
  prose-p:text-foreground/90
4
4
  prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
@@ -8,4 +8,4 @@ import{a as e}from"./chunk-BNv3lrIs.js";import{Bn as t,En as n,G as r,J as i,K a
8
8
  prose-blockquote:border-l-accent-primary prose-blockquote:text-muted-foreground
9
9
  prose-hr:border-border
10
10
  prose-th:text-foreground prose-td:text-foreground/90
11
- prose-li:text-foreground/90`,children:(0,y.jsx)(S,{content:c.content,currentCategory:c.category,onNavigateDoc:a})})}):null}function w({open:e,onClose:n}){let{t:o,i18n:l}=t(`integrations`),d=l.language||`en`,[f,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(!0),[_,S]=(0,v.useState)(),[w,T]=(0,v.useState)(),E=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(g(!0),fetch(`/api/docs?lang=${encodeURIComponent(d)}`).then(e=>e.json()).then(e=>m(e)).catch(()=>m({categories:[]})).finally(()=>g(!1)))},[e,d]);let D=(0,v.useCallback)((e,t)=>{S(e),T(t)},[]),O=(0,v.useCallback)(()=>{S(void 0),T(void 0)},[]),k=!!(_&&w);return(0,y.jsx)(s,{open:e,onOpenChange:e=>{e||n()},children:(0,y.jsxs)(r,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,y.jsxs)(i,{children:[(0,y.jsxs)(c,{className:`flex items-center gap-2`,children:[(0,y.jsx)(p,{className:`w-4 h-4`}),o(`docs.title`)]}),(0,y.jsx)(a,{children:o(`docs.dialogDescription`)})]}),(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[h?(0,y.jsx)(`div`,{className:`w-48 shrink-0 border-r border-border flex items-center justify-center`,children:(0,y.jsx)(u,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,y.jsx)(b,{categories:f?.categories??[],activeCategory:_,activeSlug:w,onSelect:D,onHome:O}),(0,y.jsx)(`main`,{ref:E,className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:k&&_&&w?(0,y.jsx)(C,{category:_,slug:w,lang:d,onNotFound:O,onNavigate:D,scrollContainerRef:E}):f&&(0,y.jsx)(x,{categories:f.categories,onSelect:D})})]})]})})}var T=(0,v.memo)(w);export{T as default};
11
+ prose-li:text-foreground/90`,children:(0,y.jsx)(S,{content:s.content,currentCategory:s.category,onNavigateDoc:i})})}):null}function w({open:e,onClose:n}){let{t:r,i18n:i}=l(`integrations`),s=i.language||`en`,[f,m]=(0,v.useState)(null),[h,g]=(0,v.useState)(!0),[_,S]=(0,v.useState)(),[w,T]=(0,v.useState)(),E=(0,v.useRef)(null);(0,v.useEffect)(()=>{e&&(g(!0),fetch(`/api/docs?lang=${encodeURIComponent(s)}`).then(e=>e.json()).then(e=>m(e)).catch(()=>m({categories:[]})).finally(()=>g(!1)))},[e,s]);let D=(0,v.useCallback)((e,t)=>{S(e),T(t)},[]),O=(0,v.useCallback)(()=>{S(void 0),T(void 0)},[]),k=!!(_&&w);return(0,y.jsx)(o,{open:e,onOpenChange:e=>{e||n()},children:(0,y.jsxs)(d,{movableResizable:!0,className:`flex max-w-5xl w-[92vw] h-[82vh] flex-col overflow-hidden`,children:[(0,y.jsxs)(c,{children:[(0,y.jsxs)(t,{className:`flex items-center gap-2`,children:[(0,y.jsx)(a,{className:`w-4 h-4`}),r(`docs.title`)]}),(0,y.jsx)(u,{children:r(`docs.dialogDescription`)})]}),(0,y.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-5 py-2`,children:[h?(0,y.jsx)(`div`,{className:`w-48 shrink-0 border-r border-border flex items-center justify-center`,children:(0,y.jsx)(p,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,y.jsx)(b,{categories:f?.categories??[],activeCategory:_,activeSlug:w,onSelect:D,onHome:O}),(0,y.jsx)(`main`,{ref:E,className:`min-w-0 flex-1 overflow-y-auto pr-1`,children:k&&_&&w?(0,y.jsx)(C,{category:_,slug:w,lang:s,onNotFound:O,onNavigate:D,scrollContainerRef:E}):f&&(0,y.jsx)(x,{categories:f.categories,onSelect:D})})]})]})})}var T=(0,v.memo)(w);export{T as default};
@@ -0,0 +1,11 @@
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{$n as t,An as n,F as r,Fn as i,P as a,Wn as o,Xn as s,Yn as c,gn as l,in as u,ot as d,pt as f,qn as p}from"./index-DyY1QyIn.js";import{t as m}from"./lib-0PFDyMxJ.js";import{t as h}from"./atom-one-dark-BMDPFwRZ.js";var g=e(t(),1),_=f();function v({categories:e,activeCategory:t,activeSlug:n}){let{t:r}=o(`integrations`);return(0,_.jsxs)(`nav`,{className:`w-56 flex-shrink-0 border-r border-border overflow-y-auto py-4 px-3 space-y-4`,children:[(0,_.jsxs)(p,{to:`/docs`,className:d(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,!t&&!n?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(i,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:r(`docs.title`)})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-0.5`,children:[(0,_.jsxs)(`div`,{className:`px-2.5 mb-1 flex items-center justify-between`,children:[(0,_.jsx)(`span`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length>0&&(0,_.jsx)(`span`,{className:`text-[9px] font-medium text-muted-foreground/60 bg-muted/40 rounded px-1 py-0.5 leading-none`,children:e.docs.length})]}),e.docs.length===0?(0,_.jsx)(`p`,{className:`px-2.5 text-xs text-muted-foreground italic`,children:r(`docs.sidebarEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-0.5`,children:e.docs.map(r=>{let i=t===e.slug&&n===r.slug;return(0,_.jsx)(`li`,{children:(0,_.jsxs)(p,{to:`/docs/${e.slug}/${r.slug}`,title:r.title,className:d(`flex w-full items-center gap-2 rounded-lg px-2.5 py-1.5 text-left text-xs transition-colors`,i?`bg-accent-primary/15 font-medium text-foreground`:`text-muted-foreground hover:bg-muted/40 hover:text-foreground`),children:[(0,_.jsx)(l,{className:`w-3.5 h-3.5 shrink-0`}),(0,_.jsx)(`span`,{className:`truncate`,children:r.title})]})},r.slug)})})]},e.slug))]})}function y({categories:e}){let{t}=o(`integrations`),r=e.reduce((e,t)=>e+t.docs.length,0),a=e.filter(e=>e.docs.length>0).length;return(0,_.jsxs)(`div`,{className:`max-w-2xl mx-auto py-8 px-6 space-y-5`,children:[(0,_.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,_.jsxs)(`h1`,{className:`flex items-center gap-2 text-lg font-semibold`,children:[(0,_.jsx)(i,{className:`w-4 h-4`}),t(`docs.title`)]}),(0,_.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:r===0?t(`docs.indexEmpty`):t(`docs.summary`,{documents:t(`docs.documentCount`,{count:r}),categories:t(`docs.categoryCount`,{count:a})})})]}),e.map(e=>(0,_.jsxs)(`div`,{className:`space-y-2`,children:[(0,_.jsx)(`h2`,{className:`text-xs font-semibold text-muted-foreground uppercase tracking-wider`,children:e.name}),e.docs.length===0?(0,_.jsx)(`p`,{className:`text-xs text-muted-foreground italic pl-2`,children:t(`docs.categoryEmpty`)}):(0,_.jsx)(`ul`,{className:`space-y-2`,children:e.docs.map(t=>(0,_.jsx)(`li`,{children:(0,_.jsxs)(p,{to:`/docs/${e.slug}/${t.slug}`,className:`flex items-center gap-3 p-2.5 rounded-md border border-border transition-colors hover:bg-muted/40 group`,children:[(0,_.jsx)(l,{className:`w-3.5 h-3.5 text-muted-foreground flex-shrink-0`}),(0,_.jsx)(`span`,{className:`text-xs font-medium text-foreground truncate`,children:t.title}),(0,_.jsx)(n,{className:`w-3 h-3 text-muted-foreground ml-auto md:opacity-0 md:group-hover:opacity-100 transition-opacity`})]})},t.slug))})]},e.slug))]})}var b=(0,g.memo)(function({content:e,currentCategory:t,onNavigateDoc:n}){return(0,_.jsx)(r,{remarkPlugins:[a],rehypePlugins:[m],components:{a({href:e,children:r,...i}){return(0,_.jsx)(`a`,{href:e,onClick:r=>{if(!e)return;if(/^[a-z][a-z0-9+.-]*:/i.test(e)){r.preventDefault(),window.open(e,`_blank`,`noopener,noreferrer`);return}if(e.startsWith(`#`))return;r.preventDefault();let i=h(e,t);i&&n(i.category,i.slug)},...i,children:r})}},children:e})});function x({category:e,slug:t,lang:n,scrollContainerRef:r}){let{t:i}=o(`integrations`),[a,s]=(0,g.useState)(null),[l,d]=(0,g.useState)(null),f=(0,g.useRef)(0),p=c();return(0,g.useEffect)(()=>{let a=++f.current;d(null),fetch(`/api/docs/${e}/${t}?lang=${encodeURIComponent(n)}`).then(async e=>{if(e.status===404){p(`/docs`,{replace:!0});return}if(!e.ok)throw Error(`HTTP ${e.status}`);return e.json()}).then(e=>{a===f.current&&e&&(s(e),r.current&&(r.current.scrollTop=0))}).catch(e=>{a===f.current&&d(e instanceof Error?e.message:i(`docs.loadError`))})},[e,t,n,p,r]),!a&&!l?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(u,{className:`w-4 h-4 animate-spin text-muted-foreground`})}):l&&!a?(0,_.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,_.jsx)(`p`,{className:`text-sm text-destructive`,children:l})}):a?(0,_.jsx)(`article`,{className:`max-w-2xl mx-auto py-8 px-6`,children:(0,_.jsx)(`div`,{className:`prose prose-sm max-w-none
2
+ prose-headings:text-foreground prose-headings:font-bold
3
+ prose-p:text-foreground/90
4
+ prose-a:text-accent-primary prose-a:no-underline hover:prose-a:underline
5
+ prose-strong:text-foreground
6
+ prose-code:text-accent-info prose-code:bg-card prose-code:px-1 prose-code:py-0.5 prose-code:rounded prose-code:text-xs
7
+ prose-pre:bg-card prose-pre:border prose-pre:border-border prose-pre:rounded-md prose-pre:p-0 prose-pre:overflow-x-auto
8
+ prose-blockquote:border-l-accent-primary prose-blockquote:text-muted-foreground
9
+ prose-hr:border-border
10
+ prose-th:text-foreground prose-td:text-foreground/90
11
+ prose-li:text-foreground/90`,children:(0,_.jsx)(b,{content:a.content,currentCategory:a.category,onNavigateDoc:(e,t)=>p(`/docs/${e}/${t}`)})})}):null}function S(){let{category:e,slug:t}=s(),{i18n:n}=o(`integrations`),r=n.language||`en`,[i,a]=(0,g.useState)(null),[c,l]=(0,g.useState)(!0),d=(0,g.useRef)(null);(0,g.useEffect)(()=>{fetch(`/api/docs?lang=${encodeURIComponent(r)}`).then(e=>e.json()).then(e=>a(e)).catch(()=>a({categories:[]})).finally(()=>l(!1))},[r]);let f=!!(e&&t);return(0,_.jsxs)(`div`,{className:`flex h-full overflow-hidden`,children:[c?(0,_.jsx)(`div`,{className:`w-56 flex-shrink-0 border-r border-border flex items-center justify-center`,children:(0,_.jsx)(u,{className:`w-3.5 h-3.5 animate-spin text-muted-foreground`})}):(0,_.jsx)(v,{categories:i?.categories??[],activeCategory:e,activeSlug:t}),(0,_.jsx)(`main`,{ref:d,className:`flex-1 overflow-y-auto`,children:f&&e&&t?(0,_.jsx)(x,{category:e,slug:t,lang:r,scrollContainerRef:d}):i&&(0,_.jsx)(y,{categories:i.categories})})]})}export{S as default};
@@ -1 +1 @@
1
- import{a as e}from"./chunk-BNv3lrIs.js";import{Bn as t,Yn as n,_n as r,lt as i,zn as a}from"./index-89SuhD4Y.js";var o=e(n(),1),s=i(),c=[{labelKey:`export.summaryCsv`,format:`csv`,mode:`summary`},{labelKey:`export.rawCsv`,format:`csv`,mode:`raw`},{labelKey:`export.summaryJson`,format:`json`,mode:`summary`},{labelKey:`export.rawJson`,format:`json`,mode:`raw`}];function l(e){if(!e)return null;let t=e.match(/filename="?([^"]+)"?/);return t?t[1]:null}function u({baseUrl:e,params:n,label:i,disabled:u}){let{t:d}=t(`analytics`),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!f)return;function e(e){g.current&&!g.current.contains(e.target)&&p(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]);let _=(0,o.useCallback)(t=>`${e}?${new URLSearchParams({format:t.format,mode:t.mode,...n}).toString()}`,[e,n]),v=(0,o.useCallback)(async e=>{p(!1),h(!0);try{let t=await fetch(_(e));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r;let a=l(t.headers.get(`Content-Disposition`)),o=`analytics-${e.mode}.${e.format}`;i.download=a??o,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] download failed:`,e),a.error(d(`export.failed`))}finally{h(!1)}},[_,d]);return(0,s.jsxs)(`div`,{ref:g,className:`relative`,children:[(0,s.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":f,disabled:m||u,onClick:()=>p(e=>!e),title:u?d(`export.noData`):void 0,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,s.jsx)(r,{className:`w-3 h-3`}),m?d(`export.downloading`):i??d(`common:actions.export`)]}),f&&(0,s.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[180px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:c.map(e=>(0,s.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>v(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,s.jsx)(r,{className:`w-3 h-3 shrink-0`}),(0,s.jsx)(`span`,{className:`flex-1`,children:d(e.labelKey)}),e.mode===`raw`&&(0,s.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:`≤10k`})]},`${e.format}-${e.mode}`))})]})}export{u as t};
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{$n as t,Un as n,Wn as r,pt as i,xn as a}from"./index-DyY1QyIn.js";var o=e(t(),1),s=i(),c=[{labelKey:`export.summaryCsv`,format:`csv`,mode:`summary`},{labelKey:`export.rawCsv`,format:`csv`,mode:`raw`},{labelKey:`export.summaryJson`,format:`json`,mode:`summary`},{labelKey:`export.rawJson`,format:`json`,mode:`raw`}];function l(e){if(!e)return null;let t=e.match(/filename="?([^"]+)"?/);return t?t[1]:null}function u({baseUrl:e,params:t,label:i,disabled:u}){let{t:d}=r(`analytics`),[f,p]=(0,o.useState)(!1),[m,h]=(0,o.useState)(!1),g=(0,o.useRef)(null);(0,o.useEffect)(()=>{if(!f)return;function e(e){g.current&&!g.current.contains(e.target)&&p(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[f]);let _=(0,o.useCallback)(n=>`${e}?${new URLSearchParams({format:n.format,mode:n.mode,...t}).toString()}`,[e,t]),v=(0,o.useCallback)(async e=>{p(!1),h(!0);try{let t=await fetch(_(e));if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.blob(),r=URL.createObjectURL(n),i=document.createElement(`a`);i.href=r;let a=l(t.headers.get(`Content-Disposition`)),o=`analytics-${e.mode}.${e.format}`;i.download=a??o,document.body.appendChild(i),i.click(),i.remove(),URL.revokeObjectURL(r)}catch(e){console.warn(`[ExportDropdown] download failed:`,e),n.error(d(`export.failed`))}finally{h(!1)}},[_,d]);return(0,s.jsxs)(`div`,{ref:g,className:`relative`,children:[(0,s.jsxs)(`button`,{type:`button`,"aria-haspopup":`true`,"aria-expanded":f,disabled:m||u,onClick:()=>p(e=>!e),title:u?d(`export.noData`):void 0,className:`flex items-center gap-1.5 h-7 px-2.5 rounded-md text-xs font-medium border border-border/60 bg-card/50 text-muted-foreground hover:text-foreground hover:bg-accent/60 transition-colors disabled:opacity-50 disabled:pointer-events-none`,children:[(0,s.jsx)(a,{className:`w-3 h-3`}),m?d(`export.downloading`):i??d(`common:actions.export`)]}),f&&(0,s.jsx)(`div`,{role:`menu`,className:`absolute right-0 z-50 mt-1 min-w-[180px] rounded-md border border-border/60 bg-popover shadow-md text-xs overflow-hidden`,children:c.map(e=>(0,s.jsxs)(`button`,{role:`menuitem`,type:`button`,onClick:()=>v(e),className:`flex w-full items-center gap-2 px-3 py-2 text-left text-foreground hover:bg-accent/60 transition-colors`,children:[(0,s.jsx)(a,{className:`w-3 h-3 shrink-0`}),(0,s.jsx)(`span`,{className:`flex-1`,children:d(e.labelKey)}),e.mode===`raw`&&(0,s.jsx)(`span`,{className:`text-[9px] text-muted-foreground`,children:`≤10k`})]},`${e.format}-${e.mode}`))})]})}export{u as t};
@@ -0,0 +1 @@
1
+ import{Jn as e,pt as t}from"./index-DyY1QyIn.js";var n=t();function r(){return(0,n.jsx)(e,{to:`/plugins`,replace:!0})}export{r as default};
@@ -0,0 +1,19 @@
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{t}from"./brain-C92rjjYP.js";import{a as n}from"./auth-DpZq5p1e.js";import{$n as r,An as i,D as a,Dn as o,En as s,F as c,Ft as l,Gt as u,Hn as d,Ht as f,K as p,Mn as m,Nt as h,Ot as g,P as _,Rn as v,Sn as y,Tn as b,U as x,Un as S,Ut as C,W as w,Wn as T,Zt as E,a as D,at as O,c as k,ct as A,dn as j,dt as M,ft as N,in as P,jn as ee,mn as te,mt as ne,o as F,on as I,ot as L,pt as re,qt as ie,s as R,y as ae}from"./index-DyY1QyIn.js";import{t as oe}from"./lib-0PFDyMxJ.js";var se=d(`chevrons-down-up`,[[`path`,{d:`m7 20 5-5 5 5`,key:`13a0gw`}],[`path`,{d:`m7 4 5 5 5-5`,key:`1kwcof`}]]),ce=d(`chevrons-up-down`,[[`path`,{d:`m7 15 5 5 5-5`,key:`1hf1tw`}],[`path`,{d:`m7 9 5-5 5 5`,key:`sgt6xg`}]]),le=d(`hourglass`,[[`path`,{d:`M5 22h14`,key:`ehvnwv`}],[`path`,{d:`M5 2h14`,key:`pdyrp9`}],[`path`,{d:`M17 22v-4.172a2 2 0 0 0-.586-1.414L12 12l-4.414 4.414A2 2 0 0 0 7 17.828V22`,key:`1d314k`}],[`path`,{d:`M7 2v4.172a2 2 0 0 0 .586 1.414L12 12l4.414-4.414A2 2 0 0 0 17 6.172V2`,key:`1vvvr6`}]]),z=re();function ue({phases:e,phaseDefinitions:t}){return t.length===0?null:(0,z.jsx)(`div`,{className:`flex items-center`,children:t.map((n,r)=>{let i=e[n.key]??`idle`,a=r<t.length-1?e[t[r+1].key]??`idle`:null;return(0,z.jsxs)(`div`,{className:`flex items-center`,children:[(0,z.jsxs)(x,{children:[(0,z.jsx)(p,{asChild:!0,children:(0,z.jsxs)(`div`,{className:`flex flex-col items-center gap-1.5 cursor-default px-4`,children:[(0,z.jsx)(B,{state:i}),(0,z.jsx)(`span`,{className:L(`text-xs font-medium transition-colors`,i===`running`?`text-blue-400 aurora-light:text-accent-info`:i===`done`?`text-emerald-400 aurora-light:text-accent-success`:i===`error`?`text-red-400 aurora-light:text-destructive`:`text-muted-foreground/40`),children:n.label})]})}),(0,z.jsxs)(w,{side:`bottom`,className:`max-w-[200px]`,children:[(0,z.jsx)(`p`,{className:`font-medium`,children:n.label}),(0,z.jsx)(`p`,{className:`text-muted-foreground mt-0.5`,children:n.description})]})]}),a!==null&&(0,z.jsx)(`div`,{className:L(`h-px w-12 -mt-5 shrink-0 transition-all duration-300`,a===`done`||i===`done`?`bg-emerald-500/30 aurora-light:bg-accent-success/40`:a===`running`?`bg-blue-400/40 aurora-light:bg-accent-info/40`:`bg-border/30`)})]},n.key)})})}function B({state:e}){return(0,z.jsxs)(`div`,{className:L(`flex items-center justify-center w-10 h-10 rounded-full transition-all duration-300`,e===`running`?`bg-blue-500/10 aurora-light:bg-accent-info/10 ring-1 ring-blue-400/30 aurora-light:ring-accent-info/30 animate-pulse`:e===`done`?`bg-emerald-500/10 aurora-light:bg-accent-success/10`:e===`error`?`bg-red-500/10 aurora-light:bg-destructive/10`:`bg-muted/20`),children:[e===`running`&&(0,z.jsx)(P,{className:`w-6 h-6 text-blue-400 aurora-light:text-accent-info animate-spin`}),e===`done`&&(0,z.jsx)(o,{className:`w-6 h-6 text-emerald-400 aurora-light:text-accent-success`}),e===`error`&&(0,z.jsx)(s,{className:`w-6 h-6 text-red-400 aurora-light:text-destructive`}),e===`idle`&&(0,z.jsx)(b,{className:`w-6 h-6 text-muted-foreground/20`})]})}var V=e(r(),1);function de(e){let t=e.trimStart();return!!(/^#{1,6}\s/.test(t)||/^[-*+]\s/.test(t)||/^\d+\.\s/.test(t)||/^\|.+\|/.test(t)||t.startsWith("```")||t.startsWith(`> `)||/\*\*[^*]+\*\*/.test(e)||/`[^`]+`/.test(e)||/\[.+\]\(.+\)/.test(e)||/^(-{3,}|_{3,}|\*{3,})$/.test(t)||/^- \[[ x]\]\s/.test(t))}var H=new Set;function U({ticketId:e,onOpen:t,children:n}){let{t:r}=T(`agent`),i=r(`refs.openTicket`,{id:e});return(0,z.jsx)(`button`,{type:`button`,"data-testid":`log-ticket-ref`,onClick:n=>{n.stopPropagation(),t(e)},title:i,"aria-label":i,className:`inline cursor-pointer p-0 align-baseline text-accent-primary/90 underline decoration-accent-primary/50 decoration-dotted underline-offset-2 transition-colors hover:text-accent-primary hover:decoration-solid`,children:n})}function fe(e){if(!e.includes(`#`))return null;let t=R(e,H);return t.some(e=>e.kind===`ticket`)?t:null}function pe(e,t){let n=fe(e);return n?n.map((e,n)=>e.kind===`ticket`?(0,z.jsx)(U,{ticketId:e.ticketId,onOpen:t,children:e.label},n):(0,z.jsx)(V.Fragment,{children:e.kind===`text`?e.text:e.label},n)):e}var me=new Set([`code`,`inlineCode`,`link`,`linkReference`,`image`,`imageReference`,`definition`,`html`]);function he(e){return e.kind===`ticket`?{type:`link`,url:D({kind:`ticket`,ticketId:e.ticketId}),children:[{type:`text`,value:e.label}]}:{type:`text`,value:e.kind===`text`?e.text:e.label}}function W(e){let t=e.children;if(t)for(let e=t.length-1;e>=0;e--){let n=t[e];if(!me.has(n.type))if(n.type===`text`&&typeof n.value==`string`){let r=R(n.value,H);r.some(e=>e.kind===`ticket`)&&t.splice(e,1,...r.map(he))}else W(n)}}function ge(){return e=>W(e)}function G(e){let{activeProjectId:t}=A(),{openRef:n}=k(),r=e??t??void 0;return(0,V.useMemo)(()=>r?e=>{n(r,{kind:`ticket`,ticketId:e})}:void 0,[r,n])}function _e(e,t){let n=`${e.id??t}`,r=e.timestamp;if(e.event_type===`log`)try{let t=JSON.parse(e.payload).line??``;return t.trim()?t.startsWith(`▸`)||t.match(/^(architect|developer|reviewer|ship|analyst)\s*:/i)?{id:n,content:t,type:`phase`,timestamp:r}:e.source===`stderr`?{id:n,content:t,type:`stderr`,timestamp:r}:de(t)?{id:n,content:t,type:`assistant`,timestamp:r}:{id:n,content:t,type:`plain`,timestamp:r}:null}catch{return null}if(e.event_type!==`log`&&e.event_type!==`result`)return null;if(e.event_type===`result`)try{let t=JSON.parse(e.payload),i=[];return t.duration_ms&&i.push(`${(t.duration_ms/1e3).toFixed(1)}s`),t.total_cost_usd&&i.push(`$${t.total_cost_usd.toFixed(4)}`),t.num_turns&&i.push(M.t(`jobs:logViewer.turns`,{count:t.num_turns})),{id:n,content:`▸ ${M.t(`jobs:logViewer.completed`)}${i.length?` — ${i.join(` · `)}`:``}`,type:`result`,timestamp:r}}catch{return null}return null}function ve(e){let t=`none`,n=[];for(let r of e){let e=r.type;if(e!==`plain`&&e!==`log`){t=`none`,n.push(r);continue}let i=r.content;i.startsWith(`--- `)?(t=`saw_minus`,n.push({...r,type:`diff-meta`})):t===`saw_minus`&&i.startsWith(`+++ `)?(t=`active`,n.push({...r,type:`diff-meta`})):t===`active`&&i.startsWith(`@@ `)?n.push({...r,type:`diff-hunk`}):t===`active`&&i.startsWith(`+`)&&!i.startsWith(`+++`)?n.push({...r,type:`diff-add`}):t===`active`&&i.startsWith(`-`)&&!i.startsWith(`---`)?n.push({...r,type:`diff-remove`}):(t===`active`&&(i.startsWith(` `)||i===``)||(t=`none`),n.push(r))}return n}function ye(e){let t=[];for(let n of e){let e=t.length>0?t[t.length-1]:null;n.type===`assistant`&&e?.type===`assistant`?e.content+=`
2
+ `+n.content:t.push({...n})}return t}function be(e){let t=[{key:`__preamble__`,header:null,lines:[]}];for(let n of e)n.type===`phase`?t.push({key:n.id,header:n,lines:[]}):t[t.length-1].lines.push(n);return t.filter(e=>e.header!==null||e.lines.length>0)}function xe({events:e,isLoading:t,projectId:n}){let{t:r,i18n:i}=T(`jobs`),[a,o]=(0,V.useState)(``),[s,c]=(0,V.useState)(!0),[l,u]=(0,V.useState)(new Set),d=(0,V.useRef)(null),f=(0,V.useRef)(null),p=G(n),{processedLines:m,groups:h,totalLines:g}=(0,V.useMemo)(()=>{let t=ve(ye(e.map((e,t)=>_e(e,t)).filter(e=>e!==null)));return{processedLines:t,groups:be(t),totalLines:t.length}},[e,i.language]),_=(0,V.useMemo)(()=>{if(!a)return g;let e=a.toLowerCase();return m.filter(t=>t.content.toLowerCase().includes(e)).length},[a,m,g]),v=(0,V.useCallback)(()=>{let e=f.current;e&&(e.scrollTop=e.scrollHeight)},[]);(0,V.useEffect)(()=>{s&&v()},[e.length,s,v]);function b(){let e=f.current;e&&c(e.scrollHeight-e.scrollTop-e.clientHeight<50)}function x(e){u(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})}return t?(0,z.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.loading`)})}):g===0?(0,z.jsx)(`div`,{className:`flex-1 flex items-center justify-center`,children:(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:r(`logViewer.empty`)})}):(0,z.jsxs)(`div`,{className:`flex flex-col h-full`,children:[(0,z.jsxs)(`div`,{className:`px-4 py-2 border-b border-border flex items-center gap-2`,children:[(0,z.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,z.jsx)(C,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,z.jsx)(ae,{placeholder:r(`logViewer.filterPlaceholder`),value:a,onChange:e=>o(e.target.value),className:`pl-7 h-7`})]}),(0,z.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:()=>{let e=m.map(e=>e.content).join(`
3
+ `);navigator.clipboard.writeText(e).then(()=>{S.success(r(`logViewer.copySuccess`))}).catch(()=>{S.error(r(`logViewer.copyFailed`))})},children:(0,z.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:r(`logViewer.lineCount`,{filtered:_,total:g})})]}),(0,z.jsxs)(`div`,{ref:f,className:`flex-1 overflow-y-auto p-2 text-xs relative`,onScroll:b,children:[h.map(e=>(0,z.jsx)(Se,{group:e,filter:a,collapsed:l.has(e.key),onToggle:()=>x(e.key),onOpenTicket:p},e.key)),(0,z.jsx)(`div`,{ref:d})]}),!s&&(0,z.jsxs)(O,{size:`sm`,variant:`secondary`,onClick:()=>{c(!0),v()},className:`absolute bottom-16 right-6 h-7 gap-1 shadow-lg`,children:[(0,z.jsx)(ee,{className:`w-3 h-3`}),r(`logViewer.jumpToBottom`)]})]})}var Se=(0,V.memo)(function({group:e,filter:t,collapsed:n,onToggle:r,onOpenTicket:a}){let{t:o}=T(`jobs`),s=t?e.lines.filter(e=>e.content.toLowerCase().includes(t.toLowerCase())):e.lines;if(e.header===null)return s.length===0?null:(0,z.jsx)(`div`,{children:s.map((e,t)=>(0,z.jsx)(K,{line:e,even:t%2==0,onOpenTicket:a},e.id))});let c=e.header.content;return(0,z.jsxs)(`div`,{className:`mt-3 rounded-md overflow-hidden border border-border/20`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:r,className:L(`flex items-center gap-2 w-full text-left px-3 py-2`,`bg-primary/5 border-b border-primary/20`,`hover:bg-primary/10 transition-colors duration-150 cursor-pointer`),children:[(0,z.jsx)(i,{className:L(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,z.jsx)(`span`,{className:`flex-1 text-[12px] font-semibold text-foreground leading-none`,children:c}),e.header.timestamp&&(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 font-mono tabular-nums shrink-0`,children:new Date(e.header.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:o(`logViewer.phaseLines`,{count:e.lines.length})})]}),!n&&(0,z.jsx)(`div`,{className:`bg-muted/5`,children:s.length===0?(0,z.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:o(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):s.map((e,t)=>(0,z.jsx)(K,{line:e,even:t%2==0,onOpenTicket:a},e.id))})]})}),Ce=[oe],we=[_],Te=[_,ge],K=(0,V.memo)(function({line:e,even:t,onOpenTicket:n}){let r=e.type===`assistant`,i=e.type===`diff-add`,a=e.type===`diff-remove`,o=e.type===`diff-meta`,s=e.type===`diff-hunk`,l=i||a||o||s,u=n!=null&&(e.type===`plain`||e.type===`log`),d=(0,V.useMemo)(()=>u&&n?pe(e.content,n):e.content,[u,n,e.content]),f=r&&n?Te:we,p=(0,V.useMemo)(()=>n?{a:({href:e,children:t})=>{let r=F(e);return r?.kind===`ticket`?(0,z.jsx)(U,{ticketId:r.ticketId,onOpen:n,children:t}):(0,z.jsx)(`a`,{href:e,children:t})}}:void 0,[n]);return(0,z.jsxs)(`div`,{className:L(`flex items-start gap-2 group px-2 py-0.5 rounded-sm`,!l&&(t?`bg-muted/20`:`bg-transparent`),e.type===`result`&&`bg-emerald-500/5 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/40 aurora-light:border-accent-success/40 mt-2 py-2`,i&&`bg-emerald-500/8 aurora-light:bg-accent-success/10 border-l-2 border-emerald-500/50 aurora-light:border-accent-success/50`,a&&`bg-red-500/8 aurora-light:bg-destructive/10 border-l-2 border-red-500/50 aurora-light:border-destructive/50`,o&&`bg-accent-primary/5 border-l-2 border-accent-primary/30`,s&&`bg-accent-info/5 border-l-2 border-accent-info/30`),children:[e.timestamp&&(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0 mt-0.5 w-[52px] font-mono tabular-nums`,children:new Date(e.timestamp).toLocaleTimeString(`en`,{hour:`2-digit`,minute:`2-digit`,second:`2-digit`,hour12:!1})}),r?(0,z.jsx)(`div`,{className:`flex-1 min-w-0 prose prose-invert prose-xs max-w-none
4
+ prose-p:my-1 prose-p:leading-relaxed
5
+ prose-headings:mt-2 prose-headings:mb-1 prose-headings:text-sm prose-headings:font-semibold
6
+ prose-ul:my-1 prose-ol:my-1 prose-li:my-0
7
+ prose-code:text-cyan-300 prose-code:text-[11px] prose-code:bg-muted/40 prose-code:px-1 prose-code:py-0.5 prose-code:rounded
8
+ prose-pre:my-1 prose-pre:bg-muted/30 prose-pre:rounded-md prose-pre:p-2 prose-pre:text-[11px]
9
+ prose-strong:text-foreground prose-em:text-foreground/70
10
+ prose-a:text-blue-400 prose-a:no-underline hover:prose-a:underline
11
+ prose-table:my-2 prose-table:text-[11px]
12
+ prose-thead:border-border prose-thead:bg-muted/30
13
+ prose-th:px-3 prose-th:py-1.5 prose-th:text-left prose-th:font-semibold prose-th:text-foreground/90
14
+ prose-td:px-3 prose-td:py-1.5 prose-td:border-border
15
+ prose-tr:border-border
16
+ text-foreground/80`,children:(0,z.jsx)(c,{remarkPlugins:f,rehypePlugins:Ce,components:p,children:e.content})}):(0,z.jsx)(`span`,{className:L(`flex-1 break-all leading-relaxed whitespace-pre-wrap font-mono`,e.type===`tool-use`&&`text-cyan-400/80 aurora-light:text-accent-info text-[11px]`,e.type===`stderr`&&`text-orange-400 aurora-light:text-accent-warning`,e.type===`result`&&`text-emerald-400 aurora-light:text-accent-success font-medium`,e.type===`log`&&`text-foreground/60`,e.type===`plain`&&`text-foreground/70`,e.type===`tool-result`&&`text-muted-foreground/50`,i&&`text-emerald-400 aurora-light:text-accent-success`,a&&`text-red-400 aurora-light:text-destructive`,o&&`text-accent-primary/80`,s&&`text-accent-info/80`),children:d})]})});function q(e){try{let t=JSON.parse(e);if(t&&typeof t==`object`&&!Array.isArray(t))return t}catch{}return null}var Ee=/^\s*━+\s*Step\s+\d+\s*·/,De=/\s*\(iteration\s+\d+\)\s*$/i;function J(e){return e.replace(/^[\s\uFE0F\p{Extended_Pictographic}]+/u,``).trim()||e.trim()}function Y(e){let t=J(e.title);return e.iteration==null?t:t.replace(De,``)}function Oe(e){return e.meta.nodeId??`${e.meta.kind}::${J(e.meta.title).replace(De,``)}`}function ke(e){let t=null,n=0,r=[[]],i=[];for(let o=0;o<e.length;o++){let s=e[o];if(s.event_type===`loop_graph`){let e=q(s.payload);e&&e.graph&&typeof e.graph==`object`&&!Array.isArray(e.graph)&&(t={graph:e.graph,loopId:typeof e.loopId==`string`?e.loopId:void 0,loopName:typeof e.loopName==`string`?e.loopName:void 0,provider:typeof e.provider==`string`?e.provider:void 0,model:typeof e.model==`string`?e.model:void 0,iterationLimit:typeof e.iterationLimit==`number`?e.iterationLimit:void 0});continue}if(s.event_type===`loop_step`){let e=q(s.payload);if(!e||typeof e.index!=`number`)continue;let t=typeof e.iteration==`number`?e.iteration:null;t!=null&&t>n&&(n=t),i.push({meta:{index:e.index,kind:typeof e.kind==`string`?e.kind:`ai-step`,title:typeof e.title==`string`?e.title:``,nodeId:typeof e.nodeId==`string`?e.nodeId:null,iteration:t,template:typeof e.template==`string`&&e.template?e.template:void 0,command:typeof e.command==`string`&&e.command?e.command:void 0},end:null,lastActivity:null}),r.push([]);continue}if(s.event_type===`loop_step_end`){let e=q(s.payload);if(!e||typeof e.index!=`number`)continue;for(let t=i.length-1;t>=0;t--)if(i[t].meta.index===e.index){i[t].end={index:e.index,nodeId:typeof e.nodeId==`string`?e.nodeId:null,status:e.status===`failed`?`failed`:`ok`,exitCode:typeof e.exitCode==`number`?e.exitCode:null,durationMs:typeof e.durationMs==`number`?e.durationMs:null,decision:e.decision===`continue`||e.decision===`stop`?e.decision:void 0};break}continue}let c=i.length>0,l=_e(s,o);if(l&&!(c&&Ee.test(l.content))&&r[r.length-1].push(l),c){let e=a(s);e.step&&e.actionKey&&(i[i.length-1].lastActivity={actionKey:e.actionKey,actionArg:e.actionArg})}}let o=e=>ve(ye(e)),s=o(r[0]),c=i.map((e,t)=>({key:`step-${t}-${e.meta.index}`,meta:e.meta,lines:o(r[t+1]),end:e.end,lastActivity:e.lastActivity})),l=s.length+c.reduce((e,t)=>e+t.lines.length,0);return{graphMeta:t,setup:s,segments:c,maxIteration:n,totalLines:l}}function Ae(e,t){return e.end?e.end.status:t.isLast?t.jobSettled?`interrupted`:`running`:`unknown`}function je(e){return e===`continue`?0:e===`stop`?2:1}function Me(e){let t=new Map(e.nodes.map(e=>[e.id,e])),n=new Set,r=[],i=a=>{if(n.has(a))return;let o=t.get(a);if(!o)return;n.add(a),r.push(o);let s=e.edges.filter(e=>e.source===a).slice().sort((e,t)=>je(e.branch)-je(t.branch));for(let e of s)i(e.target)},a=e.nodes.find(e=>e.type===`start`);a&&i(a.id);for(let t of e.nodes)i(t.id);return r}function X(e){let t=e.data?.label;return typeof t==`string`&&t.trim()?t.trim():null}function Ne(e,t){let n=e.segments.length-1,r=new Map,i=new Map;e.segments.forEach((e,t)=>{let n=Oe(e);r.set(n,{seg:e,idx:t}),e.meta.kind===`decider`&&e.end?.decision&&i.set(n,e.end.decision)});let a=e=>{let r=Ae(e.seg,{isLast:e.idx===n,jobSettled:t.jobSettled});return r===`unknown`?`ok`:r};if(e.graphMeta)return Me(e.graphMeta.graph).map(e=>{if(e.type===`start`)return{key:e.id,kind:`start`,label:X(e),state:`ok`,latestSegmentKey:null};if(e.type===`end`)return{key:e.id,kind:`end`,label:X(e),state:t.jobSettled?t.jobFailed?`failed`:`ok`:`pending`,latestSegmentKey:null};let n=r.get(e.id);return n?{key:e.id,kind:e.type,label:X(e)??Y(n.seg.meta),state:a(n),decision:e.type===`decider`?i.get(e.id):void 0,latestSegmentKey:n.seg.key}:{key:e.id,kind:e.type,label:X(e),state:`pending`,latestSegmentKey:null}});let o=[],s=new Map;return e.segments.forEach((e,t)=>{let n=Oe(e),r={seg:e,idx:t},c=s.get(n),l=e.meta.kind===`decider`?i.get(n):void 0;if(c!=null){let t=o[c];t.state=a(r),t.decision=l,t.latestSegmentKey=e.key}else s.set(n,o.length),o.push({key:n,kind:e.meta.kind,label:Y(e.meta)||null,state:a(r),decision:l,latestSegmentKey:e.key})}),o}function Pe(e){if(!Number.isFinite(e)||e<0)return`—`;if(e<1e3)return`${Math.round(e)}ms`;let t=e/1e3;if(t<60)return`${t.toFixed(1)}s`;let n=Math.floor(t/60),r=Math.round(t%60);return n<60?`${n}m ${r}s`:`${Math.floor(n/60)}h ${n%60}m`}var Fe={start:E,"ai-step":t,shell:h,decider:j,condition:j,end:te},Ie=l,Le={start:`text-accent-success`,"ai-step":`text-accent-primary`,shell:`text-accent-warning`,decider:`text-accent-highlight`,condition:`text-accent-info`,end:`text-accent-secondary`},Re={start:`border-accent-success/60`,"ai-step":`border-accent-primary/60`,shell:`border-accent-warning/60`,decider:`border-accent-highlight/60`,condition:`border-accent-info/60`,end:`border-accent-secondary/60`};function Z(e){return Fe[e]??Ie}function ze({chips:e,iteration:t,onChipClick:n,variant:r}){let{t:a}=T(`jobs`);return e.length===0&&!t?null:(0,z.jsxs)(`div`,{"data-testid":`loop-overview-strip`,role:`list`,"aria-label":a(`loopExplorer.stepMapAria`),className:L(`flex items-center gap-1 overflow-x-auto border-b border-border/30 bg-surface/20`,r===`glass`?`px-3 py-1.5`:`px-4 py-2`),children:[e.map((e,t)=>{let r=Z(e.kind),o=Le[e.kind]??`text-foreground`,s=Re[e.kind]??`border-border/40`,c=e.label??a(`loops:builder.nodes.${e.kind}`,{defaultValue:e.kind}),l=e.latestSegmentKey!=null;return(0,z.jsxs)(V.Fragment,{children:[t>0&&(0,z.jsx)(i,{className:`w-3 h-3 text-muted-foreground/30 shrink-0`}),(0,z.jsxs)(`button`,{type:`button`,role:`listitem`,"data-testid":`loop-node-chip`,"data-state":e.state,"data-kind":e.kind,"data-decision":e.decision,"aria-label":`${c} — ${e.state}`,disabled:!l,onClick:()=>e.latestSegmentKey&&n(e.latestSegmentKey),className:L(`relative flex items-center gap-1.5 shrink-0 rounded-full border bg-surface/40 px-2.5 py-1 text-[11px] transition-colors`,s,e.state===`pending`&&`opacity-45 border-border/40`,e.state===`interrupted`&&`border-dashed border-accent-warning/50`,l?`cursor-pointer hover:bg-surface/70`:`cursor-default`),children:[e.state===`running`&&(0,z.jsx)(`span`,{"aria-hidden":!0,className:`absolute -inset-px rounded-full ring-2 ring-accent-primary/50 motion-safe:animate-pulse pointer-events-none`}),(0,z.jsx)(r,{className:L(`w-3 h-3 shrink-0`,o)}),(0,z.jsx)(`span`,{className:L(`max-w-[120px] truncate font-medium text-foreground/90`,e.state===`running`&&`title-shimmer`),children:c}),e.state===`ok`&&(0,z.jsx)(m,{className:`w-3 h-3 text-accent-success shrink-0`}),e.state===`failed`&&(0,z.jsx)(g,{className:`w-3 h-3 text-destructive shrink-0`}),e.decision===`continue`&&(0,z.jsx)(u,{className:`w-3 h-3 text-accent-highlight shrink-0`}),e.decision===`stop`&&(0,z.jsx)(v,{className:`w-3 h-3 text-accent-success shrink-0`})]})]},e.key)}),t&&(0,z.jsxs)(`span`,{"data-testid":`loop-iteration-chip`,className:`ml-auto flex items-center gap-1.5 shrink-0 rounded-full border border-accent-highlight/40 bg-accent-highlight/10 px-2.5 py-1 text-[10px] font-medium text-accent-highlight tabular-nums`,children:[(0,z.jsx)(ie,{className:`w-3 h-3`}),t.limit==null?a(`loopExplorer.iterationBadge`,{count:t.current}):a(`loopExplorer.iteration`,{current:t.current,limit:t.limit})]})]})}var Be=(0,V.memo)(ze);function Ve({className:e}){return(0,z.jsxs)(`span`,{className:L(`relative flex h-2 w-2 shrink-0`,e),children:[(0,z.jsx)(`span`,{className:`motion-safe:animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60`}),(0,z.jsx)(`span`,{className:`relative inline-flex rounded-full h-2 w-2 bg-accent-primary`})]})}function He(e,t){if(!t)return e;let n=t.toLowerCase();return e.filter(e=>e.content.toLowerCase().includes(n))}function Ue(e,t,n,r){return e.length===0?(0,z.jsx)(`p`,{className:`px-4 py-2 text-[10px] text-muted-foreground/40 italic`,children:n(t?`logViewer.noMatchingLines`:`logViewer.noOutput`)}):e.map((e,t)=>(0,z.jsx)(K,{line:e,even:t%2==0,onOpenTicket:r},e.id))}function We({label:e,value:t,copyLabel:n}){let[r,i]=(0,V.useState)(!1),a=async()=>{try{await navigator.clipboard.writeText(t),i(!0),window.setTimeout(()=>i(!1),1500)}catch{}};return(0,z.jsxs)(`div`,{className:`min-w-0`,children:[(0,z.jsxs)(`div`,{className:`flex items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`text-[9px] font-semibold uppercase tracking-wider text-muted-foreground/50`,children:e}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>void a(),"aria-label":`${n} — ${e}`,title:n,className:`p-0.5 text-muted-foreground/40 hover:text-foreground transition-colors cursor-pointer`,children:r?(0,z.jsx)(m,{className:`w-2.5 h-2.5 text-accent-success`}):(0,z.jsx)(y,{className:`w-2.5 h-2.5`})})]}),(0,z.jsx)(`pre`,{className:`mt-0.5 text-[10px] font-mono leading-relaxed text-foreground/75 whitespace-pre-wrap break-words`,children:t})]})}function Ge({segment:e,status:t,collapsed:n,filter:r,onToggle:a,onCopy:o,setRef:s,onOpenTicket:c}){let{t:l}=T(`jobs`),{meta:u,lines:d,end:f,lastActivity:p}=e,h=Z(u.kind),_=Le[u.kind]??`text-foreground`,v=He(d,r),b=t===`running`,x=!!(u.template||u.command),[S,C]=(0,V.useState)(!1);return(0,z.jsxs)(`div`,{ref:t=>s(e.key,t),"data-testid":`loop-step-section`,"data-status":t,"data-step-index":u.index,className:L(`mt-3 rounded-md overflow-hidden border animate-in fade-in duration-200`,t===`running`&&`border-accent-primary/40`,t===`failed`&&`border-destructive/30`,t===`interrupted`&&`border-dashed border-accent-warning/40`,(t===`ok`||t===`unknown`)&&`border-border/20`),children:[(0,z.jsxs)(`div`,{className:L(`flex items-stretch bg-primary/5 border-b`,t===`failed`?`border-destructive/20`:`border-primary/20`),children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>a(e.key),className:`flex items-center gap-2 flex-1 min-w-0 text-left px-3 py-2 hover:bg-primary/10 transition-colors duration-150 cursor-pointer`,children:[(0,z.jsx)(i,{className:L(`w-3 h-3 text-primary/60 shrink-0 transition-transform duration-150`,!n&&`rotate-90`)}),(0,z.jsx)(`span`,{className:`text-[10px] font-mono tabular-nums text-muted-foreground/60 shrink-0 w-5 text-right`,children:u.index}),(0,z.jsx)(h,{className:L(`w-3.5 h-3.5 shrink-0`,_)}),(0,z.jsx)(`span`,{className:`text-[12px] font-semibold text-foreground leading-none truncate`,children:Y(u)}),u.iteration!=null&&u.iteration>=1&&(0,z.jsx)(`span`,{className:`shrink-0 rounded-full bg-muted/60 px-1.5 py-0.5 text-[9px] font-medium text-muted-foreground tabular-nums`,children:l(`loopExplorer.iterationBadge`,{count:u.iteration})}),b&&(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5 min-w-0 shrink-0 max-w-[40%]`,children:[(0,z.jsx)(Ve,{}),p&&(0,z.jsx)(`span`,{className:`title-shimmer text-[10px] truncate`,children:l(`statusPanel.activity.${p.actionKey}`,{arg:p.actionArg??``})})]}),t===`ok`&&(0,z.jsx)(m,{className:`w-3.5 h-3.5 text-accent-success shrink-0`}),t===`failed`&&(0,z.jsx)(g,{className:`w-3.5 h-3.5 text-destructive shrink-0`}),t===`interrupted`&&(0,z.jsx)(`span`,{className:`shrink-0 rounded border border-dashed border-accent-warning/50 px-1.5 py-0.5 text-[9px] font-medium uppercase tracking-wide text-accent-warning`,children:l(`loopExplorer.interrupted`)}),(0,z.jsx)(`span`,{className:`flex-1`}),f?.durationMs!=null&&(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/50 font-mono tabular-nums shrink-0`,children:Pe(f.durationMs)}),t===`failed`&&f?.exitCode!=null&&f.exitCode!==0&&(0,z.jsx)(`span`,{className:`text-[10px] text-destructive/70 font-mono shrink-0`,children:l(`activeJob.exitCode`,{code:f.exitCode})}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:l(`logViewer.phaseLines`,{count:d.length})})]}),x&&(0,z.jsx)(`button`,{type:`button`,onClick:()=>C(e=>!e),"aria-label":l(`loopExplorer.stepDetail`),"aria-expanded":S,title:l(`loopExplorer.stepDetail`),className:L(`px-2 flex items-center transition-colors cursor-pointer`,S?`text-foreground bg-primary/10`:`text-muted-foreground/40 hover:text-foreground hover:bg-primary/10`),children:(0,z.jsx)(I,{className:`w-3 h-3`})}),(0,z.jsx)(`button`,{type:`button`,onClick:()=>o(e.key),"aria-label":l(`loopExplorer.copyStep`),title:l(`loopExplorer.copyStep`),className:`px-2.5 flex items-center text-muted-foreground/40 hover:text-foreground hover:bg-primary/10 transition-colors cursor-pointer`,children:(0,z.jsx)(y,{className:`w-3 h-3`})})]}),S&&x&&(0,z.jsxs)(`div`,{"data-testid":`loop-step-detail`,className:L(`px-4 py-2.5 space-y-2.5 bg-muted/10 border-b animate-in fade-in duration-150`,t===`failed`?`border-destructive/20`:`border-primary/10`),children:[u.template&&(0,z.jsx)(We,{label:l(`loopExplorer.stepDetailTemplate`),value:u.template,copyLabel:l(`loopExplorer.copyCommand`)}),u.command&&(0,z.jsx)(We,{label:l(`loopExplorer.stepDetailCommand`),value:u.command,copyLabel:l(`loopExplorer.copyCommand`)})]}),!n&&(0,z.jsx)(`div`,{className:`bg-muted/5`,children:Ue(v,r,l,c)})]})}var Ke=(0,V.memo)(Ge,(e,t)=>e.segment.key===t.segment.key&&e.segment.lines.length===t.segment.lines.length&&e.segment.lines[e.segment.lines.length-1]?.content===t.segment.lines[t.segment.lines.length-1]?.content&&e.segment.meta.template===t.segment.meta.template&&e.segment.meta.command===t.segment.meta.command&&e.segment.end?.status===t.segment.end?.status&&e.segment.end?.durationMs===t.segment.end?.durationMs&&e.segment.end?.decision===t.segment.end?.decision&&e.segment.end?.exitCode===t.segment.end?.exitCode&&e.segment.lastActivity?.actionKey===t.segment.lastActivity?.actionKey&&e.segment.lastActivity?.actionArg===t.segment.lastActivity?.actionArg&&e.status===t.status&&e.collapsed===t.collapsed&&e.filter===t.filter&&e.onOpenTicket===t.onOpenTicket),Q=`__setup__`;function qe({lines:e,collapsed:t,filter:n,onToggle:r,setRef:a,onOpenTicket:o}){let{t:s}=T(`jobs`),c=He(e,n);return(0,z.jsxs)(`div`,{ref:e=>a(Q,e),"data-testid":`loop-setup-section`,className:`rounded-md overflow-hidden border border-border/20`,children:[(0,z.jsxs)(`button`,{type:`button`,onClick:()=>r(Q),className:`flex items-center gap-2 w-full text-left px-3 py-2 bg-muted/10 border-b border-border/20 hover:bg-muted/20 transition-colors duration-150 cursor-pointer`,children:[(0,z.jsx)(i,{className:L(`w-3 h-3 text-muted-foreground/60 shrink-0 transition-transform duration-150`,!t&&`rotate-90`)}),(0,z.jsx)(E,{className:`w-3.5 h-3.5 text-accent-success/70 shrink-0`}),(0,z.jsx)(`span`,{className:`text-[11px] font-semibold text-muted-foreground leading-none uppercase tracking-wide`,children:s(`loopExplorer.setup`)}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground/40 shrink-0`,children:s(`logViewer.phaseLines`,{count:e.length})})]}),!t&&(0,z.jsx)(`div`,{className:`bg-muted/5`,children:Ue(c,n,s,o)})]})}var Je=(0,V.memo)(qe,(e,t)=>e.lines.length===t.lines.length&&e.lines[e.lines.length-1]?.content===t.lines[t.lines.length-1]?.content&&e.collapsed===t.collapsed&&e.filter===t.filter&&e.onOpenTicket===t.onOpenTicket);function $(){return(0,z.jsxs)(`span`,{className:`relative flex h-1.5 w-1.5 shrink-0`,children:[(0,z.jsx)(`span`,{className:`motion-safe:animate-ping absolute inline-flex h-full w-full rounded-full bg-accent-primary opacity-60`}),(0,z.jsx)(`span`,{className:`relative inline-flex rounded-full h-1.5 w-1.5 bg-accent-primary`})]})}function Ye({events:e,jobStatus:t,isLoading:n,variant:r=`page`,projectId:i}){let{t:a,i18n:o}=T(`jobs`),[s,c]=(0,V.useState)(``),[l,u]=(0,V.useState)(`follow`),[d,f]=(0,V.useState)(new Set),p=(0,V.useRef)(null),m=(0,V.useRef)(new Map),h=G(i),g=(0,V.useMemo)(()=>ke(e),[e,o.language]),_=t!=null&&t!==`running`&&t!==`queued`,v=t===`running`,b=(0,V.useMemo)(()=>g.segments.map((e,t)=>Ae(e,{isLast:t===g.segments.length-1,jobSettled:_})),[g,_]),x=(0,V.useMemo)(()=>{let e=g.segments.map(e=>e.key);return g.setup.length>0&&e.push(Q),e},[g]),w=g.segments.length>0?g.segments[g.segments.length-1].key:Q,E=(0,V.useMemo)(()=>s?new Set(x):l===`follow`?new Set([w]):d,[s,l,w,d,x]),D=(0,V.useRef)(E);D.current=E;let k=(0,V.useRef)(g);k.current=g;let A=(0,V.useCallback)(e=>{let t=new Set(D.current);e?.(t),f(t),u(`manual`)},[]),j=(0,V.useCallback)(e=>{A(t=>{t.has(e)?t.delete(e):t.add(e)})},[A]),M=(0,V.useCallback)(e=>{A(t=>t.add(e)),requestAnimationFrame(()=>{m.current.get(e)?.scrollIntoView?.({behavior:`smooth`,block:`start`})})},[A]),N=(0,V.useCallback)(()=>{let e=p.current;e&&(e.scrollTop=e.scrollHeight)},[]),P=(0,V.useCallback)(()=>{u(`follow`),requestAnimationFrame(N)},[N]),ee=(0,V.useCallback)(()=>{f(new Set(x)),u(`manual`)},[x]),te=(0,V.useCallback)(()=>{f(new Set),u(`manual`)},[]);(0,V.useEffect)(()=>{l===`follow`&&!s&&N()},[g.totalLines,g.segments.length,l,s,N]);let ne=(0,V.useCallback)(()=>{let e=p.current;!e||l!==`follow`||e.scrollHeight-e.scrollTop-e.clientHeight>80&&A()},[l,A]),F=(0,V.useCallback)((e,t)=>{t?m.current.set(e,t):m.current.delete(e)},[]),I=(0,V.useCallback)(e=>{let t=k.current.segments.find(t=>t.key===e),n=e===`__setup__`?k.current.setup.map(e=>e.content).join(`
17
+ `):(t?.lines??[]).map(e=>e.content).join(`
18
+ `);navigator.clipboard.writeText(n).then(()=>S.success(a(`loopExplorer.copied`))).catch(()=>S.error(a(`logViewer.copyFailed`)))},[a]),re=(0,V.useCallback)(()=>{let e=k.current,t=e.setup.map(e=>e.content);for(let n of e.segments){t.push(`── Step ${n.meta.index} · ${J(n.meta.title)} ──`);for(let e of n.lines)t.push(e.content)}navigator.clipboard.writeText(t.join(`
19
+ `)).then(()=>S.success(a(`logViewer.copySuccess`))).catch(()=>S.error(a(`logViewer.copyFailed`)))},[a]),ie=(0,V.useMemo)(()=>Ne(g,{jobSettled:_,jobFailed:t===`failed`}),[g,_,t]),R=g.graphMeta?.iterationLimit??g.graphMeta?.graph.config.maxIterations??null,oe=g.maxIteration>0?{current:g.maxIteration,limit:R}:null,le=(0,V.useMemo)(()=>{if(!s)return g.totalLines;let e=s.toLowerCase(),t=g.setup.filter(t=>t.content.toLowerCase().includes(e)).length;for(let n of g.segments)t+=n.lines.filter(t=>t.content.toLowerCase().includes(e)).length;return t},[s,g]),ue=g.segments[g.segments.length-1],B=v&&(g.segments.length===0||ue?.end!=null);return n?(0,z.jsx)(`div`,{className:`flex-1 flex items-center justify-center h-full`,children:(0,z.jsx)(`p`,{className:`text-xs text-muted-foreground`,children:a(`logViewer.loading`)})}):g.totalLines===0&&g.segments.length===0?(0,z.jsx)(`div`,{"data-testid":`loop-step-explorer`,className:`flex-1 flex items-center justify-center h-full`,children:(0,z.jsxs)(`p`,{className:`text-xs text-muted-foreground flex items-center gap-2`,children:[v&&(0,z.jsx)($,{}),a(v?`loopExplorer.waiting`:`logViewer.empty`)]})}):(0,z.jsxs)(`div`,{"data-testid":`loop-step-explorer`,className:`relative flex flex-col h-full`,children:[(0,z.jsxs)(`div`,{className:L(`border-b border-border flex items-center gap-2`,r===`glass`?`px-3 py-1.5`:`px-4 py-2`),children:[(0,z.jsxs)(`div`,{className:`relative flex-1 max-w-xs`,children:[(0,z.jsx)(C,{className:`absolute left-2.5 top-1/2 -translate-y-1/2 w-3 h-3 text-muted-foreground`}),(0,z.jsx)(ae,{placeholder:a(`logViewer.filterPlaceholder`),value:s,onChange:e=>c(e.target.value),className:`pl-7 h-7`})]}),(0,z.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:ee,"aria-label":a(`loopExplorer.expandAll`),title:a(`loopExplorer.expandAll`),children:(0,z.jsx)(ce,{className:`w-3.5 h-3.5`})}),(0,z.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:te,"aria-label":a(`loopExplorer.collapseAll`),title:a(`loopExplorer.collapseAll`),children:(0,z.jsx)(se,{className:`w-3.5 h-3.5`})}),l===`follow`&&v&&(0,z.jsxs)(`span`,{className:`flex items-center gap-1.5 text-[10px] text-accent-primary shrink-0`,children:[(0,z.jsx)($,{}),a(`loopExplorer.follow`)]}),(0,z.jsx)(`span`,{className:`flex-1`}),(0,z.jsx)(O,{variant:`ghost`,size:`sm`,className:`h-7 px-2 text-muted-foreground/50 hover:text-foreground`,onClick:re,"aria-label":a(`logViewer.copySuccess`),children:(0,z.jsx)(y,{className:`w-3.5 h-3.5`})}),(0,z.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:a(`logViewer.lineCount`,{filtered:le,total:g.totalLines})})]}),(0,z.jsx)(Be,{chips:ie,iteration:oe,onChipClick:M,variant:r}),(0,z.jsxs)(`div`,{ref:p,onScroll:ne,className:`flex-1 overflow-y-auto p-2 text-xs`,children:[g.setup.length>0&&(0,z.jsx)(Je,{lines:g.setup,collapsed:!E.has(`__setup__`),filter:s,onToggle:j,setRef:F,onOpenTicket:h}),g.segments.map((e,t)=>(0,z.jsx)(Ke,{segment:e,status:b[t],collapsed:!E.has(e.key),filter:s,onToggle:j,onCopy:I,setRef:F,onOpenTicket:h},e.key)),B&&(0,z.jsxs)(`div`,{"data-testid":`loop-waiting-row`,className:`mt-3 flex items-center gap-2 px-3 py-2 text-[11px] text-muted-foreground/70 italic`,children:[(0,z.jsx)($,{}),a(`loopExplorer.waiting`)]})]}),l===`manual`&&v&&!s&&(0,z.jsxs)(`button`,{type:`button`,"data-testid":`resume-follow-pill`,onClick:P,className:`absolute bottom-4 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 rounded-full glass-card border border-accent-primary/30 px-3 py-1.5 text-[11px] font-medium text-foreground shadow-lg hover:border-accent-primary/60 transition-colors cursor-pointer animate-in fade-in slide-in-from-bottom-2 duration-200`,children:[(0,z.jsx)($,{}),a(`loopExplorer.resumeFollow`)]})]})}function Xe(e,t){switch(t.type){case`turn-user`:return{...e,streaming:!0,accepting:!0,queued:t.queued?e.queued+1:e.queued};case`turn-done`:{let n=Math.max(0,e.queued-1);return{...e,totals:t.totals,queued:n,streaming:e.queued>0}}case`finalized`:return{...e,streaming:!1,finalizing:!1,accepting:!1,queued:0,totals:t.totals??e.totals};case`accepting`:return t.accepting?{...e,accepting:!0}:{...e,accepting:!1,streaming:!1,queued:0};case`finalize-request`:return{...e,finalizing:!0};case`finalize-reject`:return{...e,finalizing:!1};case`blocked`:return{...e,accepting:!1,streaming:!1};default:return e}}function Ze(){try{return N()}catch{return null}}function Qe({jobId:e,projectId:t,settleMode:r,initialAcceptingTurns:i,kind:a=`job`,variant:s=`page`,onFinalized:c}){let{t:l}=T(`jobs`),u=r??`finalize`,d=()=>t?`${n}/api/projects/${t}`:ne(),[m,h]=(0,V.useReducer)(Xe,{streaming:!1,queued:0,totals:null,accepting:i??!0,finalizing:!1}),[g,_]=(0,V.useState)(``),[v,y]=(0,V.useState)(!1),b=(0,V.useRef)(null);(0,V.useEffect)(()=>{i!==void 0&&h({type:`accepting`,accepting:i})},[i]);let C=(0,V.useRef)(c);C.current=c;let E=Ze(),D=(0,V.useId)();(0,V.useEffect)(()=>{if(!E)return;let t=`interactive-composer-${e}-${D}`;return E.registerHandler(t,t=>{let n=t;n.jobId===e&&(n.type===`job.turn_user`?h({type:`turn-user`,queued:!!n.queued}):n.type===`job.turn_done`?h({type:`turn-done`,totals:n.totals}):n.type===`job.finalized`?(h({type:`finalized`,totals:n.totals??null}),C.current?.()):n.type===`job.interactive`&&h({type:`accepting`,accepting:!!n.acceptingTurns}))}),()=>E.unregisterHandler(t)},[E,e,D]);let k=a===`loop-step`&&!m.accepting;async function A(){let t=g.trim();if(!(!t||v||k)){y(!0);try{let n=await fetch(`${d()}/jobs/${e}/messages`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({text:t})});if(n.ok)_(``),requestAnimationFrame(()=>b.current?.focus());else if(n.status===409&&a===`loop-step`)h({type:`blocked`});else{let e=await n.json().catch(()=>({}));S.error(l(`detail.toast.sendFailed`),{description:e.error})}}catch{S.error(l(`detail.toast.networkError`))}finally{y(!1)}}}async function j(){if(!m.finalizing){h({type:`finalize-request`});try{let t=await fetch(`${d()}/jobs/${e}/finalize`,{method:`POST`});if(t.ok)S.success(l(u===`finalize`?`detail.toast.finalizeScheduled`:a===`loop-step`?`detail.toast.wrapUpStepScheduled`:`detail.toast.wrapUpScheduled`));else if(t.status===409&&a===`loop-step`)h({type:`blocked`}),h({type:`finalize-reject`});else{let e=await t.json().catch(()=>({}));S.error(l(`detail.toast.finalizeFailed`),{description:e.error}),h({type:`finalize-reject`})}}catch{S.error(l(`detail.toast.networkError`)),h({type:`finalize-reject`})}}}let M=v||k||!g.trim(),N=l(`detail.interactive.working`);return(0,z.jsxs)(`div`,{"data-testid":`interactive-job-composer`,className:L(`shrink-0 border-t px-3 py-2 space-y-1.5`,`motion-safe:animate-in motion-safe:fade-in motion-safe:slide-in-from-bottom-2 motion-safe:duration-300`,s===`glass`?`border-border/30 bg-surface/30`:`border-border/40 bg-surface/40`),children:[(0,z.jsxs)(`div`,{className:`flex items-center justify-between gap-3 text-[11px] text-muted-foreground`,children:[(0,z.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[k?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,z.jsx)(le,{className:`h-3 w-3 motion-safe:animate-pulse`}),l(`detail.interactive.waitingForStepShort`)]}):m.streaming?(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,z.jsx)(P,{className:`h-3 w-3 animate-spin text-accent-primary`}),(0,z.jsxs)(`span`,{className:`relative`,children:[N,(0,z.jsx)(`span`,{"aria-hidden":!0,className:`title-shimmer pointer-events-none absolute inset-0`,children:N})]})]}):(0,z.jsxs)(`span`,{className:`inline-flex items-center gap-1.5`,children:[(0,z.jsx)(`span`,{className:`h-1.5 w-1.5 rounded-full bg-accent-success motion-safe:animate-pulse`}),l(`detail.interactive.ready`)]}),m.queued>0&&(0,z.jsx)(`span`,{className:`rounded-full border border-accent-info/30 bg-accent-info/10 px-1.5 py-px text-[10px] tabular-nums text-accent-info motion-safe:animate-in motion-safe:fade-in`,children:l(`detail.interactive.queued`,{count:m.queued})})]}),(0,z.jsxs)(`span`,{className:`flex shrink-0 items-center gap-3`,children:[m.totals&&(0,z.jsx)(`span`,{className:`tabular-nums`,children:l(`detail.interactive.liveTotals`,{turns:m.totals.num_turns,cost:m.totals.total_cost_usd.toFixed(4)})}),u===`finalize`?(0,z.jsxs)(x,{children:[(0,z.jsx)(p,{asChild:!0,children:(0,z.jsxs)(O,{variant:`outline`,size:`sm`,onClick:()=>void j(),disabled:m.finalizing,className:`h-7 border-accent-success/40 text-accent-success hover:bg-accent-success/10`,children:[(0,z.jsx)(o,{className:`mr-1.5 h-3.5 w-3.5`}),m.finalizing?l(`detail.finalizing`):l(`detail.finalizeJob`)]})}),(0,z.jsx)(w,{children:l(`detail.finalizeJobTooltip`)})]}):(0,z.jsxs)(x,{children:[(0,z.jsx)(p,{asChild:!0,children:(0,z.jsx)(`button`,{type:`button`,onClick:()=>void j(),disabled:m.finalizing||k,className:L(`text-[11px] underline-offset-2 transition-colors`,k?`cursor-not-allowed text-muted-foreground/40`:`text-muted-foreground hover:text-accent-success hover:underline`),children:m.finalizing?l(`detail.interactive.wrappingUp`):l(a===`loop-step`?`detail.interactive.wrapUpStep`:`detail.interactive.wrapUp`)})}),(0,z.jsx)(w,{children:l(a===`loop-step`?`detail.interactive.wrapUpStepTooltip`:`detail.interactive.wrapUpTooltip`)})]})]})]}),u===`auto`&&(0,z.jsx)(`p`,{className:`text-[11px] leading-snug text-muted-foreground/60`,children:l(k?`detail.interactive.waitingForStep`:`detail.interactive.autoHint`)}),(0,z.jsxs)(`div`,{className:`flex items-end gap-2`,children:[(0,z.jsx)(`textarea`,{ref:b,value:g,onChange:e=>_(e.target.value),onKeyDown:e=>{e.key===`Enter`&&(!e.shiftKey||e.metaKey||e.ctrlKey)&&(e.preventDefault(),A())},rows:2,placeholder:l(k?`detail.interactive.waitingForStepShort`:`detail.interactive.placeholder`),"aria-label":l(`detail.interactive.placeholder`),disabled:k,className:L(`flex-1 resize-none rounded-md border border-border/50 bg-background px-2.5 py-1.5 text-sm transition-opacity focus:outline-none focus:ring-2 focus:ring-ring`,k&&`opacity-60`)}),(0,z.jsxs)(x,{children:[(0,z.jsx)(p,{asChild:!0,children:(0,z.jsx)(`span`,{className:`shrink-0`,children:(0,z.jsxs)(O,{size:`sm`,onClick:()=>void A(),disabled:M,className:`h-9`,children:[(0,z.jsx)(f,{className:`mr-1.5 h-3.5 w-3.5`}),l(`detail.interactive.send`)]})})}),M&&!v&&(0,z.jsx)(w,{children:l(k?`detail.interactive.sendDisabledWaiting`:`detail.interactive.sendDisabledEmpty`)})]})]})]})}export{ue as i,Ye as n,xe as r,Qe as t};
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{i as t,n,r,t as i}from"./InteractiveJobComposer-B5gh4Qoy.js";import{a,n as o}from"./auth-DpZq5p1e.js";import{$n as s,B as c,G as l,K as u,Ot as d,Qn as f,U as ee,Un as p,W as m,Wn as h,at as g,et as _,in as v,it as y,mt as b,n as x,pt as S,r as C,tt as w,ut as te,w as ne}from"./index-DyY1QyIn.js";var T=e(f(),1),E=e(s(),1),D=[1e3,2e3,4e3,8e3,16e3];function O(e,t){let[n,r]=(0,E.useState)(`connecting`),i=(0,E.useRef)(null),a=(0,E.useRef)(0),s=(0,E.useRef)(null),c=(0,E.useRef)(t);c.current=t;let l=(0,E.useCallback)(()=>{let t=o(),n=t?new WebSocket(e,[`specrails-desktop`,t]):new WebSocket(e);i.current=n,r(`connecting`),n.onopen=()=>{a.current=0,r(`connected`)},n.onmessage=e=>{try{let t=JSON.parse(e.data);c.current(t)}catch{}},n.onclose=()=>{i.current=null;let e=a.current;if(e>=D.length){r(`disconnected`);return}let t=D[e];a.current+=1,s.current=setTimeout(l,t)}},[e]);return(0,E.useEffect)(()=>(l(),()=>{s.current&&clearTimeout(s.current);let e=i.current;e&&(e.onopen=null,e.onmessage=null,e.onclose=null,e.onerror=null,e.close()),i.current=null}),[l]),{connectionStatus:n}}var k=S();function A(e,t){let n=new Date(t).getTime()-new Date(e).getTime();if(n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%60}m`}var j={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`},zombie_terminated:{variant:`failed`,labelKey:`statusLabel.zombie`,tooltipKey:`statusTooltip.zombie`}};function M({jobId:e,onClose:o,projectId:s}){let{t:f}=h(`jobs`),S=(0,E.useCallback)(()=>s?`${a}/api/projects/${s}`:b(),[s]),[D,M]=(0,E.useState)(null),[N,P]=(0,E.useState)([]),[F,I]=(0,E.useState)([]),[L,R]=(0,E.useState)({}),[z,B]=(0,E.useState)(!0),[V,H]=(0,E.useState)(!1),[U,W]=(0,E.useState)(!1),[G,K]=(0,E.useState)(!1);(0,E.useEffect)(()=>{async function t(){try{let t=await fetch(`${S()}/jobs/${e}`);if(t.status===404){H(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();if(M(n.job),P(n.events),n.phaseDefinitions){I(n.phaseDefinitions);let e={};for(let t of n.phaseDefinitions)e[t.key]=`idle`;R(e)}}catch{H(!0)}finally{B(!1)}}t()},[e,S]);let q=(0,E.useCallback)(()=>{fetch(`${S()}/jobs/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.job&&M(e.job)}).catch(()=>{})},[e,S]),J=(0,E.useRef)([]),Y=(0,E.useRef)(null),X=(0,E.useCallback)(()=>{Y.current=null;let e=J.current;e.length!==0&&(J.current=[],P(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]);(0,E.useEffect)(()=>()=>{Y.current&&cancelAnimationFrame(Y.current)},[]),O(c,(0,E.useCallback)(t=>{let n=t;if(n.type===`event`&&n.jobId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:n.event_type,source:n.source,payload:n.payload,timestamp:n.timestamp};J.current.push(t),Y.current||=requestAnimationFrame(X)}else if(n.type===`log`&&n.processId===e){let t={id:Date.now(),job_id:e,seq:0,event_type:`log`,source:n.source,payload:JSON.stringify({line:n.line}),timestamp:n.timestamp};J.current.push(t),Y.current||=requestAnimationFrame(X)}else if(n.type===`job.finalized`&&n.jobId===e||n.type===`job.interactive`&&n.jobId===e||(n.type===`loop.run_paused`||n.type===`loop.run_resumed`)&&n.loopRunId===e)q();else if(n.type===`phase`){let e=n.phase,t=n.state;R(n=>({...n,[e]:t}))}else if(n.type===`queue`){let t=n.jobs?.find(t=>t.id===e);t&&D&&M(e=>e&&{...e,status:t.status})}},[e,D,X,q])),(0,E.useEffect)(()=>{function e(e){if(e.key===`Escape`){if(U){W(!1);return}o()}}return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[o,U]);let Z=D?C(D):`job`,Q=Z===`loop-run`;async function re(){K(!0);try{let t=await x({projectId:s??null,jobId:e,kind:Z});t.ok?(p.success(f(Q?`modal.toast.stopSignalSent`:`modal.toast.cancelSignalSent`),{description:f(Q?`modal.toast.stopSignalSentDescription`:`modal.toast.cancelSignalSentDescription`)}),q()):p.error(f(`modal.toast.cancelFailed`),{description:t.error})}finally{K(!1)}}let $=D?j[D.status]??j.queued:j.queued,ie=D?.status===`running`,{panelRef:ae,panelStyle:oe,headerHandleProps:se,resizeHandles:ce,isFloating:le,guardBackdrop:ue}=w();return(0,T.createPortal)((0,k.jsx)(l,{delayDuration:400,children:(0,k.jsxs)(`div`,{className:`fixed inset-0 z-[65] flex items-stretch justify-center`,children:[(0,k.jsx)(`div`,{className:`absolute inset-0 bg-black/50 backdrop-blur-sm`,onClick:ue(o)}),(0,k.jsxs)(`div`,{ref:ae,className:`relative w-full m-3 rounded-xl glass-card border border-border/30 flex flex-col animate-in fade-in zoom-in-95 duration-200 overflow-hidden`,style:oe,children:[(0,k.jsxs)(`div`,{...se,className:`flex items-center justify-between px-4 py-3 border-b border-border/30${le?` cursor-grab active:cursor-grabbing`:``}`,children:[(0,k.jsxs)(`div`,{className:`flex items-center gap-3 min-w-0`,children:[D&&(0,k.jsxs)(k.Fragment,{children:[(0,k.jsxs)(ee,{children:[(0,k.jsx)(u,{asChild:!0,children:(0,k.jsx)(`div`,{children:(0,k.jsx)(y,{variant:$.variant,children:f($.labelKey)})})}),(0,k.jsx)(m,{children:f($.tooltipKey)})]}),(0,k.jsx)(`code`,{className:`text-xs font-mono text-foreground/80 truncate`,children:D.command}),(0,k.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:ne(new Date(D.started_at),{addSuffix:!0,locale:te()})}),D.total_cost_usd!=null&&D.total_cost_usd>0&&(0,k.jsxs)(`span`,{className:`text-[10px] text-muted-foreground`,children:[`$`,D.total_cost_usd.toFixed(4)]}),D.finished_at&&(0,k.jsx)(`span`,{className:`text-[10px] text-muted-foreground`,children:A(D.started_at,D.finished_at)})]}),z&&(0,k.jsx)(`span`,{className:`text-xs text-muted-foreground`,children:f(`common:states.loading`)})]}),(0,k.jsxs)(`div`,{className:`flex items-center gap-1 shrink-0`,children:[F.length>0&&(0,k.jsx)(`div`,{className:`mr-3`,children:(0,k.jsx)(t,{phases:L,phaseDefinitions:F})}),ie&&(0,k.jsxs)(g,{variant:`ghost`,size:`sm`,onClick:()=>W(!0),disabled:G,className:`h-7 text-destructive hover:text-destructive hover:bg-destructive/10`,children:[G&&(0,k.jsx)(v,{className:`w-3.5 h-3.5 mr-1.5 animate-spin`,"aria-hidden":!0}),f(Q?`dashboard:railControls.stop`:Z===`interactive`?`common:actions.discard`:`common:actions.cancel`)]}),(0,k.jsx)(`button`,{onClick:o,className:`h-7 w-7 flex items-center justify-center rounded-md text-muted-foreground hover:text-foreground hover:bg-surface/50 transition-colors cursor-pointer`,children:(0,k.jsx)(d,{className:`w-4 h-4`})})]})]}),(0,k.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:V?(0,k.jsx)(`div`,{className:`flex items-center justify-center h-full`,children:(0,k.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:f(`modal.notFound`)})}):D?.command.startsWith(`loop:`)?(0,k.jsx)(n,{events:N,jobStatus:D.status,isLoading:z,variant:`glass`,projectId:s}):(0,k.jsx)(r,{events:N,isLoading:z,projectId:s})}),!!D?.interactive&&D.status===`running`&&(0,k.jsx)(i,{jobId:e,projectId:s,settleMode:D.interactiveSettleMode,initialAcceptingTurns:D.interactiveAcceptingTurns,kind:D.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`glass`,onFinalized:q})]}),(0,k.jsx)(_,{handles:ce}),U&&(0,k.jsxs)(`div`,{"data-testid":`job-cancel-confirm`,className:`absolute inset-0 z-10 flex items-center justify-center p-4`,children:[(0,k.jsx)(`div`,{className:`absolute inset-0 bg-black/60 backdrop-blur-sm`,onClick:()=>W(!1)}),(0,k.jsxs)(`div`,{className:`relative w-full max-w-sm rounded-xl glass-card border border-border/30 p-5 shadow-xl animate-in fade-in zoom-in-95 duration-150`,children:[(0,k.jsx)(`h3`,{className:`text-base font-semibold text-foreground`,children:f(Q?`modal.stopRunConfirmTitle`:`modal.cancelConfirmTitle`)}),(0,k.jsx)(`p`,{className:`mt-1.5 text-sm text-muted-foreground`,children:f(Q?`modal.stopRunConfirmDescription`:`modal.cancelConfirmDescription`)}),(0,k.jsxs)(`div`,{className:`mt-4 flex justify-end gap-2`,children:[(0,k.jsx)(g,{variant:`ghost`,size:`sm`,onClick:()=>W(!1),children:f(`modal.keepRunning`)}),(0,k.jsx)(g,{variant:`destructive`,size:`sm`,onClick:()=>{W(!1),re()},children:f(Q?`modal.stopRun`:Z===`interactive`?`common:actions.discard`:`modal.cancelJob`)})]})]})]})]})}),document.body)}export{M as JobDetailModal};
@@ -0,0 +1 @@
1
+ import{a as e}from"./chunk-BNv3lrIs.js";import{i as t,n,r,t as i}from"./InteractiveJobComposer-B5gh4Qoy.js";import{$n as a,An as o,C as s,Cn as c,D as l,Dn as ee,E as u,En as te,K as d,Kt as f,U as p,Un as m,W as h,Wn as g,Xn as _,Yn as v,at as y,ct as b,ft as x,in as S,it as ne,jn as C,kn as w,mt as T,n as E,ot as D,pt as O,qn as k,sn as A,ut as j,w as M,xn as re}from"./index-DyY1QyIn.js";import{t as N}from"./format-command-CuWuRvka.js";var P=e(a(),1),F=O();function I(e,t){let n=(typeof t==`number`?t:new Date(t).getTime())-new Date(e).getTime();if(!Number.isFinite(n)||n<0)return`—`;let r=Math.round(n/1e3);if(r<60)return`${r}s`;let i=Math.floor(r/60),a=r%60;return i<60?`${i}m ${a}s`:`${Math.floor(i/60)}h ${i%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=l(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 B({job:e,events:t,defaultOpen:n=!0,pipelineTotals:r,phases:i,phaseDefinitions:a}){let{t:o}=g(`jobs`),[s,c]=(0,P.useState)(n),l=(0,P.useMemo)(()=>L(t),[t]),d=e.status===`running`,f=e.status===`completed`,[p,m]=(0,P.useState)(()=>Date.now());(0,P.useEffect)(()=>{if(!d)return;let e=window.setInterval(()=>m(Date.now()),1e3);return()=>window.clearInterval(e)},[d]);let[h,_]=(0,P.useReducer)(z,R),v=(0,P.useRef)(e.id);(0,P.useEffect)(()=>{v.current!==e.id&&(v.current=e.id,_({type:`reset`})),_({type:`consume`,events:t})},[e.id,t]);let[y,b]=(0,P.useState)(!0);(0,P.useEffect)(()=>{if(!d)return;b(!0);let e=window.setTimeout(()=>b(!1),8e3);return()=>window.clearTimeout(e)},[d,e.id]);let x=e.finished_at?I(e.started_at,e.finished_at):d?I(e.started_at,p):`—`,ne=!!e.total_cost_usd_estimated,w=e.total_cost_usd==null?null:`${ne?`~`:``}$${e.total_cost_usd.toFixed(4)}`,T=e.num_turns==null?null:String(e.num_turns),E=e.tokens_in==null?null:(e.tokens_in??0)+(e.tokens_out??0)+(e.tokens_cache_read??0)+(e.tokens_cache_create??0),O=E==null?null:`${(E/1e3).toFixed(1)}k`,k=(0,P.useMemo)(()=>!i||!a?null:a.find(e=>i[e.key]===`running`)?.label??null,[i,a]),A=d&&h.steps===0?`connecting`:h.actionKey||`thinking`,j=u.has(A)&&h.actionArg!==``,M=u.has(A)&&!j?`working`:A,re=j?o(`statusPanel.activity.${M}`,{arg:h.actionArg}):o(`statusPanel.activity.${M}`),N=k??(d&&h.steps===0?o(`statusPanel.activity.starting`):null),B=h.steps>0?o(`statusPanel.steps`,{count:h.steps}):null,W=o(d?`statusPanel.inProgress`:f?`statusPanel.completed`:`statusPanel.failed`),G=d?`border-accent-info/20 bg-accent-info/5`:f?`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`,K=d?S:f?ee:te,q=d?`w-4 h-4 text-accent-info shrink-0 animate-spin`:f?`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:D(`mx-4 my-2 rounded-xl border transition-colors duration-500`,G),children:[(0,F.jsxs)(`button`,{type:`button`,onClick:()=>c(!s),className:`w-full flex items-center gap-3 px-4 py-3`,children:[(0,F.jsx)(K,{className:q,"aria-hidden":`true`}),(0,F.jsx)(`span`,{className:`text-sm font-semibold flex-1 text-left`,children:W}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-[11px] text-muted-foreground`,children:[(0,F.jsx)(`span`,{className:`tabular-nums`,children:x}),d?B&&(0,F.jsx)(`span`,{className:`tabular-nums`,children:B}):(0,F.jsxs)(F.Fragment,{children:[w&&(0,F.jsx)(`span`,{className:`tabular-nums text-yellow-400 aurora-light:text-accent-warning`,children:w}),l.length>0&&(0,F.jsx)(`span`,{children:o(`statusPanel.filesCount`,{count:l.length})})]})]}),(0,F.jsx)(C,{className:D(`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:d?(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:x})]}),(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`}),N&&(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:N}),(0,F.jsx)(`span`,{className:`text-xs text-muted-foreground truncate flex-1 min-w-0`,children:re}),B&&(0,F.jsxs)(`span`,{className:`text-[11px] text-muted-foreground/60 tabular-nums shrink-0`,children:[`· `,B]})]})]}),y&&(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)(U,{label:o(`statusPanel.cost`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.costTooltip`)}),(0,F.jsx)(U,{label:o(`statusPanel.turns`),caption:o(`statusPanel.pendingCaption`),tooltip:o(`statusPanel.pendingTooltip`)}),(0,F.jsx)(U,{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)(V,{label:o(`statusPanel.duration`),value:x}),(0,F.jsx)(H,{label:o(`statusPanel.cost`),value:w,valueClass:`text-yellow-400 aurora-light:text-accent-warning`,naCaption:o(`statusPanel.notAvailable`)}),(0,F.jsx)(H,{label:o(`statusPanel.turns`),value:T,naCaption:o(`statusPanel.notAvailable`)}),(0,F.jsx)(H,{label:o(`statusPanel.tokens`),value:O,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)(V,{label:o(`statusPanel.totalCost`),value:`${r.costEstimated?`~`:``}${r.hasNullCost?`≥`:``}$${r.totalCostUsd.toFixed(4)}`,valueClass:`text-yellow-400 aurora-light:text-accent-warning`}),(0,F.jsx)(V,{label:o(`statusPanel.totalTokens`),value:`${((r.totalTokensIn+r.totalTokensOut+r.totalTokensCacheRead+r.totalTokensCacheCreate)/1e3).toFixed(1)}k`})]}),r.hasNullCost&&(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})})]}),l.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:l.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 V({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:D(`text-sm font-semibold tabular-nums mt-0.5`,n),children:t})]})}function H({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:D(`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 U({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)(c,{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 W=4;function G({tickets:e,onTicketClick:t}){let{t:n}=g(`jobs`),[r,i]=(0,P.useState)(!1);if(e.length===0)return null;let a=e.length>=W&&!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)(K,{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)(C,{className:`w-3 h-3`})]}),r&&e.length>=W&&(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)(w,{className:`w-3 h-3`})]})]})}function K({ticket:e,onClick:t}){let{t:n}=g(`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:D(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:D(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 q={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 J(){let{t:e}=g(`jobs`),{id:a}=_(),{activeProjectId:c,projects:l}=b(),ee=l.find(e=>e.id===c)?.provider,u=v(),{openTicketDetail:te}=s(),[S,C]=(0,P.useState)(null),[w,O]=(0,P.useState)([]),[I,L]=(0,P.useState)([]),[R,z]=(0,P.useState)({}),[V,H]=(0,P.useState)([]),[U,W]=(0,P.useState)(!0),[K,J]=(0,P.useState)(!1);(0,P.useEffect)(()=>{if(!a)return;let e=new AbortController;C(null),O([]),L([]),z({}),W(!0),J(!1);async function t(){try{let t=await fetch(`${T()}/jobs/${a}`,{signal:e.signal});if(t.status===404){J(!0);return}if(!t.ok)throw Error(`Failed to fetch job`);let n=await t.json();C(n.job),O(n.events)}catch(e){if(e.name===`AbortError`)return;J(!0)}finally{e.signal.aborted||W(!1)}}return t(),()=>e.abort()},[a,c]),(0,P.useEffect)(()=>{if(!S?.pipeline_id){H([]);return}let e=S.pipeline_id;fetch(`${T()}/pipelines/${e}`).then(e=>e.ok?e.json():null).then(e=>{e?.jobs&&H(e.jobs)}).catch(()=>{})},[S?.pipeline_id,S?.status]);let Y=(0,P.useRef)(c);Y.current=c;let ie=(0,P.useRef)(null);ie.current=S?.status??null;let X=(0,P.useRef)([]),Z=(0,P.useRef)(null),ae=(0,P.useCallback)(()=>{Z.current=null;let e=X.current;e.length!==0&&(X.current=[],O(t=>{let n=[...t,...e];return n.length>1e4?n.slice(n.length-8e3):n}))},[]),Q=(0,P.useCallback)(e=>{let t=X.current;t.push(e),t.length>1e4&&(X.current=t.slice(-8e3)),Z.current||=requestAnimationFrame(ae)},[ae]);(0,P.useEffect)(()=>()=>{Z.current&&cancelAnimationFrame(Z.current)},[]);let oe=(0,P.useCallback)(e=>{let t=e;if(!(Y.current&&t.projectId&&t.projectId!==Y.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===a)Q({id:Date.now(),job_id:a??``,seq:t.seq??0,event_type:t.event_type,source:t.source,payload:t.payload,timestamp:t.timestamp});else if(t.type===`log`&&t.processId===a)Q({id:Date.now(),job_id:a??``,seq:0,event_type:`log`,source:t.source,payload:JSON.stringify({line:t.line}),timestamp:t.timestamp});else if(t.type===`job.finalized`&&t.jobId===a||t.type===`job.interactive`&&t.jobId===a||(t.type===`loop.run_paused`||t.type===`loop.run_resumed`)&&t.loopRunId===a)fetch(`${T()}/jobs/${a}`).then(e=>e.json()).then(e=>C(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===a);if(e){let t=e.status,n=ie.current;C(e=>e&&{...e,status:t}),(t===`completed`||t===`failed`||t===`canceled`||t===`running`&&n!==`running`)&&fetch(`${T()}/jobs/${a}`).then(e=>e.json()).then(e=>C(e.job)).catch(()=>{})}}}},[a,Q]),{registerHandler:se,unregisterHandler:ce}=x();(0,P.useEffect)(()=>(se(`job-detail-${a}`,oe),()=>ce(`job-detail-${a}`)),[a,oe,se,ce]),(0,P.useEffect)(()=>{if(!a||!S||S.status!==`running`||S.hasTelemetry)return;let e=setInterval(()=>{fetch(`${T()}/jobs/${a}`).then(e=>e.ok?e.json():null).then(e=>{e?.job?.hasTelemetry&&C(e=>e&&{...e,hasTelemetry:!0})}).catch(()=>{})},8e3);return()=>clearInterval(e)},[a,S?.status,S?.hasTelemetry]);async function le(){if(!a)return;let t=await E({projectId:null,jobId:a});t.ok?t.status===`deleted`?(m.success(e(`detail.toast.jobDeleted`)),u(`/jobs`)):m.success(e(`detail.toast.cancelSignalSent`),{description:e(`detail.toast.cancelSignalSentDescription`)}):t.httpStatus===null?m.error(e(`detail.toast.networkError`)):m.error(e(`detail.toast.failed`),{description:t.error})}async function ue(){if(S)try{let t=await fetch(`${T()}/jobs/${S.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-${S.id}-${i}.zip`,document.body.appendChild(a),a.click(),a.remove(),URL.revokeObjectURL(r)}catch(t){m.error(e(`detail.toast.exportFailed`),{description:t.message})}}async function de(){if(S)try{let t=await fetch(`${T()}/spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({command:S.command})}),n=await t.json();if(!t.ok)throw Error(n.error??e(`detail.toast.spawnFailed`));m.success(e(`detail.toast.jobRequeued`)),u(`/jobs/${n.jobId}`)}catch(e){m.error(e.message)}}if(U)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(K||!S)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:a})}),(0,F.jsx)(y,{asChild:!0,variant:`outline`,size:`sm`,children:(0,F.jsxs)(k,{to:`/`,children:[(0,F.jsx)(A,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.backToDashboard`)]})})]});let $=q[S.status]??q.queued,fe=S.status===`running`,pe=S.status===`completed`||S.status===`failed`,me=!!S.interactive,he=me&&fe,ge=(S.tickets?.length??0)>0,_e=S.command.startsWith(`loop:`),ve=V.length>1?{totalCostUsd:V.reduce((e,t)=>e+(t.total_cost_usd??0),0),hasNullCost:V.some(e=>e.total_cost_usd==null),costEstimated:V.some(e=>!!e.total_cost_usd_estimated),nullCostCount:V.filter(e=>e.total_cost_usd==null).length,totalTokensIn:V.reduce((e,t)=>e+(t.tokens_in??0),0),totalTokensOut:V.reduce((e,t)=>e+(t.tokens_out??0),0),totalTokensCacheRead:V.reduce((e,t)=>e+(t.tokens_cache_read??0),0),totalTokensCacheCreate:V.reduce((e,t)=>e+(t.tokens_cache_create??0),0),jobCount:V.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)(k,{to:`/`,className:`hover:text-foreground transition-colors flex items-center gap-1`,children:[(0,F.jsx)(A,{className:`w-3 h-3`}),e(`detail.breadcrumbDashboard`)]}),(0,F.jsx)(o,{className:`w-3 h-3`}),(0,F.jsx)(`span`,{className:`text-foreground font-mono`,children:e(`detail.breadcrumbJob`,{id:a?.slice(0,8)})})]}),ge&&(0,F.jsx)(G,{tickets:S.tickets??[],onTicketClick:te}),(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)(p,{children:[(0,F.jsx)(d,{asChild:!0,children:(0,F.jsx)(`div`,{children:(0,F.jsx)(ne,{variant:$.variant,children:e($.labelKey)})})}),(0,F.jsx)(h,{children:e($.tooltipKey)})]}),(0,F.jsx)(`code`,{className:D(`font-mono text-foreground/90 truncate`,ge?`text-xs text-muted-foreground`:`text-sm`),children:N(S.command,ee)})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-3 text-xs text-muted-foreground flex-wrap`,children:[(0,F.jsx)(`span`,{children:S.started_at?e(`detail.startedAgo`,{timeAgo:M(new Date(S.started_at),{addSuffix:!0,locale:j()})}):e(`detail.queuedWaiting`)}),S.model&&(0,F.jsx)(`span`,{className:`text-muted-foreground/40`,children:S.model})]})]}),(0,F.jsxs)(`div`,{className:`flex items-center gap-2 shrink-0`,children:[S.hasTelemetry&&(0,F.jsxs)(p,{children:[(0,F.jsx)(d,{asChild:!0,children:(0,F.jsxs)(y,{variant:`outline`,size:`sm`,className:`h-7`,onClick:ue,"aria-label":e(`detail.exportDiagnosticAria`),children:[(0,F.jsx)(re,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.exportDiagnostic`)]})}),(0,F.jsx)(h,{children:e(`detail.exportDiagnosticTooltip`)})]}),pe&&(0,F.jsxs)(p,{children:[(0,F.jsx)(d,{asChild:!0,children:(0,F.jsxs)(y,{variant:`outline`,size:`sm`,onClick:de,className:`h-7`,children:[(0,F.jsx)(f,{className:`w-3.5 h-3.5 mr-1.5`}),e(`detail.reExecute`)]})}),(0,F.jsx)(h,{children:e(`detail.reExecuteTooltip`)})]}),fe&&(0,F.jsxs)(p,{children:[(0,F.jsx)(d,{asChild:!0,children:(0,F.jsx)(y,{variant:`outline`,size:`sm`,onClick:le,className:`h-7 border-destructive/30 text-destructive hover:bg-destructive/10`,children:e(me?`detail.cancelInteractive`:`detail.cancelJob`)})}),(0,F.jsx)(h,{children:e(`detail.cancelJobTooltip`)})]})]})]}),(0,F.jsx)(t,{phases:R,phaseDefinitions:I})]}),(S.status===`running`||S.status===`completed`||S.status===`failed`)&&(0,F.jsx)(B,{job:S,events:w,defaultOpen:S.status===`completed`||S.status===`running`,pipelineTotals:ve??void 0,phases:R,phaseDefinitions:I}),(0,F.jsx)(`div`,{className:`flex-1 overflow-hidden relative`,children:_e?(0,F.jsx)(n,{events:w,jobStatus:S.status,variant:`page`}):(0,F.jsx)(r,{events:w})}),he&&(0,F.jsx)(i,{jobId:S.id,settleMode:S.interactiveSettleMode,initialAcceptingTurns:S.interactiveAcceptingTurns,kind:S.command.startsWith(`loop:`)?`loop-step`:`job`,variant:`page`})]})}export{J as default};