@rubytech/create-maxy-code 0.1.479 → 0.1.481

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 (204) hide show
  1. package/package.json +1 -1
  2. package/payload/platform/docs/superpowers/plans/2026-07-20-storage-pages-create.md +82 -0
  3. package/payload/platform/docs/superpowers/plans/2026-07-20-task-1829-platform-ui-typecheck.md +830 -0
  4. package/payload/platform/docs/superpowers/specs/2026-07-20-task-1829-platform-ui-typecheck-design.md +163 -0
  5. package/payload/platform/lib/storage-broker/dist/__tests__/cf-exec.test.js +155 -12
  6. package/payload/platform/lib/storage-broker/dist/__tests__/cf-exec.test.js.map +1 -1
  7. package/payload/platform/lib/storage-broker/dist/cf-exec.d.ts +3 -0
  8. package/payload/platform/lib/storage-broker/dist/cf-exec.d.ts.map +1 -1
  9. package/payload/platform/lib/storage-broker/dist/cf-exec.js +68 -28
  10. package/payload/platform/lib/storage-broker/dist/cf-exec.js.map +1 -1
  11. package/payload/platform/lib/storage-broker/src/__tests__/cf-exec.test.ts +194 -16
  12. package/payload/platform/lib/storage-broker/src/cf-exec.ts +74 -29
  13. package/payload/platform/plugins/cloudflare/skills/calendar-site/SKILL.md +1 -1
  14. package/payload/platform/plugins/cloudflare/skills/site-deploy/SKILL.md +1 -1
  15. package/payload/platform/plugins/outlook/mcp/dist/__tests__/device-flow.test.js +41 -1
  16. package/payload/platform/plugins/outlook/mcp/dist/__tests__/device-flow.test.js.map +1 -1
  17. package/payload/platform/plugins/outlook/mcp/dist/__tests__/graph-client.test.js +249 -2
  18. package/payload/platform/plugins/outlook/mcp/dist/__tests__/graph-client.test.js.map +1 -1
  19. package/payload/platform/plugins/outlook/mcp/dist/__tests__/token-store.test.js +127 -3
  20. package/payload/platform/plugins/outlook/mcp/dist/__tests__/token-store.test.js.map +1 -1
  21. package/payload/platform/plugins/outlook/mcp/dist/auth/device-flow.d.ts +17 -0
  22. package/payload/platform/plugins/outlook/mcp/dist/auth/device-flow.d.ts.map +1 -1
  23. package/payload/platform/plugins/outlook/mcp/dist/auth/device-flow.js +26 -1
  24. package/payload/platform/plugins/outlook/mcp/dist/auth/device-flow.js.map +1 -1
  25. package/payload/platform/plugins/outlook/mcp/dist/auth/token-store.d.ts +37 -1
  26. package/payload/platform/plugins/outlook/mcp/dist/auth/token-store.d.ts.map +1 -1
  27. package/payload/platform/plugins/outlook/mcp/dist/auth/token-store.js +126 -5
  28. package/payload/platform/plugins/outlook/mcp/dist/auth/token-store.js.map +1 -1
  29. package/payload/platform/plugins/outlook/mcp/dist/lib/graph-client.d.ts +18 -0
  30. package/payload/platform/plugins/outlook/mcp/dist/lib/graph-client.d.ts.map +1 -1
  31. package/payload/platform/plugins/outlook/mcp/dist/lib/graph-client.js +123 -18
  32. package/payload/platform/plugins/outlook/mcp/dist/lib/graph-client.js.map +1 -1
  33. package/payload/platform/plugins/outlook/references/auth.md +45 -2
  34. package/payload/platform/plugins/storage-broker/PLUGIN.md +6 -2
  35. package/payload/platform/plugins/storage-broker/mcp/dist/index.js +23 -0
  36. package/payload/platform/plugins/storage-broker/mcp/dist/index.js.map +1 -1
  37. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.d.ts.map +1 -1
  38. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js +1 -0
  39. package/payload/platform/services/claude-session-manager/dist/canonical-tool-names.generated.js.map +1 -1
  40. package/payload/server/{chunk-3XLLTG6R.js → chunk-REWXLAPC.js} +30 -10
  41. package/payload/server/package.json +1 -1
  42. package/payload/server/public/activity.html +6 -7
  43. package/payload/server/public/assets/{AdminLoginScreens-DkxQZnvB.js → AdminLoginScreens-DXYJWXaX.js} +1 -1
  44. package/payload/server/public/assets/AdminShell-UDgNN4CA.js +2 -0
  45. package/payload/server/public/assets/{Checkbox-CsTWK8mm.js → Checkbox-C08Ulc_a.js} +1 -1
  46. package/payload/server/public/assets/activity-06gsRDVv.js +1 -0
  47. package/payload/server/public/assets/admin-BhiHyORH.js +1 -0
  48. package/payload/server/public/assets/{arc-BrHWN2Kr.js → arc-BHXuzTwg.js} +1 -1
  49. package/payload/server/public/assets/architecture-YZFGNWBL-Ct5q6ks1.js +1 -0
  50. package/payload/server/public/assets/{architectureDiagram-Q4EWVU46-Clt9NOr0.js → architectureDiagram-Q4EWVU46-DsN_vxau.js} +1 -1
  51. package/payload/server/public/assets/{blockDiagram-DXYQGD6D-BOe_jmXi.js → blockDiagram-DXYQGD6D-CvNat1uB.js} +1 -1
  52. package/payload/server/public/assets/browser-Cz4IKS47.js +1 -0
  53. package/payload/server/public/assets/{c4Diagram-AHTNJAMY-B64FaKMV.js → c4Diagram-AHTNJAMY-E9yqTPTW.js} +1 -1
  54. package/payload/server/public/assets/calendar-D0xtNqH8.js +1 -0
  55. package/payload/server/public/assets/channel-PE9vBKEQ.js +1 -0
  56. package/payload/server/public/assets/chat-DwLJ830n.js +1 -0
  57. package/payload/server/public/assets/chevron-left-Cv-TFuEf.js +1 -0
  58. package/payload/server/public/assets/{chunk-2KRD3SAO-BGAUfWvM.js → chunk-2KRD3SAO-DpzI_0EY.js} +1 -1
  59. package/payload/server/public/assets/{chunk-336JU56O-PFi6uQZ0.js → chunk-336JU56O-eR_I9Eu4.js} +2 -2
  60. package/payload/server/public/assets/chunk-426QAEUC-BDNZtJsz.js +1 -0
  61. package/payload/server/public/assets/{chunk-4BX2VUAB-CkxXXCiF.js → chunk-4BX2VUAB-D-6xk1t8.js} +1 -1
  62. package/payload/server/public/assets/{chunk-4TB4RGXK-B-7tN4IA.js → chunk-4TB4RGXK-BkqUcFpL.js} +1 -1
  63. package/payload/server/public/assets/{chunk-55IACEB6-CBkNmqrt.js → chunk-55IACEB6-ChCl2pSP.js} +1 -1
  64. package/payload/server/public/assets/{chunk-5FUZZQ4R-wa9ujn7i.js → chunk-5FUZZQ4R-DasGsg54.js} +1 -1
  65. package/payload/server/public/assets/{chunk-5PVQY5BW-DIk-xBaE.js → chunk-5PVQY5BW-DXlHUX1h.js} +1 -1
  66. package/payload/server/public/assets/{chunk-67CJDMHE-BbMV1lgW.js → chunk-67CJDMHE-BZfVpTsE.js} +1 -1
  67. package/payload/server/public/assets/{chunk-7N4EOEYR-C49Mv-nQ.js → chunk-7N4EOEYR-C6U5TIgT.js} +1 -1
  68. package/payload/server/public/assets/{chunk-AA7GKIK3-Dy_pJOp_.js → chunk-AA7GKIK3-CA7cVDmw.js} +1 -1
  69. package/payload/server/public/assets/{chunk-BSJP7CBP-Ce-OmPqn.js → chunk-BSJP7CBP-DxN2GC3p.js} +1 -1
  70. package/payload/server/public/assets/{chunk-CIAEETIT-tnjq-APC.js → chunk-CIAEETIT-C0-4wA8y.js} +1 -1
  71. package/payload/server/public/assets/{chunk-EDXVE4YY-Bvv_deZ2.js → chunk-EDXVE4YY--kyb1rLc.js} +1 -1
  72. package/payload/server/public/assets/{chunk-ENJZ2VHE-CmxCPKyU.js → chunk-ENJZ2VHE-FBN6hR7V.js} +1 -1
  73. package/payload/server/public/assets/{chunk-FMBD7UC4-Top6y08S.js → chunk-FMBD7UC4-Lpge4M5g.js} +1 -1
  74. package/payload/server/public/assets/{chunk-FOC6F5B3-B9LPNCUS.js → chunk-FOC6F5B3-CM1rwOou.js} +1 -1
  75. package/payload/server/public/assets/{chunk-ICPOFSXX-Bi-_c351.js → chunk-ICPOFSXX-JdYLY3yu.js} +2 -2
  76. package/payload/server/public/assets/{chunk-K5T4RW27-DAnRM04h.js → chunk-K5T4RW27-DCUblGBr.js} +1 -1
  77. package/payload/server/public/assets/{chunk-KGLVRYIC-C0QYcbLe.js → chunk-KGLVRYIC-BP_cide2.js} +1 -1
  78. package/payload/server/public/assets/{chunk-LIHQZDEY-BjvA5ykt.js → chunk-LIHQZDEY-DjMa1lOl.js} +1 -1
  79. package/payload/server/public/assets/{chunk-ORNJ4GCN-Cs46Gj7z.js → chunk-ORNJ4GCN-D51eJAoV.js} +1 -1
  80. package/payload/server/public/assets/{chunk-OYMX7WX6-BBpimab5.js → chunk-OYMX7WX6-4hWIO544.js} +1 -1
  81. package/payload/server/public/assets/chunk-QZHKN3VN-B_Hris8x.js +1 -0
  82. package/payload/server/public/assets/{chunk-U2HBQHQK-CQUSBHoK.js → chunk-U2HBQHQK-BwdQf9cS.js} +1 -1
  83. package/payload/server/public/assets/{chunk-X2U36JSP-Dm8TevG0.js → chunk-X2U36JSP-DmDxwLOg.js} +1 -1
  84. package/payload/server/public/assets/{chunk-XPW4576I-B10QuxYb.js → chunk-XPW4576I-JQyAB7ND.js} +1 -1
  85. package/payload/server/public/assets/{chunk-YZCP3GAM-vaGsu4Wk.js → chunk-YZCP3GAM-BonLdCzI.js} +1 -1
  86. package/payload/server/public/assets/{chunk-ZZ45TVLE-D1Qi22bL.js → chunk-ZZ45TVLE-BXKB2wSk.js} +1 -1
  87. package/payload/server/public/assets/classDiagram-6PBFFD2Q-D8Q05iMI.js +1 -0
  88. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-Dm3hAxfm.js +1 -0
  89. package/payload/server/public/assets/clone-C-wOwvpY.js +1 -0
  90. package/payload/server/public/assets/{cose-bilkent-S5V4N54A-CRDvLRXs.js → cose-bilkent-S5V4N54A-BDnd4Blw.js} +1 -1
  91. package/payload/server/public/assets/{dagre-CEmqJTt3.js → dagre-BmexzuER.js} +1 -1
  92. package/payload/server/public/assets/{dagre-KV5264BT-LXMTo7Fp.js → dagre-KV5264BT-D4WVuwPj.js} +1 -1
  93. package/payload/server/public/assets/data-DUDJfnjI.js +1 -0
  94. package/payload/server/public/assets/{diagram-5BDNPKRD-zyis6nPt.js → diagram-5BDNPKRD-Bbf4mT8a.js} +1 -1
  95. package/payload/server/public/assets/{diagram-G4DWMVQ6-BiU0XAAD.js → diagram-G4DWMVQ6-BpqVTUmx.js} +1 -1
  96. package/payload/server/public/assets/{diagram-MMDJMWI5-rGFiz1SX.js → diagram-MMDJMWI5-DY-k5k6r.js} +1 -1
  97. package/payload/server/public/assets/{diagram-TYMM5635-B0wak1ZJ.js → diagram-TYMM5635-CXHxwacS.js} +1 -1
  98. package/payload/server/public/assets/{erDiagram-SMLLAGMA-D8AUxLyX.js → erDiagram-SMLLAGMA-BNKEc3l8.js} +1 -1
  99. package/payload/server/public/assets/{flatten-naJ5PJ4f.js → flatten-jn8bZgcI.js} +1 -1
  100. package/payload/server/public/assets/{flowDiagram-DWJPFMVM-BtdUf68b.js → flowDiagram-DWJPFMVM-CbAeuJsi.js} +1 -1
  101. package/payload/server/public/assets/{ganttDiagram-T4ZO3ILL-C-lkzDmf.js → ganttDiagram-T4ZO3ILL-CeeNnL4l.js} +1 -1
  102. package/payload/server/public/assets/gitGraph-7Q5UKJZL-BBHsY16R.js +1 -0
  103. package/payload/server/public/assets/{gitGraphDiagram-UUTBAWPF-DRUKumq2.js → gitGraphDiagram-UUTBAWPF-DG8RCtfg.js} +1 -1
  104. package/payload/server/public/assets/{graph-CDSGRoeb.js → graph-BAoktBcx.js} +19 -19
  105. package/payload/server/public/assets/{graph-labels-C5qLwnWA.js → graph-labels-LeIhl7ZG.js} +1 -1
  106. package/payload/server/public/assets/{graphlib-zRsaoFEC.js → graphlib-BkDExPQi.js} +1 -1
  107. package/payload/server/public/assets/info-OMHHGYJF-C1j5I_zx.js +1 -0
  108. package/payload/server/public/assets/infoDiagram-42DDH7IO-ZWkwHWEu.js +2 -0
  109. package/payload/server/public/assets/{isEmpty-Bnpg7b8f.js → isEmpty-Dkk6_L-B.js} +1 -1
  110. package/payload/server/public/assets/{ishikawaDiagram-UXIWVN3A-BguMgoR8.js → ishikawaDiagram-UXIWVN3A-D_iMHV64.js} +1 -1
  111. package/payload/server/public/assets/{journeyDiagram-VCZTEJTY-CXhyK1n-.js → journeyDiagram-VCZTEJTY-BvPRpulx.js} +1 -1
  112. package/payload/server/public/assets/{kanban-definition-6JOO6SKY-C0UCWVx-.js → kanban-definition-6JOO6SKY-CkWaXWo2.js} +1 -1
  113. package/payload/server/public/assets/{line--uhS9YDE.js → line-BGQT9unx.js} +1 -1
  114. package/payload/server/public/assets/{linear-CAOWPodQ.js → linear-DzrYI8-8.js} +1 -1
  115. package/payload/server/public/assets/{maximize-2-CAzH8dED.js → maximize-2-2MgPSwlx.js} +1 -1
  116. package/payload/server/public/assets/{mermaid-parser.core-D6kPx7vc.js → mermaid-parser.core-DrMY7FMe.js} +2 -2
  117. package/payload/server/public/assets/{mermaid.core-CTd4DS6O.js → mermaid.core-BWdf6fZ7.js} +3 -3
  118. package/payload/server/public/assets/{mindmap-definition-QFDTVHPH-_AyvyG8C.js → mindmap-definition-QFDTVHPH-CgqM9h97.js} +1 -1
  119. package/payload/server/public/assets/operator-CZifmNhp.js +1 -0
  120. package/payload/server/public/assets/{ordinal-Wx4m9zHk.js → ordinal-DuJYM7p1.js} +1 -1
  121. package/payload/server/public/assets/packet-4T2RLAQJ-CGiTbe0N.js +1 -0
  122. package/payload/server/public/assets/{page-B5YngOrK.js → page-B4kllGd_.js} +6 -6
  123. package/payload/server/public/assets/page-DbfE7QwJ.js +1 -0
  124. package/payload/server/public/assets/{pdf-render-CeX6d2v7.js → pdf-render-riHufgrn.js} +1 -1
  125. package/payload/server/public/assets/pie-ZZUOXDRM-BrK023dE.js +1 -0
  126. package/payload/server/public/assets/{pieDiagram-DEJITSTG-6TsUDkkQ.js → pieDiagram-DEJITSTG-BeUGoYS7.js} +1 -1
  127. package/payload/server/public/assets/public-VtmyYz8E.js +1 -0
  128. package/payload/server/public/assets/{quadrantDiagram-34T5L4WZ-CWw9gOI4.js → quadrantDiagram-34T5L4WZ-CX82WgKy.js} +1 -1
  129. package/payload/server/public/assets/radar-PYXPWWZC-p7NRamXX.js +1 -0
  130. package/payload/server/public/assets/{reduce-BUmc8RDR.js → reduce-COyotL2V.js} +1 -1
  131. package/payload/server/public/assets/{requirementDiagram-MS252O5E-DCOlxNvx.js → requirementDiagram-MS252O5E-CzqebQXj.js} +1 -1
  132. package/payload/server/public/assets/{rotate-ccw-UDln4Tou.js → rotate-ccw-DaZdB2cz.js} +1 -1
  133. package/payload/server/public/assets/{sankeyDiagram-XADWPNL6-CW4Xbir3.js → sankeyDiagram-XADWPNL6-CaHi1yzU.js} +1 -1
  134. package/payload/server/public/assets/{sequenceDiagram-FGHM5R23-vhb_pBLG.js → sequenceDiagram-FGHM5R23-BF2AeiKW.js} +1 -1
  135. package/payload/server/public/assets/{stateDiagram-FHFEXIEX-Cb1WExEX.js → stateDiagram-FHFEXIEX-DtUCA8Ih.js} +1 -1
  136. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-a4FvB3L8.js +1 -0
  137. package/payload/server/public/assets/tasks-CvqVDbfO.js +1 -0
  138. package/payload/server/public/assets/{time-entry-format-DPOBIE18.js → time-entry-format-TD-PPEIu.js} +1 -1
  139. package/payload/server/public/assets/{timeline-definition-GMOUNBTQ-BAHTf_AF.js → timeline-definition-GMOUNBTQ-D3Q1YrKY.js} +1 -1
  140. package/payload/server/public/assets/treeView-SZITEDCU-CoWk8VoG.js +1 -0
  141. package/payload/server/public/assets/treemap-W4RFUUIX-BhWeGj8Y.js +1 -0
  142. package/payload/server/public/assets/{triangle-alert-Dz-CZKo5.js → triangle-alert-BaLhVNnn.js} +1 -1
  143. package/payload/server/public/assets/useCopyFeedback-BhjPzRa3.js +1 -0
  144. package/payload/server/public/assets/{useSubAccountSwitcher-BRIluIKf.css → useSubAccountSwitcher-CWRpVt1-.css} +1 -1
  145. package/payload/server/public/assets/{useSubAccountSwitcher-v8LyBzZN.js → useSubAccountSwitcher-HEVLb6Z9.js} +2 -2
  146. package/payload/server/public/assets/useVoiceRecorder-CfGgj3vm.js +2 -0
  147. package/payload/server/public/assets/{vennDiagram-DHZGUBPP-DtEttvW4.js → vennDiagram-DHZGUBPP-DnjzQDGf.js} +1 -1
  148. package/payload/server/public/assets/wardley-RL74JXVD-C0q3Hqng.js +1 -0
  149. package/payload/server/public/assets/{wardleyDiagram-NUSXRM2D-K06y6CVJ.js → wardleyDiagram-NUSXRM2D-T3WHrUvi.js} +1 -1
  150. package/payload/server/public/assets/{xychartDiagram-5P7HB3ND-D66c40lp.js → xychartDiagram-5P7HB3ND-2Efyv4h2.js} +1 -1
  151. package/payload/server/public/browser.html +4 -5
  152. package/payload/server/public/calendar.html +5 -6
  153. package/payload/server/public/chat.html +12 -13
  154. package/payload/server/public/data.html +11 -12
  155. package/payload/server/public/graph.html +10 -11
  156. package/payload/server/public/index.html +14 -15
  157. package/payload/server/public/operator.html +14 -15
  158. package/payload/server/public/public.html +12 -13
  159. package/payload/server/public/tasks.html +6 -5
  160. package/payload/server/server.js +145 -24
  161. package/payload/server/{src-XQ63FPRE.js → src-JJ6PHO5I.js} +1 -1
  162. package/payload/server/public/assets/AdminShell-Cv_nIFGe.js +0 -2
  163. package/payload/server/public/assets/activity-BbnTiVBT.js +0 -1
  164. package/payload/server/public/assets/admin-BZY3i_Ff.js +0 -1
  165. package/payload/server/public/assets/architecture-YZFGNWBL-CZQzGRSM.js +0 -1
  166. package/payload/server/public/assets/browser-BbIiSFKr.js +0 -1
  167. package/payload/server/public/assets/calendar-BvxeTHvQ.js +0 -1
  168. package/payload/server/public/assets/channel-zDUAN9Ks.js +0 -1
  169. package/payload/server/public/assets/chat-DUKxufRk.js +0 -1
  170. package/payload/server/public/assets/chevron-left-BtfJD6LL.js +0 -1
  171. package/payload/server/public/assets/chunk-426QAEUC-iJnqNRug.js +0 -1
  172. package/payload/server/public/assets/chunk-QZHKN3VN-Qlc2PFAj.js +0 -1
  173. package/payload/server/public/assets/classDiagram-6PBFFD2Q-CFsKL52p.js +0 -1
  174. package/payload/server/public/assets/classDiagram-v2-HSJHXN6E-BWBUUCiO.js +0 -1
  175. package/payload/server/public/assets/clone-h5XhkDUL.js +0 -1
  176. package/payload/server/public/assets/data-hl1wa-Ax.js +0 -1
  177. package/payload/server/public/assets/gitGraph-7Q5UKJZL-CBZPQJLj.js +0 -1
  178. package/payload/server/public/assets/info-OMHHGYJF-1vIoX-kP.js +0 -1
  179. package/payload/server/public/assets/infoDiagram-42DDH7IO-KHcXRaan.js +0 -2
  180. package/payload/server/public/assets/operator-BK7r8DAB.js +0 -1
  181. package/payload/server/public/assets/packet-4T2RLAQJ-CTU0gCGb.js +0 -1
  182. package/payload/server/public/assets/page-BsCS0Dmc.js +0 -1
  183. package/payload/server/public/assets/pie-ZZUOXDRM-D-EEHxhC.js +0 -1
  184. package/payload/server/public/assets/public-C1Pz-IBs.js +0 -1
  185. package/payload/server/public/assets/radar-PYXPWWZC-DHXATZGB.js +0 -1
  186. package/payload/server/public/assets/stateDiagram-v2-QKLJ7IA2-CxOIKvXh.js +0 -1
  187. package/payload/server/public/assets/tasks-B-cLsn3p.js +0 -1
  188. package/payload/server/public/assets/treeView-SZITEDCU-CC7ouMFd.js +0 -1
  189. package/payload/server/public/assets/treemap-W4RFUUIX-CaCg27im.js +0 -1
  190. package/payload/server/public/assets/useCopyFeedback-wtUHGohk.js +0 -1
  191. package/payload/server/public/assets/useSelectionMode-sph7AQT5.js +0 -1
  192. package/payload/server/public/assets/useVoiceRecorder-DN4jYQ0A.js +0 -2
  193. package/payload/server/public/assets/wardley-RL74JXVD-bMPsqQZ7.js +0 -1
  194. /package/payload/server/public/assets/{_baseFor-k8hYPe-U.js → _baseFor-Bjj9It3Q.js} +0 -0
  195. /package/payload/server/public/assets/{array-BFDiaBgf.js → array-BrrxEo12.js} +0 -0
  196. /package/payload/server/public/assets/{cytoscape.esm-Ch0xptA4.js → cytoscape.esm-CTWJxUxo.js} +0 -0
  197. /package/payload/server/public/assets/{defaultLocale-ZeknFqNe.js → defaultLocale-CFDbRV4k.js} +0 -0
  198. /package/payload/server/public/assets/{dist-B2N0v8hZ.js → dist-BATfy7Sn.js} +0 -0
  199. /package/payload/server/public/assets/{init-0VJVrkRJ.js → init-dXCzGgLP.js} +0 -0
  200. /package/payload/server/public/assets/{katex-Br7bH10N.js → katex-CHA1JFYJ.js} +0 -0
  201. /package/payload/server/public/assets/{path-INs8XTPH.js → path-CCRpdXhK.js} +0 -0
  202. /package/payload/server/public/assets/{preload-helper-D_sPnjeL.js → preload-helper-CH6UZRzu.js} +0 -0
  203. /package/payload/server/public/assets/{rough.esm-DU9bZLvZ.js → rough.esm-Bud4g4fh.js} +0 -0
  204. /package/payload/server/public/assets/{src-DHSQDYx-.js → src-DNdBRXXx.js} +0 -0
@@ -5,12 +5,13 @@
5
5
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
6
  <title>Tasks — Maxy</title>
7
7
  <link rel="icon" href="/favicon.ico">
8
- <script type="module" crossorigin src="/assets/tasks-B-cLsn3p.js"></script>
8
+ <script type="module" crossorigin src="/assets/tasks-CvqVDbfO.js"></script>
9
9
  <link rel="modulepreload" crossorigin href="/assets/chunk-TPjIAO9U.js">
10
- <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-v8LyBzZN.js">
11
- <link rel="modulepreload" crossorigin href="/assets/time-entry-format-DPOBIE18.js">
12
- <link rel="modulepreload" crossorigin href="/assets/rotate-ccw-UDln4Tou.js">
13
- <link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-BRIluIKf.css">
10
+ <link rel="modulepreload" crossorigin href="/assets/useSubAccountSwitcher-HEVLb6Z9.js">
11
+ <link rel="modulepreload" crossorigin href="/assets/AdminShell-UDgNN4CA.js">
12
+ <link rel="modulepreload" crossorigin href="/assets/time-entry-format-TD-PPEIu.js">
13
+ <link rel="modulepreload" crossorigin href="/assets/rotate-ccw-DaZdB2cz.js">
14
+ <link rel="stylesheet" crossorigin href="/assets/useSubAccountSwitcher-CWRpVt1-.css">
14
15
  <link rel="stylesheet" href="/brand-defaults.css">
15
16
  </head>
16
17
  <body>
@@ -133,7 +133,7 @@ import {
133
133
  registerResource,
134
134
  resolveOwner,
135
135
  tooLargeMessage
136
- } from "./chunk-3XLLTG6R.js";
136
+ } from "./chunk-REWXLAPC.js";
137
137
  import {
138
138
  __commonJS,
139
139
  __toESM
@@ -4300,7 +4300,7 @@ async function ensureWhatsAppConversation(input) {
4300
4300
  return null;
4301
4301
  }
4302
4302
  console.error(
4303
- `${TAG12} conversation-merged cacheKey=${input.cacheKey} agentType=${input.agentType} channel=whatsapp created=${result.created} ms=${ms}`
4303
+ `${TAG12} conversation-merged cacheKey=${input.cacheKey} agentType=${input.agentType} channel=whatsapp accountId=${input.platformAccountId} connectionAccountId=${input.connectionAccountId ?? input.platformAccountId} created=${result.created} ms=${ms}`
4304
4304
  );
4305
4305
  return { sessionId: result.sessionId, created: result.created };
4306
4306
  } catch (err) {
@@ -5662,6 +5662,29 @@ function selectStoreAccountKey(conns, accountId) {
5662
5662
  function resolveReadStoreKey(accountId) {
5663
5663
  return selectStoreAccountKey(Array.from(connections.values()), accountId);
5664
5664
  }
5665
+ function resolveInboundPersistAccount(args) {
5666
+ const result = args.accessResult;
5667
+ if (result?.allowed && result.reason === "account-manager" && result.effectiveAccountId) {
5668
+ return result.effectiveAccountId;
5669
+ }
5670
+ return args.connPlatformAccountId;
5671
+ }
5672
+ function resolveConversationPersistAccount(sendAccountId, counterpartyPhone) {
5673
+ const conn = findConnectionByKey(Array.from(connections.values()), sendAccountId);
5674
+ if (!conn) return sendAccountId;
5675
+ const access = checkDmAccess({
5676
+ senderPhone: counterpartyPhone,
5677
+ selfPhone: conn.selfPhone ?? "",
5678
+ config: whatsAppConfig,
5679
+ accountConfig: whatsAppConfig.accounts?.[conn.accountId],
5680
+ accountId: conn.accountId,
5681
+ isValidAccount: (id) => isValidAccountId(id)
5682
+ });
5683
+ return resolveInboundPersistAccount({
5684
+ accessResult: access,
5685
+ connPlatformAccountId: conn.platformAccountId
5686
+ });
5687
+ }
5665
5688
  function listConnectionPlatformAccountIds() {
5666
5689
  return [...connections.values()].map((conn) => conn.platformAccountId);
5667
5690
  }
@@ -5968,6 +5991,7 @@ function monitorInbound(conn) {
5968
5991
  if (!remoteJid || remoteJid === "status@broadcast") continue;
5969
5992
  if (!msg.message) continue;
5970
5993
  let receiptDeferredToWorker = false;
5994
+ let dmAccess = null;
5971
5995
  const extracted = extractMessage(msg);
5972
5996
  const mediaServable = !!(extracted.mediaType && extracted.mimetype);
5973
5997
  if (!extracted.text && !mediaServable && msg.key.id) {
@@ -5982,7 +6006,21 @@ function monitorInbound(conn) {
5982
6006
  const senderJid = isGroup ? msg.key.participant ?? remoteJid : remoteJid;
5983
6007
  const senderPhone = await resolveJidToE164(senderJid, conn.lidMapping) ?? senderJid;
5984
6008
  const ts = msg.messageTimestamp ? Number(msg.messageTimestamp) : Math.floor(Date.now() / 1e3);
5985
- const storeKey = messageStoreKey(conn.platformAccountId, remoteJid);
6009
+ const fromMe = Boolean(msg.key.fromMe);
6010
+ dmAccess = isGroup ? null : checkDmAccess({
6011
+ senderPhone,
6012
+ selfPhone: conn.selfPhone ?? "",
6013
+ config: whatsAppConfig,
6014
+ accountConfig: whatsAppConfig.accounts?.[conn.accountId],
6015
+ accountId: conn.accountId,
6016
+ isValidAccount: (id) => isValidAccountId(id)
6017
+ });
6018
+ const persistAccountId = resolveInboundPersistAccount({
6019
+ accessResult: dmAccess,
6020
+ connPlatformAccountId: conn.platformAccountId
6021
+ });
6022
+ const managerScoped = dmAccess?.allowed === true && dmAccess.reason === "account-manager";
6023
+ const storeKey = messageStoreKey(persistAccountId, remoteJid);
5986
6024
  if (extracted.text) {
5987
6025
  storeMessage(storeKey, {
5988
6026
  id: msg.key.id ?? `${remoteJid}-${ts}`,
@@ -6003,16 +6041,16 @@ function monitorInbound(conn) {
6003
6041
  direction: "inbound",
6004
6042
  jid: remoteJid
6005
6043
  });
6006
- const fromMe = Boolean(msg.key.fromMe);
6007
- const cacheKeyAgentType = isGroup ? "public" : fromMe ? "admin" : checkDmAccess({
6008
- senderPhone,
6009
- selfPhone: conn.selfPhone ?? "",
6010
- config: whatsAppConfig,
6011
- accountConfig: whatsAppConfig.accounts?.[conn.accountId]
6012
- }).agentType;
6044
+ const cacheKeyAgentType = isGroup ? "public" : fromMe ? "admin" : dmAccess?.agentType ?? "public";
6013
6045
  const cacheKey = deriveCacheKey({
6014
6046
  agentType: cacheKeyAgentType,
6015
- accountId: conn.accountId,
6047
+ // Task 1786 — an account-manager keys on its bound sub-account, so a
6048
+ // manager gets its own `:Conversation` instead of merging into the
6049
+ // owner's bare `whatsapp:<dirname>` owner-mirror row. `deriveCacheKey`
6050
+ // returns `whatsapp:<accountId>` for admin; a UUID contains no colon,
6051
+ // so the key stays 2 segments and `deriveScope` still reads "admin".
6052
+ // Every non-manager case passes conn.accountId, byte-identical.
6053
+ accountId: managerScoped ? persistAccountId : conn.accountId,
6016
6054
  senderPhone,
6017
6055
  isGroup,
6018
6056
  groupJid: isGroup ? remoteJid : void 0,
@@ -6021,7 +6059,10 @@ function monitorInbound(conn) {
6021
6059
  if (msg.key.id) {
6022
6060
  const merged = await ensureWhatsAppConversation({
6023
6061
  accountId: conn.accountId,
6024
- platformAccountId: conn.platformAccountId,
6062
+ platformAccountId: persistAccountId,
6063
+ // Task 1786 — the socket owner, logged beside the stamped account
6064
+ // so a divergence between the two is one greppable line.
6065
+ connectionAccountId: conn.platformAccountId,
6025
6066
  cacheKey,
6026
6067
  agentType: cacheKeyAgentType,
6027
6068
  groupJid: isGroup ? remoteJid : void 0
@@ -6033,7 +6074,12 @@ function monitorInbound(conn) {
6033
6074
  );
6034
6075
  const alreadyRecorded = fromMe && echoAlreadyRecorded({
6035
6076
  readConversation,
6036
- platformAccountId: conn.platformAccountId,
6077
+ // Task 1786 — read the account /reply now APPENDS under. The
6078
+ // echo gate asks "did /reply already store this?", so it must
6079
+ // look in the same store file the reply landed in; reading the
6080
+ // socket owner's file would report every manager echo as
6081
+ // unrecorded and store a duplicate copy.
6082
+ platformAccountId: persistAccountId,
6037
6083
  canonicalRemoteJid,
6038
6084
  accountId: conn.accountId,
6039
6085
  remoteJid,
@@ -6052,7 +6098,7 @@ function monitorInbound(conn) {
6052
6098
  });
6053
6099
  const basePersist = {
6054
6100
  accountId: conn.accountId,
6055
- platformAccountId: conn.platformAccountId,
6101
+ platformAccountId: persistAccountId,
6056
6102
  remoteJid,
6057
6103
  canonicalRemoteJid,
6058
6104
  cacheKey,
@@ -6071,7 +6117,7 @@ function monitorInbound(conn) {
6071
6117
  };
6072
6118
  if (wantsServableMedia && upsert.type === "append") {
6073
6119
  const sock2 = conn.sock;
6074
- const platformAccountId = conn.platformAccountId;
6120
+ const platformAccountId = persistAccountId;
6075
6121
  const caption = extracted.caption ?? "";
6076
6122
  const fallbackBody = mediaFallbackBody(extracted);
6077
6123
  const msgKeyId = msg.key.id;
@@ -6109,7 +6155,8 @@ function monitorInbound(conn) {
6109
6155
  mediaAttachmentId = await storeInboundMediaServable(
6110
6156
  msg,
6111
6157
  conn.sock,
6112
- conn.platformAccountId,
6158
+ // Task 1786 — attachment bytes follow the record's account.
6159
+ persistAccountId,
6113
6160
  mediaSeed,
6114
6161
  { maxBytes }
6115
6162
  ) ?? void 0;
@@ -9341,7 +9388,10 @@ app3.post("/pages/deploy", pagesDeployBodyLimit, async (c) => {
9341
9388
  `[pages-broker] op=project-ensure pub=${pub} project=${project} existed=${existed} created=${!existed}`
9342
9389
  );
9343
9390
  const started = Date.now();
9344
- const { url } = await exec.pagesDeploy(dir, project, branch);
9391
+ const { url, excluded } = await exec.pagesDeploy(dir, project, branch);
9392
+ console.error(
9393
+ `[pages-broker] op=stage pub=${pub} excluded=${excluded.length > 0 ? excluded.join(",") : "none"}`
9394
+ );
9345
9395
  console.error(`[pages-broker] op=deploy pub=${pub} ranMs=${Date.now() - started} url=${url}`);
9346
9396
  const httpStatus = await verifyDeployed(url);
9347
9397
  const verified = httpStatus === 200;
@@ -9389,6 +9439,58 @@ app3.post("/pages/adopt", nameBodyLimit("pages"), async (c) => {
9389
9439
  await session.close();
9390
9440
  }
9391
9441
  });
9442
+ app3.post("/pages/create", nameBodyLimit("pages"), async (c) => {
9443
+ const pub = randomUUID7().slice(0, 8);
9444
+ const account = caller(c);
9445
+ if (!account) {
9446
+ log("write", "pages", "none", "*", null, "deny", "no-caller");
9447
+ return c.json({ error: "no-caller" }, 403);
9448
+ }
9449
+ const parsed = await readJsonBody(c);
9450
+ if (!parsed.ok) return parsed.res;
9451
+ const { project } = parsed.body;
9452
+ if (!project || typeof project !== "string") return c.json({ error: "project-required" }, 400);
9453
+ console.error(`[pages-broker] op=request pub=${pub} caller=${account} project=${project}`);
9454
+ const session = getSession();
9455
+ try {
9456
+ const owner = await resolveOwner(session, "pages", project);
9457
+ if (owner !== null && owner !== account) {
9458
+ log("write", "pages", account, project, owner, "deny");
9459
+ console.error(
9460
+ `[pages-broker] op=create pub=${pub} project=${project} existedOnCf=unchecked created=false decision=deny reason=cross-account`
9461
+ );
9462
+ return c.json({ error: "cross-account" }, 403);
9463
+ }
9464
+ if (owner === account) {
9465
+ log("write", "pages", account, project, account, "allow");
9466
+ console.error(
9467
+ `[pages-broker] op=create pub=${pub} project=${project} existedOnCf=unchecked created=false decision=allow reason=already-owned`
9468
+ );
9469
+ return c.json({ project, created: false });
9470
+ }
9471
+ const exec = await makeHousePagesExec(platformRoot());
9472
+ const existedOnCf = (await exec.pagesProjectList()).some((p) => p.name === project);
9473
+ if (existedOnCf) {
9474
+ log("write", "pages", account, project, null, "deny", "exists-unregistered");
9475
+ console.error(
9476
+ `[pages-broker] op=create pub=${pub} project=${project} existedOnCf=true created=false decision=deny reason=exists-unregistered`
9477
+ );
9478
+ return c.json({ error: "exists-unregistered" }, 409);
9479
+ }
9480
+ await exec.pagesProjectCreate(project, "main");
9481
+ await registerResource(session, { accountId: account, kind: "pages", name: project, cfResourceId: project });
9482
+ log("write", "pages", account, project, account, "allow");
9483
+ console.error(
9484
+ `[pages-broker] op=create pub=${pub} project=${project} existedOnCf=false created=true decision=allow reason=owner`
9485
+ );
9486
+ return c.json({ project, created: true });
9487
+ } catch (err) {
9488
+ console.error(`[pages-broker] op=exit pub=${pub} result=error detail="${String(err)}"`);
9489
+ return c.json({ error: String(err) }, 500);
9490
+ } finally {
9491
+ await session.close();
9492
+ }
9493
+ });
9392
9494
  app3.get("/d1/list", async (c) => {
9393
9495
  const account = caller(c);
9394
9496
  if (!account) return c.json({ error: "no-caller" }, 403);
@@ -9658,7 +9760,7 @@ app3.post("/r2/object/delete", envelopeBodyLimit("write"), async (c) => {
9658
9760
  });
9659
9761
  var storage_broker_default = app3;
9660
9762
  async function runStorageAudit(root) {
9661
- const { reconcileStorage } = await import("./src-XQ63FPRE.js");
9763
+ const { reconcileStorage } = await import("./src-JJ6PHO5I.js");
9662
9764
  const cf = await makeHouseCfExec(root);
9663
9765
  const accountsDir = resolve11(root, "..", "data", "accounts");
9664
9766
  const strays = (await reconcileStorage({
@@ -9698,7 +9800,7 @@ async function runStorageAudit(root) {
9698
9800
  );
9699
9801
  }
9700
9802
  async function runPagesAudit(root) {
9701
- const { reconcilePages } = await import("./src-XQ63FPRE.js");
9803
+ const { reconcilePages } = await import("./src-JJ6PHO5I.js");
9702
9804
  const cf = await makeHousePagesExec(root);
9703
9805
  const r = await reconcilePages({
9704
9806
  cfProjects: async () => (await cf.pagesProjectList()).map((p) => p.name),
@@ -10981,6 +11083,9 @@ function readFrom(path3, from) {
10981
11083
  closeSync(fd);
10982
11084
  }
10983
11085
  }
11086
+ function resolveReplyAppendAccount(args) {
11087
+ return args.resolve(args.sendAccountId, args.counterpartyPhone) || args.sendAccountId;
11088
+ }
10984
11089
  function resumeOffset(lastEventId, fileEnd) {
10985
11090
  if (!lastEventId) return 0;
10986
11091
  const n = Number(lastEventId);
@@ -11670,9 +11775,14 @@ app5.post("/reply", requireAdminSession, async (c) => {
11670
11775
  // so the store reader renders it inline instead of a `[sent …]` text line.
11671
11776
  ...attachmentId ? { attachmentId } : {}
11672
11777
  };
11673
- appendMessage(accountId, rec);
11674
- const present = readConversation(accountId, remoteJid).some((r) => r.messageId === rec.messageId);
11675
- console.log(`${MANUAL_TAG} op=recorded sendId=${sendId} waMessageId=${waMessageId} present=${present} attachment=${attachmentId ? "yes" : "no"}`);
11778
+ const appendAccountId = resolveReplyAppendAccount({
11779
+ sendAccountId: accountId,
11780
+ counterpartyPhone: remoteJid.split("@")[0],
11781
+ resolve: resolveConversationPersistAccount
11782
+ });
11783
+ appendMessage(appendAccountId, rec);
11784
+ const present = readConversation(appendAccountId, remoteJid).some((r) => r.messageId === rec.messageId);
11785
+ console.log(`${MANUAL_TAG} op=recorded sendId=${sendId} waMessageId=${waMessageId} present=${present} appendAccount=${appendAccountId.slice(0, 8)} sendAccount=${acct8} attachment=${attachmentId ? "yes" : "no"}`);
11676
11786
  };
11677
11787
  let sent = 0;
11678
11788
  const sendStagedFile = async (file, label) => {
@@ -24472,14 +24582,25 @@ async function runConversationAudit() {
24472
24582
  size([p IN forensic WHERE p IS NOT NULL AND NOT p IN anchored]) AS unreconciled`,
24473
24583
  {}
24474
24584
  );
24585
+ const multiRes = await session.run(
24586
+ `MATCH (a:Conversation {channel: 'whatsapp'})
24587
+ WHERE a.channelAddress =~ '[0-9]+'
24588
+ WITH a.channelAddress AS addr, count(DISTINCT a.accountId) AS acctCount
24589
+ RETURN count(addr) AS senders,
24590
+ sum(CASE WHEN acctCount > 1 THEN 1 ELSE 0 END) AS multiAnchored`,
24591
+ {}
24592
+ );
24475
24593
  const rec = res.records[0];
24594
+ const multiRec = multiRes.records[0];
24476
24595
  const result = {
24477
24596
  total: Number(rec?.get("total") ?? 0),
24478
24597
  unreconciled: Number(rec?.get("unreconciled") ?? 0),
24479
- unpairable: Number(rec?.get("unpairable") ?? 0)
24598
+ unpairable: Number(rec?.get("unpairable") ?? 0),
24599
+ senders: Number(multiRec?.get("senders") ?? 0),
24600
+ multiAnchored: Number(multiRec?.get("multiAnchored") ?? 0)
24480
24601
  };
24481
24602
  console.error(
24482
- `${TAG48} channel=whatsapp total=${result.total} unreconciled=${result.unreconciled} unpairable=${result.unpairable}`
24603
+ `${TAG48} channel=whatsapp total=${result.total} senders=${result.senders} multiAnchored=${result.multiAnchored} unreconciled=${result.unreconciled} unpairable=${result.unpairable}`
24483
24604
  );
24484
24605
  return result;
24485
24606
  } catch (err) {
@@ -23,7 +23,7 @@ import {
23
23
  stripAccountWideTokens,
24
24
  tooLargeMessage,
25
25
  validateMapping
26
- } from "./chunk-3XLLTG6R.js";
26
+ } from "./chunk-REWXLAPC.js";
27
27
  import "./chunk-PFF6I7KP.js";
28
28
  export {
29
29
  D1_MAX_SQL_STATEMENT_BYTES,
@@ -1,2 +0,0 @@
1
- import{o as e}from"./chunk-TPjIAO9U.js";import{D as t,E as n,S as r,_ as i,a,d as o,i as s,l as c,m as l,n as u,o as d,p as f,s as p,t as m,u as h,v as g,x as _}from"./useSubAccountSwitcher-v8LyBzZN.js";import{c as ee,d as v,f as y,h as b,m as x,o as S,p as C,r as te,s as ne,t as re,u as w}from"./useSelectionMode-sph7AQT5.js";async function T(){try{let e=await fetch(`/api/onboarding/claude-auth`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({action:`logout`})});return e.ok?(await e.json().catch(()=>({})))?.logged_out===!0:(console.error(`[admin-ui] claude-logout http-status=${e.status}`),!1)}catch(e){return console.error(`[admin-ui] claude-logout fetch failed: ${e instanceof Error?e.message:String(e)}`),!1}}var E=e(t(),1),D=r(),O={sm:14,md:16,lg:18},ie={sm:30,md:38,lg:46};function k({variant:e=`primary`,size:t=`md`,icon:n,iconPosition:r=`leading`,loading:i=!1,fullWidth:a=!1,disabled:o=!1,type:s=`button`,onClick:c,"aria-label":l,"aria-pressed":u,style:d,className:f,children:p}){let m=[`btn`,`btn--${e}`,t===`md`?``:`btn--${t}`,a?`btn--full`:``,f].filter(Boolean).join(` `),h=O[t],g={...e===`send`?{width:ie[t],height:ie[t]}:{},...d},_=Object.keys(g).length>0;return(0,D.jsxs)(`button`,{type:s,className:m,disabled:i||o,onClick:c,"aria-label":l,"aria-pressed":u,style:_?g:void 0,children:[(0,D.jsxs)(`span`,{className:`btn__content`,style:{visibility:i?`hidden`:`visible`},children:[n&&r===`leading`&&(0,D.jsx)(n,{size:h}),p,n&&r===`trailing`&&(0,D.jsx)(n,{size:h})]}),i&&(0,D.jsx)(`span`,{className:`btn__spinner`,children:`✱`})]})}var A=i(`archive-restore`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h2`,key:`tvwodi`}],[`path`,{d:`M20 8v11a2 2 0 0 1-2 2h-2`,key:`1gkqxj`}],[`path`,{d:`m9 15 3-3 3 3`,key:`1pd0qc`}],[`path`,{d:`M12 12v9`,key:`192myk`}]]),j=i(`archive`,[[`rect`,{width:`20`,height:`5`,x:`2`,y:`3`,rx:`1`,key:`1wp1u1`}],[`path`,{d:`M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8`,key:`1s80jp`}],[`path`,{d:`M10 12h4`,key:`a56b0p`}]]),ae=i(`bot`,[[`path`,{d:`M12 8V4H8`,key:`hb8ula`}],[`rect`,{width:`16`,height:`12`,x:`4`,y:`8`,rx:`2`,key:`enze0r`}],[`path`,{d:`M2 14h2`,key:`vft8re`}],[`path`,{d:`M20 14h2`,key:`4cs60a`}],[`path`,{d:`M15 13v2`,key:`1xurst`}],[`path`,{d:`M9 13v2`,key:`rq6x2g`}]]),oe=i(`box`,[[`path`,{d:`M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z`,key:`hh9hay`}],[`path`,{d:`m3.3 7 8.7 5 8.7-5`,key:`g66t2b`}],[`path`,{d:`M12 22V12`,key:`d0xqtd`}]]),se=i(`gauge`,[[`path`,{d:`m12 14 4-4`,key:`9kzdfg`}],[`path`,{d:`M3.34 19a10 10 0 1 1 17.32 0`,key:`19p75a`}]]),ce=i(`history`,[[`path`,{d:`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,key:`1357e3`}],[`path`,{d:`M3 3v5h5`,key:`1xhq8a`}],[`path`,{d:`M12 7v5l4 2`,key:`1fdv2h`}]]),le=i(`list-todo`,[[`path`,{d:`M13 5h8`,key:`a7qcls`}],[`path`,{d:`M13 12h8`,key:`h98zly`}],[`path`,{d:`M13 19h8`,key:`c3s6r1`}],[`path`,{d:`m3 17 2 2 4-4`,key:`1jhpwq`}],[`rect`,{x:`3`,y:`4`,width:`6`,height:`6`,rx:`1`,key:`cif1o7`}]]),M=i(`message-square`,[[`path`,{d:`M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z`,key:`18887p`}]]),ue=i(`sliders-horizontal`,[[`path`,{d:`M10 5H3`,key:`1qgfaw`}],[`path`,{d:`M12 19H3`,key:`yhmn1j`}],[`path`,{d:`M14 3v4`,key:`1sua03`}],[`path`,{d:`M16 17v4`,key:`1q0r14`}],[`path`,{d:`M21 12h-9`,key:`1o4lsq`}],[`path`,{d:`M21 19h-5`,key:`1rlt1p`}],[`path`,{d:`M21 5h-7`,key:`1oszz2`}],[`path`,{d:`M8 10v4`,key:`tgpxqk`}],[`path`,{d:`M8 12H3`,key:`a7s4jb`}]]),de=i(`users`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`path`,{d:`M16 3.128a4 4 0 0 1 0 7.744`,key:`16gr8j`}],[`path`,{d:`M22 21v-2a4 4 0 0 0-3-3.87`,key:`kshegd`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}]]),N=`maxy-shell-side-px`;function fe(){if(typeof window>`u`)return 0;let e=document.querySelector(`.platform > .artefact`)?.getBoundingClientRect();return e&&e.width>0?Math.round(e.width):0}function P(e){if(typeof window>`u`)return e;let t=window.innerWidth,n=Math.max(248,t-480-fe());return Math.min(Math.max(e,248),n)}function pe(){if(typeof window>`u`)return 264;try{let e=window.localStorage.getItem(N);if(!e)return 264;let t=parseInt(e,10);if(!Number.isFinite(t))return console.warn(`[admin-ui] sidebar-width-parse-failed stored=${JSON.stringify(e)} fallback=264`),264;if(t>=248)return P(t)}catch{}return 264}function F({targetSelector:e=`.platform`}){let t=(0,E.useRef)(null),[n,r]=(0,E.useState)(()=>pe()),i=(0,E.useRef)(n);(0,E.useLayoutEffect)(()=>{let t=document.querySelector(e);!t||!(t instanceof HTMLElement)||(t.style.setProperty(`--side-px`,`${n}px`),i.current=n)},[n,e]);let a=(0,E.useCallback)(()=>{r(e=>{let t=P(e);return t===e?e:t})},[]);(0,E.useEffect)(()=>{a(),window.addEventListener(`resize`,a);let t=document.querySelector(e),n=null;return t instanceof HTMLElement&&(n=new MutationObserver(a),n.observe(t,{attributes:!0,attributeFilter:[`data-artefact`,`class`]})),()=>{window.removeEventListener(`resize`,a),n?.disconnect()}},[a,e]);let o=e=>{e.preventDefault();let n=t.current;if(!n)return;n.setPointerCapture(e.pointerId),n.classList.add(`dragging`);let a=!1,o=e=>{a=!0,r(P(Math.round(e.clientX)))},s=()=>{if(n.releasePointerCapture(e.pointerId),n.classList.remove(`dragging`),window.removeEventListener(`pointermove`,o),window.removeEventListener(`pointerup`,s),!a)return;let t=i.current;try{window.localStorage.setItem(N,String(t))}catch{}console.info(`[admin-ui] sidebar-resize px=${t}`)};window.addEventListener(`pointermove`,o),window.addEventListener(`pointerup`,s)},s=()=>{let e=P(264);r(e);try{window.localStorage.removeItem(N)}catch{}console.info(`[admin-ui] sidebar-resize px=${e}`)};return(0,D.jsx)(`div`,{ref:t,className:`side-resize-handle`,role:`separator`,"aria-orientation":`vertical`,"aria-label":`Resize sidebar`,onPointerDown:o,onDoubleClick:s})}var me=n();function he(e){return Math.max(14,e/2-386)}function ge(e){return e.left===0&&e.top===0&&e.width===0&&e.height===0}var _e={position:`fixed`,visibility:`hidden`};function I({anchorRef:e,onClose:t,className:n,role:r,ariaLabel:i,anchorId:a,children:o}){let s=(0,E.useRef)(null),[c,l]=(0,E.useState)(_e),u=(0,E.useRef)(null),d=(0,E.useCallback)(()=>{let t=s.current;if(!t)return;let r=e.current,i=[n,a].filter(Boolean).join(`:`)||`unknown`,o=t.getBoundingClientRect(),c=window.innerWidth,d=window.innerHeight,f=o.width>0&&o.height>0,p=r?r.getBoundingClientRect():null,m=(e,t)=>console.error(`[anchored-popover] op=offscreen id=${i} left=${e} top=${t} w=${o.width} h=${o.height} viewport=${c},${d}`),h=e=>{e!==u.current&&(u.current=e,console.log(e))};if(h(`[anchored-popover] op=anchor id=${i} present=${!!r} rect=${p?`${p.left},${p.top},${p.width},${p.height}`:`none`}`),!p){let e=Math.max(4,c-o.width-he(c)),t=Math.max(4,d-o.height-14);l({position:`fixed`,left:e,top:t,visibility:`visible`}),h(`[anchored-popover] op=placed id=${i} left=${e} top=${t} w=${o.width} h=${o.height} flipped=false clampedLeft=false clampedRight=false`);return}if(f&&ge(p)){l(_e),m(p.left,p.top);return}let g=p.right-o.width,_=c-o.width-4,ee=!1,v=!1;g>_&&(g=_,ee=!0),g<4&&(g=4,v=!0);let y=d-p.bottom-4,b=p.top-4,x=o.height+8<=y?!1:o.height+8<=b?!0:b>y,S=Math.max(0,x?b:y),C=x?Math.max(4,p.top-Math.min(o.height,S)):p.bottom;l({position:`fixed`,left:g,top:C,maxHeight:S,visibility:`visible`}),h(`[anchored-popover] op=placed id=${i} left=${g} top=${C} w=${o.width} h=${o.height} maxH=${S} flipped=${x} clampedLeft=${v} clampedRight=${ee}`);let te=Math.min(o.height,S);f&&(g+o.width<=0||g>=c||C+te<=0||C>=d)&&m(g,C)},[e,a,n]);return(0,E.useLayoutEffect)(()=>{if(d(),typeof ResizeObserver>`u`)return;let e=new ResizeObserver(()=>d());return s.current&&e.observe(s.current),()=>e.disconnect()},[d]),(0,E.useEffect)(()=>{let n=e=>{e.key===`Escape`&&t()},r=n=>{let r=n.target;e.current?.contains(r)||s.current?.contains(r)||t()},i=n=>{let r=e.current;r&&n.target instanceof Node&&n.target.contains(r)&&t()},a=()=>t();return document.addEventListener(`keydown`,n),document.addEventListener(`pointerdown`,r),window.addEventListener(`scroll`,i,!0),window.addEventListener(`resize`,a),()=>{document.removeEventListener(`keydown`,n),document.removeEventListener(`pointerdown`,r),window.removeEventListener(`scroll`,i,!0),window.removeEventListener(`resize`,a)}},[e,t]),(0,me.createPortal)((0,D.jsx)(`div`,{ref:s,className:n,role:r,"aria-label":i,style:c,children:o}),document.body)}function ve({actions:e,disabled:t}){let[n,r]=(0,E.useState)(!1),[i,a]=(0,E.useState)(null),o=(0,E.useRef)(null),s=(0,E.useCallback)(()=>{r(!1),a(null)},[]);return(0,D.jsxs)(`div`,{className:`conv-actions`,children:[(0,D.jsx)(`button`,{ref:o,type:`button`,className:`conv-action conv-actions-overflow`,onClick:()=>r(e=>!e),disabled:t,"aria-haspopup":`menu`,"aria-expanded":n,"aria-label":`Session actions`,title:`Session actions`,children:(0,D.jsx)(h,{size:12})}),n&&(0,D.jsx)(I,{anchorRef:o,onClose:s,className:`conv-actions-menu`,role:`menu`,children:e.map(e=>e.panel?(0,D.jsxs)(`div`,{className:`conv-actions-menu-disclosure`,children:[(0,D.jsxs)(`button`,{type:`button`,role:`menuitem`,"aria-haspopup":`dialog`,"aria-expanded":i===e.key,disabled:t,onClick:()=>a(t=>t===e.key?null:e.key),children:[e.icon,(0,D.jsx)(`span`,{children:e.menuLabel})]}),i===e.key&&(0,D.jsx)(`div`,{className:`conv-actions-menu-panel`,children:e.panel()})]},e.key):(0,D.jsxs)(`button`,{type:`button`,role:`menuitem`,className:e.danger?`conv-action-danger`:void 0,"aria-busy":e.busy,disabled:t,onClick:t=>{e.onClick?.(t),s()},children:[e.icon,(0,D.jsx)(`span`,{children:e.menuLabel})]},e.key))})]})}var L=`claude-opus-4-8[1m]`,R=`claude-sonnet-5`,ye=`claude-haiku-4-5`,be={[L]:`Opus 4.8 (1M context)`,[R]:`Sonnet 5`,[ye]:`Haiku 4.5`};function xe(e){return be[e]??e}var Se=[L,R,ye];function z(e){return e.replace(/\[1m\]$/,``)}function Ce(e){return Se.find(t=>z(t)===z(e))??e}var we=[`default`,`acceptEdits`,`plan`,`auto`,`bypassPermissions`],B=[`low`,`medium`,`high`,`xhigh`];[...we],[...B],[...B];var Te=[L,R,ye],V={default:`Ask permissions`,acceptEdits:`Accept edits`,plan:`Plan mode`,auto:`Auto mode`,bypassPermissions:`Bypass permissions`},H=we.map(e=>({value:e,label:V[e]??e})),Ee={low:`Low`,medium:`Medium`,high:`High`,xhigh:`Highest`},U=B.map(e=>({value:e,label:Ee[e]??e}));function De(e){if(e){let t=Te.find(t=>z(t)===z(e));if(t)return t}return L}function Oe({row:e,adminFetch:t,onError:n}){let[r,i]=(0,E.useState)(()=>De(e.model)),[a,s]=(0,E.useState)(``),[c,l]=(0,E.useState)(``),[u,d]=(0,E.useState)(!1),f=(0,E.useRef)(!1);(0,E.useEffect)(()=>{i(De(e.model))},[e.model]);let p=async()=>{if(!f.current){f.current=!0,d(!0);try{let i=await t(`/api/admin/session-reseat`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({fromSessionId:e.sessionId,model:r,...a?{permissionMode:a}:{},...c?{effort:c}:{}})});if(!i.ok){n(`Could not reset ${e.title} (status ${i.status})`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} status=${i.status}`),f.current=!1,d(!1);return}let o=await i.json().catch(()=>({}));o.target?window.location.assign(o.target):(n(`Reset of ${e.title} returned no target`),f.current=!1,d(!1))}catch(t){n(`Could not reset ${e.title} (network error)`),console.error(`[admin-ui] dashboard-reseat-failed sessionId=${e.sessionId} error=${t instanceof Error?t.message:String(t)}`),f.current=!1,d(!1)}}};return(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Model`}),(0,D.jsx)(`select`,{"data-kind":`model`,value:r,disabled:u,onChange:e=>i(e.target.value),children:Te.map(e=>(0,D.jsx)(`option`,{value:e,children:xe(e)},e))})]}),(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Mode`}),(0,D.jsxs)(`select`,{"data-kind":`mode`,value:a,disabled:u,onChange:e=>s(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Keep current`}),H.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,D.jsxs)(`label`,{className:`reseat-field`,children:[(0,D.jsx)(`span`,{children:`Effort`}),(0,D.jsxs)(`select`,{"data-kind":`effort`,value:c,disabled:u,onChange:e=>l(e.target.value),children:[(0,D.jsx)(`option`,{value:``,children:`Keep current`}),U.map(e=>(0,D.jsx)(`option`,{value:e.value,children:e.label},e.value))]})]}),(0,D.jsx)(`button`,{type:`button`,className:`reseat-apply`,disabled:u,"aria-busy":u,onClick:()=>void p(),children:u?(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(o,{size:12,className:`spin`,"aria-hidden":`true`}),`Resetting…`]}):`Reset`})]})}function ke(e){if(e<60)return`${e}s`;let t=Math.floor(e/60),n=e%60;return n>0?`${t}m ${n}s`:`${t}m`}function W(e){return e>=1e3?`${(e/1e3).toFixed(1)}k`:String(e)}function Ae({target:e,anchorEl:t,onConfirm:n,onCancel:r}){let i=(0,E.useRef)(null);return i.current=t,e?(0,D.jsxs)(I,{anchorRef:i,onClose:r,className:`conv-delete-confirm`,role:`alertdialog`,ariaLabel:`Confirm delete session`,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`span`,{children:`Delete this conversation?`}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:r,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[(0,D.jsxs)(`div`,{className:`conv-delete-target`,children:[(0,D.jsx)(`span`,{className:`conv-delete-label`,title:e.title,children:e.title||`Untitled session`}),(0,D.jsx)(`code`,{className:`conv-delete-id`,title:e.sessionId,children:e.sessionId.slice(0,8)})]}),(0,D.jsx)(`div`,{style:{marginTop:`8px`},children:`This permanently removes the transcript. It is not moved to Archive and cannot be recovered.`}),e.live&&(0,D.jsx)(`div`,{style:{marginTop:`8px`},children:`This session is running; deleting stops it first.`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,D.jsx)(k,{variant:`danger`,size:`sm`,style:{flex:1},onClick:n,children:`Delete`}),(0,D.jsx)(k,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:r,children:`Cancel`})]})]}):null}function je({open:e,count:t,liveCount:n,onConfirm:r,onCancel:i}){if(!e)return null;let a=t===1?``:`s`;return(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:i,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Confirm delete sessions`,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsxs)(`span`,{children:[`Delete `,t,` conversation`,a,`?`]}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:i,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[`This permanently removes `,t,` transcript`,a,`. `,t===1?`It is`:`They are`,` not moved to Archive and cannot be recovered.`,n>0&&(0,D.jsxs)(`div`,{style:{marginTop:`8px`},children:[n,` `,n===1?`is`:`are`,` running and will be stopped first.`]})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{display:`flex`,gap:`8px`,padding:`10px 14px`},children:[(0,D.jsxs)(k,{variant:`danger`,size:`sm`,style:{flex:1},onClick:r,children:[`Delete `,t]}),(0,D.jsx)(k,{variant:`secondary`,size:`sm`,style:{flex:1},onClick:i,children:`Cancel`})]})]})})}var Me=`auth-refresh-failed`;function Ne({error:e,onClose:t}){if(!e)return null;let n=e.reason===Me,r=n?`Claude sign-in expired`:`Session didn’t open`,i=n?`Your claude.ai login has expired. Re-authenticate to resume sessions.`:`The session did not bind within 60 seconds, so there is no live conversation to open.`;return(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:t,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Session could not be opened`,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`span`,{children:r}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`},children:[i,(0,D.jsxs)(`div`,{className:`claude-info-row`,style:{marginTop:`8px`},children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Reason`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:e.reason})]}),e.sessionId&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[e.sessionId.slice(0,8),`…`]})]})]})]})})}function G(e){let{show:t,onClose:n,claudeInfo:r,messages:i,sessionElapsed:a,sessionId:o,cacheKey:s}=e,[c,l]=(0,E.useState)(null);if(!t)return null;let u=i.flatMap(e=>e.events?.filter(e=>e.type===`usage`)??[]),d=u.at(-1),f=d?.peak_request_pct==null?d?.context_window?Math.round((d.input_tokens+d.cache_creation_tokens+d.cache_read_tokens)/d.context_window*100):0:Math.round(d.peak_request_pct*100),p=u.reduce((e,t)=>e+t.input_tokens+t.cache_creation_tokens+t.cache_read_tokens+t.output_tokens,0),m=i.flatMap(e=>e.events?.filter(e=>e.type===`rate_limit`)??[]).at(-1),h=u.reduce((e,t)=>e+(t.total_cost_usd??0),0),g=r?.account?.subscriptionType,_=e=>{let t=e*1e3-Date.now();if(t<=0)return`now`;let n=Math.floor(t/36e5),r=Math.floor(t%36e5/6e4);return n>0?`${n}h ${r}m`:`${r}m`};return(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`claude-info-icon`}),(0,D.jsx)(`span`,{children:`Claude Code`}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Version`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?r.version:`…`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Email`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?.account?.email??`…`})]})]}),(g||m||h>0)&&(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[g&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Plan`}),(0,D.jsx)(`span`,{className:`claude-info-value`,style:{textTransform:`capitalize`},children:g})]}),m&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Usage`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[Math.round(m.utilization*100),`%`]})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Resets in`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:_(m.resetsAt)})]}),m.isUsingOverage&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Overage`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:`Active`})]})]}),h>0&&(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session cost`}),(0,D.jsxs)(`span`,{className:`claude-info-value`,children:[`$`,h<.01?h.toFixed(4):h.toFixed(2)]})]})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,children:[(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Model`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:r?.model??`…`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Context used`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:f>0?`${f}%`:`—`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Tokens`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:p>0?W(p):`—`})]}),(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsx)(`span`,{className:`claude-info-value`,children:ke(a)})]}),(o||s)&&(()=>{let e=o??s??``;return(0,D.jsxs)(`div`,{className:`claude-info-row`,children:[(0,D.jsx)(`span`,{className:`claude-info-label`,children:`Session`}),(0,D.jsx)(`button`,{type:`button`,className:`claude-info-value claude-info-id-copy`,title:`${e} (${o?`flushed`:`pre-flush`}) — click to copy`,onClick:async()=>{l(await re(e)?`copied`:`failed`),setTimeout(()=>l(null),1200)},children:c===`copied`?`copied ✓`:c===`failed`?`copy failed ✕`:`${e.slice(0,8)}…`})]})})()]})]})})}function Pe({open:e,onConnect:t,onClose:n}){return e?(0,D.jsx)(`div`,{className:`claude-info-overlay`,onClick:n,children:(0,D.jsxs)(`div`,{className:`claude-info-modal`,onClick:e=>e.stopPropagation(),role:`alertdialog`,"aria-label":`Claude is not connected`,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsx)(`span`,{children:`Claude isn’t connected`}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:n,"aria-label":`Close`,children:`✕`})]}),(0,D.jsxs)(`div`,{className:`claude-info-section`,style:{padding:`12px 14px`,fontSize:`11px`,color:`var(--text-secondary)`,display:`flex`,flexDirection:`column`,gap:`10px`},children:[(0,D.jsx)(`span`,{children:`This needs Claude, which is currently disconnected. Connect to continue — the rest of the dashboard stays available either way.`}),(0,D.jsxs)(`div`,{style:{display:`flex`,gap:`8px`,alignItems:`center`},children:[(0,D.jsx)(k,{variant:`primary`,size:`sm`,onClick:t,children:`Connect Claude`}),(0,D.jsx)(`button`,{type:`button`,className:`claude-info-close`,style:{fontSize:`11px`},onClick:n,children:`Not now`})]})]})]})}):null}function K(e){let t=Math.round(e/6e4),n=Math.floor(t/60),r=t%60;return`${n}h ${String(r).padStart(2,`0`)}m`}function Fe(e){return e.activeMs.thinking+e.activeMs.messaging+e.activeMs.toolUse}function q(e){return e.toLocaleString(`en-GB`)}function Ie(e){return`£${e.toFixed(2)}`}function Le(e){let t=[`Day`,`Active`,`Output tokens`,`Input tokens`,`Cache write`,`Cache read`,`Opus 4.8 (GBP)`,`Sonnet 4.6 (GBP)`],n=(e,t)=>[e,K(Fe(t)),String(t.tokens.output),String(t.tokens.input),String(t.tokens.cacheWrite),String(t.tokens.cacheRead),t.costGBP.opus.toFixed(2),t.costGBP.sonnet.toFixed(2)];return[t,...e.days.map(e=>n(e.date,e)),n(`TOTAL (${e.days.length} d)`,e.totals)].map(e=>e.join(`,`)).join(`
2
- `)}function Re({label:e,d:t,bold:n}){let r=n?`th`:`td`;return(0,D.jsxs)(`tr`,{className:n?`usage-total-row`:void 0,children:[(0,D.jsx)(r,{className:`usage-day`,children:e}),(0,D.jsx)(r,{children:K(Fe(t))}),(0,D.jsx)(r,{children:q(t.tokens.output)}),(0,D.jsx)(r,{children:q(t.tokens.input)}),(0,D.jsx)(r,{children:q(t.tokens.cacheWrite)}),(0,D.jsx)(r,{children:q(t.tokens.cacheRead)}),(0,D.jsx)(r,{children:Ie(t.costGBP.opus)}),(0,D.jsx)(r,{children:Ie(t.costGBP.sonnet)})]})}function ze({show:e,onClose:t,anchorEl:n,sessionId:r,summary:i,loading:o,error:s}){let c=(0,E.useRef)(null);if(c.current=n,!e)return null;let l=!!i&&i.days.length>0;return(0,D.jsxs)(I,{anchorRef:c,onClose:t,className:`usage-popover`,role:`dialog`,ariaLabel:`Session usage and cost`,anchorId:r??void 0,children:[(0,D.jsxs)(`div`,{className:`claude-info-header`,children:[(0,D.jsxs)(`span`,{children:[`Usage & cost`,r?` · ${r.slice(0,8)}`:``]}),l&&(0,D.jsx)(`button`,{className:`usage-download`,onClick:()=>{if(!i)return;let e=new Blob([Le(i)],{type:`text/csv;charset=utf-8`}),t=URL.createObjectURL(e),n=document.createElement(`a`);n.href=t,n.download=`usage-${r?r.slice(0,8):`session`}.csv`,document.body.appendChild(n),n.click(),n.remove(),URL.revokeObjectURL(t)},"aria-label":`Download as CSV`,title:`Download as CSV`,children:(0,D.jsx)(b,{size:14})}),(0,D.jsx)(`button`,{className:`claude-info-close`,onClick:t,"aria-label":`Close`,children:(0,D.jsx)(a,{size:14})})]}),(0,D.jsxs)(`div`,{className:`claude-info-section usage-body`,children:[o&&(0,D.jsx)(`div`,{className:`usage-note`,children:`Computing usage…`}),!o&&s&&(0,D.jsx)(`div`,{className:`usage-note usage-error`,children:s}),!o&&!s&&i&&i.days.length===0&&(0,D.jsx)(`div`,{className:`usage-note`,children:`No usage recorded for this session yet.`}),!o&&!s&&i&&i.days.length>0&&(0,D.jsxs)(D.Fragment,{children:[(0,D.jsx)(`div`,{className:`usage-table-scroll`,children:(0,D.jsxs)(`table`,{className:`usage-table`,children:[(0,D.jsx)(`thead`,{children:(0,D.jsxs)(`tr`,{children:[(0,D.jsx)(`th`,{className:`usage-day`,children:`Day`}),(0,D.jsx)(`th`,{children:`Active`}),(0,D.jsx)(`th`,{children:`Output tok`}),(0,D.jsx)(`th`,{children:`Input tok`}),(0,D.jsx)(`th`,{children:`Cache write`}),(0,D.jsx)(`th`,{children:`Cache read`}),(0,D.jsx)(`th`,{children:`Opus 4.8 (£)`}),(0,D.jsx)(`th`,{children:`Sonnet 4.6 (£)`})]})}),(0,D.jsxs)(`tbody`,{children:[i.days.map(e=>(0,D.jsx)(Re,{label:e.date,d:e},e.date)),(0,D.jsx)(Re,{label:`TOTAL (${i.days.length} d)`,d:i.totals,bold:!0})]})]})}),(0,D.jsxs)(`div`,{className:`usage-note usage-caveats`,children:[`Prices dated `,i.pricing.opusPriceDate,` · £/$ `,i.pricing.usdPerGbp,` · Sonnet tokenizer factor `,i.pricing.tokenizerFactor,`. Idle human-wait dominates the calendar span; cache-read tokens dominate cost; Sonnet is a tokenizer-adjusted estimate.`]})]})]})]})}var Be=`https://claude.ai/code`,Ve=200,He=[500,1e3,1500,2e3,2500,3e3,3e3];function Ue(e,t,n){if(e&&n.target)return{kind:`navigate`,url:n.target,sameOrigin:!0};let r=n.slug??n.bridgeSessionId??null;if(e&&r)return{kind:`navigate`,url:`${Be}/${r}`,sameOrigin:!1};let i=n.reason||n.error||`status ${t}`;return{kind:`error`,sessionId:n.sessionId??null,reason:i}}function We(e){if(!e)return``;let t=Date.parse(e);return Number.isFinite(t)?new Date(t).toLocaleString(void 0,{dateStyle:`medium`,timeStyle:`short`}):``}function Ge(e){let{businessName:t,cacheKey:n,onConnectClaude:r,role:i,userName:a,userAvatar:o,onSelectProjects:u,onSelectPeople:m,onSelectTasks:h,onSelectAgents:re,onCloseMobileDrawer:T,collapsed:O,selectedWhatsappId:ie,onSelectWhatsappConversation:k,initialWhatsappSurface:N=!1,onSelectData:fe,onCloseData:P,initialDataSurface:pe=!1}=e,F=s(n),me=(0,E.useCallback)(e=>({key:`reseat`,label:`Reset session ${e.title} (model, mode, effort)`,menuLabel:`Reset`,title:`Reset — move this session onto a chosen model, mode, and effort`,icon:(0,D.jsx)(ue,{size:12}),panel:()=>(0,D.jsx)(Oe,{row:e,adminFetch:F,onError:e=>H({message:e,failed:!0})})}),[F]),he=g.productName,ge=typeof a==`string`?a:a===null?`name unavailable`:t||he,_e=(ge.trim().charAt(0)||`?`).toUpperCase(),[I,L]=(0,E.useState)(pe?`data`:N?`whatsapp`:`sessions`),[R,ye]=(0,E.useState)([]),[be,xe]=(0,E.useState)(!1),[Se,z]=(0,E.useState)(null),[Ce,we]=(0,E.useState)(!1),[B,Te]=(0,E.useState)(`file`),[V,H]=(0,E.useState)(null),[Ee,U]=(0,E.useState)(null),[De,ke]=(0,E.useState)(!1),[W,Me]=(0,E.useState)([]),[G]=(0,E.useState)(()=>typeof window>`u`?null:new URLSearchParams(window.location.search).get(`session`)),[K,Fe]=(0,E.useState)(!1),[q,Ie]=(0,E.useState)(null),[Le,Re]=(0,E.useState)(!1),[Be,Ge]=(0,E.useState)(!1),[Ke,Xe]=(0,E.useState)(!1),[Ze,Qe]=(0,E.useState)(null),[$e,et]=(0,E.useState)(new Set),tt=(0,E.useRef)(new Map),[J,nt]=(0,E.useState)(!1),[Y,rt]=(0,E.useState)(new Set),[it,at]=(0,E.useState)(!1),[X,ot]=(0,E.useState)(null),[st,ct]=(0,E.useState)(new Set),[lt,ut]=(0,E.useState)(new Set),[dt,ft]=(0,E.useState)(new Set),[pt,mt]=(0,E.useState)(null),[ht,Z]=(0,E.useState)(``),[gt,_t]=(0,E.useState)(!1),[vt,yt]=(0,E.useState)(null),[bt,xt]=(0,E.useState)(null),[St,Ct]=(0,E.useState)(!1),[wt,Tt]=(0,E.useState)(null),[Et,Dt]=(0,E.useState)(!1),Ot=(0,E.useRef)(0),[kt,At]=(0,E.useState)([]),[jt,Mt]=(0,E.useState)(!1),[Nt,Pt]=(0,E.useState)(null),[Ft,It]=(0,E.useState)(`whatsapp`),Lt=(0,E.useCallback)(e=>{if(T(),!n){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=no-cache-key`),H({message:`Session not ready — try again`,failed:!0});return}if(!e.downloadPath){console.error(`[admin-ui] artefact-download-blocked id=${e.id} reason=not-downloadable`),H({message:`${e.name} can’t be downloaded`,failed:!0});return}console.info(`[admin-ui] artefact-download id=${e.id} root=${e.downloadRoot??`data`} path=${e.downloadPath}`),te(n,e.downloadPath,e.downloadRoot??`data`),H({message:`Downloading ${e.name}`,failed:!1})},[n,T]);(0,E.useEffect)(()=>{if(!V)return;let e=setTimeout(()=>H(null),2500);return()=>clearTimeout(e)},[V]);let Rt=G!=null&&W.some(e=>e.sessionId===G);(0,E.useEffect)(()=>{G==null||!K||console.info(`[sidebar-sessions] op=select-highlight session=${G.slice(0,8)} matched=${Rt}`)},[G,Rt,K]);let zt=(0,E.useCallback)(async()=>{if(n){we(!0),z(null);try{let e=await F(`/api/admin/sidebar-artefacts`);if(!e.ok)throw Error(`status ${e.status}`);ye((await e.json()).artefacts??[]),xe(!0)}catch(e){let t=e instanceof Error?e.message:String(e);z(`Failed to load artefacts: ${t}`),console.error(`[admin-ui] sidebar-artefacts fetch failed: ${t}`)}finally{we(!1)}}},[n,F]),Q=(0,E.useCallback)(async()=>{if(!n)return null;let e=++Ot.current;Re(!0),Ie(null);try{let t=await F(`/api/admin/sidebar-sessions`);if(!t.ok)throw Error(`status ${t.status}`);let n=await t.json(),r=n.sessions??[];return e===Ot.current?(Me(r),Qe(n.accountId??null),Fe(!0),r):(console.info(`[admin-ui] sidebar-sessions-stale-response-dropped token=${e}`),r)}catch(t){let n=t instanceof Error?t.message:String(t);return e===Ot.current&&Ie(`Failed to load sessions: ${n}`),console.error(`[admin-ui] sidebar-sessions fetch failed: ${n}`),null}finally{e===Ot.current&&Re(!1)}},[n,F]),Bt=(0,E.useCallback)(async()=>{if(n){Pt(null);try{let e=await F(`/api/whatsapp-reader/conversations`);if(!e.ok)throw Error(`status ${e.status}`);At((await e.json()).conversations??[]),Mt(!0)}catch(e){let t=e instanceof Error?e.message:String(e);Pt(`Couldn't load conversations.`),console.error(`[admin-ui] channel-convos fetch failed: ${t}`)}}},[n,F]);(0,E.useEffect)(()=>{!n||K||Q()},[n,K,Q]),(0,E.useEffect)(()=>{if(!n)return;let e=null;return Bt(),e=setInterval(()=>{Bt()},qe),()=>{e!==null&&clearInterval(e)}},[n,Bt]),(0,E.useEffect)(()=>{if(!n)return;let e=null;function t(){console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=poll`),Q()}function r(){e===null&&(e=setInterval(t,Je))}function i(){e!==null&&(clearInterval(e),e=null)}function a(){document.hidden?i():(t(),r())}return document.hidden||r(),document.addEventListener(`visibilitychange`,a),()=>{i(),document.removeEventListener(`visibilitychange`,a)}},[n,Q]);let Vt=(0,E.useMemo)(()=>{let e=new Map;for(let t of ne)e.set(t,[]);for(let t of kt)e.get(t.channel)?.push(t);for(let t of ne)console.info(`[admin-ui] sidebar-nav surface=${t} count=${e.get(t).length}`);return e},[kt]),Ht={whatsapp:`WhatsApp`,telegram:`Telegram`,webchat:`Webchat`},Ut=()=>{k(null),L(`artefacts`),console.info(`[admin-ui] sidebar-nav surface=artefacts count=${be?R.length:0} collapsed=${O}`),zt()},$=1.5,Wt=()=>{console.info(`[admin-ui] sidebar-refresh surface=artefacts`),zt()},Gt=()=>{k(null),L(`sessions`),console.info(`[admin-ui] sidebar-nav surface=sessions count=${K?W.length:0} collapsed=${O}`),K||Q()},Kt=()=>{console.info(`[admin-ui] sidebar-refresh surface=sessions trigger=manual`),Q()},qt=()=>{L(`data`),console.info(`[admin-ui] sidebar-nav surface=data collapsed=${O}`),fe(),T()},Jt=e=>{P?.(),L(`whatsapp`),It(e),console.info(`[admin-ui] sidebar-nav surface=${e} count=${Vt.get(e)?.length??0} collapsed=${O}`)},Yt=(0,E.useCallback)(async e=>{if(st.has(e.sessionId))return;ct(t=>{let n=new Set(t);return n.add(e.sessionId),n});let t=window.open(``,`_blank`);try{let n=await F(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,name:e.title||e.sessionId,...e.accountId?{targetAccountId:e.accountId}:{}})}),r=await n.json().catch(()=>({})),i=Ue(n.ok,n.status,{...r,sessionId:r.sessionId??e.sessionId});console.info(`[admin-ui] sidebar-session-resume sessionId=${e.sessionId} status=${n.status} outcome=${i.kind} slug=${r.slug??r.bridgeSessionId??`none`}`),i.kind===`navigate`?(T(),t?t.location.href=i.url:window.open(i.url,`_blank`)):(t?.close(),console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} status=${n.status} reason=${i.reason}`),U(i))}catch(n){t?.close();let r=n instanceof Error?n.message:String(n);console.error(`[admin-ui] sidebar-session-resume-failed sessionId=${e.sessionId} error=${r}`),U({sessionId:e.sessionId,reason:r})}finally{ct(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[F,T,st]),Xt=(0,E.useCallback)(async e=>{let t=e.slice(0,8);for(let n=1;n<=He.length;n++){await new Promise(e=>setTimeout(e,He[n-1]));let r=await Q();if(r&&r.some(t=>t.sessionId===e)){console.info(`[admin-ui] sidebar-new-session-converged sessionId=${t} via=retry attempts=${n}`);return}}console.error(`[admin-ui] sidebar-new-session-converge-timeout sessionId=${t}`)},[Q]),Zt=(0,E.useCallback)(async()=>{if(!Et){Dt(!0);try{let e=await F(`/api/admin/session-rc-spawn`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({})}),t=await e.json().catch(()=>({})),n=Ue(e.ok,e.status,t);console.info(`[admin-ui] sidebar-new-session-spawned status=${e.status} outcome=${n.kind} slug=${t.slug??t.bridgeSessionId??`none`}`),n.kind===`navigate`?n.sameOrigin?window.location.assign(n.url):(window.open(n.url,`_blank`),t.sessionId?Xt(t.sessionId):console.error(`[admin-ui] sidebar-new-session-converge-skipped reason=no-session-id`)):e.status===503||n.reason===`claude-auth-dead`?(console.info(`[admin-ui] op=llm-action-blocked action=spawn reason=claude-disconnected`),ke(!0)):(console.error(`[admin-ui] sidebar-new-session-failed status=${e.status} reason=${n.reason}`),U(n))}catch(e){let t=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-new-session-failed error=${t}`),U({sessionId:null,reason:t})}finally{Dt(!1)}}},[F,Et,Xt]),Qt=(0,E.useCallback)((e,t)=>{e.stopPropagation(),ot(t)},[]),$t=(0,E.useCallback)(async(e,t)=>{e.stopPropagation(),yt(t),xt(null),Tt(null),Ct(!0);try{let e=await F(`/api/admin/session-usage?sessionId=${encodeURIComponent(t.sessionId)}`),n=await e.json().catch(()=>({}));e.ok?xt(n):Tt(n.error??`status ${e.status}`)}catch(e){Tt(e instanceof Error?e.message:String(e))}finally{Ct(!1)}},[F]),en=(0,E.useCallback)(async(e,t={})=>{let n=t.refresh??!0;if($e.has(e.sessionId))return!1;et(t=>{let n=new Set(t);return n.add(e.sessionId),n});try{let t=await F(`/api/admin/session-delete`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId})});if(!t.ok){let n=await t.json().catch(()=>({}));return console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} status=${t.status} error=${n.error??`unknown`}`),H({message:`Delete failed: ${n.error??`status ${t.status}`}`,failed:!0}),!1}let r=await t.json();return console.info(`[admin-ui] sidebar-session-delete sessionId=${e.sessionId} live=${e.live} confirmed=true pidKilled=${r.pidKilled??`?`} deleted=${r.deleted??`?`}`),Me(t=>t.filter(t=>t.sessionId!==e.sessionId)),n&&Q(),!0}catch(t){let n=t instanceof Error?t.message:String(t);return console.error(`[admin-ui] sidebar-session-delete-failed sessionId=${e.sessionId} error=${n}`),H({message:`Delete failed: ${n}`,failed:!0}),!1}finally{et(t=>{let n=new Set(t);return n.delete(e.sessionId),n})}},[F,$e,Q]),tn=(0,E.useCallback)(e=>{rt(t=>{let n=new Set(t);return n.has(e)?n.delete(e):n.add(e),n})},[]),nn=(0,E.useCallback)(()=>{nt(!1),rt(new Set)},[]),rn=(0,E.useCallback)(async()=>{let e=[...Y].map(e=>W.find(t=>t.sessionId===e)).filter(e=>!!e),t=e.filter(e=>e.live).length;console.info(`[admin-ui] sidebar-bulk-delete op=start count=${e.length} live=${t}`);let n=(await Promise.all(e.map(e=>en(e,{refresh:!1})))).filter(Boolean).length;console.info(`[admin-ui] sidebar-bulk-delete op=done requested=${e.length} ok=${n} failed=${e.length-n}`),Q(),nn()},[Y,W,en,Q,nn]),an=(0,E.useCallback)(async(e,t)=>{if(e.stopPropagation(),!lt.has(t.sessionId)){ut(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await F(`/api/admin/session-stop`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId})});if(!e.ok){let n=await e.json().catch(()=>({}));console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} status=${e.status} error=${n.error??`unknown`}`),H({message:`Stop failed: ${n.error??`status ${e.status}`}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-stop sessionId=${t.sessionId}`),Q()}catch(e){let n=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-stop-failed sessionId=${t.sessionId} error=${n}`),H({message:`Stop failed: ${n}`,failed:!0})}finally{ut(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[F,lt,Q]),on=(0,E.useCallback)(async(e,t,n)=>{if(e.stopPropagation(),!dt.has(t.sessionId)){ft(e=>{let n=new Set(e);return n.add(t.sessionId),n});try{let e=await F(`/api/admin/session-archive`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:t.sessionId,mode:n})});if(!e.ok){let r=await e.json().catch(()=>({})),i=r.detail??r.error??`status ${e.status}`;console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} status=${e.status} error=${r.error??`unknown`}`),H({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${i}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-archive sessionId=${t.sessionId} mode=${n}`),Q()}catch(e){let r=e instanceof Error?e.message:String(e);console.error(`[admin-ui] sidebar-session-archive-failed sessionId=${t.sessionId} mode=${n} error=${r}`),H({message:`${n===`archive`?`Archive`:`Unarchive`} failed: ${r}`,failed:!0})}finally{ft(e=>{let n=new Set(e);return n.delete(t.sessionId),n})}}},[F,dt,Q]),sn=(0,E.useCallback)(async e=>{let t=ht.trim();if(!t){H({message:`Title can’t be empty`,failed:!0});return}if(t.length>Ve){H({message:`Title too long (max ${Ve})`,failed:!0});return}_t(!0);try{let n=await F(`/api/admin/session-rename`,{method:`POST`,headers:{"Content-Type":`application/json`},body:JSON.stringify({sessionId:e.sessionId,title:t})});if(!n.ok){let t=await n.json().catch(()=>({})),r=t.reason??t.error??`status ${n.status}`;console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${r}`),H({message:`Rename failed: ${r}`,failed:!0});return}console.info(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=ok`),mt(null),Z(``),Q()}catch(t){let n=t instanceof Error?t.message:String(t);console.error(`[admin-ui] sidebar-session-rename sessionId=${e.sessionId.slice(0,8)} outcome=rejected reason=${n}`),H({message:`Rename failed: ${n}`,failed:!0})}finally{_t(!1)}},[F,ht,Q]);return(0,D.jsxs)(`aside`,{className:`side`,children:[(0,D.jsx)(`div`,{className:`side-new-session-row`,children:(0,D.jsxs)(`button`,{type:`button`,className:`side-new-session`,onClick:Zt,disabled:Et,"aria-busy":Et,children:[(0,D.jsx)(C,{size:14}),(0,D.jsx)(`span`,{children:Et?`Spawning…`:`New session`})]})}),(0,D.jsxs)(`nav`,{className:`side-nav`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=people`),m(),T()},children:[(0,D.jsx)(de,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`People`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=agents`),re(),T()},children:[(0,D.jsx)(ae,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Agents`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=projects`),u(),T()},children:[(0,D.jsx)(oe,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:_().term}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row`,onClick:()=>{console.info(`[admin-ui] sidebar-nav surface=tasks`),h(),T()},children:[(0,D.jsx)(le,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Tasks`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${I===`artefacts`?` active`:``}`,onClick:Ut,children:[(0,D.jsx)(x,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Artefacts`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${I===`sessions`?` active`:``}`,onClick:Gt,children:[(0,D.jsx)(ce,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Sessions`}),(0,D.jsx)(`span`,{className:`kbd`})]}),(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${I===`data`?` active`:``}`,onClick:qt,children:[(0,D.jsx)(l,{size:20,strokeWidth:$}),(0,D.jsx)(`span`,{className:`label`,children:`Data`}),(0,D.jsx)(`span`,{className:`kbd`})]}),jt&&ne.filter(e=>Vt.get(e).length>0).map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`nav-row${I===`whatsapp`&&Ft===e?` active`:``}`,onClick:()=>Jt(e),children:[(0,D.jsx)(w,{channel:e,size:16}),(0,D.jsx)(`span`,{className:`label`,children:Ht[e]}),(0,D.jsx)(`span`,{className:`kbd`})]},e)),Nt&&(0,D.jsx)(`div`,{className:`nav-row`,style:{color:`var(--text-tertiary)`,cursor:`default`},"aria-disabled":`true`,children:(0,D.jsx)(`span`,{className:`label`,children:Nt})})]}),I===`artefacts`&&(0,D.jsxs)(`div`,{className:`side-list`,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:`Artefacts`}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh artefacts`,"aria-label":`Refresh artefacts`,onClick:Wt,disabled:Ce,children:(0,D.jsx)(y,{size:12,className:Ce?`spinning`:void 0})}),(0,D.jsx)(`span`,{children:Ce?`…`:String(R.length)})]})]}),Se&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:Se}),be&&!Se&&R.length>0&&(()=>{let e=R.filter(e=>e.kind===`agent-template`).length,t=R.length-e;return(0,D.jsx)(`div`,{className:`artefact-filter-chips`,children:[{key:`all`,label:`All`,count:R.length},{key:`agent`,label:`Agents`,count:e},{key:`file`,label:`Files`,count:t}].map(e=>(0,D.jsxs)(`button`,{type:`button`,className:`artefact-filter-chip${B===e.key?` active`:``}`,onClick:()=>Te(e.key),disabled:e.count===0&&e.key!==`all`,children:[e.label,(0,D.jsx)(`span`,{className:`artefact-filter-chip-count`,children:e.count})]},e.key))})})(),be&&!Se&&R.length===0&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No artefacts yet`}),R.filter(e=>B===`all`?!0:B===`agent`?e.kind===`agent-template`:e.kind!==`agent-template`).map(e=>{let t=e.kind===`agent-template`,n=t?ae:x,r=We(e.updatedAt),i=e.downloadPath!==null;return(0,D.jsxs)(`button`,{type:`button`,className:`conv`,onClick:()=>Lt(e),disabled:!i,style:i?void 0:{cursor:`default`},title:i?`Download ${e.name}`:`${e.name} can’t be downloaded`,children:[(0,D.jsx)(n,{size:14,className:`conv-icon`,"data-kind":t?`agent`:`file`,"aria-label":t?`agent template`:`file`}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsx)(`span`,{className:`conv-name-line`,children:(0,D.jsx)(`span`,{className:`conv-name`,children:e.name})}),r&&(0,D.jsx)(`span`,{className:`conv-timestamp`,children:r})]}),i&&(0,D.jsx)(b,{size:12,className:`conv-rc-icon`,"aria-hidden":`true`})]},e.id)})]}),I===`sessions`&&(()=>{let e=W.filter(e=>Be?!0:!e.isSubagent).filter(e=>Ke?!0:!e.archived),t=W.some(e=>e.isSubagent),n=W.some(e=>e.archived);return(0,D.jsxs)(`div`,{className:`side-list`,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:`Sessions`}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-select${J?` active`:``}`,"aria-pressed":J,title:J?`Exit select mode`:`Select multiple sessions to delete`,onClick:()=>{nt(e=>!e),rt(new Set),mt(null),Z(``)},children:`Select`}),(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh sessions`,"aria-label":`Refresh sessions`,onClick:Kt,disabled:Le,children:(0,D.jsx)(y,{size:12,className:Le?`spinning`:void 0})}),(0,D.jsx)(`span`,{children:Le?`…`:String(e.length)})]})]}),J&&(0,D.jsxs)(`div`,{className:`session-select-bar`,children:[(0,D.jsxs)(`span`,{className:`session-select-count`,children:[Y.size,` selected`]}),(0,D.jsxs)(`button`,{type:`button`,className:`session-select-delete`,disabled:Y.size===0,onClick:()=>at(!0),children:[`Delete `,Y.size]}),(0,D.jsx)(`button`,{type:`button`,className:`session-select-cancel`,onClick:nn,children:`Cancel`})]}),Ze&&(0,D.jsx)(`div`,{className:`side-account-id`,title:`This install's accountId. The first 8 characters match the truncated UUID label on the live Remote Control daemon entry in claude.ai/code.`,children:(0,D.jsx)(`code`,{children:Ze})}),(t||n)&&(0,D.jsxs)(`div`,{className:`artefact-filter-chips`,children:[t&&(0,D.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${Be?` active`:``}`,"aria-pressed":Be,onClick:()=>Ge(e=>!e),title:Be?`Hide subagent sessions`:`Show subagent sessions`,children:`Subagents`}),n&&(0,D.jsx)(`button`,{type:`button`,className:`artefact-filter-chip${Ke?` active`:``}`,"aria-pressed":Ke,onClick:()=>Xe(e=>!e),title:Ke?`Hide archived sessions`:`Show archived sessions`,children:`Archived`})]}),q&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:q}),K&&!q&&e.length===0&&(0,D.jsx)(`div`,{className:`conv`,style:{color:`var(--text-tertiary)`,cursor:`default`},children:`No sessions yet`}),e.map(e=>{let t=We(e.startedAt),n=st.has(e.sessionId),r=$e.has(e.sessionId),i=lt.has(e.sessionId),a=dt.has(e.sessionId),o=n||r||i||a,s=()=>{window.location.assign(`/chat?session=${e.sessionId}`)},l=[{key:`open`,label:`Resume session ${e.title} in claude.ai/code`,menuLabel:`Resume in claude.ai/code`,title:`Resume in a fresh local Remote Control PTY`,icon:(0,D.jsx)(f,{size:12}),busy:n,onClick:()=>{Yt(e)}},{key:`message`,label:`Open session ${e.title} in admin webchat`,menuLabel:`Open in webchat`,title:`Open in admin webchat (/chat) — sending resumes this session`,icon:(0,D.jsx)(M,{size:12}),onClick:()=>{s()}},{key:`usage`,label:`Usage and cost for session ${e.title}`,menuLabel:`Usage & cost`,title:`Per-day active time, tokens, and estimated GBP cost`,icon:(0,D.jsx)(se,{size:12}),onClick:t=>{$t(t,e)}},...e.live?[{key:`stop`,label:`Stop session ${e.title}`,menuLabel:`Stop`,title:`Stop session process (keeps the conversation, can resume later)`,icon:(0,D.jsx)(p,{size:12}),busy:i,onClick:t=>{an(t,e)}}]:[],e.archived?{key:`unarchive`,label:`Unarchive session ${e.title}`,menuLabel:`Unarchive`,title:`Unarchive (move back to the active list)`,icon:(0,D.jsx)(A,{size:12}),busy:a,onClick:t=>{on(t,e,`unarchive`)}}:{key:`archive`,label:`Archive session ${e.title}`,menuLabel:`Archive`,title:`Archive (hide from the list, keeps the conversation resumable)`,icon:(0,D.jsx)(j,{size:12}),busy:a,onClick:t=>{on(t,e,`archive`)}},{key:`rename`,label:`Rename session ${e.title}`,menuLabel:`Rename`,title:`Rename this session`,icon:(0,D.jsx)(c,{size:12}),busy:gt&&pt===e.sessionId,onClick:t=>{t.stopPropagation(),mt(e.sessionId),Z(e.personName??e.title)}},{key:`delete`,label:`Delete session ${e.title}`,menuLabel:`Delete`,title:`Delete session (stops the process, removes the conversation)`,icon:(0,D.jsx)(d,{size:12}),danger:!0,busy:r,onClick:t=>{Qt(t,e)}},me({sessionId:e.sessionId,model:e.model??null,title:e.personName??e.title})],u=e.channel===`whatsapp`?` conv-channel-whatsapp`:e.channel===`telegram`?` conv-channel-telegram`:``,m=e.channel===`whatsapp`||e.channel===`telegram`||e.channel===`webchat`,h=ne.includes(e.channel??``)&&e.senderId&&e.titleSource===`prefix`?S({operatorName:e.personName??null,whatsappName:e.whatsappName??null,senderId:e.senderId,title:e.title}):e.personName??e.title;return(0,D.jsxs)(`div`,{ref:t=>{let n=tt.current;t?n.set(e.sessionId,t):n.delete(e.sessionId)},className:`conv conv-with-actions${u}${e.sessionId===G?` active`:``}`,children:[(0,D.jsxs)(`div`,{className:`conv-main-static conv-main-clickable`,role:`button`,tabIndex:0,"aria-label":`Open ${h} in webchat`,onClick:()=>{if(pt!==e.sessionId){if(J){tn(e.sessionId);return}s()}},onKeyDown:t=>{pt!==e.sessionId&&(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),J?tn(e.sessionId):s())},children:[J&&(0,D.jsx)(`input`,{type:`checkbox`,className:`conv-select-check`,checked:Y.has(e.sessionId),"aria-label":`Select ${h}`,onChange:()=>tn(e.sessionId),onClick:e=>e.stopPropagation()}),(0,D.jsx)(`span`,{className:`conv-live-dot`,"data-live":e.live?`1`:`0`,"aria-label":e.live?`live session`:`ended session`}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsxs)(`span`,{className:`conv-name-line`,children:[m&&(0,D.jsx)(v,{channel:e.channel,size:13}),pt===e.sessionId?(0,D.jsx)(`input`,{className:`conv-name conv-name-edit`,autoFocus:!0,onFocus:e=>e.currentTarget.select(),value:ht,disabled:gt,"aria-label":`New title for session ${e.title}`,onChange:e=>Z(e.target.value),onClick:e=>e.stopPropagation(),onKeyDown:t=>{t.key===`Enter`?(t.preventDefault(),sn(e)):t.key===`Escape`&&(t.preventDefault(),mt(null),Z(``))},onBlur:()=>{pt===e.sessionId&&!gt&&(mt(null),Z(``))}}):(0,D.jsx)(`span`,{className:`conv-name`,title:h,children:h})]}),(0,D.jsxs)(`span`,{className:`conv-timestamp`,children:[(0,D.jsx)(`code`,{className:`conv-session-id`,title:`First 8 characters of this session's id — distinguishes rows with identical auto-titles. The resume/delete buttons act on the full id.`,children:e.sessionId.slice(0,8)}),t&&(0,D.jsxs)(`span`,{children:[` · `,t]})]})]})]}),!J&&(0,D.jsx)(ve,{actions:l,disabled:o})]},e.sessionId)})]})})(),I===`whatsapp`&&(0,D.jsxs)(`div`,{className:`side-list`,children:[(0,D.jsxs)(`div`,{className:`group-head`,children:[(0,D.jsx)(`span`,{children:Ht[Ft]}),(0,D.jsxs)(`span`,{className:`group-head-meta`,children:[(0,D.jsx)(`button`,{type:`button`,className:`group-head-refresh`,title:`Refresh conversations`,"aria-label":`Refresh conversations`,onClick:()=>{Bt()},children:(0,D.jsx)(y,{size:12})}),(0,D.jsx)(`span`,{children:String(Vt.get(Ft).length)})]})]}),Vt.get(Ft).map(e=>{let t=We(e.lastMessageAt),n=ee(e);return(0,D.jsxs)(`div`,{className:`conv conv-with-actions${e.source===`store`?e.scope===`admin`?` conv-scope-admin`:` conv-scope-public`:``}${ie===n?` active`:``}`,children:[(0,D.jsxs)(`button`,{type:`button`,className:`conv-main-static conv-main-btn`,onClick:()=>{k(e),T()},title:e.title,children:[(0,D.jsx)(w,{channel:e.channel,size:14}),(0,D.jsxs)(`span`,{className:`conv-stack`,children:[(0,D.jsx)(`span`,{className:`conv-name-line`,children:(0,D.jsx)(`span`,{className:`conv-name`,children:S(e)})}),t&&(0,D.jsx)(`span`,{className:`conv-timestamp`,children:t})]})]}),e.source===`session`&&(0,D.jsx)(ve,{actions:[me({sessionId:e.sessionId,model:e.model,title:e.title})],disabled:!1})]},n)})]}),(0,D.jsx)(Ye,{}),(0,D.jsxs)(`div`,{className:`side-foot`,children:[(0,D.jsx)(`div`,{className:`avatar`,children:o?(0,D.jsx)(`img`,{src:o,alt:ge}):_e}),(0,D.jsxs)(`div`,{className:`who`,children:[(0,D.jsx)(`span`,{className:`name`,children:ge}),(0,D.jsx)(`span`,{className:`role`,children:i??`operator`})]})]}),V&&(0,D.jsx)(`div`,{className:`copy-toast${V.failed?` copy-toast-failed`:``}`,role:`status`,children:V.message}),(0,D.jsx)(Ne,{error:Ee,onClose:()=>U(null)}),(0,D.jsx)(Pe,{open:De,onConnect:()=>{ke(!1),r?.()},onClose:()=>ke(!1)}),(0,D.jsx)(Ae,{target:X,anchorEl:X?tt.current.get(X.sessionId)??null:null,onCancel:()=>ot(null),onConfirm:()=>{let e=X;ot(null),e&&en(e)}},X?.sessionId??`none`),(0,D.jsx)(je,{open:it,count:Y.size,liveCount:W.filter(e=>Y.has(e.sessionId)&&e.live).length,onConfirm:()=>{at(!1),rn()},onCancel:()=>at(!1)}),(0,D.jsx)(ze,{show:vt!==null,onClose:()=>{yt(null),xt(null),Tt(null)},anchorEl:vt?tt.current.get(vt.sessionId)??null:null,sessionId:vt?.sessionId??null,summary:bt,loading:St,error:wt},vt?.sessionId??`none`)]})}var Ke=5e3,qe=3e4,Je=3e4;function Ye(){let[e,t]=(0,E.useState)(null);if((0,E.useEffect)(()=>{let e=!1,n=null;async function r(){try{let n=await fetch(`/api/admin/system-stats`);if(!n.ok){console.error(`[admin-ui] system-stats-fetch-failed status=${n.status}`);return}let r=await n.json();e||t(r)}catch(e){console.error(`[admin-ui] system-stats-fetch-failed reason=${e instanceof Error?e.message:String(e)}`)}}function i(){n===null&&(r(),n=setInterval(()=>{r()},Ke))}function a(){n!==null&&(clearInterval(n),n=null)}function o(){document.hidden?a():i()}return document.hidden||i(),document.addEventListener(`visibilitychange`,o),()=>{e=!0,a(),document.removeEventListener(`visibilitychange`,o)}},[]),!e||e.platform===`darwin`)return null;let n=e.cpuPct,r=e.memUsedPct,i=n!==null&&n>=.9,a=n!==null&&n>=.98,o=r!==null&&r>=.9,s=r!==null&&r>=.98,c=i||o,l=a||s,u=e=>e===null?`—`:`${Math.round(e*100)}%`,d=e=>{if(e===null)return{width:`0%`,background:`var(--text-tertiary)`};let t=Math.min(1,Math.max(0,e)),n=Math.round(140*(1-t));return{width:`${Math.round(t*100)}%`,background:`hsl(${n}, 65%, 45%)`}},f=[`system-stats`];return c&&f.push(`system-stats--warn`),l&&f.push(`system-stats--crit`),(0,D.jsxs)(`div`,{className:f.join(` `),role:`status`,"aria-label":`host CPU and RAM`,children:[(0,D.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,D.jsxs)(`span`,{className:i?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`CPU `,u(n)]}),(0,D.jsx)(`div`,{className:`system-stats__bar`,children:(0,D.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(n)})})]}),(0,D.jsxs)(`div`,{className:`system-stats__metric`,children:[(0,D.jsxs)(`span`,{className:o?`system-stats__fig system-stats__fig--warn`:`system-stats__fig`,children:[`RAM `,u(r)]}),(0,D.jsx)(`div`,{className:`system-stats__bar`,children:(0,D.jsx)(`div`,{className:`system-stats__bar-fill`,style:d(r)})})]})]})}var Xe=`admin-sidebar-collapsed`,Ze=`admin-sidebar-drawer-open`;function Qe(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Xe)===`1`}catch{return!1}}function $e(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Xe,`1`):window.sessionStorage.removeItem(Xe)}catch{}}function et(){if(typeof window>`u`)return!1;try{return window.sessionStorage.getItem(Ze)===`1`}catch{return!1}}function tt(e){if(!(typeof window>`u`))try{e?window.sessionStorage.setItem(Ze,`1`):window.sessionStorage.removeItem(Ze)}catch{}}function J(e){let[t,n]=(0,E.useState)(()=>typeof window>`u`||typeof window.matchMedia!=`function`?!1:window.matchMedia(e).matches);return(0,E.useEffect)(()=>{if(typeof window>`u`||typeof window.matchMedia!=`function`)return;let t=window.matchMedia(e),r=()=>n(t.matches);return r(),t.addEventListener(`change`,r),()=>t.removeEventListener(`change`,r)},[e]),t}var nt=720;function Y(e,t){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?wa=${encodeURIComponent(t.remoteJid??``)}&acct=${encodeURIComponent(t.accountId??``)}`}}function rt(e){return e===`/`?{via:`in-place`}:{via:`navigate`,href:`/?data=1`}}function it(e,t){if(e!==`/`)return null;let n=new URLSearchParams(t),r=n.get(`wa`),i=n.get(`acct`);return!r||!i?null:{sessionId:``,projectDir:``,title:``,senderId:null,startedAt:``,channel:`whatsapp`,role:`public`,operatorName:null,whatsappName:null,lastMessageAt:null,modelGated:!1,model:null,source:`store`,accountId:i,remoteJid:r}}function at(e,t){return e===`/`?new URLSearchParams(t).has(`data`):!1}function X(e,t){return t===`operator`&&e===`chat`||e===`dashboard`?`/`:e===`data`?`/data`:e===`graph`?`/graph`:e===`calendar`?`/calendar`:e===`chat`?`/chat`:e===`activity`?`/activity`:`/browser`}function ot(e){let{cacheKey:t,businessName:n,variant:r=`admin`,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:s,onConnectClaude:c,userName:l,userAvatar:d,role:f,onOpenConversations:p,children:h,footer:g}=e,{subAccounts:v,activeAccountId:y,switching:b,switchAccount:x,refreshAccounts:S}=m(t),[C,te]=(0,E.useState)(!0);(0,E.useEffect)(()=>{if(s!==void 0||r!==`admin`)return;let e=!1,t=async()=>{try{let t=await fetch(`/api/health`);if(!t.ok)return;let n=await t.json();e||te(n.auth_status!==`dead`&&n.auth_status!==`missing`)}catch{}};t();let n=setInterval(t,6e4);return()=>{e=!0,clearInterval(n)}},[s,r]);let ne=s??C,re=c??(()=>{window.location.assign(`/?connect=claude`)}),[w,T]=(0,E.useState)(()=>Qe()),[O,ie]=(0,E.useState)(()=>et()),k=J(`(max-width: ${nt}px)`),[A,j]=(0,E.useState)(()=>typeof window>`u`||at(window.location.pathname,window.location.search)?null:it(window.location.pathname,window.location.search)),[ae]=(0,E.useState)(()=>A!==null),[oe,se]=(0,E.useState)(()=>typeof window>`u`?!1:at(window.location.pathname,window.location.search)),[ce]=(0,E.useState)(()=>oe),le=(0,E.useCallback)(e=>{$e(e),T(e)},[]),M=(0,E.useCallback)(e=>{tt(e),ie(e)},[]);(0,E.useEffect)(()=>{if(typeof window>`u`)return;let e=window.location?.pathname??``;console.info(`[admin-ui] shell-mount route=${e} variant=${r} sidebar=${r===`operator`?`none`:`present`} collapsed=${w} drawer=${O}`)},[]),(0,E.useEffect)(()=>{typeof window>`u`||!A||(console.info(`[admin-ui] wa-hydrate route=/ remoteJid=${A.remoteJid??``}`),window.history.replaceState(null,``,`/`))},[]),(0,E.useEffect)(()=>{typeof window>`u`||!oe||(console.info(`[admin-ui] data-hydrate route=/`),window.history.replaceState(null,``,`/`))},[]);let ue=(0,E.useCallback)(e=>{if(se(!1),e===null){j(null);return}let t=typeof window<`u`?window.location.pathname:`/`,n=Y(t,e);console.info(`[admin-ui] wa-open route=${t} via=${n.via} sessionId=${e.sessionId.slice(0,8)}`),n.via===`in-place`?j(e):window.location.href=n.href},[]),de=(0,E.useCallback)(()=>{let e=typeof window<`u`?window.location.pathname:`/`,t=rt(e);if(console.info(`[admin-ui] data-open route=${e} via=${t.via}`),t.via===`navigate`){window.location.href=t.href;return}j(null),se(!0)},[]),N=k?O:!w,fe=(0,E.useCallback)(()=>{if(!(typeof window>`u`))if(window.matchMedia(`(max-width: ${nt}px)`).matches){let e=O;console.info(`[admin-ui] header-sidebar-toggle from=${e?`open`:`closed`} mode=drawer`),M(!e)}else{let e=w;console.info(`[admin-ui] header-sidebar-toggle from=${e?`closed`:`open`} mode=collapse`),le(!e)}},[w,O,le,M]),P=(0,E.useCallback)(e=>{let t=X(e,r);console.info(`[admin-ui] header-menu-nav target=${e} dest=${t}`),window.location.href=t},[r]),pe={collapsed:w,mobileDrawerOpen:O,sidebarOpen:N,onToggleSidebar:fe,setMobileDrawerOpen:M,selectedWhatsapp:A,onClearWhatsapp:()=>j(null),dataOpen:oe};return r===`operator`?(0,D.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,D.jsx)(u,{businessName:n,variant:r,onNavigate:P,onOpenConversations:p,onToggleSidebar:fe,sidebarOpen:N,onLogout:i,onDisconnect:a,disconnecting:o,cacheKey:t,subAccounts:v,activeAccountId:y,switchingAccount:b,onSwitchAccount:x,refreshAccounts:S}),(0,D.jsx)(`div`,{className:`platform platform-operator`,children:typeof h==`function`?h(pe):h}),g]}):(0,D.jsxs)(`div`,{className:`admin-shell admin-page admin-shell-root`,children:[(0,D.jsx)(u,{businessName:n,variant:r,onNavigate:P,onOpenConversations:p,onToggleSidebar:fe,sidebarOpen:N,onLogout:i,onDisconnect:a,disconnecting:o,claudeConnected:ne,onConnectClaude:re,cacheKey:t,subAccounts:v,activeAccountId:y,switchingAccount:b,onSwitchAccount:x,refreshAccounts:S}),(0,D.jsxs)(`div`,{className:`platform${O?` menu-open`:``}${w?` sidebar-collapsed`:``}`,"data-artefact":`closed`,children:[(0,D.jsx)(Ge,{businessName:n,cacheKey:t,onConnectClaude:re,role:f??null,userName:l,userAvatar:d??null,onSelectProjects:()=>{window.location.href=`/graph?label=${_().label}`},onSelectPeople:()=>{window.location.href=`/graph?label=Person`},onSelectTasks:()=>{window.location.href=`/tasks`},onSelectAgents:()=>{window.location.href=`/graph?label=Agent`},onCloseMobileDrawer:()=>M(!1),collapsed:w,mobileDrawerOpen:O,selectedWhatsappId:A?ee(A):null,onSelectWhatsappConversation:ue,initialWhatsappSurface:ae,onSelectData:de,onCloseData:()=>se(!1),initialDataSurface:ce}),!k&&(0,D.jsx)(F,{}),typeof h==`function`?h(pe):h]}),O&&(0,D.jsx)(`div`,{className:`sidebar-backdrop menu-open`,"aria-hidden":`true`,onClick:()=>M(!1)}),g]})}export{A as _,G as a,R as c,de as d,ue as f,j as g,ae as h,Pe as i,Ce as l,se as m,J as n,ye as o,le as p,Ue as r,L as s,ot as t,xe as u,k as v,T as y};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-TPjIAO9U.js";import{D as t,S as n,T as r,d as i,g as a,r as o,w as s}from"./useSubAccountSwitcher-v8LyBzZN.js";import{t as c,v as l,y as u}from"./AdminShell-Cv_nIFGe.js";import{t as d}from"./Checkbox-CsTWK8mm.js";import"./useSelectionMode-sph7AQT5.js";import{t as f}from"./triangle-alert-Dz-CZKo5.js";var p=r(),m=e(t(),1),h=n(),g=`—`;function _(e){switch(e){case`waiting`:return`Waiting`;case`never-run`:return`Never run`;case`never-succeeded`:return`Never succeeded`;case`failing`:return`Failing`;case`stalled`:return`Stalled`;case`running`:return`Running`;case`ok`:return`Healthy`}}var v={waiting:`Armed and not due yet. It has no start-up run and its first interval has not elapsed, so it has correctly not fired.`,"never-run":`Its interval has elapsed and it still has not fired once. This is not the same as waiting its turn.`,"never-succeeded":`It has fired, and not one run has finished. The work this loop exists to do has never happened.`,failing:`It worked before and is failing now.`,stalled:`It has not started within three of its own intervals. Something is holding it up.`,running:`A run is in progress right now.`,ok:`The last run finished and the next is due within the interval.`},y=new Set([`never-run`,`never-succeeded`,`failing`,`stalled`]),b=10;function x(e){return e===null||!Number.isFinite(e)?g:`${e.toFixed(1)}%`}function S(e){return e<6e4?`${Math.round(e/1e3)}s`:e<36e5?`${Math.round(e/6e4)}m`:`${Math.round(e/36e5)}h`}function C(e,t){if(e===null)return g;let n=t-e;return n<0?`in ${S(-n)}`:n<6e4?`${Math.round(n/1e3)}s ago`:n<36e5?`${Math.round(n/6e4)}m ago`:`${Math.round(n/36e5)}h ago`}function w(e,t){if(e===null)return g;let n=e-t;return n>=0?`in ${S(n)}`:`overdue by ${S(-n)}`}function T({loops:e,nowMs:t=Date.now()}){let[n,r]=(0,m.useState)(!1);if(!e)return(0,h.jsxs)(`section`,{className:`activity-loops`,children:[(0,h.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,h.jsx)(`p`,{className:`activity-loops-empty`,children:`Scheduled work could not be read from the server.`})]});let i=e.armed-e.rows.length,a=e.rows.filter(e=>y.has(e.state)),o=e.rows.filter(e=>!y.has(e.state)&&typeof e.cpuPct==`number`&&e.cpuPct>=b),s=n?e.rows:[...a,...o];return(0,h.jsxs)(`section`,{className:`activity-loops`,children:[(0,h.jsx)(`h2`,{className:`activity-loops-heading`,children:`Scheduled work`}),(0,h.jsxs)(`p`,{className:`activity-loops-sub`,children:[e.armed,` `,e.armed===1?`loop`:`loops`,` armed`,a.length>0?` · ${a.length} ${a.length===1?`needs`:`need`} attention`:` · all healthy`,o.length>0&&` · ${o.length} using significant processor`,`. `,(0,h.jsx)(`button`,{type:`button`,className:`activity-loops-toggle`,"aria-expanded":n,onClick:()=>r(e=>!e),children:n?`Show less`:`Show all`})]}),typeof e.processPct==`number`&&(0,h.jsxs)(`p`,{className:`activity-loops-cpu`,children:[`Server process at `,e.processPct.toFixed(1),`% of one core`,typeof e.attributedPct==`number`&&(0,h.jsxs)(h.Fragment,{children:[` · these loops explain `,e.attributedPct.toFixed(1),`%`]}),typeof e.unattributedPct==`number`&&e.unattributedPct>=1&&(0,h.jsxs)(h.Fragment,{children:[` · `,(0,h.jsxs)(`strong`,{children:[e.unattributedPct.toFixed(1),`% is not from these loops`]})]})]}),i>0&&(0,h.jsxs)(`p`,{className:`activity-loops-omission`,role:`status`,children:[i,` armed `,i===1?`loop is`:`loops are`,` missing from this list. The server armed `,e.armed,` but sent `,e.rows.length,`.`]}),s.length===0?null:(0,h.jsxs)(`table`,{className:`activity-table`,children:[(0,h.jsx)(`thead`,{children:(0,h.jsxs)(`tr`,{children:[(0,h.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Loop`}),(0,h.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`State`}),(0,h.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Every`}),(0,h.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last run`}),(0,h.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Last OK`}),(0,h.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Took`}),(0,h.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`CPU`}),(0,h.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Runs`}),(0,h.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Produced`}),(0,h.jsx)(`th`,{scope:`col`,className:`activity-th`,children:`Next due`})]})}),(0,h.jsx)(`tbody`,{children:s.map(e=>(0,h.jsxs)(`tr`,{className:y.has(e.state)?`activity-loop-row activity-loop-unhealthy`:`activity-loop-row`,children:[(0,h.jsx)(`td`,{className:`activity-td`,children:e.name}),(0,h.jsx)(`td`,{className:`activity-td`,title:v[e.state],children:_(e.state)}),(0,h.jsx)(`td`,{className:`activity-td activity-num`,children:S(e.intervalMs)}),(0,h.jsx)(`td`,{className:`activity-td activity-num`,children:C(e.lastStartMs,t)}),(0,h.jsx)(`td`,{className:`activity-td activity-num`,children:C(e.lastSuccessMs,t)}),(0,h.jsx)(`td`,{className:`activity-td activity-num`,children:e.lastDurationMs===null?g:`${e.lastDurationMs} ms`}),(0,h.jsx)(`td`,{className:`activity-td activity-num`,title:e.cpuAttributable?e.detached?`Includes the processor time of the separate process this loop starts.`:void 0:`This loop waits on other work while it runs, so the processor time it uses cannot be separated from the rest of the server.`,children:x(e.cpuPct)}),(0,h.jsxs)(`td`,{className:`activity-td activity-num`,children:[e.successCount,`/`,e.runCount]}),(0,h.jsx)(`td`,{className:`activity-td activity-loop-note`,children:(0,h.jsx)(`span`,{className:`activity-loop-note-text`,title:e.lastError??e.lastNote??void 0,children:e.lastError??e.lastNote??g})}),(0,h.jsx)(`td`,{className:`activity-td activity-num`,children:w(e.nextDueMs,t)})]},e.name))})]}),(0,h.jsxs)(`dl`,{className:`activity-legend`,children:[(0,h.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,h.jsx)(`dt`,{className:`activity-legend-term`,children:`Runs`}),(0,h.jsx)(`dd`,{className:`activity-legend-def`,children:`Finished runs out of attempted runs since the server started. 0 out of a large number means it has tried many times and never once finished.`})]}),(0,h.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,h.jsx)(`dt`,{className:`activity-legend-term`,children:`CPU`}),(0,h.jsx)(`dd`,{className:`activity-legend-def`,children:`Share of one processor core this loop is using, measured between the last two refreshes. It includes any separate process the loop starts, and can pass 100% because those run alongside each other. A dash means it could not be measured: the loop waits on other work while it runs, so its share cannot be separated from the rest of the server.`})]}),(0,h.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,h.jsx)(`dt`,{className:`activity-legend-term`,children:g}),(0,h.jsx)(`dd`,{className:`activity-legend-def`,children:`Not measured. It does not mean zero.`})]})]})]})}var E=`maxy-admin-session-key`;function D(e){switch(e.costUnavailable){case`metering-failed`:return`Cost could not be calculated: ${e.meteringError??`the transcript could not be read`}`;case`model-not-priced`:return`No published price for this model, so cost cannot be estimated.`;case`no-transcript`:return`This session has no transcript yet, so there is nothing to cost.`;default:return}}var O=[{key:`lastMessageAt`,label:`Last activity`,dir:-1},{key:`activeMsInRange`,label:`Active time`,dir:-1},{key:`costGbp`,label:`Cost`,dir:-1},{key:`accountId`,label:`Account name`,dir:1}],k=[{key:`title`,label:`Session`,help:`The conversation name, or its short id when it has none yet.`},{key:`model`,label:`Model`,help:`The model that answered the most recent turn.`},{key:`status`,label:`Status`,help:`What the process is doing right now.`},{key:`activeMsInRange`,label:`Active`,help:`Time this session spent thinking, writing and running tools inside the selected range. This is worked time, not elapsed time.`},{key:`ageMs`,label:`Age`,help:`How long ago this conversation started. Wall-clock, so it counts every hour nobody was working.`},{key:`lastMessageAt`,label:`Last activity`,help:`The clock time of the most recent message, in your timezone. A date appears once it is not today.`},{key:`turnCount`,label:`Turns`,help:`Messages exchanged. A trailing + means the count is a minimum — the conversation is too long to count exactly.`},{key:`rssKb`,label:`RAM`,help:`Memory held by this session and all its helper processes together.`},{key:`cpuPct`,label:`CPU (avg)`,help:`AVERAGE share of one processor core over the last census interval, up to 60 seconds. It is not a reading of this instant, so a session that answered a turn a minute ago still shows a high figure while sitting quiet now. Can exceed 100% because a session runs many processes at once.`},{key:`tokensInRange`,label:`Tokens`,help:`Total tokens billed inside the selected range, added up across every day in it. A cumulative total, not the size of the conversation the model currently reads back.`},{key:`costGbp`,label:`Cost`,help:`Estimated spend inside the selected range, at published prices for this model.`}],A=[`activeMsInRange`,`lastMessageAt`,`cpuPct`,`tokensInRange`],j={label:`Account`,help:`The business this session belongs to. "untagged" means the session records no account.`};function M(e,t){let n=t?.[e];return n&&n.trim()!==``?n:e.slice(0,8)}var N=`—`;function P(e){if(e===null||!Number.isFinite(e)||e<0)return N;let t=Math.floor(e/1e3);if(t<60)return`${t}s`;let n=Math.floor(t/60);if(n<60)return`${n}m`;let r=Math.floor(n/60);return r<24?`${r}h ${n%60}m`:`${Math.floor(r/24)}d ${r%24}h`}function F(e){return e===null||!Number.isFinite(e)?N:`${(e/1024/1024).toFixed(1)} GB`}function I(e,t){if(!e)return N;let n=Date.parse(e);if(!Number.isFinite(n))return N;let r=new Date(n),i=new Date(t),a=`${String(r.getHours()).padStart(2,`0`)}:${String(r.getMinutes()).padStart(2,`0`)}`;return r.getFullYear()===i.getFullYear()&&r.getMonth()===i.getMonth()&&r.getDate()===i.getDate()?a:`${r.getDate()} ${r.toLocaleString(`en-GB`,{month:`short`})} ${a}`}function L(e){return e===null||!Number.isFinite(e)?N:`${e.toFixed(1)}%`}function R(e){return e===null||!Number.isFinite(e)?N:e<1e3?String(e):e<1e6?`${(e/1e3).toFixed(1)}k`:`${(e/1e6).toFixed(2)}M`}function z(e){return e===null||!Number.isFinite(e)?N:`£${e.toFixed(2)}`}function B(e){if(e===null||!Number.isFinite(e)||e<0)return N;let t=Math.floor(e/6e4);return`${Math.floor(t/60)}h ${t%60}m`}function V(e,t,n,r){let i=e[n],a=t[n];if(i===null&&a===null)return 0;if(i===null)return 1;if(a===null)return-1;if(n===`lastMessageAt`){let e=Date.parse(String(i)),t=Date.parse(String(a));return!Number.isFinite(e)&&!Number.isFinite(t)?0:Number.isFinite(e)?Number.isFinite(t)?(e-t)*r:-1:1}return typeof i==`number`&&typeof a==`number`?(i-a)*r:String(i).localeCompare(String(a))*r}function H(e){return e.toISOString().slice(0,10)}function U(e){let t=e.getUTCFullYear(),n=e.getUTCMonth();return{from:H(new Date(Date.UTC(t,n,1))),to:H(new Date(Date.UTC(t,n+1,0)))}}function W(e,t){let n=new Date(`${e}T00:00:00.000Z`);return U(new Date(Date.UTC(n.getUTCFullYear(),n.getUTCMonth()+t,1)))}function G(e,t){return{from:H(new Date(t-(e-1)*864e5)),to:H(new Date(t))}}function K(e){return new Date(`${e}T00:00:00.000Z`).toLocaleString(`en-GB`,{month:`long`,year:`numeric`,timeZone:`UTC`})}function q(e){if(e===null)return!1;let t=U(new Date(`${e.from}T00:00:00.000Z`));return t.from===e.from&&t.to===e.to}function J(e,t,n){switch(e){case`title`:return t.title??t.sessionId.slice(0,8);case`model`:return t.model??N;case`status`:return t.status??N;case`activeMsInRange`:return B(t.activeMsInRange);case`ageMs`:return P(t.ageMs);case`lastMessageAt`:return I(t.lastMessageAt,n);case`turnCount`:return t.turnCount===null?N:`${t.turnCount}${t.turnCountCapped?`+`:``}`;case`rssKb`:return F(t.rssKb);case`cpuPct`:return L(t.cpuPct);case`tokensInRange`:return R(t.tokensInRange);case`costGbp`:return z(t.costGbp);default:return N}}function Y({adminFetch:e}){let[t,n]=(0,m.useState)(null),[r,o]=(0,m.useState)(null),[s,c]=(0,m.useState)(!1),[u,p]=(0,m.useState)(`lastMessageAt`),[g,_]=(0,m.useState)(-1),[v,y]=(0,m.useState)(()=>U(new Date)),[b,x]=(0,m.useState)(!0),[S,C]=(0,m.useState)(!0),[w,E]=(0,m.useState)(!1),F=(0,m.useRef)(!1),I=(0,m.useRef)(void 0),L=(0,m.useCallback)(async t=>{if(F.current){I.current=t;return}F.current=!0;try{let r=await e(`/api/admin/activity${t?`?from=${t.from}&to=${t.to}`:``}`);if(r.status===403){o(`This view is available to the house account only.`),c(!0);return}if(!r.ok){o(`The session manager did not answer (status ${r.status}).`),c(!0);return}n(await r.json()),o(null)}catch(e){o(e instanceof Error?e.message:String(e))}finally{c(!0),F.current=!1;let e=I.current;I.current=void 0,e!==void 0&&L(e)}},[e]);(0,m.useEffect)(()=>{L(v);let e=setInterval(()=>void L(v),15e3);return()=>clearInterval(e)},[L,v]);let R=(0,m.useMemo)(()=>t?[...t.rows].sort((e,t)=>V(e,t,u,g)):[],[t,u,g]),z=(0,m.useMemo)(()=>R.filter(e=>e.status===`busy`?b:e.status===`idle`?S:!0),[R,b,S]),B=R.length-z.length;if(!s)return(0,h.jsxs)(`div`,{className:`activity-loading`,children:[(0,h.jsx)(i,{size:18,className:`spin`}),` Loading…`]});if(r)return(0,h.jsx)(`div`,{className:`activity-empty`,children:r});if(!t)return(0,h.jsx)(`div`,{className:`activity-empty`,children:`No response.`});let{accounts:H,census:Y,censusAgeMs:X}=t,Z=Date.now(),Q=H.onDisk!==null&&H.onDisk>H.valid,$=t.range===void 0?v:t.range;return(0,h.jsxs)(`div`,{className:`activity-body`,children:[(0,h.jsxs)(`div`,{className:`activity-head`,children:[(0,h.jsxs)(`span`,{className:`activity-title`,children:[(0,h.jsx)(a,{size:16}),` Live sessions`]}),(0,h.jsxs)(`span`,{className:`activity-meta`,children:[B>0?`${z.length} of ${R.length} live · ${B} hidden`:`${R.length} live`,` · `,H.valid,` accounts`,H.untaggedCount>0?` · ${H.untaggedCount} untagged`:``]})]}),(0,h.jsxs)(`div`,{className:`activity-controls`,children:[(0,h.jsxs)(`div`,{className:`activity-control activity-range`,children:[(0,h.jsx)(l,{variant:`secondary`,size:`sm`,"aria-label":`Previous month`,disabled:!q(v),onClick:()=>y(e=>e&&W(e.from,-1)),children:`‹`}),(0,h.jsx)(`span`,{className:`activity-range-label`,children:v===null?`All time`:q(v)?K(v.from):`${v.from} → ${v.to}`}),(0,h.jsx)(l,{variant:`secondary`,size:`sm`,"aria-label":`Next month`,disabled:!q(v),onClick:()=>y(e=>e&&W(e.from,1)),children:`›`})]}),(0,h.jsxs)(`div`,{className:`activity-control activity-presets`,children:[(0,h.jsx)(l,{variant:`secondary`,size:`sm`,"aria-pressed":v!==null&&q(v)&&v.from===U(new Date).from,onClick:()=>y(U(new Date)),children:`This month`}),(0,h.jsx)(l,{variant:`secondary`,size:`sm`,"aria-pressed":v!==null&&!q(v),onClick:()=>y(G(7,Date.now())),children:`Last 7 days`}),(0,h.jsx)(l,{variant:`secondary`,size:`sm`,"aria-pressed":v===null,onClick:()=>y(null),children:`All time`})]}),(0,h.jsxs)(`div`,{className:`activity-control`,children:[(0,h.jsx)(`label`,{className:`activity-control-label`,htmlFor:`activity-sort`,children:`Sort by`}),(0,h.jsx)(`span`,{className:`activity-select-wrap`,children:(0,h.jsx)(`select`,{id:`activity-sort`,className:`activity-select`,value:u,onChange:e=>{let t=O.find(t=>t.key===e.target.value);t&&(p(t.key),_(t.dir))},children:O.map(e=>(0,h.jsx)(`option`,{value:e.key,children:e.label},e.key))})})]}),(0,h.jsxs)(`div`,{className:`activity-control activity-visibility`,children:[(0,h.jsx)(d,{checked:b,onChange:x,label:`Busy`}),(0,h.jsx)(d,{checked:S,onChange:C,label:`Idle`})]})]}),(0,h.jsxs)(`div`,{className:`activity-range-note`,children:[$===null?`Active time, tokens and cost cover each conversation’s whole history.`:`Active time, tokens and cost cover ${$.from} to ${$.to} (UTC), inclusive.`,t.fullRangeFallback&&(0,h.jsxs)(`strong`,{className:`activity-range-rejected`,children:[` `,`The range was not accepted, so these are all-time figures.`]})]}),(0,h.jsx)(`div`,{className:`activity-census`,children:Y===null?`No census collected yet, so memory and CPU are unavailable.`:`Memory and CPU measured ${P(X)} ago, averaged over the minute before that · ${Y.cpuNull} of ${Y.live} without a CPU reading`}),Q&&(0,h.jsxs)(`div`,{className:`activity-warning`,children:[(0,h.jsx)(f,{size:14}),` `,H.onDisk,` account folders on disk but only`,` `,H.valid,` are readable. Sessions belonging to the rest cannot be attributed.`]}),R.length===0?(0,h.jsx)(`div`,{className:`activity-empty`,children:`No sessions are running.`}):z.length===0?(0,h.jsxs)(`div`,{className:`activity-empty`,children:[`All `,R.length,` running sessions are hidden by the Busy and Idle filters.`]}):(0,h.jsx)(`div`,{className:`activity-grid`,children:z.map(e=>(0,h.jsxs)(`article`,{className:`activity-card`,"data-testid":`activity-card`,"data-session-id":e.sessionId,children:[(0,h.jsx)(`h3`,{className:`activity-card-heading`,title:e.accountId??void 0,children:e.accountId===null?(0,h.jsx)(`span`,{className:`activity-untagged`,title:`This session records no account, so it cannot be attributed to a business.`,children:`untagged`}):M(e.accountId,H.names)}),(0,h.jsx)(`dl`,{className:`activity-card-rows`,children:k.map(t=>(0,h.jsxs)(`div`,{className:`activity-card-row`,children:[(0,h.jsx)(`dt`,{className:`activity-card-label`,"data-testid":`activity-card-label`,title:t.help,children:t.label}),(0,h.jsx)(`dd`,{className:`activity-card-value`,title:t.key===`costGbp`?D(e):void 0,children:J(t.key,e,Z)})]},t.key))})]},e.sessionId))}),R.length>0&&(0,h.jsxs)(`div`,{className:`activity-glossary`,children:[(0,h.jsxs)(`dl`,{className:`activity-legend`,children:[w&&(0,h.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,h.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:j.label}),(0,h.jsx)(`dd`,{className:`activity-legend-def`,children:j.help})]},`heading`),(w?k:k.filter(e=>A.includes(e.key))).map(e=>(0,h.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,h.jsx)(`dt`,{className:`activity-legend-term`,"data-testid":`activity-glossary-term`,children:e.label}),(0,h.jsx)(`dd`,{className:`activity-legend-def`,children:e.help})]},e.key)),(0,h.jsxs)(`div`,{className:`activity-legend-item`,children:[(0,h.jsx)(`dt`,{className:`activity-legend-term`,children:N}),(0,h.jsxs)(`dd`,{className:`activity-legend-def`,children:[`Not measured. It does not mean zero — a measured zero is written as a figure, so `,(0,h.jsx)(`em`,{children:`0h 0m`}),` and `,(0,h.jsx)(`em`,{children:`£0.00`}),` are real readings. Hover a dashed value for the reason where one exists.`]})]})]}),(0,h.jsx)(l,{variant:`secondary`,size:`sm`,className:`activity-glossary-toggle`,onClick:()=>E(e=>!e),children:w?`Show fewer`:`Explain every figure`})]}),(0,h.jsx)(T,{loops:t?.loops})]})}function X({cacheKey:e}){let{adminFetch:t}=s({initialCacheKey:e,surface:`activity`});return(0,h.jsx)(Y,{adminFetch:t})}function Z(){let[e,t]=(0,m.useState)(null),[n,r]=(0,m.useState)(!1),[a,s]=(0,m.useState)(void 0),[l,d]=(0,m.useState)(null),[f,p]=(0,m.useState)(null),[g,_]=(0,m.useState)(null),[v,y]=(0,m.useState)(null);(0,m.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(E)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(E)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&s(e.businessName),e.sessionId!==void 0&&d(e.sessionId??null),p(e.role??null),_(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let b=(0,m.useCallback)(()=>{try{sessionStorage.removeItem(E)}catch{}window.location.href=`/`},[]),[x,S]=(0,m.useState)(!1),C=(0,m.useCallback)(async()=>{S(!0);try{let e=await u();if(e){try{sessionStorage.removeItem(E)}catch{}window.location.href=`/`}return e}finally{S(!1)}},[]);return n?e?(0,h.jsx)(o,{cacheKey:e,surface:`activity`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=activity`);try{sessionStorage.removeItem(E)}catch{}window.location.href=`/`},children:(0,h.jsx)(c,{cacheKey:e,businessName:a,sessionId:l,onLogout:b,onDisconnect:C,disconnecting:x,userName:g,userAvatar:v,role:f,children:(0,h.jsx)(X,{cacheKey:e})})}):(0,h.jsx)(`div`,{className:`activity-page`,children:(0,h.jsxs)(`div`,{className:`activity-empty`,children:[(0,h.jsx)(`p`,{children:`You are not signed in.`}),(0,h.jsxs)(`p`,{children:[`Open the `,(0,h.jsx)(`a`,{href:`/`,className:`activity-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,h.jsx)(`div`,{className:`activity-page`,children:(0,h.jsxs)(`div`,{className:`activity-loading`,children:[(0,h.jsx)(i,{size:18,className:`spin`}),` Loading…`]})})}(0,p.createRoot)(document.getElementById(`root`)).render((0,h.jsx)(Z,{}));
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-TPjIAO9U.js";import{D as t,S as n,T as r,r as i}from"./useSubAccountSwitcher-v8LyBzZN.js";import{n as a,t as o}from"./AdminLoginScreens-DkxQZnvB.js";import{s}from"./useVoiceRecorder-DN4jYQ0A.js";import{a as c,t as l}from"./AdminShell-Cv_nIFGe.js";import"./Checkbox-CsTWK8mm.js";import{n as u,r as d}from"./page-BsCS0Dmc.js";import{c as f,o as p}from"./useSelectionMode-sph7AQT5.js";import"./graph-labels-C5qLwnWA.js";var m=r(),h=e(t(),1),g=n();function _({onOpen:e}){return(0,g.jsx)(`footer`,{className:`admin-footer`,children:(0,g.jsxs)(`div`,{className:`powered-by`,role:`button`,tabIndex:0,onClick:e,onKeyDown:t=>{(t.key===`Enter`||t.key===` `)&&(t.preventDefault(),e())},"aria-label":`Powered by Claude Code — show details`,children:[(0,g.jsx)(`img`,{src:`/brand/claude.png`,alt:`Claude`,className:`powered-by-icon`}),(0,g.jsx)(`span`,{children:`Powered by Claude Code`})]})})}function v(){let e=a(),[t,n]=(0,h.useState)(!1);(0,h.useEffect)(()=>{if(!t)return;let e=e=>{e.key===`Escape`&&n(!1)};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[t]);let r=(0,h.useCallback)(async()=>{let t=e.claudeInfo!=null;if(n(!0),t){console.info(`[admin-ui] claude-info-open cached=true ms=0`);return}let r=Date.now();try{let t=await fetch(`/api/admin/claude-info`);if(t.ok){let n=await t.json();e.setClaudeInfo(n)}console.info(`[admin-ui] claude-info-open cached=false ms=${Date.now()-r}`)}catch(e){console.error(`[admin-ui] claude-info-fetch-failed ms=${Date.now()-r} error="${e instanceof Error?e.message:String(e)}"`)}},[e]),m=(0,h.useCallback)(({code:t,path:n})=>{console.warn(`[admin-auth] outcome=chat-tab-logout-on-401 code=${t} path=${n}`),e.handleLogout()},[e]);return e.appState===`chat`?(0,g.jsx)(i,{cacheKey:e.cacheKey,onSessionExpired:m,surface:`chat`,children:(0,g.jsx)(l,{cacheKey:e.cacheKey,businessName:e.businessName,sessionId:e.sessionId,onLogout:e.handleLogout,onDisconnect:e.handleDisconnect,disconnecting:e.disconnecting,claudeConnected:e.claudeConnected,onConnectClaude:()=>e.setAppState(`connect-claude`),userName:e.userName,userAvatar:e.userAvatar,role:e.role,footer:(0,g.jsxs)(g.Fragment,{children:[(0,g.jsx)(_,{onOpen:r}),(0,g.jsx)(c,{show:t,onClose:()=>n(!1),claudeInfo:e.claudeInfo,messages:[],sessionElapsed:0,sessionId:e.sessionId,cacheKey:e.cacheKey})]}),children:t=>(0,g.jsx)(g.Fragment,{children:t.dataOpen&&e.cacheKey?(0,g.jsx)(u,{cacheKey:e.cacheKey}):t.selectedWhatsapp&&e.cacheKey?t.selectedWhatsapp.source===`store`&&t.selectedWhatsapp.remoteJid&&t.selectedWhatsapp.accountId?(0,g.jsx)(d,{accountId:t.selectedWhatsapp.accountId,remoteJid:t.selectedWhatsapp.remoteJid,contactName:p(t.selectedWhatsapp),sessionKey:e.cacheKey},f(t.selectedWhatsapp)):(0,g.jsx)(s,{sessionId:t.selectedWhatsapp.sessionId,projectDir:t.selectedWhatsapp.projectDir,sessionKey:e.cacheKey,forceDeliveredOnly:!0},f(t.selectedWhatsapp)):(0,g.jsx)(`main`,{})})})}):(0,g.jsx)(o,{auth:e})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(v,{}));
@@ -1 +0,0 @@
1
- import"./chunk-K5T4RW27-DAnRM04h.js";import{n as e}from"./chunk-7N4EOEYR-C49Mv-nQ.js";export{e as createArchitectureServices};
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-TPjIAO9U.js";import{D as t,S as n,T as r,_ as i,d as a,f as o,i as s,p as c,r as l,v as u}from"./useSubAccountSwitcher-v8LyBzZN.js";import{t as d,y as f}from"./AdminShell-Cv_nIFGe.js";import"./useSelectionMode-sph7AQT5.js";var p=i(`monitor-play`,[[`path`,{d:`M15.033 9.44a.647.647 0 0 1 0 1.12l-4.065 2.352a.645.645 0 0 1-.968-.56V7.648a.645.645 0 0 1 .967-.56z`,key:`vbtd3f`}],[`path`,{d:`M12 17v4`,key:`1riwvh`}],[`path`,{d:`M8 21h8`,key:`1ev6f3`}],[`rect`,{x:`2`,y:`3`,width:`20`,height:`14`,rx:`2`,key:`x3v2xh`}]]),m=r(),h=e(t(),1),g=n(),_=`maxy-vnc-popout`;function v(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(!1),[i,l]=(0,h.useState)(null),d=s(null);(0,h.useEffect)(()=>{let e=!1;return fetch(`/vnc-viewer.html`,{method:`HEAD`}).then(n=>{e||(console.info(`[browser-page] op=viewer-probe available=${n.ok}`),t(n.ok))}).catch(()=>{e||(console.info(`[browser-page] op=viewer-probe available=false`),t(!1))}),()=>{e=!0}},[]);let f=(0,h.useCallback)(()=>{window.open(`/vnc-popout.html?title=${encodeURIComponent(u.productName)}`,_,`width=1024,height=768`)},[]),m=(0,h.useCallback)(async()=>{r(!0),l(null);try{let e=await d(`/api/admin/browser/launch`,{method:`POST`});if(!e.ok){let t=await e.json().catch(()=>({}));throw Error(t.error||`Launch failed (${e.status})`)}}catch(e){l(e instanceof Error?e.message:String(e))}finally{r(!1)}},[d]);return e===null?(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(a,{size:18,className:`spin`}),` Checking viewer…`]})}):e?(0,g.jsxs)(`div`,{className:`vnc-surface`,children:[(0,g.jsxs)(`div`,{className:`vnc-surface__toolbar`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:m,disabled:n,children:[n?(0,g.jsx)(a,{size:14,className:`spin`}):(0,g.jsx)(o,{size:14}),` Launch browser`]}),(0,g.jsxs)(`button`,{type:`button`,className:`vnc-surface__btn`,onClick:f,children:[(0,g.jsx)(c,{size:14}),` Pop out`]}),i&&(0,g.jsx)(`span`,{className:`vnc-surface__error`,children:i})]}),(0,g.jsx)(`iframe`,{className:`vnc-surface__iframe`,src:`/vnc-viewer.html`,title:`VNC viewer`})]}):(0,g.jsx)(`div`,{className:`vnc-surface`,children:(0,g.jsxs)(`div`,{className:`vnc-surface__unavailable`,children:[(0,g.jsx)(p,{size:20}),(0,g.jsx)(`p`,{children:`VNC surface not available on this platform.`})]})})}function y(){let[e,t]=(0,h.useState)(null),[n,r]=(0,h.useState)(!1),[i,s]=(0,h.useState)(void 0),[c,u]=(0,h.useState)(null),[p,m]=(0,h.useState)(void 0),[_,y]=(0,h.useState)(null),[b,x]=(0,h.useState)(null);(0,h.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem(`maxy-admin-session-key`)}catch{}if(!n){t(null),r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&s(e.businessName),e.sessionId!==void 0&&u(e.sessionId??null),x(e.role??null),m(e.userName===void 0?null:e.userName),y(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let S=(0,h.useCallback)(()=>{try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},[]),[C,w]=(0,h.useState)(!1),T=(0,h.useCallback)(async()=>{w(!0);try{let e=await f();if(e){try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`}return e}finally{w(!1)}},[]);return n?e?(0,g.jsx)(l,{cacheKey:e,surface:`browser`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=browser`);try{sessionStorage.removeItem(`maxy-admin-session-key`)}catch{}window.location.href=`/`},children:(0,g.jsx)(d,{cacheKey:e,businessName:i,sessionId:c,onLogout:S,onDisconnect:T,disconnecting:C,userName:p,userAvatar:_,role:b,children:(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(o,{size:18}),` Browser`]})}),(0,g.jsx)(v,{})]})})}):(0,g.jsxs)(`div`,{className:`data-page`,children:[(0,g.jsx)(`header`,{className:`data-header`,children:(0,g.jsxs)(`h1`,{className:`data-title`,children:[(0,g.jsx)(o,{size:18}),` Browser`]})}),(0,g.jsxs)(`div`,{className:`data-empty`,children:[(0,g.jsx)(`p`,{children:`You are not signed in.`}),(0,g.jsxs)(`p`,{children:[`Open the `,(0,g.jsx)(`a`,{href:`/`,className:`data-link`,children:`main admin page`}),` and log in, then return here.`]})]})]}):(0,g.jsx)(`div`,{className:`data-page`,children:(0,g.jsxs)(`div`,{className:`data-loading`,children:[(0,g.jsx)(a,{size:18,className:`spin`}),` Loading…`]})})}(0,m.createRoot)(document.getElementById(`root`)).render((0,g.jsx)(y,{}));
@@ -1 +0,0 @@
1
- import{o as e}from"./chunk-TPjIAO9U.js";import{D as t,S as n,T as r,_ as i,a,d as o,l as s,o as c,p as l,r as u,w as d}from"./useSubAccountSwitcher-v8LyBzZN.js";import{d as f,t as p,y as m}from"./AdminShell-Cv_nIFGe.js";import{t as h}from"./chevron-left-BtfJD6LL.js";import{h as g}from"./useSelectionMode-sph7AQT5.js";var _=i(`calendar`,[[`path`,{d:`M8 2v4`,key:`1cmpym`}],[`path`,{d:`M16 2v4`,key:`4m81vk`}],[`rect`,{width:`18`,height:`18`,x:`3`,y:`4`,rx:`2`,key:`1hopcy`}],[`path`,{d:`M3 10h18`,key:`8toen8`}]]),v=i(`chevron-right`,[[`path`,{d:`m9 18 6-6-6-6`,key:`mthhwq`}]]),y=i(`clock`,[[`circle`,{cx:`12`,cy:`12`,r:`10`,key:`1mglay`}],[`path`,{d:`M12 6v6l4 2`,key:`mmk7yg`}]]),b=i(`map-pin`,[[`path`,{d:`M20 10c0 4.993-5.539 10.193-7.399 11.799a1 1 0 0 1-1.202 0C9.539 20.193 4 14.993 4 10a8 8 0 0 1 16 0`,key:`1r0f0z`}],[`circle`,{cx:`12`,cy:`10`,r:`3`,key:`ilqhr7`}]]),x=i(`sticky-note`,[[`path`,{d:`M21 9a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 15 3H5a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2z`,key:`1dfntj`}],[`path`,{d:`M15 3v5a1 1 0 0 0 1 1h5`,key:`6s6qgf`}]]),S=i(`user-plus`,[[`path`,{d:`M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2`,key:`1yyitq`}],[`circle`,{cx:`9`,cy:`7`,r:`4`,key:`nufk8`}],[`line`,{x1:`19`,x2:`19`,y1:`8`,y2:`14`,key:`1bvyxn`}],[`line`,{x1:`22`,x2:`16`,y1:`11`,y2:`11`,key:`1shjgl`}]]),C=r(),w=e(t(),1);function T(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate())}function E(e,t){let n=new Date(e);return n.setDate(n.getDate()+t),n}function D(e){let t=T(e),n=t.getDay();return E(t,n===0?-6:1-n)}function O(e){let t=D(e);return Array.from({length:7},(e,n)=>E(t,n))}function k(e){let t=D(new Date(e.getFullYear(),e.getMonth(),1));return Array.from({length:42},(e,n)=>E(t,n))}function A(){return Array.from({length:24},(e,t)=>t)}function ee(e){let t=e.getFullYear();return Array.from({length:12},(e,n)=>new Date(t,n,1))}function j(e,t){switch(e){case`day`:{let e=T(t);return{from:e,to:E(e,1)}}case`week`:{let e=D(t);return{from:e,to:E(e,7)}}case`month`:{let e=D(new Date(t.getFullYear(),t.getMonth(),1));return{from:e,to:E(e,42)}}case`year`:return{from:new Date(t.getFullYear(),0,1),to:new Date(t.getFullYear()+1,0,1)}}}function M(e,t,n){switch(e){case`day`:return E(t,n);case`week`:return E(t,n*7);case`month`:return new Date(t.getFullYear(),t.getMonth()+n,1);case`year`:return new Date(t.getFullYear()+n,t.getMonth(),1)}}function N(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function P(e,t){return{role:`button`,tabIndex:0,onClick:()=>t(e),onKeyDown:n=>{(n.key===`Enter`||n.key===` `)&&(n.preventDefault(),t(e))}}}var F=n(),I=[`Mon`,`Tue`,`Wed`,`Thu`,`Fri`,`Sat`,`Sun`],L=3;function R(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function te({anchor:e,meetings:t,onSelect:n}){let r=k(e),i=e.getMonth(),a=new Date;return(0,F.jsxs)(`div`,{className:`cal-month`,children:[(0,F.jsx)(`div`,{className:`cal-weekday-row`,children:I.map(e=>(0,F.jsx)(`div`,{className:`cal-weekday`,children:e},e))}),(0,F.jsx)(`div`,{className:`cal-month-grid`,children:r.map(e=>{let r=t.filter(t=>N(new Date(t.startsAt),e)).sort((e,t)=>e.startsAt.localeCompare(t.startsAt)),o=e.getMonth()!==i,s=N(e,a);return(0,F.jsxs)(`div`,{className:`cal-cell${o?` cal-cell-out`:``}${s?` cal-cell-today`:``}`,children:[(0,F.jsx)(`div`,{className:`cal-cell-num`,children:e.getDate()}),r.slice(0,L).map(e=>(0,F.jsxs)(`div`,{className:`cal-chip`,title:e.title??`Untitled`,...P(e,n),children:[!e.isAllDay&&(0,F.jsx)(`span`,{className:`cal-chip-time`,children:R(new Date(e.startsAt))}),e.title??`Untitled`]},e.meetingId)),r.length>L&&(0,F.jsxs)(`div`,{className:`cal-more`,children:[`+`,r.length-L,` more`]})]},e.toISOString())})})]})}var z=1440,B=1.8;function V(e){return e.getHours()*60+e.getMinutes()}function H(e){return e.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}function U({day:e,meetings:t,hourHeight:n,onSelect:r}){let i=n*24,a=t.filter(t=>!t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsx)(`div`,{className:`cal-day-col`,children:(0,F.jsxs)(`div`,{className:`cal-hours`,style:{height:`${i}px`},children:[Array.from({length:24},(e,t)=>(0,F.jsx)(`div`,{className:`cal-hour-line`,style:{top:`${t*n}px`}},t)),a.map(t=>{let n=new Date(t.startsAt),i=t.endsAt?new Date(t.endsAt):new Date(n.getTime()+30*6e4),a=V(n),o=N(i,e)?V(i):z,s=a/z*100,c=Math.max((o-a)/z*100,B);return(0,F.jsxs)(`div`,{className:`cal-event`,style:{top:`${s}%`,height:`${c}%`},title:t.title??`Untitled`,...P(t,r),children:[(0,F.jsx)(`span`,{className:`cal-event-time`,children:H(n)}),(0,F.jsx)(`span`,{className:`cal-event-title`,children:t.title??`Untitled`})]},t.meetingId)})]})})}var W=44;function G(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function K({anchor:e,meetings:t,onSelect:n}){let r=O(e),i=new Date;return(0,F.jsxs)(`div`,{className:`cal-timed`,children:[(0,F.jsxs)(`div`,{className:`cal-day-headrow`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`}),r.map(e=>(0,F.jsxs)(`div`,{className:`cal-day-head${N(e,i)?` cal-day-head-today`:``}`,children:[(0,F.jsx)(`span`,{className:`cal-day-head-name`,children:e.toLocaleDateString([],{weekday:`short`})}),(0,F.jsx)(`span`,{className:`cal-day-head-num`,children:e.getDate()})]},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e)).map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))},e.toISOString()))]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${W}px`},children:e===0?``:G(e)},e))}),r.map(e=>(0,F.jsx)(U,{day:e,meetings:t,hourHeight:W,onSelect:n},e.toISOString()))]})]})}var q=52;function J(e){let t=new Date;return t.setHours(e,0,0,0),t.toLocaleTimeString([],{hour:`numeric`})}function Y({anchor:e,meetings:t,onSelect:n}){let r=t.filter(t=>t.isAllDay&&N(new Date(t.startsAt),e));return(0,F.jsxs)(`div`,{className:`cal-timed cal-timed-single`,children:[(0,F.jsxs)(`div`,{className:`cal-allday-band`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:`All-day`}),(0,F.jsx)(`div`,{className:`cal-allday-cell`,children:r.map(e=>(0,F.jsx)(`div`,{className:`cal-allday-chip`,title:e.title??`Untitled`,...P(e,n),children:e.title??`Untitled`},e.meetingId))})]}),(0,F.jsxs)(`div`,{className:`cal-timed-cols`,children:[(0,F.jsx)(`div`,{className:`cal-timed-gutter`,children:A().map(e=>(0,F.jsx)(`div`,{className:`cal-hour-label`,style:{height:`${q}px`},children:e===0?``:J(e)},e))}),(0,F.jsx)(U,{day:e,meetings:t,hourHeight:q,onSelect:n})]})]})}var X=[`M`,`T`,`W`,`T`,`F`,`S`,`S`];function Z(e){return`${e.getFullYear()}-${e.getMonth()}-${e.getDate()}`}function ne({anchor:e,meetings:t,onPickMonth:n}){let r=new Date,i=new Set(t.map(e=>Z(new Date(e.startsAt))));return(0,F.jsx)(`div`,{className:`cal-year`,children:(0,F.jsx)(`div`,{className:`cal-year-grid`,children:ee(e).map(e=>{let t=k(e),a=e.getMonth();return(0,F.jsxs)(`button`,{type:`button`,className:`cal-mini`,onClick:()=>n(e),title:e.toLocaleDateString([],{month:`long`,year:`numeric`}),children:[(0,F.jsx)(`div`,{className:`cal-mini-title`,children:e.toLocaleDateString([],{month:`long`})}),(0,F.jsx)(`div`,{className:`cal-mini-weekrow`,children:X.map((e,t)=>(0,F.jsx)(`span`,{className:`cal-mini-weekday`,children:e},t))}),(0,F.jsx)(`div`,{className:`cal-mini-grid`,children:t.map(e=>{let t=e.getMonth()!==a,n=N(e,r),o=!t&&i.has(Z(e));return(0,F.jsxs)(`span`,{className:`cal-mini-day${t?` cal-mini-day-out`:``}${n?` cal-mini-day-today`:``}`,children:[e.getDate(),o&&(0,F.jsx)(`span`,{className:`cal-mini-dot`})]},e.toISOString())})})]},a)})})})}var re={meeting:`Meeting`,event:`Event`,task:`Task`};function ie(e){let t=new Date(e),n=e=>String(e).padStart(2,`0`);return`${t.getFullYear()}-${n(t.getMonth()+1)}-${n(t.getDate())}T${n(t.getHours())}:${n(t.getMinutes())}`}function ae(e){return new Date(e).toISOString()}function Q(e){return Math.floor(new Date(e).getTime()/6e4)}function oe(e){let t=new Date(e.startsAt);if(e.isAllDay)return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});let n=t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`}),r=t.toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`});return e.endsAt?`${n} · ${r} – ${new Date(e.endsAt).toLocaleTimeString([],{hour:`numeric`,minute:`2-digit`})}`:`${n} · ${r}`}function se(e){if(!e)return null;let t=e.match(/filename="([^"]+)"/);return t?t[1]:null}function ce(e,t){return e.email??`${e.name??`unknown`}-${t}`}function le({a:e}){let t=e.name||e.email||`Unknown`,n=e.name&&e.email?e.email:null;return(0,F.jsxs)(`span`,{className:`cal-attendee-lines`,children:[(0,F.jsx)(`span`,{className:`cal-attendee-name`,children:t}),n&&(0,F.jsx)(`span`,{className:`cal-attendee-email`,children:n})]})}function ue({meeting:e,adminFetch:t,onClose:n,onSaved:r,onDeleted:i}){let l=e.kind===`meeting`,[u,d]=(0,w.useState)(!1),[p,m]=(0,w.useState)(!1),[h,v]=(0,w.useState)(!1),[C,T]=(0,w.useState)(!1),[E,D]=(0,w.useState)(null),[O,k]=(0,w.useState)(e),[A,ee]=(0,w.useState)(e.title??``),[j,M]=(0,w.useState)(ie(e.startsAt)),[N,P]=(0,w.useState)(e.endsAt?ie(e.endsAt):``),[I,L]=(0,w.useState)(e.location??``),[R,te]=(0,w.useState)(e.privateNote??``),[z,B]=(0,w.useState)(``),[V,H]=(0,w.useState)(``);(0,w.useEffect)(()=>{let e=e=>{e.key===`Escape`&&!C&&n()};return window.addEventListener(`keydown`,e),()=>window.removeEventListener(`keydown`,e)},[C,n]);let U=(0,w.useCallback)(()=>{let e={},t=A.trim();t!==(O.title??``)&&(e.title=t);let n=ae(j);Q(n)!==Q(O.startsAt)&&(e.startsAt=n);let r=N?ae(N):null;(r===null?O.endsAt!==null:O.endsAt===null||Q(r)!==Q(O.endsAt))&&(e.endsAt=r);let i=I.trim()||null;i!==(O.location??null)&&(e.location=i);let a=R.trim()||null;return a!==(O.privateNote??null)&&(e.privateNote=a),e},[A,j,N,I,R,O]),W=(0,w.useCallback)(async()=>{let n=U();if(Object.keys(n).length===0){d(!1);return}T(!0),D(null);try{let i=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`PATCH`,headers:{"content-type":`application/json`},body:JSON.stringify(n)});if(!i.ok)throw Error(`HTTP ${i.status}`);let a=await i.json();k(a.meeting),r(a.meeting),d(!1)}catch(e){D(e instanceof Error?e.message:`Save failed`)}finally{T(!1)}},[t,U,e.meetingId,r]),G=(0,w.useCallback)(async()=>{let n=z.trim(),i=V.trim();if(!(!n&&!i)){T(!0),D(null);try{let a=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`POST`,headers:{"content-type":`application/json`},body:JSON.stringify({name:n||void 0,email:i||void 0})});if(!a.ok)throw Error(`HTTP ${a.status}`);let o=await a.json();k(o.meeting),r(o.meeting),B(``),H(``)}catch(e){D(e instanceof Error?e.message:`Add failed`)}finally{T(!1)}}},[t,z,V,e.meetingId,r]),K=(0,w.useCallback)(async n=>{let i=n.email?{email:n.email}:{name:n.name};T(!0),D(null);try{let n=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/attendees`,{method:`DELETE`,headers:{"content-type":`application/json`},body:JSON.stringify(i)});if(!n.ok)throw Error(`HTTP ${n.status}`);let a=await n.json();k(a.meeting),r(a.meeting)}catch(e){D(e instanceof Error?e.message:`Remove failed`)}finally{T(!1)}},[t,e.meetingId,r]),q=(0,w.useCallback)(async()=>{T(!0),D(null);try{let n=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}`,{method:`DELETE`});if(!n.ok)throw Error(`HTTP ${n.status}`);i(e.meetingId)}catch(e){D(e instanceof Error?e.message:`Delete failed`),T(!1)}},[t,e.meetingId,i]),J=(0,w.useCallback)(async n=>{v(!1),T(!0),D(null);try{let r=await t(`/api/admin/calendar/meetings/${encodeURIComponent(e.meetingId)}/ics?attendees=${n?`1`:`0`}`);if(!r.ok)throw Error(`HTTP ${r.status}`);let i=await r.blob(),a=se(r.headers.get(`content-disposition`))??`meeting.ics`,o=URL.createObjectURL(i),s=document.createElement(`a`);s.href=o,s.download=a,document.body.appendChild(s),s.click(),s.remove(),URL.revokeObjectURL(o)}catch(e){D(e instanceof Error?e.message:`Download failed`)}finally{T(!1)}},[t,e.meetingId]),Y=re[e.kind??`meeting`],X=z.trim().length>0||V.trim().length>0;return(0,F.jsx)(`div`,{className:`cal-modal-overlay`,onClick:()=>{C||n()},children:(0,F.jsxs)(`div`,{className:`cal-modal`,role:`dialog`,"aria-modal":`true`,"aria-label":u?`Edit meeting`:`Meeting detail`,onClick:e=>e.stopPropagation(),children:[(0,F.jsxs)(`div`,{className:`cal-modal-header`,children:[(0,F.jsx)(`span`,{className:`cal-modal-kind`,children:Y}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-close`,onClick:n,"aria-label":`Close`,autoFocus:!0,disabled:C,children:(0,F.jsx)(a,{size:16})})]}),!u&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsx)(`div`,{className:`cal-modal-title`,children:O.title??`Untitled`}),(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(y,{size:14}),(0,F.jsx)(`span`,{children:oe(O)})]}),O.location&&(0,F.jsxs)(`div`,{className:`cal-modal-row`,children:[(0,F.jsx)(b,{size:14}),(0,F.jsx)(`span`,{children:O.location})]}),O.attendees.length>0&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(f,{size:14}),(0,F.jsx)(`div`,{className:`cal-modal-attendees`,children:O.attendees.map((e,t)=>(0,F.jsx)(`div`,{className:`cal-attendee-row`,children:(0,F.jsx)(le,{a:e})},ce(e,t)))})]}),O.privateNote&&(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-row-top`,children:[(0,F.jsx)(x,{size:14}),(0,F.jsx)(`span`,{className:`cal-modal-note`,children:O.privateNote})]}),(0,F.jsxs)(`div`,{className:`cal-modal-row cal-modal-meta`,children:[(0,F.jsx)(_,{size:14}),(0,F.jsx)(`span`,{children:Y})]})]}),u&&(0,F.jsxs)(`div`,{className:`cal-modal-body`,children:[(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Title`}),(0,F.jsx)(`input`,{type:`text`,value:A,onChange:e=>ee(e.target.value),disabled:C})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Start`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:j,onChange:e=>M(e.target.value),disabled:C})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`End`}),(0,F.jsx)(`input`,{type:`datetime-local`,value:N,onChange:e=>P(e.target.value),disabled:C})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Location`}),(0,F.jsx)(`input`,{type:`text`,value:I,onChange:e=>L(e.target.value),disabled:C})]}),(0,F.jsxs)(`div`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Attendees`}),(0,F.jsxs)(`div`,{className:`cal-modal-attendees cal-modal-attendees-edit`,children:[O.attendees.length===0&&(0,F.jsx)(`div`,{className:`cal-attendee-empty`,children:`No attendees yet.`}),O.attendees.map((e,t)=>(0,F.jsxs)(`div`,{className:`cal-attendee-row cal-attendee-row-edit`,children:[(0,F.jsx)(le,{a:e}),(0,F.jsx)(`button`,{type:`button`,className:`cal-attendee-remove`,onClick:()=>K(e),disabled:C,"aria-label":`Remove ${e.name||e.email||`attendee`}`,children:(0,F.jsx)(a,{size:13})})]},ce(e,t)))]}),(0,F.jsxs)(`div`,{className:`cal-attendee-add`,children:[(0,F.jsx)(`input`,{type:`text`,placeholder:`Name`,value:z,onChange:e=>B(e.target.value),disabled:C,"aria-label":`Attendee name`}),(0,F.jsx)(`input`,{type:`email`,placeholder:`Email`,value:V,onChange:e=>H(e.target.value),disabled:C,"aria-label":`Attendee email`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn cal-attendee-add-btn`,onClick:G,disabled:C||!X,"aria-label":`Add attendee`,children:C?(0,F.jsx)(o,{size:13,className:`spin`}):(0,F.jsx)(S,{size:13})})]})]}),(0,F.jsxs)(`label`,{className:`cal-modal-field`,children:[(0,F.jsx)(`span`,{children:`Private note`}),(0,F.jsx)(`textarea`,{className:`cal-modal-textarea`,value:R,onChange:e=>te(e.target.value),disabled:C,rows:3,placeholder:`Only you and your team can see this.`})]})]}),E&&(0,F.jsx)(`div`,{className:`cal-modal-error`,children:E}),l&&(0,F.jsxs)(`div`,{className:`cal-modal-actions`,children:[!u&&!p&&!h&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>d(!0),disabled:C,children:[(0,F.jsx)(s,{size:14}),` Edit`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:()=>m(!0),disabled:C,children:[(0,F.jsx)(c,{size:14}),` Delete`]}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-download`,onClick:()=>{O.attendees.length>0?v(!0):J(!1)},disabled:C,children:[C?(0,F.jsx)(o,{size:14,className:`spin`}):(0,F.jsx)(g,{size:14}),` Download`]})]}),h&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Include attendees in the file?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:()=>J(!0),disabled:C,children:[C?(0,F.jsx)(o,{size:14,className:`spin`}):null,` Yes`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>J(!1),disabled:C,children:`No`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>v(!1),disabled:C,children:`Cancel`})]}),u&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-primary`,onClick:W,disabled:C,children:[C?(0,F.jsx)(o,{size:14,className:`spin`}):null,` Save`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>{d(!1),D(null)},disabled:C,children:`Cancel`})]}),p&&(0,F.jsxs)(F.Fragment,{children:[(0,F.jsx)(`span`,{className:`cal-modal-confirm-text`,children:`Delete this meeting?`}),(0,F.jsxs)(`button`,{type:`button`,className:`cal-modal-btn cal-modal-btn-danger`,onClick:q,disabled:C,children:[C?(0,F.jsx)(o,{size:14,className:`spin`}):null,` Delete`]}),(0,F.jsx)(`button`,{type:`button`,className:`cal-modal-btn`,onClick:()=>m(!1),disabled:C,children:`Cancel`})]})]})]})})}var $=`maxy-admin-session-key`,de=[`day`,`week`,`month`,`year`];function fe(e,t){switch(e){case`day`:return t.toLocaleDateString([],{weekday:`long`,day:`numeric`,month:`long`,year:`numeric`});case`week`:{let{from:e,to:n}=j(`week`,t),r=new Date(n.getTime()-1);return`${e.toLocaleDateString([],{day:`numeric`,month:`short`})} – ${r.toLocaleDateString([],{day:`numeric`,month:`short`,year:`numeric`})}`}case`month`:return t.toLocaleDateString([],{month:`long`,year:`numeric`});case`year`:return String(t.getFullYear())}}function pe(){let[e,t]=(0,w.useState)(null),[n,r]=(0,w.useState)(!1),[i,a]=(0,w.useState)(void 0),[s,c]=(0,w.useState)(null),[l,d]=(0,w.useState)(void 0),[f,h]=(0,w.useState)(null),[g,_]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1,n=null;try{n=sessionStorage.getItem($)}catch{}if(!n){r(!0);return}return fetch(`/api/admin/session?session_key=${encodeURIComponent(n)}`).then(async i=>{if(!e){if(i.status===401){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`;return}if(i.ok)try{let e=await i.json();typeof e.businessName==`string`&&a(e.businessName),e.sessionId!==void 0&&c(e.sessionId??null),_(e.role??null),d(e.userName===void 0?null:e.userName),h(e.avatar??null)}catch{}t(n),r(!0)}}).catch(()=>{e||(t(n),r(!0))}),()=>{e=!0}},[]);let v=(0,w.useCallback)(()=>{try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},[]),[y,b]=(0,w.useState)(!1),x=(0,w.useCallback)(async()=>{b(!0);try{let e=await m();if(e){try{sessionStorage.removeItem($)}catch{}window.location.href=`/`}return e}finally{b(!1)}},[]);return n?e?(0,F.jsx)(u,{cacheKey:e,surface:`calendar`,onSessionExpired:({code:e,path:t})=>{console.warn(`[admin-auth] outcome=session-expired-redirect code=${e} path=${t} surface=calendar`);try{sessionStorage.removeItem($)}catch{}window.location.href=`/`},children:(0,F.jsx)(p,{cacheKey:e,businessName:i,sessionId:s,onLogout:v,onDisconnect:x,disconnecting:y,userName:l,userAvatar:f,role:g,children:(0,F.jsx)(me,{cacheKey:e})})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-empty`,children:[(0,F.jsx)(`p`,{children:`You are not signed in.`}),(0,F.jsxs)(`p`,{children:[`Open the `,(0,F.jsx)(`a`,{href:`/`,className:`cal-link`,children:`main admin page`}),` and log in, then return here.`]})]})}):(0,F.jsx)(`div`,{className:`cal-page`,children:(0,F.jsxs)(`div`,{className:`cal-loading`,children:[(0,F.jsx)(o,{size:18,className:`spin`}),` Loading…`]})})}function me({cacheKey:e}){let{adminFetch:t,sessionRefetchNonce:n}=d({initialCacheKey:e,surface:`calendar`}),[r,i]=(0,w.useState)(`month`),[a,s]=(0,w.useState)(()=>new Date),[c,u]=(0,w.useState)([]),[f,p]=(0,w.useState)(!1),[m,g]=(0,w.useState)(null),[y,b]=(0,w.useState)(null),[x,S]=(0,w.useState)(null);(0,w.useEffect)(()=>{let e=!1;return t(`/api/admin/calendar/booking-link`).then(async t=>{if(e||!t.ok)return;let n=await t.json();typeof n.bookingDomain==`string`&&n.bookingDomain&&S(n.bookingDomain)}).catch(()=>{}),()=>{e=!0}},[t]),(0,w.useEffect)(()=>{let e=!1,{from:n,to:i}=j(r,a);return p(!0),g(null),t(`/api/admin/calendar/meetings?from=${encodeURIComponent(n.toISOString())}&to=${encodeURIComponent(i.toISOString())}`).then(async t=>{if(e)return;if(!t.ok)throw Error(`HTTP ${t.status}`);let n=await t.json();u(Array.isArray(n.meetings)?n.meetings:[])}).catch(t=>{e||(g(t instanceof Error?t.message:`Failed to load`),u([]))}).finally(()=>{e||p(!1)}),()=>{e=!0}},[r,a,n,t]);let C=(0,w.useCallback)(()=>s(new Date),[]),T=(0,w.useCallback)(()=>s(e=>M(r,e,-1)),[r]),E=(0,w.useCallback)(()=>s(e=>M(r,e,1)),[r]),D=(0,w.useCallback)(e=>{s(e),i(`month`)},[]);(0,w.useEffect)(()=>{b(null)},[r,a]);let O=(0,w.useCallback)(e=>{u(t=>t.map(t=>t.meetingId===e.meetingId?e:t)),b(e)},[]),k=(0,w.useCallback)(e=>{u(t=>t.filter(t=>t.meetingId!==e)),b(null)},[]);return(0,F.jsxs)(`div`,{className:`cal-page`,children:[(0,F.jsxs)(`header`,{className:`cal-header`,children:[(0,F.jsxs)(`div`,{className:`cal-title`,children:[(0,F.jsx)(_,{size:20}),` Calendar`]}),(0,F.jsxs)(`div`,{className:`cal-nav`,children:[(0,F.jsx)(`button`,{type:`button`,className:`cal-today-btn`,onClick:C,children:`Today`}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:T,"aria-label":`Previous`,children:(0,F.jsx)(h,{size:18})}),(0,F.jsx)(`button`,{type:`button`,className:`cal-nav-btn`,onClick:E,"aria-label":`Next`,children:(0,F.jsx)(v,{size:18})}),(0,F.jsx)(`span`,{className:`cal-range-label`,children:fe(r,a)}),f&&(0,F.jsx)(o,{size:16,className:`spin`})]}),(0,F.jsx)(`div`,{className:`cal-views`,children:de.map(e=>(0,F.jsx)(`button`,{type:`button`,className:`cal-view-btn${e===r?` cal-view-btn-active`:``}`,onClick:()=>i(e),children:e.charAt(0).toUpperCase()+e.slice(1)},e))}),x&&(0,F.jsxs)(`a`,{className:`cal-booking-link`,href:`https://${x}`,target:`_blank`,rel:`noopener noreferrer`,children:[(0,F.jsx)(l,{size:14}),` Booking page`]})]}),(0,F.jsxs)(`div`,{className:`cal-body`,children:[m&&(0,F.jsxs)(`div`,{className:`cal-error`,children:[`Could not load the calendar: `,m]}),r===`day`&&(0,F.jsx)(Y,{anchor:a,meetings:c,onSelect:b}),r===`week`&&(0,F.jsx)(K,{anchor:a,meetings:c,onSelect:b}),r===`month`&&(0,F.jsx)(te,{anchor:a,meetings:c,onSelect:b}),r===`year`&&(0,F.jsx)(ne,{anchor:a,meetings:c,onPickMonth:D})]}),y&&(0,F.jsx)(ue,{meeting:y,adminFetch:t,onClose:()=>b(null),onSaved:O,onDeleted:k})]})}(0,C.createRoot)(document.getElementById(`root`)).render((0,F.jsx)(pe,{}));
@@ -1 +0,0 @@
1
- import{it as e,rt as t}from"./chunk-ICPOFSXX-Bi-_c351.js";var n=(n,r)=>e.lang.round(t.parse(n)[r]);export{n as t};
@@ -1 +0,0 @@
1
- import{S as e,T as t}from"./useSubAccountSwitcher-v8LyBzZN.js";import"./useVoiceRecorder-DN4jYQ0A.js";import"./AdminShell-Cv_nIFGe.js";import{n}from"./page-B5YngOrK.js";import"./useCopyFeedback-wtUHGohk.js";import"./useSelectionMode-sph7AQT5.js";var r=t(),i=e();(0,r.createRoot)(document.getElementById(`root`)).render((0,i.jsx)(n,{}));
@@ -1 +0,0 @@
1
- import{_ as e}from"./useSubAccountSwitcher-v8LyBzZN.js";var t=e(`chevron-left`,[[`path`,{d:`m15 18-6-6 6-6`,key:`1wnfg3`}]]);export{t};