@saluzi/saluzi-edu 0.2.20 → 0.2.21

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 (185) hide show
  1. package/dist/cli.js +106 -83
  2. package/dist/rcs-web/assets/AdminPanel-B0hhIa7W.js +1 -0
  3. package/dist/rcs-web/assets/Claim-BTx12YJw.js +1 -0
  4. package/dist/rcs-web/assets/Dashboard-C_qeuXGp.js +1 -0
  5. package/dist/rcs-web/assets/Join-DDMaEXX-.js +1 -0
  6. package/dist/rcs-web/assets/Login-eCEGVdjw.js +1 -0
  7. package/dist/rcs-web/assets/Register-gqlt4O0J.js +1 -0
  8. package/dist/rcs-web/assets/{SessionDetail-B5C0o1YT.js → SessionDetail-BfrG6lOA.js} +10 -10
  9. package/dist/rcs-web/assets/SessionVisibilityBadge-CN3bz2gb.js +11 -0
  10. package/dist/rcs-web/assets/Setup-yO-c5mfy.js +1 -0
  11. package/dist/rcs-web/assets/{ShareLanding-DBC9gbJo.js → ShareLanding-S3XUdrDL.js} +1 -1
  12. package/dist/rcs-web/assets/TeamCreate-DGUK4ghi.js +1 -0
  13. package/dist/rcs-web/assets/TeamDetail-Ct07DirR.js +6 -0
  14. package/dist/rcs-web/assets/TeamList-CJTYa2Ah.js +1 -0
  15. package/dist/rcs-web/assets/TeamSettings-DXb0w8GG.js +1 -0
  16. package/dist/rcs-web/assets/UserSettings-DzreS8Mi.js +1 -0
  17. package/dist/rcs-web/assets/{arc-DBPKxYzS.js → arc-wiB_u0W8.js} +1 -1
  18. package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-D88rj_js.js → architectureDiagram-3BPJPVTR-70tgIgZq.js} +1 -1
  19. package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-xzgUpRMn.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-Drz4LSdp.js} +1 -1
  20. package/dist/rcs-web/assets/{c4Diagram-AAUBKEIU-vpg_EoPb.js → c4Diagram-AAUBKEIU-BM7C7SEx.js} +1 -1
  21. package/dist/rcs-web/assets/channel-D-a_TNjA.js +1 -0
  22. package/dist/rcs-web/assets/{chunk-2J33WTMH-DXWsXvhS.js → chunk-2J33WTMH-BSqxyVTy.js} +1 -1
  23. package/dist/rcs-web/assets/{chunk-4BX2VUAB-BtTxwj9K.js → chunk-4BX2VUAB-HFKHN20V.js} +1 -1
  24. package/dist/rcs-web/assets/{chunk-55IACEB6-D2-Q95qg.js → chunk-55IACEB6-DOBdvIv4.js} +1 -1
  25. package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-Ce3e5x8u.js → dist/rcs-web/assets/chunk-727SXJPM-B2qn-WmZ.js} +1 -1
  26. package/dist/rcs-web/assets/{chunk-AQP2D5EJ-C0UbKVtd.js → chunk-AQP2D5EJ-DFC3ivzL.js} +1 -1
  27. package/dist/rcs-web/assets/{chunk-FMBD7UC4-BCwppVqh.js → chunk-FMBD7UC4-CkVr3MVW.js} +1 -1
  28. package/dist/rcs-web/assets/{chunk-ND2GUHAM-CnOBwWrm.js → chunk-ND2GUHAM-B2WO2xxD.js} +1 -1
  29. package/dist/rcs-web/assets/{chunk-QZHKN3VN-CDdzB71P.js → chunk-QZHKN3VN-YpZyVA2c.js} +1 -1
  30. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-Dl3V5TVw.js +1 -0
  31. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-Dl3V5TVw.js +1 -0
  32. package/dist/rcs-web/assets/{code-block-IT6T5CEO-C1_H_ztH.js → code-block-IT6T5CEO-Bmds1dKk.js} +1 -1
  33. package/dist/rcs-web/assets/{copy-DXU1lQqc.js → copy-DdSkINCW.js} +1 -1
  34. package/dist/rcs-web/assets/{cose-bilkent-S5V4N54A-BC6nfjTF.js → cose-bilkent-S5V4N54A-CTtGg7Fx.js} +1 -1
  35. package/dist/rcs-web/assets/{dagre-BM42HDAG-CEPR_pRx.js → dagre-BM42HDAG-CFX48pZZ.js} +1 -1
  36. package/dist/rcs-web/assets/{diagram-2AECGRRQ-fVMGnSYa.js → diagram-2AECGRRQ-BwZE2jAF.js} +1 -1
  37. package/dist/rcs-web/assets/{diagram-5GNKFQAL-BPzN2rbK.js → diagram-5GNKFQAL-BuHnggju.js} +1 -1
  38. package/dist/rcs-web/assets/{diagram-KO2AKTUF-Boneg9n-.js → diagram-KO2AKTUF-Dmd3MO7f.js} +1 -1
  39. package/{packages/remote-control-server/web/dist/assets/diagram-LMA3HP47-B8AtvjO9.js → dist/rcs-web/assets/diagram-LMA3HP47-34ZNfvQd.js} +1 -1
  40. package/dist/rcs-web/assets/{diagram-OG6HWLK6-DjY7A8jK.js → diagram-OG6HWLK6-CjZvlFxO.js} +1 -1
  41. package/{packages/remote-control-server/web/dist/assets/erDiagram-TEJ5UH35-C1BEfKxk.js → dist/rcs-web/assets/erDiagram-TEJ5UH35-BWR0WD_N.js} +1 -1
  42. package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-7TbI9MLV.js → flowDiagram-I6XJVG4X-DjZ7uFyw.js} +1 -1
  43. package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-CMAV0A01.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-BuAM7awZ.js} +1 -1
  44. package/dist/rcs-web/assets/{gitGraphDiagram-PVQCEYII-DAlR8G81.js → gitGraphDiagram-PVQCEYII-B_6bqpod.js} +1 -1
  45. package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-0T0DAV4W.js → infoDiagram-5YYISTIA-BbhCTAn2.js} +1 -1
  46. package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-BAw8txlx.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-1VPCYnPS.js} +1 -1
  47. package/{packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-DWvYKwz-.js → dist/rcs-web/assets/journeyDiagram-JHISSGLW-Dzl0f8Im.js} +1 -1
  48. package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-Qzqw1H5B.js → kanban-definition-UN3LZRKU-BGoVgBze.js} +1 -1
  49. package/{packages/remote-control-server/web/dist/assets/linear-D2KIJoCI.js → dist/rcs-web/assets/linear-DF7ChHtW.js} +1 -1
  50. package/dist/rcs-web/assets/main-B_OE0doJ.css +1 -0
  51. package/dist/rcs-web/assets/main-CEsvX5rj.js +253 -0
  52. package/dist/rcs-web/assets/{mermaid-VLURNSYL-CxWk1wHz.js → mermaid-VLURNSYL-3EqupjjN.js} +4 -4
  53. package/dist/rcs-web/assets/{mermaid.core-C48YvKu4.js → mermaid.core-BnVRH5R_.js} +5 -5
  54. package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-BfmcTuCA.js → mindmap-definition-RKZ34NQL-R3usKqMg.js} +1 -1
  55. package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-DVNZpnfb.js → pieDiagram-4H26LBE5-U1XXn3t9.js} +1 -1
  56. package/{packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-COL55Z3i.js → dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-CocIpolQ.js} +1 -1
  57. package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-CFczYQ0a.js → requirementDiagram-4Y6WPE33-DX7pHOr5.js} +1 -1
  58. package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-BrQEv3WQ.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-TD6XCrii.js} +1 -1
  59. package/{packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-CMxtYmQu.js → dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-EyZvfcbT.js} +1 -1
  60. package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-Dw9xJZ-A.js → stateDiagram-AJRCARHV-B_SU6QSv.js} +1 -1
  61. package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-Br0D-weX.js → stateDiagram-v2-BHNVJYJU-C8vEqOLP.js} +1 -1
  62. package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-DuWDwYBt.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-C2XHcj96.js} +1 -1
  63. package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN--7IV65HQ.js → vennDiagram-CIIHVFJN-aAmhPOm3.js} +1 -1
  64. package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-CVTgWbvT.js → wardleyDiagram-YWT4CUSO-Db_mMfd6.js} +1 -1
  65. package/dist/rcs-web/assets/workerType-Bd-zteMi.js +1 -0
  66. package/{packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-B9om4xAF.js → dist/rcs-web/assets/xychartDiagram-2RQKCTM6-DPjdOqDe.js} +1 -1
  67. package/dist/rcs-web/index.html +2 -2
  68. package/package.json +1 -1
  69. package/packages/remote-control-server/src/__tests__/bind-replacement.test.ts +5 -5
  70. package/packages/remote-control-server/src/__tests__/phase4-integration.test.ts +2 -2
  71. package/packages/remote-control-server/src/__tests__/route-mounting.test.ts +2 -2
  72. package/packages/remote-control-server/src/__tests__/routes.test.ts +21 -5
  73. package/packages/remote-control-server/src/__tests__/shares.test.ts +21 -20
  74. package/packages/remote-control-server/src/__tests__/teams.test.ts +119 -0
  75. package/packages/remote-control-server/src/config.ts +3 -0
  76. package/packages/remote-control-server/src/db/schema.sql +6 -1
  77. package/packages/remote-control-server/src/db/sqlite.ts +46 -1
  78. package/packages/remote-control-server/src/registerRoutes.ts +17 -1
  79. package/packages/remote-control-server/src/routes/v1/environments.ts +35 -1
  80. package/packages/remote-control-server/src/routes/v1/sessions.ts +48 -2
  81. package/packages/remote-control-server/src/routes/web/auth-routes.ts +64 -0
  82. package/packages/remote-control-server/src/routes/web/environments.ts +7 -3
  83. package/packages/remote-control-server/src/routes/web/shares.ts +17 -26
  84. package/packages/remote-control-server/src/routes/web/teams.ts +241 -4
  85. package/packages/remote-control-server/src/services/environment.ts +12 -1
  86. package/packages/remote-control-server/src/store.ts +87 -4
  87. package/packages/remote-control-server/src/types/api.ts +1 -0
  88. package/packages/remote-control-server/web/dist/assets/AdminPanel-B0hhIa7W.js +1 -0
  89. package/packages/remote-control-server/web/dist/assets/Claim-BTx12YJw.js +1 -0
  90. package/packages/remote-control-server/web/dist/assets/Dashboard-C_qeuXGp.js +1 -0
  91. package/packages/remote-control-server/web/dist/assets/Join-DDMaEXX-.js +1 -0
  92. package/packages/remote-control-server/web/dist/assets/Login-eCEGVdjw.js +1 -0
  93. package/packages/remote-control-server/web/dist/assets/Register-gqlt4O0J.js +1 -0
  94. package/packages/remote-control-server/web/dist/assets/{SessionDetail-B5C0o1YT.js → SessionDetail-BfrG6lOA.js} +10 -10
  95. package/packages/remote-control-server/web/dist/assets/SessionVisibilityBadge-CN3bz2gb.js +11 -0
  96. package/packages/remote-control-server/web/dist/assets/Setup-yO-c5mfy.js +1 -0
  97. package/packages/remote-control-server/web/dist/assets/{ShareLanding-DBC9gbJo.js → ShareLanding-S3XUdrDL.js} +1 -1
  98. package/packages/remote-control-server/web/dist/assets/TeamCreate-DGUK4ghi.js +1 -0
  99. package/packages/remote-control-server/web/dist/assets/TeamDetail-Ct07DirR.js +6 -0
  100. package/packages/remote-control-server/web/dist/assets/TeamList-CJTYa2Ah.js +1 -0
  101. package/packages/remote-control-server/web/dist/assets/TeamSettings-DXb0w8GG.js +1 -0
  102. package/packages/remote-control-server/web/dist/assets/UserSettings-DzreS8Mi.js +1 -0
  103. package/packages/remote-control-server/web/dist/assets/{arc-DBPKxYzS.js → arc-wiB_u0W8.js} +1 -1
  104. package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-D88rj_js.js → architectureDiagram-3BPJPVTR-70tgIgZq.js} +1 -1
  105. package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-xzgUpRMn.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-Drz4LSdp.js} +1 -1
  106. package/packages/remote-control-server/web/dist/assets/{c4Diagram-AAUBKEIU-vpg_EoPb.js → c4Diagram-AAUBKEIU-BM7C7SEx.js} +1 -1
  107. package/packages/remote-control-server/web/dist/assets/channel-D-a_TNjA.js +1 -0
  108. package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-DXWsXvhS.js → chunk-2J33WTMH-BSqxyVTy.js} +1 -1
  109. package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-BtTxwj9K.js → chunk-4BX2VUAB-HFKHN20V.js} +1 -1
  110. package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-D2-Q95qg.js → chunk-55IACEB6-DOBdvIv4.js} +1 -1
  111. package/{dist/rcs-web/assets/chunk-727SXJPM-Ce3e5x8u.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-B2qn-WmZ.js} +1 -1
  112. package/packages/remote-control-server/web/dist/assets/{chunk-AQP2D5EJ-C0UbKVtd.js → chunk-AQP2D5EJ-DFC3ivzL.js} +1 -1
  113. package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-BCwppVqh.js → chunk-FMBD7UC4-CkVr3MVW.js} +1 -1
  114. package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-CnOBwWrm.js → chunk-ND2GUHAM-B2WO2xxD.js} +1 -1
  115. package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-CDdzB71P.js → chunk-QZHKN3VN-YpZyVA2c.js} +1 -1
  116. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-Dl3V5TVw.js +1 -0
  117. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-Dl3V5TVw.js +1 -0
  118. package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-C1_H_ztH.js → code-block-IT6T5CEO-Bmds1dKk.js} +1 -1
  119. package/packages/remote-control-server/web/dist/assets/{copy-DXU1lQqc.js → copy-DdSkINCW.js} +1 -1
  120. package/packages/remote-control-server/web/dist/assets/{cose-bilkent-S5V4N54A-BC6nfjTF.js → cose-bilkent-S5V4N54A-CTtGg7Fx.js} +1 -1
  121. package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-CEPR_pRx.js → dagre-BM42HDAG-CFX48pZZ.js} +1 -1
  122. package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-fVMGnSYa.js → diagram-2AECGRRQ-BwZE2jAF.js} +1 -1
  123. package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-BPzN2rbK.js → diagram-5GNKFQAL-BuHnggju.js} +1 -1
  124. package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-Boneg9n-.js → diagram-KO2AKTUF-Dmd3MO7f.js} +1 -1
  125. package/{dist/rcs-web/assets/diagram-LMA3HP47-B8AtvjO9.js → packages/remote-control-server/web/dist/assets/diagram-LMA3HP47-34ZNfvQd.js} +1 -1
  126. package/packages/remote-control-server/web/dist/assets/{diagram-OG6HWLK6-DjY7A8jK.js → diagram-OG6HWLK6-CjZvlFxO.js} +1 -1
  127. package/{dist/rcs-web/assets/erDiagram-TEJ5UH35-C1BEfKxk.js → packages/remote-control-server/web/dist/assets/erDiagram-TEJ5UH35-BWR0WD_N.js} +1 -1
  128. package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-7TbI9MLV.js → flowDiagram-I6XJVG4X-DjZ7uFyw.js} +1 -1
  129. package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-CMAV0A01.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-BuAM7awZ.js} +1 -1
  130. package/packages/remote-control-server/web/dist/assets/{gitGraphDiagram-PVQCEYII-DAlR8G81.js → gitGraphDiagram-PVQCEYII-B_6bqpod.js} +1 -1
  131. package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-0T0DAV4W.js → infoDiagram-5YYISTIA-BbhCTAn2.js} +1 -1
  132. package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-BAw8txlx.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-1VPCYnPS.js} +1 -1
  133. package/{dist/rcs-web/assets/journeyDiagram-JHISSGLW-DWvYKwz-.js → packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-Dzl0f8Im.js} +1 -1
  134. package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-Qzqw1H5B.js → kanban-definition-UN3LZRKU-BGoVgBze.js} +1 -1
  135. package/{dist/rcs-web/assets/linear-D2KIJoCI.js → packages/remote-control-server/web/dist/assets/linear-DF7ChHtW.js} +1 -1
  136. package/packages/remote-control-server/web/dist/assets/main-B_OE0doJ.css +1 -0
  137. package/packages/remote-control-server/web/dist/assets/main-CEsvX5rj.js +253 -0
  138. package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-CxWk1wHz.js → mermaid-VLURNSYL-3EqupjjN.js} +4 -4
  139. package/packages/remote-control-server/web/dist/assets/{mermaid.core-C48YvKu4.js → mermaid.core-BnVRH5R_.js} +5 -5
  140. package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-BfmcTuCA.js → mindmap-definition-RKZ34NQL-R3usKqMg.js} +1 -1
  141. package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-DVNZpnfb.js → pieDiagram-4H26LBE5-U1XXn3t9.js} +1 -1
  142. package/{dist/rcs-web/assets/quadrantDiagram-W4KKPZXB-COL55Z3i.js → packages/remote-control-server/web/dist/assets/quadrantDiagram-W4KKPZXB-CocIpolQ.js} +1 -1
  143. package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-CFczYQ0a.js → requirementDiagram-4Y6WPE33-DX7pHOr5.js} +1 -1
  144. package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-BrQEv3WQ.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-TD6XCrii.js} +1 -1
  145. package/{dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-CMxtYmQu.js → packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-EyZvfcbT.js} +1 -1
  146. package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-Dw9xJZ-A.js → stateDiagram-AJRCARHV-B_SU6QSv.js} +1 -1
  147. package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-Br0D-weX.js → stateDiagram-v2-BHNVJYJU-C8vEqOLP.js} +1 -1
  148. package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-DuWDwYBt.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-C2XHcj96.js} +1 -1
  149. package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN--7IV65HQ.js → vennDiagram-CIIHVFJN-aAmhPOm3.js} +1 -1
  150. package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-CVTgWbvT.js → wardleyDiagram-YWT4CUSO-Db_mMfd6.js} +1 -1
  151. package/packages/remote-control-server/web/dist/assets/workerType-Bd-zteMi.js +1 -0
  152. package/{dist/rcs-web/assets/xychartDiagram-2RQKCTM6-B9om4xAF.js → packages/remote-control-server/web/dist/assets/xychartDiagram-2RQKCTM6-DPjdOqDe.js} +1 -1
  153. package/packages/remote-control-server/web/dist/index.html +2 -2
  154. package/dist/rcs-web/assets/AdminPanel-CQU763nr.js +0 -1
  155. package/dist/rcs-web/assets/Dashboard-B1hQfqI9.js +0 -1
  156. package/dist/rcs-web/assets/Join-7hMl360t.js +0 -1
  157. package/dist/rcs-web/assets/Login-BE8mNc0U.js +0 -1
  158. package/dist/rcs-web/assets/SessionVisibilityBadge-CQN3bJW4.js +0 -11
  159. package/dist/rcs-web/assets/Setup-CqZ5gEBQ.js +0 -1
  160. package/dist/rcs-web/assets/TeamCreate-DSYdTaPe.js +0 -1
  161. package/dist/rcs-web/assets/TeamDetail-CmJGsgOP.js +0 -1
  162. package/dist/rcs-web/assets/TeamList-BMS_Qq8U.js +0 -1
  163. package/dist/rcs-web/assets/TeamSettings-C0sYgCFT.js +0 -1
  164. package/dist/rcs-web/assets/UserSettings-CqzeJ5cc.js +0 -1
  165. package/dist/rcs-web/assets/channel-Daz3yMSu.js +0 -1
  166. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DufdcV1P.js +0 -1
  167. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DufdcV1P.js +0 -1
  168. package/dist/rcs-web/assets/main-EP6Lac2m.css +0 -1
  169. package/dist/rcs-web/assets/main-J6cPs2y8.js +0 -253
  170. package/packages/remote-control-server/web/dist/assets/AdminPanel-CQU763nr.js +0 -1
  171. package/packages/remote-control-server/web/dist/assets/Dashboard-B1hQfqI9.js +0 -1
  172. package/packages/remote-control-server/web/dist/assets/Join-7hMl360t.js +0 -1
  173. package/packages/remote-control-server/web/dist/assets/Login-BE8mNc0U.js +0 -1
  174. package/packages/remote-control-server/web/dist/assets/SessionVisibilityBadge-CQN3bJW4.js +0 -11
  175. package/packages/remote-control-server/web/dist/assets/Setup-CqZ5gEBQ.js +0 -1
  176. package/packages/remote-control-server/web/dist/assets/TeamCreate-DSYdTaPe.js +0 -1
  177. package/packages/remote-control-server/web/dist/assets/TeamDetail-CmJGsgOP.js +0 -1
  178. package/packages/remote-control-server/web/dist/assets/TeamList-BMS_Qq8U.js +0 -1
  179. package/packages/remote-control-server/web/dist/assets/TeamSettings-C0sYgCFT.js +0 -1
  180. package/packages/remote-control-server/web/dist/assets/UserSettings-CqzeJ5cc.js +0 -1
  181. package/packages/remote-control-server/web/dist/assets/channel-Daz3yMSu.js +0 -1
  182. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DufdcV1P.js +0 -1
  183. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DufdcV1P.js +0 -1
  184. package/packages/remote-control-server/web/dist/assets/main-EP6Lac2m.css +0 -1
  185. package/packages/remote-control-server/web/dist/assets/main-J6cPs2y8.js +0 -253
@@ -0,0 +1 @@
1
+ import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{a1 as x,a2 as o,q as m,Y as s,K as l,i as u}from"./main-CEsvX5rj.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function j(){x();const[a,i]=d.useState([]),{myTeams:r,isLoading:c}=o(),n=d.useCallback(async()=>{try{const t=await m();i(t||[])}catch(t){console.error("Admin: failed to load sessions",t)}},[]);return d.useEffect(()=>{n()},[n]),e.jsx("div",{className:"flex-1 overflow-y-auto",children:e.jsxs("div",{className:"mx-auto max-w-5xl px-4 py-8",children:[e.jsx("h1",{className:"mb-6 font-display text-2xl font-semibold text-text-primary",children:s("admin.title")}),e.jsxs("section",{className:"mb-10",children:[e.jsxs("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:[s("admin.teams")," (",r.length,")"]}),c?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("common.loading")}):r.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("admin.noTeams")}):e.jsx("div",{className:"space-y-2",children:r.map(t=>e.jsxs("a",{href:`/teams/${t.slug}`,className:"flex items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 no-underline transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("span",{className:"font-medium text-text-primary",children:t.name}),e.jsx("span",{className:"ml-2 text-xs text-text-muted",children:t.slug})]}),e.jsx("span",{className:"text-xs text-text-muted",children:l(new Date(t.created_at).getTime()/1e3)})]},t.id))})]}),e.jsxs("section",{children:[e.jsxs("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:[s("admin.sessions")," (",a.length,")"]}),a.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-4 text-center text-text-muted",children:s("admin.noSessions")}):e.jsx("div",{className:"space-y-2",children:a.map(t=>e.jsxs("a",{href:`/code/${t.id}`,className:"flex items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 no-underline transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.title||t.id}),e.jsx("span",{className:"rounded-full bg-surface-2 px-2 py-0.5 text-xs text-text-muted",children:t.source||"unknown"})]}),e.jsx("div",{className:"truncate text-xs text-text-muted",children:t.id})]}),e.jsxs("div",{className:"ml-4 flex items-center gap-3",children:[e.jsx(u,{status:t.status}),e.jsx("span",{className:"text-xs text-text-muted",children:l(t.updated_at||t.created_at)})]})]},t.id))})]})]})})}export{j as AdminPanel};
@@ -0,0 +1 @@
1
+ import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{m as d}from"./main-CEsvX5rj.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function f(){const r=window.location.pathname.split("/"),t=r[r.length-1]||"",[i,s]=a.useState("idle"),[o,c]=a.useState(null),[m,l]=a.useState(null);return a.useEffect(()=>{if(!t||!t.startsWith("clm_")){c("Invalid claim token"),s("error");return}s("claiming"),d(t).then(n=>{l(n.environment_id),s("success")}).catch(n=>{c(n instanceof Error?n.message:"Claim failed"),s("error")})},[t]),i==="claiming"?e.jsx("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:e.jsx("p",{className:"text-sm text-text-muted",children:"Claiming environment..."})}):i==="error"?e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsx("p",{className:"text-sm text-destructive",children:o}),e.jsx("a",{href:"/code",className:"mt-4 inline-block text-accent hover:underline",children:"Back to dashboard"})]}):e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsxs("header",{className:"mb-10",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:"Environment claimed"}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:"You are now the owner of this environment."})]}),e.jsxs("div",{className:"space-y-4",children:[m&&e.jsx("p",{className:"font-mono text-xs text-text-muted",children:m}),e.jsx("a",{href:"/code",className:"inline-block rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent/90 transition-colors",children:"Go to dashboard"})]})]})}export{f as Claim};
@@ -0,0 +1 @@
1
+ import{j as e,e as i}from"./vendor-DE_-CLIE.js";import{G as S,a2 as y,i as N,K as D,a1 as w,Y as n,Q as T,n as E,q as L,r as M,p as B}from"./main-CEsvX5rj.js";import{g as v}from"./workerType-Bd-zteMi.js";import{S as I,D as F,a as O,c as A,d as P,b as $}from"./SessionVisibilityBadge-CN3bz2gb.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function W({teamName:o,className:d}){return o?e.jsx("span",{className:S("inline-flex items-center rounded-full border border-border/60 bg-surface-2 px-2 py-0.5 text-xs text-text-muted",d),children:o}):null}function q({environments:o,onSelectEnvironment:d}){const{activeTeam:u}=y(),m=i.useMemo(()=>u?o.filter(s=>s.team_id===u.id):o.filter(s=>!s.team_id),[o,u]);return!m||m.length===0?e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-8 text-center text-text-muted",children:"No active environments"}):e.jsx("div",{className:"space-y-2",children:m.map(s=>{const p=s.worker_type==="acp",b=v(s.worker_type),c=b.fullLabel,h=b.colorClass;return e.jsxs("button",{type:"button",onClick:()=>d==null?void 0:d(s),disabled:p,className:`flex w-full items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 text-left transition-colors ${p?"cursor-default opacity-80":"hover:border-border-light cursor-pointer"}`,children:[e.jsx("div",{className:"flex items-center gap-3",children:e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-text-primary",children:s.machine_name||s.id}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${h}`,children:c}),e.jsx(W,{teamName:s.team_name??null})]}),e.jsx("div",{className:"text-sm text-text-muted",children:s.directory||""})]})}),e.jsxs("div",{className:"text-right",children:[e.jsx(N,{status:s.status}),e.jsx("div",{className:"mt-1 text-xs text-text-muted",children:s.branch||""})]})]},s.id)})})}function G({sessions:o,environments:d,onSelect:u,onDelete:m}){const{activeTeam:s,myTeams:p}=y(),b=i.useMemo(()=>{const t=new Map;for(const l of p)t.set(l.id,l.name);return t},[p]),c=i.useMemo(()=>s?o.filter(t=>t.owner_type==="team"&&t.owner_id===s.id):o.filter(t=>t.owner_type==="user"||!t.owner_type),[o,s]);if(!c||c.length===0)return e.jsx("div",{className:"rounded-xl border border-border bg-surface-1 p-8 text-center text-text-muted",children:"No sessions"});const h=new Map;for(const t of d??[])t!=null&&t.id&&t.worker_type&&h.set(t.id,t.worker_type);const f=[...c].sort((t,l)=>(l.updated_at||0)-(t.updated_at||0));return e.jsx("div",{className:"space-y-2",children:f.map(t=>e.jsxs("div",{className:"group flex w-full items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 text-left transition-colors hover:border-border-light hover:bg-surface-2",children:[e.jsxs("button",{type:"button",onClick:()=>u(t.id),className:"min-w-0 flex-1 text-left",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:t.title||t.id}),t.visibility&&e.jsx(I,{visibility:t.visibility||"private"}),(()=>{var x;let l=t.source==="acp"?"acp":(x=t.environment)==null?void 0:x.worker_type;!l&&t.environment_id&&(l=h.get(t.environment_id));const a=v(l);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${a.colorClass}`,children:a.fullLabel})})()]}),e.jsxs("div",{className:"flex items-center gap-2 truncate text-xs text-text-muted",children:[e.jsx("span",{className:"truncate font-mono",children:t.id}),t.owner_type==="team"&&t.owner_id&&e.jsxs("span",{className:"inline-flex items-center gap-2 truncate",children:[e.jsx("span",{className:"text-text-muted/40",children:"|"}),e.jsx("span",{className:"truncate",children:b.get(t.owner_id)||t.owner_id})]})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx(N,{status:t.status}),e.jsx("span",{className:"text-xs text-text-muted",children:D(t.created_at||t.updated_at)}),m&&e.jsx("button",{type:"button",onClick:l=>{l.stopPropagation(),m(t.id)},className:"rounded p-1 text-text-muted opacity-0 transition-all hover:text-status-error group-hover:opacity-100",title:"Delete session",children:e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},t.id))})}function H({open:o,environments:d,onClose:u,onCreated:m}){w();const{activeTeam:s}=y(),[p,b]=i.useState(""),[c,h]=i.useState(""),[f,t]=i.useState("same-dir"),[l,a]=i.useState(""),[x,g]=i.useState(!1),_=i.useMemo(()=>s?d.filter(r=>r.team_id===s.id):d.filter(r=>!r.team_id),[d,s]);i.useEffect(()=>{o&&(b(""),h(""),t("same-dir"),a(""))},[o]);const k=async()=>{g(!0),a("");try{const r={};p.trim()&&(r.title=p.trim()),c&&(r.environment_id=c),r.spawn_mode=f;const j=T();j&&(r.team_id=j);const C=await E(r);m(C)}catch(r){a(r instanceof Error?r.message:n("dialog.createFailed"))}finally{g(!1)}};return e.jsx(F,{open:o,onOpenChange:r=>{r||u()},children:e.jsxs(O,{className:"max-w-md rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(A,{children:e.jsx(P,{className:"font-display text-lg font-semibold text-text-primary",children:n("dialog.newSession")})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:n("dialog.titleOptional")}),e.jsx("input",{type:"text",value:p,onChange:r=>b(r.target.value),placeholder:n("dialog.titlePlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:n("dialog.environment")}),e.jsxs("select",{value:c,onChange:r=>h(r.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"",children:n("dialog.none")}),_.map(r=>{const j=v(r.worker_type).shortLabel;return e.jsxs("option",{value:r.id,children:[r.machine_name||r.id," (",r.branch||n("dialog.noBranch"),") · ",j]},r.id)})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:n("dialog.workspaceMode")}),e.jsxs("select",{value:f,onChange:r=>t(r.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"same-dir",children:n("dialog.sameDir")}),e.jsx("option",{value:"worktree",children:n("dialog.worktree")})]})]}),l&&e.jsx("div",{className:"text-sm text-status-error",children:l})]}),e.jsxs($,{children:[e.jsx("button",{onClick:u,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:n("common.cancel")}),e.jsx("button",{onClick:k,disabled:x,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:x?n("common.creating"):n("common.create")})]})]})})}function J({onNavigateSession:o}){w();const[d,u]=i.useState([]),[m,s]=i.useState([]),[p,b]=i.useState(!1),c=i.useCallback(async()=>{try{const[a,x]=await Promise.all([L(),M()]);u(a||[]),s(x||[])}catch(a){console.error("Dashboard render error:",a)}},[]);i.useEffect(()=>{c();const a=setInterval(c,1e4);return()=>clearInterval(a)},[c]);const h=a=>{b(!1),o(a.id)},f=i.useCallback(a=>{},[]),t=i.useCallback(a=>{o(a)},[o]),l=i.useCallback(async a=>{if(window.confirm(n("dashboard.confirmDelete").replace("{id}",a)))try{await B(a),u(x=>x.filter(g=>g.id!==a))}catch(x){alert(x instanceof Error?x.message:n("dashboard.deleteFailed"))}},[]);return e.jsx("div",{className:"px-6 py-12 sm:px-10 sm:py-16",children:e.jsxs("div",{children:[e.jsx("h1",{className:"sr-only",children:n("dashboard.title")}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:n("dashboard.environments")}),e.jsx(q,{environments:m,onSelectEnvironment:f})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-6 flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-medium text-text-primary",children:n("dashboard.sessions")}),e.jsx("button",{onClick:()=>b(!0),className:"rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent/90 transition-colors",children:n("dashboard.newSession")})]}),e.jsx(G,{sessions:d,environments:m,onSelect:t,onDelete:l})]}),e.jsx(H,{open:p,environments:m,onClose:()=>b(!1),onCreated:h})]})})}export{J as Dashboard};
@@ -0,0 +1 @@
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{a0 as v,Y as t}from"./main-CEsvX5rj.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function E({onSuccess:b,onInvalidInvite:l}){const{join:h}=v(),[u,f]=r.useState(""),[d,j]=r.useState(""),[o,w]=r.useState(""),[c,g]=r.useState(""),[m,n]=r.useState(""),[x,p]=r.useState(!1);r.useEffect(()=>{const a=new URLSearchParams(window.location.search).get("invite");a?f(a):l()},[l]);const y=async s=>{if(s.preventDefault(),n(""),o.length<8){n(t("auth.setup.passwordTooShort"));return}if(o!==c){n(t("auth.setup.passwordMismatch"));return}p(!0);try{await h(u,d,o),b()}catch(a){const i=a instanceof Error?a.message:"Join failed";if(i.includes("Invalid invitation")||i.includes("expired")||i.includes("already used")){l();return}n(i)}finally{p(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-text-primary",children:t("auth.join.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.join.welcome")}),e.jsx("p",{className:"mt-1 text-sm text-text-muted",children:t("auth.join.description")})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.username")}),e.jsx("input",{type:"text",value:d,onChange:s=>j(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.password")}),e.jsx("input",{type:"password",value:o,onChange:s=>w(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.confirmPassword")}),e.jsx("input",{type:"password",value:c,onChange:s=>g(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),m&&e.jsx("p",{className:"text-sm text-status-error",children:m}),e.jsx("button",{type:"submit",disabled:x||!u,className:"w-full rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light disabled:cursor-not-allowed disabled:opacity-50",children:x?t("common.loading"):t("auth.join.submit")})]})]})})}export{E as Join};
@@ -0,0 +1 @@
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{a0 as f,Y as t}from"./main-CEsvX5rj.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function N({onSuccess:d,onNavigateRegister:c}){const{login:m,registrationAllowed:x}=f(),[a,p]=r.useState(""),[o,b]=r.useState(""),[l,n]=r.useState(""),[i,u]=r.useState(!1),h=async s=>{s.preventDefault(),n(""),u(!0);try{await m(a,o),d()}catch{n(t("auth.login.failed"))}finally{u(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-text-primary",children:t("auth.login.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.login.description")})]}),e.jsxs("form",{onSubmit:h,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.username")}),e.jsx("input",{type:"text",value:a,onChange:s=>p(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.password")}),e.jsx("input",{type:"password",value:o,onChange:s=>b(s.target.value),required:!0,autoComplete:"current-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),l&&e.jsx("p",{className:"text-sm text-status-error",children:l}),e.jsx("button",{type:"submit",disabled:i,className:"w-full rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light disabled:cursor-not-allowed disabled:opacity-50",children:i?t("common.loading"):t("auth.login.submit")})]}),x&&e.jsx("button",{type:"button",onClick:c,className:"w-full text-center text-sm text-text-muted hover:text-text-primary transition-colors",children:t("auth.login.register")})]})})}export{N as Login};
@@ -0,0 +1 @@
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{a0 as y,Y as t}from"./main-CEsvX5rj.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function S({onSuccess:m,onBack:x}){const{register:p}=y(),[n,b]=r.useState(""),[a,h]=r.useState(""),[l,f]=r.useState(""),[i,o]=r.useState(""),[u,d]=r.useState(!1),g=async s=>{if(s.preventDefault(),o(""),a.length<8){o(t("auth.setup.passwordTooShort"));return}if(a!==l){o(t("auth.setup.passwordMismatch"));return}d(!0);try{await p(n,a),m()}catch(c){o(c instanceof Error?c.message:t("auth.register.failed"))}finally{d(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-text-primary",children:t("auth.register.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.register.description")})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.username")}),e.jsx("input",{type:"text",value:n,onChange:s=>b(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.password")}),e.jsx("input",{type:"password",value:a,onChange:s=>h(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.confirmPassword")}),e.jsx("input",{type:"password",value:l,onChange:s=>f(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),i&&e.jsx("p",{className:"text-sm text-status-error",children:i}),e.jsx("button",{type:"submit",disabled:u,className:"w-full rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light disabled:cursor-not-allowed disabled:opacity-50",children:u?t("common.loading"):t("auth.register.submit")})]}),e.jsx("button",{type:"button",onClick:x,className:"w-full text-center text-sm text-text-muted hover:text-text-primary transition-colors",children:t("auth.register.backToLogin")})]})})}export{S as Register};
@@ -1,4 +1,4 @@
1
- var xe=Object.defineProperty;var pe=(s,t,n)=>t in s?xe(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var T=(s,t,n)=>pe(s,typeof t!="symbol"?t+"":t,n);import{e as p,j as e}from"./vendor-DE_-CLIE.js";import{E as D,s as he,y as fe,I as ye,x as O,t as be,i as ee,H as te,L as se,k as ge,h as je,G as P,B as H,d as we,V as Ne,u as ke,n as ve,w as _e,_ as ne,Q as g,A as Se,J as Ce,W as Me,F as Ee,o as Te,j as re,c as $e,C as Ae,r as Ie,M as Pe,D as De,a as Re}from"./main-J6cPs2y8.js";import{D as ae,a as oe,c as ie,d as le,b as qe,S as Ue,g as Fe}from"./SessionVisibilityBadge-CQN3bJW4.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";/**
1
+ var xe=Object.defineProperty;var pe=(s,t,n)=>t in s?xe(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var T=(s,t,n)=>pe(s,typeof t!="symbol"?t+"":t,n);import{e as p,j as e}from"./vendor-DE_-CLIE.js";import{H as D,t as he,z as fe,M as ye,y as O,u as be,i as ee,K as te,L as se,k as ge,h as je,J as P,G as H,d as we,Z as Ne,v as ke,o as ve,x as _e,a1 as ne,Y as g,A as Se,N as Ce,_ as Me,I as Ee,p as Te,j as re,c as $e,C as Ae,s as Ie,V as Pe,D as De,a as Re}from"./main-CEsvX5rj.js";import{g as qe}from"./workerType-Bd-zteMi.js";import{D as ae,a as oe,c as ie,d as le,b as Ue,S as Fe}from"./SessionVisibilityBadge-CN3bz2gb.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";/**
2
2
  * @license lucide-react v0.555.0 - ISC
3
3
  *
4
4
  * This source code is licensed under the ISC license.
@@ -8,37 +8,37 @@ var xe=Object.defineProperty;var pe=(s,t,n)=>t in s?xe(s,t,{enumerable:!0,config
8
8
  *
9
9
  * This source code is licensed under the ISC license.
10
10
  * See the LICENSE file in the root directory of this source tree.
11
- */const Le=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],Be=D("chevron-right",Le);/**
11
+ */const Le=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ze=D("chevron-right",Le);/**
12
12
  * @license lucide-react v0.555.0 - ISC
13
13
  *
14
14
  * This source code is licensed under the ISC license.
15
15
  * See the LICENSE file in the root directory of this source tree.
16
- */const ze=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],K=D("clock",ze);/**
16
+ */const Be=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Y=D("clock",Be);/**
17
17
  * @license lucide-react v0.555.0 - ISC
18
18
  *
19
19
  * This source code is licensed under the ISC license.
20
20
  * See the LICENSE file in the root directory of this source tree.
21
- */const Qe=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Ve=D("cpu",Qe);/**
21
+ */const Ve=[["path",{d:"M12 20v2",key:"1lh1kg"}],["path",{d:"M12 2v2",key:"tus03m"}],["path",{d:"M17 20v2",key:"1rnc9c"}],["path",{d:"M17 2v2",key:"11trls"}],["path",{d:"M2 12h2",key:"1t8f8n"}],["path",{d:"M2 17h2",key:"7oei6x"}],["path",{d:"M2 7h2",key:"asdhe0"}],["path",{d:"M20 12h2",key:"1q8mjw"}],["path",{d:"M20 17h2",key:"1fpfkl"}],["path",{d:"M20 7h2",key:"1o8tra"}],["path",{d:"M7 20v2",key:"4gnj0m"}],["path",{d:"M7 2v2",key:"1i4yhu"}],["rect",{x:"4",y:"4",width:"16",height:"16",rx:"2",key:"1vbyd7"}],["rect",{x:"8",y:"8",width:"8",height:"8",rx:"1",key:"z9xiuo"}]],Qe=D("cpu",Ve);/**
22
22
  * @license lucide-react v0.555.0 - ISC
23
23
  *
24
24
  * This source code is licensed under the ISC license.
25
25
  * See the LICENSE file in the root directory of this source tree.
26
- */const We=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Je=D("hash",We);/**
26
+ */const We=[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]],Ke=D("hash",We);/**
27
27
  * @license lucide-react v0.555.0 - ISC
28
28
  *
29
29
  * This source code is licensed under the ISC license.
30
30
  * See the LICENSE file in the root directory of this source tree.
31
- */const Ke=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Ye=D("info",Ke);/**
31
+ */const Ye=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Je=D("info",Ye);/**
32
32
  * @license lucide-react v0.555.0 - ISC
33
33
  *
34
34
  * This source code is licensed under the ISC license.
35
35
  * See the LICENSE file in the root directory of this source tree.
36
- */const Ge=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Xe=D("play",Ge);/**
36
+ */const Ge=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],Ze=D("play",Ge);/**
37
37
  * @license lucide-react v0.555.0 - ISC
38
38
  *
39
39
  * This source code is licensed under the ISC license.
40
40
  * See the LICENSE file in the root directory of this source tree.
41
- */const Ze=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],et=D("server-cog",Ze);/**
41
+ */const Xe=[["path",{d:"m10.852 14.772-.383.923",key:"11vil6"}],["path",{d:"M13.148 14.772a3 3 0 1 0-2.296-5.544l-.383-.923",key:"1v3clb"}],["path",{d:"m13.148 9.228.383-.923",key:"t2zzyc"}],["path",{d:"m13.53 15.696-.382-.924a3 3 0 1 1-2.296-5.544",key:"1bxfiv"}],["path",{d:"m14.772 10.852.923-.383",key:"k9m8cz"}],["path",{d:"m14.772 13.148.923.383",key:"1xvhww"}],["path",{d:"M4.5 10H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-.5",key:"tn8das"}],["path",{d:"M4.5 14H4a2 2 0 0 0-2 2v4a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-4a2 2 0 0 0-2-2h-.5",key:"1g2pve"}],["path",{d:"M6 18h.01",key:"uhywen"}],["path",{d:"M6 6h.01",key:"1utrut"}],["path",{d:"m9.228 10.852-.923-.383",key:"1wtb30"}],["path",{d:"m9.228 13.148-.923.383",key:"1a830x"}]],et=D("server-cog",Xe);/**
42
42
  * @license lucide-react v0.555.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
@@ -48,8 +48,8 @@ var xe=Object.defineProperty;var pe=(s,t,n)=>t in s?xe(s,t,{enumerable:!0,config
48
48
  *
49
49
  * This source code is licensed under the ISC license.
50
50
  * See the LICENSE file in the root directory of this source tree.
51
- */const nt=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],rt=D("triangle-alert",nt);function ce(){return{tasks:{}}}const Y=3e4;function Q(s){const t=s.trim();if(!t)return"agent";const n=t.split(/\s+/).slice(0,2).join(" ");return n.length>40?n.slice(0,40)+"…":n}function at(s,t){var x,d,u,l,o,a,h,b,f,y,j,N;const n=t.subtype;if(n!=="task_started"&&n!=="task_progress"&&n!=="task_notification")return s;const r=t.task_id;if(!r)return s;const c=Date.now(),i=s.tasks[r];if(n==="task_started"){if(i)return{tasks:{...s.tasks,[r]:{...i,description:t.description??i.description,name:Q(t.description??i.description),taskType:t.task_type??i.taskType,workflowName:t.workflow_name??i.workflowName,prompt:t.prompt??i.prompt,toolUseId:t.tool_use_id??i.toolUseId,status:"running",startTime:c,evictAfter:void 0}}};const k=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:Q(k),description:k,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:c}}}}if(n==="task_progress"){if(!i){const k=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:Q(k),description:k,toolUseId:t.tool_use_id,status:"running",startTime:c,tokenCount:(x=t.usage)==null?void 0:x.total_tokens,toolUseCount:(d=t.usage)==null?void 0:d.tool_uses,durationMs:(u=t.usage)==null?void 0:u.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[r]:{...i,description:t.description??i.description,tokenCount:((l=t.usage)==null?void 0:l.total_tokens)??i.tokenCount,toolUseCount:((o=t.usage)==null?void 0:o.tool_uses)??i.toolUseCount,durationMs:((a=t.usage)==null?void 0:a.duration_ms)??i.durationMs,lastToolName:t.last_tool_name??i.lastToolName,summary:t.summary??i.summary}}}}return i?{tasks:{...s.tasks,[r]:{...i,status:t.status??"completed",endTime:c,finalSummary:t.summary??i.finalSummary,outputFile:t.output_file??i.outputFile,tokenCount:((y=t.usage)==null?void 0:y.total_tokens)??i.tokenCount,toolUseCount:((j=t.usage)==null?void 0:j.tool_uses)??i.toolUseCount,durationMs:((N=t.usage)==null?void 0:N.duration_ms)??i.durationMs,evictAfter:c+Y}}}:{tasks:{...s.tasks,[r]:{taskId:r,name:Q(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:c,endTime:c,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(h=t.usage)==null?void 0:h.total_tokens,toolUseCount:(b=t.usage)==null?void 0:b.tool_uses,durationMs:(f=t.usage)==null?void 0:f.duration_ms,evictAfter:c+Y}}}}function ot(s,t=Date.now()){return Object.values(s.tasks).filter(n=>n.evictAfter===void 0||n.evictAfter>t).sort((n,r)=>n.startTime-r.startTime)}class it{constructor(){T(this,"listeners",new Set);T(this,"eventSource",null);T(this,"_lastSeqNum",0)}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}connect(t){this.disconnect();const n=`/web/sessions/${t}/events`,r=new EventSource(n,{withCredentials:!0});this.eventSource=r,r.addEventListener("message",c=>{try{const i=JSON.parse(c.data);if(i.seqNum!==void 0&&i.seqNum<=this._lastSeqNum)return;i.seqNum!==void 0&&(this._lastSeqNum=i.seqNum);for(const x of this.listeners)x(i)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const J=new it;function G(s){if(typeof s.content=="string")return s.content;if(s.message&&typeof s.message=="object"){const t=s.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(n=>n.type==="text"&&typeof n.text=="string").map(n=>n.text).join("")}return""}function X(s,t){for(let n=s.length-1;n>=0;n--){const r=s[n];if(r&&r.type==="tool_call"&&r.toolCall.id===t)return n}return-1}class lt{constructor(t,n,r){T(this,"sessionId");T(this,"setEntries");T(this,"unsub",null);T(this,"onStatusChange");T(this,"onError");T(this,"onPermissionRequest");T(this,"onModelsStateChange");T(this,"onSubagentUpdate");T(this,"subagentState",ce());this.sessionId=t,this.setEntries=n,this.onStatusChange=r==null?void 0:r.onStatusChange,this.onError=r==null?void 0:r.onError,this.onPermissionRequest=r==null?void 0:r.onPermissionRequest,this.onModelsStateChange=r==null?void 0:r.onModelsStateChange,this.onSubagentUpdate=r==null?void 0:r.onSubagentUpdate}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var x;const{events:t}=await he(this.sessionId);if(!t||t.length===0)return;const n=[];let r=null;const c=()=>{r&&(n.push(r),r=null)};for(const d of t){const u=d.payload||{};if(d.type==="user"){if(d.direction==="inbound")continue;c();const l=G(u);l&&n.push({type:"user_message",id:d.id||`hist-user-${n.length}`,content:l})}else if(d.type==="assistant"){c();const l=G(u),o=[],a=u.message;if(a&&typeof a=="object"&&Array.isArray(a.content))for(const h of a.content)h.type==="tool_use"&&o.push({type:"tool_call",toolCall:{id:h.id||`hist-tool-${n.length}`,title:h.name||"tool",status:"complete",rawInput:h.input||{}}});if(l||o.length>0){r={type:"assistant_message",id:d.id||`hist-asst-${n.length}`,chunks:l?[{type:"message",text:l}]:[]},n.push(r);for(const h of o)n.push(h);r=null}}else if(d.type==="tool_use"){const l=u,o={type:"tool_call",toolCall:{id:l.tool_call_id||`hist-tool-${n.length}`,title:l.tool_name||"tool",status:"complete",rawInput:l.tool_input||{}}};n.push(o)}else if(d.type==="tool_result"){const l=u,o=X(n,l.tool_call_id||"");if(o>=0){const a=n[o];n[o]={type:"tool_call",toolCall:{...a.toolCall,rawOutput:{output:l.content||l.output||""}}}}}}c(),this.setEntries(n);let i=null;for(const d of t){if(d.type!=="models_state")continue;const u=d.payload||{},l=u.raw,o=l&&typeof l=="object"?l.models_state:u.models_state;o&&Array.isArray(o.availableModels)&&typeof o.currentModelId=="string"&&(i=o)}i&&((x=this.onModelsStateChange)==null||x.call(this,i))}connectSSE(){J.connect(this.sessionId),this.unsub=J.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),J.disconnect()}handleEvent(t){var i,x,d,u,l;const n=t.type,r=t.payload||{},c=JSON.stringify(t);if(!/Remote Control connecting/i.test(c))switch(n){case"assistant":{const o=typeof r.content=="string"?r.content:"";this.setEntries(h=>{const b=h[h.length-1];if((b==null?void 0:b.type)==="assistant_message"){const f=b.chunks[b.chunks.length-1];return(f==null?void 0:f.type)==="message"?[...h.slice(0,-1),{...b,chunks:[...b.chunks.slice(0,-1),{type:"message",text:f.text+o}]}]:[...h.slice(0,-1),{...b,chunks:[...b.chunks,{type:"message",text:o}]}]}if(o&&o.trim()){const f={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:o}]};return[...h,f]}return h});const a=r.message;if(a&&typeof a=="object"&&Array.isArray(a.content)){const h=a.content.filter(b=>b.type==="tool_use");for(const b of h){const y={id:b.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`,title:b.name||"tool",status:"running",rawInput:b.input||{}};this.setEntries(j=>[...j,{type:"tool_call",toolCall:y}])}}break}case"tool_use":{const o=r,h={id:o.tool_call_id||`call-${Date.now()}`,title:o.tool_name||"tool",status:"running",rawInput:o.tool_input||{}};this.setEntries(b=>[...b,{type:"tool_call",toolCall:h}]);break}case"tool_result":{const o=r,a=o.tool_call_id||"";this.setEntries(h=>{const b=X(h,a);if(b<0)return h;const f=h[b];return h.map((y,j)=>j===b?{type:"tool_call",toolCall:{...f.toolCall,status:"complete",rawOutput:{output:o.content||o.output||""}}}:y)});break}case"control_request":case"permission_request":{const o=r.request;if(o&&o.subtype==="can_use_tool"){const a=r.request_id||"",h=o.tool_name||"unknown",b=o.input||o.tool_input||{},f=o.description||"";this.setEntries(y=>{const j=[...y].reverse().findIndex(N=>N.type==="tool_call");if(j>=0){const N=y.length-1-j,k=y[N];if(k.toolCall.status==="running")return y.map((M,E)=>E===N?{type:"tool_call",toolCall:{...k.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:a,options:[]}}}:M)}return y}),(i=this.onPermissionRequest)==null||i.call(this,{requestId:a,toolName:h,toolInput:b,description:f})}break}case"session_status":{typeof r.status=="string"&&((x=this.onStatusChange)==null||x.call(this,r.status));break}case"error":{const o=String(r.message||r.content||"Unknown error");(d=this.onError)==null||d.call(this,o);break}case"models_state":{const o=r.raw,a=typeof o=="object"&&o!==null?o.models_state:r.models_state;a&&Array.isArray(a.availableModels)&&typeof a.currentModelId=="string"&&((u=this.onModelsStateChange)==null||u.call(this,a));break}case"system":{const o=r.raw,a=o&&typeof o=="object"?o:r,h=typeof a.subtype=="string"?a.subtype:void 0;if(h==="task_started"||h==="task_progress"||h==="task_notification"){const b={subtype:h,task_id:typeof a.task_id=="string"?a.task_id:void 0,tool_use_id:typeof a.tool_use_id=="string"?a.tool_use_id:void 0,description:typeof a.description=="string"?a.description:void 0,task_type:typeof a.task_type=="string"?a.task_type:void 0,workflow_name:typeof a.workflow_name=="string"?a.workflow_name:void 0,prompt:typeof a.prompt=="string"?a.prompt:void 0,usage:a.usage&&typeof a.usage=="object"?a.usage:void 0,last_tool_name:typeof a.last_tool_name=="string"?a.last_tool_name:void 0,summary:typeof a.summary=="string"?a.summary:void 0,status:a.status==="completed"||a.status==="failed"||a.status==="stopped"?a.status:void 0,output_file:typeof a.output_file=="string"?a.output_file:void 0};this.subagentState=at(this.subagentState,b),(l=this.onSubagentUpdate)==null||l.call(this,this.subagentState)}break}}}async sendMessage(t,n,r){const c=n&&n.length>0,i=r&&r.length>0;if(!t.trim()&&!c&&!i)return;const x={type:"user_message",id:`user-${Date.now()}`,content:t,images:c?n:void 0,attachments:i?r:void 0};this.setEntries(l=>[...l,x]);const d=[];if(t&&d.push({type:"text",text:t}),c)for(const l of n)d.push({type:"image",source:{type:"base64",media_type:l.mimeType,data:l.data}});if(i){for(const l of r)if(l.kind==="text"||l.kind==="table"){const o=`📎 ${l.name}${l.size!=null?` (${ct(l.size)})`:""}`,a=l.textContent||"(空文件)";d.push({type:"text",text:`${o}
51
+ */const nt=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],rt=D("triangle-alert",nt);function ce(){return{tasks:{}}}const J=3e4;function V(s){const t=s.trim();if(!t)return"agent";const n=t.split(/\s+/).slice(0,2).join(" ");return n.length>40?n.slice(0,40)+"…":n}function at(s,t){var x,d,u,l,o,a,h,b,f,y,j,N;const n=t.subtype;if(n!=="task_started"&&n!=="task_progress"&&n!=="task_notification")return s;const r=t.task_id;if(!r)return s;const c=Date.now(),i=s.tasks[r];if(n==="task_started"){if(i)return{tasks:{...s.tasks,[r]:{...i,description:t.description??i.description,name:V(t.description??i.description),taskType:t.task_type??i.taskType,workflowName:t.workflow_name??i.workflowName,prompt:t.prompt??i.prompt,toolUseId:t.tool_use_id??i.toolUseId,status:"running",startTime:c,evictAfter:void 0}}};const k=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:V(k),description:k,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:c}}}}if(n==="task_progress"){if(!i){const k=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:V(k),description:k,toolUseId:t.tool_use_id,status:"running",startTime:c,tokenCount:(x=t.usage)==null?void 0:x.total_tokens,toolUseCount:(d=t.usage)==null?void 0:d.tool_uses,durationMs:(u=t.usage)==null?void 0:u.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[r]:{...i,description:t.description??i.description,tokenCount:((l=t.usage)==null?void 0:l.total_tokens)??i.tokenCount,toolUseCount:((o=t.usage)==null?void 0:o.tool_uses)??i.toolUseCount,durationMs:((a=t.usage)==null?void 0:a.duration_ms)??i.durationMs,lastToolName:t.last_tool_name??i.lastToolName,summary:t.summary??i.summary}}}}return i?{tasks:{...s.tasks,[r]:{...i,status:t.status??"completed",endTime:c,finalSummary:t.summary??i.finalSummary,outputFile:t.output_file??i.outputFile,tokenCount:((y=t.usage)==null?void 0:y.total_tokens)??i.tokenCount,toolUseCount:((j=t.usage)==null?void 0:j.tool_uses)??i.toolUseCount,durationMs:((N=t.usage)==null?void 0:N.duration_ms)??i.durationMs,evictAfter:c+J}}}:{tasks:{...s.tasks,[r]:{taskId:r,name:V(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:c,endTime:c,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(h=t.usage)==null?void 0:h.total_tokens,toolUseCount:(b=t.usage)==null?void 0:b.tool_uses,durationMs:(f=t.usage)==null?void 0:f.duration_ms,evictAfter:c+J}}}}function ot(s,t=Date.now()){return Object.values(s.tasks).filter(n=>n.evictAfter===void 0||n.evictAfter>t).sort((n,r)=>n.startTime-r.startTime)}class it{constructor(){T(this,"listeners",new Set);T(this,"eventSource",null);T(this,"_lastSeqNum",0)}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}connect(t){this.disconnect();const n=`/web/sessions/${t}/events`,r=new EventSource(n,{withCredentials:!0});this.eventSource=r,r.addEventListener("message",c=>{try{const i=JSON.parse(c.data);if(i.seqNum!==void 0&&i.seqNum<=this._lastSeqNum)return;i.seqNum!==void 0&&(this._lastSeqNum=i.seqNum);for(const x of this.listeners)x(i)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const K=new it;function G(s){if(typeof s.content=="string")return s.content;if(s.message&&typeof s.message=="object"){const t=s.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(n=>n.type==="text"&&typeof n.text=="string").map(n=>n.text).join("")}return""}function Z(s,t){for(let n=s.length-1;n>=0;n--){const r=s[n];if(r&&r.type==="tool_call"&&r.toolCall.id===t)return n}return-1}class lt{constructor(t,n,r){T(this,"sessionId");T(this,"setEntries");T(this,"unsub",null);T(this,"onStatusChange");T(this,"onError");T(this,"onPermissionRequest");T(this,"onModelsStateChange");T(this,"onSubagentUpdate");T(this,"subagentState",ce());this.sessionId=t,this.setEntries=n,this.onStatusChange=r==null?void 0:r.onStatusChange,this.onError=r==null?void 0:r.onError,this.onPermissionRequest=r==null?void 0:r.onPermissionRequest,this.onModelsStateChange=r==null?void 0:r.onModelsStateChange,this.onSubagentUpdate=r==null?void 0:r.onSubagentUpdate}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var x;const{events:t}=await he(this.sessionId);if(!t||t.length===0)return;const n=[];let r=null;const c=()=>{r&&(n.push(r),r=null)};for(const d of t){const u=d.payload||{};if(d.type==="user"){if(d.direction==="inbound")continue;c();const l=G(u);l&&n.push({type:"user_message",id:d.id||`hist-user-${n.length}`,content:l})}else if(d.type==="assistant"){c();const l=G(u),o=[],a=u.message;if(a&&typeof a=="object"&&Array.isArray(a.content))for(const h of a.content)h.type==="tool_use"&&o.push({type:"tool_call",toolCall:{id:h.id||`hist-tool-${n.length}`,title:h.name||"tool",status:"complete",rawInput:h.input||{}}});if(l||o.length>0){r={type:"assistant_message",id:d.id||`hist-asst-${n.length}`,chunks:l?[{type:"message",text:l}]:[]},n.push(r);for(const h of o)n.push(h);r=null}}else if(d.type==="tool_use"){const l=u,o={type:"tool_call",toolCall:{id:l.tool_call_id||`hist-tool-${n.length}`,title:l.tool_name||"tool",status:"complete",rawInput:l.tool_input||{}}};n.push(o)}else if(d.type==="tool_result"){const l=u,o=Z(n,l.tool_call_id||"");if(o>=0){const a=n[o];n[o]={type:"tool_call",toolCall:{...a.toolCall,rawOutput:{output:l.content||l.output||""}}}}}}c(),this.setEntries(n);let i=null;for(const d of t){if(d.type!=="models_state")continue;const u=d.payload||{},l=u.raw,o=l&&typeof l=="object"?l.models_state:u.models_state;o&&Array.isArray(o.availableModels)&&typeof o.currentModelId=="string"&&(i=o)}i&&((x=this.onModelsStateChange)==null||x.call(this,i))}connectSSE(){K.connect(this.sessionId),this.unsub=K.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),K.disconnect()}handleEvent(t){var i,x,d,u,l;const n=t.type,r=t.payload||{},c=JSON.stringify(t);if(!/Remote Control connecting/i.test(c))switch(n){case"assistant":{const o=typeof r.content=="string"?r.content:"";this.setEntries(h=>{const b=h[h.length-1];if((b==null?void 0:b.type)==="assistant_message"){const f=b.chunks[b.chunks.length-1];return(f==null?void 0:f.type)==="message"?[...h.slice(0,-1),{...b,chunks:[...b.chunks.slice(0,-1),{type:"message",text:f.text+o}]}]:[...h.slice(0,-1),{...b,chunks:[...b.chunks,{type:"message",text:o}]}]}if(o&&o.trim()){const f={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:o}]};return[...h,f]}return h});const a=r.message;if(a&&typeof a=="object"&&Array.isArray(a.content)){const h=a.content.filter(b=>b.type==="tool_use");for(const b of h){const y={id:b.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`,title:b.name||"tool",status:"running",rawInput:b.input||{}};this.setEntries(j=>[...j,{type:"tool_call",toolCall:y}])}}break}case"tool_use":{const o=r,h={id:o.tool_call_id||`call-${Date.now()}`,title:o.tool_name||"tool",status:"running",rawInput:o.tool_input||{}};this.setEntries(b=>[...b,{type:"tool_call",toolCall:h}]);break}case"tool_result":{const o=r,a=o.tool_call_id||"";this.setEntries(h=>{const b=Z(h,a);if(b<0)return h;const f=h[b];return h.map((y,j)=>j===b?{type:"tool_call",toolCall:{...f.toolCall,status:"complete",rawOutput:{output:o.content||o.output||""}}}:y)});break}case"control_request":case"permission_request":{const o=r.request;if(o&&o.subtype==="can_use_tool"){const a=r.request_id||"",h=o.tool_name||"unknown",b=o.input||o.tool_input||{},f=o.description||"";this.setEntries(y=>{const j=[...y].reverse().findIndex(N=>N.type==="tool_call");if(j>=0){const N=y.length-1-j,k=y[N];if(k.toolCall.status==="running")return y.map((M,E)=>E===N?{type:"tool_call",toolCall:{...k.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:a,options:[]}}}:M)}return y}),(i=this.onPermissionRequest)==null||i.call(this,{requestId:a,toolName:h,toolInput:b,description:f})}break}case"session_status":{typeof r.status=="string"&&((x=this.onStatusChange)==null||x.call(this,r.status));break}case"error":{const o=String(r.message||r.content||"Unknown error");(d=this.onError)==null||d.call(this,o);break}case"models_state":{const o=r.raw,a=typeof o=="object"&&o!==null?o.models_state:r.models_state;a&&Array.isArray(a.availableModels)&&typeof a.currentModelId=="string"&&((u=this.onModelsStateChange)==null||u.call(this,a));break}case"system":{const o=r.raw,a=o&&typeof o=="object"?o:r,h=typeof a.subtype=="string"?a.subtype:void 0;if(h==="task_started"||h==="task_progress"||h==="task_notification"){const b={subtype:h,task_id:typeof a.task_id=="string"?a.task_id:void 0,tool_use_id:typeof a.tool_use_id=="string"?a.tool_use_id:void 0,description:typeof a.description=="string"?a.description:void 0,task_type:typeof a.task_type=="string"?a.task_type:void 0,workflow_name:typeof a.workflow_name=="string"?a.workflow_name:void 0,prompt:typeof a.prompt=="string"?a.prompt:void 0,usage:a.usage&&typeof a.usage=="object"?a.usage:void 0,last_tool_name:typeof a.last_tool_name=="string"?a.last_tool_name:void 0,summary:typeof a.summary=="string"?a.summary:void 0,status:a.status==="completed"||a.status==="failed"||a.status==="stopped"?a.status:void 0,output_file:typeof a.output_file=="string"?a.output_file:void 0};this.subagentState=at(this.subagentState,b),(l=this.onSubagentUpdate)==null||l.call(this,this.subagentState)}break}}}async sendMessage(t,n,r){const c=n&&n.length>0,i=r&&r.length>0;if(!t.trim()&&!c&&!i)return;const x={type:"user_message",id:`user-${Date.now()}`,content:t,images:c?n:void 0,attachments:i?r:void 0};this.setEntries(l=>[...l,x]);const d=[];if(t&&d.push({type:"text",text:t}),c)for(const l of n)d.push({type:"image",source:{type:"base64",media_type:l.mimeType,data:l.data}});if(i){for(const l of r)if(l.kind==="text"||l.kind==="table"){const o=`📎 ${l.name}${l.size!=null?` (${ct(l.size)})`:""}`,a=l.textContent||"(空文件)";d.push({type:"text",text:`${o}
52
52
  \`\`\`
53
53
  ${a}
54
54
  \`\`\``})}else if(l.kind==="directory"){const o=`📁 目录: ${l.name}${l.files!=null?` (${l.files.length} 个文件)`:""}`,a=l.textContent||"(空目录)";d.push({type:"text",text:`${o}
55
- ${a}`})}}const u=d.length===1&&d[0].type==="text"?d[0].text||t:d.length>0?d:t;await fe(this.sessionId,{type:"user",uuid:ye(),content:t,message:{content:u}})}async respondPermission(t,n,r){await O(this.sessionId,{type:"permission_response",approved:n,request_id:t,...r}),this.setEntries(c=>c.map(i=>{var x;return i.type!=="tool_call"||((x=i.toolCall.permissionRequest)==null?void 0:x.requestId)!==t?i:{type:"tool_call",toolCall:{...i.toolCall,status:n?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(n=>n.type!=="tool_call"||n.toolCall.status!=="running"&&n.toolCall.status!=="waiting_for_confirmation"?n:{type:"tool_call",toolCall:{...n.toolCall,status:"canceled",permissionRequest:void 0}})),await be(this.sessionId)}}function ct(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function dt(s){if(!s)return"never";const t=Math.max(0,Date.now()-s);return t<5e3?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function ut(s){return s?Date.now()-s<6e4:!1}function mt({onClose:s,session:t,liveStatus:n,pendingPermissions:r,onInterrupt:c,onDelete:i}){const[x,d]=p.useState(!1),u=async()=>{await navigator.clipboard.writeText(t.id),d(!0),setTimeout(()=>d(!1),1500)},l=r.length,o=t.worker,a=t.work_item,h=t.environment;return e.jsx(ae,{open:!0,onOpenChange:b=>{b||s()},children:e.jsxs(oe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(ie,{children:e.jsx(le,{className:"font-display font-semibold text-text-primary",children:"Session Ops"})}),e.jsxs("div",{className:"mt-3 space-y-5 text-sm",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(He,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{status:n||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:o&&(ut(o.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[o&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(K,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:dt(o.last_heartbeat_at)})]}),h&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Ve,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:h.machine_name||h.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(K,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:te(t.created_at)})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(se,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),l>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[l," permission request",l>1?"s":""," awaiting your approval"]}):e.jsx("p",{className:"text-xs text-text-muted",children:"No pending actions"})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(et,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:c,className:"flex-1 rounded-md border border-border px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-2 transition-colors",children:"Interrupt"}),e.jsxs("button",{onClick:i,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors",children:[e.jsx(ge,{className:"mr-1 inline h-3 w-3"}),"Delete"]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Je,{className:"h-3.5 w-3.5"}),"Session Info"]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("dt",{children:"Session ID"}),e.jsxs("dd",{className:"flex items-center gap-1 min-w-0",children:[e.jsx("code",{className:"break-all font-mono text-text-secondary text-right",children:t.id}),e.jsx("button",{onClick:u,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:x?"✓":"⧉"})]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Spawn mode"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:a.spawn_mode??"default"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Work state"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:a.state})]})]}),t.source&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Source"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:t.source})]}),h&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:h.worker_type})]})]})]})]})]})})}const Z="rcs:subagent-panel:collapsed";function xt(s){if(s<1e3)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m${r}s`:`${n}m`;const c=Math.floor(n/60),i=n%60;return i?`${c}h${i}m`:`${c}h`}function pt(s){return s===void 0||s<=0?"":s<1e3?`${s}`:s<1e6?`${(s/1e3).toFixed(s<1e4?1:0)}k`:`${(s/1e6).toFixed(1)}M`}function ht({status:s}){return s==="running"?e.jsx(se,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(Xe,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(je,{className:"h-3 w-3 text-status-error"}):null}function ft({task:s}){const t=s.status==="running",n=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,r=pt(s.tokenCount),c=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",i=s.summary||s.description||"(no description)";return e.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:e.jsx(ht,{status:s.status})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:s.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:xt(n)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:i}),(r||c||s.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-text-muted",children:[r&&e.jsxs("span",{children:["↕ ",r," tok"]}),c&&e.jsxs("span",{children:["· ",c]}),s.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",s.lastToolName]})]}),!t&&s.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:s.finalSummary})]})]})}function yt({state:s}){const[t,n]=p.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Z)==="1"}catch{return!1}}),r=()=>{n(u=>{const l=!u;try{window.localStorage.setItem(Z,l?"1":"0")}catch{}return l})},[,c]=p.useState(0);p.useEffect(()=>{const u=Object.values(s.tasks).some(a=>a.status==="running"),l=Object.values(s.tasks).some(a=>a.status!=="running"&&a.evictAfter!==void 0);if(!u&&!l)return;const o=setInterval(()=>{c(a=>a+1)},1e3);return()=>clearInterval(o)},[s]);const i=ot(s);if(i.length===0)return null;const x=i.filter(u=>u.status==="running").length,d=x>0?`${x} running`:`${i.length} recent`;return e.jsx("section",{"aria-label":"Subagents",className:"border-t border-border bg-surface-1 px-4 py-2",children:e.jsxs("div",{className:"mx-auto max-w-3xl space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:r,"aria-expanded":!t,"aria-controls":"subagent-list",className:"flex w-full items-center justify-between text-[10px] font-medium uppercase tracking-wide text-text-muted hover:text-text-secondary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(Be,{className:`h-3 w-3 transition-transform ${t?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:d})]}),!t&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:i.map(u=>e.jsx(ft,{task:u},u.taskId))})]})})}function bt({requestId:s,toolName:t,toolInput:n,description:r,onApprove:c,onReject:i}){const x=typeof n=="string"?n:JSON.stringify(n,null,2);return e.jsxs("div",{className:"rounded-xl border border-warning-border/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-warning-border/15 text-warning-text",children:e.jsx(rt,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold text-warning-text",children:"Permission Request"})]}),r&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:P(r)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:P(t)}),t!=="AskUserQuestion"&&e.jsx("pre",{className:"mb-3 max-h-40 overflow-auto rounded-lg bg-surface-1 p-2 text-xs text-text-secondary font-mono",children:Ne(x,500)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:c,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Approve"}),e.jsx("button",{onClick:i,className:"rounded-lg bg-status-error/20 px-4 py-2 text-sm font-medium text-status-error hover:bg-status-error/30 transition-colors",children:"Reject"})]})]})}function gt({questions:s,description:t,onSubmit:n,onSkip:r}){const[c,i]=p.useState({}),[x,d]=p.useState({}),[u,l]=p.useState(0),o=(f,y,j)=>{if(j){const N=c[f]||[],k=N.includes(y)?N.filter(M=>M!==y):[...N,y];i({...c,[f]:k})}else i({...c,[f]:y})},a=f=>{var j;const y=(j=x[f])==null?void 0:j.trim();y&&(i({...c,[f]:y}),d({...x,[f]:""}))},h=()=>{var y,j;const f={};for(const[N,k]of Object.entries(c)){const M=s[parseInt(N,10)];M&&(typeof k=="number"?f[N]=((j=(y=M.options)==null?void 0:y[k])==null?void 0:j.label)||String(k):Array.isArray(k)?f[N]=k.map(E=>{var $,R;return((R=($=M.options)==null?void 0:$[E])==null?void 0:R.label)||String(E)}):f[N]=k)}n(f)};if(s.length<=1){const f=s[0]||{question:t,options:[],multiSelect:!1},y=f.multiSelect||!1;return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:P(t||f.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(f.options||[]).map((j,N)=>{const k=y?(c[0]||[]).includes(N):c[0]===N;return e.jsxs("button",{onClick:()=>o(0,N,y),className:H("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",k?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:P(j.label)}),j.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:P(j.description)})]},N)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:x[0]||"",onChange:j=>d({...x,0:j.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:j=>j.key==="Enter"&&a(0)}),e.jsx("button",{onClick:()=>a(0),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:h,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const b=s[u];return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:P(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((f,y)=>e.jsx("button",{onClick:()=>l(y),className:H("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",u===y?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:f.header||`Q${y+1}`},y))}),b&&e.jsx(jt,{question:b,qIdx:u,answers:c,otherTexts:x,onSelect:o,onOtherTextChange:(f,y)=>d({...x,[f]:y}),onOtherSubmit:a}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[u+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:h,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function jt({question:s,qIdx:t,answers:n,otherTexts:r,onSelect:c,onOtherTextChange:i,onOtherSubmit:x}){const d=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:P(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((u,l)=>{const o=d?(n[t]||[]).includes(l):n[t]===l;return e.jsxs("button",{onClick:()=>c(t,l,d),className:H("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",o?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:P(u.label)}),u.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:P(u.description)})]},l)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r[t]||"",onChange:u=>i(t,u.target.value),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:u=>u.key==="Enter"&&x(t)}),e.jsx("button",{onClick:()=>x(t),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]})]})}function wt({planContent:s,description:t,onSubmit:n}){const[r,c]=p.useState(null),[i,x]=p.useState(""),d=!s||!s.trim(),u=()=>{r&&n(r,r==="no"?i:void 0)};return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand",children:e.jsx(we,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:d?"Exit plan mode?":"Ready to code?"})]}),!d&&e.jsx("div",{className:"mb-4 max-h-64 overflow-auto rounded-lg bg-tool-card p-4 text-sm text-text-secondary",dangerouslySetInnerHTML:{__html:Nt(s)}}),e.jsx("div",{className:"space-y-2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(F,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes"}),e.jsx(F,{selected:r==="no",onClick:()=>c("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{selected:r==="yes-accept-edits",onClick:()=>c("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(F,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(F,{selected:r==="no",onClick:()=>c("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:i,onChange:l=>x(l.target.value),placeholder:"Tell Saluzi what to change...",className:"mt-3 w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",rows:3}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:u,disabled:!r,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})})]})}function F({selected:s,onClick:t,label:n,desc:r}){return e.jsxs("button",{onClick:t,className:H("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",s?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:H("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",s?"border-brand bg-brand text-white":"border-border"),children:s&&"✓"}),e.jsx("span",{className:"font-medium",children:n})]}),r&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:r})]})}function Nt(s){let t=P(s);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(n,r,c)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${c.trim()}</pre>`),t=t.replace(/`([^`]+)`/g,'<code class="rounded bg-tool-card px-1.5 py-0.5 font-mono text-xs">$1</code>'),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t}function kt(s){const[t,n]=p.useState([]),[r,c]=p.useState(!0),[i,x]=p.useState(null),d=p.useCallback(async()=>{c(!0),x(null);try{const o=await ke(s);n(o)}catch(o){x(o instanceof Error?o.message:"Failed to load shares")}finally{c(!1)}},[s]);p.useEffect(()=>{d()},[d]);const u=p.useCallback(async o=>{x(null);try{const a=await ve(s,o);return await d(),a}catch(a){throw x(a instanceof Error?a.message:"Failed to create share"),a}},[s,d]),l=p.useCallback(async o=>{x(null);try{await _e(s,o),await d()}catch(a){throw x(a instanceof Error?a.message:"Failed to revoke share"),a}},[s,d]);return{shares:t,isLoading:r,error:i,createShare:u,revokeShare:l,refresh:d}}function vt({open:s,onClose:t,sessionId:n,sessionTitle:r}){ne();const{shares:c,isLoading:i,error:x,createShare:d,revokeShare:u}=kt(n),[l,o]=p.useState("user"),[a,h]=p.useState(""),[b,f]=p.useState(""),[y,j]=p.useState("read"),[N,k]=p.useState(""),[M,E]=p.useState(!1),[$,R]=p.useState(null),[L,U]=p.useState(""),[B,S]=p.useState(!1);p.useEffect(()=>{s&&(o("user"),h(""),f(""),j("read"),k(""),E(!1),R(null),U(""),S(!1))},[s]);const q=async()=>{E(!0),U(""),R(null);try{const w={grantedTo:l==="user"?{userId:a.trim()}:{teamId:b.trim()},permission:y};N.trim()&&(w.expiresAt=N.trim());const A=await d(w);R(A.shareToken)}catch(w){U(w instanceof Error?w.message:"Failed to create share")}finally{E(!1)}},V=async w=>{try{await u(w)}catch{}},z=async()=>{if(!$)return;const w=`${window.location.origin}/code/s/${$}`;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(w),S(!0),setTimeout(()=>S(!1),2e3);return}}catch{}const A=document.createElement("textarea");A.value=w,A.style.position="fixed",A.style.opacity="0",document.body.appendChild(A),A.select();try{document.execCommand("copy"),S(!0),setTimeout(()=>S(!1),2e3)}catch{}document.body.removeChild(A)};return e.jsx(ae,{open:s,onOpenChange:w=>{w||t()},children:e.jsxs(oe,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(ie,{children:e.jsxs(le,{className:"font-display text-lg font-semibold text-text-primary",children:[g("share.title"),r?`: ${r}`:""]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:g("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>o("user"),className:`rounded-md px-3 py-1 text-sm transition-colors ${l==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:g("share.user")}),e.jsx("button",{onClick:()=>o("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${l==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:g("share.team")})]}),l==="user"?e.jsx("input",{type:"text",value:a,onChange:w=>h(w.target.value),placeholder:g("share.userIdPlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"}):e.jsx("input",{type:"text",value:b,onChange:w=>f(w.target.value),placeholder:g("share.teamIdPlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:g("share.permission")}),e.jsxs("select",{value:y,onChange:w=>j(w.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"read",children:g("share.permissionRead")}),e.jsx("option",{value:"write",children:g("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:g("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:N,onChange:w=>k(w.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none"})]}),(L||x)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:L||x}),$&&e.jsxs("div",{className:"rounded-md bg-surface-2 px-3 py-2",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-1",children:g("share.linkCreated")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"flex-1 truncate text-xs text-text-primary",children:["/code/s/",$]}),e.jsx("button",{onClick:z,className:"rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:B?g("share.copied"):g("share.copy")})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:g("share.existingShares")}),i?e.jsx("p",{className:"text-sm text-text-muted",children:g("share.loading")}):c.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:g("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:c.map(w=>e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-surface-2 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm text-text-primary",children:w.granted_to_user||w.granted_to_team||"Unknown"}),e.jsxs("p",{className:"text-xs text-text-muted",children:[w.permission==="write"?g("share.permissionWrite"):g("share.permissionRead"),w.expires_at?` · expires ${w.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>V(w.id),className:"ml-2 shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:g("share.revoke")})]},w.id))})]})]}),e.jsxs(qe,{children:[e.jsx("button",{onClick:t,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:g("common.close")}),e.jsx("button",{onClick:q,disabled:M,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:M?g("common.creating"):g("share.createShare")})]})]})})}function _t(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function St(s){const t=_t(s),n=Ce(),r=n?{proxyUrl:t,token:n}:{proxyUrl:t};return new Se(r)}function Dt({sessionId:s,onSessionLoaded:t}){ne();const[n,r]=p.useState(null),[c,i]=p.useState(null),[x,d]=p.useState(""),[u,l]=p.useState(!1),[o,a]=p.useState(!1),[h,b]=p.useState(!1),[f,y]=p.useState([]),[j,N]=p.useState(!1),[k,M]=p.useState([]),[E,$]=p.useState(null),[R,L]=p.useState(()=>ce()),U=p.useRef(null),B=p.useRef(f);B.current=f;const S=p.useMemo(()=>new lt(s,y,{onStatusChange:m=>{i(m)},onError:m=>{console.error("[RCSChatAdapter] error:",m)},onPermissionRequest:m=>{M(v=>v.some(_=>_.requestId===m.requestId)?v:[...v,m])},onModelsStateChange:m=>{$(m)},onSubagentUpdate:m=>{L(m)}}),[s]);p.useEffect(()=>(U.current=S,()=>{S.disconnect()}),[S]),p.useEffect(()=>{let m=!1;async function v(){d("");try{const _=await Ie(s);if(m)return;r(_),i(_.status),t==null||t(_)}catch(_){if(m)return;d(_ instanceof Error?_.message:g("session.loadFailed"));return}try{await S.init()}catch(_){console.warn("Failed to init adapter:",_)}}return v(),()=>{m=!0}},[s,S,t]);const q=Pe(c),V=p.useCallback(async m=>{const v=m.text.trim(),_=m.images&&m.images.length>0||m.attachments&&m.attachments.length>0;if(!v&&!_||q)return;const C=await Me(v,{sessionId:s,availableCommands:[],availableModels:(E==null?void 0:E.availableModels)??[],currentModel:E?{modelId:E.currentModelId,name:E.currentModelId}:null,supportsImages:!0,entries:B.current,setModel:async I=>{await O(s,{type:"control_request",request:{subtype:"set_model",model:I}}),$(W=>W&&{...W,currentModelId:I})},onNewSession:()=>{y([])}}).catch(()=>null);if(C){if(Ee("[SessionDetail] local command result",C),"clearEntries"in C&&C.clearEntries){y([]);return}if("newSession"in C&&C.newSession){y([]);return}if("userEntry"in C){y(I=>[...I,C.userEntry,C.cmdEntry]);return}}N(!0);try{await S.sendMessage(v,m.images,m.attachments)}catch(I){console.error("Send failed:",I)}},[S,q,s,E]),z=p.useCallback(async()=>{try{await S.interrupt()}catch(m){console.error("Interrupt failed:",m)}finally{N(!1)}},[S]),w=p.useCallback(async()=>{if(n&&window.confirm(g("dashboard.confirmDelete").replace("{id}",n.title||n.id)))try{await Te(n.id),window.location.href="/code/"}catch(m){alert(m instanceof Error?m.message:g("dashboard.deleteFailed"))}},[n]);p.useEffect(()=>{if(f.length===0)return;const m=f[f.length-1];if((m==null?void 0:m.type)==="assistant_message"||(m==null?void 0:m.type)==="tool_call"){if(m.type==="tool_call"&&m.toolCall.status==="running")return;N(!1)}},[f]);const A=p.useCallback(async m=>{try{await S.respondPermission(m,!0)}catch(v){console.error("Failed to approve:",v)}M(v=>v.filter(_=>_.requestId!==m))},[S]),de=p.useCallback(async m=>{try{await S.respondPermission(m,!1)}catch(v){console.error("Failed to reject:",v)}M(v=>v.filter(_=>_.requestId!==m))},[S]),ue=p.useCallback(async(m,v,_)=>{try{await O(s,{type:"permission_response",approved:!0,request_id:m,updated_input:{questions:_,answers:v}})}catch(C){console.error("Failed to submit answers:",C)}M(C=>C.filter(I=>I.requestId!==m))},[s]),me=p.useCallback(async(m,v,_)=>{try{v==="no"?await O(s,{type:"permission_response",approved:!1,request_id:m,..._?{message:_}:{}}):await O(s,{type:"permission_response",approved:!0,request_id:m,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[v]||"default",destination:"session"}]})}catch(C){console.error("Failed to submit plan response:",C)}M(C=>C.filter(I=>I.requestId!==m))},[s]);return x?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-status-error",children:x}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:g("session.backToDashboard")})]})}):n?n.source==="acp"&&n.environment_id?e.jsx(Mt,{sessionId:s,agentId:n.environment_id}):e.jsx(re,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:n.title||n.id}),e.jsx("div",{className:"border-b bg-surface-1 px-4 py-3",children:e.jsxs("div",{className:"mx-auto max-w-5xl",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"font-display text-lg font-semibold text-text-primary",children:e.jsx("span",{className:"truncate",children:n.title||n.id})}),n.visibility&&e.jsx(Ue,{visibility:n.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var _;const m=n.source==="acp"?"acp":(_=n.environment)==null?void 0:_.worker_type,v=Fe(m);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${v.colorClass}`,children:v.fullLabel})})(),c&&e.jsx(ee,{status:c}),e.jsx("span",{className:"text-xs text-text-muted",children:te(n.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>b(!0),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:g("session.share"),children:e.jsx(st,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>a(!o),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:g("session.info"),children:e.jsx(Ye,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>l(!u),className:"flex items-center gap-1 rounded-md px-3 py-1.5 text-sm text-text-primary font-bold hover:bg-brand-light hover:text-white transition-colors",children:[g("session.tasks"),k.length>0&&e.jsx("span",{className:"ml-1 rounded-full bg-status-warning px-1.5 py-0.5 text-[10px] font-medium text-white",children:k.length})]})]})]}),o&&e.jsxs("div",{className:"mt-2 rounded-md bg-surface-2 px-3 py-2 text-xs text-text-muted space-y-1 font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:g("session.metaSession")})," ",n.id]}),n.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:g("session.metaEnvironment")})," ",n.environment_id]})]})]})}),e.jsx($e,{entries:f,isLoading:j,emptyTitle:g("session.emptyTitle"),emptyDescription:g("session.emptyDescription")}),e.jsx(yt,{state:R}),k.length>0&&e.jsx("div",{className:"border-t bg-surface-1 px-4 py-3",children:e.jsx("div",{className:"mx-auto max-w-3xl space-y-3",children:k.map(m=>e.jsx(Ct,{request:m,onApprove:()=>A(m.requestId),onReject:()=>de(m.requestId),onSubmitAnswers:ue,onSubmitPlan:me},m.requestId))})}),e.jsx(Ae,{onSubmit:V,isLoading:j,onInterrupt:z,disabled:q,placeholder:q?g("session.closed"):g("session.inputPlaceholder"),supportsAttachments:!0}),u&&n&&e.jsx(mt,{onClose:()=>l(!1),session:n,liveStatus:c,pendingPermissions:k,onInterrupt:z,onDelete:w}),e.jsx(vt,{open:h,onClose:()=>b(!1),sessionId:n.id,sessionTitle:n.title||void 0})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:g("session.loading")})})}function Ct({request:s,onApprove:t,onReject:n,onSubmitAnswers:r,onSubmitPlan:c}){const i=s.toolName,x=s.toolInput,d=s.description||"";if(i==="AskUserQuestion"){const u=x.questions||[];return e.jsx(gt,{requestId:s.requestId,questions:u,description:d,onSubmit:l=>r(s.requestId,l,u),onSkip:n})}if(i==="ExitPlanMode"){const u=x.plan||"";return e.jsx(wt,{requestId:s.requestId,planContent:u,description:d,onSubmit:(l,o)=>c(s.requestId,l,o)})}return e.jsx(bt,{requestId:s.requestId,toolName:i,toolInput:x,description:d,onApprove:t,onReject:n})}function Mt({sessionId:s,agentId:t}){const[n,r]=p.useState(null),[c,i]=p.useState("disconnected"),[x,d]=p.useState(null),u=p.useRef(null);return p.useEffect(()=>{const l=St(t);return l.setConnectionStateHandler((o,a)=>{i(o),d(a||null)}),u.current=l,r(l),l.connect().catch(o=>{o instanceof De||(d(o.message),i("error"))}),()=>{l.disconnect(),u.current=null,r(null),i("disconnected")}},[t]),e.jsx(re,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[x&&c==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:x}),c==="connecting"&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{className:"text-text-muted text-sm",children:g("session.connectingAgent")})]})}),c==="error"&&!n&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium mb-1",children:g("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:x})]})}),n&&c==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Re,{client:n,agentId:t})})]})})}export{Dt as SessionDetail};
55
+ ${a}`})}}const u=d.length===1&&d[0].type==="text"?d[0].text||t:d.length>0?d:t;await fe(this.sessionId,{type:"user",uuid:ye(),content:t,message:{content:u}})}async respondPermission(t,n,r){await O(this.sessionId,{type:"permission_response",approved:n,request_id:t,...r}),this.setEntries(c=>c.map(i=>{var x;return i.type!=="tool_call"||((x=i.toolCall.permissionRequest)==null?void 0:x.requestId)!==t?i:{type:"tool_call",toolCall:{...i.toolCall,status:n?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(n=>n.type!=="tool_call"||n.toolCall.status!=="running"&&n.toolCall.status!=="waiting_for_confirmation"?n:{type:"tool_call",toolCall:{...n.toolCall,status:"canceled",permissionRequest:void 0}})),await be(this.sessionId)}}function ct(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function dt(s){if(!s)return"never";const t=Math.max(0,Date.now()-s);return t<5e3?"just now":t<6e4?`${Math.floor(t/1e3)}s ago`:t<36e5?`${Math.floor(t/6e4)}m ago`:`${Math.floor(t/36e5)}h ago`}function ut(s){return s?Date.now()-s<6e4:!1}function mt({onClose:s,session:t,liveStatus:n,pendingPermissions:r,onInterrupt:c,onDelete:i}){const[x,d]=p.useState(!1),u=async()=>{await navigator.clipboard.writeText(t.id),d(!0),setTimeout(()=>d(!1),1500)},l=r.length,o=t.worker,a=t.work_item,h=t.environment;return e.jsx(ae,{open:!0,onOpenChange:b=>{b||s()},children:e.jsxs(oe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-96 h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md overflow-y-auto",children:[e.jsx(ie,{children:e.jsx(le,{className:"font-display font-semibold text-text-primary",children:"Session Ops"})}),e.jsxs("div",{className:"mt-3 space-y-5 text-sm",children:[e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(He,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(ee,{status:n||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:o&&(ut(o.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[o&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Y,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:dt(o.last_heartbeat_at)})]}),h&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Qe,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:h.machine_name||h.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Y,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:te(t.created_at)})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(se,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),l>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[l," permission request",l>1?"s":""," awaiting your approval"]}):e.jsx("p",{className:"text-xs text-text-muted",children:"No pending actions"})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(et,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:c,className:"flex-1 rounded-md border border-border px-3 py-1.5 text-xs text-text-secondary hover:bg-surface-2 transition-colors",children:"Interrupt"}),e.jsxs("button",{onClick:i,className:"flex-1 rounded-md border border-status-error/30 px-3 py-1.5 text-xs text-status-error hover:bg-status-error/10 transition-colors",children:[e.jsx(ge,{className:"mr-1 inline h-3 w-3"}),"Delete"]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(Ke,{className:"h-3.5 w-3.5"}),"Session Info"]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsx("dt",{children:"Session ID"}),e.jsxs("dd",{className:"flex items-center gap-1 min-w-0",children:[e.jsx("code",{className:"break-all font-mono text-text-secondary text-right",children:t.id}),e.jsx("button",{onClick:u,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:x?"✓":"⧉"})]})]}),a&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Spawn mode"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:a.spawn_mode??"default"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Work state"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:a.state})]})]}),t.source&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Source"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:t.source})]}),h&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:h.worker_type})]})]})]})]})]})})}const X="rcs:subagent-panel:collapsed";function xt(s){if(s<1e3)return"0s";const t=Math.floor(s/1e3);if(t<60)return`${t}s`;const n=Math.floor(t/60),r=t%60;if(n<60)return r?`${n}m${r}s`:`${n}m`;const c=Math.floor(n/60),i=n%60;return i?`${c}h${i}m`:`${c}h`}function pt(s){return s===void 0||s<=0?"":s<1e3?`${s}`:s<1e6?`${(s/1e3).toFixed(s<1e4?1:0)}k`:`${(s/1e6).toFixed(1)}M`}function ht({status:s}){return s==="running"?e.jsx(se,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(Ze,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(je,{className:"h-3 w-3 text-status-error"}):null}function ft({task:s}){const t=s.status==="running",n=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,r=pt(s.tokenCount),c=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",i=s.summary||s.description||"(no description)";return e.jsxs("div",{className:"flex items-start gap-2 rounded-md bg-surface-2 px-2.5 py-1.5 text-xs",children:[e.jsx("div",{className:"mt-0.5 flex-shrink-0",children:e.jsx(ht,{status:s.status})}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("div",{className:"flex items-baseline justify-between gap-2",children:[e.jsx("span",{className:"truncate font-medium text-text-primary",children:s.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:xt(n)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:i}),(r||c||s.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-text-muted",children:[r&&e.jsxs("span",{children:["↕ ",r," tok"]}),c&&e.jsxs("span",{children:["· ",c]}),s.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",s.lastToolName]})]}),!t&&s.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:s.finalSummary})]})]})}function yt({state:s}){const[t,n]=p.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(X)==="1"}catch{return!1}}),r=()=>{n(u=>{const l=!u;try{window.localStorage.setItem(X,l?"1":"0")}catch{}return l})},[,c]=p.useState(0);p.useEffect(()=>{const u=Object.values(s.tasks).some(a=>a.status==="running"),l=Object.values(s.tasks).some(a=>a.status!=="running"&&a.evictAfter!==void 0);if(!u&&!l)return;const o=setInterval(()=>{c(a=>a+1)},1e3);return()=>clearInterval(o)},[s]);const i=ot(s);if(i.length===0)return null;const x=i.filter(u=>u.status==="running").length,d=x>0?`${x} running`:`${i.length} recent`;return e.jsx("section",{"aria-label":"Subagents",className:"border-t border-border bg-surface-1 px-4 py-2",children:e.jsxs("div",{className:"mx-auto max-w-3xl space-y-1.5",children:[e.jsxs("button",{type:"button",onClick:r,"aria-expanded":!t,"aria-controls":"subagent-list",className:"flex w-full items-center justify-between text-[10px] font-medium uppercase tracking-wide text-text-muted hover:text-text-secondary transition-colors",children:[e.jsxs("span",{className:"flex items-center gap-1",children:[e.jsx(ze,{className:`h-3 w-3 transition-transform ${t?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:d})]}),!t&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:i.map(u=>e.jsx(ft,{task:u},u.taskId))})]})})}function bt({requestId:s,toolName:t,toolInput:n,description:r,onApprove:c,onReject:i}){const x=typeof n=="string"?n:JSON.stringify(n,null,2);return e.jsxs("div",{className:"rounded-xl border border-warning-border/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-2 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-warning-border/15 text-warning-text",children:e.jsx(rt,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold text-warning-text",children:"Permission Request"})]}),r&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:P(r)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:P(t)}),t!=="AskUserQuestion"&&e.jsx("pre",{className:"mb-3 max-h-40 overflow-auto rounded-lg bg-surface-1 p-2 text-xs text-text-secondary font-mono",children:Ne(x,500)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:c,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Approve"}),e.jsx("button",{onClick:i,className:"rounded-lg bg-status-error/20 px-4 py-2 text-sm font-medium text-status-error hover:bg-status-error/30 transition-colors",children:"Reject"})]})]})}function gt({questions:s,description:t,onSubmit:n,onSkip:r}){const[c,i]=p.useState({}),[x,d]=p.useState({}),[u,l]=p.useState(0),o=(f,y,j)=>{if(j){const N=c[f]||[],k=N.includes(y)?N.filter(M=>M!==y):[...N,y];i({...c,[f]:k})}else i({...c,[f]:y})},a=f=>{var j;const y=(j=x[f])==null?void 0:j.trim();y&&(i({...c,[f]:y}),d({...x,[f]:""}))},h=()=>{var y,j;const f={};for(const[N,k]of Object.entries(c)){const M=s[parseInt(N,10)];M&&(typeof k=="number"?f[N]=((j=(y=M.options)==null?void 0:y[k])==null?void 0:j.label)||String(k):Array.isArray(k)?f[N]=k.map(E=>{var $,R;return((R=($=M.options)==null?void 0:$[E])==null?void 0:R.label)||String(E)}):f[N]=k)}n(f)};if(s.length<=1){const f=s[0]||{question:t,options:[],multiSelect:!1},y=f.multiSelect||!1;return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:P(t||f.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(f.options||[]).map((j,N)=>{const k=y?(c[0]||[]).includes(N):c[0]===N;return e.jsxs("button",{onClick:()=>o(0,N,y),className:H("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",k?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:P(j.label)}),j.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:P(j.description)})]},N)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:x[0]||"",onChange:j=>d({...x,0:j.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:j=>j.key==="Enter"&&a(0)}),e.jsx("button",{onClick:()=>a(0),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:h,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const b=s[u];return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx("div",{className:"mb-3 text-sm font-semibold text-text-primary",children:P(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:s.map((f,y)=>e.jsx("button",{onClick:()=>l(y),className:H("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",u===y?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:f.header||`Q${y+1}`},y))}),b&&e.jsx(jt,{question:b,qIdx:u,answers:c,otherTexts:x,onSelect:o,onOtherTextChange:(f,y)=>d({...x,[f]:y}),onOtherSubmit:a}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[u+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:h,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick:r,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function jt({question:s,qIdx:t,answers:n,otherTexts:r,onSelect:c,onOtherTextChange:i,onOtherSubmit:x}){const d=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:P(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((u,l)=>{const o=d?(n[t]||[]).includes(l):n[t]===l;return e.jsxs("button",{onClick:()=>c(t,l,d),className:H("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",o?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsx("div",{className:"font-medium",children:P(u.label)}),u.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:P(u.description)})]},l)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r[t]||"",onChange:u=>i(t,u.target.value),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:u=>u.key==="Enter"&&x(t)}),e.jsx("button",{onClick:()=>x(t),className:"rounded-lg border border-border px-3 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]})]})}function wt({planContent:s,description:t,onSubmit:n}){const[r,c]=p.useState(null),[i,x]=p.useState(""),d=!s||!s.trim(),u=()=>{r&&n(r,r==="no"?i:void 0)};return e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsxs("div",{className:"mb-3 flex items-center gap-2",children:[e.jsx("span",{className:"flex h-5 w-5 items-center justify-center rounded-full bg-brand/15 text-brand",children:e.jsx(we,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:d?"Exit plan mode?":"Ready to code?"})]}),!d&&e.jsx("div",{className:"mb-4 max-h-64 overflow-auto rounded-lg bg-tool-card p-4 text-sm text-text-secondary",dangerouslySetInnerHTML:{__html:Nt(s)}}),e.jsx("div",{className:"space-y-2",children:d?e.jsxs(e.Fragment,{children:[e.jsx(F,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes"}),e.jsx(F,{selected:r==="no",onClick:()=>c("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(F,{selected:r==="yes-accept-edits",onClick:()=>c("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(F,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(F,{selected:r==="no",onClick:()=>c("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:i,onChange:l=>x(l.target.value),placeholder:"Tell Saluzi what to change...",className:"mt-3 w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",rows:3}),e.jsx("div",{className:"mt-4",children:e.jsx("button",{onClick:u,disabled:!r,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})})]})}function F({selected:s,onClick:t,label:n,desc:r}){return e.jsxs("button",{onClick:t,className:H("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",s?"border-brand bg-brand/10 text-text-primary":"border-border bg-surface-2 text-text-secondary hover:border-border-light"),children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:H("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",s?"border-brand bg-brand text-white":"border-border"),children:s&&"✓"}),e.jsx("span",{className:"font-medium",children:n})]}),r&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs text-text-muted",children:r})]})}function Nt(s){let t=P(s);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(n,r,c)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${c.trim()}</pre>`),t=t.replace(/`([^`]+)`/g,'<code class="rounded bg-tool-card px-1.5 py-0.5 font-mono text-xs">$1</code>'),t=t.replace(/\*\*([^*]+)\*\*/g,"<strong>$1</strong>"),t}function kt(s){const[t,n]=p.useState([]),[r,c]=p.useState(!0),[i,x]=p.useState(null),d=p.useCallback(async()=>{c(!0),x(null);try{const o=await ke(s);n(o)}catch(o){x(o instanceof Error?o.message:"Failed to load shares")}finally{c(!1)}},[s]);p.useEffect(()=>{d()},[d]);const u=p.useCallback(async o=>{x(null);try{const a=await ve(s,o);return await d(),a}catch(a){throw x(a instanceof Error?a.message:"Failed to create share"),a}},[s,d]),l=p.useCallback(async o=>{x(null);try{await _e(s,o),await d()}catch(a){throw x(a instanceof Error?a.message:"Failed to revoke share"),a}},[s,d]);return{shares:t,isLoading:r,error:i,createShare:u,revokeShare:l,refresh:d}}function vt({open:s,onClose:t,sessionId:n,sessionTitle:r}){ne();const{shares:c,isLoading:i,error:x,createShare:d,revokeShare:u}=kt(n),[l,o]=p.useState("user"),[a,h]=p.useState(""),[b,f]=p.useState(""),[y,j]=p.useState("read"),[N,k]=p.useState(""),[M,E]=p.useState(!1),[$,R]=p.useState(null),[L,U]=p.useState(""),[z,S]=p.useState(!1);p.useEffect(()=>{s&&(o("user"),h(""),f(""),j("read"),k(""),E(!1),R(null),U(""),S(!1))},[s]);const q=async()=>{E(!0),U(""),R(null);try{const w={grantedTo:l==="user"?{userId:a.trim()}:{teamId:b.trim()},permission:y};N.trim()&&(w.expiresAt=N.trim());const A=await d(w);R(A.shareToken)}catch(w){U(w instanceof Error?w.message:"Failed to create share")}finally{E(!1)}},Q=async w=>{try{await u(w)}catch{}},B=async()=>{if(!$)return;const w=`${window.location.origin}/code/s/${$}`;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(w),S(!0),setTimeout(()=>S(!1),2e3);return}}catch{}const A=document.createElement("textarea");A.value=w,A.style.position="fixed",A.style.opacity="0",document.body.appendChild(A),A.select();try{document.execCommand("copy"),S(!0),setTimeout(()=>S(!1),2e3)}catch{}document.body.removeChild(A)};return e.jsx(ae,{open:s,onOpenChange:w=>{w||t()},children:e.jsxs(oe,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(ie,{children:e.jsxs(le,{className:"font-display text-lg font-semibold text-text-primary",children:[g("share.title"),r?`: ${r}`:""]})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:g("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>o("user"),className:`rounded-md px-3 py-1 text-sm transition-colors ${l==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:g("share.user")}),e.jsx("button",{onClick:()=>o("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${l==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:g("share.team")})]}),l==="user"?e.jsx("input",{type:"text",value:a,onChange:w=>h(w.target.value),placeholder:g("share.userIdPlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"}):e.jsx("input",{type:"text",value:b,onChange:w=>f(w.target.value),placeholder:g("share.teamIdPlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:g("share.permission")}),e.jsxs("select",{value:y,onChange:w=>j(w.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"read",children:g("share.permissionRead")}),e.jsx("option",{value:"write",children:g("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:g("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:N,onChange:w=>k(w.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none"})]}),(L||x)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:L||x}),$&&e.jsxs("div",{className:"rounded-md bg-surface-2 px-3 py-2",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-1",children:g("share.linkCreated")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"flex-1 truncate text-xs text-text-primary",children:["/code/s/",$]}),e.jsx("button",{onClick:B,className:"rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:z?g("share.copied"):g("share.copy")})]})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:g("share.existingShares")}),i?e.jsx("p",{className:"text-sm text-text-muted",children:g("share.loading")}):c.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:g("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:c.map(w=>e.jsxs("div",{className:"flex items-center justify-between rounded-md bg-surface-2 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"truncate text-sm text-text-primary",children:w.granted_to_user||w.granted_to_team||"Unknown"}),e.jsxs("p",{className:"text-xs text-text-muted",children:[w.permission==="write"?g("share.permissionWrite"):g("share.permissionRead"),w.expires_at?` · expires ${w.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>Q(w.id),className:"ml-2 shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:g("share.revoke")})]},w.id))})]})]}),e.jsxs(Ue,{children:[e.jsx("button",{onClick:t,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:g("common.close")}),e.jsx("button",{onClick:q,disabled:M,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:M?g("common.creating"):g("share.createShare")})]})]})})}function _t(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function St(s){const t=_t(s),n=Ce(),r=n?{proxyUrl:t,token:n}:{proxyUrl:t};return new Se(r)}function Rt({sessionId:s,onSessionLoaded:t}){ne();const[n,r]=p.useState(null),[c,i]=p.useState(null),[x,d]=p.useState(""),[u,l]=p.useState(!1),[o,a]=p.useState(!1),[h,b]=p.useState(!1),[f,y]=p.useState([]),[j,N]=p.useState(!1),[k,M]=p.useState([]),[E,$]=p.useState(null),[R,L]=p.useState(()=>ce()),U=p.useRef(null),z=p.useRef(f);z.current=f;const S=p.useMemo(()=>new lt(s,y,{onStatusChange:m=>{i(m)},onError:m=>{console.error("[RCSChatAdapter] error:",m)},onPermissionRequest:m=>{M(v=>v.some(_=>_.requestId===m.requestId)?v:[...v,m])},onModelsStateChange:m=>{$(m)},onSubagentUpdate:m=>{L(m)}}),[s]);p.useEffect(()=>(U.current=S,()=>{S.disconnect()}),[S]),p.useEffect(()=>{let m=!1;async function v(){d("");try{const _=await Ie(s);if(m)return;r(_),i(_.status),t==null||t(_)}catch(_){if(m)return;d(_ instanceof Error?_.message:g("session.loadFailed"));return}try{await S.init()}catch(_){console.warn("Failed to init adapter:",_)}}return v(),()=>{m=!0}},[s,S,t]);const q=Pe(c),Q=p.useCallback(async m=>{const v=m.text.trim(),_=m.images&&m.images.length>0||m.attachments&&m.attachments.length>0;if(!v&&!_||q)return;const C=await Me(v,{sessionId:s,availableCommands:[],availableModels:(E==null?void 0:E.availableModels)??[],currentModel:E?{modelId:E.currentModelId,name:E.currentModelId}:null,supportsImages:!0,entries:z.current,setModel:async I=>{await O(s,{type:"control_request",request:{subtype:"set_model",model:I}}),$(W=>W&&{...W,currentModelId:I})},onNewSession:()=>{y([])}}).catch(()=>null);if(C){if(Ee("[SessionDetail] local command result",C),"clearEntries"in C&&C.clearEntries){y([]);return}if("newSession"in C&&C.newSession){y([]);return}if("userEntry"in C){y(I=>[...I,C.userEntry,C.cmdEntry]);return}}N(!0);try{await S.sendMessage(v,m.images,m.attachments)}catch(I){console.error("Send failed:",I)}},[S,q,s,E]),B=p.useCallback(async()=>{try{await S.interrupt()}catch(m){console.error("Interrupt failed:",m)}finally{N(!1)}},[S]),w=p.useCallback(async()=>{if(n&&window.confirm(g("dashboard.confirmDelete").replace("{id}",n.title||n.id)))try{await Te(n.id),window.location.href="/code/"}catch(m){alert(m instanceof Error?m.message:g("dashboard.deleteFailed"))}},[n]);p.useEffect(()=>{if(f.length===0)return;const m=f[f.length-1];if((m==null?void 0:m.type)==="assistant_message"||(m==null?void 0:m.type)==="tool_call"){if(m.type==="tool_call"&&m.toolCall.status==="running")return;N(!1)}},[f]);const A=p.useCallback(async m=>{try{await S.respondPermission(m,!0)}catch(v){console.error("Failed to approve:",v)}M(v=>v.filter(_=>_.requestId!==m))},[S]),de=p.useCallback(async m=>{try{await S.respondPermission(m,!1)}catch(v){console.error("Failed to reject:",v)}M(v=>v.filter(_=>_.requestId!==m))},[S]),ue=p.useCallback(async(m,v,_)=>{try{await O(s,{type:"permission_response",approved:!0,request_id:m,updated_input:{questions:_,answers:v}})}catch(C){console.error("Failed to submit answers:",C)}M(C=>C.filter(I=>I.requestId!==m))},[s]),me=p.useCallback(async(m,v,_)=>{try{v==="no"?await O(s,{type:"permission_response",approved:!1,request_id:m,..._?{message:_}:{}}):await O(s,{type:"permission_response",approved:!0,request_id:m,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[v]||"default",destination:"session"}]})}catch(C){console.error("Failed to submit plan response:",C)}M(C=>C.filter(I=>I.requestId!==m))},[s]);return x?e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-status-error",children:x}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:g("session.backToDashboard")})]})}):n?n.source==="acp"&&n.environment_id?e.jsx(Mt,{sessionId:s,agentId:n.environment_id}):e.jsx(re,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:n.title||n.id}),e.jsx("div",{className:"border-b bg-surface-1 px-4 py-3",children:e.jsxs("div",{className:"mx-auto max-w-5xl",children:[e.jsxs("div",{className:"flex items-start justify-between",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h2",{className:"font-display text-lg font-semibold text-text-primary",children:e.jsx("span",{className:"truncate",children:n.title||n.id})}),n.visibility&&e.jsx(Fe,{visibility:n.visibility||"private"})]}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var _;const m=n.source==="acp"?"acp":(_=n.environment)==null?void 0:_.worker_type,v=qe(m);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${v.colorClass}`,children:v.fullLabel})})(),c&&e.jsx(ee,{status:c}),e.jsx("span",{className:"text-xs text-text-muted",children:te(n.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>b(!0),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:g("session.share"),children:e.jsx(st,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>a(!o),className:"flex items-center gap-1 rounded-md px-2 py-1 text-xs text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:g("session.info"),children:e.jsx(Je,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>l(!u),className:"flex items-center gap-1 rounded-md px-3 py-1.5 text-sm text-text-primary font-bold hover:bg-brand-light hover:text-white transition-colors",children:[g("session.tasks"),k.length>0&&e.jsx("span",{className:"ml-1 rounded-full bg-status-warning px-1.5 py-0.5 text-[10px] font-medium text-white",children:k.length})]})]})]}),o&&e.jsxs("div",{className:"mt-2 rounded-md bg-surface-2 px-3 py-2 text-xs text-text-muted space-y-1 font-mono",children:[e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:g("session.metaSession")})," ",n.id]}),n.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:g("session.metaEnvironment")})," ",n.environment_id]})]})]})}),e.jsx($e,{entries:f,isLoading:j,emptyTitle:g("session.emptyTitle"),emptyDescription:g("session.emptyDescription")}),e.jsx(yt,{state:R}),k.length>0&&e.jsx("div",{className:"border-t bg-surface-1 px-4 py-3",children:e.jsx("div",{className:"mx-auto max-w-3xl space-y-3",children:k.map(m=>e.jsx(Ct,{request:m,onApprove:()=>A(m.requestId),onReject:()=>de(m.requestId),onSubmitAnswers:ue,onSubmitPlan:me},m.requestId))})}),e.jsx(Ae,{onSubmit:Q,isLoading:j,onInterrupt:B,disabled:q,placeholder:q?g("session.closed"):g("session.inputPlaceholder"),supportsAttachments:!0}),u&&n&&e.jsx(mt,{onClose:()=>l(!1),session:n,liveStatus:c,pendingPermissions:k,onInterrupt:B,onDelete:w}),e.jsx(vt,{open:h,onClose:()=>b(!1),sessionId:n.id,sessionTitle:n.title||void 0})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:g("session.loading")})})}function Ct({request:s,onApprove:t,onReject:n,onSubmitAnswers:r,onSubmitPlan:c}){const i=s.toolName,x=s.toolInput,d=s.description||"";if(i==="AskUserQuestion"){const u=x.questions||[];return e.jsx(gt,{requestId:s.requestId,questions:u,description:d,onSubmit:l=>r(s.requestId,l,u),onSkip:n})}if(i==="ExitPlanMode"){const u=x.plan||"";return e.jsx(wt,{requestId:s.requestId,planContent:u,description:d,onSubmit:(l,o)=>c(s.requestId,l,o)})}return e.jsx(bt,{requestId:s.requestId,toolName:i,toolInput:x,description:d,onApprove:t,onReject:n})}function Mt({sessionId:s,agentId:t}){const[n,r]=p.useState(null),[c,i]=p.useState("disconnected"),[x,d]=p.useState(null),u=p.useRef(null);return p.useEffect(()=>{const l=St(t);return l.setConnectionStateHandler((o,a)=>{i(o),d(a||null)}),u.current=l,r(l),l.connect().catch(o=>{o instanceof De||(d(o.message),i("error"))}),()=>{l.disconnect(),u.current=null,r(null),i("disconnected")}},[t]),e.jsx(re,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[x&&c==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:x}),c==="connecting"&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{className:"text-text-muted text-sm",children:g("session.connectingAgent")})]})}),c==="error"&&!n&&e.jsx("div",{className:"flex-1 flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"font-medium mb-1",children:g("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:x})]})}),n&&c==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Re,{client:n,agentId:t})})]})})}export{Rt as SessionDetail};
@@ -0,0 +1,11 @@
1
+ import{j as t}from"./vendor-DE_-CLIE.js";import{H as l,R as c,f as d,e as g,X as u,G as o,T as x,g as f,O as m,U as p}from"./main-CEsvX5rj.js";/**
2
+ * @license lucide-react v0.555.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const b=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],y=l("globe",b);/**
7
+ * @license lucide-react v0.555.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const h=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],j=l("lock",h);function z({...a}){return t.jsx(c,{"data-slot":"dialog",...a})}function v({...a}){return t.jsx(f,{"data-slot":"dialog-portal",...a})}function k({className:a,...e}){return t.jsx(m,{"data-slot":"dialog-overlay",className:o("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",a),...e})}function C({className:a,children:e,showCloseButton:s=!0,...n}){return t.jsxs(v,{"data-slot":"dialog-portal",children:[t.jsx(k,{}),t.jsxs(d,{"data-slot":"dialog-content",className:o("bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 sm:max-w-lg",a),...n,children:[e,s&&t.jsxs(g,{"data-slot":"dialog-close",className:"ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",children:[t.jsx(u,{}),t.jsx("span",{className:"sr-only",children:"Close"})]})]})]})}function D({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-header",className:o("flex flex-col gap-2 text-center sm:text-left",a),...e})}function _({className:a,...e}){return t.jsx("div",{"data-slot":"dialog-footer",className:o("flex flex-col-reverse gap-2 sm:flex-row sm:justify-end",a),...e})}function I({className:a,...e}){return t.jsx(x,{"data-slot":"dialog-title",className:o("text-lg leading-none font-semibold",a),...e})}function P({visibility:a,className:e}){const s={private:{label:"Private",Icon:j,colorClass:"text-text-muted border-border/60"},team:{label:"Team",Icon:p,colorClass:"text-accent border-accent/40"},public:{label:"Public",Icon:y,colorClass:"text-accent border-accent/40"}},{label:n,Icon:i,colorClass:r}=s[a];return t.jsxs("span",{className:o("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",r,e),children:[t.jsx(i,{className:"h-3 w-3"}),n]})}export{z as D,P as S,C as a,_ as b,D as c,I as d};
@@ -0,0 +1 @@
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{a0 as v,Y as t}from"./main-CEsvX5rj.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function q({onSuccess:p,onAlreadyDone:b}){const{setup:f}=v(),[n,h]=r.useState(""),[l,y]=r.useState(""),[a,g]=r.useState(""),[d,w]=r.useState(""),[i,o]=r.useState(""),[c,m]=r.useState(!1),j=async s=>{if(s.preventDefault(),o(""),a.length<8){o(t("auth.setup.passwordTooShort"));return}if(a!==d){o(t("auth.setup.passwordMismatch"));return}m(!0);try{await f(n,l,a),p()}catch(x){const u=x instanceof Error?x.message:"Setup failed";if(u.includes("already")||u.includes("409")){b();return}o(u)}finally{m(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold text-text-primary",children:t("auth.setup.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.setup.description")})]}),e.jsxs("form",{onSubmit:j,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.apiKey")}),e.jsx("input",{type:"password",value:n,onChange:s=>h(s.target.value),required:!0,autoComplete:"off",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.username")}),e.jsx("input",{type:"text",value:l,onChange:s=>y(s.target.value),required:!0,autoComplete:"username",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.password")}),e.jsx("input",{type:"password",value:a,onChange:s=>g(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.setup.confirmPassword")}),e.jsx("input",{type:"password",value:d,onChange:s=>w(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),i&&e.jsx("p",{className:"text-sm text-status-error",children:i}),e.jsx("button",{type:"submit",disabled:c,className:"w-full rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light disabled:cursor-not-allowed disabled:opacity-50",children:c?t("common.loading"):t("auth.setup.submit")})]})]})})}export{q as Setup};
@@ -1 +1 @@
1
- import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{v as m,b as h}from"./main-J6cPs2y8.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function v(){const[t,r]=d.useState("loading"),[i,a]=d.useState(""),l=(typeof window<"u"?window.location.pathname:"").match(/\/code\/s\/([^/?]+)/),o=l?l[1]:null;return d.useEffect(()=>{if(!o){r("invalid"),a("Share link is invalid — no token found.");return}if(!o.startsWith("shr_")){r("invalid"),a("Invalid share token format.");return}let n=!1;async function c(){try{const s=await m(o);if(n)return;window.location.href=`/code/${s.id}`}catch(s){if(n)return;s instanceof h?s.status===401&&s.message.toLowerCase().includes("expired")?(r("expired"),a("This share has expired.")):s.status===404?s.message.toLowerCase().includes("session")?(r("not_found"),a("Session not found.")):(r("invalid"),a("Share not found or has been revoked.")):s.status===403?(r("invalid"),a("You do not have permission to access this share.")):(r("error"),a(s.message||"Failed to resolve share.")):(r("error"),a(s instanceof Error?s.message:"Failed to resolve share."))}}return c(),()=>{n=!0}},[o]),d.useEffect(()=>{if(t!=="loading"&&t!=="error"){const n=setTimeout(()=>{window.location.href="/code"},3e3);return()=>clearTimeout(n)}},[t]),t==="loading"?e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-muted",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{children:"Resolving share link..."})]})}):e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-primary",children:e.jsxs("div",{className:"text-center max-w-md px-4",children:[t==="expired"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Share Expired"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share has expired."})]}),t==="invalid"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Invalid Share"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share link is invalid or has been revoked."})]}),t==="not_found"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Not Found"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"The session could not be found."})]}),t==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Error"}),e.jsx("p",{className:"text-status-error mb-4",children:i})]}),e.jsx("a",{href:"/code",className:"text-brand hover:underline",children:"← Back to Dashboard"})]})})}export{v as ShareLanding};
1
+ import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{w as m,b as h}from"./main-CEsvX5rj.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function j(){const[t,r]=d.useState("loading"),[i,a]=d.useState(""),l=(typeof window<"u"?window.location.pathname:"").match(/\/code\/s\/([^/?]+)/),o=l?l[1]:null;return d.useEffect(()=>{if(!o){r("invalid"),a("Share link is invalid — no token found.");return}if(!o.startsWith("shr_")){r("invalid"),a("Invalid share token format.");return}let n=!1;async function c(){try{const s=await m(o);if(n)return;window.location.href=`/code/${s.id}`}catch(s){if(n)return;s instanceof h?s.status===401&&s.message.toLowerCase().includes("expired")?(r("expired"),a("This share has expired.")):s.status===404?s.message.toLowerCase().includes("session")?(r("not_found"),a("Session not found.")):(r("invalid"),a("Share not found or has been revoked.")):s.status===403?(r("invalid"),a("You do not have permission to access this share.")):(r("error"),a(s.message||"Failed to resolve share.")):(r("error"),a(s instanceof Error?s.message:"Failed to resolve share."))}}return c(),()=>{n=!0}},[o]),d.useEffect(()=>{if(t!=="loading"&&t!=="error"){const n=setTimeout(()=>{window.location.href="/code"},3e3);return()=>clearTimeout(n)}},[t]),t==="loading"?e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-muted",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-brand border-t-transparent rounded-full mx-auto mb-3"}),e.jsx("p",{children:"Resolving share link..."})]})}):e.jsx("div",{className:"flex h-screen items-center justify-center bg-surface-0 text-text-primary",children:e.jsxs("div",{className:"text-center max-w-md px-4",children:[t==="expired"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Share Expired"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share has expired."})]}),t==="invalid"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Invalid Share"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"This share link is invalid or has been revoked."})]}),t==="not_found"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Not Found"}),e.jsx("p",{className:"text-text-muted mb-4",children:i||"The session could not be found."})]}),t==="error"&&e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"font-display text-xl font-semibold mb-2",children:"Error"}),e.jsx("p",{className:"text-status-error mb-4",children:i})]}),e.jsx("a",{href:"/code",className:"text-brand hover:underline",children:"← Back to Dashboard"})]})})}export{j as ShareLanding};
@@ -0,0 +1 @@
1
+ import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{a1 as f,a2 as y,Y as r}from"./main-CEsvX5rj.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function S(){f();const{createTeam:u}=y(),[o,p]=a.useState(""),[s,c]=a.useState(""),[i,b]=a.useState(""),[m,l]=a.useState(null),[d,x]=a.useState(!1),h=t=>{p(t),s||c(t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-"))},g=async t=>{t.preventDefault(),l(null),x(!0);try{const n=await u({name:o,slug:s,description:i||void 0});window.location.href=`/teams/${n.slug}`}catch(n){l(n instanceof Error?n.message:"Failed to create team")}finally{x(!1)}};return e.jsx("div",{className:"px-6 py-12 sm:px-10 sm:py-16",children:e.jsxs("div",{children:[e.jsx("h1",{className:"mb-10 font-display text-2xl font-semibold tracking-tight text-text-primary",children:r("team.create.title")}),e.jsxs("form",{onSubmit:g,className:"max-w-md space-y-8",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.name")}),e.jsx("input",{id:"name",type:"text",required:!0,value:o,onChange:t=>h(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",placeholder:"Engineering"}),e.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:r("team.create.nameHint")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"slug",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.slug")}),e.jsx("input",{id:"slug",type:"text",required:!0,value:s,onChange:t=>c(t.target.value),pattern:"^[a-z0-9-]{3,32}$",className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",placeholder:"engineering"}),e.jsx("p",{className:"mt-1.5 text-xs text-text-muted",children:r("team.create.slugHint")})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-text-primary mb-2",children:r("team.create.description")}),e.jsx("textarea",{id:"description",value:i,onChange:t=>b(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",rows:3})]}),m&&e.jsx("p",{className:"text-sm text-destructive",children:m}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>window.history.back(),className:"rounded-md border border-border px-4 py-2 text-sm text-text-primary hover:bg-surface-2 transition-colors",children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:d||!o||!s,className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:d?r("common.creating"):r("team.create.submit")})]})]})]})})}export{S as TeamCreate};
@@ -0,0 +1,6 @@
1
+ import{e as a,j as e}from"./vendor-DE_-CLIE.js";import{H as M,l as w,a1 as P,Y as y,X as B,i as G,r as z,E as I,B as O,a0 as Q,S as W}from"./main-CEsvX5rj.js";import{C as T}from"./copy-DdSkINCW.js";import{g as X}from"./workerType-Bd-zteMi.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";/**
2
+ * @license lucide-react v0.555.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const Y=[["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"}]],q=M("user-plus",Y);function _(s){const[o,r]=a.useState([]),[j,v]=a.useState(!1),i=a.useCallback(async()=>{if(s){v(!0);try{const x=await w("GET",`/web/teams/${s}/members`);r(x)}catch{r([])}finally{v(!1)}}},[s]);a.useEffect(()=>{i()},[i]);const u=a.useCallback(async(x,l)=>{await w("POST",`/web/teams/${s}/members`,{userId:x,role:l}),await i()},[s,i]),d=a.useCallback(async x=>{await w("DELETE",`/web/teams/${s}/members/${x}`),await i()},[s,i]),m=a.useCallback(async(x,l)=>{await w("PATCH",`/web/teams/${s}/members/${x}`,{role:l}),await i()},[s,i]);return{members:o,isLoading:j,addMember:u,removeMember:d,updateRole:m,refetch:i}}function J(s){const[o,r]=a.useState([]),j=a.useCallback(async i=>{if(!s)return null;const u=await w("POST",`/web/teams/${s}/invitations`,i);return r(d=>[...d,u]),u},[s]),v=a.useCallback(async i=>{s&&(await w("DELETE",`/web/teams/${s}/invitations/${i}`),r(u=>u.filter(d=>d.token!==i)))},[s]);return{invitations:o,createInvitation:j,revokeInvitation:v}}function V({teamId:s,canManage:o}){P();const{invitations:r,createInvitation:j,revokeInvitation:v}=J(s),{addMember:i}=_(s),[u,d]=a.useState(!1),[m,x]=a.useState(null),[l,p]=a.useState("member"),[N,g]=a.useState(!1),[c,b]=a.useState(""),[C,k]=a.useState([]),[E,S]=a.useState(!1),[t,h]=a.useState("member"),[$,L]=a.useState(null),[A,U]=a.useState(!1),R=async()=>{d(!0);try{const n=await j({role:l,expiresIn:86400,maxUses:5});n&&x(n.token||n.inviteToken||null)}catch{}finally{d(!1)}},D=async()=>{if(!m)return;const n=`${window.location.origin}/join?invite=${m}`;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(n);return}}catch{}const f=document.createElement("textarea");f.value=n,f.style.position="fixed",f.style.opacity="0",document.body.appendChild(f),f.select();try{document.execCommand("copy")}catch{}document.body.removeChild(f)},F=async n=>{if(b(n),n.trim().length<2){k([]);return}S(!0);try{const f=await w("GET",`/web/users/search?q=${encodeURIComponent(n.trim())}`);k(f)}catch{k([])}finally{S(!1)}},H=async n=>{U(!0),L(null);try{await i(n,t),b(""),k([]),g(!1)}catch(f){L(f instanceof Error?f.message:"Failed to add user")}finally{U(!1)}};return e.jsxs("div",{className:"space-y-5",children:[o&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{className:"rounded-md border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-text-primary focus:border-accent focus:outline-none",value:l,onChange:n=>p(n.target.value),children:[e.jsx("option",{value:"member",children:y("invitation.member")}),e.jsx("option",{value:"admin",children:y("invitation.admin")})]}),e.jsx("button",{type:"button",onClick:R,disabled:u,className:"rounded-md bg-accent px-3 py-1.5 text-xs font-medium text-white transition-colors hover:bg-accent/90 disabled:opacity-50",children:u?y("invitation.creating"):y("invitation.create")}),e.jsxs("button",{type:"button",onClick:()=>g(!N),className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs font-medium text-text-primary transition-colors hover:bg-surface-2",title:y("invitation.addExistingHint"),children:[e.jsx(q,{className:"h-3.5 w-3.5"}),y("invitation.addExisting")]})]}),N&&o&&e.jsxs("div",{className:"space-y-3 rounded border border-border bg-surface-2 p-3",children:[e.jsx("p",{className:"text-xs text-text-muted",children:y("invitation.addExistingHint")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"text",value:c,onChange:n=>F(n.target.value),placeholder:y("invitation.searchUser"),className:"flex-1 rounded border border-border bg-surface-1 px-3 py-1.5 text-sm text-text-primary focus:border-accent focus:outline-none",autoFocus:!0}),e.jsxs("select",{className:"rounded border border-border bg-surface-1 px-2 py-1.5 text-sm",value:t,onChange:n=>h(n.target.value),children:[e.jsx("option",{value:"member",children:y("invitation.member")}),e.jsx("option",{value:"admin",children:y("invitation.admin")})]})]}),E&&e.jsx("p",{className:"text-xs text-text-muted",children:"Searching..."}),$&&e.jsx("p",{className:"text-xs text-destructive",children:$}),C.length>0&&e.jsx("ul",{className:"divide-y divide-border rounded border border-border bg-surface-1",children:C.map(n=>e.jsxs("li",{className:"flex items-center justify-between px-3 py-2 text-sm",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("div",{className:"text-text-primary",children:n.username}),e.jsx("div",{className:"truncate font-mono text-xs text-text-muted",children:n.id})]}),e.jsx("button",{type:"button",onClick:()=>H(n.id),disabled:A,className:"rounded bg-accent px-2 py-1 text-xs text-white hover:bg-accent/90 disabled:opacity-50",children:y("invitation.add")})]},n.id))}),c.trim().length>=2&&C.length===0&&!E&&e.jsx("p",{className:"text-xs text-text-muted",children:"No users found."})]}),m&&e.jsxs("div",{className:"flex items-center gap-2 rounded border border-accent/40 bg-accent/5 p-3",children:[e.jsx("code",{className:"flex-1 text-xs text-text-primary break-all",children:`${window.location.origin}/join?invite=${m}`}),e.jsx("button",{type:"button",onClick:D,className:"text-text-muted hover:text-text-primary",children:e.jsx(T,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>x(null),className:"text-text-muted hover:text-text-primary",children:e.jsx(B,{className:"h-4 w-4"})})]}),r.length>0&&e.jsx("ul",{className:"space-y-2",children:r.map(n=>e.jsxs("li",{className:"flex items-center justify-between rounded border border-border/60 bg-surface-2 p-2 text-sm",children:[e.jsxs("span",{className:"text-text-muted",children:[n.role," — expires ",new Date(n.expiresAt).toLocaleDateString()]}),o&&e.jsx("button",{type:"button",onClick:()=>v(n.token),className:"text-sm text-destructive hover:underline",children:y("invitation.revoke")})]},n.token))})]})}function Z({teamId:s,canManage:o}){const[r,j]=a.useState([]),[v,i]=a.useState(!0),[u,d]=a.useState(null),[m,x]=a.useState(""),[l,p]=a.useState(null),[N,g]=a.useState(!1),c=async()=>{try{const t=await z();j(t||[])}catch(t){d(t instanceof Error?t.message:"Failed to load environments")}finally{i(!1)}};a.useEffect(()=>{c()},[]);const b=a.useMemo(()=>r.filter(t=>t.team_id===s),[r,s]),C=a.useMemo(()=>r.filter(t=>!t.team_id),[r]),k=async()=>{if(m){p(null);try{await O(m,s),x(""),await c()}catch(t){p(t instanceof Error?t.message:"Failed to link environment")}}},E=async t=>{if(window.confirm("Unlink this environment from the team? It will revert to personal scope.")){p(null);try{await I(s,t),await c()}catch(h){p(h instanceof Error?h.message:"Failed to unlink environment")}}},S=async()=>{const t=`slz rc --team-id ${s}`;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(t),g(!0),setTimeout(()=>g(!1),2e3);return}}catch{}const h=document.createElement("textarea");h.value=t,h.style.position="fixed",h.style.opacity="0",document.body.appendChild(h),h.select();try{document.execCommand("copy"),g(!0),setTimeout(()=>g(!1),2e3)}catch{}document.body.removeChild(h)};return v?e.jsx("p",{className:"text-sm text-text-muted",children:"Loading environments..."}):u?e.jsx("p",{className:"text-sm text-destructive",children:u}):e.jsxs("div",{className:"space-y-8",children:[e.jsx("ul",{className:"space-y-3",children:b.length===0?e.jsx("li",{className:"text-sm text-text-muted",children:"No environments linked to this team yet."}):b.map(t=>{const h=X(t.worker_type);return e.jsxs("li",{className:"text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"font-medium text-text-primary",children:t.machine_name||t.id}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${h.colorClass}`,children:h.shortLabel}),e.jsx(G,{status:t.status}),o&&e.jsx("button",{type:"button",onClick:()=>E(t.id),className:"ml-2 text-xs text-text-muted underline-offset-2 transition-colors hover:text-destructive hover:underline",children:"Unlink"})]}),e.jsxs("div",{className:"mt-1 font-mono text-xs text-text-muted",children:[t.directory||""," ",t.branch?`· ${t.branch}`:""]})]},t.id)})}),o&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-text-muted",children:"Register a new worker to this team:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"rounded-md border border-border bg-surface-2 px-3 py-1.5 font-mono text-xs text-text-primary",children:["slz rc --team-id ",s]}),e.jsx("button",{type:"button",onClick:S,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":"Copy command",children:e.jsx(T,{className:"h-3.5 w-3.5"})}),N&&e.jsx("span",{className:"text-xs text-status-active",children:"Copied"})]})]}),C.length>0&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("p",{className:"text-sm text-text-muted",children:"Link an existing personal environment:"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{value:m,onChange:t=>x(t.target.value),className:"max-w-md rounded-md border border-border bg-surface-2 px-3 py-1.5 text-sm text-text-primary focus:border-accent focus:outline-none",children:[e.jsx("option",{value:"",children:"Select environment..."}),C.map(t=>e.jsxs("option",{value:t.id,children:[t.machine_name||t.id," ",t.branch?`· ${t.branch}`:""]},t.id))]}),e.jsx("button",{type:"button",onClick:k,disabled:!m,className:"rounded-md bg-accent px-3 py-1.5 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:"Link"})]})]}),l&&e.jsx("p",{className:"text-sm text-destructive",children:l})]})]})}async function K(s){try{const o=s.startsWith("team_")?`/web/teams/${s}`:`/web/teams/by-slug/${s}`;return await w("GET",o)}catch{return null}}function ie(){const s=window.location.pathname.split("/"),o=s[s.length-1]||"",[r,j]=a.useState(null),[v,i]=a.useState(!0),[u,d]=a.useState(!1),{members:m,isLoading:x}=_((r==null?void 0:r.id)||null),{user:l}=Q();if(a.useEffect(()=>{o&&(i(!0),K(o).then(c=>{j(c),i(!1)}))},[o]),v)return e.jsx("div",{className:"px-6 py-16 text-sm text-text-muted",children:"Loading..."});if(!r)return e.jsx("div",{className:"px-6 py-16 sm:px-10",children:e.jsxs("div",{className:"max-w-3xl",children:[e.jsx("p",{className:"text-text-muted",children:"Team not found."}),e.jsx("a",{href:"/teams",className:"text-accent hover:underline",children:"Back to teams"})]})});const p=m.find(c=>c.user_id===(l==null?void 0:l.userId)),N=(l==null?void 0:l.role)==="admin"||(p==null?void 0:p.role)==="owner"||(p==null?void 0:p.role)==="admin",g=async()=>{const c=r.id;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(c),d(!0),setTimeout(()=>d(!1),2e3);return}}catch{}const b=document.createElement("textarea");b.value=c,b.style.position="fixed",b.style.opacity="0",document.body.appendChild(b),b.select();try{document.execCommand("copy"),d(!0),setTimeout(()=>d(!1),2e3)}catch{}document.body.removeChild(b)};return e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsxs("header",{className:"mb-16",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:r.name}),e.jsxs("p",{className:"mt-2 font-mono text-xs text-text-muted",children:["/",r.slug]}),r.description&&e.jsx("p",{className:"mt-5 max-w-2xl text-sm leading-relaxed text-text-muted",children:r.description}),e.jsxs("div",{className:"mt-4 flex items-center gap-2",children:[e.jsx("code",{className:"font-mono text-xs text-text-muted",children:r.id}),e.jsx("button",{type:"button",onClick:g,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":"Copy team ID",children:e.jsx(T,{className:"h-3.5 w-3.5"})}),u&&e.jsx("span",{className:"text-xs text-status-active",children:"Copied"}),N&&e.jsx("a",{href:`/teams/${r.slug}/settings`,className:"ml-1 text-text-muted transition-colors hover:text-text-primary","aria-label":"Team settings",title:"Team settings",children:e.jsx(W,{className:"h-4 w-4"})})]})]}),e.jsxs("section",{className:"mb-16",children:[e.jsxs("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:["Members (",m.length,")"]}),x?e.jsx("p",{className:"text-sm text-text-muted",children:"Loading members..."}):e.jsx("ul",{className:"space-y-3",children:m.map(c=>e.jsxs("li",{className:"text-sm",children:[e.jsx("span",{className:"text-text-primary",children:c.username||c.user_id}),e.jsxs("span",{className:"text-text-muted",children:[" (",c.role,") "]}),e.jsx("span",{className:"font-mono text-xs text-text-muted",children:c.user_id})]},c.user_id))})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:"Environments"}),e.jsx(Z,{teamId:r.id,canManage:N})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-6 text-sm font-medium text-text-primary",children:"Invitations"}),e.jsx(V,{teamId:r.id,canManage:N})]})]})}export{ie as TeamDetail};
@@ -0,0 +1 @@
1
+ import{j as e}from"./vendor-DE_-CLIE.js";import{a2 as l,P as a}from"./main-CEsvX5rj.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function c(){const{myTeams:t,isLoading:i}=l();return i?e.jsx("div",{className:"px-6 py-20 sm:px-10",children:e.jsxs("div",{className:"max-w-4xl",children:[e.jsx("div",{className:"h-8 w-32 animate-pulse rounded bg-surface-2"}),e.jsx("div",{className:"mt-12 space-y-10",children:[0,1,2].map(s=>e.jsxs("div",{className:"space-y-3",children:[e.jsx("div",{className:"h-6 w-48 animate-pulse rounded bg-surface-2"}),e.jsx("div",{className:"h-4 w-32 animate-pulse rounded bg-surface-2"})]},s))})]})}):e.jsxs("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:[e.jsxs("header",{className:"mb-16",children:[e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight text-text-primary sm:text-4xl",children:"Teams"}),e.jsx("p",{className:"mt-3 text-sm text-text-muted",children:t.length===0?"Create your first team to start collaborating.":`${t.length} ${t.length===1?"team":"teams"}`})]}),t.length===0?e.jsx("div",{className:"py-8",children:e.jsxs("a",{href:"/teams/new",className:"inline-flex items-center gap-2 rounded-md bg-accent px-5 py-2.5 text-sm font-medium text-white transition-all hover:bg-accent/90 active:translate-y-px",children:[e.jsx(a,{className:"h-4 w-4"}),"Create team"]})}):e.jsx("ul",{className:"space-y-10",children:t.map(s=>e.jsx("li",{children:e.jsxs("a",{href:`/teams/${s.slug}`,className:"group block",children:[e.jsxs("div",{className:"flex items-baseline gap-4",children:[e.jsx("h2",{className:"font-display text-xl font-medium tracking-tight text-text-primary transition-colors group-hover:text-accent",children:s.name}),e.jsxs("span",{className:"font-mono text-xs text-text-muted",children:["/",s.slug]})]}),s.description?e.jsx("p",{className:"mt-2 max-w-2xl text-sm leading-relaxed text-text-muted",children:s.description}):e.jsx("p",{className:"mt-2 text-sm italic text-text-muted/60",children:"No description"})]})},s.id))}),t.length>0&&e.jsx("div",{className:"mt-16",children:e.jsxs("a",{href:"/teams/new",className:"inline-flex items-center gap-2 rounded-md border border-border px-4 py-2 text-sm font-medium text-text-primary transition-all hover:bg-surface-2 active:translate-y-px",children:[e.jsx(a,{className:"h-4 w-4"}),"New team"]})})]})}export{c as TeamList};
@@ -0,0 +1 @@
1
+ import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{l as c}from"./main-CEsvX5rj.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";async function j(s){try{const r=s.startsWith("team_")?`/web/teams/${s}`:`/web/teams/by-slug/${s}`;return await c("GET",r)}catch{return null}}async function w(s,r){await c("PATCH",`/web/teams/${s}`,r)}async function N(s){await c("DELETE",`/web/teams/${s}`)}function k(){const s=window.location.pathname.split("/"),r=s[s.length-2]||"",[a,h]=n.useState(null),[b,y]=n.useState(!0),[i,m]=n.useState(""),[l,d]=n.useState(""),[u,o]=n.useState(null),[x,p]=n.useState(!1);n.useEffect(()=>{r&&j(r).then(t=>{t&&(h(t),m(t.name),d(t.description||"")),y(!1)})},[r]);const g=async t=>{if(t.preventDefault(),!!a){o(null),p(!0);try{await w(a.id,{name:i,description:l}),window.location.href=`/teams/${a.slug}`}catch(f){o(f instanceof Error?f.message:"Failed to update")}finally{p(!1)}}},v=async()=>{if(a&&window.confirm("Delete this team? Environments must be transferred first."))try{await N(a.id),window.location.href="/teams"}catch(t){o(t instanceof Error?t.message:"Failed to delete")}};return b?e.jsx("div",{className:"flex items-center justify-center py-12 text-text-muted",children:"Loading..."}):a?e.jsx("div",{className:"px-6 py-12 sm:px-10 sm:py-16",children:e.jsxs("div",{children:[e.jsxs("header",{className:"mb-12",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:a.name}),e.jsxs("p",{className:"mt-1 font-mono text-xs text-text-muted",children:["/",a.slug]})]}),e.jsxs("form",{onSubmit:g,className:"mb-16 max-w-md space-y-8",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text-primary mb-2",children:"Team Name"}),e.jsx("input",{id:"name",type:"text",required:!0,value:i,onChange:t=>m(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-text-primary mb-2",children:"Description"}),e.jsx("textarea",{id:"description",value:l,onChange:t=>d(t.target.value),className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",rows:3})]}),u&&e.jsx("p",{className:"text-sm text-destructive",children:u}),e.jsxs("div",{className:"flex gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>window.history.back(),className:"rounded-md border border-border px-4 py-2 text-sm text-text-primary hover:bg-surface-2 transition-colors",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:x||!i,className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white hover:bg-accent/90 disabled:opacity-50 transition-colors",children:x?"Saving...":"Save Changes"})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-3 text-sm font-medium text-destructive",children:"Delete team"}),e.jsx("p",{className:"mb-4 text-sm text-text-muted",children:"Deleting a team requires all environments to be transferred first."}),e.jsx("button",{type:"button",onClick:v,className:"rounded-md border border-destructive/60 px-4 py-2 text-sm font-medium text-destructive hover:bg-destructive/10 transition-colors",children:"Delete Team"})]})]})}):e.jsxs("div",{className:"mx-auto max-w-lg px-4 py-8",children:[e.jsx("p",{className:"text-text-muted",children:"Team not found."}),e.jsx("a",{href:"/teams",className:"text-accent hover:underline",children:"Back to teams"})]})}export{k as TeamSettings};
@@ -0,0 +1 @@
1
+ import{e as o,j as e}from"./vendor-DE_-CLIE.js";import{a0 as C,a1 as P,Y as t,W as S}from"./main-CEsvX5rj.js";import{C as k}from"./copy-DdSkINCW.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function L(){const{user:n,logout:f}=C(),w=P(),[l,u]=o.useState(""),[c,m]=o.useState(""),[x,p]=o.useState(""),[h,b]=o.useState(""),[g,a]=o.useState(""),[y,d]=o.useState(!1);if(!n)return null;const j=async()=>{const s=n.userId;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(s),d(!0),setTimeout(()=>d(!1),2e3);return}}catch{}const r=document.createElement("textarea");r.value=s,r.style.position="fixed",r.style.opacity="0",document.body.appendChild(r),r.select();try{document.execCommand("copy"),d(!0),setTimeout(()=>d(!1),2e3)}catch{}document.body.removeChild(r)},N=async s=>{if(s.preventDefault(),a(""),b(""),c.length<8){a(t("auth.setup.passwordTooShort"));return}if(c!==x){a(t("auth.setup.passwordMismatch"));return}try{const r=await fetch("/web/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({currentPassword:l,newPassword:c})});if(!r.ok){const i=await r.json();throw new Error(i.error||t("user.settings.changeFailed"))}b(t("user.settings.passwordChanged")),u(""),m(""),p("")}catch(r){const i=r instanceof Error?r.message:t("user.settings.changeFailed");a(i)}},v=async()=>{try{if(!(await fetch("/web/auth/logout-all",{method:"POST",credentials:"include",headers:{"X-Requested-With":"XMLHttpRequest"}})).ok){a(t("common.error"));return}await f()}catch{a(t("common.error"))}};return e.jsx("div",{className:"px-6 py-16 sm:px-10 sm:py-20",children:e.jsxs("div",{children:[e.jsxs("header",{className:"mb-16",children:[e.jsx("h1",{className:"font-display text-2xl font-semibold tracking-tight text-text-primary",children:n.username}),e.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[e.jsx("code",{className:"font-mono text-xs text-text-muted",children:n.userId}),e.jsx("button",{type:"button",onClick:j,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":"Copy user ID",children:e.jsx(k,{className:"h-3.5 w-3.5"})}),y&&e.jsx("span",{className:"text-xs text-status-active",children:t("share.copied")}),e.jsx("span",{className:"text-text-muted/40",children:"·"}),e.jsx("span",{className:"text-xs text-text-muted",children:n.role})]})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-5 text-sm font-medium text-text-primary",children:t("user.settings.language")}),e.jsxs("select",{value:w,onChange:s=>S(s.target.value),className:"rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-accent focus:outline-none",children:[e.jsx("option",{value:"zh",children:"中文"}),e.jsx("option",{value:"en",children:"English"})]})]}),e.jsxs("section",{className:"mb-16",children:[e.jsx("h2",{className:"mb-5 text-sm font-medium text-text-primary",children:t("user.settings.changePassword")}),e.jsxs("form",{onSubmit:N,className:"max-w-md space-y-6",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-text-primary",children:t("user.settings.currentPassword")}),e.jsx("input",{type:"password",value:l,onChange:s=>u(s.target.value),required:!0,autoComplete:"current-password",className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-text-primary",children:t("user.settings.newPassword")}),e.jsx("input",{type:"password",value:c,onChange:s=>m(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-2 block text-sm font-medium text-text-primary",children:t("user.settings.confirmNewPassword")}),e.jsx("input",{type:"password",value:x,onChange:s=>p(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-md border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none"})]}),g&&e.jsx("p",{className:"text-sm text-status-error",children:g}),h&&e.jsx("p",{className:"text-sm text-status-active",children:h}),e.jsx("div",{className:"pt-2",children:e.jsx("button",{type:"submit",className:"rounded-md bg-accent px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-accent/90",children:t("user.settings.submit")})})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-5 text-sm font-medium text-destructive",children:t("user.settings.logoutAll")}),e.jsx("p",{className:"mb-4 text-sm text-text-muted",children:"Revoke sessions on all devices."}),e.jsx("button",{onClick:v,className:"rounded-md border border-status-error/30 px-4 py-2 text-sm font-medium text-status-error transition-colors hover:bg-status-error/10",children:t("user.settings.logoutAll")})]})]})})}export{L as UserSettings};
@@ -1 +1 @@
1
- import{bl as ln,aO as an,H as z,b8 as w,F as G,ah as un,W as y,bd as tn,b9 as J,aI as _,c as rn,m as o,aG as on,j as sn,d as fn}from"./mermaid.core-C48YvKu4.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,j,I,v,A,H,a){var q=j-l,i=I-h,n=H-v,d=a-A,u=d*q-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*q,h+u*i]}function U(l,h,j,I,v,A,H){var a=l-j,q=h-I,i=(H?A:-A)/J(a*a+q*q),n=i*q,d=-i*a,u=l+n,s=h+d,f=j+n,c=I+d,S=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,D=(g<0?-1:1)*J(on(0,T*T*R-P*P)),E=(P*g-m*D)/R,F=(-P*m-g*D)/R,b=(P*g+m*D)/R,p=(-P*m+g*D)/R,x=E-S,e=F-t,r=b-S,W=p-t;return x*x+e*e>r*r+W*W&&(E=b,F=p),{cx:E,cy:F,x01:-n,y01:-d,x11:E*(v/T-1),y11:F*(v/T-1)}}function hn(){var l=cn,h=yn,j=G(0),I=null,v=gn,A=dn,H=mn,a=null,q=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,S=rn(c-f),t=c>f;if(a||(a=n=q()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(S>tn-y)a.moveTo(s*z(f),s*w(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*z(c),u*w(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=S,D=S,E=H.apply(this,arguments)/2,F=E>y&&(I?+I.apply(this,arguments):J(u*u+s*s)),b=_(rn(s-u)/2,+j.apply(this,arguments)),p=b,x=b,e,r;if(F>y){var W=sn(F/u*w(E)),K=sn(F/s*w(E));(P-=W*2)>y?(W*=t?1:-1,R+=W,T-=W):(P=0,R=T=(f+c)/2),(D-=K*2)>y?(K*=t?1:-1,m+=K,g-=K):(D=0,m=g=(f+c)/2)}var B=s*z(m),C=s*w(m),L=u*z(T),M=u*w(T);if(b>y){var N=s*z(g),Q=s*w(g),V=u*z(R),X=u*w(R),O;if(S<an)if(O=pn(B,C,V,X,N,Q,L,M)){var Y=B-O[0],Z=C-O[1],$=N-O[0],k=Q-O[1],nn=1/w(fn((Y*$+Z*k)/(J(Y*Y+Z*Z)*J($*$+k*k)))/2),en=J(O[0]*O[0]+O[1]*O[1]);p=_(b,(u-en)/(nn-1)),x=_(b,(s-en)/(nn+1))}else p=x=0}D>y?x>y?(e=U(V,X,B,C,s,x,t),r=U(N,Q,L,M,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<b?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(B,C),a.arc(0,0,s,m,g,!t)):a.moveTo(B,C),!(u>y)||!(P>y)?a.lineTo(L,M):p>y?(e=U(L,M,N,Q,u,-p,t),r=U(B,C,V,X,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<b?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[z(d)*n,w(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:G(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:G(+n),i):h},i.cornerRadius=function(n){return arguments.length?(j=typeof n=="function"?n:G(+n),i):j},i.padRadius=function(n){return arguments.length?(I=n==null?null:typeof n=="function"?n:G(+n),i):I},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:G(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:G(+n),i):A},i.padAngle=function(n){return arguments.length?(H=typeof n=="function"?n:G(+n),i):H},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{bl as ln,aO as an,H as z,b8 as w,F as G,ah as un,W as y,bd as tn,b9 as J,aI as _,c as rn,m as o,aG as on,j as sn,d as fn}from"./mermaid.core-BnVRH5R_.js";function cn(l){return l.innerRadius}function yn(l){return l.outerRadius}function gn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,j,I,v,A,H,a){var q=j-l,i=I-h,n=H-v,d=a-A,u=d*q-n*i;if(!(u*u<y))return u=(n*(h-A)-d*(l-v))/u,[l+u*q,h+u*i]}function U(l,h,j,I,v,A,H){var a=l-j,q=h-I,i=(H?A:-A)/J(a*a+q*q),n=i*q,d=-i*a,u=l+n,s=h+d,f=j+n,c=I+d,S=(u+f)/2,t=(s+c)/2,m=f-u,g=c-s,R=m*m+g*g,T=v-A,P=u*c-f*s,D=(g<0?-1:1)*J(on(0,T*T*R-P*P)),E=(P*g-m*D)/R,F=(-P*m-g*D)/R,b=(P*g+m*D)/R,p=(-P*m+g*D)/R,x=E-S,e=F-t,r=b-S,W=p-t;return x*x+e*e>r*r+W*W&&(E=b,F=p),{cx:E,cy:F,x01:-n,y01:-d,x11:E*(v/T-1),y11:F*(v/T-1)}}function hn(){var l=cn,h=yn,j=G(0),I=null,v=gn,A=dn,H=mn,a=null,q=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,S=rn(c-f),t=c>f;if(a||(a=n=q()),s<u&&(d=s,s=u,u=d),!(s>y))a.moveTo(0,0);else if(S>tn-y)a.moveTo(s*z(f),s*w(f)),a.arc(0,0,s,f,c,!t),u>y&&(a.moveTo(u*z(c),u*w(c)),a.arc(0,0,u,c,f,t));else{var m=f,g=c,R=f,T=c,P=S,D=S,E=H.apply(this,arguments)/2,F=E>y&&(I?+I.apply(this,arguments):J(u*u+s*s)),b=_(rn(s-u)/2,+j.apply(this,arguments)),p=b,x=b,e,r;if(F>y){var W=sn(F/u*w(E)),K=sn(F/s*w(E));(P-=W*2)>y?(W*=t?1:-1,R+=W,T-=W):(P=0,R=T=(f+c)/2),(D-=K*2)>y?(K*=t?1:-1,m+=K,g-=K):(D=0,m=g=(f+c)/2)}var B=s*z(m),C=s*w(m),L=u*z(T),M=u*w(T);if(b>y){var N=s*z(g),Q=s*w(g),V=u*z(R),X=u*w(R),O;if(S<an)if(O=pn(B,C,V,X,N,Q,L,M)){var Y=B-O[0],Z=C-O[1],$=N-O[0],k=Q-O[1],nn=1/w(fn((Y*$+Z*k)/(J(Y*Y+Z*Z)*J($*$+k*k)))/2),en=J(O[0]*O[0]+O[1]*O[1]);p=_(b,(u-en)/(nn-1)),x=_(b,(s-en)/(nn+1))}else p=x=0}D>y?x>y?(e=U(V,X,B,C,s,x,t),r=U(N,Q,L,M,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<b?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(B,C),a.arc(0,0,s,m,g,!t)):a.moveTo(B,C),!(u>y)||!(P>y)?a.lineTo(L,M):p>y?(e=U(L,M,N,Q,u,-p,t),r=U(B,C,V,X,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<b?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[z(d)*n,w(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:G(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:G(+n),i):h},i.cornerRadius=function(n){return arguments.length?(j=typeof n=="function"?n:G(+n),i):j},i.padRadius=function(n){return arguments.length?(I=n==null?null:typeof n=="function"?n:G(+n),i):I},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:G(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:G(+n),i):A},i.padAngle=function(n){return arguments.length?(H=typeof n=="function"?n:G(+n),i):H},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};