agent-tower 0.7.2-beta.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 (209) hide show
  1. package/dist/executors/base.executor.d.ts.map +1 -1
  2. package/dist/executors/base.executor.js +6 -3
  3. package/dist/executors/base.executor.js.map +1 -1
  4. package/dist/routes/__tests__/workspaces.test.js +80 -0
  5. package/dist/routes/__tests__/workspaces.test.js.map +1 -1
  6. package/dist/routes/workspaces.js +1 -1
  7. package/dist/routes/workspaces.js.map +1 -1
  8. package/dist/runtime/__tests__/cli-driver-lifecycle.test.js +37 -0
  9. package/dist/runtime/__tests__/cli-driver-lifecycle.test.js.map +1 -1
  10. package/dist/runtime/__tests__/runtime-coordinator.test.js +13 -0
  11. package/dist/runtime/__tests__/runtime-coordinator.test.js.map +1 -1
  12. package/dist/runtime/cli-driver.js +17 -3
  13. package/dist/runtime/cli-driver.js.map +1 -1
  14. package/dist/runtime/contracts.d.ts +9 -2
  15. package/dist/runtime/contracts.d.ts.map +1 -1
  16. package/dist/runtime/runtime-coordinator.d.ts +2 -0
  17. package/dist/runtime/runtime-coordinator.d.ts.map +1 -1
  18. package/dist/runtime/runtime-coordinator.js +10 -0
  19. package/dist/runtime/runtime-coordinator.js.map +1 -1
  20. package/dist/services/__tests__/session-manager.lifecycle.test.js +67 -0
  21. package/dist/services/__tests__/session-manager.lifecycle.test.js.map +1 -1
  22. package/dist/services/__tests__/session-manager.team-run.test.js +41 -46
  23. package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -1
  24. package/dist/services/__tests__/team-reconciler.service.test.js +30 -0
  25. package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -1
  26. package/dist/services/project.service.d.ts.map +1 -1
  27. package/dist/services/project.service.js +30 -4
  28. package/dist/services/project.service.js.map +1 -1
  29. package/dist/services/session-manager.d.ts +1 -0
  30. package/dist/services/session-manager.d.ts.map +1 -1
  31. package/dist/services/session-manager.js +38 -3
  32. package/dist/services/session-manager.js.map +1 -1
  33. package/dist/services/session-runtime-cleanup-gate.d.ts +1 -0
  34. package/dist/services/session-runtime-cleanup-gate.d.ts.map +1 -1
  35. package/dist/services/session-runtime-cleanup-gate.js +5 -3
  36. package/dist/services/session-runtime-cleanup-gate.js.map +1 -1
  37. package/dist/services/team-reconciler.service.d.ts +1 -0
  38. package/dist/services/team-reconciler.service.d.ts.map +1 -1
  39. package/dist/services/team-reconciler.service.js +1 -0
  40. package/dist/services/team-reconciler.service.js.map +1 -1
  41. package/dist/services/workspace.service.js +8 -8
  42. package/dist/services/workspace.service.js.map +1 -1
  43. package/dist/utils/__tests__/spawned-process-identity.test.d.ts +2 -0
  44. package/dist/utils/__tests__/spawned-process-identity.test.d.ts.map +1 -0
  45. package/dist/utils/__tests__/spawned-process-identity.test.js +31 -0
  46. package/dist/utils/__tests__/spawned-process-identity.test.js.map +1 -0
  47. package/dist/utils/spawned-process-identity.d.ts +1 -1
  48. package/dist/utils/spawned-process-identity.d.ts.map +1 -1
  49. package/dist/utils/spawned-process-identity.js +11 -3
  50. package/dist/utils/spawned-process-identity.js.map +1 -1
  51. package/dist/web/assets/AgentDemoPage-Svq9Baa7.js +1 -0
  52. package/dist/web/assets/{AgentEnvironmentSettingsPage-DfVjAeK8.js → AgentEnvironmentSettingsPage-DQjnDr-h.js} +1 -1
  53. package/dist/web/assets/AgentLogo-I2etsqym.js +1 -0
  54. package/dist/web/assets/BranchSelect-Eb5UGWWX.js +1 -0
  55. package/dist/web/assets/BrandLogo-BjC1hcgv.js +1 -0
  56. package/dist/web/assets/{ConversationPage-Bh_x9kK3.js → ConversationPage-jEYUuSPT.js} +2 -2
  57. package/dist/web/assets/CreateTaskInput-B_cRDkVq.js +1 -0
  58. package/dist/web/assets/{DemoPage-xys5j303.js → DemoPage-BkkueMuL.js} +1 -1
  59. package/dist/web/assets/DesignSystemPage-oM16R2Ta.js +16 -0
  60. package/dist/web/assets/{ExecutionPermissionSelector-CTeKhMaB.js → ExecutionPermissionSelector-BX5Xx8ta.js} +1 -1
  61. package/dist/web/assets/{GeneralSettingsPage-BZEcE8xN.js → GeneralSettingsPage-B0jFlgDl.js} +1 -1
  62. package/dist/web/assets/{LoadingPreviewPage-D81UstX2.js → LoadingPreviewPage-BxjpxLLP.js} +1 -1
  63. package/dist/web/assets/McpSettingsPage-BErvd619.js +1 -0
  64. package/dist/web/assets/{MemberAvatar-BuueBvLu.js → MemberAvatar-TVtoxQe8.js} +1 -1
  65. package/dist/web/assets/NotificationSettingsPage-BETMBdj1.js +1 -0
  66. package/dist/web/assets/{ProfileSettingsPage-DdK3Q2wl.js → ProfileSettingsPage-C03ZAft-.js} +1 -1
  67. package/dist/web/assets/ProjectKanbanPage-DsPxwoVf.js +86 -0
  68. package/dist/web/assets/ProjectSettingsPage-BwNM6VWs.js +2 -0
  69. package/dist/web/assets/{ProviderSettingsPage-CiTp3QwX.js → ProviderSettingsPage-CeNQPd74.js} +3 -3
  70. package/dist/web/assets/{SettingsMasterDetail-BhepxZ5b.js → SettingsMasterDetail-B_SI2h_k.js} +1 -1
  71. package/dist/web/assets/TeamSettingsPage-BfgtMl_n.js +1 -0
  72. package/dist/web/assets/agent-meta-DOylIs2N.js +1 -0
  73. package/dist/web/assets/arc-BlZww3MO.js +1 -0
  74. package/dist/web/assets/{architectureDiagram-3BPJPVTR-Byb8rrNU.js → architectureDiagram-3BPJPVTR-DWO_DRgk.js} +1 -1
  75. package/dist/web/assets/at-sign-BFf8Sz8T.js +1 -0
  76. package/dist/web/assets/{blockDiagram-GPEHLZMM-DGcS4UET.js → blockDiagram-GPEHLZMM-CJPYhE52.js} +1 -1
  77. package/dist/web/assets/{c4Diagram-AAUBKEIU-BRyJRATZ.js → c4Diagram-AAUBKEIU-Cx5IvcjB.js} +1 -1
  78. package/dist/web/assets/channel-D9sA6Wxp.js +1 -0
  79. package/dist/web/assets/check-Cm7Vstpm.js +1 -0
  80. package/dist/web/assets/chevron-down-C6Ta4vyM.js +1 -0
  81. package/dist/web/assets/chevron-up-BwJT7iif.js +1 -0
  82. package/dist/web/assets/{chunk-2J33WTMH-DgL3sVcs.js → chunk-2J33WTMH-D9cBNYgd.js} +1 -1
  83. package/dist/web/assets/{chunk-4BX2VUAB-BVgUUvCo.js → chunk-4BX2VUAB-BY8TNt6E.js} +1 -1
  84. package/dist/web/assets/{chunk-55IACEB6-CfD9Uy7p.js → chunk-55IACEB6-pT-HP-28.js} +1 -1
  85. package/dist/web/assets/{chunk-727SXJPM-D8gRbLX6.js → chunk-727SXJPM-hy95xDLb.js} +1 -1
  86. package/dist/web/assets/{chunk-AQP2D5EJ-CwBPJyzk.js → chunk-AQP2D5EJ-DlUN-icr.js} +1 -1
  87. package/dist/web/assets/{chunk-FMBD7UC4-B0b7Iiv3.js → chunk-FMBD7UC4-Dg2iMKZR.js} +1 -1
  88. package/dist/web/assets/{chunk-ND2GUHAM-D0Y5tagg.js → chunk-ND2GUHAM-DMzFIsJ-.js} +1 -1
  89. package/dist/web/assets/{chunk-QZHKN3VN-qVEPtRTm.js → chunk-QZHKN3VN-C6CgmKuM.js} +1 -1
  90. package/dist/web/assets/{circle-alert-C_ON1rCL.js → circle-alert-Dm2Pl-rU.js} +1 -1
  91. package/dist/web/assets/classDiagram-4FO5ZUOK-2e2YVo9r.js +1 -0
  92. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-2e2YVo9r.js +1 -0
  93. package/dist/web/assets/code-block-OCS4YCEC-DizntuP_.js +2 -0
  94. package/dist/web/assets/{confirm-dialog-Drhw7wmk.js → confirm-dialog-DRpyE_qU.js} +1 -1
  95. package/dist/web/assets/copy-r0aUdsl8.js +1 -0
  96. package/dist/web/assets/{cose-bilkent-S5V4N54A-BoSlujEJ.js → cose-bilkent-S5V4N54A-D-fvmvw-.js} +1 -1
  97. package/dist/web/assets/cssMode-DVorIr82.js +1 -0
  98. package/dist/web/assets/{dagre-BM42HDAG-DWm_GyDR.js → dagre-BM42HDAG-H0bYI1f3.js} +1 -1
  99. package/dist/web/assets/{diagram-2AECGRRQ-CVtgrsl0.js → diagram-2AECGRRQ-DI568fLp.js} +1 -1
  100. package/dist/web/assets/{diagram-5GNKFQAL-XNMIXdme.js → diagram-5GNKFQAL-BLcaBzw2.js} +1 -1
  101. package/dist/web/assets/{diagram-KO2AKTUF-CYXdL2cC.js → diagram-KO2AKTUF-aL1cvl23.js} +1 -1
  102. package/dist/web/assets/{diagram-LMA3HP47-8MCVTTrT.js → diagram-LMA3HP47-DbOutAfH.js} +1 -1
  103. package/dist/web/assets/{diagram-OG6HWLK6-DMWgHctP.js → diagram-OG6HWLK6-D_cWftAX.js} +1 -1
  104. package/dist/web/assets/{erDiagram-TEJ5UH35-D3qp5csl.js → erDiagram-TEJ5UH35-DRe5V8Dx.js} +1 -1
  105. package/dist/web/assets/{flowDiagram-I6XJVG4X-D-Bem31x.js → flowDiagram-I6XJVG4X-B5-vg_Nh.js} +1 -1
  106. package/dist/web/assets/{freemarker2-D7pixABp.js → freemarker2-CXlYb2yX.js} +3 -3
  107. package/dist/web/assets/{ganttDiagram-6RSMTGT7-D5ctgPCm.js → ganttDiagram-6RSMTGT7-B3iBFICN.js} +1 -1
  108. package/dist/web/assets/{gitGraphDiagram-PVQCEYII-lA3I18_r.js → gitGraphDiagram-PVQCEYII-CZ9zsKVw.js} +1 -1
  109. package/dist/web/assets/globe-JXfw4MCF.js +1 -0
  110. package/dist/web/assets/handlebars-BL0prPVZ.js +1 -0
  111. package/dist/web/assets/html-DJWeRkWe.js +1 -0
  112. package/dist/web/assets/htmlMode-D_fekqg9.js +1 -0
  113. package/dist/web/assets/{index-CA_B15_q.js → index-CWEbo6pZ.js} +5 -5
  114. package/dist/web/assets/{index-ClhIruws.js → index-CWbMMO6g.js} +13 -13
  115. package/dist/web/assets/index-uXglTJ2_.css +1 -0
  116. package/dist/web/assets/{infoDiagram-5YYISTIA-CGy_XnVP.js → infoDiagram-5YYISTIA-DQU_sN8x.js} +1 -1
  117. package/dist/web/assets/{ishikawaDiagram-YF4QCWOH-DFGAkcYD.js → ishikawaDiagram-YF4QCWOH-BVGrNzJa.js} +1 -1
  118. package/dist/web/assets/javascript-CDfuzdfe.js +1 -0
  119. package/dist/web/assets/{journeyDiagram-JHISSGLW-C9ZHl7QM.js → journeyDiagram-JHISSGLW-DU4Md1Tq.js} +1 -1
  120. package/dist/web/assets/{jsonMode-bD-WsLyj.js → jsonMode-BMSvHUHa.js} +4 -4
  121. package/dist/web/assets/{kanban-definition-UN3LZRKU-BbbRnxDG.js → kanban-definition-UN3LZRKU-DDPgCucq.js} +1 -1
  122. package/dist/web/assets/key-round-BHVp7u3Z.js +1 -0
  123. package/dist/web/assets/{layers-BlEewgM8.js → layers-2tjjhM75.js} +1 -1
  124. package/dist/web/assets/{linear-D04wUvKo.js → linear-D8yLBTVY.js} +1 -1
  125. package/dist/web/assets/link-CnunXc7X.js +1 -0
  126. package/dist/web/assets/liquid-DHrNpv6c.js +1 -0
  127. package/dist/web/assets/{lspLanguageFeatures-jn1q-hoP.js → lspLanguageFeatures-BiYvrSP0.js} +1 -1
  128. package/dist/web/assets/mdx-CIEpgUOV.js +1 -0
  129. package/dist/web/assets/mermaid-NOHMQCX5-9-DTTfp6.js +124 -0
  130. package/dist/web/assets/{message-square-CTrwLud_.js → message-square-QM0c6Dcv.js} +1 -1
  131. package/dist/web/assets/{mindmap-definition-RKZ34NQL-n24WGa7x.js → mindmap-definition-RKZ34NQL-CCAuuWFZ.js} +1 -1
  132. package/dist/web/assets/{modal-BFDGLwoR.js → modal-BRoNvfhw.js} +1 -1
  133. package/dist/web/assets/{monaco-CirwkIGR.js → monaco-CrBn9oMJ.js} +3 -3
  134. package/dist/web/assets/paperclip-CC7nHUQ7.js +1 -0
  135. package/dist/web/assets/pencil-DIY0Hu5t.js +1 -0
  136. package/dist/web/assets/{pieDiagram-4H26LBE5-CUMw3DZK.js → pieDiagram-4H26LBE5-CXy_N5QX.js} +2 -2
  137. package/dist/web/assets/play-CIZVXiwM.js +1 -0
  138. package/dist/web/assets/python-BIs0pClJ.js +1 -0
  139. package/dist/web/assets/{quadrantDiagram-W4KKPZXB-DMshWJZy.js → quadrantDiagram-W4KKPZXB-Dt44QsS8.js} +1 -1
  140. package/dist/web/assets/razor-JCx8NEwU.js +1 -0
  141. package/dist/web/assets/{requirementDiagram-4Y6WPE33-B4Jx_Yx6.js → requirementDiagram-4Y6WPE33-BL8D7Np0.js} +1 -1
  142. package/dist/web/assets/{sankeyDiagram-5OEKKPKP-CN2JbWht.js → sankeyDiagram-5OEKKPKP-I5nefO3A.js} +1 -1
  143. package/dist/web/assets/{select-CLV6rtRD.js → select-BmjoUfrV.js} +1 -1
  144. package/dist/web/assets/{sequenceDiagram-3UESZ5HK-B4bMaYD_.js → sequenceDiagram-3UESZ5HK-lbPrhX8g.js} +1 -1
  145. package/dist/web/assets/server-BNBdQGor.js +1 -0
  146. package/dist/web/assets/stateDiagram-AJRCARHV-Bw3qtv2M.js +1 -0
  147. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-Xbc4HxDQ.js +1 -0
  148. package/dist/web/assets/{switch-Ch_hFX_n.js → switch-CEUHI4gI.js} +1 -1
  149. package/dist/web/assets/task-kalEmHDc.js +42 -0
  150. package/dist/web/assets/task-priority-wLXAgVZZ.js +1 -0
  151. package/dist/web/assets/{textarea-DDy2_gLQ.js → textarea-CD82lB0Z.js} +1 -1
  152. package/dist/web/assets/{timeline-definition-PNZ67QCA-BuLxqHOL.js → timeline-definition-PNZ67QCA-Cfg_kgoa.js} +1 -1
  153. package/dist/web/assets/{trash-2-DrNpNvRo.js → trash-2-BF_3L-qk.js} +1 -1
  154. package/dist/web/assets/{tsMode-qES9KHvZ.js → tsMode-DAHSkTAr.js} +2 -2
  155. package/dist/web/assets/typescript-CptiLWGr.js +1 -0
  156. package/dist/web/assets/{upload-D6SifUfr.js → upload-B2AMXrU-.js} +1 -1
  157. package/dist/web/assets/{use-profiles-DUoivbBF.js → use-profiles-CQ-jIuiI.js} +1 -1
  158. package/dist/web/assets/use-projects-BYUZwQ-q.js +1 -0
  159. package/dist/web/assets/{use-providers-BKYsoOBU.js → use-providers-DdV9gbj1.js} +1 -1
  160. package/dist/web/assets/useNormalizedLogs-DdFsf-Z1.js +1 -0
  161. package/dist/web/assets/{vennDiagram-CIIHVFJN-LoQ_fciU.js → vennDiagram-CIIHVFJN-CdEP03CK.js} +1 -1
  162. package/dist/web/assets/{wardley-L42UT6IY-Dh_9I9Zv.js → wardley-L42UT6IY-q_Enplrs.js} +1 -1
  163. package/dist/web/assets/{wardleyDiagram-YWT4CUSO-CQ-yZsuW.js → wardleyDiagram-YWT4CUSO-DlL6fsid.js} +1 -1
  164. package/dist/web/assets/xml-DbPqkgZW.js +1 -0
  165. package/dist/web/assets/{xychartDiagram-2RQKCTM6-HLyImhwf.js → xychartDiagram-2RQKCTM6-B2OGqVKA.js} +1 -1
  166. package/dist/web/assets/yaml-Deyq6Z5-.js +1 -0
  167. package/dist/web/index.html +2 -2
  168. package/node_modules/@agent-tower/shared/dist/types.d.ts +1 -1
  169. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  170. package/package.json +1 -1
  171. package/dist/web/assets/AgentDemoPage-CCw9EfsA.js +0 -1
  172. package/dist/web/assets/AgentLogo-BhKP5dmt.js +0 -1
  173. package/dist/web/assets/CreateTaskInput-D_KCLZ4q.js +0 -1
  174. package/dist/web/assets/McpSettingsPage-Ch1U9tIg.js +0 -1
  175. package/dist/web/assets/NotificationSettingsPage-IHVOP-Vc.js +0 -1
  176. package/dist/web/assets/ProjectKanbanPage-VFkvX9IJ.js +0 -86
  177. package/dist/web/assets/ProjectSettingsPage-BlRbxcf8.js +0 -2
  178. package/dist/web/assets/TeamSettingsPage-JaLFYXmJ.js +0 -1
  179. package/dist/web/assets/arc-Bd616RKq.js +0 -1
  180. package/dist/web/assets/channel-DJbXDmr3.js +0 -1
  181. package/dist/web/assets/check-Bj-p_n7C.js +0 -1
  182. package/dist/web/assets/chevron-down-BouKK_Vr.js +0 -1
  183. package/dist/web/assets/chevron-right-DJVYJhGF.js +0 -1
  184. package/dist/web/assets/chevron-up-CRlA9Cjl.js +0 -1
  185. package/dist/web/assets/classDiagram-4FO5ZUOK-BIz565rI.js +0 -1
  186. package/dist/web/assets/classDiagram-v2-Q7XG4LA2-BIz565rI.js +0 -1
  187. package/dist/web/assets/code-block-OCS4YCEC-wB-pkznC.js +0 -2
  188. package/dist/web/assets/cssMode-DBSRGK6o.js +0 -1
  189. package/dist/web/assets/globe-AjOch0vk.js +0 -1
  190. package/dist/web/assets/handlebars-B10IREzV.js +0 -1
  191. package/dist/web/assets/html-BpG68rDt.js +0 -1
  192. package/dist/web/assets/htmlMode-DuHt_Jpu.js +0 -1
  193. package/dist/web/assets/index-NxnivNNl.css +0 -1
  194. package/dist/web/assets/javascript-BupP80yJ.js +0 -1
  195. package/dist/web/assets/liquid-C57aZJpn.js +0 -1
  196. package/dist/web/assets/mdx-CEldzbGM.js +0 -1
  197. package/dist/web/assets/mermaid-NOHMQCX5-BsnLQ2rU.js +0 -124
  198. package/dist/web/assets/pencil-DQeFTV0j.js +0 -1
  199. package/dist/web/assets/python-B5Uu3BYh.js +0 -1
  200. package/dist/web/assets/razor-BW2eCr4L.js +0 -1
  201. package/dist/web/assets/server-Dhw531hF.js +0 -1
  202. package/dist/web/assets/stateDiagram-AJRCARHV-CJAmyasO.js +0 -1
  203. package/dist/web/assets/stateDiagram-v2-BHNVJYJU-CXOXut1l.js +0 -1
  204. package/dist/web/assets/typescript-DyiE-tjk.js +0 -1
  205. package/dist/web/assets/use-projects-CNU2P0v0.js +0 -1
  206. package/dist/web/assets/use-workspaces-C1HJqhNs.js +0 -1
  207. package/dist/web/assets/useNormalizedLogs-Bu2oXEky.js +0 -1
  208. package/dist/web/assets/xml-BNpVw2Ox.js +0 -1
  209. package/dist/web/assets/yaml-DtqgC7D8.js +0 -1
@@ -1,86 +0,0 @@
1
- const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/monaco-CirwkIGR.js","assets/index-ClhIruws.js","assets/index-NxnivNNl.css","assets/monaco-Dvl_Svmm.css"])))=>i.map(i=>d[i]);
2
- import{am as Sd,an as _o,ao as wd,ap as Cd,aq as kd,k as He,r as b,ar as de,D as ws,u as ce,j as t,$ as Ua,as as Ed,Q as Oe,l as Z,at as jd,a3 as $a,a8 as Nd,a1 as Us,B as Re,au as Ka,av as qa,aw as Va,ak as Es,X as Xt,ax as Tn,ay as Rd,P as Cr,az as Ad,E as Td,aA as Md,aB as Dd,aC as Pd,T as Ns,t as ot,V as ls,W as dt,Y as Fs,p as Ae,m as Pt,o as Lt,q as _e,a9 as Rs,U as fr,n as kr,aD as Ld,ae as Xs,aa as pi,al as Id,ag as Ya,s as $s,a7 as Tt,aj as Od,aE as Xa,aF as Mn,aG as Ga,aH as Qa,aI as Za,aJ as Ja,aK as Bd,aL as Fd,ac as zd,aM as Wd,aN as Hd,aO as Ud,a5 as yo,a6 as So}from"./index-ClhIruws.js";import{S as ut,m as Zr,u as Dn,A as Pn,o as $d,F as el,p as Kd,q as qd,r as Vd,Q as Ln,t as Yd,v as Mt,W as xt,w as tl,C as xr,x as Ur,y as Xd,z as Gd,B as Qd,T as Zd,c as Et,b as Jr,D as sl,G as Vt}from"./mermaid-NOHMQCX5-BsnLQ2rU.js";import{C as In}from"./confirm-dialog-Drhw7wmk.js";import{d as On,a as Jd,F as eu,g as rl,e as Bn,f as il,h as nl,i as Fn,j as tu,k as ol,l as zn,m as su,c as ru}from"./use-workspaces-C1HJqhNs.js";import{e as wo,f as iu,d as Wn,S as nu,u as Hn,A as br,c as Un,G as al,Z as ou,g as $n,T as Kn,h as au,i as qn,j as Co,k as lu,b as ll,l as cl,a as dl,m as ul,n as hl,R as fl,P as ml,o as ei,p as cu,C as ko,B as Eo}from"./CreateTaskInput-D_KCLZ4q.js";import{C as Nt}from"./chevron-right-DJVYJhGF.js";import{C as Wt}from"./check-Bj-p_n7C.js";import{T as gi,P as ds}from"./trash-2-DrNpNvRo.js";import{M as vi}from"./message-square-CTrwLud_.js";import{L as Ks}from"./layers-BlEewgM8.js";import{P as Vn,C as du,u as pl,a as gl,L as ti,T as si}from"./useNormalizedLogs-Bu2oXEky.js";import{a as es,l as uu,g as vl}from"./ExecutionPermissionSelector-CTeKhMaB.js";import{u as Gs}from"./use-providers-BKYsoOBU.js";import{A as xi}from"./AgentLogo-BhKP5dmt.js";import{M as Yt}from"./MemberAvatar-BuueBvLu.js";import{C as Ct}from"./chevron-down-BouKK_Vr.js";import{C as xl}from"./chevron-up-CRlA9Cjl.js";import{A as jo,G as bl}from"./globe-AjOch0vk.js";import{M as ps}from"./modal-BFDGLwoR.js";import{S as cs}from"./select-CLV6rtRD.js";import{T as hu}from"./textarea-DDy2_gLQ.js";import{S as fn,C as No}from"./server-Dhw531hF.js";import{F as Yn,e as fu,d as mu,f as pu,u as gu}from"./use-projects-CNU2P0v0.js";import{U as ri}from"./upload-D6SifUfr.js";import{P as vu}from"./pencil-DQeFTV0j.js";var xu=class extends Sd{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:_o()})}getOptimisticResult(e){return e.behavior=_o(),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:Cd(s,r.data),hasPreviousPage:wd(s,r.data),isFetchNextPageError:a,isFetchingNextPage:h,isFetchPreviousPageError:c,isFetchingPreviousPage:g,isRefetchError:i&&!a&&!c,isRefetching:m&&!h&&!g}}};function Xn(e,s){return kd(e,xu)}const bu=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],_l=He("arrow-right",bu);const _u=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],yl=He("ban",_u);const yu=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],Su=He("chevron-left",yu);const wu=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["line",{x1:"9",x2:"15",y1:"15",y2:"9",key:"1dfufj"}]],Cu=He("circle-slash",wu);const ku=[["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"}]],Eu=He("clipboard-paste",ku);const ju=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],us=He("clock-3",ju);const Nu=[["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"}]],bi=He("code-xml",Nu);const Ru=[["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"}]],Ro=He("copy-plus",Ru);const Au=[["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"}]],Tu=He("earth",Au);const Mu=[["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"}]],Sl=He("ellipsis-vertical",Mu);const Du=[["path",{d:"M2.062 12.348a1 1 0 0 1 0-.696 10.75 10.75 0 0 1 19.876 0 1 1 0 0 1 0 .696 10.75 10.75 0 0 1-19.876 0",key:"1nclc0"}],["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}]],Pu=He("eye",Du);const Lu=[["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"}]],Iu=He("file-braces-corner",Lu);const Ou=[["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"}]],ii=He("file-code-corner",Ou);const Bu=[["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"}]],Fu=He("file-exclamation-point",Bu);const zu=[["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"}]],_i=He("folder-open",zu);const Wu=[["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=He("git-graph",Wu);const Hu=[["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"}]],qs=He("history",Hu);const Uu=[["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"}]],$u=He("maximize",Uu);const Ku=[["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"}]],qu=He("panel-left-close",Ku);const Vu=[["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"}]],Yu=He("panel-left-open",Vu);const Xu=[["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"}]],Gu=He("panel-right-close",Xu);const Qu=[["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"}]],mn=He("panel-right-open",Qu);const Zu=[["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"}]],Ju=He("pen-line",Zu);const eh=[["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"}]],Cs=He("play",eh);const th=[["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"}]],wl=He("settings-2",th);const sh=[["rect",{width:"14",height:"20",x:"5",y:"2",rx:"2",ry:"2",key:"1yt0o3"}],["path",{d:"M12 18h.01",key:"mhygvu"}]],Ao=He("smartphone",sh);const rh=[["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"}]],$r=He("user-plus",rh);const ih=[["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"}]],nh=He("zoom-in",ih);const oh=[["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"}]],ah=He("zoom-out",oh),yi=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 Gn(e){return"nodeType"in e}function yt(e){var s,r;return e?Zs(e)?e:Gn(e)&&(s=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?s:window:window}function Qn(e){const{Document:s}=yt(e);return e instanceof s}function Er(e){return Zs(e)?!1:e instanceof yt(e).HTMLElement}function Cl(e){return e instanceof yt(e).SVGElement}function Js(e){return e?Zs(e)?e.document:Gn(e)?Qn(e)?e:Er(e)||Cl(e)?e.ownerDocument:document:document:document}const ts=yi?b.useLayoutEffect:b.useEffect;function Si(e){const s=b.useRef(e);return ts(()=>{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 lh(){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 _r(e,s){s===void 0&&(s=[e]);const r=b.useRef(e);return ts(()=>{r.current!==e&&(r.current=e)},s),r}function jr(e,s){const r=b.useRef();return b.useMemo(()=>{const o=e(r.current);return r.current=o,o},[...s])}function ni(e){const s=Si(e),r=b.useRef(null),o=b.useCallback(p=>{p!==r.current&&s?.(p,r.current),r.current=p},[]);return[r,o]}function oi(e){const s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}let Wi={};function wi(e,s){return b.useMemo(()=>{if(s)return s;const r=Wi[e]==null?0:Wi[e]+1;return Wi[e]=r,e+"-"+r},[e,s])}function kl(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 Hs=kl(1),ai=kl(-1);function ch(e){return"clientX"in e&&"clientY"in e}function Zn(e){if(!e)return!1;const{KeyboardEvent:s}=yt(e.target);return s&&e instanceof s}function dh(e){if(!e)return!1;const{TouchEvent:s}=yt(e.target);return s&&e instanceof s}function li(e){if(dh(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 ch(e)?{x:e.clientX,y:e.clientY}:null}const yr=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[yr.Translate.toString(e),yr.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:s,duration:r,easing:o}=e;return s+" "+r+"ms "+o}}}),To="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function uh(e){return e.matches(To)?e:e.querySelector(To)}const hh={display:"none"};function fh(e){let{id:s,value:r}=e;return de.createElement("div",{id:s,style:hh},r)}function mh(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 de.createElement("div",{id:s,style:p,role:"status","aria-live":o,"aria-atomic":!0},r)}function ph(){const[e,s]=b.useState("");return{announce:b.useCallback(o=>{o!=null&&s(o)},[]),announcement:e}}const El=b.createContext(null);function gh(e){const s=b.useContext(El);b.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(e)},[e,s])}function vh(){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 xh={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
- `},bh={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 _h(e){let{announcements:s=bh,container:r,hiddenTextDescribedById:o,screenReaderInstructions:p=xh}=e;const{announce:m,announcement:x}=ph(),i=wi("DndLiveRegion"),[n,a]=b.useState(!1);if(b.useEffect(()=>{a(!0)},[]),gh(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=de.createElement(de.Fragment,null,de.createElement(fh,{id:o,value:p.draggable}),de.createElement(mh,{id:i,announcement:x}));return r?ws.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 ci(){}function yh(e,s){return b.useMemo(()=>({sensor:e,options:s??{}}),[e,s])}function Sh(){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 wh(e,s){const r=li(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 Ch(e,s){let{data:{value:r}}=e,{data:{value:o}}=s;return o-r}function kh(e,s){if(!e||e.length===0)return null;const[r]=e;return r[s]}function Eh(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 jh=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=Eh(i,s);n>0&&p.push({id:x,data:{droppableContainer:m,value:n}})}}return p.sort(Ch)};function Nh(e,s,r){return{...e,scaleX:s&&r?s.width/r.width:1,scaleY:s&&r?s.height/r.height:1}}function jl(e,s){return e&&s?{x:e.left-s.left,y:e.top-s.top}:Ht}function Rh(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 Ah=Rh(1);function Nl(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 Th(e,s,r){const o=Nl(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 Mh={ignoreTransform:!1};function Nr(e,s){s===void 0&&(s=Mh);let r=e.getBoundingClientRect();if(s.ignoreTransform){const{transform:a,transformOrigin:h}=yt(e).getComputedStyle(e);a&&(r=Th(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 Mo(e){return Nr(e,{ignoreTransform:!0})}function Dh(e){const s=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:s,bottom:r,width:s,height:r}}function Ph(e,s){return s===void 0&&(s=yt(e).getComputedStyle(e)),s.position==="fixed"}function Lh(e,s){s===void 0&&(s=yt(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 Jn(e,s){const r=[];function o(p){if(s!=null&&r.length>=s||!p)return r;if(Qn(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!Er(p)||Cl(p)||r.includes(p))return r;const m=yt(e).getComputedStyle(p);return p!==e&&Lh(p,m)&&r.push(p),Ph(p,m)?r:o(p.parentNode)}return e?o(e):r}function Rl(e){const[s]=Jn(e,1);return s??null}function Hi(e){return!yi||!e?null:Zs(e)?e:Gn(e)?Qn(e)||e===Js(e).scrollingElement?window:Er(e)?e:null:null}function Al(e){return Zs(e)?e.scrollX:e.scrollLeft}function Tl(e){return Zs(e)?e.scrollY:e.scrollTop}function pn(e){return{x:Al(e),y:Tl(e)}}var ht;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(ht||(ht={}));function Ml(e){return!yi||!e?!1:e===document.scrollingElement}function Dl(e){const s={x:0,y:0},r=Ml(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 Ih={x:.2,y:.2};function Oh(e,s,r,o,p){let{top:m,left:x,right:i,bottom:n}=r;o===void 0&&(o=10),p===void 0&&(p=Ih);const{isTop:a,isBottom:h,isLeft:c,isRight:g}=Dl(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 Bh(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 Pl(e){return e.reduce((s,r)=>Hs(s,pn(r)),Ht)}function Fh(e){return e.reduce((s,r)=>s+Al(r),0)}function zh(e){return e.reduce((s,r)=>s+Tl(r),0)}function Ll(e,s){if(s===void 0&&(s=Nr),!e)return;const{top:r,left:o,bottom:p,right:m}=s(e);Rl(e)&&(p<=0||m<=0||r>=window.innerHeight||o>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const Wh=[["x",["left","right"],Fh],["y",["top","bottom"],zh]];class eo{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=Jn(r),p=Pl(o);this.rect={...s},this.width=s.width,this.height=s.height;for(const[m,x,i]of Wh)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 mr{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 Hh(e){const{EventTarget:s}=yt(e);return e instanceof s?e:Js(e)}function Ui(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 At;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(At||(At={}));function Do(e){e.preventDefault()}function Uh(e){e.stopPropagation()}var Ve;(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"})(Ve||(Ve={}));const Il={start:[Ve.Space,Ve.Enter],cancel:[Ve.Esc],end:[Ve.Space,Ve.Enter,Ve.Tab]},$h=(e,s)=>{let{currentCoordinates:r}=s;switch(e.code){case Ve.Right:return{...r,x:r.x+25};case Ve.Left:return{...r,x:r.x-25};case Ve.Down:return{...r,y:r.y+25};case Ve.Up:return{...r,y:r.y-25}}};class Ol{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 mr(Js(r)),this.windowListeners=new mr(yt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(At.Resize,this.handleCancel),this.windowListeners.add(At.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(At.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:s,onStart:r}=this.props,o=s.node.current;o&&Ll(o),r(Ht)}handleKeyDown(s){if(Zn(s)){const{active:r,context:o,options:p}=this.props,{keyboardCodes:m=Il,coordinateGetter:x=$h,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=ai(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}=Dl(w),E=Bh(w),y={x:Math.min(l===Ve.Right?E.right-E.width/2:E.right,Math.max(l===Ve.Right?E.left:E.left+E.width/2,c.x)),y:Math.min(l===Ve.Down?E.bottom-E.height/2:E.bottom,Math.max(l===Ve.Down?E.top:E.top+E.height/2,c.y))},j=l===Ve.Right&&!d||l===Ve.Left&&!f,A=l===Ve.Down&&!S||l===Ve.Up&&!u;if(j&&y.x!==c.x){const D=w.scrollLeft+g.x,M=l===Ve.Right&&D<=C.x||l===Ve.Left&&D>=k.x;if(M&&!g.y){w.scrollTo({left:D,behavior:i});return}M?v.x=w.scrollLeft-D:v.x=l===Ve.Right?w.scrollLeft-C.x:w.scrollLeft-k.x,v.x&&w.scrollBy({left:-v.x,behavior:i});break}else if(A&&y.y!==c.y){const D=w.scrollTop+g.y,M=l===Ve.Down&&D<=C.y||l===Ve.Up&&D>=k.y;if(M&&!g.x){w.scrollTo({top:D,behavior:i});return}M?v.y=w.scrollTop-D:v.y=l===Ve.Down?w.scrollTop-C.y:w.scrollTop-k.y,v.y&&w.scrollBy({top:-v.y,behavior:i});break}}this.handleMove(s,Hs(ai(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()}}Ol.activators=[{eventName:"onKeyDown",handler:(e,s,r)=>{let{keyboardCodes:o=Il,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 Po(e){return!!(e&&"distance"in e)}function Lo(e){return!!(e&&"delay"in e)}class to{constructor(s,r,o){var p;o===void 0&&(o=Hh(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 mr(this.document),this.listeners=new mr(o),this.windowListeners=new mr(yt(x)),this.initialCoordinates=(p=li(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(At.Resize,this.handleCancel),this.windowListeners.add(At.DragStart,Do),this.windowListeners.add(At.VisibilityChange,this.handleCancel),this.windowListeners.add(At.ContextMenu,Do),this.documentListeners.add(At.Keydown,this.handleKeydown),r){if(o!=null&&o({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(Lo(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(Po(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(At.Click,Uh,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(At.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=li(s))!=null?r:Ht,a=ai(p,n);if(!o&&i){if(Po(i)){if(i.tolerance!=null&&Ui(a,i.tolerance))return this.handleCancel();if(Ui(a,i.distance))return this.handleStart()}if(Lo(i)&&Ui(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===Ve.Esc&&this.handleCancel()}removeTextSelection(){var s;(s=this.document.getSelection())==null||s.removeAllRanges()}}const Kh={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class so extends to{constructor(s){const{event:r}=s,o=Js(r.target);super(s,Kh,o)}}so.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 qh={move:{name:"mousemove"},end:{name:"mouseup"}};var gn;(function(e){e[e.RightClick=2]="RightClick"})(gn||(gn={}));class Vh extends to{constructor(s){super(s,qh,Js(s.event.target))}}Vh.activators=[{eventName:"onMouseDown",handler:(e,s)=>{let{nativeEvent:r}=e,{onActivation:o}=s;return r.button===gn.RightClick?!1:(o?.({event:r}),!0)}}];const $i={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Yh extends to{constructor(s){super(s,$i)}static setup(){return window.addEventListener($i.move.name,s,{capture:!1,passive:!1}),function(){window.removeEventListener($i.move.name,s)};function s(){}}}Yh.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 pr;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(pr||(pr={}));var di;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(di||(di={}));function Xh(e){let{acceleration:s,activator:r=pr.Pointer,canScroll:o,draggingRect:p,enabled:m,interval:x=5,order:i=di.TreeOrder,pointerCoordinates:n,scrollableAncestors:a,scrollableAncestorRects:h,delta:c,threshold:g}=e;const v=Qh({delta:c,disabled:!m}),[_,w]=lh(),l=b.useRef({x:0,y:0}),u=b.useRef({x:0,y:0}),d=b.useMemo(()=>{switch(r){case pr.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case pr.DraggableRect:return p}},[r,p,n]),f=b.useRef(null),S=b.useCallback(()=>{const k=f.current;if(!k)return;const E=l.current.x*u.current.x,y=l.current.y*u.current.y;k.scrollBy(E,y)},[]),C=b.useMemo(()=>i===di.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 E=a.indexOf(k),y=h[E];if(!y)continue;const{direction:j,speed:A}=Oh(k,y,d,s,g);for(const D of["x","y"])v[D][j[D]]||(A[D]=0,j[D]=0);if(A.x>0||A.y>0){w(),f.current=k,_(S,x),l.current=A,u.current=j;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 Gh={x:{[ht.Backward]:!1,[ht.Forward]:!1},y:{[ht.Backward]:!1,[ht.Forward]:!1}};function Qh(e){let{delta:s,disabled:r}=e;const o=oi(s);return jr(p=>{if(r||!o||!p)return Gh;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 Zh(e,s){const r=s!=null?e.get(s):void 0,o=r?r.node.current:null;return jr(p=>{var m;return s==null?null:(m=o??p)!=null?m:null},[o,s])}function Jh(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 Sr;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(Sr||(Sr={}));var vn;(function(e){e.Optimized="optimized"})(vn||(vn={}));const Io=new Map;function ef(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=_r(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=jr(u=>{if(c&&!r)return Io;if(!u||u===Io||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 eo(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 Sr.Always:return!1;case Sr.BeforeDragging:return r;default:return!r}}}function ro(e,s){return jr(r=>e?r||(typeof s=="function"?s(e):e):null,[s,e])}function tf(e,s){return ro(e,s)}function sf(e){let{callback:s,disabled:r}=e;const o=Si(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 Ci(e){let{callback:s,disabled:r}=e;const o=Si(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 rf(e){return new eo(Nr(e),e)}function Oo(e,s,r){s===void 0&&(s=rf);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=sf({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=Ci({callback:m});return ts(()=>{m(),e?(i?.observe(e),x?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),x?.disconnect())},[e]),o}function nf(e){const s=ro(e);return jl(e,s)}const Bo=[];function of(e){const s=b.useRef(e),r=jr(o=>e?o&&o!==Bo&&e&&s.current&&e.parentNode===s.current.parentNode?o:Jn(e):Bo,[e]);return b.useEffect(()=>{s.current=e},[e]),r}function af(e){const[s,r]=b.useState(null),o=b.useRef(e),p=b.useCallback(m=>{const x=Hi(m.target);x&&r(i=>i?(i.set(x,pn(x)),new Map(i)):null)},[]);return b.useEffect(()=>{const m=o.current;if(e!==m){x(m);const i=e.map(n=>{const a=Hi(n);return a?(a.addEventListener("scroll",p,{passive:!0}),[a,pn(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=Hi(n);a?.removeEventListener("scroll",p)})}},[p,e]),b.useMemo(()=>e.length?s?Array.from(s.values()).reduce((m,x)=>Hs(m,x),Ht):Pl(e):Ht,[e,s])}function Fo(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?ai(e,r.current):Ht}function lf(e){b.useEffect(()=>{if(!yi)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 cf(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 Bl(e){return b.useMemo(()=>e?Dh(e):null,[e])}const zo=[];function df(e,s){s===void 0&&(s=Nr);const[r]=e,o=Bl(r?yt(r):null),[p,m]=b.useState(zo);function x(){m(()=>e.length?e.map(n=>Ml(n)?o:new eo(s(n),n)):zo)}const i=Ci({callback:x});return ts(()=>{i?.disconnect(),x(),e.forEach(n=>i?.observe(n))},[e]),p}function Fl(e){if(!e)return null;if(e.children.length>1)return e;const s=e.children[0];return Er(s)?s:e}function uf(e){let{measure:s}=e;const[r,o]=b.useState(null),p=b.useCallback(a=>{for(const{target:h}of a)if(Er(h)){o(c=>{const g=s(h);return c?{...c,width:g.width,height:g.height}:g});break}},[s]),m=Ci({callback:p}),x=b.useCallback(a=>{const h=Fl(a);m?.disconnect(),h&&m?.observe(h),o(h?s(h):null)},[s,m]),[i,n]=ni(x);return b.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const hf=[{sensor:so,options:{}},{sensor:Ol,options:{}}],ff={current:{}},Gr={draggable:{measure:Mo},droppable:{measure:Mo,strategy:Sr.WhileDragging,frequency:vn.Optimized},dragOverlay:{measure:Nr}};class gr 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 mf={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new gr,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:ci},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Gr,measureDroppableContainers:ci,windowRect:null,measuringScheduled:!1},zl={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:ci,draggableNodes:new Map,over:null,measureDroppableContainers:ci},Rr=b.createContext(zl),Wl=b.createContext(mf);function pf(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new gr}}}function gf(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 gr(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 gr(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 gr(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function vf(e){let{disabled:s}=e;const{active:r,activatorEvent:o,draggableNodes:p}=b.useContext(Rr),m=oi(o),x=oi(r?.id);return b.useEffect(()=>{if(!s&&!o&&m&&x!=null){if(!Zn(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=uh(h);if(c){c.focus();break}}})}},[o,s,p,x,m]),null}function Hl(e,s){let{transform:r,...o}=s;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...o}),r):r}function xf(e){return b.useMemo(()=>({draggable:{...Gr.draggable,...e?.draggable},droppable:{...Gr.droppable,...e?.droppable},dragOverlay:{...Gr.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function bf(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;ts(()=>{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=jl(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=Rl(a);g&&g.scrollBy({top:c.y,left:c.x})}},[s,x,i,o,r])}const ki=b.createContext({...Ht,scaleX:1,scaleY:1});var as;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(as||(as={}));const _f=b.memo(function(s){var r,o,p,m;let{id:x,accessibility:i,autoScroll:n=!0,children:a,sensors:h=hf,collisionDetection:c=jh,measuring:g,modifiers:v,..._}=s;const w=b.useReducer(gf,void 0,pf),[l,u]=w,[d,f]=vh(),[S,C]=b.useState(as.Uninitialized),k=S===as.Initialized,{draggable:{active:E,nodes:y,translate:j},droppable:{containers:A}}=l,D=E!=null?y.get(E):null,M=b.useRef({initial:null,translated:null}),P=b.useMemo(()=>{var te;return E!=null?{id:E,data:(te=D?.data)!=null?te:ff,rect:M}:null},[E,D]),z=b.useRef(null),[L,W]=b.useState(null),[$,R]=b.useState(null),I=_r(_,Object.values(_)),T=wi("DndDescribedBy",x),O=b.useMemo(()=>A.getEnabled(),[A]),q=xf(g),{droppableRects:V,measureDroppableContainers:B,measuringScheduled:U}=ef(O,{dragging:k,dependencies:[j.x,j.y],config:q.droppable}),H=Zh(y,E),N=b.useMemo(()=>$?li($):null,[$]),F=X(),K=tf(H,q.draggable.measure);bf({activeNode:E!=null?y.get(E):null,config:F.layoutShiftCompensation,initialRect:K,measure:q.draggable.measure});const Y=Oo(H,q.draggable.measure,K),se=Oo(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:A,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),me=A.getNodeFor((r=G.current.over)==null?void 0:r.id),ue=uf({measure:q.dragOverlay.measure}),re=(o=ue.nodeRef.current)!=null?o:H,ne=k?(p=ue.rect)!=null?p:Y:null,le=!!(ue.nodeRef.current&&ue.rect),ye=nf(le?null:Y),We=Bl(re?yt(re):null),ke=of(k?me??H:null),Ue=df(ke),at=Hl(v,{transform:{x:j.x-ye.x,y:j.y-ye.y,scaleX:1,scaleY:1},activatorEvent:$,active:P,activeNodeRect:Y,containerNodeRect:se,draggingNodeRect:ne,over:G.current.over,overlayNodeRect:ue.rect,scrollableAncestors:ke,scrollableAncestorRects:Ue,windowRect:We}),Me=N?Hs(N,j):null,je=af(ke),Be=Fo(je),Ke=Fo(je,[Y]),qe=Hs(at,Be),De=ne?Ah(ne,at):null,Ge=P&&De?c({active:P,collisionRect:De,droppableRects:V,droppableContainers:O,pointerCoordinates:Me}):null,Qe=kh(Ge,"id"),[Te,pe]=b.useState(null),et=le?at:Hs(at,Ke),Xe=Nh(et,(m=Te?.rect)!=null?m:null,Y),$e=b.useRef(null),ft=b.useCallback((te,ie)=>{let{sensor:ae,options:we}=ie;if(z.current==null)return;const Ce=y.get(z.current);if(!Ce)return;const Pe=te.nativeEvent,Je=new ae({active:z.current,activeNode:Ce,event:Pe,options:we,context:G,onAbort(xe){if(!y.get(xe))return;const{onDragAbort:Fe}=I.current,st={id:xe};Fe?.(st),d({type:"onDragAbort",event:st})},onPending(xe,fe,Fe,st){if(!y.get(xe))return;const{onDragPending:kt}=I.current,St={id:xe,constraint:fe,initialCoordinates:Fe,offset:st};kt?.(St),d({type:"onDragPending",event:St})},onStart(xe){const fe=z.current;if(fe==null)return;const Fe=y.get(fe);if(!Fe)return;const{onDragStart:st}=I.current,lt={activatorEvent:Pe,active:{id:fe,data:Fe.data,rect:M}};ws.unstable_batchedUpdates(()=>{st?.(lt),C(as.Initializing),u({type:ct.DragStart,initialCoordinates:xe,active:fe}),d({type:"onDragStart",event:lt}),W($e.current),R(Pe)})},onMove(xe){u({type:ct.DragMove,coordinates:xe})},onEnd:be(ct.DragEnd),onCancel:be(ct.DragCancel)});$e.current=Je;function be(xe){return async function(){const{active:Fe,collisions:st,over:lt,scrollAdjustedTranslate:kt}=G.current;let St=null;if(Fe&&kt){const{cancelDrop:vt}=I.current;St={activatorEvent:Pe,active:Fe,collisions:st,delta:kt,over:lt},xe===ct.DragEnd&&typeof vt=="function"&&await Promise.resolve(vt(St))&&(xe=ct.DragCancel)}z.current=null,ws.unstable_batchedUpdates(()=>{u({type:xe}),C(as.Uninitialized),pe(null),W(null),R(null),$e.current=null;const vt=xe===ct.DragEnd?"onDragEnd":"onDragCancel";if(St){const It=I.current[vt];It?.(St),d({type:vt,event:St})}})}}},[y]),tt=b.useCallback((te,ie)=>(ae,we)=>{const Ce=ae.nativeEvent,Pe=y.get(we);if(z.current!==null||!Pe||Ce.dndKit||Ce.defaultPrevented)return;const Je={active:Pe};te(ae,ie.options,Je)===!0&&(Ce.dndKit={capturedBy:ie.sensor},z.current=we,ft(ae,ie))},[y,ft]),ee=Jh(h,tt);lf(h),ts(()=>{Y&&S===as.Initializing&&C(as.Initialized)},[Y,S]),b.useEffect(()=>{const{onDragMove:te}=I.current,{active:ie,activatorEvent:ae,collisions:we,over:Ce}=G.current;if(!ie||!ae)return;const Pe={active:ie,activatorEvent:ae,collisions:we,delta:{x:qe.x,y:qe.y},over:Ce};ws.unstable_batchedUpdates(()=>{te?.(Pe),d({type:"onDragMove",event:Pe})})},[qe.x,qe.y]),b.useEffect(()=>{const{active:te,activatorEvent:ie,collisions:ae,droppableContainers:we,scrollAdjustedTranslate:Ce}=G.current;if(!te||z.current==null||!ie||!Ce)return;const{onDragOver:Pe}=I.current,Je=we.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:Ce.x,y:Ce.y},over:be};ws.unstable_batchedUpdates(()=>{pe(be),Pe?.(xe),d({type:"onDragOver",event:xe})})},[Qe]),ts(()=>{G.current={activatorEvent:$,active:P,activeNode:H,collisionRect:De,collisions:Ge,droppableRects:V,draggableNodes:y,draggingNode:re,draggingNodeRect:ne,droppableContainers:A,over:Te,scrollableAncestors:ke,scrollAdjustedTranslate:qe},M.current={initial:ne,translated:De}},[P,H,Ge,De,y,re,ne,V,A,Te,ke,qe]),Xh({...F,delta:j,draggingRect:De,pointerCoordinates:Me,scrollableAncestors:ke,scrollableAncestorRects:Ue});const he=b.useMemo(()=>({active:P,activeNode:H,activeNodeRect:Y,activatorEvent:$,collisions:Ge,containerNodeRect:se,dragOverlay:ue,draggableNodes:y,droppableContainers:A,droppableRects:V,over:Te,measureDroppableContainers:B,scrollableAncestors:ke,scrollableAncestorRects:Ue,measuringConfiguration:q,measuringScheduled:U,windowRect:We}),[P,H,Y,$,Ge,se,ue,y,A,V,Te,B,ke,Ue,q,U,We]),Se=b.useMemo(()=>({activatorEvent:$,activators:ee,active:P,activeNodeRect:Y,ariaDescribedById:{draggable:T},dispatch:u,draggableNodes:y,over:Te,measureDroppableContainers:B}),[$,ee,P,Y,u,T,y,Te,B]);return de.createElement(El.Provider,{value:f},de.createElement(Rr.Provider,{value:Se},de.createElement(Wl.Provider,{value:he},de.createElement(ki.Provider,{value:Xe},a)),de.createElement(vf,{disabled:i?.restoreFocus===!1})),de.createElement(_h,{...i,hiddenTextDescribedById:T}));function X(){const te=L?.autoScrollEnabled===!1,ie=typeof n=="object"?n.enabled===!1:n===!1,ae=k&&!te&&!ie;return typeof n=="object"?{...n,enabled:ae}:{enabled:ae}}}),yf=b.createContext(null),Wo="button",Sf="Draggable";function wf(e){let{id:s,data:r,disabled:o=!1,attributes:p}=e;const m=wi(Sf),{activators:x,activatorEvent:i,active:n,activeNodeRect:a,ariaDescribedById:h,draggableNodes:c,over:g}=b.useContext(Rr),{role:v=Wo,roleDescription:_="draggable",tabIndex:w=0}=p??{},l=n?.id===s,u=b.useContext(l?ki:yf),[d,f]=ni(),[S,C]=ni(),k=cf(x,s),E=_r(r);ts(()=>(c.set(s,{id:s,key:m,node:d,activatorNode:S,data:E}),()=>{const j=c.get(s);j&&j.key===m&&c.delete(s)}),[c,s]);const y=b.useMemo(()=>({role:v,tabIndex:w,"aria-disabled":o,"aria-pressed":l&&v===Wo?!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 Cf(){return b.useContext(Wl)}const kf="Droppable",Ef={timeout:25};function jf(e){let{data:s,disabled:r=!1,id:o,resizeObserverConfig:p}=e;const m=wi(kf),{active:x,dispatch:i,over:n,measureDroppableContainers:a}=b.useContext(Rr),h=b.useRef({disabled:r}),c=b.useRef(!1),g=b.useRef(null),v=b.useRef(null),{disabled:_,updateMeasurementsFor:w,timeout:l}={...Ef,...p},u=_r(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=Ci({callback:d,disabled:_||!x}),S=b.useCallback((y,j)=>{f&&(j&&(f.unobserve(j),c.current=!1),y&&f.observe(y))},[f]),[C,k]=ni(S),E=_r(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:E}}),()=>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 Nf(e){let{animation:s,children:r}=e;const[o,p]=b.useState(null),[m,x]=b.useState(null),i=oi(r);return!r&&!o&&i&&p(i),ts(()=>{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]),de.createElement(de.Fragment,null,r,o?b.cloneElement(o,{ref:x}):null)}const Rf={x:0,y:0,scaleX:1,scaleY:1};function Af(e){let{children:s}=e;return de.createElement(Rr.Provider,{value:zl},de.createElement(ki.Provider,{value:Rf},s))}const Tf={position:"fixed",touchAction:"none"},Mf=e=>Zn(e)?"transform 250ms ease":void 0,Df=b.forwardRef((e,s)=>{let{as:r,activatorEvent:o,adjustScale:p,children:m,className:x,rect:i,style:n,transform:a,transition:h=Mf}=e;if(!i)return null;const c=p?a:{...a,scaleX:1,scaleY:1},g={...Tf,width:i.width,height:i.height,top:i.top,left:i.left,transform:yr.Transform.toString(c),transformOrigin:p&&o?wh(o,i):void 0,transition:typeof h=="function"?h(o):h,...n};return de.createElement(r,{className:x,style:g,ref:s},m)}),Pf=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)}},Lf=e=>{let{transform:{initial:s,final:r}}=e;return[{transform:yr.Transform.toString(s)},{transform:yr.Transform.toString(r)}]},If={duration:250,easing:"ease",keyframes:Lf,sideEffects:Pf({styles:{active:{opacity:"0"}}})};function Of(e){let{config:s,draggableNodes:r,droppableContainers:o,measuringConfiguration:p}=e;return Si((m,x)=>{if(s===null)return;const i=r.get(m);if(!i)return;const n=i.node.current;if(!n)return;const a=Fl(x);if(!a)return;const{transform:h}=yt(x).getComputedStyle(x),c=Nl(h);if(!c)return;const g=typeof s=="function"?s:Bf(s);return Ll(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 Bf(e){const{duration:s,easing:r,sideEffects:o,keyframes:p}={...If,...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 Ho=0;function Ff(e){return b.useMemo(()=>{if(e!=null)return Ho++,Ho},[e])}const zf=de.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}=Cf(),k=b.useContext(ki),E=Ff(c?.id),y=Hl(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}),j=ro(g),A=Of({config:o,draggableNodes:_,droppableContainers:w,measuringConfiguration:d}),D=j?l.setRef:void 0;return de.createElement(Af,null,de.createElement(Nf,{animation:A},c&&E?de.createElement(Df,{key:E,id:c.id,ref:D,as:i,activatorEvent:h,adjustScale:s,className:n,transition:m,rect:j,style:{zIndex:a,...p},transform:y},r):null))}),Ul=768;function Wf(e){const s=window.matchMedia(`(max-width: ${Ul-1}px)`);return s.addEventListener("change",e),()=>s.removeEventListener("change",e)}function Hf(){return window.innerWidth<Ul}function Uf(){return!1}function $l(){return b.useSyncExternalStore(Wf,Hf,Uf)}function $f(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 io({isOpen:e,onClose:s,onConfirm:r,taskId:o,taskTitle:p,workspaces:m,isLoading:x}){const{t:i}=ce(),{data:n,isLoading:a}=On(m===void 0&&e?o:""),h=m??n,c=m===void 0&&e&&a,g=b.useMemo(()=>$f(h,i),[h,i]);return t.jsx(In,{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 ve={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Vs={[ve.Review]:{label:"Review",icon:Pu,iconClass:"text-warning",accentClass:"text-warning",titleClass:"font-semibold text-foreground"},[ve.Running]:{label:"Running",icon:Oe,iconClass:"text-info",accentClass:"text-info",titleClass:"task-title-running"},[ve.Pending]:{label:"Pending",icon:Ed,iconClass:"text-muted-foreground",accentClass:"text-muted-foreground",titleClass:""},[ve.Done]:{label:"Done",icon:Ua,iconClass:"text-success/80",accentClass:"text-success",titleClass:"text-muted-foreground"},[ve.Cancelled]:{label:"Cancelled",icon:Cu,iconClass:"text-muted-foreground/70",accentClass:"text-muted-foreground/70",titleClass:"text-muted-foreground"}},Kf=[ve.Review,ve.Running,ve.Pending,ve.Done,ve.Cancelled],qf="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",Vf="h-8 pointer-coarse:h-10";function ur(e){return Z(qf,Vf,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 Kl=b.createContext(null),Yf=3e4;function Xf(e=Yf){const[,s]=b.useState(0);b.useEffect(()=>{const r=setInterval(()=>s(o=>o+1),e);return()=>clearInterval(r)},[e])}const xn=60,bn=60*xn,Ki=24*bn;function Gf(e,s,r){const o=new Date(e),p=Math.max(0,Math.floor((Date.now()-o.getTime())/1e3));if(p<xn)return s("now");if(p<bn)return s("{count}m",{count:Math.floor(p/xn)});if(p<Ki)return s("{count}h",{count:Math.floor(p/bn)});if(p<7*Ki)return s("{count}d",{count:Math.floor(p/Ki)});const m=o.getFullYear()===new Date().getFullYear();return o.toLocaleDateString(r,m?{month:"numeric",day:"numeric"}:{year:"numeric",month:"numeric"})}function Qf(e){const s=jd(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",Uo="px-2 pb-1 pt-1.5 text-[11px] font-medium text-muted-foreground",$o=t.jsx("div",{className:"-mx-1 my-1 h-px bg-border/60"});function Zf({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}=ce(),g=b.useContext(Kl),v=b.useRef(null),_=!!e.projectArchivedAt,w=_||!!a,{attributes:l,listeners:u,setNodeRef:d,isDragging:f}=wf({id:e.id,data:{task:e,fromStatus:s},disabled:w}),S=b.useCallback(R=>{v.current=R,d(R),g&&(R?g.registry.set(e.id,R):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),[E,y]=b.useState(!1),j=b.useRef(null),A=b.useRef(null),D=b.useCallback(R=>{_||!x&&!i&&!n||(R.preventDefault(),k({x:R.clientX,y:R.clientY}))},[_,x,i,n]),M=b.useCallback(()=>{A.current&&(clearTimeout(A.current),A.current=null)},[]),P=b.useCallback(R=>{if(!a||_||!x&&!i)return;const I=R.touches[0];if(!I)return;const{clientX:T,clientY:O}=I;A.current=setTimeout(()=>{A.current=null,k({x:T,y:O})},500)},[a,_,x,i]);b.useEffect(()=>{if(!C)return;const R=()=>k(null),I=O=>{j.current&&!j.current.contains(O.target)&&R()},T=O=>{O.key==="Escape"&&R()};return document.addEventListener("mousedown",I),document.addEventListener("touchstart",I),document.addEventListener("keydown",T),window.addEventListener("scroll",R,!0),window.addEventListener("resize",R),()=>{document.removeEventListener("mousedown",I),document.removeEventListener("touchstart",I),document.removeEventListener("keydown",T),window.removeEventListener("scroll",R,!0),window.removeEventListener("resize",R)}},[C]),b.useLayoutEffect(()=>{const R=j.current;if(!C||!R)return;const I=8;R.style.left=`${Math.max(I,Math.min(C.x,window.innerWidth-R.offsetWidth-I))}px`,R.style.top=`${Math.max(I,Math.min(C.y,window.innerHeight-R.offsetHeight-I))}px`},[C]);const z=o?o.name:void 0,L=p?o:void 0,W=e.updatedAt?Gf(e.updatedAt,h,c):null,{titleClass:$}=Vs[s];return t.jsxs(t.Fragment,{children:[t.jsxs("button",{ref:S,type:"button",onClick:()=>m(e.id),onContextMenu:D,onTouchStart:P,onTouchEnd:M,onTouchMove:M,title:L?`${e.title} · ${L.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",ur(r),f&&"opacity-30"),...w?{}:u,...w?{}:l,children:[t.jsx("span",{className:Z("min-w-0 flex-1 truncate",$),children:e.title}),e.priority!==void 0&&e.priority!==Zr.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||L)&&t.jsx("span",{className:"task-row-meta",children:t.jsxs("span",{className:"flex items-center gap-1",children:[L&&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(L.color,"bg-[linear-gradient(90deg,currentColor_0.6em,var(--muted-foreground)_2.6em)] bg-clip-text [-webkit-text-fill-color:transparent]"),children:Qf(L.name)})}),W&&t.jsx("span",{className:"shrink-0 text-[11px] tabular-nums text-muted-foreground",children:W})]})})]}),C&&t.jsxs("div",{ref:j,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:Uo,children:h("Move to")}),Kf.filter(R=>R!==s).map(R=>{const{icon:I,label:T,accentClass:O}=Vs[R];return t.jsxs("button",{type:"button",role:"menuitem",onClick:()=>{x(e.id,R),k(null)},className:qi,children:[t.jsx(I,{className:Z("size-3.5 shrink-0",O)}),t.jsx("span",{children:h(T)})]},R)})]}),n&&t.jsxs(t.Fragment,{children:[x&&$o,t.jsx("div",{className:Uo,children:h("Priority")}),iu.map(R=>{const I=(e.priority??Zr.NORMAL)===R.value;return t.jsxs("button",{type:"button",role:"menuitemradio","aria-checked":I,onClick:()=>{n(e.id,R.value),k(null)},className:qi,children:[t.jsx(wo,{priority:R.value}),t.jsx("span",{className:"flex-1",children:h(R.label)}),I&&t.jsx(Wt,{className:"size-3.5 shrink-0 text-foreground","aria-hidden":!0})]},R.value)})]}),i&&t.jsxs(t.Fragment,{children:[(x||n)&&$o,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(gi,{className:"size-3.5 shrink-0","aria-hidden":!0}),t.jsx("span",{children:h("Delete Task")})]})]})]}),t.jsx(io,{isOpen:E,onClose:()=>y(!1),onConfirm:()=>{i?.(e.id),y(!1)},taskId:e.id,taskTitle:e.title})]})}const Jf=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}=ce(),[l,u]=b.useState(p);Xf();const d=r.length===0,f=a&&h===o,S=a&&h!==o,{setNodeRef:C,isOver:k}=jf({id:`group-${o}`,data:{status:o}}),E=o===ve.Review,y=w(s),{icon:j,accentClass:A}=Vs[o],D=b.useId(),M=a?f:l,P=M&&!S&&!d;return t.jsxs("div",{className:P?"mb-4":"mb-2","data-task-group-status":o,children:[t.jsx("div",{className:"sticky top-0 z-10 bg-sidebar px-2",children:t.jsxs("button",{type:"button",onClick:()=>!a&&u(z=>!z),"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(j,{className:Z("mr-0.5 size-3.5 shrink-0",A)}),t.jsx("span",{id:D,className:"truncate",children:y}),t.jsx(Nt,{size:12,"aria-hidden":!0,className:Z("shrink-0 text-muted-foreground/60 transition-transform duration-150 group-hover/header:text-muted-foreground",M&&"rotate-90")}),E&&!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")}),P&&t.jsx("div",{ref:f?void 0:C,role:"group","aria-labelledby":D,className:"mt-0.5 flex flex-col gap-px px-2",children:r.map(z=>{const L=m===z.id,W=z.projectId?i.find($=>$.id===z.projectId):void 0;return t.jsx(Zf,{task:z,status:o,isSelected:L,project:W,showProject:n,onSelectTask:x,onTaskStatusChange:z.projectArchivedAt?void 0:c,onDeleteTask:z.projectArchivedAt?void 0:g,onTaskPriorityChange:z.projectArchivedAt?void 0:v,disableDrag:_},z.id)})})]})}),em=12,tm=50;function sm({isOpen:e,onClose:s,tasks:r,projects:o,onSelectTask:p}){const{t:m}=ce(),[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,tm):r.slice(0,em)},[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(Wn,{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}=Vs[_.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} size-4 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 rm=260,im=220;function nm(e){const s={[ve.Review]:[],[ve.Running]:[],[ve.Pending]:[],[ve.Done]:[],[ve.Cancelled]:[]};for(const r of e)s[r.status].push(r);return s[ve.Review].sort((r,o)=>(o.priority??Zr.NORMAL)-(r.priority??Zr.NORMAL)),s}const om=[{status:ve.Review,title:"Review",defaultOpen:!0},{status:ve.Running,title:"Running",defaultOpen:!0},{status:ve.Pending,title:"Pending",defaultOpen:!1},{status:ve.Done,title:"Done",defaultOpen:!1},{status:ve.Cancelled,title:"Cancelled",defaultOpen:!1}];function am(){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-4",children:[t.jsxs("div",{className:"flex h-7 items-center gap-1.5 px-2",children:[t.jsx("div",{className:"size-3.5 shrink-0 rounded-full bg-foreground/[0.06]"}),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:"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 Ko({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:_}=ce(),{preserveDesktopSearch:w}=$a(),l=$l(),[u,d]=b.useState(null),[f,S]=b.useState(null),[C,k]=b.useState(!1),E=b.useRef(new Map),y=b.useRef(new Set),j=b.useRef(new Map),A=b.useMemo(()=>({registry:E.current}),[]),D=b.useCallback(B=>{B.remove(),y.current.delete(B)},[]),M=p?e.filter(B=>B.projectId===p):e,P=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 K=F.firstElementChild;K&&(K.style.cssText="",K.className=K.className.replace(/\bopacity-\S*/g,"").replace(/\banimate-task-enter\b/g,""),K.style.pointerEvents="none",K.style.width=`${B.width}px`,K.style.height=`${B.height}px`,K.style.margin="0",K.style.backgroundColor="var(--background)",K.style.borderRadius="0.5rem",K.style.boxShadow="0 4px 6px rgba(0, 0, 0, 0.08), 0 0 0 1px var(--border)",K.style.opacity="0.96",K.style.transition="none",K.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?im:rm,easing:"cubic-bezier(0.2, 0, 0, 1)",fill:"forwards"}).finished.then(()=>D(F),()=>D(F))},[D]);b.useLayoutEffect(()=>{const B=window.matchMedia("(prefers-reduced-motion: reduce)").matches,U=new Map;for(const H of M){const N=E.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 K=j.current.get(H.id);if(!K||K.status===H.status)continue;const Y=F.rect.left-K.rect.left,se=F.rect.top-K.rect.top;Math.abs(Y)<1&&Math.abs(se)<1||z(K.rect,F.rect,K.html)}if(!B)for(const[H,N]of j.current){if(U.has(H))continue;const F=M.find(Y=>Y.id===H);if(!F||F.status===N.status)continue;const K=P(F.status,N.rect);K&&z(N.rect,K,N.html,!0)}j.current=U},[M,z,P]),b.useEffect(()=>()=>{for(const B of y.current)B.remove();y.current.clear()},[]);const L=Sh(yh(so,{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,K=H.data.current?.status;!N||!F||!K||N.projectArchivedAt||F!==K&&h?.(N.id,K)},[h]),T=!!!(p?s.find(B=>B.id===p)??null:null)?.archivedAt,O=nm(M),q=u?Vs[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:ur(!1),children:[t.jsx(Jd,{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(ur(!!a),"disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:bg-transparent"),title:T?void 0:_("Deleted projects are read-only"),children:[t.jsx(nu,{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:ur(!1),children:[t.jsx(Wn,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",children:_("Search")})]}),t.jsxs(Nd,{to:w("/conversations"),"data-sidebar-item":"",className:ur(!1),children:[t.jsx(vi,{size:16,className:"shrink-0 text-muted-foreground"}),t.jsx("span",{className:"truncate",children:_("对话")})]})]}),v?t.jsx(am,{}):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(Ks,{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(Kl.Provider,{value:A,children:t.jsxs(_f,{sensors:L,onDragStart:W,onDragEnd:$,children:[t.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin scroll-pt-8 relative",children:t.jsx("div",{className:"pt-3 pb-4",children:om.map(({status:B,title:U,defaultOpen:H})=>t.jsx(Jf,{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(zf,{dropAnimation:null,children:u&&q?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(q.icon,{className:Z("size-4 shrink-0",q.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(sm,{isOpen:C,onClose:()=>k(!1),tasks:M,projects:s,onSelectTask:o})]})}const lm=10,cm=24,ql=lm*cm,dm=8;function um(e,s=ql){return e>s+dm}function hm(e,s){return e.includes(s)?e:[...e,s]}function fm(e,s){return e.filter(r=>r!==s)}function mm(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 Ei=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 pm(e,s=[],r=[]){const o=new Set(r.filter(m=>Ei.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 gm(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 vm(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 xm(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 bm(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function _m({status:e}){const{t:s}=ce();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(gm(e))})}function ym({invocations:e,memberById:s,workRequestById:r,onViewInvocationSession:o,onStopMember:p,isStopPending:m,stoppingMemberId:x,stopPromptInvocationId:i,onToggleStopConfirm:n}){const{t:a}=ce(),[h,c]=b.useState(bm),g=b.useMemo(()=>e.filter(_=>Ei.has(_.status)).sort((_,w)=>Date.parse(w.updatedAt??w.createdAt??"")-Date.parse(_.updatedAt??_.createdAt??"")),[e]);if(g.length===0)return null;const v=xm(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(Ct,{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(Yt,{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",vm(_.status)),children:t.jsx(_m,{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(mn,{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(Us,{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(Re,{type:"button",size:"xs",variant:"outline",disabled:S,onClick:()=>p(w.id,!1),children:[t.jsx(Us,{size:11}),t.jsx("span",{children:a(S?"Stopping":"Stop only")})]}),t.jsxs(Re,{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(yl,{size:11}),t.jsx("span",{children:a(S?"Stopping":"Stop + clear queue")})]})]})]},_.id)})})]})}const _n=Cr(),Sm=240;let Vo=0;function wm(e,s){return Vo+=1,{id:`pending-room-message-${Date.now()}-${Vo}`,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 Vl(e){return"pendingStatus"in e}function Cm(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function km(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function yn(e,s){if(s.length===0)return e;const r=new Set(s.map(km));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 Em(e){if(!e)return"";const s=new Date(e);return Number.isNaN(s.getTime())?"":s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Sn(e,s){return e instanceof Error?e.message:s}function jm(e,s=Sm){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Nm(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 Rm(e,s){const r=s.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function Yo(e){return e.membershipStatus!=="REMOVED"}function Am(e,s){return e.label??s.get(e.memberId)?.name??e.memberId}function Tm(e,s){return(e.recipientMemberIds??[]).map(r=>s.get(r)?.name??r)}function Mm(e,s){const r=e.mentions??[],o=e.contentPreview??e.content;if(r.length===0)return o;const p=r.map(x=>Am(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 Dm(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 Pm({content:e,isUser:s,workingDir:r,onOpenWorkspaceFile:o,onOpenPreviewUrl:p,onOpenVisualization:m,downloadSessionId:x}){const i=b.useMemo(()=>m||x?Kd(e):e,[e,x,m]),n=qd(i),a=b.useMemo(()=>Vd({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(Ln,{components:a,plugins:n,controls:n?Yd:void 0,children:i})})}function Lm({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=`${_n}${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(el,{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:Cm(x.sizeBytes)})]}),t.jsx(Tn,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},x.id)})})}function Im({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}=$d(c),_=g.length>0?yn(s,g):s;return t.jsxs(t.Fragment,{children:[_.trim()&&t.jsx(Fm,{message:e,content:_,attachments:g,isUser:o,tone:p,workingDir:x,onOpenWorkspaceFile:i,onOpenPreviewUrl:n,onOpenVisualization:a,downloadSessionId:h}),t.jsx(Lm,{hasAttachmentIds:c.length>0,attachments:g,isLoading:v,onOpenImage:m})]})}function Om({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(Xt,{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(Su,{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:`${_n}${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:`${_n}${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(Tn,{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(Nt,{size:24,"aria-hidden":!0})})]})}function Bm({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 Fm({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}=ce(),c=b.useId(),g=b.useRef(null),[v,_]=b.useState(null),[w,l]=b.useState(!1),[u,d]=b.useState(null),f=Ad(e.teamRunId,e.id,!1),S=f.data?.content,C=S?yn(S,r):void 0,E=!!(C&&C!==s)?C:s,y=!!(e.isTruncated&&!Vl(e)),j=v?.messageId===e.id&&v.content===E&&v.expanded,A=b.useCallback(()=>{const L=g.current;L&&l(um(L.scrollHeight))},[]);b.useLayoutEffect(()=>{A();const L=g.current;if(!L)return;const W=window.requestAnimationFrame(A),$=typeof ResizeObserver>"u"?null:new ResizeObserver(A);return $?.observe(L),window.addEventListener("resize",A),()=>{window.cancelAnimationFrame(W),$?.disconnect(),window.removeEventListener("resize",A)}},[E,A]);const D=b.useCallback(async()=>{if(d(null),j){_({messageId:e.id,content:E,expanded:!1});return}if(y&&!S){const L=await f.refetch();if(L.error){d(Sn(L.error,h("Failed to load full message")));return}const W=L.data?.content?yn(L.data.content,r):E;_({messageId:e.id,content:W,expanded:!0});return}_({messageId:e.id,content:E,expanded:!0})},[r,y,S,f,j,e.id,E,h]),M=(w||y)&&!j,P=w||y,z=f.isFetching;return t.jsxs("div",{className:"relative",children:[t.jsxs("div",{id:c,ref:g,onLoadCapture:A,className:Z("relative transition-[max-height] duration-200 ease-out",M?"overflow-hidden":""),style:M?{maxHeight:ql}:void 0,children:[t.jsx(Pm,{content:E,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")})]}),P&&t.jsxs("button",{type:"button","aria-expanded":j,"aria-controls":c,"aria-label":h(j?"Collapse message":"Expand full message"),disabled:z,onClick:()=>{D()},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:[j?t.jsx(xl,{size:13}):t.jsx(Ct,{size:13}),t.jsx("span",{children:h(z?"Loading":j?"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 Yl({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(Yt,{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(us,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"shrink-0",children:Em(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(Yt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function zm({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(xi,{agentType:e.agentType,className:"size-2.5"}),t.jsx("span",{className:"truncate",children:e.name})]})}function Wm({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}=ce(),_=e.senderType==="user",w=e.senderType==="system",l=Vl(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?Tm(e,p):[],E=t.jsxs(t.Fragment,{children:[!_&&!w&&o&&t.jsx(zm,{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(Rd,{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(Yl,{senderName:s,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:_,isSystem:w,headerAddon:E,bubbleClassName:_&&l==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:l==="sending",children:t.jsx(Im,{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 Hm({request:e,member:s,onApprove:r,onReject:o,isActionPending:p,isApprovePending:m,isRejectPending:x}){const{t:i}=ce();return t.jsx(Yl,{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(us,{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??jm(e.instruction)}),t.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[t.jsxs(Re,{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(Re,{type:"button",size:"xs",variant:"outline",disabled:p,onClick:o,children:[t.jsx(Xt,{size:12}),t.jsx("span",{children:i(x?"Rejecting":"Reject")})]})]})]})})}function Xl({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}=ce(),_=Ka(e.id),w=qa(e.id),l=Va(e.id),[u,d]=b.useState(""),[f,S]=b.useState(!1),[C,k]=b.useState(null),[E,y]=b.useState(0),[j,A]=b.useState([]),[D,M]=b.useState(!1),[P,z]=b.useState(null),[L,W]=b.useState([]),[$,R]=b.useState(null),I=b.useRef(null),T=b.useRef(null),{files:O,addFiles:q,removeFile:V,clear:B,restoreFiles:U,buildMarkdownLinks:H,getDoneAttachments:N,isUploading:F}=Dn(),K=O.some(X=>X.status==="done"&&X.attachment),[Y,se]=b.useState(null),{scrollRef:G,contentRef:me,isAtBottom:ue,scrollToBottom:re}=Hn({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:ye}=Gs(),We=b.useMemo(()=>{const X=new Map;for(const te of ye??[])X.set(te.provider.id,te.provider);return X},[ye]),ke=b.useMemo(()=>new Map((e.members??[]).map(X=>[X.id,X])),[e.members]),Ue=b.useMemo(()=>(e.members??[]).filter(Yo),[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=L.filter(ie=>!X.has(ie.id));return[...s,...te].sort((ie,ae)=>{const we=Date.parse(ie.createdAt??""),Ce=Date.parse(ae.createdAt??"");return(Number.isNaN(we)?0:we)-(Number.isNaN(Ce)?0:Ce)})},[s,L]),je=b.useMemo(()=>new Map((e.workRequests??[]).map(X=>[X.id,X])),[e.workRequests]),Be=b.useMemo(()=>pm(Me,e.workRequests??[],e.invocations??[]),[Me,e.invocations,e.workRequests]);b.useEffect(()=>{const X=Be.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,Be]);const Ke=b.useMemo(()=>(e.invocations??[]).filter(X=>Ei.has(X.status)),[e.invocations]),qe=b.useMemo(()=>j.map(X=>ke.get(X)).filter(X=>!!X).filter(Yo),[ke,j]),De=b.useMemo(()=>{const X=C?.query??"";return Ue.filter(te=>Rm(te,X)).sort((te,ie)=>{const ae=j.includes(te.id),we=j.includes(ie.id);return ae!==we?ae?1:-1:te.name.localeCompare(ie.name)})},[Ue,C?.query,j]),Ge=!r&&(f||!!C)&&De.length>0,Qe=b.useCallback((X,te)=>{if(te==null){k(null);return}k(Nm(X,te)),y(0)},[]),Te=b.useCallback(X=>{A(Ce=>hm(Ce,X.id));const te=`@${X.name} `;if(C){const Ce=`${u.slice(0,C.start)}${te}${u.slice(C.end)}`,Pe=C.start+te.length;d(Ce),k(null),S(!1),requestAnimationFrame(()=>{I.current?.focus(),I.current?.setSelectionRange(Pe,Pe)});return}const ie=u.length===0||/\s$/.test(u)?"":" ",ae=`${u}${ie}${te}`,we=ae.length;d(ae),S(!1),requestAnimationFrame(()=>{I.current?.focus(),I.current?.setSelectionRange(we,we)})},[u,C]),pe=b.useCallback(X=>{A(te=>fm(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&&(q(Array.from(te)),z(null)),X.target.value=""},[q]),$e=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(),q(te),z(null))},[q]),ft=b.useCallback(async()=>{if(r||D||F)return;const X=H(),te=N().map(be=>be.id),ie=mm(j,Ue),ae=Bm({draft:u,attachmentMarkdown:X,attachmentIds:te,mentions:ie});if(!ae||!u.trim()&&!K)return;const we=wm(e.id,ae),Ce=u,Pe=j,Je=O;W(be=>[...be,we]),d(""),A([]),S(!1),k(null),B(),I.current&&(I.current.style.height=i?"40px":"72px"),requestAnimationFrame(()=>re()),M(!0),z(null);try{const be=await p(ae);W(xe=>xe.filter(fe=>fe.id!==we.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(fe=>fe.map(Fe=>Fe.id===we.id?{...Fe,pendingStatus:"failed",error:xe}:Fe)),d(fe=>fe.length===0?Ce:fe),A(fe=>fe.length===0?Pe:fe),U(Je),z(xe),requestAnimationFrame(()=>re())}finally{M(!1)}},[Ue,O,H,B,i,u,N,K,D,F,p,r,U,re,j,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[E]??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,E,De,Ge]);b.useEffect(()=>{d(""),A([]),S(!1),k(null),z(null),W([]),B(),ne.current=!1,le.current=null,R(null),I.current&&(I.current.style.height=i?"40px":"72px")},[B,i,e.id]);const ee=_.isError?_.error:w.isError?w.error:null,he=_.isPending||w.isPending,Se=b.useCallback((X,te)=>{l.mutate({memberId:X,cancelQueued:te},{onSuccess:()=>R(null)})},[l]);return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[Y&&t.jsx(Om,{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:me,className:Z(i?"space-y-2.5":"space-y-3",n&&"max-w-4xl mx-auto"),children:[Be.length===0?t.jsxs("div",{className:"flex min-h-[180px] flex-col items-center justify-center gap-2 rounded-lg border border-dashed border-neutral-200 bg-white text-neutral-500",children:[t.jsx(Es,{size:24,className:"text-neutral-400"}),t.jsx("span",{className:"text-sm",children:v("No room messages yet")})]}):Be.map(X=>{if(X.kind==="pendingApproval"){const xe=X.request,fe=ke.get(xe.targetMemberId),Fe=_.isPending&&_.variables===xe.id,st=w.isPending&&w.variables===xe.id;return t.jsx(Hm,{request:xe,member:fe,onApprove:()=>_.mutate(xe.id),onReject:()=>w.mutate(xe.id),isActionPending:he,isApprovePending:Fe,isRejectPending:st},X.key)}const te=X.message,ie=Dm(te,ke,at),ae=te.senderType==="user"?v("你"):te.senderType==="system"?v("System"):ie?.name??v("Agent"),we=Mm(te,ke),Ce=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(Wm,{message:te,senderName:ae,senderMember:ie,senderProvider:Ce,memberById:ke,displayContent:we,onOpenImage:(xe,fe)=>se({images:xe,index:fe}),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:Sn(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:Sn(l.error,v("Failed to stop member work"))})]})}),!ue&&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(br,{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(ym,{invocations:Ke,memberById:ke,workRequestById:je,onViewInvocationSession:m,onStopMember:Se,isStopPending:l.isPending,stoppingMemberId:l.variables?.memberId??null,stopPromptInvocationId:$,onToggleStopConfirm:X=>R(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=j.includes(X.id),ae=te===E;return t.jsxs("button",{type:"button",onMouseEnter:()=>y(te),onMouseDown:we=>{we.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(Yt,{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(jo,{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:()=>pe(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(Xt,{size:12})})]},X.id))}),t.jsx(Pn,{files:O,onRemove:V}),t.jsx("textarea",{ref:I,value:u,rows:i?1:void 0,onChange:et,onKeyDown:tt,onPaste:$e,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(Vn,{size:18})}),t.jsx("button",{type:"button",onClick:()=>{S(X=>!X),k(null),requestAnimationFrame(()=>I.current?.focus())},disabled:qe.length===0&&Ue.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&&Ue.length===0?"cursor-not-allowed opacity-50":""),children:t.jsx(jo,{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||D||F||!u.trim()&&!K,title:v(F?"Uploading...":D?"发送中...":"发送"),"aria-label":v(F?"Uploading...":D?"发送中...":"发送"),className:Z("rounded-lg transition-all duration-200",i?"p-1.5":"p-2",(u.trim()||K)&&!r&&!D&&!F?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",D||F?"opacity-70":""),children:t.jsx(Un,{size:i?15:18})})]}),P&&t.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:P})]})]})})]})}function Um(e){return e?e.slice(0,8):""}function Xo(e){const s=e?Date.parse(e):0;return Number.isNaN(s)?0:s}function no(e){return e?.workspaceKind===xt.MAIN_DIRECTORY}function Ys(e){return e?no(e)?"Project directory":e.branchName:"—"}function hs(e){return e?.workingDir||e?.worktreePath||void 0}function oo(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 ${Um(m.ownerMemberId)}`:void 0),c=no(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?Ys(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:Xo(m.workspace.createdAt)-Xo(x.workspace.createdAt)})}function Gl(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===Mt.ACTIVE)?.id??e[0]?.id}function Ql(e,s){return!e||e.status!==Mt.ACTIVE||no(e)?!1:!s||e.parentWorkspaceId?!0:!!(s.mainWorkspaceId&&e.id===s.mainWorkspaceId)}function Zl(e,s,r){return e?.parentWorkspaceId?s?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:e?.baseBranch||r}const ao={readRoom:!1,postRoomMessage:!1,mentionMembers:!1,stopMemberWork:!1,markReadyForReview:!1,readFiles:!1,writeFiles:!1,runCommands:!1,readDiff:!1,mergeWorkspace:!1},$m=[{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:"合并工作区"}],Jl=[{value:"none",label:"无"},{value:"shared",label:"共享"},{value:"dedicated",label:"独占"}],Km=[{value:"MENTION_ONLY",label:"仅提及"},{value:"USER_MESSAGES",label:"所有用户消息"}],ec=[{value:"new_per_request",label:"每次新会话"},{value:"resume_last",label:"复用上次会话"}],qm=[{value:"own_only",label:"仅自己队列"},{value:"team_pending",label:"全队列待处理"}];function ar(){return{name:"",aliasesText:"",providerId:"",rolePrompt:"",capabilities:{...ao},workspacePolicy:"none",triggerPolicy:"MENTION_ONLY",sessionPolicy:"new_per_request",queueManagementPolicy:"own_only",avatar:""}}function Is(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...ao,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Vi(e){return{name:e.name,aliasesText:(e.aliases??[]).join(", "),providerId:e.providerId,rolePrompt:e.rolePrompt,capabilities:{...ao,...e.capabilities},workspacePolicy:e.workspacePolicy,triggerPolicy:e.triggerPolicy,sessionPolicy:e.sessionPolicy,queueManagementPolicy:e.queueManagementPolicy,avatar:e.avatar??""}}function Vm(e){return Array.from(new Set(e.split(/[\n,]/).map(s=>s.trim()).filter(Boolean)))}function Ym(e){return{name:e.name.trim(),aliases:Vm(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 Go(e,s){return e instanceof Error?e.message:s}function Qo(e){return e.membershipStatus!=="REMOVED"}function wn(e){return e.status==="RUNNING"||e.status==="WAITING_ROOM_REPLY"||e.status==="SESSION_ENDED"||e.status==="QUEUED"}function Zo(e){return wn(e)?"bg-emerald-500":e.status==="FAILED"?"bg-red-500":"bg-neutral-300"}function Jo(e){return Jl.find(s=>s.value===e)?.label??e}function Xm(e){return ec.find(s=>s.value===e)?.label??e}function qt({children:e}){return t.jsx("span",{className:"text-xs font-medium text-neutral-600",children:e})}function ea({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 Gm({isOpen:e,onClose:s,teamRun:r}){const{t:o}=ce(),{data:p=[]}=Td(),{data:m=[]}=Gs(),x=Md(r.id),i=Dd(r.id),n=Pd(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??[],E=b.useMemo(()=>k.filter(Qo),[k]),y=b.useMemo(()=>S&&Qo(S)&&!E.some(H=>H.id===S.id)?[...E,S]:E,[S,E]),j=g?E.find(H=>H.id===g)??null:null,A=S?.id===g?S:j,D=_?p.find(H=>H.id===_)??null:null,M=x.isPending||i.isPending||n.isPending,P=y.filter(wn).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(xi,{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?Is(H):ar()),f(null)},[y,e]),b.useEffect(()=>{S&&E.some(H=>H.id===S.id)&&C(null)},[S,E]),b.useEffect(()=>{h==="add-preset"&&D&&u(Vi(D))},[h,D]);const L=(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(Is(H))},R=()=>{c("add-preset"),v(null);const H=D??p[0]??null;w(H?.id??""),u(H?Vi(H):ar())},I=()=>{c("add-custom"),v(null),w(""),u(ar())},T=!!(l.name.trim()&&l.providerId.trim()&&l.rolePrompt.trim()),O=h==="add-preset"?!!_:h==="edit"?!!(A&&T):T,q=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(Is(N));return}const H=Ym(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(Is(N));return}if(A){const N=await i.mutateAsync({memberId:A.id,data:H});ot.success(o("Member updated")),C(F=>F?.id===N.id?N:F),v(N.id),u(Is(N))}}catch(H){ot.error(Go(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?Is(H):ar())}C(H=>H?.id===d.id?null:H),f(null),ot.success(o("Member removed"))}catch(H){ot.error(Go(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($r,{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(Re,{type:"button",variant:"outline",size:"sm",onClick:I,disabled:M,children:[t.jsx(Ro,{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(ea,{icon:t.jsx($r,{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(Re,{type:"button",variant:"outline",size:"sm",onClick:I,disabled:M,children:[t.jsx(ds,{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(Vi(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(Yt,{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(Jo(H.workspacePolicy))," · ",o(Xm(H.sessionPolicy))]})]}),N?t.jsx(Wt,{size:16,className:"shrink-0 text-neutral-900"}):null]},H.id)})})})]}),U=()=>{const H=h==="edit";return H&&!A?t.jsx("div",{className:"p-5",children:t.jsx(ea,{icon:t.jsx(Es,{size:18}),title:o("Select a member"),description:o("Choose a member on the left to edit its future TeamRun configuration."),action:t.jsxs(Re,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:M,children:[t.jsx(ds,{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(wl,{size:15,className:"text-neutral-500"}):t.jsx(ds,{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&&A?t.jsxs(Re,{type:"button",variant:"outline",size:"sm",onClick:()=>f(A),disabled:M,className:"border-red-200 text-red-700 hover:bg-red-50 hover:text-red-800",children:[t.jsx(gi,{size:13}),o("Remove")]}):t.jsxs(Re,{type:"button",variant:"outline",size:"sm",onClick:R,disabled:M,children:[t.jsx($r,{size:13}),o("Use preset")]})]})}),t.jsxs("div",{className:"p-5 lg:min-h-0 lg:flex-1 lg:overflow-y-auto",children:[H&&A?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(Yt,{name:A.name,avatar:A.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",Zo(A))}),t.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:A.name})]}),t.jsxs("div",{className:"mt-0.5 truncate text-xs text-neutral-500",children:[A.providerId," · ",o(Jo(A.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(qt,{children:o("Name")}),t.jsx("input",{value:l.name,onChange:N=>L("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(qt,{children:o("Aliases")}),t.jsx("input",{value:l.aliasesText,onChange:N=>L("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(qt,{children:o("Provider")}),t.jsx(cs,{value:l.providerId,onChange:N=>L("providerId",N),options:z})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Avatar")}),t.jsx("input",{value:l.avatar,onChange:N=>L("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(qt,{children:o("Workspace policy")}),t.jsx(cs,{value:l.workspacePolicy,onChange:N=>L("workspacePolicy",N),options:Jl.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Trigger policy")}),t.jsx(cs,{value:l.triggerPolicy,onChange:N=>L("triggerPolicy",N),options:Km.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Session policy")}),t.jsx(cs,{value:l.sessionPolicy,onChange:N=>L("sessionPolicy",N),options:ec.map(N=>({value:N.value,label:o(N.label)}))})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Queue policy")}),t.jsx(cs,{value:l.queueManagementPolicy,onChange:N=>L("queueManagementPolicy",N),options:qm.map(N=>({value:N.value,label:o(N.label)}))})]})]}),t.jsxs("label",{className:"space-y-1.5",children:[t.jsx(qt,{children:o("Role prompt")}),t.jsx("textarea",{value:l.rolePrompt,onChange:N=>L("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(qt,{children:o("Capabilities")}),t.jsx("div",{className:"grid grid-cols-1 gap-2 sm:grid-cols-2 xl:grid-cols-3",children:$m.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(ps,{isOpen:e,onClose:M?()=>{}:s,title:o("Manage Team Members"),className:"max-w-6xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Re,{type:"button",variant:"outline",onClick:s,disabled:M,children:o("Close")}),t.jsx(Re,{type:"button",onClick:q,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(Es,{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")," · ",P," ",o("working")]})]}),t.jsx(Re,{type:"button",size:"icon-sm",variant:"outline",onClick:R,disabled:M,title:o("Add member"),children:t.jsx(ds,{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(Yt,{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",Zo(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(Ju,{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:R,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($r,{size:12}),o("Preset")]}),t.jsxs("button",{type:"button",onClick:I,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(Ro,{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(In,{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&&wn(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(Ns,{size:15,className:"mt-0.5 shrink-0"}),t.jsx("span",{className:"text-sm font-medium",children:o("确认后会停止当前工作并取消队列")})]}):null]})})]})}const Qm=[],Zm=[],Jm=[],ep=240;function tp(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 ta={running:0,"waiting room reply":1,queued:2,"session ended":3,"pending approval":4,idle:5,removed:6};function Yi(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 sa(e,s){return e instanceof Error?e.message:s}function sp(e,s=ep){const r=(e??"").replace(/\s+/g," ").trim();return r.length<=s?r:`${r.slice(0,s-3).trimEnd()}...`}function Kr(e){return e?e.instructionPreview??sp(e.instruction):""}function rp(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 ip(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 np(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 op(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}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"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 lp(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function cp(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 dp(e){return[...e].sort((s,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(s.updatedAt??s.createdAt??""))}function up(e,s){return s.find(r=>r.memberId===e.id&&Ei.has(r.status))}function tc({teamRun:e,workspaces:s,selectedWorkspaceId:r,onSelectWorkspace:o,onViewInvocationSession:p}){const{t:m}=ce(),x=Ka(e.id),i=qa(e.id),n=Va(e.id),[a,h]=b.useState(null),[c,g]=b.useState(null),[v,_]=b.useState(!1),[w,l]=b.useState(!1),u=e.members??Qm,d=b.useMemo(()=>u.filter(L=>L.membershipStatus!=="REMOVED"),[u]),f=e.workRequests??Zm,S=e.invocations??Jm,C=b.useMemo(()=>oo(s,e),[e,s]),k=b.useMemo(()=>new Map(f.map(L=>[L.id,L])),[f]),E=b.useMemo(()=>[...f].filter(L=>L.status==="PENDING_APPROVAL").sort((L,W)=>Date.parse(W.updatedAt??W.createdAt??"")-Date.parse(L.updatedAt??L.createdAt??"")),[f]),y=b.useMemo(()=>[...f].filter(L=>L.status==="QUEUED").sort((L,W)=>Date.parse(W.updatedAt??W.createdAt??"")-Date.parse(L.updatedAt??L.createdAt??"")),[f]),j=b.useMemo(()=>[...u].map(L=>({member:L,status:tp(L.status)})).sort((L,W)=>ta[L.status]-ta[W.status]),[u]),A=x.isError?x.error:i.isError?i.error:null,D=x.isPending||i.isPending,M=C.find(L=>L.workspace.id===r),P=e.messages??[],z=j.filter(({status:L})=>L==="running"||L==="waiting room reply").length;return t.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[t.jsx(Gm,{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(Ks,{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(vi,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:P.length})]}),t.jsxs("span",{className:"inline-flex items-center gap-1",title:m("Members"),children:[t.jsx(Es,{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(us,{size:11,className:"text-neutral-400"}),t.jsx("span",{className:"tabular-nums",children:y.length})]}),E.length>0&&t.jsxs("span",{className:"inline-flex items-center gap-1 text-amber-600",title:m("Pending approval"),children:[t.jsx(us,{size:11}),t.jsx("span",{className:"tabular-nums",children:E.length})]})]}),t.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-3 space-y-3",children:[E.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(us,{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:E.length})]}),t.jsx("div",{className:"space-y-1.5",children:E.map(L=>{const W=u.find(I=>I.id===L.targetMemberId),$=x.isPending&&x.variables===L.id,R=i.isPending&&i.variables===L.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(Yt,{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??L.targetMemberId})]}),t.jsx("div",{className:"mt-1 text-[11px] leading-relaxed text-neutral-600 line-clamp-2",children:Kr(L)})]})}),t.jsxs("div",{className:"mt-1.5 flex items-center gap-x-2 text-[10px] text-neutral-400",children:[t.jsx("span",{children:m(op(L.requesterType))}),t.jsx("span",{children:Yi(L.createdAt)})]}),t.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>x.mutate(L.id),disabled:D,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(L.id),disabled:D,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(Xt,{size:11}),t.jsx("span",{className:"truncate",children:m(R?"Rejecting":"Reject")})]})]})]},L.id)})}),A&&t.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:sa(A,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(Es,{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(wl,{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:j.map(({member:L,status:W})=>{const $=up(L,S),R=dp(S.filter(U=>U.memberId===L.id)),I=$?k.get($.workRequestId):void 0,T=c===L.id,O=W==="running"||W==="waiting room reply",q=O&&!!$,V=a===L.id,B=n.isPending&&n.variables?.memberId===L.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(Yt,{name:L.name,avatar:L.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",np(W))}),t.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:L.name}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",ip(W)),children:m(rp(W))})]}),O&&I?.instruction&&t.jsx("div",{className:"mt-0.5 truncate pl-3 text-[10px] text-neutral-500",children:Kr(I)})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[q&&t.jsx("button",{type:"button",onClick:()=>h(V?null:L.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(Us,{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(mn,{size:12})}),t.jsx("button",{type:"button",onClick:()=>g(T?null:L.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(Ct,{size:13}):t.jsx(Nt,{size:13})})]})]}),q&&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:L.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(Us,{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:L.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(yl,{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:L.providerId}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:L.workspacePolicy}),t.jsx("span",{className:"h-0.5 w-0.5 rounded-full bg-neutral-300"}),t.jsx("span",{children:L.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:R.length})]}),R.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:R.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",ap(U.status)),children:U.status}),t.jsx("span",{className:"text-[10px] text-neutral-400",children:Yi(U.updatedAt??U.createdAt)})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Kr(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(mn,{size:10}),t.jsx("span",{children:m("Log")})]})]})},U.id)})})]}),j[j.length-1]?.member.id!==L.id&&!T&&t.jsx("div",{className:"mx-3 border-b border-neutral-100"})]},L.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:sa(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(us,{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(L=>{const W=u.find($=>$.id===L.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(Yt,{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??L.targetMemberId})]}),t.jsx("div",{className:"mt-0.5 truncate text-[11px] text-neutral-500",children:Kr(L)})]}),t.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:Yi(L.createdAt)})]})},L.id)})})]}),C.length>0&&t.jsxs("section",{className:"space-y-1.5",children:[t.jsxs("button",{type:"button",onClick:()=>_(L=>!L),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(Ks,{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:Ys(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(Ct,{size:13,className:"text-neutral-400"}):t.jsx(Nt,{size:13,className:"text-neutral-400"})]})]}),v&&t.jsx("div",{className:"space-y-1.5",children:C.map(L=>{const W=r===L.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(L.displayName)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",cp(L.roleLabel)),children:m(L.roleLabel)}),t.jsx("span",{className:Z("shrink-0 rounded-full border px-1.5 py-px text-[9px] font-medium leading-tight",lp(L.workspace.status)),children:L.workspace.status})]}),t.jsx("div",{className:"mt-0.5 truncate font-mono text-[10px] text-neutral-500",children:Ys(L.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:[L.ownerName&&t.jsxs("span",{children:[m("Owner"),": ",L.ownerName]}),L.parentBranchName&&t.jsxs("span",{children:[m("Parent"),": ",L.parentBranchName]})]})]}),t.jsxs("button",{type:"button",onClick:()=>o?.(L.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")})]})]})},L.workspace.id)})})]}),E.length===0&&y.length===0&&j.every(({status:L})=>L==="idle")&&t.jsx("div",{className:"py-2 text-center text-[11px] text-neutral-400",children:m("All members idle")})]})]})}var Xi={exports:{}},ra;function hp(){return ra||(ra=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 E,y=arguments.length,j=y<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,S,C,k);else for(var A=f.length-1;A>=0;A--)(E=f[A])&&(j=(y<3?E(j):y>3?E(S,C,j):E(S,C))||j);return y>3&&j&&Object.defineProperty(S,C,j),j},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 E=f;E<=S;E++){const y=C.translateBufferLineToString(C.ydisp+E,!0),j=(C.ydisp+E+1).toString(),A=this._rowElements[E];A&&(y.length===0?A.innerText=" ":A.textContent=y,A.setAttribute("aria-posinset",j),A.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 E,y;if(S===0?(E=C,y=this._rowElements.pop(),this._rowContainer.removeChild(y)):(E=this._rowElements.shift(),y=C,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),y.removeEventListener("focus",this._bottomBoundaryFocusListener),S===0){const j=this._createAccessibilityTreeNode();this._rowElements.unshift(j),this._rowContainer.insertAdjacentElement("afterbegin",j)}else{const j=this._createAccessibilityTreeNode();this._rowElements.push(j),this._rowContainer.appendChild(j)}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 E=l.length-1;E>=0;E--)(S=l[E])&&(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,(E=>{var y,j;if(this._isMouseOut)return;const A=E?.map((D=>({link:D})));(y=this._activeProviderReplies)===null||y===void 0||y.set(C,A),S=this._checkLinkProviderResult(C,l,S),((j=this._activeProviderReplies)===null||j===void 0?void 0:j.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],E=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 j=E;j<=y;j++){if(d.has(j)){S.splice(C--,1);break}d.add(j)}}}}_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((E=>this._linkAtPosition(E.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 E=(f=this._activeProviderReplies.get(k))===null||f===void 0?void 0:f.find((y=>this._linkAtPosition(y.link,u)));if(E){d=!0,this._handleNewLink(E);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 E=-1,y=-1,j=!1;for(let A=0;A<k;A++)if(y!==-1||d.hasContent(A)){if(d.loadCell(A,C),C.hasExtendedAttrs()&&C.extended.urlId){if(y===-1){y=A,E=C.extended.urlId;continue}j=C.extended.urlId!==E}else y!==-1&&(j=!0);if(j||y!==-1&&A===k-1){const D=(u=this._oscLinkService.getLinkData(E))===null||u===void 0?void 0:u.uri;if(D){const M={start:{x:y+1,y:w},end:{x:A+(j||A!==k-1?0:1),y:w}};let P=!1;if(!S?.allowNonHttpProtocols)try{const z=new URL(D);["http:","https:"].includes(z.protocol)||(P=!0)}catch{P=!0}P||f.push({text:D,range:M,activate:(z,L)=>S?S.activate(z,L,M):_(0,L),hover:(z,L)=>{var W;return(W=S?.hover)===null||W===void 0?void 0:W.call(S,z,L,M)},leave:(z,L)=>{var W;return(W=S?.leave)===null||W===void 0?void 0:W.call(S,z,L,M)}})}j=!1,C.hasExtendedAttrs()&&C.extended.urlId?(y=A,E=C.extended.urlId):(y=-1,E=-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),E=n(3230),y=n(9312),j=n(4725),A=n(6731),D=n(8055),M=n(8969),P=n(8460),z=n(844),L=n(6114),W=n(8437),$=n(2584),R=n(7399),I=n(5941),T=n(9074),O=n(2585),q=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=L,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new z.MutableDisposable),this._onCursorMove=this.register(new P.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new P.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new P.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new P.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new P.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new P.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new P.EventEmitter),this._onBlur=this.register(new P.EventEmitter),this._onA11yCharEmitter=this.register(new P.EventEmitter),this._onA11yTabEmitter=this.register(new P.EventEmitter),this._onWillOpen=this.register(new P.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(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,K)=>this.refresh(F,K)))),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,P.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,P.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,P.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,P.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((F=>this._afterResize(F.cols,F.rows)))),this.register((0,z.toDisposable)((()=>{var F,K;this._customKeyEventHandler=void 0,(K=(F=this.element)===null||F===void 0?void 0:F.parentNode)===null||K===void 0||K.removeChild(this.element)})))}_handleColorEvent(N){if(this._themeService)for(const F of N){let K,Y="";switch(F.index){case 256:K="foreground",Y="10";break;case 257:K="background",Y="11";break;case 258:K="cursor",Y="12";break;default:K="ansi",Y="4;"+F.index}switch(F.type){case 0:const se=D.color.toColorRGB(K==="ansi"?this._themeService.colors.ansi[F.index]:this._themeService.colors[K]);this.coreService.triggerDataEvent(`${$.C0.ESC}]${Y};${(0,I.toRgbString)(se)}${$.C1_ESCAPED.ST}`);break;case 1:if(K==="ansi")this._themeService.modifyColors((G=>G.ansi[F.index]=D.rgba.toColor(...F.color)));else{const G=K;this._themeService.modifyColors((me=>me[G]=D.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 K=Math.min(this.buffer.x,this.cols-1),Y=this._renderService.dimensions.css.cell.height,se=F.getWidth(K),G=this._renderService.dimensions.css.cell.width*se,me=this.buffer.y*this._renderService.dimensions.css.cell.height,ue=K*this._renderService.dimensions.css.cell.width;this.textarea.style.left=ue+"px",this.textarea.style.top=me+"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)),L.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)}))),L.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 K=B.createDocumentFragment();this._viewportElement=B.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),K.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),K.appendChild(this.screenElement),this.textarea=B.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),L.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(j.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(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(A.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(S.CharacterJoinerService),this._instantiationService.setService(j.ICharacterJoinerService,this._characterJoinerService),this._renderService=this.register(this._instantiationService.createInstance(E.RenderService,this.rows,this.screenElement)),this._instantiationService.setService(j.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(K);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(j.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(j.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 K(G){const me=N._mouseService.getMouseReportCoords(G,N.screenElement);if(!me)return!1;let ue,re;switch(G.overrideType||G.type){case"mousemove":re=32,G.buttons===void 0?(ue=3,G.button!==void 0&&(ue=G.button<3?G.button:3)):ue=1&G.buttons?0:4&G.buttons?1:2&G.buttons?2:3;break;case"mouseup":re=0,ue=G.button<3?G.button:3;break;case"mousedown":re=1,ue=G.button<3?G.button:3;break;case"wheel":if(N.viewport.getLinesScrolled(G)===0)return!1;re=G.deltaY<0?0:1,ue=4;break;default:return!1}return!(re===void 0||ue===void 0||ue>4)&&N.coreMouseService.triggerMouseEvent({col:me.col,row:me.row,x:me.x,y:me.y,button:ue,action:re,ctrl:G.ctrlKey,alt:G.altKey,shift:G.shiftKey})}const Y={mouseup:null,wheel:null,mousedrag:null,mousemove:null},se={mouseup:G=>(K(G),G.buttons||(this._document.removeEventListener("mouseup",Y.mouseup),Y.mousedrag&&this._document.removeEventListener("mousemove",Y.mousedrag)),this.cancel(G)),wheel:G=>(K(G),this.cancel(G,!0)),mousedrag:G=>{G.buttons&&K(G)},mousemove:G=>{G.buttons||K(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 K(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 me=this.viewport.getLinesScrolled(G);if(me===0)return;const ue=$.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(G.deltaY<0?"A":"B");let re="";for(let ne=0;ne<Math.abs(me);ne++)re+=ue;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 K;(K=this._renderService)===null||K===void 0||K.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,K=0){var Y;K===1?(super.scrollLines(N,F,K),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,K){this._selectionService.setSelection(N,F,K)}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 K;(K=this._selectionService)===null||K===void 0||K.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 K=(0,R.evaluateKeyboardEvent)(N,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(N),K.type===3||K.type===2){const Y=this.rows-1;return this.scrollLines(K.type===2?-Y:Y),this.cancel(N,!0)}return K.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,N)||(K.cancel&&this.cancel(N,!0),!K.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):(K.key!==$.C0.ETX&&K.key!==$.C0.CR||(this.textarea.value=""),this._onKey.fire({key:K.key,domEvent:N}),this._showCursor(),this.coreService.triggerDataEvent(K.key,!0),!this.optionsService.rawOptions.screenReaderMode||N.altKey||N.ctrlKey?this.cancel(N,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(N,F){const K=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"?K:K&&(!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 K,Y;(K=this._charSizeService)===null||K===void 0||K.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 K=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=K,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 q.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const F=this._renderService.dimensions.css.canvas.width.toFixed(0),K=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${$.C0.ESC}[4;${K};${F}t`);break;case q.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,E=k<3?d:S===null?S=Object.getOwnPropertyDescriptor(d,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(u,d,f,S);else for(var y=u.length-1;y>=0;y--)(C=u[y])&&(E=(k<3?C(E):k>3?C(d,f,E):C(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},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,E,y){super(),this._viewportElement=u,this._scrollArea=d,this._bufferService=f,this._optionsService=S,this._charSizeService=C,this._renderService=k,this._coreBrowserService=E,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((j=>this._activeBuffer=j.activeBuffer))),this._renderDimensions=this._renderService.dimensions,this.register(this._renderService.onDimensionsChange((j=>this._renderDimensions=j))),this._handleThemeChange(y.colors),this.register(y.onChangeColors((j=>this._handleThemeChange(j)))),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=[],E=d??this._bufferService.buffer.lines.length,y=this._bufferService.buffer.lines;for(let j=u;j<E;j++){const A=y.get(j);if(!A)continue;const D=(f=y.get(j+1))===null||f===void 0?void 0:f.isWrapped;if(C+=A.translateToString(!D),!D||j===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 E=l.length-1;E>=0;E--)(S=l[E])&&(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,E){var y,j=arguments.length,A=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(S,C,k,E);else for(var D=S.length-1;D>=0;D--)(y=S[D])&&(A=(j<3?y(A):j>3?y(C,k,A):y(C,k))||A);return j>3&&A&&Object.defineProperty(C,k,A),A},h=this&&this.__param||function(S,C){return function(k,E){C(k,E,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,E,y,j,A){var D;super(),this._viewportElement=S,this._screenElement=C,this._bufferService=k,this._decorationService=E,this._renderService=y,this._optionsService=j,this._coreBrowseService=A,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(),(D=this._viewportElement.parentElement)===null||D===void 0||D.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 P;(P=this._canvas)===null||P===void 0||P.remove()})))}_registerDecorationListeners(){this.register(this._decorationService.onDecorationRegistered((()=>this._queueRefresh(void 0,!0)))),this.register(this._decorationService.onDecorationRemoved((()=>this._queueRefresh(void 0,!0))))}_registerBufferChangeListeners(){this.register(this._renderService.onRenderedViewportChange((()=>this._queueRefresh()))),this.register(this._bufferService.buffers.onBufferActivate((()=>{this._canvas.style.display=this._bufferService.buffer===this._bufferService.buffers.alt?"none":"block"}))),this.register(this._bufferService.onScroll((()=>{this._lastKnownBufferLength!==this._bufferService.buffers.normal.lines.length&&(this._refreshDrawHeightConstants(),this._refreshColorZonePadding())})))}_registerDimensionChangeListeners(){this.register(this._renderService.onRender((()=>{this._containerHeight&&this._containerHeight===this._screenElement.clientHeight||(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)}))),this.register(this._optionsService.onSpecificOptionChange("overviewRulerWidth",(()=>this._queueRefresh(!0)))),this.register((0,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(E,y,j){let A=0;const D=E-c(E,j),M=y-c(y,j);for(let P=0;P<Math.abs(D-M);P++){const z=g(E,y)==="A"?-1:1,L=j.buffer.lines.get(D+z*P);L?.isWrapped&&A++}return A})(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,E=u,y="";for(;k!==d||E!==f;)k+=S?1:-1,S&&k>C.cols-1?(y+=C.buffer.translateBufferLineToString(E,!1,l,k),k=0,l=0,E++):!S&&k<0&&(y+=C.buffer.translateBufferLineToString(E,!1,0,l+1),k=C.cols-1,l=k,E--);return y+C.buffer.translateBufferLineToString(E,!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,j,A,D,M,P){return h(j,D,M,P).length===0?"":w(v(y,j,y,j-c(j,M),!1,M).length,_("D",P))})(S,C,0,u,d,f)+h(C,u,d,f)+(function(y,j,A,D,M,P){let z;z=h(j,D,M,P).length>0?D-c(D,M):j;const L=D,W=(function($,R,I,T,O,q){let V;return V=h(I,T,O,q).length>0?T-c(T,O):R,$<I&&V<=T||$>=I&&V<T?"C":"D"})(y,j,A,D,M,P);return w(v(y,z,A,L,W==="C",M).length,_(W,P))})(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 E=Math.abs(C-u);return w((function(y,j){return j.cols-y})(C>u?l:S,d)+(E-1)*d.cols+1+((C>u?S:l)-1),_(k,f))}},1296:function(x,i,n){var a=this&&this.__decorate||function(M,P,z,L){var W,$=arguments.length,R=$<3?P:L===null?L=Object.getOwnPropertyDescriptor(P,z):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(M,P,z,L);else for(var I=M.length-1;I>=0;I--)(W=M[I])&&(R=($<3?W(R):$>3?W(P,z,R):W(P,z))||R);return $>3&&R&&Object.defineProperty(P,z,R),R},h=this&&this.__param||function(M,P){return function(z,L){P(z,L,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-",E="xterm-bg-",y="xterm-focus",j="xterm-selection";let A=1,D=i.DomRenderer=class extends d.Disposable{constructor(M,P,z,L,W,$,R,I,T,O){super(),this._element=M,this._screenElement=P,this._viewportElement=z,this._linkifier2=L,this._charSizeService=$,this._optionsService=R,this._bufferService=I,this._coreBrowserService=T,this._themeService=O,this._terminalClass=A++,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(j),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=(0,_.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors((q=>this._injectCss(q)))),this._injectCss(this._themeService.colors),this._rowFactory=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((q=>this._handleLinkHover(q)))),this.register(this._linkifier2.onHideLinkUnderline((q=>this._handleLinkLeave(q)))),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 P=`${this._terminalSelector} .${C} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=P,this._selectionContainer.style.height=this._viewportElement.style.height,this._screenElement.style.width=`${this.dimensions.css.canvas.width}px`,this._screenElement.style.height=`${this.dimensions.css.canvas.height}px`}_injectCss(M){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let P=`${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}`;P+=`${this._terminalSelector} .${C} .xterm-dim { color: ${l.color.multiplyOpacity(M.foreground,.5).css};}`,P+=`${this._terminalSelector} span:not(.xterm-bold) { font-weight: ${this._optionsService.rawOptions.fontWeight};}${this._terminalSelector} span.xterm-bold { font-weight: ${this._optionsService.rawOptions.fontWeightBold};}${this._terminalSelector} span.xterm-italic { font-style: italic;}`,P+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",P+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${M.cursor.css}; color: ${M.cursorAccent.css}; } 50% { background-color: inherit; color: ${M.cursor.css}; }}`,P+=`${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);}`,P+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${M.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${M.selectionInactiveBackgroundOpaque.css};}`;for(const[z,L]of M.ansi.entries())P+=`${this._terminalSelector} .${k}${z} { color: ${L.css}; }${this._terminalSelector} .${k}${z}.xterm-dim { color: ${l.color.multiplyOpacity(L,.5).css}; }${this._terminalSelector} .${E}${z} { background-color: ${L.css}; }`;P+=`${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} .${E}${v.INVERTED_DEFAULT_COLOR} { background-color: ${M.foreground.css}; }`,this._themeStyleElement.textContent=P}_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,P){for(let z=this._rowElements.length;z<=P;z++){const L=document.createElement("div");this._rowContainer.appendChild(L),this._rowElements.push(L)}for(;this._rowElements.length>P;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(M,P){this._refreshRowElements(M,P),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,P,z){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(M,P,z),this.renderRows(0,this._bufferService.rows-1),!M||!P)return;const L=M[1]-this._bufferService.buffer.ydisp,W=P[1]-this._bufferService.buffer.ydisp,$=Math.max(L,0),R=Math.min(W,this._bufferService.rows-1);if($>=this._bufferService.rows||R<0)return;const I=document.createDocumentFragment();if(z){const T=M[0]>P[0];I.appendChild(this._createSelectionElement($,T?P[0]:M[0],T?M[0]:P[0],R-$+1))}else{const T=L===$?M[0]:0,O=$===W?P[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement($,T,O));const q=R-$-1;if(I.appendChild(this._createSelectionElement($+1,0,this._bufferService.cols,q)),$!==R){const V=W===R?P[0]:this._bufferService.cols;I.appendChild(this._createSelectionElement(R,0,V))}}this._selectionContainer.appendChild(I)}_createSelectionElement(M,P,z,L=1){const W=document.createElement("div");return W.style.height=L*this.dimensions.css.cell.height+"px",W.style.top=M*this.dimensions.css.cell.height+"px",W.style.left=P*this.dimensions.css.cell.width+"px",W.style.width=this.dimensions.css.cell.width*(z-P)+"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,P){const z=this._bufferService.buffer,L=z.ybase+z.y,W=Math.min(z.x,this._bufferService.cols-1),$=this._optionsService.rawOptions.cursorBlink,R=this._optionsService.rawOptions.cursorStyle,I=this._optionsService.rawOptions.cursorInactiveStyle;for(let T=M;T<=P;T++){const O=T+z.ydisp,q=this._rowElements[T],V=z.lines.get(O);if(!q||!V)break;q.replaceChildren(...this._rowFactory.createRow(V,O,O===L,R,I,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,P,z,L,W,$){z<0&&(M=0),L<0&&(P=0);const R=this._bufferService.rows-1;z=Math.max(Math.min(z,R),0),L=Math.max(Math.min(L,R),0),W=Math.min(W,this._bufferService.cols);const I=this._bufferService.buffer,T=I.ybase+I.y,O=Math.min(I.x,W-1),q=this._optionsService.rawOptions.cursorBlink,V=this._optionsService.rawOptions.cursorStyle,B=this._optionsService.rawOptions.cursorInactiveStyle;for(let U=z;U<=L;++U){const H=U+I.ydisp,N=this._rowElements[U],F=I.lines.get(H);if(!N||!F)break;N.replaceChildren(...this._rowFactory.createRow(F,H,H===T,V,B,O,q,this.dimensions.css.cell.width,this._widthCache,$?U===z?M:0:-1,$?(U===L?P:W)-1:-1))}}};i.DomRenderer=D=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)],D)},3787:function(x,i,n){var a=this&&this.__decorate||function(k,E,y,j){var A,D=arguments.length,M=D<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,y):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(k,E,y,j);else for(var P=k.length-1;P>=0;P--)(A=k[P])&&(M=(D<3?A(M):D>3?A(E,y,M):A(E,y))||M);return D>3&&M&&Object.defineProperty(E,y,M),M},h=this&&this.__param||function(k,E){return function(y,j){E(y,j,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,E,y,j,A,D,M){this._document=k,this._characterJoinerService=E,this._optionsService=y,this._coreBrowserService=j,this._coreService=A,this._decorationService=D,this._themeService=M,this._workCell=new v.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,y){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=y}createRow(k,E,y,j,A,D,M,P,z,L,W){const $=[],R=this._characterJoinerService.getJoinedCharacters(E),I=this._themeService.colors;let T,O=k.getNoBgTrimmedLength();y&&O<D+1&&(O=D+1);let q=0,V="",B=0,U=0,H=0,N=!1,F=0,K=!1,Y=0;const se=[],G=L!==-1&&W!==-1;for(let me=0;me<O;me++){k.loadCell(me,this._workCell);let ue=this._workCell.getWidth();if(ue===0)continue;let re=!1,ne=me,le=this._workCell;if(R.length>0&&me===R[0][0]){re=!0;const pe=R.shift();le=new u.JoinedCellData(this._workCell,k.translateToString(!0,pe[0],pe[1]),pe[1]-pe[0]),ne=pe[1]-1,ue=le.getWidth()}const ye=this._isCellInSelection(me,E),We=y&&me===D,ke=G&&me>=L&&me<=W;let Ue=!1;this._decorationService.forEachDecorationAtCell(me,E,void 0,(pe=>{Ue=!0}));let at=le.getChars()||g.WHITESPACE_CELL_CHAR;if(at===" "&&(le.isUnderline()||le.isOverline())&&(at=" "),Y=ue*P-z.get(at,le.isBold(),le.isItalic()),T){if(q&&(ye&&K||!ye&&!K&&le.bg===B)&&(ye&&K&&I.selectionForeground||le.fg===U)&&le.extended.ext===H&&ke===N&&Y===F&&!We&&!re&&!Ue){V+=at,q++;continue}q&&(T.textContent=V),T=this._document.createElement("span"),q=0,V=""}else T=this._document.createElement("span");if(B=le.bg,U=le.fg,H=le.extended.ext,N=ke,F=Y,K=ye,re&&D>=me&&D<=ne&&(D=me),!this._coreService.isCursorHidden&&We){if(se.push("xterm-cursor"),this._coreBrowserService.isFocused)M&&se.push("xterm-cursor-blink"),se.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(A)switch(A){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 pe=le.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&le.isBold()&&pe<8&&(pe+=8),T.style.textDecorationColor=I.ansi[pe].css}le.isOverline()&&(se.push("xterm-overline"),V===" "&&(V=" ")),le.isStrikethrough()&&se.push("xterm-strikethrough"),ke&&(T.style.textDecoration="underline");let Me=le.getFgColor(),je=le.getFgColorMode(),Be=le.getBgColor(),Ke=le.getBgColorMode();const qe=!!le.isInverse();if(qe){const pe=Me;Me=Be,Be=pe;const et=je;je=Ke,Ke=et}let De,Ge,Qe,Te=!1;switch(this._decorationService.forEachDecorationAtCell(me,E,void 0,(pe=>{pe.options.layer!=="top"&&Te||(pe.backgroundColorRGB&&(Ke=50331648,Be=pe.backgroundColorRGB.rgba>>8&16777215,De=pe.backgroundColorRGB),pe.foregroundColorRGB&&(je=50331648,Me=pe.foregroundColorRGB.rgba>>8&16777215,Ge=pe.foregroundColorRGB),Te=pe.options.layer==="top")})),!Te&&ye&&(De=this._coreBrowserService.isFocused?I.selectionBackgroundOpaque:I.selectionInactiveBackgroundOpaque,Be=De.rgba>>8&16777215,Ke=50331648,Te=!0,I.selectionForeground&&(je=50331648,Me=I.selectionForeground.rgba>>8&16777215,Ge=I.selectionForeground)),Te&&se.push("xterm-decoration-top"),Ke){case 16777216:case 33554432:Qe=I.ansi[Be],se.push(`xterm-bg-${Be}`);break;case 50331648:Qe=w.rgba.toColor(Be>>16,Be>>8&255,255&Be),this._addStyle(T,`background-color:#${C((Be>>>0).toString(16),"0",6)}`);break;default:qe?(Qe=I.foreground,se.push(`xterm-bg-${c.INVERTED_DEFAULT_COLOR}`)):Qe=I.background}switch(De||le.isDim()&&(De=w.color.multiplyOpacity(Qe,.5)),je){case 16777216:case 33554432:le.isBold()&&Me<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Me+=8),this._applyMinimumContrast(T,Qe,I.ansi[Me],le,De,void 0)||se.push(`xterm-fg-${Me}`);break;case 50331648:const pe=w.rgba.toColor(Me>>16&255,Me>>8&255,255&Me);this._applyMinimumContrast(T,Qe,pe,le,De,Ge)||this._addStyle(T,`color:#${C(Me.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(T,Qe,I.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||Ue?T.textContent=V:q++,Y!==this.defaultSpacing&&(T.style.letterSpacing=`${Y}px`),$.push(T),me=ne}return T&&q&&(T.textContent=V),$}_applyMinimumContrast(k,E,y,j,A,D){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(j.getCode()))return!1;const M=this._getContrastCache(j);let P;if(A||D||(P=M.getColor(E.rgba,y.rgba)),P===void 0){const z=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);P=w.color.ensureContrastRatio(A||E,D||y,z),M.setColor((A||E).rgba,(D||y).rgba,P??null)}return!!P&&(this._addStyle(k,`color:${P.css}`),!0)}_getContrastCache(k){return k.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(k,E){k.setAttribute("style",`${k.getAttribute("style")||""}${E};`)}_isCellInSelection(k,E){const y=this._selectionStart,j=this._selectionEnd;return!(!y||!j)&&(this._columnSelectMode?y[0]<=j[0]?k>=y[0]&&E>=y[1]&&k<j[0]&&E<=j[1]:k<y[0]&&E>=y[1]&&k>=j[0]&&E<=j[1]:E>y[1]&&E<j[1]||y[1]===j[1]&&E===y[1]&&k>=y[0]&&k<j[0]||y[1]<j[1]&&E===j[1]&&k<j[0]||y[1]<j[1]&&E===y[1]&&k>=y[0])}};function C(k,E,y){for(;k.length<y;)k=E+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 E=l.length-1;E>=0;E--)(S=l[E])&&(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,E=k<3?d:S===null?S=Object.getOwnPropertyDescriptor(d,f):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(u,d,f,S);else for(var y=u.length-1;y>=0;y--)(C=u[y])&&(E=(k<3?C(E):k>3?C(d,f,E):C(d,f))||E);return k>3&&E&&Object.defineProperty(d,f,E),E},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 sc{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,E=0,y=0,j=f.getFg(0),A=f.getBg(0);for(let D=0;D<f.getTrimmedLength();D++)if(f.loadCell(D,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==A){if(D-k>1){const M=this._getJoinedRanges(C,y,E,f,k);for(let P=0;P<M.length;P++)S.push(M[P])}k=D,y=E,j=this._workCell.fg,A=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const D=this._getJoinedRanges(C,y,E,f,k);for(let M=0;M<D.length;M++)S.push(D[M])}return S}_getJoinedRanges(d,f,S,C,k){const E=d.substring(f,S);let y=[];try{y=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const A=this._characterJoiners[j].handler(E);for(let D=0;D<A.length;D++)sc._mergeRanges(y,A[D])}catch(A){console.error(A)}return this._stringRangesToCellRanges(y,C,k),y}_stringRangesToCellRanges(d,f,S){let C=0,k=!1,E=0,y=d[C];if(y){for(let j=S;j<this._bufferService.cols;j++){const A=f.getWidth(j),D=f.getString(j).length||g.WHITESPACE_CELL_CHAR.length;if(A!==0){if(!k&&y[0]<=E&&(y[0]=j,k=!0),y[1]<=E){if(y[1]=j,y=d[++C],!y)break;y[0]<=E?(y[0]=j,k=!0):k=!1}E+=D}}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,E){var y,j=arguments.length,A=j<3?C:E===null?E=Object.getOwnPropertyDescriptor(C,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(S,C,k,E);else for(var D=S.length-1;D>=0;D--)(y=S[D])&&(A=(j<3?y(A):j>3?y(C,k,A):y(C,k))||A);return j>3&&A&&Object.defineProperty(C,k,A),A},h=this&&this.__param||function(S,C){return function(k,E){C(k,E,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,E,y,j,A,D){if(super(),this._rowCount=S,this._charSizeService=E,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(A.window,((M,P)=>this._renderRows(M,P))),this.register(this._renderDebouncer),this._screenDprMonitor=new v.ScreenDprMonitor(A.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.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(j.cols,j.rows),this._fullRefresh()}))),this.register(k.onMultipleOptionChange(["cursorBlink","cursorStyle"],(()=>this.refreshRows(j.buffer.y,j.buffer.y,!0)))),this.register((0,c.addDisposableDomListener)(A.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(D.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in A.window){const M=new A.window.IntersectionObserver((P=>this._handleIntersectionChange(P[P.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 E;this._selectionState.start=S,this._selectionState.end=C,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.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,j,A,D){var M,P=arguments.length,z=P<3?j:D===null?D=Object.getOwnPropertyDescriptor(j,A):D;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")z=Reflect.decorate(y,j,A,D);else for(var L=y.length-1;L>=0;L--)(M=y[L])&&(z=(P<3?M(z):P>3?M(j,A,z):M(j,A))||z);return P>3&&z&&Object.defineProperty(j,A,z),z},h=this&&this.__param||function(y,j){return function(A,D){j(A,D,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 E=i.SelectionService=class extends l.Disposable{constructor(y,j,A,D,M,P,z,L,W){super(),this._element=y,this._screenElement=j,this._linkifier=A,this._bufferService=D,this._coreService=M,this._mouseService=P,this._optionsService=z,this._renderService=L,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,j=this._model.finalSelectionEnd;return!(!y||!j||y[0]===j[0]&&y[1]===j[1])}get selectionText(){const y=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!y||!j)return"";const A=this._bufferService.buffer,D=[];if(this._activeSelectionMode===3){if(y[0]===j[0])return"";const M=y[0]<j[0]?y[0]:j[0],P=y[0]<j[0]?j[0]:y[0];for(let z=y[1];z<=j[1];z++){const L=A.translateBufferLineToString(z,!0,M,P);D.push(L)}}else{const M=y[1]===j[1]?j[0]:void 0;D.push(A.translateBufferLineToString(y[1],!0,y[0],M));for(let P=y[1]+1;P<=j[1]-1;P++){const z=A.lines.get(P),L=A.translateBufferLineToString(P,!0);z?.isWrapped?D[D.length-1]+=L:D.push(L)}if(y[1]!==j[1]){const P=A.lines.get(j[1]),z=A.translateBufferLineToString(j[1],!0,0,j[0]);P&&P.isWrapped?D[D.length-1]+=z:D.push(z)}}return D.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 j=this._getMouseBufferCoords(y),A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!!(A&&D&&j)&&this._areCoordsInSelection(j,A,D)}isCellInSelection(y,j){const A=this._model.finalSelectionStart,D=this._model.finalSelectionEnd;return!(!A||!D)&&this._areCoordsInSelection([y,j],A,D)}_areCoordsInSelection(y,j,A){return y[1]>j[1]&&y[1]<A[1]||j[1]===A[1]&&y[1]===j[1]&&y[0]>=j[0]&&y[0]<A[0]||j[1]<A[1]&&y[1]===A[1]&&y[0]<A[0]||j[1]<A[1]&&y[1]===j[1]&&y[0]>=j[0]}_selectWordAtCursor(y,j){var A,D;const M=(D=(A=this._linkifier.currentLink)===null||A===void 0?void 0:A.link)===null||D===void 0?void 0:D.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 P=this._getMouseBufferCoords(y);return!!P&&(this._selectWordAt(P,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(y,j){this._model.clearSelection(),y=Math.max(y,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,y],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(y){this._model.handleTrim(y)&&this.refresh()}_getMouseBufferCoords(y){const j=this._mouseService.getCoords(y,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(y){let j=(0,c.getCoordsRelativeToElement)(this._coreBrowserService.window,y,this._screenElement)[1];const A=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=A?0:(j>A&&(j-=A),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}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 j=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);j&&j.length!==this._model.selectionStart[0]&&j.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(y){this._selectWordAtCursor(y,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(y){const j=this._getMouseBufferCoords(y);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(y){return y.altKey&&!(u.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(y){if(y.stopImmediatePropagation(),!this._model.selectionStart)return;const j=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 A=this._bufferService.buffer;if(this._model.selectionEnd[1]<A.lines.length){const D=A.lines.get(this._model.selectionEnd[1]);D&&D.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]++}j&&j[0]===this._model.selectionEnd[0]&&j[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 j=y.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&y.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const A=this._mouseService.getCoords(y,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(A&&A[0]!==void 0&&A[1]!==void 0){const D=(0,g.moveToCellSequence)(A[0]-1,A[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(D,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const y=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,A=!(!y||!j||y[0]===j[0]&&y[1]===j[1]);A?y&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&y[0]===this._oldSelectionStart[0]&&y[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(y,j,A)):this._oldHasSelection&&this._fireOnSelectionChange(y,j,A)}_fireOnSelectionChange(y,j,A){this._oldSelectionStart=y,this._oldSelectionEnd=j,this._oldHasSelection=A,this._onSelectionChange.fire()}_handleBufferActivate(y){this.clearSelection(),this._trimListener.dispose(),this._trimListener=y.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(y,j){let A=j;for(let D=0;j>=D;D++){const M=y.loadCell(D,this._workCell).getChars().length;this._workCell.getWidth()===0?A--:M>1&&j!==D&&(A+=M-1)}return A}setSelection(y,j,A){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[y,j],this._model.selectionStartLength=A,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(y){this._isClickInSelection(y)||(this._selectWordAtCursor(y,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(y,j,A=!0,D=!0){if(y[0]>=this._bufferService.cols)return;const M=this._bufferService.buffer,P=M.lines.get(y[1]);if(!P)return;const z=M.translateBufferLineToString(y[1],!1);let L=this._convertViewportColToCharacterIndex(P,y[0]),W=L;const $=y[0]-L;let R=0,I=0,T=0,O=0;if(z.charAt(L)===" "){for(;L>0&&z.charAt(L-1)===" ";)L--;for(;W<z.length&&z.charAt(W+1)===" ";)W++}else{let B=y[0],U=y[0];P.getWidth(B)===0&&(R++,B--),P.getWidth(U)===2&&(I++,U++);const H=P.getString(U).length;for(H>1&&(O+=H-1,W+=H-1);B>0&&L>0&&!this._isCharWordSeparator(P.loadCell(B-1,this._workCell));){P.loadCell(B-1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===0?(R++,B--):N>1&&(T+=N-1,L-=N-1),L--,B--}for(;U<P.length&&W+1<z.length&&!this._isCharWordSeparator(P.loadCell(U+1,this._workCell));){P.loadCell(U+1,this._workCell);const N=this._workCell.getChars().length;this._workCell.getWidth()===2?(I++,U++):N>1&&(O+=N-1,W+=N-1),W++,U++}}W++;let q=L+$-R+T,V=Math.min(this._bufferService.cols,W-L+R+I-T-O);if(j||z.slice(L,W).trim()!==""){if(A&&q===0&&P.getCodePoint(0)!==32){const B=M.lines.get(y[1]-1);if(B&&P.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;q-=H,V+=H}}}if(D&&q+V===this._bufferService.cols&&P.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:q,length:V}}}_selectWordAt(y,j){const A=this._getWordAt(y,j);if(A){for(;A.start<0;)A.start+=this._bufferService.cols,y[1]--;this._model.selectionStart=[A.start,y[1]],this._model.selectionStartLength=A.length}}_selectToWordAt(y){const j=this._getWordAt(y,!0);if(j){let A=y[1];for(;j.start<0;)j.start+=this._bufferService.cols,A--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,A++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,A]}}_isCharWordSeparator(y){return y.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(y.getChars())>=0}_selectLineAt(y){const j=this._bufferService.buffer.getWrappedRangeForLine(y),A={start:{x:0,y:j.first},end:{x:this._bufferService.cols-1,y:j.last}};this._model.selectionStart=[0,j.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=(0,d.getRangeLength)(A,this._bufferService.cols)}};i.SelectionService=E=a([h(3,S.IBufferService),h(4,S.ICoreService),h(5,_.IMouseService),h(6,S.IOptionsService),h(7,_.IRenderService),h(8,_.ICoreBrowserService)],E)},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(E,y,j,A){var D,M=arguments.length,P=M<3?y:A===null?A=Object.getOwnPropertyDescriptor(y,j):A;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")P=Reflect.decorate(E,y,j,A);else for(var z=E.length-1;z>=0;z--)(D=E[z])&&(P=(M<3?D(P):M>3?D(y,j,P):D(y,j))||P);return M>3&&P&&Object.defineProperty(y,j,P),P},h=this&&this.__param||function(E,y){return function(j,A){y(j,A,E)}};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 E=[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 j=0;j<216;j++){const A=y[j/36%6|0],D=y[j/6%6|0],M=y[j%6];E.push({css:g.channels.toCss(A,D,M),rgba:g.channels.toRgba(A,D,M)})}for(let j=0;j<24;j++){const A=8+10*j;E.push({css:g.channels.toCss(A,A,A),rgba:g.channels.toRgba(A,A,A)})}return E})());let C=i.ThemeService=class extends _.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,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(E={}){const y=this._colors;if(y.foreground=k(E.foreground,l),y.background=k(E.background,u),y.cursor=k(E.cursor,d),y.cursorAccent=k(E.cursorAccent,f),y.selectionBackgroundTransparent=k(E.selectionBackground,S),y.selectionBackgroundOpaque=g.color.blend(y.background,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,y.selectionBackgroundTransparent),y.selectionInactiveBackgroundOpaque=g.color.blend(y.background,y.selectionInactiveBackgroundTransparent),y.selectionForeground=E.selectionForeground?k(E.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(E.black,i.DEFAULT_ANSI_COLORS[0]),y.ansi[1]=k(E.red,i.DEFAULT_ANSI_COLORS[1]),y.ansi[2]=k(E.green,i.DEFAULT_ANSI_COLORS[2]),y.ansi[3]=k(E.yellow,i.DEFAULT_ANSI_COLORS[3]),y.ansi[4]=k(E.blue,i.DEFAULT_ANSI_COLORS[4]),y.ansi[5]=k(E.magenta,i.DEFAULT_ANSI_COLORS[5]),y.ansi[6]=k(E.cyan,i.DEFAULT_ANSI_COLORS[6]),y.ansi[7]=k(E.white,i.DEFAULT_ANSI_COLORS[7]),y.ansi[8]=k(E.brightBlack,i.DEFAULT_ANSI_COLORS[8]),y.ansi[9]=k(E.brightRed,i.DEFAULT_ANSI_COLORS[9]),y.ansi[10]=k(E.brightGreen,i.DEFAULT_ANSI_COLORS[10]),y.ansi[11]=k(E.brightYellow,i.DEFAULT_ANSI_COLORS[11]),y.ansi[12]=k(E.brightBlue,i.DEFAULT_ANSI_COLORS[12]),y.ansi[13]=k(E.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),y.ansi[14]=k(E.brightCyan,i.DEFAULT_ANSI_COLORS[14]),y.ansi[15]=k(E.brightWhite,i.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(y.ansi.length-16,E.extendedAnsi.length);for(let A=0;A<j;A++)y.ansi[A+16]=k(E.extendedAnsi[A],i.DEFAULT_ANSI_COLORS[A+16])}this._contrastCache.clear(),this._halfContrastCache.clear(),this._updateRestoreColors(),this._onChangeColors.fire(this.colors)}restoreColor(E){this._restoreColor(E),this._onChangeColors.fire(this.colors)}_restoreColor(E){if(E!==void 0)switch(E){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[E]=this._restoreColors.ansi[E]}else for(let y=0;y<this._restoreColors.ansi.length;++y)this._colors.ansi[y]=this._restoreColors.ansi[y]}modifyColors(E){E(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(E,y){if(E!==void 0)try{return g.css.toColor(E)}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,E,y,j){return j!==void 0?`#${f(k)}${f(E)}${f(y)}${f(j)}`:`#${f(k)}${f(E)}${f(y)}`},C.toRgba=function(k,E,y,j=255){return(k<<24|E<<16|y<<8|j)>>>0}})(_||(i.channels=_={})),(function(C){function k(E,y){return v=Math.round(255*y),[h,c,g]=d.toChannels(E.rgba),{css:_.toCss(h,c,g,v),rgba:_.toRgba(h,c,g,v)}}C.blend=function(E,y){if(v=(255&y.rgba)/255,v===1)return{css:y.css,rgba:y.rgba};const j=y.rgba>>24&255,A=y.rgba>>16&255,D=y.rgba>>8&255,M=E.rgba>>24&255,P=E.rgba>>16&255,z=E.rgba>>8&255;return h=M+Math.round((j-M)*v),c=P+Math.round((A-P)*v),g=z+Math.round((D-z)*v),{css:_.toCss(h,c,g),rgba:_.toRgba(h,c,g)}},C.isOpaque=function(E){return(255&E.rgba)==255},C.ensureContrastRatio=function(E,y,j){const A=d.ensureContrastRatio(E.rgba,y.rgba,j);if(A)return d.toColor(A>>24&255,A>>16&255,A>>8&255)},C.opaque=function(E){const y=(255|E.rgba)>>>0;return[h,c,g]=d.toChannels(y),{css:_.toCss(h,c,g),rgba:y}},C.opacity=k,C.multiplyOpacity=function(E,y){return v=255&E.rgba,k(E,v*y/255)},C.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(w||(i.color=w={})),(function(C){let k,E;if(!a.isNode){const y=document.createElement("canvas");y.width=1,y.height=1;const j=y.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=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 j=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(j)return h=parseInt(j[1]),c=parseInt(j[2]),g=parseInt(j[3]),v=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),d.toColor(h,c,g,v);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,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(E,y,j){const A=E/255,D=y/255,M=j/255;return .2126*(A<=.03928?A/12.92:Math.pow((A+.055)/1.055,2.4))+.7152*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))+.0722*(M<=.03928?M/12.92:Math.pow((M+.055)/1.055,2.4))}C.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},C.relativeLuminance2=k})(u||(i.rgb=u={})),(function(C){function k(y,j,A){const D=y>>24&255,M=y>>16&255,P=y>>8&255;let z=j>>24&255,L=j>>16&255,W=j>>8&255,$=S(u.relativeLuminance2(z,L,W),u.relativeLuminance2(D,M,P));for(;$<A&&(z>0||L>0||W>0);)z-=Math.max(0,Math.ceil(.1*z)),L-=Math.max(0,Math.ceil(.1*L)),W-=Math.max(0,Math.ceil(.1*W)),$=S(u.relativeLuminance2(z,L,W),u.relativeLuminance2(D,M,P));return(z<<24|L<<16|W<<8|255)>>>0}function E(y,j,A){const D=y>>24&255,M=y>>16&255,P=y>>8&255;let z=j>>24&255,L=j>>16&255,W=j>>8&255,$=S(u.relativeLuminance2(z,L,W),u.relativeLuminance2(D,M,P));for(;$<A&&(z<255||L<255||W<255);)z=Math.min(255,z+Math.ceil(.1*(255-z))),L=Math.min(255,L+Math.ceil(.1*(255-L))),W=Math.min(255,W+Math.ceil(.1*(255-W))),$=S(u.relativeLuminance2(z,L,W),u.relativeLuminance2(D,M,P));return(z<<24|L<<16|W<<8|255)>>>0}C.ensureContrastRatio=function(y,j,A){const D=u.relativeLuminance(y>>8),M=u.relativeLuminance(j>>8);if(S(D,M)<A){if(M<D){const L=k(y,j,A),W=S(D,u.relativeLuminance(L>>8));if(W<A){const $=E(y,j,A);return W>S(D,u.relativeLuminance($>>8))?L:$}return L}const P=E(y,j,A),z=S(D,u.relativeLuminance(P>>8));if(z<A){const L=k(y,j,A);return z>S(D,u.relativeLuminance(L>>8))?P:L}return P}},C.reduceLuminance=k,C.increaseLuminance=E,C.toChannels=function(y){return[y>>24&255,y>>16&255,y>>8&255,255&y]},C.toColor=function(y,j,A,D){return{css:_.toCss(y,j,A,D),rgba:_.toRgba(y,j,A,D)}}})(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),E=n(2660);let y=!1;class j extends a.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new l.EventEmitter),this._onScroll.event((D=>{var M;(M=this._onScrollApi)===null||M===void 0||M.fire(D.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(D){for(const M in D)this.optionsService.options[M]=D[M]}constructor(D){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(D)),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(E.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,P)=>this._inputHandler.parse(M,P)))),this.register((0,l.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(D,M){this._writeBuffer.write(D,M)}writeSync(D,M){this._logService.logLevel<=h.LogLevelEnum.WARN&&!y&&(this._logService.warn("writeSync is unreliable and will be removed soon."),y=!0),this._writeBuffer.writeSync(D,M)}resize(D,M){isNaN(D)||isNaN(M)||(D=Math.max(D,v.MINIMUM_COLS),M=Math.max(M,v.MINIMUM_ROWS),this._bufferService.resize(D,M))}scroll(D,M=!1){this._bufferService.scroll(D,M)}scrollLines(D,M,P){this._bufferService.scrollLines(D,M,P)}scrollPages(D){this.scrollLines(D*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(D){const M=D-this._bufferService.buffer.ydisp;M!==0&&this.scrollLines(M)}registerEscHandler(D,M){return this._inputHandler.registerEscHandler(D,M)}registerDcsHandler(D,M){return this._inputHandler.registerDcsHandler(D,M)}registerCsiHandler(D,M){return this._inputHandler.registerCsiHandler(D,M)}registerOscHandler(D,M){return this._inputHandler.registerOscHandler(D,M)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let D=!1;const M=this.optionsService.rawOptions.windowsPty;M&&M.buildNumber!==void 0&&M.buildNumber!==void 0?D=M.backend==="conpty"&&M.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(D=!0),D?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const D=[];D.push(this.onLineFeed(S.updateWindowsModeWrappedState.bind(null,this._bufferService))),D.push(this.registerCsiHandler({final:"H"},(()=>((0,S.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,a.toDisposable)((()=>{for(const M of D)M.dispose()}))}}}i.CoreTerminal=j},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($,R,I,T){var O,q=arguments.length,V=q<3?R:T===null?T=Object.getOwnPropertyDescriptor(R,I):T;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")V=Reflect.decorate($,R,I,T);else for(var B=$.length-1;B>=0;B--)(O=$[B])&&(V=(q<3?O(V):q>3?O(R,I,V):O(R,I))||V);return q>3&&V&&Object.defineProperty(R,I,V),V},h=this&&this.__param||function($,R){return function(I,T){R(I,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),E=n(6351),y=n(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},A=131072;function D($,R){if($>24)return R.setWinLines||!1;switch($){case 1:return!!R.restoreWin;case 2:return!!R.minimizeWin;case 3:return!!R.setWinPosition;case 4:return!!R.setWinSizePixels;case 5:return!!R.raiseWin;case 6:return!!R.lowerWin;case 7:return!!R.refreshWin;case 8:return!!R.setWinSizeChars;case 9:return!!R.maximizeWin;case 10:return!!R.fullscreenWin;case 11:return!!R.getWinState;case 13:return!!R.getWinPosition;case 14:return!!R.getWinSizePixels;case 15:return!!R.getScreenSizePixels;case 16:return!!R.getCellSizePixels;case 18:return!!R.getWinSizeChars;case 19:return!!R.getScreenSizeChars;case 20:return!!R.getIconTitle;case 21:return!!R.getWinTitle;case 22:return!!R.pushTitle;case 23:return!!R.popTitle;case 24:return!!R.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 P=0;class z extends _.Disposable{getAttrData(){return this._curAttrData}constructor(R,I,T,O,q,V,B,U,H=new v.EscapeSequenceParser){super(),this._bufferService=R,this._charsetService=I,this._coreService=T,this._logService=O,this._optionsService=q,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 L(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,K)=>{this._logService.debug("Unknown OSC code: ",{identifier:N,action:F,data:K})})),this._parser.setDcsHandlerFallback(((N,F,K)=>{F==="HOOK"&&(K=K.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(N),action:F,payload:K})})),this._parser.setPrintHandler(((N,F,K)=>this.print(N,F,K))),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 E.DcsHandler(((N,F)=>this.requestStatusString(N,F))))}_preserveStack(R,I,T,O){this._parseStack.paused=!0,this._parseStack.cursorStartX=R,this._parseStack.cursorStartY=I,this._parseStack.decodedLength=T,this._parseStack.position=O}_logSlowResolvingAsync(R){this._logService.logLevel<=C.LogLevelEnum.WARN&&Promise.race([R,new Promise(((I,T)=>setTimeout((()=>T("#SLOW_TIMEOUT")),5e3)))]).catch((I=>{if(I!=="#SLOW_TIMEOUT")throw I;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(R,I){let T,O=this._activeBuffer.x,q=this._activeBuffer.y,V=0;const B=this._parseStack.paused;if(B){if(T=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,I))return this._logSlowResolvingAsync(T),T;O=this._parseStack.cursorStartX,q=this._parseStack.cursorStartY,this._parseStack.paused=!1,R.length>A&&(V=this._parseStack.position+A)}if(this._logService.logLevel<=C.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof R=="string"?` "${R}"`:` "${Array.prototype.map.call(R,(U=>String.fromCharCode(U))).join("")}"`),typeof R=="string"?R.split("").map((U=>U.charCodeAt(0))):R),this._parseBuffer.length<R.length&&this._parseBuffer.length<A&&(this._parseBuffer=new Uint32Array(Math.min(R.length,A))),B||this._dirtyRowTracker.clearRange(),R.length>A)for(let U=V;U<R.length;U+=A){const H=U+A<R.length?U+A:R.length,N=typeof R=="string"?this._stringDecoder.decode(R.substring(U,H),this._parseBuffer):this._utf8Decoder.decode(R.subarray(U,H),this._parseBuffer);if(T=this._parser.parse(this._parseBuffer,N))return this._preserveStack(O,q,N,U),this._logSlowResolvingAsync(T),T}else if(!B){const U=typeof R=="string"?this._stringDecoder.decode(R,this._parseBuffer):this._utf8Decoder.decode(R,this._parseBuffer);if(T=this._parser.parse(this._parseBuffer,U))return this._preserveStack(O,q,U,0),this._logSlowResolvingAsync(T),T}this._activeBuffer.x===O&&this._activeBuffer.y===q||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(R,I,T){let O,q;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 K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&T-I>0&&K.getWidth(this._activeBuffer.x-1)===2&&K.setCellFromCodePoint(this._activeBuffer.x-1,0,1,F.fg,F.bg,F.extended);for(let Y=I;Y<T;++Y){if(O=R[Y],q=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),q||!this._activeBuffer.x){if(this._activeBuffer.x+q-1>=U){if(H){for(;this._activeBuffer.x<U;)K.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),K=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=U-1,q===2)continue}if(N&&(K.insertCells(this._activeBuffer.x,q,this._activeBuffer.getNullCell(F),F),K.getWidth(U-1)===2&&K.setCellFromCodePoint(U-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,F.fg,F.bg,F.extended)),K.setCellFromCodePoint(this._activeBuffer.x++,O,q,F.fg,F.bg,F.extended),q>0)for(;--q;)K.setCellFromCodePoint(this._activeBuffer.x++,0,0,F.fg,F.bg,F.extended)}else K.getWidth(this._activeBuffer.x-1)?K.addCodepointToCell(this._activeBuffer.x-1,O):K.addCodepointToCell(this._activeBuffer.x-2,O)}T-I>0&&(K.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-I>0&&K.getWidth(this._activeBuffer.x)===0&&!K.hasContent(this._activeBuffer.x)&&K.setCellFromCodePoint(this._activeBuffer.x,0,1,F.fg,F.bg,F.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(R,I){return R.final!=="t"||R.prefix||R.intermediates?this._parser.registerCsiHandler(R,I):this._parser.registerCsiHandler(R,(T=>!D(T.params[0],this._optionsService.rawOptions.windowOptions)||I(T)))}registerDcsHandler(R,I){return this._parser.registerDcsHandler(R,new E.DcsHandler(I))}registerEscHandler(R,I){return this._parser.registerEscHandler(R,I)}registerOscHandler(R,I){return this._parser.registerOscHandler(R,new k.OscHandler(I))}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 R;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&&(!((R=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||R===void 0)&&R.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);I.hasWidth(this._activeBuffer.x)&&!I.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const R=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-R),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(R=this._bufferService.cols-1){this._activeBuffer.x=Math.min(R,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(R,I){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=R,this._activeBuffer.y=this._activeBuffer.scrollTop+I):(this._activeBuffer.x=R,this._activeBuffer.y=I),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(R,I){this._restrictCursor(),this._setCursor(this._activeBuffer.x+R,this._activeBuffer.y+I)}cursorUp(R){const I=this._activeBuffer.y-this._activeBuffer.scrollTop;return I>=0?this._moveCursor(0,-Math.min(I,R.params[0]||1)):this._moveCursor(0,-(R.params[0]||1)),!0}cursorDown(R){const I=this._activeBuffer.scrollBottom-this._activeBuffer.y;return I>=0?this._moveCursor(0,Math.min(I,R.params[0]||1)):this._moveCursor(0,R.params[0]||1),!0}cursorForward(R){return this._moveCursor(R.params[0]||1,0),!0}cursorBackward(R){return this._moveCursor(-(R.params[0]||1),0),!0}cursorNextLine(R){return this.cursorDown(R),this._activeBuffer.x=0,!0}cursorPrecedingLine(R){return this.cursorUp(R),this._activeBuffer.x=0,!0}cursorCharAbsolute(R){return this._setCursor((R.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(R){return this._setCursor(R.length>=2?(R.params[1]||1)-1:0,(R.params[0]||1)-1),!0}charPosAbsolute(R){return this._setCursor((R.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(R){return this._moveCursor(R.params[0]||1,0),!0}linePosAbsolute(R){return this._setCursor(this._activeBuffer.x,(R.params[0]||1)-1),!0}vPositionRelative(R){return this._moveCursor(0,R.params[0]||1),!0}hVPosition(R){return this.cursorPosition(R),!0}tabClear(R){const I=R.params[0];return I===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:I===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(R){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=R.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(R){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let I=R.params[0]||1;for(;I--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(R){const I=R.params[0];return I===1&&(this._curAttrData.bg|=536870912),I!==2&&I!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(R,I,T,O=!1,q=!1){const V=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);V.replaceCells(I,T,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),q),O&&(V.isWrapped=!1)}_resetBufferLine(R,I=!1){const T=this._activeBuffer.lines.get(this._activeBuffer.ybase+R);T&&(T.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),I),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+R),T.isWrapped=!1)}eraseInDisplay(R,I=!1){let T;switch(this._restrictCursor(this._bufferService.cols),R.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,I);T<this._bufferService.rows;T++)this._resetBufferLine(T,I);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,I),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(T+1).isWrapped=!1);T--;)this._resetBufferLine(T,I);this._dirtyRowTracker.markDirty(0);break;case 2:for(T=this._bufferService.rows,this._dirtyRowTracker.markDirty(T-1);T--;)this._resetBufferLine(T,I);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(R,I=!1){switch(this._restrictCursor(this._bufferService.cols),R.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,I);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,I);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,I)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(R){this._restrictCursor();let I=R.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,q=this._bufferService.rows-1+this._activeBuffer.ybase-O+1;for(;I--;)this._activeBuffer.lines.splice(q-1,1),this._activeBuffer.lines.splice(T,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(R){this._restrictCursor();let I=R.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;I--;)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(R){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.insertCells(this._activeBuffer.x,R.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(R){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.deleteCells(this._activeBuffer.x,R.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(R){let I=R.params[0]||1;for(;I--;)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(R){let I=R.params[0]||1;for(;I--;)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(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=R.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,I,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=R.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,I,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=R.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,I,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(R){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=R.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,I,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),O.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(R){this._restrictCursor();const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return I&&(I.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(R.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(R){if(!this._parser.precedingCodepoint)return!0;const I=R.params[0]||1,T=new Uint32Array(I);for(let O=0;O<I;++O)T[O]=this._parser.precedingCodepoint;return this.print(T,0,T.length),!0}sendDeviceAttributesPrimary(R){return R.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(R){return R.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(R.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(c.C0.ESC+"[>83;40003;0c")),!0}_is(R){return(this._optionsService.rawOptions.termName+"").indexOf(R)===0}setMode(R){for(let I=0;I<R.length;I++)switch(R.params[I]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(R){for(let I=0;I<R.length;I++)switch(R.params[I]){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(R){for(let I=0;I<R.length;I++)switch(R.params[I]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(R){for(let I=0;I<R.length;I++)switch(R.params[I]){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(),R.params[I]===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(R,I){const T=this._coreService.decPrivateModes,{activeProtocol:O,activeEncoding:q}=this._coreMouseService,V=this._coreService,{buffers:B,cols:U}=this._bufferService,{active:H,alt:N}=B,F=this._optionsService.rawOptions,K=me=>me?1:2,Y=R.params[0];return se=Y,G=I?Y===2?4:Y===4?K(V.modes.insertMode):Y===12?3:Y===20?K(F.convertEol):0:Y===1?K(T.applicationCursorKeys):Y===3?F.windowOptions.setWinLines?U===80?2:U===132?1:0:0:Y===6?K(T.origin):Y===7?K(T.wraparound):Y===8?3:Y===9?K(O==="X10"):Y===12?K(F.cursorBlink):Y===25?K(!V.isCursorHidden):Y===45?K(T.reverseWraparound):Y===66?K(T.applicationKeypad):Y===67?4:Y===1e3?K(O==="VT200"):Y===1002?K(O==="DRAG"):Y===1003?K(O==="ANY"):Y===1004?K(T.sendFocus):Y===1005?4:Y===1006?K(q==="SGR"):Y===1015?4:Y===1016?K(q==="SGR_PIXELS"):Y===1048?1:Y===47||Y===1047||Y===1049?K(H===N):Y===2004?K(T.bracketedPasteMode):0,V.triggerDataEvent(`${c.C0.ESC}[${I?"":"?"}${se};${G}$y`),!0;var se,G}_updateAttrColor(R,I,T,O,q){return I===2?(R|=50331648,R&=-16777216,R|=S.AttributeData.fromColorRGB([T,O,q])):I===5&&(R&=-50331904,R|=33554432|255&T),R}_extractColor(R,I,T){const O=[0,0,-1,0,0,0];let q=0,V=0;do{if(O[V+q]=R.params[I+V],R.hasSubParams(I+V)){const B=R.getSubParams(I+V);let U=0;do O[1]===5&&(q=1),O[V+U+1+q]=B[U];while(++U<B.length&&U+V+1+q<O.length);break}if(O[1]===5&&V+q>=2||O[1]===2&&V+q>=5)break;O[1]&&(q=1)}while(++V+I<R.length&&V+q<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(R,I){I.extended=I.extended.clone(),(!~R||R>5)&&(R=1),I.extended.underlineStyle=R,I.fg|=268435456,R===0&&(I.fg&=-268435457),I.updateExtended()}_processSGR0(R){R.fg=l.DEFAULT_ATTR_DATA.fg,R.bg=l.DEFAULT_ATTR_DATA.bg,R.extended=R.extended.clone(),R.extended.underlineStyle=0,R.extended.underlineColor&=-67108864,R.updateExtended()}charAttributes(R){if(R.length===1&&R.params[0]===0)return this._processSGR0(this._curAttrData),!0;const I=R.length;let T;const O=this._curAttrData;for(let q=0;q<I;q++)T=R.params[q],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(R.hasSubParams(q)?R.getSubParams(q)[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?q+=this._extractColor(R,q,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(R){switch(R.params[0]){case 5:this._coreService.triggerDataEvent(`${c.C0.ESC}[0n`);break;case 6:const I=this._activeBuffer.y+1,T=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[${I};${T}R`)}return!0}deviceStatusPrivate(R){if(R.params[0]===6){const I=this._activeBuffer.y+1,T=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${c.C0.ESC}[?${I};${T}R`)}return!0}softReset(R){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(R){const I=R.params[0]||1;switch(I){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=I%2==1;return this._optionsService.options.cursorBlink=T,!0}setScrollRegion(R){const I=R.params[0]||1;let T;return(R.length<2||(T=R.params[1])>this._bufferService.rows||T===0)&&(T=this._bufferService.rows),T>I&&(this._activeBuffer.scrollTop=I-1,this._activeBuffer.scrollBottom=T-1,this._setCursor(0,0)),!0}windowOptions(R){if(!D(R.params[0],this._optionsService.rawOptions.windowOptions))return!0;const I=R.length>1?R.params[1]:0;switch(R.params[0]){case 14:I!==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:I!==0&&I!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),I!==0&&I!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:I!==0&&I!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),I!==0&&I!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(R){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(R){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(R){return this._windowTitle=R,this._onTitleChange.fire(R),!0}setIconName(R){return this._iconName=R,!0}setOrReportIndexedColor(R){const I=[],T=R.split(";");for(;T.length>1;){const O=T.shift(),q=T.shift();if(/^\d+$/.exec(O)){const V=parseInt(O);if(W(V))if(q==="?")I.push({type:0,index:V});else{const B=(0,y.parseColor)(q);B&&I.push({type:1,index:V,color:B})}}}return I.length&&this._onColor.fire(I),!0}setHyperlink(R){const I=R.split(";");return!(I.length<2)&&(I[1]?this._createHyperlink(I[0],I[1]):!I[0]&&this._finishHyperlink())}_createHyperlink(R,I){this._getCurrentLinkId()&&this._finishHyperlink();const T=R.split(":");let O;const q=T.findIndex((V=>V.startsWith("id=")));return q!==-1&&(O=T[q].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:O,uri:I}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(R,I){const T=R.split(";");for(let O=0;O<T.length&&!(I>=this._specialColors.length);++O,++I)if(T[O]==="?")this._onColor.fire([{type:0,index:this._specialColors[I]}]);else{const q=(0,y.parseColor)(T[O]);q&&this._onColor.fire([{type:1,index:this._specialColors[I],color:q}])}return!0}setOrReportFgColor(R){return this._setOrReportSpecialColor(R,0)}setOrReportBgColor(R){return this._setOrReportSpecialColor(R,1)}setOrReportCursorColor(R){return this._setOrReportSpecialColor(R,2)}restoreIndexedColor(R){if(!R)return this._onColor.fire([{type:2}]),!0;const I=[],T=R.split(";");for(let O=0;O<T.length;++O)if(/^\d+$/.exec(T[O])){const q=parseInt(T[O]);W(q)&&I.push({type:2,index:q})}return I.length&&this._onColor.fire(I),!0}restoreFgColor(R){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(R){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(R){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(R){return R.length!==2?(this.selectDefaultCharset(),!0):(R[0]==="/"||this._charsetService.setgCharset(j[R[0]],g.CHARSETS[R[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 R=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,R,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(R){return this._charsetService.setgLevel(R),!0}screenAlignmentPattern(){const R=new f.CellData;R.content=4194373,R.fg=this._curAttrData.fg,R.bg=this._curAttrData.bg,this._setCursor(0,0);for(let I=0;I<this._bufferService.rows;++I){const T=this._activeBuffer.ybase+this._activeBuffer.y+I,O=this._activeBuffer.lines.get(T);O&&(O.fill(R),O.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(R,I){const T=this._bufferService.buffer,O=this._optionsService.rawOptions;return(q=>(this._coreService.triggerDataEvent(`${c.C0.ESC}${q}${c.C0.ESC}\\`),!0))(R==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:R==='"p'?'P1$r61;1"p':R==="r"?`P1$r${T.scrollTop+1};${T.scrollBottom+1}r`:R==="m"?"P1$r0m":R===" q"?`P1$r${{block:2,underline:4,bar:6}[O.cursorStyle]-(O.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(R,I){this._dirtyRowTracker.markRangeDirty(R,I)}}i.InputHandler=z;let L=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($,R){$>R&&(P=$,$=R,R=P),$<this.start&&(this.start=$),R>this.end&&(this.end=R)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function W($){return 0<=$&&$<256}L=a([h(0,C.IBufferService)],L)},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 E=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+E+1?(this.ybase--,E++,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),E&&(this.y+=E),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 E=0;E<this.lines.length;E++)C+=+this.lines.get(E).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 E=this.lines.length-1;E>=0;E--){let y=this.lines.get(E);if(!y||!y.isWrapped&&y.getTrimmedLength()<=d)continue;const j=[y];for(;y.isWrapped&&E>0;)y=this.lines.get(--E),j.unshift(y);const A=this.ybase+this.y;if(A>=E&&A<E+j.length)continue;const D=j[j.length-1].getTrimmedLength(),M=(0,v.reflowSmallerGetNewLineLengths)(j,this._cols,d),P=M.length-j.length;let z;z=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+P):Math.max(0,this.lines.length-this.lines.maxLength+P);const L=[];for(let O=0;O<P;O++){const q=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);L.push(q)}L.length>0&&(C.push({start:E+j.length+k,newLines:L}),k+=L.length),j.push(...L);let W=M.length-1,$=M[W];$===0&&(W--,$=M[W]);let R=j.length-P-1,I=D;for(;R>=0;){const O=Math.min(I,$);if(j[W]===void 0)break;if(j[W].copyCellsFrom(j[R],I-O,$-O,O,!0),$-=O,$===0&&(W--,$=M[W]),I-=O,I===0){R--;const q=Math.max(R,0);I=(0,v.getWrappedLineTrimmedLength)(j,q,this._cols)}}for(let O=0;O<j.length;O++)M[O]<d&&j[O].setCell(M[O],S);let T=P-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+P,this.ybase+f-1)}if(C.length>0){const E=[],y=[];for(let W=0;W<this.lines.length;W++)y.push(this.lines.get(W));const j=this.lines.length;let A=j-1,D=0,M=C[D];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let P=0;for(let W=Math.min(this.lines.maxLength-1,j+k-1);W>=0;W--)if(M&&M.start>A+P){for(let $=M.newLines.length-1;$>=0;$--)this.lines.set(W--,M.newLines[$]);W++,E.push({index:A+1,amount:M.newLines.length}),P+=M.newLines.length,M=C[++D]}else this.lines.set(W,y[A--]);let z=0;for(let W=E.length-1;W>=0;W--)E[W].index+=z,this.lines.onInsertEmitter.fire(E[W]),z+=E[W].amount;const L=Math.max(0,j+k-this.lines.maxLength);L>0&&this.lines.onTrimEmitter.fire(L)}}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 E=f-1;E>=0;E--){for(let y=0;y<3;y++)this._data[3*(d+E)+y]=C[3*(u+E)+y];268435456&C[3*(u+E)+2]&&(this._extendedAttrs[d+E]=l._extendedAttrs[u+E])}else for(let E=0;E<f;E++){for(let y=0;y<3;y++)this._data[3*(d+E)+y]=C[3*(u+E)+y];268435456&C[3*(u+E)+2]&&(this._extendedAttrs[d+E]=l._extendedAttrs[u+E])}const k=Object.keys(l._combined);for(let E=0;E<k.length;E++){const y=parseInt(k[E],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),j=y-k,A=c-S,D=Math.min(j,A);d[f].copyCellsFrom(d[C],k,S,D,!1),S+=D,S===c&&(f++,S=0),k+=D,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 E=0;for(let y=d.length-1;y>0&&(y>f||d[y].getTrimmedLength()===0);y--)E++;E>0&&(_.push(w+d.length-E),_.push(E)),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,E=0;for(;(k=63&this.interim[++E])&&E<4;)C<<=6,C|=k;const y=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=y-E;for(;u<j;){if(u>=h)return 0;if(k=n[u++],(192&k)!=128){u--,S=!0;break}this.interim[E++]=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(((E,y)=>y)),d=(E,y)=>u.slice(E,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,E=0;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,E=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 j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(f===!1&&j>-1){for(;j>=0&&(S=y[j](this._params),S!==!0);j--)if(S instanceof Promise)return this._parseStack.handlerPos=j,S}this._parseStack.handlers=[];break;case 4:if(f===!1&&j>-1){for(;j>=0&&(S=y[j](),S!==!0);j--)if(S instanceof Promise)return this._parseStack.handlerPos=j,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,E=this._parseStack.chunkPos+1,this.precedingCodepoint=0,this.currentState=15&this._parseStack.transition}for(let y=E;y<d;++y){switch(C=u[y],k=this._transitions.table[this.currentState<<8|(C<160?C:_)],k>>4){case 2:for(let P=y+1;;++P){if(P>=d||(C=u[P])<32||C>126&&C<_){this._printHandler(u,y,P),y=P-1;break}if(++P>=d||(C=u[P])<32||C>126&&C<_){this._printHandler(u,y,P),y=P-1;break}if(++P>=d||(C=u[P])<32||C>126&&C<_){this._printHandler(u,y,P),y=P-1;break}if(++P>=d||(C=u[P])<32||C>126&&C<_){this._printHandler(u,y,P),y=P-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 j=this._csiHandlers[this._collect<<8|C];let A=j?j.length-1:-1;for(;A>=0&&(S=j[A](this._params),S!==!0);A--)if(S instanceof Promise)return this._preserveStack(3,j,A,k,y),S;A<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 D=this._escHandlers[this._collect<<8|C];let M=D?D.length-1:-1;for(;M>=0&&(S=D[M](),S!==!0);M--)if(S instanceof Promise)return this._preserveStack(4,D,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 P=y+1;;++P)if(P>=d||(C=u[P])===24||C===26||C===27||C>127&&C<_){this._dcsParser.put(u,y,P),y=P-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 P=y+1;;P++)if(P>=d||(C=u[P])<32||C>127&&C<_){this._oscParser.put(u,y,P),y=P-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 E=l.length-1;E>=0;E--)(S=l[E])&&(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 E,y=arguments.length,j=y<3?S:k===null?k=Object.getOwnPropertyDescriptor(S,C):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(f,S,C,k);else for(var A=f.length-1;A>=0;A--)(E=f[A])&&(j=(y<3?E(j):y>3?E(S,C,j):E(S,C))||j);return y>3&&j&&Object.defineProperty(S,C,j),j},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,E=arguments.length,y=E<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 j=d.length-1;j>=0;j--)(k=d[j])&&(y=(E<3?k(y):E>3?k(f,S,y):k(f,S))||y);return E>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,E;let y=0,j=0;for(const A of this._decorations.getKeyIterator(f))y=(C=A.options.x)!==null&&C!==void 0?C:0,j=y+((k=A.options.width)!==null&&k!==void 0?k:1),d>=y&&d<j&&(!S||((E=A.options.layer)!==null&&E!==void 0?E:"bottom")===S)&&(yield A)}forEachDecorationAtCell(d,f,S,C){this._decorations.forEachByKey(f,(k=>{var E,y,j;v=(E=k.options.x)!==null&&E!==void 0?E:0,_=v+((y=k.options.width)!==null&&y!==void 0?y:1),d>=v&&d<_&&(!S||((j=k.options.layer)!==null&&j!==void 0?j:"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 E=l.length-1;E>=0;E--)(S=l[E])&&(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})()))})(Xi)),Xi.exports}var fp=hp();var mp=2,pp=1,gp=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(mp,Math.floor(h/e.css.cell.width)),rows:Math.max(pp,Math.floor(a/e.css.cell.height))}}};function vp(e={}){const{cwd:s,cols:r,rows:o,onOutput:p,onExit:m}=e,[x,i]=b.useState(null),[n,a]=b.useState(()=>ls.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=ls.getSocket(),E=()=>{a(!0),c(!1),i(null),w(!0)},y=()=>{a(!1),c(!1)},j=P=>{P.terminalId===x&&l.current.onOutput?.(P.data)},A=P=>{P.terminalId===x&&(c(!1),l.current.onExit?.(P.exitCode),i(null))},D=P=>{P.terminalId===x&&c(!0)},M=P=>{P.terminalId===x&&c(!1)};return k.on("connect",E),k.on("disconnect",y),k.on(dt.TERMINAL_STDOUT,j),k.on(dt.TERMINAL_EXIT,A),k.on(dt.TERMINAL_SUBSCRIBED,D),k.on(dt.TERMINAL_UNSUBSCRIBED,M),a(k.connected),k.connected&&k.emit(Fs.SUBSCRIBE,{topic:"terminal",id:x},P=>{P.success&&c(!0)}),()=>{k.off("connect",E),k.off("disconnect",y),k.off(dt.TERMINAL_STDOUT,j),k.off(dt.TERMINAL_EXIT,A),k.off(dt.TERMINAL_SUBSCRIBED,D),k.off(dt.TERMINAL_UNSUBSCRIBED,M),k.emit(Fs.UNSUBSCRIBE,{topic:"terminal",id:x})}},[x]);const d=b.useCallback(async()=>{const k=ls.getSocket();if(!k.connected)return null;v(!0);try{const E=await Ae.post("/terminals",{socketId:k.id,cwd:s,cols:r,rows:o});return i(E.terminalId),w(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{v(!1)}},[s,r,o]),f=b.useCallback(async()=>{const k=u.current;if(k){try{await Ae.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}i(null),c(!1)}},[]),S=b.useCallback(k=>{const E=u.current;if(!E)return;ls.getSocket().emit(Fs.TERMINAL_INPUT,{terminalId:E,data:k})},[]),C=b.useCallback((k,E)=>{const y=u.current;if(!y)return;ls.getSocket().emit(Fs.TERMINAL_RESIZE,{terminalId:y,cols:k,rows:E})},[]);return b.useEffect(()=>()=>{const k=u.current;k&&Ae.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:x,isConnected:n,isAttached:h,isCreating:g,needsRecreate:_,create:d,destroy:f,sendInput:S,resize:C}}function xp({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 bp={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"},_p=de.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:_}=vp({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}=xp({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 fp.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:bp,scrollback:5e3,convertEol:!0}),d=new gp;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"})]})}),yp=de.memo(function({commands:s,onSelect:r}){const{t:o}=ce(),[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(ou,{size:12}),t.jsx("span",{children:o("快捷命令")}),t.jsx(Ct,{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(Cs,{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))})})]})]})}),rc="\x1B",Sp="\x07",wp="œ";function Cp(e){const s=e.charCodeAt(0);return s>=64&&s<=126}function ia(e,s){let r=s;for(;r<e.length;){if(e[r]===Sp||e[r]===wp)return r+1;if(e[r]===rc&&e[r+1]==="\\")return r+2;r+=1}return r}function na(e,s){let r=s;for(;r<e.length&&!Cp(e[r]);)r+=1;return r<e.length?r+1:r}function kp(e){let s="";for(let r=0;r<e.length;){if(e[r]==="›"){r=na(e,r+1);continue}if(e[r]===""){r=ia(e,r+1);continue}if(e[r]!==rc){s+=e[r],r+=1;continue}const o=e[r+1];if(o==="["){r=na(e,r+2);continue}if(o==="]"||o==="P"||o==="X"||o==="^"||o==="_"){r=ia(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 Ep=200,jp=1e3,Np=512*1024;function Rp(e){let s=e.reduce((o,p)=>o+p.data.length,0),r=0;for(;e.length-r>jp||s>Np&&e.length-r>1;)s-=e[r].data.length,r+=1;return{entries:r>0?e.slice(r):e,trimmed:r>0}}function Ap(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=Rp(x);return{...s,entries:i.entries,reset:s.reset||r||!o&&(e?.reset??!1),truncated:s.truncated||!o&&(e?.truncated??!1)||i.trimmed}}function lo(e,s=!0){return Pt({queryKey:_e.workspaceServices.list(e),queryFn:async()=>(await Ae.get(`/workspaces/${encodeURIComponent(e)}/services`)).services,enabled:s&&!!e,refetchInterval:s&&e?3e3:!1,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}function Tp(e,s,r,o=!0){const p=Lt(),m=_e.workspaceServices.logs(e,s);return Pt({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(Ep)});n!==null&&a.set("runtimeInstanceId",n),a.set("afterSeq",String(i));const h=await Ae.get(`/workspaces/${encodeURIComponent(e)}/services/${encodeURIComponent(s)}/logs?${a}`);return Ap(x,h)},enabled:o&&!!e&&!!s,refetchInterval:x=>x.state.data?.hasMore?250:1e3,refetchIntervalInBackground:!1,refetchOnWindowFocus:"always",refetchOnReconnect:"always"})}const Mp=[];function Gi(e){return JSON.stringify([e.command,...e.args])}function oa(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 Dp(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 aa({state:e}){const{t:s}=ce(),r=Dp(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 Pp({message:e,onRetry:s}){const{t:r}=ce();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(Ns,{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(Rs,{size:13})})]})}function Lp({workspaceId:e,enabled:s=!0}){const{locale:r,t:o}=ce(),p=lo(e,s),m=p.data??Mp,[x,i]=b.useState(null),n=m.find(v=>v.name===x)??m[0]??null,a=Tp(e,n?.name??"",n?.runtimeInstanceId??null,s&&!!n),h=b.useMemo(()=>kp(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(fn,{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(Oe,{size:14,className:"animate-spin","aria-hidden":"true"}),o("Loading background services...")]}):p.isError?t.jsx(Pp,{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(fn,{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(aa,{state:v.runtimeState})]}),t.jsx("span",{className:"mt-1 block truncate font-mono text-[10px] text-neutral-500",title:Gi(v),children:Gi(v)}),t.jsxs("span",{className:"mt-1 flex min-w-0 items-center gap-1 text-[10px] text-neutral-500",children:[t.jsx(Yn,{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(us,{size:10,className:"shrink-0","aria-hidden":"true"}),t.jsx("span",{className:"truncate",children:oa(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(aa,{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:Gi(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(us,{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:oa(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(Rs,{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(Oe,{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 Qi=0;function la(){return Qi+=1,{id:`shell-${Qi}`,order:Qi}}const Ip=de.memo(function({cwd:s,isVisible:r=!0,workspaceId:o,quickCommands:p=[]}){const{t:m}=ce(),[x,i]=b.useState(()=>[la()]),[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),E=o?S:"terminals",y=b.useCallback(T=>{k.current.delete(T),c(O=>{if(!O.has(T))return O;const q=new Set(O);return q.delete(T),q})},[]),j=b.useCallback(()=>{const T=la();i(O=>[...O,T]),a(T.id)},[]),A=b.useCallback((T,O)=>{O.stopPropagation(),y(T),i(q=>{const V=q.filter(B=>B.id!==T);return T===n&&V.length>0&&a(V[V.length-1].id),V})},[n,y]),D=b.useCallback(T=>{y(T),i(O=>{const q=O.filter(V=>V.id!==T);return T===n&&q.length>0&&a(q[q.length-1].id),q})},[n,y]),M=b.useCallback((T,O)=>{k.current.set(T,O),c(q=>{if(q.has(T))return q;const V=new Set(q);return V.add(T),V})},[]),P=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)},[]),L=b.useCallback((T,O)=>{const q=k.current.get(T);return q?(q.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}L(n,O)}catch{z(n)}finally{v(!1)}},[n,z,L,m]),$=b.useCallback(()=>{!l||!d||!L(d,l)||(w(!1),u(""),f(null))},[l,L,d]),R=b.useCallback(()=>{w(!1),u(""),f(null)},[]),I=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":E==="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",E==="terminals"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(fr,{size:12,"aria-hidden":"true"}),m("Interactive terminals")]}),t.jsxs("button",{type:"button",onClick:()=>C("services"),"aria-pressed":E==="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",E==="services"?"bg-[#3a3a3a] text-neutral-100":"text-neutral-500 hover:bg-[#2d2d2d] hover:text-neutral-300"),children:[t.jsx(fn,{size:12,"aria-hidden":"true"}),m("Background services")]})]}),t.jsxs("div",{"aria-hidden":E!=="terminals",className:Z("min-h-0 flex-1 flex-col",E==="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(fr,{size:11,className:"shrink-0"}),t.jsx("span",{children:m("Shell {count}",{count:T.order})}),x.length>1&&t.jsx("span",{onClick:O=>A(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(Xt,{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:!I||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(Oe,{size:18,className:"animate-spin"}):t.jsx(Eu,{size:18})})]}),t.jsx("button",{type:"button",onClick:j,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(ds,{size:14})}),p.length>0&&t.jsx(yp,{commands:p,onSelect:P})]}),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(fr,{size:28}),t.jsx("span",{className:"text-xs",children:m("No terminals open")}),t.jsx("button",{onClick:j,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(_p,{cwd:s,isVisible:r&&E==="terminals"&&T.id===n,onExit:()=>D(T.id),onReady:O=>M(T.id,O)})},T.id))})]}),o&&E==="services"&&t.jsx("div",{className:"min-h-0 flex-1",children:t.jsx(Lp,{workspaceId:o,enabled:r})}),t.jsx(ps,{isOpen:_,onClose:R,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:R,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(hu,{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 ca(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 Op(e){if(Array.isArray(e))return e}function Bp(e,s,r){return(s=Kp(s))in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function Fp(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 zp(){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 da(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 ua(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?da(Object(r),!0).forEach(function(o){Bp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):da(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Wp(e,s){if(e==null)return{};var r,o,p=Hp(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 Hp(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 Up(e,s){return Op(e)||Fp(e,s)||qp(e,s)||zp()}function $p(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 Kp(e){var s=$p(e,"string");return typeof s=="symbol"?s:s+""}function qp(e,s){if(e){if(typeof e=="string")return ca(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)?ca(e,s):void 0}}function Vp(e,s,r){return s in e?Object.defineProperty(e,s,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[s]=r,e}function ha(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 fa(e){for(var s=1;s<arguments.length;s++){var r=arguments[s]!=null?arguments[s]:{};s%2?ha(Object(r),!0).forEach(function(o){Vp(e,o,r[o])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):ha(Object(r)).forEach(function(o){Object.defineProperty(e,o,Object.getOwnPropertyDescriptor(r,o))})}return e}function Yp(){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 hr(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 ui(e){return{}.toString.call(e).includes("Object")}function Xp(e){return!Object.keys(e).length}function wr(e){return typeof e=="function"}function Gp(e,s){return Object.prototype.hasOwnProperty.call(e,s)}function Qp(e,s){return ui(s)||fs("changeType"),Object.keys(s).some(function(r){return!Gp(e,r)})&&fs("changeField"),s}function Zp(e){wr(e)||fs("selectorType")}function Jp(e){wr(e)||ui(e)||fs("handlerType"),ui(e)&&Object.values(e).some(function(s){return!wr(s)})&&fs("handlersType")}function eg(e){e||fs("initialIsRequired"),ui(e)||fs("initialType"),Xp(e)&&fs("initialContent")}function tg(e,s){throw new Error(e[s]||e.default)}var sg={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"},fs=hr(tg)(sg),qr={changes:Qp,selector:Zp,handler:Jp,initial:eg};function rg(e){var s=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};qr.initial(e),qr.handler(s);var r={current:e},o=hr(og)(r,s),p=hr(ng)(r),m=hr(qr.changes)(e),x=hr(ig)(r);function i(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(h){return h};return qr.selector(a),a(r.current)}function n(a){Yp(o,p,m,x)(a)}return[i,n]}function ig(e,s){return wr(s)?s(e.current):s}function ng(e,s){return e.current=fa(fa({},e.current),s),s}function og(e,s,r){return wr(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 ag={create:rg},lg={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function cg(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 dg(e){return{}.toString.call(e).includes("Object")}function ug(e){return e||ma("configIsRequired"),dg(e)||ma("configType"),e.urls?(hg(),{paths:{vs:e.urls.monacoBase}}):e}function hg(){console.warn(ic.deprecation)}function fg(e,s){throw new Error(e[s]||e.default)}var ic={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
- `},ma=cg(fg)(ic),mg={config:ug},pg=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 nc(e,s){return Object.keys(s).forEach(function(r){s[r]instanceof Object&&e[r]&&Object.assign(s[r],nc(e[r],s[r]))}),ua(ua({},e),s)}var gg={type:"cancelation",msg:"operation is manually canceled"};function Zi(e){var s=!1,r=new Promise(function(o,p){e.then(function(m){return s?p(gg):o(m)}),e.catch(p)});return r.cancel=function(){return s=!0},r}var vg=["monaco"],xg=ag.create({config:lg,isInitialized:!1,resolve:null,reject:null,monaco:null}),oc=Up(xg,2),Ar=oc[0],ji=oc[1];function bg(e){var s=mg.config(e),r=s.monaco,o=Wp(s,vg);ji(function(p){return{config:nc(p.config,o),monaco:r}})}function _g(){var e=Ar(function(s){var r=s.monaco,o=s.isInitialized,p=s.resolve;return{monaco:r,isInitialized:o,resolve:p}});if(!e.isInitialized){if(ji({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Zi(Ji);if(window.monaco&&window.monaco.editor)return ac(window.monaco),e.resolve(window.monaco),Zi(Ji);pg(yg,wg)(Cg)}return Zi(Ji)}function yg(e){return document.body.appendChild(e)}function Sg(e){var s=document.createElement("script");return e&&(s.src=e),s}function wg(e){var s=Ar(function(o){var p=o.config,m=o.reject;return{config:p,reject:m}}),r=Sg("".concat(s.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=s.reject,r}function Cg(){var e=Ar(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;ac(o),e.resolve(o)},function(r){e.reject(r)})}function ac(e){Ar().monaco||ji({monaco:e})}function kg(){return Ar(function(e){var s=e.monaco;return s})}var Ji=new Promise(function(e,s){return ji({resolve:e,reject:s})}),lc={config:bg,init:_g,__getMonacoInstance:kg},Eg={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},en=Eg,jg={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},Ng=jg;function Rg({children:e}){return de.createElement("div",{style:Ng.container},e)}var Ag=Rg,Tg=Ag;function Mg({width:e,height:s,isEditorReady:r,loading:o,_ref:p,className:m,wrapperProps:x}){return de.createElement("section",{style:{...en.wrapper,width:e,height:s},...x},!r&&de.createElement(Tg,null,o),de.createElement("div",{ref:p,style:{...en.fullWidth,...!r&&en.hide},className:m}))}var Dg=Mg,cc=b.memo(Dg);function Pg(e){b.useEffect(e,[])}var dc=Pg;function Lg(e,s,r=!0){let o=b.useRef(!0);b.useEffect(o.current||!r?()=>{o.current=!1}:e,s)}var jt=Lg;function vr(){}function zs(e,s,r,o){return Ig(e,o)||Og(e,s,r,o)}function Ig(e,s){return e.editor.getModel(uc(e,s))}function Og(e,s,r,o){return e.editor.createModel(s,r,o?uc(e,o):void 0)}function uc(e,s){return e.Uri.parse(s)}function Bg({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=vr,onMount:u=vr}){let[d,f]=b.useState(!1),[S,C]=b.useState(!0),k=b.useRef(null),E=b.useRef(null),y=b.useRef(null),j=b.useRef(u),A=b.useRef(l),D=b.useRef(!1);dc(()=>{let L=lc.init();return L.then(W=>(E.current=W)&&C(!1)).catch(W=>W?.type!=="cancelation"&&console.error("Monaco initialization: error:",W)),()=>k.current?z():L.cancel()}),jt(()=>{if(k.current&&E.current){let L=k.current.getOriginalEditor(),W=zs(E.current,e||"",o||r||"text",m||"");W!==L.getModel()&&L.setModel(W)}},[m],d),jt(()=>{if(k.current&&E.current){let L=k.current.getModifiedEditor(),W=zs(E.current,s||"",p||r||"text",x||"");W!==L.getModel()&&L.setModel(W)}},[x],d),jt(()=>{let L=k.current.getModifiedEditor();L.getOption(E.current.editor.EditorOption.readOnly)?L.setValue(s||""):s!==L.getValue()&&(L.executeEdits("",[{range:L.getModel().getFullModelRange(),text:s||"",forceMoveMarkers:!0}]),L.pushUndoStop())},[s],d),jt(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),jt(()=>{let{original:L,modified:W}=k.current.getModel();E.current.editor.setModelLanguage(L,o||r||"text"),E.current.editor.setModelLanguage(W,p||r||"text")},[r,o,p],d),jt(()=>{E.current?.editor.setTheme(a)},[a],d),jt(()=>{k.current?.updateOptions(c)},[c],d);let M=b.useCallback(()=>{if(!E.current)return;A.current(E.current);let L=zs(E.current,e||"",o||r||"text",m||""),W=zs(E.current,s||"",p||r||"text",x||"");k.current?.setModel({original:L,modified:W})},[r,s,p,e,o,m,x]),P=b.useCallback(()=>{!D.current&&y.current&&(k.current=E.current.editor.createDiffEditor(y.current,{automaticLayout:!0,...c}),M(),E.current?.editor.setTheme(a),f(!0),D.current=!0)},[c,a,M]);b.useEffect(()=>{d&&j.current(k.current,E.current)},[d]),b.useEffect(()=>{!S&&!d&&P()},[S,d,P]);function z(){let L=k.current?.getModel();i||L?.original?.dispose(),n||L?.modified?.dispose(),k.current?.dispose()}return de.createElement(cc,{width:v,height:g,isEditorReady:d,loading:h,_ref:y,className:_,wrapperProps:w})}var Fg=Bg;b.memo(Fg);function zg(e){let s=b.useRef();return b.useEffect(()=>{s.current=e},[e]),s.current}var Wg=zg,Vr=new Map;function Hg({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=vr,onMount:d=vr,onChange:f,onValidate:S=vr}){let[C,k]=b.useState(!1),[E,y]=b.useState(!0),j=b.useRef(null),A=b.useRef(null),D=b.useRef(null),M=b.useRef(d),P=b.useRef(u),z=b.useRef(),L=b.useRef(o),W=Wg(m),$=b.useRef(!1),R=b.useRef(!1);dc(()=>{let O=lc.init();return O.then(q=>(j.current=q)&&y(!1)).catch(q=>q?.type!=="cancelation"&&console.error("Monaco initialization: error:",q)),()=>A.current?T():O.cancel()}),jt(()=>{let O=zs(j.current,e||o||"",s||p||"",m||r||"");O!==A.current?.getModel()&&(c&&Vr.set(W,A.current?.saveViewState()),A.current?.setModel(O),c&&A.current?.restoreViewState(Vr.get(m)))},[m],C),jt(()=>{A.current?.updateOptions(a)},[a],C),jt(()=>{!A.current||o===void 0||(A.current.getOption(j.current.editor.EditorOption.readOnly)?A.current.setValue(o):o!==A.current.getValue()&&(R.current=!0,A.current.executeEdits("",[{range:A.current.getModel().getFullModelRange(),text:o,forceMoveMarkers:!0}]),A.current.pushUndoStop(),R.current=!1))},[o],C),jt(()=>{let O=A.current?.getModel();O&&p&&j.current?.editor.setModelLanguage(O,p)},[p],C),jt(()=>{i!==void 0&&A.current?.revealLine(i)},[i],C),jt(()=>{j.current?.editor.setTheme(x)},[x],C);let I=b.useCallback(()=>{if(!(!D.current||!j.current)&&!$.current){P.current(j.current);let O=m||r,q=zs(j.current,o||e||"",s||p||"",O||"");A.current=j.current?.editor.create(D.current,{model:q,automaticLayout:!0,...a},h),c&&A.current.restoreViewState(Vr.get(O)),j.current.editor.setTheme(x),i!==void 0&&A.current.revealLine(i),k(!0),$.current=!0}},[e,s,r,o,p,m,a,h,c,x,i]);b.useEffect(()=>{C&&M.current(A.current,j.current)},[C]),b.useEffect(()=>{!E&&!C&&I()},[E,C,I]),L.current=o,b.useEffect(()=>{C&&f&&(z.current?.dispose(),z.current=A.current?.onDidChangeModelContent(O=>{R.current||f(A.current.getValue(),O)}))},[C,f]),b.useEffect(()=>{if(C){let O=j.current.editor.onDidChangeMarkers(q=>{let V=A.current.getModel()?.uri;if(V&&q.find(B=>B.path===V.path)){let B=j.current.editor.getModelMarkers({resource:V});S?.(B)}});return()=>{O?.dispose()}}return()=>{}},[C,S]);function T(){z.current?.dispose(),g?c&&Vr.set(m,A.current.saveViewState()):A.current.getModel()?.dispose(),A.current.dispose()}return de.createElement(cc,{width:v,height:_,isEditorReady:C,loading:n,_ref:D,className:w,wrapperProps:l})}var Ug=Hg,$g=b.memo(Ug),Kg=$g,Dt=function(e,s){return Number(e.toFixed(s))},qg=function(e,s){return typeof e=="number"?e:s},Ze=function(e,s,r){r&&typeof r=="function"&&r(e,s)},Vg=function(e){return-Math.cos(e*Math.PI)/2+.5},Yg=function(e){return e},Xg=function(e){return e*e},Gg=function(e){return e*(2-e)},Qg=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Zg=function(e){return e*e*e},Jg=function(e){return--e*e*e+1},ev=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},tv=function(e){return e*e*e*e},sv=function(e){return 1- --e*e*e*e},rv=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},iv=function(e){return e*e*e*e*e},nv=function(e){return 1+--e*e*e*e*e},ov=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},hc={easeOut:Vg,linear:Yg,easeInQuad:Xg,easeOutQuad:Gg,easeInOutQuad:Qg,easeInCubic:Zg,easeOutCubic:Jg,easeInOutCubic:ev,easeInQuart:tv,easeOutQuart:sv,easeInOutQuart:rv,easeInQuint:iv,easeOutQuint:nv,easeInOutQuint:ov},fc=function(e){typeof e=="number"&&cancelAnimationFrame(e)},zt=function(e){e.mounted&&(fc(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function mc(e,s,r,o){if(e.mounted){var p=new Date().getTime(),m=1;zt(e),e.animation=function(){if(!e.mounted)return fc(e.animation);var x=new Date().getTime()-p,i=x/r,n=hc[s],a=n(i);x>=r?(o(m),e.animation=null):e.animation&&(o(a),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function av(e){var s=e.scale,r=e.positionX,o=e.positionY;return!(Number.isNaN(s)||Number.isNaN(r)||Number.isNaN(o))}function vs(e,s,r,o){var p=av(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):mc(e,o,r,function(v){var _=i+h*v,w=n+c*v,l=a+g*v;m(_,w,l)})}}function lv(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 cv=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}},co=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=lv(r,o,s),x=m.wrapperWidth,i=m.wrapperHeight,n=m.newContentWidth,a=m.newDiffWidth,h=m.newContentHeight,c=m.newDiffHeight,g=cv(x,n,a,i,h,c,!!p);return g},Cn=function(e,s,r,o){return o?e<s?Dt(s,2):e>r?Dt(r,2):Dt(e,2):Dt(e,2)},ks=function(e,s){var r=co(e,s);return e.bounds=r,r};function Tr(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=Cn(e,i-c,a+c,o),_=Cn(s,n-g,h+g,o);return{x:v,y:_}}function Ni(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=Tr(c,g,p,m,0,0,null);return v}function Mr(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 pa=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=Ri(m,r);return!a},ga=function(e){var s=e.isInitialized,r=e.isPanning,o=e.setup,p=o.panning.disabled,m=s&&r&&!p;return!!m},dv=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}},uv=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 hv(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=Ni(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 pc(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=Tr(s,r,i,m,o,p,x),v=g.x,_=g.y;e.setTransformState(a,v,_)}}var fv=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}},gs=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},mv=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},pv=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 gv(e,s){var r=e.setup.velocityAnimation,o=r.equalToMove,p=r.animationTime,m=r.sensitivity;return o?p*s*m:p}function va(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:Cn(e,m,x,p)}function vv(e,s){var r=1;return s?Math.min(r,e.offsetWidth/window.innerWidth):r}function xv(e,s){var r=mv(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=vv(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 bv(e){var s=e.velocity,r=e.bounds,o=e.setup,p=e.wrapperComponent,m=pv(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,E=k,y=gv(e,n),j=Math.max(y,E),A=gs(e,S),D=gs(e,C),M=A*p.offsetWidth/100,P=D*p.offsetHeight/100,z=a+M,L=h-M,W=c+P,$=g-P,R=e.transformState,I=new Date().getTime();mc(e,f,j,function(T){var O=e.transformState,q=O.scale,V=O.positionX,B=O.positionY,U=new Date().getTime()-I,H=U/E,N=hc[_.animationType],F=1-N(Math.min(1,H)),K=1-T,Y=V+x*K,se=B+i*K,G=va(Y,R.positionX,V,d,v,h,a,L,z,F),me=va(se,R.positionY,B,u,v,g,c,$,W,F);(V!==Y||B!==se)&&e.setTransformState(q,G,me)})}}function xa(e,s){var r=e.transformState.scale;zt(e),ks(e,r),window.TouchEvent!==void 0&&s instanceof TouchEvent?uv(e,s):dv(e,s)}function uo(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=hv(e);g&&vs(e,g,s??a,h)}}function ba(e,s,r){var o=e.startCoords,p=e.setup,m=p.alignmentAnimation,x=m.sizeX,i=m.sizeY;if(o){var n=fv(e,s,r),a=n.x,h=n.y,c=gs(e,x),g=gs(e,i);xv(e,{x:a,y:h}),pc(e,a,h,c,g)}}function _v(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?bv(e):uo(e)}}function ho(e,s,r,o){var p=e.setup,m=p.minScale,x=p.maxScale,i=p.limitToBounds,n=Mr(Dt(s,2),m,x,0,!1),a=ks(e,n),h=Ni(e,r,o,n,a,i),c=h.x,g=h.y;return{scale:n,positionX:c,positionY:g}}function gc(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)&&uo(e),!(g||!p||!e.mounted)){var v=s||p.offsetWidth/2,_=r||p.offsetHeight/2,w=ho(e,x,v,_);w&&vs(e,w,h,c)}}var ms=function(){return ms=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},ms.apply(this,arguments)};function _a(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 Yr={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}},kn={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},vc=function(e){var s,r,o,p;return{previousScale:(s=e.initialScale)!==null&&s!==void 0?s:Yr.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Yr.scale,positionX:(o=e.initialPositionX)!==null&&o!==void 0?o:Yr.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:Yr.positionY}},ya=function(e){var s=ms({},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]=ms(ms({},lr[r]),e[r]):i?s[r]=_a(_a([],lr[r],!0),e[r]):s[r]=e[r]}}),s},xc=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=Mr(Dt(c,3),i,x,h,!1);return g};function bc(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,_=xc(e,s,r),w=ho(e,_,g,v);if(!w)return console.error("Error during zoom event. New transformation state was not calculated.");vs(e,w,o,p)}function _c(e,s,r,o){var p=e.setup,m=e.wrapperComponent,x=p.limitToBounds,i=vc(e.props),n=e.transformState,a=n.scale,h=n.positionX,c=n.positionY;if(m){var g=co(e,i.scale),v=Tr(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?.(),vs(e,_,s,r))}}function yv(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 Sv(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=yv(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=Mr(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,E=(h.top-_)*f+C,y=co(e,f),j=Tr(k,E,y,i,0,0,o),A=j.x,D=j.y;return{positionX:A,positionY:D,scale:f}}var wv=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),bc(e,1,s,r,o)}},Cv=function(e){return function(s,r,o){s===void 0&&(s=.5),r===void 0&&(r=300),o===void 0&&(o="easeOut"),bc(e,-1,s,r,o)}},kv=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};vs(e,v,p,m)}}},Ev=function(e){return function(s,r){s===void 0&&(s=200),r===void 0&&(r="easeOut"),_c(e,s,r)}},jv=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=yc(s||p.scale,m,x);vs(e,i,r,o)}}},Nv=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=Sv(e,x,r);vs(e,i,o,p)}}},hi=function(e){return{instance:e,zoomIn:wv(e),zoomOut:Cv(e),setTransform:kv(e),resetTransform:Ev(e),centerView:jv(e),zoomToElement:Nv(e)}},En=function(e){return{instance:e,state:e.transformState}},Ye=function(e){var s={};return Object.assign(s,En(e)),Object.assign(s,hi(e)),s},tn=!1;function sn(){try{var e={get passive(){return tn=!0,!1}};return e}catch{return tn=!1,tn}}var Xr=".".concat(kn.wrapperClass),Ri=function(e,s){return s.some(function(r){return e.matches("".concat(Xr," ").concat(r,", ").concat(Xr," .").concat(r,", ").concat(Xr," ").concat(r," *, ").concat(Xr," .").concat(r," *"))})},jn=function(e){e&&clearTimeout(e)},Rv=function(e,s,r){return"translate(".concat(e,"px, ").concat(s,"px) scale(").concat(r,")")},yc=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 Av(e){return function(s){e.forEach(function(r){typeof r=="function"?r(s):r!=null&&(r.current=s)})}}var Tv=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=Ri(a,x);return!c},Mv=function(e){return e?e.deltaY<0?1:-1:0};function Dv(e,s){var r=Mv(e),o=qg(s,r);return o}function Sc(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 Pv=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=Mr(Dt(_,3),a,n,g,w&&!c);return l},Lv=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},Iv=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=Ri(x,p);return!n},Ov=function(e){var s=e.setup.pinch.disabled,r=e.isInitialized,o=e.pinchStartDistance,p=r&&!s&&o;return!!p},Bv=function(e,s,r){var o=r.getBoundingClientRect(),p=e.touches,m=Dt(p[0].clientX-o.left,5),x=Dt(p[0].clientY-o.top,5),i=Dt(p[1].clientX-o.left,5),n=Dt(p[1].clientY-o.top,5);return{x:(m+i)/2/s,y:(x+n)/2/s}},wc=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))},Fv=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 Mr(Dt(g,2),x,m,a,!h&&!n)},zv=160,Wv=100,Hv=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))},Uv=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=Dv(s,null),S=_?d*Math.abs(s.deltaY):u,C=Pv(e,f,S,!s.ctrlKey);if(n!==C){var k=ks(e,C),E=Sc(s,m,n),y=l||w===0||h||v,j=a&&y,A=Ni(e,E.x,E.y,C,k,j),D=A.x,M=A.y;e.previousWheelEvent=s,e.setTransformState(C,D,M),Ze(Ye(e),s,o),Ze(Ye(e),s,p)}},$v=function(e,s){var r=e.props,o=r.onWheelStop,p=r.onZoomStop;jn(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(gc(e,s.x,s.y),e.wheelAnimationTimer=null)},Wv);var m=Lv(e,s);m&&(jn(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ze(Ye(e),s,o),Ze(Ye(e),s,p))},zv))},Cc=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}},Kv=function(e,s){var r=wc(s);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var o=Cc(s);e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y,zt(e)},qv=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=Bv(s,m,r);if(!(!Number.isFinite(v.x)||!Number.isFinite(v.y))){var _=wc(s),w=Fv(e,_),l=Cc(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=ks(e,w),S=c||g===0||n,C=i&&S,k=Ni(e,v.x,v.y,w,f,C),E=k.x,y=k.y;e.pinchMidpoint=v,e.lastDistance=_;var j=h.sizeX,A=h.sizeY,D=gs(e,j),M=gs(e,A),P=E+u,z=y+d,L=Tr(P,z,f,i,D,M,p),W=L.x,$=L.y;e.setTransformState(w,W,$)}}}},Vv=function(e){var s=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,gc(e,s?.x,s?.y)},kc=function(e,s){var r=e.props.onZoomStop,o=e.setup.doubleClick.animationTime;jn(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ze(Ye(e),s,r)},o)},Yv=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),_c(e,x,i,function(){return Ze(Ye(e),s,p)}),kc(e,s)};function Xv(e,s){return e==="toggle"?s===1?1:-1:e==="zoomOut"?-1:1}function Gv(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 Yv(e,s);if(!m)return console.error("No ContentComponent found");var l=Xv(g,e.transformState.scale),u=xc(e,l,v);if(x!==u){Ze(Ye(e),s,n);var d=Sc(s,m,x),f=ho(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),vs(e,f,_,w),kc(e,s)}}}var Qv=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=Ri(n,i);return!c},Zv=(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,ks(r,r.transformState.scale),r.setup=ya(o)},this.initializeWindowEvents=function(){var o,p,m=sn(),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=sn(),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=sn();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),ks(r,r.transformState.scale),uo(r,0)}),r.observer.observe(o),r.observer.observe(p)},this.onWheelZoom=function(o){var p=r.setup.disabled;if(!p){var m=Tv(r,o);if(m){var x=r.isPressingKeys(r.setup.wheel.activationKeys);x&&(Hv(r,o),Uv(r,o),$v(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=gs(r,l),f=gs(r,u);v===a&&_===h||pc(r,v,_,d,f)}},this.onPanningStart=function(o){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var x=pa(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),xa(r,o),Ze(Ye(r),o,m)))}}},this.onPanning=function(o){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var x=ga(r);if(x){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(o.preventDefault(),o.stopPropagation(),ba(r,o.clientX,o.clientY),Ze(Ye(r),o,m))}}},this.onPanningStop=function(o){var p=r.props.onPanningStop;r.isPanning&&(_v(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=Iv(r,o);n&&(Kv(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=Ov(r);n&&(o.preventDefault(),o.stopPropagation(),qv(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&&(Vv(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=pa(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),xa(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=ga(r);if(!x)return;o.preventDefault(),o.stopPropagation();var i=o.touches[0];ba(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=Qv(r,o);m&&Gv(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=yc(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):Rv(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,ks(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=ya(this.props),this.transformState=vc(this.props)}return e})(),Ai=de.createContext(null),Jv=function(e,s){return typeof e=="function"?e(s):e},e0=de.forwardRef(function(e,s){var r=b.useRef(new Zv(e)).current,o=Jv(e.children,hi(r));return b.useImperativeHandle(s,function(){return hi(r)},[r]),b.useEffect(function(){r.update(e)},[r,e]),de.createElement(Ai.Provider,{value:r},o)});de.forwardRef(function(e,s){var r=b.useRef(null),o=b.useContext(Ai);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]),de.createElement("div",ms({},e,{ref:Av([r,s])}))});function t0(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 s0=`.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
- `,Sa={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};t0(s0);var r0=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(Ai),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(){_?.()}},[]),de.createElement("div",ms({},a,{ref:w,className:"".concat(kn.wrapperClass," ").concat(Sa.wrapper," ").concat(o),style:x}),de.createElement("div",ms({},c,{ref:l,className:"".concat(kn.contentClass," ").concat(Sa.content," ").concat(m),style:i}),s))},Ec=function(){var e=b.useContext(Ai);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},i0=function(){var e=Ec();return hi(e)};function n0(e){var s=Ec(),r=b.useState(e(En(s))),o=r[0],p=r[1];return b.useEffect(function(){var m=!0,x=s.onChange(function(i){m&&p(e(En(i.instance)))});return function(){x(),m=!1}},[e,s]),o}function o0(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 a0(e,s){return Pt({queryKey:_e.files.tree(e||"",s),queryFn:()=>Ae.get("/files/tree",{params:{workingDir:e||"",path:s}}),enabled:!!e})}function l0(e,s){return Pt({queryKey:_e.files.content(e||"",s||""),queryFn:()=>Ae.get("/files/read",{params:{workingDir:e||"",path:s||""}}),enabled:!!e&&!!s})}function c0(e){const s=Lt();return b.useCallback(()=>{e&&s.invalidateQueries({queryKey:["files","tree",e]})},[s,e])}function d0(){const e=Lt();return kr({mutationFn:s=>Ae.post("/files/write",s),onSuccess:(s,r)=>{const o=_e.files.content(r.workingDir,r.path),p=e.getQueryData(o);e.setQueryData(o,{content:r.content,language:p?.language||o0(r.path)})}})}function u0(e,s){return e==="/"?`/${s}`:`${e}/${s}`}function h0(e,s){return e==="/"?s:`${e.slice(1)}/${s}`}const f0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function m0(e){if(e.type==="directory")return null;const s=e.name.split(".").pop()?.toLowerCase();return s&&f0.has(s)?tl:s==="ts"||s==="tsx"||s==="js"||s==="jsx"?ii:s==="json"?Iu:s==="md"||s==="mdx"||s==="txt"?el:eu}const wa=({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})]}),jc=({workingDir:e,path:s,depth:r,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})=>{const{t:i}=ce(),{data:n,isLoading:a,isError:h}=a0(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=u0(s,g.name),d=o.has(u);return t.jsxs("div",{children:[t.jsx(wa,{depth:r,onClick:()=>p(u),rightIcon:d?t.jsx(Ct,{size:14,className:"text-neutral-400"}):t.jsx(Nt,{size:14,className:"text-neutral-400"}),leftIcon:d?t.jsx(_i,{size:14,className:"text-amber-500"}):t.jsx(Yn,{size:14,className:"text-amber-500"}),label:g.name}),d&&t.jsx(jc,{workingDir:e,path:u,depth:r+1,expanded:o,toggleDir:p,onFileSelect:m,selectedFilePath:x})]},u)}const v=h0(s,g.name),_=m0(g),w=x===v,l=_===tl;return t.jsx(wa,{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)})})},p0=({workingDir:e,className:s,onFileSelect:r,selectedFilePath:o,onCollapse:p})=>{const{t:m}=ce(),[x,i]=b.useState(()=>new Set),n=c0(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(Rs,{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(qu,{size:13})})]})]}),t.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?t.jsx(jc,{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.")})})]})},g0=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function v0(e){const s=e.split(".").pop()?.toLowerCase();return s?g0.has(s):!1}function x0(e,s){const r=Cr(),o=new URLSearchParams({workingDir:e,path:s});return`${r}/files/image?${o.toString()}`}const b0=({filePath:e})=>{const{t:s}=ce(),{zoomIn:r,zoomOut:o,centerView:p}=i0(),m=n0(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(ah,{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(nh,{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($u,{size:13})}),t.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},_0=({workingDir:e,filePath:s})=>{const{t:r}=ce(),[o,p]=b.useState(!1),m=x0(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(e0,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:t.jsxs("div",{className:"h-full flex flex-col",children:[t.jsx(b0,{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(r0,{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 y0(e){const s=e.split("/");return s[s.length-1]||e}function S0(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 w0=({active:e,name:s,isDirty:r,onClick:o,onClose:p})=>{const{t:m}=ce();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(Xt,{size:12})})]})},C0=de.forwardRef(function({workingDir:s,className:r,readOnly:o=!1},p){const{t:m}=ce(),[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=d0();b.useEffect(()=>{let B=!1;return Ld(async()=>{const{preloadMonaco:U}=await import("./monaco-CirwkIGR.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,E]=b.useState(!1),[y,j]=b.useState(!1),A=b.useRef(280),D=b.useCallback(()=>{E(B=>(B?C(A.current):A.current=S,!B))},[S]),M=b.useCallback(B=>{B.preventDefault(),j(!0);const U=B.clientX,H=S,N=K=>{const Y=K.clientX-U,se=Math.min(480,Math.max(160,H+Y));C(se)},F=()=>{j(!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 P=b.useMemo(()=>x.find(B=>B.path===n)||null,[x,n]),{data:z,isFetching:L,isError:W,error:$}=l0(s,P?.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 R=b.useCallback((B,U,H)=>{i(N=>{if(N.find(Y=>Y.path===B))return N;const K=v0(B);return[...N,{path:B,name:y0(B),language:S0(B),content:"",savedContent:"",isDirty:!1,loaded:K,isImage:K}]}),a(B),u(U?{path:B,line:U,column:H}:null)},[]);de.useImperativeHandle(p,()=>({openFile:R}),[R]);const I=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||!P||(await f.mutateAsync({workingDir:s,path:P.path,content:P.content}),i(B=>B.map(U=>U.path===P.path?{...U,savedContent:U.content,isDirty:!1,loaded:!0}:U)))},[P,o,f,s]),q=b.useRef(()=>{});b.useEffect(()=>{q.current=()=>{O().catch(()=>{})}},[O]),b.useEffect(()=>{const B=U=>{o||(U.metaKey||U.ctrlKey)&&U.key.toLowerCase()==="s"&&(U.preventDefault(),q.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,()=>{q.current()})},[]);return b.useEffect(()=>{if(!l||l.path!==n||!P?.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,P?.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:D,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(Yu,{size:16})})}):t.jsx(t.Fragment,{children:t.jsx(p0,{workingDir:s,onFileSelect:R,selectedFilePath:P?.path||null,onCollapse:D},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(w0,{active:B.path===n,name:B.name,isDirty:B.isDirty,onClick:()=>a(B.path),onClose:U=>{U.stopPropagation(),I(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(Oe,{size:14,className:"animate-spin"}),m("Saving")]}),P?.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?P?P.isImage?t.jsx(_0,{workingDir:s,filePath:P.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(Kg,{path:P.path,value:P.content,language:P.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}}),L&&!P.loaded&&t.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:t.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[t.jsx(Oe,{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(Oe,{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 Ti(e,s={}){const r=Xs(p=>p.visibleContext),o=rl(e,r);return Pt({queryKey:_e.git.changes(e||""),queryFn:()=>Ae.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e&&(s.enabled??!0),refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1})}function Nc(e,s,r){const o=Xs(m=>m.visibleContext),p=rl(e,o);return Pt({queryKey:_e.git.diff(e||"",s||"",r),queryFn:()=>Ae.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 fo(e,s){return Pt({queryKey:_e.git.commitFiles(e||"",s||""),queryFn:()=>Ae.get("/git/commit-files",{params:{workingDir:e||"",hash:s||""}}),enabled:!!e&&!!s})}function mo(e,s,r){return Pt({queryKey:_e.git.commitDiff(e||"",s||"",r||""),queryFn:()=>Ae.get("/git/commit-diff",{params:{workingDir:e||"",hash:s||"",path:r||""}}),enabled:!!e&&!!s&&!!r})}const k0=new Set(["STARTING","RUNNING","STOPPING"]);function Rc(e){return k0.has(e.runtimeState)||e.runtimeInstanceId!==null}function Ac(e){return e instanceof pi&&e.status===409&&e.details.code==="WORKSPACE_HAS_ACTIVE_SERVICE"}function E0({services:e,isLoading:s,isError:r}){const{t:o}=ce();return s?t.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted-foreground",role:"status",children:[t.jsx(Oe,{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(Ns,{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 Tc({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}=ce(),[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(ps,{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(Oe,{size:14,className:"animate-spin"}),i?c("正在检查后台服务..."):x.length>0?c("正在停止服务并提交..."):c("正在提交...")]}):t.jsxs(t.Fragment,{children:[t.jsx(ri,{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(_l,{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(E0,{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 Os(e,s){const r=e[s];return typeof r=="string"&&r.length>0?r:void 0}function Mc(e){if(!(e instanceof pi)||e.status!==409)return;const s=e.details;if(s.code!=="MERGE_CONFLICT"||s.conflictOp!==xr.REBASE&&s.conflictOp!==xr.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:Os(s,"sourceBranch"),targetBranch:Os(s,"targetBranch"),sourceWorktreePath:Os(s,"sourceWorktreePath"),targetWorktreePath:Os(s,"targetWorktreePath"),sourceWorkspaceId:Os(s,"sourceWorkspaceId"),targetWorkspaceId:Os(s,"targetWorkspaceId")}}function Ca(e,s,r,o){const p=Mc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Dc({workspaceId:e,branchName:s,targetBranch:r,commitMessage:o,committedFileCount:p,onRefreshCommitMessage:m,onConflict:x,onResolveConflicts:i}){const{t:n}=ce(),{data:a,isLoading:h}=Bn(e),c=il(),g=nl(),v=Fn(),[_,w]=b.useState(!1),[l,u]=b.useState(null),d=lo(e,_),f=(d.data??[]).filter(Rc);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(Oe,{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,E=a.uncommittedCount+a.untrackedCount,y=!S&&!C&&!k,j=a.operation==="idle"&&a.ahead===0&&a.behind===0&&!k&&!S,A=()=>{u(null),c.mutate(e,{onError:z=>{Ca(z,n("更新失败,请稍后重试"),L=>x(L),u)}})},D=()=>{u(null),w(!0)},M=(z,L)=>{u(null),g.mutate({id:e,commitMessage:z,stopActiveServices:L},{onSuccess:()=>w(!1),onError:W=>{if(Ac(W)){u(n("后台服务仍在运行,请确认停止服务后再提交。"));return}Ca(W,n("提交失败,请稍后重试"),$=>{w(!1),x($)},u)}})},P=()=>{g.isPending||(w(!1),u(null))};return j?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(Id,{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(Fu,{size:12,className:"shrink-0"}),t.jsx("span",{children:n("{count} 个本地改动未处理,需要先整理后再继续",{count:E})})]}),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(Ns,{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(Oe,{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(Ya,{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:A,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(Rs,{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:D,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(ri,{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(ri,{size:12}),n("提交变更")]})]})]})]})}),t.jsx(Tc,{isOpen:_,onClose:P,branchName:s,targetBranch:r,commitMessage:o,isPending:g.isPending,activeServices:f,isCheckingServices:d.isLoading,serviceCheckFailed:d.isError,error:l,onConfirm:M})]})}const rn=50,nn=400,ka={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"},Ea={M:"bg-amber-500",A:"bg-emerald-500",D:"bg-red-500",R:"bg-blue-500"};function Pc(e){const s=e.split("/");return s[s.length-1]||e}function j0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function N0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Tt("{count}s ago",{count:r}):r<3600?Tt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Tt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Tt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Qr(e,s){return e.kind==="working"?`${e.diffType}:${s}`:`${e.hash}:${s}`}const Nn=({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"})]}),R0=({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})]})},Lc=({diff:e})=>{const{t:s}=ce(),[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>nn,x=m?p.slice(0,nn):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(R0,{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-nn})})]})},A0=({workingDir:e,path:s,diffType:r,enabled:o})=>{const{t:p}=ce(),{data:m,isLoading:x,isError:i}=Nc(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(Oe,{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(Lc,{diff:m?.diff||""})},T0=({workingDir:e,hash:s,path:r,enabled:o})=>{const{t:p}=ce(),{data:m,isLoading:x,isError:i}=mo(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(Oe,{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(Lc,{diff:m?.diff||""})},on=({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=Qr(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=ka[e.status]||ka.M,g=j0(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(Nt,{size:13,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Ct,{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:Pc(e.path)}),g&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate",children:g}),t.jsx("span",{className:"ml-auto"}),t.jsx(Nn,{additions:e.additions,deletions:e.deletions})]}),!m&&t.jsx("div",{className:"border-t border-border/60",children:s.kind==="working"?t.jsx(A0,{workingDir:r,path:e.path,diffType:s.diffType,enabled:i}):t.jsx(T0,{workingDir:r,hash:s.hash,path:e.path,enabled:i})})]})};function M0(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 Ic(s)}function Ic(e){const s=new Map;for(const r of e.dirs.values()){let o=Ic(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 D0=({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(_i,{size:12,className:"text-muted-foreground/70 shrink-0"}):t.jsx(Yn,{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(Oc,{node:e,depth:s+1,activeKey:r,onSelect:o})]})},Oc=({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(D0,{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",Ea[p.status]||Ea.M)}),t.jsx("span",{className:Z("text-xs truncate",m?"text-foreground font-medium":"text-foreground/90"),children:Pc(p.path)})]},p.cardKey)})]}),P0=({workingDir:e,selectedHash:s,onSelectCommit:r})=>{const{t:o}=ce(),{data:p,isLoading:m,fetchNextPage:x,hasNextPage:i,isFetchingNextPage:n}=Xn({queryKey:_e.git.log(e),queryFn:({pageParam:h=0})=>Ae.get("/git/log",{params:{workingDir:e,limit:String(rn),skip:String(h)}}),initialPageParam:0,getNextPageParam:(h,c)=>h.commits.length<rn?void 0:c.length*rn}),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(Oe,{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," · ",N0(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(Oe,{size:11,className:"animate-spin"})," ",o("正在加载...")]}):o("加载更多提交")})]})},L0=({workingDir:e,workspaceId:s,branchName:r,targetBranch:o,commitMessage:p,canRunGitOperations:m,onRefreshCommitMessage:x,onConflict:i,onResolveConflicts:n})=>{const{t:a}=ce(),[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}=Ti(e),C=h.kind==="commit"?h.commit.hash:null,{data:k,isLoading:E}=fo(e,C),y=b.useRef(new Map),j=b.useRef(null),A=b.useRef(null),D=b.useCallback((B,U)=>{U?y.current.set(B,U):y.current.delete(B)},[]),{uncommitted:M,committed:P,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(K=>({...K,cardKey:Qr(N,K.path)}));return{uncommitted:[],committed:[],commitFiles:F}}const U=(d?.uncommitted||[]).filter(B).map(N=>({...N,cardKey:Qr({kind:"working",diffType:"uncommitted"},N.path)})),H=(d?.committed||[]).filter(B).map(N=>({...N,cardKey:Qr({kind:"working",diffType:"committed"},N.path)}));return{uncommitted:U,committed:H,commitFiles:[]}},[h,d,k,g]),L=h.kind==="commit"?z:[...M,...P],W=b.useMemo(()=>M0(L),[L]),$=b.useMemo(()=>{let B=0,U=0;for(const H of L)B+=H.additions??0,U+=H.deletions??0;return{additions:B,deletions:U,files:L.length}},[L]),R=b.useCallback(()=>{const B=j.current;if(!B)return;const U=B.getBoundingClientRect().top;let H=null,N=Number.NEGATIVE_INFINITY;for(const[F,K]of y.current){const Y=K.getBoundingClientRect().top-U;Y<=48&&Y>N&&(N=Y,H=F)}if(!H){let F=null,K=Number.POSITIVE_INFINITY;for(const[Y,se]of y.current){const G=se.getBoundingClientRect().top-U;G<K&&(K=G,F=Y)}H=F}w(H)},[]);b.useEffect(()=>{const B=j.current;if(!B)return;let U=0;const H=()=>{cancelAnimationFrame(U),U=requestAnimationFrame(R)};return B.addEventListener("scroll",H,{passive:!0}),()=>{B.removeEventListener("scroll",H),cancelAnimationFrame(U)}},[R]);const I=b.useCallback(B=>{const U=y.current.get(B.cardKey);U&&(U.scrollIntoView({behavior:"smooth",block:"start"}),w(B.cardKey),u(B.cardKey),A.current&&clearTimeout(A.current),A.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),j.current?.scrollTo({top:0})},[]),O=b.useCallback(()=>{c({kind:"overview"}),v(""),w(null),j.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 q=m&&s&&r&&o,V=h.kind==="commit"?E:f;return t.jsxs("div",{className:"flex h-full w-full min-w-0 flex-col bg-background",children:[q&&i&&n&&t.jsx(Dc,{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(Nn,{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($s,{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($s,{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(Nn,{className:"ml-auto",additions:$.additions,deletions:$.deletions})]})}),t.jsxs("div",{className:"flex flex-1 min-h-0",children:[t.jsx("div",{ref:j,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("变更加载失败")}):L.length===0?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-muted-foreground/60",children:[t.jsx(ii,{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(on,{entry:B,source:{kind:"commit",hash:h.commit.hash},workingDir:e,flash:l===B.cardKey,registerNode:D},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(on,{entry:B,source:{kind:"working",diffType:"uncommitted"},workingDir:e,flash:l===B.cardKey,registerNode:D},B.cardKey))})]}),P.length>0&&t.jsxs("section",{children:[t.jsxs("div",{className:"sticky top-0 z-10 -mx-3 px-5 py-1.5 bg-background/95 backdrop-blur-sm",children:[t.jsx("span",{className:"text-[11px] font-semibold text-muted-foreground uppercase tracking-wider",children:a("已提交")}),t.jsx("span",{className:"ml-2 text-[11px] text-muted-foreground/70",children:P.length})]}),t.jsx("div",{className:"space-y-3 mt-1",children:P.map(B=>t.jsx(on,{entry:B,source:{kind:"working",diffType:"committed"},workingDir:e,flash:l===B.cardKey,registerNode:D},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(Wn,{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:L.length===0?t.jsx("div",{className:"px-2 py-3 text-[11px] text-muted-foreground/60",children:g.trim()?a("无匹配文件"):a("暂无变更文件")}):t.jsx(Oc,{node:W,depth:0,activeKey:_,onSelect:I})}),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(qs,{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(P0,{workingDir:e,selectedHash:C,onSelectCommit:T})})]})]})]})]})},an=50,ja={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 I0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Tt("{count}s ago",{count:r}):r<3600?Tt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Tt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Tt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function O0(e){const s=e.split("/");return s[s.length-1]||e}function B0(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}const F0=({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})]})},z0=({workingDir:e,hash:s,filePath:r})=>{const{t:o}=ce(),{data:p,isLoading:m,isError:x}=mo(e,s,r);if(m)return t.jsxs("div",{className:"flex-1 flex items-center justify-center text-muted-foreground",children:[t.jsx(Oe,{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(F0,{line:a,lineNum:h+1},h))})},W0=({workingDir:e,hash:s,selectedPath:r,onSelectFile:o})=>{const{t:p}=ce(),{data:m,isLoading:x}=fo(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(Oe,{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=ja[n.status]||ja.M,h=B0(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:O0(n.path)}),h&&t.jsx("span",{className:"text-[11px] text-muted-foreground/70 truncate ml-auto shrink-0",children:h})]},n.path)})})},H0=({workingDir:e})=>{const{t:s}=ce(),r=Xs(E=>E.visibleContext),o=tu(e,r),{data:p,isLoading:m,isError:x,fetchNextPage:i,hasNextPage:n,isFetchingNextPage:a}=Xn({queryKey:_e.git.log(e||""),queryFn:({pageParam:E=0})=>Ae.get("/git/log",{params:{workingDir:e||"",limit:String(an),skip:String(E)}}),initialPageParam:0,getNextPageParam:(E,y)=>E.commits.length<an?void 0:y.length*an,enabled:!!e,refetchInterval:o,refetchIntervalInBackground:!1,refetchOnWindowFocus:o?"always":!1,refetchOnReconnect:o?"always":!1}),h=p?.pages.flatMap(E=>E.commits)||[],[c,g]=b.useState(null),[v,_]=b.useState(null),[w,l]=b.useState(280),[u,d]=b.useState(!1),f=b.useCallback(E=>{E.preventDefault(),d(!0);const y=E.clientX,j=w,A=M=>{const P=Math.min(480,Math.max(180,j+(M.clientX-y)));l(P)},D=()=>{d(!1),document.removeEventListener("mousemove",A),document.removeEventListener("mouseup",D)};document.addEventListener("mousemove",A),document.addEventListener("mouseup",D)},[w]),S=E=>{c===E?(g(null),_(null)):(g(E),_(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(Oe,{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(qs,{size:28,className:"mb-2"}),t.jsx("span",{className:"text-xs",children:s("No commit history")})]});const k=h.find(E=>E.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(qs,{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(E=>{const y=c===E.hash;return t.jsxs("div",{children:[t.jsxs("button",{type:"button",onClick:()=>S(E.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:E.shortHash}),t.jsx("span",{className:"text-xs text-foreground truncate flex-1",children:E.message}),t.jsx(Nt,{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:E.author}),t.jsx("span",{className:"text-[11px] text-muted-foreground/70",children:I0(E.timestamp)})]})]})]}),y&&t.jsxs(t.Fragment,{children:[E.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:E.body}),t.jsx(W0,{workingDir:e,hash:E.hash,selectedPath:v,onSelectFile:_})]})]},E.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(Oe,{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(ii,{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(z0,{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(ii,{size:28}),t.jsx("span",{className:"text-xs",children:s(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})},Na=Cr();function U0(e){if(!Na)return e;try{const s=new URL(Na);return new URL(e,s.origin).toString()}catch{return e}}function Bc(e){return{...e,viewUrl:e.viewUrl?U0(e.viewUrl):null}}function $0(e,s=!0){return Pt({queryKey:_e.previews.status(e??""),queryFn:async()=>{const r=await Ae.get(`/previews/${e}/status`);return Bc(r)},enabled:!!e&&s,refetchOnWindowFocus:!1})}function K0(e){const s=Lt();return kr({mutationFn:async r=>{const o=await Ae.put(`/previews/${e}/config`,{target:r});return Bc(o)},onSuccess:r=>{e&&(s.setQueryData(_e.previews.status(e),r),s.invalidateQueries({queryKey:_e.workspaces.all}))}})}function q0(){return window.location.protocol==="https:"?"remote":"local"}function V0(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=>{Ae.delete(`/previews/${e}/sessions/${l}`).catch(()=>{})};return(async()=>{x(!0),n(null);try{const l={mode:q0(),localHostname:window.location.hostname},u=await Ae.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 Ae.post(`/previews/${e}/sessions/${g}/heartbeat`);c||(p(d),n(null))}catch(d){!c&&d instanceof pi&&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 Y0="agent-tower-preview",X0="agent-tower-preview-host";function G0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function Q0(e){if(!e)return null;try{return new URL(e).origin}catch{return null}}function Z0(e){return t.jsx(J0,{...e},e.workspaceId??"no-workspace")}function J0({workspaceId:e,readOnly:s,navigationRequest:r,onNavigationRequestHandled:o}){const{t:p}=ce(),[m,x]=b.useState(null),n=!(r?.source.kind==="visualization")&&!m,{data:a,isLoading:h,refetch:c,isFetching:g}=$0(e,n),v=K0(e),{session:_,isOpening:w,error:l,retry:u}=V0(e,a,n),d=b.useRef(null),f=b.useRef(null),S=b.useRef(null),C=b.useRef(null),k=b.useRef(null),E=b.useRef(null),[y,j]=b.useState(0),[A,D]=b.useState({target:null,address:"",iframeSrc:null,isFrameLoading:!1}),M=Q0(_?.viewUrl),P=a&&A.target!==a.target?{target:a.target,address:a.target??"",iframeSrc:null,isFrameLoading:!1}:a&&!a.ready&&A.iframeSrc?{...A,iframeSrc:null,isFrameLoading:!1}:A,z=b.useCallback(V=>{D(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,D(B=>{const U=r?.source.kind==="web"&&E.current!==r.id?Ur(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=Xd(_.viewUrl,F);else{const K=Ur(B.address||_.target,_.target,_.viewUrl);H=K?.kind==="proxy"?K.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 L=b.useCallback(async(V,B=!1)=>{const U=Ur(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}D({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);D({target:N.target,address:V.trim(),iframeSrc:null,isFrameLoading:!!N.ready}),j(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||E.current===r.id||r.source.kind==="web"&&h)return;const V=window.setTimeout(()=>{E.current=r.id,o?.(r.id),r.source.kind==="visualization"?(x({source:r.source,iframeSrc:Gd(r.source.sessionId,r.source.file),isFrameLoading:!0}),j(B=>B+1)):(x(null),L(r.source.url))},0);return()=>window.clearTimeout(V)},[h,L,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!==Y0)){if(U.type==="location"&&typeof U.href=="string"){const H=Qd(a?.target??null,_?.viewUrl??null,U.href,window.location.href);H&&document.activeElement!==f.current&&z({target:a?.target??P.target,address:H,isFrameLoading:!1});return}U.type==="navigate-loopback"&&typeof U.href=="string"&&L(U.href,U.newTab===!0)}};return window.addEventListener("message",V),()=>window.removeEventListener("message",V)},[P.target,L,z,_?.viewUrl,a?.target,m]);const W=V=>{d.current?.contentWindow?.postMessage({source:X0,action:V},"*")},$=V=>{V.preventDefault(),L(P.address)},R=async()=>{if(m){x(B=>B&&{...B,isFrameLoading:!0}),j(B=>B+1);return}const V=await c();if(!V.data?.ready){z({target:V.data?.target??P.target,iframeSrc:null,isFrameLoading:!1});return}if(!_||!P.iframeSrc){u();return}z({isFrameLoading:!0}),W("reload")},I=()=>{if(m){window.open(m.iframeSrc,"_blank","noopener,noreferrer");return}if(!_?.viewUrl)return;const V=Ur(P.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??P.iframeSrc,O=!!m,q=!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(Re,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>{O?x(null):W("back")},disabled:!O&&!P.iframeSrc,title:p("Back"),"aria-label":p("Back"),children:t.jsx($s,{})}),t.jsx(Re,{type:"button",size:"icon-sm",variant:"ghost",onClick:()=>W("forward"),disabled:O||!P.iframeSrc,title:p("Forward"),"aria-label":p("Forward"),children:t.jsx(_l,{})}),t.jsx(Re,{type:"button",size:"icon-sm",variant:"ghost",onClick:!O&&P.isFrameLoading?()=>{W("stop"),z({isFrameLoading:!1})}:R,disabled:!O&&!P.isFrameLoading&&g,title:!O&&P.isFrameLoading?p("Stop loading"):p("Refresh preview"),"aria-label":!O&&P.isFrameLoading?p("Stop loading"):p("Refresh preview"),children:!O&&P.isFrameLoading?t.jsx(Xt,{}):g?t.jsx(Oe,{className:"animate-spin"}):t.jsx(Rs,{})}),t.jsxs("form",{className:"relative min-w-0 flex-1",onSubmit:$,children:[t.jsx(Tu,{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??P.address,onChange:V=>z({address:V.target.value}),onKeyDown:V=>{V.key==="Enter"&&V.nativeEvent.isComposing&&V.preventDefault()},disabled:O||s||v.isPending,placeholder:G0(),"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(Re,{type:"button",size:"icon-sm",variant:"ghost",onClick:I,disabled:!T,title:p("Open preview in new tab"),"aria-label":p("Open preview in new tab"),children:t.jsx(Tn,{})})]}),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"):q?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 ex(e){switch(e){case Mt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case Mt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case Mt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case Mt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function Ra(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 tx(e){return e.length<=34?e:`...${e.slice(-31)}`}function Fc({workspaces:e,teamRun:s,selectedWorkspaceId:r,onSelectWorkspace:o,disabled:p,className:m,buttonClassName:x}){const{t:i}=ce(),[n,a]=b.useState(!1),h=b.useRef(null),c=b.useMemo(()=>oo(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(Ks,{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",Ra(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:tx(Ys(g.workspace))}),t.jsx(Ct,{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",Ra(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",ex(v.workspace.status)),children:v.workspace.status})]}),t.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:Ys(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 sx=[{key:"review",label:"Changes",icon:t.jsx(Qs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(bi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(fr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(bl,{size:14})}],rx=[{key:"history",label:"History",icon:t.jsx(qs,{size:14})},{key:"editor",label:"Editor",icon:t.jsx(bi,{size:14})},{key:"terminal",label:"Terminal",icon:t.jsx(fr,{size:14})},{key:"preview",label:"Preview",icon:t.jsx(bl,{size:14})}],ix=({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})]}),nx=({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}),zc=de.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:E}=ce(),y=Xs(re=>re.setVisibleContext),j=l==="rail",[A,D]=b.useState(!1),M=j?u??A:!0,P=b.useCallback(re=>{u===void 0&&D(re),d?.(re)},[u,d]),z=b.useMemo(()=>{const re=x?rx:sx,ne=i?re:re.filter(ye=>ye.key!=="review"&&ye.key!=="history"),le=n?ne.filter(ye=>ye.key!=="terminal"):ne;return h?[{key:"team-status",label:"Team Status",icon:t.jsx(Es,{size:14})},...le]:le},[i,x,n,h]),[L,W]=b.useState(()=>C?"preview":i?x?"history":"review":"editor"),$=b.useRef(null),R=b.useRef(0),[I,T]=b.useState(),O=b.useCallback(re=>{W(re),j&&P(!0)},[j,P]);b.useImperativeHandle(S,()=>({setTab:re=>O(re),openFile:(re,ne,le)=>{O("editor"),requestAnimationFrame(()=>$.current?.openFile(re,ne,le))},openPreview:(re,ne)=>{R.current+=1,T({id:R.current,source:re,workspaceId:ne}),O("preview")}}),[O]);const q=C??I,V=q?.workspaceId&&q.workspaceId!==o?void 0:q,B=b.useCallback(re=>{T(ne=>ne?.id===re?void 0:ne),k?.(re)},[k]),{data:U}=fu(m??""),H=b.useMemo(()=>{if(!U?.quickCommands)return[];try{return JSON.parse(U.quickCommands)}catch{return[]}},[U?.quickCommands]),[N,F]=b.useState([]),K=b.useRef(void 0);b.useEffect(()=>{p&&p!==K.current&&(K.current=p,F(re=>re.includes(p)?re:[...re,p]))},[p]),b.useEffect(()=>{z.some(re=>re.key===L)||W(z[0]?.key??"editor")},[L,z]),b.useEffect(()=>{if(j&&!M)return;const re=L==="review"?"changes":L==="history"?"history":null;if(!o||!p||!re){y(null);return}return y({workspaceId:o,workingDir:p,tab:re}),()=>{y(null)}},[L,M,j,y,p,o]);const Y=!!w&&oo(v,h).length>1,se=z.find(re=>re.key===L)??z[0],G=se?E(se.label):"",me=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:E(a?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}):null,ue=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(Fc,{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:[L==="team-status"&&h&&c,L==="editor"&&t.jsx(C0,{ref:$,workingDir:p,readOnly:n}),N.map(re=>{const ne=L==="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(Ip,{cwd:re,workspaceId:ne?o:void 0,isVisible:ne,quickCommands:H})},re)}),L==="preview"&&t.jsx(Z0,{workspaceId:o,readOnly:n,navigationRequest:V,onNavigationRequestHandled:B}),L==="review"&&t.jsx(L0,{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}),L==="history"&&t.jsx(H0,{workingDir:p})]})]});return j?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(nx,{active:M&&L===re.key,onClick:()=>O(re.key),icon:re.icon,label:E(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:[me,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:()=>P(!1),className:"flex h-7 w-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground focus:outline-none focus-visible:ring-2 focus-visible:ring-ring/40",title:E("收起"),"aria-label":E("收起"),children:t.jsx(Gu,{size:15})})]}),ue]})]}):t.jsxs("div",{className:Z("flex h-full w-full min-w-0 flex-col bg-white",s),children:[n&&me,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(ix,{active:L===re.key,onClick:()=>O(re.key),icon:re.icon,label:E(re.label)},re.key))}),ue]})}),ox=3e3;function Aa(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 Wc(e){const s=Lt(),r=b.useRef({version:0,values:new Map}),[o,p]=b.useState(0),{data:m=[]}=Pt({queryKey:_e.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 Ae.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 Aa(c,g)}});b.useEffect(()=>{if(!e)return;const a=ls.connect(),h=_e.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=>Aa(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),ox);return()=>clearTimeout(a)},[n]),i??null}function Hc({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}=ce(),[g,v]=b.useState(""),[_,w]=b.useState(""),[l,u]=b.useState(xt.WORKTREE),[d,f]=b.useState(null),[S,C]=b.useState("idle"),[k,E]=b.useState(null),y=Lt(),j=ol(o),A=$n(),D=mu(),{data:M,isLoading:P}=Gs(),z=d?.isGitRepo??n,L=d?.worktreeReady??a,W=d?.reason??h,$=z!==!1&&L!==!1;b.useEffect(()=>{if(!e||!M)return;const se=M.find(G=>!es(G));v(G=>G&&M.some(me=>me.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?xt.WORKTREE:xt.MAIN_DIRECTORY),C("idle"),E(null)}},[e,n,a,o,m,x,i]),b.useEffect(()=>{$||u(xt.MAIN_DIRECTORY)},[$]);const R=async()=>{if(!p||D.isPending)return;const se=await D.mutateAsync({id:p});f(se),se.worktreeReady&&u(xt.WORKTREE)},I=S!=="idle",T=async()=>{if(!g||!_.trim())return;const se=M?.find(G=>G.provider.id===g);if(!(!se||es(se))){E(null);try{C("creating-workspace");const G=await j.mutateAsync({workspaceKind:$?l:xt.MAIN_DIRECTORY});C("creating-session");const me=await Ae.post(`/workspaces/${G.id}/sessions`,{providerId:g,prompt:_.trim()});C("starting-session"),await A.mutateAsync(me.id),await y.invalidateQueries({queryKey:_e.workspaces.list(o)}),C("idle"),r?.(),s()}catch(G){C("idle"),E(G instanceof Error?G.message:c("启动失败,请重试"))}}},O={idle:c("启动"),"creating-workspace":c("创建工作空间..."),"creating-session":c("创建会话..."),"starting-session":c("启动 Agent...")},q=(M??[]).map(se=>{const G=se.provider,me=es(se),ue=!me,re=G.executionPermission?c("Required permission: {mode}",{mode:c(uu[G.executionPermission])}):void 0;return{value:G.id,label:ue?G.name:`${G.name}${c(" (不可用)")}`,description:[re,me&&c(me)].filter(Boolean).join(" · "),icon:t.jsx(xi,{agentType:G.agentType,className:"size-4"}),disabled:!ue}}),V=M?.find(se=>se.provider.id===g),B=V?es(V):void 0,U=!!M?.length&&M.every(se=>!!es(se)),H=!P&&!M?.length,N=c("工作树隔离改动,支持 TeamRun、Merge、Rebase 和冲突解决。"),F=c("本地模式会直接修改项目主目录,不会自动提交,也不能使用 Merge、Rebase 或冲突解决。"),K=c(W==="NO_HEAD"?"已检测到 Git,但需要先提交一次才能使用工作树模式。":"非 Git 项目只能使用本地模式。"),Y=[{value:xt.WORKTREE,label:c("工作树模式"),description:N,disabled:!$},{value:xt.MAIN_DIRECTORY,label:c("本地模式"),description:F}];return t.jsx(ps,{isOpen:e,onClose:I?()=>{}:s,title:c("启动 Agent"),action:t.jsxs(t.Fragment,{children:[t.jsx(Re,{variant:"outline",onClick:s,disabled:I,children:c("取消")}),t.jsx(Re,{onClick:T,disabled:I||!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(cs,{value:g,onChange:v,options:q,placeholder:c(P?"加载中...":"选择 Agent"),disabled:I||P}),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(es(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(cs,{value:l,onChange:se=>u(se),options:Y,disabled:I}):t.jsx(Zd,{side:"bottom",className:"w-full",content:K,children:t.jsxs("div",{tabIndex:0,"aria-label":K,className:"rounded-lg focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/60",children:[t.jsx(cs,{value:l,onChange:se=>u(se),options:Y,disabled:!0}),t.jsx("button",{type:"button",onClick:R,disabled:I||D.isPending,className:"mt-2 text-xs text-muted-foreground transition-colors hover:text-foreground disabled:cursor-not-allowed disabled:opacity-50",children:D.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:I,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 Uc(e){const s=e?.tokenUsage;if(!(!s||typeof s.totalTokens!="number"))return s}function ax(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 $c({session:e,providers:s,usage:r,compact:o=!1,providerIdFallback:p,agentTypeFallback:m,tokenTooltipSide:x="top"}){const{t:i}=ce(),n=ax(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(xi,{agentType:n.agentType,className:o?"size-3":"size-3.5"}),t.jsx("span",{className:"min-w-0 truncate",children:Od(n.label,o?12:18)})]}),t.jsx(Kn,{usage:r,tooltipSide:x})]})}function lx({isOpen:e,onClose:s,taskId:r}){const{t:o}=ce(),[p,m]=b.useState("AUTO"),[x,i]=b.useState(null),[n,a]=b.useState([]),[h,c]=b.useState(null),g=Xa();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 pi&&u.status===409){c(o("该任务已经存在 TeamRun。请刷新后再试。"));return}c(u instanceof Error?u.message:o("创建 TeamRun 失败"))}}},l=v||!_;return t.jsxs(ps,{isOpen:e,onClose:v?()=>{}:s,title:o("创建 TeamRun"),className:"max-w-5xl",action:t.jsxs(t.Fragment,{children:[t.jsx(Re,{type:"button",variant:"outline",onClick:s,disabled:v,children:o("取消")}),t.jsx(Re,{type:"button",onClick:w,disabled:l,children:o(v?"处理中...":"创建 TeamRun")})]}),children:[t.jsx(au,{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 cx({workspaceId:e,gitStatus:s,onResolve:r}){const{t:o}=ce(),p=Fn();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(Ns,{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(Re,{variant:"ghost",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,className:"text-muted-foreground hover:text-foreground",children:o("中止操作")}),t.jsx(Re,{size:"sm",onClick:r,children:o("解决冲突")})]})]})}function Kc(e){return e.length>0?e.map(s=>`- ${s}`).join(`
70
- `):"- 未获取到冲突文件列表"}function qc(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 dx(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 ux(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 hx(e,s,r,o,p){const m=Kc(r),x=qc(p);return o===xr.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,"","### 解决步骤",...dx(e,p)].join(`
72
- `)}function fx(e){const s=e.conflictOp===xr.REBASE?"Rebase":"Merge",r=Kc(e.conflictedFiles),o=[...qc(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${s} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${s} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...o,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===xr.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":ux(e)].join(`
73
- `)}function mx(e){if(e.teamRunId)return{type:"team_room",message:fx(e)};const s=e.currentSessionId||e.selectedSessionId;return s?{type:"session",sessionId:s,message:hx(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function Vc({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}=ce(),[f,S]=b.useState(""),C=qn(),k=Mn(u??""),E=zn(),y=!!u,j=l||f,A=y?k.isPending:C.isPending,D=()=>{const W=mx({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=()=>{E.mutate({workspaceId:r},{onSuccess:()=>s(!1)})},P=o==="REBASE"?"Rebase":"Merge",z=!y&&!l&&w.length>0,L=y||!!j;return t.jsx(ps,{isOpen:e,onClose:()=>s(!1),title:d("解决 {opLabel} 冲突",{opLabel:P}),action:t.jsxs("div",{className:"flex gap-2",children:[t.jsx(Re,{variant:"outline",onClick:M,children:d("在 IDE 中打开")}),t.jsx(Re,{onClick:D,disabled:!L||A,children:d(A?"发送中...":"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&&!j&&w.length===0&&t.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function px(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 Ta(e,s,r,o){const p=Mc(e);if(p){r(p);return}o(e instanceof Error?e.message:s)}function Yc({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}=ce(),v=il(),_=nl(),w=Fn(),[l,u]=b.useState(!1),[d,f]=b.useState(null),S=lo(e,l),C=(S.data??[]).filter(Rc),k=b.useMemo(()=>px(p),[p]),E=k.additions+k.deletions,y=k.files>0&&E>0,j=(m?.conflictedFiles.length??0)>0,A=!!(m&&m.operation!=="idle"),D=!!(m&&(m.hasUncommittedChanges||m.untrackedCount>0)),M=(m?.uncommittedCount??0)+(m?.untrackedCount??0),P=(m?.behind??0)>0,z=(m?.ahead??0)>0,L=x||!m&&i,W=!!(i&&e&&m&&P&&!j&&!A&&!D),$=!!(i&&e&&m&&z&&!P&&!j&&!A&&!D);if(b.useEffect(()=>{l&&a?.()},[l,a]),!y)return null;const R=j?g("冲突"):m?.operation==="rebase"?g("变基中"):m?.operation==="merge"?g("合并中"):M>0?g("{count} 未提交",{count:M}):P?g("落后 {count}",{count:m?.behind??0}):g(z?"可合并":"已是最新"),I=g("{files} 个文件 · {lines} 行",{files:k.files,lines:E}),T=()=>{W&&(f(null),v.mutate(e,{onError:B=>{Ta(B,g("更新失败,请稍后重试"),U=>h(U),f)}}))},O=()=>{$&&(f(null),u(!0))},q=(B,U)=>{f(null),_.mutate({id:e,commitMessage:B,stopActiveServices:U},{onSuccess:()=>u(!1),onError:H=>{if(Ac(H)){f(g("后台服务仍在运行,请确认停止服务后再提交。"));return}Ta(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:I}),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]})]}),j&&t.jsx(Ns,{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:R})]}),t.jsx(Nt,{size:15,className:"shrink-0 text-muted-foreground/60"})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-1",children:[A&&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||L,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(P?"同步更新":"已是最新"),children:[v.isPending?t.jsx(Oe,{size:12,className:"animate-spin"}):t.jsx(Rs,{size:12}),t.jsx("span",{children:v.isPending?g("正在同步..."):g("更新")})]}),t.jsxs("button",{type:"button",onClick:O,disabled:!$||_.isPending||L,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(Oe,{size:12,className:"animate-spin"}):t.jsx(ri,{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(Tc,{isOpen:l,onClose:V,branchName:s,targetBranch:r,commitMessage:o,isPending:_.isPending,activeServices:C,isCheckingServices:S.isLoading,serviceCheckFailed:S.isError,error:d,onConfirm:q})]})}const Ma=["creating-workspace","creating-session","starting-session"];function Xc({state:e,setupProgress:s,sessionStarted:r=!1,onRetry:o,compact:p=!1}){const{t:m}=ce(),[x,i]=b.useState(!1),n=e?.status==="failed",a=s?.status==="failed",h=n||a,c=e?Ma.indexOf(e.status):Ma.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(Ua,{className:"h-4 w-4 shrink-0"}):S?t.jsx(Oe,{className:"h-4 w-4 shrink-0 animate-spin motion-reduce:animate-none"}):u==="failed"?t.jsx(Ya,{className:"h-4 w-4 shrink-0"}):t.jsx(du,{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(Ct,{className:"h-3.5 w-3.5"}):t.jsx(Nt,{className:"h-3.5 w-3.5"}),m(x?"Hide setup output":"View setup output")]}):t.jsx("span",{}),n&&o?t.jsx(Re,{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 gx({agentType:e,workingDir:s}){return Pt({queryKey:_e.system.skillCatalog(e,s),queryFn:async()=>(await Ae.get("/system/skill-catalog",{params:{agentType:String(e),...s?{workingDir:s}:{}}})).commands,enabled:e===Et.CODEX,staleTime:3e4})}function vx(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 Gc({agentType:e,workingDir:s,input:r,setInput:o,textareaRef:p,minHeight:m,maxHeight:x}){const[i,n]=b.useState(0),{data:a=[]}=gx({agentType:e,workingDir:s}),c=b.useMemo(()=>e===Et.CODEX?Co(r):null,[e,r])?.query??null,g=b.useMemo(()=>c===null?[]:lu(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):vx(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 ln=200,xx=180;function Qc({taskId:e,title:s,readOnly:r=!1,onTitleChange:o,className:p,titleClassName:m,compact:x=!1}){const{t:i}=ce(),[n,a]=b.useState(!1),[h,c]=b.useState(s),[g,v]=b.useState(!1),_=b.useRef(null),w=b.useRef(null),l=Ga();b.useEffect(()=>{n||c(s)},[s,n]),b.useEffect(()=>{n&&_.current&&(_.current.focus(),_.current.select())},[n]),b.useEffect(()=>{if(!n)return;const j=A=>{w.current&&!w.current.contains(A.target)&&f()};return document.addEventListener("mousedown",j),()=>document.removeEventListener("mousedown",j)},[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 j=h.trim();if(!j){c(s),a(!1);return}if(j===s){a(!1);return}try{await l.mutateAsync({id:e,title:j}),o?.(j),a(!1)}catch(A){console.error("Failed to update task title:",A),c(s)}},[h,s,e,l,o]),S=b.useCallback(j=>{j.key==="Enter"&&!j.shiftKey?(j.preventDefault(),f()):j.key==="Escape"&&(j.preventDefault(),d())},[f,d]),C=b.useCallback(j=>{const A=j.target.value;A.length<=ln&&c(A)},[]),k=h.length,E=k>=xx,y=k>=ln;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(Re,{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(Oe,{size:16,className:"animate-spin"}):t.jsx(Wt,{size:16})}),t.jsx(Re,{size:x?"sm":"default",variant:"ghost",onClick:d,disabled:l.isPending,className:"h-8 w-8 p-0",children:t.jsx(Xt,{size:16})})]})]}),E&&t.jsxs("div",{className:Z("text-xs",y?"text-destructive":"text-muted-foreground"),children:[k," / ",ln," ",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(Re,{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(vu,{size:14})})]})}const bx=Cr(),_x=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${bx}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Bs=520,cn=48,yx=4,Sx=420;function wx(){const{t:e}=ce();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.")})]})}function cr(e){const s=Vs[e].icon;return t.jsx(s,{className:"size-3"})}const Da=[{status:ve.Review,className:"bg-warning/10 text-warning",hoverClass:"hover:bg-warning/15",icon:cr(ve.Review)},{status:ve.Running,className:"bg-info/10 text-info",hoverClass:"hover:bg-info/15",icon:cr(ve.Running)},{status:ve.Pending,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-muted",icon:cr(ve.Pending)},{status:ve.Done,className:"bg-success/10 text-success",hoverClass:"hover:bg-success/15",icon:cr(ve.Done)},{status:ve.Cancelled,className:"bg-muted/50 text-muted-foreground",hoverClass:"hover:bg-border",icon:cr(ve.Cancelled)}];function Cx({status:e,onChangeStatus:s}){const{t:r}=ce(),[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=Da.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:Da.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 kx({task:e,onDeleteTask:s,isDeleting:r,onTaskStatusChange:o,onTaskPriorityChange:p,autoStartState:m,onAutoStartRecovered:x}){const{t:i}=ce(),[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,E]=b.useState(null),y=b.useRef(null),[j,A]=b.useState(!1),[D,M]=b.useState(null),[P,z]=b.useState(void 0),[L,W]=b.useState(!1),$=b.useRef(null),R=b.useRef(null),I=b.useRef(null),T=b.useRef(null),{scrollRef:O,contentRef:q,isAtBottom:V,scrollToBottom:B,stopScroll:U}=Hn({resize:"smooth",initial:"instant"}),[H,N]=b.useState(!1),[F,K]=b.useState(Bs),[Y,se]=b.useState(!1),G=b.useRef(0),me=b.useRef(Bs),ue=b.useRef(null),re=b.useCallback((Q,oe,Ie)=>{y.current?.openFile(Q,oe,Ie)},[]),{data:ne,isLoading:le}=On(e?.id??""),ye=Wc(e?.id),We=ye?.status==="completed"&&m?.status!=="failed"?null:m,ke=!!(We||ye&&ye.status!=="completed"),{data:Ue}=Qa(e?.id??""),{data:at}=Za(Ue?.id??""),Me=Mn(Ue?.id??""),je=Ue??null,Be=!!je,Ke=e?.isGitRepo!==!1&&e?.worktreeReady!==!1,qe=Ue===null&&Ke,De=!!(e?.id&&Ue===null),{data:Ge,isLoading:Qe}=Ja(e?.id??"",De);b.useEffect(()=>{W(!1),M(null),z(void 0)},[e?.id]);const Te=b.useMemo(()=>Gl(ne,je,P),[P,je,ne]);b.useEffect(()=>{P&&!ne?.some(Q=>Q.id===P)&&z(void 0)},[P,ne]);const pe=b.useMemo(()=>ne?.find(Q=>Q.id===Te),[Te,ne]),et=pe?.status===Mt.ACTIVE?pe.id:void 0,Xe=Ke&&Ql(pe,je);b.useEffect(()=>{if(!L||!ne)return;ne.some(oe=>oe.status==="ACTIVE"&&oe.sessions&&oe.sessions.length>0)&&W(!1)},[ne,L]);const $e=b.useMemo(()=>{if(L||!ne)return null;const Q=gt=>{const zi=gt.createdAt,or=gt.endedAt??gt.startedAt??zi;if(!or)return 0;const Ls=Date.parse(or);return Number.isNaN(Ls)?0:Ls},oe=(gt,zi)=>{const or=gt.filter(Ls=>zi.includes(Ls.status));return or.length===0?null:or.sort((Ls,yd)=>Q(yd)-Q(Ls))[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,L]),ft=$e?.id??"",tt=Be?D??"":ft,ee=b.useMemo(()=>{if(!D||!ne)return null;for(const Q of ne){const oe=Q.sessions?.find(Ie=>Ie.id===D);if(oe)return oe}return null},[D,ne]),he=b.useMemo(()=>{if(!D||!je?.invocations)return null;const Q=je.invocations.filter(oe=>oe.sessionId===D);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},[D,je?.invocations]),Se=b.useMemo(()=>!he?.memberId||!je?.members?null:je.members.find(Q=>Q.id===he.memberId)??null,[he?.memberId,je?.members]),X=D?ee:$e??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]),we=b.useCallback((Q,oe)=>{ae({kind:"web",url:Q},oe)},[ae]),Ce=b.useCallback((Q,oe,Ie)=>{ae({kind:"visualization",sessionId:Q,file:oe},Ie)},[ae]),Pe=b.useCallback(Q=>{we(Q,ie)},[ie,we]),Je=b.useCallback(Q=>{te&&Ce(te,Q,ie)},[te,ie,Ce]),{isActive:be,isCancelling:xe}=ll(te??"",X?.status),fe=!!e?.projectArchivedAt,Fe=!!e?.projectRepoDeletedAt,st=i(Fe?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:lt}=Gs(),[kt,St]=b.useState(null),vt=$e?vl(lt,kt??$e.providerId):void 0;b.useEffect(()=>{St($e?.providerId??null)},[$e?.providerId]);const It=b.useMemo(()=>!$e||!ne?!1:!ne.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(Ie=>Ie.id===$e.id)),[$e,ne]),wt=b.useMemo(()=>{if(!(!ne||L)){if(pe)return hs(pe);for(const Q of ne)if(Q.status==="ACTIVE"&&hs(Q))return hs(Q);return hs(ne[0])}},[L,pe,ne]),Rt=cl({agentType:$e?.agentType,workingDir:wt,input:n,setInput:a,textareaRef:I,minHeight:60,maxHeight:300}),Ut=Gc({agentType:$e?.agentType,workingDir:wt,input:n,setInput:a,textareaRef:I,minHeight:60,maxHeight:300}),er=Xs(Q=>Q.setVisibleContext),$t=!!(Xe&&et&&wt&&!fe),{data:bt,isLoading:Mi}=Bn(et??"",{enabled:$t}),{data:Gt}=Ti(wt,{enabled:$t});b.useEffect(()=>{if(!(H||!$t||!et||!wt))return er({workspaceId:et,workingDir:wt,tab:"changes"}),()=>{er(null)}},[H,et,er,$t,wt]);const Qt=pe?.sessions??[],ss=Ys(pe),xs=pe?.commitMessage,As=b.useMemo(()=>Zl(pe,ne,e?.mainBranch??""),[pe,e?.mainBranch,ne]),rt=b.useMemo(()=>bt?.conflictOp&&bt.conflictedFiles.length>0?{conflictOp:bt.conflictOp,conflictedFiles:bt.conflictedFiles}:k,[bt?.conflictOp,bt?.conflictedFiles,k]),tr=rt?.targetWorkspaceId??et,Dr=rt?.targetWorktreePath??pe?.worktreePath,Pr=rt?.sourceBranch??ss,Lr=rt?.targetBranch??As,it=Lt(),Ts=b.useCallback(async()=>e?.id?it.fetchQuery({queryKey:_e.tasks.body(e.id),queryFn:()=>Ae.get(`/tasks/${e.id}/body`)}):null,[it,e?.id]),bs=b.useCallback(()=>e?.id?it.invalidateQueries({queryKey:_e.workspaces.list(e.id)}):Promise.resolve(),[e?.id,it]);b.useEffect(()=>{if(!j)return;const Q=oe=>{R.current&&!R.current.contains(oe.target)&&A(!1)};return document.addEventListener("mousedown",Q),()=>document.removeEventListener("mousedown",Q)},[j]);const Zt=qn(),Ir=zn(),_s=Bd(),Or=ol(e?.id??""),sr=$n(),Ms=su(),Ot=b.useMemo(()=>!ne||ne.some(oe=>oe.status==="ACTIVE")?null:ne.find(oe=>oe.status==="HIBERNATED")??null,[ne]),rs=b.useRef(null);b.useEffect(()=>{Ot&&rs.current!==Ot.id&&(Ms.isPending||(rs.current=Ot.id,Ms.mutate(Ot.id,{onSettled:()=>{rs.current=null}})))},[Ot,Ms]);const Di=b.useCallback(async()=>{if(!e?.id)return;const Q=$e?.providerId??lt?.find(oe=>oe.availability.type!=="NOT_FOUND")?.provider.id;if(Q){u(!1),f(!0);try{const Ie=(await Ts())?.prompt??e.title;await _s.mutateAsync(e.id),W(!0);const mt=await Or.mutateAsync({workspaceKind:Ke?void 0:xt.MAIN_DIRECTORY}),pt=await Ae.post(`/workspaces/${mt.id}/sessions`,{providerId:Q,prompt:Ie});await sr.mutateAsync(pt.id),await it.invalidateQueries({queryKey:_e.workspaces.list(e.id)})}catch(oe){console.error("[retry] failed:",oe),W(!1)}finally{f(!1)}}},[e?.id,e?.title,Ke,$e?.providerId,lt,Ts,_s,Or,sr,it]),Ds=b.useCallback(async()=>{e?.id&&(await Ts(),c(!0))},[Ts,e?.id]),Br=b.useCallback(()=>{pe?.id&&Ir.mutate({workspaceId:pe.id})},[Ir,pe?.id]),rr=b.useCallback(()=>{!e?.id||!s||(s(e.id),w(!1))},[e?.id,s]),ir=b.useCallback(Q=>{M(Q),requestAnimationFrame(()=>{B()})},[B]),Pi=b.useCallback(()=>{M(null)},[]),Ps=b.useCallback(Q=>{E(Q??null),C(!0)},[]),Fr=b.useCallback(Q=>Me.mutateAsync(Q),[Me]),is=b.useCallback(()=>{it.invalidateQueries({queryKey:Fd.all})},[it]),{isConnected:zr,isLoadingSnapshot:nr,isOutputActive:Wr,lastExitAt:Hr,logs:ys,entries:Li,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=ls.connect();Q.emit(Fs.SUBSCRIBE,{topic:"task",id:e.id});const oe=pt=>{pt.taskId===e.id&&(it.invalidateQueries({queryKey:["tasks"]}),is())},Ie=pt=>{pt.taskId===e.id&&(it.invalidateQueries({queryKey:_e.workspaces.list(e.id)}),is())},mt=pt=>{pt.taskId===e.id&&(it.invalidateQueries({queryKey:_e.workspaces.list(e.id)}),is())};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(Fs.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,it,is]),b.useEffect(()=>{if(!tt)return;const Q=ls.connect(),oe=Ie=>{Ie.sessionId===tt&&(it.invalidateQueries({queryKey:["workspaces"]}),is())};return Q.on(dt.SESSION_COMPLETED,oe),()=>{Q.off(dt.SESSION_COMPLETED,oe)}},[tt,it,is]);const{todos:J}=gl(Li),{files:ge,addFiles:Ne,removeFile:ze,clear:_t,buildMarkdownLinks:Bt,hasFiles:Le,isUploading:Ft}=Dn(),ns=b.useMemo(()=>Uc(X),[X?.tokenUsage]),Ss=dl(ys,ns);b.useEffect(()=>{tt&&zr&&Kt()},[tt,zr,Kt]);const go=b.useRef(e?.id);b.useEffect(()=>{if(go.current!==e?.id&&O.current){const Q=O.current;requestAnimationFrame(()=>{Q.scrollTop=Q.scrollHeight})}go.current=e?.id},[e?.id,O]);const os=ul(),Ii=b.useRef(!1),vo=b.useCallback(async()=>{if(!n.trim()&&!Le||!tt||Ii.current||os.isPending||xe||Ft||vt)return;Ii.current=!0;const Q=Bt(),oe=[n.trim(),Q].filter(Boolean).join(`
76
-
77
- `);a(""),_t(),I.current&&(I.current.style.height="60px"),Zt.mutate({id:tt,message:oe,providerId:kt??void 0},{onSuccess:()=>{Kt()},onError:()=>{a(Ie=>Ie||oe)},onSettled:()=>{Ii.current=!1}})},[n,tt,Zt,Kt,Le,Ft,Bt,_t,kt,vt,os.isPending,xe]),hd=b.useCallback(()=>{!tt||os.isPending||os.mutate(tt)},[tt,os]),fd=b.useCallback(Q=>{const oe=Q.target.files;oe&&oe.length>0&&Ne(Array.from(oe)),Q.target.value=""},[Ne]),md=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(),Ne(Ie))},[Ne]),[xo,Oi]=b.useState(!1),pd=b.useCallback(Q=>{Q.preventDefault(),Oi(!0)},[]),gd=b.useCallback(Q=>{Q.preventDefault(),Oi(!1)},[]),vd=b.useCallback(Q=>{Q.preventDefault(),Oi(!1);const oe=Q.dataTransfer.files;oe.length>0&&Ne(Array.from(oe))},[Ne]),Jt=b.useCallback(Q=>{const oe=ue.current?.getBoundingClientRect().width??(typeof window<"u"?window.innerWidth:void 0),Ie=oe?Math.max(Bs,oe-cn-yx-Sx):Bs;return Math.max(Bs,Math.min(Math.round(Q),Ie))},[]),Bi=b.useCallback(Q=>{const oe=Q.clientX-G.current;K(Jt(me.current-oe))},[Jt]),Fi=b.useCallback(()=>{se(!1),document.body.style.cursor="",document.body.style.userSelect=""},[]);b.useEffect(()=>{if(Y)return document.addEventListener("mousemove",Bi),document.addEventListener("mouseup",Fi),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Bi),document.removeEventListener("mouseup",Fi),document.body.style.cursor="",document.body.style.userSelect=""}},[Fi,Bi,Y]);const xd=b.useCallback(Q=>{Q.preventDefault(),G.current=Q.clientX,me.current=F,se(!0)},[F]);b.useEffect(()=>{!H||Y||K(Q=>Jt(Q))},[Jt,H,Y]),b.useEffect(()=>{if(!H)return;const Q=()=>{K(oe=>Jt(oe))};return window.addEventListener("resize",Q),()=>window.removeEventListener("resize",Q)},[Jt,H]);const bd=b.useCallback(()=>{K(Q=>Jt(Q)),N(!0),requestAnimationFrame(()=>{y.current?.setTab("review")})},[Jt]),_d=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`},[]),bo=$t&&et?t.jsx(Yc,{workspaceId:et,branchName:ss,targetBranch:As,commitMessage:xs,changes:Gt,gitStatus:bt,isGitStatusLoading:Mi,canRunGitOperations:Xe,onOpenChanges:bd,onRefreshCommitMessage:bs,onConflict:Ps,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(Qc,{taskId:e.id,title:e.title,readOnly:fe})]}),t.jsxs("div",{className:"flex items-center gap-3 flex-shrink-0",children:[t.jsx(Cx,{status:e.status,onChangeStatus:!fe&&o?Q=>o(e.id,Q):void 0}),t.jsx(hl,{value:e.priority,onChange:!fe&&p?Q=>p(e.id,Q):void 0}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx("button",{onClick:Br,disabled:!wt||fe,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(bi,{size:16})}),(s||qe)&&!fe&&t.jsxs("div",{className:"relative",ref:R,children:[t.jsx("button",{onClick:()=>A(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(Sl,{size:16})}),j&&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),A(!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(ds,{size:15}),t.jsx("span",{children:i("创建 TeamRun")})]}),t.jsxs("button",{onClick:()=>{u(!0),A(!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(zd,{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),A(!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(gi,{size:15}),t.jsx("span",{children:i("删除任务")})]})]})]})]})]})]})]}),Xe&&et&&bt&&t.jsx(cx,{workspaceId:et,gitStatus:bt,onResolve:()=>Ps()}),t.jsxs("div",{ref:ue,className:"flex-1 flex overflow-hidden",children:[t.jsx("div",{className:"flex min-w-0 flex-1 flex-col bg-background relative",children:Be&&je?D?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:D})]}),t.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[t.jsx($c,{session:X,providers:lt,usage:Ss,providerIdFallback:Se?.providerId,agentTypeFallback:X?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Re,{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:Pi,children:[t.jsx($s,{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:q,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...")})]}):ys.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(ti,{children:t.jsx(Jr,{logs:ys,downloadSessionId:te,isOutputActive:Wr,lastExitAt:Hr,onUserToggleDetails:U,workingDir:wt,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(br,{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(si,{todos:J})})})]}):t.jsx(Xl,{teamRun:je,messages:at??je.messages??[],readOnly:fe,readOnlyMessage:st,onSendMessage:Fr,onViewInvocationSession:ir,changeSummaryBar:bo,centered:!0,workingDir:wt,onOpenWorkspaceFile:re,onOpenPreviewUrl:we,onOpenVisualization:Ce}):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:q,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(Ln,{urlTransform:_x,components:sl,children:Ge.body})}):null}),!fe&&t.jsx(Xc,{state:We,setupProgress:ye,sessionStarted:!!$e?.startedAt,onRetry:ft&&m?.status==="failed"?Ds:void 0},e.id),le?(!ke||fe)&&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...")})]}):ys.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(ti,{children:t.jsx(Jr,{logs:ys,downloadSessionId:te,isOutputActive:Wr,lastExitAt:Hr,onUserToggleDetails:U,workingDir:wt,scrollElementRef:O,onOpenWorkspaceFile:re,onOpenPreviewUrl:Pe,onOpenVisualization:Je})}):!ke||m?.status==="failed"||ye?.status==="failed"||fe?t.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[(!ke||fe)&&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(Cs,{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(fe?"项目为只读历史":"尚未启动 Agent")}),t.jsx("p",{className:"text-sm text-muted-foreground mb-6 max-w-xs",children:fe?st:i("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")})]}),!fe&&(!m||m.status==="failed")&&t.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[t.jsxs(Re,{onClick:Ds,disabled:!!(m&&m.status!=="failed"),children:[t.jsx(Cs,{size:16,className:"mr-1.5"}),m?.status==="failed"?i("重试启动 Agent"):i("启动 Agent")]}),qe&&t.jsxs(Re,{variant:"outline",onClick:()=>v(!0),children:[t.jsx(ds,{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(br,{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(si,{todos:J})})}),fe?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(Re,{size:"sm",onClick:Ds,children:[t.jsx(Cs,{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:pd,onDragLeave:gd,onDrop:vd,children:[t.jsxs("div",{className:"max-w-4xl mx-auto",children:[bo,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 ${xo?"border-info bg-info/5":"border-border"}`,children:[t.jsx(Pn,{files:ge,onRemove:ze}),t.jsx("textarea",{ref:I,value:n,onChange:_d,onPaste:md,onKeyDown:Q=>{Ut.handleKeyDown(Q)||Rt.handleKeyDown(Q)||Q.key==="Enter"&&!Q.shiftKey&&!Q.repeat&&!Q.nativeEvent.isComposing&&Q.nativeEvent.keyCode!==229&&(Q.preventDefault(),vo())},rows:1,placeholder:i(xo?"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:fd}),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(Vn,{size:18})})}),t.jsxs("div",{className:"flex items-center gap-2",children:[$e&&lt&&t.jsx(ml,{providers:lt,currentProviderId:kt,agentType:$e.agentType,runtimeType:$e.runtimeType,onSelect:St}),t.jsx(Kn,{usage:Ss}),be&&!n.trim()&&!Le?t.jsx("button",{onClick:hd,disabled:os.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(Us,{size:14})}):t.jsx("button",{onClick:vo,disabled:!n.trim()&&!Le||Ft||Zt.isPending||os.isPending||xe||!!vt,className:`p-2 rounded-lg transition-all duration-200 ${(n.trim()||Le)&&!Ft&&!Zt.isPending&&!os.isPending&&!xe&&!vt?"bg-primary text-primary-foreground hover:bg-primary/90":"bg-transparent text-muted-foreground/50 cursor-not-allowed"}`,children:t.jsx(Un,{size:18})})]})]})]})]}),t.jsx(ei,{open:Rt.query!==null,anchorRef:$,commands:Rt.filteredCommands,selectedIndex:Rt.selectedIndex,query:Rt.query??"",hasCatalog:Rt.allCommands.length>0,onSelect:Rt.applyCommand}),t.jsx(ei,{open:Ut.query!==null,anchorRef:$,commands:Ut.filteredSkills,selectedIndex:Ut.selectedIndex,query:Ut.query??"",hasCatalog:Ut.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Ut.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:xd,role:"separator","aria-orientation":"vertical","aria-label":i("调整工作区宽度")}),t.jsx("div",{className:"flex h-full flex-shrink-0 bg-background",style:{width:H?cn+F:cn},children:t.jsx(zc,{sessionId:ft||void 0,workspaceId:Te,workingDir:wt,projectId:e.projectId,readOnly:fe,repoDeleted:Fe,teamRun:je,teamStatus:je?t.jsx(tc,{teamRun:je,workspaces:ne,selectedWorkspaceId:Te,onSelectWorkspace:z,onViewInvocationSession:ir}):void 0,workspaces:ne,selectedWorkspaceId:Te,onSelectWorkspace:z,variant:"rail",expanded:H,onExpandedChange:Q=>{Q&&K(oe=>Jt(oe)),N(Q)},minContentWidth:Bs,tabRef:y,gitAvailable:Ke,gitProps:Xe&&et?{branchName:ss,targetBranch:As,commitMessage:xs,canRunGitOperations:!0,onRefreshCommitMessage:bs,onConflict:Ps,onResolveConflicts:()=>Ps()}:void 0})})]}),!fe&&t.jsx(Hc,{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&&!fe&&t.jsx(lx,{isOpen:g,onClose:()=>v(!1),taskId:e.id}),Xe&&tr&&rt&&t.jsx(Vc,{open:S,onOpenChange:Q=>{C(Q),Q||E(null)},workspaceId:tr,conflictOp:rt.conflictOp,conflictedFiles:rt.conflictedFiles,sourceBranch:Pr,targetBranch:Lr,operation:bt?.operation,worktreePath:Dr,mergeAborted:rt.mergeAborted,mergeStrategy:rt.mergeStrategy,sourceWorkspaceId:rt.sourceWorkspaceId,targetWorkspaceId:rt.targetWorkspaceId,sourceWorktreePath:rt.sourceWorktreePath,targetWorktreePath:rt.targetWorktreePath,sessions:Qt,currentSessionId:Be?void 0:ft,teamRunId:je?.id}),t.jsx(In,{isOpen:l,onClose:()=>u(!1),onConfirm:Di,title:i("重新开始任务"),description:t.jsx("p",{children:i("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:i("确认重试"),variant:"default",isLoading:d}),t.jsx(io,{isOpen:_,onClose:()=>w(!1),onConfirm:rr,taskId:e.id,taskTitle:e.title,workspaces:ne,isLoading:r})]}):t.jsx(wx,{})}function po(e){switch(e){case Vt.TODO:return ve.Pending;case Vt.IN_PROGRESS:return ve.Running;case Vt.IN_REVIEW:return ve.Review;case Vt.DONE:return ve.Done;case Vt.CANCELLED:return ve.Cancelled}}function Ex(e){switch(e){case ve.Pending:return Vt.TODO;case ve.Running:return Vt.IN_PROGRESS;case ve.Review:return Vt.IN_REVIEW;case ve.Done:return Vt.DONE;case ve.Cancelled:return Vt.CANCELLED}}function jx(e){switch(e){case Et.CLAUDE_CODE:return"Claude Code";case Et.GEMINI_CLI:return"Gemini CLI";case Et.CURSOR_AGENT:return"Cursor Agent";case Et.CODEX:return"Codex";case Et.QWEN_CODE:return"Qwen Code";case Et.KIRO_CLI:return"Kiro CLI";case Et.OPENCODE:return"OpenCode";case Et.PI_CODING_AGENT:return"Pi Coding Agent";case Et.GROK_BUILD:return"Grok Build";case Et.MINION_CODE:return"Minion Code";case Et.DEEPSEEK_HERMES:return"DeepSeek Harness"}}const fi=["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 Zc(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 Nx(e){return{id:e.id,name:e.name,color:e.color||fi[Zc(e.name,fi.length)],isGitRepo:e.isGitRepo,worktreeReady:e.worktreeReady,reason:e.reason,archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function Rx(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===xt.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:e.projectId,title:e.title,status:po(e.status),priority:e.priority,agent:e.latestAgentType?jx(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 Ax(e,s){const r=e.preferredWorkspace?e.preferredWorkspace.workspaceKind===xt.MAIN_DIRECTORY?"Project directory":e.preferredWorkspace.branchName:"—";return{id:e.id,projectId:s.id,projectName:s.name,projectColor:s.color||fi[Zc(s.name,fi.length)],title:e.title,status:po(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 Pa={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 Tx(e){const s=e.split("/");return s[s.length-1]||e}function Mx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Dx({workingDir:e,filePath:s,type:r}){const{t:o}=ce(),{data:p,isLoading:m,isError:x}=Nc(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(Oe,{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 Px({entry:e,type:s,workingDir:r}){const[o,p]=b.useState(!1),m=Pa[e.status]||Pa.M,x=Mx(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:Tx(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(Ct,{size:14}):t.jsx(Nt,{size:14})})]}),o&&t.jsx(Dx,{workingDir:r,filePath:e.path,type:s})]})}function La({title:e,entries:s,type:r,workingDir:o,defaultOpen:p}){const{t:m}=ce(),[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(Ct,{size:14}):t.jsx(Nt,{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(Px,{entry:n,type:r,workingDir:o},`${r}:${n.path}`))})]})}function Lx({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:p}=Ti(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(Oe,{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(La,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),t.jsx(La,{title:"Committed",entries:x,type:"committed",workingDir:e,defaultOpen:!1})]})}const dn=50,Ia={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 Ix(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?Tt("{count}s ago",{count:r}):r<3600?Tt("{count}m ago",{count:Math.floor(r/60)}):r<86400?Tt("{count}h ago",{count:Math.floor(r/3600)}):r<604800?Tt("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Ox(e){const s=e.split("/");return s[s.length-1]||e}function Bx(e){const s=e.lastIndexOf("/");return s>0?e.slice(0,s):""}function Fx({workingDir:e,hash:s,filePath:r}){const{t:o}=ce(),{data:p,isLoading:m,isError:x}=mo(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(Oe,{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 zx({entry:e,workingDir:s,hash:r}){const[o,p]=b.useState(!1),m=Ia[e.status]||Ia.M,x=Bx(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:Ox(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(Ct,{size:14}):t.jsx(Nt,{size:14})})]}),o&&t.jsx(Fx,{workingDir:s,hash:r,filePath:e.path})]})}function Wx({commit:e,workingDir:s}){const{t:r}=ce(),[o,p]=b.useState(!1),{data:m,isLoading:x}=fo(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:Ix(e.timestamp)})]})]}),t.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:o?t.jsx(Ct,{size:14}):t.jsx(Nt,{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(Oe,{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(zx,{entry:n,workingDir:s,hash:e.hash},n.path))})]})]})}function Hx({workingDir:e}){const{t:s}=ce(),{data:r,isLoading:o,isError:p,fetchNextPage:m,hasNextPage:x,isFetchingNextPage:i}=Xn({queryKey:_e.git.log(e||""),queryFn:({pageParam:a=0})=>Ae.get("/git/log",{params:{workingDir:e||"",limit:String(dn),skip:String(a)}}),initialPageParam:0,getNextPageParam:(a,h)=>a.commits.length<dn?void 0:h.length*dn,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(Oe,{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(qs,{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(Wx,{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(Oe,{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 Ux=Cr(),$x=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${Ux}/attachments/by-path?path=${encodeURIComponent(e)}`:e;function Kx({status:e}){const s={[ve.Running]:"bg-blue-500",[ve.Review]:"bg-amber-500",[ve.Pending]:"bg-neutral-400",[ve.Done]:"bg-emerald-500",[ve.Cancelled]:"bg-neutral-400"};return t.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${s[e]}`})}const qx=[{key:"chat",label:"Chat",icon:vi},{key:"changes",label:"Changes",icon:Qs},{key:"history",label:"History",icon:qs},{key:"workspace",label:"Workspace",icon:_i}],Vx=[{key:"chat",label:"Team room",icon:vi},{key:"team-status",label:"Team Status",icon:Es},{key:"changes",label:"Changes",icon:Qs},{key:"workspace",label:"Workspace",icon:_i}];function Yx({task:e,onBack:s,onDeleteTask:r,onTaskPriorityChange:o,isDeleting:p,autoStartState:m,onAutoStartRecovered:x}){const{t:i}=ce(),n=Xs(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),E=b.useRef(0),[y,j]=b.useState(),A=b.useRef(null),D=b.useRef(null),M=b.useRef(null),P=b.useRef(null),{scrollRef:z,contentRef:L,isAtBottom:W,scrollToBottom:$,stopScroll:R}=Hn({resize:"smooth",initial:"instant"}),I=Lt();b.useEffect(()=>{if(!u)return;const J=ge=>{D.current&&!D.current.contains(ge.target)&&d(!1)};return document.addEventListener("mousedown",J),()=>document.removeEventListener("mousedown",J)},[u]);const{data:T,isLoading:O}=On(e.id),q=Wc(e.id),V=q?.status==="completed"&&m?.status!=="failed"?null:m,B=!!(V||q&&q.status!=="completed"),{data:U}=Qa(e.id),{data:H}=Za(U?.id??""),N=Mn(U?.id??""),F=U??null,K=e.isGitRepo!==!1&&e.worktreeReady!==!1,Y=b.useMemo(()=>(F?Vx:qx).filter(J=>K||J.key!=="changes"&&J.key!=="history"),[K,F]),se=U===null,{data:G,isLoading:me}=Ja(e.id,se),ue=!!e.projectArchivedAt,re=!!e.projectRepoDeletedAt,ne=i(re?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。");b.useEffect(()=>{k(void 0),S(null),j(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(()=>Gl(T,F,C),[C,F,T]);b.useEffect(()=>{C&&!T?.some(J=>J.id===C)&&k(void 0)},[C,T]);const ye=b.useMemo(()=>T?.find(J=>J.id===le),[le,T]),We=b.useMemo(()=>{if(T){if(ye)return hs(ye);for(const J of T)if(J.status==="ACTIVE"&&hs(J))return hs(J);return hs(T[0])}},[ye,T]),ke=ye?.status===Mt.ACTIVE?ye.id:void 0,Ue=K&&Ql(ye,F),at=ye?.branchName??"",Me=ye?.commitMessage,je=b.useMemo(()=>Zl(ye,T,e?.mainBranch??""),[ye,e?.mainBranch,T]),Be=!!(Ue&&ke&&We&&!ue),{data:Ke,isLoading:qe}=Bn(ke??"",{enabled:Be}),{data:De}=Ti(We,{enabled:Be}),Ge=De?.committed?.length,[Qe,Te]=b.useState(!1),[pe,et]=b.useState(null);b.useEffect(()=>{const J=K&&(a==="changes"||a==="chat"&&Be)?"changes":K&&a==="history"?"history":null;if(!ke||!We||!J){n(null);return}return n({workspaceId:ke,workingDir:We,tab:J}),()=>{n(null)}},[a,K,ke,n,Be,We]);const Xe=b.useMemo(()=>Ke?.conflictOp&&Ke.conflictedFiles.length>0?{conflictOp:Ke.conflictOp,conflictedFiles:Ke.conflictedFiles}:pe,[Ke?.conflictOp,Ke?.conflictedFiles,pe]),$e=Xe?.targetWorkspaceId??ke,ft=Xe?.targetWorktreePath??ye?.worktreePath,tt=Xe?.sourceBranch??at,ee=Xe?.targetBranch??je,he=ye?.sessions??[],Se=b.useCallback(J=>{et(J??null),Te(!0)},[]),X=b.useCallback(()=>e?.id?I.invalidateQueries({queryKey:_e.workspaces.list(e.id)}):Promise.resolve(),[e?.id,I]),te=b.useCallback(async()=>I.fetchQuery({queryKey:_e.tasks.body(e.id),queryFn:()=>Ae.get(`/tasks/${e.id}/body`)}),[I,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??[]),ge=Le=>{const Ft=Le.createdAt,ns=Le.endedAt??Le.startedAt??Ft;if(!ns)return 0;const Ss=Date.parse(ns);return Number.isNaN(Ss)?0:Ss},Ne=Le=>{const Ft=J.filter(ns=>Le.includes(ns.status));return Ft.length===0?null:Ft.sort((ns,Ss)=>ge(Ss)-ge(ns))[0]??null},ze=Ne([ut.RUNNING])??Ne([ut.PENDING])??Ne([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)=>ge(Ft)-ge(Le))[0]??null},[T]),ae=ie?.id??"",we=F?f??"":ae,Ce=b.useMemo(()=>{if(!f||!T)return null;for(const J of T){const ge=J.sessions?.find(Ne=>Ne.id===f);if(ge)return ge}return null},[f,T]),Pe=b.useMemo(()=>{if(!f||!F?.invocations)return null;const J=F.invocations.filter(ge=>ge.sessionId===f);return J.length===0?null:J.sort((ge,Ne)=>{const ze=Date.parse(ge.updatedAt??ge.createdAt??""),_t=Date.parse(Ne.updatedAt??Ne.createdAt??"");return(Number.isNaN(_t)?0:_t)-(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?Ce:ie??null,xe=be?.id,fe=b.useMemo(()=>{if(be?.workspaceId)return be.workspaceId;if(!(!be||!T))return T.find(J=>J.sessions?.some(ge=>ge.id===be.id))?.id},[be,T]),Fe=b.useCallback((J,ge)=>{const ze=(ge&&T?.some(_t=>_t.id===ge)?ge:void 0)??fe??le??void 0;ze&&k(ze),E.current+=1,j({id:E.current,source:J,workspaceId:ze}),h("workspace")},[fe,le,T]),st=b.useCallback((J,ge)=>{Fe({kind:"web",url:J},ge)},[Fe]),lt=b.useCallback((J,ge,Ne)=>{Fe({kind:"visualization",sessionId:J,file:ge},Ne)},[Fe]),kt=b.useCallback(J=>{st(J,fe)},[fe,st]),St=b.useCallback(J=>{xe&&lt(xe,J,fe)},[xe,fe,lt]),{isActive:vt,isCancelling:It}=ll(xe??"",be?.status),wt=b.useMemo(()=>!ie||!T?!1:!T.some(ge=>ge.status==="ACTIVE"&&ge.sessions?.some(Ne=>Ne.id===ie.id)),[ie,T]),{data:Rt}=Gs(),[Ut,er]=b.useState(null),$t=Ut?.sessionId===ae?Ut.providerId:ie?.providerId??null,bt=ie?vl(Rt,$t):void 0,Mi=b.useCallback(J=>{er({sessionId:ae,providerId:J})},[ae]),Gt=cl({agentType:ie?.agentType,workingDir:We,input:c,setInput:g,textareaRef:M,minHeight:40,maxHeight:140}),Qt=Gc({agentType:ie?.agentType,workingDir:We,input:c,setInput:g,textareaRef:M,minHeight:40,maxHeight:140}),ss=We&&ye?ye.id:void 0,xs=qn(),As=zn(),rt=ul(),{isConnected:tr,isLoadingSnapshot:Dr,isOutputActive:Pr,lastExitAt:Lr,logs:it,entries:Ts,attach:bs}=pl({sessionId:we,sessionStatus:be?.status,sessionStartedAt:be?.startedAt??be?.createdAt,sessionEndedAt:be?.endedAt??(vt?null:be?.updatedAt),onExit:b.useCallback(()=>{I.invalidateQueries({queryKey:["workspaces"]})},[I])}),{todos:Zt}=gl(Ts),{files:Ir,addFiles:_s,removeFile:Or,clear:sr,buildMarkdownLinks:Ms,hasFiles:Ot,isUploading:rs}=Dn(),Di=b.useMemo(()=>Uc(be),[be?.tokenUsage]),Ds=dl(it,Di);b.useEffect(()=>{we&&tr&&bs()},[we,tr,bs]);const Br=b.useRef(null);b.useEffect(()=>{if(Br.current!==e.id&&z.current){const J=z.current;requestAnimationFrame(()=>{J.scrollTop=J.scrollHeight})}Br.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||rs||bt)return;rr.current=!0;const J=Ms(),ge=[c.trim(),J].filter(Boolean).join(`
80
-
81
- `);g(""),sr(),M.current&&(M.current.style.height="40px"),xs.mutate({id:ae,message:ge,providerId:$t??void 0},{onSuccess:()=>bs(),onError:()=>g(Ne=>Ne||ge),onSettled:()=>{rr.current=!1}})},[c,ae,xs,bs,Ot,rs,Ms,sr,$t,bt,rt.isPending,It]),Pi=b.useCallback(()=>{!ae||rt.isPending||rt.mutate(ae)},[ae,rt]),Ps=b.useCallback(J=>N.mutateAsync(J),[N]),Fr=b.useCallback(J=>{S(J),h("chat"),requestAnimationFrame(()=>{$()})},[$]),is=b.useCallback(()=>{S(null)},[]),zr=b.useCallback(()=>{h("changes")},[]),nr=Be&&ke?t.jsx(Yc,{workspaceId:ke,branchName:at,targetBranch:je,commitMessage:Me,changes:De,gitStatus:Ke,isGitStatusLoading:qe,canRunGitOperations:Ue,onOpenChanges:zr,onRefreshCommitMessage:X,onConflict:Se,className:"mb-2"}):null,Wr=b.useCallback(J=>{const ge=J.target.files;ge&&ge.length>0&&_s(Array.from(ge)),J.target.value=""},[_s]),Hr=b.useCallback(J=>{const ge=J.clipboardData.items,Ne=[];for(const ze of ge)if(ze.kind==="file"){const _t=ze.getAsFile();_t&&Ne.push(_t)}Ne.length>0&&(J.preventDefault(),_s(Ne))},[_s]),ys=b.useCallback(J=>{g(J.target.value);const ge=J.target;ge.style.height="auto",ge.style.height=`${Math.max(40,Math.min(ge.scrollHeight,140))}px`},[]),Li=b.useCallback(()=>{ss&&As.mutate({workspaceId:ss})},[As,ss]),Kt=b.useRef(null);return b.useEffect(()=>{const J=window.visualViewport;if(!J)return;let ge=!1;const Ne=()=>{Kt.current&&(Kt.current.style.height=`${J.height}px`,Kt.current.style.top=`${J.offsetTop}px`)},ze=()=>Ne(),_t=()=>{ge||Ne()},Bt=()=>{ge=!0},Le=()=>{ge=!1,requestAnimationFrame(Ne)};return J.addEventListener("resize",ze),J.addEventListener("scroll",_t),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",_t),document.removeEventListener("touchstart",Bt),document.removeEventListener("touchend",Le),document.removeEventListener("touchcancel",Le)}},[]),b.useEffect(()=>{const J=Kt.current;if(!J)return;const ge=Ne=>{let ze=Ne.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}Ne.preventDefault()};return J.addEventListener("touchmove",ge,{passive:!1}),()=>J.removeEventListener("touchmove",ge)},[]),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($s,{size:18})}),t.jsxs("div",{className:"flex-1 min-w-0",children:[t.jsx(Qc,{taskId:e.id,title:e.title,readOnly:ue,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(Kx,{status:e.status}),t.jsx(hl,{value:e.priority,compact:!0,onChange:!ue&&o?J=>o(e.id,J):void 0}),t.jsx("button",{onClick:Li,disabled:!ss||ue,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:t.jsx(bi,{size:16})}),r&&!ue&&t.jsxs("div",{className:"relative",ref:D,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(Sl,{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(gi,{size:15}),t.jsx("span",{children:i("删除任务")})]})})]})]}),t.jsx("div",{className:"flex border-t border-neutral-100",children:Y.map(({key:J,label:ge,icon:Ne})=>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(Ne,{size:13,className:"shrink-0"}),t.jsx("span",{className:"truncate",children:i(ge)})]},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($c,{session:be,providers:Rt,usage:Ds,compact:!0,providerIdFallback:Je?.providerId,agentTypeFallback:be?.agentType,tokenTooltipSide:"bottom"}),t.jsxs(Re,{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:is,children:[t.jsx($s,{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:L,children:Dr?t.jsx(un,{label:i("Loading logs...")}):it.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:i(vt?"Waiting for agent output...":"No logs recorded for this session.")}):t.jsx(ti,{children:t.jsx(Jr,{logs:it,downloadSessionId:xe,isOutputActive:Pr,lastExitAt:Lr,onUserToggleDetails:R,scrollElementRef:z,onOpenPreviewUrl:kt,onOpenVisualization:St})})})}),!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(br,{size:12}),t.jsx("span",{children:i("回到底部")})]})]}),Zt.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(si,{todos:Zt,compact:!0})})]}):t.jsx(Xl,{teamRun:F,messages:H??F.messages??[],readOnly:ue,readOnlyMessage:ne,onSendMessage:Ps,onViewInvocationSession:Fr,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:L,children:[t.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:me?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(Ln,{urlTransform:$x,components:sl,children:G.body})}):t.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),!ue&&t.jsx(Xc,{state:V,setupProgress:q,sessionStarted:!!ie?.startedAt,onRetry:ae&&m?.status==="failed"?async()=>{await te(),_(!0)}:void 0,compact:!0},e.id),O?(!B||ue)&&t.jsx(un,{label:"Loading..."}):ae?Dr?t.jsx(un,{label:"Loading logs..."}):it.length===0?t.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:vt?"Waiting for agent output...":"No logs recorded."}):t.jsx(ti,{children:t.jsx(Jr,{logs:it,downloadSessionId:xe,isOutputActive:Pr,lastExitAt:Lr,onUserToggleDetails:R,scrollElementRef:z,onOpenPreviewUrl:kt,onOpenVisualization:St})}):!B||m?.status==="failed"||q?.status==="failed"||ue?t.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[(!B||ue)&&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(Cs,{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:ue?ne:i("选择一个 Agent 来执行此任务")})]}),!ue&&(!m||m.status==="failed")&&t.jsxs(Re,{onClick:async()=>{await te(),_(!0)},disabled:!!(m&&m.status!=="failed"),children:[t.jsx(Cs,{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(br,{size:12}),t.jsx("span",{children:i("回到底部")})]})]}),Zt.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(si,{todos:Zt,compact:!0})}),ue?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})}):wt?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(Re,{size:"sm",onClick:async()=>{await te(),_(!0)},children:[t.jsx(Cs,{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:we||ae,compact:!0}),t.jsxs("div",{ref:A,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[t.jsx(Pn,{files:Ir,onRemove:Or}),t.jsx("textarea",{ref:M,value:c,onChange:ys,onPaste:Hr,onKeyDown:J=>{Qt.handleKeyDown(J)||Gt.handleKeyDown(J)||J.key==="Enter"&&!J.shiftKey&&!J.repeat&&!J.nativeEvent.isComposing&&J.nativeEvent.keyCode!==229&&(J.preventDefault(),ir())},rows:1,placeholder:vt?"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:P,type:"file",multiple:!0,className:"hidden",onChange:Wr}),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:()=>P.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:t.jsx(Vn,{size:15})})}),t.jsxs("div",{className:"flex items-center gap-1",children:[ie&&Rt&&t.jsx(ml,{providers:Rt,currentProviderId:$t,agentType:ie.agentType,runtimeType:ie.runtimeType,onSelect:Mi}),t.jsx(Kn,{usage:Ds}),vt&&!c.trim()&&!Ot?t.jsx("button",{onClick:Pi,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(Us,{size:12})}):t.jsx("button",{onClick:ir,disabled:!c.trim()&&!Ot||rs||xs.isPending||rt.isPending||It||!!bt,className:`p-1.5 rounded-lg transition-colors ${(c.trim()||Ot)&&!rs&&!xs.isPending&&!rt.isPending&&!It&&!bt?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:t.jsx(Un,{size:15})})]})]})]}),t.jsx(ei,{open:Gt.query!==null,anchorRef:A,commands:Gt.filteredCommands,selectedIndex:Gt.selectedIndex,query:Gt.query??"",hasCatalog:Gt.allCommands.length>0,compact:!0,onSelect:Gt.applyCommand}),t.jsx(ei,{open:Qt.query!==null,anchorRef:A,commands:Qt.filteredSkills,selectedIndex:Qt.selectedIndex,query:Qt.query??"",hasCatalog:Qt.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:Qt.applySkill})]})]})),a==="team-status"&&F&&t.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:t.jsx(tc,{teamRun:F,workspaces:T,selectedWorkspaceId:le,onSelectWorkspace:k,onViewInvocationSession:Fr})}),a==="changes"&&K&&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(Fc,{workspaces:T,teamRun:F,selectedWorkspaceId:le,onSelectWorkspace:k,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),Ue&&ke&&t.jsx("div",{className:"shrink-0",children:t.jsx(Dc,{workspaceId:ke,branchName:at,targetBranch:je,commitMessage:Me,committedFileCount:Ge,onRefreshCommitMessage:X,onConflict:Se,onResolveConflicts:()=>Se()})}),t.jsx(Lx,{workingDir:We})]}),a==="history"&&t.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:t.jsx(Hx,{workingDir:We})}),a==="workspace"&&t.jsx("div",{className:"flex-1 overflow-hidden",children:t.jsx(zc,{sessionId:ae||void 0,workspaceId:le,workingDir:We,projectId:e.projectId,className:"h-full",hideChanges:!0,gitAvailable:K,readOnly:ue,repoDeleted:re,previewRequest:y,onPreviewRequestHandled:J=>{j(ge=>ge?.id===J?void 0:ge)}})}),!ue&&t.jsx(Hc,{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(io,{isOpen:w,onClose:()=>l(!1),onConfirm:()=>{r?.(e.id),l(!1)},taskId:e.id,taskTitle:e.title,workspaces:T,isLoading:p}),Qe&&Xe&&$e&&t.jsx(Vc,{open:Qe,onOpenChange:J=>{Te(J),J||et(null)},workspaceId:$e,conflictOp:Xe.conflictOp,conflictedFiles:Xe.conflictedFiles,sourceBranch:tt,targetBranch:ee,operation:Ke?.operation,worktreePath:ft,mergeAborted:Xe.mergeAborted,mergeStrategy:Xe.mergeStrategy,sourceWorkspaceId:Xe.sourceWorkspaceId,targetWorkspaceId:Xe.targetWorkspaceId,sourceWorktreePath:Xe.sourceWorktreePath,targetWorktreePath:Xe.targetWorktreePath,sessions:he,currentSessionId:F?void 0:ae,teamRunId:F?.id})]})}function un({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 Xx=Object.defineProperty,mi=Object.getOwnPropertySymbols,Jc=Object.prototype.hasOwnProperty,ed=Object.prototype.propertyIsEnumerable,Oa=(e,s,r)=>s in e?Xx(e,s,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[s]=r,Rn=(e,s)=>{for(var r in s||(s={}))Jc.call(s,r)&&Oa(e,r,s[r]);if(mi)for(var r of mi(s))ed.call(s,r)&&Oa(e,r,s[r]);return e},An=(e,s)=>{var r={};for(var o in e)Jc.call(e,o)&&s.indexOf(o)<0&&(r[o]=e[o]);if(e!=null&&mi)for(var o of mi(e))s.indexOf(o)<0&&ed.call(e,o)&&(r[o]=e[o]);return r};var js;(e=>{const s=class Ee{constructor(n,a,h,c){if(this.version=n,this.errorCorrectionLevel=a,this.modules=[],this.isFunction=[],n<Ee.MIN_VERSION||n>Ee.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 Ee.encodeSegments(h,a)}static encodeBinary(n,a){const h=e.QrSegment.makeBytes(n);return Ee.encodeSegments([h],a)}static encodeSegments(n,a,h=1,c=40,g=-1,v=!0){if(!(Ee.MIN_VERSION<=h&&h<=c&&c<=Ee.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let _,w;for(_=h;;_++){const f=Ee.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[Ee.Ecc.MEDIUM,Ee.Ecc.QUARTILE,Ee.Ecc.HIGH])v&&w<=Ee.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=Ee.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 Ee(_,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!=Ee.getNumDataCodewords(a,h))throw new RangeError("Invalid argument");const c=Ee.NUM_ERROR_CORRECTION_BLOCKS[h.ordinal][a],g=Ee.ECC_CODEWORDS_PER_BLOCK[h.ordinal][a],v=Math.floor(Ee.getNumRawDataModules(a)/8),_=c-v%c,w=Math.floor(v/c);let l=[];const u=Ee.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=Ee.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(Ee.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+=Ee.PENALTY_N1:_>5&&n++):(this.finderPenaltyAddHistory(_,w),v||(n+=this.finderPenaltyCountPatterns(w)*Ee.PENALTY_N3),v=this.modules[g][l],_=1);n+=this.finderPenaltyTerminateAndCount(v,_,w)*Ee.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+=Ee.PENALTY_N1:_>5&&n++):(this.finderPenaltyAddHistory(_,w),v||(n+=this.finderPenaltyCountPatterns(w)*Ee.PENALTY_N3),v=this.modules[l][g],_=1);n+=this.finderPenaltyTerminateAndCount(v,_,w)*Ee.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+=Ee.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*Ee.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<Ee.MIN_VERSION||n>Ee.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(Ee.getNumRawDataModules(n)/8)-Ee.ECC_CODEWORDS_PER_BLOCK[a.ordinal][n]*Ee.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]=Ee.reedSolomonMultiply(a[g],h),g+1<a.length&&(a[g]^=a[g+1]);h=Ee.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[_]^=Ee.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})(js||(js={}));(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={}))})(js||(js={}));(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={}))})(js||(js={}));var Ws=js;var Gx={L:Ws.QrCode.Ecc.LOW,M:Ws.QrCode.Ecc.MEDIUM,Q:Ws.QrCode.Ecc.QUARTILE,H:Ws.QrCode.Ecc.HIGH},td=128,sd="L",rd="#FFFFFF",id="#000000",nd=!1,od=1,Qx=4,Zx=0,Jx=.1;function ad(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 ld(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 eb(e,s,r,o){if(o==null)return null;const p=e.length+r*2,m=Math.floor(s*Jx),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 tb(e,s){return s!=null?Math.max(Math.floor(s),0):e?Qx:Zx}function cd({value:e,level:s,minVersion:r,includeMargin:o,marginSize:p,imageSettings:m,size:x,boostLevel:i}){let n=de.useMemo(()=>{const _=(Array.isArray(e)?e:[e]).reduce((w,l)=>(w.push(...Ws.QrSegment.makeSegments(l)),w),[]);return Ws.QrCode.encodeSegments(_,Gx[s],r,void 0,void 0,i)},[e,s,r,i]);const{cells:a,margin:h,numCells:c,calculatedImageSettings:g}=de.useMemo(()=>{let v=n.getModules();const _=tb(o,p),w=v.length+_*2,l=eb(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 sb=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),rb=de.forwardRef(function(s,r){const o=s,{value:p,size:m=td,level:x=sd,bgColor:i=rd,fgColor:n=id,includeMargin:a=nd,minVersion:h=od,boostLevel:c,marginSize:g,imageSettings:v}=o,w=An(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:l}=w,u=An(w,["style"]),d=v?.src,f=de.useRef(null),S=de.useRef(null),C=de.useCallback(z=>{f.current=z,typeof r=="function"?r(z):r&&(r.current=z)},[r]),[k,E]=de.useState(!1),{margin:y,cells:j,numCells:A,calculatedImageSettings:D}=cd({value:p,level:x,minVersion:h,boostLevel:c,includeMargin:a,marginSize:g,imageSettings:v,size:m});de.useEffect(()=>{if(f.current!=null){const z=f.current,L=z.getContext("2d");if(!L)return;let W=j;const $=S.current,R=D!=null&&$!==null&&$.complete&&$.naturalHeight!==0&&$.naturalWidth!==0;R&&D.excavation!=null&&(W=ld(j,D.excavation));const I=window.devicePixelRatio||1;z.height=z.width=m*I;const T=m/A*I;L.scale(T,T),L.fillStyle=i,L.fillRect(0,0,A,A),L.fillStyle=n,sb?L.fill(new Path2D(ad(W,y))):j.forEach(function(O,q){O.forEach(function(V,B){V&&L.fillRect(B+y,q+y,1,1)})}),D&&(L.globalAlpha=D.opacity),R&&L.drawImage($,D.x+y,D.y+y,D.w,D.h)}}),de.useEffect(()=>{E(!1)},[d]);const M=Rn({height:m,width:m},l);let P=null;return d!=null&&(P=de.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:S,crossOrigin:D?.crossOrigin})),de.createElement(de.Fragment,null,de.createElement("canvas",Rn({style:M,height:m,width:m,ref:C,role:"img"},u)),P)});rb.displayName="QRCodeCanvas";var dd=de.forwardRef(function(s,r){const o=s,{value:p,size:m=td,level:x=sd,bgColor:i=rd,fgColor:n=id,includeMargin:a=nd,minVersion:h=od,boostLevel:c,title:g,marginSize:v,imageSettings:_}=o,w=An(o,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:l,cells:u,numCells:d,calculatedImageSettings:f}=cd({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=ld(u,f.excavation)),C=de.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=ad(S,l);return de.createElement("svg",Rn({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},w),!!g&&de.createElement("title",null,g),de.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),de.createElement("path",{fill:n,d:k,shapeRendering:"crispEdges"}),C)});dd.displayName="QRCodeSVG";function ud(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function ib(){return Pt({queryKey:_e.tunnel.status,queryFn:()=>Ae.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function nb(){const e=Lt();return kr({mutationFn:()=>Ae.post("/tunnel/start",{port:ud()}),onSuccess:()=>{e.invalidateQueries({queryKey:_e.tunnel.status})}})}function ob(){const e=Lt();return kr({mutationFn:()=>Ae.post("/tunnel/regenerate",{port:ud()}),onSuccess:()=>{e.invalidateQueries({queryKey:_e.tunnel.status})}})}function ab(){const e=Lt();return kr({mutationFn:()=>Ae.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:_e.tunnel.status})}})}function lb(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 cb(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 db(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 Ba(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 dr(e){const s=e?.trim();return s||null}function ub(e){if(!e)return"";const s=[dr(e.lastLocalError),dr(e.lastRemoteError),dr(e.lastError)].filter(p=>p!==null),r=dr(e.lastProcessOutput),o=!!r&&(e.status==="error"||e.status==="exited"||!!dr(e.lastError));return r&&o&&s.push(r),s.join(`
82
- `)}function Fa(){const{t:e}=ce(),{data:s}=ib(),r=nb(),o=ab(),p=ob(),[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=lb(s),k=cb(s),E=ub(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]),j=b.useCallback(()=>{r.mutate(void 0,{onSuccess:()=>x(!0)})},[r]),A=b.useCallback(()=>{f&&(navigator.clipboard.writeText(f),n("url"),setTimeout(()=>n(null),2e3))},[f]),D=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]),P=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(Oe,{size:16,className:"animate-spin"}):C.icon==="warn"?t.jsx(Ns,{size:16}):t.jsx(Ao,{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&&ws.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(Ao,{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(Xt,{size:14})})]}),t.jsxs("button",{onClick:j,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(Oe,{size:13,className:"animate-spin"}),e(u?"Starting tunnel...":"Enable phone access")]})]})]}),document.body),m&&l&&ws.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(db(s))})]}),t.jsx("button",{onClick:()=>x(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:t.jsx(Xt,{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(cu,{size:12}),t.jsx("span",{children:e("Token protected")})]}),f&&t.jsx("div",{className:"flex justify-center py-3",children:t.jsx(dd,{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:A,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(No,{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:Ba(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:Ba(s?.lastHealthyAt)})]})]}),E&&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:E}),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:D,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(No,{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:P,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(Rs,{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 hn({isOpen:e,onClose:s}){const{t:r}=ce(),o=pu(),[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(j){const A=j instanceof Error?j.message:r("Failed to create project");a(A),ot.error(A)}},[o,s,d,r,_,w]),C=b.useCallback(async()=>{if(!(!_||!w||l)){a(null),c(!0);try{const y=await Ae.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]),E=b.useCallback(()=>{v(!1),S(!0)},[S]);return t.jsxs(t.Fragment,{children:[t.jsx(ps,{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(ru,{value:x,onChange:i,validationMode:"directory"})]}),n&&t.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:n})]})}),t.jsx(ps,{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:E,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 za(e){if(!e)return 0;const s=Date.parse(e);return Number.isNaN(s)?0:s}function hb(e){return e.map((s,r)=>({project:s,index:r,activityTime:za(s.lastActivityAt??s.createdAt),createdTime:za(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 Wa({projects:e,filterProjectId:s,setFilterProjectId:r,onCreateProject:o,className:p}){const{t:m}=ce(),[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(Ks,{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(Ct,{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(Ks,{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(ds,{size:13}),t.jsx("span",{children:m("Create New Project...")})]})]})]}):null]})}const fb=260,mb=600,Ha=400,pb=100,gb=1e3;function vb(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===xt.MAIN_DIRECTORY?{workspaceKind:xt.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 xb(){const{t:e,locale:s}=ce(),[r,o]=b.useState(null),[p,m]=b.useState(null),[x,i]=b.useState(Ha),[n,a]=b.useState(!1),[h,c]=b.useState("idle"),[g,v]=b.useState({}),_=b.useRef(!1),w=b.useRef(0),l=b.useRef(Ha),u=b.useRef(null),d=Lt(),{data:f,isLoading:S}=Gs(),{data:C,isLoading:k}=gu({limit:pb}),E=b.useMemo(()=>C?.data??[],[C?.data]),y=p&&E.some(ee=>ee.id===p)?p:null,{data:j,isLoading:A}=Wd({...y?{projectId:y}:{},limit:gb}),D=b.useMemo(()=>j?.data??[],[j?.data]),[M,P]=b.useState([]),z=b.useMemo(()=>{if(M.length===0)return D;const ee=new Set(D.map(he=>he.id));return[...M.filter(he=>!ee.has(he.id)),...D]},[D,M]),[L,W]=b.useState(null),$=b.useMemo(()=>r&&z.some(ee=>ee.id===r)?r:L&&r===L?L:null,[r,z,L]);b.useEffect(()=>{L&&z.some(ee=>ee.id===L)&&W(null)},[L,z]),b.useEffect(()=>{if(M.length===0)return;const ee=new Set(D.map(he=>he.id));M.some(he=>ee.has(he.id))&&P(he=>he.filter(Se=>!ee.has(Se.id)))},[D,M]);const R=b.useMemo(()=>hb(E),[E]),I=b.useMemo(()=>R.map(Nx),[R]),T=b.useMemo(()=>R.filter(ee=>!ee.archivedAt),[R]),O=b.useMemo(()=>{if(!f)return[];const ee=localStorage.getItem("providerUsageCount"),he=ee?JSON.parse(ee):{};return[...f].sort((Se,X)=>{const te=Se.availability.type!=="NOT_FOUND",ie=X.availability.type!=="NOT_FOUND";if(te!==ie)return te?-1:1;const ae=he[Se.provider.id]??0;return(he[X.provider.id]??0)-ae})},[f]),q=b.useMemo(()=>z.map(ee=>Rx(ee,E.find(he=>he.id===ee.projectId))),[E,z]),V=b.useMemo(()=>{if(!$)return null;const ee=z.find(Se=>Se.id===$);if(!ee)return null;const he=E.find(Se=>Se.id===ee.projectId);if(!he){const Se=ee.preferredWorkspace?ee.preferredWorkspace.workspaceKind===xt.MAIN_DIRECTORY?"Project directory":ee.preferredWorkspace.branchName:"—";return{id:ee.id,projectId:ee.projectId,projectName:"Unknown",projectColor:"text-muted-foreground",title:ee.title,status:po(ee.status),priority:ee.priority,branch:Se,mainBranch:"main",description:"",isGitRepo:!1,worktreeReady:!1,reason:"NO_GIT",projectArchivedAt:null,projectRepoDeletedAt:null}}return Ax(ee,he)},[$,z,E]),B=Xa(),U=Hd(),H=Ud(),N=Ga(),F=$n(),K=b.useCallback(ee=>{const he=vb(ee);P(Se=>Se.some(X=>X.id===ee.id)?Se.map(X=>X.id===ee.id?he:X):[he,...Se]),d.setQueryData(_e.tasks.detail(ee.id),ee),W(ee.id),o(ee.id)},[d]),Y=b.useCallback((ee,he,Se)=>{const X=ee.id,te=[ee.title,ee.description].filter(Boolean).join(`
83
-
84
- `),ie=Se===xt.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 Ae.post(`/tasks/${X}/workspaces`,{workspaceKind:Se});v(Ce=>({...Ce,[X]:{status:"creating-session",setupScript:ie}}));const we=await Ae.post(`/workspaces/${ae.id}/sessions`,{providerId:he,prompt:te});v(Ce=>({...Ce,[X]:{status:"starting-session",setupScript:ie}})),await F.mutateAsync(we.id),await d.invalidateQueries({queryKey:_e.workspaces.list(X)}),await d.invalidateQueries({queryKey:_e.workspaces.setupProgress(X)}),await d.invalidateQueries({queryKey:_e.tasks.all}),v(Ce=>{const{[X]:Pe,...Je}=Ce;return Je})}catch(ae){const we=ae instanceof Error?ae.message:e("启动 Agent 失败");v(Ce=>({...Ce,[X]:{status:"failed",error:we,setupScript:ie}})),ot.error(e("任务已创建,但启动 Agent 失败,可在详情中重试")),d.invalidateQueries({queryKey:_e.workspaces.list(X)}),d.invalidateQueries({queryKey:_e.tasks.all})}})()},[T,d,F,e]),se=b.useCallback(ee=>{v(he=>{const{[ee]:Se,...X}=he;return X}),d.invalidateQueries({queryKey:_e.workspaces.list(ee)}),d.invalidateQueries({queryKey:_e.tasks.all})},[d]),G=b.useCallback(ee=>{U.mutate(ee,{onSuccess:()=>{$===ee&&o(null),v(he=>{const{[ee]:Se,...X}=he;return X}),P(he=>he.filter(Se=>Se.id!==ee)),d.invalidateQueries({queryKey:_e.tasks.all})},onError:()=>{ot.error(e("删除任务失败"))}})},[U,$,d,e]),me=b.useCallback((ee,he)=>{H.mutate({id:ee,status:Ex(he)},{onError:()=>{ot.error(e("状态变更失败,该操作不被允许"))}})},[H,e]),ue=b.useCallback((ee,he)=>{N.mutate({id:ee,priority:he},{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=Se=>{if(!_.current)return;const X=Se.clientX-w.current,te=Math.max(fb,Math.min(mb,l.current+X));i(te)},he=()=>{_.current&&(_.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",ee),document.addEventListener("mouseup",he),()=>{document.removeEventListener("mousemove",ee),document.removeEventListener("mouseup",he)}},[]);const ne=b.useCallback(()=>{a(!0)},[]),le=b.useCallback(()=>{if(T.length===0){ot.error(e("没有可用项目,请先创建或恢复项目"));return}o(null)},[T,e]),ye=b.useCallback(()=>{a(!1)},[]),We=b.useCallback(async ee=>{const{title:he,description:Se,projectId:X,providerId:te,mode:ie,workspaceMode:ae,teamRunMode:we,teamTemplateId:Ce,memberPresetIds:Pe,attachmentLinks:Je,priority:be}=ee,xe=[Se,Je].filter(Boolean).join(`
85
-
86
- `);let fe=null;try{if(c("creating-task"),fe=await Ae.post(`/projects/${X}/tasks`,{title:he,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:fe.id,mode:we,...Ce?{teamTemplateId:Ce}:{},...Pe.length>0?{memberPresetIds:Pe}:{}})):te&&Y(fe,te,ae),y&&X!==y&&m(null),K(fe),c("idle"),d.invalidateQueries({queryKey:_e.tasks.all}),d.invalidateQueries({queryKey:_e.projects.all})}catch(Fe){if(c("idle"),fe&&ie==="TEAM"){try{await U.mutateAsync(fe.id)}catch{}throw ot.error(e("TeamRun 创建失败,请检查团队配置后重试")),Fe}else if(fe)y&&X!==y&&m(null),K(fe),d.invalidateQueries({queryKey:_e.tasks.all}),d.invalidateQueries({queryKey:_e.projects.all});else throw ot.error(Fe instanceof Error?Fe.message:e("Failed to create task")),Fe}},[T,B,Y,U,d,e,y,K]),ke=k||A,Ue=b.useMemo(()=>T.map(ee=>({id:ee.id,name:ee.name,color:I.find(he=>he.id===ee.id)?.color,repoPath:ee.repoPath,isGitRepo:ee.isGitRepo,worktreeReady:ee.worktreeReady,reason:ee.reason})),[T,I]),at=b.useMemo(()=>O.map(ee=>{const he=es(ee);return{id:ee.provider.id,name:ee.provider.name,agentType:ee.provider.agentType,available:!he,permissionMode:ee.provider.executionPermission,reason:he}}),[O]),Me=b.useMemo(()=>{if(y&&T.find(he=>he.id===y))return y;const ee=localStorage.getItem("lastSelectedProjectId");return ee&&T.find(he=>he.id===ee)?ee:T[0]?.id??""},[T,y]),[je,Be]=b.useState(Me);b.useEffect(()=>{Be(Me)},[Me]);const Ke=b.useMemo(()=>T.find(ee=>ee.id===je)?.name??T.find(ee=>ee.id===Me)?.name??e("Project"),[T,je,Me,e]),qe=s==="zh-CN"?`你需要在 ${Ke} 中做点什么?`:`What do you need to do in ${Ke}?`,De=b.useMemo(()=>{const ee=localStorage.getItem("lastSelectedProviderId");return ee&&O.find(Se=>Se.provider.id===ee&&!es(Se))?ee:O.find(Se=>!es(Se))?.provider.id??""},[O]),Ge=$l(),[Qe,Te]=b.useState(!1),{usesIntegratedTitlebar:pe,desktopPlatform:et,hasMacTrafficLights:Xe}=$a(),$e=pe&&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:Ue,providers:at,isProvidersLoading:S,onSubmit:tt,defaultProjectId:Me,defaultProviderId:De,onProjectChange:Be,createStep:h})]})]}):$&&V?t.jsxs(t.Fragment,{children:[t.jsx(Yx,{task:V,onBack:()=>o(null),onDeleteTask:V.projectArchivedAt?void 0:G,onTaskPriorityChange:V.projectArchivedAt?void 0:ue,isDeleting:U.isPending,autoStartState:g[V.id]??null,onAutoStartRecovered:se}),t.jsx(hn,{isOpen:n,onClose:ye})]}):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(Wa,{projects:I,filterProjectId:y,setFilterProjectId:m,onCreateProject:ne})]}),t.jsxs("div",{className:"flex items-center gap-1",children:[t.jsx(Fa,{}),t.jsx("button",{onClick:()=>So.getState().openSettings(),className:"p-1.5 text-muted-foreground/70 active:text-foreground rounded-md",children:t.jsx(yo,{size:16})})]})]}),t.jsx(Ko,{tasks:q,projects:I,selectedTaskId:null,onSelectTask:o,filterProjectId:y,setFilterProjectId:m,width:"100%",onCreateTask:ft,onCreateProject:ne,onTaskStatusChange:me,onTaskPriorityChange:ue,isLoading:ke&&q.length===0})]}),t.jsx(hn,{isOpen:n,onClose:ye})]}):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",pe&&"app-region-drag",$e&&"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(Wa,{projects:I,filterProjectId:y,setFilterProjectId:m,onCreateProject:ne,className:pe?"app-region-no-drag":void 0})]}),t.jsxs("div",{className:Z("flex items-center gap-1",pe&&"app-region-no-drag"),children:[t.jsx("div",{className:pe?"app-region-no-drag":void 0,children:t.jsx(Fa,{})}),t.jsx("button",{onClick:()=>So.getState().openSettings(),className:Z("p-1.5 text-muted-foreground/70 hover:text-foreground hover:bg-accent rounded-md transition-colors",pe&&"app-region-no-drag"),children:t.jsx(yo,{size:16})})]})]}),t.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[t.jsx(Ko,{tasks:q,projects:I,selectedTaskId:$,onSelectTask:o,filterProjectId:y,setFilterProjectId:m,width:x,onCreateTask:le,onCreateProject:ne,isCreateActive:!$,onTaskStatusChange:me,onDeleteTask:G,onTaskPriorityChange:ue,isLoading:ke&&q.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(kx,{task:V,onDeleteTask:V.projectArchivedAt?void 0:G,isDeleting:U.isPending,onTaskStatusChange:V.projectArchivedAt?void 0:me,onTaskPriorityChange:V.projectArchivedAt?void 0:ue,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:Ue,providers:at,isProvidersLoading:S,onSubmit:We,defaultProjectId:Me,defaultProviderId:De,onProjectChange:Be,createStep:h})]})})})]}),t.jsx(hn,{isOpen:n,onClose:ye})]})}const qb=Object.freeze(Object.defineProperty({__proto__:null,ProjectKanbanPage:xb},Symbol.toStringTag,{value:"Module"}));export{qb as P,lc as l};