agent-tower 0.7.2-beta.1 → 0.7.2-beta.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (224) hide show
  1. package/dist/executors/base.executor.d.ts.map +1 -1
  2. package/dist/executors/base.executor.js +6 -3
  3. package/dist/executors/base.executor.js.map +1 -1
  4. package/dist/routes/__tests__/workspaces.test.js +80 -0
  5. package/dist/routes/__tests__/workspaces.test.js.map +1 -1
  6. package/dist/routes/workspaces.js +1 -1
  7. package/dist/routes/workspaces.js.map +1 -1
  8. package/dist/runtime/__tests__/cli-driver-lifecycle.test.js +49 -8
  9. package/dist/runtime/__tests__/cli-driver-lifecycle.test.js.map +1 -1
  10. package/dist/runtime/__tests__/runtime-coordinator.test.js +13 -0
  11. package/dist/runtime/__tests__/runtime-coordinator.test.js.map +1 -1
  12. package/dist/runtime/cli-driver.js +32 -12
  13. package/dist/runtime/cli-driver.js.map +1 -1
  14. package/dist/runtime/contracts.d.ts +9 -2
  15. package/dist/runtime/contracts.d.ts.map +1 -1
  16. package/dist/runtime/runtime-coordinator.d.ts +2 -0
  17. package/dist/runtime/runtime-coordinator.d.ts.map +1 -1
  18. package/dist/runtime/runtime-coordinator.js +10 -0
  19. package/dist/runtime/runtime-coordinator.js.map +1 -1
  20. package/dist/services/__tests__/session-manager.lifecycle.test.js +136 -0
  21. package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
  22. package/dist/services/__tests__/session-manager.team-run.test.js +44 -47
  23. package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
  24. package/dist/services/__tests__/team-reconciler.service.test.js +30 -0
  25. package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
  26. package/dist/services/__tests__/terminal-manager.test.js +70 -0
  27. package/dist/services/__tests__/terminal-manager.test.js.map +1 -1
  28. package/dist/services/project.service.d.ts.map +1 -1
  29. package/dist/services/project.service.js +30 -4
  30. package/dist/services/project.service.js.map +1 -1
  31. package/dist/services/session-manager.d.ts +1 -0
  32. package/dist/services/session-manager.d.ts.map +1 -1
  33. package/dist/services/session-manager.js +40 -5
  34. package/dist/services/session-manager.js.map +1 -1
  35. package/dist/services/session-runtime-cleanup-gate.d.ts +1 -0
  36. package/dist/services/session-runtime-cleanup-gate.d.ts.map +1 -1
  37. package/dist/services/session-runtime-cleanup-gate.js +5 -3
  38. package/dist/services/session-runtime-cleanup-gate.js.map +1 -1
  39. package/dist/services/team-reconciler.service.d.ts +1 -0
  40. package/dist/services/team-reconciler.service.d.ts.map +1 -1
  41. package/dist/services/team-reconciler.service.js +1 -0
  42. package/dist/services/team-reconciler.service.js.map +1 -1
  43. package/dist/services/terminal-manager.d.ts.map +1 -1
  44. package/dist/services/terminal-manager.js +9 -4
  45. package/dist/services/terminal-manager.js.map +1 -1
  46. package/dist/services/workspace.service.js +8 -8
  47. package/dist/services/workspace.service.js.map +1 -1
  48. package/dist/utils/__tests__/spawned-process-identity.test.d.ts +2 -0
  49. package/dist/utils/__tests__/spawned-process-identity.test.d.ts.map +1 -0
  50. package/dist/utils/__tests__/spawned-process-identity.test.js +31 -0
  51. package/dist/utils/__tests__/spawned-process-identity.test.js.map +1 -0
  52. package/dist/utils/spawned-process-identity.d.ts +1 -1
  53. package/dist/utils/spawned-process-identity.d.ts.map +1 -1
  54. package/dist/utils/spawned-process-identity.js +11 -3
  55. package/dist/utils/spawned-process-identity.js.map +1 -1
  56. package/dist/web/assets/AgentDemoPage-D0LQRcXm.js +1 -0
  57. package/dist/web/assets/{AgentEnvironmentSettingsPage-DfVjAeK8.js → AgentEnvironmentSettingsPage-BnWVgvNe.js} +1 -1
  58. package/dist/web/assets/AgentLogo-BDyW3ihb.js +1 -0
  59. package/dist/web/assets/BranchSelect-Dmp5hq0i.js +1 -0
  60. package/dist/web/assets/BrandLogo-YGT4Vlw5.js +1 -0
  61. package/dist/web/assets/{ConversationPage-Bh_x9kK3.js → ConversationPage-BhapUYGe.js} +2 -2
  62. package/dist/web/assets/CreateTaskInput-GLF3Oyc1.js +1 -0
  63. package/dist/web/assets/{DemoPage-xys5j303.js → DemoPage-BwX2SvcN.js} +1 -1
  64. package/dist/web/assets/DesignSystemPage-j-1-1JtQ.js +16 -0
  65. package/dist/web/assets/EditableTaskTitle-mHT39coo.js +70 -0
  66. package/dist/web/assets/{ExecutionPermissionSelector-CTeKhMaB.js → ExecutionPermissionSelector-DeeNd4Kh.js} +1 -1
  67. package/dist/web/assets/{GeneralSettingsPage-BZEcE8xN.js → GeneralSettingsPage-BBe3EXcj.js} +1 -1
  68. package/dist/web/assets/{LoadingPreviewPage-D81UstX2.js → LoadingPreviewPage-BxEFnEQh.js} +1 -1
  69. package/dist/web/assets/McpSettingsPage-DDA8yUxu.js +1 -0
  70. package/dist/web/assets/{MemberAvatar-BuueBvLu.js → MemberAvatar-CCRbS97s.js} +1 -1
  71. package/dist/web/assets/MobileTaskDetail-BOIFPybn.js +5 -0
  72. package/dist/web/assets/NotificationSettingsPage-B2kUnE8w.js +1 -0
  73. package/dist/web/assets/{ProfileSettingsPage-DdK3Q2wl.js → ProfileSettingsPage-DPZpUoFd.js} +1 -1
  74. package/dist/web/assets/ProjectKanbanPage-DQnwUBFg.js +12 -0
  75. package/dist/web/assets/ProjectSettingsPage-CcXAOYb7.js +2 -0
  76. package/dist/web/assets/{ProviderSettingsPage-CiTp3QwX.js → ProviderSettingsPage-BAIRvcAS.js} +3 -3
  77. package/dist/web/assets/{SettingsMasterDetail-BhepxZ5b.js → SettingsMasterDetail-BuxwsR9R.js} +1 -1
  78. package/dist/web/assets/TaskDetail-B3pOSx3f.js +3 -0
  79. package/dist/web/assets/TeamSettingsPage-DoWmzvKu.js +1 -0
  80. package/dist/web/assets/agent-meta-MzuGtqxl.js +1 -0
  81. package/dist/web/assets/arc-Bm_QIbJA.js +1 -0
  82. package/dist/web/assets/{architectureDiagram-3BPJPVTR-Byb8rrNU.js → architectureDiagram-3BPJPVTR-B5EIiXuX.js} +1 -1
  83. package/dist/web/assets/arrow-down-BVePf1ZM.js +1 -0
  84. package/dist/web/assets/at-sign-BE17rU5b.js +1 -0
  85. package/dist/web/assets/{blockDiagram-GPEHLZMM-DGcS4UET.js → blockDiagram-GPEHLZMM-GFwnvSLM.js} +1 -1
  86. package/dist/web/assets/{c4Diagram-AAUBKEIU-BRyJRATZ.js → c4Diagram-AAUBKEIU-iJfLTxEa.js} +1 -1
  87. package/dist/web/assets/channel-CYYV7_Oi.js +1 -0
  88. package/dist/web/assets/check-qs0S_9rB.js +1 -0
  89. package/dist/web/assets/chevron-down-BaQEBzp3.js +1 -0
  90. package/dist/web/assets/chevron-up-D0y6skqr.js +1 -0
  91. package/dist/web/assets/{chunk-2J33WTMH-DgL3sVcs.js → chunk-2J33WTMH-CDxRPp-8.js} +1 -1
  92. package/dist/web/assets/{chunk-4BX2VUAB-BVgUUvCo.js → chunk-4BX2VUAB-mzPbgyiz.js} +1 -1
  93. package/dist/web/assets/{chunk-55IACEB6-CfD9Uy7p.js → chunk-55IACEB6-KNAJbQyw.js} +1 -1
  94. package/dist/web/assets/{chunk-727SXJPM-D8gRbLX6.js → chunk-727SXJPM-BqGfqkDK.js} +2 -2
  95. package/dist/web/assets/{chunk-AQP2D5EJ-CwBPJyzk.js → chunk-AQP2D5EJ-D27ue-H0.js} +1 -1
  96. package/dist/web/assets/{chunk-FMBD7UC4-B0b7Iiv3.js → chunk-FMBD7UC4-DRza-3q8.js} +1 -1
  97. package/dist/web/assets/{chunk-ND2GUHAM-D0Y5tagg.js → chunk-ND2GUHAM-CUgkviLu.js} +1 -1
  98. package/dist/web/assets/{chunk-QZHKN3VN-qVEPtRTm.js → chunk-QZHKN3VN-BAlOJwZb.js} +1 -1
  99. package/dist/web/assets/{circle-alert-C_ON1rCL.js → circle-alert-Cbvy2cMo.js} +1 -1
  100. package/dist/web/assets/classDiagram-4FO5ZUOK-Cl-3ikxt.js +1 -0
  101. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-Cl-3ikxt.js +1 -0
  102. package/dist/web/assets/code-block-OCS4YCEC-CO23R1Os.js +2 -0
  103. package/dist/web/assets/{confirm-dialog-Drhw7wmk.js → confirm-dialog-BrgNTypL.js} +1 -1
  104. package/dist/web/assets/copy-DejkmIHZ.js +1 -0
  105. package/dist/web/assets/{cose-bilkent-S5V4N54A-BoSlujEJ.js → cose-bilkent-S5V4N54A-8TBY7BP_.js} +1 -1
  106. package/dist/web/assets/cssMode-hzDRnxMx.js +1 -0
  107. package/dist/web/assets/{dagre-BM42HDAG-DWm_GyDR.js → dagre-BM42HDAG-CkMzDiim.js} +1 -1
  108. package/dist/web/assets/{diagram-2AECGRRQ-CVtgrsl0.js → diagram-2AECGRRQ-CAOQJ2N1.js} +1 -1
  109. package/dist/web/assets/{diagram-5GNKFQAL-XNMIXdme.js → diagram-5GNKFQAL-DKhE0hiI.js} +1 -1
  110. package/dist/web/assets/{diagram-KO2AKTUF-CYXdL2cC.js → diagram-KO2AKTUF-DBdkXSpa.js} +1 -1
  111. package/dist/web/assets/{diagram-LMA3HP47-8MCVTTrT.js → diagram-LMA3HP47-DRi2t32c.js} +1 -1
  112. package/dist/web/assets/{diagram-OG6HWLK6-DMWgHctP.js → diagram-OG6HWLK6-DtP92tI1.js} +1 -1
  113. package/dist/web/assets/{erDiagram-TEJ5UH35-D3qp5csl.js → erDiagram-TEJ5UH35-DWFKXtst.js} +1 -1
  114. package/dist/web/assets/{flowDiagram-I6XJVG4X-D-Bem31x.js → flowDiagram-I6XJVG4X-LDE0h4ri.js} +1 -1
  115. package/dist/web/assets/{freemarker2-D7pixABp.js → freemarker2-CLksOOZX.js} +3 -3
  116. package/dist/web/assets/{ganttDiagram-6RSMTGT7-D5ctgPCm.js → ganttDiagram-6RSMTGT7-DD2RfdyV.js} +1 -1
  117. package/dist/web/assets/gauge-CPlvCZUV.js +1 -0
  118. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-lA3I18_r.js → gitGraphDiagram-PVQCEYII-DkKrR8ex.js} +1 -1
  119. package/dist/web/assets/globe-CD4g63c9.js +1 -0
  120. package/dist/web/assets/handlebars-C1M9t0Lo.js +1 -0
  121. package/dist/web/assets/html-DKVKQovh.js +1 -0
  122. package/dist/web/assets/htmlMode-BSWjg5ir.js +1 -0
  123. package/dist/web/assets/index-BnqdwOEH.css +1 -0
  124. package/dist/web/assets/{index-ClhIruws.js → index-CMJV-mgF.js} +13 -13
  125. package/dist/web/assets/{index-CA_B15_q.js → index-D_QVcsLn.js} +5 -5
  126. package/dist/web/assets/{infoDiagram-5YYISTIA-CGy_XnVP.js → infoDiagram-5YYISTIA-BdPA9Xfi.js} +1 -1
  127. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DFGAkcYD.js → ishikawaDiagram-YF4QCWOH-220u4uiv.js} +1 -1
  128. package/dist/web/assets/javascript-WwrMY2Bg.js +1 -0
  129. package/dist/web/assets/{journeyDiagram-JHISSGLW-C9ZHl7QM.js → journeyDiagram-JHISSGLW-BvE0Y3tZ.js} +1 -1
  130. package/dist/web/assets/{jsonMode-bD-WsLyj.js → jsonMode-Dz0hnnvg.js} +4 -4
  131. package/dist/web/assets/{kanban-definition-UN3LZRKU-BbbRnxDG.js → kanban-definition-UN3LZRKU-Q0JH1P6D.js} +1 -1
  132. package/dist/web/assets/key-round-DZm1FLLr.js +1 -0
  133. package/dist/web/assets/{layers-BlEewgM8.js → layers-Dda7MM7a.js} +1 -1
  134. package/dist/web/assets/{linear-D04wUvKo.js → linear-Dr6SfnSn.js} +1 -1
  135. package/dist/web/assets/link-BUeSP3T7.js +1 -0
  136. package/dist/web/assets/liquid-CzGEh0ls.js +1 -0
  137. package/dist/web/assets/{lspLanguageFeatures-jn1q-hoP.js → lspLanguageFeatures-Bbp4PWlJ.js} +1 -1
  138. package/dist/web/assets/mdx-y6S3OMMk.js +1 -0
  139. package/dist/web/assets/mermaid-NOHMQCX5-C72362la.js +123 -0
  140. package/dist/web/assets/{message-square-CTrwLud_.js → message-square-CFriSt4D.js} +1 -1
  141. package/dist/web/assets/{mindmap-definition-RKZ34NQL-n24WGa7x.js → mindmap-definition-RKZ34NQL-bvDaNfKs.js} +1 -1
  142. package/dist/web/assets/{modal-BFDGLwoR.js → modal-DeigO7aN.js} +1 -1
  143. package/dist/web/assets/{monaco-CirwkIGR.js → monaco-BuDK9Fat.js} +3 -3
  144. package/dist/web/assets/paperclip-BOSklTt7.js +1 -0
  145. package/dist/web/assets/pencil-BRQ9W_a-.js +1 -0
  146. package/dist/web/assets/{pieDiagram-4H26LBE5-CUMw3DZK.js → pieDiagram-4H26LBE5-BQCca9Cq.js} +2 -2
  147. package/dist/web/assets/play-Mxkwq69n.js +1 -0
  148. package/dist/web/assets/python-CMnGKsU9.js +1 -0
  149. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-DMshWJZy.js → quadrantDiagram-W4KKPZXB-BEM2U7Cd.js} +1 -1
  150. package/dist/web/assets/razor-mLurbGgY.js +1 -0
  151. package/dist/web/assets/{requirementDiagram-4Y6WPE33-B4Jx_Yx6.js → requirementDiagram-4Y6WPE33-CcmFIALZ.js} +1 -1
  152. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-CN2JbWht.js → sankeyDiagram-5OEKKPKP-D9Nrfbqk.js} +1 -1
  153. package/dist/web/assets/{select-CLV6rtRD.js → select-DKS02St6.js} +1 -1
  154. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-B4bMaYD_.js → sequenceDiagram-3UESZ5HK-5udQDi0x.js} +1 -1
  155. package/dist/web/assets/server-DJaSJ9m1.js +1 -0
  156. package/dist/web/assets/stateDiagram-AJRCARHV-D-cF1NGV.js +1 -0
  157. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-a4ugQnZs.js +1 -0
  158. package/dist/web/assets/status-styles-sQm4KLdp.js +1 -0
  159. package/dist/web/assets/{switch-Ch_hFX_n.js → switch-7LWQ_sEx.js} +1 -1
  160. package/dist/web/assets/task-CDYaC_No.js +42 -0
  161. package/dist/web/assets/task-priority-acVgTiil.js +1 -0
  162. package/dist/web/assets/{textarea-DDy2_gLQ.js → textarea-Ft9KMoEI.js} +1 -1
  163. package/dist/web/assets/{timeline-definition-PNZ67QCA-BuLxqHOL.js → timeline-definition-PNZ67QCA-DXS236a-.js} +1 -1
  164. package/dist/web/assets/{trash-2-DrNpNvRo.js → trash-2-Bc-URu8c.js} +1 -1
  165. package/dist/web/assets/{tsMode-qES9KHvZ.js → tsMode-Vr3bndW1.js} +4 -4
  166. package/dist/web/assets/typescript-BfjoaUSn.js +1 -0
  167. package/dist/web/assets/{upload-D6SifUfr.js → upload-C9Z4jLtv.js} +1 -1
  168. package/dist/web/assets/use-attachments-EypT-7PI.js +2 -0
  169. package/dist/web/assets/{use-profiles-DUoivbBF.js → use-profiles-nMPGwy3v.js} +1 -1
  170. package/dist/web/assets/use-projects-DI27nNwl.js +1 -0
  171. package/dist/web/assets/{use-providers-BKYsoOBU.js → use-providers-DB9ghBPq.js} +1 -1
  172. package/dist/web/assets/use-workspaces-d4n9m9cX.js +1 -0
  173. package/dist/web/assets/useNormalizedLogs-DRoPbP0w.js +1 -0
  174. package/dist/web/assets/useTokenUsage-4qTDa8SY.js +1 -0
  175. package/dist/web/assets/{vennDiagram-CIIHVFJN-LoQ_fciU.js → vennDiagram-CIIHVFJN-BzyNrP06.js} +1 -1
  176. package/dist/web/assets/{wardley-L42UT6IY-Dh_9I9Zv.js → wardley-L42UT6IY-BQ4SyU9_.js} +1 -1
  177. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CQ-yZsuW.js → wardleyDiagram-YWT4CUSO-CcCqmB58.js} +1 -1
  178. package/dist/web/assets/xml-BGVoPR0b.js +1 -0
  179. package/dist/web/assets/{xychartDiagram-2RQKCTM6-HLyImhwf.js → xychartDiagram-2RQKCTM6-RWm1MtQk.js} +1 -1
  180. package/dist/web/assets/yaml-eFhNavrs.js +1 -0
  181. package/dist/web/index.html +2 -2
  182. package/node_modules/@agent-tower/shared/dist/types.d.ts +1 -1
  183. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  184. package/package.json +1 -1
  185. package/dist/web/assets/AgentDemoPage-CCw9EfsA.js +0 -1
  186. package/dist/web/assets/AgentLogo-BhKP5dmt.js +0 -1
  187. package/dist/web/assets/CreateTaskInput-D_KCLZ4q.js +0 -1
  188. package/dist/web/assets/McpSettingsPage-Ch1U9tIg.js +0 -1
  189. package/dist/web/assets/NotificationSettingsPage-IHVOP-Vc.js +0 -1
  190. package/dist/web/assets/ProjectKanbanPage-VFkvX9IJ.js +0 -86
  191. package/dist/web/assets/ProjectSettingsPage-BlRbxcf8.js +0 -2
  192. package/dist/web/assets/TeamSettingsPage-JaLFYXmJ.js +0 -1
  193. package/dist/web/assets/arc-Bd616RKq.js +0 -1
  194. package/dist/web/assets/channel-DJbXDmr3.js +0 -1
  195. package/dist/web/assets/check-Bj-p_n7C.js +0 -1
  196. package/dist/web/assets/chevron-down-BouKK_Vr.js +0 -1
  197. package/dist/web/assets/chevron-right-DJVYJhGF.js +0 -1
  198. package/dist/web/assets/chevron-up-CRlA9Cjl.js +0 -1
  199. package/dist/web/assets/classDiagram-4FO5ZUOK-BIz565rI.js +0 -1
  200. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BIz565rI.js +0 -1
  201. package/dist/web/assets/code-block-OCS4YCEC-wB-pkznC.js +0 -2
  202. package/dist/web/assets/cssMode-DBSRGK6o.js +0 -1
  203. package/dist/web/assets/globe-AjOch0vk.js +0 -1
  204. package/dist/web/assets/handlebars-B10IREzV.js +0 -1
  205. package/dist/web/assets/html-BpG68rDt.js +0 -1
  206. package/dist/web/assets/htmlMode-DuHt_Jpu.js +0 -1
  207. package/dist/web/assets/index-NxnivNNl.css +0 -1
  208. package/dist/web/assets/javascript-BupP80yJ.js +0 -1
  209. package/dist/web/assets/liquid-C57aZJpn.js +0 -1
  210. package/dist/web/assets/mdx-CEldzbGM.js +0 -1
  211. package/dist/web/assets/mermaid-NOHMQCX5-BsnLQ2rU.js +0 -124
  212. package/dist/web/assets/pencil-DQeFTV0j.js +0 -1
  213. package/dist/web/assets/python-B5Uu3BYh.js +0 -1
  214. package/dist/web/assets/razor-BW2eCr4L.js +0 -1
  215. package/dist/web/assets/server-Dhw531hF.js +0 -1
  216. package/dist/web/assets/stateDiagram-AJRCARHV-CJAmyasO.js +0 -1
  217. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CXOXut1l.js +0 -1
  218. package/dist/web/assets/typescript-DyiE-tjk.js +0 -1
  219. package/dist/web/assets/use-projects-CNU2P0v0.js +0 -1
  220. package/dist/web/assets/use-workspaces-C1HJqhNs.js +0 -1
  221. package/dist/web/assets/useNormalizedLogs-Bu2oXEky.js +0 -1
  222. package/dist/web/assets/xml-BNpVw2Ox.js +0 -1
  223. package/dist/web/assets/yaml-DtqgC7D8.js +0 -1
  224. /package/dist/web/assets/{ProjectKanbanPage-DcpNTP1B.css → EditableTaskTitle-DcpNTP1B.css} +0 -0
@@ -0,0 +1,70 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-BuDK9Fat.js","assets/index-CMJV-mgF.js","assets/index-BnqdwOEH.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
+ import{aG as Vi,aH as Wr,aI as Gi,aJ as Zi,aK as Qi,c as fe,u as se,r as A,j as t,l as Q,ab as Ot,B as ae,aL as Ps,aM as Ts,aN as Ms,ad as lt,X as Ve,aO as Nr,aP as Ji,Q as Rr,aQ as en,F as tn,aR as rn,aS as sn,aT as nn,T as wt,t as Se,_ as ot,$ as Be,a0 as Nt,p as ue,au as me,m as Le,o as dt,q as ge,E as he,ak as ht,Z as _t,n as Ds,aA as on,a7 as $t,a2 as Ut,at as an,ap as Bs,s as pr,ac as $e,aq as ln,a5 as cn,W as dn,az as hn}from"./index-CMJV-mgF.js";import{p as un,d as fn,e as mn,Q as pn,f as gn,r as Rt,h as vn,i as _n,j as bn}from"./mermaid-NOHMQCX5-C72362la.js";import{u as xn,A as Sn,a as yn,I as Os,T as wn}from"./use-attachments-EypT-7PI.js";import{u as Ar}from"./use-providers-DB9ghBPq.js";import{C as Xe,F as Is,W as Oe,a as He,h as xt,A as Fs}from"./agent-meta-MzuGtqxl.js";import{A as qt}from"./AgentLogo-BDyW3ihb.js";import{M as Ie}from"./MemberAvatar-CCRbS97s.js";import{C as We}from"./chevron-down-BaQEBzp3.js";import{C as Hs}from"./chevron-up-D0y6skqr.js";import{A as Cn}from"./arrow-down-BVePf1ZM.js";import{A as zr}from"./at-sign-BE17rU5b.js";import{P as kn}from"./paperclip-BOSklTt7.js";import{A as En,G as Ws,F as Lr,S as jn}from"./task-priority-acVgTiil.js";import{C as ct}from"./check-qs0S_9rB.js";import{u as Nn,T as Rn}from"./useTokenUsage-4qTDa8SY.js";import{C as An}from"./confirm-dialog-BrgNTypL.js";import{M as Ct}from"./modal-DeigO7aN.js";import{S as ze}from"./select-DKS02St6.js";import{P as gt,T as Ln}from"./trash-2-Bc-URu8c.js";import{L as gr}from"./layers-Dda7MM7a.js";import{M as Pn}from"./message-square-CFriSt4D.js";import{T as Tn}from"./textarea-Ft9KMoEI.js";import{Z as Mn,c as Dn,b as Bn,j as $r,k as On}from"./CreateTaskInput-GLF3Oyc1.js";import{P as In,F as zs,H as It,C as $s}from"./play-Mxkwq69n.js";import{S as vr}from"./server-DJaSJ9m1.js";import{F as Fn}from"./task-CDYaC_No.js";import{g as Us,f as Hn,h as Wn,b as zn,i as qs,j as Ks,u as Xs,k as $n,d as Un,c as qn}from"./use-workspaces-d4n9m9cX.js";import{U as Ft}from"./upload-C9Z4jLtv.js";import{f as Kn,d as Xn}from"./use-projects-DI27nNwl.js";import{G as Ys}from"./globe-CD4g63c9.js";import{a as st,l as Yn}from"./ExecutionPermissionSelector-DeeNd4Kh.js";import{B as Vn}from"./BranchSelect-Dmp5hq0i.js";import{C as Gn}from"./useNormalizedLogs-DRoPbP0w.js";import{P as Zn}from"./pencil-BRQ9W_a-.js";var Qn=class extends Vi{constructor(e,i){super(e,i)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:Wr()})}getOptimisticResult(e){return e.behavior=Wr(),super.getOptimisticResult(e)}fetchNextPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"forward"}}})}fetchPreviousPage(e){return this.fetch({...e,meta:{fetchMore:{direction:"backward"}}})}createResult(e,i){const{state:n}=e,h=super.createResult(e,i),{isFetching:S,isRefetching:x,isError:w,isRefetchError:s}=h,o=n.fetchMeta?.fetchMore?.direction,u=w&&o==="forward",f=S&&o==="forward",d=w&&o==="backward",p=S&&o==="backward";return{...h,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Zi(i,n.data),hasPreviousPage:Gi(i,n.data),isFetchNextPageError:u,isFetchingNextPage:f,isFetchPreviousPageError:d,isFetchingPreviousPage:p,isRefetchError:s&&!u&&!d,isRefetching:x&&!f&&!p}}};function Vs(e,i){return Qi(e,Qn)}const Jn=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],Gs=fe("arrow-right",Jn);const eo=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Zs=fe("ban",eo);const to=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],ro=fe("chevron-left",to);const so=[["path",{d:"M11 14h10",key:"1w8e9d"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v1.344",key:"1e62lh"}],["path",{d:"m17 18 4-4-4-4",key:"z2g111"}],["path",{d:"M8 4H6a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h12a2 2 0 0 0 1.793-1.113",key:"bjbb7m"}],["rect",{x:"8",y:"2",width:"8",height:"4",rx:"1",key:"ublpy"}]],io=fe("clipboard-paste",so);const no=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],Ue=fe("clock-3",no);const oo=[["line",{x1:"15",x2:"15",y1:"12",y2:"18",key:"1p7wdc"}],["line",{x1:"12",x2:"18",y1:"15",y2:"15",key:"1nscbv"}],["rect",{width:"14",height:"14",x:"8",y:"8",rx:"2",ry:"2",key:"17jyea"}],["path",{d:"M4 16c-1.1 0-2-.9-2-2V4c0-1.1.9-2 2-2h10c1.1 0 2 .9 2 2",key:"zix9uf"}]],Ur=fe("copy-plus",oo);const ao=[["path",{d:"M21.54 15H17a2 2 0 0 0-2 2v4.54",key:"1djwo0"}],["path",{d:"M7 3.34V5a3 3 0 0 0 3 3a2 2 0 0 1 2 2c0 1.1.9 2 2 2a2 2 0 0 0 2-2c0-1.1.9-2 2-2h3.17",key:"1tzkfa"}],["path",{d:"M11 21.95V18a2 2 0 0 0-2-2a2 2 0 0 1-2-2v-1a2 2 0 0 0-2-2H2.05",key:"14pb5j"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],lo=fe("earth",ao);const co=[["circle",{cx:"12",cy:"12",r:"1",key:"41hilf"}],["circle",{cx:"12",cy:"5",r:"1",key:"gxeob9"}],["circle",{cx:"12",cy:"19",r:"1",key:"lyex9k"}]],Ru=fe("ellipsis-vertical",co);const ho=[["path",{d:"M14 22h4a2 2 0 0 0 2-2V8a2.4 2.4 0 0 0-.706-1.706l-3.588-3.588A2.4 2.4 0 0 0 14 2H6a2 2 0 0 0-2 2v6",key:"14cnrg"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M5 14a1 1 0 0 0-1 1v2a1 1 0 0 1-1 1 1 1 0 0 1 1 1v2a1 1 0 0 0 1 1",key:"sr0ebq"}],["path",{d:"M9 22a1 1 0 0 0 1-1v-2a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-2a1 1 0 0 0-1-1",key:"w793db"}]],uo=fe("file-braces-corner",ho);const fo=[["path",{d:"M4 12.15V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.706.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2h-3.35",key:"1wthlu"}],["path",{d:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"m5 16-3 3 3 3",key:"331omg"}],["path",{d:"m9 22 3-3-3-3",key:"lsp7cz"}]],Ht=fe("file-code-corner",fo);const mo=[["path",{d:"M6 22a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2h8a2.4 2.4 0 0 1 1.704.706l3.588 3.588A2.4 2.4 0 0 1 20 8v12a2 2 0 0 1-2 2z",key:"1oefj6"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]],po=fe("file-exclamation-point",mo);const go=[["circle",{cx:"5",cy:"6",r:"3",key:"1qnov2"}],["path",{d:"M5 9v6",key:"158jrl"}],["circle",{cx:"5",cy:"18",r:"3",key:"104gr9"}],["path",{d:"M12 3v18",key:"108xh3"}],["circle",{cx:"19",cy:"6",r:"3",key:"108a5v"}],["path",{d:"M16 15.7A9 9 0 0 0 19 9",key:"1e3vqb"}]],Pr=fe("git-graph",go);const vo=[["path",{d:"M8 3H5a2 2 0 0 0-2 2v3",key:"1dcmit"}],["path",{d:"M21 8V5a2 2 0 0 0-2-2h-3",key:"1e4gt3"}],["path",{d:"M3 16v3a2 2 0 0 0 2 2h3",key:"wsl5sc"}],["path",{d:"M16 21h3a2 2 0 0 0 2-2v-3",key:"18trek"}]],_o=fe("maximize",vo);const bo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m16 15-3-3 3-3",key:"14y99z"}]],xo=fe("panel-left-close",bo);const So=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M9 3v18",key:"fh3hqa"}],["path",{d:"m14 9 3 3-3 3",key:"8010ee"}]],yo=fe("panel-left-open",So);const wo=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m8 9 3 3-3 3",key:"12hl5m"}]],Co=fe("panel-right-close",wo);const ko=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M15 3v18",key:"14nvp0"}],["path",{d:"m10 15-3-3 3-3",key:"1pgupc"}]],_r=fe("panel-right-open",ko);const Eo=[["path",{d:"M13 21h8",key:"1jsn5i"}],["path",{d:"M21.174 6.812a1 1 0 0 0-3.986-3.987L3.842 16.174a2 2 0 0 0-.5.83l-1.321 4.352a.5.5 0 0 0 .623.622l4.353-1.32a2 2 0 0 0 .83-.497z",key:"1a8usu"}]],jo=fe("pen-line",Eo);const No=[["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"}]],Qs=fe("settings-2",No);const Ro=[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["line",{x1:"19",x2:"19",y1:"8",y2:"14",key:"1bvyxn"}],["line",{x1:"22",x2:"16",y1:"11",y2:"11",key:"1shjgl"}]],At=fe("user-plus",Ro);const Ao=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"11",x2:"11",y1:"8",y2:"14",key:"1vmskp"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],Lo=fe("zoom-in",Ao);const Po=[["circle",{cx:"11",cy:"11",r:"8",key:"4ej97u"}],["line",{x1:"21",x2:"16.65",y1:"21",y2:"16.65",key:"13gj7c"}],["line",{x1:"8",x2:"14",y1:"11",y2:"11",key:"durymu"}]],To=fe("zoom-out",Po),Mo=10,Do=24,Js=Mo*Do,Bo=8;function Oo(e,i=Js){return e>i+Bo}function Io(e,i){return e.includes(i)?e:[...e,i]}function Fo(e,i){return e.filter(n=>n!==i)}function Ho(e,i){const n=new Map(i.map(h=>[h.id,h]));return e.map(h=>n.get(h)).filter(h=>!!h).map(h=>({memberId:h.id,label:h.name}))}const Kt=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function qr(e){if(!e)return 0;const i=Date.parse(e);return Number.isNaN(i)?0:i}function Wo(e,i=[],n=[]){const h=new Set(n.filter(x=>Kt.has(x.status)).map(x=>x.workRequestId));return[...e.map(x=>({kind:"message",key:`message:${x.id}`,sortTime:x.createdAt,order:0,message:x})),...i.filter(x=>x.status==="PENDING_APPROVAL").filter(x=>!h.has(x.id)).map(x=>({kind:"pendingApproval",key:`pending-approval:${x.id}`,sortTime:x.updatedAt??x.createdAt,order:1,request:x}))].sort((x,w)=>{const s=qr(x.sortTime)-qr(w.sortTime);return s!==0?s:x.order!==w.order?x.order-w.order:x.key.localeCompare(w.key)})}function zo(e){switch(e){case"RUNNING":return"Working";case"QUEUED":return"Queued...";case"WAITING_ROOM_REPLY":return"Waiting reply...";case"SESSION_ENDED":return"Session ended";default:return e}}function $o(e){switch(e){case"FAILED":return"text-red-500";case"RUNNING":case"WAITING_ROOM_REPLY":case"QUEUED":case"SESSION_ENDED":return"text-neutral-500";default:return"text-neutral-500"}}function Uo(e,i){const n=e.reduce((S,x)=>(S[x.status]=(S[x.status]??0)+1,S),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([S,x])=>{const w=n[S];return w?`${w} ${i(x)}`:null}).filter(S=>!!S).join(" · ")}function qo(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function Ko({status:e}){const{t:i}=se();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[i("Working"),t.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[t.jsx("span",{children:"."}),t.jsx("span",{className:"active-work-dots__second",children:"."}),t.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):t.jsx(t.Fragment,{children:i(zo(e))})}function Xo({invocations:e,memberById:i,workRequestById:n,onViewInvocationSession:h,onStopMember:S,isStopPending:x,stoppingMemberId:w,stopPromptInvocationId:s,onToggleStopConfirm:o}){const{t:u}=se(),[f,d]=A.useState(qo),p=A.useMemo(()=>e.filter(y=>Kt.has(y.status)).sort((y,b)=>Date.parse(b.updatedAt??b.createdAt??"")-Date.parse(y.updatedAt??y.createdAt??"")),[e]);if(p.length===0)return null;const m=Uo(p,u);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>d(y=>!y),"aria-expanded":f,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[t.jsxs("span",{className:"min-w-0 truncate",children:[t.jsx("span",{className:"font-medium text-neutral-800",children:u("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:m})]}),f?t.jsx(We,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(Hs,{size:15,className:"shrink-0 text-neutral-400"})]}),f&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:p.map(y=>{const b=i.get(y.memberId),r=n.get(y.workRequestId),a=!!(y.sessionId&&h),l=!!b,c=s===y.id,g=x&&w===y.memberId,_=r?.instruction??y.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:_,className:Q("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",a?"cursor-pointer hover:bg-white":"cursor-default"),role:a?"button":void 0,tabIndex:a?0:void 0,onClick:()=>y.sessionId&&h?.(y.sessionId),onKeyDown:C=>{!a||!y.sessionId||(C.key==="Enter"||C.key===" ")&&(C.preventDefault(),h?.(y.sessionId))},children:[t.jsx(Ie,{name:b?.name??u("Agent"),avatar:b?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[t.jsx("span",{className:"truncate font-medium text-neutral-800",children:b?.name??u("Agent")}),t.jsx("span",{className:Q("shrink-0",$o(y.status)),children:t.jsx(Ko,{status:y.status})})]}),a&&t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),y.sessionId&&h?.(y.sessionId)},onKeyDown:C=>C.stopPropagation(),className:"hidden shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700 group-hover:inline-flex",title:u("View log"),"aria-label":`${u("View log")} ${b?.name??u("Agent")}`,children:t.jsx(_r,{size:13})}),l&&t.jsx("button",{type:"button",onClick:C=>{C.stopPropagation(),o(y.id)},onKeyDown:C=>C.stopPropagation(),disabled:g,className:"shrink-0 rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-700 disabled:cursor-not-allowed disabled:opacity-50",title:u("Stop"),"aria-label":`${u("Stop")} ${b?.name??u("Agent")}`,children:t.jsx(Ot,{size:12})})]}),l&&c&&b&&t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[t.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:u("Stop running work?")}),t.jsxs(ae,{type:"button",size:"xs",variant:"outline",disabled:g,onClick:()=>S(b.id,!1),children:[t.jsx(Ot,{size:11}),t.jsx("span",{children:u(g?"Stopping":"Stop only")})]}),t.jsxs(ae,{type:"button",size:"xs",variant:"outline",disabled:g,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>S(b.id,!0),children:[t.jsx(Zs,{size:11}),t.jsx("span",{children:u(g?"Stopping":"Stop + clear queue")})]})]})]},y.id)})})]})}const br=Rr(),Yo=240;let Kr=0;function Vo(e,i){return Kr+=1,{id:`pending-room-message-${Date.now()}-${Kr}`,teamRunId:e,senderType:i.senderType??"user",senderId:i.senderId??null,senderInvocationId:i.senderInvocationId??null,kind:i.kind??((i.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:i.content,mentions:i.mentions??[],workRequestIds:[],artifactRefs:i.artifactRefs??[],attachmentIds:i.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function ei(e){return"pendingStatus"in e}function Go(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Zo(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function xr(e,i){if(i.length===0)return e;const n=new Set(i.map(Zo));return e.split(`
3
+ `).map(h=>{const S=h.match(/^\s*/)?.[0]??"",x=h.trimStart();for(const w of n){if(x===w)return null;if(x.startsWith(`${w} `)||x.startsWith(`${w} `))return`${S}${x.slice(w.length).trimStart()}`}return h}).filter(h=>h!=null).join(`
4
+ `).replace(/\n{3,}/g,`
5
+
6
+ `).trim()}function Qo(e){if(!e)return"";const i=new Date(e);return Number.isNaN(i.getTime())?"":i.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Sr(e,i){return e instanceof Error?e.message:i}function Jo(e,i=Yo){const n=(e??"").replace(/\s+/g," ").trim();return n.length<=i?n:`${n.slice(0,i-3).trimEnd()}...`}function ea(e,i){const h=e.slice(0,i).match(/(^|\s)@([^\s@]*)$/);return!h||h.index==null?null:{start:h.index+h[1].length,end:i,query:h[2]??""}}function ta(e,i){const n=i.trim().toLowerCase();return n?[e.name,e.providerId,...e.aliases??[]].some(S=>S.toLowerCase().includes(n)):!0}function Xr(e){return e.membershipStatus!=="REMOVED"}function ra(e,i){return e.label??i.get(e.memberId)?.name??e.memberId}function sa(e,i){return(e.recipientMemberIds??[]).map(n=>i.get(n)?.name??n)}function ia(e,i){const n=e.mentions??[],h=e.contentPreview??e.content;if(n.length===0)return h;const S=n.map(w=>ra(w,i)).filter(w=>w&&!h.includes(`@${w}`));if(S.length===0)return h;const x=S.map(w=>`@${w}`).join(" ");return h.trimEnd()?`${h.trimEnd()} ${x}`:x}function na(e,i,n){if(e.senderType!=="agent")return null;if(e.senderId&&i.has(e.senderId))return i.get(e.senderId)??null;if(e.senderInvocationId){const h=n.get(e.senderInvocationId);if(h?.memberId&&i.has(h.memberId))return i.get(h.memberId)??null}return null}function oa({content:e,isUser:i,workingDir:n,onOpenWorkspaceFile:h,onOpenPreviewUrl:S,onOpenVisualization:x,downloadSessionId:w}){const s=A.useMemo(()=>x||w?un(e):e,[e,w,x]),o=fn(s),u=A.useMemo(()=>mn({workingDir:n,onOpenWorkspaceFile:h,onOpenPreviewUrl:S,onOpenVisualization:x,downloadSessionId:w}),[w,S,x,h,n]);return t.jsx("div",{className:Q("team-room-message-markdown prose prose-sm max-w-none break-words [overflow-wrap:anywhere]","prose-p:my-2 prose-p:first:mt-0 prose-p:last:mb-0 prose-p:leading-6","prose-ul:my-2 prose-ol:my-2 prose-li:my-1 prose-li:pl-0 prose-li:leading-6 prose-li:marker:text-neutral-400","prose-blockquote:my-2 prose-blockquote:border-l-2 prose-blockquote:border-neutral-300 prose-blockquote:pl-3 prose-blockquote:text-neutral-600","prose-pre:my-3 prose-pre:max-w-full prose-pre:overflow-x-auto prose-pre:rounded-md prose-pre:border prose-pre:border-neutral-800 prose-pre:bg-neutral-950 prose-pre:p-3 prose-pre:text-xs prose-pre:leading-relaxed prose-pre:shadow-inner","prose-code:break-words prose-code:rounded prose-code:bg-neutral-100 prose-code:px-1 prose-code:py-0.5 prose-code:text-[0.9em] prose-code:font-medium prose-code:text-neutral-800","prose-pre:prose-code:bg-transparent prose-pre:prose-code:p-0 prose-pre:prose-code:text-neutral-100","prose-headings:mb-2 prose-headings:mt-3 prose-headings:font-semibold prose-headings:leading-snug","prose-a:text-blue-600 prose-a:underline-offset-2 hover:prose-a:text-blue-700","prose-hr:my-3 prose-hr:border-neutral-200",i?["text-white prose-strong:text-white prose-headings:text-white prose-blockquote:border-white/30 prose-blockquote:text-neutral-200","prose-code:bg-white/15 prose-code:text-white prose-pre:border-neutral-700 prose-a:text-blue-200 hover:prose-a:text-blue-100 prose-hr:border-white/15"]:"text-neutral-800 prose-strong:text-neutral-900"),children:t.jsx(pn,{components:u,plugins:o,controls:o?gn:void 0,children:s})})}function aa({hasAttachmentIds:e,attachments:i,isLoading:n,onOpenImage:h}){if(!e)return null;if(n&&i.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(i.length===0)return null;const S=i.filter(w=>w.mimeType.startsWith("image/")),x=new Map(S.map((w,s)=>[w.id,s]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:i.map(w=>{const s=`${br}${w.url}`;if(w.mimeType.startsWith("image/")){const u=x.get(w.id)??0;return t.jsxs("button",{type:"button",onClick:()=>h(S,u),className:"group relative h-24 w-24 overflow-hidden rounded-lg border border-neutral-200 bg-neutral-50 shadow-sm transition-opacity hover:opacity-90",title:w.originalName,children:[t.jsx("img",{src:s,alt:w.originalName,className:"h-full w-full object-cover",loading:"lazy"}),t.jsx("span",{className:"absolute inset-x-0 bottom-0 truncate bg-black/55 px-1.5 py-1 text-left text-[10px] text-white",children:w.originalName})]},w.id)}return t.jsxs("a",{href:s,target:"_blank",rel:"noopener noreferrer",className:"flex max-w-[220px] items-center gap-2 rounded-lg border border-neutral-200 bg-white px-3 py-2 text-xs text-neutral-700 shadow-sm hover:bg-neutral-50",title:w.originalName,children:[t.jsx(Is,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate font-medium",children:w.originalName}),t.jsx("span",{className:"text-neutral-400",children:Go(w.sizeBytes)})]}),t.jsx(Nr,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},w.id)})})}function la({message:e,content:i,attachmentIds:n,isUser:h,tone:S,onOpenImage:x,workingDir:w,onOpenWorkspaceFile:s,onOpenPreviewUrl:o,onOpenVisualization:u,downloadSessionId:f}){const d=A.useMemo(()=>Array.from(new Set(n??[])),[n]),{data:p=[],isLoading:m}=yn(d),y=p.length>0?xr(i,p):i;return t.jsxs(t.Fragment,{children:[y.trim()&&t.jsx(ha,{message:e,content:y,attachments:p,isUser:h,tone:S,workingDir:w,onOpenWorkspaceFile:s,onOpenPreviewUrl:o,onOpenVisualization:u,downloadSessionId:f}),t.jsx(aa,{hasAttachmentIds:d.length>0,attachments:p,isLoading:m,onOpenImage:x})]})}function ca({images:e,index:i,onClose:n,onSelect:h}){const S=e[i];if(!S)return null;const x=i>0,w=i<e.length-1;return t.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[t.jsx("button",{type:"button",onClick:n,className:"absolute right-4 top-4 rounded-full bg-white/10 p-2 text-white transition-colors hover:bg-white/20","aria-label":"Close image preview",children:t.jsx(Ve,{size:20})}),x&&t.jsx("button",{type:"button",onClick:()=>h(i-1),className:"absolute left-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Previous image",children:t.jsx(ro,{size:24,"aria-hidden":!0})}),t.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[t.jsx("img",{src:`${br}${S.url}`,alt:S.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),t.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[t.jsx("span",{className:"max-w-[70vw] truncate",children:S.originalName}),t.jsxs("a",{href:`${br}${S.url}`,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 rounded-md bg-white/10 px-2 py-1 text-xs hover:bg-white/20",children:[t.jsx(Nr,{size:13,"aria-hidden":!0}),"Open"]})]})]}),w&&t.jsx("button",{type:"button",onClick:()=>h(i+1),className:"absolute right-4 top-1/2 flex h-10 w-10 -translate-y-1/2 items-center justify-center rounded-full bg-white/10 text-white transition-colors hover:bg-white/20","aria-label":"Next image",children:t.jsx(Xe,{size:24,"aria-hidden":!0})})]})}function da({draft:e,attachmentMarkdown:i,attachmentIds:n,mentions:h}){const x=[e.trim(),i].filter(Boolean).join(`
7
+
8
+ `);return x?{content:x,mentions:h,senderType:"user",...n.length>0?{attachmentIds:n}:{}}:null}function ha({message:e,content:i,attachments:n,isUser:h,tone:S=h?"user":"agent",workingDir:x,onOpenWorkspaceFile:w,onOpenPreviewUrl:s,onOpenVisualization:o,downloadSessionId:u}){const{t:f}=se(),d=A.useId(),p=A.useRef(null),[m,y]=A.useState(null),[b,r]=A.useState(!1),[a,l]=A.useState(null),c=en(e.teamRunId,e.id,!1),g=c.data?.content,_=g?xr(g,n):void 0,k=!!(_&&_!==i)?_:i,v=!!(e.isTruncated&&!ei(e)),E=m?.messageId===e.id&&m.content===k&&m.expanded,R=A.useCallback(()=>{const M=p.current;M&&r(Oo(M.scrollHeight))},[]);A.useLayoutEffect(()=>{R();const M=p.current;if(!M)return;const F=window.requestAnimationFrame(R),U=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return U?.observe(M),window.addEventListener("resize",R),()=>{window.cancelAnimationFrame(F),U?.disconnect(),window.removeEventListener("resize",R)}},[k,R]);const O=A.useCallback(async()=>{if(l(null),E){y({messageId:e.id,content:k,expanded:!1});return}if(v&&!g){const M=await c.refetch();if(M.error){l(Sr(M.error,f("Failed to load full message")));return}const F=M.data?.content?xr(M.data.content,n):k;y({messageId:e.id,content:F,expanded:!0});return}y({messageId:e.id,content:k,expanded:!0})},[n,v,g,c,E,e.id,k,f]),L=(b||v)&&!E,P=b||v,H=c.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:d,ref:p,onLoadCapture:R,className:Q("relative transition-[max-height] duration-200 ease-out",L?"overflow-hidden":""),style:L?{maxHeight:Js}:void 0,children:[t.jsx(oa,{content:k,isUser:h,workingDir:x,onOpenWorkspaceFile:w,onOpenPreviewUrl:s,onOpenVisualization:o,downloadSessionId:u}),L&&t.jsx("div",{className:Q("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",S==="system"?"to-amber-50":S==="user"?"to-neutral-900":"to-neutral-100")})]}),P&&t.jsxs("button",{type:"button","aria-expanded":E,"aria-controls":d,"aria-label":f(E?"Collapse message":"Expand full message"),disabled:H,onClick:()=>{O()},className:Q("mt-2 inline-flex items-center gap-1 rounded-md px-2 py-1 text-xs font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-300",S==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":S==="user"?"bg-white/10 text-neutral-100 hover:bg-white/15 hover:text-white":"bg-neutral-100 text-neutral-600 hover:bg-neutral-200 hover:text-neutral-900",H?"cursor-wait opacity-70":""),children:[E?t.jsx(Hs,{size:13}):t.jsx(We,{size:13}),t.jsx("span",{children:f(H?"Loading":E?"Collapse message":"Expand full message")})]}),a&&t.jsx("div",{className:Q("mt-1 text-xs",S==="user"?"text-red-200":"text-red-600"),children:a})]})}function ti({senderName:e,avatar:i,createdAt:n,isUser:h,isSystem:S,children:x,headerAddon:w,bubbleClassName:s,isPending:o}){return S?t.jsx("div",{className:"flex justify-center",children:t.jsx("div",{className:"max-w-[min(100%,42rem)] rounded-lg border border-amber-200/80 bg-amber-50 px-3 py-2 text-xs text-amber-900 shadow-sm",children:x})}):t.jsxs("div",{className:Q("group flex items-start gap-3",h?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!h&&t.jsx(Ie,{name:e,avatar:i??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:Q("flex min-w-0 max-w-[min(86%,46rem)] flex-col",h?"items-end":"items-start"),children:[t.jsxs("div",{className:Q("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",h?"justify-end":"justify-start"),children:[t.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),t.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),t.jsx(Ue,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:Qo(n)}),w]}),t.jsx("div",{className:Q("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",h?"rounded-tr-[2px] border border-neutral-900 bg-neutral-900 text-white shadow-sm":"rounded-tl-[2px] bg-neutral-100 text-neutral-900 shadow-sm",s,o?"opacity-70":""),children:x})]}),h&&t.jsx(Ie,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function ua({provider:e}){return t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[10rem] shrink items-center gap-1 rounded-full bg-neutral-900/5 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:[t.jsx(qt,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function fa({message:e,senderName:i,senderMember:n,senderProvider:h,memberById:S,displayContent:x,onOpenImage:w,workingDir:s,onOpenWorkspaceFile:o,onOpenPreviewUrl:u,onOpenVisualization:f,previewWorkspaceId:d,previewSessionId:p}){const{t:m}=se(),y=e.senderType==="user",b=e.senderType==="system",r=ei(e)?e.pendingStatus:null,a=e.mentions??[],l=e.workRequestIds?.length??0,c=e.visibility==="PRIVATE",g=A.useCallback(v=>{u?.(v,d)},[u,d]),_=A.useCallback(v=>{p&&f?.(p,v,d)},[f,p,d]),C=c?sa(e,S):[],k=t.jsxs(t.Fragment,{children:[!y&&!b&&h&&t.jsx(ua,{provider:h}),c&&t.jsxs("span",{className:"ml-0.5 inline-flex max-w-[18rem] shrink items-center gap-1 rounded-full bg-sky-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-sky-700",title:C.join(", "),children:[t.jsx(Ji,{size:10}),t.jsxs("span",{className:"truncate",children:[m("Private"),C.length>0?`: ${C.join(", ")}`:""]})]}),!b&&l>0&&a.length===0&&t.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[m("Work requests"),": ",l]}),r==="sending"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:m("发送中...")}),r==="failed"&&t.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:m("发送失败")})]});return t.jsx(ti,{senderName:i,avatar:n?.avatar??null,createdAt:e.createdAt,isUser:y,isSystem:b,headerAddon:k,bubbleClassName:y&&r==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:r==="sending",children:t.jsx(la,{message:e,content:x,attachmentIds:e.attachmentIds,isUser:y&&r!=="failed",tone:b?"system":void 0,onOpenImage:w,workingDir:s,onOpenWorkspaceFile:o,onOpenPreviewUrl:u?g:void 0,onOpenVisualization:f&&p?_:void 0,downloadSessionId:p})})}function ma({request:e,member:i,onApprove:n,onReject:h,isActionPending:S,isApprovePending:x,isRejectPending:w}){const{t:s}=se();return t.jsx(ti,{senderName:i?.name??s("Agent"),avatar:i?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:t.jsxs("div",{className:"space-y-2",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs("span",{className:"inline-flex items-center gap-1 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[11px] font-medium text-amber-700",children:[t.jsx(Ue,{size:11}),s("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[s("Requester"),": ",s(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),t.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instructionPreview??Jo(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(ae,{type:"button",size:"xs",variant:"outline",disabled:S,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:n,children:[t.jsx(ct,{size:12}),t.jsx("span",{children:s(x?"Approving":"Approve")})]}),t.jsxs(ae,{type:"button",size:"xs",variant:"outline",disabled:S,onClick:h,children:[t.jsx(Ve,{size:12}),t.jsx("span",{children:s(w?"Rejecting":"Reject")})]})]})]})})}function Au({teamRun:e,messages:i,readOnly:n,readOnlyMessage:h,onSendMessage:S,onViewInvocationSession:x,changeSummaryBar:w,compactComposer:s,centered:o,workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:d,onOpenVisualization:p}){const{t:m}=se(),y=Ps(e.id),b=Ts(e.id),r=Ms(e.id),[a,l]=A.useState(""),[c,g]=A.useState(!1),[_,C]=A.useState(null),[k,v]=A.useState(0),[E,R]=A.useState([]),[O,L]=A.useState(!1),[P,H]=A.useState(null),[M,F]=A.useState([]),[U,N]=A.useState(null),D=A.useRef(null),T=A.useRef(null),{files:B,addFiles:q,removeFile:K,clear:$,restoreFiles:W,buildMarkdownLinks:z,getDoneAttachments:j,isUploading:I}=xn(),X=B.some(V=>V.status==="done"&&V.attachment),[Y,Z]=A.useState(null),{scrollRef:G,contentRef:te,isAtBottom:le,scrollToBottom:J}=Nn({resize:"smooth",initial:"instant"}),ne=A.useRef(!1),re=A.useRef(null);A.useEffect(()=>{const V=G.current;if(!V)return;const ee=ie=>{if(ie.deltaY<0){ne.current=!0;return}ie.deltaY>0&&V.scrollHeight-V.scrollTop-V.clientHeight<=70&&(ne.current=!1)};return V.addEventListener("wheel",ee,{passive:!0}),()=>V.removeEventListener("wheel",ee)},[G]);const{data:ye}=Ar(),ut=A.useMemo(()=>{const V=new Map;for(const ee of ye??[])V.set(ee.provider.id,ee.provider);return V},[ye]),Re=A.useMemo(()=>new Map((e.members??[]).map(V=>[V.id,V])),[e.members]),Pe=A.useMemo(()=>(e.members??[]).filter(Xr),[e.members]),Ze=A.useMemo(()=>new Map((e.invocations??[]).map(V=>[V.id,V])),[e.invocations]),_e=A.useMemo(()=>{const V=new Set(i.map(ie=>ie.id)),ee=M.filter(ie=>!V.has(ie.id));return[...i,...ee].sort((ie,pe)=>{const xe=Date.parse(ie.createdAt??""),Me=Date.parse(pe.createdAt??"");return(Number.isNaN(xe)?0:xe)-(Number.isNaN(Me)?0:Me)})},[i,M]),Qe=A.useMemo(()=>new Map((e.workRequests??[]).map(V=>[V.id,V])),[e.workRequests]),be=A.useMemo(()=>Wo(_e,e.workRequests??[],e.invocations??[]),[_e,e.invocations,e.workRequests]);A.useEffect(()=>{const V=be.at(-1)?.key??null,ee=re.current;re.current=V,!(ee==null||V==null||V===ee||ne.current)&&requestAnimationFrame(()=>{J({animation:"smooth",ignoreEscapes:!0})})},[J,be]);const Je=A.useMemo(()=>(e.invocations??[]).filter(V=>Kt.has(V.status)),[e.invocations]),Te=A.useMemo(()=>E.map(V=>Re.get(V)).filter(V=>!!V).filter(Xr),[Re,E]),ve=A.useMemo(()=>{const V=_?.query??"";return Pe.filter(ee=>ta(ee,V)).sort((ee,ie)=>{const pe=E.includes(ee.id),xe=E.includes(ie.id);return pe!==xe?pe?1:-1:ee.name.localeCompare(ie.name)})},[Pe,_?.query,E]),et=!n&&(c||!!_)&&ve.length>0,we=A.useCallback((V,ee)=>{if(ee==null){C(null);return}C(ea(V,ee)),v(0)},[]),Fe=A.useCallback(V=>{R(Me=>Io(Me,V.id));const ee=`@${V.name} `;if(_){const Me=`${a.slice(0,_.start)}${ee}${a.slice(_.end)}`,tt=_.start+ee.length;l(Me),C(null),g(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(tt,tt)});return}const ie=a.length===0||/\s$/.test(a)?"":" ",pe=`${a}${ie}${ee}`,xe=pe.length;l(pe),g(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(xe,xe)})},[a,_]),ce=A.useCallback(V=>{R(ee=>Fo(ee,V))},[]),Zt=A.useCallback(V=>{const ee=V.target.value;l(ee),H(null);const ie=V.target;ie.style.height="auto",ie.style.height=`${Math.max(s?40:72,Math.min(ie.scrollHeight,s?140:240))}px`,g(!1),we(ee,ie.selectionStart)},[s,we]),$i=A.useCallback(V=>{const ee=V.target.files;ee&&ee.length>0&&(q(Array.from(ee)),H(null)),V.target.value=""},[q]),Ui=A.useCallback(V=>{const ee=[];for(const ie of V.clipboardData.items)if(ie.kind==="file"){const pe=ie.getAsFile();pe&&ee.push(pe)}ee.length>0&&(V.preventDefault(),q(ee),H(null))},[q]),Qt=A.useCallback(async()=>{if(n||O||I)return;const V=z(),ee=j().map(je=>je.id),ie=Ho(E,Pe),pe=da({draft:a,attachmentMarkdown:V,attachmentIds:ee,mentions:ie});if(!pe||!a.trim()&&!X)return;const xe=Vo(e.id,pe),Me=a,tt=E,Jt=B;F(je=>[...je,xe]),l(""),R([]),g(!1),C(null),$(),D.current&&(D.current.style.height=s?"40px":"72px"),requestAnimationFrame(()=>J()),L(!0),H(null);try{const je=await S(pe);F(Ce=>Ce.filter(ke=>ke.id!==xe.id)),je&&typeof je=="object"&&"id"in je&&requestAnimationFrame(()=>J())}catch(je){const Ce=je instanceof Error?je.message:"Failed to send room message";F(ke=>ke.map(ft=>ft.id===xe.id?{...ft,pendingStatus:"failed",error:Ce}:ft)),l(ke=>ke.length===0?Me:ke),R(ke=>ke.length===0?tt:ke),W(Jt),H(Ce),requestAnimationFrame(()=>J())}finally{L(!1)}},[Pe,B,z,$,s,a,j,X,O,I,S,n,W,J,E,e.id]),qi=A.useCallback(V=>{const ee=V.nativeEvent.isComposing||V.nativeEvent.keyCode===229;if(et){if(V.key==="ArrowDown"){V.preventDefault(),v(ie=>(ie+1)%ve.length);return}if(V.key==="ArrowUp"){V.preventDefault(),v(ie=>(ie-1+ve.length)%ve.length);return}if(V.key==="Enter"&&!ee||V.key==="Tab"){V.preventDefault();const ie=ve[k]??ve[0];ie&&Fe(ie);return}if(V.key==="Escape"){V.preventDefault(),C(null),g(!1);return}}V.key==="Enter"&&!V.shiftKey&&!V.repeat&&!ee&&(V.preventDefault(),Qt())},[Fe,Qt,k,ve,et]);A.useEffect(()=>{l(""),R([]),g(!1),C(null),H(null),F([]),$(),ne.current=!1,re.current=null,N(null),D.current&&(D.current.style.height=s?"40px":"72px")},[$,s,e.id]);const Hr=y.isError?y.error:b.isError?b.error:null,Ki=y.isPending||b.isPending,Xi=A.useCallback((V,ee)=>{r.mutate({memberId:V,cancelQueued:ee},{onSuccess:()=>N(null)})},[r]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[Y&&t.jsx(ca,{images:Y.images,index:Y.index,onClose:()=>Z(null),onSelect:V=>Z(ee=>ee&&{...ee,index:V})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:G,className:Q("h-full overflow-y-auto scrollbar-app-thin bg-white",s?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:te,className:Q(s?"space-y-2.5":"space-y-3",o&&"max-w-4xl mx-auto"),children:[be.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(lt,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:m("No room messages yet")})]}):be.map(V=>{if(V.kind==="pendingApproval"){const Ce=V.request,ke=Re.get(Ce.targetMemberId),ft=y.isPending&&y.variables===Ce.id,Yi=b.isPending&&b.variables===Ce.id;return t.jsx(ma,{request:Ce,member:ke,onApprove:()=>y.mutate(Ce.id),onReject:()=>b.mutate(Ce.id),isActionPending:Ki,isApprovePending:ft,isRejectPending:Yi},V.key)}const ee=V.message,ie=na(ee,Re,Ze),pe=ee.senderType==="user"?m("你"):ee.senderType==="system"?m("System"):ie?.name??m("Agent"),xe=ia(ee,Re),Me=ie?.providerId?ut.get(ie.providerId)??null:null,tt=ee.senderInvocationId?Ze.get(ee.senderInvocationId):void 0,Jt=tt?.workspaceId??void 0,je=tt?.sessionId??void 0;return t.jsx(fa,{message:ee,senderName:pe,senderMember:ie,senderProvider:Me,memberById:Re,displayContent:xe,onOpenImage:(Ce,ke)=>Z({images:Ce,index:ke}),workingDir:u,onOpenWorkspaceFile:f,onOpenPreviewUrl:d,onOpenVisualization:p,previewWorkspaceId:Jt,previewSessionId:je},V.key)}),Hr&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Sr(Hr,m("Failed to update work request"))}),r.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Sr(r.error,m("Failed to stop member work"))})]})}),!le&&t.jsxs("button",{type:"button",onClick:()=>J(),className:"absolute bottom-3 left-1/2 z-10 flex -translate-x-1/2 items-center gap-1.5 rounded-full border border-neutral-200 bg-white/90 px-3 py-1.5 text-xs text-neutral-600 shadow-md backdrop-blur-sm hover:bg-white hover:text-neutral-900 transition-colors",children:[t.jsx(Cn,{size:14}),t.jsx("span",{children:m("Back to bottom")})]})]}),t.jsx("div",{className:Q("shrink-0 border-t border-transparent bg-white",s?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:Q(o&&"max-w-4xl mx-auto"),children:[t.jsx(Xo,{invocations:Je,memberById:Re,workRequestById:Qe,onViewInvocationSession:x,onStopMember:Xi,isStopPending:r.isPending,stoppingMemberId:r.variables?.memberId??null,stopPromptInvocationId:U,onToggleStopConfirm:V=>N(ee=>ee===V?null:V)}),!n&&w,n?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:h??m("This project is read-only")}):t.jsxs("div",{className:"relative rounded-xl border border-neutral-200 bg-white shadow-sm transition-all duration-200 hover:shadow-md focus-within:border-neutral-300 focus-within:shadow-md",children:[et&&t.jsxs("div",{className:"absolute bottom-full left-3 z-20 mb-2 w-[min(24rem,calc(100vw-3rem))] overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-xl",children:[t.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:m(_?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:ve.map((V,ee)=>{const ie=E.includes(V.id),pe=ee===k;return t.jsxs("button",{type:"button",onMouseEnter:()=>v(ee),onMouseDown:xe=>{xe.preventDefault(),Fe(V)},className:Q("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",pe?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Ie,{name:V.name,avatar:V.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:V.name}),ie&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:m("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[V.providerId,V.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(zr,{size:15,className:"text-neutral-400"})]},V.id)})})]}),Te.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:Te.map(V=>t.jsxs("span",{className:"inline-flex max-w-full items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-1 text-xs text-neutral-700",children:[t.jsxs("span",{className:"truncate font-medium",children:["@",V.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:V.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>ce(V.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:m("Remove mention"),"aria-label":`${m("Remove mention")} ${V.name}`,children:t.jsx(Ve,{size:12})})]},V.id))}),t.jsx(Sn,{files:B,onRemove:K}),t.jsx("textarea",{ref:D,value:a,rows:s?1:void 0,onChange:Zt,onKeyDown:qi,onPaste:Ui,onClick:V=>we(a,V.currentTarget.selectionStart),onSelect:V=>we(a,V.currentTarget.selectionStart),placeholder:m("Message the team room..."),className:Q("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",s?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:s?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:Q("flex items-center justify-between",s?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:$i}),t.jsx("button",{type:"button",onClick:()=>T.current?.click(),title:m("Upload file"),"aria-label":m("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(kn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{g(V=>!V),C(null),requestAnimationFrame(()=>D.current?.focus())},disabled:Te.length===0&&Pe.length===0,title:m("Mention members"),"aria-label":m("Mention members"),className:Q("rounded-lg transition-colors",s?"p-1.5":"p-2",c?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",Te.length===0&&Pe.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(zr,{size:s?15:18})}),Te.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[Te.length," ",m("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{Qt()},disabled:n||O||I||!a.trim()&&!X,title:m(I?"Uploading...":O?"发送中...":"发送"),"aria-label":m(I?"Uploading...":O?"发送中...":"发送"),className:Q("rounded-lg transition-all duration-200",s?"p-1.5":"p-2",(a.trim()||X)&&!n&&!O&&!I?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",O||I?"opacity-70":""),children:t.jsx(En,{size:s?15:18})})]}),P&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:P})]})]})})]})}function pa(e){return e?e.slice(0,8):""}function Yr(e){const i=e?Date.parse(e):0;return Number.isNaN(i)?0:i}function Tr(e){return e?.workspaceKind===He.MAIN_DIRECTORY}function St(e){return e?Tr(e)?"Project directory":e.branchName:"—"}function Lu(e){return e?.workingDir||e?.worktreePath||void 0}function Mr(e,i){if(!e?.length)return[];const n=new Map((i?.members??[]).map(x=>[x.id,x])),h=new Map(e.map(x=>[x.id,x])),S=i?.mainWorkspaceId??null;return e.map(x=>{const w=x.parentWorkspaceId?h.get(x.parentWorkspaceId):void 0,s=x.ownerMemberId?n.get(x.ownerMemberId):void 0,o=!!(S&&x.id===S),u=o?"main":x.parentWorkspaceId?"child":"root",f=s?.name??(x.ownerMemberId?`Member ${pa(x.ownerMemberId)}`:void 0),d=Tr(x)?"Project directory":o?"Main workspace":u==="child"?f?`${f} workspace`:"Child workspace":i?"Root workspace":"Workspace";return{workspace:x,kind:u,roleLabel:o?"Main":u==="child"?"Child":"Root",displayName:d,ownerName:f,parentBranchName:w?St(w):void 0,isMain:o}}).sort((x,w)=>{const s=u=>u.kind==="main"?0:u.kind==="child"?1:2,o=s(x)-s(w);return o!==0?o:Yr(x.workspace.createdAt)-Yr(w.workspace.createdAt)})}function Pu(e,i,n){if(e?.length)return n&&e.some(h=>h.id===n)?n:i?.mainWorkspaceId&&e.some(h=>h.id===i.mainWorkspaceId)?i.mainWorkspaceId:e.find(h=>h.status===Oe.ACTIVE)?.id??e[0]?.id}function Tu(e,i){return!e||e.status!==Oe.ACTIVE||Tr(e)?!1:!i||e.parentWorkspaceId?!0:!!(i.mainWorkspaceId&&e.id===i.mainWorkspaceId)}function Mu(e,i,n){return e?.parentWorkspaceId?i?.find(S=>S.id===e.parentWorkspaceId)?.branchName??e.baseBranch??n:e?.baseBranch||n}const Dr={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},ga=[{key:"readRoom",label:"读房间"},{key:"postRoomMessage",label:"发房间消息"},{key:"mentionMembers",label:"提及成员"},{key:"stopMemberWork",label:"停止成员工作"},{key:"markReadyForReview",label:"标记可审查"},{key:"readFiles",label:"读文件"},{key:"writeFiles",label:"写文件"},{key:"runCommands",label:"运行命令"},{key:"readDiff",label:"读 diff"},{key:"mergeWorkspace",label:"合并工作区"}],ri=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],va=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],si=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],_a=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function mt(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...Dr},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function it(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Dr,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function er(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...Dr,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function ba(e){return Array.from(new Set(e.split(/[\n,]/).map(i=>i.trim()).filter(Boolean)))}function xa(e){return{name:e.name.trim(),aliases:ba(e.aliasesText),providerId:e.providerId.trim(),rolePrompt:e.rolePrompt.trim(),capabilities:{...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar.trim()||null}}function Vr(e,i){return e instanceof Error?e.message:i}function Gr(e){return e.membershipStatus!=="REMOVED"}function yr(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Zr(e){return yr(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function Qr(e){return ri.find(i=>i.value===e)?.label??e}function Sa(e){return si.find(i=>i.value===e)?.label??e}function De({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Jr({icon:e,title:i,description:n,action:h}){return t.jsxs("div",{className:"flex min-h-[18rem] flex-col items-center justify-center rounded-lg border border-dashed border-neutral-200 bg-white px-6 py-8 text-center",children:[t.jsx("div",{className:"mb-3 flex h-10 w-10 items-center justify-center rounded-full bg-neutral-100 text-neutral-500",children:e}),t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:i}),n?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:n}):null,h?t.jsx("div",{className:"mt-4",children:h}):null]})}function ya({isOpen:e,onClose:i,teamRun:n}){const{t:h}=se(),{data:S=[]}=tn(),{data:x=[]}=Ar(),w=rn(n.id),s=sn(n.id),o=nn(n.id),u=A.useRef(!1),[f,d]=A.useState("edit"),[p,m]=A.useState(null),[y,b]=A.useState(""),[r,a]=A.useState(mt()),[l,c]=A.useState(null),[g,_]=A.useState(null),C=n.members??[],k=A.useMemo(()=>C.filter(Gr),[C]),v=A.useMemo(()=>g&&Gr(g)&&!k.some(z=>z.id===g.id)?[...k,g]:k,[g,k]),E=p?k.find(z=>z.id===p)??null:null,R=g?.id===p?g:E,O=y?S.find(z=>z.id===y)??null:null,L=w.isPending||s.isPending||o.isPending,P=v.filter(yr).length,H=A.useMemo(()=>{const z=x.map(({provider:j,availability:I})=>({value:j.id,label:j.name+(I.type==="NOT_FOUND"?h(" (不可用)"):""),icon:t.jsx(qt,{agentType:j.agentType,className:"size-4"}),disabled:I.type==="NOT_FOUND"}));return r.providerId&&!z.some(j=>j.value===r.providerId)&&z.unshift({value:r.providerId,label:`${r.providerId}${h(" (不可用)")}`,disabled:!0}),z},[r.providerId,x,h]);A.useEffect(()=>{if(!e){u.current=!1,_(null);return}if(u.current)return;u.current=!0;const z=v[0]??null;d(z?"edit":"add-preset"),m(z?.id??null),b(""),a(z?it(z):mt()),c(null)},[v,e]),A.useEffect(()=>{g&&k.some(z=>z.id===g.id)&&_(null)},[g,k]),A.useEffect(()=>{f==="add-preset"&&O&&a(er(O))},[f,O]);const M=(z,j)=>{a(I=>({...I,[z]:j}))},F=(z,j)=>{a(I=>({...I,capabilities:{...I.capabilities,[z]:j}}))},U=z=>{d("edit"),m(z.id),b(""),a(it(z))},N=()=>{d("add-preset"),m(null);const z=O??S[0]??null;b(z?.id??""),a(z?er(z):mt())},D=()=>{d("add-custom"),m(null),b(""),a(mt())},T=!!(r.name.trim()&&r.providerId.trim()&&r.rolePrompt.trim()),B=f==="add-preset"?!!y:f==="edit"?!!(R&&T):T,q=async()=>{try{if(f==="add-preset"){if(!y)return;const j=await w.mutateAsync({memberPresetId:y});Se.success(h("Member added")),_(j),d("edit"),m(j.id),b(""),a(it(j));return}const z=xa(r);if(!z.name||!z.providerId||!z.rolePrompt){Se.error(h("Name, provider, and role prompt are required"));return}if(f==="add-custom"){const j=await w.mutateAsync({member:z});Se.success(h("Member added")),_(j),d("edit"),m(j.id),a(it(j));return}if(R){const j=await s.mutateAsync({memberId:R.id,data:z});Se.success(h("Member updated")),_(I=>I?.id===j.id?j:I),m(j.id),a(it(j))}}catch(z){Se.error(Vr(z,h("Failed to save member")))}},K=async()=>{if(l)try{if(await o.mutateAsync({memberId:l.id,stopActive:!0,cancelQueued:!0}),p===l.id){const z=v.find(j=>j.id!==l.id)??null;m(z?.id??null),d(z?"edit":"add-preset"),a(z?it(z):mt())}_(z=>z?.id===l.id?null:z),c(null),Se.success(h("Member removed"))}catch(z){Se.error(Vr(z,h("Failed to remove member")))}},$=()=>t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(At,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:h("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:h("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(ae,{type:"button",variant:"outline",size:"sm",onClick:D,disabled:L,children:[t.jsx(Ur,{size:13}),h("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:S.length===0?t.jsx(Jr,{icon:t.jsx(At,{size:18}),title:h("No member presets"),description:h("Create a custom member for this TeamRun, or add presets from Team Collaboration Settings."),action:t.jsxs(ae,{type:"button",variant:"outline",size:"sm",onClick:D,disabled:L,children:[t.jsx(gt,{size:13}),h("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:S.map(z=>{const j=y===z.id;return t.jsxs("button",{type:"button",onClick:()=>{b(z.id),a(er(z))},className:Q("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",j?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Ie,{name:z.name,avatar:z.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsx("span",{className:"block truncate text-sm font-medium text-neutral-900",children:z.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:z.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[h(Qr(z.workspacePolicy))," · ",h(Sa(z.sessionPolicy))]})]}),j?t.jsx(ct,{size:16,className:"shrink-0 text-neutral-900"}):null]},z.id)})})})]}),W=()=>{const z=f==="edit";return z&&!R?t.jsx("div",{className:"p-5",children:t.jsx(Jr,{icon:t.jsx(lt,{size:18}),title:h("Select a member"),description:h("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(ae,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:L,children:[t.jsx(gt,{size:13}),h("Add member")]})})}):t.jsxs("div",{className:"flex min-h-0 flex-col lg:flex-1",children:[t.jsx("div",{className:"border-b border-neutral-100 px-5 py-4",children:t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[z?t.jsx(Qs,{size:15,className:"text-neutral-500"}):t.jsx(gt,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:h(z?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:h(z?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),z&&R?t.jsxs(ae,{type:"button",variant:"outline",size:"sm",onClick:()=>c(R),disabled:L,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(Ln,{size:13}),h("Remove")]}):t.jsxs(ae,{type:"button",variant:"outline",size:"sm",onClick:N,disabled:L,children:[t.jsx(At,{size:13}),h("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[z&&R?t.jsxs("div",{className:"mb-4 flex items-center gap-3 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2.5",children:[t.jsx(Ie,{name:R.name,avatar:R.avatar,className:"h-9 w-9 text-xs"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:Q("h-2 w-2 shrink-0 rounded-full",Zr(R))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:R.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[R.providerId," · ",h(Qr(R.workspacePolicy))]})]})]}):null,t.jsxs("div",{className:"space-y-5",children:[t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(De,{children:h("Name")}),t.jsx("input",{value:r.name,onChange:j=>M("name",j.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(De,{children:h("Aliases")}),t.jsx("input",{value:r.aliasesText,onChange:j=>M("aliasesText",j.target.value),placeholder:h("Comma separated"),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-1.5",children:[t.jsx(De,{children:h("Provider")}),t.jsx(ze,{value:r.providerId,onChange:j=>M("providerId",j),options:H})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(De,{children:h("Avatar")}),t.jsx("input",{value:r.avatar,onChange:j=>M("avatar",j.target.value),className:"h-9 w-full rounded-lg border border-neutral-200 px-3 text-sm outline-none transition-colors focus:border-neutral-400"})]})]}),t.jsxs("div",{className:"grid grid-cols-1 gap-3 md:grid-cols-2",children:[t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(De,{children:h("Workspace policy")}),t.jsx(ze,{value:r.workspacePolicy,onChange:j=>M("workspacePolicy",j),options:ri.map(j=>({value:j.value,label:h(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(De,{children:h("Trigger policy")}),t.jsx(ze,{value:r.triggerPolicy,onChange:j=>M("triggerPolicy",j),options:va.map(j=>({value:j.value,label:h(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(De,{children:h("Session policy")}),t.jsx(ze,{value:r.sessionPolicy,onChange:j=>M("sessionPolicy",j),options:si.map(j=>({value:j.value,label:h(j.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(De,{children:h("Queue policy")}),t.jsx(ze,{value:r.queueManagementPolicy,onChange:j=>M("queueManagementPolicy",j),options:_a.map(j=>({value:j.value,label:h(j.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(De,{children:h("Role prompt")}),t.jsx("textarea",{value:r.rolePrompt,onChange:j=>M("rolePrompt",j.target.value),rows:7,className:"w-full resize-y rounded-lg border border-neutral-200 px-3 py-2 text-sm leading-relaxed outline-none transition-colors focus:border-neutral-400"})]}),t.jsxs("div",{className:"space-y-2",children:[t.jsx(De,{children:h("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:ga.map(j=>t.jsxs("label",{className:"flex min-h-9 items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 py-2 text-xs text-neutral-700",children:[t.jsx("input",{type:"checkbox",checked:!!r.capabilities[j.key],onChange:I=>F(j.key,I.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:h(j.label)})]},j.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(Ct,{isOpen:e,onClose:L?()=>{}:i,title:h("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(ae,{type:"button",variant:"outline",onClick:i,disabled:L,children:h("Close")}),t.jsx(ae,{type:"button",onClick:q,disabled:L||!B,children:h(L?"Processing...":f==="edit"?"Save member":"Add member")})]}),children:t.jsxs("div",{className:"grid min-h-0 grid-cols-1 overflow-visible rounded-lg border border-neutral-200 bg-white lg:h-[min(42rem,calc(100vh-13rem))] lg:min-h-[34rem] lg:grid-cols-[20rem_minmax(0,1fr)] lg:overflow-hidden",children:[t.jsxs("aside",{className:"flex min-h-0 flex-col border-b border-neutral-200 bg-neutral-50/70 lg:border-b-0 lg:border-r",children:[t.jsx("div",{className:"border-b border-neutral-200 px-4 py-4",children:t.jsxs("div",{className:"flex items-center justify-between gap-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm font-semibold text-neutral-900",children:[t.jsx(lt,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:h("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[v.length," ",h("active")," · ",P," ",h("working")]})]}),t.jsx(ae,{type:"button",size:"icon-sm",variant:"outline",onClick:N,disabled:L,title:h("Add member"),children:t.jsx(gt,{size:14})})]})}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-2 lg:min-h-0 lg:max-h-none lg:flex-1",children:v.length===0?t.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-3 py-5 text-center text-xs text-neutral-400",children:h("No active members")}):t.jsx("div",{className:"space-y-1",children:v.map(z=>{const j=f==="edit"&&p===z.id;return t.jsxs("button",{type:"button",onClick:()=>U(z),className:Q("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",j?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Ie,{name:z.name,avatar:z.avatar,className:"h-8 w-8 text-[11px]"}),t.jsxs("span",{className:"min-w-0 flex-1",children:[t.jsxs("span",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 shrink-0 rounded-full",Zr(z))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:z.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:z.providerId})]}),t.jsx(jo,{size:13,className:Q("shrink-0 text-neutral-300 transition-opacity",j?"opacity-100":"opacity-0 group-hover:opacity-100")})]},z.id)})})}),t.jsx("div",{className:"border-t border-neutral-200 p-2",children:t.jsxs("div",{className:"grid grid-cols-2 gap-1",children:[t.jsxs("button",{type:"button",onClick:N,disabled:L,className:Q("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",f==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(At,{size:12}),h("Preset")]}),t.jsxs("button",{type:"button",onClick:D,disabled:L,className:Q("inline-flex h-8 items-center justify-center gap-1.5 rounded-md text-xs font-medium transition-colors disabled:cursor-not-allowed disabled:opacity-50",f==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Ur,{size:12}),h("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:f==="add-preset"?$():W()})]})}),t.jsx(An,{isOpen:!!l,onClose:()=>c(null),onConfirm:K,title:h("Remove member"),variant:"danger",isLoading:o.isPending,confirmText:h("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:l?h("Remove this member from future TeamRun work?"):""}),l&&yr(l)?t.jsxs("div",{className:"flex items-start gap-2 rounded-md border border-red-200 bg-red-50 px-3 py-2 text-left text-red-700",children:[t.jsx(wt,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:h("确认后会停止当前工作并取消队列")})]}):null]})})]})}const wa=[],Ca=[],ka=[],Ea=240;function ja(e){switch(e){case"RUNNING":return"running";case"WAITING":case"WAITING_ROOM_REPLY":return"waiting room reply";case"QUEUED":return"queued";case"SESSION_ENDED":return"session ended";case"PENDING_APPROVAL":return"pending approval";case"REMOVED":return"removed";default:return"idle"}}const es={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function tr(e){if(!e)return"";const i=new Date(e);return Number.isNaN(i.getTime())?"":i.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ts(e,i){return e instanceof Error?e.message:i}function Na(e,i=Ea){const n=(e??"").replace(/\s+/g," ").trim();return n.length<=i?n:`${n.slice(0,i-3).trimEnd()}...`}function Lt(e){return e?e.instructionPreview??Na(e.instruction):""}function Ra(e){switch(e){case"running":return"Running";case"waiting room reply":return"Waiting room reply";case"queued":return"Queued";case"session ended":return"Session ended";case"pending approval":return"Pending approval";case"removed":return"Removed";case"idle":return"Idle"}}function Aa(e){switch(e){case"running":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"waiting room reply":return"border-amber-200 bg-amber-50 text-amber-700";case"queued":case"session ended":return"border-blue-200 bg-blue-50 text-blue-700";case"pending approval":return"border-neutral-200 bg-neutral-50 text-neutral-600";case"removed":return"border-neutral-200 bg-neutral-50 text-neutral-400";case"idle":return"border-neutral-200 bg-white text-neutral-500"}}function La(e){switch(e){case"running":return"bg-emerald-500";case"waiting room reply":return"bg-amber-500";case"queued":case"session ended":return"bg-blue-500";case"pending approval":return"bg-neutral-400";case"removed":return"bg-neutral-300";case"idle":return"bg-neutral-300"}}function Pa(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Ta(e){switch(e){case"RUNNING":return"border-emerald-200 bg-emerald-50 text-emerald-700";case"WAITING_ROOM_REPLY":return"border-amber-200 bg-amber-50 text-amber-700";case"QUEUED":case"SESSION_ENDED":return"border-blue-200 bg-blue-50 text-blue-700";case"COMPLETED":return"border-neutral-200 bg-neutral-50 text-neutral-700";case"FAILED":return"border-red-200 bg-red-50 text-red-700";case"CANCELLED":return"border-neutral-200 bg-white text-neutral-500"}}function Ma(e){switch(e){case Oe.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Oe.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Oe.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Oe.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Da(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Ba(e){return[...e].sort((i,n)=>Date.parse(n.updatedAt??n.createdAt??"")-Date.parse(i.updatedAt??i.createdAt??""))}function Oa(e,i){return i.find(n=>n.memberId===e.id&&Kt.has(n.status))}function Du({teamRun:e,workspaces:i,selectedWorkspaceId:n,onSelectWorkspace:h,onViewInvocationSession:S}){const{t:x}=se(),w=Ps(e.id),s=Ts(e.id),o=Ms(e.id),[u,f]=A.useState(null),[d,p]=A.useState(null),[m,y]=A.useState(!1),[b,r]=A.useState(!1),a=e.members??wa,l=A.useMemo(()=>a.filter(M=>M.membershipStatus!=="REMOVED"),[a]),c=e.workRequests??Ca,g=e.invocations??ka,_=A.useMemo(()=>Mr(i,e),[e,i]),C=A.useMemo(()=>new Map(c.map(M=>[M.id,M])),[c]),k=A.useMemo(()=>[...c].filter(M=>M.status==="PENDING_APPROVAL").sort((M,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(M.updatedAt??M.createdAt??"")),[c]),v=A.useMemo(()=>[...c].filter(M=>M.status==="QUEUED").sort((M,F)=>Date.parse(F.updatedAt??F.createdAt??"")-Date.parse(M.updatedAt??M.createdAt??"")),[c]),E=A.useMemo(()=>[...a].map(M=>({member:M,status:ja(M.status)})).sort((M,F)=>es[M.status]-es[F.status]),[a]),R=w.isError?w.error:s.isError?s.error:null,O=w.isPending||s.isPending,L=_.find(M=>M.workspace.id===n),P=e.messages??[],H=E.filter(({status:M})=>M==="running"||M==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(ya,{isOpen:b,onClose:()=>r(!1),teamRun:e}),t.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(gr,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:x("Team Status")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:[t.jsx("span",{children:x("Team mode")}),t.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),t.jsxs("div",{className:"flex items-center gap-3 border-b border-neutral-100 px-4 py-1.5 shrink-0 text-[10px] text-neutral-500",children:[t.jsxs("span",{className:"inline-flex items-center gap-1",title:x("Messages"),children:[t.jsx(Pn,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:P.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:x("Members"),children:[t.jsx(lt,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:H>0?`${H}/${l.length}`:l.length}),H>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),v.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:x("Queue"),children:[t.jsx(Ue,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:v.length})]}),k.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:x("Pending approval"),children:[t.jsx(Ue,{size:11}),t.jsx("span",{className:"tabular-nums",children:k.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[k.length>0&&t.jsxs("section",{className:"space-y-2",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-amber-600",children:[t.jsx(Ue,{size:13}),t.jsx("span",{children:x("Pending approval")}),t.jsx("span",{className:"ml-auto rounded-full bg-amber-100 px-1.5 py-0.5 text-[10px] font-semibold text-amber-700",children:k.length})]}),t.jsx("div",{className:"space-y-1.5",children:k.map(M=>{const F=a.find(D=>D.id===M.targetMemberId),U=w.isPending&&w.variables===M.id,N=s.isPending&&s.variables===M.id;return t.jsxs("div",{className:"rounded-md border border-amber-200 bg-amber-50/50 px-3 py-2",children:[t.jsx("div",{className:"flex items-start justify-between gap-2",children:t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ie,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??M.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:Lt(M)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:x(Pa(M.requesterType))}),t.jsx("span",{children:tr(M.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>w.mutate(M.id),disabled:O,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-emerald-200 bg-emerald-50 px-2 text-[11px] font-medium text-emerald-700 transition-colors hover:bg-emerald-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(ct,{size:11}),t.jsx("span",{className:"truncate",children:x(U?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>s.mutate(M.id),disabled:O,className:"inline-flex h-6 min-w-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ve,{size:11}),t.jsx("span",{className:"truncate",children:x(N?"Rejecting":"Reject")})]})]})]},M.id)})}),R&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:ts(R,x("Failed to update work request"))})]}),t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(lt,{size:13}),t.jsx("span",{children:x("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:l.length}),t.jsx("button",{type:"button",onClick:()=>r(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:x("Manage Team Members"),"aria-label":x("Manage Team Members"),children:t.jsx(Qs,{size:13})})]}),a.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:x("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:E.map(({member:M,status:F})=>{const U=Oa(M,g),N=Ba(g.filter(W=>W.memberId===M.id)),D=U?C.get(U.workRequestId):void 0,T=d===M.id,B=F==="running"||F==="waiting room reply",q=B&&!!U,K=u===M.id,$=o.isPending&&o.variables?.memberId===M.id;return t.jsxs("div",{className:Q("bg-white",T&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Ie,{name:M.name,avatar:M.avatar,className:"h-6 w-6 text-[10px] shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 shrink-0 rounded-full",La(F))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:M.name}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Aa(F)),children:x(Ra(F))})]}),B&&D?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Lt(D)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[q&&t.jsx("button",{type:"button",onClick:()=>f(K?null:M.id),disabled:o.isPending,className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-red-50 hover:text-red-600 disabled:cursor-not-allowed disabled:opacity-50",title:x("Stop"),"aria-label":x("Stop"),children:t.jsx(Ot,{size:12})}),U?.sessionId&&S&&t.jsx("button",{type:"button",onClick:()=>S(U.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:x("View log"),"aria-label":x("View log"),children:t.jsx(_r,{size:12})}),t.jsx("button",{type:"button",onClick:()=>p(T?null:M.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:x("Details"),"aria-label":x("Details"),"aria-expanded":T,children:T?t.jsx(We,{size:13}):t.jsx(Xe,{size:13})})]})]}),q&&K&&t.jsxs("div",{className:"mx-3 mb-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[t.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:x("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:M.id,cancelQueued:!1},{onSuccess:()=>f(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Ot,{size:10}),t.jsx("span",{children:$&&o.variables?.cancelQueued===!1?x("Stopping"):x("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{o.mutate({memberId:M.id,cancelQueued:!0},{onSuccess:()=>f(null)})},disabled:o.isPending,className:"inline-flex h-6 items-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[t.jsx(Zs,{size:10}),t.jsx("span",{children:$&&o.variables?.cancelQueued===!0?x("Stopping"):x("Stop + clear queue")})]})]})]}),T&&t.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[t.jsxs("div",{className:"mb-1.5 flex flex-wrap items-center gap-1.5 text-[10px] text-neutral-400",children:[t.jsx("span",{children:M.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:M.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:M.sessionPolicy==="resume_last"?x("Resume last session"):x("New session per request")})]}),t.jsxs("div",{className:"mb-1.5 flex items-center justify-between gap-2",children:[t.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:x("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:N.length})]}),N.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:x("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:N.map(W=>{const z=C.get(W.workRequestId),j=!!(W.sessionId&&S);return t.jsx("div",{className:"rounded-md border border-neutral-100 bg-white px-2.5 py-1.5",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:Q("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Ta(W.status)),children:W.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:tr(W.updatedAt??W.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Lt(z)||W.workRequestId})]}),j&&t.jsxs("button",{type:"button",onClick:()=>W.sessionId&&S?.(W.sessionId),className:"inline-flex h-5 shrink-0 items-center gap-1 rounded border border-neutral-200 bg-white px-1.5 text-[10px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100",title:x("View log"),"aria-label":x("View log"),children:[t.jsx(_r,{size:10}),t.jsx("span",{children:x("Log")})]})]})},W.id)})})]}),E[E.length-1]?.member.id!==M.id&&!T&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},M.id)})}),o.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:ts(o.error,x("Failed to stop member work"))})]}),v.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[t.jsx(Ue,{size:13}),t.jsx("span",{children:x("Queue")}),t.jsx("span",{className:"ml-auto rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:v.length})]}),t.jsx("div",{className:"space-y-1",children:v.map(M=>{const F=a.find(U=>U.id===M.targetMemberId);return t.jsx("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx(Ie,{name:F?.name??"Agent",avatar:F?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:F?.name??M.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Lt(M)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:tr(M.createdAt)})]})},M.id)})})]}),_.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>y(M=>!M),className:"flex w-full items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500 transition-colors hover:text-neutral-700","aria-expanded":m,"aria-label":x("Workspaces"),children:[t.jsx(gr,{size:13}),t.jsx("span",{children:x("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[L&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:St(L.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:_.length}),m?t.jsx(We,{size:13,className:"text-neutral-400"}):t.jsx(Xe,{size:13,className:"text-neutral-400"})]})]}),m&&t.jsx("div",{className:"space-y-1.5",children:_.map(M=>{const F=n===M.workspace.id;return t.jsx("div",{className:Q("rounded-md border bg-white px-3 py-2",F?"border-neutral-400 shadow-sm":"border-neutral-200"),children:t.jsxs("div",{className:"flex items-start justify-between gap-2",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:x(M.displayName)}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Da(M.roleLabel)),children:x(M.roleLabel)}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",Ma(M.workspace.status)),children:M.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:St(M.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[M.ownerName&&t.jsxs("span",{children:[x("Owner"),": ",M.ownerName]}),M.parentBranchName&&t.jsxs("span",{children:[x("Parent"),": ",M.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>h?.(M.workspace.id),disabled:!h||F,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-neutral-50 px-2 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:x("View workspace"),children:[F?t.jsx(ct,{size:11}):t.jsx(Ws,{size:11}),t.jsx("span",{children:x(F?"Selected":"Select")})]})]})},M.workspace.id)})})]}),k.length===0&&v.length===0&&E.every(({status:M})=>M==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:x("All members idle")})]})]})}var rr={exports:{}},rs;function Ia(){return rs||(rs=1,(function(e,i){(function(n,h){e.exports=h()})(self,(()=>(()=>{var n={4567:function(w,s,o){var u=this&&this.__decorate||function(c,g,_,C){var k,v=arguments.length,E=v<3?g:C===null?C=Object.getOwnPropertyDescriptor(g,_):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(c,g,_,C);else for(var R=c.length-1;R>=0;R--)(k=c[R])&&(E=(v<3?k(E):v>3?k(g,_,E):k(g,_))||E);return v>3&&E&&Object.defineProperty(g,_,E),E},f=this&&this.__param||function(c,g){return function(_,C){g(_,C,c)}};Object.defineProperty(s,"__esModule",{value:!0}),s.AccessibilityManager=void 0;const d=o(9042),p=o(6114),m=o(9924),y=o(844),b=o(5596),r=o(4725),a=o(3656);let l=s.AccessibilityManager=class extends y.Disposable{constructor(c,g){super(),this._terminal=c,this._renderService=g,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="",this._accessibilityContainer=document.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=document.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let _=0;_<this._terminal.rows;_++)this._rowElements[_]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[_]);if(this._topBoundaryFocusListener=_=>this._handleBoundaryFocus(_,0),this._bottomBoundaryFocusListener=_=>this._handleBoundaryFocus(_,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions(),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=document.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this.register(new m.TimeBasedDebouncer(this._renderRows.bind(this))),!this._terminal.element)throw new Error("Cannot enable accessibility before Terminal.open");this._terminal.element.insertAdjacentElement("afterbegin",this._accessibilityContainer),this.register(this._terminal.onResize((_=>this._handleResize(_.rows)))),this.register(this._terminal.onRender((_=>this._refreshRows(_.start,_.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((_=>this._handleChar(_)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
9
+ `)))),this.register(this._terminal.onA11yTab((_=>this._handleTab(_)))),this.register(this._terminal.onKey((_=>this._handleKey(_.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new b.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,a.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(c){for(let g=0;g<c;g++)this._handleChar(" ")}_handleChar(c){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==c&&(this._charsToAnnounce+=c):this._charsToAnnounce+=c,c===`
10
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=d.tooMuchOutput)),p.isMac&&this._liveRegion.textContent&&this._liveRegion.textContent.length>0&&!this._liveRegion.parentNode&&setTimeout((()=>{this._accessibilityContainer.appendChild(this._liveRegion)}),0))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0,p.isMac&&this._liveRegion.remove()}_handleKey(c){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(c)||this._charsToConsume.push(c)}_refreshRows(c,g){this._liveRegionDebouncer.refresh(c,g,this._terminal.rows)}_renderRows(c,g){const _=this._terminal.buffer,C=_.lines.length.toString();for(let k=c;k<=g;k++){const v=_.translateBufferLineToString(_.ydisp+k,!0),E=(_.ydisp+k+1).toString(),R=this._rowElements[k];R&&(v.length===0?R.innerText=" ":R.textContent=v,R.setAttribute("aria-posinset",E),R.setAttribute("aria-setsize",C))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(c,g){const _=c.target,C=this._rowElements[g===0?1:this._rowElements.length-2];if(_.getAttribute("aria-posinset")===(g===0?"1":`${this._terminal.buffer.lines.length}`)||c.relatedTarget!==C)return;let k,v;if(g===0?(k=_,v=this._rowElements.pop(),this._rowContainer.removeChild(v)):(k=this._rowElements.shift(),v=_,this._rowContainer.removeChild(k)),k.removeEventListener("focus",this._topBoundaryFocusListener),v.removeEventListener("focus",this._bottomBoundaryFocusListener),g===0){const E=this._createAccessibilityTreeNode();this._rowElements.unshift(E),this._rowContainer.insertAdjacentElement("afterbegin",E)}else{const E=this._createAccessibilityTreeNode();this._rowElements.push(E),this._rowContainer.appendChild(E)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(g===0?-1:1),this._rowElements[g===0?1:this._rowElements.length-2].focus(),c.preventDefault(),c.stopImmediatePropagation()}_handleResize(c){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let g=this._rowContainer.children.length;g<this._terminal.rows;g++)this._rowElements[g]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[g]);for(;this._rowElements.length>c;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const c=document.createElement("div");return c.setAttribute("role","listitem"),c.tabIndex=-1,this._refreshRowDimensions(c),c}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){this._accessibilityContainer.style.width=`${this._renderService.dimensions.css.canvas.width}px`,this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let c=0;c<this._terminal.rows;c++)this._refreshRowDimensions(this._rowElements[c])}}_refreshRowDimensions(c){c.style.height=`${this._renderService.dimensions.css.cell.height}px`}};s.AccessibilityManager=l=u([f(1,r.IRenderService)],l)},3614:(w,s)=>{function o(p){return p.replace(/\r?\n/g,"\r")}function u(p,m){return m?"\x1B[200~"+p+"\x1B[201~":p}function f(p,m,y,b){p=u(p=o(p),y.decPrivateModes.bracketedPasteMode&&b.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(p,!0),m.value=""}function d(p,m,y){const b=y.getBoundingClientRect(),r=p.clientX-b.left-10,a=p.clientY-b.top-10;m.style.width="20px",m.style.height="20px",m.style.left=`${r}px`,m.style.top=`${a}px`,m.style.zIndex="1000",m.focus()}Object.defineProperty(s,"__esModule",{value:!0}),s.rightClickHandler=s.moveTextAreaUnderMouseCursor=s.paste=s.handlePasteEvent=s.copyHandler=s.bracketTextForPaste=s.prepareTextForTerminal=void 0,s.prepareTextForTerminal=o,s.bracketTextForPaste=u,s.copyHandler=function(p,m){p.clipboardData&&p.clipboardData.setData("text/plain",m.selectionText),p.preventDefault()},s.handlePasteEvent=function(p,m,y,b){p.stopPropagation(),p.clipboardData&&f(p.clipboardData.getData("text/plain"),m,y,b)},s.paste=f,s.moveTextAreaUnderMouseCursor=d,s.rightClickHandler=function(p,m,y,b,r){d(p,m,y),r&&b.rightClickSelect(p),m.value=b.selectionText,m.select()}},7239:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ColorContrastCache=void 0;const u=o(1505);s.ColorContrastCache=class{constructor(){this._color=new u.TwoKeyMap,this._css=new u.TwoKeyMap}setCss(f,d,p){this._css.set(f,d,p)}getCss(f,d){return this._css.get(f,d)}setColor(f,d,p){this._color.set(f,d,p)}getColor(f,d){return this._color.get(f,d)}clear(){this._color.clear(),this._css.clear()}}},3656:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.addDisposableDomListener=void 0,s.addDisposableDomListener=function(o,u,f,d){o.addEventListener(u,f,d);let p=!1;return{dispose:()=>{p||(p=!0,o.removeEventListener(u,f,d))}}}},6465:function(w,s,o){var u=this&&this.__decorate||function(r,a,l,c){var g,_=arguments.length,C=_<3?a:c===null?c=Object.getOwnPropertyDescriptor(a,l):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(r,a,l,c);else for(var k=r.length-1;k>=0;k--)(g=r[k])&&(C=(_<3?g(C):_>3?g(a,l,C):g(a,l))||C);return _>3&&C&&Object.defineProperty(a,l,C),C},f=this&&this.__param||function(r,a){return function(l,c){a(l,c,r)}};Object.defineProperty(s,"__esModule",{value:!0}),s.Linkifier2=void 0;const d=o(3656),p=o(8460),m=o(844),y=o(2585);let b=s.Linkifier2=class extends m.Disposable{get currentLink(){return this._currentLink}constructor(r){super(),this._bufferService=r,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new p.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new p.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,m.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,m.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(r){return this._linkProviders.push(r),{dispose:()=>{const a=this._linkProviders.indexOf(r);a!==-1&&this._linkProviders.splice(a,1)}}}attachToDom(r,a,l){this._element=r,this._mouseService=a,this._renderService=l,this.register((0,d.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,d.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,d.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,d.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(r){if(this._lastMouseEvent=r,!this._element||!this._mouseService)return;const a=this._positionFromMouseEvent(r,this._element,this._mouseService);if(!a)return;this._isMouseOut=!1;const l=r.composedPath();for(let c=0;c<l.length;c++){const g=l[c];if(g.classList.contains("xterm"))break;if(g.classList.contains("xterm-hover"))return}this._lastBufferCell&&a.x===this._lastBufferCell.x&&a.y===this._lastBufferCell.y||(this._handleHover(a),this._lastBufferCell=a)}_handleHover(r){if(this._activeLine!==r.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(r,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,r)||(this._clearCurrentLink(),this._askForLink(r,!0))}_askForLink(r,a){var l,c;this._activeProviderReplies&&a||((l=this._activeProviderReplies)===null||l===void 0||l.forEach((_=>{_?.forEach((C=>{C.link.dispose&&C.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=r.y);let g=!1;for(const[_,C]of this._linkProviders.entries())a?!((c=this._activeProviderReplies)===null||c===void 0)&&c.get(_)&&(g=this._checkLinkProviderResult(_,r,g)):C.provideLinks(r.y,(k=>{var v,E;if(this._isMouseOut)return;const R=k?.map((O=>({link:O})));(v=this._activeProviderReplies)===null||v===void 0||v.set(_,R),g=this._checkLinkProviderResult(_,r,g),((E=this._activeProviderReplies)===null||E===void 0?void 0:E.size)===this._linkProviders.length&&this._removeIntersectingLinks(r.y,this._activeProviderReplies)}))}_removeIntersectingLinks(r,a){const l=new Set;for(let c=0;c<a.size;c++){const g=a.get(c);if(g)for(let _=0;_<g.length;_++){const C=g[_],k=C.link.range.start.y<r?0:C.link.range.start.x,v=C.link.range.end.y>r?this._bufferService.cols:C.link.range.end.x;for(let E=k;E<=v;E++){if(l.has(E)){g.splice(_--,1);break}l.add(E)}}}}_checkLinkProviderResult(r,a,l){var c;if(!this._activeProviderReplies)return l;const g=this._activeProviderReplies.get(r);let _=!1;for(let C=0;C<r;C++)this._activeProviderReplies.has(C)&&!this._activeProviderReplies.get(C)||(_=!0);if(!_&&g){const C=g.find((k=>this._linkAtPosition(k.link,a)));C&&(l=!0,this._handleNewLink(C))}if(this._activeProviderReplies.size===this._linkProviders.length&&!l)for(let C=0;C<this._activeProviderReplies.size;C++){const k=(c=this._activeProviderReplies.get(C))===null||c===void 0?void 0:c.find((v=>this._linkAtPosition(v.link,a)));if(k){l=!0,this._handleNewLink(k);break}}return l}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(r){if(!this._element||!this._mouseService||!this._currentLink)return;const a=this._positionFromMouseEvent(r,this._element,this._mouseService);a&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,a)&&this._currentLink.link.activate(r,this._currentLink.link.text)}_clearCurrentLink(r,a){this._element&&this._currentLink&&this._lastMouseEvent&&(!r||!a||this._currentLink.link.range.start.y>=r&&this._currentLink.link.range.end.y<=a)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,m.disposeArray)(this._linkCacheDisposables))}_handleNewLink(r){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const a=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);a&&this._linkAtPosition(r.link,a)&&(this._currentLink=r,this._currentLink.state={decorations:{underline:r.link.decorations===void 0||r.link.decorations.underline,pointerCursor:r.link.decorations===void 0||r.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,r.link,this._lastMouseEvent),r.link.decorations={},Object.defineProperties(r.link.decorations,{pointerCursor:{get:()=>{var l,c;return(c=(l=this._currentLink)===null||l===void 0?void 0:l.state)===null||c===void 0?void 0:c.decorations.pointerCursor},set:l=>{var c,g;!((c=this._currentLink)===null||c===void 0)&&c.state&&this._currentLink.state.decorations.pointerCursor!==l&&(this._currentLink.state.decorations.pointerCursor=l,this._currentLink.state.isHovered&&((g=this._element)===null||g===void 0||g.classList.toggle("xterm-cursor-pointer",l)))}},underline:{get:()=>{var l,c;return(c=(l=this._currentLink)===null||l===void 0?void 0:l.state)===null||c===void 0?void 0:c.decorations.underline},set:l=>{var c,g,_;!((c=this._currentLink)===null||c===void 0)&&c.state&&((_=(g=this._currentLink)===null||g===void 0?void 0:g.state)===null||_===void 0?void 0:_.decorations.underline)!==l&&(this._currentLink.state.decorations.underline=l,this._currentLink.state.isHovered&&this._fireUnderlineEvent(r.link,l))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((l=>{if(!this._currentLink)return;const c=l.start===0?0:l.start+1+this._bufferService.buffer.ydisp,g=this._bufferService.buffer.ydisp+1+l.end;if(this._currentLink.link.range.start.y>=c&&this._currentLink.link.range.end.y<=g&&(this._clearCurrentLink(c,g),this._lastMouseEvent&&this._element)){const _=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);_&&this._askForLink(_,!1)}}))))}_linkHover(r,a,l){var c;!((c=this._currentLink)===null||c===void 0)&&c.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(a,!0),this._currentLink.state.decorations.pointerCursor&&r.classList.add("xterm-cursor-pointer")),a.hover&&a.hover(l,a.text)}_fireUnderlineEvent(r,a){const l=r.range,c=this._bufferService.buffer.ydisp,g=this._createLinkUnderlineEvent(l.start.x-1,l.start.y-c-1,l.end.x,l.end.y-c-1,void 0);(a?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(g)}_linkLeave(r,a,l){var c;!((c=this._currentLink)===null||c===void 0)&&c.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(a,!1),this._currentLink.state.decorations.pointerCursor&&r.classList.remove("xterm-cursor-pointer")),a.leave&&a.leave(l,a.text)}_linkAtPosition(r,a){const l=r.range.start.y*this._bufferService.cols+r.range.start.x,c=r.range.end.y*this._bufferService.cols+r.range.end.x,g=a.y*this._bufferService.cols+a.x;return l<=g&&g<=c}_positionFromMouseEvent(r,a,l){const c=l.getCoords(r,a,this._bufferService.cols,this._bufferService.rows);if(c)return{x:c[0],y:c[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(r,a,l,c,g){return{x1:r,y1:a,x2:l,y2:c,cols:this._bufferService.cols,fg:g}}};s.Linkifier2=b=u([f(0,y.IBufferService)],b)},9042:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.tooMuchOutput=s.promptLabel=void 0,s.promptLabel="Terminal input",s.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(w,s,o){var u=this&&this.__decorate||function(b,r,a,l){var c,g=arguments.length,_=g<3?r:l===null?l=Object.getOwnPropertyDescriptor(r,a):l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(b,r,a,l);else for(var C=b.length-1;C>=0;C--)(c=b[C])&&(_=(g<3?c(_):g>3?c(r,a,_):c(r,a))||_);return g>3&&_&&Object.defineProperty(r,a,_),_},f=this&&this.__param||function(b,r){return function(a,l){r(a,l,b)}};Object.defineProperty(s,"__esModule",{value:!0}),s.OscLinkProvider=void 0;const d=o(511),p=o(2585);let m=s.OscLinkProvider=class{constructor(b,r,a){this._bufferService=b,this._optionsService=r,this._oscLinkService=a}provideLinks(b,r){var a;const l=this._bufferService.buffer.lines.get(b-1);if(!l)return void r(void 0);const c=[],g=this._optionsService.rawOptions.linkHandler,_=new d.CellData,C=l.getTrimmedLength();let k=-1,v=-1,E=!1;for(let R=0;R<C;R++)if(v!==-1||l.hasContent(R)){if(l.loadCell(R,_),_.hasExtendedAttrs()&&_.extended.urlId){if(v===-1){v=R,k=_.extended.urlId;continue}E=_.extended.urlId!==k}else v!==-1&&(E=!0);if(E||v!==-1&&R===C-1){const O=(a=this._oscLinkService.getLinkData(k))===null||a===void 0?void 0:a.uri;if(O){const L={start:{x:v+1,y:b},end:{x:R+(E||R!==C-1?0:1),y:b}};let P=!1;if(!g?.allowNonHttpProtocols)try{const H=new URL(O);["http:","https:"].includes(H.protocol)||(P=!0)}catch{P=!0}P||c.push({text:O,range:L,activate:(H,M)=>g?g.activate(H,M,L):y(0,M),hover:(H,M)=>{var F;return(F=g?.hover)===null||F===void 0?void 0:F.call(g,H,M,L)},leave:(H,M)=>{var F;return(F=g?.leave)===null||F===void 0?void 0:F.call(g,H,M,L)}})}E=!1,_.hasExtendedAttrs()&&_.extended.urlId?(v=R,k=_.extended.urlId):(v=-1,k=-1)}}r(c)}};function y(b,r){if(confirm(`Do you want to navigate to ${r}?
11
+
12
+ WARNING: This link could potentially be dangerous`)){const a=window.open();if(a){try{a.opener=null}catch{}a.location.href=r}else console.warn("Opening link blocked as opener could not be cleared")}}s.OscLinkProvider=m=u([f(0,p.IBufferService),f(1,p.IOptionsService),f(2,p.IOscLinkService)],m)},6193:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.RenderDebouncer=void 0,s.RenderDebouncer=class{constructor(o,u){this._parentWindow=o,this._renderCallback=u,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(o){return this._refreshCallbacks.push(o),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(o,u,f){this._rowCount=f,o=o!==void 0?o:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u,this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return void this._runRefreshCallbacks();const o=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,u),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const o of this._refreshCallbacks)o(0);this._refreshCallbacks=[]}}},5596:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ScreenDprMonitor=void 0;const u=o(844);class f extends u.Disposable{constructor(p){super(),this._parentWindow=p,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,u.toDisposable)((()=>{this.clearListener()})))}setListener(p){this._listener&&this.clearListener(),this._listener=p,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var p;this._outerListener&&((p=this._resolutionMediaMatchList)===null||p===void 0||p.removeListener(this._outerListener),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._resolutionMediaMatchList=this._parentWindow.matchMedia(`screen and (resolution: ${this._parentWindow.devicePixelRatio}dppx)`),this._resolutionMediaMatchList.addListener(this._outerListener))}clearListener(){this._resolutionMediaMatchList&&this._listener&&this._outerListener&&(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._listener=void 0,this._outerListener=void 0)}}s.ScreenDprMonitor=f},3236:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Terminal=void 0;const u=o(3614),f=o(3656),d=o(6465),p=o(9042),m=o(3730),y=o(1680),b=o(3107),r=o(5744),a=o(2950),l=o(1296),c=o(428),g=o(4269),_=o(5114),C=o(8934),k=o(3230),v=o(9312),E=o(4725),R=o(6731),O=o(8055),L=o(8969),P=o(8460),H=o(844),M=o(6114),F=o(8437),U=o(2584),N=o(7399),D=o(5941),T=o(9074),B=o(2585),q=o(5435),K=o(4567),$=typeof window<"u"?window.document:null;class W extends L.CoreTerminal{get onFocus(){return this._onFocus.event}get onBlur(){return this._onBlur.event}get onA11yChar(){return this._onA11yCharEmitter.event}get onA11yTab(){return this._onA11yTabEmitter.event}get onWillOpen(){return this._onWillOpen.event}constructor(j={}){super(j),this.browser=M,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new H.MutableDisposable),this._onCursorMove=this.register(new P.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new P.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new P.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new P.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new P.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new P.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new P.EventEmitter),this._onBlur=this.register(new P.EventEmitter),this._onA11yCharEmitter=this.register(new P.EventEmitter),this._onA11yTabEmitter=this.register(new P.EventEmitter),this._onWillOpen=this.register(new P.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(d.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(m.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(T.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((I,X)=>this.refresh(I,X)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((I=>this._reportWindowsOptions(I)))),this.register(this._inputHandler.onColor((I=>this._handleColorEvent(I)))),this.register((0,P.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,P.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,P.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,P.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((I=>this._afterResize(I.cols,I.rows)))),this.register((0,H.toDisposable)((()=>{var I,X;this._customKeyEventHandler=void 0,(X=(I=this.element)===null||I===void 0?void 0:I.parentNode)===null||X===void 0||X.removeChild(this.element)})))}_handleColorEvent(j){if(this._themeService)for(const I of j){let X,Y="";switch(I.index){case 256:X="foreground",Y="10";break;case 257:X="background",Y="11";break;case 258:X="cursor",Y="12";break;default:X="ansi",Y="4;"+I.index}switch(I.type){case 0:const Z=O.color.toColorRGB(X==="ansi"?this._themeService.colors.ansi[I.index]:this._themeService.colors[X]);this.coreService.triggerDataEvent(`${U.C0.ESC}]${Y};${(0,D.toRgbString)(Z)}${U.C1_ESCAPED.ST}`);break;case 1:if(X==="ansi")this._themeService.modifyColors((G=>G.ansi[I.index]=O.rgba.toColor(...I.color)));else{const G=X;this._themeService.modifyColors((te=>te[G]=O.rgba.toColor(...I.color)))}break;case 2:this._themeService.restoreColor(I.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(j){j?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(K.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(j){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.C0.ESC+"[I"),this.updateCursorStyle(j),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var j;return(j=this.textarea)===null||j===void 0?void 0:j.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(U.C0.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;const j=this.buffer.ybase+this.buffer.y,I=this.buffer.lines.get(j);if(!I)return;const X=Math.min(this.buffer.x,this.cols-1),Y=this._renderService.dimensions.css.cell.height,Z=I.getWidth(X),G=this._renderService.dimensions.css.cell.width*Z,te=this.buffer.y*this._renderService.dimensions.css.cell.height,le=X*this._renderService.dimensions.css.cell.width;this.textarea.style.left=le+"px",this.textarea.style.top=te+"px",this.textarea.style.width=G+"px",this.textarea.style.height=Y+"px",this.textarea.style.lineHeight=Y+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",(I=>{this.hasSelection()&&(0,u.copyHandler)(I,this._selectionService)})));const j=I=>(0,u.handlePasteEvent)(I,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",j)),this.register((0,f.addDisposableDomListener)(this.element,"paste",j)),M.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(I=>{I.button===2&&(0,u.rightClickHandler)(I,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",(I=>{(0,u.rightClickHandler)(I,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),M.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",(I=>{I.button===1&&(0,u.moveTextAreaUnderMouseCursor)(I,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",(j=>this._keyUp(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",(j=>this._keyDown(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",(j=>this._keyPress(j)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",(j=>this._compositionHelper.compositionupdate(j)))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,f.addDisposableDomListener)(this.textarea,"input",(j=>this._inputEvent(j)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(j){var I;if(!j)throw new Error("Terminal requires a parent element.");j.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=j.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),j.appendChild(this.element);const X=$.createDocumentFragment();this._viewportElement=$.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),X.appendChild(this._viewportElement),this._viewportScrollArea=$.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=$.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=$.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),X.appendChild(this.screenElement),this.textarea=$.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",p.promptLabel),M.isChromeOS||this.textarea.setAttribute("aria-multiline","false"),this.textarea.setAttribute("autocorrect","off"),this.textarea.setAttribute("autocapitalize","off"),this.textarea.setAttribute("spellcheck","false"),this.textarea.tabIndex=0,this._coreBrowserService=this._instantiationService.createInstance(_.CoreBrowserService,this.textarea,(I=this._document.defaultView)!==null&&I!==void 0?I:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",(Y=>this._handleTextAreaFocus(Y)))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(c.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(E.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(E.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(g.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(k.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(E.IRenderService,this._renderService),this.register(this._renderService.onRenderedViewportChange((Y=>this._onRender.fire(Y)))),this.onResize((Y=>this._renderService.resize(Y.cols,Y.rows))),this._compositionView=$.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(a.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(X);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(C.MouseService),this._instantiationService.setService(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((Y=>this.scrollLines(Y.amount,Y.suppressScrollEvent,1))),this.register(this._inputHandler.onRequestSyncScrollBar((()=>this.viewport.syncScrollArea()))),this.register(this.viewport),this.register(this.onCursorMove((()=>{this._renderService.handleCursorMove(),this._syncTextArea()}))),this.register(this.onResize((()=>this._renderService.handleResize(this.cols,this.rows)))),this.register(this.onBlur((()=>this._renderService.handleBlur()))),this.register(this.onFocus((()=>this._renderService.handleFocus()))),this.register(this._renderService.onDimensionsChange((()=>this.viewport.syncScrollArea()))),this._selectionService=this.register(this._instantiationService.createInstance(v.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(E.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((Y=>this.scrollLines(Y.amount,Y.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((Y=>this._renderService.handleSelectionChanged(Y.start,Y.end,Y.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((Y=>{this.textarea.value=Y,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((Y=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(b.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(Y=>this._selectionService.handleMouseDown(Y)))),this.coreMouseService.areMouseEventsActive?(this._selectionService.disable(),this.element.classList.add("enable-mouse-events")):this._selectionService.enable(),this.options.screenReaderMode&&(this._accessibilityManager.value=this._instantiationService.createInstance(K.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(Y=>this._handleScreenReaderModeOptionChange(Y)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(r.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(Y=>{!this._overviewRulerRenderer&&Y&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(r.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(l.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const j=this,I=this.element;function X(G){const te=j._mouseService.getMouseReportCoords(G,j.screenElement);if(!te)return!1;let le,J;switch(G.overrideType||G.type){case"mousemove":J=32,G.buttons===void 0?(le=3,G.button!==void 0&&(le=G.button<3?G.button:3)):le=1&G.buttons?0:4&G.buttons?1:2&G.buttons?2:3;break;case"mouseup":J=0,le=G.button<3?G.button:3;break;case"mousedown":J=1,le=G.button<3?G.button:3;break;case"wheel":if(j.viewport.getLinesScrolled(G)===0)return!1;J=G.deltaY<0?0:1,le=4;break;default:return!1}return!(J===void 0||le===void 0||le>4)&&j.coreMouseService.triggerMouseEvent({col:te.col,row:te.row,x:te.x,y:te.y,button:le,action:J,ctrl:G.ctrlKey,alt:G.altKey,shift:G.shiftKey})}const Y={mouseup:null,wheel:null,mousedrag:null,mousemove:null},Z={mouseup:G=>(X(G),G.buttons||(this._document.removeEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.removeEventListener("mousemove",Y.mousedrag)),this.cancel(G)),wheel:G=>(X(G),this.cancel(G,!0)),mousedrag:G=>{G.buttons&&X(G)},mousemove:G=>{G.buttons||X(G)}};this.register(this.coreMouseService.onProtocolChange((G=>{G?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(G)),this.element.classList.add("enable-mouse-events"),this._selectionService.disable()):(this._logService.debug("Unbinding from mouse events."),this.element.classList.remove("enable-mouse-events"),this._selectionService.enable()),8&G?Y.mousemove||(I.addEventListener("mousemove",Z.mousemove),Y.mousemove=Z.mousemove):(I.removeEventListener("mousemove",Y.mousemove),Y.mousemove=null),16&G?Y.wheel||(I.addEventListener("wheel",Z.wheel,{passive:!1}),Y.wheel=Z.wheel):(I.removeEventListener("wheel",Y.wheel),Y.wheel=null),2&G?Y.mouseup||(I.addEventListener("mouseup",Z.mouseup),Y.mouseup=Z.mouseup):(this._document.removeEventListener("mouseup",Y.mouseup),I.removeEventListener("mouseup",Y.mouseup),Y.mouseup=null),4&G?Y.mousedrag||(Y.mousedrag=Z.mousedrag):(this._document.removeEventListener("mousemove",Y.mousedrag),Y.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(I,"mousedown",(G=>{if(G.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(G))return X(G),Y.mouseup&&this._document.addEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.addEventListener("mousemove",Y.mousedrag),this.cancel(G)}))),this.register((0,f.addDisposableDomListener)(I,"wheel",(G=>{if(!Y.wheel){if(!this.buffer.hasScrollback){const te=this.viewport.getLinesScrolled(G);if(te===0)return;const le=U.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(G.deltaY<0?"A":"B");let J="";for(let ne=0;ne<Math.abs(te);ne++)J+=le;return this.coreService.triggerDataEvent(J,!0),this.cancel(G,!0)}return this.viewport.handleWheel(G)?this.cancel(G):void 0}}),{passive:!1})),this.register((0,f.addDisposableDomListener)(I,"touchstart",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(G),this.cancel(G)}),{passive:!0})),this.register((0,f.addDisposableDomListener)(I,"touchmove",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(G)?void 0:this.cancel(G)}),{passive:!1}))}refresh(j,I){var X;(X=this._renderService)===null||X===void 0||X.refreshRows(j,I)}updateCursorStyle(j){var I;!((I=this._selectionService)===null||I===void 0)&&I.shouldColumnSelect(j)?this.element.classList.add("column-select"):this.element.classList.remove("column-select")}_showCursor(){this.coreService.isCursorInitialized||(this.coreService.isCursorInitialized=!0,this.refresh(this.buffer.y,this.buffer.y))}scrollLines(j,I,X=0){var Y;X===1?(super.scrollLines(j,I,X),this.refresh(0,this.rows-1)):(Y=this.viewport)===null||Y===void 0||Y.scrollLines(j)}paste(j){(0,u.paste)(j,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(j){this._customKeyEventHandler=j}registerLinkProvider(j){return this.linkifier2.registerLinkProvider(j)}registerCharacterJoiner(j){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const I=this._characterJoinerService.register(j);return this.refresh(0,this.rows-1),I}deregisterCharacterJoiner(j){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(j)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(j){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+j)}registerDecoration(j){return this._decorationService.registerDecoration(j)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(j,I,X){this._selectionService.setSelection(j,I,X)}getSelection(){return this._selectionService?this._selectionService.selectionText:""}getSelectionPosition(){if(this._selectionService&&this._selectionService.hasSelection)return{start:{x:this._selectionService.selectionStart[0],y:this._selectionService.selectionStart[1]},end:{x:this._selectionService.selectionEnd[0],y:this._selectionService.selectionEnd[1]}}}clearSelection(){var j;(j=this._selectionService)===null||j===void 0||j.clearSelection()}selectAll(){var j;(j=this._selectionService)===null||j===void 0||j.selectAll()}selectLines(j,I){var X;(X=this._selectionService)===null||X===void 0||X.selectLines(j,I)}_keyDown(j){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1)return!1;const I=this.browser.isMac&&this.options.macOptionIsMeta&&j.altKey;if(!I&&!this._compositionHelper.keydown(j))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;I||j.key!=="Dead"&&j.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const X=(0,N.evaluateKeyboardEvent)(j,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(j),X.type===3||X.type===2){const Y=this.rows-1;return this.scrollLines(X.type===2?-Y:Y),this.cancel(j,!0)}return X.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,j)||(X.cancel&&this.cancel(j,!0),!X.key||!!(j.key&&!j.ctrlKey&&!j.altKey&&!j.metaKey&&j.key.length===1&&j.key.charCodeAt(0)>=65&&j.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(X.key!==U.C0.ETX&&X.key!==U.C0.CR||(this.textarea.value=""),this._onKey.fire({key:X.key,domEvent:j}),this._showCursor(),this.coreService.triggerDataEvent(X.key,!0),!this.optionsService.rawOptions.screenReaderMode||j.altKey||j.ctrlKey?this.cancel(j,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(j,I){const X=j.isMac&&!this.options.macOptionIsMeta&&I.altKey&&!I.ctrlKey&&!I.metaKey||j.isWindows&&I.altKey&&I.ctrlKey&&!I.metaKey||j.isWindows&&I.getModifierState("AltGraph");return I.type==="keypress"?X:X&&(!I.keyCode||I.keyCode>47)}_keyUp(j){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1||((function(I){return I.keyCode===16||I.keyCode===17||I.keyCode===18})(j)||this.focus(),this.updateCursorStyle(j),this._keyPressHandled=!1)}_keyPress(j){let I;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(j)===!1)return!1;if(this.cancel(j),j.charCode)I=j.charCode;else if(j.which===null||j.which===void 0)I=j.keyCode;else{if(j.which===0||j.charCode===0)return!1;I=j.which}return!(!I||(j.altKey||j.ctrlKey||j.metaKey)&&!this._isThirdLevelShift(this.browser,j)||(I=String.fromCharCode(I),this._onKey.fire({key:I,domEvent:j}),this._showCursor(),this.coreService.triggerDataEvent(I,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(j){if(j.data&&j.inputType==="insertText"&&(!j.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const I=j.data;return this.coreService.triggerDataEvent(I,!0),this.cancel(j),!0}return!1}resize(j,I){j!==this.cols||I!==this.rows?super.resize(j,I):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(j,I){var X,Y;(X=this._charSizeService)===null||X===void 0||X.measure(),(Y=this.viewport)===null||Y===void 0||Y.syncScrollArea(!0)}clear(){var j;if(this.buffer.ybase!==0||this.buffer.y!==0){this.buffer.clearAllMarkers(),this.buffer.lines.set(0,this.buffer.lines.get(this.buffer.ybase+this.buffer.y)),this.buffer.lines.length=1,this.buffer.ydisp=0,this.buffer.ybase=0,this.buffer.y=0;for(let I=1;I<this.rows;I++)this.buffer.lines.push(this.buffer.getBlankLine(F.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(j=this.viewport)===null||j===void 0||j.reset(),this.refresh(0,this.rows-1)}}reset(){var j,I;this.options.rows=this.rows,this.options.cols=this.cols;const X=this._customKeyEventHandler;this._setup(),super.reset(),(j=this._selectionService)===null||j===void 0||j.reset(),this._decorationService.reset(),(I=this.viewport)===null||I===void 0||I.reset(),this._customKeyEventHandler=X,this.refresh(0,this.rows-1)}clearTextureAtlas(){var j;(j=this._renderService)===null||j===void 0||j.clearTextureAtlas()}_reportFocus(){var j;!((j=this.element)===null||j===void 0)&&j.classList.contains("focus")?this.coreService.triggerDataEvent(U.C0.ESC+"[I"):this.coreService.triggerDataEvent(U.C0.ESC+"[O")}_reportWindowsOptions(j){if(this._renderService)switch(j){case q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const I=this._renderService.dimensions.css.canvas.width.toFixed(0),X=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${U.C0.ESC}[4;${X};${I}t`);break;case q.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const Y=this._renderService.dimensions.css.cell.width.toFixed(0),Z=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${U.C0.ESC}[6;${Z};${Y}t`)}}cancel(j,I){if(this.options.cancelEvents||I)return j.preventDefault(),j.stopPropagation(),!1}}s.Terminal=W},9924:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TimeBasedDebouncer=void 0,s.TimeBasedDebouncer=class{constructor(o,u=1e3){this._renderCallback=o,this._debounceThresholdMS=u,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(o,u,f){this._rowCount=f,o=o!==void 0?o:0,u=u!==void 0?u:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,o):o,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,u):u;const d=Date.now();if(d-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=d,this._innerRefresh();else if(!this._additionalRefreshRequested){const p=d-this._lastRefreshMs,m=this._debounceThresholdMS-p;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),m)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const o=Math.max(this._rowStart,0),u=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(o,u)}}},1680:function(w,s,o){var u=this&&this.__decorate||function(a,l,c,g){var _,C=arguments.length,k=C<3?l:g===null?g=Object.getOwnPropertyDescriptor(l,c):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,l,c,g);else for(var v=a.length-1;v>=0;v--)(_=a[v])&&(k=(C<3?_(k):C>3?_(l,c,k):_(l,c))||k);return C>3&&k&&Object.defineProperty(l,c,k),k},f=this&&this.__param||function(a,l){return function(c,g){l(c,g,a)}};Object.defineProperty(s,"__esModule",{value:!0}),s.Viewport=void 0;const d=o(3656),p=o(4725),m=o(8460),y=o(844),b=o(2585);let r=s.Viewport=class extends y.Disposable{constructor(a,l,c,g,_,C,k,v){super(),this._viewportElement=a,this._scrollArea=l,this._bufferService=c,this._optionsService=g,this._charSizeService=_,this._renderService=C,this._coreBrowserService=k,this.scrollBarWidth=0,this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._wheelPartialScroll=0,this._refreshAnimationFrame=null,this._ignoreNextScrollEvent=!1,this._smoothScrollState={startTime:0,origin:-1,target:-1},this._onRequestScrollLines=this.register(new m.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,d.addDisposableDomListener)(this._viewportElement,"scroll",this._handleScroll.bind(this))),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((E=>this._activeBuffer=E.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((E=>this._renderDimensions=E))),this._handleThemeChange(v.colors),this.register(v.onChangeColors((E=>this._handleThemeChange(E)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(a){this._viewportElement.style.backgroundColor=a.background.css}reset(){this._currentRowHeight=0,this._currentDeviceCellHeight=0,this._lastRecordedBufferLength=0,this._lastRecordedViewportHeight=0,this._lastRecordedBufferHeight=0,this._lastTouchY=0,this._lastScrollTop=0,this._coreBrowserService.window.requestAnimationFrame((()=>this.syncScrollArea()))}_refresh(a){if(a)return this._innerRefresh(),void(this._refreshAnimationFrame!==null&&this._coreBrowserService.window.cancelAnimationFrame(this._refreshAnimationFrame));this._refreshAnimationFrame===null&&(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._innerRefresh())))}_innerRefresh(){if(this._charSizeService.height>0){this._currentRowHeight=this._renderService.dimensions.device.cell.height/this._coreBrowserService.dpr,this._currentDeviceCellHeight=this._renderService.dimensions.device.cell.height,this._lastRecordedViewportHeight=this._viewportElement.offsetHeight;const l=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==l&&(this._lastRecordedBufferHeight=l,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const a=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==a&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=a),this._refreshAnimationFrame=null}syncScrollArea(a=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(a);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(a)}_handleScroll(a){if(this._lastScrollTop=this._viewportElement.scrollTop,!this._viewportElement.offsetParent)return;if(this._ignoreNextScrollEvent)return this._ignoreNextScrollEvent=!1,void this._onRequestScrollLines.fire({amount:0,suppressScrollEvent:!0});const l=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:l,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const a=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(a*(this._smoothScrollState.target-this._smoothScrollState.origin)),a<1?this._coreBrowserService.window.requestAnimationFrame((()=>this._smoothScroll())):this._clearSmoothScrollState()}_smoothScrollPercent(){return this._optionsService.rawOptions.smoothScrollDuration&&this._smoothScrollState.startTime?Math.max(Math.min((Date.now()-this._smoothScrollState.startTime)/this._optionsService.rawOptions.smoothScrollDuration,1),0):1}_clearSmoothScrollState(){this._smoothScrollState.startTime=0,this._smoothScrollState.origin=-1,this._smoothScrollState.target=-1}_bubbleScroll(a,l){const c=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(l<0&&this._viewportElement.scrollTop!==0||l>0&&c<this._lastRecordedBufferHeight)||(a.cancelable&&a.preventDefault(),!1)}handleWheel(a){const l=this._getPixelsScrolled(a);return l!==0&&(this._optionsService.rawOptions.smoothScrollDuration?(this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target===-1?this._smoothScrollState.target=this._viewportElement.scrollTop+l:this._smoothScrollState.target+=l,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=l,this._bubbleScroll(a,l))}scrollLines(a){if(a!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const l=a*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+l,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:a,suppressScrollEvent:!1})}_getPixelsScrolled(a){if(a.deltaY===0||a.shiftKey)return 0;let l=this._applyScrollModifier(a.deltaY,a);return a.deltaMode===WheelEvent.DOM_DELTA_LINE?l*=this._currentRowHeight:a.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(l*=this._currentRowHeight*this._bufferService.rows),l}getBufferElements(a,l){var c;let g,_="";const C=[],k=l??this._bufferService.buffer.lines.length,v=this._bufferService.buffer.lines;for(let E=a;E<k;E++){const R=v.get(E);if(!R)continue;const O=(c=v.get(E+1))===null||c===void 0?void 0:c.isWrapped;if(_+=R.translateToString(!O),!O||E===v.length-1){const L=document.createElement("div");L.textContent=_,C.push(L),_.length>0&&(g=L),_=""}}return{bufferElements:C,cursorElement:g}}getLinesScrolled(a){if(a.deltaY===0||a.shiftKey)return 0;let l=this._applyScrollModifier(a.deltaY,a);return a.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(l/=this._currentRowHeight+0,this._wheelPartialScroll+=l,l=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):a.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(l*=this._bufferService.rows),l}_applyScrollModifier(a,l){const c=this._optionsService.rawOptions.fastScrollModifier;return c==="alt"&&l.altKey||c==="ctrl"&&l.ctrlKey||c==="shift"&&l.shiftKey?a*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:a*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(a){this._lastTouchY=a.touches[0].pageY}handleTouchMove(a){const l=this._lastTouchY-a.touches[0].pageY;return this._lastTouchY=a.touches[0].pageY,l!==0&&(this._viewportElement.scrollTop+=l,this._bubbleScroll(a,l))}};s.Viewport=r=u([f(2,b.IBufferService),f(3,b.IOptionsService),f(4,p.ICharSizeService),f(5,p.IRenderService),f(6,p.ICoreBrowserService),f(7,p.IThemeService)],r)},3107:function(w,s,o){var u=this&&this.__decorate||function(r,a,l,c){var g,_=arguments.length,C=_<3?a:c===null?c=Object.getOwnPropertyDescriptor(a,l):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(r,a,l,c);else for(var k=r.length-1;k>=0;k--)(g=r[k])&&(C=(_<3?g(C):_>3?g(a,l,C):g(a,l))||C);return _>3&&C&&Object.defineProperty(a,l,C),C},f=this&&this.__param||function(r,a){return function(l,c){a(l,c,r)}};Object.defineProperty(s,"__esModule",{value:!0}),s.BufferDecorationRenderer=void 0;const d=o(3656),p=o(4725),m=o(844),y=o(2585);let b=s.BufferDecorationRenderer=class extends m.Disposable{constructor(r,a,l,c){super(),this._screenElement=r,this._bufferService=a,this._decorationService=l,this._renderService=c,this._decorationElements=new Map,this._altBufferIsActive=!1,this._dimensionsChanged=!1,this._container=document.createElement("div"),this._container.classList.add("xterm-decoration-container"),this._screenElement.appendChild(this._container),this.register(this._renderService.onRenderedViewportChange((()=>this._doRefreshDecorations()))),this.register(this._renderService.onDimensionsChange((()=>{this._dimensionsChanged=!0,this._queueRefresh()}))),this.register((0,d.addDisposableDomListener)(window,"resize",(()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._altBufferIsActive=this._bufferService.buffer===this._bufferService.buffers.alt}))),this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh()))),this.register(this._decorationService.onDecorationRemoved((g=>this._removeDecoration(g)))),this.register((0,m.toDisposable)((()=>{this._container.remove(),this._decorationElements.clear()})))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback((()=>{this._doRefreshDecorations(),this._animationFrame=void 0})))}_doRefreshDecorations(){for(const r of this._decorationService.decorations)this._renderDecoration(r);this._dimensionsChanged=!1}_renderDecoration(r){this._refreshStyle(r),this._dimensionsChanged&&this._refreshXPosition(r)}_createElement(r){var a,l;const c=document.createElement("div");c.classList.add("xterm-decoration"),c.classList.toggle("xterm-decoration-top-layer",((a=r?.options)===null||a===void 0?void 0:a.layer)==="top"),c.style.width=`${Math.round((r.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,c.style.height=(r.options.height||1)*this._renderService.dimensions.css.cell.height+"px",c.style.top=(r.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",c.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const g=(l=r.options.x)!==null&&l!==void 0?l:0;return g&&g>this._bufferService.cols&&(c.style.display="none"),this._refreshXPosition(r,c),c}_refreshStyle(r){const a=r.marker.line-this._bufferService.buffers.active.ydisp;if(a<0||a>=this._bufferService.rows)r.element&&(r.element.style.display="none",r.onRenderEmitter.fire(r.element));else{let l=this._decorationElements.get(r);l||(l=this._createElement(r),r.element=l,this._decorationElements.set(r,l),this._container.appendChild(l),r.onDispose((()=>{this._decorationElements.delete(r),l.remove()}))),l.style.top=a*this._renderService.dimensions.css.cell.height+"px",l.style.display=this._altBufferIsActive?"none":"block",r.onRenderEmitter.fire(l)}}_refreshXPosition(r,a=r.element){var l;if(!a)return;const c=(l=r.options.x)!==null&&l!==void 0?l:0;(r.options.anchor||"left")==="right"?a.style.right=c?c*this._renderService.dimensions.css.cell.width+"px":"":a.style.left=c?c*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(r){var a;(a=this._decorationElements.get(r))===null||a===void 0||a.remove(),this._decorationElements.delete(r),r.dispose()}};s.BufferDecorationRenderer=b=u([f(1,y.IBufferService),f(2,y.IDecorationService),f(3,p.IRenderService)],b)},5871:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ColorZoneStore=void 0,s.ColorZoneStore=class{constructor(){this._zones=[],this._zonePool=[],this._zonePoolIndex=0,this._linePadding={full:0,left:0,center:0,right:0}}get zones(){return this._zonePool.length=Math.min(this._zonePool.length,this._zones.length),this._zones}clear(){this._zones.length=0,this._zonePoolIndex=0}addDecoration(o){if(o.options.overviewRulerOptions){for(const u of this._zones)if(u.color===o.options.overviewRulerOptions.color&&u.position===o.options.overviewRulerOptions.position){if(this._lineIntersectsZone(u,o.marker.line))return;if(this._lineAdjacentToZone(u,o.marker.line,o.options.overviewRulerOptions.position))return void this._addLineToZone(u,o.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=o.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=o.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=o.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=o.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:o.options.overviewRulerOptions.color,position:o.options.overviewRulerOptions.position,startBufferLine:o.marker.line,endBufferLine:o.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(o){this._linePadding=o}_lineIntersectsZone(o,u){return u>=o.startBufferLine&&u<=o.endBufferLine}_lineAdjacentToZone(o,u,f){return u>=o.startBufferLine-this._linePadding[f||"full"]&&u<=o.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(o,u){o.startBufferLine=Math.min(o.startBufferLine,u),o.endBufferLine=Math.max(o.endBufferLine,u)}}},5744:function(w,s,o){var u=this&&this.__decorate||function(g,_,C,k){var v,E=arguments.length,R=E<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(g,_,C,k);else for(var O=g.length-1;O>=0;O--)(v=g[O])&&(R=(E<3?v(R):E>3?v(_,C,R):v(_,C))||R);return E>3&&R&&Object.defineProperty(_,C,R),R},f=this&&this.__param||function(g,_){return function(C,k){_(C,k,g)}};Object.defineProperty(s,"__esModule",{value:!0}),s.OverviewRulerRenderer=void 0;const d=o(5871),p=o(3656),m=o(4725),y=o(844),b=o(2585),r={full:0,left:0,center:0,right:0},a={full:0,left:0,center:0,right:0},l={full:0,left:0,center:0,right:0};let c=s.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(g,_,C,k,v,E,R){var O;super(),this._viewportElement=g,this._screenElement=_,this._bufferService=C,this._decorationService=k,this._renderService=v,this._optionsService=E,this._coreBrowseService=R,this._colorZoneStore=new d.ColorZoneStore,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=document.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(O=this._viewportElement.parentElement)===null||O===void 0||O.insertBefore(this._canvas,this._viewportElement);const L=this._canvas.getContext("2d");if(!L)throw new Error("Ctx cannot be null");this._ctx=L,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var P;(P=this._canvas)===null||P===void 0||P.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,p.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const g=Math.floor(this._canvas.width/3),_=Math.ceil(this._canvas.width/3);a.full=this._canvas.width,a.left=g,a.center=_,a.right=g,this._refreshDrawHeightConstants(),l.full=0,l.left=0,l.center=a.left,l.right=a.left+a.center}_refreshDrawHeightConstants(){r.full=Math.round(2*this._coreBrowseService.dpr);const g=this._canvas.height/this._bufferService.buffer.lines.length,_=Math.round(Math.max(Math.min(g,12),6)*this._coreBrowseService.dpr);r.left=_,r.center=_,r.right=_}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*r.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*r.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*r.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*r.right)}),this._lastKnownBufferLength=this._bufferService.buffers.normal.lines.length}_refreshCanvasDimensions(){this._canvas.style.width=`${this._width}px`,this._canvas.width=Math.round(this._width*this._coreBrowseService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowseService.dpr),this._refreshDrawConstants(),this._refreshColorZonePadding()}_refreshDecorations(){this._shouldUpdateDimensions&&this._refreshCanvasDimensions(),this._ctx.clearRect(0,0,this._canvas.width,this._canvas.height),this._colorZoneStore.clear();for(const _ of this._decorationService.decorations)this._colorZoneStore.addDecoration(_);this._ctx.lineWidth=1;const g=this._colorZoneStore.zones;for(const _ of g)_.position!=="full"&&this._renderColorZone(_);for(const _ of g)_.position==="full"&&this._renderColorZone(_);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(g){this._ctx.fillStyle=g.color,this._ctx.fillRect(l[g.position||"full"],Math.round((this._canvas.height-1)*(g.startBufferLine/this._bufferService.buffers.active.lines.length)-r[g.position||"full"]/2),a[g.position||"full"],Math.round((this._canvas.height-1)*((g.endBufferLine-g.startBufferLine)/this._bufferService.buffers.active.lines.length)+r[g.position||"full"]))}_queueRefresh(g,_){this._shouldUpdateDimensions=g||this._shouldUpdateDimensions,this._shouldUpdateAnchor=_||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};s.OverviewRulerRenderer=c=u([f(2,b.IBufferService),f(3,b.IDecorationService),f(4,m.IRenderService),f(5,b.IOptionsService),f(6,m.ICoreBrowserService)],c)},2950:function(w,s,o){var u=this&&this.__decorate||function(b,r,a,l){var c,g=arguments.length,_=g<3?r:l===null?l=Object.getOwnPropertyDescriptor(r,a):l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")_=Reflect.decorate(b,r,a,l);else for(var C=b.length-1;C>=0;C--)(c=b[C])&&(_=(g<3?c(_):g>3?c(r,a,_):c(r,a))||_);return g>3&&_&&Object.defineProperty(r,a,_),_},f=this&&this.__param||function(b,r){return function(a,l){r(a,l,b)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CompositionHelper=void 0;const d=o(4725),p=o(2585),m=o(2584);let y=s.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(b,r,a,l,c,g){this._textarea=b,this._compositionView=r,this._bufferService=a,this._optionsService=l,this._coreService=c,this._renderService=g,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(b){this._compositionView.textContent=b.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(b){if(this._isComposing||this._isSendingComposition){if(b.keyCode===229||b.keyCode===16||b.keyCode===17||b.keyCode===18)return!1;this._finalizeComposition(!1)}return b.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(b){if(this._compositionView.classList.remove("active"),this._isComposing=!1,b){const r={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let a;this._isSendingComposition=!1,r.start+=this._dataAlreadySent.length,a=this._isComposing?this._textarea.value.substring(r.start,r.end):this._textarea.value.substring(r.start),a.length>0&&this._coreService.triggerDataEvent(a,!0)}}),0)}else{this._isSendingComposition=!1;const r=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(r,!0)}}_handleAnyTextareaChanges(){const b=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const r=this._textarea.value,a=r.replace(b,"");this._dataAlreadySent=a,r.length>b.length?this._coreService.triggerDataEvent(a,!0):r.length<b.length?this._coreService.triggerDataEvent(`${m.C0.DEL}`,!0):r.length===b.length&&r!==b&&this._coreService.triggerDataEvent(r,!0)}}),0)}updateCompositionElements(b){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const r=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),a=this._renderService.dimensions.css.cell.height,l=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,c=r*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=c+"px",this._compositionView.style.top=l+"px",this._compositionView.style.height=a+"px",this._compositionView.style.lineHeight=a+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const g=this._compositionView.getBoundingClientRect();this._textarea.style.left=c+"px",this._textarea.style.top=l+"px",this._textarea.style.width=Math.max(g.width,1)+"px",this._textarea.style.height=Math.max(g.height,1)+"px",this._textarea.style.lineHeight=g.height+"px"}b||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};s.CompositionHelper=y=u([f(2,p.IBufferService),f(3,p.IOptionsService),f(4,p.ICoreService),f(5,d.IRenderService)],y)},9806:(w,s)=>{function o(u,f,d){const p=d.getBoundingClientRect(),m=u.getComputedStyle(d),y=parseInt(m.getPropertyValue("padding-left")),b=parseInt(m.getPropertyValue("padding-top"));return[f.clientX-p.left-y,f.clientY-p.top-b]}Object.defineProperty(s,"__esModule",{value:!0}),s.getCoords=s.getCoordsRelativeToElement=void 0,s.getCoordsRelativeToElement=o,s.getCoords=function(u,f,d,p,m,y,b,r,a){if(!y)return;const l=o(u,f,d);return l?(l[0]=Math.ceil((l[0]+(a?b/2:0))/b),l[1]=Math.ceil(l[1]/r),l[0]=Math.min(Math.max(l[0],1),p+(a?1:0)),l[1]=Math.min(Math.max(l[1],1),m),l):void 0}},9504:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.moveToCellSequence=void 0;const u=o(2584);function f(r,a,l,c){const g=r-d(r,l),_=a-d(a,l),C=Math.abs(g-_)-(function(k,v,E){let R=0;const O=k-d(k,E),L=v-d(v,E);for(let P=0;P<Math.abs(O-L);P++){const H=p(k,v)==="A"?-1:1,M=E.buffer.lines.get(O+H*P);M?.isWrapped&&R++}return R})(r,a,l);return b(C,y(p(r,a),c))}function d(r,a){let l=0,c=a.buffer.lines.get(r),g=c?.isWrapped;for(;g&&r>=0&&r<a.rows;)l++,c=a.buffer.lines.get(--r),g=c?.isWrapped;return l}function p(r,a){return r>a?"A":"B"}function m(r,a,l,c,g,_){let C=r,k=a,v="";for(;C!==l||k!==c;)C+=g?1:-1,g&&C>_.cols-1?(v+=_.buffer.translateBufferLineToString(k,!1,r,C),C=0,r=0,k++):!g&&C<0&&(v+=_.buffer.translateBufferLineToString(k,!1,0,r+1),C=_.cols-1,r=C,k--);return v+_.buffer.translateBufferLineToString(k,!1,r,C)}function y(r,a){const l=a?"O":"[";return u.C0.ESC+l+r}function b(r,a){r=Math.floor(r);let l="";for(let c=0;c<r;c++)l+=a;return l}s.moveToCellSequence=function(r,a,l,c){const g=l.buffer.x,_=l.buffer.y;if(!l.buffer.hasScrollback)return(function(v,E,R,O,L,P){return f(E,O,L,P).length===0?"":b(m(v,E,v,E-d(E,L),!1,L).length,y("D",P))})(g,_,0,a,l,c)+f(_,a,l,c)+(function(v,E,R,O,L,P){let H;H=f(E,O,L,P).length>0?O-d(O,L):E;const M=O,F=(function(U,N,D,T,B,q){let K;return K=f(D,T,B,q).length>0?T-d(T,B):N,U<D&&K<=T||U>=D&&K<T?"C":"D"})(v,E,R,O,L,P);return b(m(v,H,R,M,F==="C",L).length,y(F,P))})(g,_,r,a,l,c);let C;if(_===a)return C=g>r?"D":"C",b(Math.abs(g-r),y(C,c));C=_>a?"D":"C";const k=Math.abs(_-a);return b((function(v,E){return E.cols-v})(_>a?r:g,l)+(k-1)*l.cols+1+((_>a?g:r)-1),y(C,c))}},1296:function(w,s,o){var u=this&&this.__decorate||function(L,P,H,M){var F,U=arguments.length,N=U<3?P:M===null?M=Object.getOwnPropertyDescriptor(P,H):M;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(L,P,H,M);else for(var D=L.length-1;D>=0;D--)(F=L[D])&&(N=(U<3?F(N):U>3?F(P,H,N):F(P,H))||N);return U>3&&N&&Object.defineProperty(P,H,N),N},f=this&&this.__param||function(L,P){return function(H,M){P(H,M,L)}};Object.defineProperty(s,"__esModule",{value:!0}),s.DomRenderer=void 0;const d=o(3787),p=o(2550),m=o(2223),y=o(6171),b=o(4725),r=o(8055),a=o(8460),l=o(844),c=o(2585),g="xterm-dom-renderer-owner-",_="xterm-rows",C="xterm-fg-",k="xterm-bg-",v="xterm-focus",E="xterm-selection";let R=1,O=s.DomRenderer=class extends l.Disposable{constructor(L,P,H,M,F,U,N,D,T,B){super(),this._element=L,this._screenElement=P,this._viewportElement=H,this._linkifier2=M,this._charSizeService=U,this._optionsService=N,this._bufferService=D,this._coreBrowserService=T,this._themeService=B,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new a.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(_),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=document.createElement("div"),this._selectionContainer.classList.add(E),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((q=>this._injectCss(q)))),this._injectCss(this._themeService.colors),this._rowFactory=F.createInstance(d.DomRendererRowFactory,document),this._element.classList.add(g+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((q=>this._handleLinkHover(q)))),this.register(this._linkifier2.onHideLinkUnderline((q=>this._handleLinkLeave(q)))),this.register((0,l.toDisposable)((()=>{this._element.classList.remove(g+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new p.WidthCache(document),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){const L=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*L,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*L),this.dimensions.device.cell.width=this.dimensions.device.char.width+Math.round(this._optionsService.rawOptions.letterSpacing),this.dimensions.device.cell.height=Math.floor(this.dimensions.device.char.height*this._optionsService.rawOptions.lineHeight),this.dimensions.device.char.left=0,this.dimensions.device.char.top=0,this.dimensions.device.canvas.width=this.dimensions.device.cell.width*this._bufferService.cols,this.dimensions.device.canvas.height=this.dimensions.device.cell.height*this._bufferService.rows,this.dimensions.css.canvas.width=Math.round(this.dimensions.device.canvas.width/L),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/L),this.dimensions.css.cell.width=this.dimensions.css.canvas.width/this._bufferService.cols,this.dimensions.css.cell.height=this.dimensions.css.canvas.height/this._bufferService.rows;for(const H of this._rowElements)H.style.width=`${this.dimensions.css.canvas.width}px`,H.style.height=`${this.dimensions.css.cell.height}px`,H.style.lineHeight=`${this.dimensions.css.cell.height}px`,H.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const P=`${this._terminalSelector} .${_} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=P,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(L){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let P=`${this._terminalSelector} .${_} { color: ${L.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;P+=`${this._terminalSelector} .${_} .xterm-dim { color: ${r.color.multiplyOpacity(L.foreground,.5).css};}`,P+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,P+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",P+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${L.cursor.css}; color: ${L.cursorAccent.css}; } 50% { background-color: inherit; color: ${L.cursor.css}; }}`,P+=`${this._terminalSelector} .${_}.${v} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${_}.${v} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${_} .xterm-cursor.xterm-cursor-block { background-color: ${L.cursor.css}; color: ${L.cursorAccent.css};}${this._terminalSelector} .${_} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${L.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${_} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${L.cursor.css} inset;}${this._terminalSelector} .${_} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${L.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,P+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${L.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${L.selectionInactiveBackgroundOpaque.css};}`;for(const[H,M]of L.ansi.entries())P+=`${this._terminalSelector} .${C}${H} { color: ${M.css}; }${this._terminalSelector} .${C}${H}.xterm-dim { color: ${r.color.multiplyOpacity(M,.5).css}; }${this._terminalSelector} .${k}${H} { background-color: ${M.css}; }`;P+=`${this._terminalSelector} .${C}${m.INVERTED_DEFAULT_COLOR} { color: ${r.color.opaque(L.background).css}; }${this._terminalSelector} .${C}${m.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${r.color.multiplyOpacity(r.color.opaque(L.background),.5).css}; }${this._terminalSelector} .${k}${m.INVERTED_DEFAULT_COLOR} { background-color: ${L.foreground.css}; }`,this._themeStyleElement.textContent=P}_setDefaultSpacing(){const L=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${L}px`,this._rowFactory.defaultSpacing=L}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(L,P){for(let H=this._rowElements.length;H<=P;H++){const M=document.createElement("div");this._rowContainer.appendChild(M),this._rowElements.push(M)}for(;this._rowElements.length>P;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(L,P){this._refreshRowElements(L,P),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(v)}handleFocus(){this._rowContainer.classList.add(v),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(L,P,H){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(L,P,H),this.renderRows(0,this._bufferService.rows-1),!L||!P)return;const M=L[1]-this._bufferService.buffer.ydisp,F=P[1]-this._bufferService.buffer.ydisp,U=Math.max(M,0),N=Math.min(F,this._bufferService.rows-1);if(U>=this._bufferService.rows||N<0)return;const D=document.createDocumentFragment();if(H){const T=L[0]>P[0];D.appendChild(this._createSelectionElement(U,T?P[0]:L[0],T?L[0]:P[0],N-U+1))}else{const T=M===U?L[0]:0,B=U===F?P[0]:this._bufferService.cols;D.appendChild(this._createSelectionElement(U,T,B));const q=N-U-1;if(D.appendChild(this._createSelectionElement(U+1,0,this._bufferService.cols,q)),U!==N){const K=F===N?P[0]:this._bufferService.cols;D.appendChild(this._createSelectionElement(N,0,K))}}this._selectionContainer.appendChild(D)}_createSelectionElement(L,P,H,M=1){const F=document.createElement("div");return F.style.height=M*this.dimensions.css.cell.height+"px",F.style.top=L*this.dimensions.css.cell.height+"px",F.style.left=P*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(H-P)+"px",F}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const L of this._rowElements)L.replaceChildren()}renderRows(L,P){const H=this._bufferService.buffer,M=H.ybase+H.y,F=Math.min(H.x,this._bufferService.cols-1),U=this._optionsService.rawOptions.cursorBlink,N=this._optionsService.rawOptions.cursorStyle,D=this._optionsService.rawOptions.cursorInactiveStyle;for(let T=L;T<=P;T++){const B=T+H.ydisp,q=this._rowElements[T],K=H.lines.get(B);if(!q||!K)break;q.replaceChildren(...this._rowFactory.createRow(K,B,B===M,N,D,F,U,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${g}${this._terminalClass}`}_handleLinkHover(L){this._setCellUnderline(L.x1,L.x2,L.y1,L.y2,L.cols,!0)}_handleLinkLeave(L){this._setCellUnderline(L.x1,L.x2,L.y1,L.y2,L.cols,!1)}_setCellUnderline(L,P,H,M,F,U){H<0&&(L=0),M<0&&(P=0);const N=this._bufferService.rows-1;H=Math.max(Math.min(H,N),0),M=Math.max(Math.min(M,N),0),F=Math.min(F,this._bufferService.cols);const D=this._bufferService.buffer,T=D.ybase+D.y,B=Math.min(D.x,F-1),q=this._optionsService.rawOptions.cursorBlink,K=this._optionsService.rawOptions.cursorStyle,$=this._optionsService.rawOptions.cursorInactiveStyle;for(let W=H;W<=M;++W){const z=W+D.ydisp,j=this._rowElements[W],I=D.lines.get(z);if(!j||!I)break;j.replaceChildren(...this._rowFactory.createRow(I,z,z===T,K,$,B,q,this.dimensions.css.cell.width,this._widthCache,U?W===H?L:0:-1,U?(W===M?P:F)-1:-1))}}};s.DomRenderer=O=u([f(4,c.IInstantiationService),f(5,b.ICharSizeService),f(6,c.IOptionsService),f(7,c.IBufferService),f(8,b.ICoreBrowserService),f(9,b.IThemeService)],O)},3787:function(w,s,o){var u=this&&this.__decorate||function(C,k,v,E){var R,O=arguments.length,L=O<3?k:E===null?E=Object.getOwnPropertyDescriptor(k,v):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(C,k,v,E);else for(var P=C.length-1;P>=0;P--)(R=C[P])&&(L=(O<3?R(L):O>3?R(k,v,L):R(k,v))||L);return O>3&&L&&Object.defineProperty(k,v,L),L},f=this&&this.__param||function(C,k){return function(v,E){k(v,E,C)}};Object.defineProperty(s,"__esModule",{value:!0}),s.DomRendererRowFactory=void 0;const d=o(2223),p=o(643),m=o(511),y=o(2585),b=o(8055),r=o(4725),a=o(4269),l=o(6171),c=o(3734);let g=s.DomRendererRowFactory=class{constructor(C,k,v,E,R,O,L){this._document=C,this._characterJoinerService=k,this._optionsService=v,this._coreBrowserService=E,this._coreService=R,this._decorationService=O,this._themeService=L,this._workCell=new m.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(C,k,v){this._selectionStart=C,this._selectionEnd=k,this._columnSelectMode=v}createRow(C,k,v,E,R,O,L,P,H,M,F){const U=[],N=this._characterJoinerService.getJoinedCharacters(k),D=this._themeService.colors;let T,B=C.getNoBgTrimmedLength();v&&B<O+1&&(B=O+1);let q=0,K="",$=0,W=0,z=0,j=!1,I=0,X=!1,Y=0;const Z=[],G=M!==-1&&F!==-1;for(let te=0;te<B;te++){C.loadCell(te,this._workCell);let le=this._workCell.getWidth();if(le===0)continue;let J=!1,ne=te,re=this._workCell;if(N.length>0&&te===N[0][0]){J=!0;const ce=N.shift();re=new a.JoinedCellData(this._workCell,C.translateToString(!0,ce[0],ce[1]),ce[1]-ce[0]),ne=ce[1]-1,le=re.getWidth()}const ye=this._isCellInSelection(te,k),ut=v&&te===O,Re=G&&te>=M&&te<=F;let Pe=!1;this._decorationService.forEachDecorationAtCell(te,k,void 0,(ce=>{Pe=!0}));let Ze=re.getChars()||p.WHITESPACE_CELL_CHAR;if(Ze===" "&&(re.isUnderline()||re.isOverline())&&(Ze=" "),Y=le*P-H.get(Ze,re.isBold(),re.isItalic()),T){if(q&&(ye&&X||!ye&&!X&&re.bg===$)&&(ye&&X&&D.selectionForeground||re.fg===W)&&re.extended.ext===z&&Re===j&&Y===I&&!ut&&!J&&!Pe){K+=Ze,q++;continue}q&&(T.textContent=K),T=this._document.createElement("span"),q=0,K=""}else T=this._document.createElement("span");if($=re.bg,W=re.fg,z=re.extended.ext,j=Re,I=Y,X=ye,J&&O>=te&&O<=ne&&(O=te),!this._coreService.isCursorHidden&&ut){if(Z.push("xterm-cursor"),this._coreBrowserService.isFocused)L&&Z.push("xterm-cursor-blink"),Z.push(E==="bar"?"xterm-cursor-bar":E==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":Z.push("xterm-cursor-outline");break;case"block":Z.push("xterm-cursor-block");break;case"bar":Z.push("xterm-cursor-bar");break;case"underline":Z.push("xterm-cursor-underline")}}if(re.isBold()&&Z.push("xterm-bold"),re.isItalic()&&Z.push("xterm-italic"),re.isDim()&&Z.push("xterm-dim"),K=re.isInvisible()?p.WHITESPACE_CELL_CHAR:re.getChars()||p.WHITESPACE_CELL_CHAR,re.isUnderline()&&(Z.push(`xterm-underline-${re.extended.underlineStyle}`),K===" "&&(K=" "),!re.isUnderlineColorDefault()))if(re.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${c.AttributeData.toColorRGB(re.getUnderlineColor()).join(",")})`;else{let ce=re.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&re.isBold()&&ce<8&&(ce+=8),T.style.textDecorationColor=D.ansi[ce].css}re.isOverline()&&(Z.push("xterm-overline"),K===" "&&(K=" ")),re.isStrikethrough()&&Z.push("xterm-strikethrough"),Re&&(T.style.textDecoration="underline");let _e=re.getFgColor(),Qe=re.getFgColorMode(),be=re.getBgColor(),Je=re.getBgColorMode();const Te=!!re.isInverse();if(Te){const ce=_e;_e=be,be=ce;const Zt=Qe;Qe=Je,Je=Zt}let ve,et,we,Fe=!1;switch(this._decorationService.forEachDecorationAtCell(te,k,void 0,(ce=>{ce.options.layer!=="top"&&Fe||(ce.backgroundColorRGB&&(Je=50331648,be=ce.backgroundColorRGB.rgba>>8&16777215,ve=ce.backgroundColorRGB),ce.foregroundColorRGB&&(Qe=50331648,_e=ce.foregroundColorRGB.rgba>>8&16777215,et=ce.foregroundColorRGB),Fe=ce.options.layer==="top")})),!Fe&&ye&&(ve=this._coreBrowserService.isFocused?D.selectionBackgroundOpaque:D.selectionInactiveBackgroundOpaque,be=ve.rgba>>8&16777215,Je=50331648,Fe=!0,D.selectionForeground&&(Qe=50331648,_e=D.selectionForeground.rgba>>8&16777215,et=D.selectionForeground)),Fe&&Z.push("xterm-decoration-top"),Je){case 16777216:case 33554432:we=D.ansi[be],Z.push(`xterm-bg-${be}`);break;case 50331648:we=b.rgba.toColor(be>>16,be>>8&255,255&be),this._addStyle(T,`background-color:#${_((be>>>0).toString(16),"0",6)}`);break;default:Te?(we=D.foreground,Z.push(`xterm-bg-${d.INVERTED_DEFAULT_COLOR}`)):we=D.background}switch(ve||re.isDim()&&(ve=b.color.multiplyOpacity(we,.5)),Qe){case 16777216:case 33554432:re.isBold()&&_e<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(_e+=8),this._applyMinimumContrast(T,we,D.ansi[_e],re,ve,void 0)||Z.push(`xterm-fg-${_e}`);break;case 50331648:const ce=b.rgba.toColor(_e>>16&255,_e>>8&255,255&_e);this._applyMinimumContrast(T,we,ce,re,ve,et)||this._addStyle(T,`color:#${_(_e.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,we,D.foreground,re,ve,void 0)||Te&&Z.push(`xterm-fg-${d.INVERTED_DEFAULT_COLOR}`)}Z.length&&(T.className=Z.join(" "),Z.length=0),ut||J||Pe?T.textContent=K:q++,Y!==this.defaultSpacing&&(T.style.letterSpacing=`${Y}px`),U.push(T),te=ne}return T&&q&&(T.textContent=K),U}_applyMinimumContrast(C,k,v,E,R,O){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,l.excludeFromContrastRatioDemands)(E.getCode()))return!1;const L=this._getContrastCache(E);let P;if(R||O||(P=L.getColor(k.rgba,v.rgba)),P===void 0){const H=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);P=b.color.ensureContrastRatio(R||k,O||v,H),L.setColor((R||k).rgba,(O||v).rgba,P??null)}return!!P&&(this._addStyle(C,`color:${P.css}`),!0)}_getContrastCache(C){return C.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(C,k){C.setAttribute("style",`${C.getAttribute("style")||""}${k};`)}_isCellInSelection(C,k){const v=this._selectionStart,E=this._selectionEnd;return!(!v||!E)&&(this._columnSelectMode?v[0]<=E[0]?C>=v[0]&&k>=v[1]&&C<E[0]&&k<=E[1]:C<v[0]&&k>=v[1]&&C>=E[0]&&k<=E[1]:k>v[1]&&k<E[1]||v[1]===E[1]&&k===v[1]&&C>=v[0]&&C<E[0]||v[1]<E[1]&&k===E[1]&&C<E[0]||v[1]<E[1]&&k===v[1]&&C>=v[0])}};function _(C,k,v){for(;C.length<v;)C=k+C;return C}s.DomRendererRowFactory=g=u([f(1,r.ICharacterJoinerService),f(2,y.IOptionsService),f(3,r.ICoreBrowserService),f(4,y.ICoreService),f(5,y.IDecorationService),f(6,r.IThemeService)],g)},2550:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.WidthCache=void 0,s.WidthCache=class{constructor(o){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=o.createElement("div"),this._container.style.position="absolute",this._container.style.top="-50000px",this._container.style.width="50000px",this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";const u=o.createElement("span"),f=o.createElement("span");f.style.fontWeight="bold";const d=o.createElement("span");d.style.fontStyle="italic";const p=o.createElement("span");p.style.fontWeight="bold",p.style.fontStyle="italic",this._measureElements=[u,f,d,p],this._container.appendChild(u),this._container.appendChild(f),this._container.appendChild(d),this._container.appendChild(p),o.body.appendChild(this._container),this.clear()}dispose(){this._container.remove(),this._measureElements.length=0,this._holey=void 0}clear(){this._flat.fill(-9999),this._holey=new Map}setFont(o,u,f,d){o===this._font&&u===this._fontSize&&f===this._weight&&d===this._weightBold||(this._font=o,this._fontSize=u,this._weight=f,this._weightBold=d,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${d}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${d}`,this.clear())}get(o,u,f){let d=0;if(!u&&!f&&o.length===1&&(d=o.charCodeAt(0))<256)return this._flat[d]!==-9999?this._flat[d]:this._flat[d]=this._measure(o,0);let p=o;u&&(p+="B"),f&&(p+="I");let m=this._holey.get(p);if(m===void 0){let y=0;u&&(y|=1),f&&(y|=2),m=this._measure(o,y),this._holey.set(p,m)}return m}_measure(o,u){const f=this._measureElements[u];return f.textContent=o.repeat(32),f.offsetWidth/32}}},2223:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.TEXT_BASELINE=s.DIM_OPACITY=s.INVERTED_DEFAULT_COLOR=void 0;const u=o(6114);s.INVERTED_DEFAULT_COLOR=257,s.DIM_OPACITY=.5,s.TEXT_BASELINE=u.isFirefox||u.isLegacyEdge?"bottom":"ideographic"},6171:(w,s)=>{function o(u){return 57508<=u&&u<=57558}Object.defineProperty(s,"__esModule",{value:!0}),s.createRenderDimensions=s.excludeFromContrastRatioDemands=s.isRestrictedPowerlineGlyph=s.isPowerlineGlyph=s.throwIfFalsy=void 0,s.throwIfFalsy=function(u){if(!u)throw new Error("value must not be falsy");return u},s.isPowerlineGlyph=o,s.isRestrictedPowerlineGlyph=function(u){return 57520<=u&&u<=57527},s.excludeFromContrastRatioDemands=function(u){return o(u)||(function(f){return 9472<=f&&f<=9631})(u)},s.createRenderDimensions=function(){return{css:{canvas:{width:0,height:0},cell:{width:0,height:0}},device:{canvas:{width:0,height:0},cell:{width:0,height:0},char:{width:0,height:0,left:0,top:0}}}}},456:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.SelectionModel=void 0,s.SelectionModel=class{constructor(o){this._bufferService=o,this.isSelectAllActive=!1,this.selectionStartLength=0}clearSelection(){this.selectionStart=void 0,this.selectionEnd=void 0,this.isSelectAllActive=!1,this.selectionStartLength=0}get finalSelectionStart(){return this.isSelectAllActive?[0,0]:this.selectionEnd&&this.selectionStart&&this.areSelectionValuesReversed()?this.selectionEnd:this.selectionStart}get finalSelectionEnd(){if(this.isSelectAllActive)return[this._bufferService.cols,this._bufferService.buffer.ybase+this._bufferService.rows-1];if(this.selectionStart){if(!this.selectionEnd||this.areSelectionValuesReversed()){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?o%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)-1]:[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[o,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const o=this.selectionStart[0]+this.selectionStartLength;return o>this._bufferService.cols?[o%this._bufferService.cols,this.selectionStart[1]+Math.floor(o/this._bufferService.cols)]:[Math.max(o,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const o=this.selectionStart,u=this.selectionEnd;return!(!o||!u)&&(o[1]>u[1]||o[1]===u[1]&&o[0]>u[0])}handleTrim(o){return this.selectionStart&&(this.selectionStart[1]-=o),this.selectionEnd&&(this.selectionEnd[1]-=o),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(w,s,o){var u=this&&this.__decorate||function(r,a,l,c){var g,_=arguments.length,C=_<3?a:c===null?c=Object.getOwnPropertyDescriptor(a,l):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(r,a,l,c);else for(var k=r.length-1;k>=0;k--)(g=r[k])&&(C=(_<3?g(C):_>3?g(a,l,C):g(a,l))||C);return _>3&&C&&Object.defineProperty(a,l,C),C},f=this&&this.__param||function(r,a){return function(l,c){a(l,c,r)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CharSizeService=void 0;const d=o(2585),p=o(8460),m=o(844);let y=s.CharSizeService=class extends m.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(r,a,l){super(),this._optionsService=l,this.width=0,this.height=0,this._onCharSizeChange=this.register(new p.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new b(r,a,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const r=this._measureStrategy.measure();r.width===this.width&&r.height===this.height||(this.width=r.width,this.height=r.height,this._onCharSizeChange.fire())}};s.CharSizeService=y=u([f(2,d.IOptionsService)],y);class b{constructor(a,l,c){this._document=a,this._parentElement=l,this._optionsService=c,this._result={width:0,height:0},this._measureElement=this._document.createElement("span"),this._measureElement.classList.add("xterm-char-measure-element"),this._measureElement.textContent="W".repeat(32),this._measureElement.setAttribute("aria-hidden","true"),this._measureElement.style.whiteSpace="pre",this._measureElement.style.fontKerning="none",this._parentElement.appendChild(this._measureElement)}measure(){this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`;const a={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return a.width!==0&&a.height!==0&&(this._result.width=a.width/32,this._result.height=Math.ceil(a.height)),this._result}}},4269:function(w,s,o){var u=this&&this.__decorate||function(a,l,c,g){var _,C=arguments.length,k=C<3?l:g===null?g=Object.getOwnPropertyDescriptor(l,c):g;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(a,l,c,g);else for(var v=a.length-1;v>=0;v--)(_=a[v])&&(k=(C<3?_(k):C>3?_(l,c,k):_(l,c))||k);return C>3&&k&&Object.defineProperty(l,c,k),k},f=this&&this.__param||function(a,l){return function(c,g){l(c,g,a)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CharacterJoinerService=s.JoinedCellData=void 0;const d=o(3734),p=o(643),m=o(511),y=o(2585);class b extends d.AttributeData{constructor(l,c,g){super(),this.content=0,this.combinedData="",this.fg=l.fg,this.bg=l.bg,this.combinedData=c,this._width=g}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(l){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}s.JoinedCellData=b;let r=s.CharacterJoinerService=class ii{constructor(l){this._bufferService=l,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new m.CellData}register(l){const c={id:this._nextCharacterJoinerId++,handler:l};return this._characterJoiners.push(c),c.id}deregister(l){for(let c=0;c<this._characterJoiners.length;c++)if(this._characterJoiners[c].id===l)return this._characterJoiners.splice(c,1),!0;return!1}getJoinedCharacters(l){if(this._characterJoiners.length===0)return[];const c=this._bufferService.buffer.lines.get(l);if(!c||c.length===0)return[];const g=[],_=c.translateToString(!0);let C=0,k=0,v=0,E=c.getFg(0),R=c.getBg(0);for(let O=0;O<c.getTrimmedLength();O++)if(c.loadCell(O,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==E||this._workCell.bg!==R){if(O-C>1){const L=this._getJoinedRanges(_,v,k,c,C);for(let P=0;P<L.length;P++)g.push(L[P])}C=O,v=k,E=this._workCell.fg,R=this._workCell.bg}k+=this._workCell.getChars().length||p.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-C>1){const O=this._getJoinedRanges(_,v,k,c,C);for(let L=0;L<O.length;L++)g.push(O[L])}return g}_getJoinedRanges(l,c,g,_,C){const k=l.substring(c,g);let v=[];try{v=this._characterJoiners[0].handler(k)}catch(E){console.error(E)}for(let E=1;E<this._characterJoiners.length;E++)try{const R=this._characterJoiners[E].handler(k);for(let O=0;O<R.length;O++)ii._mergeRanges(v,R[O])}catch(R){console.error(R)}return this._stringRangesToCellRanges(v,_,C),v}_stringRangesToCellRanges(l,c,g){let _=0,C=!1,k=0,v=l[_];if(v){for(let E=g;E<this._bufferService.cols;E++){const R=c.getWidth(E),O=c.getString(E).length||p.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!C&&v[0]<=k&&(v[0]=E,C=!0),v[1]<=k){if(v[1]=E,v=l[++_],!v)break;v[0]<=k?(v[0]=E,C=!0):C=!1}k+=O}}v&&(v[1]=this._bufferService.cols)}}static _mergeRanges(l,c){let g=!1;for(let _=0;_<l.length;_++){const C=l[_];if(g){if(c[1]<=C[0])return l[_-1][1]=c[1],l;if(c[1]<=C[1])return l[_-1][1]=Math.max(c[1],C[1]),l.splice(_,1),l;l.splice(_,1),_--}else{if(c[1]<=C[0])return l.splice(_,0,c),l;if(c[1]<=C[1])return C[0]=Math.min(c[0],C[0]),l;c[0]<C[1]&&(C[0]=Math.min(c[0],C[0]),g=!0)}}return g?l[l.length-1][1]=c[1]:l.push(c),l}};s.CharacterJoinerService=r=u([f(0,y.IBufferService)],r)},5114:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CoreBrowserService=void 0,s.CoreBrowserService=class{constructor(o,u){this._textarea=o,this.window=u,this._isFocused=!1,this._cachedIsFocused=void 0,this._textarea.addEventListener("focus",(()=>this._isFocused=!0)),this._textarea.addEventListener("blur",(()=>this._isFocused=!1))}get dpr(){return this.window.devicePixelRatio}get isFocused(){return this._cachedIsFocused===void 0&&(this._cachedIsFocused=this._isFocused&&this._textarea.ownerDocument.hasFocus(),queueMicrotask((()=>this._cachedIsFocused=void 0))),this._cachedIsFocused}}},8934:function(w,s,o){var u=this&&this.__decorate||function(y,b,r,a){var l,c=arguments.length,g=c<3?b:a===null?a=Object.getOwnPropertyDescriptor(b,r):a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")g=Reflect.decorate(y,b,r,a);else for(var _=y.length-1;_>=0;_--)(l=y[_])&&(g=(c<3?l(g):c>3?l(b,r,g):l(b,r))||g);return c>3&&g&&Object.defineProperty(b,r,g),g},f=this&&this.__param||function(y,b){return function(r,a){b(r,a,y)}};Object.defineProperty(s,"__esModule",{value:!0}),s.MouseService=void 0;const d=o(4725),p=o(9806);let m=s.MouseService=class{constructor(y,b){this._renderService=y,this._charSizeService=b}getCoords(y,b,r,a,l){return(0,p.getCoords)(window,y,b,r,a,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,l)}getMouseReportCoords(y,b){const r=(0,p.getCoordsRelativeToElement)(window,y,b);if(this._charSizeService.hasValidSize)return r[0]=Math.min(Math.max(r[0],0),this._renderService.dimensions.css.canvas.width-1),r[1]=Math.min(Math.max(r[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(r[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(r[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(r[0]),y:Math.floor(r[1])}}};s.MouseService=m=u([f(0,d.IRenderService),f(1,d.ICharSizeService)],m)},3230:function(w,s,o){var u=this&&this.__decorate||function(g,_,C,k){var v,E=arguments.length,R=E<3?_:k===null?k=Object.getOwnPropertyDescriptor(_,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(g,_,C,k);else for(var O=g.length-1;O>=0;O--)(v=g[O])&&(R=(E<3?v(R):E>3?v(_,C,R):v(_,C))||R);return E>3&&R&&Object.defineProperty(_,C,R),R},f=this&&this.__param||function(g,_){return function(C,k){_(C,k,g)}};Object.defineProperty(s,"__esModule",{value:!0}),s.RenderService=void 0;const d=o(3656),p=o(6193),m=o(5596),y=o(4725),b=o(8460),r=o(844),a=o(7226),l=o(2585);let c=s.RenderService=class extends r.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(g,_,C,k,v,E,R,O){if(super(),this._rowCount=g,this._charSizeService=k,this._renderer=this.register(new r.MutableDisposable),this._pausedResizeTask=new a.DebouncedIdleTask,this._isPaused=!1,this._needsFullRefresh=!1,this._isNextRenderRedrawOnly=!0,this._needsSelectionRefresh=!1,this._canvasWidth=0,this._canvasHeight=0,this._selectionState={start:void 0,end:void 0,columnSelectMode:!1},this._onDimensionsChange=this.register(new b.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new b.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new b.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new b.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new p.RenderDebouncer(R.window,((L,P)=>this._renderRows(L,P))),this.register(this._renderDebouncer),this._screenDprMonitor=new m.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(E.onResize((()=>this._fullRefresh()))),this.register(E.buffers.onBufferActivate((()=>{var L;return(L=this._renderer.value)===null||L===void 0?void 0:L.clear()}))),this.register(C.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(v.onDecorationRegistered((()=>this._fullRefresh()))),this.register(v.onDecorationRemoved((()=>this._fullRefresh()))),this.register(C.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(E.cols,E.rows),this._fullRefresh()}))),this.register(C.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(E.buffer.y,E.buffer.y,!0)))),this.register((0,d.addDisposableDomListener)(R.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(O.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in R.window){const L=new R.window.IntersectionObserver((P=>this._handleIntersectionChange(P[P.length-1])),{threshold:0});L.observe(_),this.register({dispose:()=>L.disconnect()})}}_handleIntersectionChange(g){this._isPaused=g.isIntersecting===void 0?g.intersectionRatio===0:!g.isIntersecting,this._isPaused||this._charSizeService.hasValidSize||this._charSizeService.measure(),!this._isPaused&&this._needsFullRefresh&&(this._pausedResizeTask.flush(),this.refreshRows(0,this._rowCount-1),this._needsFullRefresh=!1)}refreshRows(g,_,C=!1){this._isPaused?this._needsFullRefresh=!0:(C||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(g,_,this._rowCount))}_renderRows(g,_){this._renderer.value&&(g=Math.min(g,this._rowCount-1),_=Math.min(_,this._rowCount-1),this._renderer.value.renderRows(g,_),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:g,end:_}),this._onRender.fire({start:g,end:_}),this._isNextRenderRedrawOnly=!0)}resize(g,_){this._rowCount=_,this._fireOnCanvasResize()}_handleOptionsChanged(){this._renderer.value&&(this.refreshRows(0,this._rowCount-1),this._fireOnCanvasResize())}_fireOnCanvasResize(){this._renderer.value&&(this._renderer.value.dimensions.css.canvas.width===this._canvasWidth&&this._renderer.value.dimensions.css.canvas.height===this._canvasHeight||this._onDimensionsChange.fire(this._renderer.value.dimensions))}hasRenderer(){return!!this._renderer.value}setRenderer(g){this._renderer.value=g,this._renderer.value.onRequestRedraw((_=>this.refreshRows(_.start,_.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(g){return this._renderDebouncer.addRefreshCallback(g)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var g,_;this._renderer.value&&((_=(g=this._renderer.value).clearTextureAtlas)===null||_===void 0||_.call(g),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(g,_){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(g,_))):this._renderer.value.handleResize(g,_),this._fullRefresh())}handleCharSizeChanged(){var g;(g=this._renderer.value)===null||g===void 0||g.handleCharSizeChanged()}handleBlur(){var g;(g=this._renderer.value)===null||g===void 0||g.handleBlur()}handleFocus(){var g;(g=this._renderer.value)===null||g===void 0||g.handleFocus()}handleSelectionChanged(g,_,C){var k;this._selectionState.start=g,this._selectionState.end=_,this._selectionState.columnSelectMode=C,(k=this._renderer.value)===null||k===void 0||k.handleSelectionChanged(g,_,C)}handleCursorMove(){var g;(g=this._renderer.value)===null||g===void 0||g.handleCursorMove()}clear(){var g;(g=this._renderer.value)===null||g===void 0||g.clear()}};s.RenderService=c=u([f(2,l.IOptionsService),f(3,y.ICharSizeService),f(4,l.IDecorationService),f(5,l.IBufferService),f(6,y.ICoreBrowserService),f(7,y.IThemeService)],c)},9312:function(w,s,o){var u=this&&this.__decorate||function(v,E,R,O){var L,P=arguments.length,H=P<3?E:O===null?O=Object.getOwnPropertyDescriptor(E,R):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")H=Reflect.decorate(v,E,R,O);else for(var M=v.length-1;M>=0;M--)(L=v[M])&&(H=(P<3?L(H):P>3?L(E,R,H):L(E,R))||H);return P>3&&H&&Object.defineProperty(E,R,H),H},f=this&&this.__param||function(v,E){return function(R,O){E(R,O,v)}};Object.defineProperty(s,"__esModule",{value:!0}),s.SelectionService=void 0;const d=o(9806),p=o(9504),m=o(456),y=o(4725),b=o(8460),r=o(844),a=o(6114),l=o(4841),c=o(511),g=o(2585),_=" ",C=new RegExp(_,"g");let k=s.SelectionService=class extends r.Disposable{constructor(v,E,R,O,L,P,H,M,F){super(),this._element=v,this._screenElement=E,this._linkifier=R,this._bufferService=O,this._coreService=L,this._mouseService=P,this._optionsService=H,this._renderService=M,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new c.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new b.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new b.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new b.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new b.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=U=>this._handleMouseMove(U),this._mouseUpListener=U=>this._handleMouseUp(U),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((U=>this._handleTrim(U))),this.register(this._bufferService.buffers.onBufferActivate((U=>this._handleBufferActivate(U)))),this.enable(),this._model=new m.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,r.toDisposable)((()=>{this._removeMouseDownListeners()})))}reset(){this.clearSelection()}disable(){this.clearSelection(),this._enabled=!1}enable(){this._enabled=!0}get selectionStart(){return this._model.finalSelectionStart}get selectionEnd(){return this._model.finalSelectionEnd}get hasSelection(){const v=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!v||!E||v[0]===E[0]&&v[1]===E[1])}get selectionText(){const v=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!v||!E)return"";const R=this._bufferService.buffer,O=[];if(this._activeSelectionMode===3){if(v[0]===E[0])return"";const L=v[0]<E[0]?v[0]:E[0],P=v[0]<E[0]?E[0]:v[0];for(let H=v[1];H<=E[1];H++){const M=R.translateBufferLineToString(H,!0,L,P);O.push(M)}}else{const L=v[1]===E[1]?E[0]:void 0;O.push(R.translateBufferLineToString(v[1],!0,v[0],L));for(let P=v[1]+1;P<=E[1]-1;P++){const H=R.lines.get(P),M=R.translateBufferLineToString(P,!0);H?.isWrapped?O[O.length-1]+=M:O.push(M)}if(v[1]!==E[1]){const P=R.lines.get(E[1]),H=R.translateBufferLineToString(E[1],!0,0,E[0]);P&&P.isWrapped?O[O.length-1]+=H:O.push(H)}}return O.map((L=>L.replace(C," "))).join(a.isWindows?`\r
13
+ `:`
14
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(v){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),a.isLinux&&v&&this.selectionText.length&&this._onLinuxMouseSelection.fire(this.selectionText)}_refresh(){this._refreshAnimationFrame=void 0,this._onRedrawRequest.fire({start:this._model.finalSelectionStart,end:this._model.finalSelectionEnd,columnSelectMode:this._activeSelectionMode===3})}_isClickInSelection(v){const E=this._getMouseBufferCoords(v),R=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;return!!(R&&O&&E)&&this._areCoordsInSelection(E,R,O)}isCellInSelection(v,E){const R=this._model.finalSelectionStart,O=this._model.finalSelectionEnd;return!(!R||!O)&&this._areCoordsInSelection([v,E],R,O)}_areCoordsInSelection(v,E,R){return v[1]>E[1]&&v[1]<R[1]||E[1]===R[1]&&v[1]===E[1]&&v[0]>=E[0]&&v[0]<R[0]||E[1]<R[1]&&v[1]===R[1]&&v[0]<R[0]||E[1]<R[1]&&v[1]===E[1]&&v[0]>=E[0]}_selectWordAtCursor(v,E){var R,O;const L=(O=(R=this._linkifier.currentLink)===null||R===void 0?void 0:R.link)===null||O===void 0?void 0:O.range;if(L)return this._model.selectionStart=[L.start.x-1,L.start.y-1],this._model.selectionStartLength=(0,l.getRangeLength)(L,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const P=this._getMouseBufferCoords(v);return!!P&&(this._selectWordAt(P,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(v,E){this._model.clearSelection(),v=Math.max(v,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,v],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(v){this._model.handleTrim(v)&&this.refresh()}_getMouseBufferCoords(v){const E=this._mouseService.getCoords(v,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(v){let E=(0,d.getCoordsRelativeToElement)(this._coreBrowserService.window,v,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return E>=0&&E<=R?0:(E>R&&(E-=R),E=Math.min(Math.max(E,-50),50),E/=50,E/Math.abs(E)+Math.round(14*E))}shouldForceSelection(v){return a.isMac?v.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:v.shiftKey}handleMouseDown(v){if(this._mouseDownTimeStamp=v.timeStamp,(v.button!==2||!this.hasSelection)&&v.button===0){if(!this._enabled){if(!this.shouldForceSelection(v))return;v.stopPropagation()}v.preventDefault(),this._dragScrollAmount=0,this._enabled&&v.shiftKey?this._handleIncrementalClick(v):v.detail===1?this._handleSingleClick(v):v.detail===2?this._handleDoubleClick(v):v.detail===3&&this._handleTripleClick(v),this._addMouseDownListeners(),this.refresh(!0)}}_addMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.addEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.addEventListener("mouseup",this._mouseUpListener)),this._dragScrollIntervalTimer=this._coreBrowserService.window.setInterval((()=>this._dragScroll()),50)}_removeMouseDownListeners(){this._screenElement.ownerDocument&&(this._screenElement.ownerDocument.removeEventListener("mousemove",this._mouseMoveListener),this._screenElement.ownerDocument.removeEventListener("mouseup",this._mouseUpListener)),this._coreBrowserService.window.clearInterval(this._dragScrollIntervalTimer),this._dragScrollIntervalTimer=void 0}_handleIncrementalClick(v){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(v))}_handleSingleClick(v){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(v)?3:0,this._model.selectionStart=this._getMouseBufferCoords(v),!this._model.selectionStart)return;this._model.selectionEnd=void 0;const E=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);E&&E.length!==this._model.selectionStart[0]&&E.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(v){this._selectWordAtCursor(v,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(v){const E=this._getMouseBufferCoords(v);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(v){return v.altKey&&!(a.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(v){if(v.stopImmediatePropagation(),!this._model.selectionStart)return;const E=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(v),!this._model.selectionEnd)return void this.refresh(!0);this._activeSelectionMode===2?this._model.selectionEnd[1]<this._model.selectionStart[1]?this._model.selectionEnd[0]=0:this._model.selectionEnd[0]=this._bufferService.cols:this._activeSelectionMode===1&&this._selectToWordAt(this._model.selectionEnd),this._dragScrollAmount=this._getMouseEventScrollAmount(v),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const R=this._bufferService.buffer;if(this._model.selectionEnd[1]<R.lines.length){const O=R.lines.get(this._model.selectionEnd[1]);O&&O.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}E&&E[0]===this._model.selectionEnd[0]&&E[1]===this._model.selectionEnd[1]||this.refresh(!0)}_dragScroll(){if(this._model.selectionEnd&&this._model.selectionStart&&this._dragScrollAmount){this._onRequestScrollLines.fire({amount:this._dragScrollAmount,suppressScrollEvent:!1});const v=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(v.ydisp+this._bufferService.rows,v.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=v.ydisp),this.refresh()}}_handleMouseUp(v){const E=v.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&v.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(v,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const O=(0,p.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(O,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const v=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,R=!(!v||!E||v[0]===E[0]&&v[1]===E[1]);R?v&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&v[0]===this._oldSelectionStart[0]&&v[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(v,E,R)):this._oldHasSelection&&this._fireOnSelectionChange(v,E,R)}_fireOnSelectionChange(v,E,R){this._oldSelectionStart=v,this._oldSelectionEnd=E,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(v){this.clearSelection(),this._trimListener.dispose(),this._trimListener=v.activeBuffer.lines.onTrim((E=>this._handleTrim(E)))}_convertViewportColToCharacterIndex(v,E){let R=E;for(let O=0;E>=O;O++){const L=v.loadCell(O,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:L>1&&E!==O&&(R+=L-1)}return R}setSelection(v,E,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[v,E],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(v){this._isClickInSelection(v)||(this._selectWordAtCursor(v,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(v,E,R=!0,O=!0){if(v[0]>=this._bufferService.cols)return;const L=this._bufferService.buffer,P=L.lines.get(v[1]);if(!P)return;const H=L.translateBufferLineToString(v[1],!1);let M=this._convertViewportColToCharacterIndex(P,v[0]),F=M;const U=v[0]-M;let N=0,D=0,T=0,B=0;if(H.charAt(M)===" "){for(;M>0&&H.charAt(M-1)===" ";)M--;for(;F<H.length&&H.charAt(F+1)===" ";)F++}else{let $=v[0],W=v[0];P.getWidth($)===0&&(N++,$--),P.getWidth(W)===2&&(D++,W++);const z=P.getString(W).length;for(z>1&&(B+=z-1,F+=z-1);$>0&&M>0&&!this._isCharWordSeparator(P.loadCell($-1,this._workCell));){P.loadCell($-1,this._workCell);const j=this._workCell.getChars().length;this._workCell.getWidth()===0?(N++,$--):j>1&&(T+=j-1,M-=j-1),M--,$--}for(;W<P.length&&F+1<H.length&&!this._isCharWordSeparator(P.loadCell(W+1,this._workCell));){P.loadCell(W+1,this._workCell);const j=this._workCell.getChars().length;this._workCell.getWidth()===2?(D++,W++):j>1&&(B+=j-1,F+=j-1),F++,W++}}F++;let q=M+U-N+T,K=Math.min(this._bufferService.cols,F-M+N+D-T-B);if(E||H.slice(M,F).trim()!==""){if(R&&q===0&&P.getCodePoint(0)!==32){const $=L.lines.get(v[1]-1);if($&&P.isWrapped&&$.getCodePoint(this._bufferService.cols-1)!==32){const W=this._getWordAt([this._bufferService.cols-1,v[1]-1],!1,!0,!1);if(W){const z=this._bufferService.cols-W.start;q-=z,K+=z}}}if(O&&q+K===this._bufferService.cols&&P.getCodePoint(this._bufferService.cols-1)!==32){const $=L.lines.get(v[1]+1);if($?.isWrapped&&$.getCodePoint(0)!==32){const W=this._getWordAt([0,v[1]+1],!1,!1,!0);W&&(K+=W.length)}}return{start:q,length:K}}}_selectWordAt(v,E){const R=this._getWordAt(v,E);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,v[1]--;this._model.selectionStart=[R.start,v[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(v){const E=this._getWordAt(v,!0);if(E){let R=v[1];for(;E.start<0;)E.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;E.start+E.length>this._bufferService.cols;)E.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?E.start:E.start+E.length,R]}}_isCharWordSeparator(v){return v.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(v.getChars())>=0}_selectLineAt(v){const E=this._bufferService.buffer.getWrappedRangeForLine(v),R={start:{x:0,y:E.first},end:{x:this._bufferService.cols-1,y:E.last}};this._model.selectionStart=[0,E.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,l.getRangeLength)(R,this._bufferService.cols)}};s.SelectionService=k=u([f(3,g.IBufferService),f(4,g.ICoreService),f(5,y.IMouseService),f(6,g.IOptionsService),f(7,y.IRenderService),f(8,y.ICoreBrowserService)],k)},4725:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.IThemeService=s.ICharacterJoinerService=s.ISelectionService=s.IRenderService=s.IMouseService=s.ICoreBrowserService=s.ICharSizeService=void 0;const u=o(8343);s.ICharSizeService=(0,u.createDecorator)("CharSizeService"),s.ICoreBrowserService=(0,u.createDecorator)("CoreBrowserService"),s.IMouseService=(0,u.createDecorator)("MouseService"),s.IRenderService=(0,u.createDecorator)("RenderService"),s.ISelectionService=(0,u.createDecorator)("SelectionService"),s.ICharacterJoinerService=(0,u.createDecorator)("CharacterJoinerService"),s.IThemeService=(0,u.createDecorator)("ThemeService")},6731:function(w,s,o){var u=this&&this.__decorate||function(k,v,E,R){var O,L=arguments.length,P=L<3?v:R===null?R=Object.getOwnPropertyDescriptor(v,E):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(k,v,E,R);else for(var H=k.length-1;H>=0;H--)(O=k[H])&&(P=(L<3?O(P):L>3?O(v,E,P):O(v,E))||P);return L>3&&P&&Object.defineProperty(v,E,P),P},f=this&&this.__param||function(k,v){return function(E,R){v(E,R,k)}};Object.defineProperty(s,"__esModule",{value:!0}),s.ThemeService=s.DEFAULT_ANSI_COLORS=void 0;const d=o(7239),p=o(8055),m=o(8460),y=o(844),b=o(2585),r=p.css.toColor("#ffffff"),a=p.css.toColor("#000000"),l=p.css.toColor("#ffffff"),c=p.css.toColor("#000000"),g={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};s.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const k=[p.css.toColor("#2e3436"),p.css.toColor("#cc0000"),p.css.toColor("#4e9a06"),p.css.toColor("#c4a000"),p.css.toColor("#3465a4"),p.css.toColor("#75507b"),p.css.toColor("#06989a"),p.css.toColor("#d3d7cf"),p.css.toColor("#555753"),p.css.toColor("#ef2929"),p.css.toColor("#8ae234"),p.css.toColor("#fce94f"),p.css.toColor("#729fcf"),p.css.toColor("#ad7fa8"),p.css.toColor("#34e2e2"),p.css.toColor("#eeeeec")],v=[0,95,135,175,215,255];for(let E=0;E<216;E++){const R=v[E/36%6|0],O=v[E/6%6|0],L=v[E%6];k.push({css:p.channels.toCss(R,O,L),rgba:p.channels.toRgba(R,O,L)})}for(let E=0;E<24;E++){const R=8+10*E;k.push({css:p.channels.toCss(R,R,R),rgba:p.channels.toRgba(R,R,R)})}return k})());let _=s.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(k){super(),this._optionsService=k,this._contrastCache=new d.ColorContrastCache,this._halfContrastCache=new d.ColorContrastCache,this._onChangeColors=this.register(new m.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:r,background:a,cursor:l,cursorAccent:c,selectionForeground:void 0,selectionBackgroundTransparent:g,selectionBackgroundOpaque:p.color.blend(a,g),selectionInactiveBackgroundTransparent:g,selectionInactiveBackgroundOpaque:p.color.blend(a,g),ansi:s.DEFAULT_ANSI_COLORS.slice(),contrastCache:this._contrastCache,halfContrastCache:this._halfContrastCache},this._updateRestoreColors(),this._setTheme(this._optionsService.rawOptions.theme),this.register(this._optionsService.onSpecificOptionChange("minimumContrastRatio",(()=>this._contrastCache.clear()))),this.register(this._optionsService.onSpecificOptionChange("theme",(()=>this._setTheme(this._optionsService.rawOptions.theme))))}_setTheme(k={}){const v=this._colors;if(v.foreground=C(k.foreground,r),v.background=C(k.background,a),v.cursor=C(k.cursor,l),v.cursorAccent=C(k.cursorAccent,c),v.selectionBackgroundTransparent=C(k.selectionBackground,g),v.selectionBackgroundOpaque=p.color.blend(v.background,v.selectionBackgroundTransparent),v.selectionInactiveBackgroundTransparent=C(k.selectionInactiveBackground,v.selectionBackgroundTransparent),v.selectionInactiveBackgroundOpaque=p.color.blend(v.background,v.selectionInactiveBackgroundTransparent),v.selectionForeground=k.selectionForeground?C(k.selectionForeground,p.NULL_COLOR):void 0,v.selectionForeground===p.NULL_COLOR&&(v.selectionForeground=void 0),p.color.isOpaque(v.selectionBackgroundTransparent)&&(v.selectionBackgroundTransparent=p.color.opacity(v.selectionBackgroundTransparent,.3)),p.color.isOpaque(v.selectionInactiveBackgroundTransparent)&&(v.selectionInactiveBackgroundTransparent=p.color.opacity(v.selectionInactiveBackgroundTransparent,.3)),v.ansi=s.DEFAULT_ANSI_COLORS.slice(),v.ansi[0]=C(k.black,s.DEFAULT_ANSI_COLORS[0]),v.ansi[1]=C(k.red,s.DEFAULT_ANSI_COLORS[1]),v.ansi[2]=C(k.green,s.DEFAULT_ANSI_COLORS[2]),v.ansi[3]=C(k.yellow,s.DEFAULT_ANSI_COLORS[3]),v.ansi[4]=C(k.blue,s.DEFAULT_ANSI_COLORS[4]),v.ansi[5]=C(k.magenta,s.DEFAULT_ANSI_COLORS[5]),v.ansi[6]=C(k.cyan,s.DEFAULT_ANSI_COLORS[6]),v.ansi[7]=C(k.white,s.DEFAULT_ANSI_COLORS[7]),v.ansi[8]=C(k.brightBlack,s.DEFAULT_ANSI_COLORS[8]),v.ansi[9]=C(k.brightRed,s.DEFAULT_ANSI_COLORS[9]),v.ansi[10]=C(k.brightGreen,s.DEFAULT_ANSI_COLORS[10]),v.ansi[11]=C(k.brightYellow,s.DEFAULT_ANSI_COLORS[11]),v.ansi[12]=C(k.brightBlue,s.DEFAULT_ANSI_COLORS[12]),v.ansi[13]=C(k.brightMagenta,s.DEFAULT_ANSI_COLORS[13]),v.ansi[14]=C(k.brightCyan,s.DEFAULT_ANSI_COLORS[14]),v.ansi[15]=C(k.brightWhite,s.DEFAULT_ANSI_COLORS[15]),k.extendedAnsi){const E=Math.min(v.ansi.length-16,k.extendedAnsi.length);for(let R=0;R<E;R++)v.ansi[R+16]=C(k.extendedAnsi[R],s.DEFAULT_ANSI_COLORS[R+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(k){this._restoreColor(k),this._onChangeColors.fire(this.colors)}_restoreColor(k){if(k!==void 0)switch(k){case 256:this._colors.foreground=this._restoreColors.foreground;break;case 257:this._colors.background=this._restoreColors.background;break;case 258:this._colors.cursor=this._restoreColors.cursor;break;default:this._colors.ansi[k]=this._restoreColors.ansi[k]}else for(let v=0;v<this._restoreColors.ansi.length;++v)this._colors.ansi[v]=this._restoreColors.ansi[v]}modifyColors(k){k(this._colors),this._onChangeColors.fire(this.colors)}_updateRestoreColors(){this._restoreColors={foreground:this._colors.foreground,background:this._colors.background,cursor:this._colors.cursor,ansi:this._colors.ansi.slice()}}};function C(k,v){if(k!==void 0)try{return p.css.toColor(k)}catch{}return v}s.ThemeService=_=u([f(0,b.IOptionsService)],_)},6349:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CircularList=void 0;const u=o(8460),f=o(844);class d extends f.Disposable{constructor(m){super(),this._maxLength=m,this.onDeleteEmitter=this.register(new u.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new u.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new u.EventEmitter),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(m){if(this._maxLength===m)return;const y=new Array(m);for(let b=0;b<Math.min(m,this.length);b++)y[b]=this._array[this._getCyclicIndex(b)];this._array=y,this._maxLength=m,this._startIndex=0}get length(){return this._length}set length(m){if(m>this._length)for(let y=this._length;y<m;y++)this._array[y]=void 0;this._length=m}get(m){return this._array[this._getCyclicIndex(m)]}set(m,y){this._array[this._getCyclicIndex(m)]=y}push(m){this._array[this._getCyclicIndex(this._length)]=m,this._length===this._maxLength?(this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1)):this._length++}recycle(){if(this._length!==this._maxLength)throw new Error("Can only recycle when the buffer is full");return this._startIndex=++this._startIndex%this._maxLength,this.onTrimEmitter.fire(1),this._array[this._getCyclicIndex(this._length-1)]}get isFull(){return this._length===this._maxLength}pop(){return this._array[this._getCyclicIndex(this._length---1)]}splice(m,y,...b){if(y){for(let r=m;r<this._length-y;r++)this._array[this._getCyclicIndex(r)]=this._array[this._getCyclicIndex(r+y)];this._length-=y,this.onDeleteEmitter.fire({index:m,amount:y})}for(let r=this._length-1;r>=m;r--)this._array[this._getCyclicIndex(r+b.length)]=this._array[this._getCyclicIndex(r)];for(let r=0;r<b.length;r++)this._array[this._getCyclicIndex(m+r)]=b[r];if(b.length&&this.onInsertEmitter.fire({index:m,amount:b.length}),this._length+b.length>this._maxLength){const r=this._length+b.length-this._maxLength;this._startIndex+=r,this._length=this._maxLength,this.onTrimEmitter.fire(r)}else this._length+=b.length}trimStart(m){m>this._length&&(m=this._length),this._startIndex+=m,this._length-=m,this.onTrimEmitter.fire(m)}shiftElements(m,y,b){if(!(y<=0)){if(m<0||m>=this._length)throw new Error("start argument out of range");if(m+b<0)throw new Error("Cannot shift elements in list beyond index 0");if(b>0){for(let a=y-1;a>=0;a--)this.set(m+a+b,this.get(m+a));const r=m+y+b-this._length;if(r>0)for(this._length+=r;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let r=0;r<y;r++)this.set(m+r+b,this.get(m+r))}}_getCyclicIndex(m){return(this._startIndex+m)%this._maxLength}}s.CircularList=d},1439:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.clone=void 0,s.clone=function o(u,f=5){if(typeof u!="object")return u;const d=Array.isArray(u)?[]:{};for(const p in u)d[p]=f<=1?u[p]:u[p]&&o(u[p],f-1);return d}},8055:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.contrastRatio=s.toPaddedHex=s.rgba=s.rgb=s.css=s.color=s.channels=s.NULL_COLOR=void 0;const u=o(6114);let f=0,d=0,p=0,m=0;var y,b,r,a,l;function c(_){const C=_.toString(16);return C.length<2?"0"+C:C}function g(_,C){return _<C?(C+.05)/(_+.05):(_+.05)/(C+.05)}s.NULL_COLOR={css:"#00000000",rgba:0},(function(_){_.toCss=function(C,k,v,E){return E!==void 0?`#${c(C)}${c(k)}${c(v)}${c(E)}`:`#${c(C)}${c(k)}${c(v)}`},_.toRgba=function(C,k,v,E=255){return(C<<24|k<<16|v<<8|E)>>>0}})(y||(s.channels=y={})),(function(_){function C(k,v){return m=Math.round(255*v),[f,d,p]=l.toChannels(k.rgba),{css:y.toCss(f,d,p,m),rgba:y.toRgba(f,d,p,m)}}_.blend=function(k,v){if(m=(255&v.rgba)/255,m===1)return{css:v.css,rgba:v.rgba};const E=v.rgba>>24&255,R=v.rgba>>16&255,O=v.rgba>>8&255,L=k.rgba>>24&255,P=k.rgba>>16&255,H=k.rgba>>8&255;return f=L+Math.round((E-L)*m),d=P+Math.round((R-P)*m),p=H+Math.round((O-H)*m),{css:y.toCss(f,d,p),rgba:y.toRgba(f,d,p)}},_.isOpaque=function(k){return(255&k.rgba)==255},_.ensureContrastRatio=function(k,v,E){const R=l.ensureContrastRatio(k.rgba,v.rgba,E);if(R)return l.toColor(R>>24&255,R>>16&255,R>>8&255)},_.opaque=function(k){const v=(255|k.rgba)>>>0;return[f,d,p]=l.toChannels(v),{css:y.toCss(f,d,p),rgba:v}},_.opacity=C,_.multiplyOpacity=function(k,v){return m=255&k.rgba,C(k,m*v/255)},_.toColorRGB=function(k){return[k.rgba>>24&255,k.rgba>>16&255,k.rgba>>8&255]}})(b||(s.color=b={})),(function(_){let C,k;if(!u.isNode){const v=document.createElement("canvas");v.width=1,v.height=1;const E=v.getContext("2d",{willReadFrequently:!0});E&&(C=E,C.globalCompositeOperation="copy",k=C.createLinearGradient(0,0,1,1))}_.toColor=function(v){if(v.match(/#[\da-f]{3,8}/i))switch(v.length){case 4:return f=parseInt(v.slice(1,2).repeat(2),16),d=parseInt(v.slice(2,3).repeat(2),16),p=parseInt(v.slice(3,4).repeat(2),16),l.toColor(f,d,p);case 5:return f=parseInt(v.slice(1,2).repeat(2),16),d=parseInt(v.slice(2,3).repeat(2),16),p=parseInt(v.slice(3,4).repeat(2),16),m=parseInt(v.slice(4,5).repeat(2),16),l.toColor(f,d,p,m);case 7:return{css:v,rgba:(parseInt(v.slice(1),16)<<8|255)>>>0};case 9:return{css:v,rgba:parseInt(v.slice(1),16)>>>0}}const E=v.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(E)return f=parseInt(E[1]),d=parseInt(E[2]),p=parseInt(E[3]),m=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),l.toColor(f,d,p,m);if(!C||!k)throw new Error("css.toColor: Unsupported css format");if(C.fillStyle=k,C.fillStyle=v,typeof C.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(C.fillRect(0,0,1,1),[f,d,p,m]=C.getImageData(0,0,1,1).data,m!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(f,d,p,m),css:v}}})(r||(s.css=r={})),(function(_){function C(k,v,E){const R=k/255,O=v/255,L=E/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(O<=.03928?O/12.92:Math.pow((O+.055)/1.055,2.4))+.0722*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))}_.relativeLuminance=function(k){return C(k>>16&255,k>>8&255,255&k)},_.relativeLuminance2=C})(a||(s.rgb=a={})),(function(_){function C(v,E,R){const O=v>>24&255,L=v>>16&255,P=v>>8&255;let H=E>>24&255,M=E>>16&255,F=E>>8&255,U=g(a.relativeLuminance2(H,M,F),a.relativeLuminance2(O,L,P));for(;U<R&&(H>0||M>0||F>0);)H-=Math.max(0,Math.ceil(.1*H)),M-=Math.max(0,Math.ceil(.1*M)),F-=Math.max(0,Math.ceil(.1*F)),U=g(a.relativeLuminance2(H,M,F),a.relativeLuminance2(O,L,P));return(H<<24|M<<16|F<<8|255)>>>0}function k(v,E,R){const O=v>>24&255,L=v>>16&255,P=v>>8&255;let H=E>>24&255,M=E>>16&255,F=E>>8&255,U=g(a.relativeLuminance2(H,M,F),a.relativeLuminance2(O,L,P));for(;U<R&&(H<255||M<255||F<255);)H=Math.min(255,H+Math.ceil(.1*(255-H))),M=Math.min(255,M+Math.ceil(.1*(255-M))),F=Math.min(255,F+Math.ceil(.1*(255-F))),U=g(a.relativeLuminance2(H,M,F),a.relativeLuminance2(O,L,P));return(H<<24|M<<16|F<<8|255)>>>0}_.ensureContrastRatio=function(v,E,R){const O=a.relativeLuminance(v>>8),L=a.relativeLuminance(E>>8);if(g(O,L)<R){if(L<O){const M=C(v,E,R),F=g(O,a.relativeLuminance(M>>8));if(F<R){const U=k(v,E,R);return F>g(O,a.relativeLuminance(U>>8))?M:U}return M}const P=k(v,E,R),H=g(O,a.relativeLuminance(P>>8));if(H<R){const M=C(v,E,R);return H>g(O,a.relativeLuminance(M>>8))?P:M}return P}},_.reduceLuminance=C,_.increaseLuminance=k,_.toChannels=function(v){return[v>>24&255,v>>16&255,v>>8&255,255&v]},_.toColor=function(v,E,R,O){return{css:y.toCss(v,E,R,O),rgba:y.toRgba(v,E,R,O)}}})(l||(s.rgba=l={})),s.toPaddedHex=c,s.contrastRatio=g},8969:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CoreTerminal=void 0;const u=o(844),f=o(2585),d=o(4348),p=o(7866),m=o(744),y=o(7302),b=o(6975),r=o(8460),a=o(1753),l=o(1480),c=o(7994),g=o(9282),_=o(5435),C=o(5981),k=o(2660);let v=!1;class E extends u.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new r.EventEmitter),this._onScroll.event((O=>{var L;(L=this._onScrollApi)===null||L===void 0||L.fire(O.position)}))),this._onScrollApi.event}get cols(){return this._bufferService.cols}get rows(){return this._bufferService.rows}get buffers(){return this._bufferService.buffers}get options(){return this.optionsService.options}set options(O){for(const L in O)this.optionsService.options[L]=O[L]}constructor(O){super(),this._windowsWrappingHeuristics=this.register(new u.MutableDisposable),this._onBinary=this.register(new r.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new r.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new r.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new r.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new r.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new r.EventEmitter),this._instantiationService=new d.InstantiationService,this.optionsService=this.register(new y.OptionsService(O)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(m.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(p.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(b.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(a.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(l.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(c.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(k.OscLinkService),this._instantiationService.setService(f.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new _.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,r.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,r.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,r.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,r.forwardEvent)(this.coreService.onBinary,this._onBinary)),this.register(this.coreService.onRequestScrollToBottom((()=>this.scrollToBottom()))),this.register(this.coreService.onUserInput((()=>this._writeBuffer.handleUserInput()))),this.register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],(()=>this._handleWindowsPtyOptionChange()))),this.register(this._bufferService.onScroll((L=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this.register(this._inputHandler.onScroll((L=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp,source:0}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)}))),this._writeBuffer=this.register(new C.WriteBuffer(((L,P)=>this._inputHandler.parse(L,P)))),this.register((0,r.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(O,L){this._writeBuffer.write(O,L)}writeSync(O,L){this._logService.logLevel<=f.LogLevelEnum.WARN&&!v&&(this._logService.warn("writeSync is unreliable and will be removed soon."),v=!0),this._writeBuffer.writeSync(O,L)}resize(O,L){isNaN(O)||isNaN(L)||(O=Math.max(O,m.MINIMUM_COLS),L=Math.max(L,m.MINIMUM_ROWS),this._bufferService.resize(O,L))}scroll(O,L=!1){this._bufferService.scroll(O,L)}scrollLines(O,L,P){this._bufferService.scrollLines(O,L,P)}scrollPages(O){this.scrollLines(O*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(O){const L=O-this._bufferService.buffer.ydisp;L!==0&&this.scrollLines(L)}registerEscHandler(O,L){return this._inputHandler.registerEscHandler(O,L)}registerDcsHandler(O,L){return this._inputHandler.registerDcsHandler(O,L)}registerCsiHandler(O,L){return this._inputHandler.registerCsiHandler(O,L)}registerOscHandler(O,L){return this._inputHandler.registerOscHandler(O,L)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let O=!1;const L=this.optionsService.rawOptions.windowsPty;L&&L.buildNumber!==void 0&&L.buildNumber!==void 0?O=L.backend==="conpty"&&L.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(O=!0),O?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const O=[];O.push(this.onLineFeed(g.updateWindowsModeWrappedState.bind(null,this._bufferService))),O.push(this.registerCsiHandler({final:"H"},(()=>((0,g.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,u.toDisposable)((()=>{for(const L of O)L.dispose()}))}}}s.CoreTerminal=E},8460:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.forwardEvent=s.EventEmitter=void 0,s.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=o=>(this._listeners.push(o),{dispose:()=>{if(!this._disposed){for(let u=0;u<this._listeners.length;u++)if(this._listeners[u]===o)return void this._listeners.splice(u,1)}}})),this._event}fire(o,u){const f=[];for(let d=0;d<this._listeners.length;d++)f.push(this._listeners[d]);for(let d=0;d<f.length;d++)f[d].call(void 0,o,u)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},s.forwardEvent=function(o,u){return o((f=>u.fire(f)))}},5435:function(w,s,o){var u=this&&this.__decorate||function(U,N,D,T){var B,q=arguments.length,K=q<3?N:T===null?T=Object.getOwnPropertyDescriptor(N,D):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")K=Reflect.decorate(U,N,D,T);else for(var $=U.length-1;$>=0;$--)(B=U[$])&&(K=(q<3?B(K):q>3?B(N,D,K):B(N,D))||K);return q>3&&K&&Object.defineProperty(N,D,K),K},f=this&&this.__param||function(U,N){return function(D,T){N(D,T,U)}};Object.defineProperty(s,"__esModule",{value:!0}),s.InputHandler=s.WindowsOptionsReportType=void 0;const d=o(2584),p=o(7116),m=o(2015),y=o(844),b=o(482),r=o(8437),a=o(8460),l=o(643),c=o(511),g=o(3734),_=o(2585),C=o(6242),k=o(6351),v=o(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function O(U,N){if(U>24)return N.setWinLines||!1;switch(U){case 1:return!!N.restoreWin;case 2:return!!N.minimizeWin;case 3:return!!N.setWinPosition;case 4:return!!N.setWinSizePixels;case 5:return!!N.raiseWin;case 6:return!!N.lowerWin;case 7:return!!N.refreshWin;case 8:return!!N.setWinSizeChars;case 9:return!!N.maximizeWin;case 10:return!!N.fullscreenWin;case 11:return!!N.getWinState;case 13:return!!N.getWinPosition;case 14:return!!N.getWinSizePixels;case 15:return!!N.getScreenSizePixels;case 16:return!!N.getCellSizePixels;case 18:return!!N.getWinSizeChars;case 19:return!!N.getScreenSizeChars;case 20:return!!N.getIconTitle;case 21:return!!N.getWinTitle;case 22:return!!N.pushTitle;case 23:return!!N.popTitle;case 24:return!!N.setWinLines}return!1}var L;(function(U){U[U.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",U[U.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(L||(s.WindowsOptionsReportType=L={}));let P=0;class H extends y.Disposable{getAttrData(){return this._curAttrData}constructor(N,D,T,B,q,K,$,W,z=new m.EscapeSequenceParser){super(),this._bufferService=N,this._charsetService=D,this._coreService=T,this._logService=B,this._optionsService=q,this._oscLinkService=K,this._coreMouseService=$,this._unicodeService=W,this._parser=z,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new b.StringToUtf32,this._utf8Decoder=new b.Utf8ToUtf32,this._workCell=new c.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=r.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=r.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new a.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new a.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new a.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new a.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new a.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new a.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new a.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new a.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new a.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new a.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new a.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new a.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new a.EventEmitter),this.onColor=this._onColor.event,this._parseStack={paused:!1,cursorStartX:0,cursorStartY:0,decodedLength:0,position:0},this._specialColors=[256,257,258],this.register(this._parser),this._dirtyRowTracker=new M(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((j=>this._activeBuffer=j.activeBuffer))),this._parser.setCsiHandlerFallback(((j,I)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(j),params:I.toArray()})})),this._parser.setEscHandlerFallback((j=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(j)})})),this._parser.setExecuteHandlerFallback((j=>{this._logService.debug("Unknown EXECUTE code: ",{code:j})})),this._parser.setOscHandlerFallback(((j,I,X)=>{this._logService.debug("Unknown OSC code: ",{identifier:j,action:I,data:X})})),this._parser.setDcsHandlerFallback(((j,I,X)=>{I==="HOOK"&&(X=X.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(j),action:I,payload:X})})),this._parser.setPrintHandler(((j,I,X)=>this.print(j,I,X))),this._parser.registerCsiHandler({final:"@"},(j=>this.insertChars(j))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(j=>this.scrollLeft(j))),this._parser.registerCsiHandler({final:"A"},(j=>this.cursorUp(j))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(j=>this.scrollRight(j))),this._parser.registerCsiHandler({final:"B"},(j=>this.cursorDown(j))),this._parser.registerCsiHandler({final:"C"},(j=>this.cursorForward(j))),this._parser.registerCsiHandler({final:"D"},(j=>this.cursorBackward(j))),this._parser.registerCsiHandler({final:"E"},(j=>this.cursorNextLine(j))),this._parser.registerCsiHandler({final:"F"},(j=>this.cursorPrecedingLine(j))),this._parser.registerCsiHandler({final:"G"},(j=>this.cursorCharAbsolute(j))),this._parser.registerCsiHandler({final:"H"},(j=>this.cursorPosition(j))),this._parser.registerCsiHandler({final:"I"},(j=>this.cursorForwardTab(j))),this._parser.registerCsiHandler({final:"J"},(j=>this.eraseInDisplay(j,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(j=>this.eraseInDisplay(j,!0))),this._parser.registerCsiHandler({final:"K"},(j=>this.eraseInLine(j,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(j=>this.eraseInLine(j,!0))),this._parser.registerCsiHandler({final:"L"},(j=>this.insertLines(j))),this._parser.registerCsiHandler({final:"M"},(j=>this.deleteLines(j))),this._parser.registerCsiHandler({final:"P"},(j=>this.deleteChars(j))),this._parser.registerCsiHandler({final:"S"},(j=>this.scrollUp(j))),this._parser.registerCsiHandler({final:"T"},(j=>this.scrollDown(j))),this._parser.registerCsiHandler({final:"X"},(j=>this.eraseChars(j))),this._parser.registerCsiHandler({final:"Z"},(j=>this.cursorBackwardTab(j))),this._parser.registerCsiHandler({final:"`"},(j=>this.charPosAbsolute(j))),this._parser.registerCsiHandler({final:"a"},(j=>this.hPositionRelative(j))),this._parser.registerCsiHandler({final:"b"},(j=>this.repeatPrecedingCharacter(j))),this._parser.registerCsiHandler({final:"c"},(j=>this.sendDeviceAttributesPrimary(j))),this._parser.registerCsiHandler({prefix:">",final:"c"},(j=>this.sendDeviceAttributesSecondary(j))),this._parser.registerCsiHandler({final:"d"},(j=>this.linePosAbsolute(j))),this._parser.registerCsiHandler({final:"e"},(j=>this.vPositionRelative(j))),this._parser.registerCsiHandler({final:"f"},(j=>this.hVPosition(j))),this._parser.registerCsiHandler({final:"g"},(j=>this.tabClear(j))),this._parser.registerCsiHandler({final:"h"},(j=>this.setMode(j))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(j=>this.setModePrivate(j))),this._parser.registerCsiHandler({final:"l"},(j=>this.resetMode(j))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(j=>this.resetModePrivate(j))),this._parser.registerCsiHandler({final:"m"},(j=>this.charAttributes(j))),this._parser.registerCsiHandler({final:"n"},(j=>this.deviceStatus(j))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(j=>this.deviceStatusPrivate(j))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(j=>this.softReset(j))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(j=>this.setCursorStyle(j))),this._parser.registerCsiHandler({final:"r"},(j=>this.setScrollRegion(j))),this._parser.registerCsiHandler({final:"s"},(j=>this.saveCursor(j))),this._parser.registerCsiHandler({final:"t"},(j=>this.windowOptions(j))),this._parser.registerCsiHandler({final:"u"},(j=>this.restoreCursor(j))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(j=>this.insertColumns(j))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(j=>this.deleteColumns(j))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(j=>this.selectProtected(j))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(j=>this.requestMode(j,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(j=>this.requestMode(j,!1))),this._parser.setExecuteHandler(d.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(d.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(d.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(d.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(d.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(d.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(d.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(d.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(d.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(d.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(d.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(d.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new C.OscHandler((j=>(this.setTitle(j),this.setIconName(j),!0)))),this._parser.registerOscHandler(1,new C.OscHandler((j=>this.setIconName(j)))),this._parser.registerOscHandler(2,new C.OscHandler((j=>this.setTitle(j)))),this._parser.registerOscHandler(4,new C.OscHandler((j=>this.setOrReportIndexedColor(j)))),this._parser.registerOscHandler(8,new C.OscHandler((j=>this.setHyperlink(j)))),this._parser.registerOscHandler(10,new C.OscHandler((j=>this.setOrReportFgColor(j)))),this._parser.registerOscHandler(11,new C.OscHandler((j=>this.setOrReportBgColor(j)))),this._parser.registerOscHandler(12,new C.OscHandler((j=>this.setOrReportCursorColor(j)))),this._parser.registerOscHandler(104,new C.OscHandler((j=>this.restoreIndexedColor(j)))),this._parser.registerOscHandler(110,new C.OscHandler((j=>this.restoreFgColor(j)))),this._parser.registerOscHandler(111,new C.OscHandler((j=>this.restoreBgColor(j)))),this._parser.registerOscHandler(112,new C.OscHandler((j=>this.restoreCursorColor(j)))),this._parser.registerEscHandler({final:"7"},(()=>this.saveCursor())),this._parser.registerEscHandler({final:"8"},(()=>this.restoreCursor())),this._parser.registerEscHandler({final:"D"},(()=>this.index())),this._parser.registerEscHandler({final:"E"},(()=>this.nextLine())),this._parser.registerEscHandler({final:"H"},(()=>this.tabSet())),this._parser.registerEscHandler({final:"M"},(()=>this.reverseIndex())),this._parser.registerEscHandler({final:"="},(()=>this.keypadApplicationMode())),this._parser.registerEscHandler({final:">"},(()=>this.keypadNumericMode())),this._parser.registerEscHandler({final:"c"},(()=>this.fullReset())),this._parser.registerEscHandler({final:"n"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"o"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"|"},(()=>this.setgLevel(3))),this._parser.registerEscHandler({final:"}"},(()=>this.setgLevel(2))),this._parser.registerEscHandler({final:"~"},(()=>this.setgLevel(1))),this._parser.registerEscHandler({intermediates:"%",final:"@"},(()=>this.selectDefaultCharset())),this._parser.registerEscHandler({intermediates:"%",final:"G"},(()=>this.selectDefaultCharset()));for(const j in p.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:j},(()=>this.selectCharset("("+j))),this._parser.registerEscHandler({intermediates:")",final:j},(()=>this.selectCharset(")"+j))),this._parser.registerEscHandler({intermediates:"*",final:j},(()=>this.selectCharset("*"+j))),this._parser.registerEscHandler({intermediates:"+",final:j},(()=>this.selectCharset("+"+j))),this._parser.registerEscHandler({intermediates:"-",final:j},(()=>this.selectCharset("-"+j))),this._parser.registerEscHandler({intermediates:".",final:j},(()=>this.selectCharset("."+j))),this._parser.registerEscHandler({intermediates:"/",final:j},(()=>this.selectCharset("/"+j)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((j=>(this._logService.error("Parsing error: ",j),j))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new k.DcsHandler(((j,I)=>this.requestStatusString(j,I))))}_preserveStack(N,D,T,B){this._parseStack.paused=!0,this._parseStack.cursorStartX=N,this._parseStack.cursorStartY=D,this._parseStack.decodedLength=T,this._parseStack.position=B}_logSlowResolvingAsync(N){this._logService.logLevel<=_.LogLevelEnum.WARN&&Promise.race([N,new Promise(((D,T)=>setTimeout((()=>T("#SLOW_TIMEOUT")),5e3)))]).catch((D=>{if(D!=="#SLOW_TIMEOUT")throw D;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(N,D){let T,B=this._activeBuffer.x,q=this._activeBuffer.y,K=0;const $=this._parseStack.paused;if($){if(T=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,D))return this._logSlowResolvingAsync(T),T;B=this._parseStack.cursorStartX,q=this._parseStack.cursorStartY,this._parseStack.paused=!1,N.length>R&&(K=this._parseStack.position+R)}if(this._logService.logLevel<=_.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof N=="string"?` "${N}"`:` "${Array.prototype.map.call(N,(W=>String.fromCharCode(W))).join("")}"`),typeof N=="string"?N.split("").map((W=>W.charCodeAt(0))):N),this._parseBuffer.length<N.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(N.length,R))),$||this._dirtyRowTracker.clearRange(),N.length>R)for(let W=K;W<N.length;W+=R){const z=W+R<N.length?W+R:N.length,j=typeof N=="string"?this._stringDecoder.decode(N.substring(W,z),this._parseBuffer):this._utf8Decoder.decode(N.subarray(W,z),this._parseBuffer);if(T=this._parser.parse(this._parseBuffer,j))return this._preserveStack(B,q,j,W),this._logSlowResolvingAsync(T),T}else if(!$){const W=typeof N=="string"?this._stringDecoder.decode(N,this._parseBuffer):this._utf8Decoder.decode(N,this._parseBuffer);if(T=this._parser.parse(this._parseBuffer,W))return this._preserveStack(B,q,W,0),this._logSlowResolvingAsync(T),T}this._activeBuffer.x===B&&this._activeBuffer.y===q||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(N,D,T){let B,q;const K=this._charsetService.charset,$=this._optionsService.rawOptions.screenReaderMode,W=this._bufferService.cols,z=this._coreService.decPrivateModes.wraparound,j=this._coreService.modes.insertMode,I=this._curAttrData;let X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&T-D>0&&X.getWidth(this._activeBuffer.x-1)===2&&X.setCellFromCodePoint(this._activeBuffer.x-1,0,1,I.fg,I.bg,I.extended);for(let Y=D;Y<T;++Y){if(B=N[Y],q=this._unicodeService.wcwidth(B),B<127&&K){const Z=K[String.fromCharCode(B)];Z&&(B=Z.charCodeAt(0))}if($&&this._onA11yChar.fire((0,b.stringFromCodePoint)(B)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),q||!this._activeBuffer.x){if(this._activeBuffer.x+q-1>=W){if(z){for(;this._activeBuffer.x<W;)X.setCellFromCodePoint(this._activeBuffer.x++,0,1,I.fg,I.bg,I.extended);this._activeBuffer.x=0,this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData(),!0)):(this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!0),X=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=W-1,q===2)continue}if(j&&(X.insertCells(this._activeBuffer.x,q,this._activeBuffer.getNullCell(I),I),X.getWidth(W-1)===2&&X.setCellFromCodePoint(W-1,l.NULL_CELL_CODE,l.NULL_CELL_WIDTH,I.fg,I.bg,I.extended)),X.setCellFromCodePoint(this._activeBuffer.x++,B,q,I.fg,I.bg,I.extended),q>0)for(;--q;)X.setCellFromCodePoint(this._activeBuffer.x++,0,0,I.fg,I.bg,I.extended)}else X.getWidth(this._activeBuffer.x-1)?X.addCodepointToCell(this._activeBuffer.x-1,B):X.addCodepointToCell(this._activeBuffer.x-2,B)}T-D>0&&(X.loadCell(this._activeBuffer.x-1,this._workCell),this._workCell.getWidth()===2||this._workCell.getCode()>65535?this._parser.precedingCodepoint=0:this._workCell.isCombined()?this._parser.precedingCodepoint=this._workCell.getChars().charCodeAt(0):this._parser.precedingCodepoint=this._workCell.content),this._activeBuffer.x<W&&T-D>0&&X.getWidth(this._activeBuffer.x)===0&&!X.hasContent(this._activeBuffer.x)&&X.setCellFromCodePoint(this._activeBuffer.x,0,1,I.fg,I.bg,I.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(N,D){return N.final!=="t"||N.prefix||N.intermediates?this._parser.registerCsiHandler(N,D):this._parser.registerCsiHandler(N,(T=>!O(T.params[0],this._optionsService.rawOptions.windowOptions)||D(T)))}registerDcsHandler(N,D){return this._parser.registerDcsHandler(N,new k.DcsHandler(D))}registerEscHandler(N,D){return this._parser.registerEscHandler(N,D)}registerOscHandler(N,D){return this._parser.registerOscHandler(N,new C.OscHandler(D))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var N;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((N=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||N===void 0)&&N.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);D.hasWidth(this._activeBuffer.x)&&!D.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const N=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-N),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(N=this._bufferService.cols-1){this._activeBuffer.x=Math.min(N,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(N,D){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=N,this._activeBuffer.y=this._activeBuffer.scrollTop+D):(this._activeBuffer.x=N,this._activeBuffer.y=D),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(N,D){this._restrictCursor(),this._setCursor(this._activeBuffer.x+N,this._activeBuffer.y+D)}cursorUp(N){const D=this._activeBuffer.y-this._activeBuffer.scrollTop;return D>=0?this._moveCursor(0,-Math.min(D,N.params[0]||1)):this._moveCursor(0,-(N.params[0]||1)),!0}cursorDown(N){const D=this._activeBuffer.scrollBottom-this._activeBuffer.y;return D>=0?this._moveCursor(0,Math.min(D,N.params[0]||1)):this._moveCursor(0,N.params[0]||1),!0}cursorForward(N){return this._moveCursor(N.params[0]||1,0),!0}cursorBackward(N){return this._moveCursor(-(N.params[0]||1),0),!0}cursorNextLine(N){return this.cursorDown(N),this._activeBuffer.x=0,!0}cursorPrecedingLine(N){return this.cursorUp(N),this._activeBuffer.x=0,!0}cursorCharAbsolute(N){return this._setCursor((N.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(N){return this._setCursor(N.length>=2?(N.params[1]||1)-1:0,(N.params[0]||1)-1),!0}charPosAbsolute(N){return this._setCursor((N.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(N){return this._moveCursor(N.params[0]||1,0),!0}linePosAbsolute(N){return this._setCursor(this._activeBuffer.x,(N.params[0]||1)-1),!0}vPositionRelative(N){return this._moveCursor(0,N.params[0]||1),!0}hVPosition(N){return this.cursorPosition(N),!0}tabClear(N){const D=N.params[0];return D===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:D===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(N){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let D=N.params[0]||1;for(;D--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(N){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let D=N.params[0]||1;for(;D--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(N){const D=N.params[0];return D===1&&(this._curAttrData.bg|=536870912),D!==2&&D!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(N,D,T,B=!1,q=!1){const K=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);K.replaceCells(D,T,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),q),B&&(K.isWrapped=!1)}_resetBufferLine(N,D=!1){const T=this._activeBuffer.lines.get(this._activeBuffer.ybase+N);T&&(T.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),D),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+N),T.isWrapped=!1)}eraseInDisplay(N,D=!1){let T;switch(this._restrictCursor(this._bufferService.cols),N.params[0]){case 0:for(T=this._activeBuffer.y,this._dirtyRowTracker.markDirty(T),this._eraseInBufferLine(T++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,D);T<this._bufferService.rows;T++)this._resetBufferLine(T,D);this._dirtyRowTracker.markDirty(T);break;case 1:for(T=this._activeBuffer.y,this._dirtyRowTracker.markDirty(T),this._eraseInBufferLine(T,0,this._activeBuffer.x+1,!0,D),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(T+1).isWrapped=!1);T--;)this._resetBufferLine(T,D);this._dirtyRowTracker.markDirty(0);break;case 2:for(T=this._bufferService.rows,this._dirtyRowTracker.markDirty(T-1);T--;)this._resetBufferLine(T,D);this._dirtyRowTracker.markDirty(0);break;case 3:const B=this._activeBuffer.lines.length-this._bufferService.rows;B>0&&(this._activeBuffer.lines.trimStart(B),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-B,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-B,0),this._onScroll.fire(0))}return!0}eraseInLine(N,D=!1){switch(this._restrictCursor(this._bufferService.cols),N.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,D);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,D);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,D)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(N){this._restrictCursor();let D=N.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const T=this._activeBuffer.ybase+this._activeBuffer.y,B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,q=this._bufferService.rows-1+this._activeBuffer.ybase-B+1;for(;D--;)this._activeBuffer.lines.splice(q-1,1),this._activeBuffer.lines.splice(T,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(N){this._restrictCursor();let D=N.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const T=this._activeBuffer.ybase+this._activeBuffer.y;let B;for(B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-B;D--;)this._activeBuffer.lines.splice(T,1),this._activeBuffer.lines.splice(B,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(N){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.insertCells(this._activeBuffer.x,N.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(N){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.deleteCells(this._activeBuffer.x,N.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(N){let D=N.params[0]||1;for(;D--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(N){let D=N.params[0]||1;for(;D--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,0,this._activeBuffer.getBlankLine(r.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=N.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);B.deleteCells(0,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=N.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);B.insertCells(0,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=N.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);B.insertCells(this._activeBuffer.x,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(N){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=N.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);B.deleteCells(this._activeBuffer.x,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(N){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(N.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(N){if(!this._parser.precedingCodepoint)return!0;const D=N.params[0]||1,T=new Uint32Array(D);for(let B=0;B<D;++B)T[B]=this._parser.precedingCodepoint;return this.print(T,0,T.length),!0}sendDeviceAttributesPrimary(N){return N.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(d.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(d.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(N){return N.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(d.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(d.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(N.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(d.C0.ESC+"[>83;40003;0c")),!0}_is(N){return(this._optionsService.rawOptions.termName+"").indexOf(N)===0}setMode(N){for(let D=0;D<N.length;D++)switch(N.params[D]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(N){for(let D=0;D<N.length;D++)switch(N.params[D]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),this._charsetService.setgCharset(1,p.DEFAULT_CHARSET),this._charsetService.setgCharset(2,p.DEFAULT_CHARSET),this._charsetService.setgCharset(3,p.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(N){for(let D=0;D<N.length;D++)switch(N.params[D]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(N){for(let D=0;D<N.length;D++)switch(N.params[D]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),N.params[D]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(N,D){const T=this._coreService.decPrivateModes,{activeProtocol:B,activeEncoding:q}=this._coreMouseService,K=this._coreService,{buffers:$,cols:W}=this._bufferService,{active:z,alt:j}=$,I=this._optionsService.rawOptions,X=te=>te?1:2,Y=N.params[0];return Z=Y,G=D?Y===2?4:Y===4?X(K.modes.insertMode):Y===12?3:Y===20?X(I.convertEol):0:Y===1?X(T.applicationCursorKeys):Y===3?I.windowOptions.setWinLines?W===80?2:W===132?1:0:0:Y===6?X(T.origin):Y===7?X(T.wraparound):Y===8?3:Y===9?X(B==="X10"):Y===12?X(I.cursorBlink):Y===25?X(!K.isCursorHidden):Y===45?X(T.reverseWraparound):Y===66?X(T.applicationKeypad):Y===67?4:Y===1e3?X(B==="VT200"):Y===1002?X(B==="DRAG"):Y===1003?X(B==="ANY"):Y===1004?X(T.sendFocus):Y===1005?4:Y===1006?X(q==="SGR"):Y===1015?4:Y===1016?X(q==="SGR_PIXELS"):Y===1048?1:Y===47||Y===1047||Y===1049?X(z===j):Y===2004?X(T.bracketedPasteMode):0,K.triggerDataEvent(`${d.C0.ESC}[${D?"":"?"}${Z};${G}$y`),!0;var Z,G}_updateAttrColor(N,D,T,B,q){return D===2?(N|=50331648,N&=-16777216,N|=g.AttributeData.fromColorRGB([T,B,q])):D===5&&(N&=-50331904,N|=33554432|255&T),N}_extractColor(N,D,T){const B=[0,0,-1,0,0,0];let q=0,K=0;do{if(B[K+q]=N.params[D+K],N.hasSubParams(D+K)){const $=N.getSubParams(D+K);let W=0;do B[1]===5&&(q=1),B[K+W+1+q]=$[W];while(++W<$.length&&W+K+1+q<B.length);break}if(B[1]===5&&K+q>=2||B[1]===2&&K+q>=5)break;B[1]&&(q=1)}while(++K+D<N.length&&K+q<B.length);for(let $=2;$<B.length;++$)B[$]===-1&&(B[$]=0);switch(B[0]){case 38:T.fg=this._updateAttrColor(T.fg,B[1],B[3],B[4],B[5]);break;case 48:T.bg=this._updateAttrColor(T.bg,B[1],B[3],B[4],B[5]);break;case 58:T.extended=T.extended.clone(),T.extended.underlineColor=this._updateAttrColor(T.extended.underlineColor,B[1],B[3],B[4],B[5])}return K}_processUnderline(N,D){D.extended=D.extended.clone(),(!~N||N>5)&&(N=1),D.extended.underlineStyle=N,D.fg|=268435456,N===0&&(D.fg&=-268435457),D.updateExtended()}_processSGR0(N){N.fg=r.DEFAULT_ATTR_DATA.fg,N.bg=r.DEFAULT_ATTR_DATA.bg,N.extended=N.extended.clone(),N.extended.underlineStyle=0,N.extended.underlineColor&=-67108864,N.updateExtended()}charAttributes(N){if(N.length===1&&N.params[0]===0)return this._processSGR0(this._curAttrData),!0;const D=N.length;let T;const B=this._curAttrData;for(let q=0;q<D;q++)T=N.params[q],T>=30&&T<=37?(B.fg&=-50331904,B.fg|=16777216|T-30):T>=40&&T<=47?(B.bg&=-50331904,B.bg|=16777216|T-40):T>=90&&T<=97?(B.fg&=-50331904,B.fg|=16777224|T-90):T>=100&&T<=107?(B.bg&=-50331904,B.bg|=16777224|T-100):T===0?this._processSGR0(B):T===1?B.fg|=134217728:T===3?B.bg|=67108864:T===4?(B.fg|=268435456,this._processUnderline(N.hasSubParams(q)?N.getSubParams(q)[0]:1,B)):T===5?B.fg|=536870912:T===7?B.fg|=67108864:T===8?B.fg|=1073741824:T===9?B.fg|=2147483648:T===2?B.bg|=134217728:T===21?this._processUnderline(2,B):T===22?(B.fg&=-134217729,B.bg&=-134217729):T===23?B.bg&=-67108865:T===24?(B.fg&=-268435457,this._processUnderline(0,B)):T===25?B.fg&=-536870913:T===27?B.fg&=-67108865:T===28?B.fg&=-1073741825:T===29?B.fg&=2147483647:T===39?(B.fg&=-67108864,B.fg|=16777215&r.DEFAULT_ATTR_DATA.fg):T===49?(B.bg&=-67108864,B.bg|=16777215&r.DEFAULT_ATTR_DATA.bg):T===38||T===48||T===58?q+=this._extractColor(N,q,B):T===53?B.bg|=1073741824:T===55?B.bg&=-1073741825:T===59?(B.extended=B.extended.clone(),B.extended.underlineColor=-1,B.updateExtended()):T===100?(B.fg&=-67108864,B.fg|=16777215&r.DEFAULT_ATTR_DATA.fg,B.bg&=-67108864,B.bg|=16777215&r.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",T);return!0}deviceStatus(N){switch(N.params[0]){case 5:this._coreService.triggerDataEvent(`${d.C0.ESC}[0n`);break;case 6:const D=this._activeBuffer.y+1,T=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${d.C0.ESC}[${D};${T}R`)}return!0}deviceStatusPrivate(N){if(N.params[0]===6){const D=this._activeBuffer.y+1,T=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${d.C0.ESC}[?${D};${T}R`)}return!0}softReset(N){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=r.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(N){const D=N.params[0]||1;switch(D){case 1:case 2:this._optionsService.options.cursorStyle="block";break;case 3:case 4:this._optionsService.options.cursorStyle="underline";break;case 5:case 6:this._optionsService.options.cursorStyle="bar"}const T=D%2==1;return this._optionsService.options.cursorBlink=T,!0}setScrollRegion(N){const D=N.params[0]||1;let T;return(N.length<2||(T=N.params[1])>this._bufferService.rows||T===0)&&(T=this._bufferService.rows),T>D&&(this._activeBuffer.scrollTop=D-1,this._activeBuffer.scrollBottom=T-1,this._setCursor(0,0)),!0}windowOptions(N){if(!O(N.params[0],this._optionsService.rawOptions.windowOptions))return!0;const D=N.length>1?N.params[1]:0;switch(N.params[0]){case 14:D!==2&&this._onRequestWindowsOptionsReport.fire(L.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(L.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${d.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:D!==0&&D!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),D!==0&&D!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:D!==0&&D!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),D!==0&&D!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(N){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(N){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(N){return this._windowTitle=N,this._onTitleChange.fire(N),!0}setIconName(N){return this._iconName=N,!0}setOrReportIndexedColor(N){const D=[],T=N.split(";");for(;T.length>1;){const B=T.shift(),q=T.shift();if(/^\d+$/.exec(B)){const K=parseInt(B);if(F(K))if(q==="?")D.push({type:0,index:K});else{const $=(0,v.parseColor)(q);$&&D.push({type:1,index:K,color:$})}}}return D.length&&this._onColor.fire(D),!0}setHyperlink(N){const D=N.split(";");return!(D.length<2)&&(D[1]?this._createHyperlink(D[0],D[1]):!D[0]&&this._finishHyperlink())}_createHyperlink(N,D){this._getCurrentLinkId()&&this._finishHyperlink();const T=N.split(":");let B;const q=T.findIndex((K=>K.startsWith("id=")));return q!==-1&&(B=T[q].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:B,uri:D}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(N,D){const T=N.split(";");for(let B=0;B<T.length&&!(D>=this._specialColors.length);++B,++D)if(T[B]==="?")this._onColor.fire([{type:0,index:this._specialColors[D]}]);else{const q=(0,v.parseColor)(T[B]);q&&this._onColor.fire([{type:1,index:this._specialColors[D],color:q}])}return!0}setOrReportFgColor(N){return this._setOrReportSpecialColor(N,0)}setOrReportBgColor(N){return this._setOrReportSpecialColor(N,1)}setOrReportCursorColor(N){return this._setOrReportSpecialColor(N,2)}restoreIndexedColor(N){if(!N)return this._onColor.fire([{type:2}]),!0;const D=[],T=N.split(";");for(let B=0;B<T.length;++B)if(/^\d+$/.exec(T[B])){const q=parseInt(T[B]);F(q)&&D.push({type:2,index:q})}return D.length&&this._onColor.fire(D),!0}restoreFgColor(N){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(N){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(N){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,p.DEFAULT_CHARSET),!0}selectCharset(N){return N.length!==2?(this.selectDefaultCharset(),!0):(N[0]==="/"||this._charsetService.setgCharset(E[N[0]],p.CHARSETS[N[1]]||p.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const N=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,N,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=r.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=r.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(N){return this._charsetService.setgLevel(N),!0}screenAlignmentPattern(){const N=new c.CellData;N.content=4194373,N.fg=this._curAttrData.fg,N.bg=this._curAttrData.bg,this._setCursor(0,0);for(let D=0;D<this._bufferService.rows;++D){const T=this._activeBuffer.ybase+this._activeBuffer.y+D,B=this._activeBuffer.lines.get(T);B&&(B.fill(N),B.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(N,D){const T=this._bufferService.buffer,B=this._optionsService.rawOptions;return(q=>(this._coreService.triggerDataEvent(`${d.C0.ESC}${q}${d.C0.ESC}\\`),!0))(N==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:N==='"p'?'P1$r61;1"p':N==="r"?`P1$r${T.scrollTop+1};${T.scrollBottom+1}r`:N==="m"?"P1$r0m":N===" q"?`P1$r${{block:2,underline:4,bar:6}[B.cursorStyle]-(B.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(N,D){this._dirtyRowTracker.markRangeDirty(N,D)}}s.InputHandler=H;let M=class{constructor(U){this._bufferService=U,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(U){U<this.start?this.start=U:U>this.end&&(this.end=U)}markRangeDirty(U,N){U>N&&(P=U,U=N,N=P),U<this.start&&(this.start=U),N>this.end&&(this.end=N)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(U){return 0<=U&&U<256}M=u([f(0,_.IBufferService)],M)},844:(w,s)=>{function o(u){for(const f of u)f.dispose();u.length=0}Object.defineProperty(s,"__esModule",{value:!0}),s.getDisposeArrayDisposable=s.disposeArray=s.toDisposable=s.MutableDisposable=s.Disposable=void 0,s.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const u of this._disposables)u.dispose();this._disposables.length=0}register(u){return this._disposables.push(u),u}unregister(u){const f=this._disposables.indexOf(u);f!==-1&&this._disposables.splice(f,1)}},s.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(u){var f;this._isDisposed||u===this._value||((f=this._value)===null||f===void 0||f.dispose(),this._value=u)}clear(){this.value=void 0}dispose(){var u;this._isDisposed=!0,(u=this._value)===null||u===void 0||u.dispose(),this._value=void 0}},s.toDisposable=function(u){return{dispose:u}},s.disposeArray=o,s.getDisposeArrayDisposable=function(u){return{dispose:()=>o(u)}}},1505:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.FourKeyMap=s.TwoKeyMap=void 0;class o{constructor(){this._data={}}set(f,d,p){this._data[f]||(this._data[f]={}),this._data[f][d]=p}get(f,d){return this._data[f]?this._data[f][d]:void 0}clear(){this._data={}}}s.TwoKeyMap=o,s.FourKeyMap=class{constructor(){this._data=new o}set(u,f,d,p,m){this._data.get(u,f)||this._data.set(u,f,new o),this._data.get(u,f).set(d,p,m)}get(u,f,d,p){var m;return(m=this._data.get(u,f))===null||m===void 0?void 0:m.get(d,p)}clear(){this._data.clear()}}},6114:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.isChromeOS=s.isLinux=s.isWindows=s.isIphone=s.isIpad=s.isMac=s.getSafariVersion=s.isSafari=s.isLegacyEdge=s.isFirefox=s.isNode=void 0,s.isNode=typeof navigator>"u";const o=s.isNode?"node":navigator.userAgent,u=s.isNode?"node":navigator.platform;s.isFirefox=o.includes("Firefox"),s.isLegacyEdge=o.includes("Edge"),s.isSafari=/^((?!chrome|android).)*safari/i.test(o),s.getSafariVersion=function(){if(!s.isSafari)return 0;const f=o.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},s.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(u),s.isIpad=u==="iPad",s.isIphone=u==="iPhone",s.isWindows=["Windows","Win16","Win32","WinCE"].includes(u),s.isLinux=u.indexOf("Linux")>=0,s.isChromeOS=/\bCrOS\b/.test(o)},6106:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.SortedList=void 0;let o=0;s.SortedList=class{constructor(u){this._getKey=u,this._array=[]}clear(){this._array.length=0}insert(u){this._array.length!==0?(o=this._search(this._getKey(u)),this._array.splice(o,0,u)):this._array.push(u)}delete(u){if(this._array.length===0)return!1;const f=this._getKey(u);if(f===void 0||(o=this._search(f),o===-1)||this._getKey(this._array[o])!==f)return!1;do if(this._array[o]===u)return this._array.splice(o,1),!0;while(++o<this._array.length&&this._getKey(this._array[o])===f);return!1}*getKeyIterator(u){if(this._array.length!==0&&(o=this._search(u),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===u))do yield this._array[o];while(++o<this._array.length&&this._getKey(this._array[o])===u)}forEachByKey(u,f){if(this._array.length!==0&&(o=this._search(u),!(o<0||o>=this._array.length)&&this._getKey(this._array[o])===u))do f(this._array[o]);while(++o<this._array.length&&this._getKey(this._array[o])===u)}values(){return[...this._array].values()}_search(u){let f=0,d=this._array.length-1;for(;d>=f;){let p=f+d>>1;const m=this._getKey(this._array[p]);if(m>u)d=p-1;else{if(!(m<u)){for(;p>0&&this._getKey(this._array[p-1])===u;)p--;return p}f=p+1}}return f}}},7226:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DebouncedIdleTask=s.IdleTaskQueue=s.PriorityTaskQueue=void 0;const u=o(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(m){this._tasks.push(m),this._start()}flush(){for(;this._i<this._tasks.length;)this._tasks[this._i]()||this._i++;this.clear()}clear(){this._idleCallback&&(this._cancelCallback(this._idleCallback),this._idleCallback=void 0),this._i=0,this._tasks.length=0}_start(){this._idleCallback||(this._idleCallback=this._requestCallback(this._process.bind(this)))}_process(m){this._idleCallback=void 0;let y=0,b=0,r=m.timeRemaining(),a=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),b=Math.max(y,b),a=m.timeRemaining(),1.5*b>a)return r-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(r-y))}ms`),void this._start();r=a}this.clear()}}class d extends f{_requestCallback(m){return setTimeout((()=>m(this._createDeadline(16))))}_cancelCallback(m){clearTimeout(m)}_createDeadline(m){const y=Date.now()+m;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}s.PriorityTaskQueue=d,s.IdleTaskQueue=!u.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(p){return requestIdleCallback(p)}_cancelCallback(p){cancelIdleCallback(p)}}:d,s.DebouncedIdleTask=class{constructor(){this._queue=new s.IdleTaskQueue}set(p){this._queue.clear(),this._queue.enqueue(p)}flush(){this._queue.flush()}}},9282:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.updateWindowsModeWrappedState=void 0;const u=o(643);s.updateWindowsModeWrappedState=function(f){const d=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),p=d?.get(f.cols-1),m=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);m&&p&&(m.isWrapped=p[u.CHAR_DATA_CODE_INDEX]!==u.NULL_CELL_CODE&&p[u.CHAR_DATA_CODE_INDEX]!==u.WHITESPACE_CELL_CODE)}},3734:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ExtendedAttrs=s.AttributeData=void 0;class o{constructor(){this.fg=0,this.bg=0,this.extended=new u}static toColorRGB(d){return[d>>>16&255,d>>>8&255,255&d]}static fromColorRGB(d){return(255&d[0])<<16|(255&d[1])<<8|255&d[2]}clone(){const d=new o;return d.fg=this.fg,d.bg=this.bg,d.extended=this.extended.clone(),d}isInverse(){return 67108864&this.fg}isBold(){return 134217728&this.fg}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:268435456&this.fg}isBlink(){return 536870912&this.fg}isInvisible(){return 1073741824&this.fg}isItalic(){return 67108864&this.bg}isDim(){return 134217728&this.bg}isStrikethrough(){return 2147483648&this.fg}isProtected(){return 536870912&this.bg}isOverline(){return 1073741824&this.bg}getFgColorMode(){return 50331648&this.fg}getBgColorMode(){return 50331648&this.bg}isFgRGB(){return(50331648&this.fg)==50331648}isBgRGB(){return(50331648&this.bg)==50331648}isFgPalette(){return(50331648&this.fg)==16777216||(50331648&this.fg)==33554432}isBgPalette(){return(50331648&this.bg)==16777216||(50331648&this.bg)==33554432}isFgDefault(){return(50331648&this.fg)==0}isBgDefault(){return(50331648&this.bg)==0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(50331648&this.fg){case 16777216:case 33554432:return 255&this.fg;case 50331648:return 16777215&this.fg;default:return-1}}getBgColor(){switch(50331648&this.bg){case 16777216:case 33554432:return 255&this.bg;case 50331648:return 16777215&this.bg;default:return-1}}hasExtendedAttrs(){return 268435456&this.bg}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(268435456&this.bg&&~this.extended.underlineColor)switch(50331648&this.extended.underlineColor){case 16777216:case 33554432:return 255&this.extended.underlineColor;case 50331648:return 16777215&this.extended.underlineColor;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return 268435456&this.bg&&~this.extended.underlineColor?50331648&this.extended.underlineColor:this.getFgColorMode()}isUnderlineColorRGB(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==50331648:this.isFgRGB()}isUnderlineColorPalette(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==16777216||(50331648&this.extended.underlineColor)==33554432:this.isFgPalette()}isUnderlineColorDefault(){return 268435456&this.bg&&~this.extended.underlineColor?(50331648&this.extended.underlineColor)==0:this.isFgDefault()}getUnderlineStyle(){return 268435456&this.fg?268435456&this.bg?this.extended.underlineStyle:1:0}}s.AttributeData=o;class u{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(d){this._ext=d}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(d){this._ext&=-469762049,this._ext|=d<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(d){this._ext&=-67108864,this._ext|=67108863&d}get urlId(){return this._urlId}set urlId(d){this._urlId=d}constructor(d=0,p=0){this._ext=0,this._urlId=0,this._ext=d,this._urlId=p}clone(){return new u(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}s.ExtendedAttrs=u},9092:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Buffer=s.MAX_BUFFER_SIZE=void 0;const u=o(6349),f=o(7226),d=o(3734),p=o(8437),m=o(4634),y=o(511),b=o(643),r=o(4863),a=o(7116);s.MAX_BUFFER_SIZE=4294967295,s.Buffer=class{constructor(l,c,g){this._hasScrollback=l,this._optionsService=c,this._bufferService=g,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=p.DEFAULT_ATTR_DATA.clone(),this.savedCharset=a.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,b.NULL_CELL_CHAR,b.NULL_CELL_WIDTH,b.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,b.WHITESPACE_CELL_CHAR,b.WHITESPACE_CELL_WIDTH,b.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(l){return l?(this._nullCell.fg=l.fg,this._nullCell.bg=l.bg,this._nullCell.extended=l.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new d.ExtendedAttrs),this._nullCell}getWhitespaceCell(l){return l?(this._whitespaceCell.fg=l.fg,this._whitespaceCell.bg=l.bg,this._whitespaceCell.extended=l.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new d.ExtendedAttrs),this._whitespaceCell}getBlankLine(l,c){return new p.BufferLine(this._bufferService.cols,this.getNullCell(l),c)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const l=this.ybase+this.y-this.ydisp;return l>=0&&l<this._rows}_getCorrectBufferLength(l){if(!this._hasScrollback)return l;const c=l+this._optionsService.rawOptions.scrollback;return c>s.MAX_BUFFER_SIZE?s.MAX_BUFFER_SIZE:c}fillViewportRows(l){if(this.lines.length===0){l===void 0&&(l=p.DEFAULT_ATTR_DATA);let c=this._rows;for(;c--;)this.lines.push(this.getBlankLine(l))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new u.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(l,c){const g=this.getNullCell(p.DEFAULT_ATTR_DATA);let _=0;const C=this._getCorrectBufferLength(c);if(C>this.lines.maxLength&&(this.lines.maxLength=C),this.lines.length>0){if(this._cols<l)for(let v=0;v<this.lines.length;v++)_+=+this.lines.get(v).resize(l,g);let k=0;if(this._rows<c)for(let v=this._rows;v<c;v++)this.lines.length<c+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new p.BufferLine(l,g)):this.ybase>0&&this.lines.length<=this.ybase+this.y+k+1?(this.ybase--,k++,this.ydisp>0&&this.ydisp--):this.lines.push(new p.BufferLine(l,g)));else for(let v=this._rows;v>c;v--)this.lines.length>c+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(C<this.lines.maxLength){const v=this.lines.length-C;v>0&&(this.lines.trimStart(v),this.ybase=Math.max(this.ybase-v,0),this.ydisp=Math.max(this.ydisp-v,0),this.savedY=Math.max(this.savedY-v,0)),this.lines.maxLength=C}this.x=Math.min(this.x,l-1),this.y=Math.min(this.y,c-1),k&&(this.y+=k),this.savedX=Math.min(this.savedX,l-1),this.scrollTop=0}if(this.scrollBottom=c-1,this._isReflowEnabled&&(this._reflow(l,c),this._cols>l))for(let k=0;k<this.lines.length;k++)_+=+this.lines.get(k).resize(l,g);this._cols=l,this._rows=c,this._memoryCleanupQueue.clear(),_>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let l=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,l=!1);let c=0;for(;this._memoryCleanupPosition<this.lines.length;)if(c+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),c>100)return!0;return l}get _isReflowEnabled(){const l=this._optionsService.rawOptions.windowsPty;return l&&l.buildNumber?this._hasScrollback&&l.backend==="conpty"&&l.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(l,c){this._cols!==l&&(l>this._cols?this._reflowLarger(l,c):this._reflowSmaller(l,c))}_reflowLarger(l,c){const g=(0,m.reflowLargerGetLinesToRemove)(this.lines,this._cols,l,this.ybase+this.y,this.getNullCell(p.DEFAULT_ATTR_DATA));if(g.length>0){const _=(0,m.reflowLargerCreateNewLayout)(this.lines,g);(0,m.reflowLargerApplyNewLayout)(this.lines,_.layout),this._reflowLargerAdjustViewport(l,c,_.countRemoved)}}_reflowLargerAdjustViewport(l,c,g){const _=this.getNullCell(p.DEFAULT_ATTR_DATA);let C=g;for(;C-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<c&&this.lines.push(new p.BufferLine(l,_))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-g,0)}_reflowSmaller(l,c){const g=this.getNullCell(p.DEFAULT_ATTR_DATA),_=[];let C=0;for(let k=this.lines.length-1;k>=0;k--){let v=this.lines.get(k);if(!v||!v.isWrapped&&v.getTrimmedLength()<=l)continue;const E=[v];for(;v.isWrapped&&k>0;)v=this.lines.get(--k),E.unshift(v);const R=this.ybase+this.y;if(R>=k&&R<k+E.length)continue;const O=E[E.length-1].getTrimmedLength(),L=(0,m.reflowSmallerGetNewLineLengths)(E,this._cols,l),P=L.length-E.length;let H;H=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+P):Math.max(0,this.lines.length-this.lines.maxLength+P);const M=[];for(let B=0;B<P;B++){const q=this.getBlankLine(p.DEFAULT_ATTR_DATA,!0);M.push(q)}M.length>0&&(_.push({start:k+E.length+C,newLines:M}),C+=M.length),E.push(...M);let F=L.length-1,U=L[F];U===0&&(F--,U=L[F]);let N=E.length-P-1,D=O;for(;N>=0;){const B=Math.min(D,U);if(E[F]===void 0)break;if(E[F].copyCellsFrom(E[N],D-B,U-B,B,!0),U-=B,U===0&&(F--,U=L[F]),D-=B,D===0){N--;const q=Math.max(N,0);D=(0,m.getWrappedLineTrimmedLength)(E,q,this._cols)}}for(let B=0;B<E.length;B++)L[B]<l&&E[B].setCell(L[B],g);let T=P-H;for(;T-- >0;)this.ybase===0?this.y<c-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+C)-c&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+P,this.ybase+c-1)}if(_.length>0){const k=[],v=[];for(let F=0;F<this.lines.length;F++)v.push(this.lines.get(F));const E=this.lines.length;let R=E-1,O=0,L=_[O];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+C);let P=0;for(let F=Math.min(this.lines.maxLength-1,E+C-1);F>=0;F--)if(L&&L.start>R+P){for(let U=L.newLines.length-1;U>=0;U--)this.lines.set(F--,L.newLines[U]);F++,k.push({index:R+1,amount:L.newLines.length}),P+=L.newLines.length,L=_[++O]}else this.lines.set(F,v[R--]);let H=0;for(let F=k.length-1;F>=0;F--)k[F].index+=H,this.lines.onInsertEmitter.fire(k[F]),H+=k[F].amount;const M=Math.max(0,E+C-this.lines.maxLength);M>0&&this.lines.onTrimEmitter.fire(M)}}translateBufferLineToString(l,c,g=0,_){const C=this.lines.get(l);return C?C.translateToString(c,g,_):""}getWrappedRangeForLine(l){let c=l,g=l;for(;c>0&&this.lines.get(c).isWrapped;)c--;for(;g+1<this.lines.length&&this.lines.get(g+1).isWrapped;)g++;return{first:c,last:g}}setupTabStops(l){for(l!=null?this.tabs[l]||(l=this.prevStop(l)):(this.tabs={},l=0);l<this._cols;l+=this._optionsService.rawOptions.tabStopWidth)this.tabs[l]=!0}prevStop(l){for(l==null&&(l=this.x);!this.tabs[--l]&&l>0;);return l>=this._cols?this._cols-1:l<0?0:l}nextStop(l){for(l==null&&(l=this.x);!this.tabs[++l]&&l<this._cols;);return l>=this._cols?this._cols-1:l<0?0:l}clearMarkers(l){this._isClearing=!0;for(let c=0;c<this.markers.length;c++)this.markers[c].line===l&&(this.markers[c].dispose(),this.markers.splice(c--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let l=0;l<this.markers.length;l++)this.markers[l].dispose(),this.markers.splice(l--,1);this._isClearing=!1}addMarker(l){const c=new r.Marker(l);return this.markers.push(c),c.register(this.lines.onTrim((g=>{c.line-=g,c.line<0&&c.dispose()}))),c.register(this.lines.onInsert((g=>{c.line>=g.index&&(c.line+=g.amount)}))),c.register(this.lines.onDelete((g=>{c.line>=g.index&&c.line<g.index+g.amount&&c.dispose(),c.line>g.index&&(c.line-=g.amount)}))),c.register(c.onDispose((()=>this._removeMarker(c)))),c}_removeMarker(l){this._isClearing||this.markers.splice(this.markers.indexOf(l),1)}}},8437:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferLine=s.DEFAULT_ATTR_DATA=void 0;const u=o(3734),f=o(511),d=o(643),p=o(482);s.DEFAULT_ATTR_DATA=Object.freeze(new u.AttributeData);let m=0;class y{constructor(r,a,l=!1){this.isWrapped=l,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*r);const c=a||f.CellData.fromCharData([0,d.NULL_CELL_CHAR,d.NULL_CELL_WIDTH,d.NULL_CELL_CODE]);for(let g=0;g<r;++g)this.setCell(g,c);this.length=r}get(r){const a=this._data[3*r+0],l=2097151&a;return[this._data[3*r+1],2097152&a?this._combined[r]:l?(0,p.stringFromCodePoint)(l):"",a>>22,2097152&a?this._combined[r].charCodeAt(this._combined[r].length-1):l]}set(r,a){this._data[3*r+1]=a[d.CHAR_DATA_ATTR_INDEX],a[d.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[r]=a[1],this._data[3*r+0]=2097152|r|a[d.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*r+0]=a[d.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|a[d.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(r){return this._data[3*r+0]>>22}hasWidth(r){return 12582912&this._data[3*r+0]}getFg(r){return this._data[3*r+1]}getBg(r){return this._data[3*r+2]}hasContent(r){return 4194303&this._data[3*r+0]}getCodePoint(r){const a=this._data[3*r+0];return 2097152&a?this._combined[r].charCodeAt(this._combined[r].length-1):2097151&a}isCombined(r){return 2097152&this._data[3*r+0]}getString(r){const a=this._data[3*r+0];return 2097152&a?this._combined[r]:2097151&a?(0,p.stringFromCodePoint)(2097151&a):""}isProtected(r){return 536870912&this._data[3*r+2]}loadCell(r,a){return m=3*r,a.content=this._data[m+0],a.fg=this._data[m+1],a.bg=this._data[m+2],2097152&a.content&&(a.combinedData=this._combined[r]),268435456&a.bg&&(a.extended=this._extendedAttrs[r]),a}setCell(r,a){2097152&a.content&&(this._combined[r]=a.combinedData),268435456&a.bg&&(this._extendedAttrs[r]=a.extended),this._data[3*r+0]=a.content,this._data[3*r+1]=a.fg,this._data[3*r+2]=a.bg}setCellFromCodePoint(r,a,l,c,g,_){268435456&g&&(this._extendedAttrs[r]=_),this._data[3*r+0]=a|l<<22,this._data[3*r+1]=c,this._data[3*r+2]=g}addCodepointToCell(r,a){let l=this._data[3*r+0];2097152&l?this._combined[r]+=(0,p.stringFromCodePoint)(a):(2097151&l?(this._combined[r]=(0,p.stringFromCodePoint)(2097151&l)+(0,p.stringFromCodePoint)(a),l&=-2097152,l|=2097152):l=a|4194304,this._data[3*r+0]=l)}insertCells(r,a,l,c){if((r%=this.length)&&this.getWidth(r-1)===2&&this.setCellFromCodePoint(r-1,0,1,c?.fg||0,c?.bg||0,c?.extended||new u.ExtendedAttrs),a<this.length-r){const g=new f.CellData;for(let _=this.length-r-a-1;_>=0;--_)this.setCell(r+a+_,this.loadCell(r+_,g));for(let _=0;_<a;++_)this.setCell(r+_,l)}else for(let g=r;g<this.length;++g)this.setCell(g,l);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,c?.fg||0,c?.bg||0,c?.extended||new u.ExtendedAttrs)}deleteCells(r,a,l,c){if(r%=this.length,a<this.length-r){const g=new f.CellData;for(let _=0;_<this.length-r-a;++_)this.setCell(r+_,this.loadCell(r+a+_,g));for(let _=this.length-a;_<this.length;++_)this.setCell(_,l)}else for(let g=r;g<this.length;++g)this.setCell(g,l);r&&this.getWidth(r-1)===2&&this.setCellFromCodePoint(r-1,0,1,c?.fg||0,c?.bg||0,c?.extended||new u.ExtendedAttrs),this.getWidth(r)!==0||this.hasContent(r)||this.setCellFromCodePoint(r,0,1,c?.fg||0,c?.bg||0,c?.extended||new u.ExtendedAttrs)}replaceCells(r,a,l,c,g=!1){if(g)for(r&&this.getWidth(r-1)===2&&!this.isProtected(r-1)&&this.setCellFromCodePoint(r-1,0,1,c?.fg||0,c?.bg||0,c?.extended||new u.ExtendedAttrs),a<this.length&&this.getWidth(a-1)===2&&!this.isProtected(a)&&this.setCellFromCodePoint(a,0,1,c?.fg||0,c?.bg||0,c?.extended||new u.ExtendedAttrs);r<a&&r<this.length;)this.isProtected(r)||this.setCell(r,l),r++;else for(r&&this.getWidth(r-1)===2&&this.setCellFromCodePoint(r-1,0,1,c?.fg||0,c?.bg||0,c?.extended||new u.ExtendedAttrs),a<this.length&&this.getWidth(a-1)===2&&this.setCellFromCodePoint(a,0,1,c?.fg||0,c?.bg||0,c?.extended||new u.ExtendedAttrs);r<a&&r<this.length;)this.setCell(r++,l)}resize(r,a){if(r===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const l=3*r;if(r>this.length){if(this._data.buffer.byteLength>=4*l)this._data=new Uint32Array(this._data.buffer,0,l);else{const c=new Uint32Array(l);c.set(this._data),this._data=c}for(let c=this.length;c<r;++c)this.setCell(c,a)}else{this._data=this._data.subarray(0,l);const c=Object.keys(this._combined);for(let _=0;_<c.length;_++){const C=parseInt(c[_],10);C>=r&&delete this._combined[C]}const g=Object.keys(this._extendedAttrs);for(let _=0;_<g.length;_++){const C=parseInt(g[_],10);C>=r&&delete this._extendedAttrs[C]}}return this.length=r,4*l*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const r=new Uint32Array(this._data.length);return r.set(this._data),this._data=r,1}return 0}fill(r,a=!1){if(a)for(let l=0;l<this.length;++l)this.isProtected(l)||this.setCell(l,r);else{this._combined={},this._extendedAttrs={};for(let l=0;l<this.length;++l)this.setCell(l,r)}}copyFrom(r){this.length!==r.length?this._data=new Uint32Array(r._data):this._data.set(r._data),this.length=r.length,this._combined={};for(const a in r._combined)this._combined[a]=r._combined[a];this._extendedAttrs={};for(const a in r._extendedAttrs)this._extendedAttrs[a]=r._extendedAttrs[a];this.isWrapped=r.isWrapped}clone(){const r=new y(0);r._data=new Uint32Array(this._data),r.length=this.length;for(const a in this._combined)r._combined[a]=this._combined[a];for(const a in this._extendedAttrs)r._extendedAttrs[a]=this._extendedAttrs[a];return r.isWrapped=this.isWrapped,r}getTrimmedLength(){for(let r=this.length-1;r>=0;--r)if(4194303&this._data[3*r+0])return r+(this._data[3*r+0]>>22);return 0}getNoBgTrimmedLength(){for(let r=this.length-1;r>=0;--r)if(4194303&this._data[3*r+0]||50331648&this._data[3*r+2])return r+(this._data[3*r+0]>>22);return 0}copyCellsFrom(r,a,l,c,g){const _=r._data;if(g)for(let k=c-1;k>=0;k--){for(let v=0;v<3;v++)this._data[3*(l+k)+v]=_[3*(a+k)+v];268435456&_[3*(a+k)+2]&&(this._extendedAttrs[l+k]=r._extendedAttrs[a+k])}else for(let k=0;k<c;k++){for(let v=0;v<3;v++)this._data[3*(l+k)+v]=_[3*(a+k)+v];268435456&_[3*(a+k)+2]&&(this._extendedAttrs[l+k]=r._extendedAttrs[a+k])}const C=Object.keys(r._combined);for(let k=0;k<C.length;k++){const v=parseInt(C[k],10);v>=a&&(this._combined[v-a+l]=r._combined[v])}}translateToString(r=!1,a=0,l=this.length){r&&(l=Math.min(l,this.getTrimmedLength()));let c="";for(;a<l;){const g=this._data[3*a+0],_=2097151&g;c+=2097152&g?this._combined[a]:_?(0,p.stringFromCodePoint)(_):d.WHITESPACE_CELL_CHAR,a+=g>>22||1}return c}}s.BufferLine=y},4841:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.getRangeLength=void 0,s.getRangeLength=function(o,u){if(o.start.y>o.end.y)throw new Error(`Buffer range end (${o.end.x}, ${o.end.y}) cannot be before start (${o.start.x}, ${o.start.y})`);return u*(o.end.y-o.start.y)+(o.end.x-o.start.x+1)}},4634:(w,s)=>{function o(u,f,d){if(f===u.length-1)return u[f].getTrimmedLength();const p=!u[f].hasContent(d-1)&&u[f].getWidth(d-1)===1,m=u[f+1].getWidth(0)===2;return p&&m?d-1:d}Object.defineProperty(s,"__esModule",{value:!0}),s.getWrappedLineTrimmedLength=s.reflowSmallerGetNewLineLengths=s.reflowLargerApplyNewLayout=s.reflowLargerCreateNewLayout=s.reflowLargerGetLinesToRemove=void 0,s.reflowLargerGetLinesToRemove=function(u,f,d,p,m){const y=[];for(let b=0;b<u.length-1;b++){let r=b,a=u.get(++r);if(!a.isWrapped)continue;const l=[u.get(b)];for(;r<u.length&&a.isWrapped;)l.push(a),a=u.get(++r);if(p>=b&&p<r){b+=l.length-1;continue}let c=0,g=o(l,c,f),_=1,C=0;for(;_<l.length;){const v=o(l,_,f),E=v-C,R=d-g,O=Math.min(E,R);l[c].copyCellsFrom(l[_],C,g,O,!1),g+=O,g===d&&(c++,g=0),C+=O,C===v&&(_++,C=0),g===0&&c!==0&&l[c-1].getWidth(d-1)===2&&(l[c].copyCellsFrom(l[c-1],d-1,g++,1,!1),l[c-1].setCell(d-1,m))}l[c].replaceCells(g,d,m);let k=0;for(let v=l.length-1;v>0&&(v>c||l[v].getTrimmedLength()===0);v--)k++;k>0&&(y.push(b+l.length-k),y.push(k)),b+=l.length-1}return y},s.reflowLargerCreateNewLayout=function(u,f){const d=[];let p=0,m=f[p],y=0;for(let b=0;b<u.length;b++)if(m===b){const r=f[++p];u.onDeleteEmitter.fire({index:b-y,amount:r}),b+=r-1,y+=r,m=f[++p]}else d.push(b);return{layout:d,countRemoved:y}},s.reflowLargerApplyNewLayout=function(u,f){const d=[];for(let p=0;p<f.length;p++)d.push(u.get(f[p]));for(let p=0;p<d.length;p++)u.set(p,d[p]);u.length=f.length},s.reflowSmallerGetNewLineLengths=function(u,f,d){const p=[],m=u.map(((a,l)=>o(u,l,f))).reduce(((a,l)=>a+l));let y=0,b=0,r=0;for(;r<m;){if(m-r<d){p.push(m-r);break}y+=d;const a=o(u,b,f);y>a&&(y-=a,b++);const l=u[b].getWidth(y-1)===2;l&&y--;const c=l?d-1:d;p.push(c),r+=c}return p},s.getWrappedLineTrimmedLength=o},5295:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferSet=void 0;const u=o(8460),f=o(844),d=o(9092);class p extends f.Disposable{constructor(y,b){super(),this._optionsService=y,this._bufferService=b,this._onBufferActivate=this.register(new u.EventEmitter),this.onBufferActivate=this._onBufferActivate.event,this.reset(),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.resize(this._bufferService.cols,this._bufferService.rows)))),this.register(this._optionsService.onSpecificOptionChange("tabStopWidth",(()=>this.setupTabStops())))}reset(){this._normal=new d.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new d.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,b){this._normal.resize(y,b),this._alt.resize(y,b),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}s.BufferSet=p},511:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CellData=void 0;const u=o(482),f=o(643),d=o(3734);class p extends d.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new d.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const b=new p;return b.setFromCharData(y),b}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,u.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let b=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)b=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const r=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=r&&r<=56319){const a=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=a&&a<=57343?this.content=1024*(r-55296)+a-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:b=!0}else b=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;b&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}s.CellData=p},643:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.WHITESPACE_CELL_CODE=s.WHITESPACE_CELL_WIDTH=s.WHITESPACE_CELL_CHAR=s.NULL_CELL_CODE=s.NULL_CELL_WIDTH=s.NULL_CELL_CHAR=s.CHAR_DATA_CODE_INDEX=s.CHAR_DATA_WIDTH_INDEX=s.CHAR_DATA_CHAR_INDEX=s.CHAR_DATA_ATTR_INDEX=s.DEFAULT_EXT=s.DEFAULT_ATTR=s.DEFAULT_COLOR=void 0,s.DEFAULT_COLOR=0,s.DEFAULT_ATTR=256|s.DEFAULT_COLOR<<9,s.DEFAULT_EXT=0,s.CHAR_DATA_ATTR_INDEX=0,s.CHAR_DATA_CHAR_INDEX=1,s.CHAR_DATA_WIDTH_INDEX=2,s.CHAR_DATA_CODE_INDEX=3,s.NULL_CELL_CHAR="",s.NULL_CELL_WIDTH=1,s.NULL_CELL_CODE=0,s.WHITESPACE_CELL_CHAR=" ",s.WHITESPACE_CELL_WIDTH=1,s.WHITESPACE_CELL_CODE=32},4863:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Marker=void 0;const u=o(8460),f=o(844);class d{get id(){return this._id}constructor(m){this.line=m,this.isDisposed=!1,this._disposables=[],this._id=d._nextId++,this._onDispose=this.register(new u.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,f.disposeArray)(this._disposables),this._disposables.length=0)}register(m){return this._disposables.push(m),m}}s.Marker=d,d._nextId=1},7116:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DEFAULT_CHARSET=s.CHARSETS=void 0,s.CHARSETS={},s.DEFAULT_CHARSET=s.CHARSETS.B,s.CHARSETS[0]={"`":"◆",a:"▒",b:"␉",c:"␌",d:"␍",e:"␊",f:"°",g:"±",h:"␤",i:"␋",j:"┘",k:"┐",l:"┌",m:"└",n:"┼",o:"⎺",p:"⎻",q:"─",r:"⎼",s:"⎽",t:"├",u:"┤",v:"┴",w:"┬",x:"│",y:"≤",z:"≥","{":"π","|":"≠","}":"£","~":"·"},s.CHARSETS.A={"#":"£"},s.CHARSETS.B=void 0,s.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},s.CHARSETS.C=s.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},s.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},s.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},s.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},s.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},s.CHARSETS.E=s.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},s.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},s.CHARSETS.H=s.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},s.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(w,s)=>{var o,u,f;Object.defineProperty(s,"__esModule",{value:!0}),s.C1_ESCAPED=s.C1=s.C0=void 0,(function(d){d.NUL="\0",d.SOH="",d.STX="",d.ETX="",d.EOT="",d.ENQ="",d.ACK="",d.BEL="\x07",d.BS="\b",d.HT=" ",d.LF=`
15
+ `,d.VT="\v",d.FF="\f",d.CR="\r",d.SO="",d.SI="",d.DLE="",d.DC1="",d.DC2="",d.DC3="",d.DC4="",d.NAK="",d.SYN="",d.ETB="",d.CAN="",d.EM="",d.SUB="",d.ESC="\x1B",d.FS="",d.GS="",d.RS="",d.US="",d.SP=" ",d.DEL=""})(o||(s.C0=o={})),(function(d){d.PAD="€",d.HOP="",d.BPH="‚",d.NBH="ƒ",d.IND="„",d.NEL="…",d.SSA="†",d.ESA="‡",d.HTS="ˆ",d.HTJ="‰",d.VTS="Š",d.PLD="‹",d.PLU="Œ",d.RI="",d.SS2="Ž",d.SS3="",d.DCS="",d.PU1="‘",d.PU2="’",d.STS="“",d.CCH="”",d.MW="•",d.SPA="–",d.EPA="—",d.SOS="˜",d.SGCI="™",d.SCI="š",d.CSI="›",d.ST="œ",d.OSC="",d.PM="ž",d.APC="Ÿ"})(u||(s.C1=u={})),(function(d){d.ST=`${o.ESC}\\`})(f||(s.C1_ESCAPED=f={}))},7399:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.evaluateKeyboardEvent=void 0;const u=o(2584),f={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};s.evaluateKeyboardEvent=function(d,p,m,y){const b={type:0,cancel:!1,key:void 0},r=(d.shiftKey?1:0)|(d.altKey?2:0)|(d.ctrlKey?4:0)|(d.metaKey?8:0);switch(d.keyCode){case 0:d.key==="UIKeyInputUpArrow"?b.key=p?u.C0.ESC+"OA":u.C0.ESC+"[A":d.key==="UIKeyInputLeftArrow"?b.key=p?u.C0.ESC+"OD":u.C0.ESC+"[D":d.key==="UIKeyInputRightArrow"?b.key=p?u.C0.ESC+"OC":u.C0.ESC+"[C":d.key==="UIKeyInputDownArrow"&&(b.key=p?u.C0.ESC+"OB":u.C0.ESC+"[B");break;case 8:if(d.altKey){b.key=u.C0.ESC+u.C0.DEL;break}b.key=u.C0.DEL;break;case 9:if(d.shiftKey){b.key=u.C0.ESC+"[Z";break}b.key=u.C0.HT,b.cancel=!0;break;case 13:b.key=d.altKey?u.C0.ESC+u.C0.CR:u.C0.CR,b.cancel=!0;break;case 27:b.key=u.C0.ESC,d.altKey&&(b.key=u.C0.ESC+u.C0.ESC),b.cancel=!0;break;case 37:if(d.metaKey)break;r?(b.key=u.C0.ESC+"[1;"+(r+1)+"D",b.key===u.C0.ESC+"[1;3D"&&(b.key=u.C0.ESC+(m?"b":"[1;5D"))):b.key=p?u.C0.ESC+"OD":u.C0.ESC+"[D";break;case 39:if(d.metaKey)break;r?(b.key=u.C0.ESC+"[1;"+(r+1)+"C",b.key===u.C0.ESC+"[1;3C"&&(b.key=u.C0.ESC+(m?"f":"[1;5C"))):b.key=p?u.C0.ESC+"OC":u.C0.ESC+"[C";break;case 38:if(d.metaKey)break;r?(b.key=u.C0.ESC+"[1;"+(r+1)+"A",m||b.key!==u.C0.ESC+"[1;3A"||(b.key=u.C0.ESC+"[1;5A")):b.key=p?u.C0.ESC+"OA":u.C0.ESC+"[A";break;case 40:if(d.metaKey)break;r?(b.key=u.C0.ESC+"[1;"+(r+1)+"B",m||b.key!==u.C0.ESC+"[1;3B"||(b.key=u.C0.ESC+"[1;5B")):b.key=p?u.C0.ESC+"OB":u.C0.ESC+"[B";break;case 45:d.shiftKey||d.ctrlKey||(b.key=u.C0.ESC+"[2~");break;case 46:b.key=r?u.C0.ESC+"[3;"+(r+1)+"~":u.C0.ESC+"[3~";break;case 36:b.key=r?u.C0.ESC+"[1;"+(r+1)+"H":p?u.C0.ESC+"OH":u.C0.ESC+"[H";break;case 35:b.key=r?u.C0.ESC+"[1;"+(r+1)+"F":p?u.C0.ESC+"OF":u.C0.ESC+"[F";break;case 33:d.shiftKey?b.type=2:d.ctrlKey?b.key=u.C0.ESC+"[5;"+(r+1)+"~":b.key=u.C0.ESC+"[5~";break;case 34:d.shiftKey?b.type=3:d.ctrlKey?b.key=u.C0.ESC+"[6;"+(r+1)+"~":b.key=u.C0.ESC+"[6~";break;case 112:b.key=r?u.C0.ESC+"[1;"+(r+1)+"P":u.C0.ESC+"OP";break;case 113:b.key=r?u.C0.ESC+"[1;"+(r+1)+"Q":u.C0.ESC+"OQ";break;case 114:b.key=r?u.C0.ESC+"[1;"+(r+1)+"R":u.C0.ESC+"OR";break;case 115:b.key=r?u.C0.ESC+"[1;"+(r+1)+"S":u.C0.ESC+"OS";break;case 116:b.key=r?u.C0.ESC+"[15;"+(r+1)+"~":u.C0.ESC+"[15~";break;case 117:b.key=r?u.C0.ESC+"[17;"+(r+1)+"~":u.C0.ESC+"[17~";break;case 118:b.key=r?u.C0.ESC+"[18;"+(r+1)+"~":u.C0.ESC+"[18~";break;case 119:b.key=r?u.C0.ESC+"[19;"+(r+1)+"~":u.C0.ESC+"[19~";break;case 120:b.key=r?u.C0.ESC+"[20;"+(r+1)+"~":u.C0.ESC+"[20~";break;case 121:b.key=r?u.C0.ESC+"[21;"+(r+1)+"~":u.C0.ESC+"[21~";break;case 122:b.key=r?u.C0.ESC+"[23;"+(r+1)+"~":u.C0.ESC+"[23~";break;case 123:b.key=r?u.C0.ESC+"[24;"+(r+1)+"~":u.C0.ESC+"[24~";break;default:if(!d.ctrlKey||d.shiftKey||d.altKey||d.metaKey)if(m&&!y||!d.altKey||d.metaKey)!m||d.altKey||d.ctrlKey||d.shiftKey||!d.metaKey?d.key&&!d.ctrlKey&&!d.altKey&&!d.metaKey&&d.keyCode>=48&&d.key.length===1?b.key=d.key:d.key&&d.ctrlKey&&(d.key==="_"&&(b.key=u.C0.US),d.key==="@"&&(b.key=u.C0.NUL)):d.keyCode===65&&(b.type=1);else{const a=f[d.keyCode],l=a?.[d.shiftKey?1:0];if(l)b.key=u.C0.ESC+l;else if(d.keyCode>=65&&d.keyCode<=90){const c=d.ctrlKey?d.keyCode-64:d.keyCode+32;let g=String.fromCharCode(c);d.shiftKey&&(g=g.toUpperCase()),b.key=u.C0.ESC+g}else if(d.keyCode===32)b.key=u.C0.ESC+(d.ctrlKey?u.C0.NUL:" ");else if(d.key==="Dead"&&d.code.startsWith("Key")){let c=d.code.slice(3,4);d.shiftKey||(c=c.toLowerCase()),b.key=u.C0.ESC+c,b.cancel=!0}}else d.keyCode>=65&&d.keyCode<=90?b.key=String.fromCharCode(d.keyCode-64):d.keyCode===32?b.key=u.C0.NUL:d.keyCode>=51&&d.keyCode<=55?b.key=String.fromCharCode(d.keyCode-51+27):d.keyCode===56?b.key=u.C0.DEL:d.keyCode===219?b.key=u.C0.ESC:d.keyCode===220?b.key=u.C0.FS:d.keyCode===221&&(b.key=u.C0.GS)}return b}},482:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Utf8ToUtf32=s.StringToUtf32=s.utf32ToString=s.stringFromCodePoint=void 0,s.stringFromCodePoint=function(o){return o>65535?(o-=65536,String.fromCharCode(55296+(o>>10))+String.fromCharCode(o%1024+56320)):String.fromCharCode(o)},s.utf32ToString=function(o,u=0,f=o.length){let d="";for(let p=u;p<f;++p){let m=o[p];m>65535?(m-=65536,d+=String.fromCharCode(55296+(m>>10))+String.fromCharCode(m%1024+56320)):d+=String.fromCharCode(m)}return d},s.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(o,u){const f=o.length;if(!f)return 0;let d=0,p=0;if(this._interim){const m=o.charCodeAt(p++);56320<=m&&m<=57343?u[d++]=1024*(this._interim-55296)+m-56320+65536:(u[d++]=this._interim,u[d++]=m),this._interim=0}for(let m=p;m<f;++m){const y=o.charCodeAt(m);if(55296<=y&&y<=56319){if(++m>=f)return this._interim=y,d;const b=o.charCodeAt(m);56320<=b&&b<=57343?u[d++]=1024*(y-55296)+b-56320+65536:(u[d++]=y,u[d++]=b)}else y!==65279&&(u[d++]=y)}return d}},s.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(o,u){const f=o.length;if(!f)return 0;let d,p,m,y,b=0,r=0,a=0;if(this.interim[0]){let g=!1,_=this.interim[0];_&=(224&_)==192?31:(240&_)==224?15:7;let C,k=0;for(;(C=63&this.interim[++k])&&k<4;)_<<=6,_|=C;const v=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=v-k;for(;a<E;){if(a>=f)return 0;if(C=o[a++],(192&C)!=128){a--,g=!0;break}this.interim[k++]=C,_<<=6,_|=63&C}g||(v===2?_<128?a--:u[b++]=_:v===3?_<2048||_>=55296&&_<=57343||_===65279||(u[b++]=_):_<65536||_>1114111||(u[b++]=_)),this.interim.fill(0)}const l=f-4;let c=a;for(;c<f;){for(;!(!(c<l)||128&(d=o[c])||128&(p=o[c+1])||128&(m=o[c+2])||128&(y=o[c+3]));)u[b++]=d,u[b++]=p,u[b++]=m,u[b++]=y,c+=4;if(d=o[c++],d<128)u[b++]=d;else if((224&d)==192){if(c>=f)return this.interim[0]=d,b;if(p=o[c++],(192&p)!=128){c--;continue}if(r=(31&d)<<6|63&p,r<128){c--;continue}u[b++]=r}else if((240&d)==224){if(c>=f)return this.interim[0]=d,b;if(p=o[c++],(192&p)!=128){c--;continue}if(c>=f)return this.interim[0]=d,this.interim[1]=p,b;if(m=o[c++],(192&m)!=128){c--;continue}if(r=(15&d)<<12|(63&p)<<6|63&m,r<2048||r>=55296&&r<=57343||r===65279)continue;u[b++]=r}else if((248&d)==240){if(c>=f)return this.interim[0]=d,b;if(p=o[c++],(192&p)!=128){c--;continue}if(c>=f)return this.interim[0]=d,this.interim[1]=p,b;if(m=o[c++],(192&m)!=128){c--;continue}if(c>=f)return this.interim[0]=d,this.interim[1]=p,this.interim[2]=m,b;if(y=o[c++],(192&y)!=128){c--;continue}if(r=(7&d)<<18|(63&p)<<12|(63&m)<<6|63&y,r<65536||r>1114111)continue;u[b++]=r}}return b}}},225:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.UnicodeV6=void 0;const o=[[768,879],[1155,1158],[1160,1161],[1425,1469],[1471,1471],[1473,1474],[1476,1477],[1479,1479],[1536,1539],[1552,1557],[1611,1630],[1648,1648],[1750,1764],[1767,1768],[1770,1773],[1807,1807],[1809,1809],[1840,1866],[1958,1968],[2027,2035],[2305,2306],[2364,2364],[2369,2376],[2381,2381],[2385,2388],[2402,2403],[2433,2433],[2492,2492],[2497,2500],[2509,2509],[2530,2531],[2561,2562],[2620,2620],[2625,2626],[2631,2632],[2635,2637],[2672,2673],[2689,2690],[2748,2748],[2753,2757],[2759,2760],[2765,2765],[2786,2787],[2817,2817],[2876,2876],[2879,2879],[2881,2883],[2893,2893],[2902,2902],[2946,2946],[3008,3008],[3021,3021],[3134,3136],[3142,3144],[3146,3149],[3157,3158],[3260,3260],[3263,3263],[3270,3270],[3276,3277],[3298,3299],[3393,3395],[3405,3405],[3530,3530],[3538,3540],[3542,3542],[3633,3633],[3636,3642],[3655,3662],[3761,3761],[3764,3769],[3771,3772],[3784,3789],[3864,3865],[3893,3893],[3895,3895],[3897,3897],[3953,3966],[3968,3972],[3974,3975],[3984,3991],[3993,4028],[4038,4038],[4141,4144],[4146,4146],[4150,4151],[4153,4153],[4184,4185],[4448,4607],[4959,4959],[5906,5908],[5938,5940],[5970,5971],[6002,6003],[6068,6069],[6071,6077],[6086,6086],[6089,6099],[6109,6109],[6155,6157],[6313,6313],[6432,6434],[6439,6440],[6450,6450],[6457,6459],[6679,6680],[6912,6915],[6964,6964],[6966,6970],[6972,6972],[6978,6978],[7019,7027],[7616,7626],[7678,7679],[8203,8207],[8234,8238],[8288,8291],[8298,8303],[8400,8431],[12330,12335],[12441,12442],[43014,43014],[43019,43019],[43045,43046],[64286,64286],[65024,65039],[65056,65059],[65279,65279],[65529,65531]],u=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let f;s.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let d=0;d<o.length;++d)f.fill(0,o[d][0],o[d][1]+1)}}wcwidth(d){return d<32?0:d<127?1:d<65536?f[d]:(function(p,m){let y,b=0,r=m.length-1;if(p<m[0][0]||p>m[r][1])return!1;for(;r>=b;)if(y=b+r>>1,p>m[y][1])b=y+1;else{if(!(p<m[y][0]))return!0;r=y-1}return!1})(d,u)?0:d>=131072&&d<=196605||d>=196608&&d<=262141?2:1}}},5981:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.WriteBuffer=void 0;const u=o(8460),f=o(844);class d extends f.Disposable{constructor(m){super(),this._action=m,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new u.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(m,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let b;for(this._isSyncWriting=!0;b=this._writeBuffer.shift();){this._action(b);const r=this._callbacks.shift();r&&r()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(m,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=m.length,this._writeBuffer.push(m),this._callbacks.push(y)}_innerWrite(m=0,y=!0){const b=m||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const r=this._writeBuffer[this._bufferOffset],a=this._action(r,y);if(a){const c=g=>Date.now()-b>=12?setTimeout((()=>this._innerWrite(0,g))):this._innerWrite(b,g);return void a.catch((g=>(queueMicrotask((()=>{throw g})),Promise.resolve(!1)))).then(c)}const l=this._callbacks[this._bufferOffset];if(l&&l(),this._bufferOffset++,this._pendingData-=r.length,Date.now()-b>=12)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>50&&(this._writeBuffer=this._writeBuffer.slice(this._bufferOffset),this._callbacks=this._callbacks.slice(this._bufferOffset),this._bufferOffset=0),setTimeout((()=>this._innerWrite()))):(this._writeBuffer.length=0,this._callbacks.length=0,this._pendingData=0,this._bufferOffset=0),this._onWriteParsed.fire()}}s.WriteBuffer=d},5941:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.toRgbString=s.parseColor=void 0;const o=/^([\da-f])\/([\da-f])\/([\da-f])$|^([\da-f]{2})\/([\da-f]{2})\/([\da-f]{2})$|^([\da-f]{3})\/([\da-f]{3})\/([\da-f]{3})$|^([\da-f]{4})\/([\da-f]{4})\/([\da-f]{4})$/,u=/^[\da-f]+$/;function f(d,p){const m=d.toString(16),y=m.length<2?"0"+m:m;switch(p){case 4:return m[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}s.parseColor=function(d){if(!d)return;let p=d.toLowerCase();if(p.indexOf("rgb:")===0){p=p.slice(4);const m=o.exec(p);if(m){const y=m[1]?15:m[4]?255:m[7]?4095:65535;return[Math.round(parseInt(m[1]||m[4]||m[7]||m[10],16)/y*255),Math.round(parseInt(m[2]||m[5]||m[8]||m[11],16)/y*255),Math.round(parseInt(m[3]||m[6]||m[9]||m[12],16)/y*255)]}}else if(p.indexOf("#")===0&&(p=p.slice(1),u.exec(p)&&[3,6,9,12].includes(p.length))){const m=p.length/3,y=[0,0,0];for(let b=0;b<3;++b){const r=parseInt(p.slice(m*b,m*b+m),16);y[b]=m===1?r<<4:m===2?r:m===3?r>>4:r>>8}return y}},s.toRgbString=function(d,p=16){const[m,y,b]=d;return`rgb:${f(m,p)}/${f(y,p)}/${f(b,p)}`}},5770:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.PAYLOAD_LIMIT=void 0,s.PAYLOAD_LIMIT=1e7},6351:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DcsHandler=s.DcsParser=void 0;const u=o(482),f=o(8742),d=o(5770),p=[];s.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=p,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=p}registerHandler(y,b){this._handlers[y]===void 0&&(this._handlers[y]=[]);const r=this._handlers[y];return r.push(b),{dispose:()=>{const a=r.indexOf(b);a!==-1&&r.splice(a,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=p,this._ident=0}hook(y,b){if(this.reset(),this._ident=y,this._active=this._handlers[y]||p,this._active.length)for(let r=this._active.length-1;r>=0;r--)this._active[r].hook(b);else this._handlerFb(this._ident,"HOOK",b)}put(y,b,r){if(this._active.length)for(let a=this._active.length-1;a>=0;a--)this._active[a].put(y,b,r);else this._handlerFb(this._ident,"PUT",(0,u.utf32ToString)(y,b,r))}unhook(y,b=!0){if(this._active.length){let r=!1,a=this._active.length-1,l=!1;if(this._stack.paused&&(a=this._stack.loopPosition-1,r=b,l=this._stack.fallThrough,this._stack.paused=!1),!l&&r===!1){for(;a>=0&&(r=this._active[a].unhook(y),r!==!0);a--)if(r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=a,this._stack.fallThrough=!1,r;a--}for(;a>=0;a--)if(r=this._active[a].unhook(!1),r instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=a,this._stack.fallThrough=!0,r}else this._handlerFb(this._ident,"UNHOOK",y);this._active=p,this._ident=0}};const m=new f.Params;m.addParam(0),s.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=m,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():m,this._data="",this._hitLimit=!1}put(y,b,r){this._hitLimit||(this._data+=(0,u.utf32ToString)(y,b,r),this._data.length>d.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let b=!1;if(this._hitLimit)b=!1;else if(y&&(b=this._handler(this._data,this._params),b instanceof Promise))return b.then((r=>(this._params=m,this._data="",this._hitLimit=!1,r)));return this._params=m,this._data="",this._hitLimit=!1,b}}},2015:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.EscapeSequenceParser=s.VT500_TRANSITION_TABLE=s.TransitionTable=void 0;const u=o(844),f=o(8742),d=o(6242),p=o(6351);class m{constructor(a){this.table=new Uint8Array(a)}setDefault(a,l){this.table.fill(a<<4|l)}add(a,l,c,g){this.table[l<<8|a]=c<<4|g}addMany(a,l,c,g){for(let _=0;_<a.length;_++)this.table[l<<8|a[_]]=c<<4|g}}s.TransitionTable=m;const y=160;s.VT500_TRANSITION_TABLE=(function(){const r=new m(4095),a=Array.apply(null,Array(256)).map(((k,v)=>v)),l=(k,v)=>a.slice(k,v),c=l(32,127),g=l(0,24);g.push(25),g.push.apply(g,l(28,32));const _=l(0,14);let C;for(C in r.setDefault(1,0),r.addMany(c,0,2,0),_)r.addMany([24,26,153,154],C,3,0),r.addMany(l(128,144),C,3,0),r.addMany(l(144,152),C,3,0),r.add(156,C,0,0),r.add(27,C,11,1),r.add(157,C,4,8),r.addMany([152,158,159],C,0,7),r.add(155,C,11,3),r.add(144,C,11,9);return r.addMany(g,0,3,0),r.addMany(g,1,3,1),r.add(127,1,0,1),r.addMany(g,8,0,8),r.addMany(g,3,3,3),r.add(127,3,0,3),r.addMany(g,4,3,4),r.add(127,4,0,4),r.addMany(g,6,3,6),r.addMany(g,5,3,5),r.add(127,5,0,5),r.addMany(g,2,3,2),r.add(127,2,0,2),r.add(93,1,4,8),r.addMany(c,8,5,8),r.add(127,8,5,8),r.addMany([156,27,24,26,7],8,6,0),r.addMany(l(28,32),8,0,8),r.addMany([88,94,95],1,0,7),r.addMany(c,7,0,7),r.addMany(g,7,0,7),r.add(156,7,0,0),r.add(127,7,0,7),r.add(91,1,11,3),r.addMany(l(64,127),3,7,0),r.addMany(l(48,60),3,8,4),r.addMany([60,61,62,63],3,9,4),r.addMany(l(48,60),4,8,4),r.addMany(l(64,127),4,7,0),r.addMany([60,61,62,63],4,0,6),r.addMany(l(32,64),6,0,6),r.add(127,6,0,6),r.addMany(l(64,127),6,0,0),r.addMany(l(32,48),3,9,5),r.addMany(l(32,48),5,9,5),r.addMany(l(48,64),5,0,6),r.addMany(l(64,127),5,7,0),r.addMany(l(32,48),4,9,5),r.addMany(l(32,48),1,9,2),r.addMany(l(32,48),2,9,2),r.addMany(l(48,127),2,10,0),r.addMany(l(48,80),1,10,0),r.addMany(l(81,88),1,10,0),r.addMany([89,90,92],1,10,0),r.addMany(l(96,127),1,10,0),r.add(80,1,11,9),r.addMany(g,9,0,9),r.add(127,9,0,9),r.addMany(l(28,32),9,0,9),r.addMany(l(32,48),9,9,12),r.addMany(l(48,60),9,8,10),r.addMany([60,61,62,63],9,9,10),r.addMany(g,11,0,11),r.addMany(l(32,128),11,0,11),r.addMany(l(28,32),11,0,11),r.addMany(g,10,0,10),r.add(127,10,0,10),r.addMany(l(28,32),10,0,10),r.addMany(l(48,60),10,8,10),r.addMany([60,61,62,63],10,0,11),r.addMany(l(32,48),10,9,12),r.addMany(g,12,0,12),r.add(127,12,0,12),r.addMany(l(28,32),12,0,12),r.addMany(l(32,48),12,9,12),r.addMany(l(48,64),12,0,11),r.addMany(l(64,127),12,12,13),r.addMany(l(64,127),10,12,13),r.addMany(l(64,127),9,12,13),r.addMany(g,13,13,13),r.addMany(c,13,13,13),r.add(127,13,0,13),r.addMany([27,156,24,26],13,14,0),r.add(y,0,2,0),r.add(y,8,5,8),r.add(y,6,0,6),r.add(y,11,0,11),r.add(y,13,13,13),r})();class b extends u.Disposable{constructor(a=s.VT500_TRANSITION_TABLE){super(),this._transitions=a,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(l,c,g)=>{},this._executeHandlerFb=l=>{},this._csiHandlerFb=(l,c)=>{},this._escHandlerFb=l=>{},this._errorHandlerFb=l=>l,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,u.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new d.OscParser),this._dcsParser=this.register(new p.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(a,l=[64,126]){let c=0;if(a.prefix){if(a.prefix.length>1)throw new Error("only one byte as prefix supported");if(c=a.prefix.charCodeAt(0),c&&60>c||c>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(a.intermediates){if(a.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let _=0;_<a.intermediates.length;++_){const C=a.intermediates.charCodeAt(_);if(32>C||C>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");c<<=8,c|=C}}if(a.final.length!==1)throw new Error("final must be a single byte");const g=a.final.charCodeAt(0);if(l[0]>g||g>l[1])throw new Error(`final must be in range ${l[0]} .. ${l[1]}`);return c<<=8,c|=g,c}identToString(a){const l=[];for(;a;)l.push(String.fromCharCode(255&a)),a>>=8;return l.reverse().join("")}setPrintHandler(a){this._printHandler=a}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(a,l){const c=this._identifier(a,[48,126]);this._escHandlers[c]===void 0&&(this._escHandlers[c]=[]);const g=this._escHandlers[c];return g.push(l),{dispose:()=>{const _=g.indexOf(l);_!==-1&&g.splice(_,1)}}}clearEscHandler(a){this._escHandlers[this._identifier(a,[48,126])]&&delete this._escHandlers[this._identifier(a,[48,126])]}setEscHandlerFallback(a){this._escHandlerFb=a}setExecuteHandler(a,l){this._executeHandlers[a.charCodeAt(0)]=l}clearExecuteHandler(a){this._executeHandlers[a.charCodeAt(0)]&&delete this._executeHandlers[a.charCodeAt(0)]}setExecuteHandlerFallback(a){this._executeHandlerFb=a}registerCsiHandler(a,l){const c=this._identifier(a);this._csiHandlers[c]===void 0&&(this._csiHandlers[c]=[]);const g=this._csiHandlers[c];return g.push(l),{dispose:()=>{const _=g.indexOf(l);_!==-1&&g.splice(_,1)}}}clearCsiHandler(a){this._csiHandlers[this._identifier(a)]&&delete this._csiHandlers[this._identifier(a)]}setCsiHandlerFallback(a){this._csiHandlerFb=a}registerDcsHandler(a,l){return this._dcsParser.registerHandler(this._identifier(a),l)}clearDcsHandler(a){this._dcsParser.clearHandler(this._identifier(a))}setDcsHandlerFallback(a){this._dcsParser.setHandlerFallback(a)}registerOscHandler(a,l){return this._oscParser.registerHandler(a,l)}clearOscHandler(a){this._oscParser.clearHandler(a)}setOscHandlerFallback(a){this._oscParser.setHandlerFallback(a)}setErrorHandler(a){this._errorHandler=a}clearErrorHandler(){this._errorHandler=this._errorHandlerFb}reset(){this.currentState=this.initialState,this._oscParser.reset(),this._dcsParser.reset(),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(a,l,c,g,_){this._parseStack.state=a,this._parseStack.handlers=l,this._parseStack.handlerPos=c,this._parseStack.transition=g,this._parseStack.chunkPos=_}parse(a,l,c){let g,_=0,C=0,k=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,k=this._parseStack.chunkPos+1;else{if(c===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const v=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(c===!1&&E>-1){for(;E>=0&&(g=v[E](this._params),g!==!0);E--)if(g instanceof Promise)return this._parseStack.handlerPos=E,g}this._parseStack.handlers=[];break;case 4:if(c===!1&&E>-1){for(;E>=0&&(g=v[E](),g!==!0);E--)if(g instanceof Promise)return this._parseStack.handlerPos=E,g}this._parseStack.handlers=[];break;case 6:if(_=a[this._parseStack.chunkPos],g=this._dcsParser.unhook(_!==24&&_!==26,c),g)return g;_===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(_=a[this._parseStack.chunkPos],g=this._oscParser.end(_!==24&&_!==26,c),g)return g;_===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,k=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let v=k;v<l;++v){switch(_=a[v],C=this._transitions.table[this.currentState<<8|(_<160?_:y)],C>>4){case 2:for(let P=v+1;;++P){if(P>=l||(_=a[P])<32||_>126&&_<y){this._printHandler(a,v,P),v=P-1;break}if(++P>=l||(_=a[P])<32||_>126&&_<y){this._printHandler(a,v,P),v=P-1;break}if(++P>=l||(_=a[P])<32||_>126&&_<y){this._printHandler(a,v,P),v=P-1;break}if(++P>=l||(_=a[P])<32||_>126&&_<y){this._printHandler(a,v,P),v=P-1;break}}break;case 3:this._executeHandlers[_]?this._executeHandlers[_]():this._executeHandlerFb(_),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:v,code:_,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|_];let R=E?E.length-1:-1;for(;R>=0&&(g=E[R](this._params),g!==!0);R--)if(g instanceof Promise)return this._preserveStack(3,E,R,C,v),g;R<0&&this._csiHandlerFb(this._collect<<8|_,this._params),this.precedingCodepoint=0;break;case 8:do switch(_){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(_-48)}while(++v<l&&(_=a[v])>47&&_<60);v--;break;case 9:this._collect<<=8,this._collect|=_;break;case 10:const O=this._escHandlers[this._collect<<8|_];let L=O?O.length-1:-1;for(;L>=0&&(g=O[L](),g!==!0);L--)if(g instanceof Promise)return this._preserveStack(4,O,L,C,v),g;L<0&&this._escHandlerFb(this._collect<<8|_),this.precedingCodepoint=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|_,this._params);break;case 13:for(let P=v+1;;++P)if(P>=l||(_=a[P])===24||_===26||_===27||_>127&&_<y){this._dcsParser.put(a,v,P),v=P-1;break}break;case 14:if(g=this._dcsParser.unhook(_!==24&&_!==26),g)return this._preserveStack(6,[],0,C,v),g;_===27&&(C|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0;break;case 4:this._oscParser.start();break;case 5:for(let P=v+1;;P++)if(P>=l||(_=a[P])<32||_>127&&_<y){this._oscParser.put(a,v,P),v=P-1;break}break;case 6:if(g=this._oscParser.end(_!==24&&_!==26),g)return this._preserveStack(5,[],0,C,v),g;_===27&&(C|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&C}}}s.EscapeSequenceParser=b},6242:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.OscHandler=s.OscParser=void 0;const u=o(5770),f=o(482),d=[];s.OscParser=class{constructor(){this._state=0,this._active=d,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(p,m){this._handlers[p]===void 0&&(this._handlers[p]=[]);const y=this._handlers[p];return y.push(m),{dispose:()=>{const b=y.indexOf(m);b!==-1&&y.splice(b,1)}}}clearHandler(p){this._handlers[p]&&delete this._handlers[p]}setHandlerFallback(p){this._handlerFb=p}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=d}reset(){if(this._state===2)for(let p=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;p>=0;--p)this._active[p].end(!1);this._stack.paused=!1,this._active=d,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||d,this._active.length)for(let p=this._active.length-1;p>=0;p--)this._active[p].start();else this._handlerFb(this._id,"START")}_put(p,m,y){if(this._active.length)for(let b=this._active.length-1;b>=0;b--)this._active[b].put(p,m,y);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(p,m,y))}start(){this.reset(),this._state=1}put(p,m,y){if(this._state!==3){if(this._state===1)for(;m<y;){const b=p[m++];if(b===59){this._state=2,this._start();break}if(b<48||57<b)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+b-48}this._state===2&&y-m>0&&this._put(p,m,y)}}end(p,m=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,b=this._active.length-1,r=!1;if(this._stack.paused&&(b=this._stack.loopPosition-1,y=m,r=this._stack.fallThrough,this._stack.paused=!1),!r&&y===!1){for(;b>=0&&(y=this._active[b].end(p),y!==!0);b--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!1,y;b--}for(;b>=0;b--)if(y=this._active[b].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=b,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",p);this._active=d,this._id=-1,this._state=0}}},s.OscHandler=class{constructor(p){this._handler=p,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(p,m,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(p,m,y),this._data.length>u.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(p){let m=!1;if(this._hitLimit)m=!1;else if(p&&(m=this._handler(this._data),m instanceof Promise))return m.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,m}}},8742:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.Params=void 0;const o=2147483647;class u{static fromArray(d){const p=new u;if(!d.length)return p;for(let m=Array.isArray(d[0])?1:0;m<d.length;++m){const y=d[m];if(Array.isArray(y))for(let b=0;b<y.length;++b)p.addSubParam(y[b]);else p.addParam(y)}return p}constructor(d=32,p=32){if(this.maxLength=d,this.maxSubParamsLength=p,p>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(d),this.length=0,this._subParams=new Int32Array(p),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(d),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const d=new u(this.maxLength,this.maxSubParamsLength);return d.params.set(this.params),d.length=this.length,d._subParams.set(this._subParams),d._subParamsLength=this._subParamsLength,d._subParamsIdx.set(this._subParamsIdx),d._rejectDigits=this._rejectDigits,d._rejectSubDigits=this._rejectSubDigits,d._digitIsSub=this._digitIsSub,d}toArray(){const d=[];for(let p=0;p<this.length;++p){d.push(this.params[p]);const m=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-m>0&&d.push(Array.prototype.slice.call(this._subParams,m,y))}return d}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(d){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(d<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=d>o?o:d}}addSubParam(d){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(d<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=d>o?o:d,this._subParamsIdx[this.length-1]++}}hasSubParams(d){return(255&this._subParamsIdx[d])-(this._subParamsIdx[d]>>8)>0}getSubParams(d){const p=this._subParamsIdx[d]>>8,m=255&this._subParamsIdx[d];return m-p>0?this._subParams.subarray(p,m):null}getSubParamsAll(){const d={};for(let p=0;p<this.length;++p){const m=this._subParamsIdx[p]>>8,y=255&this._subParamsIdx[p];y-m>0&&(d[p]=this._subParams.slice(m,y))}return d}addDigit(d){let p;if(this._rejectDigits||!(p=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const m=this._digitIsSub?this._subParams:this.params,y=m[p-1];m[p-1]=~y?Math.min(10*y+d,o):d}}s.Params=u},5741:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.AddonManager=void 0,s.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let o=this._addons.length-1;o>=0;o--)this._addons[o].instance.dispose()}loadAddon(o,u){const f={instance:u,dispose:u.dispose,isDisposed:!1};this._addons.push(f),u.dispose=()=>this._wrappedAddonDispose(f),u.activate(o)}_wrappedAddonDispose(o){if(o.isDisposed)return;let u=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===o){u=f;break}if(u===-1)throw new Error("Could not dispose an addon that has not been loaded");o.isDisposed=!0,o.dispose.apply(o.instance),this._addons.splice(u,1)}}},8771:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferApiView=void 0;const u=o(3785),f=o(511);s.BufferApiView=class{constructor(d,p){this._buffer=d,this.type=p}init(d){return this._buffer=d,this}get cursorY(){return this._buffer.y}get cursorX(){return this._buffer.x}get viewportY(){return this._buffer.ydisp}get baseY(){return this._buffer.ybase}get length(){return this._buffer.lines.length}getLine(d){const p=this._buffer.lines.get(d);if(p)return new u.BufferLineApiView(p)}getNullCell(){return new f.CellData}}},3785:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferLineApiView=void 0;const u=o(511);s.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,d){if(!(f<0||f>=this._line.length))return d?(this._line.loadCell(f,d),d):this._line.loadCell(f,new u.CellData)}translateToString(f,d,p){return this._line.translateToString(f,d,p)}}},8285:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.BufferNamespaceApi=void 0;const u=o(8771),f=o(8460),d=o(844);class p extends d.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new f.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new u.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new u.BufferApiView(this._core.buffers.alt,"alternate"),this._core.buffers.onBufferActivate((()=>this._onBufferChange.fire(this.active)))}get active(){if(this._core.buffers.active===this._core.buffers.normal)return this.normal;if(this._core.buffers.active===this._core.buffers.alt)return this.alternate;throw new Error("Active buffer is neither normal nor alternate")}get normal(){return this._normal.init(this._core.buffers.normal)}get alternate(){return this._alternate.init(this._core.buffers.alt)}}s.BufferNamespaceApi=p},7975:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.ParserApi=void 0,s.ParserApi=class{constructor(o){this._core=o}registerCsiHandler(o,u){return this._core.registerCsiHandler(o,(f=>u(f.toArray())))}addCsiHandler(o,u){return this.registerCsiHandler(o,u)}registerDcsHandler(o,u){return this._core.registerDcsHandler(o,((f,d)=>u(f,d.toArray())))}addDcsHandler(o,u){return this.registerDcsHandler(o,u)}registerEscHandler(o,u){return this._core.registerEscHandler(o,u)}addEscHandler(o,u){return this.registerEscHandler(o,u)}registerOscHandler(o,u){return this._core.registerOscHandler(o,u)}addOscHandler(o,u){return this.registerOscHandler(o,u)}}},7090:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.UnicodeApi=void 0,s.UnicodeApi=class{constructor(o){this._core=o}register(o){this._core.unicodeService.register(o)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(o){this._core.unicodeService.activeVersion=o}}},744:function(w,s,o){var u=this&&this.__decorate||function(r,a,l,c){var g,_=arguments.length,C=_<3?a:c===null?c=Object.getOwnPropertyDescriptor(a,l):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(r,a,l,c);else for(var k=r.length-1;k>=0;k--)(g=r[k])&&(C=(_<3?g(C):_>3?g(a,l,C):g(a,l))||C);return _>3&&C&&Object.defineProperty(a,l,C),C},f=this&&this.__param||function(r,a){return function(l,c){a(l,c,r)}};Object.defineProperty(s,"__esModule",{value:!0}),s.BufferService=s.MINIMUM_ROWS=s.MINIMUM_COLS=void 0;const d=o(8460),p=o(844),m=o(5295),y=o(2585);s.MINIMUM_COLS=2,s.MINIMUM_ROWS=1;let b=s.BufferService=class extends p.Disposable{get buffer(){return this.buffers.active}constructor(r){super(),this.isUserScrolling=!1,this._onResize=this.register(new d.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new d.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(r.rawOptions.cols||0,s.MINIMUM_COLS),this.rows=Math.max(r.rawOptions.rows||0,s.MINIMUM_ROWS),this.buffers=this.register(new m.BufferSet(r,this))}resize(r,a){this.cols=r,this.rows=a,this.buffers.resize(r,a),this._onResize.fire({cols:r,rows:a})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(r,a=!1){const l=this.buffer;let c;c=this._cachedBlankLine,c&&c.length===this.cols&&c.getFg(0)===r.fg&&c.getBg(0)===r.bg||(c=l.getBlankLine(r,a),this._cachedBlankLine=c),c.isWrapped=a;const g=l.ybase+l.scrollTop,_=l.ybase+l.scrollBottom;if(l.scrollTop===0){const C=l.lines.isFull;_===l.lines.length-1?C?l.lines.recycle().copyFrom(c):l.lines.push(c.clone()):l.lines.splice(_+1,0,c.clone()),C?this.isUserScrolling&&(l.ydisp=Math.max(l.ydisp-1,0)):(l.ybase++,this.isUserScrolling||l.ydisp++)}else{const C=_-g+1;l.lines.shiftElements(g+1,C-1,-1),l.lines.set(_,c.clone())}this.isUserScrolling||(l.ydisp=l.ybase),this._onScroll.fire(l.ydisp)}scrollLines(r,a,l){const c=this.buffer;if(r<0){if(c.ydisp===0)return;this.isUserScrolling=!0}else r+c.ydisp>=c.ybase&&(this.isUserScrolling=!1);const g=c.ydisp;c.ydisp=Math.max(Math.min(c.ydisp+r,c.ybase),0),g!==c.ydisp&&(a||this._onScroll.fire(c.ydisp))}};s.BufferService=b=u([f(0,y.IOptionsService)],b)},7994:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.CharsetService=void 0,s.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(o){this.glevel=o,this.charset=this._charsets[o]}setgCharset(o,u){this._charsets[o]=u,this.glevel===o&&(this.charset=u)}}},1753:function(w,s,o){var u=this&&this.__decorate||function(c,g,_,C){var k,v=arguments.length,E=v<3?g:C===null?C=Object.getOwnPropertyDescriptor(g,_):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(c,g,_,C);else for(var R=c.length-1;R>=0;R--)(k=c[R])&&(E=(v<3?k(E):v>3?k(g,_,E):k(g,_))||E);return v>3&&E&&Object.defineProperty(g,_,E),E},f=this&&this.__param||function(c,g){return function(_,C){g(_,C,c)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CoreMouseService=void 0;const d=o(2585),p=o(8460),m=o(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:c=>c.button!==4&&c.action===1&&(c.ctrl=!1,c.alt=!1,c.shift=!1,!0)},VT200:{events:19,restrict:c=>c.action!==32},DRAG:{events:23,restrict:c=>c.action!==32||c.button!==3},ANY:{events:31,restrict:c=>!0}};function b(c,g){let _=(c.ctrl?16:0)|(c.shift?4:0)|(c.alt?8:0);return c.button===4?(_|=64,_|=c.action):(_|=3&c.button,4&c.button&&(_|=64),8&c.button&&(_|=128),c.action===32?_|=32:c.action!==0||g||(_|=3)),_}const r=String.fromCharCode,a={DEFAULT:c=>{const g=[b(c,!1)+32,c.col+32,c.row+32];return g[0]>255||g[1]>255||g[2]>255?"":`\x1B[M${r(g[0])}${r(g[1])}${r(g[2])}`},SGR:c=>{const g=c.action===0&&c.button!==4?"m":"M";return`\x1B[<${b(c,!0)};${c.col};${c.row}${g}`},SGR_PIXELS:c=>{const g=c.action===0&&c.button!==4?"m":"M";return`\x1B[<${b(c,!0)};${c.x};${c.y}${g}`}};let l=s.CoreMouseService=class extends m.Disposable{constructor(c,g){super(),this._bufferService=c,this._coreService=g,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new p.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const _ of Object.keys(y))this.addProtocol(_,y[_]);for(const _ of Object.keys(a))this.addEncoding(_,a[_]);this.reset()}addProtocol(c,g){this._protocols[c]=g}addEncoding(c,g){this._encodings[c]=g}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(c){if(!this._protocols[c])throw new Error(`unknown protocol "${c}"`);this._activeProtocol=c,this._onProtocolChange.fire(this._protocols[c].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(c){if(!this._encodings[c])throw new Error(`unknown encoding "${c}"`);this._activeEncoding=c}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(c){if(c.col<0||c.col>=this._bufferService.cols||c.row<0||c.row>=this._bufferService.rows||c.button===4&&c.action===32||c.button===3&&c.action!==32||c.button!==4&&(c.action===2||c.action===3)||(c.col++,c.row++,c.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,c,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(c))return!1;const g=this._encodings[this._activeEncoding](c);return g&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(g):this._coreService.triggerDataEvent(g,!0)),this._lastEvent=c,!0}explainEvents(c){return{down:!!(1&c),up:!!(2&c),drag:!!(4&c),move:!!(8&c),wheel:!!(16&c)}}_equalEvents(c,g,_){if(_){if(c.x!==g.x||c.y!==g.y)return!1}else if(c.col!==g.col||c.row!==g.row)return!1;return c.button===g.button&&c.action===g.action&&c.ctrl===g.ctrl&&c.alt===g.alt&&c.shift===g.shift}};s.CoreMouseService=l=u([f(0,d.IBufferService),f(1,d.ICoreService)],l)},6975:function(w,s,o){var u=this&&this.__decorate||function(l,c,g,_){var C,k=arguments.length,v=k<3?c:_===null?_=Object.getOwnPropertyDescriptor(c,g):_;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")v=Reflect.decorate(l,c,g,_);else for(var E=l.length-1;E>=0;E--)(C=l[E])&&(v=(k<3?C(v):k>3?C(c,g,v):C(c,g))||v);return k>3&&v&&Object.defineProperty(c,g,v),v},f=this&&this.__param||function(l,c){return function(g,_){c(g,_,l)}};Object.defineProperty(s,"__esModule",{value:!0}),s.CoreService=void 0;const d=o(1439),p=o(8460),m=o(844),y=o(2585),b=Object.freeze({insertMode:!1}),r=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let a=s.CoreService=class extends m.Disposable{constructor(l,c,g){super(),this._bufferService=l,this._logService=c,this._optionsService=g,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new p.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new p.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new p.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new p.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,d.clone)(b),this.decPrivateModes=(0,d.clone)(r)}reset(){this.modes=(0,d.clone)(b),this.decPrivateModes=(0,d.clone)(r)}triggerDataEvent(l,c=!1){if(this._optionsService.rawOptions.disableStdin)return;const g=this._bufferService.buffer;c&&this._optionsService.rawOptions.scrollOnUserInput&&g.ybase!==g.ydisp&&this._onRequestScrollToBottom.fire(),c&&this._onUserInput.fire(),this._logService.debug(`sending data "${l}"`,(()=>l.split("").map((_=>_.charCodeAt(0))))),this._onData.fire(l)}triggerBinaryEvent(l){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${l}"`,(()=>l.split("").map((c=>c.charCodeAt(0))))),this._onBinary.fire(l))}};s.CoreService=a=u([f(0,y.IBufferService),f(1,y.ILogService),f(2,y.IOptionsService)],a)},9074:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.DecorationService=void 0;const u=o(8055),f=o(8460),d=o(844),p=o(6106);let m=0,y=0;class b extends d.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new p.SortedList((l=>l?.marker.line)),this._onDecorationRegistered=this.register(new f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,d.toDisposable)((()=>this.reset())))}registerDecoration(l){if(l.marker.isDisposed)return;const c=new r(l);if(c){const g=c.marker.onDispose((()=>c.dispose()));c.onDispose((()=>{c&&(this._decorations.delete(c)&&this._onDecorationRemoved.fire(c),g.dispose())})),this._decorations.insert(c),this._onDecorationRegistered.fire(c)}return c}reset(){for(const l of this._decorations.values())l.dispose();this._decorations.clear()}*getDecorationsAtCell(l,c,g){var _,C,k;let v=0,E=0;for(const R of this._decorations.getKeyIterator(c))v=(_=R.options.x)!==null&&_!==void 0?_:0,E=v+((C=R.options.width)!==null&&C!==void 0?C:1),l>=v&&l<E&&(!g||((k=R.options.layer)!==null&&k!==void 0?k:"bottom")===g)&&(yield R)}forEachDecorationAtCell(l,c,g,_){this._decorations.forEachByKey(c,(C=>{var k,v,E;m=(k=C.options.x)!==null&&k!==void 0?k:0,y=m+((v=C.options.width)!==null&&v!==void 0?v:1),l>=m&&l<y&&(!g||((E=C.options.layer)!==null&&E!==void 0?E:"bottom")===g)&&_(C)}))}}s.DecorationService=b;class r extends d.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=u.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=u.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(l){super(),this.options=l,this.onRenderEmitter=this.register(new f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=l.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.InstantiationService=s.ServiceCollection=void 0;const u=o(2585),f=o(8343);class d{constructor(...m){this._entries=new Map;for(const[y,b]of m)this.set(y,b)}set(m,y){const b=this._entries.get(m);return this._entries.set(m,y),b}forEach(m){for(const[y,b]of this._entries.entries())m(y,b)}has(m){return this._entries.has(m)}get(m){return this._entries.get(m)}}s.ServiceCollection=d,s.InstantiationService=class{constructor(){this._services=new d,this._services.set(u.IInstantiationService,this)}setService(p,m){this._services.set(p,m)}getService(p){return this._services.get(p)}createInstance(p,...m){const y=(0,f.getServiceDependencies)(p).sort(((a,l)=>a.index-l.index)),b=[];for(const a of y){const l=this._services.get(a.id);if(!l)throw new Error(`[createInstance] ${p.name} depends on UNKNOWN service ${a.id}.`);b.push(l)}const r=y.length>0?y[0].index:m.length;if(m.length!==r)throw new Error(`[createInstance] First service dependency of ${p.name} at position ${r+1} conflicts with ${m.length} static arguments`);return new p(...m,...b)}}},7866:function(w,s,o){var u=this&&this.__decorate||function(r,a,l,c){var g,_=arguments.length,C=_<3?a:c===null?c=Object.getOwnPropertyDescriptor(a,l):c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(r,a,l,c);else for(var k=r.length-1;k>=0;k--)(g=r[k])&&(C=(_<3?g(C):_>3?g(a,l,C):g(a,l))||C);return _>3&&C&&Object.defineProperty(a,l,C),C},f=this&&this.__param||function(r,a){return function(l,c){a(l,c,r)}};Object.defineProperty(s,"__esModule",{value:!0}),s.traceCall=s.setTraceLogger=s.LogService=void 0;const d=o(844),p=o(2585),m={trace:p.LogLevelEnum.TRACE,debug:p.LogLevelEnum.DEBUG,info:p.LogLevelEnum.INFO,warn:p.LogLevelEnum.WARN,error:p.LogLevelEnum.ERROR,off:p.LogLevelEnum.OFF};let y,b=s.LogService=class extends d.Disposable{get logLevel(){return this._logLevel}constructor(r){super(),this._optionsService=r,this._logLevel=p.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=m[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(r){for(let a=0;a<r.length;a++)typeof r[a]=="function"&&(r[a]=r[a]())}_log(r,a,l){this._evalLazyOptionalParams(l),r.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+a,...l)}trace(r,...a){var l,c;this._logLevel<=p.LogLevelEnum.TRACE&&this._log((c=(l=this._optionsService.options.logger)===null||l===void 0?void 0:l.trace.bind(this._optionsService.options.logger))!==null&&c!==void 0?c:console.log,r,a)}debug(r,...a){var l,c;this._logLevel<=p.LogLevelEnum.DEBUG&&this._log((c=(l=this._optionsService.options.logger)===null||l===void 0?void 0:l.debug.bind(this._optionsService.options.logger))!==null&&c!==void 0?c:console.log,r,a)}info(r,...a){var l,c;this._logLevel<=p.LogLevelEnum.INFO&&this._log((c=(l=this._optionsService.options.logger)===null||l===void 0?void 0:l.info.bind(this._optionsService.options.logger))!==null&&c!==void 0?c:console.info,r,a)}warn(r,...a){var l,c;this._logLevel<=p.LogLevelEnum.WARN&&this._log((c=(l=this._optionsService.options.logger)===null||l===void 0?void 0:l.warn.bind(this._optionsService.options.logger))!==null&&c!==void 0?c:console.warn,r,a)}error(r,...a){var l,c;this._logLevel<=p.LogLevelEnum.ERROR&&this._log((c=(l=this._optionsService.options.logger)===null||l===void 0?void 0:l.error.bind(this._optionsService.options.logger))!==null&&c!==void 0?c:console.error,r,a)}};s.LogService=b=u([f(0,p.IOptionsService)],b),s.setTraceLogger=function(r){y=r},s.traceCall=function(r,a,l){if(typeof l.value!="function")throw new Error("not supported");const c=l.value;l.value=function(...g){if(y.logLevel!==p.LogLevelEnum.TRACE)return c.apply(this,g);y.trace(`GlyphRenderer#${c.name}(${g.map((C=>JSON.stringify(C))).join(", ")})`);const _=c.apply(this,g);return y.trace(`GlyphRenderer#${c.name} return`,_),_}}},7302:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.OptionsService=s.DEFAULT_OPTIONS=void 0;const u=o(8460),f=o(844),d=o(6114);s.DEFAULT_OPTIONS={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"courier-new, courier, monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},rightClickSelectsWord:d.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const p=["normal","bold","100","200","300","400","500","600","700","800","900"];class m extends f.Disposable{constructor(b){super(),this._onOptionChange=this.register(new u.EventEmitter),this.onOptionChange=this._onOptionChange.event;const r=Object.assign({},s.DEFAULT_OPTIONS);for(const a in b)if(a in r)try{const l=b[a];r[a]=this._sanitizeAndValidateOption(a,l)}catch(l){console.error(l)}this.rawOptions=r,this.options=Object.assign({},r),this._setupOptions()}onSpecificOptionChange(b,r){return this.onOptionChange((a=>{a===b&&r(this.rawOptions[b])}))}onMultipleOptionChange(b,r){return this.onOptionChange((a=>{b.indexOf(a)!==-1&&r()}))}_setupOptions(){const b=a=>{if(!(a in s.DEFAULT_OPTIONS))throw new Error(`No option with key "${a}"`);return this.rawOptions[a]},r=(a,l)=>{if(!(a in s.DEFAULT_OPTIONS))throw new Error(`No option with key "${a}"`);l=this._sanitizeAndValidateOption(a,l),this.rawOptions[a]!==l&&(this.rawOptions[a]=l,this._onOptionChange.fire(a))};for(const a in this.rawOptions){const l={get:b.bind(this,a),set:r.bind(this,a)};Object.defineProperty(this.options,a,l)}}_sanitizeAndValidateOption(b,r){switch(b){case"cursorStyle":if(r||(r=s.DEFAULT_OPTIONS[b]),!(function(a){return a==="block"||a==="underline"||a==="bar"})(r))throw new Error(`"${r}" is not a valid value for ${b}`);break;case"wordSeparator":r||(r=s.DEFAULT_OPTIONS[b]);break;case"fontWeight":case"fontWeightBold":if(typeof r=="number"&&1<=r&&r<=1e3)break;r=p.includes(r)?r:s.DEFAULT_OPTIONS[b];break;case"cursorWidth":r=Math.floor(r);case"lineHeight":case"tabStopWidth":if(r<1)throw new Error(`${b} cannot be less than 1, value: ${r}`);break;case"minimumContrastRatio":r=Math.max(1,Math.min(21,Math.round(10*r)/10));break;case"scrollback":if((r=Math.min(r,4294967295))<0)throw new Error(`${b} cannot be less than 0, value: ${r}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(r<=0)throw new Error(`${b} cannot be less than or equal to 0, value: ${r}`);break;case"rows":case"cols":if(!r&&r!==0)throw new Error(`${b} must be numeric, value: ${r}`);break;case"windowsPty":r=r??{}}return r}}s.OptionsService=m},2660:function(w,s,o){var u=this&&this.__decorate||function(m,y,b,r){var a,l=arguments.length,c=l<3?y:r===null?r=Object.getOwnPropertyDescriptor(y,b):r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")c=Reflect.decorate(m,y,b,r);else for(var g=m.length-1;g>=0;g--)(a=m[g])&&(c=(l<3?a(c):l>3?a(y,b,c):a(y,b))||c);return l>3&&c&&Object.defineProperty(y,b,c),c},f=this&&this.__param||function(m,y){return function(b,r){y(b,r,m)}};Object.defineProperty(s,"__esModule",{value:!0}),s.OscLinkService=void 0;const d=o(2585);let p=s.OscLinkService=class{constructor(m){this._bufferService=m,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(m){const y=this._bufferService.buffer;if(m.id===void 0){const g=y.addMarker(y.ybase+y.y),_={data:m,id:this._nextId++,lines:[g]};return g.onDispose((()=>this._removeMarkerFromLink(_,g))),this._dataByLinkId.set(_.id,_),_.id}const b=m,r=this._getEntryIdKey(b),a=this._entriesWithId.get(r);if(a)return this.addLineToLink(a.id,y.ybase+y.y),a.id;const l=y.addMarker(y.ybase+y.y),c={id:this._nextId++,key:this._getEntryIdKey(b),data:b,lines:[l]};return l.onDispose((()=>this._removeMarkerFromLink(c,l))),this._entriesWithId.set(c.key,c),this._dataByLinkId.set(c.id,c),c.id}addLineToLink(m,y){const b=this._dataByLinkId.get(m);if(b&&b.lines.every((r=>r.line!==y))){const r=this._bufferService.buffer.addMarker(y);b.lines.push(r),r.onDispose((()=>this._removeMarkerFromLink(b,r)))}}getLinkData(m){var y;return(y=this._dataByLinkId.get(m))===null||y===void 0?void 0:y.data}_getEntryIdKey(m){return`${m.id};;${m.uri}`}_removeMarkerFromLink(m,y){const b=m.lines.indexOf(y);b!==-1&&(m.lines.splice(b,1),m.lines.length===0&&(m.data.id!==void 0&&this._entriesWithId.delete(m.key),this._dataByLinkId.delete(m.id)))}};s.OscLinkService=p=u([f(0,d.IBufferService)],p)},8343:(w,s)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.createDecorator=s.getServiceDependencies=s.serviceRegistry=void 0;const o="di$target",u="di$dependencies";s.serviceRegistry=new Map,s.getServiceDependencies=function(f){return f[u]||[]},s.createDecorator=function(f){if(s.serviceRegistry.has(f))return s.serviceRegistry.get(f);const d=function(p,m,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(b,r,a){r[o]===r?r[u].push({id:b,index:a}):(r[u]=[{id:b,index:a}],r[o]=r)})(d,p,y)};return d.toString=()=>f,s.serviceRegistry.set(f,d),d}},2585:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.IDecorationService=s.IUnicodeService=s.IOscLinkService=s.IOptionsService=s.ILogService=s.LogLevelEnum=s.IInstantiationService=s.ICharsetService=s.ICoreService=s.ICoreMouseService=s.IBufferService=void 0;const u=o(8343);var f;s.IBufferService=(0,u.createDecorator)("BufferService"),s.ICoreMouseService=(0,u.createDecorator)("CoreMouseService"),s.ICoreService=(0,u.createDecorator)("CoreService"),s.ICharsetService=(0,u.createDecorator)("CharsetService"),s.IInstantiationService=(0,u.createDecorator)("InstantiationService"),(function(d){d[d.TRACE=0]="TRACE",d[d.DEBUG=1]="DEBUG",d[d.INFO=2]="INFO",d[d.WARN=3]="WARN",d[d.ERROR=4]="ERROR",d[d.OFF=5]="OFF"})(f||(s.LogLevelEnum=f={})),s.ILogService=(0,u.createDecorator)("LogService"),s.IOptionsService=(0,u.createDecorator)("OptionsService"),s.IOscLinkService=(0,u.createDecorator)("OscLinkService"),s.IUnicodeService=(0,u.createDecorator)("UnicodeService"),s.IDecorationService=(0,u.createDecorator)("DecorationService")},1480:(w,s,o)=>{Object.defineProperty(s,"__esModule",{value:!0}),s.UnicodeService=void 0;const u=o(8460),f=o(225);s.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new u.EventEmitter,this.onChange=this._onChange.event;const d=new f.UnicodeV6;this.register(d),this._active=d.version,this._activeProvider=d}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(d){if(!this._providers[d])throw new Error(`unknown Unicode version "${d}"`);this._active=d,this._activeProvider=this._providers[d],this._onChange.fire(d)}register(d){this._providers[d.version]=d}wcwidth(d){return this._activeProvider.wcwidth(d)}getStringCellWidth(d){let p=0;const m=d.length;for(let y=0;y<m;++y){let b=d.charCodeAt(y);if(55296<=b&&b<=56319){if(++y>=m)return p+this.wcwidth(b);const r=d.charCodeAt(y);56320<=r&&r<=57343?b=1024*(b-55296)+r-56320+65536:p+=this.wcwidth(r)}p+=this.wcwidth(b)}return p}}}},h={};function S(w){var s=h[w];if(s!==void 0)return s.exports;var o=h[w]={exports:{}};return n[w].call(o.exports,o,o.exports,S),o.exports}var x={};return(()=>{var w=x;Object.defineProperty(w,"__esModule",{value:!0}),w.Terminal=void 0;const s=S(9042),o=S(3236),u=S(844),f=S(5741),d=S(8285),p=S(7975),m=S(7090),y=["cols","rows"];class b extends u.Disposable{constructor(a){super(),this._core=this.register(new o.Terminal(a)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const l=g=>this._core.options[g],c=(g,_)=>{this._checkReadonlyOptions(g),this._core.options[g]=_};for(const g in this._core.options){const _={get:l.bind(this,g),set:c.bind(this,g)};Object.defineProperty(this._publicOptions,g,_)}}_checkReadonlyOptions(a){if(y.includes(a))throw new Error(`Option "${a}" can only be set in the constructor`)}_checkProposedApi(){if(!this._core.optionsService.rawOptions.allowProposedApi)throw new Error("You must set the allowProposedApi option to true to use proposed API")}get onBell(){return this._core.onBell}get onBinary(){return this._core.onBinary}get onCursorMove(){return this._core.onCursorMove}get onData(){return this._core.onData}get onKey(){return this._core.onKey}get onLineFeed(){return this._core.onLineFeed}get onRender(){return this._core.onRender}get onResize(){return this._core.onResize}get onScroll(){return this._core.onScroll}get onSelectionChange(){return this._core.onSelectionChange}get onTitleChange(){return this._core.onTitleChange}get onWriteParsed(){return this._core.onWriteParsed}get element(){return this._core.element}get parser(){return this._parser||(this._parser=new p.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new m.UnicodeApi(this._core)}get textarea(){return this._core.textarea}get rows(){return this._core.rows}get cols(){return this._core.cols}get buffer(){return this._buffer||(this._buffer=this.register(new d.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const a=this._core.coreService.decPrivateModes;let l="none";switch(this._core.coreMouseService.activeProtocol){case"X10":l="x10";break;case"VT200":l="vt200";break;case"DRAG":l="drag";break;case"ANY":l="any"}return{applicationCursorKeysMode:a.applicationCursorKeys,applicationKeypadMode:a.applicationKeypad,bracketedPasteMode:a.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:l,originMode:a.origin,reverseWraparoundMode:a.reverseWraparound,sendFocusMode:a.sendFocus,wraparoundMode:a.wraparound}}get options(){return this._publicOptions}set options(a){for(const l in a)this._publicOptions[l]=a[l]}blur(){this._core.blur()}focus(){this._core.focus()}resize(a,l){this._verifyIntegers(a,l),this._core.resize(a,l)}open(a){this._core.open(a)}attachCustomKeyEventHandler(a){this._core.attachCustomKeyEventHandler(a)}registerLinkProvider(a){return this._core.registerLinkProvider(a)}registerCharacterJoiner(a){return this._checkProposedApi(),this._core.registerCharacterJoiner(a)}deregisterCharacterJoiner(a){this._checkProposedApi(),this._core.deregisterCharacterJoiner(a)}registerMarker(a=0){return this._verifyIntegers(a),this._core.registerMarker(a)}registerDecoration(a){var l,c,g;return this._checkProposedApi(),this._verifyPositiveIntegers((l=a.x)!==null&&l!==void 0?l:0,(c=a.width)!==null&&c!==void 0?c:0,(g=a.height)!==null&&g!==void 0?g:0),this._core.registerDecoration(a)}hasSelection(){return this._core.hasSelection()}select(a,l,c){this._verifyIntegers(a,l,c),this._core.select(a,l,c)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(a,l){this._verifyIntegers(a,l),this._core.selectLines(a,l)}dispose(){super.dispose()}scrollLines(a){this._verifyIntegers(a),this._core.scrollLines(a)}scrollPages(a){this._verifyIntegers(a),this._core.scrollPages(a)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(a){this._verifyIntegers(a),this._core.scrollToLine(a)}clear(){this._core.clear()}write(a,l){this._core.write(a,l)}writeln(a,l){this._core.write(a),this._core.write(`\r
16
+ `,l)}paste(a){this._core.paste(a)}refresh(a,l){this._verifyIntegers(a,l),this._core.refresh(a,l)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(a){this._addonManager.loadAddon(this,a)}static get strings(){return s}_verifyIntegers(...a){for(const l of a)if(l===1/0||isNaN(l)||l%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...a){for(const l of a)if(l&&(l===1/0||isNaN(l)||l%1!=0||l<0))throw new Error("This API only accepts positive integers")}}w.Terminal=b})(),x})()))})(rr)),rr.exports}var Fa=Ia();var Ha=2,Wa=1,za=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let i=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(i._renderService.clear(),this._terminal.resize(e.cols,e.rows))}proposeDimensions(){if(!this._terminal||!this._terminal.element||!this._terminal.element.parentElement)return;let e=this._terminal._core._renderService.dimensions;if(e.css.cell.width===0||e.css.cell.height===0)return;let i=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,n=window.getComputedStyle(this._terminal.element.parentElement),h=parseInt(n.getPropertyValue("height")),S=Math.max(0,parseInt(n.getPropertyValue("width"))),x=window.getComputedStyle(this._terminal.element),w={top:parseInt(x.getPropertyValue("padding-top")),bottom:parseInt(x.getPropertyValue("padding-bottom")),right:parseInt(x.getPropertyValue("padding-right")),left:parseInt(x.getPropertyValue("padding-left"))},s=w.top+w.bottom,o=w.right+w.left,u=h-s,f=S-o-i;return{cols:Math.max(Ha,Math.floor(f/e.css.cell.width)),rows:Math.max(Wa,Math.floor(u/e.css.cell.height))}}};function $a(e={}){const{cwd:i,cols:n,rows:h,onOutput:S,onExit:x}=e,[w,s]=A.useState(null),[o,u]=A.useState(()=>ot.isConnected()),[f,d]=A.useState(!1),[p,m]=A.useState(!1),[y,b]=A.useState(!1),r=A.useRef({onOutput:S,onExit:x});r.current={onOutput:S,onExit:x};const a=A.useRef(null);a.current=w,A.useEffect(()=>{if(!w)return;const C=ot.getSocket(),k=()=>{u(!0),d(!1),s(null),b(!0)},v=()=>{u(!1),d(!1)},E=P=>{P.terminalId===w&&r.current.onOutput?.(P.data)},R=P=>{P.terminalId===w&&(d(!1),r.current.onExit?.(P.exitCode),s(null))},O=P=>{P.terminalId===w&&d(!0)},L=P=>{P.terminalId===w&&d(!1)};return C.on("connect",k),C.on("disconnect",v),C.on(Be.TERMINAL_STDOUT,E),C.on(Be.TERMINAL_EXIT,R),C.on(Be.TERMINAL_SUBSCRIBED,O),C.on(Be.TERMINAL_UNSUBSCRIBED,L),u(C.connected),C.connected&&C.emit(Nt.SUBSCRIBE,{topic:"terminal",id:w},P=>{P.success&&d(!0)}),()=>{C.off("connect",k),C.off("disconnect",v),C.off(Be.TERMINAL_STDOUT,E),C.off(Be.TERMINAL_EXIT,R),C.off(Be.TERMINAL_SUBSCRIBED,O),C.off(Be.TERMINAL_UNSUBSCRIBED,L),C.emit(Nt.UNSUBSCRIBE,{topic:"terminal",id:w})}},[w]);const l=A.useCallback(async()=>{const C=ot.getSocket();if(!C.connected)return null;m(!0);try{const k=await ue.post("/terminals",{socketId:C.id,cwd:i,cols:n,rows:h});return s(k.terminalId),b(!1),k.terminalId}catch(k){return console.error("[useStandaloneTerminal] Failed to create terminal:",k),null}finally{m(!1)}},[i,n,h]),c=A.useCallback(async()=>{const C=a.current;if(C){try{await ue.delete(`/terminals/${C}`)}catch(k){console.error("[useStandaloneTerminal] Failed to destroy terminal:",k)}s(null),d(!1)}},[]),g=A.useCallback(C=>{const k=a.current;if(!k)return;ot.getSocket().emit(Nt.TERMINAL_INPUT,{terminalId:k,data:C})},[]),_=A.useCallback((C,k)=>{const v=a.current;if(!v)return;ot.getSocket().emit(Nt.TERMINAL_RESIZE,{terminalId:v,cols:C,rows:k})},[]);return A.useEffect(()=>()=>{const C=a.current;C&&ue.delete(`/terminals/${C}`).catch(()=>{})},[]),{terminalId:w,isConnected:o,isAttached:f,isCreating:p,needsRecreate:y,create:l,destroy:c,sendInput:g,resize:_}}function Ua({terminalRef:e,xtermRef:i,fitAddonRef:n,isVisible:h=!0,onResize:S}){const x=A.useRef(null),w=A.useRef(null),s=A.useRef(0),o=A.useCallback(()=>{x.current!=null&&(window.clearTimeout(x.current),x.current=null),w.current!=null&&(window.cancelAnimationFrame(w.current),w.current=null)},[]),u=A.useCallback(()=>{const p=n.current,m=i.current,y=e.current;if(!p||!m||!y||y.clientWidth<=0||y.clientHeight<=0)return!1;try{return p.fit(),m.cols>0&&m.rows>0&&S(m.cols,m.rows),!0}catch{return!1}},[n,S,e,i]),f=A.useCallback((p=6)=>{o();const m=s.current+1;s.current=m;let y=0;const b=()=>{s.current===m&&(w.current=window.requestAnimationFrame(()=>{if(w.current=null,s.current!==m)return;const r=u(),a=y<2;y<p&&(!r||a)&&(y+=1,x.current=window.setTimeout(b,50))}))};b()},[o,u]),d=A.useCallback(()=>{s.current+=1,o()},[o]);return A.useEffect(()=>d,[d]),A.useEffect(()=>{h&&f(8)},[h,f]),A.useEffect(()=>{const p=e.current;if(!p)return;if(typeof ResizeObserver>"u"){f(8);return}const m=new ResizeObserver(()=>{f(4)});return m.observe(p),p.parentElement&&m.observe(p.parentElement),f(8),()=>{m.disconnect()}},[f,e]),{fitNow:u,scheduleFit:f}}const qa={background:"#1e1e1e",foreground:"#d4d4d4",cursor:"#d4d4d4",selectionBackground:"#264f78",black:"#1e1e1e",red:"#f44747",green:"#6a9955",yellow:"#d7ba7d",blue:"#569cd6",magenta:"#c586c0",cyan:"#4ec9b0",white:"#d4d4d4",brightBlack:"#808080",brightRed:"#f44747",brightGreen:"#6a9955",brightYellow:"#d7ba7d",brightBlue:"#569cd6",brightMagenta:"#c586c0",brightCyan:"#4ec9b0",brightWhite:"#ffffff"},Ka=me.memo(function({cwd:i,isVisible:n=!0,onExit:h,onReady:S}){const x=A.useRef(null),w=A.useRef(null),s=A.useRef(null),o=A.useRef(!1),{terminalId:u,isAttached:f,needsRecreate:d,create:p,sendInput:m,resize:y}=$a({cwd:i,onOutput:A.useCallback(a=>{w.current?.write(a)},[]),onExit:A.useCallback(a=>{w.current?.writeln(`\r
17
+ \x1B[90m[Process exited with code ${a}]\x1B[0m`),h?.(a)},[h])}),{scheduleFit:b}=Ua({terminalRef:x,xtermRef:w,fitAddonRef:s,isVisible:n,onResize:y}),r=A.useCallback(a=>{w.current?.paste(a)},[]);return A.useEffect(()=>{n||w.current?.blur()},[n]),A.useEffect(()=>{if(!d)return;const a=w.current;a&&a.writeln(`\r
18
+ \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),p()},[d,p]),A.useLayoutEffect(()=>{if(!x.current)return;const a=new Fa.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:qa,scrollback:5e3,convertEol:!0}),l=new za;return a.loadAddon(l),a.open(x.current),w.current=a,s.current=l,b(8),()=>{a.dispose(),w.current=null,s.current=null}},[b]),A.useEffect(()=>{o.current||(o.current=!0,p())},[p]),A.useEffect(()=>{const a=w.current;if(!a||!f)return;const l=a.onData(c=>{m(c)});return()=>l.dispose()},[m,f]),A.useEffect(()=>{f&&(b(4),S?.({sendInput:m,paste:r}))},[f,S,r,b,m]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[!u&&t.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),t.jsx("div",{ref:x,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),Xa=me.memo(function({commands:i,onSelect:n}){const{t:h}=se(),[S,x]=A.useState(!1),w=A.useRef(null),s=A.useRef(null);return A.useEffect(()=>{if(!S)return;const o=u=>{w.current&&!w.current.contains(u.target)&&s.current&&!s.current.contains(u.target)&&x(!1)};return document.addEventListener("mousedown",o),()=>document.removeEventListener("mousedown",o)},[S]),i.length===0?null:t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),t.jsxs("div",{className:"relative",children:[t.jsxs("button",{ref:s,onClick:()=>x(!S),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${S?"bg-amber-500/20 text-amber-300":"bg-amber-500/10 text-amber-400/80 hover:bg-amber-500/20 hover:text-amber-300"}`,children:[t.jsx(Mn,{size:12}),t.jsx("span",{children:h("快捷命令")}),t.jsx(We,{size:10,className:`transition-transform ${S?"rotate-180":""}`})]}),S&&t.jsx("div",{ref:w,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:t.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:i.map((o,u)=>t.jsxs("button",{onClick:()=>{n(o.command),x(!1)},className:"w-full flex items-start gap-2.5 px-3 py-2 hover:bg-[#383838] transition-colors text-left group",children:[t.jsx(In,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:o.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:o.command})]})]},u))})})]})]})}),ni="\x1B",Ya="\x07",Va="œ";function Ga(e){const i=e.charCodeAt(0);return i>=64&&i<=126}function ss(e,i){let n=i;for(;n<e.length;){if(e[n]===Ya||e[n]===Va)return n+1;if(e[n]===ni&&e[n+1]==="\\")return n+2;n+=1}return n}function is(e,i){let n=i;for(;n<e.length&&!Ga(e[n]);)n+=1;return n<e.length?n+1:n}function Za(e){let i="";for(let n=0;n<e.length;){if(e[n]==="›"){n=is(e,n+1);continue}if(e[n]===""){n=ss(e,n+1);continue}if(e[n]!==ni){i+=e[n],n+=1;continue}const h=e[n+1];if(h==="["){n=is(e,n+2);continue}if(h==="]"||h==="P"||h==="X"||h==="^"||h==="_"){n=ss(e,n+2);continue}for(n+=1;n<e.length;){const S=e.charCodeAt(n);if(S<32||S>47)break;n+=1}n<e.length&&(n+=1)}return i}const Qa=200,Ja=1e3,el=512*1024;function tl(e){let i=e.reduce((h,S)=>h+S.data.length,0),n=0;for(;e.length-n>Ja||i>el&&e.length-n>1;)i-=e[n].data.length,n+=1;return{entries:n>0?e.slice(n):e,trimmed:n>0}}function rl(e,i){const n=!!e&&e.runtimeInstanceId!==i.runtimeInstanceId,h=n||i.reset,S=h?[]:e?.entries??[],x=new Set(S.map(o=>o.seq)),w=[...S,...i.entries.filter(o=>!x.has(o.seq))].sort((o,u)=>o.seq-u.seq),s=tl(w);return{...i,entries:s.entries,reset:i.reset||n||!h&&(e?.reset??!1),truncated:i.truncated||!h&&(e?.truncated??!1)||s.trimmed}}function Br(e,i=!0){return Le({queryKey:ge.workspaceServices.list(e),queryFn:async()=>(await ue.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:i&&!!e,refetchInterval:i&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function sl(e,i,n,h=!0){const S=dt(),x=ge.workspaceServices.logs(e,i);return Le({queryKey:x,queryFn:async()=>{const w=S.getQueryData(x),s=w?Math.max(0,w.nextSeq-1):0,o=w===void 0?n:w.runtimeInstanceId,u=new URLSearchParams({limit:String(Qa)});o!==null&&u.set("runtimeInstanceId",o),u.set("afterSeq",String(s));const f=await ue.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(i)}/logs?${u}`);return rl(w,f)},enabled:h&&!!e&&!!i,refetchInterval:w=>w.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const il=[];function sr(e){return JSON.stringify([e.command,...e.args])}function ns(e,i,n){if(!e)return n;const h=new Date(e);return Number.isNaN(h.getTime())?n:new Intl.DateTimeFormat(i,{dateStyle:"medium",timeStyle:"medium"}).format(h)}function nl(e){switch(e){case"RUNNING":return{label:"Running",dotClassName:"bg-emerald-400"};case"STARTING":return{label:"Starting",dotClassName:"bg-amber-400"};case"STOPPING":return{label:"Stopping",dotClassName:"bg-amber-400"};case"FAILED":return{label:"Failed",dotClassName:"bg-red-400"};case"EXITED":return{label:"Exited",dotClassName:"bg-neutral-400"};default:return{label:"Stopped",dotClassName:"bg-neutral-500"}}}function os({state:e}){const{t:i}=se(),n=nl(e);return t.jsxs("span",{className:"inline-flex shrink-0 items-center gap-1.5 text-[11px] text-neutral-300",children:[t.jsx("span",{className:Q("h-1.5 w-1.5 rounded-full",n.dotClassName),"aria-hidden":"true"}),i(n.label)]})}function ol({message:e,onRetry:i}){const{t:n}=se();return t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 px-4 text-xs text-red-300",role:"alert",children:[t.jsx(wt,{size:14,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{children:e}),t.jsx("button",{type:"button",onClick:i,className:"flex h-7 w-7 shrink-0 items-center justify-center rounded text-neutral-400 transition-colors hover:bg-[#333] hover:text-white focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",title:n("Retry"),"aria-label":n("Retry"),children:t.jsx(ht,{size:13})})]})}function al({workspaceId:e,enabled:i=!0}){const{locale:n,t:h}=se(),S=Br(e,i),x=S.data??il,[w,s]=A.useState(null),o=x.find(m=>m.name===w)??x[0]??null,u=sl(e,o?.name??"",o?.runtimeInstanceId??null,i&&!!o),f=A.useMemo(()=>Za(u.data?.entries.map(m=>m.data).join("")??""),[u.data?.entries]),d=A.useRef(null),p=A.useRef(!0);return A.useEffect(()=>{p.current=!0},[o?.id,o?.runtimeInstanceId]),A.useEffect(()=>{const m=d.current;m&&p.current&&(m.scrollTop=m.scrollHeight)},[f]),t.jsxs("div",{className:"flex h-full min-h-0 w-full min-w-0 flex-col bg-[#1e1e1e] text-neutral-200 md:flex-row",children:[t.jsxs("aside",{className:"flex max-h-[44%] min-h-32 shrink-0 flex-col border-b border-[#343434] bg-[#252526] md:max-h-none md:min-h-0 md:w-72 md:border-b-0 md:border-r",children:[t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between border-b border-[#343434] px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[t.jsx(vr,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":"true"}),t.jsx("h2",{className:"truncate text-xs font-medium",children:h("Background services")})]}),!S.isLoading&&!S.isError&&t.jsx("span",{className:"text-[11px] tabular-nums text-neutral-500",children:x.length})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-app-thin",children:S.isLoading?t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(he,{size:14,className:"animate-spin","aria-hidden":"true"}),h("Loading background services...")]}):S.isError?t.jsx(ol,{message:h("Failed to load background services."),onRetry:()=>{S.refetch()}}):x.length===0?t.jsxs("div",{className:"flex min-h-24 flex-col items-center justify-center gap-2 px-4 text-center text-xs text-neutral-500",children:[t.jsx(vr,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:h("No background services")})]}):x.map(m=>{const y=m.name===o?.name;return t.jsxs("button",{type:"button",onClick:()=>s(m.name),"aria-pressed":y,className:Q("block w-full border-b border-[#343434] px-3 py-2.5 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",y?"bg-[#1e1e1e]":"hover:bg-[#2d2d2d]"),children:[t.jsxs("span",{className:"flex min-w-0 items-center justify-between gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-100",children:m.name}),t.jsx(os,{state:m.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[10px] text-neutral-500",title:sr(m),children:sr(m)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(Lr,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:m.relativeCwd||"."})]}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(Ue,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:ns(m.startedAt,n,h("Not started"))})]})]},m.id)})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-[#1e1e1e]","aria-label":h("Background service logs"),children:o?t.jsxs(t.Fragment,{children:[t.jsxs("header",{className:"shrink-0 border-b border-[#343434] bg-[#252526]",children:[t.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-x-3 gap-y-1 px-3 pt-2",children:[t.jsx("span",{className:"min-w-0 truncate text-xs font-semibold text-neutral-100",children:o.name}),t.jsx(os,{state:o.runtimeState})]}),t.jsxs("div",{className:"max-h-32 overflow-y-auto overscroll-y-contain px-3 pb-2 scrollbar-app-thin focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-neutral-400",tabIndex:0,"aria-label":`${o.name} ${h("Details")}`,children:[t.jsxs("dl",{className:"mt-1.5 grid min-w-0 gap-x-4 gap-y-1 text-[10px] text-neutral-500 sm:grid-cols-2",children:[t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[h("Command"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:sr(o)})]}),t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[h("Working directory"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:o.relativeCwd||"."})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:col-span-2",children:[t.jsx(Ue,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsxs("dt",{className:"shrink-0",children:[h("Started"),":"]}),t.jsx("dd",{className:"truncate text-neutral-400",children:ns(o.startedAt,n,h("Not started"))})]})]}),o.lastError&&t.jsx("p",{className:"mt-1.5 break-words text-[10px] text-red-300",role:"alert",children:o.lastError})]})]}),(u.data?.truncated||u.data?.reset)&&t.jsx("div",{className:"shrink-0 border-b border-amber-400/20 bg-amber-400/10 px-3 py-1.5 text-[10px] text-amber-200",children:h("Earlier log output is unavailable.")}),u.isError&&t.jsxs("div",{className:"flex shrink-0 items-center gap-2 border-b border-red-400/20 bg-red-400/10 px-3 py-1.5 text-[10px] text-red-200",role:"alert",children:[t.jsx("span",{children:h("Failed to refresh service logs.")}),t.jsx("button",{type:"button",onClick:()=>{u.refetch()},className:"flex h-6 w-6 items-center justify-center rounded text-red-100 transition-colors hover:bg-red-300/15 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-red-200",title:h("Retry"),"aria-label":h("Retry"),children:t.jsx(ht,{size:11})})]}),t.jsx("div",{ref:d,onScroll:m=>{const y=m.currentTarget;p.current=y.scrollHeight-y.scrollTop-y.clientHeight<32},className:"min-h-0 flex-1 overflow-auto p-3 scrollbar-app-thin",role:"log","aria-live":"off",tabIndex:0,children:u.isLoading&&!u.data?t.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(he,{size:14,className:"animate-spin","aria-hidden":"true"}),h("Loading service logs...")]}):f?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-neutral-300",children:f}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-500",children:h("No logs yet")})})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-neutral-500",children:S.isLoading?h("Loading background services..."):h("Select a background service")})})]})}let ir=0;function as(){return ir+=1,{id:`shell-${ir}`,order:ir}}const ll=me.memo(function({cwd:i,isVisible:n=!0,workspaceId:h,quickCommands:S=[]}){const{t:x}=se(),[w,s]=A.useState(()=>[as()]),[o,u]=A.useState(()=>w[0].id),[f,d]=A.useState(()=>new Set),[p,m]=A.useState(!1),[y,b]=A.useState(!1),[r,a]=A.useState(""),[l,c]=A.useState(null),[g,_]=A.useState("terminals"),C=A.useRef(new Map),k=h?g:"terminals",v=A.useCallback(T=>{C.current.delete(T),d(B=>{if(!B.has(T))return B;const q=new Set(B);return q.delete(T),q})},[]),E=A.useCallback(()=>{const T=as();s(B=>[...B,T]),u(T.id)},[]),R=A.useCallback((T,B)=>{B.stopPropagation(),v(T),s(q=>{const K=q.filter($=>$.id!==T);return T===o&&K.length>0&&u(K[K.length-1].id),K})},[o,v]),O=A.useCallback(T=>{v(T),s(B=>{const q=B.filter(K=>K.id!==T);return T===o&&q.length>0&&u(q[q.length-1].id),q})},[o,v]),L=A.useCallback((T,B)=>{C.current.set(T,B),d(q=>{if(q.has(T))return q;const K=new Set(q);return K.add(T),K})},[]),P=A.useCallback(T=>{const B=C.current.get(o);B&&B.sendInput(T+"\r")},[o]),H=A.useCallback((T,B="")=>{c(T),a(B),b(!0)},[]),M=A.useCallback((T,B)=>{const q=C.current.get(T);return q?(q.paste(B),Se.success(x("Pasted into terminal")),!0):(Se.error(x("Terminal is not ready")),!1)},[x]),F=A.useCallback(async()=>{if(!C.current.has(o)){Se.error(x("Terminal is not ready"));return}const T=navigator.clipboard;if(!T?.readText){H(o);return}m(!0);try{const B=await T.readText();if(!B||B.includes(`
19
+ `)||B.includes("\r")){H(o,B);return}M(o,B)}catch{H(o)}finally{m(!1)}},[o,H,M,x]),U=A.useCallback(()=>{!r||!l||!M(l,r)||(b(!1),a(""),c(null))},[r,M,l]),N=A.useCallback(()=>{b(!1),a(""),c(null)},[]),D=f.has(o);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[h&&t.jsxs("div",{className:"flex h-10 shrink-0 items-center gap-1 border-b border-[#343434] bg-[#202020] px-2 select-none",children:[t.jsxs("button",{type:"button",onClick:()=>_("terminals"),"aria-pressed":k==="terminals",className:Q("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",k==="terminals"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(_t,{size:12,"aria-hidden":"true"}),x("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>_("services"),"aria-pressed":k==="services",className:Q("flex h-7 items-center gap-1.5 rounded px-2.5 text-[11px] font-medium transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-neutral-400",k==="services"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(vr,{size:12,"aria-hidden":"true"}),x("Background services")]})]}),t.jsxs("div",{"aria-hidden":k!=="terminals",className:Q("min-h-0 flex-1 flex-col",k==="terminals"?"flex":"hidden"),children:[t.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin flex-1 min-w-0",children:w.map(T=>t.jsxs("button",{onClick:()=>u(T.id),className:Q("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",T.id===o?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(_t,{size:11,className:"shrink-0"}),t.jsx("span",{children:x("Shell {count}",{count:T.order})}),w.length>1&&t.jsx("span",{onClick:B=>R(T.id,B),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Ve,{size:10})})]},T.id))}),w.length>0&&t.jsxs(t.Fragment,{children:[t.jsx("span",{className:"mx-0.5 block h-5 w-px shrink-0 bg-[#3a3a3a] md:hidden","aria-hidden":"true"}),t.jsx("button",{type:"button",onClick:F,disabled:!D||p,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-400 transition-colors hover:bg-[#333] hover:text-neutral-100 active:bg-[#3a3a3a] disabled:cursor-not-allowed disabled:opacity-40 md:hidden",title:x("Paste into terminal"),"aria-label":x("Paste into terminal"),children:p?t.jsx(he,{size:18,className:"animate-spin"}):t.jsx(io,{size:18})})]}),t.jsx("button",{type:"button",onClick:E,className:"flex h-11 w-11 shrink-0 items-center justify-center text-neutral-500 transition-colors hover:bg-[#333] hover:text-neutral-300 active:bg-[#3a3a3a] md:h-auto md:w-auto md:px-2 md:py-1.5",title:x("New Terminal"),"aria-label":x("New Terminal"),children:t.jsx(gt,{size:14})}),S.length>0&&t.jsx(Xa,{commands:S,onSelect:P})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:w.length===0?t.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(_t,{size:28}),t.jsx("span",{className:"text-xs",children:x("No terminals open")}),t.jsx("button",{onClick:E,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:x("New Terminal")})]})}):w.map(T=>t.jsx("div",{"aria-hidden":T.id!==o,className:Q("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",T.id===o?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(Ka,{cwd:i,isVisible:n&&k==="terminals"&&T.id===o,onExit:()=>O(T.id),onReady:B=>L(T.id,B)})},T.id))})]}),h&&k==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(al,{workspaceId:h,enabled:n})}),t.jsx(Ct,{isOpen:y,onClose:N,title:x("Paste into terminal"),className:"fixed inset-x-0 bottom-0 max-h-[70dvh] max-w-none rounded-b-none rounded-t-lg border-x-0 border-b-0 sm:relative sm:inset-auto sm:max-w-lg sm:rounded-lg sm:border",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{type:"button",onClick:N,className:"min-h-11 px-4 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900",children:x("Cancel")}),t.jsx("button",{type:"button",onClick:U,disabled:!r,className:"min-h-11 rounded-md bg-neutral-900 px-4 text-sm font-medium text-white transition-colors hover:bg-black disabled:cursor-not-allowed disabled:opacity-40",children:x("Paste")})]}),children:t.jsx(Tn,{autoFocus:!0,value:r,onChange:T=>a(T.target.value),placeholder:x("Paste terminal input here"),"aria-label":x("Terminal paste content"),className:"min-h-32 resize-none bg-white font-mono"})})]})});function ls(e,i){(i==null||i>e.length)&&(i=e.length);for(var n=0,h=Array(i);n<i;n++)h[n]=e[n];return h}function cl(e){if(Array.isArray(e))return e}function dl(e,i,n){return(i=vl(i))in e?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n,e}function hl(e,i){var n=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(n!=null){var h,S,x,w,s=[],o=!0,u=!1;try{if(x=(n=n.call(e)).next,i!==0)for(;!(o=(h=x.call(n)).done)&&(s.push(h.value),s.length!==i);o=!0);}catch(f){u=!0,S=f}finally{try{if(!o&&n.return!=null&&(w=n.return(),Object(w)!==w))return}finally{if(u)throw S}}return s}}function ul(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
20
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function cs(e,i){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(e);i&&(h=h.filter(function(S){return Object.getOwnPropertyDescriptor(e,S).enumerable})),n.push.apply(n,h)}return n}function ds(e){for(var i=1;i<arguments.length;i++){var n=arguments[i]!=null?arguments[i]:{};i%2?cs(Object(n),!0).forEach(function(h){dl(e,h,n[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):cs(Object(n)).forEach(function(h){Object.defineProperty(e,h,Object.getOwnPropertyDescriptor(n,h))})}return e}function fl(e,i){if(e==null)return{};var n,h,S=ml(e,i);if(Object.getOwnPropertySymbols){var x=Object.getOwnPropertySymbols(e);for(h=0;h<x.length;h++)n=x[h],i.indexOf(n)===-1&&{}.propertyIsEnumerable.call(e,n)&&(S[n]=e[n])}return S}function ml(e,i){if(e==null)return{};var n={};for(var h in e)if({}.hasOwnProperty.call(e,h)){if(i.indexOf(h)!==-1)continue;n[h]=e[h]}return n}function pl(e,i){return cl(e)||hl(e,i)||_l(e,i)||ul()}function gl(e,i){if(typeof e!="object"||!e)return e;var n=e[Symbol.toPrimitive];if(n!==void 0){var h=n.call(e,i);if(typeof h!="object")return h;throw new TypeError("@@toPrimitive must return a primitive value.")}return(i==="string"?String:Number)(e)}function vl(e){var i=gl(e,"string");return typeof i=="symbol"?i:i+""}function _l(e,i){if(e){if(typeof e=="string")return ls(e,i);var n={}.toString.call(e).slice(8,-1);return n==="Object"&&e.constructor&&(n=e.constructor.name),n==="Map"||n==="Set"?Array.from(e):n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ls(e,i):void 0}}function bl(e,i,n){return i in e?Object.defineProperty(e,i,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[i]=n,e}function hs(e,i){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var h=Object.getOwnPropertySymbols(e);i&&(h=h.filter(function(S){return Object.getOwnPropertyDescriptor(e,S).enumerable})),n.push.apply(n,h)}return n}function us(e){for(var i=1;i<arguments.length;i++){var n=arguments[i]!=null?arguments[i]:{};i%2?hs(Object(n),!0).forEach(function(h){bl(e,h,n[h])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):hs(Object(n)).forEach(function(h){Object.defineProperty(e,h,Object.getOwnPropertyDescriptor(n,h))})}return e}function xl(){for(var e=arguments.length,i=new Array(e),n=0;n<e;n++)i[n]=arguments[n];return function(h){return i.reduceRight(function(S,x){return x(S)},h)}}function vt(e){return function i(){for(var n=this,h=arguments.length,S=new Array(h),x=0;x<h;x++)S[x]=arguments[x];return S.length>=e.length?e.apply(this,S):function(){for(var w=arguments.length,s=new Array(w),o=0;o<w;o++)s[o]=arguments[o];return i.apply(n,[].concat(S,s))}}}function Wt(e){return{}.toString.call(e).includes("Object")}function Sl(e){return!Object.keys(e).length}function yt(e){return typeof e=="function"}function yl(e,i){return Object.prototype.hasOwnProperty.call(e,i)}function wl(e,i){return Wt(i)||qe("changeType"),Object.keys(i).some(function(n){return!yl(e,n)})&&qe("changeField"),i}function Cl(e){yt(e)||qe("selectorType")}function kl(e){yt(e)||Wt(e)||qe("handlerType"),Wt(e)&&Object.values(e).some(function(i){return!yt(i)})&&qe("handlersType")}function El(e){e||qe("initialIsRequired"),Wt(e)||qe("initialType"),Sl(e)&&qe("initialContent")}function jl(e,i){throw new Error(e[i]||e.default)}var Nl={initialIsRequired:"initial state is required",initialType:"initial state should be an object",initialContent:"initial state shouldn't be an empty object",handlerType:"handler should be an object or a function",handlersType:"all handlers should be a functions",selectorType:"selector should be a function",changeType:"provided value of changes should be an object",changeField:'it seams you want to change a field in the state which is not specified in the "initial" state',default:"an unknown error accured in `state-local` package"},qe=vt(jl)(Nl),Pt={changes:wl,selector:Cl,handler:kl,initial:El};function Rl(e){var i=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Pt.initial(e),Pt.handler(i);var n={current:e},h=vt(Pl)(n,i),S=vt(Ll)(n),x=vt(Pt.changes)(e),w=vt(Al)(n);function s(){var u=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return Pt.selector(u),u(n.current)}function o(u){xl(h,S,x,w)(u)}return[s,o]}function Al(e,i){return yt(i)?i(e.current):i}function Ll(e,i){return e.current=us(us({},e.current),i),i}function Pl(e,i,n){return yt(i)?i(e.current):Object.keys(n).forEach(function(h){var S;return(S=i[h])===null||S===void 0?void 0:S.call(i,e.current[h])}),n}var Tl={create:Rl},Ml={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Dl(e){return function i(){for(var n=this,h=arguments.length,S=new Array(h),x=0;x<h;x++)S[x]=arguments[x];return S.length>=e.length?e.apply(this,S):function(){for(var w=arguments.length,s=new Array(w),o=0;o<w;o++)s[o]=arguments[o];return i.apply(n,[].concat(S,s))}}}function Bl(e){return{}.toString.call(e).includes("Object")}function Ol(e){return e||fs("configIsRequired"),Bl(e)||fs("configType"),e.urls?(Il(),{paths:{vs:e.urls.monacoBase}}):e}function Il(){console.warn(oi.deprecation)}function Fl(e,i){throw new Error(e[i]||e.default)}var oi={configIsRequired:"the configuration object is required",configType:"the configuration object should be an object",default:"an unknown error accured in `@monaco-editor/loader` package",deprecation:`Deprecation warning!
21
+ You are using deprecated way of configuration.
22
+
23
+ Instead of using
24
+ monaco.config({ urls: { monacoBase: '...' } })
25
+ use
26
+ monaco.config({ paths: { vs: '...' } })
27
+
28
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
29
+ `},fs=Dl(Fl)(oi),Hl={config:Ol},Wl=function(){for(var i=arguments.length,n=new Array(i),h=0;h<i;h++)n[h]=arguments[h];return function(S){return n.reduceRight(function(x,w){return w(x)},S)}};function ai(e,i){return Object.keys(i).forEach(function(n){i[n]instanceof Object&&e[n]&&Object.assign(i[n],ai(e[n],i[n]))}),ds(ds({},e),i)}var zl={type:"cancelation",msg:"operation is manually canceled"};function nr(e){var i=!1,n=new Promise(function(h,S){e.then(function(x){return i?S(zl):h(x)}),e.catch(S)});return n.cancel=function(){return i=!0},n}var $l=["monaco"],Ul=Tl.create({config:Ml,isInitialized:!1,resolve:null,reject:null,monaco:null}),li=pl(Ul,2),kt=li[0],Xt=li[1];function ql(e){var i=Hl.config(e),n=i.monaco,h=fl(i,$l);Xt(function(S){return{config:ai(S.config,h),monaco:n}})}function Kl(){var e=kt(function(i){var n=i.monaco,h=i.isInitialized,S=i.resolve;return{monaco:n,isInitialized:h,resolve:S}});if(!e.isInitialized){if(Xt({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),nr(or);if(window.monaco&&window.monaco.editor)return ci(window.monaco),e.resolve(window.monaco),nr(or);Wl(Xl,Vl)(Gl)}return nr(or)}function Xl(e){return document.body.appendChild(e)}function Yl(e){var i=document.createElement("script");return e&&(i.src=e),i}function Vl(e){var i=kt(function(h){var S=h.config,x=h.reject;return{config:S,reject:x}}),n=Yl("".concat(i.config.paths.vs,"/loader.js"));return n.onload=function(){return e()},n.onerror=i.reject,n}function Gl(){var e=kt(function(n){var h=n.config,S=n.resolve,x=n.reject;return{config:h,resolve:S,reject:x}}),i=window.require;i.config(e.config),i(["vs/editor/editor.main"],function(n){var h=n.m||n;ci(h),e.resolve(h)},function(n){e.reject(n)})}function ci(e){kt().monaco||Xt({monaco:e})}function Zl(){return kt(function(e){var i=e.monaco;return i})}var or=new Promise(function(e,i){return Xt({resolve:e,reject:i})}),di={config:ql,init:Kl,__getMonacoInstance:Zl},Ql={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},ar=Ql,Jl={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},ec=Jl;function tc({children:e}){return me.createElement("div",{style:ec.container},e)}var rc=tc,sc=rc;function ic({width:e,height:i,isEditorReady:n,loading:h,_ref:S,className:x,wrapperProps:w}){return me.createElement("section",{style:{...ar.wrapper,width:e,height:i},...w},!n&&me.createElement(sc,null,h),me.createElement("div",{ref:S,style:{...ar.fullWidth,...!n&&ar.hide},className:x}))}var nc=ic,hi=A.memo(nc);function oc(e){A.useEffect(e,[])}var ui=oc;function ac(e,i,n=!0){let h=A.useRef(!0);A.useEffect(h.current||!n?()=>{h.current=!1}:e,i)}var Ee=ac;function bt(){}function at(e,i,n,h){return lc(e,h)||cc(e,i,n,h)}function lc(e,i){return e.editor.getModel(fi(e,i))}function cc(e,i,n,h){return e.editor.createModel(i,n,h?fi(e,h):void 0)}function fi(e,i){return e.Uri.parse(i)}function dc({original:e,modified:i,language:n,originalLanguage:h,modifiedLanguage:S,originalModelPath:x,modifiedModelPath:w,keepCurrentOriginalModel:s=!1,keepCurrentModifiedModel:o=!1,theme:u="light",loading:f="Loading...",options:d={},height:p="100%",width:m="100%",className:y,wrapperProps:b={},beforeMount:r=bt,onMount:a=bt}){let[l,c]=A.useState(!1),[g,_]=A.useState(!0),C=A.useRef(null),k=A.useRef(null),v=A.useRef(null),E=A.useRef(a),R=A.useRef(r),O=A.useRef(!1);ui(()=>{let M=di.init();return M.then(F=>(k.current=F)&&_(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>C.current?H():M.cancel()}),Ee(()=>{if(C.current&&k.current){let M=C.current.getOriginalEditor(),F=at(k.current,e||"",h||n||"text",x||"");F!==M.getModel()&&M.setModel(F)}},[x],l),Ee(()=>{if(C.current&&k.current){let M=C.current.getModifiedEditor(),F=at(k.current,i||"",S||n||"text",w||"");F!==M.getModel()&&M.setModel(F)}},[w],l),Ee(()=>{let M=C.current.getModifiedEditor();M.getOption(k.current.editor.EditorOption.readOnly)?M.setValue(i||""):i!==M.getValue()&&(M.executeEdits("",[{range:M.getModel().getFullModelRange(),text:i||"",forceMoveMarkers:!0}]),M.pushUndoStop())},[i],l),Ee(()=>{C.current?.getModel()?.original.setValue(e||"")},[e],l),Ee(()=>{let{original:M,modified:F}=C.current.getModel();k.current.editor.setModelLanguage(M,h||n||"text"),k.current.editor.setModelLanguage(F,S||n||"text")},[n,h,S],l),Ee(()=>{k.current?.editor.setTheme(u)},[u],l),Ee(()=>{C.current?.updateOptions(d)},[d],l);let L=A.useCallback(()=>{if(!k.current)return;R.current(k.current);let M=at(k.current,e||"",h||n||"text",x||""),F=at(k.current,i||"",S||n||"text",w||"");C.current?.setModel({original:M,modified:F})},[n,i,S,e,h,x,w]),P=A.useCallback(()=>{!O.current&&v.current&&(C.current=k.current.editor.createDiffEditor(v.current,{automaticLayout:!0,...d}),L(),k.current?.editor.setTheme(u),c(!0),O.current=!0)},[d,u,L]);A.useEffect(()=>{l&&E.current(C.current,k.current)},[l]),A.useEffect(()=>{!g&&!l&&P()},[g,l,P]);function H(){let M=C.current?.getModel();s||M?.original?.dispose(),o||M?.modified?.dispose(),C.current?.dispose()}return me.createElement(hi,{width:m,height:p,isEditorReady:l,loading:f,_ref:v,className:y,wrapperProps:b})}var hc=dc;A.memo(hc);function uc(e){let i=A.useRef();return A.useEffect(()=>{i.current=e},[e]),i.current}var fc=uc,Tt=new Map;function mc({defaultValue:e,defaultLanguage:i,defaultPath:n,value:h,language:S,path:x,theme:w="light",line:s,loading:o="Loading...",options:u={},overrideServices:f={},saveViewState:d=!0,keepCurrentModel:p=!1,width:m="100%",height:y="100%",className:b,wrapperProps:r={},beforeMount:a=bt,onMount:l=bt,onChange:c,onValidate:g=bt}){let[_,C]=A.useState(!1),[k,v]=A.useState(!0),E=A.useRef(null),R=A.useRef(null),O=A.useRef(null),L=A.useRef(l),P=A.useRef(a),H=A.useRef(),M=A.useRef(h),F=fc(x),U=A.useRef(!1),N=A.useRef(!1);ui(()=>{let B=di.init();return B.then(q=>(E.current=q)&&v(!1)).catch(q=>q?.type!=="cancelation"&&console.error("Monaco initialization: error:",q)),()=>R.current?T():B.cancel()}),Ee(()=>{let B=at(E.current,e||h||"",i||S||"",x||n||"");B!==R.current?.getModel()&&(d&&Tt.set(F,R.current?.saveViewState()),R.current?.setModel(B),d&&R.current?.restoreViewState(Tt.get(x)))},[x],_),Ee(()=>{R.current?.updateOptions(u)},[u],_),Ee(()=>{!R.current||h===void 0||(R.current.getOption(E.current.editor.EditorOption.readOnly)?R.current.setValue(h):h!==R.current.getValue()&&(N.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:h,forceMoveMarkers:!0}]),R.current.pushUndoStop(),N.current=!1))},[h],_),Ee(()=>{let B=R.current?.getModel();B&&S&&E.current?.editor.setModelLanguage(B,S)},[S],_),Ee(()=>{s!==void 0&&R.current?.revealLine(s)},[s],_),Ee(()=>{E.current?.editor.setTheme(w)},[w],_);let D=A.useCallback(()=>{if(!(!O.current||!E.current)&&!U.current){P.current(E.current);let B=x||n,q=at(E.current,h||e||"",i||S||"",B||"");R.current=E.current?.editor.create(O.current,{model:q,automaticLayout:!0,...u},f),d&&R.current.restoreViewState(Tt.get(B)),E.current.editor.setTheme(w),s!==void 0&&R.current.revealLine(s),C(!0),U.current=!0}},[e,i,n,h,S,x,u,f,d,w,s]);A.useEffect(()=>{_&&L.current(R.current,E.current)},[_]),A.useEffect(()=>{!k&&!_&&D()},[k,_,D]),M.current=h,A.useEffect(()=>{_&&c&&(H.current?.dispose(),H.current=R.current?.onDidChangeModelContent(B=>{N.current||c(R.current.getValue(),B)}))},[_,c]),A.useEffect(()=>{if(_){let B=E.current.editor.onDidChangeMarkers(q=>{let K=R.current.getModel()?.uri;if(K&&q.find($=>$.path===K.path)){let $=E.current.editor.getModelMarkers({resource:K});g?.($)}});return()=>{B?.dispose()}}return()=>{}},[_,g]);function T(){H.current?.dispose(),p?d&&Tt.set(x,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return me.createElement(hi,{width:m,height:y,isEditorReady:_,loading:o,_ref:O,className:b,wrapperProps:r})}var pc=mc,gc=A.memo(pc),vc=gc,Ne=function(e,i){return Number(e.toFixed(i))},_c=function(e,i){return typeof e=="number"?e:i},de=function(e,i,n){n&&typeof n=="function"&&n(e,i)},bc=function(e){return-Math.cos(e*Math.PI)/2+.5},xc=function(e){return e},Sc=function(e){return e*e},yc=function(e){return e*(2-e)},wc=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Cc=function(e){return e*e*e},kc=function(e){return--e*e*e+1},Ec=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},jc=function(e){return e*e*e*e},Nc=function(e){return 1- --e*e*e*e},Rc=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Ac=function(e){return e*e*e*e*e},Lc=function(e){return 1+--e*e*e*e*e},Pc=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},mi={easeOut:bc,linear:xc,easeInQuad:Sc,easeOutQuad:yc,easeInOutQuad:wc,easeInCubic:Cc,easeOutCubic:kc,easeInOutCubic:Ec,easeInQuart:jc,easeOutQuart:Nc,easeInOutQuart:Rc,easeInQuint:Ac,easeOutQuint:Lc,easeInOutQuint:Pc},pi=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Ae=function(e){e.mounted&&(pi(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function gi(e,i,n,h){if(e.mounted){var S=new Date().getTime(),x=1;Ae(e),e.animation=function(){if(!e.mounted)return pi(e.animation);var w=new Date().getTime()-S,s=w/n,o=mi[i],u=o(s);w>=n?(h(x),e.animation=null):e.animation&&(h(u),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Tc(e){var i=e.scale,n=e.positionX,h=e.positionY;return!(Number.isNaN(i)||Number.isNaN(n)||Number.isNaN(h))}function Ge(e,i,n,h){var S=Tc(i);if(!(!e.mounted||!S)){var x=e.setTransformState,w=e.transformState,s=w.scale,o=w.positionX,u=w.positionY,f=i.scale-s,d=i.positionX-o,p=i.positionY-u;n===0?x(i.scale,i.positionX,i.positionY):gi(e,h,n,function(m){var y=s+f*m,b=o+d*m,r=u+p*m;x(y,b,r)})}}function Mc(e,i,n){var h=e.offsetWidth,S=e.offsetHeight,x=i.offsetWidth,w=i.offsetHeight,s=x*n,o=w*n,u=h-s,f=S-o;return{wrapperWidth:h,wrapperHeight:S,newContentWidth:s,newDiffWidth:u,newContentHeight:o,newDiffHeight:f}}var Dc=function(e,i,n,h,S,x,w){var s=e>i?n*(w?1:.5):0,o=h>S?x*(w?1:.5):0,u=e-i-s,f=s,d=h-S-o,p=o;return{minPositionX:u,maxPositionX:f,minPositionY:d,maxPositionY:p}},Or=function(e,i){var n=e.wrapperComponent,h=e.contentComponent,S=e.setup.centerZoomedOut;if(!n||!h)throw new Error("Components are not mounted");var x=Mc(n,h,i),w=x.wrapperWidth,s=x.wrapperHeight,o=x.newContentWidth,u=x.newDiffWidth,f=x.newContentHeight,d=x.newDiffHeight,p=Dc(w,o,u,s,f,d,!!S);return p},wr=function(e,i,n,h){return h?e<i?Ne(i,2):e>n?Ne(n,2):Ne(e,2):Ne(e,2)},rt=function(e,i){var n=Or(e,i);return e.bounds=n,n};function Et(e,i,n,h,S,x,w){var s=n.minPositionX,o=n.minPositionY,u=n.maxPositionX,f=n.maxPositionY,d=0,p=0;w&&(d=S,p=x);var m=wr(e,s-d,u+d,h),y=wr(i,o-p,f+p,h);return{x:m,y}}function Yt(e,i,n,h,S,x){var w=e.transformState,s=w.scale,o=w.positionX,u=w.positionY,f=h-s;if(typeof i!="number"||typeof n!="number")return console.error("Mouse X and Y position were not provided!"),{x:o,y:u};var d=o-i*f,p=u-n*f,m=Et(d,p,S,x,0,0,null);return m}function jt(e,i,n,h,S){var x=S?h:0,w=i-x;return!Number.isNaN(n)&&e>=n?n:!Number.isNaN(i)&&e<=w?w:e}var ms=function(e,i){var n=e.setup.panning.excluded,h=e.isInitialized,S=e.wrapperComponent,x=i.target,w="shadowRoot"in x&&"composedPath"in i,s=w?i.composedPath().some(function(f){return f instanceof Element?S?.contains(f):!1}):S?.contains(x),o=h&&x&&s;if(!o)return!1;var u=Vt(x,n);return!u},ps=function(e){var i=e.isInitialized,n=e.isPanning,h=e.setup,S=h.panning.disabled,x=i&&n&&!S;return!!x},Bc=function(e,i){var n=e.transformState,h=n.positionX,S=n.positionY;e.isPanning=!0;var x=i.clientX,w=i.clientY;e.startCoords={x:x-h,y:w-S}},Oc=function(e,i){var n=i.touches,h=e.transformState,S=h.positionX,x=h.positionY;e.isPanning=!0;var w=n.length===1;if(w){var s=n[0].clientX,o=n[0].clientY;e.startCoords={x:s-S,y:o-x}}};function Ic(e){var i=e.transformState,n=i.positionX,h=i.positionY,S=i.scale,x=e.setup,w=x.disabled,s=x.limitToBounds,o=x.centerZoomedOut,u=e.wrapperComponent;if(!(w||!u||!e.bounds)){var f=e.bounds,d=f.maxPositionX,p=f.minPositionX,m=f.maxPositionY,y=f.minPositionY,b=n>d||n<p,r=h>m||h<y,a=n>d?u.offsetWidth:e.setup.minPositionX||0,l=h>m?u.offsetHeight:e.setup.minPositionY||0,c=Yt(e,a,l,S,e.bounds,s||o),g=c.x,_=c.y;return{scale:S,positionX:b?g:n,positionY:r?_:h}}}function vi(e,i,n,h,S){var x=e.setup.limitToBounds,w=e.wrapperComponent,s=e.bounds,o=e.transformState,u=o.scale,f=o.positionX,d=o.positionY;if(!(w===null||s===null||i===f&&n===d)){var p=Et(i,n,s,x,h,S,w),m=p.x,y=p.y;e.setTransformState(u,m,y)}}var Fc=function(e,i,n){var h=e.startCoords,S=e.transformState,x=e.setup.panning,w=x.lockAxisX,s=x.lockAxisY,o=S.positionX,u=S.positionY;if(!h)return{x:o,y:u};var f=i-h.x,d=n-h.y,p=w?o:f,m=s?u:d;return{x:p,y:m}},Ye=function(e,i){var n=e.setup,h=e.transformState,S=h.scale,x=n.minScale,w=n.disablePadding;return i>0&&S>=x&&!w?i:0},Hc=function(e){var i=e.mounted,n=e.setup,h=n.disabled,S=n.velocityAnimation,x=e.transformState.scale,w=S.disabled,s=!w||x>1||!h||i;return!!s},Wc=function(e){var i=e.mounted,n=e.velocity,h=e.bounds,S=e.setup,x=S.disabled,w=S.velocityAnimation,s=e.transformState.scale,o=w.disabled,u=!o||s>1||!x||i;return!(!u||!n||!h)};function zc(e,i){var n=e.setup.velocityAnimation,h=n.equalToMove,S=n.animationTime,x=n.sensitivity;return h?S*i*x:S}function gs(e,i,n,h,S,x,w,s,o,u){if(S){if(i>w&&n>w){var f=w+(e-w)*u;return f>o?o:f<w?w:f}if(i<x&&n<x){var f=x+(e-x)*u;return f<s?s:f>x?x:f}}return h?i:wr(e,x,w,S)}function $c(e,i){var n=1;return i?Math.min(n,e.offsetWidth/window.innerWidth):n}function Uc(e,i){var n=Hc(e);if(n){var h=e.lastMousePosition,S=e.velocityTime,x=e.setup,w=e.wrapperComponent,s=x.velocityAnimation.equalToMove,o=Date.now();if(h&&S&&w){var u=$c(w,s),f=i.x-h.x,d=i.y-h.y,p=f/u,m=d/u,y=o-S,b=f*f+d*d,r=Math.sqrt(b)/y;e.velocity={velocityX:p,velocityY:m,total:r}}e.lastMousePosition=i,e.velocityTime=o}}function qc(e){var i=e.velocity,n=e.bounds,h=e.setup,S=e.wrapperComponent,x=Wc(e);if(!(!x||!i||!n||!S)){var w=i.velocityX,s=i.velocityY,o=i.total,u=n.maxPositionX,f=n.minPositionX,d=n.maxPositionY,p=n.minPositionY,m=h.limitToBounds,y=h.alignmentAnimation,b=h.zoomAnimation,r=h.panning,a=r.lockAxisY,l=r.lockAxisX,c=b.animationType,g=y.sizeX,_=y.sizeY,C=y.velocityAlignmentTime,k=C,v=zc(e,o),E=Math.max(v,k),R=Ye(e,g),O=Ye(e,_),L=R*S.offsetWidth/100,P=O*S.offsetHeight/100,H=u+L,M=f-L,F=d+P,U=p-P,N=e.transformState,D=new Date().getTime();gi(e,c,E,function(T){var B=e.transformState,q=B.scale,K=B.positionX,$=B.positionY,W=new Date().getTime()-D,z=W/k,j=mi[y.animationType],I=1-j(Math.min(1,z)),X=1-T,Y=K+w*X,Z=$+s*X,G=gs(Y,N.positionX,K,l,m,f,u,M,H,I),te=gs(Z,N.positionY,$,a,m,p,d,U,F,I);(K!==Y||$!==Z)&&e.setTransformState(q,G,te)})}}function vs(e,i){var n=e.transformState.scale;Ae(e),rt(e,n),window.TouchEvent!==void 0&&i instanceof TouchEvent?Oc(e,i):Bc(e,i)}function Ir(e,i){var n=e.transformState.scale,h=e.setup,S=h.minScale,x=h.alignmentAnimation,w=x.disabled,s=x.sizeX,o=x.sizeY,u=x.animationTime,f=x.animationType,d=w||n<S||!s&&!o;if(!d){var p=Ic(e);p&&Ge(e,p,i??u,f)}}function _s(e,i,n){var h=e.startCoords,S=e.setup,x=S.alignmentAnimation,w=x.sizeX,s=x.sizeY;if(h){var o=Fc(e,i,n),u=o.x,f=o.y,d=Ye(e,w),p=Ye(e,s);Uc(e,{x:u,y:f}),vi(e,u,f,d,p)}}function Kc(e){if(e.isPanning){var i=e.setup.panning.velocityDisabled,n=e.velocity,h=e.wrapperComponent,S=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var x=h?.getBoundingClientRect(),w=S?.getBoundingClientRect(),s=x?.width||0,o=x?.height||0,u=w?.width||0,f=w?.height||0,d=s<u||o<f,p=!i&&n&&n?.total>.1&&d;p?qc(e):Ir(e)}}function Fr(e,i,n,h){var S=e.setup,x=S.minScale,w=S.maxScale,s=S.limitToBounds,o=jt(Ne(i,2),x,w,0,!1),u=rt(e,o),f=Yt(e,n,h,o,u,s),d=f.x,p=f.y;return{scale:o,positionX:d,positionY:p}}function _i(e,i,n){var h=e.transformState.scale,S=e.wrapperComponent,x=e.setup,w=x.minScale,s=x.limitToBounds,o=x.zoomAnimation,u=o.disabled,f=o.animationTime,d=o.animationType,p=u||h>=w;if((h>=1||s)&&Ir(e),!(p||!S||!e.mounted)){var m=i||S.offsetWidth/2,y=n||S.offsetHeight/2,b=Fr(e,w,m,y);b&&Ge(e,b,f,d)}}var Ke=function(){return Ke=Object.assign||function(i){for(var n,h=1,S=arguments.length;h<S;h++){n=arguments[h];for(var x in n)Object.prototype.hasOwnProperty.call(n,x)&&(i[x]=n[x])}return i},Ke.apply(this,arguments)};function bs(e,i,n){for(var h=0,S=i.length,x;h<S;h++)(x||!(h in i))&&(x||(x=Array.prototype.slice.call(i,0,h)),x[h]=i[h]);return e.concat(x||Array.prototype.slice.call(i))}var Mt={scale:1,positionX:0,positionY:0},pt={disabled:!1,minPositionX:null,maxPositionX:null,minPositionY:null,maxPositionY:null,minScale:1,maxScale:8,limitToBounds:!0,centerZoomedOut:!1,centerOnInit:!1,disablePadding:!1,smooth:!0,wheel:{step:.2,disabled:!1,smoothStep:.001,wheelDisabled:!1,touchPadDisabled:!1,activationKeys:[],excluded:[]},panning:{disabled:!1,velocityDisabled:!1,lockAxisX:!1,lockAxisY:!1,allowLeftClickPan:!0,allowMiddleClickPan:!0,allowRightClickPan:!0,wheelPanning:!1,activationKeys:[],excluded:[]},pinch:{step:5,disabled:!1,excluded:[]},doubleClick:{disabled:!1,step:.7,mode:"zoomIn",animationType:"easeOut",animationTime:200,excluded:[]},zoomAnimation:{disabled:!1,size:.4,animationTime:200,animationType:"easeOut"},alignmentAnimation:{disabled:!1,sizeX:100,sizeY:100,animationTime:200,velocityAlignmentTime:400,animationType:"easeOut"},velocityAnimation:{disabled:!1,sensitivity:1,animationTime:400,animationType:"easeOut",equalToMove:!0}},Cr={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},bi=function(e){var i,n,h,S;return{previousScale:(i=e.initialScale)!==null&&i!==void 0?i:Mt.scale,scale:(n=e.initialScale)!==null&&n!==void 0?n:Mt.scale,positionX:(h=e.initialPositionX)!==null&&h!==void 0?h:Mt.positionX,positionY:(S=e.initialPositionY)!==null&&S!==void 0?S:Mt.positionY}},xs=function(e){var i=Ke({},pt);return Object.keys(e).forEach(function(n){var h=typeof e[n]<"u",S=typeof pt[n]<"u";if(S&&h){var x=Object.prototype.toString.call(pt[n]),w=x==="[object Object]",s=x==="[object Array]";w?i[n]=Ke(Ke({},pt[n]),e[n]):s?i[n]=bs(bs([],pt[n],!0),e[n]):i[n]=e[n]}}),i},xi=function(e,i,n){var h=e.transformState.scale,S=e.wrapperComponent,x=e.setup,w=x.maxScale,s=x.minScale,o=x.zoomAnimation,u=x.smooth,f=o.size;if(!S)throw new Error("Wrapper is not mounted");var d=u?h*Math.exp(i*n):h+i*n,p=jt(Ne(d,3),s,w,f,!1);return p};function Si(e,i,n,h,S){var x=e.wrapperComponent,w=e.transformState,s=w.scale,o=w.positionX,u=w.positionY;if(!x)return console.error("No WrapperComponent found");var f=x.offsetWidth,d=x.offsetHeight,p=(f/2-o)/s,m=(d/2-u)/s,y=xi(e,i,n),b=Fr(e,y,p,m);if(!b)return console.error("Error during zoom event. New transformation state was not calculated.");Ge(e,b,h,S)}function yi(e,i,n,h){var S=e.setup,x=e.wrapperComponent,w=S.limitToBounds,s=bi(e.props),o=e.transformState,u=o.scale,f=o.positionX,d=o.positionY;if(x){var p=Or(e,s.scale),m=Et(s.positionX,s.positionY,p,w,0,0,x),y={scale:s.scale,positionX:m.x,positionY:m.y};u===s.scale&&f===s.positionX&&d===s.positionY||(h?.(),Ge(e,y,i,n))}}function Xc(e,i,n,h){var S=e.getBoundingClientRect(),x=i.getBoundingClientRect(),w=n.getBoundingClientRect(),s=x.x*h.scale,o=x.y*h.scale;return{x:(S.x-w.x+s)/h.scale,y:(S.y-w.y+o)/h.scale}}function Yc(e,i,n){var h=e.wrapperComponent,S=e.contentComponent,x=e.transformState,w=e.setup,s=w.limitToBounds,o=w.minScale,u=w.maxScale;if(!h||!S)return x;var f=h.getBoundingClientRect(),d=i.getBoundingClientRect(),p=Xc(i,h,S,x),m=p.x,y=p.y,b=d.width/x.scale,r=d.height/x.scale,a=h.offsetWidth/b,l=h.offsetHeight/r,c=jt(n||Math.min(a,l),o,u,0,!1),g=(f.width-b*c)/2,_=(f.height-r*c)/2,C=(f.left-m)*c+g,k=(f.top-y)*c+_,v=Or(e,c),E=Et(C,k,v,s,0,0,h),R=E.x,O=E.y;return{positionX:R,positionY:O,scale:c}}var Vc=function(e){return function(i,n,h){i===void 0&&(i=.5),n===void 0&&(n=300),h===void 0&&(h="easeOut"),Si(e,1,i,n,h)}},Gc=function(e){return function(i,n,h){i===void 0&&(i=.5),n===void 0&&(n=300),h===void 0&&(h="easeOut"),Si(e,-1,i,n,h)}},Zc=function(e){return function(i,n,h,S,x){S===void 0&&(S=300),x===void 0&&(x="easeOut");var w=e.transformState,s=w.positionX,o=w.positionY,u=w.scale,f=e.wrapperComponent,d=e.contentComponent,p=e.setup.disabled;if(!(p||!f||!d)){var m={positionX:Number.isNaN(i)?s:i,positionY:Number.isNaN(n)?o:n,scale:Number.isNaN(h)?u:h};Ge(e,m,S,x)}}},Qc=function(e){return function(i,n){i===void 0&&(i=200),n===void 0&&(n="easeOut"),yi(e,i,n)}},Jc=function(e){return function(i,n,h){n===void 0&&(n=200),h===void 0&&(h="easeOut");var S=e.transformState,x=e.wrapperComponent,w=e.contentComponent;if(x&&w){var s=wi(i||S.scale,x,w);Ge(e,s,n,h)}}},ed=function(e){return function(i,n,h,S){h===void 0&&(h=600),S===void 0&&(S="easeOut"),Ae(e);var x=e.wrapperComponent,w=typeof i=="string"?document.getElementById(i):i;if(x&&w&&x.contains(w)){var s=Yc(e,w,n);Ge(e,s,h,S)}}},zt=function(e){return{instance:e,zoomIn:Vc(e),zoomOut:Gc(e),setTransform:Zc(e),resetTransform:Qc(e),centerView:Jc(e),zoomToElement:ed(e)}},kr=function(e){return{instance:e,state:e.transformState}},oe=function(e){var i={};return Object.assign(i,kr(e)),Object.assign(i,zt(e)),i},lr=!1;function cr(){try{var e={get passive(){return lr=!0,!1}};return e}catch{return lr=!1,lr}}var Dt=".".concat(Cr.wrapperClass),Vt=function(e,i){return i.some(function(n){return e.matches("".concat(Dt," ").concat(n,", ").concat(Dt," .").concat(n,", ").concat(Dt," ").concat(n," *, ").concat(Dt," .").concat(n," *"))})},Er=function(e){e&&clearTimeout(e)},td=function(e,i,n){return"translate(".concat(e,"px, ").concat(i,"px) scale(").concat(n,")")},wi=function(e,i,n){var h=n.offsetWidth*e,S=n.offsetHeight*e,x=(i.offsetWidth-h)/2,w=(i.offsetHeight-S)/2;return{scale:e,positionX:x,positionY:w}};function rd(e){return function(i){e.forEach(function(n){typeof n=="function"?n(i):n!=null&&(n.current=i)})}}var sd=function(e,i){var n=e.setup.wheel,h=n.disabled,S=n.wheelDisabled,x=n.touchPadDisabled,w=n.excluded,s=e.isInitialized,o=e.isPanning,u=i.target,f=s&&!o&&!h&&u;if(!f||S&&!i.ctrlKey||x&&i.ctrlKey)return!1;var d=Vt(u,w);return!d},id=function(e){return e?e.deltaY<0?1:-1:0};function nd(e,i){var n=id(e),h=_c(i,n);return h}function Ci(e,i,n){var h=i.getBoundingClientRect(),S=0,x=0;if("clientX"in e)S=(e.clientX-h.left)/n,x=(e.clientY-h.top)/n;else{var w=e.touches[0];S=(w.clientX-h.left)/n,x=(w.clientY-h.top)/n}return(Number.isNaN(S)||Number.isNaN(x))&&console.error("No mouse or touch offset found"),{x:S,y:x}}var od=function(e,i,n,h,S){var x=e.transformState.scale,w=e.wrapperComponent,s=e.setup,o=s.maxScale,u=s.minScale,f=s.zoomAnimation,d=s.disablePadding,p=f.size,m=f.disabled;if(!w)throw new Error("Wrapper is not mounted");var y=x+i*n,b=h?!1:!m,r=jt(Ne(y,3),u,o,p,b&&!d);return r},ad=function(e,i){var n=e.previousWheelEvent,h=e.transformState.scale,S=e.setup,x=S.maxScale,w=S.minScale;return n?h<x||h>w||Math.sign(n.deltaY)!==Math.sign(i.deltaY)||n.deltaY>0&&n.deltaY<i.deltaY||n.deltaY<0&&n.deltaY>i.deltaY||Math.sign(n.deltaY)!==Math.sign(i.deltaY):!1},ld=function(e,i){var n=e.setup.pinch,h=n.disabled,S=n.excluded,x=e.isInitialized,w=i.target,s=x&&!h&&w;if(!s)return!1;var o=Vt(w,S);return!o},cd=function(e){var i=e.setup.pinch.disabled,n=e.isInitialized,h=e.pinchStartDistance,S=n&&!i&&h;return!!S},dd=function(e,i,n){var h=n.getBoundingClientRect(),S=e.touches,x=Ne(S[0].clientX-h.left,5),w=Ne(S[0].clientY-h.top,5),s=Ne(S[1].clientX-h.left,5),o=Ne(S[1].clientY-h.top,5);return{x:(x+s)/2/i,y:(w+o)/2/i}},ki=function(e){return Math.sqrt(Math.pow(e.touches[0].pageX-e.touches[1].pageX,2)+Math.pow(e.touches[0].pageY-e.touches[1].pageY,2))},hd=function(e,i){var n=e.pinchStartScale,h=e.pinchStartDistance,S=e.setup,x=S.maxScale,w=S.minScale,s=S.zoomAnimation,o=S.disablePadding,u=s.size,f=s.disabled;if(!n||h===null||!i)throw new Error("Pinch touches distance was not provided");if(i<0)return e.transformState.scale;var d=i/h,p=d*n;return jt(Ne(p,2),w,x,u,!f&&!o)},ud=160,fd=100,md=function(e,i){var n=e.props,h=n.onWheelStart,S=n.onZoomStart;e.wheelStopEventTimer||(Ae(e),de(oe(e),i,h),de(oe(e),i,S))},pd=function(e,i){var n=e.props,h=n.onWheel,S=n.onZoom,x=e.contentComponent,w=e.setup,s=e.transformState,o=s.scale,u=w.limitToBounds,f=w.centerZoomedOut,d=w.zoomAnimation,p=w.wheel,m=w.disablePadding,y=w.smooth,b=d.size,r=d.disabled,a=p.step,l=p.smoothStep;if(!x)throw new Error("Component not mounted");i.preventDefault(),i.stopPropagation();var c=nd(i,null),g=y?l*Math.abs(i.deltaY):a,_=od(e,c,g,!i.ctrlKey);if(o!==_){var C=rt(e,_),k=Ci(i,x,o),v=r||b===0||f||m,E=u&&v,R=Yt(e,k.x,k.y,_,C,E),O=R.x,L=R.y;e.previousWheelEvent=i,e.setTransformState(_,O,L),de(oe(e),i,h),de(oe(e),i,S)}},gd=function(e,i){var n=e.props,h=n.onWheelStop,S=n.onZoomStop;Er(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(_i(e,i.x,i.y),e.wheelAnimationTimer=null)},fd);var x=ad(e,i);x&&(Er(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,de(oe(e),i,h),de(oe(e),i,S))},ud))},Ei=function(e){for(var i=0,n=0,h=0;h<2;h+=1)i+=e.touches[h].clientX,n+=e.touches[h].clientY;var S=i/2,x=n/2;return{x:S,y:x}},vd=function(e,i){var n=ki(i);e.pinchStartDistance=n,e.lastDistance=n,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var h=Ei(i);e.pinchLastCenterX=h.x,e.pinchLastCenterY=h.y,Ae(e)},_d=function(e,i){var n=e.contentComponent,h=e.pinchStartDistance,S=e.wrapperComponent,x=e.transformState.scale,w=e.setup,s=w.limitToBounds,o=w.centerZoomedOut,u=w.zoomAnimation,f=w.alignmentAnimation,d=u.disabled,p=u.size;if(!(h===null||!n)){var m=dd(i,x,n);if(!(!Number.isFinite(m.x)||!Number.isFinite(m.y))){var y=ki(i),b=hd(e,y),r=Ei(i),a=r.x-(e.pinchLastCenterX||0),l=r.y-(e.pinchLastCenterY||0);if(!(b===x&&a===0&&l===0)){e.pinchLastCenterX=r.x,e.pinchLastCenterY=r.y;var c=rt(e,b),g=d||p===0||o,_=s&&g,C=Yt(e,m.x,m.y,b,c,_),k=C.x,v=C.y;e.pinchMidpoint=m,e.lastDistance=y;var E=f.sizeX,R=f.sizeY,O=Ye(e,E),L=Ye(e,R),P=k+a,H=v+l,M=Et(P,H,c,s,O,L,S),F=M.x,U=M.y;e.setTransformState(b,F,U)}}}},bd=function(e){var i=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,_i(e,i?.x,i?.y)},ji=function(e,i){var n=e.props.onZoomStop,h=e.setup.doubleClick.animationTime;Er(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,de(oe(e),i,n)},h)},xd=function(e,i){var n=e.props,h=n.onZoomStart,S=n.onZoom,x=e.setup.doubleClick,w=x.animationTime,s=x.animationType;de(oe(e),i,h),yi(e,w,s,function(){return de(oe(e),i,S)}),ji(e,i)};function Sd(e,i){return e==="toggle"?i===1?1:-1:e==="zoomOut"?-1:1}function yd(e,i){var n=e.setup,h=e.doubleClickStopEventTimer,S=e.transformState,x=e.contentComponent,w=S.scale,s=e.props,o=s.onZoomStart,u=s.onZoom,f=n.doubleClick,d=f.disabled,p=f.mode,m=f.step,y=f.animationTime,b=f.animationType;if(!d&&!h){if(p==="reset")return xd(e,i);if(!x)return console.error("No ContentComponent found");var r=Sd(p,e.transformState.scale),a=xi(e,r,m);if(w!==a){de(oe(e),i,o);var l=Ci(i,x,w),c=Fr(e,a,l.x,l.y);if(!c)return console.error("Error during zoom event. New transformation state was not calculated.");de(oe(e),i,u),Ge(e,c,y,b),ji(e,i)}}}var wd=function(e,i){var n=e.isInitialized,h=e.setup,S=e.wrapperComponent,x=h.doubleClick,w=x.disabled,s=x.excluded,o=i.target,u=S?.contains(o),f=n&&o&&u&&!w;if(!f)return!1;var d=Vt(o,s);return!d},Cd=(function(){function e(i){var n=this;this.mounted=!0,this.pinchLastCenterX=null,this.pinchLastCenterY=null,this.onChangeCallbacks=new Set,this.onInitCallbacks=new Set,this.wrapperComponent=null,this.contentComponent=null,this.isInitialized=!1,this.bounds=null,this.previousWheelEvent=null,this.wheelStopEventTimer=null,this.wheelAnimationTimer=null,this.isPanning=!1,this.isWheelPanning=!1,this.startCoords=null,this.lastTouch=null,this.distance=null,this.lastDistance=null,this.pinchStartDistance=null,this.pinchStartScale=null,this.pinchMidpoint=null,this.doubleClickStopEventTimer=null,this.velocity=null,this.velocityTime=null,this.lastMousePosition=null,this.animate=!1,this.animation=null,this.maxBounds=null,this.pressedKeys={},this.mount=function(){n.initializeWindowEvents()},this.unmount=function(){n.cleanupWindowEvents()},this.update=function(h){n.props=h,rt(n,n.transformState.scale),n.setup=xs(h)},this.initializeWindowEvents=function(){var h,S,x=cr(),w=(h=n.wrapperComponent)===null||h===void 0?void 0:h.ownerDocument,s=w?.defaultView;(S=n.wrapperComponent)===null||S===void 0||S.addEventListener("wheel",n.onWheelPanning,x),s?.addEventListener("mousedown",n.onPanningStart,x),s?.addEventListener("mousemove",n.onPanning,x),s?.addEventListener("mouseup",n.onPanningStop,x),w?.addEventListener("mouseleave",n.clearPanning,x),s?.addEventListener("keyup",n.setKeyUnPressed,x),s?.addEventListener("keydown",n.setKeyPressed,x)},this.cleanupWindowEvents=function(){var h,S,x=cr(),w=(h=n.wrapperComponent)===null||h===void 0?void 0:h.ownerDocument,s=w?.defaultView;s?.removeEventListener("mousedown",n.onPanningStart,x),s?.removeEventListener("mousemove",n.onPanning,x),s?.removeEventListener("mouseup",n.onPanningStop,x),w?.removeEventListener("mouseleave",n.clearPanning,x),s?.removeEventListener("keyup",n.setKeyUnPressed,x),s?.removeEventListener("keydown",n.setKeyPressed,x),document.removeEventListener("mouseleave",n.clearPanning,x),Ae(n),(S=n.observer)===null||S===void 0||S.disconnect()},this.handleInitializeWrapperEvents=function(h){var S=cr();h.addEventListener("wheel",n.onWheelZoom,S),h.addEventListener("dblclick",n.onDoubleClick,S),h.addEventListener("touchstart",n.onTouchPanningStart,S),h.addEventListener("touchmove",n.onTouchPanning,S),h.addEventListener("touchend",n.onTouchPanningStop,S)},this.handleInitialize=function(h,S){var x=!1,w=n.setup.centerOnInit,s=function(o,u){for(var f=0,d=o;f<d.length;f++){var p=d[f];if(p.target===u)return!0}return!1};n.applyTransformation(),n.onInitCallbacks.forEach(function(o){o(oe(n))}),n.observer=new ResizeObserver(function(o){if(s(o,h)||s(o,S))if(w&&!x){var u=S.offsetWidth,f=S.offsetHeight;(u>0||f>0)&&(x=!0,n.setCenter())}else Ae(n),rt(n,n.transformState.scale),Ir(n,0)}),n.observer.observe(h),n.observer.observe(S)},this.onWheelZoom=function(h){var S=n.setup.disabled;if(!S){var x=sd(n,h);if(x){var w=n.isPressingKeys(n.setup.wheel.activationKeys);w&&(md(n,h),pd(n,h),gd(n,h))}}},this.onWheelPanning=function(h){var S=n.setup,x=S.disabled,w=S.wheel,s=S.panning;if(!(!n.wrapperComponent||!n.contentComponent||x||!w.wheelDisabled||s.disabled||!s.wheelPanning||h.ctrlKey)){h.preventDefault(),h.stopPropagation();var o=n.transformState,u=o.positionX,f=o.positionY,d=u-h.deltaX,p=f-h.deltaY,m=s.lockAxisX?u:d,y=s.lockAxisY?f:p,b=n.setup.alignmentAnimation,r=b.sizeX,a=b.sizeY,l=Ye(n,r),c=Ye(n,a);m===u&&y===f||vi(n,m,y,l,c)}},this.onPanningStart=function(h){var S=n.setup.disabled,x=n.props.onPanningStart;if(!S){var w=ms(n,h);if(w){var s=n.isPressingKeys(n.setup.panning.activationKeys);s&&(h.button===0&&!n.setup.panning.allowLeftClickPan||h.button===1&&!n.setup.panning.allowMiddleClickPan||h.button===2&&!n.setup.panning.allowRightClickPan||(h.preventDefault(),h.stopPropagation(),Ae(n),vs(n,h),de(oe(n),h,x)))}}},this.onPanning=function(h){var S=n.setup.disabled,x=n.props.onPanning;if(!S){var w=ps(n);if(w){var s=n.isPressingKeys(n.setup.panning.activationKeys);s&&(h.preventDefault(),h.stopPropagation(),_s(n,h.clientX,h.clientY),de(oe(n),h,x))}}},this.onPanningStop=function(h){var S=n.props.onPanningStop;n.isPanning&&(Kc(n),de(oe(n),h,S))},this.onPinchStart=function(h){var S=n.setup.disabled,x=n.props,w=x.onPinchingStart,s=x.onZoomStart;if(!S){var o=ld(n,h);o&&(vd(n,h),Ae(n),de(oe(n),h,w),de(oe(n),h,s))}},this.onPinch=function(h){var S=n.setup.disabled,x=n.props,w=x.onPinching,s=x.onZoom;if(!S){var o=cd(n);o&&(h.preventDefault(),h.stopPropagation(),_d(n,h),de(oe(n),h,w),de(oe(n),h,s))}},this.onPinchStop=function(h){var S=n.props,x=S.onPinchingStop,w=S.onZoomStop;n.pinchStartScale&&(bd(n),de(oe(n),h,x),de(oe(n),h,w))},this.onTouchPanningStart=function(h){var S=n.setup.disabled,x=n.props.onPanningStart;if(!S){var w=ms(n,h);if(w){var s=n.lastTouch&&+new Date-n.lastTouch<200&&h.touches.length===1;if(!s){n.lastTouch=+new Date,Ae(n);var o=h.touches,u=o.length===1,f=o.length===2;u&&(Ae(n),vs(n,h),de(oe(n),h,x)),f&&n.onPinchStart(h)}}}},this.onTouchPanning=function(h){var S=n.setup.disabled,x=n.props.onPanning;if(n.isPanning&&h.touches.length===1){if(S)return;var w=ps(n);if(!w)return;h.preventDefault(),h.stopPropagation();var s=h.touches[0];_s(n,s.clientX,s.clientY),de(oe(n),h,x)}else h.touches.length>1&&n.onPinch(h)},this.onTouchPanningStop=function(h){n.onPanningStop(h),n.onPinchStop(h)},this.onDoubleClick=function(h){var S=n.setup.disabled;if(!S){var x=wd(n,h);x&&yd(n,h)}},this.clearPanning=function(h){n.isPanning&&n.onPanningStop(h)},this.setKeyPressed=function(h){n.pressedKeys[h.key]=!0},this.setKeyUnPressed=function(h){n.pressedKeys[h.key]=!1},this.isPressingKeys=function(h){return h.length?!!h.find(function(S){return n.pressedKeys[S]}):!0},this.setTransformState=function(h,S,x){var w=n.props.onTransformed;if(!Number.isNaN(h)&&!Number.isNaN(S)&&!Number.isNaN(x)){h!==n.transformState.scale&&(n.transformState.previousScale=n.transformState.scale,n.transformState.scale=h),n.transformState.positionX=S,n.transformState.positionY=x,n.applyTransformation();var s=oe(n);n.onChangeCallbacks.forEach(function(o){return o(s)}),de(s,{scale:h,positionX:S,positionY:x},w)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(n.wrapperComponent&&n.contentComponent){var h=wi(n.transformState.scale,n.wrapperComponent,n.contentComponent);n.setTransformState(h.scale,h.positionX,h.positionY)}},this.handleTransformStyles=function(h,S,x){return n.props.customTransform?n.props.customTransform(h,S,x):td(h,S,x)},this.applyTransformation=function(){if(!(!n.mounted||!n.contentComponent)){var h=n.transformState,S=h.scale,x=h.positionX,w=h.positionY,s=n.handleTransformStyles(x,w,S);n.contentComponent.style.transform=s}},this.getContext=function(){return oe(n)},this.onChange=function(h){return n.onChangeCallbacks.has(h)||n.onChangeCallbacks.add(h),function(){n.onChangeCallbacks.delete(h)}},this.onInit=function(h){return n.onInitCallbacks.has(h)||n.onInitCallbacks.add(h),function(){n.onInitCallbacks.delete(h)}},this.init=function(h,S){n.cleanupWindowEvents(),n.wrapperComponent=h,n.contentComponent=S,rt(n,n.transformState.scale),n.handleInitializeWrapperEvents(h),n.handleInitialize(h,S),n.initializeWindowEvents(),n.isInitialized=!0;var x=oe(n);de(x,void 0,n.props.onInit)},this.props=i,this.setup=xs(this.props),this.transformState=bi(this.props)}return e})(),Gt=me.createContext(null),kd=function(e,i){return typeof e=="function"?e(i):e},Ed=me.forwardRef(function(e,i){var n=A.useRef(new Cd(e)).current,h=kd(e.children,zt(n));return A.useImperativeHandle(i,function(){return zt(n)},[n]),A.useEffect(function(){n.update(e)},[n,e]),me.createElement(Gt.Provider,{value:n},h)});me.forwardRef(function(e,i){var n=A.useRef(null),h=A.useContext(Gt);return A.useEffect(function(){return h.onChange(function(S){if(n.current){var x=0,w=0;n.current.style.transform=h.handleTransformStyles(x,w,1/S.instance.transformState.scale)}})},[h]),me.createElement("div",Ke({},e,{ref:rd([n,i])}))});function jd(e,i){i===void 0&&(i={});var n=i.insertAt;if(!(typeof document>"u")){var h=document.head||document.getElementsByTagName("head")[0],S=document.createElement("style");S.type="text/css",n==="top"&&h.firstChild?h.insertBefore(S,h.firstChild):h.appendChild(S),S.styleSheet?S.styleSheet.cssText=e:S.appendChild(document.createTextNode(e))}}var Nd=`.transform-component-module_wrapper__SPB86 {
30
+ position: relative;
31
+ width: -moz-fit-content;
32
+ width: fit-content;
33
+ height: -moz-fit-content;
34
+ height: fit-content;
35
+ overflow: hidden;
36
+ -webkit-touch-callout: none; /* iOS Safari */
37
+ -webkit-user-select: none; /* Safari */
38
+ -khtml-user-select: none; /* Konqueror HTML */
39
+ -moz-user-select: none; /* Firefox */
40
+ -ms-user-select: none; /* Internet Explorer/Edge */
41
+ user-select: none;
42
+ margin: 0;
43
+ padding: 0;
44
+ transform: translate3d(0, 0, 0);
45
+ }
46
+ .transform-component-module_content__FBWxo {
47
+ display: flex;
48
+ flex-wrap: wrap;
49
+ width: -moz-fit-content;
50
+ width: fit-content;
51
+ height: -moz-fit-content;
52
+ height: fit-content;
53
+ margin: 0;
54
+ padding: 0;
55
+ transform-origin: 0% 0%;
56
+ }
57
+ .transform-component-module_content__FBWxo img {
58
+ pointer-events: none;
59
+ }
60
+ `,Ss={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};jd(Nd);var Rd=function(e){var i=e.children,n=e.wrapperClass,h=n===void 0?"":n,S=e.contentClass,x=S===void 0?"":S,w=e.wrapperStyle,s=e.contentStyle,o=e.wrapperProps,u=o===void 0?{}:o,f=e.contentProps,d=f===void 0?{}:f,p=A.useContext(Gt),m=p.init,y=p.cleanupWindowEvents,b=A.useRef(null),r=A.useRef(null);return A.useEffect(function(){var a=b.current,l=r.current;return a!==null&&l!==null&&m&&m?.(a,l),function(){y?.()}},[]),me.createElement("div",Ke({},u,{ref:b,className:"".concat(Cr.wrapperClass," ").concat(Ss.wrapper," ").concat(h),style:w}),me.createElement("div",Ke({},d,{ref:r,className:"".concat(Cr.contentClass," ").concat(Ss.content," ").concat(x),style:s}),i))},Ni=function(){var e=A.useContext(Gt);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Ad=function(){var e=Ni();return zt(e)};function Ld(e){var i=Ni(),n=A.useState(e(kr(i))),h=n[0],S=n[1];return A.useEffect(function(){var x=!0,w=i.onChange(function(s){x&&S(e(kr(s.instance)))});return function(){w(),x=!1}},[e,i]),h}function Pd(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}function Td(e,i){return Le({queryKey:ge.files.tree(e||"",i),queryFn:()=>ue.get("/files/tree",{params:{workingDir:e||"",path:i}}),enabled:!!e})}function Md(e,i){return Le({queryKey:ge.files.content(e||"",i||""),queryFn:()=>ue.get("/files/read",{params:{workingDir:e||"",path:i||""}}),enabled:!!e&&!!i})}function Dd(e){const i=dt();return A.useCallback(()=>{e&&i.invalidateQueries({queryKey:["files","tree",e]})},[i,e])}function Bd(){const e=dt();return Ds({mutationFn:i=>ue.post("/files/write",i),onSuccess:(i,n)=>{const h=ge.files.content(n.workingDir,n.path),S=e.getQueryData(h);e.setQueryData(h,{content:n.content,language:S?.language||Pd(n.path)})}})}function Od(e,i){return e==="/"?`/${i}`:`${e}/${i}`}function Id(e,i){return e==="/"?i:`${e.slice(1)}/${i}`}const Fd=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Hd(e){if(e.type==="directory")return null;const i=e.name.split(".").pop()?.toLowerCase();return i&&Fd.has(i)?Os:i==="ts"||i==="tsx"||i==="js"||i==="jsx"?Ht:i==="json"?uo:i==="md"||i==="mdx"||i==="txt"?Is:Fn}const ys=({depth:e,active:i,onClick:n,leftIcon:h,rightIcon:S,label:x})=>t.jsxs("button",{type:"button",onClick:n,className:Q("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",i&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:S}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:h}),t.jsx("span",{className:"truncate text-neutral-700",children:x})]}),Ri=({workingDir:e,path:i,depth:n,expanded:h,toggleDir:S,onFileSelect:x,selectedFilePath:w})=>{const{t:s}=se(),{data:o,isLoading:u,isError:f}=Td(e,i),d=A.useMemo(()=>o?.items??[],[o?.items]);return u?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+n*14},children:s("Loading...")}):f?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+n*14},children:s("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:d.map(p=>{if(p.type==="directory"){const a=Od(i,p.name),l=h.has(a);return t.jsxs("div",{children:[t.jsx(ys,{depth:n,onClick:()=>S(a),rightIcon:l?t.jsx(We,{size:14,className:"text-neutral-400"}):t.jsx(Xe,{size:14,className:"text-neutral-400"}),leftIcon:l?t.jsx(zs,{size:14,className:"text-amber-500"}):t.jsx(Lr,{size:14,className:"text-amber-500"}),label:p.name}),l&&t.jsx(Ri,{workingDir:e,path:a,depth:n+1,expanded:h,toggleDir:S,onFileSelect:x,selectedFilePath:w})]},a)}const m=Id(i,p.name),y=Hd(p),b=w===m,r=y===Os;return t.jsx(ys,{depth:n,active:b,onClick:()=>x(m),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?t.jsx(y,{size:14,className:r?"text-emerald-600":"text-sky-600"}):null,label:p.name},m)})})},Wd=({workingDir:e,className:i,onFileSelect:n,selectedFilePath:h,onCollapse:S})=>{const{t:x}=se(),[w,s]=A.useState(()=>new Set),o=Dd(e),u=A.useCallback(f=>{s(d=>{const p=new Set(d);return p.has(f)?p.delete(f):p.add(f),p})},[]);return t.jsxs("div",{className:Q("h-full flex flex-col",i),children:[t.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:x("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||x("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:o,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:x("Refresh file tree"),children:t.jsx(ht,{size:13})}),S&&t.jsx("button",{type:"button",onClick:S,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:x("Collapse file tree"),children:t.jsx(xo,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(Ri,{workingDir:e,path:"/",depth:0,expanded:w,toggleDir:u,onFileSelect:n,selectedFilePath:h}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:x("No workspace selected.")})})]})},zd=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function $d(e){const i=e.split(".").pop()?.toLowerCase();return i?zd.has(i):!1}function Ud(e,i){const n=Rr(),h=new URLSearchParams({workingDir:e,path:i});return`${n}/files/image?${h.toString()}`}const qd=({filePath:e})=>{const{t:i}=se(),{zoomIn:n,zoomOut:h,centerView:S}=Ad(),x=Ld(s=>s.state.scale),w=Math.round(x*100);return t.jsxs("div",{className:"flex items-center gap-1 px-3 py-1.5 border-b border-neutral-200 bg-neutral-50/80 shrink-0",children:[t.jsx("button",{type:"button",onClick:()=>h(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:i("Zoom out"),children:t.jsx(To,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>S(1),className:"px-1.5 py-0.5 rounded hover:bg-neutral-200 text-[11px] text-neutral-600 tabular-nums min-w-[40px] text-center transition-colors",title:i("Reset zoom"),children:[w,"%"]}),t.jsx("button",{type:"button",onClick:()=>n(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:i("Zoom in"),children:t.jsx(Lo,{size:14})}),t.jsx("button",{type:"button",onClick:()=>S(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:i("Fit to view"),children:t.jsx(_o,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Kd=({workingDir:e,filePath:i})=>{const{t:n}=se(),[h,S]=A.useState(!1),x=Ud(e,i);return h?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:n("Failed to load image.")}):t.jsx(Ed,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(qd,{filePath:i}),t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden bg-[repeating-conic-gradient(#f3f3f3_0%_25%,#fff_0%_50%)] bg-[length:16px_16px]",children:t.jsx(Rd,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:x,alt:i,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>S(!0)})})})]})})};function Xd(e){const i=e.split("/");return i[i.length-1]||e}function Yd(e){switch(e.split(".").pop()?.toLowerCase()){case"ts":case"tsx":return"typescript";case"js":case"jsx":case"mjs":case"cjs":return"javascript";case"json":return"json";case"md":case"mdx":return"markdown";case"css":return"css";case"scss":return"scss";case"html":return"html";case"yml":case"yaml":return"yaml";case"sh":return"shell";case"py":return"python";case"go":return"go";case"rs":return"rust";default:return"plaintext"}}const Vd=({active:e,name:i,isDirty:n,onClick:h,onClose:S})=>{const{t:x}=se();return t.jsxs("button",{type:"button",onClick:h,className:Q("group flex items-center gap-2 px-3 py-2 rounded-t-md border-t border-x -mb-px min-w-[120px] max-w-[240px]",e?"bg-white border-neutral-200 text-neutral-900":"bg-neutral-100/60 border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-100"),children:[t.jsx("span",{className:Q("w-2 h-2 rounded-full",n?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:i}),t.jsx("span",{onClick:S,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":x("Close tab"),title:x("Close"),children:t.jsx(Ve,{size:12})})]})},Gd=me.forwardRef(function({workingDir:i,className:n,readOnly:h=!1},S){const{t:x}=se(),[w,s]=A.useState([]),[o,u]=A.useState(null),[f,d]=A.useState(!1),[p,m]=A.useState(!1),[y,b]=A.useState(0),[r,a]=A.useState(null),l=A.useRef(null),c=Bd();A.useEffect(()=>{let $=!1;return on(async()=>{const{preloadMonaco:W}=await import("./monaco-BuDK9Fat.js").then(z=>z.m);return{preloadMonaco:W}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:W})=>W()).then(()=>{$||d(!0)}).catch(()=>{$||m(!0)}),()=>{$=!0}},[]);const[g,_]=A.useState(280),[C,k]=A.useState(!1),[v,E]=A.useState(!1),R=A.useRef(280),O=A.useCallback(()=>{k($=>($?_(R.current):R.current=g,!$))},[g]),L=A.useCallback($=>{$.preventDefault(),E(!0);const W=$.clientX,z=g,j=X=>{const Y=X.clientX-W,Z=Math.min(480,Math.max(160,z+Y));_(Z)},I=()=>{E(!1),document.removeEventListener("mousemove",j),document.removeEventListener("mouseup",I)};document.addEventListener("mousemove",j),document.addEventListener("mouseup",I)},[g]);A.useEffect(()=>{s([]),u(null),a(null)},[i]);const P=A.useMemo(()=>w.find($=>$.path===o)||null,[w,o]),{data:H,isFetching:M,isError:F,error:U}=Md(i,P?.isImage?null:o);A.useEffect(()=>{!o||!H||s($=>$.map(W=>W.path!==o||W.isDirty||W.loaded?W:{...W,language:H.language||W.language,content:H.content,savedContent:H.content,isDirty:!1,loaded:!0}))},[o,H]);const N=A.useCallback(($,W,z)=>{s(j=>{if(j.find(Y=>Y.path===$))return j;const X=$d($);return[...j,{path:$,name:Xd($),language:Yd($),content:"",savedContent:"",isDirty:!1,loaded:X,isImage:X}]}),u($),a(W?{path:$,line:W,column:z}:null)},[]);me.useImperativeHandle(S,()=>({openFile:N}),[N]);const D=A.useCallback($=>{s(W=>{const z=W.filter(j=>j.path!==$);return u(j=>j!==$?j:z.length?z[z.length-1].path:null),z})},[]),T=A.useCallback($=>{s(W=>W.map(z=>{if(z.path!==o)return z;const j=$!==z.savedContent;return{...z,content:$,isDirty:j}}))},[o]),B=A.useCallback(async()=>{h||!i||!P||(await c.mutateAsync({workingDir:i,path:P.path,content:P.content}),s($=>$.map(W=>W.path===P.path?{...W,savedContent:W.content,isDirty:!1,loaded:!0}:W)))},[P,h,c,i]),q=A.useRef(()=>{});A.useEffect(()=>{q.current=()=>{B().catch(()=>{})}},[B]),A.useEffect(()=>{const $=W=>{h||(W.metaKey||W.ctrlKey)&&W.key.toLowerCase()==="s"&&(W.preventDefault(),q.current())};return window.addEventListener("keydown",$),()=>window.removeEventListener("keydown",$)},[h]);const K=A.useCallback(($,W)=>{l.current=$,b(z=>z+1),$.addCommand(W.KeyMod.CtrlCmd|W.KeyCode.KeyS,()=>{q.current()})},[]);return A.useEffect(()=>{if(!r||r.path!==o||!P?.loaded)return;const $=l.current,W=$?.getModel();if(!$||!W)return;const z=Math.min(r.line,W.getLineCount()),j=Math.min(r.column??1,W.getLineMaxColumn(z)),I={lineNumber:z,column:j};$.setPosition(I),$.revealPositionInCenter(I),$.focus(),a(null)},[o,P?.loaded,y,r]),t.jsxs("div",{className:Q("flex h-full overflow-hidden bg-white",n),style:v?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:C?36:g,transition:v?"none":"width 0.15s ease"},children:C?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:O,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:x("Expand file tree"),children:t.jsx(yo,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(Wd,{workingDir:i,onFileSelect:N,selectedFilePath:P?.path||null,onCollapse:O},i||"no-working-dir")})}),!C&&t.jsx("div",{onMouseDown:L,className:Q("w-1 shrink-0 cursor-col-resize transition-colors",v?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),t.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1 px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 overflow-x-auto shrink-0",children:[w.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:x("No open files")}):w.map($=>t.jsx(Vd,{active:$.path===o,name:$.name,isDirty:$.isDirty,onClick:()=>u($.path),onClose:W=>{W.stopPropagation(),D($.path)}},$.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[h&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:x("Read-only")}),c.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(he,{size:14,className:"animate-spin"}),x("Saving")]}),P?.isDirty&&!c.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:x("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:i?P?P.isImage?t.jsx(Kd,{workingDir:i,filePath:P.path}):p?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:x("Failed to load editor.")}):f?t.jsxs(t.Fragment,{children:[t.jsx(vc,{path:P.path,value:P.content,language:P.language,theme:"vs-light",height:"100%",onChange:h?void 0:$=>T($??""),onMount:K,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:h}}),M&&!P.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(he,{size:14,className:"animate-spin"}),x("Loading file...")]})}),F&&t.jsxs("div",{className:"absolute bottom-2 left-2 right-2 text-xs text-red-700 bg-red-50 border border-red-200 rounded px-2 py-1",children:[x("Failed to load file"),U instanceof Error?`: ${U.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(he,{size:14,className:"animate-spin mr-2"}),x("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:x("Select a file from the tree to open.")}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:x("No workspace selected.")})})]})]})});function Zd(e,i={}){const n=$t(S=>S.visibleContext),h=Us(e,n);return Le({queryKey:ge.git.changes(e||""),queryFn:()=>ue.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(i.enabled??!0),refetchInterval:h,refetchIntervalInBackground:!1,refetchOnWindowFocus:h?"always":!1,refetchOnReconnect:h?"always":!1})}function Qd(e,i,n){const h=$t(x=>x.visibleContext),S=Us(e,h);return Le({queryKey:ge.git.diff(e||"",i||"",n),queryFn:()=>ue.get("/git/diff",{params:{workingDir:e||"",path:i||"",type:n}}),enabled:!!e&&!!i,refetchInterval:S,refetchIntervalInBackground:!1,refetchOnWindowFocus:S?"always":!1,refetchOnReconnect:S?"always":!1})}function Ai(e,i){return Le({queryKey:ge.git.commitFiles(e||"",i||""),queryFn:()=>ue.get("/git/commit-files",{params:{workingDir:e||"",hash:i||""}}),enabled:!!e&&!!i})}function Li(e,i,n){return Le({queryKey:ge.git.commitDiff(e||"",i||"",n||""),queryFn:()=>ue.get("/git/commit-diff",{params:{workingDir:e||"",hash:i||"",path:n||""}}),enabled:!!e&&!!i&&!!n})}const Jd=new Set(["STARTING","RUNNING","STOPPING"]);function Pi(e){return Jd.has(e.runtimeState)||e.runtimeInstanceId!==null}function Ti(e){return e instanceof Ut&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function eh({services:e,isLoading:i,isError:n}){const{t:h}=se();return i?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(he,{size:13,className:"animate-spin shrink-0","aria-hidden":"true"}),t.jsx("span",{children:h("正在检查后台服务...")})]}):e.length>0?t.jsxs("div",{className:"flex gap-2.5 rounded-md border border-amber-200 bg-amber-50 px-3 py-2.5 text-amber-900",children:[t.jsx(wt,{size:16,className:"mt-0.5 shrink-0","aria-hidden":"true"}),t.jsxs("div",{className:"min-w-0 text-xs leading-relaxed",children:[t.jsx("p",{className:"font-medium",children:h("合并前将停止 {count} 个后台服务",{count:e.length})}),t.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-amber-800",children:e.map(S=>S.name).join(", ")}),t.jsx("p",{className:"mt-1 text-amber-700",children:h("停止后不会自动恢复。")})]})]}):n?t.jsx("p",{className:"text-xs text-amber-700",role:"status",children:h("无法检查后台服务状态,提交时会再次确认。")}):null}const th={INVALID_BASE_BRANCH:"Choose an existing local branch different from the workspace branch.",BASE_BRANCH_UNRELATED:"The selected branch has no shared commit history with this workspace.",WORKSPACE_BASE_BRANCH_BUSY:"Wait for the Agent to finish or stop it before changing the base branch.",WORKSPACE_GIT_OPERATION_IN_PROGRESS:"Finish or abort the current Git operation before changing the base branch.",WORKSPACE_BASE_BRANCH_CHANGED:"The workspace changed. Refresh and select the base branch again.",INVALID_WORKSPACE_STATE:"Only active workspaces can change base branch. Refresh the list.",WORKSPACE_BASE_BRANCH_MANAGED:"TeamRun member base branches are managed by their parent workspace."};function Mi(e){return e.isOpen?t.jsx(rh,{...e},e.workspaceId):null}function rh({isOpen:e,onClose:i,onBaseBranchSaved:n,projectId:h,workspaceId:S,branchName:x,targetBranch:w,commitMessage:s,isPending:o,canMerge:u,activeServices:f,isCheckingServices:d,serviceCheckFailed:p,error:m,onConfirm:y}){const{t:b}=se(),r=A.useId(),a=Hn(h),l=Wn(),c=a.data?.workspaces.find(N=>N.id===S),g=c?.baseBranch||a.data?.mainBranch||w,[_,C]=A.useState(null),k=_??g,v=a.data?.branches.filter(N=>N!==x)??[],E=!!c&&k!==g,R=o||l.isPending,O=a.isPending||a.isFetching||a.isError,L=l.error instanceof Ut?String(l.error.details.code):"",[P,H]=A.useState(null),M=P??s??"",F=()=>{R||i()},U=async()=>{if(!(!c||!E))try{await l.mutateAsync({id:S,baseBranch:k,expectedBaseBranch:c.baseBranch}),Se.success(b("Workspace base branch saved. Review the changes before merging.")),i(),n?.()}catch{}};return t.jsx(Ct,{isOpen:e,onClose:F,title:b("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:F,disabled:R,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:b("取消")}),t.jsx("button",{onClick:()=>y(M.trim()||void 0,f.length>0),disabled:R||d||O||E||!u,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium text-primary-foreground bg-primary hover:bg-primary/90 rounded-md transition-colors disabled:opacity-50",children:o||d?t.jsxs(t.Fragment,{children:[t.jsx(he,{size:14,className:"animate-spin"}),d?b("正在检查后台服务..."):f.length>0?b("正在停止服务并提交..."):b("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(Ft,{size:14}),f.length>0?b("停止服务并提交"):b("确认提交")]})})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:x}),t.jsx(Gs,{size:14,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"px-2 py-0.5 rounded-sm bg-muted font-mono text-xs text-muted-foreground",children:c?g:w})]}),a.isPending?t.jsx("p",{className:"text-xs text-muted-foreground",children:b("Loading...")}):a.isError?t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:b("Could not load branches. Refresh to try again.")}),t.jsx(ae,{size:"sm",variant:"outline",onClick:()=>{a.refetch()},children:b("Refresh")})]}):c&&t.jsxs("div",{className:"space-y-2",children:[t.jsx("label",{htmlFor:r,className:"block text-xs font-medium",children:b("Base branch for this workspace")}),t.jsx(Vn,{id:r,label:b("Base branch for this workspace"),value:k,branches:v,disabled:R,isRefreshing:a.isFetching,onOpen:()=>{a.refetch()},onChange:N=>{C(N),l.reset()}}),t.jsx("p",{className:"text-[11px] text-muted-foreground leading-relaxed",children:b("Changing this base branch updates the comparison, update and merge target for this workspace only. Save and review the changes before merging.")}),E&&t.jsx(ae,{size:"sm",onClick:()=>{U()},disabled:R||O||!v.includes(k),children:l.isPending?b("Saving"):b("Save base branch and review changes")}),l.isError&&t.jsx("p",{role:"alert",className:"text-xs text-destructive",children:b(th[L]??"Could not save the base branch. Refresh and try again.")})]}),!u&&t.jsx("p",{className:"text-xs text-muted-foreground",children:b("Review the changes and sync the base branch before submitting.")}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:b("提交消息")}),t.jsx("textarea",{value:M,onChange:N=>H(N.target.value),placeholder:b("请描述本次修改的内容"),rows:4,className:"w-full px-3 py-2 rounded-md border border-input text-sm font-mono text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring resize-none"}),t.jsx("p",{className:"mt-1.5 text-[11px] text-muted-foreground/70 leading-relaxed",children:b("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!M.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:b("留空将使用默认消息")})]}),t.jsx(eh,{services:f,isLoading:d,isError:p}),m&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:m})]})})}function nt(e,i){const n=e[i];return typeof n=="string"&&n.length>0?n:void 0}function Di(e){if(!(e instanceof Ut)||e.status!==409)return;const i=e.details;if(i.code!=="MERGE_CONFLICT"||i.conflictOp!==xt.REBASE&&i.conflictOp!==xt.MERGE||!Array.isArray(i.conflictedFiles)||!i.conflictedFiles.every(h=>typeof h=="string"))return;const n=i.mergeStrategy==="squash"||i.mergeStrategy==="no_ff"?i.mergeStrategy:void 0;return{conflictOp:i.conflictOp,conflictedFiles:i.conflictedFiles,mergeAborted:typeof i.mergeAborted=="boolean"?i.mergeAborted:void 0,mergeStrategy:n,sourceBranch:nt(i,"sourceBranch"),targetBranch:nt(i,"targetBranch"),sourceWorktreePath:nt(i,"sourceWorktreePath"),targetWorktreePath:nt(i,"targetWorktreePath"),sourceWorkspaceId:nt(i,"sourceWorkspaceId"),targetWorkspaceId:nt(i,"targetWorkspaceId")}}function ws(e,i,n,h){const S=Di(e);if(S){n(S);return}h(e instanceof Error?e.message:i)}function sh({projectId:e,workspaceId:i,branchName:n,targetBranch:h,commitMessage:S,committedFileCount:x,onRefreshCommitMessage:w,onConflict:s,onResolveConflicts:o}){const{t:u}=se(),{data:f,isLoading:d}=zn(i),p=qs(),m=Ks(),y=Xs(),[b,r]=A.useState(!1),[a,l]=A.useState(null),c=Br(i,b),g=(c.data??[]).filter(Pi);if(A.useEffect(()=>{b&&w?.()},[b,w]),d||!f)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(he,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:u("正在检查工作区状态...")})]});const _=f.conflictedFiles.length>0,C=f.operation!=="idle",k=f.hasUncommittedChanges||f.untrackedCount>0,v=f.uncommittedCount+f.untrackedCount,E=!_&&!C&&!k,R=f.operation==="idle"&&f.ahead===0&&f.behind===0&&!k&&!_,O=()=>{l(null),p.mutate(i,{onError:M=>{ws(M,u("更新失败,请稍后重试"),F=>s(F),l)}})},L=()=>{l(null),r(!0)},P=(M,F)=>{l(null),m.mutate({id:i,commitMessage:M,stopActiveServices:F},{onSuccess:()=>r(!1),onError:U=>{if(Ti(U)){l(u("后台服务仍在运行,请确认停止服务后再提交。"));return}ws(U,u("提交失败,请稍后重试"),N=>{r(!1),s(N)},l)}})},H=()=>{m.isPending||(r(!1),l(null))};return R?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-muted-foreground/70 border-b border-border/60",children:[t.jsx(an,{size:13}),t.jsx("span",{className:"text-xs",children:u("当前分支还没有任何变更")})]}):t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"border-b border-border bg-background",children:t.jsxs("div",{className:"px-3 py-2",children:[a&&t.jsx("div",{className:"mb-2 px-2.5 py-1.5 rounded-md bg-red-50 border border-red-200 text-[11px] text-red-700",children:a}),k&&t.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2.5 py-1.5 rounded-md bg-amber-50 border border-amber-200 text-[11px] text-amber-800",children:[t.jsx(po,{size:12,className:"shrink-0"}),t.jsx("span",{children:u("{count} 个本地改动未处理,需要先整理后再继续",{count:v})})]}),_&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-amber-700",children:[t.jsx(wt,{size:13,className:"shrink-0"}),t.jsx("span",{children:u("{count} 个文件存在冲突,需要处理后继续",{count:f.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:o,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-amber-800 bg-amber-100 hover:bg-amber-200 border border-amber-200 transition-colors",children:u("处理冲突")}),t.jsx("button",{onClick:()=>y.mutate(i),disabled:y.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:y.isPending?u("正在撤销..."):u("撤销操作")})]})]}),C&&!_&&t.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[t.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-info",children:[t.jsx(he,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:f.operation==="rebase"?u("正在同步源分支更新..."):u("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>y.mutate(i),disabled:y.isPending,className:"flex items-center gap-1.5 ml-auto px-2.5 py-1 rounded-md text-xs text-muted-foreground hover:bg-muted border border-border transition-colors disabled:opacity-50",children:[t.jsx(Bs,{size:12}),y.isPending?u("正在撤销..."):u("撤销操作")]})]}),!_&&!C&&(f.behind>0||f.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[f.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:u("源分支 {branch} 有 {count} 个更新",{branch:h,count:f.behind})}),t.jsxs("button",{onClick:O,disabled:!E||p.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(ht,{size:12}),p.isPending?u("正在同步..."):u("同步更新")]})]}),f.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:u("{count} 个文件变更,可以安全提交",{count:x??f.ahead})}),k?t.jsxs("button",{disabled:!0,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs text-muted-foreground/60 bg-muted/60 border border-border cursor-not-allowed",title:u(k?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(Ft,{size:12}),u("提交变更")]}):t.jsxs("button",{onClick:L,disabled:m.isPending,className:"flex items-center gap-1.5 px-2.5 py-1 rounded-md text-xs font-medium text-primary-foreground bg-primary hover:bg-primary/90 transition-colors disabled:opacity-50",children:[t.jsx(Ft,{size:12}),u("提交变更")]})]})]})]})}),t.jsx(Mi,{projectId:e,workspaceId:i,canMerge:E&&f.ahead>0&&f.behind===0,isOpen:b,onClose:H,branchName:n,targetBranch:h,commitMessage:S,isPending:m.isPending,activeServices:g,isCheckingServices:c.isLoading,serviceCheckFailed:c.isError,error:a,onConfirm:P})]})}const dr=50,hr=400,Cs={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"},ks={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Bi(e){const i=e.split("/");return i[i.length-1]||e}function ih(e){const i=e.lastIndexOf("/");return i>0?e.slice(0,i):""}function nh(e){const n=Math.floor(Date.now()/1e3)-e;return n<60?$e("{count}s ago",{count:n}):n<3600?$e("{count}m ago",{count:Math.floor(n/60)}):n<86400?$e("{count}h ago",{count:Math.floor(n/3600)}):n<604800?$e("{count}d ago",{count:Math.floor(n/86400)}):new Date(e*1e3).toLocaleDateString()}function Bt(e,i){return e.kind==="working"?`${e.diffType}:${i}`:`${e.hash}:${i}`}const jr=({additions:e,deletions:i,className:n})=>e===void 0&&i===void 0?null:t.jsxs("span",{className:Q("flex items-center gap-1 font-mono text-[11px] shrink-0",n),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),i!==void 0&&i>0&&t.jsxs("span",{className:"text-red-600",children:["-",i]}),(e??0)===0&&(i??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),oh=({line:e,lineNum:i})=>{let n="",h="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?n="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?n="bg-destructive/10":e.startsWith("@@")?(n="bg-info/5",h="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(h="text-muted-foreground/70"),t.jsxs("div",{className:Q("flex",n),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:i}),t.jsx("span",{className:Q("pl-2 whitespace-pre",h),children:e})]})},Oi=({diff:e})=>{const{t:i}=se(),[n,h]=A.useState(!1),S=A.useMemo(()=>e.split(`
61
+ `),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:i("没有可显示的差异内容")});const x=!n&&S.length>hr,w=x?S.slice(0,hr):S;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[w.map((s,o)=>t.jsx(oh,{line:s,lineNum:o+1},o)),x&&t.jsx("button",{type:"button",onClick:()=>h(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:i("还有 {count} 行变更被折叠,点击展开全部",{count:S.length-hr})})]})},ah=({workingDir:e,path:i,diffType:n,enabled:h})=>{const{t:S}=se(),{data:x,isLoading:w,isError:s}=Qd(e,h?i:null,n);return!h||w?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(he,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:S("正在加载差异...")})]}):s?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:S("差异加载失败")}):t.jsx(Oi,{diff:x?.diff||""})},lh=({workingDir:e,hash:i,path:n,enabled:h})=>{const{t:S}=se(),{data:x,isLoading:w,isError:s}=Li(e,h?i:null,h?n:null);return!h||w?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(he,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:S("正在加载差异...")})]}):s?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:S("差异加载失败")}):t.jsx(Oi,{diff:x?.diff||""})},ur=({entry:e,source:i,workingDir:n,flash:h,registerNode:S})=>{const[x,w]=A.useState(!1),[s,o]=A.useState(!1),u=A.useRef(null),f=Bt(i,e.path);A.useEffect(()=>(S(f,u.current),()=>S(f,null)),[f,S]),A.useEffect(()=>{const m=u.current;if(!m||s)return;const y=new IntersectionObserver(b=>{b.some(r=>r.isIntersecting)&&(o(!0),y.disconnect())},{rootMargin:"300px 0px"});return y.observe(m),()=>y.disconnect()},[s]);const d=Cs[e.status]||Cs.M,p=ih(e.path);return t.jsxs("div",{ref:u,"data-card-key":f,className:Q("rounded-md border border-border bg-background overflow-hidden transition-shadow",h&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>w(m=>!m),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[x?t.jsx(Xe,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(We,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:Q("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",d),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:Bi(e.path)}),p&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:p}),t.jsx("span",{className:"ml-auto"}),t.jsx(jr,{additions:e.additions,deletions:e.deletions})]}),!x&&t.jsx("div",{className:"border-t border-border/60",children:i.kind==="working"?t.jsx(ah,{workingDir:n,path:e.path,diffType:i.diffType,enabled:s}):t.jsx(lh,{workingDir:n,hash:i.hash,path:e.path,enabled:s})})]})};function ch(e){const i={name:"",path:"",dirs:new Map,files:[]};for(const n of e){const h=n.path.split("/");let S=i;for(let x=0;x<h.length-1;x++){const w=h[x];S.dirs.has(w)||S.dirs.set(w,{name:w,path:S.path?`${S.path}/${w}`:w,dirs:new Map,files:[]}),S=S.dirs.get(w)}S.files.push(n)}return Ii(i)}function Ii(e){const i=new Map;for(const n of e.dirs.values()){let h=Ii(n);for(;h.dirs.size===1&&h.files.length===0;){const S=[...h.dirs.values()][0];h={...S,name:`${h.name}/${S.name}`}}i.set(h.name,h)}return{...e,dirs:i}}const dh=({dir:e,depth:i,activeKey:n,onSelect:h})=>{const[S,x]=A.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>x(w=>!w),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+i*12},children:[S?t.jsx(zs,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Lr,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),S&&t.jsx(Fi,{node:e,depth:i+1,activeKey:n,onSelect:h})]})},Fi=({node:e,depth:i,activeKey:n,onSelect:h})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((S,x)=>S.name.localeCompare(x.name)).map(S=>t.jsx(dh,{dir:S,depth:i,activeKey:n,onSelect:h},S.path)),e.files.slice().sort((S,x)=>S.path.localeCompare(x.path)).map(S=>{const x=n===S.cardKey;return t.jsxs("button",{type:"button",onClick:()=>h(S),className:Q("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",x?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+i*12},title:S.path,children:[t.jsx("span",{className:Q("w-1.5 h-1.5 rounded-full shrink-0",ks[S.status]||ks.M)}),t.jsx("span",{className:Q("text-xs truncate",x?"text-foreground font-medium":"text-foreground/90"),children:Bi(S.path)})]},S.cardKey)})]}),hh=({workingDir:e,selectedHash:i,onSelectCommit:n})=>{const{t:h}=se(),{data:S,isLoading:x,fetchNextPage:w,hasNextPage:s,isFetchingNextPage:o}=Vs({queryKey:ge.git.log(e),queryFn:({pageParam:f=0})=>ue.get("/git/log",{params:{workingDir:e,limit:String(dr),skip:String(f)}}),initialPageParam:0,getNextPageParam:(f,d)=>f.commits.length<dr?void 0:d.length*dr}),u=S?.pages.flatMap(f=>f.commits)||[];return x?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(he,{size:11,className:"animate-spin"}),t.jsx("span",{children:h("正在加载提交记录...")})]}):u.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:h("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[u.map(f=>{const d=i===f.hash;return t.jsxs("button",{type:"button",onClick:()=>n(f),className:Q("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",d?"bg-muted":"hover:bg-muted/60"),title:f.message,children:[t.jsx("span",{className:Q("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",d?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:Q("block text-xs truncate",d?"text-foreground font-medium":"text-foreground/90"),children:f.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:f.shortHash})," · ",f.author," · ",nh(f.timestamp)]})]})]},f.hash)}),s&&t.jsx("button",{type:"button",onClick:()=>w(),disabled:o,className:"w-full py-1.5 text-[11px] text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:o?t.jsxs(t.Fragment,{children:[t.jsx(he,{size:11,className:"animate-spin"})," ",h("正在加载...")]}):h("加载更多提交")})]})},uh=({projectId:e,workingDir:i,workspaceId:n,branchName:h,targetBranch:S,commitMessage:x,canRunGitOperations:w,onRefreshCommitMessage:s,onConflict:o,onResolveConflicts:u})=>{const{t:f}=se(),[d,p]=A.useState({kind:"overview"}),[m,y]=A.useState(""),[b,r]=A.useState(null),[a,l]=A.useState(null),{data:c,isLoading:g,isError:_}=Zd(i),C=d.kind==="commit"?d.commit.hash:null,{data:k,isLoading:v}=Ai(i,C),E=A.useRef(new Map),R=A.useRef(null),O=A.useRef(null),L=A.useCallback((W,z)=>{z?E.current.set(W,z):E.current.delete(W)},[]),{uncommitted:P,committed:H,commitFiles:M}=A.useMemo(()=>{const W=I=>!m.trim()||I.path.toLowerCase().includes(m.trim().toLowerCase());if(d.kind==="commit"){const I={kind:"commit",hash:d.commit.hash},X=(k?.files||[]).filter(W).map(Y=>({...Y,cardKey:Bt(I,Y.path)}));return{uncommitted:[],committed:[],commitFiles:X}}const z=(c?.uncommitted||[]).filter(W).map(I=>({...I,cardKey:Bt({kind:"working",diffType:"uncommitted"},I.path)})),j=(c?.committed||[]).filter(W).map(I=>({...I,cardKey:Bt({kind:"working",diffType:"committed"},I.path)}));return{uncommitted:z,committed:j,commitFiles:[]}},[d,c,k,m]),F=d.kind==="commit"?M:[...P,...H],U=A.useMemo(()=>ch(F),[F]),N=A.useMemo(()=>{let W=0,z=0;for(const j of F)W+=j.additions??0,z+=j.deletions??0;return{additions:W,deletions:z,files:F.length}},[F]),D=A.useCallback(()=>{const W=R.current;if(!W)return;const z=W.getBoundingClientRect().top;let j=null,I=Number.NEGATIVE_INFINITY;for(const[X,Y]of E.current){const Z=Y.getBoundingClientRect().top-z;Z<=48&&Z>I&&(I=Z,j=X)}if(!j){let X=null,Y=Number.POSITIVE_INFINITY;for(const[Z,G]of E.current){const te=G.getBoundingClientRect().top-z;te<Y&&(Y=te,X=Z)}j=X}r(j)},[]);A.useEffect(()=>{const W=R.current;if(!W)return;let z=0;const j=()=>{cancelAnimationFrame(z),z=requestAnimationFrame(D)};return W.addEventListener("scroll",j,{passive:!0}),()=>{W.removeEventListener("scroll",j),cancelAnimationFrame(z)}},[D]);const T=A.useCallback(W=>{const z=E.current.get(W.cardKey);z&&(z.scrollIntoView({behavior:"smooth",block:"start"}),r(W.cardKey),l(W.cardKey),O.current&&clearTimeout(O.current),O.current=setTimeout(()=>l(null),1200))},[]),B=A.useCallback(W=>{p(z=>z.kind==="commit"&&z.commit.hash===W.hash?{kind:"overview"}:{kind:"commit",commit:W}),y(""),r(null),R.current?.scrollTo({top:0})},[]),q=A.useCallback(()=>{p({kind:"overview"}),y(""),r(null),R.current?.scrollTo({top:0})},[]);if(!i)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:f("未选择工作区")});const K=w&&e&&n&&h&&S,$=d.kind==="commit"?v:g;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[K&&o&&u&&t.jsx(sh,{projectId:e,workspaceId:n,branchName:h,targetBranch:S,commitMessage:x,committedFileCount:c?.committed?.length,onRefreshCommitMessage:s,onConflict:o,onResolveConflicts:u}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:d.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Pr,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:f("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:f("{count} 个文件",{count:N.files})}),t.jsx(jr,{additions:N.additions,deletions:N.deletions}),h&&S&&t.jsxs("span",{className:"ml-auto flex items-center gap-1 text-[11px] text-muted-foreground/70 font-mono truncate",children:[t.jsx("span",{className:"truncate",children:h}),t.jsx(pr,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:S})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:q,className:"flex items-center gap-1 px-1.5 py-0.5 -ml-1.5 rounded-sm text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 transition-colors shrink-0",children:[t.jsx(pr,{size:12}),f("全部变更")]}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:d.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:d.commit.message}),t.jsx(jr,{className:"ml-auto",additions:N.additions,deletions:N.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:R,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:$?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(W=>t.jsxs("div",{className:"rounded-md border border-border overflow-hidden",children:[t.jsx("div",{className:"h-8 bg-muted/60 animate-pulse"}),t.jsxs("div",{className:"p-3 space-y-2",children:[t.jsx("div",{className:"h-3 w-2/3 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-1/2 bg-muted animate-pulse rounded-sm"}),t.jsx("div",{className:"h-3 w-3/4 bg-muted animate-pulse rounded-sm"})]})]},W))}):_&&d.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:f("变更加载失败")}):F.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(Ht,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:m.trim()?f("没有匹配筛选条件的文件"):d.kind==="commit"?f("该提交没有文件变更"):f("没有待审查的变更")})]}):d.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:M.map(W=>t.jsx(ur,{entry:W,source:{kind:"commit",hash:d.commit.hash},workingDir:i,flash:a===W.cardKey,registerNode:L},W.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[P.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:f("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:P.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:P.map(W=>t.jsx(ur,{entry:W,source:{kind:"working",diffType:"uncommitted"},workingDir:i,flash:a===W.cardKey,registerNode:L},W.cardKey))})]}),H.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:f("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:H.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:H.map(W=>t.jsx(ur,{entry:W,source:{kind:"working",diffType:"committed"},workingDir:i,flash:a===W.cardKey,registerNode:L},W.cardKey))})]})]})}),t.jsxs("aside",{className:"shrink-0 border-l border-border flex flex-col min-h-0",style:{width:"clamp(15rem, 24%, 22rem)"},children:[t.jsx("div",{className:"p-2 shrink-0",children:t.jsxs("div",{className:"relative",children:[t.jsx(jn,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:m,onChange:W=>y(W.target.value),placeholder:f("筛选文件..."),className:"w-full pl-6.5 pr-2 py-1.5 rounded-md border border-input bg-background text-xs text-foreground placeholder:text-muted-foreground/60 focus:outline-none focus:ring-2 focus:ring-ring/30 focus:border-ring"})]})}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin px-1.5 pb-1.5 min-h-0",children:F.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:m.trim()?f("无匹配文件"):f("暂无变更文件")}):t.jsx(Fi,{node:U,depth:0,activeKey:b,onSelect:T})}),t.jsxs("div",{className:"shrink-0 border-t border-border/60 max-h-[40%] flex flex-col min-h-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 shrink-0",children:[t.jsx(It,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:f("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(hh,{workingDir:i,selectedHash:C,onSelectCommit:B})})]})]})]})]})},fr=50,Es={M:"text-amber-600 border-amber-200 bg-amber-50",A:"text-emerald-600 border-emerald-200 bg-emerald-50",D:"text-red-600 border-red-200 bg-red-50",R:"text-blue-600 border-blue-200 bg-blue-50"};function fh(e){const n=Math.floor(Date.now()/1e3)-e;return n<60?$e("{count}s ago",{count:n}):n<3600?$e("{count}m ago",{count:Math.floor(n/60)}):n<86400?$e("{count}h ago",{count:Math.floor(n/3600)}):n<604800?$e("{count}d ago",{count:Math.floor(n/86400)}):new Date(e*1e3).toLocaleDateString()}function mh(e){const i=e.split("/");return i[i.length-1]||e}function ph(e){const i=e.lastIndexOf("/");return i>0?e.slice(0,i):""}const gh=({line:e,lineNum:i})=>{let n="",h="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?n="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?n="bg-destructive/10":e.startsWith("@@")?(n="bg-info/5",h="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(h="text-muted-foreground/70"),t.jsxs("div",{className:Q("flex",n),children:[t.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-muted-foreground/60 select-none border-r border-border/60",children:i}),t.jsx("span",{className:Q("pl-2 whitespace-pre",h),children:e})]})},vh=({workingDir:e,hash:i,filePath:n})=>{const{t:h}=se(),{data:S,isLoading:x,isError:w}=Li(e,i,n);if(x)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(he,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:h("Loading diff...")})]});if(w)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:h("Failed to load diff.")});const s=S?.diff||"";if(!s.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:h("No diff content available.")});const o=s.split(`
62
+ `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:o.map((u,f)=>t.jsx(gh,{line:u,lineNum:f+1},f))})},_h=({workingDir:e,hash:i,selectedPath:n,onSelectFile:h})=>{const{t:S}=se(),{data:x,isLoading:w}=Ai(e,i);if(w)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(he,{size:12,className:"animate-spin"}),t.jsx("span",{children:S("Loading...")})]});const s=x?.files||[];return s.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:S("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:s.map(o=>{const u=Es[o.status]||Es.M,f=ph(o.path);return t.jsxs("button",{type:"button",onClick:d=>{d.stopPropagation(),h(o.path)},className:Q("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",n===o.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:Q("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",u),children:o.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:mh(o.path)}),f&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:f})]},o.path)})})},bh=({workingDir:e})=>{const{t:i}=se(),n=$t(k=>k.visibleContext),h=$n(e,n),{data:S,isLoading:x,isError:w,fetchNextPage:s,hasNextPage:o,isFetchingNextPage:u}=Vs({queryKey:ge.git.log(e||""),queryFn:({pageParam:k=0})=>ue.get("/git/log",{params:{workingDir:e||"",limit:String(fr),skip:String(k)}}),initialPageParam:0,getNextPageParam:(k,v)=>k.commits.length<fr?void 0:v.length*fr,enabled:!!e,refetchInterval:h,refetchIntervalInBackground:!1,refetchOnWindowFocus:h?"always":!1,refetchOnReconnect:h?"always":!1}),f=S?.pages.flatMap(k=>k.commits)||[],[d,p]=A.useState(null),[m,y]=A.useState(null),[b,r]=A.useState(280),[a,l]=A.useState(!1),c=A.useCallback(k=>{k.preventDefault(),l(!0);const v=k.clientX,E=b,R=L=>{const P=Math.min(480,Math.max(180,E+(L.clientX-v)));r(P)},O=()=>{l(!1),document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",O)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",O)},[b]),g=k=>{d===k?(p(null),y(null)):(p(k),y(null))},_=A.useRef(null);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:i("No workspace selected.")});if(x)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(he,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:i("Loading history...")})]});if(w)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:i("Failed to load history.")});if(f.length===0)return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-muted-foreground/60 bg-background h-full",children:[t.jsx(It,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:i("No commit history")})]});const C=f.find(k=>k.hash===d);return t.jsxs("div",{className:"flex h-full bg-background",style:a?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:b},children:[t.jsx("div",{className:"px-3 py-2.5 border-b border-border/60 shrink-0",children:t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx(It,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:i("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:f.length})]})}),t.jsxs("div",{ref:_,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[f.map(k=>{const v=d===k.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>g(k.hash),className:Q("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",v?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:t.jsx("div",{className:Q("w-2 h-2 rounded-full shrink-0 transition-colors",v?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-1.5",children:[t.jsx("span",{className:"text-[11px] font-mono text-muted-foreground shrink-0",children:k.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:k.message}),t.jsx(Xe,{size:12,className:Q("shrink-0 text-muted-foreground/70 transition-transform",v&&"rotate-90")})]}),t.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:k.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:fh(k.timestamp)})]})]})]}),v&&t.jsxs(t.Fragment,{children:[k.body&&t.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-muted-foreground whitespace-pre-wrap leading-5 border-l-2 border-border ml-3",children:k.body}),t.jsx(_h,{workingDir:e,hash:k.hash,selectedPath:m,onSelectFile:y})]})]},k.hash)}),o&&t.jsx("button",{type:"button",onClick:()=>s(),disabled:u,className:"w-full py-2 text-xs text-muted-foreground hover:text-foreground hover:bg-muted/60 rounded-sm transition-colors flex items-center justify-center gap-1.5",children:u?t.jsxs(t.Fragment,{children:[t.jsx(he,{size:12,className:"animate-spin"})," ",i("Loading...")]}):i("Load more")})]})]}),t.jsx("div",{onMouseDown:c,className:Q("w-1 shrink-0 cursor-col-resize transition-colors",a?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:m&&d?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"px-3 py-2 border-b border-border/60 flex items-center gap-2 shrink-0",children:[t.jsx(Ht,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:m}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",C?.shortHash,")"]})]}),t.jsx(vh,{workingDir:e,hash:d,filePath:m})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/60",children:t.jsxs("div",{className:"flex flex-col items-center gap-2",children:[t.jsx(Ht,{size:28}),t.jsx("span",{className:"text-xs",children:i(d?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},js=Rr();function xh(e){if(!js)return e;try{const i=new URL(js);return new URL(e,i.origin).toString()}catch{return e}}function Hi(e){return{...e,viewUrl:e.viewUrl?xh(e.viewUrl):null}}function Sh(e,i=!0){return Le({queryKey:ge.previews.status(e??""),queryFn:async()=>{const n=await ue.get(`/previews/${e}/status`);return Hi(n)},enabled:!!e&&i,refetchOnWindowFocus:!1})}function yh(e){const i=dt();return Ds({mutationFn:async n=>{const h=await ue.put(`/previews/${e}/config`,{target:n});return Hi(h)},onSuccess:n=>{e&&(i.setQueryData(ge.previews.status(e),n),i.invalidateQueries({queryKey:ge.workspaces.all}))}})}function wh(){return window.location.protocol==="https:"?"remote":"local"}function Ch(e,i,n=!0){const[h,S]=A.useState(null),[x,w]=A.useState(!1),[s,o]=A.useState(null),[u,f]=A.useState(0);return A.useEffect(()=>{if(!n||!e||!i?.ready||!i.target){S(null),w(!1),o(null);return}let d=!1,p=null,m=null;S(null);const y=r=>{ue.delete(`/previews/${e}/sessions/${r}`).catch(()=>{})};return(async()=>{w(!0),o(null);try{const r={mode:wh(),localHostname:window.location.hostname},a=await ue.post(`/previews/${e}/sessions`,r);if(d){y(a.id);return}p=a.id,S(a),m=window.setInterval(async()=>{if(p)try{const l=await ue.post(`/previews/${e}/sessions/${p}/heartbeat`);d||(S(l),o(null))}catch(l){!d&&l instanceof Ut&&l.status===404?f(c=>c+1):d||o(l instanceof Error?l:new Error("Preview session heartbeat failed"))}},3e4)}catch(r){d||(S(null),o(r instanceof Error?r:new Error("Failed to open preview session")))}finally{d||w(!1)}})(),()=>{d=!0,m!==null&&window.clearInterval(m),p&&y(p)}},[n,u,i?.ready,i?.target,e]),{session:h,isOpening:x,error:s,retry:()=>f(d=>d+1)}}const kh="agent-tower-preview",Eh="agent-tower-preview-host";function jh(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Nh(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function Rh(e){return t.jsx(Ah,{...e},e.workspaceId??"no-workspace")}function Ah({workspaceId:e,readOnly:i,navigationRequest:n,onNavigationRequestHandled:h}){const{t:S}=se(),[x,w]=A.useState(null),o=!(n?.source.kind==="visualization")&&!x,{data:u,isLoading:f,refetch:d,isFetching:p}=Sh(e,o),m=yh(e),{session:y,isOpening:b,error:r,retry:a}=Ch(e,u,o),l=A.useRef(null),c=A.useRef(null),g=A.useRef(null),_=A.useRef(null),C=A.useRef(null),k=A.useRef(null),[v,E]=A.useState(0),[R,O]=A.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),L=Nh(y?.viewUrl),P=u&&R.target!==u.target?{target:u.target,address:u.target??"",iframeSrc:null,isFrameLoading:!1}:u&&!u.ready&&R.iframeSrc?{...R,iframeSrc:null,isFrameLoading:!1}:R,H=A.useCallback(K=>{O($=>({...u&&$.target!==u.target?{target:u.target,address:u.target??"",iframeSrc:null,isFrameLoading:!1}:$,...K}))},[u]);A.useEffect(()=>{if(!y||y.target!==u?.target)return;const K=C.current!==L;C.current=L,O($=>{const W=n?.source.kind==="web"&&k.current!==n.id?Rt(n.source.url,y.target,y.viewUrl):null;if(!K&&$.iframeSrc&&$.target===y.target&&W?.kind!=="proxy")return $;let z=$.iframeSrc;if(W?.kind==="proxy")z=W.url;else if(!z||$.target!==y.target||K){const I=g.current;if(I)z=vn(y.viewUrl,I);else{const X=Rt($.address||y.target,y.target,y.viewUrl);z=X?.kind==="proxy"?X.url:y.viewUrl}}g.current=null;const j=_.current;return j&&!j.closed&&z&&j.location.replace(z),_.current=null,{target:y.target,address:W?.kind==="proxy"?n?.source.kind==="web"?n.source.url:$.address:$.address||y.target,iframeSrc:z,isFrameLoading:!!z}})},[n,y,L,u?.target]),A.useEffect(()=>()=>{_.current?.close()},[]);const M=A.useCallback(async(K,$=!1)=>{const W=Rt(K,u?.target??null,y?.viewUrl??null);if(!W||!e)return;if(w(null),W.kind==="proxy"){if($){window.open(W.url,"_blank","noopener,noreferrer");return}O({target:u?.target??null,address:K,iframeSrc:W.url,isFrameLoading:!0});return}if(i)return;const z=$?window.open("about:blank","_blank"):null;z&&(z.opener=null);try{g.current=W.path,_.current=z;const j=await m.mutateAsync(W.target);O({target:j.target,address:K.trim(),iframeSrc:null,isFrameLoading:!!j.ready}),E(I=>I+1),Se.success(S("Preview target saved")),j.ready||(_.current?.close(),_.current=null)}catch(j){_.current?.close(),_.current=null,g.current=null;const I=j instanceof Error?j.message:S("Failed to save preview target");Se.error(I)}},[y?.viewUrl,i,u?.target,S,m,e]);A.useEffect(()=>{if(!n||k.current===n.id||n.source.kind==="web"&&f)return;const K=window.setTimeout(()=>{k.current=n.id,h?.(n.id),n.source.kind==="visualization"?(w({source:n.source,iframeSrc:_n(n.source.sessionId,n.source.file),isFrameLoading:!0}),E($=>$+1)):(w(null),M(n.source.url))},0);return()=>window.clearTimeout(K)},[f,M,n,h]),A.useEffect(()=>{if(x)return;const K=$=>{if($.source!==l.current?.contentWindow)return;const W=$.data;if(!(!W||W.source!==kh)){if(W.type==="location"&&typeof W.href=="string"){const z=bn(u?.target??null,y?.viewUrl??null,W.href,window.location.href);z&&document.activeElement!==c.current&&H({target:u?.target??P.target,address:z,isFrameLoading:!1});return}W.type==="navigate-loopback"&&typeof W.href=="string"&&M(W.href,W.newTab===!0)}};return window.addEventListener("message",K),()=>window.removeEventListener("message",K)},[P.target,M,H,y?.viewUrl,u?.target,x]);const F=K=>{l.current?.contentWindow?.postMessage({source:Eh,action:K},"*")},U=K=>{K.preventDefault(),M(P.address)},N=async()=>{if(x){w($=>$&&{...$,isFrameLoading:!0}),E($=>$+1);return}const K=await d();if(!K.data?.ready){H({target:K.data?.target??P.target,iframeSrc:null,isFrameLoading:!1});return}if(!y||!P.iframeSrc){a();return}H({isFrameLoading:!0}),F("reload")},D=()=>{if(x){window.open(x.iframeSrc,"_blank","noopener,noreferrer");return}if(!y?.viewUrl)return;const K=Rt(P.address||y.target,y.target,y.viewUrl),$=K?.kind==="proxy"?K.url:y.viewUrl;window.open($,"_blank","noopener,noreferrer")};if(!e)return t.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:S("No active workspace.")});const T=x?.iframeSrc??P.iframeSrc,B=!!x,q=!B&&(f||p||m.isPending||b);return t.jsxs("div",{className:"h-full flex flex-col bg-white",children:[t.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-2 py-2",children:[t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>{B?w(null):F("back")},disabled:!B&&!P.iframeSrc,title:S("Back"),"aria-label":S("Back"),children:t.jsx(pr,{})}),t.jsx(ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>F("forward"),disabled:B||!P.iframeSrc,title:S("Forward"),"aria-label":S("Forward"),children:t.jsx(Gs,{})}),t.jsx(ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:!B&&P.isFrameLoading?()=>{F("stop"),H({isFrameLoading:!1})}:N,disabled:!B&&!P.isFrameLoading&&p,title:!B&&P.isFrameLoading?S("Stop loading"):S("Refresh preview"),"aria-label":!B&&P.isFrameLoading?S("Stop loading"):S("Refresh preview"),children:!B&&P.isFrameLoading?t.jsx(Ve,{}):p?t.jsx(he,{className:"animate-spin"}):t.jsx(ht,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:U,children:[t.jsx(lo,{className:"pointer-events-none absolute left-2.5 top-1/2 size-3.5 -translate-y-1/2 text-neutral-400"}),t.jsx("input",{ref:c,value:x?.source.file??P.address,onChange:K=>H({address:K.target.value}),onKeyDown:K=>{K.key==="Enter"&&K.nativeEvent.isComposing&&K.preventDefault()},disabled:B||i||m.isPending,placeholder:jh(),"aria-label":S("Preview address"),className:"h-8 w-full min-w-0 rounded-md border border-neutral-200 bg-white pl-8 pr-2.5 text-xs text-neutral-800 outline-none transition-colors placeholder:text-neutral-400 focus:border-neutral-400 disabled:bg-neutral-100 disabled:text-neutral-400"})]}),t.jsx(ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:D,disabled:!T,title:S("Open preview in new tab"),"aria-label":S("Open preview in new tab"),children:t.jsx(Nr,{})})]}),t.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 px-1 text-[11px] leading-4",children:[t.jsx("span",{className:"truncate text-neutral-500",children:B?S("Viewing agent visualization"):q?S("Checking preview target..."):r?r.message:u?.ready?`${S("Proxying")} ${u.target}`:u?.configured?`${S("Preview target is not reachable")}${u.error?`: ${u.error}`:""}`:S("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:S(B?"Session file":"Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:T?t.jsx("iframe",{ref:l,src:T,title:S("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:B?"allow-modals allow-pointer-lock allow-presentation allow-scripts":"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts",allow:"clipboard-read; clipboard-write; fullscreen",onLoad:()=>{B?w(K=>K&&{...K,isFrameLoading:!1}):H({isFrameLoading:!1})}},v):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:u?.configured?u.ready&&b?S("Checking preview target..."):S("Start the preview server, then refresh."):S("Configure a local preview target to display it here.")})})]})}function Lh(e){switch(e){case Oe.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Oe.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Oe.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Oe.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Ns(e){switch(e){case"Main":return"border-indigo-200 bg-indigo-50 text-indigo-700";case"Child":return"border-cyan-200 bg-cyan-50 text-cyan-700";default:return"border-neutral-200 bg-neutral-50 text-neutral-600"}}function Ph(e){return e.length<=34?e:`...${e.slice(-31)}`}function Th({workspaces:e,teamRun:i,selectedWorkspaceId:n,onSelectWorkspace:h,disabled:S,className:x,buttonClassName:w}){const{t:s}=se(),[o,u]=A.useState(!1),f=A.useRef(null),d=A.useMemo(()=>Mr(e,i),[e,i]),p=d.find(m=>m.workspace.id===n)??d[0];return A.useEffect(()=>{if(!o)return;const m=y=>{f.current&&!f.current.contains(y.target)&&u(!1)};return document.addEventListener("mousedown",m),()=>document.removeEventListener("mousedown",m)},[o]),d.length<=1?null:t.jsxs("div",{ref:f,className:Q("relative",x),children:[t.jsxs("button",{type:"button",onClick:()=>u(m=>!m),disabled:S,className:Q("inline-flex h-8 max-w-[340px] items-center gap-2 rounded-md border border-neutral-200 bg-white px-2.5 text-left text-xs text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50 disabled:cursor-not-allowed disabled:opacity-50",w),title:s("Workspace"),children:[t.jsx(gr,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Ns(p.roleLabel)),children:s(p.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:s(p.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:Ph(St(p.workspace))}),t.jsx(We,{size:13,className:Q("shrink-0 text-neutral-400 transition-transform",o&&"rotate-180")})]}),o&&t.jsx("div",{className:"absolute left-0 top-full z-50 mt-2 w-[420px] max-w-[calc(100vw-2rem)] rounded-lg border border-neutral-200 bg-white py-1.5 shadow-lg",children:d.map(m=>{const y=m.workspace.id===p.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{h(m.workspace.id),u(!1)},className:Q("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",y&&"bg-neutral-50"),children:[t.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:y?t.jsx(ct,{size:13}):t.jsx(Ws,{size:13})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:s(m.displayName)}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Ns(m.roleLabel)),children:s(m.roleLabel)}),t.jsx("span",{className:Q("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Lh(m.workspace.status)),children:m.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:St(m.workspace)}),t.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[m.ownerName&&t.jsxs("span",{children:[s("Owner"),": ",m.ownerName]}),m.parentBranchName&&t.jsxs("span",{children:[s("Parent"),": ",m.parentBranchName]}),t.jsx("span",{children:m.workspace.id.slice(0,8)})]})]})]},m.workspace.id)})})]})}const Mh=[{key:"review",label:"Changes",icon:t.jsx(Pr,{size:14})},{key:"editor",label:"Editor",icon:t.jsx($s,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(_t,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ys,{size:14})}],Dh=[{key:"history",label:"History",icon:t.jsx(It,{size:14})},{key:"editor",label:"Editor",icon:t.jsx($s,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(_t,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(Ys,{size:14})}],Bh=({active:e,onClick:i,icon:n,label:h})=>t.jsxs("button",{type:"button",onClick:i,className:Q("flex shrink-0 items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px whitespace-nowrap",e?"bg-white border-neutral-200 text-neutral-900 shadow-[0_-2px_6px_rgba(0,0,0,0.02)] z-10":"bg-transparent border-transparent text-neutral-500 hover:text-neutral-700 hover:bg-neutral-200/50"),children:[n,t.jsx("span",{children:h})]}),Oh=({active:e,onClick:i,icon:n,label:h})=>t.jsx("button",{type:"button",onClick:i,title:h,"aria-label":h,"aria-pressed":e,className:Q("flex h-9 w-9 items-center justify-center rounded-lg border text-muted-foreground transition-colors focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",e?"border-neutral-900 bg-neutral-900 text-white shadow-sm":"border-transparent hover:border-border hover:bg-background hover:text-foreground"),children:n}),Bu=me.memo(function({className:i,sessionId:n,workspaceId:h,workingDir:S,projectId:x,hideChanges:w,gitAvailable:s=!0,readOnly:o,repoDeleted:u,teamRun:f,teamStatus:d,gitProps:p,workspaces:m,selectedWorkspaceId:y,onSelectWorkspace:b,variant:r="tabs",expanded:a,onExpandedChange:l,minContentWidth:c=520,tabRef:g,previewRequest:_,onPreviewRequestHandled:C}){const{t:k}=se(),v=$t(J=>J.setVisibleContext),E=r==="rail",[R,O]=A.useState(!1),L=E?a??R:!0,P=A.useCallback(J=>{a===void 0&&O(J),l?.(J)},[a,l]),H=A.useMemo(()=>{const J=w?Dh:Mh,ne=s?J:J.filter(ye=>ye.key!=="review"&&ye.key!=="history"),re=o?ne.filter(ye=>ye.key!=="terminal"):ne;return f?[{key:"team-status",label:"Team Status",icon:t.jsx(lt,{size:14})},...re]:re},[s,w,o,f]),[M,F]=A.useState(()=>_?"preview":s?w?"history":"review":"editor"),U=A.useRef(null),N=A.useRef(0),[D,T]=A.useState(),B=A.useCallback(J=>{F(J),E&&P(!0)},[E,P]);A.useImperativeHandle(g,()=>({setTab:J=>B(J),openFile:(J,ne,re)=>{B("editor"),requestAnimationFrame(()=>U.current?.openFile(J,ne,re))},openPreview:(J,ne)=>{N.current+=1,T({id:N.current,source:J,workspaceId:ne}),B("preview")}}),[B]);const q=_??D,K=q?.workspaceId&&q.workspaceId!==h?void 0:q,$=A.useCallback(J=>{T(ne=>ne?.id===J?void 0:ne),C?.(J)},[C]),{data:W}=Kn(x??""),z=A.useMemo(()=>{if(!W?.quickCommands)return[];try{return JSON.parse(W.quickCommands)}catch{return[]}},[W?.quickCommands]),[j,I]=A.useState([]),X=A.useRef(void 0);A.useEffect(()=>{S&&S!==X.current&&(X.current=S,I(J=>J.includes(S)?J:[...J,S]))},[S]),A.useEffect(()=>{H.some(J=>J.key===M)||F(H[0]?.key??"editor")},[M,H]),A.useEffect(()=>{if(E&&!L)return;const J=M==="review"?"changes":M==="history"?"history":null;if(!h||!S||!J){v(null);return}return v({workspaceId:h,workingDir:S,tab:J}),()=>{v(null)}},[M,L,E,v,S,h]);const Y=!!b&&Mr(m,f).length>1,Z=H.find(J=>J.key===M)??H[0],G=Z?k(Z.label):"",te=o?t.jsx("div",{className:"mx-2 mt-2 rounded-lg border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:k(u?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,le=t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[Y&&t.jsx("div",{className:"shrink-0 px-3 py-1.5 border-b border-neutral-100 bg-neutral-50/60",children:t.jsx(Th,{workspaces:m,teamRun:f,selectedWorkspaceId:y,onSelectWorkspace:b,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[M==="team-status"&&f&&d,M==="editor"&&t.jsx(Gd,{ref:U,workingDir:S,readOnly:o}),j.map(J=>{const ne=M==="terminal"&&S===J;return t.jsx("div",{"aria-hidden":!ne,className:"absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",style:{display:ne?"block":"none"},children:t.jsx(ll,{cwd:J,workspaceId:ne?h:void 0,isVisible:ne,quickCommands:z})},J)}),M==="preview"&&t.jsx(Rh,{workspaceId:h,readOnly:o,navigationRequest:K,onNavigationRequestHandled:$}),M==="review"&&t.jsx(uh,{projectId:x,workingDir:S,workspaceId:h,branchName:p?.branchName,targetBranch:p?.targetBranch,commitMessage:p?.commitMessage,canRunGitOperations:p?.canRunGitOperations,onRefreshCommitMessage:p?.onRefreshCommitMessage,onConflict:p?.onConflict,onResolveConflicts:p?.onResolveConflicts}),M==="history"&&t.jsx(bh,{workingDir:S})]})]});return E?t.jsxs("div",{className:Q("flex h-full w-full min-w-0 bg-white",i),children:[t.jsx("div",{className:"flex h-full w-12 shrink-0 flex-col items-center gap-1 border-l border-border bg-muted/35 px-1.5 py-2",children:H.map(J=>t.jsx(Oh,{active:L&&M===J.key,onClick:()=>B(J.key),icon:J.icon,label:k(J.label)},J.key))}),L&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:c},children:[te,t.jsxs("div",{className:"flex h-10 shrink-0 items-center justify-between gap-3 border-b border-border bg-background px-3",children:[t.jsxs("div",{className:"flex min-w-0 items-center gap-2 text-sm font-semibold text-foreground",children:[t.jsx("span",{className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-lg border border-border bg-muted/35 text-muted-foreground",children:Z?.icon}),t.jsx("span",{className:"truncate",children:G})]}),t.jsx("button",{type:"button",onClick:()=>P(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:k("收起"),"aria-label":k("收起"),children:t.jsx(Co,{size:15})})]}),le]})]}):t.jsxs("div",{className:Q("flex h-full w-full min-w-0 flex-col bg-white",i),children:[o&&te,t.jsx("div",{className:"flex items-center overflow-x-auto scrollbar-app-thin px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:H.map(J=>t.jsx(Bh,{active:M===J.key,onClick:()=>B(J.key),icon:J.icon,label:k(J.label)},J.key))}),le]})}),Ih=3e3;function Rs(e,i){const n=new Map(e.map(h=>[h.workspaceId,h]));for(const h of i){const S=n.get(h.workspaceId);(!S||h.updatedAt>=S.updatedAt)&&n.set(h.workspaceId,h)}return[...n.values()]}function Ou(e){const i=dt(),n=A.useRef({version:0,values:new Map}),[h,S]=A.useState(0),{data:x=[]}=Le({queryKey:ge.workspaces.setupProgress(e??""),enabled:!!e,refetchOnMount:"always",refetchInterval:u=>u.state.data?.some(f=>f.status==="running")?3e3:!1,queryFn:async({signal:u})=>{const f=n.current.version,d=await ue.get(`/tasks/${e}/setup-progress`,{signal:u}),p=[...n.current.values.values()].filter(m=>m.version>f&&m.progress.taskId===e).map(m=>m.progress);return Rs(d,p)}});A.useEffect(()=>{if(!e)return;const u=ot.connect(),f=ge.workspaces.setupProgress(e),d=m=>{if(m.taskId!==e)return;const y=n.current.values.get(m.workspaceId);y&&y.progress.updatedAt>m.updatedAt||(n.current.values.set(m.workspaceId,{version:++n.current.version,progress:m}),i.setQueryData(f,b=>Rs(b??[],[m])))},p=()=>{i.invalidateQueries({queryKey:f})};return u.on(Be.WORKSPACE_SETUP_PROGRESS,d),u.on("connect",p),()=>{u.off(Be.WORKSPACE_SETUP_PROGRESS,d),u.off("connect",p)}},[e,i]);const w=[...x].sort((u,f)=>f.updatedAt-u.updatedAt),s=w.find(u=>u.status==="running")??w.find(u=>u.status!=="running"&&u.updatedAt>h),o=s?.status!=="running"?s?.updatedAt??null:null;return A.useEffect(()=>{if(o===null)return;const u=setTimeout(()=>S(o),Ih);return()=>clearTimeout(u)},[o]),s??null}function Iu({isOpen:e,onClose:i,onStarted:n,taskId:h,projectId:S,taskTitle:x,taskDescription:w,taskPrompt:s,projectIsGitRepo:o=!0,projectWorktreeReady:u=!0,projectGitReason:f}){const{t:d}=se(),[p,m]=A.useState(""),[y,b]=A.useState(""),[r,a]=A.useState(He.WORKTREE),[l,c]=A.useState(null),[g,_]=A.useState("idle"),[C,k]=A.useState(null),v=dt(),E=Un(h),R=Dn(),O=Xn(),{data:L,isLoading:P}=Ar(),H=l?.isGitRepo??o,M=l?.worktreeReady??u,F=l?.reason??f,U=H!==!1&&M!==!1;A.useEffect(()=>{if(!e||!L)return;const Z=L.find(G=>!st(G));m(G=>G&&L.some(te=>te.provider.id===G)?G:Z?.provider.id??"")},[e,L]),A.useEffect(()=>{if(e){const Z=[x];w&&Z.push(w),b(s?.trim()||Z.join(`
63
+
64
+ `)),c(null),a(o!==!1&&u!==!1?He.WORKTREE:He.MAIN_DIRECTORY),_("idle"),k(null)}},[e,o,u,h,x,w,s]),A.useEffect(()=>{U||a(He.MAIN_DIRECTORY)},[U]);const N=async()=>{if(!S||O.isPending)return;const Z=await O.mutateAsync({id:S});c(Z),Z.worktreeReady&&a(He.WORKTREE)},D=g!=="idle",T=async()=>{if(!p||!y.trim())return;const Z=L?.find(G=>G.provider.id===p);if(!(!Z||st(Z))){k(null);try{_("creating-workspace");const G=await E.mutateAsync({workspaceKind:U?r:He.MAIN_DIRECTORY});_("creating-session");const te=await ue.post(`/workspaces/${G.id}/sessions`,{providerId:p,prompt:y.trim()});_("starting-session"),await R.mutateAsync(te.id),await v.invalidateQueries({queryKey:ge.workspaces.list(h)}),_("idle"),n?.(),i()}catch(G){_("idle"),k(G instanceof Error?G.message:d("启动失败,请重试"))}}},B={idle:d("启动"),"creating-workspace":d("创建工作空间..."),"creating-session":d("创建会话..."),"starting-session":d("启动 Agent...")},q=(L??[]).map(Z=>{const G=Z.provider,te=st(Z),le=!te,J=G.executionPermission?d("Required permission: {mode}",{mode:d(Yn[G.executionPermission])}):void 0;return{value:G.id,label:le?G.name:`${G.name}${d(" (不可用)")}`,description:[J,te&&d(te)].filter(Boolean).join(" · "),icon:t.jsx(qt,{agentType:G.agentType,className:"size-4"}),disabled:!le}}),K=L?.find(Z=>Z.provider.id===p),$=K?st(K):void 0,W=!!L?.length&&L.every(Z=>!!st(Z)),z=!P&&!L?.length,j=d("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),I=d("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),X=d(F==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),Y=[{value:He.WORKTREE,label:d("工作树模式"),description:j,disabled:!U},{value:He.MAIN_DIRECTORY,label:d("本地模式"),description:I}];return t.jsx(Ct,{isOpen:e,onClose:D?()=>{}:i,title:d("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(ae,{variant:"outline",onClick:i,disabled:D,children:d("取消")}),t.jsx(ae,{onClick:T,disabled:D||!K||!y.trim()||!!$,children:B[g]})]}),children:t.jsxs("div",{className:"space-y-5",children:[t.jsx("div",{children:t.jsxs("div",{className:"grid grid-cols-1 gap-3 sm:grid-cols-2",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:d("Agent")}),t.jsx(ze,{value:p,onChange:m,options:q,placeholder:d(P?"加载中...":"选择 Agent"),disabled:D||P}),$?t.jsx("p",{role:"alert",className:"mt-2 break-words text-xs leading-snug text-destructive",children:d($)}):null,W&&!K?t.jsxs("div",{role:"alert",className:"mt-2 space-y-1 break-words text-xs leading-snug text-destructive",children:[t.jsx("p",{children:d("No available Provider for this session.")}),t.jsx("ul",{className:"space-y-1",children:L.map(Z=>t.jsxs("li",{children:[Z.provider.name,": ",d(st(Z))]},Z.provider.id))})]}):null,z?t.jsx("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:d("No available Provider for this session.")}):null]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:d("模式")}),U?t.jsx(ze,{value:r,onChange:Z=>a(Z),options:Y,disabled:D}):t.jsx(wn,{side:"bottom",className:"w-full",content:X,children:t.jsxs("div",{tabIndex:0,"aria-label":X,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(ze,{value:r,onChange:Z=>a(Z),options:Y,disabled:!0}),t.jsx("button",{type:"button",onClick:N,disabled:D||O.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:O.isPending?d("检测中..."):d("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:d("任务描述")}),t.jsx("textarea",{value:y,onChange:Z=>b(Z.target.value),rows:5,disabled:D,placeholder:d("描述你想让 Agent 完成的任务..."),className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm text-neutral-900 placeholder-neutral-400 focus:outline-none focus:ring-1 focus:ring-neutral-300 focus:border-neutral-300 resize-none disabled:opacity-50 disabled:bg-neutral-50"})]}),C&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:C})]})})}function Fu(e){const i=e?.tokenUsage;if(!(!i||typeof i.totalTokens!="number"))return i}function Fh(e,i,n){const h=e?.providerId??n?.providerId??null,S=h?i?.find(o=>o.provider.id===h)?.provider:null,x=S?.name??h??e?.agentType??n?.agentType??null;if(!x)return null;const w=e?.agentType??S?.agentType??n?.agentType??null,s=h&&S?.name&&h!==S.name?`${S.name} (${h})`:x;return{label:x,title:s,agentType:w}}function Hu({session:e,providers:i,usage:n,compact:h=!1,providerIdFallback:S,agentTypeFallback:x,tokenTooltipSide:w="top"}){const{t:s}=se(),o=Fh(e,i,{providerId:S,agentType:x});return!o&&!n?null:t.jsxs("div",{className:`flex shrink-0 items-center ${h?"gap-1":"gap-2"}`,children:[o&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${h?"max-w-[130px] min-w-[82px] gap-1 px-1.5 py-1 text-[11px]":"max-w-[220px] min-w-[110px] gap-1.5 px-2 py-1.5 text-xs"}`,title:`${s("Provider")}: ${o.title}`,children:[t.jsx(qt,{agentType:o.agentType,className:h?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:ln(o.label,h?12:18)})]}),t.jsx(Rn,{usage:n,tooltipSide:w})]})}function Wi(e){return e.length>0?e.map(i=>`- ${i}`).join(`
65
+ `):"- 未获取到冲突文件列表"}function zi(e){if(!e)return[];const i=[];return e.workspaceId&&i.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&i.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&i.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&i.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&i.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&i.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&i.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&i.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&i.push("- Merge state: conflict detected and already aborted by Agent Tower"),i}function Hh(e,i){if(!i?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const n=i.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,h=i.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${n}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${h} 完成合并`]}function Wh(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const i=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,n=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${i}中确认工作区干净,重新执行 \`${n}\` 复现冲突,解决后完成提交并汇报验证结果。`}function zh(e,i,n,h,S){const x=Wi(n),w=zi(S);return h===xt.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${i}\` 时发生了冲突。`,...w.length>0?["","### 上下文",...w]:[],"","### 冲突文件",x,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
66
+ `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${i}\` 时发生了冲突。`,...w.length>0?["","### 上下文",...w]:[],"","### 冲突文件",x,"","### 解决步骤",...Hh(e,S)].join(`
67
+ `)}function $h(e){const i=e.conflictOp===xt.REBASE?"Rebase":"Merge",n=Wi(e.conflictedFiles),h=[...zi(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${i} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${i} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...h,"","### 冲突文件",n,"","### 用户意图",e.conflictOp===xt.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":Wh(e)].join(`
68
+ `)}function Uh(e){if(e.teamRunId)return{type:"team_room",message:$h(e)};const i=e.currentSessionId||e.selectedSessionId;return i?{type:"session",sessionId:i,message:zh(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Wu({open:e,onOpenChange:i,workspaceId:n,conflictOp:h,conflictedFiles:S,sourceBranch:x,targetBranch:w,operation:s,worktreePath:o,mergeAborted:u,mergeStrategy:f,sourceWorkspaceId:d,targetWorkspaceId:p,sourceWorktreePath:m,targetWorktreePath:y,sessions:b,currentSessionId:r,teamRunId:a}){const{t:l}=se(),[c,g]=A.useState(""),_=Bn(),C=cn(a??""),k=qn(),v=!!a,E=r||c,R=v?C.isPending:_.isPending,O=()=>{const F=Uh({workspaceId:n,worktreePath:o,operation:s,mergeAborted:u,mergeStrategy:f,sourceWorkspaceId:d,targetWorkspaceId:p,sourceWorktreePath:m,targetWorktreePath:y,sourceBranch:x,targetBranch:w,conflictedFiles:S,conflictOp:h,teamRunId:a,currentSessionId:r,selectedSessionId:c});if(F.type==="team_room"){C.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{Se.success(l("已发送到 Team Room")),i(!1)}});return}F.type==="session"&&_.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>i(!1)})},L=()=>{k.mutate({workspaceId:n},{onSuccess:()=>i(!1)})},P=h==="REBASE"?"Rebase":"Merge",H=!v&&!r&&b.length>0,M=v||!!E;return t.jsx(Ct,{isOpen:e,onClose:()=>i(!1),title:l("解决 {opLabel} 冲突",{opLabel:P}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(ae,{variant:"outline",onClick:L,children:l("在 IDE 中打开")}),t.jsx(ae,{onClick:O,disabled:!M||R,children:l(R?"发送中...":"AI 辅助解决")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:l("冲突文件({count})",{count:S.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:S.map(F=>t.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:F},F))})]}),v&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:l("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),H&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:l("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:c,onChange:F=>g(F.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[t.jsx("option",{value:"",children:l("选择一个 Session...")}),b.map(F=>t.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!v&&!E&&b.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:l("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function qh(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((n,h)=>({files:n.files+1,additions:n.additions+(h.additions??0),deletions:n.deletions+(h.deletions??0)}),{files:0,additions:0,deletions:0})}function As(e,i,n,h){const S=Di(e);if(S){n(S);return}h(e instanceof Error?e.message:i)}function zu({projectId:e,workspaceId:i,branchName:n,targetBranch:h,commitMessage:S,changes:x,gitStatus:w,isGitStatusLoading:s,canRunGitOperations:o,onOpenChanges:u,onRefreshCommitMessage:f,onConflict:d,className:p}){const{t:m}=se(),y=qs(),b=Ks(),r=Xs(),[a,l]=A.useState(!1),[c,g]=A.useState(null),_=Br(i,a),C=(_.data??[]).filter(Pi),k=A.useMemo(()=>qh(x),[x]),v=k.additions+k.deletions,E=k.files>0&&v>0,R=(w?.conflictedFiles.length??0)>0,O=!!(w&&w.operation!=="idle"),L=!!(w&&(w.hasUncommittedChanges||w.untrackedCount>0)),P=(w?.uncommittedCount??0)+(w?.untrackedCount??0),H=(w?.behind??0)>0,M=(w?.ahead??0)>0,F=s||!w&&o,U=!!(o&&i&&w&&H&&!R&&!O&&!L),N=!!(o&&i&&w&&M&&!H&&!R&&!O&&!L),D=!!(o&&i&&w&&!R&&!O&&!L);if(A.useEffect(()=>{a&&f?.()},[a,f]),!E)return null;const T=R?m("冲突"):w?.operation==="rebase"?m("变基中"):w?.operation==="merge"?m("合并中"):P>0?m("{count} 未提交",{count:P}):H?m("落后 {count}",{count:w?.behind??0}):m(M?"可合并":"已是最新"),B=m("{files} 个文件 · {lines} 行",{files:k.files,lines:v}),q=()=>{U&&(g(null),y.mutate(i,{onError:z=>{As(z,m("更新失败,请稍后重试"),j=>d(j),g)}}))},K=()=>{D&&(g(null),l(!0))},$=(z,j)=>{g(null),b.mutate({id:i,commitMessage:z,stopActiveServices:j},{onSuccess:()=>l(!1),onError:I=>{if(Ti(I)){g(m("后台服务仍在运行,请确认停止服务后再提交。"));return}As(I,m("提交失败,请稍后重试"),X=>{l(!1),d(X)},g)}})},W=()=>{b.isPending||(l(!1),g(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Q("space-y-1",p),children:[t.jsxs("div",{className:"flex items-center gap-1.5 rounded-lg bg-muted/25 px-2 py-1.5",children:[t.jsxs("button",{type:"button",onClick:u,className:"flex min-w-0 flex-1 items-center gap-1.5 rounded-md px-1.5 py-0.5 text-left transition-colors hover:bg-muted/55 focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40","aria-label":m("查看变更详情"),children:[t.jsx("span",{className:"flex h-6 w-6 shrink-0 items-center justify-center rounded-md bg-background/70 text-muted-foreground",children:t.jsx(Pr,{size:13})}),t.jsxs("span",{className:"flex min-w-0 flex-1 items-center gap-2",children:[t.jsx("span",{className:"truncate text-xs font-medium text-foreground",children:B}),t.jsxs("span",{className:"hidden shrink-0 items-center gap-1 font-mono text-[11px] sm:inline-flex",children:[k.additions>0&&t.jsxs("span",{className:"text-success",children:["+",k.additions]}),k.deletions>0&&t.jsxs("span",{className:"text-destructive",children:["-",k.deletions]})]}),R&&t.jsx(wt,{size:13,className:"shrink-0 text-amber-600"}),t.jsxs("span",{className:"hidden min-w-0 items-center gap-1 text-[11px] text-muted-foreground md:flex",children:[t.jsx("span",{className:"truncate font-mono",children:n}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:h})]}),t.jsx("span",{className:"shrink-0 rounded-full bg-background/75 px-1.5 py-0.5 text-[10px] font-medium text-muted-foreground",children:T})]}),t.jsx(Xe,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[O&&t.jsx("button",{type:"button",onClick:()=>r.mutate(i),disabled:r.isPending,className:"hidden h-7 items-center rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-50 sm:inline-flex",children:r.isPending?m("正在撤销..."):m("撤销操作")}),t.jsxs("button",{type:"button",onClick:q,disabled:!U||y.isPending||F,className:"inline-flex h-7 items-center gap-1.5 rounded-md border border-border/70 bg-background px-2 text-xs font-medium text-foreground/80 transition-colors hover:bg-muted disabled:cursor-not-allowed disabled:opacity-45",title:m(H?"同步更新":"已是最新"),children:[y.isPending?t.jsx(he,{size:12,className:"animate-spin"}):t.jsx(ht,{size:12}),t.jsx("span",{children:y.isPending?m("正在同步..."):m("更新")})]}),t.jsxs("button",{type:"button",onClick:K,disabled:!D||b.isPending||F,className:"inline-flex h-7 items-center gap-1.5 rounded-md bg-primary px-2 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90 disabled:cursor-not-allowed disabled:bg-muted disabled:text-muted-foreground",title:N?m("合并到 {target}",{target:h}):m("提交变更"),children:[b.isPending?t.jsx(he,{size:12,className:"animate-spin"}):t.jsx(Ft,{size:12}),t.jsx("span",{children:b.isPending?m("正在提交..."):m("合并")})]})]})]}),c&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:c})]}),t.jsx(Mi,{projectId:e,workspaceId:i,canMerge:N,isOpen:a,onClose:W,onBaseBranchSaved:u,branchName:n,targetBranch:h,commitMessage:S,isPending:b.isPending,activeServices:C,isCheckingServices:_.isLoading,serviceCheckFailed:_.isError,error:c,onConfirm:$})]})}const Ls=["creating-workspace","creating-session","starting-session"];function $u({state:e,setupProgress:i,sessionStarted:n=!1,onRetry:h,compact:S=!1}){const{t:x}=se(),[w,s]=A.useState(!1),o=e?.status==="failed",u=i?.status==="failed",f=o||u,d=e?Ls.indexOf(e.status):Ls.length,p=[x("Preparing workspace"),x("Creating session"),x("Starting agent")],m=(e?.setupScript??"").split(`
69
+ `).map(r=>r.trim()).filter(Boolean),y=e||n?p.map((r,a)=>({label:r,status:o?"pending":a<d?"completed":a===d?"active":"pending"})):[];(i||m.length>0)&&y.push({label:i?.status==="running"?x("Running setup ({current}/{total})",{current:i.currentIndex??0,total:i.totalCommands}):i?.status==="completed"?x("Setup complete"):i?.status==="failed"?x("Setup failed"):x("Run setup script"),status:i?.status==="running"?"active":i?.status??"pending",description:i?.currentCommand||m.join(`
70
+ `)});const b=!!i?.output?.trim();return!e&&!i?null:t.jsxs("div",{className:`${S?"my-2 mb-4":"my-3 mb-6"} mx-auto w-full max-w-2xl rounded-xl border ${f?"border-destructive/30 bg-destructive/[0.03]":"border-border/70 bg-background"} px-4 py-3 text-left shadow-sm`,role:f?"alert":"status","aria-live":f?"assertive":"polite",children:[f&&(e?.error||i?.error||o)?t.jsx("p",{className:"mb-2 break-words text-xs text-destructive/80",children:e?.error||i?.error||x("Agent start failed")}):null,t.jsx("div",{className:"space-y-2",children:y.map(({label:r,status:a,description:l})=>{const c=a==="completed",g=a==="active";return t.jsxs("div",{className:`flex items-start gap-2 text-sm ${a==="failed"?"text-destructive":c||g?"text-info":"text-muted-foreground"}`,children:[c?t.jsx(dn,{className:"h-4 w-4 shrink-0"}):g?t.jsx(he,{className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none"}):a==="failed"?t.jsx(Bs,{className:"h-4 w-4 shrink-0"}):t.jsx(Gn,{className:"h-4 w-4 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{children:r}),l&&t.jsx("code",{className:"mt-1 block whitespace-pre-wrap break-all rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:l})]})]},r)})}),(b||o)&&t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 border-t border-border/50 pt-2",children:[b?t.jsxs("button",{type:"button",onClick:()=>s(r=>!r),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":w,"aria-controls":"task-start-progress-details",children:[w?t.jsx(We,{className:"h-3.5 w-3.5"}):t.jsx(Xe,{className:"h-3.5 w-3.5"}),x(w?"Hide setup output":"View setup output")]}):t.jsx("span",{}),o&&h?t.jsx(ae,{size:"sm",variant:"outline",onClick:h,children:x("Retry start")}):null]}),w&&t.jsx("div",{id:"task-start-progress-details",className:"mt-2 rounded-md bg-muted/35 px-2.5 py-2 text-xs leading-relaxed text-muted-foreground",children:t.jsx("pre",{className:"whitespace-pre-wrap break-words font-mono",children:i?.output??""})})]})}function Kh({agentType:e,workingDir:i}){return Le({queryKey:ge.system.skillCatalog(e,i),queryFn:async()=>(await ue.get("/system/skill-catalog",{params:{agentType:String(e),...i?{workingDir:i}:{}}})).commands,enabled:e===Fs.CODEX,staleTime:3e4})}function Xh(e){const i=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,n=e.key==="Tab"&&!e.shiftKey;return i||n}function Uu({agentType:e,workingDir:i,input:n,setInput:h,textareaRef:S,minHeight:x,maxHeight:w}){const[s,o]=A.useState(0),{data:u=[]}=Kh({agentType:e,workingDir:i}),d=A.useMemo(()=>e===Fs.CODEX?$r(n):null,[e,n])?.query??null,p=A.useMemo(()=>d===null?[]:On(u,d),[d,u]),m=A.useCallback(()=>{const r=S.current;r&&(r.style.height="auto",r.style.height=`${Math.max(x,Math.min(r.scrollHeight,w))}px`)},[w,x,S]);A.useEffect(()=>{o(0)},[e,d]),A.useEffect(()=>{s<p.length||o(0)},[p.length,s]);const y=A.useCallback(r=>{const a=$r(n);if(!a)return;const l=`${n.slice(0,a.replaceStart)}${r.command} `;h(l),requestAnimationFrame(()=>{const c=S.current;c&&(m(),c.focus(),c.setSelectionRange(l.length,l.length))})},[n,m,h,S]),b=A.useCallback(r=>d===null||p.length===0?!1:r.key==="ArrowDown"?(r.preventDefault(),o(a=>(a+1)%p.length),!0):r.key==="ArrowUp"?(r.preventDefault(),o(a=>(a-1+p.length)%p.length),!0):Xh(r)?(r.preventDefault(),y(p[s]??p[0]),!0):!1,[y,p,d,s]);return{allSkills:u,query:d,filteredSkills:p,selectedIndex:s,setSelectedIndex:o,applySkill:y,handleKeyDown:b}}const mr=200,Yh=180;function qu({taskId:e,title:i,readOnly:n=!1,onTitleChange:h,className:S,titleClassName:x,compact:w=!1}){const{t:s}=se(),[o,u]=A.useState(!1),[f,d]=A.useState(i),[p,m]=A.useState(!1),y=A.useRef(null),b=A.useRef(null),r=hn();A.useEffect(()=>{o||d(i)},[i,o]),A.useEffect(()=>{o&&y.current&&(y.current.focus(),y.current.select())},[o]),A.useEffect(()=>{if(!o)return;const E=R=>{b.current&&!b.current.contains(R.target)&&c()};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[o,f]);const a=A.useCallback(()=>{n||(u(!0),d(i))},[n,i]),l=A.useCallback(()=>{u(!1),d(i)},[i]),c=A.useCallback(async()=>{const E=f.trim();if(!E){d(i),u(!1);return}if(E===i){u(!1);return}try{await r.mutateAsync({id:e,title:E}),h?.(E),u(!1)}catch(R){console.error("Failed to update task title:",R),d(i)}},[f,i,e,r,h]),g=A.useCallback(E=>{E.key==="Enter"&&!E.shiftKey?(E.preventDefault(),c()):E.key==="Escape"&&(E.preventDefault(),l())},[c,l]),_=A.useCallback(E=>{const R=E.target.value;R.length<=mr&&d(R)},[]),C=f.length,k=C>=Yh,v=C>=mr;return o?t.jsxs("div",{ref:b,className:Q("flex flex-col gap-2",S),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{ref:y,type:"text",value:f,onChange:_,onKeyDown:g,disabled:r.isPending,className:Q("flex-1 min-w-0 px-2 py-1 text-lg font-semibold bg-background border border-input rounded-md","focus:outline-none focus:ring-2 focus:ring-ring focus:border-transparent","disabled:opacity-50 disabled:cursor-not-allowed",w&&"text-base py-0.5",x),placeholder:s("输入任务标题")}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(ae,{size:w?"sm":"default",variant:"ghost",onClick:c,disabled:r.isPending||!f.trim(),className:"h-8 w-8 p-0",children:r.isPending?t.jsx(he,{size:16,className:"animate-spin"}):t.jsx(ct,{size:16})}),t.jsx(ae,{size:w?"sm":"default",variant:"ghost",onClick:l,disabled:r.isPending,className:"h-8 w-8 p-0",children:t.jsx(Ve,{size:16})})]})]}),k&&t.jsxs("div",{className:Q("text-xs",v?"text-destructive":"text-muted-foreground"),children:[C," / ",mr," ",s("字符")]})]}):t.jsxs("div",{ref:b,className:Q("group flex items-center gap-2 min-w-0",S),onMouseEnter:()=>m(!0),onMouseLeave:()=>m(!1),children:[t.jsx("h2",{onClick:a,className:Q("flex-1 min-w-0 text-lg font-semibold text-foreground break-words line-clamp-2",!n&&"cursor-text hover:text-foreground/80 transition-colors",w&&"text-base",x),children:i}),!n&&p&&t.jsx(ae,{size:"sm",variant:"ghost",onClick:a,className:"h-7 w-7 p-0 shrink-0 opacity-60 hover:opacity-100",title:s("编辑标题"),children:t.jsx(Zn,{size:14})})]})}export{qu as E,Pr as G,Au as R,Hu as S,$u as T,zu as W,Uu as a,Zd as b,Tu as c,St as d,Mu as e,Fu as f,Lu as g,Ru as h,Bu as i,Du as j,Iu as k,Wu as l,Qd as m,Vs as n,Ai as o,Li as p,Th as q,Pu as r,sh as s,di as t,Ou as u};