@saluzi/saluzi-edu 0.2.12 → 0.2.13

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 (167) hide show
  1. package/dist/cli.js +212 -140
  2. package/dist/rcs-web/assets/Dashboard-YYwDrKTN.js +1 -0
  3. package/dist/rcs-web/assets/Join-DKCP5X6X.js +1 -0
  4. package/dist/rcs-web/assets/Login-0VGZs85I.js +1 -0
  5. package/{packages/remote-control-server/web/dist/assets/SessionDetail-DSoMXZJb.js → dist/rcs-web/assets/SessionDetail-DmK-DfBQ.js} +11 -11
  6. package/dist/rcs-web/assets/Setup-C0cjxXMt.js +1 -0
  7. package/dist/rcs-web/assets/{ShareLanding-C06U9Nrr.js → ShareLanding-DUZrreJ7.js} +1 -1
  8. package/dist/rcs-web/assets/TeamCreate-B8ZV6EdY.js +1 -0
  9. package/dist/rcs-web/assets/{TeamDetail-d_GwIRHd.js → TeamDetail-DBAsJ__i.js} +2 -2
  10. package/dist/rcs-web/assets/{TeamList-BlNGdKci.js → TeamList-C-Hte4nV.js} +1 -1
  11. package/dist/rcs-web/assets/{TeamSettings-CPraC9uS.js → TeamSettings-CNVwYwcp.js} +1 -1
  12. package/dist/rcs-web/assets/UserSettings-DRdz9kYE.js +1 -0
  13. package/dist/rcs-web/assets/{arc-BmYza-0n.js → arc-CJxirXEQ.js} +1 -1
  14. package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-CYBtlgdO.js → architectureDiagram-3BPJPVTR-BZvIHrLA.js} +1 -1
  15. package/dist/rcs-web/assets/{blockDiagram-GPEHLZMM-RJAfHk_a.js → blockDiagram-GPEHLZMM-3p0y3Ija.js} +1 -1
  16. package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-CJ-qJA6w.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-Bmz9A1wn.js} +1 -1
  17. package/dist/rcs-web/assets/channel-DaI_n8dp.js +1 -0
  18. package/dist/rcs-web/assets/{chunk-2J33WTMH-n5I6Q1zJ.js → chunk-2J33WTMH-B8gQz22j.js} +1 -1
  19. package/dist/rcs-web/assets/{chunk-4BX2VUAB-CSOBh7qY.js → chunk-4BX2VUAB-CgLEZsTU.js} +1 -1
  20. package/dist/rcs-web/assets/{chunk-55IACEB6-C0euQVm_.js → chunk-55IACEB6-0mdE_-IS.js} +1 -1
  21. package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-Ch7yD8cR.js → dist/rcs-web/assets/chunk-727SXJPM-DdtjnIHR.js} +1 -1
  22. package/{packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-Ms2Q7r6u.js → dist/rcs-web/assets/chunk-AQP2D5EJ-BtwFPk50.js} +1 -1
  23. package/dist/rcs-web/assets/{chunk-FMBD7UC4-bszHUkpx.js → chunk-FMBD7UC4-BcO9mQ0P.js} +1 -1
  24. package/dist/rcs-web/assets/{chunk-ND2GUHAM-BVQIhq6J.js → chunk-ND2GUHAM-BvRq13S_.js} +1 -1
  25. package/dist/rcs-web/assets/{chunk-QZHKN3VN-BVEDe5qc.js → chunk-QZHKN3VN-D7GHkPpq.js} +1 -1
  26. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-pYllpkOq.js +1 -0
  27. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-pYllpkOq.js +1 -0
  28. package/dist/rcs-web/assets/{code-block-IT6T5CEO-B26n-rFC.js → code-block-IT6T5CEO-B1p-vO-3.js} +1 -1
  29. package/{packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-DXc7GE8W.js → dist/rcs-web/assets/cose-bilkent-S5V4N54A-L0rUZuH5.js} +1 -1
  30. package/dist/rcs-web/assets/{dagre-BM42HDAG-DAXofHt_.js → dagre-BM42HDAG-CHGuio22.js} +1 -1
  31. package/dist/rcs-web/assets/{diagram-2AECGRRQ-DK0TBUQA.js → diagram-2AECGRRQ-DIDRyQk8.js} +1 -1
  32. package/dist/rcs-web/assets/{diagram-5GNKFQAL-DMsq-Grp.js → diagram-5GNKFQAL-CNubKb6P.js} +1 -1
  33. package/dist/rcs-web/assets/{diagram-KO2AKTUF-B3FMhmUc.js → diagram-KO2AKTUF-CzQh664-.js} +1 -1
  34. package/dist/rcs-web/assets/{diagram-LMA3HP47-BjO3BHFl.js → diagram-LMA3HP47-CWBR7-VG.js} +1 -1
  35. package/dist/rcs-web/assets/{diagram-OG6HWLK6-CNg4B2L3.js → diagram-OG6HWLK6-BMHdlbcZ.js} +1 -1
  36. package/{packages/remote-control-server/web/dist/assets/erDiagram-TEJ5UH35-BDxz8NRK.js → dist/rcs-web/assets/erDiagram-TEJ5UH35-OgT8dC-K.js} +1 -1
  37. package/{packages/remote-control-server/web/dist/assets/flowDiagram-I6XJVG4X-VIgM13sK.js → dist/rcs-web/assets/flowDiagram-I6XJVG4X-DRrCY2oB.js} +1 -1
  38. package/dist/rcs-web/assets/{ganttDiagram-6RSMTGT7-Ba2QuJU0.js → ganttDiagram-6RSMTGT7-DctpzEKN.js} +1 -1
  39. package/dist/rcs-web/assets/{gitGraphDiagram-PVQCEYII-B-gV-lAg.js → gitGraphDiagram-PVQCEYII-5KpLszm9.js} +1 -1
  40. package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-DothwgD4.js → infoDiagram-5YYISTIA-BAKD_Tt7.js} +1 -1
  41. package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-DhpjM1Vc.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-VHOPG4Nc.js} +1 -1
  42. package/dist/rcs-web/assets/{journeyDiagram-JHISSGLW-PbQTouMJ.js → journeyDiagram-JHISSGLW-BtGih-ik.js} +1 -1
  43. package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-63WdwG-X.js → kanban-definition-UN3LZRKU-BsEGZsD1.js} +1 -1
  44. package/dist/rcs-web/assets/{linear-CeRljV9s.js → linear-Dj636PNG.js} +1 -1
  45. package/dist/rcs-web/assets/main-CkqtCllF.js +238 -0
  46. package/dist/rcs-web/assets/{mermaid-VLURNSYL-CG6yNR7g.js → mermaid-VLURNSYL-DutpHHm9.js} +4 -4
  47. package/dist/rcs-web/assets/{mermaid.core-CAuNNATY.js → mermaid.core-XHHf0pen.js} +5 -5
  48. package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-9hDL1CUV.js → mindmap-definition-RKZ34NQL-BBa8V_3g.js} +1 -1
  49. package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-BS_P2t04.js → pieDiagram-4H26LBE5-BuNEdo9H.js} +1 -1
  50. package/dist/rcs-web/assets/{quadrantDiagram-W4KKPZXB-Cp9QQkHV.js → quadrantDiagram-W4KKPZXB-CsJgyQIN.js} +1 -1
  51. package/dist/rcs-web/assets/{requirementDiagram-4Y6WPE33-C_XSzOKE.js → requirementDiagram-4Y6WPE33-DqMJZ914.js} +1 -1
  52. package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-BhuVqzZd.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-CVsz09q2.js} +1 -1
  53. package/{packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-C3IPZrcW.js → dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-BRp4Wddn.js} +1 -1
  54. package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-CN4iNPRl.js → stateDiagram-AJRCARHV-S-QqQr-D.js} +1 -1
  55. package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-CICBlDSJ.js → stateDiagram-v2-BHNVJYJU-D77KfDr-.js} +1 -1
  56. package/{packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-Be7t_3rC.js → dist/rcs-web/assets/timeline-definition-PNZ67QCA-De8bFWnE.js} +1 -1
  57. package/dist/rcs-web/assets/{useTeams-DPHGnBHL.js → useTeams-CqJOqEy1.js} +1 -1
  58. package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-CSaUc2Xv.js → vennDiagram-CIIHVFJN-Dikwrn1L.js} +1 -1
  59. package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-DTuJrl9P.js → wardleyDiagram-YWT4CUSO-DUzpiV6H.js} +1 -1
  60. package/dist/rcs-web/assets/{workerType-CSqeySYe.js → workerType-DOQ0AHrq.js} +1 -1
  61. package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-BQ0oU3Qi.js → xychartDiagram-2RQKCTM6-OZNbB32D.js} +1 -1
  62. package/dist/rcs-web/index.html +1 -1
  63. package/package.json +2 -2
  64. package/packages/remote-control-server/src/__tests__/cookie.test.ts +0 -71
  65. package/packages/remote-control-server/src/__tests__/data-layer-round2.test.ts +556 -0
  66. package/packages/remote-control-server/src/__tests__/route-mounting.test.ts +212 -0
  67. package/packages/remote-control-server/src/__tests__/routes.test.ts +5 -44
  68. package/packages/remote-control-server/src/__tests__/security-fixes.test.ts +526 -0
  69. package/packages/remote-control-server/src/__tests__/security-round3.test.ts +780 -0
  70. package/packages/remote-control-server/src/__tests__/shares.test.ts +5 -2
  71. package/packages/remote-control-server/src/auth/constants.ts +0 -6
  72. package/packages/remote-control-server/src/auth/cookie.ts +0 -43
  73. package/packages/remote-control-server/src/auth/csrf.ts +58 -0
  74. package/packages/remote-control-server/src/auth/middleware.ts +7 -4
  75. package/packages/remote-control-server/src/index.ts +26 -0
  76. package/packages/remote-control-server/src/registerRoutes.ts +17 -1
  77. package/packages/remote-control-server/src/routes/web/auth-routes.ts +93 -54
  78. package/packages/remote-control-server/src/routes/web/auth.ts +16 -23
  79. package/packages/remote-control-server/src/routes/web/sessions.ts +30 -5
  80. package/packages/remote-control-server/src/routes/web/shares.ts +38 -1
  81. package/packages/remote-control-server/src/routes/web/teams.ts +22 -4
  82. package/packages/remote-control-server/src/services/session.ts +143 -9
  83. package/packages/remote-control-server/src/store.ts +34 -1
  84. package/packages/remote-control-server/src/types/api.ts +0 -1
  85. package/packages/remote-control-server/web/dist/assets/Dashboard-YYwDrKTN.js +1 -0
  86. package/packages/remote-control-server/web/dist/assets/Join-DKCP5X6X.js +1 -0
  87. package/packages/remote-control-server/web/dist/assets/Login-0VGZs85I.js +1 -0
  88. package/{dist/rcs-web/assets/SessionDetail-DSoMXZJb.js → packages/remote-control-server/web/dist/assets/SessionDetail-DmK-DfBQ.js} +11 -11
  89. package/packages/remote-control-server/web/dist/assets/Setup-C0cjxXMt.js +1 -0
  90. package/packages/remote-control-server/web/dist/assets/{ShareLanding-C06U9Nrr.js → ShareLanding-DUZrreJ7.js} +1 -1
  91. package/packages/remote-control-server/web/dist/assets/TeamCreate-B8ZV6EdY.js +1 -0
  92. package/packages/remote-control-server/web/dist/assets/{TeamDetail-d_GwIRHd.js → TeamDetail-DBAsJ__i.js} +2 -2
  93. package/packages/remote-control-server/web/dist/assets/{TeamList-BlNGdKci.js → TeamList-C-Hte4nV.js} +1 -1
  94. package/packages/remote-control-server/web/dist/assets/{TeamSettings-CPraC9uS.js → TeamSettings-CNVwYwcp.js} +1 -1
  95. package/packages/remote-control-server/web/dist/assets/UserSettings-DRdz9kYE.js +1 -0
  96. package/packages/remote-control-server/web/dist/assets/{arc-BmYza-0n.js → arc-CJxirXEQ.js} +1 -1
  97. package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-CYBtlgdO.js → architectureDiagram-3BPJPVTR-BZvIHrLA.js} +1 -1
  98. package/packages/remote-control-server/web/dist/assets/{blockDiagram-GPEHLZMM-RJAfHk_a.js → blockDiagram-GPEHLZMM-3p0y3Ija.js} +1 -1
  99. package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-CJ-qJA6w.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-Bmz9A1wn.js} +1 -1
  100. package/packages/remote-control-server/web/dist/assets/channel-DaI_n8dp.js +1 -0
  101. package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-n5I6Q1zJ.js → chunk-2J33WTMH-B8gQz22j.js} +1 -1
  102. package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-CSOBh7qY.js → chunk-4BX2VUAB-CgLEZsTU.js} +1 -1
  103. package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-C0euQVm_.js → chunk-55IACEB6-0mdE_-IS.js} +1 -1
  104. package/{dist/rcs-web/assets/chunk-727SXJPM-Ch7yD8cR.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-DdtjnIHR.js} +1 -1
  105. package/{dist/rcs-web/assets/chunk-AQP2D5EJ-Ms2Q7r6u.js → packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-BtwFPk50.js} +1 -1
  106. package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-bszHUkpx.js → chunk-FMBD7UC4-BcO9mQ0P.js} +1 -1
  107. package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-BVQIhq6J.js → chunk-ND2GUHAM-BvRq13S_.js} +1 -1
  108. package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-BVEDe5qc.js → chunk-QZHKN3VN-D7GHkPpq.js} +1 -1
  109. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-pYllpkOq.js +1 -0
  110. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-pYllpkOq.js +1 -0
  111. package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-B26n-rFC.js → code-block-IT6T5CEO-B1p-vO-3.js} +1 -1
  112. package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-DXc7GE8W.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-L0rUZuH5.js} +1 -1
  113. package/packages/remote-control-server/web/dist/assets/{dagre-BM42HDAG-DAXofHt_.js → dagre-BM42HDAG-CHGuio22.js} +1 -1
  114. package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-DK0TBUQA.js → diagram-2AECGRRQ-DIDRyQk8.js} +1 -1
  115. package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-DMsq-Grp.js → diagram-5GNKFQAL-CNubKb6P.js} +1 -1
  116. package/packages/remote-control-server/web/dist/assets/{diagram-KO2AKTUF-B3FMhmUc.js → diagram-KO2AKTUF-CzQh664-.js} +1 -1
  117. package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-BjO3BHFl.js → diagram-LMA3HP47-CWBR7-VG.js} +1 -1
  118. package/packages/remote-control-server/web/dist/assets/{diagram-OG6HWLK6-CNg4B2L3.js → diagram-OG6HWLK6-BMHdlbcZ.js} +1 -1
  119. package/{dist/rcs-web/assets/erDiagram-TEJ5UH35-BDxz8NRK.js → packages/remote-control-server/web/dist/assets/erDiagram-TEJ5UH35-OgT8dC-K.js} +1 -1
  120. package/{dist/rcs-web/assets/flowDiagram-I6XJVG4X-VIgM13sK.js → packages/remote-control-server/web/dist/assets/flowDiagram-I6XJVG4X-DRrCY2oB.js} +1 -1
  121. package/packages/remote-control-server/web/dist/assets/{ganttDiagram-6RSMTGT7-Ba2QuJU0.js → ganttDiagram-6RSMTGT7-DctpzEKN.js} +1 -1
  122. package/packages/remote-control-server/web/dist/assets/{gitGraphDiagram-PVQCEYII-B-gV-lAg.js → gitGraphDiagram-PVQCEYII-5KpLszm9.js} +1 -1
  123. package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-DothwgD4.js → infoDiagram-5YYISTIA-BAKD_Tt7.js} +1 -1
  124. package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-DhpjM1Vc.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-VHOPG4Nc.js} +1 -1
  125. package/packages/remote-control-server/web/dist/assets/{journeyDiagram-JHISSGLW-PbQTouMJ.js → journeyDiagram-JHISSGLW-BtGih-ik.js} +1 -1
  126. package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-63WdwG-X.js → kanban-definition-UN3LZRKU-BsEGZsD1.js} +1 -1
  127. package/packages/remote-control-server/web/dist/assets/{linear-CeRljV9s.js → linear-Dj636PNG.js} +1 -1
  128. package/packages/remote-control-server/web/dist/assets/main-CkqtCllF.js +238 -0
  129. package/packages/remote-control-server/web/dist/assets/{mermaid-VLURNSYL-CG6yNR7g.js → mermaid-VLURNSYL-DutpHHm9.js} +4 -4
  130. package/packages/remote-control-server/web/dist/assets/{mermaid.core-CAuNNATY.js → mermaid.core-XHHf0pen.js} +5 -5
  131. package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-9hDL1CUV.js → mindmap-definition-RKZ34NQL-BBa8V_3g.js} +1 -1
  132. package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-BS_P2t04.js → pieDiagram-4H26LBE5-BuNEdo9H.js} +1 -1
  133. package/packages/remote-control-server/web/dist/assets/{quadrantDiagram-W4KKPZXB-Cp9QQkHV.js → quadrantDiagram-W4KKPZXB-CsJgyQIN.js} +1 -1
  134. package/packages/remote-control-server/web/dist/assets/{requirementDiagram-4Y6WPE33-C_XSzOKE.js → requirementDiagram-4Y6WPE33-DqMJZ914.js} +1 -1
  135. package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-BhuVqzZd.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-CVsz09q2.js} +1 -1
  136. package/{dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-C3IPZrcW.js → packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-BRp4Wddn.js} +1 -1
  137. package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-CN4iNPRl.js → stateDiagram-AJRCARHV-S-QqQr-D.js} +1 -1
  138. package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-CICBlDSJ.js → stateDiagram-v2-BHNVJYJU-D77KfDr-.js} +1 -1
  139. package/{dist/rcs-web/assets/timeline-definition-PNZ67QCA-Be7t_3rC.js → packages/remote-control-server/web/dist/assets/timeline-definition-PNZ67QCA-De8bFWnE.js} +1 -1
  140. package/packages/remote-control-server/web/dist/assets/{useTeams-DPHGnBHL.js → useTeams-CqJOqEy1.js} +1 -1
  141. package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-CSaUc2Xv.js → vennDiagram-CIIHVFJN-Dikwrn1L.js} +1 -1
  142. package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-DTuJrl9P.js → wardleyDiagram-YWT4CUSO-DUzpiV6H.js} +1 -1
  143. package/packages/remote-control-server/web/dist/assets/{workerType-CSqeySYe.js → workerType-DOQ0AHrq.js} +1 -1
  144. package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-BQ0oU3Qi.js → xychartDiagram-2RQKCTM6-OZNbB32D.js} +1 -1
  145. package/packages/remote-control-server/web/dist/index.html +1 -1
  146. package/dist/rcs-web/assets/Dashboard-D_Im4UId.js +0 -1
  147. package/dist/rcs-web/assets/Join-BTnvMsB9.js +0 -1
  148. package/dist/rcs-web/assets/Login-ClT7RckC.js +0 -1
  149. package/dist/rcs-web/assets/Setup-PaDA6Et-.js +0 -1
  150. package/dist/rcs-web/assets/TeamCreate-249rK3U3.js +0 -1
  151. package/dist/rcs-web/assets/UserSettings-X627Fdni.js +0 -1
  152. package/dist/rcs-web/assets/channel-BUwWbT6U.js +0 -1
  153. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DYtx22zv.js +0 -1
  154. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DYtx22zv.js +0 -1
  155. package/dist/rcs-web/assets/i18n-Dbt-vEQ3.js +0 -1
  156. package/dist/rcs-web/assets/main-DvfxciBy.js +0 -238
  157. package/packages/remote-control-server/web/dist/assets/Dashboard-D_Im4UId.js +0 -1
  158. package/packages/remote-control-server/web/dist/assets/Join-BTnvMsB9.js +0 -1
  159. package/packages/remote-control-server/web/dist/assets/Login-ClT7RckC.js +0 -1
  160. package/packages/remote-control-server/web/dist/assets/Setup-PaDA6Et-.js +0 -1
  161. package/packages/remote-control-server/web/dist/assets/TeamCreate-249rK3U3.js +0 -1
  162. package/packages/remote-control-server/web/dist/assets/UserSettings-X627Fdni.js +0 -1
  163. package/packages/remote-control-server/web/dist/assets/channel-BUwWbT6U.js +0 -1
  164. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DYtx22zv.js +0 -1
  165. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DYtx22zv.js +0 -1
  166. package/packages/remote-control-server/web/dist/assets/i18n-Dbt-vEQ3.js +0 -1
  167. package/packages/remote-control-server/web/dist/assets/main-DvfxciBy.js +0 -238
@@ -0,0 +1 @@
1
+ import{j as e,e as d}from"./vendor-DE_-CLIE.js";import{h as N,B as w,Q as v,I as s,l as k,n as C,o as S,m as _}from"./main-CkqtCllF.js";import{g as y,D,a as L,c as E,d as B,b as M}from"./workerType-DOQ0AHrq.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function T({environments:l,onSelectEnvironment:x}){return!l||l.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:l.map(a=>{const i=a.worker_type==="acp",c=y(a.worker_type),u=c.fullLabel,t=c.colorClass;return e.jsxs("button",{type:"button",onClick:()=>x==null?void 0:x(a),disabled:i,className:`flex w-full items-center justify-between rounded-xl border border-border bg-surface-1 px-4 py-3 text-left transition-colors ${i?"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:a.machine_name||a.id}),e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${t}`,children:u})]}),e.jsx("div",{className:"text-sm text-text-muted",children:a.directory||""})]})}),e.jsxs("div",{className:"text-right",children:[e.jsx(N,{status:a.status}),e.jsx("div",{className:"mt-1 text-xs text-text-muted",children:a.branch||""})]})]},a.id)})})}function F({sessions:l,environments:x,onSelect:a,onDelete:i}){if(!l||l.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 c=new Map;for(const t of x??[])t!=null&&t.id&&t.worker_type&&c.set(t.id,t.worker_type);const u=[...l].sort((t,n)=>(n.updated_at||0)-(t.updated_at||0));return e.jsx("div",{className:"space-y-2",children:u.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:()=>a(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}),(()=>{var h;let n=t.source==="acp"?"acp":(h=t.environment)==null?void 0:h.worker_type;!n&&t.environment_id&&(n=c.get(t.environment_id));const p=y(n);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${p.colorClass}`,children:p.fullLabel})})()]}),e.jsx("div",{className:"truncate text-xs text-text-muted",children:t.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:w(t.created_at||t.updated_at)}),i&&e.jsx("button",{type:"button",onClick:n=>{n.stopPropagation(),i(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 I({open:l,environments:x,onClose:a,onCreated:i}){v();const[c,u]=d.useState(""),[t,n]=d.useState(""),[p,h]=d.useState("same-dir"),[f,b]=d.useState(""),[o,m]=d.useState(!1);d.useEffect(()=>{l&&(u(""),n(""),h("same-dir"),b(""))},[l]);const g=async()=>{m(!0),b("");try{const r={};c.trim()&&(r.title=c.trim()),t&&(r.environment_id=t),r.spawn_mode=p;const j=await k(r);i(j)}catch(r){b(r instanceof Error?r.message:s("dialog.createFailed"))}finally{m(!1)}};return e.jsx(D,{open:l,onOpenChange:r=>{r||a()},children:e.jsxs(L,{className:"max-w-md rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(E,{children:e.jsx(B,{className:"font-display text-lg font-semibold text-text-primary",children:s("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:s("dialog.titleOptional")}),e.jsx("input",{type:"text",value:c,onChange:r=>u(r.target.value),placeholder:s("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:s("dialog.environment")}),e.jsxs("select",{value:t,onChange:r=>n(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:s("dialog.none")}),x.map(r=>{const j=y(r.worker_type).shortLabel;return e.jsxs("option",{value:r.id,children:[r.machine_name||r.id," (",r.branch||s("dialog.noBranch"),") · ",j]},r.id)})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:s("dialog.workspaceMode")}),e.jsxs("select",{value:p,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:"same-dir",children:s("dialog.sameDir")}),e.jsx("option",{value:"worktree",children:s("dialog.worktree")})]})]}),f&&e.jsx("div",{className:"text-sm text-status-error",children:f})]}),e.jsxs(M,{children:[e.jsx("button",{onClick:a,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:s("common.cancel")}),e.jsx("button",{onClick:g,disabled:o,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:o?s("common.creating"):s("common.create")})]})]})})}function H({onNavigateSession:l}){v();const[x,a]=d.useState([]),[i,c]=d.useState([]),[u,t]=d.useState(!1),n=d.useCallback(async()=>{try{const[o,m]=await Promise.all([C(),S()]);a(o||[]),c(m||[])}catch(o){console.error("Dashboard render error:",o)}},[]);d.useEffect(()=>{n();const o=setInterval(n,1e4);return()=>clearInterval(o)},[n]);const p=o=>{t(!1),l(o.id)},h=d.useCallback(o=>{},[]),f=d.useCallback(o=>{l(o)},[l]),b=d.useCallback(async o=>{if(window.confirm(s("dashboard.confirmDelete").replace("{id}",o)))try{await _(o),a(m=>m.filter(g=>g.id!==o))}catch(m){alert(m instanceof Error?m.message:s("dashboard.deleteFailed"))}},[]);return e.jsxs("div",{className:"mx-auto max-w-5xl px-4 py-8",children:[e.jsx("h1",{className:"sr-only",children:s("dashboard.title")}),e.jsxs("section",{className:"mb-10",children:[e.jsx("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:s("dashboard.environments")}),e.jsx(T,{environments:i,onSelectEnvironment:h})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"font-display text-lg font-semibold text-text-primary",children:s("dashboard.sessions")}),e.jsx("button",{onClick:()=>t(!0),className:"rounded-lg bg-brand px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:s("dashboard.newSession")})]}),e.jsx(F,{sessions:x,environments:i,onSelect:f,onDelete:b})]}),e.jsx(I,{open:u,environments:i,onClose:()=>t(!1),onCreated:p})]})}export{H as Dashboard};
@@ -0,0 +1 @@
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{N,I as t}from"./main-CkqtCllF.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function E({onSuccess:b,onInvalidInvite:l}){const{join:h}=N(),[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{N as b,I as t}from"./main-CkqtCllF.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function j({onSuccess:d}){const{login:c}=b(),[a,m]=r.useState(""),[o,x]=r.useState(""),[l,n]=r.useState(""),[i,u]=r.useState(!1),p=async s=>{s.preventDefault(),n(""),u(!0);try{await c(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:p,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=>m(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=>x(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")})]})]})})}export{j as Login};
@@ -1,50 +1,50 @@
1
- var ae=Object.defineProperty;var oe=(s,t,n)=>t in s?ae(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var S=(s,t,n)=>oe(s,typeof t!="symbol"?t+"":t,n);import{e as g,j as e}from"./vendor-DE_-CLIE.js";import{y as $,l as ie,r as le,v as ce,F as de,u as I,s as ue,h as J,E as K,L as Y,j as me,S as xe,B as E,x as P,d as pe,I as he,A as fe,G as ye,J as ge,z as be,n as je,i as G,c as we,C as Ne,q as ke,H as ve,D as _e,a as Se}from"./main-DvfxciBy.js";import{D as Ce,a as Me,c as Ee,d as $e,g as Ae}from"./workerType-CSqeySYe.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";/**
1
+ var oe=Object.defineProperty;var ie=(s,t,n)=>t in s?oe(s,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[t]=n;var C=(s,t,n)=>ie(s,typeof t!="symbol"?t+"":t,n);import{e as g,j as e}from"./vendor-DE_-CLIE.js";import{x as A,q as le,u as ce,E as de,t as P,r as ue,h as J,B as Y,L as G,j as me,S as xe,z as $,w as D,d as pe,J as he,A as fe,F as ye,Q as ge,K as be,y as je,I as _,m as we,i as X,c as Ne,C as ke,p as ve,G as _e,D as Se,a as Ce}from"./main-CkqtCllF.js";import{D as Me,a as Ee,c as $e,d as Ae,g as Te}from"./workerType-DOQ0AHrq.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.
5
5
  * See the LICENSE file in the root directory of this source tree.
6
- */const Te=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Ie=$("activity",Te);/**
6
+ */const Ie=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],Pe=A("activity",Ie);/**
7
7
  * @license lucide-react v0.555.0 - ISC
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 Pe=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],qe=$("chevron-right",Pe);/**
11
+ */const De=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],qe=A("chevron-right",De);/**
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 De=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],z=$("clock",De);/**
16
+ */const Re=[["path",{d:"M12 6v6l4 2",key:"mmk7yg"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],L=A("clock",Re);/**
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 Re=[["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"}]],Ue=$("cpu",Re);/**
21
+ */const Ue=[["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"}]],Fe=A("cpu",Ue);/**
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 Fe=[["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"}]],Oe=$("hash",Fe);/**
26
+ */const Oe=[["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"}]],He=A("hash",Oe);/**
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 He=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Be=$("info",He);/**
31
+ */const ze=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Be=A("info",ze);/**
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 ze=[["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"}]],Le=$("play",ze);/**
36
+ */const Le=[["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"}]],Qe=A("play",Le);/**
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 Qe=[["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"}]],Ve=$("server-cog",Qe);/**
41
+ */const Ve=[["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"}]],Ke=A("server-cog",Ve);/**
42
42
  * @license lucide-react v0.555.0 - ISC
43
43
  *
44
44
  * This source code is licensed under the ISC license.
45
45
  * See the LICENSE file in the root directory of this source tree.
46
- */const We=[["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"}]],Je=$("triangle-alert",We);function X(){return{tasks:{}}}const L=3e4;function U(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 Ke(s,t){var p,u,m,l,i,o,x,h,f,y,b,j;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(),a=s.tasks[r];if(n==="task_started"){if(a)return{tasks:{...s.tasks,[r]:{...a,description:t.description??a.description,name:U(t.description??a.description),taskType:t.task_type??a.taskType,workflowName:t.workflow_name??a.workflowName,prompt:t.prompt??a.prompt,toolUseId:t.tool_use_id??a.toolUseId,status:"running",startTime:c,evictAfter:void 0}}};const w=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:U(w),description:w,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(!a){const w=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:U(w),description:w,toolUseId:t.tool_use_id,status:"running",startTime:c,tokenCount:(p=t.usage)==null?void 0:p.total_tokens,toolUseCount:(u=t.usage)==null?void 0:u.tool_uses,durationMs:(m=t.usage)==null?void 0:m.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[r]:{...a,description:t.description??a.description,tokenCount:((l=t.usage)==null?void 0:l.total_tokens)??a.tokenCount,toolUseCount:((i=t.usage)==null?void 0:i.tool_uses)??a.toolUseCount,durationMs:((o=t.usage)==null?void 0:o.duration_ms)??a.durationMs,lastToolName:t.last_tool_name??a.lastToolName,summary:t.summary??a.summary}}}}return a?{tasks:{...s.tasks,[r]:{...a,status:t.status??"completed",endTime:c,finalSummary:t.summary??a.finalSummary,outputFile:t.output_file??a.outputFile,tokenCount:((y=t.usage)==null?void 0:y.total_tokens)??a.tokenCount,toolUseCount:((b=t.usage)==null?void 0:b.tool_uses)??a.toolUseCount,durationMs:((j=t.usage)==null?void 0:j.duration_ms)??a.durationMs,evictAfter:c+L}}}:{tasks:{...s.tasks,[r]:{taskId:r,name:U(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:c,endTime:c,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(x=t.usage)==null?void 0:x.total_tokens,toolUseCount:(h=t.usage)==null?void 0:h.tool_uses,durationMs:(f=t.usage)==null?void 0:f.duration_ms,evictAfter:c+L}}}}function Ye(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 Ge{constructor(){S(this,"listeners",new Set);S(this,"eventSource",null);S(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 a=JSON.parse(c.data);if(a.seqNum!==void 0&&a.seqNum<=this._lastSeqNum)return;a.seqNum!==void 0&&(this._lastSeqNum=a.seqNum);for(const p of this.listeners)p(a)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const O=new Ge;function Q(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 V(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 Xe{constructor(t,n,r){S(this,"sessionId");S(this,"setEntries");S(this,"unsub",null);S(this,"onStatusChange");S(this,"onError");S(this,"onPermissionRequest");S(this,"onModelsStateChange");S(this,"onSubagentUpdate");S(this,"subagentState",X());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(){try{await ie(this.sessionId)}catch{}await this.loadHistory(),this.connectSSE()}async loadHistory(){var p;const{events:t}=await le(this.sessionId);if(!t||t.length===0)return;const n=[];let r=null;const c=()=>{r&&(n.push(r),r=null)};for(const u of t){const m=u.payload||{};if(u.type==="user"){if(u.direction==="inbound")continue;c();const l=Q(m);l&&n.push({type:"user_message",id:u.id||`hist-user-${n.length}`,content:l})}else if(u.type==="assistant"){c();const l=Q(m),i=[],o=m.message;if(o&&typeof o=="object"&&Array.isArray(o.content))for(const x of o.content)x.type==="tool_use"&&i.push({type:"tool_call",toolCall:{id:x.id||`hist-tool-${n.length}`,title:x.name||"tool",status:"complete",rawInput:x.input||{}}});if(l||i.length>0){r={type:"assistant_message",id:u.id||`hist-asst-${n.length}`,chunks:l?[{type:"message",text:l}]:[]},n.push(r);for(const x of i)n.push(x);r=null}}else if(u.type==="tool_use"){const l=m,i={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(i)}else if(u.type==="tool_result"){const l=m,i=V(n,l.tool_call_id||"");if(i>=0){const o=n[i];n[i]={type:"tool_call",toolCall:{...o.toolCall,rawOutput:{output:l.content||l.output||""}}}}}}c(),this.setEntries(n);let a=null;for(const u of t){if(u.type!=="models_state")continue;const m=u.payload||{},l=m.raw,i=l&&typeof l=="object"?l.models_state:m.models_state;i&&Array.isArray(i.availableModels)&&typeof i.currentModelId=="string"&&(a=i)}a&&((p=this.onModelsStateChange)==null||p.call(this,a))}connectSSE(){O.connect(this.sessionId),this.unsub=O.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),O.disconnect()}handleEvent(t){var a,p,u,m,l;const n=t.type,r=t.payload||{},c=JSON.stringify(t);if(!/Remote Control connecting/i.test(c))switch(n){case"assistant":{const i=typeof r.content=="string"?r.content:"";this.setEntries(x=>{const h=x[x.length-1];if((h==null?void 0:h.type)==="assistant_message"){const f=h.chunks[h.chunks.length-1];return(f==null?void 0:f.type)==="message"?[...x.slice(0,-1),{...h,chunks:[...h.chunks.slice(0,-1),{type:"message",text:f.text+i}]}]:[...x.slice(0,-1),{...h,chunks:[...h.chunks,{type:"message",text:i}]}]}if(i&&i.trim()){const f={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:i}]};return[...x,f]}return x});const o=r.message;if(o&&typeof o=="object"&&Array.isArray(o.content)){const x=o.content.filter(h=>h.type==="tool_use");for(const h of x){const y={id:h.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`,title:h.name||"tool",status:"running",rawInput:h.input||{}};this.setEntries(b=>[...b,{type:"tool_call",toolCall:y}])}}break}case"tool_use":{const i=r,x={id:i.tool_call_id||`call-${Date.now()}`,title:i.tool_name||"tool",status:"running",rawInput:i.tool_input||{}};this.setEntries(h=>[...h,{type:"tool_call",toolCall:x}]);break}case"tool_result":{const i=r,o=i.tool_call_id||"";this.setEntries(x=>{const h=V(x,o);if(h<0)return x;const f=x[h];return x.map((y,b)=>b===h?{type:"tool_call",toolCall:{...f.toolCall,status:"complete",rawOutput:{output:i.content||i.output||""}}}:y)});break}case"control_request":case"permission_request":{const i=r.request;if(i&&i.subtype==="can_use_tool"){const o=r.request_id||"",x=i.tool_name||"unknown",h=i.input||i.tool_input||{},f=i.description||"";this.setEntries(y=>{const b=[...y].reverse().findIndex(j=>j.type==="tool_call");if(b>=0){const j=y.length-1-b,w=y[j];if(w.toolCall.status==="running")return y.map((C,A)=>A===j?{type:"tool_call",toolCall:{...w.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:o,options:[]}}}:C)}return y}),(a=this.onPermissionRequest)==null||a.call(this,{requestId:o,toolName:x,toolInput:h,description:f})}break}case"session_status":{typeof r.status=="string"&&((p=this.onStatusChange)==null||p.call(this,r.status));break}case"error":{const i=String(r.message||r.content||"Unknown error");(u=this.onError)==null||u.call(this,i);break}case"models_state":{const i=r.raw,o=typeof i=="object"&&i!==null?i.models_state:r.models_state;o&&Array.isArray(o.availableModels)&&typeof o.currentModelId=="string"&&((m=this.onModelsStateChange)==null||m.call(this,o));break}case"system":{const i=r.raw,o=i&&typeof i=="object"?i:r,x=typeof o.subtype=="string"?o.subtype:void 0;if(x==="task_started"||x==="task_progress"||x==="task_notification"){const h={subtype:x,task_id:typeof o.task_id=="string"?o.task_id:void 0,tool_use_id:typeof o.tool_use_id=="string"?o.tool_use_id:void 0,description:typeof o.description=="string"?o.description:void 0,task_type:typeof o.task_type=="string"?o.task_type:void 0,workflow_name:typeof o.workflow_name=="string"?o.workflow_name:void 0,prompt:typeof o.prompt=="string"?o.prompt:void 0,usage:o.usage&&typeof o.usage=="object"?o.usage:void 0,last_tool_name:typeof o.last_tool_name=="string"?o.last_tool_name:void 0,summary:typeof o.summary=="string"?o.summary:void 0,status:o.status==="completed"||o.status==="failed"||o.status==="stopped"?o.status:void 0,output_file:typeof o.output_file=="string"?o.output_file:void 0};this.subagentState=Ke(this.subagentState,h),(l=this.onSubagentUpdate)==null||l.call(this,this.subagentState)}break}}}async sendMessage(t,n,r){const c=n&&n.length>0,a=r&&r.length>0;if(!t.trim()&&!c&&!a)return;const p={type:"user_message",id:`user-${Date.now()}`,content:t,images:c?n:void 0,attachments:a?r:void 0};this.setEntries(l=>[...l,p]);const u=[];if(t&&u.push({type:"text",text:t}),c)for(const l of n)u.push({type:"image",source:{type:"base64",media_type:l.mimeType,data:l.data}});if(a){for(const l of r)if(l.kind==="text"||l.kind==="table"){const i=`📎 ${l.name}${l.size!=null?` (${Ze(l.size)})`:""}`,o=l.textContent||"(空文件)";u.push({type:"text",text:`${i}
46
+ */const We=[["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"}]],Je=A("triangle-alert",We);function Z(){return{tasks:{}}}const Q=3e4;function F(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 Ye(s,t){var p,u,m,l,i,o,x,h,f,y,b,j;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(),a=s.tasks[r];if(n==="task_started"){if(a)return{tasks:{...s.tasks,[r]:{...a,description:t.description??a.description,name:F(t.description??a.description),taskType:t.task_type??a.taskType,workflowName:t.workflow_name??a.workflowName,prompt:t.prompt??a.prompt,toolUseId:t.tool_use_id??a.toolUseId,status:"running",startTime:c,evictAfter:void 0}}};const w=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:F(w),description:w,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(!a){const w=t.description??"";return{tasks:{...s.tasks,[r]:{taskId:r,name:F(w),description:w,toolUseId:t.tool_use_id,status:"running",startTime:c,tokenCount:(p=t.usage)==null?void 0:p.total_tokens,toolUseCount:(u=t.usage)==null?void 0:u.tool_uses,durationMs:(m=t.usage)==null?void 0:m.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...s.tasks,[r]:{...a,description:t.description??a.description,tokenCount:((l=t.usage)==null?void 0:l.total_tokens)??a.tokenCount,toolUseCount:((i=t.usage)==null?void 0:i.tool_uses)??a.toolUseCount,durationMs:((o=t.usage)==null?void 0:o.duration_ms)??a.durationMs,lastToolName:t.last_tool_name??a.lastToolName,summary:t.summary??a.summary}}}}return a?{tasks:{...s.tasks,[r]:{...a,status:t.status??"completed",endTime:c,finalSummary:t.summary??a.finalSummary,outputFile:t.output_file??a.outputFile,tokenCount:((y=t.usage)==null?void 0:y.total_tokens)??a.tokenCount,toolUseCount:((b=t.usage)==null?void 0:b.tool_uses)??a.toolUseCount,durationMs:((j=t.usage)==null?void 0:j.duration_ms)??a.durationMs,evictAfter:c+Q}}}:{tasks:{...s.tasks,[r]:{taskId:r,name:F(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:c,endTime:c,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(x=t.usage)==null?void 0:x.total_tokens,toolUseCount:(h=t.usage)==null?void 0:h.tool_uses,durationMs:(f=t.usage)==null?void 0:f.duration_ms,evictAfter:c+Q}}}}function Ge(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 Xe{constructor(){C(this,"listeners",new Set);C(this,"eventSource",null);C(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 a=JSON.parse(c.data);if(a.seqNum!==void 0&&a.seqNum<=this._lastSeqNum)return;a.seqNum!==void 0&&(this._lastSeqNum=a.seqNum);for(const p of this.listeners)p(a)}catch{}})}disconnect(){this.eventSource&&(this.eventSource.close(),this.eventSource=null),this._lastSeqNum=0}}const H=new Xe;function V(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 K(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 Ze{constructor(t,n,r){C(this,"sessionId");C(this,"setEntries");C(this,"unsub",null);C(this,"onStatusChange");C(this,"onError");C(this,"onPermissionRequest");C(this,"onModelsStateChange");C(this,"onSubagentUpdate");C(this,"subagentState",Z());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 p;const{events:t}=await le(this.sessionId);if(!t||t.length===0)return;const n=[];let r=null;const c=()=>{r&&(n.push(r),r=null)};for(const u of t){const m=u.payload||{};if(u.type==="user"){if(u.direction==="inbound")continue;c();const l=V(m);l&&n.push({type:"user_message",id:u.id||`hist-user-${n.length}`,content:l})}else if(u.type==="assistant"){c();const l=V(m),i=[],o=m.message;if(o&&typeof o=="object"&&Array.isArray(o.content))for(const x of o.content)x.type==="tool_use"&&i.push({type:"tool_call",toolCall:{id:x.id||`hist-tool-${n.length}`,title:x.name||"tool",status:"complete",rawInput:x.input||{}}});if(l||i.length>0){r={type:"assistant_message",id:u.id||`hist-asst-${n.length}`,chunks:l?[{type:"message",text:l}]:[]},n.push(r);for(const x of i)n.push(x);r=null}}else if(u.type==="tool_use"){const l=m,i={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(i)}else if(u.type==="tool_result"){const l=m,i=K(n,l.tool_call_id||"");if(i>=0){const o=n[i];n[i]={type:"tool_call",toolCall:{...o.toolCall,rawOutput:{output:l.content||l.output||""}}}}}}c(),this.setEntries(n);let a=null;for(const u of t){if(u.type!=="models_state")continue;const m=u.payload||{},l=m.raw,i=l&&typeof l=="object"?l.models_state:m.models_state;i&&Array.isArray(i.availableModels)&&typeof i.currentModelId=="string"&&(a=i)}a&&((p=this.onModelsStateChange)==null||p.call(this,a))}connectSSE(){H.connect(this.sessionId),this.unsub=H.onEvent(t=>this.handleEvent(t))}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),H.disconnect()}handleEvent(t){var a,p,u,m,l;const n=t.type,r=t.payload||{},c=JSON.stringify(t);if(!/Remote Control connecting/i.test(c))switch(n){case"assistant":{const i=typeof r.content=="string"?r.content:"";this.setEntries(x=>{const h=x[x.length-1];if((h==null?void 0:h.type)==="assistant_message"){const f=h.chunks[h.chunks.length-1];return(f==null?void 0:f.type)==="message"?[...x.slice(0,-1),{...h,chunks:[...h.chunks.slice(0,-1),{type:"message",text:f.text+i}]}]:[...x.slice(0,-1),{...h,chunks:[...h.chunks,{type:"message",text:i}]}]}if(i&&i.trim()){const f={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[{type:"message",text:i}]};return[...x,f]}return x});const o=r.message;if(o&&typeof o=="object"&&Array.isArray(o.content)){const x=o.content.filter(h=>h.type==="tool_use");for(const h of x){const y={id:h.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`,title:h.name||"tool",status:"running",rawInput:h.input||{}};this.setEntries(b=>[...b,{type:"tool_call",toolCall:y}])}}break}case"tool_use":{const i=r,x={id:i.tool_call_id||`call-${Date.now()}`,title:i.tool_name||"tool",status:"running",rawInput:i.tool_input||{}};this.setEntries(h=>[...h,{type:"tool_call",toolCall:x}]);break}case"tool_result":{const i=r,o=i.tool_call_id||"";this.setEntries(x=>{const h=K(x,o);if(h<0)return x;const f=x[h];return x.map((y,b)=>b===h?{type:"tool_call",toolCall:{...f.toolCall,status:"complete",rawOutput:{output:i.content||i.output||""}}}:y)});break}case"control_request":case"permission_request":{const i=r.request;if(i&&i.subtype==="can_use_tool"){const o=r.request_id||"",x=i.tool_name||"unknown",h=i.input||i.tool_input||{},f=i.description||"";this.setEntries(y=>{const b=[...y].reverse().findIndex(j=>j.type==="tool_call");if(b>=0){const j=y.length-1-b,w=y[j];if(w.toolCall.status==="running")return y.map((M,T)=>T===j?{type:"tool_call",toolCall:{...w.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:o,options:[]}}}:M)}return y}),(a=this.onPermissionRequest)==null||a.call(this,{requestId:o,toolName:x,toolInput:h,description:f})}break}case"session_status":{typeof r.status=="string"&&((p=this.onStatusChange)==null||p.call(this,r.status));break}case"error":{const i=String(r.message||r.content||"Unknown error");(u=this.onError)==null||u.call(this,i);break}case"models_state":{const i=r.raw,o=typeof i=="object"&&i!==null?i.models_state:r.models_state;o&&Array.isArray(o.availableModels)&&typeof o.currentModelId=="string"&&((m=this.onModelsStateChange)==null||m.call(this,o));break}case"system":{const i=r.raw,o=i&&typeof i=="object"?i:r,x=typeof o.subtype=="string"?o.subtype:void 0;if(x==="task_started"||x==="task_progress"||x==="task_notification"){const h={subtype:x,task_id:typeof o.task_id=="string"?o.task_id:void 0,tool_use_id:typeof o.tool_use_id=="string"?o.tool_use_id:void 0,description:typeof o.description=="string"?o.description:void 0,task_type:typeof o.task_type=="string"?o.task_type:void 0,workflow_name:typeof o.workflow_name=="string"?o.workflow_name:void 0,prompt:typeof o.prompt=="string"?o.prompt:void 0,usage:o.usage&&typeof o.usage=="object"?o.usage:void 0,last_tool_name:typeof o.last_tool_name=="string"?o.last_tool_name:void 0,summary:typeof o.summary=="string"?o.summary:void 0,status:o.status==="completed"||o.status==="failed"||o.status==="stopped"?o.status:void 0,output_file:typeof o.output_file=="string"?o.output_file:void 0};this.subagentState=Ye(this.subagentState,h),(l=this.onSubagentUpdate)==null||l.call(this,this.subagentState)}break}}}async sendMessage(t,n,r){const c=n&&n.length>0,a=r&&r.length>0;if(!t.trim()&&!c&&!a)return;const p={type:"user_message",id:`user-${Date.now()}`,content:t,images:c?n:void 0,attachments:a?r:void 0};this.setEntries(l=>[...l,p]);const u=[];if(t&&u.push({type:"text",text:t}),c)for(const l of n)u.push({type:"image",source:{type:"base64",media_type:l.mimeType,data:l.data}});if(a){for(const l of r)if(l.kind==="text"||l.kind==="table"){const i=`📎 ${l.name}${l.size!=null?` (${et(l.size)})`:""}`,o=l.textContent||"(空文件)";u.push({type:"text",text:`${i}
47
47
  \`\`\`
48
48
  ${o}
49
49
  \`\`\``})}else if(l.kind==="directory"){const i=`📁 目录: ${l.name}${l.files!=null?` (${l.files.length} 个文件)`:""}`,o=l.textContent||"(空目录)";u.push({type:"text",text:`${i}
50
- ${o}`})}}const m=u.length===1&&u[0].type==="text"?u[0].text||t:u.length>0?u:t;await ce(this.sessionId,{type:"user",uuid:de(),content:t,message:{content:m}})}async respondPermission(t,n,r){await I(this.sessionId,{type:"permission_response",approved:n,request_id:t,...r}),this.setEntries(c=>c.map(a=>{var p;return a.type!=="tool_call"||((p=a.toolCall.permissionRequest)==null?void 0:p.requestId)!==t?a:{type:"tool_call",toolCall:{...a.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 ue(this.sessionId)}}function Ze(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function et(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 tt(s){return s?Date.now()-s<6e4:!1}function st({onClose:s,session:t,liveStatus:n,pendingPermissions:r,onInterrupt:c,onDelete:a}){const[p,u]=g.useState(!1),m=async()=>{await navigator.clipboard.writeText(t.id),u(!0),setTimeout(()=>u(!1),1500)},l=r.length,i=t.worker,o=t.work_item,x=t.environment;return e.jsx(Ce,{open:!0,onOpenChange:h=>{h||s()},children:e.jsxs(Me,{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(Ee,{children:e.jsx($e,{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(Ie,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{status:n||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:i&&(tt(i.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[i&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:et(i.last_heartbeat_at)})]}),x&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Ue,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:x.machine_name||x.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(z,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:K(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(Y,{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(Ve,{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:a,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(me,{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(Oe,{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:m,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:p?"✓":"⧉"})]})]}),o&&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:o.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:o.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})]}),x&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:x.worker_type})]})]})]})]})]})})}const W="rcs:subagent-panel:collapsed";function nt(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),a=n%60;return a?`${c}h${a}m`:`${c}h`}function rt(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 at({status:s}){return s==="running"?e.jsx(Y,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(Le,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(xe,{className:"h-3 w-3 text-status-error"}):null}function ot({task:s}){const t=s.status==="running",n=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,r=rt(s.tokenCount),c=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",a=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(at,{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:nt(n)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:a}),(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 it({state:s}){const[t,n]=g.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(W)==="1"}catch{return!1}}),r=()=>{n(m=>{const l=!m;try{window.localStorage.setItem(W,l?"1":"0")}catch{}return l})},[,c]=g.useState(0);g.useEffect(()=>{const m=Object.values(s.tasks).some(o=>o.status==="running"),l=Object.values(s.tasks).some(o=>o.status!=="running"&&o.evictAfter!==void 0);if(!m&&!l)return;const i=setInterval(()=>{c(o=>o+1)},1e3);return()=>clearInterval(i)},[s]);const a=Ye(s);if(a.length===0)return null;const p=a.filter(m=>m.status==="running").length,u=p>0?`${p} running`:`${a.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(qe,{className:`h-3 w-3 transition-transform ${t?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:u})]}),!t&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:a.map(m=>e.jsx(ot,{task:m},m.taskId))})]})})}function lt({requestId:s,toolName:t,toolInput:n,description:r,onApprove:c,onReject:a}){const p=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(Je,{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:E(r)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:E(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:he(p,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:a,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 ct({questions:s,description:t,onSubmit:n,onSkip:r}){const[c,a]=g.useState({}),[p,u]=g.useState({}),[m,l]=g.useState(0),i=(f,y,b)=>{if(b){const j=c[f]||[],w=j.includes(y)?j.filter(C=>C!==y):[...j,y];a({...c,[f]:w})}else a({...c,[f]:y})},o=f=>{var b;const y=(b=p[f])==null?void 0:b.trim();y&&(a({...c,[f]:y}),u({...p,[f]:""}))},x=()=>{var y,b;const f={};for(const[j,w]of Object.entries(c)){const C=s[parseInt(j,10)];C&&(typeof w=="number"?f[j]=((b=(y=C.options)==null?void 0:y[w])==null?void 0:b.label)||String(w):Array.isArray(w)?f[j]=w.map(A=>{var q,D;return((D=(q=C.options)==null?void 0:q[A])==null?void 0:D.label)||String(A)}):f[j]=w)}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:E(t||f.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(f.options||[]).map((b,j)=>{const w=y?(c[0]||[]).includes(j):c[0]===j;return e.jsxs("button",{onClick:()=>i(0,j,y),className:P("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",w?"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:E(b.label)}),b.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:E(b.description)})]},j)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:p[0]||"",onChange:b=>u({...p,0:b.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:b=>b.key==="Enter"&&o(0)}),e.jsx("button",{onClick:()=>o(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:x,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 h=s[m];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:E(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:P("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",m===y?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:f.header||`Q${y+1}`},y))}),h&&e.jsx(dt,{question:h,qIdx:m,answers:c,otherTexts:p,onSelect:i,onOtherTextChange:(f,y)=>u({...p,[f]:y}),onOtherSubmit:o}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[m+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:x,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 dt({question:s,qIdx:t,answers:n,otherTexts:r,onSelect:c,onOtherTextChange:a,onOtherSubmit:p}){const u=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:E(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((m,l)=>{const i=u?(n[t]||[]).includes(l):n[t]===l;return e.jsxs("button",{onClick:()=>c(t,l,u),className:P("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",i?"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:E(m.label)}),m.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:E(m.description)})]},l)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r[t]||"",onChange:m=>a(t,m.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:m=>m.key==="Enter"&&p(t)}),e.jsx("button",{onClick:()=>p(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 ut({planContent:s,description:t,onSubmit:n}){const[r,c]=g.useState(null),[a,p]=g.useState(""),u=!s||!s.trim(),m=()=>{r&&n(r,r==="no"?a: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(pe,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:u?"Exit plan mode?":"Ready to code?"})]}),!u&&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:mt(s)}}),e.jsx("div",{className:"space-y-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(T,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes"}),e.jsx(T,{selected:r==="no",onClick:()=>c("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(T,{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(T,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(T,{selected:r==="no",onClick:()=>c("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:a,onChange:l=>p(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:m,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 T({selected:s,onClick:t,label:n,desc:r}){return e.jsxs("button",{onClick:t,className:P("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:P("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 mt(s){let t=E(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 xt(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function pt(s){const t=xt(s),n=ye(),r=n?{proxyUrl:t,token:n}:{proxyUrl:t};return new fe(r)}function kt({sessionId:s,onSessionLoaded:t}){const[n,r]=g.useState(null),[c,a]=g.useState(null),[p,u]=g.useState(""),[m,l]=g.useState(!1),[i,o]=g.useState(!1),[x,h]=g.useState([]),[f,y]=g.useState(!1),[b,j]=g.useState([]),[w,C]=g.useState(null),[A,q]=g.useState(()=>X()),D=g.useRef(null),H=g.useRef(x);H.current=x;const _=g.useMemo(()=>new Xe(s,h,{onStatusChange:d=>{a(d)},onError:d=>{console.error("[RCSChatAdapter] error:",d)},onPermissionRequest:d=>{j(N=>N.some(k=>k.requestId===d.requestId)?N:[...N,d])},onModelsStateChange:d=>{C(d)},onSubagentUpdate:d=>{q(d)}}),[s]);g.useEffect(()=>(D.current=_,()=>{_.disconnect()}),[_]),g.useEffect(()=>{let d=!1;async function N(){u("");try{const k=await ke(s);if(d)return;r(k),a(k.status),t==null||t(k)}catch(k){if(d)return;u(k instanceof Error?k.message:"Failed to load session");return}try{await _.init()}catch(k){console.warn("Failed to init adapter:",k)}}return N(),()=>{d=!0}},[s,_,t]);const R=ve(c),Z=g.useCallback(async d=>{const N=d.text.trim(),k=d.images&&d.images.length>0||d.attachments&&d.attachments.length>0;if(!N&&!k||R)return;const v=await ge(N,{sessionId:s,availableCommands:[],availableModels:(w==null?void 0:w.availableModels)??[],currentModel:w?{modelId:w.currentModelId,name:w.currentModelId}:null,supportsImages:!0,entries:H.current,setModel:async M=>{await I(s,{type:"control_request",request:{subtype:"set_model",model:M}}),C(F=>F&&{...F,currentModelId:M})},onNewSession:()=>{h([])}}).catch(()=>null);if(v){if(be("[SessionDetail] local command result",v),"clearEntries"in v&&v.clearEntries){h([]);return}if("newSession"in v&&v.newSession){h([]);return}if("userEntry"in v){h(M=>[...M,v.userEntry,v.cmdEntry]);return}}y(!0);try{await _.sendMessage(N,d.images,d.attachments)}catch(M){console.error("Send failed:",M)}},[_,R,s,w]),B=g.useCallback(async()=>{try{await _.interrupt()}catch(d){console.error("Interrupt failed:",d)}finally{y(!1)}},[_]),ee=g.useCallback(async()=>{if(n&&window.confirm(`删除会话 ${n.title||n.id}?此操作不可恢复。`))try{await je(n.id),window.location.href="/code/"}catch(d){alert(d instanceof Error?d.message:"Failed to delete session")}},[n]);g.useEffect(()=>{if(x.length===0)return;const d=x[x.length-1];if((d==null?void 0:d.type)==="assistant_message"||(d==null?void 0:d.type)==="tool_call"){if(d.type==="tool_call"&&d.toolCall.status==="running")return;y(!1)}},[x]);const te=g.useCallback(async d=>{try{await _.respondPermission(d,!0)}catch(N){console.error("Failed to approve:",N)}j(N=>N.filter(k=>k.requestId!==d))},[_]),se=g.useCallback(async d=>{try{await _.respondPermission(d,!1)}catch(N){console.error("Failed to reject:",N)}j(N=>N.filter(k=>k.requestId!==d))},[_]),ne=g.useCallback(async(d,N,k)=>{try{await I(s,{type:"permission_response",approved:!0,request_id:d,updated_input:{questions:k,answers:N}})}catch(v){console.error("Failed to submit answers:",v)}j(v=>v.filter(M=>M.requestId!==d))},[s]),re=g.useCallback(async(d,N,k)=>{try{N==="no"?await I(s,{type:"permission_response",approved:!1,request_id:d,...k?{message:k}:{}}):await I(s,{type:"permission_response",approved:!0,request_id:d,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[N]||"default",destination:"session"}]})}catch(v){console.error("Failed to submit plan response:",v)}j(v=>v.filter(M=>M.requestId!==d))},[s]);return p?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:p}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:"← Back to Dashboard"})]})}):n?n.source==="acp"&&n.environment_id?e.jsx(ft,{sessionId:s,agentId:n.environment_id}):e.jsx(G,{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.jsx("h2",{className:"font-display text-lg font-semibold text-text-primary",children:e.jsx("span",{className:"truncate",children:n.title||n.id})}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var k;const d=n.source==="acp"?"acp":(k=n.environment)==null?void 0:k.worker_type,N=Ae(d);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${N.colorClass}`,children:N.fullLabel})})(),c&&e.jsx(J,{status:c}),e.jsx("span",{className:"text-xs text-text-muted",children:K(n.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(!i),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:"Session info",children:e.jsx(Be,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>l(!m),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:["Tasks",b.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:b.length})]})]})]}),i&&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:"Session"})," ",n.id]}),n.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:"Environment"})," ",n.environment_id]})]})]})}),e.jsx(we,{entries:x,isLoading:f,emptyTitle:"开始对话",emptyDescription:"输入消息开始聊天"}),e.jsx(it,{state:A}),b.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:b.map(d=>e.jsx(ht,{request:d,onApprove:()=>te(d.requestId),onReject:()=>se(d.requestId),onSubmitAnswers:ne,onSubmitPlan:re},d.requestId))})}),e.jsx(Ne,{onSubmit:Z,isLoading:f,onInterrupt:B,disabled:R,placeholder:R?"会话已关闭":"输入消息...",supportsAttachments:!0}),m&&n&&e.jsx(st,{onClose:()=>l(!1),session:n,liveStatus:c,pendingPermissions:b,onInterrupt:B,onDelete:ee})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:"Loading session..."})})}function ht({request:s,onApprove:t,onReject:n,onSubmitAnswers:r,onSubmitPlan:c}){const a=s.toolName,p=s.toolInput,u=s.description||"";if(a==="AskUserQuestion"){const m=p.questions||[];return e.jsx(ct,{requestId:s.requestId,questions:m,description:u,onSubmit:l=>r(s.requestId,l,m),onSkip:n})}if(a==="ExitPlanMode"){const m=p.plan||"";return e.jsx(ut,{requestId:s.requestId,planContent:m,description:u,onSubmit:(l,i)=>c(s.requestId,l,i)})}return e.jsx(lt,{requestId:s.requestId,toolName:a,toolInput:p,description:u,onApprove:t,onReject:n})}function ft({sessionId:s,agentId:t}){const[n,r]=g.useState(null),[c,a]=g.useState("disconnected"),[p,u]=g.useState(null),m=g.useRef(null);return g.useEffect(()=>{const l=pt(t);return l.setConnectionStateHandler((i,o)=>{a(i),u(o||null)}),m.current=l,r(l),l.connect().catch(i=>{i instanceof _e||(u(i.message),a("error"))}),()=>{l.disconnect(),m.current=null,r(null),a("disconnected")}},[t]),e.jsx(G,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[p&&c==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:p}),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:"Connecting to agent..."})]})}),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:"Connection Failed"}),e.jsx("p",{className:"text-text-muted text-sm",children:p})]})}),n&&c==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Se,{client:n,agentId:t})})]})})}export{kt as SessionDetail};
50
+ ${o}`})}}const m=u.length===1&&u[0].type==="text"?u[0].text||t:u.length>0?u:t;await ce(this.sessionId,{type:"user",uuid:de(),content:t,message:{content:m}})}async respondPermission(t,n,r){await P(this.sessionId,{type:"permission_response",approved:n,request_id:t,...r}),this.setEntries(c=>c.map(a=>{var p;return a.type!=="tool_call"||((p=a.toolCall.permissionRequest)==null?void 0:p.requestId)!==t?a:{type:"tool_call",toolCall:{...a.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 ue(this.sessionId)}}function et(s){return s<1024?`${s} B`:s<1024*1024?`${(s/1024).toFixed(1)} KB`:`${(s/(1024*1024)).toFixed(1)} MB`}function tt(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 st(s){return s?Date.now()-s<6e4:!1}function nt({onClose:s,session:t,liveStatus:n,pendingPermissions:r,onInterrupt:c,onDelete:a}){const[p,u]=g.useState(!1),m=async()=>{await navigator.clipboard.writeText(t.id),u(!0),setTimeout(()=>u(!1),1500)},l=r.length,i=t.worker,o=t.work_item,x=t.environment;return e.jsx(Me,{open:!0,onOpenChange:h=>{h||s()},children:e.jsxs(Ee,{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($e,{children:e.jsx(Ae,{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(Pe,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(J,{status:n||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:i&&(st(i.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[i&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(L,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:tt(i.last_heartbeat_at)})]}),x&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Fe,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:x.machine_name||x.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(L,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Y(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(G,{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(Ke,{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:a,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(me,{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(He,{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:m,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:p?"✓":"⧉"})]})]}),o&&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:o.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:o.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})]}),x&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:x.worker_type})]})]})]})]})]})})}const W="rcs:subagent-panel:collapsed";function rt(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),a=n%60;return a?`${c}h${a}m`:`${c}h`}function at(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 ot({status:s}){return s==="running"?e.jsx(G,{className:"h-3 w-3 animate-spin text-brand"}):s==="completed"?e.jsx(Qe,{className:"h-3 w-3 text-status-success"}):s==="failed"||s==="stopped"?e.jsx(xe,{className:"h-3 w-3 text-status-error"}):null}function it({task:s}){const t=s.status==="running",n=t?s.durationMs??Date.now()-s.startTime:(s.endTime??Date.now())-s.startTime,r=at(s.tokenCount),c=s.toolUseCount!==void 0&&s.toolUseCount>0?`${s.toolUseCount} tool${s.toolUseCount>1?"s":""}`:"",a=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(ot,{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:rt(n)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:a}),(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 lt({state:s}){const[t,n]=g.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(W)==="1"}catch{return!1}}),r=()=>{n(m=>{const l=!m;try{window.localStorage.setItem(W,l?"1":"0")}catch{}return l})},[,c]=g.useState(0);g.useEffect(()=>{const m=Object.values(s.tasks).some(o=>o.status==="running"),l=Object.values(s.tasks).some(o=>o.status!=="running"&&o.evictAfter!==void 0);if(!m&&!l)return;const i=setInterval(()=>{c(o=>o+1)},1e3);return()=>clearInterval(i)},[s]);const a=Ge(s);if(a.length===0)return null;const p=a.filter(m=>m.status==="running").length,u=p>0?`${p} running`:`${a.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(qe,{className:`h-3 w-3 transition-transform ${t?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:u})]}),!t&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:a.map(m=>e.jsx(it,{task:m},m.taskId))})]})})}function ct({requestId:s,toolName:t,toolInput:n,description:r,onApprove:c,onReject:a}){const p=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(Je,{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:$(r)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:$(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:he(p,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:a,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 dt({questions:s,description:t,onSubmit:n,onSkip:r}){const[c,a]=g.useState({}),[p,u]=g.useState({}),[m,l]=g.useState(0),i=(f,y,b)=>{if(b){const j=c[f]||[],w=j.includes(y)?j.filter(M=>M!==y):[...j,y];a({...c,[f]:w})}else a({...c,[f]:y})},o=f=>{var b;const y=(b=p[f])==null?void 0:b.trim();y&&(a({...c,[f]:y}),u({...p,[f]:""}))},x=()=>{var y,b;const f={};for(const[j,w]of Object.entries(c)){const M=s[parseInt(j,10)];M&&(typeof w=="number"?f[j]=((b=(y=M.options)==null?void 0:y[w])==null?void 0:b.label)||String(w):Array.isArray(w)?f[j]=w.map(T=>{var q,R;return((R=(q=M.options)==null?void 0:q[T])==null?void 0:R.label)||String(T)}):f[j]=w)}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:$(t||f.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(f.options||[]).map((b,j)=>{const w=y?(c[0]||[]).includes(j):c[0]===j;return e.jsxs("button",{onClick:()=>i(0,j,y),className:D("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",w?"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:$(b.label)}),b.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:$(b.description)})]},j)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:p[0]||"",onChange:b=>u({...p,0:b.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:b=>b.key==="Enter"&&o(0)}),e.jsx("button",{onClick:()=>o(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:x,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 h=s[m];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:$(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:D("rounded-md px-3 py-1.5 text-xs whitespace-nowrap transition-colors",m===y?"bg-brand/20 text-brand":"text-text-muted hover:bg-surface-2"),children:f.header||`Q${y+1}`},y))}),h&&e.jsx(ut,{question:h,qIdx:m,answers:c,otherTexts:p,onSelect:i,onOtherTextChange:(f,y)=>u({...p,[f]:y}),onOtherSubmit:o}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs text-text-muted",children:[m+1," / ",s.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:x,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 ut({question:s,qIdx:t,answers:n,otherTexts:r,onSelect:c,onOtherTextChange:a,onOtherSubmit:p}){const u=s.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:$(s.question)}),e.jsxs("div",{className:"space-y-2",children:[(s.options||[]).map((m,l)=>{const i=u?(n[t]||[]).includes(l):n[t]===l;return e.jsxs("button",{onClick:()=>c(t,l,u),className:D("w-full rounded-lg border px-4 py-2.5 text-left text-sm transition-colors",i?"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:$(m.label)}),m.description&&e.jsx("div",{className:"mt-0.5 text-xs text-text-muted",children:$(m.description)})]},l)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r[t]||"",onChange:m=>a(t,m.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:m=>m.key==="Enter"&&p(t)}),e.jsx("button",{onClick:()=>p(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 mt({planContent:s,description:t,onSubmit:n}){const[r,c]=g.useState(null),[a,p]=g.useState(""),u=!s||!s.trim(),m=()=>{r&&n(r,r==="no"?a: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(pe,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold text-text-primary",children:u?"Exit plan mode?":"Ready to code?"})]}),!u&&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:xt(s)}}),e.jsx("div",{className:"space-y-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(I,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes"}),e.jsx(I,{selected:r==="no",onClick:()=>c("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(I,{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(I,{selected:r==="yes-default",onClick:()=>c("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(I,{selected:r==="no",onClick:()=>c("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:a,onChange:l=>p(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:m,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 I({selected:s,onClick:t,label:n,desc:r}){return e.jsxs("button",{onClick:t,className:D("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:D("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 xt(s){let t=$(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 pt(s){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${s}`}function ht(s){const t=pt(s),n=ye(),r=n?{proxyUrl:t,token:n}:{proxyUrl:t};return new fe(r)}function vt({sessionId:s,onSessionLoaded:t}){ge();const[n,r]=g.useState(null),[c,a]=g.useState(null),[p,u]=g.useState(""),[m,l]=g.useState(!1),[i,o]=g.useState(!1),[x,h]=g.useState([]),[f,y]=g.useState(!1),[b,j]=g.useState([]),[w,M]=g.useState(null),[T,q]=g.useState(()=>Z()),R=g.useRef(null),z=g.useRef(x);z.current=x;const S=g.useMemo(()=>new Ze(s,h,{onStatusChange:d=>{a(d)},onError:d=>{console.error("[RCSChatAdapter] error:",d)},onPermissionRequest:d=>{j(N=>N.some(k=>k.requestId===d.requestId)?N:[...N,d])},onModelsStateChange:d=>{M(d)},onSubagentUpdate:d=>{q(d)}}),[s]);g.useEffect(()=>(R.current=S,()=>{S.disconnect()}),[S]),g.useEffect(()=>{let d=!1;async function N(){u("");try{const k=await ve(s);if(d)return;r(k),a(k.status),t==null||t(k)}catch(k){if(d)return;u(k instanceof Error?k.message:_("session.loadFailed"));return}try{await S.init()}catch(k){console.warn("Failed to init adapter:",k)}}return N(),()=>{d=!0}},[s,S,t]);const U=_e(c),ee=g.useCallback(async d=>{const N=d.text.trim(),k=d.images&&d.images.length>0||d.attachments&&d.attachments.length>0;if(!N&&!k||U)return;const v=await be(N,{sessionId:s,availableCommands:[],availableModels:(w==null?void 0:w.availableModels)??[],currentModel:w?{modelId:w.currentModelId,name:w.currentModelId}:null,supportsImages:!0,entries:z.current,setModel:async E=>{await P(s,{type:"control_request",request:{subtype:"set_model",model:E}}),M(O=>O&&{...O,currentModelId:E})},onNewSession:()=>{h([])}}).catch(()=>null);if(v){if(je("[SessionDetail] local command result",v),"clearEntries"in v&&v.clearEntries){h([]);return}if("newSession"in v&&v.newSession){h([]);return}if("userEntry"in v){h(E=>[...E,v.userEntry,v.cmdEntry]);return}}y(!0);try{await S.sendMessage(N,d.images,d.attachments)}catch(E){console.error("Send failed:",E)}},[S,U,s,w]),B=g.useCallback(async()=>{try{await S.interrupt()}catch(d){console.error("Interrupt failed:",d)}finally{y(!1)}},[S]),te=g.useCallback(async()=>{if(n&&window.confirm(_("dashboard.confirmDelete").replace("{id}",n.title||n.id)))try{await we(n.id),window.location.href="/code/"}catch(d){alert(d instanceof Error?d.message:_("dashboard.deleteFailed"))}},[n]);g.useEffect(()=>{if(x.length===0)return;const d=x[x.length-1];if((d==null?void 0:d.type)==="assistant_message"||(d==null?void 0:d.type)==="tool_call"){if(d.type==="tool_call"&&d.toolCall.status==="running")return;y(!1)}},[x]);const se=g.useCallback(async d=>{try{await S.respondPermission(d,!0)}catch(N){console.error("Failed to approve:",N)}j(N=>N.filter(k=>k.requestId!==d))},[S]),ne=g.useCallback(async d=>{try{await S.respondPermission(d,!1)}catch(N){console.error("Failed to reject:",N)}j(N=>N.filter(k=>k.requestId!==d))},[S]),re=g.useCallback(async(d,N,k)=>{try{await P(s,{type:"permission_response",approved:!0,request_id:d,updated_input:{questions:k,answers:N}})}catch(v){console.error("Failed to submit answers:",v)}j(v=>v.filter(E=>E.requestId!==d))},[s]),ae=g.useCallback(async(d,N,k)=>{try{N==="no"?await P(s,{type:"permission_response",approved:!1,request_id:d,...k?{message:k}:{}}):await P(s,{type:"permission_response",approved:!0,request_id:d,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[N]||"default",destination:"session"}]})}catch(v){console.error("Failed to submit plan response:",v)}j(v=>v.filter(E=>E.requestId!==d))},[s]);return p?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:p}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand hover:underline",children:_("session.backToDashboard")})]})}):n?n.source==="acp"&&n.environment_id?e.jsx(yt,{sessionId:s,agentId:n.environment_id}):e.jsx(X,{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.jsx("h2",{className:"font-display text-lg font-semibold text-text-primary",children:e.jsx("span",{className:"truncate",children:n.title||n.id})}),e.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-2",children:[(()=>{var k;const d=n.source==="acp"?"acp":(k=n.environment)==null?void 0:k.worker_type,N=Te(d);return e.jsx("span",{className:`rounded-full px-2 py-0.5 text-xs font-medium ${N.colorClass}`,children:N.fullLabel})})(),c&&e.jsx(J,{status:c}),e.jsx("span",{className:"text-xs text-text-muted",children:Y(n.created_at)})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>o(!i),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:_("session.info"),children:e.jsx(Be,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>l(!m),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:[_("session.tasks"),b.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:b.length})]})]})]}),i&&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:_("session.metaSession")})," ",n.id]}),n.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:_("session.metaEnvironment")})," ",n.environment_id]})]})]})}),e.jsx(Ne,{entries:x,isLoading:f,emptyTitle:_("session.emptyTitle"),emptyDescription:_("session.emptyDescription")}),e.jsx(lt,{state:T}),b.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:b.map(d=>e.jsx(ft,{request:d,onApprove:()=>se(d.requestId),onReject:()=>ne(d.requestId),onSubmitAnswers:re,onSubmitPlan:ae},d.requestId))})}),e.jsx(ke,{onSubmit:ee,isLoading:f,onInterrupt:B,disabled:U,placeholder:U?_("session.closed"):_("session.inputPlaceholder"),supportsAttachments:!0}),m&&n&&e.jsx(nt,{onClose:()=>l(!1),session:n,liveStatus:c,pendingPermissions:b,onInterrupt:B,onDelete:te})]})}):e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:_("session.loading")})})}function ft({request:s,onApprove:t,onReject:n,onSubmitAnswers:r,onSubmitPlan:c}){const a=s.toolName,p=s.toolInput,u=s.description||"";if(a==="AskUserQuestion"){const m=p.questions||[];return e.jsx(dt,{requestId:s.requestId,questions:m,description:u,onSubmit:l=>r(s.requestId,l,m),onSkip:n})}if(a==="ExitPlanMode"){const m=p.plan||"";return e.jsx(mt,{requestId:s.requestId,planContent:m,description:u,onSubmit:(l,i)=>c(s.requestId,l,i)})}return e.jsx(ct,{requestId:s.requestId,toolName:a,toolInput:p,description:u,onApprove:t,onReject:n})}function yt({sessionId:s,agentId:t}){const[n,r]=g.useState(null),[c,a]=g.useState("disconnected"),[p,u]=g.useState(null),m=g.useRef(null);return g.useEffect(()=>{const l=ht(t);return l.setConnectionStateHandler((i,o)=>{a(i),u(o||null)}),m.current=l,r(l),l.connect().catch(i=>{i instanceof Se||(u(i.message),a("error"))}),()=>{l.disconnect(),m.current=null,r(null),a("disconnected")}},[t]),e.jsx(X,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[p&&c==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:p}),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:_("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:_("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:p})]})}),n&&c==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Ce,{client:n,agentId:t})})]})})}export{vt as SessionDetail};
@@ -0,0 +1 @@
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{N as v,I as t}from"./main-CkqtCllF.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{t as m,b as h}from"./main-DvfxciBy.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};
1
+ import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{s as m,b as h}from"./main-CkqtCllF.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{u as f}from"./useTeams-CqJOqEy1.js";import{Q as y,I as r}from"./main-CkqtCllF.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function C(){y();const{createTeam:u}=f(),[o,p]=a.useState(""),[s,m]=a.useState(""),[n,b]=a.useState(""),[l,c]=a.useState(null),[d,x]=a.useState(!1),h=t=>{p(t),s||m(t.toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-"))},g=async t=>{t.preventDefault(),c(null),x(!0);try{const i=await u({name:o,slug:s,description:n||void 0});window.location.href=`/teams/${i.id}`}catch(i){c(i instanceof Error?i.message:"Failed to create team")}finally{x(!1)}};return e.jsxs("div",{className:"mx-auto max-w-lg px-4 py-8",children:[e.jsx("h1",{className:"text-xl font-semibold text-text-primary mb-6",children:r("team.create.title")}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text-primary mb-1",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 border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary",placeholder:"Engineering"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"slug",className:"block text-sm font-medium text-text-primary mb-1",children:r("team.create.slug")}),e.jsx("input",{id:"slug",type:"text",required:!0,value:s,onChange:t=>m(t.target.value),pattern:"^[a-z0-9-]{3,32}$",className:"w-full rounded border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary",placeholder:"engineering"}),e.jsx("p",{className:"mt-1 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-1",children:r("team.create.description")}),e.jsx("textarea",{id:"description",value:n,onChange:t=>b(t.target.value),className:"w-full rounded border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary",rows:3})]}),l&&e.jsx("p",{className:"text-sm text-destructive",children:l}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{type:"button",onClick:()=>window.history.back(),className:"rounded border border-border px-4 py-2 text-sm text-text-primary hover:bg-surface-2",children:r("common.cancel")}),e.jsx("button",{type:"submit",disabled:d||!o||!s,className:"rounded bg-accent px-4 py-2 text-sm text-white hover:bg-accent/90 disabled:opacity-50",children:d?r("common.creating"):r("team.create.submit")})]})]})]})}export{C as TeamCreate};
@@ -1,4 +1,4 @@
1
- import{e as i,j as e}from"./vendor-DE_-CLIE.js";import{y as f,k as b,X as y,M as v}from"./main-DvfxciBy.js";import{u as w,t as p}from"./i18n-Dbt-vEQ3.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";/**
1
+ import{e as i,j as e}from"./vendor-DE_-CLIE.js";import{x as f,k as b,Q as y,I as p,X as v,N as w}from"./main-CkqtCllF.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,4 +8,4 @@ import{e as i,j as e}from"./vendor-DE_-CLIE.js";import{y as f,k as b,X as y,M as
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 k=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],T=f("settings",k);function C(t){const[l,a]=i.useState([]),[u,d]=i.useState(!1),s=i.useCallback(async()=>{if(t){d(!0);try{const n=await b("GET",`/web/teams/${t}/members`);a(n)}catch{a([])}finally{d(!1)}}},[t]);i.useEffect(()=>{s()},[s]);const r=i.useCallback(async(n,h)=>{await b("POST",`/web/teams/${t}/members`,{userId:n,role:h}),await s()},[t,s]),c=i.useCallback(async n=>{await b("DELETE",`/web/teams/${t}/members/${n}`),await s()},[t,s]),m=i.useCallback(async(n,h)=>{await b("PATCH",`/web/teams/${t}/members/${n}`,{role:h}),await s()},[t,s]);return{members:l,isLoading:u,addMember:r,removeMember:c,updateRole:m,refetch:s}}function $(t){const[l,a]=i.useState([]),u=i.useCallback(async s=>{if(!t)return null;const r=await b("POST",`/web/teams/${t}/invitations`,s);return a(c=>[...c,r]),r},[t]),d=i.useCallback(async s=>{t&&(await b("DELETE",`/web/teams/${t}/invitations/${s}`),a(r=>r.filter(c=>c.token!==s)))},[t]);return{invitations:l,createInvitation:u,revokeInvitation:d}}function E({teamId:t,canManage:l}){w();const{invitations:a,createInvitation:u,revokeInvitation:d}=$(t),[s,r]=i.useState(!1),[c,m]=i.useState(null),[n,h]=i.useState("member"),x=async()=>{r(!0);try{const o=await u({role:n,expiresIn:86400,maxUses:5});o&&m(o.token||o.inviteToken||null)}catch{}finally{r(!1)}},j=()=>{if(c){const o=`${window.location.origin}/join?token=${c}`;navigator.clipboard.writeText(o).catch(()=>{})}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:p("invitation.title")}),l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{className:"rounded border border-border bg-surface-2 px-2 py-1 text-sm",value:n,onChange:o=>h(o.target.value),children:[e.jsx("option",{value:"member",children:p("invitation.member")}),e.jsx("option",{value:"admin",children:p("invitation.admin")})]}),e.jsx("button",{type:"button",onClick:x,disabled:s,className:"rounded bg-accent px-3 py-1 text-sm text-white hover:bg-accent/90 disabled:opacity-50",children:s?p("invitation.creating"):p("invitation.create")})]})]}),c&&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?token=${c}`}),e.jsx("button",{type:"button",onClick:j,className:"text-text-muted hover:text-text-primary",children:e.jsx(g,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>m(null),className:"text-text-muted hover:text-text-primary",children:e.jsx(y,{className:"h-4 w-4"})})]}),a.length>0&&e.jsx("ul",{className:"space-y-2",children:a.map(o=>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:[o.role," — expires ",new Date(o.expiresAt).toLocaleDateString()]}),l&&e.jsx("button",{type:"button",onClick:()=>d(o.token),className:"text-sm text-destructive hover:underline",children:p("invitation.revoke")})]},o.token))})]})}async function L(t){try{return await b("GET",`/web/teams/${t}`)}catch{return null}}function P(){const t=window.location.pathname.split("/"),l=t[t.length-1]||"",[a,u]=i.useState(null),[d,s]=i.useState(!0),{members:r,isLoading:c}=C(l||null),{user:m}=v();if(i.useEffect(()=>{l&&(s(!0),L(l).then(x=>{u(x),s(!1)}))},[l]),d)return e.jsx("div",{className:"flex items-center justify-center py-12 text-text-muted",children:"Loading..."});if(!a)return e.jsxs("div",{className:"mx-auto max-w-3xl 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"})]});const n=r.find(x=>x.user_id===(m==null?void 0:m.userId)),h=(m==null?void 0:m.role)==="admin"||(n==null?void 0:n.role)==="owner"||(n==null?void 0:n.role)==="admin";return e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-text-primary",children:a.name}),e.jsxs("p",{className:"text-sm text-text-muted",children:["/",a.slug]})]}),e.jsxs("a",{href:`/teams/${a.id}/settings`,className:"inline-flex items-center gap-1.5 rounded border border-border px-3 py-1.5 text-sm text-text-primary hover:bg-surface-2",children:[e.jsx(T,{className:"h-4 w-4"}),"Settings"]})]}),a.description&&e.jsx("p",{className:"text-sm text-text-muted mb-6",children:a.description}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-lg font-medium text-text-primary mb-4",children:["Members (",r.length,")"]}),c?e.jsx("p",{className:"text-sm text-text-muted",children:"Loading members..."}):e.jsx("ul",{className:"space-y-2",children:r.map(x=>e.jsxs("li",{className:"flex items-center justify-between rounded border border-border/60 bg-surface-2 p-3",children:[e.jsx("div",{children:e.jsx("span",{className:"text-sm text-text-primary",children:x.username||x.user_id})}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-border/60 bg-surface-1 px-2 py-0.5 text-xs text-text-muted",children:x.role})]},x.user_id))})]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-lg font-medium text-text-primary mb-4",children:"Environments"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Team environments are listed in the dashboard when this team is active."})]}),e.jsx(E,{teamId:a.id,canManage:h})]})}export{P as TeamDetail};
11
+ */const k=[["path",{d:"M9.671 4.136a2.34 2.34 0 0 1 4.659 0 2.34 2.34 0 0 0 3.319 1.915 2.34 2.34 0 0 1 2.33 4.033 2.34 2.34 0 0 0 0 3.831 2.34 2.34 0 0 1-2.33 4.033 2.34 2.34 0 0 0-3.319 1.915 2.34 2.34 0 0 1-4.659 0 2.34 2.34 0 0 0-3.32-1.915 2.34 2.34 0 0 1-2.33-4.033 2.34 2.34 0 0 0 0-3.831A2.34 2.34 0 0 1 6.35 6.051a2.34 2.34 0 0 0 3.319-1.915",key:"1i5ecw"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],T=f("settings",k);function C(t){const[l,n]=i.useState([]),[u,d]=i.useState(!1),s=i.useCallback(async()=>{if(t){d(!0);try{const a=await b("GET",`/web/teams/${t}/members`);n(a)}catch{n([])}finally{d(!1)}}},[t]);i.useEffect(()=>{s()},[s]);const r=i.useCallback(async(a,h)=>{await b("POST",`/web/teams/${t}/members`,{userId:a,role:h}),await s()},[t,s]),c=i.useCallback(async a=>{await b("DELETE",`/web/teams/${t}/members/${a}`),await s()},[t,s]),x=i.useCallback(async(a,h)=>{await b("PATCH",`/web/teams/${t}/members/${a}`,{role:h}),await s()},[t,s]);return{members:l,isLoading:u,addMember:r,removeMember:c,updateRole:x,refetch:s}}function $(t){const[l,n]=i.useState([]),u=i.useCallback(async s=>{if(!t)return null;const r=await b("POST",`/web/teams/${t}/invitations`,s);return n(c=>[...c,r]),r},[t]),d=i.useCallback(async s=>{t&&(await b("DELETE",`/web/teams/${t}/invitations/${s}`),n(r=>r.filter(c=>c.token!==s)))},[t]);return{invitations:l,createInvitation:u,revokeInvitation:d}}function E({teamId:t,canManage:l}){y();const{invitations:n,createInvitation:u,revokeInvitation:d}=$(t),[s,r]=i.useState(!1),[c,x]=i.useState(null),[a,h]=i.useState("member"),m=async()=>{r(!0);try{const o=await u({role:a,expiresIn:86400,maxUses:5});o&&x(o.token||o.inviteToken||null)}catch{}finally{r(!1)}},j=()=>{if(c){const o=`${window.location.origin}/join?token=${c}`;navigator.clipboard.writeText(o).catch(()=>{})}};return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("h3",{className:"text-sm font-medium text-text-primary",children:p("invitation.title")}),l&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{className:"rounded border border-border bg-surface-2 px-2 py-1 text-sm",value:a,onChange:o=>h(o.target.value),children:[e.jsx("option",{value:"member",children:p("invitation.member")}),e.jsx("option",{value:"admin",children:p("invitation.admin")})]}),e.jsx("button",{type:"button",onClick:m,disabled:s,className:"rounded bg-accent px-3 py-1 text-sm text-white hover:bg-accent/90 disabled:opacity-50",children:s?p("invitation.creating"):p("invitation.create")})]})]}),c&&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?token=${c}`}),e.jsx("button",{type:"button",onClick:j,className:"text-text-muted hover:text-text-primary",children:e.jsx(g,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>x(null),className:"text-text-muted hover:text-text-primary",children:e.jsx(v,{className:"h-4 w-4"})})]}),n.length>0&&e.jsx("ul",{className:"space-y-2",children:n.map(o=>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:[o.role," — expires ",new Date(o.expiresAt).toLocaleDateString()]}),l&&e.jsx("button",{type:"button",onClick:()=>d(o.token),className:"text-sm text-destructive hover:underline",children:p("invitation.revoke")})]},o.token))})]})}async function L(t){try{return await b("GET",`/web/teams/${t}`)}catch{return null}}function A(){const t=window.location.pathname.split("/"),l=t[t.length-1]||"",[n,u]=i.useState(null),[d,s]=i.useState(!0),{members:r,isLoading:c}=C(l||null),{user:x}=w();if(i.useEffect(()=>{l&&(s(!0),L(l).then(m=>{u(m),s(!1)}))},[l]),d)return e.jsx("div",{className:"flex items-center justify-center py-12 text-text-muted",children:"Loading..."});if(!n)return e.jsxs("div",{className:"mx-auto max-w-3xl 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"})]});const a=r.find(m=>m.user_id===(x==null?void 0:x.userId)),h=(x==null?void 0:x.role)==="admin"||(a==null?void 0:a.role)==="owner"||(a==null?void 0:a.role)==="admin";return e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-xl font-semibold text-text-primary",children:n.name}),e.jsxs("p",{className:"text-sm text-text-muted",children:["/",n.slug]})]}),e.jsxs("a",{href:`/teams/${n.id}/settings`,className:"inline-flex items-center gap-1.5 rounded border border-border px-3 py-1.5 text-sm text-text-primary hover:bg-surface-2",children:[e.jsx(T,{className:"h-4 w-4"}),"Settings"]})]}),n.description&&e.jsx("p",{className:"text-sm text-text-muted mb-6",children:n.description}),e.jsxs("div",{className:"mb-8",children:[e.jsxs("h2",{className:"text-lg font-medium text-text-primary mb-4",children:["Members (",r.length,")"]}),c?e.jsx("p",{className:"text-sm text-text-muted",children:"Loading members..."}):e.jsx("ul",{className:"space-y-2",children:r.map(m=>e.jsxs("li",{className:"flex items-center justify-between rounded border border-border/60 bg-surface-2 p-3",children:[e.jsx("div",{children:e.jsx("span",{className:"text-sm text-text-primary",children:m.username||m.user_id})}),e.jsx("span",{className:"inline-flex items-center rounded-full border border-border/60 bg-surface-1 px-2 py-0.5 text-xs text-text-muted",children:m.role})]},m.user_id))})]}),e.jsxs("div",{className:"mb-8",children:[e.jsx("h2",{className:"text-lg font-medium text-text-primary mb-4",children:"Environments"}),e.jsx("p",{className:"text-sm text-text-muted",children:"Team environments are listed in the dashboard when this team is active."})]}),e.jsx(E,{teamId:n.id,canManage:h})]})}export{A as TeamDetail};
@@ -1 +1 @@
1
- import{j as e}from"./vendor-DE_-CLIE.js";import{u as a}from"./useTeams-DPHGnBHL.js";import{P as i}from"./main-DvfxciBy.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function l(){const{myTeams:t,isLoading:r}=a();return r?e.jsx("div",{className:"flex items-center justify-center py-12 text-text-muted",children:"Loading teams..."}):e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-xl font-semibold text-text-primary",children:"Teams"}),e.jsxs("a",{href:"/teams/new",className:"inline-flex items-center gap-1.5 rounded bg-accent px-3 py-1.5 text-sm text-white hover:bg-accent/90",children:[e.jsx(i,{className:"h-4 w-4"}),"Create Team"]})]}),t.length===0?e.jsx("div",{className:"rounded border border-border/60 bg-surface-2 p-8 text-center",children:e.jsx("p",{className:"text-text-muted",children:"You are not a member of any teams yet."})}):e.jsx("ul",{className:"space-y-3",children:t.map(s=>e.jsx("li",{children:e.jsx("a",{href:`/teams/${s.id}`,className:"block rounded border border-border/60 bg-surface-2 p-4 hover:bg-surface-3 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium text-text-primary",children:s.name}),e.jsxs("p",{className:"text-sm text-text-muted",children:["/",s.slug]})]}),s.description&&e.jsx("p",{className:"text-sm text-text-muted max-w-xs truncate",children:s.description})]})})},s.id))})]})}export{l as TeamList};
1
+ import{j as e}from"./vendor-DE_-CLIE.js";import{u as a}from"./useTeams-CqJOqEy1.js";import{P as i}from"./main-CkqtCllF.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function l(){const{myTeams:t,isLoading:r}=a();return r?e.jsx("div",{className:"flex items-center justify-center py-12 text-text-muted",children:"Loading teams..."}):e.jsxs("div",{className:"mx-auto max-w-3xl px-4 py-8",children:[e.jsxs("div",{className:"flex items-center justify-between mb-6",children:[e.jsx("h1",{className:"text-xl font-semibold text-text-primary",children:"Teams"}),e.jsxs("a",{href:"/teams/new",className:"inline-flex items-center gap-1.5 rounded bg-accent px-3 py-1.5 text-sm text-white hover:bg-accent/90",children:[e.jsx(i,{className:"h-4 w-4"}),"Create Team"]})]}),t.length===0?e.jsx("div",{className:"rounded border border-border/60 bg-surface-2 p-8 text-center",children:e.jsx("p",{className:"text-text-muted",children:"You are not a member of any teams yet."})}):e.jsx("ul",{className:"space-y-3",children:t.map(s=>e.jsx("li",{children:e.jsx("a",{href:`/teams/${s.id}`,className:"block rounded border border-border/60 bg-surface-2 p-4 hover:bg-surface-3 transition-colors",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"font-medium text-text-primary",children:s.name}),e.jsxs("p",{className:"text-sm text-text-muted",children:["/",s.slug]})]}),s.description&&e.jsx("p",{className:"text-sm text-text-muted max-w-xs truncate",children:s.description})]})})},s.id))})]})}export{l as TeamList};
@@ -1 +1 @@
1
- import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{k as o}from"./main-DvfxciBy.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";async function j(s){try{return await o("GET",`/web/teams/${s}`)}catch{return null}}async function w(s,a){await o("PATCH",`/web/teams/${s}`,a)}async function N(s){await o("DELETE",`/web/teams/${s}`)}function k(){const s=window.location.pathname.split("/"),a=s[s.length-2]||"",[h,b]=r.useState(null),[f,y]=r.useState(!0),[n,c]=r.useState(""),[m,l]=r.useState(""),[d,i]=r.useState(null),[x,u]=r.useState(!1);r.useEffect(()=>{a&&j(a).then(t=>{t&&(b(t),c(t.name),l(t.description||"")),y(!1)})},[a]);const v=async t=>{if(t.preventDefault(),!!a){i(null),u(!0);try{await w(a,{name:n,description:m}),window.location.href=`/teams/${a}`}catch(p){i(p instanceof Error?p.message:"Failed to update")}finally{u(!1)}}},g=async()=>{if(a&&window.confirm("Delete this team? Environments must be transferred first."))try{await N(a),window.location.href="/teams"}catch(t){i(t instanceof Error?t.message:"Failed to delete")}};return f?e.jsx("div",{className:"flex items-center justify-center py-12 text-text-muted",children:"Loading..."}):h?e.jsxs("div",{className:"mx-auto max-w-lg px-4 py-8",children:[e.jsx("h1",{className:"text-xl font-semibold text-text-primary mb-6",children:"Team Settings"}),e.jsxs("form",{onSubmit:v,className:"space-y-4 mb-8",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text-primary mb-1",children:"Team Name"}),e.jsx("input",{id:"name",type:"text",required:!0,value:n,onChange:t=>c(t.target.value),className:"w-full rounded border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-text-primary mb-1",children:"Description"}),e.jsx("textarea",{id:"description",value:m,onChange:t=>l(t.target.value),className:"w-full rounded border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary",rows:3})]}),d&&e.jsx("p",{className:"text-sm text-destructive",children:d}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{type:"button",onClick:()=>window.history.back(),className:"rounded border border-border px-4 py-2 text-sm text-text-primary hover:bg-surface-2",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:x||!n,className:"rounded bg-accent px-4 py-2 text-sm text-white hover:bg-accent/90 disabled:opacity-50",children:x?"Saving...":"Save Changes"})]})]}),e.jsxs("div",{className:"rounded border border-destructive/40 p-4",children:[e.jsx("h2",{className:"text-sm font-medium text-destructive mb-2",children:"Danger Zone"}),e.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Deleting a team requires all environments to be transferred first."}),e.jsx("button",{type:"button",onClick:g,className:"rounded border border-destructive/60 px-4 py-2 text-sm text-destructive hover:bg-destructive/10",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};
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{k as o}from"./main-CkqtCllF.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";async function j(s){try{return await o("GET",`/web/teams/${s}`)}catch{return null}}async function w(s,a){await o("PATCH",`/web/teams/${s}`,a)}async function N(s){await o("DELETE",`/web/teams/${s}`)}function k(){const s=window.location.pathname.split("/"),a=s[s.length-2]||"",[h,b]=r.useState(null),[f,y]=r.useState(!0),[n,c]=r.useState(""),[m,l]=r.useState(""),[d,i]=r.useState(null),[x,u]=r.useState(!1);r.useEffect(()=>{a&&j(a).then(t=>{t&&(b(t),c(t.name),l(t.description||"")),y(!1)})},[a]);const v=async t=>{if(t.preventDefault(),!!a){i(null),u(!0);try{await w(a,{name:n,description:m}),window.location.href=`/teams/${a}`}catch(p){i(p instanceof Error?p.message:"Failed to update")}finally{u(!1)}}},g=async()=>{if(a&&window.confirm("Delete this team? Environments must be transferred first."))try{await N(a),window.location.href="/teams"}catch(t){i(t instanceof Error?t.message:"Failed to delete")}};return f?e.jsx("div",{className:"flex items-center justify-center py-12 text-text-muted",children:"Loading..."}):h?e.jsxs("div",{className:"mx-auto max-w-lg px-4 py-8",children:[e.jsx("h1",{className:"text-xl font-semibold text-text-primary mb-6",children:"Team Settings"}),e.jsxs("form",{onSubmit:v,className:"space-y-4 mb-8",children:[e.jsxs("div",{children:[e.jsx("label",{htmlFor:"name",className:"block text-sm font-medium text-text-primary mb-1",children:"Team Name"}),e.jsx("input",{id:"name",type:"text",required:!0,value:n,onChange:t=>c(t.target.value),className:"w-full rounded border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary"})]}),e.jsxs("div",{children:[e.jsx("label",{htmlFor:"description",className:"block text-sm font-medium text-text-primary mb-1",children:"Description"}),e.jsx("textarea",{id:"description",value:m,onChange:t=>l(t.target.value),className:"w-full rounded border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary",rows:3})]}),d&&e.jsx("p",{className:"text-sm text-destructive",children:d}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("button",{type:"button",onClick:()=>window.history.back(),className:"rounded border border-border px-4 py-2 text-sm text-text-primary hover:bg-surface-2",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:x||!n,className:"rounded bg-accent px-4 py-2 text-sm text-white hover:bg-accent/90 disabled:opacity-50",children:x?"Saving...":"Save Changes"})]})]}),e.jsxs("div",{className:"rounded border border-destructive/40 p-4",children:[e.jsx("h2",{className:"text-sm font-medium text-destructive mb-2",children:"Danger Zone"}),e.jsx("p",{className:"text-sm text-text-muted mb-3",children:"Deleting a team requires all environments to be transferred first."}),e.jsx("button",{type:"button",onClick:g,className:"rounded border border-destructive/60 px-4 py-2 text-sm text-destructive hover:bg-destructive/10",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{N,Q as v,I as t,H as C}from"./main-CkqtCllF.js";import"./shiki-mEP5vQQu.js";import"./motion-BILbV7YQ.js";function E({onBack:g}){const{user:l,logout:f}=N(),w=v(),[i,c]=o.useState(""),[n,u]=o.useState(""),[m,x]=o.useState(""),[h,p]=o.useState(""),[b,r]=o.useState("");if(!l)return null;const j=async s=>{if(s.preventDefault(),r(""),p(""),n.length<8){r(t("auth.setup.passwordTooShort"));return}if(n!==m){r(t("auth.setup.passwordMismatch"));return}try{const a=await fetch("/web/auth/change-password",{method:"POST",credentials:"include",headers:{"Content-Type":"application/json","X-Requested-With":"XMLHttpRequest"},body:JSON.stringify({currentPassword:i,newPassword:n})});if(!a.ok){const d=await a.json();throw new Error(d.error||t("user.settings.changeFailed"))}p(t("user.settings.passwordChanged")),c(""),u(""),x("")}catch(a){const d=a instanceof Error?a.message:t("user.settings.changeFailed");r(d)}},y=async()=>{try{if(!(await fetch("/web/auth/logout-all",{method:"POST",credentials:"include",headers:{"X-Requested-With":"XMLHttpRequest"}})).ok){r(t("common.error"));return}await f()}catch{r(t("common.error"))}};return e.jsxs("div",{className:"mx-auto max-w-lg px-4 py-8",children:[e.jsx("button",{onClick:g,className:"mb-6 text-sm text-text-muted hover:text-text-primary transition-colors",children:t("user.settings.backDashboard")}),e.jsx("h1",{className:"mb-8 font-display text-2xl font-semibold text-text-primary",children:t("user.settings.title")}),e.jsx("section",{className:"mb-8 rounded-lg border border-border bg-surface-1 p-4",children:e.jsxs("dl",{className:"space-y-2 text-sm",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-text-muted",children:t("auth.login.username")}),e.jsx("dd",{className:"font-medium text-text-primary",children:l.username})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{className:"text-text-muted",children:t("user.settings.role")}),e.jsx("dd",{className:"font-medium text-text-primary",children:l.role})]})]})}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:t("user.settings.language")}),e.jsxs("select",{value:w,onChange:s=>C(s.target.value),className:"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:"zh",children:"中文"}),e.jsx("option",{value:"en",children:"English"})]})]}),e.jsxs("section",{className:"mb-8",children:[e.jsx("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:t("user.settings.changePassword")}),e.jsxs("form",{onSubmit:j,className:"space-y-3",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("user.settings.currentPassword")}),e.jsx("input",{type:"password",value:i,onChange:s=>c(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"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("user.settings.newPassword")}),e.jsx("input",{type:"password",value:n,onChange:s=>u(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("user.settings.confirmNewPassword")}),e.jsx("input",{type:"password",value:m,onChange:s=>x(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"})]}),b&&e.jsx("p",{className:"text-sm text-status-error",children:b}),h&&e.jsx("p",{className:"text-sm text-status-active",children:h}),e.jsx("button",{type:"submit",className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white transition-colors hover:bg-brand-light",children:t("user.settings.submit")})]})]}),e.jsxs("section",{children:[e.jsx("h2",{className:"mb-4 font-display text-lg font-semibold text-text-primary",children:t("user.settings.logoutAll")}),e.jsx("button",{onClick:y,className:"rounded-lg 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{E 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-CAuNNATY.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-XHHf0pen.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};