@saluzi/saluzi-edu 0.5.21 → 0.5.22

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (186) hide show
  1. package/dist/cli.js +67 -63
  2. package/dist/guide/guide-data.json +174 -174
  3. package/dist/rcs-web/assets/AdminPanel-w39uutIr.js +1 -0
  4. package/dist/rcs-web/assets/ArtifactView-wUyXqsCU.js +1 -0
  5. package/dist/rcs-web/assets/{ArtifactsGallery-B63LTThv.js → ArtifactsGallery-DxVwQ8Wh.js} +15 -15
  6. package/dist/rcs-web/assets/Claim-D7HLQsN_.js +1 -0
  7. package/dist/rcs-web/assets/Dashboard-Bz-0-u1i.js +31 -0
  8. package/dist/rcs-web/assets/{Join-zelwrNDz.js → Join-CIaF_Ohx.js} +1 -1
  9. package/dist/rcs-web/assets/{Login-BmYeCfbw.js → Login-DNiG6cNe.js} +1 -1
  10. package/dist/rcs-web/assets/{Register-Dfw4S_A0.js → Register-CZ5iK6MO.js} +1 -1
  11. package/dist/rcs-web/assets/SessionDetail-HEE0RVF6.js +73 -0
  12. package/dist/rcs-web/assets/SessionVisibilityBadge-BY5tHU7b.js +16 -0
  13. package/dist/rcs-web/assets/{Setup-BTTET7Rk.js → Setup-CJerwA76.js} +1 -1
  14. package/dist/rcs-web/assets/{ShareLanding-DaLDc5iV.js → ShareLanding-CgkypqyR.js} +1 -1
  15. package/dist/rcs-web/assets/TeamDetail-ChdJxhFx.js +6 -0
  16. package/dist/rcs-web/assets/TeamList-lVbIAJts.js +1 -0
  17. package/dist/rcs-web/assets/TeamSettings-Bk3T7qB1.js +1 -0
  18. package/dist/rcs-web/assets/UserSearchInput-nQ2jQJmj.js +6 -0
  19. package/dist/rcs-web/assets/UserSettings-BZP7lYFA.js +1 -0
  20. package/dist/rcs-web/assets/{arc-CPhgreP8.js → arc-BLA5f37u.js} +1 -1
  21. package/dist/rcs-web/assets/{architectureDiagram-3BPJPVTR-CpAi-qzk.js → architectureDiagram-3BPJPVTR-GM4VEh2Q.js} +1 -1
  22. package/{packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-DcsxgO1K.js → dist/rcs-web/assets/blockDiagram-GPEHLZMM-C1u0Ojfk.js} +1 -1
  23. package/{packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-BQ5cjzbZ.js → dist/rcs-web/assets/c4Diagram-AAUBKEIU-1cul6feX.js} +1 -1
  24. package/dist/rcs-web/assets/channel-C0wRu8mS.js +1 -0
  25. package/dist/rcs-web/assets/{chunk-2J33WTMH-wa-oCiR6.js → chunk-2J33WTMH-CmySrkX6.js} +1 -1
  26. package/dist/rcs-web/assets/{chunk-4BX2VUAB-D2ybEyPG.js → chunk-4BX2VUAB-EzctfdX5.js} +1 -1
  27. package/dist/rcs-web/assets/{chunk-55IACEB6-CQGtwyGQ.js → chunk-55IACEB6-ClG1aobM.js} +1 -1
  28. package/{packages/remote-control-server/web/dist/assets/chunk-727SXJPM-D0ITaMeP.js → dist/rcs-web/assets/chunk-727SXJPM-D7CCqdxe.js} +1 -1
  29. package/{packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-BWRrcP1d.js → dist/rcs-web/assets/chunk-AQP2D5EJ-C12KuaNz.js} +1 -1
  30. package/dist/rcs-web/assets/{chunk-FMBD7UC4-C-CaLwfI.js → chunk-FMBD7UC4-WFInUvtG.js} +1 -1
  31. package/dist/rcs-web/assets/{chunk-ND2GUHAM-OPpmIsi8.js → chunk-ND2GUHAM-79eEElwS.js} +1 -1
  32. package/dist/rcs-web/assets/{chunk-QZHKN3VN-Bq6R2yM7.js → chunk-QZHKN3VN-B2q3R-jr.js} +1 -1
  33. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DdKmm0r6.js +1 -0
  34. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DdKmm0r6.js +1 -0
  35. package/{packages/remote-control-server/web/dist/assets/code-block-IT6T5CEO-BQf-xjVa.js → dist/rcs-web/assets/code-block-IT6T5CEO-BxkGH7r3.js} +1 -1
  36. package/dist/rcs-web/assets/{copy-lzYYFmlH.js → copy-CJUB1OCZ.js} +1 -1
  37. package/{packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-CuUSRgoZ.js → dist/rcs-web/assets/cose-bilkent-S5V4N54A-D77W33NX.js} +1 -1
  38. package/{packages/remote-control-server/web/dist/assets/dagre-BM42HDAG-BP4ZP_3D.js → dist/rcs-web/assets/dagre-BM42HDAG-DWSpM1Pp.js} +1 -1
  39. package/dist/rcs-web/assets/{diagram-2AECGRRQ-XQnH0b9k.js → diagram-2AECGRRQ-BmjFx9zx.js} +1 -1
  40. package/dist/rcs-web/assets/{diagram-5GNKFQAL-BnuYmMPD.js → diagram-5GNKFQAL-XJL0kjUS.js} +1 -1
  41. package/{packages/remote-control-server/web/dist/assets/diagram-KO2AKTUF-LymV4oAW.js → dist/rcs-web/assets/diagram-KO2AKTUF-BD-qltFe.js} +1 -1
  42. package/dist/rcs-web/assets/{diagram-LMA3HP47-NSg5NWFp.js → diagram-LMA3HP47-CC9yXUQZ.js} +1 -1
  43. package/{packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-kVTMFgtZ.js → dist/rcs-web/assets/diagram-OG6HWLK6-CM4_62w2.js} +1 -1
  44. package/dist/rcs-web/assets/dialog-BnhKhSaK.js +1 -0
  45. package/dist/rcs-web/assets/{erDiagram-TEJ5UH35-BJBTtX2s.js → erDiagram-TEJ5UH35-CLCbQ9SN.js} +1 -1
  46. package/dist/rcs-web/assets/{flowDiagram-I6XJVG4X-CcQXZNID.js → flowDiagram-I6XJVG4X-BRJxpd6c.js} +1 -1
  47. package/{packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-DW8iKyq_.js → dist/rcs-web/assets/ganttDiagram-6RSMTGT7-Q9D0n7zY.js} +1 -1
  48. package/{packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-BTBYx3LF.js → dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-DfDoy86d.js} +1 -1
  49. package/dist/rcs-web/assets/{infoDiagram-5YYISTIA-BRZAYc6t.js → infoDiagram-5YYISTIA-56dRcjZy.js} +1 -1
  50. package/{packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-BYMQtEeD.js → dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-BHdffIkI.js} +1 -1
  51. package/{packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-aqx7w1db.js → dist/rcs-web/assets/journeyDiagram-JHISSGLW-CsEp1AVc.js} +1 -1
  52. package/{packages/remote-control-server/web/dist/assets/kanban-definition-UN3LZRKU-BxEHfP4O.js → dist/rcs-web/assets/kanban-definition-UN3LZRKU-_RE82LM5.js} +1 -1
  53. package/dist/rcs-web/assets/{linear-Chjw8hPE.js → linear-DDo4ZKYf.js} +1 -1
  54. package/dist/rcs-web/assets/main-BKohkTQG.css +1 -0
  55. package/dist/rcs-web/assets/{main-Dh-rPGBg.js → main-bwawHmb2.js} +15 -15
  56. package/{packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-CrqI4db6.js → dist/rcs-web/assets/mermaid-VLURNSYL-BAWTa5p7.js} +4 -4
  57. package/dist/rcs-web/assets/{mermaid.core-EjsI3GC3.js → mermaid.core-Bk3OUzLn.js} +5 -5
  58. package/dist/rcs-web/assets/{mindmap-definition-RKZ34NQL-D2rO_fGA.js → mindmap-definition-RKZ34NQL-Dn3-IrmG.js} +1 -1
  59. package/dist/rcs-web/assets/{notifications-WMIbgYDP.js → notifications-BV1MotN8.js} +1 -1
  60. package/dist/rcs-web/assets/{pieDiagram-4H26LBE5-DDwJZfoh.js → pieDiagram-4H26LBE5-BevMVM81.js} +1 -1
  61. package/dist/rcs-web/assets/{quadrantDiagram-W4KKPZXB-DDtqMwKx.js → quadrantDiagram-W4KKPZXB-ChsIQYAl.js} +1 -1
  62. package/dist/rcs-web/assets/{refresh-cw-l0u8pxJi.js → refresh-cw-CKRHMYj-.js} +1 -1
  63. package/{packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-BtSk2-5u.js → dist/rcs-web/assets/requirementDiagram-4Y6WPE33-dsySOh5e.js} +1 -1
  64. package/dist/rcs-web/assets/{sankeyDiagram-5OEKKPKP-SDLDMxUT.js → sankeyDiagram-5OEKKPKP-DNR-vE3O.js} +1 -1
  65. package/dist/rcs-web/assets/{sequenceDiagram-3UESZ5HK-D7iAclg1.js → sequenceDiagram-3UESZ5HK-D3qAxHng.js} +1 -1
  66. package/dist/rcs-web/assets/{stateDiagram-AJRCARHV-Bxx23fZH.js → stateDiagram-AJRCARHV-BWhyLeMU.js} +1 -1
  67. package/dist/rcs-web/assets/{stateDiagram-v2-BHNVJYJU-z1g82auz.js → stateDiagram-v2-BHNVJYJU-Cr7eEfN-.js} +1 -1
  68. package/dist/rcs-web/assets/{timeline-definition-PNZ67QCA-C8kBbm_V.js → timeline-definition-PNZ67QCA-iel9USPs.js} +1 -1
  69. package/dist/rcs-web/assets/{vennDiagram-CIIHVFJN-CPldb1-R.js → vennDiagram-CIIHVFJN--VRUq03V.js} +1 -1
  70. package/{packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-MCHB2fG7.js → dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-Mbg_c9zq.js} +1 -1
  71. package/dist/rcs-web/assets/{xychartDiagram-2RQKCTM6-CHj-KmL6.js → xychartDiagram-2RQKCTM6-475G72ds.js} +1 -1
  72. package/dist/rcs-web/index.html +2 -2
  73. package/package.json +1 -1
  74. package/packages/remote-control-server/src/__tests__/client-ip.test.ts +67 -0
  75. package/packages/remote-control-server/src/__tests__/teams.test.ts +44 -0
  76. package/packages/remote-control-server/src/client-ip.ts +57 -0
  77. package/packages/remote-control-server/src/db/sqlite.ts +22 -0
  78. package/packages/remote-control-server/src/routes/v1/environments.ts +4 -0
  79. package/packages/remote-control-server/src/routes/web/teams.ts +12 -1
  80. package/packages/remote-control-server/src/services/environment.ts +12 -0
  81. package/packages/remote-control-server/src/store.ts +37 -8
  82. package/packages/remote-control-server/src/types/api.ts +7 -0
  83. package/packages/remote-control-server/web/dist/assets/AdminPanel-w39uutIr.js +1 -0
  84. package/packages/remote-control-server/web/dist/assets/ArtifactView-wUyXqsCU.js +1 -0
  85. package/packages/remote-control-server/web/dist/assets/{ArtifactsGallery-B63LTThv.js → ArtifactsGallery-DxVwQ8Wh.js} +15 -15
  86. package/packages/remote-control-server/web/dist/assets/Claim-D7HLQsN_.js +1 -0
  87. package/packages/remote-control-server/web/dist/assets/Dashboard-Bz-0-u1i.js +31 -0
  88. package/packages/remote-control-server/web/dist/assets/{Join-zelwrNDz.js → Join-CIaF_Ohx.js} +1 -1
  89. package/packages/remote-control-server/web/dist/assets/{Login-BmYeCfbw.js → Login-DNiG6cNe.js} +1 -1
  90. package/packages/remote-control-server/web/dist/assets/{Register-Dfw4S_A0.js → Register-CZ5iK6MO.js} +1 -1
  91. package/packages/remote-control-server/web/dist/assets/SessionDetail-HEE0RVF6.js +73 -0
  92. package/packages/remote-control-server/web/dist/assets/SessionVisibilityBadge-BY5tHU7b.js +16 -0
  93. package/packages/remote-control-server/web/dist/assets/{Setup-BTTET7Rk.js → Setup-CJerwA76.js} +1 -1
  94. package/packages/remote-control-server/web/dist/assets/{ShareLanding-DaLDc5iV.js → ShareLanding-CgkypqyR.js} +1 -1
  95. package/packages/remote-control-server/web/dist/assets/TeamDetail-ChdJxhFx.js +6 -0
  96. package/packages/remote-control-server/web/dist/assets/TeamList-lVbIAJts.js +1 -0
  97. package/packages/remote-control-server/web/dist/assets/TeamSettings-Bk3T7qB1.js +1 -0
  98. package/packages/remote-control-server/web/dist/assets/UserSearchInput-nQ2jQJmj.js +6 -0
  99. package/packages/remote-control-server/web/dist/assets/UserSettings-BZP7lYFA.js +1 -0
  100. package/packages/remote-control-server/web/dist/assets/{arc-CPhgreP8.js → arc-BLA5f37u.js} +1 -1
  101. package/packages/remote-control-server/web/dist/assets/{architectureDiagram-3BPJPVTR-CpAi-qzk.js → architectureDiagram-3BPJPVTR-GM4VEh2Q.js} +1 -1
  102. package/{dist/rcs-web/assets/blockDiagram-GPEHLZMM-DcsxgO1K.js → packages/remote-control-server/web/dist/assets/blockDiagram-GPEHLZMM-C1u0Ojfk.js} +1 -1
  103. package/{dist/rcs-web/assets/c4Diagram-AAUBKEIU-BQ5cjzbZ.js → packages/remote-control-server/web/dist/assets/c4Diagram-AAUBKEIU-1cul6feX.js} +1 -1
  104. package/packages/remote-control-server/web/dist/assets/channel-C0wRu8mS.js +1 -0
  105. package/packages/remote-control-server/web/dist/assets/{chunk-2J33WTMH-wa-oCiR6.js → chunk-2J33WTMH-CmySrkX6.js} +1 -1
  106. package/packages/remote-control-server/web/dist/assets/{chunk-4BX2VUAB-D2ybEyPG.js → chunk-4BX2VUAB-EzctfdX5.js} +1 -1
  107. package/packages/remote-control-server/web/dist/assets/{chunk-55IACEB6-CQGtwyGQ.js → chunk-55IACEB6-ClG1aobM.js} +1 -1
  108. package/{dist/rcs-web/assets/chunk-727SXJPM-D0ITaMeP.js → packages/remote-control-server/web/dist/assets/chunk-727SXJPM-D7CCqdxe.js} +1 -1
  109. package/{dist/rcs-web/assets/chunk-AQP2D5EJ-BWRrcP1d.js → packages/remote-control-server/web/dist/assets/chunk-AQP2D5EJ-C12KuaNz.js} +1 -1
  110. package/packages/remote-control-server/web/dist/assets/{chunk-FMBD7UC4-C-CaLwfI.js → chunk-FMBD7UC4-WFInUvtG.js} +1 -1
  111. package/packages/remote-control-server/web/dist/assets/{chunk-ND2GUHAM-OPpmIsi8.js → chunk-ND2GUHAM-79eEElwS.js} +1 -1
  112. package/packages/remote-control-server/web/dist/assets/{chunk-QZHKN3VN-Bq6R2yM7.js → chunk-QZHKN3VN-B2q3R-jr.js} +1 -1
  113. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DdKmm0r6.js +1 -0
  114. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DdKmm0r6.js +1 -0
  115. package/{dist/rcs-web/assets/code-block-IT6T5CEO-BQf-xjVa.js → packages/remote-control-server/web/dist/assets/code-block-IT6T5CEO-BxkGH7r3.js} +1 -1
  116. package/packages/remote-control-server/web/dist/assets/{copy-lzYYFmlH.js → copy-CJUB1OCZ.js} +1 -1
  117. package/{dist/rcs-web/assets/cose-bilkent-S5V4N54A-CuUSRgoZ.js → packages/remote-control-server/web/dist/assets/cose-bilkent-S5V4N54A-D77W33NX.js} +1 -1
  118. package/{dist/rcs-web/assets/dagre-BM42HDAG-BP4ZP_3D.js → packages/remote-control-server/web/dist/assets/dagre-BM42HDAG-DWSpM1Pp.js} +1 -1
  119. package/packages/remote-control-server/web/dist/assets/{diagram-2AECGRRQ-XQnH0b9k.js → diagram-2AECGRRQ-BmjFx9zx.js} +1 -1
  120. package/packages/remote-control-server/web/dist/assets/{diagram-5GNKFQAL-BnuYmMPD.js → diagram-5GNKFQAL-XJL0kjUS.js} +1 -1
  121. package/{dist/rcs-web/assets/diagram-KO2AKTUF-LymV4oAW.js → packages/remote-control-server/web/dist/assets/diagram-KO2AKTUF-BD-qltFe.js} +1 -1
  122. package/packages/remote-control-server/web/dist/assets/{diagram-LMA3HP47-NSg5NWFp.js → diagram-LMA3HP47-CC9yXUQZ.js} +1 -1
  123. package/{dist/rcs-web/assets/diagram-OG6HWLK6-kVTMFgtZ.js → packages/remote-control-server/web/dist/assets/diagram-OG6HWLK6-CM4_62w2.js} +1 -1
  124. package/packages/remote-control-server/web/dist/assets/dialog-BnhKhSaK.js +1 -0
  125. package/packages/remote-control-server/web/dist/assets/{erDiagram-TEJ5UH35-BJBTtX2s.js → erDiagram-TEJ5UH35-CLCbQ9SN.js} +1 -1
  126. package/packages/remote-control-server/web/dist/assets/{flowDiagram-I6XJVG4X-CcQXZNID.js → flowDiagram-I6XJVG4X-BRJxpd6c.js} +1 -1
  127. package/{dist/rcs-web/assets/ganttDiagram-6RSMTGT7-DW8iKyq_.js → packages/remote-control-server/web/dist/assets/ganttDiagram-6RSMTGT7-Q9D0n7zY.js} +1 -1
  128. package/{dist/rcs-web/assets/gitGraphDiagram-PVQCEYII-BTBYx3LF.js → packages/remote-control-server/web/dist/assets/gitGraphDiagram-PVQCEYII-DfDoy86d.js} +1 -1
  129. package/packages/remote-control-server/web/dist/assets/{infoDiagram-5YYISTIA-BRZAYc6t.js → infoDiagram-5YYISTIA-56dRcjZy.js} +1 -1
  130. package/{dist/rcs-web/assets/ishikawaDiagram-YF4QCWOH-BYMQtEeD.js → packages/remote-control-server/web/dist/assets/ishikawaDiagram-YF4QCWOH-BHdffIkI.js} +1 -1
  131. package/{dist/rcs-web/assets/journeyDiagram-JHISSGLW-aqx7w1db.js → packages/remote-control-server/web/dist/assets/journeyDiagram-JHISSGLW-CsEp1AVc.js} +1 -1
  132. package/{dist/rcs-web/assets/kanban-definition-UN3LZRKU-BxEHfP4O.js → packages/remote-control-server/web/dist/assets/kanban-definition-UN3LZRKU-_RE82LM5.js} +1 -1
  133. package/packages/remote-control-server/web/dist/assets/{linear-Chjw8hPE.js → linear-DDo4ZKYf.js} +1 -1
  134. package/packages/remote-control-server/web/dist/assets/main-BKohkTQG.css +1 -0
  135. package/packages/remote-control-server/web/dist/assets/{main-Dh-rPGBg.js → main-bwawHmb2.js} +15 -15
  136. package/{dist/rcs-web/assets/mermaid-VLURNSYL-CrqI4db6.js → packages/remote-control-server/web/dist/assets/mermaid-VLURNSYL-BAWTa5p7.js} +4 -4
  137. package/packages/remote-control-server/web/dist/assets/{mermaid.core-EjsI3GC3.js → mermaid.core-Bk3OUzLn.js} +5 -5
  138. package/packages/remote-control-server/web/dist/assets/{mindmap-definition-RKZ34NQL-D2rO_fGA.js → mindmap-definition-RKZ34NQL-Dn3-IrmG.js} +1 -1
  139. package/packages/remote-control-server/web/dist/assets/{notifications-WMIbgYDP.js → notifications-BV1MotN8.js} +1 -1
  140. package/packages/remote-control-server/web/dist/assets/{pieDiagram-4H26LBE5-DDwJZfoh.js → pieDiagram-4H26LBE5-BevMVM81.js} +1 -1
  141. package/packages/remote-control-server/web/dist/assets/{quadrantDiagram-W4KKPZXB-DDtqMwKx.js → quadrantDiagram-W4KKPZXB-ChsIQYAl.js} +1 -1
  142. package/packages/remote-control-server/web/dist/assets/{refresh-cw-l0u8pxJi.js → refresh-cw-CKRHMYj-.js} +1 -1
  143. package/{dist/rcs-web/assets/requirementDiagram-4Y6WPE33-BtSk2-5u.js → packages/remote-control-server/web/dist/assets/requirementDiagram-4Y6WPE33-dsySOh5e.js} +1 -1
  144. package/packages/remote-control-server/web/dist/assets/{sankeyDiagram-5OEKKPKP-SDLDMxUT.js → sankeyDiagram-5OEKKPKP-DNR-vE3O.js} +1 -1
  145. package/packages/remote-control-server/web/dist/assets/{sequenceDiagram-3UESZ5HK-D7iAclg1.js → sequenceDiagram-3UESZ5HK-D3qAxHng.js} +1 -1
  146. package/packages/remote-control-server/web/dist/assets/{stateDiagram-AJRCARHV-Bxx23fZH.js → stateDiagram-AJRCARHV-BWhyLeMU.js} +1 -1
  147. package/packages/remote-control-server/web/dist/assets/{stateDiagram-v2-BHNVJYJU-z1g82auz.js → stateDiagram-v2-BHNVJYJU-Cr7eEfN-.js} +1 -1
  148. package/packages/remote-control-server/web/dist/assets/{timeline-definition-PNZ67QCA-C8kBbm_V.js → timeline-definition-PNZ67QCA-iel9USPs.js} +1 -1
  149. package/packages/remote-control-server/web/dist/assets/{vennDiagram-CIIHVFJN-CPldb1-R.js → vennDiagram-CIIHVFJN--VRUq03V.js} +1 -1
  150. package/{dist/rcs-web/assets/wardleyDiagram-YWT4CUSO-MCHB2fG7.js → packages/remote-control-server/web/dist/assets/wardleyDiagram-YWT4CUSO-Mbg_c9zq.js} +1 -1
  151. package/packages/remote-control-server/web/dist/assets/{xychartDiagram-2RQKCTM6-CHj-KmL6.js → xychartDiagram-2RQKCTM6-475G72ds.js} +1 -1
  152. package/packages/remote-control-server/web/dist/index.html +2 -2
  153. package/dist/rcs-web/assets/AdminPanel-fsacwgfK.js +0 -1
  154. package/dist/rcs-web/assets/ArtifactView-DmMwrTRk.js +0 -1
  155. package/dist/rcs-web/assets/Claim-hOGNTz-n.js +0 -1
  156. package/dist/rcs-web/assets/Dashboard-BBIlAMpr.js +0 -6
  157. package/dist/rcs-web/assets/SessionDetail-zXHv84SV.js +0 -83
  158. package/dist/rcs-web/assets/SessionVisibilityBadge-DA_Sg1dx.js +0 -11
  159. package/dist/rcs-web/assets/TeamCreate-BWtaB-_Z.js +0 -1
  160. package/dist/rcs-web/assets/TeamDetail-Crmn6PaC.js +0 -6
  161. package/dist/rcs-web/assets/TeamList-B8Rob6VK.js +0 -1
  162. package/dist/rcs-web/assets/TeamSettings-CfRHolhe.js +0 -1
  163. package/dist/rcs-web/assets/UserSearchInput-DkaGgR76.js +0 -1
  164. package/dist/rcs-web/assets/UserSettings-D1oW7oVv.js +0 -1
  165. package/dist/rcs-web/assets/channel-DHj-rIRW.js +0 -1
  166. package/dist/rcs-web/assets/classDiagram-4FO5ZUOK-DsAw9J1B.js +0 -1
  167. package/dist/rcs-web/assets/classDiagram-v2-Q7XG4LA2-DsAw9J1B.js +0 -1
  168. package/dist/rcs-web/assets/dialog-DrDf89nL.js +0 -1
  169. package/dist/rcs-web/assets/main-CJvwpIVn.css +0 -1
  170. package/packages/remote-control-server/web/dist/assets/AdminPanel-fsacwgfK.js +0 -1
  171. package/packages/remote-control-server/web/dist/assets/ArtifactView-DmMwrTRk.js +0 -1
  172. package/packages/remote-control-server/web/dist/assets/Claim-hOGNTz-n.js +0 -1
  173. package/packages/remote-control-server/web/dist/assets/Dashboard-BBIlAMpr.js +0 -6
  174. package/packages/remote-control-server/web/dist/assets/SessionDetail-zXHv84SV.js +0 -83
  175. package/packages/remote-control-server/web/dist/assets/SessionVisibilityBadge-DA_Sg1dx.js +0 -11
  176. package/packages/remote-control-server/web/dist/assets/TeamCreate-BWtaB-_Z.js +0 -1
  177. package/packages/remote-control-server/web/dist/assets/TeamDetail-Crmn6PaC.js +0 -6
  178. package/packages/remote-control-server/web/dist/assets/TeamList-B8Rob6VK.js +0 -1
  179. package/packages/remote-control-server/web/dist/assets/TeamSettings-CfRHolhe.js +0 -1
  180. package/packages/remote-control-server/web/dist/assets/UserSearchInput-DkaGgR76.js +0 -1
  181. package/packages/remote-control-server/web/dist/assets/UserSettings-D1oW7oVv.js +0 -1
  182. package/packages/remote-control-server/web/dist/assets/channel-DHj-rIRW.js +0 -1
  183. package/packages/remote-control-server/web/dist/assets/classDiagram-4FO5ZUOK-DsAw9J1B.js +0 -1
  184. package/packages/remote-control-server/web/dist/assets/classDiagram-v2-Q7XG4LA2-DsAw9J1B.js +0 -1
  185. package/packages/remote-control-server/web/dist/assets/dialog-DrDf89nL.js +0 -1
  186. package/packages/remote-control-server/web/dist/assets/main-CJvwpIVn.css +0 -1
@@ -0,0 +1,31 @@
1
+ import{j as e,e as r}from"./vendor-DE_-CLIE.js";import{ap as D,h as X,g as Z,an as _,aE as t,aN as R,aL as O,U as J,at as W,aM as $,I as Y,e as B,d as P,aw as ee,$ as se,ah as ae,a3 as te,a6 as ne,a2 as re,S as q,X as le,aF as ce}from"./main-bwawHmb2.js";import{A as de,S as ie}from"./SessionVisibilityBadge-BY5tHU7b.js";import{g as A}from"./workerType-BOi1t0TG.js";import{D as oe,a as me,d as he}from"./dialog-BnhKhSaK.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 xe=[["rect",{width:"20",height:"5",x:"2",y:"3",rx:"1",key:"1wp1u1"}],["path",{d:"M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",key:"1s80jp"}],["path",{d:"M10 12h4",key:"a56b0p"}]],z=D("archive",xe);/**
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 ue=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"12",x2:"12",y1:"8",y2:"12",key:"1pkeuh"}],["line",{x1:"12",x2:"12.01",y1:"16",y2:"16",key:"4dfq90"}]],pe=D("circle-alert",ue);/**
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 fe=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],je=D("folder",fe);/**
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 ge=[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],be=D("triangle-alert",ge);/**
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 Ne=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}],["path",{d:"M5 12.859a10 10 0 0 1 5.17-2.69",key:"1dl1wf"}],["path",{d:"M19 12.859a10 10 0 0 0-2.007-1.523",key:"4k23kn"}],["path",{d:"M2 8.82a15 15 0 0 1 4.177-2.643",key:"1grhjp"}],["path",{d:"M22 8.82a15 15 0 0 0-11.288-3.764",key:"z3jwby"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],U=D("wifi-off",Ne);/**
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 ye=[["path",{d:"M12 20h.01",key:"zekei9"}],["path",{d:"M2 8.82a15 15 0 0 1 20 0",key:"dnpr2z"}],["path",{d:"M5 12.859a10 10 0 0 1 14 0",key:"1x1e6c"}],["path",{d:"M8.5 16.429a5 5 0 0 1 7 0",key:"1bycff"}]],we=D("wifi",ye),ve={running:{label:"running",Icon:de},active:{label:"active",Icon:we},idle:{label:"idle",Icon:X},disconnected:{label:"disconnected",Icon:U},offline:{label:"offline",Icon:U},inactive:{label:"inactive",Icon:z},archived:{label:"archived",Icon:z},error:{label:"error",Icon:pe,tone:"text-status-error border-status-error/40"},requires_action:{label:"requires_action",Icon:be,tone:"text-status-warning border-status-warning/40"}};function ke({status:c,className:i}){const{label:f,Icon:u,tone:m}=ve[c]??{label:c,Icon:Z,tone:void 0};return e.jsxs("span",{className:_("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",m??"text-text-muted border-border/60",i),title:f,children:[e.jsx(u,{className:"h-3 w-3","aria-hidden":"true"}),f]})}function _e({teamName:c,className:i}){return c?e.jsx("span",{className:_("inline-flex items-center rounded-full border border-border/60 bg-surface-2 px-2 py-0.5 text-xs text-text-muted",i),children:c}):null}function V({title:c,hint:i}){return e.jsx("div",{className:"ds-reg",children:e.jsxs("div",{className:"ds-reg-row ds-reg-empty",children:[e.jsxs("span",{className:"ds-reg-main",children:[e.jsx("span",{className:"ds-empty-title",children:c}),e.jsx("span",{className:"ds-reg-meta ds-empty-hint",children:i})]}),e.jsx("span",{className:"ds-reg-aside",children:e.jsx("span",{className:"ds-empty-marker",children:t("dashboard.emptyMarker")})})]})})}function Se({environments:c,onSelectEnvironment:i}){const{activeTeam:f}=R(),{user:u}=O(),m=r.useMemo(()=>(u==null?void 0:u.role)==="admin"?c:f?c.filter(l=>l.team_id===f.id):c.filter(l=>!l.team_id),[c,f,u]);return!m||m.length===0?e.jsx(V,{title:t("dashboard.emptyEnvironmentsTitle"),hint:t("dashboard.emptyEnvironmentsHint")}):e.jsx("div",{className:"ds-reg",children:m.map(l=>{var N,y,b;const p=l.worker_type==="acp",S=A(l.worker_type),o=((N=l.directory)==null?void 0:N.trim())||null,j=((y=l.ip_address)==null?void 0:y.trim())||null,g=((b=l.owner_username)==null?void 0:b.trim())||null;return e.jsxs("div",{className:_("ds-reg-row group",p&&"opacity-80"),children:[e.jsxs("button",{type:"button",onClick:()=>i==null?void 0:i(l),disabled:p,className:_("ds-reg-main",p?"cursor-default":"cursor-pointer"),children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[15px] font-medium text-text-primary",children:l.machine_name||l.id}),e.jsx("span",{className:_("ds-reg-tag rounded-full",S.colorClass),children:S.fullLabel}),e.jsx(ke,{status:l.status,className:"ds-reg-tag"}),e.jsx(_e,{teamName:l.team_name??null,className:"ds-reg-tag"})]}),(o||j||g)&&e.jsxs("span",{className:"ds-reg-meta flex min-w-0 items-center gap-1.5 text-xs text-text-muted",children:[o&&e.jsx("span",{className:"min-w-0 truncate font-mono",children:o}),o&&j&&e.jsx("span",{className:"ds-reg-fact-sep","aria-hidden":"true",children:"·"}),j&&e.jsx("span",{className:"shrink-0 whitespace-nowrap font-mono tabular-nums",children:j}),(o||j)&&g&&e.jsx("span",{className:"ds-reg-fact-sep","aria-hidden":"true",children:"·"}),g&&e.jsxs("span",{className:"ds-reg-owner",title:`${t("dashboard.envOwner")}: ${g}`,children:[e.jsx(J,{className:"h-3 w-3","aria-hidden":"true"}),e.jsx("span",{className:"min-w-0 truncate",children:g})]})]})]}),e.jsx("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:W(l.created_at)})})]},l.id)})})}function Ce({sessions:c,environments:i,onSelect:f,onDelete:u}){$();const{activeTeam:m,myTeams:l}=R(),{user:p}=O(),S=r.useMemo(()=>{const s=new Map;for(const d of l)s.set(d.id,d.name);return s},[l]),o=r.useMemo(()=>(p==null?void 0:p.role)==="admin"?c:m?c.filter(s=>s.owner_type==="team"&&s.owner_id===m.id):c.filter(s=>s.owner_type==="user"||s.access_level==="write"||s.access_level==="read"),[c,m,p]),{mySessions:j,sharedSessions:g}=r.useMemo(()=>{const s=[],d=[];for(const h of o)m?s.push(h):h.access_level==="write"||h.access_level==="read"?d.push(h):s.push(h);return{mySessions:s,sharedSessions:d}},[o,m]),N=new Map;for(const s of i??[])s!=null&&s.id&&s.worker_type&&N.set(s.id,s.worker_type);const y=(s,d)=>(d.updated_at||0)-(s.updated_at||0);function b(s){var v;const d=!!u&&s.access_level!=="write"&&s.access_level!=="read";let h=s.source==="acp"?"acp":(v=s.environment)==null?void 0:v.worker_type;!h&&s.environment_id&&(h=N.get(s.environment_id));const x=A(h);return e.jsxs("div",{className:"ds-reg-row group",children:[e.jsxs("button",{type:"button",onClick:()=>f(s.id),className:"ds-reg-main cursor-pointer",children:[e.jsxs("span",{className:"flex items-center gap-2",children:[e.jsx("span",{className:"min-w-0 truncate text-[15px] font-medium text-text-primary",children:s.title||s.id}),s.visibility&&e.jsx(ie,{visibility:s.visibility||"private",className:"ds-reg-tag"}),e.jsx("span",{className:_("ds-reg-tag rounded-full",x.colorClass),children:x.fullLabel})]}),e.jsxs("span",{className:"ds-reg-meta flex items-center gap-2 truncate text-xs text-text-muted",children:[e.jsx("span",{className:"truncate font-mono",children:s.id}),s.owner_type==="team"&&s.owner_id&&e.jsxs("span",{className:"inline-flex items-center gap-2 truncate",children:[e.jsx("span",{className:"text-text-muted/40",children:"|"}),e.jsx("span",{className:"truncate",children:S.get(s.owner_id)||s.owner_id})]})]})]}),e.jsxs("div",{className:"ds-reg-aside",children:[e.jsx(Y,{status:s.status}),e.jsx("span",{className:"whitespace-nowrap font-mono text-xs tabular-nums text-text-muted",children:W(s.created_at||s.updated_at)}),d&&e.jsx("button",{type:"button",onClick:I=>{I.stopPropagation(),u(s.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:"Delete session",children:e.jsx("svg",{className:"h-4 w-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]})]},s.id)}if(o.length===0)return e.jsx(V,{title:t("dashboard.emptySessionsTitle"),hint:t("dashboard.emptySessionsHint")});const w=[...j].sort(y),C=[...g].sort(y);return e.jsxs("div",{className:"space-y-4",children:[w.length>0&&e.jsx("section",{className:"space-y-2",children:e.jsx("div",{className:"ds-reg",children:w.map(b)})}),C.length>0&&e.jsxs("section",{className:"space-y-2",children:[w.length>0&&e.jsx("h3",{className:"text-xs font-medium uppercase tracking-wide text-text-muted",children:t("session.sharedWithMe")}),e.jsx("div",{className:"ds-reg",children:C.map(b)})]})]})}function Me({open:c,environments:i,onClose:f,onCreated:u}){$();const{activeTeam:m}=R(),{user:l}=O(),[p,S]=r.useState(""),[o,j]=r.useState(""),[g,N]=r.useState("same-dir"),[y,b]=r.useState(""),[w,C]=r.useState(!1),[s,d]=r.useState(!1),h=r.useMemo(()=>(l==null?void 0:l.role)==="admin"?i:m?i.filter(a=>a.team_id===m.id):i.filter(a=>!a.team_id),[i,m,l]);r.useEffect(()=>{c&&(S(""),j(""),N("same-dir"),b(""),d(!1))},[c]);const x=h.find(a=>a.id===o)||null,v=x?h.findIndex(a=>a.id===x.id)+1:null,I=async()=>{C(!0),b("");try{const a={};p.trim()&&(a.title=p.trim()),o&&(a.environment_id=o),a.spawn_mode=g;const E=ee();E&&(a.team_id=E);const T=await se(a);u(T)}catch(a){b(a instanceof Error?a.message:t("dialog.createFailed"))}finally{C(!1)}};return e.jsx(oe,{open:c,onOpenChange:a=>{a||f()},children:e.jsx(me,{className:"nsd-shell max-w-md",children:e.jsxs("div",{className:"nsd-box",children:[e.jsx(he,{className:"nsd-h",children:t("dialog.newSession")}),e.jsxs("div",{className:"nsd-field nsd-field--env",children:[e.jsx("span",{className:"nsd-lab",children:t("dialog.environment")}),e.jsxs("button",{type:"button",className:"nsd-envtrigger","aria-expanded":s,onClick:()=>d(a=>!a),children:[e.jsx("span",{className:"nsd-env-read",children:x?e.jsxs(e.Fragment,{children:[v!==null&&e.jsxs("span",{className:"nsd-env-idx",children:["#",v]}),e.jsx("span",{className:"nsd-env-name",children:x.machine_name||x.id}),e.jsx("span",{className:_("nsd-env-type",A(x.worker_type).colorClass),children:A(x.worker_type).shortLabel})]}):e.jsx("span",{className:"nsd-env-none",children:t("dialog.envSelectEnv")})}),e.jsx(B,{className:"nsd-env-caret"})]}),(x==null?void 0:x.directory)&&e.jsx("span",{className:"nsd-env-path",children:x.directory}),s&&e.jsxs("div",{className:"nsd-envpanel",children:[e.jsx("button",{type:"button",onClick:()=>{j(""),d(!1)},className:"nsd-envrow",children:e.jsxs("span",{className:"nsd-envrow-head",children:[e.jsx("span",{className:"nsd-envrow-name",children:t("dialog.none")}),!o&&e.jsx(P,{className:"ml-auto h-3.5 w-3.5 shrink-0 text-brand-text"})]})}),h.length===0?e.jsx("p",{className:"nsd-envempty",children:t("dialog.envEmpty")}):h.map((a,E)=>{const T=A(a.worker_type),M=!!a.team_id,L=a.id===o;return e.jsxs("button",{type:"button","data-selected":L?"on":void 0,onClick:()=>{j(a.id),d(!1)},className:"nsd-envrow",children:[e.jsxs("span",{className:"nsd-envrow-head",children:[e.jsxs("span",{className:"nsd-envrow-idx",children:["#",E+1]}),e.jsx("span",{className:"nsd-envrow-name",children:a.machine_name||a.id}),e.jsx("span",{className:_("nsd-envrow-type",T.colorClass),children:T.shortLabel}),e.jsx("span",{className:_("nsd-envrow-team",M?"border-border/60 bg-surface-2 text-text-muted":"border-brand/30 bg-brand/10 text-brand-text"),children:M?`${t("dialog.envTeam")}: ${a.team_name||a.team_id}`:t("dialog.envPersonal")}),L&&e.jsx(P,{className:"ml-auto h-3.5 w-3.5 shrink-0 text-brand-text"})]}),a.directory&&e.jsxs("span",{className:"nsd-envrow-dir",children:[e.jsx(je,{className:"h-3 w-3 shrink-0"}),e.jsx("span",{className:"nsd-envrow-path",children:a.directory}),a.branch&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-text-muted/40",children:"·"}),e.jsx("span",{className:"nsd-envrow-path",children:a.branch})]})]})]},a.id)})]})]}),e.jsxs("label",{className:"nsd-field",children:[e.jsx("span",{className:"nsd-lab",children:t("dialog.titleOptional")}),e.jsx("input",{type:"text",value:p,onChange:a=>S(a.target.value),placeholder:t("dialog.titlePlaceholder"),className:"nsd-title"})]}),e.jsxs("label",{className:"nsd-field",children:[e.jsx("span",{className:"nsd-lab",children:t("dialog.workspaceMode")}),e.jsxs("span",{className:"nsd-modesel",children:[e.jsxs("select",{value:g,onChange:a=>N(a.target.value),className:"nsd-mode",children:[e.jsx("option",{value:"same-dir",children:t("dialog.sameDir")}),e.jsx("option",{value:"worktree",children:t("dialog.worktree")})]}),e.jsx(B,{className:"nsd-mode-caret"})]})]}),y&&e.jsx("p",{className:"nsd-error",children:y}),e.jsxs("div",{className:"nsd-foot",children:[e.jsx("button",{type:"button",onClick:f,className:"nsd-cancel",children:t("common.cancel")}),e.jsx("button",{type:"button",onClick:I,disabled:w,className:"btn-ticket nsd-create",children:w?t("common.creating"):t("common.create")})]})]})})})}function Re({onNavigateSession:c}){const i=$(),f=r.useMemo(()=>new Date().toLocaleDateString(i==="zh"?"zh-CN":"en-US",{year:"numeric",month:"long",day:"numeric",weekday:"short"}),[i]),[u,m]=r.useState([]),[l,p]=r.useState([]),[S,o]=r.useState(!1),[j,g]=r.useState(!1),[N,y]=r.useState(""),[b,w]=r.useState(null),[C,s]=r.useState(!1),d=r.useRef(0),[h,x]=r.useState(!1),v=j||h,I=r.useCallback(()=>{g(!1),y(""),x(!0)},[]),a=r.useCallback(()=>{x(!1)},[]),E=r.useRef(null),T=r.useRef(!1);r.useEffect(()=>{var n;T.current&&!v&&((n=E.current)==null||n.focus()),T.current=v},[v]),r.useEffect(()=>{const n=N.trim();if(!n){d.current+=1,w(null),s(!1);return}s(!0);const k=++d.current,F=setTimeout(()=>{ae(n).then(K=>{d.current===k&&w(K.results??[])}).catch(()=>{d.current===k&&w([])}).finally(()=>{d.current===k&&s(!1)})},300);return()=>clearTimeout(F)},[N]);const M=r.useCallback(async()=>{try{const[n,k]=await Promise.all([te(),ne()]);m(n||[]),p(k||[])}catch(n){console.error("Dashboard render error:",n)}},[]);r.useEffect(()=>{M();const n=setInterval(M,5e3);return window.addEventListener("focus",M),()=>{clearInterval(n),window.removeEventListener("focus",M)}},[M]);const L=n=>{o(!1),c(n.id)},H=r.useCallback(n=>{},[]),Q=r.useCallback(n=>{c(n)},[c]),G=r.useCallback(async n=>{if(window.confirm(t("dashboard.confirmDelete").replace("{id}",n)))try{await re(n),m(k=>k.filter(F=>F.id!==n))}catch(k){alert(k instanceof Error?k.message:t("dashboard.deleteFailed"))}},[]);return e.jsxs("div",{className:"ds-dash",children:[e.jsxs("header",{className:"ds-dash-bar hero-enter",children:[e.jsx("span",{className:"ds-dash-dateline",children:f}),e.jsxs("div",{className:"ds-dash-titlerow",children:[e.jsx("h1",{className:"ds-dash-title font-display font-semibold tracking-tight text-text-primary",children:t("dashboard.title")}),e.jsxs("div",{className:"ds-dash-counts",children:[e.jsxs("span",{children:[u.length," ",t("dashboard.sessions")]}),e.jsxs("span",{children:[l.length," ",t("dashboard.environments")]})]})]})]}),e.jsxs("section",{className:"ds-dash-row",children:[e.jsx("h2",{className:"font-display text-lg font-semibold text-text-primary",children:t("dashboard.environments")}),e.jsx(Se,{environments:l,onSelectEnvironment:H})]}),e.jsxs("section",{className:"ds-dash-row",children:[e.jsxs("div",{className:"ds-dash-rowhead",children:[e.jsxs("div",{className:"ds-dash-rowlabel",children:[e.jsx("h2",{className:"font-display text-lg font-semibold text-text-primary",children:t("dashboard.sessions")}),v?e.jsxs("div",{className:_("ds-dash-search",h&&"ds-dash-search--folding"),onAnimationEnd:a,children:[e.jsx(q,{className:"h-4 w-4 flex-shrink-0 text-text-muted","aria-hidden":"true"}),e.jsx("input",{autoFocus:!0,value:N,onChange:n=>y(n.target.value),onKeyDown:n=>{n.key==="Escape"&&I()},placeholder:t("dashboard.searchPlaceholder"),"aria-label":t("dashboard.searchPlaceholder"),className:"w-full min-w-0 bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"}),C&&e.jsx("span",{className:"flex-shrink-0 text-xs text-text-muted",children:t("dashboard.searching")}),e.jsx("button",{type:"button",onClick:I,className:"ds-dash-search-close",title:t("dashboard.closeSearch"),"aria-label":t("dashboard.closeSearch"),children:e.jsx(le,{className:"h-3.5 w-3.5"})})]}):e.jsx("button",{ref:E,type:"button",onClick:()=>g(!0),className:"ds-dash-search-toggle",title:t("dashboard.searchAction"),"aria-label":t("dashboard.searchAction"),children:e.jsx(q,{className:"h-4 w-4"})})]}),e.jsx("button",{type:"button",onClick:()=>o(!0),className:"btn-ticket",children:t("dashboard.newSession")})]}),b!==null?e.jsxs("div",{className:"ds-reg",children:[b.length===0&&!C&&e.jsx("p",{className:"ds-reg-row ds-reg-empty text-sm text-text-muted",children:t("dashboard.searchNoResults")}),b.map(n=>e.jsxs("button",{type:"button",onClick:()=>c(n.session_id),className:"ds-reg-row w-full cursor-pointer",children:[e.jsxs("span",{className:"min-w-0",children:[e.jsx("span",{className:"block truncate text-[15px] font-medium text-text-primary",children:n.title||n.session_id}),n.snippet&&e.jsx("span",{className:"mt-1 line-clamp-2 block text-xs leading-relaxed text-text-muted",children:n.snippet})]}),e.jsx("span",{className:"whitespace-nowrap font-mono text-xs text-text-muted",children:n.match_count>0?ce("dashboard.nMatches",{n:n.match_count}):t("dashboard.nameMatch")})]},n.session_id))]}):e.jsx(Ce,{sessions:u,environments:l,onSelect:Q,onDelete:G})]}),e.jsx(Me,{open:S,environments:l,onClose:()=>o(!1),onCreated:L})]})}export{Re as Dashboard};
@@ -1 +1 @@
1
- import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aH as v,E as N,aA as t}from"./main-Dh-rPGBg.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function P({onSuccess:h,onInvalidInvite:i}){const{join:b}=v(),[l,f]=r.useState(""),[u,w]=r.useState(""),[o,j]=r.useState(""),[c,g]=r.useState(""),[m,n]=r.useState(""),[x,p]=r.useState(!1);r.useEffect(()=>{const a=new URLSearchParams(window.location.search).get("invite");a?f(a):i()},[i]);const y=async s=>{if(s.preventDefault(),n(""),o.length<8){n(t("auth.setup.passwordTooShort"));return}if(o!==c){n(t("auth.setup.passwordMismatch"));return}p(!0);try{await b(l,u,o),h()}catch(a){const d=a instanceof Error?a.message:"Join failed";if(d.includes("Invalid invitation")||d.includes("expired")||d.includes("already used")){i();return}n(d)}finally{p(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"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 text-brand"}),e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight text-text-primary",children:t("auth.join.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.join.welcome")}),e.jsx("p",{className:"mt-1 text-sm text-text-muted",children:t("auth.join.description")})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.username")}),e.jsx("input",{type:"text",value:u,onChange:s=>w(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.password")}),e.jsx("input",{type:"password",value:o,onChange:s=>j(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.confirmPassword")}),e.jsx("input",{type:"password",value:c,onChange:s=>g(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),m&&e.jsx("p",{className:"text-sm text-status-error",children:m}),e.jsx("button",{type:"submit",disabled:x||!l,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:x?t("common.loading"):t("auth.join.submit")})]})]})})}export{P as Join};
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aL as v,G as N,aE as t}from"./main-bwawHmb2.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function P({onSuccess:h,onInvalidInvite:i}){const{join:b}=v(),[l,f]=r.useState(""),[u,w]=r.useState(""),[o,j]=r.useState(""),[c,g]=r.useState(""),[m,n]=r.useState(""),[x,p]=r.useState(!1);r.useEffect(()=>{const a=new URLSearchParams(window.location.search).get("invite");a?f(a):i()},[i]);const y=async s=>{if(s.preventDefault(),n(""),o.length<8){n(t("auth.setup.passwordTooShort"));return}if(o!==c){n(t("auth.setup.passwordMismatch"));return}p(!0);try{await b(l,u,o),h()}catch(a){const d=a instanceof Error?a.message:"Join failed";if(d.includes("Invalid invitation")||d.includes("expired")||d.includes("already used")){i();return}n(d)}finally{p(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"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 text-brand"}),e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight text-text-primary",children:t("auth.join.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.join.welcome")}),e.jsx("p",{className:"mt-1 text-sm text-text-muted",children:t("auth.join.description")})]}),e.jsxs("form",{onSubmit:y,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.username")}),e.jsx("input",{type:"text",value:u,onChange:s=>w(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.password")}),e.jsx("input",{type:"password",value:o,onChange:s=>j(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.confirmPassword")}),e.jsx("input",{type:"password",value:c,onChange:s=>g(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),m&&e.jsx("p",{className:"text-sm text-status-error",children:m}),e.jsx("button",{type:"submit",disabled:x||!l,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:x?t("common.loading"):t("auth.join.submit")})]})]})})}export{P as Join};
@@ -1 +1 @@
1
- import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{aA as t,aB as y,aH as j,E as w}from"./main-Dh-rPGBg.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function v(s){if(!(s instanceof Error))return t("auth.login.failed");if(s instanceof TypeError)return t("auth.login.unreachable");const r=s.message;return/failed to fetch|network|load failed/i.test(r)?t("auth.login.unreachable"):/csrf/i.test(r)?t("auth.login.csrfBlocked"):/too many/i.test(r)?t("auth.login.rateLimited"):/invalid credentials/i.test(r)?t("auth.login.failed"):!r||/^login failed$/i.test(r)?t("auth.login.failed"):y("auth.login.failedWithReason",{message:r})}function C({onSuccess:s,onNavigateRegister:r}){const{login:m,registrationAllowed:x,singleUserMode:h}=j(),[o,f]=n.useState(""),[i,b]=n.useState(""),[l,d]=n.useState(""),[u,c]=n.useState(!1),p=async a=>{a.preventDefault(),d(""),c(!0);try{await m(o,i),s()}catch(g){d(v(g))}finally{c(!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(w,{className:"mx-auto mb-5 h-10 w-10 text-brand"}),e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight text-text-primary",children:t("auth.login.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.login.description")})]}),e.jsxs("form",{onSubmit:p,className:"space-y-4",children:[h&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2 text-xs text-text-secondary",children:[e.jsx("p",{children:t("auth.login.singleUserHint")}),e.jsx("p",{className:"mt-1 font-mono text-text-primary",children:"admin / admin123"}),e.jsx("p",{className:"mt-1 text-text-muted",children:t("auth.login.singleUserHintFooter")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.username")}),e.jsx("input",{type:"text",value:o,onChange:a=>f(a.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.password")}),e.jsx("input",{type:"password",value:i,onChange:a=>b(a.target.value),required:!0,autoComplete:"current-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),l&&e.jsx("p",{className:"text-sm text-status-error",children:l}),e.jsx("button",{type:"submit",disabled:u,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:u?t("common.loading"):t("auth.login.submit")})]}),x&&e.jsx("button",{type:"button",onClick:r,className:"w-full text-center text-sm text-text-muted hover:text-text-primary transition-colors",children:t("auth.login.register")})]})})}export{C as Login};
1
+ import{e as n,j as e}from"./vendor-DE_-CLIE.js";import{aE as t,aF as y,aL as j,G as w}from"./main-bwawHmb2.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function v(s){if(!(s instanceof Error))return t("auth.login.failed");if(s instanceof TypeError)return t("auth.login.unreachable");const r=s.message;return/failed to fetch|network|load failed/i.test(r)?t("auth.login.unreachable"):/csrf/i.test(r)?t("auth.login.csrfBlocked"):/too many/i.test(r)?t("auth.login.rateLimited"):/invalid credentials/i.test(r)?t("auth.login.failed"):!r||/^login failed$/i.test(r)?t("auth.login.failed"):y("auth.login.failedWithReason",{message:r})}function C({onSuccess:s,onNavigateRegister:r}){const{login:m,registrationAllowed:x,singleUserMode:h}=j(),[o,f]=n.useState(""),[i,b]=n.useState(""),[l,d]=n.useState(""),[u,c]=n.useState(!1),p=async a=>{a.preventDefault(),d(""),c(!0);try{await m(o,i),s()}catch(g){d(v(g))}finally{c(!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(w,{className:"mx-auto mb-5 h-10 w-10 text-brand"}),e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight text-text-primary",children:t("auth.login.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.login.description")})]}),e.jsxs("form",{onSubmit:p,className:"space-y-4",children:[h&&e.jsxs("div",{className:"rounded-lg border border-border bg-surface-2 px-3 py-2 text-xs text-text-secondary",children:[e.jsx("p",{children:t("auth.login.singleUserHint")}),e.jsx("p",{className:"mt-1 font-mono text-text-primary",children:"admin / admin123"}),e.jsx("p",{className:"mt-1 text-text-muted",children:t("auth.login.singleUserHintFooter")})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.username")}),e.jsx("input",{type:"text",value:o,onChange:a=>f(a.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.password")}),e.jsx("input",{type:"password",value:i,onChange:a=>b(a.target.value),required:!0,autoComplete:"current-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),l&&e.jsx("p",{className:"text-sm text-status-error",children:l}),e.jsx("button",{type:"submit",disabled:u,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:u?t("common.loading"):t("auth.login.submit")})]}),x&&e.jsx("button",{type:"button",onClick:r,className:"w-full text-center text-sm text-text-muted hover:text-text-primary transition-colors",children:t("auth.login.register")})]})})}export{C as Login};
@@ -1 +1 @@
1
- import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aH as w,E as y,aA as t}from"./main-Dh-rPGBg.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function k({onSuccess:c,onBack:x}){const{register:p}=w(),[n,h]=r.useState(""),[a,b]=r.useState(""),[l,f]=r.useState(""),[d,o]=r.useState(""),[i,u]=r.useState(!1),g=async s=>{if(s.preventDefault(),o(""),a.length<8){o(t("auth.setup.passwordTooShort"));return}if(a!==l){o(t("auth.setup.passwordMismatch"));return}u(!0);try{await p(n,a),c()}catch(m){o(m instanceof Error?m.message:t("auth.register.failed"))}finally{u(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"hero-enter w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(y,{className:"mx-auto mb-5 h-10 w-10 text-brand"}),e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight text-text-primary",children:t("auth.register.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.register.description")})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.username")}),e.jsx("input",{type:"text",value:n,onChange:s=>h(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.password")}),e.jsx("input",{type:"password",value:a,onChange:s=>b(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.confirmPassword")}),e.jsx("input",{type:"password",value:l,onChange:s=>f(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),d&&e.jsx("p",{className:"text-sm text-status-error",children:d}),e.jsx("button",{type:"submit",disabled:i,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:i?t("common.loading"):t("auth.register.submit")})]}),e.jsx("button",{type:"button",onClick:x,className:"w-full text-center text-sm text-text-muted hover:text-text-primary transition-colors",children:t("auth.register.backToLogin")})]})})}export{k as Register};
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aL as w,G as y,aE as t}from"./main-bwawHmb2.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function k({onSuccess:c,onBack:x}){const{register:p}=w(),[n,h]=r.useState(""),[a,b]=r.useState(""),[l,f]=r.useState(""),[d,o]=r.useState(""),[i,u]=r.useState(!1),g=async s=>{if(s.preventDefault(),o(""),a.length<8){o(t("auth.setup.passwordTooShort"));return}if(a!==l){o(t("auth.setup.passwordMismatch"));return}u(!0);try{await p(n,a),c()}catch(m){o(m instanceof Error?m.message:t("auth.register.failed"))}finally{u(!1)}};return e.jsx("div",{className:"flex min-h-screen items-center justify-center bg-surface-0 px-4",children:e.jsxs("div",{className:"hero-enter w-full max-w-sm space-y-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx(y,{className:"mx-auto mb-5 h-10 w-10 text-brand"}),e.jsx("h1",{className:"font-display text-3xl font-semibold tracking-tight text-text-primary",children:t("auth.register.title")}),e.jsx("p",{className:"mt-2 text-sm text-text-muted",children:t("auth.register.description")})]}),e.jsxs("form",{onSubmit:g,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.username")}),e.jsx("input",{type:"text",value:n,onChange:s=>h(s.target.value),required:!0,autoComplete:"username",autoFocus:!0,className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.login.password")}),e.jsx("input",{type:"password",value:a,onChange:s=>b(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm font-medium text-text-secondary",children:t("auth.join.confirmPassword")}),e.jsx("input",{type:"password",value:l,onChange:s=>f(s.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded-lg border border-border bg-surface-2 px-3 py-2 text-sm text-text-primary placeholder:text-text-muted focus:border-brand focus:outline-none"})]}),d&&e.jsx("p",{className:"text-sm text-status-error",children:d}),e.jsx("button",{type:"submit",disabled:i,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:i?t("common.loading"):t("auth.register.submit")})]}),e.jsx("button",{type:"button",onClick:x,className:"w-full text-center text-sm text-text-muted hover:text-text-primary transition-colors",children:t("auth.register.backToLogin")})]})})}export{k as Register};
@@ -0,0 +1,73 @@
1
+ var Fs=Object.defineProperty;var Ks=(n,t,s)=>t in n?Fs(n,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):n[t]=s;var M=(n,t,s)=>Ks(n,typeof t!="symbol"?t+"":t,s);import{j as e,e as l}from"./vendor-DE_-CLIE.js";import{ap as Q,a8 as Ls,ay as Tt,ax as Mt,aE as c,aA as Bs,az as Oe,aF as O,au as oe,aj as Hs,ai as z,ab as Ws,ag as Qs,aJ as Vs,aM as J,T as zs,Q as Gs,I as Ys,h as Rt,at as ts,L as _e,N as Js,aq as Ue,d as Se,S as it,M as Xs,x as Zs,X as en,H as tn,ar as W,an as ee,as as sn,aG as nn,E as rn,D as an,aH as At,ac as on,a0 as ln,af as cn,A as dn,av as un,aB as mn,aC as xn,Z as $t,$ as fn,aI as pn,b as hn,a2 as It,ad as gn,K as ss,F as yn,c as bn,C as jn,a7 as Dt,k as wn,a as vn,t as Fe,v as Ke,z as kn,f as Le,e as Be,u as He,r as Nn,B as _n}from"./main-bwawHmb2.js";import{g as qt}from"./workerType-BOi1t0TG.js";import{D as de,a as ue,c as me,d as xe,b as Sn}from"./dialog-BnhKhSaK.js";import{A as Cn,S as En}from"./SessionVisibilityBadge-BY5tHU7b.js";import{R as Tn}from"./refresh-cw-CKRHMYj-.js";import{A as Mn,U as Rn}from"./UserSearchInput-nQ2jQJmj.js";import{C as An}from"./copy-CJUB1OCZ.js";import{E as $n,A as In}from"./ArtifactsGallery-DxVwQ8Wh.js";import{S as Dn,b as qn}from"./notifications-BV1MotN8.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 Pn=[["path",{d:"m9 18 6-6-6-6",key:"mthhwq"}]],ns=Q("chevron-right",Pn);/**
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 On=[["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"}]],rs=Q("cpu",On);/**
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 Un=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Fn=Q("gauge",Un);/**
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 Kn=[["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"}]],Ln=Q("hash",Kn);/**
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 Bn=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 16v-4",key:"1dtifu"}],["path",{d:"M12 8h.01",key:"e9boi3"}]],Hn=Q("info",Bn);/**
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 Wn=[["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"}]],as=Q("message-circle-question-mark",Wn);/**
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 Qn=[["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"}]],Vn=Q("message-square-text",Qn);/**
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 zn=[["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"}]],Gn=Q("play",zn);/**
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 Yn=[["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"}]],os=Q("plug",Yn);/**
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 Jn=[["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"}]],Xn=Q("server-cog",Jn);/**
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 Zn=[["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"}]],is=Q("settings-2",Zn);/**
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 er=[["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=Q("share-2",er);/**
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:"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"}]],nr=Q("shield-check",sr);function ls(){return{tasks:{}}}const Pt=3e4;function qe(n){const t=n.trim();if(!t)return"agent";const s=t.split(/\s+/).slice(0,2).join(" ");return s.length>40?s.slice(0,40)+"…":s}function rr(n,t){var i,u,y,p,g,v,N,S,x,d,j,h;const s=t.subtype;if(s!=="task_started"&&s!=="task_progress"&&s!=="task_notification")return n;const r=t.task_id;if(!r)return n;const a=Date.now(),m=n.tasks[r];if(s==="task_started"){if(m)return{tasks:{...n.tasks,[r]:{...m,description:t.description??m.description,name:qe(t.description??m.description),taskType:t.task_type??m.taskType,workflowName:t.workflow_name??m.workflowName,prompt:t.prompt??m.prompt,toolUseId:t.tool_use_id??m.toolUseId,status:"running",startTime:a,evictAfter:void 0}}};const b=t.description??"";return{tasks:{...n.tasks,[r]:{taskId:r,name:qe(b),description:b,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(!m){const b=t.description??"";return{tasks:{...n.tasks,[r]:{taskId:r,name:qe(b),description:b,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:(y=t.usage)==null?void 0:y.duration_ms,lastToolName:t.last_tool_name,summary:t.summary}}}}return{tasks:{...n.tasks,[r]:{...m,description:t.description??m.description,tokenCount:((p=t.usage)==null?void 0:p.total_tokens)??m.tokenCount,toolUseCount:((g=t.usage)==null?void 0:g.tool_uses)??m.toolUseCount,durationMs:((v=t.usage)==null?void 0:v.duration_ms)??m.durationMs,lastToolName:t.last_tool_name??m.lastToolName,summary:t.summary??m.summary}}}}return m?{tasks:{...n.tasks,[r]:{...m,status:t.status??"completed",endTime:a,finalSummary:t.summary??m.finalSummary,outputFile:t.output_file??m.outputFile,tokenCount:((d=t.usage)==null?void 0:d.total_tokens)??m.tokenCount,toolUseCount:((j=t.usage)==null?void 0:j.tool_uses)??m.toolUseCount,durationMs:((h=t.usage)==null?void 0:h.duration_ms)??m.durationMs,evictAfter:a+Pt}}}:{tasks:{...n.tasks,[r]:{taskId:r,name:qe(t.summary??""),description:t.summary??"",status:t.status??"completed",startTime:a,endTime:a,finalSummary:t.summary,outputFile:t.output_file,tokenCount:(N=t.usage)==null?void 0:N.total_tokens,toolUseCount:(S=t.usage)==null?void 0:S.tool_uses,durationMs:(x=t.usage)==null?void 0:x.duration_ms,evictAfter:a+Pt}}}}function ar(n,t=Date.now()){return Object.values(n.tasks).filter(s=>s.evictAfter===void 0||s.evictAfter>t).sort((s,r)=>s.startTime-r.startTime)}function or(n){if(!n||typeof n!="object"||Array.isArray(n))return null;const t=n,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,side_question:t.side_question===!0};return Object.values(s).some(Boolean)?s:null}function Ot(n,t){const s=[];if(Array.isArray(n)){for(const r of n){if(!r||typeof r!="object")continue;const a=r;if(typeof a.name!="string"||!a.name)continue;const m=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}:{},...m?{type:m}:{}})}if(s.length>0)return s}if(Array.isArray(t))for(const r of t)typeof r=="string"&&r&&s.push({name:r});return s}function Ut(n){const t=n.raw&&typeof n.raw=="object"&&!Array.isArray(n.raw)?n.raw:n,s=Ot(t.slash_command_details??n.slash_command_details,t.slash_commands??n.slash_commands),r=Ot(t.skill_details??n.skill_details,t.skills??n.skills),a=or(t.remote_capabilities??n.remote_capabilities);return s.length===0&&r.length===0&&!a?null:{commands:s,skills:r,capabilities:a}}class ir{constructor(t){M(this,"listeners",new Set);M(this,"stateListeners",new Set);M(this,"eventSource",null);M(this,"sessionId",null);M(this,"_lastSeqNum",0);M(this,"lastFrameAt",0);M(this,"firstEventAfterOpen",!1);M(this,"watchdogTimer",null);M(this,"visibilityHandler",null);M(this,"reconnectTimer",null);M(this,"reconnectAttempts",0);M(this,"_state","idle");M(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",r=>{this.lastFrameAt=Date.now();try{const a=JSON.parse(r.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 m of this.listeners)m(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 Vs(),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 ie=new ir;function nt(n){if(typeof n.content=="string")return n.content;if(n.message&&typeof n.message=="object"){const t=n.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 Ft(n,t){for(let s=n.length-1;s>=0;s--){const r=n[s];if(r&&r.type==="tool_call"&&r.toolCall.id===t)return s}return-1}const rt="streaming-";function lr(n){const t=n.message;if(!t||typeof t!="object"||!Array.isArray(t.content))return"";const s=[];for(const r of t.content)if((r==null?void 0:r.type)==="thinking"){const a=typeof r.thinking=="string"&&r.thinking||typeof r.text=="string"&&r.text||"";a&&s.push(a)}return s.join("")}function Kt(n){return n.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 Lt(n){if(!n||typeof n!="object")return"";const t=n;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 r=s.target_event_id;if(typeof r=="string"&&r)return r}return""}class cr{constructor(t,s,r){M(this,"sessionId");M(this,"setEntries");M(this,"unsub",null);M(this,"unsubState",null);M(this,"onStatusChange");M(this,"onError");M(this,"onPermissionRequest");M(this,"onModelsStateChange");M(this,"onSubagentUpdate");M(this,"onControlResponse");M(this,"onPermissionModeChange");M(this,"onUsageChange");M(this,"onElicitationRequest");M(this,"onWorkerInfoChange");M(this,"subagentState",ls());M(this,"seenUuids",new Set);M(this,"seenToolCallIds",new Set);M(this,"postedUserUuids",new Set);M(this,"pendingControlRequests",new Map);M(this,"turnEnded",!1);M(this,"userSinceTurnEnd",!1);M(this,"closed",!1);this.sessionId=t,this.setEntries=s,this.onStatusChange=r==null?void 0:r.onStatusChange,this.onError=r==null?void 0:r.onError,this.onPermissionRequest=r==null?void 0:r.onPermissionRequest,this.onModelsStateChange=r==null?void 0:r.onModelsStateChange,this.onSubagentUpdate=r==null?void 0:r.onSubagentUpdate,this.onControlResponse=r==null?void 0:r.onControlResponse,this.onPermissionModeChange=r==null?void 0:r.onPermissionModeChange,this.onUsageChange=r==null?void 0:r.onUsageChange,this.onElicitationRequest=r==null?void 0:r.onElicitationRequest,this.onWorkerInfoChange=r==null?void 0:r.onWorkerInfoChange}markClosed(){this.closed=!0}async init(){await this.loadHistory(),this.connectSSE()}async loadHistory(){var v,N,S,x,d,j;const{events:t}=await Ls(this.sessionId);if(!t||t.length===0)return;const s=new Set;for(const h of t){if(h.type!=="user"||h.direction==="inbound")continue;const b=(v=h.payload)==null?void 0:v.uuid;typeof b=="string"&&b&&s.add(b)}const r=[];let a=null;const m=()=>{a&&(r.push(a),a=null)};for(const h of t){const b=h.payload||{},k=b.uuid;if(typeof k=="string"&&k&&this.seenUuids.add(k),h.type==="tool_use"){const w=b.tool_call_id;typeof w=="string"&&w&&this.seenToolCallIds.add(w)}if(h.type==="user"){if(h.direction==="inbound"){const T=b.uuid;if(typeof T!="string"||!T||s.has(T))continue}m();const w=nt(b);w&&r.push({type:"user_message",id:h.id||`hist-user-${r.length}`,content:w})}else if(h.type==="assistant"){m();const w=nt(b);if(Tt(w))continue;const T=[],I=b.message;if(I&&typeof I=="object"&&Array.isArray(I.content)){for(const D of I.content)if(D.type==="tool_use"){const L=D.id;L&&this.seenToolCallIds.add(L),T.push({type:"tool_call",toolCall:{id:L||`hist-tool-${r.length}`,title:D.name||"tool",status:"complete",rawInput:D.input||{}}})}}if(w||T.length>0){a={type:"assistant_message",id:h.id||`hist-asst-${r.length}`,chunks:w?[{type:"message",text:w}]:[]},r.push(a);for(const D of T)r.push(D);a=null}}else if(h.type==="conversation_rewound"){const w=Lt(b);if(w){const T=r.findIndex(I=>Mt(I)===w);T>=0&&(r.length=T)}}else if(h.type==="tool_use"){const w=b,T={type:"tool_call",toolCall:{id:w.tool_call_id||`hist-tool-${r.length}`,title:w.tool_name||"tool",status:"complete",rawInput:w.tool_input||{}}};r.push(T)}else if(h.type==="tool_result"){const w=b,T=Ft(r,w.tool_call_id||"");if(T>=0){const I=r[T];r[T]={type:"tool_call",toolCall:{...I.toolCall,rawOutput:{output:w.content||w.output||""}}}}}}m();let i=null;for(const h of t){if(h.type!=="task_state")continue;const b=h.payload||{};Array.isArray(b.tasks)&&(i=b.tasks)}if(i&&i.length>0){const h=Kt(i);h.length>0&&r.push({type:"plan",id:`plan-hist-${Date.now()}`,entries:h})}this.setEntries(r);let u=null,y=null,p=null,g=null;for(const h of t){const b=h.payload||{};if(h.type==="user"?g="user":(h.type==="result"||h.type==="result_success"||h.type==="interrupt")&&(g="turn_end"),h.type==="system"&&(b.subtype==="init"||((N=b.raw)==null?void 0:N.subtype)==="init")&&(y=Ut(b)),h.type==="models_state"){const k=b.raw,w=k&&typeof k=="object"?k.models_state:b.models_state;w&&Array.isArray(w.availableModels)&&typeof w.currentModelId=="string"&&(u=w)}else if(h.type==="result"||h.type==="result_success"){const k=b.usage,w=typeof b.total_cost_usd=="number"?b.total_cost_usd:null;(k||w!==null)&&(p={inputTokens:((k==null?void 0:k.input_tokens)??0)+((k==null?void 0:k.cache_read_input_tokens)??0)+((k==null?void 0:k.cache_creation_input_tokens)??0),outputTokens:(k==null?void 0:k.output_tokens)??0,totalCostUsd:w})}}u&&((S=this.onModelsStateChange)==null||S.call(this,u)),y&&((x=this.onWorkerInfoChange)==null||x.call(this,y)),p&&((d=this.onUsageChange)==null||d.call(this,p)),this.turnEnded=g==="turn_end",this.userSinceTurnEnd=g==="user",this.turnEnded&&!this.closed&&((j=this.onStatusChange)==null||j.call(this,"idle"))}connectSSE(){ie.connect(this.sessionId),this.unsub=ie.onEvent(t=>this.handleEvent(t)),this.unsubState=ie.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),ie.disconnect()}handleEvent(t){var a,m,i,u,y,p,g,v,N,S;const s=t.type,r=t.payload||{};switch(s){case"user":{if(this.userSinceTurnEnd=!0,t.direction==="inbound"){const x=r.uuid;if(typeof x!="string"||!x||this.postedUserUuids.has(x)||this.seenUuids.has(x))break;this.seenUuids.add(x);const d=nt(r);d&&this.setEntries(j=>[...j,{type:"user_message",id:t.id||`user-${Date.now()}`,content:d}])}break}case"assistant":{const x=r.uuid;if(typeof x=="string"&&x){if(this.seenUuids.has(x))break;this.seenUuids.add(x)}const d=typeof r.content=="string"?r.content:"";if(Tt(d))break;const j=lr(r);this.setEntries(b=>{const k=b[b.length-1];if((k==null?void 0:k.type)==="assistant_message"&&k.id.startsWith(rt))return[...b.slice(0,-1),{...k,id:`assistant-${Date.now()}`,chunks:[...j?[{type:"thought",text:j}]:[],{type:"message",text:d}]}];if((k==null?void 0:k.type)==="assistant_message"){const w=k.chunks[k.chunks.length-1];return(w==null?void 0:w.type)==="message"?[...b.slice(0,-1),{...k,chunks:[...k.chunks.slice(0,-1),{type:"message",text:w.text+d}]}]:[...b.slice(0,-1),{...k,chunks:[...k.chunks,{type:"message",text:d}]}]}if(d&&d.trim()||j){const w={type:"assistant_message",id:`assistant-${Date.now()}`,chunks:[...j?[{type:"thought",text:j}]:[],...d?[{type:"message",text:d}]:[]]};return[...b,w]}return b});const h=r.message;if(h&&typeof h=="object"&&Array.isArray(h.content)){const b=h.content.filter(k=>k.type==="tool_use");for(const k of b){const w=k.id||`call-${Date.now()}-${Math.random().toString(16).slice(2,8)}`;if(this.seenToolCallIds.has(w))continue;this.seenToolCallIds.add(w);const T={id:w,title:k.name||"tool",status:"running",rawInput:k.input||{}};this.setEntries(I=>[...I,{type:"tool_call",toolCall:T}])}}break}case"tool_use":{const x=r,d=x.tool_call_id||`call-${Date.now()}`;if(this.seenToolCallIds.has(d))break;this.seenToolCallIds.add(d);const j={id:d,title:x.tool_name||"tool",status:"running",rawInput:x.tool_input||{}};this.setEntries(h=>[...h,{type:"tool_call",toolCall:j}]);break}case"tool_result":{const x=r,d=x.tool_call_id||"";this.setEntries(j=>{const h=Ft(j,d);if(h<0)return j;const b=j[h];return j.map((k,w)=>w===h?{type:"tool_call",toolCall:{...b.toolCall,status:"complete",rawOutput:{output:x.content||x.output||""}}}:k)});break}case"control_request":case"permission_request":{const x=r.request;if(x&&x.subtype==="can_use_tool"){const d=r.request_id||"",j=x.tool_name||"unknown",h=x.input||x.tool_input||{},b=x.description||"",k=Array.isArray(x.permission_suggestions)?x.permission_suggestions:[];this.setEntries(w=>{const T=[...w].reverse().findIndex(I=>I.type==="tool_call");if(T>=0){const I=w.length-1-T,D=w[I];if(D.toolCall.status==="running")return w.map((L,te)=>te===I?{type:"tool_call",toolCall:{...D.toolCall,status:"waiting_for_confirmation",permissionRequest:{requestId:d,options:[]}}}:L)}return w}),(a=this.onPermissionRequest)==null||a.call(this,{requestId:d,toolName:j,toolInput:h,description:b,suggestions:k})}else x&&x.subtype==="elicitation"&&((m=this.onElicitationRequest)==null||m.call(this,{requestId:r.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=Lt(r);x&&this.setEntries(d=>{const j=d.findIndex(h=>Mt(h)===x);return j===-1?d:d.slice(0,j)});break}case"session_status":{if(Bs(r)){this.setEntries([]);break}if(typeof r.status=="string"){if(Oe(r.status))this.closed=!0;else if(this.closed)break;if(r.status==="running"&&this.turnEnded&&!this.userSinceTurnEnd)break;(i=this.onStatusChange)==null||i.call(this,r.status)}break}case"error":{const x=String(r.message||r.content||"Unknown error");(u=this.onError)==null||u.call(this,x);break}case"models_state":{const x=r.raw,d=typeof x=="object"&&x!==null?x.models_state:r.models_state;d&&Array.isArray(d.availableModels)&&typeof d.currentModelId=="string"&&((y=this.onModelsStateChange)==null||y.call(this,d));break}case"system":{const x=r.raw,d=x&&typeof x=="object"?x:r,j=typeof d.subtype=="string"?d.subtype:void 0;if(j==="task_started"||j==="task_progress"||j==="task_notification"){const b={subtype:j,task_id:typeof d.task_id=="string"?d.task_id:void 0,tool_use_id:typeof d.tool_use_id=="string"?d.tool_use_id:void 0,description:typeof d.description=="string"?d.description:void 0,task_type:typeof d.task_type=="string"?d.task_type:void 0,workflow_name:typeof d.workflow_name=="string"?d.workflow_name:void 0,prompt:typeof d.prompt=="string"?d.prompt:void 0,usage:d.usage&&typeof d.usage=="object"?d.usage:void 0,last_tool_name:typeof d.last_tool_name=="string"?d.last_tool_name:void 0,summary:typeof d.summary=="string"?d.summary:void 0,status:d.status==="completed"||d.status==="failed"||d.status==="stopped"?d.status:void 0,output_file:typeof d.output_file=="string"?d.output_file:void 0};this.subagentState=rr(this.subagentState,b)}const h=typeof d.permissionMode=="string"?d.permissionMode:typeof r.permissionMode=="string"?r.permissionMode:null;if(h&&((p=this.onPermissionModeChange)==null||p.call(this,h)),j==="init"){const b=Ut(r);b&&((g=this.onWorkerInfoChange)==null||g.call(this,b))}break}case"control_response":{const x=r.response;if(x&&typeof x=="object"){const d=typeof x.request_id=="string"?x.request_id:"",j=typeof x.subtype=="string"?x.subtype:"";if(d){(v=this.onControlResponse)==null||v.call(this,{subtype:j,requestId:d,error:typeof x.error=="string"?x.error:void 0});const h=this.pendingControlRequests.get(d);h&&(this.pendingControlRequests.delete(d),h({data:j==="success"&&x.response&&typeof x.response=="object"?x.response:null,...j==="error"&&typeof x.error=="string"?{error:x.error}:{}}))}}break}case"stream_event":{const x=r.event;if(!x||typeof x.type!="string")break;if(x.type==="content_block_delta"){const d=x.delta;if(!d||typeof d.type!="string")break;const j=d.type==="text_delta"?"message":d.type==="thinking_delta"?"thought":null;if(!j)break;const h=d.text??d.thinking;if(typeof h!="string"||!h)break;this.appendStreamingDelta(j,h)}break}case"partial_assistant":{const x=typeof r.content=="string"?r.content:"";x&&this.appendStreamingDelta("message",x);break}case"result":case"result_success":{this.turnEnded=!0,this.userSinceTurnEnd=!1,this.closed||(N=this.onStatusChange)==null||N.call(this,"idle");const x=r.usage,d=typeof r.total_cost_usd=="number"?r.total_cost_usd:null;if(x||d!==null){const w=((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);(S=this.onUsageChange)==null||S.call(this,{inputTokens:w,outputTokens:(x==null?void 0:x.output_tokens)??0,totalCostUsd:d})}const j=typeof r.subtype=="string"?r.subtype:"",h=r.raw&&typeof r.raw=="object"?r.raw:void 0,k=(typeof r.result=="string"?r.result:typeof(h==null?void 0:h.result)=="string"?h.result:"").trim();j.startsWith("error_")&&k&&this.setEntries(w=>[...w,{type:"command_output",id:`exit-error-${typeof r.uuid=="string"?r.uuid:Date.now()}`,commandName:"worker",inputText:"",title:c("adapter.workerCrashed"),outputText:k,variant:"error"}]);break}case"task_state":{const x=Array.isArray(r.tasks)?r.tasks:[];if(x.length===0)break;const d=Kt(x);if(d.length===0)break;this.setEntries(j=>[...j.filter(b=>b.type!=="plan"),{type:"plan",id:`plan-${r.task_list_id||Date.now()}`,entries:d}]);break}}}appendStreamingDelta(t,s){this.setEntries(r=>{const a=r[r.length-1];if((a==null?void 0:a.type)==="assistant_message"&&a.id.startsWith(rt)){const i=a.chunks[a.chunks.length-1];return(i==null?void 0:i.type)===t?[...r.slice(0,-1),{...a,chunks:[...a.chunks.slice(0,-1),{type:t,text:i.text+s}]}]:[...r.slice(0,-1),{...a,chunks:[...a.chunks,{type:t,text:s}]}]}const m={type:"assistant_message",id:`${rt}${Date.now()}`,chunks:[{type:t,text:s}]};return[...r,m]})}async sendMessage(t,s,r){var p;const a=s&&s.length>0,m=r&&r.length>0;if(!t.trim()&&!a&&!m)return;const i={type:"user_message",id:`user-${Date.now()}`,content:t,images:a?s:void 0,attachments:m?r: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(m){for(const g of r)if(g.kind==="text"||g.kind==="table"){const v=`📎 ${g.name}${g.size!=null?` (${dr(g.size)})`:""}`,N=g.textContent||c("attach.emptyFile");u.push({type:"text",text:`${v}
67
+ \`\`\`
68
+ ${N}
69
+ \`\`\``})}else if(g.kind==="directory"){const v=g.files!=null?`${O("attach.directoryHeader",{name:g.name})} ${O("attach.fileCount",{n:g.files.length})}`:O("attach.directoryHeader",{name:g.name}),N=g.textContent||c("attach.emptyDirectory");u.push({type:"text",text:`${v}
70
+ ${N}`})}}const y=u.length===1&&u[0].type==="text"?u[0].text||t:u.length>0?u:t;try{const g=oe();this.postedUserUuids.add(g);const v=await Hs(this.sessionId,{type:"user",uuid:g,content:t,message:{content:y}}),N=(p=v==null?void 0:v.event)==null?void 0:p.id;N&&this.setEntries(S=>S.map(x=>x.type==="user_message"&&x.id===i.id?{...x,id:N}:x))}catch(g){throw this.setEntries(v=>v.filter(N=>!(N.type==="user_message"&&N.id===i.id))),g}}async respondPermission(t,s,r){await z(this.sessionId,{type:"permission_response",approved:s,request_id:t,...r}),this.setEntries(a=>a.map(m=>{var i;return m.type!=="tool_call"||((i=m.toolCall.permissionRequest)==null?void 0:i.requestId)!==t?m:{type:"tool_call",toolCall:{...m.toolCall,status:s?"running":"rejected",permissionRequest:void 0}}}))}async interrupt(){this.setEntries(t=>t.map(s=>s.type!=="tool_call"||s.toolCall.status!=="running"&&s.toolCall.status!=="waiting_for_confirmation"?s:{type:"tool_call",toolCall:{...s.toolCall,status:"canceled",permissionRequest:void 0}})),await Ws(this.sessionId)}async setPermissionMode(t){const s=oe();return await z(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_permission_mode",mode:t}}),s}async controlRoundTrip(t,s=8e3){const r=oe(),a=new Promise(i=>{this.pendingControlRequests.set(r,i)}),m=setTimeout(()=>{const i=this.pendingControlRequests.get(r);i&&(this.pendingControlRequests.delete(r),i({data:null,error:"timeout"}))},s);try{return await z(this.sessionId,{type:"control_request",request_id:r,request:t}),await a}catch(i){throw this.pendingControlRequests.delete(r),i}finally{clearTimeout(m)}}async searchFiles(t,s=20){const r=await this.controlRoundTrip({subtype:"file_search",query:t,limit:s});try{if(!r.data||!Array.isArray(r.data.suggestions))return[];const a=[];for(const m of r.data.suggestions)m&&typeof m=="object"&&typeof m.path=="string"&&a.push(m.path);return a}catch{return[]}}async respondElicitation(t,s,r){await z(this.sessionId,{type:"permission_response",approved:s==="accept",request_id:t,response:{subtype:"success",request_id:t,response:{action:s,...r?{content:r}:{}}}})}async askSideQuestion(t){const s=await this.controlRoundTrip({subtype:"side_question",question:t},12e4);if(s.error||!s.data)return null;const r=s.data.response;return typeof r=="string"?r: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 r of t.data.sessions){if(!r||typeof r!="object")continue;const a=r;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=oe();return await z(this.sessionId,{type:"control_request",request_id:s,request:{subtype:"set_effort",...t?{effort:t}:{effort:null}}}),s}async setThinkingBudget(t){const s=oe();return await z(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,r=t.data.rawMaxTokens,a=t.data.percentage;if(typeof s!="number"||typeof r!="number")return null;const m=t.data.categories,i=Array.isArray(m)?m.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:r,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 r=[];for(const m of s){if(!m||typeof m!="object")continue;const i=m;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 y=i.serverInfo,p=i.config;r.push({name:i.name,status:u,...y&&typeof y.name=="string"&&typeof y.version=="string"?{serverInfo:{name:y.name,version:y.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 r}async toggleMcpServer(t,s){const r=await this.controlRoundTrip({subtype:"mcp_toggle",serverName:t,enabled:s},15e3);return r.error?{ok:!1,error:r.error==="timeout"?c("adapter.requestTimeout"):r.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 r=s.applied,a=s.effective&&typeof s.effective=="object"&&!Array.isArray(s.effective)?s.effective:{},m=s.sources,i=[];if(Array.isArray(m))for(const u of m){if(!u||typeof u!="object")continue;const y=u;typeof y.source=="string"&&i.push({source:y.source,settings:y.settings&&typeof y.settings=="object"&&!Array.isArray(y.settings)?y.settings:{}})}return{applied:{model:typeof(r==null?void 0:r.model)=="string"?r.model:null,effort:typeof(r==null?void 0:r.effort)=="string"?r.effort: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 Qs(this.sessionId,t)}async endSession(t){await z(this.sessionId,{type:"control_request",request_id:oe(),request:{subtype:"end_session",...t?{reason:t}:{}}})}}function dr(n){return n<1024?`${n} B`:n<1024*1024?`${(n/1024).toFixed(1)} KB`:`${(n/(1024*1024)).toFixed(1)} MB`}function Pe({onBack:n,title:t,meta:s,actions:r}){return J(),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:n,"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})]}),r&&e.jsx("div",{className:"flex flex-shrink-0 items-center gap-0.5",children:r}),e.jsx("span",{className:"mx-1 h-4 w-px flex-shrink-0 bg-border","aria-hidden":"true"}),e.jsx(zs,{}),e.jsx(Gs,{onSettingsClick:()=>{window.history.pushState(null,"","/settings"),window.dispatchEvent(new PopStateEvent("popstate"))}})]})})}function ur(n){if(!n)return"never";const t=Math.max(0,Date.now()-n);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 mr(n){return n?Date.now()-n<6e4:!1}function xr({onClose:n,session:t,liveStatus:s,pendingPermissions:r,onInterrupt:a,onDelete:m,onEndSession:i}){const[u,y]=l.useState(!1),p=async()=>{await navigator.clipboard.writeText(t.id),y(!0),setTimeout(()=>y(!1),1500)},[g,v]=l.useState(!1),N=async()=>{if(!(!i||g)&&window.confirm(c("task.endConfirm"))){v(!0);try{await i(),n()}catch{v(!1)}}},S=r.length,x=t.worker,d=t.work_item,j=t.environment;return e.jsx(de,{open:!0,onOpenChange:h=>{h||n()},children:e.jsxs(ue,{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(me,{children:e.jsx(xe,{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(Cn,{className:"h-3.5 w-3.5"}),"Status"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Ys,{status:s||t.status||"unknown"}),e.jsx("span",{className:"text-xs text-text-muted",children:x&&(mr(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(Rt,{className:"h-3 w-3"}),"Heartbeat"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ur(x.last_heartbeat_at)})]}),j&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(rs,{className:"h-3 w-3"}),"Environment"]}),e.jsx("dd",{className:"truncate text-text-secondary",children:j.machine_name||j.id})]}),t.created_at&&e.jsxs("div",{className:"flex justify-between",children:[e.jsxs("dt",{className:"flex items-center gap-1",children:[e.jsx(Rt,{className:"h-3 w-3"}),"Created"]}),e.jsx("dd",{className:"font-mono text-text-secondary",children:ts(t.created_at)})]})]})]}),e.jsxs("section",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center gap-1.5 text-xs font-medium uppercase tracking-wide text-text-muted",children:[e.jsx(_e,{className:"h-3.5 w-3.5"}),"Pending Actions"]}),S>0?e.jsxs("div",{className:"rounded-md bg-status-warning/10 px-3 py-2 text-xs text-status-warning",children:[S," permission request",S>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(Xn,{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"}),i&&e.jsx("button",{onClick:N,disabled:g,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:g?"Ending…":"End session"}),e.jsxs("button",{onClick:m,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(Js,{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(Ln,{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:p,className:"text-text-muted hover:text-text-primary transition-colors flex-shrink-0",title:"Copy session id",children:u?"✓":"⧉"})]})]}),d&&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:d.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:d.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})]}),j&&e.jsxs("div",{className:"flex justify-between",children:[e.jsx("dt",{children:"Worker type"}),e.jsx("dd",{className:"font-mono text-text-secondary",children:j.worker_type})]})]})]})]})]})})}const fr={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"},pr={connected:"mcp.status.connected",failed:"mcp.status.failed","needs-auth":"mcp.status.needsAuth",pending:"mcp.status.pending",disabled:"mcp.status.disabled"};function hr({onClose:n,fetchServers:t,onToggle:s,onReconnect:r}){J();const[a,m]=l.useState(null),[i,u]=l.useState(null),[y,p]=l.useState(null),[g,v]=l.useState(null),N=l.useCallback(async()=>{p(null),v(null);try{const d=await t();m(d),u(null)}catch(d){Ue("[McpPanel] fetch failed",d),u(c("mcp.loadFailed"))}},[t]);l.useEffect(()=>{N()},[N]);const S=async d=>{const j=d.status==="disabled";p(`toggle:${d.name}`),v(null);try{const h=await s(d.name,j);h.ok||v(h.error||c("mcp.toggleFailed"))}finally{await N()}},x=async d=>{p(`reconnect:${d.name}`),v(null);try{const j=await r(d.name);j.ok||v(j.error||c("mcp.reconnectFailed"))}finally{await N()}};return e.jsx(de,{open:!0,onOpenChange:d=>{d||n()},children:e.jsxs(ue,{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(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(os,{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(_e,{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(d=>{const j=y===`toggle:${d.name}`,h=y===`reconnect:${d.name}`,b=d.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:d.name}),e.jsx("span",{className:`flex-shrink-0 rounded-full px-1.5 py-0.5 text-[10px] font-medium ${fr[d.status]}`,children:c(pr[d.status])})]}),e.jsxs("div",{className:"mt-0.5 truncate text-xs text-text-muted",children:[d.serverInfo?`${d.serverInfo.name} v${d.serverInfo.version}`:d.url||"stdio",d.toolCount!==void 0&&` · ${O("mcp.toolCount",{n:d.toolCount})}`]}),d.error&&e.jsx("div",{className:"mt-1 truncate text-xs text-status-error",title:d.error,children:d.error})]}),e.jsxs("div",{className:"flex flex-shrink-0 items-center gap-1",children:[e.jsx("button",{type:"button",onClick:()=>void x(d),disabled:h||b,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(Tn,{className:`h-3.5 w-3.5 ${h?"animate-spin":""}`})}),e.jsx("button",{type:"button",role:"switch","aria-checked":!b,onClick:()=>void S(d),disabled:j,className:`relative h-5 w-9 rounded-full transition-colors disabled:opacity-50 ${b?"bg-surface-3":"bg-brand"}`,title:b?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 ${b?"left-0.5":"left-4.5"}`})})]})]})},d.name)})]})]})})}function gr(n){if(n==null)return c("settings.unset");if(typeof n=="string")return n;try{return JSON.stringify(n)}catch{return String(n)}}function Bt(n){if(n==null)return c("settings.unset");if(typeof n=="object")try{return JSON.stringify(n,null,2)}catch{return String(n)}return String(n)}function yr({onClose:n,fetchSettings:t,onApply:s}){J();const[r,a]=l.useState(null),[m,i]=l.useState(null),[u,y]=l.useState(""),[p,g]=l.useState(null),[v,N]=l.useState(null),[S,x]=l.useState(null),[d,j]=l.useState(!1),h=l.useCallback(async()=>{g(null),N(null),x(null),j(!1);try{const C=await t();a(C),i(C?null:c("settings.loadFailed"))}catch(C){Ue("[SettingsDrawer] fetch failed",C),i(c("settings.loadFailed"))}},[t]);l.useEffect(()=>{h()},[h]);const b=l.useMemo(()=>r?Object.entries(r.effective).filter(([,C])=>C!==void 0).sort(([C],[U])=>C.localeCompare(U)):[],[r]),k=l.useMemo(()=>{const C=u.trim().toLowerCase();return C?b.filter(([U,V])=>`${U} ${gr(V)}`.toLowerCase().includes(C)):b},[b,u]),w=C=>typeof C[1]=="boolean",T=l.useMemo(()=>k.filter(w),[k]),I=l.useMemo(()=>k.filter(C=>!w(C)),[k]),D=l.useMemo(()=>S===null?null:b.find(([C])=>C===S)??null,[b,S]),L=async()=>{if(D)try{await navigator.clipboard.writeText(Bt(D[1])),j(!0),window.setTimeout(()=>j(!1),1500)}catch(C){Ue("[SettingsDrawer] copy failed",C)}},te=async(C,U)=>{g(C),N(null);try{const V=await s({[C]:!U});V.ok||N(V.error||c("settings.writeFailed"))}finally{await h()}};return e.jsx(de,{open:!0,onOpenChange:C=>{C||n()},children:e.jsxs(ue,{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(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(is,{className:"h-4 w-4"}),c("session.settings.title")]})}),e.jsxs("div",{className:"mt-3 space-y-4 text-sm",children:[v&&e.jsx("div",{className:"rounded-md bg-status-error/10 px-3 py-2 text-xs text-status-error",children:v}),r===null&&!m&&e.jsxs("div",{className:"flex items-center gap-2 text-xs text-text-muted",children:[e.jsx(_e,{className:"h-3.5 w-3.5 animate-spin"}),c("settings.loading")]}),m&&e.jsx("p",{className:"text-xs text-status-error",children:m}),r&&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:r.applied.model||c("settings.defaultModel")})]}),r.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:r.applied.effort})]}),e.jsx("p",{className:"mt-2 text-[11px] leading-relaxed text-text-muted",children:c("settings.hint")})]}),D?e.jsxs("section",{className:"space-y-2",children:[e.jsxs("button",{type:"button",onClick:()=>{x(null),j(!1)},className:"flex items-center gap-1.5 text-xs text-text-muted transition-colors hover:text-text-primary",children:[e.jsx(Mn,{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:D[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-[11px] leading-relaxed text-text-secondary",children:Bt(D[1])}),e.jsxs("button",{type:"button",onClick:()=>void L(),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:[d?e.jsx(Se,{className:"h-3.5 w-3.5 text-status-success"}):e.jsx(An,{className:"h-3.5 w-3.5"}),d?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(it,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{value:u,onChange:C=>y(C.target.value),placeholder:c("settings.searchPlaceholder"),className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"})]}),k.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-[11px] font-medium uppercase tracking-wide text-text-muted",children:O("settings.togglable",{n:T.length})}),T.map(([C,U])=>{const V=p===C;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:C}),e.jsx("button",{type:"button",role:"switch","aria-checked":U,disabled:V,onClick:()=>void te(C,U),className:`relative h-5 w-9 flex-shrink-0 rounded-full transition-colors disabled:opacity-50 ${U?"bg-brand":"bg-surface-3"}`,title:U?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 ${U?"left-4.5":"left-0.5"}`})})]},C)})]}),I.length>0&&e.jsxs("section",{className:"space-y-1.5",children:[e.jsx("h3",{className:"text-[11px] font-medium uppercase tracking-wide text-text-muted",children:O("settings.readOnly",{n:I.length})}),I.map(([C])=>e.jsxs("button",{type:"button",onClick:()=>x(C),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:C}),e.jsx(ns,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"})]},C))]})]})]})]})]})})}function br({onClose:n,onAsk:t}){J();const[s,r]=l.useState([]),[a,m]=l.useState(""),[i,u]=l.useState(!1),y=async()=>{const p=a.trim();if(!p||i)return;const g=Date.now();r(v=>[...v,{id:g,question:p,answer:null}]),m(""),u(!0);try{const v=await t(p);r(N=>N.map(S=>S.id===g?{...S,answer:v??c("sideQuestion.noAnswer"),error:v===null}:S))}finally{u(!1)}};return e.jsx(de,{open:!0,onOpenChange:p=>{p||n()},children:e.jsxs(ue,{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(me,{children:e.jsxs(xe,{className:"flex items-center gap-2 font-display font-semibold text-text-primary",children:[e.jsx(as,{className:"h-4 w-4"}),c("sideQuestion.title")]})}),e.jsx("p",{className:"mt-1 text-[11px] 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(Xs,{children:p.answer})})})]})]},p.id))]}),e.jsxs("div",{className:"mt-3 flex items-end gap-2",children:[e.jsx("textarea",{value:a,onChange:p=>m(p.target.value),onKeyDown:p=>{p.key==="Enter"&&!p.shiftKey&&!p.nativeEvent.isComposing&&(p.preventDefault(),y())},rows:Math.min(4,Math.max(1,a.split(`
71
+ `).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 y(),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(_e,{className:"h-4 w-4 animate-spin"}):e.jsx(Zs,{className:"h-4 w-4"})})]})]})})}const Ht="rcs:subagent-panel:collapsed";function jr(n){if(n<1e3)return"0s";const t=Math.floor(n/1e3);if(t<60)return`${t}s`;const s=Math.floor(t/60),r=t%60;if(s<60)return r?`${s}m${r}s`:`${s}m`;const a=Math.floor(s/60),m=s%60;return m?`${a}h${m}m`:`${a}h`}function wr(n){return n===void 0||n<=0?"":n<1e3?`${n}`:n<1e6?`${(n/1e3).toFixed(n<1e4?1:0)}k`:`${(n/1e6).toFixed(1)}M`}function vr({status:n}){return n==="running"?e.jsx(_e,{className:"h-3 w-3 animate-spin text-brand-text"}):n==="completed"?e.jsx(Gn,{className:"h-3 w-3 text-status-success"}):n==="failed"||n==="stopped"?e.jsx(tn,{className:"h-3 w-3 text-status-error"}):null}function kr({task:n,onStopTask:t}){const s=n.status==="running",r=s?n.durationMs??Date.now()-n.startTime:(n.endTime??Date.now())-n.startTime,a=wr(n.tokenCount),m=n.toolUseCount!==void 0&&n.toolUseCount>0?`${n.toolUseCount} tool${n.toolUseCount>1?"s":""}`:"",i=n.summary||n.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(vr,{status:n.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:n.name}),e.jsx("span",{className:"flex-shrink-0 font-mono text-text-muted",children:jr(r)})]}),e.jsx("div",{className:"mt-0.5 truncate text-text-secondary",children:i}),(a||m||n.lastToolName)&&e.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 font-mono text-[10px] text-text-muted",children:[a&&e.jsxs("span",{children:["↕ ",a," tok"]}),m&&e.jsxs("span",{children:["· ",m]}),n.lastToolName&&e.jsxs("span",{className:"truncate",children:["· last: ",n.lastToolName]})]}),!s&&n.finalSummary&&e.jsx("div",{className:"mt-1 rounded bg-status-success/10 px-1.5 py-0.5 text-[10px] text-status-success",children:n.finalSummary})]}),s&&t&&e.jsx("button",{type:"button",onClick:()=>t(n.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(en,{className:"h-3.5 w-3.5"})})]})}function Nr({state:n,onStopTask:t}){const[s,r]=l.useState(()=>{if(typeof window>"u")return!1;try{return window.localStorage.getItem(Ht)==="1"}catch{return!1}}),a=()=>{r(p=>{const g=!p;try{window.localStorage.setItem(Ht,g?"1":"0")}catch{}return g})},[,m]=l.useState(0);l.useEffect(()=>{const p=Object.values(n.tasks).some(N=>N.status==="running"),g=Object.values(n.tasks).some(N=>N.status!=="running"&&N.evictAfter!==void 0);if(!p&&!g)return;const v=setInterval(()=>{m(N=>N+1)},1e3);return()=>clearInterval(v)},[n]);const i=ar(n);if(i.length===0)return null;const u=i.filter(p=>p.status==="running").length,y=u>0?`${u} running`:`${i.length} recent`;return e.jsx("section",{"aria-label":"Subagents",className:"border-t border-border bg-surface-1 px-4 py-2",children:e.jsxs("div",{className:"mx-auto max-w-3xl space-y-1.5",children:[e.jsxs("button",{type:"button",onClick: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(ns,{className:`h-3 w-3 transition-transform ${s?"":"rotate-90"}`}),e.jsx("span",{children:"Subagents"})]}),e.jsx("span",{children:y})]}),!s&&e.jsx("div",{id:"subagent-list",className:"space-y-1.5",children:i.map(p=>e.jsx(kr,{task:p,onStopTask:t},p.taskId))})]})})}const at="focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-surface-1";function Wt(n,t){var a;const s=(a=t==null?void 0:t.find(m=>m.type==="addRules"||m.type==="replaceRules"))==null?void 0:a.rules,r=s==null?void 0:s[0];return r!=null&&r.ruleContent?`${r.toolName}(${r.ruleContent})`:r!=null&&r.toolName?r.toolName:n}function _r({requestId:n,toolName:t,toolInput:s,description:r,suggestions:a,onApprove:m,onApproveAlways:i,onReject:u}){J();const y=s&&typeof s=="object"&&!Array.isArray(s)?s:{},p=sn(nn(t),y,{writeUnknownLabel:c("permission.writeUnknown")}),g=typeof s=="string"?s:JSON.stringify(s,null,2),v=Array.isArray(a)&&a.length>0;return e.jsxs("div",{role:"group","aria-label":O("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(rn,{className:"h-3 w-3"})}),e.jsx("span",{className:"text-sm font-semibold font-display text-approve-text",children:c("permission.title")})]}),r&&e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:W(r)}),e.jsx("div",{className:"mb-2 font-mono text-xs font-bold text-text-primary",children:W(t)}),t!=="AskUserQuestion"&&(p?e.jsx("div",{className:"mb-3 space-y-2",children:p.map((N,S)=>e.jsx(an,{filePath:N.filePath,oldString:N.oldString,newString:N.newString,label:N.label},S))}):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:At(g,500)})),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx("button",{onClick:m,className:ee("rounded-lg bg-approve px-4 py-2 text-sm font-medium font-display text-white hover:bg-approve-hover transition-colors",at),children:c("permission.approve")}),v&&i&&e.jsxs("button",{onClick:i,className:ee("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",at),title:c("permission.alwaysAllowHint").replace("{rule}",Wt(t,a)),children:[e.jsx(nr,{className:"h-3.5 w-3.5"}),c("permission.alwaysAllow")," ",At(Wt(t,a),40)]}),e.jsx("button",{onClick:u,className:ee("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",at),children:c("permission.reject")})]})]})}function Sr({questions:n,description:t,onSubmit:s,onSkip:r}){const[a,m]=l.useState({}),[i,u]=l.useState({}),[y,p]=l.useState(0),g=(x,d,j)=>{if(j){const h=a[x]||[],b=h.includes(d)?h.filter(k=>k!==d):[...h,d];m({...a,[x]:b})}else m({...a,[x]:d})},v=x=>{var j;const d=(j=i[x])==null?void 0:j.trim();d&&(m({...a,[x]:d}),u({...i,[x]:""}))},N=()=>{var d,j;const x={};for(const[h,b]of Object.entries(a)){const k=n[parseInt(h,10)];k&&(typeof b=="number"?x[h]=((j=(d=k.options)==null?void 0:d[b])==null?void 0:j.label)||String(b):Array.isArray(b)?x[h]=b.map(w=>{var T,I;return((I=(T=k.options)==null?void 0:T[w])==null?void 0:I.label)||String(w)}):x[h]=b)}s(x)};if(n.length<=1){const x=n[0]||{question:t,options:[],multiSelect:!1},d=x.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:W(t||x.question||"Question")}),e.jsxs("div",{className:"space-y-2",children:[(x.options||[]).map((j,h)=>{const b=d?(a[0]||[]).includes(h):a[0]===h;return e.jsxs("button",{onClick:()=>g(0,h,d),className:ee("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",b?"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:W(j.label)}),j.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:W(j.description)})]},h)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:i[0]||"",onChange:j=>u({...i,0:j.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:j=>j.key==="Enter"&&v(0)}),e.jsx("button",{onClick:()=>v(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:N,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:r,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 S=n[y];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:W(t||"Questions")}),e.jsx("div",{className:"mb-3 flex gap-1 overflow-x-auto",children:n.map((x,d)=>e.jsx("button",{onClick:()=>p(d),className:ee("rounded-md px-3 py-1.5 text-xs font-display whitespace-nowrap transition-colors",y===d?"bg-brand/20 text-brand-text":"text-text-muted hover:bg-surface-2"),children:x.header||`Q${d+1}`},d))}),S&&e.jsx(Cr,{question:S,qIdx:y,answers:a,otherTexts:i,onSelect:g,onOtherTextChange:(x,d)=>u({...i,[x]:d}),onOtherSubmit:v}),e.jsxs("div",{className:"mt-4 flex items-center justify-between",children:[e.jsxs("span",{className:"text-xs font-display text-text-muted",children:[y+1," / ",n.length]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:N,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:r,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 Cr({question:n,qIdx:t,answers:s,otherTexts:r,onSelect:a,onOtherTextChange:m,onOtherSubmit:i}){const u=n.multiSelect||!1;return e.jsxs("div",{children:[e.jsx("div",{className:"mb-2 text-sm text-text-secondary",children:W(n.question)}),e.jsxs("div",{className:"space-y-2",children:[(n.options||[]).map((y,p)=>{const g=u?(s[t]||[]).includes(p):s[t]===p;return e.jsxs("button",{onClick:()=>a(t,p,u),className:ee("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:W(y.label)}),y.description&&e.jsx("div",{className:"mt-0.5 text-xs font-sans text-text-muted",children:W(y.description)})]},p)}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{type:"text",value:r[t]||"",onChange:y=>m(t,y.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:y=>y.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 Er({planContent:n,description:t,onSubmit:s}){const[r,a]=l.useState(null),[m,i]=l.useState(""),u=!n||!n.trim(),y=()=>{r&&s(r,r==="no"?m: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(Se,{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:Tr(n)}}),e.jsx("div",{className:"space-y-2",children:u?e.jsxs(e.Fragment,{children:[e.jsx(Ne,{selected:r==="yes-default",onClick:()=>a("yes-default"),label:"Yes"}),e.jsx(Ne,{selected:r==="no",onClick:()=>a("no"),label:"No"})]}):e.jsxs(e.Fragment,{children:[e.jsx(Ne,{selected:r==="yes-accept-edits",onClick:()=>a("yes-accept-edits"),label:"Yes, auto-accept edits",desc:"Approve plan and auto-accept file edits"}),e.jsx(Ne,{selected:r==="yes-default",onClick:()=>a("yes-default"),label:"Yes, manually approve edits",desc:"Approve plan but confirm each edit"}),e.jsx(Ne,{selected:r==="no",onClick:()=>a("no"),label:"No, keep planning",desc:"Provide feedback to refine the plan"})]})}),r==="no"&&e.jsx("textarea",{value:m,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:y,disabled:!r,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 Ne({selected:n,onClick:t,label:s,desc:r}){return e.jsxs("button",{onClick:t,className:ee("w-full rounded-lg border px-4 py-2.5 text-left text-sm font-display transition-colors",n?"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:ee("flex h-4 w-4 items-center justify-center rounded-full border text-[10px] transition-colors",n?"border-brand bg-brand text-white":"border-border"),children:n&&"✓"}),e.jsx("span",{className:"font-medium font-display",children:s})]}),r&&e.jsx("div",{className:"mt-0.5 pl-6 text-xs font-sans text-text-muted",children:r})]})}function Tr(n){let t=W(n);return t=t.replace(/```(\w*)\n?([\s\S]*?)```/g,(s,r,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 Mr({request:n,onSubmit:t}){J();const s=Rr(n.requestedSchema),r=Ar(n.requestedSchema),[a,m]=l.useState({}),i=s.length===0||r.every(u=>(a[u]??"").trim()!=="");return n.mode==="url"&&n.url?e.jsxs("div",{className:"rounded-xl border border-brand/30 bg-surface-1 p-4",children:[e.jsx(Qt,{serverName:n.serverName,message:n.message}),e.jsxs("a",{href:n.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:n.url}),e.jsx($n,{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(Qt,{serverName:n.serverName,message:n.message}),s.length>0&&e.jsx("div",{className:"mb-3 space-y-3",children:s.map(({name:u,prop:y})=>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}),r.includes(u)&&e.jsx("span",{className:"text-[10px] font-medium text-warning-text",children:c("elicitation.required")})]}),y.description&&e.jsx("div",{className:"mb-1 text-xs text-text-muted",children:W(y.description)}),e.jsx("input",{type:y.type==="number"?"number":"text",value:a[u]??"",onChange:p=>m(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:y,prop:p}of s){const g=(a[y]??"").trim();g&&(u[y]=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 Qt({serverName:n,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(Vn,{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:W(n)})]})]}),t&&e.jsx("div",{className:"text-sm text-text-secondary",children:W(t)})]})}function Rr(n){const t=n==null?void 0:n.properties;return!t||typeof t!="object"?[]:Object.entries(t).filter(([,s])=>s&&typeof s=="object").map(([s,r])=>({name:s,prop:r}))}function Ar(n){const t=n==null?void 0:n.required;return Array.isArray(t)?t.filter(s=>typeof s=="string"):[]}function $r(n){const[t,s]=l.useState([]),[r,a]=l.useState(!0),[m,i]=l.useState(null),u=l.useCallback(async()=>{a(!0),i(null);try{const g=await on(n);s(g)}catch(g){i(g instanceof Error?g.message:"Failed to load shares")}finally{a(!1)}},[n]);l.useEffect(()=>{u()},[u]);const y=l.useCallback(async g=>{i(null);try{const v=await ln(n,g);return await u(),v}catch(v){throw i(v instanceof Error?v.message:"Failed to create share"),v}},[n,u]),p=l.useCallback(async g=>{i(null);try{await cn(n,g),await u()}catch(v){throw i(v instanceof Error?v.message:"Failed to revoke share"),v}},[n,u]);return{shares:t,isLoading:r,error:m,createShare:y,revokeShare:p,refresh:u}}function Ir({open:n,onClose:t,sessionId:s,sessionTitle:r}){J();const{shares:a,isLoading:m,error:i,createShare:u,revokeShare:y}=$r(s),[p,g]=l.useState("user"),[v,N]=l.useState(""),[S,x]=l.useState(""),[d,j]=l.useState("read"),[h,b]=l.useState(""),[k,w]=l.useState(!1),[T,I]=l.useState(null),[D,L]=l.useState(""),[te,C]=l.useState(!1),[U,V]=l.useState(!1);l.useEffect(()=>{n&&(g("user"),N(""),x(""),j("read"),b(""),w(!1),I(null),L(""),C(!1),V(!1))},[n]);const Ce=async()=>{w(!0),L(""),I(null);try{const A={grantedTo:p==="user"?{userId:v.trim()}:{teamId:S.trim()},permission:d};h.trim()&&(A.expiresAt=h.trim());const fe=await u(A);I(`${window.location.origin}/code/s/${fe.shareToken}`)}catch(A){L(A instanceof Error?A.message:"Failed to create share")}finally{w(!1)}},Ee=async A=>{try{await y(A)}catch{}},Y=async()=>{if(!T)return;V(!1);try{if(navigator.clipboard&&window.isSecureContext){await navigator.clipboard.writeText(T),C(!0),setTimeout(()=>C(!1),2e3);return}}catch{}const A=document.createElement("textarea");A.value=T,A.style.position="fixed",A.style.opacity="0",document.body.appendChild(A),A.select();try{document.execCommand("copy"),C(!0),setTimeout(()=>C(!1),2e3)}catch{V(!0)}document.body.removeChild(A)};return e.jsx(de,{open:n,onOpenChange:A=>{A||t()},children:e.jsxs(ue,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(me,{children:e.jsxs(xe,{className:"font-display text-lg font-semibold text-text-primary",children:[c("share.title"),r?`: ${r}`:""]})}),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(Rn,{onSelect:N,placeholder:c("share.userIdPlaceholder"),actionLabel:c("share.selectUser")}):e.jsx("input",{type:"text",value:S,onChange:A=>x(A.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"&&v&&e.jsxs("p",{className:"mt-1 text-xs text-text-muted",children:[c("share.selectedUser"),": ",e.jsx("span",{className:"font-mono",children:v})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-1 block text-sm text-text-secondary",children:c("share.permission")}),e.jsxs("select",{value:d,onChange:A=>j(A.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:A=>b(A.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"})]}),(D||i)&&e.jsx("div",{className:"rounded-md bg-destructive/10 px-3 py-2 text-sm text-status-error",children:D||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:Y,className:"shrink-0 rounded-md bg-brand px-2 py-1 text-xs text-white hover:bg-brand-light transition-colors",children:te?c("share.copied"):c("share.copy")})]}),U&&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")}),m?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(A=>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:A.granted_to_user||A.granted_to_team||"Unknown"}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[A.permission==="write"?c("share.permissionWrite"):c("share.permissionRead"),A.expires_at?` · expires ${A.expires_at}`:""]})]}),e.jsx("button",{onClick:()=>Ee(A.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")})]},A.id))})]})]}),e.jsxs(Sn,{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:Ce,disabled:k||(p==="user"?!v.trim():!S.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:k?c("common.creating"):c("share.createShare")})]})]})})}function Dr(n){const t=new Date,s=new Date(t.getTime()-1440*60*1e3),r=(i,u)=>i.getFullYear()===u.getFullYear()&&i.getMonth()===u.getMonth()&&i.getDate()===u.getDate(),a={today:[],yesterday:[],earlier:[]};for(const i of n){const u=new Date(i.modified||0);r(u,t)?a.today.push(i):r(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 qr(n){return n?new Date(n).toLocaleString():""}function Pr({open:n,onClose:t,adapter:s,onResume:r}){const a=J(),[m,i]=l.useState([]),[u,y]=l.useState(!1),[p,g]=l.useState("");l.useEffect(()=>{if(!n)return;let N=!1;return y(!0),g(""),i([]),s.listResumableSessions().then(S=>{N||i(S)}).catch(S=>{N||g(S instanceof Error?S.message:String(S))}).finally(()=>{N||y(!1)}),()=>{N=!0}},[n,s]);const v=l.useMemo(()=>Dr(m),[m,a]);return e.jsx(de,{open:n,onOpenChange:N=>{N||t()},children:e.jsxs(ue,{className:"max-w-lg rounded-2xl border-border bg-surface-1 p-6 shadow-2xl",children:[e.jsx(me,{children:e.jsx(xe,{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&&m.length===0&&e.jsx("p",{className:"py-6 text-center text-sm text-text-muted",children:c("resume.empty")}),!u&&!p&&v.map(N=>e.jsxs("div",{children:[e.jsx("p",{className:"mb-1 text-xs font-medium text-text-muted",children:N.label}),e.jsx("div",{className:"space-y-1",children:N.items.map(S=>e.jsxs("button",{type:"button",onClick:()=>r(S),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:S.title}),e.jsxs("p",{className:"truncate text-xs text-text-muted",children:[qr(S.modified),S.gitBranch?` · ${S.gitBranch}`:""]})]},S.sessionId))})]},N.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 Or{constructor(t,s,r,a){M(this,"pending",null);this.current=t,this.apply=s,this.send=r,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(r=>{this.pending&&(this.pending.requestId=r)}).catch(r=>{this.rollback(s,Vt(r),"send")})}catch(r){this.rollback(s,Vt(r),"send")}}handleControlResponse(t){const s=this.pending;if(!s||s.requestId!==t.requestId)return!1;const{previous:r}=s;return this.pending=null,t.subtype==="error"&&this.rollback(r,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,r){var a;this.pending=null,this.current=t,this.apply(t),s&&((a=this.onError)==null||a.call(this,s,r))}}function Vt(n){return n instanceof Error?n.message:String(n)}function ot(n){const t=l.useRef(n);t.current=n;const s=l.useRef(null);s.current||(s.current=new Or(n.value,a=>t.current.apply(a),a=>t.current.send(a),(a,m)=>{var i,u;return(u=(i=t.current).onError)==null?void 0:u.call(i,a,m)}));const r=s.current;return l.useEffect(()=>{r.adoptExternal(n.value)}),l.useMemo(()=>({set:a=>r.set(a),handleControlResponse:a=>r.handleControlResponse(a),sync:a=>r.sync(a)}),[r])}const cs="rcs_context_usage_";function ds(){try{if(typeof localStorage<"u")return localStorage}catch{}return null}function zt(){return{totalTokens:0,rawMaxTokens:0,percentage:0}}function Ur(n){if(!n||typeof n!="object"||Array.isArray(n))return null;const t=n,{totalTokens:s,rawMaxTokens:r,percentage:a}=t;if(typeof s!="number"||typeof r!="number"||typeof a!="number")return null;const m=t.categories,i=Array.isArray(m)?m.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:r,percentage:a,...typeof t.model=="string"&&t.model?{model:t.model}:{},...i&&i.length>0?{categories:i}:{}}}function Fr(n,t=ds()){if(!t||!n)return null;try{const s=t.getItem(cs+n);return s?Ur(JSON.parse(s)):null}catch{return null}}function Kr(n,t,s=ds()){if(!(!s||!n))try{s.setItem(cs+n,JSON.stringify(t))}catch{}}function Lr(n){return`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/acp/relay/${n}`}function Br(n){const t=Lr(n),s=un(),r=s?{proxyUrl:t,token:s}:{proxyUrl:t};return new dn(r)}const le=[{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"}],Gt="rcs_permission_mode";function ce(n){return n<1e3?String(n):n<1e6?`${(n/1e3).toFixed(1)}k`:`${(n/1e6).toFixed(1)}M`}function Hr(n){const t=le.findIndex(s=>s.value===n);return le[(t+1+le.length)%le.length].value}const lt=[{value:"off",labelKey:"session.thinking.off",descKey:"session.thinking.offDesc",label:void 0,description:void 0,tokens:null},{value:"on",labelKey:"session.thinking.on",descKey:"session.thinking.onDesc",label:void 0,description:void 0,tokens:0},{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}],Yt="rcs_thinking_budget",ct=[{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"}],Jt=n=>n.labelKey?c(n.labelKey):n.label,Xt=n=>n.labelKey?c(n.labelKey):n.label,Zt="rcs_effort";function Wr(n){return n!=null&&n.capabilities?n.capabilities:n?{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,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,side_question:!1}}function Qr({budget:n,onBudgetChange:t,disabled:s}){const[r,a]=l.useState(!1),m=lt.find(i=>i.value===n);return e.jsxs(Fe,{open:r,onOpenChange:a,children:[e.jsx(Ke,{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(_n,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:m?Xt(m):c("session.thinking.fallback")}),r?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-64 p-1",align:"start",children:lt.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:n===i.value&&e.jsx(Se,{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:Xt(i)}),e.jsx("div",{className:"text-xs text-text-muted",children:i.descKey?c(i.descKey):i.description})]})]},i.value))})]})}function Vr({effort:n,onEffortChange:t,disabled:s}){const[r,a]=l.useState(!1),m=ct.find(i=>i.value===n);return e.jsxs(Fe,{open:r,onOpenChange:a,children:[e.jsx(Ke,{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(Fn,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:m?Jt(m):c("session.effort.fallback")}),r?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-64 p-1",align:"start",children:ct.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:n===i.value&&e.jsx(Se,{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:Jt(i)}),e.jsx("div",{className:"text-xs text-text-muted",children:c(i.descKey)})]})]},i.value))})]})}const zr=new Set(["Free space","Autocompact buffer","Compact buffer"]),es=["bg-brand","bg-status-active","bg-status-success","bg-violet-500","bg-amber-500","bg-pink-500","bg-teal-500"];function Gr({usage:n}){const t=Math.min(100,Math.max(0,n.percentage)),s=t>=80,r=(n.categories??[]).filter(u=>!u.isDeferred&&!zr.has(u.name)),a=(n.categories??[]).filter(u=>u.isDeferred),m=r.reduce((u,y)=>u+y.tokens,0),i=[`${O("session.context.tooltip",{used:ce(n.totalTokens),max:ce(n.rawMaxTokens)})}${n.model?` · ${n.model}`:""}`,...r.slice(0,8).map(u=>`${u.name}: ${ce(u.tokens)}`),...a.slice(0,3).map(u=>`${u.name}${c("session.context.deferredSuffix")}: ${ce(u.tokens)}`)];return e.jsxs("span",{className:"flex items-center gap-1.5 text-[11px] text-text-muted font-mono",title:i.join(`
72
+ `),children:[e.jsx("span",{className:"relative flex h-1.5 w-16 overflow-hidden rounded-full bg-surface-3",children:r.length>0?r.map((u,y)=>e.jsx("span",{className:s&&y===0?"bg-status-warning":es[y%es.length],style:{width:`${Math.min(100,Math.max(0,m>0?u.tokens/m*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 Yr({models:n,currentModelId:t,onSelect:s,disabled:r}){const[a,m]=l.useState(!1),i=n.find(p=>p.modelId===t)??null,u=n.length>0,y=async p=>{s(p.modelId),m(!1)};return e.jsxs(Fe,{open:a,onOpenChange:u?m:void 0,children:[e.jsx(Ke,{asChild:!0,children:e.jsxs("button",{type:"button",disabled:r||!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(rs,{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(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-72 p-0",align:"start",children:e.jsx(Nn,{models:n,currentModelId:t,onSelect:y,showSearch:n.length>5})})]})}function Jr({mode:n,onModeChange:t,disabled:s}){const[r,a]=l.useState(!1),m=le.find(i=>i.value===n);return e.jsxs(Fe,{open:r,onOpenChange:a,children:[e.jsx(Ke,{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(kn,{className:"h-3 w-3"}),e.jsx("span",{className:"max-w-24 truncate",children:m?c(m.labelKey):n}),r?e.jsx(Le,{className:"h-3 w-3"}):e.jsx(Be,{className:"h-3 w-3"})]})}),e.jsx(He,{className:"w-64 p-1",align:"start",children:le.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:n===i.value&&e.jsx(Se,{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 xa({sessionId:n,onBack:t}){var Et;J();const[s,r]=l.useState(null),[a,m]=l.useState(null),[i,u]=l.useState(""),[y,p]=l.useState(!1),[g,v]=l.useState(!1),[N,S]=l.useState(!1),[x,d]=l.useState(!1),[j,h]=l.useState(!1),[b,k]=l.useState(!1),[w,T]=l.useState(""),[I,D]=l.useState(0),L=l.useRef(null),[te,C]=l.useState({text:"",nonce:0}),[U,V]=l.useState(!1),[Ce,Ee]=l.useState(!1),[Y,A]=l.useState(!1),[fe,dt]=l.useState(0),[us,ms]=l.useState(0),[pe,X]=l.useState([]),[G,he]=l.useState(!1),[ge,re]=l.useState([]),[B,We]=l.useState(null),[xs,fs]=l.useState(()=>ls()),[H,ps]=l.useState(null),[ut,hs]=l.useState(()=>localStorage.getItem(Yt)||"off"),[gs,mt]=l.useState(()=>Fr(n)),[Qe,Ve]=l.useState(!0),[ye,ys]=l.useState(null),[Te,xt]=l.useState(null),[Me,Re]=l.useState([]),[bs,ze]=l.useState(!1),[Ge,ft]=l.useState(""),Ye=l.useRef(null),[Ae,js]=l.useState(()=>localStorage.getItem(Gt)||"default"),[pt,ht]=l.useState(null),be=l.useRef(null),[gt,yt]=l.useState(null),je=l.useRef(null),ae=l.useRef(null),bt=l.useRef(pe);bt.current=pe;const $e=l.useRef(null);$e.current||($e.current=new Dn(qn()));const jt=l.useRef(n);jt.current=(s==null?void 0:s.title)||n,l.useEffect(()=>{var o;(o=$e.current)==null||o.reset()},[n]);const se=l.useCallback(o=>{ht(o),be.current&&clearTimeout(be.current),be.current=setTimeout(()=>ht(null),5e3)},[]),Z=l.useCallback(o=>{yt(o),je.current&&clearTimeout(je.current),je.current=setTimeout(()=>yt(null),5e3)},[]),Ie=ot({value:Ae,apply:o=>{js(o);try{localStorage.setItem(Gt,o)}catch{}},send:o=>{const f=ae.current;return f?f.setPermissionMode(o):Promise.reject(new Error("adapter not ready"))},onError:(o,f)=>{console.error("[SessionDetail] set permission mode failed:",o),se(f==="send"?O("session.mode.switchFailedRequest",{message:o}):o||c("session.mode.switchFailed"))}}),Je=l.useCallback(o=>Ie.set(o),[Ie]),Xe=ot({value:ut,apply:o=>{hs(o);try{localStorage.setItem(Yt,o)}catch{}},send:o=>{var E;const f=ae.current;if(!f)return Promise.reject(new Error("adapter not ready"));const _=((E=lt.find(R=>R.value===o))==null?void 0:E.tokens)??null;return f.setThinkingBudget(_)},onError:(o,f)=>{console.error("[SessionDetail] set thinking budget failed:",o),se(f==="send"?O("session.thinking.failedRequest",{message:o}):o||c("session.thinking.failed"))}}),$=l.useMemo(()=>new cr(n,X,{onStatusChange:o=>{var f;m(o),he(o==="running"||o==="requires_action"),(f=$e.current)==null||f.onStatus(o,jt.current)},onError:o=>{console.error("[RCSChatAdapter] error:",o)},onPermissionRequest:o=>{re(f=>f.some(_=>_.requestId===o.requestId)?f:[...f,o])},onModelsStateChange:o=>{We(o)},onSubagentUpdate:o=>{fs(o)},onControlResponse:o=>{Xe.handleControlResponse(o)||Ie.handleControlResponse(o)},onPermissionModeChange:o=>{Ie.sync(o)},onUsageChange:o=>{ys(f=>({inputTokens:Math.max((f==null?void 0:f.inputTokens)??0,o.inputTokens),outputTokens:Math.max((f==null?void 0:f.outputTokens)??0,o.outputTokens),totalCostUsd:o.totalCostUsd??(f==null?void 0:f.totalCostUsd)??null}))},onWorkerInfoChange:o=>{ps(f=>JSON.stringify(f)===JSON.stringify(o)?f:o)},onElicitationRequest:o=>{xt(o)}}),[n,se]);l.useEffect(()=>(ae.current=$,()=>{$.disconnect()}),[$]);const P=l.useMemo(()=>Wr(H),[H]),ws=J(),Ze=l.useMemo(()=>mn((H==null?void 0:H.commands)??[],(H==null?void 0:H.skills)??[]),[H,ws]),we=l.useMemo(()=>xn(pe,w),[pe,w]),vs=l.useCallback(o=>Xe.set(o),[Xe]),[wt,ks]=l.useState(()=>localStorage.getItem(Zt)||"auto"),Ns=ot({value:wt,apply:o=>{ks(o);try{localStorage.setItem(Zt,o)}catch{}},send:o=>{var E;const f=ae.current;if(!f)return Promise.reject(new Error("adapter not ready"));const _=(E=ct.find(R=>R.value===o))==null?void 0:E.effort;return f.setEffort(_)},onError:(o,f)=>{console.error("[SessionDetail] set effort failed:",o),se(f==="send"?O("session.effort.failedRequest",{message:o}):o||c("session.effort.failed"))}}),et=l.useCallback(()=>{var o;P.get_context_usage&&((o=ae.current)==null||o.getContextUsage().then(f=>{f&&(mt(f),Kr(n,f))}).catch(()=>{}).finally(()=>Ve(!1)))},[P,n]);l.useEffect(()=>{if(!P.get_context_usage)return;G||et();const o=setInterval(et,6e4);return()=>clearInterval(o)},[P,G,et]),l.useEffect(()=>{H&&!P.get_context_usage&&Ve(!1)},[H,P]),l.useEffect(()=>{if(!Qe)return;const o=setTimeout(()=>Ve(!1),1e4);return()=>clearTimeout(o)},[Qe]);const vt=l.useRef(Y);vt.current=Y,l.useEffect(()=>ie.onEvent(f=>{f.type!=="artifact_created"&&f.type!=="artifact_updated"||(vt.current&&ms(_=>_+1),dt(_=>_+1))}),[]);const[ve,_s]=l.useState("idle");l.useEffect(()=>ie.onStateChange(f=>_s(f)),[]),l.useEffect(()=>{Y&&dt(0)},[Y]),l.useEffect(()=>{let o=!1;async function f(){u("");try{const _=await Dt(n);if(o)return;r(_),m(_.status),Oe(_.status)&&$.markClosed(),he(_.status==="running"||_.status==="requires_action")}catch(_){if(o)return;u(_ instanceof Error?_.message:c("session.loadFailed"));return}try{await $.init()}catch(_){console.warn("Failed to init adapter:",_)}}return f(),()=>{o=!0}},[n,$]);const q=Oe(a),kt=l.useRef(a);kt.current=a,l.useEffect(()=>{if(q)return;let o=!1;const _=setInterval(async()=>{try{const E=await Dt(n);if(o||E.status===kt.current)return;Oe(E.status)&&$.markClosed(),m(E.status),he(E.status==="running"||E.status==="requires_action")}catch{}},6e4);return()=>{o=!0,clearInterval(_)}},[n,q,$]);const F=(s==null?void 0:s.access_level)==="read",Nt=gs??(Qe&&!q&&!F?zt():null),tt=l.useCallback(()=>{X([]),mt(zt()),$t(n).catch(o=>{console.warn("[SessionDetail] Failed to clear session history:",o)})},[n]),ke=l.useCallback(async(o,f)=>{const _=ae.current;if(!_||q)return;if(o.sessionId===n){X(R=>[...R,{type:"command_output",id:`cmd-resume-${Date.now()}`,commandName:"resume",inputText:f??"/resume",title:"Resume",subtitle:c("session.resume.title"),outputText:c("session.resume.currentBlocked"),variant:"error"}]);return}const E=(R,K="default")=>X(ne=>[...ne,{type:"command_output",id:`cmd-resume-${Date.now()}-${Math.random().toString(36).slice(2,6)}`,commandName:"resume",inputText:f??`/resume ${o.sessionId.slice(0,8)}`,title:"Resume",subtitle:c("session.resume.title"),outputText:R,variant:K}]);E(O("session.resume.restoring",{title:o.title??""}));try{await $t(n),X([]);const R=await _.resumeSession(o.sessionId);E(R.title?O("session.resume.restoredWithTitle",{count:R.messageCount,title:R.title}):O("session.resume.restored",{count:R.messageCount}))}catch(R){E(O("session.resume.failed",{message:R instanceof Error?R.message:String(R)}),"error")}},[q,n]),Ss=l.useCallback(async()=>{if(s!=null&&s.environment_id)try{const o=await fn({environment_id:s.environment_id});window.location.href=`/code/${o.id}?resumeFrom=${n}`}catch(o){Z(O("session.createFailedWithReason",{message:o instanceof Error?o.message:String(o)}))}},[s,n,Z]),Cs=l.useRef(new URLSearchParams(window.location.search).get("resumeFrom")),_t=l.useRef(!1);l.useEffect(()=>{const o=Cs.current;!o||_t.current||!H||!P.resume||(_t.current=!0,window.history.replaceState({},"",window.location.pathname),ke({sessionId:o,title:o.slice(0,8),modified:0},null))},[H,P.resume,ke]);const De=l.useCallback(async o=>{const f=o.text.trim(),_=o.images&&o.images.length>0||o.attachments&&o.attachments.length>0;if(!f&&!_||q)return;const E=/^\/resume(?:\s+(.*))?$/.exec(f);if(E){const K=(E[1]??"").trim();if(!P.resume){X(ne=>[...ne,{type:"user_message",id:`user-${Date.now()}`,content:f},{type:"command_output",id:`cmd-${Date.now()}`,commandName:"resume",inputText:f,title:"Resume",subtitle:c("session.resume.title"),outputText:c("session.resume.unsupported"),variant:"error"}]);return}K?await ke({sessionId:K,title:K,modified:0},f):h(!0);return}const R=await pn(f,{sessionId:n,availableCommands:Ze,availableModels:(B==null?void 0:B.availableModels)??[],currentModel:B?{modelId:B.currentModelId,name:B.currentModelId}:null,supportsImages:!0,entries:bt.current,setModel:async K=>{await z(n,{type:"control_request",request:{subtype:"set_model",model:K}}),We(ne=>ne&&{...ne,currentModelId:K})},onNewSession:()=>{X([])}}).catch(()=>null);if(R){if(Ue("[SessionDetail] local command result",R),"clearEntries"in R&&R.clearEntries){tt();return}if("newSession"in R&&R.newSession){tt();return}if("userEntry"in R){X(K=>[...K,R.userEntry,R.cmdEntry]);return}}he(!0);try{await $.sendMessage(f,o.images,o.attachments)}catch(K){if(console.error("Send failed:",K),K instanceof hn&&K.type==="session_closed"){m("archived"),$.markClosed(),Z(c("session.closedSendBlocked"));return}Z(`${c("session.sendFailed")}${K instanceof Error?`: ${K.message}`:""}`)}},[$,q,n,B,Ze,tt,Z,ke,P]),Es=l.useCallback(o=>{if(G){Re(f=>[...f,o]);return}De(o)},[G,De]),st=l.useRef(!1);l.useEffect(()=>{if(q){Re(f=>f.length>0?[]:f);return}if(G||Me.length===0||st.current)return;const o=Me[0];o&&(st.current=!0,Re(f=>f.slice(1)),De(o).finally(()=>{st.current=!1}))},[G,Me,De,q]);const Ts=l.useCallback((o,f)=>{if(G)return;const _=f==="edit"?c("session.rewind.confirmEdit"):c("session.rewind.confirm");window.confirm(`${_}
73
+ ${c("session.rewind.confirmBody")}`)&&$.rewindToMessage(o.id).then(()=>{f==="edit"&&o.content&&C(E=>({text:o.content,nonce:E.nonce+1}))}).catch(E=>{console.error("[SessionDetail] rewind failed:",E),Z(O("session.rewind.failed",{message:E instanceof Error?E.message:String(E)}))})},[G,Z]),Ms=l.useCallback(o=>{const f=we.orderedMatchIds;if(f.length===0)return;const _=(o%f.length+f.length)%f.length;D(_);const E=f[_],R=document.querySelector(`[data-entry-id="${CSS.escape(E)}"]`);R==null||R.scrollIntoView({block:"center",behavior:"smooth"})},[we]),St=l.useCallback(async()=>{try{await $.interrupt()}catch(o){console.error("Interrupt failed:",o)}finally{he(!1)}},[$]),Rs=l.useCallback(()=>{Je(Hr(Ae))},[Je,Ae]);l.useEffect(()=>()=>{be.current&&clearTimeout(be.current),je.current&&clearTimeout(je.current)},[]);const As=l.useCallback(async()=>{if(s&&window.confirm(c("dashboard.confirmDelete").replace("{id}",s.title||s.id)))try{await It(s.id),window.location.href="/code/"}catch(o){alert(o instanceof Error?o.message:c("dashboard.deleteFailed"))}},[s]),$s=l.useCallback(async o=>{try{await $.respondPermission(o,!0)}catch(f){console.error("Failed to approve:",f)}re(f=>f.filter(_=>_.requestId!==o))},[$]),Is=l.useCallback(async(o,f)=>{try{await $.respondPermission(o,!0,{updated_permissions:f})}catch(_){console.error("Failed to approve with rules:",_)}re(_=>_.filter(E=>E.requestId!==o))},[$]),Ds=l.useCallback(async(o,f)=>{const _=Te;if(xt(null),!!_)try{await $.respondElicitation(_.requestId,o,f)}catch(E){console.error("Failed to submit elicitation:",E)}},[Te,$]),qs=l.useCallback(()=>{!s||F||(ft(s.title||""),ze(!0),setTimeout(()=>{var o,f;(o=Ye.current)==null||o.focus(),(f=Ye.current)==null||f.select()},0))},[s,F]),Ct=l.useCallback(async()=>{const o=Ge.trim();if(ze(!1),!(!s||!o||o===s.title))try{const f=await gn(s.id,o);r(_=>_&&{..._,title:f.title??o})}catch(f){console.error("Rename failed:",f),alert(f instanceof Error?f.message:c("session.rename.failed"))}},[s,Ge]),Ps=l.useCallback(async o=>{try{await $.respondPermission(o,!1)}catch(f){console.error("Failed to reject:",f)}re(f=>f.filter(_=>_.requestId!==o))},[$]),Os=l.useCallback(async(o,f,_)=>{try{await z(n,{type:"permission_response",approved:!0,request_id:o,updated_input:{questions:_,answers:f}})}catch(E){console.error("Failed to submit answers:",E)}re(E=>E.filter(R=>R.requestId!==o))},[n]),Us=l.useCallback(async(o,f,_)=>{try{f==="no"?await z(n,{type:"permission_response",approved:!1,request_id:o,..._?{message:_}:{}}):await z(n,{type:"permission_response",approved:!0,request_id:o,updated_permissions:[{type:"setMode",mode:{"yes-accept-edits":"acceptEdits","yes-default":"default"}[f]||"default",destination:"session"}]})}catch(E){console.error("Failed to submit plan response:",E)}re(E=>E.filter(R=>R.requestId!==o))},[n]);return i?e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(Pe,{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(Pe,{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(Zr,{sessionId:n,agentId:s.environment_id})]}):e.jsx(ss,{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(Pe,{onBack:t,title:bs?e.jsx("input",{ref:Ye,value:Ge,onChange:o=>ft(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),Ct()):o.key==="Escape"&&(o.preventDefault(),ze(!1))},onBlur:()=>void Ct(),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:!F&&!q?e.jsx("button",{type:"button",onClick:qs,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(En,{visibility:s.visibility||"private",className:"hidden flex-shrink-0 text-[10px] sm:inline-flex"})]}),meta:e.jsx(e.Fragment,{children:(()=>{var _;const o=s.source==="acp"?"acp":(_=s.environment)==null?void 0:_.worker_type,f=qt(o);return e.jsx("span",{className:`hidden items-center rounded-full px-2 py-0.5 text-[10px] font-medium sm:inline-flex ${f.colorClass}`,children:f.fullLabel})})()}),actions:e.jsx(e.Fragment,{children:e.jsxs("div",{className:"flex items-center gap-0.5",children:[e.jsxs("button",{onClick:()=>A(!Y),className:`relative flex h-7 w-7 items-center justify-center rounded-md transition-colors ${Y?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:c("artifacts.title"),children:[e.jsx(yn,{className:"h-3.5 w-3.5"}),fe>0&&!Y&&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-[9px] font-bold text-white",children:fe>9?"9+":fe})]}),P.side_question&&!q&&!F&&e.jsx("button",{onClick:()=>d(!x),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${x?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:c("session.sideQuestion.title"),children:e.jsx(as,{className:"h-3.5 w-3.5"})}),e.jsx("button",{onClick:()=>{const o=!b;k(o),o?setTimeout(()=>{var f;return(f=L.current)==null?void 0:f.focus()},0):(T(""),D(0))},className:`flex h-7 w-7 items-center justify-center rounded-md transition-colors ${b?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:c("session.search.title"),children:e.jsx(it,{className:"h-3.5 w-3.5"})}),P.mcp_management&&!q&&!F&&e.jsx("button",{onClick:()=>v(!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(os,{className:"h-3.5 w-3.5"})}),P.remote_settings&&!q&&!F&&e.jsx("button",{onClick:()=>S(!N),className:`hidden h-7 w-7 items-center justify-center rounded-md transition-colors sm:flex ${N?"bg-brand-light text-white":"text-text-muted hover:bg-surface-2 hover:text-text-secondary"}`,title:c("session.settings.title"),children:e.jsx(is,{className:"h-3.5 w-3.5"})}),!F&&(s==null?void 0:s.access_level)!=="write"&&e.jsx("button",{onClick:()=>Ee(!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:()=>V(!U),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(Hn,{className:"h-3.5 w-3.5"})}),e.jsxs("button",{onClick:()=>p(!y),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"),ge.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:ge.length})]})]})})}),U&&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":(Et=s.environment)==null?void 0:Et.worker_type).fullLabel]}),e.jsxs("div",{children:[e.jsx("span",{className:"text-text-primary font-bold font-sans",children:c("session.metaCreated")})," ",ts(s.created_at)]})]})})}),(ve==="reconnecting"||ve==="failed")&&e.jsxs("div",{className:`flex items-center justify-center gap-2 px-4 py-1.5 text-xs font-medium ${ve==="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 ${ve==="failed"?"bg-status-error":"animate-pulse bg-status-warning"}`}),ve==="failed"?c("session.sseFailed"):c("session.sseReconnecting")]}),Y&&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(In,{sessionId:n,embedded:!0,refreshTick:us})})}),b&&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(it,{className:"h-3.5 w-3.5 flex-shrink-0 text-text-muted"}),e.jsx("input",{ref:L,value:w,onChange:o=>{T(o.target.value),D(0)},onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing?(o.preventDefault(),Ms(w&&o.shiftKey?I-1:I+1)):o.key==="Escape"&&(o.preventDefault(),k(!1),T(""))},placeholder:c("session.search.placeholder"),className:"w-full bg-transparent text-sm text-text-primary placeholder:text-text-muted focus:outline-none"}),w.trim()&&e.jsx("span",{className:"flex-shrink-0 font-mono text-[11px] text-text-muted",children:we.orderedMatchIds.length===0?c("session.search.noResults"):`${I+1}/${we.orderedMatchIds.length}`})]})}),e.jsx(bn,{entries:pe,isLoading:G,emptyTitle:c("session.emptyTitle"),emptyDescription:c("session.emptyDescription"),searchMatchIds:w.trim()?we.matchIds:void 0,onRewindEntry:P.rewind&&!q&&!F&&!G?(o,f)=>Ts(o,f):void 0}),e.jsx(Nr,{state:xs,onStopTask:P.stop_task?o=>{$.stopSubagent(o).then(f=>{f.ok||Z(f.error||c("session.stopTask.failed"))})}:void 0}),ge.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:ge.map(o=>e.jsx(Xr,{request:o,onApprove:()=>$s(o.requestId),onApproveAlways:o.suggestions&&o.suggestions.length>0?()=>Is(o.requestId,o.suggestions??[]):void 0,onReject:()=>Ps(o.requestId),onSubmitAnswers:Os,onSubmitPlan:Us},o.requestId))})}),Te&&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(Mr,{request:Te,onSubmit:Ds})})}),gt&&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:gt})}),pt&&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:pt})}),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(Jr,{mode:Ae,onModeChange:Je,disabled:q||F}),e.jsx(Yr,{models:(B==null?void 0:B.availableModels)??[],currentModelId:(B==null?void 0:B.currentModelId)??null,onSelect:o=>{z(n,{type:"control_request",request:{subtype:"set_model",model:o}}),We(f=>f&&{...f,currentModelId:o})},disabled:q||F}),P.set_max_thinking_tokens&&e.jsx(Qr,{budget:ut,onBudgetChange:vs,disabled:q||F}),P.set_effort&&e.jsx(Vr,{effort:wt,onEffortChange:o=>Ns.set(o),disabled:q||F})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[Nt&&e.jsx(Gr,{usage:Nt}),ye&&e.jsxs("span",{className:"text-[11px] text-text-muted font-mono",title:c("session.usage.total"),children:[ce(ye.inputTokens)," in / ",ce(ye.outputTokens)," out",ye.totalCostUsd!=null&&` · $${ye.totalCostUsd.toFixed(2)}`]})]})]}),q&&(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 Ss(),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(jn,{onSubmit:Es,isLoading:G,onInterrupt:St,onCycleMode:Rs,disabled:q||F,placeholder:q?c("session.closed"):F?c("session.readOnly"):c("session.inputPlaceholder"),supportsAttachments:!0,commands:Ze,queueWhileLoading:!0,queuedCount:Me.length,onDequeue:o=>Re(f=>f.filter((_,E)=>E!==o)),onSearchFiles:P.file_search?o=>$.searchFiles(o):void 0,historyKey:n,draftOverride:te}),g&&e.jsx(hr,{onClose:()=>v(!1),fetchServers:()=>$.getMcpServers(),onToggle:(o,f)=>$.toggleMcpServer(o,f),onReconnect:o=>$.reconnectMcpServer(o)}),N&&e.jsx(yr,{onClose:()=>S(!1),fetchSettings:()=>$.getRemoteSettings(),onApply:o=>$.applyFlagSettings(o)}),x&&e.jsx(br,{onClose:()=>d(!1),onAsk:o=>$.askSideQuestion(o)}),y&&s&&e.jsx(xr,{onClose:()=>p(!1),session:s,liveStatus:a,pendingPermissions:ge,onInterrupt:St,onDelete:As,onEndSession:P.end_session&&!q&&!F?async()=>{await $.endSession("ended from web"),await It(s.id),window.location.href="/code/"}:void 0}),e.jsx(Ir,{open:Ce,onClose:()=>Ee(!1),sessionId:s.id,sessionTitle:s.title||void 0}),e.jsx(Pr,{open:j,onClose:()=>h(!1),adapter:$,onResume:o=>{h(!1),ke(o,null)}})]})}):e.jsxs("div",{className:"flex flex-1 flex-col overflow-hidden",children:[e.jsx(Pe,{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 Xr({request:n,onApprove:t,onApproveAlways:s,onReject:r,onSubmitAnswers:a,onSubmitPlan:m}){const i=n.toolName,u=n.toolInput,y=n.description||"";if(i==="AskUserQuestion"){const p=u.questions||[];return e.jsx(Sr,{requestId:n.requestId,questions:p,description:y,onSubmit:g=>a(n.requestId,g,p),onSkip:r})}if(i==="ExitPlanMode"){const p=u.plan||"";return e.jsx(Er,{requestId:n.requestId,planContent:p,description:y,onSubmit:(g,v)=>m(n.requestId,g,v)})}return e.jsx(_r,{requestId:n.requestId,toolName:i,toolInput:u,description:y,suggestions:n.suggestions,onApprove:t,onApproveAlways:s,onReject:r})}function Zr({sessionId:n,agentId:t}){const[s,r]=l.useState(null),[a,m]=l.useState("disconnected"),[i,u]=l.useState(null),y=l.useRef(null);return l.useEffect(()=>{const p=Br(t);return p.setConnectionStateHandler((g,v)=>{m(g),u(v||null)}),y.current=p,r(p),p.connect().catch(g=>{g instanceof wn||(u(g.message),m("error"))}),()=>{p.disconnect(),y.current=null,r(null),m("disconnected")}},[t]),e.jsx(ss,{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(vn,{client:s,agentId:t})})]})})}export{xa as SessionDetail};
@@ -0,0 +1,16 @@
1
+ import{ap as e,V as r,an as i}from"./main-bwawHmb2.js";import{j as c}from"./vendor-DE_-CLIE.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 d=[["path",{d:"M22 12h-2.48a2 2 0 0 0-1.93 1.46l-2.35 8.36a.25.25 0 0 1-.48 0L9.24 2.18a.25.25 0 0 0-.48 0l-2.35 8.36A2 2 0 0 1 4.49 12H2",key:"169zse"}]],u=e("activity",d);/**
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 p=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M12 2a14.5 14.5 0 0 0 0 20 14.5 14.5 0 0 0 0-20",key:"13o1zl"}],["path",{d:"M2 12h20",key:"9i4pu4"}]],x=e("globe",p);/**
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 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=e("lock",b);function k({visibility:t,className:o}){const a={private:{label:"Private",Icon:m,colorClass:"text-text-muted border-border/60"},team:{label:"Team",Icon:r,colorClass:"text-accent border-accent/40"},public:{label:"Public",Icon:x,colorClass:"text-accent border-accent/40"}},{label:s,Icon:l,colorClass:n}=a[t];return c.jsxs("span",{className:i("inline-flex items-center gap-1 rounded-full border px-2 py-0.5 text-xs",n,o),children:[c.jsx(l,{className:"h-3 w-3"}),s]})}export{u as A,k as S};
@@ -1 +1 @@
1
- import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aH as v,E as N,aA as t}from"./main-Dh-rPGBg.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function q({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(""),[m,c]=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}c(!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{c(!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 text-brand"}),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:m,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:m?t("common.loading"):t("auth.setup.submit")})]})]})})}export{q as Setup};
1
+ import{e as r,j as e}from"./vendor-DE_-CLIE.js";import{aL as v,G as N,aE as t}from"./main-bwawHmb2.js";import"./preload-helper-BiaRt2Oj.js";import"./motion-BILbV7YQ.js";function q({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(""),[m,c]=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}c(!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{c(!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 text-brand"}),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:m,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:m?t("common.loading"):t("auth.setup.submit")})]})]})})}export{q as Setup};
@@ -1 +1 @@
1
- import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{aa as m,b as h}from"./main-Dh-rPGBg.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
+ import{e as d,j as e}from"./vendor-DE_-CLIE.js";import{ae as m,b as h}from"./main-bwawHmb2.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};