@saluzi/saluzi-edu 0.7.4 → 0.7.6
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.
- package/dist/cli.js +93 -61
- package/dist/rcs-schema.sql +42 -0
- package/dist/rcs-web/assets/{AdminPanel-B9YWaqlO.js → AdminPanel-D0i_28O2.js} +1 -1
- package/dist/rcs-web/assets/{ArtifactView-B8lAeS5B.js → ArtifactView-Dd6d3O3z.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/ArtifactsGallery-CNd9-Awp.js → dist/rcs-web/assets/ArtifactsGallery-BTVS7sar.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/Claim-Dq08pl4W.js → dist/rcs-web/assets/Claim-CkuDG_ay.js} +1 -1
- package/dist/rcs-web/assets/{Dashboard-JZcrtByh.js → Dashboard-BBZHnmut.js} +2 -2
- package/dist/rcs-web/assets/{Join-DgvRnpyb.js → Join-DbBj-5mj.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/Login-CZbz6Wms.js → dist/rcs-web/assets/Login-Csvt3wvz.js} +1 -1
- package/dist/rcs-web/assets/MemoriesGallery-C5cT73hA.js +1 -0
- package/dist/rcs-web/assets/{Register-DD7uiwEj.js → Register-Cmp7ogoN.js} +1 -1
- package/dist/rcs-web/assets/{RegisterEmpty-BrBfeQXp.js → RegisterEmpty-BoIy42g_.js} +2 -2
- package/dist/rcs-web/assets/SessionDetail-CocGah-8.js +83 -0
- package/dist/rcs-web/assets/{SessionVisibilityBadge-kSo9esvT.js → SessionVisibilityBadge-C873QvnC.js} +2 -2
- package/dist/rcs-web/assets/{Setup-Ca30VUSF.js → Setup-DOU0qTNX.js} +1 -1
- package/dist/rcs-web/assets/{ShareLanding-C_vlxFAM.js → ShareLanding-DMR9eh0F.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/TeamDetail-8T_kKUcX.js → dist/rcs-web/assets/TeamDetail-MPfqesJf.js} +2 -2
- package/dist/rcs-web/assets/{TeamList-DRXGQCJi.js → TeamList-CgWVmdPU.js} +1 -1
- package/dist/rcs-web/assets/{TeamSettings-Byhon5C1.js → TeamSettings-V3L0H8Nb.js} +1 -1
- package/dist/rcs-web/assets/{UserSearchInput-wixyd_8w.js → UserSearchInput-xqtDX6Bz.js} +2 -2
- package/dist/rcs-web/assets/{UserSettings-Ds2retFk.js → UserSettings-Cfqs_5af.js} +1 -1
- package/dist/rcs-web/assets/{arc-CThS8KNL.js → arc-Bl97za3P.js} +1 -1
- package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-Bko99SuX.js → architectureDiagram-3BPJPVTR-B8IQfxi6.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-CqCAgp0i.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-DNfBHM8J.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-C1pGDG-L.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-CO4HDUF2.js} +1 -1
- package/dist/rcs-web/assets/channel-DcTKV8fL.js +1 -0
- package/dist/rcs-web/assets/{chunk-2J33WTMH-Bz0kJwEY.js → chunk-2J33WTMH-4CBnqzb3.js} +1 -1
- package/dist/rcs-web/assets/{chunk-4BX2VUAB-DYnlidI7.js → chunk-4BX2VUAB-ClbIGQlY.js} +1 -1
- package/dist/rcs-web/assets/{chunk-55IACEB6-cMV4HRvm.js → chunk-55IACEB6-BnrTfmFM.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-Bgz9JRYO.js → dist/rcs-web/assets/chunk-727SXJPM-C17NZOQL.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-DIFGJlEF.js → dist/rcs-web/assets/chunk-AQP2D5EJ-CljirtnS.js} +1 -1
- package/dist/rcs-web/assets/{chunk-FMBD7UC4-BUC7O7T0.js → chunk-FMBD7UC4-Bb20ipZI.js} +1 -1
- package/dist/rcs-web/assets/{chunk-ND2GUHAM-kGqgVnBZ.js → chunk-ND2GUHAM-L3q9_xAn.js} +1 -1
- package/dist/rcs-web/assets/{chunk-QZHKN3VN-B01O0qXh.js → chunk-QZHKN3VN-FyYNxzak.js} +1 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-5DsQRSDS.js +1 -0
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-5DsQRSDS.js +1 -0
- package/dist/rcs-web/assets/{code-block-IT6T5CEO-CscK0pCh.js → code-block-IT6T5CEO-CQVTEZwg.js} +1 -1
- package/dist/rcs-web/assets/{copy-CvmA5P_Q.js → copy-CFZBXuu9.js} +1 -1
- package/dist/rcs-web/assets/{cose-bilkent-S5V4N54A-BsBsVccW.js → cose-bilkent-S5V4N54A-Cs2MVxlS.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/dagre-BM42HDAG-Bn4B33S-.js → dist/rcs-web/assets/dagre-BM42HDAG-CWZcIIf5.js} +1 -1
- package/dist/rcs-web/assets/{diagram-2AECGRRQ-DAuAIPR6.js → diagram-2AECGRRQ-DpumSk2d.js} +1 -1
- package/dist/rcs-web/assets/{diagram-5GNKFQAL-w3k2b4gC.js → diagram-5GNKFQAL-DcF2qwdh.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/diagram-KO2AKTUF-CMLav2KT.js → dist/rcs-web/assets/diagram-KO2AKTUF-BGnqGSPz.js} +1 -1
- package/dist/rcs-web/assets/{diagram-LMA3HP47-D14sXWdh.js → diagram-LMA3HP47-k-UxYOZ9.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-BexFwBQa.js → dist/rcs-web/assets/diagram-OG6HWLK6-BMPzmD6S.js} +1 -1
- package/dist/rcs-web/assets/{dialog-B4hKrd7w.js → dialog-DKk230y5.js} +1 -1
- package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-BA8ANmoV.js → erDiagram-TEJ5UH35-BvmA6W9Z.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/flowDiagram-I6XJVG4X-dTQIvKsj.js → dist/rcs-web/assets/flowDiagram-I6XJVG4X-ptAnksiF.js} +1 -1
- package/dist/rcs-web/assets/{ganttDiagram-6RSMTGT7-8SDHYxXc.js → ganttDiagram-6RSMTGT7-Bhgrzcs3.js} +1 -1
- package/dist/rcs-web/assets/{gitGraphDiagram-PVQCEYII-Bu7LyvTG.js → gitGraphDiagram-PVQCEYII-B8-vcbF-.js} +1 -1
- package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-BuQuDvuX.js → infoDiagram-5YYISTIA-DaW0unc2.js} +1 -1
- package/dist/rcs-web/assets/{ishikawaDiagram-YF4QCWOH-QjafGk8V.js → ishikawaDiagram-YF4QCWOH-4oYGuWP6.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-_FOXjXDF.js → dist/rcs-web/assets/journeyDiagram-JHISSGLW-B9YXpw0W.js} +1 -1
- package/dist/rcs-web/assets/{kanban-definition-UN3LZRKU-CbqJqyY6.js → kanban-definition-UN3LZRKU-Cglus7wI.js} +1 -1
- package/dist/rcs-web/assets/{linear-H6F41eb2.js → linear-CRTJd3_G.js} +1 -1
- package/dist/rcs-web/assets/{main-BopVSHhX.js → main-BKbA2ddo.js} +65 -65
- package/dist/rcs-web/assets/main-CP31AzxJ.css +1 -0
- package/{packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-5FH_DIq9.js → dist/rcs-web/assets/mermaid-VLURNSYL-D0JeVL0B.js} +4 -4
- package/dist/rcs-web/assets/{mermaid.core-C004NitB.js → mermaid.core-CobUk_K5.js} +5 -5
- package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-utqEJ2a8.js → mindmap-definition-RKZ34NQL-B1s-et_p.js} +1 -1
- package/dist/rcs-web/assets/{notifications-DOBs9HVf.js → notifications-BrgRJuzQ.js} +1 -1
- package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-OlbTwDZQ.js → pieDiagram-4H26LBE5-PcBs9RT_.js} +1 -1
- package/dist/rcs-web/assets/{quadrantDiagram-W4KKPZXB-BOe2DhrU.js → quadrantDiagram-W4KKPZXB-B2GxITjv.js} +1 -1
- package/dist/rcs-web/assets/{refresh-cw-BSwpDl-7.js → refresh-cw-BwmFF3kw.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-s6V1yWUG.js → dist/rcs-web/assets/requirementDiagram-4Y6WPE33-BfyZiasB.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-CdJD78Mx.js → dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-Br7tRtmq.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-DvGV6Dhl.js → dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-CN1NSfHS.js} +1 -1
- package/{packages/remote-control-server/web/dist/assets/stateDiagram-AJRCARHV-Bj-_Ulcn.js → dist/rcs-web/assets/stateDiagram-AJRCARHV-C4S8hKUx.js} +1 -1
- package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-BLGWynk-.js → stateDiagram-v2-BHNVJYJU-CbEMz-jf.js} +1 -1
- package/dist/rcs-web/assets/{timeline-definition-PNZ67QCA-B6VAH6Ka.js → timeline-definition-PNZ67QCA-mTiK0HwD.js} +1 -1
- package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-DUwaLI6R.js → vennDiagram-CIIHVFJN-DCe95URb.js} +1 -1
- package/dist/rcs-web/assets/{wardleyDiagram-YWT4CUSO-CBetJore.js → wardleyDiagram-YWT4CUSO-Cct1r0Ax.js} +1 -1
- package/dist/rcs-web/assets/{workerType-BF4aY_R_.js → workerType-DW9l12WG.js} +1 -1
- package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-BBnx6V66.js → xychartDiagram-2RQKCTM6-CVc0eQYa.js} +1 -1
- package/dist/rcs-web/index.html +2 -2
- package/package.json +1 -1
- package/packages/remote-control-server/src/__tests__/memories.test.ts +654 -0
- package/packages/remote-control-server/src/db/rcs-schema.sql +42 -0
- package/packages/remote-control-server/src/registerRoutes.ts +6 -0
- package/packages/remote-control-server/src/routes/v1/memories.ts +132 -0
- package/packages/remote-control-server/src/routes/web/memories.ts +321 -0
- package/packages/remote-control-server/src/services/memories.ts +747 -0
- package/packages/remote-control-server/web/dist/assets/{AdminPanel-B9YWaqlO.js → AdminPanel-D0i_28O2.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ArtifactView-B8lAeS5B.js → ArtifactView-Dd6d3O3z.js} +1 -1
- package/{dist/rcs-web/assets/ArtifactsGallery-CNd9-Awp.js → packages/remote-control-server/web/dist/assets/ArtifactsGallery-BTVS7sar.js} +1 -1
- package/{dist/rcs-web/assets/Claim-Dq08pl4W.js → packages/remote-control-server/web/dist/assets/Claim-CkuDG_ay.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{Dashboard-JZcrtByh.js → Dashboard-BBZHnmut.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{Join-DgvRnpyb.js → Join-DbBj-5mj.js} +1 -1
- package/{dist/rcs-web/assets/Login-CZbz6Wms.js → packages/remote-control-server/web/dist/assets/Login-Csvt3wvz.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/MemoriesGallery-C5cT73hA.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{Register-DD7uiwEj.js → Register-Cmp7ogoN.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{RegisterEmpty-BrBfeQXp.js → RegisterEmpty-BoIy42g_.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/SessionDetail-CocGah-8.js +83 -0
- package/packages/remote-control-server/web/dist/assets/{SessionVisibilityBadge-kSo9esvT.js → SessionVisibilityBadge-C873QvnC.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{Setup-Ca30VUSF.js → Setup-DOU0qTNX.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ShareLanding-C_vlxFAM.js → ShareLanding-DMR9eh0F.js} +1 -1
- package/{dist/rcs-web/assets/TeamDetail-8T_kKUcX.js → packages/remote-control-server/web/dist/assets/TeamDetail-MPfqesJf.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{TeamList-DRXGQCJi.js → TeamList-CgWVmdPU.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{TeamSettings-Byhon5C1.js → TeamSettings-V3L0H8Nb.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{UserSearchInput-wixyd_8w.js → UserSearchInput-xqtDX6Bz.js} +2 -2
- package/packages/remote-control-server/web/dist/assets/{UserSettings-Ds2retFk.js → UserSettings-Cfqs_5af.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{arc-CThS8KNL.js → arc-Bl97za3P.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-Bko99SuX.js → architectureDiagram-3BPJPVTR-B8IQfxi6.js} +1 -1
- package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-CqCAgp0i.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-DNfBHM8J.js} +1 -1
- package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-C1pGDG-L.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-CO4HDUF2.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/channel-DcTKV8fL.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-Bz0kJwEY.js → chunk-2J33WTMH-4CBnqzb3.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-DYnlidI7.js → chunk-4BX2VUAB-ClbIGQlY.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-cMV4HRvm.js → chunk-55IACEB6-BnrTfmFM.js} +1 -1
- package/{dist/rcs-web/assets/chunk-727SXJPM-Bgz9JRYO.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-C17NZOQL.js} +1 -1
- package/{dist/rcs-web/assets/chunk-AQP2D5EJ-DIFGJlEF.js → packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-CljirtnS.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-BUC7O7T0.js → chunk-FMBD7UC4-Bb20ipZI.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-kGqgVnBZ.js → chunk-ND2GUHAM-L3q9_xAn.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-B01O0qXh.js → chunk-QZHKN3VN-FyYNxzak.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-5DsQRSDS.js +1 -0
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-5DsQRSDS.js +1 -0
- package/packages/remote-control-server/web/dist/assets/{code-block-IT6T5CEO-CscK0pCh.js → code-block-IT6T5CEO-CQVTEZwg.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{copy-CvmA5P_Q.js → copy-CFZBXuu9.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{cose-bilkent-S5V4N54A-BsBsVccW.js → cose-bilkent-S5V4N54A-Cs2MVxlS.js} +1 -1
- package/{dist/rcs-web/assets/dagre-BM42HDAG-Bn4B33S-.js → packages/remote-control-server/web/dist/assets/dagre-BM42HDAG-CWZcIIf5.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-DAuAIPR6.js → diagram-2AECGRRQ-DpumSk2d.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-w3k2b4gC.js → diagram-5GNKFQAL-DcF2qwdh.js} +1 -1
- package/{dist/rcs-web/assets/diagram-KO2AKTUF-CMLav2KT.js → packages/remote-control-server/web/dist/assets/diagram-KO2AKTUF-BGnqGSPz.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-D14sXWdh.js → diagram-LMA3HP47-k-UxYOZ9.js} +1 -1
- package/{dist/rcs-web/assets/diagram-OG6HWLK6-BexFwBQa.js → packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-BMPzmD6S.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{dialog-B4hKrd7w.js → dialog-DKk230y5.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-BA8ANmoV.js → erDiagram-TEJ5UH35-BvmA6W9Z.js} +1 -1
- package/{dist/rcs-web/assets/flowDiagram-I6XJVG4X-dTQIvKsj.js → packages/remote-control-server/web/dist/assets/flowDiagram-I6XJVG4X-ptAnksiF.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ganttDiagram-6RSMTGT7-8SDHYxXc.js → ganttDiagram-6RSMTGT7-Bhgrzcs3.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{gitGraphDiagram-PVQCEYII-Bu7LyvTG.js → gitGraphDiagram-PVQCEYII-B8-vcbF-.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-BuQuDvuX.js → infoDiagram-5YYISTIA-DaW0unc2.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{ishikawaDiagram-YF4QCWOH-QjafGk8V.js → ishikawaDiagram-YF4QCWOH-4oYGuWP6.js} +1 -1
- package/{dist/rcs-web/assets/journeyDiagram-JHISSGLW-_FOXjXDF.js → packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-B9YXpw0W.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{kanban-definition-UN3LZRKU-CbqJqyY6.js → kanban-definition-UN3LZRKU-Cglus7wI.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{linear-H6F41eb2.js → linear-CRTJd3_G.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{main-BopVSHhX.js → main-BKbA2ddo.js} +65 -65
- package/packages/remote-control-server/web/dist/assets/main-CP31AzxJ.css +1 -0
- package/{dist/rcs-web/assets/mermaid-VLURNSYL-5FH_DIq9.js → packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-D0JeVL0B.js} +4 -4
- package/packages/remote-control-server/web/dist/assets/{mermaid.core-C004NitB.js → mermaid.core-CobUk_K5.js} +5 -5
- package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-utqEJ2a8.js → mindmap-definition-RKZ34NQL-B1s-et_p.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{notifications-DOBs9HVf.js → notifications-BrgRJuzQ.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-OlbTwDZQ.js → pieDiagram-4H26LBE5-PcBs9RT_.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{quadrantDiagram-W4KKPZXB-BOe2DhrU.js → quadrantDiagram-W4KKPZXB-B2GxITjv.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{refresh-cw-BSwpDl-7.js → refresh-cw-BwmFF3kw.js} +1 -1
- package/{dist/rcs-web/assets/requirementDiagram-4Y6WPE33-s6V1yWUG.js → packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-BfyZiasB.js} +1 -1
- package/{dist/rcs-web/assets/sankeyDiagram-5OEKKPKP-CdJD78Mx.js → packages/remote-control-server/web/dist/assets/sankeyDiagram-5OEKKPKP-Br7tRtmq.js} +1 -1
- package/{dist/rcs-web/assets/sequenceDiagram-3UESZ5HK-DvGV6Dhl.js → packages/remote-control-server/web/dist/assets/sequenceDiagram-3UESZ5HK-CN1NSfHS.js} +1 -1
- package/{dist/rcs-web/assets/stateDiagram-AJRCARHV-Bj-_Ulcn.js → packages/remote-control-server/web/dist/assets/stateDiagram-AJRCARHV-C4S8hKUx.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-BLGWynk-.js → stateDiagram-v2-BHNVJYJU-CbEMz-jf.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{timeline-definition-PNZ67QCA-B6VAH6Ka.js → timeline-definition-PNZ67QCA-mTiK0HwD.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-DUwaLI6R.js → vennDiagram-CIIHVFJN-DCe95URb.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{wardleyDiagram-YWT4CUSO-CBetJore.js → wardleyDiagram-YWT4CUSO-Cct1r0Ax.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{workerType-BF4aY_R_.js → workerType-DW9l12WG.js} +1 -1
- package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-BBnx6V66.js → xychartDiagram-2RQKCTM6-CVc0eQYa.js} +1 -1
- package/packages/remote-control-server/web/dist/index.html +2 -2
- package/dist/rcs-web/assets/SessionDetail-BbnQBjP1.js +0 -78
- package/dist/rcs-web/assets/channel-D6RbJTfV.js +0 -1
- package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-BlCPk6aR.js +0 -1
- package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-BlCPk6aR.js +0 -1
- package/dist/rcs-web/assets/main-C0n90aVY.css +0 -1
- package/packages/remote-control-server/web/dist/assets/SessionDetail-BbnQBjP1.js +0 -78
- package/packages/remote-control-server/web/dist/assets/channel-D6RbJTfV.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-BlCPk6aR.js +0 -1
- package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-BlCPk6aR.js +0 -1
- package/packages/remote-control-server/web/dist/assets/main-C0n90aVY.css +0 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
var dn=Object.defineProperty;var un=(r,t,s)=>t in r?dn(r,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):r[t]=s;var R=(r,t,s)=>un(r,typeof t!="symbol"?t+"":t,s);import{j as e,e as l}from"./vendor-DE_-CLIE.js";import{av as W,ac as mn,aD as Ut,aC as Ft,aJ as c,aF as xn,aE as Qe,aK as K,aA as le,ao as fn,an as V,af as pn,al as hn,aO as gn,aR as Z,T as yn,Q as bn,X as jn,L as Te,H as wn,I as kn,i as Kt,az as ys,N as vn,aw as ze,e as xe,S as ut,M as Nn,y as _n,ax as G,at as ae,ay as Sn,aL as Cn,G as Tn,D as En,aM as Lt,ag as Mn,a1 as Rn,ak as An,A as In,aB as $n,aG as Dn,aH as qn,Z as Bt,a0 as Pn,aN as On,b as Un,a4 as Ht,ai as Fn,K as bs,F as Kn,B as js,d as Ln,C as Bn,ab as Wt,l as Hn,a as Wn,u as Ee,w as Me,E as Qn,g as Re,f as Ae,v as Ie,s as zn}from"./main-BKbA2ddo.js";import{A as Vn,g as Qt}from"./workerType-DW9l12WG.js";import{D as fe,a as pe,c as he,d as ge,b as Gn}from"./dialog-DKk230y5.js";import{R as Yn}from"./refresh-cw-BwmFF3kw.js";import{A as Jn,U as Xn}from"./UserSearchInput-xqtDX6Bz.js";import{C as Zn}from"./copy-CFZBXuu9.js";import{E as er,A as tr}from"./ArtifactsGallery-BTVS7sar.js";import{S as sr}from"./SessionVisibilityBadge-C873QvnC.js";import{MemoriesGallery as nr}from"./MemoriesGallery-C5cT73hA.js";import{S as rr,b as ar}from"./notifications-BrgRJuzQ.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";/**
|
|
2
|
+
* @license lucide-react v0.555.0 - ISC
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the ISC license.
|
|
5
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/const or=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ws=W("chevron-right",or);/**
|
|
7
|
+
* @license lucide-react v0.555.0 - ISC
|
|
8
|
+
*
|
|
9
|
+
* This source code is licensed under the ISC license.
|
|
10
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
11
|
+
*/const ir=[["circle",{cx:"8",cy:"8",r:"6",key:"3yglwk"}],["path",{d:"M18.09 10.37A6 6 0 1 1 10.34 18",key:"t5s6rm"}],["path",{d:"M7 6h1v4",key:"1obek4"}],["path",{d:"m16.71 13.88.7.71-2.82 2.82",key:"1rbuyh"}]],lr=W("coins",ir);/**
|
|
12
|
+
* @license lucide-react v0.555.0 - ISC
|
|
13
|
+
*
|
|
14
|
+
* This source code is licensed under the ISC license.
|
|
15
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
16
|
+
*/const cr=[["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"}]],ks=W("cpu",cr);/**
|
|
17
|
+
* @license lucide-react v0.555.0 - ISC
|
|
18
|
+
*
|
|
19
|
+
* This source code is licensed under the ISC license.
|
|
20
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
21
|
+
*/const dr=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],ur=W("gauge",dr);/**
|
|
22
|
+
* @license lucide-react v0.555.0 - ISC
|
|
23
|
+
*
|
|
24
|
+
* This source code is licensed under the ISC license.
|
|
25
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
26
|
+
*/const mr=[["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"}]],xr=W("hash",mr);/**
|
|
27
|
+
* @license lucide-react v0.555.0 - ISC
|
|
28
|
+
*
|
|
29
|
+
* This source code is licensed under the ISC license.
|
|
30
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
31
|
+
*/const fr=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],pr=W("info",fr);/**
|
|
32
|
+
* @license lucide-react v0.555.0 - ISC
|
|
33
|
+
*
|
|
34
|
+
* This source code is licensed under the ISC license.
|
|
35
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
36
|
+
*/const hr=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],gr=W("layers",hr);/**
|
|
37
|
+
* @license lucide-react v0.555.0 - ISC
|
|
38
|
+
*
|
|
39
|
+
* This source code is licensed under the ISC license.
|
|
40
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
41
|
+
*/const yr=[["path",{d:"M2.992 16.342a2 2 0 0 1 .094 1.167l-1.065 3.29a1 1 0 0 0 1.236 1.168l3.413-.998a2 2 0 0 1 1.099.092 10 10 0 1 0-4.777-4.719",key:"1sd12s"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],vs=W("message-circle-question-mark",yr);/**
|
|
42
|
+
* @license lucide-react v0.555.0 - ISC
|
|
43
|
+
*
|
|
44
|
+
* This source code is licensed under the ISC license.
|
|
45
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
46
|
+
*/const br=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}],["path",{d:"M7 11h10",key:"1twpyw"}],["path",{d:"M7 15h6",key:"d9of3u"}],["path",{d:"M7 7h8",key:"af5zfr"}]],jr=W("message-square-text",br);/**
|
|
47
|
+
* @license lucide-react v0.555.0 - ISC
|
|
48
|
+
*
|
|
49
|
+
* This source code is licensed under the ISC license.
|
|
50
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
51
|
+
*/const wr=[["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"}]],kr=W("play",wr);/**
|
|
52
|
+
* @license lucide-react v0.555.0 - ISC
|
|
53
|
+
*
|
|
54
|
+
* This source code is licensed under the ISC license.
|
|
55
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
56
|
+
*/const vr=[["path",{d:"M12 22v-5",key:"1ega77"}],["path",{d:"M9 8V2",key:"14iosj"}],["path",{d:"M15 8V2",key:"18g5xt"}],["path",{d:"M18 8v5a4 4 0 0 1-4 4h-4a4 4 0 0 1-4-4V8Z",key:"osxo6l"}]],Ns=W("plug",vr);/**
|
|
57
|
+
* @license lucide-react v0.555.0 - ISC
|
|
58
|
+
*
|
|
59
|
+
* This source code is licensed under the ISC license.
|
|
60
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
61
|
+
*/const Nr=[["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"}]],_r=W("server-cog",Nr);/**
|
|
62
|
+
* @license lucide-react v0.555.0 - ISC
|
|
63
|
+
*
|
|
64
|
+
* This source code is licensed under the ISC license.
|
|
65
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
66
|
+
*/const Sr=[["path",{d:"M14 17H5",key:"gfn3mx"}],["path",{d:"M19 7h-9",key:"6i9tg"}],["circle",{cx:"17",cy:"17",r:"3",key:"18b49y"}],["circle",{cx:"7",cy:"7",r:"3",key:"dfmy0x"}]],_s=W("settings-2",Sr);/**
|
|
67
|
+
* @license lucide-react v0.555.0 - ISC
|
|
68
|
+
*
|
|
69
|
+
* This source code is licensed under the ISC license.
|
|
70
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
71
|
+
*/const Cr=[["circle",{cx:"18",cy:"5",r:"3",key:"gq8acd"}],["circle",{cx:"6",cy:"12",r:"3",key:"w7nqdw"}],["circle",{cx:"18",cy:"19",r:"3",key:"1xt0gg"}],["line",{x1:"8.59",x2:"15.42",y1:"13.51",y2:"17.49",key:"47mynk"}],["line",{x1:"15.41",x2:"8.59",y1:"6.51",y2:"10.49",key:"1n3mei"}]],Tr=W("share-2",Cr);/**
|
|
72
|
+
* @license lucide-react v0.555.0 - ISC
|
|
73
|
+
*
|
|
74
|
+
* This source code is licensed under the ISC license.
|
|
75
|
+
* See the LICENSE file in the root directory of this source tree.
|
|
76
|
+
*/const Er=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Mr=W("shield-check",Er);function mt(){return{tasks:{}}}const zt=3e4;function Be(r){const t=r.trim();if(!t)return"agent";const s=t.split(/\s+/).slice(0,2).join(" ");return s.length>40?s.slice(0,40)+"…":s}function Vt(r,t){var i,u,f,p,g,y,k,C,_,j,x,h;const s=t.subtype;if(s!=="task_started"&&s!=="task_progress"&&s!=="task_notification")return r;const n=t.task_id;if(!n)return r;const a=Date.now(),d=r.tasks[n];if(s==="task_started"){if(d)return{tasks:{...r.tasks,[n]:{...d,description:t.description??d.description,name:Be(t.description??d.description),taskType:t.task_type??d.taskType,workflowName:t.workflow_name??d.workflowName,prompt:t.prompt??d.prompt,toolUseId:t.tool_use_id??d.toolUseId,status:"running",startTime:a,evictAfter:void 0}}};const w=t.description??"";return{tasks:{...r.tasks,[n]:{taskId:n,name:Be(w),description:w,taskType:t.task_type,workflowName:t.workflow_name,prompt:t.prompt,toolUseId:t.tool_use_id,status:"running",startTime:a}}}}if(s==="task_progress"){if(!d){const w=t.description??"";return{tasks:{...r.tasks,[n]:{taskId:n,name:Be(w),description:w,toolUseId:t.tool_use_id,status:"running",startTime:a,tokenCount:(i=t.usage)==null?void 0:i.total_tokens,toolUseCount:(u=t.usage)==null?void 0:u.tool_uses,durationMs:(f=t.usage)==null?void 0:f.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...r.tasks,[n]:{...d,description:t.description??d.description,tokenCount:((p=t.usage)==null?void 0:p.total_tokens)??d.tokenCount,toolUseCount:((g=t.usage)==null?void 0:g.tool_uses)??d.toolUseCount,durationMs:((y=t.usage)==null?void 0:y.duration_ms)??d.durationMs,lastToolName:t.last_tool_name??d.lastToolName,summary:t.summary??d.summary}}}}return d?{tasks:{...r.tasks,[n]:{...d,status:t.status??"completed",endTime:a,finalSummary:t.summary??d.finalSummary,outputFile:t.output_file??d.outputFile,tokenCount:((j=t.usage)==null?void 0:j.total_tokens)??d.tokenCount,toolUseCount:((x=t.usage)==null?void 0:x.tool_uses)??d.toolUseCount,durationMs:((h=t.usage)==null?void 0:h.duration_ms)??d.durationMs,evictAfter:a+zt}}}:{tasks:{...r.tasks,[n]:{taskId:n,name:Be(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:a,endTime:a,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(k=t.usage)==null?void 0:k.total_tokens,toolUseCount:(C=t.usage)==null?void 0:C.tool_uses,durationMs:(_=t.usage)==null?void 0:_.duration_ms,evictAfter:a+zt}}}}function Ss(r,t=Date.now()){return Object.values(r.tasks).filter(s=>s.evictAfter===void 0||s.evictAfter>t).sort((s,n)=>s.startTime-n.startTime)}const Gt={in_process_teammate:0,local_bash:1,monitor_mcp:2,remote_agent:3,local_agent:4,dream:5},Yt=100;function Rr(r){const t=new Map;for(const s of r){const n=s.taskType??"",a=t.get(n);a?a.push(s):t.set(n,[s])}return[...t.entries()].sort(([s],[n])=>{const a=Gt[s]??Yt,d=Gt[n]??Yt;return a===d?s.localeCompare(n):a-d}).map(([s,n])=>({taskType:s,tasks:[...n].sort((a,d)=>a.startTime-d.startTime)}))}function Jt(r){const t=r.raw,s=t&&typeof t=="object"?t:r,n=typeof s.subtype=="string"?s.subtype:void 0;return n!=="task_started"&&n!=="task_progress"&&n!=="task_notification"?null:{subtype:n,task_id:typeof s.task_id=="string"?s.task_id:void 0,tool_use_id:typeof s.tool_use_id=="string"?s.tool_use_id:void 0,description:typeof s.description=="string"?s.description:void 0,task_type:typeof s.task_type=="string"?s.task_type:void 0,workflow_name:typeof s.workflow_name=="string"?s.workflow_name:void 0,prompt:typeof s.prompt=="string"?s.prompt:void 0,usage:s.usage&&typeof s.usage=="object"?s.usage:void 0,last_tool_name:typeof s.last_tool_name=="string"?s.last_tool_name:void 0,summary:typeof s.summary=="string"?s.summary:void 0,status:s.status==="completed"||s.status==="failed"||s.status==="stopped"?s.status:void 0,output_file:typeof s.output_file=="string"?s.output_file:void 0}}function Ar(r){if(!r||typeof r!="object"||Array.isArray(r))return null;const t=r,s={file_search:t.file_search===!0,clear:t.clear===!0,set_max_thinking_tokens:t.set_max_thinking_tokens===!0,get_context_usage:t.get_context_usage===!0,stop_task:t.stop_task===!0,set_model:t.set_model===!0,set_permission_mode:t.set_permission_mode===!0,interrupt:t.interrupt===!0,end_session:t.end_session===!0,mcp_management:t.mcp_management===!0,remote_settings:t.remote_settings===!0,rewind:t.rewind===!0,resume:t.resume===!0,set_effort:t.set_effort===!0,set_token_mode:t.set_token_mode===!0,side_question:t.side_question===!0};return Object.values(s).some(Boolean)?s:null}function Xt(r,t){const s=[];if(Array.isArray(r)){for(const n of r){if(!n||typeof n!="object")continue;const a=n;if(typeof a.name!="string"||!a.name)continue;const d=a.type==="prompt"||a.type==="local"||a.type==="local-jsx"?a.type:void 0;s.push({name:a.name,...typeof a.description=="string"&&a.description?{description:a.description}:{},...typeof a.argumentHint=="string"&&a.argumentHint?{argumentHint:a.argumentHint}:{},...d?{type:d}:{}})}if(s.length>0)return s}if(Array.isArray(t))for(const n of t)typeof n=="string"&&n&&s.push({name:n});return s}function Zt(r){const t=r.raw&&typeof r.raw=="object"&&!Array.isArray(r.raw)?r.raw:r,s=Xt(t.slash_command_details??r.slash_command_details,t.slash_commands??r.slash_commands),n=Xt(t.skill_details??r.skill_details,t.skills??r.skills),a=Ar(t.remote_capabilities??r.remote_capabilities);return s.length===0&&n.length===0&&!a?null:{commands:s,skills:n,capabilities:a}}class Ir{constructor(t){R(this,"listeners",new Set);R(this,"stateListeners",new Set);R(this,"eventSource",null);R(this,"sessionId",null);R(this,"_lastSeqNum",0);R(this,"lastFrameAt",0);R(this,"firstEventAfterOpen",!1);R(this,"watchdogTimer",null);R(this,"visibilityHandler",null);R(this,"reconnectTimer",null);R(this,"reconnectAttempts",0);R(this,"_state","idle");R(this,"opts");this.opts={stallThresholdMs:45e3,watchdogTickMs:5e3,reconnectBaseDelayMs:1e3,reconnectMaxDelayMs:15e3,maxReconnectAttempts:6,...t}}get state(){return this._state}onEvent(t){return this.listeners.add(t),()=>this.listeners.delete(t)}onStateChange(t){return this.stateListeners.add(t),()=>this.stateListeners.delete(t)}connect(t){this.stopReconnectTimer(),this.reconnectAttempts=0,this.sessionId=t,this.openStream()}openStream(){if(this.closeStream(),!this.sessionId)return;this.setState("connecting");const t=this._lastSeqNum>0?`/web/sessions/${this.sessionId}/events?fromSeqNum=${this._lastSeqNum}`:`/web/sessions/${this.sessionId}/events`,s=new EventSource(t,{withCredentials:!0});this.eventSource=s,this.lastFrameAt=Date.now(),this.firstEventAfterOpen=!0,s.addEventListener("open",()=>{this.lastFrameAt=Date.now(),this.reconnectAttempts=0,this.firstEventAfterOpen=!0,this.setState("open")}),s.addEventListener("ping",()=>{this.lastFrameAt=Date.now()}),s.addEventListener("message",n=>{this.lastFrameAt=Date.now();try{const a=JSON.parse(n.data);if(this.firstEventAfterOpen&&(this.firstEventAfterOpen=!1,typeof a.seqNum=="number"&&a.seqNum<this._lastSeqNum&&(this._lastSeqNum=a.seqNum-1,this.notifyResync())),a.seqNum!==void 0&&a.seqNum<=this._lastSeqNum)return;a.seqNum!==void 0&&(this._lastSeqNum=a.seqNum);for(const d of this.listeners)d(a)}catch{}}),s.addEventListener("error",()=>{s.readyState===EventSource.CLOSED&&this.scheduleReconnect()}),this.startWatchdog()}disconnect(){this.sessionId=null,this.stopReconnectTimer(),this.closeStream(),this._lastSeqNum=0,this.reconnectAttempts=0,this.setState("idle")}closeStream(){this.stopWatchdog(),this.eventSource&&(this.eventSource.close(),this.eventSource=null)}startWatchdog(){this.stopWatchdog(),this.watchdogTimer=setInterval(()=>{this.probeStall()},this.opts.watchdogTickMs),typeof document<"u"&&(this.visibilityHandler=()=>{document.visibilityState==="visible"&&this.probeStall()},document.addEventListener("visibilitychange",this.visibilityHandler))}probeStall(){const t=this.eventSource;!t||t.readyState!==EventSource.OPEN||Date.now()-this.lastFrameAt<=this.opts.stallThresholdMs||this.scheduleReconnect()}stopWatchdog(){this.watchdogTimer&&(clearInterval(this.watchdogTimer),this.watchdogTimer=null),this.visibilityHandler&&(typeof document<"u"&&document.removeEventListener("visibilitychange",this.visibilityHandler),this.visibilityHandler=null)}stopReconnectTimer(){this.reconnectTimer&&(clearTimeout(this.reconnectTimer),this.reconnectTimer=null)}scheduleReconnect(){if(this.reconnectTimer||!this.sessionId)return;if(this.closeStream(),this.reconnectAttempts++,this.reconnectAttempts>this.opts.maxReconnectAttempts){this.setState("failed");return}this.setState("reconnecting");const t=Math.min(this.opts.reconnectBaseDelayMs*2**(this.reconnectAttempts-1),this.opts.reconnectMaxDelayMs),s=Math.max(0,t+t*.25*(2*Math.random()-1));this.reconnectTimer=setTimeout(()=>{this.reconnectTimer=null,this.reconnect()},s)}async reconnect(){this.sessionId&&(await gn(),this.sessionId&&this.openStream())}setState(t){if(this._state!==t){this._state=t;for(const s of this.stateListeners)s(t,{})}}notifyResync(){for(const t of this.stateListeners)t(this._state,{resync:!0})}}const ce=new Ir;function lt(r){if(typeof r.content=="string")return r.content;if(r.message&&typeof r.message=="object"){const t=r.message;if(typeof t.content=="string")return t.content;if(Array.isArray(t.content))return t.content.filter(s=>s.type==="text"&&typeof s.text=="string").map(s=>s.text).join("")}return""}function es(r,t){for(let s=r.length-1;s>=0;s--){const n=r[s];if(n&&n.type==="tool_call"&&n.toolCall.id===t)return s}return-1}const ct="streaming-";function ts(r){const t=r.message;if(!t||typeof t!="object"||!Array.isArray(t.content))return"";const s=[];for(const n of t.content)if((n==null?void 0:n.type)==="thinking"){const a=typeof n.thinking=="string"&&n.thinking||typeof n.text=="string"&&n.text||"";a&&s.push(a)}return s.join("")}function ss(r){return r.filter(t=>typeof t.subject=="string"&&t.subject).map(t=>({content:t.subject,priority:"medium",status:t.status==="completed"?"completed":t.status==="in_progress"?"in_progress":"pending"}))}function ns(r){if(!r||typeof r!="object")return"";const t=r;if(typeof t.target_event_id=="string"&&t.target_event_id)return t.target_event_id;const s=t.raw;if(s&&typeof s=="object"&&!Array.isArray(s)){const n=s.target_event_id;if(typeof n=="string"&&n)return n}return""}class $r{constructor(t,s,n){R(this,"sessionId");R(this,"setEntries");R(this,"unsub",null);R(this,"unsubState",null);R(this,"onStatusChange");R(this,"onError");R(this,"onPermissionRequest");R(this,"onModelsStateChange");R(this,"onSubagentUpdate");R(this,"onControlResponse");R(this,"onPermissionModeChange");R(this,"onUsageChange");R(this,"onElicitationRequest");R(this,"onWorkerInfoChange");R(this,"onTurnStart");R(this,"subagentState",mt());R(this,"seenUuids",new Set);R(this,"seenToolCallIds",new Set);R(this,"pendingToolCallIds",new Set);R(this,"pendingPermissionToolIds",new Map);R(this,"postedUserUuids",new Set);R(this,"pendingControlRequests",new Map);R(this,"turnEnded",!1);R(this,"userSinceTurnEnd",!1);R(this,"turnStartedAt",null);R(this,"closed",!1);this.sessionId=t,this.setEntries=s,this.onStatusChange=n==null?void 0:n.onStatusChange,this.onError=n==null?void 0:n.onError,this.onPermissionRequest=n==null?void 0:n.onPermissionRequest,this.onModelsStateChange=n==null?void 0:n.onModelsStateChange,this.onSubagentUpdate=n==null?void 0:n.onSubagentUpdate,this.onControlResponse=n==null?void 0:n.onControlResponse,this.onPermissionModeChange=n==null?void 0:n.onPermissionModeChange,this.onUsageChange=n==null?void 0:n.onUsageChange,this.onElicitationRequest=n==null?void 0:n.onElicitationRequest,this.onWorkerInfoChange=n==null?void 0:n.onWorkerInfoChange,this.onTurnStart=n==null?void 0:n.onTurnStart}markClosed(){this.closed=!0}setTurnStartedAt(t){var s;this.turnStartedAt!==t&&(this.turnStartedAt=t,(s=this.onTurnStart)==null||s.call(this,t))}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var j,x,h,w,S,I,T;const{events:t}=await mn(this.sessionId);if(!t||t.length===0)return;const s=new Set;for(const b of t){if(b.type!=="user"||b.direction==="inbound")continue;const E=(j=b.payload)==null?void 0:j.uuid;typeof E=="string"&&E&&s.add(E)}const n=[];let a=null;const d=()=>{a&&(n.push(a),a=null)};for(const b of t){const E=b.payload||{},$=E.uuid;if(typeof $=="string"&&$&&this.seenUuids.add($),b.type==="tool_use"){const A=E.tool_call_id;typeof A=="string"&&A&&this.seenToolCallIds.add(A)}if(b.type==="user"){if(b.direction==="inbound"){const N=E.uuid;if(typeof N!="string"||!N||s.has(N))continue}d();const A=lt(E);A&&n.push({type:"user_message",id:b.id||`hist-user-${n.length}`,content:A})}else if(b.type==="assistant"){d();const A=lt(E);if(Ut(A))continue;const N=ts(E),O=[],L=E.message;if(L&&typeof L=="object"&&Array.isArray(L.content)){for(const Y of L.content)if(Y.type==="tool_use"){const se=Y.id;se&&this.seenToolCallIds.add(se),O.push({type:"tool_call",toolCall:{id:se||`hist-tool-${n.length}`,title:Y.name||"tool",status:"complete",rawInput:Y.input||{}}})}}if(A||N||O.length>0){a={type:"assistant_message",id:b.id||`hist-asst-${n.length}`,chunks:[...N?[{type:"thought",text:N}]:[],...A?[{type:"message",text:A}]:[]]},n.push(a);for(const Y of O)n.push(Y);a=null}}else if(b.type==="conversation_rewound"){const A=ns(E);if(A){const N=n.findIndex(O=>Ft(O)===A);N>=0&&(n.length=N)}}else if(b.type==="tool_use"){const A=E,N={type:"tool_call",toolCall:{id:A.tool_call_id||`hist-tool-${n.length}`,title:A.tool_name||"tool",status:"complete",rawInput:A.tool_input||{}}};n.push(N)}else if(b.type==="tool_result"){const A=E,N=es(n,A.tool_call_id||"");if(N>=0){const O=n[N];n[N]={type:"tool_call",toolCall:{...O.toolCall,rawOutput:{output:A.content||A.output||""}}}}}}d();let i=null;for(const b of t){if(b.type!=="task_state")continue;const E=b.payload||{};Array.isArray(E.tasks)&&(i=E.tasks)}if(i&&i.length>0){const b=ss(i);b.length>0&&n.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:b})}this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries(n);let u=null,f=null,p=null,g=null,y=0,k=0;for(const b of t){const E=b.payload||{};if(typeof b.createdAt=="number"&&(b.createdAt>k&&(k=b.createdAt),b.type==="user"&&g!=="user"&&b.createdAt>0&&(y=b.createdAt)),b.type==="user"?g="user":(b.type==="result"||b.type==="result_success"||b.type==="interrupt")&&(g="turn_end"),b.type==="system"&&(E.subtype==="init"||((x=E.raw)==null?void 0:x.subtype)==="init")&&(f=Zt(E)),b.type==="models_state"){const $=E.raw,A=$&&typeof $=="object"?$.models_state:E.models_state;A&&Array.isArray(A.availableModels)&&typeof A.currentModelId=="string"&&(u=A)}else if(b.type==="result"||b.type==="result_success"){const $=E.usage,A=typeof E.total_cost_usd=="number"?E.total_cost_usd:null;($||A!==null)&&(p={inputTokens:(($==null?void 0:$.input_tokens)??0)+(($==null?void 0:$.cache_read_input_tokens)??0)+(($==null?void 0:$.cache_creation_input_tokens)??0),outputTokens:($==null?void 0:$.output_tokens)??0,totalCostUsd:A})}}let C=!1,_=mt();for(const b of t){if(b.type!=="system")continue;const E=Jt(b.payload||{});E&&(_=Vt(_,E),C=!0)}C&&(this.subagentState=_,(h=this.onSubagentUpdate)==null||h.call(this,this.subagentState)),u&&((w=this.onModelsStateChange)==null||w.call(this,u)),f&&((S=this.onWorkerInfoChange)==null||S.call(this,f)),p&&((I=this.onUsageChange)==null||I.call(this,p)),this.turnEnded=g==="turn_end",this.userSinceTurnEnd=g==="user",this.setTurnStartedAt(!this.closed&&g==="user"&&y>0&&k>=y?Date.now()-(k-y):null),this.turnEnded&&!this.closed&&((T=this.onStatusChange)==null||T.call(this,"idle"))}connectSSE(){ce.connect(this.sessionId),this.unsub=ce.onEvent(t=>this.handleEvent(t)),this.unsubState=ce.onStateChange((t,s)=>{s.resync&&!this.closed&&this.loadHistory().catch(()=>{})})}disconnect(){this.unsub&&(this.unsub(),this.unsub=null),this.unsubState&&(this.unsubState(),this.unsubState=null),ce.disconnect()}handleEvent(t){var a,d,i,u,f,p,g,y,k,C,_,j;const s=t.type,n=t.payload||{};switch(s){case"user":{if(this.applyEmbeddedToolResults(n),this.userSinceTurnEnd=!0,!this.closed&&this.turnStartedAt===null&&this.setTurnStartedAt(Date.now()),t.direction==="inbound"){const x=n.uuid;if(typeof x!="string"||!x||this.postedUserUuids.has(x)||this.seenUuids.has(x))break;this.seenUuids.add(x);const h=lt(n);h&&this.setEntries(w=>[...w,{type:"user_message",id:t.id||`user-${Date.now()}`,content:h}])}break}case"assistant":{const x=n.uuid;if(typeof x=="string"&&x){if(this.seenUuids.has(x))break;this.seenUuids.add(x)}const h=typeof n.content=="string"?n.content:"";if(Ut(h))break;const w=ts(n);this.setEntries(I=>{const T=I[I.length-1];if((T==null?void 0:T.type)==="assistant_message"&&T.id.startsWith(ct))return[...I.slice(0,-1),{...T,id:`assistant-${Date.now()}`,chunks:[...w?[{type:"thought",text:w}]:[],{type:"message",text:h}]}];if((T==null?void 0:T.type)==="assistant_message"){const b=T.chunks[T.chunks.length-1];return(b==null?void 0:b.type)==="message"?[...I.slice(0,-1),{...T,chunks:[...T.chunks.slice(0,-1),{type:"message",text:b.text+h}]}]:[...I.slice(0,-1),{...T,chunks:[...T.chunks,{type:"message",text:h}]}]}if(h&&h.trim()||w){const b={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...w?[{type:"thought",text:w}]:[],...h?[{type:"message",text:h}]:[]]};return[...I,b]}return I});const S=n.message;if(S&&typeof S=="object"&&Array.isArray(S.content)){const I=S.content.filter(T=>T.type==="tool_use");for(const T of I){const b=T.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(b))continue;this.seenToolCallIds.add(b),this.pendingToolCallIds.add(b);const E={id:b,title:T.name||"tool",status:"running",rawInput:T.input||{}};this.setEntries($=>[...$,{type:"tool_call",toolCall:E}])}}break}case"tool_use":{const x=n,h=x.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(h))break;this.seenToolCallIds.add(h),this.pendingToolCallIds.add(h);const w={id:h,title:x.tool_name||"tool",status:"running",rawInput:x.tool_input||{}};this.setEntries(S=>[...S,{type:"tool_call",toolCall:w}]);break}case"tool_result":{const x=n;this.applyToolResult(x.tool_call_id||"",x.content??x.output);break}case"interrupt":{this.finalizePendingToolCalls("canceled"),this.turnEnded=!0,this.userSinceTurnEnd=!1,this.setTurnStartedAt(null),this.closed||(a=this.onStatusChange)==null||a.call(this,"idle");break}case"control_request":case"permission_request":{const x=n.request;if(x&&x.subtype==="can_use_tool"){const h=n.request_id||"",w=x.tool_name||"unknown",S=x.input||x.tool_input||{},I=x.description||"",T=Array.isArray(x.permission_suggestions)?x.permission_suggestions:[];this.setEntries(b=>{const E=[...b].reverse().findIndex($=>$.type==="tool_call");if(E>=0){const $=b.length-1-E,A=b[$];if(A.toolCall.status==="running")return this.pendingPermissionToolIds.set(h,A.toolCall.id),b.map((N,O)=>O===$?{type:"tool_call",toolCall:{...A.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:h,options:[]}}}:N)}return b}),(d=this.onPermissionRequest)==null||d.call(this,{requestId:h,toolName:w,toolInput:S,description:I,suggestions:T})}else x&&x.subtype==="elicitation"&&((i=this.onElicitationRequest)==null||i.call(this,{requestId:n.request_id||"",serverName:x.mcp_server_name||"",message:x.message||"",mode:x.mode==="url"?"url":"form",url:typeof x.url=="string"?x.url:void 0,requestedSchema:x.requested_schema||void 0}));break}case"conversation_rewound":{const x=ns(n);x&&(this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries(h=>{const w=h.findIndex(S=>Ft(S)===x);return w===-1?h:h.slice(0,w)}));break}case"session_status":{if(xn(n)){this.pendingToolCallIds.clear(),this.pendingPermissionToolIds.clear(),this.setEntries([]);break}if(typeof n.status=="string"){if(Qe(n.status))this.closed=!0,this.finalizePendingToolCalls("canceled");else if(this.closed)break;if(n.status==="running"&&this.turnEnded&&!this.userSinceTurnEnd)break;(u=this.onStatusChange)==null||u.call(this,n.status)}break}case"error":{const x=String(n.message||n.content||"Unknown error");(f=this.onError)==null||f.call(this,x);break}case"models_state":{const x=n.raw,h=typeof x=="object"&&x!==null?x.models_state:n.models_state;h&&Array.isArray(h.availableModels)&&typeof h.currentModelId=="string"&&((p=this.onModelsStateChange)==null||p.call(this,h));break}case"system":{const x=n.raw,h=x&&typeof x=="object"?x:n,w=typeof h.subtype=="string"?h.subtype:void 0,S=Jt(n);S&&(this.subagentState=Vt(this.subagentState,S),(g=this.onSubagentUpdate)==null||g.call(this,this.subagentState));const I=typeof h.permissionMode=="string"?h.permissionMode:typeof n.permissionMode=="string"?n.permissionMode:null;if(I&&((y=this.onPermissionModeChange)==null||y.call(this,I)),w==="init"){const T=Zt(n);T&&((k=this.onWorkerInfoChange)==null||k.call(this,T))}break}case"control_response":{const x=n.response;if(x&&typeof x=="object"){const h=typeof x.request_id=="string"?x.request_id:"",w=typeof x.subtype=="string"?x.subtype:"";if(h){(C=this.onControlResponse)==null||C.call(this,{subtype:w,requestId:h,error:typeof x.error=="string"?x.error:void 0});const S=this.pendingControlRequests.get(h);S&&(this.pendingControlRequests.delete(h),S({data:w==="success"&&x.response&&typeof x.response=="object"?x.response:null,...w==="error"&&typeof x.error=="string"?{error:x.error}:{}}))}}break}case"stream_event":{const x=n.event;if(!x||typeof x.type!="string")break;if(x.type==="content_block_delta"){const h=x.delta;if(!h||typeof h.type!="string")break;const w=h.type==="text_delta"?"message":h.type==="thinking_delta"?"thought":null;if(!w)break;const S=h.text??h.thinking;if(typeof S!="string"||!S)break;this.appendStreamingDelta(w,S)}break}case"partial_assistant":{const x=typeof n.content=="string"?n.content:"";x&&this.appendStreamingDelta("message",x);break}case"result":case"result_success":{this.turnEnded=!0,this.userSinceTurnEnd=!1,this.setTurnStartedAt(null),this.finalizePendingToolCalls(n.is_error?"canceled":"complete"),this.closed||(_=this.onStatusChange)==null||_.call(this,"idle");const x=n.usage,h=typeof n.total_cost_usd=="number"?n.total_cost_usd:null;if(x||h!==null){const b=((x==null?void 0:x.input_tokens)??0)+((x==null?void 0:x.cache_read_input_tokens)??0)+((x==null?void 0:x.cache_creation_input_tokens)??0);(j=this.onUsageChange)==null||j.call(this,{inputTokens:b,outputTokens:(x==null?void 0:x.output_tokens)??0,totalCostUsd:h})}const w=typeof n.subtype=="string"?n.subtype:"",S=n.raw&&typeof n.raw=="object"?n.raw:void 0,T=(typeof n.result=="string"?n.result:typeof(S==null?void 0:S.result)=="string"?S.result:"").trim();w.startsWith("error_")&&T&&this.setEntries(b=>[...b,{type:"command_output",id:`exit-error-${typeof n.uuid=="string"?n.uuid:Date.now()}`,commandName:"worker",inputText:"",title:c("adapter.workerCrashed"),outputText:T,variant:"error"}]);break}case"task_state":{const x=Array.isArray(n.tasks)?n.tasks:[];if(x.length===0)break;const h=ss(x);if(h.length===0)break;this.setEntries(w=>[...w.filter(I=>I.type!=="plan"),{type:"plan",id:`plan-${n.task_list_id||Date.now()}`,entries:h}]);break}}}applyEmbeddedToolResults(t){const s=t.message;if(!(!s||typeof s!="object"||!Array.isArray(s.content)))for(const n of s.content)!n||n.type!=="tool_result"||this.applyToolResult(n.tool_use_id||"",n.content??n.output)}applyToolResult(t,s){t&&(this.pendingToolCallIds.delete(t),this.setEntries(n=>{const a=es(n,t);if(a<0)return n;const d=n[a];return d.toolCall.status!=="running"&&d.toolCall.status!=="waiting_for_confirmation"?n:n.map((i,u)=>u===a?{type:"tool_call",toolCall:{...d.toolCall,status:"complete",permissionRequest:void 0,rawOutput:{output:s||""}}}:i)}))}finalizePendingToolCalls(t){if(this.pendingToolCallIds.size===0)return;const s=this.pendingToolCallIds;this.pendingToolCallIds=new Set,this.setEntries(n=>n.map(a=>a.type!=="tool_call"||!s.has(a.toolCall.id)?a:{type:"tool_call",toolCall:{...a.toolCall,status:t,permissionRequest:void 0}}))}appendStreamingDelta(t,s){this.setEntries(n=>{const a=n[n.length-1];if((a==null?void 0:a.type)==="assistant_message"&&a.id.startsWith(ct)){const i=a.chunks[a.chunks.length-1];return(i==null?void 0:i.type)===t?[...n.slice(0,-1),{...a,chunks:[...a.chunks.slice(0,-1),{type:t,text:i.text+s}]}]:[...n.slice(0,-1),{...a,chunks:[...a.chunks,{type:t,text:s}]}]}const d={type:"assistant_message",id:`${ct}${Date.now()}`,chunks:[{type:t,text:s}]};return[...n,d]})}async sendMessage(t,s,n){var p;const a=s&&s.length>0,d=n&&n.length>0;if(!t.trim()&&!a&&!d)return;const i={type:"user_message",id:`user-${Date.now()}`,content:t,images:a?s:void 0,attachments:d?n:void 0};this.setEntries(g=>[...g,i]);const u=[];if(t&&u.push({type:"text",text:t}),a)for(const g of s)u.push({type:"image",source:{type:"base64",media_type:g.mimeType,data:g.data}});if(d){for(const g of n)if(g.kind==="text"||g.kind==="table"){const y=`📎 ${g.name}${g.size!=null?` (${Dr(g.size)})`:""}`,k=g.textContent||c("attach.emptyFile");u.push({type:"text",text:`${y}
|
|
77
|
+
\`\`\`
|
|
78
|
+
${k}
|
|
79
|
+
\`\`\``})}else if(g.kind==="directory"){const y=g.files!=null?`${K("attach.directoryHeader",{name:g.name})} ${K("attach.fileCount",{n:g.files.length})}`:K("attach.directoryHeader",{name:g.name}),k=g.textContent||c("attach.emptyDirectory");u.push({type:"text",text:`${y}
|
|
80
|
+
${k}`})}}const f=u.length===1&&u[0].type==="text"?u[0].text||t:u.length>0?u:t;try{const g=le();this.postedUserUuids.add(g);const y=await fn(this.sessionId,{type:"user",uuid:g,content:t,message:{content:f}}),k=(p=y==null?void 0:y.event)==null?void 0:p.id;k&&this.setEntries(C=>C.map(_=>_.type==="user_message"&&_.id===i.id?{..._,id:k}:_))}catch(g){throw this.setEntries(y=>y.filter(k=>!(k.type==="user_message"&&k.id===i.id))),g}}async respondPermission(t,s,n){await V(this.sessionId,{type:"permission_response",approved:s,request_id:t,...n});const a=this.pendingPermissionToolIds.get(t);this.pendingPermissionToolIds.delete(t),a&&!s&&this.pendingToolCallIds.delete(a),this.setEntries(d=>d.map(i=>{var u;return i.type!=="tool_call"||((u=i.toolCall.permissionRequest)==null?void 0:u.requestId)!==t?i:{type:"tool_call",toolCall:{...i.toolCall,status:s?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.finalizePendingToolCalls("canceled"),await pn(this.sessionId)}async setPermissionMode(t){const s=le();return await V(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_permission_mode",mode:t}}),s}async controlRoundTrip(t,s=8e3){const n=le(),a=new Promise(i=>{this.pendingControlRequests.set(n,i)}),d=setTimeout(()=>{const i=this.pendingControlRequests.get(n);i&&(this.pendingControlRequests.delete(n),i({data:null,error:"timeout"}))},s);try{return await V(this.sessionId,{type:"control_request",request_id:n,request:t}),await a}catch(i){throw this.pendingControlRequests.delete(n),i}finally{clearTimeout(d)}}async searchFiles(t,s=20){const n=await this.controlRoundTrip({subtype:"file_search",query:t,limit:s});try{if(!n.data||!Array.isArray(n.data.suggestions))return[];const a=[];for(const d of n.data.suggestions)d&&typeof d=="object"&&typeof d.path=="string"&&a.push(d.path);return a}catch{return[]}}async respondElicitation(t,s,n){await V(this.sessionId,{type:"permission_response",approved:s==="accept",request_id:t,response:{subtype:"success",request_id:t,response:{action:s,...n?{content:n}:{}}}})}async askSideQuestion(t){const s=await this.controlRoundTrip({subtype:"side_question",question:t},12e4);if(s.error||!s.data)return null;const n=s.data.response;return typeof n=="string"?n:null}async listResumableSessions(){const t=await this.controlRoundTrip({subtype:"list_sessions"});if(!t.data||!Array.isArray(t.data.sessions))throw new Error(t.error??"list_sessions failed");const s=[];for(const n of t.data.sessions){if(!n||typeof n!="object")continue;const a=n;typeof a.session_id!="string"||!a.session_id||s.push({sessionId:a.session_id,title:typeof a.title=="string"&&a.title?a.title:a.session_id.slice(0,8),modified:typeof a.modified=="number"?a.modified:0,...typeof a.created_at=="number"?{createdAt:a.created_at}:{},...typeof a.git_branch=="string"&&a.git_branch?{gitBranch:a.git_branch}:{}})}return s}async resumeSession(t){const s=await this.controlRoundTrip({subtype:"resume_session",session_id:t},3e4);if(!s.data)throw new Error(s.error??"resume_session failed");return{title:typeof s.data.title=="string"?s.data.title:null,messageCount:typeof s.data.message_count=="number"?s.data.message_count:0}}async setEffort(t){const s=le();return await V(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_effort",...t?{effort:t}:{effort:null}}}),s}async setTokenMode(t){const s=le();return await V(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_token_mode",mode:t}}),s}async setThinkingBudget(t){const s=le();return await V(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_max_thinking_tokens",max_thinking_tokens:t}}),s}async getContextUsage(){const t=await this.controlRoundTrip({subtype:"get_context_usage"});try{if(!t.data)return null;const s=t.data.totalTokens,n=t.data.rawMaxTokens,a=t.data.percentage;if(typeof s!="number"||typeof n!="number")return null;const d=t.data.categories,i=Array.isArray(d)?d.filter(u=>!!u&&typeof u=="object"&&typeof u.name=="string").map(u=>({name:u.name,tokens:typeof u.tokens=="number"?u.tokens:0,...u.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:s,rawMaxTokens:n,percentage:typeof a=="number"?a:0,...typeof t.data.model=="string"&&t.data.model?{model:t.data.model}:{},...i&&i.length>0?{categories:i}:{}}}catch{return null}}async stopSubagent(t){const s=await this.controlRoundTrip({subtype:"stop_task",task_id:t});try{return s.error?{ok:!1,error:s.error==="timeout"?c("adapter.stopTimeout"):s.error}:{ok:!0}}catch{return{ok:!1,error:c("adapter.stopFailed")}}}async getMcpServers(){var a;const s=(a=(await this.controlRoundTrip({subtype:"mcp_status"})).data)==null?void 0:a.mcpServers;if(!Array.isArray(s))return[];const n=[];for(const d of s){if(!d||typeof d!="object")continue;const i=d;if(typeof i.name!="string"||!i.name)continue;const u=i.status;if(u!=="connected"&&u!=="failed"&&u!=="needs-auth"&&u!=="pending"&&u!=="disabled")continue;const f=i.serverInfo,p=i.config;n.push({name:i.name,status:u,...f&&typeof f.name=="string"&&typeof f.version=="string"?{serverInfo:{name:f.name,version:f.version}}:{},...typeof i.error=="string"&&i.error?{error:i.error}:{},...typeof(p==null?void 0:p.url)=="string"&&p.url?{url:p.url}:{},...Array.isArray(i.tools)?{toolCount:i.tools.length}:{}})}return n}async toggleMcpServer(t,s){const n=await this.controlRoundTrip({subtype:"mcp_toggle",serverName:t,enabled:s},15e3);return n.error?{ok:!1,error:n.error==="timeout"?c("adapter.requestTimeout"):n.error}:{ok:!0}}async reconnectMcpServer(t){const s=await this.controlRoundTrip({subtype:"mcp_reconnect",serverName:t},2e4);return s.error?{ok:!1,error:s.error==="timeout"?c("adapter.requestTimeout"):s.error}:{ok:!0}}async getRemoteSettings(){const s=(await this.controlRoundTrip({subtype:"get_settings"})).data;if(!s)return null;const n=s.applied,a=s.effective&&typeof s.effective=="object"&&!Array.isArray(s.effective)?s.effective:{},d=s.sources,i=[];if(Array.isArray(d))for(const u of d){if(!u||typeof u!="object")continue;const f=u;typeof f.source=="string"&&i.push({source:f.source,settings:f.settings&&typeof f.settings=="object"&&!Array.isArray(f.settings)?f.settings:{}})}return{applied:{model:typeof(n==null?void 0:n.model)=="string"?n.model:null,effort:typeof(n==null?void 0:n.effort)=="string"?n.effort:null,tokenMode:typeof(n==null?void 0:n.tokenMode)=="string"?n.tokenMode:null},effective:a,sources:i}}async applyFlagSettings(t){const s=await this.controlRoundTrip({subtype:"apply_flag_settings",settings:t},15e3);return s.error?{ok:!1,error:s.error==="timeout"?c("adapter.requestTimeout"):s.error}:{ok:!0}}async rewindToMessage(t){await hn(this.sessionId,t)}async endSession(t){await V(this.sessionId,{type:"control_request",request_id:le(),request:{subtype:"end_session",...t?{reason:t}:{}}})}}function Dr(r){return r<1024?`${r} B`:r<1024*1024?`${(r/1024).toFixed(1)} KB`:`${(r/(1024*1024)).toFixed(1)} MB`}function He({onBack:r,title:t,meta:s,actions:n}){return Z(),e.jsx("div",{className:"flex-shrink-0 border-b border-nav-rule bg-surface-1/80 backdrop-blur-md",children:e.jsxs("div",{className:"mx-auto flex h-12 w-full page-measure items-center gap-2 px-4 sm:px-8",children:[e.jsx("button",{type:"button",onClick:r,"aria-label":c("nav.dashboard"),title:c("nav.dashboard"),className:"-mx-2 flex-shrink-0 rounded-md px-2 py-1 text-xs text-text-muted transition hover:-translate-x-0.5 hover:bg-surface-2 hover:text-text-primary",children:c("nav.dashboard")}),e.jsx("span",{className:"mx-1 h-4 w-px flex-shrink-0 bg-border","aria-hidden":"true"}),e.jsxs("div",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t,s&&e.jsx("div",{className:"flex flex-shrink-0 items-center gap-2",children:s})]}),n&&e.jsx("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:n}),e.jsx("span",{className:"mx-1 h-4 w-px flex-shrink-0 bg-border","aria-hidden":"true"}),e.jsx(yn,{}),e.jsx(bn,{onSettingsClick:()=>{window.history.pushState(null,"","/settings"),window.dispatchEvent(new PopStateEvent("popstate"))}})]})})}const rs="rcs:subagent-panel:collapsed";function qr(r){if(r<1e3)return"0s";const t=Math.floor(r/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60),n=t%60;if(s<60)return n?`${s}m${n}s`:`${s}m`;const a=Math.floor(s/60),d=s%60;return d?`${a}h${d}m`:`${a}h`}function Pr(r){return r===void 0||r<=0?"":r<1e3?`${r}`:r<1e6?`${(r/1e3).toFixed(r<1e4?1:0)}k`:`${(r/1e6).toFixed(1)}M`}function Or({status:r}){return r==="running"?e.jsx(Te,{className:"h-3 w-3 animate-spin text-brand-text"}):r==="completed"?e.jsx(kr,{className:"h-3 w-3 text-status-success"}):r==="failed"||r==="stopped"?e.jsx(wn,{className:"h-3 w-3 text-status-error"}):null}function Cs({task:r,onStopTask:t,fullText:s}){const n=r.status==="running",a=n?r.durationMs??Date.now()-r.startTime:(r.endTime??Date.now())-r.startTime,d=Pr(r.tokenCount),i=r.toolUseCount!==void 0&&r.toolUseCount>0?`${r.toolUseCount} tool${r.toolUseCount>1?"s":""}`:"",u=r.summary||r.description||"(no description)";return e.jsxs("div",{className:"group/task 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(Or,{status:r.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:r.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:qr(a)})]}),e.jsx("div",{className:`mt-0.5 text-text-secondary ${s?"line-clamp-2 break-words":"truncate"}`,children:u}),(d||i||r.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex items-center gap-x-2 overflow-hidden whitespace-nowrap font-mono text-[10px] text-text-muted",children:[d&&e.jsxs("span",{className:"flex-shrink-0",children:["↕ ",d," tok"]}),i&&e.jsxs("span",{className:"flex-shrink-0",children:["· ",i]}),r.lastToolName&&e.jsxs("span",{className:"min-w-0 truncate",children:["· last: ",r.lastToolName]})]}),!n&&r.finalSummary&&e.jsx("div",{className:"mt-1 line-clamp-2 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:r.finalSummary})]}),n&&t&&e.jsx("button",{type:"button",onClick:()=>t(r.taskId),title:c("subagent.stop"),className:"mt-0.5 flex-shrink-0 rounded p-0.5 text-text-muted opacity-0 transition-opacity hover:bg-status-error/10 hover:text-status-error focus:opacity-100 group-hover/task:opacity-100",children:e.jsx(jn,{className:"h-3.5 w-3.5"})})]})}function Ur({state:r,onStopTask:t}){const[s,n]=l.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(rs)==="1"}catch{return!1}}),a=()=>{n(y=>{const k=!y;try{window.localStorage.setItem(rs,k?"1":"0")}catch{}return k})},d=Object.values(r.tasks).some(y=>y.status==="running"),i=Object.values(r.tasks).some(y=>y.status!=="running"&&y.evictAfter!==void 0),[,u]=l.useState(0);l.useEffect(()=>{if(!d&&!i)return;const y=setInterval(()=>{u(k=>k+1)},1e3);return()=>clearInterval(y)},[d,i]);const f=Ss(r);if(f.length===0)return null;const p=f.filter(y=>y.status==="running").length,g=p>0?`${p} running`:`${f.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:a,"aria-expanded":!s,"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(ws,{className:`h-3 w-3 transition-transform ${s?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:g})]}),!s&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:f.map(y=>e.jsx(Cs,{task:y,onStopTask:t},y.taskId))})]})})}function Fr(r){if(!r)return"never";const t=Math.max(0,Date.now()-r);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 Kr(r){return r?Date.now()-r<6e4:!1}function Lr({onClose:r,session:t,liveStatus:s,pendingPermissions:n,onInterrupt:a,onDelete:d,subagentState:i,onStopTask:u,onEndSession:f}){const[p,g]=l.useState(!1),y=async()=>{await navigator.clipboard.writeText(t.id),g(!0),setTimeout(()=>g(!1),1500)},[k,C]=l.useState(!1),_=async()=>{if(!(!f||k)&&window.confirm(c("task.endConfirm"))){C(!0);try{await f(),r()}catch{C(!1)}}},j=n.length,x=t.worker,h=t.work_item,w=t.environment;return e.jsx(fe,{open:!0,onOpenChange:S=>{S||r()},children:e.jsxs(pe,{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(he,{children:e.jsx(ge,{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(Vn,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(kn,{status:s||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:x&&(Kr(x.last_heartbeat_at)?"· worker online":"· worker offline")})]}),e.jsxs("dl",{className:"space-y-1 text-xs text-text-muted",children:[x&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Kt,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:Fr(x.last_heartbeat_at)})]}),w&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(ks,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:w.machine_name||w.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Kt,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ys(t.created_at)})]})]})]}),e.jsx(Wr,{state:i,onStopTask:u}),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(Te,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),j>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[j," permission request",j>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(_r,{className:"h-3.5 w-3.5"}),"Quick Actions"]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:a,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"}),f&&e.jsx("button",{onClick:_,disabled:k,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 disabled:opacity-50 disabled:cursor-not-allowed",title:c("task.endHint"),children:k?"Ending…":"End session"}),e.jsxs("button",{onClick:d,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(vn,{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(xr,{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:y,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:p?"✓":"⧉"})]})]}),h&&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:h.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:h.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})]}),w&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:w.worker_type})]})]})]})]})]})})}const Br={in_process_teammate:"task.type.teammates",local_bash:"task.type.shells",monitor_mcp:"task.type.monitors",remote_agent:"task.type.remoteAgents",local_agent:"task.type.localAgents"},Hr=new Set(["dream"]);function Wr({state:r,onStopTask:t}){const s=Object.values(r.tasks).some(f=>f.status==="running"),n=Object.values(r.tasks).some(f=>f.status!=="running"&&f.evictAfter!==void 0),[,a]=l.useState(0);l.useEffect(()=>{if(!s&&!n)return;const f=setInterval(()=>{a(p=>p+1)},1e3);return()=>clearInterval(f)},[s,n]);const d=Ss(r),i=d.filter(f=>f.status==="running").length,u=d.length-i;return e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(gr,{className:"h-3.5 w-3.5"}),c("task.backgroundTasks")]}),d.length>0&&e.jsx("span",{className:"font-mono text-[10px] text-text-muted",children:i>0&&u>0?K("task.mixedCount",{running:i,recent:u}):i>0?K("task.runningCount",{count:i}):K("task.recentCount",{count:d.length})})]}),d.length===0?e.jsx("p",{className:"text-xs text-text-muted",children:c("task.noBackgroundTasks")}):e.jsx("div",{className:"max-h-[38vh] space-y-2 overflow-y-auto overscroll-contain pr-1",children:Rr(d).map(f=>{const p=!Hr.has(f.taskType),g=Br[f.taskType]??"task.type.tasks";return e.jsxs("div",{className:"space-y-1",children:[p&&e.jsxs("div",{className:"pl-1 text-[10px] font-medium uppercase tracking-wide text-text-muted/80",children:[c(g)," (",f.tasks.length,")"]}),f.tasks.map(y=>e.jsx(Cs,{task:y,onStopTask:t,fullText:!0},y.taskId))]},f.taskType)})})]})}const Qr={connected:"bg-status-success/15 text-status-success",failed:"bg-status-error/15 text-status-error","needs-auth":"bg-status-warning/15 text-status-warning",pending:"bg-status-active/15 text-status-active",disabled:"bg-surface-3 text-text-muted"},zr={connected:"mcp.status.connected",failed:"mcp.status.failed","needs-auth":"mcp.status.needsAuth",pending:"mcp.status.pending",disabled:"mcp.status.disabled"};function Vr({onClose:r,fetchServers:t,onToggle:s,onReconnect:n}){Z();const[a,d]=l.useState(null),[i,u]=l.useState(null),[f,p]=l.useState(null),[g,y]=l.useState(null),k=l.useCallback(async()=>{p(null),y(null);try{const j=await t();d(j),u(null)}catch(j){ze("[McpPanel] fetch failed",j),u(c("mcp.loadFailed"))}},[t]);l.useEffect(()=>{k()},[k]);const C=async j=>{const x=j.status==="disabled";p(`toggle:${j.name}`),y(null);try{const h=await s(j.name,x);h.ok||y(h.error||c("mcp.toggleFailed"))}finally{await k()}},_=async j=>{p(`reconnect:${j.name}`),y(null);try{const x=await n(j.name);x.ok||y(x.error||c("mcp.reconnectFailed"))}finally{await k()}};return e.jsx(fe,{open:!0,onOpenChange:j=>{j||r()},children:e.jsxs(pe,{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(he,{children:e.jsxs(ge,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(Ns,{className:"h-4 w-4"}),c("session.mcp.title")]})}),e.jsxs("div",{className:"mt-3 space-y-3 text-sm",children:[g&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:g}),a===null&&!i&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(Te,{className:"h-3.5 w-3.5 animate-spin"}),c("mcp.loading")]}),i&&e.jsx("p",{className:"text-xs text-status-error",children:i}),a!==null&&a.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:c("mcp.empty")}),a==null?void 0:a.map(j=>{const x=f===`toggle:${j.name}`,h=f===`reconnect:${j.name}`,w=j.status==="disabled";return e.jsx("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2.5",children:e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"truncate text-sm font-medium text-text-primary",children:j.name}),e.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium ${Qr[j.status]}`,children:c(zr[j.status])})]}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-text-muted",children:[j.serverInfo?`${j.serverInfo.name} v${j.serverInfo.version}`:j.url||"stdio",j.toolCount!==void 0&&` · ${K("mcp.toolCount",{n:j.toolCount})}`]}),j.error&&e.jsx("div",{className:"mt-1 truncate text-xs text-status-error",title:j.error,children:j.error})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void _(j),disabled:h||w,className:"rounded-md p-1.5 text-text-muted hover:bg-surface-3 hover:text-text-primary transition-colors disabled:opacity-40 disabled:cursor-not-allowed",title:c("mcp.reconnect"),children:e.jsx(Yn,{className:`h-3.5 w-3.5 ${h?"animate-spin":""}`})}),e.jsx("button",{type:"button",role:"switch","aria-checked":!w,onClick:()=>void C(j),disabled:x,className:`relative h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${w?"bg-surface-3":"bg-brand"}`,title:w?c("mcp.enable"):c("mcp.disable"),children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${w?"left-0.5":"left-4.5"}`})})]})]})},j.name)})]})]})})}function Gr(r){if(r==null)return c("settings.unset");if(typeof r=="string")return r;try{return JSON.stringify(r)}catch{return String(r)}}function as(r){if(r==null)return c("settings.unset");if(typeof r=="object")try{return JSON.stringify(r,null,2)}catch{return String(r)}return String(r)}function Yr({onClose:r,fetchSettings:t,onApply:s}){Z();const[n,a]=l.useState(null),[d,i]=l.useState(null),[u,f]=l.useState(""),[p,g]=l.useState(null),[y,k]=l.useState(null),[C,_]=l.useState(null),[j,x]=l.useState(!1),h=l.useCallback(async()=>{g(null),k(null),_(null),x(!1);try{const N=await t();a(N),i(N?null:c("settings.loadFailed"))}catch(N){ze("[SettingsDrawer] fetch failed",N),i(c("settings.loadFailed"))}},[t]);l.useEffect(()=>{h()},[h]);const w=l.useMemo(()=>n?Object.entries(n.effective).filter(([,N])=>N!==void 0).sort(([N],[O])=>N.localeCompare(O)):[],[n]),S=l.useMemo(()=>{const N=u.trim().toLowerCase();return N?w.filter(([O,L])=>`${O} ${Gr(L)}`.toLowerCase().includes(N)):w},[w,u]),I=N=>typeof N[1]=="boolean",T=l.useMemo(()=>S.filter(I),[S]),b=l.useMemo(()=>S.filter(N=>!I(N)),[S]),E=l.useMemo(()=>C===null?null:w.find(([N])=>N===C)??null,[w,C]),$=async()=>{if(E)try{await navigator.clipboard.writeText(as(E[1])),x(!0),window.setTimeout(()=>x(!1),1500)}catch(N){ze("[SettingsDrawer] copy failed",N)}},A=async(N,O)=>{g(N),k(null);try{const L=await s({[N]:!O});L.ok||k(L.error||c("settings.writeFailed"))}finally{await h()}};return e.jsx(fe,{open:!0,onOpenChange:N=>{N||r()},children:e.jsxs(pe,{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(he,{children:e.jsxs(ge,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(_s,{className:"h-4 w-4"}),c("session.settings.title")]})}),e.jsxs("div",{className:"mt-3 space-y-4 text-sm",children:[y&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:y}),n===null&&!d&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(Te,{className:"h-3.5 w-3.5 animate-spin"}),c("settings.loading")]}),d&&e.jsx("p",{className:"text-xs text-status-error",children:d}),n&&e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2.5",children:[e.jsxs("div",{className:"flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:c("settings.model")}),e.jsx("code",{className:"font-mono text-text-secondary",children:n.applied.model||c("settings.defaultModel")})]}),n.applied.effort&&e.jsxs("div",{className:"mt-1 flex items-center justify-between text-xs",children:[e.jsx("span",{className:"text-text-muted",children:"Effort"}),e.jsx("code",{className:"font-mono text-text-secondary",children:n.applied.effort})]}),e.jsx("p",{className:"mt-2 text-[10px] leading-relaxed text-text-muted",children:c("settings.hint")})]}),E?e.jsxs("section",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>{_(null),x(!1)},className:"flex items-center gap-1.5 text-xs text-text-muted transition-colors hover:text-text-primary",children:[e.jsx(Jn,{className:"h-3.5 w-3.5"}),c("settings.back")]}),e.jsx("div",{className:"break-all font-mono text-xs font-medium text-text-primary",children:E[0]}),e.jsx("pre",{className:"max-h-[60vh] overflow-y-auto whitespace-pre-wrap break-all rounded-md border border-border bg-surface-2 p-3 font-mono text-[10px] leading-relaxed text-text-secondary",children:as(E[1])}),e.jsxs("button",{type:"button",onClick:()=>void $(),className:"flex items-center gap-1.5 rounded-md border border-border px-2.5 py-1.5 text-xs text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary",children:[j?e.jsx(xe,{className:"h-3.5 w-3.5 text-status-success"}):e.jsx(Zn,{className:"h-3.5 w-3.5"}),j?c("settings.copied"):c("settings.copyValue")]})]}):e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-2 px-2.5 py-1.5",children:[e.jsx(ut,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{value:u,onChange:N=>f(N.target.value),placeholder:c("settings.searchPlaceholder"),className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"})]}),S.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:c("settings.noMatch")}),T.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-[10px] font-medium uppercase tracking-wide text-text-muted",children:K("settings.togglable",{n:T.length})}),T.map(([N,O])=>{const L=p===N;return e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-md border border-border bg-surface-2 px-3 py-2",children:[e.jsx("div",{className:"truncate font-mono text-xs text-text-primary",children:N}),e.jsx("button",{type:"button",role:"switch","aria-checked":O,disabled:L,onClick:()=>void A(N,O),className:`relative h-5 w-9 flex-shrink-0 rounded-full transition-colors disabled:opacity-50 ${O?"bg-brand":"bg-surface-3"}`,title:O?c("settings.turnOff"):c("settings.turnOn"),children:e.jsx("span",{className:`absolute top-0.5 h-4 w-4 rounded-full bg-white transition-all ${O?"left-4.5":"left-0.5"}`})})]},N)})]}),b.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-[10px] font-medium uppercase tracking-wide text-text-muted",children:K("settings.readOnly",{n:b.length})}),b.map(([N])=>e.jsxs("button",{type:"button",onClick:()=>_(N),className:"flex w-full items-center justify-between gap-3 rounded-md border border-border bg-surface-2 px-3 py-2 text-left transition-colors hover:bg-surface-3",title:c("settings.viewDetail"),children:[e.jsx("span",{className:"truncate font-mono text-xs text-text-primary",children:N}),e.jsx(ws,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"})]},N))]})]})]})]})]})})}function Jr({onClose:r,onAsk:t}){Z();const[s,n]=l.useState([]),[a,d]=l.useState(""),[i,u]=l.useState(!1),f=async()=>{const p=a.trim();if(!p||i)return;const g=Date.now();n(y=>[...y,{id:g,question:p,answer:null}]),d(""),u(!0);try{const y=await t(p);n(k=>k.map(C=>C.id===g?{...C,answer:y??c("sideQuestion.noAnswer"),error:y===null}:C))}finally{u(!1)}};return e.jsx(fe,{open:!0,onOpenChange:p=>{p||r()},children:e.jsxs(pe,{showCloseButton:!1,className:"fixed inset-y-0 right-0 top-auto left-auto translate-x-0 translate-y-0 w-full sm:w-[26rem] h-full max-w-none max-h-none rounded-none border-l border-border bg-surface-1 p-4 sm:max-w-md flex flex-col",children:[e.jsx(he,{children:e.jsxs(ge,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(vs,{className:"h-4 w-4"}),c("sideQuestion.title")]})}),e.jsx("p",{className:"mt-1 text-[10px] leading-relaxed text-text-muted",children:c("sideQuestion.desc")}),e.jsxs("div",{className:"mt-3 flex-1 space-y-4 overflow-y-auto",children:[s.length===0&&e.jsx("p",{className:"text-xs text-text-muted",children:c("sideQuestion.empty")}),s.map(p=>e.jsxs("div",{className:"space-y-2",children:[e.jsx("div",{className:"flex justify-end",children:e.jsx("div",{className:"max-w-[85%] rounded-2xl rounded-br-md border border-user-bubble-border bg-user-bubble px-4 py-2 text-sm text-text-primary",children:p.question})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsx("div",{className:"w-7 h-7 rounded-lg bg-brand/8 flex items-center justify-center flex-shrink-0 overflow-hidden",children:e.jsx("img",{src:"/code/pony.svg",alt:"Saluzi",width:24,height:24,className:"object-contain",draggable:!1})}),e.jsx("div",{className:"min-w-0 flex-1 pt-1 text-sm text-text-primary",children:p.answer===null?e.jsxs("span",{className:"chat-typing-indicator inline-flex items-center gap-1","aria-hidden":"true",children:[e.jsx("span",{}),e.jsx("span",{}),e.jsx("span",{})]}):e.jsx("div",{className:p.error?"text-status-error":"",children:e.jsx(Nn,{children:p.answer})})})]})]},p.id))]}),e.jsxs("div",{className:"mt-3 flex items-end gap-2",children:[e.jsx("textarea",{value:a,onChange:p=>d(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&!p.nativeEvent.isComposing&&(p.preventDefault(),f())},rows:Math.min(4,Math.max(1,a.split(`
|
|
81
|
+
`).length)),placeholder:c("sideQuestion.placeholder"),disabled:i,className:"flex-1 resize-none rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-accent focus:outline-none disabled:opacity-50"}),e.jsx("button",{type:"button",onClick:()=>void f(),disabled:i||!a.trim(),className:"flex h-9 w-9 flex-shrink-0 items-center justify-center rounded-lg bg-brand text-white transition-colors hover:bg-brand-light disabled:opacity-40 disabled:cursor-not-allowed",title:c("sideQuestion.send"),children:i?e.jsx(Te,{className:"h-4 w-4 animate-spin"}):e.jsx(_n,{className:"h-4 w-4"})})]})]})})}const dt="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-1";function os(r,t){var a;const s=(a=t==null?void 0:t.find(d=>d.type==="addRules"||d.type==="replaceRules"))==null?void 0:a.rules,n=s==null?void 0:s[0];return n!=null&&n.ruleContent?`${n.toolName}(${n.ruleContent})`:n!=null&&n.toolName?n.toolName:r}function Xr({requestId:r,toolName:t,toolInput:s,description:n,suggestions:a,onApprove:d,onApproveAlways:i,onReject:u}){Z();const f=s&&typeof s=="object"&&!Array.isArray(s)?s:{},p=Sn(Cn(t),f,{writeUnknownLabel:c("permission.writeUnknown")}),g=typeof s=="string"?s:JSON.stringify(s,null,2),y=Array.isArray(a)&&a.length>0;return e.jsxs("div",{role:"group","aria-label":K("permission.requestAria",{tool:t}),className:"rounded-xl border border-approve/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-approve/15 text-approve-text",children:e.jsx(Tn,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold font-display text-approve-text",children:c("permission.title")})]}),n&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:G(n)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:G(t)}),t!=="AskUserQuestion"&&(p?e.jsx("div",{className:"mb-3 space-y-2",children:p.map((k,C)=>e.jsx(En,{filePath:k.filePath,oldString:k.oldString,newString:k.newString,label:k.label},C))}):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:Lt(g,500)})),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:d,className:ae("rounded-lg bg-approve px-4 py-2 text-sm font-medium font-display text-white hover:bg-approve-hover transition-colors",dt),children:c("permission.approve")}),y&&i&&e.jsxs("button",{onClick:i,className:ae("flex items-center gap-1.5 rounded-lg border border-approve/40 bg-approve/10 px-4 py-2 text-sm font-medium font-display text-approve-text hover:bg-approve/20 transition-colors",dt),title:c("permission.alwaysAllowHint").replace("{rule}",os(t,a)),children:[e.jsx(Mr,{className:"h-3.5 w-3.5"}),c("permission.alwaysAllow")," ",Lt(os(t,a),40)]}),e.jsx("button",{onClick:u,className:ae("rounded-lg border border-status-error/40 px-4 py-2 text-sm font-medium font-display text-status-error hover:bg-status-error/10 transition-colors",dt),children:c("permission.reject")})]})]})}function Zr({questions:r,description:t,onSubmit:s,onSkip:n}){const[a,d]=l.useState({}),[i,u]=l.useState({}),[f,p]=l.useState(0),g=(_,j,x)=>{if(x){const h=a[_]||[],w=h.includes(j)?h.filter(S=>S!==j):[...h,j];d({...a,[_]:w})}else d({...a,[_]:j})},y=_=>{var x;const j=(x=i[_])==null?void 0:x.trim();j&&(d({...a,[_]:j}),u({...i,[_]:""}))},k=()=>{var j,x;const _={};for(const[h,w]of Object.entries(a)){const S=r[parseInt(h,10)];S&&(typeof w=="number"?_[h]=((x=(j=S.options)==null?void 0:j[w])==null?void 0:x.label)||String(w):Array.isArray(w)?_[h]=w.map(I=>{var T,b;return((b=(T=S.options)==null?void 0:T[I])==null?void 0:b.label)||String(I)}):_[h]=w)}s(_)};if(r.length<=1){const _=r[0]||{question:t,options:[],multiSelect:!1},j=_.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 font-display text-text-primary",children:G(t||_.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(_.options||[]).map((x,h)=>{const w=j?(a[0]||[]).includes(h):a[0]===h;return e.jsxs("button",{onClick:()=>g(0,h,j),className:ae("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display 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 font-display",children:G(x.label)}),x.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:G(x.description)})]},h)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:i[0]||"",onChange:x=>u({...i,0:x.target.value}),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm font-display text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:x=>x.key==="Enter"&&y(0)}),e.jsx("button",{onClick:()=>y(0),className:"rounded-lg border border-border px-3 py-2 text-sm font-display 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:k,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium font-display text-white hover:bg-brand-light transition-colors",children:"Submit"}),e.jsx("button",{onClick:n,className:"rounded-lg border border-border px-4 py-2 text-sm font-display text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})}const C=r[f];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 font-display text-text-primary",children:G(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:r.map((_,j)=>e.jsx("button",{onClick:()=>p(j),className:ae("rounded-md px-3 py-1.5 text-xs font-display whitespace-nowrap transition-colors",f===j?"bg-brand/20 text-brand-text":"text-text-muted hover:bg-surface-2"),children:_.header||`Q${j+1}`},j))}),C&&e.jsx(ea,{question:C,qIdx:f,answers:a,otherTexts:i,onSelect:g,onOtherTextChange:(_,j)=>u({...i,[_]:j}),onOtherSubmit:y}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-display text-text-muted",children:[f+1," / ",r.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:k,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium font-display text-white hover:bg-brand-light transition-colors",children:"Submit All"}),e.jsx("button",{onClick:n,className:"rounded-lg border border-border px-4 py-2 text-sm font-display text-text-secondary hover:bg-surface-2 transition-colors",children:"Skip"})]})]})]})}function ea({question:r,qIdx:t,answers:s,otherTexts:n,onSelect:a,onOtherTextChange:d,onOtherSubmit:i}){const u=r.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:G(r.question)}),e.jsxs("div",{className:"space-y-2",children:[(r.options||[]).map((f,p)=>{const g=u?(s[t]||[]).includes(p):s[t]===p;return e.jsxs("button",{onClick:()=>a(t,p,u),className:ae("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",g?"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 font-display",children:G(f.label)}),f.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:G(f.description)})]},p)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:n[t]||"",onChange:f=>d(t,f.target.value),placeholder:"Other...",className:"flex-1 rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm font-display text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none",onKeyDown:f=>f.key==="Enter"&&i(t)}),e.jsx("button",{onClick:()=>i(t),className:"rounded-lg border border-border px-3 py-2 text-sm font-display text-text-secondary hover:bg-surface-2 transition-colors",children:"Send"})]})]})]})}function ta({planContent:r,description:t,onSubmit:s}){const[n,a]=l.useState(null),[d,i]=l.useState(""),u=!r||!r.trim(),f=()=>{n&&s(n,n==="no"?d: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-text",children:e.jsx(xe,{className:"h-3 w-3",strokeWidth:2.5})}),e.jsx("span",{className:"text-sm font-semibold font-display 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:sa(r)}}),e.jsx("div",{className:"space-y-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Ce,{selected:n==="yes-default",onClick:()=>a("yes-default"),label:"Yes"}),e.jsx(Ce,{selected:n==="no",onClick:()=>a("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ce,{selected:n==="yes-accept-edits",onClick:()=>a("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(Ce,{selected:n==="yes-default",onClick:()=>a("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(Ce,{selected:n==="no",onClick:()=>a("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),n==="no"&&e.jsx("textarea",{value:d,onChange:p=>i(p.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 font-display 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:f,disabled:!n,className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium font-display text-white hover:bg-brand-light disabled:opacity-50 transition-colors",children:"Submit"})})]})}function Ce({selected:r,onClick:t,label:s,desc:n}){return e.jsxs("button",{onClick:t,className:ae("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",r?"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:ae("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",r?"border-brand bg-brand text-white":"border-border"),children:r&&"✓"}),e.jsx("span",{className:"font-medium font-display",children:s})]}),n&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs font-sans text-text-muted",children:n})]})}function sa(r){let t=G(r);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(s,n,a)=>`<pre class="my-2 overflow-x-auto rounded-lg bg-tool-card p-3 font-mono text-xs">${a.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 na({request:r,onSubmit:t}){Z();const s=ra(r.requestedSchema),n=aa(r.requestedSchema),[a,d]=l.useState({}),i=s.length===0||n.every(u=>(a[u]??"").trim()!=="");return r.mode==="url"&&r.url?e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(is,{serverName:r.serverName,message:r.message}),e.jsxs("a",{href:r.url,target:"_blank",rel:"noopener noreferrer",className:"mt-2 flex w-full items-center justify-between rounded-lg border border-border bg-surface-2 px-4 py-2.5 text-sm text-brand-text hover:bg-brand/10 transition-colors",children:[e.jsx("span",{className:"truncate font-mono text-xs",children:r.url}),e.jsx(er,{className:"ml-2 h-4 w-4 flex-shrink-0"})]}),e.jsxs("div",{className:"mt-4 flex gap-2",children:[e.jsx("button",{onClick:()=>t("accept"),className:"rounded-lg bg-brand px-4 py-2 text-sm font-medium text-white hover:bg-brand-light transition-colors",children:c("elicitation.done")}),e.jsx("button",{onClick:()=>t("cancel"),className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:c("common.cancel")})]})]}):e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(is,{serverName:r.serverName,message:r.message}),s.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:s.map(({name:u,prop:f})=>e.jsxs("label",{className:"block",children:[e.jsxs("div",{className:"mb-1 flex items-center gap-2",children:[e.jsx("span",{className:"font-mono text-xs font-medium text-text-primary",children:u}),n.includes(u)&&e.jsx("span",{className:"text-[10px] font-medium text-warning-text",children:c("elicitation.required")})]}),f.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:G(f.description)}),e.jsx("input",{type:f.type==="number"?"number":"text",value:a[u]??"",onChange:p=>d(g=>({...g,[u]:p.target.value})),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"})]},u))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>{const u={};for(const{name:f,prop:p}of s){const g=(a[f]??"").trim();g&&(u[f]=p.type==="number"?Number(g):g)}t("accept",u)},disabled:!i,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:c("elicitation.submit")}),e.jsx("button",{onClick:()=>t("decline"),className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:c("elicitation.decline")})]})]})}function is({serverName:r,message:t}){return e.jsxs("div",{className:"mb-3",children:[e.jsxs("div",{className:"mb-1 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-text",children:e.jsx(jr,{className:"h-3 w-3"})}),e.jsxs("span",{className:"text-sm font-semibold text-text-primary",children:[c("elicitation.title")," ",e.jsx("span",{className:"font-mono text-xs text-text-muted",children:G(r)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:G(t)})]})}function ra(r){const t=r==null?void 0:r.properties;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,s])=>s&&typeof s=="object").map(([s,n])=>({name:s,prop:n}))}function aa(r){const t=r==null?void 0:r.required;return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function oa(r){const[t,s]=l.useState([]),[n,a]=l.useState(!0),[d,i]=l.useState(null),u=l.useCallback(async()=>{a(!0),i(null);try{const g=await Mn(r);s(g)}catch(g){i(g instanceof Error?g.message:"Failed to load shares")}finally{a(!1)}},[r]);l.useEffect(()=>{u()},[u]);const f=l.useCallback(async g=>{i(null);try{const y=await Rn(r,g);return await u(),y}catch(y){throw i(y instanceof Error?y.message:"Failed to create share"),y}},[r,u]),p=l.useCallback(async g=>{i(null);try{await An(r,g),await u()}catch(y){throw i(y instanceof Error?y.message:"Failed to revoke share"),y}},[r,u]);return{shares:t,isLoading:n,error:d,createShare:f,revokeShare:p,refresh:u}}function ia({open:r,onClose:t,sessionId:s,sessionTitle:n}){Z();const{shares:a,isLoading:d,error:i,createShare:u,revokeShare:f}=oa(s),[p,g]=l.useState("user"),[y,k]=l.useState(""),[C,_]=l.useState(""),[j,x]=l.useState("read"),[h,w]=l.useState(""),[S,I]=l.useState(!1),[T,b]=l.useState(null),[E,$]=l.useState(""),[A,N]=l.useState(!1),[O,L]=l.useState(!1);l.useEffect(()=>{r&&(g("user"),k(""),_(""),x("read"),w(""),I(!1),b(null),$(""),N(!1),L(!1))},[r]);const Y=async()=>{I(!0),$(""),b(null);try{const q={grantedTo:p==="user"?{userId:y.trim()}:{teamId:C.trim()},permission:j};h.trim()&&(q.expiresAt=h.trim());const oe=await u(q);b(`${window.location.origin}/code/s/${oe.shareToken}`)}catch(q){$(q instanceof Error?q.message:"Failed to create share")}finally{I(!1)}},se=async q=>{try{await f(q)}catch{}},J=async()=>{if(!T)return;L(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(T),N(!0),setTimeout(()=>N(!1),2e3);return}}catch{}const q=document.createElement("textarea");q.value=T,q.style.position="fixed",q.style.opacity="0",document.body.appendChild(q),q.select();try{document.execCommand("copy"),N(!0),setTimeout(()=>N(!1),2e3)}catch{L(!0)}document.body.removeChild(q)};return e.jsx(fe,{open:r,onOpenChange:q=>{q||t()},children:e.jsxs(pe,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(he,{children:e.jsxs(ge,{className:"font-display text-lg font-semibold text-text-primary",children:[c("share.title"),n?`: ${n}`:""]})}),e.jsxs("div",{className:"space-y-4 min-w-0",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:c("share.grantTo")}),e.jsxs("div",{className:"flex gap-2 mb-2",children:[e.jsx("button",{onClick:()=>g("user"),className:`rounded-md px-3 py-1 text-sm transition-colors ${p==="user"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:c("share.user")}),e.jsx("button",{onClick:()=>g("team"),className:`rounded-md px-3 py-1 text-sm transition-colors ${p==="team"?"bg-brand text-white":"bg-surface-2 text-text-secondary hover:bg-surface-3"}`,children:c("share.team")})]}),p==="user"?e.jsx(Xn,{onSelect:k,placeholder:c("share.userIdPlaceholder"),actionLabel:c("share.selectUser")}):e.jsx("input",{type:"text",value:C,onChange:q=>_(q.target.value),placeholder:c("share.teamIdPlaceholder"),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"}),p==="user"&&y&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[c("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:y})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:c("share.permission")}),e.jsxs("select",{value:j,onChange:q=>x(q.target.value),className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary focus:border-brand focus:outline-none",children:[e.jsx("option",{value:"read",children:c("share.permissionRead")}),e.jsx("option",{value:"write",children:c("share.permissionWrite")})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:c("share.expiresAt")}),e.jsx("input",{type:"datetime-local",value:h,onChange:q=>w(q.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"})]}),(E||i)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:E||i}),T&&e.jsxs("div",{className:"rounded-md bg-surface-2 px-3 py-2",children:[e.jsx("p",{className:"text-sm text-text-secondary mb-1",children:c("share.linkCreated")}),e.jsxs("div",{className:"flex items-start gap-2 min-w-0",children:[e.jsx("code",{className:"min-w-0 flex-1 break-all text-xs text-text-primary",children:T}),e.jsx("button",{onClick:J,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:A?c("share.copied"):c("share.copy")})]}),O&&e.jsx("p",{className:"mt-1 text-xs text-status-error",children:c("share.copyFailed")})]}),e.jsxs("div",{children:[e.jsx("h4",{className:"mb-2 text-sm font-medium text-text-secondary",children:c("share.existingShares")}),d?e.jsx("p",{className:"text-sm text-text-muted",children:c("share.loading")}):a.length===0?e.jsx("p",{className:"text-sm text-text-muted",children:c("share.none")}):e.jsx("div",{className:"space-y-2 max-h-40 overflow-y-auto",children:a.map(q=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded-md bg-surface-2 px-3 py-2",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"truncate text-sm text-text-primary",children:q.granted_to_user||q.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[q.permission==="write"?c("share.permissionWrite"):c("share.permissionRead"),q.expires_at?` · expires ${q.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>se(q.id),className:"shrink-0 rounded-md px-2 py-1 text-xs text-status-error hover:bg-surface-3 transition-colors",children:c("share.revoke")})]},q.id))})]})]}),e.jsxs(Gn,{children:[e.jsx("button",{onClick:t,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary hover:bg-surface-2 transition-colors",children:c("common.close")}),e.jsx("button",{onClick:Y,disabled:S||(p==="user"?!y.trim():!C.trim()),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:S?c("common.creating"):c("share.createShare")})]})]})})}function la(r){const t=new Date,s=new Date(t.getTime()-1440*60*1e3),n=(i,u)=>i.getFullYear()===u.getFullYear()&&i.getMonth()===u.getMonth()&&i.getDate()===u.getDate(),a={today:[],yesterday:[],earlier:[]};for(const i of r){const u=new Date(i.modified||0);n(u,t)?a.today.push(i):n(u,s)?a.yesterday.push(i):a.earlier.push(i)}return[["today",c("resume.today")],["yesterday",c("resume.yesterday")],["earlier",c("resume.earlier")]].map(([i,u])=>({label:u,items:a[i]})).filter(i=>i.items.length>0)}function ca(r){return r?new Date(r).toLocaleString():""}function da({open:r,onClose:t,adapter:s,onResume:n}){const a=Z(),[d,i]=l.useState([]),[u,f]=l.useState(!1),[p,g]=l.useState("");l.useEffect(()=>{if(!r)return;let k=!1;return f(!0),g(""),i([]),s.listResumableSessions().then(C=>{k||i(C)}).catch(C=>{k||g(C instanceof Error?C.message:String(C))}).finally(()=>{k||f(!1)}),()=>{k=!0}},[r,s]);const y=l.useMemo(()=>la(d),[d,a]);return e.jsx(fe,{open:r,onOpenChange:k=>{k||t()},children:e.jsxs(pe,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(he,{children:e.jsx(ge,{className:"font-display text-lg font-semibold text-text-primary",children:c("session.resume.title")})}),e.jsxs("div",{className:"max-h-96 min-w-0 space-y-4 overflow-y-auto",children:[u&&e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:c("resume.loading")}),!u&&p&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:p}),!u&&!p&&d.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:c("resume.empty")}),!u&&!p&&y.map(k=>e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-text-muted",children:k.label}),e.jsx("div",{className:"space-y-1",children:k.items.map(C=>e.jsxs("button",{type:"button",onClick:()=>n(C),className:"w-full rounded-md px-3 py-2 text-left transition-colors hover:bg-surface-3",children:[e.jsx("p",{className:"truncate text-sm text-text-primary",children:C.title}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[ca(C.modified),C.gitBranch?` · ${C.gitBranch}`:""]})]},C.sessionId))})]},k.label))]}),e.jsx("div",{className:"mt-4 flex justify-end",children:e.jsx("button",{type:"button",onClick:t,className:"rounded-lg border border-border px-4 py-2 text-sm text-text-secondary transition-colors hover:bg-surface-2",children:c("common.cancel")})})]})})}class ua{constructor(t,s,n,a){R(this,"pending",null);this.current=t,this.apply=s,this.send=n,this.onError=a}set(t){if(t===this.current)return;const s=this.current;this.current=t,this.pending={requestId:null,previous:s},this.apply(t);try{Promise.resolve(this.send(t)).then(n=>{this.pending&&(this.pending.requestId=n)}).catch(n=>{this.rollback(s,ls(n),"send")})}catch(n){this.rollback(s,ls(n),"send")}}handleControlResponse(t){const s=this.pending;if(!s||s.requestId!==t.requestId)return!1;const{previous:n}=s;return this.pending=null,t.subtype==="error"&&this.rollback(n,t.error??"","response"),!0}sync(t){t!==this.current&&(this.current=t,this.apply(t),this.pending=null)}adoptExternal(t){this.pending||t!==this.current&&(this.current=t)}getCurrent(){return this.current}rollback(t,s,n){var a;this.pending=null,this.current=t,this.apply(t),s&&((a=this.onError)==null||a.call(this,s,n))}}function ls(r){return r instanceof Error?r.message:String(r)}function We(r){const t=l.useRef(r);t.current=r;const s=l.useRef(null);s.current||(s.current=new ua(r.value,a=>t.current.apply(a),a=>t.current.send(a),(a,d)=>{var i,u;return(u=(i=t.current).onError)==null?void 0:u.call(i,a,d)}));const n=s.current;return l.useEffect(()=>{n.adoptExternal(r.value)}),l.useMemo(()=>({set:a=>n.set(a),handleControlResponse:a=>n.handleControlResponse(a),sync:a=>n.sync(a)}),[n])}const Ts="rcs_context_usage_";function Es(){try{if(typeof localStorage<"u")return localStorage}catch{}return null}function cs(){return{totalTokens:0,rawMaxTokens:0,percentage:0}}function ma(r){if(!r||typeof r!="object"||Array.isArray(r))return null;const t=r,{totalTokens:s,rawMaxTokens:n,percentage:a}=t;if(typeof s!="number"||typeof n!="number"||typeof a!="number")return null;const d=t.categories,i=Array.isArray(d)?d.filter(u=>!!u&&typeof u=="object"&&typeof u.name=="string").map(u=>({name:u.name,tokens:typeof u.tokens=="number"?u.tokens:0,...u.isDeferred===!0?{isDeferred:!0}:{}})):void 0;return{totalTokens:s,rawMaxTokens:n,percentage:a,...typeof t.model=="string"&&t.model?{model:t.model}:{},...i&&i.length>0?{categories:i}:{}}}function xa(r,t=Es()){if(!t||!r)return null;try{const s=t.getItem(Ts+r);return s?ma(JSON.parse(s)):null}catch{return null}}function fa(r,t,s=Es()){if(!(!s||!r))try{s.setItem(Ts+r,JSON.stringify(t))}catch{}}function pa(r){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${r}`}function ha(r){const t=pa(r),s=$n(),n=s?{proxyUrl:t,token:s}:{proxyUrl:t};return new In(n)}const ue=[{value:"default",labelKey:"session.mode.default",descKey:"session.mode.defaultDesc"},{value:"acceptEdits",labelKey:"session.mode.acceptEdits",descKey:"session.mode.acceptEditsDesc"},{value:"plan",labelKey:"session.mode.plan",descKey:"session.mode.planDesc"},{value:"bypassPermissions",labelKey:"session.mode.bypass",descKey:"session.mode.bypassDesc"}],ds="rcs_permission_mode";function me(r){return r<1e3?String(r):r<1e6?`${(r/1e3).toFixed(1)}k`:`${(r/1e6).toFixed(1)}M`}function ga(r){const t=ue.findIndex(s=>s.value===r);return ue[(t+1+ue.length)%ue.length].value}const Ve=[{value:"off",labelKey:"session.thinking.off",descKey:"session.thinking.offDesc",label:void 0,description:void 0,tokens:0},{value:"on",labelKey:"session.thinking.on",descKey:"session.thinking.onDesc",label:void 0,description:void 0,tokens:null},{value:"8192",labelKey:void 0,descKey:void 0,label:"8k",description:"8192 tokens",tokens:8192},{value:"16384",labelKey:void 0,descKey:void 0,label:"16k",description:"16384 tokens",tokens:16384},{value:"32768",labelKey:void 0,descKey:void 0,label:"32k",description:"32768 tokens",tokens:32768}],us="rcs_thinking_budget",xt=[{value:"auto",effort:void 0,labelKey:"session.effort.auto",descKey:"session.effort.autoDesc",label:void 0},{value:"low",effort:"low",labelKey:void 0,descKey:"session.effort.lowDesc",label:"low"},{value:"medium",effort:"medium",labelKey:void 0,descKey:"session.effort.mediumDesc",label:"medium"},{value:"high",effort:"high",labelKey:void 0,descKey:"session.effort.highDesc",label:"high"},{value:"xhigh",effort:"xhigh",labelKey:void 0,descKey:"session.effort.xhighDesc",label:"xhigh"},{value:"max",effort:"max",labelKey:void 0,descKey:"session.effort.maxDesc",label:"max"}],ms=r=>r.labelKey?c(r.labelKey):r.label,xs=r=>r.labelKey?c(r.labelKey):r.label,fs="rcs_effort",ps=[{value:"normal",descKey:"session.tokenMode.normalDesc"},{value:"poor",descKey:"session.tokenMode.poorDesc"},{value:"sa",descKey:"session.tokenMode.saDesc"}],hs="rcs_token_mode";function ya(r){return r!=null&&r.capabilities?r.capabilities:r?{file_search:!0,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!0,stop_task:!0,set_model:!0,set_permission_mode:!0,interrupt:!0,end_session:!0,mcp_management:!0,remote_settings:!0,rewind:!0,resume:!0,set_effort:!0,set_token_mode:!1,side_question:!0}:{file_search:!1,clear:!0,set_max_thinking_tokens:!0,get_context_usage:!1,stop_task:!1,set_model:!0,set_permission_mode:!0,interrupt:!0,end_session:!1,mcp_management:!1,remote_settings:!1,rewind:!1,resume:!1,set_effort:!1,set_token_mode:!1,side_question:!1}}function ba({budget:r,onBudgetChange:t,disabled:s}){const[n,a]=l.useState(!1),d=Ve.find(i=>i.value===r);return e.jsxs(Ee,{open:n,onOpenChange:a,children:[e.jsx(Me,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:c("session.thinking.title"),children:[e.jsx(js,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:d?xs(d):c("session.thinking.fallback")}),n?e.jsx(Re,{className:"h-3 w-3"}):e.jsx(Ae,{className:"h-3 w-3"})]})}),e.jsx(Ie,{className:"w-64 p-1",align:"start",children:Ve.map(i=>e.jsxs("button",{type:"button",onClick:()=>{t(i.value,i.tokens),a(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:r===i.value&&e.jsx(xe,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:xs(i)}),e.jsx("div",{className:"text-xs text-text-muted",children:i.descKey?c(i.descKey):i.description})]})]},i.value))})]})}function ja({effort:r,onEffortChange:t,disabled:s}){const[n,a]=l.useState(!1),d=xt.find(i=>i.value===r);return e.jsxs(Ee,{open:n,onOpenChange:a,children:[e.jsx(Me,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:c("session.effort.title"),children:[e.jsx(ur,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:d?ms(d):c("session.effort.fallback")}),n?e.jsx(Re,{className:"h-3 w-3"}):e.jsx(Ae,{className:"h-3 w-3"})]})}),e.jsx(Ie,{className:"w-64 p-1",align:"start",children:xt.map(i=>e.jsxs("button",{type:"button",onClick:()=>{t(i.value),a(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:r===i.value&&e.jsx(xe,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:ms(i)}),e.jsx("div",{className:"text-xs text-text-muted",children:c(i.descKey)})]})]},i.value))})]})}function wa({mode:r,onModeChange:t,disabled:s}){const[n,a]=l.useState(!1),d=ps.find(i=>i.value===r);return e.jsxs(Ee,{open:n,onOpenChange:a,children:[e.jsx(Me,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:c("session.tokenMode.title"),children:[e.jsx(lr,{className:"h-3 w-3"}),e.jsx("span",{className:`max-w-24 truncate ${r!=="normal"?"font-medium text-brand-text":""}`,children:d?c(`session.tokenMode.${d.value}`):c("session.tokenMode.fallback")}),n?e.jsx(Re,{className:"h-3 w-3"}):e.jsx(Ae,{className:"h-3 w-3"})]})}),e.jsx(Ie,{className:"w-64 p-1",align:"start",children:ps.map(i=>e.jsxs("button",{type:"button",onClick:()=>{t(i.value),a(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:r===i.value&&e.jsx(xe,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:c(`session.tokenMode.${i.value}`)}),e.jsx("div",{className:"text-xs text-text-muted",children:c(i.descKey)})]})]},i.value))})]})}const ka=new Set(["Free space","Autocompact buffer","Compact buffer"]),gs=["bg-brand","bg-status-active","bg-status-success","bg-violet-500","bg-amber-500","bg-pink-500","bg-teal-500"];function va({usage:r}){const t=Math.min(100,Math.max(0,r.percentage)),s=t>=80,n=(r.categories??[]).filter(u=>!u.isDeferred&&!ka.has(u.name)),a=(r.categories??[]).filter(u=>u.isDeferred),d=n.reduce((u,f)=>u+f.tokens,0),i=[`${K("session.context.tooltip",{used:me(r.totalTokens),max:me(r.rawMaxTokens)})}${r.model?` · ${r.model}`:""}`,...n.slice(0,8).map(u=>`${u.name}: ${me(u.tokens)}`),...a.slice(0,3).map(u=>`${u.name}${c("session.context.deferredSuffix")}: ${me(u.tokens)}`)];return e.jsxs("span",{className:"flex items-center gap-1.5 text-[10px] text-text-muted font-mono",title:i.join(`
|
|
82
|
+
`),children:[e.jsx("span",{className:"relative flex h-1.5 w-16 overflow-hidden rounded-full bg-surface-3",children:n.length>0?n.map((u,f)=>e.jsx("span",{className:s&&f===0?"bg-status-warning":gs[f%gs.length],style:{width:`${Math.min(100,Math.max(0,d>0?u.tokens/d*t:0))}%`}},u.name)):e.jsx("span",{className:`absolute inset-y-0 left-0 rounded-full transition-all ${s?"bg-status-warning":"bg-brand/70"}`,style:{width:`${t}%`}})}),e.jsxs("span",{children:[t,"%"]})]})}function Na({models:r,currentModelId:t,onSelect:s,disabled:n}){const[a,d]=l.useState(!1),i=r.find(p=>p.modelId===t)??null,u=r.length>0,f=async p=>{s(p.modelId),d(!1)};return e.jsxs(Ee,{open:a,onOpenChange:u?d:void 0,children:[e.jsx(Me,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:n||!u,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:c("session.model.title"),children:[e.jsx(ks,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-32 truncate",children:(i==null?void 0:i.name)??t??c("session.model.title")}),a?e.jsx(Re,{className:"h-3 w-3"}):e.jsx(Ae,{className:"h-3 w-3"})]})}),e.jsx(Ie,{className:"w-72 p-0",align:"start",children:e.jsx(zn,{models:r,currentModelId:t,onSelect:f,showSearch:r.length>5})})]})}function _a({mode:r,onModeChange:t,disabled:s}){const[n,a]=l.useState(!1),d=ue.find(i=>i.value===r);return e.jsxs(Ee,{open:n,onOpenChange:a,children:[e.jsx(Me,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:s,className:"flex items-center gap-1.5 rounded-lg px-2 h-7 text-xs text-text-muted hover:text-text-primary hover:bg-surface-2 transition-colors disabled:opacity-50 disabled:cursor-not-allowed font-display",title:c("session.mode.title"),children:[e.jsx(Qn,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:d?c(d.labelKey):r}),n?e.jsx(Re,{className:"h-3 w-3"}):e.jsx(Ae,{className:"h-3 w-3"})]})}),e.jsx(Ie,{className:"w-64 p-1",align:"start",children:ue.map(i=>e.jsxs("button",{type:"button",onClick:()=>{t(i.value),a(!1)},className:"flex w-full items-start gap-2 rounded-md px-2.5 py-2 text-left hover:bg-surface-2 transition-colors",children:[e.jsx("span",{className:"mt-0.5 flex h-4 w-4 flex-shrink-0 items-center justify-center",children:r===i.value&&e.jsx(xe,{className:"h-3.5 w-3.5 text-brand-text"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("div",{className:"text-sm font-medium text-text-primary",children:c(i.labelKey)}),e.jsx("div",{className:"text-xs text-text-muted",children:c(i.descKey)})]})]},i.value))})]})}function La({sessionId:r,onBack:t}){var Ot;Z();const[s,n]=l.useState(null),[a,d]=l.useState(null),[i,u]=l.useState(""),[f,p]=l.useState(!1),[g,y]=l.useState(!1),[k,C]=l.useState(!1),[_,j]=l.useState(!1),[x,h]=l.useState(!1),[w,S]=l.useState(!1),[I,T]=l.useState(""),[b,E]=l.useState(0),$=l.useRef(null),[A,N]=l.useState({text:"",nonce:0}),[O,L]=l.useState(!1),[Y,se]=l.useState(!1),[J,q]=l.useState(!1),[oe,Ms]=l.useState(!1),[Ge,ft]=l.useState(0),[Rs,As]=l.useState(0),[ye,ne]=l.useState([]),[X,be]=l.useState(!1),[je,de]=l.useState([]),[z,Ye]=l.useState(null),[pt,Is]=l.useState(()=>mt()),[Q,$s]=l.useState(null),[$e,Ds]=l.useState(()=>localStorage.getItem(us)||"off"),[qs,ht]=l.useState(()=>xa(r)),[Je,Xe]=l.useState(!0),[we,Ps]=l.useState(null),[Os,Us]=l.useState(null),[De,gt]=l.useState(null),[qe,Pe]=l.useState([]),[Fs,Ze]=l.useState(!1),[et,yt]=l.useState(""),tt=l.useRef(null),[Oe,Ks]=l.useState(()=>localStorage.getItem(ds)||"default"),[bt,jt]=l.useState(null),ke=l.useRef(null),[wt,kt]=l.useState(null),ve=l.useRef(null),ee=l.useRef(null),vt=l.useRef(ye);vt.current=ye;const Ue=l.useRef(null);Ue.current||(Ue.current=new rr(ar()));const Nt=l.useRef(r);Nt.current=(s==null?void 0:s.title)||r,l.useEffect(()=>{var o;(o=Ue.current)==null||o.reset()},[r]);const te=l.useCallback(o=>{jt(o),ke.current&&clearTimeout(ke.current),ke.current=setTimeout(()=>jt(null),5e3)},[]),re=l.useCallback(o=>{kt(o),ve.current&&clearTimeout(ve.current),ve.current=setTimeout(()=>kt(null),5e3)},[]),Fe=We({value:Oe,apply:o=>{Ks(o);try{localStorage.setItem(ds,o)}catch{}},send:o=>{const m=ee.current;return m?m.setPermissionMode(o):Promise.reject(new Error("adapter not ready"))},onError:(o,m)=>{console.error("[SessionDetail] set permission mode failed:",o),te(m==="send"?K("session.mode.switchFailedRequest",{message:o}):o||c("session.mode.switchFailed"))}}),st=l.useCallback(o=>Fe.set(o),[Fe]),[_t,Ls]=l.useState(()=>localStorage.getItem(hs)||"normal"),Ke=We({value:_t,apply:o=>{Ls(o);try{localStorage.setItem(hs,o)}catch{}},send:o=>{const m=ee.current;return m?m.setTokenMode(o):Promise.reject(new Error("adapter not ready"))},onError:(o,m)=>{console.error("[SessionDetail] set token mode failed:",o),te(m==="send"?K("session.tokenMode.failedRequest",{message:o}):o||c("session.tokenMode.failed"))}}),nt=We({value:$e,apply:o=>{Ds(o);try{localStorage.setItem(us,o)}catch{}},send:o=>{var M;const m=ee.current;if(!m)return Promise.reject(new Error("adapter not ready"));const v=((M=Ve.find(D=>D.value===o))==null?void 0:M.tokens)??null;return m.setThinkingBudget(v)},onError:(o,m)=>{console.error("[SessionDetail] set thinking budget failed:",o),te(m==="send"?K("session.thinking.failedRequest",{message:o}):o||c("session.thinking.failed"))}}),P=l.useMemo(()=>new $r(r,ne,{onStatusChange:o=>{var m;d(o),be(o==="running"||o==="requires_action"),(m=Ue.current)==null||m.onStatus(o,Nt.current)},onError:o=>{console.error("[RCSChatAdapter] error:",o)},onPermissionRequest:o=>{de(m=>m.some(v=>v.requestId===o.requestId)?m:[...m,o])},onModelsStateChange:o=>{Ye(o)},onSubagentUpdate:o=>{Is(o)},onControlResponse:o=>{nt.handleControlResponse(o)||Ke.handleControlResponse(o)||Mt.handleControlResponse(o)||Fe.handleControlResponse(o)},onPermissionModeChange:o=>{Fe.sync(o)},onUsageChange:o=>{Ps(m=>({inputTokens:Math.max((m==null?void 0:m.inputTokens)??0,o.inputTokens),outputTokens:Math.max((m==null?void 0:m.outputTokens)??0,o.outputTokens),totalCostUsd:o.totalCostUsd??(m==null?void 0:m.totalCostUsd)??null}))},onWorkerInfoChange:o=>{$s(m=>JSON.stringify(m)===JSON.stringify(o)?m:o)},onTurnStart:o=>{Us(o)},onElicitationRequest:o=>{gt(o)}}),[r,te]);l.useEffect(()=>(ee.current=P,()=>{P.disconnect()}),[P]);const U=l.useMemo(()=>ya(Q),[Q]),St=l.useRef(!1);l.useEffect(()=>{var v;if(!U.set_max_thinking_tokens||St.current)return;const o=ee.current;if(!o)return;const m=((v=Ve.find(M=>M.value===$e))==null?void 0:v.tokens)??null;o.setThinkingBudget(m).then(()=>{St.current=!0}).catch(M=>console.error("[SessionDetail] reconcile thinking budget failed:",M))},[U.set_max_thinking_tokens,$e,Q]);const Ct=U.stop_task?o=>{P.stopSubagent(o).then(m=>{m.ok||re(m.error||c("session.stopTask.failed"))})}:void 0,Tt=l.useRef(!1);l.useEffect(()=>{if(!U.set_token_mode||Tt.current)return;const o=ee.current;o&&(Tt.current=!0,o.getRemoteSettings().then(m=>{const v=m==null?void 0:m.applied.tokenMode;(v==="normal"||v==="poor"||v==="sa")&&Ke.sync(v)}).catch(m=>console.error("[SessionDetail] reconcile token mode failed:",m)))},[U.set_token_mode,Ke]);const Bs=Z(),rt=l.useMemo(()=>Dn((Q==null?void 0:Q.commands)??[],(Q==null?void 0:Q.skills)??[]),[Q,Bs]),Ne=l.useMemo(()=>qn(ye,I),[ye,I]),Hs=l.useCallback(o=>nt.set(o),[nt]),[Et,Ws]=l.useState(()=>localStorage.getItem(fs)||"auto"),Mt=We({value:Et,apply:o=>{Ws(o);try{localStorage.setItem(fs,o)}catch{}},send:o=>{var M;const m=ee.current;if(!m)return Promise.reject(new Error("adapter not ready"));const v=(M=xt.find(D=>D.value===o))==null?void 0:M.effort;return m.setEffort(v)},onError:(o,m)=>{console.error("[SessionDetail] set effort failed:",o),te(m==="send"?K("session.effort.failedRequest",{message:o}):o||c("session.effort.failed"))}}),at=l.useCallback(()=>{var o;U.get_context_usage&&((o=ee.current)==null||o.getContextUsage().then(m=>{m&&(ht(m),fa(r,m))}).catch(()=>{}).finally(()=>Xe(!1)))},[U,r]);l.useEffect(()=>{if(!U.get_context_usage)return;at();const o=setInterval(at,6e4);return()=>clearInterval(o)},[U,X,at]),l.useEffect(()=>{Q&&!U.get_context_usage&&Xe(!1)},[Q,U]),l.useEffect(()=>{if(!Je)return;const o=setTimeout(()=>Xe(!1),1e4);return()=>clearTimeout(o)},[Je]);const Rt=l.useRef(J);Rt.current=J,l.useEffect(()=>ce.onEvent(m=>{m.type!=="artifact_created"&&m.type!=="artifact_updated"||(Rt.current&&As(v=>v+1),ft(v=>v+1))}),[]);const[Qs,zs]=l.useState(0),At=l.useRef(oe);At.current=oe,l.useEffect(()=>ce.onEvent(m=>{m.type==="memory_synced"&&At.current&&zs(v=>v+1)}),[]);const[_e,Vs]=l.useState("idle");l.useEffect(()=>ce.onStateChange(m=>Vs(m)),[]),l.useEffect(()=>{J&&ft(0)},[J]),l.useEffect(()=>{let o=!1;async function m(){u("");try{const v=await Wt(r);if(o)return;n(v),d(v.status),Qe(v.status)&&P.markClosed(),be(v.status==="running"||v.status==="requires_action")}catch(v){if(o)return;u(v instanceof Error?v.message:c("session.loadFailed"));return}try{await P.init()}catch(v){console.warn("Failed to init adapter:",v)}}return m(),()=>{o=!0}},[r,P]);const F=Qe(a),It=l.useRef(a);It.current=a,l.useEffect(()=>{if(F)return;let o=!1;const v=setInterval(async()=>{try{const M=await Wt(r);if(o||M.status===It.current)return;Qe(M.status)&&P.markClosed(),d(M.status),be(M.status==="running"||M.status==="requires_action")}catch{}},6e4);return()=>{o=!0,clearInterval(v)}},[r,F,P]);const B=(s==null?void 0:s.access_level)==="read",$t=qs??(Je&&!F&&!B?cs():null),ot=l.useCallback(()=>{ne([]),ht(cs()),Bt(r).catch(o=>{console.warn("[SessionDetail] Failed to clear session history:",o)})},[r]),Se=l.useCallback(async(o,m)=>{const v=ee.current;if(!v||F)return;if(o.sessionId===r){ne(D=>[...D,{type:"command_output",id:`cmd-resume-${Date.now()}`,commandName:"resume",inputText:m??"/resume",title:"Resume",subtitle:c("session.resume.title"),outputText:c("session.resume.currentBlocked"),variant:"error"}]);return}const M=(D,H="default")=>ne(ie=>[...ie,{type:"command_output",id:`cmd-resume-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,commandName:"resume",inputText:m??`/resume ${o.sessionId.slice(0,8)}`,title:"Resume",subtitle:c("session.resume.title"),outputText:D,variant:H}]);M(K("session.resume.restoring",{title:o.title??""}));try{await Bt(r),ne([]);const D=await v.resumeSession(o.sessionId);M(D.title?K("session.resume.restoredWithTitle",{count:D.messageCount,title:D.title}):K("session.resume.restored",{count:D.messageCount}))}catch(D){M(K("session.resume.failed",{message:D instanceof Error?D.message:String(D)}),"error")}},[F,r]),Gs=l.useCallback(async()=>{if(s!=null&&s.environment_id)try{const o=await Pn({environment_id:s.environment_id});window.location.href=`/code/${o.id}?resumeFrom=${r}`}catch(o){re(K("session.createFailedWithReason",{message:o instanceof Error?o.message:String(o)}))}},[s,r,re]),Ys=l.useRef(new URLSearchParams(window.location.search).get("resumeFrom")),Dt=l.useRef(!1);l.useEffect(()=>{const o=Ys.current;!o||Dt.current||!Q||!U.resume||(Dt.current=!0,window.history.replaceState({},"",window.location.pathname),Se({sessionId:o,title:o.slice(0,8),modified:0},null))},[Q,U.resume,Se]);const Le=l.useCallback(async o=>{const m=o.text.trim(),v=o.images&&o.images.length>0||o.attachments&&o.attachments.length>0;if(!m&&!v||F)return;const M=/^\/resume(?:\s+(.*))?$/.exec(m);if(M){const H=(M[1]??"").trim();if(!U.resume){ne(ie=>[...ie,{type:"user_message",id:`user-${Date.now()}`,content:m},{type:"command_output",id:`cmd-${Date.now()}`,commandName:"resume",inputText:m,title:"Resume",subtitle:c("session.resume.title"),outputText:c("session.resume.unsupported"),variant:"error"}]);return}H?await Se({sessionId:H,title:H,modified:0},m):h(!0);return}const D=await On(m,{sessionId:r,availableCommands:rt,availableModels:(z==null?void 0:z.availableModels)??[],currentModel:z?{modelId:z.currentModelId,name:z.currentModelId}:null,supportsImages:!0,entries:vt.current,setModel:async H=>{await V(r,{type:"control_request",request:{subtype:"set_model",model:H}}),Ye(ie=>ie&&{...ie,currentModelId:H})},onNewSession:()=>{ne([])}}).catch(()=>null);if(D){if(ze("[SessionDetail] local command result",D),"clearEntries"in D&&D.clearEntries){ot();return}if("newSession"in D&&D.newSession){ot();return}if("userEntry"in D){ne(H=>[...H,D.userEntry,D.cmdEntry]);return}}be(!0);try{await P.sendMessage(m,o.images,o.attachments)}catch(H){if(console.error("Send failed:",H),H instanceof Un&&H.type==="session_closed"){d("archived"),P.markClosed(),re(c("session.closedSendBlocked"));return}re(`${c("session.sendFailed")}${H instanceof Error?`: ${H.message}`:""}`)}},[P,F,r,z,rt,ot,re,Se,U]),Js=l.useCallback(o=>{if(X){Pe(m=>[...m,o]);return}Le(o)},[X,Le]),it=l.useRef(!1);l.useEffect(()=>{if(F){Pe(m=>m.length>0?[]:m);return}if(X||qe.length===0||it.current)return;const o=qe[0];o&&(it.current=!0,Pe(m=>m.slice(1)),Le(o).finally(()=>{it.current=!1}))},[X,qe,Le,F]);const Xs=l.useCallback((o,m)=>{if(X)return;const v=m==="edit"?c("session.rewind.confirmEdit"):c("session.rewind.confirm");window.confirm(`${v}
|
|
83
|
+
${c("session.rewind.confirmBody")}`)&&P.rewindToMessage(o.id).then(()=>{m==="edit"&&o.content&&N(M=>({text:o.content,nonce:M.nonce+1}))}).catch(M=>{console.error("[SessionDetail] rewind failed:",M),re(K("session.rewind.failed",{message:M instanceof Error?M.message:String(M)}))})},[X,re]),Zs=l.useCallback(o=>{const m=Ne.orderedMatchIds;if(m.length===0)return;const v=(o%m.length+m.length)%m.length;E(v);const M=m[v],D=document.querySelector(`[data-entry-id="${CSS.escape(M)}"]`);D==null||D.scrollIntoView({block:"center",behavior:"smooth"})},[Ne]),qt=l.useCallback(async()=>{try{await P.interrupt()}catch(o){console.error("Interrupt failed:",o)}finally{be(!1)}},[P]),en=l.useCallback(()=>{st(ga(Oe))},[st,Oe]);l.useEffect(()=>()=>{ke.current&&clearTimeout(ke.current),ve.current&&clearTimeout(ve.current)},[]);const tn=l.useCallback(async()=>{if(s&&window.confirm(c("dashboard.confirmDelete").replace("{id}",s.title||s.id)))try{await Ht(s.id),window.location.href="/code/"}catch(o){alert(o instanceof Error?o.message:c("dashboard.deleteFailed"))}},[s]),sn=l.useCallback(async o=>{try{await P.respondPermission(o,!0)}catch(m){console.error("Failed to approve:",m)}de(m=>m.filter(v=>v.requestId!==o))},[P]),nn=l.useCallback(async(o,m)=>{try{await P.respondPermission(o,!0,{updated_permissions:m})}catch(v){console.error("Failed to approve with rules:",v)}de(v=>v.filter(M=>M.requestId!==o))},[P]),rn=l.useCallback(async(o,m)=>{const v=De;if(gt(null),!!v)try{await P.respondElicitation(v.requestId,o,m)}catch(M){console.error("Failed to submit elicitation:",M)}},[De,P]),an=l.useCallback(()=>{!s||B||(yt(s.title||""),Ze(!0),setTimeout(()=>{var o,m;(o=tt.current)==null||o.focus(),(m=tt.current)==null||m.select()},0))},[s,B]),Pt=l.useCallback(async()=>{const o=et.trim();if(Ze(!1),!(!s||!o||o===s.title))try{const m=await Fn(s.id,o);n(v=>v&&{...v,title:m.title??o})}catch(m){console.error("Rename failed:",m),alert(m instanceof Error?m.message:c("session.rename.failed"))}},[s,et]),on=l.useCallback(async o=>{try{await P.respondPermission(o,!1)}catch(m){console.error("Failed to reject:",m)}de(m=>m.filter(v=>v.requestId!==o))},[P]),ln=l.useCallback(async(o,m,v)=>{try{await V(r,{type:"permission_response",approved:!0,request_id:o,updated_input:{questions:v,answers:m}})}catch(M){console.error("Failed to submit answers:",M)}de(M=>M.filter(D=>D.requestId!==o))},[r]),cn=l.useCallback(async(o,m,v)=>{try{m==="no"?await V(r,{type:"permission_response",approved:!1,request_id:o,...v?{message:v}:{}}):await V(r,{type:"permission_response",approved:!0,request_id:o,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[m]||"default",destination:"session"}]})}catch(M){console.error("Failed to submit plan response:",M)}de(M=>M.filter(D=>D.requestId!==o))},[r]);return i?e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(He,{onBack:t,title:e.jsx("span",{className:"text-xs font-medium text-text-muted",children:c("session.loadFailed")})}),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:i}),e.jsx("a",{href:"/code/",className:"mt-4 inline-block text-brand-text hover:underline",children:c("session.backToDashboard")})]})})]}):s?s.source==="acp"&&s.environment_id?e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:s.title||s.id}),e.jsx(He,{onBack:t,title:e.jsx("span",{className:"truncate text-xs font-semibold text-text-primary",children:s.title||s.id}),meta:e.jsx("span",{className:"rounded-full bg-brand/15 px-2 py-0.5 text-[10px] font-medium text-brand-text",children:"ACP"})}),e.jsx(Ca,{sessionId:r,agentId:s.environment_id})]}):e.jsx(bs,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx("h1",{className:"sr-only",children:s.title||s.id}),e.jsx(He,{onBack:t,title:Fs?e.jsx("input",{ref:tt,value:et,onChange:o=>yt(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),Pt()):o.key==="Escape"&&(o.preventDefault(),Ze(!1))},onBlur:()=>void Pt(),maxLength:200,className:"w-full max-w-xs rounded-md border border-brand/50 bg-surface-2 px-2 py-0.5 text-xs font-semibold text-text-primary focus:outline-none focus:ring-2 focus:ring-brand/30"}):e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"flex min-w-0 items-center gap-2 text-xs font-semibold text-text-primary",children:!B&&!F?e.jsx("button",{type:"button",onClick:an,title:c("session.rename.title"),className:"truncate text-left transition-colors hover:text-text-secondary",children:s.title||s.id}):e.jsx("span",{className:"truncate",children:s.title||s.id})}),s.visibility&&e.jsx(sr,{visibility:s.visibility||"private",className:"hidden flex-shrink-0 text-[10px] sm:inline-flex"})]}),meta:e.jsx(e.Fragment,{children:(()=>{var v;const o=s.source==="acp"?"acp":(v=s.environment)==null?void 0:v.worker_type,m=Qt(o);return e.jsx("span",{className:`hidden items-center rounded-full px-2 py-0.5 text-[10px] font-medium sm:inline-flex ${m.colorClass}`,children:m.fullLabel})})()}),actions:e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs("button",{onClick:()=>q(!J),className:`relative flex h-7 w-7 items-center justify-center rounded-md transition-colors ${J?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:c("artifacts.title"),children:[e.jsx(Kn,{className:"h-3.5 w-3.5"}),Ge>0&&!J&&e.jsx("span",{className:"absolute -right-0.5 -top-0.5 flex h-3.5 min-w-3.5 items-center justify-center rounded-full bg-brand px-0.5 text-[10px] font-bold text-white",children:Ge>9?"9+":Ge})]}),e.jsx("button",{onClick:()=>Ms(!oe),className:`flex h-7 w-7 items-center justify-center rounded-md transition-colors ${oe?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:c("memories.title"),children:e.jsx(js,{className:"h-3.5 w-3.5"})}),U.side_question&&!F&&!B&&e.jsx("button",{onClick:()=>j(!_),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${_?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:c("session.sideQuestion.title"),children:e.jsx(vs,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>{const o=!w;S(o),o?setTimeout(()=>{var m;return(m=$.current)==null?void 0:m.focus()},0):(T(""),E(0))},className:`flex h-7 w-7 items-center justify-center rounded-md transition-colors ${w?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:c("session.search.title"),children:e.jsx(ut,{className:"h-3.5 w-3.5"})}),U.mcp_management&&!F&&!B&&e.jsx("button",{onClick:()=>y(!g),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${g?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:c("session.mcp.title"),children:e.jsx(Ns,{className:"h-3.5 w-3.5"})}),U.remote_settings&&!F&&!B&&e.jsx("button",{onClick:()=>C(!k),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${k?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:c("session.settings.title"),children:e.jsx(_s,{className:"h-3.5 w-3.5"})}),!B&&(s==null?void 0:s.access_level)!=="write"&&e.jsx("button",{onClick:()=>se(!0),className:"flex h-7 w-7 items-center justify-center rounded-md text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors",title:c("session.share"),children:e.jsx(Tr,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>L(!O),className:"hidden h-7 w-7 items-center justify-center rounded-md text-text-muted hover:bg-surface-2 hover:text-text-secondary transition-colors sm:flex",title:c("session.info"),children:e.jsx(pr,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>p(!f),className:"ml-0.5 flex items-center gap-1 rounded-md px-2 py-1 text-xs font-semibold text-text-primary hover:bg-brand-light hover:text-white transition-colors",children:[c("session.tasks"),je.length>0&&e.jsx("span",{className:"rounded-full bg-status-warning/15 px-1.5 py-0.5 text-[10px] font-medium text-status-warning",children:je.length})]})]})})}),O&&e.jsx("div",{className:"flex-shrink-0 border-b bg-surface-1 py-2",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8",children:e.jsxs("div",{className:"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:c("session.metaSession")})," ",s.id]}),s.environment_id&&e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:c("session.metaEnvironment")})," ",s.environment_id]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:c("session.metaStatus")})," ",a]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:c("session.metaWorker")})," ",Qt(s.source==="acp"?"acp":(Ot=s.environment)==null?void 0:Ot.worker_type).fullLabel]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:c("session.metaCreated")})," ",ys(s.created_at)]})]})})}),(_e==="reconnecting"||_e==="failed")&&e.jsxs("div",{className:`flex items-center justify-center gap-2 px-4 py-1.5 text-xs font-medium ${_e==="failed"?"bg-status-error/10 text-status-error":"bg-status-warning/10 text-status-warning"}`,children:[e.jsx("span",{className:`inline-block h-1.5 w-1.5 rounded-full ${_e==="failed"?"bg-status-error":"animate-pulse bg-status-warning"}`}),_e==="failed"?c("session.sseFailed"):c("session.sseReconnecting")]}),J&&e.jsx("div",{className:"border-b bg-surface-1 py-4",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8",children:e.jsx(tr,{sessionId:r,embedded:!0,refreshTick:Rs})})}),oe&&e.jsx("div",{className:"border-b bg-surface-1 py-4",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8",children:e.jsx(nr,{sessionId:r,embedded:!0,refreshTick:Qs})})}),w&&e.jsx("div",{className:"border-b bg-surface-1 py-2",children:e.jsxs("div",{className:"mx-auto flex page-measure px-4 sm:px-8 items-center gap-2",children:[e.jsx(ut,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{ref:$,value:I,onChange:o=>{T(o.target.value),E(0)},onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),Zs(I&&o.shiftKey?b-1:b+1)):o.key==="Escape"&&(o.preventDefault(),S(!1),T(""))},placeholder:c("session.search.placeholder"),className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"}),I.trim()&&e.jsx("span",{className:"flex-shrink-0 font-mono text-[10px] text-text-muted",children:Ne.orderedMatchIds.length===0?c("session.search.noResults"):`${b+1}/${Ne.orderedMatchIds.length}`})]})}),e.jsx(Ln,{entries:ye,isLoading:X,turnStartedAt:Os,emptyTitle:c("session.emptyTitle"),emptyDescription:c("session.emptyDescription"),searchMatchIds:I.trim()?Ne.matchIds:void 0,onRewindEntry:U.rewind&&!F&&!B&&!X?(o,m)=>Xs(o,m):void 0}),e.jsx(Ur,{state:pt,onStopTask:Ct}),je.length>0&&e.jsx("div",{className:"border-t bg-surface-1 py-3",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8 space-y-3",children:je.map(o=>e.jsx(Sa,{request:o,onApprove:()=>sn(o.requestId),onApproveAlways:o.suggestions&&o.suggestions.length>0?()=>nn(o.requestId,o.suggestions??[]):void 0,onReject:()=>on(o.requestId),onSubmitAnswers:ln,onSubmitPlan:cn},o.requestId))})}),De&&e.jsx("div",{className:"border-t bg-surface-1 py-3",children:e.jsx("div",{className:"mx-auto page-measure px-4 sm:px-8",children:e.jsx(na,{request:De,onSubmit:rn})})}),wt&&e.jsx("div",{className:"mx-auto page-measure w-full px-4 sm:px-8 pb-1",children:e.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 px-3 py-1.5 text-xs text-red-700 dark:text-red-300",children:wt})}),bt&&e.jsx("div",{className:"mx-auto page-measure w-full px-4 sm:px-8 pb-1",children:e.jsx("div",{className:"rounded-lg bg-red-50 dark:bg-red-900/20 border border-red-200 dark:border-red-800 px-3 py-1.5 text-xs text-red-700 dark:text-red-300",children:bt})}),e.jsxs("div",{className:"page-measure mx-auto w-full px-4 sm:px-8 pb-1 flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(_a,{mode:Oe,onModeChange:st,disabled:F||B}),e.jsx(Na,{models:(z==null?void 0:z.availableModels)??[],currentModelId:(z==null?void 0:z.currentModelId)??null,onSelect:o=>{V(r,{type:"control_request",request:{subtype:"set_model",model:o}}),Ye(m=>m&&{...m,currentModelId:o})},disabled:F||B}),U.set_max_thinking_tokens&&e.jsx(ba,{budget:$e,onBudgetChange:Hs,disabled:F||B}),U.set_effort&&e.jsx(ja,{effort:Et,onEffortChange:o=>Mt.set(o),disabled:F||B}),U.set_token_mode&&e.jsx(wa,{mode:_t,onModeChange:o=>Ke.set(o),disabled:F||B})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[$t&&e.jsx(va,{usage:$t}),we&&e.jsxs("span",{className:"text-[10px] text-text-muted font-mono",title:c("session.usage.total"),children:[me(we.inputTokens)," in / ",me(we.outputTokens)," out",we.totalCostUsd!=null&&` · $${we.totalCostUsd.toFixed(2)}`]})]})]}),F&&(s==null?void 0:s.environment_id)&&e.jsx("div",{className:"mx-auto w-full page-measure px-4 pb-2 sm:px-8",children:e.jsx("button",{type:"button",onClick:()=>void Gs(),className:"w-full rounded-lg border border-border bg-surface-1 px-4 py-2.5 text-sm text-text-secondary transition-colors hover:bg-surface-2 hover:text-text-primary",children:c("session.resumeInNew")})}),e.jsx(Bn,{onSubmit:Js,isLoading:X,onInterrupt:qt,onCycleMode:en,disabled:F||B,placeholder:F?c("session.closed"):B?c("session.readOnly"):c("session.inputPlaceholder"),supportsAttachments:!0,commands:rt,queueWhileLoading:!0,queuedCount:qe.length,onDequeue:o=>Pe(m=>m.filter((v,M)=>M!==o)),onSearchFiles:U.file_search?o=>P.searchFiles(o):void 0,historyKey:r,draftOverride:A}),g&&e.jsx(Vr,{onClose:()=>y(!1),fetchServers:()=>P.getMcpServers(),onToggle:(o,m)=>P.toggleMcpServer(o,m),onReconnect:o=>P.reconnectMcpServer(o)}),k&&e.jsx(Yr,{onClose:()=>C(!1),fetchSettings:()=>P.getRemoteSettings(),onApply:o=>P.applyFlagSettings(o)}),_&&e.jsx(Jr,{onClose:()=>j(!1),onAsk:o=>P.askSideQuestion(o)}),f&&s&&e.jsx(Lr,{onClose:()=>p(!1),session:s,liveStatus:a,pendingPermissions:je,subagentState:pt,onStopTask:Ct,onInterrupt:qt,onDelete:tn,onEndSession:U.end_session&&!F&&!B?async()=>{await P.endSession("ended from web"),await Ht(s.id),window.location.href="/code/"}:void 0}),e.jsx(ia,{open:Y,onClose:()=>se(!1),sessionId:s.id,sessionTitle:s.title||void 0}),e.jsx(da,{open:x,onClose:()=>h(!1),adapter:P,onResume:o=>{h(!1),Se(o,null)}})]})}):e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(He,{onBack:t,title:e.jsx("span",{className:"h-3.5 w-40 animate-pulse rounded bg-surface-2"})}),e.jsx("div",{className:"flex flex-1 items-center justify-center",children:e.jsx("div",{className:"text-text-muted",children:c("session.loading")})})]})}function Sa({request:r,onApprove:t,onApproveAlways:s,onReject:n,onSubmitAnswers:a,onSubmitPlan:d}){const i=r.toolName,u=r.toolInput,f=r.description||"";if(i==="AskUserQuestion"){const p=u.questions||[];return e.jsx(Zr,{requestId:r.requestId,questions:p,description:f,onSubmit:g=>a(r.requestId,g,p),onSkip:n})}if(i==="ExitPlanMode"){const p=u.plan||"";return e.jsx(ta,{requestId:r.requestId,planContent:p,description:f,onSubmit:(g,y)=>d(r.requestId,g,y)})}return e.jsx(Xr,{requestId:r.requestId,toolName:i,toolInput:u,description:f,suggestions:r.suggestions,onApprove:t,onApproveAlways:s,onReject:n})}function Ca({sessionId:r,agentId:t}){const[s,n]=l.useState(null),[a,d]=l.useState("disconnected"),[i,u]=l.useState(null),f=l.useRef(null);return l.useEffect(()=>{const p=ha(t);return p.setConnectionStateHandler((g,y)=>{d(g),u(y||null)}),f.current=p,n(p),p.connect().catch(g=>{g instanceof Hn||(u(g.message),d("error"))}),()=>{p.disconnect(),f.current=null,n(null),d("disconnected")}},[t]),e.jsx(bs,{children:e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[i&&a==="error"&&e.jsx("div",{className:"px-4 py-2 bg-destructive/10 text-destructive text-sm border-b",children:i}),a==="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:c("session.connectingAgent")})]})}),a==="error"&&!s&&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:c("session.connectionFailed")}),e.jsx("p",{className:"text-text-muted text-sm",children:i})]})}),s&&a==="connected"&&e.jsx("div",{className:"flex-1 min-h-0",children:e.jsx(Wn,{client:s,agentId:t})})]})})}export{La as SessionDetail};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{j as e}from"./vendor-DE_-CLIE.js";import{av as c,V as n,at as i}from"./main-BKbA2ddo.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{j as e}from"./vendor-DE_-CLIE.js";import{ap as c,V as n,an as i}from"./ma
|
|
|
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
|
|
11
|
+
*/const b=[["rect",{width:"18",height:"11",x:"3",y:"11",rx:"2",ry:"2",key:"1w4ew1"}],["path",{d:"M7 11V7a5 5 0 0 1 10 0v4",key:"fwvmzm"}]],m=c("lock",b);function u({visibility:o,className:t}){const a={private:{label:"Private",Icon:m,colorClass:"text-text-muted border-border/60"},team:{label:"Team",Icon:n,colorClass:"text-accent border-accent/40"},public:{label:"Public",Icon:x,colorClass:"text-accent border-accent/40"}},{label:s,Icon:r,colorClass:l}=a[o];return e.jsxs("span",{className:i("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",l,t),children:[e.jsx(r,{className:"h-3 w-3"}),s]})}export{u as S};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aQ as v,c as N,aJ as t}from"./main-BKbA2ddo.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function E({onSuccess:p,onAlreadyDone:b}){const{setup:h}=v(),[d,f]=r.useState(""),[l,y]=r.useState(""),[a,g]=r.useState(""),[u,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!==u){o(t("auth.setup.passwordMismatch"));return}m(!0);try{await h(d,l,a),p()}catch(x){const n=x instanceof Error?x.message:"Setup failed";if(n.includes("already")||n.includes("409")){b();return}o(n)}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:"hero-enter w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(N,{className:"mx-auto mb-5 h-10 w-10"}),e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight 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:d,onChange:s=>f(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:u,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.5 font-display text-sm font-medium text-white shadow-lg shadow-brand/25 transition-all hover:-translate-y-0.5 hover:bg-brand-light hover:shadow-brand/40 disabled:cursor-not-allowed disabled:opacity-50 disabled:hover:translate-y-0 disabled:hover:shadow-none",children:c?t("common.loading"):t("auth.setup.submit")})]})]})})}export{E as Setup};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{aj as m,b as h}from"./main-BKbA2ddo.js";import"./preload-helper-BiaRt2Oj.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-text hover:underline",children:"← Back to Dashboard"})]})})}export{j as ShareLanding};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{
|
|
1
|
+
import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{av as q,W as T,aR as M,aJ as t,e as B,X as F,aK as G,at as I,U as J,az as K,a8 as Q,aq as X,ap as Y,aQ as V,z as Z,m as ee,r as te,P as se,n as ae,p as ne,o as H,q as re,N as ie}from"./main-BKbA2ddo.js";import{R as U,E as oe}from"./RegisterEmpty-BoIy42g_.js";import{U as le,A as O}from"./UserSearchInput-xqtDX6Bz.js";import{C as D}from"./copy-CFZBXuu9.js";import{g as ce}from"./workerType-DW9l12WG.js";import"./preload-helper-BiaRt2Oj.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 r,j as e}from"./vendor-DE_-CLIE.js";import{ap as q,W as T,aL as D,aD
|
|
|
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 xe=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],ue=q("user-plus",xe);function W(n){const[x,i]=r.useState([]),[k,v]=r.useState(!1),l=r.useCallback(async()=>{if(n){v(!0);try{const p=await T("GET",`/web/teams/${n}/members`);i(p)}catch{i([])}finally{v(!1)}}},[n]);r.useEffect(()=>{l()},[l]);const b=r.useCallback(async(p,y)=>{await T("POST",`/web/teams/${n}/members`,{userId:p,role:y}),await l()},[n,l]),u=r.useCallback(async p=>{await T("DELETE",`/web/teams/${n}/members/${p}`),await l()},[n,l]),d=r.useCallback(async(p,y)=>{await T("PATCH",`/web/teams/${n}/members/${p}`,{role:y}),await l()},[n,l]);return{members:x,isLoading:k,addMember:b,removeMember:u,updateRole:d,refetch:l}}function pe(n){const[x,i]=r.useState([]),k=r.useCallback(async l=>{if(!n)return null;const b=await T("POST",`/web/teams/${n}/invitations`,l);return i(u=>[...u,b]),b},[n]),v=r.useCallback(async l=>{n&&(await T("DELETE",`/web/teams/${n}/invitations/${l}`),i(b=>b.filter(u=>u.token!==l)))},[n]);return{invitations:x,createInvitation:k,revokeInvitation:v}}function he({teamId:n,canManage:x}){D();const{invitations:i,createInvitation:k,revokeInvitation:v}=pe(n),{addMember:l}=W(n),[b,u]=r.useState(!1),[d,p]=r.useState(null),[y,C]=r.useState("member"),[m,w]=r.useState(!1),[g,f]=r.useState("member"),[j,_]=r.useState(null),[A,L]=r.useState(!1),[a,s]=r.useState(!1),[c,h]=r.useState(!1),N=async()=>{u(!0);try{const o=await k({role:y,expiresIn:86400,maxUses:5});o&&p(o.token||o.inviteToken||null)}catch{}finally{u(!1)}},$=async()=>{if(!d)return;const o=`${window.location.origin}/join?invite=${d}`;let S=!1;try{navigator.clipboard&&window.isSecureContext&&(await navigator.clipboard.writeText(o),S=!0)}catch{}if(!S){const E=document.createElement("textarea");E.value=o,E.style.position="fixed",E.style.top="0",E.style.opacity="0",document.body.appendChild(E),E.focus(),E.select(),E.setSelectionRange(0,o.length);try{S=document.execCommand("copy")}catch{S=!1}document.body.removeChild(E)}S?(h(!1),s(!0),setTimeout(()=>s(!1),2e3)):(s(!1),h(!0),setTimeout(()=>h(!1),4e3))},R=async o=>{L(!0),_(null);try{await l(o,g),w(!1)}catch(S){_(S instanceof Error?S.message:t("invitation.addFailed"))}finally{L(!1)}};return e.jsxs("section",{className:"ds-page-row",children:[e.jsx("h2",{children:t("team.detail.invitations")}),x&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{className:"rounded-md border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-text-primary focus:border-accent focus:outline-none",value:y,onChange:o=>C(o.target.value),"aria-label":t("team.member.role"),children:[e.jsx("option",{value:"member",children:t("invitation.member")}),e.jsx("option",{value:"admin",children:t("invitation.admin")})]}),e.jsx("button",{type:"button",onClick:N,disabled:b,className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-text-primary transition-colors hover:bg-surface-2 disabled:opacity-40",children:b?t("invitation.creating"):t("invitation.create")}),e.jsxs("button",{type:"button",onClick:()=>w(o=>!o),"aria-pressed":m,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs font-medium text-text-primary transition-colors hover:bg-surface-2",title:t("invitation.addExistingHint"),children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),t("invitation.addExisting")]})]}),d&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-1 px-3 py-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-text-primary",children:`${window.location.origin}/join?invite=${d}`}),e.jsx("button",{type:"button",onClick:$,className:a?"text-status-active":"text-text-muted hover:text-text-primary",title:a?t("share.copied"):t("share.copy"),children:a?e.jsx(B,{className:"h-4 w-4"}):e.jsx(U,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>p(null),className:"text-text-muted hover:text-text-primary","aria-label":t("common.cancel"),children:e.jsx(F,{className:"h-4 w-4"})})]}),c&&e.jsx("p",{className:"text-xs text-status-error",children:t("share.copyFailed")}),m&&x&&e.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-surface-1 p-3",children:[e.jsx("p",{className:"text-xs text-text-muted",children:t("invitation.addExistingHint")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("select",{className:"rounded-md border border-border bg-surface-2 px-2 py-1.5 text-sm text-text-primary focus:border-accent focus:outline-none",value:g,onChange:o=>f(o.target.value),"aria-label":t("team.member.role"),children:[e.jsx("option",{value:"member",children:t("invitation.member")}),e.jsx("option",{value:"admin",children:t("invitation.admin")})]})}),j&&e.jsx("p",{className:"text-xs text-destructive",children:j}),e.jsx(le,{onSelect:R,actionDisabled:A,placeholder:t("invitation.searchUser")})]}),i.length===0?e.jsx(M,{title:t("invitation.emptyTitle"),hint:t("invitation.emptyHint")}):e.jsx("div",{className:"ds-reg",children:i.map(o=>e.jsxs("div",{className:"ds-reg-row group",children:[e.jsxs("div",{className:"ds-reg-main",children:[e.jsx("span",{className:"ds-reg-tag shrink-0 rounded-full border border-border/60 bg-surface-2 text-text-muted",children:o.role==="admin"?t("invitation.admin"):t("invitation.member")}),e.jsx("span",{className:"ds-reg-meta truncate font-mono text-xs text-text-muted",children:G("invitation.expires",{date:new Date(o.expiresAt).toLocaleDateString()})})]}),x&&e.jsx("div",{className:"ds-reg-aside",children:e.jsx("button",{type:"button",onClick:()=>v(o.token),className:"ds-reg-delete rounded p-1 text-text-muted opacity-0 transition-all hover:text-status-error group-hover:opacity-100 focus-visible:opacity-100",title:t("invitation.revoke"),"aria-label":t("invitation.revoke"),children:e.jsx(F,{className:"h-4 w-4"})})})]},o.token))})]})}function be({teamId:n,canManage:x}){D();const[i,k]=r.useState([]),[v,l]=r.useState(!0),[b,u]=r.useState(null),[d,p]=r.useState(""),[y,C]=r.useState(null),[m,w]=r.useState(!1),g=async()=>{try{const a=await Y();k(a||[])}catch(a){u(a instanceof Error?a.message:t("team.detail.loadEnvsFailed"))}finally{l(!1)}};r.useEffect(()=>{g()},[]);const f=r.useMemo(()=>i.filter(a=>a.team_id===n),[i,n]),j=r.useMemo(()=>i.filter(a=>!a.team_id),[i]),_=async()=>{if(d){C(null);try{await Q(d,n),p(""),await g()}catch(a){C(a instanceof Error?a.message:t("team.detail.linkFailed"))}}},A=async a=>{if(window.confirm(t("team.detail.unlinkConfirm"))){C(null);try{await J(n,a),await g()}catch(s){C(s instanceof Error?s.message:t("team.detail.unlinkFailed"))}}},L=async()=>{const a=`slz rc --team-id ${n}`;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(a),w(!0),setTimeout(()=>w(!1),2e3);return}}catch{}const s=document.createElement("textarea");s.value=a,s.style.position="fixed",s.style.opacity="0",document.body.appendChild(s),s.select();try{document.execCommand("copy"),w(!0),setTimeout(()=>w(!1),2e3)}catch{}document.body.removeChild(s)};return e.jsxs("section",{className:"ds-page-row",children:[e.jsx("h2",{children:t("team.detail.environments")}),v?e.jsx("p",{className:"text-sm text-text-muted",children:t("common.loading")}):b?e.jsx("p",{className:"text-sm text-status-error",children:b}):e.jsxs(e.Fragment,{children:[f.length===0?e.jsx(M,{title:t("team.detail.envsEmptyTitle"),hint:t("team.detail.envsEmptyHint")}):e.jsx("div",{className:"ds-reg",children:f.map(a=>{var N,$;const s=ce(a.worker_type),c=((N=a.directory)==null?void 0:N.trim())||null,h=(($=a.owner_username)==null?void 0:$.trim())||null;return e.jsxs("div",{className:"ds-reg-row group",children:[e.jsxs("div",{className:"ds-reg-main",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-text-primary",children:a.machine_name||a.id}),e.jsx("span",{className:I("ds-reg-tag rounded-full",s.colorClass),children:s.fullLabel}),e.jsx(oe,{status:a.status,className:"ds-reg-tag"})]}),(c||h)&&e.jsxs("span",{className:"ds-reg-meta flex min-w-0 items-center gap-1.5 text-xs text-text-muted",children:[c&&e.jsx("span",{className:"min-w-0 truncate font-mono",children:c}),c&&h&&e.jsx("span",{className:"ds-reg-fact-sep","aria-hidden":"true",children:"·"}),h&&e.jsxs("span",{className:"ds-reg-owner",title:`${t("dashboard.envOwner")}: ${h}`,children:[e.jsx(K,{className:"h-3 w-3","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate",children:h})]})]})]}),e.jsxs("div",{className:"ds-reg-aside",children:[e.jsx("span",{className:"col-start-2 whitespace-nowrap font-mono text-xs tabular-nums text-text-muted",children:X(a.created_at)}),x&&e.jsx("button",{type:"button",onClick:()=>A(a.id),className:"ds-reg-delete rounded p-1 text-text-muted opacity-0 transition-all hover:text-status-error group-hover:opacity-100 focus-visible:opacity-100",title:t("team.detail.unlink"),"aria-label":t("team.detail.unlink"),children:e.jsx(me,{className:"h-4 w-4"})})]})]},a.id)})}),x&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-xs text-text-muted",children:t("team.detail.registerHint")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"rounded-md border border-border bg-surface-2 px-3 py-1.5 font-mono text-xs text-text-primary",children:["slz rc --team-id ",n]}),e.jsx("button",{type:"button",onClick:L,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":t("team.detail.copyCommand"),title:t("team.detail.copyCommand"),children:e.jsx(U,{className:"h-3.5 w-3.5"})}),m&&e.jsx("span",{className:"text-xs text-status-active",children:t("share.copied")})]})]}),j.length>0&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"team-link-env",className:"text-xs text-text-muted",children:t("team.detail.linkHint")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{id:"team-link-env",value:d,onChange:a=>p(a.target.value),className:"max-w-md rounded-md border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-text-primary focus:border-accent focus:outline-none",children:[e.jsx("option",{value:"",children:t("team.detail.linkSelect")}),j.map(a=>e.jsx("option",{value:a.id,children:a.machine_name||a.id},a.id))]}),e.jsx("button",{type:"button",onClick:_,disabled:!d,className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-text-primary transition-colors hover:bg-surface-2 disabled:opacity-40",children:t("team.detail.link")})]})]})]}),y&&e.jsx("p",{className:"text-sm text-status-error",children:y})]})]})}async function fe(n){try{const x=n.startsWith("team_")?`/web/teams/${n}`:`/web/teams/by-slug/${n}`;return await T("GET",x)}catch{return null}}const ye={owner:"team.member.roleOwner",admin:"team.member.roleAdmin",member:"team.member.roleMember"},P={owner:"border-brand/30 bg-brand/10 text-brand-text",admin:"border-accent/30 bg-accent/10 text-accent",member:"border-border/60 bg-surface-2 text-text-muted"};function z(n){return t(ye[n]||"team.member.roleMember")}function Se(){D();const n=window.location.pathname.split("/"),x=n[n.length-1]||"",[i,k]=r.useState(null),[v,l]=r.useState(!0),[b,u]=r.useState(!1),{members:d,isLoading:p,updateRole:y,removeMember:C}=W((i==null?void 0:i.id)||null),{user:m}=V(),[w,g]=r.useState("");if(r.useEffect(()=>{x&&(l(!0),fe(x).then(s=>{k(s),l(!1)}))},[x]),v)return e.jsx("div",{className:"ds-page text-sm text-text-muted",children:t("common.loading")});if(!i)return e.jsxs("div",{className:"ds-page",children:[e.jsx("div",{className:"ds-page-head",children:e.jsxs("a",{href:"/teams",className:"ds-page-back",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),t("team.detail.back")]})}),e.jsx("p",{className:"text-sm text-text-muted",children:t("team.detail.notFound")})]});const f=d.find(s=>s.user_id===(m==null?void 0:m.userId)),j=(m==null?void 0:m.role)==="admin"||(f==null?void 0:f.role)==="owner"||(f==null?void 0:f.role)==="admin",_=(m==null?void 0:m.role)==="admin"||(f==null?void 0:f.role)==="owner",A=async()=>{const s=i.id;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(s),u(!0),setTimeout(()=>u(!1),2e3);return}}catch{}const c=document.createElement("textarea");c.value=s,c.style.position="fixed",c.style.opacity="0",document.body.appendChild(c),c.select();try{document.execCommand("copy"),u(!0),setTimeout(()=>u(!1),2e3)}catch{}document.body.removeChild(c)},L=async(s,c)=>{if(s.role!==c){g("");try{await y(s.user_id,c)}catch(h){g(h instanceof Error?h.message:t("team.member.updateFailed"))}}},a=async s=>{const c=s.username||s.user_id;if(window.confirm(t("team.member.removeConfirm").replace("{name}",c))){g("");try{await C(s.user_id)}catch(N){g(N instanceof Error?N.message:t("team.member.updateFailed"))}}};return e.jsxs("div",{className:"ds-page",children:[e.jsxs("header",{className:"ds-page-head",children:[e.jsx("div",{className:"ds-page-runhead",children:e.jsx("span",{className:"ds-page-runhead-label",children:t("team.list.kicker")})}),e.jsxs("div",{className:"ds-page-titlerow",children:[e.jsx("h1",{className:"ds-page-title font-display font-semibold tracking-tight text-text-primary",children:i.name}),e.jsx("span",{className:"ds-page-count",children:G("team.detail.memberCount",{n:d.length})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"font-mono text-xs text-text-muted",children:["/",i.slug]}),e.jsx("span",{className:"font-mono text-xs text-text-muted","aria-hidden":"true",children:"·"}),e.jsx("code",{className:"font-mono text-xs text-text-muted",children:i.id}),e.jsx("button",{type:"button",onClick:A,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":t("team.detail.copyId"),title:t("team.detail.copyId"),children:e.jsx(U,{className:"h-3.5 w-3.5"})}),b&&e.jsx("span",{className:"text-xs text-status-active",children:t("share.copied")}),j&&e.jsx("a",{href:`/teams/${i.slug}/settings`,className:"ml-1 text-text-muted transition-colors hover:text-text-primary","aria-label":t("team.settings.title"),title:t("team.settings.title"),children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsx("a",{href:"/teams",className:"text-text-muted transition-colors hover:text-text-primary","aria-label":t("team.detail.back"),title:t("team.detail.back"),children:e.jsx(O,{className:"h-4 w-4"})})]}),i.description&&e.jsx("p",{className:"ds-page-lede",children:i.description})]}),e.jsxs("section",{className:"ds-page-row",children:[e.jsx("h2",{children:t("team.detail.members")}),w&&e.jsx("p",{className:"text-sm text-status-error",children:w}),p?e.jsx("p",{className:"text-sm text-text-muted",children:t("common.loading")}):d.length===0?e.jsx(M,{title:t("team.detail.membersEmptyTitle"),hint:t("team.detail.membersEmptyHint")}):e.jsx("div",{className:"ds-reg",children:d.map(s=>{const c=s.user_id===(m==null?void 0:m.userId),h=s.role==="owner"||s.role==="admin",N=j&&(!h||_),$=N&&!(s.role==="owner"&&d.filter(o=>o.role==="owner").length<=1),R=["owner","admin","member"];return e.jsxs("div",{className:"ds-reg-row",children:[e.jsxs("div",{className:"ds-reg-main",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-text-primary",children:s.username||s.user_id}),c&&e.jsx("span",{className:"shrink-0 text-xs text-text-muted",children:t("team.member.you")}),e.jsx("span",{className:I("ds-reg-tag shrink-0 rounded-full border",P[s.role]||P.member),children:z(s.role)})]}),e.jsx("span",{className:"ds-reg-meta min-w-0 truncate font-mono text-xs text-text-muted",children:s.user_id})]}),j&&e.jsx("div",{className:"ds-reg-aside",children:e.jsxs(ee,{children:[e.jsx(te,{asChild:!0,children:e.jsx("button",{type:"button",disabled:!N,className:"rounded p-1 text-text-muted transition-colors hover:bg-surface-1 hover:text-text-primary disabled:opacity-40 disabled:hover:bg-transparent","aria-label":t("team.member.changeRole"),title:t("team.member.changeRole"),children:e.jsx(se,{className:"h-4 w-4"})})}),e.jsxs(ae,{align:"end",className:"w-48",children:[e.jsx(ne,{className:"text-xs text-text-muted",children:t("team.member.changeRole")}),R.map(o=>e.jsxs(H,{onSelect:()=>L(s,o),className:"flex items-center justify-between",children:[e.jsx("span",{children:z(o)}),s.role===o&&e.jsx(B,{className:"h-3.5 w-3.5 text-brand-text"})]},o)),e.jsx(re,{}),e.jsxs(H,{variant:"destructive",disabled:!$,onSelect:()=>a(s),className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:t("team.member.remove")})]})]})]})})]},s.user_id)})})]}),e.jsx(be,{teamId:i.id,canManage:j}),e.jsx(he,{teamId:i.id,canManage:j})]})}export{Se as TeamDetail};
|
|
11
|
+
*/const xe=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],ue=q("user-plus",xe);function W(n){const[x,i]=r.useState([]),[k,v]=r.useState(!1),l=r.useCallback(async()=>{if(n){v(!0);try{const p=await T("GET",`/web/teams/${n}/members`);i(p)}catch{i([])}finally{v(!1)}}},[n]);r.useEffect(()=>{l()},[l]);const b=r.useCallback(async(p,y)=>{await T("POST",`/web/teams/${n}/members`,{userId:p,role:y}),await l()},[n,l]),u=r.useCallback(async p=>{await T("DELETE",`/web/teams/${n}/members/${p}`),await l()},[n,l]),d=r.useCallback(async(p,y)=>{await T("PATCH",`/web/teams/${n}/members/${p}`,{role:y}),await l()},[n,l]);return{members:x,isLoading:k,addMember:b,removeMember:u,updateRole:d,refetch:l}}function pe(n){const[x,i]=r.useState([]),k=r.useCallback(async l=>{if(!n)return null;const b=await T("POST",`/web/teams/${n}/invitations`,l);return i(u=>[...u,b]),b},[n]),v=r.useCallback(async l=>{n&&(await T("DELETE",`/web/teams/${n}/invitations/${l}`),i(b=>b.filter(u=>u.token!==l)))},[n]);return{invitations:x,createInvitation:k,revokeInvitation:v}}function he({teamId:n,canManage:x}){M();const{invitations:i,createInvitation:k,revokeInvitation:v}=pe(n),{addMember:l}=W(n),[b,u]=r.useState(!1),[d,p]=r.useState(null),[y,C]=r.useState("member"),[m,w]=r.useState(!1),[g,f]=r.useState("member"),[j,_]=r.useState(null),[R,L]=r.useState(!1),[a,s]=r.useState(!1),[c,h]=r.useState(!1),N=async()=>{u(!0);try{const o=await k({role:y,expiresIn:86400,maxUses:5});o&&p(o.token||o.inviteToken||null)}catch{}finally{u(!1)}},$=async()=>{if(!d)return;const o=`${window.location.origin}/join?invite=${d}`;let S=!1;try{navigator.clipboard&&window.isSecureContext&&(await navigator.clipboard.writeText(o),S=!0)}catch{}if(!S){const E=document.createElement("textarea");E.value=o,E.style.position="fixed",E.style.top="0",E.style.opacity="0",document.body.appendChild(E),E.focus(),E.select(),E.setSelectionRange(0,o.length);try{S=document.execCommand("copy")}catch{S=!1}document.body.removeChild(E)}S?(h(!1),s(!0),setTimeout(()=>s(!1),2e3)):(s(!1),h(!0),setTimeout(()=>h(!1),4e3))},A=async o=>{L(!0),_(null);try{await l(o,g),w(!1)}catch(S){_(S instanceof Error?S.message:t("invitation.addFailed"))}finally{L(!1)}};return e.jsxs("section",{className:"ds-page-row",children:[e.jsx("h2",{children:t("team.detail.invitations")}),x&&e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{className:"rounded-md border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-text-primary focus:border-accent focus:outline-none",value:y,onChange:o=>C(o.target.value),"aria-label":t("team.member.role"),children:[e.jsx("option",{value:"member",children:t("invitation.member")}),e.jsx("option",{value:"admin",children:t("invitation.admin")})]}),e.jsx("button",{type:"button",onClick:N,disabled:b,className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-text-primary transition-colors hover:bg-surface-2 disabled:opacity-40",children:b?t("invitation.creating"):t("invitation.create")}),e.jsxs("button",{type:"button",onClick:()=>w(o=>!o),"aria-pressed":m,className:"inline-flex items-center gap-1.5 rounded-md border border-border px-3 py-1.5 text-xs font-medium text-text-primary transition-colors hover:bg-surface-2",title:t("invitation.addExistingHint"),children:[e.jsx(ue,{className:"h-3.5 w-3.5"}),t("invitation.addExisting")]})]}),d&&e.jsxs("div",{className:"flex items-center gap-2 rounded-md border border-border bg-surface-1 px-3 py-2",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate font-mono text-xs text-text-primary",children:`${window.location.origin}/join?invite=${d}`}),e.jsx("button",{type:"button",onClick:$,className:a?"text-status-active":"text-text-muted hover:text-text-primary",title:a?t("share.copied"):t("share.copy"),children:a?e.jsx(B,{className:"h-4 w-4"}):e.jsx(D,{className:"h-4 w-4"})}),e.jsx("button",{type:"button",onClick:()=>p(null),className:"text-text-muted hover:text-text-primary","aria-label":t("common.cancel"),children:e.jsx(F,{className:"h-4 w-4"})})]}),c&&e.jsx("p",{className:"text-xs text-status-error",children:t("share.copyFailed")}),m&&x&&e.jsxs("div",{className:"space-y-3 rounded-md border border-border bg-surface-1 p-3",children:[e.jsx("p",{className:"text-xs text-text-muted",children:t("invitation.addExistingHint")}),e.jsx("div",{className:"flex items-center gap-2",children:e.jsxs("select",{className:"rounded-md border border-border bg-surface-2 px-2 py-1.5 text-sm text-text-primary focus:border-accent focus:outline-none",value:g,onChange:o=>f(o.target.value),"aria-label":t("team.member.role"),children:[e.jsx("option",{value:"member",children:t("invitation.member")}),e.jsx("option",{value:"admin",children:t("invitation.admin")})]})}),j&&e.jsx("p",{className:"text-xs text-destructive",children:j}),e.jsx(le,{onSelect:A,actionDisabled:R,placeholder:t("invitation.searchUser")})]}),i.length===0?e.jsx(U,{title:t("invitation.emptyTitle"),hint:t("invitation.emptyHint")}):e.jsx("div",{className:"ds-reg",children:i.map(o=>e.jsxs("div",{className:"ds-reg-row group",children:[e.jsxs("div",{className:"ds-reg-main",children:[e.jsx("span",{className:"ds-reg-tag shrink-0 rounded-full border border-border/60 bg-surface-2 text-text-muted",children:o.role==="admin"?t("invitation.admin"):t("invitation.member")}),e.jsx("span",{className:"ds-reg-meta truncate font-mono text-xs text-text-muted",children:G("invitation.expires",{date:new Date(o.expiresAt).toLocaleDateString()})})]}),x&&e.jsx("div",{className:"ds-reg-aside",children:e.jsx("button",{type:"button",onClick:()=>v(o.token),className:"ds-reg-delete rounded p-1 text-text-muted opacity-0 transition-all hover:text-status-error group-hover:opacity-100 focus-visible:opacity-100",title:t("invitation.revoke"),"aria-label":t("invitation.revoke"),children:e.jsx(F,{className:"h-4 w-4"})})})]},o.token))})]})}function be({teamId:n,canManage:x}){M();const[i,k]=r.useState([]),[v,l]=r.useState(!0),[b,u]=r.useState(null),[d,p]=r.useState(""),[y,C]=r.useState(null),[m,w]=r.useState(!1),g=async()=>{try{const a=await Q();k(a||[])}catch(a){u(a instanceof Error?a.message:t("team.detail.loadEnvsFailed"))}finally{l(!1)}};r.useEffect(()=>{g()},[]);const f=r.useMemo(()=>i.filter(a=>a.team_id===n),[i,n]),j=r.useMemo(()=>i.filter(a=>!a.team_id),[i]),_=async()=>{if(d){C(null);try{await Y(d,n),p(""),await g()}catch(a){C(a instanceof Error?a.message:t("team.detail.linkFailed"))}}},R=async a=>{if(window.confirm(t("team.detail.unlinkConfirm"))){C(null);try{await X(n,a),await g()}catch(s){C(s instanceof Error?s.message:t("team.detail.unlinkFailed"))}}},L=async()=>{const a=`slz rc --team-id ${n}`;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(a),w(!0),setTimeout(()=>w(!1),2e3);return}}catch{}const s=document.createElement("textarea");s.value=a,s.style.position="fixed",s.style.opacity="0",document.body.appendChild(s),s.select();try{document.execCommand("copy"),w(!0),setTimeout(()=>w(!1),2e3)}catch{}document.body.removeChild(s)};return e.jsxs("section",{className:"ds-page-row",children:[e.jsx("h2",{children:t("team.detail.environments")}),v?e.jsx("p",{className:"text-sm text-text-muted",children:t("common.loading")}):b?e.jsx("p",{className:"text-sm text-status-error",children:b}):e.jsxs(e.Fragment,{children:[f.length===0?e.jsx(U,{title:t("team.detail.envsEmptyTitle"),hint:t("team.detail.envsEmptyHint")}):e.jsx("div",{className:"ds-reg",children:f.map(a=>{var N,$;const s=ce(a.worker_type),c=((N=a.directory)==null?void 0:N.trim())||null,h=(($=a.owner_username)==null?void 0:$.trim())||null;return e.jsxs("div",{className:"ds-reg-row group",children:[e.jsxs("div",{className:"ds-reg-main",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-text-primary",children:a.machine_name||a.id}),e.jsx("span",{className:I("ds-reg-tag rounded-full",s.colorClass),children:s.fullLabel}),e.jsx(oe,{status:a.status,className:"ds-reg-tag"})]}),(c||h)&&e.jsxs("span",{className:"ds-reg-meta flex min-w-0 items-center gap-1.5 text-xs text-text-muted",children:[c&&e.jsx("span",{className:"min-w-0 truncate font-mono",children:c}),c&&h&&e.jsx("span",{className:"ds-reg-fact-sep","aria-hidden":"true",children:"·"}),h&&e.jsxs("span",{className:"ds-reg-owner",title:`${t("dashboard.envOwner")}: ${h}`,children:[e.jsx(J,{className:"h-3 w-3","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate",children:h})]})]})]}),e.jsxs("div",{className:"ds-reg-aside",children:[e.jsx("span",{className:"col-start-2 whitespace-nowrap font-mono text-xs tabular-nums text-text-muted",children:K(a.created_at)}),x&&e.jsx("button",{type:"button",onClick:()=>R(a.id),className:"ds-reg-delete rounded p-1 text-text-muted opacity-0 transition-all hover:text-status-error group-hover:opacity-100 focus-visible:opacity-100",title:t("team.detail.unlink"),"aria-label":t("team.detail.unlink"),children:e.jsx(me,{className:"h-4 w-4"})})]})]},a.id)})}),x&&e.jsxs("div",{className:"flex flex-col gap-3",children:[e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("span",{className:"text-xs text-text-muted",children:t("team.detail.registerHint")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("code",{className:"rounded-md border border-border bg-surface-2 px-3 py-1.5 font-mono text-xs text-text-primary",children:["slz rc --team-id ",n]}),e.jsx("button",{type:"button",onClick:L,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":t("team.detail.copyCommand"),title:t("team.detail.copyCommand"),children:e.jsx(D,{className:"h-3.5 w-3.5"})}),m&&e.jsx("span",{className:"text-xs text-status-active",children:t("share.copied")})]})]}),j.length>0&&e.jsxs("div",{className:"flex flex-col gap-1.5",children:[e.jsx("label",{htmlFor:"team-link-env",className:"text-xs text-text-muted",children:t("team.detail.linkHint")}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("select",{id:"team-link-env",value:d,onChange:a=>p(a.target.value),className:"max-w-md rounded-md border border-border bg-surface-2 px-2.5 py-1.5 text-xs text-text-primary focus:border-accent focus:outline-none",children:[e.jsx("option",{value:"",children:t("team.detail.linkSelect")}),j.map(a=>e.jsx("option",{value:a.id,children:a.machine_name||a.id},a.id))]}),e.jsx("button",{type:"button",onClick:_,disabled:!d,className:"inline-flex items-center rounded-md border border-border px-3 py-1.5 text-xs font-medium text-text-primary transition-colors hover:bg-surface-2 disabled:opacity-40",children:t("team.detail.link")})]})]})]}),y&&e.jsx("p",{className:"text-sm text-status-error",children:y})]})]})}async function fe(n){try{const x=n.startsWith("team_")?`/web/teams/${n}`:`/web/teams/by-slug/${n}`;return await T("GET",x)}catch{return null}}const ye={owner:"team.member.roleOwner",admin:"team.member.roleAdmin",member:"team.member.roleMember"},P={owner:"border-brand/30 bg-brand/10 text-brand-text",admin:"border-accent/30 bg-accent/10 text-accent",member:"border-border/60 bg-surface-2 text-text-muted"};function z(n){return t(ye[n]||"team.member.roleMember")}function Se(){M();const n=window.location.pathname.split("/"),x=n[n.length-1]||"",[i,k]=r.useState(null),[v,l]=r.useState(!0),[b,u]=r.useState(!1),{members:d,isLoading:p,updateRole:y,removeMember:C}=W((i==null?void 0:i.id)||null),{user:m}=V(),[w,g]=r.useState("");if(r.useEffect(()=>{x&&(l(!0),fe(x).then(s=>{k(s),l(!1)}))},[x]),v)return e.jsx("div",{className:"ds-page text-sm text-text-muted",children:t("common.loading")});if(!i)return e.jsxs("div",{className:"ds-page",children:[e.jsx("div",{className:"ds-page-head",children:e.jsxs("a",{href:"/teams",className:"ds-page-back",children:[e.jsx(O,{className:"h-3.5 w-3.5"}),t("team.detail.back")]})}),e.jsx("p",{className:"text-sm text-text-muted",children:t("team.detail.notFound")})]});const f=d.find(s=>s.user_id===(m==null?void 0:m.userId)),j=(m==null?void 0:m.role)==="admin"||(f==null?void 0:f.role)==="owner"||(f==null?void 0:f.role)==="admin",_=(m==null?void 0:m.role)==="admin"||(f==null?void 0:f.role)==="owner",R=async()=>{const s=i.id;try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(s),u(!0),setTimeout(()=>u(!1),2e3);return}}catch{}const c=document.createElement("textarea");c.value=s,c.style.position="fixed",c.style.opacity="0",document.body.appendChild(c),c.select();try{document.execCommand("copy"),u(!0),setTimeout(()=>u(!1),2e3)}catch{}document.body.removeChild(c)},L=async(s,c)=>{if(s.role!==c){g("");try{await y(s.user_id,c)}catch(h){g(h instanceof Error?h.message:t("team.member.updateFailed"))}}},a=async s=>{const c=s.username||s.user_id;if(window.confirm(t("team.member.removeConfirm").replace("{name}",c))){g("");try{await C(s.user_id)}catch(N){g(N instanceof Error?N.message:t("team.member.updateFailed"))}}};return e.jsxs("div",{className:"ds-page",children:[e.jsxs("header",{className:"ds-page-head",children:[e.jsx("div",{className:"ds-page-runhead",children:e.jsx("span",{className:"ds-page-runhead-label",children:t("team.list.kicker")})}),e.jsxs("div",{className:"ds-page-titlerow",children:[e.jsx("h1",{className:"ds-page-title font-display font-semibold tracking-tight text-text-primary",children:i.name}),e.jsx("span",{className:"ds-page-count",children:G("team.detail.memberCount",{n:d.length})})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"font-mono text-xs text-text-muted",children:["/",i.slug]}),e.jsx("span",{className:"font-mono text-xs text-text-muted","aria-hidden":"true",children:"·"}),e.jsx("code",{className:"font-mono text-xs text-text-muted",children:i.id}),e.jsx("button",{type:"button",onClick:R,className:"text-text-muted transition-colors hover:text-text-primary","aria-label":t("team.detail.copyId"),title:t("team.detail.copyId"),children:e.jsx(D,{className:"h-3.5 w-3.5"})}),b&&e.jsx("span",{className:"text-xs text-status-active",children:t("share.copied")}),j&&e.jsx("a",{href:`/teams/${i.slug}/settings`,className:"ml-1 text-text-muted transition-colors hover:text-text-primary","aria-label":t("team.settings.title"),title:t("team.settings.title"),children:e.jsx(Z,{className:"h-4 w-4"})}),e.jsx("a",{href:"/teams",className:"text-text-muted transition-colors hover:text-text-primary","aria-label":t("team.detail.back"),title:t("team.detail.back"),children:e.jsx(O,{className:"h-4 w-4"})})]}),i.description&&e.jsx("p",{className:"ds-page-lede",children:i.description})]}),e.jsxs("section",{className:"ds-page-row",children:[e.jsx("h2",{children:t("team.detail.members")}),w&&e.jsx("p",{className:"text-sm text-status-error",children:w}),p?e.jsx("p",{className:"text-sm text-text-muted",children:t("common.loading")}):d.length===0?e.jsx(U,{title:t("team.detail.membersEmptyTitle"),hint:t("team.detail.membersEmptyHint")}):e.jsx("div",{className:"ds-reg",children:d.map(s=>{const c=s.user_id===(m==null?void 0:m.userId),h=s.role==="owner"||s.role==="admin",N=j&&(!h||_),$=N&&!(s.role==="owner"&&d.filter(o=>o.role==="owner").length<=1),A=["owner","admin","member"];return e.jsxs("div",{className:"ds-reg-row",children:[e.jsxs("div",{className:"ds-reg-main",children:[e.jsxs("span",{className:"flex min-w-0 items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-sm font-medium text-text-primary",children:s.username||s.user_id}),c&&e.jsx("span",{className:"shrink-0 text-xs text-text-muted",children:t("team.member.you")}),e.jsx("span",{className:I("ds-reg-tag shrink-0 rounded-full border",P[s.role]||P.member),children:z(s.role)})]}),e.jsx("span",{className:"ds-reg-meta min-w-0 truncate font-mono text-xs text-text-muted",children:s.user_id})]}),j&&e.jsx("div",{className:"ds-reg-aside",children:e.jsxs(ee,{children:[e.jsx(te,{asChild:!0,children:e.jsx("button",{type:"button",disabled:!N,className:"rounded p-1 text-text-muted transition-colors hover:bg-surface-1 hover:text-text-primary disabled:opacity-40 disabled:hover:bg-transparent","aria-label":t("team.member.changeRole"),title:t("team.member.changeRole"),children:e.jsx(se,{className:"h-4 w-4"})})}),e.jsxs(ae,{align:"end",className:"w-48",children:[e.jsx(ne,{className:"text-xs text-text-muted",children:t("team.member.changeRole")}),A.map(o=>e.jsxs(H,{onSelect:()=>L(s,o),className:"flex items-center justify-between",children:[e.jsx("span",{children:z(o)}),s.role===o&&e.jsx(B,{className:"h-3.5 w-3.5 text-brand-text"})]},o)),e.jsx(re,{}),e.jsxs(H,{variant:"destructive",disabled:!$,onSelect:()=>a(s),className:"flex items-center gap-2",children:[e.jsx(ie,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:t("team.member.remove")})]})]})]})})]},s.user_id)})})]}),e.jsx(be,{teamId:i.id,canManage:j}),e.jsx(he,{teamId:i.id,canManage:j})]})}export{Se as TeamDetail};
|