@runfusion/fusion 0.52.0 → 0.53.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 (295) hide show
  1. package/dist/bin.js +3064 -2337
  2. package/dist/client/.vite/manifest.json +248 -248
  3. package/dist/client/assets/{AgentDetailView-C-PM8cwG.js → AgentDetailView-DYiAlisV.js} +3 -3
  4. package/dist/client/assets/AgentPermissionPolicyEditor-CMtzKP_x.js +6 -0
  5. package/dist/client/assets/AgentPermissionPolicyEditor-TpdlOWZW.css +1 -0
  6. package/dist/client/assets/{AgentsView-DJJO0laF.js → AgentsView-YfJlxZoN.js} +3 -3
  7. package/dist/client/assets/ChatView-Diuc5LOe.js +6 -0
  8. package/dist/client/assets/{CommandCenter-CKvo0MuO.js → CommandCenter-CIwFDUKg.js} +2 -2
  9. package/dist/client/assets/{DevServerView-BHLG4Mxg.js → DevServerView-DDRHfATy.js} +1 -1
  10. package/dist/client/assets/{DirectoryPicker-CRY-rpnj.js → DirectoryPicker-C6HRGnSQ.js} +1 -1
  11. package/dist/client/assets/{DocumentsView-DhC4dnXD.js → DocumentsView-C5RTxVSE.js} +1 -1
  12. package/dist/client/assets/{EvalsView-DsnLOVZB.js → EvalsView-B9DCS8sV.js} +1 -1
  13. package/dist/client/assets/{ExperimentalAgentOnboardingModal-B4iFX60E.js → ExperimentalAgentOnboardingModal-DGmpwghz.js} +1 -1
  14. package/dist/client/assets/{GoalsView-D5bzq6W9.js → GoalsView-B2hr3p6f.js} +1 -1
  15. package/dist/client/assets/{InsightsView-Drpu72M4.js → InsightsView-DM3eYN2S.js} +1 -1
  16. package/dist/client/assets/{MemoryView-auLBP3UW.js → MemoryView-8Yg8r9qS.js} +1 -1
  17. package/dist/client/assets/{PiExtensionsManager-RlbkXf_t.js → PiExtensionsManager-DbZ5qtAF.js} +1 -1
  18. package/dist/client/assets/{PluginManager-BJMUacpG.js → PluginManager-C1YuxOWu.js} +1 -1
  19. package/dist/client/assets/{PullRequestView-344B9WF-.js → PullRequestView-CMVvVGaP.js} +1 -1
  20. package/dist/client/assets/{ResearchView-BNqt-f53.js → ResearchView-BjvgxMjL.js} +1 -1
  21. package/dist/client/assets/{SecretsView-Be8Tm8It.js → SecretsView-gChNSW57.js} +1 -1
  22. package/dist/client/assets/SessionTerminal-BSeQ5i5F.js +2 -0
  23. package/dist/client/assets/SettingsModal-CQuHnNXu.js +21 -0
  24. package/dist/client/assets/{SettingsModal-B28DuhaN.js → SettingsModal-_04cEhgW.js} +1 -1
  25. package/dist/client/assets/{SetupWizardModal-y2j9aZoi.js → SetupWizardModal-Dk9VO68p.js} +2 -2
  26. package/dist/client/assets/ShadcnColorPicker-3OgfenMo.css +1 -0
  27. package/dist/client/assets/ShadcnColorPicker-DyPMec2U.js +11 -0
  28. package/dist/client/assets/{SkillsView-HQp7UTdA.js → SkillsView-BAMinq2_.js} +1 -1
  29. package/dist/client/assets/{TodoView-DF7_qWGH.js → TodoView-DaXGwdTQ.js} +1 -1
  30. package/dist/client/assets/WorkflowNodeEditor-DmJI-3Qp.js +8 -0
  31. package/dist/client/assets/{agentSkills-Cy_HrYHd.js → agentSkills-B_n4hPLc.js} +1 -1
  32. package/dist/client/assets/app-5S4z84u5.js +13 -0
  33. package/dist/client/assets/app-B1VYocx2.js +13 -0
  34. package/dist/client/assets/app-BhtYYxin.js +13 -0
  35. package/dist/client/assets/app-Cts0__Vx.js +13 -0
  36. package/dist/client/assets/app-DczBmsP4.js +13 -0
  37. package/dist/client/assets/app-_GFUqcMK.js +13 -0
  38. package/dist/client/assets/{architectureDiagram-3BPJPVTR-4ur4sxlr.js → architectureDiagram-3BPJPVTR-DysoZtiI.js} +1 -1
  39. package/dist/client/assets/{blockDiagram-GPEHLZMM-BgZeqq_q.js → blockDiagram-GPEHLZMM-DpwJlK7i.js} +1 -1
  40. package/dist/client/assets/{c4Diagram-AAUBKEIU-BQtdOIrm.js → c4Diagram-AAUBKEIU-DV115Z4B.js} +1 -1
  41. package/dist/client/assets/channel-BgnsK1mp.js +1 -0
  42. package/dist/client/assets/{chunk-2J33WTMH-C1k1PBy1.js → chunk-2J33WTMH-B5BtZWCx.js} +1 -1
  43. package/dist/client/assets/{chunk-4BX2VUAB-hNujwvSn.js → chunk-4BX2VUAB-CJvgQM9e.js} +1 -1
  44. package/dist/client/assets/{chunk-55IACEB6-CnXV9LyI.js → chunk-55IACEB6-ClrKLhVZ.js} +1 -1
  45. package/dist/client/assets/{chunk-727SXJPM-B-ocMdYN.js → chunk-727SXJPM-DhfUMdP5.js} +1 -1
  46. package/dist/client/assets/{chunk-AQP2D5EJ-CWNRUL6C.js → chunk-AQP2D5EJ-CGKqiWfs.js} +1 -1
  47. package/dist/client/assets/{chunk-FMBD7UC4-DerrCiYe.js → chunk-FMBD7UC4-sLs4-jLA.js} +1 -1
  48. package/dist/client/assets/{chunk-ND2GUHAM-BfcSPlX-.js → chunk-ND2GUHAM-BaptHWZM.js} +1 -1
  49. package/dist/client/assets/{chunk-QZHKN3VN-BaWScAds.js → chunk-QZHKN3VN-CArEOzHE.js} +1 -1
  50. package/dist/client/assets/classDiagram-4FO5ZUOK-ZkHxi9su.js +1 -0
  51. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-ZkHxi9su.js +1 -0
  52. package/dist/client/assets/{cose-bilkent-S5V4N54A-n0Oeinz2.js → cose-bilkent-S5V4N54A-DZ4jAfQc.js} +1 -1
  53. package/dist/client/assets/{dagre-BM42HDAG-CUtehSt2.js → dagre-BM42HDAG-CMhtRslH.js} +1 -1
  54. package/dist/client/assets/{dashboard-view-BW3GHqgb.js → dashboard-view-Bc5cz2DG.js} +1 -1
  55. package/dist/client/assets/{dashboard-view-DWKCxtr5.js → dashboard-view-Buq7raMZ.js} +1 -1
  56. package/dist/client/assets/{diagram-2AECGRRQ-Bz4aOzhR.js → diagram-2AECGRRQ-6uVCJGM-.js} +1 -1
  57. package/dist/client/assets/{diagram-5GNKFQAL-UoxIMwPf.js → diagram-5GNKFQAL-fRigQDqm.js} +1 -1
  58. package/dist/client/assets/{diagram-KO2AKTUF-BYR7hloS.js → diagram-KO2AKTUF-DeLeKk1C.js} +1 -1
  59. package/dist/client/assets/{diagram-LMA3HP47-BR9MaP8U.js → diagram-LMA3HP47-BVRY5C4e.js} +1 -1
  60. package/dist/client/assets/{diagram-OG6HWLK6-BOfldYHv.js → diagram-OG6HWLK6-DdP1xMRM.js} +1 -1
  61. package/dist/client/assets/{erDiagram-TEJ5UH35-B8x9mfOs.js → erDiagram-TEJ5UH35-BU5DG9IX.js} +1 -1
  62. package/dist/client/assets/{flowDiagram-I6XJVG4X-DBnTroCV.js → flowDiagram-I6XJVG4X-CFSihB_T.js} +1 -1
  63. package/dist/client/assets/{folder-open-CFze34Eq.js → folder-open-CV5ek-IV.js} +1 -1
  64. package/dist/client/assets/{ganttDiagram-6RSMTGT7-BfzFy7iz.js → ganttDiagram-6RSMTGT7-BFVLXtHC.js} +1 -1
  65. package/dist/client/assets/{gitGraphDiagram-PVQCEYII-CNTFu6IY.js → gitGraphDiagram-PVQCEYII-TiwSURa4.js} +1 -1
  66. package/dist/client/assets/index-CEUULqTR.js +1336 -0
  67. package/dist/client/assets/index-D1IHwGhg.css +1 -0
  68. package/dist/client/assets/{infoDiagram-5YYISTIA-DJiBRaAl.js → infoDiagram-5YYISTIA-Drkf3o26.js} +1 -1
  69. package/dist/client/assets/{ishikawaDiagram-YF4QCWOH-CIY9t4cc.js → ishikawaDiagram-YF4QCWOH-a9ZSlbx2.js} +1 -1
  70. package/dist/client/assets/{journeyDiagram-JHISSGLW-HLMZmcjY.js → journeyDiagram-JHISSGLW-DF_3fPPW.js} +1 -1
  71. package/dist/client/assets/{kanban-definition-UN3LZRKU-x9nKoxCI.js → kanban-definition-UN3LZRKU-B6dXVyXh.js} +1 -1
  72. package/dist/client/assets/{mermaid.core-pHkdB6fb.js → mermaid.core-BGFpwAba.js} +4 -4
  73. package/dist/client/assets/{mindmap-definition-RKZ34NQL-Bs_4Tofu.js → mindmap-definition-RKZ34NQL-D5bZ0zCy.js} +1 -1
  74. package/dist/client/assets/{pieDiagram-4H26LBE5-BGHz9JGZ.js → pieDiagram-4H26LBE5-Dh6rUd7R.js} +1 -1
  75. package/dist/client/assets/{quadrantDiagram-W4KKPZXB-xHSR7cAR.js → quadrantDiagram-W4KKPZXB-D9Fy6Nl1.js} +1 -1
  76. package/dist/client/assets/{requirementDiagram-4Y6WPE33-D7YMNM44.js → requirementDiagram-4Y6WPE33-Bky271Dr.js} +1 -1
  77. package/dist/client/assets/{sankeyDiagram-5OEKKPKP-OAXuab3Y.js → sankeyDiagram-5OEKKPKP-Cs9Bx7N3.js} +1 -1
  78. package/dist/client/assets/{sequenceDiagram-3UESZ5HK-BZCjKFVL.js → sequenceDiagram-3UESZ5HK-BV7DAI0_.js} +1 -1
  79. package/dist/client/assets/{shield-alert-BBK8Risa.js → shield-alert-BEwCrI8k.js} +1 -1
  80. package/dist/client/assets/{stateDiagram-AJRCARHV-COnJQqA4.js → stateDiagram-AJRCARHV-CTvWoU00.js} +1 -1
  81. package/dist/client/assets/{stateDiagram-v2-BHNVJYJU-Diml4Nhm.js → stateDiagram-v2-BHNVJYJU-ZSZ46LWU.js} +1 -1
  82. package/dist/client/assets/{timeline-definition-PNZ67QCA-DHIKvV9L.js → timeline-definition-PNZ67QCA-DSJscSa7.js} +1 -1
  83. package/dist/client/assets/{upload-CqUJUdZW.js → upload-CNW5goS6.js} +1 -1
  84. package/dist/client/assets/{users-CAE-FEzI.js → users-BhzdPkLN.js} +1 -1
  85. package/dist/client/assets/{vennDiagram-CIIHVFJN-o9AxLDoL.js → vennDiagram-CIIHVFJN-CziD-NoU.js} +1 -1
  86. package/dist/client/assets/{wardley-L42UT6IY-B7MIazje.js → wardley-L42UT6IY-Bt1vdMb3.js} +1 -1
  87. package/dist/client/assets/{wardleyDiagram-YWT4CUSO-B6qUJx0N.js → wardleyDiagram-YWT4CUSO-B_Dlx683.js} +1 -1
  88. package/dist/client/assets/{xychartDiagram-2RQKCTM6-13mSXuCA.js → xychartDiagram-2RQKCTM6-cYDRrhyM.js} +1 -1
  89. package/dist/client/index.html +3 -3
  90. package/dist/client/theme-data.css +156 -0
  91. package/dist/client/version.json +1 -1
  92. package/dist/desktop/client/.vite/manifest.json +1652 -0
  93. package/dist/desktop/client/assets/AgentDetailView-BzSyldiW.css +1 -0
  94. package/dist/desktop/client/assets/AgentDetailView-SJpg9JA5.js +18 -0
  95. package/dist/desktop/client/assets/AgentPermissionPolicyEditor-KMUDm0nu.js +6 -0
  96. package/dist/desktop/client/assets/AgentPermissionPolicyEditor-TpdlOWZW.css +1 -0
  97. package/dist/desktop/client/assets/AgentsView-CITigHGD.js +24 -0
  98. package/dist/desktop/client/assets/AgentsView-CzMa5Olf.css +1 -0
  99. package/dist/desktop/client/assets/ChatView-D_2wBIIx.css +1 -0
  100. package/dist/desktop/client/assets/ChatView-EeFLKmZB.js +6 -0
  101. package/dist/desktop/client/assets/CommandCenter-B9q-zM9p.css +1 -0
  102. package/dist/desktop/client/assets/CommandCenter-DmqJyMvs.js +71 -0
  103. package/dist/desktop/client/assets/DevServerView-Ckhpio_x.js +1 -0
  104. package/dist/desktop/client/assets/DevServerView-iBondC7z.css +1 -0
  105. package/dist/desktop/client/assets/DirectoryPicker-0rspvcMz.css +1 -0
  106. package/dist/desktop/client/assets/DirectoryPicker-j-rxo0kC.js +1 -0
  107. package/dist/desktop/client/assets/DocumentsView-DCS-N7cU.js +1 -0
  108. package/dist/desktop/client/assets/EvalsView-CTbgPUne.css +1 -0
  109. package/dist/desktop/client/assets/EvalsView-Dd26ipFU.js +1 -0
  110. package/dist/desktop/client/assets/ExperimentalAgentOnboardingModal-3ZEFv8sr.css +1 -0
  111. package/dist/desktop/client/assets/ExperimentalAgentOnboardingModal-BqgWIa9n.js +1 -0
  112. package/dist/desktop/client/assets/GoalsView-4-eEOeqw.css +1 -0
  113. package/dist/desktop/client/assets/GoalsView-C5gWzKqI.js +2 -0
  114. package/dist/desktop/client/assets/InsightsView-2SPZDH3m.js +11 -0
  115. package/dist/desktop/client/assets/InsightsView-C7yRTMPn.css +1 -0
  116. package/dist/desktop/client/assets/MemoryView-CBDUr2Jy.css +1 -0
  117. package/dist/desktop/client/assets/MemoryView-D2OAkbGv.js +2 -0
  118. package/dist/desktop/client/assets/PiExtensionsManager-DLrKJDwr.js +11 -0
  119. package/dist/desktop/client/assets/PiExtensionsManager-kgTOHPE9.css +1 -0
  120. package/dist/desktop/client/assets/PluginManager-B0CMG4RR.js +1 -0
  121. package/dist/desktop/client/assets/PluginManager-DSiHizRD.css +1 -0
  122. package/dist/desktop/client/assets/PullRequestView-DhTrKHeu.js +6 -0
  123. package/dist/desktop/client/assets/PullRequestView-NkeImY1n.css +1 -0
  124. package/dist/desktop/client/assets/ResearchView-BQwV9L4h.js +1 -0
  125. package/dist/desktop/client/assets/ResearchView-DIVNQF4_.css +1 -0
  126. package/dist/desktop/client/assets/SecretsView-Boby9tkU.js +1 -0
  127. package/dist/desktop/client/assets/SecretsView-CvFioX7R.css +1 -0
  128. package/dist/desktop/client/assets/SessionTerminal-CPbzm5Oi.css +1 -0
  129. package/dist/desktop/client/assets/SessionTerminal-CT_DUO7z.js +2 -0
  130. package/dist/desktop/client/assets/SettingsModal-BzZNPNIh.css +1 -0
  131. package/dist/desktop/client/assets/SettingsModal-CaE4JYxi.css +1 -0
  132. package/dist/desktop/client/assets/SettingsModal-CvsRQchW.js +1 -0
  133. package/dist/desktop/client/assets/SettingsModal-Dijfj3cb.js +21 -0
  134. package/dist/desktop/client/assets/SetupWizardModal-BIiJIXkh.js +2 -0
  135. package/dist/desktop/client/assets/ShadcnColorPicker-0ZZqsOqD.js +11 -0
  136. package/dist/desktop/client/assets/ShadcnColorPicker-3OgfenMo.css +1 -0
  137. package/dist/desktop/client/assets/SkillsView-Pzo5lSju.js +1 -0
  138. package/dist/desktop/client/assets/SkillsView-tAW7TTCz.css +1 -0
  139. package/dist/desktop/client/assets/TodoView--YoVYWvw.css +1 -0
  140. package/dist/desktop/client/assets/TodoView-ClCgLTmi.js +6 -0
  141. package/dist/desktop/client/assets/WorkflowNodeEditor-8XHmq-V2.js +8 -0
  142. package/dist/desktop/client/assets/WorkflowNodeEditor-Df-_206_.css +1 -0
  143. package/dist/desktop/client/assets/addon-fit-C1WQXRvu.js +1 -0
  144. package/dist/desktop/client/assets/addon-unicode11-BVmNDUBM.js +1 -0
  145. package/dist/desktop/client/assets/addon-web-links-CkVew5xs.js +1 -0
  146. package/dist/desktop/client/assets/addon-webgl-uLc0RKcC.js +58 -0
  147. package/dist/desktop/client/assets/agentSkills-D5osLOR5.js +1 -0
  148. package/dist/desktop/client/assets/agentSkills-bQJ4X1gH.css +1 -0
  149. package/dist/desktop/client/assets/agentsOrgChartLayout-BMvyuaLA.js +1 -0
  150. package/dist/desktop/client/assets/app-5S4z84u5.js +13 -0
  151. package/dist/desktop/client/assets/app-B1VYocx2.js +13 -0
  152. package/dist/desktop/client/assets/app-BhtYYxin.js +13 -0
  153. package/dist/desktop/client/assets/app-Cts0__Vx.js +13 -0
  154. package/dist/desktop/client/assets/app-DczBmsP4.js +13 -0
  155. package/dist/desktop/client/assets/app-_GFUqcMK.js +13 -0
  156. package/dist/desktop/client/assets/arc-cxkkNsnK.js +1 -0
  157. package/dist/desktop/client/assets/architectureDiagram-3BPJPVTR-CrjMDhPI.js +36 -0
  158. package/dist/desktop/client/assets/band-CquvqAHh.js +1 -0
  159. package/dist/desktop/client/assets/blockDiagram-GPEHLZMM-CTQo88ZR.js +132 -0
  160. package/dist/desktop/client/assets/c4Diagram-AAUBKEIU-YjMRExC0.js +10 -0
  161. package/dist/desktop/client/assets/channel-ByWi0lfq.js +1 -0
  162. package/dist/desktop/client/assets/chunk-2J33WTMH-O2741OpT.js +1 -0
  163. package/dist/desktop/client/assets/chunk-4BX2VUAB-E8A3umbR.js +1 -0
  164. package/dist/desktop/client/assets/chunk-55IACEB6-B052cwdC.js +1 -0
  165. package/dist/desktop/client/assets/chunk-727SXJPM-BKI0HQTP.js +206 -0
  166. package/dist/desktop/client/assets/chunk-AQP2D5EJ-DegV3EMW.js +231 -0
  167. package/dist/desktop/client/assets/chunk-FMBD7UC4-B7tLsOki.js +15 -0
  168. package/dist/desktop/client/assets/chunk-ND2GUHAM-2xF-Tg95.js +1 -0
  169. package/dist/desktop/client/assets/chunk-QZHKN3VN-DUl8dvkQ.js +1 -0
  170. package/dist/desktop/client/assets/classDiagram-4FO5ZUOK-C6nL18EV.js +1 -0
  171. package/dist/desktop/client/assets/classDiagram-v2-Q7XG4LA2-C6nL18EV.js +1 -0
  172. package/dist/desktop/client/assets/common-BDp2y6CF.js +1 -0
  173. package/dist/desktop/client/assets/common-BnEo5fLN.js +1 -0
  174. package/dist/desktop/client/assets/common-Bzr_Y8h4.js +1 -0
  175. package/dist/desktop/client/assets/common-CvwyFzfv.js +1 -0
  176. package/dist/desktop/client/assets/common-CztCXRkz.js +1 -0
  177. package/dist/desktop/client/assets/common-DPe2mbb7.js +1 -0
  178. package/dist/desktop/client/assets/cose-bilkent-S5V4N54A-DWz6vuMa.js +1 -0
  179. package/dist/desktop/client/assets/cytoscape.esm-OyMbaexL.js +331 -0
  180. package/dist/desktop/client/assets/dagre-BM42HDAG-GgO-3j8E.js +4 -0
  181. package/dist/desktop/client/assets/dashboard-view-CosTtyxo.js +1 -0
  182. package/dist/desktop/client/assets/dashboard-view-CuUPQZzi.css +1 -0
  183. package/dist/desktop/client/assets/dashboard-view-Cw1KM3Az.js +8161 -0
  184. package/dist/desktop/client/assets/dashboard-view-D_zsA-kz.css +1 -0
  185. package/dist/desktop/client/assets/defaultLocale-DX6XiGOO.js +1 -0
  186. package/dist/desktop/client/assets/diagram-2AECGRRQ-BZQIXBBG.js +43 -0
  187. package/dist/desktop/client/assets/diagram-5GNKFQAL-B1pdxoln.js +10 -0
  188. package/dist/desktop/client/assets/diagram-KO2AKTUF-B2lApC5l.js +3 -0
  189. package/dist/desktop/client/assets/diagram-LMA3HP47-BRqKMh4D.js +24 -0
  190. package/dist/desktop/client/assets/diagram-OG6HWLK6-Dl7BJ0tE.js +24 -0
  191. package/dist/desktop/client/assets/erDiagram-TEJ5UH35-DS6QZa9s.js +85 -0
  192. package/dist/desktop/client/assets/errors-07IrmOYM.js +1 -0
  193. package/dist/desktop/client/assets/errors-BPsCufin.js +1 -0
  194. package/dist/desktop/client/assets/errors-CcVDgqlA.js +1 -0
  195. package/dist/desktop/client/assets/errors-D-i_Bxc6.js +1 -0
  196. package/dist/desktop/client/assets/errors-DDdWAK-U.js +1 -0
  197. package/dist/desktop/client/assets/errors-DOF5Td3F.js +1 -0
  198. package/dist/desktop/client/assets/flowDiagram-I6XJVG4X-Zk7IzQc2.js +162 -0
  199. package/dist/desktop/client/assets/folder-open-BhDX2lOd.js +6 -0
  200. package/dist/desktop/client/assets/ganttDiagram-6RSMTGT7-CJuYCcjE.js +292 -0
  201. package/dist/desktop/client/assets/gitGraphDiagram-PVQCEYII-BmCm6tvH.js +106 -0
  202. package/dist/desktop/client/assets/graph--OzhPTMs.js +1 -0
  203. package/dist/desktop/client/assets/index-BCe5TILt.css +1 -0
  204. package/dist/desktop/client/assets/index-CoS-MsCg.js +1336 -0
  205. package/dist/desktop/client/assets/infoDiagram-5YYISTIA-Ds6lrlTh.js +2 -0
  206. package/dist/desktop/client/assets/init-Dmth1JHB.js +1 -0
  207. package/dist/desktop/client/assets/ishikawaDiagram-YF4QCWOH-D3deq-vb.js +70 -0
  208. package/dist/desktop/client/assets/journeyDiagram-JHISSGLW-BuHVkT2m.js +139 -0
  209. package/dist/desktop/client/assets/kanban-definition-UN3LZRKU-DdoE5oU5.js +89 -0
  210. package/dist/desktop/client/assets/katex-HP8lGamR.js +257 -0
  211. package/dist/desktop/client/assets/layout-SsrduOYp.js +1 -0
  212. package/dist/desktop/client/assets/linear-CwI45w2t.js +1 -0
  213. package/dist/desktop/client/assets/mermaid.core-_nbzHc5D.js +309 -0
  214. package/dist/desktop/client/assets/mindmap-definition-RKZ34NQL-Bq-XuCz_.js +96 -0
  215. package/dist/desktop/client/assets/ordinal-DILIJJjt.js +1 -0
  216. package/dist/desktop/client/assets/pieDiagram-4H26LBE5-BgcfpW6J.js +30 -0
  217. package/dist/desktop/client/assets/projectDetection-G3XuxD2X.js +1 -0
  218. package/dist/desktop/client/assets/quadrantDiagram-W4KKPZXB-Xys80jUW.js +7 -0
  219. package/dist/desktop/client/assets/requirementDiagram-4Y6WPE33-C8S5lJeA.js +84 -0
  220. package/dist/desktop/client/assets/sankeyDiagram-5OEKKPKP-B_3GGQyd.js +40 -0
  221. package/dist/desktop/client/assets/sequenceDiagram-3UESZ5HK-DIu6iwmX.js +162 -0
  222. package/dist/desktop/client/assets/shield-alert-BHWZI_om.js +6 -0
  223. package/dist/desktop/client/assets/stateDiagram-AJRCARHV-CnaR2a9t.js +1 -0
  224. package/dist/desktop/client/assets/stateDiagram-v2-BHNVJYJU-VHc1xbe0.js +1 -0
  225. package/dist/desktop/client/assets/step-yuy0qJer.js +1 -0
  226. package/dist/desktop/client/assets/time-Ckmi30gH.js +1 -0
  227. package/dist/desktop/client/assets/timeline-definition-PNZ67QCA-BrtDAg8s.js +120 -0
  228. package/dist/desktop/client/assets/upload-DOLP3Bv3.js +6 -0
  229. package/dist/desktop/client/assets/users-2kEJQeOu.js +6 -0
  230. package/dist/desktop/client/assets/vendor-codemirror-jBKmHyH0.js +27 -0
  231. package/dist/desktop/client/assets/vendor-i18n-GF3RlKbq.js +9 -0
  232. package/dist/desktop/client/assets/vendor-react-SZ_qB27O.js +49 -0
  233. package/dist/desktop/client/assets/vendor-reactflow-C5ap-Sga.css +1 -0
  234. package/dist/desktop/client/assets/vendor-reactflow-CnI7NMXG.js +15 -0
  235. package/dist/desktop/client/assets/vendor-xterm-BNq00GSj.js +9 -0
  236. package/dist/desktop/client/assets/vendor-xterm-LZoznX6r.css +32 -0
  237. package/dist/desktop/client/assets/vennDiagram-CIIHVFJN-CVjr2RxJ.js +34 -0
  238. package/dist/desktop/client/assets/wardley-L42UT6IY-CVstgB5f.js +173 -0
  239. package/dist/desktop/client/assets/wardleyDiagram-YWT4CUSO-Da3szr-D.js +78 -0
  240. package/dist/desktop/client/assets/xychartDiagram-2RQKCTM6-B0o0ggVt.js +7 -0
  241. package/dist/desktop/client/assets/zoom-out-NWbVkreR.js +41 -0
  242. package/dist/desktop/client/brands/hermes-logo.svg +1 -0
  243. package/dist/desktop/client/fonts/SymbolsNerdFontMono-Regular.ttf +0 -0
  244. package/dist/desktop/client/icons/icon-192.png +0 -0
  245. package/dist/desktop/client/icons/icon-512.png +0 -0
  246. package/dist/desktop/client/index.html +244 -0
  247. package/dist/desktop/client/logo.svg +6 -0
  248. package/dist/desktop/client/manifest.json +23 -0
  249. package/dist/desktop/client/sw.js +175 -0
  250. package/dist/desktop/client/theme-data.css +7154 -0
  251. package/dist/desktop/client/version.json +1 -0
  252. package/dist/desktop/main.js +1661 -0
  253. package/dist/desktop/main.js.map +7 -0
  254. package/dist/desktop/preload.js +110 -0
  255. package/dist/desktop/preload.js.map +7 -0
  256. package/dist/droid-cli/package.json +1 -1
  257. package/dist/extension.js +1692 -1418
  258. package/dist/pi-claude-cli/index.ts +40 -8
  259. package/dist/pi-claude-cli/package.json +5 -3
  260. package/dist/pi-claude-cli/src/__tests__/process-manager.test.ts +2 -2
  261. package/dist/pi-claude-cli/src/__tests__/provider.test.ts +39 -23
  262. package/dist/plugin-sdk/index.d.ts +9 -2
  263. package/dist/plugins/fusion-plugin-acp-runtime/package.json +1 -1
  264. package/dist/plugins/fusion-plugin-cli-printing-press/package.json +1 -1
  265. package/dist/plugins/fusion-plugin-compound-engineering/bundled.js +15 -3
  266. package/dist/plugins/fusion-plugin-compound-engineering/package.json +1 -1
  267. package/dist/plugins/fusion-plugin-cursor-runtime/package.json +1 -1
  268. package/dist/plugins/fusion-plugin-dependency-graph/package.json +1 -1
  269. package/dist/plugins/fusion-plugin-droid-runtime/package.json +1 -1
  270. package/dist/plugins/fusion-plugin-hermes-runtime/package.json +1 -1
  271. package/dist/plugins/fusion-plugin-openclaw-runtime/package.json +1 -1
  272. package/dist/plugins/fusion-plugin-paperclip-runtime/package.json +1 -1
  273. package/dist/plugins/fusion-plugin-reports/package.json +1 -1
  274. package/dist/plugins/fusion-plugin-roadmap/package.json +1 -1
  275. package/dist/plugins/fusion-plugin-whatsapp-chat/package.json +1 -1
  276. package/package.json +4 -3
  277. package/dist/client/assets/AgentPermissionPolicyEditor-CGxjOr6G.css +0 -1
  278. package/dist/client/assets/AgentPermissionPolicyEditor-DrVW4VPc.js +0 -6
  279. package/dist/client/assets/ChatView-C7uTm5hO.js +0 -16
  280. package/dist/client/assets/SessionTerminal-CumHUelZ.js +0 -2
  281. package/dist/client/assets/SettingsModal-AJfer-ve.js +0 -21
  282. package/dist/client/assets/ShadcnColorPicker-Cc72uPKJ.js +0 -11
  283. package/dist/client/assets/ShadcnColorPicker-CyeAnJUU.css +0 -1
  284. package/dist/client/assets/WorkflowNodeEditor-BjpqTIYE.js +0 -8
  285. package/dist/client/assets/app-CGubyqAW.js +0 -13
  286. package/dist/client/assets/app-CrQpHbIs.js +0 -13
  287. package/dist/client/assets/app-DboK-0Ty.js +0 -13
  288. package/dist/client/assets/app-DjnYET2y.js +0 -13
  289. package/dist/client/assets/app-MacS555z.js +0 -13
  290. package/dist/client/assets/app-nvVayIeU.js +0 -13
  291. package/dist/client/assets/channel-Dn5XowfJ.js +0 -1
  292. package/dist/client/assets/classDiagram-4FO5ZUOK-zSOW-KNk.js +0 -1
  293. package/dist/client/assets/classDiagram-v2-Q7XG4LA2-zSOW-KNk.js +0 -1
  294. package/dist/client/assets/index-QnHUwSjw.css +0 -1
  295. package/dist/client/assets/index-Y-vyXPPN.js +0 -1331
@@ -1,4 +1,4 @@
1
- import{r as f,j as s,g as nn,a as Dx,b as Al,c as Lx}from"./vendor-react-SZ_qB27O.js";import{c as yi,gK as Rx,ds as eh,L as El,q as gi,gL as bi,a7 as _l,gM as Ml,ae as th,gN as fu,R as Gr,gO as rh,dz as $x,aR as nh,aV as ah,bp as Bx,al as Tl,cl as Il,cm as Fx,gP as zx,f as Kx,f7 as Vx,gQ as Ux,u as ih,gR as qx,gS as Wx,bM as mu,gT as vu,fv as Hx,gU as Gx,ai as Xx,o as xi,G as Yx,gV as us,gW as Zx,gX as Jx,gY as Qx,gZ as ej,g_ as tj,g$ as rj,dW as sh,h0 as oh,h1 as hu,bU as Aa,h2 as To,h3 as lh,h4 as Io,ak as ch,bN as uh,a3 as nj,cn as dh,dl as aj,J as Do,b$ as ij,P as Ea,fi as fh,ee as sj,h5 as oj,I as lj,eq as pu,X as wa,D as cj,F as uj,am as yu,aJ as dj,h6 as gu,h7 as fj,h8 as mj,h9 as vj,ha as hj,du as pj}from"./index-Y-vyXPPN.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import{a as mh,b as vh,p as yj,w as gj}from"./vendor-reactflow-CnI7NMXG.js";import{w as hh,n as ph,a as Ae,A as Dl,G as bj,H as xj,l as yh,t as ji,b as wt,p as Lo,s as _a,c as gh,q as jj,r as wj,u as Cj,v as kj,x as Pj,y as Sj,z as Nj,C as Oj,D as Aj,k as Ej,E as _j,F as Mj}from"./step-yuy0qJer.js";import{b as Tj,p as Ij}from"./band-CquvqAHh.js";import{d as Ma,n as Dj,e as Lj,f as Ro,g as Ir,h as Ll,a as Rl,i as bu,j as Bt,c as Rj,k as wi,l as $j,m as Bj}from"./linear-CwI45w2t.js";import{i as sr,a as qt}from"./init-Dmth1JHB.js";import{m as xu,a as ju,p as Fj,q as zj,u as Kj,s as Vj,r as Uj,v as qj,w as Wj,x as Hj,y as Gj,z as Xj,A as Yj,B as Zj,t as Jj}from"./time-Ckmi30gH.js";import{f as Qj,b as e0}from"./defaultLocale-DX6XiGOO.js";import{i as t0,o as r0}from"./ordinal-DILIJJjt.js";import{r as n0}from"./agentsOrgChartLayout-BMvyuaLA.js";import{S as a0}from"./shield-alert-BBK8Risa.js";import{C as Lt,T as i0,a as s0}from"./ShadcnColorPicker-Cc72uPKJ.js";import{v as o0}from"./projectDetection-G3XuxD2X.js";import{U as bh}from"./upload-CqUJUdZW.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
1
+ import{r as f,j as s,g as nn,a as Dx,b as Al,c as Lx}from"./vendor-react-SZ_qB27O.js";import{c as yi,gK as Rx,ds as eh,L as El,q as gi,gL as bi,a7 as _l,gM as Ml,ae as th,gN as fu,R as Gr,gO as rh,dz as $x,aR as nh,aV as ah,bp as Bx,al as Tl,cl as Il,cm as Fx,gP as zx,f as Kx,f7 as Vx,gQ as Ux,u as ih,gR as qx,gS as Wx,bM as mu,gT as vu,fv as Hx,gU as Gx,ai as Xx,o as xi,G as Yx,gV as us,gW as Zx,gX as Jx,gY as Qx,gZ as ej,g_ as tj,g$ as rj,dW as sh,h0 as oh,h1 as hu,bU as Aa,h2 as To,h3 as lh,h4 as Io,ak as ch,bN as uh,a3 as nj,cn as dh,dl as aj,J as Do,b$ as ij,P as Ea,fi as fh,h5 as sj,h6 as oj,I as lj,er as pu,X as wa,D as cj,F as uj,am as yu,aJ as dj,h7 as gu,h8 as fj,h9 as mj,ha as vj,hb as hj,du as pj}from"./index-CEUULqTR.js";import{u as le}from"./vendor-i18n-GF3RlKbq.js";import{a as mh,b as vh,p as yj,w as gj}from"./vendor-reactflow-CnI7NMXG.js";import{w as hh,n as ph,a as Ae,A as Dl,G as bj,H as xj,l as yh,t as ji,b as wt,p as Lo,s as _a,c as gh,q as jj,r as wj,u as Cj,v as kj,x as Pj,y as Sj,z as Nj,C as Oj,D as Aj,k as Ej,E as _j,F as Mj}from"./step-yuy0qJer.js";import{b as Tj,p as Ij}from"./band-CquvqAHh.js";import{d as Ma,n as Dj,e as Lj,f as Ro,g as Ir,h as Ll,a as Rl,i as bu,j as Bt,c as Rj,k as wi,l as $j,m as Bj}from"./linear-CwI45w2t.js";import{i as sr,a as qt}from"./init-Dmth1JHB.js";import{m as xu,a as ju,p as Fj,q as zj,u as Kj,s as Vj,r as Uj,v as qj,w as Wj,x as Hj,y as Gj,z as Xj,A as Yj,B as Zj,t as Jj}from"./time-Ckmi30gH.js";import{f as Qj,b as e0}from"./defaultLocale-DX6XiGOO.js";import{i as t0,o as r0}from"./ordinal-DILIJJjt.js";import{r as n0}from"./agentsOrgChartLayout-BMvyuaLA.js";import{S as a0}from"./shield-alert-BEwCrI8k.js";import{C as Lt,T as i0,a as s0}from"./ShadcnColorPicker-DyPMec2U.js";import{v as o0}from"./projectDetection-G3XuxD2X.js";import{U as bh}from"./upload-CNW5goS6.js";import"./vendor-xterm-BNq00GSj.js";import"./vendor-codemirror-jBKmHyH0.js";/**
2
2
  * @license lucide-react v1.7.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -68,4 +68,4 @@ import{r as f,j as s,g as nn,a as Dx,b as Al,c as Lx}from"./vendor-react-SZ_qB27
68
68
  */var Um;function T1(){if(Um)return me;Um=1;var e=60103,t=60106,r=60107,n=60108,a=60114,i=60109,o=60110,l=60112,c=60113,d=60120,u=60115,m=60116,h=60121,v=60122,y=60117,g=60129,p=60131;if(typeof Symbol=="function"&&Symbol.for){var b=Symbol.for;e=b("react.element"),t=b("react.portal"),r=b("react.fragment"),n=b("react.strict_mode"),a=b("react.profiler"),i=b("react.provider"),o=b("react.context"),l=b("react.forward_ref"),c=b("react.suspense"),d=b("react.suspense_list"),u=b("react.memo"),m=b("react.lazy"),h=b("react.block"),v=b("react.server.block"),y=b("react.fundamental"),g=b("react.debug_trace_mode"),p=b("react.legacy_hidden")}function j(I){if(typeof I=="object"&&I!==null){var D=I.$$typeof;switch(D){case e:switch(I=I.type,I){case r:case a:case n:case c:case d:return I;default:switch(I=I&&I.$$typeof,I){case o:case l:case m:case u:case i:return I;default:return D}}case t:return D}}}var x=i,C=e,w=l,P=r,O=m,k=u,N=t,S=a,A=n,_=c;return me.ContextConsumer=o,me.ContextProvider=x,me.Element=C,me.ForwardRef=w,me.Fragment=P,me.Lazy=O,me.Memo=k,me.Portal=N,me.Profiler=S,me.StrictMode=A,me.Suspense=_,me.isAsyncMode=function(){return!1},me.isConcurrentMode=function(){return!1},me.isContextConsumer=function(I){return j(I)===o},me.isContextProvider=function(I){return j(I)===i},me.isElement=function(I){return typeof I=="object"&&I!==null&&I.$$typeof===e},me.isForwardRef=function(I){return j(I)===l},me.isFragment=function(I){return j(I)===r},me.isLazy=function(I){return j(I)===m},me.isMemo=function(I){return j(I)===u},me.isPortal=function(I){return j(I)===t},me.isProfiler=function(I){return j(I)===a},me.isStrictMode=function(I){return j(I)===n},me.isSuspense=function(I){return j(I)===c},me.isValidElementType=function(I){return typeof I=="string"||typeof I=="function"||I===r||I===a||I===g||I===n||I===c||I===d||I===p||typeof I=="object"&&I!==null&&(I.$$typeof===m||I.$$typeof===u||I.$$typeof===i||I.$$typeof===o||I.$$typeof===l||I.$$typeof===y||I.$$typeof===h||I[0]===v)},me.typeOf=j,me}var qm;function I1(){return qm||(qm=1,bo.exports=T1()),bo.exports}var D1=I1(),Wm=e=>typeof e=="string"?e:e?e.displayName||e.name||"Component":"",Hm=null,xo=null,yb=e=>{if(e===Hm&&Array.isArray(xo))return xo;var t=[];return f.Children.forEach(e,r=>{De(r)||(D1.isFragment(r)?t=t.concat(yb(r.props.children)):t.push(r))}),xo=t,Hm=e,t};function gb(e,t){var r=[],n=[];return Array.isArray(t)?n=t.map(a=>Wm(a)):n=[Wm(t)],yb(e).forEach(a=>{var i=Nr(a,"type.displayName")||Nr(a,"type.name");i&&n.indexOf(i)!==-1&&r.push(a)}),r}var bb=e=>e&&typeof e=="object"&&"clipDot"in e?!!e.clipDot:!0,jo={},Gm;function L1(){return Gm||(Gm=1,(function(e){Object.defineProperty(e,Symbol.toStringTag,{value:"Module"});function t(r){if(typeof r!="object"||r==null)return!1;if(Object.getPrototypeOf(r)===null)return!0;if(Object.prototype.toString.call(r)!=="[object Object]"){const a=r[Symbol.toStringTag];return a==null||!Object.getOwnPropertyDescriptor(r,Symbol.toStringTag)?.writable?!1:r.toString()===`[object ${a}]`}let n=r;for(;Object.getPrototypeOf(n)!==null;)n=Object.getPrototypeOf(n);return Object.getPrototypeOf(r)===n}e.isPlainObject=t})(jo)),jo}var wo,Xm;function R1(){return Xm||(Xm=1,wo=L1().isPlainObject),wo}var $1=R1();const B1=nn($1);var Ym,Zm,Jm,Qm,ev;function tv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function rv(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?tv(Object(r),!0).forEach(function(n){F1(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):tv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function F1(e,t,r){return(t=z1(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function z1(e){var t=K1(e,"string");return typeof t=="symbol"?t:t+""}function K1(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function si(){return si=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},si.apply(null,arguments)}function gn(e,t){return t||(t=e.slice(0)),Object.freeze(Object.defineProperties(e,{raw:{value:Object.freeze(t)}}))}var nv=(e,t,r,n,a)=>{var i=r-n,o;return o=Ne(Ym||(Ym=gn(["M ",",",""])),e,t),o+=Ne(Zm||(Zm=gn(["L ",",",""])),e+r,t),o+=Ne(Jm||(Jm=gn(["L ",",",""])),e+r-i/2,t+a),o+=Ne(Qm||(Qm=gn(["L ",",",""])),e+r-i/2-n,t+a),o+=Ne(ev||(ev=gn(["L ",","," Z"])),e,t),o},V1={x:0,y:0,upperWidth:0,lowerWidth:0,height:0,isUpdateAnimationActive:!1,animationBegin:0,animationDuration:1500,animationEasing:"ease"},U1=e=>{var t=Le(e,V1),{x:r,y:n,upperWidth:a,lowerWidth:i,height:o,className:l}=t,{animationEasing:c,animationDuration:d,animationBegin:u,isUpdateAnimationActive:m}=t,h=f.useRef(null),[v,y]=f.useState(-1),g=f.useRef(a),p=f.useRef(i),b=f.useRef(o),j=f.useRef(r),x=f.useRef(n),C=qi(e,"trapezoid-");if(f.useEffect(()=>{if(h.current&&h.current.getTotalLength)try{var D=h.current.getTotalLength();D&&y(D)}catch{}},[]),r!==+r||n!==+n||a!==+a||i!==+i||o!==+o||a===0&&i===0||o===0)return null;var w=de("recharts-trapezoid",l);if(!m)return f.createElement("g",null,f.createElement("path",si({},Je(t),{className:w,d:nv(r,n,a,i,o)})));var P=g.current,O=p.current,k=b.current,N=j.current,S=x.current,A="0px ".concat(v===-1?1:v,"px"),_="".concat(v,"px ").concat(v,"px"),I=uy(["strokeDasharray"],d,c);return f.createElement(Ui,{animationId:C,key:C,canBegin:v>0,duration:d,easing:c,isActive:m,begin:u},D=>{var F=We(P,a,D),V=We(O,i,D),U=We(k,o,D),te=We(N,r,D),q=We(S,n,D);h.current&&(g.current=F,p.current=V,b.current=U,j.current=te,x.current=q);var ee=D>0?{transition:I,strokeDasharray:_}:{strokeDasharray:A};return f.createElement("path",si({},Je(t),{className:w,d:nv(te,q,F,V,U),ref:h,style:rv(rv({},ee),t.style)}))})},q1=["option","shapeType","activeClassName","inActiveClassName"];function W1(e,t){if(e==null)return{};var r,n,a=H1(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function H1(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function av(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function oi(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?av(Object(r),!0).forEach(function(n){G1(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):av(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function G1(e,t,r){return(t=X1(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function X1(e){var t=Y1(e,"string");return typeof t=="symbol"?t:t+""}function Y1(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function Z1(e,t){return oi(oi({},t),e)}function J1(e,t){return e==="symbols"}function iv(e){var{shapeType:t,elementProps:r}=e;switch(t){case"rectangle":return f.createElement(vy,r);case"trapezoid":return f.createElement(U1,r);case"sector":return f.createElement(gy,r);case"symbols":if(J1(t))return f.createElement(Yl,r);break;case"curve":return f.createElement(mc,r);default:return null}}function Q1(e){return f.isValidElement(e)?e.props:e}function xb(e){var{option:t,shapeType:r,activeClassName:n="recharts-active-shape",inActiveClassName:a="recharts-shape"}=e,i=W1(e,q1),o;if(f.isValidElement(t))o=f.cloneElement(t,oi(oi({},i),Q1(t)));else if(typeof t=="function")o=t(i,i.index);else if(B1(t)&&typeof t!="boolean"){var l=Z1(t,i);o=f.createElement(iv,{shapeType:r,elementProps:l})}else{var c=i;o=f.createElement(iv,{shapeType:r,elementProps:c})}return i.isActive?f.createElement(Qe,{className:n},o):f.createElement(Qe,{className:a},o)}var eM=(e,t,r)=>{var n=ve();return(a,i)=>o=>{e?.(a,i,o),n(wg({activeIndex:String(i),activeDataKey:t,activeCoordinate:a.tooltipPosition,activeGraphicalItemId:r}))}},tM=e=>{var t=ve();return(r,n)=>a=>{e?.(r,n,a),t(nA())}},rM=(e,t,r)=>{var n=ve();return(a,i)=>o=>{e?.(a,i,o),n(aA({activeIndex:String(i),activeDataKey:t,activeCoordinate:a.tooltipPosition,activeGraphicalItemId:r}))}};function jb(e){var{tooltipEntrySettings:t}=e,r=ve(),n=rt(),a=f.useRef(null);return f.useLayoutEffect(()=>{n||(a.current===null?r(QO(t)):a.current!==t&&r(eA({prev:a.current,next:t})),a.current=t)},[t,r,n]),f.useLayoutEffect(()=>()=>{a.current&&(r(tA(a.current)),a.current=null)},[r]),null}function nM(e){var{legendPayload:t}=e,r=ve(),n=rt(),a=f.useRef(null);return f.useLayoutEffect(()=>{n||(a.current===null?r(iy(t)):a.current!==t&&r(sy({prev:a.current,next:t})),a.current=t)},[r,n,t]),f.useLayoutEffect(()=>()=>{a.current&&(r(oy(a.current)),a.current=null)},[r]),null}function aM(e){var{legendPayload:t}=e,r=ve(),n=Y(ge),a=f.useRef(null);return f.useLayoutEffect(()=>{n!=="centric"&&n!=="radial"||(a.current===null?r(iy(t)):a.current!==t&&r(sy({prev:a.current,next:t})),a.current=t)},[r,n,t]),f.useLayoutEffect(()=>()=>{a.current&&(r(oy(a.current)),a.current=null)},[r]),null}var Co,iM=()=>{var[e]=f.useState(()=>An("uid-"));return e},sM=(Co=Lx.useId)!==null&&Co!==void 0?Co:iM;function oM(e,t){var r=sM();return t||(e?"".concat(e,"-").concat(r):r)}var lM=f.createContext(void 0),wb=e=>{var{id:t,type:r,children:n}=e,a=oM("recharts-".concat(r),t);return f.createElement(lM.Provider,{value:a},n(a))},cM={cartesianItems:[],polarItems:[]},Cb=Xe({name:"graphicalItems",initialState:cM,reducers:{addCartesianGraphicalItem:{reducer(e,t){e.cartesianItems.push(t.payload)},prepare:xe()},replaceCartesianGraphicalItem:{reducer(e,t){var{prev:r,next:n}=t.payload,a=pt(e).cartesianItems.indexOf(r);a>-1&&(e.cartesianItems[a]=n)},prepare:xe()},removeCartesianGraphicalItem:{reducer(e,t){var r=pt(e).cartesianItems.indexOf(t.payload);r>-1&&e.cartesianItems.splice(r,1)},prepare:xe()},addPolarGraphicalItem:{reducer(e,t){e.polarItems.push(t.payload)},prepare:xe()},removePolarGraphicalItem:{reducer(e,t){var r=pt(e).polarItems.indexOf(t.payload);r>-1&&e.polarItems.splice(r,1)},prepare:xe()},replacePolarGraphicalItem:{reducer(e,t){var{prev:r,next:n}=t.payload,a=pt(e).polarItems.indexOf(r);a>-1&&(e.polarItems[a]=n)},prepare:xe()}}}),{addCartesianGraphicalItem:uM,replaceCartesianGraphicalItem:dM,removeCartesianGraphicalItem:fM,addPolarGraphicalItem:mM,removePolarGraphicalItem:vM,replacePolarGraphicalItem:hM}=Cb.actions,pM=Cb.reducer,yM=e=>{var t=ve(),r=f.useRef(null);return f.useLayoutEffect(()=>{r.current===null?t(uM(e)):r.current!==e&&t(dM({prev:r.current,next:e})),r.current=e},[t,e]),f.useLayoutEffect(()=>()=>{r.current&&(t(fM(r.current)),r.current=null)},[t]),null},gM=f.memo(yM),bM=e=>{var t=ve(),r=f.useRef(null);return f.useLayoutEffect(()=>{r.current===null?t(mM(e)):r.current!==e&&t(hM({prev:r.current,next:e})),r.current=e},[t,e]),f.useLayoutEffect(()=>()=>{r.current&&(t(vM(r.current)),r.current=null)},[t]),null},xM=f.memo(bM),jM=["key"],wM=["onMouseEnter","onClick","onMouseLeave"],CM=["id"],kM=["id"];function ir(){return ir=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ir.apply(null,arguments)}function ss(e,t){if(e==null)return{};var r,n,a=PM(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function PM(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function sv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ce(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?sv(Object(r),!0).forEach(function(n){SM(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):sv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function SM(e,t,r){return(t=NM(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function NM(e){var t=OM(e,"string");return typeof t=="symbol"?t:t+""}function OM(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function AM(e){var t=f.useMemo(()=>gb(e.children,rs),[e.children]),r=Y(n=>_1(n,e.id,t));return r==null?null:f.createElement(aM,{legendPayload:r})}function EM(e){if(!(e==null||typeof e=="boolean"||typeof e=="function")){if(f.isValidElement(e)){var t,r=(t=e.props)===null||t===void 0?void 0:t.fill;return typeof r=="string"?r:void 0}var{fill:n}=e;return typeof n=="string"?n:void 0}}var _M=f.memo(e=>{var{dataKey:t,nameKey:r,sectors:n,stroke:a,strokeWidth:i,fill:o,name:l,hide:c,tooltipType:d,id:u,activeShape:m}=e,h=EM(m),v=n.map(g=>{var p=g.tooltipPayload;return h==null||p==null?p:p.map(b=>Ce(Ce({},b),{},{color:h,fill:h}))}),y={dataDefinedOnItem:v,getPosition:g=>{var p;return(p=n[Number(g)])===null||p===void 0?void 0:p.tooltipPosition},settings:{stroke:a,strokeWidth:i,fill:o,dataKey:t,nameKey:r,name:Di(l,t),hide:c,type:d,color:o,unit:"",graphicalItemId:u}};return f.createElement(jb,{tooltipEntrySettings:y})}),MM=(e,t)=>e>t?"start":e<t?"end":"middle",TM=(e,t,r)=>ot(typeof t=="function"?t(e):t,r,r*.8),IM=(e,t,r)=>{var{top:n,left:a,width:i,height:o}=t,l=hy(i,o),c=a+ot(e.cx,i,i/2),d=n+ot(e.cy,o,o/2),u=ot(e.innerRadius,l,0),m=TM(r,e.outerRadius,l),h=e.maxRadius||Math.sqrt(i*i+o*o)/2;return{cx:c,cy:d,innerRadius:u,outerRadius:m,maxRadius:h}},DM=(e,t)=>{var r=He(t-e),n=Math.min(Math.abs(t-e),360);return r*n},LM=(e,t)=>{if(f.isValidElement(e))return f.cloneElement(e,t);if(typeof e=="function")return e(t);var r=de("recharts-pie-label-line",typeof e!="boolean"?e.className:""),{key:n}=t,a=ss(t,jM);return f.createElement(mc,ir({},a,{type:"linear",className:r}))},RM=(e,t,r)=>{if(f.isValidElement(e))return f.cloneElement(e,t);var n=r;if(typeof e=="function"&&(n=e(t),f.isValidElement(n)))return n;var a=de("recharts-pie-label-text",hb(e));return f.createElement(ns,ir({},t,{alignmentBaseline:"middle",className:a}),n)};function $M(e){var{sectors:t,props:r,showLabels:n}=e,{label:a,labelLine:i,dataKey:o}=r;if(!n||!a||!t)return null;var l=yt(r),c=Xr(a),d=Xr(i),u=typeof a=="object"&&"offsetRadius"in a&&typeof a.offsetRadius=="number"&&a.offsetRadius||20,m=t.map((h,v)=>{var y=(h.startAngle+h.endAngle)/2,g=Ee(h.cx,h.cy,h.outerRadius+u,y),p=Ce(Ce(Ce(Ce({},l),h),{},{stroke:"none"},c),{},{index:v,textAnchor:MM(g.x,h.cx)},g),b=Ce(Ce(Ce(Ce({},l),h),{},{fill:"none",stroke:h.fill},d),{},{index:v,points:[Ee(h.cx,h.cy,h.outerRadius,y),g],key:"line"});return f.createElement(Ct,{zIndex:Ve.label,key:"label-".concat(h.startAngle,"-").concat(h.endAngle,"-").concat(h.midAngle,"-").concat(v)},f.createElement(Qe,null,i&&LM(i,b),RM(a,p,he(h,o))))});return f.createElement(Qe,{className:"recharts-pie-labels"},m)}function BM(e){var{sectors:t,props:r,showLabels:n}=e,{label:a}=r;return typeof a=="object"&&a!=null&&"position"in a?f.createElement(ub,{label:a}):f.createElement($M,{sectors:t,props:r,showLabels:n})}function FM(e){var{sectors:t,activeShape:r,inactiveShape:n,allOtherPieProps:a,shape:i,id:o}=e,l=Y(rn),c=Y($g),d=Y(Bg),{onMouseEnter:u,onClick:m,onMouseLeave:h}=a,v=ss(a,wM),y=eM(u,a.dataKey,o),g=tM(h),p=rM(m,a.dataKey,o);return t==null||t.length===0?null:f.createElement(f.Fragment,null,t.map((b,j)=>{if(b?.startAngle===0&&b?.endAngle===0&&t.length!==1)return null;var x=d==null||d===o,C=String(j)===l&&(c==null||a.dataKey===c)&&x,w=l?n:null,P=r&&C?r:w,O=Ce(Ce({},b),{},{stroke:b.stroke,tabIndex:-1,[qp]:j,[Wp]:o});return f.createElement(Qe,ir({key:"sector-".concat(b?.startAngle,"-").concat(b?.endAngle,"-").concat(b.midAngle,"-").concat(j),tabIndex:-1,className:"recharts-pie-sector"},Jl(v,b,j),{onMouseEnter:y(b,j),onMouseLeave:g(b,j),onClick:p(b,j)}),f.createElement(xb,ir({option:i??P,index:j,shapeType:"sector",isActive:C},O)))}))}function zM(e){var t,{pieSettings:r,displayedData:n,cells:a,offset:i}=e,{cornerRadius:o,startAngle:l,endAngle:c,dataKey:d,nameKey:u,tooltipType:m}=r,h=Math.abs(r.minAngle),v=DM(l,c),y=Math.abs(v),g=n.length<=1?0:(t=r.paddingAngle)!==null&&t!==void 0?t:0,p=n.filter(k=>he(k,d,0)!==0).length,b=(y>=360?p:p-1)*g,j=n.reduce((k,N)=>{var S=he(N,d,0);return k+(Z(S)?S:0)},0),x=h>0&&j>0&&n.some(k=>{var N=he(k,d,0),S=(Z(N)?N:0)/j;return N!==0&&S*y<h}),C=x?h:0,w=y-p*C-b,P;if(j>0){var O;P=n.map((k,N)=>{var S=he(k,d,0),A=he(k,u,N),_=IM(r,i,k),I=(Z(S)?S:0)/j,D,F=Ce(Ce({},k),a&&a[N]&&a[N].props),V=F!=null&&"fill"in F&&typeof F.fill=="string"?F.fill:r.fill;N?D=O.endAngle+He(v)*g*(S!==0?1:0):D=l;var U=D+He(v)*((S!==0?C:0)+I*w),te=(D+U)/2,q=(_.innerRadius+_.outerRadius)/2,ee=[{name:A,value:S,payload:F,dataKey:d,type:m,color:V,fill:V,graphicalItemId:r.id}],L=Ee(_.cx,_.cy,q,te);return O=Ce(Ce(Ce(Ce({},r.presentationProps),{},{percent:I,cornerRadius:typeof o=="string"?parseFloat(o):o,name:A,tooltipPayload:ee,midAngle:te,middleRadius:q,tooltipPosition:L},F),_),{},{value:S,dataKey:d,startAngle:D,endAngle:U,payload:F,paddingAngle:S!==0?He(v)*g:0}),O})}return P}function KM(e){var{showLabels:t,sectors:r,children:n}=e,a=f.useMemo(()=>!t||!r?[]:r.map(i=>({value:i.value,payload:i.payload,clockWise:!1,parentViewBox:void 0,viewBox:{cx:i.cx,cy:i.cy,innerRadius:i.innerRadius,outerRadius:i.outerRadius,startAngle:i.startAngle,endAngle:i.endAngle,clockWise:!1},fill:i.fill})),[r,t]);return f.createElement(v1,{value:t?a:void 0},n)}function VM(e){var{props:t,previousSectorsRef:r,id:n}=e,{sectors:a,isAnimationActive:i,animationBegin:o,animationDuration:l,animationEasing:c,activeShape:d,inactiveShape:u,onAnimationStart:m,onAnimationEnd:h}=t,v=qi(t,"recharts-pie-"),y=r.current,[g,p]=f.useState(!1),b=f.useCallback(()=>{typeof h=="function"&&h(),p(!1)},[h]),j=f.useCallback(()=>{typeof m=="function"&&m(),p(!0)},[m]);return f.createElement(KM,{showLabels:!g,sectors:a},f.createElement(Ui,{animationId:v,begin:o,duration:l,isActive:i,easing:c,onAnimationStart:j,onAnimationEnd:b,key:v},x=>{var C,w=[],P=a&&a[0],O=(C=P?.startAngle)!==null&&C!==void 0?C:0;return a?.forEach((k,N)=>{var S=y&&y[N],A=N>0?Nr(k,"paddingAngle",0):0;if(S){var _=We(S.endAngle-S.startAngle,k.endAngle-k.startAngle,x),I=Ce(Ce({},k),{},{startAngle:O+A,endAngle:O+_+A});w.push(I),O=I.endAngle}else{var{endAngle:D,startAngle:F}=k,V=We(0,D-F,x),U=Ce(Ce({},k),{},{startAngle:O+A,endAngle:O+V+A});w.push(U),O=U.endAngle}}),r.current=w,f.createElement(Qe,null,f.createElement(FM,{sectors:w,activeShape:d,inactiveShape:u,allOtherPieProps:t,shape:t.shape,id:n}))}),f.createElement(BM,{showLabels:!g,sectors:a,props:t}),t.children)}var UM={animationBegin:400,animationDuration:1500,animationEasing:"ease",cx:"50%",cy:"50%",dataKey:"value",endAngle:360,fill:"#808080",hide:!1,innerRadius:0,isAnimationActive:"auto",label:!1,labelLine:!0,legendType:"rect",minAngle:0,nameKey:"name",outerRadius:"80%",paddingAngle:0,rootTabIndex:0,startAngle:0,stroke:"#fff",zIndex:Ve.area};function qM(e){var{id:t}=e,r=ss(e,CM),{hide:n,className:a,rootTabIndex:i}=e,o=f.useMemo(()=>gb(e.children,rs),[e.children]),l=Y(u=>M1(u,t,o)),c=f.useRef(null),d=de("recharts-pie",a);return n||l==null?(c.current=null,f.createElement(Qe,{tabIndex:i,className:d})):f.createElement(Ct,{zIndex:e.zIndex},f.createElement(_M,{dataKey:e.dataKey,nameKey:e.nameKey,sectors:l,stroke:e.stroke,strokeWidth:e.strokeWidth,fill:e.fill,name:e.name,hide:e.hide,tooltipType:e.tooltipType,id:t,activeShape:e.activeShape}),f.createElement(Qe,{tabIndex:i,className:d},f.createElement(VM,{props:Ce(Ce({},r),{},{sectors:l}),previousSectorsRef:c,id:t})))}function WM(e){var t=Le(e,UM),{id:r}=t,n=ss(t,kM),a=yt(n);return f.createElement(wb,{id:r,type:"pie"},i=>f.createElement(f.Fragment,null,f.createElement(xM,{type:"pie",id:i,data:n.data,dataKey:n.dataKey,hide:n.hide,angleAxisId:0,radiusAxisId:0,name:n.name,nameKey:n.nameKey,tooltipType:n.tooltipType,legendType:n.legendType,fill:n.fill,cx:n.cx,cy:n.cy,startAngle:n.startAngle,endAngle:n.endAngle,paddingAngle:n.paddingAngle,minAngle:n.minAngle,innerRadius:n.innerRadius,outerRadius:n.outerRadius,cornerRadius:n.cornerRadius,presentationProps:a,maxRadius:t.maxRadius}),f.createElement(AM,ir({},n,{id:i})),f.createElement(qM,ir({},n,{id:i}))))}var kb=WM;kb.displayName="Pie";var HM=["points"];function ov(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ko(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?ov(Object(r),!0).forEach(function(n){GM(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ov(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function GM(e,t,r){return(t=XM(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function XM(e){var t=YM(e,"string");return typeof t=="symbol"?t:t+""}function YM(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function li(){return li=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},li.apply(null,arguments)}function ZM(e,t){if(e==null)return{};var r,n,a=JM(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function JM(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function QM(e){var{option:t,dotProps:r,className:n}=e;if(f.isValidElement(t))return f.cloneElement(t,r);if(typeof t=="function")return t(r);var a=de(n,typeof t!="boolean"?t.className:""),i=r??{},{points:o}=i,l=ZM(i,HM);return f.createElement(db,li({},l,{className:a}))}function eT(e,t){return e==null?!1:t?!0:e.length===1}function tT(e){var{points:t,dot:r,className:n,dotClassName:a,dataKey:i,baseProps:o,needClip:l,clipPathId:c,zIndex:d=Ve.scatter}=e;if(!eT(t,r))return null;var u=bb(r),m=nw(r),h=t.map((y,g)=>{var p,b,j=ko(ko(ko({r:3},o),m),{},{index:g,cx:(p=y.x)!==null&&p!==void 0?p:void 0,cy:(b=y.y)!==null&&b!==void 0?b:void 0,dataKey:i,value:y.value,payload:y.payload,points:t});return f.createElement(QM,{key:"dot-".concat(g),option:r,dotProps:j,className:a})}),v={};return l&&c!=null&&(v.clipPath="url(#clipPath-".concat(u?"":"dots-").concat(c,")")),f.createElement(Ct,{zIndex:d},f.createElement(Qe,li({className:n},v),h))}function lv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function cv(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?lv(Object(r),!0).forEach(function(n){rT(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):lv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function rT(e,t,r){return(t=nT(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function nT(e){var t=aT(e,"string");return typeof t=="symbol"?t:t+""}function aT(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var iT={xAxis:{},yAxis:{},zAxis:{}},Pb=Xe({name:"cartesianAxis",initialState:iT,reducers:{addXAxis:{reducer(e,t){e.xAxis[t.payload.id]=t.payload},prepare:xe()},replaceXAxis:{reducer(e,t){var{prev:r,next:n}=t.payload;e.xAxis[r.id]!==void 0&&(r.id!==n.id&&delete e.xAxis[r.id],e.xAxis[n.id]=n)},prepare:xe()},removeXAxis:{reducer(e,t){delete e.xAxis[t.payload.id]},prepare:xe()},addYAxis:{reducer(e,t){e.yAxis[t.payload.id]=t.payload},prepare:xe()},replaceYAxis:{reducer(e,t){var{prev:r,next:n}=t.payload;e.yAxis[r.id]!==void 0&&(r.id!==n.id&&delete e.yAxis[r.id],e.yAxis[n.id]=n)},prepare:xe()},removeYAxis:{reducer(e,t){delete e.yAxis[t.payload.id]},prepare:xe()},addZAxis:{reducer(e,t){e.zAxis[t.payload.id]=t.payload},prepare:xe()},replaceZAxis:{reducer(e,t){var{prev:r,next:n}=t.payload;e.zAxis[r.id]!==void 0&&(r.id!==n.id&&delete e.zAxis[r.id],e.zAxis[n.id]=n)},prepare:xe()},removeZAxis:{reducer(e,t){delete e.zAxis[t.payload.id]},prepare:xe()},updateYAxisWidth(e,t){var{id:r,width:n}=t.payload,a=e.yAxis[r];if(a){var i,o=a.widthHistory||[];if(o.length===3&&o[0]===o[2]&&n===o[1]&&n!==a.width&&Math.abs(n-((i=o[0])!==null&&i!==void 0?i:0))<=1)return;var l=[...o,n].slice(-3);e.yAxis[r]=cv(cv({},a),{},{width:n,widthHistory:l})}}}}),{addXAxis:sT,replaceXAxis:oT,removeXAxis:lT,addYAxis:cT,replaceYAxis:uT,removeYAxis:dT,addZAxis:S2,replaceZAxis:N2,removeZAxis:O2,updateYAxisWidth:fT}=Pb.actions,mT=Pb.reducer,vT=M([Be],e=>({top:e.top,bottom:e.bottom,left:e.left,right:e.right})),hT=M([vT,Ht,Gt],(e,t,r)=>{if(!(!e||t==null||r==null))return{x:e.left,y:e.top,width:Math.max(0,t-e.left-e.right),height:Math.max(0,r-e.top-e.bottom)}}),ru=()=>Y(hT),pT=()=>Y(JA);function uv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Po(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?uv(Object(r),!0).forEach(function(n){yT(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):uv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function yT(e,t,r){return(t=gT(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function gT(e){var t=bT(e,"string");return typeof t=="symbol"?t:t+""}function bT(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var xT=e=>{var{point:t,childIndex:r,mainColor:n,activeDot:a,dataKey:i,clipPath:o}=e;if(a===!1||t.x==null||t.y==null)return null;var l={index:r,dataKey:i,cx:t.x,cy:t.y,r:4,fill:n??"none",strokeWidth:2,stroke:"#fff",payload:t.payload,value:t.value},c=Po(Po(Po({},l),Xr(a)),Zl(a)),d;return f.isValidElement(a)?d=f.cloneElement(a,c):typeof a=="function"?d=a(c):d=f.createElement(db,c),f.createElement(Qe,{className:"recharts-active-dot",clipPath:o},d)};function jT(e){var{points:t,mainColor:r,activeDot:n,itemDataKey:a,clipPath:i,zIndex:o=Ve.activeDot}=e,l=Y(rn),c=pT();if(t==null||c==null)return null;var d=t.find(u=>c.includes(u.payload));return De(d)?null:f.createElement(Ct,{zIndex:o},f.createElement(xT,{point:d,childIndex:Number(l),mainColor:r,dataKey:a,activeDot:n,clipPath:i}))}var Sb=e=>{var{chartData:t}=e,r=ve(),n=rt();return f.useEffect(()=>n?()=>{}:(r(wm(t)),()=>{r(wm(void 0))}),[t,r,n]),null},dv={x:0,y:0,width:0,height:0,padding:{top:0,right:0,bottom:0,left:0}},Nb=Xe({name:"brush",initialState:dv,reducers:{setBrushSettings(e,t){return t.payload==null?dv:t.payload}}}),{setBrushSettings:A2}=Nb.actions,wT=Nb.reducer;function CT(e){return(e%180+180)%180}var kT=function(t){var{width:r,height:n}=t,a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:0,i=CT(a),o=i*Math.PI/180,l=Math.atan(n/r),c=o>l&&o<Math.PI-l?n/Math.sin(o):r/Math.cos(o);return Math.abs(c)},PT={dots:[],areas:[],lines:[]},Ob=Xe({name:"referenceElements",initialState:PT,reducers:{addDot:(e,t)=>{e.dots.push(t.payload)},removeDot:(e,t)=>{var r=pt(e).dots.findIndex(n=>n===t.payload);r!==-1&&e.dots.splice(r,1)},addArea:(e,t)=>{e.areas.push(t.payload)},removeArea:(e,t)=>{var r=pt(e).areas.findIndex(n=>n===t.payload);r!==-1&&e.areas.splice(r,1)},addLine:(e,t)=>{e.lines.push(t.payload)},removeLine:(e,t)=>{var r=pt(e).lines.findIndex(n=>n===t.payload);r!==-1&&e.lines.splice(r,1)}}}),{addDot:E2,removeDot:_2,addArea:M2,removeArea:T2,addLine:I2,removeLine:D2}=Ob.actions,ST=Ob.reducer,NT=f.createContext(void 0),OT=e=>{var{children:t}=e,[r]=f.useState("".concat(An("recharts"),"-clip")),n=ru();if(n==null)return null;var{x:a,y:i,width:o,height:l}=n;return f.createElement(NT.Provider,{value:r},f.createElement("defs",null,f.createElement("clipPath",{id:r},f.createElement("rect",{x:a,y:i,height:l,width:o}))),t)};function Ab(e,t){if(t<1)return[];if(t===1)return e;for(var r=[],n=0;n<e.length;n+=t){var a=e[n];a!==void 0&&r.push(a)}return r}function AT(e,t,r){var n={width:e.width+t.width,height:e.height+t.height};return kT(n,r)}function ET(e,t,r){var n=r==="width",{x:a,y:i,width:o,height:l}=e;return t===1?{start:n?a:i,end:n?a+o:i+l}:{start:n?a+o:i+l,end:n?a:i}}function Bn(e,t,r,n,a){if(e*t<e*n||e*t>e*a)return!1;var i=r();return e*(t-e*i/2-n)>=0&&e*(t+e*i/2-a)<=0}function _T(e,t){return Ab(e,t+1)}function MT(e,t,r,n,a){for(var i=(n||[]).slice(),{start:o,end:l}=t,c=0,d=1,u=o,m=function(){var y=n?.[c];if(y===void 0)return{v:Ab(n,d)};var g=c,p,b=()=>(p===void 0&&(p=r(y,g)),p),j=y.coordinate,x=c===0||Bn(e,j,b,u,l);x||(c=0,u=o,d+=1),x&&(u=j+e*(b()/2+a),c+=d)},h;d<=i.length;)if(h=m(),h)return h.v;return[]}function TT(e,t,r,n,a){var i=(n||[]).slice(),o=i.length;if(o===0)return[];for(var{start:l,end:c}=t,d=1;d<=o;d++){for(var u=(o-1)%d,m=l,h=!0,v=function(){var C=n[g];if(C==null)return 0;var w=g,P,O=()=>(P===void 0&&(P=r(C,w)),P),k=C.coordinate,N=g===u||Bn(e,k,O,m,c);if(!N)return h=!1,1;N&&(m=k+e*(O()/2+a))},y,g=u;g<o&&(y=v(),!(y!==0&&y===1));g+=d);if(h){for(var p=[],b=u;b<o;b+=d){var j=n[b];j!=null&&p.push(j)}return p}}return[]}function fv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Ue(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?fv(Object(r),!0).forEach(function(n){IT(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):fv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function IT(e,t,r){return(t=DT(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function DT(e){var t=LT(e,"string");return typeof t=="symbol"?t:t+""}function LT(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function RT(e,t,r,n,a){for(var i=(n||[]).slice(),o=i.length,{start:l}=t,{end:c}=t,d=function(h){var v=i[h];if(v==null)return 1;var y=v,g,p=()=>(g===void 0&&(g=r(v,h)),g);if(h===o-1){var b=e*(y.coordinate+e*p()/2-c);i[h]=y=Ue(Ue({},y),{},{tickCoord:b>0?y.coordinate-b*e:y.coordinate})}else i[h]=y=Ue(Ue({},y),{},{tickCoord:y.coordinate});if(y.tickCoord!=null){var j=Bn(e,y.tickCoord,p,l,c);j&&(c=y.tickCoord-e*(p()/2+a),i[h]=Ue(Ue({},y),{},{isShow:!0}))}},u=o-1;u>=0;u--)d(u);return i}function $T(e,t,r,n,a,i){var o=(n||[]).slice(),l=o.length,{start:c,end:d}=t;if(i){var u=n[l-1];if(u!=null){var m=r(u,l-1),h=e*(u.coordinate+e*m/2-d);if(o[l-1]=u=Ue(Ue({},u),{},{tickCoord:h>0?u.coordinate-h*e:u.coordinate}),u.tickCoord!=null){var v=Bn(e,u.tickCoord,()=>m,c,d);v&&(d=u.tickCoord-e*(m/2+a),o[l-1]=Ue(Ue({},u),{},{isShow:!0}))}}}for(var y=i?l-1:l,g=function(j){var x=o[j];if(x==null)return 1;var C=x,w,P=()=>(w===void 0&&(w=r(x,j)),w);if(j===0){var O=e*(C.coordinate-e*P()/2-c);o[j]=C=Ue(Ue({},C),{},{tickCoord:O<0?C.coordinate-O*e:C.coordinate})}else o[j]=C=Ue(Ue({},C),{},{tickCoord:C.coordinate});if(C.tickCoord!=null){var k=Bn(e,C.tickCoord,P,c,d);k&&(c=C.tickCoord+e*(P()/2+a),o[j]=Ue(Ue({},C),{},{isShow:!0}))}},p=0;p<y;p++)g(p);return o}function nu(e,t,r){var{tick:n,ticks:a,viewBox:i,minTickGap:o,orientation:l,interval:c,tickFormatter:d,unit:u,angle:m}=e;if(!a||!a.length||!n)return[];if(Z(c)||Xn.isSsr){var h;return(h=_T(a,Z(c)?c:0))!==null&&h!==void 0?h:[]}var v=[],y=l==="top"||l==="bottom"?"width":"height",g=u&&y==="width"?On(u,{fontSize:t,letterSpacing:r}):{width:0,height:0},p=(w,P)=>{var O=typeof d=="function"?d(w.value,P):w.value;return y==="width"?AT(On(O,{fontSize:t,letterSpacing:r}),g,m):On(O,{fontSize:t,letterSpacing:r})[y]},b=a[0],j=a[1],x=a.length>=2&&b!=null&&j!=null?He(j.coordinate-b.coordinate):1,C=ET(i,x,y);return c==="equidistantPreserveStart"?MT(x,C,p,a,o):c==="equidistantPreserveEnd"?TT(x,C,p,a,o):(c==="preserveStart"||c==="preserveStartEnd"?v=$T(x,C,p,a,o,c==="preserveStartEnd"):v=RT(x,C,p,a,o),v.filter(w=>w.isShow))}var BT=e=>{var{ticks:t,label:r,labelGapWithTick:n=5,tickSize:a=0,tickMargin:i=0}=e,o=0;if(t){Array.from(t).forEach(u=>{if(u){var m=u.getBoundingClientRect();m.width>o&&(o=m.width)}});var l=r?r.getBoundingClientRect().width:0,c=a+i,d=o+c+l+(r?n:0);return Math.round(d)}return 0},FT={xAxis:{},yAxis:{}},Eb=Xe({name:"renderedTicks",initialState:FT,reducers:{setRenderedTicks:(e,t)=>{var{axisType:r,axisId:n,ticks:a}=t.payload;e[r][n]=a},removeRenderedTicks:(e,t)=>{var{axisType:r,axisId:n}=t.payload;delete e[r][n]}}}),{setRenderedTicks:zT,removeRenderedTicks:KT}=Eb.actions,VT=Eb.reducer,UT=["axisLine","width","height","className","hide","ticks","axisType","axisId"];function qT(e,t){if(e==null)return{};var r,n,a=WT(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function WT(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function Tr(){return Tr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Tr.apply(null,arguments)}function mv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Se(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?mv(Object(r),!0).forEach(function(n){HT(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):mv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function HT(e,t,r){return(t=GT(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function GT(e){var t=XT(e,"string");return typeof t=="symbol"?t:t+""}function XT(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var zt={x:0,y:0,width:0,height:0,viewBox:{x:0,y:0,width:0,height:0},orientation:"bottom",ticks:[],stroke:"#666",tickLine:!0,axisLine:!0,tick:!0,mirror:!1,minTickGap:5,tickSize:6,tickMargin:2,interval:"preserveEnd",zIndex:Ve.axis};function YT(e){var{x:t,y:r,width:n,height:a,orientation:i,mirror:o,axisLine:l,otherSvgProps:c}=e;if(!l)return null;var d=Se(Se(Se({},c),yt(l)),{},{fill:"none"});if(i==="top"||i==="bottom"){var u=+(i==="top"&&!o||i==="bottom"&&o);d=Se(Se({},d),{},{x1:t,y1:r+u*a,x2:t+n,y2:r+u*a})}else{var m=+(i==="left"&&!o||i==="right"&&o);d=Se(Se({},d),{},{x1:t+m*n,y1:r,x2:t+m*n,y2:r+a})}return f.createElement("line",Tr({},d,{className:de("recharts-cartesian-axis-line",Nr(l,"className"))}))}function ZT(e,t,r,n,a,i,o,l,c){var d,u,m,h,v,y,g=l?-1:1,p=e.tickSize||o,b=Z(e.tickCoord)?e.tickCoord:e.coordinate;switch(i){case"top":d=u=e.coordinate,h=r+ +!l*a,m=h-g*p,y=m-g*c,v=b;break;case"left":m=h=e.coordinate,u=t+ +!l*n,d=u-g*p,v=d-g*c,y=b;break;case"right":m=h=e.coordinate,u=t+ +l*n,d=u+g*p,v=d+g*c,y=b;break;default:d=u=e.coordinate,h=r+ +l*a,m=h+g*p,y=m+g*c,v=b;break}return{line:{x1:d,y1:m,x2:u,y2:h},tick:{x:v,y}}}function JT(e,t){switch(e){case"left":return t?"start":"end";case"right":return t?"end":"start";default:return"middle"}}function QT(e,t){switch(e){case"left":case"right":return"middle";case"top":return t?"start":"end";default:return t?"end":"start"}}function eI(e){var{option:t,tickProps:r,value:n}=e,a,i=de(r.className,"recharts-cartesian-axis-tick-value");if(f.isValidElement(t))a=f.cloneElement(t,Se(Se({},r),{},{className:i}));else if(typeof t=="function")a=t(Se(Se({},r),{},{className:i}));else{var o="recharts-cartesian-axis-tick-value";typeof t!="boolean"&&(o=de(o,hb(t))),a=f.createElement(ns,Tr({},r,{className:o}),n)}return a}function tI(e){var{ticks:t,axisType:r,axisId:n}=e,a=ve();return f.useEffect(()=>{if(n==null||r==null)return Kn;var i=t.map(o=>({value:o.value,coordinate:o.coordinate,offset:o.offset,index:o.index}));return a(zT({ticks:i,axisId:n,axisType:r})),()=>{a(KT({axisId:n,axisType:r}))}},[a,t,n,r]),null}var rI=f.forwardRef((e,t)=>{var{ticks:r=[],tick:n,tickLine:a,stroke:i,tickFormatter:o,unit:l,padding:c,tickTextProps:d,orientation:u,mirror:m,x:h,y:v,width:y,height:g,tickSize:p,tickMargin:b,fontSize:j,letterSpacing:x,getTicksConfig:C,events:w,axisType:P,axisId:O}=e,k=nu(Se(Se({},C),{},{ticks:r}),j,x),N=yt(C),S=Xr(n),A=rb(N.textAnchor)?N.textAnchor:JT(u,m),_=QT(u,m),I={};typeof a=="object"&&(I=a);var D=Se(Se({},N),{},{fill:"none"},I),F=k.map(te=>Se({entry:te},ZT(te,h,v,y,g,u,p,m,b))),V=F.map(te=>{var{entry:q,line:ee}=te;return f.createElement(Qe,{className:"recharts-cartesian-axis-tick",key:"tick-".concat(q.value,"-").concat(q.coordinate,"-").concat(q.tickCoord)},a&&f.createElement("line",Tr({},D,ee,{className:de("recharts-cartesian-axis-tick-line",Nr(a,"className"))})))}),U=F.map((te,q)=>{var ee,L,{entry:B,tick:X}=te,Q=Se(Se(Se(Se({verticalAnchor:_},N),{},{textAnchor:A,stroke:"none",fill:i},X),{},{index:q,payload:B,visibleTicksCount:k.length,tickFormatter:o,padding:c},d),{},{angle:(ee=(L=d?.angle)!==null&&L!==void 0?L:N.angle)!==null&&ee!==void 0?ee:0}),G=Se(Se({},Q),S);return f.createElement(Qe,Tr({className:"recharts-cartesian-axis-tick-label",key:"tick-label-".concat(B.value,"-").concat(B.coordinate,"-").concat(B.tickCoord)},Jl(w,B,q)),n&&f.createElement(eI,{option:n,tickProps:G,value:"".concat(typeof o=="function"?o(B.value,q):B.value).concat(l||"")}))});return f.createElement("g",{className:"recharts-cartesian-axis-ticks recharts-".concat(P,"-ticks")},f.createElement(tI,{ticks:k,axisId:O,axisType:P}),U.length>0&&f.createElement(Ct,{zIndex:Ve.label},f.createElement("g",{className:"recharts-cartesian-axis-tick-labels recharts-".concat(P,"-tick-labels"),ref:t},U)),V.length>0&&f.createElement("g",{className:"recharts-cartesian-axis-tick-lines recharts-".concat(P,"-tick-lines")},V))}),nI=f.forwardRef((e,t)=>{var{axisLine:r,width:n,height:a,className:i,hide:o,ticks:l,axisType:c,axisId:d}=e,u=qT(e,UT),[m,h]=f.useState(""),[v,y]=f.useState(""),g=f.useRef(null);f.useImperativeHandle(t,()=>({getCalculatedWidth:()=>{var b;return BT({ticks:g.current,label:(b=e.labelRef)===null||b===void 0?void 0:b.current,labelGapWithTick:5,tickSize:e.tickSize,tickMargin:e.tickMargin})}}));var p=f.useCallback(b=>{if(b){var j=b.getElementsByClassName("recharts-cartesian-axis-tick-value");g.current=j;var x=j[0];if(x){var C=window.getComputedStyle(x),w=C.fontSize,P=C.letterSpacing;(w!==m||P!==v)&&(h(w),y(P))}}},[m,v]);return o||n!=null&&n<=0||a!=null&&a<=0?null:f.createElement(Ct,{zIndex:e.zIndex},f.createElement(Qe,{className:de("recharts-cartesian-axis",i)},f.createElement(YT,{x:e.x,y:e.y,width:n,height:a,orientation:e.orientation,mirror:e.mirror,axisLine:r,otherSvgProps:yt(e)}),f.createElement(rI,{ref:p,axisType:c,events:u,fontSize:m,getTicksConfig:e,height:e.height,letterSpacing:v,mirror:e.mirror,orientation:e.orientation,padding:e.padding,stroke:e.stroke,tick:e.tick,tickFormatter:e.tickFormatter,tickLine:e.tickLine,tickMargin:e.tickMargin,tickSize:e.tickSize,tickTextProps:e.tickTextProps,ticks:l,unit:e.unit,width:e.width,x:e.x,y:e.y,axisId:d}),f.createElement(J_,{x:e.x,y:e.y,width:e.width,height:e.height,lowerWidth:e.width,upperWidth:e.width},f.createElement(l1,{label:e.label,labelRef:e.labelRef}),e.children)))}),au=f.forwardRef((e,t)=>{var r=Le(e,zt);return f.createElement(nI,Tr({},r,{ref:t}))});au.displayName="CartesianAxis";var aI=["x1","y1","x2","y2","key"],iI=["offset"],sI=["xAxisId","yAxisId"],oI=["xAxisId","yAxisId"];function vv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function qe(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?vv(Object(r),!0).forEach(function(n){lI(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):vv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function lI(e,t,r){return(t=cI(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function cI(e){var t=uI(e,"string");return typeof t=="symbol"?t:t+""}function uI(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function wr(){return wr=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},wr.apply(null,arguments)}function ci(e,t){if(e==null)return{};var r,n,a=dI(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function dI(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var fI=e=>{var{fill:t}=e;if(!t||t==="none")return null;var{fillOpacity:r,x:n,y:a,width:i,height:o,ry:l}=e;return f.createElement("rect",{x:n,y:a,ry:l,width:i,height:o,stroke:"none",fill:t,fillOpacity:r,className:"recharts-cartesian-grid-bg"})};function _b(e){var{option:t,lineItemProps:r}=e,n;if(f.isValidElement(t))n=f.cloneElement(t,r);else if(typeof t=="function")n=t(r);else{var a,{x1:i,y1:o,x2:l,y2:c,key:d}=r,u=ci(r,aI),m=(a=yt(u))!==null&&a!==void 0?a:{},{offset:h}=m,v=ci(m,iI);n=f.createElement("line",wr({},v,{x1:i,y1:o,x2:l,y2:c,fill:"none",key:d}))}return n}function mI(e){var{x:t,width:r,horizontal:n=!0,horizontalPoints:a}=e;if(!n||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=ci(e,sI),c=a.map((d,u)=>{var m=qe(qe({},l),{},{x1:t,y1:d,x2:t+r,y2:d,key:"line-".concat(u),index:u});return f.createElement(_b,{key:"line-".concat(u),option:n,lineItemProps:m})});return f.createElement("g",{className:"recharts-cartesian-grid-horizontal"},c)}function vI(e){var{y:t,height:r,vertical:n=!0,verticalPoints:a}=e;if(!n||!a||!a.length)return null;var{xAxisId:i,yAxisId:o}=e,l=ci(e,oI),c=a.map((d,u)=>{var m=qe(qe({},l),{},{x1:d,y1:t,x2:d,y2:t+r,key:"line-".concat(u),index:u});return f.createElement(_b,{option:n,lineItemProps:m,key:"line-".concat(u)})});return f.createElement("g",{className:"recharts-cartesian-grid-vertical"},c)}function hI(e){var{horizontalFill:t,fillOpacity:r,x:n,y:a,width:i,height:o,horizontalPoints:l,horizontal:c=!0}=e;if(!c||!t||!t.length||l==null)return null;var d=l.map(m=>Math.round(m+a-a)).sort((m,h)=>m-h);a!==d[0]&&d.unshift(0);var u=d.map((m,h)=>{var v=d[h+1],y=v==null,g=y?a+o-m:v-m;if(g<=0)return null;var p=h%t.length;return f.createElement("rect",{key:"react-".concat(h),y:m,x:n,height:g,width:i,stroke:"none",fill:t[p],fillOpacity:r,className:"recharts-cartesian-grid-bg"})});return f.createElement("g",{className:"recharts-cartesian-gridstripes-horizontal"},u)}function pI(e){var{vertical:t=!0,verticalFill:r,fillOpacity:n,x:a,y:i,width:o,height:l,verticalPoints:c}=e;if(!t||!r||!r.length)return null;var d=c.map(m=>Math.round(m+a-a)).sort((m,h)=>m-h);a!==d[0]&&d.unshift(0);var u=d.map((m,h)=>{var v=d[h+1],y=v==null,g=y?a+o-m:v-m;if(g<=0)return null;var p=h%r.length;return f.createElement("rect",{key:"react-".concat(h),x:m,y:i,width:g,height:l,stroke:"none",fill:r[p],fillOpacity:n,className:"recharts-cartesian-grid-bg"})});return f.createElement("g",{className:"recharts-cartesian-gridstripes-vertical"},u)}var yI=(e,t)=>{var{xAxis:r,width:n,height:a,offset:i}=e;return Kp(nu(qe(qe(qe({},zt),r),{},{ticks:Vp(r),viewBox:{x:0,y:0,width:n,height:a}})),i.left,i.left+i.width,t)},gI=(e,t)=>{var{yAxis:r,width:n,height:a,offset:i}=e;return Kp(nu(qe(qe(qe({},zt),r),{},{ticks:Vp(r),viewBox:{x:0,y:0,width:n,height:a}})),i.top,i.top+i.height,t)},bI={horizontal:!0,vertical:!0,horizontalPoints:[],verticalPoints:[],stroke:"#ccc",fill:"none",verticalFill:[],horizontalFill:[],xAxisId:0,yAxisId:0,syncWithTicks:!1,zIndex:Ve.grid};function Mb(e){var t=lc(),r=cc(),n=Xp(),a=qe(qe({},Le(e,bI)),{},{x:Z(e.x)?e.x:n.left,y:Z(e.y)?e.y:n.top,width:Z(e.width)?e.width:n.width,height:Z(e.height)?e.height:n.height}),{xAxisId:i,yAxisId:o,x:l,y:c,width:d,height:u,syncWithTicks:m,horizontalValues:h,verticalValues:v}=a,y=rt(),g=Y(N=>cm(N,"xAxis",i,y)),p=Y(N=>cm(N,"yAxis",o,y));if(!Zr(d)||!Zr(u)||!Z(l)||!Z(c))return null;var b=a.verticalCoordinatesGenerator||yI,j=a.horizontalCoordinatesGenerator||gI,{horizontalPoints:x,verticalPoints:C}=a;if((!x||!x.length)&&typeof j=="function"){var w=h&&h.length,P=j({yAxis:p?qe(qe({},p),{},{ticks:w?h:p.ticks}):void 0,width:t??d,height:r??u,offset:n},w?!0:m);Xd(Array.isArray(P),"horizontalCoordinatesGenerator should return Array but instead it returned [".concat(typeof P,"]")),Array.isArray(P)&&(x=P)}if((!C||!C.length)&&typeof b=="function"){var O=v&&v.length,k=b({xAxis:g?qe(qe({},g),{},{ticks:O?v:g.ticks}):void 0,width:t??d,height:r??u,offset:n},O?!0:m);Xd(Array.isArray(k),"verticalCoordinatesGenerator should return Array but instead it returned [".concat(typeof k,"]")),Array.isArray(k)&&(C=k)}return f.createElement(Ct,{zIndex:a.zIndex},f.createElement("g",{className:"recharts-cartesian-grid"},f.createElement(fI,{fill:a.fill,fillOpacity:a.fillOpacity,x:a.x,y:a.y,width:a.width,height:a.height,ry:a.ry}),f.createElement(hI,wr({},a,{horizontalPoints:x})),f.createElement(pI,wr({},a,{verticalPoints:C})),f.createElement(mI,wr({},a,{offset:n,horizontalPoints:x,xAxis:g,yAxis:p})),f.createElement(vI,wr({},a,{offset:n,verticalPoints:C,xAxis:g,yAxis:p}))))}Mb.displayName="CartesianGrid";var xI={},Tb=Xe({name:"errorBars",initialState:xI,reducers:{addErrorBar:(e,t)=>{var{itemId:r,errorBar:n}=t.payload;e[r]||(e[r]=[]),e[r].push(n)},replaceErrorBar:(e,t)=>{var{itemId:r,prev:n,next:a}=t.payload;e[r]&&(e[r]=e[r].map(i=>i.dataKey===n.dataKey&&i.direction===n.direction?a:i))},removeErrorBar:(e,t)=>{var{itemId:r,errorBar:n}=t.payload;e[r]&&(e[r]=e[r].filter(a=>a.dataKey!==n.dataKey||a.direction!==n.direction))}}}),{addErrorBar:L2,replaceErrorBar:R2,removeErrorBar:$2}=Tb.actions,jI=Tb.reducer,wI=["children"];function CI(e,t){if(e==null)return{};var r,n,a=kI(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function kI(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var PI={data:[],xAxisId:"xAxis-0",yAxisId:"yAxis-0",dataPointFormatter:()=>({x:0,y:0,value:0}),errorBarOffset:0},SI=f.createContext(PI);function NI(e){var{children:t}=e,r=CI(e,wI);return f.createElement(SI.Provider,{value:r},t)}function Ib(e,t){var r,n,a=Y(d=>Xt(d,e)),i=Y(d=>Yt(d,t)),o=(r=a?.allowDataOverflow)!==null&&r!==void 0?r:Me.allowDataOverflow,l=(n=i?.allowDataOverflow)!==null&&n!==void 0?n:Te.allowDataOverflow,c=o||l;return{needClip:c,needClipX:o,needClipY:l}}function OI(e){var{xAxisId:t,yAxisId:r,clipPathId:n}=e,a=ru(),{needClipX:i,needClipY:o,needClip:l}=Ib(t,r);if(!l||!a)return null;var{x:c,y:d,width:u,height:m}=a;return f.createElement("clipPath",{id:"clipPath-".concat(n)},f.createElement("rect",{x:i?c:c-u/2,y:o?d:d-m/2,width:i?u:u*2,height:o?m:m*2}))}var Db=(e,t,r,n)=>pg(e,"xAxis",t,n),Lb=(e,t,r,n)=>hg(e,"xAxis",t,n),Rb=(e,t,r,n)=>pg(e,"yAxis",r,n),$b=(e,t,r,n)=>hg(e,"yAxis",r,n),AI=M([ge,Db,Rb,Lb,$b],(e,t,r,n,a)=>Wt(e,"xAxis")?Ua(t,n,!1):Ua(r,a,!1)),EI=(e,t,r,n,a)=>a;function _I(e){return e.type==="line"}var MI=M([Hy,EI],(e,t)=>e.filter(_I).find(r=>r.id===t)),TI=M([ge,Db,Rb,Lb,$b,MI,AI,Yn],(e,t,r,n,a,i,o,l)=>{var{chartData:c,dataStartIndex:d,dataEndIndex:u}=l;if(!(i==null||t==null||r==null||n==null||a==null||n.length===0||a.length===0||o==null||e!=="horizontal"&&e!=="vertical")){var{dataKey:m,data:h}=i,v;if(h!=null&&h.length>0?v=h:v=c?.slice(d,u+1),v!=null)return eD({layout:e,xAxis:t,yAxis:r,xAxisTicks:n,yAxisTicks:a,dataKey:m,bandSize:o,displayedData:v})}});function II(e){var t=Xr(e),r=3,n=2;if(t!=null){var{r:a,strokeWidth:i}=t,o=Number(a),l=Number(i);return(Number.isNaN(o)||o<0)&&(o=r),(Number.isNaN(l)||l<0)&&(l=n),{r:o,strokeWidth:l}}return{r,strokeWidth:n}}var DI=["id"],LI=["type","layout","connectNulls","needClip","shape"],RI=["activeDot","animateNewValues","animationBegin","animationDuration","animationEasing","connectNulls","dot","hide","isAnimationActive","label","legendType","xAxisId","yAxisId","id"];function Fn(){return Fn=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Fn.apply(null,arguments)}function hv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function At(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?hv(Object(r),!0).forEach(function(n){$I(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):hv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function $I(e,t,r){return(t=BI(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function BI(e){var t=FI(e,"string");return typeof t=="symbol"?t:t+""}function FI(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function iu(e,t){if(e==null)return{};var r,n,a=zI(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function zI(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var KI=e=>{var{dataKey:t,name:r,stroke:n,legendType:a,hide:i}=e;return[{inactive:i,dataKey:t,type:a,color:n,value:Di(r,t),payload:e}]},VI=f.memo(e=>{var{dataKey:t,data:r,stroke:n,strokeWidth:a,fill:i,name:o,hide:l,unit:c,tooltipType:d,id:u}=e,m={dataDefinedOnItem:r,getPosition:Kn,settings:{stroke:n,strokeWidth:a,fill:i,dataKey:t,nameKey:void 0,name:Di(o,t),hide:l,type:d,color:n,unit:c,graphicalItemId:u}};return f.createElement(jb,{tooltipEntrySettings:m})}),Bb=(e,t)=>"".concat(t,"px ").concat(e,"px");function UI(e,t){for(var r=e.length%2!==0?[...e,0]:e,n=[],a=0;a<t;++a)n.push(...r);return n}var qI=(e,t,r)=>{var n=r.reduce((h,v)=>h+v,0);if(!n)return Bb(t,e);for(var a=Math.floor(e/n),i=e%n,o=[],l=0,c=0;l<r.length;c+=(d=r[l])!==null&&d!==void 0?d:0,++l){var d,u=r[l];if(u!=null&&c+u>i){o=[...r.slice(0,l),i-c];break}}var m=o.length%2===0?[0,t]:[t];return[...UI(r,a),...o,...m].map(h=>"".concat(h,"px")).join(", ")};function WI(e){var{clipPathId:t,points:r,props:n}=e,{dot:a,dataKey:i,needClip:o}=n,{id:l}=n,c=iu(n,DI),d=yt(c);return f.createElement(tT,{points:r,dot:a,className:"recharts-line-dots",dotClassName:"recharts-line-dot",dataKey:i,baseProps:d,needClip:o,clipPathId:t})}function HI(e){var{showLabels:t,children:r,points:n}=e,a=f.useMemo(()=>n?.map(i=>{var o,l,c={x:(o=i.x)!==null&&o!==void 0?o:0,y:(l=i.y)!==null&&l!==void 0?l:0,width:0,lowerWidth:0,upperWidth:0,height:0};return At(At({},c),{},{value:i.value,payload:i.payload,viewBox:c,parentViewBox:void 0,fill:void 0})}),[n]);return f.createElement(m1,{value:t?a:void 0},r)}function pv(e){var{clipPathId:t,pathRef:r,points:n,strokeDasharray:a,props:i}=e,{type:o,layout:l,connectNulls:c,needClip:d,shape:u}=i,m=iu(i,LI),h=At(At({},Je(m)),{},{fill:"none",className:"recharts-line-curve",clipPath:d?"url(#clipPath-".concat(t,")"):void 0,points:n,type:o,layout:l,connectNulls:c,strokeDasharray:a??i.strokeDasharray});return f.createElement(f.Fragment,null,n?.length>1&&f.createElement(xb,Fn({shapeType:"curve",option:u},h,{pathRef:r})),f.createElement(WI,{points:n,clipPathId:t,props:i}))}function GI(e){try{return e&&e.getTotalLength&&e.getTotalLength()||0}catch{return 0}}function XI(e){var{clipPathId:t,props:r,pathRef:n,previousPointsRef:a,longestAnimatedLengthRef:i}=e,{points:o,strokeDasharray:l,isAnimationActive:c,animationBegin:d,animationDuration:u,animationEasing:m,animateNewValues:h,width:v,height:y,onAnimationEnd:g,onAnimationStart:p}=r,b=a.current,j=qi(o,"recharts-line-"),x=f.useRef(j),[C,w]=f.useState(!1),P=!C,O=f.useCallback(()=>{typeof g=="function"&&g(),w(!1)},[g]),k=f.useCallback(()=>{typeof p=="function"&&p(),w(!0)},[p]),N=GI(n.current),S=f.useRef(0);x.current!==j&&(S.current=i.current,x.current=j);var A=S.current;return f.createElement(HI,{points:o,showLabels:P},r.children,f.createElement(Ui,{animationId:j,begin:d,duration:u,isActive:c,easing:m,onAnimationEnd:O,onAnimationStart:k,key:j},_=>{var I=We(A,N+A,_),D=Math.min(I,N),F;if(c)if(l){var V="".concat(l).split(/[,\s]+/gim).map(q=>parseFloat(q));F=qI(D,N,V)}else F=Bb(N,D);else F=l==null?void 0:String(l);if(_>0&&N>0&&(a.current=o,i.current=Math.max(i.current,D)),b){var U=b.length/o.length,te=_===1?o:o.map((q,ee)=>{var L=Math.floor(ee*U);if(b[L]){var B=b[L];return At(At({},q),{},{x:We(B.x,q.x,_),y:We(B.y,q.y,_)})}return h?At(At({},q),{},{x:We(v*2,q.x,_),y:We(y/2,q.y,_)}):At(At({},q),{},{x:q.x,y:q.y})});return a.current=te,f.createElement(pv,{props:r,points:te,clipPathId:t,pathRef:n,strokeDasharray:F})}return f.createElement(pv,{props:r,points:o,clipPathId:t,pathRef:n,strokeDasharray:F})}),f.createElement(ub,{label:r.label}))}function YI(e){var{clipPathId:t,props:r}=e,n=f.useRef(null),a=f.useRef(0),i=f.useRef(null);return f.createElement(XI,{props:r,clipPathId:t,previousPointsRef:n,longestAnimatedLengthRef:a,pathRef:i})}var ZI=(e,t)=>{var r,n;return{x:(r=e.x)!==null&&r!==void 0?r:void 0,y:(n=e.y)!==null&&n!==void 0?n:void 0,value:e.value,errorVal:he(e.payload,t)}};class JI extends f.Component{render(){var{hide:t,dot:r,points:n,className:a,xAxisId:i,yAxisId:o,top:l,left:c,width:d,height:u,id:m,needClip:h,zIndex:v}=this.props;if(t)return null;var y=de("recharts-line",a),g=m,{r:p,strokeWidth:b}=II(r),j=bb(r),x=p*2+b,C=h?"url(#clipPath-".concat(j?"":"dots-").concat(g,")"):void 0;return f.createElement(Ct,{zIndex:v},f.createElement(Qe,{className:y},h&&f.createElement("defs",null,f.createElement(OI,{clipPathId:g,xAxisId:i,yAxisId:o}),!j&&f.createElement("clipPath",{id:"clipPath-dots-".concat(g)},f.createElement("rect",{x:c-x/2,y:l-x/2,width:d+x,height:u+x}))),f.createElement(NI,{xAxisId:i,yAxisId:o,data:n,dataPointFormatter:ZI,errorBarOffset:0},f.createElement(YI,{props:this.props,clipPathId:g}))),f.createElement(jT,{activeDot:this.props.activeDot,points:n,mainColor:this.props.stroke,itemDataKey:this.props.dataKey,clipPath:C}))}}var Fb={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:Ve.line,type:"linear"};function QI(e){var t=Le(e,Fb),{activeDot:r,animateNewValues:n,animationBegin:a,animationDuration:i,animationEasing:o,connectNulls:l,dot:c,hide:d,isAnimationActive:u,label:m,legendType:h,xAxisId:v,yAxisId:y,id:g}=t,p=iu(t,RI),{needClip:b}=Ib(v,y),j=ru(),x=an(),C=rt(),w=Y(S=>TI(S,v,y,C,g));if(x!=="horizontal"&&x!=="vertical"||w==null||j==null)return null;var{height:P,width:O,x:k,y:N}=j;return f.createElement(JI,Fn({},p,{id:g,connectNulls:l,dot:c,activeDot:r,animateNewValues:n,animationBegin:a,animationDuration:i,animationEasing:o,isAnimationActive:u,hide:d,label:m,legendType:h,xAxisId:v,yAxisId:y,points:w,layout:x,height:P,width:O,left:k,top:N,needClip:b}))}function eD(e){var{layout:t,xAxis:r,yAxis:n,xAxisTicks:a,yAxisTicks:i,dataKey:o,bandSize:l,displayedData:c}=e;return c.map((d,u)=>{var m=he(d,o);if(t==="horizontal"){var h=Ud({axis:r,ticks:a,bandSize:l,entry:d,index:u}),v=De(m)?null:n.scale.map(m);return{x:h,y:v??null,value:m,payload:d}}var y=De(m)?null:r.scale.map(m),g=Ud({axis:n,ticks:i,bandSize:l,entry:d,index:u});return y==null||g==null?null:{x:y,y:g,value:m,payload:d}}).filter(Boolean)}function tD(e){var t=Le(e,Fb),r=rt();return f.createElement(wb,{id:t.id,type:"line"},n=>f.createElement(f.Fragment,null,f.createElement(nM,{legendPayload:KI(t)}),f.createElement(VI,{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:n}),f.createElement(gM,{type:"line",id:n,data:t.data,xAxisId:t.xAxisId,yAxisId:t.yAxisId,zAxisId:0,dataKey:t.dataKey,hide:t.hide,isPanorama:r}),f.createElement(QI,Fn({},t,{id:n}))))}var zb=f.memo(tD,Gn);zb.displayName="Line";var rD=["domain","range"],nD=["domain","range"];function yv(e,t){if(e==null)return{};var r,n,a=aD(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function aD(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function gv(e,t){return e===t?!0:Array.isArray(e)&&e.length===2&&Array.isArray(t)&&t.length===2?e[0]===t[0]&&e[1]===t[1]:!1}function Kb(e,t){if(e===t)return!0;var{domain:r,range:n}=e,a=yv(e,rD),{domain:i,range:o}=t,l=yv(t,nD);return!gv(r,i)||!gv(n,o)?!1:Gn(a,l)}var iD=["type"],sD=["dangerouslySetInnerHTML","ticks","scale"],oD=["id","scale"];function yl(){return yl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},yl.apply(null,arguments)}function bv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function xv(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?bv(Object(r),!0).forEach(function(n){lD(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):bv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function lD(e,t,r){return(t=cD(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function cD(e){var t=uD(e,"string");return typeof t=="symbol"?t:t+""}function uD(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function gl(e,t){if(e==null)return{};var r,n,a=dD(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function dD(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function fD(e){var t=ve(),r=f.useRef(null),n=Yp(),{type:a}=e,i=gl(e,iD),o=Gi(n,"xAxis",a),l=f.useMemo(()=>{if(o!=null)return xv(xv({},i),{},{type:o})},[i,o]);return f.useLayoutEffect(()=>{l!=null&&(r.current===null?t(sT(l)):r.current!==l&&t(oT({prev:r.current,next:l})),r.current=l)},[l,t]),f.useLayoutEffect(()=>()=>{r.current&&(t(lT(r.current)),r.current=null)},[t]),null}var mD=e=>{var{xAxisId:t,className:r}=e,n=Y(Hp),a=rt(),i="xAxis",o=Y(b=>vg(b,i,t,a)),l=Y(b=>IO(b,t)),c=Y(b=>FO(b,t)),d=Y(b=>Uy(b,t));if(l==null||c==null||d==null)return null;var{dangerouslySetInnerHTML:u,ticks:m,scale:h}=e,v=gl(e,sD),{id:y,scale:g}=d,p=gl(d,oD);return f.createElement(au,yl({},v,p,{x:c.x,y:c.y,width:l.width,height:l.height,className:de("recharts-".concat(i," ").concat(i),r),viewBox:n,ticks:o,axisType:i,axisId:t}))},vD={allowDataOverflow:Me.allowDataOverflow,allowDecimals:Me.allowDecimals,allowDuplicatedCategory:Me.allowDuplicatedCategory,angle:Me.angle,axisLine:zt.axisLine,height:Me.height,hide:!1,includeHidden:Me.includeHidden,interval:Me.interval,label:!1,minTickGap:Me.minTickGap,mirror:Me.mirror,orientation:Me.orientation,padding:Me.padding,reversed:Me.reversed,scale:Me.scale,tick:Me.tick,tickCount:Me.tickCount,tickLine:zt.tickLine,tickSize:zt.tickSize,type:Me.type,niceTicks:Me.niceTicks,xAxisId:0},hD=e=>{var t=Le(e,vD);return f.createElement(f.Fragment,null,f.createElement(fD,{allowDataOverflow:t.allowDataOverflow,allowDecimals:t.allowDecimals,allowDuplicatedCategory:t.allowDuplicatedCategory,angle:t.angle,dataKey:t.dataKey,domain:t.domain,height:t.height,hide:t.hide,id:t.xAxisId,includeHidden:t.includeHidden,interval:t.interval,minTickGap:t.minTickGap,mirror:t.mirror,name:t.name,orientation:t.orientation,padding:t.padding,reversed:t.reversed,scale:t.scale,tick:t.tick,tickCount:t.tickCount,tickFormatter:t.tickFormatter,ticks:t.ticks,type:t.type,unit:t.unit,niceTicks:t.niceTicks}),f.createElement(mD,t))},Vb=f.memo(hD,Kb);Vb.displayName="XAxis";var pD=["type"],yD=["dangerouslySetInnerHTML","ticks","scale"],gD=["id","scale"];function bl(){return bl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},bl.apply(null,arguments)}function jv(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function wv(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?jv(Object(r),!0).forEach(function(n){bD(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):jv(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function bD(e,t,r){return(t=xD(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function xD(e){var t=jD(e,"string");return typeof t=="symbol"?t:t+""}function jD(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function xl(e,t){if(e==null)return{};var r,n,a=wD(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function wD(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function CD(e){var t=ve(),r=f.useRef(null),n=Yp(),{type:a}=e,i=xl(e,pD),o=Gi(n,"yAxis",a),l=f.useMemo(()=>{if(o!=null)return wv(wv({},i),{},{type:o})},[o,i]);return f.useLayoutEffect(()=>{l!=null&&(r.current===null?t(cT(l)):r.current!==l&&t(uT({prev:r.current,next:l})),r.current=l)},[l,t]),f.useLayoutEffect(()=>()=>{r.current&&(t(dT(r.current)),r.current=null)},[t]),null}function kD(e){var{yAxisId:t,className:r,width:n,label:a}=e,i=f.useRef(null),o=f.useRef(null),l=Y(Hp),c=rt(),d=ve(),u="yAxis",m=Y(P=>VO(P,t)),h=Y(P=>KO(P,t)),v=Y(P=>vg(P,u,t,c)),y=Y(P=>qy(P,t));if(f.useLayoutEffect(()=>{if(!(n!=="auto"||!m||Qc(a)||f.isValidElement(a)||y==null)){var P=i.current;if(P){var O=P.getCalculatedWidth();Math.round(m.width)!==Math.round(O)&&d(fT({id:t,width:O}))}}},[v,m,d,a,t,n,y]),m==null||h==null||y==null)return null;var{dangerouslySetInnerHTML:g,ticks:p,scale:b}=e,j=xl(e,yD),{id:x,scale:C}=y,w=xl(y,gD);return f.createElement(au,bl({},j,w,{ref:i,labelRef:o,x:h.x,y:h.y,tickTextProps:n==="auto"?{width:void 0}:{width:n},width:m.width,height:m.height,className:de("recharts-".concat(u," ").concat(u),r),viewBox:l,ticks:v,axisType:u,axisId:t}))}var PD={allowDataOverflow:Te.allowDataOverflow,allowDecimals:Te.allowDecimals,allowDuplicatedCategory:Te.allowDuplicatedCategory,angle:Te.angle,axisLine:zt.axisLine,hide:!1,includeHidden:Te.includeHidden,interval:Te.interval,label:!1,minTickGap:Te.minTickGap,mirror:Te.mirror,orientation:Te.orientation,padding:Te.padding,reversed:Te.reversed,scale:Te.scale,tick:Te.tick,tickCount:Te.tickCount,tickLine:zt.tickLine,tickSize:zt.tickSize,type:Te.type,niceTicks:Te.niceTicks,width:Te.width,yAxisId:0},SD=e=>{var t=Le(e,PD);return f.createElement(f.Fragment,null,f.createElement(CD,{interval:t.interval,id:t.yAxisId,scale:t.scale,type:t.type,domain:t.domain,allowDataOverflow:t.allowDataOverflow,dataKey:t.dataKey,allowDuplicatedCategory:t.allowDuplicatedCategory,allowDecimals:t.allowDecimals,tickCount:t.tickCount,padding:t.padding,includeHidden:t.includeHidden,reversed:t.reversed,ticks:t.ticks,width:t.width,orientation:t.orientation,mirror:t.mirror,hide:t.hide,unit:t.unit,name:t.name,angle:t.angle,minTickGap:t.minTickGap,tick:t.tick,tickFormatter:t.tickFormatter,niceTicks:t.niceTicks}),f.createElement(kD,t))},Ub=f.memo(SD,Kb);Ub.displayName="YAxis";var ND=(e,t)=>t,su=M([ND,ge,Ry,Fe,Ig,Zt,dE,Be],gE);function OD(e){return"getBBox"in e.currentTarget&&typeof e.currentTarget.getBBox=="function"}function ou(e){var t=e.currentTarget.getBoundingClientRect(),r,n;if(OD(e)){var a=e.currentTarget.getBBox();r=a.width>0?t.width/a.width:1,n=a.height>0?t.height/a.height:1}else{var i=e.currentTarget;r=i.offsetWidth>0?t.width/i.offsetWidth:1,n=i.offsetHeight>0?t.height/i.offsetHeight:1}var o=(l,c)=>({relativeX:Math.round((l-t.left)/r),relativeY:Math.round((c-t.top)/n)});return"touches"in e?Array.from(e.touches).map(l=>o(l.clientX,l.clientY)):o(e.clientX,e.clientY)}var qb=ct("mouseClick"),Wb=Un();Wb.startListening({actionCreator:qb,effect:(e,t)=>{var r=e.payload,n=su(t.getState(),ou(r));n?.activeIndex!=null&&t.dispatch(iA({activeIndex:n.activeIndex,activeDataKey:void 0,activeCoordinate:n.activeCoordinate}))}});var jl=ct("mouseMove"),Hb=Un(),Fr=null,mr=null,So=null;Hb.startListening({actionCreator:jl,effect:(e,t)=>{var r=e.payload,n=t.getState(),{throttleDelay:a,throttledEvents:i}=n.eventSettings,o=i==="all"||i?.includes("mousemove");Fr!==null&&(cancelAnimationFrame(Fr),Fr=null),mr!==null&&(typeof a!="number"||!o)&&(clearTimeout(mr),mr=null),So=ou(r);var l=()=>{var c=t.getState(),d=ta(c,c.tooltip.settings.shared);if(!So){Fr=null,mr=null;return}if(d==="axis"){var u=su(c,So);u?.activeIndex!=null?t.dispatch(kg({activeIndex:u.activeIndex,activeDataKey:void 0,activeCoordinate:u.activeCoordinate})):t.dispatch(Cg())}Fr=null,mr=null};if(!o){l();return}a==="raf"?Fr=requestAnimationFrame(l):typeof a=="number"&&mr===null&&(mr=setTimeout(l,a))}});function AD(e,t){return t instanceof HTMLElement?"HTMLElement <".concat(t.tagName,' class="').concat(t.className,'">'):t===window?"global.window":e==="children"&&typeof t=="object"&&t!==null?"<<CHILDREN>>":t}var Cv={accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,barSize:void 0,className:void 0,maxBarSize:void 0,stackOffset:"none",syncId:void 0,syncMethod:"index",baseValue:void 0,reverseStackOrder:!1},Gb=Xe({name:"rootProps",initialState:Cv,reducers:{updateOptions:(e,t)=>{var r;e.accessibilityLayer=t.payload.accessibilityLayer,e.barCategoryGap=t.payload.barCategoryGap,e.barGap=(r=t.payload.barGap)!==null&&r!==void 0?r:Cv.barGap,e.barSize=t.payload.barSize,e.maxBarSize=t.payload.maxBarSize,e.stackOffset=t.payload.stackOffset,e.syncId=t.payload.syncId,e.syncMethod=t.payload.syncMethod,e.className=t.payload.className,e.baseValue=t.payload.baseValue,e.reverseStackOrder=t.payload.reverseStackOrder}}}),ED=Gb.reducer,{updateOptions:_D}=Gb.actions,MD=null,TD={updatePolarOptions:(e,t)=>e===null?t.payload:(e.startAngle=t.payload.startAngle,e.endAngle=t.payload.endAngle,e.cx=t.payload.cx,e.cy=t.payload.cy,e.innerRadius=t.payload.innerRadius,e.outerRadius=t.payload.outerRadius,e)},Xb=Xe({name:"polarOptions",initialState:MD,reducers:TD}),{updatePolarOptions:ID}=Xb.actions,DD=Xb.reducer,Yb=ct("keyDown"),Zb=ct("focus"),Jb=ct("blur"),os=Un(),zr=null,vr=null,ha=null;os.startListening({actionCreator:Yb,effect:(e,t)=>{ha=e.payload,zr!==null&&(cancelAnimationFrame(zr),zr=null);var r=t.getState(),{throttleDelay:n,throttledEvents:a}=r.eventSettings,i=a==="all"||a.includes("keydown");vr!==null&&(typeof n!="number"||!i)&&(clearTimeout(vr),vr=null);var o=()=>{try{var l=t.getState(),c=l.rootProps.accessibilityLayer!==!1;if(!c)return;var{keyboardInteraction:d}=l.tooltip,u=ha;if(u!=="ArrowRight"&&u!=="ArrowLeft"&&u!=="Enter")return;var m=Nn(d,Mr(l),en(l),tn(l)),h=m==null?-1:Number(m),v=!Number.isFinite(h)||h<0,y=Zt(l),g=Mr(l),p=ta(l,l.tooltip.settings.shared);if(u==="Enter"){if(v)return;var b=ai(l,p,"hover",String(d.index));t.dispatch(ni({active:!d.active,activeIndex:d.index,activeCoordinate:b}));return}var j=GO(l),x=j==="left-to-right"?1:-1,C=u==="ArrowRight"?1:-1,w;if(v){var P=en(l),O=tn(l),k=C*x,N=D=>({active:!1,index:String(D),dataKey:void 0,graphicalItemId:void 0,coordinate:void 0});if(w=-1,k>0){for(var S=0;S<g.length;S++)if(Nn(N(S),g,P,O)!=null){w=S;break}}else for(var A=g.length-1;A>=0;A--)if(Nn(N(A),g,P,O)!=null){w=A;break}if(w<0)return}else{w=h+C*x;var _=y?.length||g.length;if(_===0||w>=_||w<0)return}var I=ai(l,p,"hover",String(w));t.dispatch(ni({active:!0,activeIndex:w.toString(),activeCoordinate:I}))}finally{zr=null,vr=null}};if(!i){o();return}n==="raf"?zr=requestAnimationFrame(o):typeof n=="number"&&vr===null&&(o(),ha=null,vr=setTimeout(()=>{ha?o():(vr=null,zr=null)},n))}});os.startListening({actionCreator:Zb,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:a}=r.tooltip;if(!a.active&&a.index==null){var i="0",o=ta(r,r.tooltip.settings.shared),l=ai(r,o,"hover",String(i));t.dispatch(ni({active:!0,activeIndex:i,activeCoordinate:l}))}}}});os.startListening({actionCreator:Jb,effect:(e,t)=>{var r=t.getState(),n=r.rootProps.accessibilityLayer!==!1;if(n){var{keyboardInteraction:a}=r.tooltip;a.active&&t.dispatch(ni({active:!1,activeIndex:a.index,activeCoordinate:a.coordinate}))}}});function Qb(e){e.persist();var{currentTarget:t}=e;return new Proxy(e,{get:(r,n)=>{if(n==="currentTarget")return t;var a=Reflect.get(r,n);return typeof a=="function"?a.bind(r):a}})}var vt=ct("externalEvent"),ex=Un(),pa=new Map,bn=new Map,No=new Map;ex.startListening({actionCreator:vt,effect:(e,t)=>{var{handler:r,reactEvent:n}=e.payload;if(r!=null){var a=n.type,i=Qb(n);No.set(a,{handler:r,reactEvent:i});var o=pa.get(a);o!==void 0&&(cancelAnimationFrame(o),pa.delete(a));var l=t.getState(),{throttleDelay:c,throttledEvents:d}=l.eventSettings,u=d,m=u==="all"||u?.includes(a),h=bn.get(a);h!==void 0&&(typeof c!="number"||!m)&&(clearTimeout(h),bn.delete(a));var v=()=>{var p=No.get(a);try{if(!p)return;var{handler:b,reactEvent:j}=p,x=t.getState(),C={activeCoordinate:XA(x),activeDataKey:$g(x),activeIndex:rn(x),activeLabel:Rg(x),activeTooltipIndex:rn(x),isTooltipActive:YA(x)};b&&b(C,j)}finally{pa.delete(a),bn.delete(a),No.delete(a)}};if(!m){v();return}if(c==="raf"){var y=requestAnimationFrame(v);pa.set(a,y)}else if(typeof c=="number"){if(!bn.has(a)){v();var g=setTimeout(v,c);bn.set(a,g)}}else v()}}});var LD=M([fn],e=>e.tooltipItemPayloads),RD=M([LD,(e,t)=>t,(e,t,r)=>r],(e,t,r)=>{if(t!=null){var n=e.find(i=>i.settings.graphicalItemId===r);if(n!=null){var{getPosition:a}=n;if(a!=null)return a(t)}}}),tx=ct("touchMove"),rx=Un(),hr=null,Qt=null,kv=null,xn=null;rx.startListening({actionCreator:tx,effect:(e,t)=>{var r=e.payload;if(!(r.touches==null||r.touches.length===0)){xn=Qb(r);var n=t.getState(),{throttleDelay:a,throttledEvents:i}=n.eventSettings,o=i==="all"||i.includes("touchmove");hr!==null&&(cancelAnimationFrame(hr),hr=null),Qt!==null&&(typeof a!="number"||!o)&&(clearTimeout(Qt),Qt=null),kv=Array.from(r.touches).map(c=>ou({clientX:c.clientX,clientY:c.clientY,currentTarget:r.currentTarget}));var l=()=>{if(xn!=null){var c=t.getState(),d=ta(c,c.tooltip.settings.shared);if(d==="axis"){var u,m=(u=kv)===null||u===void 0?void 0:u[0];if(m==null){hr=null,Qt=null;return}var h=su(c,m);h?.activeIndex!=null&&t.dispatch(kg({activeIndex:h.activeIndex,activeDataKey:void 0,activeCoordinate:h.activeCoordinate}))}else if(d==="item"){var v,y=xn.touches[0];if(document.elementFromPoint==null||y==null)return;var g=document.elementFromPoint(y.clientX,y.clientY);if(!g||!g.getAttribute)return;var p=g.getAttribute(qp),b=(v=g.getAttribute(Wp))!==null&&v!==void 0?v:void 0,j=Dr(c).find(w=>w.id===b);if(p==null||j==null||b==null)return;var{dataKey:x}=j,C=RD(c,p,b);t.dispatch(wg({activeDataKey:x,activeIndex:p,activeCoordinate:C,activeGraphicalItemId:b}))}hr=null,Qt=null}};if(!o){l();return}a==="raf"?hr=requestAnimationFrame(l):typeof a=="number"&&Qt===null&&(l(),xn=null,Qt=setTimeout(()=>{xn?l():(Qt=null,hr=null)},a))}}});var lu={throttleDelay:"raf",throttledEvents:["mousemove","touchmove","pointermove","scroll","wheel"]},nx=Xe({name:"eventSettings",initialState:lu,reducers:{setEventSettings:(e,t)=>{t.payload.throttleDelay!=null&&(e.throttleDelay=t.payload.throttleDelay),t.payload.throttledEvents!=null&&(e.throttledEvents=t.payload.throttledEvents)}}}),{setEventSettings:$D}=nx.actions,BD=nx.reducer,FD=mp({brush:wT,cartesianAxis:mT,chartData:GE,errorBars:jI,eventSettings:BD,graphicalItems:pM,layout:Ek,legend:bP,options:VE,polarAxis:P1,polarOptions:DD,referenceElements:ST,renderedTicks:VT,rootProps:ED,tooltip:sA,zIndex:_E}),zD=function(t){var r=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"Chart";return tk({reducer:FD,preloadedState:t,middleware:n=>{var a;return n({serializableCheck:!1,immutableCheck:!["commonjs","es6","production"].includes((a="es6")!==null&&a!==void 0?a:"")}).concat([Wb.middleware,Hb.middleware,os.middleware,ex.middleware,rx.middleware])},enhancers:n=>{var a=n;return typeof n=="function"&&(a=n()),a.concat(Op({type:"raf"}))},devTools:{serialize:{replacer:AD},name:"recharts-".concat(r)}})};function ax(e){var{preloadedState:t,children:r,reduxStoreName:n}=e,a=rt(),i=f.useRef(null);if(a)return r;i.current==null&&(i.current=zD(t,n));var o=ec;return f.createElement(RP,{context:o,store:i.current},r)}function KD(e){var{layout:t,margin:r}=e,n=ve(),a=rt();return f.useEffect(()=>{a||(n(Nk(t)),n(Sk(r)))},[n,a,t,r]),null}var ix=f.memo(KD,Gn);function sx(e){var t=ve();return f.useEffect(()=>{t(_D(e))},[t,e]),null}var VD=e=>{var t=ve();return f.useEffect(()=>{t($D(e))},[t,e]),null},ox=f.memo(VD,Gn);function Pv(e){var{zIndex:t,isPanorama:r}=e,n=f.useRef(null),a=ve();return f.useLayoutEffect(()=>(n.current&&a(AE({zIndex:t,element:n.current,isPanorama:r})),()=>{a(EE({zIndex:t,isPanorama:r}))}),[a,t,r]),f.createElement("g",{tabIndex:-1,ref:n,className:"recharts-zIndex-layer_".concat(t)})}function Sv(e){var{children:t,isPanorama:r}=e,n=Y(xE);if(!n||n.length===0)return t;var a=n.filter(o=>o<0),i=n.filter(o=>o>0);return f.createElement(f.Fragment,null,a.map(o=>f.createElement(Pv,{key:o,zIndex:o,isPanorama:r})),t,i.map(o=>f.createElement(Pv,{key:o,zIndex:o,isPanorama:r})))}var UD=["children"];function qD(e,t){if(e==null)return{};var r,n,a=WD(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function WD(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function ui(){return ui=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ui.apply(null,arguments)}var HD={width:"100%",height:"100%",display:"block"},GD=f.forwardRef((e,t)=>{var r=lc(),n=cc(),a=cy();if(!Zr(r)||!Zr(n))return null;var{children:i,otherAttributes:o,title:l,desc:c}=e,d,u;return o!=null&&(typeof o.tabIndex=="number"?d=o.tabIndex:d=a?0:void 0,typeof o.role=="string"?u=o.role:u=a?"application":void 0),f.createElement(Wl,ui({},o,{title:l,desc:c,role:u,tabIndex:d,width:r,height:n,style:HD,ref:t}),i)}),XD=e=>{var{children:t}=e,r=Y(Bi);if(!r)return null;var{width:n,height:a,y:i,x:o}=r;return f.createElement(Wl,{width:n,height:a,x:o,y:i},t)},Nv=f.forwardRef((e,t)=>{var{children:r}=e,n=qD(e,UD),a=rt();return a?f.createElement(XD,null,f.createElement(Sv,{isPanorama:!0},r)):f.createElement(GD,ui({ref:t},n),f.createElement(Sv,{isPanorama:!1},r))});function YD(){var e=ve(),[t,r]=f.useState(null),n=Y(Uk);return f.useEffect(()=>{if(t!=null){var a=t.getBoundingClientRect(),i=a.width/t.offsetWidth;ue(i)&&i!==n&&e(Ak(i))}},[t,e,n]),r}function Ov(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function ZD(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ov(Object(r),!0).forEach(function(n){JD(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ov(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function JD(e,t,r){return(t=QD(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function QD(e){var t=eL(e,"string");return typeof t=="symbol"?t:t+""}function eL(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function ar(){return ar=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},ar.apply(null,arguments)}var tL=()=>(n_(),null);function di(e){if(typeof e=="number")return e;if(typeof e=="string"){var t=parseFloat(e);if(!Number.isNaN(t))return t}return 0}var rL=f.forwardRef((e,t)=>{var r,n,a=f.useRef(null),[i,o]=f.useState({containerWidth:di((r=e.style)===null||r===void 0?void 0:r.width),containerHeight:di((n=e.style)===null||n===void 0?void 0:n.height)}),l=f.useCallback((d,u)=>{o(m=>{var h=Math.round(d),v=Math.round(u);return m.containerWidth===h&&m.containerHeight===v?m:{containerWidth:h,containerHeight:v}})},[]),c=f.useCallback(d=>{if(typeof t=="function"&&t(d),a.current!=null&&(a.current.disconnect(),a.current=null),d!=null&&typeof ResizeObserver<"u"){var{width:u,height:m}=d.getBoundingClientRect();l(u,m);var h=y=>{var g=y[0];if(g!=null){var{width:p,height:b}=g.contentRect;l(p,b)}},v=new ResizeObserver(h);v.observe(d),a.current=v}},[t,l]);return f.useEffect(()=>()=>{var d=a.current;d?.disconnect()},[l]),f.createElement(f.Fragment,null,f.createElement(Wn,{width:i.containerWidth,height:i.containerHeight}),f.createElement("div",ar({ref:c},e)))}),nL=f.forwardRef((e,t)=>{var{width:r,height:n}=e,[a,i]=f.useState({containerWidth:di(r),containerHeight:di(n)}),o=f.useCallback((c,d)=>{i(u=>{var m=Math.round(c),h=Math.round(d);return u.containerWidth===m&&u.containerHeight===h?u:{containerWidth:m,containerHeight:h}})},[]),l=f.useCallback(c=>{if(typeof t=="function"&&t(c),c!=null){var{width:d,height:u}=c.getBoundingClientRect();o(d,u)}},[t,o]);return f.createElement(f.Fragment,null,f.createElement(Wn,{width:a.containerWidth,height:a.containerHeight}),f.createElement("div",ar({ref:l},e)))}),aL=f.forwardRef((e,t)=>{var{width:r,height:n}=e;return f.createElement(f.Fragment,null,f.createElement(Wn,{width:r,height:n}),f.createElement("div",ar({ref:t},e)))}),iL=f.forwardRef((e,t)=>{var{width:r,height:n}=e;return typeof r=="string"||typeof n=="string"?f.createElement(nL,ar({},e,{ref:t})):typeof r=="number"&&typeof n=="number"?f.createElement(aL,ar({},e,{width:r,height:n,ref:t})):f.createElement(f.Fragment,null,f.createElement(Wn,{width:r,height:n}),f.createElement("div",ar({ref:t},e)))});function sL(e){return e?rL:iL}var oL=f.forwardRef((e,t)=>{var{children:r,className:n,height:a,onClick:i,onContextMenu:o,onDoubleClick:l,onMouseDown:c,onMouseEnter:d,onMouseLeave:u,onMouseMove:m,onMouseUp:h,onTouchEnd:v,onTouchMove:y,onTouchStart:g,style:p,width:b,responsive:j,dispatchTouchEvents:x=!0}=e,C=f.useRef(null),w=ve(),[P,O]=f.useState(null),[k,N]=f.useState(null),S=YD(),A=Gp(),_=A?.width>0?A.width:b,I=A?.height>0?A.height:a,D=f.useCallback($=>{S($),typeof t=="function"&&t($),O($),N($),$!=null&&(C.current=$)},[S,t,O,N]),F=f.useCallback($=>{w(qb($)),w(vt({handler:i,reactEvent:$}))},[w,i]),V=f.useCallback($=>{w(jl($)),w(vt({handler:d,reactEvent:$}))},[w,d]),U=f.useCallback($=>{w(Cg()),w(vt({handler:u,reactEvent:$}))},[w,u]),te=f.useCallback($=>{w(jl($)),w(vt({handler:m,reactEvent:$}))},[w,m]),q=f.useCallback(()=>{w(Zb())},[w]),ee=f.useCallback(()=>{w(Jb())},[w]),L=f.useCallback($=>{w(Yb($.key))},[w]),B=f.useCallback($=>{w(vt({handler:o,reactEvent:$}))},[w,o]),X=f.useCallback($=>{w(vt({handler:l,reactEvent:$}))},[w,l]),Q=f.useCallback($=>{w(vt({handler:c,reactEvent:$}))},[w,c]),G=f.useCallback($=>{w(vt({handler:h,reactEvent:$}))},[w,h]),ie=f.useCallback($=>{w(vt({handler:g,reactEvent:$}))},[w,g]),se=f.useCallback($=>{x&&w(tx($)),w(vt({handler:y,reactEvent:$}))},[w,x,y]),re=f.useCallback($=>{w(vt({handler:v,reactEvent:$}))},[w,v]),W=sL(j);return f.createElement(Wg.Provider,{value:P},f.createElement(Uh.Provider,{value:k},f.createElement(W,{width:_??p?.width,height:I??p?.height,className:de("recharts-wrapper",n),style:ZD({position:"relative",cursor:"default",width:_,height:I},p),onClick:F,onContextMenu:B,onDoubleClick:X,onFocus:q,onBlur:ee,onKeyDown:L,onMouseDown:Q,onMouseEnter:V,onMouseLeave:U,onMouseMove:te,onMouseUp:G,onTouchEnd:re,onTouchMove:se,onTouchStart:ie,ref:D},f.createElement(tL,null),r)))}),lL=["width","height","responsive","children","className","style","compact","title","desc"];function cL(e,t){if(e==null)return{};var r,n,a=uL(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function uL(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}var lx=f.forwardRef((e,t)=>{var{width:r,height:n,responsive:a,children:i,className:o,style:l,compact:c,title:d,desc:u}=e,m=cL(e,lL),h=yt(m);return c?f.createElement(f.Fragment,null,f.createElement(Wn,{width:r,height:n}),f.createElement(Nv,{otherAttributes:h,title:d,desc:u},i)):f.createElement(oL,{className:o,style:l,width:r,height:n,responsive:a??!1,onClick:e.onClick,onMouseLeave:e.onMouseLeave,onMouseEnter:e.onMouseEnter,onMouseMove:e.onMouseMove,onMouseDown:e.onMouseDown,onMouseUp:e.onMouseUp,onContextMenu:e.onContextMenu,onDoubleClick:e.onDoubleClick,onTouchStart:e.onTouchStart,onTouchMove:e.onTouchMove,onTouchEnd:e.onTouchEnd},f.createElement(Nv,{otherAttributes:h,title:d,desc:u,ref:t},f.createElement(OT,null,i)))});function wl(){return wl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},wl.apply(null,arguments)}function Av(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function dL(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Av(Object(r),!0).forEach(function(n){fL(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Av(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function fL(e,t,r){return(t=mL(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function mL(e){var t=vL(e,"string");return typeof t=="symbol"?t:t+""}function vL(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var hL={top:5,right:5,bottom:5,left:5},pL=dL({accessibilityLayer:!0,barCategoryGap:"10%",barGap:4,layout:"horizontal",margin:hL,responsive:!1,reverseStackOrder:!1,stackOffset:"none",syncMethod:"index"},lu),yL=f.forwardRef(function(t,r){var n,a=Le(t.categoricalChartProps,pL),{chartName:i,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,categoricalChartProps:d}=t,u={chartName:i,defaultTooltipEventType:o,validateTooltipEventTypes:l,tooltipPayloadSearcher:c,eventEmitter:void 0};return f.createElement(ax,{preloadedState:{options:u},reduxStoreName:(n=d.id)!==null&&n!==void 0?n:i},f.createElement(Sb,{chartData:d.data}),f.createElement(ix,{layout:a.layout,margin:a.margin}),f.createElement(ox,{throttleDelay:a.throttleDelay,throttledEvents:a.throttledEvents}),f.createElement(sx,{baseValue:a.baseValue,accessibilityLayer:a.accessibilityLayer,barCategoryGap:a.barCategoryGap,maxBarSize:a.maxBarSize,stackOffset:a.stackOffset,barGap:a.barGap,barSize:a.barSize,syncId:a.syncId,syncMethod:a.syncMethod,className:a.className,reverseStackOrder:a.reverseStackOrder}),f.createElement(lx,wl({},a,{ref:r})))}),gL=["axis"],bL=f.forwardRef((e,t)=>f.createElement(yL,{chartName:"LineChart",defaultTooltipEventType:"axis",validateTooltipEventTypes:gL,tooltipPayloadSearcher:Hg,categoricalChartProps:e,ref:t}));function xL(e){var t=ve();return f.useEffect(()=>{t(ID(e))},[t,e]),null}var jL=["layout"];function Cl(){return Cl=Object.assign?Object.assign.bind():function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)({}).hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e},Cl.apply(null,arguments)}function wL(e,t){if(e==null)return{};var r,n,a=CL(e,t);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);for(n=0;n<i.length;n++)r=i[n],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(a[r]=e[r])}return a}function CL(e,t){if(e==null)return{};var r={};for(var n in e)if({}.hasOwnProperty.call(e,n)){if(t.indexOf(n)!==-1)continue;r[n]=e[n]}return r}function Ev(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function kL(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Ev(Object(r),!0).forEach(function(n){PL(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Ev(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function PL(e,t,r){return(t=SL(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function SL(e){var t=NL(e,"string");return typeof t=="symbol"?t:t+""}function NL(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var OL={top:5,right:5,bottom:5,left:5},cx=kL({accessibilityLayer:!0,stackOffset:"none",barCategoryGap:"10%",barGap:4,margin:OL,reverseStackOrder:!1,syncMethod:"index",layout:"radial",responsive:!1,cx:"50%",cy:"50%",innerRadius:0,outerRadius:"80%"},lu),AL=f.forwardRef(function(t,r){var n,a=Le(t.categoricalChartProps,cx),{layout:i}=a,o=wL(a,jL),{chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:d,tooltipPayloadSearcher:u}=t,m={chartName:l,defaultTooltipEventType:c,validateTooltipEventTypes:d,tooltipPayloadSearcher:u,eventEmitter:void 0};return f.createElement(ax,{preloadedState:{options:m},reduxStoreName:(n=a.id)!==null&&n!==void 0?n:l},f.createElement(Sb,{chartData:a.data}),f.createElement(ix,{layout:i,margin:a.margin}),f.createElement(ox,{throttleDelay:a.throttleDelay,throttledEvents:a.throttledEvents}),f.createElement(sx,{baseValue:void 0,accessibilityLayer:a.accessibilityLayer,barCategoryGap:a.barCategoryGap,maxBarSize:a.maxBarSize,stackOffset:a.stackOffset,barGap:a.barGap,barSize:a.barSize,syncId:a.syncId,syncMethod:a.syncMethod,className:a.className,reverseStackOrder:a.reverseStackOrder}),f.createElement(xL,{cx:a.cx,cy:a.cy,startAngle:a.startAngle,endAngle:a.endAngle,innerRadius:a.innerRadius,outerRadius:a.outerRadius}),f.createElement(lx,Cl({},o,{ref:r})))});function _v(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter(function(a){return Object.getOwnPropertyDescriptor(e,a).enumerable})),r.push.apply(r,n)}return r}function Mv(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?_v(Object(r),!0).forEach(function(n){EL(e,n,r[n])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):_v(Object(r)).forEach(function(n){Object.defineProperty(e,n,Object.getOwnPropertyDescriptor(r,n))})}return e}function EL(e,t,r){return(t=_L(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function _L(e){var t=ML(e,"string");return typeof t=="symbol"?t:t+""}function ML(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var n=r.call(e,t);if(typeof n!="object")return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}var TL=["item"],IL=Mv(Mv({},cx),{},{layout:"centric",startAngle:0,endAngle:360}),DL=f.forwardRef((e,t)=>{var r=Le(e,IL);return f.createElement(AL,{chartName:"PieChart",defaultTooltipEventType:"item",validateTooltipEventTypes:TL,tooltipPayloadSearcher:Hg,categoricalChartProps:r,ref:t})});const fi="currentColor",LL=["--accent","--todo","--in-progress","--in-review","--triage","--color-success","--color-warning","--color-error"];function pr(e,t=fi){if(typeof document>"u"||typeof getComputedStyle!="function")return t;const r=getComputedStyle(document.documentElement).getPropertyValue(e).trim();return r.length>0?r:t}function cu(){const e=pr("--text"),t=pr("--text-muted",e),r=pr("--accent"),n=pr("--surface-1",""),a=pr("--surface-2",n),i=pr("--border-subtle",""),o=LL.map(l=>pr(l)).filter(l=>l.length>0);return{stroke:r,fill:a,grid:i,tick:t,tooltipBackground:n,tooltipBorder:i,tooltipText:e,legendText:t,palette:o.length>0?o:[fi]}}function ux(e,t=cu()){if(t.palette.length===0)return fi;const r=Number.isFinite(e)&&e>=0?Math.floor(e):0;return t.palette[r%t.palette.length]??fi}const RL={width:320,height:220},dx=120,fx=120;function $L(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function BL(e){return e.map(t=>({label:t.label,value:Number.isFinite(t.value)&&t.value>0?t.value:0})).filter(t=>t.value>0)}function Tv(e,t){return e!==void 0||t!==void 0?{width:e,height:t}:void 0}function Iv(e){return typeof e=="number"||typeof e=="string"&&/^\d+(?:\.\d+)?%$/.test(e)?e:"100%"}function mi(e,t){return Number.isFinite(e)&&e>=t?e:null}function FL(e,t,r){return{width:typeof t=="number"&&t>0?t:e.width,height:typeof r=="number"&&r>0?r:e.height}}function zL(e,t){return Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function KL(e){const t=e.getBoundingClientRect(),r=mi(t.width,dx),n=mi(t.height,fx);return r===null||n===null?null:{width:r,height:n}}function VL(){const e=f.useRef(null),[t,r]=f.useState(RL);return f.useLayoutEffect(()=>{const n=e.current;if(!n)return;const a=o=>{o&&r(l=>zL(l,o)?l:o)};if(a(KL(n)),typeof ResizeObserver>"u")return;const i=new ResizeObserver(o=>{const l=o[0];if(!l)return;const c=mi(l.contentRect.width,dx),d=mi(l.contentRect.height,fx);a(c===null||d===null?null:{width:c,height:d})});return i.observe(n),()=>i.disconnect()},[]),{ref:e,dimensions:t}}function kt({data:e,ariaLabel:t,width:r,height:n,emptyLabel:a="No chart data"}){const i=cu(),{ref:o,dimensions:l}=VL(),c=FL(l,r,n),d=BL(e);return d.length===0?s.jsx("div",{className:"cc-recharts-empty",role:"img","aria-label":t,style:Tv(r,n),children:a}):s.jsx("div",{ref:o,className:"cc-recharts-chart",role:"img","aria-label":t,style:Tv(r,n),"data-responsive-width":Iv(r),"data-responsive-height":Iv(n),children:s.jsxs(DL,{width:c.width,height:c.height,children:[s.jsx(kb,{data:d,dataKey:"value",nameKey:"label",isAnimationActive:!$L(),children:d.map((u,m)=>s.jsx(rs,{fill:ux(m,i),stroke:i.tooltipBorder},u.label))}),s.jsx(Yg,{contentStyle:{background:i.tooltipBackground,borderColor:i.tooltipBorder,color:i.tooltipText},itemStyle:{color:i.tooltipText},labelStyle:{color:i.tooltipText}}),s.jsx(fc,{wrapperStyle:{color:i.legendText}})]})})}const UL={width:360,height:220},mx=120,vx=120;function qL(){return typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia("(prefers-reduced-motion: reduce)").matches}function WL(e){return Number.isFinite(e)&&e>0?e:0}function HL(e){const t=e.reduce((r,n)=>n>r?n:r,0);return t<=0?e.map(()=>0):e.map(r=>r/t*100)}function GL(e,t){return e.map((r,n)=>{const a=r.values.map(WL);return{label:r.label,dataKey:`series${n}`,values:a,plotKey:t==="series"?`series${n}Normalized`:`series${n}`,plotValues:t==="series"?HL(a):a}}).filter(r=>r.values.length>0)}function XL(e){const t=e.reduce((r,n)=>Math.max(r,n.values.length),0);return Array.from({length:t},(r,n)=>{const a={index:n+1};for(const i of e)a[i.dataKey]=i.values[n]??0,a[i.plotKey]=i.plotValues[n]??0;return a})}function Dv(e,t){return e!==void 0||t!==void 0?{width:e,height:t}:void 0}function Lv(e){return typeof e=="number"||typeof e=="string"&&/^\d+(?:\.\d+)?%$/.test(e)?e:"100%"}function vi(e,t){return Number.isFinite(e)&&e>=t?e:null}function YL(e,t,r){return{width:typeof t=="number"&&t>0?t:e.width,height:typeof r=="number"&&r>0?r:e.height}}function ZL(e,t){return Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function JL(e){const t=e.getBoundingClientRect(),r=vi(t.width,mx),n=vi(t.height,vx);return r===null||n===null?null:{width:r,height:n}}function QL(){const e=f.useRef(null),[t,r]=f.useState(UL);return f.useLayoutEffect(()=>{const n=e.current;if(!n)return;const a=o=>{o&&r(l=>ZL(l,o)?l:o)};if(a(JL(n)),typeof ResizeObserver>"u")return;const i=new ResizeObserver(o=>{const l=o[0];if(!l)return;const c=vi(l.contentRect.width,mx),d=vi(l.contentRect.height,vx);a(c===null||d===null?null:{width:c,height:d})});return i.observe(n),()=>i.disconnect()},[]),{ref:e,dimensions:t}}function cr({series:e,ariaLabel:t,width:r,height:n,emptyLabel:a="No chart data",xAxisLabels:i,valueFormatter:o,scaleMode:l="shared"}){const c=cu(),{ref:d,dimensions:u}=QL(),m=YL(u,r,n),h=GL(e,l),v=XL(h),y=p=>{const b=typeof p=="number"?p:Number(p);return Number.isFinite(b)?i?.[b-1]??String(p):String(p)},g=p=>{const b=typeof p=="number"?p:Number(p);return o&&Number.isFinite(b)?o(b):String(p)};return h.length===0||v.length===0?s.jsx("div",{className:"cc-recharts-empty",role:"img","aria-label":t,style:Dv(r,n),children:a}):s.jsx("div",{ref:d,className:"cc-recharts-chart",role:"img","aria-label":t,style:Dv(r,n),"data-scale-mode":l,"data-responsive-width":Lv(r),"data-responsive-height":Lv(n),children:s.jsxs(bL,{width:m.width,height:m.height,data:v,children:[s.jsx(Mb,{stroke:c.grid}),s.jsx(Vb,{dataKey:"index",stroke:c.tick,tick:{fill:c.tick},tickFormatter:i?y:void 0}),s.jsx(Ub,{stroke:c.tick,tick:{fill:c.tick},domain:l==="series"?[0,100]:void 0,tickFormatter:l==="series"?p=>`${p}%`:o}),s.jsx(Yg,{contentStyle:{background:c.tooltipBackground,borderColor:c.tooltipBorder,color:c.tooltipText},itemStyle:{color:c.tooltipText},labelStyle:{color:c.tooltipText},formatter:o?p=>g(p):void 0,labelFormatter:i?y:void 0}),s.jsx(fc,{wrapperStyle:{color:c.legendText}}),h.map((p,b)=>s.jsx(zb,{type:"monotone",dataKey:p.plotKey,name:p.label,stroke:ux(b,c),isAnimationActive:!qL()},p.dataKey))]})})}function Pt({testId:e,isLoading:t,error:r,isEmpty:n,emptyMessage:a,children:i}){const{t:o}=le("app");return t?s.jsxs("div",{className:"cc-loading-inline","data-testid":`cc-area-${e}-loading`,children:[s.jsx(El,{size:18,className:"spin"}),s.jsx("span",{children:o("commandCenter.area.loading","Loading…")})]}):r!==null?s.jsxs("div",{className:"cc-area-error","data-testid":`cc-area-${e}-error`,role:"alert",children:[s.jsx(gi,{size:22}),s.jsx("p",{children:r})]}):n?s.jsxs("div",{className:"cc-area-empty","data-testid":`cc-area-${e}-empty`,children:[s.jsx(bi,{size:24}),s.jsx("p",{children:a??o("commandCenter.area.empty","No data for the selected range.")})]}):s.jsx("div",{className:"cc-area","data-testid":`cc-area-${e}`,children:i})}function eR(e,t){if(t==="")return e;const r=t.slice(1);return`${e}${e.includes("?")?"&":"?"}${r}`}function Ge(e,t,r={}){const[n,a]=f.useState(null),i=f.useRef(null),[o,l]=f.useState(!0),[c,d]=f.useState(null),u=Z0(t),m=Fh(t),h=f.useCallback(async()=>{if(m){l(!1);return}i.current!==null||l(!0),d(null);try{const g=await _l(eR(e,u));i.current=g,a(g)}catch(g){d(g instanceof Error?g.message:"Failed to load analytics")}finally{l(!1)}},[e,u,m]);f.useEffect(()=>{h()},[h]),f.useEffect(()=>{if(m||r.pollMs===void 0)return;const y=window.setInterval(()=>{h()},r.pollMs);return()=>window.clearInterval(y)},[m,h,r.pollMs]);const v=f.useCallback(()=>{h()},[h]);return{data:n,isLoading:o,error:c!==null&&n===null?c:null,reload:v}}const tR=15e3,rR=["hour","day","week"];function Rv(e){return e.unavailable||e.usd===null?-1:e.usd}function $v(e){return e.key??"unknown"}function Bv(e,t){return e.key??t}function hx(e){return Ml(e.key??"")}function nR({group:e,unknownLabel:t}){const r=e.key??t;return s.jsxs("span",{className:"cc-model-label",children:[s.jsx(eh,{provider:hx(e),size:"sm"}),s.jsx("span",{className:"cc-model-label-text",children:r})]})}function aR(e,t,r){const n=[...e];return n.sort((a,i)=>{let o=0;return t==="key"?o=(a.key??"").localeCompare(i.key??""):t==="totalTokens"?o=a.totalTokens-i.totalTokens:o=Rv(a.cost)-Rv(i.cost),o===0&&(o=(a.key??"").localeCompare(i.key??"")),o*r}),n}function iR({range:e}){const{t}=le("app"),[r,n]=f.useState("day"),a=`/command-center/tokens?groupBy=model&granularity=${r}`,{data:i,isLoading:o,error:l}=Ge(a,e,{pollMs:tR}),c=f.useMemo(()=>i?.groups??[],[i?.groups]),d=f.useMemo(()=>i?.series??[],[i?.series]),[u,m]=f.useState("totalTokens"),[h,v]=f.useState(-1),y=f.useMemo(()=>c.map(A=>A.key??"∅").join(" "),[c]),g=f.useRef(null);f.useEffect(()=>{if(g.current===null){g.current=y;return}g.current!==y&&(g.current=y,m("totalTokens"),v(-1))},[y]);const p=f.useMemo(()=>aR(c,u,h),[c,u,h]),b=f.useMemo(()=>[...c].sort((A,_)=>_.totalTokens-A.totalTokens||(A.key??"").localeCompare(_.key??"")),[c]),j=f.useMemo(()=>b.map(A=>({label:Bv(A,t("commandCenter.tokens.unknownModel","(unknown)")),value:A.totalTokens,valueLabel:K(A.totalTokens),iconProvider:hx(A)})),[b,t]),x=f.useMemo(()=>b.map(A=>({label:Bv(A,t("commandCenter.tokens.unknownModel","(unknown)")),value:A.totalTokens})),[b,t]),C=f.useMemo(()=>[{label:t("commandCenter.tokens.input","Input"),values:d.map(A=>A.inputTokens)},{label:t("commandCenter.tokens.output","Output"),values:d.map(A=>A.outputTokens)},{label:t("commandCenter.tokens.cached","Cached"),values:d.map(A=>A.cachedTokens)},{label:t("commandCenter.tokens.total","Total"),values:d.map(A=>A.totalTokens)}],[d,t]);function w(A){A===u?v(_=>_===1?-1:1):(m(A),v(A==="key"?1:-1))}function P(A){return A!==u?null:s.jsx("span",{className:"cc-sort-caret",children:h===1?"▲":"▼"})}const O=i?.totals,k=f.useMemo(()=>d.map(A=>A.bucket).join(" "),[d]),N=O?.totalTokens??0,S=!i||N===0;return s.jsxs(Pt,{testId:"tokens",isLoading:o,error:l,isEmpty:S,children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.tokens.totalsTitle","Totals")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-tokens-total",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.tokens.totalTokens","Total tokens")}),s.jsx("div",{className:"cc-stat-value cc-token-count-live",children:K(N)},N)]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-tokens-cost",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.tokens.cost","Estimated cost")}),s.jsx("div",{className:"cc-stat-value",children:i?Sr(i.cost.usd,i.cost.unavailable):"—"}),i?.cost.stale?s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.tokens.stalePricing","pricing may be stale")}):null]}),s.jsxs("div",{className:"card cc-stat-card",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.tokens.tasks","Tasks")}),s.jsx("div",{className:"cc-stat-value",children:K(O?.nTasks??0)})]})]})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsxs("div",{className:"cc-area-section-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.tokens.overTimeChart","Tokens over time")}),s.jsx("div",{className:"cc-token-granularity",role:"group","aria-label":t("commandCenter.tokens.granularity","Token chart granularity"),children:rR.map(A=>s.jsx("button",{type:"button",className:`btn ${A===r?"active":""}`,"aria-pressed":A===r,"data-testid":`cc-token-granularity-${A}`,onClick:()=>n(A),children:t(`commandCenter.tokens.granularity.${A}`,A)},A))})]}),s.jsx(Q0,{points:d,ariaLabel:t("commandCenter.tokens.overTimeChart","Tokens over time")},k)]}),d.length>0?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-tokens-line",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.tokens.rechartsLine","Tokens trend")}),s.jsx(cr,{series:C,ariaLabel:t("commandCenter.tokens.rechartsLine","Tokens trend")})]}):null,s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.tokens.byModelChart","Tokens by model")}),s.jsx(Ze,{data:j,ariaLabel:t("commandCenter.tokens.byModelChart","Tokens by model")})]}),x.length>0?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-tokens-pie",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.tokens.pieChart","Token share by model")}),s.jsx(kt,{data:x,ariaLabel:t("commandCenter.tokens.pieChart","Token share by model")})]}):null,s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.tokens.tableTitle","Per-model breakdown")}),s.jsx("div",{className:"cc-table-wrap",children:s.jsxs("table",{className:"cc-table","data-testid":"cc-tokens-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsxs("th",{className:"cc-sortable",onClick:()=>w("key"),"data-testid":"cc-tokens-sort-key",children:[t("commandCenter.tokens.model","Model"),P("key")]}),s.jsx("th",{children:t("commandCenter.tokens.input","Input")}),s.jsx("th",{children:t("commandCenter.tokens.output","Output")}),s.jsx("th",{children:t("commandCenter.tokens.cached","Cached")}),s.jsxs("th",{className:"cc-sortable",onClick:()=>w("totalTokens"),"data-testid":"cc-tokens-sort-total",children:[t("commandCenter.tokens.total","Total"),P("totalTokens")]}),s.jsxs("th",{className:"cc-sortable",onClick:()=>w("cost"),"data-testid":"cc-tokens-sort-cost",children:[t("commandCenter.tokens.costCol","Cost"),P("cost")]})]})}),s.jsx("tbody",{children:p.map(A=>s.jsxs("tr",{"data-testid":`cc-tokens-row-${$v(A)}`,children:[s.jsx("td",{children:s.jsx(nR,{group:A,unknownLabel:t("commandCenter.tokens.unknownModel","(unknown)")})}),s.jsx("td",{children:K(A.inputTokens)}),s.jsx("td",{children:K(A.outputTokens)}),s.jsx("td",{children:K(A.cachedTokens)}),s.jsx("td",{children:K(A.totalTokens)}),s.jsx("td",{children:A.cost.unavailable||A.cost.usd===null?s.jsx("span",{className:"cc-unavailable",title:t("commandCenter.tokens.costUnavailable","No pricing for this model"),children:"—"}):Sr(A.cost.usd,A.cost.unavailable)})]},$v(A)))})]})})]})]})}function sR({range:e}){const{t}=le("app"),{data:r,isLoading:n,error:a}=Ge("/command-center/tools",e),i=f.useMemo(()=>[...r?.byCategory??[]].sort((u,m)=>m.count-u.count||u.category.localeCompare(m.category)),[r?.byCategory]),o=f.useMemo(()=>i.map(u=>({label:u.category,value:u.count,valueLabel:K(u.count)})),[i]),l=f.useMemo(()=>i.map(u=>({label:u.category,value:u.count})),[i]),c=!r||r.toolCalls===0,d=r?r.fullyAutonomous?t("commandCenter.tools.ratioAutonomous","{{ratio}} calls/session (fully autonomous)",{ratio:r.autonomyRatio.toFixed(1)}):`${r.autonomyRatio.toFixed(1)}:1`:"—";return s.jsxs(Pt,{testId:"tools",isLoading:n,error:a,isEmpty:c,children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.tools.summaryTitle","Summary")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-tools-autonomy",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.tools.autonomyRatio","Autonomy ratio")}),s.jsx("div",{className:"cc-stat-value",children:d}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.tools.autonomyHint","tool calls per human intervention")})]}),s.jsxs("div",{className:"card cc-stat-card",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.tools.toolCalls","Tool calls")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.toolCalls??0)})]}),s.jsxs("div",{className:"card cc-stat-card",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.tools.interventions","Interventions")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.interventions.total??0)}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.tools.interventionBreakdown","{{approvals}} approvals · {{steers}} steers",{approvals:K(r?.interventions.approvals??0),steers:K(r?.interventions.userSteers??0)})})]}),s.jsxs("div",{className:"card cc-stat-card",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.tools.sessions","Sessions")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.sessions??0)})]})]})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.tools.categoriesTitle","Tool categories")}),s.jsx(Ze,{data:o,ariaLabel:t("commandCenter.tools.categoriesTitle","Tool categories")})]}),l.length>0?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-tools-pie",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.tools.pieChart","Tool category share")}),s.jsx(kt,{data:l,ariaLabel:t("commandCenter.tools.pieChart","Tool category share")})]}):null]})}const oR=250,lR=100,kl=1.8,qr=3,cR={width:oR,height:lR};function uR(e,t){if(!Number.isFinite(e)||e<=0)return 0;const r=Number.isFinite(t)&&t>0?t:1;return Math.max(0,Math.min(100,e/r*100))}function Fv(e){return Number.isFinite(e)?e:0}function dR(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||e<=0||t<=0?null:{width:Math.max(e,qr*2+kl*2),height:Math.max(t,qr*2+kl*2)}}function fR(e,t,r,n,a){const i=Math.max(0,a.width-qr*2),o=Math.max(0,a.height-qr*2),l=r<=1?a.width/2:qr+t/(r-1)*i,c=uR(e,n);return{x:Fv(l),y:Fv(qr+o*(1-c/100))}}function mR(e,t,r){return e.map((n,a)=>fR(n,a,e.length,t,r))}function vR(e){return e.map(t=>`${t.x},${t.y}`).join(" ")}function hR(e,t){return Number.isFinite(t)&&t!==void 0&&t>0?t:e.reduce((r,n)=>{const a=n.values.reduce((i,o)=>Number.isFinite(o)&&o>i?o:i,0);return a>r?a:r},0)}function zv(e){return dR(e.width,e.height)}function pR(e,t){return Math.abs(e.width-t.width)<.5&&Math.abs(e.height-t.height)<.5}function ya({series:e,ariaLabel:t,max:r}){const n=f.useRef(null),[a,i]=f.useState(cR),o=hR(e,r);return f.useLayoutEffect(()=>{const l=n.current;if(!l)return;const c=u=>{u&&i(m=>pR(m,u)?m:u)};if(c(zv(l.getBoundingClientRect())),typeof ResizeObserver>"u")return;const d=new ResizeObserver(u=>{const m=u[0];m&&c(zv(m.contentRect))});return d.observe(l),()=>d.disconnect()},[]),s.jsx("svg",{ref:n,className:"cc-line-chart",role:"img","aria-label":t,viewBox:`0 0 ${a.width} ${a.height}`,preserveAspectRatio:"none",children:e.map((l,c)=>{const d=mR(l.values,o,a),u=vR(d);return s.jsxs("g",{className:"cc-line-chart-series","aria-label":l.label,children:[d.length>1?s.jsx("polyline",{className:"cc-line-chart-path",points:u,pathLength:a.width,vectorEffect:"non-scaling-stroke","aria-hidden":"true"}):null,d.map((m,h)=>s.jsx("circle",{className:"cc-line-chart-point",cx:m.x,cy:m.y,r:kl,vectorEffect:"non-scaling-stroke","aria-hidden":"true"},h))]},c)})})}function yR(e,t){if(!Number.isFinite(e)||e<=0)return 0;const r=Number.isFinite(t)&&t>0?t:1;return Math.max(0,Math.min(100,e/r*100))}function Kt({values:e,ariaLabel:t,max:r}){const n=r??e.reduce((a,i)=>i>a?i:a,0);return s.jsx("div",{className:"cc-sparkline",role:"img","aria-label":t,children:e.map((a,i)=>{const o=yR(a,n);return s.jsx("div",{className:"cc-sparkline-bar",style:{height:`${o}%`},"aria-hidden":"true"},i)})})}const gR=15e3;function bR({range:e}){const{t}=le("app"),{data:r,isLoading:n,error:a,reload:i}=Ge("/command-center/activity",e),o=f.useMemo(()=>r?.daily??[],[r?.daily]),l=f.useMemo(()=>o.map(j=>j.messages),[o]),c=f.useMemo(()=>o.map(j=>j.activeAgents),[o]),d=f.useMemo(()=>o.map(j=>j.activeNodes),[o]),u=f.useMemo(()=>o.map(j=>j.agentRuns),[o]),m=f.useMemo(()=>o.map(j=>j.messages+j.activeAgents+j.activeNodes),[o]),h=f.useMemo(()=>[{label:t("commandCenter.activity.messages","Messages"),values:l},{label:t("commandCenter.activity.activeAgents","Active agents"),values:c},{label:t("commandCenter.activity.agentRuns","Agent runs"),values:u}],[u,c,l,t]),v=Fh(e),y=n&&r===null;f.useEffect(()=>{if(v)return;const j=window.setInterval(()=>{i()},gR);return()=>window.clearInterval(j)},[v,i]);const g=r?.agentRuns??{total:0,active:0,completed:0,failed:0},p=f.useMemo(()=>[{label:t("commandCenter.activity.agentRunsActive","Active"),value:g.active},{label:t("commandCenter.activity.agentRunsCompleted","Completed"),value:g.completed},{label:t("commandCenter.activity.agentRunsFailed","Failed"),value:g.failed}].filter(j=>j.value>0),[g.active,g.completed,g.failed,t]),b=!r||r.sessions===0&&r.messages===0&&r.activeNodes===0&&r.activeAgents===0&&g.total===0;return s.jsxs(Pt,{testId:"activity",isLoading:y,error:a,isEmpty:b,children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.activity.summaryTitle","Summary")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-activity-sessions",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.activity.sessions","Sessions")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.sessions??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-activity-messages",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.activity.messages","Messages")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.messages??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-activity-nodes",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.activity.activeNodes","Active nodes")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.activeNodes??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-activity-agents",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.activity.activeAgents","Active agents")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.activeAgents??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-activity-agent-runs",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.activity.agentRuns","Agent runs")}),s.jsx("div",{className:"cc-stat-value",children:K(g.total)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-activity-agent-runs-active",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.activity.agentRunsActive","Active")}),s.jsx("div",{className:"cc-stat-value",children:K(g.active)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-activity-agent-runs-completed",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.activity.agentRunsCompleted","Completed")}),s.jsx("div",{className:"cc-stat-value",children:K(g.completed)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-activity-agent-runs-failed",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.activity.agentRunsFailed","Failed")}),s.jsx("div",{className:"cc-stat-value",children:K(g.failed)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-activity-stickiness",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.activity.stickiness","Stickiness")}),s.jsx("div",{className:"cc-stat-value",children:r?`${Math.round(r.stickiness*100)}%`:"—"}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.activity.stickinessHint","DAU / MAU")})]})]})]}),o.length>0?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-activity-line",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.activity.rechartsLine","Activity trend")}),s.jsx(cr,{series:h,ariaLabel:t("commandCenter.activity.rechartsLine","Activity trend"),scaleMode:"series"})]}):null,p.length>0?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-activity-pie",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.activity.agentRunOutcomeShare","Agent run outcome share")}),s.jsx(kt,{data:p,ariaLabel:t("commandCenter.activity.agentRunOutcomeShare","Agent run outcome share")})]}):null,s.jsxs("div",{className:"cc-area-section","data-testid":"cc-activity-line-messages",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.activity.messagesPerDay","Messages / day")}),s.jsx(ya,{series:[{label:t("commandCenter.activity.messages","Messages"),values:l}],ariaLabel:t("commandCenter.activity.messagesPerDay","Messages / day")})]}),s.jsxs("div",{className:"cc-area-section","data-testid":"cc-activity-line-agents",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.activity.agentsPerDay","Active agents / day")}),s.jsx(ya,{series:[{label:t("commandCenter.activity.activeAgents","Active agents"),values:c}],ariaLabel:t("commandCenter.activity.agentsPerDay","Active agents / day")})]}),s.jsxs("div",{className:"cc-area-section","data-testid":"cc-activity-line-nodes",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.activity.nodesPerDay","Active nodes / day")}),s.jsx(ya,{series:[{label:t("commandCenter.activity.activeNodes","Active nodes"),values:d}],ariaLabel:t("commandCenter.activity.nodesPerDay","Active nodes / day")})]}),s.jsxs("div",{className:"cc-area-section","data-testid":"cc-activity-agent-runs-sparkline",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.activity.agentRunsPerDay","Agent runs / day")}),s.jsx(Kt,{values:u,ariaLabel:t("commandCenter.activity.agentRunsPerDay","Agent runs / day")})]}),s.jsxs("div",{className:"cc-area-section","data-testid":"cc-activity-line-throughput",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.activity.throughputPerDay","Throughput / day")}),s.jsx(ya,{series:[{label:t("commandCenter.activity.throughput","Throughput"),values:m}],ariaLabel:t("commandCenter.activity.throughputPerDay","Throughput / day")})]})]})}function xR({range:e}){const{t}=le("app"),{confirm:r}=th(),{data:n,isLoading:a,error:i}=Ge("/command-center/productivity",e),[o,l]=f.useState(!1),[c,d]=f.useState(null),[u,m]=f.useState(null),h=f.useCallback(async()=>{if(!o){l(!0),m(null),d(null);try{const D=await fu({dryRun:!0});d(D)}catch(D){m(D instanceof Error?D.message:t("commandCenter.productivity.backfillFailed","Failed to backfill historical LOC stats"))}finally{l(!1)}}},[o,t]),v=f.useCallback(async()=>{if(!(o||!await r({title:t("commandCenter.productivity.backfillConfirmTitle","Apply LOC backfill?"),message:t("commandCenter.productivity.backfillConfirmMessage","This will persist diff stats to task_commit_associations for historical commit associations. Review the dry-run counts before applying."),confirmLabel:t("commandCenter.productivity.backfillApply","Apply backfill"),cancelLabel:t("common.cancel","Cancel"),danger:!0}))){l(!0),m(null);try{const F=await fu({dryRun:!1});d(F)}catch(F){m(F instanceof Error?F.message:t("commandCenter.productivity.backfillFailed","Failed to backfill historical LOC stats"))}finally{l(!1)}}},[r,o,t]),y=f.useMemo(()=>(n?.byLanguage??[]).slice(0,12).map(D=>({label:D.language,value:D.count,valueLabel:K(D.count)})),[n?.byLanguage]),g=f.useMemo(()=>(n?.byLanguage??[]).slice(0,12).map(D=>({label:D.language,value:D.count})),[n?.byLanguage]),p=n?.taskDuration??{completedTasks:0,averageMs:null,medianMs:null,p90Ms:null,totalMs:null,unavailable:!0},b=f.useMemo(()=>(n?.taskDurationTrend??[]).filter(D=>!D.unavailable&&D.completedTasks>0&&D.averageMs!==null&&D.medianMs!==null&&Number.isFinite(D.averageMs)&&Number.isFinite(D.medianMs)),[n?.taskDurationTrend]),j=f.useMemo(()=>[{label:t("commandCenter.productivity.averageDuration","Average"),values:b.map(D=>D.averageMs??0)},{label:t("commandCenter.productivity.medianDuration","Median"),values:b.map(D=>D.medianMs??0)}],[t,b]),x=f.useMemo(()=>b.map(D=>D.bucket),[b]),C=b.length>0,w=n?.loc??{value:null,unavailable:!0},P=n?.hoursSaved??{value:null,unavailable:!0},O=!n||n.modifiedFiles===0&&n.commits===0&&n.pullRequests===0&&p.completedTasks===0,k=!n||w.unavailable||w.value===null,N=!n||P.unavailable||P.value===null,S=!n||p.unavailable,A=t("commandCenter.productivity.durationUnavailable","Task duration is unavailable until completed tasks have active execution time recorded"),_=u?"cc-productivity-backfill-status--error":o?"cc-productivity-backfill-status--warning":"",I=(D,F)=>S||D===null?s.jsx("span",{className:"cc-unavailable",title:A,"data-testid":F,children:"—"}):Eu(D);return s.jsxs(Pt,{testId:"productivity",isLoading:a,error:i,isEmpty:O,children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.productivity.outcomesTitle","Outcomes")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-productivity-commits",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.productivity.commits","Commits")}),s.jsx("div",{className:"cc-stat-value",children:K(n?.commits??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-productivity-prs",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.productivity.pullRequests","Pull requests")}),s.jsx("div",{className:"cc-stat-value",children:K(n?.pullRequests??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-productivity-hours-saved",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.productivity.hoursSaved","Human hours saved")}),s.jsx("div",{className:"cc-stat-value",children:N?s.jsx("span",{className:"cc-unavailable",title:t("commandCenter.productivity.hoursSavedUnavailable","Estimated human hours saved is unavailable until commit diff stats exist"),"data-testid":"cc-productivity-hours-saved-unavailable",children:"—"}):K(P.value??0)}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.productivity.hoursSavedEstimate","estimate from lines changed")})]})]})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.productivity.volumeTitle","Volume (proxy)")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-productivity-files",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.productivity.modifiedFiles","Files modified")}),s.jsx("div",{className:"cc-stat-value",children:K(n?.modifiedFiles??0)}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.productivity.volumeHint","volume, not outcome")})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-productivity-loc",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.productivity.loc","Lines changed")}),s.jsx("div",{className:"cc-stat-value",children:k?s.jsx("span",{className:"cc-unavailable",title:t("commandCenter.productivity.locUnavailable","LOC is unavailable until commit diff stats are recorded"),"data-testid":"cc-productivity-loc-unavailable",children:"—"}):K(w.value??0)}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.productivity.volumeHint","volume, not outcome")}),s.jsxs("div",{className:"cc-productivity-backfill-actions",children:[s.jsxs("button",{type:"button",className:"btn","data-testid":"cc-productivity-backfill-button",onClick:()=>void h(),disabled:o,children:[s.jsx(Gr,{className:o?"spin":void 0}),s.jsx("span",{children:o?t("commandCenter.productivity.backfillBusy","Checking historical LOC…"):t("commandCenter.productivity.backfillButton","Preview LOC backfill")})]}),c?.dryRun?s.jsx("button",{type:"button",className:"btn","data-testid":"cc-productivity-backfill-apply-button",onClick:()=>void v(),disabled:o,children:t("commandCenter.productivity.backfillApply","Apply backfill")}):null]}),o||c||u?s.jsxs("div",{className:`cc-productivity-backfill-status ${_}`.trim(),"data-testid":"cc-productivity-backfill-result",role:"status",children:[o?s.jsx("span",{children:t("commandCenter.productivity.backfillPending","LOC backfill check is running.")}):null,u?s.jsx("span",{children:u}):null,c?s.jsxs(s.Fragment,{children:[s.jsx("span",{children:t("commandCenter.productivity.backfillResult","Backfill report")}),s.jsx("span",{children:c.dryRun?t("commandCenter.productivity.backfillPreviewLabel","Dry-run preview"):t("commandCenter.productivity.backfillAppliedLabel","Applied")}),s.jsxs("span",{children:[t("commandCenter.productivity.backfillScannedRows","Scanned rows"),": ",c.scannedRows]}),s.jsxs("span",{children:[t("commandCenter.productivity.backfillDistinctCommits","Distinct commits"),": ",c.distinctCommits]}),s.jsxs("span",{children:[t("commandCenter.productivity.backfillUpdatedRows","Updated rows"),": ",c.updatedRows]}),s.jsxs("span",{children:[t("commandCenter.productivity.backfillSkippedUnavailableCommits","Skipped unavailable commits"),": ",c.skippedUnavailableCommits]}),s.jsxs("span",{children:[t("commandCenter.productivity.backfillSkippedInvalidShas","Skipped invalid SHAs"),": ",c.skippedInvalidShas]})]}):null]}):null]})]})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.productivity.durationTitle","Task duration")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-productivity-duration-completed",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.productivity.completedTasks","Completed tasks")}),s.jsx("div",{className:"cc-stat-value",children:K(p.completedTasks)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-productivity-duration-avg",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.productivity.averageDuration","Average")}),s.jsx("div",{className:"cc-stat-value",children:I(p.averageMs,"cc-productivity-duration-avg-unavailable")})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-productivity-duration-median",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.productivity.medianDuration","Median")}),s.jsx("div",{className:"cc-stat-value",children:I(p.medianMs,"cc-productivity-duration-median-unavailable")})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-productivity-duration-p90",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.productivity.p90Duration","P90")}),s.jsx("div",{className:"cc-stat-value",children:I(p.p90Ms,"cc-productivity-duration-p90-unavailable")})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-productivity-duration-total",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.productivity.totalDuration","Total active")}),s.jsx("div",{className:"cc-stat-value",children:I(p.totalMs,"cc-productivity-duration-total-unavailable")})]})]})]}),C?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-productivity-duration-trend",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.productivity.durationTrendTitle","Task duration over time")}),s.jsx(cr,{series:j,ariaLabel:t("commandCenter.productivity.durationTrendTitle","Task duration over time"),xAxisLabels:x,valueFormatter:Eu})]}):null,s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.productivity.byLanguage","Files by language")}),s.jsx(Ze,{data:y,ariaLabel:t("commandCenter.productivity.byLanguage","Files by language")})]}),g.length>0?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-productivity-pie",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.productivity.languagePie","Language share")}),s.jsx(kt,{data:g,ariaLabel:t("commandCenter.productivity.languagePie","Language share")})]}):null]})}const jR=15e3,wR=1e4,CR=4,Oo=[.1,.25,.5,1,2,3,5,10];function Kv(e){return e.unavailable||e.usd===null?-1:e.usd}function hi(e,t){return e.agentName??e.agentId??t}function kR(e){switch(e){case"running":return"status-dot status-dot--connecting";case"active":case"idle":return"status-dot status-dot--online";case"error":case"failed":return"status-dot status-dot--error";case"starting":case"pending":return"status-dot status-dot--pending";default:return"status-dot status-dot--pending"}}function PR(e,t,r,n){const a=[...e];return a.sort((i,o)=>{let l=0;return t==="agent"?l=hi(i,n).localeCompare(hi(o,n)):t==="tokens"?l=i.tokens.totalTokens-o.tokens.totalTokens:t==="cost"?l=Kv(i.cost)-Kv(o.cost):t==="filesChanged"?l=i.filesChanged-o.filesChanged:t==="tasksCompleted"?l=i.tasksCompleted-o.tasksCompleted:l=i.tasksInProgress-o.tasksInProgress,l===0&&(l=i.agentId.localeCompare(o.agentId)),l*r}),a}function Vv(e,t,r){return[...e].sort((n,a)=>t(a)-t(n)||n.agentId.localeCompare(a.agentId)).slice(0,12).map(n=>{const a=t(n);return{label:hi(n,r),value:a,valueLabel:K(a)}})}function SR(e,t){if(!e)return t;const r=new Date(e);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function NR({paused:e,label:t}){return s.jsxs("span",{className:"cc-team-status-pill",children:[s.jsx("span",{className:`status-dot ${e?"status-dot--pending":"status-dot--online"}`,"aria-hidden":"true"}),s.jsx("span",{children:t})]})}function px({node:e}){const t=e.children.length>0;return s.jsxs("li",{className:"cc-team-org-item",children:[s.jsx("div",{className:"cc-team-org-card",children:s.jsxs("div",{className:"cc-team-org-card-header",children:[s.jsx("span",{className:"cc-team-org-avatar",children:s.jsx(Kx,{agent:e.agent,size:20})}),s.jsx("span",{className:"cc-team-org-name",children:e.agent.name}),s.jsx("span",{className:"cc-team-org-badge",children:e.agent.state})]})}),t?s.jsx("ul",{className:"cc-team-org-children",children:e.children.map(r=>s.jsx(px,{node:r},r.agent.id))}):null]})}function OR({range:e,projectId:t,addToast:r}){const{t:n}=le("app"),{globalPaused:a,enginePaused:i,toggleEnginePause:o}=rh(t),[l,c]=f.useState(1),[d,u]=f.useState(!1),[m,h]=f.useState({status:"loading",data:null,error:null}),[v,y]=f.useState({status:"loading",data:null,error:null}),g=f.useRef(null),p=f.useRef(!0);f.useEffect(()=>(p.current=!0,()=>{p.current=!1,g.current&&clearTimeout(g.current)}),[]);const b=f.useRef(null),j=f.useRef(null),x=f.useRef(!1),[C,w]=f.useState(!1),[P,O]=f.useState(0),{data:k,isLoading:N,error:S}=Ge("/command-center/team",e,{pollMs:jR});f.useEffect(()=>{let E=!1;return h({status:"loading",data:null,error:null}),(async()=>{try{const T=await $x(t);E||h({status:"loaded",data:T,error:null})}catch(T){E||h({status:"error",data:null,error:T instanceof Error?T.message:n("commandCenter.controls.orgChart.error","Unable to load org chart")})}})(),()=>{E=!0}},[t,n]),f.useEffect(()=>{const E=b.current;if(!E)return;const T=()=>{O(E.clientWidth)};T();const J=typeof ResizeObserver<"u"?new ResizeObserver(T):null;return J?.observe(E),window.addEventListener("resize",T),()=>{J?.disconnect(),window.removeEventListener("resize",T)}},[m.status]),f.useEffect(()=>{let E=!1,T;const J=async()=>{try{const dt=await zx(t);E||y({status:"loaded",data:dt,error:null})}catch(dt){E||y({status:"error",data:null,error:dt instanceof Error?dt.message:n("commandCenter.controls.status.error","Unable to load live scheduler status")})}finally{E||(T=setTimeout(J,wR))}};return y({status:"loading",data:null,error:null}),J(),()=>{E=!0,T&&clearTimeout(T)}},[t,n]),f.useEffect(()=>{let E=!1;return nh(t).then(T=>{E||c(T.heartbeatMultiplier??1)}).catch(()=>{}),()=>{E=!0}},[t]);const A=f.useCallback(E=>{const T=Number.isFinite(E)&&E>0?E:1;c(T),g.current&&clearTimeout(g.current),g.current=setTimeout(()=>{g.current=null,p.current&&u(!0),(async()=>{try{await ah({heartbeatMultiplier:T},t),p.current&&r?.(n("agents.heartbeatSpeedSet","Heartbeat speed set to ×{{value}}",{value:T.toFixed(1)}),"success")}catch(J){p.current&&r?.(n("agents.heartbeatSpeedSaveFailed","Failed to save heartbeat multiplier: {{error}}",{error:Bx(J)}),"error")}finally{p.current&&u(!1)}})()},300)},[t,r,n]),_=f.useMemo(()=>k?.agents??[],[k?.agents]),I=n("commandCenter.team.unknownAgent","(unknown agent)"),D=n("commandCenter.team.unknownRole","Unknown role"),F=n("commandCenter.team.noChartData","No non-zero values for this chart yet."),[V,U]=f.useState("tokens"),[te,q]=f.useState(-1),ee=f.useMemo(()=>_.map(E=>E.agentId).join(" "),[_]),L=f.useRef(null);f.useEffect(()=>{if(L.current===null){L.current=ee;return}L.current!==ee&&(L.current=ee,U("tokens"),q(-1))},[ee]);const B=f.useMemo(()=>PR(_,V,te,I),[_,te,V,I]),X=f.useMemo(()=>Vv(_,E=>E.tokens.totalTokens,I),[_,I]),Q=f.useMemo(()=>X.map(E=>({label:E.label,value:E.value})),[X]),G=f.useMemo(()=>Vv(_,E=>E.tasksCompleted,I),[_,I]),ie=X.some(E=>E.value>0),se=G.some(E=>E.value>0),re=f.useMemo(()=>_.flatMap(E=>[E.tokens.totalTokens,E.filesChanged,E.tasksCompleted]),[_]);function W(E){E===V?q(T=>T===1?-1:1):(U(E),q(E==="agent"?1:-1))}function $(E){return E!==V?null:s.jsx("span",{className:"cc-sort-caret",children:te===1?"▲":"▼"})}const ne=f.useCallback(E=>{const T=j.current;!T||T.pointerId!==E.pointerId||(E.currentTarget.hasPointerCapture?.(E.pointerId)&&E.currentTarget.releasePointerCapture?.(E.pointerId),j.current=null,w(!1))},[]),we=f.useCallback(E=>{if(E.pointerType==="touch"||E.button!==0)return;const T=E.currentTarget;x.current=!1,j.current={pointerId:E.pointerId,startX:E.clientX,startY:E.clientY,startScrollLeft:T.scrollLeft,startScrollTop:T.scrollTop,isPanning:!1},T.setPointerCapture?.(E.pointerId)},[]),z=f.useCallback(E=>{const T=j.current;if(!T||T.pointerId!==E.pointerId)return;const J=E.clientX-T.startX,dt=E.clientY-T.startY;if(!T.isPanning&&Math.hypot(J,dt)<CR)return;T.isPanning||(T.isPanning=!0,x.current=!0,w(!0)),E.preventDefault();const dr=E.currentTarget;dr.scrollLeft=T.startScrollLeft-J,dr.scrollTop=T.startScrollTop-dt},[]),fe=f.useCallback(E=>{x.current&&(x.current=!1,E.preventDefault(),E.stopPropagation())},[]),be=f.useMemo(()=>m.status!=="loaded"||P<=0&&m.data.length>1?"vertical":n0({tree:m.data,availableWidth:P,preference:"auto"}),[P,m]),ye=v.data?.globalPause??a,nt=v.data?.enginePaused??i,ur=SR(v.data?.lastActivityAt,n("commandCenter.controls.status.noActivity","No recent activity"));return s.jsxs("div",{className:"cc-team-area",children:[s.jsxs("div",{className:"cc-team-ops-grid","data-testid":"cc-team-ops",children:[s.jsxs("section",{className:"card cc-team-ops-card cc-team-ops-card--org","data-testid":"cc-team-org-chart",children:[s.jsx("div",{className:"cc-team-ops-card-header",children:s.jsx("div",{children:s.jsx("h3",{children:n("commandCenter.controls.orgChart.title","Agent org chart")})})}),s.jsx("div",{className:`cc-team-org-scroll${C?" is-dragging":""}`,"data-layout":be,ref:b,"aria-live":"polite",onPointerDown:we,onPointerMove:z,onPointerUp:ne,onPointerCancel:ne,onPointerLeave:ne,onClickCapture:fe,children:m.status==="loading"?s.jsx("p",{className:"cc-team-muted",children:s.jsx(Tl,{label:n("commandCenter.controls.orgChart.loading","Loading org chart…")})}):m.status==="error"?s.jsx("p",{className:"cc-team-error",role:"alert",children:m.error}):m.data.length===0?s.jsx("p",{className:"cc-team-muted",children:n("commandCenter.controls.orgChart.empty","No agents are reporting in yet.")}):s.jsx("ul",{className:"cc-team-org-roots",children:m.data.map(E=>s.jsx(px,{node:E},E.agent.id))})})]}),s.jsxs("section",{className:"card cc-team-ops-card cc-team-ops-card--heartbeat","data-testid":"cc-team-heartbeat",children:[s.jsxs("div",{className:"cc-team-ops-card-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:n("commandCenter.controls.heartbeat.title","Heartbeat control")}),s.jsx("p",{children:n("commandCenter.controls.heartbeat.description","Pause or resume the scheduling heartbeat.")})]}),s.jsx(NR,{paused:nt,label:nt?n("commandCenter.controls.status.paused","Paused"):n("commandCenter.controls.status.running","Running")})]}),s.jsxs("dl",{className:"cc-team-facts",children:[s.jsxs("div",{children:[s.jsx("dt",{children:n("commandCenter.controls.status.lastActivity","Last activity")}),s.jsx("dd",{children:v.status==="loading"?n("commandCenter.controls.status.loading","Loading…"):ur})]}),s.jsxs("div",{children:[s.jsx("dt",{children:n("commandCenter.controls.status.maxConcurrent","Max concurrent")}),s.jsx("dd",{children:v.data?.maxConcurrent??"—"})]})]}),v.status==="error"?s.jsx("p",{className:"cc-team-error",role:"alert",children:v.error}):null,s.jsxs("button",{type:"button",className:"btn btn-secondary cc-team-action",onClick:()=>void o(),disabled:ye,children:[nt?s.jsx(Il,{size:16,"aria-hidden":"true"}):s.jsx(Fx,{size:16,"aria-hidden":"true"}),s.jsx("span",{children:nt?n("commandCenter.controls.heartbeat.resume","Resume heartbeat"):n("commandCenter.controls.heartbeat.pause","Pause heartbeat")})]}),ye?s.jsx("p",{className:"cc-team-muted",children:n("commandCenter.controls.heartbeat.disabledByStop","Start the AI engine before resuming the heartbeat.")}):null,s.jsxs("div",{className:"cc-team-heartbeat-multiplier heartbeat-multiplier-group",children:[s.jsxs("div",{className:"heartbeat-multiplier-controls",children:[s.jsx("label",{htmlFor:"ccHeartbeatMultiplier",className:"heartbeat-multiplier-label",children:n("agents.heartbeatSpeed","Heartbeat Speed")}),s.jsx("input",{id:"ccHeartbeatMultiplier",className:"heartbeat-multiplier-slider touch-target",type:"range",min:.1,max:10,step:.1,value:l,onChange:E=>{const T=Number(E.target.value);A(Number.isFinite(T)&&T>0?T:1)},disabled:d}),s.jsxs("span",{className:"heartbeat-multiplier-value",children:["×",l.toFixed(1)]}),s.jsx("select",{className:"heartbeat-multiplier-preset",value:String(Oo.reduce((E,T)=>Math.abs(T-l)<Math.abs(E-l)?T:E,Oo[0])),onChange:E=>{const T=Number(E.target.value);A(Number.isFinite(T)&&T>0?T:1)},disabled:d,"aria-label":n("agents.heartbeatSpeedPreset","Heartbeat speed preset"),children:Oo.map(E=>s.jsxs("option",{value:String(E),children:["×",E]},E))})]}),s.jsx("small",{className:"text-secondary",children:n("agents.heartbeatSpeedHint","Scales all agent heartbeat intervals. ×0.5 = twice as fast, ×2.0 = twice as slow. Default: ×1.0")})]})]})]}),s.jsxs(Pt,{testId:"team",isLoading:N,error:S,isEmpty:!k||k.agents.length===0,emptyMessage:n("commandCenter.team.empty","No agents have reported team analytics yet."),children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:n("commandCenter.team.totalsTitle","Team totals")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-team-total-tokens",children:[s.jsx("div",{className:"cc-stat-label",children:n("commandCenter.team.totalTokens","Total tokens")}),s.jsx("div",{className:"cc-stat-value",children:K(k?.totals.tokens.totalTokens??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-team-total-cost",children:[s.jsx("div",{className:"cc-stat-label",children:n("commandCenter.team.totalCost","Estimated cost")}),s.jsx("div",{className:"cc-stat-value",children:k?Sr(k.totals.cost.usd,k.totals.cost.unavailable):"—"})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-team-total-files",children:[s.jsx("div",{className:"cc-stat-label",children:n("commandCenter.team.filesChanged","Files changed")}),s.jsx("div",{className:"cc-stat-value",children:K(k?.totals.filesChanged??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-team-total-completed",children:[s.jsx("div",{className:"cc-stat-label",children:n("commandCenter.team.tasksCompleted","Tasks done")}),s.jsx("div",{className:"cc-stat-value",children:K(k?.totals.tasksCompleted??0)})]})]})]}),s.jsxs("div",{className:"cc-area-section cc-team-chart-grid",children:[ie?s.jsxs("div",{className:"cc-team-chart-panel","data-testid":"cc-team-pie",children:[s.jsx("h3",{className:"cc-area-section-title",children:n("commandCenter.team.tokenShareByAgent","Token share by agent")}),s.jsx(kt,{data:Q,ariaLabel:n("commandCenter.team.tokenShareByAgent","Token share by agent")})]}):null,s.jsxs("div",{className:"cc-team-chart-panel","data-testid":"cc-team-tokens-chart",children:[s.jsx("h3",{className:"cc-area-section-title",children:n("commandCenter.team.tokensByAgent","Tokens by agent")}),ie?s.jsx(Ze,{data:X,ariaLabel:n("commandCenter.team.tokensByAgent","Tokens by agent")}):s.jsx("p",{className:"cc-muted-hint",children:F})]}),s.jsxs("div",{className:"cc-team-chart-panel","data-testid":"cc-team-completed-chart",children:[s.jsx("h3",{className:"cc-area-section-title",children:n("commandCenter.team.completedByAgent","Tasks done by agent")}),se?s.jsx(Ze,{data:G,ariaLabel:n("commandCenter.team.completedByAgent","Tasks done by agent")}):s.jsx("p",{className:"cc-muted-hint",children:F})]}),s.jsxs("div",{className:"cc-team-chart-panel cc-team-spark-panel","data-testid":"cc-team-spread-chart",children:[s.jsx("h3",{className:"cc-area-section-title",children:n("commandCenter.team.spread","Team spread")}),s.jsx(Kt,{values:re,ariaLabel:n("commandCenter.team.spread","Team spread")})]})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:n("commandCenter.team.tableTitle","Per-agent breakdown")}),s.jsx("div",{className:"cc-table-wrap",children:s.jsxs("table",{className:"cc-table","data-testid":"cc-team-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsxs("th",{className:"cc-sortable",onClick:()=>W("agent"),"data-testid":"cc-team-sort-agent",children:[n("commandCenter.team.agent","Agent"),$("agent")]}),s.jsxs("th",{className:"cc-sortable",onClick:()=>W("tokens"),"data-testid":"cc-team-sort-tokens",children:[n("commandCenter.team.tokens","Tokens"),$("tokens")]}),s.jsxs("th",{className:"cc-sortable",onClick:()=>W("cost"),"data-testid":"cc-team-sort-cost",children:[n("commandCenter.team.cost","Cost"),$("cost")]}),s.jsxs("th",{className:"cc-sortable",onClick:()=>W("filesChanged"),"data-testid":"cc-team-sort-files",children:[n("commandCenter.team.files","Files changed"),$("filesChanged")]}),s.jsxs("th",{className:"cc-sortable",onClick:()=>W("tasksCompleted"),"data-testid":"cc-team-sort-completed",children:[n("commandCenter.team.done","Tasks done"),$("tasksCompleted")]}),s.jsxs("th",{className:"cc-sortable",onClick:()=>W("tasksInProgress"),"data-testid":"cc-team-sort-progress",children:[n("commandCenter.team.inProgress","In progress"),$("tasksInProgress")]})]})}),s.jsx("tbody",{children:B.map(E=>s.jsxs("tr",{"data-testid":`cc-team-row-${E.agentId}`,children:[s.jsx("td",{children:s.jsxs("span",{className:"cc-team-agent-cell",children:[s.jsx("span",{className:kR(E.state),"aria-label":n("commandCenter.team.state","Agent state: {{state}}",{state:E.state??n("commandCenter.team.unknownState","unknown")})}),s.jsxs("span",{children:[s.jsx("span",{className:"cc-team-agent-name",children:hi(E,I)}),s.jsx("span",{className:"cc-team-agent-role",children:E.role??D})]})]})}),s.jsx("td",{children:K(E.tokens.totalTokens)}),s.jsx("td",{children:Sr(E.cost.usd,E.cost.unavailable)}),s.jsx("td",{children:K(E.filesChanged)}),s.jsx("td",{children:K(E.tasksCompleted)}),s.jsx("td",{children:K(E.tasksInProgress)})]},E.agentId))})]})})]})]})]})}function yx(e,t){return e.workflowName||e.workflowId||t}function AR(e,t,r,n){const a=[...e];return a.sort((i,o)=>{let l=0;return l=i.tokens.totalTokens-o.tokens.totalTokens,l===0&&(l=i.workflowId.localeCompare(o.workflowId)),l*r}),a}function Uv(e,t,r){return[...e].sort((n,a)=>t(a)-t(n)||n.workflowId.localeCompare(a.workflowId)).slice(0,12).map(n=>{const a=t(n);return{label:yx(n,r),value:a,valueLabel:K(a)}})}function ER({range:e}){const{t}=le("app"),{data:r,isLoading:n,error:a}=Ge("/command-center/workflows",e),i=t("commandCenter.workflows.unknownWorkflow","(unknown workflow)"),o=t("commandCenter.workflows.noChartData","No non-zero values for this chart yet."),l=r?.workflows??[],c=AR(l,"tokens",-1),d=Uv(l,v=>v.tokens.totalTokens,i),u=Uv(l,v=>v.tasksCompleted,i),m=d.some(v=>v.value>0),h=u.some(v=>v.value>0);return s.jsxs(Pt,{testId:"workflows",isLoading:n,error:a,isEmpty:!r||r.workflows.length===0,emptyMessage:t("commandCenter.workflows.empty","No workflow analytics have been recorded for this range yet."),children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.workflows.totalsTitle","Workflow totals")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-workflows-total-tokens",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.workflows.totalTokens","Total tokens")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.totals.tokens.totalTokens??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-workflows-total-cost",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.workflows.totalCost","Estimated cost")}),s.jsx("div",{className:"cc-stat-value",children:r?Sr(r.totals.cost.usd,r.totals.cost.unavailable):"—"})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-workflows-total-files",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.workflows.filesChanged","Files changed")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.totals.filesChanged??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-workflows-total-completed",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.workflows.tasksCompleted","Tasks done")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.totals.tasksCompleted??0)})]})]})]}),s.jsxs("div",{className:"cc-area-section cc-team-chart-grid",children:[s.jsxs("div",{className:"cc-team-chart-panel","data-testid":"cc-workflows-tokens-chart",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.workflows.tokensByWorkflow","Tokens by workflow")}),m?s.jsx(Ze,{data:d,ariaLabel:t("commandCenter.workflows.tokensByWorkflow","Tokens by workflow")}):s.jsx("p",{className:"cc-muted-hint",children:o})]}),s.jsxs("div",{className:"cc-team-chart-panel","data-testid":"cc-workflows-completed-chart",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.workflows.completedByWorkflow","Tasks done by workflow")}),h?s.jsx(Ze,{data:u,ariaLabel:t("commandCenter.workflows.completedByWorkflow","Tasks done by workflow")}):s.jsx("p",{className:"cc-muted-hint",children:o})]})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.workflows.tableTitle","Per-workflow breakdown")}),s.jsx("div",{className:"cc-table-wrap",children:s.jsxs("table",{className:"cc-table","data-testid":"cc-workflows-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:t("commandCenter.workflows.workflow","Workflow")}),s.jsx("th",{children:t("commandCenter.workflows.tokens","Tokens")}),s.jsx("th",{children:t("commandCenter.workflows.cost","Cost")}),s.jsx("th",{children:t("commandCenter.workflows.files","Files changed")}),s.jsx("th",{children:t("commandCenter.workflows.done","Tasks done")}),s.jsx("th",{children:t("commandCenter.workflows.inProgress","In progress")}),s.jsx("th",{children:t("commandCenter.workflows.inReview","In review")})]})}),s.jsx("tbody",{children:c.map(v=>s.jsxs("tr",{"data-testid":`cc-workflows-row-${v.workflowId}`,children:[s.jsx("td",{children:s.jsxs("span",{className:"cc-team-agent-cell",children:[s.jsx(Vx,{workflowId:v.workflowId,icon:v.workflowIcon,decorative:!0}),s.jsxs("span",{children:[s.jsx("span",{className:"cc-team-agent-name",children:yx(v,i)}),s.jsx("span",{className:"cc-team-agent-role",children:v.workflowId})]})]})}),s.jsx("td",{children:K(v.tokens.totalTokens)}),s.jsx("td",{children:Sr(v.cost.usd,v.cost.unavailable)}),s.jsx("td",{children:K(v.filesChanged)}),s.jsx("td",{children:K(v.tasksCompleted)}),s.jsx("td",{children:K(v.tasksInProgress)}),s.jsx("td",{children:K(v.tasksInReview)})]},v.workflowId))})]})})]})]})}function _R({range:e}){const{t}=le("app"),{data:r,isLoading:n,error:a}=Ge("/command-center/tokens?groupBy=model&granularity=day",e),{data:i,isLoading:o}=Ge("/command-center/plugin-activations",e),l=f.useMemo(()=>(r?.groups??[]).filter(b=>(b.key??"").trim().length>0),[r?.groups]),c=l.length,d=f.useMemo(()=>[...l].sort((b,j)=>j.nTasks-b.nTasks||(b.key??"").localeCompare(j.key??"")).slice(0,12).map(b=>({label:b.key??t("commandCenter.tokens.unknownModel","(unknown)"),value:b.nTasks,valueLabel:K(b.nTasks),iconProvider:Ml(b.key??"")})),[l,t]),u=f.useMemo(()=>d.map(b=>({label:b.label,value:b.value})),[d]),m=f.useMemo(()=>[{label:t("commandCenter.ecosystem.tokenTrendSeries","Tokens"),values:(r?.series??[]).map(b=>b.totalTokens)},{label:t("commandCenter.ecosystem.taskTrendSeries","Tasks"),values:(r?.series??[]).map(b=>b.nTasks)}],[r?.series,t]),h=u.some(b=>b.value>0),v=(r?.series??[]).length>0,y=i?.unavailable===!1,g=(!r||c===0)&&!y,p=n||o&&!r;return s.jsxs(Pt,{testId:"ecosystem",isLoading:p,error:a,isEmpty:g,emptyMessage:t("commandCenter.ecosystem.empty","No models or plugins active in the selected range."),children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.ecosystem.breadthTitle","Ecosystem breadth")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-ecosystem-unique-models",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.ecosystem.uniqueModels","Active models")}),s.jsx("div",{className:"cc-stat-value",children:K(c)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-ecosystem-plugins",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.ecosystem.plugins","Plugin activations")}),s.jsx("div",{className:"cc-stat-value",children:y?s.jsx("span",{"data-testid":"cc-ecosystem-plugins-value",children:K(i?.activations??0)}):s.jsx("span",{className:"cc-unavailable",title:t("commandCenter.ecosystem.pluginsUnavailable","Plugin-activation metrics are not yet recorded"),"data-testid":"cc-ecosystem-plugins-unavailable",children:"—"})})]})]})]}),h?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-ecosystem-pie",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.ecosystem.modelShareTitle","Task share by model")}),s.jsx(kt,{data:u,ariaLabel:t("commandCenter.ecosystem.modelShareTitle","Task share by model")})]}):null,v?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-ecosystem-line",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.ecosystem.trendTitle","Ecosystem trend")}),s.jsx(cr,{series:m,ariaLabel:t("commandCenter.ecosystem.trendTitle","Ecosystem trend")})]}):null,s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.ecosystem.perModelTitle","Tasks per model")}),s.jsx(Ze,{data:d,ariaLabel:t("commandCenter.ecosystem.perModelTitle","Tasks per model")})]})]})}const qv=100,MR=1e3;function TR(e,t){const r=new Date(e);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function IR({range:e}){const{t}=le("app"),{data:r,isLoading:n,error:a}=Ge("/command-center/github",e),[i,o]=f.useState(!1),[l,c]=f.useState(null),[d,u]=f.useState(null),m=f.useCallback(async()=>{if(!i){o(!0),c(null),u(null);try{let D=0;const F={scanned:0,filled:0,skipped:0,errors:0};for(let V=0;V<MR;V+=1){const U=await Ux({offset:D,limit:qv});if(F.scanned+=U.scanned,F.filled+=U.filled,F.skipped+=U.skipped,F.errors+=U.errors,!U.hasMore){c(F);return}D+=qv}c(F),u(t("commandCenter.github.backfillMaxBatches","Backfill stopped after the safety limit; rerun after checking server logs."))}catch(D){u(D instanceof Error?D.message:t("commandCenter.github.backfillFailed","Failed to backfill GitHub source issue close times"))}finally{o(!1)}}},[i,t]),h=f.useMemo(()=>r?.daily??[],[r?.daily]),v=f.useMemo(()=>r?.byRepo??[],[r?.byRepo]),y=f.useMemo(()=>r?.resolved??[],[r?.resolved]),g=f.useMemo(()=>h.map(D=>D.filed),[h]),p=f.useMemo(()=>h.map(D=>D.fixed),[h]),b=f.useMemo(()=>Math.max(0,...g,...p),[g,p]),j=f.useMemo(()=>v.slice(0,12).map(D=>({label:D.repo,value:D.filed+D.fixed,valueLabel:t("commandCenter.github.repoValue","{{filed}} filed / {{fixed}} fixed",{filed:K(D.filed),fixed:K(D.fixed)})})),[v,t]),x=f.useMemo(()=>[{label:t("commandCenter.github.filed","Filed by Fusion"),value:r?.filed??0},{label:t("commandCenter.github.fixed","Fixed by Fusion"),value:r?.fixed??0}],[r?.filed,r?.fixed,t]),C=f.useMemo(()=>[{label:t("commandCenter.github.filedTrend","Filed"),values:g},{label:t("commandCenter.github.fixedTrend","Fixed"),values:p}],[g,p,t]),w=r?.filed??0,P=r?.fixed??0,O=r?.net??w-P,k=!r||w===0&&P===0,N=h.length>0,S=w+P>0,A=j.length>0,_=y.length>0,I=d||(l?.errors??0)>0?"cc-github-backfill-status--error":i?"cc-github-backfill-status--warning":"";return s.jsxs(Pt,{testId:"github",isLoading:n,error:a,isEmpty:!1,emptyMessage:t("commandCenter.github.empty","No GitHub issue activity in the selected range."),children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.github.totalsTitle","GitHub issue flow")}),k?s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.github.empty","No GitHub issue activity in the selected range.")}):null,s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-github-filed",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.github.filed","Filed by Fusion")}),s.jsx("div",{className:"cc-stat-value",children:K(w)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-github-fixed",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.github.fixed","Fixed by Fusion")}),s.jsx("div",{className:"cc-stat-value",children:K(P)}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.github.fixedApproximation","Uses done tasks updated in range")}),s.jsx("div",{className:"cc-github-backfill-actions",children:s.jsxs("button",{type:"button",className:"btn","data-testid":"cc-github-backfill-button",onClick:()=>void m(),disabled:i,children:[s.jsx(Gr,{className:i?"spin":void 0}),s.jsx("span",{children:i?t("commandCenter.github.backfillBusy","Backfilling close times…"):t("commandCenter.github.backfillButton","Backfill exact close times")})]})}),i||l||d?s.jsxs("div",{className:`cc-github-backfill-status ${I}`.trim(),"data-testid":"cc-github-backfill-result",role:"status",children:[i?s.jsx("span",{children:t("commandCenter.github.backfillPending","Backfill is running in paginated batches.")}):null,d?s.jsx("span",{children:d}):null,l?s.jsx("span",{children:l.scanned===0&&l.filled===0?t("commandCenter.github.backfillNothing","Nothing to backfill. Scanned {{scanned}}, filled {{filled}}, skipped {{skipped}}, errors {{errors}}.",l):t("commandCenter.github.backfillResult","Backfill complete. Scanned {{scanned}}, filled {{filled}}, skipped {{skipped}}, errors {{errors}}.",l)}):null]}):null]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-github-net",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.github.net","Net")}),s.jsx("div",{className:"cc-stat-value",children:K(O)})]})]})]}),S?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-github-pie",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.github.issueFlowShare","Filed vs fixed share")}),s.jsx(kt,{data:x,ariaLabel:t("commandCenter.github.issueFlowShare","Filed vs fixed share")})]}):null,N?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-github-line",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.github.dailyLine","Filed vs fixed line")}),s.jsx(cr,{series:C,ariaLabel:t("commandCenter.github.dailyLine","Filed vs fixed line")})]}):null,N?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-github-daily-trend",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.github.dailyTrend","Filed vs fixed trend")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.github.filedTrend","Filed")}),s.jsx(Kt,{values:g,max:b,ariaLabel:t("commandCenter.github.filedTrend","Filed")})]}),s.jsxs("div",{className:"card cc-stat-card",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.github.fixedTrend","Fixed")}),s.jsx(Kt,{values:p,max:b,ariaLabel:t("commandCenter.github.fixedTrend","Fixed")})]})]})]}):null,A?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-github-by-repo",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.github.byRepo","By repository")}),s.jsx(Ze,{data:j,ariaLabel:t("commandCenter.github.byRepo","By repository")})]}):null,_?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-github-resolved",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.github.resolvedTitle","Resolved issues")}),s.jsx("div",{className:"cc-table-wrap",children:s.jsxs("table",{className:"cc-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{scope:"col",children:t("commandCenter.github.resolvedIssue","Issue")}),s.jsx("th",{scope:"col",children:t("commandCenter.github.resolvedTask","Resolving task")}),s.jsx("th",{scope:"col",children:t("commandCenter.github.resolvedAt","Resolved at")})]})}),s.jsx("tbody",{children:y.map(D=>{const F=D.issueNumber===null?D.repo:`${D.repo}#${D.issueNumber}`,V=TR(D.resolvedAt,t("commandCenter.github.resolvedAtUnknown","Unknown"));return s.jsxs("tr",{children:[s.jsx("td",{children:D.url?s.jsx("a",{href:D.url,target:"_blank",rel:"noopener noreferrer","aria-label":t("commandCenter.github.openResolvedIssue","Open GitHub issue {{issue}}",{issue:F}),children:F}):s.jsx("span",{children:F})}),s.jsxs("td",{children:[s.jsx("span",{children:D.taskTitle||D.taskId})," ",s.jsxs("span",{className:"cc-stat-sub",children:["(",D.taskId,")"]})]}),s.jsxs("td",{children:[s.jsx("span",{children:V})," ",D.resolvedAtExact?null:s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.github.resolvedApprox","approx")})]})]},D.taskId)})})]})})]}):null]})}function DR({range:e}){const{t}=le("app"),{data:r,isLoading:n}=Ge("/command-center/signals",e),{data:a,isLoading:i}=Ge("/command-center/signals/connectors",e),o=f.useMemo(()=>(r?.bySource??[]).map(g=>({label:g.source,value:g.count,valueLabel:K(g.count)})),[r?.bySource]),l=f.useMemo(()=>(r?.bySeverity??[]).map(g=>({label:g.severity,value:g.count,valueLabel:K(g.count)})),[r?.bySeverity]),c=f.useMemo(()=>[{label:t("commandCenter.signals.open","Open"),value:r?.open??0},{label:t("commandCenter.signals.resolved","Resolved"),value:r?.resolved??0}],[r?.open,r?.resolved,t]),d=!r||r.totalSignals===0,m=(Array.isArray(a?.connectors)?a.connectors.filter(g=>g.configured).map(g=>g.provider):void 0)??r?.connectors?.configured??[],v=m.length>0||r?.connectors?.anyConfigured===!0?t("commandCenter.signals.emptyAwaitingSignals","Connector configured, awaiting signals in this range. Configured providers: {{providers}}.",{providers:m.length>0?m.join(", "):t("commandCenter.signals.providersUnknown","unknown")}):t("commandCenter.signals.emptyNoConnectorConfigured","No signal connector configured. Connect Sentry, Datadog, PagerDuty, or a generic webhook to see incident metrics here."),y=!d&&c.some(g=>g.value>0);return s.jsxs(Pt,{testId:"signals",isLoading:n||i,error:null,isEmpty:d,emptyMessage:v,children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.signals.summaryTitle","Summary")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-signals-total",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.signals.total","Total signals")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.totalSignals??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-signals-open",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.signals.open","Open")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.open??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-signals-resolved",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.signals.resolved","Resolved")}),s.jsx("div",{className:"cc-stat-value",children:K(r?.resolved??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-signals-mttr",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.signals.mttr","MTTR")}),s.jsx("div",{className:"cc-stat-value",children:r&&r.mttr.value!==null&&!r.mttr.unavailable?t("commandCenter.signals.mttrValue","{{min}} min",{min:Math.round(r.mttr.value)}):s.jsx("span",{className:"cc-unavailable",title:t("commandCenter.signals.mttrUnavailable","MTTR is unavailable until incident data is recorded"),children:"—"})})]})]})]}),y?s.jsxs("div",{className:"cc-area-section","data-testid":"cc-signals-pie",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.signals.statusShare","Signal status share")}),s.jsx(kt,{data:c,ariaLabel:t("commandCenter.signals.statusShare","Signal status share")})]}):null,s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.signals.bySource","By source")}),s.jsx(Ze,{data:o,ariaLabel:t("commandCenter.signals.bySource","By source")})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.signals.bySeverity","By severity")}),s.jsx(Ze,{data:l,ariaLabel:t("commandCenter.signals.bySeverity","By severity")})]})]})}function gx(e){return e===null||!Number.isFinite(e)||e<=0?0:Math.max(0,Math.min(1,e))}function LR(e){if(e===null)return"—";const t=gx(e);return`${Math.round(t*100)}%`}function Oa({value:e,label:t,ariaLabel:r}){const n=gx(e),a=LR(e),i={"--cc-radial-value":`${n*100}%`};return s.jsxs("div",{className:"cc-radial-gauge",role:"img","aria-label":r,style:i,children:[s.jsx("div",{className:"cc-radial-gauge-ring","aria-hidden":"true",children:s.jsx("div",{className:"cc-radial-gauge-core",children:s.jsx("span",{className:"cc-radial-gauge-value",children:a})})}),s.jsx("span",{className:"cc-radial-gauge-label",children:t})]})}const RR=5e3,$R=30,BR=["triage","todo","in-progress","in-review","done"],FR=["idle","active","running","error"];function at(e){if(!Number.isFinite(e)||e<0)return"—";const t=e/(1024*1024);return t<1024?`${t.toFixed(0)} MB`:`${(t/1024).toFixed(2)} GB`}function Wv(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?"—":`${(e/t*100).toFixed(1)}%`}function zR(e,t){if(t<=0)return"normal";const r=e/t;return r>=.85?"critical":r>=.65?"warning":"normal"}function KR(e,t){if(t<=0)return"normal";const r=e/t;return r>=.5?"critical":r>=.25?"warning":"normal"}function VR(e,t){if(t<=0)return"normal";const r=e/t;return r>=.9?"critical":r>=.75?"warning":"normal"}function UR(e,t){if(e===null||!Number.isFinite(e)||e<0)return"normal";const r=t>0?e/t:e;return r>=80?"critical":r>=50?"warning":"normal"}function ga(e){return e==="critical"?"cc-system-value--critical":e==="warning"?"cc-system-value--warning":""}function qR(e,t){if(!e)return t;const r=new Date(e);return Number.isNaN(r.getTime())?t:r.toLocaleString()}function pi(e,t){return!Number.isFinite(e)||!Number.isFinite(t)||t<=0?0:Math.max(0,Math.min(1,e/t))}function Sn(e){return e==null||!Number.isFinite(e)?0:Math.max(0,Math.min(100,e))}function WR(e){const t=e.systemStats,r=t.systemTotalMem-t.systemFreeMem;return{cpuPercent:Sn(t.cpuPercent),usedSystemMemPercent:pi(r,t.systemTotalMem)*100,heapUsedPercent:pi(t.heapUsed,t.heapLimit)*100}}function HR({projectId:e}){const{t}=le("app"),[r,n]=f.useState(null),[a,i]=f.useState([]),[o,l]=f.useState(!0),[c,d]=f.useState(null),[u,m]=f.useState(!0),[h,v]=f.useState(90),[y,g]=f.useState(!1),[p,b]=f.useState(!1),[j,x]=f.useState(null),[C,w]=f.useState(null),[P,O]=f.useState(null),[k,N]=f.useState(null),{nodes:S}=ih(),A=f.useMemo(()=>S.find(E=>E.type==="local")?.id,[S]),_=k??A??null,I=S.find(E=>E.id===_)??null,D=S.length>1,F=I?.name??t("systemStats.localNodeFallback","Local node"),V=f.useCallback(E=>{const T=[];return E.type==="local"&&T.push(t("systemStats.thisNodeSuffix","this node")),E.status&&E.status!=="online"&&T.push(t("systemStats.nodeStatusSuffix","{{status}}",{status:E.status})),T.length>0?`${E.name} (${T.join(" · ")})`:E.name},[S,t]),U=f.useCallback(async E=>{l(!0);try{const T=_&&_!==A?await qx(_,e):await Wx(e);n(T),i(J=>[...J,WR(T)].slice(-$R)),d(null),O(Date.now()),E?.preserveKillResult||x(null)}catch(T){d(T instanceof Error?T.message:t("systemStats.errorLoadStats","Failed to load system stats"))}finally{l(!1)}},[_,A,e,t]);f.useEffect(()=>{U();const E=window.setInterval(()=>{U()},RR);return()=>{window.clearInterval(E)}},[U]),f.useEffect(()=>{N(E=>E&&S.some(T=>T.id===E)?E:null)},[S]),f.useEffect(()=>{i([]),d(null),x(null),b(!1)},[_]),f.useEffect(()=>{let E=!1;return(async()=>{try{const J=await Hx();if(E)return;m(J.vitestAutoKillEnabled??!0),v(J.vitestKillThresholdPct??90),w(null)}catch(J){E||w(J instanceof Error?J.message:t("systemStats.errorLoadVitestSettings","Failed to load vitest settings"))}})(),()=>{E=!0}},[t]);const te=f.useCallback(async E=>{m(E);try{await mu({vitestAutoKillEnabled:E}),w(null)}catch(T){w(T instanceof Error?T.message:t("systemStats.errorSaveVitestSettings","Failed to save vitest settings"))}},[t]),q=f.useCallback(async E=>{const T=Math.min(99,Math.max(50,Number.isFinite(E)?Math.round(E):90));v(T);try{await mu({vitestKillThresholdPct:T}),w(null)}catch(J){w(J instanceof Error?J.message:t("systemStats.errorSaveVitestSettings","Failed to save vitest settings"))}},[t]),ee=f.useCallback(async()=>{if(!y){if(!p){b(!0);return}g(!0);try{const E=_&&_!==A?await vu(e,_,A):await vu(e);x(E),b(!1),await U({preserveKillResult:!0})}catch(E){d(E instanceof Error?E.message:t("systemStats.errorKillVitest","Failed to kill vitest processes"))}finally{g(!1)}}},[p,_,y,U,A,e,t]),L=r?.systemStats,B=r?.taskStats,X=L?L.systemTotalMem-L.systemFreeMem:0,Q=L?pi(X,L.systemTotalMem):0,G=L?pi(L.heapUsed,L.heapLimit):0,ie=L?.cpuPercent===null||L?.cpuPercent===void 0?null:Sn(L.cpuPercent)/100,se=L?.cpuPercent===null||L?.cpuPercent===void 0?t("systemStats.cpuSampling","Sampling…"):`${L.cpuPercent.toFixed(1)}%`,re=P?t("systemStats.updatedAt","Updated {{time}}",{time:new Date(P).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}):t("systemStats.waitingFirstUpdate","Waiting for first update"),W=f.useMemo(()=>{const E=B?.byColumn??{};return(Object.keys(E).length>0?Object.keys(E):BR).map(J=>({label:J,value:E[J]??0,valueLabel:K(E[J]??0)}))},[B?.byColumn]),$=f.useMemo(()=>W.map(E=>({label:E.label,value:E.value})),[W]),ne=f.useMemo(()=>[{label:t("commandCenter.system.cpuSeries","CPU"),values:a.map(E=>Sn(E.cpuPercent))},{label:t("commandCenter.system.memorySeries","Memory"),values:a.map(E=>Sn(E.usedSystemMemPercent))},{label:t("commandCenter.system.heapSeries","Heap"),values:a.map(E=>Sn(E.heapUsedPercent))}],[a,t]),we=$.some(E=>E.value>0),z=a.length>0,fe=f.useMemo(()=>{const E=B?.agents;return FR.map(T=>({label:t(`systemStats.agent${T[0].toUpperCase()}${T.slice(1)}`,T),value:E?.[T]??0,valueLabel:K(E?.[T]??0)}))},[B?.agents,t]),be=f.useMemo(()=>{const E=L?ga(zR(L.heapUsed,L.heapLimit)):"",T=L?ga(KR(L.rss,L.systemTotalMem)):"",J=L?ga(VR(X,L.systemTotalMem)):"",dt=L?ga(UR(L.cpuPercent,L.cpuCount)):"";return[{label:t("systemStats.rowAppCpu","App CPU"),value:se,detail:L?.cpuPercent===null?t("systemStats.cpuFirstSamplePending","First sample pending"):t("systemStats.cpuProcessUsage","process usage"),className:dt},{label:t("systemStats.rowRss","RSS"),value:L?at(L.rss):"—",detail:L?Wv(L.rss,L.systemTotalMem):"—",className:T},{label:t("systemStats.rowHeapUsed","Heap Used"),value:L?at(L.heapUsed):"—",detail:L?t("systemStats.rowHeapUsedDetail","of {{total}}",{total:at(L.heapTotal)}):"—",className:E},{label:t("systemStats.rowHeapLimit","Heap Limit"),value:L?at(L.heapLimit):"—",detail:t("systemStats.rowHeapLimitDetail","V8 limit")},{label:t("systemStats.rowExternal","External"),value:L?at(L.external):"—"},{label:t("systemStats.rowArrayBuffers","Array Buffers"),value:L?at(L.arrayBuffers):"—"},{label:t("systemStats.rowLoadAvg","Load Avg"),value:L?.loadAvg.map(dr=>dr.toFixed(2)).join(" ")??"—"},{label:t("systemStats.rowCores","Cores"),value:L?.cpuCount??"—"},{label:t("systemStats.rowPlatform","Platform"),value:L?.platform??"—"},{label:t("systemStats.rowNode","Node"),value:L?.nodeVersion??"—"},{label:t("systemStats.rowPid","PID"),value:L?.pid??"—"},{label:t("systemStats.rowMemoryUsed","Memory Used"),value:L?at(X):"—",detail:L?`${Wv(X,L.systemTotalMem)} of ${at(L.systemTotalMem)}`:"—",className:J},{label:t("systemStats.rowMemoryFree","Memory Free"),value:L?at(L.systemFreeMem):"—"}]},[se,L,t,X]),ye=r?.vitestProcessCount,nt=qR(r?.vitestLastAutoKillAt,t("systemStats.notYet","Not yet")),ur=o&&!!r;return s.jsxs(Pt,{testId:"system",isLoading:o&&!r,error:r?null:c,isEmpty:!1,children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsxs("div",{className:"cc-area-section-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.system.healthTitle","Live system health")}),s.jsxs("div",{className:"cc-system-refresh","aria-live":"polite",children:[D?s.jsxs("label",{className:"cc-system-node-selector",htmlFor:"cc-system-node-select",children:[s.jsx("span",{children:t("systemStats.nodeSelectorLabel","Node")}),s.jsx("select",{id:"cc-system-node-select",className:"input","data-testid":"cc-system-node-select","aria-label":t("systemStats.nodeSelectorAriaLabel","Select system stats node"),value:_??"",onChange:E=>{i([]),x(null),b(!1),N(E.target.value||null)},children:S.map(E=>s.jsx("option",{value:E.id,children:V(E)},E.id))})]}):null,s.jsx("span",{children:t("systemStats.viewingNode","Viewing {{node}}",{node:F})}),s.jsx("span",{children:t("systemStats.autoRefresh","Auto-refresh · 5s")}),s.jsx("span",{children:re}),s.jsx("button",{type:"button",className:"btn-icon",onClick:()=>void U(),title:t("systemStats.refreshTitle","Refresh"),"aria-label":t("systemStats.refreshAriaLabel","Refresh system stats"),children:s.jsx(Gr,{size:16,className:ur?"spin":void 0})})]})]}),c&&r?s.jsx("p",{className:"cc-system-note cc-system-note--error",role:"status",children:t("systemStats.footerRefreshFailed","Latest refresh failed: {{error}}",{error:c})}):null,s.jsxs("div",{className:"cc-stat-grid cc-system-gauges",children:[s.jsxs("div",{className:"card cc-stat-card cc-stat-card--gauge","data-testid":"cc-system-cpu-gauge",children:[s.jsx(Oa,{value:ie,label:t("systemStats.rowAppCpu","App CPU"),ariaLabel:t("commandCenter.system.cpuGauge","App CPU usage")}),s.jsx("span",{className:"cc-stat-sub",children:se})]}),s.jsxs("div",{className:"card cc-stat-card cc-stat-card--gauge","data-testid":"cc-system-mem-gauge",children:[s.jsx(Oa,{value:Q,label:t("systemStats.rowMemoryUsed","Memory Used"),ariaLabel:t("commandCenter.system.memoryGauge","System memory used")}),s.jsx("span",{className:"cc-stat-sub",children:L?`${at(X)} / ${at(L.systemTotalMem)}`:"—"})]}),s.jsxs("div",{className:"card cc-stat-card cc-stat-card--gauge","data-testid":"cc-system-heap-gauge",children:[s.jsx(Oa,{value:G,label:t("systemStats.rowHeapUsed","Heap Used"),ariaLabel:t("commandCenter.system.heapGauge","Heap used")}),s.jsx("span",{className:"cc-stat-sub",children:L?`${at(L.heapUsed)} / ${at(L.heapLimit)}`:"—"})]})]})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.system.trendsTitle","Live trends")}),z?s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-system-line",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.system.resourceTrend","Resource trend")}),s.jsx(cr,{series:ne,ariaLabel:t("commandCenter.system.resourceTrend","Resource trend")})]}):null,s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-system-cpu-trend",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.system.cpuTrend","CPU over time")}),s.jsx(Kt,{values:a.map(E=>E.cpuPercent),max:100,ariaLabel:t("commandCenter.system.cpuTrend","CPU over time")})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-system-memory-trend",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.system.memoryTrend","Memory over time")}),s.jsx(Kt,{values:a.map(E=>E.usedSystemMemPercent),max:100,ariaLabel:t("commandCenter.system.memoryTrend","Memory over time")})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-system-heap-trend",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.system.heapTrend","Heap over time")}),s.jsx(Kt,{values:a.map(E=>E.heapUsedPercent),max:100,ariaLabel:t("commandCenter.system.heapTrend","Heap over time")})]})]})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.system.workloadTitle","Workload")}),s.jsxs("div",{className:"cc-system-chart-grid",children:[we?s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-system-pie",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.system.taskShare","Task distribution")}),s.jsx(kt,{data:$,ariaLabel:t("commandCenter.system.taskShare","Task distribution")})]}):null,s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-system-tasks-bar",children:[s.jsx("div",{className:"cc-stat-label",children:t("systemStats.sectionTasks","Tasks")}),s.jsx(Ze,{data:W,ariaLabel:t("systemStats.sectionTasksAriaLabel","Task stats")})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-system-agents-bar",children:[s.jsx("div",{className:"cc-stat-label",children:t("systemStats.sectionAgents","Agents")}),s.jsx(Ze,{data:fe,ariaLabel:t("systemStats.sectionAgentsAriaLabel","Agent stats")})]})]})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.system.detailsTitle","Runtime details")}),s.jsx("div",{className:"cc-stat-grid","data-testid":"cc-system-details-grid",children:be.map(E=>s.jsxs("div",{className:"card cc-stat-card",children:[s.jsx("div",{className:"cc-stat-label",children:E.label}),s.jsx("div",{className:`cc-stat-value ${E.className??""}`.trim(),children:E.value}),E.detail?s.jsx("span",{className:"cc-stat-sub",children:E.detail}):null]},E.label))})]}),s.jsxs("div",{className:"cc-area-section","data-testid":"cc-system-vitest-controls",children:[s.jsxs("h3",{className:"cc-area-section-title cc-system-section-title-with-icon",children:[s.jsx(a0,{}),s.jsx("span",{children:t("systemStats.sectionVitest","Vitest Controls")})]}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card",children:[s.jsx("div",{className:"cc-stat-label",children:t("systemStats.vitestProcesses","Vitest Processes")}),s.jsx("div",{className:"cc-stat-value",children:ye??"—"})]}),s.jsxs("div",{className:"card cc-stat-card",children:[s.jsx("div",{className:"cc-stat-label",children:t("systemStats.lastAutoKill","Last auto-kill: {{time}}",{time:""}).trim()}),s.jsx("div",{className:"cc-stat-value",children:nt})]})]}),s.jsxs("div",{className:"card cc-system-vitest-card",children:[s.jsxs("button",{type:"button",className:"btn btn-danger","data-testid":"cc-system-kill-vitest",onClick:()=>void ee(),disabled:y||ye===0,children:[s.jsx(d0,{}),s.jsx("span",{children:p?t("systemStats.confirmKill","Confirm Kill?"):t("systemStats.killVitest","Kill Vitest Processes")})]}),s.jsxs("label",{className:"cc-system-toggle-row",children:[s.jsx("input",{type:"checkbox",checked:u,onChange:E=>{te(E.target.checked)}}),s.jsx("span",{children:t("systemStats.autoKillLabel","Auto-kill vitest on memory pressure")})]}),s.jsxs("div",{className:"cc-system-threshold-row",children:[s.jsx("label",{htmlFor:"cc-system-vitest-threshold-number",children:t("systemStats.killThresholdLabel","Kill threshold (%)")}),s.jsxs("div",{className:"cc-system-threshold-controls",children:[s.jsx("input",{id:"cc-system-vitest-threshold-range",type:"range",min:50,max:99,value:h,"aria-label":t("systemStats.killThresholdSliderAriaLabel","Kill threshold slider (%)"),onChange:E=>{const T=Number.parseInt(E.target.value,10);q(Number.isNaN(T)?90:T)}}),s.jsx("input",{id:"cc-system-vitest-threshold-number",type:"number",className:"input",min:50,max:99,value:h,"aria-label":t("systemStats.killThresholdInputAriaLabel","Kill threshold (%)"),onChange:E=>{const T=Number.parseInt(E.target.value,10);q(Number.isNaN(T)?90:T)},onBlur:()=>{q(h)}})]})]}),j?s.jsx("p",{className:`cc-system-note ${j.killed>0?"cc-system-note--success":"cc-system-note--error"}`,children:t("systemStats.killedProcesses","Killed {{count}} processes",{count:j.killed})}):null,C?s.jsx("p",{className:"cc-system-note cc-system-note--error",children:C}):null]})]})]})}function GR(e,t){if(!Number.isFinite(e)||e<=0)return 0;const r=Number.isFinite(t)&&t>0?t:1;return Math.max(0,Math.min(100,e/r*100))}function XR(e,t){return t===null?null:!Number.isFinite(t)||t<=0?"—":`${Math.max(0,Math.min(100,e/t*100)).toFixed(0)}%`}function bx({stages:e,ariaLabel:t}){const r=e.reduce((n,a)=>a.value>n?a.value:n,0);return s.jsx("ol",{className:"cc-funnel","aria-label":t,children:e.map((n,a)=>{const i=GR(n.value,r),o=a>0?e[a-1].value:null,l=XR(n.value,o),c=String(Number.isFinite(n.value)?n.value:0);return s.jsxs("li",{className:"cc-funnel-stage",children:[s.jsxs("div",{className:"cc-funnel-header",children:[s.jsx("span",{className:"cc-funnel-label",children:n.label}),l!==null?s.jsx("span",{className:"cc-funnel-conversion",children:l}):null]}),s.jsx("div",{className:"cc-funnel-track",children:s.jsx("div",{className:"cc-funnel-fill",style:{width:`${i}%`},role:"img","aria-label":`${n.label}: ${c}`})}),s.jsx("span",{className:"cc-funnel-value",children:c})]},n.label)})})}const YR=5e3,ZR=3e4,JR=["session:updated","session:completed","run:created","run:updated","run:completed","run:cancelled","run:failed","agent:stateChanged","task:moved","task:updated","task:created","task:deleted"],Ao=[{id:"triage",match:e=>e==="triage"||e==="signal"||e==="backlog"},{id:"todo",match:e=>e==="todo"||e==="to-do"||e==="to do"||e==="ready"},{id:"in-progress",match:e=>e==="in-progress"||e==="in progress"||e==="doing"},{id:"in-review",match:e=>e==="in-review"||e==="in review"||e==="review"},{id:"done",match:e=>e==="done"||e==="complete"||e==="completed"||e==="shipped"}];function QR(){const[e,t]=f.useState(null),[r,n]=f.useState(!0),[a,i]=f.useState(null),[o,l]=f.useState(!1),c=f.useRef(null),d=f.useRef(null),u=f.useRef(!1),m=f.useRef(!0),h=f.useCallback(()=>{d.current!==null&&(clearInterval(d.current),d.current=null,l(!1))},[]),v=f.useCallback(async()=>{if(!u.current){u.current=!0;try{const g=await _l("/command-center/live");if(!m.current)return;c.current=g,t(g),i(null)}catch(g){if(!m.current)return;i(g instanceof Error?g.message:"Failed to load live snapshot")}finally{if(u.current=!1,m.current){n(!1);const g=c.current;!!g&&(g.activeSessions>0||g.activeRuns>0)?d.current===null&&(d.current=setInterval(()=>{v()},YR),l(!0)):h()}}}},[h]);f.useEffect(()=>{m.current=!0,v();const g=Xx("/api/events",{events:Object.fromEntries(JR.map(p=>[p,()=>void v()])),onReconnect:()=>void v()});return()=>{m.current=!1,g(),h()}},[v,h]);const y=f.useCallback(()=>{v()},[v]);return{snapshot:e,isLoading:r,error:a!==null&&e===null?a:null,polling:o,reload:y}}function e$(e){const t=e.split(/[/\\]/).filter(Boolean);return t.length>0?t[t.length-1]:e}function t$(e,t){const r=Date.parse(t),n=new Map;for(const a of e){if(!a.worktreePath)continue;const i=n.get(a.worktreePath)??{count:0,freshestMs:0},o=Date.parse(a.updatedAt);n.set(a.worktreePath,{count:i.count+1,freshestMs:Number.isFinite(o)?Math.max(i.freshestMs,o):i.freshestMs})}return Array.from(n.entries()).map(([a,i])=>{const o=Number.isFinite(r)&&i.freshestMs>0?r-i.freshestMs:0;return{path:a,label:e$(a),sessionCount:i.count,inactive:o>ZR}}).sort((a,i)=>i.sessionCount-a.sessionCount)}function r$(e,t){const r=new Map;for(const i of Ao)r.set(i.id,0);let n=0;for(const i of e){const o=i.column.trim().toLowerCase(),l=Ao.find(c=>c.match(o));l?r.set(l.id,(r.get(l.id)??0)+i.count):n+=i.count}const a=Ao.map(i=>({label:t(`commandCenter.missionControl.stage.${i.id}`,i.id),value:r.get(i.id)??0}));return n>0&&a.push({label:t("commandCenter.missionControl.stage.other","Other"),value:n}),a}function n$(){const{t:e}=le("app"),{snapshot:t,isLoading:r,error:n}=QR(),a=f.useMemo(()=>t?.sessions??[],[t?.sessions]),i=f.useMemo(()=>t?t$(t.sessions,t.capturedAt):[],[t]),o=f.useMemo(()=>t?r$(t.columns,e):[],[t,e]);if(r&&!t)return s.jsxs("div",{className:"cc-loading-inline","data-testid":"mission-control-loading",children:[s.jsx(El,{size:18,className:"spin"}),s.jsx("span",{children:e("commandCenter.missionControl.loading","Loading live activity…")})]});if(n!==null)return s.jsxs("div",{className:"cc-area-error","data-testid":"mission-control-error",role:"alert",children:[s.jsx(gi,{size:22}),s.jsx("p",{children:n})]});const l=(t?.activeSessions??0)>0||(t?.activeRuns??0)>0;return s.jsxs("div",{className:"cc-mission-control","data-testid":"mission-control",children:[s.jsxs("div",{className:"cc-stat-grid","data-testid":"mission-control-summary",children:[s.jsxs("div",{className:"card cc-stat-card","data-testid":"mission-control-active-sessions",children:[s.jsx("div",{className:"cc-stat-label",children:e("commandCenter.missionControl.activeSessions","Active sessions")}),s.jsx("div",{className:"cc-stat-value",children:t?.activeSessions??0})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"mission-control-active-runs",children:[s.jsx("div",{className:"cc-stat-label",children:e("commandCenter.missionControl.activeRuns","Active runs")}),s.jsx("div",{className:"cc-stat-value",children:t?.activeRuns??0})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"mission-control-active-nodes",children:[s.jsx("div",{className:"cc-stat-label",children:e("commandCenter.missionControl.activeNodes","Active nodes")}),s.jsx("div",{className:"cc-stat-value",children:t?.activeNodes??0})]})]}),l?null:s.jsxs("div",{className:"cc-area-empty","data-testid":"mission-control-idle",children:[s.jsx(Gx,{size:24}),s.jsx("p",{children:e("commandCenter.missionControl.idle","No active sessions. Live updates resume when work starts.")})]}),s.jsxs("div",{className:"cc-mc-columns",children:[s.jsxs("section",{className:"cc-mc-section","data-testid":"mission-control-sessions",children:[s.jsx("h3",{className:"cc-area-section-title",children:e("commandCenter.missionControl.sessionsTitle","Sessions")}),a.length===0?s.jsx("p",{className:"cc-mc-muted","data-testid":"mission-control-sessions-empty",children:e("commandCenter.missionControl.noSessions","No active sessions.")}):s.jsx("ul",{className:"cc-mc-list",children:a.map(c=>s.jsxs("li",{className:"cc-mc-session","data-testid":`mission-control-session-${c.id}`,children:[s.jsx("span",{className:"cc-mc-session-purpose",children:c.purpose||c.adapterId}),s.jsxs("span",{className:"cc-mc-session-meta",children:[s.jsx("span",{className:"cc-mc-badge",children:c.agentState}),c.taskId?s.jsx("span",{className:"cc-mc-task",children:c.taskId}):null]})]},c.id))})]}),s.jsxs("section",{className:"cc-mc-section","data-testid":"mission-control-nodes",children:[s.jsx("h3",{className:"cc-area-section-title",children:e("commandCenter.missionControl.nodesTitle","Nodes")}),i.length===0?s.jsx("p",{className:"cc-mc-muted","data-testid":"mission-control-nodes-empty",children:e("commandCenter.missionControl.noNodes","No active nodes.")}):s.jsx("ul",{className:"cc-mc-list",children:i.map(c=>s.jsxs("li",{className:`cc-mc-node${c.inactive?" inactive":""}`,"data-testid":`mission-control-node-${c.label}`,"data-inactive":c.inactive?"true":"false",children:[s.jsx("span",{className:"cc-mc-node-label",children:c.label}),s.jsxs("span",{className:"cc-mc-node-meta",children:[c.inactive?s.jsx("span",{className:"cc-mc-badge inactive",children:e("commandCenter.missionControl.inactive","inactive")}):null,s.jsx("span",{className:"cc-mc-node-count",children:e("commandCenter.missionControl.sessionCount","{{count}} session",{count:c.sessionCount})})]})]},c.path))})]})]}),s.jsxs("section",{className:"cc-mc-section","data-testid":"mission-control-funnel",children:[s.jsx("h3",{className:"cc-area-section-title",children:e("commandCenter.missionControl.funnelTitle","SDLC funnel (live)")}),s.jsx(bx,{stages:o,ariaLabel:e("commandCenter.missionControl.funnelTitle","SDLC funnel (live)")})]})]})}function Hv({className:e}){return s.jsxs("span",{className:`theme-option-swatch ${e}`,"aria-hidden":"true",children:[s.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-1"}),s.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-2"}),s.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-3"}),s.jsx("span",{className:"theme-option-swatch-sample theme-option-swatch-sample-4"})]})}function a$({colorTheme:e,onColorThemeChange:t,themeMode:r,shadcnCustomColors:n={},resolvedThemeMode:a=r==="light"?"light":"dark",onThemeModeChange:i,onShadcnCustomColorsChange:o=()=>{}}){const{t:l}=le("app"),[c,d]=f.useState(!1),[u,m]=f.useState(()=>Math.max(0,Lt.findIndex(x=>x.value===e))),h=f.useRef(null),v=f.useRef([]),y=f.useMemo(()=>Lt.find(x=>x.value===e)??Lt[0],[e]),g="theme-dropdown-listbox";f.useEffect(()=>{if(!c)return;const x=C=>{h.current&&!h.current.contains(C.target)&&d(!1)};return document.addEventListener("pointerdown",x),()=>document.removeEventListener("pointerdown",x)},[c]),f.useEffect(()=>{m(Math.max(0,Lt.findIndex(x=>x.value===e)))},[e]),f.useEffect(()=>{c&&v.current[u]?.focus()},[u,c]);const p=x=>{t(x),d(!1)},b=x=>{if(x.key==="ArrowDown"||x.key==="ArrowUp"||x.key==="Enter"||x.key===" "){x.preventDefault();const C=Math.max(0,Lt.findIndex(w=>w.value===e));m(x.key==="ArrowUp"?Math.max(0,C-1):C),d(!0)}},j=(x,C,w)=>{if(x.key==="Escape"){x.preventDefault(),d(!1);return}if(x.key==="ArrowDown"||x.key==="ArrowUp"){x.preventDefault();const P=x.key==="ArrowDown"?1:-1;m((C+P+Lt.length)%Lt.length);return}if(x.key==="Home"){x.preventDefault(),m(0);return}if(x.key==="End"){x.preventDefault(),m(Lt.length-1);return}(x.key==="Enter"||x.key===" ")&&(x.preventDefault(),p(w))};return s.jsxs("div",{className:`theme-dropdown${c?" open":""}`,ref:h,children:[s.jsxs("button",{type:"button",className:"theme-dropdown-trigger btn","aria-haspopup":"listbox","aria-expanded":c,"aria-controls":g,onClick:()=>d(x=>!x),onKeyDown:b,children:[s.jsx(Hv,{className:y.className}),s.jsx("span",{className:"theme-dropdown-trigger-label",children:l(`theme.colorTheme.${y.value}`,y.label)}),s.jsx(xi,{size:16,"aria-hidden":"true"})]}),r&&i?s.jsx("div",{className:"theme-dropdown-modes",role:"radiogroup","aria-label":l("theme.modeLabel","Theme mode"),children:i0.map(({value:x,label:C,icon:w})=>s.jsxs("button",{type:"button",className:`theme-dropdown-mode-btn btn btn-sm${r===x?" active":""}`,"aria-pressed":r===x,onClick:()=>i(x),title:l(`theme.${x}Mode`,`${C} mode`),children:[s.jsx(w,{size:16,"aria-hidden":"true"}),s.jsx("span",{children:l(`theme.${x}`,C)})]},x))}):null,e==="shadcn-custom"?s.jsx(s0,{value:n,onChange:o,resolvedThemeMode:a}):null,c?s.jsx("div",{className:"theme-dropdown-popover",role:"presentation",children:s.jsx("div",{id:g,className:"theme-dropdown-list",role:"listbox","aria-label":l("theme.colorThemeLabel","Color theme"),children:Lt.map(({value:x,label:C,className:w},P)=>{const O=e===x;return s.jsxs("button",{ref:k=>{v.current[P]=k},type:"button",className:`theme-dropdown-option${O?" active":""}`,role:"option","aria-selected":O,tabIndex:P===u?0:-1,onClick:()=>p(x),onKeyDown:k=>j(k,P,x),children:[s.jsx(Hv,{className:w}),s.jsx("span",{className:"theme-dropdown-option-label",children:l(`theme.colorTheme.${x}`,C)}),O?s.jsx(Yx,{size:16,"aria-hidden":"true"}):null]},x)})})}):null]})}const Gv=500,yr={maxConcurrent:us.maxConcurrent,maxTriageConcurrent:us.maxTriageConcurrent,maxWorktrees:us.maxWorktrees},xr={maxConcurrent:{min:1,max:50},maxTriageConcurrent:{min:1,max:50},maxWorktrees:{min:1,max:50}},i$={maxConcurrent:{key:"commandCenter.controls.concurrency.maxConcurrent",defaultValue:"Max concurrent tasks"},maxTriageConcurrent:{key:"commandCenter.controls.concurrency.maxTriageConcurrent",defaultValue:"Max triage concurrent"},maxWorktrees:{key:"commandCenter.controls.concurrency.maxWorktrees",defaultValue:"Max worktrees"}};function Pl(e,t,r){return Math.min(r,Math.max(t,e))}function jn(e,t){return Math.max(xr[e].max,t)}function Xv(e,t){return t<=0?0:Pl(e/t,0,1)}function Yv(e){return{"--use-pct":`${e*100}%`,"--use-offset":`calc((var(--cc-controls-range-thumb-size) / 2) + ((100% - var(--cc-controls-range-thumb-size)) * ${e}))`}}function s$(e,t){return Object.keys(e).filter(r=>e[r]!==t[r])}function o$({paused:e,label:t}){return s.jsxs("span",{className:"cc-controls-status-pill",children:[s.jsx("span",{className:`status-dot ${e?"status-dot--pending":"status-dot--online"}`,"aria-hidden":"true"}),s.jsx("span",{children:t})]})}function l$({projectId:e,colorTheme:t,themeMode:r,shadcnCustomColors:n={},resolvedThemeMode:a=r==="light"?"light":"dark",onColorThemeChange:i,onThemeModeChange:o,onShadcnCustomColorsChange:l=()=>{},onChangeView:c}){const{t:d}=le("app"),{confirm:u}=th(),{globalPaused:m,toggleGlobalPause:h,refresh:v}=rh(e),[y,g]=f.useState({status:"loading",data:null,error:null}),[p,b]=f.useState(!1),[j,x]=f.useState("idle"),C=f.useRef(yr),w=f.useRef(null),P=f.useRef(!1),[O,k]=f.useState(null),[N,S]=f.useState(!1),A=f.useRef(!1),_=Zx();f.useEffect(()=>{let G=!1;return b(!1),x("idle"),g({status:"loading",data:null,error:null}),(async()=>{try{const[ie,se]=await Promise.all([Jx(e),nh(e)]);if(!G){const re={maxConcurrent:se.maxConcurrent??ie.maxConcurrent??yr.maxConcurrent,maxTriageConcurrent:se.maxTriageConcurrent??yr.maxTriageConcurrent,maxWorktrees:se.maxWorktrees??yr.maxWorktrees};C.current=re,w.current=null,P.current=!1,g({status:"loaded",data:re,error:null})}}catch(ie){G||g({status:"error",data:yr,error:ie instanceof Error?ie.message:d("commandCenter.controls.concurrency.error","Unable to load concurrency settings")})}})(),()=>{G=!0}},[e,d]),f.useEffect(()=>{if(!p||!y.data||P.current)return;const G=y.data,ie=setTimeout(()=>{const se=C.current,re=s$(G,se);if(re.length===0){b(!1),w.current=null;return}P.current=!0;const W=re.map(ne=>{const we=i$[ne];return d("commandCenter.controls.concurrency.confirmChangeSummaryItem","{{setting}} from {{oldValue}} to {{newValue}}",{setting:d(we.key,we.defaultValue),oldValue:se[ne],newValue:G[ne]})}),$=re.length===1?d("commandCenter.controls.concurrency.confirmMessage","Change {{setting}}?",{setting:W[0]}):d("commandCenter.controls.concurrency.confirmMultipleMessage","Change these concurrency settings: {{settings}}?",{settings:W.join("; ")});u({title:d("commandCenter.controls.concurrency.confirmTitle","Confirm concurrency change"),message:$,confirmLabel:d("commandCenter.controls.concurrency.confirmSave","Save change"),cancelLabel:d("commandCenter.controls.concurrency.confirmCancel","Cancel")}).then(ne=>{if(P.current=!1,!ne){g({status:"loaded",data:C.current,error:null}),b(!1),w.current=null,x("idle");return}x("saving"),ah(G,e).then(async()=>{await v(),C.current=G,b(!1),w.current=null,x("saved")}).catch(()=>{x("error")})})},Gv);return()=>clearTimeout(ie)},[u,p,y.data,e,v,d]);const I=(G,ie,se,re)=>{const W=Pl(Number(ie),se,re);w.current=G,g($=>({status:"loaded",data:{...$.data??yr,[G]:W},error:null})),b(!0),x("idle")},D=G=>{const ie=Pl(Number(G),_.min,_.sliderMax);k(ie),S(!0)};f.useEffect(()=>{if(!N||O===null||!_.interactive||A.current)return;const G=O,ie=_.value,se=setTimeout(()=>{if(G===ie){k(null),S(!1);return}A.current=!0,u({title:d("commandCenter.controls.concurrency.confirmTitle","Confirm concurrency change"),message:d("commandCenter.controls.concurrency.confirmMessage","Change {{setting}} from {{oldValue}} to {{newValue}}?",{setting:d("settings.scheduling.globalMaxConcurrent","Global Max Concurrent"),oldValue:ie,newValue:G}),confirmLabel:d("commandCenter.controls.concurrency.confirmSave","Save change"),cancelLabel:d("commandCenter.controls.concurrency.confirmCancel","Cancel")}).then(re=>{A.current=!1,re&&_.setValue(String(G)),k(null),S(!1)})},Gv);return()=>clearTimeout(se)},[u,_.interactive,_.setValue,_.value,N,O,d]);const F=m,V=y.data??yr,U=_.status==="loaded",te=_.projectActiveCount(e),q=O??_.value,ee=Math.max(_.sliderMax,q),L=jn("maxConcurrent",V.maxConcurrent),B=Xv(_.currentlyActive,ee),X=Xv(te,L),Q=_.status==="loading"||_.status==="idle"?d("commandCenter.controls.status.loading","Loading…"):_.status==="error"?d("commandCenter.controls.status.loadError","Load failed"):_.saveState==="saving"?d("commandCenter.controls.status.saving","Saving…"):_.saveState==="saved"?d("commandCenter.controls.status.saved","Saved"):_.saveState==="error"?d("commandCenter.controls.status.saveError","Save failed"):d("commandCenter.controls.status.ready","Ready");return s.jsx("section",{className:"cc-controls","data-testid":"command-center-controls","aria-label":d("commandCenter.controls.title","Operator controls"),children:s.jsxs("div",{className:"cc-controls-grid",children:[s.jsxs("section",{className:"card cc-controls-card","data-testid":"cc-controls-engine",children:[s.jsxs("div",{className:"cc-controls-card-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:d("commandCenter.controls.engine.title","AI engine")}),s.jsx("p",{children:d("commandCenter.controls.engine.description","Stopping the engine halts all AI work.")})]}),s.jsx(o$,{paused:F,label:F?d("commandCenter.controls.status.stopped","Stopped"):d("commandCenter.controls.status.running","Running")})]}),s.jsxs("button",{type:"button",className:"btn btn-secondary cc-controls-action",onClick:()=>void h(),children:[s.jsx(c0,{size:16,"aria-hidden":"true"}),s.jsx("span",{children:F?d("header.startAiEngine","Start AI Engine"):d("header.stopAiEngine","Stop AI Engine")})]}),c?s.jsxs("div",{className:"cc-overview-engine-nav","data-testid":"command-center-engine-panel",children:[s.jsx("button",{type:"button",className:"btn btn-secondary cc-overview-engine-nav-btn",onClick:()=>c("board"),children:d("commandCenter.controls.engine.viewBoard","View Board")}),s.jsx("button",{type:"button",className:"btn btn-secondary cc-overview-engine-nav-btn",onClick:()=>c("agents"),children:d("commandCenter.controls.engine.viewAgents","View Agents")})]}):null]}),s.jsxs("section",{className:"card cc-controls-card","data-testid":"cc-controls-theme",children:[s.jsx("div",{className:"cc-controls-card-header",children:s.jsxs("div",{children:[s.jsx("h3",{children:d("commandCenter.controls.theme.title","Theme")}),s.jsx("p",{children:d("commandCenter.controls.theme.description","Switch the dashboard theme with live color previews.")})]})}),s.jsx(a$,{colorTheme:t,themeMode:r,shadcnCustomColors:n,resolvedThemeMode:a,onColorThemeChange:i,onThemeModeChange:o,onShadcnCustomColorsChange:l})]}),s.jsxs("section",{className:"card cc-controls-card cc-controls-card--concurrency","data-testid":"cc-controls-concurrency",children:[s.jsxs("div",{className:"cc-controls-card-header",children:[s.jsxs("div",{children:[s.jsx("h3",{children:d("commandCenter.controls.concurrency.title","Concurrency")}),s.jsx("p",{children:d("commandCenter.controls.concurrency.description","Tune live scheduler capacity.")})]}),s.jsx("span",{className:`cc-controls-save-state cc-controls-save-state--${j}`,"aria-live":"polite",children:y.status==="loading"?d("commandCenter.controls.status.loading","Loading…"):j==="saving"?d("commandCenter.controls.status.saving","Saving…"):j==="saved"?d("commandCenter.controls.status.saved","Saved"):j==="error"?d("commandCenter.controls.status.saveError","Save failed"):d("commandCenter.controls.status.ready","Ready")})]}),s.jsxs("div",{className:"cc-controls-sliders",children:[s.jsxs("label",{className:"cc-controls-slider cc-controls-slider--global",htmlFor:"cc-global-max-concurrent",children:[s.jsxs("span",{className:"cc-controls-slider-label",children:[d("settings.scheduling.globalMaxConcurrent","Global Max Concurrent"),s.jsx("strong",{children:q})]}),s.jsx("small",{className:"cc-controls-slider-caption",children:d("settings.scheduling.maximumConcurrentAgentsAcrossAllProjects","Maximum concurrent agents across all projects")}),U?s.jsx("small",{className:"cc-controls-slider-caption","data-testid":"cc-global-running",children:d("commandCenter.controls.concurrency.runningGlobal","{{count}} running (all projects)",{count:_.currentlyActive})}):null,s.jsxs("span",{className:"cc-controls-range-wrap",children:[s.jsx("input",{id:"cc-global-max-concurrent",className:"cc-controls-touch-slider",type:"range",min:_.min,max:ee,value:q,disabled:!_.interactive,onChange:G=>D(G.target.value)}),U?s.jsx("span",{className:"status-dot status-dot--online cc-controls-use-marker",style:Yv(B),"data-testid":"cc-global-use-marker","aria-hidden":"true"}):null]}),s.jsx("span",{className:`cc-controls-save-state cc-controls-save-state--${_.saveState}`,"aria-live":"polite",children:Q}),_.status==="error"?s.jsx("small",{className:"cc-controls-error",role:"alert",children:d("commandCenter.controls.concurrency.error","Unable to load concurrency settings")}):null]}),s.jsxs("label",{className:"cc-controls-slider",htmlFor:"cc-max-concurrent",children:[s.jsxs("span",{className:"cc-controls-slider-label",children:[d("commandCenter.controls.concurrency.maxConcurrent","Max concurrent tasks"),s.jsx("strong",{children:V.maxConcurrent})]}),U?s.jsx("small",{className:"cc-controls-slider-caption","data-testid":"cc-project-running",children:d("commandCenter.controls.concurrency.runningProject","{{count}} running (this project)",{count:te})}):null,s.jsxs("span",{className:"cc-controls-range-wrap",children:[s.jsx("input",{id:"cc-max-concurrent",className:"cc-controls-touch-slider",type:"range",min:xr.maxConcurrent.min,max:L,value:V.maxConcurrent,disabled:y.status==="loading",onChange:G=>I("maxConcurrent",G.target.value,xr.maxConcurrent.min,L)}),U?s.jsx("span",{className:"status-dot status-dot--online cc-controls-use-marker",style:Yv(X),"data-testid":"cc-project-use-marker","aria-hidden":"true"}):null]})]}),s.jsxs("label",{className:"cc-controls-slider",htmlFor:"cc-max-triage-concurrent",children:[s.jsxs("span",{className:"cc-controls-slider-label",children:[d("commandCenter.controls.concurrency.maxTriageConcurrent","Max triage concurrent"),s.jsx("strong",{children:V.maxTriageConcurrent})]}),s.jsx("input",{id:"cc-max-triage-concurrent",className:"cc-controls-touch-slider",type:"range",min:xr.maxTriageConcurrent.min,max:jn("maxTriageConcurrent",V.maxTriageConcurrent),value:V.maxTriageConcurrent,disabled:y.status==="loading",onChange:G=>I("maxTriageConcurrent",G.target.value,xr.maxTriageConcurrent.min,jn("maxTriageConcurrent",V.maxTriageConcurrent))})]}),s.jsxs("label",{className:"cc-controls-slider",htmlFor:"cc-max-worktrees",children:[s.jsxs("span",{className:"cc-controls-slider-label",children:[d("commandCenter.controls.concurrency.maxWorktrees","Max worktrees"),s.jsx("strong",{children:V.maxWorktrees})]}),s.jsx("input",{id:"cc-max-worktrees",className:"cc-controls-touch-slider",type:"range",min:xr.maxWorktrees.min,max:jn("maxWorktrees",V.maxWorktrees),value:V.maxWorktrees,disabled:y.status==="loading",onChange:G=>I("maxWorktrees",G.target.value,xr.maxWorktrees.min,jn("maxWorktrees",V.maxWorktrees))})]})]}),y.status==="error"?s.jsx("p",{className:"cc-controls-error",role:"alert",children:y.error}):null]})]})})}function Zv(e){return`${(e*100).toFixed(1)}%`}function Jv(e){return e===null?"—":`${(e/6e4).toFixed(1)}m`}function ba(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?e:t.toLocaleString()}function c$(){const{t:e}=le("app"),[t,r]=f.useState(null),[n,a]=f.useState(!0),[i,o]=f.useState(null),[l,c]=f.useState(!1),[d,u]=f.useState(!1),[m,h]=f.useState(null),v=f.useCallback(async()=>{a(!0),o(null);try{const S=await fetch("/api/health/reliability");if(!S.ok)throw new Error(`Failed to load reliability metrics (${S.status})`);const A=await S.json();r(A)}catch(S){o(S instanceof Error?S.message:e("reliability.failedToLoad","Failed to load reliability metrics"))}finally{a(!1)}},[e]),y=f.useCallback(async()=>{h(null);const S=await fetch("/api/health/reliability/reset",{method:"POST"});if(!S.ok)throw new Error(`Failed to reset reliability metrics (${S.status})`);await v(),u(!1)},[v]);f.useEffect(()=>{v();const S=setInterval(()=>{v()},6e4);return()=>clearInterval(S)},[v]);const g=t?.headline.inReviewFailureRate7d,p=f.useMemo(()=>g==null?null:Math.max(0,Math.min(1,1-g)),[g]),b=f.useMemo(()=>p===null?"var(--text-muted)":p>=.95?"var(--color-success)":p>=.9?"var(--color-warning)":"var(--color-error)",[p]),j=f.useMemo(()=>(t?.perDay??[]).reduce((S,A)=>S+A.tasksEnteredInReview,0),[t?.perDay]),x=f.useMemo(()=>(t?.perDay??[]).reduce((S,A)=>S+A.tasksBouncedToInProgress,0),[t?.perDay]),C=f.useMemo(()=>t?.perDay?[...l?t.perDay:t.perDay.filter(A=>A.hasSamples!==!1)].sort((A,_)=>A.date.localeCompare(_.date)):[],[t?.perDay,l]),w=f.useMemo(()=>C.some(A=>A.tasksEnteredInReview>0||A.tasksBouncedToInProgress>0)?[{label:e("reliability.flowChart.entered","Entered"),values:C.map(A=>A.tasksEnteredInReview)},{label:e("reliability.flowChart.bounced","Bounced"),values:C.map(A=>A.tasksBouncedToInProgress)}]:[],[C,e]),P=f.useMemo(()=>Object.entries(t?.mergeAttempts.histogram??{}).sort(([S],[A])=>S.localeCompare(A,void 0,{numeric:!0})),[t?.mergeAttempts.histogram]),O=f.useMemo(()=>P.map(([S,A])=>({label:S,value:A})),[P]),k=f.useMemo(()=>P.reduce((S,[,A])=>S+A,0),[P]),N=t?ba(t.resetAt??new Date(Date.parse(t.generatedAt)-t.windowDays*864e5).toISOString()):"—";return n&&t===null?s.jsxs("div",{className:"reliability-loading","data-testid":"reliability-loading",children:[s.jsx(El,{size:24,className:"spin"}),s.jsx("p",{children:e("reliability.loading","Loading reliability data...")})]}):i!==null&&t===null?s.jsxs("div",{className:"reliability-error","data-testid":"reliability-error",role:"alert",children:[s.jsx(gi,{size:24}),s.jsx("p",{children:i})]}):s.jsxs("section",{className:"reliability-view",children:[s.jsxs("div",{className:"card reliability-card reliability-headline-card",children:[s.jsxs("div",{className:"reliability-section-header",children:[s.jsx("h2",{children:e("reliability.heading","Reliability")}),s.jsx("button",{className:"btn btn-danger btn-sm",onClick:()=>u(!0),children:e("reliability.resetStats","Reset stats")})]}),s.jsx("div",{className:"reliability-headline",style:{color:b},children:g==null?e("reliability.insufficientData","Insufficient data — {{reason}}",{reason:t?.headline.reason??"unknown"}):Zv(p??0)}),p!==null?s.jsx("div",{className:"reliability-muted",children:e("reliability.successRateLabel","In-review success rate (last 7d)")}):null,t?.resetAt?s.jsx("div",{className:"reliability-muted",children:e("reliability.countingSince","Counting since {{date}}",{date:ba(t.resetAt)})}):null,s.jsxs("details",{className:"reliability-details",children:[s.jsx("summary",{children:e("reliability.details","Details")}),s.jsxs("div",{className:"reliability-details-content",children:[s.jsx("div",{children:e("reliability.bouncedEntered","{{bounced}} bounced / {{entered}} entered (last {{days}}d)",{bounced:x,entered:j,days:t?.windowDays??7})}),g!=null?s.jsx("div",{children:e("reliability.failureRate","Failure rate: {{rate}}",{rate:Zv(g)})}):null,s.jsx("div",{children:e("reliability.window","Window: {{start}} → {{end}}",{start:N,end:ba(t?.generatedAt)})}),t?.resetAt?s.jsx("div",{children:e("reliability.resetBaseline","Reset baseline: {{date}}",{date:ba(t.resetAt)})}):null,t?.headline.reason?s.jsx("div",{children:e("reliability.reason","Reason: {{reason}}",{reason:t.headline.reason})}):null]})]})]}),s.jsxs("div",{className:"reliability-grid",children:[s.jsxs("div",{className:"card reliability-card",children:[s.jsxs("div",{className:"reliability-section-header",children:[s.jsx("h3",{children:e("reliability.inReviewFlow","In-review flow")}),s.jsx("button",{className:"btn btn-sm",onClick:()=>c(S=>!S),children:l?e("reliability.hideEmptyDays","Hide empty days"):e("reliability.showEmptyDays","Show empty days")})]}),s.jsxs("div",{className:"reliability-chart-section","data-testid":"reliability-flow-chart",children:[s.jsx("h4",{children:e("reliability.flowChart.heading","Entered vs bounced trend")}),s.jsx(cr,{series:w,ariaLabel:e("reliability.flowChart.aria","In-review entered vs bounced per day"),emptyLabel:e("reliability.flowChart.empty","No in-review flow data")})]}),s.jsxs("table",{className:"reliability-table",children:[s.jsx("thead",{children:s.jsxs("tr",{children:[s.jsx("th",{children:e("reliability.table.date","Date")}),s.jsx("th",{children:e("reliability.table.entered","Entered")}),s.jsx("th",{children:e("reliability.table.bounced","Bounced")})]})}),s.jsx("tbody",{children:C.map(S=>s.jsxs("tr",{children:[s.jsx("td",{children:S.date}),s.jsx("td",{children:S.tasksEnteredInReview}),s.jsx("td",{children:S.tasksBouncedToInProgress})]},S.date))})]})]}),s.jsxs("div",{className:"card reliability-card",children:[s.jsx("h3",{children:e("reliability.duration.heading","Duration")}),s.jsxs("div",{className:"reliability-stat-row",children:[s.jsx("span",{children:e("reliability.duration.p50","P50")}),s.jsx("strong",{children:Jv(t?.duration.p50Ms??null)})]}),s.jsxs("div",{className:"reliability-stat-row",children:[s.jsx("span",{children:e("reliability.duration.p95","P95")}),s.jsx("strong",{children:Jv(t?.duration.p95Ms??null)})]}),s.jsx("div",{className:"reliability-muted",children:e("reliability.duration.samples","Samples: {{count}}",{count:t?.duration.sampleCount??0})}),s.jsxs("details",{className:"reliability-details",children:[s.jsx("summary",{children:e("reliability.duration.moreStats","More stats")}),s.jsxs("div",{className:"reliability-details-content",children:[s.jsx("div",{children:e("reliability.duration.p50Raw","P50 raw: {{value}} ms",{value:t?.duration.p50Ms??"—"})}),s.jsx("div",{children:e("reliability.duration.p95Raw","P95 raw: {{value}} ms",{value:t?.duration.p95Ms??"—"})}),s.jsx("div",{children:e("reliability.duration.sampleCount","Sample count: {{count}}",{count:t?.duration.sampleCount??0})}),t?.duration.reason?s.jsx("div",{children:e("reliability.duration.reason","Reason: {{reason}}",{reason:t.duration.reason})}):null]})]})]}),s.jsxs("div",{className:"card reliability-card",children:[s.jsx("h3",{children:e("reliability.mergeAttempts.heading","Merge attempts")}),s.jsxs("div",{className:"reliability-stat-row",children:[s.jsx("span",{children:e("reliability.mergeAttempts.mean","Mean")}),s.jsx("strong",{children:t?.mergeAttempts.mean?.toFixed(2)??"—"})]}),s.jsxs("div",{className:"reliability-stat-row",children:[s.jsx("span",{children:e("reliability.mergeAttempts.max","Max")}),s.jsx("strong",{children:t?.mergeAttempts.max??"—"})]}),s.jsxs("div",{className:"reliability-chart-section","data-testid":"reliability-merge-attempts-chart",children:[s.jsx("h4",{children:e("reliability.mergeAttemptsChart.heading","Attempts distribution")}),s.jsx(kt,{data:O,ariaLabel:e("reliability.mergeAttemptsChart.aria","Merge attempts histogram"),emptyLabel:e("reliability.mergeAttemptsChart.empty","No merge attempt data")})]}),s.jsx("ul",{className:"reliability-histogram",children:P.map(([S,A])=>s.jsxs("li",{children:[s.jsx("span",{children:S}),s.jsx("div",{className:"reliability-histogram-bar-wrap",children:s.jsx("div",{className:"reliability-histogram-bar",style:{width:`${Math.min(A*20,100)}%`}})}),s.jsx("strong",{children:A})]},S))}),s.jsxs("details",{className:"reliability-details",children:[s.jsx("summary",{children:e("reliability.mergeAttempts.moreStats","More stats")}),s.jsxs("div",{className:"reliability-details-content",children:[s.jsx("div",{children:e("reliability.mergeAttempts.tasksCounted","Tasks counted: {{count}}",{count:k})}),s.jsx("div",{children:e("reliability.mergeAttempts.histogramTotal","Histogram total: {{count}}",{count:k})}),t?.mergeAttempts.reason?s.jsx("div",{children:e("reliability.mergeAttempts.reason","Reason: {{reason}}",{reason:t.mergeAttempts.reason})}):null]})]})]})]}),d?s.jsx("div",{className:"modal-overlay open",role:"presentation",children:s.jsxs("div",{className:"modal",role:"dialog","aria-modal":"true","aria-labelledby":"reliability-reset-title",children:[s.jsx("div",{className:"modal-header",children:s.jsx("h2",{id:"reliability-reset-title",children:e("reliability.resetModal.title","Reset reliability stats?")})}),s.jsx("p",{children:e("reliability.resetModal.description","This sets a new baseline for reliability statistics. Historical events older than the reset time are excluded from counts but are not deleted.")}),m?s.jsx("div",{className:"form-error",children:m}):null,s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{className:"btn",onClick:()=>u(!1),children:e("common.cancel","Cancel")}),s.jsx("button",{className:"btn btn-danger",onClick:()=>{y().catch(S=>{h(S instanceof Error?S.message:e("reliability.resetModal.failedError","Failed to reset reliability stats"))})},children:e("reliability.resetModal.confirm","Confirm reset")})]})]})}):null]})}function Eo(e){const{lastSyncAt:t,remoteReachable:r,diff:n}=e,a=Object.values(n.workflowSettings).reduce((o,l)=>o+l.length,0),i=n.global.length+n.project.length+a;return t===null?{syncState:"never-synced",lastSyncAt:t,diffCount:0}:r?i>0?{syncState:"diff",lastSyncAt:t,diffCount:i}:{syncState:"synced",lastSyncAt:t,diffCount:0}:{syncState:"error",lastSyncAt:t,diffCount:i}}function Sl(e){if(e===null)return"Never synced";const t=new Date(e);if(Number.isNaN(t.getTime()))return"Never synced";const n=Date.now()-t.getTime(),a=Math.floor(n/1e3),i=Math.floor(a/60),o=Math.floor(i/60),l=Math.floor(o/24);return i<1?"Synced just now":i<60?`Synced ${i}m ago`:o<24?`Synced ${o}h ago`:`Synced ${l}d ago`}function u$(e){switch(e){case"synced":return"var(--color-success)";case"pending":return"var(--color-warning)";case"diff":return"var(--color-warning)";case"error":return"var(--color-error)";case"never-synced":return"var(--text-muted)"}}const d$=3e4;function f$(){const{t:e}=le("app"),[t,r]=f.useState({}),[n,a]=f.useState(!1),[i,o]=f.useState({}),[l,c]=f.useState(null),d=f.useRef(new Set),u=f.useRef(!1),m=f.useRef(null),h=f.useRef(null),v=f.useCallback(async(k,N)=>{try{const S=await Qx(k);r(A=>({...A,[k]:S})),c(null)}catch(S){console.error(`Failed to fetch sync status for node ${k}:`,S),c(S instanceof Error?S.message:e("nodeSync.error.failedToFetchStatus","Failed to fetch sync status"))}},[e]),y=f.useCallback(async()=>{const k=Array.from(d.current);if(k.length===0)return;m.current&&m.current.abort(),m.current=new AbortController;const N=!u.current;N&&a(!0),c(null);try{const S=await Promise.allSettled(k.map(_=>v(_,N)));u.current=!0,S.filter(_=>_.status==="rejected").length>0&&c(e("nodeSync.error.someRequestsFailed","Some sync status requests failed"))}catch(S){if(S instanceof Error&&S.name==="AbortError")return;c(S instanceof Error?S.message:e("nodeSync.error.failedToFetchStatus","Failed to fetch sync status")),u.current=!0}finally{a(!1)}},[v,e]),g=f.useCallback(()=>{h.current&&clearInterval(h.current),h.current=setInterval(()=>{y()},d$)},[y]),p=f.useCallback(()=>{h.current&&(clearInterval(h.current),h.current=null)},[]);f.useEffect(()=>(y(),g(),()=>{p(),m.current&&m.current.abort()}),[y,g,p]);const b=f.useCallback(k=>{d.current.has(k)||(d.current.add(k),v(k,!u.current))},[v]),j=f.useCallback(k=>{d.current.delete(k),r(N=>{const S={...N};return delete S[k],S}),d.current.size===0&&p()},[p]),x=f.useCallback(async k=>{o(N=>({...N,[k]:!0})),c(null);try{const N=await ej(k);return v(k,!1),!N.success&&N.error&&c(N.error),N}catch(N){const S=N instanceof Error?N.message:e("nodeSync.error.pushFailed","Push settings failed");throw c(S),N}finally{o(N=>{const S={...N};return delete S[k],S})}},[v,e]),C=f.useCallback(async k=>{o(N=>({...N,[k]:!0})),c(null);try{const N=await tj(k);return v(k,!1),!N.success&&N.error&&c(N.error),N}catch(N){const S=N instanceof Error?N.message:e("nodeSync.error.pullFailed","Pull settings failed");throw c(S),N}finally{o(N=>{const S={...N};return delete S[k],S})}},[v,e]),w=f.useCallback(async k=>{o(N=>({...N,[k]:!0})),c(null);try{return await rj(k)}catch(N){const S=N instanceof Error?N.message:e("nodeSync.error.authSyncFailed","Auth sync failed");throw c(S),N}finally{o(N=>{const S={...N};return delete S[k],S})}},[e]),P=f.useCallback(k=>t[k]?.authMatch,[t]),O=f.useCallback(k=>t[k]?.authDiff,[t]);return{syncStatusMap:t,loading:n,actionLoading:i,error:l,refresh:y,trackNode:b,untrackNode:j,pushSettings:x,pullSettings:C,syncAuth:w,getAuthSyncState:P,getAuthProviders:O}}const m$=1e4,v$=1e3;function h$(){const{t:e}=le("app"),[t,r]=f.useState([]),[n,a]=f.useState(!0),[i,o]=f.useState(null),l=f.useRef(null),c=f.useRef(0),d=f.useRef(t),u=sh();f.useEffect(()=>{d.current=t},[t]);const m=f.useCallback(v=>d.current.length>0&&oh(v,u.wasRecentlyHidden()),[u]),h=f.useCallback(async()=>{try{o(null);const v=await hu();r(v.nodes)}catch(v){const y=v instanceof Error?v.message:e("mesh.failedToFetchMeshState","Failed to fetch mesh state");m(y)||o(y)}},[m,e]);return f.useEffect(()=>{let v=!1;async function y(){a(!0);try{const p=await hu();v||(r(p.nodes),o(null))}catch(p){const b=p instanceof Error?p.message:e("mesh.failedToFetchMeshState","Failed to fetch mesh state");!v&&!m(b)&&o(b)}finally{v||a(!1)}}y();const g=()=>{if(document.visibilityState!=="visible")return;const p=Date.now(),b=p-c.current;if(b<v$){Aa({view:"useMeshState",trigger:"visibility",projectId:void 0,replayAttempted:!1,reason:"debounce-skipped",detail:{timeSinceLastRefreshMs:b}});return}c.current=p,Aa({view:"useMeshState",trigger:"visibility",projectId:void 0,replayAttempted:!1,reason:"debounced-refresh"}),h()};return document.addEventListener("visibilitychange",g),()=>{v=!0,document.removeEventListener("visibilitychange",g)}},[h,m,e]),f.useEffect(()=>{if(!n)return l.current=setInterval(()=>{h()},m$),()=>{l.current&&(clearInterval(l.current),l.current=null)}},[n,h]),{meshState:t,loading:n,error:i,refresh:h}}function p$(e){return{online:{label:e("nodes.status.online","Online"),color:"var(--color-success)",className:"node-card__status--online"},offline:{label:e("nodes.status.offline","Offline"),color:"var(--color-error)",className:"node-card__status--offline"},connecting:{label:e("nodes.status.connecting","Connecting"),color:"var(--color-warning)",className:"node-card__status--connecting"},error:{label:e("nodes.status.error","Error"),color:"var(--color-error)",className:"node-card__status--error"},creating:{label:e("nodes.status.creating","Creating"),color:"var(--color-warning)",className:"node-card__status--creating"},recreating:{label:e("nodes.status.recreating","Recreating"),color:"var(--color-warning)",className:"node-card__status--recreating"},deleting:{label:e("nodes.status.deleting","Deleting"),color:"var(--color-error)",className:"node-card__status--deleting"},running:{label:e("nodes.status.running","Running"),color:"var(--color-success)",className:"node-card__status--online"},stopped:{label:e("nodes.status.stopped","Stopped"),color:"var(--color-error)",className:"node-card__status--offline"},exited:{label:e("nodes.status.exited","Exited"),color:"var(--color-error)",className:"node-card__status--offline"}}}const y$={match:"var(--color-success)",differs:"var(--color-warning)","not-synced":"var(--text-muted)"};function g$(e,t,r){if(e==="match")return r?r("nodes.auth.match","Auth credentials match"):"Auth credentials match";if(e==="not-synced")return r?r("nodes.auth.notSynced","Auth not synced"):"Auth not synced";if(t&&Object.keys(t).length>0){const n=Object.entries(t).filter(([,a])=>a==="differs").map(([a])=>a);if(n.length>0)return r?r("nodes.auth.differProviders","Auth credentials differ: {{providers}}",{providers:n.join(", ")}):`Auth credentials differ: ${n.join(", ")}`}return r?r("nodes.auth.differ","Auth credentials differ"):"Auth credentials differ"}function b$(e,t=42){return e.length<=t?e:`${e.slice(0,t-3)}...`}function x$(e,t){const r=e.node,n=t.node;if(r.id!==n.id||r.name!==n.name||r.type!==n.type||r.url!==n.url||r.status!==n.status||r.maxConcurrent!==n.maxConcurrent||r.updatedAt!==n.updatedAt||e.isLoading!==t.isLoading)return!1;const a=e.managedDockerNode,i=t.managedDockerNode;if(!!a!=!!i||a&&i&&(a.id!==i.id||a.status!==i.status||a.imageTag!==i.imageTag||a.updatedAt!==i.updatedAt))return!1;const o=e.syncStatus,l=t.syncStatus;if(!(!o&&!l)){if(!o||!l)return!1;if(o.syncState!==l.syncState||o.lastSyncAt!==l.lastSyncAt||o.diffCount!==l.diffCount)return!1}if(e.authSyncState!==t.authSyncState)return!1;const c=e.authSyncProviders,d=t.authSyncProviders;if(c!==d){if(!c||!d)return!1;{const h=Object.keys(c),v=Object.keys(d);if(h.length!==v.length||h.some(y=>c[y]!==d[y]))return!1}}const u=To(e.projects,r),m=To(t.projects,n);return u===m}function j$({node:e,projects:t,onHealthCheck:r,onEdit:n,onRemove:a,isLoading:i=!1,syncStatus:o,authSyncState:l,authSyncProviders:c,managedDockerNode:d}){const{t:u}=le("app"),[m,h]=f.useState(!1),v=p$(u),y=v[e.status]??v.offline,g=d?v[d.status]??v.error:null,p=d?.hostConfig.type==="remote"?u("nodes.dockerHost.remote","Remote: {{host}}",{host:d.hostConfig.host??"unknown"}):u("nodes.dockerHost.local","Local Docker"),b=f.useMemo(()=>To(t,e),[t,e]),j=f.useCallback(()=>{n(e)},[n,e]),x=f.useCallback(O=>{O.stopPropagation(),r(e.id)},[r,e.id]),C=f.useCallback(O=>{O.stopPropagation(),n(e)},[n,e]),w=f.useCallback(O=>{if(O.stopPropagation(),!m){h(!0);return}a(e.id),h(!1)},[m,a,e.id]),P=f.useCallback(O=>{(O.key==="Enter"||O.key===" ")&&(O.preventDefault(),n(e))},[n,e]);return s.jsxs("article",{className:`node-card ${i?"node-card--loading":""}`,"data-node-id":e.id,role:"button",tabIndex:0,onClick:j,onKeyDown:P,children:[s.jsx("header",{className:"node-card__header",children:s.jsxs("div",{className:"node-card__title-wrap",children:[s.jsx("div",{className:"node-card__icon",children:s.jsx(lh,{size:18})}),s.jsxs("div",{children:[s.jsx("h3",{className:"node-card__name",title:e.name,children:e.name}),s.jsxs("div",{className:"node-card__meta-row",children:[s.jsx("span",{className:"node-card__type-badge",children:e.type==="local"?u("nodes.type.local","Local"):u("nodes.type.remote","Remote")}),d&&s.jsxs("span",{className:"node-card__docker-badge",title:u("nodes.dockerBadge","Managed Docker node"),children:[s.jsx(Io,{size:12,"aria-hidden":!0}),u("nodes.dockerLabel","Docker")]}),s.jsxs("span",{className:`node-card__status ${y.className}`,style:{color:y.color},"data-status":e.status,children:[s.jsx("span",{className:"node-card__status-indicator",style:{backgroundColor:y.color},"aria-hidden":!0}),y.label]}),d&&g&&s.jsxs("span",{className:`node-card__status ${g.className}`,style:{color:g.color},"data-status":d.status,children:[s.jsx("span",{className:"node-card__status-indicator",style:{backgroundColor:g.color},"aria-hidden":!0}),g.label]}),e.type==="remote"&&l&&s.jsx("span",{className:`node-card__auth-indicator node-card__auth-indicator--${l}`,title:g$(l,c,u),"aria-label":u("nodes.authSync.label","Auth sync: {{status}}",{status:l==="match"?u("nodes.authSync.match","credentials match"):l==="differs"?u("nodes.authSync.differ","credentials differ"):u("nodes.authSync.notSynced","not synced")}),style:{color:y$[l]},children:s.jsx(ch,{size:14})})]})]})]})}),s.jsxs("div",{className:"node-card__body",children:[e.type==="remote"&&e.url&&s.jsx("div",{className:"node-card__url",title:e.url,children:b$(e.url)}),d&&s.jsxs("div",{className:"node-card__docker-meta",children:[s.jsxs("span",{title:`${d.imageName}:${d.imageTag}`,children:[d.imageName,":",d.imageTag]}),s.jsx("span",{title:p,children:p})]}),s.jsxs("div",{className:"node-card__metrics",children:[s.jsxs("div",{className:"node-card__metric",children:[s.jsx("span",{className:"node-card__metric-label",children:u("nodes.metrics.projects","Projects")}),s.jsx("span",{className:"node-card__metric-value",children:b})]}),s.jsxs("div",{className:"node-card__metric",children:[s.jsx("span",{className:"node-card__metric-label",children:u("nodes.metrics.concurrency","Concurrency")}),s.jsx("span",{className:"node-card__metric-value",children:e.maxConcurrent})]})]}),e.type==="remote"&&o&&s.jsxs("div",{className:"node-card__sync","data-sync-state":o.syncState,"data-testid":"node-card-sync",children:[s.jsx("span",{className:"node-card__sync-dot",style:{backgroundColor:u$(o.syncState)},"aria-hidden":!0}),s.jsx("span",{className:"node-card__sync-time",children:Sl(o.lastSyncAt)})]})]}),s.jsxs("footer",{className:"node-card__actions",children:[s.jsxs("button",{className:"btn btn-sm node-card__action",type:"button",onClick:x,disabled:i,"aria-label":u("nodes.actions.health.ariaLabel","Run node health check"),title:u("nodes.actions.health.title","Health Check"),children:[s.jsx(uh,{size:14}),s.jsx("span",{children:u("nodes.actions.health.label","Health")})]}),s.jsxs("button",{className:"btn btn-sm node-card__action",type:"button",onClick:C,disabled:i,"aria-label":u("nodes.actions.edit.ariaLabel","Edit node"),title:u("nodes.actions.edit.title","Edit"),children:[s.jsx(nj,{size:14}),s.jsx("span",{children:u("nodes.actions.edit.label","Edit")})]}),d&&s.jsxs(s.Fragment,{children:[s.jsxs("button",{className:"btn btn-sm node-card__action",type:"button",disabled:!0,"aria-label":u("nodes.actions.start.ariaLabel","Start node container"),title:u("nodes.actions.start.title","Available after FN-3113"),children:[s.jsx(Il,{size:14}),s.jsx("span",{children:u("nodes.actions.start.label","Start")})]}),s.jsxs("button",{className:"btn btn-sm node-card__action",type:"button",disabled:!0,"aria-label":u("nodes.actions.stop.ariaLabel","Stop node container"),title:u("nodes.actions.stop.title","Available after FN-3113"),children:[s.jsx(dh,{size:14}),s.jsx("span",{children:u("nodes.actions.stop.label","Stop")})]}),s.jsxs("button",{className:"btn btn-sm node-card__action",type:"button",disabled:!0,"aria-label":u("nodes.actions.restart.ariaLabel","Restart node container"),title:u("nodes.actions.restart.title","Available after FN-3113"),children:[s.jsx(aj,{size:14}),s.jsx("span",{children:u("nodes.actions.restart.label","Restart")})]})]}),s.jsxs("button",{className:`btn btn-sm node-card__action node-card__action--remove ${m?"btn-danger is-armed":""}`,type:"button",onClick:w,disabled:i,"aria-label":m?u("nodes.actions.remove.ariaLabelConfirm","Confirm remove node"):u("nodes.actions.remove.ariaLabel","Remove node"),title:m?u("nodes.actions.remove.titleConfirm","Confirm remove"):u("nodes.actions.remove.title","Remove"),children:[s.jsx(Do,{size:14}),s.jsx("span",{children:m?u("nodes.actions.remove.labelConfirm","Confirm"):u("nodes.actions.remove.label","Remove")})]})]})]})}const w$=f.memo(j$,x$),wn={online:"var(--success, var(--color-success))",offline:"var(--text-dim)",connecting:"var(--color-warning)",error:"var(--color-error)"},xa=28,C$=12,k$=300,P$=120;function S$({nodes:e,className:t}){const{t:r}=le("app"),n=f.useMemo(()=>e.find(u=>u.nodeType==="local")??e[0],[e]),a=f.useMemo(()=>e.filter(u=>u.nodeId!==n?.nodeId),[e,n?.nodeId]),i=f.useMemo(()=>k$+Math.max(0,a.length-4)*20,[a.length]),o=i/2,l=i/2,c=f.useMemo(()=>{const u=new Map;if(n&&u.set(n.nodeId,{x:o,y:l,node:n}),a.length>0){const m=Math.min(P$,i/2-xa-10),h=2*Math.PI/a.length,v=-Math.PI/2;a.forEach((y,g)=>{const p=v+g*h;u.set(y.nodeId,{node:y,x:o+m*Math.cos(p),y:l+m*Math.sin(p)})})}return u},[o,l,n,a,i]),d=f.useMemo(()=>{const u=new Set,m=[];for(const h of e){const v=c.get(h.nodeId);if(v)for(const y of h.knownPeers){const g=c.get(y.peerNodeId);if(!g)continue;const p=[h.nodeId,y.peerNodeId].sort().join("::");u.has(p)||(u.add(p),m.push({key:p,from:v,to:g}))}}return m},[c,e]);return e.length===0?s.jsx("div",{className:`mesh-topology mesh-topology--empty ${t??""}`,children:s.jsx("div",{className:"mesh-topology__empty-state",children:s.jsx("p",{children:r("mesh.noNodes","No nodes to display")})})}):s.jsxs("div",{className:`mesh-topology ${t??""}`,children:[s.jsxs("svg",{className:"mesh-topology__svg",viewBox:`0 0 ${i} ${i}`,preserveAspectRatio:"xMidYMid meet","aria-label":r("mesh.ariaLabel","Node mesh topology visualization"),children:[d.map(u=>s.jsx("line",{className:"mesh-topology__link mesh-topology__peer-line",x1:u.from.x,y1:u.from.y,x2:u.to.x,y2:u.to.y},u.key)),Array.from(c.values()).map(({node:u,x:m,y:h})=>s.jsxs("g",{className:"mesh-topology__node",transform:`translate(${m}, ${h})`,children:[s.jsx("circle",{className:"mesh-topology__node-circle",r:xa,fill:wn[u.status],"aria-label":`${u.nodeName} (${u.status})`}),s.jsx("text",{className:"mesh-topology__node-label",y:xa+C$,textAnchor:"middle",children:u.nodeName.length>12?`${u.nodeName.slice(0,10)}…`:u.nodeName}),s.jsxs("g",{className:"mesh-topology__node-type",transform:`translate(0 ${-xa-10})`,children:[s.jsx("circle",{className:"mesh-topology__node-type-badge",r:"8"}),s.jsx("text",{className:"mesh-topology__node-type-text",textAnchor:"middle",dominantBaseline:"middle",children:u.nodeType==="local"?"L":"R"})]})]},u.nodeId))]}),s.jsxs("div",{className:"mesh-topology__legend",children:[s.jsxs("div",{className:"mesh-topology__legend-item",children:[s.jsx("span",{className:"mesh-topology__legend-dot",style:{background:wn.online}}),s.jsx("span",{children:r("mesh.online","Online")})]}),s.jsxs("div",{className:"mesh-topology__legend-item",children:[s.jsx("span",{className:"mesh-topology__legend-dot",style:{background:wn.offline}}),s.jsx("span",{children:r("mesh.offline","Offline")})]}),s.jsxs("div",{className:"mesh-topology__legend-item",children:[s.jsx("span",{className:"mesh-topology__legend-dot",style:{background:wn.connecting}}),s.jsx("span",{children:r("mesh.connecting","Connecting")})]}),s.jsxs("div",{className:"mesh-topology__legend-item",children:[s.jsx("span",{className:"mesh-topology__legend-dot",style:{background:wn.error}}),s.jsx("span",{children:r("mesh.error","Error")})]})]}),d.length===0&&s.jsx("p",{className:"mesh-topology__notice",children:r("mesh.noPeers","Peer-to-peer discovery data unavailable.")})]})}const N$=f.memo(S$),Nl=1,Ol=10;function O$(e,t){const r={projectMappings:{}};e.name.trim()||(r.name=t("nodes.nameRequired","Name is required")),e.type==="remote"&&!e.url?.trim()&&(r.url=t("nodes.urlRequired","URL is required for remote nodes")),(!Number.isFinite(e.maxConcurrent)||e.maxConcurrent<Nl||e.maxConcurrent>Ol)&&(r.maxConcurrent=t("nodes.concurrencyRange","Concurrency must be between {{min}} and {{max}}",{min:Nl,max:Ol}));for(const n of e.projectMappings){const a=o0(n.path);a.valid||(r.projectMappings[n.projectId]=a.error??t("nodes.pathInvalid","Path is invalid"))}return r}function A$({isOpen:e,onClose:t,onSubmit:r,onDiscoverRemoteProjects:n,addToast:a,projects:i}){const{t:o}=le("app");ij(e);const[l,c]=f.useState(""),[d,u]=f.useState("local"),[m,h]=f.useState(""),[v,y]=f.useState(""),[g,p]=f.useState(2),[b,j]=f.useState("auto-generate"),[x,C]=f.useState({}),[w,P]=f.useState({projectMappings:{}}),[O,k]=f.useState(!1),[N,S]=f.useState("idle"),[A,_]=f.useState(null),[I,D]=f.useState([]),F=f.useCallback(()=>{c(""),u("local"),h(""),y(""),p(2),j("auto-generate"),C({}),P({projectMappings:{}}),k(!1),S("idle"),_(null),D([])},[]),V=f.useCallback(()=>{O||(F(),t())},[O,t,F]);f.useEffect(()=>{if(!e){F();return}const B=X=>{X.key==="Escape"&&(X.preventDefault(),V())};return document.addEventListener("keydown",B),()=>{document.removeEventListener("keydown",B)}},[V,e,F]);const U=f.useMemo(()=>({name:l.trim(),type:d,url:d==="remote"&&m.trim()||void 0,apiKey:d==="remote"&&b==="provide"&&v||void 0,maxConcurrent:g,apiKeyMode:b,projectMappings:Object.entries(x).map(([B,X])=>({projectId:B,path:X.trim()}))}),[v,b,g,l,x,d,m]),te=f.useCallback(async()=>{if(O||N==="loading")return;const B=m.trim();if(!B){P(X=>({...X,url:o("nodes.urlRequired","URL is required for remote nodes")}));return}S("loading"),_(null);try{const X=await n({url:B,apiKey:b==="provide"&&v.trim().length>0?v:void 0});D(X.projects),S("success"),C(Q=>{if(Object.keys(Q).length===0)return Q;const G={...Q};for(const ie of i){if(!(ie.id in G))continue;const se=X.projects.filter(re=>re.name===ie.name);se.length===1&&(G[ie.id]=se[0].path)}return G})}catch(X){S("error"),D([]),_(X instanceof Error?X.message:o("nodes.discoveryFailed","Failed to discover remote projects"))}},[v,b,N,O,n,i,o,m]);f.useEffect(()=>{if(d!=="remote"){S("idle"),_(null),D([]);return}S("idle"),_(null),D([])},[v,b,d,m]);const q=f.useCallback(async()=>{if(O)return;const B=O$(U,o);if(P(B),!(B.name||B.url||B.maxConcurrent||Object.keys(B.projectMappings).length>0)){if(U.type==="remote"&&N!=="success"){_(o("nodes.discoverBeforeAdding","Discover remote projects before adding this node."));return}k(!0);try{await r(U),a(o("nodes.registered",'Node "{{name}}" registered',{name:U.name}),"success"),V()}catch(X){const Q=X instanceof Error?X.message:o("nodes.registerFailed","Failed to register node");a(Q,"error")}finally{k(!1)}}},[a,V,N,U,O,r,o]),ee=B=>{C(X=>{if(B.id in X){const{[B.id]:Q,...G}=X;return G}if(d==="remote"&&N==="success"){const Q=I.filter(G=>G.name===B.name);return Q.length===1?{...X,[B.id]:Q[0].path}:{...X,[B.id]:""}}return{...X,[B.id]:B.path}})},L=(B,X)=>{C(Q=>({...Q,[B]:X}))};return e?s.jsx("div",{className:"modal-overlay open",onClick:V,children:s.jsxs("div",{className:"modal modal-md add-node-modal",onClick:B=>B.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":o("nodes.addNode","Add Node"),children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{children:o("nodes.addNode","Add Node")}),s.jsx("button",{className:"modal-close",onClick:V,disabled:O,"aria-label":o("nodes.closeNodeModal","Close add node modal"),children:"×"})]}),s.jsxs("div",{className:"modal-body add-node-modal__body",children:[s.jsx("p",{className:"add-node-modal__description",children:o("nodes.description","Register an existing Fusion node by providing its connection details and concurrency settings.")}),s.jsxs("label",{className:"add-node-modal__field",children:[s.jsx("span",{children:o("nodes.name","Name")}),s.jsx("input",{className:"input",type:"text",value:l,onChange:B=>c(B.target.value),placeholder:o("nodes.namePlaceholder","Build Machine"),disabled:O,"aria-invalid":!!w.name,autoFocus:!0}),w.name&&s.jsx("span",{className:"form-error add-node-modal__error",children:w.name})]}),s.jsxs("div",{className:"add-node-modal__type-toggle",children:[s.jsx("button",{type:"button",className:`add-node-modal__type-btn ${d==="local"?"active":""}`,"data-type":"local",onClick:()=>u("local"),disabled:O,"aria-pressed":d==="local",children:o("nodes.local","Local")}),s.jsx("button",{type:"button",className:`add-node-modal__type-btn ${d==="remote"?"active":""}`,"data-type":"remote",onClick:()=>u("remote"),disabled:O,"aria-pressed":d==="remote",children:o("nodes.remote","Remote")})]}),d==="remote"&&s.jsxs("div",{className:"add-node-modal__remote-fields","data-testid":"remote-fields-container","data-visible":!0,children:[s.jsxs("label",{className:"add-node-modal__field",children:[s.jsx("span",{children:o("nodes.reachableUrl","Reachable URL / Hostname")}),s.jsx("input",{className:"input",type:"text",value:m,onChange:B=>h(B.target.value),placeholder:"https://node.example.com",disabled:O,"aria-invalid":!!w.url}),w.url&&s.jsx("span",{className:"form-error add-node-modal__error",children:w.url})]}),s.jsxs("label",{className:"add-node-modal__field",children:[s.jsx("span",{children:o("nodes.apiKeyMode","API Key Mode")}),s.jsxs("select",{className:"select",value:b,onChange:B=>j(B.target.value),disabled:O,children:[s.jsx("option",{value:"auto-generate",children:o("nodes.autoGenerate","Auto-generate")}),s.jsx("option",{value:"provide",children:o("nodes.provideManually","Provide key manually")})]})]}),b==="provide"&&s.jsxs("label",{className:"add-node-modal__field",children:[s.jsx("span",{children:o("nodes.apiKey","API Key")}),s.jsx("input",{className:"input",type:"password",value:v,onChange:B=>y(B.target.value),placeholder:o("nodes.apiKeyPlaceholder","Enter node API key"),disabled:O})]}),s.jsxs("div",{className:"add-node-modal__discovery-actions",children:[s.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>void te(),disabled:O||N==="loading",children:N==="loading"?o("nodes.discovering","Discovering..."):o("nodes.discoverRemoteProjects","Discover Remote Projects")}),N==="success"&&s.jsx("span",{className:"add-node-modal__discovery-state","data-state":"success",children:I.length>0?o("nodes.discoveredCount","Discovered {{count}} remote project{{plural}}",{count:I.length,plural:I.length===1?"":"s"}):o("nodes.noProjectsDiscovered","No projects discovered on remote node.")}),N==="error"&&A&&s.jsx("span",{className:"form-error add-node-modal__error",children:A}),N==="idle"&&s.jsx("span",{className:"add-node-modal__hint",children:o("nodes.discoverBeforeAdding","Discover remote projects before adding this node.")})]}),N==="success"&&I.length>0&&s.jsx("div",{className:"add-node-modal__discovered-list","aria-label":o("nodes.discoveredRemoteProjectsLabel","Discovered remote projects"),children:I.map(B=>s.jsxs("div",{className:"card add-node-modal__discovered-card",children:[s.jsxs("div",{className:"add-node-modal__discovered-row",children:[s.jsx("strong",{children:B.name}),s.jsx("span",{className:"card-status-badge card-status-badge--in-review",children:B.status})]}),s.jsx("div",{className:"add-node-modal__hint",children:B.path})]},`${B.id}-${B.path}`))})]}),s.jsxs("label",{className:"add-node-modal__field",children:[s.jsx("span",{children:o("nodes.maxConcurrent","Max Concurrent")}),s.jsx("input",{className:"input",type:"number",min:Nl,max:Ol,value:g,onChange:B=>p(Number(B.target.value)),disabled:O,"aria-invalid":!!w.maxConcurrent}),s.jsx("span",{className:"add-node-modal__hint",children:o("nodes.maxConcurrentHint","Max simultaneous task agents (1–10)")}),w.maxConcurrent&&s.jsx("span",{className:"form-error add-node-modal__error",children:w.maxConcurrent})]}),s.jsxs("section",{className:"add-node-modal__projects","aria-label":o("nodes.projectPathMappingsLabel","Project path mappings"),children:[s.jsx("h4",{className:"add-node-modal__projects-title",children:o("nodes.attachProjects","Attach Existing Projects")}),s.jsx("p",{className:"add-node-modal__hint",children:o("nodes.attachProjectsHint","Select existing projects to run on this node and provide the node-specific absolute path for each one.")}),i.length===0?s.jsx("p",{className:"add-node-modal__hint",children:o("nodes.noProjects","No projects are currently registered.")}):s.jsx("div",{className:"add-node-modal__project-list",children:i.map(B=>{const X=B.id in x,Q=w.projectMappings[B.id];return s.jsxs("div",{className:"card add-node-modal__project-card",children:[s.jsxs("label",{className:"checkbox-label add-node-modal__project-toggle",children:[s.jsx("input",{type:"checkbox",checked:X,onChange:()=>ee(B),disabled:O}),s.jsx("span",{children:B.name})]}),X&&s.jsxs("label",{className:"add-node-modal__field",children:[s.jsx("span",{children:o("nodes.pathOnNode","Path on this node")}),d==="remote"&&N==="success"&&s.jsx("span",{className:"add-node-modal__hint",children:(()=>{const G=I.filter(ie=>ie.name===B.name);return G.length===1?o("nodes.pathDiscovered","Remote-authoritative path discovered: {{path}}",{path:G[0].path}):G.length>1?o("nodes.multipleMatches","Multiple remote projects matched this name. Enter the correct path manually."):o("nodes.noMatch","No exact remote name match. Enter this path manually.")})()}),s.jsx("input",{className:"input",type:"text",value:x[B.id]??"",onChange:G=>L(B.id,G.target.value),disabled:O,placeholder:"/absolute/path/to/project","aria-invalid":!!Q}),Q&&s.jsx("span",{className:"form-error add-node-modal__error",children:Q})]})]},B.id)})})]})]}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{className:"btn btn-sm",onClick:V,disabled:O,children:o("common.cancel","Cancel")}),s.jsx("button",{className:"btn btn-primary btn-sm","data-testid":"add-node-submit",onClick:q,disabled:O,children:O?o("nodes.adding","Adding..."):o("nodes.addNode","Add Node")})]})]})}):null}function E$(){const[e,t]=f.useState([]),[r,n]=f.useState(!1),[a,i]=f.useState(null),[o,l]=f.useState(!1),[c,d]=f.useState(null),[u,m]=f.useState(!1),h=f.useCallback(async()=>{n(!0),i(null);try{const g=await fetch("/api/docker/contexts");if(!g.ok)throw new Error(`Failed to load Docker contexts (${g.status})`);const p=await g.json();return t(p),p}catch(g){const p=g instanceof Error?g.message:String(g);throw i(p),g}finally{n(!1)}},[]),v=f.useCallback(async g=>{l(!0);try{const p=await fetch("/api/docker/test-connection",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({hostConfig:g})});if(!p.ok)throw new Error(`Failed to test Docker connection (${p.status})`);const b=await p.json();return d(b),b}finally{l(!1)}},[]),y=f.useCallback(async()=>{m(!0);try{const g=await fetch("/api/docker/local-available");if(!g.ok)throw new Error(`Failed to check local Docker availability (${g.status})`);return await g.json()}finally{m(!1)}},[]);return{contexts:e,isLoadingContexts:r,contextsError:a,loadContexts:h,isTestingConnection:o,lastTestResult:c,testConnection:v,isCheckingLocal:u,checkLocalDocker:y}}function _$({value:e,onChange:t}){const{t:r}=le("app"),[n,a]=f.useState(!!(e?.tlsCaPath||e?.tlsCertPath||e?.tlsKeyPath||e?.tlsVerify));f.useEffect(()=>{n||t({tlsVerify:void 0,tlsCaPath:void 0,tlsCertPath:void 0,tlsKeyPath:void 0})},[n,t]);const i=f.useMemo(()=>({tlsVerify:e?.tlsVerify??!0,tlsCaPath:e?.tlsCaPath??"",tlsCertPath:e?.tlsCertPath??"",tlsKeyPath:e?.tlsKeyPath??""}),[e]);return s.jsxs("div",{className:"docker-tls-config",children:[s.jsxs("label",{className:"checkbox-label",children:[s.jsx("input",{type:"checkbox",checked:n,onChange:o=>a(o.target.checked)}),r("docker.useTls","Use TLS")]}),n&&s.jsxs("div",{className:"docker-tls-config__fields",children:[s.jsxs("div",{className:"docker-tls-config__field",children:[s.jsx("label",{htmlFor:"docker-tls-ca-path",children:r("docker.caPath","CA Certificate Path")}),s.jsx("input",{id:"docker-tls-ca-path",className:"input",value:i.tlsCaPath,onChange:o=>t({...i,tlsCaPath:o.target.value}),placeholder:"/etc/docker/ca.pem"})]}),s.jsxs("div",{className:"docker-tls-config__field",children:[s.jsx("label",{htmlFor:"docker-tls-cert-path",children:r("docker.certPath","Client Certificate Path")}),s.jsx("input",{id:"docker-tls-cert-path",className:"input",value:i.tlsCertPath,onChange:o=>t({...i,tlsCertPath:o.target.value}),placeholder:"/etc/docker/cert.pem"})]}),s.jsxs("div",{className:"docker-tls-config__field",children:[s.jsx("label",{htmlFor:"docker-tls-key-path",children:r("docker.keyPath","Client Key Path")}),s.jsx("input",{id:"docker-tls-key-path",className:"input",value:i.tlsKeyPath,onChange:o=>t({...i,tlsKeyPath:o.target.value}),placeholder:"/etc/docker/key.pem"})]}),s.jsxs("label",{className:"checkbox-label",children:[s.jsx("input",{type:"checkbox",checked:i.tlsVerify,onChange:o=>t({...i,tlsVerify:o.target.checked})}),r("docker.verifyTls","Verify TLS Certificate")]})]})]})}function M$({value:e,onChange:t,onError:r}){const{t:n}=le("app"),a=e?.context?"context":e?.host?"host":"local",[i,o]=f.useState(a),[l,c]=f.useState(e?.context??""),[d,u]=f.useState(e?.host??""),[m,h]=f.useState(null),{contexts:v,isLoadingContexts:y,contextsError:g,loadContexts:p,testConnection:b,isTestingConnection:j,lastTestResult:x,checkLocalDocker:C,isCheckingLocal:w}=E$(),P=f.useMemo(()=>({tlsVerify:e?.tlsVerify,tlsCaPath:e?.tlsCaPath,tlsCertPath:e?.tlsCertPath,tlsKeyPath:e?.tlsKeyPath}),[e]);f.useEffect(()=>{if(i==="local"){t({});return}if(i==="context"){p().catch(k=>r?.(k instanceof Error?k.message:String(k))),t(l?{context:l}:{});return}t({host:d,...P})},[i]);const O=f.useCallback(k=>{i==="host"&&t({host:d,...k})},[d,i,t]);return s.jsxs("div",{className:"docker-target-selector",children:[s.jsxs("div",{className:"docker-target-selector__modes",role:"group","aria-label":n("docker.targetMode","Docker target mode"),children:[s.jsx("button",{type:"button",className:`btn btn-sm ${i==="local"?"docker-target-selector__mode-active":""}`,onClick:()=>{o("local"),C().then(k=>{if(k.available){const N=k.version?` (${k.version})`:"";h(n("docker.available","Docker is available{{version}}",{version:N}))}else{const N=k.error?`: ${k.error}`:"";h(n("docker.notFound","Docker not found{{error}}",{error:N}))}}).catch(k=>{const N=k instanceof Error?k.message:String(k);h(n("docker.notFoundError","Docker not found: {{message}}",{message:N})),r?.(N)})},children:n("docker.local","Local Docker")}),s.jsx("button",{type:"button",className:`btn btn-sm ${i==="context"?"docker-target-selector__mode-active":""}`,onClick:()=>o("context"),children:n("docker.context","Docker Context")}),s.jsx("button",{type:"button",className:`btn btn-sm ${i==="host"?"docker-target-selector__mode-active":""}`,onClick:()=>o("host"),children:n("docker.remote","Remote Host")})]}),i==="local"&&m&&s.jsx("div",{className:"docker-target-selector__status",children:m}),i==="context"&&s.jsxs("div",{className:"docker-target-selector__panel",children:[s.jsxs("div",{className:"docker-target-selector__context-row",children:[s.jsxs("select",{className:"select",value:l,onChange:k=>{const N=k.target.value;c(N),t(N?{context:N}:{})},children:[s.jsx("option",{value:"",children:n("docker.selectContext","Select context")}),v.map(k=>s.jsxs("option",{value:k.name,children:[k.name,k.isCurrentContext?" (current)":"",k.dockerHost?` — ${k.dockerHost}`:""]},k.name))]}),s.jsx("button",{type:"button",className:"btn btn-sm btn-icon",onClick:()=>void p(),disabled:y,"aria-label":n("docker.refreshContexts","Refresh contexts"),children:s.jsx(Gr,{size:14})})]}),g&&s.jsx("div",{className:"docker-target-selector__error",children:g})]}),i==="host"&&s.jsxs("div",{className:"docker-target-selector__panel",children:[s.jsxs("div",{className:"docker-target-selector__field",children:[s.jsx("label",{htmlFor:"docker-target-selector-host",children:n("docker.host","Docker Host")}),s.jsx("input",{id:"docker-target-selector-host",className:"input",placeholder:n("docker.hostPlaceholder","tcp://host:2376"),value:d,onChange:k=>{const N=k.target.value;u(N),t({host:N,...P})}})]}),s.jsx(_$,{value:P,onChange:O})]}),s.jsx("button",{type:"button",className:"btn btn-sm",onClick:()=>void b(i==="local"?void 0:i==="context"?{context:l}:{host:d,...P}),disabled:j||w,children:j?n("docker.testing","Testing..."):n("docker.testConnection","Test Connection")}),x&&s.jsx("div",{className:x.success?"docker-target-selector__success":"docker-target-selector__error",children:x.success?n("docker.connected","Connected{{version}}",{version:x.dockerVersion?` (Docker ${x.dockerVersion})`:""}):x.error??n("docker.connectionFailed","Connection failed")})]})}const _o="http://localhost:4040",Qv={readWrite:"rw",readOnly:"ro"};function T$({isOpen:e,onClose:t,onSubmit:r,addToast:n}){const{t:a}=le("app"),[i,o]=f.useState(""),[l,c]=f.useState({}),[d,u]=f.useState(_o),[m,h]=f.useState("auto"),[v,y]=f.useState(""),[g,p]=f.useState(!1),[b,j]=f.useState(!1),[x,C]=f.useState(!0),[w,P]=f.useState(4096),[O,k]=f.useState(2),[N,S]=f.useState(!1),[A,_]=f.useState("runfusion/fusion"),[I,D]=f.useState("latest"),[F,V]=f.useState([]),[U,te]=f.useState([]),[q,ee]=f.useState({}),[L,B]=f.useState(!1),X=f.useCallback(()=>{o(""),c({}),u(_o),h("auto"),y(""),p(!1),j(!1),C(!0),P(4096),k(2),S(!1),_("runfusion/fusion"),D("latest"),V([]),te([]),ee({}),B(!1)},[]),Q=f.useCallback(()=>{L||(X(),t())},[t,X,L]);f.useEffect(()=>{if(!e){X();return}const z=fe=>{fe.key==="Escape"&&(fe.preventDefault(),Q())};return document.addEventListener("keydown",z),()=>document.removeEventListener("keydown",z)},[Q,e,X]);const G=f.useMemo(()=>({nodeId:null,name:i.trim(),imageName:A.trim()||"runfusion/fusion",imageTag:I.trim()||"latest",hostConfig:{context:l.context?.trim()||void 0,host:l.host?.trim()||void 0,tlsVerify:l.tlsVerify,tlsCaPath:l.tlsCaPath?.trim()||void 0,tlsCertPath:l.tlsCertPath?.trim()||void 0,tlsKeyPath:l.tlsKeyPath?.trim()||void 0},envVars:Object.fromEntries(F.map(z=>[z.key.trim(),z.value]).filter(([z])=>!!z)),volumeMounts:U.map(z=>({hostPath:z.hostPath.trim(),containerPath:z.containerPath.trim(),mode:z.mode})).filter(z=>z.hostPath&&z.containerPath),resourceSizing:{memoryMB:w,cpus:O},extraClis:[g?"claude-cli":null,b?"droid-cli":null].filter(Boolean),persistentStorage:x,reachableUrl:d.trim()||null,apiKey:m==="manual"&&v.trim()||null}),[v,m,O,l,F,A,I,g,b,w,U,i,x,d]),ie=f.useCallback(()=>{V(z=>[...z,{key:"",value:""}])},[]),se=f.useCallback((z,fe)=>{V(be=>be.map((ye,nt)=>nt===z?fe:ye))},[]),re=f.useCallback(z=>{V(fe=>fe.filter((be,ye)=>ye!==z))},[]),W=f.useCallback(()=>{te(z=>[...z,{hostPath:"",containerPath:"",mode:"rw"}])},[]),$=f.useCallback((z,fe)=>{te(be=>be.map((ye,nt)=>nt===z?fe:ye))},[]),ne=f.useCallback(z=>{te(fe=>fe.filter((be,ye)=>ye!==z))},[]),we=f.useCallback(async()=>{if(L)return;const z={};if((!G.name||G.name.length>64)&&(z.name=a("docker.errors.nameRequired","Name is required and must be 64 characters or fewer")),G.reachableUrl||(z.reachableUrl=a("docker.errors.urlRequired","URL is required")),w<512&&(z.memoryMB=a("docker.errors.memoryMinimum","Memory must be at least 512 MB")),O<.5&&(z.cpus=a("docker.errors.cpusMinimum","CPUs must be at least 0.5")),ee(z),!(Object.keys(z).length>0)){B(!0);try{await r(G),Q()}catch{}finally{B(!1)}}},[Q,O,G,w,r,L,a]);return e?s.jsx("div",{className:"modal-overlay open",onClick:Q,children:s.jsxs("div",{className:"modal docker-onboarding",role:"dialog","aria-modal":"true","aria-label":a("docker.ariaLabels.modal","Docker node onboarding"),onClick:z=>z.stopPropagation(),children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{children:a("docker.titles.provisionNode","Provision Docker Node")}),s.jsx("button",{className:"modal-close",onClick:Q,disabled:L,"aria-label":a("docker.ariaLabels.closeModal","Close onboarding modal"),children:"×"})]}),s.jsxs("div",{className:"modal-body docker-onboarding__body",children:[s.jsxs("section",{className:"docker-onboarding__section",children:[s.jsx("h4",{className:"docker-onboarding__section-title",children:a("docker.sections.requiredSettings","Required Settings")}),s.jsxs("label",{className:"docker-onboarding__field",children:[s.jsx("span",{children:a("docker.labels.nodeName","Node Name")}),s.jsx("input",{className:"input",value:i,onChange:z=>o(z.target.value),disabled:L,placeholder:a("docker.placeholders.nodeName","my-docker-node"),autoFocus:!0})]}),q.name&&s.jsx("div",{className:"form-error",children:q.name}),s.jsx(M$,{value:l,onChange:c}),s.jsxs("label",{className:"docker-onboarding__field",children:[s.jsx("span",{children:a("docker.labels.reachableUrl","Reachable URL")}),s.jsx("input",{className:"input",value:d,onChange:z=>u(z.target.value),disabled:L,placeholder:_o})]}),q.reachableUrl&&s.jsx("div",{className:"form-error",children:q.reachableUrl}),s.jsxs("div",{className:"docker-onboarding__radio-group",children:[s.jsxs("label",{className:"checkbox-label",children:[s.jsx("input",{type:"radio",checked:m==="auto",onChange:()=>h("auto"),disabled:L}),a("docker.options.autoGenerate","Auto-generate")]}),s.jsxs("label",{className:"checkbox-label",children:[s.jsx("input",{type:"radio",checked:m==="manual",onChange:()=>h("manual"),disabled:L}),a("docker.options.provideManually","Provide manually")]})]}),m==="manual"&&s.jsxs("label",{className:"docker-onboarding__field",children:[s.jsx("span",{children:a("docker.labels.apiKey","API Key")}),s.jsx("input",{className:"input",type:"password",value:v,onChange:z=>y(z.target.value),disabled:L,placeholder:a("docker.placeholders.apiKey","Enter API key")})]}),s.jsxs("div",{className:"docker-onboarding__checkbox-group",children:[s.jsxs("label",{className:"checkbox-label",children:[s.jsx("input",{type:"checkbox",checked:g,onChange:z=>p(z.target.checked),disabled:L}),a("docker.options.claudeCli","Claude CLI")]}),s.jsxs("label",{className:"checkbox-label",children:[s.jsx("input",{type:"checkbox",checked:b,onChange:z=>j(z.target.checked),disabled:L}),a("docker.options.droidCli","Droid CLI")]}),s.jsxs("label",{className:"checkbox-label",children:[s.jsx("input",{type:"checkbox",checked:x,onChange:z=>C(z.target.checked),disabled:L}),a("docker.options.persistentStorage","Keep data across container recreations")]})]}),s.jsxs("div",{className:"docker-onboarding__inline-fields",children:[s.jsxs("label",{className:"docker-onboarding__field",children:[s.jsx("span",{children:a("docker.labels.memory","Memory (MB)")}),s.jsx("input",{className:"input",type:"number",min:512,value:w,onChange:z=>P(Number(z.target.value)),disabled:L})]}),s.jsxs("label",{className:"docker-onboarding__field",children:[s.jsx("span",{children:a("docker.labels.cpus","CPUs")}),s.jsx("input",{className:"input",type:"number",min:.5,step:.5,value:O,onChange:z=>k(Number(z.target.value)),disabled:L})]})]}),q.memoryMB&&s.jsx("div",{className:"form-error",children:q.memoryMB}),q.cpus&&s.jsx("div",{className:"form-error",children:q.cpus})]}),s.jsxs("section",{className:"docker-onboarding__section",children:[s.jsxs("button",{type:"button",className:`docker-onboarding__advanced-toggle ${N?"is-expanded":""}`,onClick:()=>S(z=>!z),disabled:L,children:[s.jsx("span",{children:a("docker.sections.advanced","Advanced")}),s.jsx(xi,{})]}),s.jsx("div",{className:`docker-onboarding__advanced-content ${N?"is-expanded":""}`,children:s.jsxs("div",{children:[s.jsxs("div",{className:"docker-onboarding__inline-fields",children:[s.jsxs("label",{className:"docker-onboarding__field",children:[s.jsx("span",{children:a("docker.labels.image","Image")}),s.jsx("input",{className:"input",value:A,onChange:z=>_(z.target.value),disabled:L,placeholder:a("docker.placeholders.image","runfusion/fusion")})]}),s.jsxs("label",{className:"docker-onboarding__field",children:[s.jsx("span",{children:a("docker.labels.tag","Tag")}),s.jsx("input",{className:"input",value:I,onChange:z=>D(z.target.value),disabled:L,placeholder:a("docker.placeholders.tag","latest")})]})]}),s.jsxs("div",{className:"docker-onboarding__kv-list",children:[s.jsx("h5",{children:a("docker.sections.environmentVariables","Environment Variables")}),F.map((z,fe)=>s.jsxs("div",{className:"docker-onboarding__kv-row docker-onboarding__kv-row--env",children:[s.jsx("input",{className:"input",placeholder:a("docker.placeholders.envVarKey","KEY"),value:z.key,disabled:L,onChange:be=>se(fe,{key:be.target.value,value:z.value})}),s.jsx("input",{className:"input",placeholder:a("docker.placeholders.envVarValue","Value"),value:z.value,disabled:L,onChange:be=>se(fe,{key:z.key,value:be.target.value})}),s.jsx("button",{type:"button",className:"btn btn-icon","aria-label":a("docker.ariaLabels.removeVariable","Remove environment variable"),onClick:()=>re(fe),disabled:L,children:s.jsx(Do,{size:14})})]},`env-${fe}`)),s.jsxs("button",{type:"button",className:"btn btn-sm docker-onboarding__kv-add",onClick:ie,disabled:L,children:[s.jsx(Ea,{size:14}),a("docker.actions.addVariable","Add variable")]})]}),s.jsxs("div",{className:"docker-onboarding__kv-list",children:[s.jsx("h5",{children:a("docker.sections.volumeMounts","Volume Mounts")}),U.map((z,fe)=>s.jsxs("div",{className:"docker-onboarding__kv-row docker-onboarding__kv-row--mount",children:[s.jsx("input",{className:"input",placeholder:a("docker.placeholders.hostPath","Host path"),value:z.hostPath,disabled:L,onChange:be=>$(fe,{hostPath:be.target.value,containerPath:z.containerPath,mode:z.mode})}),s.jsx("input",{className:"input",placeholder:a("docker.placeholders.containerPath","Container path"),value:z.containerPath,disabled:L,onChange:be=>$(fe,{hostPath:z.hostPath,containerPath:be.target.value,mode:z.mode})}),s.jsxs("select",{className:"select",value:z.mode,disabled:L,onChange:be=>$(fe,{hostPath:z.hostPath,containerPath:z.containerPath,mode:be.target.value==="ro"?"ro":"rw"}),children:[s.jsx("option",{value:"rw",children:Qv.readWrite}),s.jsx("option",{value:"ro",children:Qv.readOnly})]}),s.jsx("button",{type:"button",className:"btn btn-icon","aria-label":a("docker.ariaLabels.removeMount","Remove volume mount"),onClick:()=>ne(fe),disabled:L,children:s.jsx(Do,{size:14})})]},`mount-${fe}`)),s.jsxs("button",{type:"button",className:"btn btn-sm docker-onboarding__kv-add",onClick:W,disabled:L,children:[s.jsx(Ea,{size:14}),a("docker.actions.addMount","Add mount")]})]})]})})]})]}),s.jsxs("div",{className:"modal-actions",children:[s.jsx("button",{className:"btn",onClick:Q,disabled:L,children:a("docker.actions.cancel","Cancel")}),s.jsx("button",{className:"btn btn-primary",onClick:()=>void we(),disabled:L,children:L?a("docker.states.creating","Creating..."):a("docker.actions.createNode","Create Docker Node")})]})]})}):null}function I$({nodeId:e,entries:t,loading:r=!1,singleNode:n=!1}){const{t:a}=le("app"),[i,o]=f.useState(!1),[l,c]=f.useState("all"),[d,u]=f.useState("all"),m=f.useCallback(()=>{o(b=>!b)},[]),h=f.useMemo(()=>{const b=new Set;for(const j of t)b.add(j.nodeName);return Array.from(b).sort()},[t]),v=f.useMemo(()=>{let b=[...t];return l!=="all"&&(b=b.filter(j=>j.direction===l)),!n&&d!=="all"&&(b=b.filter(j=>j.nodeName===d)),b.sort((j,x)=>{const C=new Date(j.timestamp).getTime();return new Date(x.timestamp).getTime()-C}),b},[t,l,d,n]),y=f.useCallback(b=>new Date(b).toLocaleString(),[]),g=f.useCallback(b=>{switch(b){case"success":return"settings-sync-log__badge--success";case"conflict":return"settings-sync-log__badge--conflict";case"error":return"settings-sync-log__badge--error";default:return""}},[]),p=f.useCallback(b=>{switch(b){case"success":return a("syncLog.resultSuccess","Success");case"conflict":return a("syncLog.resultConflict","Conflict");case"error":return a("syncLog.resultError","Error");default:return b}},[a]);return s.jsxs("div",{className:"settings-sync-log",children:[s.jsxs("button",{className:"settings-sync-log__header",type:"button",onClick:m,"aria-expanded":i,"data-testid":"settings-sync-log-header",children:[s.jsx(xi,{size:16,className:`settings-sync-log__chevron ${i?"settings-sync-log__chevron--expanded":""}`}),s.jsx("span",{children:a("syncLog.entryCount",{count:t.length,defaultValue_one:"{{count}} entry",defaultValue_other:"{{count}} entries"})})]}),i&&s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"settings-sync-log__filters",children:[s.jsxs("label",{children:[a("syncLog.filterDirection","Direction:"),s.jsxs("select",{value:l,onChange:b=>c(b.target.value),children:[s.jsx("option",{value:"all",children:a("syncLog.filterAll","All")}),s.jsx("option",{value:"push",children:a("syncLog.filterPush","Push")}),s.jsx("option",{value:"pull",children:a("syncLog.filterPull","Pull")})]})]}),!n&&s.jsxs("label",{children:[a("syncLog.filterNode","Node:"),s.jsxs("select",{value:d,onChange:b=>u(b.target.value),children:[s.jsx("option",{value:"all",children:a("syncLog.filterAllNodes","All Nodes")}),h.map(b=>s.jsx("option",{value:b,children:b},b))]})]})]}),r&&t.length===0?s.jsx("div",{className:"settings-sync-log__empty",children:s.jsx(Tl,{label:a("syncLog.loading","Loading...")})}):v.length===0?s.jsx("div",{className:"settings-sync-log__empty",children:a("syncLog.noHistory","No sync history available")}):s.jsx("div",{className:"settings-sync-log__list",children:v.map(b=>s.jsxs("div",{className:"settings-sync-log__entry",children:[s.jsx("span",{className:"settings-sync-log__entry-timestamp",children:y(b.timestamp)}),s.jsx("span",{className:"settings-sync-log__entry-direction",children:b.direction==="push"?s.jsx(bh,{size:14,"data-testid":"upload-icon"}):s.jsx(fh,{size:14,"data-testid":"download-icon"})}),s.jsx("span",{className:`settings-sync-log__entry-result ${g(b.result)}`,children:p(b.result)}),!n&&s.jsx("span",{className:"settings-sync-log__entry-node",children:b.nodeName}),b.details&&s.jsx("span",{className:"settings-sync-log__entry-details",title:b.details,children:sj(b.details??"")})]},b.id))})]})]})}function D$(e,t){const r=typeof e=="string"?e:JSON.stringify(e,null,2),n=typeof t=="string"?t:JSON.stringify(t,null,2);if(r===n)return r;const a=r.split(`
69
69
  `),i=n.split(`
70
70
  `),o=[],l=Math.max(a.length,i.length);for(let c=0;c<l;c++){const d=a[c],u=i[c];d!==void 0&&d!==u&&o.push(`- ${d}`),u!==void 0&&u!==d&&o.push(`+ ${u}`),d!==void 0&&d===u&&o.push(` ${d}`)}return o.join(`
71
- `)}function L$({isOpen:e,onClose:t,onResolve:r,conflicts:n,localNodeName:a,remoteNodeName:i,addToast:o}){const{t:l}=le("app"),[c,d]=f.useState({}),[u,m]=f.useState(!1);f.useEffect(()=>{const b={};for(const j of n)c[j.key]||(b[j.key]={resolution:"local"});Object.keys(b).length>0&&d(j=>({...j,...b}))},[n,c]),f.useEffect(()=>{if(!e)return;const b=j=>{j.key==="Escape"&&(j.preventDefault(),t())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,t]);const h=f.useCallback((b,j)=>{d(x=>{const C=x[b]??{};return j==="manual"?{...x,[b]:{resolution:"manual",manualValue:C.manualValue??JSON.stringify(n.find(w=>w.key===b)?.localValue??null,null,2)}}:{...x,[b]:{resolution:j}}})},[n]),v=f.useCallback((b,j)=>{d(x=>({...x,[b]:{...x[b],resolution:"manual",manualValue:j}}))},[]),y=f.useCallback(b=>{const j={};for(const x of n)j[x.key]={resolution:b};d(j)},[n]),g=f.useCallback(async()=>{m(!0);try{const b=n.map(j=>{const x=c[j.key]??{resolution:"local"};let C;switch(x.resolution){case"remote":C=j.remoteValue;break;case"manual":try{C=JSON.parse(x.manualValue??"null")}catch{C=x.manualValue??null}break;case"local":default:C=j.localValue;break}return{key:j.key,value:C}});await r(b),o(l("settings.resolvedSuccess","Settings conflicts resolved successfully"),"success"),t()}catch(b){const j=b instanceof Error?b.message:l("settings.resolveFailed","Failed to resolve conflicts");o(j,"error")}finally{m(!1)}},[o,n,t,r,c]),p=f.useMemo(()=>{const b={};for(const j of n)b[j.key]=D$(j.localValue,j.remoteValue);return b},[n]);return!e||n.length===0?null:s.jsx("div",{className:"modal-overlay open",onClick:t,children:s.jsxs("div",{className:"modal modal-lg settings-sync-conflict-modal",onClick:b=>b.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":l("settings.conflictModalTitle","Resolve Settings Conflicts"),children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{children:l("settings.conflictModalTitle","Resolve Settings Conflicts")}),s.jsx("button",{className:"modal-close",onClick:t,"aria-label":l("settings.closeModal","Close conflict modal"),children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[s.jsx("div",{className:"settings-sync-conflict-modal__conflict-list",children:n.map(b=>{const j=c[b.key]??{resolution:"local"},x=p[b.key];return s.jsxs("div",{className:"settings-sync-conflict-modal__conflict-item",children:[s.jsx("div",{className:"settings-sync-conflict-modal__key",children:b.key}),s.jsxs("div",{className:"settings-sync-conflict-modal__diff-panel",children:[s.jsxs("div",{className:"settings-sync-conflict-modal__diff-side",children:[s.jsx("div",{className:"settings-sync-conflict-modal__diff-label",children:a}),s.jsx("div",{className:"settings-sync-conflict-modal__diff-content",children:s.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap"},children:x})})]}),s.jsxs("div",{className:"settings-sync-conflict-modal__diff-side",children:[s.jsx("div",{className:"settings-sync-conflict-modal__diff-label",children:i}),s.jsx("div",{className:"settings-sync-conflict-modal__diff-content",children:s.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap"},children:x})})]})]}),s.jsxs("div",{className:"settings-sync-conflict-modal__resolution",children:[s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:`resolution-${b.key}`,checked:j.resolution==="local",onChange:()=>h(b.key,"local")}),l("settings.keepLocal","Keep Local")]}),s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:`resolution-${b.key}`,checked:j.resolution==="remote",onChange:()=>h(b.key,"remote")}),l("settings.keepRemote","Keep Remote")]}),s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:`resolution-${b.key}`,checked:j.resolution==="manual",onChange:()=>h(b.key,"manual")}),l("settings.mergeManually","Merge Manually")]})]}),j.resolution==="manual"&&s.jsx("textarea",{className:"settings-sync-conflict-modal__manual-input",value:j.manualValue??"",onChange:C=>v(b.key,C.target.value),placeholder:l("settings.jsonPlaceholder","Enter JSON value...")})]},b.key)})}),s.jsxs("div",{className:"settings-sync-conflict-modal__bulk-actions",children:[s.jsx("button",{className:"btn btn-sm",onClick:()=>y("local"),type:"button",children:l("settings.resolveAllLocal","Resolve All: Keep Local")}),s.jsx("button",{className:"btn btn-sm",onClick:()=>y("remote"),type:"button",children:l("settings.resolveAllRemote","Resolve All: Keep Remote")})]})]}),s.jsxs("div",{className:"modal-actions settings-sync-conflict-modal__footer",children:[s.jsx("button",{className:"btn btn-sm",onClick:t,children:l("actions.cancel","Cancel")}),s.jsx("button",{className:"btn btn-primary btn-sm",onClick:g,disabled:u,children:u?l("settings.resolving","Resolving..."):l("actions.confirm","Confirm")})]})]})})}const ja={readWrite:"rw",readOnly:"ro",volume:"volume",bind:"bind"},xx=/(KEY|TOKEN|SECRET|PASSWORD)/i;function Mo(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function R$(e){if(!e)return"—";const t=new Date(e),r=Date.now();if(Number.isNaN(t.getTime())||t.getTime()>r)return"—";const n=Math.floor((r-t.getTime())/1e3);if(n<60)return`${n}s`;const a=Math.floor(n/60);if(a<60)return`${a}m`;const i=Math.floor(a/60);return i<24?`${i}h ${a%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function $$(e){switch(e){case"synced":return"node-detail-modal__sync-dot--synced";case"diff":return"node-detail-modal__sync-dot--diff";case"error":return"node-detail-modal__sync-dot--error";case"pending":return"node-detail-modal__sync-dot--pending";case"never-synced":default:return"node-detail-modal__sync-dot--never"}}function B$(e){return e==="running"?"success":e==="creating"||e==="recreating"||e==="restarting"?"warning":"error"}function F$(e){return e?`${e.charAt(0).toUpperCase()}${e.slice(1)}`:"Unknown"}function z$(e){if(!e)return"—";try{const t=new URL(e);return t.port?t.port:t.protocol==="https:"?"443":t.protocol==="http:"?"80":"—"}catch{return"—"}}function K$(e,t){return xx.test(e)?"••••••••":t}function V$({isOpen:e,onClose:t,node:r,projects:n,onUpdate:a,onHealthCheck:i,addToast:o,syncStatus:l,onPushSettings:c,onPullSettings:d,onSyncAuth:u,syncHistory:m=[],onResolveConflicts:h,managedDockerNode:v,containerStatus:y,onFetchContainerStatus:g,onFetchLogs:p,onUpdateDockerConfig:b,onFetchDockerConfigDiff:j}){const{t:x}=le("app"),C=f.useRef(!0),[w,P]=f.useState(!1),[O,k]=f.useState(""),[N,S]=f.useState(""),[A,_]=f.useState(""),[I,D]=f.useState(2),[F,V]=f.useState(!1),[U,te]=f.useState(!1),[q,ee]=f.useState(!1),[L,B]=f.useState(!1),[X,Q]=f.useState(null),[G,ie]=f.useState(!1),[se]=f.useState([]),[re,W]=f.useState(y),[$,ne]=f.useState(!1),[we,z]=f.useState(!1),[fe,be]=f.useState(""),[ye,nt]=f.useState(!1),[ur,E]=f.useState(!1),[T,J]=f.useState(r?.dockerConfig??null),[dt,dr]=f.useState({}),[na,uu]=f.useState(!1),[jx,du]=f.useState(!1);f.useEffect(()=>(C.current=!0,()=>{C.current=!1}),[]),f.useEffect(()=>{W(y)},[y]),f.useEffect(()=>{if(!r||!e){P(!1),z(!1),be("");return}k(r.name),S(r.url??""),_(r.apiKey??""),D(r.maxConcurrent),P(!1),J(r.dockerConfig??null),E(!1),dr({})},[e,r]),f.useEffect(()=>{if(!e)return;const R=ae=>{ae.key==="Escape"&&(ae.preventDefault(),t())};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[e,t]);const ls=f.useMemo(()=>r?oj(n,r):[],[r,n]),wx=f.useMemo(()=>v?v.hostConfig.type==="remote"?v.hostConfig.host??"—":x("nodes.localDocker","Local Docker"):"—",[v,x]),Cx=f.useMemo(()=>!v?.resourceSizing?.cpuLimit&&!v?.resourceSizing?.memoryLimit?x("nodes.dockerResourceDefault","Default"):`${v.resourceSizing?.cpuLimit??x("nodes.dockerDefaultCpu","Default CPU")} / ${v.resourceSizing?.memoryLimit??x("nodes.dockerDefaultMemory","Default memory")}`,[v,x]),kx=f.useCallback(async()=>{if(r)try{if(await i(r.id),!C.current)return;o(x("nodes.healthCheckSuccess","Health check completed for {{name}}",{name:r.name}),"success")}catch(R){if(!C.current)return;const ae=R instanceof Error?R.message:x("nodes.healthCheckFailed","Health check failed");o(ae,"error")}},[o,r,i]),Px=f.useCallback(async()=>{if(!(!r||!c)){Q(null),te(!0);try{if(await c(r.id),!C.current)return;o(x("nodes.pushSettingsSuccess","Settings pushed successfully"),"success")}catch(R){if(!C.current)return;const ae=R instanceof Error?R.message:x("nodes.pushSettingsFailed","Push settings failed");Q(ae),o(ae,"error")}finally{C.current&&te(!1)}}},[o,r,c]),Sx=f.useCallback(async()=>{if(!(!r||!d)){Q(null),ee(!0);try{if(await d(r.id),!C.current)return;o(x("nodes.pullSettingsSuccess","Settings pulled successfully"),"success")}catch(R){if(!C.current)return;const ae=R instanceof Error?R.message:x("nodes.pullSettingsFailed","Pull settings failed");Q(ae),o(ae,"error")}finally{C.current&&ee(!1)}}},[o,r,d]),Nx=f.useCallback(async()=>{if(!(!r||!u)){Q(null),B(!0);try{if(await u(r.id),!C.current)return;o(x("nodes.syncAuthSuccess","Auth credentials synced successfully"),"success")}catch(R){if(!C.current)return;const ae=R instanceof Error?R.message:x("nodes.syncAuthFailed","Auth sync failed");Q(ae),o(ae,"error")}finally{C.current&&B(!1)}}},[o,r,u]),Ox=f.useCallback(()=>{Q(null)},[]),Ax=f.useCallback(async()=>{if(!(!v||!g)){ne(!0);try{const R=await g(v.id);if(!C.current)return;W(R)}catch(R){const ae=R instanceof Error?R.message:x("nodes.fetchContainerStatusFailed","Failed to fetch container status");o(ae,"error")}finally{C.current&&ne(!1)}}},[o,v,g]),Ex=f.useCallback(async()=>{if(!(!v||!p)){z(!0),nt(!0);try{const R=await p(v.id);if(!C.current)return;be(R)}catch(R){if(!C.current)return;be("");const ae=R instanceof Error?R.message:x("nodes.fetchContainerLogsFailed","Failed to fetch container logs");o(ae,"error")}finally{C.current&&nt(!1)}}},[o,v,p]),_x=f.useCallback(async()=>{if(!r||F)return;const R=O.trim();if(!R){o(x("nodes.nameRequired","Name is required"),"error");return}if(r.type==="remote"&&!N.trim()){o(x("nodes.urlRequired","URL is required for remote nodes"),"error");return}if(!Number.isFinite(I)||I<1){o(x("nodes.concurrencyMin","Concurrency must be at least 1"),"error");return}V(!0);try{await a(r.id,{name:R,url:r.type==="remote"&&N.trim()||void 0,apiKey:r.type==="remote"&&A||void 0,maxConcurrent:I}),o(x("nodes.updateSuccess","Updated {{name}}",{name:R}),"success"),P(!1)}catch(ae){const Ye=ae instanceof Error?ae.message:x("nodes.updateFailed","Failed to update node");o(Ye,"error")}finally{V(!1)}},[o,A,F,I,O,r,a,N]);f.useEffect(()=>{!r?.dockerConfig||!j||!e||j(r.id).then(R=>{C.current&&du(R.needsRecreate)}).catch(()=>{C.current&&du(!1)})},[e,r,j]);const Mx=f.useCallback(async()=>{if(!(!r||!T||!b||na)){uu(!0);try{const R=await b(r.id,{image:T.image,volumeMounts:T.volumeMounts,environment:T.environment,resources:T.resources,host:T.host,extraClis:T.extraClis,persistence:T.persistence,containerName:T.containerName});if(!C.current)return;J(R),o(x("nodes.dockerConfigSaveSuccess","Docker config saved"),"success")}catch(R){if(!C.current)return;const ae=R instanceof Error?R.message:x("nodes.dockerConfigSaveFailed","Failed to save Docker config");o(ae,"error")}finally{C.current&&uu(!1)}}},[o,T,na,r,b]),Tx=f.useCallback(()=>{r&&(k(r.name),S(r.url??""),_(r.apiKey??""),D(r.maxConcurrent),P(!1))},[r]);if(!e||!r)return null;const Jt=re?.status??v?.status,Ix=B$(Jt);return s.jsxs("div",{className:"modal-overlay open",onClick:t,children:[s.jsxs("div",{className:"modal modal-lg node-detail-modal",onClick:R=>R.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":x("nodes.modalAriaLabel","Node details for {{name}}",{name:r.name}),children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{children:x("nodes.modalTitle","Node Details")}),s.jsx("button",{className:"modal-close",onClick:t,"aria-label":x("nodes.closeModalAriaLabel","Close node detail modal"),children:"×"})]}),s.jsxs("div",{className:"modal-body node-detail-modal__body",children:[s.jsxs("section",{className:"node-detail-modal__section",children:[s.jsxs("div",{className:"node-detail-modal__section-header",children:[s.jsx("h4",{children:x("nodes.sectionOverview","Overview")}),!w&&s.jsxs("button",{className:"btn btn-sm",onClick:()=>P(!0),children:[s.jsx(lj,{size:14}),x("nodes.editButton","Edit")]})]}),s.jsxs("div",{className:"node-detail-modal__grid",children:[s.jsxs("label",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldName","Name")}),w?s.jsx("input",{className:"input",value:O,onChange:R=>k(R.target.value),disabled:F}):s.jsx("strong",{children:r.name})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldType","Type")}),s.jsx("strong",{children:r.type==="local"?x("nodes.typeLocal","Local"):x("nodes.typeRemote","Remote")})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldStatus","Status")}),s.jsx("strong",{children:r.status})]}),s.jsxs("label",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldMaxConcurrent","Max Concurrent")}),w?s.jsx("input",{className:"input",type:"number",min:1,max:10,value:I,onChange:R=>D(Number(R.target.value)),disabled:F}):s.jsx("strong",{children:r.maxConcurrent})]}),r.type==="remote"&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"node-detail-modal__field node-detail-modal__field--full",children:[s.jsx("span",{children:x("nodes.fieldUrl","URL")}),w?s.jsx("input",{className:"input",value:N,onChange:R=>S(R.target.value),disabled:F}):s.jsx("strong",{children:r.url??"—"})]}),s.jsxs("label",{className:"node-detail-modal__field node-detail-modal__field--full",children:[s.jsx("span",{children:x("nodes.fieldApiKey","API Key")}),w?s.jsx("input",{className:"input",type:"password",value:A,onChange:R=>_(R.target.value),placeholder:x("nodes.apiKeyPlaceholder","Leave blank to keep unchanged"),disabled:F}):s.jsx("strong",{children:r.apiKey?"••••••••":x("nodes.apiKeyNotConfigured","Not configured")})]})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldCreated","Created")}),s.jsx("strong",{children:Mo(r.createdAt)})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldUpdated","Updated")}),s.jsx("strong",{children:Mo(r.updatedAt)})]})]}),w&&s.jsxs("div",{className:"node-detail-modal__edit-actions",children:[s.jsxs("button",{className:"btn btn-primary btn-sm",onClick:_x,disabled:F,children:[s.jsx(pu,{size:14}),F?x("nodes.saving","Saving..."):x("nodes.saveButton","Save")]}),s.jsxs("button",{className:"btn btn-sm",onClick:Tx,disabled:F,children:[s.jsx(wa,{size:14}),x("nodes.cancelButton","Cancel")]})]})]}),s.jsxs("section",{className:"node-detail-modal__section",children:[s.jsxs("h4",{children:[r.type==="local"?x("nodes.sectionProjects","Projects"):x("nodes.sectionAssignedProjects","Assigned Projects")," (",ls.length,")"]}),ls.length===0?s.jsx("p",{className:"node-detail-modal__empty",children:r.type==="local"?x("nodes.noProjectsRunning","No projects are running on this node."):x("nodes.noProjectsAssigned","No projects are assigned to this node.")}):s.jsx("ul",{className:"node-detail-modal__project-list",children:ls.map(R=>s.jsxs("li",{className:"node-detail-modal__project-item",children:[s.jsx("span",{children:R.name}),s.jsx("code",{children:R.id})]},R.id))})]}),s.jsxs("section",{className:"node-detail-modal__section",children:[s.jsx("h4",{children:x("nodes.sectionHealth","Health")}),s.jsxs("div",{className:"node-detail-modal__health-row",children:[s.jsxs("span",{children:[x("nodes.healthStatus","Status:")," ",s.jsx("strong",{children:r.status})]}),s.jsxs("span",{children:[x("nodes.healthLastCheck","Last check:")," ",s.jsx("strong",{children:Mo(r.updatedAt)})]})]})]}),T&&s.jsxs("section",{className:"node-detail-modal__section node-detail-modal__docker-config",children:[s.jsxs("button",{className:"btn btn-sm node-detail-modal__docker-toggle",onClick:()=>E(R=>!R),"aria-expanded":ur,children:[s.jsx(xi,{size:14,className:ur?"node-detail-modal__docker-toggle-icon--expanded":""}),x("nodes.dockerConfiguration","Docker Configuration")]}),ur&&s.jsxs("div",{className:"node-detail-modal__docker-config-content",children:[s.jsx("div",{className:"node-detail-modal__grid",children:s.jsxs("label",{className:"node-detail-modal__field node-detail-modal__field--full",children:[s.jsx("span",{children:x("nodes.dockerFieldImage","Image")}),s.jsx("input",{className:"input",value:T.image,onChange:R=>J({...T,image:R.target.value})})]})}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerVolumeMounts","Volume Mounts")}),s.jsxs("div",{className:"node-detail-modal__docker-list",children:[T.volumeMounts.map((R,ae)=>s.jsxs("div",{className:"node-detail-modal__docker-row",children:[s.jsx("input",{className:"input",value:R.hostPath,placeholder:x("nodes.dockerHostPath","Host path"),onChange:Ye=>{const ce=[...T.volumeMounts];ce[ae]={...ce[ae],hostPath:Ye.target.value},J({...T,volumeMounts:ce})}}),s.jsx("input",{className:"input",value:R.containerPath,placeholder:x("nodes.dockerContainerPath","Container path"),onChange:Ye=>{const ce=[...T.volumeMounts];ce[ae]={...ce[ae],containerPath:Ye.target.value},J({...T,volumeMounts:ce})}}),s.jsxs("select",{className:"input",value:R.mode??"rw",onChange:Ye=>{const ce=[...T.volumeMounts];ce[ae]={...ce[ae],mode:Ye.target.value},J({...T,volumeMounts:ce})},children:[s.jsx("option",{value:"rw",children:ja.readWrite}),s.jsx("option",{value:"ro",children:ja.readOnly})]}),s.jsxs("select",{className:"input",value:R.type??"volume",onChange:Ye=>{const ce=[...T.volumeMounts];ce[ae]={...ce[ae],type:Ye.target.value},J({...T,volumeMounts:ce})},children:[s.jsx("option",{value:"volume",children:ja.volume}),s.jsx("option",{value:"bind",children:ja.bind})]}),s.jsx("button",{className:"btn btn-sm",onClick:()=>J({...T,volumeMounts:T.volumeMounts.filter((Ye,ce)=>ce!==ae)}),children:x("nodes.removeButton","Remove")})]},`${R.hostPath}-${R.containerPath}-${ae}`)),s.jsx("button",{className:"btn btn-sm",onClick:()=>J({...T,volumeMounts:[...T.volumeMounts,{hostPath:"",containerPath:"",mode:"rw",type:"volume"}]}),children:x("nodes.addMountButton","Add Mount")})]})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerEnvVars","Environment Variables")}),s.jsxs("div",{className:"node-detail-modal__docker-list",children:[Object.entries(T.environment).map(([R,ae])=>{const Ye=xx.test(R)&&!dt[R];return s.jsxs("div",{className:"node-detail-modal__docker-row",children:[s.jsx("input",{className:"input",value:R,onChange:ce=>{const cs={...T.environment};delete cs[R],cs[ce.target.value]=ae,J({...T,environment:cs})}}),s.jsx("input",{className:"input",value:Ye?"***":String(ae),onChange:ce=>J({...T,environment:{...T.environment,[R]:ce.target.value}})}),s.jsx("button",{className:"btn btn-sm",onClick:()=>dr(ce=>({...ce,[R]:!ce[R]})),children:dt[R]?s.jsx(cj,{size:14}):s.jsx(uj,{size:14})}),s.jsx("button",{className:"btn btn-sm",onClick:()=>{const ce={...T.environment};delete ce[R],J({...T,environment:ce})},children:x("nodes.removeButton","Remove")})]},R)}),s.jsx("button",{className:"btn btn-sm",onClick:()=>{const R=`NEW_VAR_${Object.keys(T.environment).length+1}`;J({...T,environment:{...T.environment,[R]:""}})},children:x("nodes.addVariableButton","Add Variable")})]})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerResources","Resources")}),s.jsxs("div",{className:"node-detail-modal__docker-stack",children:[s.jsx("input",{className:"input",type:"number",placeholder:x("nodes.dockerMemoryBytes","Memory bytes (2 GB = 2147483648)"),value:T.resources?.memoryBytes??"",onChange:R=>J({...T,resources:{...T.resources,memoryBytes:R.target.value?Number(R.target.value):void 0}})}),s.jsx("input",{className:"input",type:"number",placeholder:x("nodes.dockerCpuCount","CPU count"),value:T.resources?.cpuCount??"",onChange:R=>J({...T,resources:{...T.resources,cpuCount:R.target.value?Number(R.target.value):void 0}})}),s.jsx("input",{className:"input",type:"number",placeholder:x("nodes.dockerPidsLimit","PIDs limit"),value:T.resources?.pidsLimit??"",onChange:R=>J({...T,resources:{...T.resources,pidsLimit:R.target.value?Number(R.target.value):void 0}})})]})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerHostConfig","Host Config")}),s.jsxs("div",{className:"node-detail-modal__docker-stack",children:[s.jsx("input",{className:"input",placeholder:x("nodes.dockerContextName","Context name"),value:T.host?.contextName??"",onChange:R=>J({...T,host:{...T.host,contextName:R.target.value}})}),s.jsx("input",{className:"input",placeholder:x("nodes.dockerHostUrl","Docker host URL"),value:T.host?.dockerHost??"",onChange:R=>J({...T,host:{...T.host,dockerHost:R.target.value}})}),s.jsx("input",{className:"input",placeholder:x("nodes.dockerTlsCaCert","TLS CA cert path"),value:T.host?.tlsCaCert??"",onChange:R=>J({...T,host:{...T.host,tlsCaCert:R.target.value}})}),s.jsx("input",{className:"input",placeholder:x("nodes.dockerTlsCert","TLS cert path"),value:T.host?.tlsCert??"",onChange:R=>J({...T,host:{...T.host,tlsCert:R.target.value}})}),s.jsx("input",{className:"input",placeholder:x("nodes.dockerTlsKey","TLS key path"),value:T.host?.tlsKey??"",onChange:R=>J({...T,host:{...T.host,tlsKey:R.target.value}})}),s.jsxs("label",{className:"node-detail-modal__checkbox",children:[s.jsx("input",{type:"checkbox",checked:T.host?.tlsVerify??!0,onChange:R=>J({...T,host:{...T.host,tlsVerify:R.target.checked}})}),x("nodes.dockerTlsVerify","TLS verify")]})]})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerExtraClis","Extra CLIs")}),s.jsxs("div",{className:"node-detail-modal__docker-list",children:[(T.extraClis??[]).map((R,ae)=>s.jsxs("div",{className:"node-detail-modal__docker-row",children:[s.jsx("input",{className:"input",value:R,onChange:Ye=>{const ce=[...T.extraClis??[]];ce[ae]=Ye.target.value,J({...T,extraClis:ce})}}),s.jsx("button",{className:"btn btn-sm",onClick:()=>J({...T,extraClis:(T.extraClis??[]).filter((Ye,ce)=>ce!==ae)}),children:x("nodes.removeButton","Remove")})]},`${R}-${ae}`)),s.jsx("button",{className:"btn btn-sm",onClick:()=>J({...T,extraClis:[...T.extraClis??[],""]}),children:x("nodes.addCliButton","Add CLI")})]})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerPersistence","Persistence")}),s.jsxs("div",{className:"node-detail-modal__docker-stack",children:[s.jsx("input",{className:"input",placeholder:x("nodes.dockerVolumeName","Volume name"),value:T.persistence?.volumeName??"",onChange:R=>J({...T,persistence:{...T.persistence,volumeName:R.target.value}})}),s.jsxs("label",{className:"node-detail-modal__checkbox",children:[s.jsx("input",{type:"checkbox",checked:T.persistence?.retainOnDelete??!1,onChange:R=>J({...T,persistence:{...T.persistence,retainOnDelete:R.target.checked}})}),x("nodes.dockerRetainOnDelete","Retain on delete")]})]})]}),s.jsxs("div",{className:"node-detail-modal__docker-meta",children:[s.jsx("span",{children:x("nodes.dockerConfigMeta","Config v{{version}} • Updated {{updated}}",{version:T.configVersion,updated:Sl(T.lastUpdated??r.updatedAt)})}),jx&&s.jsx("span",{className:"node-detail-modal__docker-recreate",children:x("nodes.dockerNeedsRecreate","Needs Recreate")})]}),s.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>void Mx(),disabled:na,children:[s.jsx(pu,{size:14}),na?x("nodes.saving","Saving..."):x("nodes.saveDockerConfig","Save Docker Config")]})]})]}),v&&s.jsxs("section",{className:"node-detail-modal__section docker-management",children:[s.jsx("h4",{children:x("nodes.sectionDockerManagement","Docker Management")}),s.jsxs("div",{className:"docker-management__status-card",children:[s.jsxs("div",{className:"docker-management__status-row",children:[s.jsx("span",{className:`docker-management__status-dot docker-management__status-dot--${Ix}`,"aria-hidden":!0}),s.jsx("strong",{children:Jt?F$(Jt):x("nodes.dockerStatusUnknown","Unknown")}),(Jt==="creating"||Jt==="recreating"||Jt==="restarting")&&s.jsx(yu,{size:14,className:"spin","aria-hidden":!0})]}),s.jsxs("div",{className:"docker-management__status-meta",children:[Jt==="running"&&s.jsxs("span",{children:[x("nodes.dockerUptime","Uptime:")," ",R$(re?.startedAt)]}),Jt!=="running"&&re?.exitCode!==void 0&&s.jsxs("span",{children:[x("nodes.dockerExitCode","Exit code:")," ",re.exitCode]}),(re?.error||v.errorMessage)&&s.jsx("span",{children:re?.error??v.errorMessage})]}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void Ax(),disabled:!g||$,children:$?x("nodes.refreshing","Refreshing..."):x("nodes.refreshStatus","Refresh Status")})]}),s.jsxs("div",{className:"node-detail-modal__grid docker-management__info-grid",children:[s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerFieldImage","Image")}),s.jsx("strong",{children:s.jsxs("code",{children:[v.imageName,":",v.imageTag]})})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerContainerId","Container ID")}),s.jsx("strong",{children:s.jsx("code",{children:v.containerId?v.containerId.slice(0,12):"—"})})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerHost","Host")}),s.jsx("strong",{children:wx})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerPersistentStorage","Persistent Storage")}),s.jsx("strong",{children:v.persistentStorage?x("nodes.yes","Yes"):x("nodes.no","No")})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerPort","Port")}),s.jsx("strong",{children:z$(v.reachableUrl)})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerResourceSizing","Resource Sizing")}),s.jsx("strong",{children:Cx})]})]}),s.jsxs("div",{className:"docker-management__actions",children:[s.jsxs("button",{className:"btn btn-sm",disabled:!0,title:x("nodes.availableSoon","Available after FN-3113"),children:[s.jsx(Il,{size:14}),x("nodes.startButton","Start")]}),s.jsxs("button",{className:"btn btn-sm",disabled:!0,title:x("nodes.availableSoon","Available after FN-3113"),children:[s.jsx(dh,{size:14}),x("nodes.stopButton","Stop")]}),s.jsxs("button",{className:"btn btn-sm",disabled:!0,title:x("nodes.availableSoon","Available after FN-3113"),children:[s.jsx(yu,{size:14}),x("nodes.restartButton","Restart")]}),s.jsxs("button",{className:"btn btn-sm",onClick:()=>void Ex(),disabled:!p,children:[s.jsx(dj,{size:14}),x("nodes.viewLogsButton","View Logs")]})]}),we&&s.jsxs("div",{className:"docker-management__log-viewer",children:[s.jsxs("div",{className:"docker-management__log-viewer-header",children:[s.jsx("strong",{children:x("nodes.containerLogs","Container Logs")}),s.jsx("button",{className:"btn-icon",onClick:()=>z(!1),"aria-label":x("nodes.closeLogsAriaLabel","Close logs"),children:s.jsx(wa,{size:14})})]}),ye?s.jsx("p",{children:x("nodes.fetchingLogs","Fetching logs...")}):s.jsx("pre",{children:fe.trim()||x("nodes.noLogsAvailable","No logs available")})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerEnvVars","Environment Variables")}),s.jsx("dl",{className:"docker-management__env-list",children:Object.entries(v.envVars).map(([R,ae])=>s.jsxs("div",{children:[s.jsx("dt",{children:R}),s.jsx("dd",{children:K$(R,ae)})]},R))})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerVolumeMounts","Volume Mounts")}),s.jsx("ul",{className:"docker-management__mounts-list",children:v.volumeMounts.map(R=>s.jsxs("li",{children:[s.jsxs("span",{children:[R.hostPath," → ",R.containerPath]}),R.readOnly&&s.jsx("span",{className:"node-card__type-badge",children:x("nodes.readOnly","Read-only")})]},`${R.hostPath}:${R.containerPath}`))})]})]}),r.type==="remote"&&s.jsxs("section",{className:"node-detail-modal__section",children:[s.jsx("h4",{children:x("nodes.sectionSettingsSync","Settings Sync")}),l&&s.jsxs("div",{className:"node-detail-modal__sync-status",children:[s.jsx("span",{className:`node-detail-modal__sync-dot ${$$(l.syncState)}`,"aria-hidden":!0}),s.jsxs("span",{children:[x("nodes.syncLastSync","Last sync:")," ",s.jsx("strong",{children:l.lastSyncAt?Sl(l.lastSyncAt):x("nodes.syncNeverSynced","Never synced")})]}),l.diffCount>0&&s.jsxs("span",{className:"node-detail-modal__sync-diff",children:[x("nodes.syncDifferences","Differences:")," ",s.jsx("strong",{children:l.diffCount})]})]}),s.jsxs("div",{className:"node-detail-modal__sync-actions",children:[s.jsxs("button",{className:"btn btn-sm",onClick:Px,disabled:U||!c,children:[s.jsx(bh,{size:14}),U?x("nodes.pushing","Pushing..."):x("nodes.pushSettings","Push Settings")]}),s.jsxs("button",{className:"btn btn-sm",onClick:Sx,disabled:q||!d,children:[s.jsx(fh,{size:14}),q?x("nodes.pulling","Pulling..."):x("nodes.pullSettings","Pull Settings")]}),s.jsxs("button",{className:"btn btn-sm",onClick:Nx,disabled:L||!u,children:[s.jsx(ch,{size:14}),L?x("nodes.syncing","Syncing..."):x("nodes.syncAuth","Sync Auth")]})]}),X&&s.jsxs("div",{className:"node-detail-modal__sync-error",children:[s.jsx("span",{children:X}),s.jsx("button",{className:"node-detail-modal__sync-error-dismiss",onClick:Ox,"aria-label":x("nodes.dismissError","Dismiss error"),children:s.jsx(wa,{size:14})})]})]}),r.type==="remote"&&s.jsxs("section",{className:"node-detail-modal__section",children:[s.jsx("h4",{children:x("nodes.sectionSyncHistory","Sync History")}),s.jsx(I$,{nodeId:r.id,entries:m,singleNode:!0})]})]}),s.jsxs("div",{className:"modal-actions node-detail-modal__actions",children:[s.jsxs("button",{className:"btn btn-sm",onClick:kx,children:[s.jsx(uh,{size:14}),x("nodes.healthCheckButton","Health Check")]}),s.jsx("button",{className:"btn btn-sm",onClick:t,children:x("nodes.closeButton","Close")})]})]}),r.type==="remote"&&s.jsx(L$,{isOpen:G,onClose:()=>ie(!1),onResolve:h??(async()=>{}),conflicts:se,localNodeName:x("nodes.localNodeName","Local"),remoteNodeName:r.name,addToast:o})]})}const U$=15e3,q$=1e3;function W$(){const[e,t]=f.useState([]),[r,n]=f.useState(!0),[a,i]=f.useState(null),o=f.useRef(null),l=f.useRef(0),c=f.useRef(e),d=sh();f.useEffect(()=>{c.current=e},[e]);const u=f.useCallback(g=>c.current.length>0&&oh(g,d.wasRecentlyHidden()),[d]),m=f.useCallback(async()=>{try{i(null);const g=await gu();t(g)}catch(g){const p=g instanceof Error?g.message:"Failed to fetch managed Docker nodes";u(p)||i(p)}},[u]);f.useEffect(()=>{let g=!1;async function p(){n(!0);try{const j=await gu();g||(t(j),i(null))}catch(j){const x=j instanceof Error?j.message:"Failed to fetch managed Docker nodes";!g&&!u(x)&&i(x)}finally{g||n(!1)}}p();const b=()=>{if(document.visibilityState!=="visible")return;const j=Date.now(),x=j-l.current;if(x<q$){Aa({view:"useManagedDockerNodes",trigger:"visibility",projectId:void 0,replayAttempted:!1,reason:"debounce-skipped",detail:{timeSinceLastRefreshMs:x}});return}l.current=j,Aa({view:"useManagedDockerNodes",trigger:"visibility",projectId:void 0,replayAttempted:!1,reason:"debounced-refresh"}),m()};return document.addEventListener("visibilitychange",b),()=>{g=!0,document.removeEventListener("visibilitychange",b)}},[m,u]),f.useEffect(()=>{if(!r)return o.current=setInterval(()=>{m()},U$),()=>{o.current&&(clearInterval(o.current),o.current=null)}},[r,m]);const h=f.useCallback(async g=>fj(g),[]),v=f.useCallback(async(g,p)=>(await mj(g,p)).logs,[]),y=f.useCallback(async g=>{const p=await vj(g),b={...p,nodeId:p.nodeId??void 0,containerId:p.containerId??void 0,status:p.status,hostConfig:{type:p.hostConfig.host||p.hostConfig.context?"remote":"local",host:p.hostConfig.host,context:p.hostConfig.context},reachableUrl:p.reachableUrl??void 0,volumeMounts:p.volumeMounts.map(j=>({hostPath:j.hostPath,containerPath:j.containerPath,readOnly:j.mode==="ro"?!0:void 0})),persistentStorage:p.persistentStorage,resourceSizing:{cpuLimit:p.resourceSizing.cpus!==void 0?String(p.resourceSizing.cpus):void 0,memoryLimit:p.resourceSizing.memoryMB!==void 0?`${p.resourceSizing.memoryMB}MB`:void 0},errorMessage:p.errorMessage??void 0};return t(j=>[...j,b]),b},[]);return{dockerNodes:e,loading:r,error:a,refresh:m,getContainerStatus:h,getLogs:v,create:y}}function H$({addToast:e,onClose:t}){const{t:r}=le("app"),{nodes:n,loading:a,error:i,refresh:o,register:l,update:c,unregister:d,healthCheck:u,patchDockerConfig:m,fetchDockerDiff:h,discoverRemoteProjects:v}=ih(),{projects:y,refresh:g}=hj(),{meshState:p,loading:b,error:j}=h$(),{syncStatusMap:x,pushSettings:C,pullSettings:w,syncAuth:P,trackNode:O,getAuthSyncState:k,getAuthProviders:N}=f$(),{dockerNodes:S,loading:A,refresh:_,getContainerStatus:I,getLogs:D,create:F}=W$(),[V,U]=f.useState(!1),[te,q]=f.useState(!1),[ee,L]=f.useState(null);f.useEffect(()=>{const $=n.filter(ne=>ne.type==="remote");for(const ne of $)O(ne.id)},[n,O]),f.useEffect(()=>{if(!ee)return;const $=n.find(ne=>ne.id===ee.id)??null;L($)},[n,ee]);const B=f.useMemo(()=>{const $=n.length,ne=n.filter(ye=>ye.status==="online").length,we=n.filter(ye=>ye.status==="offline"||ye.status==="error").length,z=n.filter(ye=>ye.type==="remote").length,fe=n.filter(ye=>ye.type==="remote"&&x[ye.id]&&Eo(x[ye.id]).syncState==="synced").length,be=S.length;return{total:$,online:ne,offline:we,remote:z,synced:fe,docker:be}},[S.length,n,x]),X=f.useCallback(async $=>{await l($),await g()},[g,l]),Q=f.useCallback(async $=>{try{await F($),e(r("nodes.dockerNodeCreated",'Docker node "{{name}}" created',{name:$.name}),"success"),q(!1)}catch(ne){const we=ne instanceof Error?ne.message:r("nodes.failedCreateDocker","Failed to create Docker node");throw e(we,"error"),ne}},[e,F,r]),G=f.useMemo(()=>{const $=new Map;for(const ne of S)ne.nodeId&&$.set(ne.nodeId,ne);return $},[S]),ie=f.useCallback(async()=>{try{await Promise.all([o(),_()])}catch{e(r("nodes.failedRefresh","Failed to refresh nodes"),"error")}},[e,o,_,r]),se=f.useCallback(async $=>{try{await u($),e(r("nodes.healthCheckComplete","Node health check complete"),"success")}catch(ne){const we=ne instanceof Error?ne.message:r("nodes.healthCheckFailed","Health check failed");e(we,"error")}},[e,u,r]),re=f.useCallback(async $=>{try{await d($),e(r("nodes.removed","Node removed"),"success"),ee?.id===$&&L(null)}catch(ne){const we=ne instanceof Error?ne.message:r("nodes.failedRemove","Failed to remove node");e(we,"error")}},[e,ee?.id,d,r]),W=f.useCallback(async($,ne)=>{await c($,ne)},[c]);return s.jsxs("div",{className:"nodes-view","data-testid":"nodes-view",children:[s.jsxs("div",{className:"nodes-view-header",children:[s.jsxs("div",{className:"nodes-view-title",children:[s.jsxs("h2",{children:[s.jsx(lh,{size:20}),r("nodes.heading","Nodes")]}),s.jsx("span",{className:"nodes-view-count",children:r("nodes.registeredCount","{{count}} registered",{count:n.length})})]}),s.jsxs("div",{className:"nodes-view-actions",children:[t?s.jsx("button",{className:"btn-icon nodes-view-close",onClick:t,"aria-label":r("nodes.closeAriaLabel","Close nodes view"),children:s.jsx(wa,{size:16})}):null,s.jsxs("button",{className:"btn btn-sm",onClick:()=>void ie(),disabled:a||A,children:[s.jsx(Gr,{size:14,className:a?"spin":""}),r("nodes.refresh","Refresh")]}),s.jsxs("button",{className:"btn btn-sm",onClick:()=>U(!0),children:[s.jsx(Ea,{size:14}),r("nodes.addNode","Add Node")]}),s.jsxs("button",{className:"btn btn-sm",onClick:()=>q(!0),title:r("nodes.addDockerNodeTitle","Add a managed Docker node"),children:[s.jsx(Io,{size:14}),r("nodes.addDockerNode","Add Docker Node")]})]})]}),s.jsxs("div",{className:"nodes-view-stats",children:[s.jsxs("div",{className:"nodes-view-stat","data-testid":"nodes-stat-total",children:[s.jsx("span",{children:r("nodes.total","Total")}),s.jsx("strong",{children:B.total})]}),s.jsxs("div",{className:"nodes-view-stat nodes-view-stat--online","data-testid":"nodes-stat-online",children:[s.jsxs("span",{children:[s.jsx(h0,{size:14})," ",r("nodes.online","Online")]}),s.jsx("strong",{children:B.online})]}),s.jsxs("div",{className:"nodes-view-stat nodes-view-stat--offline","data-testid":"nodes-stat-offline",children:[s.jsxs("span",{children:[s.jsx(m0,{size:14})," ",r("nodes.offline","Offline")]}),s.jsx("strong",{children:B.offline})]}),s.jsxs("div",{className:"nodes-view-stat","data-testid":"nodes-stat-remote",children:[s.jsxs("span",{children:[s.jsx(pj,{size:14})," ",r("nodes.remote","Remote")]}),s.jsx("strong",{children:B.remote})]}),s.jsxs("div",{className:"nodes-view-stat nodes-view-stat--synced","data-testid":"nodes-stat-synced",children:[s.jsxs("span",{children:[s.jsx(Gr,{size:14})," ",r("nodes.synced","Synced")]}),s.jsx("strong",{children:B.synced})]}),s.jsxs("div",{className:"nodes-view-stat","data-testid":"nodes-stat-docker",children:[s.jsxs("span",{children:[s.jsx(Io,{size:14})," ",r("nodes.docker","Docker")]}),s.jsx("strong",{children:B.docker})]})]}),(i||j)&&s.jsx("div",{className:"nodes-view-error",children:i??j}),!b&&p.length>0&&s.jsxs("section",{className:"nodes-view-topology","aria-label":r("nodes.meshTopologyAriaLabel","Mesh Topology"),children:[s.jsx("h3",{className:"nodes-view-section-title",children:r("nodes.meshTopology","Mesh Topology")}),s.jsx(N$,{nodes:p})]}),a?s.jsx("div",{className:"nodes-view-grid",children:Array.from({length:4}).map(($,ne)=>s.jsx("div",{className:"node-card node-card--loading","aria-hidden":!0},ne))}):n.length===0?s.jsxs("div",{className:"nodes-view-empty",children:[s.jsx("p",{children:r("nodes.noRegistered","No nodes are registered yet.")}),s.jsxs("button",{className:"btn btn-primary",onClick:()=>U(!0),children:[s.jsx(Ea,{size:14}),r("nodes.addFirstNode","Add First Node")]})]}):s.jsx("div",{className:"nodes-view-grid",children:n.map($=>{const ne=$.type==="remote"&&x[$.id]?Eo(x[$.id]):void 0;return s.jsx(w$,{node:$,projects:y,onHealthCheck:we=>{se(we)},onEdit:we=>L(we),onRemove:we=>{re(we)},isLoading:a,syncStatus:ne,authSyncState:$.type==="remote"?k($.id):void 0,authSyncProviders:$.type==="remote"?N($.id):void 0,managedDockerNode:G.get($.id)},$.id)})}),s.jsx(A$,{isOpen:V,onClose:()=>U(!1),onSubmit:X,onDiscoverRemoteProjects:v,addToast:e,projects:y}),s.jsx(T$,{isOpen:te,onClose:()=>q(!1),onSubmit:Q,addToast:e}),s.jsx(V$,{isOpen:ee!==null,onClose:()=>L(null),node:ee,projects:y,onUpdate:W,onHealthCheck:se,addToast:e,syncStatus:ee?.type==="remote"&&ee&&x[ee.id]?Eo(x[ee.id]):void 0,onPushSettings:C,onPullSettings:w,onSyncAuth:P,managedDockerNode:ee?G.get(ee.id):void 0,onFetchContainerStatus:I,onFetchLogs:D,onUpdateDockerConfig:m,onFetchDockerConfigDiff:h})]})}function G$(){const{t:e}=le("app");return t=>{switch(t){case"triage":return e("commandCenter.funnel.stage.triage","Triage");case"todo":return e("commandCenter.funnel.stage.todo","Todo");case"in-progress":return e("commandCenter.funnel.stage.inProgress","In progress");case"in-review":return e("commandCenter.funnel.stage.inReview","In review");case"done":return e("commandCenter.funnel.stage.done","Done");case"other":return e("commandCenter.funnel.stage.other","Other");default:return t}}}function X$(e){return Number.isFinite(e)?e.toFixed(2):"—"}function Y$({range:e}){const{t}=le("app"),r=G$(),{data:n,isLoading:a,error:i}=Ge("/command-center/activity",e),o=n?.funnel??null,l=f.useMemo(()=>(o?.stages??[]).map(d=>({label:r(d.stage),value:d.entered})),[o?.stages,r]),c=!o||o.stages.every(d=>d.entered===0);return s.jsxs(Pt,{testId:"funnel",isLoading:a,error:i,isEmpty:c,emptyMessage:t("commandCenter.funnel.empty","No task transitions in the selected range."),children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.funnel.title","SDLC funnel")}),s.jsx(bx,{stages:l,ariaLabel:t("commandCenter.funnel.ariaLabel","Tasks per workflow stage")})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.funnel.throughputTitle","Throughput")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card cc-stat-card--gauge","data-testid":"cc-funnel-completion-rate",children:[s.jsx(Oa,{value:o?.completionRate??null,label:t("commandCenter.funnel.completionRate","Completion rate"),ariaLabel:t("commandCenter.funnel.completionRateAria","Completion rate for in-range triage entrants")}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.funnel.completionRateHint","Done ÷ entered (in range)")})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-funnel-throughput",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.funnel.throughputPerDay","Tasks done / day")}),s.jsx("div",{className:"cc-stat-value",children:X$(o?.throughputPerDay??0)}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.funnel.rangeDays","{{count}} day range",{count:o?.rangeDays??0})})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-funnel-done",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.funnel.doneInRange","Reached done")}),s.jsx("div",{className:"cc-stat-value",children:K(o?.doneInRange??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-funnel-entered",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.funnel.enteredInRange","Entered triage")}),s.jsx("div",{className:"cc-stat-value",children:K(o?.enteredInRange??0)})]})]})]})]})}const Z$=8;function J$(e){const{t}=le("app");return[{id:"overview",label:t("commandCenter.tabs.overview","Overview")},{id:"tokens",label:t("commandCenter.tabs.tokens","Tokens")},{id:"tools",label:t("commandCenter.tabs.tools","Tools")},{id:"activity",label:t("commandCenter.tabs.activity","Activity")},{id:"productivity",label:t("commandCenter.tabs.productivity","Productivity")},{id:"team",label:t("commandCenter.tabs.team","Team")},{id:"workflows",label:t("commandCenter.tabs.workflows","Workflows")},{id:"ecosystem",label:t("commandCenter.tabs.ecosystem","Ecosystem")},{id:"github",label:t("commandCenter.tabs.github","GitHub")},{id:"signals",label:t("commandCenter.tabs.signals","Signals")},{id:"system",label:t("commandCenter.tabs.system","System")},...e?[{id:"nodes",label:t("commandCenter.tabs.nodes","Nodes")}]:[],{id:"reliability",label:t("commandCenter.tabs.reliability","Reliability")},{id:"mission-control",label:t("commandCenter.tabs.missionControl","Mission Control")}]}const Q$=15e3;function e2({range:e,projectId:t,colorTheme:r="default",themeMode:n="system",shadcnCustomColors:a={},resolvedThemeMode:i=n==="light"?"light":"dark",onColorThemeChange:o=()=>{},onThemeModeChange:l=()=>{},onShadcnCustomColorsChange:c=()=>{},onChangeView:d}){const{t:u}=le("app"),m=Ge("/command-center/tokens?groupBy=model",e,{pollMs:Q$}),h=Ge("/command-center/tools",e),v=Ge("/command-center/activity",e),y=Ge("/command-center/signals",e),[g,p]=f.useState(null),[b,j]=f.useState(!0);f.useEffect(()=>{let W=!1;return j(!0),(async()=>{try{const $=await _l("/command-center/live");W||p($)}catch{W||p(null)}finally{W||j(!1)}})(),()=>{W=!0}},[]);const x=m.data?.totals?.totalTokens??0,C=h.data?.toolCalls??0,w=v.data?.activeNodes??0,P=v.data?.activeAgents??0,O=v.data?.sessions??0,k=v.data?.agentRuns?.total??0,N=v.data?.funnel?.doneInRange??0,S=g?.columns.find(W=>W.column==="in-progress")?.count??0,A=m.data?.groups?.length??0,_=f.useMemo(()=>[...m.data?.groups??[]].sort((W,$)=>$.totalTokens-W.totalTokens||(W.key??"").localeCompare($.key??"")).slice(0,Z$).map(W=>({label:W.key??u("commandCenter.tokens.unknownModel","(unknown)"),value:W.totalTokens,valueLabel:K(W.totalTokens),iconProvider:Ml(W.key??"")})),[m.data?.groups,u]),I=f.useMemo(()=>[...h.data?.byCategory??[]].sort((W,$)=>$.count-W.count||W.category.localeCompare($.category)).map(W=>({label:W.category,value:W.count,valueLabel:K(W.count)})),[h.data?.byCategory]),D=f.useMemo(()=>_.map(W=>({label:W.label,value:W.value})),[_]),F=f.useMemo(()=>(v.data?.daily??[]).map(W=>W.messages+W.activeAgents+(W.agentRuns??0)),[v.data?.daily]),V=f.useMemo(()=>[{label:u("commandCenter.activity.messages","Messages"),values:(v.data?.daily??[]).map(W=>W.messages)},{label:u("commandCenter.activity.activeAgents","Active agents"),values:(v.data?.daily??[]).map(W=>W.activeAgents)},{label:u("commandCenter.activity.agentRuns","Agent runs"),values:(v.data?.daily??[]).map(W=>W.agentRuns)}],[v.data?.daily,u]),U=F.length>0?F:[O,v.data?.messages??0,P,w,N],te=_.length>0||I.length>0||F.length>0,q=O>0||(v.data?.messages??0)>0||w>0||P>0||k>0||N>0,ee=x>0||C>0||q,B=!(m.data!==null&&h.data!==null&&v.data!==null)&&(m.isLoading||h.isLoading||v.isLoading),X=m.error??h.error??v.error,Q=m.data?Sr(m.data.cost?.usd??null,m.data.cost?.unavailable??!0):"—",G=h.data?h.data.fullyAutonomous?u("commandCenter.tools.ratioAutonomous","{{ratio}} calls/session (fully autonomous)",{ratio:h.data.autonomyRatio.toFixed(1)}):`${h.data.autonomyRatio.toFixed(1)}:1`:"—",ie=[{id:"tokens",label:u("commandCenter.overview.tokensCost","Tokens & cost"),value:K(x),subLabel:Q},{id:"autonomy",label:u("commandCenter.overview.autonomy","Autonomy ratio"),value:G},{id:"agentRuns",label:u("commandCenter.overview.agentRuns","Agent runs"),value:K(k)},{id:"tasksDone",label:u("commandCenter.overview.tasksDone","Tasks done"),value:K(N)},{id:"models",label:u("commandCenter.overview.uniqueModels","Unique models"),value:K(A)},{id:"signals",label:u("commandCenter.overview.openSignals","Open signals"),value:y.isLoading?"—":y.data?K(y.data.open??0):"—"}],se=s.jsx(s.Fragment,{children:s.jsx(l$,{projectId:t,colorTheme:r,themeMode:n,shadcnCustomColors:a,resolvedThemeMode:i,onColorThemeChange:o,onThemeModeChange:l,onShadcnCustomColorsChange:c,onChangeView:d})}),re=s.jsx("div",{className:"cc-overview-throughput","data-testid":"command-center-throughput",children:s.jsx(Y$,{range:e})});return B?s.jsxs("div",{className:"cc-overview",children:[se,s.jsxs("div",{className:"cc-loading","data-testid":"command-center-overview-loading",children:[s.jsx("div",{className:"cc-chart-skeleton"}),s.jsx("p",{children:s.jsx(Tl,{label:u("commandCenter.loading","Loading dashboard...")})})]}),re]}):X!==null&&!ee?s.jsxs("div",{className:"cc-overview",children:[se,s.jsxs("div",{className:"cc-error","data-testid":"command-center-overview-error",role:"alert",children:[s.jsx(gi,{size:24}),s.jsx("p",{children:X})]}),re]}):ee?s.jsxs("div",{className:"cc-overview",children:[se,s.jsx("div",{className:"cc-stat-grid",children:ie.map(W=>s.jsxs("div",{className:"card cc-stat-card","data-testid":`command-center-stat-${W.id}`,children:[s.jsx("div",{className:"cc-stat-label",children:W.label}),s.jsx("div",{className:`cc-stat-value ${W.id==="tokens"?"cc-token-count-live":""}`,children:W.value},W.value),W.subLabel?s.jsx("span",{className:"cc-stat-sub",children:W.subLabel}):null]},W.id))}),s.jsxs("div",{className:"cc-live-strip","data-testid":"command-center-live-strip",children:[s.jsxs("div",{className:"cc-live-strip-heading",children:[s.jsx("span",{className:"status-dot status-dot--connecting","aria-hidden":"true"}),s.jsx("span",{className:"cc-live-strip-label",children:u("commandCenter.overview.liveStrip","Live activity snapshot")})]}),s.jsxs("div",{className:"cc-live-strip-metrics","data-testid":"command-center-live-snapshot",children:[s.jsxs("span",{className:"cc-live-metric","data-testid":"command-center-live-tasks-in-progress",children:[s.jsx("span",{className:"cc-live-metric-value",children:b?"—":K(S)}),s.jsx("span",{className:"cc-live-metric-label",children:u("commandCenter.overview.tasksInProgress","tasks in progress")})]}),s.jsxs("span",{className:"cc-live-metric","data-testid":"command-center-live-agents-working",children:[s.jsx("span",{className:"cc-live-metric-value",children:K(P)}),s.jsx("span",{className:"cc-live-metric-label",children:u("commandCenter.overview.agentsWorking","agents working")})]}),s.jsxs("span",{className:"cc-live-metric","data-testid":"command-center-live-tokens",children:[s.jsx("span",{className:"cc-live-metric-value cc-token-count-live",children:K(x)},x),s.jsx("span",{className:"cc-live-metric-label",children:u("commandCenter.overview.liveTokens","tokens")})]}),s.jsxs("span",{className:"cc-live-metric","data-testid":"command-center-live-open-signals",children:[s.jsx("span",{className:"cc-live-metric-value",children:y.isLoading?"—":y.data?K(y.data.open??0):"—"}),s.jsx("span",{className:"cc-live-metric-label",children:u("commandCenter.overview.openSignals","open signals")})]})]}),s.jsxs("div",{className:"cc-live-trend","data-testid":"command-center-throughput-trend",children:[s.jsx("span",{className:"cc-live-trend-label",children:u("commandCenter.overview.throughputTrend","throughput trend")}),s.jsx(Kt,{values:U,ariaLabel:u("commandCenter.overview.throughputTrendAria","Recent activity throughput trend")})]})]}),te?s.jsxs("section",{className:"cc-overview-charts","data-testid":"command-center-overview-charts",children:[_.length>0?s.jsxs("div",{className:"card cc-overview-chart-card","data-testid":"command-center-overview-chart-tokens",children:[s.jsxs("div",{className:"cc-overview-chart-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:u("commandCenter.overview.tokensByModel","Tokens by model")}),s.jsx("p",{children:u("commandCenter.overview.tokensByModelHint","Top model token consumers in this range")})]}),s.jsx(Ze,{data:_,ariaLabel:u("commandCenter.overview.tokensByModel","Tokens by model")})]}):null,D.length>0?s.jsxs("div",{className:"card cc-overview-chart-card","data-testid":"cc-overview-pie",children:[s.jsxs("div",{className:"cc-overview-chart-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:u("commandCenter.overview.tokensByModelPie","Token share by model")}),s.jsx("p",{children:u("commandCenter.overview.tokensByModelPieHint","Top model token share in this range")})]}),s.jsx(kt,{data:D,ariaLabel:u("commandCenter.overview.tokensByModelPie","Token share by model")})]}):null,I.length>0?s.jsxs("div",{className:"card cc-overview-chart-card","data-testid":"command-center-overview-chart-tools",children:[s.jsxs("div",{className:"cc-overview-chart-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:u("commandCenter.overview.toolCategories","Tool categories")}),s.jsx("p",{children:u("commandCenter.overview.toolCategoriesHint","Autonomous work grouped by tool family")})]}),s.jsx(Ze,{data:I,ariaLabel:u("commandCenter.overview.toolCategories","Tool categories")})]}):null,F.length>0?s.jsxs("div",{className:"card cc-overview-chart-card cc-overview-chart-card--trend","data-testid":"cc-overview-line",children:[s.jsxs("div",{className:"cc-overview-chart-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:u("commandCenter.overview.dailyActivityLine","Daily activity line")}),s.jsx("p",{children:u("commandCenter.overview.dailyActivityLineHint","Messages, agents, and runs by day")})]}),s.jsx(cr,{series:V,ariaLabel:u("commandCenter.overview.dailyActivityLine","Daily activity line")})]}):null,F.length>0?s.jsxs("div",{className:"card cc-overview-chart-card cc-overview-chart-card--trend","data-testid":"command-center-overview-chart-activity",children:[s.jsxs("div",{className:"cc-overview-chart-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:u("commandCenter.overview.dailyActivity","Daily activity trend")}),s.jsx("p",{children:u("commandCenter.overview.dailyActivityHint","Messages plus active agents per day")})]}),s.jsx(Kt,{values:F,ariaLabel:u("commandCenter.overview.dailyActivityAria","Daily activity trend")})]}):null]}):null,re]}):s.jsxs("div",{className:"cc-overview",children:[se,s.jsxs("div",{className:"cc-empty","data-testid":"command-center-empty",children:[s.jsx(bi,{size:28}),s.jsx("p",{children:u("commandCenter.empty","No usage data yet. Run some agents to populate the Dashboard.")})]}),re]})}function t2({tabId:e}){const{t}=le("app");return s.jsxs("div",{className:"cc-empty","data-testid":`command-center-placeholder-${e}`,children:[s.jsx(bi,{size:28}),s.jsx("p",{children:t("commandCenter.areaPending","This area renders once metrics data is available.")})]})}function B2({projectId:e,colorTheme:t="default",themeMode:r="system",shadcnCustomColors:n={},resolvedThemeMode:a=r==="light"?"light":"dark",onColorThemeChange:i=()=>{},onThemeModeChange:o=()=>{},onShadcnCustomColorsChange:l=()=>{},addToast:c=()=>{},nodesEnabled:d=!1,onChangeView:u}={}){const{t:m}=le("app"),h=J$(d),[v,y]=f.useState("overview"),[g,p]=f.useState(()=>Bh($h((w,P)=>P)[1])),b=f.useRef([]),j=f.useCallback(w=>{const P=(w+h.length)%h.length;y(h[P].id),b.current[P]?.focus()},[h]),x=f.useCallback((w,P)=>{switch(w.key){case"ArrowRight":case"ArrowDown":w.preventDefault(),j(P+1);break;case"ArrowLeft":case"ArrowUp":w.preventDefault(),j(P-1);break;case"Home":w.preventDefault(),j(0);break;case"End":w.preventDefault(),j(h.length-1);break;case"Enter":case" ":w.preventDefault(),y(h[P].id);break}},[j,h]);function C(){switch(v){case"overview":return s.jsx(e2,{range:g,projectId:e,colorTheme:t,themeMode:r,shadcnCustomColors:n,resolvedThemeMode:a,onColorThemeChange:i,onThemeModeChange:o,onShadcnCustomColorsChange:l,onChangeView:u});case"tokens":return s.jsx(iR,{range:g});case"tools":return s.jsx(sR,{range:g});case"activity":return s.jsx(bR,{range:g});case"productivity":return s.jsx(xR,{range:g});case"team":return s.jsx(OR,{range:g,projectId:e,addToast:c});case"workflows":return s.jsx(ER,{range:g});case"ecosystem":return s.jsx(_R,{range:g});case"github":return s.jsx(IR,{range:g});case"signals":return s.jsx(DR,{range:g});case"system":return s.jsx(HR,{});case"nodes":return s.jsx(H$,{addToast:c});case"reliability":return s.jsx(c$,{});case"mission-control":return s.jsx(n$,{});default:return s.jsx(t2,{tabId:v})}}return s.jsxs("section",{className:"command-center","data-testid":"command-center",children:[s.jsxs("header",{className:"cc-header",children:[s.jsxs("h2",{className:"cc-title",children:[s.jsx(bi,{size:20}),m("commandCenter.heading","Dashboard")]}),s.jsx(X0,{value:g,onChange:p})]}),s.jsx("div",{className:"cc-tablist",role:"tablist","aria-label":m("commandCenter.tablistLabel","Dashboard sections"),children:h.map((w,P)=>{const O=w.id===v;return s.jsx("button",{ref:k=>{b.current[P]=k},role:"tab",id:`cc-tab-${w.id}`,"aria-selected":O,"aria-controls":`cc-tabpanel-${w.id}`,tabIndex:O?0:-1,className:`cc-tab${O?" active":""}`,onClick:()=>y(w.id),onKeyDown:k=>x(k,P),"data-testid":`command-center-tab-${w.id}`,children:w.label},w.id)})}),s.jsx("div",{role:"tabpanel",id:`cc-tabpanel-${v}`,"aria-labelledby":`cc-tab-${v}`,tabIndex:0,className:"cc-tabpanel","data-testid":`command-center-panel-${v}`,children:C()})]})}export{B2 as CommandCenter};
71
+ `)}function L$({isOpen:e,onClose:t,onResolve:r,conflicts:n,localNodeName:a,remoteNodeName:i,addToast:o}){const{t:l}=le("app"),[c,d]=f.useState({}),[u,m]=f.useState(!1);f.useEffect(()=>{const b={};for(const j of n)c[j.key]||(b[j.key]={resolution:"local"});Object.keys(b).length>0&&d(j=>({...j,...b}))},[n,c]),f.useEffect(()=>{if(!e)return;const b=j=>{j.key==="Escape"&&(j.preventDefault(),t())};return document.addEventListener("keydown",b),()=>document.removeEventListener("keydown",b)},[e,t]);const h=f.useCallback((b,j)=>{d(x=>{const C=x[b]??{};return j==="manual"?{...x,[b]:{resolution:"manual",manualValue:C.manualValue??JSON.stringify(n.find(w=>w.key===b)?.localValue??null,null,2)}}:{...x,[b]:{resolution:j}}})},[n]),v=f.useCallback((b,j)=>{d(x=>({...x,[b]:{...x[b],resolution:"manual",manualValue:j}}))},[]),y=f.useCallback(b=>{const j={};for(const x of n)j[x.key]={resolution:b};d(j)},[n]),g=f.useCallback(async()=>{m(!0);try{const b=n.map(j=>{const x=c[j.key]??{resolution:"local"};let C;switch(x.resolution){case"remote":C=j.remoteValue;break;case"manual":try{C=JSON.parse(x.manualValue??"null")}catch{C=x.manualValue??null}break;case"local":default:C=j.localValue;break}return{key:j.key,value:C}});await r(b),o(l("settings.resolvedSuccess","Settings conflicts resolved successfully"),"success"),t()}catch(b){const j=b instanceof Error?b.message:l("settings.resolveFailed","Failed to resolve conflicts");o(j,"error")}finally{m(!1)}},[o,n,t,r,c]),p=f.useMemo(()=>{const b={};for(const j of n)b[j.key]=D$(j.localValue,j.remoteValue);return b},[n]);return!e||n.length===0?null:s.jsx("div",{className:"modal-overlay open",onClick:t,children:s.jsxs("div",{className:"modal modal-lg settings-sync-conflict-modal",onClick:b=>b.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":l("settings.conflictModalTitle","Resolve Settings Conflicts"),children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{children:l("settings.conflictModalTitle","Resolve Settings Conflicts")}),s.jsx("button",{className:"modal-close",onClick:t,"aria-label":l("settings.closeModal","Close conflict modal"),children:"×"})]}),s.jsxs("div",{className:"modal-body",children:[s.jsx("div",{className:"settings-sync-conflict-modal__conflict-list",children:n.map(b=>{const j=c[b.key]??{resolution:"local"},x=p[b.key];return s.jsxs("div",{className:"settings-sync-conflict-modal__conflict-item",children:[s.jsx("div",{className:"settings-sync-conflict-modal__key",children:b.key}),s.jsxs("div",{className:"settings-sync-conflict-modal__diff-panel",children:[s.jsxs("div",{className:"settings-sync-conflict-modal__diff-side",children:[s.jsx("div",{className:"settings-sync-conflict-modal__diff-label",children:a}),s.jsx("div",{className:"settings-sync-conflict-modal__diff-content",children:s.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap"},children:x})})]}),s.jsxs("div",{className:"settings-sync-conflict-modal__diff-side",children:[s.jsx("div",{className:"settings-sync-conflict-modal__diff-label",children:i}),s.jsx("div",{className:"settings-sync-conflict-modal__diff-content",children:s.jsx("pre",{style:{margin:0,whiteSpace:"pre-wrap"},children:x})})]})]}),s.jsxs("div",{className:"settings-sync-conflict-modal__resolution",children:[s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:`resolution-${b.key}`,checked:j.resolution==="local",onChange:()=>h(b.key,"local")}),l("settings.keepLocal","Keep Local")]}),s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:`resolution-${b.key}`,checked:j.resolution==="remote",onChange:()=>h(b.key,"remote")}),l("settings.keepRemote","Keep Remote")]}),s.jsxs("label",{children:[s.jsx("input",{type:"radio",name:`resolution-${b.key}`,checked:j.resolution==="manual",onChange:()=>h(b.key,"manual")}),l("settings.mergeManually","Merge Manually")]})]}),j.resolution==="manual"&&s.jsx("textarea",{className:"settings-sync-conflict-modal__manual-input",value:j.manualValue??"",onChange:C=>v(b.key,C.target.value),placeholder:l("settings.jsonPlaceholder","Enter JSON value...")})]},b.key)})}),s.jsxs("div",{className:"settings-sync-conflict-modal__bulk-actions",children:[s.jsx("button",{className:"btn btn-sm",onClick:()=>y("local"),type:"button",children:l("settings.resolveAllLocal","Resolve All: Keep Local")}),s.jsx("button",{className:"btn btn-sm",onClick:()=>y("remote"),type:"button",children:l("settings.resolveAllRemote","Resolve All: Keep Remote")})]})]}),s.jsxs("div",{className:"modal-actions settings-sync-conflict-modal__footer",children:[s.jsx("button",{className:"btn btn-sm",onClick:t,children:l("actions.cancel","Cancel")}),s.jsx("button",{className:"btn btn-primary btn-sm",onClick:g,disabled:u,children:u?l("settings.resolving","Resolving..."):l("actions.confirm","Confirm")})]})]})})}const ja={readWrite:"rw",readOnly:"ro",volume:"volume",bind:"bind"},xx=/(KEY|TOKEN|SECRET|PASSWORD)/i;function Mo(e){if(!e)return"—";const t=new Date(e);return Number.isNaN(t.getTime())?"—":t.toLocaleString()}function R$(e){if(!e)return"—";const t=new Date(e),r=Date.now();if(Number.isNaN(t.getTime())||t.getTime()>r)return"—";const n=Math.floor((r-t.getTime())/1e3);if(n<60)return`${n}s`;const a=Math.floor(n/60);if(a<60)return`${a}m`;const i=Math.floor(a/60);return i<24?`${i}h ${a%60}m`:`${Math.floor(i/24)}d ${i%24}h`}function $$(e){switch(e){case"synced":return"node-detail-modal__sync-dot--synced";case"diff":return"node-detail-modal__sync-dot--diff";case"error":return"node-detail-modal__sync-dot--error";case"pending":return"node-detail-modal__sync-dot--pending";case"never-synced":default:return"node-detail-modal__sync-dot--never"}}function B$(e){return e==="running"?"success":e==="creating"||e==="recreating"||e==="restarting"?"warning":"error"}function F$(e){return e?`${e.charAt(0).toUpperCase()}${e.slice(1)}`:"Unknown"}function z$(e){if(!e)return"—";try{const t=new URL(e);return t.port?t.port:t.protocol==="https:"?"443":t.protocol==="http:"?"80":"—"}catch{return"—"}}function K$(e,t){return xx.test(e)?"••••••••":t}function V$({isOpen:e,onClose:t,node:r,projects:n,onUpdate:a,onHealthCheck:i,addToast:o,syncStatus:l,onPushSettings:c,onPullSettings:d,onSyncAuth:u,syncHistory:m=[],onResolveConflicts:h,managedDockerNode:v,containerStatus:y,onFetchContainerStatus:g,onFetchLogs:p,onUpdateDockerConfig:b,onFetchDockerConfigDiff:j}){const{t:x}=le("app"),C=f.useRef(!0),[w,P]=f.useState(!1),[O,k]=f.useState(""),[N,S]=f.useState(""),[A,_]=f.useState(""),[I,D]=f.useState(2),[F,V]=f.useState(!1),[U,te]=f.useState(!1),[q,ee]=f.useState(!1),[L,B]=f.useState(!1),[X,Q]=f.useState(null),[G,ie]=f.useState(!1),[se]=f.useState([]),[re,W]=f.useState(y),[$,ne]=f.useState(!1),[we,z]=f.useState(!1),[fe,be]=f.useState(""),[ye,nt]=f.useState(!1),[ur,E]=f.useState(!1),[T,J]=f.useState(r?.dockerConfig??null),[dt,dr]=f.useState({}),[na,uu]=f.useState(!1),[jx,du]=f.useState(!1);f.useEffect(()=>(C.current=!0,()=>{C.current=!1}),[]),f.useEffect(()=>{W(y)},[y]),f.useEffect(()=>{if(!r||!e){P(!1),z(!1),be("");return}k(r.name),S(r.url??""),_(r.apiKey??""),D(r.maxConcurrent),P(!1),J(r.dockerConfig??null),E(!1),dr({})},[e,r]),f.useEffect(()=>{if(!e)return;const R=ae=>{ae.key==="Escape"&&(ae.preventDefault(),t())};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[e,t]);const ls=f.useMemo(()=>r?oj(n,r):[],[r,n]),wx=f.useMemo(()=>v?v.hostConfig.type==="remote"?v.hostConfig.host??"—":x("nodes.localDocker","Local Docker"):"—",[v,x]),Cx=f.useMemo(()=>!v?.resourceSizing?.cpuLimit&&!v?.resourceSizing?.memoryLimit?x("nodes.dockerResourceDefault","Default"):`${v.resourceSizing?.cpuLimit??x("nodes.dockerDefaultCpu","Default CPU")} / ${v.resourceSizing?.memoryLimit??x("nodes.dockerDefaultMemory","Default memory")}`,[v,x]),kx=f.useCallback(async()=>{if(r)try{if(await i(r.id),!C.current)return;o(x("nodes.healthCheckSuccess","Health check completed for {{name}}",{name:r.name}),"success")}catch(R){if(!C.current)return;const ae=R instanceof Error?R.message:x("nodes.healthCheckFailed","Health check failed");o(ae,"error")}},[o,r,i]),Px=f.useCallback(async()=>{if(!(!r||!c)){Q(null),te(!0);try{if(await c(r.id),!C.current)return;o(x("nodes.pushSettingsSuccess","Settings pushed successfully"),"success")}catch(R){if(!C.current)return;const ae=R instanceof Error?R.message:x("nodes.pushSettingsFailed","Push settings failed");Q(ae),o(ae,"error")}finally{C.current&&te(!1)}}},[o,r,c]),Sx=f.useCallback(async()=>{if(!(!r||!d)){Q(null),ee(!0);try{if(await d(r.id),!C.current)return;o(x("nodes.pullSettingsSuccess","Settings pulled successfully"),"success")}catch(R){if(!C.current)return;const ae=R instanceof Error?R.message:x("nodes.pullSettingsFailed","Pull settings failed");Q(ae),o(ae,"error")}finally{C.current&&ee(!1)}}},[o,r,d]),Nx=f.useCallback(async()=>{if(!(!r||!u)){Q(null),B(!0);try{if(await u(r.id),!C.current)return;o(x("nodes.syncAuthSuccess","Auth credentials synced successfully"),"success")}catch(R){if(!C.current)return;const ae=R instanceof Error?R.message:x("nodes.syncAuthFailed","Auth sync failed");Q(ae),o(ae,"error")}finally{C.current&&B(!1)}}},[o,r,u]),Ox=f.useCallback(()=>{Q(null)},[]),Ax=f.useCallback(async()=>{if(!(!v||!g)){ne(!0);try{const R=await g(v.id);if(!C.current)return;W(R)}catch(R){const ae=R instanceof Error?R.message:x("nodes.fetchContainerStatusFailed","Failed to fetch container status");o(ae,"error")}finally{C.current&&ne(!1)}}},[o,v,g]),Ex=f.useCallback(async()=>{if(!(!v||!p)){z(!0),nt(!0);try{const R=await p(v.id);if(!C.current)return;be(R)}catch(R){if(!C.current)return;be("");const ae=R instanceof Error?R.message:x("nodes.fetchContainerLogsFailed","Failed to fetch container logs");o(ae,"error")}finally{C.current&&nt(!1)}}},[o,v,p]),_x=f.useCallback(async()=>{if(!r||F)return;const R=O.trim();if(!R){o(x("nodes.nameRequired","Name is required"),"error");return}if(r.type==="remote"&&!N.trim()){o(x("nodes.urlRequired","URL is required for remote nodes"),"error");return}if(!Number.isFinite(I)||I<1){o(x("nodes.concurrencyMin","Concurrency must be at least 1"),"error");return}V(!0);try{await a(r.id,{name:R,url:r.type==="remote"&&N.trim()||void 0,apiKey:r.type==="remote"&&A||void 0,maxConcurrent:I}),o(x("nodes.updateSuccess","Updated {{name}}",{name:R}),"success"),P(!1)}catch(ae){const Ye=ae instanceof Error?ae.message:x("nodes.updateFailed","Failed to update node");o(Ye,"error")}finally{V(!1)}},[o,A,F,I,O,r,a,N]);f.useEffect(()=>{!r?.dockerConfig||!j||!e||j(r.id).then(R=>{C.current&&du(R.needsRecreate)}).catch(()=>{C.current&&du(!1)})},[e,r,j]);const Mx=f.useCallback(async()=>{if(!(!r||!T||!b||na)){uu(!0);try{const R=await b(r.id,{image:T.image,volumeMounts:T.volumeMounts,environment:T.environment,resources:T.resources,host:T.host,extraClis:T.extraClis,persistence:T.persistence,containerName:T.containerName});if(!C.current)return;J(R),o(x("nodes.dockerConfigSaveSuccess","Docker config saved"),"success")}catch(R){if(!C.current)return;const ae=R instanceof Error?R.message:x("nodes.dockerConfigSaveFailed","Failed to save Docker config");o(ae,"error")}finally{C.current&&uu(!1)}}},[o,T,na,r,b]),Tx=f.useCallback(()=>{r&&(k(r.name),S(r.url??""),_(r.apiKey??""),D(r.maxConcurrent),P(!1))},[r]);if(!e||!r)return null;const Jt=re?.status??v?.status,Ix=B$(Jt);return s.jsxs("div",{className:"modal-overlay open",onClick:t,children:[s.jsxs("div",{className:"modal modal-lg node-detail-modal",onClick:R=>R.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":x("nodes.modalAriaLabel","Node details for {{name}}",{name:r.name}),children:[s.jsxs("div",{className:"modal-header",children:[s.jsx("h3",{children:x("nodes.modalTitle","Node Details")}),s.jsx("button",{className:"modal-close",onClick:t,"aria-label":x("nodes.closeModalAriaLabel","Close node detail modal"),children:"×"})]}),s.jsxs("div",{className:"modal-body node-detail-modal__body",children:[s.jsxs("section",{className:"node-detail-modal__section",children:[s.jsxs("div",{className:"node-detail-modal__section-header",children:[s.jsx("h4",{children:x("nodes.sectionOverview","Overview")}),!w&&s.jsxs("button",{className:"btn btn-sm",onClick:()=>P(!0),children:[s.jsx(lj,{size:14}),x("nodes.editButton","Edit")]})]}),s.jsxs("div",{className:"node-detail-modal__grid",children:[s.jsxs("label",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldName","Name")}),w?s.jsx("input",{className:"input",value:O,onChange:R=>k(R.target.value),disabled:F}):s.jsx("strong",{children:r.name})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldType","Type")}),s.jsx("strong",{children:r.type==="local"?x("nodes.typeLocal","Local"):x("nodes.typeRemote","Remote")})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldStatus","Status")}),s.jsx("strong",{children:r.status})]}),s.jsxs("label",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldMaxConcurrent","Max Concurrent")}),w?s.jsx("input",{className:"input",type:"number",min:1,max:10,value:I,onChange:R=>D(Number(R.target.value)),disabled:F}):s.jsx("strong",{children:r.maxConcurrent})]}),r.type==="remote"&&s.jsxs(s.Fragment,{children:[s.jsxs("label",{className:"node-detail-modal__field node-detail-modal__field--full",children:[s.jsx("span",{children:x("nodes.fieldUrl","URL")}),w?s.jsx("input",{className:"input",value:N,onChange:R=>S(R.target.value),disabled:F}):s.jsx("strong",{children:r.url??"—"})]}),s.jsxs("label",{className:"node-detail-modal__field node-detail-modal__field--full",children:[s.jsx("span",{children:x("nodes.fieldApiKey","API Key")}),w?s.jsx("input",{className:"input",type:"password",value:A,onChange:R=>_(R.target.value),placeholder:x("nodes.apiKeyPlaceholder","Leave blank to keep unchanged"),disabled:F}):s.jsx("strong",{children:r.apiKey?"••••••••":x("nodes.apiKeyNotConfigured","Not configured")})]})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldCreated","Created")}),s.jsx("strong",{children:Mo(r.createdAt)})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.fieldUpdated","Updated")}),s.jsx("strong",{children:Mo(r.updatedAt)})]})]}),w&&s.jsxs("div",{className:"node-detail-modal__edit-actions",children:[s.jsxs("button",{className:"btn btn-primary btn-sm",onClick:_x,disabled:F,children:[s.jsx(pu,{size:14}),F?x("nodes.saving","Saving..."):x("nodes.saveButton","Save")]}),s.jsxs("button",{className:"btn btn-sm",onClick:Tx,disabled:F,children:[s.jsx(wa,{size:14}),x("nodes.cancelButton","Cancel")]})]})]}),s.jsxs("section",{className:"node-detail-modal__section",children:[s.jsxs("h4",{children:[r.type==="local"?x("nodes.sectionProjects","Projects"):x("nodes.sectionAssignedProjects","Assigned Projects")," (",ls.length,")"]}),ls.length===0?s.jsx("p",{className:"node-detail-modal__empty",children:r.type==="local"?x("nodes.noProjectsRunning","No projects are running on this node."):x("nodes.noProjectsAssigned","No projects are assigned to this node.")}):s.jsx("ul",{className:"node-detail-modal__project-list",children:ls.map(R=>s.jsxs("li",{className:"node-detail-modal__project-item",children:[s.jsx("span",{children:R.name}),s.jsx("code",{children:R.id})]},R.id))})]}),s.jsxs("section",{className:"node-detail-modal__section",children:[s.jsx("h4",{children:x("nodes.sectionHealth","Health")}),s.jsxs("div",{className:"node-detail-modal__health-row",children:[s.jsxs("span",{children:[x("nodes.healthStatus","Status:")," ",s.jsx("strong",{children:r.status})]}),s.jsxs("span",{children:[x("nodes.healthLastCheck","Last check:")," ",s.jsx("strong",{children:Mo(r.updatedAt)})]})]})]}),T&&s.jsxs("section",{className:"node-detail-modal__section node-detail-modal__docker-config",children:[s.jsxs("button",{className:"btn btn-sm node-detail-modal__docker-toggle",onClick:()=>E(R=>!R),"aria-expanded":ur,children:[s.jsx(xi,{size:14,className:ur?"node-detail-modal__docker-toggle-icon--expanded":""}),x("nodes.dockerConfiguration","Docker Configuration")]}),ur&&s.jsxs("div",{className:"node-detail-modal__docker-config-content",children:[s.jsx("div",{className:"node-detail-modal__grid",children:s.jsxs("label",{className:"node-detail-modal__field node-detail-modal__field--full",children:[s.jsx("span",{children:x("nodes.dockerFieldImage","Image")}),s.jsx("input",{className:"input",value:T.image,onChange:R=>J({...T,image:R.target.value})})]})}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerVolumeMounts","Volume Mounts")}),s.jsxs("div",{className:"node-detail-modal__docker-list",children:[T.volumeMounts.map((R,ae)=>s.jsxs("div",{className:"node-detail-modal__docker-row",children:[s.jsx("input",{className:"input",value:R.hostPath,placeholder:x("nodes.dockerHostPath","Host path"),onChange:Ye=>{const ce=[...T.volumeMounts];ce[ae]={...ce[ae],hostPath:Ye.target.value},J({...T,volumeMounts:ce})}}),s.jsx("input",{className:"input",value:R.containerPath,placeholder:x("nodes.dockerContainerPath","Container path"),onChange:Ye=>{const ce=[...T.volumeMounts];ce[ae]={...ce[ae],containerPath:Ye.target.value},J({...T,volumeMounts:ce})}}),s.jsxs("select",{className:"input",value:R.mode??"rw",onChange:Ye=>{const ce=[...T.volumeMounts];ce[ae]={...ce[ae],mode:Ye.target.value},J({...T,volumeMounts:ce})},children:[s.jsx("option",{value:"rw",children:ja.readWrite}),s.jsx("option",{value:"ro",children:ja.readOnly})]}),s.jsxs("select",{className:"input",value:R.type??"volume",onChange:Ye=>{const ce=[...T.volumeMounts];ce[ae]={...ce[ae],type:Ye.target.value},J({...T,volumeMounts:ce})},children:[s.jsx("option",{value:"volume",children:ja.volume}),s.jsx("option",{value:"bind",children:ja.bind})]}),s.jsx("button",{className:"btn btn-sm",onClick:()=>J({...T,volumeMounts:T.volumeMounts.filter((Ye,ce)=>ce!==ae)}),children:x("nodes.removeButton","Remove")})]},`${R.hostPath}-${R.containerPath}-${ae}`)),s.jsx("button",{className:"btn btn-sm",onClick:()=>J({...T,volumeMounts:[...T.volumeMounts,{hostPath:"",containerPath:"",mode:"rw",type:"volume"}]}),children:x("nodes.addMountButton","Add Mount")})]})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerEnvVars","Environment Variables")}),s.jsxs("div",{className:"node-detail-modal__docker-list",children:[Object.entries(T.environment).map(([R,ae])=>{const Ye=xx.test(R)&&!dt[R];return s.jsxs("div",{className:"node-detail-modal__docker-row",children:[s.jsx("input",{className:"input",value:R,onChange:ce=>{const cs={...T.environment};delete cs[R],cs[ce.target.value]=ae,J({...T,environment:cs})}}),s.jsx("input",{className:"input",value:Ye?"***":String(ae),onChange:ce=>J({...T,environment:{...T.environment,[R]:ce.target.value}})}),s.jsx("button",{className:"btn btn-sm",onClick:()=>dr(ce=>({...ce,[R]:!ce[R]})),children:dt[R]?s.jsx(cj,{size:14}):s.jsx(uj,{size:14})}),s.jsx("button",{className:"btn btn-sm",onClick:()=>{const ce={...T.environment};delete ce[R],J({...T,environment:ce})},children:x("nodes.removeButton","Remove")})]},R)}),s.jsx("button",{className:"btn btn-sm",onClick:()=>{const R=`NEW_VAR_${Object.keys(T.environment).length+1}`;J({...T,environment:{...T.environment,[R]:""}})},children:x("nodes.addVariableButton","Add Variable")})]})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerResources","Resources")}),s.jsxs("div",{className:"node-detail-modal__docker-stack",children:[s.jsx("input",{className:"input",type:"number",placeholder:x("nodes.dockerMemoryBytes","Memory bytes (2 GB = 2147483648)"),value:T.resources?.memoryBytes??"",onChange:R=>J({...T,resources:{...T.resources,memoryBytes:R.target.value?Number(R.target.value):void 0}})}),s.jsx("input",{className:"input",type:"number",placeholder:x("nodes.dockerCpuCount","CPU count"),value:T.resources?.cpuCount??"",onChange:R=>J({...T,resources:{...T.resources,cpuCount:R.target.value?Number(R.target.value):void 0}})}),s.jsx("input",{className:"input",type:"number",placeholder:x("nodes.dockerPidsLimit","PIDs limit"),value:T.resources?.pidsLimit??"",onChange:R=>J({...T,resources:{...T.resources,pidsLimit:R.target.value?Number(R.target.value):void 0}})})]})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerHostConfig","Host Config")}),s.jsxs("div",{className:"node-detail-modal__docker-stack",children:[s.jsx("input",{className:"input",placeholder:x("nodes.dockerContextName","Context name"),value:T.host?.contextName??"",onChange:R=>J({...T,host:{...T.host,contextName:R.target.value}})}),s.jsx("input",{className:"input",placeholder:x("nodes.dockerHostUrl","Docker host URL"),value:T.host?.dockerHost??"",onChange:R=>J({...T,host:{...T.host,dockerHost:R.target.value}})}),s.jsx("input",{className:"input",placeholder:x("nodes.dockerTlsCaCert","TLS CA cert path"),value:T.host?.tlsCaCert??"",onChange:R=>J({...T,host:{...T.host,tlsCaCert:R.target.value}})}),s.jsx("input",{className:"input",placeholder:x("nodes.dockerTlsCert","TLS cert path"),value:T.host?.tlsCert??"",onChange:R=>J({...T,host:{...T.host,tlsCert:R.target.value}})}),s.jsx("input",{className:"input",placeholder:x("nodes.dockerTlsKey","TLS key path"),value:T.host?.tlsKey??"",onChange:R=>J({...T,host:{...T.host,tlsKey:R.target.value}})}),s.jsxs("label",{className:"node-detail-modal__checkbox",children:[s.jsx("input",{type:"checkbox",checked:T.host?.tlsVerify??!0,onChange:R=>J({...T,host:{...T.host,tlsVerify:R.target.checked}})}),x("nodes.dockerTlsVerify","TLS verify")]})]})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerExtraClis","Extra CLIs")}),s.jsxs("div",{className:"node-detail-modal__docker-list",children:[(T.extraClis??[]).map((R,ae)=>s.jsxs("div",{className:"node-detail-modal__docker-row",children:[s.jsx("input",{className:"input",value:R,onChange:Ye=>{const ce=[...T.extraClis??[]];ce[ae]=Ye.target.value,J({...T,extraClis:ce})}}),s.jsx("button",{className:"btn btn-sm",onClick:()=>J({...T,extraClis:(T.extraClis??[]).filter((Ye,ce)=>ce!==ae)}),children:x("nodes.removeButton","Remove")})]},`${R}-${ae}`)),s.jsx("button",{className:"btn btn-sm",onClick:()=>J({...T,extraClis:[...T.extraClis??[],""]}),children:x("nodes.addCliButton","Add CLI")})]})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerPersistence","Persistence")}),s.jsxs("div",{className:"node-detail-modal__docker-stack",children:[s.jsx("input",{className:"input",placeholder:x("nodes.dockerVolumeName","Volume name"),value:T.persistence?.volumeName??"",onChange:R=>J({...T,persistence:{...T.persistence,volumeName:R.target.value}})}),s.jsxs("label",{className:"node-detail-modal__checkbox",children:[s.jsx("input",{type:"checkbox",checked:T.persistence?.retainOnDelete??!1,onChange:R=>J({...T,persistence:{...T.persistence,retainOnDelete:R.target.checked}})}),x("nodes.dockerRetainOnDelete","Retain on delete")]})]})]}),s.jsxs("div",{className:"node-detail-modal__docker-meta",children:[s.jsx("span",{children:x("nodes.dockerConfigMeta","Config v{{version}} • Updated {{updated}}",{version:T.configVersion,updated:Sl(T.lastUpdated??r.updatedAt)})}),jx&&s.jsx("span",{className:"node-detail-modal__docker-recreate",children:x("nodes.dockerNeedsRecreate","Needs Recreate")})]}),s.jsxs("button",{className:"btn btn-primary btn-sm",onClick:()=>void Mx(),disabled:na,children:[s.jsx(pu,{size:14}),na?x("nodes.saving","Saving..."):x("nodes.saveDockerConfig","Save Docker Config")]})]})]}),v&&s.jsxs("section",{className:"node-detail-modal__section docker-management",children:[s.jsx("h4",{children:x("nodes.sectionDockerManagement","Docker Management")}),s.jsxs("div",{className:"docker-management__status-card",children:[s.jsxs("div",{className:"docker-management__status-row",children:[s.jsx("span",{className:`docker-management__status-dot docker-management__status-dot--${Ix}`,"aria-hidden":!0}),s.jsx("strong",{children:Jt?F$(Jt):x("nodes.dockerStatusUnknown","Unknown")}),(Jt==="creating"||Jt==="recreating"||Jt==="restarting")&&s.jsx(yu,{size:14,className:"spin","aria-hidden":!0})]}),s.jsxs("div",{className:"docker-management__status-meta",children:[Jt==="running"&&s.jsxs("span",{children:[x("nodes.dockerUptime","Uptime:")," ",R$(re?.startedAt)]}),Jt!=="running"&&re?.exitCode!==void 0&&s.jsxs("span",{children:[x("nodes.dockerExitCode","Exit code:")," ",re.exitCode]}),(re?.error||v.errorMessage)&&s.jsx("span",{children:re?.error??v.errorMessage})]}),s.jsx("button",{className:"btn btn-sm",onClick:()=>void Ax(),disabled:!g||$,children:$?x("nodes.refreshing","Refreshing..."):x("nodes.refreshStatus","Refresh Status")})]}),s.jsxs("div",{className:"node-detail-modal__grid docker-management__info-grid",children:[s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerFieldImage","Image")}),s.jsx("strong",{children:s.jsxs("code",{children:[v.imageName,":",v.imageTag]})})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerContainerId","Container ID")}),s.jsx("strong",{children:s.jsx("code",{children:v.containerId?v.containerId.slice(0,12):"—"})})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerHostLabel","Host")}),s.jsx("strong",{children:wx})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerPersistentStorage","Persistent Storage")}),s.jsx("strong",{children:v.persistentStorage?x("nodes.yes","Yes"):x("nodes.no","No")})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerPort","Port")}),s.jsx("strong",{children:z$(v.reachableUrl)})]}),s.jsxs("div",{className:"node-detail-modal__field",children:[s.jsx("span",{children:x("nodes.dockerResourceSizing","Resource Sizing")}),s.jsx("strong",{children:Cx})]})]}),s.jsxs("div",{className:"docker-management__actions",children:[s.jsxs("button",{className:"btn btn-sm",disabled:!0,title:x("nodes.availableSoon","Available after FN-3113"),children:[s.jsx(Il,{size:14}),x("nodes.startButton","Start")]}),s.jsxs("button",{className:"btn btn-sm",disabled:!0,title:x("nodes.availableSoon","Available after FN-3113"),children:[s.jsx(dh,{size:14}),x("nodes.stopButton","Stop")]}),s.jsxs("button",{className:"btn btn-sm",disabled:!0,title:x("nodes.availableSoon","Available after FN-3113"),children:[s.jsx(yu,{size:14}),x("nodes.restartButton","Restart")]}),s.jsxs("button",{className:"btn btn-sm",onClick:()=>void Ex(),disabled:!p,children:[s.jsx(dj,{size:14}),x("nodes.viewLogsButton","View Logs")]})]}),we&&s.jsxs("div",{className:"docker-management__log-viewer",children:[s.jsxs("div",{className:"docker-management__log-viewer-header",children:[s.jsx("strong",{children:x("nodes.containerLogs","Container Logs")}),s.jsx("button",{className:"btn-icon",onClick:()=>z(!1),"aria-label":x("nodes.closeLogsAriaLabel","Close logs"),children:s.jsx(wa,{size:14})})]}),ye?s.jsx("p",{children:x("nodes.fetchingLogs","Fetching logs...")}):s.jsx("pre",{children:fe.trim()||x("nodes.noLogsAvailable","No logs available")})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerEnvVars","Environment Variables")}),s.jsx("dl",{className:"docker-management__env-list",children:Object.entries(v.envVars).map(([R,ae])=>s.jsxs("div",{children:[s.jsx("dt",{children:R}),s.jsx("dd",{children:K$(R,ae)})]},R))})]}),s.jsxs("details",{children:[s.jsx("summary",{children:x("nodes.dockerVolumeMounts","Volume Mounts")}),s.jsx("ul",{className:"docker-management__mounts-list",children:v.volumeMounts.map(R=>s.jsxs("li",{children:[s.jsxs("span",{children:[R.hostPath," → ",R.containerPath]}),R.readOnly&&s.jsx("span",{className:"node-card__type-badge",children:x("nodes.readOnly","Read-only")})]},`${R.hostPath}:${R.containerPath}`))})]})]}),r.type==="remote"&&s.jsxs("section",{className:"node-detail-modal__section",children:[s.jsx("h4",{children:x("nodes.sectionSettingsSync","Settings Sync")}),l&&s.jsxs("div",{className:"node-detail-modal__sync-status",children:[s.jsx("span",{className:`node-detail-modal__sync-dot ${$$(l.syncState)}`,"aria-hidden":!0}),s.jsxs("span",{children:[x("nodes.syncLastSync","Last sync:")," ",s.jsx("strong",{children:l.lastSyncAt?Sl(l.lastSyncAt):x("nodes.syncNeverSynced","Never synced")})]}),l.diffCount>0&&s.jsxs("span",{className:"node-detail-modal__sync-diff",children:[x("nodes.syncDifferences","Differences:")," ",s.jsx("strong",{children:l.diffCount})]})]}),s.jsxs("div",{className:"node-detail-modal__sync-actions",children:[s.jsxs("button",{className:"btn btn-sm",onClick:Px,disabled:U||!c,children:[s.jsx(bh,{size:14}),U?x("nodes.pushing","Pushing..."):x("nodes.pushSettings","Push Settings")]}),s.jsxs("button",{className:"btn btn-sm",onClick:Sx,disabled:q||!d,children:[s.jsx(fh,{size:14}),q?x("nodes.pulling","Pulling..."):x("nodes.pullSettings","Pull Settings")]}),s.jsxs("button",{className:"btn btn-sm",onClick:Nx,disabled:L||!u,children:[s.jsx(ch,{size:14}),L?x("nodes.syncing","Syncing..."):x("nodes.syncAuth","Sync Auth")]})]}),X&&s.jsxs("div",{className:"node-detail-modal__sync-error",children:[s.jsx("span",{children:X}),s.jsx("button",{className:"node-detail-modal__sync-error-dismiss",onClick:Ox,"aria-label":x("nodes.dismissError","Dismiss error"),children:s.jsx(wa,{size:14})})]})]}),r.type==="remote"&&s.jsxs("section",{className:"node-detail-modal__section",children:[s.jsx("h4",{children:x("nodes.sectionSyncHistory","Sync History")}),s.jsx(I$,{nodeId:r.id,entries:m,singleNode:!0})]})]}),s.jsxs("div",{className:"modal-actions node-detail-modal__actions",children:[s.jsxs("button",{className:"btn btn-sm",onClick:kx,children:[s.jsx(uh,{size:14}),x("nodes.healthCheckButton","Health Check")]}),s.jsx("button",{className:"btn btn-sm",onClick:t,children:x("nodes.closeButton","Close")})]})]}),r.type==="remote"&&s.jsx(L$,{isOpen:G,onClose:()=>ie(!1),onResolve:h??(async()=>{}),conflicts:se,localNodeName:x("nodes.localNodeName","Local"),remoteNodeName:r.name,addToast:o})]})}const U$=15e3,q$=1e3;function W$(){const[e,t]=f.useState([]),[r,n]=f.useState(!0),[a,i]=f.useState(null),o=f.useRef(null),l=f.useRef(0),c=f.useRef(e),d=sh();f.useEffect(()=>{c.current=e},[e]);const u=f.useCallback(g=>c.current.length>0&&oh(g,d.wasRecentlyHidden()),[d]),m=f.useCallback(async()=>{try{i(null);const g=await gu();t(g)}catch(g){const p=g instanceof Error?g.message:"Failed to fetch managed Docker nodes";u(p)||i(p)}},[u]);f.useEffect(()=>{let g=!1;async function p(){n(!0);try{const j=await gu();g||(t(j),i(null))}catch(j){const x=j instanceof Error?j.message:"Failed to fetch managed Docker nodes";!g&&!u(x)&&i(x)}finally{g||n(!1)}}p();const b=()=>{if(document.visibilityState!=="visible")return;const j=Date.now(),x=j-l.current;if(x<q$){Aa({view:"useManagedDockerNodes",trigger:"visibility",projectId:void 0,replayAttempted:!1,reason:"debounce-skipped",detail:{timeSinceLastRefreshMs:x}});return}l.current=j,Aa({view:"useManagedDockerNodes",trigger:"visibility",projectId:void 0,replayAttempted:!1,reason:"debounced-refresh"}),m()};return document.addEventListener("visibilitychange",b),()=>{g=!0,document.removeEventListener("visibilitychange",b)}},[m,u]),f.useEffect(()=>{if(!r)return o.current=setInterval(()=>{m()},U$),()=>{o.current&&(clearInterval(o.current),o.current=null)}},[r,m]);const h=f.useCallback(async g=>fj(g),[]),v=f.useCallback(async(g,p)=>(await mj(g,p)).logs,[]),y=f.useCallback(async g=>{const p=await vj(g),b={...p,nodeId:p.nodeId??void 0,containerId:p.containerId??void 0,status:p.status,hostConfig:{type:p.hostConfig.host||p.hostConfig.context?"remote":"local",host:p.hostConfig.host,context:p.hostConfig.context},reachableUrl:p.reachableUrl??void 0,volumeMounts:p.volumeMounts.map(j=>({hostPath:j.hostPath,containerPath:j.containerPath,readOnly:j.mode==="ro"?!0:void 0})),persistentStorage:p.persistentStorage,resourceSizing:{cpuLimit:p.resourceSizing.cpus!==void 0?String(p.resourceSizing.cpus):void 0,memoryLimit:p.resourceSizing.memoryMB!==void 0?`${p.resourceSizing.memoryMB}MB`:void 0},errorMessage:p.errorMessage??void 0};return t(j=>[...j,b]),b},[]);return{dockerNodes:e,loading:r,error:a,refresh:m,getContainerStatus:h,getLogs:v,create:y}}function H$({addToast:e,onClose:t}){const{t:r}=le("app"),{nodes:n,loading:a,error:i,refresh:o,register:l,update:c,unregister:d,healthCheck:u,patchDockerConfig:m,fetchDockerDiff:h,discoverRemoteProjects:v}=ih(),{projects:y,refresh:g}=hj(),{meshState:p,loading:b,error:j}=h$(),{syncStatusMap:x,pushSettings:C,pullSettings:w,syncAuth:P,trackNode:O,getAuthSyncState:k,getAuthProviders:N}=f$(),{dockerNodes:S,loading:A,refresh:_,getContainerStatus:I,getLogs:D,create:F}=W$(),[V,U]=f.useState(!1),[te,q]=f.useState(!1),[ee,L]=f.useState(null);f.useEffect(()=>{const $=n.filter(ne=>ne.type==="remote");for(const ne of $)O(ne.id)},[n,O]),f.useEffect(()=>{if(!ee)return;const $=n.find(ne=>ne.id===ee.id)??null;L($)},[n,ee]);const B=f.useMemo(()=>{const $=n.length,ne=n.filter(ye=>ye.status==="online").length,we=n.filter(ye=>ye.status==="offline"||ye.status==="error").length,z=n.filter(ye=>ye.type==="remote").length,fe=n.filter(ye=>ye.type==="remote"&&x[ye.id]&&Eo(x[ye.id]).syncState==="synced").length,be=S.length;return{total:$,online:ne,offline:we,remote:z,synced:fe,docker:be}},[S.length,n,x]),X=f.useCallback(async $=>{await l($),await g()},[g,l]),Q=f.useCallback(async $=>{try{await F($),e(r("nodes.dockerNodeCreated",'Docker node "{{name}}" created',{name:$.name}),"success"),q(!1)}catch(ne){const we=ne instanceof Error?ne.message:r("nodes.failedCreateDocker","Failed to create Docker node");throw e(we,"error"),ne}},[e,F,r]),G=f.useMemo(()=>{const $=new Map;for(const ne of S)ne.nodeId&&$.set(ne.nodeId,ne);return $},[S]),ie=f.useCallback(async()=>{try{await Promise.all([o(),_()])}catch{e(r("nodes.failedRefresh","Failed to refresh nodes"),"error")}},[e,o,_,r]),se=f.useCallback(async $=>{try{await u($),e(r("nodes.healthCheckComplete","Node health check complete"),"success")}catch(ne){const we=ne instanceof Error?ne.message:r("nodes.healthCheckFailed","Health check failed");e(we,"error")}},[e,u,r]),re=f.useCallback(async $=>{try{await d($),e(r("nodes.removed","Node removed"),"success"),ee?.id===$&&L(null)}catch(ne){const we=ne instanceof Error?ne.message:r("nodes.failedRemove","Failed to remove node");e(we,"error")}},[e,ee?.id,d,r]),W=f.useCallback(async($,ne)=>{await c($,ne)},[c]);return s.jsxs("div",{className:"nodes-view","data-testid":"nodes-view",children:[s.jsxs("div",{className:"nodes-view-header",children:[s.jsxs("div",{className:"nodes-view-title",children:[s.jsxs("h2",{children:[s.jsx(lh,{size:20}),r("nodes.heading","Nodes")]}),s.jsx("span",{className:"nodes-view-count",children:r("nodes.registeredCount","{{count}} registered",{count:n.length})})]}),s.jsxs("div",{className:"nodes-view-actions",children:[t?s.jsx("button",{className:"btn-icon nodes-view-close",onClick:t,"aria-label":r("nodes.closeAriaLabel","Close nodes view"),children:s.jsx(wa,{size:16})}):null,s.jsxs("button",{className:"btn btn-sm",onClick:()=>void ie(),disabled:a||A,children:[s.jsx(Gr,{size:14,className:a?"spin":""}),r("nodes.refresh","Refresh")]}),s.jsxs("button",{className:"btn btn-sm",onClick:()=>U(!0),children:[s.jsx(Ea,{size:14}),r("nodes.addNode","Add Node")]}),s.jsxs("button",{className:"btn btn-sm",onClick:()=>q(!0),title:r("nodes.addDockerNodeTitle","Add a managed Docker node"),children:[s.jsx(Io,{size:14}),r("nodes.addDockerNode","Add Docker Node")]})]})]}),s.jsxs("div",{className:"nodes-view-stats",children:[s.jsxs("div",{className:"nodes-view-stat","data-testid":"nodes-stat-total",children:[s.jsx("span",{children:r("nodes.total","Total")}),s.jsx("strong",{children:B.total})]}),s.jsxs("div",{className:"nodes-view-stat nodes-view-stat--online","data-testid":"nodes-stat-online",children:[s.jsxs("span",{children:[s.jsx(h0,{size:14})," ",r("nodes.online","Online")]}),s.jsx("strong",{children:B.online})]}),s.jsxs("div",{className:"nodes-view-stat nodes-view-stat--offline","data-testid":"nodes-stat-offline",children:[s.jsxs("span",{children:[s.jsx(m0,{size:14})," ",r("nodes.offline","Offline")]}),s.jsx("strong",{children:B.offline})]}),s.jsxs("div",{className:"nodes-view-stat","data-testid":"nodes-stat-remote",children:[s.jsxs("span",{children:[s.jsx(pj,{size:14})," ",r("nodes.remote","Remote")]}),s.jsx("strong",{children:B.remote})]}),s.jsxs("div",{className:"nodes-view-stat nodes-view-stat--synced","data-testid":"nodes-stat-synced",children:[s.jsxs("span",{children:[s.jsx(Gr,{size:14})," ",r("nodes.synced","Synced")]}),s.jsx("strong",{children:B.synced})]}),s.jsxs("div",{className:"nodes-view-stat","data-testid":"nodes-stat-docker",children:[s.jsxs("span",{children:[s.jsx(Io,{size:14})," ",r("nodes.docker","Docker")]}),s.jsx("strong",{children:B.docker})]})]}),(i||j)&&s.jsx("div",{className:"nodes-view-error",children:i??j}),!b&&p.length>0&&s.jsxs("section",{className:"nodes-view-topology","aria-label":r("nodes.meshTopologyAriaLabel","Mesh Topology"),children:[s.jsx("h3",{className:"nodes-view-section-title",children:r("nodes.meshTopology","Mesh Topology")}),s.jsx(N$,{nodes:p})]}),a?s.jsx("div",{className:"nodes-view-grid",children:Array.from({length:4}).map(($,ne)=>s.jsx("div",{className:"node-card node-card--loading","aria-hidden":!0},ne))}):n.length===0?s.jsxs("div",{className:"nodes-view-empty",children:[s.jsx("p",{children:r("nodes.noRegistered","No nodes are registered yet.")}),s.jsxs("button",{className:"btn btn-primary",onClick:()=>U(!0),children:[s.jsx(Ea,{size:14}),r("nodes.addFirstNode","Add First Node")]})]}):s.jsx("div",{className:"nodes-view-grid",children:n.map($=>{const ne=$.type==="remote"&&x[$.id]?Eo(x[$.id]):void 0;return s.jsx(w$,{node:$,projects:y,onHealthCheck:we=>{se(we)},onEdit:we=>L(we),onRemove:we=>{re(we)},isLoading:a,syncStatus:ne,authSyncState:$.type==="remote"?k($.id):void 0,authSyncProviders:$.type==="remote"?N($.id):void 0,managedDockerNode:G.get($.id)},$.id)})}),s.jsx(A$,{isOpen:V,onClose:()=>U(!1),onSubmit:X,onDiscoverRemoteProjects:v,addToast:e,projects:y}),s.jsx(T$,{isOpen:te,onClose:()=>q(!1),onSubmit:Q,addToast:e}),s.jsx(V$,{isOpen:ee!==null,onClose:()=>L(null),node:ee,projects:y,onUpdate:W,onHealthCheck:se,addToast:e,syncStatus:ee?.type==="remote"&&ee&&x[ee.id]?Eo(x[ee.id]):void 0,onPushSettings:C,onPullSettings:w,onSyncAuth:P,managedDockerNode:ee?G.get(ee.id):void 0,onFetchContainerStatus:I,onFetchLogs:D,onUpdateDockerConfig:m,onFetchDockerConfigDiff:h})]})}function G$(){const{t:e}=le("app");return t=>{switch(t){case"triage":return e("commandCenter.funnel.stage.triage","Triage");case"todo":return e("commandCenter.funnel.stage.todo","Todo");case"in-progress":return e("commandCenter.funnel.stage.inProgress","In progress");case"in-review":return e("commandCenter.funnel.stage.inReview","In review");case"done":return e("commandCenter.funnel.stage.done","Done");case"other":return e("commandCenter.funnel.stage.other","Other");default:return t}}}function X$(e){return Number.isFinite(e)?e.toFixed(2):"—"}function Y$({range:e}){const{t}=le("app"),r=G$(),{data:n,isLoading:a,error:i}=Ge("/command-center/activity",e),o=n?.funnel??null,l=f.useMemo(()=>(o?.stages??[]).map(d=>({label:r(d.stage),value:d.entered})),[o?.stages,r]),c=!o||o.stages.every(d=>d.entered===0);return s.jsxs(Pt,{testId:"funnel",isLoading:a,error:i,isEmpty:c,emptyMessage:t("commandCenter.funnel.empty","No task transitions in the selected range."),children:[s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.funnel.title","SDLC funnel")}),s.jsx(bx,{stages:l,ariaLabel:t("commandCenter.funnel.ariaLabel","Tasks per workflow stage")})]}),s.jsxs("div",{className:"cc-area-section",children:[s.jsx("h3",{className:"cc-area-section-title",children:t("commandCenter.funnel.throughputTitle","Throughput")}),s.jsxs("div",{className:"cc-stat-grid",children:[s.jsxs("div",{className:"card cc-stat-card cc-stat-card--gauge","data-testid":"cc-funnel-completion-rate",children:[s.jsx(Oa,{value:o?.completionRate??null,label:t("commandCenter.funnel.completionRate","Completion rate"),ariaLabel:t("commandCenter.funnel.completionRateAria","Completion rate for in-range triage entrants")}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.funnel.completionRateHint","Done ÷ entered (in range)")})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-funnel-throughput",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.funnel.throughputPerDay","Tasks done / day")}),s.jsx("div",{className:"cc-stat-value",children:X$(o?.throughputPerDay??0)}),s.jsx("span",{className:"cc-stat-sub",children:t("commandCenter.funnel.rangeDays","{{count}} day range",{count:o?.rangeDays??0})})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-funnel-done",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.funnel.doneInRange","Reached done")}),s.jsx("div",{className:"cc-stat-value",children:K(o?.doneInRange??0)})]}),s.jsxs("div",{className:"card cc-stat-card","data-testid":"cc-funnel-entered",children:[s.jsx("div",{className:"cc-stat-label",children:t("commandCenter.funnel.enteredInRange","Entered triage")}),s.jsx("div",{className:"cc-stat-value",children:K(o?.enteredInRange??0)})]})]})]})]})}const Z$=8;function J$(e){const{t}=le("app");return[{id:"overview",label:t("commandCenter.tabs.overview","Overview")},{id:"tokens",label:t("commandCenter.tabs.tokens","Tokens")},{id:"tools",label:t("commandCenter.tabs.tools","Tools")},{id:"activity",label:t("commandCenter.tabs.activity","Activity")},{id:"productivity",label:t("commandCenter.tabs.productivity","Productivity")},{id:"team",label:t("commandCenter.tabs.team","Team")},{id:"workflows",label:t("commandCenter.tabs.workflows","Workflows")},{id:"ecosystem",label:t("commandCenter.tabs.ecosystem","Ecosystem")},{id:"github",label:t("commandCenter.tabs.github","GitHub")},{id:"signals",label:t("commandCenter.tabs.signals","Signals")},{id:"system",label:t("commandCenter.tabs.system","System")},...e?[{id:"nodes",label:t("commandCenter.tabs.nodes","Nodes")}]:[],{id:"reliability",label:t("commandCenter.tabs.reliability","Reliability")},{id:"mission-control",label:t("commandCenter.tabs.missionControl","Mission Control")}]}const Q$=15e3;function e2({range:e,projectId:t,colorTheme:r="default",themeMode:n="system",shadcnCustomColors:a={},resolvedThemeMode:i=n==="light"?"light":"dark",onColorThemeChange:o=()=>{},onThemeModeChange:l=()=>{},onShadcnCustomColorsChange:c=()=>{},onChangeView:d}){const{t:u}=le("app"),m=Ge("/command-center/tokens?groupBy=model",e,{pollMs:Q$}),h=Ge("/command-center/tools",e),v=Ge("/command-center/activity",e),y=Ge("/command-center/signals",e),[g,p]=f.useState(null),[b,j]=f.useState(!0);f.useEffect(()=>{let W=!1;return j(!0),(async()=>{try{const $=await _l("/command-center/live");W||p($)}catch{W||p(null)}finally{W||j(!1)}})(),()=>{W=!0}},[]);const x=m.data?.totals?.totalTokens??0,C=h.data?.toolCalls??0,w=v.data?.activeNodes??0,P=v.data?.activeAgents??0,O=v.data?.sessions??0,k=v.data?.agentRuns?.total??0,N=v.data?.funnel?.doneInRange??0,S=g?.columns.find(W=>W.column==="in-progress")?.count??0,A=m.data?.groups?.length??0,_=f.useMemo(()=>[...m.data?.groups??[]].sort((W,$)=>$.totalTokens-W.totalTokens||(W.key??"").localeCompare($.key??"")).slice(0,Z$).map(W=>({label:W.key??u("commandCenter.tokens.unknownModel","(unknown)"),value:W.totalTokens,valueLabel:K(W.totalTokens),iconProvider:Ml(W.key??"")})),[m.data?.groups,u]),I=f.useMemo(()=>[...h.data?.byCategory??[]].sort((W,$)=>$.count-W.count||W.category.localeCompare($.category)).map(W=>({label:W.category,value:W.count,valueLabel:K(W.count)})),[h.data?.byCategory]),D=f.useMemo(()=>_.map(W=>({label:W.label,value:W.value})),[_]),F=f.useMemo(()=>(v.data?.daily??[]).map(W=>W.messages+W.activeAgents+(W.agentRuns??0)),[v.data?.daily]),V=f.useMemo(()=>[{label:u("commandCenter.activity.messages","Messages"),values:(v.data?.daily??[]).map(W=>W.messages)},{label:u("commandCenter.activity.activeAgents","Active agents"),values:(v.data?.daily??[]).map(W=>W.activeAgents)},{label:u("commandCenter.activity.agentRuns","Agent runs"),values:(v.data?.daily??[]).map(W=>W.agentRuns)}],[v.data?.daily,u]),U=F.length>0?F:[O,v.data?.messages??0,P,w,N],te=_.length>0||I.length>0||F.length>0,q=O>0||(v.data?.messages??0)>0||w>0||P>0||k>0||N>0,ee=x>0||C>0||q,B=!(m.data!==null&&h.data!==null&&v.data!==null)&&(m.isLoading||h.isLoading||v.isLoading),X=m.error??h.error??v.error,Q=m.data?Sr(m.data.cost?.usd??null,m.data.cost?.unavailable??!0):"—",G=h.data?h.data.fullyAutonomous?u("commandCenter.tools.ratioAutonomous","{{ratio}} calls/session (fully autonomous)",{ratio:h.data.autonomyRatio.toFixed(1)}):`${h.data.autonomyRatio.toFixed(1)}:1`:"—",ie=[{id:"tokens",label:u("commandCenter.overview.tokensCost","Tokens & cost"),value:K(x),subLabel:Q},{id:"autonomy",label:u("commandCenter.overview.autonomy","Autonomy ratio"),value:G},{id:"agentRuns",label:u("commandCenter.overview.agentRuns","Agent runs"),value:K(k)},{id:"tasksDone",label:u("commandCenter.overview.tasksDone","Tasks done"),value:K(N)},{id:"models",label:u("commandCenter.overview.uniqueModels","Unique models"),value:K(A)},{id:"signals",label:u("commandCenter.overview.openSignals","Open signals"),value:y.isLoading?"—":y.data?K(y.data.open??0):"—"}],se=s.jsx(s.Fragment,{children:s.jsx(l$,{projectId:t,colorTheme:r,themeMode:n,shadcnCustomColors:a,resolvedThemeMode:i,onColorThemeChange:o,onThemeModeChange:l,onShadcnCustomColorsChange:c,onChangeView:d})}),re=s.jsx("div",{className:"cc-overview-throughput","data-testid":"command-center-throughput",children:s.jsx(Y$,{range:e})});return B?s.jsxs("div",{className:"cc-overview",children:[se,s.jsxs("div",{className:"cc-loading","data-testid":"command-center-overview-loading",children:[s.jsx("div",{className:"cc-chart-skeleton"}),s.jsx("p",{children:s.jsx(Tl,{label:u("commandCenter.loading","Loading dashboard...")})})]}),re]}):X!==null&&!ee?s.jsxs("div",{className:"cc-overview",children:[se,s.jsxs("div",{className:"cc-error","data-testid":"command-center-overview-error",role:"alert",children:[s.jsx(gi,{size:24}),s.jsx("p",{children:X})]}),re]}):ee?s.jsxs("div",{className:"cc-overview",children:[se,s.jsx("div",{className:"cc-stat-grid",children:ie.map(W=>s.jsxs("div",{className:"card cc-stat-card","data-testid":`command-center-stat-${W.id}`,children:[s.jsx("div",{className:"cc-stat-label",children:W.label}),s.jsx("div",{className:`cc-stat-value ${W.id==="tokens"?"cc-token-count-live":""}`,children:W.value},W.value),W.subLabel?s.jsx("span",{className:"cc-stat-sub",children:W.subLabel}):null]},W.id))}),s.jsxs("div",{className:"cc-live-strip","data-testid":"command-center-live-strip",children:[s.jsxs("div",{className:"cc-live-strip-heading",children:[s.jsx("span",{className:"status-dot status-dot--connecting","aria-hidden":"true"}),s.jsx("span",{className:"cc-live-strip-label",children:u("commandCenter.overview.liveStrip","Live activity snapshot")})]}),s.jsxs("div",{className:"cc-live-strip-metrics","data-testid":"command-center-live-snapshot",children:[s.jsxs("span",{className:"cc-live-metric","data-testid":"command-center-live-tasks-in-progress",children:[s.jsx("span",{className:"cc-live-metric-value",children:b?"—":K(S)}),s.jsx("span",{className:"cc-live-metric-label",children:u("commandCenter.overview.tasksInProgress","tasks in progress")})]}),s.jsxs("span",{className:"cc-live-metric","data-testid":"command-center-live-agents-working",children:[s.jsx("span",{className:"cc-live-metric-value",children:K(P)}),s.jsx("span",{className:"cc-live-metric-label",children:u("commandCenter.overview.agentsWorking","agents working")})]}),s.jsxs("span",{className:"cc-live-metric","data-testid":"command-center-live-tokens",children:[s.jsx("span",{className:"cc-live-metric-value cc-token-count-live",children:K(x)},x),s.jsx("span",{className:"cc-live-metric-label",children:u("commandCenter.overview.liveTokens","tokens")})]}),s.jsxs("span",{className:"cc-live-metric","data-testid":"command-center-live-open-signals",children:[s.jsx("span",{className:"cc-live-metric-value",children:y.isLoading?"—":y.data?K(y.data.open??0):"—"}),s.jsx("span",{className:"cc-live-metric-label",children:u("commandCenter.overview.openSignals","open signals")})]})]}),s.jsxs("div",{className:"cc-live-trend","data-testid":"command-center-throughput-trend",children:[s.jsx("span",{className:"cc-live-trend-label",children:u("commandCenter.overview.throughputTrend","throughput trend")}),s.jsx(Kt,{values:U,ariaLabel:u("commandCenter.overview.throughputTrendAria","Recent activity throughput trend")})]})]}),te?s.jsxs("section",{className:"cc-overview-charts","data-testid":"command-center-overview-charts",children:[_.length>0?s.jsxs("div",{className:"card cc-overview-chart-card","data-testid":"command-center-overview-chart-tokens",children:[s.jsxs("div",{className:"cc-overview-chart-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:u("commandCenter.overview.tokensByModel","Tokens by model")}),s.jsx("p",{children:u("commandCenter.overview.tokensByModelHint","Top model token consumers in this range")})]}),s.jsx(Ze,{data:_,ariaLabel:u("commandCenter.overview.tokensByModel","Tokens by model")})]}):null,D.length>0?s.jsxs("div",{className:"card cc-overview-chart-card","data-testid":"cc-overview-pie",children:[s.jsxs("div",{className:"cc-overview-chart-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:u("commandCenter.overview.tokensByModelPie","Token share by model")}),s.jsx("p",{children:u("commandCenter.overview.tokensByModelPieHint","Top model token share in this range")})]}),s.jsx(kt,{data:D,ariaLabel:u("commandCenter.overview.tokensByModelPie","Token share by model")})]}):null,I.length>0?s.jsxs("div",{className:"card cc-overview-chart-card","data-testid":"command-center-overview-chart-tools",children:[s.jsxs("div",{className:"cc-overview-chart-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:u("commandCenter.overview.toolCategories","Tool categories")}),s.jsx("p",{children:u("commandCenter.overview.toolCategoriesHint","Autonomous work grouped by tool family")})]}),s.jsx(Ze,{data:I,ariaLabel:u("commandCenter.overview.toolCategories","Tool categories")})]}):null,F.length>0?s.jsxs("div",{className:"card cc-overview-chart-card cc-overview-chart-card--trend","data-testid":"cc-overview-line",children:[s.jsxs("div",{className:"cc-overview-chart-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:u("commandCenter.overview.dailyActivityLine","Daily activity line")}),s.jsx("p",{children:u("commandCenter.overview.dailyActivityLineHint","Messages, agents, and runs by day")})]}),s.jsx(cr,{series:V,ariaLabel:u("commandCenter.overview.dailyActivityLine","Daily activity line")})]}):null,F.length>0?s.jsxs("div",{className:"card cc-overview-chart-card cc-overview-chart-card--trend","data-testid":"command-center-overview-chart-activity",children:[s.jsxs("div",{className:"cc-overview-chart-header",children:[s.jsx("h3",{className:"cc-area-section-title",children:u("commandCenter.overview.dailyActivity","Daily activity trend")}),s.jsx("p",{children:u("commandCenter.overview.dailyActivityHint","Messages plus active agents per day")})]}),s.jsx(Kt,{values:F,ariaLabel:u("commandCenter.overview.dailyActivityAria","Daily activity trend")})]}):null]}):null,re]}):s.jsxs("div",{className:"cc-overview",children:[se,s.jsxs("div",{className:"cc-empty","data-testid":"command-center-empty",children:[s.jsx(bi,{size:28}),s.jsx("p",{children:u("commandCenter.empty","No usage data yet. Run some agents to populate the Dashboard.")})]}),re]})}function t2({tabId:e}){const{t}=le("app");return s.jsxs("div",{className:"cc-empty","data-testid":`command-center-placeholder-${e}`,children:[s.jsx(bi,{size:28}),s.jsx("p",{children:t("commandCenter.areaPending","This area renders once metrics data is available.")})]})}function B2({projectId:e,colorTheme:t="default",themeMode:r="system",shadcnCustomColors:n={},resolvedThemeMode:a=r==="light"?"light":"dark",onColorThemeChange:i=()=>{},onThemeModeChange:o=()=>{},onShadcnCustomColorsChange:l=()=>{},addToast:c=()=>{},nodesEnabled:d=!1,onChangeView:u}={}){const{t:m}=le("app"),h=J$(d),[v,y]=f.useState("overview"),[g,p]=f.useState(()=>Bh($h((w,P)=>P)[1])),b=f.useRef([]),j=f.useCallback(w=>{const P=(w+h.length)%h.length;y(h[P].id),b.current[P]?.focus()},[h]),x=f.useCallback((w,P)=>{switch(w.key){case"ArrowRight":case"ArrowDown":w.preventDefault(),j(P+1);break;case"ArrowLeft":case"ArrowUp":w.preventDefault(),j(P-1);break;case"Home":w.preventDefault(),j(0);break;case"End":w.preventDefault(),j(h.length-1);break;case"Enter":case" ":w.preventDefault(),y(h[P].id);break}},[j,h]);function C(){switch(v){case"overview":return s.jsx(e2,{range:g,projectId:e,colorTheme:t,themeMode:r,shadcnCustomColors:n,resolvedThemeMode:a,onColorThemeChange:i,onThemeModeChange:o,onShadcnCustomColorsChange:l,onChangeView:u});case"tokens":return s.jsx(iR,{range:g});case"tools":return s.jsx(sR,{range:g});case"activity":return s.jsx(bR,{range:g});case"productivity":return s.jsx(xR,{range:g});case"team":return s.jsx(OR,{range:g,projectId:e,addToast:c});case"workflows":return s.jsx(ER,{range:g});case"ecosystem":return s.jsx(_R,{range:g});case"github":return s.jsx(IR,{range:g});case"signals":return s.jsx(DR,{range:g});case"system":return s.jsx(HR,{});case"nodes":return s.jsx(H$,{addToast:c});case"reliability":return s.jsx(c$,{});case"mission-control":return s.jsx(n$,{});default:return s.jsx(t2,{tabId:v})}}return s.jsxs("section",{className:"command-center","data-testid":"command-center",children:[s.jsxs("header",{className:"cc-header",children:[s.jsxs("h2",{className:"cc-title",children:[s.jsx(bi,{size:20}),m("commandCenter.heading","Dashboard")]}),s.jsx(X0,{value:g,onChange:p})]}),s.jsx("div",{className:"cc-tablist",role:"tablist","aria-label":m("commandCenter.tablistLabel","Dashboard sections"),children:h.map((w,P)=>{const O=w.id===v;return s.jsx("button",{ref:k=>{b.current[P]=k},role:"tab",id:`cc-tab-${w.id}`,"aria-selected":O,"aria-controls":`cc-tabpanel-${w.id}`,tabIndex:O?0:-1,className:`cc-tab${O?" active":""}`,onClick:()=>y(w.id),onKeyDown:k=>x(k,P),"data-testid":`command-center-tab-${w.id}`,children:w.label},w.id)})}),s.jsx("div",{role:"tabpanel",id:`cc-tabpanel-${v}`,"aria-labelledby":`cc-tab-${v}`,tabIndex:0,className:"cc-tabpanel","data-testid":`command-center-panel-${v}`,children:C()})]})}export{B2 as CommandCenter};