agent-tower 0.7.1 → 0.7.2-beta.4

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 (216) 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 +244 -0
  5. package/dist/routes/__tests__/workspaces.test.js.map +1 -1
  6. package/dist/routes/workspaces.d.ts.map +1 -1
  7. package/dist/routes/workspaces.js +11 -0
  8. package/dist/routes/workspaces.js.map +1 -1
  9. package/dist/runtime/__tests__/cli-driver-lifecycle.test.js +37 -0
  10. package/dist/runtime/__tests__/cli-driver-lifecycle.test.js.map +1 -1
  11. package/dist/runtime/__tests__/runtime-coordinator.test.js +13 -0
  12. package/dist/runtime/__tests__/runtime-coordinator.test.js.map +1 -1
  13. package/dist/runtime/cli-driver.js +17 -3
  14. package/dist/runtime/cli-driver.js.map +1 -1
  15. package/dist/runtime/contracts.d.ts +9 -2
  16. package/dist/runtime/contracts.d.ts.map +1 -1
  17. package/dist/runtime/runtime-coordinator.d.ts +2 -0
  18. package/dist/runtime/runtime-coordinator.d.ts.map +1 -1
  19. package/dist/runtime/runtime-coordinator.js +10 -0
  20. package/dist/runtime/runtime-coordinator.js.map +1 -1
  21. package/dist/services/__tests__/session-manager.lifecycle.test.js +67 -0
  22. package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
  23. package/dist/services/__tests__/session-manager.team-run.test.js +41 -46
  24. package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
  25. package/dist/services/__tests__/team-reconciler.service.test.js +30 -0
  26. package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
  27. package/dist/services/project.service.d.ts.map +1 -1
  28. package/dist/services/project.service.js +30 -4
  29. package/dist/services/project.service.js.map +1 -1
  30. package/dist/services/session-manager.d.ts +1 -0
  31. package/dist/services/session-manager.d.ts.map +1 -1
  32. package/dist/services/session-manager.js +38 -3
  33. package/dist/services/session-manager.js.map +1 -1
  34. package/dist/services/session-runtime-cleanup-gate.d.ts +1 -0
  35. package/dist/services/session-runtime-cleanup-gate.d.ts.map +1 -1
  36. package/dist/services/session-runtime-cleanup-gate.js +5 -3
  37. package/dist/services/session-runtime-cleanup-gate.js.map +1 -1
  38. package/dist/services/team-reconciler.service.d.ts +1 -0
  39. package/dist/services/team-reconciler.service.d.ts.map +1 -1
  40. package/dist/services/team-reconciler.service.js +1 -0
  41. package/dist/services/team-reconciler.service.js.map +1 -1
  42. package/dist/services/workspace.service.d.ts +7 -1
  43. package/dist/services/workspace.service.d.ts.map +1 -1
  44. package/dist/services/workspace.service.js +111 -9
  45. package/dist/services/workspace.service.js.map +1 -1
  46. package/dist/utils/__tests__/spawned-process-identity.test.d.ts +2 -0
  47. package/dist/utils/__tests__/spawned-process-identity.test.d.ts.map +1 -0
  48. package/dist/utils/__tests__/spawned-process-identity.test.js +31 -0
  49. package/dist/utils/__tests__/spawned-process-identity.test.js.map +1 -0
  50. package/dist/utils/spawned-process-identity.d.ts +1 -1
  51. package/dist/utils/spawned-process-identity.d.ts.map +1 -1
  52. package/dist/utils/spawned-process-identity.js +11 -3
  53. package/dist/utils/spawned-process-identity.js.map +1 -1
  54. package/dist/web/assets/AgentDemoPage-Svq9Baa7.js +1 -0
  55. package/dist/web/assets/{AgentEnvironmentSettingsPage-b0XzUzna.js → AgentEnvironmentSettingsPage-DQjnDr-h.js} +1 -1
  56. package/dist/web/assets/AgentLogo-I2etsqym.js +1 -0
  57. package/dist/web/assets/BranchSelect-Eb5UGWWX.js +1 -0
  58. package/dist/web/assets/BrandLogo-BjC1hcgv.js +1 -0
  59. package/dist/web/assets/{ConversationPage-DQRA8WuD.js → ConversationPage-jEYUuSPT.js} +2 -2
  60. package/dist/web/assets/CreateTaskInput-B_cRDkVq.js +1 -0
  61. package/dist/web/assets/{DemoPage-DaDC_MIJ.js → DemoPage-BkkueMuL.js} +1 -1
  62. package/dist/web/assets/DesignSystemPage-oM16R2Ta.js +16 -0
  63. package/dist/web/assets/{ExecutionPermissionSelector-DglILGVC.js → ExecutionPermissionSelector-BX5Xx8ta.js} +1 -1
  64. package/dist/web/assets/{GeneralSettingsPage-BKRf-usO.js → GeneralSettingsPage-B0jFlgDl.js} +1 -1
  65. package/dist/web/assets/{LoadingPreviewPage-BHAQCQDA.js → LoadingPreviewPage-BxjpxLLP.js} +1 -1
  66. package/dist/web/assets/McpSettingsPage-BErvd619.js +1 -0
  67. package/dist/web/assets/{MemberAvatar-DUXHTIXf.js → MemberAvatar-TVtoxQe8.js} +1 -1
  68. package/dist/web/assets/NotificationSettingsPage-BETMBdj1.js +1 -0
  69. package/dist/web/assets/{ProfileSettingsPage-DwziCseV.js → ProfileSettingsPage-C03ZAft-.js} +1 -1
  70. package/dist/web/assets/ProjectKanbanPage-DsPxwoVf.js +86 -0
  71. package/dist/web/assets/ProjectSettingsPage-BwNM6VWs.js +2 -0
  72. package/dist/web/assets/{ProviderSettingsPage-CC3zkdf6.js → ProviderSettingsPage-CeNQPd74.js} +3 -3
  73. package/dist/web/assets/{SettingsMasterDetail-D5lNH2f6.js → SettingsMasterDetail-B_SI2h_k.js} +1 -1
  74. package/dist/web/assets/TeamSettingsPage-BfgtMl_n.js +1 -0
  75. package/dist/web/assets/agent-meta-DOylIs2N.js +1 -0
  76. package/dist/web/assets/arc-BlZww3MO.js +1 -0
  77. package/dist/web/assets/{architectureDiagram-3BPJPVTR-C_p9_AH2.js → architectureDiagram-3BPJPVTR-DWO_DRgk.js} +1 -1
  78. package/dist/web/assets/at-sign-BFf8Sz8T.js +1 -0
  79. package/dist/web/assets/{blockDiagram-GPEHLZMM-CKsR1Tax.js → blockDiagram-GPEHLZMM-CJPYhE52.js} +1 -1
  80. package/dist/web/assets/{c4Diagram-AAUBKEIU-BBUKt2FW.js → c4Diagram-AAUBKEIU-Cx5IvcjB.js} +1 -1
  81. package/dist/web/assets/channel-D9sA6Wxp.js +1 -0
  82. package/dist/web/assets/check-Cm7Vstpm.js +1 -0
  83. package/dist/web/assets/chevron-down-C6Ta4vyM.js +1 -0
  84. package/dist/web/assets/chevron-up-BwJT7iif.js +1 -0
  85. package/dist/web/assets/{chunk-2J33WTMH-BcGNhDoU.js → chunk-2J33WTMH-D9cBNYgd.js} +1 -1
  86. package/dist/web/assets/{chunk-4BX2VUAB-9dL7TVjW.js → chunk-4BX2VUAB-BY8TNt6E.js} +1 -1
  87. package/dist/web/assets/{chunk-55IACEB6-CzJzh0tH.js → chunk-55IACEB6-pT-HP-28.js} +1 -1
  88. package/dist/web/assets/{chunk-727SXJPM-Bp5EOgoG.js → chunk-727SXJPM-hy95xDLb.js} +1 -1
  89. package/dist/web/assets/{chunk-AQP2D5EJ-BaLnh9ac.js → chunk-AQP2D5EJ-DlUN-icr.js} +1 -1
  90. package/dist/web/assets/{chunk-FMBD7UC4-BcbzC8r4.js → chunk-FMBD7UC4-Dg2iMKZR.js} +1 -1
  91. package/dist/web/assets/{chunk-ND2GUHAM-DkT5Stbd.js → chunk-ND2GUHAM-DMzFIsJ-.js} +1 -1
  92. package/dist/web/assets/{chunk-QZHKN3VN-DszScpAV.js → chunk-QZHKN3VN-C6CgmKuM.js} +1 -1
  93. package/dist/web/assets/{circle-alert-ChWS5BPS.js → circle-alert-Dm2Pl-rU.js} +1 -1
  94. package/dist/web/assets/classDiagram-4FO5ZUOK-2e2YVo9r.js +1 -0
  95. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-2e2YVo9r.js +1 -0
  96. package/dist/web/assets/code-block-OCS4YCEC-DizntuP_.js +2 -0
  97. package/dist/web/assets/{confirm-dialog-0vHzUzvI.js → confirm-dialog-DRpyE_qU.js} +1 -1
  98. package/dist/web/assets/copy-r0aUdsl8.js +1 -0
  99. package/dist/web/assets/{cose-bilkent-S5V4N54A-DueZsNr5.js → cose-bilkent-S5V4N54A-D-fvmvw-.js} +1 -1
  100. package/dist/web/assets/cssMode-DVorIr82.js +1 -0
  101. package/dist/web/assets/{dagre-BM42HDAG-BkQGrA8s.js → dagre-BM42HDAG-H0bYI1f3.js} +1 -1
  102. package/dist/web/assets/{diagram-2AECGRRQ-D4qtEjjj.js → diagram-2AECGRRQ-DI568fLp.js} +1 -1
  103. package/dist/web/assets/{diagram-5GNKFQAL-ZuFk-7GO.js → diagram-5GNKFQAL-BLcaBzw2.js} +1 -1
  104. package/dist/web/assets/{diagram-KO2AKTUF-kwBr5lw0.js → diagram-KO2AKTUF-aL1cvl23.js} +1 -1
  105. package/dist/web/assets/{diagram-LMA3HP47-m88-mNyr.js → diagram-LMA3HP47-DbOutAfH.js} +1 -1
  106. package/dist/web/assets/{diagram-OG6HWLK6-B9gV1dxA.js → diagram-OG6HWLK6-D_cWftAX.js} +1 -1
  107. package/dist/web/assets/{erDiagram-TEJ5UH35-De_DsoOX.js → erDiagram-TEJ5UH35-DRe5V8Dx.js} +1 -1
  108. package/dist/web/assets/{flowDiagram-I6XJVG4X-9VwLS0b3.js → flowDiagram-I6XJVG4X-B5-vg_Nh.js} +1 -1
  109. package/dist/web/assets/{freemarker2-CLp1Yffb.js → freemarker2-CXlYb2yX.js} +3 -3
  110. package/dist/web/assets/{ganttDiagram-6RSMTGT7-DoOyYr5i.js → ganttDiagram-6RSMTGT7-B3iBFICN.js} +1 -1
  111. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-CMGuTxMz.js → gitGraphDiagram-PVQCEYII-CZ9zsKVw.js} +1 -1
  112. package/dist/web/assets/globe-JXfw4MCF.js +1 -0
  113. package/dist/web/assets/handlebars-BL0prPVZ.js +1 -0
  114. package/dist/web/assets/html-DJWeRkWe.js +1 -0
  115. package/dist/web/assets/htmlMode-D_fekqg9.js +1 -0
  116. package/dist/web/assets/{index-DI7lHrAR.js → index-CWEbo6pZ.js} +5 -5
  117. package/dist/web/assets/index-CWbMMO6g.js +122 -0
  118. package/dist/web/assets/index-uXglTJ2_.css +1 -0
  119. package/dist/web/assets/{infoDiagram-5YYISTIA-gUCDmQX7.js → infoDiagram-5YYISTIA-DQU_sN8x.js} +1 -1
  120. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-CmfFhhIz.js → ishikawaDiagram-YF4QCWOH-BVGrNzJa.js} +1 -1
  121. package/dist/web/assets/javascript-CDfuzdfe.js +1 -0
  122. package/dist/web/assets/{journeyDiagram-JHISSGLW-BvV5GoR_.js → journeyDiagram-JHISSGLW-DU4Md1Tq.js} +1 -1
  123. package/dist/web/assets/{jsonMode-BbjYNQ7Q.js → jsonMode-BMSvHUHa.js} +4 -4
  124. package/dist/web/assets/{kanban-definition-UN3LZRKU-BpTm0MC-.js → kanban-definition-UN3LZRKU-DDPgCucq.js} +1 -1
  125. package/dist/web/assets/key-round-BHVp7u3Z.js +1 -0
  126. package/dist/web/assets/{layers-DslPQJ3T.js → layers-2tjjhM75.js} +1 -1
  127. package/dist/web/assets/{linear-BJ_g8wqu.js → linear-D8yLBTVY.js} +1 -1
  128. package/dist/web/assets/link-CnunXc7X.js +1 -0
  129. package/dist/web/assets/liquid-DHrNpv6c.js +1 -0
  130. package/dist/web/assets/{lspLanguageFeatures-PSX0tqnR.js → lspLanguageFeatures-BiYvrSP0.js} +1 -1
  131. package/dist/web/assets/mdx-CIEpgUOV.js +1 -0
  132. package/dist/web/assets/mermaid-NOHMQCX5-9-DTTfp6.js +124 -0
  133. package/dist/web/assets/{message-square-C-22K3oa.js → message-square-QM0c6Dcv.js} +1 -1
  134. package/dist/web/assets/{mindmap-definition-RKZ34NQL-DS5GLydx.js → mindmap-definition-RKZ34NQL-CCAuuWFZ.js} +1 -1
  135. package/dist/web/assets/{modal-CFVLBZ5p.js → modal-BRoNvfhw.js} +1 -1
  136. package/dist/web/assets/{monaco-CkaUvvB4.js → monaco-CrBn9oMJ.js} +3 -3
  137. package/dist/web/assets/paperclip-CC7nHUQ7.js +1 -0
  138. package/dist/web/assets/pencil-DIY0Hu5t.js +1 -0
  139. package/dist/web/assets/{pieDiagram-4H26LBE5-C1PJJGsh.js → pieDiagram-4H26LBE5-CXy_N5QX.js} +2 -2
  140. package/dist/web/assets/play-CIZVXiwM.js +1 -0
  141. package/dist/web/assets/python-BIs0pClJ.js +1 -0
  142. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-CzDfs-TQ.js → quadrantDiagram-W4KKPZXB-Dt44QsS8.js} +1 -1
  143. package/dist/web/assets/razor-JCx8NEwU.js +1 -0
  144. package/dist/web/assets/{requirementDiagram-4Y6WPE33-qHbU7oZa.js → requirementDiagram-4Y6WPE33-BL8D7Np0.js} +1 -1
  145. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-BfRgrEeN.js → sankeyDiagram-5OEKKPKP-I5nefO3A.js} +1 -1
  146. package/dist/web/assets/{select-CL78HCY0.js → select-BmjoUfrV.js} +1 -1
  147. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-CGTNzKk3.js → sequenceDiagram-3UESZ5HK-lbPrhX8g.js} +1 -1
  148. package/dist/web/assets/server-BNBdQGor.js +1 -0
  149. package/dist/web/assets/stateDiagram-AJRCARHV-Bw3qtv2M.js +1 -0
  150. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Xbc4HxDQ.js +1 -0
  151. package/dist/web/assets/{switch-DmQ0Brgd.js → switch-CEUHI4gI.js} +1 -1
  152. package/dist/web/assets/task-kalEmHDc.js +42 -0
  153. package/dist/web/assets/task-priority-wLXAgVZZ.js +1 -0
  154. package/dist/web/assets/{textarea-DOte4pMQ.js → textarea-CD82lB0Z.js} +1 -1
  155. package/dist/web/assets/{timeline-definition-PNZ67QCA-BBhCKsly.js → timeline-definition-PNZ67QCA-Cfg_kgoa.js} +1 -1
  156. package/dist/web/assets/{trash-2-BSAHXKfW.js → trash-2-BF_3L-qk.js} +1 -1
  157. package/dist/web/assets/{tsMode-B6rHoWny.js → tsMode-DAHSkTAr.js} +2 -2
  158. package/dist/web/assets/typescript-CptiLWGr.js +1 -0
  159. package/dist/web/assets/{upload-e87qV_RH.js → upload-B2AMXrU-.js} +1 -1
  160. package/dist/web/assets/{use-profiles-Cv2zBJOC.js → use-profiles-CQ-jIuiI.js} +1 -1
  161. package/dist/web/assets/use-projects-BYUZwQ-q.js +1 -0
  162. package/dist/web/assets/{use-providers-CnpIgITQ.js → use-providers-DdV9gbj1.js} +1 -1
  163. package/dist/web/assets/useNormalizedLogs-DdFsf-Z1.js +1 -0
  164. package/dist/web/assets/{vennDiagram-CIIHVFJN-DrDrt_Jg.js → vennDiagram-CIIHVFJN-CdEP03CK.js} +1 -1
  165. package/dist/web/assets/{wardley-L42UT6IY-CMYQm14y.js → wardley-L42UT6IY-q_Enplrs.js} +1 -1
  166. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-COLA9A80.js → wardleyDiagram-YWT4CUSO-DlL6fsid.js} +1 -1
  167. package/dist/web/assets/xml-DbPqkgZW.js +1 -0
  168. package/dist/web/assets/{xychartDiagram-2RQKCTM6-BDegkKoT.js → xychartDiagram-2RQKCTM6-B2OGqVKA.js} +1 -1
  169. package/dist/web/assets/yaml-Deyq6Z5-.js +1 -0
  170. package/dist/web/index.html +2 -2
  171. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +2 -2
  172. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
  173. package/node_modules/@agent-tower/shared/dist/types.d.ts +19 -2
  174. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  175. package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
  176. package/package.json +1 -1
  177. package/dist/web/assets/AgentDemoPage-Gr8q6VxC.js +0 -1
  178. package/dist/web/assets/AgentLogo-q8Chady2.js +0 -1
  179. package/dist/web/assets/CreateTaskInput-Dr6Lvllw.js +0 -1
  180. package/dist/web/assets/Icons-7lThaqQv.js +0 -1
  181. package/dist/web/assets/McpSettingsPage-CVOEPwCv.js +0 -1
  182. package/dist/web/assets/NotificationSettingsPage-DBe1YCNN.js +0 -1
  183. package/dist/web/assets/ProjectKanbanPage-Dcz8KXWU.js +0 -86
  184. package/dist/web/assets/ProjectSettingsPage-hzSrj79M.js +0 -2
  185. package/dist/web/assets/TeamSettingsPage-Cdbvh2ne.js +0 -1
  186. package/dist/web/assets/arc-d2D24uRQ.js +0 -1
  187. package/dist/web/assets/channel-D0hF47LU.js +0 -1
  188. package/dist/web/assets/check-BqhuHtHP.js +0 -1
  189. package/dist/web/assets/chevron-down-Bw_76CB_.js +0 -1
  190. package/dist/web/assets/chevron-right-DbcFf_Dw.js +0 -1
  191. package/dist/web/assets/chevron-up-x1n3MhC-.js +0 -1
  192. package/dist/web/assets/classDiagram-4FO5ZUOK-ulXJsBKw.js +0 -1
  193. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-ulXJsBKw.js +0 -1
  194. package/dist/web/assets/code-block-OCS4YCEC-G8tEtSdL.js +0 -2
  195. package/dist/web/assets/cssMode-Dqx3XDOC.js +0 -1
  196. package/dist/web/assets/folder-picker-B0khMt7A.js +0 -1
  197. package/dist/web/assets/handlebars-CmLfR6Uy.js +0 -1
  198. package/dist/web/assets/html-D34UDOLc.js +0 -1
  199. package/dist/web/assets/htmlMode-qjrvkZFJ.js +0 -1
  200. package/dist/web/assets/index-DrzmyANC.js +0 -122
  201. package/dist/web/assets/index-MMCbS8_L.css +0 -1
  202. package/dist/web/assets/javascript-D5tp0LcO.js +0 -1
  203. package/dist/web/assets/liquid-DBu3_6XS.js +0 -1
  204. package/dist/web/assets/mdx-Bb4nrA8s.js +0 -1
  205. package/dist/web/assets/mermaid-NOHMQCX5-B44shuzc.js +0 -124
  206. package/dist/web/assets/pencil-DB3VPszm.js +0 -1
  207. package/dist/web/assets/python-BfodDYt4.js +0 -1
  208. package/dist/web/assets/razor-DdED1MBH.js +0 -1
  209. package/dist/web/assets/server-Cd7APx6v.js +0 -1
  210. package/dist/web/assets/stateDiagram-AJRCARHV-BY1LJ4b7.js +0 -1
  211. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-BV_JKRZC.js +0 -1
  212. package/dist/web/assets/typescript-C2A3q8UY.js +0 -1
  213. package/dist/web/assets/use-projects-C8WDJXdj.js +0 -1
  214. package/dist/web/assets/useNormalizedLogs-AbIXa8s-.js +0 -1
  215. package/dist/web/assets/xml-D4xDxfjR.js +0 -1
  216. package/dist/web/assets/yaml-yJExA7tq.js +0 -1
@@ -1,86 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-CkaUvvB4.js","assets/index-DrzmyANC.js","assets/index-MMCbS8_L.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
- import{aj as kd,ak as bo,al as Ed,am as jd,an as Nd,k as Ve,r as b,ao as ue,D as Cs,m as Et,ap as Rs,n as Ut,p as ye,o as vt,q as ce,u as de,j as t,l as Z,aq as Rd,Z as Ha,_ as Ad,a0 as qs,B as Ae,ar as Ua,as as $a,at as qa,ah as js,X as Gt,au as An,av as Td,P as wr,aw as Md,E as Dd,ax as Pd,ay as Ld,az as Id,T as As,t as ot,V as cs,W as dt,Y as Ws,Q as Be,aA as Ts,U as hr,aB as Od,aC as mi,ai as Bd,ad as Ka,s as Ks,aa as Dt,ag as Fd,aD as Va,aE as Tn,a6 as zd,aF as Ya,aG as Xa,aH as Ga,aI as Qa,aJ as Wd,aK as Hd,a3 as Ud,aL as $d,aM as qd,aN as Kd,$ as _o,a9 as yo}from"./index-DrzmyANC.js";import{S as ut,m as Gr,u as Mn,A as Dn,o as Vd,F as Za,p as Yd,q as Xd,r as Gd,Q as Pn,t as Qd,v as Pt,W as bt,w as Ja,C as vr,x as Wr,y as Zd,z as Jd,B as eu,T as tu,c as Nt,b as Qr,D as el,G as Yt}from"./mermaid-NOHMQCX5-B44shuzc.js";import{C as Ln}from"./confirm-dialog-0vHzUzvI.js";import{c as tl,a as sl,b as rl,I as il,d as nl,A as So,G as ol}from"./Icons-7lThaqQv.js";import{e as wo,f as su,d as In,S as ru,u as On,A as xr,c as Bn,G as al,Z as iu,g as Fn,T as zn,h as nu,i as Wn,j as Co,k as ou,b as ll,l as cl,a as dl,m as ul,n as hl,R as fl,P as ml,o as Zr,p as au,C as ko,B as Eo}from"./CreateTaskInput-Dr6Lvllw.js";import{C as At}from"./chevron-right-DbcFf_Dw.js";import{C as Wt}from"./check-BqhuHtHP.js";import{T as pi,P as us}from"./trash-2-BSAHXKfW.js";import{a as lu,F as cu,b as du}from"./folder-picker-B0khMt7A.js";import{M as gi}from"./message-square-C-22K3oa.js";import{L as Vs}from"./layers-DslPQJ3T.js";import{P as Hn,C as uu,u as pl,a as gl,L as Jr,T as ei}from"./useNormalizedLogs-AbIXa8s-.js";import{a as ts,l as hu,g as vl}from"./ExecutionPermissionSelector-DglILGVC.js";import{u as Gs}from"./use-providers-CnpIgITQ.js";import{A as vi}from"./AgentLogo-q8Chady2.js";import{M as Xt}from"./MemberAvatar-DUXHTIXf.js";import{C as kt}from"./chevron-down-Bw_76CB_.js";import{C as xl}from"./chevron-up-x1n3MhC-.js";import{M as gs}from"./modal-CFVLBZ5p.js";import{S as ds}from"./select-CL78HCY0.js";import{T as fu}from"./textarea-DOte4pMQ.js";import{S as hn,C as jo}from"./server-Cd7APx6v.js";import{F as Un,e as mu,d as pu,f as gu,u as vu}from"./use-projects-C8WDJXdj.js";import{U as ti}from"./upload-e87qV_RH.js";import{P as xu}from"./pencil-DB3VPszm.js";var bu=class extends kd{constructor(e,s){super(e,s)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:bo()})}getOptimisticResult(e){return e.behavior=bo(),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,s){const{state:r}=e,o=super.createResult(e,s),{isFetching:p,isRefetching:m,isError:x,isRefetchError:i}=o,n=r.fetchMeta?.fetchMore?.direction,a=x&&n==="forward",h=p&&n==="forward",c=x&&n==="backward",g=p&&n==="backward";return{...o,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:jd(s,r.data),hasPreviousPage:Ed(s,r.data),isFetchNextPageError:a,isFetchingNextPage:h,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!a&&!c,isRefetching:m&&!h&&!g}}};function $n(e,s){return Nd(e,bu)}const _u=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],bl=Ve("arrow-right",_u);const yu=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_l=Ve("ban",yu);const Su=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],wu=Ve("chevron-left",Su);const Cu=[["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"}]],ku=Ve("clipboard-paste",Cu);const Eu=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],hs=Ve("clock-3",Eu);const ju=[["path",{d:"m18 16 4-4-4-4",key:"1inbqp"}],["path",{d:"m6 8-4 4 4 4",key:"15zrgr"}],["path",{d:"m14.5 4-5 16",key:"e7oirm"}]],xi=Ve("code-xml",ju);const Nu=[["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"}]],No=Ve("copy-plus",Nu);const Ru=[["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"}]],Au=Ve("earth",Ru);const Tu=[["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"}]],yl=Ve("ellipsis-vertical",Tu);const Mu=[["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"}]],Du=Ve("file-braces-corner",Mu);const Pu=[["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"}]],si=Ve("file-code-corner",Pu);const Lu=[["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"}]],Iu=Ve("file-exclamation-point",Lu);const Ou=[["path",{d:"m6 14 1.5-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.54 6a2 2 0 0 1-1.95 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2",key:"usdka0"}]],bi=Ve("folder-open",Ou);const Bu=[["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"}]],Qs=Ve("git-graph",Bu);const Fu=[["path",{d:"M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8",key:"1357e3"}],["path",{d:"M3 3v5h5",key:"1xhq8a"}],["path",{d:"M12 7v5l4 2",key:"1fdv2h"}]],Ys=Ve("history",Fu);const zu=[["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"}]],Wu=Ve("maximize",zu);const Hu=[["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"}]],Uu=Ve("panel-left-close",Hu);const $u=[["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"}]],qu=Ve("panel-left-open",$u);const Ku=[["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"}]],Vu=Ve("panel-right-close",Ku);const Yu=[["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"}]],fn=Ve("panel-right-open",Yu);const Xu=[["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"}]],Gu=Ve("pen-line",Xu);const Qu=[["path",{d:"M5 5a2 2 0 0 1 3.008-1.728l11.997 6.998a2 2 0 0 1 .003 3.458l-12 7A2 2 0 0 1 5 19z",key:"10ikf1"}]],ks=Ve("play",Qu);const Zu=[["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"}]],Sl=Ve("settings-2",Zu);const Ju=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Ro=Ve("smartphone",Ju);const eh=[["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"}]],Hr=Ve("user-plus",eh);const th=[["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"}]],sh=Ve("zoom-in",th);const rh=[["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"}]],ih=Ve("zoom-out",rh),_i=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function Zs(e){const s=Object.prototype.toString.call(e);return s==="[object Window]"||s==="[object global]"}function qn(e){return"nodeType"in e}function St(e){var s,r;return e?Zs(e)?e:qn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Kn(e){const{Document:s}=St(e);return e instanceof s}function Cr(e){return Zs(e)?!1:e instanceof St(e).HTMLElement}function wl(e){return e instanceof St(e).SVGElement}function Js(e){return e?Zs(e)?e.document:qn(e)?Kn(e)?e:Cr(e)||wl(e)?e.ownerDocument:document:document:document}const ss=_i?b.useLayoutEffect:b.useEffect;function yi(e){const s=b.useRef(e);return ss(()=>{s.current=e}),b.useCallback(function(){for(var r=arguments.length,o=new Array(r),p=0;p<r;p++)o[p]=arguments[p];return s.current==null?void 0:s.current(...o)},[])}function nh(){const e=b.useRef(null),s=b.useCallback((o,p)=>{e.current=setInterval(o,p)},[]),r=b.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[s,r]}function br(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return ss(()=>{r.current!==e&&(r.current=e)},s),r}function kr(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function ri(e){const s=yi(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function ii(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let zi={};function Si(e,s){return b.useMemo(()=>{if(s)return s;const r=zi[e]==null?0:zi[e]+1;return zi[e]=r,e+"-"+r},[e,s])}function Cl(e){return function(s){for(var r=arguments.length,o=new Array(r>1?r-1:0),p=1;p<r;p++)o[p-1]=arguments[p];return o.reduce((m,x)=>{const i=Object.entries(x);for(const[n,a]of i){const h=m[n];h!=null&&(m[n]=h+e*a)}return m},{...s})}}const $s=Cl(1),ni=Cl(-1);function oh(e){return"clientX"in e&&"clientY"in e}function Vn(e){if(!e)return!1;const{KeyboardEvent:s}=St(e.target);return s&&e instanceof s}function ah(e){if(!e)return!1;const{TouchEvent:s}=St(e.target);return s&&e instanceof s}function oi(e){if(ah(e)){if(e.touches&&e.touches.length){const{clientX:s,clientY:r}=e.touches[0];return{x:s,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:s,clientY:r}=e.changedTouches[0];return{x:s,y:r}}}return oh(e)?{x:e.clientX,y:e.clientY}:null}const _r=Object.freeze({Translate:{toString(e){if(!e)return;const{x:s,y:r}=e;return"translate3d("+(s?Math.round(s):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:s,scaleY:r}=e;return"scaleX("+s+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[_r.Translate.toString(e),_r.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),Ao="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function lh(e){return e.matches(Ao)?e:e.querySelector(Ao)}const ch={display:"none"};function dh(e){let{id:s,value:r}=e;return ue.createElement("div",{id:s,style:ch},r)}function uh(e){let{id:s,announcement:r,ariaLiveType:o="assertive"}=e;const p={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return ue.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function hh(){const[e,s]=b.useState("");return{announce:b.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const kl=b.createContext(null);function fh(e){const s=b.useContext(kl);b.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function mh(){const[e]=b.useState(()=>new Set),s=b.useCallback(o=>(e.add(o),()=>e.delete(o)),[e]);return[b.useCallback(o=>{let{type:p,event:m}=o;e.forEach(x=>{var i;return(i=x[p])==null?void 0:i.call(x,m)})},[e]),s]}const ph={draggable:`
3
- To pick up a draggable item, press the space bar.
4
- While dragging, use the arrow keys to move the item.
5
- Press space again to drop the item in its new position, or press escape to cancel.
6
- `},gh={onDragStart(e){let{active:s}=e;return"Picked up draggable item "+s.id+"."},onDragOver(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was moved over droppable area "+r.id+".":"Draggable item "+s.id+" is no longer over a droppable area."},onDragEnd(e){let{active:s,over:r}=e;return r?"Draggable item "+s.id+" was dropped over droppable area "+r.id:"Draggable item "+s.id+" was dropped."},onDragCancel(e){let{active:s}=e;return"Dragging was cancelled. Draggable item "+s.id+" was dropped."}};function vh(e){let{announcements:s=gh,container:r,hiddenTextDescribedById:o,screenReaderInstructions:p=ph}=e;const{announce:m,announcement:x}=hh(),i=Si("DndLiveRegion"),[n,a]=b.useState(!1);if(b.useEffect(()=>{a(!0)},[]),fh(b.useMemo(()=>({onDragStart(c){let{active:g}=c;m(s.onDragStart({active:g}))},onDragMove(c){let{active:g,over:v}=c;s.onDragMove&&m(s.onDragMove({active:g,over:v}))},onDragOver(c){let{active:g,over:v}=c;m(s.onDragOver({active:g,over:v}))},onDragEnd(c){let{active:g,over:v}=c;m(s.onDragEnd({active:g,over:v}))},onDragCancel(c){let{active:g,over:v}=c;m(s.onDragCancel({active:g,over:v}))}}),[m,s])),!n)return null;const h=ue.createElement(ue.Fragment,null,ue.createElement(dh,{id:o,value:p.draggable}),ue.createElement(uh,{id:i,announcement:x}));return r?Cs.createPortal(h,r):h}var ct;(function(e){e.DragStart="dragStart",e.DragMove="dragMove",e.DragEnd="dragEnd",e.DragCancel="dragCancel",e.DragOver="dragOver",e.RegisterDroppable="registerDroppable",e.SetDroppableDisabled="setDroppableDisabled",e.UnregisterDroppable="unregisterDroppable"})(ct||(ct={}));function ai(){}function xh(e,s){return b.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function bh(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return b.useMemo(()=>[...s].filter(o=>o!=null),[...s])}const Ht=Object.freeze({x:0,y:0});function _h(e,s){const r=oi(e);if(!r)return"0 0";const o={x:(r.x-s.left)/s.width*100,y:(r.y-s.top)/s.height*100};return o.x+"% "+o.y+"%"}function yh(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function Sh(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function wh(e,s){const r=Math.max(s.top,e.top),o=Math.max(s.left,e.left),p=Math.min(s.left+s.width,e.left+e.width),m=Math.min(s.top+s.height,e.top+e.height),x=p-o,i=m-r;if(o<p&&r<m){const n=s.width*s.height,a=e.width*e.height,h=x*i,c=h/(n+a-h);return Number(c.toFixed(4))}return 0}const Ch=e=>{let{collisionRect:s,droppableRects:r,droppableContainers:o}=e;const p=[];for(const m of o){const{id:x}=m,i=r.get(x);if(i){const n=wh(i,s);n>0&&p.push({id:x,data:{droppableContainer:m,value:n}})}}return p.sort(yh)};function kh(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function El(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Ht}function Eh(e){return function(r){for(var o=arguments.length,p=new Array(o>1?o-1:0),m=1;m<o;m++)p[m-1]=arguments[m];return p.reduce((x,i)=>({...x,top:x.top+e*i.y,bottom:x.bottom+e*i.y,left:x.left+e*i.x,right:x.right+e*i.x}),{...r})}}const jh=Eh(1);function jl(e){if(e.startsWith("matrix3d(")){const s=e.slice(9,-1).split(/, /);return{x:+s[12],y:+s[13],scaleX:+s[0],scaleY:+s[5]}}else if(e.startsWith("matrix(")){const s=e.slice(7,-1).split(/, /);return{x:+s[4],y:+s[5],scaleX:+s[0],scaleY:+s[3]}}return null}function Nh(e,s,r){const o=jl(s);if(!o)return e;const{scaleX:p,scaleY:m,x,y:i}=o,n=e.left-x-(1-p)*parseFloat(r),a=e.top-i-(1-m)*parseFloat(r.slice(r.indexOf(" ")+1)),h=p?e.width/p:e.width,c=m?e.height/m:e.height;return{width:h,height:c,top:a,right:n+h,bottom:a+c,left:n}}const Rh={ignoreTransform:!1};function Er(e,s){s===void 0&&(s=Rh);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:a,transformOrigin:h}=St(e).getComputedStyle(e);a&&(r=Nh(r,a,h))}const{top:o,left:p,width:m,height:x,bottom:i,right:n}=r;return{top:o,left:p,width:m,height:x,bottom:i,right:n}}function To(e){return Er(e,{ignoreTransform:!0})}function Ah(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Th(e,s){return s===void 0&&(s=St(e).getComputedStyle(e)),s.position==="fixed"}function Mh(e,s){s===void 0&&(s=St(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(p=>{const m=s[p];return typeof m=="string"?r.test(m):!1})}function Yn(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(Kn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!Cr(p)||wl(p)||r.includes(p))return r;const m=St(e).getComputedStyle(p);return p!==e&&Mh(p,m)&&r.push(p),Th(p,m)?r:o(p.parentNode)}return e?o(e):r}function Nl(e){const[s]=Yn(e,1);return s??null}function Wi(e){return!_i||!e?null:Zs(e)?e:qn(e)?Kn(e)||e===Js(e).scrollingElement?window:Cr(e)?e:null:null}function Rl(e){return Zs(e)?e.scrollX:e.scrollLeft}function Al(e){return Zs(e)?e.scrollY:e.scrollTop}function mn(e){return{x:Rl(e),y:Al(e)}}var ht;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ht||(ht={}));function Tl(e){return!_i||!e?!1:e===document.scrollingElement}function Ml(e){const s={x:0,y:0},r=Tl(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},o={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},p=e.scrollTop<=s.y,m=e.scrollLeft<=s.x,x=e.scrollTop>=o.y,i=e.scrollLeft>=o.x;return{isTop:p,isLeft:m,isBottom:x,isRight:i,maxScroll:o,minScroll:s}}const Dh={x:.2,y:.2};function Ph(e,s,r,o,p){let{top:m,left:x,right:i,bottom:n}=r;o===void 0&&(o=10),p===void 0&&(p=Dh);const{isTop:a,isBottom:h,isLeft:c,isRight:g}=Ml(e),v={x:0,y:0},_={x:0,y:0},w={height:s.height*p.y,width:s.width*p.x};return!a&&m<=s.top+w.height?(v.y=ht.Backward,_.y=o*Math.abs((s.top+w.height-m)/w.height)):!h&&n>=s.bottom-w.height&&(v.y=ht.Forward,_.y=o*Math.abs((s.bottom-w.height-n)/w.height)),!g&&i>=s.right-w.width?(v.x=ht.Forward,_.x=o*Math.abs((s.right-w.width-i)/w.width)):!c&&x<=s.left+w.width&&(v.x=ht.Backward,_.x=o*Math.abs((s.left+w.width-x)/w.width)),{direction:v,speed:_}}function Lh(e){if(e===document.scrollingElement){const{innerWidth:m,innerHeight:x}=window;return{top:0,left:0,right:m,bottom:x,width:m,height:x}}const{top:s,left:r,right:o,bottom:p}=e.getBoundingClientRect();return{top:s,left:r,right:o,bottom:p,width:e.clientWidth,height:e.clientHeight}}function Dl(e){return e.reduce((s,r)=>$s(s,mn(r)),Ht)}function Ih(e){return e.reduce((s,r)=>s+Rl(r),0)}function Oh(e){return e.reduce((s,r)=>s+Al(r),0)}function Pl(e,s){if(s===void 0&&(s=Er),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);Nl(e)&&(p<=0||m<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Bh=[["x",["left","right"],Ih],["y",["top","bottom"],Oh]];class Xn{constructor(s,r){this.rect=void 0,this.width=void 0,this.height=void 0,this.top=void 0,this.bottom=void 0,this.right=void 0,this.left=void 0;const o=Yn(r),p=Dl(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,x,i]of Bh)for(const n of x)Object.defineProperty(this,n,{get:()=>{const a=i(o),h=p[m]-a;return this.rect[n]+h},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class fr{constructor(s){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var o;return(o=this.target)==null?void 0:o.removeEventListener(...r)})},this.target=s}add(s,r,o){var p;(p=this.target)==null||p.addEventListener(s,r,o),this.listeners.push([s,r,o])}}function Fh(e){const{EventTarget:s}=St(e);return e instanceof s?e:Js(e)}function Hi(e,s){const r=Math.abs(e.x),o=Math.abs(e.y);return typeof s=="number"?Math.sqrt(r**2+o**2)>s:"x"in s&&"y"in s?r>s.x&&o>s.y:"x"in s?r>s.x:"y"in s?o>s.y:!1}var Mt;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(Mt||(Mt={}));function Mo(e){e.preventDefault()}function zh(e){e.stopPropagation()}var Ke;(function(e){e.Space="Space",e.Down="ArrowDown",e.Right="ArrowRight",e.Left="ArrowLeft",e.Up="ArrowUp",e.Esc="Escape",e.Enter="Enter",e.Tab="Tab"})(Ke||(Ke={}));const Ll={start:[Ke.Space,Ke.Enter],cancel:[Ke.Esc],end:[Ke.Space,Ke.Enter,Ke.Tab]},Wh=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case Ke.Right:return{...r,x:r.x+25};case Ke.Left:return{...r,x:r.x-25};case Ke.Down:return{...r,y:r.y+25};case Ke.Up:return{...r,y:r.y-25}}};class Il{constructor(s){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=s;const{event:{target:r}}=s;this.props=s,this.listeners=new fr(Js(r)),this.windowListeners=new fr(St(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(Mt.Resize,this.handleCancel),this.windowListeners.add(Mt.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(Mt.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&Pl(o),r(Ht)}handleKeyDown(s){if(Vn(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=Ll,coordinateGetter:x=Wh,scrollBehavior:i="smooth"}=p,{code:n}=s;if(m.end.includes(n)){this.handleEnd(s);return}if(m.cancel.includes(n)){this.handleCancel(s);return}const{collisionRect:a}=o.current,h=a?{x:a.left,y:a.top}:Ht;this.referenceCoordinates||(this.referenceCoordinates=h);const c=x(s,{active:r,context:o.current,currentCoordinates:h});if(c){const g=ni(c,h),v={x:0,y:0},{scrollableAncestors:_}=o.current;for(const w of _){const l=s.code,{isTop:u,isRight:d,isLeft:f,isBottom:S,maxScroll:C,minScroll:k}=Ml(w),j=Lh(w),y={x:Math.min(l===Ke.Right?j.right-j.width/2:j.right,Math.max(l===Ke.Right?j.left:j.left+j.width/2,c.x)),y:Math.min(l===Ke.Down?j.bottom-j.height/2:j.bottom,Math.max(l===Ke.Down?j.top:j.top+j.height/2,c.y))},E=l===Ke.Right&&!d||l===Ke.Left&&!f,R=l===Ke.Down&&!S||l===Ke.Up&&!u;if(E&&y.x!==c.x){const P=w.scrollLeft+g.x,M=l===Ke.Right&&P<=C.x||l===Ke.Left&&P>=k.x;if(M&&!g.y){w.scrollTo({left:P,behavior:i});return}M?v.x=w.scrollLeft-P:v.x=l===Ke.Right?w.scrollLeft-C.x:w.scrollLeft-k.x,v.x&&w.scrollBy({left:-v.x,behavior:i});break}else if(R&&y.y!==c.y){const P=w.scrollTop+g.y,M=l===Ke.Down&&P<=C.y||l===Ke.Up&&P>=k.y;if(M&&!g.x){w.scrollTo({top:P,behavior:i});return}M?v.y=w.scrollTop-P:v.y=l===Ke.Down?w.scrollTop-C.y:w.scrollTop-k.y,v.y&&w.scrollBy({top:-v.y,behavior:i});break}}this.handleMove(s,$s(ni(c,this.referenceCoordinates),v))}}}handleMove(s,r){const{onMove:o}=this.props;s.preventDefault(),o(r)}handleEnd(s){const{onEnd:r}=this.props;s.preventDefault(),this.detach(),r()}handleCancel(s){const{onCancel:r}=this.props;s.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Il.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=Ll,onActivation:p}=s,{active:m}=r;const{code:x}=e.nativeEvent;if(o.start.includes(x)){const i=m.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function Do(e){return!!(e&&"distance"in e)}function Po(e){return!!(e&&"delay"in e)}class Gn{constructor(s,r,o){var p;o===void 0&&(o=Fh(s.event.target)),this.props=void 0,this.events=void 0,this.autoScrollEnabled=!0,this.document=void 0,this.activated=!1,this.initialCoordinates=void 0,this.timeoutId=null,this.listeners=void 0,this.documentListeners=void 0,this.windowListeners=void 0,this.props=s,this.events=r;const{event:m}=s,{target:x}=m;this.props=s,this.events=r,this.document=Js(x),this.documentListeners=new fr(this.document),this.listeners=new fr(o),this.windowListeners=new fr(St(x)),this.initialCoordinates=(p=oi(m))!=null?p:Ht,this.handleStart=this.handleStart.bind(this),this.handleMove=this.handleMove.bind(this),this.handleEnd=this.handleEnd.bind(this),this.handleCancel=this.handleCancel.bind(this),this.handleKeydown=this.handleKeydown.bind(this),this.removeTextSelection=this.removeTextSelection.bind(this),this.attach()}attach(){const{events:s,props:{options:{activationConstraint:r,bypassActivationConstraint:o}}}=this;if(this.listeners.add(s.move.name,this.handleMove,{passive:!1}),this.listeners.add(s.end.name,this.handleEnd),s.cancel&&this.listeners.add(s.cancel.name,this.handleCancel),this.windowListeners.add(Mt.Resize,this.handleCancel),this.windowListeners.add(Mt.DragStart,Mo),this.windowListeners.add(Mt.VisibilityChange,this.handleCancel),this.windowListeners.add(Mt.ContextMenu,Mo),this.documentListeners.add(Mt.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Po(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Do(r)){this.handlePending(r);return}}this.handleStart()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll(),setTimeout(this.documentListeners.removeAll,50),this.timeoutId!==null&&(clearTimeout(this.timeoutId),this.timeoutId=null)}handlePending(s,r){const{active:o,onPending:p}=this.props;p(o,s,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:s}=this,{onStart:r}=this.props;s&&(this.activated=!0,this.documentListeners.add(Mt.Click,zh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(Mt.SelectionChange,this.removeTextSelection),r(s))}handleMove(s){var r;const{activated:o,initialCoordinates:p,props:m}=this,{onMove:x,options:{activationConstraint:i}}=m;if(!p)return;const n=(r=oi(s))!=null?r:Ht,a=ni(p,n);if(!o&&i){if(Do(i)){if(i.tolerance!=null&&Hi(a,i.tolerance))return this.handleCancel();if(Hi(a,i.distance))return this.handleStart()}if(Po(i)&&Hi(a,i.tolerance))return this.handleCancel();this.handlePending(i,a);return}s.cancelable&&s.preventDefault(),x(n)}handleEnd(){const{onAbort:s,onEnd:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleCancel(){const{onAbort:s,onCancel:r}=this.props;this.detach(),this.activated||s(this.props.active),r()}handleKeydown(s){s.code===Ke.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const Hh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Qn extends Gn{constructor(s){const{event:r}=s,o=Js(r.target);super(s,Hh,o)}}Qn.activators=[{eventName:"onPointerDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return!r.isPrimary||r.button!==0?!1:(o?.({event:r}),!0)}}];const Uh={move:{name:"mousemove"},end:{name:"mouseup"}};var pn;(function(e){e[e.RightClick=2]="RightClick"})(pn||(pn={}));class $h extends Gn{constructor(s){super(s,Uh,Js(s.event.target))}}$h.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===pn.RightClick?!1:(o?.({event:r}),!0)}}];const Ui={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class qh extends Gn{constructor(s){super(s,Ui)}static setup(){return window.addEventListener(Ui.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener(Ui.move.name,s)};function s(){}}}qh.activators=[{eventName:"onTouchStart",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;const{touches:p}=r;return p.length>1?!1:(o?.({event:r}),!0)}}];var mr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(mr||(mr={}));var li;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(li||(li={}));function Kh(e){let{acceleration:s,activator:r=mr.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:x=5,order:i=li.TreeOrder,pointerCoordinates:n,scrollableAncestors:a,scrollableAncestorRects:h,delta:c,threshold:g}=e;const v=Yh({delta:c,disabled:!m}),[_,w]=nh(),l=b.useRef({x:0,y:0}),u=b.useRef({x:0,y:0}),d=b.useMemo(()=>{switch(r){case mr.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case mr.DraggableRect:return p}},[r,p,n]),f=b.useRef(null),S=b.useCallback(()=>{const k=f.current;if(!k)return;const j=l.current.x*u.current.x,y=l.current.y*u.current.y;k.scrollBy(j,y)},[]),C=b.useMemo(()=>i===li.TreeOrder?[...a].reverse():a,[i,a]);b.useEffect(()=>{if(!m||!a.length||!d){w();return}for(const k of C){if(o?.(k)===!1)continue;const j=a.indexOf(k),y=h[j];if(!y)continue;const{direction:E,speed:R}=Ph(k,y,d,s,g);for(const P of["x","y"])v[P][E[P]]||(R[P]=0,E[P]=0);if(R.x>0||R.y>0){w(),f.current=k,_(S,x),l.current=R,u.current=E;return}}l.current={x:0,y:0},u.current={x:0,y:0},w()},[s,S,o,w,m,x,JSON.stringify(d),JSON.stringify(v),_,a,C,h,JSON.stringify(g)])}const Vh={x:{[ht.Backward]:!1,[ht.Forward]:!1},y:{[ht.Backward]:!1,[ht.Forward]:!1}};function Yh(e){let{delta:s,disabled:r}=e;const o=ii(s);return kr(p=>{if(r||!o||!p)return Vh;const m={x:Math.sign(s.x-o.x),y:Math.sign(s.y-o.y)};return{x:{[ht.Backward]:p.x[ht.Backward]||m.x===-1,[ht.Forward]:p.x[ht.Forward]||m.x===1},y:{[ht.Backward]:p.y[ht.Backward]||m.y===-1,[ht.Forward]:p.y[ht.Forward]||m.y===1}}},[r,s,o])}function Xh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return kr(p=>{var m;return s==null?null:(m=o??p)!=null?m:null},[o,s])}function Gh(e,s){return b.useMemo(()=>e.reduce((r,o)=>{const{sensor:p}=o,m=p.activators.map(x=>({eventName:x.eventName,handler:s(x.handler,o)}));return[...r,...m]},[]),[e,s])}var yr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(yr||(yr={}));var gn;(function(e){e.Optimized="optimized"})(gn||(gn={}));const Lo=new Map;function Qh(e,s){let{dragging:r,dependencies:o,config:p}=s;const[m,x]=b.useState(null),{frequency:i,measure:n,strategy:a}=p,h=b.useRef(e),c=l(),g=br(c),v=b.useCallback(function(u){u===void 0&&(u=[]),!g.current&&x(d=>d===null?u:d.concat(u.filter(f=>!d.includes(f))))},[g]),_=b.useRef(null),w=kr(u=>{if(c&&!r)return Lo;if(!u||u===Lo||h.current!==e||m!=null){const d=new Map;for(let f of e){if(!f)continue;if(m&&m.length>0&&!m.includes(f.id)&&f.rect.current){d.set(f.id,f.rect.current);continue}const S=f.node.current,C=S?new Xn(n(S),S):null;f.rect.current=C,C&&d.set(f.id,C)}return d}return u},[e,m,r,c,n]);return b.useEffect(()=>{h.current=e},[e]),b.useEffect(()=>{c||v()},[r,c]),b.useEffect(()=>{m&&m.length>0&&x(null)},[JSON.stringify(m)]),b.useEffect(()=>{c||typeof i!="number"||_.current!==null||(_.current=setTimeout(()=>{v(),_.current=null},i))},[i,c,v,...o]),{droppableRects:w,measureDroppableContainers:v,measuringScheduled:m!=null};function l(){switch(a){case yr.Always:return!1;case yr.BeforeDragging:return r;default:return!r}}}function Zn(e,s){return kr(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function Zh(e,s){return Zn(e,s)}function Jh(e){let{callback:s,disabled:r}=e;const o=yi(s),p=b.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(o)},[o,r]);return b.useEffect(()=>()=>p?.disconnect(),[p]),p}function wi(e){let{callback:s,disabled:r}=e;const o=yi(s),p=b.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(o)},[r]);return b.useEffect(()=>()=>p?.disconnect(),[p]),p}function ef(e){return new Xn(Er(e),e)}function Io(e,s,r){s===void 0&&(s=ef);const[o,p]=b.useState(null);function m(){p(n=>{if(!e)return null;if(e.isConnected===!1){var a;return(a=n??r)!=null?a:null}const h=s(e);return JSON.stringify(n)===JSON.stringify(h)?n:h})}const x=Jh({callback(n){if(e)for(const a of n){const{type:h,target:c}=a;if(h==="childList"&&c instanceof HTMLElement&&c.contains(e)){m();break}}}}),i=wi({callback:m});return ss(()=>{m(),e?(i?.observe(e),x?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),x?.disconnect())},[e]),o}function tf(e){const s=Zn(e);return El(e,s)}const Oo=[];function sf(e){const s=b.useRef(e),r=kr(o=>e?o&&o!==Oo&&e&&s.current&&e.parentNode===s.current.parentNode?o:Yn(e):Oo,[e]);return b.useEffect(()=>{s.current=e},[e]),r}function rf(e){const[s,r]=b.useState(null),o=b.useRef(e),p=b.useCallback(m=>{const x=Wi(m.target);x&&r(i=>i?(i.set(x,mn(x)),new Map(i)):null)},[]);return b.useEffect(()=>{const m=o.current;if(e!==m){x(m);const i=e.map(n=>{const a=Wi(n);return a?(a.addEventListener("scroll",p,{passive:!0}),[a,mn(a)]):null}).filter(n=>n!=null);r(i.length?new Map(i):null),o.current=e}return()=>{x(e),x(m)};function x(i){i.forEach(n=>{const a=Wi(n);a?.removeEventListener("scroll",p)})}},[p,e]),b.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,x)=>$s(m,x),Ht):Dl(e):Ht,[e,s])}function Bo(e,s){s===void 0&&(s=[]);const r=b.useRef(null);return b.useEffect(()=>{r.current=null},s),b.useEffect(()=>{const o=e!==Ht;o&&!r.current&&(r.current=e),!o&&r.current&&(r.current=null)},[e]),r.current?ni(e,r.current):Ht}function nf(e){b.useEffect(()=>{if(!_i)return;const s=e.map(r=>{let{sensor:o}=r;return o.setup==null?void 0:o.setup()});return()=>{for(const r of s)r?.()}},e.map(s=>{let{sensor:r}=s;return r}))}function of(e,s){return b.useMemo(()=>e.reduce((r,o)=>{let{eventName:p,handler:m}=o;return r[p]=x=>{m(x,s)},r},{}),[e,s])}function Ol(e){return b.useMemo(()=>e?Ah(e):null,[e])}const Fo=[];function af(e,s){s===void 0&&(s=Er);const[r]=e,o=Ol(r?St(r):null),[p,m]=b.useState(Fo);function x(){m(()=>e.length?e.map(n=>Tl(n)?o:new Xn(s(n),n)):Fo)}const i=wi({callback:x});return ss(()=>{i?.disconnect(),x(),e.forEach(n=>i?.observe(n))},[e]),p}function Bl(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return Cr(s)?s:e}function lf(e){let{measure:s}=e;const[r,o]=b.useState(null),p=b.useCallback(a=>{for(const{target:h}of a)if(Cr(h)){o(c=>{const g=s(h);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=wi({callback:p}),x=b.useCallback(a=>{const h=Bl(a);m?.disconnect(),h&&m?.observe(h),o(h?s(h):null)},[s,m]),[i,n]=ri(x);return b.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const cf=[{sensor:Qn,options:{}},{sensor:Il,options:{}}],df={current:{}},Yr={draggable:{measure:To},droppable:{measure:To,strategy:yr.WhileDragging,frequency:gn.Optimized},dragOverlay:{measure:Er}};class pr extends Map{get(s){var r;return s!=null&&(r=super.get(s))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(s=>{let{disabled:r}=s;return!r})}getNodeFor(s){var r,o;return(r=(o=this.get(s))==null?void 0:o.node.current)!=null?r:void 0}}const uf={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new pr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ai},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Yr,measureDroppableContainers:ai,windowRect:null,measuringScheduled:!1},Fl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ai,draggableNodes:new Map,over:null,measureDroppableContainers:ai},jr=b.createContext(Fl),zl=b.createContext(uf);function hf(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new pr}}}function ff(e,s){switch(s.type){case ct.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:s.initialCoordinates,active:s.active}};case ct.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:s.coordinates.x-e.draggable.initialCoordinates.x,y:s.coordinates.y-e.draggable.initialCoordinates.y}}};case ct.DragEnd:case ct.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case ct.RegisterDroppable:{const{element:r}=s,{id:o}=r,p=new pr(e.droppable.containers);return p.set(o,r),{...e,droppable:{...e.droppable,containers:p}}}case ct.SetDroppableDisabled:{const{id:r,key:o,disabled:p}=s,m=e.droppable.containers.get(r);if(!m||o!==m.key)return e;const x=new pr(e.droppable.containers);return x.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:x}}}case ct.UnregisterDroppable:{const{id:r,key:o}=s,p=e.droppable.containers.get(r);if(!p||o!==p.key)return e;const m=new pr(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function mf(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:p}=b.useContext(jr),m=ii(o),x=ii(r?.id);return b.useEffect(()=>{if(!s&&!o&&m&&x!=null){if(!Vn(m)||document.activeElement===m.target)return;const i=p.get(x);if(!i)return;const{activatorNode:n,node:a}=i;if(!n.current&&!a.current)return;requestAnimationFrame(()=>{for(const h of[n.current,a.current]){if(!h)continue;const c=lh(h);if(c){c.focus();break}}})}},[o,s,p,x,m]),null}function Wl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...o}),r):r}function pf(e){return b.useMemo(()=>({draggable:{...Yr.draggable,...e?.draggable},droppable:{...Yr.droppable,...e?.droppable},dragOverlay:{...Yr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function gf(e){let{activeNode:s,measure:r,initialRect:o,config:p=!0}=e;const m=b.useRef(!1),{x,y:i}=typeof p=="boolean"?{x:p,y:p}:p;ss(()=>{if(!x&&!i||!s){m.current=!1;return}if(m.current||!o)return;const a=s?.node.current;if(!a||a.isConnected===!1)return;const h=r(a),c=El(h,o);if(x||(c.x=0),i||(c.y=0),m.current=!0,Math.abs(c.x)>0||Math.abs(c.y)>0){const g=Nl(a);g&&g.scrollBy({top:c.y,left:c.x})}},[s,x,i,o,r])}const Ci=b.createContext({...Ht,scaleX:1,scaleY:1});var ls;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(ls||(ls={}));const vf=b.memo(function(s){var r,o,p,m;let{id:x,accessibility:i,autoScroll:n=!0,children:a,sensors:h=cf,collisionDetection:c=Ch,measuring:g,modifiers:v,..._}=s;const w=b.useReducer(ff,void 0,hf),[l,u]=w,[d,f]=mh(),[S,C]=b.useState(ls.Uninitialized),k=S===ls.Initialized,{draggable:{active:j,nodes:y,translate:E},droppable:{containers:R}}=l,P=j!=null?y.get(j):null,M=b.useRef({initial:null,translated:null}),L=b.useMemo(()=>{var te;return j!=null?{id:j,data:(te=P?.data)!=null?te:df,rect:M}:null},[j,P]),z=b.useRef(null),[I,W]=b.useState(null),[$,A]=b.useState(null),D=br(_,Object.values(_)),T=Si("DndDescribedBy",x),O=b.useMemo(()=>R.getEnabled(),[R]),K=pf(g),{droppableRects:V,measureDroppableContainers:B,measuringScheduled:U}=Qh(O,{dragging:k,dependencies:[E.x,E.y],config:K.droppable}),H=Xh(y,j),N=b.useMemo(()=>$?oi($):null,[$]),F=X(),q=Zh(H,K.draggable.measure);gf({activeNode:j!=null?y.get(j):null,config:F.layoutShiftCompensation,initialRect:q,measure:K.draggable.measure});const Y=Io(H,K.draggable.measure,q),se=Io(H?H.parentElement:null),G=b.useRef({activatorEvent:null,active:null,activeNode:H,collisionRect:null,collisions:null,droppableRects:V,draggableNodes:y,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),pe=R.getNodeFor((r=G.current.over)==null?void 0:r.id),he=lf({measure:K.dragOverlay.measure}),re=(o=he.nodeRef.current)!=null?o:H,ne=k?(p=he.rect)!=null?p:Y:null,le=!!(he.nodeRef.current&&he.rect),Se=tf(le?null:Y),We=Ol(re?St(re):null),Ee=sf(k?pe??H:null),He=af(Ee),at=Wl(v,{transform:{x:E.x-Se.x,y:E.y-Se.y,scaleX:1,scaleY:1},activatorEvent:$,active:L,activeNodeRect:Y,containerNodeRect:se,draggingNodeRect:ne,over:G.current.over,overlayNodeRect:he.rect,scrollableAncestors:Ee,scrollableAncestorRects:He,windowRect:We}),Me=N?$s(N,E):null,Ne=rf(Ee),Oe=Bo(Ne),$e=Bo(Ne,[Y]),qe=$s(at,Oe),De=ne?jh(ne,at):null,Ge=L&&De?c({active:L,collisionRect:De,droppableRects:V,droppableContainers:O,pointerCoordinates:Me}):null,Qe=Sh(Ge,"id"),[Te,ge]=b.useState(null),et=le?at:$s(at,$e),Xe=kh(et,(m=Te?.rect)!=null?m:null,Y),Ue=b.useRef(null),ft=b.useCallback((te,ie)=>{let{sensor:ae,options:Ce}=ie;if(z.current==null)return;const ke=y.get(z.current);if(!ke)return;const Pe=te.nativeEvent,Je=new ae({active:z.current,activeNode:ke,event:Pe,options:Ce,context:G,onAbort(xe){if(!y.get(xe))return;const{onDragAbort:Fe}=D.current,st={id:xe};Fe?.(st),d({type:"onDragAbort",event:st})},onPending(xe,me,Fe,st){if(!y.get(xe))return;const{onDragPending:jt}=D.current,wt={id:xe,constraint:me,initialCoordinates:Fe,offset:st};jt?.(wt),d({type:"onDragPending",event:wt})},onStart(xe){const me=z.current;if(me==null)return;const Fe=y.get(me);if(!Fe)return;const{onDragStart:st}=D.current,lt={activatorEvent:Pe,active:{id:me,data:Fe.data,rect:M}};Cs.unstable_batchedUpdates(()=>{st?.(lt),C(ls.Initializing),u({type:ct.DragStart,initialCoordinates:xe,active:me}),d({type:"onDragStart",event:lt}),W(Ue.current),A(Pe)})},onMove(xe){u({type:ct.DragMove,coordinates:xe})},onEnd:be(ct.DragEnd),onCancel:be(ct.DragCancel)});Ue.current=Je;function be(xe){return async function(){const{active:Fe,collisions:st,over:lt,scrollAdjustedTranslate:jt}=G.current;let wt=null;if(Fe&&jt){const{cancelDrop:xt}=D.current;wt={activatorEvent:Pe,active:Fe,collisions:st,delta:jt,over:lt},xe===ct.DragEnd&&typeof xt=="function"&&await Promise.resolve(xt(wt))&&(xe=ct.DragCancel)}z.current=null,Cs.unstable_batchedUpdates(()=>{u({type:xe}),C(ls.Uninitialized),ge(null),W(null),A(null),Ue.current=null;const xt=xe===ct.DragEnd?"onDragEnd":"onDragCancel";if(wt){const It=D.current[xt];It?.(wt),d({type:xt,event:wt})}})}}},[y]),tt=b.useCallback((te,ie)=>(ae,Ce)=>{const ke=ae.nativeEvent,Pe=y.get(Ce);if(z.current!==null||!Pe||ke.dndKit||ke.defaultPrevented)return;const Je={active:Pe};te(ae,ie.options,Je)===!0&&(ke.dndKit={capturedBy:ie.sensor},z.current=Ce,ft(ae,ie))},[y,ft]),ee=Gh(h,tt);nf(h),ss(()=>{Y&&S===ls.Initializing&&C(ls.Initialized)},[Y,S]),b.useEffect(()=>{const{onDragMove:te}=D.current,{active:ie,activatorEvent:ae,collisions:Ce,over:ke}=G.current;if(!ie||!ae)return;const Pe={active:ie,activatorEvent:ae,collisions:Ce,delta:{x:qe.x,y:qe.y},over:ke};Cs.unstable_batchedUpdates(()=>{te?.(Pe),d({type:"onDragMove",event:Pe})})},[qe.x,qe.y]),b.useEffect(()=>{const{active:te,activatorEvent:ie,collisions:ae,droppableContainers:Ce,scrollAdjustedTranslate:ke}=G.current;if(!te||z.current==null||!ie||!ke)return;const{onDragOver:Pe}=D.current,Je=Ce.get(Qe),be=Je&&Je.rect.current?{id:Je.id,rect:Je.rect.current,data:Je.data,disabled:Je.disabled}:null,xe={active:te,activatorEvent:ie,collisions:ae,delta:{x:ke.x,y:ke.y},over:be};Cs.unstable_batchedUpdates(()=>{ge(be),Pe?.(xe),d({type:"onDragOver",event:xe})})},[Qe]),ss(()=>{G.current={activatorEvent:$,active:L,activeNode:H,collisionRect:De,collisions:Ge,droppableRects:V,draggableNodes:y,draggingNode:re,draggingNodeRect:ne,droppableContainers:R,over:Te,scrollableAncestors:Ee,scrollAdjustedTranslate:qe},M.current={initial:ne,translated:De}},[L,H,Ge,De,y,re,ne,V,R,Te,Ee,qe]),Kh({...F,delta:E,draggingRect:De,pointerCoordinates:Me,scrollableAncestors:Ee,scrollableAncestorRects:He});const fe=b.useMemo(()=>({active:L,activeNode:H,activeNodeRect:Y,activatorEvent:$,collisions:Ge,containerNodeRect:se,dragOverlay:he,draggableNodes:y,droppableContainers:R,droppableRects:V,over:Te,measureDroppableContainers:B,scrollableAncestors:Ee,scrollableAncestorRects:He,measuringConfiguration:K,measuringScheduled:U,windowRect:We}),[L,H,Y,$,Ge,se,he,y,R,V,Te,B,Ee,He,K,U,We]),we=b.useMemo(()=>({activatorEvent:$,activators:ee,active:L,activeNodeRect:Y,ariaDescribedById:{draggable:T},dispatch:u,draggableNodes:y,over:Te,measureDroppableContainers:B}),[$,ee,L,Y,u,T,y,Te,B]);return ue.createElement(kl.Provider,{value:f},ue.createElement(jr.Provider,{value:we},ue.createElement(zl.Provider,{value:fe},ue.createElement(Ci.Provider,{value:Xe},a)),ue.createElement(mf,{disabled:i?.restoreFocus===!1})),ue.createElement(vh,{...i,hiddenTextDescribedById:T}));function X(){const te=I?.autoScrollEnabled===!1,ie=typeof n=="object"?n.enabled===!1:n===!1,ae=k&&!te&&!ie;return typeof n=="object"?{...n,enabled:ae}:{enabled:ae}}}),xf=b.createContext(null),zo="button",bf="Draggable";function _f(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=Si(bf),{activators:x,activatorEvent:i,active:n,activeNodeRect:a,ariaDescribedById:h,draggableNodes:c,over:g}=b.useContext(jr),{role:v=zo,roleDescription:_="draggable",tabIndex:w=0}=p??{},l=n?.id===s,u=b.useContext(l?Ci:xf),[d,f]=ri(),[S,C]=ri(),k=of(x,s),j=br(r);ss(()=>(c.set(s,{id:s,key:m,node:d,activatorNode:S,data:j}),()=>{const E=c.get(s);E&&E.key===m&&c.delete(s)}),[c,s]);const y=b.useMemo(()=>({role:v,tabIndex:w,"aria-disabled":o,"aria-pressed":l&&v===zo?!0:void 0,"aria-roledescription":_,"aria-describedby":h.draggable}),[o,v,w,l,_,h.draggable]);return{active:n,activatorEvent:i,activeNodeRect:a,attributes:y,isDragging:l,listeners:o?void 0:k,node:d,over:g,setNodeRef:f,setActivatorNodeRef:C,transform:u}}function yf(){return b.useContext(zl)}const Sf="Droppable",wf={timeout:25};function Cf(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=Si(Sf),{active:x,dispatch:i,over:n,measureDroppableContainers:a}=b.useContext(jr),h=b.useRef({disabled:r}),c=b.useRef(!1),g=b.useRef(null),v=b.useRef(null),{disabled:_,updateMeasurementsFor:w,timeout:l}={...wf,...p},u=br(w??o),d=b.useCallback(()=>{if(!c.current){c.current=!0;return}v.current!=null&&clearTimeout(v.current),v.current=setTimeout(()=>{a(Array.isArray(u.current)?u.current:[u.current]),v.current=null},l)},[l]),f=wi({callback:d,disabled:_||!x}),S=b.useCallback((y,E)=>{f&&(E&&(f.unobserve(E),c.current=!1),y&&f.observe(y))},[f]),[C,k]=ri(S),j=br(s);return b.useEffect(()=>{!f||!C.current||(f.disconnect(),c.current=!1,f.observe(C.current))},[C,f]),b.useEffect(()=>(i({type:ct.RegisterDroppable,element:{id:o,key:m,disabled:r,node:C,rect:g,data:j}}),()=>i({type:ct.UnregisterDroppable,key:m,id:o})),[o]),b.useEffect(()=>{r!==h.current.disabled&&(i({type:ct.SetDroppableDisabled,id:o,key:m,disabled:r}),h.current.disabled=r)},[o,m,r,i]),{active:x,rect:g,isOver:n?.id===o,node:C,over:n,setNodeRef:k}}function kf(e){let{animation:s,children:r}=e;const[o,p]=b.useState(null),[m,x]=b.useState(null),i=ii(r);return!r&&!o&&i&&p(i),ss(()=>{if(!m)return;const n=o?.key,a=o?.props.id;if(n==null||a==null){p(null);return}Promise.resolve(s(a,m)).then(()=>{p(null)})},[s,o,m]),ue.createElement(ue.Fragment,null,r,o?b.cloneElement(o,{ref:x}):null)}const Ef={x:0,y:0,scaleX:1,scaleY:1};function jf(e){let{children:s}=e;return ue.createElement(jr.Provider,{value:Fl},ue.createElement(Ci.Provider,{value:Ef},s))}const Nf={position:"fixed",touchAction:"none"},Rf=e=>Vn(e)?"transform 250ms ease":void 0,Af=b.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:p,children:m,className:x,rect:i,style:n,transform:a,transition:h=Rf}=e;if(!i)return null;const c=p?a:{...a,scaleX:1,scaleY:1},g={...Nf,width:i.width,height:i.height,top:i.top,left:i.left,transform:_r.Transform.toString(c),transformOrigin:p&&o?_h(o,i):void 0,transition:typeof h=="function"?h(o):h,...n};return ue.createElement(r,{className:x,style:g,ref:s},m)}),Tf=e=>s=>{let{active:r,dragOverlay:o}=s;const p={},{styles:m,className:x}=e;if(m!=null&&m.active)for(const[i,n]of Object.entries(m.active))n!==void 0&&(p[i]=r.node.style.getPropertyValue(i),r.node.style.setProperty(i,n));if(m!=null&&m.dragOverlay)for(const[i,n]of Object.entries(m.dragOverlay))n!==void 0&&o.node.style.setProperty(i,n);return x!=null&&x.active&&r.node.classList.add(x.active),x!=null&&x.dragOverlay&&o.node.classList.add(x.dragOverlay),function(){for(const[n,a]of Object.entries(p))r.node.style.setProperty(n,a);x!=null&&x.active&&r.node.classList.remove(x.active)}},Mf=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:_r.Transform.toString(s)},{transform:_r.Transform.toString(r)}]},Df={duration:250,easing:"ease",keyframes:Mf,sideEffects:Tf({styles:{active:{opacity:"0"}}})};function Pf(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return yi((m,x)=>{if(s===null)return;const i=r.get(m);if(!i)return;const n=i.node.current;if(!n)return;const a=Bl(x);if(!a)return;const{transform:h}=St(x).getComputedStyle(x),c=jl(h);if(!c)return;const g=typeof s=="function"?s:Lf(s);return Pl(n,p.draggable.measure),g({active:{id:m,data:i.data,node:n,rect:p.draggable.measure(n)},draggableNodes:r,dragOverlay:{node:x,rect:p.dragOverlay.measure(a)},droppableContainers:o,measuringConfiguration:p,transform:c})})}function Lf(e){const{duration:s,easing:r,sideEffects:o,keyframes:p}={...Df,...e};return m=>{let{active:x,dragOverlay:i,transform:n,...a}=m;if(!s)return;const h={x:i.rect.left-x.rect.left,y:i.rect.top-x.rect.top},c={scaleX:n.scaleX!==1?x.rect.width*n.scaleX/i.rect.width:1,scaleY:n.scaleY!==1?x.rect.height*n.scaleY/i.rect.height:1},g={x:n.x-h.x,y:n.y-h.y,...c},v=p({...a,active:x,dragOverlay:i,transform:{initial:n,final:g}}),[_]=v,w=v[v.length-1];if(JSON.stringify(_)===JSON.stringify(w))return;const l=o?.({active:x,dragOverlay:i,...a}),u=i.node.animate(v,{duration:s,easing:r,fill:"forwards"});return new Promise(d=>{u.onfinish=()=>{l?.(),d()}})}}let Wo=0;function If(e){return b.useMemo(()=>{if(e!=null)return Wo++,Wo},[e])}const Of=ue.memo(e=>{let{adjustScale:s=!1,children:r,dropAnimation:o,style:p,transition:m,modifiers:x,wrapperElement:i="div",className:n,zIndex:a=999}=e;const{activatorEvent:h,active:c,activeNodeRect:g,containerNodeRect:v,draggableNodes:_,droppableContainers:w,dragOverlay:l,over:u,measuringConfiguration:d,scrollableAncestors:f,scrollableAncestorRects:S,windowRect:C}=yf(),k=b.useContext(Ci),j=If(c?.id),y=Wl(x,{activatorEvent:h,active:c,activeNodeRect:g,containerNodeRect:v,draggingNodeRect:l.rect,over:u,overlayNodeRect:l.rect,scrollableAncestors:f,scrollableAncestorRects:S,transform:k,windowRect:C}),E=Zn(g),R=Pf({config:o,draggableNodes:_,droppableContainers:w,measuringConfiguration:d}),P=E?l.setRef:void 0;return ue.createElement(jf,null,ue.createElement(kf,{animation:R},c&&j?ue.createElement(Af,{key:j,id:c.id,ref:P,as:i,activatorEvent:h,adjustScale:s,className:n,transition:m,rect:E,style:{zIndex:a,...p},transform:y},r):null))}),Hl=768;function Bf(e){const s=window.matchMedia(`(max-width: ${Hl-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function Ff(){return window.innerWidth<Hl}function zf(){return!1}function Ul(){return b.useSyncExternalStore(Bf,Ff,zf)}const Wf=1500,Hf=2e3,Uf=5e3;function $l(e,s){return e&&s?.workingDir===e&&s.tab==="changes"?Wf:!1}function $f(e,s){return e&&s?.workspaceId===e&&s.tab==="changes"?Hf:!1}function qf(e,s){return e&&s?.workingDir===e&&s.tab==="history"?Uf:!1}function Jn(e){return Et({queryKey:ce.workspaces.list(e),queryFn:()=>ye.get(`/tasks/${e}/workspaces`),enabled:!!e})}function ql(e){const s=vt();return Ut({mutationFn:r=>ye.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{s.invalidateQueries({queryKey:ce.workspaces.list(e)}),s.invalidateQueries({queryKey:ce.tasks.all})}})}function Kl(){const e=vt();return Ut({mutationFn:({id:s,commitMessage:r,stopActiveServices:o})=>ye.post(`/workspaces/${s}/merge`,{commitMessage:r,stopActiveServices:o}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all}),e.invalidateQueries({queryKey:ce.git.all}),e.invalidateQueries({queryKey:ce.workspaceServices.all})},onError:()=>{e.invalidateQueries({queryKey:ce.git.all}),e.invalidateQueries({queryKey:ce.workspaceServices.all})}})}function Kf(){const e=vt();return Ut({mutationFn:s=>ye.post(`/workspaces/${s}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:ce.workspaces.all}),e.invalidateQueries({queryKey:ce.tasks.all})}})}function eo(){return Ut({mutationFn:({workspaceId:e,editorType:s})=>ye.post(`/workspaces/${e}/open-editor`,{editorType:s})})}function to(e,s={}){const r=Rs(p=>p.visibleContext),o=$f(e,r);return Et({queryKey:ce.workspaces.gitStatus(e),queryFn:()=>ye.get(`/workspaces/${e}/git-status`),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function Vl(){const e=vt();return Ut({mutationFn:s=>ye.post(`/workspaces/${s}/rebase`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})},onError:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})}})}function so(){const e=vt();return Ut({mutationFn:s=>ye.post(`/workspaces/${s}/abort-operation`),onSuccess:(s,r)=>{e.invalidateQueries({queryKey:ce.workspaces.gitStatus(r)}),e.invalidateQueries({queryKey:ce.git.all})}})}function Vf(e,s){const r=[];if(!e||e.length===0)return r;const o=e.some(m=>m.status==="ACTIVE");return e.some(m=>m.sessions?.some(x=>x.status===ut.RUNNING||x.status===ut.PENDING))&&r.push(s("正在运行的 Agent 将被停止")),o&&(r.push(s("分支上未合并的变更将丢失")),r.push(s("关联的工作目录(worktree)将被清理"))),r}function ro({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:x}){const{t:i}=de(),{data:n,isLoading:a}=Jn(m===void 0&&e?o:""),h=m??n,c=m===void 0&&e&&a,g=b.useMemo(()=>Vf(h,i),[h,i]);return t.jsx(Ln,{isOpen:e,onClose:s,onConfirm:r,title:i("删除任务"),description:t.jsxs(t.Fragment,{children:[t.jsx("p",{children:i("确认删除任务「{title}」?此操作不可撤销。",{title:p})}),c?t.jsx("p",{className:"mt-2 text-xs text-neutral-400",children:i("加载中...")}):g.length>0?t.jsx("ul",{className:"mt-2 space-y-1",children:g.map((v,_)=>t.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[t.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),t.jsx("span",{children:v})]},_))}):null]}),confirmText:i("删除"),variant:"danger",isLoading:x||c})}const _e={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},ci={[_e.Review]:{label:"Review",icon:nl,iconClass:"text-warning",accentClass:"text-warning"},[_e.Running]:{label:"Running",icon:il,iconClass:"text-info",accentClass:"text-info"},[_e.Pending]:{label:"Pending",icon:rl,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground"},[_e.Done]:{label:"Done",icon:sl,iconClass:"text-success/80",accentClass:"text-success"},[_e.Cancelled]:{label:"Cancelled",icon:tl,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70"}},Yf=[_e.Review,_e.Running,_e.Pending,_e.Done,_e.Cancelled],Xf="flex w-full min-w-0 items-center gap-2.5 rounded-md px-2 text-sm text-left transition-[background-color,box-shadow,color] duration-150 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",Gf="h-8 pointer-coarse:h-10";function dr(e){return Z(Xf,Gf,e?"bg-background text-foreground shadow-xs ring-1 ring-border/80":"text-foreground/80 hover:bg-accent hover:text-foreground active:bg-foreground/[0.06]")}const Yl=b.createContext(null),Qf=3e4;function Zf(e=Qf){const[,s]=b.useState(0);b.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}const vn=60,xn=60*vn,$i=24*xn;function Jf(e,s,r){const o=new Date(e),p=Math.max(0,Math.floor((Date.now()-o.getTime())/1e3));if(p<vn)return s("now");if(p<xn)return s("{count}m",{count:Math.floor(p/vn)});if(p<$i)return s("{count}h",{count:Math.floor(p/xn)});if(p<7*$i)return s("{count}d",{count:Math.floor(p/$i)});const m=o.getFullYear()===new Date().getFullYear();return o.toLocaleDateString(r,m?{month:"numeric",day:"numeric"}:{year:"numeric",month:"numeric"})}function em(e){const s=Rd(e,9,"..");if(s===e)return e;const r=s.slice(0,-2),o=r.search(/[-_.\s][^-_.\s]*$/);return`${o>=3?r.slice(0,o):r}..`}const qi="flex w-full items-center gap-2 rounded-md px-2 py-1.5 text-left text-[13px] text-foreground/80 transition-colors hover:bg-accent hover:text-foreground focus-visible:bg-accent focus-visible:outline-none",Ho="px-2 pb-1 pt-1.5 text-[11px] font-medium text-muted-foreground",Uo=t.jsx("div",{className:"-mx-1 my-1 h-px bg-border/60"});function tm({task:e,status:s,isSelected:r,project:o,showProject:p,onSelectTask:m,onTaskStatusChange:x,onDeleteTask:i,onTaskPriorityChange:n,disableDrag:a}){const{t:h,locale:c}=de(),g=b.useContext(Yl),v=b.useRef(null),_=!!e.projectArchivedAt,w=_||!!a,{attributes:l,listeners:u,setNodeRef:d,isDragging:f}=_f({id:e.id,data:{task:e,fromStatus:s},disabled:w}),S=b.useCallback(D=>{v.current=D,d(D),g&&(D?g.registry.set(e.id,D):g.registry.delete(e.id))},[d,g,e.id]);b.useEffect(()=>()=>{g?.registry.delete(e.id)},[e.id,g]);const[C,k]=b.useState(null),[j,y]=b.useState(!1),E=b.useRef(null),R=b.useRef(null),P=b.useCallback(D=>{_||!x&&!i&&!n||(D.preventDefault(),k({x:D.clientX,y:D.clientY}))},[_,x,i,n]),M=b.useCallback(()=>{R.current&&(clearTimeout(R.current),R.current=null)},[]),L=b.useCallback(D=>{if(!a||_||!x&&!i)return;const T=D.touches[0];if(!T)return;const{clientX:O,clientY:K}=T;R.current=setTimeout(()=>{R.current=null,k({x:O,y:K})},500)},[a,_,x,i]);b.useEffect(()=>{if(!C)return;const D=()=>k(null),T=K=>{E.current&&!E.current.contains(K.target)&&D()},O=K=>{K.key==="Escape"&&D()};return document.addEventListener("mousedown",T),document.addEventListener("touchstart",T),document.addEventListener("keydown",O),window.addEventListener("scroll",D,!0),window.addEventListener("resize",D),()=>{document.removeEventListener("mousedown",T),document.removeEventListener("touchstart",T),document.removeEventListener("keydown",O),window.removeEventListener("scroll",D,!0),window.removeEventListener("resize",D)}},[C]),b.useLayoutEffect(()=>{const D=E.current;if(!C||!D)return;const T=8;D.style.left=`${Math.max(T,Math.min(C.x,window.innerWidth-D.offsetWidth-T))}px`,D.style.top=`${Math.max(T,Math.min(C.y,window.innerHeight-D.offsetHeight-T))}px`},[C]);const z=o?o.name:void 0,I=p?o:void 0,W=e.updatedAt?Jf(e.updatedAt,h,c):null,{icon:$,iconClass:A}=ci[s];return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:S,type:"button",onClick:()=>m(e.id),onContextMenu:P,onTouchStart:L,onTouchEnd:M,onTouchMove:M,title:I?`${e.title} · ${I.name}`:e.title,"aria-label":z?`${e.title} — ${z}`:e.title,"aria-current":r||void 0,"data-sidebar-item":"",className:Z("task-row animate-task-enter",dr(r),f&&"opacity-30"),...w?{}:u,...w?{}:l,children:[t.jsx($,{className:Z("shrink-0",A,s===_e.Running&&"motion-safe:animate-pulse")}),t.jsx("span",{className:"min-w-0 flex-1 truncate",children:e.title}),e.priority!==void 0&&e.priority!==Gr.NORMAL&&t.jsx(wo,{priority:e.priority}),e.projectArchivedAt&&t.jsx("span",{className:"inline-flex shrink-0 items-center rounded-full bg-foreground/[0.06] px-1.5 py-0.5 text-[10px] font-medium leading-none text-muted-foreground",children:e.projectRepoDeletedAt?h("源码已删除"):h("已删除")}),(W||I)&&t.jsx("span",{className:"task-row-meta",children:t.jsxs("span",{className:"flex items-center gap-1",children:[I&&t.jsx("span",{className:"shrink-0 whitespace-nowrap rounded bg-foreground/[0.05] px-1 py-0.5 text-[10px] font-medium leading-none @max-[22rem]:hidden",children:t.jsx("span",{className:Z(I.color,"bg-[linear-gradient(90deg,currentColor_0.6em,var(--muted-foreground)_2.6em)] bg-clip-text [-webkit-text-fill-color:transparent]"),children:em(I.name)})}),W&&t.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:W})]})})]}),C&&t.jsxs("div",{ref:E,role:"menu",className:"fixed z-[100] w-48 rounded-lg border border-border bg-popover p-1 shadow-lg shadow-black/5 animate-in fade-in zoom-in-95 duration-100",children:[x&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:Ho,children:h("Move to")}),Yf.filter(D=>D!==s).map(D=>{const{icon:T,label:O,accentClass:K}=ci[D];return t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{x(e.id,D),k(null)},className:qi,children:[t.jsx(T,{className:Z("size-3.5 shrink-0",K)}),t.jsx("span",{children:h(O)})]},D)})]}),n&&t.jsxs(t.Fragment,{children:[x&&Uo,t.jsx("div",{className:Ho,children:h("Priority")}),su.map(D=>{const T=(e.priority??Gr.NORMAL)===D.value;return t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":T,onClick:()=>{n(e.id,D.value),k(null)},className:qi,children:[t.jsx(wo,{priority:D.value}),t.jsx("span",{className:"flex-1",children:h(D.label)}),T&&t.jsx(Wt,{className:"size-3.5 shrink-0 text-foreground","aria-hidden":!0})]},D.value)})]}),i&&t.jsxs(t.Fragment,{children:[(x||n)&&Uo,t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{y(!0),k(null)},className:Z(qi,"text-destructive hover:bg-destructive/10 hover:text-destructive focus-visible:bg-destructive/10"),children:[t.jsx(pi,{className:"size-3.5 shrink-0","aria-hidden":!0}),t.jsx("span",{children:h("Delete Task")})]})]})]}),t.jsx(ro,{isOpen:j,onClose:()=>y(!1),onConfirm:()=>{i?.(e.id),y(!1)},taskId:e.id,taskTitle:e.title})]})}const sm=b.memo(function({title:s,tasks:r,status:o,defaultOpen:p,selectedTaskId:m,onSelectTask:x,projects:i,showProject:n=!0,isDragging:a,dragFromStatus:h,onTaskStatusChange:c,onDeleteTask:g,onTaskPriorityChange:v,disableDrag:_}){const{t:w}=de(),[l,u]=b.useState(p);Zf();const d=r.length===0,f=a&&h===o,S=a&&h!==o,{setNodeRef:C,isOver:k}=Cf({id:`group-${o}`,data:{status:o}}),j=o===_e.Review,y=w(s),E=a?f:l;return t.jsxs("div",{className:"mb-2","data-task-group-status":o,children:[t.jsx("div",{className:"px-2",children:t.jsxs("button",{type:"button",onClick:()=>!a&&u(R=>!R),"aria-expanded":l,"data-sidebar-item":"",className:"group/header flex h-7 w-full items-center gap-1 rounded-md px-2 text-xs font-medium text-muted-foreground transition-colors hover:bg-accent hover:text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx("span",{className:"truncate",children:y}),t.jsx(At,{size:12,"aria-hidden":!0,className:Z("shrink-0 text-muted-foreground/60 transition-transform duration-150 group-hover/header:text-muted-foreground",E&&"rotate-90")}),j&&!d?t.jsx("span",{className:"ml-auto rounded-full bg-warning/15 px-1.5 text-[11px] font-semibold leading-4 tabular-nums text-warning",children:r.length}):t.jsx("span",{className:"ml-auto text-[11px] font-normal tabular-nums text-muted-foreground/80",children:r.length})]})}),S&&t.jsx("div",{ref:C,className:Z("mx-2 mt-0.5 flex h-9 items-center justify-center rounded-md border border-dashed text-xs font-medium transition-colors duration-150",k?"border-info/50 bg-info/5 text-info":"border-border bg-foreground/[0.02] text-muted-foreground"),children:k?w("Drop into {title}",{title:y}):w("Drop here")}),E&&!S&&!d&&t.jsx("div",{ref:f?void 0:C,className:"mt-0.5 flex flex-col gap-px px-2",children:r.map(R=>{const P=m===R.id,M=R.projectId?i.find(L=>L.id===R.projectId):void 0;return t.jsx(tm,{task:R,status:o,isSelected:P,project:M,showProject:n,onSelectTask:x,onTaskStatusChange:R.projectArchivedAt?void 0:c,onDeleteTask:R.projectArchivedAt?void 0:g,onTaskPriorityChange:R.projectArchivedAt?void 0:v,disableDrag:_},R.id)})})]})}),rm=12,im=50;function nm({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=de(),[x,i]=b.useState(""),[n,a]=b.useState(0),h=b.useRef(null);b.useEffect(()=>{e&&(i(""),a(0))},[e]);const c=b.useMemo(()=>{const _=x.trim().toLowerCase();return _?r.filter(w=>w.title.toLowerCase().includes(_)).slice(0,im):r.slice(0,rm)},[r,x]);b.useEffect(()=>{a(0)},[x]),b.useEffect(()=>{h.current?.children[n]?.scrollIntoView({block:"nearest"})},[n]);const g=b.useCallback(_=>{p(_),s()},[p,s]),v=b.useCallback(_=>{if(_.key==="Escape")_.preventDefault(),s();else if(_.key==="ArrowDown")_.preventDefault(),a(w=>Math.min(w+1,c.length-1));else if(_.key==="ArrowUp")_.preventDefault(),a(w=>Math.max(w-1,0));else if(_.key==="Enter"&&!_.nativeEvent.isComposing){_.preventDefault();const w=c[n];w&&g(w.id)}},[s,c,n,g]);return e?t.jsxs("div",{className:"fixed inset-0 z-90",role:"dialog","aria-modal":"true",children:[t.jsx("div",{className:"absolute inset-0 bg-black/20",onClick:s}),t.jsxs("div",{className:"absolute left-1/2 top-[18vh] w-[min(560px,calc(100vw-2rem))] -translate-x-1/2 bg-popover rounded-xl border border-border shadow-lg overflow-hidden animate-in fade-in zoom-in-95 duration-100",children:[t.jsxs("div",{className:"flex items-center gap-2.5 px-4 border-b border-border/60",children:[t.jsx(In,{size:15,className:"text-muted-foreground/70 shrink-0"}),t.jsx("input",{value:x,onChange:_=>i(_.target.value),onKeyDown:v,placeholder:m("Search tasks..."),"aria-label":m("Search tasks..."),autoFocus:!0,className:"flex-1 py-3 bg-transparent border-none focus:outline-none text-sm text-foreground placeholder-muted-foreground/60"})]}),c.length>0?t.jsxs(t.Fragment,{children:[!x.trim()&&t.jsx("div",{className:"px-4 pt-2.5 pb-1 text-[11px] font-medium text-muted-foreground/70",children:m("Recent tasks")}),t.jsx("div",{ref:h,className:"max-h-[46vh] overflow-y-auto scrollbar-app-thin pb-1.5 pt-0.5",children:c.map((_,w)=>{const l=o.find(f=>f.id===_.projectId),{icon:u,iconClass:d}=ci[_.status];return t.jsxs("button",{onClick:()=>g(_.id),onMouseEnter:()=>a(w),className:`w-full flex items-center gap-2.5 px-4 py-2 text-left transition-colors
7
- ${w===n?"bg-accent":""}`,children:[t.jsx(u,{className:`${d} shrink-0`}),t.jsx("span",{className:"flex-1 min-w-0 truncate text-sm text-foreground/90",title:_.title,children:_.title}),l&&t.jsx("span",{className:"shrink-0 max-w-[120px] truncate text-xs text-muted-foreground/70",children:l.name})]},_.id)})})]}):t.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted-foreground/70",children:m("No matching tasks")})]})]}):null}const om=260,am=220;function lm(e){const s={[_e.Review]:[],[_e.Running]:[],[_e.Pending]:[],[_e.Done]:[],[_e.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s[_e.Review].sort((r,o)=>(o.priority??Gr.NORMAL)-(r.priority??Gr.NORMAL)),s}const cm=[{status:_e.Review,title:"Review",defaultOpen:!0},{status:_e.Running,title:"Running",defaultOpen:!0},{status:_e.Pending,title:"Pending",defaultOpen:!1},{status:_e.Done,title:"Done",defaultOpen:!1},{status:_e.Cancelled,title:"Cancelled",defaultOpen:!1}];function dm(){return t.jsx("div",{className:"flex-1 overflow-hidden px-2 pt-3 motion-safe:animate-pulse","aria-hidden":!0,children:[3,4].map((e,s)=>t.jsxs("div",{className:"mb-2",children:[t.jsx("div",{className:"flex h-7 items-center px-2",children:t.jsx("div",{className:"h-2.5 w-12 rounded-full bg-foreground/[0.06]"})}),Array.from({length:e}).map((r,o)=>t.jsxs("div",{className:"flex h-8 items-center gap-2.5 px-2 pointer-coarse:h-10",children:[t.jsx("div",{className:"size-4 shrink-0 rounded-full bg-foreground/[0.06]"}),t.jsx("div",{className:"h-3 rounded-full bg-foreground/[0.06]",style:{width:`${64-(o+s)%3*14}%`}}),t.jsx("div",{className:"ml-auto h-2.5 w-8 shrink-0 rounded-full bg-foreground/[0.05]"})]},o))]},s))})}function $o({tasks:e=[],projects:s=[],selectedTaskId:r,onSelectTask:o,filterProjectId:p,setFilterProjectId:m,width:x=320,onCreateTask:i,onCreateProject:n,isCreateActive:a,onTaskStatusChange:h,onDeleteTask:c,onTaskPriorityChange:g,isLoading:v=!1}){const{t:_}=de(),{preserveDesktopSearch:w}=Ha(),l=Ul(),[u,d]=b.useState(null),[f,S]=b.useState(null),[C,k]=b.useState(!1),j=b.useRef(new Map),y=b.useRef(new Set),E=b.useRef(new Map),R=b.useMemo(()=>({registry:j.current}),[]),P=b.useCallback(B=>{B.remove(),y.current.delete(B)},[]),M=p?e.filter(B=>B.projectId===p):e,L=b.useCallback((B,U)=>{const H=document.querySelector(`[data-task-group-status="${B}"]`);if(!H)return null;const F=(H.querySelector("button")??H).getBoundingClientRect();return F.width===0||F.height===0?null:new DOMRect(F.left,F.bottom+2,U.width,U.height)},[]),z=b.useCallback((B,U,H,N=!1)=>{const F=document.createElement("div");F.setAttribute("aria-hidden","true"),F.innerHTML=H;const q=F.firstElementChild;q&&(q.style.cssText="",q.className=q.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),q.style.pointerEvents="none",q.style.width=`${B.width}px`,q.style.height=`${B.height}px`,q.style.margin="0",q.style.backgroundColor="var(--background)",q.style.borderRadius="0.5rem",q.style.boxShadow="0 4px 6px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border)",q.style.opacity="0.96",q.style.transition="none",q.setAttribute("tabindex","-1")),Object.assign(F.style,{position:"fixed",left:`${B.left}px`,top:`${B.top}px`,width:`${B.width}px`,height:`${B.height}px`,zIndex:"9999",pointerEvents:"none",overflow:"visible",transformOrigin:"top left",willChange:"transform, opacity"}),document.body.appendChild(F),y.current.add(F);const Y=U.left-B.left,se=U.top-B.top;F.animate([{transform:"translate(0, 0)",opacity:.96,offset:0},{transform:`translate(${Y}px, ${se}px)`,opacity:N?.12:.96,offset:1}],{duration:N?am:om,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>P(F),()=>P(F))},[P]);b.useLayoutEffect(()=>{const B=window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=new Map;for(const H of M){const N=j.current.get(H.id);if(!N)continue;const F={status:H.status,rect:N.getBoundingClientRect(),html:N.outerHTML};if(U.set(H.id,F),B)continue;const q=E.current.get(H.id);if(!q||q.status===H.status)continue;const Y=F.rect.left-q.rect.left,se=F.rect.top-q.rect.top;Math.abs(Y)<1&&Math.abs(se)<1||z(q.rect,F.rect,q.html)}if(!B)for(const[H,N]of E.current){if(U.has(H))continue;const F=M.find(Y=>Y.id===H);if(!F||F.status===N.status)continue;const q=L(F.status,N.rect);q&&z(N.rect,q,N.html,!0)}E.current=U},[M,z,L]),b.useEffect(()=>()=>{for(const B of y.current)B.remove();y.current.clear()},[]);const I=bh(xh(Qn,{activationConstraint:{distance:8}})),W=b.useCallback(B=>{const U=B.active.data.current?.task,H=B.active.data.current?.fromStatus;U&&d(U),H&&S(H)},[]),$=b.useCallback(B=>{d(null),S(null);const{active:U,over:H}=B;if(!H)return;const N=U.data.current?.task,F=U.data.current?.fromStatus,q=H.data.current?.status;!N||!F||!q||N.projectArchivedAt||F!==q&&h?.(N.id,q)},[h]),T=!!!(p?s.find(B=>B.id===p)??null:null)?.archivedAt,O=lm(M),K=u?ci[u.status]:null,V=b.useCallback(B=>{if(B.key!=="ArrowDown"&&B.key!=="ArrowUp"||B.altKey||B.ctrlKey||B.metaKey||B.shiftKey)return;const U=Array.from(B.currentTarget.querySelectorAll("[data-sidebar-item]:not(:disabled)")),H=U.indexOf(B.target);H!==-1&&(B.preventDefault(),U[H+(B.key==="ArrowDown"?1:-1)]?.focus())},[]);return t.jsxs("div",{className:"@container h-full flex flex-col flex-shrink-0",style:{width:x},onKeyDown:V,children:[t.jsxs("div",{className:"px-2 pt-2 pb-1 flex flex-col gap-px flex-shrink-0",children:[n&&t.jsxs("button",{type:"button",onClick:n,"data-sidebar-item":"",className:dr(!1),children:[t.jsx(lu,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",children:_("New Project")})]}),t.jsxs("button",{type:"button",onClick:i,disabled:!T,"aria-current":a||void 0,"data-sidebar-item":"",className:Z(dr(!!a),"disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"),title:T?void 0:_("Deleted projects are read-only"),children:[t.jsx(ru,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",children:_("New Task")})]}),t.jsxs("button",{type:"button",onClick:()=>k(!0),"data-sidebar-item":"",className:dr(!1),children:[t.jsx(In,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",children:_("Search")})]}),t.jsxs(Ad,{to:w("/conversations"),"data-sidebar-item":"",className:dr(!1),children:[t.jsx(gi,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",children:_("对话")})]})]}),v?t.jsx(dm,{}):M.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-6 pb-[10vh] text-center select-none",children:[t.jsx(Vs,{size:36,className:"text-muted-foreground/40 mb-3",strokeWidth:1.5}),t.jsx("p",{className:"text-sm text-muted-foreground mb-4",children:_("No tasks")}),T&&i?t.jsx("button",{type:"button",onClick:i,className:"px-3.5 py-1.5 rounded-md bg-brand text-brand-foreground text-xs font-medium hover:bg-brand/90 transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60 focus-visible:ring-offset-2",children:_("New Task")}):null]}):t.jsx(Yl.Provider,{value:R,children:t.jsxs(vf,{sensors:I,onDragStart:W,onDragEnd:$,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin pt-3 pb-4 relative",children:cm.map(({status:B,title:U,defaultOpen:H})=>t.jsx(sm,{title:U,tasks:O[B],status:B,defaultOpen:H,selectedTaskId:r,onSelectTask:o,projects:s,showProject:!p,isDragging:u!==null,dragFromStatus:f,onTaskStatusChange:h,onDeleteTask:c,onTaskPriorityChange:g,disableDrag:l},B))}),t.jsx(Of,{dropAnimation:null,children:u&&K?t.jsxs("div",{className:"flex h-8 w-fit max-w-[280px] items-center gap-2.5 rounded-md bg-background px-2 text-sm text-foreground shadow-[0_12px_16px_-4px_rgba(36,36,36,0.08)] ring-1 ring-border/80",children:[t.jsx(K.icon,{className:Z("shrink-0",K.iconClass)}),t.jsx("span",{className:"truncate",title:u.title,children:u.title})]}):null})]})}),!v&&t.jsxs("div",{className:"h-9 px-4 flex flex-shrink-0 items-center justify-between border-t border-border/60 text-xs text-muted-foreground",children:[t.jsx("span",{className:"tabular-nums",children:_("{count} tasks",{count:M.length})}),p?t.jsx("button",{type:"button",onClick:()=>m(null),className:"rounded-sm hover:text-foreground underline decoration-border underline-offset-2 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:_("Clear filter")}):null]}),t.jsx(nm,{isOpen:C,onClose:()=>k(!1),tasks:M,projects:s,onSelectTask:o})]})}const um=10,hm=24,Xl=um*hm,fm=8;function mm(e,s=Xl){return e>s+fm}function pm(e,s){return e.includes(s)?e:[...e,s]}function gm(e,s){return e.filter(r=>r!==s)}function vm(e,s){const r=new Map(s.map(o=>[o.id,o]));return e.map(o=>r.get(o)).filter(o=>!!o).map(o=>({memberId:o.id,label:o.name}))}const ki=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function qo(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function xm(e,s=[],r=[]){const o=new Set(r.filter(m=>ki.has(m.status)).map(m=>m.workRequestId));return[...e.map(m=>({kind:"message",key:`message:${m.id}`,sortTime:m.createdAt,order:0,message:m})),...s.filter(m=>m.status==="PENDING_APPROVAL").filter(m=>!o.has(m.id)).map(m=>({kind:"pendingApproval",key:`pending-approval:${m.id}`,sortTime:m.updatedAt??m.createdAt,order:1,request:m}))].sort((m,x)=>{const i=qo(m.sortTime)-qo(x.sortTime);return i!==0?i:m.order!==x.order?m.order-x.order:m.key.localeCompare(x.key)})}function bm(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 _m(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 ym(e,s){const r=e.reduce((p,m)=>(p[m.status]=(p[m.status]??0)+1,p),{});return[["RUNNING","running"],["QUEUED","queued"],["WAITING_ROOM_REPLY","waiting"],["SESSION_ENDED","ended"]].map(([p,m])=>{const x=r[p];return x?`${x} ${s(m)}`:null}).filter(p=>!!p).join(" · ")}function Sm(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function wm({status:e}){const{t:s}=de();return e==="RUNNING"?t.jsxs(t.Fragment,{children:[s("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:s(bm(e))})}function Cm({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:p,isStopPending:m,stoppingMemberId:x,stopPromptInvocationId:i,onToggleStopConfirm:n}){const{t:a}=de(),[h,c]=b.useState(Sm),g=b.useMemo(()=>e.filter(_=>ki.has(_.status)).sort((_,w)=>Date.parse(w.updatedAt??w.createdAt??"")-Date.parse(_.updatedAt??_.createdAt??"")),[e]);if(g.length===0)return null;const v=ym(g,a);return t.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[t.jsxs("button",{type:"button",onClick:()=>c(_=>!_),"aria-expanded":h,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:a("Active work")}),t.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),t.jsx("span",{children:v})]}),h?t.jsx(kt,{size:15,className:"shrink-0 text-neutral-400"}):t.jsx(xl,{size:15,className:"shrink-0 text-neutral-400"})]}),h&&t.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(_=>{const w=s.get(_.memberId),l=r.get(_.workRequestId),u=!!(_.sessionId&&o),d=!!w,f=i===_.id,S=m&&x===_.memberId,C=l?.instruction??_.workRequestId;return t.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[t.jsxs("div",{title:C,className:Z("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",u?"cursor-pointer hover:bg-white":"cursor-default"),role:u?"button":void 0,tabIndex:u?0:void 0,onClick:()=>_.sessionId&&o?.(_.sessionId),onKeyDown:k=>{!u||!_.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),o?.(_.sessionId))},children:[t.jsx(Xt,{name:w?.name??a("Agent"),avatar:w?.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:w?.name??a("Agent")}),t.jsx("span",{className:Z("shrink-0",_m(_.status)),children:t.jsx(wm,{status:_.status})})]}),u&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),_.sessionId&&o?.(_.sessionId)},onKeyDown:k=>k.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:a("View log"),"aria-label":`${a("View log")} ${w?.name??a("Agent")}`,children:t.jsx(fn,{size:13})}),d&&t.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),n(_.id)},onKeyDown:k=>k.stopPropagation(),disabled:S,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:a("Stop"),"aria-label":`${a("Stop")} ${w?.name??a("Agent")}`,children:t.jsx(qs,{size:12})})]}),d&&f&&w&&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:a("Stop running work?")}),t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:S,onClick:()=>p(w.id,!1),children:[t.jsx(qs,{size:11}),t.jsx("span",{children:a(S?"Stopping":"Stop only")})]}),t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:S,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>p(w.id,!0),children:[t.jsx(_l,{size:11}),t.jsx("span",{children:a(S?"Stopping":"Stop + clear queue")})]})]})]},_.id)})})]})}const bn=wr(),km=240;let Ko=0;function Em(e,s){return Ko+=1,{id:`pending-room-message-${Date.now()}-${Ko}`,teamRunId:e,senderType:s.senderType??"user",senderId:s.senderId??null,senderInvocationId:s.senderInvocationId??null,kind:s.kind??((s.mentions?.length??0)>0?"work_request":"chat"),visibility:"PUBLIC",content:s.content,mentions:s.mentions??[],workRequestIds:[],artifactRefs:s.artifactRefs??[],attachmentIds:s.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function Gl(e){return"pendingStatus"in e}function jm(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Nm(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function _n(e,s){if(s.length===0)return e;const r=new Set(s.map(Nm));return e.split(`
8
- `).map(o=>{const p=o.match(/^\s*/)?.[0]??"",m=o.trimStart();for(const x of r){if(m===x)return null;if(m.startsWith(`${x} `)||m.startsWith(`${x} `))return`${p}${m.slice(x.length).trimStart()}`}return o}).filter(o=>o!=null).join(`
9
- `).replace(/\n{3,}/g,`
10
-
11
- `).trim()}function Rm(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function yn(e,s){return e instanceof Error?e.message:s}function Am(e,s=km){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Tm(e,s){const o=e.slice(0,s).match(/(^|\s)@([^\s@]*)$/);return!o||o.index==null?null:{start:o.index+o[1].length,end:s,query:o[2]??""}}function Mm(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function Vo(e){return e.membershipStatus!=="REMOVED"}function Dm(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function Pm(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function Lm(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const p=r.map(x=>Dm(x,s)).filter(x=>x&&!o.includes(`@${x}`));if(p.length===0)return o;const m=p.map(x=>`@${x}`).join(" ");return o.trimEnd()?`${o.trimEnd()} ${m}`:m}function Im(e,s,r){if(e.senderType!=="agent")return null;if(e.senderId&&s.has(e.senderId))return s.get(e.senderId)??null;if(e.senderInvocationId){const o=r.get(e.senderInvocationId);if(o?.memberId&&s.has(o.memberId))return s.get(o.memberId)??null}return null}function Om({content:e,isUser:s,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:x}){const i=b.useMemo(()=>m||x?Yd(e):e,[e,x,m]),n=Xd(i),a=b.useMemo(()=>Gd({workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:x}),[x,p,m,o,r]);return t.jsx("div",{className:Z("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",s?["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:a,plugins:n,controls:n?Qd:void 0,children:i})})}function Bm({hasAttachmentIds:e,attachments:s,isLoading:r,onOpenImage:o}){if(!e)return null;if(r&&s.length===0)return t.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(s.length===0)return null;const p=s.filter(x=>x.mimeType.startsWith("image/")),m=new Map(p.map((x,i)=>[x.id,i]));return t.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:s.map(x=>{const i=`${bn}${x.url}`;if(x.mimeType.startsWith("image/")){const a=m.get(x.id)??0;return t.jsxs("button",{type:"button",onClick:()=>o(p,a),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:x.originalName,children:[t.jsx("img",{src:i,alt:x.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:x.originalName})]},x.id)}return t.jsxs("a",{href:i,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:x.originalName,children:[t.jsx(Za,{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:x.originalName}),t.jsx("span",{className:"text-neutral-400",children:jm(x.sizeBytes)})]}),t.jsx(An,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},x.id)})})}function Fm({message:e,content:s,attachmentIds:r,isUser:o,tone:p,onOpenImage:m,workingDir:x,onOpenWorkspaceFile:i,onOpenPreviewUrl:n,onOpenVisualization:a,downloadSessionId:h}){const c=b.useMemo(()=>Array.from(new Set(r??[])),[r]),{data:g=[],isLoading:v}=Vd(c),_=g.length>0?_n(s,g):s;return t.jsxs(t.Fragment,{children:[_.trim()&&t.jsx(Hm,{message:e,content:_,attachments:g,isUser:o,tone:p,workingDir:x,onOpenWorkspaceFile:i,onOpenPreviewUrl:n,onOpenVisualization:a,downloadSessionId:h}),t.jsx(Bm,{hasAttachmentIds:c.length>0,attachments:g,isLoading:v,onOpenImage:m})]})}function zm({images:e,index:s,onClose:r,onSelect:o}){const p=e[s];if(!p)return null;const m=s>0,x=s<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:r,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(Gt,{size:20})}),m&&t.jsx("button",{type:"button",onClick:()=>o(s-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(wu,{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:`${bn}${p.url}`,alt:p.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:p.originalName}),t.jsxs("a",{href:`${bn}${p.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(An,{size:13,"aria-hidden":!0}),"Open"]})]})]}),x&&t.jsx("button",{type:"button",onClick:()=>o(s+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(At,{size:24,"aria-hidden":!0})})]})}function Wm({draft:e,attachmentMarkdown:s,attachmentIds:r,mentions:o}){const m=[e.trim(),s].filter(Boolean).join(`
12
-
13
- `);return m?{content:m,mentions:o,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function Hm({message:e,content:s,attachments:r,isUser:o,tone:p=o?"user":"agent",workingDir:m,onOpenWorkspaceFile:x,onOpenPreviewUrl:i,onOpenVisualization:n,downloadSessionId:a}){const{t:h}=de(),c=b.useId(),g=b.useRef(null),[v,_]=b.useState(null),[w,l]=b.useState(!1),[u,d]=b.useState(null),f=Md(e.teamRunId,e.id,!1),S=f.data?.content,C=S?_n(S,r):void 0,j=!!(C&&C!==s)?C:s,y=!!(e.isTruncated&&!Gl(e)),E=v?.messageId===e.id&&v.content===j&&v.expanded,R=b.useCallback(()=>{const I=g.current;I&&l(mm(I.scrollHeight))},[]);b.useLayoutEffect(()=>{R();const I=g.current;if(!I)return;const W=window.requestAnimationFrame(R),$=typeof ResizeObserver>"u"?null:new ResizeObserver(R);return $?.observe(I),window.addEventListener("resize",R),()=>{window.cancelAnimationFrame(W),$?.disconnect(),window.removeEventListener("resize",R)}},[j,R]);const P=b.useCallback(async()=>{if(d(null),E){_({messageId:e.id,content:j,expanded:!1});return}if(y&&!S){const I=await f.refetch();if(I.error){d(yn(I.error,h("Failed to load full message")));return}const W=I.data?.content?_n(I.data.content,r):j;_({messageId:e.id,content:W,expanded:!0});return}_({messageId:e.id,content:j,expanded:!0})},[r,y,S,f,E,e.id,j,h]),M=(w||y)&&!E,L=w||y,z=f.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:c,ref:g,onLoadCapture:R,className:Z("relative transition-[max-height] duration-200 ease-out",M?"overflow-hidden":""),style:M?{maxHeight:Xl}:void 0,children:[t.jsx(Om,{content:j,isUser:o,workingDir:m,onOpenWorkspaceFile:x,onOpenPreviewUrl:i,onOpenVisualization:n,downloadSessionId:a}),M&&t.jsx("div",{className:Z("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",p==="system"?"to-amber-50":p==="user"?"to-neutral-900":"to-neutral-100")})]}),L&&t.jsxs("button",{type:"button","aria-expanded":E,"aria-controls":c,"aria-label":h(E?"Collapse message":"Expand full message"),disabled:z,onClick:()=>{P()},className:Z("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",p==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":p==="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",z?"cursor-wait opacity-70":""),children:[E?t.jsx(xl,{size:13}):t.jsx(kt,{size:13}),t.jsx("span",{children:h(z?"Loading":E?"Collapse message":"Expand full message")})]}),u&&t.jsx("div",{className:Z("mt-1 text-xs",p==="user"?"text-red-200":"text-red-600"),children:u})]})}function Ql({senderName:e,avatar:s,createdAt:r,isUser:o,isSystem:p,children:m,headerAddon:x,bubbleClassName:i,isPending:n}){return p?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:m})}):t.jsxs("div",{className:Z("group flex items-start gap-3",o?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!o&&t.jsx(Xt,{name:e,avatar:s??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),t.jsxs("div",{className:Z("flex min-w-0 max-w-[min(86%,46rem)] flex-col",o?"items-end":"items-start"),children:[t.jsxs("div",{className:Z("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",o?"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(hs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:Rm(r)}),x]}),t.jsx("div",{className:Z("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",o?"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",i,n?"opacity-70":""),children:m})]}),o&&t.jsx(Xt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function Um({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(vi,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function $m({message:e,senderName:s,senderMember:r,senderProvider:o,memberById:p,displayContent:m,onOpenImage:x,workingDir:i,onOpenWorkspaceFile:n,onOpenPreviewUrl:a,onOpenVisualization:h,previewWorkspaceId:c,previewSessionId:g}){const{t:v}=de(),_=e.senderType==="user",w=e.senderType==="system",l=Gl(e)?e.pendingStatus:null,u=e.mentions??[],d=e.workRequestIds?.length??0,f=e.visibility==="PRIVATE",S=b.useCallback(y=>{a?.(y,c)},[a,c]),C=b.useCallback(y=>{g&&h?.(g,y,c)},[h,g,c]),k=f?Pm(e,p):[],j=t.jsxs(t.Fragment,{children:[!_&&!w&&o&&t.jsx(Um,{provider:o}),f&&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:k.join(", "),children:[t.jsx(Td,{size:10}),t.jsxs("span",{className:"truncate",children:[v("Private"),k.length>0?`: ${k.join(", ")}`:""]})]}),!w&&d>0&&u.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:[v("Work requests"),": ",d]}),l==="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:v("发送中...")}),l==="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:v("发送失败")})]});return t.jsx(Ql,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:_,isSystem:w,headerAddon:j,bubbleClassName:_&&l==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:l==="sending",children:t.jsx(Fm,{message:e,content:m,attachmentIds:e.attachmentIds,isUser:_&&l!=="failed",tone:w?"system":void 0,onOpenImage:x,workingDir:i,onOpenWorkspaceFile:n,onOpenPreviewUrl:a?S:void 0,onOpenVisualization:h&&g?C:void 0,downloadSessionId:g})})}function qm({request:e,member:s,onApprove:r,onReject:o,isActionPending:p,isApprovePending:m,isRejectPending:x}){const{t:i}=de();return t.jsx(Ql,{senderName:s?.name??i("Agent"),avatar:s?.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(hs,{size:11}),i("Pending approval")]}),t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[i("Requester"),": ",i(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??Am(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:p,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[t.jsx(Wt,{size:12}),t.jsx("span",{children:i(m?"Approving":"Approve")})]}),t.jsxs(Ae,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(Gt,{size:12}),t.jsx("span",{children:i(x?"Rejecting":"Reject")})]})]})]})})}function Zl({teamRun:e,messages:s,readOnly:r,readOnlyMessage:o,onSendMessage:p,onViewInvocationSession:m,changeSummaryBar:x,compactComposer:i,centered:n,workingDir:a,onOpenWorkspaceFile:h,onOpenPreviewUrl:c,onOpenVisualization:g}){const{t:v}=de(),_=Ua(e.id),w=$a(e.id),l=qa(e.id),[u,d]=b.useState(""),[f,S]=b.useState(!1),[C,k]=b.useState(null),[j,y]=b.useState(0),[E,R]=b.useState([]),[P,M]=b.useState(!1),[L,z]=b.useState(null),[I,W]=b.useState([]),[$,A]=b.useState(null),D=b.useRef(null),T=b.useRef(null),{files:O,addFiles:K,removeFile:V,clear:B,restoreFiles:U,buildMarkdownLinks:H,getDoneAttachments:N,isUploading:F}=Mn(),q=O.some(X=>X.status==="done"&&X.attachment),[Y,se]=b.useState(null),{scrollRef:G,contentRef:pe,isAtBottom:he,scrollToBottom:re}=On({resize:"smooth",initial:"instant"}),ne=b.useRef(!1),le=b.useRef(null);b.useEffect(()=>{const X=G.current;if(!X)return;const te=ie=>{if(ie.deltaY<0){ne.current=!0;return}ie.deltaY>0&&X.scrollHeight-X.scrollTop-X.clientHeight<=70&&(ne.current=!1)};return X.addEventListener("wheel",te,{passive:!0}),()=>X.removeEventListener("wheel",te)},[G]);const{data:Se}=Gs(),We=b.useMemo(()=>{const X=new Map;for(const te of Se??[])X.set(te.provider.id,te.provider);return X},[Se]),Ee=b.useMemo(()=>new Map((e.members??[]).map(X=>[X.id,X])),[e.members]),He=b.useMemo(()=>(e.members??[]).filter(Vo),[e.members]),at=b.useMemo(()=>new Map((e.invocations??[]).map(X=>[X.id,X])),[e.invocations]),Me=b.useMemo(()=>{const X=new Set(s.map(ie=>ie.id)),te=I.filter(ie=>!X.has(ie.id));return[...s,...te].sort((ie,ae)=>{const Ce=Date.parse(ie.createdAt??""),ke=Date.parse(ae.createdAt??"");return(Number.isNaN(Ce)?0:Ce)-(Number.isNaN(ke)?0:ke)})},[s,I]),Ne=b.useMemo(()=>new Map((e.workRequests??[]).map(X=>[X.id,X])),[e.workRequests]),Oe=b.useMemo(()=>xm(Me,e.workRequests??[],e.invocations??[]),[Me,e.invocations,e.workRequests]);b.useEffect(()=>{const X=Oe.at(-1)?.key??null,te=le.current;le.current=X,!(te==null||X==null||X===te||ne.current)&&requestAnimationFrame(()=>{re({animation:"smooth",ignoreEscapes:!0})})},[re,Oe]);const $e=b.useMemo(()=>(e.invocations??[]).filter(X=>ki.has(X.status)),[e.invocations]),qe=b.useMemo(()=>E.map(X=>Ee.get(X)).filter(X=>!!X).filter(Vo),[Ee,E]),De=b.useMemo(()=>{const X=C?.query??"";return He.filter(te=>Mm(te,X)).sort((te,ie)=>{const ae=E.includes(te.id),Ce=E.includes(ie.id);return ae!==Ce?ae?1:-1:te.name.localeCompare(ie.name)})},[He,C?.query,E]),Ge=!r&&(f||!!C)&&De.length>0,Qe=b.useCallback((X,te)=>{if(te==null){k(null);return}k(Tm(X,te)),y(0)},[]),Te=b.useCallback(X=>{R(ke=>pm(ke,X.id));const te=`@${X.name} `;if(C){const ke=`${u.slice(0,C.start)}${te}${u.slice(C.end)}`,Pe=C.start+te.length;d(ke),k(null),S(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(Pe,Pe)});return}const ie=u.length===0||/\s$/.test(u)?"":" ",ae=`${u}${ie}${te}`,Ce=ae.length;d(ae),S(!1),requestAnimationFrame(()=>{D.current?.focus(),D.current?.setSelectionRange(Ce,Ce)})},[u,C]),ge=b.useCallback(X=>{R(te=>gm(te,X))},[]),et=b.useCallback(X=>{const te=X.target.value;d(te),z(null);const ie=X.target;ie.style.height="auto",ie.style.height=`${Math.max(i?40:72,Math.min(ie.scrollHeight,i?140:240))}px`,S(!1),Qe(te,ie.selectionStart)},[i,Qe]),Xe=b.useCallback(X=>{const te=X.target.files;te&&te.length>0&&(K(Array.from(te)),z(null)),X.target.value=""},[K]),Ue=b.useCallback(X=>{const te=[];for(const ie of X.clipboardData.items)if(ie.kind==="file"){const ae=ie.getAsFile();ae&&te.push(ae)}te.length>0&&(X.preventDefault(),K(te),z(null))},[K]),ft=b.useCallback(async()=>{if(r||P||F)return;const X=H(),te=N().map(be=>be.id),ie=vm(E,He),ae=Wm({draft:u,attachmentMarkdown:X,attachmentIds:te,mentions:ie});if(!ae||!u.trim()&&!q)return;const Ce=Em(e.id,ae),ke=u,Pe=E,Je=O;W(be=>[...be,Ce]),d(""),R([]),S(!1),k(null),B(),D.current&&(D.current.style.height=i?"40px":"72px"),requestAnimationFrame(()=>re()),M(!0),z(null);try{const be=await p(ae);W(xe=>xe.filter(me=>me.id!==Ce.id)),be&&typeof be=="object"&&"id"in be&&requestAnimationFrame(()=>re())}catch(be){const xe=be instanceof Error?be.message:"Failed to send room message";W(me=>me.map(Fe=>Fe.id===Ce.id?{...Fe,pendingStatus:"failed",error:xe}:Fe)),d(me=>me.length===0?ke:me),R(me=>me.length===0?Pe:me),U(Je),z(xe),requestAnimationFrame(()=>re())}finally{M(!1)}},[He,O,H,B,i,u,N,q,P,F,p,r,U,re,E,e.id]),tt=b.useCallback(X=>{const te=X.nativeEvent.isComposing||X.nativeEvent.keyCode===229;if(Ge){if(X.key==="ArrowDown"){X.preventDefault(),y(ie=>(ie+1)%De.length);return}if(X.key==="ArrowUp"){X.preventDefault(),y(ie=>(ie-1+De.length)%De.length);return}if(X.key==="Enter"&&!te||X.key==="Tab"){X.preventDefault();const ie=De[j]??De[0];ie&&Te(ie);return}if(X.key==="Escape"){X.preventDefault(),k(null),S(!1);return}}X.key==="Enter"&&!X.shiftKey&&!X.repeat&&!te&&(X.preventDefault(),ft())},[Te,ft,j,De,Ge]);b.useEffect(()=>{d(""),R([]),S(!1),k(null),z(null),W([]),B(),ne.current=!1,le.current=null,A(null),D.current&&(D.current.style.height=i?"40px":"72px")},[B,i,e.id]);const ee=_.isError?_.error:w.isError?w.error:null,fe=_.isPending||w.isPending,we=b.useCallback((X,te)=>{l.mutate({memberId:X,cancelQueued:te},{onSuccess:()=>A(null)})},[l]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[Y&&t.jsx(zm,{images:Y.images,index:Y.index,onClose:()=>se(null),onSelect:X=>se(te=>te&&{...te,index:X})}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:G,className:Z("h-full overflow-y-auto scrollbar-app-thin bg-white",i?"px-3 py-3":"px-4 py-4"),children:t.jsxs("div",{ref:pe,className:Z(i?"space-y-2.5":"space-y-3",n&&"max-w-4xl mx-auto"),children:[Oe.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(js,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:v("No room messages yet")})]}):Oe.map(X=>{if(X.kind==="pendingApproval"){const xe=X.request,me=Ee.get(xe.targetMemberId),Fe=_.isPending&&_.variables===xe.id,st=w.isPending&&w.variables===xe.id;return t.jsx(qm,{request:xe,member:me,onApprove:()=>_.mutate(xe.id),onReject:()=>w.mutate(xe.id),isActionPending:fe,isApprovePending:Fe,isRejectPending:st},X.key)}const te=X.message,ie=Im(te,Ee,at),ae=te.senderType==="user"?v("你"):te.senderType==="system"?v("System"):ie?.name??v("Agent"),Ce=Lm(te,Ee),ke=ie?.providerId?We.get(ie.providerId)??null:null,Pe=te.senderInvocationId?at.get(te.senderInvocationId):void 0,Je=Pe?.workspaceId??void 0,be=Pe?.sessionId??void 0;return t.jsx($m,{message:te,senderName:ae,senderMember:ie,senderProvider:ke,memberById:Ee,displayContent:Ce,onOpenImage:(xe,me)=>se({images:xe,index:me}),workingDir:a,onOpenWorkspaceFile:h,onOpenPreviewUrl:c,onOpenVisualization:g,previewWorkspaceId:Je,previewSessionId:be},X.key)}),ee&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:yn(ee,v("Failed to update work request"))}),l.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:yn(l.error,v("Failed to stop member work"))})]})}),!he&&t.jsxs("button",{type:"button",onClick:()=>re(),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(xr,{size:14}),t.jsx("span",{children:v("Back to bottom")})]})]}),t.jsx("div",{className:Z("shrink-0 border-t border-transparent bg-white",i?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:t.jsxs("div",{className:Z(n&&"max-w-4xl mx-auto"),children:[t.jsx(Cm,{invocations:$e,memberById:Ee,workRequestById:Ne,onViewInvocationSession:m,onStopMember:we,isStopPending:l.isPending,stoppingMemberId:l.variables?.memberId??null,stopPromptInvocationId:$,onToggleStopConfirm:X=>A(te=>te===X?null:X)}),!r&&x,r?t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:o??v("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:[Ge&&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:v(C?"Mention members":"Team members")}),t.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:De.map((X,te)=>{const ie=E.includes(X.id),ae=te===j;return t.jsxs("button",{type:"button",onMouseEnter:()=>y(te),onMouseDown:Ce=>{Ce.preventDefault(),Te(X)},className:Z("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",ae?"bg-neutral-100":"hover:bg-neutral-50"),children:[t.jsx(Xt,{name:X.name,avatar:X.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:X.name}),ie&&t.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:v("selected")})]}),t.jsx("div",{className:"truncate text-xs text-neutral-500",children:[X.providerId,X.id.slice(0,8)].filter(Boolean).join(" · ")})]}),t.jsx(So,{size:15,className:"text-neutral-400"})]},X.id)})})]}),qe.length>0&&t.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:qe.map(X=>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:["@",X.name]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:X.id.slice(0,8)}),t.jsx("button",{type:"button",onClick:()=>ge(X.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:v("Remove mention"),"aria-label":`${v("Remove mention")} ${X.name}`,children:t.jsx(Gt,{size:12})})]},X.id))}),t.jsx(Dn,{files:O,onRemove:V}),t.jsx("textarea",{ref:D,value:u,rows:i?1:void 0,onChange:et,onKeyDown:tt,onPaste:Ue,onClick:X=>Qe(u,X.currentTarget.selectionStart),onSelect:X=>Qe(u,X.currentTarget.selectionStart),placeholder:v("Message the team room..."),className:Z("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",i?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:i?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),t.jsxs("div",{className:Z("flex items-center justify-between",i?"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:Xe}),t.jsx("button",{type:"button",onClick:()=>T.current?.click(),title:v("Upload file"),"aria-label":v("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:t.jsx(Hn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{S(X=>!X),k(null),requestAnimationFrame(()=>D.current?.focus())},disabled:qe.length===0&&He.length===0,title:v("Mention members"),"aria-label":v("Mention members"),className:Z("rounded-lg transition-colors",i?"p-1.5":"p-2",f?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",qe.length===0&&He.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(So,{size:i?15:18})}),qe.length>0&&t.jsxs("span",{className:"text-[11px] text-neutral-500",children:[qe.length," ",v("selected")]})]}),t.jsx("button",{type:"button",onClick:()=>{ft()},disabled:r||P||F||!u.trim()&&!q,title:v(F?"Uploading...":P?"发送中...":"发送"),"aria-label":v(F?"Uploading...":P?"发送中...":"发送"),className:Z("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(u.trim()||q)&&!r&&!P&&!F?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",P||F?"opacity-70":""),children:t.jsx(Bn,{size:i?15:18})})]}),L&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:L})]})]})})]})}function Km(e){return e?e.slice(0,8):""}function Yo(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function io(e){return e?.workspaceKind===bt.MAIN_DIRECTORY}function Xs(e){return e?io(e)?"Project directory":e.branchName:"—"}function fs(e){return e?.workingDir||e?.worktreePath||void 0}function no(e,s){if(!e?.length)return[];const r=new Map((s?.members??[]).map(m=>[m.id,m])),o=new Map(e.map(m=>[m.id,m])),p=s?.mainWorkspaceId??null;return e.map(m=>{const x=m.parentWorkspaceId?o.get(m.parentWorkspaceId):void 0,i=m.ownerMemberId?r.get(m.ownerMemberId):void 0,n=!!(p&&m.id===p),a=n?"main":m.parentWorkspaceId?"child":"root",h=i?.name??(m.ownerMemberId?`Member ${Km(m.ownerMemberId)}`:void 0),c=io(m)?"Project directory":n?"Main workspace":a==="child"?h?`${h} workspace`:"Child workspace":s?"Root workspace":"Workspace";return{workspace:m,kind:a,roleLabel:n?"Main":a==="child"?"Child":"Root",displayName:c,ownerName:h,parentBranchName:x?Xs(x):void 0,isMain:n}}).sort((m,x)=>{const i=a=>a.kind==="main"?0:a.kind==="child"?1:2,n=i(m)-i(x);return n!==0?n:Yo(m.workspace.createdAt)-Yo(x.workspace.createdAt)})}function Jl(e,s,r){if(e?.length)return r&&e.some(o=>o.id===r)?r:s?.mainWorkspaceId&&e.some(o=>o.id===s.mainWorkspaceId)?s.mainWorkspaceId:e.find(o=>o.status===Pt.ACTIVE)?.id??e[0]?.id}function ec(e,s){return!e||e.status!==Pt.ACTIVE||io(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function tc(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const oo={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},Vm=[{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:"合并工作区"}],sc=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Ym=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],rc=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],Xm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function ar(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...oo},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function Bs(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...oo,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Ki(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...oo,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Gm(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function Qm(e){return{name:e.name.trim(),aliases:Gm(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 Xo(e,s){return e instanceof Error?e.message:s}function Go(e){return e.membershipStatus!=="REMOVED"}function Sn(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Qo(e){return Sn(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function Zo(e){return sc.find(s=>s.value===e)?.label??e}function Zm(e){return rc.find(s=>s.value===e)?.label??e}function Vt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function Jo({icon:e,title:s,description:r,action:o}){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:s}),r?t.jsx("div",{className:"mt-1 max-w-sm text-xs leading-relaxed text-neutral-500",children:r}):null,o?t.jsx("div",{className:"mt-4",children:o}):null]})}function Jm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=de(),{data:p=[]}=Dd(),{data:m=[]}=Gs(),x=Pd(r.id),i=Ld(r.id),n=Id(r.id),a=b.useRef(!1),[h,c]=b.useState("edit"),[g,v]=b.useState(null),[_,w]=b.useState(""),[l,u]=b.useState(ar()),[d,f]=b.useState(null),[S,C]=b.useState(null),k=r.members??[],j=b.useMemo(()=>k.filter(Go),[k]),y=b.useMemo(()=>S&&Go(S)&&!j.some(H=>H.id===S.id)?[...j,S]:j,[S,j]),E=g?j.find(H=>H.id===g)??null:null,R=S?.id===g?S:E,P=_?p.find(H=>H.id===_)??null:null,M=x.isPending||i.isPending||n.isPending,L=y.filter(Sn).length,z=b.useMemo(()=>{const H=m.map(({provider:N,availability:F})=>({value:N.id,label:N.name+(F.type==="NOT_FOUND"?o(" (不可用)"):""),icon:t.jsx(vi,{agentType:N.agentType,className:"size-4"}),disabled:F.type==="NOT_FOUND"}));return l.providerId&&!H.some(N=>N.value===l.providerId)&&H.unshift({value:l.providerId,label:`${l.providerId}${o(" (不可用)")}`,disabled:!0}),H},[l.providerId,m,o]);b.useEffect(()=>{if(!e){a.current=!1,C(null);return}if(a.current)return;a.current=!0;const H=y[0]??null;c(H?"edit":"add-preset"),v(H?.id??null),w(""),u(H?Bs(H):ar()),f(null)},[y,e]),b.useEffect(()=>{S&&j.some(H=>H.id===S.id)&&C(null)},[S,j]),b.useEffect(()=>{h==="add-preset"&&P&&u(Ki(P))},[h,P]);const I=(H,N)=>{u(F=>({...F,[H]:N}))},W=(H,N)=>{u(F=>({...F,capabilities:{...F.capabilities,[H]:N}}))},$=H=>{c("edit"),v(H.id),w(""),u(Bs(H))},A=()=>{c("add-preset"),v(null);const H=P??p[0]??null;w(H?.id??""),u(H?Ki(H):ar())},D=()=>{c("add-custom"),v(null),w(""),u(ar())},T=!!(l.name.trim()&&l.providerId.trim()&&l.rolePrompt.trim()),O=h==="add-preset"?!!_:h==="edit"?!!(R&&T):T,K=async()=>{try{if(h==="add-preset"){if(!_)return;const N=await x.mutateAsync({memberPresetId:_});ot.success(o("Member added")),C(N),c("edit"),v(N.id),w(""),u(Bs(N));return}const H=Qm(l);if(!H.name||!H.providerId||!H.rolePrompt){ot.error(o("Name, provider, and role prompt are required"));return}if(h==="add-custom"){const N=await x.mutateAsync({member:H});ot.success(o("Member added")),C(N),c("edit"),v(N.id),u(Bs(N));return}if(R){const N=await i.mutateAsync({memberId:R.id,data:H});ot.success(o("Member updated")),C(F=>F?.id===N.id?N:F),v(N.id),u(Bs(N))}}catch(H){ot.error(Xo(H,o("Failed to save member")))}},V=async()=>{if(d)try{if(await n.mutateAsync({memberId:d.id,stopActive:!0,cancelQueued:!0}),g===d.id){const H=y.find(N=>N.id!==d.id)??null;v(H?.id??null),c(H?"edit":"add-preset"),u(H?Bs(H):ar())}C(H=>H?.id===d.id?null:H),f(null),ot.success(o("Member removed"))}catch(H){ot.error(Xo(H,o("Failed to remove member")))}},B=()=>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(Hr,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Add member from preset")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o("Choose a saved preset to add a ready-to-run member snapshot.")})]}),t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:D,disabled:M,children:[t.jsx(No,{size:13}),o("Custom member")]})]})}),t.jsx("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:p.length===0?t.jsx(Jo,{icon:t.jsx(Hr,{size:18}),title:o("No member presets"),description:o("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:M,children:[t.jsx(us,{size:13}),o("Custom member")]})}):t.jsx("div",{className:"grid grid-cols-1 gap-2 xl:grid-cols-2",children:p.map(H=>{const N=_===H.id;return t.jsxs("button",{type:"button",onClick:()=>{w(H.id),u(Ki(H))},className:Z("flex min-h-[4.25rem] items-center gap-3 rounded-lg border px-3 py-2.5 text-left transition-colors",N?"border-neutral-900 bg-neutral-50 shadow-sm":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[t.jsx(Xt,{name:H.name,avatar:H.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:H.name}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:H.providerId}),t.jsxs("span",{className:"mt-1 block truncate text-[10px] text-neutral-400",children:[o(Zo(H.workspacePolicy))," · ",o(Zm(H.sessionPolicy))]})]}),N?t.jsx(Wt,{size:16,className:"shrink-0 text-neutral-900"}):null]},H.id)})})})]}),U=()=>{const H=h==="edit";return H&&!R?t.jsx("div",{className:"p-5",children:t.jsx(Jo,{icon:t.jsx(js,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:M,children:[t.jsx(us,{size:13}),o("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:[H?t.jsx(Sl,{size:15,className:"text-neutral-500"}):t.jsx(us,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o(H?"Edit member":"Custom member")})]}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:o(H?"Provider, role, workspace, and session changes apply to future work only.":"Create a one-off member snapshot for this TeamRun.")})]}),H&&R?t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:()=>f(R),disabled:M,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(pi,{size:13}),o("Remove")]}):t.jsxs(Ae,{type:"button",variant:"outline",size:"sm",onClick:A,disabled:M,children:[t.jsx(Hr,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[H&&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(Xt,{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:Z("h-2 w-2 shrink-0 rounded-full",Qo(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," · ",o(Zo(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(Vt,{children:o("Name")}),t.jsx("input",{value:l.name,onChange:N=>I("name",N.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(Vt,{children:o("Aliases")}),t.jsx("input",{value:l.aliasesText,onChange:N=>I("aliasesText",N.target.value),placeholder:o("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(Vt,{children:o("Provider")}),t.jsx(ds,{value:l.providerId,onChange:N=>I("providerId",N),options:z})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Vt,{children:o("Avatar")}),t.jsx("input",{value:l.avatar,onChange:N=>I("avatar",N.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(Vt,{children:o("Workspace policy")}),t.jsx(ds,{value:l.workspacePolicy,onChange:N=>I("workspacePolicy",N),options:sc.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Vt,{children:o("Trigger policy")}),t.jsx(ds,{value:l.triggerPolicy,onChange:N=>I("triggerPolicy",N),options:Ym.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Vt,{children:o("Session policy")}),t.jsx(ds,{value:l.sessionPolicy,onChange:N=>I("sessionPolicy",N),options:rc.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Vt,{children:o("Queue policy")}),t.jsx(ds,{value:l.queueManagementPolicy,onChange:N=>I("queueManagementPolicy",N),options:Xm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(Vt,{children:o("Role prompt")}),t.jsx("textarea",{value:l.rolePrompt,onChange:N=>I("rolePrompt",N.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(Vt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:Vm.map(N=>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:!!l.capabilities[N.key],onChange:F=>W(N.key,F.target.checked)}),t.jsx("span",{className:"min-w-0 truncate",children:o(N.label)})]},N.key))})]})]})]})]})};return t.jsxs(t.Fragment,{children:[t.jsx(gs,{isOpen:e,onClose:M?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Ae,{type:"button",variant:"outline",onClick:s,disabled:M,children:o("Close")}),t.jsx(Ae,{type:"button",onClick:K,disabled:M||!O,children:o(M?"Processing...":h==="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(js,{size:15,className:"text-neutral-500"}),t.jsx("span",{children:o("Members")})]}),t.jsxs("div",{className:"mt-1 text-xs text-neutral-500",children:[y.length," ",o("active")," · ",L," ",o("working")]})]}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"outline",onClick:A,disabled:M,title:o("Add member"),children:t.jsx(us,{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:y.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:o("No active members")}):t.jsx("div",{className:"space-y-1",children:y.map(H=>{const N=h==="edit"&&g===H.id;return t.jsxs("button",{type:"button",onClick:()=>$(H),className:Z("group flex w-full items-center gap-2 rounded-lg border px-2.5 py-2 text-left transition-colors",N?"border-neutral-300 bg-white shadow-sm":"border-transparent hover:border-neutral-200 hover:bg-white"),children:[t.jsx(Xt,{name:H.name,avatar:H.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:Z("h-1.5 w-1.5 shrink-0 rounded-full",Qo(H))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:H.name})]}),t.jsx("span",{className:"mt-0.5 block truncate text-xs text-neutral-500",children:H.providerId})]}),t.jsx(Gu,{size:13,className:Z("shrink-0 text-neutral-300 transition-opacity",N?"opacity-100":"opacity-0 group-hover:opacity-100")})]},H.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:A,disabled:M,className:Z("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",h==="add-preset"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(Hr,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:D,disabled:M,className:Z("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",h==="add-custom"?"bg-neutral-900 text-white":"bg-white text-neutral-600 hover:bg-neutral-100"),children:[t.jsx(No,{size:12}),o("Custom")]})]})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-col",children:h==="add-preset"?B():U()})]})}),t.jsx(Ln,{isOpen:!!d,onClose:()=>f(null),onConfirm:V,title:o("Remove member"),variant:"danger",isLoading:n.isPending,confirmText:o("Remove"),description:t.jsxs("div",{className:"space-y-2",children:[t.jsx("p",{children:d?o("Remove this member from future TeamRun work?"):""}),d&&Sn(d)?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(As,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const ep=[],tp=[],sp=[],rp=240;function ip(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 ea={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Vi(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function ta(e,s){return e instanceof Error?e.message:s}function np(e,s=rp){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Ur(e){return e?e.instructionPreview??np(e.instruction):""}function op(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 ap(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 lp(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 cp(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function dp(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 up(e){switch(e){case Pt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Pt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Pt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Pt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function hp(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 fp(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function mp(e,s){return s.find(r=>r.memberId===e.id&&ki.has(r.status))}function ic({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=de(),x=Ua(e.id),i=$a(e.id),n=qa(e.id),[a,h]=b.useState(null),[c,g]=b.useState(null),[v,_]=b.useState(!1),[w,l]=b.useState(!1),u=e.members??ep,d=b.useMemo(()=>u.filter(I=>I.membershipStatus!=="REMOVED"),[u]),f=e.workRequests??tp,S=e.invocations??sp,C=b.useMemo(()=>no(s,e),[e,s]),k=b.useMemo(()=>new Map(f.map(I=>[I.id,I])),[f]),j=b.useMemo(()=>[...f].filter(I=>I.status==="PENDING_APPROVAL").sort((I,W)=>Date.parse(W.updatedAt??W.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),y=b.useMemo(()=>[...f].filter(I=>I.status==="QUEUED").sort((I,W)=>Date.parse(W.updatedAt??W.createdAt??"")-Date.parse(I.updatedAt??I.createdAt??"")),[f]),E=b.useMemo(()=>[...u].map(I=>({member:I,status:ip(I.status)})).sort((I,W)=>ea[I.status]-ea[W.status]),[u]),R=x.isError?x.error:i.isError?i.error:null,P=x.isPending||i.isPending,M=C.find(I=>I.workspace.id===r),L=e.messages??[],z=E.filter(({status:I})=>I==="running"||I==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(Jm,{isOpen:w,onClose:()=>l(!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(Vs,{size:14,className:"text-neutral-500 shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:m("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:m("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:m("Messages"),children:[t.jsx(gi,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:L.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(js,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:z>0?`${z}/${d.length}`:d.length}),z>0&&t.jsx("span",{className:"h-1.5 w-1.5 rounded-full bg-emerald-500"})]}),y.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Queue"),children:[t.jsx(hs,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:y.length})]}),j.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(hs,{size:11}),t.jsx("span",{className:"tabular-nums",children:j.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[j.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(hs,{size:13}),t.jsx("span",{children:m("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:j.length})]}),t.jsx("div",{className:"space-y-1.5",children:j.map(I=>{const W=u.find(D=>D.id===I.targetMemberId),$=x.isPending&&x.variables===I.id,A=i.isPending&&i.variables===I.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(Xt,{name:W?.name??"Agent",avatar:W?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:W?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:Ur(I)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(cp(I.requesterType))}),t.jsx("span",{children:Vi(I.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>x.mutate(I.id),disabled:P,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(Wt,{size:11}),t.jsx("span",{className:"truncate",children:m($?"Approving":"Approve")})]}),t.jsxs("button",{type:"button",onClick:()=>i.mutate(I.id),disabled:P,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(Gt,{size:11}),t.jsx("span",{className:"truncate",children:m(A?"Rejecting":"Reject")})]})]})]},I.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:ta(R,m("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(js,{size:13}),t.jsx("span",{children:m("Members")}),t.jsx("span",{className:"ml-auto text-[10px] font-normal text-neutral-400",children:d.length}),t.jsx("button",{type:"button",onClick:()=>l(!0),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("Manage Team Members"),"aria-label":m("Manage Team Members"),children:t.jsx(Sl,{size:13})})]}),u.length===0?t.jsx("div",{className:"py-3 text-center text-xs text-neutral-400",children:m("No members")}):t.jsx("div",{className:"space-y-px rounded-md border border-neutral-200 overflow-hidden",children:E.map(({member:I,status:W})=>{const $=mp(I,S),A=fp(S.filter(U=>U.memberId===I.id)),D=$?k.get($.workRequestId):void 0,T=c===I.id,O=W==="running"||W==="waiting room reply",K=O&&!!$,V=a===I.id,B=n.isPending&&n.variables?.memberId===I.id;return t.jsxs("div",{className:Z("bg-white",T&&"bg-neutral-50/50"),children:[t.jsxs("div",{className:"flex items-center gap-2 px-3 py-2",children:[t.jsx(Xt,{name:I.name,avatar:I.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:Z("h-1.5 w-1.5 shrink-0 rounded-full",lp(W))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:I.name}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",ap(W)),children:m(op(W))})]}),O&&D?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Ur(D)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[K&&t.jsx("button",{type:"button",onClick:()=>h(V?null:I.id),disabled:n.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:m("Stop"),"aria-label":m("Stop"),children:t.jsx(qs,{size:12})}),$?.sessionId&&p&&t.jsx("button",{type:"button",onClick:()=>p($.sessionId),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-700",title:m("View log"),"aria-label":m("View log"),children:t.jsx(fn,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(T?null:I.id),className:"rounded-md p-1 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",title:m("Details"),"aria-label":m("Details"),"aria-expanded":T,children:T?t.jsx(kt,{size:13}):t.jsx(At,{size:13})})]})]}),K&&V&&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:m("Stop running work?")}),t.jsxs("div",{className:"flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:I.id,cancelQueued:!1},{onSuccess:()=>h(null)})},disabled:n.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(qs,{size:10}),t.jsx("span",{children:B&&n.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),t.jsxs("button",{type:"button",onClick:()=>{n.mutate({memberId:I.id,cancelQueued:!0},{onSuccess:()=>h(null)})},disabled:n.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(_l,{size:10}),t.jsx("span",{children:B&&n.variables?.cancelQueued===!0?m("Stopping"):m("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:I.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:I.sessionPolicy==="resume_last"?m("Resume last session"):m("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:m("Invocation history")}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:A.length})]}),A.length===0?t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("No invocations yet")}):t.jsx("div",{className:"space-y-1",children:A.map(U=>{const H=k.get(U.workRequestId),N=!!(U.sessionId&&p);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:Z("rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",dp(U.status)),children:U.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Vi(U.updatedAt??U.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Ur(H)||U.workRequestId})]}),N&&t.jsxs("button",{type:"button",onClick:()=>U.sessionId&&p?.(U.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:m("View log"),"aria-label":m("View log"),children:[t.jsx(fn,{size:10}),t.jsx("span",{children:m("Log")})]})]})},U.id)})})]}),E[E.length-1]?.member.id!==I.id&&!T&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},I.id)})}),n.isError&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:ta(n.error,m("Failed to stop member work"))})]}),y.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(hs,{size:13}),t.jsx("span",{children:m("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:y.length})]}),t.jsx("div",{className:"space-y-1",children:y.map(I=>{const W=u.find($=>$.id===I.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(Xt,{name:W?.name??"Agent",avatar:W?.avatar??null,className:"h-4 w-4 text-[8px]"}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:W?.name??I.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Ur(I)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Vi(I.createdAt)})]})},I.id)})})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>_(I=>!I),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":v,"aria-label":m("Workspaces"),children:[t.jsx(Vs,{size:13}),t.jsx("span",{children:m("Workspaces")}),t.jsxs("span",{className:"ml-auto flex items-center gap-1.5",children:[M&&t.jsx("span",{className:"max-w-[120px] truncate font-mono text-[10px] font-normal text-neutral-400",children:Xs(M.workspace)}),t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-semibold text-neutral-600",children:C.length}),v?t.jsx(kt,{size:13,className:"text-neutral-400"}):t.jsx(At,{size:13,className:"text-neutral-400"})]})]}),v&&t.jsx("div",{className:"space-y-1.5",children:C.map(I=>{const W=r===I.workspace.id;return t.jsx("div",{className:Z("rounded-md border bg-white px-3 py-2",W?"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:m(I.displayName)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",hp(I.roleLabel)),children:m(I.roleLabel)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",up(I.workspace.status)),children:I.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:Xs(I.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:[I.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",I.ownerName]}),I.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",I.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(I.workspace.id),disabled:!o||W,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:m("View workspace"),children:[W?t.jsx(Wt,{size:11}):t.jsx(al,{size:11}),t.jsx("span",{children:m(W?"Selected":"Select")})]})]})},I.workspace.id)})})]}),j.length===0&&y.length===0&&E.every(({status:I})=>I==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var Yi={exports:{}},sa;function pp(){return sa||(sa=1,(function(e,s){(function(r,o){e.exports=o()})(self,(()=>(()=>{var r={4567:function(x,i,n){var a=this&&this.__decorate||function(f,S,C,k){var j,y=arguments.length,E=y<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(f,S,C,k);else for(var R=f.length-1;R>=0;R--)(j=f[R])&&(E=(y<3?j(E):y>3?j(S,C,E):j(S,C))||E);return y>3&&E&&Object.defineProperty(S,C,E),E},h=this&&this.__param||function(f,S){return function(C,k){S(C,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const c=n(9042),g=n(6114),v=n(9924),_=n(844),w=n(5596),l=n(4725),u=n(3656);let d=i.AccessibilityManager=class extends _.Disposable{constructor(f,S){super(),this._terminal=f,this._renderService=S,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 C=0;C<this._terminal.rows;C++)this._rowElements[C]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[C]);if(this._topBoundaryFocusListener=C=>this._handleBoundaryFocus(C,0),this._bottomBoundaryFocusListener=C=>this._handleBoundaryFocus(C,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 v.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((C=>this._handleResize(C.rows)))),this.register(this._terminal.onRender((C=>this._refreshRows(C.start,C.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((C=>this._handleChar(C)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
14
- `)))),this.register(this._terminal.onA11yTab((C=>this._handleTab(C)))),this.register(this._terminal.onKey((C=>this._handleKey(C.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new w.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,u.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,_.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(f){for(let S=0;S<f;S++)this._handleChar(" ")}_handleChar(f){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==f&&(this._charsToAnnounce+=f):this._charsToAnnounce+=f,f===`
15
- `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=c.tooMuchOutput)),g.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,g.isMac&&this._liveRegion.remove()}_handleKey(f){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(f)||this._charsToConsume.push(f)}_refreshRows(f,S){this._liveRegionDebouncer.refresh(f,S,this._terminal.rows)}_renderRows(f,S){const C=this._terminal.buffer,k=C.lines.length.toString();for(let j=f;j<=S;j++){const y=C.translateBufferLineToString(C.ydisp+j,!0),E=(C.ydisp+j+1).toString(),R=this._rowElements[j];R&&(y.length===0?R.innerText=" ":R.textContent=y,R.setAttribute("aria-posinset",E),R.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(f,S){const C=f.target,k=this._rowElements[S===0?1:this._rowElements.length-2];if(C.getAttribute("aria-posinset")===(S===0?"1":`${this._terminal.buffer.lines.length}`)||f.relatedTarget!==k)return;let j,y;if(S===0?(j=C,y=this._rowElements.pop(),this._rowContainer.removeChild(y)):(j=this._rowElements.shift(),y=C,this._rowContainer.removeChild(j)),j.removeEventListener("focus",this._topBoundaryFocusListener),y.removeEventListener("focus",this._bottomBoundaryFocusListener),S===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(S===0?-1:1),this._rowElements[S===0?1:this._rowElements.length-2].focus(),f.preventDefault(),f.stopImmediatePropagation()}_handleResize(f){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let S=this._rowContainer.children.length;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);for(;this._rowElements.length>f;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const f=document.createElement("div");return f.setAttribute("role","listitem"),f.tabIndex=-1,this._refreshRowDimensions(f),f}_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 f=0;f<this._terminal.rows;f++)this._refreshRowDimensions(this._rowElements[f])}}_refreshRowDimensions(f){f.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=d=a([h(1,l.IRenderService)],d)},3614:(x,i)=>{function n(g){return g.replace(/\r?\n/g,"\r")}function a(g,v){return v?"\x1B[200~"+g+"\x1B[201~":g}function h(g,v,_,w){g=a(g=n(g),_.decPrivateModes.bracketedPasteMode&&w.rawOptions.ignoreBracketedPasteMode!==!0),_.triggerDataEvent(g,!0),v.value=""}function c(g,v,_){const w=_.getBoundingClientRect(),l=g.clientX-w.left-10,u=g.clientY-w.top-10;v.style.width="20px",v.style.height="20px",v.style.left=`${l}px`,v.style.top=`${u}px`,v.style.zIndex="1000",v.focus()}Object.defineProperty(i,"__esModule",{value:!0}),i.rightClickHandler=i.moveTextAreaUnderMouseCursor=i.paste=i.handlePasteEvent=i.copyHandler=i.bracketTextForPaste=i.prepareTextForTerminal=void 0,i.prepareTextForTerminal=n,i.bracketTextForPaste=a,i.copyHandler=function(g,v){g.clipboardData&&g.clipboardData.setData("text/plain",v.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,v,_,w){g.stopPropagation(),g.clipboardData&&h(g.clipboardData.getData("text/plain"),v,_,w)},i.paste=h,i.moveTextAreaUnderMouseCursor=c,i.rightClickHandler=function(g,v,_,w,l){c(g,v,_),l&&w.rightClickSelect(g),v.value=w.selectionText,v.select()}},7239:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const a=n(1505);i.ColorContrastCache=class{constructor(){this._color=new a.TwoKeyMap,this._css=new a.TwoKeyMap}setCss(h,c,g){this._css.set(h,c,g)}getCss(h,c){return this._css.get(h,c)}setColor(h,c,g){this._color.set(h,c,g)}getColor(h,c){return this._color.get(h,c)}clear(){this._color.clear(),this._css.clear()}}},3656:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(n,a,h,c){n.addEventListener(a,h,c);let g=!1;return{dispose:()=>{g||(g=!0,n.removeEventListener(a,h,c))}}}},6465:function(x,i,n){var a=this&&this.__decorate||function(l,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,u,d,f);else for(var j=l.length-1;j>=0;j--)(S=l[j])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(l,u){return function(d,f){u(d,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const c=n(3656),g=n(8460),v=n(844),_=n(2585);let w=i.Linkifier2=class extends v.Disposable{get currentLink(){return this._currentLink}constructor(l){super(),this._bufferService=l,this._linkProviders=[],this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this.register(new g.EventEmitter),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this.register(new g.EventEmitter),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this.register((0,v.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,v.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(l){return this._linkProviders.push(l),{dispose:()=>{const u=this._linkProviders.indexOf(l);u!==-1&&this._linkProviders.splice(u,1)}}}attachToDom(l,u,d){this._element=l,this._mouseService=u,this._renderService=d,this.register((0,c.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,c.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,c.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(l){if(this._lastMouseEvent=l,!this._element||!this._mouseService)return;const u=this._positionFromMouseEvent(l,this._element,this._mouseService);if(!u)return;this._isMouseOut=!1;const d=l.composedPath();for(let f=0;f<d.length;f++){const S=d[f];if(S.classList.contains("xterm"))break;if(S.classList.contains("xterm-hover"))return}this._lastBufferCell&&u.x===this._lastBufferCell.x&&u.y===this._lastBufferCell.y||(this._handleHover(u),this._lastBufferCell=u)}_handleHover(l){if(this._activeLine!==l.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(l,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,l)||(this._clearCurrentLink(),this._askForLink(l,!0))}_askForLink(l,u){var d,f;this._activeProviderReplies&&u||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((C=>{C?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=l.y);let S=!1;for(const[C,k]of this._linkProviders.entries())u?!((f=this._activeProviderReplies)===null||f===void 0)&&f.get(C)&&(S=this._checkLinkProviderResult(C,l,S)):k.provideLinks(l.y,(j=>{var y,E;if(this._isMouseOut)return;const R=j?.map((P=>({link:P})));(y=this._activeProviderReplies)===null||y===void 0||y.set(C,R),S=this._checkLinkProviderResult(C,l,S),((E=this._activeProviderReplies)===null||E===void 0?void 0:E.size)===this._linkProviders.length&&this._removeIntersectingLinks(l.y,this._activeProviderReplies)}))}_removeIntersectingLinks(l,u){const d=new Set;for(let f=0;f<u.size;f++){const S=u.get(f);if(S)for(let C=0;C<S.length;C++){const k=S[C],j=k.link.range.start.y<l?0:k.link.range.start.x,y=k.link.range.end.y>l?this._bufferService.cols:k.link.range.end.x;for(let E=j;E<=y;E++){if(d.has(E)){S.splice(C--,1);break}d.add(E)}}}}_checkLinkProviderResult(l,u,d){var f;if(!this._activeProviderReplies)return d;const S=this._activeProviderReplies.get(l);let C=!1;for(let k=0;k<l;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(C=!0);if(!C&&S){const k=S.find((j=>this._linkAtPosition(j.link,u)));k&&(d=!0,this._handleNewLink(k))}if(this._activeProviderReplies.size===this._linkProviders.length&&!d)for(let k=0;k<this._activeProviderReplies.size;k++){const j=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((y=>this._linkAtPosition(y.link,u)));if(j){d=!0,this._handleNewLink(j);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(l){if(!this._element||!this._mouseService||!this._currentLink)return;const u=this._positionFromMouseEvent(l,this._element,this._mouseService);u&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,u)&&this._currentLink.link.activate(l,this._currentLink.link.text)}_clearCurrentLink(l,u){this._element&&this._currentLink&&this._lastMouseEvent&&(!l||!u||this._currentLink.link.range.start.y>=l&&this._currentLink.link.range.end.y<=u)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,v.disposeArray)(this._linkCacheDisposables))}_handleNewLink(l){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const u=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);u&&this._linkAtPosition(l.link,u)&&(this._currentLink=l,this._currentLink.state={decorations:{underline:l.link.decorations===void 0||l.link.decorations.underline,pointerCursor:l.link.decorations===void 0||l.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,l.link,this._lastMouseEvent),l.link.decorations={},Object.defineProperties(l.link.decorations,{pointerCursor:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.pointerCursor},set:d=>{var f,S;!((f=this._currentLink)===null||f===void 0)&&f.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((S=this._element)===null||S===void 0||S.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,f;return(f=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||f===void 0?void 0:f.decorations.underline},set:d=>{var f,S,C;!((f=this._currentLink)===null||f===void 0)&&f.state&&((C=(S=this._currentLink)===null||S===void 0?void 0:S.state)===null||C===void 0?void 0:C.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(l.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const f=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,S=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=f&&this._currentLink.link.range.end.y<=S&&(this._clearCurrentLink(f,S),this._lastMouseEvent&&this._element)){const C=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);C&&this._askForLink(C,!1)}}))))}_linkHover(l,u,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(u,!0),this._currentLink.state.decorations.pointerCursor&&l.classList.add("xterm-cursor-pointer")),u.hover&&u.hover(d,u.text)}_fireUnderlineEvent(l,u){const d=l.range,f=this._bufferService.buffer.ydisp,S=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-f-1,d.end.x,d.end.y-f-1,void 0);(u?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(S)}_linkLeave(l,u,d){var f;!((f=this._currentLink)===null||f===void 0)&&f.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(u,!1),this._currentLink.state.decorations.pointerCursor&&l.classList.remove("xterm-cursor-pointer")),u.leave&&u.leave(d,u.text)}_linkAtPosition(l,u){const d=l.range.start.y*this._bufferService.cols+l.range.start.x,f=l.range.end.y*this._bufferService.cols+l.range.end.x,S=u.y*this._bufferService.cols+u.x;return d<=S&&S<=f}_positionFromMouseEvent(l,u,d){const f=d.getCoords(l,u,this._bufferService.cols,this._bufferService.rows);if(f)return{x:f[0],y:f[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(l,u,d,f,S){return{x1:l,y1:u,x2:d,y2:f,cols:this._bufferService.cols,fg:S}}};i.Linkifier2=w=a([h(0,_.IBufferService)],w)},9042:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.tooMuchOutput=i.promptLabel=void 0,i.promptLabel="Terminal input",i.tooMuchOutput="Too much output to announce, navigate to rows manually to read"},3730:function(x,i,n){var a=this&&this.__decorate||function(w,l,u,d){var f,S=arguments.length,C=S<3?l:d===null?d=Object.getOwnPropertyDescriptor(l,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,l,u,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(S<3?f(C):S>3?f(l,u,C):f(l,u))||C);return S>3&&C&&Object.defineProperty(l,u,C),C},h=this&&this.__param||function(w,l){return function(u,d){l(u,d,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const c=n(511),g=n(2585);let v=i.OscLinkProvider=class{constructor(w,l,u){this._bufferService=w,this._optionsService=l,this._oscLinkService=u}provideLinks(w,l){var u;const d=this._bufferService.buffer.lines.get(w-1);if(!d)return void l(void 0);const f=[],S=this._optionsService.rawOptions.linkHandler,C=new c.CellData,k=d.getTrimmedLength();let j=-1,y=-1,E=!1;for(let R=0;R<k;R++)if(y!==-1||d.hasContent(R)){if(d.loadCell(R,C),C.hasExtendedAttrs()&&C.extended.urlId){if(y===-1){y=R,j=C.extended.urlId;continue}E=C.extended.urlId!==j}else y!==-1&&(E=!0);if(E||y!==-1&&R===k-1){const P=(u=this._oscLinkService.getLinkData(j))===null||u===void 0?void 0:u.uri;if(P){const M={start:{x:y+1,y:w},end:{x:R+(E||R!==k-1?0:1),y:w}};let L=!1;if(!S?.allowNonHttpProtocols)try{const z=new URL(P);["http:","https:"].includes(z.protocol)||(L=!0)}catch{L=!0}L||f.push({text:P,range:M,activate:(z,I)=>S?S.activate(z,I,M):_(0,I),hover:(z,I)=>{var W;return(W=S?.hover)===null||W===void 0?void 0:W.call(S,z,I,M)},leave:(z,I)=>{var W;return(W=S?.leave)===null||W===void 0?void 0:W.call(S,z,I,M)}})}E=!1,C.hasExtendedAttrs()&&C.extended.urlId?(y=R,j=C.extended.urlId):(y=-1,j=-1)}}l(f)}};function _(w,l){if(confirm(`Do you want to navigate to ${l}?
16
-
17
- WARNING: This link could potentially be dangerous`)){const u=window.open();if(u){try{u.opener=null}catch{}u.location.href=l}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=v=a([h(0,g.IBufferService),h(1,g.IOptionsService),h(2,g.IOscLinkService)],v)},6193:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(n,a){this._parentWindow=n,this._renderCallback=a,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._parentWindow.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(n){return this._refreshCallbacks.push(n),this._animationFrame||(this._animationFrame=this._parentWindow.requestAnimationFrame((()=>this._innerRefresh()))),this._animationFrame}refresh(n,a,h){this._rowCount=h,n=n!==void 0?n:0,a=a!==void 0?a:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,a):a,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 n=Math.max(this._rowStart,0),a=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,a),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const a=n(844);class h extends a.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,a.toDisposable)((()=>{this.clearListener()})))}setListener(g){this._listener&&this.clearListener(),this._listener=g,this._outerListener=()=>{this._listener&&(this._listener(this._parentWindow.devicePixelRatio,this._currentDevicePixelRatio),this._updateDpr())},this._updateDpr()}_updateDpr(){var g;this._outerListener&&((g=this._resolutionMediaMatchList)===null||g===void 0||g.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)}}i.ScreenDprMonitor=h},3236:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const a=n(3614),h=n(3656),c=n(6465),g=n(9042),v=n(3730),_=n(1680),w=n(3107),l=n(5744),u=n(2950),d=n(1296),f=n(428),S=n(4269),C=n(5114),k=n(8934),j=n(3230),y=n(9312),E=n(4725),R=n(6731),P=n(8055),M=n(8969),L=n(8460),z=n(844),I=n(6114),W=n(8437),$=n(2584),A=n(7399),D=n(5941),T=n(9074),O=n(2585),K=n(5435),V=n(4567),B=typeof window<"u"?window.document:null;class U extends M.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(N={}){super(N),this.browser=I,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new z.MutableDisposable),this._onCursorMove=this.register(new L.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new L.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new L.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new L.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new L.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new L.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new L.EventEmitter),this._onBlur=this.register(new L.EventEmitter),this._onA11yCharEmitter=this.register(new L.EventEmitter),this._onA11yTabEmitter=this.register(new L.EventEmitter),this._onWillOpen=this.register(new L.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(c.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(v.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(T.DecorationService),this._instantiationService.setService(O.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((F,q)=>this.refresh(F,q)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((F=>this._reportWindowsOptions(F)))),this.register(this._inputHandler.onColor((F=>this._handleColorEvent(F)))),this.register((0,L.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,L.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,L.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,L.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((F=>this._afterResize(F.cols,F.rows)))),this.register((0,z.toDisposable)((()=>{var F,q;this._customKeyEventHandler=void 0,(q=(F=this.element)===null||F===void 0?void 0:F.parentNode)===null||q===void 0||q.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const F of N){let q,Y="";switch(F.index){case 256:q="foreground",Y="10";break;case 257:q="background",Y="11";break;case 258:q="cursor",Y="12";break;default:q="ansi",Y="4;"+F.index}switch(F.type){case 0:const se=P.color.toColorRGB(q==="ansi"?this._themeService.colors.ansi[F.index]:this._themeService.colors[q]);this.coreService.triggerDataEvent(`${$.C0.ESC}]${Y};${(0,D.toRgbString)(se)}${$.C1_ESCAPED.ST}`);break;case 1:if(q==="ansi")this._themeService.modifyColors((G=>G.ansi[F.index]=P.rgba.toColor(...F.color)));else{const G=q;this._themeService.modifyColors((pe=>pe[G]=P.rgba.toColor(...F.color)))}break;case 2:this._themeService.restoreColor(F.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(N){N?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(V.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(N){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.C0.ESC+"[I"),this.updateCursorStyle(N),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var N;return(N=this.textarea)===null||N===void 0?void 0:N.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent($.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 N=this.buffer.ybase+this.buffer.y,F=this.buffer.lines.get(N);if(!F)return;const q=Math.min(this.buffer.x,this.cols-1),Y=this._renderService.dimensions.css.cell.height,se=F.getWidth(q),G=this._renderService.dimensions.css.cell.width*se,pe=this.buffer.y*this._renderService.dimensions.css.cell.height,he=q*this._renderService.dimensions.css.cell.width;this.textarea.style.left=he+"px",this.textarea.style.top=pe+"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,h.addDisposableDomListener)(this.element,"copy",(F=>{this.hasSelection()&&(0,a.copyHandler)(F,this._selectionService)})));const N=F=>(0,a.handlePasteEvent)(F,this.textarea,this.coreService,this.optionsService);this.register((0,h.addDisposableDomListener)(this.textarea,"paste",N)),this.register((0,h.addDisposableDomListener)(this.element,"paste",N)),I.isFirefox?this.register((0,h.addDisposableDomListener)(this.element,"mousedown",(F=>{F.button===2&&(0,a.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,h.addDisposableDomListener)(this.element,"contextmenu",(F=>{(0,a.rightClickHandler)(F,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),I.isLinux&&this.register((0,h.addDisposableDomListener)(this.element,"auxclick",(F=>{F.button===1&&(0,a.moveTextAreaUnderMouseCursor)(F,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,h.addDisposableDomListener)(this.textarea,"keyup",(N=>this._keyUp(N)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keydown",(N=>this._keyDown(N)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"keypress",(N=>this._keyPress(N)),!0)),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionupdate",(N=>this._compositionHelper.compositionupdate(N)))),this.register((0,h.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,h.addDisposableDomListener)(this.textarea,"input",(N=>this._inputEvent(N)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(N){var F;if(!N)throw new Error("Terminal requires a parent element.");N.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=N.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),N.appendChild(this.element);const q=B.createDocumentFragment();this._viewportElement=B.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),q.appendChild(this._viewportElement),this._viewportScrollArea=B.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=B.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=B.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),q.appendChild(this.screenElement),this.textarea=B.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),I.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(C.CoreBrowserService,this.textarea,(F=this._document.defaultView)!==null&&F!==void 0?F:window),this._instantiationService.setService(E.ICoreBrowserService,this._coreBrowserService),this.register((0,h.addDisposableDomListener)(this.textarea,"focus",(Y=>this._handleTextAreaFocus(Y)))),this.register((0,h.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(f.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(S.CharacterJoinerService),this._instantiationService.setService(E.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(j.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=B.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(u.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(q);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),this._mouseService=this._instantiationService.createInstance(k.MouseService),this._instantiationService.setService(E.IMouseService,this._mouseService),this.viewport=this._instantiationService.createInstance(_.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(y.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,h.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(w.BufferDecorationRenderer,this.screenElement)),this.register((0,h.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(V.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(Y=>this._handleScreenReaderModeOptionChange(Y)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(l.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(Y=>{!this._overviewRulerRenderer&&Y&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(l.OverviewRulerRenderer,this._viewportElement,this.screenElement)))})),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(d.DomRenderer,this.element,this.screenElement,this._viewportElement,this.linkifier2)}bindMouse(){const N=this,F=this.element;function q(G){const pe=N._mouseService.getMouseReportCoords(G,N.screenElement);if(!pe)return!1;let he,re;switch(G.overrideType||G.type){case"mousemove":re=32,G.buttons===void 0?(he=3,G.button!==void 0&&(he=G.button<3?G.button:3)):he=1&G.buttons?0:4&G.buttons?1:2&G.buttons?2:3;break;case"mouseup":re=0,he=G.button<3?G.button:3;break;case"mousedown":re=1,he=G.button<3?G.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(G)===0)return!1;re=G.deltaY<0?0:1,he=4;break;default:return!1}return!(re===void 0||he===void 0||he>4)&&N.coreMouseService.triggerMouseEvent({col:pe.col,row:pe.row,x:pe.x,y:pe.y,button:he,action:re,ctrl:G.ctrlKey,alt:G.altKey,shift:G.shiftKey})}const Y={mouseup:null,wheel:null,mousedrag:null,mousemove:null},se={mouseup:G=>(q(G),G.buttons||(this._document.removeEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.removeEventListener("mousemove",Y.mousedrag)),this.cancel(G)),wheel:G=>(q(G),this.cancel(G,!0)),mousedrag:G=>{G.buttons&&q(G)},mousemove:G=>{G.buttons||q(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||(F.addEventListener("mousemove",se.mousemove),Y.mousemove=se.mousemove):(F.removeEventListener("mousemove",Y.mousemove),Y.mousemove=null),16&G?Y.wheel||(F.addEventListener("wheel",se.wheel,{passive:!1}),Y.wheel=se.wheel):(F.removeEventListener("wheel",Y.wheel),Y.wheel=null),2&G?Y.mouseup||(F.addEventListener("mouseup",se.mouseup),Y.mouseup=se.mouseup):(this._document.removeEventListener("mouseup",Y.mouseup),F.removeEventListener("mouseup",Y.mouseup),Y.mouseup=null),4&G?Y.mousedrag||(Y.mousedrag=se.mousedrag):(this._document.removeEventListener("mousemove",Y.mousedrag),Y.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,h.addDisposableDomListener)(F,"mousedown",(G=>{if(G.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(G))return q(G),Y.mouseup&&this._document.addEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.addEventListener("mousemove",Y.mousedrag),this.cancel(G)}))),this.register((0,h.addDisposableDomListener)(F,"wheel",(G=>{if(!Y.wheel){if(!this.buffer.hasScrollback){const pe=this.viewport.getLinesScrolled(G);if(pe===0)return;const he=$.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(G.deltaY<0?"A":"B");let re="";for(let ne=0;ne<Math.abs(pe);ne++)re+=he;return this.coreService.triggerDataEvent(re,!0),this.cancel(G,!0)}return this.viewport.handleWheel(G)?this.cancel(G):void 0}}),{passive:!1})),this.register((0,h.addDisposableDomListener)(F,"touchstart",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(G),this.cancel(G)}),{passive:!0})),this.register((0,h.addDisposableDomListener)(F,"touchmove",(G=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(G)?void 0:this.cancel(G)}),{passive:!1}))}refresh(N,F){var q;(q=this._renderService)===null||q===void 0||q.refreshRows(N,F)}updateCursorStyle(N){var F;!((F=this._selectionService)===null||F===void 0)&&F.shouldColumnSelect(N)?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(N,F,q=0){var Y;q===1?(super.scrollLines(N,F,q),this.refresh(0,this.rows-1)):(Y=this.viewport)===null||Y===void 0||Y.scrollLines(N)}paste(N){(0,a.paste)(N,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(N){this._customKeyEventHandler=N}registerLinkProvider(N){return this.linkifier2.registerLinkProvider(N)}registerCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const F=this._characterJoinerService.register(N);return this.refresh(0,this.rows-1),F}deregisterCharacterJoiner(N){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(N)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(N){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+N)}registerDecoration(N){return this._decorationService.registerDecoration(N)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(N,F,q){this._selectionService.setSelection(N,F,q)}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 N;(N=this._selectionService)===null||N===void 0||N.clearSelection()}selectAll(){var N;(N=this._selectionService)===null||N===void 0||N.selectAll()}selectLines(N,F){var q;(q=this._selectionService)===null||q===void 0||q.selectLines(N,F)}_keyDown(N){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;const F=this.browser.isMac&&this.options.macOptionIsMeta&&N.altKey;if(!F&&!this._compositionHelper.keydown(N))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;F||N.key!=="Dead"&&N.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const q=(0,A.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),q.type===3||q.type===2){const Y=this.rows-1;return this.scrollLines(q.type===2?-Y:Y),this.cancel(N,!0)}return q.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(q.cancel&&this.cancel(N,!0),!q.key||!!(N.key&&!N.ctrlKey&&!N.altKey&&!N.metaKey&&N.key.length===1&&N.key.charCodeAt(0)>=65&&N.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(q.key!==$.C0.ETX&&q.key!==$.C0.CR||(this.textarea.value=""),this._onKey.fire({key:q.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(q.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,F){const q=N.isMac&&!this.options.macOptionIsMeta&&F.altKey&&!F.ctrlKey&&!F.metaKey||N.isWindows&&F.altKey&&F.ctrlKey&&!F.metaKey||N.isWindows&&F.getModifierState("AltGraph");return F.type==="keypress"?q:q&&(!F.keyCode||F.keyCode>47)}_keyUp(N){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1||((function(F){return F.keyCode===16||F.keyCode===17||F.keyCode===18})(N)||this.focus(),this.updateCursorStyle(N),this._keyPressHandled=!1)}_keyPress(N){let F;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(N)===!1)return!1;if(this.cancel(N),N.charCode)F=N.charCode;else if(N.which===null||N.which===void 0)F=N.keyCode;else{if(N.which===0||N.charCode===0)return!1;F=N.which}return!(!F||(N.altKey||N.ctrlKey||N.metaKey)&&!this._isThirdLevelShift(this.browser,N)||(F=String.fromCharCode(F),this._onKey.fire({key:F,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(F,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(N){if(N.data&&N.inputType==="insertText"&&(!N.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const F=N.data;return this.coreService.triggerDataEvent(F,!0),this.cancel(N),!0}return!1}resize(N,F){N!==this.cols||F!==this.rows?super.resize(N,F):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(N,F){var q,Y;(q=this._charSizeService)===null||q===void 0||q.measure(),(Y=this.viewport)===null||Y===void 0||Y.syncScrollArea(!0)}clear(){var N;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 F=1;F<this.rows;F++)this.buffer.lines.push(this.buffer.getBlankLine(W.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(N=this.viewport)===null||N===void 0||N.reset(),this.refresh(0,this.rows-1)}}reset(){var N,F;this.options.rows=this.rows,this.options.cols=this.cols;const q=this._customKeyEventHandler;this._setup(),super.reset(),(N=this._selectionService)===null||N===void 0||N.reset(),this._decorationService.reset(),(F=this.viewport)===null||F===void 0||F.reset(),this._customKeyEventHandler=q,this.refresh(0,this.rows-1)}clearTextureAtlas(){var N;(N=this._renderService)===null||N===void 0||N.clearTextureAtlas()}_reportFocus(){var N;!((N=this.element)===null||N===void 0)&&N.classList.contains("focus")?this.coreService.triggerDataEvent($.C0.ESC+"[I"):this.coreService.triggerDataEvent($.C0.ESC+"[O")}_reportWindowsOptions(N){if(this._renderService)switch(N){case K.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const F=this._renderService.dimensions.css.canvas.width.toFixed(0),q=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[4;${q};${F}t`);break;case K.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const Y=this._renderService.dimensions.css.cell.width.toFixed(0),se=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[6;${se};${Y}t`)}}cancel(N,F){if(this.options.cancelEvents||F)return N.preventDefault(),N.stopPropagation(),!1}}i.Terminal=U},9924:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(n,a=1e3){this._renderCallback=n,this._debounceThresholdMS=a,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,a,h){this._rowCount=h,n=n!==void 0?n:0,a=a!==void 0?a:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,n):n,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,a):a;const c=Date.now();if(c-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=c,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=c-this._lastRefreshMs,v=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),v)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const n=Math.max(this._rowStart,0),a=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,a)}}},1680:function(x,i,n){var a=this&&this.__decorate||function(u,d,f,S){var C,k=arguments.length,j=k<3?d:S===null?S=Object.getOwnPropertyDescriptor(d,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(u,d,f,S);else for(var y=u.length-1;y>=0;y--)(C=u[y])&&(j=(k<3?C(j):k>3?C(d,f,j):C(d,f))||j);return k>3&&j&&Object.defineProperty(d,f,j),j},h=this&&this.__param||function(u,d){return function(f,S){d(f,S,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const c=n(3656),g=n(4725),v=n(8460),_=n(844),w=n(2585);let l=i.Viewport=class extends _.Disposable{constructor(u,d,f,S,C,k,j,y){super(),this._viewportElement=u,this._scrollArea=d,this._bufferService=f,this._optionsService=S,this._charSizeService=C,this._renderService=k,this._coreBrowserService=j,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 v.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,c.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(y.colors),this.register(y.onChangeColors((E=>this._handleThemeChange(E)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(u){this._viewportElement.style.backgroundColor=u.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(u){if(u)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 d=Math.round(this._currentRowHeight*this._lastRecordedBufferLength)+(this._lastRecordedViewportHeight-this._renderService.dimensions.css.canvas.height);this._lastRecordedBufferHeight!==d&&(this._lastRecordedBufferHeight=d,this._scrollArea.style.height=this._lastRecordedBufferHeight+"px")}const u=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==u&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=u),this._refreshAnimationFrame=null}syncScrollArea(u=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(u);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(u)}_handleScroll(u){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 d=Math.round(this._lastScrollTop/this._currentRowHeight)-this._bufferService.buffer.ydisp;this._onRequestScrollLines.fire({amount:d,suppressScrollEvent:!0})}_smoothScroll(){if(this._isDisposed||this._smoothScrollState.origin===-1||this._smoothScrollState.target===-1)return;const u=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(u*(this._smoothScrollState.target-this._smoothScrollState.origin)),u<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(u,d){const f=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&f<this._lastRecordedBufferHeight)||(u.cancelable&&u.preventDefault(),!1)}handleWheel(u){const d=this._getPixelsScrolled(u);return d!==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+d:this._smoothScrollState.target+=d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()):this._viewportElement.scrollTop+=d,this._bubbleScroll(u,d))}scrollLines(u){if(u!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=u*this._currentRowHeight;this._smoothScrollState.startTime=Date.now(),this._smoothScrollPercent()<1?(this._smoothScrollState.origin=this._viewportElement.scrollTop,this._smoothScrollState.target=this._smoothScrollState.origin+d,this._smoothScrollState.target=Math.max(Math.min(this._smoothScrollState.target,this._viewportElement.scrollHeight),0),this._smoothScroll()):this._clearSmoothScrollState()}else this._onRequestScrollLines.fire({amount:u,suppressScrollEvent:!1})}_getPixelsScrolled(u){if(u.deltaY===0||u.shiftKey)return 0;let d=this._applyScrollModifier(u.deltaY,u);return u.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:u.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(u,d){var f;let S,C="";const k=[],j=d??this._bufferService.buffer.lines.length,y=this._bufferService.buffer.lines;for(let E=u;E<j;E++){const R=y.get(E);if(!R)continue;const P=(f=y.get(E+1))===null||f===void 0?void 0:f.isWrapped;if(C+=R.translateToString(!P),!P||E===y.length-1){const M=document.createElement("div");M.textContent=C,k.push(M),C.length>0&&(S=M),C=""}}return{bufferElements:k,cursorElement:S}}getLinesScrolled(u){if(u.deltaY===0||u.shiftKey)return 0;let d=this._applyScrollModifier(u.deltaY,u);return u.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(d/=this._currentRowHeight+0,this._wheelPartialScroll+=d,d=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):u.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(u,d){const f=this._optionsService.rawOptions.fastScrollModifier;return f==="alt"&&d.altKey||f==="ctrl"&&d.ctrlKey||f==="shift"&&d.shiftKey?u*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:u*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(u){this._lastTouchY=u.touches[0].pageY}handleTouchMove(u){const d=this._lastTouchY-u.touches[0].pageY;return this._lastTouchY=u.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(u,d))}};i.Viewport=l=a([h(2,w.IBufferService),h(3,w.IOptionsService),h(4,g.ICharSizeService),h(5,g.IRenderService),h(6,g.ICoreBrowserService),h(7,g.IThemeService)],l)},3107:function(x,i,n){var a=this&&this.__decorate||function(l,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,u,d,f);else for(var j=l.length-1;j>=0;j--)(S=l[j])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(l,u){return function(d,f){u(d,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const c=n(3656),g=n(4725),v=n(844),_=n(2585);let w=i.BufferDecorationRenderer=class extends v.Disposable{constructor(l,u,d,f){super(),this._screenElement=l,this._bufferService=u,this._decorationService=d,this._renderService=f,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,c.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((S=>this._removeDecoration(S)))),this.register((0,v.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 l of this._decorationService.decorations)this._renderDecoration(l);this._dimensionsChanged=!1}_renderDecoration(l){this._refreshStyle(l),this._dimensionsChanged&&this._refreshXPosition(l)}_createElement(l){var u,d;const f=document.createElement("div");f.classList.add("xterm-decoration"),f.classList.toggle("xterm-decoration-top-layer",((u=l?.options)===null||u===void 0?void 0:u.layer)==="top"),f.style.width=`${Math.round((l.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,f.style.height=(l.options.height||1)*this._renderService.dimensions.css.cell.height+"px",f.style.top=(l.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",f.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const S=(d=l.options.x)!==null&&d!==void 0?d:0;return S&&S>this._bufferService.cols&&(f.style.display="none"),this._refreshXPosition(l,f),f}_refreshStyle(l){const u=l.marker.line-this._bufferService.buffers.active.ydisp;if(u<0||u>=this._bufferService.rows)l.element&&(l.element.style.display="none",l.onRenderEmitter.fire(l.element));else{let d=this._decorationElements.get(l);d||(d=this._createElement(l),l.element=d,this._decorationElements.set(l,d),this._container.appendChild(d),l.onDispose((()=>{this._decorationElements.delete(l),d.remove()}))),d.style.top=u*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",l.onRenderEmitter.fire(d)}}_refreshXPosition(l,u=l.element){var d;if(!u)return;const f=(d=l.options.x)!==null&&d!==void 0?d:0;(l.options.anchor||"left")==="right"?u.style.right=f?f*this._renderService.dimensions.css.cell.width+"px":"":u.style.left=f?f*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(l){var u;(u=this._decorationElements.get(l))===null||u===void 0||u.remove(),this._decorationElements.delete(l),l.dispose()}};i.BufferDecorationRenderer=w=a([h(1,_.IBufferService),h(2,_.IDecorationService),h(3,g.IRenderService)],w)},5871:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorZoneStore=void 0,i.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(n){if(n.options.overviewRulerOptions){for(const a of this._zones)if(a.color===n.options.overviewRulerOptions.color&&a.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(a,n.marker.line))return;if(this._lineAdjacentToZone(a,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(a,n.marker.line)}if(this._zonePoolIndex<this._zonePool.length)return this._zonePool[this._zonePoolIndex].color=n.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=n.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=n.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=n.marker.line,void this._zones.push(this._zonePool[this._zonePoolIndex++]);this._zones.push({color:n.options.overviewRulerOptions.color,position:n.options.overviewRulerOptions.position,startBufferLine:n.marker.line,endBufferLine:n.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(n){this._linePadding=n}_lineIntersectsZone(n,a){return a>=n.startBufferLine&&a<=n.endBufferLine}_lineAdjacentToZone(n,a,h){return a>=n.startBufferLine-this._linePadding[h||"full"]&&a<=n.endBufferLine+this._linePadding[h||"full"]}_addLineToZone(n,a){n.startBufferLine=Math.min(n.startBufferLine,a),n.endBufferLine=Math.max(n.endBufferLine,a)}}},5744:function(x,i,n){var a=this&&this.__decorate||function(S,C,k,j){var y,E=arguments.length,R=E<3?C:j===null?j=Object.getOwnPropertyDescriptor(C,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,C,k,j);else for(var P=S.length-1;P>=0;P--)(y=S[P])&&(R=(E<3?y(R):E>3?y(C,k,R):y(C,k))||R);return E>3&&R&&Object.defineProperty(C,k,R),R},h=this&&this.__param||function(S,C){return function(k,j){C(k,j,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const c=n(5871),g=n(3656),v=n(4725),_=n(844),w=n(2585),l={full:0,left:0,center:0,right:0},u={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let f=i.OverviewRulerRenderer=class extends _.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(S,C,k,j,y,E,R){var P;super(),this._viewportElement=S,this._screenElement=C,this._bufferService=k,this._decorationService=j,this._renderService=y,this._optionsService=E,this._coreBrowseService=R,this._colorZoneStore=new c.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(),(P=this._viewportElement.parentElement)===null||P===void 0||P.insertBefore(this._canvas,this._viewportElement);const M=this._canvas.getContext("2d");if(!M)throw new Error("Ctx cannot be null");this._ctx=M,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,_.toDisposable)((()=>{var L;(L=this._canvas)===null||L===void 0||L.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,g.addDisposableDomListener)(this._coreBrowseService.window,"resize",(()=>this._queueRefresh(!0)))),this._queueRefresh(!0)}_refreshDrawConstants(){const S=Math.floor(this._canvas.width/3),C=Math.ceil(this._canvas.width/3);u.full=this._canvas.width,u.left=S,u.center=C,u.right=S,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=u.left,d.right=u.left+u.center}_refreshDrawHeightConstants(){l.full=Math.round(2*this._coreBrowseService.dpr);const S=this._canvas.height/this._bufferService.buffer.lines.length,C=Math.round(Math.max(Math.min(S,12),6)*this._coreBrowseService.dpr);l.left=C,l.center=C,l.right=C}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*l.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 C of this._decorationService.decorations)this._colorZoneStore.addDecoration(C);this._ctx.lineWidth=1;const S=this._colorZoneStore.zones;for(const C of S)C.position!=="full"&&this._renderColorZone(C);for(const C of S)C.position==="full"&&this._renderColorZone(C);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(S){this._ctx.fillStyle=S.color,this._ctx.fillRect(d[S.position||"full"],Math.round((this._canvas.height-1)*(S.startBufferLine/this._bufferService.buffers.active.lines.length)-l[S.position||"full"]/2),u[S.position||"full"],Math.round((this._canvas.height-1)*((S.endBufferLine-S.startBufferLine)/this._bufferService.buffers.active.lines.length)+l[S.position||"full"]))}_queueRefresh(S,C){this._shouldUpdateDimensions=S||this._shouldUpdateDimensions,this._shouldUpdateAnchor=C||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=f=a([h(2,w.IBufferService),h(3,w.IDecorationService),h(4,v.IRenderService),h(5,w.IOptionsService),h(6,v.ICoreBrowserService)],f)},2950:function(x,i,n){var a=this&&this.__decorate||function(w,l,u,d){var f,S=arguments.length,C=S<3?l:d===null?d=Object.getOwnPropertyDescriptor(l,u):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")C=Reflect.decorate(w,l,u,d);else for(var k=w.length-1;k>=0;k--)(f=w[k])&&(C=(S<3?f(C):S>3?f(l,u,C):f(l,u))||C);return S>3&&C&&Object.defineProperty(l,u,C),C},h=this&&this.__param||function(w,l){return function(u,d){l(u,d,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const c=n(4725),g=n(2585),v=n(2584);let _=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(w,l,u,d,f,S){this._textarea=w,this._compositionView=l,this._bufferService=u,this._optionsService=d,this._coreService=f,this._renderService=S,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(w){this._compositionView.textContent=w.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(w){if(this._isComposing||this._isSendingComposition){if(w.keyCode===229||w.keyCode===16||w.keyCode===17||w.keyCode===18)return!1;this._finalizeComposition(!1)}return w.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(w){if(this._compositionView.classList.remove("active"),this._isComposing=!1,w){const l={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let u;this._isSendingComposition=!1,l.start+=this._dataAlreadySent.length,u=this._isComposing?this._textarea.value.substring(l.start,l.end):this._textarea.value.substring(l.start),u.length>0&&this._coreService.triggerDataEvent(u,!0)}}),0)}else{this._isSendingComposition=!1;const l=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(l,!0)}}_handleAnyTextareaChanges(){const w=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const l=this._textarea.value,u=l.replace(w,"");this._dataAlreadySent=u,l.length>w.length?this._coreService.triggerDataEvent(u,!0):l.length<w.length?this._coreService.triggerDataEvent(`${v.C0.DEL}`,!0):l.length===w.length&&l!==w&&this._coreService.triggerDataEvent(l,!0)}}),0)}updateCompositionElements(w){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const l=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),u=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,f=l*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=f+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=u+"px",this._compositionView.style.lineHeight=u+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const S=this._compositionView.getBoundingClientRect();this._textarea.style.left=f+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(S.width,1)+"px",this._textarea.style.height=Math.max(S.height,1)+"px",this._textarea.style.lineHeight=S.height+"px"}w||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=_=a([h(2,g.IBufferService),h(3,g.IOptionsService),h(4,g.ICoreService),h(5,c.IRenderService)],_)},9806:(x,i)=>{function n(a,h,c){const g=c.getBoundingClientRect(),v=a.getComputedStyle(c),_=parseInt(v.getPropertyValue("padding-left")),w=parseInt(v.getPropertyValue("padding-top"));return[h.clientX-g.left-_,h.clientY-g.top-w]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(a,h,c,g,v,_,w,l,u){if(!_)return;const d=n(a,h,c);return d?(d[0]=Math.ceil((d[0]+(u?w/2:0))/w),d[1]=Math.ceil(d[1]/l),d[0]=Math.min(Math.max(d[0],1),g+(u?1:0)),d[1]=Math.min(Math.max(d[1],1),v),d):void 0}},9504:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const a=n(2584);function h(l,u,d,f){const S=l-c(l,d),C=u-c(u,d),k=Math.abs(S-C)-(function(j,y,E){let R=0;const P=j-c(j,E),M=y-c(y,E);for(let L=0;L<Math.abs(P-M);L++){const z=g(j,y)==="A"?-1:1,I=E.buffer.lines.get(P+z*L);I?.isWrapped&&R++}return R})(l,u,d);return w(k,_(g(l,u),f))}function c(l,u){let d=0,f=u.buffer.lines.get(l),S=f?.isWrapped;for(;S&&l>=0&&l<u.rows;)d++,f=u.buffer.lines.get(--l),S=f?.isWrapped;return d}function g(l,u){return l>u?"A":"B"}function v(l,u,d,f,S,C){let k=l,j=u,y="";for(;k!==d||j!==f;)k+=S?1:-1,S&&k>C.cols-1?(y+=C.buffer.translateBufferLineToString(j,!1,l,k),k=0,l=0,j++):!S&&k<0&&(y+=C.buffer.translateBufferLineToString(j,!1,0,l+1),k=C.cols-1,l=k,j--);return y+C.buffer.translateBufferLineToString(j,!1,l,k)}function _(l,u){const d=u?"O":"[";return a.C0.ESC+d+l}function w(l,u){l=Math.floor(l);let d="";for(let f=0;f<l;f++)d+=u;return d}i.moveToCellSequence=function(l,u,d,f){const S=d.buffer.x,C=d.buffer.y;if(!d.buffer.hasScrollback)return(function(y,E,R,P,M,L){return h(E,P,M,L).length===0?"":w(v(y,E,y,E-c(E,M),!1,M).length,_("D",L))})(S,C,0,u,d,f)+h(C,u,d,f)+(function(y,E,R,P,M,L){let z;z=h(E,P,M,L).length>0?P-c(P,M):E;const I=P,W=(function($,A,D,T,O,K){let V;return V=h(D,T,O,K).length>0?T-c(T,O):A,$<D&&V<=T||$>=D&&V<T?"C":"D"})(y,E,R,P,M,L);return w(v(y,z,R,I,W==="C",M).length,_(W,L))})(S,C,l,u,d,f);let k;if(C===u)return k=S>l?"D":"C",w(Math.abs(S-l),_(k,f));k=C>u?"D":"C";const j=Math.abs(C-u);return w((function(y,E){return E.cols-y})(C>u?l:S,d)+(j-1)*d.cols+1+((C>u?S:l)-1),_(k,f))}},1296:function(x,i,n){var a=this&&this.__decorate||function(M,L,z,I){var W,$=arguments.length,A=$<3?L:I===null?I=Object.getOwnPropertyDescriptor(L,z):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(M,L,z,I);else for(var D=M.length-1;D>=0;D--)(W=M[D])&&(A=($<3?W(A):$>3?W(L,z,A):W(L,z))||A);return $>3&&A&&Object.defineProperty(L,z,A),A},h=this&&this.__param||function(M,L){return function(z,I){L(z,I,M)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const c=n(3787),g=n(2550),v=n(2223),_=n(6171),w=n(4725),l=n(8055),u=n(8460),d=n(844),f=n(2585),S="xterm-dom-renderer-owner-",C="xterm-rows",k="xterm-fg-",j="xterm-bg-",y="xterm-focus",E="xterm-selection";let R=1,P=i.DomRenderer=class extends d.Disposable{constructor(M,L,z,I,W,$,A,D,T,O){super(),this._element=M,this._screenElement=L,this._viewportElement=z,this._linkifier2=I,this._charSizeService=$,this._optionsService=A,this._bufferService=D,this._coreBrowserService=T,this._themeService=O,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new u.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(C),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,_.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((K=>this._injectCss(K)))),this._injectCss(this._themeService.colors),this._rowFactory=W.createInstance(c.DomRendererRowFactory,document),this._element.classList.add(S+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline((K=>this._handleLinkHover(K)))),this.register(this._linkifier2.onHideLinkUnderline((K=>this._handleLinkLeave(K)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(S+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()}))),this._widthCache=new g.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 M=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*M,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*M),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/M),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/M),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 z of this._rowElements)z.style.width=`${this.dimensions.css.canvas.width}px`,z.style.height=`${this.dimensions.css.cell.height}px`,z.style.lineHeight=`${this.dimensions.css.cell.height}px`,z.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const L=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=L,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(M){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let L=`${this._terminalSelector} .${C} { color: ${M.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;L+=`${this._terminalSelector} .${C} .xterm-dim { color: ${l.color.multiplyOpacity(M.foreground,.5).css};}`,L+=`${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;}`,L+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",L+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css}; } 50% { background-color: inherit; color: ${M.cursor.css}; }}`,L+=`${this._terminalSelector} .${C}.${y} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C}.${y} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-block { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css};}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${M.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${M.cursor.css} inset;}${this._terminalSelector} .${C} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${M.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,L+=`${this._terminalSelector} .${E} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${E} div { position: absolute; background-color: ${M.selectionBackgroundOpaque.css};}${this._terminalSelector} .${E} div { position: absolute; background-color: ${M.selectionInactiveBackgroundOpaque.css};}`;for(const[z,I]of M.ansi.entries())L+=`${this._terminalSelector} .${k}${z} { color: ${I.css}; }${this._terminalSelector} .${k}${z}.xterm-dim { color: ${l.color.multiplyOpacity(I,.5).css}; }${this._terminalSelector} .${j}${z} { background-color: ${I.css}; }`;L+=`${this._terminalSelector} .${k}${v.INVERTED_DEFAULT_COLOR} { color: ${l.color.opaque(M.background).css}; }${this._terminalSelector} .${k}${v.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${l.color.multiplyOpacity(l.color.opaque(M.background),.5).css}; }${this._terminalSelector} .${j}${v.INVERTED_DEFAULT_COLOR} { background-color: ${M.foreground.css}; }`,this._themeStyleElement.textContent=L}_setDefaultSpacing(){const M=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${M}px`,this._rowFactory.defaultSpacing=M}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(M,L){for(let z=this._rowElements.length;z<=L;z++){const I=document.createElement("div");this._rowContainer.appendChild(I),this._rowElements.push(I)}for(;this._rowElements.length>L;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(M,L){this._refreshRowElements(M,L),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(y)}handleFocus(){this._rowContainer.classList.add(y),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(M,L,z){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(M,L,z),this.renderRows(0,this._bufferService.rows-1),!M||!L)return;const I=M[1]-this._bufferService.buffer.ydisp,W=L[1]-this._bufferService.buffer.ydisp,$=Math.max(I,0),A=Math.min(W,this._bufferService.rows-1);if($>=this._bufferService.rows||A<0)return;const D=document.createDocumentFragment();if(z){const T=M[0]>L[0];D.appendChild(this._createSelectionElement($,T?L[0]:M[0],T?M[0]:L[0],A-$+1))}else{const T=I===$?M[0]:0,O=$===W?L[0]:this._bufferService.cols;D.appendChild(this._createSelectionElement($,T,O));const K=A-$-1;if(D.appendChild(this._createSelectionElement($+1,0,this._bufferService.cols,K)),$!==A){const V=W===A?L[0]:this._bufferService.cols;D.appendChild(this._createSelectionElement(A,0,V))}}this._selectionContainer.appendChild(D)}_createSelectionElement(M,L,z,I=1){const W=document.createElement("div");return W.style.height=I*this.dimensions.css.cell.height+"px",W.style.top=M*this.dimensions.css.cell.height+"px",W.style.left=L*this.dimensions.css.cell.width+"px",W.style.width=this.dimensions.css.cell.width*(z-L)+"px",W}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 M of this._rowElements)M.replaceChildren()}renderRows(M,L){const z=this._bufferService.buffer,I=z.ybase+z.y,W=Math.min(z.x,this._bufferService.cols-1),$=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,D=this._optionsService.rawOptions.cursorInactiveStyle;for(let T=M;T<=L;T++){const O=T+z.ydisp,K=this._rowElements[T],V=z.lines.get(O);if(!K||!V)break;K.replaceChildren(...this._rowFactory.createRow(V,O,O===I,A,D,W,$,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${S}${this._terminalClass}`}_handleLinkHover(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!0)}_handleLinkLeave(M){this._setCellUnderline(M.x1,M.x2,M.y1,M.y2,M.cols,!1)}_setCellUnderline(M,L,z,I,W,$){z<0&&(M=0),I<0&&(L=0);const A=this._bufferService.rows-1;z=Math.max(Math.min(z,A),0),I=Math.max(Math.min(I,A),0),W=Math.min(W,this._bufferService.cols);const D=this._bufferService.buffer,T=D.ybase+D.y,O=Math.min(D.x,W-1),K=this._optionsService.rawOptions.cursorBlink,V=this._optionsService.rawOptions.cursorStyle,B=this._optionsService.rawOptions.cursorInactiveStyle;for(let U=z;U<=I;++U){const H=U+D.ydisp,N=this._rowElements[U],F=D.lines.get(H);if(!N||!F)break;N.replaceChildren(...this._rowFactory.createRow(F,H,H===T,V,B,O,K,this.dimensions.css.cell.width,this._widthCache,$?U===z?M:0:-1,$?(U===I?L:W)-1:-1))}}};i.DomRenderer=P=a([h(4,f.IInstantiationService),h(5,w.ICharSizeService),h(6,f.IOptionsService),h(7,f.IBufferService),h(8,w.ICoreBrowserService),h(9,w.IThemeService)],P)},3787:function(x,i,n){var a=this&&this.__decorate||function(k,j,y,E){var R,P=arguments.length,M=P<3?j:E===null?E=Object.getOwnPropertyDescriptor(j,y):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(k,j,y,E);else for(var L=k.length-1;L>=0;L--)(R=k[L])&&(M=(P<3?R(M):P>3?R(j,y,M):R(j,y))||M);return P>3&&M&&Object.defineProperty(j,y,M),M},h=this&&this.__param||function(k,j){return function(y,E){j(y,E,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const c=n(2223),g=n(643),v=n(511),_=n(2585),w=n(8055),l=n(4725),u=n(4269),d=n(6171),f=n(3734);let S=i.DomRendererRowFactory=class{constructor(k,j,y,E,R,P,M){this._document=k,this._characterJoinerService=j,this._optionsService=y,this._coreBrowserService=E,this._coreService=R,this._decorationService=P,this._themeService=M,this._workCell=new v.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,j,y){this._selectionStart=k,this._selectionEnd=j,this._columnSelectMode=y}createRow(k,j,y,E,R,P,M,L,z,I,W){const $=[],A=this._characterJoinerService.getJoinedCharacters(j),D=this._themeService.colors;let T,O=k.getNoBgTrimmedLength();y&&O<P+1&&(O=P+1);let K=0,V="",B=0,U=0,H=0,N=!1,F=0,q=!1,Y=0;const se=[],G=I!==-1&&W!==-1;for(let pe=0;pe<O;pe++){k.loadCell(pe,this._workCell);let he=this._workCell.getWidth();if(he===0)continue;let re=!1,ne=pe,le=this._workCell;if(A.length>0&&pe===A[0][0]){re=!0;const ge=A.shift();le=new u.JoinedCellData(this._workCell,k.translateToString(!0,ge[0],ge[1]),ge[1]-ge[0]),ne=ge[1]-1,he=le.getWidth()}const Se=this._isCellInSelection(pe,j),We=y&&pe===P,Ee=G&&pe>=I&&pe<=W;let He=!1;this._decorationService.forEachDecorationAtCell(pe,j,void 0,(ge=>{He=!0}));let at=le.getChars()||g.WHITESPACE_CELL_CHAR;if(at===" "&&(le.isUnderline()||le.isOverline())&&(at=" "),Y=he*L-z.get(at,le.isBold(),le.isItalic()),T){if(K&&(Se&&q||!Se&&!q&&le.bg===B)&&(Se&&q&&D.selectionForeground||le.fg===U)&&le.extended.ext===H&&Ee===N&&Y===F&&!We&&!re&&!He){V+=at,K++;continue}K&&(T.textContent=V),T=this._document.createElement("span"),K=0,V=""}else T=this._document.createElement("span");if(B=le.bg,U=le.fg,H=le.extended.ext,N=Ee,F=Y,q=Se,re&&P>=pe&&P<=ne&&(P=pe),!this._coreService.isCursorHidden&&We){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)M&&se.push("xterm-cursor-blink"),se.push(E==="bar"?"xterm-cursor-bar":E==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":se.push("xterm-cursor-outline");break;case"block":se.push("xterm-cursor-block");break;case"bar":se.push("xterm-cursor-bar");break;case"underline":se.push("xterm-cursor-underline")}}if(le.isBold()&&se.push("xterm-bold"),le.isItalic()&&se.push("xterm-italic"),le.isDim()&&se.push("xterm-dim"),V=le.isInvisible()?g.WHITESPACE_CELL_CHAR:le.getChars()||g.WHITESPACE_CELL_CHAR,le.isUnderline()&&(se.push(`xterm-underline-${le.extended.underlineStyle}`),V===" "&&(V=" "),!le.isUnderlineColorDefault()))if(le.isUnderlineColorRGB())T.style.textDecorationColor=`rgb(${f.AttributeData.toColorRGB(le.getUnderlineColor()).join(",")})`;else{let ge=le.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&le.isBold()&&ge<8&&(ge+=8),T.style.textDecorationColor=D.ansi[ge].css}le.isOverline()&&(se.push("xterm-overline"),V===" "&&(V=" ")),le.isStrikethrough()&&se.push("xterm-strikethrough"),Ee&&(T.style.textDecoration="underline");let Me=le.getFgColor(),Ne=le.getFgColorMode(),Oe=le.getBgColor(),$e=le.getBgColorMode();const qe=!!le.isInverse();if(qe){const ge=Me;Me=Oe,Oe=ge;const et=Ne;Ne=$e,$e=et}let De,Ge,Qe,Te=!1;switch(this._decorationService.forEachDecorationAtCell(pe,j,void 0,(ge=>{ge.options.layer!=="top"&&Te||(ge.backgroundColorRGB&&($e=50331648,Oe=ge.backgroundColorRGB.rgba>>8&16777215,De=ge.backgroundColorRGB),ge.foregroundColorRGB&&(Ne=50331648,Me=ge.foregroundColorRGB.rgba>>8&16777215,Ge=ge.foregroundColorRGB),Te=ge.options.layer==="top")})),!Te&&Se&&(De=this._coreBrowserService.isFocused?D.selectionBackgroundOpaque:D.selectionInactiveBackgroundOpaque,Oe=De.rgba>>8&16777215,$e=50331648,Te=!0,D.selectionForeground&&(Ne=50331648,Me=D.selectionForeground.rgba>>8&16777215,Ge=D.selectionForeground)),Te&&se.push("xterm-decoration-top"),$e){case 16777216:case 33554432:Qe=D.ansi[Oe],se.push(`xterm-bg-${Oe}`);break;case 50331648:Qe=w.rgba.toColor(Oe>>16,Oe>>8&255,255&Oe),this._addStyle(T,`background-color:#${C((Oe>>>0).toString(16),"0",6)}`);break;default:qe?(Qe=D.foreground,se.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):Qe=D.background}switch(De||le.isDim()&&(De=w.color.multiplyOpacity(Qe,.5)),Ne){case 16777216:case 33554432:le.isBold()&&Me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Me+=8),this._applyMinimumContrast(T,Qe,D.ansi[Me],le,De,void 0)||se.push(`xterm-fg-${Me}`);break;case 50331648:const ge=w.rgba.toColor(Me>>16&255,Me>>8&255,255&Me);this._applyMinimumContrast(T,Qe,ge,le,De,Ge)||this._addStyle(T,`color:#${C(Me.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,Qe,D.foreground,le,De,void 0)||qe&&se.push(`xterm-fg-${c.INVERTED_DEFAULT_COLOR}`)}se.length&&(T.className=se.join(" "),se.length=0),We||re||He?T.textContent=V:K++,Y!==this.defaultSpacing&&(T.style.letterSpacing=`${Y}px`),$.push(T),pe=ne}return T&&K&&(T.textContent=V),$}_applyMinimumContrast(k,j,y,E,R,P){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(E.getCode()))return!1;const M=this._getContrastCache(E);let L;if(R||P||(L=M.getColor(j.rgba,y.rgba)),L===void 0){const z=this._optionsService.rawOptions.minimumContrastRatio/(E.isDim()?2:1);L=w.color.ensureContrastRatio(R||j,P||y,z),M.setColor((R||j).rgba,(P||y).rgba,L??null)}return!!L&&(this._addStyle(k,`color:${L.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,j){k.setAttribute("style",`${k.getAttribute("style")||""}${j};`)}_isCellInSelection(k,j){const y=this._selectionStart,E=this._selectionEnd;return!(!y||!E)&&(this._columnSelectMode?y[0]<=E[0]?k>=y[0]&&j>=y[1]&&k<E[0]&&j<=E[1]:k<y[0]&&j>=y[1]&&k>=E[0]&&j<=E[1]:j>y[1]&&j<E[1]||y[1]===E[1]&&j===y[1]&&k>=y[0]&&k<E[0]||y[1]<E[1]&&j===E[1]&&k<E[0]||y[1]<E[1]&&j===y[1]&&k>=y[0])}};function C(k,j,y){for(;k.length<y;)k=j+k;return k}i.DomRendererRowFactory=S=a([h(1,l.ICharacterJoinerService),h(2,_.IOptionsService),h(3,l.ICoreBrowserService),h(4,_.ICoreService),h(5,_.IDecorationService),h(6,l.IThemeService)],S)},2550:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WidthCache=void 0,i.WidthCache=class{constructor(n){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=n.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 a=n.createElement("span"),h=n.createElement("span");h.style.fontWeight="bold";const c=n.createElement("span");c.style.fontStyle="italic";const g=n.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[a,h,c,g],this._container.appendChild(a),this._container.appendChild(h),this._container.appendChild(c),this._container.appendChild(g),n.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(n,a,h,c){n===this._font&&a===this._fontSize&&h===this._weight&&c===this._weightBold||(this._font=n,this._fontSize=a,this._weight=h,this._weightBold=c,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${h}`,this._measureElements[1].style.fontWeight=`${c}`,this._measureElements[2].style.fontWeight=`${h}`,this._measureElements[3].style.fontWeight=`${c}`,this.clear())}get(n,a,h){let c=0;if(!a&&!h&&n.length===1&&(c=n.charCodeAt(0))<256)return this._flat[c]!==-9999?this._flat[c]:this._flat[c]=this._measure(n,0);let g=n;a&&(g+="B"),h&&(g+="I");let v=this._holey.get(g);if(v===void 0){let _=0;a&&(_|=1),h&&(_|=2),v=this._measure(n,_),this._holey.set(g,v)}return v}_measure(n,a){const h=this._measureElements[a];return h.textContent=n.repeat(32),h.offsetWidth/32}}},2223:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const a=n(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=a.isFirefox||a.isLegacyEdge?"bottom":"ideographic"},6171:(x,i)=>{function n(a){return 57508<=a&&a<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(a){if(!a)throw new Error("value must not be falsy");return a},i.isPowerlineGlyph=n,i.isRestrictedPowerlineGlyph=function(a){return 57520<=a&&a<=57527},i.excludeFromContrastRatioDemands=function(a){return n(a)||(function(h){return 9472<=h&&h<=9631})(a)},i.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:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionModel=void 0,i.SelectionModel=class{constructor(n){this._bufferService=n,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 n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?n%this._bufferService.cols==0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)-1]:[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[n,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){const n=this.selectionStart[0]+this.selectionStartLength;return n>this._bufferService.cols?[n%this._bufferService.cols,this.selectionStart[1]+Math.floor(n/this._bufferService.cols)]:[Math.max(n,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){const n=this.selectionStart,a=this.selectionEnd;return!(!n||!a)&&(n[1]>a[1]||n[1]===a[1]&&n[0]>a[0])}handleTrim(n){return this.selectionStart&&(this.selectionStart[1]-=n),this.selectionEnd&&(this.selectionEnd[1]-=n),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}}},428:function(x,i,n){var a=this&&this.__decorate||function(l,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,u,d,f);else for(var j=l.length-1;j>=0;j--)(S=l[j])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(l,u){return function(d,f){u(d,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const c=n(2585),g=n(8460),v=n(844);let _=i.CharSizeService=class extends v.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(l,u,d){super(),this._optionsService=d,this.width=0,this.height=0,this._onCharSizeChange=this.register(new g.EventEmitter),this.onCharSizeChange=this._onCharSizeChange.event,this._measureStrategy=new w(l,u,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const l=this._measureStrategy.measure();l.width===this.width&&l.height===this.height||(this.width=l.width,this.height=l.height,this._onCharSizeChange.fire())}};i.CharSizeService=_=a([h(2,c.IOptionsService)],_);class w{constructor(u,d,f){this._document=u,this._parentElement=d,this._optionsService=f,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 u={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return u.width!==0&&u.height!==0&&(this._result.width=u.width/32,this._result.height=Math.ceil(u.height)),this._result}}},4269:function(x,i,n){var a=this&&this.__decorate||function(u,d,f,S){var C,k=arguments.length,j=k<3?d:S===null?S=Object.getOwnPropertyDescriptor(d,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(u,d,f,S);else for(var y=u.length-1;y>=0;y--)(C=u[y])&&(j=(k<3?C(j):k>3?C(d,f,j):C(d,f))||j);return k>3&&j&&Object.defineProperty(d,f,j),j},h=this&&this.__param||function(u,d){return function(f,S){d(f,S,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const c=n(3734),g=n(643),v=n(511),_=n(2585);class w extends c.AttributeData{constructor(d,f,S){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=f,this._width=S}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(d){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.JoinedCellData=w;let l=i.CharacterJoinerService=class nc{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new v.CellData}register(d){const f={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(f),f.id}deregister(d){for(let f=0;f<this._characterJoiners.length;f++)if(this._characterJoiners[f].id===d)return this._characterJoiners.splice(f,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const f=this._bufferService.buffer.lines.get(d);if(!f||f.length===0)return[];const S=[],C=f.translateToString(!0);let k=0,j=0,y=0,E=f.getFg(0),R=f.getBg(0);for(let P=0;P<f.getTrimmedLength();P++)if(f.loadCell(P,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==E||this._workCell.bg!==R){if(P-k>1){const M=this._getJoinedRanges(C,y,j,f,k);for(let L=0;L<M.length;L++)S.push(M[L])}k=P,y=j,E=this._workCell.fg,R=this._workCell.bg}j+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const P=this._getJoinedRanges(C,y,j,f,k);for(let M=0;M<P.length;M++)S.push(P[M])}return S}_getJoinedRanges(d,f,S,C,k){const j=d.substring(f,S);let y=[];try{y=this._characterJoiners[0].handler(j)}catch(E){console.error(E)}for(let E=1;E<this._characterJoiners.length;E++)try{const R=this._characterJoiners[E].handler(j);for(let P=0;P<R.length;P++)nc._mergeRanges(y,R[P])}catch(R){console.error(R)}return this._stringRangesToCellRanges(y,C,k),y}_stringRangesToCellRanges(d,f,S){let C=0,k=!1,j=0,y=d[C];if(y){for(let E=S;E<this._bufferService.cols;E++){const R=f.getWidth(E),P=f.getString(E).length||g.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!k&&y[0]<=j&&(y[0]=E,k=!0),y[1]<=j){if(y[1]=E,y=d[++C],!y)break;y[0]<=j?(y[0]=E,k=!0):k=!1}j+=P}}y&&(y[1]=this._bufferService.cols)}}static _mergeRanges(d,f){let S=!1;for(let C=0;C<d.length;C++){const k=d[C];if(S){if(f[1]<=k[0])return d[C-1][1]=f[1],d;if(f[1]<=k[1])return d[C-1][1]=Math.max(f[1],k[1]),d.splice(C,1),d;d.splice(C,1),C--}else{if(f[1]<=k[0])return d.splice(C,0,f),d;if(f[1]<=k[1])return k[0]=Math.min(f[0],k[0]),d;f[0]<k[1]&&(k[0]=Math.min(f[0],k[0]),S=!0)}}return S?d[d.length-1][1]=f[1]:d.push(f),d}};i.CharacterJoinerService=l=a([h(0,_.IBufferService)],l)},5114:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(n,a){this._textarea=n,this.window=a,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(x,i,n){var a=this&&this.__decorate||function(_,w,l,u){var d,f=arguments.length,S=f<3?w:u===null?u=Object.getOwnPropertyDescriptor(w,l):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(_,w,l,u);else for(var C=_.length-1;C>=0;C--)(d=_[C])&&(S=(f<3?d(S):f>3?d(w,l,S):d(w,l))||S);return f>3&&S&&Object.defineProperty(w,l,S),S},h=this&&this.__param||function(_,w){return function(l,u){w(l,u,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const c=n(4725),g=n(9806);let v=i.MouseService=class{constructor(_,w){this._renderService=_,this._charSizeService=w}getCoords(_,w,l,u,d){return(0,g.getCoords)(window,_,w,l,u,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(_,w){const l=(0,g.getCoordsRelativeToElement)(window,_,w);if(this._charSizeService.hasValidSize)return l[0]=Math.min(Math.max(l[0],0),this._renderService.dimensions.css.canvas.width-1),l[1]=Math.min(Math.max(l[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(l[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(l[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(l[0]),y:Math.floor(l[1])}}};i.MouseService=v=a([h(0,c.IRenderService),h(1,c.ICharSizeService)],v)},3230:function(x,i,n){var a=this&&this.__decorate||function(S,C,k,j){var y,E=arguments.length,R=E<3?C:j===null?j=Object.getOwnPropertyDescriptor(C,k):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(S,C,k,j);else for(var P=S.length-1;P>=0;P--)(y=S[P])&&(R=(E<3?y(R):E>3?y(C,k,R):y(C,k))||R);return E>3&&R&&Object.defineProperty(C,k,R),R},h=this&&this.__param||function(S,C){return function(k,j){C(k,j,S)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const c=n(3656),g=n(6193),v=n(5596),_=n(4725),w=n(8460),l=n(844),u=n(7226),d=n(2585);let f=i.RenderService=class extends l.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(S,C,k,j,y,E,R,P){if(super(),this._rowCount=S,this._charSizeService=j,this._renderer=this.register(new l.MutableDisposable),this._pausedResizeTask=new u.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 w.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new w.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new w.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new w.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((M,L)=>this._renderRows(M,L))),this.register(this._renderDebouncer),this._screenDprMonitor=new v.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(E.onResize((()=>this._fullRefresh()))),this.register(E.buffers.onBufferActivate((()=>{var M;return(M=this._renderer.value)===null||M===void 0?void 0:M.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(y.onDecorationRegistered((()=>this._fullRefresh()))),this.register(y.onDecorationRemoved((()=>this._fullRefresh()))),this.register(k.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio"],(()=>{this.clear(),this.handleResize(E.cols,E.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(E.buffer.y,E.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(R.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(P.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in R.window){const M=new R.window.IntersectionObserver((L=>this._handleIntersectionChange(L[L.length-1])),{threshold:0});M.observe(C),this.register({dispose:()=>M.disconnect()})}}_handleIntersectionChange(S){this._isPaused=S.isIntersecting===void 0?S.intersectionRatio===0:!S.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(S,C,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(S,C,this._rowCount))}_renderRows(S,C){this._renderer.value&&(S=Math.min(S,this._rowCount-1),C=Math.min(C,this._rowCount-1),this._renderer.value.renderRows(S,C),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:S,end:C}),this._onRender.fire({start:S,end:C}),this._isNextRenderRedrawOnly=!0)}resize(S,C){this._rowCount=C,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(S){this._renderer.value=S,this._renderer.value.onRequestRedraw((C=>this.refreshRows(C.start,C.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(S){return this._renderDebouncer.addRefreshCallback(S)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var S,C;this._renderer.value&&((C=(S=this._renderer.value).clearTextureAtlas)===null||C===void 0||C.call(S),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(S,C){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(S,C))):this._renderer.value.handleResize(S,C),this._fullRefresh())}handleCharSizeChanged(){var S;(S=this._renderer.value)===null||S===void 0||S.handleCharSizeChanged()}handleBlur(){var S;(S=this._renderer.value)===null||S===void 0||S.handleBlur()}handleFocus(){var S;(S=this._renderer.value)===null||S===void 0||S.handleFocus()}handleSelectionChanged(S,C,k){var j;this._selectionState.start=S,this._selectionState.end=C,this._selectionState.columnSelectMode=k,(j=this._renderer.value)===null||j===void 0||j.handleSelectionChanged(S,C,k)}handleCursorMove(){var S;(S=this._renderer.value)===null||S===void 0||S.handleCursorMove()}clear(){var S;(S=this._renderer.value)===null||S===void 0||S.clear()}};i.RenderService=f=a([h(2,d.IOptionsService),h(3,_.ICharSizeService),h(4,d.IDecorationService),h(5,d.IBufferService),h(6,_.ICoreBrowserService),h(7,_.IThemeService)],f)},9312:function(x,i,n){var a=this&&this.__decorate||function(y,E,R,P){var M,L=arguments.length,z=L<3?E:P===null?P=Object.getOwnPropertyDescriptor(E,R):P;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(y,E,R,P);else for(var I=y.length-1;I>=0;I--)(M=y[I])&&(z=(L<3?M(z):L>3?M(E,R,z):M(E,R))||z);return L>3&&z&&Object.defineProperty(E,R,z),z},h=this&&this.__param||function(y,E){return function(R,P){E(R,P,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const c=n(9806),g=n(9504),v=n(456),_=n(4725),w=n(8460),l=n(844),u=n(6114),d=n(4841),f=n(511),S=n(2585),C=" ",k=new RegExp(C,"g");let j=i.SelectionService=class extends l.Disposable{constructor(y,E,R,P,M,L,z,I,W){super(),this._element=y,this._screenElement=E,this._linkifier=R,this._bufferService=P,this._coreService=M,this._mouseService=L,this._optionsService=z,this._renderService=I,this._coreBrowserService=W,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new f.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new w.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new w.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new w.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new w.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=$=>this._handleMouseMove($),this._mouseUpListener=$=>this._handleMouseUp($),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim(($=>this._handleTrim($))),this.register(this._bufferService.buffers.onBufferActivate(($=>this._handleBufferActivate($)))),this.enable(),this._model=new v.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,l.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 y=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;return!(!y||!E||y[0]===E[0]&&y[1]===E[1])}get selectionText(){const y=this._model.finalSelectionStart,E=this._model.finalSelectionEnd;if(!y||!E)return"";const R=this._bufferService.buffer,P=[];if(this._activeSelectionMode===3){if(y[0]===E[0])return"";const M=y[0]<E[0]?y[0]:E[0],L=y[0]<E[0]?E[0]:y[0];for(let z=y[1];z<=E[1];z++){const I=R.translateBufferLineToString(z,!0,M,L);P.push(I)}}else{const M=y[1]===E[1]?E[0]:void 0;P.push(R.translateBufferLineToString(y[1],!0,y[0],M));for(let L=y[1]+1;L<=E[1]-1;L++){const z=R.lines.get(L),I=R.translateBufferLineToString(L,!0);z?.isWrapped?P[P.length-1]+=I:P.push(I)}if(y[1]!==E[1]){const L=R.lines.get(E[1]),z=R.translateBufferLineToString(E[1],!0,0,E[0]);L&&L.isWrapped?P[P.length-1]+=z:P.push(z)}}return P.map((M=>M.replace(k," "))).join(u.isWindows?`\r
18
- `:`
19
- `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(y){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),u.isLinux&&y&&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(y){const E=this._getMouseBufferCoords(y),R=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!!(R&&P&&E)&&this._areCoordsInSelection(E,R,P)}isCellInSelection(y,E){const R=this._model.finalSelectionStart,P=this._model.finalSelectionEnd;return!(!R||!P)&&this._areCoordsInSelection([y,E],R,P)}_areCoordsInSelection(y,E,R){return y[1]>E[1]&&y[1]<R[1]||E[1]===R[1]&&y[1]===E[1]&&y[0]>=E[0]&&y[0]<R[0]||E[1]<R[1]&&y[1]===R[1]&&y[0]<R[0]||E[1]<R[1]&&y[1]===E[1]&&y[0]>=E[0]}_selectWordAtCursor(y,E){var R,P;const M=(P=(R=this._linkifier.currentLink)===null||R===void 0?void 0:R.link)===null||P===void 0?void 0:P.range;if(M)return this._model.selectionStart=[M.start.x-1,M.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(M,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const L=this._getMouseBufferCoords(y);return!!L&&(this._selectWordAt(L,E),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(y,E){this._model.clearSelection(),y=Math.max(y,0),E=Math.min(E,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,y],this._model.selectionEnd=[this._bufferService.cols,E],this.refresh(),this._onSelectionChange.fire()}_handleTrim(y){this._model.handleTrim(y)&&this.refresh()}_getMouseBufferCoords(y){const E=this._mouseService.getCoords(y,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(E)return E[0]--,E[1]--,E[1]+=this._bufferService.buffer.ydisp,E}_getMouseEventScrollAmount(y){let E=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,y,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(y){return u.isMac?y.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:y.shiftKey}handleMouseDown(y){if(this._mouseDownTimeStamp=y.timeStamp,(y.button!==2||!this.hasSelection)&&y.button===0){if(!this._enabled){if(!this.shouldForceSelection(y))return;y.stopPropagation()}y.preventDefault(),this._dragScrollAmount=0,this._enabled&&y.shiftKey?this._handleIncrementalClick(y):y.detail===1?this._handleSingleClick(y):y.detail===2?this._handleDoubleClick(y):y.detail===3&&this._handleTripleClick(y),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(y){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(y))}_handleSingleClick(y){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(y)?3:0,this._model.selectionStart=this._getMouseBufferCoords(y),!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(y){this._selectWordAtCursor(y,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(y){const E=this._getMouseBufferCoords(y);E&&(this._activeSelectionMode=2,this._selectLineAt(E[1]))}shouldColumnSelect(y){return y.altKey&&!(u.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(y){if(y.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(y),!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(y),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 P=R.lines.get(this._model.selectionEnd[1]);P&&P.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 y=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(y.ydisp+this._bufferService.rows,y.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=y.ydisp),this.refresh()}}_handleMouseUp(y){const E=y.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&E<500&&y.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(y,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const P=(0,g.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(P,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const y=this._model.finalSelectionStart,E=this._model.finalSelectionEnd,R=!(!y||!E||y[0]===E[0]&&y[1]===E[1]);R?y&&E&&(this._oldSelectionStart&&this._oldSelectionEnd&&y[0]===this._oldSelectionStart[0]&&y[1]===this._oldSelectionStart[1]&&E[0]===this._oldSelectionEnd[0]&&E[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(y,E,R)):this._oldHasSelection&&this._fireOnSelectionChange(y,E,R)}_fireOnSelectionChange(y,E,R){this._oldSelectionStart=y,this._oldSelectionEnd=E,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(y){this.clearSelection(),this._trimListener.dispose(),this._trimListener=y.activeBuffer.lines.onTrim((E=>this._handleTrim(E)))}_convertViewportColToCharacterIndex(y,E){let R=E;for(let P=0;E>=P;P++){const M=y.loadCell(P,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:M>1&&E!==P&&(R+=M-1)}return R}setSelection(y,E,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[y,E],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(y){this._isClickInSelection(y)||(this._selectWordAtCursor(y,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(y,E,R=!0,P=!0){if(y[0]>=this._bufferService.cols)return;const M=this._bufferService.buffer,L=M.lines.get(y[1]);if(!L)return;const z=M.translateBufferLineToString(y[1],!1);let I=this._convertViewportColToCharacterIndex(L,y[0]),W=I;const $=y[0]-I;let A=0,D=0,T=0,O=0;if(z.charAt(I)===" "){for(;I>0&&z.charAt(I-1)===" ";)I--;for(;W<z.length&&z.charAt(W+1)===" ";)W++}else{let B=y[0],U=y[0];L.getWidth(B)===0&&(A++,B--),L.getWidth(U)===2&&(D++,U++);const H=L.getString(U).length;for(H>1&&(O+=H-1,W+=H-1);B>0&&I>0&&!this._isCharWordSeparator(L.loadCell(B-1,this._workCell));){L.loadCell(B-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,B--):N>1&&(T+=N-1,I-=N-1),I--,B--}for(;U<L.length&&W+1<z.length&&!this._isCharWordSeparator(L.loadCell(U+1,this._workCell));){L.loadCell(U+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(D++,U++):N>1&&(O+=N-1,W+=N-1),W++,U++}}W++;let K=I+$-A+T,V=Math.min(this._bufferService.cols,W-I+A+D-T-O);if(E||z.slice(I,W).trim()!==""){if(R&&K===0&&L.getCodePoint(0)!==32){const B=M.lines.get(y[1]-1);if(B&&L.isWrapped&&B.getCodePoint(this._bufferService.cols-1)!==32){const U=this._getWordAt([this._bufferService.cols-1,y[1]-1],!1,!0,!1);if(U){const H=this._bufferService.cols-U.start;K-=H,V+=H}}}if(P&&K+V===this._bufferService.cols&&L.getCodePoint(this._bufferService.cols-1)!==32){const B=M.lines.get(y[1]+1);if(B?.isWrapped&&B.getCodePoint(0)!==32){const U=this._getWordAt([0,y[1]+1],!1,!1,!0);U&&(V+=U.length)}}return{start:K,length:V}}}_selectWordAt(y,E){const R=this._getWordAt(y,E);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,y[1]--;this._model.selectionStart=[R.start,y[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(y){const E=this._getWordAt(y,!0);if(E){let R=y[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(y){return y.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(y.getChars())>=0}_selectLineAt(y){const E=this._bufferService.buffer.getWrappedRangeForLine(y),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,d.getRangeLength)(R,this._bufferService.cols)}};i.SelectionService=j=a([h(3,S.IBufferService),h(4,S.ICoreService),h(5,_.IMouseService),h(6,S.IOptionsService),h(7,_.IRenderService),h(8,_.ICoreBrowserService)],j)},4725:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IThemeService=i.ICharacterJoinerService=i.ISelectionService=i.IRenderService=i.IMouseService=i.ICoreBrowserService=i.ICharSizeService=void 0;const a=n(8343);i.ICharSizeService=(0,a.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,a.createDecorator)("CoreBrowserService"),i.IMouseService=(0,a.createDecorator)("MouseService"),i.IRenderService=(0,a.createDecorator)("RenderService"),i.ISelectionService=(0,a.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,a.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,a.createDecorator)("ThemeService")},6731:function(x,i,n){var a=this&&this.__decorate||function(j,y,E,R){var P,M=arguments.length,L=M<3?y:R===null?R=Object.getOwnPropertyDescriptor(y,E):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")L=Reflect.decorate(j,y,E,R);else for(var z=j.length-1;z>=0;z--)(P=j[z])&&(L=(M<3?P(L):M>3?P(y,E,L):P(y,E))||L);return M>3&&L&&Object.defineProperty(y,E,L),L},h=this&&this.__param||function(j,y){return function(E,R){y(E,R,j)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const c=n(7239),g=n(8055),v=n(8460),_=n(844),w=n(2585),l=g.css.toColor("#ffffff"),u=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),f=g.css.toColor("#000000"),S={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117};i.DEFAULT_ANSI_COLORS=Object.freeze((()=>{const j=[g.css.toColor("#2e3436"),g.css.toColor("#cc0000"),g.css.toColor("#4e9a06"),g.css.toColor("#c4a000"),g.css.toColor("#3465a4"),g.css.toColor("#75507b"),g.css.toColor("#06989a"),g.css.toColor("#d3d7cf"),g.css.toColor("#555753"),g.css.toColor("#ef2929"),g.css.toColor("#8ae234"),g.css.toColor("#fce94f"),g.css.toColor("#729fcf"),g.css.toColor("#ad7fa8"),g.css.toColor("#34e2e2"),g.css.toColor("#eeeeec")],y=[0,95,135,175,215,255];for(let E=0;E<216;E++){const R=y[E/36%6|0],P=y[E/6%6|0],M=y[E%6];j.push({css:g.channels.toCss(R,P,M),rgba:g.channels.toRgba(R,P,M)})}for(let E=0;E<24;E++){const R=8+10*E;j.push({css:g.channels.toCss(R,R,R),rgba:g.channels.toRgba(R,R,R)})}return j})());let C=i.ThemeService=class extends _.Disposable{get colors(){return this._colors}constructor(j){super(),this._optionsService=j,this._contrastCache=new c.ColorContrastCache,this._halfContrastCache=new c.ColorContrastCache,this._onChangeColors=this.register(new v.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:l,background:u,cursor:d,cursorAccent:f,selectionForeground:void 0,selectionBackgroundTransparent:S,selectionBackgroundOpaque:g.color.blend(u,S),selectionInactiveBackgroundTransparent:S,selectionInactiveBackgroundOpaque:g.color.blend(u,S),ansi:i.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(j={}){const y=this._colors;if(y.foreground=k(j.foreground,l),y.background=k(j.background,u),y.cursor=k(j.cursor,d),y.cursorAccent=k(j.cursorAccent,f),y.selectionBackgroundTransparent=k(j.selectionBackground,S),y.selectionBackgroundOpaque=g.color.blend(y.background,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundTransparent=k(j.selectionInactiveBackground,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundOpaque=g.color.blend(y.background,y.selectionInactiveBackgroundTransparent),y.selectionForeground=j.selectionForeground?k(j.selectionForeground,g.NULL_COLOR):void 0,y.selectionForeground===g.NULL_COLOR&&(y.selectionForeground=void 0),g.color.isOpaque(y.selectionBackgroundTransparent)&&(y.selectionBackgroundTransparent=g.color.opacity(y.selectionBackgroundTransparent,.3)),g.color.isOpaque(y.selectionInactiveBackgroundTransparent)&&(y.selectionInactiveBackgroundTransparent=g.color.opacity(y.selectionInactiveBackgroundTransparent,.3)),y.ansi=i.DEFAULT_ANSI_COLORS.slice(),y.ansi[0]=k(j.black,i.DEFAULT_ANSI_COLORS[0]),y.ansi[1]=k(j.red,i.DEFAULT_ANSI_COLORS[1]),y.ansi[2]=k(j.green,i.DEFAULT_ANSI_COLORS[2]),y.ansi[3]=k(j.yellow,i.DEFAULT_ANSI_COLORS[3]),y.ansi[4]=k(j.blue,i.DEFAULT_ANSI_COLORS[4]),y.ansi[5]=k(j.magenta,i.DEFAULT_ANSI_COLORS[5]),y.ansi[6]=k(j.cyan,i.DEFAULT_ANSI_COLORS[6]),y.ansi[7]=k(j.white,i.DEFAULT_ANSI_COLORS[7]),y.ansi[8]=k(j.brightBlack,i.DEFAULT_ANSI_COLORS[8]),y.ansi[9]=k(j.brightRed,i.DEFAULT_ANSI_COLORS[9]),y.ansi[10]=k(j.brightGreen,i.DEFAULT_ANSI_COLORS[10]),y.ansi[11]=k(j.brightYellow,i.DEFAULT_ANSI_COLORS[11]),y.ansi[12]=k(j.brightBlue,i.DEFAULT_ANSI_COLORS[12]),y.ansi[13]=k(j.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),y.ansi[14]=k(j.brightCyan,i.DEFAULT_ANSI_COLORS[14]),y.ansi[15]=k(j.brightWhite,i.DEFAULT_ANSI_COLORS[15]),j.extendedAnsi){const E=Math.min(y.ansi.length-16,j.extendedAnsi.length);for(let R=0;R<E;R++)y.ansi[R+16]=k(j.extendedAnsi[R],i.DEFAULT_ANSI_COLORS[R+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(j){this._restoreColor(j),this._onChangeColors.fire(this.colors)}_restoreColor(j){if(j!==void 0)switch(j){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[j]=this._restoreColors.ansi[j]}else for(let y=0;y<this._restoreColors.ansi.length;++y)this._colors.ansi[y]=this._restoreColors.ansi[y]}modifyColors(j){j(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 k(j,y){if(j!==void 0)try{return g.css.toColor(j)}catch{}return y}i.ThemeService=C=a([h(0,w.IOptionsService)],C)},6349:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const a=n(8460),h=n(844);class c extends h.Disposable{constructor(v){super(),this._maxLength=v,this.onDeleteEmitter=this.register(new a.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new a.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new a.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(v){if(this._maxLength===v)return;const _=new Array(v);for(let w=0;w<Math.min(v,this.length);w++)_[w]=this._array[this._getCyclicIndex(w)];this._array=_,this._maxLength=v,this._startIndex=0}get length(){return this._length}set length(v){if(v>this._length)for(let _=this._length;_<v;_++)this._array[_]=void 0;this._length=v}get(v){return this._array[this._getCyclicIndex(v)]}set(v,_){this._array[this._getCyclicIndex(v)]=_}push(v){this._array[this._getCyclicIndex(this._length)]=v,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(v,_,...w){if(_){for(let l=v;l<this._length-_;l++)this._array[this._getCyclicIndex(l)]=this._array[this._getCyclicIndex(l+_)];this._length-=_,this.onDeleteEmitter.fire({index:v,amount:_})}for(let l=this._length-1;l>=v;l--)this._array[this._getCyclicIndex(l+w.length)]=this._array[this._getCyclicIndex(l)];for(let l=0;l<w.length;l++)this._array[this._getCyclicIndex(v+l)]=w[l];if(w.length&&this.onInsertEmitter.fire({index:v,amount:w.length}),this._length+w.length>this._maxLength){const l=this._length+w.length-this._maxLength;this._startIndex+=l,this._length=this._maxLength,this.onTrimEmitter.fire(l)}else this._length+=w.length}trimStart(v){v>this._length&&(v=this._length),this._startIndex+=v,this._length-=v,this.onTrimEmitter.fire(v)}shiftElements(v,_,w){if(!(_<=0)){if(v<0||v>=this._length)throw new Error("start argument out of range");if(v+w<0)throw new Error("Cannot shift elements in list beyond index 0");if(w>0){for(let u=_-1;u>=0;u--)this.set(v+u+w,this.get(v+u));const l=v+_+w-this._length;if(l>0)for(this._length+=l;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let l=0;l<_;l++)this.set(v+l+w,this.get(v+l))}}_getCyclicIndex(v){return(this._startIndex+v)%this._maxLength}}i.CircularList=c},1439:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function n(a,h=5){if(typeof a!="object")return a;const c=Array.isArray(a)?[]:{};for(const g in a)c[g]=h<=1?a[g]:a[g]&&n(a[g],h-1);return c}},8055:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.contrastRatio=i.toPaddedHex=i.rgba=i.rgb=i.css=i.color=i.channels=i.NULL_COLOR=void 0;const a=n(6114);let h=0,c=0,g=0,v=0;var _,w,l,u,d;function f(C){const k=C.toString(16);return k.length<2?"0"+k:k}function S(C,k){return C<k?(k+.05)/(C+.05):(C+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(C){C.toCss=function(k,j,y,E){return E!==void 0?`#${f(k)}${f(j)}${f(y)}${f(E)}`:`#${f(k)}${f(j)}${f(y)}`},C.toRgba=function(k,j,y,E=255){return(k<<24|j<<16|y<<8|E)>>>0}})(_||(i.channels=_={})),(function(C){function k(j,y){return v=Math.round(255*y),[h,c,g]=d.toChannels(j.rgba),{css:_.toCss(h,c,g,v),rgba:_.toRgba(h,c,g,v)}}C.blend=function(j,y){if(v=(255&y.rgba)/255,v===1)return{css:y.css,rgba:y.rgba};const E=y.rgba>>24&255,R=y.rgba>>16&255,P=y.rgba>>8&255,M=j.rgba>>24&255,L=j.rgba>>16&255,z=j.rgba>>8&255;return h=M+Math.round((E-M)*v),c=L+Math.round((R-L)*v),g=z+Math.round((P-z)*v),{css:_.toCss(h,c,g),rgba:_.toRgba(h,c,g)}},C.isOpaque=function(j){return(255&j.rgba)==255},C.ensureContrastRatio=function(j,y,E){const R=d.ensureContrastRatio(j.rgba,y.rgba,E);if(R)return d.toColor(R>>24&255,R>>16&255,R>>8&255)},C.opaque=function(j){const y=(255|j.rgba)>>>0;return[h,c,g]=d.toChannels(y),{css:_.toCss(h,c,g),rgba:y}},C.opacity=k,C.multiplyOpacity=function(j,y){return v=255&j.rgba,k(j,v*y/255)},C.toColorRGB=function(j){return[j.rgba>>24&255,j.rgba>>16&255,j.rgba>>8&255]}})(w||(i.color=w={})),(function(C){let k,j;if(!a.isNode){const y=document.createElement("canvas");y.width=1,y.height=1;const E=y.getContext("2d",{willReadFrequently:!0});E&&(k=E,k.globalCompositeOperation="copy",j=k.createLinearGradient(0,0,1,1))}C.toColor=function(y){if(y.match(/#[\da-f]{3,8}/i))switch(y.length){case 4:return h=parseInt(y.slice(1,2).repeat(2),16),c=parseInt(y.slice(2,3).repeat(2),16),g=parseInt(y.slice(3,4).repeat(2),16),d.toColor(h,c,g);case 5:return h=parseInt(y.slice(1,2).repeat(2),16),c=parseInt(y.slice(2,3).repeat(2),16),g=parseInt(y.slice(3,4).repeat(2),16),v=parseInt(y.slice(4,5).repeat(2),16),d.toColor(h,c,g,v);case 7:return{css:y,rgba:(parseInt(y.slice(1),16)<<8|255)>>>0};case 9:return{css:y,rgba:parseInt(y.slice(1),16)>>>0}}const E=y.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 h=parseInt(E[1]),c=parseInt(E[2]),g=parseInt(E[3]),v=Math.round(255*(E[5]===void 0?1:parseFloat(E[5]))),d.toColor(h,c,g,v);if(!k||!j)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=j,k.fillStyle=y,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[h,c,g,v]=k.getImageData(0,0,1,1).data,v!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:_.toRgba(h,c,g,v),css:y}}})(l||(i.css=l={})),(function(C){function k(j,y,E){const R=j/255,P=y/255,M=E/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(P<=.03928?P/12.92:Math.pow((P+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}C.relativeLuminance=function(j){return k(j>>16&255,j>>8&255,255&j)},C.relativeLuminance2=k})(u||(i.rgb=u={})),(function(C){function k(y,E,R){const P=y>>24&255,M=y>>16&255,L=y>>8&255;let z=E>>24&255,I=E>>16&255,W=E>>8&255,$=S(u.relativeLuminance2(z,I,W),u.relativeLuminance2(P,M,L));for(;$<R&&(z>0||I>0||W>0);)z-=Math.max(0,Math.ceil(.1*z)),I-=Math.max(0,Math.ceil(.1*I)),W-=Math.max(0,Math.ceil(.1*W)),$=S(u.relativeLuminance2(z,I,W),u.relativeLuminance2(P,M,L));return(z<<24|I<<16|W<<8|255)>>>0}function j(y,E,R){const P=y>>24&255,M=y>>16&255,L=y>>8&255;let z=E>>24&255,I=E>>16&255,W=E>>8&255,$=S(u.relativeLuminance2(z,I,W),u.relativeLuminance2(P,M,L));for(;$<R&&(z<255||I<255||W<255);)z=Math.min(255,z+Math.ceil(.1*(255-z))),I=Math.min(255,I+Math.ceil(.1*(255-I))),W=Math.min(255,W+Math.ceil(.1*(255-W))),$=S(u.relativeLuminance2(z,I,W),u.relativeLuminance2(P,M,L));return(z<<24|I<<16|W<<8|255)>>>0}C.ensureContrastRatio=function(y,E,R){const P=u.relativeLuminance(y>>8),M=u.relativeLuminance(E>>8);if(S(P,M)<R){if(M<P){const I=k(y,E,R),W=S(P,u.relativeLuminance(I>>8));if(W<R){const $=j(y,E,R);return W>S(P,u.relativeLuminance($>>8))?I:$}return I}const L=j(y,E,R),z=S(P,u.relativeLuminance(L>>8));if(z<R){const I=k(y,E,R);return z>S(P,u.relativeLuminance(I>>8))?L:I}return L}},C.reduceLuminance=k,C.increaseLuminance=j,C.toChannels=function(y){return[y>>24&255,y>>16&255,y>>8&255,255&y]},C.toColor=function(y,E,R,P){return{css:_.toCss(y,E,R,P),rgba:_.toRgba(y,E,R,P)}}})(d||(i.rgba=d={})),i.toPaddedHex=f,i.contrastRatio=S},8969:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const a=n(844),h=n(2585),c=n(4348),g=n(7866),v=n(744),_=n(7302),w=n(6975),l=n(8460),u=n(1753),d=n(1480),f=n(7994),S=n(9282),C=n(5435),k=n(5981),j=n(2660);let y=!1;class E extends a.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new l.EventEmitter),this._onScroll.event((P=>{var M;(M=this._onScrollApi)===null||M===void 0||M.fire(P.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(P){for(const M in P)this.optionsService.options[M]=P[M]}constructor(P){super(),this._windowsWrappingHeuristics=this.register(new a.MutableDisposable),this._onBinary=this.register(new l.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new l.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new l.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new l.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new l.EventEmitter),this._instantiationService=new c.InstantiationService,this.optionsService=this.register(new _.OptionsService(P)),this._instantiationService.setService(h.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(v.BufferService)),this._instantiationService.setService(h.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(h.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(w.CoreService)),this._instantiationService.setService(h.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(u.CoreMouseService)),this._instantiationService.setService(h.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(h.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(f.CharsetService),this._instantiationService.setService(h.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(j.OscLinkService),this._instantiationService.setService(h.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new C.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,l.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,l.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,l.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,l.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((M=>{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((M=>{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 k.WriteBuffer(((M,L)=>this._inputHandler.parse(M,L)))),this.register((0,l.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(P,M){this._writeBuffer.write(P,M)}writeSync(P,M){this._logService.logLevel<=h.LogLevelEnum.WARN&&!y&&(this._logService.warn("writeSync is unreliable and will be removed soon."),y=!0),this._writeBuffer.writeSync(P,M)}resize(P,M){isNaN(P)||isNaN(M)||(P=Math.max(P,v.MINIMUM_COLS),M=Math.max(M,v.MINIMUM_ROWS),this._bufferService.resize(P,M))}scroll(P,M=!1){this._bufferService.scroll(P,M)}scrollLines(P,M,L){this._bufferService.scrollLines(P,M,L)}scrollPages(P){this.scrollLines(P*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(P){const M=P-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(P,M){return this._inputHandler.registerEscHandler(P,M)}registerDcsHandler(P,M){return this._inputHandler.registerDcsHandler(P,M)}registerCsiHandler(P,M){return this._inputHandler.registerCsiHandler(P,M)}registerOscHandler(P,M){return this._inputHandler.registerOscHandler(P,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let P=!1;const M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?P=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(P=!0),P?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const P=[];P.push(this.onLineFeed(S.updateWindowsModeWrappedState.bind(null,this._bufferService))),P.push(this.registerCsiHandler({final:"H"},(()=>((0,S.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,a.toDisposable)((()=>{for(const M of P)M.dispose()}))}}}i.CoreTerminal=E},8460:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.forwardEvent=i.EventEmitter=void 0,i.EventEmitter=class{constructor(){this._listeners=[],this._disposed=!1}get event(){return this._event||(this._event=n=>(this._listeners.push(n),{dispose:()=>{if(!this._disposed){for(let a=0;a<this._listeners.length;a++)if(this._listeners[a]===n)return void this._listeners.splice(a,1)}}})),this._event}fire(n,a){const h=[];for(let c=0;c<this._listeners.length;c++)h.push(this._listeners[c]);for(let c=0;c<h.length;c++)h[c].call(void 0,n,a)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(n,a){return n((h=>a.fire(h)))}},5435:function(x,i,n){var a=this&&this.__decorate||function($,A,D,T){var O,K=arguments.length,V=K<3?A:T===null?T=Object.getOwnPropertyDescriptor(A,D):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")V=Reflect.decorate($,A,D,T);else for(var B=$.length-1;B>=0;B--)(O=$[B])&&(V=(K<3?O(V):K>3?O(A,D,V):O(A,D))||V);return K>3&&V&&Object.defineProperty(A,D,V),V},h=this&&this.__param||function($,A){return function(D,T){A(D,T,$)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const c=n(2584),g=n(7116),v=n(2015),_=n(844),w=n(482),l=n(8437),u=n(8460),d=n(643),f=n(511),S=n(3734),C=n(2585),k=n(6242),j=n(6351),y=n(5941),E={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function P($,A){if($>24)return A.setWinLines||!1;switch($){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var M;(function($){$[$.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",$[$.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(M||(i.WindowsOptionsReportType=M={}));let L=0;class z extends _.Disposable{getAttrData(){return this._curAttrData}constructor(A,D,T,O,K,V,B,U,H=new v.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=D,this._coreService=T,this._logService=O,this._optionsService=K,this._oscLinkService=V,this._coreMouseService=B,this._unicodeService=U,this._parser=H,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new w.StringToUtf32,this._utf8Decoder=new w.Utf8ToUtf32,this._workCell=new f.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=l.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new u.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new u.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new u.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new u.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new u.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new u.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new u.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new u.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new u.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new u.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new u.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new u.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new u.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 I(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((N=>this._activeBuffer=N.activeBuffer))),this._parser.setCsiHandlerFallback(((N,F)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(N),params:F.toArray()})})),this._parser.setEscHandlerFallback((N=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(N)})})),this._parser.setExecuteHandlerFallback((N=>{this._logService.debug("Unknown EXECUTE code: ",{code:N})})),this._parser.setOscHandlerFallback(((N,F,q)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:F,data:q})})),this._parser.setDcsHandlerFallback(((N,F,q)=>{F==="HOOK"&&(q=q.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:F,payload:q})})),this._parser.setPrintHandler(((N,F,q)=>this.print(N,F,q))),this._parser.registerCsiHandler({final:"@"},(N=>this.insertChars(N))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(N=>this.scrollLeft(N))),this._parser.registerCsiHandler({final:"A"},(N=>this.cursorUp(N))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(N=>this.scrollRight(N))),this._parser.registerCsiHandler({final:"B"},(N=>this.cursorDown(N))),this._parser.registerCsiHandler({final:"C"},(N=>this.cursorForward(N))),this._parser.registerCsiHandler({final:"D"},(N=>this.cursorBackward(N))),this._parser.registerCsiHandler({final:"E"},(N=>this.cursorNextLine(N))),this._parser.registerCsiHandler({final:"F"},(N=>this.cursorPrecedingLine(N))),this._parser.registerCsiHandler({final:"G"},(N=>this.cursorCharAbsolute(N))),this._parser.registerCsiHandler({final:"H"},(N=>this.cursorPosition(N))),this._parser.registerCsiHandler({final:"I"},(N=>this.cursorForwardTab(N))),this._parser.registerCsiHandler({final:"J"},(N=>this.eraseInDisplay(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(N=>this.eraseInDisplay(N,!0))),this._parser.registerCsiHandler({final:"K"},(N=>this.eraseInLine(N,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(N=>this.eraseInLine(N,!0))),this._parser.registerCsiHandler({final:"L"},(N=>this.insertLines(N))),this._parser.registerCsiHandler({final:"M"},(N=>this.deleteLines(N))),this._parser.registerCsiHandler({final:"P"},(N=>this.deleteChars(N))),this._parser.registerCsiHandler({final:"S"},(N=>this.scrollUp(N))),this._parser.registerCsiHandler({final:"T"},(N=>this.scrollDown(N))),this._parser.registerCsiHandler({final:"X"},(N=>this.eraseChars(N))),this._parser.registerCsiHandler({final:"Z"},(N=>this.cursorBackwardTab(N))),this._parser.registerCsiHandler({final:"`"},(N=>this.charPosAbsolute(N))),this._parser.registerCsiHandler({final:"a"},(N=>this.hPositionRelative(N))),this._parser.registerCsiHandler({final:"b"},(N=>this.repeatPrecedingCharacter(N))),this._parser.registerCsiHandler({final:"c"},(N=>this.sendDeviceAttributesPrimary(N))),this._parser.registerCsiHandler({prefix:">",final:"c"},(N=>this.sendDeviceAttributesSecondary(N))),this._parser.registerCsiHandler({final:"d"},(N=>this.linePosAbsolute(N))),this._parser.registerCsiHandler({final:"e"},(N=>this.vPositionRelative(N))),this._parser.registerCsiHandler({final:"f"},(N=>this.hVPosition(N))),this._parser.registerCsiHandler({final:"g"},(N=>this.tabClear(N))),this._parser.registerCsiHandler({final:"h"},(N=>this.setMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(N=>this.setModePrivate(N))),this._parser.registerCsiHandler({final:"l"},(N=>this.resetMode(N))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(N=>this.resetModePrivate(N))),this._parser.registerCsiHandler({final:"m"},(N=>this.charAttributes(N))),this._parser.registerCsiHandler({final:"n"},(N=>this.deviceStatus(N))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(N=>this.deviceStatusPrivate(N))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(N=>this.softReset(N))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(N=>this.setCursorStyle(N))),this._parser.registerCsiHandler({final:"r"},(N=>this.setScrollRegion(N))),this._parser.registerCsiHandler({final:"s"},(N=>this.saveCursor(N))),this._parser.registerCsiHandler({final:"t"},(N=>this.windowOptions(N))),this._parser.registerCsiHandler({final:"u"},(N=>this.restoreCursor(N))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(N=>this.insertColumns(N))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(N=>this.deleteColumns(N))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(N=>this.selectProtected(N))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(N=>this.requestMode(N,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(N=>this.requestMode(N,!1))),this._parser.setExecuteHandler(c.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(c.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(c.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(c.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(c.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(c.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(c.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(c.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(c.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(c.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((N=>(this.setTitle(N),this.setIconName(N),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((N=>this.setIconName(N)))),this._parser.registerOscHandler(2,new k.OscHandler((N=>this.setTitle(N)))),this._parser.registerOscHandler(4,new k.OscHandler((N=>this.setOrReportIndexedColor(N)))),this._parser.registerOscHandler(8,new k.OscHandler((N=>this.setHyperlink(N)))),this._parser.registerOscHandler(10,new k.OscHandler((N=>this.setOrReportFgColor(N)))),this._parser.registerOscHandler(11,new k.OscHandler((N=>this.setOrReportBgColor(N)))),this._parser.registerOscHandler(12,new k.OscHandler((N=>this.setOrReportCursorColor(N)))),this._parser.registerOscHandler(104,new k.OscHandler((N=>this.restoreIndexedColor(N)))),this._parser.registerOscHandler(110,new k.OscHandler((N=>this.restoreFgColor(N)))),this._parser.registerOscHandler(111,new k.OscHandler((N=>this.restoreBgColor(N)))),this._parser.registerOscHandler(112,new k.OscHandler((N=>this.restoreCursorColor(N)))),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 N in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:N},(()=>this.selectCharset("("+N))),this._parser.registerEscHandler({intermediates:")",final:N},(()=>this.selectCharset(")"+N))),this._parser.registerEscHandler({intermediates:"*",final:N},(()=>this.selectCharset("*"+N))),this._parser.registerEscHandler({intermediates:"+",final:N},(()=>this.selectCharset("+"+N))),this._parser.registerEscHandler({intermediates:"-",final:N},(()=>this.selectCharset("-"+N))),this._parser.registerEscHandler({intermediates:".",final:N},(()=>this.selectCharset("."+N))),this._parser.registerEscHandler({intermediates:"/",final:N},(()=>this.selectCharset("/"+N)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((N=>(this._logService.error("Parsing error: ",N),N))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new j.DcsHandler(((N,F)=>this.requestStatusString(N,F))))}_preserveStack(A,D,T,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=D,this._parseStack.decodedLength=T,this._parseStack.position=O}_logSlowResolvingAsync(A){this._logService.logLevel<=C.LogLevelEnum.WARN&&Promise.race([A,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(A,D){let T,O=this._activeBuffer.x,K=this._activeBuffer.y,V=0;const B=this._parseStack.paused;if(B){if(T=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,D))return this._logSlowResolvingAsync(T),T;O=this._parseStack.cursorStartX,K=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>R&&(V=this._parseStack.position+R)}if(this._logService.logLevel<=C.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(U=>String.fromCharCode(U))).join("")}"`),typeof A=="string"?A.split("").map((U=>U.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(A.length,R))),B||this._dirtyRowTracker.clearRange(),A.length>R)for(let U=V;U<A.length;U+=R){const H=U+R<A.length?U+R:A.length,N=typeof A=="string"?this._stringDecoder.decode(A.substring(U,H),this._parseBuffer):this._utf8Decoder.decode(A.subarray(U,H),this._parseBuffer);if(T=this._parser.parse(this._parseBuffer,N))return this._preserveStack(O,K,N,U),this._logSlowResolvingAsync(T),T}else if(!B){const U=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(T=this._parser.parse(this._parseBuffer,U))return this._preserveStack(O,K,U,0),this._logSlowResolvingAsync(T),T}this._activeBuffer.x===O&&this._activeBuffer.y===K||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,D,T){let O,K;const V=this._charsetService.charset,B=this._optionsService.rawOptions.screenReaderMode,U=this._bufferService.cols,H=this._coreService.decPrivateModes.wraparound,N=this._coreService.modes.insertMode,F=this._curAttrData;let q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&T-D>0&&q.getWidth(this._activeBuffer.x-1)===2&&q.setCellFromCodePoint(this._activeBuffer.x-1,0,1,F.fg,F.bg,F.extended);for(let Y=D;Y<T;++Y){if(O=A[Y],K=this._unicodeService.wcwidth(O),O<127&&V){const se=V[String.fromCharCode(O)];se&&(O=se.charCodeAt(0))}if(B&&this._onA11yChar.fire((0,w.stringFromCodePoint)(O)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),K||!this._activeBuffer.x){if(this._activeBuffer.x+K-1>=U){if(H){for(;this._activeBuffer.x<U;)q.setCellFromCodePoint(this._activeBuffer.x++,0,1,F.fg,F.bg,F.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),q=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=U-1,K===2)continue}if(N&&(q.insertCells(this._activeBuffer.x,K,this._activeBuffer.getNullCell(F),F),q.getWidth(U-1)===2&&q.setCellFromCodePoint(U-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,F.fg,F.bg,F.extended)),q.setCellFromCodePoint(this._activeBuffer.x++,O,K,F.fg,F.bg,F.extended),K>0)for(;--K;)q.setCellFromCodePoint(this._activeBuffer.x++,0,0,F.fg,F.bg,F.extended)}else q.getWidth(this._activeBuffer.x-1)?q.addCodepointToCell(this._activeBuffer.x-1,O):q.addCodepointToCell(this._activeBuffer.x-2,O)}T-D>0&&(q.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<U&&T-D>0&&q.getWidth(this._activeBuffer.x)===0&&!q.hasContent(this._activeBuffer.x)&&q.setCellFromCodePoint(this._activeBuffer.x,0,1,F.fg,F.bg,F.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,D){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,D):this._parser.registerCsiHandler(A,(T=>!P(T.params[0],this._optionsService.rawOptions.windowOptions)||D(T)))}registerDcsHandler(A,D){return this._parser.registerDcsHandler(A,new j.DcsHandler(D))}registerEscHandler(A,D){return this._parser.registerEscHandler(A,D)}registerOscHandler(A,D){return this._parser.registerOscHandler(A,new k.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 A;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&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.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 A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,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(A,D){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+D):(this._activeBuffer.x=A,this._activeBuffer.y=D),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,D){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+D)}cursorUp(A){const D=this._activeBuffer.y-this._activeBuffer.scrollTop;return D>=0?this._moveCursor(0,-Math.min(D,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const D=this._activeBuffer.scrollBottom-this._activeBuffer.y;return D>=0?this._moveCursor(0,Math.min(D,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const D=A.params[0];return D===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:D===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let D=A.params[0]||1;for(;D--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let D=A.params[0]||1;for(;D--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const D=A.params[0];return D===1&&(this._curAttrData.bg|=536870912),D!==2&&D!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,D,T,O=!1,K=!1){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);V.replaceCells(D,T,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),K),O&&(V.isWrapped=!1)}_resetBufferLine(A,D=!1){const T=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);T&&(T.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),D),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),T.isWrapped=!1)}eraseInDisplay(A,D=!1){let T;switch(this._restrictCursor(this._bufferService.cols),A.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 O=this._activeBuffer.lines.length-this._bufferService.rows;O>0&&(this._activeBuffer.lines.trimStart(O),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-O,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-O,0),this._onScroll.fire(0))}return!0}eraseInLine(A,D=!1){switch(this._restrictCursor(this._bufferService.cols),A.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(A){this._restrictCursor();let D=A.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,O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,K=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;D--;)this._activeBuffer.lines.splice(K-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(A){this._restrictCursor();let D=A.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 O;for(O=this._bufferService.rows-1-this._activeBuffer.scrollBottom,O=this._bufferService.rows-1+this._activeBuffer.ybase-O;D--;)this._activeBuffer.lines.splice(T,1),this._activeBuffer.lines.splice(O,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let D=A.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(A){let D=A.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(l.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);O.deleteCells(0,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);O.insertCells(0,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);O.insertCells(this._activeBuffer.x,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const D=A.params[0]||1;for(let T=this._activeBuffer.scrollTop;T<=this._activeBuffer.scrollBottom;++T){const O=this._activeBuffer.lines.get(this._activeBuffer.ybase+T);O.deleteCells(this._activeBuffer.x,D,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const D=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return D&&(D.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const D=A.params[0]||1,T=new Uint32Array(D);for(let O=0;O<D;++O)T[O]=this._parser.precedingCodepoint;return this.print(T,0,T.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(c.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(c.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(c.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(c.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let D=0;D<A.length;D++)switch(A.params[D]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let D=0;D<A.length;D++)switch(A.params[D]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.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(A){for(let D=0;D<A.length;D++)switch(A.params[D]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let D=0;D<A.length;D++)switch(A.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(),A.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(A,D){const T=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:K}=this._coreMouseService,V=this._coreService,{buffers:B,cols:U}=this._bufferService,{active:H,alt:N}=B,F=this._optionsService.rawOptions,q=pe=>pe?1:2,Y=A.params[0];return se=Y,G=D?Y===2?4:Y===4?q(V.modes.insertMode):Y===12?3:Y===20?q(F.convertEol):0:Y===1?q(T.applicationCursorKeys):Y===3?F.windowOptions.setWinLines?U===80?2:U===132?1:0:0:Y===6?q(T.origin):Y===7?q(T.wraparound):Y===8?3:Y===9?q(O==="X10"):Y===12?q(F.cursorBlink):Y===25?q(!V.isCursorHidden):Y===45?q(T.reverseWraparound):Y===66?q(T.applicationKeypad):Y===67?4:Y===1e3?q(O==="VT200"):Y===1002?q(O==="DRAG"):Y===1003?q(O==="ANY"):Y===1004?q(T.sendFocus):Y===1005?4:Y===1006?q(K==="SGR"):Y===1015?4:Y===1016?q(K==="SGR_PIXELS"):Y===1048?1:Y===47||Y===1047||Y===1049?q(H===N):Y===2004?q(T.bracketedPasteMode):0,V.triggerDataEvent(`${c.C0.ESC}[${D?"":"?"}${se};${G}$y`),!0;var se,G}_updateAttrColor(A,D,T,O,K){return D===2?(A|=50331648,A&=-16777216,A|=S.AttributeData.fromColorRGB([T,O,K])):D===5&&(A&=-50331904,A|=33554432|255&T),A}_extractColor(A,D,T){const O=[0,0,-1,0,0,0];let K=0,V=0;do{if(O[V+K]=A.params[D+V],A.hasSubParams(D+V)){const B=A.getSubParams(D+V);let U=0;do O[1]===5&&(K=1),O[V+U+1+K]=B[U];while(++U<B.length&&U+V+1+K<O.length);break}if(O[1]===5&&V+K>=2||O[1]===2&&V+K>=5)break;O[1]&&(K=1)}while(++V+D<A.length&&V+K<O.length);for(let B=2;B<O.length;++B)O[B]===-1&&(O[B]=0);switch(O[0]){case 38:T.fg=this._updateAttrColor(T.fg,O[1],O[3],O[4],O[5]);break;case 48:T.bg=this._updateAttrColor(T.bg,O[1],O[3],O[4],O[5]);break;case 58:T.extended=T.extended.clone(),T.extended.underlineColor=this._updateAttrColor(T.extended.underlineColor,O[1],O[3],O[4],O[5])}return V}_processUnderline(A,D){D.extended=D.extended.clone(),(!~A||A>5)&&(A=1),D.extended.underlineStyle=A,D.fg|=268435456,A===0&&(D.fg&=-268435457),D.updateExtended()}_processSGR0(A){A.fg=l.DEFAULT_ATTR_DATA.fg,A.bg=l.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const D=A.length;let T;const O=this._curAttrData;for(let K=0;K<D;K++)T=A.params[K],T>=30&&T<=37?(O.fg&=-50331904,O.fg|=16777216|T-30):T>=40&&T<=47?(O.bg&=-50331904,O.bg|=16777216|T-40):T>=90&&T<=97?(O.fg&=-50331904,O.fg|=16777224|T-90):T>=100&&T<=107?(O.bg&=-50331904,O.bg|=16777224|T-100):T===0?this._processSGR0(O):T===1?O.fg|=134217728:T===3?O.bg|=67108864:T===4?(O.fg|=268435456,this._processUnderline(A.hasSubParams(K)?A.getSubParams(K)[0]:1,O)):T===5?O.fg|=536870912:T===7?O.fg|=67108864:T===8?O.fg|=1073741824:T===9?O.fg|=2147483648:T===2?O.bg|=134217728:T===21?this._processUnderline(2,O):T===22?(O.fg&=-134217729,O.bg&=-134217729):T===23?O.bg&=-67108865:T===24?(O.fg&=-268435457,this._processUnderline(0,O)):T===25?O.fg&=-536870913:T===27?O.fg&=-67108865:T===28?O.fg&=-1073741825:T===29?O.fg&=2147483647:T===39?(O.fg&=-67108864,O.fg|=16777215&l.DEFAULT_ATTR_DATA.fg):T===49?(O.bg&=-67108864,O.bg|=16777215&l.DEFAULT_ATTR_DATA.bg):T===38||T===48||T===58?K+=this._extractColor(A,K,O):T===53?O.bg|=1073741824:T===55?O.bg&=-1073741825:T===59?(O.extended=O.extended.clone(),O.extended.underlineColor=-1,O.updateExtended()):T===100?(O.fg&=-67108864,O.fg|=16777215&l.DEFAULT_ATTR_DATA.fg,O.bg&=-67108864,O.bg|=16777215&l.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",T);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const D=this._activeBuffer.y+1,T=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${D};${T}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const D=this._activeBuffer.y+1,T=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${D};${T}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=l.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(A){const D=A.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(A){const D=A.params[0]||1;let T;return(A.length<2||(T=A.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(A){if(!P(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const D=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:D!==2&&this._onRequestWindowsOptionsReport.fire(M.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(M.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${c.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(A){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(A){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(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const D=[],T=A.split(";");for(;T.length>1;){const O=T.shift(),K=T.shift();if(/^\d+$/.exec(O)){const V=parseInt(O);if(W(V))if(K==="?")D.push({type:0,index:V});else{const B=(0,y.parseColor)(K);B&&D.push({type:1,index:V,color:B})}}}return D.length&&this._onColor.fire(D),!0}setHyperlink(A){const D=A.split(";");return!(D.length<2)&&(D[1]?this._createHyperlink(D[0],D[1]):!D[0]&&this._finishHyperlink())}_createHyperlink(A,D){this._getCurrentLinkId()&&this._finishHyperlink();const T=A.split(":");let O;const K=T.findIndex((V=>V.startsWith("id=")));return K!==-1&&(O=T[K].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,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(A,D){const T=A.split(";");for(let O=0;O<T.length&&!(D>=this._specialColors.length);++O,++D)if(T[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[D]}]);else{const K=(0,y.parseColor)(T[O]);K&&this._onColor.fire([{type:1,index:this._specialColors[D],color:K}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const D=[],T=A.split(";");for(let O=0;O<T.length;++O)if(/^\d+$/.exec(T[O])){const K=parseInt(T[O]);W(K)&&D.push({type:2,index:K})}return D.length&&this._onColor.fire(D),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){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,g.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(E[A[0]],g.CHARSETS[A[1]]||g.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 A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,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=l.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=l.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new f.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.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,O=this._activeBuffer.lines.get(T);O&&(O.fill(A),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,D){const T=this._bufferService.buffer,O=this._optionsService.rawOptions;return(K=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${K}${c.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${T.scrollTop+1};${T.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,D){this._dirtyRowTracker.markRangeDirty(A,D)}}i.InputHandler=z;let I=class{constructor($){this._bufferService=$,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty($){$<this.start?this.start=$:$>this.end&&(this.end=$)}markRangeDirty($,A){$>A&&(L=$,$=A,A=L),$<this.start&&(this.start=$),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function W($){return 0<=$&&$<256}I=a([h(0,C.IBufferService)],I)},844:(x,i)=>{function n(a){for(const h of a)h.dispose();a.length=0}Object.defineProperty(i,"__esModule",{value:!0}),i.getDisposeArrayDisposable=i.disposeArray=i.toDisposable=i.MutableDisposable=i.Disposable=void 0,i.Disposable=class{constructor(){this._disposables=[],this._isDisposed=!1}dispose(){this._isDisposed=!0;for(const a of this._disposables)a.dispose();this._disposables.length=0}register(a){return this._disposables.push(a),a}unregister(a){const h=this._disposables.indexOf(a);h!==-1&&this._disposables.splice(h,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(a){var h;this._isDisposed||a===this._value||((h=this._value)===null||h===void 0||h.dispose(),this._value=a)}clear(){this.value=void 0}dispose(){var a;this._isDisposed=!0,(a=this._value)===null||a===void 0||a.dispose(),this._value=void 0}},i.toDisposable=function(a){return{dispose:a}},i.disposeArray=n,i.getDisposeArrayDisposable=function(a){return{dispose:()=>n(a)}}},1505:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(h,c,g){this._data[h]||(this._data[h]={}),this._data[h][c]=g}get(h,c){return this._data[h]?this._data[h][c]:void 0}clear(){this._data={}}}i.TwoKeyMap=n,i.FourKeyMap=class{constructor(){this._data=new n}set(a,h,c,g,v){this._data.get(a,h)||this._data.set(a,h,new n),this._data.get(a,h).set(c,g,v)}get(a,h,c,g){var v;return(v=this._data.get(a,h))===null||v===void 0?void 0:v.get(c,g)}clear(){this._data.clear()}}},6114:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.isChromeOS=i.isLinux=i.isWindows=i.isIphone=i.isIpad=i.isMac=i.getSafariVersion=i.isSafari=i.isLegacyEdge=i.isFirefox=i.isNode=void 0,i.isNode=typeof navigator>"u";const n=i.isNode?"node":navigator.userAgent,a=i.isNode?"node":navigator.platform;i.isFirefox=n.includes("Firefox"),i.isLegacyEdge=n.includes("Edge"),i.isSafari=/^((?!chrome|android).)*safari/i.test(n),i.getSafariVersion=function(){if(!i.isSafari)return 0;const h=n.match(/Version\/(\d+)/);return h===null||h.length<2?0:parseInt(h[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(a),i.isIpad=a==="iPad",i.isIphone=a==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(a),i.isLinux=a.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(n)},6106:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let n=0;i.SortedList=class{constructor(a){this._getKey=a,this._array=[]}clear(){this._array.length=0}insert(a){this._array.length!==0?(n=this._search(this._getKey(a)),this._array.splice(n,0,a)):this._array.push(a)}delete(a){if(this._array.length===0)return!1;const h=this._getKey(a);if(h===void 0||(n=this._search(h),n===-1)||this._getKey(this._array[n])!==h)return!1;do if(this._array[n]===a)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===h);return!1}*getKeyIterator(a){if(this._array.length!==0&&(n=this._search(a),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===a))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===a)}forEachByKey(a,h){if(this._array.length!==0&&(n=this._search(a),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===a))do h(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===a)}values(){return[...this._array].values()}_search(a){let h=0,c=this._array.length-1;for(;c>=h;){let g=h+c>>1;const v=this._getKey(this._array[g]);if(v>a)c=g-1;else{if(!(v<a)){for(;g>0&&this._getKey(this._array[g-1])===a;)g--;return g}h=g+1}}return h}}},7226:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const a=n(6114);class h{constructor(){this._tasks=[],this._i=0}enqueue(v){this._tasks.push(v),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(v){this._idleCallback=void 0;let _=0,w=0,l=v.timeRemaining(),u=0;for(;this._i<this._tasks.length;){if(_=Date.now(),this._tasks[this._i]()||this._i++,_=Math.max(1,Date.now()-_),w=Math.max(_,w),u=v.timeRemaining(),1.5*w>u)return l-_<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(l-_))}ms`),void this._start();l=u}this.clear()}}class c extends h{_requestCallback(v){return setTimeout((()=>v(this._createDeadline(16))))}_cancelCallback(v){clearTimeout(v)}_createDeadline(v){const _=Date.now()+v;return{timeRemaining:()=>Math.max(0,_-Date.now())}}}i.PriorityTaskQueue=c,i.IdleTaskQueue=!a.isNode&&"requestIdleCallback"in window?class extends h{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:c,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const a=n(643);i.updateWindowsModeWrappedState=function(h){const c=h.buffer.lines.get(h.buffer.ybase+h.buffer.y-1),g=c?.get(h.cols-1),v=h.buffer.lines.get(h.buffer.ybase+h.buffer.y);v&&g&&(v.isWrapped=g[a.CHAR_DATA_CODE_INDEX]!==a.NULL_CELL_CODE&&g[a.CHAR_DATA_CODE_INDEX]!==a.WHITESPACE_CELL_CODE)}},3734:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ExtendedAttrs=i.AttributeData=void 0;class n{constructor(){this.fg=0,this.bg=0,this.extended=new a}static toColorRGB(c){return[c>>>16&255,c>>>8&255,255&c]}static fromColorRGB(c){return(255&c[0])<<16|(255&c[1])<<8|255&c[2]}clone(){const c=new n;return c.fg=this.fg,c.bg=this.bg,c.extended=this.extended.clone(),c}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}}i.AttributeData=n;class a{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(c){this._ext=c}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(c){this._ext&=-469762049,this._ext|=c<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(c){this._ext&=-67108864,this._ext|=67108863&c}get urlId(){return this._urlId}set urlId(c){this._urlId=c}constructor(c=0,g=0){this._ext=0,this._urlId=0,this._ext=c,this._urlId=g}clone(){return new a(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=a},9092:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const a=n(6349),h=n(7226),c=n(3734),g=n(8437),v=n(4634),_=n(511),w=n(643),l=n(4863),u=n(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(d,f,S){this._hasScrollback=d,this._optionsService=f,this._bufferService=S,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=g.DEFAULT_ATTR_DATA.clone(),this.savedCharset=u.DEFAULT_CHARSET,this.markers=[],this._nullCell=_.CellData.fromCharData([0,w.NULL_CELL_CHAR,w.NULL_CELL_WIDTH,w.NULL_CELL_CODE]),this._whitespaceCell=_.CellData.fromCharData([0,w.WHITESPACE_CELL_CHAR,w.WHITESPACE_CELL_WIDTH,w.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new h.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new a.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(d){return d?(this._nullCell.fg=d.fg,this._nullCell.bg=d.bg,this._nullCell.extended=d.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new c.ExtendedAttrs),this._nullCell}getWhitespaceCell(d){return d?(this._whitespaceCell.fg=d.fg,this._whitespaceCell.bg=d.bg,this._whitespaceCell.extended=d.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new c.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,f){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),f)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){const d=this.ybase+this.y-this.ydisp;return d>=0&&d<this._rows}_getCorrectBufferLength(d){if(!this._hasScrollback)return d;const f=d+this._optionsService.rawOptions.scrollback;return f>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:f}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let f=this._rows;for(;f--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new a.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,f){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let C=0;const k=this._getCorrectBufferLength(f);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let y=0;y<this.lines.length;y++)C+=+this.lines.get(y).resize(d,S);let j=0;if(this._rows<f)for(let y=this._rows;y<f;y++)this.lines.length<f+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new g.BufferLine(d,S)):this.ybase>0&&this.lines.length<=this.ybase+this.y+j+1?(this.ybase--,j++,this.ydisp>0&&this.ydisp--):this.lines.push(new g.BufferLine(d,S)));else for(let y=this._rows;y>f;y--)this.lines.length>f+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const y=this.lines.length-k;y>0&&(this.lines.trimStart(y),this.ybase=Math.max(this.ybase-y,0),this.ydisp=Math.max(this.ydisp-y,0),this.savedY=Math.max(this.savedY-y,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,f-1),j&&(this.y+=j),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=f-1,this._isReflowEnabled&&(this._reflow(d,f),this._cols>d))for(let j=0;j<this.lines.length;j++)C+=+this.lines.get(j).resize(d,S);this._cols=d,this._rows=f,this._memoryCleanupQueue.clear(),C>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue((()=>this._batchedMemoryCleanup())))}_batchedMemoryCleanup(){let d=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,d=!1);let f=0;for(;this._memoryCleanupPosition<this.lines.length;)if(f+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),f>100)return!0;return d}get _isReflowEnabled(){const d=this._optionsService.rawOptions.windowsPty;return d&&d.buildNumber?this._hasScrollback&&d.backend==="conpty"&&d.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(d,f){this._cols!==d&&(d>this._cols?this._reflowLarger(d,f):this._reflowSmaller(d,f))}_reflowLarger(d,f){const S=(0,v.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(S.length>0){const C=(0,v.reflowLargerCreateNewLayout)(this.lines,S);(0,v.reflowLargerApplyNewLayout)(this.lines,C.layout),this._reflowLargerAdjustViewport(d,f,C.countRemoved)}}_reflowLargerAdjustViewport(d,f,S){const C=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=S;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<f&&this.lines.push(new g.BufferLine(d,C))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-S,0)}_reflowSmaller(d,f){const S=this.getNullCell(g.DEFAULT_ATTR_DATA),C=[];let k=0;for(let j=this.lines.length-1;j>=0;j--){let y=this.lines.get(j);if(!y||!y.isWrapped&&y.getTrimmedLength()<=d)continue;const E=[y];for(;y.isWrapped&&j>0;)y=this.lines.get(--j),E.unshift(y);const R=this.ybase+this.y;if(R>=j&&R<j+E.length)continue;const P=E[E.length-1].getTrimmedLength(),M=(0,v.reflowSmallerGetNewLineLengths)(E,this._cols,d),L=M.length-E.length;let z;z=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+L):Math.max(0,this.lines.length-this.lines.maxLength+L);const I=[];for(let O=0;O<L;O++){const K=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);I.push(K)}I.length>0&&(C.push({start:j+E.length+k,newLines:I}),k+=I.length),E.push(...I);let W=M.length-1,$=M[W];$===0&&(W--,$=M[W]);let A=E.length-L-1,D=P;for(;A>=0;){const O=Math.min(D,$);if(E[W]===void 0)break;if(E[W].copyCellsFrom(E[A],D-O,$-O,O,!0),$-=O,$===0&&(W--,$=M[W]),D-=O,D===0){A--;const K=Math.max(A,0);D=(0,v.getWrappedLineTrimmedLength)(E,K,this._cols)}}for(let O=0;O<E.length;O++)M[O]<d&&E[O].setCell(M[O],S);let T=L-z;for(;T-- >0;)this.ybase===0?this.y<f-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-f&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+L,this.ybase+f-1)}if(C.length>0){const j=[],y=[];for(let W=0;W<this.lines.length;W++)y.push(this.lines.get(W));const E=this.lines.length;let R=E-1,P=0,M=C[P];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let L=0;for(let W=Math.min(this.lines.maxLength-1,E+k-1);W>=0;W--)if(M&&M.start>R+L){for(let $=M.newLines.length-1;$>=0;$--)this.lines.set(W--,M.newLines[$]);W++,j.push({index:R+1,amount:M.newLines.length}),L+=M.newLines.length,M=C[++P]}else this.lines.set(W,y[R--]);let z=0;for(let W=j.length-1;W>=0;W--)j[W].index+=z,this.lines.onInsertEmitter.fire(j[W]),z+=j[W].amount;const I=Math.max(0,E+k-this.lines.maxLength);I>0&&this.lines.onTrimEmitter.fire(I)}}translateBufferLineToString(d,f,S=0,C){const k=this.lines.get(d);return k?k.translateToString(f,S,C):""}getWrappedRangeForLine(d){let f=d,S=d;for(;f>0&&this.lines.get(f).isWrapped;)f--;for(;S+1<this.lines.length&&this.lines.get(S+1).isWrapped;)S++;return{first:f,last:S}}setupTabStops(d){for(d!=null?this.tabs[d]||(d=this.prevStop(d)):(this.tabs={},d=0);d<this._cols;d+=this._optionsService.rawOptions.tabStopWidth)this.tabs[d]=!0}prevStop(d){for(d==null&&(d=this.x);!this.tabs[--d]&&d>0;);return d>=this._cols?this._cols-1:d<0?0:d}nextStop(d){for(d==null&&(d=this.x);!this.tabs[++d]&&d<this._cols;);return d>=this._cols?this._cols-1:d<0?0:d}clearMarkers(d){this._isClearing=!0;for(let f=0;f<this.markers.length;f++)this.markers[f].line===d&&(this.markers[f].dispose(),this.markers.splice(f--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let d=0;d<this.markers.length;d++)this.markers[d].dispose(),this.markers.splice(d--,1);this._isClearing=!1}addMarker(d){const f=new l.Marker(d);return this.markers.push(f),f.register(this.lines.onTrim((S=>{f.line-=S,f.line<0&&f.dispose()}))),f.register(this.lines.onInsert((S=>{f.line>=S.index&&(f.line+=S.amount)}))),f.register(this.lines.onDelete((S=>{f.line>=S.index&&f.line<S.index+S.amount&&f.dispose(),f.line>S.index&&(f.line-=S.amount)}))),f.register(f.onDispose((()=>this._removeMarker(f)))),f}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const a=n(3734),h=n(511),c=n(643),g=n(482);i.DEFAULT_ATTR_DATA=Object.freeze(new a.AttributeData);let v=0;class _{constructor(l,u,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*l);const f=u||h.CellData.fromCharData([0,c.NULL_CELL_CHAR,c.NULL_CELL_WIDTH,c.NULL_CELL_CODE]);for(let S=0;S<l;++S)this.setCell(S,f);this.length=l}get(l){const u=this._data[3*l+0],d=2097151&u;return[this._data[3*l+1],2097152&u?this._combined[l]:d?(0,g.stringFromCodePoint)(d):"",u>>22,2097152&u?this._combined[l].charCodeAt(this._combined[l].length-1):d]}set(l,u){this._data[3*l+1]=u[c.CHAR_DATA_ATTR_INDEX],u[c.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[l]=u[1],this._data[3*l+0]=2097152|l|u[c.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*l+0]=u[c.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|u[c.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(l){return this._data[3*l+0]>>22}hasWidth(l){return 12582912&this._data[3*l+0]}getFg(l){return this._data[3*l+1]}getBg(l){return this._data[3*l+2]}hasContent(l){return 4194303&this._data[3*l+0]}getCodePoint(l){const u=this._data[3*l+0];return 2097152&u?this._combined[l].charCodeAt(this._combined[l].length-1):2097151&u}isCombined(l){return 2097152&this._data[3*l+0]}getString(l){const u=this._data[3*l+0];return 2097152&u?this._combined[l]:2097151&u?(0,g.stringFromCodePoint)(2097151&u):""}isProtected(l){return 536870912&this._data[3*l+2]}loadCell(l,u){return v=3*l,u.content=this._data[v+0],u.fg=this._data[v+1],u.bg=this._data[v+2],2097152&u.content&&(u.combinedData=this._combined[l]),268435456&u.bg&&(u.extended=this._extendedAttrs[l]),u}setCell(l,u){2097152&u.content&&(this._combined[l]=u.combinedData),268435456&u.bg&&(this._extendedAttrs[l]=u.extended),this._data[3*l+0]=u.content,this._data[3*l+1]=u.fg,this._data[3*l+2]=u.bg}setCellFromCodePoint(l,u,d,f,S,C){268435456&S&&(this._extendedAttrs[l]=C),this._data[3*l+0]=u|d<<22,this._data[3*l+1]=f,this._data[3*l+2]=S}addCodepointToCell(l,u){let d=this._data[3*l+0];2097152&d?this._combined[l]+=(0,g.stringFromCodePoint)(u):(2097151&d?(this._combined[l]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(u),d&=-2097152,d|=2097152):d=u|4194304,this._data[3*l+0]=d)}insertCells(l,u,d,f){if((l%=this.length)&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),u<this.length-l){const S=new h.CellData;for(let C=this.length-l-u-1;C>=0;--C)this.setCell(l+u+C,this.loadCell(l+C,S));for(let C=0;C<u;++C)this.setCell(l+C,d)}else for(let S=l;S<this.length;++S)this.setCell(S,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs)}deleteCells(l,u,d,f){if(l%=this.length,u<this.length-l){const S=new h.CellData;for(let C=0;C<this.length-l-u;++C)this.setCell(l+C,this.loadCell(l+u+C,S));for(let C=this.length-u;C<this.length;++C)this.setCell(C,d)}else for(let S=l;S<this.length;++S)this.setCell(S,d);l&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),this.getWidth(l)!==0||this.hasContent(l)||this.setCellFromCodePoint(l,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs)}replaceCells(l,u,d,f,S=!1){if(S)for(l&&this.getWidth(l-1)===2&&!this.isProtected(l-1)&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),u<this.length&&this.getWidth(u-1)===2&&!this.isProtected(u)&&this.setCellFromCodePoint(u,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs);l<u&&l<this.length;)this.isProtected(l)||this.setCell(l,d),l++;else for(l&&this.getWidth(l-1)===2&&this.setCellFromCodePoint(l-1,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs),u<this.length&&this.getWidth(u-1)===2&&this.setCellFromCodePoint(u,0,1,f?.fg||0,f?.bg||0,f?.extended||new a.ExtendedAttrs);l<u&&l<this.length;)this.setCell(l++,d)}resize(l,u){if(l===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*l;if(l>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const f=new Uint32Array(d);f.set(this._data),this._data=f}for(let f=this.length;f<l;++f)this.setCell(f,u)}else{this._data=this._data.subarray(0,d);const f=Object.keys(this._combined);for(let C=0;C<f.length;C++){const k=parseInt(f[C],10);k>=l&&delete this._combined[k]}const S=Object.keys(this._extendedAttrs);for(let C=0;C<S.length;C++){const k=parseInt(S[C],10);k>=l&&delete this._extendedAttrs[k]}}return this.length=l,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const l=new Uint32Array(this._data.length);return l.set(this._data),this._data=l,1}return 0}fill(l,u=!1){if(u)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,l);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,l)}}copyFrom(l){this.length!==l.length?this._data=new Uint32Array(l._data):this._data.set(l._data),this.length=l.length,this._combined={};for(const u in l._combined)this._combined[u]=l._combined[u];this._extendedAttrs={};for(const u in l._extendedAttrs)this._extendedAttrs[u]=l._extendedAttrs[u];this.isWrapped=l.isWrapped}clone(){const l=new _(0);l._data=new Uint32Array(this._data),l.length=this.length;for(const u in this._combined)l._combined[u]=this._combined[u];for(const u in this._extendedAttrs)l._extendedAttrs[u]=this._extendedAttrs[u];return l.isWrapped=this.isWrapped,l}getTrimmedLength(){for(let l=this.length-1;l>=0;--l)if(4194303&this._data[3*l+0])return l+(this._data[3*l+0]>>22);return 0}getNoBgTrimmedLength(){for(let l=this.length-1;l>=0;--l)if(4194303&this._data[3*l+0]||50331648&this._data[3*l+2])return l+(this._data[3*l+0]>>22);return 0}copyCellsFrom(l,u,d,f,S){const C=l._data;if(S)for(let j=f-1;j>=0;j--){for(let y=0;y<3;y++)this._data[3*(d+j)+y]=C[3*(u+j)+y];268435456&C[3*(u+j)+2]&&(this._extendedAttrs[d+j]=l._extendedAttrs[u+j])}else for(let j=0;j<f;j++){for(let y=0;y<3;y++)this._data[3*(d+j)+y]=C[3*(u+j)+y];268435456&C[3*(u+j)+2]&&(this._extendedAttrs[d+j]=l._extendedAttrs[u+j])}const k=Object.keys(l._combined);for(let j=0;j<k.length;j++){const y=parseInt(k[j],10);y>=u&&(this._combined[y-u+d]=l._combined[y])}}translateToString(l=!1,u=0,d=this.length){l&&(d=Math.min(d,this.getTrimmedLength()));let f="";for(;u<d;){const S=this._data[3*u+0],C=2097151&S;f+=2097152&S?this._combined[u]:C?(0,g.stringFromCodePoint)(C):c.WHITESPACE_CELL_CHAR,u+=S>>22||1}return f}}i.BufferLine=_},4841:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(n,a){if(n.start.y>n.end.y)throw new Error(`Buffer range end (${n.end.x}, ${n.end.y}) cannot be before start (${n.start.x}, ${n.start.y})`);return a*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(x,i)=>{function n(a,h,c){if(h===a.length-1)return a[h].getTrimmedLength();const g=!a[h].hasContent(c-1)&&a[h].getWidth(c-1)===1,v=a[h+1].getWidth(0)===2;return g&&v?c-1:c}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(a,h,c,g,v){const _=[];for(let w=0;w<a.length-1;w++){let l=w,u=a.get(++l);if(!u.isWrapped)continue;const d=[a.get(w)];for(;l<a.length&&u.isWrapped;)d.push(u),u=a.get(++l);if(g>=w&&g<l){w+=d.length-1;continue}let f=0,S=n(d,f,h),C=1,k=0;for(;C<d.length;){const y=n(d,C,h),E=y-k,R=c-S,P=Math.min(E,R);d[f].copyCellsFrom(d[C],k,S,P,!1),S+=P,S===c&&(f++,S=0),k+=P,k===y&&(C++,k=0),S===0&&f!==0&&d[f-1].getWidth(c-1)===2&&(d[f].copyCellsFrom(d[f-1],c-1,S++,1,!1),d[f-1].setCell(c-1,v))}d[f].replaceCells(S,c,v);let j=0;for(let y=d.length-1;y>0&&(y>f||d[y].getTrimmedLength()===0);y--)j++;j>0&&(_.push(w+d.length-j),_.push(j)),w+=d.length-1}return _},i.reflowLargerCreateNewLayout=function(a,h){const c=[];let g=0,v=h[g],_=0;for(let w=0;w<a.length;w++)if(v===w){const l=h[++g];a.onDeleteEmitter.fire({index:w-_,amount:l}),w+=l-1,_+=l,v=h[++g]}else c.push(w);return{layout:c,countRemoved:_}},i.reflowLargerApplyNewLayout=function(a,h){const c=[];for(let g=0;g<h.length;g++)c.push(a.get(h[g]));for(let g=0;g<c.length;g++)a.set(g,c[g]);a.length=h.length},i.reflowSmallerGetNewLineLengths=function(a,h,c){const g=[],v=a.map(((u,d)=>n(a,d,h))).reduce(((u,d)=>u+d));let _=0,w=0,l=0;for(;l<v;){if(v-l<c){g.push(v-l);break}_+=c;const u=n(a,w,h);_>u&&(_-=u,w++);const d=a[w].getWidth(_-1)===2;d&&_--;const f=d?c-1:c;g.push(f),l+=f}return g},i.getWrappedLineTrimmedLength=n},5295:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const a=n(8460),h=n(844),c=n(9092);class g extends h.Disposable{constructor(_,w){super(),this._optionsService=_,this._bufferService=w,this._onBufferActivate=this.register(new a.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 c.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new c.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(_){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(_),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(_,w){this._normal.resize(_,w),this._alt.resize(_,w),this.setupTabStops(_)}setupTabStops(_){this._normal.setupTabStops(_),this._alt.setupTabStops(_)}}i.BufferSet=g},511:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const a=n(482),h=n(643),c=n(3734);class g extends c.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new c.ExtendedAttrs,this.combinedData=""}static fromCharData(_){const w=new g;return w.setFromCharData(_),w}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,a.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(_){this.fg=_[h.CHAR_DATA_ATTR_INDEX],this.bg=0;let w=!1;if(_[h.CHAR_DATA_CHAR_INDEX].length>2)w=!0;else if(_[h.CHAR_DATA_CHAR_INDEX].length===2){const l=_[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=l&&l<=56319){const u=_[h.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=u&&u<=57343?this.content=1024*(l-55296)+u-56320+65536|_[h.CHAR_DATA_WIDTH_INDEX]<<22:w=!0}else w=!0}else this.content=_[h.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|_[h.CHAR_DATA_WIDTH_INDEX]<<22;w&&(this.combinedData=_[h.CHAR_DATA_CHAR_INDEX],this.content=2097152|_[h.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WHITESPACE_CELL_CODE=i.WHITESPACE_CELL_WIDTH=i.WHITESPACE_CELL_CHAR=i.NULL_CELL_CODE=i.NULL_CELL_WIDTH=i.NULL_CELL_CHAR=i.CHAR_DATA_CODE_INDEX=i.CHAR_DATA_WIDTH_INDEX=i.CHAR_DATA_CHAR_INDEX=i.CHAR_DATA_ATTR_INDEX=i.DEFAULT_EXT=i.DEFAULT_ATTR=i.DEFAULT_COLOR=void 0,i.DEFAULT_COLOR=0,i.DEFAULT_ATTR=256|i.DEFAULT_COLOR<<9,i.DEFAULT_EXT=0,i.CHAR_DATA_ATTR_INDEX=0,i.CHAR_DATA_CHAR_INDEX=1,i.CHAR_DATA_WIDTH_INDEX=2,i.CHAR_DATA_CODE_INDEX=3,i.NULL_CELL_CHAR="",i.NULL_CELL_WIDTH=1,i.NULL_CELL_CODE=0,i.WHITESPACE_CELL_CHAR=" ",i.WHITESPACE_CELL_WIDTH=1,i.WHITESPACE_CELL_CODE=32},4863:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const a=n(8460),h=n(844);class c{get id(){return this._id}constructor(v){this.line=v,this.isDisposed=!1,this._disposables=[],this._id=c._nextId++,this._onDispose=this.register(new a.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,h.disposeArray)(this._disposables),this._disposables.length=0)}register(v){return this._disposables.push(v),v}}i.Marker=c,c._nextId=1},7116:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DEFAULT_CHARSET=i.CHARSETS=void 0,i.CHARSETS={},i.DEFAULT_CHARSET=i.CHARSETS.B,i.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:"≥","{":"π","|":"≠","}":"£","~":"·"},i.CHARSETS.A={"#":"£"},i.CHARSETS.B=void 0,i.CHARSETS[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"},i.CHARSETS.C=i.CHARSETS[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"},i.CHARSETS.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"},i.CHARSETS.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"},i.CHARSETS.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"},i.CHARSETS.E=i.CHARSETS[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"},i.CHARSETS.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"},i.CHARSETS.H=i.CHARSETS[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"},i.CHARSETS["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"}},2584:(x,i)=>{var n,a,h;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(c){c.NUL="\0",c.SOH="",c.STX="",c.ETX="",c.EOT="",c.ENQ="",c.ACK="",c.BEL="\x07",c.BS="\b",c.HT=" ",c.LF=`
20
- `,c.VT="\v",c.FF="\f",c.CR="\r",c.SO="",c.SI="",c.DLE="",c.DC1="",c.DC2="",c.DC3="",c.DC4="",c.NAK="",c.SYN="",c.ETB="",c.CAN="",c.EM="",c.SUB="",c.ESC="\x1B",c.FS="",c.GS="",c.RS="",c.US="",c.SP=" ",c.DEL=""})(n||(i.C0=n={})),(function(c){c.PAD="€",c.HOP="",c.BPH="‚",c.NBH="ƒ",c.IND="„",c.NEL="…",c.SSA="†",c.ESA="‡",c.HTS="ˆ",c.HTJ="‰",c.VTS="Š",c.PLD="‹",c.PLU="Œ",c.RI="",c.SS2="Ž",c.SS3="",c.DCS="",c.PU1="‘",c.PU2="’",c.STS="“",c.CCH="”",c.MW="•",c.SPA="–",c.EPA="—",c.SOS="˜",c.SGCI="™",c.SCI="š",c.CSI="›",c.ST="œ",c.OSC="",c.PM="ž",c.APC="Ÿ"})(a||(i.C1=a={})),(function(c){c.ST=`${n.ESC}\\`})(h||(i.C1_ESCAPED=h={}))},7399:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const a=n(2584),h={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:["'",'"']};i.evaluateKeyboardEvent=function(c,g,v,_){const w={type:0,cancel:!1,key:void 0},l=(c.shiftKey?1:0)|(c.altKey?2:0)|(c.ctrlKey?4:0)|(c.metaKey?8:0);switch(c.keyCode){case 0:c.key==="UIKeyInputUpArrow"?w.key=g?a.C0.ESC+"OA":a.C0.ESC+"[A":c.key==="UIKeyInputLeftArrow"?w.key=g?a.C0.ESC+"OD":a.C0.ESC+"[D":c.key==="UIKeyInputRightArrow"?w.key=g?a.C0.ESC+"OC":a.C0.ESC+"[C":c.key==="UIKeyInputDownArrow"&&(w.key=g?a.C0.ESC+"OB":a.C0.ESC+"[B");break;case 8:if(c.altKey){w.key=a.C0.ESC+a.C0.DEL;break}w.key=a.C0.DEL;break;case 9:if(c.shiftKey){w.key=a.C0.ESC+"[Z";break}w.key=a.C0.HT,w.cancel=!0;break;case 13:w.key=c.altKey?a.C0.ESC+a.C0.CR:a.C0.CR,w.cancel=!0;break;case 27:w.key=a.C0.ESC,c.altKey&&(w.key=a.C0.ESC+a.C0.ESC),w.cancel=!0;break;case 37:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"D",w.key===a.C0.ESC+"[1;3D"&&(w.key=a.C0.ESC+(v?"b":"[1;5D"))):w.key=g?a.C0.ESC+"OD":a.C0.ESC+"[D";break;case 39:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"C",w.key===a.C0.ESC+"[1;3C"&&(w.key=a.C0.ESC+(v?"f":"[1;5C"))):w.key=g?a.C0.ESC+"OC":a.C0.ESC+"[C";break;case 38:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"A",v||w.key!==a.C0.ESC+"[1;3A"||(w.key=a.C0.ESC+"[1;5A")):w.key=g?a.C0.ESC+"OA":a.C0.ESC+"[A";break;case 40:if(c.metaKey)break;l?(w.key=a.C0.ESC+"[1;"+(l+1)+"B",v||w.key!==a.C0.ESC+"[1;3B"||(w.key=a.C0.ESC+"[1;5B")):w.key=g?a.C0.ESC+"OB":a.C0.ESC+"[B";break;case 45:c.shiftKey||c.ctrlKey||(w.key=a.C0.ESC+"[2~");break;case 46:w.key=l?a.C0.ESC+"[3;"+(l+1)+"~":a.C0.ESC+"[3~";break;case 36:w.key=l?a.C0.ESC+"[1;"+(l+1)+"H":g?a.C0.ESC+"OH":a.C0.ESC+"[H";break;case 35:w.key=l?a.C0.ESC+"[1;"+(l+1)+"F":g?a.C0.ESC+"OF":a.C0.ESC+"[F";break;case 33:c.shiftKey?w.type=2:c.ctrlKey?w.key=a.C0.ESC+"[5;"+(l+1)+"~":w.key=a.C0.ESC+"[5~";break;case 34:c.shiftKey?w.type=3:c.ctrlKey?w.key=a.C0.ESC+"[6;"+(l+1)+"~":w.key=a.C0.ESC+"[6~";break;case 112:w.key=l?a.C0.ESC+"[1;"+(l+1)+"P":a.C0.ESC+"OP";break;case 113:w.key=l?a.C0.ESC+"[1;"+(l+1)+"Q":a.C0.ESC+"OQ";break;case 114:w.key=l?a.C0.ESC+"[1;"+(l+1)+"R":a.C0.ESC+"OR";break;case 115:w.key=l?a.C0.ESC+"[1;"+(l+1)+"S":a.C0.ESC+"OS";break;case 116:w.key=l?a.C0.ESC+"[15;"+(l+1)+"~":a.C0.ESC+"[15~";break;case 117:w.key=l?a.C0.ESC+"[17;"+(l+1)+"~":a.C0.ESC+"[17~";break;case 118:w.key=l?a.C0.ESC+"[18;"+(l+1)+"~":a.C0.ESC+"[18~";break;case 119:w.key=l?a.C0.ESC+"[19;"+(l+1)+"~":a.C0.ESC+"[19~";break;case 120:w.key=l?a.C0.ESC+"[20;"+(l+1)+"~":a.C0.ESC+"[20~";break;case 121:w.key=l?a.C0.ESC+"[21;"+(l+1)+"~":a.C0.ESC+"[21~";break;case 122:w.key=l?a.C0.ESC+"[23;"+(l+1)+"~":a.C0.ESC+"[23~";break;case 123:w.key=l?a.C0.ESC+"[24;"+(l+1)+"~":a.C0.ESC+"[24~";break;default:if(!c.ctrlKey||c.shiftKey||c.altKey||c.metaKey)if(v&&!_||!c.altKey||c.metaKey)!v||c.altKey||c.ctrlKey||c.shiftKey||!c.metaKey?c.key&&!c.ctrlKey&&!c.altKey&&!c.metaKey&&c.keyCode>=48&&c.key.length===1?w.key=c.key:c.key&&c.ctrlKey&&(c.key==="_"&&(w.key=a.C0.US),c.key==="@"&&(w.key=a.C0.NUL)):c.keyCode===65&&(w.type=1);else{const u=h[c.keyCode],d=u?.[c.shiftKey?1:0];if(d)w.key=a.C0.ESC+d;else if(c.keyCode>=65&&c.keyCode<=90){const f=c.ctrlKey?c.keyCode-64:c.keyCode+32;let S=String.fromCharCode(f);c.shiftKey&&(S=S.toUpperCase()),w.key=a.C0.ESC+S}else if(c.keyCode===32)w.key=a.C0.ESC+(c.ctrlKey?a.C0.NUL:" ");else if(c.key==="Dead"&&c.code.startsWith("Key")){let f=c.code.slice(3,4);c.shiftKey||(f=f.toLowerCase()),w.key=a.C0.ESC+f,w.cancel=!0}}else c.keyCode>=65&&c.keyCode<=90?w.key=String.fromCharCode(c.keyCode-64):c.keyCode===32?w.key=a.C0.NUL:c.keyCode>=51&&c.keyCode<=55?w.key=String.fromCharCode(c.keyCode-51+27):c.keyCode===56?w.key=a.C0.DEL:c.keyCode===219?w.key=a.C0.ESC:c.keyCode===220?w.key=a.C0.FS:c.keyCode===221&&(w.key=a.C0.GS)}return w}},482:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Utf8ToUtf32=i.StringToUtf32=i.utf32ToString=i.stringFromCodePoint=void 0,i.stringFromCodePoint=function(n){return n>65535?(n-=65536,String.fromCharCode(55296+(n>>10))+String.fromCharCode(n%1024+56320)):String.fromCharCode(n)},i.utf32ToString=function(n,a=0,h=n.length){let c="";for(let g=a;g<h;++g){let v=n[g];v>65535?(v-=65536,c+=String.fromCharCode(55296+(v>>10))+String.fromCharCode(v%1024+56320)):c+=String.fromCharCode(v)}return c},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,a){const h=n.length;if(!h)return 0;let c=0,g=0;if(this._interim){const v=n.charCodeAt(g++);56320<=v&&v<=57343?a[c++]=1024*(this._interim-55296)+v-56320+65536:(a[c++]=this._interim,a[c++]=v),this._interim=0}for(let v=g;v<h;++v){const _=n.charCodeAt(v);if(55296<=_&&_<=56319){if(++v>=h)return this._interim=_,c;const w=n.charCodeAt(v);56320<=w&&w<=57343?a[c++]=1024*(_-55296)+w-56320+65536:(a[c++]=_,a[c++]=w)}else _!==65279&&(a[c++]=_)}return c}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,a){const h=n.length;if(!h)return 0;let c,g,v,_,w=0,l=0,u=0;if(this.interim[0]){let S=!1,C=this.interim[0];C&=(224&C)==192?31:(240&C)==224?15:7;let k,j=0;for(;(k=63&this.interim[++j])&&j<4;)C<<=6,C|=k;const y=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,E=y-j;for(;u<E;){if(u>=h)return 0;if(k=n[u++],(192&k)!=128){u--,S=!0;break}this.interim[j++]=k,C<<=6,C|=63&k}S||(y===2?C<128?u--:a[w++]=C:y===3?C<2048||C>=55296&&C<=57343||C===65279||(a[w++]=C):C<65536||C>1114111||(a[w++]=C)),this.interim.fill(0)}const d=h-4;let f=u;for(;f<h;){for(;!(!(f<d)||128&(c=n[f])||128&(g=n[f+1])||128&(v=n[f+2])||128&(_=n[f+3]));)a[w++]=c,a[w++]=g,a[w++]=v,a[w++]=_,f+=4;if(c=n[f++],c<128)a[w++]=c;else if((224&c)==192){if(f>=h)return this.interim[0]=c,w;if(g=n[f++],(192&g)!=128){f--;continue}if(l=(31&c)<<6|63&g,l<128){f--;continue}a[w++]=l}else if((240&c)==224){if(f>=h)return this.interim[0]=c,w;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=h)return this.interim[0]=c,this.interim[1]=g,w;if(v=n[f++],(192&v)!=128){f--;continue}if(l=(15&c)<<12|(63&g)<<6|63&v,l<2048||l>=55296&&l<=57343||l===65279)continue;a[w++]=l}else if((248&c)==240){if(f>=h)return this.interim[0]=c,w;if(g=n[f++],(192&g)!=128){f--;continue}if(f>=h)return this.interim[0]=c,this.interim[1]=g,w;if(v=n[f++],(192&v)!=128){f--;continue}if(f>=h)return this.interim[0]=c,this.interim[1]=g,this.interim[2]=v,w;if(_=n[f++],(192&_)!=128){f--;continue}if(l=(7&c)<<18|(63&g)<<12|(63&v)<<6|63&_,l<65536||l>1114111)continue;a[w++]=l}}return w}}},225:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeV6=void 0;const n=[[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]],a=[[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 h;i.UnicodeV6=class{constructor(){if(this.version="6",!h){h=new Uint8Array(65536),h.fill(1),h[0]=0,h.fill(0,1,32),h.fill(0,127,160),h.fill(2,4352,4448),h[9001]=2,h[9002]=2,h.fill(2,11904,42192),h[12351]=1,h.fill(2,44032,55204),h.fill(2,63744,64256),h.fill(2,65040,65050),h.fill(2,65072,65136),h.fill(2,65280,65377),h.fill(2,65504,65511);for(let c=0;c<n.length;++c)h.fill(0,n[c][0],n[c][1]+1)}}wcwidth(c){return c<32?0:c<127?1:c<65536?h[c]:(function(g,v){let _,w=0,l=v.length-1;if(g<v[0][0]||g>v[l][1])return!1;for(;l>=w;)if(_=w+l>>1,g>v[_][1])w=_+1;else{if(!(g<v[_][0]))return!0;l=_-1}return!1})(c,a)?0:c>=131072&&c<=196605||c>=196608&&c<=262141?2:1}}},5981:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const a=n(8460),h=n(844);class c extends h.Disposable{constructor(v){super(),this._action=v,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new a.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(v,_){if(_!==void 0&&this._syncCalls>_)return void(this._syncCalls=0);if(this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let w;for(this._isSyncWriting=!0;w=this._writeBuffer.shift();){this._action(w);const l=this._callbacks.shift();l&&l()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(v,_){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+=v.length,this._writeBuffer.push(v),this._callbacks.push(_),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=v.length,this._writeBuffer.push(v),this._callbacks.push(_)}_innerWrite(v=0,_=!0){const w=v||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const l=this._writeBuffer[this._bufferOffset],u=this._action(l,_);if(u){const f=S=>Date.now()-w>=12?setTimeout((()=>this._innerWrite(0,S))):this._innerWrite(w,S);return void u.catch((S=>(queueMicrotask((()=>{throw S})),Promise.resolve(!1)))).then(f)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=l.length,Date.now()-w>=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()}}i.WriteBuffer=c},5941:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.toRgbString=i.parseColor=void 0;const n=/^([\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})$/,a=/^[\da-f]+$/;function h(c,g){const v=c.toString(16),_=v.length<2?"0"+v:v;switch(g){case 4:return v[0];case 8:return _;case 12:return(_+_).slice(0,3);default:return _+_}}i.parseColor=function(c){if(!c)return;let g=c.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const v=n.exec(g);if(v){const _=v[1]?15:v[4]?255:v[7]?4095:65535;return[Math.round(parseInt(v[1]||v[4]||v[7]||v[10],16)/_*255),Math.round(parseInt(v[2]||v[5]||v[8]||v[11],16)/_*255),Math.round(parseInt(v[3]||v[6]||v[9]||v[12],16)/_*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),a.exec(g)&&[3,6,9,12].includes(g.length))){const v=g.length/3,_=[0,0,0];for(let w=0;w<3;++w){const l=parseInt(g.slice(v*w,v*w+v),16);_[w]=v===1?l<<4:v===2?l:v===3?l>>4:l>>8}return _}},i.toRgbString=function(c,g=16){const[v,_,w]=c;return`rgb:${h(v,g)}/${h(_,g)}/${h(w,g)}`}},5770:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const a=n(482),h=n(8742),c=n(5770),g=[];i.DcsParser=class{constructor(){this._handlers=Object.create(null),this._active=g,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=g}registerHandler(_,w){this._handlers[_]===void 0&&(this._handlers[_]=[]);const l=this._handlers[_];return l.push(w),{dispose:()=>{const u=l.indexOf(w);u!==-1&&l.splice(u,1)}}}clearHandler(_){this._handlers[_]&&delete this._handlers[_]}setHandlerFallback(_){this._handlerFb=_}reset(){if(this._active.length)for(let _=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;_>=0;--_)this._active[_].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(_,w){if(this.reset(),this._ident=_,this._active=this._handlers[_]||g,this._active.length)for(let l=this._active.length-1;l>=0;l--)this._active[l].hook(w);else this._handlerFb(this._ident,"HOOK",w)}put(_,w,l){if(this._active.length)for(let u=this._active.length-1;u>=0;u--)this._active[u].put(_,w,l);else this._handlerFb(this._ident,"PUT",(0,a.utf32ToString)(_,w,l))}unhook(_,w=!0){if(this._active.length){let l=!1,u=this._active.length-1,d=!1;if(this._stack.paused&&(u=this._stack.loopPosition-1,l=w,d=this._stack.fallThrough,this._stack.paused=!1),!d&&l===!1){for(;u>=0&&(l=this._active[u].unhook(_),l!==!0);u--)if(l instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=u,this._stack.fallThrough=!1,l;u--}for(;u>=0;u--)if(l=this._active[u].unhook(!1),l instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=u,this._stack.fallThrough=!0,l}else this._handlerFb(this._ident,"UNHOOK",_);this._active=g,this._ident=0}};const v=new h.Params;v.addParam(0),i.DcsHandler=class{constructor(_){this._handler=_,this._data="",this._params=v,this._hitLimit=!1}hook(_){this._params=_.length>1||_.params[0]?_.clone():v,this._data="",this._hitLimit=!1}put(_,w,l){this._hitLimit||(this._data+=(0,a.utf32ToString)(_,w,l),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(_){let w=!1;if(this._hitLimit)w=!1;else if(_&&(w=this._handler(this._data,this._params),w instanceof Promise))return w.then((l=>(this._params=v,this._data="",this._hitLimit=!1,l)));return this._params=v,this._data="",this._hitLimit=!1,w}}},2015:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const a=n(844),h=n(8742),c=n(6242),g=n(6351);class v{constructor(u){this.table=new Uint8Array(u)}setDefault(u,d){this.table.fill(u<<4|d)}add(u,d,f,S){this.table[d<<8|u]=f<<4|S}addMany(u,d,f,S){for(let C=0;C<u.length;C++)this.table[d<<8|u[C]]=f<<4|S}}i.TransitionTable=v;const _=160;i.VT500_TRANSITION_TABLE=(function(){const l=new v(4095),u=Array.apply(null,Array(256)).map(((j,y)=>y)),d=(j,y)=>u.slice(j,y),f=d(32,127),S=d(0,24);S.push(25),S.push.apply(S,d(28,32));const C=d(0,14);let k;for(k in l.setDefault(1,0),l.addMany(f,0,2,0),C)l.addMany([24,26,153,154],k,3,0),l.addMany(d(128,144),k,3,0),l.addMany(d(144,152),k,3,0),l.add(156,k,0,0),l.add(27,k,11,1),l.add(157,k,4,8),l.addMany([152,158,159],k,0,7),l.add(155,k,11,3),l.add(144,k,11,9);return l.addMany(S,0,3,0),l.addMany(S,1,3,1),l.add(127,1,0,1),l.addMany(S,8,0,8),l.addMany(S,3,3,3),l.add(127,3,0,3),l.addMany(S,4,3,4),l.add(127,4,0,4),l.addMany(S,6,3,6),l.addMany(S,5,3,5),l.add(127,5,0,5),l.addMany(S,2,3,2),l.add(127,2,0,2),l.add(93,1,4,8),l.addMany(f,8,5,8),l.add(127,8,5,8),l.addMany([156,27,24,26,7],8,6,0),l.addMany(d(28,32),8,0,8),l.addMany([88,94,95],1,0,7),l.addMany(f,7,0,7),l.addMany(S,7,0,7),l.add(156,7,0,0),l.add(127,7,0,7),l.add(91,1,11,3),l.addMany(d(64,127),3,7,0),l.addMany(d(48,60),3,8,4),l.addMany([60,61,62,63],3,9,4),l.addMany(d(48,60),4,8,4),l.addMany(d(64,127),4,7,0),l.addMany([60,61,62,63],4,0,6),l.addMany(d(32,64),6,0,6),l.add(127,6,0,6),l.addMany(d(64,127),6,0,0),l.addMany(d(32,48),3,9,5),l.addMany(d(32,48),5,9,5),l.addMany(d(48,64),5,0,6),l.addMany(d(64,127),5,7,0),l.addMany(d(32,48),4,9,5),l.addMany(d(32,48),1,9,2),l.addMany(d(32,48),2,9,2),l.addMany(d(48,127),2,10,0),l.addMany(d(48,80),1,10,0),l.addMany(d(81,88),1,10,0),l.addMany([89,90,92],1,10,0),l.addMany(d(96,127),1,10,0),l.add(80,1,11,9),l.addMany(S,9,0,9),l.add(127,9,0,9),l.addMany(d(28,32),9,0,9),l.addMany(d(32,48),9,9,12),l.addMany(d(48,60),9,8,10),l.addMany([60,61,62,63],9,9,10),l.addMany(S,11,0,11),l.addMany(d(32,128),11,0,11),l.addMany(d(28,32),11,0,11),l.addMany(S,10,0,10),l.add(127,10,0,10),l.addMany(d(28,32),10,0,10),l.addMany(d(48,60),10,8,10),l.addMany([60,61,62,63],10,0,11),l.addMany(d(32,48),10,9,12),l.addMany(S,12,0,12),l.add(127,12,0,12),l.addMany(d(28,32),12,0,12),l.addMany(d(32,48),12,9,12),l.addMany(d(48,64),12,0,11),l.addMany(d(64,127),12,12,13),l.addMany(d(64,127),10,12,13),l.addMany(d(64,127),9,12,13),l.addMany(S,13,13,13),l.addMany(f,13,13,13),l.add(127,13,0,13),l.addMany([27,156,24,26],13,14,0),l.add(_,0,2,0),l.add(_,8,5,8),l.add(_,6,0,6),l.add(_,11,0,11),l.add(_,13,13,13),l})();class w extends a.Disposable{constructor(u=i.VT500_TRANSITION_TABLE){super(),this._transitions=u,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new h.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,f,S)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,f)=>{},this._escHandlerFb=d=>{},this._errorHandlerFb=d=>d,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this.register((0,a.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new c.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(u,d=[64,126]){let f=0;if(u.prefix){if(u.prefix.length>1)throw new Error("only one byte as prefix supported");if(f=u.prefix.charCodeAt(0),f&&60>f||f>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(u.intermediates){if(u.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let C=0;C<u.intermediates.length;++C){const k=u.intermediates.charCodeAt(C);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");f<<=8,f|=k}}if(u.final.length!==1)throw new Error("final must be a single byte");const S=u.final.charCodeAt(0);if(d[0]>S||S>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return f<<=8,f|=S,f}identToString(u){const d=[];for(;u;)d.push(String.fromCharCode(255&u)),u>>=8;return d.reverse().join("")}setPrintHandler(u){this._printHandler=u}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(u,d){const f=this._identifier(u,[48,126]);this._escHandlers[f]===void 0&&(this._escHandlers[f]=[]);const S=this._escHandlers[f];return S.push(d),{dispose:()=>{const C=S.indexOf(d);C!==-1&&S.splice(C,1)}}}clearEscHandler(u){this._escHandlers[this._identifier(u,[48,126])]&&delete this._escHandlers[this._identifier(u,[48,126])]}setEscHandlerFallback(u){this._escHandlerFb=u}setExecuteHandler(u,d){this._executeHandlers[u.charCodeAt(0)]=d}clearExecuteHandler(u){this._executeHandlers[u.charCodeAt(0)]&&delete this._executeHandlers[u.charCodeAt(0)]}setExecuteHandlerFallback(u){this._executeHandlerFb=u}registerCsiHandler(u,d){const f=this._identifier(u);this._csiHandlers[f]===void 0&&(this._csiHandlers[f]=[]);const S=this._csiHandlers[f];return S.push(d),{dispose:()=>{const C=S.indexOf(d);C!==-1&&S.splice(C,1)}}}clearCsiHandler(u){this._csiHandlers[this._identifier(u)]&&delete this._csiHandlers[this._identifier(u)]}setCsiHandlerFallback(u){this._csiHandlerFb=u}registerDcsHandler(u,d){return this._dcsParser.registerHandler(this._identifier(u),d)}clearDcsHandler(u){this._dcsParser.clearHandler(this._identifier(u))}setDcsHandlerFallback(u){this._dcsParser.setHandlerFallback(u)}registerOscHandler(u,d){return this._oscParser.registerHandler(u,d)}clearOscHandler(u){this._oscParser.clearHandler(u)}setOscHandlerFallback(u){this._oscParser.setHandlerFallback(u)}setErrorHandler(u){this._errorHandler=u}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(u,d,f,S,C){this._parseStack.state=u,this._parseStack.handlers=d,this._parseStack.handlerPos=f,this._parseStack.transition=S,this._parseStack.chunkPos=C}parse(u,d,f){let S,C=0,k=0,j=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,j=this._parseStack.chunkPos+1;else{if(f===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const y=this._parseStack.handlers;let E=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&E>-1){for(;E>=0&&(S=y[E](this._params),S!==!0);E--)if(S instanceof Promise)return this._parseStack.handlerPos=E,S}this._parseStack.handlers=[];break;case 4:if(f===!1&&E>-1){for(;E>=0&&(S=y[E](),S!==!0);E--)if(S instanceof Promise)return this._parseStack.handlerPos=E,S}this._parseStack.handlers=[];break;case 6:if(C=u[this._parseStack.chunkPos],S=this._dcsParser.unhook(C!==24&&C!==26,f),S)return S;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(C=u[this._parseStack.chunkPos],S=this._oscParser.end(C!==24&&C!==26,f),S)return S;C===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0}this._parseStack.state=0,j=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let y=j;y<d;++y){switch(C=u[y],k=this._transitions.table[this.currentState<<8|(C<160?C:_)],k>>4){case 2:for(let L=y+1;;++L){if(L>=d||(C=u[L])<32||C>126&&C<_){this._printHandler(u,y,L),y=L-1;break}if(++L>=d||(C=u[L])<32||C>126&&C<_){this._printHandler(u,y,L),y=L-1;break}if(++L>=d||(C=u[L])<32||C>126&&C<_){this._printHandler(u,y,L),y=L-1;break}if(++L>=d||(C=u[L])<32||C>126&&C<_){this._printHandler(u,y,L),y=L-1;break}}break;case 3:this._executeHandlers[C]?this._executeHandlers[C]():this._executeHandlerFb(C),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:y,code:C,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const E=this._csiHandlers[this._collect<<8|C];let R=E?E.length-1:-1;for(;R>=0&&(S=E[R](this._params),S!==!0);R--)if(S instanceof Promise)return this._preserveStack(3,E,R,k,y),S;R<0&&this._csiHandlerFb(this._collect<<8|C,this._params),this.precedingCodepoint=0;break;case 8:do switch(C){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(C-48)}while(++y<d&&(C=u[y])>47&&C<60);y--;break;case 9:this._collect<<=8,this._collect|=C;break;case 10:const P=this._escHandlers[this._collect<<8|C];let M=P?P.length-1:-1;for(;M>=0&&(S=P[M](),S!==!0);M--)if(S instanceof Promise)return this._preserveStack(4,P,M,k,y),S;M<0&&this._escHandlerFb(this._collect<<8|C),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|C,this._params);break;case 13:for(let L=y+1;;++L)if(L>=d||(C=u[L])===24||C===26||C===27||C>127&&C<_){this._dcsParser.put(u,y,L),y=L-1;break}break;case 14:if(S=this._dcsParser.unhook(C!==24&&C!==26),S)return this._preserveStack(6,[],0,k,y),S;C===27&&(k|=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 L=y+1;;L++)if(L>=d||(C=u[L])<32||C>127&&C<_){this._oscParser.put(u,y,L),y=L-1;break}break;case 6:if(S=this._oscParser.end(C!==24&&C!==26),S)return this._preserveStack(5,[],0,k,y),S;C===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=w},6242:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const a=n(5770),h=n(482),c=[];i.OscParser=class{constructor(){this._state=0,this._active=c,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,v){this._handlers[g]===void 0&&(this._handlers[g]=[]);const _=this._handlers[g];return _.push(v),{dispose:()=>{const w=_.indexOf(v);w!==-1&&_.splice(w,1)}}}clearHandler(g){this._handlers[g]&&delete this._handlers[g]}setHandlerFallback(g){this._handlerFb=g}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=c}reset(){if(this._state===2)for(let g=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;g>=0;--g)this._active[g].end(!1);this._stack.paused=!1,this._active=c,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||c,this._active.length)for(let g=this._active.length-1;g>=0;g--)this._active[g].start();else this._handlerFb(this._id,"START")}_put(g,v,_){if(this._active.length)for(let w=this._active.length-1;w>=0;w--)this._active[w].put(g,v,_);else this._handlerFb(this._id,"PUT",(0,h.utf32ToString)(g,v,_))}start(){this.reset(),this._state=1}put(g,v,_){if(this._state!==3){if(this._state===1)for(;v<_;){const w=g[v++];if(w===59){this._state=2,this._start();break}if(w<48||57<w)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+w-48}this._state===2&&_-v>0&&this._put(g,v,_)}}end(g,v=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let _=!1,w=this._active.length-1,l=!1;if(this._stack.paused&&(w=this._stack.loopPosition-1,_=v,l=this._stack.fallThrough,this._stack.paused=!1),!l&&_===!1){for(;w>=0&&(_=this._active[w].end(g),_!==!0);w--)if(_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!1,_;w--}for(;w>=0;w--)if(_=this._active[w].end(!1),_ instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=w,this._stack.fallThrough=!0,_}else this._handlerFb(this._id,"END",g);this._active=c,this._id=-1,this._state=0}}},i.OscHandler=class{constructor(g){this._handler=g,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(g,v,_){this._hitLimit||(this._data+=(0,h.utf32ToString)(g,v,_),this._data.length>a.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let v=!1;if(this._hitLimit)v=!1;else if(g&&(v=this._handler(this._data),v instanceof Promise))return v.then((_=>(this._data="",this._hitLimit=!1,_)));return this._data="",this._hitLimit=!1,v}}},8742:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const n=2147483647;class a{static fromArray(c){const g=new a;if(!c.length)return g;for(let v=Array.isArray(c[0])?1:0;v<c.length;++v){const _=c[v];if(Array.isArray(_))for(let w=0;w<_.length;++w)g.addSubParam(_[w]);else g.addParam(_)}return g}constructor(c=32,g=32){if(this.maxLength=c,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(c),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(c),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const c=new a(this.maxLength,this.maxSubParamsLength);return c.params.set(this.params),c.length=this.length,c._subParams.set(this._subParams),c._subParamsLength=this._subParamsLength,c._subParamsIdx.set(this._subParamsIdx),c._rejectDigits=this._rejectDigits,c._rejectSubDigits=this._rejectSubDigits,c._digitIsSub=this._digitIsSub,c}toArray(){const c=[];for(let g=0;g<this.length;++g){c.push(this.params[g]);const v=this._subParamsIdx[g]>>8,_=255&this._subParamsIdx[g];_-v>0&&c.push(Array.prototype.slice.call(this._subParams,v,_))}return c}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(c){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=c>n?n:c}}addSubParam(c){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(c<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=c>n?n:c,this._subParamsIdx[this.length-1]++}}hasSubParams(c){return(255&this._subParamsIdx[c])-(this._subParamsIdx[c]>>8)>0}getSubParams(c){const g=this._subParamsIdx[c]>>8,v=255&this._subParamsIdx[c];return v-g>0?this._subParams.subarray(g,v):null}getSubParamsAll(){const c={};for(let g=0;g<this.length;++g){const v=this._subParamsIdx[g]>>8,_=255&this._subParamsIdx[g];_-v>0&&(c[g]=this._subParams.slice(v,_))}return c}addDigit(c){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const v=this._digitIsSub?this._subParams:this.params,_=v[g-1];v[g-1]=~_?Math.min(10*_+c,n):c}}i.Params=a},5741:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.AddonManager=void 0,i.AddonManager=class{constructor(){this._addons=[]}dispose(){for(let n=this._addons.length-1;n>=0;n--)this._addons[n].instance.dispose()}loadAddon(n,a){const h={instance:a,dispose:a.dispose,isDisposed:!1};this._addons.push(h),a.dispose=()=>this._wrappedAddonDispose(h),a.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let a=-1;for(let h=0;h<this._addons.length;h++)if(this._addons[h]===n){a=h;break}if(a===-1)throw new Error("Could not dispose an addon that has not been loaded");n.isDisposed=!0,n.dispose.apply(n.instance),this._addons.splice(a,1)}}},8771:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const a=n(3785),h=n(511);i.BufferApiView=class{constructor(c,g){this._buffer=c,this.type=g}init(c){return this._buffer=c,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(c){const g=this._buffer.lines.get(c);if(g)return new a.BufferLineApiView(g)}getNullCell(){return new h.CellData}}},3785:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const a=n(511);i.BufferLineApiView=class{constructor(h){this._line=h}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(h,c){if(!(h<0||h>=this._line.length))return c?(this._line.loadCell(h,c),c):this._line.loadCell(h,new a.CellData)}translateToString(h,c,g){return this._line.translateToString(h,c,g)}}},8285:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const a=n(8771),h=n(8460),c=n(844);class g extends c.Disposable{constructor(_){super(),this._core=_,this._onBufferChange=this.register(new h.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new a.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new a.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)}}i.BufferNamespaceApi=g},7975:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,a){return this._core.registerCsiHandler(n,(h=>a(h.toArray())))}addCsiHandler(n,a){return this.registerCsiHandler(n,a)}registerDcsHandler(n,a){return this._core.registerDcsHandler(n,((h,c)=>a(h,c.toArray())))}addDcsHandler(n,a){return this.registerDcsHandler(n,a)}registerEscHandler(n,a){return this._core.registerEscHandler(n,a)}addEscHandler(n,a){return this.registerEscHandler(n,a)}registerOscHandler(n,a){return this._core.registerOscHandler(n,a)}addOscHandler(n,a){return this.registerOscHandler(n,a)}}},7090:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeApi=void 0,i.UnicodeApi=class{constructor(n){this._core=n}register(n){this._core.unicodeService.register(n)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(n){this._core.unicodeService.activeVersion=n}}},744:function(x,i,n){var a=this&&this.__decorate||function(l,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,u,d,f);else for(var j=l.length-1;j>=0;j--)(S=l[j])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(l,u){return function(d,f){u(d,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const c=n(8460),g=n(844),v=n(5295),_=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let w=i.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(l){super(),this.isUserScrolling=!1,this._onResize=this.register(new c.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new c.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(l.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(l.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new v.BufferSet(l,this))}resize(l,u){this.cols=l,this.rows=u,this.buffers.resize(l,u),this._onResize.fire({cols:l,rows:u})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(l,u=!1){const d=this.buffer;let f;f=this._cachedBlankLine,f&&f.length===this.cols&&f.getFg(0)===l.fg&&f.getBg(0)===l.bg||(f=d.getBlankLine(l,u),this._cachedBlankLine=f),f.isWrapped=u;const S=d.ybase+d.scrollTop,C=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;C===d.lines.length-1?k?d.lines.recycle().copyFrom(f):d.lines.push(f.clone()):d.lines.splice(C+1,0,f.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=C-S+1;d.lines.shiftElements(S+1,k-1,-1),d.lines.set(C,f.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(l,u,d){const f=this.buffer;if(l<0){if(f.ydisp===0)return;this.isUserScrolling=!0}else l+f.ydisp>=f.ybase&&(this.isUserScrolling=!1);const S=f.ydisp;f.ydisp=Math.max(Math.min(f.ydisp+l,f.ybase),0),S!==f.ydisp&&(u||this._onScroll.fire(f.ydisp))}};i.BufferService=w=a([h(0,_.IOptionsService)],w)},7994:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CharsetService=void 0,i.CharsetService=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(n){this.glevel=n,this.charset=this._charsets[n]}setgCharset(n,a){this._charsets[n]=a,this.glevel===n&&(this.charset=a)}}},1753:function(x,i,n){var a=this&&this.__decorate||function(f,S,C,k){var j,y=arguments.length,E=y<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(f,S,C,k);else for(var R=f.length-1;R>=0;R--)(j=f[R])&&(E=(y<3?j(E):y>3?j(S,C,E):j(S,C))||E);return y>3&&E&&Object.defineProperty(S,C,E),E},h=this&&this.__param||function(f,S){return function(C,k){S(C,k,f)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const c=n(2585),g=n(8460),v=n(844),_={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:f=>f.button!==4&&f.action===1&&(f.ctrl=!1,f.alt=!1,f.shift=!1,!0)},VT200:{events:19,restrict:f=>f.action!==32},DRAG:{events:23,restrict:f=>f.action!==32||f.button!==3},ANY:{events:31,restrict:f=>!0}};function w(f,S){let C=(f.ctrl?16:0)|(f.shift?4:0)|(f.alt?8:0);return f.button===4?(C|=64,C|=f.action):(C|=3&f.button,4&f.button&&(C|=64),8&f.button&&(C|=128),f.action===32?C|=32:f.action!==0||S||(C|=3)),C}const l=String.fromCharCode,u={DEFAULT:f=>{const S=[w(f,!1)+32,f.col+32,f.row+32];return S[0]>255||S[1]>255||S[2]>255?"":`\x1B[M${l(S[0])}${l(S[1])}${l(S[2])}`},SGR:f=>{const S=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${w(f,!0)};${f.col};${f.row}${S}`},SGR_PIXELS:f=>{const S=f.action===0&&f.button!==4?"m":"M";return`\x1B[<${w(f,!0)};${f.x};${f.y}${S}`}};let d=i.CoreMouseService=class extends v.Disposable{constructor(f,S){super(),this._bufferService=f,this._coreService=S,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._onProtocolChange=this.register(new g.EventEmitter),this.onProtocolChange=this._onProtocolChange.event;for(const C of Object.keys(_))this.addProtocol(C,_[C]);for(const C of Object.keys(u))this.addEncoding(C,u[C]);this.reset()}addProtocol(f,S){this._protocols[f]=S}addEncoding(f,S){this._encodings[f]=S}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(f){if(!this._protocols[f])throw new Error(`unknown protocol "${f}"`);this._activeProtocol=f,this._onProtocolChange.fire(this._protocols[f].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(f){if(!this._encodings[f])throw new Error(`unknown encoding "${f}"`);this._activeEncoding=f}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(f){if(f.col<0||f.col>=this._bufferService.cols||f.row<0||f.row>=this._bufferService.rows||f.button===4&&f.action===32||f.button===3&&f.action!==32||f.button!==4&&(f.action===2||f.action===3)||(f.col++,f.row++,f.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,f,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(f))return!1;const S=this._encodings[this._activeEncoding](f);return S&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(S):this._coreService.triggerDataEvent(S,!0)),this._lastEvent=f,!0}explainEvents(f){return{down:!!(1&f),up:!!(2&f),drag:!!(4&f),move:!!(8&f),wheel:!!(16&f)}}_equalEvents(f,S,C){if(C){if(f.x!==S.x||f.y!==S.y)return!1}else if(f.col!==S.col||f.row!==S.row)return!1;return f.button===S.button&&f.action===S.action&&f.ctrl===S.ctrl&&f.alt===S.alt&&f.shift===S.shift}};i.CoreMouseService=d=a([h(0,c.IBufferService),h(1,c.ICoreService)],d)},6975:function(x,i,n){var a=this&&this.__decorate||function(d,f,S,C){var k,j=arguments.length,y=j<3?f:C===null?C=Object.getOwnPropertyDescriptor(f,S):C;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")y=Reflect.decorate(d,f,S,C);else for(var E=d.length-1;E>=0;E--)(k=d[E])&&(y=(j<3?k(y):j>3?k(f,S,y):k(f,S))||y);return j>3&&y&&Object.defineProperty(f,S,y),y},h=this&&this.__param||function(d,f){return function(S,C){f(S,C,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const c=n(1439),g=n(8460),v=n(844),_=n(2585),w=Object.freeze({insertMode:!1}),l=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let u=i.CoreService=class extends v.Disposable{constructor(d,f,S){super(),this._bufferService=d,this._logService=f,this._optionsService=S,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this.register(new g.EventEmitter),this.onData=this._onData.event,this._onUserInput=this.register(new g.EventEmitter),this.onUserInput=this._onUserInput.event,this._onBinary=this.register(new g.EventEmitter),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this.register(new g.EventEmitter),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=(0,c.clone)(w),this.decPrivateModes=(0,c.clone)(l)}reset(){this.modes=(0,c.clone)(w),this.decPrivateModes=(0,c.clone)(l)}triggerDataEvent(d,f=!1){if(this._optionsService.rawOptions.disableStdin)return;const S=this._bufferService.buffer;f&&this._optionsService.rawOptions.scrollOnUserInput&&S.ybase!==S.ydisp&&this._onRequestScrollToBottom.fire(),f&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((C=>C.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((f=>f.charCodeAt(0))))),this._onBinary.fire(d))}};i.CoreService=u=a([h(0,_.IBufferService),h(1,_.ILogService),h(2,_.IOptionsService)],u)},9074:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const a=n(8055),h=n(8460),c=n(844),g=n(6106);let v=0,_=0;class w extends c.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new h.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new h.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,c.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const f=new l(d);if(f){const S=f.marker.onDispose((()=>f.dispose()));f.onDispose((()=>{f&&(this._decorations.delete(f)&&this._onDecorationRemoved.fire(f),S.dispose())})),this._decorations.insert(f),this._onDecorationRegistered.fire(f)}return f}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,f,S){var C,k,j;let y=0,E=0;for(const R of this._decorations.getKeyIterator(f))y=(C=R.options.x)!==null&&C!==void 0?C:0,E=y+((k=R.options.width)!==null&&k!==void 0?k:1),d>=y&&d<E&&(!S||((j=R.options.layer)!==null&&j!==void 0?j:"bottom")===S)&&(yield R)}forEachDecorationAtCell(d,f,S,C){this._decorations.forEachByKey(f,(k=>{var j,y,E;v=(j=k.options.x)!==null&&j!==void 0?j:0,_=v+((y=k.options.width)!==null&&y!==void 0?y:1),d>=v&&d<_&&(!S||((E=k.options.layer)!==null&&E!==void 0?E:"bottom")===S)&&C(k)}))}}i.DecorationService=w;class l extends c.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=a.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=a.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(d){super(),this.options=d,this.onRenderEmitter=this.register(new h.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new h.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=d.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const a=n(2585),h=n(8343);class c{constructor(...v){this._entries=new Map;for(const[_,w]of v)this.set(_,w)}set(v,_){const w=this._entries.get(v);return this._entries.set(v,_),w}forEach(v){for(const[_,w]of this._entries.entries())v(_,w)}has(v){return this._entries.has(v)}get(v){return this._entries.get(v)}}i.ServiceCollection=c,i.InstantiationService=class{constructor(){this._services=new c,this._services.set(a.IInstantiationService,this)}setService(g,v){this._services.set(g,v)}getService(g){return this._services.get(g)}createInstance(g,...v){const _=(0,h.getServiceDependencies)(g).sort(((u,d)=>u.index-d.index)),w=[];for(const u of _){const d=this._services.get(u.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${u.id}.`);w.push(d)}const l=_.length>0?_[0].index:v.length;if(v.length!==l)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${l+1} conflicts with ${v.length} static arguments`);return new g(...v,...w)}}},7866:function(x,i,n){var a=this&&this.__decorate||function(l,u,d,f){var S,C=arguments.length,k=C<3?u:f===null?f=Object.getOwnPropertyDescriptor(u,d):f;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(l,u,d,f);else for(var j=l.length-1;j>=0;j--)(S=l[j])&&(k=(C<3?S(k):C>3?S(u,d,k):S(u,d))||k);return C>3&&k&&Object.defineProperty(u,d,k),k},h=this&&this.__param||function(l,u){return function(d,f){u(d,f,l)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const c=n(844),g=n(2585),v={trace:g.LogLevelEnum.TRACE,debug:g.LogLevelEnum.DEBUG,info:g.LogLevelEnum.INFO,warn:g.LogLevelEnum.WARN,error:g.LogLevelEnum.ERROR,off:g.LogLevelEnum.OFF};let _,w=i.LogService=class extends c.Disposable{get logLevel(){return this._logLevel}constructor(l){super(),this._optionsService=l,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),_=this}_updateLogLevel(){this._logLevel=v[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(l){for(let u=0;u<l.length;u++)typeof l[u]=="function"&&(l[u]=l[u]())}_log(l,u,d){this._evalLazyOptionalParams(d),l.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+u,...d)}trace(l,...u){var d,f;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,l,u)}debug(l,...u){var d,f;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.log,l,u)}info(l,...u){var d,f;this._logLevel<=g.LogLevelEnum.INFO&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.info,l,u)}warn(l,...u){var d,f;this._logLevel<=g.LogLevelEnum.WARN&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.warn,l,u)}error(l,...u){var d,f;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((f=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&f!==void 0?f:console.error,l,u)}};i.LogService=w=a([h(0,g.IOptionsService)],w),i.setTraceLogger=function(l){_=l},i.traceCall=function(l,u,d){if(typeof d.value!="function")throw new Error("not supported");const f=d.value;d.value=function(...S){if(_.logLevel!==g.LogLevelEnum.TRACE)return f.apply(this,S);_.trace(`GlyphRenderer#${f.name}(${S.map((k=>JSON.stringify(k))).join(", ")})`);const C=f.apply(this,S);return _.trace(`GlyphRenderer#${f.name} return`,C),C}}},7302:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const a=n(8460),h=n(844),c=n(6114);i.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:c.isMac,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRulerWidth:0};const g=["normal","bold","100","200","300","400","500","600","700","800","900"];class v extends h.Disposable{constructor(w){super(),this._onOptionChange=this.register(new a.EventEmitter),this.onOptionChange=this._onOptionChange.event;const l=Object.assign({},i.DEFAULT_OPTIONS);for(const u in w)if(u in l)try{const d=w[u];l[u]=this._sanitizeAndValidateOption(u,d)}catch(d){console.error(d)}this.rawOptions=l,this.options=Object.assign({},l),this._setupOptions()}onSpecificOptionChange(w,l){return this.onOptionChange((u=>{u===w&&l(this.rawOptions[w])}))}onMultipleOptionChange(w,l){return this.onOptionChange((u=>{w.indexOf(u)!==-1&&l()}))}_setupOptions(){const w=u=>{if(!(u in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${u}"`);return this.rawOptions[u]},l=(u,d)=>{if(!(u in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${u}"`);d=this._sanitizeAndValidateOption(u,d),this.rawOptions[u]!==d&&(this.rawOptions[u]=d,this._onOptionChange.fire(u))};for(const u in this.rawOptions){const d={get:w.bind(this,u),set:l.bind(this,u)};Object.defineProperty(this.options,u,d)}}_sanitizeAndValidateOption(w,l){switch(w){case"cursorStyle":if(l||(l=i.DEFAULT_OPTIONS[w]),!(function(u){return u==="block"||u==="underline"||u==="bar"})(l))throw new Error(`"${l}" is not a valid value for ${w}`);break;case"wordSeparator":l||(l=i.DEFAULT_OPTIONS[w]);break;case"fontWeight":case"fontWeightBold":if(typeof l=="number"&&1<=l&&l<=1e3)break;l=g.includes(l)?l:i.DEFAULT_OPTIONS[w];break;case"cursorWidth":l=Math.floor(l);case"lineHeight":case"tabStopWidth":if(l<1)throw new Error(`${w} cannot be less than 1, value: ${l}`);break;case"minimumContrastRatio":l=Math.max(1,Math.min(21,Math.round(10*l)/10));break;case"scrollback":if((l=Math.min(l,4294967295))<0)throw new Error(`${w} cannot be less than 0, value: ${l}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(l<=0)throw new Error(`${w} cannot be less than or equal to 0, value: ${l}`);break;case"rows":case"cols":if(!l&&l!==0)throw new Error(`${w} must be numeric, value: ${l}`);break;case"windowsPty":l=l??{}}return l}}i.OptionsService=v},2660:function(x,i,n){var a=this&&this.__decorate||function(v,_,w,l){var u,d=arguments.length,f=d<3?_:l===null?l=Object.getOwnPropertyDescriptor(_,w):l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")f=Reflect.decorate(v,_,w,l);else for(var S=v.length-1;S>=0;S--)(u=v[S])&&(f=(d<3?u(f):d>3?u(_,w,f):u(_,w))||f);return d>3&&f&&Object.defineProperty(_,w,f),f},h=this&&this.__param||function(v,_){return function(w,l){_(w,l,v)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const c=n(2585);let g=i.OscLinkService=class{constructor(v){this._bufferService=v,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(v){const _=this._bufferService.buffer;if(v.id===void 0){const S=_.addMarker(_.ybase+_.y),C={data:v,id:this._nextId++,lines:[S]};return S.onDispose((()=>this._removeMarkerFromLink(C,S))),this._dataByLinkId.set(C.id,C),C.id}const w=v,l=this._getEntryIdKey(w),u=this._entriesWithId.get(l);if(u)return this.addLineToLink(u.id,_.ybase+_.y),u.id;const d=_.addMarker(_.ybase+_.y),f={id:this._nextId++,key:this._getEntryIdKey(w),data:w,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(f,d))),this._entriesWithId.set(f.key,f),this._dataByLinkId.set(f.id,f),f.id}addLineToLink(v,_){const w=this._dataByLinkId.get(v);if(w&&w.lines.every((l=>l.line!==_))){const l=this._bufferService.buffer.addMarker(_);w.lines.push(l),l.onDispose((()=>this._removeMarkerFromLink(w,l)))}}getLinkData(v){var _;return(_=this._dataByLinkId.get(v))===null||_===void 0?void 0:_.data}_getEntryIdKey(v){return`${v.id};;${v.uri}`}_removeMarkerFromLink(v,_){const w=v.lines.indexOf(_);w!==-1&&(v.lines.splice(w,1),v.lines.length===0&&(v.data.id!==void 0&&this._entriesWithId.delete(v.key),this._dataByLinkId.delete(v.id)))}};i.OscLinkService=g=a([h(0,c.IBufferService)],g)},8343:(x,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const n="di$target",a="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(h){return h[a]||[]},i.createDecorator=function(h){if(i.serviceRegistry.has(h))return i.serviceRegistry.get(h);const c=function(g,v,_){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(w,l,u){l[n]===l?l[a].push({id:w,index:u}):(l[a]=[{id:w,index:u}],l[n]=l)})(c,g,_)};return c.toString=()=>h,i.serviceRegistry.set(h,c),c}},2585:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.IDecorationService=i.IUnicodeService=i.IOscLinkService=i.IOptionsService=i.ILogService=i.LogLevelEnum=i.IInstantiationService=i.ICharsetService=i.ICoreService=i.ICoreMouseService=i.IBufferService=void 0;const a=n(8343);var h;i.IBufferService=(0,a.createDecorator)("BufferService"),i.ICoreMouseService=(0,a.createDecorator)("CoreMouseService"),i.ICoreService=(0,a.createDecorator)("CoreService"),i.ICharsetService=(0,a.createDecorator)("CharsetService"),i.IInstantiationService=(0,a.createDecorator)("InstantiationService"),(function(c){c[c.TRACE=0]="TRACE",c[c.DEBUG=1]="DEBUG",c[c.INFO=2]="INFO",c[c.WARN=3]="WARN",c[c.ERROR=4]="ERROR",c[c.OFF=5]="OFF"})(h||(i.LogLevelEnum=h={})),i.ILogService=(0,a.createDecorator)("LogService"),i.IOptionsService=(0,a.createDecorator)("OptionsService"),i.IOscLinkService=(0,a.createDecorator)("OscLinkService"),i.IUnicodeService=(0,a.createDecorator)("UnicodeService"),i.IDecorationService=(0,a.createDecorator)("DecorationService")},1480:(x,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const a=n(8460),h=n(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new a.EventEmitter,this.onChange=this._onChange.event;const c=new h.UnicodeV6;this.register(c),this._active=c.version,this._activeProvider=c}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(c){if(!this._providers[c])throw new Error(`unknown Unicode version "${c}"`);this._active=c,this._activeProvider=this._providers[c],this._onChange.fire(c)}register(c){this._providers[c.version]=c}wcwidth(c){return this._activeProvider.wcwidth(c)}getStringCellWidth(c){let g=0;const v=c.length;for(let _=0;_<v;++_){let w=c.charCodeAt(_);if(55296<=w&&w<=56319){if(++_>=v)return g+this.wcwidth(w);const l=c.charCodeAt(_);56320<=l&&l<=57343?w=1024*(w-55296)+l-56320+65536:g+=this.wcwidth(l)}g+=this.wcwidth(w)}return g}}}},o={};function p(x){var i=o[x];if(i!==void 0)return i.exports;var n=o[x]={exports:{}};return r[x].call(n.exports,n,n.exports,p),n.exports}var m={};return(()=>{var x=m;Object.defineProperty(x,"__esModule",{value:!0}),x.Terminal=void 0;const i=p(9042),n=p(3236),a=p(844),h=p(5741),c=p(8285),g=p(7975),v=p(7090),_=["cols","rows"];class w extends a.Disposable{constructor(u){super(),this._core=this.register(new n.Terminal(u)),this._addonManager=this.register(new h.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=S=>this._core.options[S],f=(S,C)=>{this._checkReadonlyOptions(S),this._core.options[S]=C};for(const S in this._core.options){const C={get:d.bind(this,S),set:f.bind(this,S)};Object.defineProperty(this._publicOptions,S,C)}}_checkReadonlyOptions(u){if(_.includes(u))throw new Error(`Option "${u}" 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 g.ParserApi(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new v.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 c.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const u=this._core.coreService.decPrivateModes;let d="none";switch(this._core.coreMouseService.activeProtocol){case"X10":d="x10";break;case"VT200":d="vt200";break;case"DRAG":d="drag";break;case"ANY":d="any"}return{applicationCursorKeysMode:u.applicationCursorKeys,applicationKeypadMode:u.applicationKeypad,bracketedPasteMode:u.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:u.origin,reverseWraparoundMode:u.reverseWraparound,sendFocusMode:u.sendFocus,wraparoundMode:u.wraparound}}get options(){return this._publicOptions}set options(u){for(const d in u)this._publicOptions[d]=u[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(u,d){this._verifyIntegers(u,d),this._core.resize(u,d)}open(u){this._core.open(u)}attachCustomKeyEventHandler(u){this._core.attachCustomKeyEventHandler(u)}registerLinkProvider(u){return this._core.registerLinkProvider(u)}registerCharacterJoiner(u){return this._checkProposedApi(),this._core.registerCharacterJoiner(u)}deregisterCharacterJoiner(u){this._checkProposedApi(),this._core.deregisterCharacterJoiner(u)}registerMarker(u=0){return this._verifyIntegers(u),this._core.registerMarker(u)}registerDecoration(u){var d,f,S;return this._checkProposedApi(),this._verifyPositiveIntegers((d=u.x)!==null&&d!==void 0?d:0,(f=u.width)!==null&&f!==void 0?f:0,(S=u.height)!==null&&S!==void 0?S:0),this._core.registerDecoration(u)}hasSelection(){return this._core.hasSelection()}select(u,d,f){this._verifyIntegers(u,d,f),this._core.select(u,d,f)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(u,d){this._verifyIntegers(u,d),this._core.selectLines(u,d)}dispose(){super.dispose()}scrollLines(u){this._verifyIntegers(u),this._core.scrollLines(u)}scrollPages(u){this._verifyIntegers(u),this._core.scrollPages(u)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(u){this._verifyIntegers(u),this._core.scrollToLine(u)}clear(){this._core.clear()}write(u,d){this._core.write(u,d)}writeln(u,d){this._core.write(u),this._core.write(`\r
21
- `,d)}paste(u){this._core.paste(u)}refresh(u,d){this._verifyIntegers(u,d),this._core.refresh(u,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(u){this._addonManager.loadAddon(this,u)}static get strings(){return i}_verifyIntegers(...u){for(const d of u)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...u){for(const d of u)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}x.Terminal=w})(),m})()))})(Yi)),Yi.exports}var gp=pp();var vp=2,xp=1,bp=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let s=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(s._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 s=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),o=parseInt(r.getPropertyValue("height")),p=Math.max(0,parseInt(r.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),x={top:parseInt(m.getPropertyValue("padding-top")),bottom:parseInt(m.getPropertyValue("padding-bottom")),right:parseInt(m.getPropertyValue("padding-right")),left:parseInt(m.getPropertyValue("padding-left"))},i=x.top+x.bottom,n=x.right+x.left,a=o-i,h=p-n-s;return{cols:Math.max(vp,Math.floor(h/e.css.cell.width)),rows:Math.max(xp,Math.floor(a/e.css.cell.height))}}};function _p(e={}){const{cwd:s,cols:r,rows:o,onOutput:p,onExit:m}=e,[x,i]=b.useState(null),[n,a]=b.useState(()=>cs.isConnected()),[h,c]=b.useState(!1),[g,v]=b.useState(!1),[_,w]=b.useState(!1),l=b.useRef({onOutput:p,onExit:m});l.current={onOutput:p,onExit:m};const u=b.useRef(null);u.current=x,b.useEffect(()=>{if(!x)return;const k=cs.getSocket(),j=()=>{a(!0),c(!1),i(null),w(!0)},y=()=>{a(!1),c(!1)},E=L=>{L.terminalId===x&&l.current.onOutput?.(L.data)},R=L=>{L.terminalId===x&&(c(!1),l.current.onExit?.(L.exitCode),i(null))},P=L=>{L.terminalId===x&&c(!0)},M=L=>{L.terminalId===x&&c(!1)};return k.on("connect",j),k.on("disconnect",y),k.on(dt.TERMINAL_STDOUT,E),k.on(dt.TERMINAL_EXIT,R),k.on(dt.TERMINAL_SUBSCRIBED,P),k.on(dt.TERMINAL_UNSUBSCRIBED,M),a(k.connected),k.connected&&k.emit(Ws.SUBSCRIBE,{topic:"terminal",id:x},L=>{L.success&&c(!0)}),()=>{k.off("connect",j),k.off("disconnect",y),k.off(dt.TERMINAL_STDOUT,E),k.off(dt.TERMINAL_EXIT,R),k.off(dt.TERMINAL_SUBSCRIBED,P),k.off(dt.TERMINAL_UNSUBSCRIBED,M),k.emit(Ws.UNSUBSCRIBE,{topic:"terminal",id:x})}},[x]);const d=b.useCallback(async()=>{const k=cs.getSocket();if(!k.connected)return null;v(!0);try{const j=await ye.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return i(j.terminalId),w(!1),j.terminalId}catch(j){return console.error("[useStandaloneTerminal] Failed to create terminal:",j),null}finally{v(!1)}},[s,r,o]),f=b.useCallback(async()=>{const k=u.current;if(k){try{await ye.delete(`/terminals/${k}`)}catch(j){console.error("[useStandaloneTerminal] Failed to destroy terminal:",j)}i(null),c(!1)}},[]),S=b.useCallback(k=>{const j=u.current;if(!j)return;cs.getSocket().emit(Ws.TERMINAL_INPUT,{terminalId:j,data:k})},[]),C=b.useCallback((k,j)=>{const y=u.current;if(!y)return;cs.getSocket().emit(Ws.TERMINAL_RESIZE,{terminalId:y,cols:k,rows:j})},[]);return b.useEffect(()=>()=>{const k=u.current;k&&ye.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:x,isConnected:n,isAttached:h,isCreating:g,needsRecreate:_,create:d,destroy:f,sendInput:S,resize:C}}function yp({terminalRef:e,xtermRef:s,fitAddonRef:r,isVisible:o=!0,onResize:p}){const m=b.useRef(null),x=b.useRef(null),i=b.useRef(0),n=b.useCallback(()=>{m.current!=null&&(window.clearTimeout(m.current),m.current=null),x.current!=null&&(window.cancelAnimationFrame(x.current),x.current=null)},[]),a=b.useCallback(()=>{const g=r.current,v=s.current,_=e.current;if(!g||!v||!_||_.clientWidth<=0||_.clientHeight<=0)return!1;try{return g.fit(),v.cols>0&&v.rows>0&&p(v.cols,v.rows),!0}catch{return!1}},[r,p,e,s]),h=b.useCallback((g=6)=>{n();const v=i.current+1;i.current=v;let _=0;const w=()=>{i.current===v&&(x.current=window.requestAnimationFrame(()=>{if(x.current=null,i.current!==v)return;const l=a(),u=_<2;_<g&&(!l||u)&&(_+=1,m.current=window.setTimeout(w,50))}))};w()},[n,a]),c=b.useCallback(()=>{i.current+=1,n()},[n]);return b.useEffect(()=>c,[c]),b.useEffect(()=>{o&&h(8)},[o,h]),b.useEffect(()=>{const g=e.current;if(!g)return;if(typeof ResizeObserver>"u"){h(8);return}const v=new ResizeObserver(()=>{h(4)});return v.observe(g),g.parentElement&&v.observe(g.parentElement),h(8),()=>{v.disconnect()}},[h,e]),{fitNow:a,scheduleFit:h}}const Sp={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"},wp=ue.memo(function({cwd:s,isVisible:r=!0,onExit:o,onReady:p}){const m=b.useRef(null),x=b.useRef(null),i=b.useRef(null),n=b.useRef(!1),{terminalId:a,isAttached:h,needsRecreate:c,create:g,sendInput:v,resize:_}=_p({cwd:s,onOutput:b.useCallback(u=>{x.current?.write(u)},[]),onExit:b.useCallback(u=>{x.current?.writeln(`\r
22
- \x1B[90m[Process exited with code ${u}]\x1B[0m`),o?.(u)},[o])}),{scheduleFit:w}=yp({terminalRef:m,xtermRef:x,fitAddonRef:i,isVisible:r,onResize:_}),l=b.useCallback(u=>{x.current?.paste(u)},[]);return b.useEffect(()=>{r||x.current?.blur()},[r]),b.useEffect(()=>{if(!c)return;const u=x.current;u&&u.writeln(`\r
23
- \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),g()},[c,g]),b.useLayoutEffect(()=>{if(!m.current)return;const u=new gp.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:Sp,scrollback:5e3,convertEol:!0}),d=new bp;return u.loadAddon(d),u.open(m.current),x.current=u,i.current=d,w(8),()=>{u.dispose(),x.current=null,i.current=null}},[w]),b.useEffect(()=>{n.current||(n.current=!0,g())},[g]),b.useEffect(()=>{const u=x.current;if(!u||!h)return;const d=u.onData(f=>{v(f)});return()=>d.dispose()},[v,h]),b.useEffect(()=>{h&&(w(4),p?.({sendInput:v,paste:l}))},[h,p,l,w,v]),t.jsxs("div",{className:"relative flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[!a&&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:m,className:"terminal-xterm-host flex-1 min-h-0 min-w-0 w-full overflow-hidden"})]})}),Cp=ue.memo(function({commands:s,onSelect:r}){const{t:o}=de(),[p,m]=b.useState(!1),x=b.useRef(null),i=b.useRef(null);return b.useEffect(()=>{if(!p)return;const n=a=>{x.current&&!x.current.contains(a.target)&&i.current&&!i.current.contains(a.target)&&m(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[p]),s.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:i,onClick:()=>m(!p),className:`flex items-center gap-1.5 px-2.5 py-1 mx-1 rounded text-[11px] font-medium transition-colors shrink-0 ${p?"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(iu,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(kt,{size:10,className:`transition-transform ${p?"rotate-180":""}`})]}),p&&t.jsx("div",{ref:x,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:s.map((n,a)=>t.jsxs("button",{onClick:()=>{r(n.command),m(!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(ks,{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:n.name}),t.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:n.command})]})]},a))})})]})]})}),oc="\x1B",kp="\x07",Ep="œ";function jp(e){const s=e.charCodeAt(0);return s>=64&&s<=126}function ra(e,s){let r=s;for(;r<e.length;){if(e[r]===kp||e[r]===Ep)return r+1;if(e[r]===oc&&e[r+1]==="\\")return r+2;r+=1}return r}function ia(e,s){let r=s;for(;r<e.length&&!jp(e[r]);)r+=1;return r<e.length?r+1:r}function Np(e){let s="";for(let r=0;r<e.length;){if(e[r]==="›"){r=ia(e,r+1);continue}if(e[r]===""){r=ra(e,r+1);continue}if(e[r]!==oc){s+=e[r],r+=1;continue}const o=e[r+1];if(o==="["){r=ia(e,r+2);continue}if(o==="]"||o==="P"||o==="X"||o==="^"||o==="_"){r=ra(e,r+2);continue}for(r+=1;r<e.length;){const p=e.charCodeAt(r);if(p<32||p>47)break;r+=1}r<e.length&&(r+=1)}return s}const Rp=200,Ap=1e3,Tp=512*1024;function Mp(e){let s=e.reduce((o,p)=>o+p.data.length,0),r=0;for(;e.length-r>Ap||s>Tp&&e.length-r>1;)s-=e[r].data.length,r+=1;return{entries:r>0?e.slice(r):e,trimmed:r>0}}function Dp(e,s){const r=!!e&&e.runtimeInstanceId!==s.runtimeInstanceId,o=r||s.reset,p=o?[]:e?.entries??[],m=new Set(p.map(n=>n.seq)),x=[...p,...s.entries.filter(n=>!m.has(n.seq))].sort((n,a)=>n.seq-a.seq),i=Mp(x);return{...s,entries:i.entries,reset:s.reset||r||!o&&(e?.reset??!1),truncated:s.truncated||!o&&(e?.truncated??!1)||i.trimmed}}function ao(e,s=!0){return Et({queryKey:ce.workspaceServices.list(e),queryFn:async()=>(await ye.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:s&&!!e,refetchInterval:s&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function Pp(e,s,r,o=!0){const p=vt(),m=ce.workspaceServices.logs(e,s);return Et({queryKey:m,queryFn:async()=>{const x=p.getQueryData(m),i=x?Math.max(0,x.nextSeq-1):0,n=x===void 0?r:x.runtimeInstanceId,a=new URLSearchParams({limit:String(Rp)});n!==null&&a.set("runtimeInstanceId",n),a.set("afterSeq",String(i));const h=await ye.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(s)}/logs?${a}`);return Dp(x,h)},enabled:o&&!!e&&!!s,refetchInterval:x=>x.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const Lp=[];function Xi(e){return JSON.stringify([e.command,...e.args])}function na(e,s,r){if(!e)return r;const o=new Date(e);return Number.isNaN(o.getTime())?r:new Intl.DateTimeFormat(s,{dateStyle:"medium",timeStyle:"medium"}).format(o)}function Ip(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 oa({state:e}){const{t:s}=de(),r=Ip(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:Z("h-1.5 w-1.5 rounded-full",r.dotClassName),"aria-hidden":"true"}),s(r.label)]})}function Op({message:e,onRetry:s}){const{t:r}=de();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(As,{size:14,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{children:e}),t.jsx("button",{type:"button",onClick:s,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:r("Retry"),"aria-label":r("Retry"),children:t.jsx(Ts,{size:13})})]})}function Bp({workspaceId:e,enabled:s=!0}){const{locale:r,t:o}=de(),p=ao(e,s),m=p.data??Lp,[x,i]=b.useState(null),n=m.find(v=>v.name===x)??m[0]??null,a=Pp(e,n?.name??"",n?.runtimeInstanceId??null,s&&!!n),h=b.useMemo(()=>Np(a.data?.entries.map(v=>v.data).join("")??""),[a.data?.entries]),c=b.useRef(null),g=b.useRef(!0);return b.useEffect(()=>{g.current=!0},[n?.id,n?.runtimeInstanceId]),b.useEffect(()=>{const v=c.current;v&&g.current&&(v.scrollTop=v.scrollHeight)},[h]),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(hn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":"true"}),t.jsx("h2",{className:"truncate text-xs font-medium",children:o("Background services")})]}),!p.isLoading&&!p.isError&&t.jsx("span",{className:"text-[11px] tabular-nums text-neutral-500",children:m.length})]}),t.jsx("div",{className:"min-h-0 flex-1 overflow-y-auto scrollbar-app-thin",children:p.isLoading?t.jsxs("div",{className:"flex min-h-24 items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading background services...")]}):p.isError?t.jsx(Op,{message:o("Failed to load background services."),onRetry:()=>{p.refetch()}}):m.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(hn,{size:22,"aria-hidden":"true"}),t.jsx("span",{children:o("No background services")})]}):m.map(v=>{const _=v.name===n?.name;return t.jsxs("button",{type:"button",onClick:()=>i(v.name),"aria-pressed":_,className:Z("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",_?"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:v.name}),t.jsx(oa,{state:v.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[10px] text-neutral-500",title:Xi(v),children:Xi(v)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(Un,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:v.relativeCwd||"."})]}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(hs,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:na(v.startedAt,r,o("Not started"))})]})]},v.id)})})]}),t.jsx("section",{className:"flex min-h-0 min-w-0 flex-1 flex-col bg-[#1e1e1e]","aria-label":o("Background service logs"),children:n?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:n.name}),t.jsx(oa,{state:n.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":`${n.name} ${o("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:[o("Command"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:Xi(n)})]}),t.jsxs("div",{className:"flex min-w-0 gap-1.5",children:[t.jsxs("dt",{className:"shrink-0",children:[o("Working directory"),":"]}),t.jsx("dd",{className:"min-w-0 break-all font-mono text-neutral-400",children:n.relativeCwd||"."})]}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1.5 sm:col-span-2",children:[t.jsx(hs,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsxs("dt",{className:"shrink-0",children:[o("Started"),":"]}),t.jsx("dd",{className:"truncate text-neutral-400",children:na(n.startedAt,r,o("Not started"))})]})]}),n.lastError&&t.jsx("p",{className:"mt-1.5 break-words text-[10px] text-red-300",role:"alert",children:n.lastError})]})]}),(a.data?.truncated||a.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:o("Earlier log output is unavailable.")}),a.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:o("Failed to refresh service logs.")}),t.jsx("button",{type:"button",onClick:()=>{a.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:o("Retry"),"aria-label":o("Retry"),children:t.jsx(Ts,{size:11})})]}),t.jsx("div",{ref:c,onScroll:v=>{const _=v.currentTarget;g.current=_.scrollHeight-_.scrollTop-_.clientHeight<32},className:"min-h-0 flex-1 overflow-auto p-3 scrollbar-app-thin",role:"log","aria-live":"off",tabIndex:0,children:a.isLoading&&!a.data?t.jsxs("div",{className:"flex h-full items-center justify-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading service logs...")]}):h?t.jsx("pre",{className:"m-0 whitespace-pre-wrap break-words font-mono text-[11px] leading-5 text-neutral-300",children:h}):t.jsx("div",{className:"flex h-full items-center justify-center text-xs text-neutral-500",children:o("No logs yet")})})]}):t.jsx("div",{className:"flex h-full items-center justify-center px-4 text-center text-xs text-neutral-500",children:p.isLoading?o("Loading background services..."):o("Select a background service")})})]})}let Gi=0;function aa(){return Gi+=1,{id:`shell-${Gi}`,order:Gi}}const Fp=ue.memo(function({cwd:s,isVisible:r=!0,workspaceId:o,quickCommands:p=[]}){const{t:m}=de(),[x,i]=b.useState(()=>[aa()]),[n,a]=b.useState(()=>x[0].id),[h,c]=b.useState(()=>new Set),[g,v]=b.useState(!1),[_,w]=b.useState(!1),[l,u]=b.useState(""),[d,f]=b.useState(null),[S,C]=b.useState("terminals"),k=b.useRef(new Map),j=o?S:"terminals",y=b.useCallback(T=>{k.current.delete(T),c(O=>{if(!O.has(T))return O;const K=new Set(O);return K.delete(T),K})},[]),E=b.useCallback(()=>{const T=aa();i(O=>[...O,T]),a(T.id)},[]),R=b.useCallback((T,O)=>{O.stopPropagation(),y(T),i(K=>{const V=K.filter(B=>B.id!==T);return T===n&&V.length>0&&a(V[V.length-1].id),V})},[n,y]),P=b.useCallback(T=>{y(T),i(O=>{const K=O.filter(V=>V.id!==T);return T===n&&K.length>0&&a(K[K.length-1].id),K})},[n,y]),M=b.useCallback((T,O)=>{k.current.set(T,O),c(K=>{if(K.has(T))return K;const V=new Set(K);return V.add(T),V})},[]),L=b.useCallback(T=>{const O=k.current.get(n);O&&O.sendInput(T+"\r")},[n]),z=b.useCallback((T,O="")=>{f(T),u(O),w(!0)},[]),I=b.useCallback((T,O)=>{const K=k.current.get(T);return K?(K.paste(O),ot.success(m("Pasted into terminal")),!0):(ot.error(m("Terminal is not ready")),!1)},[m]),W=b.useCallback(async()=>{if(!k.current.has(n)){ot.error(m("Terminal is not ready"));return}const T=navigator.clipboard;if(!T?.readText){z(n);return}v(!0);try{const O=await T.readText();if(!O||O.includes(`
24
- `)||O.includes("\r")){z(n,O);return}I(n,O)}catch{z(n)}finally{v(!1)}},[n,z,I,m]),$=b.useCallback(()=>{!l||!d||!I(d,l)||(w(!1),u(""),f(null))},[l,I,d]),A=b.useCallback(()=>{w(!1),u(""),f(null)},[]),D=h.has(n);return t.jsxs("div",{className:"flex h-full w-full min-h-0 min-w-0 flex-col overflow-hidden bg-[#1e1e1e]",children:[o&&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:()=>C("terminals"),"aria-pressed":j==="terminals",className:Z("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",j==="terminals"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(hr,{size:12,"aria-hidden":"true"}),m("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>C("services"),"aria-pressed":j==="services",className:Z("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",j==="services"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(hn,{size:12,"aria-hidden":"true"}),m("Background services")]})]}),t.jsxs("div",{"aria-hidden":j!=="terminals",className:Z("min-h-0 flex-1 flex-col",j==="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:x.map(T=>t.jsxs("button",{onClick:()=>a(T.id),className:Z("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",T.id===n?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[t.jsx(hr,{size:11,className:"shrink-0"}),t.jsx("span",{children:m("Shell {count}",{count:T.order})}),x.length>1&&t.jsx("span",{onClick:O=>R(T.id,O),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:t.jsx(Gt,{size:10})})]},T.id))}),x.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:W,disabled:!D||g,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:m("Paste into terminal"),"aria-label":m("Paste into terminal"),children:g?t.jsx(Be,{size:18,className:"animate-spin"}):t.jsx(ku,{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:m("New Terminal"),"aria-label":m("New Terminal"),children:t.jsx(us,{size:14})}),p.length>0&&t.jsx(Cp,{commands:p,onSelect:L})]}),t.jsx("div",{className:"flex-1 min-h-0 min-w-0 overflow-hidden relative",children:x.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(hr,{size:28}),t.jsx("span",{className:"text-xs",children:m("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:m("New Terminal")})]})}):x.map(T=>t.jsx("div",{"aria-hidden":T.id!==n,className:Z("absolute inset-0 h-full w-full min-h-0 min-w-0 overflow-hidden",T.id===n?"visible pointer-events-auto":"invisible pointer-events-none"),children:t.jsx(wp,{cwd:s,isVisible:r&&j==="terminals"&&T.id===n,onExit:()=>P(T.id),onReady:O=>M(T.id,O)})},T.id))})]}),o&&j==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Bp,{workspaceId:o,enabled:r})}),t.jsx(gs,{isOpen:_,onClose:A,title:m("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:A,className:"min-h-11 px-4 text-sm font-medium text-neutral-600 transition-colors hover:text-neutral-900",children:m("Cancel")}),t.jsx("button",{type:"button",onClick:$,disabled:!l,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:m("Paste")})]}),children:t.jsx(fu,{autoFocus:!0,value:l,onChange:T=>u(T.target.value),placeholder:m("Paste terminal input here"),"aria-label":m("Terminal paste content"),className:"min-h-32 resize-none bg-white font-mono"})})]})});function la(e,s){(s==null||s>e.length)&&(s=e.length);for(var r=0,o=Array(s);r<s;r++)o[r]=e[r];return o}function zp(e){if(Array.isArray(e))return e}function Wp(e,s,r){return(s=Yp(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Hp(e,s){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var o,p,m,x,i=[],n=!0,a=!1;try{if(m=(r=r.call(e)).next,s!==0)for(;!(n=(o=m.call(r)).done)&&(i.push(o.value),i.length!==s);n=!0);}catch(h){a=!0,p=h}finally{try{if(!n&&r.return!=null&&(x=r.return(),Object(x)!==x))return}finally{if(a)throw p}}return i}}function Up(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
25
- In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ca(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function da(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?ca(Object(r),!0).forEach(function(o){Wp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ca(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function $p(e,s){if(e==null)return{};var r,o,p=qp(e,s);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(e);for(o=0;o<m.length;o++)r=m[o],s.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(p[r]=e[r])}return p}function qp(e,s){if(e==null)return{};var r={};for(var o in e)if({}.hasOwnProperty.call(e,o)){if(s.indexOf(o)!==-1)continue;r[o]=e[o]}return r}function Kp(e,s){return zp(e)||Hp(e,s)||Xp(e,s)||Up()}function Vp(e,s){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var o=r.call(e,s);if(typeof o!="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(s==="string"?String:Number)(e)}function Yp(e){var s=Vp(e,"string");return typeof s=="symbol"?s:s+""}function Xp(e,s){if(e){if(typeof e=="string")return la(e,s);var r={}.toString.call(e).slice(8,-1);return r==="Object"&&e.constructor&&(r=e.constructor.name),r==="Map"||r==="Set"?Array.from(e):r==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?la(e,s):void 0}}function Gp(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function ua(e,s){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);s&&(o=o.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,o)}return r}function ha(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?ua(Object(r),!0).forEach(function(o){Gp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ua(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Qp(){for(var e=arguments.length,s=new Array(e),r=0;r<e;r++)s[r]=arguments[r];return function(o){return s.reduceRight(function(p,m){return m(p)},o)}}function ur(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var x=arguments.length,i=new Array(x),n=0;n<x;n++)i[n]=arguments[n];return s.apply(r,[].concat(p,i))}}}function di(e){return{}.toString.call(e).includes("Object")}function Zp(e){return!Object.keys(e).length}function Sr(e){return typeof e=="function"}function Jp(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function eg(e,s){return di(s)||ms("changeType"),Object.keys(s).some(function(r){return!Jp(e,r)})&&ms("changeField"),s}function tg(e){Sr(e)||ms("selectorType")}function sg(e){Sr(e)||di(e)||ms("handlerType"),di(e)&&Object.values(e).some(function(s){return!Sr(s)})&&ms("handlersType")}function rg(e){e||ms("initialIsRequired"),di(e)||ms("initialType"),Zp(e)&&ms("initialContent")}function ig(e,s){throw new Error(e[s]||e.default)}var ng={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"},ms=ur(ig)(ng),$r={changes:eg,selector:tg,handler:sg,initial:rg};function og(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};$r.initial(e),$r.handler(s);var r={current:e},o=ur(cg)(r,s),p=ur(lg)(r),m=ur($r.changes)(e),x=ur(ag)(r);function i(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(h){return h};return $r.selector(a),a(r.current)}function n(a){Qp(o,p,m,x)(a)}return[i,n]}function ag(e,s){return Sr(s)?s(e.current):s}function lg(e,s){return e.current=ha(ha({},e.current),s),s}function cg(e,s,r){return Sr(s)?s(e.current):Object.keys(r).forEach(function(o){var p;return(p=s[o])===null||p===void 0?void 0:p.call(s,e.current[o])}),r}var dg={create:og},ug={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function hg(e){return function s(){for(var r=this,o=arguments.length,p=new Array(o),m=0;m<o;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var x=arguments.length,i=new Array(x),n=0;n<x;n++)i[n]=arguments[n];return s.apply(r,[].concat(p,i))}}}function fg(e){return{}.toString.call(e).includes("Object")}function mg(e){return e||fa("configIsRequired"),fg(e)||fa("configType"),e.urls?(pg(),{paths:{vs:e.urls.monacoBase}}):e}function pg(){console.warn(ac.deprecation)}function gg(e,s){throw new Error(e[s]||e.default)}var ac={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!
26
- You are using deprecated way of configuration.
27
-
28
- Instead of using
29
- monaco.config({ urls: { monacoBase: '...' } })
30
- use
31
- monaco.config({ paths: { vs: '...' } })
32
-
33
- For more please check the link https://github.com/suren-atoyan/monaco-loader#config
34
- `},fa=hg(gg)(ac),vg={config:mg},xg=function(){for(var s=arguments.length,r=new Array(s),o=0;o<s;o++)r[o]=arguments[o];return function(p){return r.reduceRight(function(m,x){return x(m)},p)}};function lc(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],lc(e[r],s[r]))}),da(da({},e),s)}var bg={type:"cancelation",msg:"operation is manually canceled"};function Qi(e){var s=!1,r=new Promise(function(o,p){e.then(function(m){return s?p(bg):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var _g=["monaco"],yg=dg.create({config:ug,isInitialized:!1,resolve:null,reject:null,monaco:null}),cc=Kp(yg,2),Nr=cc[0],Ei=cc[1];function Sg(e){var s=vg.config(e),r=s.monaco,o=$p(s,_g);Ei(function(p){return{config:lc(p.config,o),monaco:r}})}function wg(){var e=Nr(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(Ei({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Qi(Zi);if(window.monaco&&window.monaco.editor)return dc(window.monaco),e.resolve(window.monaco),Qi(Zi);xg(Cg,Eg)(jg)}return Qi(Zi)}function Cg(e){return document.body.appendChild(e)}function kg(e){var s=document.createElement("script");return e&&(s.src=e),s}function Eg(e){var s=Nr(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=kg("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function jg(){var e=Nr(function(r){var o=r.config,p=r.resolve,m=r.reject;return{config:o,resolve:p,reject:m}}),s=window.require;s.config(e.config),s(["vs/editor/editor.main"],function(r){var o=r.m||r;dc(o),e.resolve(o)},function(r){e.reject(r)})}function dc(e){Nr().monaco||Ei({monaco:e})}function Ng(){return Nr(function(e){var s=e.monaco;return s})}var Zi=new Promise(function(e,s){return Ei({resolve:e,reject:s})}),uc={config:Sg,init:wg,__getMonacoInstance:Ng},Rg={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Ji=Rg,Ag={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Tg=Ag;function Mg({children:e}){return ue.createElement("div",{style:Tg.container},e)}var Dg=Mg,Pg=Dg;function Lg({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:x}){return ue.createElement("section",{style:{...Ji.wrapper,width:e,height:s},...x},!r&&ue.createElement(Pg,null,o),ue.createElement("div",{ref:p,style:{...Ji.fullWidth,...!r&&Ji.hide},className:m}))}var Ig=Lg,hc=b.memo(Ig);function Og(e){b.useEffect(e,[])}var fc=Og;function Bg(e,s,r=!0){let o=b.useRef(!0);b.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var Rt=Bg;function gr(){}function Hs(e,s,r,o){return Fg(e,o)||zg(e,s,r,o)}function Fg(e,s){return e.editor.getModel(mc(e,s))}function zg(e,s,r,o){return e.editor.createModel(s,r,o?mc(e,o):void 0)}function mc(e,s){return e.Uri.parse(s)}function Wg({original:e,modified:s,language:r,originalLanguage:o,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:x,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:n=!1,theme:a="light",loading:h="Loading...",options:c={},height:g="100%",width:v="100%",className:_,wrapperProps:w={},beforeMount:l=gr,onMount:u=gr}){let[d,f]=b.useState(!1),[S,C]=b.useState(!0),k=b.useRef(null),j=b.useRef(null),y=b.useRef(null),E=b.useRef(u),R=b.useRef(l),P=b.useRef(!1);fc(()=>{let I=uc.init();return I.then(W=>(j.current=W)&&C(!1)).catch(W=>W?.type!=="cancelation"&&console.error("Monaco initialization: error:",W)),()=>k.current?z():I.cancel()}),Rt(()=>{if(k.current&&j.current){let I=k.current.getOriginalEditor(),W=Hs(j.current,e||"",o||r||"text",m||"");W!==I.getModel()&&I.setModel(W)}},[m],d),Rt(()=>{if(k.current&&j.current){let I=k.current.getModifiedEditor(),W=Hs(j.current,s||"",p||r||"text",x||"");W!==I.getModel()&&I.setModel(W)}},[x],d),Rt(()=>{let I=k.current.getModifiedEditor();I.getOption(j.current.editor.EditorOption.readOnly)?I.setValue(s||""):s!==I.getValue()&&(I.executeEdits("",[{range:I.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),I.pushUndoStop())},[s],d),Rt(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),Rt(()=>{let{original:I,modified:W}=k.current.getModel();j.current.editor.setModelLanguage(I,o||r||"text"),j.current.editor.setModelLanguage(W,p||r||"text")},[r,o,p],d),Rt(()=>{j.current?.editor.setTheme(a)},[a],d),Rt(()=>{k.current?.updateOptions(c)},[c],d);let M=b.useCallback(()=>{if(!j.current)return;R.current(j.current);let I=Hs(j.current,e||"",o||r||"text",m||""),W=Hs(j.current,s||"",p||r||"text",x||"");k.current?.setModel({original:I,modified:W})},[r,s,p,e,o,m,x]),L=b.useCallback(()=>{!P.current&&y.current&&(k.current=j.current.editor.createDiffEditor(y.current,{automaticLayout:!0,...c}),M(),j.current?.editor.setTheme(a),f(!0),P.current=!0)},[c,a,M]);b.useEffect(()=>{d&&E.current(k.current,j.current)},[d]),b.useEffect(()=>{!S&&!d&&L()},[S,d,L]);function z(){let I=k.current?.getModel();i||I?.original?.dispose(),n||I?.modified?.dispose(),k.current?.dispose()}return ue.createElement(hc,{width:v,height:g,isEditorReady:d,loading:h,_ref:y,className:_,wrapperProps:w})}var Hg=Wg;b.memo(Hg);function Ug(e){let s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}var $g=Ug,qr=new Map;function qg({defaultValue:e,defaultLanguage:s,defaultPath:r,value:o,language:p,path:m,theme:x="light",line:i,loading:n="Loading...",options:a={},overrideServices:h={},saveViewState:c=!0,keepCurrentModel:g=!1,width:v="100%",height:_="100%",className:w,wrapperProps:l={},beforeMount:u=gr,onMount:d=gr,onChange:f,onValidate:S=gr}){let[C,k]=b.useState(!1),[j,y]=b.useState(!0),E=b.useRef(null),R=b.useRef(null),P=b.useRef(null),M=b.useRef(d),L=b.useRef(u),z=b.useRef(),I=b.useRef(o),W=$g(m),$=b.useRef(!1),A=b.useRef(!1);fc(()=>{let O=uc.init();return O.then(K=>(E.current=K)&&y(!1)).catch(K=>K?.type!=="cancelation"&&console.error("Monaco initialization: error:",K)),()=>R.current?T():O.cancel()}),Rt(()=>{let O=Hs(E.current,e||o||"",s||p||"",m||r||"");O!==R.current?.getModel()&&(c&&qr.set(W,R.current?.saveViewState()),R.current?.setModel(O),c&&R.current?.restoreViewState(qr.get(m)))},[m],C),Rt(()=>{R.current?.updateOptions(a)},[a],C),Rt(()=>{!R.current||o===void 0||(R.current.getOption(E.current.editor.EditorOption.readOnly)?R.current.setValue(o):o!==R.current.getValue()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.current=!1))},[o],C),Rt(()=>{let O=R.current?.getModel();O&&p&&E.current?.editor.setModelLanguage(O,p)},[p],C),Rt(()=>{i!==void 0&&R.current?.revealLine(i)},[i],C),Rt(()=>{E.current?.editor.setTheme(x)},[x],C);let D=b.useCallback(()=>{if(!(!P.current||!E.current)&&!$.current){L.current(E.current);let O=m||r,K=Hs(E.current,o||e||"",s||p||"",O||"");R.current=E.current?.editor.create(P.current,{model:K,automaticLayout:!0,...a},h),c&&R.current.restoreViewState(qr.get(O)),E.current.editor.setTheme(x),i!==void 0&&R.current.revealLine(i),k(!0),$.current=!0}},[e,s,r,o,p,m,a,h,c,x,i]);b.useEffect(()=>{C&&M.current(R.current,E.current)},[C]),b.useEffect(()=>{!j&&!C&&D()},[j,C,D]),I.current=o,b.useEffect(()=>{C&&f&&(z.current?.dispose(),z.current=R.current?.onDidChangeModelContent(O=>{A.current||f(R.current.getValue(),O)}))},[C,f]),b.useEffect(()=>{if(C){let O=E.current.editor.onDidChangeMarkers(K=>{let V=R.current.getModel()?.uri;if(V&&K.find(B=>B.path===V.path)){let B=E.current.editor.getModelMarkers({resource:V});S?.(B)}});return()=>{O?.dispose()}}return()=>{}},[C,S]);function T(){z.current?.dispose(),g?c&&qr.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return ue.createElement(hc,{width:v,height:_,isEditorReady:C,loading:n,_ref:P,className:w,wrapperProps:l})}var Kg=qg,Vg=b.memo(Kg),Yg=Vg,Lt=function(e,s){return Number(e.toFixed(s))},Xg=function(e,s){return typeof e=="number"?e:s},Ze=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Gg=function(e){return-Math.cos(e*Math.PI)/2+.5},Qg=function(e){return e},Zg=function(e){return e*e},Jg=function(e){return e*(2-e)},ev=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},tv=function(e){return e*e*e},sv=function(e){return--e*e*e+1},rv=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},iv=function(e){return e*e*e*e},nv=function(e){return 1- --e*e*e*e},ov=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},av=function(e){return e*e*e*e*e},lv=function(e){return 1+--e*e*e*e*e},cv=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},pc={easeOut:Gg,linear:Qg,easeInQuad:Zg,easeOutQuad:Jg,easeInOutQuad:ev,easeInCubic:tv,easeOutCubic:sv,easeInOutCubic:rv,easeInQuart:iv,easeOutQuart:nv,easeInOutQuart:ov,easeInQuint:av,easeOutQuint:lv,easeInOutQuint:cv},gc=function(e){typeof e=="number"&&cancelAnimationFrame(e)},zt=function(e){e.mounted&&(gc(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function vc(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;zt(e),e.animation=function(){if(!e.mounted)return gc(e.animation);var x=new Date().getTime()-p,i=x/r,n=pc[s],a=n(i);x>=r?(o(m),e.animation=null):e.animation&&(o(a),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function dv(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function xs(e,s,r,o){var p=dv(s);if(!(!e.mounted||!p)){var m=e.setTransformState,x=e.transformState,i=x.scale,n=x.positionX,a=x.positionY,h=s.scale-i,c=s.positionX-n,g=s.positionY-a;r===0?m(s.scale,s.positionX,s.positionY):vc(e,o,r,function(v){var _=i+h*v,w=n+c*v,l=a+g*v;m(_,w,l)})}}function uv(e,s,r){var o=e.offsetWidth,p=e.offsetHeight,m=s.offsetWidth,x=s.offsetHeight,i=m*r,n=x*r,a=o-i,h=p-n;return{wrapperWidth:o,wrapperHeight:p,newContentWidth:i,newDiffWidth:a,newContentHeight:n,newDiffHeight:h}}var hv=function(e,s,r,o,p,m,x){var i=e>s?r*(x?1:.5):0,n=o>p?m*(x?1:.5):0,a=e-s-i,h=i,c=o-p-n,g=n;return{minPositionX:a,maxPositionX:h,minPositionY:c,maxPositionY:g}},lo=function(e,s){var r=e.wrapperComponent,o=e.contentComponent,p=e.setup.centerZoomedOut;if(!r||!o)throw new Error("Components are not mounted");var m=uv(r,o,s),x=m.wrapperWidth,i=m.wrapperHeight,n=m.newContentWidth,a=m.newDiffWidth,h=m.newContentHeight,c=m.newDiffHeight,g=hv(x,n,a,i,h,c,!!p);return g},wn=function(e,s,r,o){return o?e<s?Lt(s,2):e>r?Lt(r,2):Lt(e,2):Lt(e,2)},Es=function(e,s){var r=lo(e,s);return e.bounds=r,r};function Rr(e,s,r,o,p,m,x){var i=r.minPositionX,n=r.minPositionY,a=r.maxPositionX,h=r.maxPositionY,c=0,g=0;x&&(c=p,g=m);var v=wn(e,i-c,a+c,o),_=wn(s,n-g,h+g,o);return{x:v,y:_}}function ji(e,s,r,o,p,m){var x=e.transformState,i=x.scale,n=x.positionX,a=x.positionY,h=o-i;if(typeof s!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:a};var c=n-s*h,g=a-r*h,v=Rr(c,g,p,m,0,0,null);return v}function Ar(e,s,r,o,p){var m=p?o:0,x=s-m;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(s)&&e<=x?x:e}var ma=function(e,s){var r=e.setup.panning.excluded,o=e.isInitialized,p=e.wrapperComponent,m=s.target,x="shadowRoot"in m&&"composedPath"in s,i=x?s.composedPath().some(function(h){return h instanceof Element?p?.contains(h):!1}):p?.contains(m),n=o&&m&&i;if(!n)return!1;var a=Ni(m,r);return!a},pa=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},fv=function(e,s){var r=e.transformState,o=r.positionX,p=r.positionY;e.isPanning=!0;var m=s.clientX,x=s.clientY;e.startCoords={x:m-o,y:x-p}},mv=function(e,s){var r=s.touches,o=e.transformState,p=o.positionX,m=o.positionY;e.isPanning=!0;var x=r.length===1;if(x){var i=r[0].clientX,n=r[0].clientY;e.startCoords={x:i-p,y:n-m}}};function pv(e){var s=e.transformState,r=s.positionX,o=s.positionY,p=s.scale,m=e.setup,x=m.disabled,i=m.limitToBounds,n=m.centerZoomedOut,a=e.wrapperComponent;if(!(x||!a||!e.bounds)){var h=e.bounds,c=h.maxPositionX,g=h.minPositionX,v=h.maxPositionY,_=h.minPositionY,w=r>c||r<g,l=o>v||o<_,u=r>c?a.offsetWidth:e.setup.minPositionX||0,d=o>v?a.offsetHeight:e.setup.minPositionY||0,f=ji(e,u,d,p,e.bounds,i||n),S=f.x,C=f.y;return{scale:p,positionX:w?S:r,positionY:l?C:o}}}function xc(e,s,r,o,p){var m=e.setup.limitToBounds,x=e.wrapperComponent,i=e.bounds,n=e.transformState,a=n.scale,h=n.positionX,c=n.positionY;if(!(x===null||i===null||s===h&&r===c)){var g=Rr(s,r,i,m,o,p,x),v=g.x,_=g.y;e.setTransformState(a,v,_)}}var gv=function(e,s,r){var o=e.startCoords,p=e.transformState,m=e.setup.panning,x=m.lockAxisX,i=m.lockAxisY,n=p.positionX,a=p.positionY;if(!o)return{x:n,y:a};var h=s-o.x,c=r-o.y,g=x?n:h,v=i?a:c;return{x:g,y:v}},vs=function(e,s){var r=e.setup,o=e.transformState,p=o.scale,m=r.minScale,x=r.disablePadding;return s>0&&p>=m&&!x?s:0},vv=function(e){var s=e.mounted,r=e.setup,o=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,x=p.disabled,i=!x||m>1||!o||s;return!!i},xv=function(e){var s=e.mounted,r=e.velocity,o=e.bounds,p=e.setup,m=p.disabled,x=p.velocityAnimation,i=e.transformState.scale,n=x.disabled,a=!n||i>1||!m||s;return!(!a||!r||!o)};function bv(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function ga(e,s,r,o,p,m,x,i,n,a){if(p){if(s>x&&r>x){var h=x+(e-x)*a;return h>n?n:h<x?x:h}if(s<m&&r<m){var h=m+(e-m)*a;return h<i?i:h>m?m:h}}return o?s:wn(e,m,x,p)}function _v(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function yv(e,s){var r=vv(e);if(r){var o=e.lastMousePosition,p=e.velocityTime,m=e.setup,x=e.wrapperComponent,i=m.velocityAnimation.equalToMove,n=Date.now();if(o&&p&&x){var a=_v(x,i),h=s.x-o.x,c=s.y-o.y,g=h/a,v=c/a,_=n-p,w=h*h+c*c,l=Math.sqrt(w)/_;e.velocity={velocityX:g,velocityY:v,total:l}}e.lastMousePosition=s,e.velocityTime=n}}function Sv(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=xv(e);if(!(!m||!s||!r||!p)){var x=s.velocityX,i=s.velocityY,n=s.total,a=r.maxPositionX,h=r.minPositionX,c=r.maxPositionY,g=r.minPositionY,v=o.limitToBounds,_=o.alignmentAnimation,w=o.zoomAnimation,l=o.panning,u=l.lockAxisY,d=l.lockAxisX,f=w.animationType,S=_.sizeX,C=_.sizeY,k=_.velocityAlignmentTime,j=k,y=bv(e,n),E=Math.max(y,j),R=vs(e,S),P=vs(e,C),M=R*p.offsetWidth/100,L=P*p.offsetHeight/100,z=a+M,I=h-M,W=c+L,$=g-L,A=e.transformState,D=new Date().getTime();vc(e,f,E,function(T){var O=e.transformState,K=O.scale,V=O.positionX,B=O.positionY,U=new Date().getTime()-D,H=U/j,N=pc[_.animationType],F=1-N(Math.min(1,H)),q=1-T,Y=V+x*q,se=B+i*q,G=ga(Y,A.positionX,V,d,v,h,a,I,z,F),pe=ga(se,A.positionY,B,u,v,g,c,$,W,F);(V!==Y||B!==se)&&e.setTransformState(K,G,pe)})}}function va(e,s){var r=e.transformState.scale;zt(e),Es(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?mv(e,s):fv(e,s)}function co(e,s){var r=e.transformState.scale,o=e.setup,p=o.minScale,m=o.alignmentAnimation,x=m.disabled,i=m.sizeX,n=m.sizeY,a=m.animationTime,h=m.animationType,c=x||r<p||!i&&!n;if(!c){var g=pv(e);g&&xs(e,g,s??a,h)}}function xa(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,x=m.sizeX,i=m.sizeY;if(o){var n=gv(e,s,r),a=n.x,h=n.y,c=vs(e,x),g=vs(e,i);yv(e,{x:a,y:h}),xc(e,a,h,c,g)}}function wv(e){if(e.isPanning){var s=e.setup.panning.velocityDisabled,r=e.velocity,o=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var m=o?.getBoundingClientRect(),x=p?.getBoundingClientRect(),i=m?.width||0,n=m?.height||0,a=x?.width||0,h=x?.height||0,c=i<a||n<h,g=!s&&r&&r?.total>.1&&c;g?Sv(e):co(e)}}function uo(e,s,r,o){var p=e.setup,m=p.minScale,x=p.maxScale,i=p.limitToBounds,n=Ar(Lt(s,2),m,x,0,!1),a=Es(e,n),h=ji(e,r,o,n,a,i),c=h.x,g=h.y;return{scale:n,positionX:c,positionY:g}}function bc(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,x=m.minScale,i=m.limitToBounds,n=m.zoomAnimation,a=n.disabled,h=n.animationTime,c=n.animationType,g=a||o>=x;if((o>=1||i)&&co(e),!(g||!p||!e.mounted)){var v=s||p.offsetWidth/2,_=r||p.offsetHeight/2,w=uo(e,x,v,_);w&&xs(e,w,h,c)}}var ps=function(){return ps=Object.assign||function(s){for(var r,o=1,p=arguments.length;o<p;o++){r=arguments[o];for(var m in r)Object.prototype.hasOwnProperty.call(r,m)&&(s[m]=r[m])}return s},ps.apply(this,arguments)};function ba(e,s,r){for(var o=0,p=s.length,m;o<p;o++)(m||!(o in s))&&(m||(m=Array.prototype.slice.call(s,0,o)),m[o]=s[o]);return e.concat(m||Array.prototype.slice.call(s))}var Kr={scale:1,positionX:0,positionY:0},lr={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}},Cn={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},_c=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:Kr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Kr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:Kr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:Kr.positionY}},_a=function(e){var s=ps({},lr);return Object.keys(e).forEach(function(r){var o=typeof e[r]<"u",p=typeof lr[r]<"u";if(p&&o){var m=Object.prototype.toString.call(lr[r]),x=m==="[object Object]",i=m==="[object Array]";x?s[r]=ps(ps({},lr[r]),e[r]):i?s[r]=ba(ba([],lr[r],!0),e[r]):s[r]=e[r]}}),s},yc=function(e,s,r){var o=e.transformState.scale,p=e.wrapperComponent,m=e.setup,x=m.maxScale,i=m.minScale,n=m.zoomAnimation,a=m.smooth,h=n.size;if(!p)throw new Error("Wrapper is not mounted");var c=a?o*Math.exp(s*r):o+s*r,g=Ar(Lt(c,3),i,x,h,!1);return g};function Sc(e,s,r,o,p){var m=e.wrapperComponent,x=e.transformState,i=x.scale,n=x.positionX,a=x.positionY;if(!m)return console.error("No WrapperComponent found");var h=m.offsetWidth,c=m.offsetHeight,g=(h/2-n)/i,v=(c/2-a)/i,_=yc(e,s,r),w=uo(e,_,g,v);if(!w)return console.error("Error during zoom event. New transformation state was not calculated.");xs(e,w,o,p)}function wc(e,s,r,o){var p=e.setup,m=e.wrapperComponent,x=p.limitToBounds,i=_c(e.props),n=e.transformState,a=n.scale,h=n.positionX,c=n.positionY;if(m){var g=lo(e,i.scale),v=Rr(i.positionX,i.positionY,g,x,0,0,m),_={scale:i.scale,positionX:v.x,positionY:v.y};a===i.scale&&h===i.positionX&&c===i.positionY||(o?.(),xs(e,_,s,r))}}function Cv(e,s,r,o){var p=e.getBoundingClientRect(),m=s.getBoundingClientRect(),x=r.getBoundingClientRect(),i=m.x*o.scale,n=m.y*o.scale;return{x:(p.x-x.x+i)/o.scale,y:(p.y-x.y+n)/o.scale}}function kv(e,s,r){var o=e.wrapperComponent,p=e.contentComponent,m=e.transformState,x=e.setup,i=x.limitToBounds,n=x.minScale,a=x.maxScale;if(!o||!p)return m;var h=o.getBoundingClientRect(),c=s.getBoundingClientRect(),g=Cv(s,o,p,m),v=g.x,_=g.y,w=c.width/m.scale,l=c.height/m.scale,u=o.offsetWidth/w,d=o.offsetHeight/l,f=Ar(r||Math.min(u,d),n,a,0,!1),S=(h.width-w*f)/2,C=(h.height-l*f)/2,k=(h.left-v)*f+S,j=(h.top-_)*f+C,y=lo(e,f),E=Rr(k,j,y,i,0,0,o),R=E.x,P=E.y;return{positionX:R,positionY:P,scale:f}}var Ev=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Sc(e,1,s,r,o)}},jv=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),Sc(e,-1,s,r,o)}},Nv=function(e){return function(s,r,o,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var x=e.transformState,i=x.positionX,n=x.positionY,a=x.scale,h=e.wrapperComponent,c=e.contentComponent,g=e.setup.disabled;if(!(g||!h||!c)){var v={positionX:Number.isNaN(s)?i:s,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(o)?a:o};xs(e,v,p,m)}}},Rv=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),wc(e,s,r)}},Av=function(e){return function(s,r,o){r===void 0&&(r=200),o===void 0&&(o="easeOut");var p=e.transformState,m=e.wrapperComponent,x=e.contentComponent;if(m&&x){var i=Cc(s||p.scale,m,x);xs(e,i,r,o)}}},Tv=function(e){return function(s,r,o,p){o===void 0&&(o=600),p===void 0&&(p="easeOut"),zt(e);var m=e.wrapperComponent,x=typeof s=="string"?document.getElementById(s):s;if(m&&x&&m.contains(x)){var i=kv(e,x,r);xs(e,i,o,p)}}},ui=function(e){return{instance:e,zoomIn:Ev(e),zoomOut:jv(e),setTransform:Nv(e),resetTransform:Rv(e),centerView:Av(e),zoomToElement:Tv(e)}},kn=function(e){return{instance:e,state:e.transformState}},Ye=function(e){var s={};return Object.assign(s,kn(e)),Object.assign(s,ui(e)),s},en=!1;function tn(){try{var e={get passive(){return en=!0,!1}};return e}catch{return en=!1,en}}var Vr=".".concat(Cn.wrapperClass),Ni=function(e,s){return s.some(function(r){return e.matches("".concat(Vr," ").concat(r,", ").concat(Vr," .").concat(r,", ").concat(Vr," ").concat(r," *, ").concat(Vr," .").concat(r," *"))})},En=function(e){e&&clearTimeout(e)},Mv=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},Cc=function(e,s,r){var o=r.offsetWidth*e,p=r.offsetHeight*e,m=(s.offsetWidth-o)/2,x=(s.offsetHeight-p)/2;return{scale:e,positionX:m,positionY:x}};function Dv(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Pv=function(e,s){var r=e.setup.wheel,o=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,x=r.excluded,i=e.isInitialized,n=e.isPanning,a=s.target,h=i&&!n&&!o&&a;if(!h||p&&!s.ctrlKey||m&&s.ctrlKey)return!1;var c=Ni(a,x);return!c},Lv=function(e){return e?e.deltaY<0?1:-1:0};function Iv(e,s){var r=Lv(e),o=Xg(s,r);return o}function kc(e,s,r){var o=s.getBoundingClientRect(),p=0,m=0;if("clientX"in e)p=(e.clientX-o.left)/r,m=(e.clientY-o.top)/r;else{var x=e.touches[0];p=(x.clientX-o.left)/r,m=(x.clientY-o.top)/r}return(Number.isNaN(p)||Number.isNaN(m))&&console.error("No mouse or touch offset found"),{x:p,y:m}}var Ov=function(e,s,r,o,p){var m=e.transformState.scale,x=e.wrapperComponent,i=e.setup,n=i.maxScale,a=i.minScale,h=i.zoomAnimation,c=i.disablePadding,g=h.size,v=h.disabled;if(!x)throw new Error("Wrapper is not mounted");var _=m+s*r,w=o?!1:!v,l=Ar(Lt(_,3),a,n,g,w&&!c);return l},Bv=function(e,s){var r=e.previousWheelEvent,o=e.transformState.scale,p=e.setup,m=p.maxScale,x=p.minScale;return r?o<m||o>x||Math.sign(r.deltaY)!==Math.sign(s.deltaY)||r.deltaY>0&&r.deltaY<s.deltaY||r.deltaY<0&&r.deltaY>s.deltaY||Math.sign(r.deltaY)!==Math.sign(s.deltaY):!1},Fv=function(e,s){var r=e.setup.pinch,o=r.disabled,p=r.excluded,m=e.isInitialized,x=s.target,i=m&&!o&&x;if(!i)return!1;var n=Ni(x,p);return!n},zv=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},Wv=function(e,s,r){var o=r.getBoundingClientRect(),p=e.touches,m=Lt(p[0].clientX-o.left,5),x=Lt(p[0].clientY-o.top,5),i=Lt(p[1].clientX-o.left,5),n=Lt(p[1].clientY-o.top,5);return{x:(m+i)/2/s,y:(x+n)/2/s}},Ec=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))},Hv=function(e,s){var r=e.pinchStartScale,o=e.pinchStartDistance,p=e.setup,m=p.maxScale,x=p.minScale,i=p.zoomAnimation,n=p.disablePadding,a=i.size,h=i.disabled;if(!r||o===null||!s)throw new Error("Pinch touches distance was not provided");if(s<0)return e.transformState.scale;var c=s/o,g=c*r;return Ar(Lt(g,2),x,m,a,!h&&!n)},Uv=160,$v=100,qv=function(e,s){var r=e.props,o=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(zt(e),Ze(Ye(e),s,o),Ze(Ye(e),s,p))},Kv=function(e,s){var r=e.props,o=r.onWheel,p=r.onZoom,m=e.contentComponent,x=e.setup,i=e.transformState,n=i.scale,a=x.limitToBounds,h=x.centerZoomedOut,c=x.zoomAnimation,g=x.wheel,v=x.disablePadding,_=x.smooth,w=c.size,l=c.disabled,u=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");s.preventDefault(),s.stopPropagation();var f=Iv(s,null),S=_?d*Math.abs(s.deltaY):u,C=Ov(e,f,S,!s.ctrlKey);if(n!==C){var k=Es(e,C),j=kc(s,m,n),y=l||w===0||h||v,E=a&&y,R=ji(e,j.x,j.y,C,k,E),P=R.x,M=R.y;e.previousWheelEvent=s,e.setTransformState(C,P,M),Ze(Ye(e),s,o),Ze(Ye(e),s,p)}},Vv=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;En(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(bc(e,s.x,s.y),e.wheelAnimationTimer=null)},$v);var m=Bv(e,s);m&&(En(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ze(Ye(e),s,o),Ze(Ye(e),s,p))},Uv))},jc=function(e){for(var s=0,r=0,o=0;o<2;o+=1)s+=e.touches[o].clientX,r+=e.touches[o].clientY;var p=s/2,m=r/2;return{x:p,y:m}},Yv=function(e,s){var r=Ec(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=jc(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,zt(e)},Xv=function(e,s){var r=e.contentComponent,o=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,x=e.setup,i=x.limitToBounds,n=x.centerZoomedOut,a=x.zoomAnimation,h=x.alignmentAnimation,c=a.disabled,g=a.size;if(!(o===null||!r)){var v=Wv(s,m,r);if(!(!Number.isFinite(v.x)||!Number.isFinite(v.y))){var _=Ec(s),w=Hv(e,_),l=jc(s),u=l.x-(e.pinchLastCenterX||0),d=l.y-(e.pinchLastCenterY||0);if(!(w===m&&u===0&&d===0)){e.pinchLastCenterX=l.x,e.pinchLastCenterY=l.y;var f=Es(e,w),S=c||g===0||n,C=i&&S,k=ji(e,v.x,v.y,w,f,C),j=k.x,y=k.y;e.pinchMidpoint=v,e.lastDistance=_;var E=h.sizeX,R=h.sizeY,P=vs(e,E),M=vs(e,R),L=j+u,z=y+d,I=Rr(L,z,f,i,P,M,p),W=I.x,$=I.y;e.setTransformState(w,W,$)}}}},Gv=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,bc(e,s?.x,s?.y)},Nc=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;En(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ze(Ye(e),s,r)},o)},Qv=function(e,s){var r=e.props,o=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,x=m.animationTime,i=m.animationType;Ze(Ye(e),s,o),wc(e,x,i,function(){return Ze(Ye(e),s,p)}),Nc(e,s)};function Zv(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Jv(e,s){var r=e.setup,o=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,x=p.scale,i=e.props,n=i.onZoomStart,a=i.onZoom,h=r.doubleClick,c=h.disabled,g=h.mode,v=h.step,_=h.animationTime,w=h.animationType;if(!c&&!o){if(g==="reset")return Qv(e,s);if(!m)return console.error("No ContentComponent found");var l=Zv(g,e.transformState.scale),u=yc(e,l,v);if(x!==u){Ze(Ye(e),s,n);var d=kc(s,m,x),f=uo(e,u,d.x,d.y);if(!f)return console.error("Error during zoom event. New transformation state was not calculated.");Ze(Ye(e),s,a),xs(e,f,_,w),Nc(e,s)}}}var e0=function(e,s){var r=e.isInitialized,o=e.setup,p=e.wrapperComponent,m=o.doubleClick,x=m.disabled,i=m.excluded,n=s.target,a=p?.contains(n),h=r&&n&&a&&!x;if(!h)return!1;var c=Ni(n,i);return!c},t0=(function(){function e(s){var r=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(){r.initializeWindowEvents()},this.unmount=function(){r.cleanupWindowEvents()},this.update=function(o){r.props=o,Es(r,r.transformState.scale),r.setup=_a(o)},this.initializeWindowEvents=function(){var o,p,m=tn(),x=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=x?.defaultView;(p=r.wrapperComponent)===null||p===void 0||p.addEventListener("wheel",r.onWheelPanning,m),i?.addEventListener("mousedown",r.onPanningStart,m),i?.addEventListener("mousemove",r.onPanning,m),i?.addEventListener("mouseup",r.onPanningStop,m),x?.addEventListener("mouseleave",r.clearPanning,m),i?.addEventListener("keyup",r.setKeyUnPressed,m),i?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var o,p,m=tn(),x=(o=r.wrapperComponent)===null||o===void 0?void 0:o.ownerDocument,i=x?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,m),i?.removeEventListener("mousemove",r.onPanning,m),i?.removeEventListener("mouseup",r.onPanningStop,m),x?.removeEventListener("mouseleave",r.clearPanning,m),i?.removeEventListener("keyup",r.setKeyUnPressed,m),i?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),zt(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(o){var p=tn();o.addEventListener("wheel",r.onWheelZoom,p),o.addEventListener("dblclick",r.onDoubleClick,p),o.addEventListener("touchstart",r.onTouchPanningStart,p),o.addEventListener("touchmove",r.onTouchPanning,p),o.addEventListener("touchend",r.onTouchPanningStop,p)},this.handleInitialize=function(o,p){var m=!1,x=r.setup.centerOnInit,i=function(n,a){for(var h=0,c=n;h<c.length;h++){var g=c[h];if(g.target===a)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(n){n(Ye(r))}),r.observer=new ResizeObserver(function(n){if(i(n,o)||i(n,p))if(x&&!m){var a=p.offsetWidth,h=p.offsetHeight;(a>0||h>0)&&(m=!0,r.setCenter())}else zt(r),Es(r,r.transformState.scale),co(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=Pv(r,o);if(m){var x=r.isPressingKeys(r.setup.wheel.activationKeys);x&&(qv(r,o),Kv(r,o),Vv(r,o))}}},this.onWheelPanning=function(o){var p=r.setup,m=p.disabled,x=p.wheel,i=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!x.wheelDisabled||i.disabled||!i.wheelPanning||o.ctrlKey)){o.preventDefault(),o.stopPropagation();var n=r.transformState,a=n.positionX,h=n.positionY,c=a-o.deltaX,g=h-o.deltaY,v=i.lockAxisX?a:c,_=i.lockAxisY?h:g,w=r.setup.alignmentAnimation,l=w.sizeX,u=w.sizeY,d=vs(r,l),f=vs(r,u);v===a&&_===h||xc(r,v,_,d,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var x=ma(r,o);if(x){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.button===0&&!r.setup.panning.allowLeftClickPan||o.button===1&&!r.setup.panning.allowMiddleClickPan||o.button===2&&!r.setup.panning.allowRightClickPan||(o.preventDefault(),o.stopPropagation(),zt(r),va(r,o),Ze(Ye(r),o,m)))}}},this.onPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var x=pa(r);if(x){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.preventDefault(),o.stopPropagation(),xa(r,o.clientX,o.clientY),Ze(Ye(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(wv(r),Ze(Ye(r),o,p))},this.onPinchStart=function(o){var p=r.setup.disabled,m=r.props,x=m.onPinchingStart,i=m.onZoomStart;if(!p){var n=Fv(r,o);n&&(Yv(r,o),zt(r),Ze(Ye(r),o,x),Ze(Ye(r),o,i))}},this.onPinch=function(o){var p=r.setup.disabled,m=r.props,x=m.onPinching,i=m.onZoom;if(!p){var n=zv(r);n&&(o.preventDefault(),o.stopPropagation(),Xv(r,o),Ze(Ye(r),o,x),Ze(Ye(r),o,i))}},this.onPinchStop=function(o){var p=r.props,m=p.onPinchingStop,x=p.onZoomStop;r.pinchStartScale&&(Gv(r),Ze(Ye(r),o,m),Ze(Ye(r),o,x))},this.onTouchPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var x=ma(r,o);if(x){var i=r.lastTouch&&+new Date-r.lastTouch<200&&o.touches.length===1;if(!i){r.lastTouch=+new Date,zt(r);var n=o.touches,a=n.length===1,h=n.length===2;a&&(zt(r),va(r,o),Ze(Ye(r),o,m)),h&&r.onPinchStart(o)}}}},this.onTouchPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(r.isPanning&&o.touches.length===1){if(p)return;var x=pa(r);if(!x)return;o.preventDefault(),o.stopPropagation();var i=o.touches[0];xa(r,i.clientX,i.clientY),Ze(Ye(r),o,m)}else o.touches.length>1&&r.onPinch(o)},this.onTouchPanningStop=function(o){r.onPanningStop(o),r.onPinchStop(o)},this.onDoubleClick=function(o){var p=r.setup.disabled;if(!p){var m=e0(r,o);m&&Jv(r,o)}},this.clearPanning=function(o){r.isPanning&&r.onPanningStop(o)},this.setKeyPressed=function(o){r.pressedKeys[o.key]=!0},this.setKeyUnPressed=function(o){r.pressedKeys[o.key]=!1},this.isPressingKeys=function(o){return o.length?!!o.find(function(p){return r.pressedKeys[p]}):!0},this.setTransformState=function(o,p,m){var x=r.props.onTransformed;if(!Number.isNaN(o)&&!Number.isNaN(p)&&!Number.isNaN(m)){o!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=o),r.transformState.positionX=p,r.transformState.positionY=m,r.applyTransformation();var i=Ye(r);r.onChangeCallbacks.forEach(function(n){return n(i)}),Ze(i,{scale:o,positionX:p,positionY:m},x)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var o=Cc(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(o.scale,o.positionX,o.positionY)}},this.handleTransformStyles=function(o,p,m){return r.props.customTransform?r.props.customTransform(o,p,m):Mv(o,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var o=r.transformState,p=o.scale,m=o.positionX,x=o.positionY,i=r.handleTransformStyles(m,x,p);r.contentComponent.style.transform=i}},this.getContext=function(){return Ye(r)},this.onChange=function(o){return r.onChangeCallbacks.has(o)||r.onChangeCallbacks.add(o),function(){r.onChangeCallbacks.delete(o)}},this.onInit=function(o){return r.onInitCallbacks.has(o)||r.onInitCallbacks.add(o),function(){r.onInitCallbacks.delete(o)}},this.init=function(o,p){r.cleanupWindowEvents(),r.wrapperComponent=o,r.contentComponent=p,Es(r,r.transformState.scale),r.handleInitializeWrapperEvents(o),r.handleInitialize(o,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Ye(r);Ze(m,void 0,r.props.onInit)},this.props=s,this.setup=_a(this.props),this.transformState=_c(this.props)}return e})(),Ri=ue.createContext(null),s0=function(e,s){return typeof e=="function"?e(s):e},r0=ue.forwardRef(function(e,s){var r=b.useRef(new t0(e)).current,o=s0(e.children,ui(r));return b.useImperativeHandle(s,function(){return ui(r)},[r]),b.useEffect(function(){r.update(e)},[r,e]),ue.createElement(Ri.Provider,{value:r},o)});ue.forwardRef(function(e,s){var r=b.useRef(null),o=b.useContext(Ri);return b.useEffect(function(){return o.onChange(function(p){if(r.current){var m=0,x=0;r.current.style.transform=o.handleTransformStyles(m,x,1/p.instance.transformState.scale)}})},[o]),ue.createElement("div",ps({},e,{ref:Dv([r,s])}))});function i0(e,s){s===void 0&&(s={});var r=s.insertAt;if(!(typeof document>"u")){var o=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",r==="top"&&o.firstChild?o.insertBefore(p,o.firstChild):o.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var n0=`.transform-component-module_wrapper__SPB86 {
35
- position: relative;
36
- width: -moz-fit-content;
37
- width: fit-content;
38
- height: -moz-fit-content;
39
- height: fit-content;
40
- overflow: hidden;
41
- -webkit-touch-callout: none; /* iOS Safari */
42
- -webkit-user-select: none; /* Safari */
43
- -khtml-user-select: none; /* Konqueror HTML */
44
- -moz-user-select: none; /* Firefox */
45
- -ms-user-select: none; /* Internet Explorer/Edge */
46
- user-select: none;
47
- margin: 0;
48
- padding: 0;
49
- transform: translate3d(0, 0, 0);
50
- }
51
- .transform-component-module_content__FBWxo {
52
- display: flex;
53
- flex-wrap: wrap;
54
- width: -moz-fit-content;
55
- width: fit-content;
56
- height: -moz-fit-content;
57
- height: fit-content;
58
- margin: 0;
59
- padding: 0;
60
- transform-origin: 0% 0%;
61
- }
62
- .transform-component-module_content__FBWxo img {
63
- pointer-events: none;
64
- }
65
- `,ya={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};i0(n0);var o0=function(e){var s=e.children,r=e.wrapperClass,o=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,x=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,a=n===void 0?{}:n,h=e.contentProps,c=h===void 0?{}:h,g=b.useContext(Ri),v=g.init,_=g.cleanupWindowEvents,w=b.useRef(null),l=b.useRef(null);return b.useEffect(function(){var u=w.current,d=l.current;return u!==null&&d!==null&&v&&v?.(u,d),function(){_?.()}},[]),ue.createElement("div",ps({},a,{ref:w,className:"".concat(Cn.wrapperClass," ").concat(ya.wrapper," ").concat(o),style:x}),ue.createElement("div",ps({},c,{ref:l,className:"".concat(Cn.contentClass," ").concat(ya.content," ").concat(m),style:i}),s))},Rc=function(){var e=b.useContext(Ri);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},a0=function(){var e=Rc();return ui(e)};function l0(e){var s=Rc(),r=b.useState(e(kn(s))),o=r[0],p=r[1];return b.useEffect(function(){var m=!0,x=s.onChange(function(i){m&&p(e(kn(i.instance)))});return function(){x(),m=!1}},[e,s]),o}function c0(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 d0(e,s){return Et({queryKey:ce.files.tree(e||"",s),queryFn:()=>ye.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function u0(e,s){return Et({queryKey:ce.files.content(e||"",s||""),queryFn:()=>ye.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function h0(e){const s=vt();return b.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function f0(){const e=vt();return Ut({mutationFn:s=>ye.post("/files/write",s),onSuccess:(s,r)=>{const o=ce.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||c0(r.path)})}})}function m0(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function p0(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const g0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function v0(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&g0.has(s)?Ja:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?si:s==="json"?Du:s==="md"||s==="mdx"||s==="txt"?Za:cu}const Sa=({depth:e,active:s,onClick:r,leftIcon:o,rightIcon:p,label:m})=>t.jsxs("button",{type:"button",onClick:r,className:Z("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",s&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[t.jsx("span",{className:"shrink-0",children:p}),t.jsx("span",{className:"shrink-0 text-neutral-500",children:o}),t.jsx("span",{className:"truncate text-neutral-700",children:m})]}),Ac=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})=>{const{t:i}=de(),{data:n,isLoading:a,isError:h}=d0(e,s),c=b.useMemo(()=>n?.items??[],[n?.items]);return a?t.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):h?t.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):t.jsx("div",{className:"space-y-0.5",children:c.map(g=>{if(g.type==="directory"){const u=m0(s,g.name),d=o.has(u);return t.jsxs("div",{children:[t.jsx(Sa,{depth:r,onClick:()=>p(u),rightIcon:d?t.jsx(kt,{size:14,className:"text-neutral-400"}):t.jsx(At,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(bi,{size:14,className:"text-amber-500"}):t.jsx(Un,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(Ac,{workingDir:e,path:u,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})]},u)}const v=p0(s,g.name),_=v0(g),w=x===v,l=_===Ja;return t.jsx(Sa,{depth:r,active:w,onClick:()=>m(v),rightIcon:t.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:_?t.jsx(_,{size:14,className:l?"text-emerald-600":"text-sky-600"}):null,label:g.name},v)})})},x0=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=de(),[x,i]=b.useState(()=>new Set),n=h0(e),a=b.useCallback(h=>{i(c=>{const g=new Set(c);return g.has(h)?g.delete(h):g.add(h),g})},[]);return t.jsxs("div",{className:Z("h-full flex flex-col",s),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:m("Files")}),t.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),t.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&t.jsx("button",{type:"button",onClick:n,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Refresh file tree"),children:t.jsx(Ts,{size:13})}),p&&t.jsx("button",{type:"button",onClick:p,className:"p-1 rounded hover:bg-neutral-200 text-neutral-400 hover:text-neutral-700 transition-colors",title:m("Collapse file tree"),children:t.jsx(Uu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(Ac,{workingDir:e,path:"/",depth:0,expanded:x,toggleDir:a,onFileSelect:r,selectedFilePath:o}):t.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},b0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function _0(e){const s=e.split(".").pop()?.toLowerCase();return s?b0.has(s):!1}function y0(e,s){const r=wr(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const S0=({filePath:e})=>{const{t:s}=de(),{zoomIn:r,zoomOut:o,centerView:p}=a0(),m=l0(i=>i.state.scale),x=Math.round(m*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:()=>o(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom out"),children:t.jsx(ih,{size:14})}),t.jsxs("button",{type:"button",onClick:()=>p(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:s("Reset zoom"),children:[x,"%"]}),t.jsx("button",{type:"button",onClick:()=>r(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:s("Zoom in"),children:t.jsx(sh,{size:14})}),t.jsx("button",{type:"button",onClick:()=>p(1),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors ml-1",title:s("Fit to view"),children:t.jsx(Wu,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},w0=({workingDir:e,filePath:s})=>{const{t:r}=de(),[o,p]=b.useState(!1),m=y0(e,s);return o?t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):t.jsx(r0,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(S0,{filePath:s}),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(o0,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:t.jsx("img",{src:m,alt:s,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function C0(e){const s=e.split("/");return s[s.length-1]||e}function k0(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 E0=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=de();return t.jsxs("button",{type:"button",onClick:o,className:Z("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:Z("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),t.jsx("span",{className:"truncate flex-1 text-left text-xs",children:s}),t.jsx("span",{onClick:p,className:"opacity-0 group-hover:opacity-100 p-0.5 hover:bg-neutral-200 rounded transition-all shrink-0","aria-label":m("Close tab"),title:m("Close"),children:t.jsx(Gt,{size:12})})]})},j0=ue.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=de(),[x,i]=b.useState([]),[n,a]=b.useState(null),[h,c]=b.useState(!1),[g,v]=b.useState(!1),[_,w]=b.useState(0),[l,u]=b.useState(null),d=b.useRef(null),f=f0();b.useEffect(()=>{let B=!1;return Od(async()=>{const{preloadMonaco:U}=await import("./monaco-CkaUvvB4.js").then(H=>H.m);return{preloadMonaco:U}},__vite__mapDeps([0,1,2,3])).then(({preloadMonaco:U})=>U()).then(()=>{B||c(!0)}).catch(()=>{B||v(!0)}),()=>{B=!0}},[]);const[S,C]=b.useState(280),[k,j]=b.useState(!1),[y,E]=b.useState(!1),R=b.useRef(280),P=b.useCallback(()=>{j(B=>(B?C(R.current):R.current=S,!B))},[S]),M=b.useCallback(B=>{B.preventDefault(),E(!0);const U=B.clientX,H=S,N=q=>{const Y=q.clientX-U,se=Math.min(480,Math.max(160,H+Y));C(se)},F=()=>{E(!1),document.removeEventListener("mousemove",N),document.removeEventListener("mouseup",F)};document.addEventListener("mousemove",N),document.addEventListener("mouseup",F)},[S]);b.useEffect(()=>{i([]),a(null),u(null)},[s]);const L=b.useMemo(()=>x.find(B=>B.path===n)||null,[x,n]),{data:z,isFetching:I,isError:W,error:$}=u0(s,L?.isImage?null:n);b.useEffect(()=>{!n||!z||i(B=>B.map(U=>U.path!==n||U.isDirty||U.loaded?U:{...U,language:z.language||U.language,content:z.content,savedContent:z.content,isDirty:!1,loaded:!0}))},[n,z]);const A=b.useCallback((B,U,H)=>{i(N=>{if(N.find(Y=>Y.path===B))return N;const q=_0(B);return[...N,{path:B,name:C0(B),language:k0(B),content:"",savedContent:"",isDirty:!1,loaded:q,isImage:q}]}),a(B),u(U?{path:B,line:U,column:H}:null)},[]);ue.useImperativeHandle(p,()=>({openFile:A}),[A]);const D=b.useCallback(B=>{i(U=>{const H=U.filter(N=>N.path!==B);return a(N=>N!==B?N:H.length?H[H.length-1].path:null),H})},[]),T=b.useCallback(B=>{i(U=>U.map(H=>{if(H.path!==n)return H;const N=B!==H.savedContent;return{...H,content:B,isDirty:N}}))},[n]),O=b.useCallback(async()=>{o||!s||!L||(await f.mutateAsync({workingDir:s,path:L.path,content:L.content}),i(B=>B.map(U=>U.path===L.path?{...U,savedContent:U.content,isDirty:!1,loaded:!0}:U)))},[L,o,f,s]),K=b.useRef(()=>{});b.useEffect(()=>{K.current=()=>{O().catch(()=>{})}},[O]),b.useEffect(()=>{const B=U=>{o||(U.metaKey||U.ctrlKey)&&U.key.toLowerCase()==="s"&&(U.preventDefault(),K.current())};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[o]);const V=b.useCallback((B,U)=>{d.current=B,w(H=>H+1),B.addCommand(U.KeyMod.CtrlCmd|U.KeyCode.KeyS,()=>{K.current()})},[]);return b.useEffect(()=>{if(!l||l.path!==n||!L?.loaded)return;const B=d.current,U=B?.getModel();if(!B||!U)return;const H=Math.min(l.line,U.getLineCount()),N=Math.min(l.column??1,U.getLineMaxColumn(H)),F={lineNumber:H,column:N};B.setPosition(F),B.revealPositionInCenter(F),B.focus(),u(null)},[n,L?.loaded,_,l]),t.jsxs("div",{className:Z("flex h-full overflow-hidden bg-white",r),style:y?{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:k?36:S,transition:y?"none":"width 0.15s ease"},children:k?t.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:t.jsx("button",{type:"button",onClick:P,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:m("Expand file tree"),children:t.jsx(qu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(x0,{workingDir:s,onFileSelect:A,selectedFilePath:L?.path||null,onCollapse:P},s||"no-working-dir")})}),!k&&t.jsx("div",{onMouseDown:M,className:Z("w-1 shrink-0 cursor-col-resize transition-colors",y?"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:[x.length===0?t.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:m("No open files")}):x.map(B=>t.jsx(E0,{active:B.path===n,name:B.name,isDirty:B.isDirty,onClick:()=>a(B.path),onClose:U=>{U.stopPropagation(),D(B.path)}},B.path)),t.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[o&&t.jsx("span",{className:"text-[11px] text-neutral-400",children:m("Read-only")}),f.isPending&&t.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[t.jsx(Be,{size:14,className:"animate-spin"}),m("Saving")]}),L?.isDirty&&!f.isPending&&t.jsx("span",{className:"text-[11px] text-amber-600",children:m("Unsaved")})]})]}),t.jsx("div",{className:"flex-1 min-h-0 relative",children:s?L?L.isImage?t.jsx(w0,{workingDir:s,filePath:L.path}):g?t.jsx("div",{className:"h-full flex items-center justify-center text-red-600 text-sm",children:m("Failed to load editor.")}):h?t.jsxs(t.Fragment,{children:[t.jsx(Yg,{path:L.path,value:L.content,language:L.language,theme:"vs-light",height:"100%",onChange:o?void 0:B=>T(B??""),onMount:V,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:o}}),I&&!L.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(Be,{size:14,className:"animate-spin"}),m("Loading file...")]})}),W&&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:[m("Failed to load file"),$ instanceof Error?`: ${$.message}`:""]})]}):t.jsxs("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),m("Loading editor...")]}):t.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:m("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:m("No workspace selected.")})})]})]})});function Ai(e,s={}){const r=Rs(p=>p.visibleContext),o=$l(e,r);return Et({queryKey:ce.git.changes(e||""),queryFn:()=>ye.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function Tc(e,s,r){const o=Rs(m=>m.visibleContext),p=$l(e,o);return Et({queryKey:ce.git.diff(e||"",s||"",r),queryFn:()=>ye.get("/git/diff",{params:{workingDir:e||"",path:s||"",type:r}}),enabled:!!e&&!!s,refetchInterval:p,refetchIntervalInBackground:!1,refetchOnWindowFocus:p?"always":!1,refetchOnReconnect:p?"always":!1})}function ho(e,s){return Et({queryKey:ce.git.commitFiles(e||"",s||""),queryFn:()=>ye.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function fo(e,s,r){return Et({queryKey:ce.git.commitDiff(e||"",s||"",r||""),queryFn:()=>ye.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}const N0=new Set(["STARTING","RUNNING","STOPPING"]);function Mc(e){return N0.has(e.runtimeState)||e.runtimeInstanceId!==null}function Dc(e){return e instanceof mi&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function R0({services:e,isLoading:s,isError:r}){const{t:o}=de();return s?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(Be,{size:13,className:"animate-spin shrink-0","aria-hidden":"true"}),t.jsx("span",{children:o("正在检查后台服务...")})]}):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(As,{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:o("合并前将停止 {count} 个后台服务",{count:e.length})}),t.jsx("p",{className:"mt-1 break-all font-mono text-[11px] text-amber-800",children:e.map(p=>p.name).join(", ")}),t.jsx("p",{className:"mt-1 text-amber-700",children:o("停止后不会自动恢复。")})]})]}):r?t.jsx("p",{className:"text-xs text-amber-700",role:"status",children:o("无法检查后台服务状态,提交时会再次确认。")}):null}function Pc({isOpen:e,onClose:s,branchName:r,targetBranch:o,commitMessage:p,isPending:m,activeServices:x,isCheckingServices:i,serviceCheckFailed:n,error:a,onConfirm:h}){const{t:c}=de(),[g,v]=b.useState(""),[_,w]=b.useState(!1);b.useEffect(()=>{e&&(w(!1),v(p??""))},[e]),b.useEffect(()=>{_||!e||v(p??"")},[p,_,e]);const l=()=>{m||s()};return t.jsx(gs,{isOpen:e,onClose:l,title:c("提交变更"),className:"max-w-md",action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:l,disabled:m,className:"px-4 py-2 text-sm font-medium text-muted-foreground hover:text-foreground transition-colors disabled:opacity-50",children:c("取消")}),t.jsx("button",{onClick:()=>h(g.trim()||void 0,x.length>0),disabled:m||i,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:m||i?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:14,className:"animate-spin"}),i?c("正在检查后台服务..."):x.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(ti,{size:14}),x.length>0?c("停止服务并提交"):c("确认提交")]})})]}),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:r}),t.jsx(bl,{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:o})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-xs font-medium text-foreground mb-1.5",children:c("提交消息")}),t.jsx("textarea",{value:g,onChange:u=>{w(!0),v(u.target.value)},placeholder:c("请描述本次修改的内容"),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:c("建议以 feat、fix、docs、refactor、chore 开头,保持提交记录清晰。feat 新增功能,fix 修复问题,docs 文档更新,refactor 代码重构,chore 日常维护。")}),!g.trim()&&t.jsx("p",{className:"mt-1 text-[11px] text-muted-foreground/70",children:c("留空将使用默认消息")})]}),t.jsx(R0,{services:x,isLoading:i,isError:n}),a&&t.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:a})]})})}function Fs(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Lc(e){if(!(e instanceof mi)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==vr.REBASE&&s.conflictOp!==vr.MERGE||!Array.isArray(s.conflictedFiles)||!s.conflictedFiles.every(o=>typeof o=="string"))return;const r=s.mergeStrategy==="squash"||s.mergeStrategy==="no_ff"?s.mergeStrategy:void 0;return{conflictOp:s.conflictOp,conflictedFiles:s.conflictedFiles,mergeAborted:typeof s.mergeAborted=="boolean"?s.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Fs(s,"sourceBranch"),targetBranch:Fs(s,"targetBranch"),sourceWorktreePath:Fs(s,"sourceWorktreePath"),targetWorktreePath:Fs(s,"targetWorktreePath"),sourceWorkspaceId:Fs(s,"sourceWorkspaceId"),targetWorkspaceId:Fs(s,"targetWorkspaceId")}}function wa(e,s,r,o){const p=Lc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Ic({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:x,onResolveConflicts:i}){const{t:n}=de(),{data:a,isLoading:h}=to(e),c=Vl(),g=Kl(),v=so(),[_,w]=b.useState(!1),[l,u]=b.useState(null),d=ao(e,_),f=(d.data??[]).filter(Mc);if(b.useEffect(()=>{_&&m?.()},[_,m]),h||!a)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(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:n("正在检查工作区状态...")})]});const S=a.conflictedFiles.length>0,C=a.operation!=="idle",k=a.hasUncommittedChanges||a.untrackedCount>0,j=a.uncommittedCount+a.untrackedCount,y=!S&&!C&&!k,E=a.operation==="idle"&&a.ahead===0&&a.behind===0&&!k&&!S,R=()=>{u(null),c.mutate(e,{onError:z=>{wa(z,n("更新失败,请稍后重试"),I=>x(I),u)}})},P=()=>{u(null),w(!0)},M=(z,I)=>{u(null),g.mutate({id:e,commitMessage:z,stopActiveServices:I},{onSuccess:()=>w(!1),onError:W=>{if(Dc(W)){u(n("后台服务仍在运行,请确认停止服务后再提交。"));return}wa(W,n("提交失败,请稍后重试"),$=>{w(!1),x($)},u)}})},L=()=>{g.isPending||(w(!1),u(null))};return E?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(Bd,{size:13}),t.jsx("span",{className:"text-xs",children:n("当前分支还没有任何变更")})]}):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:[l&&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:l}),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(Iu,{size:12,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个本地改动未处理,需要先整理后再继续",{count:j})})]}),S&&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(As,{size:13,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个文件存在冲突,需要处理后继续",{count:a.conflictedFiles.length})})]}),t.jsxs("div",{className:"flex items-center gap-1.5 ml-auto",children:[t.jsx("button",{onClick:i,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:n("处理冲突")}),t.jsx("button",{onClick:()=>v.mutate(e),disabled:v.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:v.isPending?n("正在撤销..."):n("撤销操作")})]})]}),C&&!S&&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(Be,{size:13,className:"animate-spin shrink-0"}),t.jsx("span",{children:a.operation==="rebase"?n("正在同步源分支更新..."):n("正在提交变更...")})]}),t.jsxs("button",{onClick:()=>v.mutate(e),disabled:v.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(Ka,{size:12}),v.isPending?n("正在撤销..."):n("撤销操作")]})]}),!S&&!C&&(a.behind>0||a.ahead>0)&&t.jsxs("div",{className:"flex items-center gap-3 flex-wrap",children:[a.behind>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("源分支 {branch} 有 {count} 个更新",{branch:r,count:a.behind})}),t.jsxs("button",{onClick:R,disabled:!y||c.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(Ts,{size:12}),c.isPending?n("正在同步..."):n("同步更新")]})]}),a.ahead>0&&t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs text-muted-foreground",children:n("{count} 个文件变更,可以安全提交",{count:p??a.ahead})}),a.behind===0&&!k?t.jsxs("button",{onClick:P,disabled:g.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(ti,{size:12}),n("提交变更")]}):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:n(k?"需要先处理本地改动":"需要先同步源分支更新"),children:[t.jsx(ti,{size:12}),n("提交变更")]})]})]})]})}),t.jsx(Pc,{isOpen:_,onClose:L,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,activeServices:f,isCheckingServices:d.isLoading,serviceCheckFailed:d.isError,error:l,onConfirm:M})]})}const sn=50,rn=400,Ca={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"},ka={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Oc(e){const s=e.split("/");return s[s.length-1]||e}function A0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function T0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Dt("{count}s ago",{count:r}):r<3600?Dt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Dt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Dt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Xr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const jn=({additions:e,deletions:s,className:r})=>e===void 0&&s===void 0?null:t.jsxs("span",{className:Z("flex items-center gap-1 font-mono text-[11px] shrink-0",r),children:[e!==void 0&&e>0&&t.jsxs("span",{className:"text-emerald-600",children:["+",e]}),s!==void 0&&s>0&&t.jsxs("span",{className:"text-red-600",children:["-",s]}),(e??0)===0&&(s??0)===0&&t.jsx("span",{className:"text-muted-foreground/60",children:"0"})]}),M0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:Z("flex",r),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:s}),t.jsx("span",{className:Z("pl-2 whitespace-pre",o),children:e})]})},Bc=({diff:e})=>{const{t:s}=de(),[r,o]=b.useState(!1),p=b.useMemo(()=>e.split(`
66
- `),[e]);if(!e.trim())return t.jsx("div",{className:"py-6 text-center text-muted-foreground/70 text-xs",children:s("没有可显示的差异内容")});const m=!r&&p.length>rn,x=m?p.slice(0,rn):p;return t.jsxs("div",{className:"overflow-x-auto scrollbar-app-thin font-mono text-xs leading-5",children:[x.map((i,n)=>t.jsx(M0,{line:i,lineNum:n+1},n)),m&&t.jsx("button",{type:"button",onClick:()=>o(!0),className:"w-full py-2 text-xs text-info hover:bg-info/5 transition-colors",children:s("还有 {count} 行变更被折叠,点击展开全部",{count:p.length-rn})})]})},D0=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=de(),{data:m,isLoading:x,isError:i}=Tc(e,o?s:null,r);return!o||x?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Bc,{diff:m?.diff||""})},P0=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=de(),{data:m,isLoading:x,isError:i}=fo(e,o?s:null,o?r:null);return!o||x?t.jsxs("div",{className:"flex items-center justify-center py-8 text-muted-foreground",children:[t.jsx(Be,{size:14,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:p("正在加载差异...")})]}):i?t.jsx("div",{className:"py-6 text-center text-destructive text-xs",children:p("差异加载失败")}):t.jsx(Bc,{diff:m?.diff||""})},nn=({entry:e,source:s,workingDir:r,flash:o,registerNode:p})=>{const[m,x]=b.useState(!1),[i,n]=b.useState(!1),a=b.useRef(null),h=Xr(s,e.path);b.useEffect(()=>(p(h,a.current),()=>p(h,null)),[h,p]),b.useEffect(()=>{const v=a.current;if(!v||i)return;const _=new IntersectionObserver(w=>{w.some(l=>l.isIntersecting)&&(n(!0),_.disconnect())},{rootMargin:"300px 0px"});return _.observe(v),()=>_.disconnect()},[i]);const c=Ca[e.status]||Ca.M,g=A0(e.path);return t.jsxs("div",{ref:a,"data-card-key":h,className:Z("rounded-md border border-border bg-background overflow-hidden transition-shadow",o&&"ring-2 ring-info/40"),children:[t.jsxs("button",{type:"button",onClick:()=>x(v=>!v),className:"w-full flex items-center gap-2 px-3 py-2 bg-muted/40 hover:bg-muted/70 transition-colors text-left",children:[m?t.jsx(At,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(kt,{size:13,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:Z("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",c),children:e.status}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:Oc(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(jn,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(D0,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(P0,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function L0(e){const s={name:"",path:"",dirs:new Map,files:[]};for(const r of e){const o=r.path.split("/");let p=s;for(let m=0;m<o.length-1;m++){const x=o[m];p.dirs.has(x)||p.dirs.set(x,{name:x,path:p.path?`${p.path}/${x}`:x,dirs:new Map,files:[]}),p=p.dirs.get(x)}p.files.push(r)}return Fc(s)}function Fc(e){const s=new Map;for(const r of e.dirs.values()){let o=Fc(r);for(;o.dirs.size===1&&o.files.length===0;){const p=[...o.dirs.values()][0];o={...p,name:`${o.name}/${p.name}`}}s.set(o.name,o)}return{...e,dirs:s}}const I0=({dir:e,depth:s,activeKey:r,onSelect:o})=>{const[p,m]=b.useState(!0);return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>m(x=>!x),className:"flex items-center gap-1.5 w-full px-2 py-1 rounded-sm hover:bg-muted/60 text-left",style:{paddingLeft:8+s*12},children:[p?t.jsx(bi,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Un,{size:12,className:"text-muted-foreground/70 shrink-0"}),t.jsx("span",{className:"text-[11px] text-muted-foreground truncate",children:e.name})]}),p&&t.jsx(zc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},zc=({node:e,depth:s,activeKey:r,onSelect:o})=>t.jsxs(t.Fragment,{children:[[...e.dirs.values()].sort((p,m)=>p.name.localeCompare(m.name)).map(p=>t.jsx(I0,{dir:p,depth:s,activeKey:r,onSelect:o},p.path)),e.files.slice().sort((p,m)=>p.path.localeCompare(m.path)).map(p=>{const m=r===p.cardKey;return t.jsxs("button",{type:"button",onClick:()=>o(p),className:Z("flex items-center gap-1.5 w-full px-2 py-1 rounded-sm text-left",m?"bg-muted":"hover:bg-muted/60"),style:{paddingLeft:8+s*12},title:p.path,children:[t.jsx("span",{className:Z("w-1.5 h-1.5 rounded-full shrink-0",ka[p.status]||ka.M)}),t.jsx("span",{className:Z("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:Oc(p.path)})]},p.cardKey)})]}),O0=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=de(),{data:p,isLoading:m,fetchNextPage:x,hasNextPage:i,isFetchingNextPage:n}=$n({queryKey:ce.git.log(e),queryFn:({pageParam:h=0})=>ye.get("/git/log",{params:{workingDir:e,limit:String(sn),skip:String(h)}}),initialPageParam:0,getNextPageParam:(h,c)=>h.commits.length<sn?void 0:c.length*sn}),a=p?.pages.flatMap(h=>h.commits)||[];return m?t.jsxs("div",{className:"flex items-center gap-1.5 px-3 py-2 text-muted-foreground/70 text-[11px]",children:[t.jsx(Be,{size:11,className:"animate-spin"}),t.jsx("span",{children:o("正在加载提交记录...")})]}):a.length===0?t.jsx("div",{className:"px-3 py-2 text-[11px] text-muted-foreground/60",children:o("暂无提交记录")}):t.jsxs("div",{className:"space-y-px px-1.5 pb-1.5",children:[a.map(h=>{const c=s===h.hash;return t.jsxs("button",{type:"button",onClick:()=>r(h),className:Z("flex items-start gap-1.5 w-full px-1.5 py-1 rounded-sm text-left group",c?"bg-muted":"hover:bg-muted/60"),title:h.message,children:[t.jsx("span",{className:Z("w-1.5 h-1.5 rounded-full mt-1.5 shrink-0 transition-colors",c?"bg-brand":"bg-border group-hover:bg-muted-foreground/60")}),t.jsxs("span",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:Z("block text-xs truncate",c?"text-foreground font-medium":"text-foreground/90"),children:h.message}),t.jsxs("span",{className:"block text-[11px] text-muted-foreground/70 truncate",children:[t.jsx("span",{className:"font-mono",children:h.shortHash})," · ",h.author," · ",T0(h.timestamp)]})]})]},h.hash)}),i&&t.jsx("button",{type:"button",onClick:()=>x(),disabled:n,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:n?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},B0=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:x,onConflict:i,onResolveConflicts:n})=>{const{t:a}=de(),[h,c]=b.useState({kind:"overview"}),[g,v]=b.useState(""),[_,w]=b.useState(null),[l,u]=b.useState(null),{data:d,isLoading:f,isError:S}=Ai(e),C=h.kind==="commit"?h.commit.hash:null,{data:k,isLoading:j}=ho(e,C),y=b.useRef(new Map),E=b.useRef(null),R=b.useRef(null),P=b.useCallback((B,U)=>{U?y.current.set(B,U):y.current.delete(B)},[]),{uncommitted:M,committed:L,commitFiles:z}=b.useMemo(()=>{const B=N=>!g.trim()||N.path.toLowerCase().includes(g.trim().toLowerCase());if(h.kind==="commit"){const N={kind:"commit",hash:h.commit.hash},F=(k?.files||[]).filter(B).map(q=>({...q,cardKey:Xr(N,q.path)}));return{uncommitted:[],committed:[],commitFiles:F}}const U=(d?.uncommitted||[]).filter(B).map(N=>({...N,cardKey:Xr({kind:"working",diffType:"uncommitted"},N.path)})),H=(d?.committed||[]).filter(B).map(N=>({...N,cardKey:Xr({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:U,committed:H,commitFiles:[]}},[h,d,k,g]),I=h.kind==="commit"?z:[...M,...L],W=b.useMemo(()=>L0(I),[I]),$=b.useMemo(()=>{let B=0,U=0;for(const H of I)B+=H.additions??0,U+=H.deletions??0;return{additions:B,deletions:U,files:I.length}},[I]),A=b.useCallback(()=>{const B=E.current;if(!B)return;const U=B.getBoundingClientRect().top;let H=null,N=Number.NEGATIVE_INFINITY;for(const[F,q]of y.current){const Y=q.getBoundingClientRect().top-U;Y<=48&&Y>N&&(N=Y,H=F)}if(!H){let F=null,q=Number.POSITIVE_INFINITY;for(const[Y,se]of y.current){const G=se.getBoundingClientRect().top-U;G<q&&(q=G,F=Y)}H=F}w(H)},[]);b.useEffect(()=>{const B=E.current;if(!B)return;let U=0;const H=()=>{cancelAnimationFrame(U),U=requestAnimationFrame(A)};return B.addEventListener("scroll",H,{passive:!0}),()=>{B.removeEventListener("scroll",H),cancelAnimationFrame(U)}},[A]);const D=b.useCallback(B=>{const U=y.current.get(B.cardKey);U&&(U.scrollIntoView({behavior:"smooth",block:"start"}),w(B.cardKey),u(B.cardKey),R.current&&clearTimeout(R.current),R.current=setTimeout(()=>u(null),1200))},[]),T=b.useCallback(B=>{c(U=>U.kind==="commit"&&U.commit.hash===B.hash?{kind:"overview"}:{kind:"commit",commit:B}),v(""),w(null),E.current?.scrollTo({top:0})},[]),O=b.useCallback(()=>{c({kind:"overview"}),v(""),w(null),E.current?.scrollTo({top:0})},[]);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground text-sm bg-background h-full",children:a("未选择工作区")});const K=m&&s&&r&&o,V=h.kind==="commit"?j:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[K&&i&&n&&t.jsx(Ic,{workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,committedFileCount:d?.committed?.length,onRefreshCommitMessage:x,onConflict:i,onResolveConflicts:n}),t.jsx("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border/60 shrink-0 min-h-[37px]",children:h.kind==="overview"?t.jsxs(t.Fragment,{children:[t.jsx(Qs,{size:14,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:a("代码审查")}),t.jsx("span",{className:"text-[11px] text-muted-foreground",children:a("{count} 个文件",{count:$.files})}),t.jsx(jn,{additions:$.additions,deletions:$.deletions}),r&&o&&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:r}),t.jsx(Ks,{size:10,className:"rotate-180 shrink-0"}),t.jsx("span",{className:"truncate",children:o})]})]}):t.jsxs(t.Fragment,{children:[t.jsxs("button",{type:"button",onClick:O,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(Ks,{size:12}),a("全部变更")]}),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:h.commit.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate",children:h.commit.message}),t.jsx(jn,{className:"ml-auto",additions:$.additions,deletions:$.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:E,className:"flex-1 min-w-0 overflow-y-auto scrollbar-app-thin",children:V?t.jsx("div",{className:"p-3 space-y-3",children:[0,1].map(B=>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"})]})]},B))}):S&&h.kind==="overview"?t.jsx("div",{className:"flex-1 flex items-center justify-center py-16 text-destructive text-sm",children:a("变更加载失败")}):I.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(si,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:g.trim()?a("没有匹配筛选条件的文件"):h.kind==="commit"?a("该提交没有文件变更"):a("没有待审查的变更")})]}):h.kind==="commit"?t.jsx("div",{className:"p-3 space-y-3",children:z.map(B=>t.jsx(nn,{entry:B,source:{kind:"commit",hash:h.commit.hash},workingDir:e,flash:l===B.cardKey,registerNode:P},B.cardKey))}):t.jsxs("div",{className:"p-3 space-y-4",children:[M.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:a("未提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:M.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:M.map(B=>t.jsx(nn,{entry:B,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:l===B.cardKey,registerNode:P},B.cardKey))})]}),L.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:a("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:L.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:L.map(B=>t.jsx(nn,{entry:B,source:{kind:"working",diffType:"committed"},workingDir:e,flash:l===B.cardKey,registerNode:P},B.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(In,{size:12,className:"absolute left-2 top-1/2 -translate-y-1/2 text-muted-foreground/60"}),t.jsx("input",{value:g,onChange:B=>v(B.target.value),placeholder:a("筛选文件..."),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:I.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?a("无匹配文件"):a("暂无变更文件")}):t.jsx(zc,{node:W,depth:0,activeKey:_,onSelect:D})}),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(Ys,{size:12,className:"text-muted-foreground"}),t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("提交记录")})]}),t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin min-h-0",children:t.jsx(O0,{workingDir:e,selectedHash:C,onSelectCommit:T})})]})]})]})]})},on=50,Ea={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 F0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Dt("{count}s ago",{count:r}):r<3600?Dt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Dt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Dt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function z0(e){const s=e.split("/");return s[s.length-1]||e}function W0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const H0=({line:e,lineNum:s})=>{let r="",o="text-foreground/90";return e.startsWith("+")&&!e.startsWith("+++")?r="bg-success/10":e.startsWith("-")&&!e.startsWith("---")?r="bg-destructive/10":e.startsWith("@@")?(r="bg-info/5",o="text-info"):(e.startsWith("diff ")||e.startsWith("index "))&&(o="text-muted-foreground/70"),t.jsxs("div",{className:Z("flex",r),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:s}),t.jsx("span",{className:Z("pl-2 whitespace-pre",o),children:e})]})},U0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=de(),{data:p,isLoading:m,isError:x}=fo(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-xs",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"flex-1 flex items-center justify-center text-muted-foreground/70 text-xs",children:o("No diff content available.")});const n=i.split(`
67
- `);return t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((a,h)=>t.jsx(H0,{line:a,lineNum:h+1},h))})},$0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=de(),{data:m,isLoading:x}=ho(e,s);if(x)return t.jsxs("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70 flex items-center gap-1",children:[t.jsx(Be,{size:12,className:"animate-spin"}),t.jsx("span",{children:p("Loading...")})]});const i=m?.files||[];return i.length===0?t.jsx("div",{className:"pl-7 py-1 text-xs text-muted-foreground/70",children:p("No files changed")}):t.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(n=>{const a=Ea[n.status]||Ea.M,h=W0(n.path);return t.jsxs("button",{type:"button",onClick:c=>{c.stopPropagation(),o(n.path)},className:Z("flex items-center gap-2 px-1.5 py-1 rounded-sm cursor-pointer w-full text-left",r===n.path?"bg-muted":"hover:bg-muted/60"),children:[t.jsx("span",{className:Z("w-4 h-4 flex items-center justify-center text-[11px] font-semibold border rounded-sm shrink-0",a),children:n.status}),t.jsx("span",{className:"text-xs text-foreground truncate",children:z0(n.path)}),h&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:h})]},n.path)})})},q0=({workingDir:e})=>{const{t:s}=de(),r=Rs(j=>j.visibleContext),o=qf(e,r),{data:p,isLoading:m,isError:x,fetchNextPage:i,hasNextPage:n,isFetchingNextPage:a}=$n({queryKey:ce.git.log(e||""),queryFn:({pageParam:j=0})=>ye.get("/git/log",{params:{workingDir:e||"",limit:String(on),skip:String(j)}}),initialPageParam:0,getNextPageParam:(j,y)=>j.commits.length<on?void 0:y.length*on,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),h=p?.pages.flatMap(j=>j.commits)||[],[c,g]=b.useState(null),[v,_]=b.useState(null),[w,l]=b.useState(280),[u,d]=b.useState(!1),f=b.useCallback(j=>{j.preventDefault(),d(!0);const y=j.clientX,E=w,R=M=>{const L=Math.min(480,Math.max(180,E+(M.clientX-y)));l(L)},P=()=>{d(!1),document.removeEventListener("mousemove",R),document.removeEventListener("mouseup",P)};document.addEventListener("mousemove",R),document.addEventListener("mouseup",P)},[w]),S=j=>{c===j?(g(null),_(null)):(g(j),_(null))},C=b.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:s("No workspace selected.")});if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground bg-background h-full",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]});if(x)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-destructive text-sm bg-background h-full",children:s("Failed to load history.")});if(h.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(Ys,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=h.find(j=>j.hash===c);return t.jsxs("div",{className:"flex h-full bg-background",style:u?{userSelect:"none",cursor:"col-resize"}:void 0,children:[t.jsxs("div",{className:"border-r border-border flex flex-col shrink-0",style:{width:w},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(Ys,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-semibold text-foreground",children:s("History")}),t.jsx("span",{className:"text-[11px] bg-muted px-1.5 py-0.5 rounded-full text-muted-foreground",children:h.length})]})}),t.jsxs("div",{ref:C,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[h.map(j=>{const y=c===j.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>S(j.hash),className:Z("flex items-start gap-2 px-2 py-1.5 rounded-sm cursor-pointer w-full text-left group",y?"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:Z("w-2 h-2 rounded-full shrink-0 transition-colors",y?"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:j.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:j.message}),t.jsx(At,{size:12,className:Z("shrink-0 text-muted-foreground/70 transition-transform",y&&"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:j.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:F0(j.timestamp)})]})]})]}),y&&t.jsxs(t.Fragment,{children:[j.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:j.body}),t.jsx($0,{workingDir:e,hash:j.hash,selectedPath:v,onSelectFile:_})]})]},j.hash)}),n&&t.jsx("button",{type:"button",onClick:()=>i(),disabled:a,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:a?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:12,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]})]}),t.jsx("div",{onMouseDown:f,className:Z("w-1 shrink-0 cursor-col-resize transition-colors",u?"bg-info/60":"bg-transparent hover:bg-info/30")}),t.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:v&&c?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(si,{size:14,className:"text-muted-foreground"}),t.jsx("span",{className:"text-xs font-medium text-foreground truncate",children:v}),t.jsxs("span",{className:"text-[11px] text-muted-foreground/70",children:["(",k?.shortHash,")"]})]}),t.jsx(U0,{workingDir:e,hash:c,filePath:v})]}):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(si,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},ja=wr();function K0(e){if(!ja)return e;try{const s=new URL(ja);return new URL(e,s.origin).toString()}catch{return e}}function Wc(e){return{...e,viewUrl:e.viewUrl?K0(e.viewUrl):null}}function V0(e,s=!0){return Et({queryKey:ce.previews.status(e??""),queryFn:async()=>{const r=await ye.get(`/previews/${e}/status`);return Wc(r)},enabled:!!e&&s,refetchOnWindowFocus:!1})}function Y0(e){const s=vt();return Ut({mutationFn:async r=>{const o=await ye.put(`/previews/${e}/config`,{target:r});return Wc(o)},onSuccess:r=>{e&&(s.setQueryData(ce.previews.status(e),r),s.invalidateQueries({queryKey:ce.workspaces.all}))}})}function X0(){return window.location.protocol==="https:"?"remote":"local"}function G0(e,s,r=!0){const[o,p]=b.useState(null),[m,x]=b.useState(!1),[i,n]=b.useState(null),[a,h]=b.useState(0);return b.useEffect(()=>{if(!r||!e||!s?.ready||!s.target){p(null),x(!1),n(null);return}let c=!1,g=null,v=null;p(null);const _=l=>{ye.delete(`/previews/${e}/sessions/${l}`).catch(()=>{})};return(async()=>{x(!0),n(null);try{const l={mode:X0(),localHostname:window.location.hostname},u=await ye.post(`/previews/${e}/sessions`,l);if(c){_(u.id);return}g=u.id,p(u),v=window.setInterval(async()=>{if(g)try{const d=await ye.post(`/previews/${e}/sessions/${g}/heartbeat`);c||(p(d),n(null))}catch(d){!c&&d instanceof mi&&d.status===404?h(f=>f+1):c||n(d instanceof Error?d:new Error("Preview session heartbeat failed"))}},3e4)}catch(l){c||(p(null),n(l instanceof Error?l:new Error("Failed to open preview session")))}finally{c||x(!1)}})(),()=>{c=!0,v!==null&&window.clearInterval(v),g&&_(g)}},[r,a,s?.ready,s?.target,e]),{session:o,isOpening:m,error:i,retry:()=>h(c=>c+1)}}const Q0="agent-tower-preview",Z0="agent-tower-preview-host";function J0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function ex(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function tx(e){return t.jsx(sx,{...e},e.workspaceId??"no-workspace")}function sx({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:p}=de(),[m,x]=b.useState(null),n=!(r?.source.kind==="visualization")&&!m,{data:a,isLoading:h,refetch:c,isFetching:g}=V0(e,n),v=Y0(e),{session:_,isOpening:w,error:l,retry:u}=G0(e,a,n),d=b.useRef(null),f=b.useRef(null),S=b.useRef(null),C=b.useRef(null),k=b.useRef(null),j=b.useRef(null),[y,E]=b.useState(0),[R,P]=b.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),M=ex(_?.viewUrl),L=a&&R.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:a&&!a.ready&&R.iframeSrc?{...R,iframeSrc:null,isFrameLoading:!1}:R,z=b.useCallback(V=>{P(B=>({...a&&B.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:B,...V}))},[a]);b.useEffect(()=>{if(!_||_.target!==a?.target)return;const V=k.current!==M;k.current=M,P(B=>{const U=r?.source.kind==="web"&&j.current!==r.id?Wr(r.source.url,_.target,_.viewUrl):null;if(!V&&B.iframeSrc&&B.target===_.target&&U?.kind!=="proxy")return B;let H=B.iframeSrc;if(U?.kind==="proxy")H=U.url;else if(!H||B.target!==_.target||V){const F=S.current;if(F)H=Zd(_.viewUrl,F);else{const q=Wr(B.address||_.target,_.target,_.viewUrl);H=q?.kind==="proxy"?q.url:_.viewUrl}}S.current=null;const N=C.current;return N&&!N.closed&&H&&N.location.replace(H),C.current=null,{target:_.target,address:U?.kind==="proxy"?r?.source.kind==="web"?r.source.url:B.address:B.address||_.target,iframeSrc:H,isFrameLoading:!!H}})},[r,_,M,a?.target]),b.useEffect(()=>()=>{C.current?.close()},[]);const I=b.useCallback(async(V,B=!1)=>{const U=Wr(V,a?.target??null,_?.viewUrl??null);if(!U||!e)return;if(x(null),U.kind==="proxy"){if(B){window.open(U.url,"_blank","noopener,noreferrer");return}P({target:a?.target??null,address:V,iframeSrc:U.url,isFrameLoading:!0});return}if(s)return;const H=B?window.open("about:blank","_blank"):null;H&&(H.opener=null);try{S.current=U.path,C.current=H;const N=await v.mutateAsync(U.target);P({target:N.target,address:V.trim(),iframeSrc:null,isFrameLoading:!!N.ready}),E(F=>F+1),ot.success(p("Preview target saved")),N.ready||(C.current?.close(),C.current=null)}catch(N){C.current?.close(),C.current=null,S.current=null;const F=N instanceof Error?N.message:p("Failed to save preview target");ot.error(F)}},[_?.viewUrl,s,a?.target,p,v,e]);b.useEffect(()=>{if(!r||j.current===r.id||r.source.kind==="web"&&h)return;const V=window.setTimeout(()=>{j.current=r.id,o?.(r.id),r.source.kind==="visualization"?(x({source:r.source,iframeSrc:Jd(r.source.sessionId,r.source.file),isFrameLoading:!0}),E(B=>B+1)):(x(null),I(r.source.url))},0);return()=>window.clearTimeout(V)},[h,I,r,o]),b.useEffect(()=>{if(m)return;const V=B=>{if(B.source!==d.current?.contentWindow)return;const U=B.data;if(!(!U||U.source!==Q0)){if(U.type==="location"&&typeof U.href=="string"){const H=eu(a?.target??null,_?.viewUrl??null,U.href,window.location.href);H&&document.activeElement!==f.current&&z({target:a?.target??L.target,address:H,isFrameLoading:!1});return}U.type==="navigate-loopback"&&typeof U.href=="string"&&I(U.href,U.newTab===!0)}};return window.addEventListener("message",V),()=>window.removeEventListener("message",V)},[L.target,I,z,_?.viewUrl,a?.target,m]);const W=V=>{d.current?.contentWindow?.postMessage({source:Z0,action:V},"*")},$=V=>{V.preventDefault(),I(L.address)},A=async()=>{if(m){x(B=>B&&{...B,isFrameLoading:!0}),E(B=>B+1);return}const V=await c();if(!V.data?.ready){z({target:V.data?.target??L.target,iframeSrc:null,isFrameLoading:!1});return}if(!_||!L.iframeSrc){u();return}z({isFrameLoading:!0}),W("reload")},D=()=>{if(m){window.open(m.iframeSrc,"_blank","noopener,noreferrer");return}if(!_?.viewUrl)return;const V=Wr(L.address||_.target,_.target,_.viewUrl),B=V?.kind==="proxy"?V.url:_.viewUrl;window.open(B,"_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:p("No active workspace.")});const T=m?.iframeSrc??L.iframeSrc,O=!!m,K=!O&&(h||g||v.isPending||w);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:()=>{O?x(null):W("back")},disabled:!O&&!L.iframeSrc,title:p("Back"),"aria-label":p("Back"),children:t.jsx(Ks,{})}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>W("forward"),disabled:O||!L.iframeSrc,title:p("Forward"),"aria-label":p("Forward"),children:t.jsx(bl,{})}),t.jsx(Ae,{type:"button",size:"icon-sm",variant:"ghost",onClick:!O&&L.isFrameLoading?()=>{W("stop"),z({isFrameLoading:!1})}:A,disabled:!O&&!L.isFrameLoading&&g,title:!O&&L.isFrameLoading?p("Stop loading"):p("Refresh preview"),"aria-label":!O&&L.isFrameLoading?p("Stop loading"):p("Refresh preview"),children:!O&&L.isFrameLoading?t.jsx(Gt,{}):g?t.jsx(Be,{className:"animate-spin"}):t.jsx(Ts,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:$,children:[t.jsx(Au,{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:f,value:m?.source.file??L.address,onChange:V=>z({address:V.target.value}),onKeyDown:V=>{V.key==="Enter"&&V.nativeEvent.isComposing&&V.preventDefault()},disabled:O||s||v.isPending,placeholder:J0(),"aria-label":p("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:p("Open preview in new tab"),"aria-label":p("Open preview in new tab"),children:t.jsx(An,{})})]}),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:O?p("Viewing agent visualization"):K?p("Checking preview target..."):l?l.message:a?.ready?`${p("Proxying")} ${a.target}`:a?.configured?`${p("Preview target is not reachable")}${a.error?`: ${a.error}`:""}`:p("Enter a local preview URL on the Agent Tower machine.")}),t.jsx("span",{className:"shrink-0 text-neutral-400",children:p(O?"Session file":"Loopback only")})]})]}),t.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:T?t.jsx("iframe",{ref:d,src:T,title:p("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:O?"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:()=>{O?x(V=>V&&{...V,isFrameLoading:!1}):z({isFrameLoading:!1})}},y):t.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:a?.configured?a.ready&&w?p("Checking preview target..."):p("Start the preview server, then refresh."):p("Configure a local preview target to display it here.")})})]})}function rx(e){switch(e){case Pt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Pt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Pt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Pt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Na(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 ix(e){return e.length<=34?e:`...${e.slice(-31)}`}function Hc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:x}){const{t:i}=de(),[n,a]=b.useState(!1),h=b.useRef(null),c=b.useMemo(()=>no(e,s),[e,s]),g=c.find(v=>v.workspace.id===r)??c[0];return b.useEffect(()=>{if(!n)return;const v=_=>{h.current&&!h.current.contains(_.target)&&a(!1)};return document.addEventListener("mousedown",v),()=>document.removeEventListener("mousedown",v)},[n]),c.length<=1?null:t.jsxs("div",{ref:h,className:Z("relative",m),children:[t.jsxs("button",{type:"button",onClick:()=>a(v=>!v),disabled:p,className:Z("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",x),title:i("Workspace"),children:[t.jsx(Vs,{size:14,className:"shrink-0 text-neutral-500"}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Na(g.roleLabel)),children:i(g.roleLabel)}),t.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),t.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:ix(Xs(g.workspace))}),t.jsx(kt,{size:13,className:Z("shrink-0 text-neutral-400 transition-transform",n&&"rotate-180")})]}),n&&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:c.map(v=>{const _=v.workspace.id===g.workspace.id;return t.jsxs("button",{type:"button",onClick:()=>{o(v.workspace.id),a(!1)},className:Z("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",_&&"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:_?t.jsx(Wt,{size:13}):t.jsx(al,{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:i(v.displayName)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Na(v.roleLabel)),children:i(v.roleLabel)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",rx(v.workspace.status)),children:v.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:Xs(v.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:[v.ownerName&&t.jsxs("span",{children:[i("Owner"),": ",v.ownerName]}),v.parentBranchName&&t.jsxs("span",{children:[i("Parent"),": ",v.parentBranchName]}),t.jsx("span",{children:v.workspace.id.slice(0,8)})]})]})]},v.workspace.id)})})]})}const nx=[{key:"review",label:"Changes",icon:t.jsx(Qs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(xi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(hr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ol,{size:14})}],ox=[{key:"history",label:"History",icon:t.jsx(Ys,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(xi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(hr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(ol,{size:14})}],ax=({active:e,onClick:s,icon:r,label:o})=>t.jsxs("button",{type:"button",onClick:s,className:Z("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:[r,t.jsx("span",{children:o})]}),lx=({active:e,onClick:s,icon:r,label:o})=>t.jsx("button",{type:"button",onClick:s,title:o,"aria-label":o,"aria-pressed":e,className:Z("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:r}),Uc=ue.memo(function({className:s,sessionId:r,workspaceId:o,workingDir:p,projectId:m,hideChanges:x,gitAvailable:i=!0,readOnly:n,repoDeleted:a,teamRun:h,teamStatus:c,gitProps:g,workspaces:v,selectedWorkspaceId:_,onSelectWorkspace:w,variant:l="tabs",expanded:u,onExpandedChange:d,minContentWidth:f=520,tabRef:S,previewRequest:C,onPreviewRequestHandled:k}){const{t:j}=de(),y=Rs(re=>re.setVisibleContext),E=l==="rail",[R,P]=b.useState(!1),M=E?u??R:!0,L=b.useCallback(re=>{u===void 0&&P(re),d?.(re)},[u,d]),z=b.useMemo(()=>{const re=x?ox:nx,ne=i?re:re.filter(Se=>Se.key!=="review"&&Se.key!=="history"),le=n?ne.filter(Se=>Se.key!=="terminal"):ne;return h?[{key:"team-status",label:"Team Status",icon:t.jsx(js,{size:14})},...le]:le},[i,x,n,h]),[I,W]=b.useState(()=>C?"preview":i?x?"history":"review":"editor"),$=b.useRef(null),A=b.useRef(0),[D,T]=b.useState(),O=b.useCallback(re=>{W(re),E&&L(!0)},[E,L]);b.useImperativeHandle(S,()=>({setTab:re=>O(re),openFile:(re,ne,le)=>{O("editor"),requestAnimationFrame(()=>$.current?.openFile(re,ne,le))},openPreview:(re,ne)=>{A.current+=1,T({id:A.current,source:re,workspaceId:ne}),O("preview")}}),[O]);const K=C??D,V=K?.workspaceId&&K.workspaceId!==o?void 0:K,B=b.useCallback(re=>{T(ne=>ne?.id===re?void 0:ne),k?.(re)},[k]),{data:U}=mu(m??""),H=b.useMemo(()=>{if(!U?.quickCommands)return[];try{return JSON.parse(U.quickCommands)}catch{return[]}},[U?.quickCommands]),[N,F]=b.useState([]),q=b.useRef(void 0);b.useEffect(()=>{p&&p!==q.current&&(q.current=p,F(re=>re.includes(p)?re:[...re,p]))},[p]),b.useEffect(()=>{z.some(re=>re.key===I)||W(z[0]?.key??"editor")},[I,z]),b.useEffect(()=>{if(E&&!M)return;const re=I==="review"?"changes":I==="history"?"history":null;if(!o||!p||!re){y(null);return}return y({workspaceId:o,workingDir:p,tab:re}),()=>{y(null)}},[I,M,E,y,p,o]);const Y=!!w&&no(v,h).length>1,se=z.find(re=>re.key===I)??z[0],G=se?j(se.label):"",pe=n?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:j(a?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,he=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(Hc,{workspaces:v,teamRun:h,selectedWorkspaceId:_,onSelectWorkspace:w,buttonClassName:"h-7 text-[11px]"})}),t.jsxs("div",{className:"relative flex-1 min-h-0 overflow-hidden",children:[I==="team-status"&&h&&c,I==="editor"&&t.jsx(j0,{ref:$,workingDir:p,readOnly:n}),N.map(re=>{const ne=I==="terminal"&&p===re;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(Fp,{cwd:re,workspaceId:ne?o:void 0,isVisible:ne,quickCommands:H})},re)}),I==="preview"&&t.jsx(tx,{workspaceId:o,readOnly:n,navigationRequest:V,onNavigationRequestHandled:B}),I==="review"&&t.jsx(B0,{workingDir:p,workspaceId:o,branchName:g?.branchName,targetBranch:g?.targetBranch,commitMessage:g?.commitMessage,canRunGitOperations:g?.canRunGitOperations,onRefreshCommitMessage:g?.onRefreshCommitMessage,onConflict:g?.onConflict,onResolveConflicts:g?.onResolveConflicts}),I==="history"&&t.jsx(q0,{workingDir:p})]})]});return E?t.jsxs("div",{className:Z("flex h-full w-full min-w-0 bg-white",s),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:z.map(re=>t.jsx(lx,{active:M&&I===re.key,onClick:()=>O(re.key),icon:re.icon,label:j(re.label)},re.key))}),M&&t.jsxs("div",{className:"flex h-full min-w-0 flex-1 flex-col border-l border-border bg-background",style:{minWidth:f},children:[pe,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:se?.icon}),t.jsx("span",{className:"truncate",children:G})]}),t.jsx("button",{type:"button",onClick:()=>L(!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:j("收起"),"aria-label":j("收起"),children:t.jsx(Vu,{size:15})})]}),he]})]}):t.jsxs("div",{className:Z("flex h-full w-full min-w-0 flex-col bg-white",s),children:[n&&pe,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:z.map(re=>t.jsx(ax,{active:I===re.key,onClick:()=>O(re.key),icon:re.icon,label:j(re.label)},re.key))}),he]})}),cx=3e3;function Ra(e,s){const r=new Map(e.map(o=>[o.workspaceId,o]));for(const o of s){const p=r.get(o.workspaceId);(!p||o.updatedAt>=p.updatedAt)&&r.set(o.workspaceId,o)}return[...r.values()]}function $c(e){const s=vt(),r=b.useRef({version:0,values:new Map}),[o,p]=b.useState(0),{data:m=[]}=Et({queryKey:ce.workspaces.setupProgress(e??""),enabled:!!e,refetchOnMount:"always",refetchInterval:a=>a.state.data?.some(h=>h.status==="running")?3e3:!1,queryFn:async({signal:a})=>{const h=r.current.version,c=await ye.get(`/tasks/${e}/setup-progress`,{signal:a}),g=[...r.current.values.values()].filter(v=>v.version>h&&v.progress.taskId===e).map(v=>v.progress);return Ra(c,g)}});b.useEffect(()=>{if(!e)return;const a=cs.connect(),h=ce.workspaces.setupProgress(e),c=v=>{if(v.taskId!==e)return;const _=r.current.values.get(v.workspaceId);_&&_.progress.updatedAt>v.updatedAt||(r.current.values.set(v.workspaceId,{version:++r.current.version,progress:v}),s.setQueryData(h,w=>Ra(w??[],[v])))},g=()=>{s.invalidateQueries({queryKey:h})};return a.on(dt.WORKSPACE_SETUP_PROGRESS,c),a.on("connect",g),()=>{a.off(dt.WORKSPACE_SETUP_PROGRESS,c),a.off("connect",g)}},[e,s]);const x=[...m].sort((a,h)=>h.updatedAt-a.updatedAt),i=x.find(a=>a.status==="running")??x.find(a=>a.status!=="running"&&a.updatedAt>o),n=i?.status!=="running"?i?.updatedAt??null:null;return b.useEffect(()=>{if(n===null)return;const a=setTimeout(()=>p(n),cx);return()=>clearTimeout(a)},[n]),i??null}function qc({isOpen:e,onClose:s,onStarted:r,taskId:o,projectId:p,taskTitle:m,taskDescription:x,taskPrompt:i,projectIsGitRepo:n=!0,projectWorktreeReady:a=!0,projectGitReason:h}){const{t:c}=de(),[g,v]=b.useState(""),[_,w]=b.useState(""),[l,u]=b.useState(bt.WORKTREE),[d,f]=b.useState(null),[S,C]=b.useState("idle"),[k,j]=b.useState(null),y=vt(),E=ql(o),R=Fn(),P=pu(),{data:M,isLoading:L}=Gs(),z=d?.isGitRepo??n,I=d?.worktreeReady??a,W=d?.reason??h,$=z!==!1&&I!==!1;b.useEffect(()=>{if(!e||!M)return;const se=M.find(G=>!ts(G));v(G=>G&&M.some(pe=>pe.provider.id===G)?G:se?.provider.id??"")},[e,M]),b.useEffect(()=>{if(e){const se=[m];x&&se.push(x),w(i?.trim()||se.join(`
68
-
69
- `)),f(null),u(n!==!1&&a!==!1?bt.WORKTREE:bt.MAIN_DIRECTORY),C("idle"),j(null)}},[e,n,a,o,m,x,i]),b.useEffect(()=>{$||u(bt.MAIN_DIRECTORY)},[$]);const A=async()=>{if(!p||P.isPending)return;const se=await P.mutateAsync({id:p});f(se),se.worktreeReady&&u(bt.WORKTREE)},D=S!=="idle",T=async()=>{if(!g||!_.trim())return;const se=M?.find(G=>G.provider.id===g);if(!(!se||ts(se))){j(null);try{C("creating-workspace");const G=await E.mutateAsync({workspaceKind:$?l:bt.MAIN_DIRECTORY});C("creating-session");const pe=await ye.post(`/workspaces/${G.id}/sessions`,{providerId:g,prompt:_.trim()});C("starting-session"),await R.mutateAsync(pe.id),await y.invalidateQueries({queryKey:ce.workspaces.list(o)}),C("idle"),r?.(),s()}catch(G){C("idle"),j(G instanceof Error?G.message:c("启动失败,请重试"))}}},O={idle:c("启动"),"creating-workspace":c("创建工作空间..."),"creating-session":c("创建会话..."),"starting-session":c("启动 Agent...")},K=(M??[]).map(se=>{const G=se.provider,pe=ts(se),he=!pe,re=G.executionPermission?c("Required permission: {mode}",{mode:c(hu[G.executionPermission])}):void 0;return{value:G.id,label:he?G.name:`${G.name}${c(" (不可用)")}`,description:[re,pe&&c(pe)].filter(Boolean).join(" · "),icon:t.jsx(vi,{agentType:G.agentType,className:"size-4"}),disabled:!he}}),V=M?.find(se=>se.provider.id===g),B=V?ts(V):void 0,U=!!M?.length&&M.every(se=>!!ts(se)),H=!L&&!M?.length,N=c("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),F=c("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),q=c(W==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),Y=[{value:bt.WORKTREE,label:c("工作树模式"),description:N,disabled:!$},{value:bt.MAIN_DIRECTORY,label:c("本地模式"),description:F}];return t.jsx(gs,{isOpen:e,onClose:D?()=>{}:s,title:c("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Ae,{variant:"outline",onClick:s,disabled:D,children:c("取消")}),t.jsx(Ae,{onClick:T,disabled:D||!V||!_.trim()||!!B,children:O[S]})]}),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:c("Agent")}),t.jsx(ds,{value:g,onChange:v,options:K,placeholder:c(L?"加载中...":"选择 Agent"),disabled:D||L}),B?t.jsx("p",{role:"alert",className:"mt-2 break-words text-xs leading-snug text-destructive",children:c(B)}):null,U&&!V?t.jsxs("div",{role:"alert",className:"mt-2 space-y-1 break-words text-xs leading-snug text-destructive",children:[t.jsx("p",{children:c("No available Provider for this session.")}),t.jsx("ul",{className:"space-y-1",children:M.map(se=>t.jsxs("li",{children:[se.provider.name,": ",c(ts(se))]},se.provider.id))})]}):null,H?t.jsx("p",{role:"alert",className:"mt-2 text-xs text-destructive",children:c("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:c("模式")}),$?t.jsx(ds,{value:l,onChange:se=>u(se),options:Y,disabled:D}):t.jsx(tu,{side:"bottom",className:"w-full",content:q,children:t.jsxs("div",{tabIndex:0,"aria-label":q,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(ds,{value:l,onChange:se=>u(se),options:Y,disabled:!0}),t.jsx("button",{type:"button",onClick:A,disabled:D||P.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:P.isPending?c("检测中..."):c("重新检测 Git 状态")})]})})]})]})}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:c("任务描述")}),t.jsx("textarea",{value:_,onChange:se=>w(se.target.value),rows:5,disabled:D,placeholder:c("描述你想让 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"})]}),k&&t.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:k})]})})}function Kc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function dx(e,s,r){const o=e?.providerId??r?.providerId??null,p=o?s?.find(n=>n.provider.id===o)?.provider:null,m=p?.name??o??e?.agentType??r?.agentType??null;if(!m)return null;const x=e?.agentType??p?.agentType??r?.agentType??null,i=o&&p?.name&&o!==p.name?`${p.name} (${o})`:m;return{label:m,title:i,agentType:x}}function Vc({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:x="top"}){const{t:i}=de(),n=dx(e,s,{providerId:p,agentType:m});return!n&&!r?null:t.jsxs("div",{className:`flex shrink-0 items-center ${o?"gap-1":"gap-2"}`,children:[n&&t.jsxs("div",{className:`flex shrink-0 items-center rounded-lg text-neutral-500 ${o?"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:`${i("Provider")}: ${n.title}`,children:[t.jsx(vi,{agentType:n.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:Fd(n.label,o?12:18)})]}),t.jsx(zn,{usage:r,tooltipSide:x})]})}function ux({isOpen:e,onClose:s,taskId:r}){const{t:o}=de(),[p,m]=b.useState("AUTO"),[x,i]=b.useState(null),[n,a]=b.useState([]),[h,c]=b.useState(null),g=Va();b.useEffect(()=>{e&&(m("AUTO"),i(null),a([]),c(null))},[e]);const v=g.isPending,_=!!x||n.length>0,w=async()=>{if(!v){if(!x&&n.length===0){c(o("请选择至少一个团队模板或成员预设。"));return}c(null);try{await g.mutateAsync({taskId:r,mode:p,...x?{teamTemplateId:x}:{},...n.length>0?{memberPresetIds:n}:{}}),s()}catch(u){if(u instanceof mi&&u.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(u instanceof Error?u.message:o("创建 TeamRun 失败"))}}},l=v||!_;return t.jsxs(gs,{isOpen:e,onClose:v?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Ae,{type:"button",variant:"outline",onClick:s,disabled:v,children:o("取消")}),t.jsx(Ae,{type:"button",onClick:w,disabled:l,children:o(v?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(nu,{mode:p,setMode:m,selectedTemplateId:x,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:a,disabled:v}),h&&t.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:h})]})}function hx({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=de(),p=so();if(s.operation==="idle"||s.conflictedFiles.length===0)return null;const m=s.operation==="rebase"?"Rebase":"Merge";return t.jsxs("div",{className:"mx-6 mt-3 flex items-center gap-3 rounded-lg border border-warning/25 bg-warning/[0.06] px-4 py-2.5",children:[t.jsx(As,{size:15,className:"text-warning shrink-0"}),t.jsxs("div",{className:"flex-1 min-w-0 flex items-center gap-2",children:[t.jsxs("span",{className:"text-sm font-medium text-foreground",children:[m," ",o("冲突")]}),t.jsxs("span",{className:"inline-flex items-center rounded-full bg-warning/15 px-2 py-0.5 text-xs font-semibold text-warning tabular-nums",children:[s.conflictedFiles.length," ",o("个文件")]})]}),t.jsxs("div",{className:"flex items-center gap-1.5 shrink-0",children:[t.jsx(Ae,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Ae,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function Yc(e){return e.length>0?e.map(s=>`- ${s}`).join(`
70
- `):"- 未获取到冲突文件列表"}function Xc(e){if(!e)return[];const s=[];return e.workspaceId&&s.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&s.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&s.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&s.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&s.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&s.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&s.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&s.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&s.push("- Merge state: conflict detected and already aborted by Agent Tower"),s}function fx(e,s){if(!s?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=s.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,o=s.mergeStrategy==="squash"?"`git commit`":"`git merge --continue` 或 `git commit`";return["1. 注意:Agent Tower 检测到 merge 冲突后已经执行 abort,当前不要假设存在冲突标记或 `MERGE_HEAD`","2. 切换到 Target worktree / Target branch 上下文,确认工作区干净",`3. 重新执行 \`${r}\` 复现冲突`,"4. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","5. 对每个已解决的文件执行 `git add <file>`",`6. 执行 ${o} 完成合并`]}function mx(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const s=e.targetWorktreePath?`目标 worktree \`${e.targetWorktreePath}\``:`目标分支 \`${e.targetBranch}\``,r=e.mergeStrategy==="squash"?`git merge --squash --no-commit ${e.sourceBranch}`:`git merge --no-ff ${e.sourceBranch}`;return`Agent Tower 已在检测到冲突后 abort 了 merge;请在${s}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function px(e,s,r,o,p){const m=Yc(r),x=Xc(p);return o===vr.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${s}\` 时发生了冲突。`,...x.length>0?["","### 上下文",...x]:[],"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
71
- `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${s}\` 时发生了冲突。`,...x.length>0?["","### 上下文",...x]:[],"","### 冲突文件",m,"","### 解决步骤",...fx(e,p)].join(`
72
- `)}function gx(e){const s=e.conflictOp===vr.REBASE?"Rebase":"Merge",r=Yc(e.conflictedFiles),o=[...Xc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===vr.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":mx(e)].join(`
73
- `)}function vx(e){if(e.teamRunId)return{type:"team_room",message:gx(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:px(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Gc({open:e,onOpenChange:s,workspaceId:r,conflictOp:o,conflictedFiles:p,sourceBranch:m,targetBranch:x,operation:i,worktreePath:n,mergeAborted:a,mergeStrategy:h,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:v,targetWorktreePath:_,sessions:w,currentSessionId:l,teamRunId:u}){const{t:d}=de(),[f,S]=b.useState(""),C=Wn(),k=Tn(u??""),j=eo(),y=!!u,E=l||f,R=y?k.isPending:C.isPending,P=()=>{const W=vx({workspaceId:r,worktreePath:n,operation:i,mergeAborted:a,mergeStrategy:h,sourceWorkspaceId:c,targetWorkspaceId:g,sourceWorktreePath:v,targetWorktreePath:_,sourceBranch:m,targetBranch:x,conflictedFiles:p,conflictOp:o,teamRunId:u,currentSessionId:l,selectedSessionId:f});if(W.type==="team_room"){k.mutate({content:W.message,kind:"chat"},{onSuccess:()=>{ot.success(d("已发送到 Team Room")),s(!1)}});return}W.type==="session"&&C.mutate({id:W.sessionId,message:W.message},{onSuccess:()=>s(!1)})},M=()=>{j.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},L=o==="REBASE"?"Rebase":"Merge",z=!y&&!l&&w.length>0,I=y||!!E;return t.jsx(gs,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:L}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Ae,{variant:"outline",onClick:M,children:d("在 IDE 中打开")}),t.jsx(Ae,{onClick:P,disabled:!I||R,children:d(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:d("冲突文件({count})",{count:p.length})}),t.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(W=>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:W},W))})]}),y&&t.jsx("div",{className:"rounded-md border border-blue-100 bg-blue-50 px-3 py-2 text-sm text-blue-800",children:d("TeamRun 模式下会把处理冲突请求发送到 Team Room,由团队调度处理。")}),z&&t.jsxs("div",{children:[t.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),t.jsxs("select",{value:f,onChange:W=>S(W.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:d("选择一个 Session...")}),w.map(W=>t.jsxs("option",{value:W.id,children:[W.agentType," — ",W.status]},W.id))]})]}),!y&&!E&&w.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function xx(e){return[...e?.uncommitted??[],...e?.committed??[]].reduce((r,o)=>({files:r.files+1,additions:r.additions+(o.additions??0),deletions:r.deletions+(o.deletions??0)}),{files:0,additions:0,deletions:0})}function Aa(e,s,r,o){const p=Lc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Qc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,changes:p,gitStatus:m,isGitStatusLoading:x,canRunGitOperations:i,onOpenChanges:n,onRefreshCommitMessage:a,onConflict:h,className:c}){const{t:g}=de(),v=Vl(),_=Kl(),w=so(),[l,u]=b.useState(!1),[d,f]=b.useState(null),S=ao(e,l),C=(S.data??[]).filter(Mc),k=b.useMemo(()=>xx(p),[p]),j=k.additions+k.deletions,y=k.files>0&&j>0,E=(m?.conflictedFiles.length??0)>0,R=!!(m&&m.operation!=="idle"),P=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),M=(m?.uncommittedCount??0)+(m?.untrackedCount??0),L=(m?.behind??0)>0,z=(m?.ahead??0)>0,I=x||!m&&i,W=!!(i&&e&&m&&L&&!E&&!R&&!P),$=!!(i&&e&&m&&z&&!L&&!E&&!R&&!P);if(b.useEffect(()=>{l&&a?.()},[l,a]),!y)return null;const A=E?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):M>0?g("{count} 未提交",{count:M}):L?g("落后 {count}",{count:m?.behind??0}):g(z?"可合并":"已是最新"),D=g("{files} 个文件 · {lines} 行",{files:k.files,lines:j}),T=()=>{W&&(f(null),v.mutate(e,{onError:B=>{Aa(B,g("更新失败,请稍后重试"),U=>h(U),f)}}))},O=()=>{$&&(f(null),u(!0))},K=(B,U)=>{f(null),_.mutate({id:e,commitMessage:B,stopActiveServices:U},{onSuccess:()=>u(!1),onError:H=>{if(Dc(H)){f(g("后台服务仍在运行,请确认停止服务后再提交。"));return}Aa(H,g("提交失败,请稍后重试"),N=>{u(!1),h(N)},f)}})},V=()=>{_.isPending||(u(!1),f(null))};return t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:Z("space-y-1",c),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:n,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":g("查看变更详情"),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(Qs,{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:D}),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]})]}),E&&t.jsx(As,{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:s}),t.jsx("span",{className:"text-muted-foreground/40",children:"→"}),t.jsx("span",{className:"truncate font-mono",children:r})]}),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:A})]}),t.jsx(At,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[R&&t.jsx("button",{type:"button",onClick:()=>w.mutate(e),disabled:w.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:w.isPending?g("正在撤销..."):g("撤销操作")}),t.jsxs("button",{type:"button",onClick:T,disabled:!W||v.isPending||I,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:g(L?"同步更新":"已是最新"),children:[v.isPending?t.jsx(Be,{size:12,className:"animate-spin"}):t.jsx(Ts,{size:12}),t.jsx("span",{children:v.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!$||_.isPending||I,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:$?g("合并到 {target}",{target:r}):g("提交变更"),children:[_.isPending?t.jsx(Be,{size:12,className:"animate-spin"}):t.jsx(ti,{size:12}),t.jsx("span",{children:_.isPending?g("正在提交..."):g("合并")})]})]})]}),d&&t.jsx("div",{className:"rounded-lg border border-destructive/20 bg-destructive/5 px-3 py-1.5 text-xs text-destructive",children:d})]}),t.jsx(Pc,{isOpen:l,onClose:V,branchName:s,targetBranch:r,commitMessage:o,isPending:_.isPending,activeServices:C,isCheckingServices:S.isLoading,serviceCheckFailed:S.isError,error:d,onConfirm:K})]})}const Ta=["creating-workspace","creating-session","starting-session"];function Zc({state:e,setupProgress:s,sessionStarted:r=!1,onRetry:o,compact:p=!1}){const{t:m}=de(),[x,i]=b.useState(!1),n=e?.status==="failed",a=s?.status==="failed",h=n||a,c=e?Ta.indexOf(e.status):Ta.length,g=[m("Preparing workspace"),m("Creating session"),m("Starting agent")],v=(e?.setupScript??"").split(`
74
- `).map(l=>l.trim()).filter(Boolean),_=e||r?g.map((l,u)=>({label:l,status:n?"pending":u<c?"completed":u===c?"active":"pending"})):[];(s||v.length>0)&&_.push({label:s?.status==="running"?m("Running setup ({current}/{total})",{current:s.currentIndex??0,total:s.totalCommands}):s?.status==="completed"?m("Setup complete"):s?.status==="failed"?m("Setup failed"):m("Run setup script"),status:s?.status==="running"?"active":s?.status??"pending",description:s?.currentCommand||v.join(`
75
- `)});const w=!!s?.output?.trim();return!e&&!s?null:t.jsxs("div",{className:`${p?"my-2 mb-4":"my-3 mb-6"} mx-auto w-full max-w-2xl rounded-xl border ${h?"border-destructive/30 bg-destructive/[0.03]":"border-border/70 bg-background"} px-4 py-3 text-left shadow-sm`,role:h?"alert":"status","aria-live":h?"assertive":"polite",children:[h&&(e?.error||s?.error||n)?t.jsx("p",{className:"mb-2 break-words text-xs text-destructive/80",children:e?.error||s?.error||m("Agent start failed")}):null,t.jsx("div",{className:"space-y-2",children:_.map(({label:l,status:u,description:d})=>{const f=u==="completed",S=u==="active";return t.jsxs("div",{className:`flex items-start gap-2 text-sm ${u==="failed"?"text-destructive":f||S?"text-info":"text-muted-foreground"}`,children:[f?t.jsx(zd,{className:"h-4 w-4 shrink-0"}):S?t.jsx(Be,{className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none"}):u==="failed"?t.jsx(Ka,{className:"h-4 w-4 shrink-0"}):t.jsx(uu,{className:"h-4 w-4 shrink-0"}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsx("span",{children:l}),d&&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:d})]})]},l)})}),(w||n)&&t.jsxs("div",{className:"mt-3 flex items-center justify-between gap-3 border-t border-border/50 pt-2",children:[w?t.jsxs("button",{type:"button",onClick:()=>i(l=>!l),className:"inline-flex items-center gap-1 text-xs text-muted-foreground transition-colors hover:text-foreground","aria-expanded":x,"aria-controls":"task-start-progress-details",children:[x?t.jsx(kt,{className:"h-3.5 w-3.5"}):t.jsx(At,{className:"h-3.5 w-3.5"}),m(x?"Hide setup output":"View setup output")]}):t.jsx("span",{}),n&&o?t.jsx(Ae,{size:"sm",variant:"outline",onClick:o,children:m("Retry start")}):null]}),x&&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:s?.output??""})})]})}function bx({agentType:e,workingDir:s}){return Et({queryKey:ce.system.skillCatalog(e,s),queryFn:async()=>(await ye.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Nt.CODEX,staleTime:3e4})}function _x(e){const s=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return s||r}function Jc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:x}){const[i,n]=b.useState(0),{data:a=[]}=bx({agentType:e,workingDir:s}),c=b.useMemo(()=>e===Nt.CODEX?Co(r):null,[e,r])?.query??null,g=b.useMemo(()=>c===null?[]:ou(a,c),[c,a]),v=b.useCallback(()=>{const l=p.current;l&&(l.style.height="auto",l.style.height=`${Math.max(m,Math.min(l.scrollHeight,x))}px`)},[x,m,p]);b.useEffect(()=>{n(0)},[e,c]),b.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const _=b.useCallback(l=>{const u=Co(r);if(!u)return;const d=`${r.slice(0,u.replaceStart)}${l.command} `;o(d),requestAnimationFrame(()=>{const f=p.current;f&&(v(),f.focus(),f.setSelectionRange(d.length,d.length))})},[r,v,o,p]),w=b.useCallback(l=>c===null||g.length===0?!1:l.key==="ArrowDown"?(l.preventDefault(),n(u=>(u+1)%g.length),!0):l.key==="ArrowUp"?(l.preventDefault(),n(u=>(u-1+g.length)%g.length),!0):_x(l)?(l.preventDefault(),_(g[i]??g[0]),!0):!1,[_,g,c,i]);return{allSkills:a,query:c,filteredSkills:g,selectedIndex:i,setSelectedIndex:n,applySkill:_,handleKeyDown:w}}const an=200,yx=180;function ed({taskId:e,title:s,readOnly:r=!1,onTitleChange:o,className:p,titleClassName:m,compact:x=!1}){const{t:i}=de(),[n,a]=b.useState(!1),[h,c]=b.useState(s),[g,v]=b.useState(!1),_=b.useRef(null),w=b.useRef(null),l=Ya();b.useEffect(()=>{n||c(s)},[s,n]),b.useEffect(()=>{n&&_.current&&(_.current.focus(),_.current.select())},[n]),b.useEffect(()=>{if(!n)return;const E=R=>{w.current&&!w.current.contains(R.target)&&f()};return document.addEventListener("mousedown",E),()=>document.removeEventListener("mousedown",E)},[n,h]);const u=b.useCallback(()=>{r||(a(!0),c(s))},[r,s]),d=b.useCallback(()=>{a(!1),c(s)},[s]),f=b.useCallback(async()=>{const E=h.trim();if(!E){c(s),a(!1);return}if(E===s){a(!1);return}try{await l.mutateAsync({id:e,title:E}),o?.(E),a(!1)}catch(R){console.error("Failed to update task title:",R),c(s)}},[h,s,e,l,o]),S=b.useCallback(E=>{E.key==="Enter"&&!E.shiftKey?(E.preventDefault(),f()):E.key==="Escape"&&(E.preventDefault(),d())},[f,d]),C=b.useCallback(E=>{const R=E.target.value;R.length<=an&&c(R)},[]),k=h.length,j=k>=yx,y=k>=an;return n?t.jsxs("div",{ref:w,className:Z("flex flex-col gap-2",p),children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{ref:_,type:"text",value:h,onChange:C,onKeyDown:S,disabled:l.isPending,className:Z("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",x&&"text-base py-0.5",m),placeholder:i("输入任务标题")}),t.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[t.jsx(Ae,{size:x?"sm":"default",variant:"ghost",onClick:f,disabled:l.isPending||!h.trim(),className:"h-8 w-8 p-0",children:l.isPending?t.jsx(Be,{size:16,className:"animate-spin"}):t.jsx(Wt,{size:16})}),t.jsx(Ae,{size:x?"sm":"default",variant:"ghost",onClick:d,disabled:l.isPending,className:"h-8 w-8 p-0",children:t.jsx(Gt,{size:16})})]})]}),j&&t.jsxs("div",{className:Z("text-xs",y?"text-destructive":"text-muted-foreground"),children:[k," / ",an," ",i("字符")]})]}):t.jsxs("div",{ref:w,className:Z("group flex items-center gap-2 min-w-0",p),onMouseEnter:()=>v(!0),onMouseLeave:()=>v(!1),children:[t.jsx("h2",{onClick:u,className:Z("flex-1 min-w-0 text-lg font-semibold text-foreground break-words line-clamp-2",!r&&"cursor-text hover:text-foreground/80 transition-colors",x&&"text-base",m),children:s}),!r&&g&&t.jsx(Ae,{size:"sm",variant:"ghost",onClick:u,className:"h-7 w-7 p-0 shrink-0 opacity-60 hover:opacity-100",title:i("编辑标题"),children:t.jsx(xu,{size:14})})]})}const Sx=wr(),wx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Sx}/attachments/by-path?path=${encodeURIComponent(e)}`:e,zs=520,ln=48,Cx=4,kx=420;function Ex(){const{t:e}=de();return t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-background text-muted-foreground/70 select-none",children:[t.jsx("div",{className:"w-16 h-16 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-6",children:t.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-muted-foreground/50",children:[t.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),t.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),t.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),t.jsx("h3",{className:"text-foreground font-medium mb-2 text-lg",children:"Agent Tower"}),t.jsx("p",{className:"text-sm max-w-sm text-center text-muted-foreground leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const Ma=[{status:_e.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:t.jsx(nl,{className:"w-3 h-3"})},{status:_e.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:t.jsx(il,{className:"w-3 h-3"})},{status:_e.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:t.jsx(rl,{className:"w-3 h-3"})},{status:_e.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:t.jsx(sl,{className:"w-3 h-3"})},{status:_e.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:t.jsx(tl,{className:"w-3 h-3"})}];function jx({status:e,onChangeStatus:s}){const{t:r}=de(),[o,p]=b.useState(!1),m=b.useRef(null);b.useEffect(()=>{if(!o)return;const i=n=>{m.current&&!m.current.contains(n.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[o]);const x=Ma.find(i=>i.status===e);return t.jsxs("div",{className:"relative",ref:m,children:[t.jsxs("button",{onClick:()=>s&&p(i=>!i),className:`flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium transition-colors ${x.className} ${s?"cursor-pointer hover:opacity-80":""}`,children:[x.icon,t.jsx("span",{children:r(e)}),s&&t.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${o?"rotate-180":""}`,children:t.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),o&&t.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-background rounded-lg border border-border shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:Ma.filter(i=>i.status!==e).map(i=>t.jsxs("button",{onClick:()=>{s?.(i.status),p(!1)},className:`w-full flex items-center gap-2 px-3 py-2 text-xs font-medium transition-colors ${i.hoverClass}`,children:[t.jsx("span",{className:i.className.split(" ").find(n=>n.startsWith("text-")),children:i.icon}),t.jsx("span",{className:"text-foreground/80",children:r(i.status)})]},i.status))})]})}function Nx({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,onTaskPriorityChange:p,autoStartState:m,onAutoStartRecovered:x}){const{t:i}=de(),[n,a]=b.useState(""),[h,c]=b.useState(!1),[g,v]=b.useState(!1),[_,w]=b.useState(!1),[l,u]=b.useState(!1),[d,f]=b.useState(!1),[S,C]=b.useState(!1),[k,j]=b.useState(null),y=b.useRef(null),[E,R]=b.useState(!1),[P,M]=b.useState(null),[L,z]=b.useState(void 0),[I,W]=b.useState(!1),$=b.useRef(null),A=b.useRef(null),D=b.useRef(null),T=b.useRef(null),{scrollRef:O,contentRef:K,isAtBottom:V,scrollToBottom:B,stopScroll:U}=On({resize:"smooth",initial:"instant"}),[H,N]=b.useState(!1),[F,q]=b.useState(zs),[Y,se]=b.useState(!1),G=b.useRef(0),pe=b.useRef(zs),he=b.useRef(null),re=b.useCallback((Q,oe,Ie)=>{y.current?.openFile(Q,oe,Ie)},[]),{data:ne,isLoading:le}=Jn(e?.id??""),Se=$c(e?.id),We=Se?.status==="completed"&&m?.status!=="failed"?null:m,Ee=!!(We||Se&&Se.status!=="completed"),{data:He}=Xa(e?.id??""),{data:at}=Ga(He?.id??""),Me=Tn(He?.id??""),Ne=He??null,Oe=!!Ne,$e=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,qe=He===null&&$e,De=!!(e?.id&&He===null),{data:Ge,isLoading:Qe}=Qa(e?.id??"",De);b.useEffect(()=>{W(!1),M(null),z(void 0)},[e?.id]);const Te=b.useMemo(()=>Jl(ne,Ne,L),[L,Ne,ne]);b.useEffect(()=>{L&&!ne?.some(Q=>Q.id===L)&&z(void 0)},[L,ne]);const ge=b.useMemo(()=>ne?.find(Q=>Q.id===Te),[Te,ne]),et=ge?.status===Pt.ACTIVE?ge.id:void 0,Xe=$e&&ec(ge,Ne);b.useEffect(()=>{if(!I||!ne)return;ne.some(oe=>oe.status==="ACTIVE"&&oe.sessions&&oe.sessions.length>0)&&W(!1)},[ne,I]);const Ue=b.useMemo(()=>{if(I||!ne)return null;const Q=gt=>{const Fi=gt.createdAt,or=gt.endedAt??gt.startedAt??Fi;if(!or)return 0;const Os=Date.parse(or);return Number.isNaN(Os)?0:Os},oe=(gt,Fi)=>{const or=gt.filter(Os=>Fi.includes(Os.status));return or.length===0?null:or.sort((Os,Cd)=>Q(Cd)-Q(Os))[0]??null},Ie=ne.filter(gt=>gt.status==="ACTIVE"&&Array.isArray(gt.sessions)).flatMap(gt=>gt.sessions??[]),mt=oe(Ie,[ut.RUNNING])??oe(Ie,[ut.PENDING])??oe(Ie,[ut.COMPLETED,ut.FAILED,ut.CANCELLED]);if(mt)return mt;const pt=ne.filter(gt=>(gt.status==="MERGED"||gt.status==="ABANDONED"||gt.status==="HIBERNATED")&&Array.isArray(gt.sessions)).flatMap(gt=>gt.sessions??[]);return oe(pt,[ut.COMPLETED,ut.FAILED,ut.CANCELLED])},[ne,I]),ft=Ue?.id??"",tt=Oe?P??"":ft,ee=b.useMemo(()=>{if(!P||!ne)return null;for(const Q of ne){const oe=Q.sessions?.find(Ie=>Ie.id===P);if(oe)return oe}return null},[P,ne]),fe=b.useMemo(()=>{if(!P||!Ne?.invocations)return null;const Q=Ne.invocations.filter(oe=>oe.sessionId===P);return Q.length===0?null:Q.sort((oe,Ie)=>{const mt=Date.parse(oe.updatedAt??oe.createdAt??""),pt=Date.parse(Ie.updatedAt??Ie.createdAt??"");return(Number.isNaN(pt)?0:pt)-(Number.isNaN(mt)?0:mt)})[0]??null},[P,Ne?.invocations]),we=b.useMemo(()=>!fe?.memberId||!Ne?.members?null:Ne.members.find(Q=>Q.id===fe.memberId)??null,[fe?.memberId,Ne?.members]),X=P?ee:Ue??null,te=X?.id,ie=b.useMemo(()=>{if(X?.workspaceId)return X.workspaceId;if(!(!X||!ne))return ne.find(Q=>Q.sessions?.some(oe=>oe.id===X.id))?.id},[X,ne]),ae=b.useCallback((Q,oe)=>{const mt=(oe&&ne?.some(pt=>pt.id===oe)?oe:void 0)??ie??Te??void 0;mt&&z(mt),y.current?.openPreview(Q,mt)},[ie,Te,ne]),Ce=b.useCallback((Q,oe)=>{ae({kind:"web",url:Q},oe)},[ae]),ke=b.useCallback((Q,oe,Ie)=>{ae({kind:"visualization",sessionId:Q,file:oe},Ie)},[ae]),Pe=b.useCallback(Q=>{Ce(Q,ie)},[ie,Ce]),Je=b.useCallback(Q=>{te&&ke(te,Q,ie)},[te,ie,ke]),{isActive:be,isCancelling:xe}=ll(te??"",X?.status),me=!!e?.projectArchivedAt,Fe=!!e?.projectRepoDeletedAt,st=i(Fe?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:lt}=Gs(),[jt,wt]=b.useState(null),xt=Ue?vl(lt,jt??Ue.providerId):void 0;b.useEffect(()=>{wt(Ue?.providerId??null)},[Ue?.providerId]);const It=b.useMemo(()=>!Ue||!ne?!1:!ne.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(Ie=>Ie.id===Ue.id)),[Ue,ne]),Ct=b.useMemo(()=>{if(!(!ne||I)){if(ge)return fs(ge);for(const Q of ne)if(Q.status==="ACTIVE"&&fs(Q))return fs(Q);return fs(ne[0])}},[I,ge,ne]),Tt=cl({agentType:Ue?.agentType,workingDir:Ct,input:n,setInput:a,textareaRef:D,minHeight:60,maxHeight:300}),$t=Jc({agentType:Ue?.agentType,workingDir:Ct,input:n,setInput:a,textareaRef:D,minHeight:60,maxHeight:300}),er=Rs(Q=>Q.setVisibleContext),qt=!!(Xe&&et&&Ct&&!me),{data:_t,isLoading:Ti}=to(et??"",{enabled:qt}),{data:Qt}=Ai(Ct,{enabled:qt});b.useEffect(()=>{if(!(H||!qt||!et||!Ct))return er({workspaceId:et,workingDir:Ct,tab:"changes"}),()=>{er(null)}},[H,et,er,qt,Ct]);const Zt=ge?.sessions??[],rs=Xs(ge),bs=ge?.commitMessage,Ms=b.useMemo(()=>tc(ge,ne,e?.mainBranch??""),[ge,e?.mainBranch,ne]),rt=b.useMemo(()=>_t?.conflictOp&&_t.conflictedFiles.length>0?{conflictOp:_t.conflictOp,conflictedFiles:_t.conflictedFiles}:k,[_t?.conflictOp,_t?.conflictedFiles,k]),tr=rt?.targetWorkspaceId??et,Tr=rt?.targetWorktreePath??ge?.worktreePath,Mr=rt?.sourceBranch??rs,Dr=rt?.targetBranch??Ms,it=vt(),Ds=b.useCallback(async()=>e?.id?it.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>ye.get(`/tasks/${e.id}/body`)}):null,[it,e?.id]),_s=b.useCallback(()=>e?.id?it.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,it]);b.useEffect(()=>{if(!E)return;const Q=oe=>{A.current&&!A.current.contains(oe.target)&&R(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[E]);const Jt=Wn(),Pr=eo(),ys=Wd(),Lr=ql(e?.id??""),sr=Fn(),Ps=Kf(),Ot=b.useMemo(()=>!ne||ne.some(oe=>oe.status==="ACTIVE")?null:ne.find(oe=>oe.status==="HIBERNATED")??null,[ne]),is=b.useRef(null);b.useEffect(()=>{Ot&&is.current!==Ot.id&&(Ps.isPending||(is.current=Ot.id,Ps.mutate(Ot.id,{onSettled:()=>{is.current=null}})))},[Ot,Ps]);const Mi=b.useCallback(async()=>{if(!e?.id)return;const Q=Ue?.providerId??lt?.find(oe=>oe.availability.type!=="NOT_FOUND")?.provider.id;if(Q){u(!1),f(!0);try{const Ie=(await Ds())?.prompt??e.title;await ys.mutateAsync(e.id),W(!0);const mt=await Lr.mutateAsync({workspaceKind:$e?void 0:bt.MAIN_DIRECTORY}),pt=await ye.post(`/workspaces/${mt.id}/sessions`,{providerId:Q,prompt:Ie});await sr.mutateAsync(pt.id),await it.invalidateQueries({queryKey:ce.workspaces.list(e.id)})}catch(oe){console.error("[retry] failed:",oe),W(!1)}finally{f(!1)}}},[e?.id,e?.title,$e,Ue?.providerId,lt,Ds,ys,Lr,sr,it]),Ls=b.useCallback(async()=>{e?.id&&(await Ds(),c(!0))},[Ds,e?.id]),Ir=b.useCallback(()=>{ge?.id&&Pr.mutate({workspaceId:ge.id})},[Pr,ge?.id]),rr=b.useCallback(()=>{!e?.id||!s||(s(e.id),w(!1))},[e?.id,s]),ir=b.useCallback(Q=>{M(Q),requestAnimationFrame(()=>{B()})},[B]),Di=b.useCallback(()=>{M(null)},[]),Is=b.useCallback(Q=>{j(Q??null),C(!0)},[]),Or=b.useCallback(Q=>Me.mutateAsync(Q),[Me]),ns=b.useCallback(()=>{it.invalidateQueries({queryKey:Hd.all})},[it]),{isConnected:Br,isLoadingSnapshot:nr,isOutputActive:Fr,lastExitAt:zr,logs:Ss,entries:Pi,attach:Kt}=pl({sessionId:tt,sessionStatus:X?.status,sessionStartedAt:X?.startedAt??X?.createdAt,sessionEndedAt:X?.endedAt??(be?null:X?.updatedAt),onExit:b.useCallback(()=>{it.invalidateQueries({queryKey:["workspaces"]})},[it])});b.useEffect(()=>{if(!e?.id)return;const Q=cs.connect();Q.emit(Ws.SUBSCRIBE,{topic:"task",id:e.id});const oe=pt=>{pt.taskId===e.id&&(it.invalidateQueries({queryKey:["tasks"]}),ns())},Ie=pt=>{pt.taskId===e.id&&(it.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),ns())},mt=pt=>{pt.taskId===e.id&&(it.invalidateQueries({queryKey:ce.workspaces.list(e.id)}),ns())};return Q.on(dt.TASK_UPDATED,oe),Q.on(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.on(dt.WORKSPACE_HIBERNATED,mt),()=>{Q.off(dt.TASK_UPDATED,oe),Q.off(dt.WORKSPACE_COMMIT_MESSAGE_UPDATED,Ie),Q.off(dt.WORKSPACE_HIBERNATED,mt),Q.emit(Ws.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,it,ns]),b.useEffect(()=>{if(!tt)return;const Q=cs.connect(),oe=Ie=>{Ie.sessionId===tt&&(it.invalidateQueries({queryKey:["workspaces"]}),ns())};return Q.on(dt.SESSION_COMPLETED,oe),()=>{Q.off(dt.SESSION_COMPLETED,oe)}},[tt,it,ns]);const{todos:J}=gl(Pi),{files:ve,addFiles:Re,removeFile:ze,clear:yt,buildMarkdownLinks:Bt,hasFiles:Le,isUploading:Ft}=Mn(),os=b.useMemo(()=>Kc(X),[X?.tokenUsage]),ws=dl(Ss,os);b.useEffect(()=>{tt&&Br&&Kt()},[tt,Br,Kt]);const po=b.useRef(e?.id);b.useEffect(()=>{if(po.current!==e?.id&&O.current){const Q=O.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}po.current=e?.id},[e?.id,O]);const as=ul(),Li=b.useRef(!1),go=b.useCallback(async()=>{if(!n.trim()&&!Le||!tt||Li.current||as.isPending||xe||Ft||xt)return;Li.current=!0;const Q=Bt(),oe=[n.trim(),Q].filter(Boolean).join(`
76
-
77
- `);a(""),yt(),D.current&&(D.current.style.height="60px"),Jt.mutate({id:tt,message:oe,providerId:jt??void 0},{onSuccess:()=>{Kt()},onError:()=>{a(Ie=>Ie||oe)},onSettled:()=>{Li.current=!1}})},[n,tt,Jt,Kt,Le,Ft,Bt,yt,jt,xt,as.isPending,xe]),pd=b.useCallback(()=>{!tt||as.isPending||as.mutate(tt)},[tt,as]),gd=b.useCallback(Q=>{const oe=Q.target.files;oe&&oe.length>0&&Re(Array.from(oe)),Q.target.value=""},[Re]),vd=b.useCallback(Q=>{const oe=Q.clipboardData.items,Ie=[];for(const mt of oe)if(mt.kind==="file"){const pt=mt.getAsFile();pt&&Ie.push(pt)}Ie.length>0&&(Q.preventDefault(),Re(Ie))},[Re]),[vo,Ii]=b.useState(!1),xd=b.useCallback(Q=>{Q.preventDefault(),Ii(!0)},[]),bd=b.useCallback(Q=>{Q.preventDefault(),Ii(!1)},[]),_d=b.useCallback(Q=>{Q.preventDefault(),Ii(!1);const oe=Q.dataTransfer.files;oe.length>0&&Re(Array.from(oe))},[Re]),es=b.useCallback(Q=>{const oe=he.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ie=oe?Math.max(zs,oe-ln-Cx-kx):zs;return Math.max(zs,Math.min(Math.round(Q),Ie))},[]),Oi=b.useCallback(Q=>{const oe=Q.clientX-G.current;q(es(pe.current-oe))},[es]),Bi=b.useCallback(()=>{se(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);b.useEffect(()=>{if(Y)return document.addEventListener("mousemove",Oi),document.addEventListener("mouseup",Bi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Oi),document.removeEventListener("mouseup",Bi),document.body.style.cursor="",document.body.style.userSelect=""}},[Bi,Oi,Y]);const yd=b.useCallback(Q=>{Q.preventDefault(),G.current=Q.clientX,pe.current=F,se(!0)},[F]);b.useEffect(()=>{!H||Y||q(Q=>es(Q))},[es,H,Y]),b.useEffect(()=>{if(!H)return;const Q=()=>{q(oe=>es(oe))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[es,H]);const Sd=b.useCallback(()=>{q(Q=>es(Q)),N(!0),requestAnimationFrame(()=>{y.current?.setTab("review")})},[es]),wd=b.useCallback(Q=>{a(Q.target.value);const oe=Q.target;oe.style.height="auto";const Ie=oe.scrollHeight;oe.style.height=`${Math.max(60,Math.min(Ie,300))}px`},[]),xo=qt&&et?t.jsx(Qc,{workspaceId:et,branchName:rs,targetBranch:Ms,commitMessage:bs,changes:Qt,gitStatus:_t,isGitStatusLoading:Ti,canRunGitOperations:Xe,onOpenChanges:Sd,onRefreshCommitMessage:_s,onConflict:Is,className:"mb-1.5"}):null;return e?t.jsxs("div",{className:"flex-1 flex flex-col h-full bg-background relative overflow-hidden",children:[t.jsxs("div",{className:"px-6 py-3 flex items-center justify-between border-b border-border/60 bg-background z-20 flex-shrink-0",children:[t.jsxs("div",{className:"flex flex-col min-w-0 flex-1 mr-4",children:[t.jsxs("div",{className:"flex items-center gap-1.5 mb-0.5",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${e.projectColor.replace("text-","bg-")}`}),t.jsx("span",{className:"text-xs text-muted-foreground truncate",children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-muted px-2 py-0.5 text-[10px] font-medium text-muted-foreground shrink-0",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),t.jsx("span",{className:"text-muted-foreground/40 text-xs",children:"/"}),t.jsx("span",{className:"text-xs text-muted-foreground/70 font-mono truncate",children:e.branch})]}),t.jsx(ed,{taskId:e.id,title:e.title,readOnly:me})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(jx,{status:e.status,onChangeStatus:!me&&o?Q=>o(e.id,Q):void 0}),t.jsx(hl,{value:e.priority,onChange:!me&&p?Q=>p(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:Ir,disabled:!Ct||me,className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:i("Open in IDE"),children:t.jsx(xi,{size:16})}),(s||qe)&&!me&&t.jsxs("div",{className:"relative",ref:A,children:[t.jsx("button",{onClick:()=>R(Q=>!Q),className:"w-8 h-8 flex items-center justify-center rounded-md text-muted-foreground/70 hover:text-foreground hover:bg-muted transition-colors",title:i("More actions"),children:t.jsx(yl,{size:16})}),E&&t.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-background rounded-lg border border-border shadow-lg z-50 py-1",children:[qe&&t.jsxs("button",{onClick:()=>{v(!0),R(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(us,{size:15}),t.jsx("span",{children:i("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{u(!0),R(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-foreground/80 hover:bg-muted/50 transition-colors",children:[t.jsx(Ud,{size:15}),t.jsx("span",{children:i("重新开始")})]}),s&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"my-1 border-t border-border/60"}),t.jsxs("button",{onClick:()=>{w(!0),R(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-destructive hover:bg-destructive/10 transition-colors",children:[t.jsx(pi,{size:15}),t.jsx("span",{children:i("删除任务")})]})]})]})]})]})]})]}),Xe&&et&&_t&&t.jsx(hx,{workspaceId:et,gitStatus:_t,onResolve:()=>Is()}),t.jsxs("div",{ref:he,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Oe&&Ne?P?t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-border px-4 py-3",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-foreground",children:i("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-muted-foreground",children:P})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx(Vc,{session:X,providers:lt,usage:ws,providerIdFallback:we?.providerId,agentTypeFallback:X?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Ae,{type:"button",size:"sm",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-border/70 bg-background/60 px-2 text-xs font-medium text-muted-foreground hover:border-muted-foreground/40 hover:bg-muted hover:text-foreground",onClick:Di,children:[t.jsx(Ks,{size:13}),t.jsx("span",{children:i("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:O,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsx("div",{ref:K,className:"w-full max-w-4xl mx-auto",children:nr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:i("Loading logs...")})]}):Ss.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:i(be?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Jr,{children:t.jsx(Qr,{logs:Ss,downloadSessionId:te,isOutputActive:Fr,lastExitAt:zr,onUserToggleDetails:U,workingDir:Ct,scrollElementRef:O,onOpenWorkspaceFile:re,onOpenPreviewUrl:Pe,onOpenVisualization:Je})})})}),!V&&t.jsxs("button",{onClick:()=>B(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":i("Scroll to bottom"),children:[t.jsx(xr,{size:14}),t.jsx("span",{children:i("回到底部")})]})]}),J.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(ei,{todos:J})})})]}):t.jsx(Zl,{teamRun:Ne,messages:at??Ne.messages??[],readOnly:me,readOnlyMessage:st,onSendMessage:Or,onViewInvocationSession:ir,changeSummaryBar:xo,centered:!0,workingDir:Ct,onOpenWorkspaceFile:re,onOpenPreviewUrl:Ce,onOpenVisualization:ke}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:O,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:t.jsxs("div",{ref:K,className:"w-full min-w-0 max-w-4xl mx-auto",children:[(Qe||Ge?.body)&&t.jsx("div",{className:"mb-4 pb-4 border-b border-border/60 min-w-0",children:Qe?t.jsx("p",{className:"text-sm text-muted-foreground/70 italic",children:i("Loading...")}):Ge?.body?t.jsx("div",{className:"text-sm text-muted-foreground leading-relaxed prose prose-sm max-w-none break-words overflow-hidden",children:t.jsx(Pn,{urlTransform:wx,components:el,children:Ge.body})}):null}),!me&&t.jsx(Zc,{state:We,setupProgress:Se,sessionStarted:!!Ue?.startedAt,onRetry:ft&&m?.status==="failed"?Ls:void 0},e.id),le?(!Ee||me)&&t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:i("Loading...")})]}):ft?nr?t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-muted-foreground/70",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:i("Loading logs...")})]}):Ss.length===0?t.jsx("div",{className:"text-muted-foreground/70 text-center py-8",children:i(be?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Jr,{children:t.jsx(Qr,{logs:Ss,downloadSessionId:te,isOutputActive:Fr,lastExitAt:zr,onUserToggleDetails:U,workingDir:Ct,scrollElementRef:O,onOpenWorkspaceFile:re,onOpenPreviewUrl:Pe,onOpenVisualization:Je})}):!Ee||m?.status==="failed"||Se?.status==="failed"||me?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(!Ee||me)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-14 h-14 bg-muted/50 rounded-2xl border border-border/60 flex items-center justify-center mb-5",children:t.jsx(ks,{size:24,className:"text-muted-foreground/70 ml-0.5"})}),t.jsx("h3",{className:"text-base font-medium text-foreground mb-1.5",children:i(me?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:me?st:i("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")})]}),!me&&(!m||m.status==="failed")&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Ae,{onClick:Ls,disabled:!!(m&&m.status!=="failed"),children:[t.jsx(ks,{size:16,className:"mr-1.5"}),m?.status==="failed"?i("重试启动 Agent"):i("启动 Agent")]}),qe&&t.jsxs(Ae,{variant:"outline",onClick:()=>v(!0),children:[t.jsx(us,{size:16,className:"mr-1.5"}),i("创建 TeamRun")]})]})]}):null]})}),!V&&t.jsxs("button",{onClick:()=>B(),className:"absolute bottom-3 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1.5 px-3 py-1.5 bg-background/90 backdrop-blur-sm border border-border rounded-full shadow-md text-xs text-muted-foreground hover:bg-background hover:text-foreground transition-all","aria-label":i("Scroll to bottom"),children:[t.jsx(xr,{size:14}),t.jsx("span",{children:i("回到底部")})]})]}),J.length>0&&t.jsx("div",{className:"px-6 pt-2 pb-1 bg-background flex-shrink-0 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx(ei,{todos:J})})}),me?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsx("div",{className:"bg-muted/50 rounded-xl border border-border px-4 py-3 text-sm text-muted-foreground",children:st})})}):It?t.jsx("div",{className:"p-6 pt-3 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-border/60",children:t.jsx("div",{className:"max-w-4xl mx-auto",children:t.jsxs("div",{className:"flex items-center justify-between bg-muted/50 rounded-xl border border-border px-4 py-3",children:[t.jsx("span",{className:"text-sm text-muted-foreground",children:i("代码已合并,以上为历史沟通记录")}),t.jsxs(Ae,{size:"sm",onClick:Ls,children:[t.jsx(ks,{size:14,className:"mr-1.5"}),i("启动新 Agent")]})]})})}):t.jsxs("div",{className:"p-6 pt-2 bg-background flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:xd,onDragLeave:bd,onDrop:_d,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[xo,tt?t.jsx(fl,{sessionId:tt}):null,t.jsxs("div",{ref:$,className:`relative bg-background rounded-xl border hover:border-ring/40 focus-within:border-ring/60 transition-colors duration-200 ${vo?"border-info bg-info/5":"border-border"}`,children:[t.jsx(Dn,{files:ve,onRemove:ze}),t.jsx("textarea",{ref:D,value:n,onChange:wd,onPaste:vd,onKeyDown:Q=>{$t.handleKeyDown(Q)||Tt.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),go())},rows:1,placeholder:i(vo?"Drop files here...":ft&&!be?"Continue conversation...":"Message Agent..."),className:"w-full px-4 pt-4 pb-2 bg-transparent border-none focus:outline-none resize-none text-sm text-foreground placeholder-muted-foreground/70 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),t.jsx("input",{ref:T,type:"file",multiple:!0,className:"hidden",onChange:gd}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[t.jsx("div",{className:"flex items-center gap-1",children:t.jsx("button",{onClick:()=>T.current?.click(),className:"p-2 text-muted-foreground/70 hover:text-muted-foreground hover:bg-muted rounded-lg transition-colors",title:i("Upload file"),children:t.jsx(Hn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[Ue&&lt&&t.jsx(ml,{providers:lt,currentProviderId:jt,agentType:Ue.agentType,runtimeType:Ue.runtimeType,onSelect:wt}),t.jsx(zn,{usage:ws}),be&&!n.trim()&&!Le?t.jsx("button",{onClick:pd,disabled:as.isPending||xe,className:"p-2 rounded-lg transition-all duration-200 bg-destructive text-white hover:bg-destructive/90 disabled:opacity-50",children:t.jsx(qs,{size:14})}):t.jsx("button",{onClick:go,disabled:!n.trim()&&!Le||Ft||Jt.isPending||as.isPending||xe||!!xt,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||Le)&&!Ft&&!Jt.isPending&&!as.isPending&&!xe&&!xt?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(Bn,{size:18})})]})]})]})]}),t.jsx(Zr,{open:Tt.query!==null,anchorRef:$,commands:Tt.filteredCommands,selectedIndex:Tt.selectedIndex,query:Tt.query??"",hasCatalog:Tt.allCommands.length>0,onSelect:Tt.applyCommand}),t.jsx(Zr,{open:$t.query!==null,anchorRef:$,commands:$t.filteredSkills,selectedIndex:$t.selectedIndex,query:$t.query??"",hasCatalog:$t.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:$t.applySkill})]})]})}),H&&t.jsx("div",{className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",onMouseDown:yd,role:"separator","aria-orientation":"vertical","aria-label":i("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:H?ln+F:ln},children:t.jsx(Uc,{sessionId:ft||void 0,workspaceId:Te,workingDir:Ct,projectId:e.projectId,readOnly:me,repoDeleted:Fe,teamRun:Ne,teamStatus:Ne?t.jsx(ic,{teamRun:Ne,workspaces:ne,selectedWorkspaceId:Te,onSelectWorkspace:z,onViewInvocationSession:ir}):void 0,workspaces:ne,selectedWorkspaceId:Te,onSelectWorkspace:z,variant:"rail",expanded:H,onExpandedChange:Q=>{Q&&q(oe=>es(oe)),N(Q)},minContentWidth:zs,tabRef:y,gitAvailable:$e,gitProps:Xe&&et?{branchName:rs,targetBranch:Ms,commitMessage:bs,canRunGitOperations:!0,onRefreshCommitMessage:_s,onConflict:Is,onResolveConflicts:()=>Is()}:void 0})})]}),!me&&t.jsx(qc,{isOpen:h,onClose:()=>c(!1),taskId:e.id,projectId:e.projectId,taskTitle:Ge?.title??e.title,taskDescription:Ge?.body??"",taskPrompt:Ge?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>x?.(e.id)}),qe&&!me&&t.jsx(ux,{isOpen:g,onClose:()=>v(!1),taskId:e.id}),Xe&&tr&&rt&&t.jsx(Gc,{open:S,onOpenChange:Q=>{C(Q),Q||j(null)},workspaceId:tr,conflictOp:rt.conflictOp,conflictedFiles:rt.conflictedFiles,sourceBranch:Mr,targetBranch:Dr,operation:_t?.operation,worktreePath:Tr,mergeAborted:rt.mergeAborted,mergeStrategy:rt.mergeStrategy,sourceWorkspaceId:rt.sourceWorkspaceId,targetWorkspaceId:rt.targetWorkspaceId,sourceWorktreePath:rt.sourceWorktreePath,targetWorktreePath:rt.targetWorktreePath,sessions:Zt,currentSessionId:Oe?void 0:ft,teamRunId:Ne?.id}),t.jsx(Ln,{isOpen:l,onClose:()=>u(!1),onConfirm:Mi,title:i("重新开始任务"),description:t.jsx("p",{children:i("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:i("确认重试"),variant:"default",isLoading:d}),t.jsx(ro,{isOpen:_,onClose:()=>w(!1),onConfirm:rr,taskId:e.id,taskTitle:e.title,workspaces:ne,isLoading:r})]}):t.jsx(Ex,{})}function mo(e){switch(e){case Yt.TODO:return _e.Pending;case Yt.IN_PROGRESS:return _e.Running;case Yt.IN_REVIEW:return _e.Review;case Yt.DONE:return _e.Done;case Yt.CANCELLED:return _e.Cancelled}}function Rx(e){switch(e){case _e.Pending:return Yt.TODO;case _e.Running:return Yt.IN_PROGRESS;case _e.Review:return Yt.IN_REVIEW;case _e.Done:return Yt.DONE;case _e.Cancelled:return Yt.CANCELLED}}function Ax(e){switch(e){case Nt.CLAUDE_CODE:return"Claude Code";case Nt.GEMINI_CLI:return"Gemini CLI";case Nt.CURSOR_AGENT:return"Cursor Agent";case Nt.CODEX:return"Codex";case Nt.QWEN_CODE:return"Qwen Code";case Nt.KIRO_CLI:return"Kiro CLI";case Nt.OPENCODE:return"OpenCode";case Nt.PI_CODING_AGENT:return"Pi Coding Agent";case Nt.GROK_BUILD:return"Grok Build";case Nt.MINION_CODE:return"Minion Code";case Nt.DEEPSEEK_HERMES:return"DeepSeek Harness"}}const hi=["text-indigo-600","text-emerald-600","text-rose-600","text-amber-600","text-cyan-600","text-violet-600","text-teal-600","text-pink-600"];function td(e,s){let r=0;for(let o=0;o<e.length;o++)r=(r<<5)-r+e.charCodeAt(o)|0;return Math.abs(r)%s}function Tx(e){return{id:e.id,name:e.name,color:e.color||hi[td(e.name,hi.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Mx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===bt.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:mo(e.status),priority:e.priority,agent:e.latestAgentType?Ax(e.latestAgentType):"—",branch:r,description:"",updatedAt:new Date(e.updatedAt).toISOString(),isGitRepo:s?.isGitRepo,worktreeReady:s?.worktreeReady,reason:s?.reason,projectArchivedAt:s?.archivedAt??null,projectRepoDeletedAt:s?.repoDeletedAt??null}}function Dx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===bt.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||hi[td(s.name,hi.length)],title:e.title,status:mo(e.status),priority:e.priority,branch:r,mainBranch:s.mainBranch??"main",description:"",isGitRepo:s.isGitRepo,worktreeReady:s.worktreeReady,reason:s.reason,projectArchivedAt:s.archivedAt??null,projectRepoDeletedAt:s.repoDeletedAt??null}}const Da={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 Px(e){const s=e.split("/");return s[s.length-1]||e}function Lx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Ix({workingDir:e,filePath:s,type:r}){const{t:o}=de(),{data:p,isLoading:m,isError:x}=Tc(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
78
- `);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((a,h)=>{let c="",g="text-neutral-400";return a.startsWith("+")&&!a.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):a.startsWith("-")&&!a.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):a.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:Z("px-3 whitespace-pre",c,g),children:a},h)})})}function Ox({entry:e,type:s,workingDir:r}){const[o,p]=b.useState(!1),m=Da[e.status]||Da.M,x=Lx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:Z("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:Z("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Px(e.path)}),x&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:x})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(kt,{size:14}):t.jsx(At,{size:14})})]}),o&&t.jsx(Ix,{workingDir:r,filePath:e.path,type:s})]})}function Pa({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=de(),[x,i]=b.useState(p);return s.length===0?null:t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>i(n=>!n),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[t.jsx("span",{className:"text-neutral-400",children:x?t.jsx(kt,{size:14}):t.jsx(At,{size:14})}),t.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),t.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:s.length})]}),x&&t.jsx("div",{className:"divide-y divide-neutral-100",children:s.map(n=>t.jsx(Ox,{entry:n,type:r,workingDir:o},`${r}:${n.path}`))})]})}function Bx({workingDir:e}){const{t:s}=de(),{data:r,isLoading:o,isError:p}=Ai(e);if(!e)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")});if(o)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading changes...")})]});if(p)return t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load changes.")});const m=r?.uncommitted||[],x=r?.committed||[];return m.length+x.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Qs,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No pending changes")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx(Pa,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(Pa,{title:"Committed",entries:x,type:"committed",workingDir:e,defaultOpen:!1})]})}const cn=50,La={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 Fx(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Dt("{count}s ago",{count:r}):r<3600?Dt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Dt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Dt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function zx(e){const s=e.split("/");return s[s.length-1]||e}function Wx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Hx({workingDir:e,hash:s,filePath:r}){const{t:o}=de(),{data:p,isLoading:m,isError:x}=fo(e,s,r);if(m)return t.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:o("Loading diff...")})]});if(x)return t.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:o("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:o("No diff content available.")});const n=i.split(`
79
- `);return t.jsx("div",{className:"overflow-x-auto scrollbar-app-thin bg-neutral-950 rounded-lg mx-3 mb-3 font-mono text-[11px] leading-5",children:n.map((a,h)=>{let c="",g="text-neutral-400";return a.startsWith("+")&&!a.startsWith("+++")?(c="bg-emerald-950/40",g="text-emerald-400"):a.startsWith("-")&&!a.startsWith("---")?(c="bg-red-950/40",g="text-red-400"):a.startsWith("@@")&&(c="bg-blue-950/30",g="text-blue-400"),t.jsx("div",{className:Z("px-3 whitespace-pre",c,g),children:a},h)})})}function Ux({entry:e,workingDir:s,hash:r}){const[o,p]=b.useState(!1),m=La[e.status]||La.M,x=Wx(e.path);return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(i=>!i),className:Z("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("span",{className:Z("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:zx(e.path)}),x&&t.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:x})]}),t.jsx("span",{className:"text-neutral-400 shrink-0",children:o?t.jsx(kt,{size:14}):t.jsx(At,{size:14})})]}),o&&t.jsx(Hx,{workingDir:s,hash:r,filePath:e.path})]})}function $x({commit:e,workingDir:s}){const{t:r}=de(),[o,p]=b.useState(!1),{data:m,isLoading:x}=ho(s,o?e.hash:null),i=m?.files||[];return t.jsxs("div",{children:[t.jsxs("button",{onClick:()=>p(n=>!n),className:Z("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",o&&"bg-neutral-50"),children:[t.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:t.jsx("div",{className:Z("w-2.5 h-2.5 rounded-full shrink-0",o?"bg-blue-500":"bg-neutral-300")})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),t.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),t.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[t.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),t.jsx("span",{className:"text-[11px] text-neutral-400",children:Fx(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(kt,{size:14}):t.jsx(At,{size:14})})]}),o&&t.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&t.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),x?t.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[t.jsx(Be,{size:14,className:"animate-spin"}),t.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):i.length===0?t.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):t.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(n=>t.jsx(Ux,{entry:n,workingDir:s,hash:e.hash},n.path))})]})]})}function qx({workingDir:e}){const{t:s}=de(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:x,isFetchingNextPage:i}=$n({queryKey:ce.git.log(e||""),queryFn:({pageParam:a=0})=>ye.get("/git/log",{params:{workingDir:e||"",limit:String(cn),skip:String(a)}}),initialPageParam:0,getNextPageParam:(a,h)=>a.commits.length<cn?void 0:h.length*cn,enabled:!!e}),n=r?.pages.flatMap(a=>a.commits)||[];return e?o?t.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[t.jsx(Be,{size:16,className:"animate-spin mr-2"}),t.jsx("span",{className:"text-sm",children:s("Loading history...")})]}):p?t.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:s("Failed to load history.")}):n.length===0?t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[t.jsx(Ys,{size:28,className:"mb-3"}),t.jsx("span",{className:"text-sm",children:s("No commit history")})]}):t.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[t.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(a=>t.jsx($x,{commit:a,workingDir:e},a.hash))}),x&&t.jsx("button",{type:"button",onClick:()=>m(),disabled:i,className:"w-full py-4 text-sm text-neutral-500 active:text-neutral-700 active:bg-neutral-50 flex items-center justify-center gap-2",children:i?t.jsxs(t.Fragment,{children:[t.jsx(Be,{size:14,className:"animate-spin"})," ",s("Loading...")]}):s("Load more")})]}):t.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:s("No workspace selected.")})}const Kx=wr(),Vx=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Kx}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Yx({status:e}){const s={[_e.Running]:"bg-blue-500",[_e.Review]:"bg-amber-500",[_e.Pending]:"bg-neutral-400",[_e.Done]:"bg-emerald-500",[_e.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const Xx=[{key:"chat",label:"Chat",icon:gi},{key:"changes",label:"Changes",icon:Qs},{key:"history",label:"History",icon:Ys},{key:"workspace",label:"Workspace",icon:bi}],Gx=[{key:"chat",label:"Team room",icon:gi},{key:"team-status",label:"Team Status",icon:js},{key:"changes",label:"Changes",icon:Qs},{key:"workspace",label:"Workspace",icon:bi}];function Qx({task:e,onBack:s,onDeleteTask:r,onTaskPriorityChange:o,isDeleting:p,autoStartState:m,onAutoStartRecovered:x}){const{t:i}=de(),n=Rs(J=>J.setVisibleContext),[a,h]=b.useState("chat"),[c,g]=b.useState(""),[v,_]=b.useState(!1),[w,l]=b.useState(!1),[u,d]=b.useState(!1),[f,S]=b.useState(null),[C,k]=b.useState(void 0),j=b.useRef(0),[y,E]=b.useState(),R=b.useRef(null),P=b.useRef(null),M=b.useRef(null),L=b.useRef(null),{scrollRef:z,contentRef:I,isAtBottom:W,scrollToBottom:$,stopScroll:A}=On({resize:"smooth",initial:"instant"}),D=vt();b.useEffect(()=>{if(!u)return;const J=ve=>{P.current&&!P.current.contains(ve.target)&&d(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[u]);const{data:T,isLoading:O}=Jn(e.id),K=$c(e.id),V=K?.status==="completed"&&m?.status!=="failed"?null:m,B=!!(V||K&&K.status!=="completed"),{data:U}=Xa(e.id),{data:H}=Ga(U?.id??""),N=Tn(U?.id??""),F=U??null,q=e.isGitRepo!==!1&&e.worktreeReady!==!1,Y=b.useMemo(()=>(F?Gx:Xx).filter(J=>q||J.key!=="changes"&&J.key!=="history"),[q,F]),se=U===null,{data:G,isLoading:pe}=Qa(e.id,se),he=!!e.projectArchivedAt,re=!!e.projectRepoDeletedAt,ne=i(re?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");b.useEffect(()=>{k(void 0),S(null),E(void 0)},[e.id]),b.useEffect(()=>{F&&a==="history"&&h("chat"),!F&&a==="team-status"&&h("chat"),Y.some(J=>J.key===a)||h("chat")},[a,Y,F]);const le=b.useMemo(()=>Jl(T,F,C),[C,F,T]);b.useEffect(()=>{C&&!T?.some(J=>J.id===C)&&k(void 0)},[C,T]);const Se=b.useMemo(()=>T?.find(J=>J.id===le),[le,T]),We=b.useMemo(()=>{if(T){if(Se)return fs(Se);for(const J of T)if(J.status==="ACTIVE"&&fs(J))return fs(J);return fs(T[0])}},[Se,T]),Ee=Se?.status===Pt.ACTIVE?Se.id:void 0,He=q&&ec(Se,F),at=Se?.branchName??"",Me=Se?.commitMessage,Ne=b.useMemo(()=>tc(Se,T,e?.mainBranch??""),[Se,e?.mainBranch,T]),Oe=!!(He&&Ee&&We&&!he),{data:$e,isLoading:qe}=to(Ee??"",{enabled:Oe}),{data:De}=Ai(We,{enabled:Oe}),Ge=De?.committed?.length,[Qe,Te]=b.useState(!1),[ge,et]=b.useState(null);b.useEffect(()=>{const J=q&&(a==="changes"||a==="chat"&&Oe)?"changes":q&&a==="history"?"history":null;if(!Ee||!We||!J){n(null);return}return n({workspaceId:Ee,workingDir:We,tab:J}),()=>{n(null)}},[a,q,Ee,n,Oe,We]);const Xe=b.useMemo(()=>$e?.conflictOp&&$e.conflictedFiles.length>0?{conflictOp:$e.conflictOp,conflictedFiles:$e.conflictedFiles}:ge,[$e?.conflictOp,$e?.conflictedFiles,ge]),Ue=Xe?.targetWorkspaceId??Ee,ft=Xe?.targetWorktreePath??Se?.worktreePath,tt=Xe?.sourceBranch??at,ee=Xe?.targetBranch??Ne,fe=Se?.sessions??[],we=b.useCallback(J=>{et(J??null),Te(!0)},[]),X=b.useCallback(()=>e?.id?D.invalidateQueries({queryKey:ce.workspaces.list(e.id)}):Promise.resolve(),[e?.id,D]),te=b.useCallback(async()=>D.fetchQuery({queryKey:ce.tasks.body(e.id),queryFn:()=>ye.get(`/tasks/${e.id}/body`)}),[D,e.id]),ie=b.useMemo(()=>{if(!T)return null;const J=T.filter(Le=>Le.status==="ACTIVE"&&Array.isArray(Le.sessions)).flatMap(Le=>Le.sessions??[]),ve=Le=>{const Ft=Le.createdAt,os=Le.endedAt??Le.startedAt??Ft;if(!os)return 0;const ws=Date.parse(os);return Number.isNaN(ws)?0:ws},Re=Le=>{const Ft=J.filter(os=>Le.includes(os.status));return Ft.length===0?null:Ft.sort((os,ws)=>ve(ws)-ve(os))[0]??null},ze=Re([ut.RUNNING])??Re([ut.PENDING])??Re([ut.COMPLETED,ut.FAILED,ut.CANCELLED]);if(ze)return ze;const Bt=T.filter(Le=>(Le.status==="ABANDONED"||Le.status==="MERGED"||Le.status==="HIBERNATED")&&Array.isArray(Le.sessions)).flatMap(Le=>Le.sessions??[]).filter(Le=>[ut.COMPLETED,ut.FAILED,ut.CANCELLED].includes(Le.status));return Bt.length===0?null:Bt.sort((Le,Ft)=>ve(Ft)-ve(Le))[0]??null},[T]),ae=ie?.id??"",Ce=F?f??"":ae,ke=b.useMemo(()=>{if(!f||!T)return null;for(const J of T){const ve=J.sessions?.find(Re=>Re.id===f);if(ve)return ve}return null},[f,T]),Pe=b.useMemo(()=>{if(!f||!F?.invocations)return null;const J=F.invocations.filter(ve=>ve.sessionId===f);return J.length===0?null:J.sort((ve,Re)=>{const ze=Date.parse(ve.updatedAt??ve.createdAt??""),yt=Date.parse(Re.updatedAt??Re.createdAt??"");return(Number.isNaN(yt)?0:yt)-(Number.isNaN(ze)?0:ze)})[0]??null},[f,F?.invocations]),Je=b.useMemo(()=>!Pe?.memberId||!F?.members?null:F.members.find(J=>J.id===Pe.memberId)??null,[Pe?.memberId,F?.members]),be=f?ke:ie??null,xe=be?.id,me=b.useMemo(()=>{if(be?.workspaceId)return be.workspaceId;if(!(!be||!T))return T.find(J=>J.sessions?.some(ve=>ve.id===be.id))?.id},[be,T]),Fe=b.useCallback((J,ve)=>{const ze=(ve&&T?.some(yt=>yt.id===ve)?ve:void 0)??me??le??void 0;ze&&k(ze),j.current+=1,E({id:j.current,source:J,workspaceId:ze}),h("workspace")},[me,le,T]),st=b.useCallback((J,ve)=>{Fe({kind:"web",url:J},ve)},[Fe]),lt=b.useCallback((J,ve,Re)=>{Fe({kind:"visualization",sessionId:J,file:ve},Re)},[Fe]),jt=b.useCallback(J=>{st(J,me)},[me,st]),wt=b.useCallback(J=>{xe&&lt(xe,J,me)},[xe,me,lt]),{isActive:xt,isCancelling:It}=ll(xe??"",be?.status),Ct=b.useMemo(()=>!ie||!T?!1:!T.some(ve=>ve.status==="ACTIVE"&&ve.sessions?.some(Re=>Re.id===ie.id)),[ie,T]),{data:Tt}=Gs(),[$t,er]=b.useState(null),qt=$t?.sessionId===ae?$t.providerId:ie?.providerId??null,_t=ie?vl(Tt,qt):void 0,Ti=b.useCallback(J=>{er({sessionId:ae,providerId:J})},[ae]),Qt=cl({agentType:ie?.agentType,workingDir:We,input:c,setInput:g,textareaRef:M,minHeight:40,maxHeight:140}),Zt=Jc({agentType:ie?.agentType,workingDir:We,input:c,setInput:g,textareaRef:M,minHeight:40,maxHeight:140}),rs=We&&Se?Se.id:void 0,bs=Wn(),Ms=eo(),rt=ul(),{isConnected:tr,isLoadingSnapshot:Tr,isOutputActive:Mr,lastExitAt:Dr,logs:it,entries:Ds,attach:_s}=pl({sessionId:Ce,sessionStatus:be?.status,sessionStartedAt:be?.startedAt??be?.createdAt,sessionEndedAt:be?.endedAt??(xt?null:be?.updatedAt),onExit:b.useCallback(()=>{D.invalidateQueries({queryKey:["workspaces"]})},[D])}),{todos:Jt}=gl(Ds),{files:Pr,addFiles:ys,removeFile:Lr,clear:sr,buildMarkdownLinks:Ps,hasFiles:Ot,isUploading:is}=Mn(),Mi=b.useMemo(()=>Kc(be),[be?.tokenUsage]),Ls=dl(it,Mi);b.useEffect(()=>{Ce&&tr&&_s()},[Ce,tr,_s]);const Ir=b.useRef(null);b.useEffect(()=>{if(Ir.current!==e.id&&z.current){const J=z.current;requestAnimationFrame(()=>{J.scrollTop=J.scrollHeight})}Ir.current=e.id},[e.id,z]);const rr=b.useRef(!1),ir=b.useCallback(async()=>{if(!c.trim()&&!Ot||!ae||rr.current||rt.isPending||It||is||_t)return;rr.current=!0;const J=Ps(),ve=[c.trim(),J].filter(Boolean).join(`
80
-
81
- `);g(""),sr(),M.current&&(M.current.style.height="40px"),bs.mutate({id:ae,message:ve,providerId:qt??void 0},{onSuccess:()=>_s(),onError:()=>g(Re=>Re||ve),onSettled:()=>{rr.current=!1}})},[c,ae,bs,_s,Ot,is,Ps,sr,qt,_t,rt.isPending,It]),Di=b.useCallback(()=>{!ae||rt.isPending||rt.mutate(ae)},[ae,rt]),Is=b.useCallback(J=>N.mutateAsync(J),[N]),Or=b.useCallback(J=>{S(J),h("chat"),requestAnimationFrame(()=>{$()})},[$]),ns=b.useCallback(()=>{S(null)},[]),Br=b.useCallback(()=>{h("changes")},[]),nr=Oe&&Ee?t.jsx(Qc,{workspaceId:Ee,branchName:at,targetBranch:Ne,commitMessage:Me,changes:De,gitStatus:$e,isGitStatusLoading:qe,canRunGitOperations:He,onOpenChanges:Br,onRefreshCommitMessage:X,onConflict:we,className:"mb-2"}):null,Fr=b.useCallback(J=>{const ve=J.target.files;ve&&ve.length>0&&ys(Array.from(ve)),J.target.value=""},[ys]),zr=b.useCallback(J=>{const ve=J.clipboardData.items,Re=[];for(const ze of ve)if(ze.kind==="file"){const yt=ze.getAsFile();yt&&Re.push(yt)}Re.length>0&&(J.preventDefault(),ys(Re))},[ys]),Ss=b.useCallback(J=>{g(J.target.value);const ve=J.target;ve.style.height="auto",ve.style.height=`${Math.max(40,Math.min(ve.scrollHeight,140))}px`},[]),Pi=b.useCallback(()=>{rs&&Ms.mutate({workspaceId:rs})},[Ms,rs]),Kt=b.useRef(null);return b.useEffect(()=>{const J=window.visualViewport;if(!J)return;let ve=!1;const Re=()=>{Kt.current&&(Kt.current.style.height=`${J.height}px`,Kt.current.style.top=`${J.offsetTop}px`)},ze=()=>Re(),yt=()=>{ve||Re()},Bt=()=>{ve=!0},Le=()=>{ve=!1,requestAnimationFrame(Re)};return J.addEventListener("resize",ze),J.addEventListener("scroll",yt),document.addEventListener("touchstart",Bt,{passive:!0}),document.addEventListener("touchend",Le,{passive:!0}),document.addEventListener("touchcancel",Le,{passive:!0}),()=>{J.removeEventListener("resize",ze),J.removeEventListener("scroll",yt),document.removeEventListener("touchstart",Bt),document.removeEventListener("touchend",Le),document.removeEventListener("touchcancel",Le)}},[]),b.useEffect(()=>{const J=Kt.current;if(!J)return;const ve=Re=>{let ze=Re.target;for(;ze&&ze!==J;){if(ze.tagName==="TEXTAREA"){if(ze.scrollHeight>ze.clientHeight)return;ze=ze.parentElement;continue}const Bt=window.getComputedStyle(ze).overflowY;if((Bt==="auto"||Bt==="scroll")&&ze.scrollHeight>ze.clientHeight)return;ze=ze.parentElement}Re.preventDefault()};return J.addEventListener("touchmove",ve,{passive:!1}),()=>J.removeEventListener("touchmove",ve)},[]),t.jsxs("div",{ref:Kt,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[t.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[t.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[t.jsx("button",{onClick:s,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:t.jsx(Ks,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx(ed,{taskId:e.id,title:e.title,readOnly:he,titleClassName:"text-[13px] font-bold text-neutral-900 truncate leading-tight",compact:!0}),t.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[t.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&t.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?i("源码已删除"):i("已删除")}),t.jsx("span",{className:"text-neutral-300",children:"/"}),t.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),t.jsx(Yx,{status:e.status}),t.jsx(hl,{value:e.priority,compact:!0,onChange:!he&&o?J=>o(e.id,J):void 0}),t.jsx("button",{onClick:Pi,disabled:!rs||he,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(xi,{size:16})}),r&&!he&&t.jsxs("div",{className:"relative",ref:P,children:[t.jsx("button",{onClick:()=>d(J=>!J),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:t.jsx(yl,{size:16})}),u&&t.jsx("div",{className:"absolute right-0 top-full mt-1 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:t.jsxs("button",{onClick:()=>{l(!0),d(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[t.jsx(pi,{size:15}),t.jsx("span",{children:i("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:Y.map(({key:J,label:ve,icon:Re})=>t.jsxs("button",{onClick:()=>h(J),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${a===J?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[t.jsx(Re,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:i(ve)})]},J))})]}),a==="chat"&&(F?t.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:f?t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsxs("div",{className:"relative z-20 flex shrink-0 items-center justify-between gap-3 overflow-visible border-b border-neutral-200 px-3 py-2.5",children:[t.jsxs("div",{className:"min-w-0",children:[t.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:i("Invocation details")}),t.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:f})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[t.jsx(Vc,{session:be,providers:Tt,usage:Ls,compact:!0,providerIdFallback:Je?.providerId,agentTypeFallback:be?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Ae,{type:"button",size:"xs",variant:"ghost",className:"h-7 gap-1 rounded-lg border border-neutral-200/70 bg-white/60 px-1.5 text-[11px] font-medium text-neutral-500 hover:border-neutral-300 hover:bg-neutral-100 hover:text-neutral-900 active:bg-neutral-100",onClick:ns,children:[t.jsx(Ks,{size:12}),t.jsx("span",{children:i("Team room")})]})]})]}),t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:z,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsx("div",{ref:I,children:Tr?t.jsx(dn,{label:i("Loading logs...")}):it.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:i(xt?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(Jr,{children:t.jsx(Qr,{logs:it,downloadSessionId:xe,isOutputActive:Mr,lastExitAt:Dr,onUserToggleDetails:A,scrollElementRef:z,onOpenPreviewUrl:jt,onOpenVisualization:wt})})})}),!W&&t.jsxs("button",{onClick:()=>$(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":i("Scroll to bottom"),children:[t.jsx(xr,{size:12}),t.jsx("span",{children:i("回到底部")})]})]}),Jt.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(ei,{todos:Jt,compact:!0})})]}):t.jsx(Zl,{teamRun:F,messages:H??F.messages??[],readOnly:he,readOnlyMessage:ne,onSendMessage:Is,onViewInvocationSession:Or,changeSummaryBar:nr,compactComposer:!0,workingDir:We,onOpenPreviewUrl:st,onOpenVisualization:lt})}):t.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[t.jsxs("div",{className:"relative flex-1 min-h-0",children:[t.jsx("div",{ref:z,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:t.jsxs("div",{ref:I,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:pe?t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:i("Loading...")}):G?.body?t.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:t.jsx(Pn,{urlTransform:Vx,components:el,children:G.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!he&&t.jsx(Zc,{state:V,setupProgress:K,sessionStarted:!!ie?.startedAt,onRetry:ae&&m?.status==="failed"?async()=>{await te(),_(!0)}:void 0,compact:!0},e.id),O?(!B||he)&&t.jsx(dn,{label:"Loading..."}):ae?Tr?t.jsx(dn,{label:"Loading logs..."}):it.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:xt?"Waiting for agent output...":"No logs recorded."}):t.jsx(Jr,{children:t.jsx(Qr,{logs:it,downloadSessionId:xe,isOutputActive:Mr,lastExitAt:Dr,onUserToggleDetails:A,scrollElementRef:z,onOpenPreviewUrl:jt,onOpenVisualization:wt})}):!B||m?.status==="failed"||K?.status==="failed"||he?t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(!B||he)&&t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:t.jsx(ks,{size:20,className:"text-neutral-400 ml-0.5"})}),t.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:i("尚未启动 Agent")}),t.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:he?ne:i("选择一个 Agent 来执行此任务")})]}),!he&&(!m||m.status==="failed")&&t.jsxs(Ae,{onClick:async()=>{await te(),_(!0)},disabled:!!(m&&m.status!=="failed"),children:[t.jsx(ks,{size:16,className:"mr-1.5"}),m?.status==="failed"?i("重试启动 Agent"):i("启动 Agent")]})]}):null]})}),!W&&t.jsxs("button",{onClick:()=>$(),className:"absolute bottom-2 left-1/2 -translate-x-1/2 z-10 flex items-center gap-1 px-2.5 py-1 bg-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-[11px] text-neutral-600 active:bg-white transition-all","aria-label":"Scroll to bottom",children:[t.jsx(xr,{size:12}),t.jsx("span",{children:i("回到底部")})]})]}),Jt.length>0&&t.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:t.jsx(ei,{todos:Jt,compact:!0})}),he?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:ne})}):Ct?t.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:t.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[t.jsx("span",{className:"text-xs text-neutral-500",children:i("代码已合并,以上为历史沟通记录")}),t.jsxs(Ae,{size:"sm",onClick:async()=>{await te(),_(!0)},children:[t.jsx(ks,{size:14,className:"mr-1.5"}),i("启动新 Agent")]})]})}):ae&&t.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[nr,t.jsx(fl,{sessionId:Ce||ae,compact:!0}),t.jsxs("div",{ref:R,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(Dn,{files:Pr,onRemove:Lr}),t.jsx("textarea",{ref:M,value:c,onChange:Ss,onPaste:zr,onKeyDown:J=>{Zt.handleKeyDown(J)||Qt.handleKeyDown(J)||J.key==="Enter"&&!J.shiftKey&&!J.repeat&&!J.nativeEvent.isComposing&&J.nativeEvent.keyCode!==229&&(J.preventDefault(),ir())},rows:1,placeholder:xt?"Message Agent...":"Continue conversation...",className:"w-full px-3 pt-2.5 pb-1 bg-transparent border-none focus:outline-none resize-none text-[15px] text-neutral-900 placeholder-neutral-400",style:{minHeight:40,maxHeight:140}}),t.jsx("input",{ref:L,type:"file",multiple:!0,className:"hidden",onChange:Fr}),t.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[t.jsx("div",{className:"flex items-center gap-0.5",children:t.jsx("button",{onClick:()=>L.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(Hn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[ie&&Tt&&t.jsx(ml,{providers:Tt,currentProviderId:qt,agentType:ie.agentType,runtimeType:ie.runtimeType,onSelect:Ti}),t.jsx(zn,{usage:Ls}),xt&&!c.trim()&&!Ot?t.jsx("button",{onClick:Di,disabled:rt.isPending||It,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:t.jsx(qs,{size:12})}):t.jsx("button",{onClick:ir,disabled:!c.trim()&&!Ot||is||bs.isPending||rt.isPending||It||!!_t,className:`p-1.5 rounded-lg transition-colors ${(c.trim()||Ot)&&!is&&!bs.isPending&&!rt.isPending&&!It&&!_t?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Bn,{size:15})})]})]})]}),t.jsx(Zr,{open:Qt.query!==null,anchorRef:R,commands:Qt.filteredCommands,selectedIndex:Qt.selectedIndex,query:Qt.query??"",hasCatalog:Qt.allCommands.length>0,compact:!0,onSelect:Qt.applyCommand}),t.jsx(Zr,{open:Zt.query!==null,anchorRef:R,commands:Zt.filteredSkills,selectedIndex:Zt.selectedIndex,query:Zt.query??"",hasCatalog:Zt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Zt.applySkill})]})]})),a==="team-status"&&F&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(ic,{teamRun:F,workspaces:T,selectedWorkspaceId:le,onSelectWorkspace:k,onViewInvocationSession:Or})}),a==="changes"&&q&&t.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[T&&T.length>1&&t.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:t.jsx(Hc,{workspaces:T,teamRun:F,selectedWorkspaceId:le,onSelectWorkspace:k,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),He&&Ee&&t.jsx("div",{className:"shrink-0",children:t.jsx(Ic,{workspaceId:Ee,branchName:at,targetBranch:Ne,commitMessage:Me,committedFileCount:Ge,onRefreshCommitMessage:X,onConflict:we,onResolveConflicts:()=>we()})}),t.jsx(Bx,{workingDir:We})]}),a==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(qx,{workingDir:We})}),a==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(Uc,{sessionId:ae||void 0,workspaceId:le,workingDir:We,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:q,readOnly:he,repoDeleted:re,previewRequest:y,onPreviewRequestHandled:J=>{E(ve=>ve?.id===J?void 0:ve)}})}),!he&&t.jsx(qc,{isOpen:v,onClose:()=>_(!1),taskId:e.id,projectId:e.projectId,taskTitle:G?.title??e.title,taskDescription:G?.body??"",taskPrompt:G?.prompt,projectIsGitRepo:e.isGitRepo,projectWorktreeReady:e.worktreeReady,projectGitReason:e.reason,onStarted:()=>x?.(e.id)}),t.jsx(ro,{isOpen:w,onClose:()=>l(!1),onConfirm:()=>{r?.(e.id),l(!1)},taskId:e.id,taskTitle:e.title,workspaces:T,isLoading:p}),Qe&&Xe&&Ue&&t.jsx(Gc,{open:Qe,onOpenChange:J=>{Te(J),J||et(null)},workspaceId:Ue,conflictOp:Xe.conflictOp,conflictedFiles:Xe.conflictedFiles,sourceBranch:tt,targetBranch:ee,operation:$e?.operation,worktreePath:ft,mergeAborted:Xe.mergeAborted,mergeStrategy:Xe.mergeStrategy,sourceWorkspaceId:Xe.sourceWorkspaceId,targetWorkspaceId:Xe.targetWorkspaceId,sourceWorktreePath:Xe.sourceWorktreePath,targetWorktreePath:Xe.targetWorktreePath,sessions:fe,currentSessionId:F?void 0:ae,teamRunId:F?.id})]})}function dn({label:e}){return t.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[t.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[t.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),t.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),t.jsx("span",{className:"text-sm",children:e})]})}var Zx=Object.defineProperty,fi=Object.getOwnPropertySymbols,sd=Object.prototype.hasOwnProperty,rd=Object.prototype.propertyIsEnumerable,Ia=(e,s,r)=>s in e?Zx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,Nn=(e,s)=>{for(var r in s||(s={}))sd.call(s,r)&&Ia(e,r,s[r]);if(fi)for(var r of fi(s))rd.call(s,r)&&Ia(e,r,s[r]);return e},Rn=(e,s)=>{var r={};for(var o in e)sd.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&fi)for(var o of fi(e))s.indexOf(o)<0&&rd.call(e,o)&&(r[o]=e[o]);return r};var Ns;(e=>{const s=class je{constructor(n,a,h,c){if(this.version=n,this.errorCorrectionLevel=a,this.modules=[],this.isFunction=[],n<je.MIN_VERSION||n>je.MAX_VERSION)throw new RangeError("Version value out of range");if(c<-1||c>7)throw new RangeError("Mask value out of range");this.size=n*4+17;let g=[];for(let _=0;_<this.size;_++)g.push(!1);for(let _=0;_<this.size;_++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const v=this.addEccAndInterleave(h);if(this.drawCodewords(v),c==-1){let _=1e9;for(let w=0;w<8;w++){this.applyMask(w),this.drawFormatBits(w);const l=this.getPenaltyScore();l<_&&(c=w,_=l),this.applyMask(w)}}p(0<=c&&c<=7),this.mask=c,this.applyMask(c),this.drawFormatBits(c),this.isFunction=[]}static encodeText(n,a){const h=e.QrSegment.makeSegments(n);return je.encodeSegments(h,a)}static encodeBinary(n,a){const h=e.QrSegment.makeBytes(n);return je.encodeSegments([h],a)}static encodeSegments(n,a,h=1,c=40,g=-1,v=!0){if(!(je.MIN_VERSION<=h&&h<=c&&c<=je.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let _,w;for(_=h;;_++){const f=je.getNumDataCodewords(_,a)*8,S=x.getTotalBits(n,_);if(S<=f){w=S;break}if(_>=c)throw new RangeError("Data too long")}for(const f of[je.Ecc.MEDIUM,je.Ecc.QUARTILE,je.Ecc.HIGH])v&&w<=je.getNumDataCodewords(_,f)*8&&(a=f);let l=[];for(const f of n){r(f.mode.modeBits,4,l),r(f.numChars,f.mode.numCharCountBits(_),l);for(const S of f.getData())l.push(S)}p(l.length==w);const u=je.getNumDataCodewords(_,a)*8;p(l.length<=u),r(0,Math.min(4,u-l.length),l),r(0,(8-l.length%8)%8,l),p(l.length%8==0);for(let f=236;l.length<u;f^=253)r(f,8,l);let d=[];for(;d.length*8<l.length;)d.push(0);return l.forEach((f,S)=>d[S>>>3]|=f<<7-(S&7)),new je(_,a,d,g)}getModule(n,a){return 0<=n&&n<this.size&&0<=a&&a<this.size&&this.modules[a][n]}getModules(){return this.modules}drawFunctionPatterns(){for(let h=0;h<this.size;h++)this.setFunctionModule(6,h,h%2==0),this.setFunctionModule(h,6,h%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),a=n.length;for(let h=0;h<a;h++)for(let c=0;c<a;c++)h==0&&c==0||h==0&&c==a-1||h==a-1&&c==0||this.drawAlignmentPattern(n[h],n[c]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const a=this.errorCorrectionLevel.formatBits<<3|n;let h=a;for(let g=0;g<10;g++)h=h<<1^(h>>>9)*1335;const c=(a<<10|h)^21522;p(c>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,o(c,g));this.setFunctionModule(8,7,o(c,6)),this.setFunctionModule(8,8,o(c,7)),this.setFunctionModule(7,8,o(c,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,o(c,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,o(c,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,o(c,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let n=this.version;for(let h=0;h<12;h++)n=n<<1^(n>>>11)*7973;const a=this.version<<12|n;p(a>>>18==0);for(let h=0;h<18;h++){const c=o(a,h),g=this.size-11+h%3,v=Math.floor(h/3);this.setFunctionModule(g,v,c),this.setFunctionModule(v,g,c)}}drawFinderPattern(n,a){for(let h=-4;h<=4;h++)for(let c=-4;c<=4;c++){const g=Math.max(Math.abs(c),Math.abs(h)),v=n+c,_=a+h;0<=v&&v<this.size&&0<=_&&_<this.size&&this.setFunctionModule(v,_,g!=2&&g!=4)}}drawAlignmentPattern(n,a){for(let h=-2;h<=2;h++)for(let c=-2;c<=2;c++)this.setFunctionModule(n+c,a+h,Math.max(Math.abs(c),Math.abs(h))!=1)}setFunctionModule(n,a,h){this.modules[a][n]=h,this.isFunction[a][n]=!0}addEccAndInterleave(n){const a=this.version,h=this.errorCorrectionLevel;if(n.length!=je.getNumDataCodewords(a,h))throw new RangeError("Invalid argument");const c=je.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][a],g=je.ECC_CODEWORDS_PER_BLOCK[h.ordinal][a],v=Math.floor(je.getNumRawDataModules(a)/8),_=c-v%c,w=Math.floor(v/c);let l=[];const u=je.reedSolomonComputeDivisor(g);for(let f=0,S=0;f<c;f++){let C=n.slice(S,S+w-g+(f<_?0:1));S+=C.length;const k=je.reedSolomonComputeRemainder(C,u);f<_&&C.push(0),l.push(C.concat(k))}let d=[];for(let f=0;f<l[0].length;f++)l.forEach((S,C)=>{(f!=w-g||C>=_)&&d.push(S[f])});return p(d.length==v),d}drawCodewords(n){if(n.length!=Math.floor(je.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let a=0;for(let h=this.size-1;h>=1;h-=2){h==6&&(h=5);for(let c=0;c<this.size;c++)for(let g=0;g<2;g++){const v=h-g,w=(h+1&2)==0?this.size-1-c:c;!this.isFunction[w][v]&&a<n.length*8&&(this.modules[w][v]=o(n[a>>>3],7-(a&7)),a++)}}p(a==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let a=0;a<this.size;a++)for(let h=0;h<this.size;h++){let c;switch(n){case 0:c=(h+a)%2==0;break;case 1:c=a%2==0;break;case 2:c=h%3==0;break;case 3:c=(h+a)%3==0;break;case 4:c=(Math.floor(h/3)+Math.floor(a/2))%2==0;break;case 5:c=h*a%2+h*a%3==0;break;case 6:c=(h*a%2+h*a%3)%2==0;break;case 7:c=((h+a)%2+h*a%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[a][h]&&c&&(this.modules[a][h]=!this.modules[a][h])}}getPenaltyScore(){let n=0;for(let g=0;g<this.size;g++){let v=!1,_=0,w=[0,0,0,0,0,0,0];for(let l=0;l<this.size;l++)this.modules[g][l]==v?(_++,_==5?n+=je.PENALTY_N1:_>5&&n++):(this.finderPenaltyAddHistory(_,w),v||(n+=this.finderPenaltyCountPatterns(w)*je.PENALTY_N3),v=this.modules[g][l],_=1);n+=this.finderPenaltyTerminateAndCount(v,_,w)*je.PENALTY_N3}for(let g=0;g<this.size;g++){let v=!1,_=0,w=[0,0,0,0,0,0,0];for(let l=0;l<this.size;l++)this.modules[l][g]==v?(_++,_==5?n+=je.PENALTY_N1:_>5&&n++):(this.finderPenaltyAddHistory(_,w),v||(n+=this.finderPenaltyCountPatterns(w)*je.PENALTY_N3),v=this.modules[l][g],_=1);n+=this.finderPenaltyTerminateAndCount(v,_,w)*je.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let v=0;v<this.size-1;v++){const _=this.modules[g][v];_==this.modules[g][v+1]&&_==this.modules[g+1][v]&&_==this.modules[g+1][v+1]&&(n+=je.PENALTY_N2)}let a=0;for(const g of this.modules)a=g.reduce((v,_)=>v+(_?1:0),a);const h=this.size*this.size,c=Math.ceil(Math.abs(a*20-h*10)/h)-1;return p(0<=c&&c<=9),n+=c*je.PENALTY_N4,p(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,a=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let h=[6];for(let c=this.size-7;h.length<n;c-=a)h.splice(1,0,c);return h}}static getNumRawDataModules(n){if(n<je.MIN_VERSION||n>je.MAX_VERSION)throw new RangeError("Version number out of range");let a=(16*n+128)*n+64;if(n>=2){const h=Math.floor(n/7)+2;a-=(25*h-10)*h-55,n>=7&&(a-=36)}return p(208<=a&&a<=29648),a}static getNumDataCodewords(n,a){return Math.floor(je.getNumRawDataModules(n)/8)-je.ECC_CODEWORDS_PER_BLOCK[a.ordinal][n]*je.NUM_ERROR_CORRECTION_BLOCKS[a.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let a=[];for(let c=0;c<n-1;c++)a.push(0);a.push(1);let h=1;for(let c=0;c<n;c++){for(let g=0;g<a.length;g++)a[g]=je.reedSolomonMultiply(a[g],h),g+1<a.length&&(a[g]^=a[g+1]);h=je.reedSolomonMultiply(h,2)}return a}static reedSolomonComputeRemainder(n,a){let h=a.map(c=>0);for(const c of n){const g=c^h.shift();h.push(0),a.forEach((v,_)=>h[_]^=je.reedSolomonMultiply(v,g))}return h}static reedSolomonMultiply(n,a){if(n>>>8||a>>>8)throw new RangeError("Byte out of range");let h=0;for(let c=7;c>=0;c--)h=h<<1^(h>>>7)*285,h^=(a>>>c&1)*n;return p(h>>>8==0),h}finderPenaltyCountPatterns(n){const a=n[1];p(a<=this.size*3);const h=a>0&&n[2]==a&&n[3]==a*3&&n[4]==a&&n[5]==a;return(h&&n[0]>=a*4&&n[6]>=a?1:0)+(h&&n[6]>=a*4&&n[0]>=a?1:0)}finderPenaltyTerminateAndCount(n,a,h){return n&&(this.finderPenaltyAddHistory(a,h),a=0),a+=this.size,this.finderPenaltyAddHistory(a,h),this.finderPenaltyCountPatterns(h)}finderPenaltyAddHistory(n,a){a[0]==0&&(n+=this.size),a.pop(),a.unshift(n)}};s.MIN_VERSION=1,s.MAX_VERSION=40,s.PENALTY_N1=3,s.PENALTY_N2=3,s.PENALTY_N3=40,s.PENALTY_N4=10,s.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],s.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],e.QrCode=s;function r(i,n,a){if(n<0||n>31||i>>>n)throw new RangeError("Value out of range");for(let h=n-1;h>=0;h--)a.push(i>>>h&1)}function o(i,n){return(i>>>n&1)!=0}function p(i){if(!i)throw new Error("Assertion error")}const m=class nt{constructor(n,a,h){if(this.mode=n,this.numChars=a,this.bitData=h,a<0)throw new RangeError("Invalid argument");this.bitData=h.slice()}static makeBytes(n){let a=[];for(const h of n)r(h,8,a);return new nt(nt.Mode.BYTE,n.length,a)}static makeNumeric(n){if(!nt.isNumeric(n))throw new RangeError("String contains non-numeric characters");let a=[];for(let h=0;h<n.length;){const c=Math.min(n.length-h,3);r(parseInt(n.substring(h,h+c),10),c*3+1,a),h+=c}return new nt(nt.Mode.NUMERIC,n.length,a)}static makeAlphanumeric(n){if(!nt.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let a=[],h;for(h=0;h+2<=n.length;h+=2){let c=nt.ALPHANUMERIC_CHARSET.indexOf(n.charAt(h))*45;c+=nt.ALPHANUMERIC_CHARSET.indexOf(n.charAt(h+1)),r(c,11,a)}return h<n.length&&r(nt.ALPHANUMERIC_CHARSET.indexOf(n.charAt(h)),6,a),new nt(nt.Mode.ALPHANUMERIC,n.length,a)}static makeSegments(n){return n==""?[]:nt.isNumeric(n)?[nt.makeNumeric(n)]:nt.isAlphanumeric(n)?[nt.makeAlphanumeric(n)]:[nt.makeBytes(nt.toUtf8ByteArray(n))]}static makeEci(n){let a=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)r(n,8,a);else if(n<16384)r(2,2,a),r(n,14,a);else if(n<1e6)r(6,3,a),r(n,21,a);else throw new RangeError("ECI assignment value out of range");return new nt(nt.Mode.ECI,0,a)}static isNumeric(n){return nt.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return nt.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,a){let h=0;for(const c of n){const g=c.mode.numCharCountBits(a);if(c.numChars>=1<<g)return 1/0;h+=4+g+c.bitData.length}return h}static toUtf8ByteArray(n){n=encodeURI(n);let a=[];for(let h=0;h<n.length;h++)n.charAt(h)!="%"?a.push(n.charCodeAt(h)):(a.push(parseInt(n.substring(h+1,h+3),16)),h+=2);return a}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let x=m;e.QrSegment=m})(Ns||(Ns={}));(e=>{(s=>{const r=class{constructor(p,m){this.ordinal=p,this.formatBits=m}};r.LOW=new r(0,1),r.MEDIUM=new r(1,0),r.QUARTILE=new r(2,3),r.HIGH=new r(3,2),s.Ecc=r})(e.QrCode||(e.QrCode={}))})(Ns||(Ns={}));(e=>{(s=>{const r=class{constructor(p,m){this.modeBits=p,this.numBitsCharCount=m}numCharCountBits(p){return this.numBitsCharCount[Math.floor((p+7)/17)]}};r.NUMERIC=new r(1,[10,12,14]),r.ALPHANUMERIC=new r(2,[9,11,13]),r.BYTE=new r(4,[8,16,16]),r.KANJI=new r(8,[8,10,12]),r.ECI=new r(7,[0,0,0]),s.Mode=r})(e.QrSegment||(e.QrSegment={}))})(Ns||(Ns={}));var Us=Ns;var Jx={L:Us.QrCode.Ecc.LOW,M:Us.QrCode.Ecc.MEDIUM,Q:Us.QrCode.Ecc.QUARTILE,H:Us.QrCode.Ecc.HIGH},id=128,nd="L",od="#FFFFFF",ad="#000000",ld=!1,cd=1,eb=4,tb=0,sb=.1;function dd(e,s=0){const r=[];return e.forEach(function(o,p){let m=null;o.forEach(function(x,i){if(!x&&m!==null){r.push(`M${m+s} ${p+s}h${i-m}v1H${m+s}z`),m=null;return}if(i===o.length-1){if(!x)return;m===null?r.push(`M${i+s},${p+s} h1v1H${i+s}z`):r.push(`M${m+s},${p+s} h${i+1-m}v1H${m+s}z`);return}x&&m===null&&(m=i)})}),r.join("")}function ud(e,s){return e.slice().map((r,o)=>o<s.y||o>=s.y+s.h?r:r.map((p,m)=>m<s.x||m>=s.x+s.w?p:!1))}function rb(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*sb),x=p/s,i=(o.width||m)*x,n=(o.height||m)*x,a=o.x==null?e.length/2-i/2:o.x*x,h=o.y==null?e.length/2-n/2:o.y*x,c=o.opacity==null?1:o.opacity;let g=null;if(o.excavate){let _=Math.floor(a),w=Math.floor(h),l=Math.ceil(i+a-_),u=Math.ceil(n+h-w);g={x:_,y:w,w:l,h:u}}const v=o.crossOrigin;return{x:a,y:h,h:n,w:i,excavation:g,opacity:c,crossOrigin:v}}function ib(e,s){return s!=null?Math.max(Math.floor(s),0):e?eb:tb}function hd({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:x,boostLevel:i}){let n=ue.useMemo(()=>{const _=(Array.isArray(e)?e:[e]).reduce((w,l)=>(w.push(...Us.QrSegment.makeSegments(l)),w),[]);return Us.QrCode.encodeSegments(_,Jx[s],r,void 0,void 0,i)},[e,s,r,i]);const{cells:a,margin:h,numCells:c,calculatedImageSettings:g}=ue.useMemo(()=>{let v=n.getModules();const _=ib(o,p),w=v.length+_*2,l=rb(v,x,_,m);return{cells:v,margin:_,numCells:w,calculatedImageSettings:l}},[n,x,m,o,p]);return{qrcode:n,margin:h,cells:a,numCells:c,calculatedImageSettings:g}}var nb=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),ob=ue.forwardRef(function(s,r){const o=s,{value:p,size:m=id,level:x=nd,bgColor:i=od,fgColor:n=ad,includeMargin:a=ld,minVersion:h=cd,boostLevel:c,marginSize:g,imageSettings:v}=o,w=Rn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:l}=w,u=Rn(w,["style"]),d=v?.src,f=ue.useRef(null),S=ue.useRef(null),C=ue.useCallback(z=>{f.current=z,typeof r=="function"?r(z):r&&(r.current=z)},[r]),[k,j]=ue.useState(!1),{margin:y,cells:E,numCells:R,calculatedImageSettings:P}=hd({value:p,level:x,minVersion:h,boostLevel:c,includeMargin:a,marginSize:g,imageSettings:v,size:m});ue.useEffect(()=>{if(f.current!=null){const z=f.current,I=z.getContext("2d");if(!I)return;let W=E;const $=S.current,A=P!=null&&$!==null&&$.complete&&$.naturalHeight!==0&&$.naturalWidth!==0;A&&P.excavation!=null&&(W=ud(E,P.excavation));const D=window.devicePixelRatio||1;z.height=z.width=m*D;const T=m/R*D;I.scale(T,T),I.fillStyle=i,I.fillRect(0,0,R,R),I.fillStyle=n,nb?I.fill(new Path2D(dd(W,y))):E.forEach(function(O,K){O.forEach(function(V,B){V&&I.fillRect(B+y,K+y,1,1)})}),P&&(I.globalAlpha=P.opacity),A&&I.drawImage($,P.x+y,P.y+y,P.w,P.h)}}),ue.useEffect(()=>{j(!1)},[d]);const M=Nn({height:m,width:m},l);let L=null;return d!=null&&(L=ue.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{j(!0)},ref:S,crossOrigin:P?.crossOrigin})),ue.createElement(ue.Fragment,null,ue.createElement("canvas",Nn({style:M,height:m,width:m,ref:C,role:"img"},u)),L)});ob.displayName="QRCodeCanvas";var fd=ue.forwardRef(function(s,r){const o=s,{value:p,size:m=id,level:x=nd,bgColor:i=od,fgColor:n=ad,includeMargin:a=ld,minVersion:h=cd,boostLevel:c,title:g,marginSize:v,imageSettings:_}=o,w=Rn(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:l,cells:u,numCells:d,calculatedImageSettings:f}=hd({value:p,level:x,minVersion:h,boostLevel:c,includeMargin:a,marginSize:v,imageSettings:_,size:m});let S=u,C=null;_!=null&&f!=null&&(f.excavation!=null&&(S=ud(u,f.excavation)),C=ue.createElement("image",{href:_.src,height:f.h,width:f.w,x:f.x+l,y:f.y+l,preserveAspectRatio:"none",opacity:f.opacity,crossOrigin:f.crossOrigin}));const k=dd(S,l);return ue.createElement("svg",Nn({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},w),!!g&&ue.createElement("title",null,g),ue.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ue.createElement("path",{fill:n,d:k,shapeRendering:"crispEdges"}),C)});fd.displayName="QRCodeSVG";function md(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function ab(){return Et({queryKey:ce.tunnel.status,queryFn:()=>ye.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function lb(){const e=vt();return Ut({mutationFn:()=>ye.post("/tunnel/start",{port:md()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function cb(){const e=vt();return Ut({mutationFn:()=>ye.post("/tunnel/regenerate",{port:md()}),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function db(){const e=vt();return Ut({mutationFn:()=>ye.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:ce.tunnel.status})}})}function ub(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Use Agent Tower on your phone",icon:"idle"};switch(e.status){case"healthy":case"checking":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:e.status==="healthy"?"Tunnel healthy":"Checking tunnel health",icon:"ok"};case"degraded":case"localUnhealthy":case"linkReplaced":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel needs attention",icon:"warn"};case"exited":case"error":return{button:"text-red-600 hover:bg-red-50",dot:"bg-red-500",label:"Tunnel unavailable",icon:"error"};case"starting":return{button:"text-amber-600 hover:bg-amber-50",dot:"bg-amber-500",label:"Tunnel starting",icon:"loading"}}}function hb(e){if(!e||e.status==="stopped")return"Tunnel is off";switch(e.status){case"healthy":return"Tunnel healthy";case"checking":return"Checking tunnel health";case"degraded":return"Observing original link";case"localUnhealthy":return"Local service unavailable";case"exited":return"Tunnel process exited";case"error":return"Tunnel error";case"linkReplaced":return"New link generated";case"starting":return"Tunnel starting"}}function fb(e){if(!e||e.status==="stopped")return"Start a temporary Quick Tunnel when you need to share this Agent Tower session.";switch(e.status){case"healthy":return"The Cloudflare tunnel is running and the local Agent Tower health check passed.";case"checking":return"The Cloudflare tunnel is running. Agent Tower is waiting for the first local health check.";case"degraded":return"The original public URL is currently unreachable. Agent Tower is watching for it to recover and will not generate a new link automatically.";case"localUnhealthy":return"The local Agent Tower target is not responding, so the tunnel cannot be considered healthy.";case"exited":return"The tunnel process has exited. The old Quick Tunnel link is unlikely to recover.";case"error":return"The tunnel reported an error. Check the diagnostics before generating a new link.";case"linkReplaced":return"A new Quick Tunnel link was generated. The old link and token are no longer valid.";case"starting":return"Agent Tower is asking Cloudflare Quick Tunnel for a temporary public URL."}}function Oa(e){if(!e)return"Never";const s=new Date(e).getTime();if(!Number.isFinite(s))return e;const r=Math.max(0,Math.round((Date.now()-s)/1e3));if(r<60)return`${r}s ago`;const o=Math.round(r/60);if(o<60)return`${o}m ago`;const p=Math.round(o/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function cr(e){const s=e?.trim();return s||null}function mb(e){if(!e)return"";const s=[cr(e.lastLocalError),cr(e.lastRemoteError),cr(e.lastError)].filter(p=>p!==null),r=cr(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!cr(e.lastError));return r&&o&&s.push(r),s.join(`
82
- `)}function Ba(){const{t:e}=de(),{data:s}=ab(),r=lb(),o=db(),p=cb(),[m,x]=b.useState(!1),[i,n]=b.useState(null),a=b.useRef(null),[h,c]=b.useState({top:0,right:0}),[g,v]=b.useState(!1),[_,w]=b.useState(!1),l=s?.status!==void 0&&s.status!=="stopped",u=r.isPending||s?.status==="starting",d=p.isPending,f=s?.shareableUrl,S=s?.token,C=ub(s),k=hb(s),j=mb(s);b.useEffect(()=>{if(m&&a.current){const z=a.current.getBoundingClientRect();c({top:z.bottom+8,right:window.innerWidth-z.right})}},[m]);const y=b.useCallback(()=>{x(!0)},[l]),E=b.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>x(!0)})},[r]),R=b.useCallback(()=>{f&&(navigator.clipboard.writeText(f),n("url"),setTimeout(()=>n(null),2e3))},[f]),P=b.useCallback(()=>{S&&(navigator.clipboard.writeText(S),n("token"),setTimeout(()=>n(null),2e3))},[S]),M=b.useCallback(()=>{o.mutate(),x(!1),v(!1),w(!1)},[o]),L=b.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{w(!1),x(!0)}})},[p]);return t.jsxs("div",{className:"relative",children:[t.jsx("button",{ref:a,onClick:y,disabled:u,className:`p-1.5 rounded-md transition-colors ${C.button}`,title:e(C.label),children:u?t.jsx(Be,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(As,{size:16}):t.jsx(Ro,{size:16})}),l&&!u&&t.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${C.dot} rounded-full`}),m&&!l&&Cs.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>x(!1)}),t.jsxs("div",{className:"fixed z-[101] w-80 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:h.top,right:h.right},children:[t.jsxs("div",{className:"flex items-start justify-between gap-3",children:[t.jsxs("div",{className:"flex items-start gap-2",children:[t.jsx("span",{className:"mt-0.5 flex size-7 items-center justify-center rounded-md bg-neutral-100 text-neutral-700",children:t.jsx(Ro,{size:16})}),t.jsxs("div",{children:[t.jsx("div",{className:"text-sm font-medium text-neutral-900",children:e("Use Agent Tower on your phone")}),t.jsx("p",{className:"mt-1 text-xs leading-relaxed text-neutral-500",children:e("After enabling the tunnel, you can scan a QR code with your phone to visit this Agent Tower instance, assign tasks, and check agent status.")})]})]}),t.jsx("button",{onClick:()=>x(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Gt,{size:14})})]}),t.jsxs("button",{onClick:E,disabled:u,className:"mt-3 w-full px-3 py-2 text-xs font-medium text-white bg-neutral-900 hover:bg-neutral-800 rounded-md transition-colors disabled:opacity-50 flex items-center justify-center gap-1.5",children:[u&&t.jsx(Be,{size:13,className:"animate-spin"}),e(u?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&l&&Cs.createPortal(t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>x(!1)}),t.jsxs("div",{className:"fixed z-[101] w-96 max-w-[calc(100vw-1rem)] bg-white rounded-lg shadow-lg border border-neutral-200 p-3",style:{top:h.top,right:h.right},children:[t.jsxs("div",{className:"flex items-start justify-between mb-2",children:[t.jsxs("div",{children:[t.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${s?.status==="healthy"||s?.status==="checking"?"text-emerald-600":s?.status==="exited"||s?.status==="error"?"text-red-600":"text-amber-600"}`,children:[t.jsx("span",{className:`w-1.5 h-1.5 ${C.dot} rounded-full inline-block`}),e(k)]}),t.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(fb(s))})]}),t.jsx("button",{onClick:()=>x(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Gt,{size:14})})]}),S&&t.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-2 py-1 bg-neutral-50 rounded text-xs text-neutral-700",children:[t.jsx(au,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(fd,{value:f,size:160})}),f||s?.url?t.jsxs("div",{className:"flex items-center gap-2",children:[t.jsx("input",{readOnly:!0,value:f??s?.url??"",className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-700 select-all",onFocus:z=>z.target.select()}),t.jsx("button",{onClick:R,disabled:!f,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-40",title:e("Copy shareable link"),children:i==="url"?t.jsx(Wt,{size:14,className:"text-emerald-500"}):t.jsx(jo,{size:14})})]}):t.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-2 py-1.5 text-xs text-neutral-500",children:e("No tunnel link available")}),t.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:Oa(s?.lastCheckedAt)})]}),t.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[t.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),t.jsx("div",{className:"mt-0.5 text-neutral-800",children:Oa(s?.lastHealthyAt)})]})]}),j&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800 whitespace-pre-wrap break-words max-h-28 overflow-auto",children:j}),s?.status==="degraded"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("Agent Tower is keeping the same URL and waiting for Cloudflare Quick Tunnel to recover.")}),s?.status==="linkReplaced"&&t.jsx("div",{className:"mt-2 rounded-md border border-amber-200 bg-amber-50 px-2 py-1.5 text-xs text-amber-800",children:e("The previous tunnel link and token are no longer valid.")}),S&&t.jsxs("div",{className:"mt-2",children:[t.jsx("button",{onClick:()=>v(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&t.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[t.jsx("code",{className:"flex-1 min-w-0 px-2 py-1.5 text-xs bg-neutral-50 border border-neutral-200 rounded-md text-neutral-600 break-all",children:S}),t.jsx("button",{onClick:P,className:"p-1.5 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors shrink-0",title:e("Copy token"),children:i==="token"?t.jsx(Wt,{size:14,className:"text-emerald-500"}):t.jsx(jo,{size:14})})]})]}),_&&t.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[t.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),t.jsxs("div",{className:"mt-2 flex gap-2",children:[t.jsx("button",{onClick:()=>w(!1),className:"flex-1 px-2 py-1 rounded-md bg-white text-neutral-700 border border-neutral-200 hover:bg-neutral-50",children:e("Cancel")}),t.jsx("button",{onClick:L,disabled:d,className:"flex-1 px-2 py-1 rounded-md bg-red-600 text-white hover:bg-red-700 disabled:opacity-50",children:e(d?"Generating...":"Regenerate link")})]})]}),!_&&t.jsxs("button",{onClick:()=>w(!0),disabled:d||s?.canRegenerate===!1,className:"mt-3 w-full px-3 py-1.5 text-xs text-amber-700 hover:bg-amber-50 rounded-md transition-colors disabled:opacity-40 flex items-center justify-center gap-1.5",children:[t.jsx(Ts,{size:13}),e("Regenerate link")]}),t.jsx("button",{onClick:M,disabled:o.isPending,className:"mt-2 w-full px-3 py-1.5 text-xs text-red-600 hover:bg-red-50 rounded-md transition-colors",children:o.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function un({isOpen:e,onClose:s}){const{t:r}=de(),o=gu(),[p,m]=b.useState(""),[x,i]=b.useState(""),[n,a]=b.useState(null),[h,c]=b.useState(!1),[g,v]=b.useState(!1),_=p.trim(),w=x.trim(),l=h||o.isPending,u=b.useMemo(()=>!!(_&&w&&!l),[_,w,l]),d=b.useCallback(()=>{m(""),i(""),a(null),v(!1)},[]),f=b.useCallback(()=>{l||(d(),s())},[l,s,d]);b.useEffect(()=>{e||d()},[e,d]);const S=b.useCallback(async y=>{try{await o.mutateAsync({name:_,repoPath:w,initEmptyRepo:y}),d(),s()}catch(E){const R=E instanceof Error?E.message:r("Failed to create project");a(R),ot.error(R)}},[o,s,d,r,_,w]),C=b.useCallback(async()=>{if(!(!_||!w||l)){a(null),c(!0);try{const y=await ye.get("/filesystem/validate",{params:{path:w}});if(!y.valid){a(y.error??r("Selected path is not a valid directory"));return}if(y.isGitRepo){await S(!1);return}if(y.reason==="no_git"&&y.isEmpty){v(!0);return}if(y.reason==="no_git"){await S(!1);return}await S(!1)}catch(y){a(y instanceof Error?y.message:r("Could not check project path"))}finally{c(!1)}}},[S,l,r,_,w]),k=b.useCallback(()=>{v(!1),S(!1)},[S]),j=b.useCallback(()=>{v(!1),S(!0)},[S]);return t.jsxs(t.Fragment,{children:[t.jsx(gs,{isOpen:e,onClose:f,title:r("Create New Project"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:f,disabled:l,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:C,disabled:!u,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${u?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:h?r("Checking..."):o.isPending?r("Creating..."):r("Create Project")})]}),children:t.jsxs("div",{className:"space-y-4",children:[t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),t.jsx("input",{type:"text",value:p,onChange:y=>m(y.target.value),placeholder:r("e.g., Agent Tower"),disabled:l,className:"w-full px-3 py-2 border border-neutral-200 rounded-lg text-sm focus:outline-none focus:border-neutral-400 transition-colors disabled:bg-neutral-50 disabled:text-neutral-400",autoFocus:!0})]}),t.jsxs("div",{children:[t.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Path")}),t.jsx(du,{value:x,onChange:i,validationMode:"directory"})]}),n&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:n})]})}),t.jsx(gs,{isOpen:g,onClose:()=>{o.isPending||v(!1)},title:r("Initialize Git repository?"),action:t.jsxs(t.Fragment,{children:[t.jsx("button",{onClick:()=>v(!1),disabled:o.isPending,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),t.jsx("button",{onClick:k,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg border border-neutral-200 text-neutral-700 hover:bg-neutral-50 transition-colors disabled:opacity-50",children:r("Create Local Project")}),t.jsx("button",{onClick:j,disabled:o.isPending,className:"px-4 py-2 text-sm font-medium rounded-lg bg-neutral-900 text-white hover:bg-black transition-colors disabled:opacity-50",children:o.isPending?r("Creating..."):r("Initialize and Create")})]}),children:t.jsxs("div",{className:"space-y-3 text-sm text-neutral-600 leading-relaxed",children:[t.jsx("p",{children:r("This directory is empty and does not have Git version control yet. Agent Tower can initialize Git and create the initial commit before creating the project.")}),t.jsx("p",{children:r("You can also create it as a local project now. Local projects only support local Solo tasks until Git is initialized.")})]})})]})}function Fa(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function pb(e){return e.map((s,r)=>({project:s,index:r,activityTime:Fa(s.lastActivityAt??s.createdAt),createdTime:Fa(s.createdAt)})).sort((s,r)=>{const o=r.activityTime-s.activityTime;if(o!==0)return o;const p=r.createdTime-s.createdTime;return p!==0?p:s.index-r.index}).map(({project:s})=>s)}function za({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=de(),[x,i]=b.useState(!1),n=e.filter(h=>!h.archivedAt),a=s?e.find(h=>h.id===s)??null:null;return t.jsxs("div",{className:Z("relative flex items-center min-w-0",p),children:[t.jsx("span",{className:"mx-1.5 text-muted-foreground/40 select-none",children:"/"}),t.jsxs("button",{onClick:()=>i(h=>!h),className:"flex items-center gap-1.5 px-2 py-1 rounded-md text-sm text-foreground/90 hover:bg-accent transition-colors min-w-0",children:[a?t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${a.color.replace("text-","bg-")}`}):t.jsx(Vs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:"truncate max-w-[200px] font-medium",children:a?a.name:m("All Projects")}),t.jsx(kt,{size:13,className:`text-muted-foreground/70 shrink-0 transition-transform duration-200 ${x?"rotate-180":""}`})]}),x?t.jsxs(t.Fragment,{children:[t.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>i(!1)}),t.jsxs("div",{className:"absolute left-4 top-full mt-1.5 w-60 bg-popover border border-border rounded-lg shadow-lg shadow-black/5 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[t.jsxs("button",{onClick:()=>{r(null),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx(Vs,{size:13,className:"text-muted-foreground shrink-0"}),t.jsx("span",{className:`flex-1 truncate ${s===null?"text-foreground font-medium":"text-muted-foreground"}`,children:m("All Projects")}),s===null?t.jsx(Wt,{size:14,className:"text-foreground shrink-0"}):null]}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsx("div",{className:"max-h-[40vh] overflow-y-auto scrollbar-app-thin",children:n.map(h=>{const c=s===h.id;return t.jsxs("button",{onClick:()=>{r(h.id),i(!1)},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 hover:bg-accent/50 transition-colors",children:[t.jsx("span",{className:`w-2 h-2 rounded-full shrink-0 ${h.color.replace("text-","bg-")}`}),t.jsx("span",{className:`flex-1 truncate ${c?"text-foreground font-medium":"text-muted-foreground"}`,children:h.name}),c?t.jsx(Wt,{size:14,className:"text-foreground shrink-0"}):null]},h.id)})}),t.jsx("div",{className:"h-px bg-border/60 my-1 mx-2"}),t.jsxs("button",{onClick:()=>{i(!1),o()},className:"w-full text-left px-3 py-1.5 text-[13px] flex items-center gap-2 text-muted-foreground hover:text-foreground hover:bg-accent/50 transition-colors",children:[t.jsx(us,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}const gb=260,vb=600,Wa=400,xb=100,bb=1e3;function _b(e){const s=e.workspaces?.find(o=>o.status==="ACTIVE")??e.workspaces?.[0],r=s?.sessions?.at(-1);return{id:e.id,projectId:e.projectId,title:e.titlePreview??e.title,status:e.status,priority:e.priority,...s?{preferredWorkspace:{...s.workspaceKind===bt.MAIN_DIRECTORY?{workspaceKind:bt.MAIN_DIRECTORY}:{},branchName:s.branchName}}:{},...r?{latestAgentType:r.agentType}:{},...e.workspaces?.some(o=>o.sessions?.some(p=>p.status==="RUNNING"||p.status==="PENDING"))?{hasRunningSession:!0}:{},updatedAt:e.updatedAt?new Date(e.updatedAt).getTime():Date.now()}}function yb(){const{t:e,locale:s}=de(),[r,o]=b.useState(null),[p,m]=b.useState(null),[x,i]=b.useState(Wa),[n,a]=b.useState(!1),[h,c]=b.useState("idle"),[g,v]=b.useState({}),_=b.useRef(!1),w=b.useRef(0),l=b.useRef(Wa),u=b.useRef(null),d=vt(),{data:f,isLoading:S}=Gs(),{data:C,isLoading:k}=vu({limit:xb}),j=b.useMemo(()=>C?.data??[],[C?.data]),y=p&&j.some(ee=>ee.id===p)?p:null,{data:E,isLoading:R}=$d({...y?{projectId:y}:{},limit:bb}),P=b.useMemo(()=>E?.data??[],[E?.data]),[M,L]=b.useState([]),z=b.useMemo(()=>{if(M.length===0)return P;const ee=new Set(P.map(fe=>fe.id));return[...M.filter(fe=>!ee.has(fe.id)),...P]},[P,M]),[I,W]=b.useState(null),$=b.useMemo(()=>r&&z.some(ee=>ee.id===r)?r:I&&r===I?I:null,[r,z,I]);b.useEffect(()=>{I&&z.some(ee=>ee.id===I)&&W(null)},[I,z]),b.useEffect(()=>{if(M.length===0)return;const ee=new Set(P.map(fe=>fe.id));M.some(fe=>ee.has(fe.id))&&L(fe=>fe.filter(we=>!ee.has(we.id)))},[P,M]);const A=b.useMemo(()=>pb(j),[j]),D=b.useMemo(()=>A.map(Tx),[A]),T=b.useMemo(()=>A.filter(ee=>!ee.archivedAt),[A]),O=b.useMemo(()=>{if(!f)return[];const ee=localStorage.getItem("providerUsageCount"),fe=ee?JSON.parse(ee):{};return[...f].sort((we,X)=>{const te=we.availability.type!=="NOT_FOUND",ie=X.availability.type!=="NOT_FOUND";if(te!==ie)return te?-1:1;const ae=fe[we.provider.id]??0;return(fe[X.provider.id]??0)-ae})},[f]),K=b.useMemo(()=>z.map(ee=>Mx(ee,j.find(fe=>fe.id===ee.projectId))),[j,z]),V=b.useMemo(()=>{if(!$)return null;const ee=z.find(we=>we.id===$);if(!ee)return null;const fe=j.find(we=>we.id===ee.projectId);if(!fe){const we=ee.preferredWorkspace?ee.preferredWorkspace.workspaceKind===bt.MAIN_DIRECTORY?"Project directory":ee.preferredWorkspace.branchName:"—";return{id:ee.id,projectId:ee.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:ee.title,status:mo(ee.status),priority:ee.priority,branch:we,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return Dx(ee,fe)},[$,z,j]),B=Va(),U=qd(),H=Kd(),N=Ya(),F=Fn(),q=b.useCallback(ee=>{const fe=_b(ee);L(we=>we.some(X=>X.id===ee.id)?we.map(X=>X.id===ee.id?fe:X):[fe,...we]),d.setQueryData(ce.tasks.detail(ee.id),ee),W(ee.id),o(ee.id)},[d]),Y=b.useCallback((ee,fe,we)=>{const X=ee.id,te=[ee.title,ee.description].filter(Boolean).join(`
83
-
84
- `),ie=we===bt.WORKTREE?T.find(ae=>ae.id===ee.projectId)?.setupScript??null:null;v(ae=>({...ae,[X]:{status:"creating-workspace",setupScript:ie}})),(async()=>{try{const ae=await ye.post(`/tasks/${X}/workspaces`,{workspaceKind:we});v(ke=>({...ke,[X]:{status:"creating-session",setupScript:ie}}));const Ce=await ye.post(`/workspaces/${ae.id}/sessions`,{providerId:fe,prompt:te});v(ke=>({...ke,[X]:{status:"starting-session",setupScript:ie}})),await F.mutateAsync(Ce.id),await d.invalidateQueries({queryKey:ce.workspaces.list(X)}),await d.invalidateQueries({queryKey:ce.workspaces.setupProgress(X)}),await d.invalidateQueries({queryKey:ce.tasks.all}),v(ke=>{const{[X]:Pe,...Je}=ke;return Je})}catch(ae){const Ce=ae instanceof Error?ae.message:e("启动 Agent 失败");v(ke=>({...ke,[X]:{status:"failed",error:Ce,setupScript:ie}})),ot.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:ce.workspaces.list(X)}),d.invalidateQueries({queryKey:ce.tasks.all})}})()},[T,d,F,e]),se=b.useCallback(ee=>{v(fe=>{const{[ee]:we,...X}=fe;return X}),d.invalidateQueries({queryKey:ce.workspaces.list(ee)}),d.invalidateQueries({queryKey:ce.tasks.all})},[d]),G=b.useCallback(ee=>{U.mutate(ee,{onSuccess:()=>{$===ee&&o(null),v(fe=>{const{[ee]:we,...X}=fe;return X}),L(fe=>fe.filter(we=>we.id!==ee)),d.invalidateQueries({queryKey:ce.tasks.all})},onError:()=>{ot.error(e("删除任务失败"))}})},[U,$,d,e]),pe=b.useCallback((ee,fe)=>{H.mutate({id:ee,status:Rx(fe)},{onError:()=>{ot.error(e("状态变更失败,该操作不被允许"))}})},[H,e]),he=b.useCallback((ee,fe)=>{N.mutate({id:ee,priority:fe},{onError:()=>{ot.error(e("优先级变更失败"))}})},[N,e]),re=b.useCallback(ee=>{ee.preventDefault(),_.current=!0,w.current=ee.clientX,l.current=x,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[x]);b.useEffect(()=>{const ee=we=>{if(!_.current)return;const X=we.clientX-w.current,te=Math.max(gb,Math.min(vb,l.current+X));i(te)},fe=()=>{_.current&&(_.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",ee),document.addEventListener("mouseup",fe),()=>{document.removeEventListener("mousemove",ee),document.removeEventListener("mouseup",fe)}},[]);const ne=b.useCallback(()=>{a(!0)},[]),le=b.useCallback(()=>{if(T.length===0){ot.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[T,e]),Se=b.useCallback(()=>{a(!1)},[]),We=b.useCallback(async ee=>{const{title:fe,description:we,projectId:X,providerId:te,mode:ie,workspaceMode:ae,teamRunMode:Ce,teamTemplateId:ke,memberPresetIds:Pe,attachmentLinks:Je,priority:be}=ee,xe=[we,Je].filter(Boolean).join(`
85
-
86
- `);let me=null;try{if(c("creating-task"),me=await ye.post(`/projects/${X}/tasks`,{title:fe,description:xe||void 0,priority:be}),localStorage.setItem("lastSelectedProjectId",X),ie==="SOLO"&&te){localStorage.setItem("lastSelectedProviderId",te);const st=localStorage.getItem("providerUsageCount"),lt=st?JSON.parse(st):{};lt[te]=(lt[te]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(lt))}ie==="TEAM"?(c("creating-teamrun"),await B.mutateAsync({taskId:me.id,mode:Ce,...ke?{teamTemplateId:ke}:{},...Pe.length>0?{memberPresetIds:Pe}:{}})):te&&Y(me,te,ae),y&&X!==y&&m(null),q(me),c("idle"),d.invalidateQueries({queryKey:ce.tasks.all}),d.invalidateQueries({queryKey:ce.projects.all})}catch(Fe){if(c("idle"),me&&ie==="TEAM"){try{await U.mutateAsync(me.id)}catch{}throw ot.error(e("TeamRun 创建失败,请检查团队配置后重试")),Fe}else if(me)y&&X!==y&&m(null),q(me),d.invalidateQueries({queryKey:ce.tasks.all}),d.invalidateQueries({queryKey:ce.projects.all});else throw ot.error(Fe instanceof Error?Fe.message:e("Failed to create task")),Fe}},[T,B,Y,U,d,e,y,q]),Ee=k||R,He=b.useMemo(()=>T.map(ee=>({id:ee.id,name:ee.name,color:D.find(fe=>fe.id===ee.id)?.color,repoPath:ee.repoPath,isGitRepo:ee.isGitRepo,worktreeReady:ee.worktreeReady,reason:ee.reason})),[T,D]),at=b.useMemo(()=>O.map(ee=>{const fe=ts(ee);return{id:ee.provider.id,name:ee.provider.name,agentType:ee.provider.agentType,available:!fe,permissionMode:ee.provider.executionPermission,reason:fe}}),[O]),Me=b.useMemo(()=>{if(y&&T.find(fe=>fe.id===y))return y;const ee=localStorage.getItem("lastSelectedProjectId");return ee&&T.find(fe=>fe.id===ee)?ee:T[0]?.id??""},[T,y]),[Ne,Oe]=b.useState(Me);b.useEffect(()=>{Oe(Me)},[Me]);const $e=b.useMemo(()=>T.find(ee=>ee.id===Ne)?.name??T.find(ee=>ee.id===Me)?.name??e("Project"),[T,Ne,Me,e]),qe=s==="zh-CN"?`你需要在 ${$e} 中做点什么?`:`What do you need to do in ${$e}?`,De=b.useMemo(()=>{const ee=localStorage.getItem("lastSelectedProviderId");return ee&&O.find(we=>we.provider.id===ee&&!ts(we))?ee:O.find(we=>!ts(we))?.provider.id??""},[O]),Ge=Ul(),[Qe,Te]=b.useState(!1),{usesIntegratedTitlebar:ge,desktopPlatform:et,hasMacTrafficLights:Xe}=Ha(),Ue=ge&&et==="win32",ft=b.useCallback(()=>{if(T.length===0){ot.error(e("没有可用项目,请先创建或恢复项目"));return}Te(!0)},[T,e]),tt=b.useCallback(async ee=>{await We(ee),Te(!1)},[We]);return Ge?Qe?t.jsxs("div",{className:"flex flex-col h-dvh bg-background overflow-hidden text-sm",children:[t.jsx("header",{className:"h-12 border-b border-border/60 flex items-center px-4 shrink-0",children:t.jsx("button",{onClick:()=>Te(!1),className:"text-sm text-muted-foreground active:text-foreground",children:e("Cancel")})}),t.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center px-4 pb-[8vh]",children:[t.jsx("h1",{className:"max-w-full text-center text-[20px] font-medium tracking-tight leading-snug text-foreground mb-5 break-words",children:qe}),t.jsx(ko,{projects:He,providers:at,isProvidersLoading:S,onSubmit:tt,defaultProjectId:Me,defaultProviderId:De,onProjectChange:Oe,createStep:h})]})]}):$&&V?t.jsxs(t.Fragment,{children:[t.jsx(Qx,{task:V,onBack:()=>o(null),onDeleteTask:V.projectArchivedAt?void 0:G,onTaskPriorityChange:V.projectArchivedAt?void 0:he,isDeleting:U.isPending,autoStartState:g[V.id]??null,onAutoStartRecovered:se}),t.jsx(un,{isOpen:n,onClose:Se})]}):t.jsxs(t.Fragment,{children:[t.jsxs("div",{className:"flex flex-col h-dvh bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:"h-12 bg-sidebar flex items-center px-4 justify-between shrink-0 z-20",children:[t.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[t.jsx(Eo,{}),t.jsx(za,{projects:D,filterProjectId:y,setFilterProjectId:m,onCreateProject:ne})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Ba,{}),t.jsx("button",{onClick:()=>yo.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(_o,{size:16})})]})]}),t.jsx($o,{tasks:K,projects:D,selectedTaskId:null,onSelectTask:o,filterProjectId:y,setFilterProjectId:m,width:"100%",onCreateTask:ft,onCreateProject:ne,onTaskStatusChange:pe,onTaskPriorityChange:he,isLoading:Ee&&K.length===0})]}),t.jsx(un,{isOpen:n,onClose:Se})]}):t.jsxs("div",{ref:u,className:"flex flex-col h-screen bg-sidebar overflow-hidden text-sm",children:[t.jsxs("header",{className:Z("h-12 bg-sidebar flex items-center px-4 justify-between flex-shrink-0 z-20 relative",ge&&"app-region-drag",Ue&&"pr-[150px]"),children:[t.jsxs("div",{className:Z("flex items-center gap-2 min-w-0",Xe&&"pl-[72px]"),children:[t.jsx(Eo,{}),t.jsx(za,{projects:D,filterProjectId:y,setFilterProjectId:m,onCreateProject:ne,className:ge?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:Z("flex items-center gap-1",ge&&"app-region-no-drag"),children:[t.jsx("div",{className:ge?"app-region-no-drag":void 0,children:t.jsx(Ba,{})}),t.jsx("button",{onClick:()=>yo.getState().openSettings(),className:Z("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",ge&&"app-region-no-drag"),children:t.jsx(_o,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[t.jsx($o,{tasks:K,projects:D,selectedTaskId:$,onSelectTask:o,filterProjectId:y,setFilterProjectId:m,width:x,onCreateTask:le,onCreateProject:ne,isCreateActive:!$,onTaskStatusChange:pe,onDeleteTask:G,onTaskPriorityChange:he,isLoading:Ee&&K.length===0}),t.jsx("div",{onMouseDown:re,className:"w-1 cursor-col-resize hover:bg-border active:bg-ring/40 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),t.jsx("div",{className:"flex-1 flex min-w-0 mb-2 mr-2 rounded-xl border border-border/50 bg-background overflow-hidden",children:$&&V?t.jsx(Nx,{task:V,onDeleteTask:V.projectArchivedAt?void 0:G,isDeleting:U.isPending,onTaskStatusChange:V.projectArchivedAt?void 0:pe,onTaskPriorityChange:V.projectArchivedAt?void 0:he,autoStartState:g[V.id]??null,onAutoStartRecovered:se}):$&&!V?t.jsx("div",{className:"flex-1 flex items-center justify-center bg-background min-w-0",children:t.jsx("span",{className:"text-sm text-muted-foreground/70",children:e("Loading...")})}):t.jsx("div",{className:"flex-1 flex flex-col items-center justify-center bg-background min-w-0 px-8 pb-[10vh]",children:t.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center animate-[fadeInUp_0.5s_cubic-bezier(0.16,1,0.3,1)]",children:[t.jsx("h1",{className:"max-w-full text-center text-[26px] font-medium tracking-tight leading-snug text-foreground mb-6 break-words",children:qe}),t.jsx(ko,{projects:He,providers:at,isProvidersLoading:S,onSubmit:We,defaultProjectId:Me,defaultProviderId:De,onProjectChange:Oe,createStep:h})]})})})]}),t.jsx(un,{isOpen:n,onClose:Se})]})}const Xb=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:yb},Symbol.toStringTag,{value:"Module"}));export{Xb as P,uc as l};