agent-tower 0.4.15 → 0.4.16-beta.3

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 (279) hide show
  1. package/dist/app.test.js +2 -0
  2. package/dist/app.test.js.map +1 -1
  3. package/dist/core/event-bus.d.ts +2 -0
  4. package/dist/core/event-bus.d.ts.map +1 -1
  5. package/dist/core/event-bus.js.map +1 -1
  6. package/dist/executors/__tests__/codex.executor.test.d.ts +2 -0
  7. package/dist/executors/__tests__/codex.executor.test.d.ts.map +1 -0
  8. package/dist/executors/__tests__/codex.executor.test.js +28 -0
  9. package/dist/executors/__tests__/codex.executor.test.js.map +1 -0
  10. package/dist/executors/codex.executor.d.ts +1 -0
  11. package/dist/executors/codex.executor.d.ts.map +1 -1
  12. package/dist/executors/codex.executor.js +19 -1
  13. package/dist/executors/codex.executor.js.map +1 -1
  14. package/dist/git/git-cli.d.ts +18 -1
  15. package/dist/git/git-cli.d.ts.map +1 -1
  16. package/dist/git/git-cli.js +17 -1
  17. package/dist/git/git-cli.js.map +1 -1
  18. package/dist/git/worktree.manager.d.ts +29 -2
  19. package/dist/git/worktree.manager.d.ts.map +1 -1
  20. package/dist/git/worktree.manager.js +137 -16
  21. package/dist/git/worktree.manager.js.map +1 -1
  22. package/dist/git/worktree.manager.test.d.ts +2 -0
  23. package/dist/git/worktree.manager.test.d.ts.map +1 -0
  24. package/dist/git/worktree.manager.test.js +104 -0
  25. package/dist/git/worktree.manager.test.js.map +1 -0
  26. package/dist/mcp/context.d.ts +3 -0
  27. package/dist/mcp/context.d.ts.map +1 -1
  28. package/dist/mcp/context.js +10 -1
  29. package/dist/mcp/context.js.map +1 -1
  30. package/dist/mcp/http-client.d.ts +24 -1
  31. package/dist/mcp/http-client.d.ts.map +1 -1
  32. package/dist/mcp/http-client.js +37 -3
  33. package/dist/mcp/http-client.js.map +1 -1
  34. package/dist/mcp/server.d.ts.map +1 -1
  35. package/dist/mcp/server.js +190 -0
  36. package/dist/mcp/server.js.map +1 -1
  37. package/dist/middleware/tunnel-auth.d.ts.map +1 -1
  38. package/dist/middleware/tunnel-auth.js +2 -0
  39. package/dist/middleware/tunnel-auth.js.map +1 -1
  40. package/dist/output/__tests__/codex-parser.test.d.ts +2 -0
  41. package/dist/output/__tests__/codex-parser.test.d.ts.map +1 -0
  42. package/dist/output/__tests__/codex-parser.test.js +148 -0
  43. package/dist/output/__tests__/codex-parser.test.js.map +1 -0
  44. package/dist/output/codex-parser.d.ts +12 -0
  45. package/dist/output/codex-parser.d.ts.map +1 -1
  46. package/dist/output/codex-parser.js +129 -12
  47. package/dist/output/codex-parser.js.map +1 -1
  48. package/dist/routes/__tests__/attachments.test.d.ts +2 -0
  49. package/dist/routes/__tests__/attachments.test.d.ts.map +1 -0
  50. package/dist/routes/__tests__/attachments.test.js +86 -0
  51. package/dist/routes/__tests__/attachments.test.js.map +1 -0
  52. package/dist/routes/__tests__/filesystem.test.d.ts +2 -0
  53. package/dist/routes/__tests__/filesystem.test.d.ts.map +1 -0
  54. package/dist/routes/__tests__/filesystem.test.js +80 -0
  55. package/dist/routes/__tests__/filesystem.test.js.map +1 -0
  56. package/dist/routes/__tests__/previews.test.d.ts +2 -0
  57. package/dist/routes/__tests__/previews.test.d.ts.map +1 -0
  58. package/dist/routes/__tests__/previews.test.js +89 -0
  59. package/dist/routes/__tests__/previews.test.js.map +1 -0
  60. package/dist/routes/__tests__/tasks.test.d.ts +2 -0
  61. package/dist/routes/__tests__/tasks.test.d.ts.map +1 -0
  62. package/dist/routes/__tests__/tasks.test.js +72 -0
  63. package/dist/routes/__tests__/tasks.test.js.map +1 -0
  64. package/dist/routes/attachments.d.ts.map +1 -1
  65. package/dist/routes/attachments.js +36 -16
  66. package/dist/routes/attachments.js.map +1 -1
  67. package/dist/routes/filesystem.d.ts.map +1 -1
  68. package/dist/routes/filesystem.js +24 -3
  69. package/dist/routes/filesystem.js.map +1 -1
  70. package/dist/routes/index.d.ts.map +1 -1
  71. package/dist/routes/index.js +6 -0
  72. package/dist/routes/index.js.map +1 -1
  73. package/dist/routes/previews.d.ts +6 -0
  74. package/dist/routes/previews.d.ts.map +1 -0
  75. package/dist/routes/previews.js +413 -0
  76. package/dist/routes/previews.js.map +1 -0
  77. package/dist/routes/projects.d.ts.map +1 -1
  78. package/dist/routes/projects.js +1 -0
  79. package/dist/routes/projects.js.map +1 -1
  80. package/dist/routes/system.d.ts.map +1 -1
  81. package/dist/routes/system.js +35 -1
  82. package/dist/routes/system.js.map +1 -1
  83. package/dist/routes/tasks.js +2 -2
  84. package/dist/routes/tasks.js.map +1 -1
  85. package/dist/routes/team-runs.d.ts +11 -0
  86. package/dist/routes/team-runs.d.ts.map +1 -0
  87. package/dist/routes/team-runs.js +309 -0
  88. package/dist/routes/team-runs.js.map +1 -0
  89. package/dist/routes/tunnel.d.ts.map +1 -1
  90. package/dist/routes/tunnel.js +20 -0
  91. package/dist/routes/tunnel.js.map +1 -1
  92. package/dist/routes/workspaces.d.ts.map +1 -1
  93. package/dist/routes/workspaces.js +15 -1
  94. package/dist/routes/workspaces.js.map +1 -1
  95. package/dist/services/__tests__/preview.service.test.d.ts +2 -0
  96. package/dist/services/__tests__/preview.service.test.d.ts.map +1 -0
  97. package/dist/services/__tests__/preview.service.test.js +29 -0
  98. package/dist/services/__tests__/preview.service.test.js.map +1 -0
  99. package/dist/services/__tests__/session-manager.team-run.test.d.ts +2 -0
  100. package/dist/services/__tests__/session-manager.team-run.test.d.ts.map +1 -0
  101. package/dist/services/__tests__/session-manager.team-run.test.js +286 -0
  102. package/dist/services/__tests__/session-manager.team-run.test.js.map +1 -0
  103. package/dist/services/__tests__/task.service.test.d.ts +2 -0
  104. package/dist/services/__tests__/task.service.test.d.ts.map +1 -0
  105. package/dist/services/__tests__/task.service.test.js +65 -0
  106. package/dist/services/__tests__/task.service.test.js.map +1 -0
  107. package/dist/services/__tests__/team-lock.service.test.d.ts +2 -0
  108. package/dist/services/__tests__/team-lock.service.test.d.ts.map +1 -0
  109. package/dist/services/__tests__/team-lock.service.test.js +81 -0
  110. package/dist/services/__tests__/team-lock.service.test.js.map +1 -0
  111. package/dist/services/__tests__/team-reconciler.service.test.d.ts +2 -0
  112. package/dist/services/__tests__/team-reconciler.service.test.d.ts.map +1 -0
  113. package/dist/services/__tests__/team-reconciler.service.test.js +1536 -0
  114. package/dist/services/__tests__/team-reconciler.service.test.js.map +1 -0
  115. package/dist/services/__tests__/team-run.service.test.d.ts +2 -0
  116. package/dist/services/__tests__/team-run.service.test.d.ts.map +1 -0
  117. package/dist/services/__tests__/team-run.service.test.js +699 -0
  118. package/dist/services/__tests__/team-run.service.test.js.map +1 -0
  119. package/dist/services/__tests__/team-scheduler.service.test.d.ts +2 -0
  120. package/dist/services/__tests__/team-scheduler.service.test.d.ts.map +1 -0
  121. package/dist/services/__tests__/team-scheduler.service.test.js +1688 -0
  122. package/dist/services/__tests__/team-scheduler.service.test.js.map +1 -0
  123. package/dist/services/__tests__/tunnel.service.test.d.ts +2 -0
  124. package/dist/services/__tests__/tunnel.service.test.d.ts.map +1 -0
  125. package/dist/services/__tests__/tunnel.service.test.js +138 -0
  126. package/dist/services/__tests__/tunnel.service.test.js.map +1 -0
  127. package/dist/services/__tests__/workspace.service.test.d.ts +2 -0
  128. package/dist/services/__tests__/workspace.service.test.d.ts.map +1 -0
  129. package/dist/services/__tests__/workspace.service.test.js +695 -0
  130. package/dist/services/__tests__/workspace.service.test.js.map +1 -0
  131. package/dist/services/attachment-context.d.ts +3 -0
  132. package/dist/services/attachment-context.d.ts.map +1 -0
  133. package/dist/services/attachment-context.js +34 -0
  134. package/dist/services/attachment-context.js.map +1 -0
  135. package/dist/services/preview.service.d.ts +19 -0
  136. package/dist/services/preview.service.d.ts.map +1 -0
  137. package/dist/services/preview.service.js +147 -0
  138. package/dist/services/preview.service.js.map +1 -0
  139. package/dist/services/project.service.d.ts +2 -0
  140. package/dist/services/project.service.d.ts.map +1 -1
  141. package/dist/services/project.service.js +87 -18
  142. package/dist/services/project.service.js.map +1 -1
  143. package/dist/services/session-manager.d.ts +43 -1
  144. package/dist/services/session-manager.d.ts.map +1 -1
  145. package/dist/services/session-manager.js +110 -2
  146. package/dist/services/session-manager.js.map +1 -1
  147. package/dist/services/task.service.d.ts +6 -0
  148. package/dist/services/task.service.d.ts.map +1 -1
  149. package/dist/services/task.service.js +15 -3
  150. package/dist/services/task.service.js.map +1 -1
  151. package/dist/services/team-lock.service.d.ts +25 -0
  152. package/dist/services/team-lock.service.d.ts.map +1 -0
  153. package/dist/services/team-lock.service.js +56 -0
  154. package/dist/services/team-lock.service.js.map +1 -0
  155. package/dist/services/team-reconciler.service.d.ts +44 -0
  156. package/dist/services/team-reconciler.service.d.ts.map +1 -0
  157. package/dist/services/team-reconciler.service.js +286 -0
  158. package/dist/services/team-reconciler.service.js.map +1 -0
  159. package/dist/services/team-run-events.d.ts +13 -0
  160. package/dist/services/team-run-events.d.ts.map +1 -0
  161. package/dist/services/team-run-events.js +27 -0
  162. package/dist/services/team-run-events.js.map +1 -0
  163. package/dist/services/team-run.service.d.ts +92 -0
  164. package/dist/services/team-run.service.d.ts.map +1 -0
  165. package/dist/services/team-run.service.js +835 -0
  166. package/dist/services/team-run.service.js.map +1 -0
  167. package/dist/services/team-scheduler.service.d.ts +104 -0
  168. package/dist/services/team-scheduler.service.d.ts.map +1 -0
  169. package/dist/services/team-scheduler.service.js +843 -0
  170. package/dist/services/team-scheduler.service.js.map +1 -0
  171. package/dist/services/tunnel.service.d.ts +31 -5
  172. package/dist/services/tunnel.service.d.ts.map +1 -1
  173. package/dist/services/tunnel.service.js +293 -32
  174. package/dist/services/tunnel.service.js.map +1 -1
  175. package/dist/services/workspace.service.d.ts +161 -7
  176. package/dist/services/workspace.service.d.ts.map +1 -1
  177. package/dist/services/workspace.service.js +396 -51
  178. package/dist/services/workspace.service.js.map +1 -1
  179. package/dist/socket/events.d.ts +1 -1
  180. package/dist/socket/events.d.ts.map +1 -1
  181. package/dist/socket/events.js.map +1 -1
  182. package/dist/socket/socket-gateway.d.ts.map +1 -1
  183. package/dist/socket/socket-gateway.js +5 -1
  184. package/dist/socket/socket-gateway.js.map +1 -1
  185. package/dist/web/assets/AgentDemoPage-Bf6labVB.js +1 -0
  186. package/dist/web/assets/{DemoPage-XwuS8vNB.js → DemoPage-DlfG47rV.js} +3 -3
  187. package/dist/web/assets/{GeneralSettingsPage-CliIgpwf.js → GeneralSettingsPage-DefqwzVn.js} +1 -1
  188. package/dist/web/assets/MemberAvatar-DVw_TedB.js +1 -0
  189. package/dist/web/assets/NotificationSettingsPage-C9h1U1Za.js +1 -0
  190. package/dist/web/assets/{ProfileSettingsPage-CkU_kZKG.js → ProfileSettingsPage-BkZE2yVP.js} +1 -1
  191. package/dist/web/assets/ProjectKanbanPage-B1Ckl1uY.js +89 -0
  192. package/dist/web/assets/ProjectSettingsPage-ByZ13awb.js +2 -0
  193. package/dist/web/assets/{ProviderSettingsPage-CfvdeoEU.js → ProviderSettingsPage-DSQYe8B6.js} +12 -12
  194. package/dist/web/assets/TeamSettingsPage-DUukJ_Ih.js +1 -0
  195. package/dist/web/assets/agent-tower-logo-COx9gy77.png +0 -0
  196. package/dist/web/assets/{button-BWFTEdOr.js → button-Bpm98eOV.js} +1 -1
  197. package/dist/web/assets/{chevron-down-CuPdBAx-.js → chevron-down-DSKKXCi8.js} +1 -1
  198. package/dist/web/assets/{chevron-right-Cs8vYTMn.js → chevron-right-CZdDV9GU.js} +1 -1
  199. package/dist/web/assets/chevron-up-gnnlwvYe.js +1 -0
  200. package/dist/web/assets/{circle-check-BXZTzqw0.js → circle-check-DeD_VuLK.js} +1 -1
  201. package/dist/web/assets/{code-block-OCS4YCEC-BxUpvXK_.js → code-block-OCS4YCEC-BrGjkdjS.js} +1 -1
  202. package/dist/web/assets/{confirm-dialog-CDLHRthd.js → confirm-dialog-CEVVvAcE.js} +1 -1
  203. package/dist/web/assets/folder-picker-ZBQlFEWL.js +1 -0
  204. package/dist/web/assets/index-B5g4V0NU.js +13 -0
  205. package/dist/web/assets/index-ltjI8o6A.css +1 -0
  206. package/dist/web/assets/loader-circle-GMfBClX0.js +1 -0
  207. package/dist/web/assets/{log-adapter-CeKrvZcz.js → log-adapter-DKKM3sxS.js} +1 -1
  208. package/dist/web/assets/{mermaid-NOHMQCX5-BOSwJqP0.js → mermaid-NOHMQCX5-D5USvUiZ.js} +44 -44
  209. package/dist/web/assets/modal-JMpuh-LG.js +1 -0
  210. package/dist/web/assets/{pencil-BMxBxIhw.js → pencil-QrCW47nn.js} +1 -1
  211. package/dist/web/assets/{select-BUmRG0LY.js → select-CINRzLiE.js} +1 -1
  212. package/dist/web/assets/upload-vFxZxKHo.js +1 -0
  213. package/dist/web/assets/{use-profiles-C1vlPE-2.js → use-profiles-SrVWPYv0.js} +1 -1
  214. package/dist/web/assets/{use-providers-Cdxr4Jbz.js → use-providers-BihMydl0.js} +1 -1
  215. package/dist/web/avatars/presets/avatar-preset-01-developer.png +0 -0
  216. package/dist/web/avatars/presets/avatar-preset-02-architect.png +0 -0
  217. package/dist/web/avatars/presets/avatar-preset-03-tester.png +0 -0
  218. package/dist/web/avatars/presets/avatar-preset-04-devops.png +0 -0
  219. package/dist/web/avatars/presets/avatar-preset-05-data-scientist.png +0 -0
  220. package/dist/web/avatars/presets/avatar-preset-06-frontend.png +0 -0
  221. package/dist/web/avatars/presets/avatar-preset-07-backend.png +0 -0
  222. package/dist/web/avatars/presets/avatar-preset-08-security.png +0 -0
  223. package/dist/web/avatars/presets/avatar-preset-09-project-manager.png +0 -0
  224. package/dist/web/avatars/presets/avatar-preset-10-product-manager.png +0 -0
  225. package/dist/web/avatars/presets/avatar-preset-11-scrum-master.png +0 -0
  226. package/dist/web/avatars/presets/avatar-preset-12-tech-lead.png +0 -0
  227. package/dist/web/avatars/presets/avatar-preset-13-coordinator.png +0 -0
  228. package/dist/web/avatars/presets/avatar-preset-14-mentor.png +0 -0
  229. package/dist/web/avatars/presets/avatar-preset-15-reviewer.png +0 -0
  230. package/dist/web/avatars/presets/avatar-preset-16-ui-designer.png +0 -0
  231. package/dist/web/avatars/presets/avatar-preset-17-ux-researcher.png +0 -0
  232. package/dist/web/avatars/presets/avatar-preset-18-documenter.png +0 -0
  233. package/dist/web/avatars/presets/avatar-preset-19-translator.png +0 -0
  234. package/dist/web/avatars/presets/avatar-preset-20-analyst.png +0 -0
  235. package/dist/web/avatars/presets/avatar-preset-21-consultant.png +0 -0
  236. package/dist/web/avatars/presets/avatar-preset-22-creative-director.png +0 -0
  237. package/dist/web/avatars/presets/avatar-preset-23-support.png +0 -0
  238. package/dist/web/avatars/presets/avatar-preset-24-assistant.png +0 -0
  239. package/dist/web/avatars/presets/avatar-preset-25-robot.png +0 -0
  240. package/dist/web/avatars/presets/avatar-preset-grid.png +0 -0
  241. package/dist/web/index.html +2 -2
  242. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts +10 -0
  243. package/node_modules/@agent-tower/shared/dist/socket/events.d.ts.map +1 -1
  244. package/node_modules/@agent-tower/shared/dist/socket/events.js +1 -0
  245. package/node_modules/@agent-tower/shared/dist/socket/events.js.map +1 -1
  246. package/node_modules/@agent-tower/shared/dist/types.d.ts +161 -0
  247. package/node_modules/@agent-tower/shared/dist/types.d.ts.map +1 -1
  248. package/node_modules/@agent-tower/shared/dist/types.js.map +1 -1
  249. package/node_modules/@prisma/client/.prisma/client/default.d.ts +1 -0
  250. package/node_modules/@prisma/client/.prisma/client/default.js +1 -0
  251. package/node_modules/@prisma/client/.prisma/client/edge.d.ts +1 -0
  252. package/node_modules/@prisma/client/.prisma/client/edge.js +396 -0
  253. package/node_modules/@prisma/client/.prisma/client/index-browser.js +385 -0
  254. package/node_modules/@prisma/client/.prisma/client/index.d.ts +26996 -0
  255. package/node_modules/@prisma/client/.prisma/client/index.js +421 -0
  256. package/node_modules/@prisma/client/.prisma/client/libquery_engine-darwin-arm64.dylib.node +0 -0
  257. package/node_modules/@prisma/client/.prisma/client/package.json +97 -0
  258. package/node_modules/@prisma/client/.prisma/client/query_engine-windows.dll.node +0 -0
  259. package/node_modules/@prisma/client/.prisma/client/schema.prisma +296 -0
  260. package/node_modules/@prisma/client/.prisma/client/wasm.d.ts +1 -0
  261. package/node_modules/@prisma/client/.prisma/client/wasm.js +385 -0
  262. package/node_modules/@prisma/client/package.json +3 -2
  263. package/package.json +2 -1
  264. package/prisma/migrations/20260515000000_add_workspace_preview_target/migration.sql +2 -0
  265. package/prisma/migrations/20260518000000_add_team_run_collaboration/migration.sql +150 -0
  266. package/prisma/migrations/20260522000000_add_team_member_session_policy/migration.sql +2 -0
  267. package/prisma/migrations/20260526000000_add_team_run_main_and_dedicated_workspaces/migration.sql +21 -0
  268. package/prisma/schema.prisma +147 -1
  269. package/dist/web/assets/AgentDemoPage-ClnGPAV9.js +0 -1
  270. package/dist/web/assets/NotificationSettingsPage-y3vhVgPv.js +0 -1
  271. package/dist/web/assets/ProjectKanbanPage-BddzfZRV.js +0 -87
  272. package/dist/web/assets/ProjectSettingsPage-B6xhbziO.js +0 -2
  273. package/dist/web/assets/circle-alert-EUyZcWhp.js +0 -1
  274. package/dist/web/assets/folder-picker-CUbhsnhi.js +0 -1
  275. package/dist/web/assets/index-BGvfX18x.css +0 -1
  276. package/dist/web/assets/index-CHN8jahE.js +0 -13
  277. package/dist/web/assets/loader-circle-BHzDVpxt.js +0 -1
  278. package/dist/web/assets/modal-D_AU4URz.js +0 -1
  279. package/dist/web/assets/use-projects-Bcd5hIOY.js +0 -1
@@ -0,0 +1,89 @@
1
+ const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["assets/modal-JMpuh-LG.js","assets/index-B5g4V0NU.js","assets/index-ltjI8o6A.css","assets/utils-CkSf8FUe.js"])))=>i.map(i=>d[i]);
2
+ import{Q as ui,x as rn,y as Tl,z as Ml,A as Dl,B as ei,D as Ll,E as Pl,e as Qe,G as Ol,H as Il,r as C,I as Bl,J as Fl,K as zl,M as Hl,N as nn,O as on,P as Wl,R as $l,T as Ul,h as xe,U as ie,V as Ut,u as ne,j as s,d as vt,g as me,W as bo,X as yo,Y as ti,Z as So,_ as fr,v as Ot,S as ct,C as es,f as ut,q as le,w as It,t as ns,i as ql,k as Kl,L as Gs,$ as wo,a0 as Co,a1 as an,a2 as hi,a3 as ko,a4 as Eo,a5 as Xl,a6 as Vl,a7 as ln,a8 as Yl}from"./index-B5g4V0NU.js";import{h as fi,b as mi,d as pi,c as gi,i as vi,f as os,A as cn,P as mr,Q as _i,G as xi,u as jo,a as No,e as Qs,T as Ao,S as dn}from"./mermaid-NOHMQCX5-D5USvUiZ.js";import{C as _t,a as At}from"./chevron-down-DSKKXCi8.js";import{C as Tt}from"./chevron-right-CZdDV9GU.js";import{P as as,X as Ht,M as Ms,T as bi}from"./modal-JMpuh-LG.js";import{W as kt,C as ws,A as Nt,S as Ge,T as jt}from"./log-adapter-DKKM3sxS.js";import{B as De}from"./button-Bpm98eOV.js";import{L as Ke}from"./loader-circle-GMfBClX0.js";import{M as Xt}from"./MemberAvatar-DVw_TedB.js";import{c as se,t as un}from"./utils-CkSf8FUe.js";import{C as yi}from"./chevron-up-gnnlwvYe.js";import{a as Gl,F as Ql,f as Zl,R as Jl,g as ec,e as tc,u as sc}from"./folder-picker-ZBQlFEWL.js";import{u as Ds}from"./use-providers-BihMydl0.js";import{T as Si,C as Zs}from"./confirm-dialog-CEVVvAcE.js";import{S as hn}from"./select-CINRzLiE.js";var rc=class extends ui{constructor(e,t){super(e,t)}bindMethods(){super.bindMethods(),this.fetchNextPage=this.fetchNextPage.bind(this),this.fetchPreviousPage=this.fetchPreviousPage.bind(this)}setOptions(e){super.setOptions({...e,behavior:rn()})}getOptimisticResult(e){return e.behavior=rn(),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,t){const{state:r}=e,a=super.createResult(e,t),{isFetching:p,isRefetching:m,isError:v,isRefetchError:i}=a,n=r.fetchMeta?.fetchMore?.direction,c=v&&n==="forward",f=p&&n==="forward",l=v&&n==="backward",g=p&&n==="backward";return{...a,fetchNextPage:this.fetchNextPage,fetchPreviousPage:this.fetchPreviousPage,hasNextPage:Ml(t,r.data),hasPreviousPage:Tl(t,r.data),isFetchNextPageError:c,isFetchingNextPage:f,isFetchPreviousPageError:l,isFetchingPreviousPage:g,isRefetchError:i&&!c&&!l,isRefetching:m&&!f&&!g}}};function fn(e,t){const r=new Set(t);return e.filter(a=>!r.has(a))}function ic(e,t,r){const a=e.slice(0);return a[t]=r,a}var nc=class extends Dl{#r;#e;#i;#n;#t;#s;#o;#a;#l;#c=[];constructor(e,t,r){super(),this.#r=e,this.#n=r,this.#i=[],this.#t=[],this.#e=[],this.setQueries(t)}onSubscribe(){this.listeners.size===1&&this.#t.forEach(e=>{e.subscribe(t=>{this.#f(e,t)})})}onUnsubscribe(){this.listeners.size||this.destroy()}destroy(){this.listeners=new Set,this.#t.forEach(e=>{e.destroy()})}setQueries(e,t){this.#i=e,this.#n=t,ei.batch(()=>{const r=this.#t,a=this.#h(this.#i);a.forEach(f=>f.observer.setOptions(f.defaultedQueryOptions));const p=a.map(f=>f.observer),m=p.map(f=>f.getCurrentResult()),v=r.length!==p.length,i=p.some((f,l)=>f!==r[l]),n=v||i,c=n?!0:m.some((f,l)=>{const g=this.#e[l];return!g||!Ll(f,g)});!n&&!c||(n&&(this.#c=a,this.#t=p),this.#e=m,this.hasListeners()&&(n&&(fn(r,p).forEach(f=>{f.destroy()}),fn(p,r).forEach(f=>{f.subscribe(l=>{this.#f(f,l)})})),this.#m()))})}getCurrentResult(){return this.#e}getQueries(){return this.#t.map(e=>e.getCurrentQuery())}getObservers(){return this.#t}getOptimisticResult(e,t){const r=this.#h(e),a=r.map(m=>m.observer.getOptimisticResult(m.defaultedQueryOptions)),p=r.map(m=>m.defaultedQueryOptions.queryHash);return[a,m=>this.#u(m??a,t,p),()=>this.#d(a,r)]}#d(e,t){return t.map((r,a)=>{const p=e[a];return r.defaultedQueryOptions.notifyOnChangeProps?p:r.observer.trackResult(p,m=>{t.forEach(v=>{v.observer.trackProp(m)})})})}#u(e,t,r){if(t){const a=this.#l,p=r!==void 0&&a!==void 0&&(a.length!==r.length||r.some((m,v)=>m!==a[v]));return(!this.#s||this.#e!==this.#a||p||t!==this.#o)&&(this.#o=t,this.#a=this.#e,r!==void 0&&(this.#l=r),this.#s=Pl(this.#s,t(e))),this.#s}return e}#h(e){const t=new Map;this.#t.forEach(a=>{const p=a.options.queryHash;if(!p)return;const m=t.get(p);m?m.push(a):t.set(p,[a])});const r=[];return e.forEach(a=>{const p=this.#r.defaultQueryOptions(a),v=t.get(p.queryHash)?.shift()??new ui(this.#r,p);r.push({defaultedQueryOptions:p,observer:v})}),r}#f(e,t){const r=this.#t.indexOf(e);r!==-1&&(this.#e=ic(this.#e,r,t),this.#m())}#m(){if(this.hasListeners()){const e=this.#s,t=this.#d(this.#e,this.#c),r=this.#u(t,this.#n?.combine);e!==r&&ei.batch(()=>{this.listeners.forEach(a=>{a(this.#e)})})}}};function oc({queries:e,...t},r){const a=Qe(),p=Ol(),m=Il(),v=C.useMemo(()=>e.map(_=>{const o=a.defaultQueryOptions(_);return o._optimisticResults=p?"isRestoring":"optimistic",o}),[e,a,p]);v.forEach(_=>{Bl(_);const o=a.getQueryCache().get(_.queryHash);Fl(_,m,o)}),zl(m);const[i]=C.useState(()=>new nc(a,v,t)),[n,c,f]=i.getOptimisticResult(v,t.combine),l=!p&&t.subscribed!==!1;C.useSyncExternalStore(C.useCallback(_=>l?i.subscribe(ei.batchCalls(_)):Hl,[i,l]),()=>i.getCurrentResult(),()=>i.getCurrentResult()),C.useEffect(()=>{i.setQueries(v,t)},[v,t,i]);const b=n.some((_,o)=>nn(v[o],_))?n.flatMap((_,o)=>{const h=v[o];if(h){const d=new ui(a,h);if(nn(h,_))return on(h,d,m);Wl(_,p)&&on(h,d,m)}return[]}):[];if(b.length>0)throw Promise.all(b);const y=n.find((_,o)=>{const h=v[o];return h&&$l({result:_,errorResetBoundary:m,throwOnError:h.throwOnError,query:a.getQueryCache().get(h.queryHash),suspense:h.suspense})});if(y?.error)throw y.error;return c(f())}function Ro(e,t){return Ul(e,rc)}const ac=[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]],Cs=xe("arrow-down",ac);const lc=[["path",{d:"M5 12h14",key:"1ays0h"}],["path",{d:"m12 5 7 7-7 7",key:"xquz4c"}]],To=xe("arrow-right",lc);const cc=[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]],wi=xe("arrow-up",cc);const dc=[["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],_s=xe("ban",dc);const uc=[["path",{d:"M12 8V4H8",key:"hb8ula"}],["rect",{width:"16",height:"12",x:"4",y:"8",rx:"2",key:"enze0r"}],["path",{d:"M2 14h2",key:"vft8re"}],["path",{d:"M20 14h2",key:"4cs60a"}],["path",{d:"M15 13v2",key:"1xurst"}],["path",{d:"M9 13v2",key:"rq6x2g"}]],hc=xe("bot",uc);const fc=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],mc=xe("chevron-left",fc);const pc=[["path",{d:"M21.801 10A10 10 0 1 1 17 3.335",key:"yps3ct"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]],mn=xe("circle-check-big",pc);const gc=[["path",{d:"M12 6v6h4",key:"135r8i"}],["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}]],ts=xe("clock-3",gc);const vc=[["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"}]],pr=xe("code-xml",vc);const _c=[["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"}]],pn=xe("copy",_c);const xc=[["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"}]],Mo=xe("ellipsis-vertical",xc);const bc=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],Ci=xe("external-link",bc);const yc=[["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"}]],Sc=xe("file-braces-corner",yc);const wc=[["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"}]],ks=xe("file-code-corner",wc);const Cc=[["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"}]],kc=xe("file-exclamation-point",Cc);const Ec=[["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:"M14 2v5a1 1 0 0 0 1 1h5",key:"wfsgrz"}],["path",{d:"M10 9H8",key:"b1mrlr"}],["path",{d:"M16 13H8",key:"t4e002"}],["path",{d:"M16 17H8",key:"z1uh3a"}]],ki=xe("file-text",Ec);const jc=[["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"}]],Ei=xe("folder-open",jc);const Nc=[["path",{d:"m12 14 4-4",key:"9kzdfg"}],["path",{d:"M3.34 19a10 10 0 1 1 17.32 0",key:"19p75a"}]],Ac=xe("gauge",Nc);const Rc=[["line",{x1:"6",x2:"6",y1:"3",y2:"15",key:"17qcm7"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}],["path",{d:"M18 9a9 9 0 0 1-9 9",key:"n2h4wq"}]],ji=xe("git-branch",Rc);const Tc=[["circle",{cx:"12",cy:"18",r:"3",key:"1mpf1b"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["path",{d:"M18 9v2c0 .6-.4 1-1 1H7c-.6 0-1-.4-1-1V9",key:"1uq4wg"}],["path",{d:"M12 12v3",key:"158kv8"}]],Mc=xe("git-fork",Tc);const Dc=[["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"}]],ls=xe("git-graph",Dc);const Lc=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M6 21V9a9 9 0 0 0 9 9",key:"7kw0sc"}]],Do=xe("git-merge",Lc);const Pc=[["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"}]],cs=xe("history",Pc);const Oc=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",ry:"2",key:"1m3agn"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}]],Ni=xe("image",Oc);const Ic=[["path",{d:"M12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83z",key:"zw3jo"}],["path",{d:"M2 12a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 12",key:"1wduqc"}],["path",{d:"M2 17a1 1 0 0 0 .58.91l8.6 3.91a2 2 0 0 0 1.65 0l8.58-3.9A1 1 0 0 0 22 17",key:"kqbvx6"}]],ds=xe("layers",Ic);const Bc=[["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"}]],Fc=xe("maximize",Bc);const zc=[["path",{d:"M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z",key:"18887p"}]],Js=xe("message-square",zc);const Hc=[["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"}]],Wc=xe("panel-left-close",Hc);const $c=[["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"}]],Uc=xe("panel-left-open",$c);const qc=[["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"}]],Kc=xe("panel-right-close",qc);const Xc=[["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"}]],Ai=xe("panel-right-open",Xc);const Vc=[["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"}]],qt=xe("play",Vc);const Yc=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],Es=xe("refresh-cw",Yc);const Gc=[["path",{d:"M15.2 3a2 2 0 0 1 1.4.6l3.8 3.8a2 2 0 0 1 .6 1.4V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2z",key:"1c8476"}],["path",{d:"M17 21v-7a1 1 0 0 0-1-1H8a1 1 0 0 0-1 1v7",key:"1ydtos"}],["path",{d:"M7 3v4a1 1 0 0 0 1 1h7",key:"t51u73"}]],Qc=xe("save",Gc);const Zc=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}]],Jc=xe("shield",Zc);const ed=[["path",{d:"M12 19h8",key:"baeox8"}],["path",{d:"m4 17 6-6-6-6",key:"1yngyt"}]],er=xe("terminal",ed);const td=[["path",{d:"M4 14a1 1 0 0 1-.78-1.63l9.9-10.2a.5.5 0 0 1 .86.46l-1.92 6.02A1 1 0 0 0 13 10h7a1 1 0 0 1 .78 1.63l-9.9 10.2a.5.5 0 0 1-.86-.46l1.92-6.02A1 1 0 0 0 11 14z",key:"1xq2db"}]],sd=xe("zap",td);const rd=[["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"}]],id=xe("zoom-in",rd);const nd=[["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"}]],od=xe("zoom-out",nd),gr=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function us(e){const t=Object.prototype.toString.call(e);return t==="[object Window]"||t==="[object global]"}function Ri(e){return"nodeType"in e}function gt(e){var t,r;return e?us(e)?e:Ri(e)&&(t=(r=e.ownerDocument)==null?void 0:r.defaultView)!=null?t:window:window}function Ti(e){const{Document:t}=gt(e);return e instanceof t}function Ls(e){return us(e)?!1:e instanceof gt(e).HTMLElement}function Lo(e){return e instanceof gt(e).SVGElement}function hs(e){return e?us(e)?e.document:Ri(e)?Ti(e)?e:Ls(e)||Lo(e)?e.ownerDocument:document:document:document}const Rt=gr?C.useLayoutEffect:C.useEffect;function vr(e){const t=C.useRef(e);return Rt(()=>{t.current=e}),C.useCallback(function(){for(var r=arguments.length,a=new Array(r),p=0;p<r;p++)a[p]=arguments[p];return t.current==null?void 0:t.current(...a)},[])}function ad(){const e=C.useRef(null),t=C.useCallback((a,p)=>{e.current=setInterval(a,p)},[]),r=C.useCallback(()=>{e.current!==null&&(clearInterval(e.current),e.current=null)},[]);return[t,r]}function js(e,t){t===void 0&&(t=[e]);const r=C.useRef(e);return Rt(()=>{r.current!==e&&(r.current=e)},t),r}function Ps(e,t){const r=C.useRef();return C.useMemo(()=>{const a=e(r.current);return r.current=a,a},[...t])}function tr(e){const t=vr(e),r=C.useRef(null),a=C.useCallback(p=>{p!==r.current&&t?.(p,r.current),r.current=p},[]);return[r,a]}function sr(e){const t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}let Pr={};function _r(e,t){return C.useMemo(()=>{if(t)return t;const r=Pr[e]==null?0:Pr[e]+1;return Pr[e]=r,e+"-"+r},[e,t])}function Po(e){return function(t){for(var r=arguments.length,a=new Array(r>1?r-1:0),p=1;p<r;p++)a[p-1]=arguments[p];return a.reduce((m,v)=>{const i=Object.entries(v);for(const[n,c]of i){const f=m[n];f!=null&&(m[n]=f+e*c)}return m},{...t})}}const is=Po(1),rr=Po(-1);function ld(e){return"clientX"in e&&"clientY"in e}function Mi(e){if(!e)return!1;const{KeyboardEvent:t}=gt(e.target);return t&&e instanceof t}function cd(e){if(!e)return!1;const{TouchEvent:t}=gt(e.target);return t&&e instanceof t}function ir(e){if(cd(e)){if(e.touches&&e.touches.length){const{clientX:t,clientY:r}=e.touches[0];return{x:t,y:r}}else if(e.changedTouches&&e.changedTouches.length){const{clientX:t,clientY:r}=e.changedTouches[0];return{x:t,y:r}}}return ld(e)?{x:e.clientX,y:e.clientY}:null}const Ns=Object.freeze({Translate:{toString(e){if(!e)return;const{x:t,y:r}=e;return"translate3d("+(t?Math.round(t):0)+"px, "+(r?Math.round(r):0)+"px, 0)"}},Scale:{toString(e){if(!e)return;const{scaleX:t,scaleY:r}=e;return"scaleX("+t+") scaleY("+r+")"}},Transform:{toString(e){if(e)return[Ns.Translate.toString(e),Ns.Scale.toString(e)].join(" ")}},Transition:{toString(e){let{property:t,duration:r,easing:a}=e;return t+" "+r+"ms "+a}}}),gn="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function dd(e){return e.matches(gn)?e:e.querySelector(gn)}const ud={display:"none"};function hd(e){let{id:t,value:r}=e;return ie.createElement("div",{id:t,style:ud},r)}function fd(e){let{id:t,announcement:r,ariaLiveType:a="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 ie.createElement("div",{id:t,style:p,role:"status","aria-live":a,"aria-atomic":!0},r)}function md(){const[e,t]=C.useState("");return{announce:C.useCallback(a=>{a!=null&&t(a)},[]),announcement:e}}const Oo=C.createContext(null);function pd(e){const t=C.useContext(Oo);C.useEffect(()=>{if(!t)throw new Error("useDndMonitor must be used within a children of <DndContext>");return t(e)},[e,t])}function gd(){const[e]=C.useState(()=>new Set),t=C.useCallback(a=>(e.add(a),()=>e.delete(a)),[e]);return[C.useCallback(a=>{let{type:p,event:m}=a;e.forEach(v=>{var i;return(i=v[p])==null?void 0:i.call(v,m)})},[e]),t]}const vd={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
+ `},_d={onDragStart(e){let{active:t}=e;return"Picked up draggable item "+t.id+"."},onDragOver(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was moved over droppable area "+r.id+".":"Draggable item "+t.id+" is no longer over a droppable area."},onDragEnd(e){let{active:t,over:r}=e;return r?"Draggable item "+t.id+" was dropped over droppable area "+r.id:"Draggable item "+t.id+" was dropped."},onDragCancel(e){let{active:t}=e;return"Dragging was cancelled. Draggable item "+t.id+" was dropped."}};function xd(e){let{announcements:t=_d,container:r,hiddenTextDescribedById:a,screenReaderInstructions:p=vd}=e;const{announce:m,announcement:v}=md(),i=_r("DndLiveRegion"),[n,c]=C.useState(!1);if(C.useEffect(()=>{c(!0)},[]),pd(C.useMemo(()=>({onDragStart(l){let{active:g}=l;m(t.onDragStart({active:g}))},onDragMove(l){let{active:g,over:b}=l;t.onDragMove&&m(t.onDragMove({active:g,over:b}))},onDragOver(l){let{active:g,over:b}=l;m(t.onDragOver({active:g,over:b}))},onDragEnd(l){let{active:g,over:b}=l;m(t.onDragEnd({active:g,over:b}))},onDragCancel(l){let{active:g,over:b}=l;m(t.onDragCancel({active:g,over:b}))}}),[m,t])),!n)return null;const f=ie.createElement(ie.Fragment,null,ie.createElement(hd,{id:a,value:p.draggable}),ie.createElement(fd,{id:i,announcement:v}));return r?Ut.createPortal(f,r):f}var at;(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"})(at||(at={}));function nr(){}function bd(e,t){return C.useMemo(()=>({sensor:e,options:t??{}}),[e,t])}function yd(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return C.useMemo(()=>[...t].filter(a=>a!=null),[...t])}const Et=Object.freeze({x:0,y:0});function Sd(e,t){const r=ir(e);if(!r)return"0 0";const a={x:(r.x-t.left)/t.width*100,y:(r.y-t.top)/t.height*100};return a.x+"% "+a.y+"%"}function wd(e,t){let{data:{value:r}}=e,{data:{value:a}}=t;return a-r}function Cd(e,t){if(!e||e.length===0)return null;const[r]=e;return r[t]}function kd(e,t){const r=Math.max(t.top,e.top),a=Math.max(t.left,e.left),p=Math.min(t.left+t.width,e.left+e.width),m=Math.min(t.top+t.height,e.top+e.height),v=p-a,i=m-r;if(a<p&&r<m){const n=t.width*t.height,c=e.width*e.height,f=v*i,l=f/(n+c-f);return Number(l.toFixed(4))}return 0}const Ed=e=>{let{collisionRect:t,droppableRects:r,droppableContainers:a}=e;const p=[];for(const m of a){const{id:v}=m,i=r.get(v);if(i){const n=kd(i,t);n>0&&p.push({id:v,data:{droppableContainer:m,value:n}})}}return p.sort(wd)};function jd(e,t,r){return{...e,scaleX:t&&r?t.width/r.width:1,scaleY:t&&r?t.height/r.height:1}}function Io(e,t){return e&&t?{x:e.left-t.left,y:e.top-t.top}:Et}function Nd(e){return function(r){for(var a=arguments.length,p=new Array(a>1?a-1:0),m=1;m<a;m++)p[m-1]=arguments[m];return p.reduce((v,i)=>({...v,top:v.top+e*i.y,bottom:v.bottom+e*i.y,left:v.left+e*i.x,right:v.right+e*i.x}),{...r})}}const Ad=Nd(1);function Bo(e){if(e.startsWith("matrix3d(")){const t=e.slice(9,-1).split(/, /);return{x:+t[12],y:+t[13],scaleX:+t[0],scaleY:+t[5]}}else if(e.startsWith("matrix(")){const t=e.slice(7,-1).split(/, /);return{x:+t[4],y:+t[5],scaleX:+t[0],scaleY:+t[3]}}return null}function Rd(e,t,r){const a=Bo(t);if(!a)return e;const{scaleX:p,scaleY:m,x:v,y:i}=a,n=e.left-v-(1-p)*parseFloat(r),c=e.top-i-(1-m)*parseFloat(r.slice(r.indexOf(" ")+1)),f=p?e.width/p:e.width,l=m?e.height/m:e.height;return{width:f,height:l,top:c,right:n+f,bottom:c+l,left:n}}const Td={ignoreTransform:!1};function Os(e,t){t===void 0&&(t=Td);let r=e.getBoundingClientRect();if(t.ignoreTransform){const{transform:c,transformOrigin:f}=gt(e).getComputedStyle(e);c&&(r=Rd(r,c,f))}const{top:a,left:p,width:m,height:v,bottom:i,right:n}=r;return{top:a,left:p,width:m,height:v,bottom:i,right:n}}function vn(e){return Os(e,{ignoreTransform:!0})}function Md(e){const t=e.innerWidth,r=e.innerHeight;return{top:0,left:0,right:t,bottom:r,width:t,height:r}}function Dd(e,t){return t===void 0&&(t=gt(e).getComputedStyle(e)),t.position==="fixed"}function Ld(e,t){t===void 0&&(t=gt(e).getComputedStyle(e));const r=/(auto|scroll|overlay)/;return["overflow","overflowX","overflowY"].some(p=>{const m=t[p];return typeof m=="string"?r.test(m):!1})}function Di(e,t){const r=[];function a(p){if(t!=null&&r.length>=t||!p)return r;if(Ti(p)&&p.scrollingElement!=null&&!r.includes(p.scrollingElement))return r.push(p.scrollingElement),r;if(!Ls(p)||Lo(p)||r.includes(p))return r;const m=gt(e).getComputedStyle(p);return p!==e&&Ld(p,m)&&r.push(p),Dd(p,m)?r:a(p.parentNode)}return e?a(e):r}function Fo(e){const[t]=Di(e,1);return t??null}function Or(e){return!gr||!e?null:us(e)?e:Ri(e)?Ti(e)||e===hs(e).scrollingElement?window:Ls(e)?e:null:null}function zo(e){return us(e)?e.scrollX:e.scrollLeft}function Ho(e){return us(e)?e.scrollY:e.scrollTop}function si(e){return{x:zo(e),y:Ho(e)}}var dt;(function(e){e[e.Forward=1]="Forward",e[e.Backward=-1]="Backward"})(dt||(dt={}));function Wo(e){return!gr||!e?!1:e===document.scrollingElement}function $o(e){const t={x:0,y:0},r=Wo(e)?{height:window.innerHeight,width:window.innerWidth}:{height:e.clientHeight,width:e.clientWidth},a={x:e.scrollWidth-r.width,y:e.scrollHeight-r.height},p=e.scrollTop<=t.y,m=e.scrollLeft<=t.x,v=e.scrollTop>=a.y,i=e.scrollLeft>=a.x;return{isTop:p,isLeft:m,isBottom:v,isRight:i,maxScroll:a,minScroll:t}}const Pd={x:.2,y:.2};function Od(e,t,r,a,p){let{top:m,left:v,right:i,bottom:n}=r;a===void 0&&(a=10),p===void 0&&(p=Pd);const{isTop:c,isBottom:f,isLeft:l,isRight:g}=$o(e),b={x:0,y:0},y={x:0,y:0},_={height:t.height*p.y,width:t.width*p.x};return!c&&m<=t.top+_.height?(b.y=dt.Backward,y.y=a*Math.abs((t.top+_.height-m)/_.height)):!f&&n>=t.bottom-_.height&&(b.y=dt.Forward,y.y=a*Math.abs((t.bottom-_.height-n)/_.height)),!g&&i>=t.right-_.width?(b.x=dt.Forward,y.x=a*Math.abs((t.right-_.width-i)/_.width)):!l&&v<=t.left+_.width&&(b.x=dt.Backward,y.x=a*Math.abs((t.left+_.width-v)/_.width)),{direction:b,speed:y}}function Id(e){if(e===document.scrollingElement){const{innerWidth:m,innerHeight:v}=window;return{top:0,left:0,right:m,bottom:v,width:m,height:v}}const{top:t,left:r,right:a,bottom:p}=e.getBoundingClientRect();return{top:t,left:r,right:a,bottom:p,width:e.clientWidth,height:e.clientHeight}}function Uo(e){return e.reduce((t,r)=>is(t,si(r)),Et)}function Bd(e){return e.reduce((t,r)=>t+zo(r),0)}function Fd(e){return e.reduce((t,r)=>t+Ho(r),0)}function qo(e,t){if(t===void 0&&(t=Os),!e)return;const{top:r,left:a,bottom:p,right:m}=t(e);Fo(e)&&(p<=0||m<=0||r>=window.innerHeight||a>=window.innerWidth)&&e.scrollIntoView({block:"center",inline:"center"})}const zd=[["x",["left","right"],Bd],["y",["top","bottom"],Fd]];class Li{constructor(t,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 a=Di(r),p=Uo(a);this.rect={...t},this.width=t.width,this.height=t.height;for(const[m,v,i]of zd)for(const n of v)Object.defineProperty(this,n,{get:()=>{const c=i(a),f=p[m]-c;return this.rect[n]+f},enumerable:!0});Object.defineProperty(this,"rect",{enumerable:!1})}}class xs{constructor(t){this.target=void 0,this.listeners=[],this.removeAll=()=>{this.listeners.forEach(r=>{var a;return(a=this.target)==null?void 0:a.removeEventListener(...r)})},this.target=t}add(t,r,a){var p;(p=this.target)==null||p.addEventListener(t,r,a),this.listeners.push([t,r,a])}}function Hd(e){const{EventTarget:t}=gt(e);return e instanceof t?e:hs(e)}function Ir(e,t){const r=Math.abs(e.x),a=Math.abs(e.y);return typeof t=="number"?Math.sqrt(r**2+a**2)>t:"x"in t&&"y"in t?r>t.x&&a>t.y:"x"in t?r>t.x:"y"in t?a>t.y:!1}var St;(function(e){e.Click="click",e.DragStart="dragstart",e.Keydown="keydown",e.ContextMenu="contextmenu",e.Resize="resize",e.SelectionChange="selectionchange",e.VisibilityChange="visibilitychange"})(St||(St={}));function _n(e){e.preventDefault()}function Wd(e){e.stopPropagation()}var Be;(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"})(Be||(Be={}));const Ko={start:[Be.Space,Be.Enter],cancel:[Be.Esc],end:[Be.Space,Be.Enter,Be.Tab]},$d=(e,t)=>{let{currentCoordinates:r}=t;switch(e.code){case Be.Right:return{...r,x:r.x+25};case Be.Left:return{...r,x:r.x-25};case Be.Down:return{...r,y:r.y+25};case Be.Up:return{...r,y:r.y-25}}};class Xo{constructor(t){this.props=void 0,this.autoScrollEnabled=!1,this.referenceCoordinates=void 0,this.listeners=void 0,this.windowListeners=void 0,this.props=t;const{event:{target:r}}=t;this.props=t,this.listeners=new xs(hs(r)),this.windowListeners=new xs(gt(r)),this.handleKeyDown=this.handleKeyDown.bind(this),this.handleCancel=this.handleCancel.bind(this),this.attach()}attach(){this.handleStart(),this.windowListeners.add(St.Resize,this.handleCancel),this.windowListeners.add(St.VisibilityChange,this.handleCancel),setTimeout(()=>this.listeners.add(St.Keydown,this.handleKeyDown))}handleStart(){const{activeNode:t,onStart:r}=this.props,a=t.node.current;a&&qo(a),r(Et)}handleKeyDown(t){if(Mi(t)){const{active:r,context:a,options:p}=this.props,{keyboardCodes:m=Ko,coordinateGetter:v=$d,scrollBehavior:i="smooth"}=p,{code:n}=t;if(m.end.includes(n)){this.handleEnd(t);return}if(m.cancel.includes(n)){this.handleCancel(t);return}const{collisionRect:c}=a.current,f=c?{x:c.left,y:c.top}:Et;this.referenceCoordinates||(this.referenceCoordinates=f);const l=v(t,{active:r,context:a.current,currentCoordinates:f});if(l){const g=rr(l,f),b={x:0,y:0},{scrollableAncestors:y}=a.current;for(const _ of y){const o=t.code,{isTop:h,isRight:d,isLeft:u,isBottom:x,maxScroll:S,minScroll:k}=$o(_),E=Id(_),w={x:Math.min(o===Be.Right?E.right-E.width/2:E.right,Math.max(o===Be.Right?E.left:E.left+E.width/2,l.x)),y:Math.min(o===Be.Down?E.bottom-E.height/2:E.bottom,Math.max(o===Be.Down?E.top:E.top+E.height/2,l.y))},j=o===Be.Right&&!d||o===Be.Left&&!u,R=o===Be.Down&&!x||o===Be.Up&&!h;if(j&&w.x!==l.x){const L=_.scrollLeft+g.x,D=o===Be.Right&&L<=S.x||o===Be.Left&&L>=k.x;if(D&&!g.y){_.scrollTo({left:L,behavior:i});return}D?b.x=_.scrollLeft-L:b.x=o===Be.Right?_.scrollLeft-S.x:_.scrollLeft-k.x,b.x&&_.scrollBy({left:-b.x,behavior:i});break}else if(R&&w.y!==l.y){const L=_.scrollTop+g.y,D=o===Be.Down&&L<=S.y||o===Be.Up&&L>=k.y;if(D&&!g.x){_.scrollTo({top:L,behavior:i});return}D?b.y=_.scrollTop-L:b.y=o===Be.Down?_.scrollTop-S.y:_.scrollTop-k.y,b.y&&_.scrollBy({top:-b.y,behavior:i});break}}this.handleMove(t,is(rr(l,this.referenceCoordinates),b))}}}handleMove(t,r){const{onMove:a}=this.props;t.preventDefault(),a(r)}handleEnd(t){const{onEnd:r}=this.props;t.preventDefault(),this.detach(),r()}handleCancel(t){const{onCancel:r}=this.props;t.preventDefault(),this.detach(),r()}detach(){this.listeners.removeAll(),this.windowListeners.removeAll()}}Xo.activators=[{eventName:"onKeyDown",handler:(e,t,r)=>{let{keyboardCodes:a=Ko,onActivation:p}=t,{active:m}=r;const{code:v}=e.nativeEvent;if(a.start.includes(v)){const i=m.activatorNode.current;return i&&e.target!==i?!1:(e.preventDefault(),p?.({event:e.nativeEvent}),!0)}return!1}}];function xn(e){return!!(e&&"distance"in e)}function bn(e){return!!(e&&"delay"in e)}class Pi{constructor(t,r,a){var p;a===void 0&&(a=Hd(t.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=t,this.events=r;const{event:m}=t,{target:v}=m;this.props=t,this.events=r,this.document=hs(v),this.documentListeners=new xs(this.document),this.listeners=new xs(a),this.windowListeners=new xs(gt(v)),this.initialCoordinates=(p=ir(m))!=null?p:Et,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:t,props:{options:{activationConstraint:r,bypassActivationConstraint:a}}}=this;if(this.listeners.add(t.move.name,this.handleMove,{passive:!1}),this.listeners.add(t.end.name,this.handleEnd),t.cancel&&this.listeners.add(t.cancel.name,this.handleCancel),this.windowListeners.add(St.Resize,this.handleCancel),this.windowListeners.add(St.DragStart,_n),this.windowListeners.add(St.VisibilityChange,this.handleCancel),this.windowListeners.add(St.ContextMenu,_n),this.documentListeners.add(St.Keydown,this.handleKeydown),r){if(a!=null&&a({event:this.props.event,activeNode:this.props.activeNode,options:this.props.options}))return this.handleStart();if(bn(r)){this.timeoutId=setTimeout(this.handleStart,r.delay),this.handlePending(r);return}if(xn(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(t,r){const{active:a,onPending:p}=this.props;p(a,t,this.initialCoordinates,r)}handleStart(){const{initialCoordinates:t}=this,{onStart:r}=this.props;t&&(this.activated=!0,this.documentListeners.add(St.Click,Wd,{capture:!0}),this.removeTextSelection(),this.documentListeners.add(St.SelectionChange,this.removeTextSelection),r(t))}handleMove(t){var r;const{activated:a,initialCoordinates:p,props:m}=this,{onMove:v,options:{activationConstraint:i}}=m;if(!p)return;const n=(r=ir(t))!=null?r:Et,c=rr(p,n);if(!a&&i){if(xn(i)){if(i.tolerance!=null&&Ir(c,i.tolerance))return this.handleCancel();if(Ir(c,i.distance))return this.handleStart()}if(bn(i)&&Ir(c,i.tolerance))return this.handleCancel();this.handlePending(i,c);return}t.cancelable&&t.preventDefault(),v(n)}handleEnd(){const{onAbort:t,onEnd:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleCancel(){const{onAbort:t,onCancel:r}=this.props;this.detach(),this.activated||t(this.props.active),r()}handleKeydown(t){t.code===Be.Esc&&this.handleCancel()}removeTextSelection(){var t;(t=this.document.getSelection())==null||t.removeAllRanges()}}const Ud={cancel:{name:"pointercancel"},move:{name:"pointermove"},end:{name:"pointerup"}};class Oi extends Pi{constructor(t){const{event:r}=t,a=hs(r.target);super(t,Ud,a)}}Oi.activators=[{eventName:"onPointerDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:a}=t;return!r.isPrimary||r.button!==0?!1:(a?.({event:r}),!0)}}];const qd={move:{name:"mousemove"},end:{name:"mouseup"}};var ri;(function(e){e[e.RightClick=2]="RightClick"})(ri||(ri={}));class Kd extends Pi{constructor(t){super(t,qd,hs(t.event.target))}}Kd.activators=[{eventName:"onMouseDown",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:a}=t;return r.button===ri.RightClick?!1:(a?.({event:r}),!0)}}];const Br={cancel:{name:"touchcancel"},move:{name:"touchmove"},end:{name:"touchend"}};class Xd extends Pi{constructor(t){super(t,Br)}static setup(){return window.addEventListener(Br.move.name,t,{capture:!1,passive:!1}),function(){window.removeEventListener(Br.move.name,t)};function t(){}}}Xd.activators=[{eventName:"onTouchStart",handler:(e,t)=>{let{nativeEvent:r}=e,{onActivation:a}=t;const{touches:p}=r;return p.length>1?!1:(a?.({event:r}),!0)}}];var bs;(function(e){e[e.Pointer=0]="Pointer",e[e.DraggableRect=1]="DraggableRect"})(bs||(bs={}));var or;(function(e){e[e.TreeOrder=0]="TreeOrder",e[e.ReversedTreeOrder=1]="ReversedTreeOrder"})(or||(or={}));function Vd(e){let{acceleration:t,activator:r=bs.Pointer,canScroll:a,draggingRect:p,enabled:m,interval:v=5,order:i=or.TreeOrder,pointerCoordinates:n,scrollableAncestors:c,scrollableAncestorRects:f,delta:l,threshold:g}=e;const b=Gd({delta:l,disabled:!m}),[y,_]=ad(),o=C.useRef({x:0,y:0}),h=C.useRef({x:0,y:0}),d=C.useMemo(()=>{switch(r){case bs.Pointer:return n?{top:n.y,bottom:n.y,left:n.x,right:n.x}:null;case bs.DraggableRect:return p}},[r,p,n]),u=C.useRef(null),x=C.useCallback(()=>{const k=u.current;if(!k)return;const E=o.current.x*h.current.x,w=o.current.y*h.current.y;k.scrollBy(E,w)},[]),S=C.useMemo(()=>i===or.TreeOrder?[...c].reverse():c,[i,c]);C.useEffect(()=>{if(!m||!c.length||!d){_();return}for(const k of S){if(a?.(k)===!1)continue;const E=c.indexOf(k),w=f[E];if(!w)continue;const{direction:j,speed:R}=Od(k,w,d,t,g);for(const L of["x","y"])b[L][j[L]]||(R[L]=0,j[L]=0);if(R.x>0||R.y>0){_(),u.current=k,y(x,v),o.current=R,h.current=j;return}}o.current={x:0,y:0},h.current={x:0,y:0},_()},[t,x,a,_,m,v,JSON.stringify(d),JSON.stringify(b),y,c,S,f,JSON.stringify(g)])}const Yd={x:{[dt.Backward]:!1,[dt.Forward]:!1},y:{[dt.Backward]:!1,[dt.Forward]:!1}};function Gd(e){let{delta:t,disabled:r}=e;const a=sr(t);return Ps(p=>{if(r||!a||!p)return Yd;const m={x:Math.sign(t.x-a.x),y:Math.sign(t.y-a.y)};return{x:{[dt.Backward]:p.x[dt.Backward]||m.x===-1,[dt.Forward]:p.x[dt.Forward]||m.x===1},y:{[dt.Backward]:p.y[dt.Backward]||m.y===-1,[dt.Forward]:p.y[dt.Forward]||m.y===1}}},[r,t,a])}function Qd(e,t){const r=t!=null?e.get(t):void 0,a=r?r.node.current:null;return Ps(p=>{var m;return t==null?null:(m=a??p)!=null?m:null},[a,t])}function Zd(e,t){return C.useMemo(()=>e.reduce((r,a)=>{const{sensor:p}=a,m=p.activators.map(v=>({eventName:v.eventName,handler:t(v.handler,a)}));return[...r,...m]},[]),[e,t])}var As;(function(e){e[e.Always=0]="Always",e[e.BeforeDragging=1]="BeforeDragging",e[e.WhileDragging=2]="WhileDragging"})(As||(As={}));var ii;(function(e){e.Optimized="optimized"})(ii||(ii={}));const yn=new Map;function Jd(e,t){let{dragging:r,dependencies:a,config:p}=t;const[m,v]=C.useState(null),{frequency:i,measure:n,strategy:c}=p,f=C.useRef(e),l=o(),g=js(l),b=C.useCallback(function(h){h===void 0&&(h=[]),!g.current&&v(d=>d===null?h:d.concat(h.filter(u=>!d.includes(u))))},[g]),y=C.useRef(null),_=Ps(h=>{if(l&&!r)return yn;if(!h||h===yn||f.current!==e||m!=null){const d=new Map;for(let u of e){if(!u)continue;if(m&&m.length>0&&!m.includes(u.id)&&u.rect.current){d.set(u.id,u.rect.current);continue}const x=u.node.current,S=x?new Li(n(x),x):null;u.rect.current=S,S&&d.set(u.id,S)}return d}return h},[e,m,r,l,n]);return C.useEffect(()=>{f.current=e},[e]),C.useEffect(()=>{l||b()},[r,l]),C.useEffect(()=>{m&&m.length>0&&v(null)},[JSON.stringify(m)]),C.useEffect(()=>{l||typeof i!="number"||y.current!==null||(y.current=setTimeout(()=>{b(),y.current=null},i))},[i,l,b,...a]),{droppableRects:_,measureDroppableContainers:b,measuringScheduled:m!=null};function o(){switch(c){case As.Always:return!1;case As.BeforeDragging:return r;default:return!r}}}function Ii(e,t){return Ps(r=>e?r||(typeof t=="function"?t(e):e):null,[t,e])}function eu(e,t){return Ii(e,t)}function tu(e){let{callback:t,disabled:r}=e;const a=vr(t),p=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.MutationObserver>"u")return;const{MutationObserver:m}=window;return new m(a)},[a,r]);return C.useEffect(()=>()=>p?.disconnect(),[p]),p}function xr(e){let{callback:t,disabled:r}=e;const a=vr(t),p=C.useMemo(()=>{if(r||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:m}=window;return new m(a)},[r]);return C.useEffect(()=>()=>p?.disconnect(),[p]),p}function su(e){return new Li(Os(e),e)}function Sn(e,t,r){t===void 0&&(t=su);const[a,p]=C.useState(null);function m(){p(n=>{if(!e)return null;if(e.isConnected===!1){var c;return(c=n??r)!=null?c:null}const f=t(e);return JSON.stringify(n)===JSON.stringify(f)?n:f})}const v=tu({callback(n){if(e)for(const c of n){const{type:f,target:l}=c;if(f==="childList"&&l instanceof HTMLElement&&l.contains(e)){m();break}}}}),i=xr({callback:m});return Rt(()=>{m(),e?(i?.observe(e),v?.observe(document.body,{childList:!0,subtree:!0})):(i?.disconnect(),v?.disconnect())},[e]),a}function ru(e){const t=Ii(e);return Io(e,t)}const wn=[];function iu(e){const t=C.useRef(e),r=Ps(a=>e?a&&a!==wn&&e&&t.current&&e.parentNode===t.current.parentNode?a:Di(e):wn,[e]);return C.useEffect(()=>{t.current=e},[e]),r}function nu(e){const[t,r]=C.useState(null),a=C.useRef(e),p=C.useCallback(m=>{const v=Or(m.target);v&&r(i=>i?(i.set(v,si(v)),new Map(i)):null)},[]);return C.useEffect(()=>{const m=a.current;if(e!==m){v(m);const i=e.map(n=>{const c=Or(n);return c?(c.addEventListener("scroll",p,{passive:!0}),[c,si(c)]):null}).filter(n=>n!=null);r(i.length?new Map(i):null),a.current=e}return()=>{v(e),v(m)};function v(i){i.forEach(n=>{const c=Or(n);c?.removeEventListener("scroll",p)})}},[p,e]),C.useMemo(()=>e.length?t?Array.from(t.values()).reduce((m,v)=>is(m,v),Et):Uo(e):Et,[e,t])}function Cn(e,t){t===void 0&&(t=[]);const r=C.useRef(null);return C.useEffect(()=>{r.current=null},t),C.useEffect(()=>{const a=e!==Et;a&&!r.current&&(r.current=e),!a&&r.current&&(r.current=null)},[e]),r.current?rr(e,r.current):Et}function ou(e){C.useEffect(()=>{if(!gr)return;const t=e.map(r=>{let{sensor:a}=r;return a.setup==null?void 0:a.setup()});return()=>{for(const r of t)r?.()}},e.map(t=>{let{sensor:r}=t;return r}))}function au(e,t){return C.useMemo(()=>e.reduce((r,a)=>{let{eventName:p,handler:m}=a;return r[p]=v=>{m(v,t)},r},{}),[e,t])}function Vo(e){return C.useMemo(()=>e?Md(e):null,[e])}const kn=[];function lu(e,t){t===void 0&&(t=Os);const[r]=e,a=Vo(r?gt(r):null),[p,m]=C.useState(kn);function v(){m(()=>e.length?e.map(n=>Wo(n)?a:new Li(t(n),n)):kn)}const i=xr({callback:v});return Rt(()=>{i?.disconnect(),v(),e.forEach(n=>i?.observe(n))},[e]),p}function Yo(e){if(!e)return null;if(e.children.length>1)return e;const t=e.children[0];return Ls(t)?t:e}function cu(e){let{measure:t}=e;const[r,a]=C.useState(null),p=C.useCallback(c=>{for(const{target:f}of c)if(Ls(f)){a(l=>{const g=t(f);return l?{...l,width:g.width,height:g.height}:g});break}},[t]),m=xr({callback:p}),v=C.useCallback(c=>{const f=Yo(c);m?.disconnect(),f&&m?.observe(f),a(f?t(f):null)},[t,m]),[i,n]=tr(v);return C.useMemo(()=>({nodeRef:i,rect:r,setRef:n}),[r,i,n])}const du=[{sensor:Oi,options:{}},{sensor:Xo,options:{}}],uu={current:{}},Ys={draggable:{measure:vn},droppable:{measure:vn,strategy:As.WhileDragging,frequency:ii.Optimized},dragOverlay:{measure:Os}};class ys extends Map{get(t){var r;return t!=null&&(r=super.get(t))!=null?r:void 0}toArray(){return Array.from(this.values())}getEnabled(){return this.toArray().filter(t=>{let{disabled:r}=t;return!r})}getNodeFor(t){var r,a;return(r=(a=this.get(t))==null?void 0:a.node.current)!=null?r:void 0}}const hu={activatorEvent:null,active:null,activeNode:null,activeNodeRect:null,collisions:null,containerNodeRect:null,draggableNodes:new Map,droppableRects:new Map,droppableContainers:new ys,over:null,dragOverlay:{nodeRef:{current:null},rect:null,setRef:nr},scrollableAncestors:[],scrollableAncestorRects:[],measuringConfiguration:Ys,measureDroppableContainers:nr,windowRect:null,measuringScheduled:!1},Go={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:nr,draggableNodes:new Map,over:null,measureDroppableContainers:nr},Is=C.createContext(Go),Qo=C.createContext(hu);function fu(){return{draggable:{active:null,initialCoordinates:{x:0,y:0},nodes:new Map,translate:{x:0,y:0}},droppable:{containers:new ys}}}function mu(e,t){switch(t.type){case at.DragStart:return{...e,draggable:{...e.draggable,initialCoordinates:t.initialCoordinates,active:t.active}};case at.DragMove:return e.draggable.active==null?e:{...e,draggable:{...e.draggable,translate:{x:t.coordinates.x-e.draggable.initialCoordinates.x,y:t.coordinates.y-e.draggable.initialCoordinates.y}}};case at.DragEnd:case at.DragCancel:return{...e,draggable:{...e.draggable,active:null,initialCoordinates:{x:0,y:0},translate:{x:0,y:0}}};case at.RegisterDroppable:{const{element:r}=t,{id:a}=r,p=new ys(e.droppable.containers);return p.set(a,r),{...e,droppable:{...e.droppable,containers:p}}}case at.SetDroppableDisabled:{const{id:r,key:a,disabled:p}=t,m=e.droppable.containers.get(r);if(!m||a!==m.key)return e;const v=new ys(e.droppable.containers);return v.set(r,{...m,disabled:p}),{...e,droppable:{...e.droppable,containers:v}}}case at.UnregisterDroppable:{const{id:r,key:a}=t,p=e.droppable.containers.get(r);if(!p||a!==p.key)return e;const m=new ys(e.droppable.containers);return m.delete(r),{...e,droppable:{...e.droppable,containers:m}}}default:return e}}function pu(e){let{disabled:t}=e;const{active:r,activatorEvent:a,draggableNodes:p}=C.useContext(Is),m=sr(a),v=sr(r?.id);return C.useEffect(()=>{if(!t&&!a&&m&&v!=null){if(!Mi(m)||document.activeElement===m.target)return;const i=p.get(v);if(!i)return;const{activatorNode:n,node:c}=i;if(!n.current&&!c.current)return;requestAnimationFrame(()=>{for(const f of[n.current,c.current]){if(!f)continue;const l=dd(f);if(l){l.focus();break}}})}},[a,t,p,v,m]),null}function Zo(e,t){let{transform:r,...a}=t;return e!=null&&e.length?e.reduce((p,m)=>m({transform:p,...a}),r):r}function gu(e){return C.useMemo(()=>({draggable:{...Ys.draggable,...e?.draggable},droppable:{...Ys.droppable,...e?.droppable},dragOverlay:{...Ys.dragOverlay,...e?.dragOverlay}}),[e?.draggable,e?.droppable,e?.dragOverlay])}function vu(e){let{activeNode:t,measure:r,initialRect:a,config:p=!0}=e;const m=C.useRef(!1),{x:v,y:i}=typeof p=="boolean"?{x:p,y:p}:p;Rt(()=>{if(!v&&!i||!t){m.current=!1;return}if(m.current||!a)return;const c=t?.node.current;if(!c||c.isConnected===!1)return;const f=r(c),l=Io(f,a);if(v||(l.x=0),i||(l.y=0),m.current=!0,Math.abs(l.x)>0||Math.abs(l.y)>0){const g=Fo(c);g&&g.scrollBy({top:l.y,left:l.x})}},[t,v,i,a,r])}const br=C.createContext({...Et,scaleX:1,scaleY:1});var Pt;(function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Initializing=1]="Initializing",e[e.Initialized=2]="Initialized"})(Pt||(Pt={}));const _u=C.memo(function(t){var r,a,p,m;let{id:v,accessibility:i,autoScroll:n=!0,children:c,sensors:f=du,collisionDetection:l=Ed,measuring:g,modifiers:b,...y}=t;const _=C.useReducer(mu,void 0,fu),[o,h]=_,[d,u]=gd(),[x,S]=C.useState(Pt.Uninitialized),k=x===Pt.Initialized,{draggable:{active:E,nodes:w,translate:j},droppable:{containers:R}}=o,L=E!=null?w.get(E):null,D=C.useRef({initial:null,translated:null}),N=C.useMemo(()=>{var We;return E!=null?{id:E,data:(We=L?.data)!=null?We:uu,rect:D}:null},[E,L]),M=C.useRef(null),[O,F]=C.useState(null),[z,A]=C.useState(null),P=js(y,Object.values(y)),I=_r("DndDescribedBy",v),B=C.useMemo(()=>R.getEnabled(),[R]),$=gu(g),{droppableRects:X,measureDroppableContainers:Z,measuringScheduled:J}=Jd(B,{dragging:k,dependencies:[j.x,j.y],config:$.droppable}),ae=Qd(w,E),T=C.useMemo(()=>z?ir(z):null,[z]),H=He(),U=eu(ae,$.draggable.measure);vu({activeNode:E!=null?w.get(E):null,config:H.layoutShiftCompensation,initialRect:U,measure:$.draggable.measure});const W=Sn(ae,$.draggable.measure,U),te=Sn(ae?ae.parentElement:null),K=C.useRef({activatorEvent:null,active:null,activeNode:ae,collisionRect:null,collisions:null,droppableRects:X,draggableNodes:w,draggingNode:null,draggingNodeRect:null,droppableContainers:R,over:null,scrollableAncestors:[],scrollAdjustedTranslate:null}),ce=R.getNodeFor((r=K.current.over)==null?void 0:r.id),he=cu({measure:$.dragOverlay.measure}),ve=(a=he.nodeRef.current)!=null?a:ae,Fe=k?(p=he.rect)!=null?p:W:null,re=!!(he.nodeRef.current&&he.rect),pe=ru(re?null:W),Ze=Vo(ve?gt(ve):null),je=iu(k?ce??ae:null),Le=lu(je),we=Zo(b,{transform:{x:j.x-pe.x,y:j.y-pe.y,scaleX:1,scaleY:1},activatorEvent:z,active:N,activeNodeRect:W,containerNodeRect:te,draggingNodeRect:Fe,over:K.current.over,overlayNodeRect:he.rect,scrollableAncestors:je,scrollableAncestorRects:Le,windowRect:Ze}),Ce=T?is(T,j):null,Xe=nu(je),_e=Cn(Xe),ze=Cn(Xe,[W]),ke=is(we,_e),Re=Fe?Ad(Fe,we):null,tt=N&&Re?l({active:N,collisionRect:Re,droppableRects:X,droppableContainers:B,pointerCoordinates:Ce}):null,qe=Cd(tt,"id"),[q,Q]=C.useState(null),ue=re?we:is(we,ze),Te=jd(ue,(m=q?.rect)!=null?m:null,W),Ne=C.useRef(null),Ee=C.useCallback((We,st)=>{let{sensor:Je,options:pt}=st;if(M.current==null)return;const Me=w.get(M.current);if(!Me)return;const rt=We.nativeEvent,ht=new Je({active:M.current,activeNode:Me,event:rt,options:pt,context:K,onAbort(Ie){if(!w.get(Ie))return;const{onDragAbort:oe}=P.current,be={id:Ie};oe?.(be),d({type:"onDragAbort",event:be})},onPending(Ie,Y,oe,be){if(!w.get(Ie))return;const{onDragPending:it}=P.current,V={id:Ie,constraint:Y,initialCoordinates:oe,offset:be};it?.(V),d({type:"onDragPending",event:V})},onStart(Ie){const Y=M.current;if(Y==null)return;const oe=w.get(Y);if(!oe)return;const{onDragStart:be}=P.current,ye={activatorEvent:rt,active:{id:Y,data:oe.data,rect:D}};Ut.unstable_batchedUpdates(()=>{be?.(ye),S(Pt.Initializing),h({type:at.DragStart,initialCoordinates:Ie,active:Y}),d({type:"onDragStart",event:ye}),F(Ne.current),A(rt)})},onMove(Ie){h({type:at.DragMove,coordinates:Ie})},onEnd:xt(at.DragEnd),onCancel:xt(at.DragCancel)});Ne.current=ht;function xt(Ie){return async function(){const{active:oe,collisions:be,over:ye,scrollAdjustedTranslate:it}=K.current;let V=null;if(oe&&it){const{cancelDrop:ee}=P.current;V={activatorEvent:rt,active:oe,collisions:be,delta:it,over:ye},Ie===at.DragEnd&&typeof ee=="function"&&await Promise.resolve(ee(V))&&(Ie=at.DragCancel)}M.current=null,Ut.unstable_batchedUpdates(()=>{h({type:Ie}),S(Pt.Uninitialized),Q(null),F(null),A(null),Ne.current=null;const ee=Ie===at.DragEnd?"onDragEnd":"onDragCancel";if(V){const fe=P.current[ee];fe?.(V),d({type:ee,event:V})}})}}},[w]),lt=C.useCallback((We,st)=>(Je,pt)=>{const Me=Je.nativeEvent,rt=w.get(pt);if(M.current!==null||!rt||Me.dndKit||Me.defaultPrevented)return;const ht={active:rt};We(Je,st.options,ht)===!0&&(Me.dndKit={capturedBy:st.sensor},M.current=pt,Ee(Je,st))},[w,Ee]),ft=Zd(f,lt);ou(f),Rt(()=>{W&&x===Pt.Initializing&&S(Pt.Initialized)},[W,x]),C.useEffect(()=>{const{onDragMove:We}=P.current,{active:st,activatorEvent:Je,collisions:pt,over:Me}=K.current;if(!st||!Je)return;const rt={active:st,activatorEvent:Je,collisions:pt,delta:{x:ke.x,y:ke.y},over:Me};Ut.unstable_batchedUpdates(()=>{We?.(rt),d({type:"onDragMove",event:rt})})},[ke.x,ke.y]),C.useEffect(()=>{const{active:We,activatorEvent:st,collisions:Je,droppableContainers:pt,scrollAdjustedTranslate:Me}=K.current;if(!We||M.current==null||!st||!Me)return;const{onDragOver:rt}=P.current,ht=pt.get(qe),xt=ht&&ht.rect.current?{id:ht.id,rect:ht.rect.current,data:ht.data,disabled:ht.disabled}:null,Ie={active:We,activatorEvent:st,collisions:Je,delta:{x:Me.x,y:Me.y},over:xt};Ut.unstable_batchedUpdates(()=>{Q(xt),rt?.(Ie),d({type:"onDragOver",event:Ie})})},[qe]),Rt(()=>{K.current={activatorEvent:z,active:N,activeNode:ae,collisionRect:Re,collisions:tt,droppableRects:X,draggableNodes:w,draggingNode:ve,draggingNodeRect:Fe,droppableContainers:R,over:q,scrollableAncestors:je,scrollAdjustedTranslate:ke},D.current={initial:Fe,translated:Re}},[N,ae,tt,Re,w,ve,Fe,X,R,q,je,ke]),Vd({...H,delta:j,draggingRect:Re,pointerCoordinates:Ce,scrollableAncestors:je,scrollableAncestorRects:Le});const Pe=C.useMemo(()=>({active:N,activeNode:ae,activeNodeRect:W,activatorEvent:z,collisions:tt,containerNodeRect:te,dragOverlay:he,draggableNodes:w,droppableContainers:R,droppableRects:X,over:q,measureDroppableContainers:Z,scrollableAncestors:je,scrollableAncestorRects:Le,measuringConfiguration:$,measuringScheduled:J,windowRect:Ze}),[N,ae,W,z,tt,te,he,w,R,X,q,Z,je,Le,$,J,Ze]),Ve=C.useMemo(()=>({activatorEvent:z,activators:ft,active:N,activeNodeRect:W,ariaDescribedById:{draggable:I},dispatch:h,draggableNodes:w,over:q,measureDroppableContainers:Z}),[z,ft,N,W,h,I,w,q,Z]);return ie.createElement(Oo.Provider,{value:u},ie.createElement(Is.Provider,{value:Ve},ie.createElement(Qo.Provider,{value:Pe},ie.createElement(br.Provider,{value:Te},c)),ie.createElement(pu,{disabled:i?.restoreFocus===!1})),ie.createElement(xd,{...i,hiddenTextDescribedById:I}));function He(){const We=O?.autoScrollEnabled===!1,st=typeof n=="object"?n.enabled===!1:n===!1,Je=k&&!We&&!st;return typeof n=="object"?{...n,enabled:Je}:{enabled:Je}}}),xu=C.createContext(null),En="button",bu="Draggable";function yu(e){let{id:t,data:r,disabled:a=!1,attributes:p}=e;const m=_r(bu),{activators:v,activatorEvent:i,active:n,activeNodeRect:c,ariaDescribedById:f,draggableNodes:l,over:g}=C.useContext(Is),{role:b=En,roleDescription:y="draggable",tabIndex:_=0}=p??{},o=n?.id===t,h=C.useContext(o?br:xu),[d,u]=tr(),[x,S]=tr(),k=au(v,t),E=js(r);Rt(()=>(l.set(t,{id:t,key:m,node:d,activatorNode:x,data:E}),()=>{const j=l.get(t);j&&j.key===m&&l.delete(t)}),[l,t]);const w=C.useMemo(()=>({role:b,tabIndex:_,"aria-disabled":a,"aria-pressed":o&&b===En?!0:void 0,"aria-roledescription":y,"aria-describedby":f.draggable}),[a,b,_,o,y,f.draggable]);return{active:n,activatorEvent:i,activeNodeRect:c,attributes:w,isDragging:o,listeners:a?void 0:k,node:d,over:g,setNodeRef:u,setActivatorNodeRef:S,transform:h}}function Su(){return C.useContext(Qo)}const wu="Droppable",Cu={timeout:25};function ku(e){let{data:t,disabled:r=!1,id:a,resizeObserverConfig:p}=e;const m=_r(wu),{active:v,dispatch:i,over:n,measureDroppableContainers:c}=C.useContext(Is),f=C.useRef({disabled:r}),l=C.useRef(!1),g=C.useRef(null),b=C.useRef(null),{disabled:y,updateMeasurementsFor:_,timeout:o}={...Cu,...p},h=js(_??a),d=C.useCallback(()=>{if(!l.current){l.current=!0;return}b.current!=null&&clearTimeout(b.current),b.current=setTimeout(()=>{c(Array.isArray(h.current)?h.current:[h.current]),b.current=null},o)},[o]),u=xr({callback:d,disabled:y||!v}),x=C.useCallback((w,j)=>{u&&(j&&(u.unobserve(j),l.current=!1),w&&u.observe(w))},[u]),[S,k]=tr(x),E=js(t);return C.useEffect(()=>{!u||!S.current||(u.disconnect(),l.current=!1,u.observe(S.current))},[S,u]),C.useEffect(()=>(i({type:at.RegisterDroppable,element:{id:a,key:m,disabled:r,node:S,rect:g,data:E}}),()=>i({type:at.UnregisterDroppable,key:m,id:a})),[a]),C.useEffect(()=>{r!==f.current.disabled&&(i({type:at.SetDroppableDisabled,id:a,key:m,disabled:r}),f.current.disabled=r)},[a,m,r,i]),{active:v,rect:g,isOver:n?.id===a,node:S,over:n,setNodeRef:k}}function Eu(e){let{animation:t,children:r}=e;const[a,p]=C.useState(null),[m,v]=C.useState(null),i=sr(r);return!r&&!a&&i&&p(i),Rt(()=>{if(!m)return;const n=a?.key,c=a?.props.id;if(n==null||c==null){p(null);return}Promise.resolve(t(c,m)).then(()=>{p(null)})},[t,a,m]),ie.createElement(ie.Fragment,null,r,a?C.cloneElement(a,{ref:v}):null)}const ju={x:0,y:0,scaleX:1,scaleY:1};function Nu(e){let{children:t}=e;return ie.createElement(Is.Provider,{value:Go},ie.createElement(br.Provider,{value:ju},t))}const Au={position:"fixed",touchAction:"none"},Ru=e=>Mi(e)?"transform 250ms ease":void 0,Tu=C.forwardRef((e,t)=>{let{as:r,activatorEvent:a,adjustScale:p,children:m,className:v,rect:i,style:n,transform:c,transition:f=Ru}=e;if(!i)return null;const l=p?c:{...c,scaleX:1,scaleY:1},g={...Au,width:i.width,height:i.height,top:i.top,left:i.left,transform:Ns.Transform.toString(l),transformOrigin:p&&a?Sd(a,i):void 0,transition:typeof f=="function"?f(a):f,...n};return ie.createElement(r,{className:v,style:g,ref:t},m)}),Mu=e=>t=>{let{active:r,dragOverlay:a}=t;const p={},{styles:m,className:v}=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&&a.node.style.setProperty(i,n);return v!=null&&v.active&&r.node.classList.add(v.active),v!=null&&v.dragOverlay&&a.node.classList.add(v.dragOverlay),function(){for(const[n,c]of Object.entries(p))r.node.style.setProperty(n,c);v!=null&&v.active&&r.node.classList.remove(v.active)}},Du=e=>{let{transform:{initial:t,final:r}}=e;return[{transform:Ns.Transform.toString(t)},{transform:Ns.Transform.toString(r)}]},Lu={duration:250,easing:"ease",keyframes:Du,sideEffects:Mu({styles:{active:{opacity:"0"}}})};function Pu(e){let{config:t,draggableNodes:r,droppableContainers:a,measuringConfiguration:p}=e;return vr((m,v)=>{if(t===null)return;const i=r.get(m);if(!i)return;const n=i.node.current;if(!n)return;const c=Yo(v);if(!c)return;const{transform:f}=gt(v).getComputedStyle(v),l=Bo(f);if(!l)return;const g=typeof t=="function"?t:Ou(t);return qo(n,p.draggable.measure),g({active:{id:m,data:i.data,node:n,rect:p.draggable.measure(n)},draggableNodes:r,dragOverlay:{node:v,rect:p.dragOverlay.measure(c)},droppableContainers:a,measuringConfiguration:p,transform:l})})}function Ou(e){const{duration:t,easing:r,sideEffects:a,keyframes:p}={...Lu,...e};return m=>{let{active:v,dragOverlay:i,transform:n,...c}=m;if(!t)return;const f={x:i.rect.left-v.rect.left,y:i.rect.top-v.rect.top},l={scaleX:n.scaleX!==1?v.rect.width*n.scaleX/i.rect.width:1,scaleY:n.scaleY!==1?v.rect.height*n.scaleY/i.rect.height:1},g={x:n.x-f.x,y:n.y-f.y,...l},b=p({...c,active:v,dragOverlay:i,transform:{initial:n,final:g}}),[y]=b,_=b[b.length-1];if(JSON.stringify(y)===JSON.stringify(_))return;const o=a?.({active:v,dragOverlay:i,...c}),h=i.node.animate(b,{duration:t,easing:r,fill:"forwards"});return new Promise(d=>{h.onfinish=()=>{o?.(),d()}})}}let jn=0;function Iu(e){return C.useMemo(()=>{if(e!=null)return jn++,jn},[e])}const Bu=ie.memo(e=>{let{adjustScale:t=!1,children:r,dropAnimation:a,style:p,transition:m,modifiers:v,wrapperElement:i="div",className:n,zIndex:c=999}=e;const{activatorEvent:f,active:l,activeNodeRect:g,containerNodeRect:b,draggableNodes:y,droppableContainers:_,dragOverlay:o,over:h,measuringConfiguration:d,scrollableAncestors:u,scrollableAncestorRects:x,windowRect:S}=Su(),k=C.useContext(br),E=Iu(l?.id),w=Zo(v,{activatorEvent:f,active:l,activeNodeRect:g,containerNodeRect:b,draggingNodeRect:o.rect,over:h,overlayNodeRect:o.rect,scrollableAncestors:u,scrollableAncestorRects:x,transform:k,windowRect:S}),j=Ii(g),R=Pu({config:a,draggableNodes:y,droppableContainers:_,measuringConfiguration:d}),L=j?o.setRef:void 0;return ie.createElement(Nu,null,ie.createElement(Eu,{animation:R},l&&E?ie.createElement(Tu,{key:E,id:l.id,ref:L,as:i,activatorEvent:f,adjustScale:t,className:n,transition:m,rect:j,style:{zIndex:c,...p},transform:w},r):null))}),Jo=768;function Fu(e){const t=window.matchMedia(`(max-width: ${Jo-1}px)`);return t.addEventListener("change",e),()=>t.removeEventListener("change",e)}function zu(){return window.innerWidth<Jo}function Hu(){return!1}function ea(){return C.useSyncExternalStore(Fu,zu,Hu)}const ge={Review:"Review",Running:"Running",Pending:"Pending",Done:"Done",Cancelled:"Cancelled"},Wu=[{status:ge.Review,label:"Review",icon:fi,color:"text-amber-600"},{status:ge.Running,label:"Running",icon:mi,color:"text-blue-600"},{status:ge.Pending,label:"Pending",icon:pi,color:"text-neutral-600"},{status:ge.Done,label:"Done",icon:gi,color:"text-emerald-600"},{status:ge.Cancelled,label:"Cancelled",icon:vi,color:"text-neutral-500"}];function $u({task:e,status:t,isSelected:r,isAgentActive:a,project:p,onSelectTask:m,onTaskStatusChange:v,onDeleteTask:i,disableDrag:n}){const{t:c}=ne(),f=!!e.projectArchivedAt,l=f||!!n,{attributes:g,listeners:b,setNodeRef:y,isDragging:_}=yu({id:e.id,data:{task:e,fromStatus:t},disabled:l}),[o,h]=C.useState(null),d=C.useRef(null),u=C.useRef(null),x=C.useCallback(E=>{f||!v&&!i||(E.preventDefault(),h({x:E.clientX,y:E.clientY}))},[f,v,i]),S=C.useCallback(()=>{u.current&&(clearTimeout(u.current),u.current=null)},[]),k=C.useCallback(E=>{if(!n||f||!v&&!i)return;const w=E.touches[0];if(!w)return;const{clientX:j,clientY:R}=w;u.current=setTimeout(()=>{u.current=null,h({x:j,y:R})},500)},[n,f,v,i]);return C.useEffect(()=>{if(!o)return;const E=w=>{d.current&&!d.current.contains(w.target)&&h(null)};return document.addEventListener("mousedown",E),document.addEventListener("touchstart",E),()=>{document.removeEventListener("mousedown",E),document.removeEventListener("touchstart",E)}},[o]),s.jsxs(s.Fragment,{children:[s.jsxs("button",{ref:y,onClick:()=>m(e.id),onContextMenu:x,onTouchStart:k,onTouchEnd:S,onTouchMove:S,className:`flex items-start pl-7 pr-4 py-2 text-sm w-full text-left transition-all border-l-2 group
7
+ ${_?"opacity-30":""}
8
+ ${r?"bg-neutral-100 border-neutral-800":"border-transparent hover:bg-neutral-50 hover:border-neutral-200"}`,...l?{}:b,...l?{}:g,children:[s.jsxs("div",{className:`mt-0.5 mr-3 flex-shrink-0 ${t===ge.Running?"text-blue-600":"text-neutral-500"}`,children:[t===ge.Review&&s.jsx(fi,{className:r?"text-amber-600":"text-neutral-500"}),t===ge.Running&&s.jsx(mi,{className:"animate-pulse"}),t===ge.Pending&&s.jsx(pi,{}),t===ge.Done&&s.jsx(gi,{className:"text-neutral-400"}),t===ge.Cancelled&&s.jsx(vi,{className:"text-neutral-400"})]}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"mb-0.5",children:[s.jsx("span",{className:`font-medium mr-1 ${p?.color||"text-neutral-500"}`,children:p?.name}),s.jsx("span",{className:"text-neutral-400",children:"/"}),s.jsx("span",{className:`ml-1 ${r?"text-neutral-900":"text-neutral-700"}`,children:e.title}),e.projectArchivedAt&&s.jsx("span",{className:"ml-1.5 inline-flex items-center rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?c("源码已删除"):c("已删除")}),a&&s.jsxs("span",{className:"relative inline-flex h-2 w-2 ml-1.5 align-middle",children:[s.jsx("span",{className:"animate-ping absolute inline-flex h-full w-full rounded-full bg-emerald-400 opacity-75"}),s.jsx("span",{className:"relative inline-flex rounded-full h-2 w-2 bg-emerald-500"})]})]}),s.jsx("p",{className:`text-xs line-clamp-2 leading-relaxed ${r?"text-neutral-500":"text-neutral-400 group-hover:text-neutral-500"}`,children:e.description})]})]}),o&&s.jsxs("div",{ref:d,className:"fixed z-[100] w-44 bg-white rounded-lg border border-neutral-200 shadow-xl py-1 animate-in fade-in zoom-in-95 duration-100",style:{left:o.x,top:o.y},children:[v&&s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:c("Move to")}),Wu.filter(E=>E.status!==t).map(E=>{const w=E.icon;return s.jsxs("button",{onClick:()=>{v(e.id,E.status),h(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs hover:bg-neutral-50 transition-colors",children:[s.jsx(w,{className:`w-3.5 h-3.5 ${E.color}`}),s.jsx("span",{className:"text-neutral-700",children:c(E.label)})]},E.status)})]}),i&&s.jsxs(s.Fragment,{children:[v&&s.jsx("div",{className:"my-1 border-t border-neutral-100"}),s.jsxs("button",{onClick:()=>{i(e.id),h(null)},className:"w-full flex items-center gap-2 px-3 py-2 text-xs text-red-600 hover:bg-red-50 transition-colors",children:[s.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",className:"w-3.5 h-3.5",children:[s.jsx("path",{d:"M3 6h18"}),s.jsx("path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6"}),s.jsx("path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2"})]}),s.jsx("span",{children:c("Delete Task")})]})]})]})]})}const Uu=C.memo(function({title:t,tasks:r,status:a,defaultOpen:p,selectedTaskId:m,onSelectTask:v,projects:i,activeTaskIds:n,isDragging:c,dragFromStatus:f,onTaskStatusChange:l,onDeleteTask:g,disableDrag:b}){const{t:y}=ne(),[_,o]=C.useState(p),h=r.length===0,d=c&&f===a,u=c&&f!==a,{setNodeRef:x,isOver:S}=ku({id:`group-${a}`,data:{status:a}}),k=a===ge.Review,E=y(t),w=c?d&&(_||!0):_;return s.jsxs("div",{className:"mb-2",children:[s.jsxs("button",{onClick:()=>!c&&o(j=>!j),className:"flex items-center w-full px-4 py-2 text-sm font-medium text-neutral-600 hover:text-neutral-900 hover:bg-neutral-50 transition-colors",children:[s.jsx("span",{className:"mr-2 text-neutral-400",children:w?s.jsx(_t,{size:14}):s.jsx(Tt,{size:14})}),s.jsx("span",{className:"flex-1 text-left",children:E}),k&&!h?s.jsx("span",{className:"px-2 py-0.5 bg-amber-100 text-amber-700 text-xs font-bold rounded-full animate-hop",children:r.length}):s.jsxs("span",{className:"text-xs text-neutral-400 font-normal",children:["(",r.length,")"]})]}),u&&s.jsx("div",{ref:x,className:`mx-3 my-1 flex items-center justify-center rounded-lg border-2 border-dashed transition-all duration-150 h-10
9
+ ${S?"border-blue-400 bg-blue-50 text-blue-600":"border-neutral-300 bg-neutral-50/50 text-neutral-400"}`,children:s.jsx("span",{className:"text-xs font-medium",children:S?y("Drop into {title}",{title:E}):y("Drop here")})}),w&&!u&&s.jsx("div",{ref:d?void 0:x,className:`flex flex-col mt-1 min-h-[40px] rounded-md mx-2 transition-colors
10
+ ${S&&!d?"bg-blue-50 ring-1 ring-blue-200":""}
11
+ ${h&&c?"border border-dashed border-neutral-300":""}`,children:h?s.jsx("span",{className:"text-xs text-neutral-300 py-2 pl-7",children:y("No tasks")}):r.map(j=>{const R=i.find(N=>N.id===j.projectId),L=m===j.id,D=n?.has(j.id)??!1;return s.jsx($u,{task:j,status:a,isSelected:L,isAgentActive:D,project:R,onSelectTask:v,onTaskStatusChange:j.projectArchivedAt?void 0:l,onDeleteTask:j.projectArchivedAt?void 0:g,disableDrag:b},j.id)})})]})});function qu(e){const t={[ge.Review]:[],[ge.Running]:[],[ge.Pending]:[],[ge.Done]:[],[ge.Cancelled]:[]};for(const r of e)t[r.status].push(r);return t}const Ku=[{status:ge.Review,title:"Review",defaultOpen:!0},{status:ge.Running,title:"Running",defaultOpen:!0},{status:ge.Pending,title:"Pending",defaultOpen:!1},{status:ge.Done,title:"Done",defaultOpen:!1},{status:ge.Cancelled,title:"Cancelled",defaultOpen:!1}];function Nn({tasks:e=[],projects:t=[],selectedTaskId:r,onSelectTask:a,filterProjectId:p,setFilterProjectId:m,width:v=320,onCreateProject:i,onCreateTask:n,activeTaskIds:c,onTaskStatusChange:f,onDeleteTask:l}){const{t:g}=ne(),b=ea(),[y,_]=C.useState(!1),[o,h]=C.useState(null),[d,u]=C.useState(null),x=yd(bd(Oi,{activationConstraint:{distance:8}})),S=C.useCallback(M=>{const O=M.active.data.current?.task,F=M.active.data.current?.fromStatus;O&&h(O),F&&u(F)},[]),k=C.useCallback(M=>{h(null),u(null);const{active:O,over:F}=M;if(!F)return;const z=O.data.current?.task,A=O.data.current?.fromStatus,P=F.data.current?.status;!z||!A||!P||z.projectArchivedAt||A!==P&&f?.(z.id,P)},[f]),E=p?e.filter(M=>M.projectId===p):e,w=p?t.find(M=>M.id===p)??null:null,j=t.filter(M=>!M.archivedAt),L=!!!w?.archivedAt,D=qu(E),N=v==="100%";return s.jsxs("div",{className:`h-full flex flex-col bg-white flex-shrink-0 ${N?"":"border-r border-neutral-200"}`,style:{width:v},children:[s.jsxs("div",{className:"h-14 flex items-center justify-between px-3 border-b border-neutral-100 flex-shrink-0 relative z-20",children:[s.jsxs("div",{className:"relative flex-1 mr-2",children:[s.jsxs("button",{onClick:()=>_(M=>!M),className:"flex items-center gap-2 px-2 py-1.5 rounded-md text-sm font-semibold text-neutral-900 hover:bg-neutral-100 transition-colors w-full text-left group",children:[p&&w?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:`w-2 h-2 rounded-full flex-shrink-0 ${w.color.replace("text-","bg-")}`}),s.jsx("span",{className:"truncate",children:w.name})]}):s.jsxs(s.Fragment,{children:[s.jsx(ds,{size:16,className:"text-neutral-500 group-hover:text-neutral-800"}),s.jsx("span",{children:g("All Projects")})]}),s.jsx(_t,{size:14,className:`text-neutral-400 ml-auto transition-transform duration-200 ${y?"rotate-180":""}`})]}),y?s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-30",onClick:()=>_(!1)}),s.jsxs("div",{className:"absolute left-0 top-full mt-1 w-56 bg-white border border-neutral-200 rounded-lg shadow-xl shadow-neutral-200/50 z-40 py-1 animate-in fade-in zoom-in-95 duration-100 origin-top-left",children:[s.jsx("div",{className:"px-3 py-2 text-[10px] font-semibold text-neutral-400 uppercase tracking-wider",children:g("Select View")}),s.jsxs("button",{onClick:()=>{m(null),_(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors group",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"w-5 h-5 flex items-center justify-center rounded border border-neutral-200 bg-neutral-50 text-neutral-500 group-hover:border-neutral-300",children:s.jsx(ds,{size:12})}),s.jsx("span",{className:p===null?"text-neutral-900 font-medium":"text-neutral-600",children:g("All Projects")})]}),p===null?s.jsx(At,{size:14,className:"text-neutral-900"}):null]}),s.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),j.map(M=>{const O=p===M.id,F=M.color.replace("text-","bg-");return s.jsxs("button",{onClick:()=>{m(M.id),_(!1)},className:"w-full text-left px-3 py-2 text-xs flex items-center justify-between hover:bg-neutral-50 transition-colors",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:`w-2 h-2 rounded-full ml-1.5 mr-1.5 ${F}`}),s.jsx("span",{className:O?"text-neutral-900 font-medium":"text-neutral-600",children:M.name})]}),O?s.jsx(At,{size:14,className:"text-neutral-900"}):null]},M.id)}),s.jsx("div",{className:"h-px bg-neutral-100 my-1 mx-2"}),s.jsxs("button",{onClick:()=>{_(!1),i?.()},className:"w-full text-left px-3 py-2 text-xs flex items-center gap-2 text-neutral-500 hover:text-neutral-900 hover:bg-neutral-50 transition-colors",children:[s.jsx(as,{size:14}),s.jsx("span",{children:g("Create New Project...")})]})]})]}):null]}),s.jsx("button",{onClick:n,disabled:!L,className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors flex-shrink-0 disabled:opacity-30 disabled:cursor-not-allowed",title:g(L?"New Task":"Deleted projects are read-only"),children:s.jsx(as,{size:18})})]}),s.jsxs(_u,{sensors:x,onDragStart:S,onDragEnd:k,children:[s.jsx("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin py-4 relative",children:Ku.map(({status:M,title:O,defaultOpen:F})=>s.jsx(Uu,{title:O,tasks:D[M],status:M,defaultOpen:F,selectedTaskId:r,onSelectTask:a,projects:t,activeTaskIds:c,isDragging:o!==null,dragFromStatus:d,onTaskStatusChange:f,onDeleteTask:l,disableDrag:b},M))}),s.jsx(Bu,{dropAnimation:null,children:o?s.jsx("div",{className:"bg-white shadow-lg rounded-md border border-neutral-200 px-4 py-2 text-sm max-w-[280px] opacity-90",children:s.jsx("span",{className:"text-neutral-700 font-medium",children:o.title})}):null})]}),E.length>0?s.jsxs("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:[s.jsx("span",{children:g("{count} tasks",{count:E.length})}),p?s.jsx("button",{onClick:()=>m(null),className:"hover:text-neutral-800 underline decoration-neutral-300 underline-offset-2",children:g("Clear filter")}):null]}):s.jsx("div",{className:"p-4 border-t border-neutral-100 text-xs text-neutral-400 flex items-center justify-between",children:s.jsx("span",{children:g("{count} tasks",{count:0})})})]})}const Xu={damping:.7,stiffness:.05,mass:1.25},Vu=70,Yu=1e3/60,Gu=350;let yr=!1;globalThis.document?.addEventListener("mousedown",()=>{yr=!0});globalThis.document?.addEventListener("mouseup",()=>{yr=!1});globalThis.document?.addEventListener("click",()=>{yr=!1});const Bi=(e={})=>{const[t,r]=C.useState(!1),[a,p]=C.useState(e.initial!==!1),[m,v]=C.useState(!1),i=C.useRef(null);i.current=e;const n=C.useCallback(()=>{if(!yr)return!1;const d=window.getSelection();if(!d||!d.rangeCount)return!1;const u=d.getRangeAt(0);return u.commonAncestorContainer.contains(o.current)||o.current?.contains(u.commonAncestorContainer)},[]),c=C.useCallback(d=>{l.isAtBottom=d,p(d)},[]),f=C.useCallback(d=>{l.escapedFromLock=d,r(d)},[]),l=C.useMemo(()=>{let d;return{escapedFromLock:t,isAtBottom:a,resizeDifference:0,accumulated:0,velocity:0,listeners:new Set,get scrollTop(){return o.current?.scrollTop??0},set scrollTop(u){o.current&&(o.current.scrollTop=u,l.ignoreScrollToTop=o.current.scrollTop)},get targetScrollTop(){return!o.current||!h.current?0:o.current.scrollHeight-1-o.current.clientHeight},get calculatedTargetScrollTop(){if(!o.current||!h.current)return 0;const{targetScrollTop:u}=this;if(!e.targetScrollTop)return u;if(d?.targetScrollTop===u)return d.calculatedScrollTop;const x=Math.max(Math.min(e.targetScrollTop(u,{scrollElement:o.current,contentElement:h.current}),u),0);return d={targetScrollTop:u,calculatedScrollTop:x},requestAnimationFrame(()=>{d=void 0}),x},get scrollDifference(){return this.calculatedTargetScrollTop-this.scrollTop},get isNearBottom(){return this.scrollDifference<=Vu}}},[]),g=C.useCallback((d={})=>{typeof d=="string"&&(d={animation:d}),d.preserveScrollPosition||c(!0);const u=Date.now()+(Number(d.wait)||0),x=zr(i.current,d.animation),{ignoreEscapes:S=!1}=d;let k,E=l.calculatedTargetScrollTop;d.duration instanceof Promise?d.duration.finally(()=>{k=Date.now()}):k=u+(d.duration??0);const w=async()=>{const j=new Promise(requestAnimationFrame).then(()=>{if(!l.isAtBottom)return l.animation=void 0,!1;const{scrollTop:R}=l,L=performance.now(),D=(L-(l.lastTick??L))/Yu;if(l.animation||(l.animation={behavior:x,promise:j,ignoreEscapes:S}),l.animation.behavior===x&&(l.lastTick=L),n()||u>Date.now())return w();if(R<Math.min(E,l.calculatedTargetScrollTop)){if(l.animation?.behavior===x){if(x==="instant")return l.scrollTop=l.calculatedTargetScrollTop,w();l.velocity=(x.damping*l.velocity+x.stiffness*l.scrollDifference)/x.mass,l.accumulated+=l.velocity*D,l.scrollTop+=l.accumulated,l.scrollTop!==R&&(l.accumulated=0)}return w()}return k>Date.now()?(E=l.calculatedTargetScrollTop,w()):(l.animation=void 0,l.scrollTop<l.calculatedTargetScrollTop?g({animation:zr(i.current,i.current.resize),ignoreEscapes:S,duration:Math.max(0,k-Date.now())||void 0}):l.isAtBottom)});return j.then(R=>(requestAnimationFrame(()=>{l.animation||(l.lastTick=void 0,l.velocity=0)}),R))};return d.wait!==!0&&(l.animation=void 0),l.animation?.behavior===x?l.animation.promise:w()},[c,n,l]),b=C.useCallback(()=>{f(!0),c(!1)},[f,c]),y=C.useCallback(({target:d})=>{if(d!==o.current)return;const{scrollTop:u,ignoreScrollToTop:x}=l;let{lastScrollTop:S=u}=l;l.lastScrollTop=u,l.ignoreScrollToTop=void 0,x&&x>u&&(S=x),v(l.isNearBottom),setTimeout(()=>{if(l.resizeDifference||u===x)return;if(n()){f(!0),c(!1);return}const k=u>S,E=u<S;if(l.animation?.ignoreEscapes){l.scrollTop=S;return}E&&(f(!0),c(!1)),k&&f(!1),!l.escapedFromLock&&l.isNearBottom&&c(!0)},1)},[f,c,n,l]),_=C.useCallback(({target:d,deltaY:u})=>{let x=d;for(;!["scroll","auto"].includes(getComputedStyle(x).overflow);){if(!x.parentElement)return;x=x.parentElement}x===o.current&&u<0&&o.current.scrollHeight>o.current.clientHeight&&!l.animation?.ignoreEscapes&&(f(!0),c(!1))},[f,c,l]),o=An(d=>{o.current?.removeEventListener("scroll",y),o.current?.removeEventListener("wheel",_),d?.addEventListener("scroll",y,{passive:!0}),d?.addEventListener("wheel",_,{passive:!0})},[]),h=An(d=>{if(l.resizeObserver?.disconnect(),!d)return;let u;l.resizeObserver=new ResizeObserver(([x])=>{const{height:S}=x.contentRect,k=S-(u??S);if(l.resizeDifference=k,l.scrollTop>l.targetScrollTop&&(l.scrollTop=l.targetScrollTop),v(l.isNearBottom),k>=0){const E=zr(i.current,u?i.current.resize:i.current.initial);g({animation:E,wait:!0,preserveScrollPosition:!0,duration:E==="instant"?void 0:Gu})}else l.isNearBottom&&(f(!1),c(!0));u=S,requestAnimationFrame(()=>{setTimeout(()=>{l.resizeDifference===k&&(l.resizeDifference=0)},1)})}),l.resizeObserver?.observe(d)},[]);return{contentRef:h,scrollRef:o,scrollToBottom:g,stopScroll:b,isAtBottom:a||m,isNearBottom:m,escapedFromLock:t,state:l}};function An(e,t){const r=C.useCallback(a=>(r.current=a,e(a)),t);return r}const Fr=new Map;function zr(...e){const t={...Xu};let r=!1;for(const p of e){if(p==="instant"){r=!0;continue}typeof p=="object"&&(r=!1,t.damping=p.damping??t.damping,t.stiffness=p.stiffness??t.stiffness,t.mass=p.mass??t.mass)}const a=JSON.stringify(t);return Fr.has(a)||Fr.set(a,Object.freeze(t)),r?"instant":Fr.get(a)}function Qu({content:e,children:t,className:r=""}){return s.jsxs("div",{className:`group/tooltip relative ${r}`,children:[t,s.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-3 py-2 bg-neutral-900 text-white text-xs rounded-lg opacity-0 group-hover/tooltip:opacity-100 transition-opacity pointer-events-none whitespace-nowrap z-50 shadow-lg",children:[e,s.jsx("div",{className:"absolute top-full left-1/2 -translate-x-1/2 border-4 border-transparent border-t-neutral-900"})]})]})}function $s(e){return e>=1e6?`${(e/1e6).toFixed(1)}M`:e>=1e3?`${(e/1e3).toFixed(1)}K`:e.toString()}function Zu(e){return e>=.9?"text-red-500":e>=.7?"text-amber-500":"text-neutral-400"}function ta({usage:e}){const{t}=ne();if(!e)return null;const r=e.modelContextWindow,a=r?e.totalTokens/r:0,p=r?Math.min(Math.round(a*100),100):null,m=r?Zu(a):"text-neutral-400",v=r?s.jsx("span",{children:t("上下文: {used} / {max} tokens",{used:$s(e.totalTokens),max:$s(r)})}):s.jsx("span",{children:t("已使用: {used} tokens",{used:$s(e.totalTokens)})});return s.jsx(Qu,{content:v,children:s.jsxs("div",{className:"flex items-center gap-1.5 px-2 py-1.5 text-xs rounded-lg hover:bg-neutral-100 transition-colors cursor-default select-none",children:[s.jsx(Ac,{size:14,className:m}),s.jsxs("span",{className:`tabular-nums ${m}`,children:[$s(e.totalTokens),p!==null&&s.jsxs("span",{className:"text-neutral-300 ml-0.5",children:["/ ",p,"%"]})]})]})})}const Ju="/api";async function eh(e){const t=new FormData;t.append("file",e);const r=await fetch(`${Ju}/attachments/upload`,{method:"POST",body:t});if(!r.ok){const a=await r.json().catch(()=>({}));throw new Error(a.error||`Upload failed (${r.status})`)}return r.json()}let th=0;function Sr(){const[e,t]=C.useState([]),r=C.useRef(e);r.current=e;const a=C.useCallback(async l=>{const g=l.map(b=>({tempId:`tmp-${++th}`,file:b,progress:0,status:"uploading"}));t(b=>[...b,...g]),await Promise.allSettled(g.map(async b=>{try{const y=await eh(b.file);t(_=>_.map(o=>o.tempId===b.tempId?{...o,status:"done",progress:100,attachment:y}:o))}catch(y){t(_=>_.map(o=>o.tempId===b.tempId?{...o,status:"error",error:y instanceof Error?y.message:"Upload failed"}:o))}}))},[]),p=C.useCallback(()=>r.current.filter(l=>l.status==="done"&&l.attachment).map(l=>l.attachment),[]),m=C.useCallback(l=>{t(g=>g.filter(b=>b.tempId!==l))},[]),v=C.useCallback(()=>{t([])},[]),i=C.useCallback(l=>{l.length!==0&&t(g=>{const b=new Set(g.map(_=>_.attachment?.id??_.tempId)),y=l.filter(_=>{const o=_.attachment?.id??_.tempId;return b.has(o)?!1:(b.add(o),!0)});return y.length>0?[...g,...y]:g})},[]),n=C.useCallback(()=>{const l=p();return l.length===0?"":l.map(g=>`${g.mimeType.startsWith("image/")?"!":""}[${g.originalName}](${g.storagePath})`).join(`
12
+ `)},[p]),c=e.length>0,f=e.some(l=>l.status==="uploading");return{files:e,addFiles:a,removeFile:m,clear:v,restoreFiles:i,buildMarkdownLinks:n,getDoneAttachments:p,hasFiles:c,isUploading:f}}function sh(e){const t=C.useMemo(()=>Array.from(new Set(e.filter(Boolean))),[e]);return vt({queryKey:["attachments","metadata",t],queryFn:()=>me.get("/attachments/metadata",{params:{ids:t.join(",")}}),enabled:t.length>0,staleTime:300*1e3})}const rh="/api";function ih(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function wr({files:e,onRemove:t}){return e.length===0?null:s.jsx("div",{"aria-label":"Attachments",className:"flex flex-wrap gap-2 px-4 pt-3 pb-1",children:e.map(r=>s.jsx(nh,{item:r,onRemove:t},r.tempId))})}function nh({item:e,onRemove:t}){const r=e.file.type.startsWith("image/"),a=e.status==="error",p=e.status==="uploading";return s.jsxs("div",{className:`relative group flex items-center gap-2 px-3 py-2 rounded-lg border text-xs max-w-[200px] ${a?"border-red-200 bg-red-50 text-red-600":"border-neutral-200 bg-neutral-50 text-neutral-700"}`,children:[r&&e.status==="done"&&e.attachment?s.jsx("img",{src:`${rh}${e.attachment.url}`,alt:e.file.name,className:"w-8 h-8 rounded object-cover flex-shrink-0"}):s.jsx("span",{className:"flex-shrink-0",children:p?s.jsx(Ke,{size:16,className:"animate-spin text-neutral-400"}):r?s.jsx(Ni,{size:16,className:"text-neutral-400"}):s.jsx(ki,{size:16,className:"text-neutral-400"})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate font-medium",children:e.file.name}),a?s.jsx("div",{className:"truncate text-red-500",children:e.error}):s.jsx("div",{className:"text-neutral-400",children:ih(e.file.size)})]}),s.jsx("button",{onClick:()=>t(e.tempId),className:"absolute -top-1.5 -right-1.5 hidden group-hover:flex items-center justify-center w-5 h-5 rounded-full bg-neutral-700 text-white hover:bg-neutral-900 transition-colors",children:s.jsx(Ht,{size:10})})]})}const oh=10,ah=24,sa=oh*ah,lh=8;function ch(e,t=sa){return e>t+lh}function dh(e,t){return e.includes(t)?e:[...e,t]}function uh(e,t){return e.filter(r=>r!==t)}function hh(e,t){const r=new Map(t.map(a=>[a.id,a]));return e.map(a=>r.get(a)).filter(a=>!!a).map(a=>({memberId:a.id,label:a.name}))}const Rs=new Set(["RUNNING","WAITING_ROOM_REPLY","QUEUED","SESSION_ENDED"]);function Rn(e){if(!e)return 0;const t=Date.parse(e);return Number.isNaN(t)?0:t}function fh(e,t=[],r=[]){const a=new Set(r.filter(m=>Rs.has(m.status)).map(m=>m.workRequestId));return[...e.map(m=>({kind:"message",key:`message:${m.id}`,sortTime:m.createdAt,order:0,message:m})),...t.filter(m=>m.status==="PENDING_APPROVAL").filter(m=>!a.has(m.id)).map(m=>({kind:"pendingApproval",key:`pending-approval:${m.id}`,sortTime:m.updatedAt??m.createdAt,order:1,request:m}))].sort((m,v)=>{const i=Rn(m.sortTime)-Rn(v.sortTime);return i!==0?i:m.order!==v.order?m.order-v.order:m.key.localeCompare(v.key)})}function mh(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 ph(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 gh(e,t){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 v=r[p];return v?`${v} ${t(m)}`:null}).filter(p=>!!p).join(" · ")}function vh(){return typeof window>"u"||typeof window.matchMedia!="function"?!1:window.matchMedia("(min-width: 768px)").matches}function _h({status:e}){const{t}=ne();return e==="RUNNING"?s.jsxs(s.Fragment,{children:[t("Working"),s.jsxs("span",{className:"active-work-dots","aria-hidden":"true",children:[s.jsx("span",{children:"."}),s.jsx("span",{className:"active-work-dots__second",children:"."}),s.jsx("span",{className:"active-work-dots__third",children:"."})]})]}):s.jsx(s.Fragment,{children:t(mh(e))})}function xh({invocations:e,memberById:t,workRequestById:r,onViewInvocationSession:a,onStopMember:p,isStopPending:m,stoppingMemberId:v,stopPromptInvocationId:i,onToggleStopConfirm:n}){const{t:c}=ne(),[f,l]=C.useState(vh),g=C.useMemo(()=>e.filter(y=>Rs.has(y.status)).sort((y,_)=>Date.parse(_.updatedAt??_.createdAt??"")-Date.parse(y.updatedAt??y.createdAt??"")),[e]);if(g.length===0)return null;const b=gh(g,c);return s.jsxs("div",{className:"border-t border-neutral-200 bg-neutral-50/80",children:[s.jsxs("button",{type:"button",onClick:()=>l(y=>!y),"aria-expanded":f,className:"flex h-8 w-full items-center justify-between gap-3 px-3 text-left text-xs text-neutral-600 transition-colors hover:bg-neutral-100",children:[s.jsxs("span",{className:"min-w-0 truncate",children:[s.jsx("span",{className:"font-medium text-neutral-800",children:c("Active work")}),s.jsx("span",{className:"mx-1.5 text-neutral-300",children:"·"}),s.jsx("span",{children:b})]}),f?s.jsx(_t,{size:15,className:"shrink-0 text-neutral-400"}):s.jsx(yi,{size:15,className:"shrink-0 text-neutral-400"})]}),f&&s.jsx("div",{className:"max-h-32 overflow-y-auto border-t border-neutral-200",children:g.map(y=>{const _=t.get(y.memberId),o=r.get(y.workRequestId),h=!!(y.sessionId&&a),d=!!_,u=i===y.id,x=m&&v===y.memberId,S=o?.instruction??y.workRequestId;return s.jsxs("div",{className:"border-t border-neutral-100 first:border-t-0",children:[s.jsxs("div",{title:S,className:se("group flex h-8 items-center gap-2 px-3 text-xs text-neutral-700",h?"cursor-pointer hover:bg-white":"cursor-default"),role:h?"button":void 0,tabIndex:h?0:void 0,onClick:()=>y.sessionId&&a?.(y.sessionId),onKeyDown:k=>{!h||!y.sessionId||(k.key==="Enter"||k.key===" ")&&(k.preventDefault(),a?.(y.sessionId))},children:[s.jsx(Xt,{name:_?.name??c("Agent"),avatar:_?.avatar??null,className:"h-4 w-4 text-[8px]"}),s.jsxs("div",{className:"flex min-w-0 flex-1 items-baseline gap-1.5",children:[s.jsx("span",{className:"truncate font-medium text-neutral-800",children:_?.name??c("Agent")}),s.jsx("span",{className:se("shrink-0",ph(y.status)),children:s.jsx(_h,{status:y.status})})]}),h&&s.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),y.sessionId&&a?.(y.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:c("View log"),"aria-label":`${c("View log")} ${_?.name??c("Agent")}`,children:s.jsx(Ai,{size:13})}),d&&s.jsx("button",{type:"button",onClick:k=>{k.stopPropagation(),n(y.id)},onKeyDown:k=>k.stopPropagation(),disabled:x,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:c("Stop"),"aria-label":`${c("Stop")} ${_?.name??c("Agent")}`,children:s.jsx(os,{size:12})})]}),d&&u&&_&&s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 border-t border-neutral-100 bg-white px-3 py-2",children:[s.jsx("span",{className:"mr-1 text-[11px] text-neutral-600",children:c("Stop running work?")}),s.jsxs(De,{type:"button",size:"xs",variant:"outline",disabled:x,onClick:()=>p(_.id,!1),children:[s.jsx(os,{size:11}),s.jsx("span",{children:c(x?"Stopping":"Stop only")})]}),s.jsxs(De,{type:"button",size:"xs",variant:"outline",disabled:x,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:()=>p(_.id,!0),children:[s.jsx(_s,{size:11}),s.jsx("span",{children:c(x?"Stopping":"Stop + clear queue")})]})]})]},y.id)})})]})}const ar="/api";let Tn=0;function bh(e,t){return Tn+=1,{id:`pending-room-message-${Date.now()}-${Tn}`,teamRunId:e,senderType:t.senderType??"user",senderId:t.senderId??null,senderInvocationId:t.senderInvocationId??null,kind:t.kind??((t.mentions?.length??0)>0?"work_request":"chat"),content:t.content,mentions:t.mentions??[],workRequestIds:[],artifactRefs:t.artifactRefs??[],attachmentIds:t.attachmentIds??[],createdAt:new Date().toISOString(),pendingStatus:"sending"}}function yh(e){return"pendingStatus"in e}const Sh=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${ar}/attachments/by-path?path=${encodeURIComponent(e)}`:e,wh=({src:e,alt:t,...r})=>s.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:s.jsx("img",{src:e,alt:t,...r,className:"max-w-[300px] max-h-[200px] object-contain rounded-lg border border-neutral-200 cursor-pointer hover:opacity-90 transition-opacity"})}),Ch={img:wh};function kh(e){return e<1024?`${e}B`:e<1024*1024?`${(e/1024).toFixed(1)}KB`:`${(e/(1024*1024)).toFixed(1)}MB`}function Eh(e){return`${e.mimeType.startsWith("image/")?"!":""}[${e.originalName}](${e.storagePath})`}function jh(e,t){if(t.length===0)return e;const r=new Set(t.map(Eh));return e.split(`
13
+ `).map(a=>{const p=a.match(/^\s*/)?.[0]??"",m=a.trimStart();for(const v of r){if(m===v)return null;if(m.startsWith(`${v} `)||m.startsWith(`${v} `))return`${p}${m.slice(v.length).trimStart()}`}return a}).filter(a=>a!=null).join(`
14
+ `).replace(/\n{3,}/g,`
15
+
16
+ `).trim()}function Nh(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}function Mn(e,t){return e instanceof Error?e.message:t}function Ah(e,t){const a=e.slice(0,t).match(/(^|\s)@([^\s@]*)$/);return!a||a.index==null?null:{start:a.index+a[1].length,end:t,query:a[2]??""}}function Rh(e,t){const r=t.trim().toLowerCase();return r?[e.name,e.providerId,...e.aliases??[]].some(p=>p.toLowerCase().includes(r)):!0}function Th(e,t){return e.label??t.get(e.memberId)?.name??e.memberId}function Mh(e,t){const r=e.mentions??[];if(r.length===0)return e.content;const a=r.map(m=>Th(m,t)).filter(m=>m&&!e.content.includes(`@${m}`));if(a.length===0)return e.content;const p=a.map(m=>`@${m}`).join(" ");return e.content.trimEnd()?`${e.content.trimEnd()} ${p}`:p}function Dh(e,t,r){if(e.senderType!=="agent")return null;if(e.senderId&&t.has(e.senderId))return t.get(e.senderId)??null;if(e.senderInvocationId){const a=r.get(e.senderInvocationId);if(a?.memberId&&t.has(a.memberId))return t.get(a.memberId)??null}return null}function Lh({content:e,isUser:t}){return s.jsx("div",{className:se("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",t?["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:s.jsx(_i,{urlTransform:Sh,components:Ch,children:e})})}function Ph({hasAttachmentIds:e,attachments:t,isLoading:r,onOpenImage:a}){if(!e)return null;if(r&&t.length===0)return s.jsx("div",{className:"mt-3 text-xs text-neutral-400",children:"Loading attachments..."});if(t.length===0)return null;const p=t.filter(v=>v.mimeType.startsWith("image/")),m=new Map(p.map((v,i)=>[v.id,i]));return s.jsx("div",{className:"mt-3 flex flex-wrap gap-2 text-neutral-700",children:t.map(v=>{const i=`${ar}${v.url}`;if(v.mimeType.startsWith("image/")){const c=m.get(v.id)??0;return s.jsxs("button",{type:"button",onClick:()=>a(p,c),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:v.originalName,children:[s.jsx("img",{src:i,alt:v.originalName,className:"h-full w-full object-cover",loading:"lazy"}),s.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:v.originalName})]},v.id)}return s.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:v.originalName,children:[s.jsx(ki,{size:16,className:"shrink-0 text-neutral-400","aria-hidden":!0}),s.jsxs("span",{className:"min-w-0 flex-1",children:[s.jsx("span",{className:"block truncate font-medium",children:v.originalName}),s.jsx("span",{className:"text-neutral-400",children:kh(v.sizeBytes)})]}),s.jsx(Ci,{size:13,className:"shrink-0 text-neutral-400","aria-hidden":!0})]},v.id)})})}function Oh({content:e,attachmentIds:t,isUser:r,tone:a,onOpenImage:p}){const m=C.useMemo(()=>Array.from(new Set(t??[])),[t]),{data:v=[],isLoading:i}=sh(m),n=v.length>0?jh(e,v):e;return s.jsxs(s.Fragment,{children:[n.trim()&&s.jsx(Fh,{content:n,isUser:r,tone:a}),s.jsx(Ph,{hasAttachmentIds:m.length>0,attachments:v,isLoading:i,onOpenImage:p})]})}function Ih({images:e,index:t,onClose:r,onSelect:a}){const p=e[t];if(!p)return null;const m=t>0,v=t<e.length-1;return s.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-black/80 p-4",role:"dialog","aria-modal":"true",children:[s.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:s.jsx(Ht,{size:20})}),m&&s.jsx("button",{type:"button",onClick:()=>a(t-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:s.jsx(mc,{size:24,"aria-hidden":!0})}),s.jsxs("div",{className:"flex max-h-full max-w-full flex-col items-center gap-3",children:[s.jsx("img",{src:`${ar}${p.url}`,alt:p.originalName,className:"max-h-[82vh] max-w-[92vw] rounded-lg object-contain"}),s.jsxs("div",{className:"flex items-center gap-3 text-sm text-white",children:[s.jsx("span",{className:"max-w-[70vw] truncate",children:p.originalName}),s.jsxs("a",{href:`${ar}${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:[s.jsx(Ci,{size:13,"aria-hidden":!0}),"Open"]})]})]}),v&&s.jsx("button",{type:"button",onClick:()=>a(t+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:s.jsx(Tt,{size:24,"aria-hidden":!0})})]})}function Bh({draft:e,attachmentMarkdown:t,attachmentIds:r,mentions:a}){const m=[e.trim(),t].filter(Boolean).join(`
17
+
18
+ `);return m?{content:m,mentions:a,senderType:"user",...r.length>0?{attachmentIds:r}:{}}:null}function Fh({content:e,isUser:t,tone:r=t?"user":"agent"}){const{t:a}=ne(),p=C.useId(),m=C.useRef(null),[v,i]=C.useState(null),[n,c]=C.useState(!1),f=v?.content===e&&v.expanded,l=C.useCallback(()=>{const b=m.current;b&&c(ch(b.scrollHeight))},[]);C.useLayoutEffect(()=>{l();const b=m.current;if(!b)return;const y=window.requestAnimationFrame(l),_=typeof ResizeObserver>"u"?null:new ResizeObserver(l);return _?.observe(b),window.addEventListener("resize",l),()=>{window.cancelAnimationFrame(y),_?.disconnect(),window.removeEventListener("resize",l)}},[e,l]);const g=n&&!f;return s.jsxs("div",{className:"relative",children:[s.jsxs("div",{id:p,ref:m,onLoadCapture:l,className:se("relative transition-[max-height] duration-200 ease-out",g?"overflow-hidden":""),style:g?{maxHeight:sa}:void 0,children:[s.jsx(Lh,{content:e,isUser:t}),g&&s.jsx("div",{className:se("pointer-events-none absolute inset-x-0 bottom-0 h-16 bg-gradient-to-b from-transparent",r==="system"?"to-amber-50":r==="user"?"to-neutral-900":"to-neutral-100")})]}),n&&s.jsxs("button",{type:"button","aria-expanded":f,"aria-controls":p,"aria-label":a(f?"Collapse message":"Expand full message"),onClick:()=>i({content:e,expanded:!f}),className:se("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",r==="system"?"bg-amber-100 text-amber-800 hover:bg-amber-200":r==="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"),children:[f?s.jsx(yi,{size:13}):s.jsx(_t,{size:13}),s.jsx("span",{children:a(f?"Collapse message":"Expand full message")})]})]})}function ra({senderName:e,avatar:t,createdAt:r,isUser:a,isSystem:p,children:m,headerAddon:v,bubbleClassName:i,isPending:n}){return p?s.jsx("div",{className:"flex justify-center",children:s.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})}):s.jsxs("div",{className:se("group flex items-start gap-3",a?"justify-end pl-8 sm:pl-14":"justify-start pr-8 sm:pr-14"),children:[!a&&s.jsx(Xt,{name:e,avatar:t??null,className:"mt-0.5 h-8 w-8 text-[11px]"}),s.jsxs("div",{className:se("flex min-w-0 max-w-[min(86%,46rem)] flex-col",a?"items-end":"items-start"),children:[s.jsxs("div",{className:se("mb-1.5 flex max-w-full items-center gap-1.5 px-0.5 text-[11px] text-neutral-500",a?"justify-end":"justify-start"),children:[s.jsx("span",{className:"truncate font-semibold text-neutral-700",children:e}),s.jsx("span",{className:"h-1 w-1 rounded-full bg-neutral-300","aria-hidden":!0}),s.jsx(ts,{size:11,className:"text-neutral-400"}),s.jsx("span",{className:"shrink-0",children:Nh(r)}),v]}),s.jsx("div",{className:se("max-w-full rounded-lg px-3.5 py-3 text-sm leading-6 transition-colors",a?"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})]}),a&&s.jsx(Xt,{name:e,avatar:null,className:"mt-0.5 h-8 w-8 border-neutral-300 bg-neutral-900 text-white text-[11px]"})]})}function zh({message:e,senderName:t,senderMember:r,displayContent:a,onOpenImage:p}){const{t:m}=ne(),v=e.senderType==="user",i=e.senderType==="system",n=yh(e)?e.pendingStatus:null,c=e.mentions??[],f=e.workRequestIds?.length??0,l=s.jsxs(s.Fragment,{children:[v&&f>0&&c.length===0&&s.jsxs("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-600",children:[m("Work requests"),": ",f]}),n==="sending"&&s.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-neutral-900/8 px-1.5 py-0.5 text-[10px] font-medium leading-none text-neutral-500",children:m("发送中...")}),n==="failed"&&s.jsx("span",{className:"ml-0.5 shrink-0 rounded-full bg-red-50 px-1.5 py-0.5 text-[10px] font-medium leading-none text-red-600",children:m("发送失败")})]});return s.jsxs(ra,{senderName:t,avatar:r?.avatar??null,createdAt:e.createdAt,isUser:v,isSystem:i,headerAddon:l,bubbleClassName:v&&n==="failed"?"border-red-200 bg-red-50 text-red-900":void 0,isPending:n==="sending",children:[s.jsx(Oh,{content:a,attachmentIds:e.attachmentIds,isUser:v&&n!=="failed",tone:i?"system":void 0,onOpenImage:p}),!v&&!i&&f>0&&c.length===0&&s.jsx("div",{className:"mt-2 flex flex-wrap gap-1.5",children:s.jsxs("span",{className:"rounded-full bg-blue-50 px-2 py-0.5 text-[11px] font-medium text-blue-700",children:[m("Work requests"),": ",f]})})]})}function Hh({request:e,member:t,onApprove:r,onReject:a,onCancel:p,isActionPending:m,isApprovePending:v,isRejectPending:i,isCancelPending:n}){const{t:c}=ne();return s.jsx(ra,{senderName:t?.name??c("Agent"),avatar:t?.avatar??null,createdAt:e.createdAt,bubbleClassName:"border border-amber-200/80 bg-amber-50/80",children:s.jsxs("div",{className:"space-y-2",children:[s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.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:[s.jsx(ts,{size:11}),c("Pending approval")]}),s.jsxs("span",{className:"text-[11px] text-neutral-500",children:[c("Requester"),": ",c(e.requesterType==="user"?"User":e.requesterType==="system"?"System":"Agent")]})]}),s.jsx("div",{className:"text-sm leading-6 text-neutral-800 [overflow-wrap:anywhere]",children:e.instruction}),s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5",children:[s.jsxs(De,{type:"button",size:"xs",variant:"outline",disabled:m,className:"border-emerald-200 bg-emerald-50 text-emerald-700 hover:bg-emerald-100 hover:text-emerald-800",onClick:r,children:[s.jsx(At,{size:12}),s.jsx("span",{children:c(v?"Approving":"Approve")})]}),s.jsxs(De,{type:"button",size:"xs",variant:"outline",disabled:m,onClick:a,children:[s.jsx(Ht,{size:12}),s.jsx("span",{children:c(i?"Rejecting":"Reject")})]}),s.jsxs(De,{type:"button",size:"xs",variant:"outline",disabled:m,className:"border-red-200 bg-red-50 text-red-700 hover:bg-red-100 hover:text-red-800",onClick:p,children:[s.jsx(_s,{size:12}),s.jsx("span",{children:c(n?"Cancelling":"Cancel")})]})]})]})})}function ia({teamRun:e,messages:t,readOnly:r,readOnlyMessage:a,onSendMessage:p,onViewInvocationSession:m,compactComposer:v}){const{t:i}=ne(),n=bo(e.id),c=yo(e.id),f=ti(e.id),l=So(e.id),[g,b]=C.useState(""),[y,_]=C.useState(!1),[o,h]=C.useState(null),[d,u]=C.useState(0),[x,S]=C.useState([]),[k,E]=C.useState(!1),[w,j]=C.useState(null),[R,L]=C.useState([]),[D,N]=C.useState(null),M=C.useRef(null),O=C.useRef(null),{files:F,addFiles:z,removeFile:A,clear:P,restoreFiles:I,buildMarkdownLinks:B,getDoneAttachments:$,isUploading:X}=Sr(),Z=F.some(q=>q.status==="done"&&q.attachment),[J,ae]=C.useState(null),{scrollRef:T,contentRef:H,isAtBottom:U,scrollToBottom:W}=Bi({resize:"smooth",initial:"instant"}),te=C.useMemo(()=>new Map((e.members??[]).map(q=>[q.id,q])),[e.members]),K=C.useMemo(()=>new Map((e.invocations??[]).map(q=>[q.id,q])),[e.invocations]),ce=C.useMemo(()=>{const q=new Set(t.map(ue=>ue.id)),Q=R.filter(ue=>!q.has(ue.id));return[...t,...Q].sort((ue,Te)=>{const Ne=Date.parse(ue.createdAt??""),Ee=Date.parse(Te.createdAt??"");return(Number.isNaN(Ne)?0:Ne)-(Number.isNaN(Ee)?0:Ee)})},[t,R]),he=C.useMemo(()=>new Map((e.workRequests??[]).map(q=>[q.id,q])),[e.workRequests]),ve=C.useMemo(()=>fh(ce,e.workRequests??[],e.invocations??[]),[ce,e.invocations,e.workRequests]),Fe=C.useMemo(()=>(e.invocations??[]).filter(q=>Rs.has(q.status)),[e.invocations]),re=C.useMemo(()=>x.map(q=>te.get(q)).filter(q=>!!q),[te,x]),pe=C.useMemo(()=>{const q=o?.query??"";return(e.members??[]).filter(Q=>Rh(Q,q)).sort((Q,ue)=>{const Te=x.includes(Q.id),Ne=x.includes(ue.id);return Te!==Ne?Te?1:-1:Q.name.localeCompare(ue.name)})},[o?.query,x,e.members]),Ze=!r&&(y||!!o)&&pe.length>0,je=C.useCallback((q,Q)=>{if(Q==null){h(null);return}h(Ah(q,Q)),u(0)},[]),Le=C.useCallback(q=>{S(Ee=>dh(Ee,q.id));const Q=`@${q.name} `;if(o){const Ee=`${g.slice(0,o.start)}${Q}${g.slice(o.end)}`,lt=o.start+Q.length;b(Ee),h(null),_(!1),requestAnimationFrame(()=>{M.current?.focus(),M.current?.setSelectionRange(lt,lt)});return}const ue=g.length===0||/\s$/.test(g)?"":" ",Te=`${g}${ue}${Q}`,Ne=Te.length;b(Te),_(!1),requestAnimationFrame(()=>{M.current?.focus(),M.current?.setSelectionRange(Ne,Ne)})},[g,o]),we=C.useCallback(q=>{S(Q=>uh(Q,q))},[]),Ce=C.useCallback(q=>{const Q=q.target.value;b(Q),j(null);const ue=q.target;ue.style.height="auto",ue.style.height=`${Math.max(v?40:72,Math.min(ue.scrollHeight,v?140:240))}px`,_(!1),je(Q,ue.selectionStart)},[v,je]),Xe=C.useCallback(q=>{const Q=q.target.files;Q&&Q.length>0&&(z(Array.from(Q)),j(null)),q.target.value=""},[z]),_e=C.useCallback(q=>{const Q=[];for(const ue of q.clipboardData.items)if(ue.kind==="file"){const Te=ue.getAsFile();Te&&Q.push(Te)}Q.length>0&&(q.preventDefault(),z(Q),j(null))},[z]),ze=C.useCallback(async()=>{if(r||k||X)return;const q=B(),Q=$().map(Pe=>Pe.id),ue=hh(x,e.members??[]),Te=Bh({draft:g,attachmentMarkdown:q,attachmentIds:Q,mentions:ue});if(!Te||!g.trim()&&!Z)return;const Ne=bh(e.id,Te),Ee=g,lt=x,ft=F;L(Pe=>[...Pe,Ne]),b(""),S([]),_(!1),h(null),P(),M.current&&(M.current.style.height=v?"40px":"72px"),requestAnimationFrame(()=>W()),E(!0),j(null);try{const Pe=await p(Te);L(Ve=>Ve.filter(He=>He.id!==Ne.id)),Pe&&typeof Pe=="object"&&"id"in Pe&&requestAnimationFrame(()=>W())}catch(Pe){const Ve=Pe instanceof Error?Pe.message:"Failed to send room message";L(He=>He.map(We=>We.id===Ne.id?{...We,pendingStatus:"failed",error:Ve}:We)),b(He=>He.length===0?Ee:He),S(He=>He.length===0?lt:He),I(ft),j(Ve),requestAnimationFrame(()=>W())}finally{E(!1)}},[F,B,P,v,g,$,Z,k,X,p,r,I,W,x,e.id,e.members]),ke=C.useCallback(q=>{const Q=q.nativeEvent.isComposing||q.nativeEvent.keyCode===229;if(Ze){if(q.key==="ArrowDown"){q.preventDefault(),u(ue=>(ue+1)%pe.length);return}if(q.key==="ArrowUp"){q.preventDefault(),u(ue=>(ue-1+pe.length)%pe.length);return}if(q.key==="Enter"&&!Q||q.key==="Tab"){q.preventDefault();const ue=pe[d]??pe[0];ue&&Le(ue);return}if(q.key==="Escape"){q.preventDefault(),h(null),_(!1);return}}q.key==="Enter"&&!q.shiftKey&&!q.repeat&&!Q&&(q.preventDefault(),ze())},[Le,ze,d,pe,Ze]);C.useEffect(()=>{b(""),S([]),_(!1),h(null),j(null),L([]),P(),N(null),M.current&&(M.current.style.height=v?"40px":"72px")},[P,v,e.id]);const Re=n.isError?n.error:c.isError?c.error:f.isError?f.error:null,tt=n.isPending||c.isPending||f.isPending,qe=C.useCallback((q,Q)=>{l.mutate({memberId:q,cancelQueued:Q},{onSuccess:()=>N(null)})},[l]);return s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[J&&s.jsx(Ih,{images:J.images,index:J.index,onClose:()=>ae(null),onSelect:q=>ae(Q=>Q&&{...Q,index:q})}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:T,className:se("h-full overflow-y-auto scrollbar-app-thin bg-white",v?"px-3 py-3":"px-4 py-4"),children:s.jsxs("div",{ref:H,className:se(v?"space-y-2.5":"space-y-3"),children:[ve.length===0?s.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:[s.jsx(fr,{size:24,className:"text-neutral-400"}),s.jsx("span",{className:"text-sm",children:i("No room messages yet")})]}):ve.map(q=>{if(q.kind==="pendingApproval"){const Ee=q.request,lt=te.get(Ee.targetMemberId),ft=n.isPending&&n.variables===Ee.id,Pe=c.isPending&&c.variables===Ee.id,Ve=f.isPending&&f.variables===Ee.id;return s.jsx(Hh,{request:Ee,member:lt,onApprove:()=>n.mutate(Ee.id),onReject:()=>c.mutate(Ee.id),onCancel:()=>f.mutate(Ee.id),isActionPending:tt,isApprovePending:ft,isRejectPending:Pe,isCancelPending:Ve},q.key)}const Q=q.message,ue=Dh(Q,te,K),Te=Q.senderType==="user"?i("你"):Q.senderType==="system"?i("System"):ue?.name??i("Agent"),Ne=Mh(Q,te);return s.jsx(zh,{message:Q,senderName:Te,senderMember:ue,displayContent:Ne,onOpenImage:(Ee,lt)=>ae({images:Ee,index:lt})},q.key)}),Re&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Mn(Re,i("Failed to update work request"))}),l.isError&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Mn(l.error,i("Failed to stop member work"))})]})}),!U&&s.jsxs("button",{type:"button",onClick:()=>W(),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:[s.jsx(Cs,{size:14}),s.jsx("span",{children:i("Back to bottom")})]})]}),s.jsxs("div",{className:se("shrink-0 border-t border-transparent bg-white",v?"px-3 pb-2 pt-1.5":"px-6 pb-6 pt-2"),children:[s.jsx(xh,{invocations:Fe,memberById:te,workRequestById:he,onViewInvocationSession:m,onStopMember:qe,isStopPending:l.isPending,stoppingMemberId:l.variables?.memberId??null,stopPromptInvocationId:D,onToggleStopConfirm:q=>N(Q=>Q===q?null:q)}),r?s.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-500",children:a??i("This project is read-only")}):s.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:[Ze&&s.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:[s.jsx("div",{className:"border-b border-neutral-100 px-3 py-2 text-xs font-medium text-neutral-500",children:i(o?"Mention members":"Team members")}),s.jsx("div",{className:"max-h-64 overflow-y-auto p-1",children:pe.map((q,Q)=>{const ue=x.includes(q.id),Te=Q===d;return s.jsxs("button",{type:"button",onMouseEnter:()=>u(Q),onMouseDown:Ne=>{Ne.preventDefault(),Le(q)},className:se("flex w-full items-center gap-2 rounded-lg px-2 py-2 text-left transition-colors",Te?"bg-neutral-100":"hover:bg-neutral-50"),children:[s.jsx(Xt,{name:q.name,avatar:q.avatar,className:"h-8 w-8 text-[11px]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate text-sm font-medium text-neutral-900",children:q.name}),ue&&s.jsx("span",{className:"rounded-full bg-neutral-900 px-1.5 py-0.5 text-[10px] font-medium text-white",children:i("selected")})]}),s.jsx("div",{className:"truncate text-xs text-neutral-500",children:[q.providerId,q.id.slice(0,8)].filter(Boolean).join(" · ")})]}),s.jsx(cn,{size:15,className:"text-neutral-400"})]},q.id)})})]}),re.length>0&&s.jsx("div",{className:"flex flex-wrap items-center gap-1.5 border-b border-neutral-100 px-3 py-2",children:re.map(q=>s.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:[s.jsxs("span",{className:"truncate font-medium",children:["@",q.name]}),s.jsx("span",{className:"shrink-0 text-[10px] text-neutral-400",children:q.id.slice(0,8)}),s.jsx("button",{type:"button",onClick:()=>we(q.id),className:"shrink-0 rounded-full p-0.5 text-neutral-400 transition-colors hover:bg-neutral-200 hover:text-neutral-700",title:i("Remove mention"),"aria-label":`${i("Remove mention")} ${q.name}`,children:s.jsx(Ht,{size:12})})]},q.id))}),s.jsx(wr,{files:F,onRemove:A}),s.jsx("textarea",{ref:M,value:g,rows:v?1:void 0,onChange:Ce,onKeyDown:ke,onPaste:_e,onClick:q=>je(g,q.currentTarget.selectionStart),onSelect:q=>je(g,q.currentTarget.selectionStart),placeholder:i("Message the team room..."),className:se("w-full resize-none border-none bg-transparent text-neutral-900 placeholder-neutral-400 focus:outline-none",v?"px-3 pb-1 pt-2.5 text-[15px] leading-5":"px-4 pb-2 pt-4 text-sm leading-relaxed"),style:v?{minHeight:40,maxHeight:140}:{minHeight:60,maxHeight:220}}),s.jsxs("div",{className:se("flex items-center justify-between",v?"px-2 pb-1.5 pt-0.5":"px-2 pb-2 pt-1"),children:[s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("input",{ref:O,type:"file",multiple:!0,className:"hidden",onChange:Xe}),s.jsx("button",{type:"button",onClick:()=>O.current?.click(),title:i("Upload file"),"aria-label":i("Upload file"),className:"rounded-lg p-2 text-neutral-400 transition-colors hover:bg-neutral-100 hover:text-neutral-600",children:s.jsx(mr,{size:18})}),s.jsx("button",{type:"button",onClick:()=>{_(q=>!q),h(null),requestAnimationFrame(()=>M.current?.focus())},disabled:re.length===0&&(e.members??[]).length===0,title:i("Mention members"),"aria-label":i("Mention members"),className:se("rounded-lg transition-colors",v?"p-1.5":"p-2",y?"bg-neutral-100 text-neutral-700":"text-neutral-400 hover:bg-neutral-100 hover:text-neutral-600",re.length===0&&(e.members??[]).length===0?"cursor-not-allowed opacity-50":""),children:s.jsx(cn,{size:v?15:18})}),re.length>0&&s.jsxs("span",{className:"text-[11px] text-neutral-500",children:[re.length," ",i("selected")]})]}),s.jsx("button",{type:"button",onClick:()=>{ze()},disabled:r||k||X||!g.trim()&&!Z,title:i(X?"Uploading...":k?"发送中...":"发送"),"aria-label":i(X?"Uploading...":k?"发送中...":"发送"),className:se("rounded-lg transition-all duration-200",v?"p-1.5":"p-2",(g.trim()||Z)&&!r&&!k&&!X?"bg-neutral-900 text-white shadow-md hover:bg-black":"cursor-not-allowed bg-transparent text-neutral-300",k||X?"opacity-70":""),children:s.jsx(wi,{size:v?15:18})})]}),w&&s.jsx("div",{className:"border-t border-neutral-100 px-3 py-2 text-xs text-red-600",children:w})]})]})]})}function Wh(e){return e?e.slice(0,8):""}function Dn(e){const t=e?Date.parse(e):0;return Number.isNaN(t)?0:t}function na(e,t){if(!e?.length)return[];const r=new Map((t?.members??[]).map(m=>[m.id,m])),a=new Map(e.map(m=>[m.id,m])),p=t?.mainWorkspaceId??null;return e.map(m=>{const v=m.parentWorkspaceId?a.get(m.parentWorkspaceId):void 0,i=m.ownerMemberId?r.get(m.ownerMemberId):void 0,n=!!(p&&m.id===p),c=n?"main":m.parentWorkspaceId?"child":"root",f=i?.name??(m.ownerMemberId?`Member ${Wh(m.ownerMemberId)}`:void 0),l=n?"Main workspace":c==="child"?f?`${f} workspace`:"Child workspace":t?"Root workspace":"Workspace";return{workspace:m,kind:c,roleLabel:n?"Main":c==="child"?"Child":"Root",displayName:l,ownerName:f,parentBranchName:v?.branchName,isMain:n}}).sort((m,v)=>{const i=c=>c.kind==="main"?0:c.kind==="child"?1:2,n=i(m)-i(v);return n!==0?n:Dn(m.workspace.createdAt)-Dn(v.workspace.createdAt)})}function oa(e,t,r){if(e?.length)return r&&e.some(a=>a.id===r)?r:t?.mainWorkspaceId&&e.some(a=>a.id===t.mainWorkspaceId)?t.mainWorkspaceId:e.find(a=>a.status===kt.ACTIVE)?.id??e[0]?.id}function $h(e,t){return!e||e.status!==kt.ACTIVE?!1:!t||e.parentWorkspaceId?!0:!!(t.mainWorkspaceId&&e.id===t.mainWorkspaceId)}function Uh(e,t,r){return e?.parentWorkspaceId?t?.find(p=>p.id===e.parentWorkspaceId)?.branchName??e.baseBranch??r:r}const qh=[],Kh=[],Xh=[];function Zt(e){if(!e)return"";const t=new Date(e);return Number.isNaN(t.getTime())?"":t.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})}function Hr(e,t){return e instanceof Error?e.message:t}function Vh(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"idle":return"Idle"}}function Yh(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"idle":return"border-neutral-200 bg-white text-neutral-500"}}function Gh(e){switch(e){case"user":return"User";case"agent":return"Agent";case"system":return"System"}}function Qh(e){switch(e){case"queue":return"Queue if busy";case"cancel_current_and_start":return"Cancel current if busy"}}function Zh(e){switch(e){case"new_per_request":return"New session per request";case"resume_last":return"Resume last session"}}function Jh(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 ef(e){switch(e){case kt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case kt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case kt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case kt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function tf(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 sf(e){return[...e].sort((t,r)=>Date.parse(r.updatedAt??r.createdAt??"")-Date.parse(t.updatedAt??t.createdAt??""))}function Wr(e){return e?`${e.slice(0,8)}...`:""}function rf(e,t,r){const a=t.filter(m=>m.memberId===e.id);if(a.some(m=>m.status==="RUNNING"))return"running";if(a.some(m=>m.status==="WAITING_ROOM_REPLY"))return"waiting room reply";if(a.some(m=>m.status==="QUEUED"))return"queued";if(a.some(m=>m.status==="SESSION_ENDED"))return"session ended";const p=r.find(m=>m.targetMemberId===e.id&&(m.status==="PENDING_APPROVAL"||m.status==="QUEUED"));return p?.status==="PENDING_APPROVAL"?"pending approval":p?.status==="QUEUED"?"queued":"idle"}function aa({teamRun:e,workspaces:t,selectedWorkspaceId:r,onSelectWorkspace:a,onViewInvocationSession:p}){const{t:m}=ne(),v=bo(e.id),i=yo(e.id),n=ti(e.id),c=ti(e.id),f=So(e.id),[l,g]=C.useState(null),[b,y]=C.useState(null),_=e.members??qh,o=e.workRequests??Kh,h=e.invocations??Xh,d=C.useMemo(()=>na(t,e),[e,t]),u=C.useMemo(()=>new Map(o.map(N=>[N.id,N])),[o]),x=e.messages?.length??0,S=C.useMemo(()=>h.filter(N=>Rs.has(N.status)).sort((N,M)=>Date.parse(M.updatedAt??M.createdAt??"")-Date.parse(N.updatedAt??N.createdAt??"")),[h]),k=C.useMemo(()=>[...h].filter(N=>N.status==="COMPLETED"||N.status==="FAILED"||N.status==="CANCELLED").sort((N,M)=>Date.parse(M.updatedAt??M.createdAt??"")-Date.parse(N.updatedAt??N.createdAt??"")).slice(0,6),[h]),E=C.useMemo(()=>[...o].filter(N=>N.status==="PENDING_APPROVAL").sort((N,M)=>Date.parse(M.updatedAt??M.createdAt??"")-Date.parse(N.updatedAt??N.createdAt??"")),[o]),w=C.useMemo(()=>[...o].filter(N=>N.status==="QUEUED").sort((N,M)=>Date.parse(M.updatedAt??M.createdAt??"")-Date.parse(N.updatedAt??N.createdAt??"")),[o]),j=v.isError?v.error:i.isError?i.error:n.isError?n.error:null,R=c.isError?c.error:null,L=v.isPending||i.isPending||n.isPending,D=c.isPending;return s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[s.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[s.jsx(ds,{size:14,className:"text-neutral-500 shrink-0"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:m("Team Status")})]}),s.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:[s.jsx("span",{children:m("Team mode")}),s.jsx("span",{className:"text-neutral-700",children:e.mode})]})]}),s.jsxs("div",{className:"flex-1 min-h-0 overflow-y-auto scrollbar-app-thin px-4 py-4 space-y-4",children:[s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(Js,{size:13}),s.jsx("span",{children:m("Team room")})]}),s.jsx("div",{className:"rounded-md border border-neutral-200 bg-neutral-50 px-3 py-2",children:s.jsxs("div",{className:"flex flex-wrap items-center gap-1.5 text-[11px] text-neutral-500",children:[s.jsxs("span",{className:"rounded-full border border-neutral-200 bg-white px-2 py-0.5 font-medium text-neutral-600",children:[m("Messages"),": ",x]}),s.jsxs("span",{className:"rounded-full border border-neutral-200 bg-white px-2 py-0.5 font-medium text-neutral-600",children:[m("Team mode"),": ",e.mode]}),e.reviewReason&&s.jsxs("span",{className:"rounded-full border border-neutral-200 bg-white px-2 py-0.5 font-medium text-neutral-600",children:[m("Review reason"),": ",e.reviewReason]})]})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(ds,{size:13}),s.jsx("span",{children:m("Workspaces")})]}),s.jsx("div",{className:"space-y-2",children:d.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:m("No workspace")}):d.map(N=>{const M=r===N.workspace.id;return s.jsx("div",{className:se("rounded-md border bg-white px-3 py-2",M?"border-neutral-400 shadow-sm":"border-neutral-200"),children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:m(N.displayName)}),s.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",tf(N.roleLabel)),children:m(N.roleLabel)}),s.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",ef(N.workspace.status)),children:N.workspace.status})]}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:N.workspace.branchName}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[N.ownerName&&s.jsxs("span",{children:[m("Owner"),": ",N.ownerName]}),N.parentBranchName&&s.jsxs("span",{children:[m("Parent"),": ",N.parentBranchName]}),s.jsxs("span",{children:[m("Workspace"),": ",Wr(N.workspace.id)]})]})]}),s.jsxs("button",{type:"button",onClick:()=>a?.(N.workspace.id),disabled:!a||M,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:[M?s.jsx(At,{size:11}):s.jsx(ji,{size:11}),s.jsx("span",{children:m(M?"Selected":"Select")})]})]})},N.workspace.id)})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(ts,{size:13}),s.jsx("span",{children:m("Pending approval")})]}),s.jsx("div",{className:"space-y-2",children:E.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:m("No pending approvals")}):E.map(N=>{const M=_.find(A=>A.id===N.targetMemberId),O=v.isPending&&v.variables===N.id,F=i.isPending&&i.variables===N.id,z=n.isPending&&n.variables===N.id;return s.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:M?.name??N.targetMemberId}),s.jsx("div",{className:"mt-0.5 text-[11px] leading-relaxed text-neutral-500 line-clamp-3",children:N.instruction})]}),s.jsx("span",{className:"shrink-0 rounded-full border border-amber-200 bg-amber-50 px-2 py-0.5 text-[10px] font-medium text-amber-700",children:m("Pending approval")})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-x-2 gap-y-1 text-[10px] text-neutral-500",children:[s.jsxs("span",{children:[m("Requester"),": ",m(Gh(N.requesterType))]}),s.jsx("span",{children:Zt(N.createdAt)}),s.jsx("span",{children:m(Qh(N.ifBusy))}),s.jsxs("span",{children:[m("Cancel queued"),": ",m(N.cancelQueued?"Yes":"No")]})]}),s.jsxs("div",{className:"mt-2 flex flex-wrap gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>v.mutate(N.id),disabled:L,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",title:m("Approve"),children:[s.jsx(At,{size:11}),s.jsx("span",{className:"truncate",children:m(O?"Approving":"Approve")})]}),s.jsxs("button",{type:"button",onClick:()=>i.mutate(N.id),disabled:L,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",title:m("Reject"),children:[s.jsx(Ht,{size:11}),s.jsx("span",{className:"truncate",children:m(F?"Rejecting":"Reject")})]}),s.jsxs("button",{type:"button",onClick:()=>n.mutate(N.id),disabled:L,className:"inline-flex h-6 min-w-0 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",title:m("Cancel"),children:[s.jsx(_s,{size:11}),s.jsx("span",{className:"truncate",children:m(z?"Cancelling":"Cancel")})]})]})]},N.id)})}),j&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Hr(j,m("Failed to update work request"))})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(fr,{size:13}),s.jsx("span",{children:m("Members")})]}),s.jsx("div",{className:"space-y-2",children:_.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:m("No members")}):_.map(N=>{const M=rf(N,h,o),O=sf(h.filter(A=>A.memberId===N.id)),F=O[0],z=b===N.id;return s.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white",children:[s.jsxs("button",{type:"button",onClick:()=>y(z?null:N.id),className:"flex w-full items-start justify-between gap-3 px-3 py-2 text-left transition-colors hover:bg-neutral-50",children:[s.jsxs("div",{className:"flex min-w-0 items-start gap-2",children:[s.jsx(Xt,{name:N.name,avatar:N.avatar}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:N.name}),s.jsxs("div",{className:"truncate text-[11px] text-neutral-500",children:[N.providerId," · ",N.workspacePolicy," · ",m(Zh(N.sessionPolicy))]}),F&&s.jsxs("div",{className:"mt-0.5 truncate text-[11px] text-neutral-400",children:[m("Latest"),": ",F.status," · ",Zt(F.updatedAt??F.createdAt)]})]})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-1.5",children:[s.jsx("span",{className:se("rounded-full border px-2 py-0.5 text-[10px] font-medium capitalize",Yh(M)),children:m(Vh(M))}),z?s.jsx(_t,{size:14,className:"text-neutral-400"}):s.jsx(Tt,{size:14,className:"text-neutral-400"})]})]}),z&&s.jsxs("div",{className:"border-t border-neutral-100 px-3 py-2",children:[s.jsxs("div",{className:"mb-2 flex items-center justify-between gap-2",children:[s.jsx("span",{className:"text-[11px] font-medium text-neutral-500",children:m("Invocation history")}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:O.length})]}),O.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-xs text-neutral-500",children:m("No invocation history")}):s.jsx("div",{className:"space-y-1.5",children:O.map(A=>{const P=u.get(A.workRequestId),I=!!(A.sessionId&&p);return s.jsx("div",{className:"rounded-md border border-neutral-100 bg-neutral-50/70 px-2.5 py-2",children:s.jsxs("div",{className:"flex items-start justify-between gap-2",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsxs("div",{className:"flex min-w-0 flex-wrap items-center gap-1.5",children:[s.jsx("span",{className:se("rounded-full border px-1.5 py-0.5 text-[10px] font-medium",Jh(A.status)),children:A.status}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:Zt(A.updatedAt??A.createdAt)})]}),s.jsx("div",{className:"mt-1 truncate text-[11px] text-neutral-500",children:P?.instruction??A.workRequestId}),s.jsxs("div",{className:"mt-1 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[s.jsxs("span",{children:[m("Invocation"),": ",Wr(A.id)]}),A.sessionId&&s.jsxs("span",{children:[m("Session"),": ",Wr(A.sessionId)]})]})]}),s.jsxs("button",{type:"button",onClick:()=>A.sessionId&&p?.(A.sessionId),disabled:!I,className:"inline-flex h-6 shrink-0 items-center gap-1 rounded-md border border-neutral-200 bg-white px-2 text-[11px] font-medium text-neutral-600 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",title:m("View details"),children:[s.jsx(Ai,{size:11}),s.jsx("span",{children:m("View log")})]})]})},A.id)})})]})]},N.id)})})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(Js,{size:13}),s.jsx("span",{children:m("Queue")})]}),s.jsx("div",{className:"space-y-2",children:w.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:m("No queued work requests")}):w.map(N=>{const M=_.find(F=>F.id===N.targetMemberId),O=c.isPending&&c.variables===N.id;return s.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:M?.name??N.targetMemberId}),s.jsx("div",{className:"mt-0.5 text-[11px] text-neutral-500 line-clamp-2",children:N.instruction})]}),s.jsxs("button",{type:"button",onClick:()=>c.mutate(N.id),disabled:D,className:"inline-flex h-6 shrink-0 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",title:m("Cancel"),children:[s.jsx(_s,{size:11}),s.jsx("span",{children:m(O?"Cancelling":"Cancel")})]})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] text-neutral-500",children:[s.jsx(ts,{size:11}),s.jsx("span",{children:Zt(N.createdAt)})]})]},N.id)})}),R&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Hr(R,m("Failed to cancel work request"))})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(hc,{size:13}),s.jsx("span",{children:m("Active invocations")})]}),s.jsx("div",{className:"space-y-2",children:S.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:m("No active invocations")}):S.map(N=>{const M=_.find(A=>A.id===N.memberId),O=Rs.has(N.status)&&!!M,F=l===N.id,z=f.isPending&&f.variables?.memberId===M?.id;return s.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:M?.name??N.memberId}),s.jsxs("div",{className:"mt-0.5 text-[11px] text-neutral-500",children:[N.status," · ",N.sessionId?N.sessionId.slice(0,8):N.id.slice(0,8)]})]}),O?s.jsxs("button",{type:"button",onClick:()=>g(F?null:N.id),disabled:f.isPending,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("Stop"),children:[s.jsx(os,{size:10}),s.jsx("span",{children:m("Stop")})]}):s.jsx(Es,{size:12,className:"text-neutral-400 shrink-0"})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] text-neutral-500",children:[s.jsx(ts,{size:11}),s.jsx("span",{children:Zt(N.updatedAt??N.createdAt)})]}),O&&F&&s.jsxs("div",{className:"mt-2 rounded-md border border-neutral-200 bg-neutral-50 p-2",children:[s.jsx("div",{className:"mb-1.5 text-[11px] text-neutral-600",children:m("Stop running work?")}),s.jsxs("div",{className:"grid grid-cols-1 gap-1.5",children:[s.jsxs("button",{type:"button",onClick:()=>{f.mutate({memberId:M.id,cancelQueued:!1},{onSuccess:()=>g(null)})},disabled:f.isPending,className:"inline-flex min-h-6 w-full items-center justify-center gap-1 rounded-md border border-neutral-200 bg-white px-2 py-1 text-[11px] font-medium text-neutral-700 transition-colors hover:bg-neutral-100 disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx(os,{size:10}),s.jsx("span",{children:z&&f.variables?.cancelQueued===!1?m("Stopping"):m("Stop only")})]}),s.jsxs("button",{type:"button",onClick:()=>{f.mutate({memberId:M.id,cancelQueued:!0},{onSuccess:()=>g(null)})},disabled:f.isPending,className:"inline-flex min-h-6 w-full items-center justify-center gap-1 rounded-md border border-red-200 bg-red-50 px-2 py-1 text-[11px] font-medium text-red-700 transition-colors hover:bg-red-100 disabled:cursor-not-allowed disabled:opacity-50",children:[s.jsx(_s,{size:10}),s.jsx("span",{children:z&&f.variables?.cancelQueued===!0?m("Stopping"):m("Stop + clear queue")})]})]})]})]},N.id)})}),f.isError&&s.jsx("div",{className:"rounded-md border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700",children:Hr(f.error,m("Failed to stop member work"))})]}),s.jsxs("section",{className:"space-y-2",children:[s.jsxs("div",{className:"flex items-center gap-2 text-[11px] font-medium uppercase tracking-wide text-neutral-500",children:[s.jsx(Es,{size:13}),s.jsx("span",{children:m("Recently completed")})]}),s.jsx("div",{className:"space-y-2",children:k.length===0?s.jsx("div",{className:"rounded-md border border-dashed border-neutral-200 bg-neutral-50 px-3 py-3 text-sm text-neutral-500",children:m("No completed invocations")}):k.map(N=>{const M=_.find(O=>O.id===N.memberId);return s.jsxs("div",{className:"rounded-md border border-neutral-200 bg-white px-3 py-2",children:[s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-xs font-medium text-neutral-900",children:M?.name??N.memberId}),s.jsx("div",{className:"mt-0.5 text-[11px] text-neutral-500",children:N.status})]}),s.jsx("span",{className:"rounded-full border border-neutral-200 bg-neutral-50 px-2 py-0.5 text-[10px] font-medium text-neutral-600",children:N.status})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-2 text-[11px] text-neutral-500",children:[s.jsx(ts,{size:11}),s.jsx("span",{children:Zt(N.updatedAt??N.createdAt)})]})]},N.id)})})]})]})]})}var $r={exports:{}},Ln;function nf(){return Ln||(Ln=1,(function(e,t){(function(r,a){e.exports=a()})(self,(()=>(()=>{var r={4567:function(v,i,n){var c=this&&this.__decorate||function(u,x,S,k){var E,w=arguments.length,j=w<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(u,x,S,k);else for(var R=u.length-1;R>=0;R--)(E=u[R])&&(j=(w<3?E(j):w>3?E(x,S,j):E(x,S))||j);return w>3&&j&&Object.defineProperty(x,S,j),j},f=this&&this.__param||function(u,x){return function(S,k){x(S,k,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.AccessibilityManager=void 0;const l=n(9042),g=n(6114),b=n(9924),y=n(844),_=n(5596),o=n(4725),h=n(3656);let d=i.AccessibilityManager=class extends y.Disposable{constructor(u,x){super(),this._terminal=u,this._renderService=x,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 S=0;S<this._terminal.rows;S++)this._rowElements[S]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[S]);if(this._topBoundaryFocusListener=S=>this._handleBoundaryFocus(S,0),this._bottomBoundaryFocusListener=S=>this._handleBoundaryFocus(S,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 b.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((S=>this._handleResize(S.rows)))),this.register(this._terminal.onRender((S=>this._refreshRows(S.start,S.end)))),this.register(this._terminal.onScroll((()=>this._refreshRows()))),this.register(this._terminal.onA11yChar((S=>this._handleChar(S)))),this.register(this._terminal.onLineFeed((()=>this._handleChar(`
19
+ `)))),this.register(this._terminal.onA11yTab((S=>this._handleTab(S)))),this.register(this._terminal.onKey((S=>this._handleKey(S.key)))),this.register(this._terminal.onBlur((()=>this._clearLiveRegion()))),this.register(this._renderService.onDimensionsChange((()=>this._refreshRowsDimensions()))),this._screenDprMonitor=new _.ScreenDprMonitor(window),this.register(this._screenDprMonitor),this._screenDprMonitor.setListener((()=>this._refreshRowsDimensions())),this.register((0,h.addDisposableDomListener)(window,"resize",(()=>this._refreshRowsDimensions()))),this._refreshRows(),this.register((0,y.toDisposable)((()=>{this._accessibilityContainer.remove(),this._rowElements.length=0})))}_handleTab(u){for(let x=0;x<u;x++)this._handleChar(" ")}_handleChar(u){this._liveRegionLineCount<21&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==u&&(this._charsToAnnounce+=u):this._charsToAnnounce+=u,u===`
20
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===21&&(this._liveRegion.textContent+=l.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(u){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(u)||this._charsToConsume.push(u)}_refreshRows(u,x){this._liveRegionDebouncer.refresh(u,x,this._terminal.rows)}_renderRows(u,x){const S=this._terminal.buffer,k=S.lines.length.toString();for(let E=u;E<=x;E++){const w=S.translateBufferLineToString(S.ydisp+E,!0),j=(S.ydisp+E+1).toString(),R=this._rowElements[E];R&&(w.length===0?R.innerText=" ":R.textContent=w,R.setAttribute("aria-posinset",j),R.setAttribute("aria-setsize",k))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(u,x){const S=u.target,k=this._rowElements[x===0?1:this._rowElements.length-2];if(S.getAttribute("aria-posinset")===(x===0?"1":`${this._terminal.buffer.lines.length}`)||u.relatedTarget!==k)return;let E,w;if(x===0?(E=S,w=this._rowElements.pop(),this._rowContainer.removeChild(w)):(E=this._rowElements.shift(),w=S,this._rowContainer.removeChild(E)),E.removeEventListener("focus",this._topBoundaryFocusListener),w.removeEventListener("focus",this._bottomBoundaryFocusListener),x===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(x===0?-1:1),this._rowElements[x===0?1:this._rowElements.length-2].focus(),u.preventDefault(),u.stopImmediatePropagation()}_handleResize(u){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let x=this._rowContainer.children.length;x<this._terminal.rows;x++)this._rowElements[x]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[x]);for(;this._rowElements.length>u;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){const u=document.createElement("div");return u.setAttribute("role","listitem"),u.tabIndex=-1,this._refreshRowDimensions(u),u}_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 u=0;u<this._terminal.rows;u++)this._refreshRowDimensions(this._rowElements[u])}}_refreshRowDimensions(u){u.style.height=`${this._renderService.dimensions.css.cell.height}px`}};i.AccessibilityManager=d=c([f(1,o.IRenderService)],d)},3614:(v,i)=>{function n(g){return g.replace(/\r?\n/g,"\r")}function c(g,b){return b?"\x1B[200~"+g+"\x1B[201~":g}function f(g,b,y,_){g=c(g=n(g),y.decPrivateModes.bracketedPasteMode&&_.rawOptions.ignoreBracketedPasteMode!==!0),y.triggerDataEvent(g,!0),b.value=""}function l(g,b,y){const _=y.getBoundingClientRect(),o=g.clientX-_.left-10,h=g.clientY-_.top-10;b.style.width="20px",b.style.height="20px",b.style.left=`${o}px`,b.style.top=`${h}px`,b.style.zIndex="1000",b.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=c,i.copyHandler=function(g,b){g.clipboardData&&g.clipboardData.setData("text/plain",b.selectionText),g.preventDefault()},i.handlePasteEvent=function(g,b,y,_){g.stopPropagation(),g.clipboardData&&f(g.clipboardData.getData("text/plain"),b,y,_)},i.paste=f,i.moveTextAreaUnderMouseCursor=l,i.rightClickHandler=function(g,b,y,_,o){l(g,b,y),o&&_.rightClickSelect(g),b.value=_.selectionText,b.select()}},7239:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ColorContrastCache=void 0;const c=n(1505);i.ColorContrastCache=class{constructor(){this._color=new c.TwoKeyMap,this._css=new c.TwoKeyMap}setCss(f,l,g){this._css.set(f,l,g)}getCss(f,l){return this._css.get(f,l)}setColor(f,l,g){this._color.set(f,l,g)}getColor(f,l){return this._color.get(f,l)}clear(){this._color.clear(),this._css.clear()}}},3656:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.addDisposableDomListener=void 0,i.addDisposableDomListener=function(n,c,f,l){n.addEventListener(c,f,l);let g=!1;return{dispose:()=>{g||(g=!0,n.removeEventListener(c,f,l))}}}},6465:function(v,i,n){var c=this&&this.__decorate||function(o,h,d,u){var x,S=arguments.length,k=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(o,h,d,u);else for(var E=o.length-1;E>=0;E--)(x=o[E])&&(k=(S<3?x(k):S>3?x(h,d,k):x(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(o,h){return function(d,u){h(d,u,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Linkifier2=void 0;const l=n(3656),g=n(8460),b=n(844),y=n(2585);let _=i.Linkifier2=class extends b.Disposable{get currentLink(){return this._currentLink}constructor(o){super(),this._bufferService=o,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,b.getDisposeArrayDisposable)(this._linkCacheDisposables)),this.register((0,b.toDisposable)((()=>{this._lastMouseEvent=void 0}))),this.register(this._bufferService.onResize((()=>{this._clearCurrentLink(),this._wasResized=!0})))}registerLinkProvider(o){return this._linkProviders.push(o),{dispose:()=>{const h=this._linkProviders.indexOf(o);h!==-1&&this._linkProviders.splice(h,1)}}}attachToDom(o,h,d){this._element=o,this._mouseService=h,this._renderService=d,this.register((0,l.addDisposableDomListener)(this._element,"mouseleave",(()=>{this._isMouseOut=!0,this._clearCurrentLink()}))),this.register((0,l.addDisposableDomListener)(this._element,"mousemove",this._handleMouseMove.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mousedown",this._handleMouseDown.bind(this))),this.register((0,l.addDisposableDomListener)(this._element,"mouseup",this._handleMouseUp.bind(this)))}_handleMouseMove(o){if(this._lastMouseEvent=o,!this._element||!this._mouseService)return;const h=this._positionFromMouseEvent(o,this._element,this._mouseService);if(!h)return;this._isMouseOut=!1;const d=o.composedPath();for(let u=0;u<d.length;u++){const x=d[u];if(x.classList.contains("xterm"))break;if(x.classList.contains("xterm-hover"))return}this._lastBufferCell&&h.x===this._lastBufferCell.x&&h.y===this._lastBufferCell.y||(this._handleHover(h),this._lastBufferCell=h)}_handleHover(o){if(this._activeLine!==o.y||this._wasResized)return this._clearCurrentLink(),this._askForLink(o,!1),void(this._wasResized=!1);this._currentLink&&this._linkAtPosition(this._currentLink.link,o)||(this._clearCurrentLink(),this._askForLink(o,!0))}_askForLink(o,h){var d,u;this._activeProviderReplies&&h||((d=this._activeProviderReplies)===null||d===void 0||d.forEach((S=>{S?.forEach((k=>{k.link.dispose&&k.link.dispose()}))})),this._activeProviderReplies=new Map,this._activeLine=o.y);let x=!1;for(const[S,k]of this._linkProviders.entries())h?!((u=this._activeProviderReplies)===null||u===void 0)&&u.get(S)&&(x=this._checkLinkProviderResult(S,o,x)):k.provideLinks(o.y,(E=>{var w,j;if(this._isMouseOut)return;const R=E?.map((L=>({link:L})));(w=this._activeProviderReplies)===null||w===void 0||w.set(S,R),x=this._checkLinkProviderResult(S,o,x),((j=this._activeProviderReplies)===null||j===void 0?void 0:j.size)===this._linkProviders.length&&this._removeIntersectingLinks(o.y,this._activeProviderReplies)}))}_removeIntersectingLinks(o,h){const d=new Set;for(let u=0;u<h.size;u++){const x=h.get(u);if(x)for(let S=0;S<x.length;S++){const k=x[S],E=k.link.range.start.y<o?0:k.link.range.start.x,w=k.link.range.end.y>o?this._bufferService.cols:k.link.range.end.x;for(let j=E;j<=w;j++){if(d.has(j)){x.splice(S--,1);break}d.add(j)}}}}_checkLinkProviderResult(o,h,d){var u;if(!this._activeProviderReplies)return d;const x=this._activeProviderReplies.get(o);let S=!1;for(let k=0;k<o;k++)this._activeProviderReplies.has(k)&&!this._activeProviderReplies.get(k)||(S=!0);if(!S&&x){const k=x.find((E=>this._linkAtPosition(E.link,h)));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=(u=this._activeProviderReplies.get(k))===null||u===void 0?void 0:u.find((w=>this._linkAtPosition(w.link,h)));if(E){d=!0,this._handleNewLink(E);break}}return d}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(o){if(!this._element||!this._mouseService||!this._currentLink)return;const h=this._positionFromMouseEvent(o,this._element,this._mouseService);h&&this._mouseDownLink===this._currentLink&&this._linkAtPosition(this._currentLink.link,h)&&this._currentLink.link.activate(o,this._currentLink.link.text)}_clearCurrentLink(o,h){this._element&&this._currentLink&&this._lastMouseEvent&&(!o||!h||this._currentLink.link.range.start.y>=o&&this._currentLink.link.range.end.y<=h)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,(0,b.disposeArray)(this._linkCacheDisposables))}_handleNewLink(o){if(!this._element||!this._lastMouseEvent||!this._mouseService)return;const h=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);h&&this._linkAtPosition(o.link,h)&&(this._currentLink=o,this._currentLink.state={decorations:{underline:o.link.decorations===void 0||o.link.decorations.underline,pointerCursor:o.link.decorations===void 0||o.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,o.link,this._lastMouseEvent),o.link.decorations={},Object.defineProperties(o.link.decorations,{pointerCursor:{get:()=>{var d,u;return(u=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||u===void 0?void 0:u.decorations.pointerCursor},set:d=>{var u,x;!((u=this._currentLink)===null||u===void 0)&&u.state&&this._currentLink.state.decorations.pointerCursor!==d&&(this._currentLink.state.decorations.pointerCursor=d,this._currentLink.state.isHovered&&((x=this._element)===null||x===void 0||x.classList.toggle("xterm-cursor-pointer",d)))}},underline:{get:()=>{var d,u;return(u=(d=this._currentLink)===null||d===void 0?void 0:d.state)===null||u===void 0?void 0:u.decorations.underline},set:d=>{var u,x,S;!((u=this._currentLink)===null||u===void 0)&&u.state&&((S=(x=this._currentLink)===null||x===void 0?void 0:x.state)===null||S===void 0?void 0:S.decorations.underline)!==d&&(this._currentLink.state.decorations.underline=d,this._currentLink.state.isHovered&&this._fireUnderlineEvent(o.link,d))}}}),this._renderService&&this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange((d=>{if(!this._currentLink)return;const u=d.start===0?0:d.start+1+this._bufferService.buffer.ydisp,x=this._bufferService.buffer.ydisp+1+d.end;if(this._currentLink.link.range.start.y>=u&&this._currentLink.link.range.end.y<=x&&(this._clearCurrentLink(u,x),this._lastMouseEvent&&this._element)){const S=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);S&&this._askForLink(S,!1)}}))))}_linkHover(o,h,d){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!0),this._currentLink.state.decorations.pointerCursor&&o.classList.add("xterm-cursor-pointer")),h.hover&&h.hover(d,h.text)}_fireUnderlineEvent(o,h){const d=o.range,u=this._bufferService.buffer.ydisp,x=this._createLinkUnderlineEvent(d.start.x-1,d.start.y-u-1,d.end.x,d.end.y-u-1,void 0);(h?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(x)}_linkLeave(o,h,d){var u;!((u=this._currentLink)===null||u===void 0)&&u.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(h,!1),this._currentLink.state.decorations.pointerCursor&&o.classList.remove("xterm-cursor-pointer")),h.leave&&h.leave(d,h.text)}_linkAtPosition(o,h){const d=o.range.start.y*this._bufferService.cols+o.range.start.x,u=o.range.end.y*this._bufferService.cols+o.range.end.x,x=h.y*this._bufferService.cols+h.x;return d<=x&&x<=u}_positionFromMouseEvent(o,h,d){const u=d.getCoords(o,h,this._bufferService.cols,this._bufferService.rows);if(u)return{x:u[0],y:u[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(o,h,d,u,x){return{x1:o,y1:h,x2:d,y2:u,cols:this._bufferService.cols,fg:x}}};i.Linkifier2=_=c([f(0,y.IBufferService)],_)},9042:(v,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(v,i,n){var c=this&&this.__decorate||function(_,o,h,d){var u,x=arguments.length,S=x<3?o:d===null?d=Object.getOwnPropertyDescriptor(o,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(_,o,h,d);else for(var k=_.length-1;k>=0;k--)(u=_[k])&&(S=(x<3?u(S):x>3?u(o,h,S):u(o,h))||S);return x>3&&S&&Object.defineProperty(o,h,S),S},f=this&&this.__param||function(_,o){return function(h,d){o(h,d,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkProvider=void 0;const l=n(511),g=n(2585);let b=i.OscLinkProvider=class{constructor(_,o,h){this._bufferService=_,this._optionsService=o,this._oscLinkService=h}provideLinks(_,o){var h;const d=this._bufferService.buffer.lines.get(_-1);if(!d)return void o(void 0);const u=[],x=this._optionsService.rawOptions.linkHandler,S=new l.CellData,k=d.getTrimmedLength();let E=-1,w=-1,j=!1;for(let R=0;R<k;R++)if(w!==-1||d.hasContent(R)){if(d.loadCell(R,S),S.hasExtendedAttrs()&&S.extended.urlId){if(w===-1){w=R,E=S.extended.urlId;continue}j=S.extended.urlId!==E}else w!==-1&&(j=!0);if(j||w!==-1&&R===k-1){const L=(h=this._oscLinkService.getLinkData(E))===null||h===void 0?void 0:h.uri;if(L){const D={start:{x:w+1,y:_},end:{x:R+(j||R!==k-1?0:1),y:_}};let N=!1;if(!x?.allowNonHttpProtocols)try{const M=new URL(L);["http:","https:"].includes(M.protocol)||(N=!0)}catch{N=!0}N||u.push({text:L,range:D,activate:(M,O)=>x?x.activate(M,O,D):y(0,O),hover:(M,O)=>{var F;return(F=x?.hover)===null||F===void 0?void 0:F.call(x,M,O,D)},leave:(M,O)=>{var F;return(F=x?.leave)===null||F===void 0?void 0:F.call(x,M,O,D)}})}j=!1,S.hasExtendedAttrs()&&S.extended.urlId?(w=R,E=S.extended.urlId):(w=-1,E=-1)}}o(u)}};function y(_,o){if(confirm(`Do you want to navigate to ${o}?
21
+
22
+ WARNING: This link could potentially be dangerous`)){const h=window.open();if(h){try{h.opener=null}catch{}h.location.href=o}else console.warn("Opening link blocked as opener could not be cleared")}}i.OscLinkProvider=b=c([f(0,g.IBufferService),f(1,g.IOptionsService),f(2,g.IOscLinkService)],b)},6193:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.RenderDebouncer=void 0,i.RenderDebouncer=class{constructor(n,c){this._parentWindow=n,this._renderCallback=c,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,c,f){this._rowCount=f,n=n!==void 0?n:0,c=c!==void 0?c: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,c):c,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),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,c),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(const n of this._refreshCallbacks)n(0);this._refreshCallbacks=[]}}},5596:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ScreenDprMonitor=void 0;const c=n(844);class f extends c.Disposable{constructor(g){super(),this._parentWindow=g,this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this.register((0,c.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=f},3236:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Terminal=void 0;const c=n(3614),f=n(3656),l=n(6465),g=n(9042),b=n(3730),y=n(1680),_=n(3107),o=n(5744),h=n(2950),d=n(1296),u=n(428),x=n(4269),S=n(5114),k=n(8934),E=n(3230),w=n(9312),j=n(4725),R=n(6731),L=n(8055),D=n(8969),N=n(8460),M=n(844),O=n(6114),F=n(8437),z=n(2584),A=n(7399),P=n(5941),I=n(9074),B=n(2585),$=n(5435),X=n(4567),Z=typeof window<"u"?window.document:null;class J extends D.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(T={}){super(T),this.browser=O,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this.register(new M.MutableDisposable),this._onCursorMove=this.register(new N.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onKey=this.register(new N.EventEmitter),this.onKey=this._onKey.event,this._onRender=this.register(new N.EventEmitter),this.onRender=this._onRender.event,this._onSelectionChange=this.register(new N.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this.register(new N.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onBell=this.register(new N.EventEmitter),this.onBell=this._onBell.event,this._onFocus=this.register(new N.EventEmitter),this._onBlur=this.register(new N.EventEmitter),this._onA11yCharEmitter=this.register(new N.EventEmitter),this._onA11yTabEmitter=this.register(new N.EventEmitter),this._onWillOpen=this.register(new N.EventEmitter),this._setup(),this.linkifier2=this.register(this._instantiationService.createInstance(l.Linkifier2)),this.linkifier2.registerLinkProvider(this._instantiationService.createInstance(b.OscLinkProvider)),this._decorationService=this._instantiationService.createInstance(I.DecorationService),this._instantiationService.setService(B.IDecorationService,this._decorationService),this.register(this._inputHandler.onRequestBell((()=>this._onBell.fire()))),this.register(this._inputHandler.onRequestRefreshRows(((H,U)=>this.refresh(H,U)))),this.register(this._inputHandler.onRequestSendFocus((()=>this._reportFocus()))),this.register(this._inputHandler.onRequestReset((()=>this.reset()))),this.register(this._inputHandler.onRequestWindowsOptionsReport((H=>this._reportWindowsOptions(H)))),this.register(this._inputHandler.onColor((H=>this._handleColorEvent(H)))),this.register((0,N.forwardEvent)(this._inputHandler.onCursorMove,this._onCursorMove)),this.register((0,N.forwardEvent)(this._inputHandler.onTitleChange,this._onTitleChange)),this.register((0,N.forwardEvent)(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this.register((0,N.forwardEvent)(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this.register(this._bufferService.onResize((H=>this._afterResize(H.cols,H.rows)))),this.register((0,M.toDisposable)((()=>{var H,U;this._customKeyEventHandler=void 0,(U=(H=this.element)===null||H===void 0?void 0:H.parentNode)===null||U===void 0||U.removeChild(this.element)})))}_handleColorEvent(T){if(this._themeService)for(const H of T){let U,W="";switch(H.index){case 256:U="foreground",W="10";break;case 257:U="background",W="11";break;case 258:U="cursor",W="12";break;default:U="ansi",W="4;"+H.index}switch(H.type){case 0:const te=L.color.toColorRGB(U==="ansi"?this._themeService.colors.ansi[H.index]:this._themeService.colors[U]);this.coreService.triggerDataEvent(`${z.C0.ESC}]${W};${(0,P.toRgbString)(te)}${z.C1_ESCAPED.ST}`);break;case 1:if(U==="ansi")this._themeService.modifyColors((K=>K.ansi[H.index]=L.rgba.toColor(...H.color)));else{const K=U;this._themeService.modifyColors((ce=>ce[K]=L.rgba.toColor(...H.color)))}break;case 2:this._themeService.restoreColor(H.index)}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(T){T?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(X.AccessibilityManager,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(T){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.C0.ESC+"[I"),this.updateCursorStyle(T),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var T;return(T=this.textarea)===null||T===void 0?void 0:T.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(z.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 T=this.buffer.ybase+this.buffer.y,H=this.buffer.lines.get(T);if(!H)return;const U=Math.min(this.buffer.x,this.cols-1),W=this._renderService.dimensions.css.cell.height,te=H.getWidth(U),K=this._renderService.dimensions.css.cell.width*te,ce=this.buffer.y*this._renderService.dimensions.css.cell.height,he=U*this._renderService.dimensions.css.cell.width;this.textarea.style.left=he+"px",this.textarea.style.top=ce+"px",this.textarea.style.width=K+"px",this.textarea.style.height=W+"px",this.textarea.style.lineHeight=W+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this.register((0,f.addDisposableDomListener)(this.element,"copy",(H=>{this.hasSelection()&&(0,c.copyHandler)(H,this._selectionService)})));const T=H=>(0,c.handlePasteEvent)(H,this.textarea,this.coreService,this.optionsService);this.register((0,f.addDisposableDomListener)(this.textarea,"paste",T)),this.register((0,f.addDisposableDomListener)(this.element,"paste",T)),O.isFirefox?this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(H=>{H.button===2&&(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))):this.register((0,f.addDisposableDomListener)(this.element,"contextmenu",(H=>{(0,c.rightClickHandler)(H,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)}))),O.isLinux&&this.register((0,f.addDisposableDomListener)(this.element,"auxclick",(H=>{H.button===1&&(0,c.moveTextAreaUnderMouseCursor)(H,this.textarea,this.screenElement)})))}_bindKeys(){this.register((0,f.addDisposableDomListener)(this.textarea,"keyup",(T=>this._keyUp(T)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keydown",(T=>this._keyDown(T)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"keypress",(T=>this._keyPress(T)),!0)),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionstart",(()=>this._compositionHelper.compositionstart()))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionupdate",(T=>this._compositionHelper.compositionupdate(T)))),this.register((0,f.addDisposableDomListener)(this.textarea,"compositionend",(()=>this._compositionHelper.compositionend()))),this.register((0,f.addDisposableDomListener)(this.textarea,"input",(T=>this._inputEvent(T)),!0)),this.register(this.onRender((()=>this._compositionHelper.updateCompositionElements())))}open(T){var H;if(!T)throw new Error("Terminal requires a parent element.");T.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),this._document=T.ownerDocument,this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),T.appendChild(this.element);const U=Z.createDocumentFragment();this._viewportElement=Z.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),U.appendChild(this._viewportElement),this._viewportScrollArea=Z.createElement("div"),this._viewportScrollArea.classList.add("xterm-scroll-area"),this._viewportElement.appendChild(this._viewportScrollArea),this.screenElement=Z.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._helperContainer=Z.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),U.appendChild(this.screenElement),this.textarea=Z.createElement("textarea"),this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",g.promptLabel),O.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(S.CoreBrowserService,this.textarea,(H=this._document.defaultView)!==null&&H!==void 0?H:window),this._instantiationService.setService(j.ICoreBrowserService,this._coreBrowserService),this.register((0,f.addDisposableDomListener)(this.textarea,"focus",(W=>this._handleTextAreaFocus(W)))),this.register((0,f.addDisposableDomListener)(this.textarea,"blur",(()=>this._handleTextAreaBlur()))),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(u.CharSizeService,this._document,this._helperContainer),this._instantiationService.setService(j.ICharSizeService,this._charSizeService),this._themeService=this._instantiationService.createInstance(R.ThemeService),this._instantiationService.setService(j.IThemeService,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(x.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((W=>this._onRender.fire(W)))),this.onResize((W=>this._renderService.resize(W.cols,W.rows))),this._compositionView=Z.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(h.CompositionHelper,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this.element.appendChild(U);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(y.Viewport,this._viewportElement,this._viewportScrollArea),this.viewport.onRequestScrollLines((W=>this.scrollLines(W.amount,W.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(w.SelectionService,this.element,this.screenElement,this.linkifier2)),this._instantiationService.setService(j.ISelectionService,this._selectionService),this.register(this._selectionService.onRequestScrollLines((W=>this.scrollLines(W.amount,W.suppressScrollEvent)))),this.register(this._selectionService.onSelectionChange((()=>this._onSelectionChange.fire()))),this.register(this._selectionService.onRequestRedraw((W=>this._renderService.handleSelectionChanged(W.start,W.end,W.columnSelectMode)))),this.register(this._selectionService.onLinuxMouseSelection((W=>{this.textarea.value=W,this.textarea.focus(),this.textarea.select()}))),this.register(this._onScroll.event((W=>{this.viewport.syncScrollArea(),this._selectionService.refresh()}))),this.register((0,f.addDisposableDomListener)(this._viewportElement,"scroll",(()=>this._selectionService.refresh()))),this.linkifier2.attachToDom(this.screenElement,this._mouseService,this._renderService),this.register(this._instantiationService.createInstance(_.BufferDecorationRenderer,this.screenElement)),this.register((0,f.addDisposableDomListener)(this.element,"mousedown",(W=>this._selectionService.handleMouseDown(W)))),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(X.AccessibilityManager,this)),this.register(this.optionsService.onSpecificOptionChange("screenReaderMode",(W=>this._handleScreenReaderModeOptionChange(W)))),this.options.overviewRulerWidth&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(o.OverviewRulerRenderer,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRulerWidth",(W=>{!this._overviewRulerRenderer&&W&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this.register(this._instantiationService.createInstance(o.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 T=this,H=this.element;function U(K){const ce=T._mouseService.getMouseReportCoords(K,T.screenElement);if(!ce)return!1;let he,ve;switch(K.overrideType||K.type){case"mousemove":ve=32,K.buttons===void 0?(he=3,K.button!==void 0&&(he=K.button<3?K.button:3)):he=1&K.buttons?0:4&K.buttons?1:2&K.buttons?2:3;break;case"mouseup":ve=0,he=K.button<3?K.button:3;break;case"mousedown":ve=1,he=K.button<3?K.button:3;break;case"wheel":if(T.viewport.getLinesScrolled(K)===0)return!1;ve=K.deltaY<0?0:1,he=4;break;default:return!1}return!(ve===void 0||he===void 0||he>4)&&T.coreMouseService.triggerMouseEvent({col:ce.col,row:ce.row,x:ce.x,y:ce.y,button:he,action:ve,ctrl:K.ctrlKey,alt:K.altKey,shift:K.shiftKey})}const W={mouseup:null,wheel:null,mousedrag:null,mousemove:null},te={mouseup:K=>(U(K),K.buttons||(this._document.removeEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.removeEventListener("mousemove",W.mousedrag)),this.cancel(K)),wheel:K=>(U(K),this.cancel(K,!0)),mousedrag:K=>{K.buttons&&U(K)},mousemove:K=>{K.buttons||U(K)}};this.register(this.coreMouseService.onProtocolChange((K=>{K?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(K)),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&K?W.mousemove||(H.addEventListener("mousemove",te.mousemove),W.mousemove=te.mousemove):(H.removeEventListener("mousemove",W.mousemove),W.mousemove=null),16&K?W.wheel||(H.addEventListener("wheel",te.wheel,{passive:!1}),W.wheel=te.wheel):(H.removeEventListener("wheel",W.wheel),W.wheel=null),2&K?W.mouseup||(H.addEventListener("mouseup",te.mouseup),W.mouseup=te.mouseup):(this._document.removeEventListener("mouseup",W.mouseup),H.removeEventListener("mouseup",W.mouseup),W.mouseup=null),4&K?W.mousedrag||(W.mousedrag=te.mousedrag):(this._document.removeEventListener("mousemove",W.mousedrag),W.mousedrag=null)}))),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this.register((0,f.addDisposableDomListener)(H,"mousedown",(K=>{if(K.preventDefault(),this.focus(),this.coreMouseService.areMouseEventsActive&&!this._selectionService.shouldForceSelection(K))return U(K),W.mouseup&&this._document.addEventListener("mouseup",W.mouseup),W.mousedrag&&this._document.addEventListener("mousemove",W.mousedrag),this.cancel(K)}))),this.register((0,f.addDisposableDomListener)(H,"wheel",(K=>{if(!W.wheel){if(!this.buffer.hasScrollback){const ce=this.viewport.getLinesScrolled(K);if(ce===0)return;const he=z.C0.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(K.deltaY<0?"A":"B");let ve="";for(let Fe=0;Fe<Math.abs(ce);Fe++)ve+=he;return this.coreService.triggerDataEvent(ve,!0),this.cancel(K,!0)}return this.viewport.handleWheel(K)?this.cancel(K):void 0}}),{passive:!1})),this.register((0,f.addDisposableDomListener)(H,"touchstart",(K=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchStart(K),this.cancel(K)}),{passive:!0})),this.register((0,f.addDisposableDomListener)(H,"touchmove",(K=>{if(!this.coreMouseService.areMouseEventsActive)return this.viewport.handleTouchMove(K)?void 0:this.cancel(K)}),{passive:!1}))}refresh(T,H){var U;(U=this._renderService)===null||U===void 0||U.refreshRows(T,H)}updateCursorStyle(T){var H;!((H=this._selectionService)===null||H===void 0)&&H.shouldColumnSelect(T)?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(T,H,U=0){var W;U===1?(super.scrollLines(T,H,U),this.refresh(0,this.rows-1)):(W=this.viewport)===null||W===void 0||W.scrollLines(T)}paste(T){(0,c.paste)(T,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(T){this._customKeyEventHandler=T}registerLinkProvider(T){return this.linkifier2.registerLinkProvider(T)}registerCharacterJoiner(T){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");const H=this._characterJoinerService.register(T);return this.refresh(0,this.rows-1),H}deregisterCharacterJoiner(T){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(T)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(T){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+T)}registerDecoration(T){return this._decorationService.registerDecoration(T)}hasSelection(){return!!this._selectionService&&this._selectionService.hasSelection}select(T,H,U){this._selectionService.setSelection(T,H,U)}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 T;(T=this._selectionService)===null||T===void 0||T.clearSelection()}selectAll(){var T;(T=this._selectionService)===null||T===void 0||T.selectAll()}selectLines(T,H){var U;(U=this._selectionService)===null||U===void 0||U.selectLines(T,H)}_keyDown(T){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1)return!1;const H=this.browser.isMac&&this.options.macOptionIsMeta&&T.altKey;if(!H&&!this._compositionHelper.keydown(T))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(),!1;H||T.key!=="Dead"&&T.key!=="AltGraph"||(this._unprocessedDeadKey=!0);const U=(0,A.evaluateKeyboardEvent)(T,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(T),U.type===3||U.type===2){const W=this.rows-1;return this.scrollLines(U.type===2?-W:W),this.cancel(T,!0)}return U.type===1&&this.selectAll(),!!this._isThirdLevelShift(this.browser,T)||(U.cancel&&this.cancel(T,!0),!U.key||!!(T.key&&!T.ctrlKey&&!T.altKey&&!T.metaKey&&T.key.length===1&&T.key.charCodeAt(0)>=65&&T.key.charCodeAt(0)<=90)||(this._unprocessedDeadKey?(this._unprocessedDeadKey=!1,!0):(U.key!==z.C0.ETX&&U.key!==z.C0.CR||(this.textarea.value=""),this._onKey.fire({key:U.key,domEvent:T}),this._showCursor(),this.coreService.triggerDataEvent(U.key,!0),!this.optionsService.rawOptions.screenReaderMode||T.altKey||T.ctrlKey?this.cancel(T,!0):void(this._keyDownHandled=!0))))}_isThirdLevelShift(T,H){const U=T.isMac&&!this.options.macOptionIsMeta&&H.altKey&&!H.ctrlKey&&!H.metaKey||T.isWindows&&H.altKey&&H.ctrlKey&&!H.metaKey||T.isWindows&&H.getModifierState("AltGraph");return H.type==="keypress"?U:U&&(!H.keyCode||H.keyCode>47)}_keyUp(T){this._keyDownSeen=!1,this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1||((function(H){return H.keyCode===16||H.keyCode===17||H.keyCode===18})(T)||this.focus(),this.updateCursorStyle(T),this._keyPressHandled=!1)}_keyPress(T){let H;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(T)===!1)return!1;if(this.cancel(T),T.charCode)H=T.charCode;else if(T.which===null||T.which===void 0)H=T.keyCode;else{if(T.which===0||T.charCode===0)return!1;H=T.which}return!(!H||(T.altKey||T.ctrlKey||T.metaKey)&&!this._isThirdLevelShift(this.browser,T)||(H=String.fromCharCode(H),this._onKey.fire({key:H,domEvent:T}),this._showCursor(),this.coreService.triggerDataEvent(H,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,0))}_inputEvent(T){if(T.data&&T.inputType==="insertText"&&(!T.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;const H=T.data;return this.coreService.triggerDataEvent(H,!0),this.cancel(T),!0}return!1}resize(T,H){T!==this.cols||H!==this.rows?super.resize(T,H):this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure()}_afterResize(T,H){var U,W;(U=this._charSizeService)===null||U===void 0||U.measure(),(W=this.viewport)===null||W===void 0||W.syncScrollArea(!0)}clear(){var T;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 H=1;H<this.rows;H++)this.buffer.lines.push(this.buffer.getBlankLine(F.DEFAULT_ATTR_DATA));this._onScroll.fire({position:this.buffer.ydisp,source:0}),(T=this.viewport)===null||T===void 0||T.reset(),this.refresh(0,this.rows-1)}}reset(){var T,H;this.options.rows=this.rows,this.options.cols=this.cols;const U=this._customKeyEventHandler;this._setup(),super.reset(),(T=this._selectionService)===null||T===void 0||T.reset(),this._decorationService.reset(),(H=this.viewport)===null||H===void 0||H.reset(),this._customKeyEventHandler=U,this.refresh(0,this.rows-1)}clearTextureAtlas(){var T;(T=this._renderService)===null||T===void 0||T.clearTextureAtlas()}_reportFocus(){var T;!((T=this.element)===null||T===void 0)&&T.classList.contains("focus")?this.coreService.triggerDataEvent(z.C0.ESC+"[I"):this.coreService.triggerDataEvent(z.C0.ESC+"[O")}_reportWindowsOptions(T){if(this._renderService)switch(T){case $.WindowsOptionsReportType.GET_WIN_SIZE_PIXELS:const H=this._renderService.dimensions.css.canvas.width.toFixed(0),U=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[4;${U};${H}t`);break;case $.WindowsOptionsReportType.GET_CELL_SIZE_PIXELS:const W=this._renderService.dimensions.css.cell.width.toFixed(0),te=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${z.C0.ESC}[6;${te};${W}t`)}}cancel(T,H){if(this.options.cancelEvents||H)return T.preventDefault(),T.stopPropagation(),!1}}i.Terminal=J},9924:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TimeBasedDebouncer=void 0,i.TimeBasedDebouncer=class{constructor(n,c=1e3){this._renderCallback=n,this._debounceThresholdMS=c,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(n,c,f){this._rowCount=f,n=n!==void 0?n:0,c=c!==void 0?c: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,c):c;const l=Date.now();if(l-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=l,this._innerRefresh();else if(!this._additionalRefreshRequested){const g=l-this._lastRefreshMs,b=this._debounceThresholdMS-g;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout((()=>{this._lastRefreshMs=Date.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0}),b)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;const n=Math.max(this._rowStart,0),c=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(n,c)}}},1680:function(v,i,n){var c=this&&this.__decorate||function(h,d,u,x){var S,k=arguments.length,E=k<3?d:x===null?x=Object.getOwnPropertyDescriptor(d,u):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,u,x);else for(var w=h.length-1;w>=0;w--)(S=h[w])&&(E=(k<3?S(E):k>3?S(d,u,E):S(d,u))||E);return k>3&&E&&Object.defineProperty(d,u,E),E},f=this&&this.__param||function(h,d){return function(u,x){d(u,x,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.Viewport=void 0;const l=n(3656),g=n(4725),b=n(8460),y=n(844),_=n(2585);let o=i.Viewport=class extends y.Disposable{constructor(h,d,u,x,S,k,E,w){super(),this._viewportElement=h,this._scrollArea=d,this._bufferService=u,this._optionsService=x,this._charSizeService=S,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 b.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this.scrollBarWidth=this._viewportElement.offsetWidth-this._scrollArea.offsetWidth||15,this.register((0,l.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(w.colors),this.register(w.onChangeColors((j=>this._handleThemeChange(j)))),this.register(this._optionsService.onSpecificOptionChange("scrollback",(()=>this.syncScrollArea()))),setTimeout((()=>this.syncScrollArea()))}_handleThemeChange(h){this._viewportElement.style.backgroundColor=h.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(h){if(h)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 h=this._bufferService.buffer.ydisp*this._currentRowHeight;this._viewportElement.scrollTop!==h&&(this._ignoreNextScrollEvent=!0,this._viewportElement.scrollTop=h),this._refreshAnimationFrame=null}syncScrollArea(h=!1){if(this._lastRecordedBufferLength!==this._bufferService.buffer.lines.length)return this._lastRecordedBufferLength=this._bufferService.buffer.lines.length,void this._refresh(h);this._lastRecordedViewportHeight===this._renderService.dimensions.css.canvas.height&&this._lastScrollTop===this._activeBuffer.ydisp*this._currentRowHeight&&this._renderDimensions.device.cell.height===this._currentDeviceCellHeight||this._refresh(h)}_handleScroll(h){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 h=this._smoothScrollPercent();this._viewportElement.scrollTop=this._smoothScrollState.origin+Math.round(h*(this._smoothScrollState.target-this._smoothScrollState.origin)),h<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(h,d){const u=this._viewportElement.scrollTop+this._lastRecordedViewportHeight;return!(d<0&&this._viewportElement.scrollTop!==0||d>0&&u<this._lastRecordedBufferHeight)||(h.cancelable&&h.preventDefault(),!1)}handleWheel(h){const d=this._getPixelsScrolled(h);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(h,d))}scrollLines(h){if(h!==0)if(this._optionsService.rawOptions.smoothScrollDuration){const d=h*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:h,suppressScrollEvent:!1})}_getPixelsScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.deltaMode===WheelEvent.DOM_DELTA_LINE?d*=this._currentRowHeight:h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._currentRowHeight*this._bufferService.rows),d}getBufferElements(h,d){var u;let x,S="";const k=[],E=d??this._bufferService.buffer.lines.length,w=this._bufferService.buffer.lines;for(let j=h;j<E;j++){const R=w.get(j);if(!R)continue;const L=(u=w.get(j+1))===null||u===void 0?void 0:u.isWrapped;if(S+=R.translateToString(!L),!L||j===w.length-1){const D=document.createElement("div");D.textContent=S,k.push(D),S.length>0&&(x=D),S=""}}return{bufferElements:k,cursorElement:x}}getLinesScrolled(h){if(h.deltaY===0||h.shiftKey)return 0;let d=this._applyScrollModifier(h.deltaY,h);return h.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):h.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(d*=this._bufferService.rows),d}_applyScrollModifier(h,d){const u=this._optionsService.rawOptions.fastScrollModifier;return u==="alt"&&d.altKey||u==="ctrl"&&d.ctrlKey||u==="shift"&&d.shiftKey?h*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:h*this._optionsService.rawOptions.scrollSensitivity}handleTouchStart(h){this._lastTouchY=h.touches[0].pageY}handleTouchMove(h){const d=this._lastTouchY-h.touches[0].pageY;return this._lastTouchY=h.touches[0].pageY,d!==0&&(this._viewportElement.scrollTop+=d,this._bubbleScroll(h,d))}};i.Viewport=o=c([f(2,_.IBufferService),f(3,_.IOptionsService),f(4,g.ICharSizeService),f(5,g.IRenderService),f(6,g.ICoreBrowserService),f(7,g.IThemeService)],o)},3107:function(v,i,n){var c=this&&this.__decorate||function(o,h,d,u){var x,S=arguments.length,k=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(o,h,d,u);else for(var E=o.length-1;E>=0;E--)(x=o[E])&&(k=(S<3?x(k):S>3?x(h,d,k):x(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(o,h){return function(d,u){h(d,u,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferDecorationRenderer=void 0;const l=n(3656),g=n(4725),b=n(844),y=n(2585);let _=i.BufferDecorationRenderer=class extends b.Disposable{constructor(o,h,d,u){super(),this._screenElement=o,this._bufferService=h,this._decorationService=d,this._renderService=u,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,l.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((x=>this._removeDecoration(x)))),this.register((0,b.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 o of this._decorationService.decorations)this._renderDecoration(o);this._dimensionsChanged=!1}_renderDecoration(o){this._refreshStyle(o),this._dimensionsChanged&&this._refreshXPosition(o)}_createElement(o){var h,d;const u=document.createElement("div");u.classList.add("xterm-decoration"),u.classList.toggle("xterm-decoration-top-layer",((h=o?.options)===null||h===void 0?void 0:h.layer)==="top"),u.style.width=`${Math.round((o.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,u.style.height=(o.options.height||1)*this._renderService.dimensions.css.cell.height+"px",u.style.top=(o.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height+"px",u.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;const x=(d=o.options.x)!==null&&d!==void 0?d:0;return x&&x>this._bufferService.cols&&(u.style.display="none"),this._refreshXPosition(o,u),u}_refreshStyle(o){const h=o.marker.line-this._bufferService.buffers.active.ydisp;if(h<0||h>=this._bufferService.rows)o.element&&(o.element.style.display="none",o.onRenderEmitter.fire(o.element));else{let d=this._decorationElements.get(o);d||(d=this._createElement(o),o.element=d,this._decorationElements.set(o,d),this._container.appendChild(d),o.onDispose((()=>{this._decorationElements.delete(o),d.remove()}))),d.style.top=h*this._renderService.dimensions.css.cell.height+"px",d.style.display=this._altBufferIsActive?"none":"block",o.onRenderEmitter.fire(d)}}_refreshXPosition(o,h=o.element){var d;if(!h)return;const u=(d=o.options.x)!==null&&d!==void 0?d:0;(o.options.anchor||"left")==="right"?h.style.right=u?u*this._renderService.dimensions.css.cell.width+"px":"":h.style.left=u?u*this._renderService.dimensions.css.cell.width+"px":""}_removeDecoration(o){var h;(h=this._decorationElements.get(o))===null||h===void 0||h.remove(),this._decorationElements.delete(o),o.dispose()}};i.BufferDecorationRenderer=_=c([f(1,y.IBufferService),f(2,y.IDecorationService),f(3,g.IRenderService)],_)},5871:(v,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 c of this._zones)if(c.color===n.options.overviewRulerOptions.color&&c.position===n.options.overviewRulerOptions.position){if(this._lineIntersectsZone(c,n.marker.line))return;if(this._lineAdjacentToZone(c,n.marker.line,n.options.overviewRulerOptions.position))return void this._addLineToZone(c,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,c){return c>=n.startBufferLine&&c<=n.endBufferLine}_lineAdjacentToZone(n,c,f){return c>=n.startBufferLine-this._linePadding[f||"full"]&&c<=n.endBufferLine+this._linePadding[f||"full"]}_addLineToZone(n,c){n.startBufferLine=Math.min(n.startBufferLine,c),n.endBufferLine=Math.max(n.endBufferLine,c)}}},5744:function(v,i,n){var c=this&&this.__decorate||function(x,S,k,E){var w,j=arguments.length,R=j<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(x,S,k,E);else for(var L=x.length-1;L>=0;L--)(w=x[L])&&(R=(j<3?w(R):j>3?w(S,k,R):w(S,k))||R);return j>3&&R&&Object.defineProperty(S,k,R),R},f=this&&this.__param||function(x,S){return function(k,E){S(k,E,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OverviewRulerRenderer=void 0;const l=n(5871),g=n(3656),b=n(4725),y=n(844),_=n(2585),o={full:0,left:0,center:0,right:0},h={full:0,left:0,center:0,right:0},d={full:0,left:0,center:0,right:0};let u=i.OverviewRulerRenderer=class extends y.Disposable{get _width(){return this._optionsService.options.overviewRulerWidth||0}constructor(x,S,k,E,w,j,R){var L;super(),this._viewportElement=x,this._screenElement=S,this._bufferService=k,this._decorationService=E,this._renderService=w,this._optionsService=j,this._coreBrowseService=R,this._colorZoneStore=new l.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(),(L=this._viewportElement.parentElement)===null||L===void 0||L.insertBefore(this._canvas,this._viewportElement);const D=this._canvas.getContext("2d");if(!D)throw new Error("Ctx cannot be null");this._ctx=D,this._registerDecorationListeners(),this._registerBufferChangeListeners(),this._registerDimensionChangeListeners(),this.register((0,y.toDisposable)((()=>{var N;(N=this._canvas)===null||N===void 0||N.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 x=Math.floor(this._canvas.width/3),S=Math.ceil(this._canvas.width/3);h.full=this._canvas.width,h.left=x,h.center=S,h.right=x,this._refreshDrawHeightConstants(),d.full=0,d.left=0,d.center=h.left,d.right=h.left+h.center}_refreshDrawHeightConstants(){o.full=Math.round(2*this._coreBrowseService.dpr);const x=this._canvas.height/this._bufferService.buffer.lines.length,S=Math.round(Math.max(Math.min(x,12),6)*this._coreBrowseService.dpr);o.left=S,o.center=S,o.right=S}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*o.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 S of this._decorationService.decorations)this._colorZoneStore.addDecoration(S);this._ctx.lineWidth=1;const x=this._colorZoneStore.zones;for(const S of x)S.position!=="full"&&this._renderColorZone(S);for(const S of x)S.position==="full"&&this._renderColorZone(S);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderColorZone(x){this._ctx.fillStyle=x.color,this._ctx.fillRect(d[x.position||"full"],Math.round((this._canvas.height-1)*(x.startBufferLine/this._bufferService.buffers.active.lines.length)-o[x.position||"full"]/2),h[x.position||"full"],Math.round((this._canvas.height-1)*((x.endBufferLine-x.startBufferLine)/this._bufferService.buffers.active.lines.length)+o[x.position||"full"]))}_queueRefresh(x,S){this._shouldUpdateDimensions=x||this._shouldUpdateDimensions,this._shouldUpdateAnchor=S||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowseService.window.requestAnimationFrame((()=>{this._refreshDecorations(),this._animationFrame=void 0})))}};i.OverviewRulerRenderer=u=c([f(2,_.IBufferService),f(3,_.IDecorationService),f(4,b.IRenderService),f(5,_.IOptionsService),f(6,b.ICoreBrowserService)],u)},2950:function(v,i,n){var c=this&&this.__decorate||function(_,o,h,d){var u,x=arguments.length,S=x<3?o:d===null?d=Object.getOwnPropertyDescriptor(o,h):d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")S=Reflect.decorate(_,o,h,d);else for(var k=_.length-1;k>=0;k--)(u=_[k])&&(S=(x<3?u(S):x>3?u(o,h,S):u(o,h))||S);return x>3&&S&&Object.defineProperty(o,h,S),S},f=this&&this.__param||function(_,o){return function(h,d){o(h,d,_)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CompositionHelper=void 0;const l=n(4725),g=n(2585),b=n(2584);let y=i.CompositionHelper=class{get isComposing(){return this._isComposing}constructor(_,o,h,d,u,x){this._textarea=_,this._compositionView=o,this._bufferService=h,this._optionsService=d,this._coreService=u,this._renderService=x,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(_){this._compositionView.textContent=_.data,this.updateCompositionElements(),setTimeout((()=>{this._compositionPosition.end=this._textarea.value.length}),0)}compositionend(){this._finalizeComposition(!0)}keydown(_){if(this._isComposing||this._isSendingComposition){if(_.keyCode===229||_.keyCode===16||_.keyCode===17||_.keyCode===18)return!1;this._finalizeComposition(!1)}return _.keyCode!==229||(this._handleAnyTextareaChanges(),!1)}_finalizeComposition(_){if(this._compositionView.classList.remove("active"),this._isComposing=!1,_){const o={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout((()=>{if(this._isSendingComposition){let h;this._isSendingComposition=!1,o.start+=this._dataAlreadySent.length,h=this._isComposing?this._textarea.value.substring(o.start,o.end):this._textarea.value.substring(o.start),h.length>0&&this._coreService.triggerDataEvent(h,!0)}}),0)}else{this._isSendingComposition=!1;const o=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(o,!0)}}_handleAnyTextareaChanges(){const _=this._textarea.value;setTimeout((()=>{if(!this._isComposing){const o=this._textarea.value,h=o.replace(_,"");this._dataAlreadySent=h,o.length>_.length?this._coreService.triggerDataEvent(h,!0):o.length<_.length?this._coreService.triggerDataEvent(`${b.C0.DEL}`,!0):o.length===_.length&&o!==_&&this._coreService.triggerDataEvent(o,!0)}}),0)}updateCompositionElements(_){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){const o=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),h=this._renderService.dimensions.css.cell.height,d=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,u=o*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=u+"px",this._compositionView.style.top=d+"px",this._compositionView.style.height=h+"px",this._compositionView.style.lineHeight=h+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";const x=this._compositionView.getBoundingClientRect();this._textarea.style.left=u+"px",this._textarea.style.top=d+"px",this._textarea.style.width=Math.max(x.width,1)+"px",this._textarea.style.height=Math.max(x.height,1)+"px",this._textarea.style.lineHeight=x.height+"px"}_||setTimeout((()=>this.updateCompositionElements(!0)),0)}}};i.CompositionHelper=y=c([f(2,g.IBufferService),f(3,g.IOptionsService),f(4,g.ICoreService),f(5,l.IRenderService)],y)},9806:(v,i)=>{function n(c,f,l){const g=l.getBoundingClientRect(),b=c.getComputedStyle(l),y=parseInt(b.getPropertyValue("padding-left")),_=parseInt(b.getPropertyValue("padding-top"));return[f.clientX-g.left-y,f.clientY-g.top-_]}Object.defineProperty(i,"__esModule",{value:!0}),i.getCoords=i.getCoordsRelativeToElement=void 0,i.getCoordsRelativeToElement=n,i.getCoords=function(c,f,l,g,b,y,_,o,h){if(!y)return;const d=n(c,f,l);return d?(d[0]=Math.ceil((d[0]+(h?_/2:0))/_),d[1]=Math.ceil(d[1]/o),d[0]=Math.min(Math.max(d[0],1),g+(h?1:0)),d[1]=Math.min(Math.max(d[1],1),b),d):void 0}},9504:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.moveToCellSequence=void 0;const c=n(2584);function f(o,h,d,u){const x=o-l(o,d),S=h-l(h,d),k=Math.abs(x-S)-(function(E,w,j){let R=0;const L=E-l(E,j),D=w-l(w,j);for(let N=0;N<Math.abs(L-D);N++){const M=g(E,w)==="A"?-1:1,O=j.buffer.lines.get(L+M*N);O?.isWrapped&&R++}return R})(o,h,d);return _(k,y(g(o,h),u))}function l(o,h){let d=0,u=h.buffer.lines.get(o),x=u?.isWrapped;for(;x&&o>=0&&o<h.rows;)d++,u=h.buffer.lines.get(--o),x=u?.isWrapped;return d}function g(o,h){return o>h?"A":"B"}function b(o,h,d,u,x,S){let k=o,E=h,w="";for(;k!==d||E!==u;)k+=x?1:-1,x&&k>S.cols-1?(w+=S.buffer.translateBufferLineToString(E,!1,o,k),k=0,o=0,E++):!x&&k<0&&(w+=S.buffer.translateBufferLineToString(E,!1,0,o+1),k=S.cols-1,o=k,E--);return w+S.buffer.translateBufferLineToString(E,!1,o,k)}function y(o,h){const d=h?"O":"[";return c.C0.ESC+d+o}function _(o,h){o=Math.floor(o);let d="";for(let u=0;u<o;u++)d+=h;return d}i.moveToCellSequence=function(o,h,d,u){const x=d.buffer.x,S=d.buffer.y;if(!d.buffer.hasScrollback)return(function(w,j,R,L,D,N){return f(j,L,D,N).length===0?"":_(b(w,j,w,j-l(j,D),!1,D).length,y("D",N))})(x,S,0,h,d,u)+f(S,h,d,u)+(function(w,j,R,L,D,N){let M;M=f(j,L,D,N).length>0?L-l(L,D):j;const O=L,F=(function(z,A,P,I,B,$){let X;return X=f(P,I,B,$).length>0?I-l(I,B):A,z<P&&X<=I||z>=P&&X<I?"C":"D"})(w,j,R,L,D,N);return _(b(w,M,R,O,F==="C",D).length,y(F,N))})(x,S,o,h,d,u);let k;if(S===h)return k=x>o?"D":"C",_(Math.abs(x-o),y(k,u));k=S>h?"D":"C";const E=Math.abs(S-h);return _((function(w,j){return j.cols-w})(S>h?o:x,d)+(E-1)*d.cols+1+((S>h?x:o)-1),y(k,u))}},1296:function(v,i,n){var c=this&&this.__decorate||function(D,N,M,O){var F,z=arguments.length,A=z<3?N:O===null?O=Object.getOwnPropertyDescriptor(N,M):O;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")A=Reflect.decorate(D,N,M,O);else for(var P=D.length-1;P>=0;P--)(F=D[P])&&(A=(z<3?F(A):z>3?F(N,M,A):F(N,M))||A);return z>3&&A&&Object.defineProperty(N,M,A),A},f=this&&this.__param||function(D,N){return function(M,O){N(M,O,D)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRenderer=void 0;const l=n(3787),g=n(2550),b=n(2223),y=n(6171),_=n(4725),o=n(8055),h=n(8460),d=n(844),u=n(2585),x="xterm-dom-renderer-owner-",S="xterm-rows",k="xterm-fg-",E="xterm-bg-",w="xterm-focus",j="xterm-selection";let R=1,L=i.DomRenderer=class extends d.Disposable{constructor(D,N,M,O,F,z,A,P,I,B){super(),this._element=D,this._screenElement=N,this._viewportElement=M,this._linkifier2=O,this._charSizeService=z,this._optionsService=A,this._bufferService=P,this._coreBrowserService=I,this._themeService=B,this._terminalClass=R++,this._rowElements=[],this.onRequestRedraw=this.register(new h.EventEmitter).event,this._rowContainer=document.createElement("div"),this._rowContainer.classList.add(S),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,y.createRenderDimensions)(),this._updateDimensions(),this.register(this._optionsService.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._themeService.onChangeColors(($=>this._injectCss($)))),this._injectCss(this._themeService.colors),this._rowFactory=F.createInstance(l.DomRendererRowFactory,document),this._element.classList.add(x+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this.register(this._linkifier2.onShowLinkUnderline(($=>this._handleLinkHover($)))),this.register(this._linkifier2.onHideLinkUnderline(($=>this._handleLinkLeave($)))),this.register((0,d.toDisposable)((()=>{this._element.classList.remove(x+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 D=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*D,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*D),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/D),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/D),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 M of this._rowElements)M.style.width=`${this.dimensions.css.canvas.width}px`,M.style.height=`${this.dimensions.css.cell.height}px`,M.style.lineHeight=`${this.dimensions.css.cell.height}px`,M.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));const N=`${this._terminalSelector} .${S} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=N,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(D){this._themeStyleElement||(this._themeStyleElement=document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let N=`${this._terminalSelector} .${S} { color: ${D.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;N+=`${this._terminalSelector} .${S} .xterm-dim { color: ${o.color.multiplyOpacity(D.foreground,.5).css};}`,N+=`${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;}`,N+="@keyframes blink_box_shadow_"+this._terminalClass+" { 50% { border-bottom-style: hidden; }}",N+="@keyframes blink_block_"+this._terminalClass+` { 0% { background-color: ${D.cursor.css}; color: ${D.cursorAccent.css}; } 50% { background-color: inherit; color: ${D.cursor.css}; }}`,N+=`${this._terminalSelector} .${S}.${w} .xterm-cursor.xterm-cursor-blink:not(.xterm-cursor-block) { animation: blink_box_shadow_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S}.${w} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: blink_block_`+this._terminalClass+` 1s step-end infinite;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-block { background-color: ${D.cursor.css}; color: ${D.cursorAccent.css};}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${D.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${D.cursor.css} inset;}${this._terminalSelector} .${S} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${D.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,N+=`${this._terminalSelector} .${j} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${j} div { position: absolute; background-color: ${D.selectionBackgroundOpaque.css};}${this._terminalSelector} .${j} div { position: absolute; background-color: ${D.selectionInactiveBackgroundOpaque.css};}`;for(const[M,O]of D.ansi.entries())N+=`${this._terminalSelector} .${k}${M} { color: ${O.css}; }${this._terminalSelector} .${k}${M}.xterm-dim { color: ${o.color.multiplyOpacity(O,.5).css}; }${this._terminalSelector} .${E}${M} { background-color: ${O.css}; }`;N+=`${this._terminalSelector} .${k}${b.INVERTED_DEFAULT_COLOR} { color: ${o.color.opaque(D.background).css}; }${this._terminalSelector} .${k}${b.INVERTED_DEFAULT_COLOR}.xterm-dim { color: ${o.color.multiplyOpacity(o.color.opaque(D.background),.5).css}; }${this._terminalSelector} .${E}${b.INVERTED_DEFAULT_COLOR} { background-color: ${D.foreground.css}; }`,this._themeStyleElement.textContent=N}_setDefaultSpacing(){const D=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${D}px`,this._rowFactory.defaultSpacing=D}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(D,N){for(let M=this._rowElements.length;M<=N;M++){const O=document.createElement("div");this._rowContainer.appendChild(O),this._rowElements.push(O)}for(;this._rowElements.length>N;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(D,N){this._refreshRowElements(D,N),this._updateDimensions()}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(w)}handleFocus(){this._rowContainer.classList.add(w),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(D,N,M){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(D,N,M),this.renderRows(0,this._bufferService.rows-1),!D||!N)return;const O=D[1]-this._bufferService.buffer.ydisp,F=N[1]-this._bufferService.buffer.ydisp,z=Math.max(O,0),A=Math.min(F,this._bufferService.rows-1);if(z>=this._bufferService.rows||A<0)return;const P=document.createDocumentFragment();if(M){const I=D[0]>N[0];P.appendChild(this._createSelectionElement(z,I?N[0]:D[0],I?D[0]:N[0],A-z+1))}else{const I=O===z?D[0]:0,B=z===F?N[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(z,I,B));const $=A-z-1;if(P.appendChild(this._createSelectionElement(z+1,0,this._bufferService.cols,$)),z!==A){const X=F===A?N[0]:this._bufferService.cols;P.appendChild(this._createSelectionElement(A,0,X))}}this._selectionContainer.appendChild(P)}_createSelectionElement(D,N,M,O=1){const F=document.createElement("div");return F.style.height=O*this.dimensions.css.cell.height+"px",F.style.top=D*this.dimensions.css.cell.height+"px",F.style.left=N*this.dimensions.css.cell.width+"px",F.style.width=this.dimensions.css.cell.width*(M-N)+"px",F}handleCursorMove(){}_handleOptionsChanged(){this._updateDimensions(),this._injectCss(this._themeService.colors),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}clear(){for(const D of this._rowElements)D.replaceChildren()}renderRows(D,N){const M=this._bufferService.buffer,O=M.ybase+M.y,F=Math.min(M.x,this._bufferService.cols-1),z=this._optionsService.rawOptions.cursorBlink,A=this._optionsService.rawOptions.cursorStyle,P=this._optionsService.rawOptions.cursorInactiveStyle;for(let I=D;I<=N;I++){const B=I+M.ydisp,$=this._rowElements[I],X=M.lines.get(B);if(!$||!X)break;$.replaceChildren(...this._rowFactory.createRow(X,B,B===O,A,P,F,z,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${x}${this._terminalClass}`}_handleLinkHover(D){this._setCellUnderline(D.x1,D.x2,D.y1,D.y2,D.cols,!0)}_handleLinkLeave(D){this._setCellUnderline(D.x1,D.x2,D.y1,D.y2,D.cols,!1)}_setCellUnderline(D,N,M,O,F,z){M<0&&(D=0),O<0&&(N=0);const A=this._bufferService.rows-1;M=Math.max(Math.min(M,A),0),O=Math.max(Math.min(O,A),0),F=Math.min(F,this._bufferService.cols);const P=this._bufferService.buffer,I=P.ybase+P.y,B=Math.min(P.x,F-1),$=this._optionsService.rawOptions.cursorBlink,X=this._optionsService.rawOptions.cursorStyle,Z=this._optionsService.rawOptions.cursorInactiveStyle;for(let J=M;J<=O;++J){const ae=J+P.ydisp,T=this._rowElements[J],H=P.lines.get(ae);if(!T||!H)break;T.replaceChildren(...this._rowFactory.createRow(H,ae,ae===I,X,Z,B,$,this.dimensions.css.cell.width,this._widthCache,z?J===M?D:0:-1,z?(J===O?N:F)-1:-1))}}};i.DomRenderer=L=c([f(4,u.IInstantiationService),f(5,_.ICharSizeService),f(6,u.IOptionsService),f(7,u.IBufferService),f(8,_.ICoreBrowserService),f(9,_.IThemeService)],L)},3787:function(v,i,n){var c=this&&this.__decorate||function(k,E,w,j){var R,L=arguments.length,D=L<3?E:j===null?j=Object.getOwnPropertyDescriptor(E,w):j;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")D=Reflect.decorate(k,E,w,j);else for(var N=k.length-1;N>=0;N--)(R=k[N])&&(D=(L<3?R(D):L>3?R(E,w,D):R(E,w))||D);return L>3&&D&&Object.defineProperty(E,w,D),D},f=this&&this.__param||function(k,E){return function(w,j){E(w,j,k)}};Object.defineProperty(i,"__esModule",{value:!0}),i.DomRendererRowFactory=void 0;const l=n(2223),g=n(643),b=n(511),y=n(2585),_=n(8055),o=n(4725),h=n(4269),d=n(6171),u=n(3734);let x=i.DomRendererRowFactory=class{constructor(k,E,w,j,R,L,D){this._document=k,this._characterJoinerService=E,this._optionsService=w,this._coreBrowserService=j,this._coreService=R,this._decorationService=L,this._themeService=D,this._workCell=new b.CellData,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(k,E,w){this._selectionStart=k,this._selectionEnd=E,this._columnSelectMode=w}createRow(k,E,w,j,R,L,D,N,M,O,F){const z=[],A=this._characterJoinerService.getJoinedCharacters(E),P=this._themeService.colors;let I,B=k.getNoBgTrimmedLength();w&&B<L+1&&(B=L+1);let $=0,X="",Z=0,J=0,ae=0,T=!1,H=0,U=!1,W=0;const te=[],K=O!==-1&&F!==-1;for(let ce=0;ce<B;ce++){k.loadCell(ce,this._workCell);let he=this._workCell.getWidth();if(he===0)continue;let ve=!1,Fe=ce,re=this._workCell;if(A.length>0&&ce===A[0][0]){ve=!0;const Q=A.shift();re=new h.JoinedCellData(this._workCell,k.translateToString(!0,Q[0],Q[1]),Q[1]-Q[0]),Fe=Q[1]-1,he=re.getWidth()}const pe=this._isCellInSelection(ce,E),Ze=w&&ce===L,je=K&&ce>=O&&ce<=F;let Le=!1;this._decorationService.forEachDecorationAtCell(ce,E,void 0,(Q=>{Le=!0}));let we=re.getChars()||g.WHITESPACE_CELL_CHAR;if(we===" "&&(re.isUnderline()||re.isOverline())&&(we=" "),W=he*N-M.get(we,re.isBold(),re.isItalic()),I){if($&&(pe&&U||!pe&&!U&&re.bg===Z)&&(pe&&U&&P.selectionForeground||re.fg===J)&&re.extended.ext===ae&&je===T&&W===H&&!Ze&&!ve&&!Le){X+=we,$++;continue}$&&(I.textContent=X),I=this._document.createElement("span"),$=0,X=""}else I=this._document.createElement("span");if(Z=re.bg,J=re.fg,ae=re.extended.ext,T=je,H=W,U=pe,ve&&L>=ce&&L<=Fe&&(L=ce),!this._coreService.isCursorHidden&&Ze){if(te.push("xterm-cursor"),this._coreBrowserService.isFocused)D&&te.push("xterm-cursor-blink"),te.push(j==="bar"?"xterm-cursor-bar":j==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(R)switch(R){case"outline":te.push("xterm-cursor-outline");break;case"block":te.push("xterm-cursor-block");break;case"bar":te.push("xterm-cursor-bar");break;case"underline":te.push("xterm-cursor-underline")}}if(re.isBold()&&te.push("xterm-bold"),re.isItalic()&&te.push("xterm-italic"),re.isDim()&&te.push("xterm-dim"),X=re.isInvisible()?g.WHITESPACE_CELL_CHAR:re.getChars()||g.WHITESPACE_CELL_CHAR,re.isUnderline()&&(te.push(`xterm-underline-${re.extended.underlineStyle}`),X===" "&&(X=" "),!re.isUnderlineColorDefault()))if(re.isUnderlineColorRGB())I.style.textDecorationColor=`rgb(${u.AttributeData.toColorRGB(re.getUnderlineColor()).join(",")})`;else{let Q=re.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&re.isBold()&&Q<8&&(Q+=8),I.style.textDecorationColor=P.ansi[Q].css}re.isOverline()&&(te.push("xterm-overline"),X===" "&&(X=" ")),re.isStrikethrough()&&te.push("xterm-strikethrough"),je&&(I.style.textDecoration="underline");let Ce=re.getFgColor(),Xe=re.getFgColorMode(),_e=re.getBgColor(),ze=re.getBgColorMode();const ke=!!re.isInverse();if(ke){const Q=Ce;Ce=_e,_e=Q;const ue=Xe;Xe=ze,ze=ue}let Re,tt,qe,q=!1;switch(this._decorationService.forEachDecorationAtCell(ce,E,void 0,(Q=>{Q.options.layer!=="top"&&q||(Q.backgroundColorRGB&&(ze=50331648,_e=Q.backgroundColorRGB.rgba>>8&16777215,Re=Q.backgroundColorRGB),Q.foregroundColorRGB&&(Xe=50331648,Ce=Q.foregroundColorRGB.rgba>>8&16777215,tt=Q.foregroundColorRGB),q=Q.options.layer==="top")})),!q&&pe&&(Re=this._coreBrowserService.isFocused?P.selectionBackgroundOpaque:P.selectionInactiveBackgroundOpaque,_e=Re.rgba>>8&16777215,ze=50331648,q=!0,P.selectionForeground&&(Xe=50331648,Ce=P.selectionForeground.rgba>>8&16777215,tt=P.selectionForeground)),q&&te.push("xterm-decoration-top"),ze){case 16777216:case 33554432:qe=P.ansi[_e],te.push(`xterm-bg-${_e}`);break;case 50331648:qe=_.rgba.toColor(_e>>16,_e>>8&255,255&_e),this._addStyle(I,`background-color:#${S((_e>>>0).toString(16),"0",6)}`);break;default:ke?(qe=P.foreground,te.push(`xterm-bg-${l.INVERTED_DEFAULT_COLOR}`)):qe=P.background}switch(Re||re.isDim()&&(Re=_.color.multiplyOpacity(qe,.5)),Xe){case 16777216:case 33554432:re.isBold()&&Ce<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(Ce+=8),this._applyMinimumContrast(I,qe,P.ansi[Ce],re,Re,void 0)||te.push(`xterm-fg-${Ce}`);break;case 50331648:const Q=_.rgba.toColor(Ce>>16&255,Ce>>8&255,255&Ce);this._applyMinimumContrast(I,qe,Q,re,Re,tt)||this._addStyle(I,`color:#${S(Ce.toString(16),"0",6)}`);break;default:this._applyMinimumContrast(I,qe,P.foreground,re,Re,void 0)||ke&&te.push(`xterm-fg-${l.INVERTED_DEFAULT_COLOR}`)}te.length&&(I.className=te.join(" "),te.length=0),Ze||ve||Le?I.textContent=X:$++,W!==this.defaultSpacing&&(I.style.letterSpacing=`${W}px`),z.push(I),ce=Fe}return I&&$&&(I.textContent=X),z}_applyMinimumContrast(k,E,w,j,R,L){if(this._optionsService.rawOptions.minimumContrastRatio===1||(0,d.excludeFromContrastRatioDemands)(j.getCode()))return!1;const D=this._getContrastCache(j);let N;if(R||L||(N=D.getColor(E.rgba,w.rgba)),N===void 0){const M=this._optionsService.rawOptions.minimumContrastRatio/(j.isDim()?2:1);N=_.color.ensureContrastRatio(R||E,L||w,M),D.setColor((R||E).rgba,(L||w).rgba,N??null)}return!!N&&(this._addStyle(k,`color:${N.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 w=this._selectionStart,j=this._selectionEnd;return!(!w||!j)&&(this._columnSelectMode?w[0]<=j[0]?k>=w[0]&&E>=w[1]&&k<j[0]&&E<=j[1]:k<w[0]&&E>=w[1]&&k>=j[0]&&E<=j[1]:E>w[1]&&E<j[1]||w[1]===j[1]&&E===w[1]&&k>=w[0]&&k<j[0]||w[1]<j[1]&&E===j[1]&&k<j[0]||w[1]<j[1]&&E===w[1]&&k>=w[0])}};function S(k,E,w){for(;k.length<w;)k=E+k;return k}i.DomRendererRowFactory=x=c([f(1,o.ICharacterJoinerService),f(2,y.IOptionsService),f(3,o.ICoreBrowserService),f(4,y.ICoreService),f(5,y.IDecorationService),f(6,o.IThemeService)],x)},2550:(v,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 c=n.createElement("span"),f=n.createElement("span");f.style.fontWeight="bold";const l=n.createElement("span");l.style.fontStyle="italic";const g=n.createElement("span");g.style.fontWeight="bold",g.style.fontStyle="italic",this._measureElements=[c,f,l,g],this._container.appendChild(c),this._container.appendChild(f),this._container.appendChild(l),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,c,f,l){n===this._font&&c===this._fontSize&&f===this._weight&&l===this._weightBold||(this._font=n,this._fontSize=c,this._weight=f,this._weightBold=l,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${f}`,this._measureElements[1].style.fontWeight=`${l}`,this._measureElements[2].style.fontWeight=`${f}`,this._measureElements[3].style.fontWeight=`${l}`,this.clear())}get(n,c,f){let l=0;if(!c&&!f&&n.length===1&&(l=n.charCodeAt(0))<256)return this._flat[l]!==-9999?this._flat[l]:this._flat[l]=this._measure(n,0);let g=n;c&&(g+="B"),f&&(g+="I");let b=this._holey.get(g);if(b===void 0){let y=0;c&&(y|=1),f&&(y|=2),b=this._measure(n,y),this._holey.set(g,b)}return b}_measure(n,c){const f=this._measureElements[c];return f.textContent=n.repeat(32),f.offsetWidth/32}}},2223:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.TEXT_BASELINE=i.DIM_OPACITY=i.INVERTED_DEFAULT_COLOR=void 0;const c=n(6114);i.INVERTED_DEFAULT_COLOR=257,i.DIM_OPACITY=.5,i.TEXT_BASELINE=c.isFirefox||c.isLegacyEdge?"bottom":"ideographic"},6171:(v,i)=>{function n(c){return 57508<=c&&c<=57558}Object.defineProperty(i,"__esModule",{value:!0}),i.createRenderDimensions=i.excludeFromContrastRatioDemands=i.isRestrictedPowerlineGlyph=i.isPowerlineGlyph=i.throwIfFalsy=void 0,i.throwIfFalsy=function(c){if(!c)throw new Error("value must not be falsy");return c},i.isPowerlineGlyph=n,i.isRestrictedPowerlineGlyph=function(c){return 57520<=c&&c<=57527},i.excludeFromContrastRatioDemands=function(c){return n(c)||(function(f){return 9472<=f&&f<=9631})(c)},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:(v,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,c=this.selectionEnd;return!(!n||!c)&&(n[1]>c[1]||n[1]===c[1]&&n[0]>c[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(v,i,n){var c=this&&this.__decorate||function(o,h,d,u){var x,S=arguments.length,k=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(o,h,d,u);else for(var E=o.length-1;E>=0;E--)(x=o[E])&&(k=(S<3?x(k):S>3?x(h,d,k):x(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(o,h){return function(d,u){h(d,u,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharSizeService=void 0;const l=n(2585),g=n(8460),b=n(844);let y=i.CharSizeService=class extends b.Disposable{get hasValidSize(){return this.width>0&&this.height>0}constructor(o,h,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 _(o,h,this._optionsService),this.register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],(()=>this.measure())))}measure(){const o=this._measureStrategy.measure();o.width===this.width&&o.height===this.height||(this.width=o.width,this.height=o.height,this._onCharSizeChange.fire())}};i.CharSizeService=y=c([f(2,l.IOptionsService)],y);class _{constructor(h,d,u){this._document=h,this._parentElement=d,this._optionsService=u,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 h={height:Number(this._measureElement.offsetHeight),width:Number(this._measureElement.offsetWidth)};return h.width!==0&&h.height!==0&&(this._result.width=h.width/32,this._result.height=Math.ceil(h.height)),this._result}}},4269:function(v,i,n){var c=this&&this.__decorate||function(h,d,u,x){var S,k=arguments.length,E=k<3?d:x===null?x=Object.getOwnPropertyDescriptor(d,u):x;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")E=Reflect.decorate(h,d,u,x);else for(var w=h.length-1;w>=0;w--)(S=h[w])&&(E=(k<3?S(E):k>3?S(d,u,E):S(d,u))||E);return k>3&&E&&Object.defineProperty(d,u,E),E},f=this&&this.__param||function(h,d){return function(u,x){d(u,x,h)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CharacterJoinerService=i.JoinedCellData=void 0;const l=n(3734),g=n(643),b=n(511),y=n(2585);class _ extends l.AttributeData{constructor(d,u,x){super(),this.content=0,this.combinedData="",this.fg=d.fg,this.bg=d.bg,this.combinedData=u,this._width=x}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=_;let o=i.CharacterJoinerService=class la{constructor(d){this._bufferService=d,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new b.CellData}register(d){const u={id:this._nextCharacterJoinerId++,handler:d};return this._characterJoiners.push(u),u.id}deregister(d){for(let u=0;u<this._characterJoiners.length;u++)if(this._characterJoiners[u].id===d)return this._characterJoiners.splice(u,1),!0;return!1}getJoinedCharacters(d){if(this._characterJoiners.length===0)return[];const u=this._bufferService.buffer.lines.get(d);if(!u||u.length===0)return[];const x=[],S=u.translateToString(!0);let k=0,E=0,w=0,j=u.getFg(0),R=u.getBg(0);for(let L=0;L<u.getTrimmedLength();L++)if(u.loadCell(L,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==j||this._workCell.bg!==R){if(L-k>1){const D=this._getJoinedRanges(S,w,E,u,k);for(let N=0;N<D.length;N++)x.push(D[N])}k=L,w=E,j=this._workCell.fg,R=this._workCell.bg}E+=this._workCell.getChars().length||g.WHITESPACE_CELL_CHAR.length}if(this._bufferService.cols-k>1){const L=this._getJoinedRanges(S,w,E,u,k);for(let D=0;D<L.length;D++)x.push(L[D])}return x}_getJoinedRanges(d,u,x,S,k){const E=d.substring(u,x);let w=[];try{w=this._characterJoiners[0].handler(E)}catch(j){console.error(j)}for(let j=1;j<this._characterJoiners.length;j++)try{const R=this._characterJoiners[j].handler(E);for(let L=0;L<R.length;L++)la._mergeRanges(w,R[L])}catch(R){console.error(R)}return this._stringRangesToCellRanges(w,S,k),w}_stringRangesToCellRanges(d,u,x){let S=0,k=!1,E=0,w=d[S];if(w){for(let j=x;j<this._bufferService.cols;j++){const R=u.getWidth(j),L=u.getString(j).length||g.WHITESPACE_CELL_CHAR.length;if(R!==0){if(!k&&w[0]<=E&&(w[0]=j,k=!0),w[1]<=E){if(w[1]=j,w=d[++S],!w)break;w[0]<=E?(w[0]=j,k=!0):k=!1}E+=L}}w&&(w[1]=this._bufferService.cols)}}static _mergeRanges(d,u){let x=!1;for(let S=0;S<d.length;S++){const k=d[S];if(x){if(u[1]<=k[0])return d[S-1][1]=u[1],d;if(u[1]<=k[1])return d[S-1][1]=Math.max(u[1],k[1]),d.splice(S,1),d;d.splice(S,1),S--}else{if(u[1]<=k[0])return d.splice(S,0,u),d;if(u[1]<=k[1])return k[0]=Math.min(u[0],k[0]),d;u[0]<k[1]&&(k[0]=Math.min(u[0],k[0]),x=!0)}}return x?d[d.length-1][1]=u[1]:d.push(u),d}};i.CharacterJoinerService=o=c([f(0,y.IBufferService)],o)},5114:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreBrowserService=void 0,i.CoreBrowserService=class{constructor(n,c){this._textarea=n,this.window=c,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(v,i,n){var c=this&&this.__decorate||function(y,_,o,h){var d,u=arguments.length,x=u<3?_:h===null?h=Object.getOwnPropertyDescriptor(_,o):h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")x=Reflect.decorate(y,_,o,h);else for(var S=y.length-1;S>=0;S--)(d=y[S])&&(x=(u<3?d(x):u>3?d(_,o,x):d(_,o))||x);return u>3&&x&&Object.defineProperty(_,o,x),x},f=this&&this.__param||function(y,_){return function(o,h){_(o,h,y)}};Object.defineProperty(i,"__esModule",{value:!0}),i.MouseService=void 0;const l=n(4725),g=n(9806);let b=i.MouseService=class{constructor(y,_){this._renderService=y,this._charSizeService=_}getCoords(y,_,o,h,d){return(0,g.getCoords)(window,y,_,o,h,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,d)}getMouseReportCoords(y,_){const o=(0,g.getCoordsRelativeToElement)(window,y,_);if(this._charSizeService.hasValidSize)return o[0]=Math.min(Math.max(o[0],0),this._renderService.dimensions.css.canvas.width-1),o[1]=Math.min(Math.max(o[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(o[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(o[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(o[0]),y:Math.floor(o[1])}}};i.MouseService=b=c([f(0,l.IRenderService),f(1,l.ICharSizeService)],b)},3230:function(v,i,n){var c=this&&this.__decorate||function(x,S,k,E){var w,j=arguments.length,R=j<3?S:E===null?E=Object.getOwnPropertyDescriptor(S,k):E;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")R=Reflect.decorate(x,S,k,E);else for(var L=x.length-1;L>=0;L--)(w=x[L])&&(R=(j<3?w(R):j>3?w(S,k,R):w(S,k))||R);return j>3&&R&&Object.defineProperty(S,k,R),R},f=this&&this.__param||function(x,S){return function(k,E){S(k,E,x)}};Object.defineProperty(i,"__esModule",{value:!0}),i.RenderService=void 0;const l=n(3656),g=n(6193),b=n(5596),y=n(4725),_=n(8460),o=n(844),h=n(7226),d=n(2585);let u=i.RenderService=class extends o.Disposable{get dimensions(){return this._renderer.value.dimensions}constructor(x,S,k,E,w,j,R,L){if(super(),this._rowCount=x,this._charSizeService=E,this._renderer=this.register(new o.MutableDisposable),this._pausedResizeTask=new h.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 _.EventEmitter),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this.register(new _.EventEmitter),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this.register(new _.EventEmitter),this.onRender=this._onRender.event,this._onRefreshRequest=this.register(new _.EventEmitter),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new g.RenderDebouncer(R.window,((D,N)=>this._renderRows(D,N))),this.register(this._renderDebouncer),this._screenDprMonitor=new b.ScreenDprMonitor(R.window),this._screenDprMonitor.setListener((()=>this.handleDevicePixelRatioChange())),this.register(this._screenDprMonitor),this.register(j.onResize((()=>this._fullRefresh()))),this.register(j.buffers.onBufferActivate((()=>{var D;return(D=this._renderer.value)===null||D===void 0?void 0:D.clear()}))),this.register(k.onOptionChange((()=>this._handleOptionsChanged()))),this.register(this._charSizeService.onCharSizeChange((()=>this.handleCharSizeChanged()))),this.register(w.onDecorationRegistered((()=>this._fullRefresh()))),this.register(w.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,l.addDisposableDomListener)(R.window,"resize",(()=>this.handleDevicePixelRatioChange()))),this.register(L.onChangeColors((()=>this._fullRefresh()))),"IntersectionObserver"in R.window){const D=new R.window.IntersectionObserver((N=>this._handleIntersectionChange(N[N.length-1])),{threshold:0});D.observe(S),this.register({dispose:()=>D.disconnect()})}}_handleIntersectionChange(x){this._isPaused=x.isIntersecting===void 0?x.intersectionRatio===0:!x.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(x,S,k=!1){this._isPaused?this._needsFullRefresh=!0:(k||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(x,S,this._rowCount))}_renderRows(x,S){this._renderer.value&&(x=Math.min(x,this._rowCount-1),S=Math.min(S,this._rowCount-1),this._renderer.value.renderRows(x,S),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:x,end:S}),this._onRender.fire({start:x,end:S}),this._isNextRenderRedrawOnly=!0)}resize(x,S){this._rowCount=S,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(x){this._renderer.value=x,this._renderer.value.onRequestRedraw((S=>this.refreshRows(S.start,S.end,!0))),this._needsSelectionRefresh=!0,this._fullRefresh()}addRefreshCallback(x){return this._renderDebouncer.addRefreshCallback(x)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var x,S;this._renderer.value&&((S=(x=this._renderer.value).clearTextureAtlas)===null||S===void 0||S.call(x),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(x,S){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set((()=>this._renderer.value.handleResize(x,S))):this._renderer.value.handleResize(x,S),this._fullRefresh())}handleCharSizeChanged(){var x;(x=this._renderer.value)===null||x===void 0||x.handleCharSizeChanged()}handleBlur(){var x;(x=this._renderer.value)===null||x===void 0||x.handleBlur()}handleFocus(){var x;(x=this._renderer.value)===null||x===void 0||x.handleFocus()}handleSelectionChanged(x,S,k){var E;this._selectionState.start=x,this._selectionState.end=S,this._selectionState.columnSelectMode=k,(E=this._renderer.value)===null||E===void 0||E.handleSelectionChanged(x,S,k)}handleCursorMove(){var x;(x=this._renderer.value)===null||x===void 0||x.handleCursorMove()}clear(){var x;(x=this._renderer.value)===null||x===void 0||x.clear()}};i.RenderService=u=c([f(2,d.IOptionsService),f(3,y.ICharSizeService),f(4,d.IDecorationService),f(5,d.IBufferService),f(6,y.ICoreBrowserService),f(7,y.IThemeService)],u)},9312:function(v,i,n){var c=this&&this.__decorate||function(w,j,R,L){var D,N=arguments.length,M=N<3?j:L===null?L=Object.getOwnPropertyDescriptor(j,R):L;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")M=Reflect.decorate(w,j,R,L);else for(var O=w.length-1;O>=0;O--)(D=w[O])&&(M=(N<3?D(M):N>3?D(j,R,M):D(j,R))||M);return N>3&&M&&Object.defineProperty(j,R,M),M},f=this&&this.__param||function(w,j){return function(R,L){j(R,L,w)}};Object.defineProperty(i,"__esModule",{value:!0}),i.SelectionService=void 0;const l=n(9806),g=n(9504),b=n(456),y=n(4725),_=n(8460),o=n(844),h=n(6114),d=n(4841),u=n(511),x=n(2585),S=" ",k=new RegExp(S,"g");let E=i.SelectionService=class extends o.Disposable{constructor(w,j,R,L,D,N,M,O,F){super(),this._element=w,this._screenElement=j,this._linkifier=R,this._bufferService=L,this._coreService=D,this._mouseService=N,this._optionsService=M,this._renderService=O,this._coreBrowserService=F,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new u.CellData,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this.register(new _.EventEmitter),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this.register(new _.EventEmitter),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this.register(new _.EventEmitter),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this.register(new _.EventEmitter),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=z=>this._handleMouseMove(z),this._mouseUpListener=z=>this._handleMouseUp(z),this._coreService.onUserInput((()=>{this.hasSelection&&this.clearSelection()})),this._trimListener=this._bufferService.buffer.lines.onTrim((z=>this._handleTrim(z))),this.register(this._bufferService.buffers.onBufferActivate((z=>this._handleBufferActivate(z)))),this.enable(),this._model=new b.SelectionModel(this._bufferService),this._activeSelectionMode=0,this.register((0,o.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 w=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;return!(!w||!j||w[0]===j[0]&&w[1]===j[1])}get selectionText(){const w=this._model.finalSelectionStart,j=this._model.finalSelectionEnd;if(!w||!j)return"";const R=this._bufferService.buffer,L=[];if(this._activeSelectionMode===3){if(w[0]===j[0])return"";const D=w[0]<j[0]?w[0]:j[0],N=w[0]<j[0]?j[0]:w[0];for(let M=w[1];M<=j[1];M++){const O=R.translateBufferLineToString(M,!0,D,N);L.push(O)}}else{const D=w[1]===j[1]?j[0]:void 0;L.push(R.translateBufferLineToString(w[1],!0,w[0],D));for(let N=w[1]+1;N<=j[1]-1;N++){const M=R.lines.get(N),O=R.translateBufferLineToString(N,!0);M?.isWrapped?L[L.length-1]+=O:L.push(O)}if(w[1]!==j[1]){const N=R.lines.get(j[1]),M=R.translateBufferLineToString(j[1],!0,0,j[0]);N&&N.isWrapped?L[L.length-1]+=M:L.push(M)}}return L.map((D=>D.replace(k," "))).join(h.isWindows?`\r
23
+ `:`
24
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(w){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame((()=>this._refresh()))),h.isLinux&&w&&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(w){const j=this._getMouseBufferCoords(w),R=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!!(R&&L&&j)&&this._areCoordsInSelection(j,R,L)}isCellInSelection(w,j){const R=this._model.finalSelectionStart,L=this._model.finalSelectionEnd;return!(!R||!L)&&this._areCoordsInSelection([w,j],R,L)}_areCoordsInSelection(w,j,R){return w[1]>j[1]&&w[1]<R[1]||j[1]===R[1]&&w[1]===j[1]&&w[0]>=j[0]&&w[0]<R[0]||j[1]<R[1]&&w[1]===R[1]&&w[0]<R[0]||j[1]<R[1]&&w[1]===j[1]&&w[0]>=j[0]}_selectWordAtCursor(w,j){var R,L;const D=(L=(R=this._linkifier.currentLink)===null||R===void 0?void 0:R.link)===null||L===void 0?void 0:L.range;if(D)return this._model.selectionStart=[D.start.x-1,D.start.y-1],this._model.selectionStartLength=(0,d.getRangeLength)(D,this._bufferService.cols),this._model.selectionEnd=void 0,!0;const N=this._getMouseBufferCoords(w);return!!N&&(this._selectWordAt(N,j),this._model.selectionEnd=void 0,!0)}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(w,j){this._model.clearSelection(),w=Math.max(w,0),j=Math.min(j,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,w],this._model.selectionEnd=[this._bufferService.cols,j],this.refresh(),this._onSelectionChange.fire()}_handleTrim(w){this._model.handleTrim(w)&&this.refresh()}_getMouseBufferCoords(w){const j=this._mouseService.getCoords(w,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(j)return j[0]--,j[1]--,j[1]+=this._bufferService.buffer.ydisp,j}_getMouseEventScrollAmount(w){let j=(0,l.getCoordsRelativeToElement)(this._coreBrowserService.window,w,this._screenElement)[1];const R=this._renderService.dimensions.css.canvas.height;return j>=0&&j<=R?0:(j>R&&(j-=R),j=Math.min(Math.max(j,-50),50),j/=50,j/Math.abs(j)+Math.round(14*j))}shouldForceSelection(w){return h.isMac?w.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:w.shiftKey}handleMouseDown(w){if(this._mouseDownTimeStamp=w.timeStamp,(w.button!==2||!this.hasSelection)&&w.button===0){if(!this._enabled){if(!this.shouldForceSelection(w))return;w.stopPropagation()}w.preventDefault(),this._dragScrollAmount=0,this._enabled&&w.shiftKey?this._handleIncrementalClick(w):w.detail===1?this._handleSingleClick(w):w.detail===2?this._handleDoubleClick(w):w.detail===3&&this._handleTripleClick(w),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(w){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(w))}_handleSingleClick(w){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(w)?3:0,this._model.selectionStart=this._getMouseBufferCoords(w),!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(w){this._selectWordAtCursor(w,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(w){const j=this._getMouseBufferCoords(w);j&&(this._activeSelectionMode=2,this._selectLineAt(j[1]))}shouldColumnSelect(w){return w.altKey&&!(h.isMac&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(w){if(w.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(w),!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(w),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));const R=this._bufferService.buffer;if(this._model.selectionEnd[1]<R.lines.length){const L=R.lines.get(this._model.selectionEnd[1]);L&&L.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 w=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(w.ydisp+this._bufferService.rows,w.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=w.ydisp),this.refresh()}}_handleMouseUp(w){const j=w.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&j<500&&w.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){const R=this._mouseService.getCoords(w,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(R&&R[0]!==void 0&&R[1]!==void 0){const L=(0,g.moveToCellSequence)(R[0]-1,R[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(L,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){const w=this._model.finalSelectionStart,j=this._model.finalSelectionEnd,R=!(!w||!j||w[0]===j[0]&&w[1]===j[1]);R?w&&j&&(this._oldSelectionStart&&this._oldSelectionEnd&&w[0]===this._oldSelectionStart[0]&&w[1]===this._oldSelectionStart[1]&&j[0]===this._oldSelectionEnd[0]&&j[1]===this._oldSelectionEnd[1]||this._fireOnSelectionChange(w,j,R)):this._oldHasSelection&&this._fireOnSelectionChange(w,j,R)}_fireOnSelectionChange(w,j,R){this._oldSelectionStart=w,this._oldSelectionEnd=j,this._oldHasSelection=R,this._onSelectionChange.fire()}_handleBufferActivate(w){this.clearSelection(),this._trimListener.dispose(),this._trimListener=w.activeBuffer.lines.onTrim((j=>this._handleTrim(j)))}_convertViewportColToCharacterIndex(w,j){let R=j;for(let L=0;j>=L;L++){const D=w.loadCell(L,this._workCell).getChars().length;this._workCell.getWidth()===0?R--:D>1&&j!==L&&(R+=D-1)}return R}setSelection(w,j,R){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[w,j],this._model.selectionStartLength=R,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(w){this._isClickInSelection(w)||(this._selectWordAtCursor(w,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(w,j,R=!0,L=!0){if(w[0]>=this._bufferService.cols)return;const D=this._bufferService.buffer,N=D.lines.get(w[1]);if(!N)return;const M=D.translateBufferLineToString(w[1],!1);let O=this._convertViewportColToCharacterIndex(N,w[0]),F=O;const z=w[0]-O;let A=0,P=0,I=0,B=0;if(M.charAt(O)===" "){for(;O>0&&M.charAt(O-1)===" ";)O--;for(;F<M.length&&M.charAt(F+1)===" ";)F++}else{let Z=w[0],J=w[0];N.getWidth(Z)===0&&(A++,Z--),N.getWidth(J)===2&&(P++,J++);const ae=N.getString(J).length;for(ae>1&&(B+=ae-1,F+=ae-1);Z>0&&O>0&&!this._isCharWordSeparator(N.loadCell(Z-1,this._workCell));){N.loadCell(Z-1,this._workCell);const T=this._workCell.getChars().length;this._workCell.getWidth()===0?(A++,Z--):T>1&&(I+=T-1,O-=T-1),O--,Z--}for(;J<N.length&&F+1<M.length&&!this._isCharWordSeparator(N.loadCell(J+1,this._workCell));){N.loadCell(J+1,this._workCell);const T=this._workCell.getChars().length;this._workCell.getWidth()===2?(P++,J++):T>1&&(B+=T-1,F+=T-1),F++,J++}}F++;let $=O+z-A+I,X=Math.min(this._bufferService.cols,F-O+A+P-I-B);if(j||M.slice(O,F).trim()!==""){if(R&&$===0&&N.getCodePoint(0)!==32){const Z=D.lines.get(w[1]-1);if(Z&&N.isWrapped&&Z.getCodePoint(this._bufferService.cols-1)!==32){const J=this._getWordAt([this._bufferService.cols-1,w[1]-1],!1,!0,!1);if(J){const ae=this._bufferService.cols-J.start;$-=ae,X+=ae}}}if(L&&$+X===this._bufferService.cols&&N.getCodePoint(this._bufferService.cols-1)!==32){const Z=D.lines.get(w[1]+1);if(Z?.isWrapped&&Z.getCodePoint(0)!==32){const J=this._getWordAt([0,w[1]+1],!1,!1,!0);J&&(X+=J.length)}}return{start:$,length:X}}}_selectWordAt(w,j){const R=this._getWordAt(w,j);if(R){for(;R.start<0;)R.start+=this._bufferService.cols,w[1]--;this._model.selectionStart=[R.start,w[1]],this._model.selectionStartLength=R.length}}_selectToWordAt(w){const j=this._getWordAt(w,!0);if(j){let R=w[1];for(;j.start<0;)j.start+=this._bufferService.cols,R--;if(!this._model.areSelectionValuesReversed())for(;j.start+j.length>this._bufferService.cols;)j.length-=this._bufferService.cols,R++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?j.start:j.start+j.length,R]}}_isCharWordSeparator(w){return w.getWidth()!==0&&this._optionsService.rawOptions.wordSeparator.indexOf(w.getChars())>=0}_selectLineAt(w){const j=this._bufferService.buffer.getWrappedRangeForLine(w),R={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)(R,this._bufferService.cols)}};i.SelectionService=E=c([f(3,x.IBufferService),f(4,x.ICoreService),f(5,y.IMouseService),f(6,x.IOptionsService),f(7,y.IRenderService),f(8,y.ICoreBrowserService)],E)},4725:(v,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 c=n(8343);i.ICharSizeService=(0,c.createDecorator)("CharSizeService"),i.ICoreBrowserService=(0,c.createDecorator)("CoreBrowserService"),i.IMouseService=(0,c.createDecorator)("MouseService"),i.IRenderService=(0,c.createDecorator)("RenderService"),i.ISelectionService=(0,c.createDecorator)("SelectionService"),i.ICharacterJoinerService=(0,c.createDecorator)("CharacterJoinerService"),i.IThemeService=(0,c.createDecorator)("ThemeService")},6731:function(v,i,n){var c=this&&this.__decorate||function(E,w,j,R){var L,D=arguments.length,N=D<3?w:R===null?R=Object.getOwnPropertyDescriptor(w,j):R;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")N=Reflect.decorate(E,w,j,R);else for(var M=E.length-1;M>=0;M--)(L=E[M])&&(N=(D<3?L(N):D>3?L(w,j,N):L(w,j))||N);return D>3&&N&&Object.defineProperty(w,j,N),N},f=this&&this.__param||function(E,w){return function(j,R){w(j,R,E)}};Object.defineProperty(i,"__esModule",{value:!0}),i.ThemeService=i.DEFAULT_ANSI_COLORS=void 0;const l=n(7239),g=n(8055),b=n(8460),y=n(844),_=n(2585),o=g.css.toColor("#ffffff"),h=g.css.toColor("#000000"),d=g.css.toColor("#ffffff"),u=g.css.toColor("#000000"),x={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")],w=[0,95,135,175,215,255];for(let j=0;j<216;j++){const R=w[j/36%6|0],L=w[j/6%6|0],D=w[j%6];E.push({css:g.channels.toCss(R,L,D),rgba:g.channels.toRgba(R,L,D)})}for(let j=0;j<24;j++){const R=8+10*j;E.push({css:g.channels.toCss(R,R,R),rgba:g.channels.toRgba(R,R,R)})}return E})());let S=i.ThemeService=class extends y.Disposable{get colors(){return this._colors}constructor(E){super(),this._optionsService=E,this._contrastCache=new l.ColorContrastCache,this._halfContrastCache=new l.ColorContrastCache,this._onChangeColors=this.register(new b.EventEmitter),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:o,background:h,cursor:d,cursorAccent:u,selectionForeground:void 0,selectionBackgroundTransparent:x,selectionBackgroundOpaque:g.color.blend(h,x),selectionInactiveBackgroundTransparent:x,selectionInactiveBackgroundOpaque:g.color.blend(h,x),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 w=this._colors;if(w.foreground=k(E.foreground,o),w.background=k(E.background,h),w.cursor=k(E.cursor,d),w.cursorAccent=k(E.cursorAccent,u),w.selectionBackgroundTransparent=k(E.selectionBackground,x),w.selectionBackgroundOpaque=g.color.blend(w.background,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundTransparent=k(E.selectionInactiveBackground,w.selectionBackgroundTransparent),w.selectionInactiveBackgroundOpaque=g.color.blend(w.background,w.selectionInactiveBackgroundTransparent),w.selectionForeground=E.selectionForeground?k(E.selectionForeground,g.NULL_COLOR):void 0,w.selectionForeground===g.NULL_COLOR&&(w.selectionForeground=void 0),g.color.isOpaque(w.selectionBackgroundTransparent)&&(w.selectionBackgroundTransparent=g.color.opacity(w.selectionBackgroundTransparent,.3)),g.color.isOpaque(w.selectionInactiveBackgroundTransparent)&&(w.selectionInactiveBackgroundTransparent=g.color.opacity(w.selectionInactiveBackgroundTransparent,.3)),w.ansi=i.DEFAULT_ANSI_COLORS.slice(),w.ansi[0]=k(E.black,i.DEFAULT_ANSI_COLORS[0]),w.ansi[1]=k(E.red,i.DEFAULT_ANSI_COLORS[1]),w.ansi[2]=k(E.green,i.DEFAULT_ANSI_COLORS[2]),w.ansi[3]=k(E.yellow,i.DEFAULT_ANSI_COLORS[3]),w.ansi[4]=k(E.blue,i.DEFAULT_ANSI_COLORS[4]),w.ansi[5]=k(E.magenta,i.DEFAULT_ANSI_COLORS[5]),w.ansi[6]=k(E.cyan,i.DEFAULT_ANSI_COLORS[6]),w.ansi[7]=k(E.white,i.DEFAULT_ANSI_COLORS[7]),w.ansi[8]=k(E.brightBlack,i.DEFAULT_ANSI_COLORS[8]),w.ansi[9]=k(E.brightRed,i.DEFAULT_ANSI_COLORS[9]),w.ansi[10]=k(E.brightGreen,i.DEFAULT_ANSI_COLORS[10]),w.ansi[11]=k(E.brightYellow,i.DEFAULT_ANSI_COLORS[11]),w.ansi[12]=k(E.brightBlue,i.DEFAULT_ANSI_COLORS[12]),w.ansi[13]=k(E.brightMagenta,i.DEFAULT_ANSI_COLORS[13]),w.ansi[14]=k(E.brightCyan,i.DEFAULT_ANSI_COLORS[14]),w.ansi[15]=k(E.brightWhite,i.DEFAULT_ANSI_COLORS[15]),E.extendedAnsi){const j=Math.min(w.ansi.length-16,E.extendedAnsi.length);for(let R=0;R<j;R++)w.ansi[R+16]=k(E.extendedAnsi[R],i.DEFAULT_ANSI_COLORS[R+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 w=0;w<this._restoreColors.ansi.length;++w)this._colors.ansi[w]=this._restoreColors.ansi[w]}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,w){if(E!==void 0)try{return g.css.toColor(E)}catch{}return w}i.ThemeService=S=c([f(0,_.IOptionsService)],S)},6349:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CircularList=void 0;const c=n(8460),f=n(844);class l extends f.Disposable{constructor(b){super(),this._maxLength=b,this.onDeleteEmitter=this.register(new c.EventEmitter),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this.register(new c.EventEmitter),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this.register(new c.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(b){if(this._maxLength===b)return;const y=new Array(b);for(let _=0;_<Math.min(b,this.length);_++)y[_]=this._array[this._getCyclicIndex(_)];this._array=y,this._maxLength=b,this._startIndex=0}get length(){return this._length}set length(b){if(b>this._length)for(let y=this._length;y<b;y++)this._array[y]=void 0;this._length=b}get(b){return this._array[this._getCyclicIndex(b)]}set(b,y){this._array[this._getCyclicIndex(b)]=y}push(b){this._array[this._getCyclicIndex(this._length)]=b,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(b,y,..._){if(y){for(let o=b;o<this._length-y;o++)this._array[this._getCyclicIndex(o)]=this._array[this._getCyclicIndex(o+y)];this._length-=y,this.onDeleteEmitter.fire({index:b,amount:y})}for(let o=this._length-1;o>=b;o--)this._array[this._getCyclicIndex(o+_.length)]=this._array[this._getCyclicIndex(o)];for(let o=0;o<_.length;o++)this._array[this._getCyclicIndex(b+o)]=_[o];if(_.length&&this.onInsertEmitter.fire({index:b,amount:_.length}),this._length+_.length>this._maxLength){const o=this._length+_.length-this._maxLength;this._startIndex+=o,this._length=this._maxLength,this.onTrimEmitter.fire(o)}else this._length+=_.length}trimStart(b){b>this._length&&(b=this._length),this._startIndex+=b,this._length-=b,this.onTrimEmitter.fire(b)}shiftElements(b,y,_){if(!(y<=0)){if(b<0||b>=this._length)throw new Error("start argument out of range");if(b+_<0)throw new Error("Cannot shift elements in list beyond index 0");if(_>0){for(let h=y-1;h>=0;h--)this.set(b+h+_,this.get(b+h));const o=b+y+_-this._length;if(o>0)for(this._length+=o;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let o=0;o<y;o++)this.set(b+o+_,this.get(b+o))}}_getCyclicIndex(b){return(this._startIndex+b)%this._maxLength}}i.CircularList=l},1439:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.clone=void 0,i.clone=function n(c,f=5){if(typeof c!="object")return c;const l=Array.isArray(c)?[]:{};for(const g in c)l[g]=f<=1?c[g]:c[g]&&n(c[g],f-1);return l}},8055:(v,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 c=n(6114);let f=0,l=0,g=0,b=0;var y,_,o,h,d;function u(S){const k=S.toString(16);return k.length<2?"0"+k:k}function x(S,k){return S<k?(k+.05)/(S+.05):(S+.05)/(k+.05)}i.NULL_COLOR={css:"#00000000",rgba:0},(function(S){S.toCss=function(k,E,w,j){return j!==void 0?`#${u(k)}${u(E)}${u(w)}${u(j)}`:`#${u(k)}${u(E)}${u(w)}`},S.toRgba=function(k,E,w,j=255){return(k<<24|E<<16|w<<8|j)>>>0}})(y||(i.channels=y={})),(function(S){function k(E,w){return b=Math.round(255*w),[f,l,g]=d.toChannels(E.rgba),{css:y.toCss(f,l,g,b),rgba:y.toRgba(f,l,g,b)}}S.blend=function(E,w){if(b=(255&w.rgba)/255,b===1)return{css:w.css,rgba:w.rgba};const j=w.rgba>>24&255,R=w.rgba>>16&255,L=w.rgba>>8&255,D=E.rgba>>24&255,N=E.rgba>>16&255,M=E.rgba>>8&255;return f=D+Math.round((j-D)*b),l=N+Math.round((R-N)*b),g=M+Math.round((L-M)*b),{css:y.toCss(f,l,g),rgba:y.toRgba(f,l,g)}},S.isOpaque=function(E){return(255&E.rgba)==255},S.ensureContrastRatio=function(E,w,j){const R=d.ensureContrastRatio(E.rgba,w.rgba,j);if(R)return d.toColor(R>>24&255,R>>16&255,R>>8&255)},S.opaque=function(E){const w=(255|E.rgba)>>>0;return[f,l,g]=d.toChannels(w),{css:y.toCss(f,l,g),rgba:w}},S.opacity=k,S.multiplyOpacity=function(E,w){return b=255&E.rgba,k(E,b*w/255)},S.toColorRGB=function(E){return[E.rgba>>24&255,E.rgba>>16&255,E.rgba>>8&255]}})(_||(i.color=_={})),(function(S){let k,E;if(!c.isNode){const w=document.createElement("canvas");w.width=1,w.height=1;const j=w.getContext("2d",{willReadFrequently:!0});j&&(k=j,k.globalCompositeOperation="copy",E=k.createLinearGradient(0,0,1,1))}S.toColor=function(w){if(w.match(/#[\da-f]{3,8}/i))switch(w.length){case 4:return f=parseInt(w.slice(1,2).repeat(2),16),l=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),d.toColor(f,l,g);case 5:return f=parseInt(w.slice(1,2).repeat(2),16),l=parseInt(w.slice(2,3).repeat(2),16),g=parseInt(w.slice(3,4).repeat(2),16),b=parseInt(w.slice(4,5).repeat(2),16),d.toColor(f,l,g,b);case 7:return{css:w,rgba:(parseInt(w.slice(1),16)<<8|255)>>>0};case 9:return{css:w,rgba:parseInt(w.slice(1),16)>>>0}}const j=w.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 f=parseInt(j[1]),l=parseInt(j[2]),g=parseInt(j[3]),b=Math.round(255*(j[5]===void 0?1:parseFloat(j[5]))),d.toColor(f,l,g,b);if(!k||!E)throw new Error("css.toColor: Unsupported css format");if(k.fillStyle=E,k.fillStyle=w,typeof k.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(k.fillRect(0,0,1,1),[f,l,g,b]=k.getImageData(0,0,1,1).data,b!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:y.toRgba(f,l,g,b),css:w}}})(o||(i.css=o={})),(function(S){function k(E,w,j){const R=E/255,L=w/255,D=j/255;return .2126*(R<=.03928?R/12.92:Math.pow((R+.055)/1.055,2.4))+.7152*(L<=.03928?L/12.92:Math.pow((L+.055)/1.055,2.4))+.0722*(D<=.03928?D/12.92:Math.pow((D+.055)/1.055,2.4))}S.relativeLuminance=function(E){return k(E>>16&255,E>>8&255,255&E)},S.relativeLuminance2=k})(h||(i.rgb=h={})),(function(S){function k(w,j,R){const L=w>>24&255,D=w>>16&255,N=w>>8&255;let M=j>>24&255,O=j>>16&255,F=j>>8&255,z=x(h.relativeLuminance2(M,O,F),h.relativeLuminance2(L,D,N));for(;z<R&&(M>0||O>0||F>0);)M-=Math.max(0,Math.ceil(.1*M)),O-=Math.max(0,Math.ceil(.1*O)),F-=Math.max(0,Math.ceil(.1*F)),z=x(h.relativeLuminance2(M,O,F),h.relativeLuminance2(L,D,N));return(M<<24|O<<16|F<<8|255)>>>0}function E(w,j,R){const L=w>>24&255,D=w>>16&255,N=w>>8&255;let M=j>>24&255,O=j>>16&255,F=j>>8&255,z=x(h.relativeLuminance2(M,O,F),h.relativeLuminance2(L,D,N));for(;z<R&&(M<255||O<255||F<255);)M=Math.min(255,M+Math.ceil(.1*(255-M))),O=Math.min(255,O+Math.ceil(.1*(255-O))),F=Math.min(255,F+Math.ceil(.1*(255-F))),z=x(h.relativeLuminance2(M,O,F),h.relativeLuminance2(L,D,N));return(M<<24|O<<16|F<<8|255)>>>0}S.ensureContrastRatio=function(w,j,R){const L=h.relativeLuminance(w>>8),D=h.relativeLuminance(j>>8);if(x(L,D)<R){if(D<L){const O=k(w,j,R),F=x(L,h.relativeLuminance(O>>8));if(F<R){const z=E(w,j,R);return F>x(L,h.relativeLuminance(z>>8))?O:z}return O}const N=E(w,j,R),M=x(L,h.relativeLuminance(N>>8));if(M<R){const O=k(w,j,R);return M>x(L,h.relativeLuminance(O>>8))?N:O}return N}},S.reduceLuminance=k,S.increaseLuminance=E,S.toChannels=function(w){return[w>>24&255,w>>16&255,w>>8&255,255&w]},S.toColor=function(w,j,R,L){return{css:y.toCss(w,j,R,L),rgba:y.toRgba(w,j,R,L)}}})(d||(i.rgba=d={})),i.toPaddedHex=u,i.contrastRatio=x},8969:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CoreTerminal=void 0;const c=n(844),f=n(2585),l=n(4348),g=n(7866),b=n(744),y=n(7302),_=n(6975),o=n(8460),h=n(1753),d=n(1480),u=n(7994),x=n(9282),S=n(5435),k=n(5981),E=n(2660);let w=!1;class j extends c.Disposable{get onScroll(){return this._onScrollApi||(this._onScrollApi=this.register(new o.EventEmitter),this._onScroll.event((L=>{var D;(D=this._onScrollApi)===null||D===void 0||D.fire(L.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(L){for(const D in L)this.optionsService.options[D]=L[D]}constructor(L){super(),this._windowsWrappingHeuristics=this.register(new c.MutableDisposable),this._onBinary=this.register(new o.EventEmitter),this.onBinary=this._onBinary.event,this._onData=this.register(new o.EventEmitter),this.onData=this._onData.event,this._onLineFeed=this.register(new o.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onResize=this.register(new o.EventEmitter),this.onResize=this._onResize.event,this._onWriteParsed=this.register(new o.EventEmitter),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this.register(new o.EventEmitter),this._instantiationService=new l.InstantiationService,this.optionsService=this.register(new y.OptionsService(L)),this._instantiationService.setService(f.IOptionsService,this.optionsService),this._bufferService=this.register(this._instantiationService.createInstance(b.BufferService)),this._instantiationService.setService(f.IBufferService,this._bufferService),this._logService=this.register(this._instantiationService.createInstance(g.LogService)),this._instantiationService.setService(f.ILogService,this._logService),this.coreService=this.register(this._instantiationService.createInstance(_.CoreService)),this._instantiationService.setService(f.ICoreService,this.coreService),this.coreMouseService=this.register(this._instantiationService.createInstance(h.CoreMouseService)),this._instantiationService.setService(f.ICoreMouseService,this.coreMouseService),this.unicodeService=this.register(this._instantiationService.createInstance(d.UnicodeService)),this._instantiationService.setService(f.IUnicodeService,this.unicodeService),this._charsetService=this._instantiationService.createInstance(u.CharsetService),this._instantiationService.setService(f.ICharsetService,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(E.OscLinkService),this._instantiationService.setService(f.IOscLinkService,this._oscLinkService),this._inputHandler=this.register(new S.InputHandler(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this.register((0,o.forwardEvent)(this._inputHandler.onLineFeed,this._onLineFeed)),this.register(this._inputHandler),this.register((0,o.forwardEvent)(this._bufferService.onResize,this._onResize)),this.register((0,o.forwardEvent)(this.coreService.onData,this._onData)),this.register((0,o.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((D=>{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((D=>{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(((D,N)=>this._inputHandler.parse(D,N)))),this.register((0,o.forwardEvent)(this._writeBuffer.onWriteParsed,this._onWriteParsed))}write(L,D){this._writeBuffer.write(L,D)}writeSync(L,D){this._logService.logLevel<=f.LogLevelEnum.WARN&&!w&&(this._logService.warn("writeSync is unreliable and will be removed soon."),w=!0),this._writeBuffer.writeSync(L,D)}resize(L,D){isNaN(L)||isNaN(D)||(L=Math.max(L,b.MINIMUM_COLS),D=Math.max(D,b.MINIMUM_ROWS),this._bufferService.resize(L,D))}scroll(L,D=!1){this._bufferService.scroll(L,D)}scrollLines(L,D,N){this._bufferService.scrollLines(L,D,N)}scrollPages(L){this.scrollLines(L*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(L){const D=L-this._bufferService.buffer.ydisp;D!==0&&this.scrollLines(D)}registerEscHandler(L,D){return this._inputHandler.registerEscHandler(L,D)}registerDcsHandler(L,D){return this._inputHandler.registerDcsHandler(L,D)}registerCsiHandler(L,D){return this._inputHandler.registerCsiHandler(L,D)}registerOscHandler(L,D){return this._inputHandler.registerOscHandler(L,D)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let L=!1;const D=this.optionsService.rawOptions.windowsPty;D&&D.buildNumber!==void 0&&D.buildNumber!==void 0?L=D.backend==="conpty"&&D.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(L=!0),L?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){const L=[];L.push(this.onLineFeed(x.updateWindowsModeWrappedState.bind(null,this._bufferService))),L.push(this.registerCsiHandler({final:"H"},(()=>((0,x.updateWindowsModeWrappedState)(this._bufferService),!1)))),this._windowsWrappingHeuristics.value=(0,c.toDisposable)((()=>{for(const D of L)D.dispose()}))}}}i.CoreTerminal=j},8460:(v,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 c=0;c<this._listeners.length;c++)if(this._listeners[c]===n)return void this._listeners.splice(c,1)}}})),this._event}fire(n,c){const f=[];for(let l=0;l<this._listeners.length;l++)f.push(this._listeners[l]);for(let l=0;l<f.length;l++)f[l].call(void 0,n,c)}dispose(){this.clearListeners(),this._disposed=!0}clearListeners(){this._listeners&&(this._listeners.length=0)}},i.forwardEvent=function(n,c){return n((f=>c.fire(f)))}},5435:function(v,i,n){var c=this&&this.__decorate||function(z,A,P,I){var B,$=arguments.length,X=$<3?A:I===null?I=Object.getOwnPropertyDescriptor(A,P):I;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")X=Reflect.decorate(z,A,P,I);else for(var Z=z.length-1;Z>=0;Z--)(B=z[Z])&&(X=($<3?B(X):$>3?B(A,P,X):B(A,P))||X);return $>3&&X&&Object.defineProperty(A,P,X),X},f=this&&this.__param||function(z,A){return function(P,I){A(P,I,z)}};Object.defineProperty(i,"__esModule",{value:!0}),i.InputHandler=i.WindowsOptionsReportType=void 0;const l=n(2584),g=n(7116),b=n(2015),y=n(844),_=n(482),o=n(8437),h=n(8460),d=n(643),u=n(511),x=n(3734),S=n(2585),k=n(6242),E=n(6351),w=n(5941),j={"(":0,")":1,"*":2,"+":3,"-":1,".":2},R=131072;function L(z,A){if(z>24)return A.setWinLines||!1;switch(z){case 1:return!!A.restoreWin;case 2:return!!A.minimizeWin;case 3:return!!A.setWinPosition;case 4:return!!A.setWinSizePixels;case 5:return!!A.raiseWin;case 6:return!!A.lowerWin;case 7:return!!A.refreshWin;case 8:return!!A.setWinSizeChars;case 9:return!!A.maximizeWin;case 10:return!!A.fullscreenWin;case 11:return!!A.getWinState;case 13:return!!A.getWinPosition;case 14:return!!A.getWinSizePixels;case 15:return!!A.getScreenSizePixels;case 16:return!!A.getCellSizePixels;case 18:return!!A.getWinSizeChars;case 19:return!!A.getScreenSizeChars;case 20:return!!A.getIconTitle;case 21:return!!A.getWinTitle;case 22:return!!A.pushTitle;case 23:return!!A.popTitle;case 24:return!!A.setWinLines}return!1}var D;(function(z){z[z.GET_WIN_SIZE_PIXELS=0]="GET_WIN_SIZE_PIXELS",z[z.GET_CELL_SIZE_PIXELS=1]="GET_CELL_SIZE_PIXELS"})(D||(i.WindowsOptionsReportType=D={}));let N=0;class M extends y.Disposable{getAttrData(){return this._curAttrData}constructor(A,P,I,B,$,X,Z,J,ae=new b.EscapeSequenceParser){super(),this._bufferService=A,this._charsetService=P,this._coreService=I,this._logService=B,this._optionsService=$,this._oscLinkService=X,this._coreMouseService=Z,this._unicodeService=J,this._parser=ae,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new _.StringToUtf32,this._utf8Decoder=new _.Utf8ToUtf32,this._workCell=new u.CellData,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=o.DEFAULT_ATTR_DATA.clone(),this._onRequestBell=this.register(new h.EventEmitter),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this.register(new h.EventEmitter),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this.register(new h.EventEmitter),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this.register(new h.EventEmitter),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this.register(new h.EventEmitter),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this.register(new h.EventEmitter),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this.register(new h.EventEmitter),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this.register(new h.EventEmitter),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this.register(new h.EventEmitter),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this.register(new h.EventEmitter),this.onLineFeed=this._onLineFeed.event,this._onScroll=this.register(new h.EventEmitter),this.onScroll=this._onScroll.event,this._onTitleChange=this.register(new h.EventEmitter),this.onTitleChange=this._onTitleChange.event,this._onColor=this.register(new h.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 O(this._bufferService),this._activeBuffer=this._bufferService.buffer,this.register(this._bufferService.buffers.onBufferActivate((T=>this._activeBuffer=T.activeBuffer))),this._parser.setCsiHandlerFallback(((T,H)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(T),params:H.toArray()})})),this._parser.setEscHandlerFallback((T=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(T)})})),this._parser.setExecuteHandlerFallback((T=>{this._logService.debug("Unknown EXECUTE code: ",{code:T})})),this._parser.setOscHandlerFallback(((T,H,U)=>{this._logService.debug("Unknown OSC code: ",{identifier:T,action:H,data:U})})),this._parser.setDcsHandlerFallback(((T,H,U)=>{H==="HOOK"&&(U=U.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(T),action:H,payload:U})})),this._parser.setPrintHandler(((T,H,U)=>this.print(T,H,U))),this._parser.registerCsiHandler({final:"@"},(T=>this.insertChars(T))),this._parser.registerCsiHandler({intermediates:" ",final:"@"},(T=>this.scrollLeft(T))),this._parser.registerCsiHandler({final:"A"},(T=>this.cursorUp(T))),this._parser.registerCsiHandler({intermediates:" ",final:"A"},(T=>this.scrollRight(T))),this._parser.registerCsiHandler({final:"B"},(T=>this.cursorDown(T))),this._parser.registerCsiHandler({final:"C"},(T=>this.cursorForward(T))),this._parser.registerCsiHandler({final:"D"},(T=>this.cursorBackward(T))),this._parser.registerCsiHandler({final:"E"},(T=>this.cursorNextLine(T))),this._parser.registerCsiHandler({final:"F"},(T=>this.cursorPrecedingLine(T))),this._parser.registerCsiHandler({final:"G"},(T=>this.cursorCharAbsolute(T))),this._parser.registerCsiHandler({final:"H"},(T=>this.cursorPosition(T))),this._parser.registerCsiHandler({final:"I"},(T=>this.cursorForwardTab(T))),this._parser.registerCsiHandler({final:"J"},(T=>this.eraseInDisplay(T,!1))),this._parser.registerCsiHandler({prefix:"?",final:"J"},(T=>this.eraseInDisplay(T,!0))),this._parser.registerCsiHandler({final:"K"},(T=>this.eraseInLine(T,!1))),this._parser.registerCsiHandler({prefix:"?",final:"K"},(T=>this.eraseInLine(T,!0))),this._parser.registerCsiHandler({final:"L"},(T=>this.insertLines(T))),this._parser.registerCsiHandler({final:"M"},(T=>this.deleteLines(T))),this._parser.registerCsiHandler({final:"P"},(T=>this.deleteChars(T))),this._parser.registerCsiHandler({final:"S"},(T=>this.scrollUp(T))),this._parser.registerCsiHandler({final:"T"},(T=>this.scrollDown(T))),this._parser.registerCsiHandler({final:"X"},(T=>this.eraseChars(T))),this._parser.registerCsiHandler({final:"Z"},(T=>this.cursorBackwardTab(T))),this._parser.registerCsiHandler({final:"`"},(T=>this.charPosAbsolute(T))),this._parser.registerCsiHandler({final:"a"},(T=>this.hPositionRelative(T))),this._parser.registerCsiHandler({final:"b"},(T=>this.repeatPrecedingCharacter(T))),this._parser.registerCsiHandler({final:"c"},(T=>this.sendDeviceAttributesPrimary(T))),this._parser.registerCsiHandler({prefix:">",final:"c"},(T=>this.sendDeviceAttributesSecondary(T))),this._parser.registerCsiHandler({final:"d"},(T=>this.linePosAbsolute(T))),this._parser.registerCsiHandler({final:"e"},(T=>this.vPositionRelative(T))),this._parser.registerCsiHandler({final:"f"},(T=>this.hVPosition(T))),this._parser.registerCsiHandler({final:"g"},(T=>this.tabClear(T))),this._parser.registerCsiHandler({final:"h"},(T=>this.setMode(T))),this._parser.registerCsiHandler({prefix:"?",final:"h"},(T=>this.setModePrivate(T))),this._parser.registerCsiHandler({final:"l"},(T=>this.resetMode(T))),this._parser.registerCsiHandler({prefix:"?",final:"l"},(T=>this.resetModePrivate(T))),this._parser.registerCsiHandler({final:"m"},(T=>this.charAttributes(T))),this._parser.registerCsiHandler({final:"n"},(T=>this.deviceStatus(T))),this._parser.registerCsiHandler({prefix:"?",final:"n"},(T=>this.deviceStatusPrivate(T))),this._parser.registerCsiHandler({intermediates:"!",final:"p"},(T=>this.softReset(T))),this._parser.registerCsiHandler({intermediates:" ",final:"q"},(T=>this.setCursorStyle(T))),this._parser.registerCsiHandler({final:"r"},(T=>this.setScrollRegion(T))),this._parser.registerCsiHandler({final:"s"},(T=>this.saveCursor(T))),this._parser.registerCsiHandler({final:"t"},(T=>this.windowOptions(T))),this._parser.registerCsiHandler({final:"u"},(T=>this.restoreCursor(T))),this._parser.registerCsiHandler({intermediates:"'",final:"}"},(T=>this.insertColumns(T))),this._parser.registerCsiHandler({intermediates:"'",final:"~"},(T=>this.deleteColumns(T))),this._parser.registerCsiHandler({intermediates:'"',final:"q"},(T=>this.selectProtected(T))),this._parser.registerCsiHandler({intermediates:"$",final:"p"},(T=>this.requestMode(T,!0))),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},(T=>this.requestMode(T,!1))),this._parser.setExecuteHandler(l.C0.BEL,(()=>this.bell())),this._parser.setExecuteHandler(l.C0.LF,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.VT,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.FF,(()=>this.lineFeed())),this._parser.setExecuteHandler(l.C0.CR,(()=>this.carriageReturn())),this._parser.setExecuteHandler(l.C0.BS,(()=>this.backspace())),this._parser.setExecuteHandler(l.C0.HT,(()=>this.tab())),this._parser.setExecuteHandler(l.C0.SO,(()=>this.shiftOut())),this._parser.setExecuteHandler(l.C0.SI,(()=>this.shiftIn())),this._parser.setExecuteHandler(l.C1.IND,(()=>this.index())),this._parser.setExecuteHandler(l.C1.NEL,(()=>this.nextLine())),this._parser.setExecuteHandler(l.C1.HTS,(()=>this.tabSet())),this._parser.registerOscHandler(0,new k.OscHandler((T=>(this.setTitle(T),this.setIconName(T),!0)))),this._parser.registerOscHandler(1,new k.OscHandler((T=>this.setIconName(T)))),this._parser.registerOscHandler(2,new k.OscHandler((T=>this.setTitle(T)))),this._parser.registerOscHandler(4,new k.OscHandler((T=>this.setOrReportIndexedColor(T)))),this._parser.registerOscHandler(8,new k.OscHandler((T=>this.setHyperlink(T)))),this._parser.registerOscHandler(10,new k.OscHandler((T=>this.setOrReportFgColor(T)))),this._parser.registerOscHandler(11,new k.OscHandler((T=>this.setOrReportBgColor(T)))),this._parser.registerOscHandler(12,new k.OscHandler((T=>this.setOrReportCursorColor(T)))),this._parser.registerOscHandler(104,new k.OscHandler((T=>this.restoreIndexedColor(T)))),this._parser.registerOscHandler(110,new k.OscHandler((T=>this.restoreFgColor(T)))),this._parser.registerOscHandler(111,new k.OscHandler((T=>this.restoreBgColor(T)))),this._parser.registerOscHandler(112,new k.OscHandler((T=>this.restoreCursorColor(T)))),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 T in g.CHARSETS)this._parser.registerEscHandler({intermediates:"(",final:T},(()=>this.selectCharset("("+T))),this._parser.registerEscHandler({intermediates:")",final:T},(()=>this.selectCharset(")"+T))),this._parser.registerEscHandler({intermediates:"*",final:T},(()=>this.selectCharset("*"+T))),this._parser.registerEscHandler({intermediates:"+",final:T},(()=>this.selectCharset("+"+T))),this._parser.registerEscHandler({intermediates:"-",final:T},(()=>this.selectCharset("-"+T))),this._parser.registerEscHandler({intermediates:".",final:T},(()=>this.selectCharset("."+T))),this._parser.registerEscHandler({intermediates:"/",final:T},(()=>this.selectCharset("/"+T)));this._parser.registerEscHandler({intermediates:"#",final:"8"},(()=>this.screenAlignmentPattern())),this._parser.setErrorHandler((T=>(this._logService.error("Parsing error: ",T),T))),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new E.DcsHandler(((T,H)=>this.requestStatusString(T,H))))}_preserveStack(A,P,I,B){this._parseStack.paused=!0,this._parseStack.cursorStartX=A,this._parseStack.cursorStartY=P,this._parseStack.decodedLength=I,this._parseStack.position=B}_logSlowResolvingAsync(A){this._logService.logLevel<=S.LogLevelEnum.WARN&&Promise.race([A,new Promise(((P,I)=>setTimeout((()=>I("#SLOW_TIMEOUT")),5e3)))]).catch((P=>{if(P!=="#SLOW_TIMEOUT")throw P;console.warn("async parser handler taking longer than 5000 ms")}))}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(A,P){let I,B=this._activeBuffer.x,$=this._activeBuffer.y,X=0;const Z=this._parseStack.paused;if(Z){if(I=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,P))return this._logSlowResolvingAsync(I),I;B=this._parseStack.cursorStartX,$=this._parseStack.cursorStartY,this._parseStack.paused=!1,A.length>R&&(X=this._parseStack.position+R)}if(this._logService.logLevel<=S.LogLevelEnum.DEBUG&&this._logService.debug("parsing data"+(typeof A=="string"?` "${A}"`:` "${Array.prototype.map.call(A,(J=>String.fromCharCode(J))).join("")}"`),typeof A=="string"?A.split("").map((J=>J.charCodeAt(0))):A),this._parseBuffer.length<A.length&&this._parseBuffer.length<R&&(this._parseBuffer=new Uint32Array(Math.min(A.length,R))),Z||this._dirtyRowTracker.clearRange(),A.length>R)for(let J=X;J<A.length;J+=R){const ae=J+R<A.length?J+R:A.length,T=typeof A=="string"?this._stringDecoder.decode(A.substring(J,ae),this._parseBuffer):this._utf8Decoder.decode(A.subarray(J,ae),this._parseBuffer);if(I=this._parser.parse(this._parseBuffer,T))return this._preserveStack(B,$,T,J),this._logSlowResolvingAsync(I),I}else if(!Z){const J=typeof A=="string"?this._stringDecoder.decode(A,this._parseBuffer):this._utf8Decoder.decode(A,this._parseBuffer);if(I=this._parser.parse(this._parseBuffer,J))return this._preserveStack(B,$,J,0),this._logSlowResolvingAsync(I),I}this._activeBuffer.x===B&&this._activeBuffer.y===$||this._onCursorMove.fire(),this._onRequestRefreshRows.fire(this._dirtyRowTracker.start,this._dirtyRowTracker.end)}print(A,P,I){let B,$;const X=this._charsetService.charset,Z=this._optionsService.rawOptions.screenReaderMode,J=this._bufferService.cols,ae=this._coreService.decPrivateModes.wraparound,T=this._coreService.modes.insertMode,H=this._curAttrData;let U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&I-P>0&&U.getWidth(this._activeBuffer.x-1)===2&&U.setCellFromCodePoint(this._activeBuffer.x-1,0,1,H.fg,H.bg,H.extended);for(let W=P;W<I;++W){if(B=A[W],$=this._unicodeService.wcwidth(B),B<127&&X){const te=X[String.fromCharCode(B)];te&&(B=te.charCodeAt(0))}if(Z&&this._onA11yChar.fire((0,_.stringFromCodePoint)(B)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),$||!this._activeBuffer.x){if(this._activeBuffer.x+$-1>=J){if(ae){for(;this._activeBuffer.x<J;)U.setCellFromCodePoint(this._activeBuffer.x++,0,1,H.fg,H.bg,H.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),U=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y)}else if(this._activeBuffer.x=J-1,$===2)continue}if(T&&(U.insertCells(this._activeBuffer.x,$,this._activeBuffer.getNullCell(H),H),U.getWidth(J-1)===2&&U.setCellFromCodePoint(J-1,d.NULL_CELL_CODE,d.NULL_CELL_WIDTH,H.fg,H.bg,H.extended)),U.setCellFromCodePoint(this._activeBuffer.x++,B,$,H.fg,H.bg,H.extended),$>0)for(;--$;)U.setCellFromCodePoint(this._activeBuffer.x++,0,0,H.fg,H.bg,H.extended)}else U.getWidth(this._activeBuffer.x-1)?U.addCodepointToCell(this._activeBuffer.x-1,B):U.addCodepointToCell(this._activeBuffer.x-2,B)}I-P>0&&(U.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<J&&I-P>0&&U.getWidth(this._activeBuffer.x)===0&&!U.hasContent(this._activeBuffer.x)&&U.setCellFromCodePoint(this._activeBuffer.x,0,1,H.fg,H.bg,H.extended),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(A,P){return A.final!=="t"||A.prefix||A.intermediates?this._parser.registerCsiHandler(A,P):this._parser.registerCsiHandler(A,(I=>!L(I.params[0],this._optionsService.rawOptions.windowOptions)||P(I)))}registerDcsHandler(A,P){return this._parser.registerDcsHandler(A,new E.DcsHandler(P))}registerEscHandler(A,P){return this._parser.registerEscHandler(A,P)}registerOscHandler(A,P){return this._parser.registerOscHandler(A,new k.OscHandler(P))}bell(){return this._onRequestBell.fire(),!0}lineFeed(){return this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._optionsService.rawOptions.convertEol&&(this._activeBuffer.x=0),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows?this._activeBuffer.y=this._bufferService.rows-1:this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.x>=this._bufferService.cols&&this._activeBuffer.x--,this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._onLineFeed.fire(),!0}carriageReturn(){return this._activeBuffer.x=0,!0}backspace(){var A;if(!this._coreService.decPrivateModes.reverseWraparound)return this._restrictCursor(),this._activeBuffer.x>0&&this._activeBuffer.x--,!0;if(this._restrictCursor(this._bufferService.cols),this._activeBuffer.x>0)this._activeBuffer.x--;else if(this._activeBuffer.x===0&&this._activeBuffer.y>this._activeBuffer.scrollTop&&this._activeBuffer.y<=this._activeBuffer.scrollBottom&&(!((A=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))===null||A===void 0)&&A.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);P.hasWidth(this._activeBuffer.x)&&!P.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;const A=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-A),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(A=this._bufferService.cols-1){this._activeBuffer.x=Math.min(A,Math.max(0,this._activeBuffer.x)),this._activeBuffer.y=this._coreService.decPrivateModes.origin?Math.min(this._activeBuffer.scrollBottom,Math.max(this._activeBuffer.scrollTop,this._activeBuffer.y)):Math.min(this._bufferService.rows-1,Math.max(0,this._activeBuffer.y)),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_setCursor(A,P){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=A,this._activeBuffer.y=this._activeBuffer.scrollTop+P):(this._activeBuffer.x=A,this._activeBuffer.y=P),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(A,P){this._restrictCursor(),this._setCursor(this._activeBuffer.x+A,this._activeBuffer.y+P)}cursorUp(A){const P=this._activeBuffer.y-this._activeBuffer.scrollTop;return P>=0?this._moveCursor(0,-Math.min(P,A.params[0]||1)):this._moveCursor(0,-(A.params[0]||1)),!0}cursorDown(A){const P=this._activeBuffer.scrollBottom-this._activeBuffer.y;return P>=0?this._moveCursor(0,Math.min(P,A.params[0]||1)):this._moveCursor(0,A.params[0]||1),!0}cursorForward(A){return this._moveCursor(A.params[0]||1,0),!0}cursorBackward(A){return this._moveCursor(-(A.params[0]||1),0),!0}cursorNextLine(A){return this.cursorDown(A),this._activeBuffer.x=0,!0}cursorPrecedingLine(A){return this.cursorUp(A),this._activeBuffer.x=0,!0}cursorCharAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(A){return this._setCursor(A.length>=2?(A.params[1]||1)-1:0,(A.params[0]||1)-1),!0}charPosAbsolute(A){return this._setCursor((A.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(A){return this._moveCursor(A.params[0]||1,0),!0}linePosAbsolute(A){return this._setCursor(this._activeBuffer.x,(A.params[0]||1)-1),!0}vPositionRelative(A){return this._moveCursor(0,A.params[0]||1),!0}hVPosition(A){return this.cursorPosition(A),!0}tabClear(A){const P=A.params[0];return P===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:P===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=A.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(A){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let P=A.params[0]||1;for(;P--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(A){const P=A.params[0];return P===1&&(this._curAttrData.bg|=536870912),P!==2&&P!==0||(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(A,P,I,B=!1,$=!1){const X=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);X.replaceCells(P,I,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData(),$),B&&(X.isWrapped=!1)}_resetBufferLine(A,P=!1){const I=this._activeBuffer.lines.get(this._activeBuffer.ybase+A);I&&(I.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),P),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+A),I.isWrapped=!1)}eraseInDisplay(A,P=!1){let I;switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:for(I=this._activeBuffer.y,this._dirtyRowTracker.markDirty(I),this._eraseInBufferLine(I++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);I<this._bufferService.rows;I++)this._resetBufferLine(I,P);this._dirtyRowTracker.markDirty(I);break;case 1:for(I=this._activeBuffer.y,this._dirtyRowTracker.markDirty(I),this._eraseInBufferLine(I,0,this._activeBuffer.x+1,!0,P),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(I+1).isWrapped=!1);I--;)this._resetBufferLine(I,P);this._dirtyRowTracker.markDirty(0);break;case 2:for(I=this._bufferService.rows,this._dirtyRowTracker.markDirty(I-1);I--;)this._resetBufferLine(I,P);this._dirtyRowTracker.markDirty(0);break;case 3:const B=this._activeBuffer.lines.length-this._bufferService.rows;B>0&&(this._activeBuffer.lines.trimStart(B),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-B,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-B,0),this._onScroll.fire(0))}return!0}eraseInLine(A,P=!1){switch(this._restrictCursor(this._bufferService.cols),A.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,P);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,P);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,P)}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(A){this._restrictCursor();let P=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=this._activeBuffer.ybase+this._activeBuffer.y,B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,$=this._bufferService.rows-1+this._activeBuffer.ybase-B+1;for(;P--;)this._activeBuffer.lines.splice($-1,1),this._activeBuffer.lines.splice(I,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(A){this._restrictCursor();let P=A.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const I=this._activeBuffer.ybase+this._activeBuffer.y;let B;for(B=this._bufferService.rows-1-this._activeBuffer.scrollBottom,B=this._bufferService.rows-1+this._activeBuffer.ybase-B;P--;)this._activeBuffer.lines.splice(I,1),this._activeBuffer.lines.splice(B,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}insertChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.insertCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.deleteCells(this._activeBuffer.x,A.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(A){let P=A.params[0]||1;for(;P--;)this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollTop,1),this._activeBuffer.lines.splice(this._activeBuffer.ybase+this._activeBuffer.scrollBottom,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollDown(A){let P=A.params[0]||1;for(;P--;)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(o.DEFAULT_ATTR_DATA));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);B.deleteCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);B.insertCells(0,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);B.insertCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(A){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;const P=A.params[0]||1;for(let I=this._activeBuffer.scrollTop;I<=this._activeBuffer.scrollBottom;++I){const B=this._activeBuffer.lines.get(this._activeBuffer.ybase+I);B.deleteCells(this._activeBuffer.x,P,this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),B.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(A){this._restrictCursor();const P=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return P&&(P.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(A.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData()),this._eraseAttrData()),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(A){if(!this._parser.precedingCodepoint)return!0;const P=A.params[0]||1,I=new Uint32Array(P);for(let B=0;B<P;++B)I[B]=this._parser.precedingCodepoint;return this.print(I,0,I.length),!0}sendDeviceAttributesPrimary(A){return A.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(l.C0.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(l.C0.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(A){return A.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(l.C0.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(l.C0.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(A.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(l.C0.ESC+"[>83;40003;0c")),!0}_is(A){return(this._optionsService.rawOptions.termName+"").indexOf(A)===0}setMode(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0}return!0}setModePrivate(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),this._charsetService.setgCharset(1,g.DEFAULT_CHARSET),this._charsetService.setgCharset(2,g.DEFAULT_CHARSET),this._charsetService.setgCharset(3,g.DEFAULT_CHARSET);break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(132,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!0,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!0;break;case 12:this._optionsService.options.cursorBlink=!0;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!0;break;case 66:this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire();break;case 9:this._coreMouseService.activeProtocol="X10";break;case 1e3:this._coreMouseService.activeProtocol="VT200";break;case 1002:this._coreMouseService.activeProtocol="DRAG";break;case 1003:this._coreMouseService.activeProtocol="ANY";break;case 1004:this._coreService.decPrivateModes.sendFocus=!0,this._onRequestSendFocus.fire();break;case 1005:this._logService.debug("DECSET 1005 not supported (see #2507)");break;case 1006:this._coreMouseService.activeEncoding="SGR";break;case 1015:this._logService.debug("DECSET 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="SGR_PIXELS";break;case 25:this._coreService.isCursorHidden=!1;break;case 1048:this.saveCursor();break;case 1049:this.saveCursor();case 47:case 1047:this._bufferService.buffers.activateAltBuffer(this._eraseAttrData()),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0}return!0}resetMode(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1}return!0}resetModePrivate(A){for(let P=0;P<A.length;P++)switch(A.params[P]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!1;break;case 3:this._optionsService.rawOptions.windowOptions.setWinLines&&(this._bufferService.resize(80,this._bufferService.rows),this._onRequestReset.fire());break;case 6:this._coreService.decPrivateModes.origin=!1,this._setCursor(0,0);break;case 7:this._coreService.decPrivateModes.wraparound=!1;break;case 12:this._optionsService.options.cursorBlink=!1;break;case 45:this._coreService.decPrivateModes.reverseWraparound=!1;break;case 66:this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire();break;case 9:case 1e3:case 1002:case 1003:this._coreMouseService.activeProtocol="NONE";break;case 1004:this._coreService.decPrivateModes.sendFocus=!1;break;case 1005:this._logService.debug("DECRST 1005 not supported (see #2507)");break;case 1006:case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),A.params[P]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(0,this._bufferService.rows-1),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1}return!0}requestMode(A,P){const I=this._coreService.decPrivateModes,{activeProtocol:B,activeEncoding:$}=this._coreMouseService,X=this._coreService,{buffers:Z,cols:J}=this._bufferService,{active:ae,alt:T}=Z,H=this._optionsService.rawOptions,U=ce=>ce?1:2,W=A.params[0];return te=W,K=P?W===2?4:W===4?U(X.modes.insertMode):W===12?3:W===20?U(H.convertEol):0:W===1?U(I.applicationCursorKeys):W===3?H.windowOptions.setWinLines?J===80?2:J===132?1:0:0:W===6?U(I.origin):W===7?U(I.wraparound):W===8?3:W===9?U(B==="X10"):W===12?U(H.cursorBlink):W===25?U(!X.isCursorHidden):W===45?U(I.reverseWraparound):W===66?U(I.applicationKeypad):W===67?4:W===1e3?U(B==="VT200"):W===1002?U(B==="DRAG"):W===1003?U(B==="ANY"):W===1004?U(I.sendFocus):W===1005?4:W===1006?U($==="SGR"):W===1015?4:W===1016?U($==="SGR_PIXELS"):W===1048?1:W===47||W===1047||W===1049?U(ae===T):W===2004?U(I.bracketedPasteMode):0,X.triggerDataEvent(`${l.C0.ESC}[${P?"":"?"}${te};${K}$y`),!0;var te,K}_updateAttrColor(A,P,I,B,$){return P===2?(A|=50331648,A&=-16777216,A|=x.AttributeData.fromColorRGB([I,B,$])):P===5&&(A&=-50331904,A|=33554432|255&I),A}_extractColor(A,P,I){const B=[0,0,-1,0,0,0];let $=0,X=0;do{if(B[X+$]=A.params[P+X],A.hasSubParams(P+X)){const Z=A.getSubParams(P+X);let J=0;do B[1]===5&&($=1),B[X+J+1+$]=Z[J];while(++J<Z.length&&J+X+1+$<B.length);break}if(B[1]===5&&X+$>=2||B[1]===2&&X+$>=5)break;B[1]&&($=1)}while(++X+P<A.length&&X+$<B.length);for(let Z=2;Z<B.length;++Z)B[Z]===-1&&(B[Z]=0);switch(B[0]){case 38:I.fg=this._updateAttrColor(I.fg,B[1],B[3],B[4],B[5]);break;case 48:I.bg=this._updateAttrColor(I.bg,B[1],B[3],B[4],B[5]);break;case 58:I.extended=I.extended.clone(),I.extended.underlineColor=this._updateAttrColor(I.extended.underlineColor,B[1],B[3],B[4],B[5])}return X}_processUnderline(A,P){P.extended=P.extended.clone(),(!~A||A>5)&&(A=1),P.extended.underlineStyle=A,P.fg|=268435456,A===0&&(P.fg&=-268435457),P.updateExtended()}_processSGR0(A){A.fg=o.DEFAULT_ATTR_DATA.fg,A.bg=o.DEFAULT_ATTR_DATA.bg,A.extended=A.extended.clone(),A.extended.underlineStyle=0,A.extended.underlineColor&=-67108864,A.updateExtended()}charAttributes(A){if(A.length===1&&A.params[0]===0)return this._processSGR0(this._curAttrData),!0;const P=A.length;let I;const B=this._curAttrData;for(let $=0;$<P;$++)I=A.params[$],I>=30&&I<=37?(B.fg&=-50331904,B.fg|=16777216|I-30):I>=40&&I<=47?(B.bg&=-50331904,B.bg|=16777216|I-40):I>=90&&I<=97?(B.fg&=-50331904,B.fg|=16777224|I-90):I>=100&&I<=107?(B.bg&=-50331904,B.bg|=16777224|I-100):I===0?this._processSGR0(B):I===1?B.fg|=134217728:I===3?B.bg|=67108864:I===4?(B.fg|=268435456,this._processUnderline(A.hasSubParams($)?A.getSubParams($)[0]:1,B)):I===5?B.fg|=536870912:I===7?B.fg|=67108864:I===8?B.fg|=1073741824:I===9?B.fg|=2147483648:I===2?B.bg|=134217728:I===21?this._processUnderline(2,B):I===22?(B.fg&=-134217729,B.bg&=-134217729):I===23?B.bg&=-67108865:I===24?(B.fg&=-268435457,this._processUnderline(0,B)):I===25?B.fg&=-536870913:I===27?B.fg&=-67108865:I===28?B.fg&=-1073741825:I===29?B.fg&=2147483647:I===39?(B.fg&=-67108864,B.fg|=16777215&o.DEFAULT_ATTR_DATA.fg):I===49?(B.bg&=-67108864,B.bg|=16777215&o.DEFAULT_ATTR_DATA.bg):I===38||I===48||I===58?$+=this._extractColor(A,$,B):I===53?B.bg|=1073741824:I===55?B.bg&=-1073741825:I===59?(B.extended=B.extended.clone(),B.extended.underlineColor=-1,B.updateExtended()):I===100?(B.fg&=-67108864,B.fg|=16777215&o.DEFAULT_ATTR_DATA.fg,B.bg&=-67108864,B.bg|=16777215&o.DEFAULT_ATTR_DATA.bg):this._logService.debug("Unknown SGR attribute: %d.",I);return!0}deviceStatus(A){switch(A.params[0]){case 5:this._coreService.triggerDataEvent(`${l.C0.ESC}[0n`);break;case 6:const P=this._activeBuffer.y+1,I=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[${P};${I}R`)}return!0}deviceStatusPrivate(A){if(A.params[0]===6){const P=this._activeBuffer.y+1,I=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${l.C0.ESC}[?${P};${I}R`)}return!0}softReset(A){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._coreService.reset(),this._charsetService.reset(),this._activeBuffer.savedX=0,this._activeBuffer.savedY=this._activeBuffer.ybase,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,this._coreService.decPrivateModes.origin=!1,!0}setCursorStyle(A){const P=A.params[0]||1;switch(P){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 I=P%2==1;return this._optionsService.options.cursorBlink=I,!0}setScrollRegion(A){const P=A.params[0]||1;let I;return(A.length<2||(I=A.params[1])>this._bufferService.rows||I===0)&&(I=this._bufferService.rows),I>P&&(this._activeBuffer.scrollTop=P-1,this._activeBuffer.scrollBottom=I-1,this._setCursor(0,0)),!0}windowOptions(A){if(!L(A.params[0],this._optionsService.rawOptions.windowOptions))return!0;const P=A.length>1?A.params[1]:0;switch(A.params[0]){case 14:P!==2&&this._onRequestWindowsOptionsReport.fire(D.GET_WIN_SIZE_PIXELS);break;case 16:this._onRequestWindowsOptionsReport.fire(D.GET_CELL_SIZE_PIXELS);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${l.C0.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:P!==0&&P!==2||(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>10&&this._windowTitleStack.shift()),P!==0&&P!==1||(this._iconNameStack.push(this._iconName),this._iconNameStack.length>10&&this._iconNameStack.shift());break;case 23:P!==0&&P!==2||this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),P!==0&&P!==1||this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop())}return!0}saveCursor(A){return this._activeBuffer.savedX=this._activeBuffer.x,this._activeBuffer.savedY=this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.savedCurAttrData.fg=this._curAttrData.fg,this._activeBuffer.savedCurAttrData.bg=this._curAttrData.bg,this._activeBuffer.savedCharset=this._charsetService.charset,!0}restoreCursor(A){return this._activeBuffer.x=this._activeBuffer.savedX||0,this._activeBuffer.y=Math.max(this._activeBuffer.savedY-this._activeBuffer.ybase,0),this._curAttrData.fg=this._activeBuffer.savedCurAttrData.fg,this._curAttrData.bg=this._activeBuffer.savedCurAttrData.bg,this._charsetService.charset=this._savedCharset,this._activeBuffer.savedCharset&&(this._charsetService.charset=this._activeBuffer.savedCharset),this._restrictCursor(),!0}setTitle(A){return this._windowTitle=A,this._onTitleChange.fire(A),!0}setIconName(A){return this._iconName=A,!0}setOrReportIndexedColor(A){const P=[],I=A.split(";");for(;I.length>1;){const B=I.shift(),$=I.shift();if(/^\d+$/.exec(B)){const X=parseInt(B);if(F(X))if($==="?")P.push({type:0,index:X});else{const Z=(0,w.parseColor)($);Z&&P.push({type:1,index:X,color:Z})}}}return P.length&&this._onColor.fire(P),!0}setHyperlink(A){const P=A.split(";");return!(P.length<2)&&(P[1]?this._createHyperlink(P[0],P[1]):!P[0]&&this._finishHyperlink())}_createHyperlink(A,P){this._getCurrentLinkId()&&this._finishHyperlink();const I=A.split(":");let B;const $=I.findIndex((X=>X.startsWith("id=")));return $!==-1&&(B=I[$].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:B,uri:P}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(A,P){const I=A.split(";");for(let B=0;B<I.length&&!(P>=this._specialColors.length);++B,++P)if(I[B]==="?")this._onColor.fire([{type:0,index:this._specialColors[P]}]);else{const $=(0,w.parseColor)(I[B]);$&&this._onColor.fire([{type:1,index:this._specialColors[P],color:$}])}return!0}setOrReportFgColor(A){return this._setOrReportSpecialColor(A,0)}setOrReportBgColor(A){return this._setOrReportSpecialColor(A,1)}setOrReportCursorColor(A){return this._setOrReportSpecialColor(A,2)}restoreIndexedColor(A){if(!A)return this._onColor.fire([{type:2}]),!0;const P=[],I=A.split(";");for(let B=0;B<I.length;++B)if(/^\d+$/.exec(I[B])){const $=parseInt(I[B]);F($)&&P.push({type:2,index:$})}return P.length&&this._onColor.fire(P),!0}restoreFgColor(A){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(A){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(A){return this._onColor.fire([{type:2,index:258}]),!0}nextLine(){return this._activeBuffer.x=0,this.index(),!0}keypadApplicationMode(){return this._logService.debug("Serial port requested application keypad."),this._coreService.decPrivateModes.applicationKeypad=!0,this._onRequestSyncScrollBar.fire(),!0}keypadNumericMode(){return this._logService.debug("Switching back to normal keypad."),this._coreService.decPrivateModes.applicationKeypad=!1,this._onRequestSyncScrollBar.fire(),!0}selectDefaultCharset(){return this._charsetService.setgLevel(0),this._charsetService.setgCharset(0,g.DEFAULT_CHARSET),!0}selectCharset(A){return A.length!==2?(this.selectDefaultCharset(),!0):(A[0]==="/"||this._charsetService.setgCharset(j[A[0]],g.CHARSETS[A[1]]||g.DEFAULT_CHARSET),!0)}index(){return this._restrictCursor(),this._activeBuffer.y++,this._activeBuffer.y===this._activeBuffer.scrollBottom+1?(this._activeBuffer.y--,this._bufferService.scroll(this._eraseAttrData())):this._activeBuffer.y>=this._bufferService.rows&&(this._activeBuffer.y=this._bufferService.rows-1),this._restrictCursor(),!0}tabSet(){return this._activeBuffer.tabs[this._activeBuffer.x]=!0,!0}reverseIndex(){if(this._restrictCursor(),this._activeBuffer.y===this._activeBuffer.scrollTop){const A=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,A,1),this._activeBuffer.lines.set(this._activeBuffer.ybase+this._activeBuffer.y,this._activeBuffer.getBlankLine(this._eraseAttrData())),this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom)}else this._activeBuffer.y--,this._restrictCursor();return!0}fullReset(){return this._parser.reset(),this._onRequestReset.fire(),!0}reset(){this._curAttrData=o.DEFAULT_ATTR_DATA.clone(),this._eraseAttrDataInternal=o.DEFAULT_ATTR_DATA.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=67108863&this._curAttrData.bg,this._eraseAttrDataInternal}setgLevel(A){return this._charsetService.setgLevel(A),!0}screenAlignmentPattern(){const A=new u.CellData;A.content=4194373,A.fg=this._curAttrData.fg,A.bg=this._curAttrData.bg,this._setCursor(0,0);for(let P=0;P<this._bufferService.rows;++P){const I=this._activeBuffer.ybase+this._activeBuffer.y+P,B=this._activeBuffer.lines.get(I);B&&(B.fill(A),B.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(A,P){const I=this._bufferService.buffer,B=this._optionsService.rawOptions;return($=>(this._coreService.triggerDataEvent(`${l.C0.ESC}${$}${l.C0.ESC}\\`),!0))(A==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:A==='"p'?'P1$r61;1"p':A==="r"?`P1$r${I.scrollTop+1};${I.scrollBottom+1}r`:A==="m"?"P1$r0m":A===" q"?`P1$r${{block:2,underline:4,bar:6}[B.cursorStyle]-(B.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(A,P){this._dirtyRowTracker.markRangeDirty(A,P)}}i.InputHandler=M;let O=class{constructor(z){this._bufferService=z,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(z){z<this.start?this.start=z:z>this.end&&(this.end=z)}markRangeDirty(z,A){z>A&&(N=z,z=A,A=N),z<this.start&&(this.start=z),A>this.end&&(this.end=A)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};function F(z){return 0<=z&&z<256}O=c([f(0,S.IBufferService)],O)},844:(v,i)=>{function n(c){for(const f of c)f.dispose();c.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 c of this._disposables)c.dispose();this._disposables.length=0}register(c){return this._disposables.push(c),c}unregister(c){const f=this._disposables.indexOf(c);f!==-1&&this._disposables.splice(f,1)}},i.MutableDisposable=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(c){var f;this._isDisposed||c===this._value||((f=this._value)===null||f===void 0||f.dispose(),this._value=c)}clear(){this.value=void 0}dispose(){var c;this._isDisposed=!0,(c=this._value)===null||c===void 0||c.dispose(),this._value=void 0}},i.toDisposable=function(c){return{dispose:c}},i.disposeArray=n,i.getDisposeArrayDisposable=function(c){return{dispose:()=>n(c)}}},1505:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.FourKeyMap=i.TwoKeyMap=void 0;class n{constructor(){this._data={}}set(f,l,g){this._data[f]||(this._data[f]={}),this._data[f][l]=g}get(f,l){return this._data[f]?this._data[f][l]:void 0}clear(){this._data={}}}i.TwoKeyMap=n,i.FourKeyMap=class{constructor(){this._data=new n}set(c,f,l,g,b){this._data.get(c,f)||this._data.set(c,f,new n),this._data.get(c,f).set(l,g,b)}get(c,f,l,g){var b;return(b=this._data.get(c,f))===null||b===void 0?void 0:b.get(l,g)}clear(){this._data.clear()}}},6114:(v,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,c=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 f=n.match(/Version\/(\d+)/);return f===null||f.length<2?0:parseInt(f[1])},i.isMac=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(c),i.isIpad=c==="iPad",i.isIphone=c==="iPhone",i.isWindows=["Windows","Win16","Win32","WinCE"].includes(c),i.isLinux=c.indexOf("Linux")>=0,i.isChromeOS=/\bCrOS\b/.test(n)},6106:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.SortedList=void 0;let n=0;i.SortedList=class{constructor(c){this._getKey=c,this._array=[]}clear(){this._array.length=0}insert(c){this._array.length!==0?(n=this._search(this._getKey(c)),this._array.splice(n,0,c)):this._array.push(c)}delete(c){if(this._array.length===0)return!1;const f=this._getKey(c);if(f===void 0||(n=this._search(f),n===-1)||this._getKey(this._array[n])!==f)return!1;do if(this._array[n]===c)return this._array.splice(n,1),!0;while(++n<this._array.length&&this._getKey(this._array[n])===f);return!1}*getKeyIterator(c){if(this._array.length!==0&&(n=this._search(c),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===c))do yield this._array[n];while(++n<this._array.length&&this._getKey(this._array[n])===c)}forEachByKey(c,f){if(this._array.length!==0&&(n=this._search(c),!(n<0||n>=this._array.length)&&this._getKey(this._array[n])===c))do f(this._array[n]);while(++n<this._array.length&&this._getKey(this._array[n])===c)}values(){return[...this._array].values()}_search(c){let f=0,l=this._array.length-1;for(;l>=f;){let g=f+l>>1;const b=this._getKey(this._array[g]);if(b>c)l=g-1;else{if(!(b<c)){for(;g>0&&this._getKey(this._array[g-1])===c;)g--;return g}f=g+1}}return f}}},7226:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DebouncedIdleTask=i.IdleTaskQueue=i.PriorityTaskQueue=void 0;const c=n(6114);class f{constructor(){this._tasks=[],this._i=0}enqueue(b){this._tasks.push(b),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(b){this._idleCallback=void 0;let y=0,_=0,o=b.timeRemaining(),h=0;for(;this._i<this._tasks.length;){if(y=Date.now(),this._tasks[this._i]()||this._i++,y=Math.max(1,Date.now()-y),_=Math.max(y,_),h=b.timeRemaining(),1.5*_>h)return o-y<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(o-y))}ms`),void this._start();o=h}this.clear()}}class l extends f{_requestCallback(b){return setTimeout((()=>b(this._createDeadline(16))))}_cancelCallback(b){clearTimeout(b)}_createDeadline(b){const y=Date.now()+b;return{timeRemaining:()=>Math.max(0,y-Date.now())}}}i.PriorityTaskQueue=l,i.IdleTaskQueue=!c.isNode&&"requestIdleCallback"in window?class extends f{_requestCallback(g){return requestIdleCallback(g)}_cancelCallback(g){cancelIdleCallback(g)}}:l,i.DebouncedIdleTask=class{constructor(){this._queue=new i.IdleTaskQueue}set(g){this._queue.clear(),this._queue.enqueue(g)}flush(){this._queue.flush()}}},9282:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.updateWindowsModeWrappedState=void 0;const c=n(643);i.updateWindowsModeWrappedState=function(f){const l=f.buffer.lines.get(f.buffer.ybase+f.buffer.y-1),g=l?.get(f.cols-1),b=f.buffer.lines.get(f.buffer.ybase+f.buffer.y);b&&g&&(b.isWrapped=g[c.CHAR_DATA_CODE_INDEX]!==c.NULL_CELL_CODE&&g[c.CHAR_DATA_CODE_INDEX]!==c.WHITESPACE_CELL_CODE)}},3734:(v,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 c}static toColorRGB(l){return[l>>>16&255,l>>>8&255,255&l]}static fromColorRGB(l){return(255&l[0])<<16|(255&l[1])<<8|255&l[2]}clone(){const l=new n;return l.fg=this.fg,l.bg=this.bg,l.extended=this.extended.clone(),l}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 c{get ext(){return this._urlId?-469762049&this._ext|this.underlineStyle<<26:this._ext}set ext(l){this._ext=l}get underlineStyle(){return this._urlId?5:(469762048&this._ext)>>26}set underlineStyle(l){this._ext&=-469762049,this._ext|=l<<26&469762048}get underlineColor(){return 67108863&this._ext}set underlineColor(l){this._ext&=-67108864,this._ext|=67108863&l}get urlId(){return this._urlId}set urlId(l){this._urlId=l}constructor(l=0,g=0){this._ext=0,this._urlId=0,this._ext=l,this._urlId=g}clone(){return new c(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}}i.ExtendedAttrs=c},9092:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Buffer=i.MAX_BUFFER_SIZE=void 0;const c=n(6349),f=n(7226),l=n(3734),g=n(8437),b=n(4634),y=n(511),_=n(643),o=n(4863),h=n(7116);i.MAX_BUFFER_SIZE=4294967295,i.Buffer=class{constructor(d,u,x){this._hasScrollback=d,this._optionsService=u,this._bufferService=x,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=h.DEFAULT_CHARSET,this.markers=[],this._nullCell=y.CellData.fromCharData([0,_.NULL_CELL_CHAR,_.NULL_CELL_WIDTH,_.NULL_CELL_CODE]),this._whitespaceCell=y.CellData.fromCharData([0,_.WHITESPACE_CELL_CHAR,_.WHITESPACE_CELL_WIDTH,_.WHITESPACE_CELL_CODE]),this._isClearing=!1,this._memoryCleanupQueue=new f.IdleTaskQueue,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new c.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 l.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 l.ExtendedAttrs),this._whitespaceCell}getBlankLine(d,u){return new g.BufferLine(this._bufferService.cols,this.getNullCell(d),u)}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 u=d+this._optionsService.rawOptions.scrollback;return u>i.MAX_BUFFER_SIZE?i.MAX_BUFFER_SIZE:u}fillViewportRows(d){if(this.lines.length===0){d===void 0&&(d=g.DEFAULT_ATTR_DATA);let u=this._rows;for(;u--;)this.lines.push(this.getBlankLine(d))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new c.CircularList(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(d,u){const x=this.getNullCell(g.DEFAULT_ATTR_DATA);let S=0;const k=this._getCorrectBufferLength(u);if(k>this.lines.maxLength&&(this.lines.maxLength=k),this.lines.length>0){if(this._cols<d)for(let w=0;w<this.lines.length;w++)S+=+this.lines.get(w).resize(d,x);let E=0;if(this._rows<u)for(let w=this._rows;w<u;w++)this.lines.length<u+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,x)):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,x)));else for(let w=this._rows;w>u;w--)this.lines.length>u+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(k<this.lines.maxLength){const w=this.lines.length-k;w>0&&(this.lines.trimStart(w),this.ybase=Math.max(this.ybase-w,0),this.ydisp=Math.max(this.ydisp-w,0),this.savedY=Math.max(this.savedY-w,0)),this.lines.maxLength=k}this.x=Math.min(this.x,d-1),this.y=Math.min(this.y,u-1),E&&(this.y+=E),this.savedX=Math.min(this.savedX,d-1),this.scrollTop=0}if(this.scrollBottom=u-1,this._isReflowEnabled&&(this._reflow(d,u),this._cols>d))for(let E=0;E<this.lines.length;E++)S+=+this.lines.get(E).resize(d,x);this._cols=d,this._rows=u,this._memoryCleanupQueue.clear(),S>.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 u=0;for(;this._memoryCleanupPosition<this.lines.length;)if(u+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),u>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,u){this._cols!==d&&(d>this._cols?this._reflowLarger(d,u):this._reflowSmaller(d,u))}_reflowLarger(d,u){const x=(0,b.reflowLargerGetLinesToRemove)(this.lines,this._cols,d,this.ybase+this.y,this.getNullCell(g.DEFAULT_ATTR_DATA));if(x.length>0){const S=(0,b.reflowLargerCreateNewLayout)(this.lines,x);(0,b.reflowLargerApplyNewLayout)(this.lines,S.layout),this._reflowLargerAdjustViewport(d,u,S.countRemoved)}}_reflowLargerAdjustViewport(d,u,x){const S=this.getNullCell(g.DEFAULT_ATTR_DATA);let k=x;for(;k-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<u&&this.lines.push(new g.BufferLine(d,S))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-x,0)}_reflowSmaller(d,u){const x=this.getNullCell(g.DEFAULT_ATTR_DATA),S=[];let k=0;for(let E=this.lines.length-1;E>=0;E--){let w=this.lines.get(E);if(!w||!w.isWrapped&&w.getTrimmedLength()<=d)continue;const j=[w];for(;w.isWrapped&&E>0;)w=this.lines.get(--E),j.unshift(w);const R=this.ybase+this.y;if(R>=E&&R<E+j.length)continue;const L=j[j.length-1].getTrimmedLength(),D=(0,b.reflowSmallerGetNewLineLengths)(j,this._cols,d),N=D.length-j.length;let M;M=this.ybase===0&&this.y!==this.lines.length-1?Math.max(0,this.y-this.lines.maxLength+N):Math.max(0,this.lines.length-this.lines.maxLength+N);const O=[];for(let B=0;B<N;B++){const $=this.getBlankLine(g.DEFAULT_ATTR_DATA,!0);O.push($)}O.length>0&&(S.push({start:E+j.length+k,newLines:O}),k+=O.length),j.push(...O);let F=D.length-1,z=D[F];z===0&&(F--,z=D[F]);let A=j.length-N-1,P=L;for(;A>=0;){const B=Math.min(P,z);if(j[F]===void 0)break;if(j[F].copyCellsFrom(j[A],P-B,z-B,B,!0),z-=B,z===0&&(F--,z=D[F]),P-=B,P===0){A--;const $=Math.max(A,0);P=(0,b.getWrappedLineTrimmedLength)(j,$,this._cols)}}for(let B=0;B<j.length;B++)D[B]<d&&j[B].setCell(D[B],x);let I=N-M;for(;I-- >0;)this.ybase===0?this.y<u-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+k)-u&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+N,this.ybase+u-1)}if(S.length>0){const E=[],w=[];for(let F=0;F<this.lines.length;F++)w.push(this.lines.get(F));const j=this.lines.length;let R=j-1,L=0,D=S[L];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+k);let N=0;for(let F=Math.min(this.lines.maxLength-1,j+k-1);F>=0;F--)if(D&&D.start>R+N){for(let z=D.newLines.length-1;z>=0;z--)this.lines.set(F--,D.newLines[z]);F++,E.push({index:R+1,amount:D.newLines.length}),N+=D.newLines.length,D=S[++L]}else this.lines.set(F,w[R--]);let M=0;for(let F=E.length-1;F>=0;F--)E[F].index+=M,this.lines.onInsertEmitter.fire(E[F]),M+=E[F].amount;const O=Math.max(0,j+k-this.lines.maxLength);O>0&&this.lines.onTrimEmitter.fire(O)}}translateBufferLineToString(d,u,x=0,S){const k=this.lines.get(d);return k?k.translateToString(u,x,S):""}getWrappedRangeForLine(d){let u=d,x=d;for(;u>0&&this.lines.get(u).isWrapped;)u--;for(;x+1<this.lines.length&&this.lines.get(x+1).isWrapped;)x++;return{first:u,last:x}}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 u=0;u<this.markers.length;u++)this.markers[u].line===d&&(this.markers[u].dispose(),this.markers.splice(u--,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 u=new o.Marker(d);return this.markers.push(u),u.register(this.lines.onTrim((x=>{u.line-=x,u.line<0&&u.dispose()}))),u.register(this.lines.onInsert((x=>{u.line>=x.index&&(u.line+=x.amount)}))),u.register(this.lines.onDelete((x=>{u.line>=x.index&&u.line<x.index+x.amount&&u.dispose(),u.line>x.index&&(u.line-=x.amount)}))),u.register(u.onDispose((()=>this._removeMarker(u)))),u}_removeMarker(d){this._isClearing||this.markers.splice(this.markers.indexOf(d),1)}}},8437:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLine=i.DEFAULT_ATTR_DATA=void 0;const c=n(3734),f=n(511),l=n(643),g=n(482);i.DEFAULT_ATTR_DATA=Object.freeze(new c.AttributeData);let b=0;class y{constructor(o,h,d=!1){this.isWrapped=d,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(3*o);const u=h||f.CellData.fromCharData([0,l.NULL_CELL_CHAR,l.NULL_CELL_WIDTH,l.NULL_CELL_CODE]);for(let x=0;x<o;++x)this.setCell(x,u);this.length=o}get(o){const h=this._data[3*o+0],d=2097151&h;return[this._data[3*o+1],2097152&h?this._combined[o]:d?(0,g.stringFromCodePoint)(d):"",h>>22,2097152&h?this._combined[o].charCodeAt(this._combined[o].length-1):d]}set(o,h){this._data[3*o+1]=h[l.CHAR_DATA_ATTR_INDEX],h[l.CHAR_DATA_CHAR_INDEX].length>1?(this._combined[o]=h[1],this._data[3*o+0]=2097152|o|h[l.CHAR_DATA_WIDTH_INDEX]<<22):this._data[3*o+0]=h[l.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|h[l.CHAR_DATA_WIDTH_INDEX]<<22}getWidth(o){return this._data[3*o+0]>>22}hasWidth(o){return 12582912&this._data[3*o+0]}getFg(o){return this._data[3*o+1]}getBg(o){return this._data[3*o+2]}hasContent(o){return 4194303&this._data[3*o+0]}getCodePoint(o){const h=this._data[3*o+0];return 2097152&h?this._combined[o].charCodeAt(this._combined[o].length-1):2097151&h}isCombined(o){return 2097152&this._data[3*o+0]}getString(o){const h=this._data[3*o+0];return 2097152&h?this._combined[o]:2097151&h?(0,g.stringFromCodePoint)(2097151&h):""}isProtected(o){return 536870912&this._data[3*o+2]}loadCell(o,h){return b=3*o,h.content=this._data[b+0],h.fg=this._data[b+1],h.bg=this._data[b+2],2097152&h.content&&(h.combinedData=this._combined[o]),268435456&h.bg&&(h.extended=this._extendedAttrs[o]),h}setCell(o,h){2097152&h.content&&(this._combined[o]=h.combinedData),268435456&h.bg&&(this._extendedAttrs[o]=h.extended),this._data[3*o+0]=h.content,this._data[3*o+1]=h.fg,this._data[3*o+2]=h.bg}setCellFromCodePoint(o,h,d,u,x,S){268435456&x&&(this._extendedAttrs[o]=S),this._data[3*o+0]=h|d<<22,this._data[3*o+1]=u,this._data[3*o+2]=x}addCodepointToCell(o,h){let d=this._data[3*o+0];2097152&d?this._combined[o]+=(0,g.stringFromCodePoint)(h):(2097151&d?(this._combined[o]=(0,g.stringFromCodePoint)(2097151&d)+(0,g.stringFromCodePoint)(h),d&=-2097152,d|=2097152):d=h|4194304,this._data[3*o+0]=d)}insertCells(o,h,d,u){if((o%=this.length)&&this.getWidth(o-1)===2&&this.setCellFromCodePoint(o-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length-o){const x=new f.CellData;for(let S=this.length-o-h-1;S>=0;--S)this.setCell(o+h+S,this.loadCell(o+S,x));for(let S=0;S<h;++S)this.setCell(o+S,d)}else for(let x=o;x<this.length;++x)this.setCell(x,d);this.getWidth(this.length-1)===2&&this.setCellFromCodePoint(this.length-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}deleteCells(o,h,d,u){if(o%=this.length,h<this.length-o){const x=new f.CellData;for(let S=0;S<this.length-o-h;++S)this.setCell(o+S,this.loadCell(o+h+S,x));for(let S=this.length-h;S<this.length;++S)this.setCell(S,d)}else for(let x=o;x<this.length;++x)this.setCell(x,d);o&&this.getWidth(o-1)===2&&this.setCellFromCodePoint(o-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),this.getWidth(o)!==0||this.hasContent(o)||this.setCellFromCodePoint(o,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs)}replaceCells(o,h,d,u,x=!1){if(x)for(o&&this.getWidth(o-1)===2&&!this.isProtected(o-1)&&this.setCellFromCodePoint(o-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&!this.isProtected(h)&&this.setCellFromCodePoint(h,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs);o<h&&o<this.length;)this.isProtected(o)||this.setCell(o,d),o++;else for(o&&this.getWidth(o-1)===2&&this.setCellFromCodePoint(o-1,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs),h<this.length&&this.getWidth(h-1)===2&&this.setCellFromCodePoint(h,0,1,u?.fg||0,u?.bg||0,u?.extended||new c.ExtendedAttrs);o<h&&o<this.length;)this.setCell(o++,d)}resize(o,h){if(o===this.length)return 4*this._data.length*2<this._data.buffer.byteLength;const d=3*o;if(o>this.length){if(this._data.buffer.byteLength>=4*d)this._data=new Uint32Array(this._data.buffer,0,d);else{const u=new Uint32Array(d);u.set(this._data),this._data=u}for(let u=this.length;u<o;++u)this.setCell(u,h)}else{this._data=this._data.subarray(0,d);const u=Object.keys(this._combined);for(let S=0;S<u.length;S++){const k=parseInt(u[S],10);k>=o&&delete this._combined[k]}const x=Object.keys(this._extendedAttrs);for(let S=0;S<x.length;S++){const k=parseInt(x[S],10);k>=o&&delete this._extendedAttrs[k]}}return this.length=o,4*d*2<this._data.buffer.byteLength}cleanupMemory(){if(4*this._data.length*2<this._data.buffer.byteLength){const o=new Uint32Array(this._data.length);return o.set(this._data),this._data=o,1}return 0}fill(o,h=!1){if(h)for(let d=0;d<this.length;++d)this.isProtected(d)||this.setCell(d,o);else{this._combined={},this._extendedAttrs={};for(let d=0;d<this.length;++d)this.setCell(d,o)}}copyFrom(o){this.length!==o.length?this._data=new Uint32Array(o._data):this._data.set(o._data),this.length=o.length,this._combined={};for(const h in o._combined)this._combined[h]=o._combined[h];this._extendedAttrs={};for(const h in o._extendedAttrs)this._extendedAttrs[h]=o._extendedAttrs[h];this.isWrapped=o.isWrapped}clone(){const o=new y(0);o._data=new Uint32Array(this._data),o.length=this.length;for(const h in this._combined)o._combined[h]=this._combined[h];for(const h in this._extendedAttrs)o._extendedAttrs[h]=this._extendedAttrs[h];return o.isWrapped=this.isWrapped,o}getTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0])return o+(this._data[3*o+0]>>22);return 0}getNoBgTrimmedLength(){for(let o=this.length-1;o>=0;--o)if(4194303&this._data[3*o+0]||50331648&this._data[3*o+2])return o+(this._data[3*o+0]>>22);return 0}copyCellsFrom(o,h,d,u,x){const S=o._data;if(x)for(let E=u-1;E>=0;E--){for(let w=0;w<3;w++)this._data[3*(d+E)+w]=S[3*(h+E)+w];268435456&S[3*(h+E)+2]&&(this._extendedAttrs[d+E]=o._extendedAttrs[h+E])}else for(let E=0;E<u;E++){for(let w=0;w<3;w++)this._data[3*(d+E)+w]=S[3*(h+E)+w];268435456&S[3*(h+E)+2]&&(this._extendedAttrs[d+E]=o._extendedAttrs[h+E])}const k=Object.keys(o._combined);for(let E=0;E<k.length;E++){const w=parseInt(k[E],10);w>=h&&(this._combined[w-h+d]=o._combined[w])}}translateToString(o=!1,h=0,d=this.length){o&&(d=Math.min(d,this.getTrimmedLength()));let u="";for(;h<d;){const x=this._data[3*h+0],S=2097151&x;u+=2097152&x?this._combined[h]:S?(0,g.stringFromCodePoint)(S):l.WHITESPACE_CELL_CHAR,h+=x>>22||1}return u}}i.BufferLine=y},4841:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.getRangeLength=void 0,i.getRangeLength=function(n,c){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 c*(n.end.y-n.start.y)+(n.end.x-n.start.x+1)}},4634:(v,i)=>{function n(c,f,l){if(f===c.length-1)return c[f].getTrimmedLength();const g=!c[f].hasContent(l-1)&&c[f].getWidth(l-1)===1,b=c[f+1].getWidth(0)===2;return g&&b?l-1:l}Object.defineProperty(i,"__esModule",{value:!0}),i.getWrappedLineTrimmedLength=i.reflowSmallerGetNewLineLengths=i.reflowLargerApplyNewLayout=i.reflowLargerCreateNewLayout=i.reflowLargerGetLinesToRemove=void 0,i.reflowLargerGetLinesToRemove=function(c,f,l,g,b){const y=[];for(let _=0;_<c.length-1;_++){let o=_,h=c.get(++o);if(!h.isWrapped)continue;const d=[c.get(_)];for(;o<c.length&&h.isWrapped;)d.push(h),h=c.get(++o);if(g>=_&&g<o){_+=d.length-1;continue}let u=0,x=n(d,u,f),S=1,k=0;for(;S<d.length;){const w=n(d,S,f),j=w-k,R=l-x,L=Math.min(j,R);d[u].copyCellsFrom(d[S],k,x,L,!1),x+=L,x===l&&(u++,x=0),k+=L,k===w&&(S++,k=0),x===0&&u!==0&&d[u-1].getWidth(l-1)===2&&(d[u].copyCellsFrom(d[u-1],l-1,x++,1,!1),d[u-1].setCell(l-1,b))}d[u].replaceCells(x,l,b);let E=0;for(let w=d.length-1;w>0&&(w>u||d[w].getTrimmedLength()===0);w--)E++;E>0&&(y.push(_+d.length-E),y.push(E)),_+=d.length-1}return y},i.reflowLargerCreateNewLayout=function(c,f){const l=[];let g=0,b=f[g],y=0;for(let _=0;_<c.length;_++)if(b===_){const o=f[++g];c.onDeleteEmitter.fire({index:_-y,amount:o}),_+=o-1,y+=o,b=f[++g]}else l.push(_);return{layout:l,countRemoved:y}},i.reflowLargerApplyNewLayout=function(c,f){const l=[];for(let g=0;g<f.length;g++)l.push(c.get(f[g]));for(let g=0;g<l.length;g++)c.set(g,l[g]);c.length=f.length},i.reflowSmallerGetNewLineLengths=function(c,f,l){const g=[],b=c.map(((h,d)=>n(c,d,f))).reduce(((h,d)=>h+d));let y=0,_=0,o=0;for(;o<b;){if(b-o<l){g.push(b-o);break}y+=l;const h=n(c,_,f);y>h&&(y-=h,_++);const d=c[_].getWidth(y-1)===2;d&&y--;const u=d?l-1:l;g.push(u),o+=u}return g},i.getWrappedLineTrimmedLength=n},5295:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferSet=void 0;const c=n(8460),f=n(844),l=n(9092);class g extends f.Disposable{constructor(y,_){super(),this._optionsService=y,this._bufferService=_,this._onBufferActivate=this.register(new c.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 l.Buffer(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new l.Buffer(!1,this._optionsService,this._bufferService),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}),this.setupTabStops()}get alt(){return this._alt}get active(){return this._activeBuffer}get normal(){return this._normal}activateNormalBuffer(){this._activeBuffer!==this._normal&&(this._normal.x=this._alt.x,this._normal.y=this._alt.y,this._alt.clearAllMarkers(),this._alt.clear(),this._activeBuffer=this._normal,this._onBufferActivate.fire({activeBuffer:this._normal,inactiveBuffer:this._alt}))}activateAltBuffer(y){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(y),this._alt.x=this._normal.x,this._alt.y=this._normal.y,this._activeBuffer=this._alt,this._onBufferActivate.fire({activeBuffer:this._alt,inactiveBuffer:this._normal}))}resize(y,_){this._normal.resize(y,_),this._alt.resize(y,_),this.setupTabStops(y)}setupTabStops(y){this._normal.setupTabStops(y),this._alt.setupTabStops(y)}}i.BufferSet=g},511:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.CellData=void 0;const c=n(482),f=n(643),l=n(3734);class g extends l.AttributeData{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new l.ExtendedAttrs,this.combinedData=""}static fromCharData(y){const _=new g;return _.setFromCharData(y),_}isCombined(){return 2097152&this.content}getWidth(){return this.content>>22}getChars(){return 2097152&this.content?this.combinedData:2097151&this.content?(0,c.stringFromCodePoint)(2097151&this.content):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):2097151&this.content}setFromCharData(y){this.fg=y[f.CHAR_DATA_ATTR_INDEX],this.bg=0;let _=!1;if(y[f.CHAR_DATA_CHAR_INDEX].length>2)_=!0;else if(y[f.CHAR_DATA_CHAR_INDEX].length===2){const o=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0);if(55296<=o&&o<=56319){const h=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(1);56320<=h&&h<=57343?this.content=1024*(o-55296)+h-56320+65536|y[f.CHAR_DATA_WIDTH_INDEX]<<22:_=!0}else _=!0}else this.content=y[f.CHAR_DATA_CHAR_INDEX].charCodeAt(0)|y[f.CHAR_DATA_WIDTH_INDEX]<<22;_&&(this.combinedData=y[f.CHAR_DATA_CHAR_INDEX],this.content=2097152|y[f.CHAR_DATA_WIDTH_INDEX]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}}i.CellData=g},643:(v,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:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Marker=void 0;const c=n(8460),f=n(844);class l{get id(){return this._id}constructor(b){this.line=b,this.isDisposed=!1,this._disposables=[],this._id=l._nextId++,this._onDispose=this.register(new c.EventEmitter),this.onDispose=this._onDispose.event}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),(0,f.disposeArray)(this._disposables),this._disposables.length=0)}register(b){return this._disposables.push(b),b}}i.Marker=l,l._nextId=1},7116:(v,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:(v,i)=>{var n,c,f;Object.defineProperty(i,"__esModule",{value:!0}),i.C1_ESCAPED=i.C1=i.C0=void 0,(function(l){l.NUL="\0",l.SOH="",l.STX="",l.ETX="",l.EOT="",l.ENQ="",l.ACK="",l.BEL="\x07",l.BS="\b",l.HT=" ",l.LF=`
25
+ `,l.VT="\v",l.FF="\f",l.CR="\r",l.SO="",l.SI="",l.DLE="",l.DC1="",l.DC2="",l.DC3="",l.DC4="",l.NAK="",l.SYN="",l.ETB="",l.CAN="",l.EM="",l.SUB="",l.ESC="\x1B",l.FS="",l.GS="",l.RS="",l.US="",l.SP=" ",l.DEL=""})(n||(i.C0=n={})),(function(l){l.PAD="€",l.HOP="",l.BPH="‚",l.NBH="ƒ",l.IND="„",l.NEL="…",l.SSA="†",l.ESA="‡",l.HTS="ˆ",l.HTJ="‰",l.VTS="Š",l.PLD="‹",l.PLU="Œ",l.RI="",l.SS2="Ž",l.SS3="",l.DCS="",l.PU1="‘",l.PU2="’",l.STS="“",l.CCH="”",l.MW="•",l.SPA="–",l.EPA="—",l.SOS="˜",l.SGCI="™",l.SCI="š",l.CSI="›",l.ST="œ",l.OSC="",l.PM="ž",l.APC="Ÿ"})(c||(i.C1=c={})),(function(l){l.ST=`${n.ESC}\\`})(f||(i.C1_ESCAPED=f={}))},7399:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.evaluateKeyboardEvent=void 0;const c=n(2584),f={48:["0",")"],49:["1","!"],50:["2","@"],51:["3","#"],52:["4","$"],53:["5","%"],54:["6","^"],55:["7","&"],56:["8","*"],57:["9","("],186:[";",":"],187:["=","+"],188:[",","<"],189:["-","_"],190:[".",">"],191:["/","?"],192:["`","~"],219:["[","{"],220:["\\","|"],221:["]","}"],222:["'",'"']};i.evaluateKeyboardEvent=function(l,g,b,y){const _={type:0,cancel:!1,key:void 0},o=(l.shiftKey?1:0)|(l.altKey?2:0)|(l.ctrlKey?4:0)|(l.metaKey?8:0);switch(l.keyCode){case 0:l.key==="UIKeyInputUpArrow"?_.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A":l.key==="UIKeyInputLeftArrow"?_.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D":l.key==="UIKeyInputRightArrow"?_.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C":l.key==="UIKeyInputDownArrow"&&(_.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B");break;case 8:if(l.altKey){_.key=c.C0.ESC+c.C0.DEL;break}_.key=c.C0.DEL;break;case 9:if(l.shiftKey){_.key=c.C0.ESC+"[Z";break}_.key=c.C0.HT,_.cancel=!0;break;case 13:_.key=l.altKey?c.C0.ESC+c.C0.CR:c.C0.CR,_.cancel=!0;break;case 27:_.key=c.C0.ESC,l.altKey&&(_.key=c.C0.ESC+c.C0.ESC),_.cancel=!0;break;case 37:if(l.metaKey)break;o?(_.key=c.C0.ESC+"[1;"+(o+1)+"D",_.key===c.C0.ESC+"[1;3D"&&(_.key=c.C0.ESC+(b?"b":"[1;5D"))):_.key=g?c.C0.ESC+"OD":c.C0.ESC+"[D";break;case 39:if(l.metaKey)break;o?(_.key=c.C0.ESC+"[1;"+(o+1)+"C",_.key===c.C0.ESC+"[1;3C"&&(_.key=c.C0.ESC+(b?"f":"[1;5C"))):_.key=g?c.C0.ESC+"OC":c.C0.ESC+"[C";break;case 38:if(l.metaKey)break;o?(_.key=c.C0.ESC+"[1;"+(o+1)+"A",b||_.key!==c.C0.ESC+"[1;3A"||(_.key=c.C0.ESC+"[1;5A")):_.key=g?c.C0.ESC+"OA":c.C0.ESC+"[A";break;case 40:if(l.metaKey)break;o?(_.key=c.C0.ESC+"[1;"+(o+1)+"B",b||_.key!==c.C0.ESC+"[1;3B"||(_.key=c.C0.ESC+"[1;5B")):_.key=g?c.C0.ESC+"OB":c.C0.ESC+"[B";break;case 45:l.shiftKey||l.ctrlKey||(_.key=c.C0.ESC+"[2~");break;case 46:_.key=o?c.C0.ESC+"[3;"+(o+1)+"~":c.C0.ESC+"[3~";break;case 36:_.key=o?c.C0.ESC+"[1;"+(o+1)+"H":g?c.C0.ESC+"OH":c.C0.ESC+"[H";break;case 35:_.key=o?c.C0.ESC+"[1;"+(o+1)+"F":g?c.C0.ESC+"OF":c.C0.ESC+"[F";break;case 33:l.shiftKey?_.type=2:l.ctrlKey?_.key=c.C0.ESC+"[5;"+(o+1)+"~":_.key=c.C0.ESC+"[5~";break;case 34:l.shiftKey?_.type=3:l.ctrlKey?_.key=c.C0.ESC+"[6;"+(o+1)+"~":_.key=c.C0.ESC+"[6~";break;case 112:_.key=o?c.C0.ESC+"[1;"+(o+1)+"P":c.C0.ESC+"OP";break;case 113:_.key=o?c.C0.ESC+"[1;"+(o+1)+"Q":c.C0.ESC+"OQ";break;case 114:_.key=o?c.C0.ESC+"[1;"+(o+1)+"R":c.C0.ESC+"OR";break;case 115:_.key=o?c.C0.ESC+"[1;"+(o+1)+"S":c.C0.ESC+"OS";break;case 116:_.key=o?c.C0.ESC+"[15;"+(o+1)+"~":c.C0.ESC+"[15~";break;case 117:_.key=o?c.C0.ESC+"[17;"+(o+1)+"~":c.C0.ESC+"[17~";break;case 118:_.key=o?c.C0.ESC+"[18;"+(o+1)+"~":c.C0.ESC+"[18~";break;case 119:_.key=o?c.C0.ESC+"[19;"+(o+1)+"~":c.C0.ESC+"[19~";break;case 120:_.key=o?c.C0.ESC+"[20;"+(o+1)+"~":c.C0.ESC+"[20~";break;case 121:_.key=o?c.C0.ESC+"[21;"+(o+1)+"~":c.C0.ESC+"[21~";break;case 122:_.key=o?c.C0.ESC+"[23;"+(o+1)+"~":c.C0.ESC+"[23~";break;case 123:_.key=o?c.C0.ESC+"[24;"+(o+1)+"~":c.C0.ESC+"[24~";break;default:if(!l.ctrlKey||l.shiftKey||l.altKey||l.metaKey)if(b&&!y||!l.altKey||l.metaKey)!b||l.altKey||l.ctrlKey||l.shiftKey||!l.metaKey?l.key&&!l.ctrlKey&&!l.altKey&&!l.metaKey&&l.keyCode>=48&&l.key.length===1?_.key=l.key:l.key&&l.ctrlKey&&(l.key==="_"&&(_.key=c.C0.US),l.key==="@"&&(_.key=c.C0.NUL)):l.keyCode===65&&(_.type=1);else{const h=f[l.keyCode],d=h?.[l.shiftKey?1:0];if(d)_.key=c.C0.ESC+d;else if(l.keyCode>=65&&l.keyCode<=90){const u=l.ctrlKey?l.keyCode-64:l.keyCode+32;let x=String.fromCharCode(u);l.shiftKey&&(x=x.toUpperCase()),_.key=c.C0.ESC+x}else if(l.keyCode===32)_.key=c.C0.ESC+(l.ctrlKey?c.C0.NUL:" ");else if(l.key==="Dead"&&l.code.startsWith("Key")){let u=l.code.slice(3,4);l.shiftKey||(u=u.toLowerCase()),_.key=c.C0.ESC+u,_.cancel=!0}}else l.keyCode>=65&&l.keyCode<=90?_.key=String.fromCharCode(l.keyCode-64):l.keyCode===32?_.key=c.C0.NUL:l.keyCode>=51&&l.keyCode<=55?_.key=String.fromCharCode(l.keyCode-51+27):l.keyCode===56?_.key=c.C0.DEL:l.keyCode===219?_.key=c.C0.ESC:l.keyCode===220?_.key=c.C0.FS:l.keyCode===221&&(_.key=c.C0.GS)}return _}},482:(v,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,c=0,f=n.length){let l="";for(let g=c;g<f;++g){let b=n[g];b>65535?(b-=65536,l+=String.fromCharCode(55296+(b>>10))+String.fromCharCode(b%1024+56320)):l+=String.fromCharCode(b)}return l},i.StringToUtf32=class{constructor(){this._interim=0}clear(){this._interim=0}decode(n,c){const f=n.length;if(!f)return 0;let l=0,g=0;if(this._interim){const b=n.charCodeAt(g++);56320<=b&&b<=57343?c[l++]=1024*(this._interim-55296)+b-56320+65536:(c[l++]=this._interim,c[l++]=b),this._interim=0}for(let b=g;b<f;++b){const y=n.charCodeAt(b);if(55296<=y&&y<=56319){if(++b>=f)return this._interim=y,l;const _=n.charCodeAt(b);56320<=_&&_<=57343?c[l++]=1024*(y-55296)+_-56320+65536:(c[l++]=y,c[l++]=_)}else y!==65279&&(c[l++]=y)}return l}},i.Utf8ToUtf32=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(n,c){const f=n.length;if(!f)return 0;let l,g,b,y,_=0,o=0,h=0;if(this.interim[0]){let x=!1,S=this.interim[0];S&=(224&S)==192?31:(240&S)==224?15:7;let k,E=0;for(;(k=63&this.interim[++E])&&E<4;)S<<=6,S|=k;const w=(224&this.interim[0])==192?2:(240&this.interim[0])==224?3:4,j=w-E;for(;h<j;){if(h>=f)return 0;if(k=n[h++],(192&k)!=128){h--,x=!0;break}this.interim[E++]=k,S<<=6,S|=63&k}x||(w===2?S<128?h--:c[_++]=S:w===3?S<2048||S>=55296&&S<=57343||S===65279||(c[_++]=S):S<65536||S>1114111||(c[_++]=S)),this.interim.fill(0)}const d=f-4;let u=h;for(;u<f;){for(;!(!(u<d)||128&(l=n[u])||128&(g=n[u+1])||128&(b=n[u+2])||128&(y=n[u+3]));)c[_++]=l,c[_++]=g,c[_++]=b,c[_++]=y,u+=4;if(l=n[u++],l<128)c[_++]=l;else if((224&l)==192){if(u>=f)return this.interim[0]=l,_;if(g=n[u++],(192&g)!=128){u--;continue}if(o=(31&l)<<6|63&g,o<128){u--;continue}c[_++]=o}else if((240&l)==224){if(u>=f)return this.interim[0]=l,_;if(g=n[u++],(192&g)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,_;if(b=n[u++],(192&b)!=128){u--;continue}if(o=(15&l)<<12|(63&g)<<6|63&b,o<2048||o>=55296&&o<=57343||o===65279)continue;c[_++]=o}else if((248&l)==240){if(u>=f)return this.interim[0]=l,_;if(g=n[u++],(192&g)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,_;if(b=n[u++],(192&b)!=128){u--;continue}if(u>=f)return this.interim[0]=l,this.interim[1]=g,this.interim[2]=b,_;if(y=n[u++],(192&y)!=128){u--;continue}if(o=(7&l)<<18|(63&g)<<12|(63&b)<<6|63&y,o<65536||o>1114111)continue;c[_++]=o}}return _}}},225:(v,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]],c=[[68097,68099],[68101,68102],[68108,68111],[68152,68154],[68159,68159],[119143,119145],[119155,119170],[119173,119179],[119210,119213],[119362,119364],[917505,917505],[917536,917631],[917760,917999]];let f;i.UnicodeV6=class{constructor(){if(this.version="6",!f){f=new Uint8Array(65536),f.fill(1),f[0]=0,f.fill(0,1,32),f.fill(0,127,160),f.fill(2,4352,4448),f[9001]=2,f[9002]=2,f.fill(2,11904,42192),f[12351]=1,f.fill(2,44032,55204),f.fill(2,63744,64256),f.fill(2,65040,65050),f.fill(2,65072,65136),f.fill(2,65280,65377),f.fill(2,65504,65511);for(let l=0;l<n.length;++l)f.fill(0,n[l][0],n[l][1]+1)}}wcwidth(l){return l<32?0:l<127?1:l<65536?f[l]:(function(g,b){let y,_=0,o=b.length-1;if(g<b[0][0]||g>b[o][1])return!1;for(;o>=_;)if(y=_+o>>1,g>b[y][1])_=y+1;else{if(!(g<b[y][0]))return!0;o=y-1}return!1})(l,c)?0:l>=131072&&l<=196605||l>=196608&&l<=262141?2:1}}},5981:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.WriteBuffer=void 0;const c=n(8460),f=n(844);class l extends f.Disposable{constructor(b){super(),this._action=b,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this.register(new c.EventEmitter),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(b,y){if(y!==void 0&&this._syncCalls>y)return void(this._syncCalls=0);if(this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;let _;for(this._isSyncWriting=!0;_=this._writeBuffer.shift();){this._action(_);const o=this._callbacks.shift();o&&o()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(b,y){if(this._pendingData>5e7)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput)return this._didUserInput=!1,this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(y),void this._innerWrite();setTimeout((()=>this._innerWrite()))}this._pendingData+=b.length,this._writeBuffer.push(b),this._callbacks.push(y)}_innerWrite(b=0,y=!0){const _=b||Date.now();for(;this._writeBuffer.length>this._bufferOffset;){const o=this._writeBuffer[this._bufferOffset],h=this._action(o,y);if(h){const u=x=>Date.now()-_>=12?setTimeout((()=>this._innerWrite(0,x))):this._innerWrite(_,x);return void h.catch((x=>(queueMicrotask((()=>{throw x})),Promise.resolve(!1)))).then(u)}const d=this._callbacks[this._bufferOffset];if(d&&d(),this._bufferOffset++,this._pendingData-=o.length,Date.now()-_>=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=l},5941:(v,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})$/,c=/^[\da-f]+$/;function f(l,g){const b=l.toString(16),y=b.length<2?"0"+b:b;switch(g){case 4:return b[0];case 8:return y;case 12:return(y+y).slice(0,3);default:return y+y}}i.parseColor=function(l){if(!l)return;let g=l.toLowerCase();if(g.indexOf("rgb:")===0){g=g.slice(4);const b=n.exec(g);if(b){const y=b[1]?15:b[4]?255:b[7]?4095:65535;return[Math.round(parseInt(b[1]||b[4]||b[7]||b[10],16)/y*255),Math.round(parseInt(b[2]||b[5]||b[8]||b[11],16)/y*255),Math.round(parseInt(b[3]||b[6]||b[9]||b[12],16)/y*255)]}}else if(g.indexOf("#")===0&&(g=g.slice(1),c.exec(g)&&[3,6,9,12].includes(g.length))){const b=g.length/3,y=[0,0,0];for(let _=0;_<3;++_){const o=parseInt(g.slice(b*_,b*_+b),16);y[_]=b===1?o<<4:b===2?o:b===3?o>>4:o>>8}return y}},i.toRgbString=function(l,g=16){const[b,y,_]=l;return`rgb:${f(b,g)}/${f(y,g)}/${f(_,g)}`}},5770:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.PAYLOAD_LIMIT=void 0,i.PAYLOAD_LIMIT=1e7},6351:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DcsHandler=i.DcsParser=void 0;const c=n(482),f=n(8742),l=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(y,_){this._handlers[y]===void 0&&(this._handlers[y]=[]);const o=this._handlers[y];return o.push(_),{dispose:()=>{const h=o.indexOf(_);h!==-1&&o.splice(h,1)}}}clearHandler(y){this._handlers[y]&&delete this._handlers[y]}setHandlerFallback(y){this._handlerFb=y}reset(){if(this._active.length)for(let y=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;y>=0;--y)this._active[y].unhook(!1);this._stack.paused=!1,this._active=g,this._ident=0}hook(y,_){if(this.reset(),this._ident=y,this._active=this._handlers[y]||g,this._active.length)for(let o=this._active.length-1;o>=0;o--)this._active[o].hook(_);else this._handlerFb(this._ident,"HOOK",_)}put(y,_,o){if(this._active.length)for(let h=this._active.length-1;h>=0;h--)this._active[h].put(y,_,o);else this._handlerFb(this._ident,"PUT",(0,c.utf32ToString)(y,_,o))}unhook(y,_=!0){if(this._active.length){let o=!1,h=this._active.length-1,d=!1;if(this._stack.paused&&(h=this._stack.loopPosition-1,o=_,d=this._stack.fallThrough,this._stack.paused=!1),!d&&o===!1){for(;h>=0&&(o=this._active[h].unhook(y),o!==!0);h--)if(o instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!1,o;h--}for(;h>=0;h--)if(o=this._active[h].unhook(!1),o instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=h,this._stack.fallThrough=!0,o}else this._handlerFb(this._ident,"UNHOOK",y);this._active=g,this._ident=0}};const b=new f.Params;b.addParam(0),i.DcsHandler=class{constructor(y){this._handler=y,this._data="",this._params=b,this._hitLimit=!1}hook(y){this._params=y.length>1||y.params[0]?y.clone():b,this._data="",this._hitLimit=!1}put(y,_,o){this._hitLimit||(this._data+=(0,c.utf32ToString)(y,_,o),this._data.length>l.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}unhook(y){let _=!1;if(this._hitLimit)_=!1;else if(y&&(_=this._handler(this._data,this._params),_ instanceof Promise))return _.then((o=>(this._params=b,this._data="",this._hitLimit=!1,o)));return this._params=b,this._data="",this._hitLimit=!1,_}}},2015:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.EscapeSequenceParser=i.VT500_TRANSITION_TABLE=i.TransitionTable=void 0;const c=n(844),f=n(8742),l=n(6242),g=n(6351);class b{constructor(h){this.table=new Uint8Array(h)}setDefault(h,d){this.table.fill(h<<4|d)}add(h,d,u,x){this.table[d<<8|h]=u<<4|x}addMany(h,d,u,x){for(let S=0;S<h.length;S++)this.table[d<<8|h[S]]=u<<4|x}}i.TransitionTable=b;const y=160;i.VT500_TRANSITION_TABLE=(function(){const o=new b(4095),h=Array.apply(null,Array(256)).map(((E,w)=>w)),d=(E,w)=>h.slice(E,w),u=d(32,127),x=d(0,24);x.push(25),x.push.apply(x,d(28,32));const S=d(0,14);let k;for(k in o.setDefault(1,0),o.addMany(u,0,2,0),S)o.addMany([24,26,153,154],k,3,0),o.addMany(d(128,144),k,3,0),o.addMany(d(144,152),k,3,0),o.add(156,k,0,0),o.add(27,k,11,1),o.add(157,k,4,8),o.addMany([152,158,159],k,0,7),o.add(155,k,11,3),o.add(144,k,11,9);return o.addMany(x,0,3,0),o.addMany(x,1,3,1),o.add(127,1,0,1),o.addMany(x,8,0,8),o.addMany(x,3,3,3),o.add(127,3,0,3),o.addMany(x,4,3,4),o.add(127,4,0,4),o.addMany(x,6,3,6),o.addMany(x,5,3,5),o.add(127,5,0,5),o.addMany(x,2,3,2),o.add(127,2,0,2),o.add(93,1,4,8),o.addMany(u,8,5,8),o.add(127,8,5,8),o.addMany([156,27,24,26,7],8,6,0),o.addMany(d(28,32),8,0,8),o.addMany([88,94,95],1,0,7),o.addMany(u,7,0,7),o.addMany(x,7,0,7),o.add(156,7,0,0),o.add(127,7,0,7),o.add(91,1,11,3),o.addMany(d(64,127),3,7,0),o.addMany(d(48,60),3,8,4),o.addMany([60,61,62,63],3,9,4),o.addMany(d(48,60),4,8,4),o.addMany(d(64,127),4,7,0),o.addMany([60,61,62,63],4,0,6),o.addMany(d(32,64),6,0,6),o.add(127,6,0,6),o.addMany(d(64,127),6,0,0),o.addMany(d(32,48),3,9,5),o.addMany(d(32,48),5,9,5),o.addMany(d(48,64),5,0,6),o.addMany(d(64,127),5,7,0),o.addMany(d(32,48),4,9,5),o.addMany(d(32,48),1,9,2),o.addMany(d(32,48),2,9,2),o.addMany(d(48,127),2,10,0),o.addMany(d(48,80),1,10,0),o.addMany(d(81,88),1,10,0),o.addMany([89,90,92],1,10,0),o.addMany(d(96,127),1,10,0),o.add(80,1,11,9),o.addMany(x,9,0,9),o.add(127,9,0,9),o.addMany(d(28,32),9,0,9),o.addMany(d(32,48),9,9,12),o.addMany(d(48,60),9,8,10),o.addMany([60,61,62,63],9,9,10),o.addMany(x,11,0,11),o.addMany(d(32,128),11,0,11),o.addMany(d(28,32),11,0,11),o.addMany(x,10,0,10),o.add(127,10,0,10),o.addMany(d(28,32),10,0,10),o.addMany(d(48,60),10,8,10),o.addMany([60,61,62,63],10,0,11),o.addMany(d(32,48),10,9,12),o.addMany(x,12,0,12),o.add(127,12,0,12),o.addMany(d(28,32),12,0,12),o.addMany(d(32,48),12,9,12),o.addMany(d(48,64),12,0,11),o.addMany(d(64,127),12,12,13),o.addMany(d(64,127),10,12,13),o.addMany(d(64,127),9,12,13),o.addMany(x,13,13,13),o.addMany(u,13,13,13),o.add(127,13,0,13),o.addMany([27,156,24,26],13,14,0),o.add(y,0,2,0),o.add(y,8,5,8),o.add(y,6,0,6),o.add(y,11,0,11),o.add(y,13,13,13),o})();class _ extends c.Disposable{constructor(h=i.VT500_TRANSITION_TABLE){super(),this._transitions=h,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new f.Params,this._params.addParam(0),this._collect=0,this.precedingCodepoint=0,this._printHandlerFb=(d,u,x)=>{},this._executeHandlerFb=d=>{},this._csiHandlerFb=(d,u)=>{},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,c.toDisposable)((()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)}))),this._oscParser=this.register(new l.OscParser),this._dcsParser=this.register(new g.DcsParser),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},(()=>!0))}_identifier(h,d=[64,126]){let u=0;if(h.prefix){if(h.prefix.length>1)throw new Error("only one byte as prefix supported");if(u=h.prefix.charCodeAt(0),u&&60>u||u>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(h.intermediates){if(h.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let S=0;S<h.intermediates.length;++S){const k=h.intermediates.charCodeAt(S);if(32>k||k>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");u<<=8,u|=k}}if(h.final.length!==1)throw new Error("final must be a single byte");const x=h.final.charCodeAt(0);if(d[0]>x||x>d[1])throw new Error(`final must be in range ${d[0]} .. ${d[1]}`);return u<<=8,u|=x,u}identToString(h){const d=[];for(;h;)d.push(String.fromCharCode(255&h)),h>>=8;return d.reverse().join("")}setPrintHandler(h){this._printHandler=h}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(h,d){const u=this._identifier(h,[48,126]);this._escHandlers[u]===void 0&&(this._escHandlers[u]=[]);const x=this._escHandlers[u];return x.push(d),{dispose:()=>{const S=x.indexOf(d);S!==-1&&x.splice(S,1)}}}clearEscHandler(h){this._escHandlers[this._identifier(h,[48,126])]&&delete this._escHandlers[this._identifier(h,[48,126])]}setEscHandlerFallback(h){this._escHandlerFb=h}setExecuteHandler(h,d){this._executeHandlers[h.charCodeAt(0)]=d}clearExecuteHandler(h){this._executeHandlers[h.charCodeAt(0)]&&delete this._executeHandlers[h.charCodeAt(0)]}setExecuteHandlerFallback(h){this._executeHandlerFb=h}registerCsiHandler(h,d){const u=this._identifier(h);this._csiHandlers[u]===void 0&&(this._csiHandlers[u]=[]);const x=this._csiHandlers[u];return x.push(d),{dispose:()=>{const S=x.indexOf(d);S!==-1&&x.splice(S,1)}}}clearCsiHandler(h){this._csiHandlers[this._identifier(h)]&&delete this._csiHandlers[this._identifier(h)]}setCsiHandlerFallback(h){this._csiHandlerFb=h}registerDcsHandler(h,d){return this._dcsParser.registerHandler(this._identifier(h),d)}clearDcsHandler(h){this._dcsParser.clearHandler(this._identifier(h))}setDcsHandlerFallback(h){this._dcsParser.setHandlerFallback(h)}registerOscHandler(h,d){return this._oscParser.registerHandler(h,d)}clearOscHandler(h){this._oscParser.clearHandler(h)}setOscHandlerFallback(h){this._oscParser.setHandlerFallback(h)}setErrorHandler(h){this._errorHandler=h}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(h,d,u,x,S){this._parseStack.state=h,this._parseStack.handlers=d,this._parseStack.handlerPos=u,this._parseStack.transition=x,this._parseStack.chunkPos=S}parse(h,d,u){let x,S=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(u===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");const w=this._parseStack.handlers;let j=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(u===!1&&j>-1){for(;j>=0&&(x=w[j](this._params),x!==!0);j--)if(x instanceof Promise)return this._parseStack.handlerPos=j,x}this._parseStack.handlers=[];break;case 4:if(u===!1&&j>-1){for(;j>=0&&(x=w[j](),x!==!0);j--)if(x instanceof Promise)return this._parseStack.handlerPos=j,x}this._parseStack.handlers=[];break;case 6:if(S=h[this._parseStack.chunkPos],x=this._dcsParser.unhook(S!==24&&S!==26,u),x)return x;S===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(S=h[this._parseStack.chunkPos],x=this._oscParser.end(S!==24&&S!==26,u),x)return x;S===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 w=E;w<d;++w){switch(S=h[w],k=this._transitions.table[this.currentState<<8|(S<160?S:y)],k>>4){case 2:for(let N=w+1;;++N){if(N>=d||(S=h[N])<32||S>126&&S<y){this._printHandler(h,w,N),w=N-1;break}if(++N>=d||(S=h[N])<32||S>126&&S<y){this._printHandler(h,w,N),w=N-1;break}if(++N>=d||(S=h[N])<32||S>126&&S<y){this._printHandler(h,w,N),w=N-1;break}if(++N>=d||(S=h[N])<32||S>126&&S<y){this._printHandler(h,w,N),w=N-1;break}}break;case 3:this._executeHandlers[S]?this._executeHandlers[S]():this._executeHandlerFb(S),this.precedingCodepoint=0;break;case 0:break;case 1:if(this._errorHandler({position:w,code:S,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:const j=this._csiHandlers[this._collect<<8|S];let R=j?j.length-1:-1;for(;R>=0&&(x=j[R](this._params),x!==!0);R--)if(x instanceof Promise)return this._preserveStack(3,j,R,k,w),x;R<0&&this._csiHandlerFb(this._collect<<8|S,this._params),this.precedingCodepoint=0;break;case 8:do switch(S){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(S-48)}while(++w<d&&(S=h[w])>47&&S<60);w--;break;case 9:this._collect<<=8,this._collect|=S;break;case 10:const L=this._escHandlers[this._collect<<8|S];let D=L?L.length-1:-1;for(;D>=0&&(x=L[D](),x!==!0);D--)if(x instanceof Promise)return this._preserveStack(4,L,D,k,w),x;D<0&&this._escHandlerFb(this._collect<<8|S),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|S,this._params);break;case 13:for(let N=w+1;;++N)if(N>=d||(S=h[N])===24||S===26||S===27||S>127&&S<y){this._dcsParser.put(h,w,N),w=N-1;break}break;case 14:if(x=this._dcsParser.unhook(S!==24&&S!==26),x)return this._preserveStack(6,[],0,k,w),x;S===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 N=w+1;;N++)if(N>=d||(S=h[N])<32||S>127&&S<y){this._oscParser.put(h,w,N),w=N-1;break}break;case 6:if(x=this._oscParser.end(S!==24&&S!==26),x)return this._preserveStack(5,[],0,k,w),x;S===27&&(k|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingCodepoint=0}this.currentState=15&k}}}i.EscapeSequenceParser=_},6242:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OscHandler=i.OscParser=void 0;const c=n(5770),f=n(482),l=[];i.OscParser=class{constructor(){this._state=0,this._active=l,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(g,b){this._handlers[g]===void 0&&(this._handlers[g]=[]);const y=this._handlers[g];return y.push(b),{dispose:()=>{const _=y.indexOf(b);_!==-1&&y.splice(_,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=l}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=l,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||l,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,b,y){if(this._active.length)for(let _=this._active.length-1;_>=0;_--)this._active[_].put(g,b,y);else this._handlerFb(this._id,"PUT",(0,f.utf32ToString)(g,b,y))}start(){this.reset(),this._state=1}put(g,b,y){if(this._state!==3){if(this._state===1)for(;b<y;){const _=g[b++];if(_===59){this._state=2,this._start();break}if(_<48||57<_)return void(this._state=3);this._id===-1&&(this._id=0),this._id=10*this._id+_-48}this._state===2&&y-b>0&&this._put(g,b,y)}}end(g,b=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),this._active.length){let y=!1,_=this._active.length-1,o=!1;if(this._stack.paused&&(_=this._stack.loopPosition-1,y=b,o=this._stack.fallThrough,this._stack.paused=!1),!o&&y===!1){for(;_>=0&&(y=this._active[_].end(g),y!==!0);_--)if(y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!1,y;_--}for(;_>=0;_--)if(y=this._active[_].end(!1),y instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=_,this._stack.fallThrough=!0,y}else this._handlerFb(this._id,"END",g);this._active=l,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,b,y){this._hitLimit||(this._data+=(0,f.utf32ToString)(g,b,y),this._data.length>c.PAYLOAD_LIMIT&&(this._data="",this._hitLimit=!0))}end(g){let b=!1;if(this._hitLimit)b=!1;else if(g&&(b=this._handler(this._data),b instanceof Promise))return b.then((y=>(this._data="",this._hitLimit=!1,y)));return this._data="",this._hitLimit=!1,b}}},8742:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.Params=void 0;const n=2147483647;class c{static fromArray(l){const g=new c;if(!l.length)return g;for(let b=Array.isArray(l[0])?1:0;b<l.length;++b){const y=l[b];if(Array.isArray(y))for(let _=0;_<y.length;++_)g.addSubParam(y[_]);else g.addParam(y)}return g}constructor(l=32,g=32){if(this.maxLength=l,this.maxSubParamsLength=g,g>256)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(l),this.length=0,this._subParams=new Int32Array(g),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(l),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}clone(){const l=new c(this.maxLength,this.maxSubParamsLength);return l.params.set(this.params),l.length=this.length,l._subParams.set(this._subParams),l._subParamsLength=this._subParamsLength,l._subParamsIdx.set(this._subParamsIdx),l._rejectDigits=this._rejectDigits,l._rejectSubDigits=this._rejectSubDigits,l._digitIsSub=this._digitIsSub,l}toArray(){const l=[];for(let g=0;g<this.length;++g){l.push(this.params[g]);const b=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-b>0&&l.push(Array.prototype.slice.call(this._subParams,b,y))}return l}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(l){if(this._digitIsSub=!1,this.length>=this.maxLength)this._rejectDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=l>n?n:l}}addSubParam(l){if(this._digitIsSub=!0,this.length)if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength)this._rejectSubDigits=!0;else{if(l<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=l>n?n:l,this._subParamsIdx[this.length-1]++}}hasSubParams(l){return(255&this._subParamsIdx[l])-(this._subParamsIdx[l]>>8)>0}getSubParams(l){const g=this._subParamsIdx[l]>>8,b=255&this._subParamsIdx[l];return b-g>0?this._subParams.subarray(g,b):null}getSubParamsAll(){const l={};for(let g=0;g<this.length;++g){const b=this._subParamsIdx[g]>>8,y=255&this._subParamsIdx[g];y-b>0&&(l[g]=this._subParams.slice(b,y))}return l}addDigit(l){let g;if(this._rejectDigits||!(g=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;const b=this._digitIsSub?this._subParams:this.params,y=b[g-1];b[g-1]=~y?Math.min(10*y+l,n):l}}i.Params=c},5741:(v,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,c){const f={instance:c,dispose:c.dispose,isDisposed:!1};this._addons.push(f),c.dispose=()=>this._wrappedAddonDispose(f),c.activate(n)}_wrappedAddonDispose(n){if(n.isDisposed)return;let c=-1;for(let f=0;f<this._addons.length;f++)if(this._addons[f]===n){c=f;break}if(c===-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(c,1)}}},8771:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferApiView=void 0;const c=n(3785),f=n(511);i.BufferApiView=class{constructor(l,g){this._buffer=l,this.type=g}init(l){return this._buffer=l,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(l){const g=this._buffer.lines.get(l);if(g)return new c.BufferLineApiView(g)}getNullCell(){return new f.CellData}}},3785:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferLineApiView=void 0;const c=n(511);i.BufferLineApiView=class{constructor(f){this._line=f}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(f,l){if(!(f<0||f>=this._line.length))return l?(this._line.loadCell(f,l),l):this._line.loadCell(f,new c.CellData)}translateToString(f,l,g){return this._line.translateToString(f,l,g)}}},8285:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.BufferNamespaceApi=void 0;const c=n(8771),f=n(8460),l=n(844);class g extends l.Disposable{constructor(y){super(),this._core=y,this._onBufferChange=this.register(new f.EventEmitter),this.onBufferChange=this._onBufferChange.event,this._normal=new c.BufferApiView(this._core.buffers.normal,"normal"),this._alternate=new c.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:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.ParserApi=void 0,i.ParserApi=class{constructor(n){this._core=n}registerCsiHandler(n,c){return this._core.registerCsiHandler(n,(f=>c(f.toArray())))}addCsiHandler(n,c){return this.registerCsiHandler(n,c)}registerDcsHandler(n,c){return this._core.registerDcsHandler(n,((f,l)=>c(f,l.toArray())))}addDcsHandler(n,c){return this.registerDcsHandler(n,c)}registerEscHandler(n,c){return this._core.registerEscHandler(n,c)}addEscHandler(n,c){return this.registerEscHandler(n,c)}registerOscHandler(n,c){return this._core.registerOscHandler(n,c)}addOscHandler(n,c){return this.registerOscHandler(n,c)}}},7090:(v,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(v,i,n){var c=this&&this.__decorate||function(o,h,d,u){var x,S=arguments.length,k=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(o,h,d,u);else for(var E=o.length-1;E>=0;E--)(x=o[E])&&(k=(S<3?x(k):S>3?x(h,d,k):x(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(o,h){return function(d,u){h(d,u,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.BufferService=i.MINIMUM_ROWS=i.MINIMUM_COLS=void 0;const l=n(8460),g=n(844),b=n(5295),y=n(2585);i.MINIMUM_COLS=2,i.MINIMUM_ROWS=1;let _=i.BufferService=class extends g.Disposable{get buffer(){return this.buffers.active}constructor(o){super(),this.isUserScrolling=!1,this._onResize=this.register(new l.EventEmitter),this.onResize=this._onResize.event,this._onScroll=this.register(new l.EventEmitter),this.onScroll=this._onScroll.event,this.cols=Math.max(o.rawOptions.cols||0,i.MINIMUM_COLS),this.rows=Math.max(o.rawOptions.rows||0,i.MINIMUM_ROWS),this.buffers=this.register(new b.BufferSet(o,this))}resize(o,h){this.cols=o,this.rows=h,this.buffers.resize(o,h),this._onResize.fire({cols:o,rows:h})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(o,h=!1){const d=this.buffer;let u;u=this._cachedBlankLine,u&&u.length===this.cols&&u.getFg(0)===o.fg&&u.getBg(0)===o.bg||(u=d.getBlankLine(o,h),this._cachedBlankLine=u),u.isWrapped=h;const x=d.ybase+d.scrollTop,S=d.ybase+d.scrollBottom;if(d.scrollTop===0){const k=d.lines.isFull;S===d.lines.length-1?k?d.lines.recycle().copyFrom(u):d.lines.push(u.clone()):d.lines.splice(S+1,0,u.clone()),k?this.isUserScrolling&&(d.ydisp=Math.max(d.ydisp-1,0)):(d.ybase++,this.isUserScrolling||d.ydisp++)}else{const k=S-x+1;d.lines.shiftElements(x+1,k-1,-1),d.lines.set(S,u.clone())}this.isUserScrolling||(d.ydisp=d.ybase),this._onScroll.fire(d.ydisp)}scrollLines(o,h,d){const u=this.buffer;if(o<0){if(u.ydisp===0)return;this.isUserScrolling=!0}else o+u.ydisp>=u.ybase&&(this.isUserScrolling=!1);const x=u.ydisp;u.ydisp=Math.max(Math.min(u.ydisp+o,u.ybase),0),x!==u.ydisp&&(h||this._onScroll.fire(u.ydisp))}};i.BufferService=_=c([f(0,y.IOptionsService)],_)},7994:(v,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,c){this._charsets[n]=c,this.glevel===n&&(this.charset=c)}}},1753:function(v,i,n){var c=this&&this.__decorate||function(u,x,S,k){var E,w=arguments.length,j=w<3?x:k===null?k=Object.getOwnPropertyDescriptor(x,S):k;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")j=Reflect.decorate(u,x,S,k);else for(var R=u.length-1;R>=0;R--)(E=u[R])&&(j=(w<3?E(j):w>3?E(x,S,j):E(x,S))||j);return w>3&&j&&Object.defineProperty(x,S,j),j},f=this&&this.__param||function(u,x){return function(S,k){x(S,k,u)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreMouseService=void 0;const l=n(2585),g=n(8460),b=n(844),y={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:u=>u.button!==4&&u.action===1&&(u.ctrl=!1,u.alt=!1,u.shift=!1,!0)},VT200:{events:19,restrict:u=>u.action!==32},DRAG:{events:23,restrict:u=>u.action!==32||u.button!==3},ANY:{events:31,restrict:u=>!0}};function _(u,x){let S=(u.ctrl?16:0)|(u.shift?4:0)|(u.alt?8:0);return u.button===4?(S|=64,S|=u.action):(S|=3&u.button,4&u.button&&(S|=64),8&u.button&&(S|=128),u.action===32?S|=32:u.action!==0||x||(S|=3)),S}const o=String.fromCharCode,h={DEFAULT:u=>{const x=[_(u,!1)+32,u.col+32,u.row+32];return x[0]>255||x[1]>255||x[2]>255?"":`\x1B[M${o(x[0])}${o(x[1])}${o(x[2])}`},SGR:u=>{const x=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${_(u,!0)};${u.col};${u.row}${x}`},SGR_PIXELS:u=>{const x=u.action===0&&u.button!==4?"m":"M";return`\x1B[<${_(u,!0)};${u.x};${u.y}${x}`}};let d=i.CoreMouseService=class extends b.Disposable{constructor(u,x){super(),this._bufferService=u,this._coreService=x,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 S of Object.keys(y))this.addProtocol(S,y[S]);for(const S of Object.keys(h))this.addEncoding(S,h[S]);this.reset()}addProtocol(u,x){this._protocols[u]=x}addEncoding(u,x){this._encodings[u]=x}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(u){if(!this._protocols[u])throw new Error(`unknown protocol "${u}"`);this._activeProtocol=u,this._onProtocolChange.fire(this._protocols[u].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(u){if(!this._encodings[u])throw new Error(`unknown encoding "${u}"`);this._activeEncoding=u}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null}triggerMouseEvent(u){if(u.col<0||u.col>=this._bufferService.cols||u.row<0||u.row>=this._bufferService.rows||u.button===4&&u.action===32||u.button===3&&u.action!==32||u.button!==4&&(u.action===2||u.action===3)||(u.col++,u.row++,u.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,u,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(u))return!1;const x=this._encodings[this._activeEncoding](u);return x&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(x):this._coreService.triggerDataEvent(x,!0)),this._lastEvent=u,!0}explainEvents(u){return{down:!!(1&u),up:!!(2&u),drag:!!(4&u),move:!!(8&u),wheel:!!(16&u)}}_equalEvents(u,x,S){if(S){if(u.x!==x.x||u.y!==x.y)return!1}else if(u.col!==x.col||u.row!==x.row)return!1;return u.button===x.button&&u.action===x.action&&u.ctrl===x.ctrl&&u.alt===x.alt&&u.shift===x.shift}};i.CoreMouseService=d=c([f(0,l.IBufferService),f(1,l.ICoreService)],d)},6975:function(v,i,n){var c=this&&this.__decorate||function(d,u,x,S){var k,E=arguments.length,w=E<3?u:S===null?S=Object.getOwnPropertyDescriptor(u,x):S;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")w=Reflect.decorate(d,u,x,S);else for(var j=d.length-1;j>=0;j--)(k=d[j])&&(w=(E<3?k(w):E>3?k(u,x,w):k(u,x))||w);return E>3&&w&&Object.defineProperty(u,x,w),w},f=this&&this.__param||function(d,u){return function(x,S){u(x,S,d)}};Object.defineProperty(i,"__esModule",{value:!0}),i.CoreService=void 0;const l=n(1439),g=n(8460),b=n(844),y=n(2585),_=Object.freeze({insertMode:!1}),o=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,origin:!1,reverseWraparound:!1,sendFocus:!1,wraparound:!0});let h=i.CoreService=class extends b.Disposable{constructor(d,u,x){super(),this._bufferService=d,this._logService=u,this._optionsService=x,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,l.clone)(_),this.decPrivateModes=(0,l.clone)(o)}reset(){this.modes=(0,l.clone)(_),this.decPrivateModes=(0,l.clone)(o)}triggerDataEvent(d,u=!1){if(this._optionsService.rawOptions.disableStdin)return;const x=this._bufferService.buffer;u&&this._optionsService.rawOptions.scrollOnUserInput&&x.ybase!==x.ydisp&&this._onRequestScrollToBottom.fire(),u&&this._onUserInput.fire(),this._logService.debug(`sending data "${d}"`,(()=>d.split("").map((S=>S.charCodeAt(0))))),this._onData.fire(d)}triggerBinaryEvent(d){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${d}"`,(()=>d.split("").map((u=>u.charCodeAt(0))))),this._onBinary.fire(d))}};i.CoreService=h=c([f(0,y.IBufferService),f(1,y.ILogService),f(2,y.IOptionsService)],h)},9074:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.DecorationService=void 0;const c=n(8055),f=n(8460),l=n(844),g=n(6106);let b=0,y=0;class _ extends l.Disposable{get decorations(){return this._decorations.values()}constructor(){super(),this._decorations=new g.SortedList((d=>d?.marker.line)),this._onDecorationRegistered=this.register(new f.EventEmitter),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this.register(new f.EventEmitter),this.onDecorationRemoved=this._onDecorationRemoved.event,this.register((0,l.toDisposable)((()=>this.reset())))}registerDecoration(d){if(d.marker.isDisposed)return;const u=new o(d);if(u){const x=u.marker.onDispose((()=>u.dispose()));u.onDispose((()=>{u&&(this._decorations.delete(u)&&this._onDecorationRemoved.fire(u),x.dispose())})),this._decorations.insert(u),this._onDecorationRegistered.fire(u)}return u}reset(){for(const d of this._decorations.values())d.dispose();this._decorations.clear()}*getDecorationsAtCell(d,u,x){var S,k,E;let w=0,j=0;for(const R of this._decorations.getKeyIterator(u))w=(S=R.options.x)!==null&&S!==void 0?S:0,j=w+((k=R.options.width)!==null&&k!==void 0?k:1),d>=w&&d<j&&(!x||((E=R.options.layer)!==null&&E!==void 0?E:"bottom")===x)&&(yield R)}forEachDecorationAtCell(d,u,x,S){this._decorations.forEachByKey(u,(k=>{var E,w,j;b=(E=k.options.x)!==null&&E!==void 0?E:0,y=b+((w=k.options.width)!==null&&w!==void 0?w:1),d>=b&&d<y&&(!x||((j=k.options.layer)!==null&&j!==void 0?j:"bottom")===x)&&S(k)}))}}i.DecorationService=_;class o extends l.Disposable{get isDisposed(){return this._isDisposed}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=c.css.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=c.css.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}constructor(d){super(),this.options=d,this.onRenderEmitter=this.register(new f.EventEmitter),this.onRender=this.onRenderEmitter.event,this._onDispose=this.register(new f.EventEmitter),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=d.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}dispose(){this._onDispose.fire(),super.dispose()}}},4348:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.InstantiationService=i.ServiceCollection=void 0;const c=n(2585),f=n(8343);class l{constructor(...b){this._entries=new Map;for(const[y,_]of b)this.set(y,_)}set(b,y){const _=this._entries.get(b);return this._entries.set(b,y),_}forEach(b){for(const[y,_]of this._entries.entries())b(y,_)}has(b){return this._entries.has(b)}get(b){return this._entries.get(b)}}i.ServiceCollection=l,i.InstantiationService=class{constructor(){this._services=new l,this._services.set(c.IInstantiationService,this)}setService(g,b){this._services.set(g,b)}getService(g){return this._services.get(g)}createInstance(g,...b){const y=(0,f.getServiceDependencies)(g).sort(((h,d)=>h.index-d.index)),_=[];for(const h of y){const d=this._services.get(h.id);if(!d)throw new Error(`[createInstance] ${g.name} depends on UNKNOWN service ${h.id}.`);_.push(d)}const o=y.length>0?y[0].index:b.length;if(b.length!==o)throw new Error(`[createInstance] First service dependency of ${g.name} at position ${o+1} conflicts with ${b.length} static arguments`);return new g(...b,..._)}}},7866:function(v,i,n){var c=this&&this.__decorate||function(o,h,d,u){var x,S=arguments.length,k=S<3?h:u===null?u=Object.getOwnPropertyDescriptor(h,d):u;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")k=Reflect.decorate(o,h,d,u);else for(var E=o.length-1;E>=0;E--)(x=o[E])&&(k=(S<3?x(k):S>3?x(h,d,k):x(h,d))||k);return S>3&&k&&Object.defineProperty(h,d,k),k},f=this&&this.__param||function(o,h){return function(d,u){h(d,u,o)}};Object.defineProperty(i,"__esModule",{value:!0}),i.traceCall=i.setTraceLogger=i.LogService=void 0;const l=n(844),g=n(2585),b={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 y,_=i.LogService=class extends l.Disposable{get logLevel(){return this._logLevel}constructor(o){super(),this._optionsService=o,this._logLevel=g.LogLevelEnum.OFF,this._updateLogLevel(),this.register(this._optionsService.onSpecificOptionChange("logLevel",(()=>this._updateLogLevel()))),y=this}_updateLogLevel(){this._logLevel=b[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(o){for(let h=0;h<o.length;h++)typeof o[h]=="function"&&(o[h]=o[h]())}_log(o,h,d){this._evalLazyOptionalParams(d),o.call(console,(this._optionsService.options.logger?"":"xterm.js: ")+h,...d)}trace(o,...h){var d,u;this._logLevel<=g.LogLevelEnum.TRACE&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.trace.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,o,h)}debug(o,...h){var d,u;this._logLevel<=g.LogLevelEnum.DEBUG&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.debug.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.log,o,h)}info(o,...h){var d,u;this._logLevel<=g.LogLevelEnum.INFO&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.info.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.info,o,h)}warn(o,...h){var d,u;this._logLevel<=g.LogLevelEnum.WARN&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.warn.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.warn,o,h)}error(o,...h){var d,u;this._logLevel<=g.LogLevelEnum.ERROR&&this._log((u=(d=this._optionsService.options.logger)===null||d===void 0?void 0:d.error.bind(this._optionsService.options.logger))!==null&&u!==void 0?u:console.error,o,h)}};i.LogService=_=c([f(0,g.IOptionsService)],_),i.setTraceLogger=function(o){y=o},i.traceCall=function(o,h,d){if(typeof d.value!="function")throw new Error("not supported");const u=d.value;d.value=function(...x){if(y.logLevel!==g.LogLevelEnum.TRACE)return u.apply(this,x);y.trace(`GlyphRenderer#${u.name}(${x.map((k=>JSON.stringify(k))).join(", ")})`);const S=u.apply(this,x);return y.trace(`GlyphRenderer#${u.name} return`,S),S}}},7302:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.OptionsService=i.DEFAULT_OPTIONS=void 0;const c=n(8460),f=n(844),l=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:l.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 b extends f.Disposable{constructor(_){super(),this._onOptionChange=this.register(new c.EventEmitter),this.onOptionChange=this._onOptionChange.event;const o=Object.assign({},i.DEFAULT_OPTIONS);for(const h in _)if(h in o)try{const d=_[h];o[h]=this._sanitizeAndValidateOption(h,d)}catch(d){console.error(d)}this.rawOptions=o,this.options=Object.assign({},o),this._setupOptions()}onSpecificOptionChange(_,o){return this.onOptionChange((h=>{h===_&&o(this.rawOptions[_])}))}onMultipleOptionChange(_,o){return this.onOptionChange((h=>{_.indexOf(h)!==-1&&o()}))}_setupOptions(){const _=h=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);return this.rawOptions[h]},o=(h,d)=>{if(!(h in i.DEFAULT_OPTIONS))throw new Error(`No option with key "${h}"`);d=this._sanitizeAndValidateOption(h,d),this.rawOptions[h]!==d&&(this.rawOptions[h]=d,this._onOptionChange.fire(h))};for(const h in this.rawOptions){const d={get:_.bind(this,h),set:o.bind(this,h)};Object.defineProperty(this.options,h,d)}}_sanitizeAndValidateOption(_,o){switch(_){case"cursorStyle":if(o||(o=i.DEFAULT_OPTIONS[_]),!(function(h){return h==="block"||h==="underline"||h==="bar"})(o))throw new Error(`"${o}" is not a valid value for ${_}`);break;case"wordSeparator":o||(o=i.DEFAULT_OPTIONS[_]);break;case"fontWeight":case"fontWeightBold":if(typeof o=="number"&&1<=o&&o<=1e3)break;o=g.includes(o)?o:i.DEFAULT_OPTIONS[_];break;case"cursorWidth":o=Math.floor(o);case"lineHeight":case"tabStopWidth":if(o<1)throw new Error(`${_} cannot be less than 1, value: ${o}`);break;case"minimumContrastRatio":o=Math.max(1,Math.min(21,Math.round(10*o)/10));break;case"scrollback":if((o=Math.min(o,4294967295))<0)throw new Error(`${_} cannot be less than 0, value: ${o}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(o<=0)throw new Error(`${_} cannot be less than or equal to 0, value: ${o}`);break;case"rows":case"cols":if(!o&&o!==0)throw new Error(`${_} must be numeric, value: ${o}`);break;case"windowsPty":o=o??{}}return o}}i.OptionsService=b},2660:function(v,i,n){var c=this&&this.__decorate||function(b,y,_,o){var h,d=arguments.length,u=d<3?y:o===null?o=Object.getOwnPropertyDescriptor(y,_):o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")u=Reflect.decorate(b,y,_,o);else for(var x=b.length-1;x>=0;x--)(h=b[x])&&(u=(d<3?h(u):d>3?h(y,_,u):h(y,_))||u);return d>3&&u&&Object.defineProperty(y,_,u),u},f=this&&this.__param||function(b,y){return function(_,o){y(_,o,b)}};Object.defineProperty(i,"__esModule",{value:!0}),i.OscLinkService=void 0;const l=n(2585);let g=i.OscLinkService=class{constructor(b){this._bufferService=b,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(b){const y=this._bufferService.buffer;if(b.id===void 0){const x=y.addMarker(y.ybase+y.y),S={data:b,id:this._nextId++,lines:[x]};return x.onDispose((()=>this._removeMarkerFromLink(S,x))),this._dataByLinkId.set(S.id,S),S.id}const _=b,o=this._getEntryIdKey(_),h=this._entriesWithId.get(o);if(h)return this.addLineToLink(h.id,y.ybase+y.y),h.id;const d=y.addMarker(y.ybase+y.y),u={id:this._nextId++,key:this._getEntryIdKey(_),data:_,lines:[d]};return d.onDispose((()=>this._removeMarkerFromLink(u,d))),this._entriesWithId.set(u.key,u),this._dataByLinkId.set(u.id,u),u.id}addLineToLink(b,y){const _=this._dataByLinkId.get(b);if(_&&_.lines.every((o=>o.line!==y))){const o=this._bufferService.buffer.addMarker(y);_.lines.push(o),o.onDispose((()=>this._removeMarkerFromLink(_,o)))}}getLinkData(b){var y;return(y=this._dataByLinkId.get(b))===null||y===void 0?void 0:y.data}_getEntryIdKey(b){return`${b.id};;${b.uri}`}_removeMarkerFromLink(b,y){const _=b.lines.indexOf(y);_!==-1&&(b.lines.splice(_,1),b.lines.length===0&&(b.data.id!==void 0&&this._entriesWithId.delete(b.key),this._dataByLinkId.delete(b.id)))}};i.OscLinkService=g=c([f(0,l.IBufferService)],g)},8343:(v,i)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.createDecorator=i.getServiceDependencies=i.serviceRegistry=void 0;const n="di$target",c="di$dependencies";i.serviceRegistry=new Map,i.getServiceDependencies=function(f){return f[c]||[]},i.createDecorator=function(f){if(i.serviceRegistry.has(f))return i.serviceRegistry.get(f);const l=function(g,b,y){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");(function(_,o,h){o[n]===o?o[c].push({id:_,index:h}):(o[c]=[{id:_,index:h}],o[n]=o)})(l,g,y)};return l.toString=()=>f,i.serviceRegistry.set(f,l),l}},2585:(v,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 c=n(8343);var f;i.IBufferService=(0,c.createDecorator)("BufferService"),i.ICoreMouseService=(0,c.createDecorator)("CoreMouseService"),i.ICoreService=(0,c.createDecorator)("CoreService"),i.ICharsetService=(0,c.createDecorator)("CharsetService"),i.IInstantiationService=(0,c.createDecorator)("InstantiationService"),(function(l){l[l.TRACE=0]="TRACE",l[l.DEBUG=1]="DEBUG",l[l.INFO=2]="INFO",l[l.WARN=3]="WARN",l[l.ERROR=4]="ERROR",l[l.OFF=5]="OFF"})(f||(i.LogLevelEnum=f={})),i.ILogService=(0,c.createDecorator)("LogService"),i.IOptionsService=(0,c.createDecorator)("OptionsService"),i.IOscLinkService=(0,c.createDecorator)("OscLinkService"),i.IUnicodeService=(0,c.createDecorator)("UnicodeService"),i.IDecorationService=(0,c.createDecorator)("DecorationService")},1480:(v,i,n)=>{Object.defineProperty(i,"__esModule",{value:!0}),i.UnicodeService=void 0;const c=n(8460),f=n(225);i.UnicodeService=class{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new c.EventEmitter,this.onChange=this._onChange.event;const l=new f.UnicodeV6;this.register(l),this._active=l.version,this._activeProvider=l}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(l){if(!this._providers[l])throw new Error(`unknown Unicode version "${l}"`);this._active=l,this._activeProvider=this._providers[l],this._onChange.fire(l)}register(l){this._providers[l.version]=l}wcwidth(l){return this._activeProvider.wcwidth(l)}getStringCellWidth(l){let g=0;const b=l.length;for(let y=0;y<b;++y){let _=l.charCodeAt(y);if(55296<=_&&_<=56319){if(++y>=b)return g+this.wcwidth(_);const o=l.charCodeAt(y);56320<=o&&o<=57343?_=1024*(_-55296)+o-56320+65536:g+=this.wcwidth(o)}g+=this.wcwidth(_)}return g}}}},a={};function p(v){var i=a[v];if(i!==void 0)return i.exports;var n=a[v]={exports:{}};return r[v].call(n.exports,n,n.exports,p),n.exports}var m={};return(()=>{var v=m;Object.defineProperty(v,"__esModule",{value:!0}),v.Terminal=void 0;const i=p(9042),n=p(3236),c=p(844),f=p(5741),l=p(8285),g=p(7975),b=p(7090),y=["cols","rows"];class _ extends c.Disposable{constructor(h){super(),this._core=this.register(new n.Terminal(h)),this._addonManager=this.register(new f.AddonManager),this._publicOptions=Object.assign({},this._core.options);const d=x=>this._core.options[x],u=(x,S)=>{this._checkReadonlyOptions(x),this._core.options[x]=S};for(const x in this._core.options){const S={get:d.bind(this,x),set:u.bind(this,x)};Object.defineProperty(this._publicOptions,x,S)}}_checkReadonlyOptions(h){if(y.includes(h))throw new Error(`Option "${h}" 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 b.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 l.BufferNamespaceApi(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){const h=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:h.applicationCursorKeys,applicationKeypadMode:h.applicationKeypad,bracketedPasteMode:h.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:d,originMode:h.origin,reverseWraparoundMode:h.reverseWraparound,sendFocusMode:h.sendFocus,wraparoundMode:h.wraparound}}get options(){return this._publicOptions}set options(h){for(const d in h)this._publicOptions[d]=h[d]}blur(){this._core.blur()}focus(){this._core.focus()}resize(h,d){this._verifyIntegers(h,d),this._core.resize(h,d)}open(h){this._core.open(h)}attachCustomKeyEventHandler(h){this._core.attachCustomKeyEventHandler(h)}registerLinkProvider(h){return this._core.registerLinkProvider(h)}registerCharacterJoiner(h){return this._checkProposedApi(),this._core.registerCharacterJoiner(h)}deregisterCharacterJoiner(h){this._checkProposedApi(),this._core.deregisterCharacterJoiner(h)}registerMarker(h=0){return this._verifyIntegers(h),this._core.registerMarker(h)}registerDecoration(h){var d,u,x;return this._checkProposedApi(),this._verifyPositiveIntegers((d=h.x)!==null&&d!==void 0?d:0,(u=h.width)!==null&&u!==void 0?u:0,(x=h.height)!==null&&x!==void 0?x:0),this._core.registerDecoration(h)}hasSelection(){return this._core.hasSelection()}select(h,d,u){this._verifyIntegers(h,d,u),this._core.select(h,d,u)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(h,d){this._verifyIntegers(h,d),this._core.selectLines(h,d)}dispose(){super.dispose()}scrollLines(h){this._verifyIntegers(h),this._core.scrollLines(h)}scrollPages(h){this._verifyIntegers(h),this._core.scrollPages(h)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(h){this._verifyIntegers(h),this._core.scrollToLine(h)}clear(){this._core.clear()}write(h,d){this._core.write(h,d)}writeln(h,d){this._core.write(h),this._core.write(`\r
26
+ `,d)}paste(h){this._core.paste(h)}refresh(h,d){this._verifyIntegers(h,d),this._core.refresh(h,d)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(h){this._addonManager.loadAddon(this,h)}static get strings(){return i}_verifyIntegers(...h){for(const d of h)if(d===1/0||isNaN(d)||d%1!=0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...h){for(const d of h)if(d&&(d===1/0||isNaN(d)||d%1!=0||d<0))throw new Error("This API only accepts positive integers")}}v.Terminal=_})(),m})()))})($r)),$r.exports}var of=nf();var af=2,lf=1,cf=class{activate(e){this._terminal=e}dispose(){}fit(){let e=this.proposeDimensions();if(!e||!this._terminal||isNaN(e.cols)||isNaN(e.rows))return;let t=this._terminal._core;(this._terminal.rows!==e.rows||this._terminal.cols!==e.cols)&&(t._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 t=this._terminal.options.scrollback===0?0:this._terminal.options.overviewRuler?.width||14,r=window.getComputedStyle(this._terminal.element.parentElement),a=parseInt(r.getPropertyValue("height")),p=Math.max(0,parseInt(r.getPropertyValue("width"))),m=window.getComputedStyle(this._terminal.element),v={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=v.top+v.bottom,n=v.right+v.left,c=a-i,f=p-n-t;return{cols:Math.max(af,Math.floor(f/e.css.cell.width)),rows:Math.max(lf,Math.floor(c/e.css.cell.height))}}};function df(e={}){const{cwd:t,cols:r,rows:a,onOutput:p,onExit:m}=e,[v,i]=C.useState(null),[n,c]=C.useState(()=>Ot.isConnected()),[f,l]=C.useState(!1),[g,b]=C.useState(!1),[y,_]=C.useState(!1),o=C.useRef({onOutput:p,onExit:m});o.current={onOutput:p,onExit:m};const h=C.useRef(null);h.current=v,C.useEffect(()=>{if(!v)return;const k=Ot.getSocket(),E=()=>{c(!0),l(!1),i(null),_(!0)},w=()=>{c(!1),l(!1)},j=N=>{N.terminalId===v&&o.current.onOutput?.(N.data)},R=N=>{N.terminalId===v&&(l(!1),o.current.onExit?.(N.exitCode),i(null))},L=N=>{N.terminalId===v&&l(!0)},D=N=>{N.terminalId===v&&l(!1)};return k.on("connect",E),k.on("disconnect",w),k.on(ct.TERMINAL_STDOUT,j),k.on(ct.TERMINAL_EXIT,R),k.on(ct.TERMINAL_SUBSCRIBED,L),k.on(ct.TERMINAL_UNSUBSCRIBED,D),c(k.connected),k.connected&&k.emit(es.SUBSCRIBE,{topic:"terminal",id:v},N=>{N.success&&l(!0)}),()=>{k.off("connect",E),k.off("disconnect",w),k.off(ct.TERMINAL_STDOUT,j),k.off(ct.TERMINAL_EXIT,R),k.off(ct.TERMINAL_SUBSCRIBED,L),k.off(ct.TERMINAL_UNSUBSCRIBED,D),k.emit(es.UNSUBSCRIBE,{topic:"terminal",id:v})}},[v]);const d=C.useCallback(async()=>{const k=Ot.getSocket();if(!k.connected)return null;b(!0);try{const E=await me.post("/terminals",{socketId:k.id,cwd:t,cols:r,rows:a});return i(E.terminalId),_(!1),E.terminalId}catch(E){return console.error("[useStandaloneTerminal] Failed to create terminal:",E),null}finally{b(!1)}},[t,r,a]),u=C.useCallback(async()=>{const k=h.current;if(k){try{await me.delete(`/terminals/${k}`)}catch(E){console.error("[useStandaloneTerminal] Failed to destroy terminal:",E)}i(null),l(!1)}},[]),x=C.useCallback(k=>{const E=h.current;if(!E)return;Ot.getSocket().emit(es.TERMINAL_INPUT,{terminalId:E,data:k})},[]),S=C.useCallback((k,E)=>{const w=h.current;if(!w)return;Ot.getSocket().emit(es.TERMINAL_RESIZE,{terminalId:w,cols:k,rows:E})},[]);return C.useEffect(()=>()=>{const k=h.current;k&&me.delete(`/terminals/${k}`).catch(()=>{})},[]),{terminalId:v,isConnected:n,isAttached:f,isCreating:g,needsRecreate:y,create:d,destroy:u,sendInput:x,resize:S}}const uf={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"},hf=ie.memo(function({cwd:t,onExit:r,onReady:a}){const p=C.useRef(null),m=C.useRef(null),v=C.useRef(null),i=C.useRef(!1),{terminalId:n,isAttached:c,needsRecreate:f,create:l,sendInput:g,resize:b}=df({cwd:t,onOutput:C.useCallback(y=>{m.current?.write(y)},[]),onExit:C.useCallback(y=>{m.current?.writeln(`\r
27
+ \x1B[90m[Process exited with code ${y}]\x1B[0m`),r?.(y)},[r])});return C.useEffect(()=>{if(!f)return;const y=m.current;y&&y.writeln(`\r
28
+ \x1B[33m[Terminal disconnected — reconnecting...]\x1B[0m`),l()},[f,l]),C.useLayoutEffect(()=>{if(!p.current)return;const y=new of.Terminal({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, 'Courier New', monospace",lineHeight:1.4,theme:uf,scrollback:5e3,convertEol:!0}),_=new cf;y.loadAddon(_),y.open(p.current);const o=(h=0)=>{if(!(h>=5))try{const u=p.current;if(!u||u.clientWidth===0||u.clientHeight===0){setTimeout(()=>o(h+1),50);return}_.fit(),b(y.cols,y.rows)}catch{setTimeout(()=>o(h+1),50)}};return o(0),setTimeout(()=>o(1),100),m.current=y,v.current=_,()=>{y.dispose(),m.current=null,v.current=null}},[b]),C.useEffect(()=>{i.current||(i.current=!0,l())},[l]),C.useEffect(()=>{const y=m.current;if(!y||!c)return;const _=y.onData(o=>{g(o)});return()=>_.dispose()},[g,c]),C.useEffect(()=>{c&&a?.({sendInput:g})},[c,g,a]),C.useEffect(()=>{if(!p.current)return;const y=new ResizeObserver(()=>{requestAnimationFrame(()=>{try{const _=v.current,o=m.current,h=p.current;_&&o&&h&&h.clientWidth>0&&h.clientHeight>0&&(_.fit(),b(o.cols,o.rows))}catch{}})});return y.observe(p.current),()=>y.disconnect()},[b]),s.jsxs("div",{className:"relative flex h-full flex-col bg-[#1e1e1e]",children:[!n&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center text-neutral-500 text-xs z-10 bg-[#1e1e1e]",children:"Starting terminal..."}),s.jsx("div",{ref:p,className:"flex-1 overflow-hidden px-1 pt-1"})]})}),ff=ie.memo(function({commands:t,onSelect:r}){const{t:a}=ne(),[p,m]=C.useState(!1),v=C.useRef(null),i=C.useRef(null);return C.useEffect(()=>{if(!p)return;const n=c=>{v.current&&!v.current.contains(c.target)&&i.current&&!i.current.contains(c.target)&&m(!1)};return document.addEventListener("mousedown",n),()=>document.removeEventListener("mousedown",n)},[p]),t.length===0?null:s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"w-px h-4 bg-[#444] mx-1 shrink-0"}),s.jsxs("div",{className:"relative",children:[s.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:[s.jsx(sd,{size:12}),s.jsx("span",{children:a("快捷命令")}),s.jsx(_t,{size:10,className:`transition-transform ${p?"rotate-180":""}`})]}),p&&s.jsx("div",{ref:v,className:"absolute right-0 top-full mt-1 w-72 bg-[#2d2d2d] border border-[#444] rounded-lg shadow-xl z-[100] overflow-hidden",children:s.jsx("div",{className:"max-h-[240px] overflow-y-auto",children:t.map((n,c)=>s.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:[s.jsx(qt,{size:12,className:"text-green-500 mt-0.5 shrink-0 opacity-0 group-hover:opacity-100 transition-opacity"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"text-[12px] font-medium text-neutral-200",children:n.name}),s.jsx("div",{className:"text-[11px] font-mono text-neutral-500 truncate",children:n.command})]})]},c))})})]})]})});let Ur=0;function Pn(){return Ur+=1,{id:`shell-${Ur}`,order:Ur}}const mf=ie.memo(function({cwd:t,quickCommands:r=[]}){const{t:a}=ne(),[p,m]=C.useState(()=>[Pn()]),[v,i]=C.useState(()=>p[0].id),n=C.useRef(new Map),c=C.useCallback(()=>{const y=Pn();m(_=>[..._,y]),i(y.id)},[]),f=C.useCallback((y,_)=>{_.stopPropagation(),n.current.delete(y),m(o=>{const h=o.filter(d=>d.id!==y);return y===v&&h.length>0&&i(h[h.length-1].id),h})},[v]),l=C.useCallback(y=>{n.current.delete(y),m(_=>{const o=_.filter(h=>h.id!==y);return y===v&&o.length>0&&i(o[o.length-1].id),o})},[v]),g=C.useCallback((y,_)=>{n.current.set(y,_.sendInput)},[]),b=C.useCallback(y=>{const _=n.current.get(v);_&&_(y+"\r")},[v]);return s.jsxs("div",{className:"flex h-full flex-col bg-[#1e1e1e]",children:[s.jsxs("div",{className:"flex items-center bg-[#252526] border-b border-[#333] shrink-0 select-none",children:[s.jsx("div",{className:"flex items-center overflow-x-auto flex-1 min-w-0",children:p.map(y=>s.jsxs("button",{onClick:()=>i(y.id),className:se("flex items-center gap-1.5 px-3 py-1.5 text-[11px] border-r border-[#333] whitespace-nowrap group transition-colors",y.id===v?"bg-[#1e1e1e] text-neutral-200":"bg-[#2d2d2d] text-neutral-500 hover:text-neutral-300"),children:[s.jsx(er,{size:11,className:"shrink-0"}),s.jsx("span",{children:a("Shell {count}",{count:y.order})}),p.length>1&&s.jsx("span",{onClick:_=>f(y.id,_),className:"ml-1 p-0.5 rounded hover:bg-[#444] opacity-0 group-hover:opacity-100 transition-opacity cursor-pointer",children:s.jsx(Ht,{size:10})})]},y.id))}),s.jsx("button",{onClick:c,className:"flex items-center justify-center px-2 py-1.5 text-neutral-500 hover:text-neutral-300 hover:bg-[#333] transition-colors shrink-0",title:a("New Terminal"),children:s.jsx(as,{size:14})}),r.length>0&&s.jsx(ff,{commands:r,onSelect:b})]}),s.jsx("div",{className:"flex-1 overflow-hidden relative",children:p.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center h-full text-neutral-500",children:s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(er,{size:28}),s.jsx("span",{className:"text-xs",children:a("No terminals open")}),s.jsx("button",{onClick:c,className:"mt-1 px-3 py-1 text-xs bg-[#333] hover:bg-[#444] rounded transition-colors text-neutral-300",children:a("New Terminal")})]})}):p.map(y=>s.jsx("div",{className:"absolute inset-0",style:{display:y.id===v?"block":"none"},children:s.jsx(hf,{cwd:t,onExit:()=>l(y.id),onReady:_=>g(y.id,_)})},y.id))})]})});function On(e,t){(t==null||t>e.length)&&(t=e.length);for(var r=0,a=Array(t);r<t;r++)a[r]=e[r];return a}function pf(e){if(Array.isArray(e))return e}function gf(e,t,r){return(t=wf(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function vf(e,t){var r=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(r!=null){var a,p,m,v,i=[],n=!0,c=!1;try{if(m=(r=r.call(e)).next,t!==0)for(;!(n=(a=m.call(r)).done)&&(i.push(a.value),i.length!==t);n=!0);}catch(f){c=!0,p=f}finally{try{if(!n&&r.return!=null&&(v=r.return(),Object(v)!==v))return}finally{if(c)throw p}}return i}}function _f(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
29
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function In(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,a)}return r}function Bn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?In(Object(r),!0).forEach(function(a){gf(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):In(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function xf(e,t){if(e==null)return{};var r,a,p=bf(e,t);if(Object.getOwnPropertySymbols){var m=Object.getOwnPropertySymbols(e);for(a=0;a<m.length;a++)r=m[a],t.indexOf(r)===-1&&{}.propertyIsEnumerable.call(e,r)&&(p[r]=e[r])}return p}function bf(e,t){if(e==null)return{};var r={};for(var a in e)if({}.hasOwnProperty.call(e,a)){if(t.indexOf(a)!==-1)continue;r[a]=e[a]}return r}function yf(e,t){return pf(e)||vf(e,t)||Cf(e,t)||_f()}function Sf(e,t){if(typeof e!="object"||!e)return e;var r=e[Symbol.toPrimitive];if(r!==void 0){var a=r.call(e,t);if(typeof a!="object")return a;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function wf(e){var t=Sf(e,"string");return typeof t=="symbol"?t:t+""}function Cf(e,t){if(e){if(typeof e=="string")return On(e,t);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)?On(e,t):void 0}}function kf(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function Fn(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);t&&(a=a.filter(function(p){return Object.getOwnPropertyDescriptor(e,p).enumerable})),r.push.apply(r,a)}return r}function zn(e){for(var t=1;t<arguments.length;t++){var r=arguments[t]!=null?arguments[t]:{};t%2?Fn(Object(r),!0).forEach(function(a){kf(e,a,r[a])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):Fn(Object(r)).forEach(function(a){Object.defineProperty(e,a,Object.getOwnPropertyDescriptor(r,a))})}return e}function Ef(){for(var e=arguments.length,t=new Array(e),r=0;r<e;r++)t[r]=arguments[r];return function(a){return t.reduceRight(function(p,m){return m(p)},a)}}function vs(e){return function t(){for(var r=this,a=arguments.length,p=new Array(a),m=0;m<a;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,i=new Array(v),n=0;n<v;n++)i[n]=arguments[n];return t.apply(r,[].concat(p,i))}}}function lr(e){return{}.toString.call(e).includes("Object")}function jf(e){return!Object.keys(e).length}function Ts(e){return typeof e=="function"}function Nf(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Af(e,t){return lr(t)||Bt("changeType"),Object.keys(t).some(function(r){return!Nf(e,r)})&&Bt("changeField"),t}function Rf(e){Ts(e)||Bt("selectorType")}function Tf(e){Ts(e)||lr(e)||Bt("handlerType"),lr(e)&&Object.values(e).some(function(t){return!Ts(t)})&&Bt("handlersType")}function Mf(e){e||Bt("initialIsRequired"),lr(e)||Bt("initialType"),jf(e)&&Bt("initialContent")}function Df(e,t){throw new Error(e[t]||e.default)}var Lf={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"},Bt=vs(Df)(Lf),Us={changes:Af,selector:Rf,handler:Tf,initial:Mf};function Pf(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};Us.initial(e),Us.handler(t);var r={current:e},a=vs(Bf)(r,t),p=vs(If)(r),m=vs(Us.changes)(e),v=vs(Of)(r);function i(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(f){return f};return Us.selector(c),c(r.current)}function n(c){Ef(a,p,m,v)(c)}return[i,n]}function Of(e,t){return Ts(t)?t(e.current):t}function If(e,t){return e.current=zn(zn({},e.current),t),t}function Bf(e,t,r){return Ts(t)?t(e.current):Object.keys(r).forEach(function(a){var p;return(p=t[a])===null||p===void 0?void 0:p.call(t,e.current[a])}),r}var Ff={create:Pf},zf={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Hf(e){return function t(){for(var r=this,a=arguments.length,p=new Array(a),m=0;m<a;m++)p[m]=arguments[m];return p.length>=e.length?e.apply(this,p):function(){for(var v=arguments.length,i=new Array(v),n=0;n<v;n++)i[n]=arguments[n];return t.apply(r,[].concat(p,i))}}}function Wf(e){return{}.toString.call(e).includes("Object")}function $f(e){return e||Hn("configIsRequired"),Wf(e)||Hn("configType"),e.urls?(Uf(),{paths:{vs:e.urls.monacoBase}}):e}function Uf(){console.warn(ca.deprecation)}function qf(e,t){throw new Error(e[t]||e.default)}var ca={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!
30
+ You are using deprecated way of configuration.
31
+
32
+ Instead of using
33
+ monaco.config({ urls: { monacoBase: '...' } })
34
+ use
35
+ monaco.config({ paths: { vs: '...' } })
36
+
37
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
38
+ `},Hn=Hf(qf)(ca),Kf={config:$f},Xf=function(){for(var t=arguments.length,r=new Array(t),a=0;a<t;a++)r[a]=arguments[a];return function(p){return r.reduceRight(function(m,v){return v(m)},p)}};function da(e,t){return Object.keys(t).forEach(function(r){t[r]instanceof Object&&e[r]&&Object.assign(t[r],da(e[r],t[r]))}),Bn(Bn({},e),t)}var Vf={type:"cancelation",msg:"operation is manually canceled"};function qr(e){var t=!1,r=new Promise(function(a,p){e.then(function(m){return t?p(Vf):a(m)}),e.catch(p)});return r.cancel=function(){return t=!0},r}var Yf=["monaco"],Gf=Ff.create({config:zf,isInitialized:!1,resolve:null,reject:null,monaco:null}),ua=yf(Gf,2),Bs=ua[0],Cr=ua[1];function Qf(e){var t=Kf.config(e),r=t.monaco,a=xf(t,Yf);Cr(function(p){return{config:da(p.config,a),monaco:r}})}function Zf(){var e=Bs(function(t){var r=t.monaco,a=t.isInitialized,p=t.resolve;return{monaco:r,isInitialized:a,resolve:p}});if(!e.isInitialized){if(Cr({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),qr(Kr);if(window.monaco&&window.monaco.editor)return ha(window.monaco),e.resolve(window.monaco),qr(Kr);Xf(Jf,tm)(sm)}return qr(Kr)}function Jf(e){return document.body.appendChild(e)}function em(e){var t=document.createElement("script");return e&&(t.src=e),t}function tm(e){var t=Bs(function(a){var p=a.config,m=a.reject;return{config:p,reject:m}}),r=em("".concat(t.config.paths.vs,"/loader.js"));return r.onload=function(){return e()},r.onerror=t.reject,r}function sm(){var e=Bs(function(r){var a=r.config,p=r.resolve,m=r.reject;return{config:a,resolve:p,reject:m}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(r){var a=r.m||r;ha(a),e.resolve(a)},function(r){e.reject(r)})}function ha(e){Bs().monaco||Cr({monaco:e})}function rm(){return Bs(function(e){var t=e.monaco;return t})}var Kr=new Promise(function(e,t){return Cr({resolve:e,reject:t})}),fa={config:Qf,init:Zf,__getMonacoInstance:rm},im={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},Xr=im,nm={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},om=nm;function am({children:e}){return ie.createElement("div",{style:om.container},e)}var lm=am,cm=lm;function dm({width:e,height:t,isEditorReady:r,loading:a,_ref:p,className:m,wrapperProps:v}){return ie.createElement("section",{style:{...Xr.wrapper,width:e,height:t},...v},!r&&ie.createElement(cm,null,a),ie.createElement("div",{ref:p,style:{...Xr.fullWidth,...!r&&Xr.hide},className:m}))}var um=dm,ma=C.memo(um);function hm(e){C.useEffect(e,[])}var pa=hm;function fm(e,t,r=!0){let a=C.useRef(!0);C.useEffect(a.current||!r?()=>{a.current=!1}:e,t)}var bt=fm;function Ss(){}function ss(e,t,r,a){return mm(e,a)||pm(e,t,r,a)}function mm(e,t){return e.editor.getModel(ga(e,t))}function pm(e,t,r,a){return e.editor.createModel(t,r,a?ga(e,a):void 0)}function ga(e,t){return e.Uri.parse(t)}function gm({original:e,modified:t,language:r,originalLanguage:a,modifiedLanguage:p,originalModelPath:m,modifiedModelPath:v,keepCurrentOriginalModel:i=!1,keepCurrentModifiedModel:n=!1,theme:c="light",loading:f="Loading...",options:l={},height:g="100%",width:b="100%",className:y,wrapperProps:_={},beforeMount:o=Ss,onMount:h=Ss}){let[d,u]=C.useState(!1),[x,S]=C.useState(!0),k=C.useRef(null),E=C.useRef(null),w=C.useRef(null),j=C.useRef(h),R=C.useRef(o),L=C.useRef(!1);pa(()=>{let O=fa.init();return O.then(F=>(E.current=F)&&S(!1)).catch(F=>F?.type!=="cancelation"&&console.error("Monaco initialization: error:",F)),()=>k.current?M():O.cancel()}),bt(()=>{if(k.current&&E.current){let O=k.current.getOriginalEditor(),F=ss(E.current,e||"",a||r||"text",m||"");F!==O.getModel()&&O.setModel(F)}},[m],d),bt(()=>{if(k.current&&E.current){let O=k.current.getModifiedEditor(),F=ss(E.current,t||"",p||r||"text",v||"");F!==O.getModel()&&O.setModel(F)}},[v],d),bt(()=>{let O=k.current.getModifiedEditor();O.getOption(E.current.editor.EditorOption.readOnly)?O.setValue(t||""):t!==O.getValue()&&(O.executeEdits("",[{range:O.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),O.pushUndoStop())},[t],d),bt(()=>{k.current?.getModel()?.original.setValue(e||"")},[e],d),bt(()=>{let{original:O,modified:F}=k.current.getModel();E.current.editor.setModelLanguage(O,a||r||"text"),E.current.editor.setModelLanguage(F,p||r||"text")},[r,a,p],d),bt(()=>{E.current?.editor.setTheme(c)},[c],d),bt(()=>{k.current?.updateOptions(l)},[l],d);let D=C.useCallback(()=>{if(!E.current)return;R.current(E.current);let O=ss(E.current,e||"",a||r||"text",m||""),F=ss(E.current,t||"",p||r||"text",v||"");k.current?.setModel({original:O,modified:F})},[r,t,p,e,a,m,v]),N=C.useCallback(()=>{!L.current&&w.current&&(k.current=E.current.editor.createDiffEditor(w.current,{automaticLayout:!0,...l}),D(),E.current?.editor.setTheme(c),u(!0),L.current=!0)},[l,c,D]);C.useEffect(()=>{d&&j.current(k.current,E.current)},[d]),C.useEffect(()=>{!x&&!d&&N()},[x,d,N]);function M(){let O=k.current?.getModel();i||O?.original?.dispose(),n||O?.modified?.dispose(),k.current?.dispose()}return ie.createElement(ma,{width:b,height:g,isEditorReady:d,loading:f,_ref:w,className:y,wrapperProps:_})}var vm=gm;C.memo(vm);function _m(e){let t=C.useRef();return C.useEffect(()=>{t.current=e},[e]),t.current}var xm=_m,qs=new Map;function bm({defaultValue:e,defaultLanguage:t,defaultPath:r,value:a,language:p,path:m,theme:v="light",line:i,loading:n="Loading...",options:c={},overrideServices:f={},saveViewState:l=!0,keepCurrentModel:g=!1,width:b="100%",height:y="100%",className:_,wrapperProps:o={},beforeMount:h=Ss,onMount:d=Ss,onChange:u,onValidate:x=Ss}){let[S,k]=C.useState(!1),[E,w]=C.useState(!0),j=C.useRef(null),R=C.useRef(null),L=C.useRef(null),D=C.useRef(d),N=C.useRef(h),M=C.useRef(),O=C.useRef(a),F=xm(m),z=C.useRef(!1),A=C.useRef(!1);pa(()=>{let B=fa.init();return B.then($=>(j.current=$)&&w(!1)).catch($=>$?.type!=="cancelation"&&console.error("Monaco initialization: error:",$)),()=>R.current?I():B.cancel()}),bt(()=>{let B=ss(j.current,e||a||"",t||p||"",m||r||"");B!==R.current?.getModel()&&(l&&qs.set(F,R.current?.saveViewState()),R.current?.setModel(B),l&&R.current?.restoreViewState(qs.get(m)))},[m],S),bt(()=>{R.current?.updateOptions(c)},[c],S),bt(()=>{!R.current||a===void 0||(R.current.getOption(j.current.editor.EditorOption.readOnly)?R.current.setValue(a):a!==R.current.getValue()&&(A.current=!0,R.current.executeEdits("",[{range:R.current.getModel().getFullModelRange(),text:a,forceMoveMarkers:!0}]),R.current.pushUndoStop(),A.current=!1))},[a],S),bt(()=>{let B=R.current?.getModel();B&&p&&j.current?.editor.setModelLanguage(B,p)},[p],S),bt(()=>{i!==void 0&&R.current?.revealLine(i)},[i],S),bt(()=>{j.current?.editor.setTheme(v)},[v],S);let P=C.useCallback(()=>{if(!(!L.current||!j.current)&&!z.current){N.current(j.current);let B=m||r,$=ss(j.current,a||e||"",t||p||"",B||"");R.current=j.current?.editor.create(L.current,{model:$,automaticLayout:!0,...c},f),l&&R.current.restoreViewState(qs.get(B)),j.current.editor.setTheme(v),i!==void 0&&R.current.revealLine(i),k(!0),z.current=!0}},[e,t,r,a,p,m,c,f,l,v,i]);C.useEffect(()=>{S&&D.current(R.current,j.current)},[S]),C.useEffect(()=>{!E&&!S&&P()},[E,S,P]),O.current=a,C.useEffect(()=>{S&&u&&(M.current?.dispose(),M.current=R.current?.onDidChangeModelContent(B=>{A.current||u(R.current.getValue(),B)}))},[S,u]),C.useEffect(()=>{if(S){let B=j.current.editor.onDidChangeMarkers($=>{let X=R.current.getModel()?.uri;if(X&&$.find(Z=>Z.path===X.path)){let Z=j.current.editor.getModelMarkers({resource:X});x?.(Z)}});return()=>{B?.dispose()}}return()=>{}},[S,x]);function I(){M.current?.dispose(),g?l&&qs.set(m,R.current.saveViewState()):R.current.getModel()?.dispose(),R.current.dispose()}return ie.createElement(ma,{width:b,height:y,isEditorReady:S,loading:n,_ref:L,className:_,wrapperProps:o})}var ym=bm,Sm=C.memo(ym),wm=Sm,wt=function(e,t){return Number(e.toFixed(t))},Cm=function(e,t){return typeof e=="number"?e:t},Ye=function(e,t,r){r&&typeof r=="function"&&r(e,t)},km=function(e){return-Math.cos(e*Math.PI)/2+.5},Em=function(e){return e},jm=function(e){return e*e},Nm=function(e){return e*(2-e)},Am=function(e){return e<.5?2*e*e:-1+(4-2*e)*e},Rm=function(e){return e*e*e},Tm=function(e){return--e*e*e+1},Mm=function(e){return e<.5?4*e*e*e:(e-1)*(2*e-2)*(2*e-2)+1},Dm=function(e){return e*e*e*e},Lm=function(e){return 1- --e*e*e*e},Pm=function(e){return e<.5?8*e*e*e*e:1-8*--e*e*e*e},Om=function(e){return e*e*e*e*e},Im=function(e){return 1+--e*e*e*e*e},Bm=function(e){return e<.5?16*e*e*e*e*e:1+16*--e*e*e*e*e},va={easeOut:km,linear:Em,easeInQuad:jm,easeOutQuad:Nm,easeInOutQuad:Am,easeInCubic:Rm,easeOutCubic:Tm,easeInOutCubic:Mm,easeInQuart:Dm,easeOutQuart:Lm,easeInOutQuart:Pm,easeInQuint:Om,easeOutQuint:Im,easeInOutQuint:Bm},_a=function(e){typeof e=="number"&&cancelAnimationFrame(e)},Ct=function(e){e.mounted&&(_a(e.animation),e.animate=!1,e.animation=null,e.velocity=null)};function xa(e,t,r,a){if(e.mounted){var p=new Date().getTime(),m=1;Ct(e),e.animation=function(){if(!e.mounted)return _a(e.animation);var v=new Date().getTime()-p,i=v/r,n=va[t],c=n(i);v>=r?(a(m),e.animation=null):e.animation&&(a(c),requestAnimationFrame(e.animation))},requestAnimationFrame(e.animation)}}function Fm(e){var t=e.scale,r=e.positionX,a=e.positionY;return!(Number.isNaN(t)||Number.isNaN(r)||Number.isNaN(a))}function Wt(e,t,r,a){var p=Fm(t);if(!(!e.mounted||!p)){var m=e.setTransformState,v=e.transformState,i=v.scale,n=v.positionX,c=v.positionY,f=t.scale-i,l=t.positionX-n,g=t.positionY-c;r===0?m(t.scale,t.positionX,t.positionY):xa(e,a,r,function(b){var y=i+f*b,_=n+l*b,o=c+g*b;m(y,_,o)})}}function zm(e,t,r){var a=e.offsetWidth,p=e.offsetHeight,m=t.offsetWidth,v=t.offsetHeight,i=m*r,n=v*r,c=a-i,f=p-n;return{wrapperWidth:a,wrapperHeight:p,newContentWidth:i,newDiffWidth:c,newContentHeight:n,newDiffHeight:f}}var Hm=function(e,t,r,a,p,m,v){var i=e>t?r*(v?1:.5):0,n=a>p?m*(v?1:.5):0,c=e-t-i,f=i,l=a-p-n,g=n;return{minPositionX:c,maxPositionX:f,minPositionY:l,maxPositionY:g}},Fi=function(e,t){var r=e.wrapperComponent,a=e.contentComponent,p=e.setup.centerZoomedOut;if(!r||!a)throw new Error("Components are not mounted");var m=zm(r,a,t),v=m.wrapperWidth,i=m.wrapperHeight,n=m.newContentWidth,c=m.newDiffWidth,f=m.newContentHeight,l=m.newDiffHeight,g=Hm(v,n,c,i,f,l,!!p);return g},ni=function(e,t,r,a){return a?e<t?wt(t,2):e>r?wt(r,2):wt(e,2):wt(e,2)},Kt=function(e,t){var r=Fi(e,t);return e.bounds=r,r};function Fs(e,t,r,a,p,m,v){var i=r.minPositionX,n=r.minPositionY,c=r.maxPositionX,f=r.maxPositionY,l=0,g=0;v&&(l=p,g=m);var b=ni(e,i-l,c+l,a),y=ni(t,n-g,f+g,a);return{x:b,y}}function kr(e,t,r,a,p,m){var v=e.transformState,i=v.scale,n=v.positionX,c=v.positionY,f=a-i;if(typeof t!="number"||typeof r!="number")return console.error("Mouse X and Y position were not provided!"),{x:n,y:c};var l=n-t*f,g=c-r*f,b=Fs(l,g,p,m,0,0,null);return b}function zs(e,t,r,a,p){var m=p?a:0,v=t-m;return!Number.isNaN(r)&&e>=r?r:!Number.isNaN(t)&&e<=v?v:e}var Wn=function(e,t){var r=e.setup.panning.excluded,a=e.isInitialized,p=e.wrapperComponent,m=t.target,v="shadowRoot"in m&&"composedPath"in t,i=v?t.composedPath().some(function(f){return f instanceof Element?p?.contains(f):!1}):p?.contains(m),n=a&&m&&i;if(!n)return!1;var c=Er(m,r);return!c},$n=function(e){var t=e.isInitialized,r=e.isPanning,a=e.setup,p=a.panning.disabled,m=t&&r&&!p;return!!m},Wm=function(e,t){var r=e.transformState,a=r.positionX,p=r.positionY;e.isPanning=!0;var m=t.clientX,v=t.clientY;e.startCoords={x:m-a,y:v-p}},$m=function(e,t){var r=t.touches,a=e.transformState,p=a.positionX,m=a.positionY;e.isPanning=!0;var v=r.length===1;if(v){var i=r[0].clientX,n=r[0].clientY;e.startCoords={x:i-p,y:n-m}}};function Um(e){var t=e.transformState,r=t.positionX,a=t.positionY,p=t.scale,m=e.setup,v=m.disabled,i=m.limitToBounds,n=m.centerZoomedOut,c=e.wrapperComponent;if(!(v||!c||!e.bounds)){var f=e.bounds,l=f.maxPositionX,g=f.minPositionX,b=f.maxPositionY,y=f.minPositionY,_=r>l||r<g,o=a>b||a<y,h=r>l?c.offsetWidth:e.setup.minPositionX||0,d=a>b?c.offsetHeight:e.setup.minPositionY||0,u=kr(e,h,d,p,e.bounds,i||n),x=u.x,S=u.y;return{scale:p,positionX:_?x:r,positionY:o?S:a}}}function ba(e,t,r,a,p){var m=e.setup.limitToBounds,v=e.wrapperComponent,i=e.bounds,n=e.transformState,c=n.scale,f=n.positionX,l=n.positionY;if(!(v===null||i===null||t===f&&r===l)){var g=Fs(t,r,i,m,a,p,v),b=g.x,y=g.y;e.setTransformState(c,b,y)}}var qm=function(e,t,r){var a=e.startCoords,p=e.transformState,m=e.setup.panning,v=m.lockAxisX,i=m.lockAxisY,n=p.positionX,c=p.positionY;if(!a)return{x:n,y:c};var f=t-a.x,l=r-a.y,g=v?n:f,b=i?c:l;return{x:g,y:b}},zt=function(e,t){var r=e.setup,a=e.transformState,p=a.scale,m=r.minScale,v=r.disablePadding;return t>0&&p>=m&&!v?t:0},Km=function(e){var t=e.mounted,r=e.setup,a=r.disabled,p=r.velocityAnimation,m=e.transformState.scale,v=p.disabled,i=!v||m>1||!a||t;return!!i},Xm=function(e){var t=e.mounted,r=e.velocity,a=e.bounds,p=e.setup,m=p.disabled,v=p.velocityAnimation,i=e.transformState.scale,n=v.disabled,c=!n||i>1||!m||t;return!(!c||!r||!a)};function Vm(e,t){var r=e.setup.velocityAnimation,a=r.equalToMove,p=r.animationTime,m=r.sensitivity;return a?p*t*m:p}function Un(e,t,r,a,p,m,v,i,n,c){if(p){if(t>v&&r>v){var f=v+(e-v)*c;return f>n?n:f<v?v:f}if(t<m&&r<m){var f=m+(e-m)*c;return f<i?i:f>m?m:f}}return a?t:ni(e,m,v,p)}function Ym(e,t){var r=1;return t?Math.min(r,e.offsetWidth/window.innerWidth):r}function Gm(e,t){var r=Km(e);if(r){var a=e.lastMousePosition,p=e.velocityTime,m=e.setup,v=e.wrapperComponent,i=m.velocityAnimation.equalToMove,n=Date.now();if(a&&p&&v){var c=Ym(v,i),f=t.x-a.x,l=t.y-a.y,g=f/c,b=l/c,y=n-p,_=f*f+l*l,o=Math.sqrt(_)/y;e.velocity={velocityX:g,velocityY:b,total:o}}e.lastMousePosition=t,e.velocityTime=n}}function Qm(e){var t=e.velocity,r=e.bounds,a=e.setup,p=e.wrapperComponent,m=Xm(e);if(!(!m||!t||!r||!p)){var v=t.velocityX,i=t.velocityY,n=t.total,c=r.maxPositionX,f=r.minPositionX,l=r.maxPositionY,g=r.minPositionY,b=a.limitToBounds,y=a.alignmentAnimation,_=a.zoomAnimation,o=a.panning,h=o.lockAxisY,d=o.lockAxisX,u=_.animationType,x=y.sizeX,S=y.sizeY,k=y.velocityAlignmentTime,E=k,w=Vm(e,n),j=Math.max(w,E),R=zt(e,x),L=zt(e,S),D=R*p.offsetWidth/100,N=L*p.offsetHeight/100,M=c+D,O=f-D,F=l+N,z=g-N,A=e.transformState,P=new Date().getTime();xa(e,u,j,function(I){var B=e.transformState,$=B.scale,X=B.positionX,Z=B.positionY,J=new Date().getTime()-P,ae=J/E,T=va[y.animationType],H=1-T(Math.min(1,ae)),U=1-I,W=X+v*U,te=Z+i*U,K=Un(W,A.positionX,X,d,b,f,c,O,M,H),ce=Un(te,A.positionY,Z,h,b,g,l,z,F,H);(X!==W||Z!==te)&&e.setTransformState($,K,ce)})}}function qn(e,t){var r=e.transformState.scale;Ct(e),Kt(e,r),window.TouchEvent!==void 0&&t instanceof TouchEvent?$m(e,t):Wm(e,t)}function zi(e,t){var r=e.transformState.scale,a=e.setup,p=a.minScale,m=a.alignmentAnimation,v=m.disabled,i=m.sizeX,n=m.sizeY,c=m.animationTime,f=m.animationType,l=v||r<p||!i&&!n;if(!l){var g=Um(e);g&&Wt(e,g,t??c,f)}}function Kn(e,t,r){var a=e.startCoords,p=e.setup,m=p.alignmentAnimation,v=m.sizeX,i=m.sizeY;if(a){var n=qm(e,t,r),c=n.x,f=n.y,l=zt(e,v),g=zt(e,i);Gm(e,{x:c,y:f}),ba(e,c,f,l,g)}}function Zm(e){if(e.isPanning){var t=e.setup.panning.velocityDisabled,r=e.velocity,a=e.wrapperComponent,p=e.contentComponent;e.isPanning=!1,e.animate=!1,e.animation=null;var m=a?.getBoundingClientRect(),v=p?.getBoundingClientRect(),i=m?.width||0,n=m?.height||0,c=v?.width||0,f=v?.height||0,l=i<c||n<f,g=!t&&r&&r?.total>.1&&l;g?Qm(e):zi(e)}}function Hi(e,t,r,a){var p=e.setup,m=p.minScale,v=p.maxScale,i=p.limitToBounds,n=zs(wt(t,2),m,v,0,!1),c=Kt(e,n),f=kr(e,r,a,n,c,i),l=f.x,g=f.y;return{scale:n,positionX:l,positionY:g}}function ya(e,t,r){var a=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.minScale,i=m.limitToBounds,n=m.zoomAnimation,c=n.disabled,f=n.animationTime,l=n.animationType,g=c||a>=v;if((a>=1||i)&&zi(e),!(g||!p||!e.mounted)){var b=t||p.offsetWidth/2,y=r||p.offsetHeight/2,_=Hi(e,v,b,y);_&&Wt(e,_,f,l)}}var Ft=function(){return Ft=Object.assign||function(t){for(var r,a=1,p=arguments.length;a<p;a++){r=arguments[a];for(var m in r)Object.prototype.hasOwnProperty.call(r,m)&&(t[m]=r[m])}return t},Ft.apply(this,arguments)};function Xn(e,t,r){for(var a=0,p=t.length,m;a<p;a++)(m||!(a in t))&&(m||(m=Array.prototype.slice.call(t,0,a)),m[a]=t[a]);return e.concat(m||Array.prototype.slice.call(t))}var Ks={scale:1,positionX:0,positionY:0},gs={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}},oi={wrapperClass:"react-transform-wrapper",contentClass:"react-transform-component"},Sa=function(e){var t,r,a,p;return{previousScale:(t=e.initialScale)!==null&&t!==void 0?t:Ks.scale,scale:(r=e.initialScale)!==null&&r!==void 0?r:Ks.scale,positionX:(a=e.initialPositionX)!==null&&a!==void 0?a:Ks.positionX,positionY:(p=e.initialPositionY)!==null&&p!==void 0?p:Ks.positionY}},Vn=function(e){var t=Ft({},gs);return Object.keys(e).forEach(function(r){var a=typeof e[r]<"u",p=typeof gs[r]<"u";if(p&&a){var m=Object.prototype.toString.call(gs[r]),v=m==="[object Object]",i=m==="[object Array]";v?t[r]=Ft(Ft({},gs[r]),e[r]):i?t[r]=Xn(Xn([],gs[r],!0),e[r]):t[r]=e[r]}}),t},wa=function(e,t,r){var a=e.transformState.scale,p=e.wrapperComponent,m=e.setup,v=m.maxScale,i=m.minScale,n=m.zoomAnimation,c=m.smooth,f=n.size;if(!p)throw new Error("Wrapper is not mounted");var l=c?a*Math.exp(t*r):a+t*r,g=zs(wt(l,3),i,v,f,!1);return g};function Ca(e,t,r,a,p){var m=e.wrapperComponent,v=e.transformState,i=v.scale,n=v.positionX,c=v.positionY;if(!m)return console.error("No WrapperComponent found");var f=m.offsetWidth,l=m.offsetHeight,g=(f/2-n)/i,b=(l/2-c)/i,y=wa(e,t,r),_=Hi(e,y,g,b);if(!_)return console.error("Error during zoom event. New transformation state was not calculated.");Wt(e,_,a,p)}function ka(e,t,r,a){var p=e.setup,m=e.wrapperComponent,v=p.limitToBounds,i=Sa(e.props),n=e.transformState,c=n.scale,f=n.positionX,l=n.positionY;if(m){var g=Fi(e,i.scale),b=Fs(i.positionX,i.positionY,g,v,0,0,m),y={scale:i.scale,positionX:b.x,positionY:b.y};c===i.scale&&f===i.positionX&&l===i.positionY||(a?.(),Wt(e,y,t,r))}}function Jm(e,t,r,a){var p=e.getBoundingClientRect(),m=t.getBoundingClientRect(),v=r.getBoundingClientRect(),i=m.x*a.scale,n=m.y*a.scale;return{x:(p.x-v.x+i)/a.scale,y:(p.y-v.y+n)/a.scale}}function ep(e,t,r){var a=e.wrapperComponent,p=e.contentComponent,m=e.transformState,v=e.setup,i=v.limitToBounds,n=v.minScale,c=v.maxScale;if(!a||!p)return m;var f=a.getBoundingClientRect(),l=t.getBoundingClientRect(),g=Jm(t,a,p,m),b=g.x,y=g.y,_=l.width/m.scale,o=l.height/m.scale,h=a.offsetWidth/_,d=a.offsetHeight/o,u=zs(r||Math.min(h,d),n,c,0,!1),x=(f.width-_*u)/2,S=(f.height-o*u)/2,k=(f.left-b)*u+x,E=(f.top-y)*u+S,w=Fi(e,u),j=Fs(k,E,w,i,0,0,a),R=j.x,L=j.y;return{positionX:R,positionY:L,scale:u}}var tp=function(e){return function(t,r,a){t===void 0&&(t=.5),r===void 0&&(r=300),a===void 0&&(a="easeOut"),Ca(e,1,t,r,a)}},sp=function(e){return function(t,r,a){t===void 0&&(t=.5),r===void 0&&(r=300),a===void 0&&(a="easeOut"),Ca(e,-1,t,r,a)}},rp=function(e){return function(t,r,a,p,m){p===void 0&&(p=300),m===void 0&&(m="easeOut");var v=e.transformState,i=v.positionX,n=v.positionY,c=v.scale,f=e.wrapperComponent,l=e.contentComponent,g=e.setup.disabled;if(!(g||!f||!l)){var b={positionX:Number.isNaN(t)?i:t,positionY:Number.isNaN(r)?n:r,scale:Number.isNaN(a)?c:a};Wt(e,b,p,m)}}},ip=function(e){return function(t,r){t===void 0&&(t=200),r===void 0&&(r="easeOut"),ka(e,t,r)}},np=function(e){return function(t,r,a){r===void 0&&(r=200),a===void 0&&(a="easeOut");var p=e.transformState,m=e.wrapperComponent,v=e.contentComponent;if(m&&v){var i=Ea(t||p.scale,m,v);Wt(e,i,r,a)}}},op=function(e){return function(t,r,a,p){a===void 0&&(a=600),p===void 0&&(p="easeOut"),Ct(e);var m=e.wrapperComponent,v=typeof t=="string"?document.getElementById(t):t;if(m&&v&&m.contains(v)){var i=ep(e,v,r);Wt(e,i,a,p)}}},cr=function(e){return{instance:e,zoomIn:tp(e),zoomOut:sp(e),setTransform:rp(e),resetTransform:ip(e),centerView:np(e),zoomToElement:op(e)}},ai=function(e){return{instance:e,state:e.transformState}},Ue=function(e){var t={};return Object.assign(t,ai(e)),Object.assign(t,cr(e)),t},Vr=!1;function Yr(){try{var e={get passive(){return Vr=!0,!1}};return e}catch{return Vr=!1,Vr}}var Xs=".".concat(oi.wrapperClass),Er=function(e,t){return t.some(function(r){return e.matches("".concat(Xs," ").concat(r,", ").concat(Xs," .").concat(r,", ").concat(Xs," ").concat(r," *, ").concat(Xs," .").concat(r," *"))})},li=function(e){e&&clearTimeout(e)},ap=function(e,t,r){return"translate(".concat(e,"px, ").concat(t,"px) scale(").concat(r,")")},Ea=function(e,t,r){var a=r.offsetWidth*e,p=r.offsetHeight*e,m=(t.offsetWidth-a)/2,v=(t.offsetHeight-p)/2;return{scale:e,positionX:m,positionY:v}};function lp(e){return function(t){e.forEach(function(r){typeof r=="function"?r(t):r!=null&&(r.current=t)})}}var cp=function(e,t){var r=e.setup.wheel,a=r.disabled,p=r.wheelDisabled,m=r.touchPadDisabled,v=r.excluded,i=e.isInitialized,n=e.isPanning,c=t.target,f=i&&!n&&!a&&c;if(!f||p&&!t.ctrlKey||m&&t.ctrlKey)return!1;var l=Er(c,v);return!l},dp=function(e){return e?e.deltaY<0?1:-1:0};function up(e,t){var r=dp(e),a=Cm(t,r);return a}function ja(e,t,r){var a=t.getBoundingClientRect(),p=0,m=0;if("clientX"in e)p=(e.clientX-a.left)/r,m=(e.clientY-a.top)/r;else{var v=e.touches[0];p=(v.clientX-a.left)/r,m=(v.clientY-a.top)/r}return(Number.isNaN(p)||Number.isNaN(m))&&console.error("No mouse or touch offset found"),{x:p,y:m}}var hp=function(e,t,r,a,p){var m=e.transformState.scale,v=e.wrapperComponent,i=e.setup,n=i.maxScale,c=i.minScale,f=i.zoomAnimation,l=i.disablePadding,g=f.size,b=f.disabled;if(!v)throw new Error("Wrapper is not mounted");var y=m+t*r,_=a?!1:!b,o=zs(wt(y,3),c,n,g,_&&!l);return o},fp=function(e,t){var r=e.previousWheelEvent,a=e.transformState.scale,p=e.setup,m=p.maxScale,v=p.minScale;return r?a<m||a>v||Math.sign(r.deltaY)!==Math.sign(t.deltaY)||r.deltaY>0&&r.deltaY<t.deltaY||r.deltaY<0&&r.deltaY>t.deltaY||Math.sign(r.deltaY)!==Math.sign(t.deltaY):!1},mp=function(e,t){var r=e.setup.pinch,a=r.disabled,p=r.excluded,m=e.isInitialized,v=t.target,i=m&&!a&&v;if(!i)return!1;var n=Er(v,p);return!n},pp=function(e){var t=e.setup.pinch.disabled,r=e.isInitialized,a=e.pinchStartDistance,p=r&&!t&&a;return!!p},gp=function(e,t,r){var a=r.getBoundingClientRect(),p=e.touches,m=wt(p[0].clientX-a.left,5),v=wt(p[0].clientY-a.top,5),i=wt(p[1].clientX-a.left,5),n=wt(p[1].clientY-a.top,5);return{x:(m+i)/2/t,y:(v+n)/2/t}},Na=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))},vp=function(e,t){var r=e.pinchStartScale,a=e.pinchStartDistance,p=e.setup,m=p.maxScale,v=p.minScale,i=p.zoomAnimation,n=p.disablePadding,c=i.size,f=i.disabled;if(!r||a===null||!t)throw new Error("Pinch touches distance was not provided");if(t<0)return e.transformState.scale;var l=t/a,g=l*r;return zs(wt(g,2),v,m,c,!f&&!n)},_p=160,xp=100,bp=function(e,t){var r=e.props,a=r.onWheelStart,p=r.onZoomStart;e.wheelStopEventTimer||(Ct(e),Ye(Ue(e),t,a),Ye(Ue(e),t,p))},yp=function(e,t){var r=e.props,a=r.onWheel,p=r.onZoom,m=e.contentComponent,v=e.setup,i=e.transformState,n=i.scale,c=v.limitToBounds,f=v.centerZoomedOut,l=v.zoomAnimation,g=v.wheel,b=v.disablePadding,y=v.smooth,_=l.size,o=l.disabled,h=g.step,d=g.smoothStep;if(!m)throw new Error("Component not mounted");t.preventDefault(),t.stopPropagation();var u=up(t,null),x=y?d*Math.abs(t.deltaY):h,S=hp(e,u,x,!t.ctrlKey);if(n!==S){var k=Kt(e,S),E=ja(t,m,n),w=o||_===0||f||b,j=c&&w,R=kr(e,E.x,E.y,S,k,j),L=R.x,D=R.y;e.previousWheelEvent=t,e.setTransformState(S,L,D),Ye(Ue(e),t,a),Ye(Ue(e),t,p)}},Sp=function(e,t){var r=e.props,a=r.onWheelStop,p=r.onZoomStop;li(e.wheelAnimationTimer),e.wheelAnimationTimer=setTimeout(function(){e.mounted&&(ya(e,t.x,t.y),e.wheelAnimationTimer=null)},xp);var m=fp(e,t);m&&(li(e.wheelStopEventTimer),e.wheelStopEventTimer=setTimeout(function(){e.mounted&&(e.wheelStopEventTimer=null,Ye(Ue(e),t,a),Ye(Ue(e),t,p))},_p))},Aa=function(e){for(var t=0,r=0,a=0;a<2;a+=1)t+=e.touches[a].clientX,r+=e.touches[a].clientY;var p=t/2,m=r/2;return{x:p,y:m}},wp=function(e,t){var r=Na(t);e.pinchStartDistance=r,e.lastDistance=r,e.pinchStartScale=e.transformState.scale,e.isPanning=!1;var a=Aa(t);e.pinchLastCenterX=a.x,e.pinchLastCenterY=a.y,Ct(e)},Cp=function(e,t){var r=e.contentComponent,a=e.pinchStartDistance,p=e.wrapperComponent,m=e.transformState.scale,v=e.setup,i=v.limitToBounds,n=v.centerZoomedOut,c=v.zoomAnimation,f=v.alignmentAnimation,l=c.disabled,g=c.size;if(!(a===null||!r)){var b=gp(t,m,r);if(!(!Number.isFinite(b.x)||!Number.isFinite(b.y))){var y=Na(t),_=vp(e,y),o=Aa(t),h=o.x-(e.pinchLastCenterX||0),d=o.y-(e.pinchLastCenterY||0);if(!(_===m&&h===0&&d===0)){e.pinchLastCenterX=o.x,e.pinchLastCenterY=o.y;var u=Kt(e,_),x=l||g===0||n,S=i&&x,k=kr(e,b.x,b.y,_,u,S),E=k.x,w=k.y;e.pinchMidpoint=b,e.lastDistance=y;var j=f.sizeX,R=f.sizeY,L=zt(e,j),D=zt(e,R),N=E+h,M=w+d,O=Fs(N,M,u,i,L,D,p),F=O.x,z=O.y;e.setTransformState(_,F,z)}}}},kp=function(e){var t=e.pinchMidpoint;e.velocity=null,e.lastDistance=null,e.pinchMidpoint=null,e.pinchStartScale=null,e.pinchStartDistance=null,ya(e,t?.x,t?.y)},Ra=function(e,t){var r=e.props.onZoomStop,a=e.setup.doubleClick.animationTime;li(e.doubleClickStopEventTimer),e.doubleClickStopEventTimer=setTimeout(function(){e.doubleClickStopEventTimer=null,Ye(Ue(e),t,r)},a)},Ep=function(e,t){var r=e.props,a=r.onZoomStart,p=r.onZoom,m=e.setup.doubleClick,v=m.animationTime,i=m.animationType;Ye(Ue(e),t,a),ka(e,v,i,function(){return Ye(Ue(e),t,p)}),Ra(e,t)};function jp(e,t){return e==="toggle"?t===1?1:-1:e==="zoomOut"?-1:1}function Np(e,t){var r=e.setup,a=e.doubleClickStopEventTimer,p=e.transformState,m=e.contentComponent,v=p.scale,i=e.props,n=i.onZoomStart,c=i.onZoom,f=r.doubleClick,l=f.disabled,g=f.mode,b=f.step,y=f.animationTime,_=f.animationType;if(!l&&!a){if(g==="reset")return Ep(e,t);if(!m)return console.error("No ContentComponent found");var o=jp(g,e.transformState.scale),h=wa(e,o,b);if(v!==h){Ye(Ue(e),t,n);var d=ja(t,m,v),u=Hi(e,h,d.x,d.y);if(!u)return console.error("Error during zoom event. New transformation state was not calculated.");Ye(Ue(e),t,c),Wt(e,u,y,_),Ra(e,t)}}}var Ap=function(e,t){var r=e.isInitialized,a=e.setup,p=e.wrapperComponent,m=a.doubleClick,v=m.disabled,i=m.excluded,n=t.target,c=p?.contains(n),f=r&&n&&c&&!v;if(!f)return!1;var l=Er(n,i);return!l},Rp=(function(){function e(t){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(a){r.props=a,Kt(r,r.transformState.scale),r.setup=Vn(a)},this.initializeWindowEvents=function(){var a,p,m=Yr(),v=(a=r.wrapperComponent)===null||a===void 0?void 0:a.ownerDocument,i=v?.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),v?.addEventListener("mouseleave",r.clearPanning,m),i?.addEventListener("keyup",r.setKeyUnPressed,m),i?.addEventListener("keydown",r.setKeyPressed,m)},this.cleanupWindowEvents=function(){var a,p,m=Yr(),v=(a=r.wrapperComponent)===null||a===void 0?void 0:a.ownerDocument,i=v?.defaultView;i?.removeEventListener("mousedown",r.onPanningStart,m),i?.removeEventListener("mousemove",r.onPanning,m),i?.removeEventListener("mouseup",r.onPanningStop,m),v?.removeEventListener("mouseleave",r.clearPanning,m),i?.removeEventListener("keyup",r.setKeyUnPressed,m),i?.removeEventListener("keydown",r.setKeyPressed,m),document.removeEventListener("mouseleave",r.clearPanning,m),Ct(r),(p=r.observer)===null||p===void 0||p.disconnect()},this.handleInitializeWrapperEvents=function(a){var p=Yr();a.addEventListener("wheel",r.onWheelZoom,p),a.addEventListener("dblclick",r.onDoubleClick,p),a.addEventListener("touchstart",r.onTouchPanningStart,p),a.addEventListener("touchmove",r.onTouchPanning,p),a.addEventListener("touchend",r.onTouchPanningStop,p)},this.handleInitialize=function(a,p){var m=!1,v=r.setup.centerOnInit,i=function(n,c){for(var f=0,l=n;f<l.length;f++){var g=l[f];if(g.target===c)return!0}return!1};r.applyTransformation(),r.onInitCallbacks.forEach(function(n){n(Ue(r))}),r.observer=new ResizeObserver(function(n){if(i(n,a)||i(n,p))if(v&&!m){var c=p.offsetWidth,f=p.offsetHeight;(c>0||f>0)&&(m=!0,r.setCenter())}else Ct(r),Kt(r,r.transformState.scale),zi(r,0)}),r.observer.observe(a),r.observer.observe(p)},this.onWheelZoom=function(a){var p=r.setup.disabled;if(!p){var m=cp(r,a);if(m){var v=r.isPressingKeys(r.setup.wheel.activationKeys);v&&(bp(r,a),yp(r,a),Sp(r,a))}}},this.onWheelPanning=function(a){var p=r.setup,m=p.disabled,v=p.wheel,i=p.panning;if(!(!r.wrapperComponent||!r.contentComponent||m||!v.wheelDisabled||i.disabled||!i.wheelPanning||a.ctrlKey)){a.preventDefault(),a.stopPropagation();var n=r.transformState,c=n.positionX,f=n.positionY,l=c-a.deltaX,g=f-a.deltaY,b=i.lockAxisX?c:l,y=i.lockAxisY?f:g,_=r.setup.alignmentAnimation,o=_.sizeX,h=_.sizeY,d=zt(r,o),u=zt(r,h);b===c&&y===f||ba(r,b,y,d,u)}},this.onPanningStart=function(a){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Wn(r,a);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(a.button===0&&!r.setup.panning.allowLeftClickPan||a.button===1&&!r.setup.panning.allowMiddleClickPan||a.button===2&&!r.setup.panning.allowRightClickPan||(a.preventDefault(),a.stopPropagation(),Ct(r),qn(r,a),Ye(Ue(r),a,m)))}}},this.onPanning=function(a){var p=r.setup.disabled,m=r.props.onPanning;if(!p){var v=$n(r);if(v){var i=r.isPressingKeys(r.setup.panning.activationKeys);i&&(a.preventDefault(),a.stopPropagation(),Kn(r,a.clientX,a.clientY),Ye(Ue(r),a,m))}}},this.onPanningStop=function(a){var p=r.props.onPanningStop;r.isPanning&&(Zm(r),Ye(Ue(r),a,p))},this.onPinchStart=function(a){var p=r.setup.disabled,m=r.props,v=m.onPinchingStart,i=m.onZoomStart;if(!p){var n=mp(r,a);n&&(wp(r,a),Ct(r),Ye(Ue(r),a,v),Ye(Ue(r),a,i))}},this.onPinch=function(a){var p=r.setup.disabled,m=r.props,v=m.onPinching,i=m.onZoom;if(!p){var n=pp(r);n&&(a.preventDefault(),a.stopPropagation(),Cp(r,a),Ye(Ue(r),a,v),Ye(Ue(r),a,i))}},this.onPinchStop=function(a){var p=r.props,m=p.onPinchingStop,v=p.onZoomStop;r.pinchStartScale&&(kp(r),Ye(Ue(r),a,m),Ye(Ue(r),a,v))},this.onTouchPanningStart=function(a){var p=r.setup.disabled,m=r.props.onPanningStart;if(!p){var v=Wn(r,a);if(v){var i=r.lastTouch&&+new Date-r.lastTouch<200&&a.touches.length===1;if(!i){r.lastTouch=+new Date,Ct(r);var n=a.touches,c=n.length===1,f=n.length===2;c&&(Ct(r),qn(r,a),Ye(Ue(r),a,m)),f&&r.onPinchStart(a)}}}},this.onTouchPanning=function(a){var p=r.setup.disabled,m=r.props.onPanning;if(r.isPanning&&a.touches.length===1){if(p)return;var v=$n(r);if(!v)return;a.preventDefault(),a.stopPropagation();var i=a.touches[0];Kn(r,i.clientX,i.clientY),Ye(Ue(r),a,m)}else a.touches.length>1&&r.onPinch(a)},this.onTouchPanningStop=function(a){r.onPanningStop(a),r.onPinchStop(a)},this.onDoubleClick=function(a){var p=r.setup.disabled;if(!p){var m=Ap(r,a);m&&Np(r,a)}},this.clearPanning=function(a){r.isPanning&&r.onPanningStop(a)},this.setKeyPressed=function(a){r.pressedKeys[a.key]=!0},this.setKeyUnPressed=function(a){r.pressedKeys[a.key]=!1},this.isPressingKeys=function(a){return a.length?!!a.find(function(p){return r.pressedKeys[p]}):!0},this.setTransformState=function(a,p,m){var v=r.props.onTransformed;if(!Number.isNaN(a)&&!Number.isNaN(p)&&!Number.isNaN(m)){a!==r.transformState.scale&&(r.transformState.previousScale=r.transformState.scale,r.transformState.scale=a),r.transformState.positionX=p,r.transformState.positionY=m,r.applyTransformation();var i=Ue(r);r.onChangeCallbacks.forEach(function(n){return n(i)}),Ye(i,{scale:a,positionX:p,positionY:m},v)}else console.error("Detected NaN set state values")},this.setCenter=function(){if(r.wrapperComponent&&r.contentComponent){var a=Ea(r.transformState.scale,r.wrapperComponent,r.contentComponent);r.setTransformState(a.scale,a.positionX,a.positionY)}},this.handleTransformStyles=function(a,p,m){return r.props.customTransform?r.props.customTransform(a,p,m):ap(a,p,m)},this.applyTransformation=function(){if(!(!r.mounted||!r.contentComponent)){var a=r.transformState,p=a.scale,m=a.positionX,v=a.positionY,i=r.handleTransformStyles(m,v,p);r.contentComponent.style.transform=i}},this.getContext=function(){return Ue(r)},this.onChange=function(a){return r.onChangeCallbacks.has(a)||r.onChangeCallbacks.add(a),function(){r.onChangeCallbacks.delete(a)}},this.onInit=function(a){return r.onInitCallbacks.has(a)||r.onInitCallbacks.add(a),function(){r.onInitCallbacks.delete(a)}},this.init=function(a,p){r.cleanupWindowEvents(),r.wrapperComponent=a,r.contentComponent=p,Kt(r,r.transformState.scale),r.handleInitializeWrapperEvents(a),r.handleInitialize(a,p),r.initializeWindowEvents(),r.isInitialized=!0;var m=Ue(r);Ye(m,void 0,r.props.onInit)},this.props=t,this.setup=Vn(this.props),this.transformState=Sa(this.props)}return e})(),jr=ie.createContext(null),Tp=function(e,t){return typeof e=="function"?e(t):e},Mp=ie.forwardRef(function(e,t){var r=C.useRef(new Rp(e)).current,a=Tp(e.children,cr(r));return C.useImperativeHandle(t,function(){return cr(r)},[r]),C.useEffect(function(){r.update(e)},[r,e]),ie.createElement(jr.Provider,{value:r},a)});ie.forwardRef(function(e,t){var r=C.useRef(null),a=C.useContext(jr);return C.useEffect(function(){return a.onChange(function(p){if(r.current){var m=0,v=0;r.current.style.transform=a.handleTransformStyles(m,v,1/p.instance.transformState.scale)}})},[a]),ie.createElement("div",Ft({},e,{ref:lp([r,t])}))});function Dp(e,t){t===void 0&&(t={});var r=t.insertAt;if(!(typeof document>"u")){var a=document.head||document.getElementsByTagName("head")[0],p=document.createElement("style");p.type="text/css",r==="top"&&a.firstChild?a.insertBefore(p,a.firstChild):a.appendChild(p),p.styleSheet?p.styleSheet.cssText=e:p.appendChild(document.createTextNode(e))}}var Lp=`.transform-component-module_wrapper__SPB86 {
39
+ position: relative;
40
+ width: -moz-fit-content;
41
+ width: fit-content;
42
+ height: -moz-fit-content;
43
+ height: fit-content;
44
+ overflow: hidden;
45
+ -webkit-touch-callout: none; /* iOS Safari */
46
+ -webkit-user-select: none; /* Safari */
47
+ -khtml-user-select: none; /* Konqueror HTML */
48
+ -moz-user-select: none; /* Firefox */
49
+ -ms-user-select: none; /* Internet Explorer/Edge */
50
+ user-select: none;
51
+ margin: 0;
52
+ padding: 0;
53
+ transform: translate3d(0, 0, 0);
54
+ }
55
+ .transform-component-module_content__FBWxo {
56
+ display: flex;
57
+ flex-wrap: wrap;
58
+ width: -moz-fit-content;
59
+ width: fit-content;
60
+ height: -moz-fit-content;
61
+ height: fit-content;
62
+ margin: 0;
63
+ padding: 0;
64
+ transform-origin: 0% 0%;
65
+ }
66
+ .transform-component-module_content__FBWxo img {
67
+ pointer-events: none;
68
+ }
69
+ `,Yn={wrapper:"transform-component-module_wrapper__SPB86",content:"transform-component-module_content__FBWxo"};Dp(Lp);var Pp=function(e){var t=e.children,r=e.wrapperClass,a=r===void 0?"":r,p=e.contentClass,m=p===void 0?"":p,v=e.wrapperStyle,i=e.contentStyle,n=e.wrapperProps,c=n===void 0?{}:n,f=e.contentProps,l=f===void 0?{}:f,g=C.useContext(jr),b=g.init,y=g.cleanupWindowEvents,_=C.useRef(null),o=C.useRef(null);return C.useEffect(function(){var h=_.current,d=o.current;return h!==null&&d!==null&&b&&b?.(h,d),function(){y?.()}},[]),ie.createElement("div",Ft({},c,{ref:_,className:"".concat(oi.wrapperClass," ").concat(Yn.wrapper," ").concat(a),style:v}),ie.createElement("div",Ft({},l,{ref:o,className:"".concat(oi.contentClass," ").concat(Yn.content," ").concat(m),style:i}),t))},Ta=function(){var e=C.useContext(jr);if(!e)throw new Error("Transform context must be placed inside TransformWrapper");return e},Op=function(){var e=Ta();return cr(e)};function Ip(e){var t=Ta(),r=C.useState(e(ai(t))),a=r[0],p=r[1];return C.useEffect(function(){var m=!0,v=t.onChange(function(i){m&&p(e(ai(i.instance)))});return function(){v(),m=!1}},[e,t]),a}function Bp(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 Fp(e,t){return vt({queryKey:le.files.tree(e||"",t),queryFn:()=>me.get("/files/tree",{params:{workingDir:e||"",path:t}}),enabled:!!e})}function zp(e,t){return vt({queryKey:le.files.content(e||"",t||""),queryFn:()=>me.get("/files/read",{params:{workingDir:e||"",path:t||""}}),enabled:!!e&&!!t})}function Hp(e){const t=Qe();return C.useCallback(()=>{e&&t.invalidateQueries({queryKey:["files","tree",e]})},[t,e])}function Wp(){const e=Qe();return ut({mutationFn:t=>me.post("/files/write",t),onSuccess:(t,r)=>{const a=le.files.content(r.workingDir,r.path),p=e.getQueryData(a);e.setQueryData(a,{content:r.content,language:p?.language||Bp(r.path)})}})}function $p(e,t){return e==="/"?`/${t}`:`${e}/${t}`}function Up(e,t){return e==="/"?t:`${e.slice(1)}/${t}`}const qp=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Kp(e){if(e.type==="directory")return null;const t=e.name.split(".").pop()?.toLowerCase();return t&&qp.has(t)?Ni:t==="ts"||t==="tsx"||t==="js"||t==="jsx"?ks:t==="json"?Sc:t==="md"||t==="mdx"||t==="txt"?ki:Ql}const Gn=({depth:e,active:t,onClick:r,leftIcon:a,rightIcon:p,label:m})=>s.jsxs("button",{type:"button",onClick:r,className:se("w-full flex items-center gap-2 rounded px-2 py-1 text-left text-xs hover:bg-neutral-100",t&&"bg-neutral-100 text-neutral-900"),style:{paddingLeft:8+e*14},children:[s.jsx("span",{className:"shrink-0",children:p}),s.jsx("span",{className:"shrink-0 text-neutral-500",children:a}),s.jsx("span",{className:"truncate text-neutral-700",children:m})]}),Ma=({workingDir:e,path:t,depth:r,expanded:a,toggleDir:p,onFileSelect:m,selectedFilePath:v})=>{const{t:i}=ne(),{data:n,isLoading:c,isError:f}=Fp(e,t),l=C.useMemo(()=>n?.items??[],[n?.items]);return c?s.jsx("div",{className:"text-xs text-neutral-400 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Loading...")}):f?s.jsx("div",{className:"text-xs text-red-600 px-2 py-1",style:{paddingLeft:8+r*14},children:i("Failed to load")}):s.jsx("div",{className:"space-y-0.5",children:l.map(g=>{if(g.type==="directory"){const h=$p(t,g.name),d=a.has(h);return s.jsxs("div",{children:[s.jsx(Gn,{depth:r,onClick:()=>p(h),rightIcon:d?s.jsx(_t,{size:14,className:"text-neutral-400"}):s.jsx(Tt,{size:14,className:"text-neutral-400"}),leftIcon:d?s.jsx(Ei,{size:14,className:"text-amber-500"}):s.jsx(Gl,{size:14,className:"text-amber-500"}),label:g.name}),d&&s.jsx(Ma,{workingDir:e,path:h,depth:r+1,expanded:a,toggleDir:p,onFileSelect:m,selectedFilePath:v})]},h)}const b=Up(t,g.name),y=Kp(g),_=v===b,o=y===Ni;return s.jsx(Gn,{depth:r,active:_,onClick:()=>m(b),rightIcon:s.jsx("span",{className:"inline-block w-[14px]"}),leftIcon:y?s.jsx(y,{size:14,className:o?"text-emerald-600":"text-sky-600"}):null,label:g.name},b)})})},Xp=({workingDir:e,className:t,onFileSelect:r,selectedFilePath:a,onCollapse:p})=>{const{t:m}=ne(),[v,i]=C.useState(()=>new Set),n=Hp(e),c=C.useCallback(f=>{i(l=>{const g=new Set(l);return g.has(f)?g.delete(f):g.add(f),g})},[]);return s.jsxs("div",{className:se("h-full flex flex-col",t),children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-200 bg-neutral-50/80 flex items-center justify-between",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-[11px] font-semibold text-neutral-600 uppercase tracking-wider",children:m("Files")}),s.jsx("div",{className:"text-[11px] text-neutral-400 truncate",children:e||m("No working directory")})]}),s.jsxs("div",{className:"flex items-center gap-0.5 shrink-0",children:[e&&s.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:s.jsx(Es,{size:13})}),p&&s.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:s.jsx(Wc,{size:13})})]})]}),s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-2",children:e?s.jsx(Ma,{workingDir:e,path:"/",depth:0,expanded:v,toggleDir:c,onFileSelect:r,selectedFilePath:a}):s.jsx("div",{className:"text-xs text-neutral-500 px-2 py-2",children:m("No workspace selected.")})})]})},Vp=new Set(["png","jpg","jpeg","gif","bmp","webp","svg","ico","avif"]);function Yp(e){const t=e.split(".").pop()?.toLowerCase();return t?Vp.has(t):!1}function Gp(e,t){const r="/api",a=new URLSearchParams({workingDir:e,path:t});return`${r}/files/image?${a.toString()}`}const Qp=({filePath:e})=>{const{t}=ne(),{zoomIn:r,zoomOut:a,centerView:p}=Op(),m=Ip(i=>i.state.scale),v=Math.round(m*100);return s.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:[s.jsx("button",{type:"button",onClick:()=>a(.5),className:"p-1 rounded hover:bg-neutral-200 text-neutral-500 hover:text-neutral-700 transition-colors",title:t("Zoom out"),children:s.jsx(od,{size:14})}),s.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:t("Reset zoom"),children:[v,"%"]}),s.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:t("Zoom in"),children:s.jsx(id,{size:14})}),s.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:t("Fit to view"),children:s.jsx(Fc,{size:13})}),s.jsx("span",{className:"ml-2 text-[11px] text-neutral-400 truncate",children:e})]})},Zp=({workingDir:e,filePath:t})=>{const{t:r}=ne(),[a,p]=C.useState(!1),m=Gp(e,t);return a?s.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:r("Failed to load image.")}):s.jsx(Mp,{initialScale:1,minScale:.1,maxScale:10,centerOnInit:!0,doubleClick:{mode:"toggle"},children:s.jsxs("div",{className:"h-full flex flex-col",children:[s.jsx(Qp,{filePath:t}),s.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:s.jsx(Pp,{wrapperStyle:{width:"100%",height:"100%"},contentStyle:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:s.jsx("img",{src:m,alt:t,className:"max-w-full max-h-full object-contain rounded shadow-sm",draggable:!1,onError:()=>p(!0)})})})]})})};function Jp(e){const t=e.split("/");return t[t.length-1]||e}function e0(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 t0=({active:e,name:t,isDirty:r,onClick:a,onClose:p})=>{const{t:m}=ne();return s.jsxs("button",{type:"button",onClick:a,className:se("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:[s.jsx("span",{className:se("w-2 h-2 rounded-full",r?"bg-amber-500":"bg-transparent")}),s.jsx("span",{className:"truncate flex-1 text-left text-xs",children:t}),s.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:s.jsx(Ht,{size:12})})]})},s0=({workingDir:e,className:t,readOnly:r=!1})=>{const{t:a}=ne(),[p,m]=C.useState([]),[v,i]=C.useState(null),n=Wp(),[c,f]=C.useState(280),[l,g]=C.useState(!1),[b,y]=C.useState(!1),_=C.useRef(280),o=C.useCallback(()=>{g(N=>(N?f(_.current):_.current=c,!N))},[c]),h=C.useCallback(N=>{N.preventDefault(),y(!0);const M=N.clientX,O=c,F=A=>{const P=A.clientX-M,I=Math.min(480,Math.max(160,O+P));f(I)},z=()=>{y(!1),document.removeEventListener("mousemove",F),document.removeEventListener("mouseup",z)};document.addEventListener("mousemove",F),document.addEventListener("mouseup",z)},[c]);C.useEffect(()=>{m([]),i(null)},[e]);const d=C.useMemo(()=>p.find(N=>N.path===v)||null,[p,v]),{data:u,isFetching:x,isError:S,error:k}=zp(e,d?.isImage?null:v);C.useEffect(()=>{!v||!u||m(N=>N.map(M=>M.path!==v||M.isDirty||M.loaded?M:{...M,language:u.language||M.language,content:u.content,savedContent:u.content,isDirty:!1,loaded:!0}))},[v,u]);const E=C.useCallback(N=>{m(M=>{if(M.find(z=>z.path===N))return M;const F=Yp(N);return[...M,{path:N,name:Jp(N),language:e0(N),content:"",savedContent:"",isDirty:!1,loaded:F,isImage:F}]}),i(N)},[]),w=C.useCallback(N=>{m(M=>{const O=M.filter(F=>F.path!==N);return i(F=>F!==N?F:O.length?O[O.length-1].path:null),O})},[]),j=C.useCallback(N=>{m(M=>M.map(O=>{if(O.path!==v)return O;const F=N!==O.savedContent;return{...O,content:N,isDirty:F}}))},[v]),R=C.useCallback(async()=>{r||!e||!d||(await n.mutateAsync({workingDir:e,path:d.path,content:d.content}),m(N=>N.map(M=>M.path===d.path?{...M,savedContent:M.content,isDirty:!1,loaded:!0}:M)))},[d,r,n,e]),L=C.useRef(()=>{});C.useEffect(()=>{L.current=()=>{R().catch(()=>{})}},[R]),C.useEffect(()=>{const N=M=>{r||(M.metaKey||M.ctrlKey)&&M.key.toLowerCase()==="s"&&(M.preventDefault(),L.current())};return window.addEventListener("keydown",N),()=>window.removeEventListener("keydown",N)},[r]);const D=C.useCallback((N,M)=>{N.addCommand(M.KeyMod.CtrlCmd|M.KeyCode.KeyS,()=>{L.current()})},[]);return s.jsxs("div",{className:se("flex h-full overflow-hidden bg-white",t),style:b?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsx("div",{className:"border-r border-neutral-200 bg-white shrink-0 overflow-hidden relative",style:{width:l?36:c,transition:b?"none":"width 0.15s ease"},children:l?s.jsx("div",{className:"h-full flex items-start pt-2 justify-center",children:s.jsx("button",{type:"button",onClick:o,className:"p-1.5 rounded hover:bg-neutral-100 text-neutral-500 hover:text-neutral-700 transition-colors",title:a("Expand file tree"),children:s.jsx(Uc,{size:16})})}):s.jsx(s.Fragment,{children:s.jsx(Xp,{workingDir:e,onFileSelect:E,selectedFilePath:d?.path||null,onCollapse:o},e||"no-working-dir")})}),!l&&s.jsx("div",{onMouseDown:h,className:se("w-1 shrink-0 cursor-col-resize transition-colors",b?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsxs("div",{className:"flex-1 flex flex-col min-w-0",children:[s.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:[p.length===0?s.jsx("div",{className:"px-2 pb-2 text-xs text-neutral-500",children:a("No open files")}):p.map(N=>s.jsx(t0,{active:N.path===v,name:N.name,isDirty:N.isDirty,onClick:()=>i(N.path),onClose:M=>{M.stopPropagation(),w(N.path)}},N.path)),s.jsxs("div",{className:"ml-auto flex items-center gap-2 pb-2 pr-1",children:[r&&s.jsx("span",{className:"text-[11px] text-neutral-400",children:a("Read-only")}),n.isPending&&s.jsxs("span",{className:"flex items-center gap-2 text-xs text-neutral-500",children:[s.jsx(Ke,{size:14,className:"animate-spin"}),a("Saving")]}),d?.isDirty&&!n.isPending&&s.jsx("span",{className:"text-[11px] text-amber-600",children:a("Unsaved")})]})]}),s.jsx("div",{className:"flex-1 min-h-0 relative",children:e?d?d.isImage?s.jsx(Zp,{workingDir:e,filePath:d.path}):s.jsxs(s.Fragment,{children:[s.jsx(wm,{path:d.path,value:d.content,language:d.language,theme:"vs-light",height:"100%",onChange:r?void 0:N=>j(N??""),onMount:D,options:{fontSize:13,minimap:{enabled:!1},scrollBeyondLastLine:!1,wordWrap:"off",automaticLayout:!0,readOnly:r}}),x&&!d.loaded&&s.jsx("div",{className:"absolute inset-0 bg-white/60 flex items-center justify-center",children:s.jsxs("div",{className:"flex items-center gap-2 text-xs text-neutral-600",children:[s.jsx(Ke,{size:14,className:"animate-spin"}),a("Loading file...")]})}),S&&s.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:[a("Failed to load file"),k instanceof Error?`: ${k.message}`:""]})]}):s.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:a("Select a file from the tree to open.")}):s.jsx("div",{className:"h-full flex items-center justify-center text-neutral-500 text-sm",children:a("No workspace selected.")})})]})]})};function Da(e){return vt({queryKey:le.git.changes(e||""),queryFn:()=>me.get("/git/changes",{params:{workingDir:e||""}}),enabled:!!e})}function La(e,t,r){return vt({queryKey:le.git.diff(e||"",t||"",r),queryFn:()=>me.get("/git/diff",{params:{workingDir:e||"",path:t||"",type:r}}),enabled:!!e&&!!t})}function Pa(e,t){return vt({queryKey:le.git.commitFiles(e||"",t||""),queryFn:()=>me.get("/git/commit-files",{params:{workingDir:e||"",hash:t||""}}),enabled:!!e&&!!t})}function Oa(e,t,r){return vt({queryKey:le.git.commitDiff(e||"",t||"",r||""),queryFn:()=>me.get("/git/commit-diff",{params:{workingDir:e||"",hash:t||"",path:r||""}}),enabled:!!e&&!!t&&!!r})}const Qn={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"},r0={M:"Modified",A:"Added",D:"Deleted",R:"Renamed"};function i0(e){const t=e.split("/");return t[t.length-1]||e}function n0(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const o0=({entry:e,selected:t,onClick:r})=>{const{t:a}=ne(),p=Qn[e.status]||Qn.M,m=r0[e.status]||e.status,v=n0(e.path);return s.jsxs("button",{type:"button",onClick:r,className:se("flex items-center gap-2 px-2 py-1.5 rounded cursor-pointer group w-full text-left",t?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("span",{className:se("w-4 h-4 flex items-center justify-center text-[10px] font-bold border rounded-sm shrink-0",p),title:a(m),children:e.status}),s.jsx("span",{className:"text-xs text-neutral-900 truncate",children:i0(e.path)}),v&&s.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:v})]})},Zn=({title:e,entries:t,type:r,selectedKey:a,onSelect:p})=>{const{t:m}=ne();return t.length===0?null:s.jsxs("div",{children:[s.jsxs("div",{className:"flex items-center gap-2 px-2 py-1.5",children:[s.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:t.length})]}),s.jsx("div",{className:"space-y-0.5",children:t.map(v=>{const i=`${r}:${v.path}`;return s.jsx(o0,{entry:v,selected:a===i,onClick:()=>p(v.path,r)},i)})})]})},a0=({line:e,lineNum:t})=>{let r="",a="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(r="bg-emerald-50",a="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(r="bg-red-50",a="text-red-800"):e.startsWith("@@")?(r="bg-blue-50",a="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(a="text-neutral-400"),s.jsxs("div",{className:se("flex",r),children:[s.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),s.jsx("span",{className:se("pl-2 whitespace-pre",a),children:e})]})},l0=({workingDir:e,filePath:t,type:r})=>{const{t:a}=ne(),{data:p,isLoading:m,isError:v}=La(e,t,r);if(m)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[s.jsx(Ke,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(v)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:a("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:a("No diff content available.")});const n=i.split(`
70
+ `);return s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((c,f)=>s.jsx(a0,{line:c,lineNum:f+1},f))})},c0=({workingDir:e})=>{const{t}=ne(),{data:r,isLoading:a,isError:p}=Da(e),[m,v]=C.useState(null),[i,n]=C.useState(260),[c,f]=C.useState(!1),l=C.useCallback(h=>{h.preventDefault(),f(!0);const d=h.clientX,u=i,x=k=>{const E=k.clientX-d,w=Math.min(480,Math.max(160,u+E));n(w)},S=()=>{f(!1),document.removeEventListener("mousemove",x),document.removeEventListener("mouseup",S)};document.addEventListener("mousemove",x),document.addEventListener("mouseup",S)},[i]),g=m?`${m.type}:${m.path}`:null,b=(h,d)=>{v({path:h,type:d})};if(!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:t("No workspace selected.")});if(a)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[s.jsx(Ke,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(p)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load changes.")});const y=r?.uncommitted||[],_=r?.committed||[],o=y.length+_.length;return s.jsxs("div",{className:"flex h-full bg-white",style:c?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:i},children:[s.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ls,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("Changes")}),o>0&&s.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:o})]})}),s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:o===0?s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-neutral-400",children:[s.jsx(ls,{size:28,className:"mb-2"}),s.jsx("span",{className:"text-xs",children:t("No pending changes")})]}):s.jsxs("div",{className:"space-y-2",children:[s.jsx(Zn,{title:"Uncommitted",entries:y,type:"uncommitted",selectedKey:g,onSelect:b}),s.jsx(Zn,{title:"Committed",entries:_,type:"committed",selectedKey:g,onSelect:b})]})})]}),s.jsx("div",{onMouseDown:l,className:se("w-1 shrink-0 cursor-col-resize transition-colors",c?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:m?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[s.jsx(ks,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:m.path}),s.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",t(m.type==="uncommitted"?"Uncommitted":"Committed"),")"]})]}),s.jsx(l0,{workingDir:e,filePath:m.path,type:m.type})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(ks,{size:28}),s.jsx("span",{className:"text-xs",children:t("Select a file to view diff")})]})})})]})},Gr=50,Jn={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 d0(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?It("{count}s ago",{count:r}):r<3600?It("{count}m ago",{count:Math.floor(r/60)}):r<86400?It("{count}h ago",{count:Math.floor(r/3600)}):r<604800?It("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function u0(e){const t=e.split("/");return t[t.length-1]||e}function h0(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}const f0=({line:e,lineNum:t})=>{let r="",a="text-neutral-700";return e.startsWith("+")&&!e.startsWith("+++")?(r="bg-emerald-50",a="text-emerald-800"):e.startsWith("-")&&!e.startsWith("---")?(r="bg-red-50",a="text-red-800"):e.startsWith("@@")?(r="bg-blue-50",a="text-blue-700"):(e.startsWith("diff ")||e.startsWith("index "))&&(a="text-neutral-400"),s.jsxs("div",{className:se("flex",r),children:[s.jsx("span",{className:"w-10 shrink-0 text-right pr-2 text-neutral-400 select-none border-r border-neutral-100",children:t}),s.jsx("span",{className:se("pl-2 whitespace-pre",a),children:e})]})},m0=({workingDir:e,hash:t,filePath:r})=>{const{t:a}=ne(),{data:p,isLoading:m,isError:v}=Oa(e,t,r);if(m)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500",children:[s.jsx(Ke,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(v)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-xs",children:a("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-xs",children:a("No diff content available.")});const n=i.split(`
71
+ `);return s.jsx("div",{className:"flex-1 overflow-auto scrollbar-app-thin font-mono text-xs leading-5",children:n.map((c,f)=>s.jsx(f0,{line:c,lineNum:f+1},f))})},p0=({workingDir:e,hash:t,selectedPath:r,onSelectFile:a})=>{const{t:p}=ne(),{data:m,isLoading:v}=Pa(e,t);if(v)return s.jsxs("div",{className:"pl-7 py-1 text-xs text-neutral-400 flex items-center gap-1",children:[s.jsx(Ke,{size:12,className:"animate-spin"}),s.jsx("span",{children:p("Loading...")})]});const i=m?.files||[];return i.length===0?s.jsx("div",{className:"pl-7 py-1 text-xs text-neutral-400",children:p("No files changed")}):s.jsx("div",{className:"pl-7 pb-1 space-y-0.5",children:i.map(n=>{const c=Jn[n.status]||Jn.M,f=h0(n.path);return s.jsxs("button",{type:"button",onClick:l=>{l.stopPropagation(),a(n.path)},className:se("flex items-center gap-1.5 px-1.5 py-1 rounded cursor-pointer w-full text-left",r===n.path?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("span",{className:se("w-3.5 h-3.5 flex items-center justify-center text-[9px] font-bold border rounded-sm shrink-0",c),children:n.status}),s.jsx("span",{className:"text-[11px] text-neutral-900 truncate",children:u0(n.path)}),f&&s.jsx("span",{className:"text-[10px] text-neutral-400 truncate ml-auto shrink-0",children:f})]},n.path)})})},g0=({workingDir:e})=>{const{t}=ne(),{data:r,isLoading:a,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=Ro({queryKey:le.git.log(e||""),queryFn:({pageParam:S=0})=>me.get("/git/log",{params:{workingDir:e||"",limit:String(Gr),skip:String(S)}}),initialPageParam:0,getNextPageParam:(S,k)=>S.commits.length<Gr?void 0:k.length*Gr,enabled:!!e}),n=r?.pages.flatMap(S=>S.commits)||[],[c,f]=C.useState(null),[l,g]=C.useState(null),[b,y]=C.useState(280),[_,o]=C.useState(!1),h=C.useCallback(S=>{S.preventDefault(),o(!0);const k=S.clientX,E=b,w=R=>{const L=Math.min(480,Math.max(180,E+(R.clientX-k)));y(L)},j=()=>{o(!1),document.removeEventListener("mousemove",w),document.removeEventListener("mouseup",j)};document.addEventListener("mousemove",w),document.addEventListener("mouseup",j)},[b]),d=S=>{c===S?(f(null),g(null)):(f(S),g(null))},u=C.useRef(null);if(!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-500 text-sm bg-white h-full",children:t("No workspace selected.")});if(a)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-500 bg-white h-full",children:[s.jsx(Ke,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading history...")})]});if(p)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm bg-white h-full",children:t("Failed to load history.")});if(n.length===0)return s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center py-12 text-neutral-400 bg-white h-full",children:[s.jsx(cs,{size:28,className:"mb-2"}),s.jsx("span",{className:"text-xs",children:t("No commit history")})]});const x=n.find(S=>S.hash===c);return s.jsxs("div",{className:"flex h-full bg-white",style:_?{userSelect:"none",cursor:"col-resize"}:void 0,children:[s.jsxs("div",{className:"border-r border-neutral-200 flex flex-col shrink-0",style:{width:b},children:[s.jsx("div",{className:"px-3 py-2.5 border-b border-neutral-100 shrink-0",children:s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(cs,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-semibold text-neutral-900",children:t("History")}),s.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:n.length})]})}),s.jsxs("div",{ref:u,className:"flex-1 overflow-auto scrollbar-app-thin p-1.5",children:[n.map(S=>{const k=c===S.hash;return s.jsxs("div",{children:[s.jsxs("button",{type:"button",onClick:()=>d(S.hash),className:se("flex items-start gap-2 px-2 py-1.5 rounded cursor-pointer w-full text-left group",k?"bg-blue-50":"hover:bg-neutral-50"),children:[s.jsx("div",{className:"flex flex-col items-center shrink-0 pt-1",children:s.jsx("div",{className:se("w-2 h-2 rounded-full shrink-0 transition-colors",k?"bg-blue-500":"bg-neutral-300 group-hover:bg-neutral-500")})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-1.5",children:[s.jsx("span",{className:"text-[11px] font-mono text-blue-600 shrink-0",children:S.shortHash}),s.jsx("span",{className:"text-xs text-neutral-900 truncate flex-1",children:S.message}),s.jsx(Tt,{size:12,className:se("shrink-0 text-neutral-400 transition-transform",k&&"rotate-90")})]}),s.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5",children:[s.jsx("span",{className:"text-[10px] text-neutral-500 truncate",children:S.author}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:d0(S.timestamp)})]})]})]}),k&&s.jsxs(s.Fragment,{children:[S.body&&s.jsx("div",{className:"pl-7 pr-2 py-1.5 text-[11px] text-neutral-600 whitespace-pre-wrap leading-4 border-l-2 border-blue-100 ml-3",children:S.body}),s.jsx(p0,{workingDir:e,hash:S.hash,selectedPath:l,onSelectFile:g})]})]},S.hash)}),v&&s.jsx("button",{type:"button",onClick:()=>m(),disabled:i,className:"w-full py-2 text-xs text-neutral-500 hover:text-neutral-700 hover:bg-neutral-50 rounded transition-colors flex items-center justify-center gap-1.5",children:i?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{size:12,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]})]}),s.jsx("div",{onMouseDown:h,className:se("w-1 shrink-0 cursor-col-resize transition-colors",_?"bg-blue-400":"bg-transparent hover:bg-blue-300")}),s.jsx("div",{className:"flex-1 flex flex-col min-w-0",children:l&&c?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"px-3 py-2 border-b border-neutral-100 flex items-center gap-2 shrink-0",children:[s.jsx(ks,{size:14,className:"text-neutral-500"}),s.jsx("span",{className:"text-xs font-medium text-neutral-700 truncate",children:l}),s.jsxs("span",{className:"text-[10px] text-neutral-400",children:["(",x?.shortHash,")"]})]}),s.jsx(m0,{workingDir:e,hash:c,filePath:l})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:s.jsxs("div",{className:"flex flex-col items-center gap-2",children:[s.jsx(ks,{size:28}),s.jsx("span",{className:"text-xs",children:t(c?"Select a file to view diff":"Select a commit to view changes")})]})})})]})};function v0(e){return vt({queryKey:le.previews.status(e??""),queryFn:async()=>{const t=await me.get(`/previews/${e}/status`);return{...t,viewUrl:t.viewUrl?t.viewUrl:null}},enabled:!!e,refetchOnWindowFocus:!1})}function _0(e){const t=Qe();return ut({mutationFn:r=>me.put(`/previews/${e}/config`,{target:r}),onSuccess:()=>{e&&(t.invalidateQueries({queryKey:le.previews.status(e)}),t.invalidateQueries({queryKey:le.workspaces.all}))}})}function x0(){return"3000, localhost:3000, http://127.0.0.1:5173"}function b0({workspaceId:e,readOnly:t}){const{t:r}=ne(),{data:a,isLoading:p,refetch:m,isFetching:v}=v0(e),i=_0(e),[n,c]=C.useState(""),[f,l]=C.useState(0);C.useEffect(()=>{c(a?.target??"")},[a?.target]);const g=C.useMemo(()=>!a?.ready||!a.viewUrl?null:`${a.viewUrl}?_=${f}`,[f,a?.ready,a?.viewUrl]),b=async()=>{if(e)try{await i.mutateAsync(n.trim()||null),l(_=>_+1),ns.success(r("Preview target saved"))}catch(_){const o=_ instanceof Error?_.message:r("Failed to save preview target");ns.error(o)}},y=async()=>{await m(),l(_=>_+1)};return e?s.jsxs("div",{className:"h-full flex flex-col bg-white",children:[s.jsxs("div",{className:"shrink-0 border-b border-neutral-200 bg-neutral-50 px-3 py-2",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{value:n,onChange:_=>c(_.target.value),onKeyDown:_=>{_.key==="Enter"&&!_.nativeEvent.isComposing&&(_.preventDefault(),b())},disabled:t||i.isPending,placeholder:x0(),className:"h-8 min-w-0 flex-1 rounded-md border border-neutral-200 bg-white px-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"}),s.jsxs(De,{type:"button",size:"sm",variant:"outline",onClick:b,disabled:t||i.isPending,title:r("Save preview target"),children:[i.isPending?s.jsx(Ke,{className:"animate-spin"}):s.jsx(Qc,{}),s.jsx("span",{className:"hidden xl:inline",children:r("Save")})]}),s.jsxs(De,{type:"button",size:"sm",variant:"outline",onClick:y,disabled:v,title:r("Refresh preview"),children:[v?s.jsx(Ke,{className:"animate-spin"}):s.jsx(Es,{}),s.jsx("span",{className:"hidden xl:inline",children:r("Refresh")})]}),a?.ready&&a.viewUrl&&s.jsx(De,{type:"button",size:"sm",variant:"outline",asChild:!0,title:r("Open preview in new tab"),children:s.jsx("a",{href:a.viewUrl,target:"_blank",rel:"noopener noreferrer",children:s.jsx(Ci,{})})})]}),s.jsxs("div",{className:"mt-1 flex min-h-4 items-center justify-between gap-2 text-[11px] leading-4",children:[s.jsx("span",{className:"truncate text-neutral-500",children:p?r("Checking preview target..."):a?.ready?`${r("Proxying")} ${a.target}`:a?.configured?`${r("Preview target is not reachable")}${a.error?`: ${a.error}`:""}`:r("Enter a local preview URL on the Agent Tower machine.")}),s.jsx("span",{className:"shrink-0 text-neutral-400",children:r("Loopback only")})]})]}),s.jsx("div",{className:"relative flex-1 min-h-0 bg-white",children:g?s.jsx("iframe",{src:g,title:r("Preview"),className:"absolute inset-0 h-full w-full border-0 bg-white",sandbox:"allow-downloads allow-forms allow-modals allow-pointer-lock allow-popups allow-same-origin allow-scripts"},g):s.jsx("div",{className:"absolute inset-0 flex items-center justify-center px-4 text-center text-sm text-neutral-500",children:a?.configured?r("Start the preview server, then refresh."):r("Configure a local preview target to display it here.")})})]}):s.jsx("div",{className:"h-full flex items-center justify-center bg-white text-sm text-neutral-500",children:r("No active workspace.")})}const y0=[{key:"changes",label:"Changes",icon:s.jsx(ls,{size:14})},{key:"history",label:"History",icon:s.jsx(cs,{size:14})},{key:"editor",label:"Editor",icon:s.jsx(pr,{size:14})},{key:"terminal",label:"Terminal",icon:s.jsx(er,{size:14})},{key:"preview",label:"Preview",icon:s.jsx(xi,{size:14})}],S0=[{key:"history",label:"History",icon:s.jsx(cs,{size:14})},{key:"editor",label:"Editor",icon:s.jsx(pr,{size:14})},{key:"terminal",label:"Terminal",icon:s.jsx(er,{size:14})},{key:"preview",label:"Preview",icon:s.jsx(xi,{size:14})}],w0=({active:e,onClick:t,icon:r,label:a})=>s.jsxs("button",{onClick:t,className:se("flex items-center gap-2 px-4 py-2 text-xs font-medium transition-all rounded-t-md border-t border-x -mb-px",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,s.jsx("span",{children:a})]}),Ia=ie.memo(function({className:t,sessionId:r,workspaceId:a,workingDir:p,projectId:m,hideChanges:v,readOnly:i,repoDeleted:n,teamRun:c,teamStatus:f}){const{t:l}=ne(),g=C.useMemo(()=>{const x=v?S0:y0,S=i?x.filter(k=>k.key!=="terminal"):x;return c?[{key:"team-status",label:"Team Status",icon:s.jsx(fr,{size:14})},...S]:S},[v,i,c]),[b,y]=C.useState(v?"history":"changes"),{data:_}=Zl(m??""),o=C.useMemo(()=>{if(!_?.quickCommands)return[];try{return JSON.parse(_.quickCommands)}catch{return[]}},[_?.quickCommands]),[h,d]=C.useState([]),u=C.useRef(void 0);return C.useEffect(()=>{p&&p!==u.current&&(u.current=p,d(x=>x.includes(p)?x:[...x,p]))},[p]),C.useEffect(()=>{i&&b==="terminal"&&y(v?"history":"changes")},[b,v,i]),C.useEffect(()=>{c||b!=="team-status"||y(v?"history":"changes")},[b,v,c]),s.jsxs("div",{className:se("flex flex-col h-full bg-white",t),children:[i&&s.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:l(n?"项目已删除且本地仓库文件已清理。这里只保留历史视图。":"项目已删除。Workspace 以只读模式展示历史内容。")}),s.jsx("div",{className:"flex items-center px-2 pt-2 border-b border-neutral-200 bg-neutral-100/80 shrink-0 gap-1 select-none",children:g.map(x=>s.jsx(w0,{active:b===x.key,onClick:()=>y(x.key),icon:x.icon,label:l(x.label)},x.key))}),s.jsxs("div",{className:"flex-1 overflow-hidden relative",children:[b==="team-status"&&c&&f,b==="editor"&&s.jsx(s0,{workingDir:p,readOnly:i}),h.map(x=>s.jsx("div",{className:"h-full absolute inset-0",style:{display:b==="terminal"&&p===x?"block":"none"},children:s.jsx(mf,{cwd:x,quickCommands:o})},x)),b==="preview"&&s.jsx(b0,{workspaceId:a,readOnly:i}),b==="changes"&&s.jsx(c0,{workingDir:p}),b==="history"&&s.jsx(g0,{workingDir:p})]})]})});function C0(e){switch(e){case kt.ACTIVE:return"border-emerald-200 bg-emerald-50 text-emerald-700";case kt.MERGED:return"border-blue-200 bg-blue-50 text-blue-700";case kt.HIBERNATED:return"border-amber-200 bg-amber-50 text-amber-700";case kt.ABANDONED:return"border-neutral-200 bg-neutral-50 text-neutral-500"}}function eo(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 k0(e){return e.length<=34?e:`...${e.slice(-31)}`}function Ba({workspaces:e,teamRun:t,selectedWorkspaceId:r,onSelectWorkspace:a,disabled:p,className:m,buttonClassName:v}){const{t:i}=ne(),[n,c]=C.useState(!1),f=C.useRef(null),l=C.useMemo(()=>na(e,t),[e,t]),g=l.find(b=>b.workspace.id===r)??l[0];return C.useEffect(()=>{if(!n)return;const b=y=>{f.current&&!f.current.contains(y.target)&&c(!1)};return document.addEventListener("mousedown",b),()=>document.removeEventListener("mousedown",b)},[n]),l.length===0?s.jsxs("div",{className:se("inline-flex h-8 items-center gap-2 rounded-md border border-neutral-200 bg-neutral-50 px-2.5 text-xs text-neutral-400",m),children:[s.jsx(ds,{size:14}),s.jsx("span",{children:i("No workspace")})]}):s.jsxs("div",{ref:f,className:se("relative",m),children:[s.jsxs("button",{type:"button",onClick:()=>c(b=>!b),disabled:p,className:se("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",v),title:i("Workspace"),children:[s.jsx(ds,{size:14,className:"shrink-0 text-neutral-500"}),s.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",eo(g.roleLabel)),children:i(g.roleLabel)}),s.jsx("span",{className:"min-w-0 truncate font-medium text-neutral-900",children:i(g.displayName)}),s.jsx("span",{className:"min-w-0 truncate font-mono text-[11px] text-neutral-500",children:k0(g.workspace.branchName)}),s.jsx(_t,{size:13,className:se("shrink-0 text-neutral-400 transition-transform",n&&"rotate-180")})]}),n&&s.jsx("div",{className:"absolute right-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:l.map(b=>{const y=b.workspace.id===g.workspace.id;return s.jsxs("button",{type:"button",onClick:()=>{a(b.workspace.id),c(!1)},className:se("flex w-full items-start gap-2 px-3 py-2 text-left transition-colors hover:bg-neutral-50",y&&"bg-neutral-50"),children:[s.jsx("div",{className:"mt-0.5 flex h-6 w-6 shrink-0 items-center justify-center rounded-md border border-neutral-200 bg-white text-neutral-500",children:y?s.jsx(At,{size:13}):s.jsx(ji,{size:13})}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-1.5",children:[s.jsx("span",{className:"truncate text-xs font-medium text-neutral-900",children:i(b.displayName)}),s.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",eo(b.roleLabel)),children:i(b.roleLabel)}),s.jsx("span",{className:se("shrink-0 rounded-full border px-1.5 py-0.5 text-[10px] font-medium",C0(b.workspace.status)),children:b.workspace.status})]}),s.jsx("div",{className:"mt-1 truncate font-mono text-[11px] text-neutral-500",children:b.workspace.branchName}),s.jsxs("div",{className:"mt-0.5 flex flex-wrap items-center gap-x-2 gap-y-0.5 text-[10px] text-neutral-400",children:[b.ownerName&&s.jsxs("span",{children:[i("Owner"),": ",b.ownerName]}),b.parentBranchName&&s.jsxs("span",{children:[i("Parent"),": ",b.parentBranchName]}),s.jsx("span",{children:b.workspace.id.slice(0,8)})]})]})]},b.workspace.id)})})]})}function Fa(e){return vt({queryKey:le.workspaces.list(e),queryFn:()=>me.get(`/tasks/${e}/workspaces`),enabled:!!e})}function za(e){const t=Qe();return ut({mutationFn:r=>me.post(`/tasks/${e}/workspaces`,r),onSuccess:()=>{t.invalidateQueries({queryKey:le.workspaces.list(e)}),t.invalidateQueries({queryKey:le.tasks.all})}})}function E0(){const e=Qe();return ut({mutationFn:({id:t,commitMessage:r})=>me.post(`/workspaces/${t}/merge`,{commitMessage:r}),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all})}})}function j0(){const e=Qe();return ut({mutationFn:t=>me.post(`/workspaces/${t}/reactivate`),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all})}})}function Wi(){return ut({mutationFn:({workspaceId:e,editorType:t})=>me.post(`/workspaces/${e}/open-editor`,{editorType:t})})}function Ha(e){return vt({queryKey:le.workspaces.gitStatus(e),queryFn:()=>me.get(`/workspaces/${e}/git-status`),enabled:!!e})}function N0(){const e=Qe();return ut({mutationFn:t=>me.post(`/workspaces/${t}/rebase`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(r)})},onError:(t,r)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(r)})}})}function A0(){const e=Qe();return ut({mutationFn:t=>me.post(`/workspaces/${t}/abort-operation`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:le.workspaces.gitStatus(r)})}})}const to=1500,R0=3e3;function T0(e){const[t,r]=C.useState(null),a=C.useRef(0),p=C.useRef(null),m=C.useRef(null);return C.useEffect(()=>{if(!e)return;const v=()=>{m.current&&(clearTimeout(m.current),m.current=null)},i=Ot.connect(),n=f=>{r(f),m.current=setTimeout(()=>r(null),R0)},c=f=>{if(f.taskId!==e)return;const l={status:f.status,currentCommand:f.currentCommand,currentIndex:f.currentIndex,totalCommands:f.totalCommands,error:f.error};if(f.status==="running"){v(),p.current=null,a.current===0&&(a.current=Date.now()),r(l);return}const g=a.current>0?Date.now()-a.current:0,b=to-g;a.current===0?(a.current=Date.now(),r({status:"running",totalCommands:f.totalCommands,currentIndex:f.totalCommands}),p.current=l,m.current=setTimeout(()=>n(l),to)):b>0?(p.current=l,v(),m.current=setTimeout(()=>n(l),b)):n(l)};return i.on(ct.WORKSPACE_SETUP_PROGRESS,c),()=>{i.off(ct.WORKSPACE_SETUP_PROGRESS,c),v(),a.current=0,p.current=null}},[e]),t}function $i(){const e=Qe();return ut({mutationFn:t=>me.post(`/sessions/${t}/start`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:le.sessions.detail(r)}),e.invalidateQueries({queryKey:le.tasks.all})}})}function Wa(){const e=Qe();return ut({mutationFn:t=>me.post(`/sessions/${t}/stop`),onSuccess:(t,r)=>{e.invalidateQueries({queryKey:le.sessions.detail(r)})}})}function Ui(){const e=Qe();return ut({mutationFn:({id:t,message:r,providerId:a})=>me.post(`/sessions/${t}/message`,{message:r,providerId:a}),onSuccess:()=>{e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.all})}})}function M0(e,t){const r={};return vt({queryKey:le.tasks.list(e,t),queryFn:()=>me.get(`/projects/${e}/tasks`,{params:r}),enabled:!!e})}function D0(e){const t=Qe();return ut({mutationFn:r=>me.post(`/projects/${e}/tasks`,r),onSuccess:()=>{t.invalidateQueries({queryKey:le.tasks.list(e)}),t.invalidateQueries({queryKey:le.tasks.stats(e)})}})}function L0(){const e=Qe();return ut({mutationFn:({id:t,status:r})=>me.patch(`/tasks/${t}/status`,{status:r}),onSuccess:t=>{e.invalidateQueries({queryKey:le.tasks.all}),e.invalidateQueries({queryKey:le.tasks.detail(t.id)})}})}function P0(){const e=Qe();return ut({mutationFn:t=>me.delete(`/tasks/${t}`),onSuccess:()=>{e.invalidateQueries({queryKey:le.tasks.all})}})}function O0(){const e=Qe();return ut({mutationFn:t=>me.post(`/tasks/${t}/retry`,{}),onSuccess:t=>{e.invalidateQueries({queryKey:le.tasks.all}),e.invalidateQueries({queryKey:le.workspaces.all}),e.invalidateQueries({queryKey:le.tasks.detail(t.id)})}})}function $a(e,t){return C.useMemo(()=>{for(let r=e.length-1;r>=0;r--){const a=e[r];if(a.tokenUsage&&typeof a.tokenUsage.totalTokens=="number"&&a.tokenUsage.totalTokens>0)return{totalTokens:a.tokenUsage.totalTokens,modelContextWindow:a.tokenUsage.modelContextWindow}}return t??null},[e,t])}function Ua({isOpen:e,onClose:t,taskId:r,taskTitle:a,taskDescription:p}){const{t:m}=ne(),[v,i]=C.useState(""),[n,c]=C.useState(""),[f,l]=C.useState("idle"),[g,b]=C.useState(null),y=Qe(),_=za(r),o=$i(),{data:h,isLoading:d}=Ds();C.useEffect(()=>{if(!e||!h)return;const k=h.find(E=>E.availability.type!=="NOT_FOUND");k&&i(k.provider.id)},[e,h]),C.useEffect(()=>{if(e){const k=[a];p&&k.push(p),c(k.join(`
72
+
73
+ `)),l("idle"),b(null)}},[e,a,p]);const u=f!=="idle",x=async()=>{if(!(!v||!n.trim())){b(null);try{l("creating-workspace");const k=await _.mutateAsync({});l("creating-session");const E=await me.post(`/workspaces/${k.id}/sessions`,{providerId:v,prompt:n.trim()});l("starting-session"),await o.mutateAsync(E.id),await y.invalidateQueries({queryKey:le.workspaces.list(r)}),l("idle"),t()}catch(k){l("idle"),b(k instanceof Error?k.message:m("启动失败,请重试"))}}},S={idle:m("启动"),"creating-workspace":m("创建工作空间..."),"creating-session":m("创建会话..."),"starting-session":m("启动 Agent...")};return s.jsx(Ms,{isOpen:e,onClose:u?()=>{}:t,title:m("启动 Agent"),action:s.jsxs(s.Fragment,{children:[s.jsx(De,{variant:"outline",onClick:t,disabled:u,children:m("取消")}),s.jsx(De,{onClick:x,disabled:u||!v||!n.trim(),children:S[f]})]}),children:s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:m("选择 Provider")}),s.jsxs("div",{className:"flex gap-2 flex-wrap",children:[d&&s.jsx("span",{className:"text-sm text-neutral-400",children:m("加载中...")}),h?.map(({provider:k,availability:E})=>{const w=E.type!=="NOT_FOUND";return s.jsxs(De,{variant:v===k.id?"default":"outline",size:"sm",disabled:!w||u,onClick:()=>i(k.id),children:[k.name,!w&&m(" (不可用)")]},k.id)})]})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-2",children:m("任务描述")}),s.jsx("textarea",{value:n,onChange:k=>c(k.target.value),rows:5,disabled:u,placeholder:m("描述你想让 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"})]}),g&&s.jsx("div",{className:"text-sm text-red-600 bg-red-50 border border-red-100 rounded-lg px-3 py-2",children:g})]})})}function I0(e,t){return e instanceof Error?e.message:t}function B0(e){return Object.values(e).filter(Boolean).length}function so(e,t,r,a){if(r.filter(v=>v===a).length<=1)return e;const m=r.slice(0,t+1).filter(v=>v===a).length;return`${e} #${m}`}function ro({title:e,error:t,isFetching:r,onRetry:a,disabled:p}){const{t:m}=ne();return s.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"font-medium",children:e}),s.jsx("div",{className:"mt-1 text-xs text-red-600",children:I0(t,m("请稍后重试。"))})]}),s.jsx(De,{type:"button",size:"sm",variant:"outline",onClick:a,disabled:p||r,children:r?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{size:14,className:"animate-spin"}),m("加载中...")]}):m("重试")})]})})}function qa({mode:e,setMode:t,selectedTemplateId:r,setSelectedTemplateId:a,selectedMemberPresetIds:p,setSelectedMemberPresetIds:m,disabled:v=!1}){const{t:i}=ne(),{data:n}=Ds(),{data:c,error:f,isError:l,isFetching:g,isLoading:b,refetch:y}=ql(),{data:_,error:o,isError:h,isFetching:d,isLoading:u,refetch:x}=Kl(),S=C.useMemo(()=>new Map((n??[]).map(({provider:M,availability:O})=>[M.id,M.name+(O.type==="NOT_FOUND"?i(" (不可用)"):"")])),[n,i]),k=C.useMemo(()=>new Map((c??[]).map(M=>[M.id,M])),[c]),E=C.useMemo(()=>new Map((_??[]).map(M=>[M.id,M])),[_]),w=r?E.get(r)??null:null,j=C.useMemo(()=>p.map(M=>k.get(M)).filter(M=>!!M),[k,p]);C.useEffect(()=>{c!==void 0&&m(M=>{const O=M.filter(F=>k.has(F));return O.length===M.length&&O.every((F,z)=>F===M[z])?M:O})},[c,k,m]),C.useEffect(()=>{_!==void 0&&a(M=>!M||E.has(M)?M:null)},[a,E,_]);const R=M=>{v||a(O=>O===M?null:M)},L=M=>{v||m(O=>[...O,M])},D=M=>{v||m(O=>O.filter((F,z)=>z!==M))},N=(M,O)=>{v||m(F=>{const z=M+O;if(z<0||z>=F.length)return F;const A=[...F],[P]=A.splice(M,1);return A.splice(z,0,P),A})};return s.jsxs("div",{className:"space-y-5",children:[s.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[s.jsxs("div",{children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900",children:i("TeamRun 模式")}),s.jsx("div",{className:"text-xs text-neutral-500",children:i("默认使用自动模式,团队消息会直接排队执行。")})]}),s.jsxs("div",{className:"inline-flex rounded-md border border-neutral-200 bg-neutral-50 p-1",children:[s.jsx("button",{type:"button",onClick:()=>!v&&t("CONFIRM"),disabled:v,className:se("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",e==="CONFIRM"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:i("确认模式")}),s.jsx("button",{type:"button",onClick:()=>!v&&t("AUTO"),disabled:v,className:se("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",e==="AUTO"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:i("自动模式")})]})]}),s.jsx("div",{className:"pr-1",children:s.jsxs("div",{className:"grid gap-5 lg:grid-cols-[minmax(0,1.15fr)_minmax(320px,0.85fr)]",children:[s.jsxs("div",{className:"space-y-5",children:[s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("团队模板")}),s.jsx("p",{className:"text-xs text-neutral-400",children:i("模板成员会先加入,随后按顺序追加所选成员。")})]}),h?s.jsx(ro,{title:i("团队模板加载失败"),error:o,isFetching:d,onRetry:()=>{x()},disabled:v}):u?s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-400",children:[s.jsx(Ke,{size:14,className:"animate-spin"}),i("加载中...")]}):(_??[]).length===0?s.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:[s.jsx("div",{children:i("当前没有团队模板")}),s.jsx(De,{asChild:!0,size:"sm",variant:"outline",className:"mt-3",children:s.jsx(Gs,{to:"/settings/team",children:i("前往 /settings/team 创建")})})]}):s.jsx("div",{className:"space-y-2",children:(_??[]).map(M=>{const O=M.id===r,F=M.members?.length??0,z=M.members?.map(P=>P.memberPresetId)??[],A=M.members?.slice(0,3).map((P,I)=>so(P.memberPreset?.name??P.memberPresetId,I,z,P.memberPresetId)).join(" · ");return s.jsx("button",{type:"button",onClick:()=>R(M.id),disabled:v,className:se("w-full rounded-lg border px-3 py-2 text-left transition-colors disabled:cursor-not-allowed disabled:opacity-60",O?"border-neutral-900 bg-neutral-50":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:s.jsxs("div",{className:"flex items-start justify-between gap-3",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:M.name}),s.jsx("div",{className:"mt-1 truncate text-xs text-neutral-500",children:i("{count} 个成员",{count:F})}),A&&s.jsx("div",{className:"mt-2 truncate text-[11px] text-neutral-400",children:A})]}),O&&s.jsx(At,{size:14,className:"mt-0.5 shrink-0 text-neutral-900"})]})},M.id)})})]}),s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("成员预设")}),s.jsx("p",{className:"text-xs text-neutral-400",children:i("选择顺序即保存顺序。")})]}),l?s.jsx(ro,{title:i("成员预设加载失败"),error:f,isFetching:g,onRetry:()=>{y()},disabled:v}):b?s.jsxs("div",{className:"flex items-center gap-2 rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-3 text-sm text-neutral-400",children:[s.jsx(Ke,{size:14,className:"animate-spin"}),i("加载中...")]}):(c??[]).length===0?s.jsxs("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:[s.jsx("div",{children:i("当前没有成员预设")}),s.jsx(De,{asChild:!0,size:"sm",variant:"outline",className:"mt-3",children:s.jsx(Gs,{to:"/settings/team",children:i("前往 /settings/team 创建")})})]}):s.jsx("div",{className:"space-y-2",children:(c??[]).map(M=>{const O=p.filter(A=>A===M.id).length,F=S.get(M.providerId)??M.providerId,z=B0(M.capabilities);return s.jsxs("button",{type:"button",onClick:()=>L(M.id),disabled:v,className:se("flex w-full items-start gap-3 rounded-lg border px-3 py-2 text-left transition-colors",v&&"cursor-not-allowed opacity-60",O>0?"border-neutral-900 bg-neutral-50":"border-neutral-200 bg-white hover:border-neutral-300 hover:bg-neutral-50"),children:[s.jsx(Xt,{name:M.name,avatar:M.avatar,className:"mt-0.5 h-8 w-8 text-[11px]"}),s.jsxs("div",{className:"min-w-0 flex-1",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:M.name}),s.jsx("div",{className:"truncate text-xs text-neutral-500",children:F})]}),s.jsxs("div",{className:"flex shrink-0 items-center gap-2",children:[s.jsxs("span",{className:"text-[11px] text-neutral-400",children:[z,"/10"]}),O>0&&s.jsxs("span",{className:"rounded-full bg-neutral-900 px-2 py-0.5 text-[11px] font-medium text-white",children:["x",O]}),s.jsx(as,{size:15,className:"text-neutral-500"})]})]},M.id)})})]})]}),s.jsxs("div",{className:"space-y-5",children:[s.jsxs("section",{className:"space-y-3",children:[s.jsxs("div",{children:[s.jsx("h3",{className:"text-sm font-semibold text-neutral-900",children:i("已选成员")}),s.jsx("p",{className:"text-xs text-neutral-400",children:i("上移下移后即为保存顺序。")})]}),j.length===0?s.jsx("div",{className:"rounded-lg border border-dashed border-neutral-200 bg-white px-4 py-4 text-sm text-neutral-400",children:i("尚未选择成员预设")}):s.jsx("div",{className:"space-y-2",children:j.map((M,O)=>{const F=S.get(M.providerId)??M.providerId,z=so(M.name,O,p,M.id);return s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border border-neutral-200 bg-white px-3 py-2",children:[s.jsxs("div",{className:"flex min-w-0 items-center gap-2",children:[s.jsx(Xt,{name:M.name,avatar:M.avatar,className:"h-8 w-8 text-[11px]"}),s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"truncate text-sm font-medium text-neutral-900",children:z}),s.jsx("div",{className:"truncate text-xs text-neutral-500",children:F})]})]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(De,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>N(O,-1),disabled:v||O===0,title:i("上移"),children:s.jsx(yi,{size:14})}),s.jsx(De,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>N(O,1),disabled:v||O===j.length-1,title:i("下移"),children:s.jsx(_t,{size:14})}),s.jsx(De,{type:"button",variant:"ghost",size:"icon-sm",onClick:()=>D(O),disabled:v,title:i("移除"),children:s.jsx(bi,{size:14})})]})]},`${M.id}-${O}`)})})]}),s.jsxs("section",{className:"rounded-lg border border-neutral-200 bg-neutral-50 px-4 py-4",children:[s.jsx("div",{className:"text-xs font-medium text-neutral-700",children:i("模板成员会先加入,随后按顺序追加所选成员。")}),s.jsx("div",{className:"mt-2 text-xs text-neutral-500",children:w?s.jsxs(s.Fragment,{children:[s.jsx("span",{className:"font-medium text-neutral-700",children:w.name}),s.jsx("span",{className:"mx-1",children:"·"}),s.jsx("span",{children:i("{count} 个成员",{count:w.members?.length??0})})]}):s.jsx("span",{children:i("请选择至少一个团队模板或成员预设。")})})]})]})]})})]})}function F0({isOpen:e,onClose:t,taskId:r}){const{t:a}=ne(),[p,m]=C.useState("AUTO"),[v,i]=C.useState(null),[n,c]=C.useState([]),[f,l]=C.useState(null),g=wo();C.useEffect(()=>{e&&(m("AUTO"),i(null),c([]),l(null))},[e]);const b=g.isPending,y=!!v||n.length>0,_=async()=>{if(!b){if(!v&&n.length===0){l(a("请选择至少一个团队模板或成员预设。"));return}l(null);try{await g.mutateAsync({taskId:r,mode:p,...v?{teamTemplateId:v}:{},...n.length>0?{memberPresetIds:n}:{}}),t()}catch(h){if(h instanceof Co&&h.status===409){l(a("该任务已经存在 TeamRun。请刷新后再试。"));return}l(h instanceof Error?h.message:a("创建 TeamRun 失败"))}}},o=b||!y;return s.jsxs(Ms,{isOpen:e,onClose:b?()=>{}:t,title:a("创建 TeamRun"),className:"max-w-5xl",action:s.jsxs(s.Fragment,{children:[s.jsx(De,{type:"button",variant:"outline",onClick:t,disabled:b,children:a("取消")}),s.jsx(De,{type:"button",onClick:_,disabled:o,children:a(b?"处理中...":"创建 TeamRun")})]}),children:[s.jsx(qa,{mode:p,setMode:m,selectedTemplateId:v,setSelectedTemplateId:i,selectedMemberPresetIds:n,setSelectedMemberPresetIds:c,disabled:b}),f&&s.jsx("div",{role:"alert",className:"rounded-lg border border-red-200 bg-red-50 px-4 py-3 text-sm text-red-700",children:f})]})}function Ka({providers:e,currentProviderId:t,agentType:r,onSelect:a}){const{t:p}=ne(),[m,v]=C.useState(!1),i=C.useRef(null),n=e.filter(f=>String(f.provider.agentType)===r),c=e.find(f=>f.provider.id===t);return C.useEffect(()=>{function f(l){i.current&&!i.current.contains(l.target)&&v(!1)}if(m)return document.addEventListener("mousedown",f),()=>document.removeEventListener("mousedown",f)},[m]),n.length<=1?s.jsxs("div",{className:"flex items-center gap-1 text-xs text-neutral-400 px-2 py-1.5 select-none cursor-default",children:[s.jsx(an,{size:14,className:"shrink-0"}),s.jsx("span",{children:c?.provider.name?un(c.provider.name,12):r})]}):s.jsxs("div",{className:"relative",ref:i,children:[s.jsxs("button",{onClick:()=>v(!m),className:"flex items-center gap-1 text-xs px-2 py-1.5 rounded-lg transition-colors cursor-pointer hover:bg-neutral-100 text-neutral-400 hover:text-neutral-600",title:`Provider: ${c?.provider.name??r} (click to change)`,children:[s.jsx(an,{size:14,className:"shrink-0"}),s.jsx("span",{children:c?.provider.name?un(c.provider.name,12):r}),s.jsx(_t,{size:12,className:`shrink-0 transition-transform ${m?"rotate-180":""}`})]}),m&&s.jsxs("div",{className:"absolute bottom-full right-0 mb-1 bg-white rounded-lg border border-neutral-200 shadow-lg py-1 min-w-[160px] z-50",children:[s.jsx("div",{className:"px-2 py-1 text-xs text-neutral-400 border-b border-neutral-100",children:p("切换渠道")}),n.map(f=>s.jsxs("button",{onClick:()=>{a(f.provider.id),v(!1)},className:`w-full flex items-center justify-between px-3 py-2 text-sm text-left hover:bg-neutral-50 transition-colors ${f.provider.id===t?"bg-blue-50 text-blue-600":"text-neutral-700"}`,children:[s.jsxs("span",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"truncate max-w-[120px]",children:f.provider.name}),f.provider.isDefault&&s.jsx("span",{className:"text-xs text-neutral-400",children:p("(默认)")})]}),f.provider.id===t&&s.jsx(At,{size:14,className:"shrink-0"})]},f.provider.id))]})]})}function z0({commands:e,selectedIndex:t,query:r,hasCatalog:a,title:p="Slash Commands",queryPrefix:m="/",emptyCatalogMessage:v="No slash commands catalog for this agent yet.",emptyQueryMessage:i,insertionHint:n="Enter / Tab to insert",compact:c=!1,onSelect:f}){const l=c?"px-1.5 pb-1.5":"px-2 pb-2",g=c?"px-2 py-1.5":"px-2.5 py-2",b=c?"max-h-36":"max-h-48";return s.jsxs("div",{className:c?"pt-1.5":"pt-2",children:[s.jsxs("div",{className:`mb-1 flex items-center justify-between ${c?"px-2 pt-0.5":"px-3 pt-1"}`,children:[s.jsx("span",{className:"text-[10px] font-medium uppercase tracking-[0.14em] text-neutral-400",children:p}),s.jsx("span",{className:"text-[10px] text-neutral-400",children:n})]}),e.length===0?s.jsx("div",{className:`${c?"px-2 pb-2 pt-1.5 text-[11px]":"px-3 pb-3 pt-2 text-xs"} text-neutral-400`,children:a?i??`No matches for ${m}${r}`:v}):s.jsx("div",{className:`${l} ${b} overflow-y-auto`,children:e.map((y,_)=>s.jsxs("button",{type:"button",onMouseDown:o=>o.preventDefault(),onClick:()=>f(y),className:`w-full rounded-lg border text-left transition-colors ${_===t?"border-neutral-300 bg-neutral-50":"border-transparent hover:border-neutral-200 hover:bg-neutral-50/80"} ${g}`,children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("div",{className:"font-mono text-[13px] text-neutral-900",children:y.command}),y.kind&&y.kind!=="builtin"?s.jsx("span",{className:"rounded-full border border-neutral-200 px-1.5 py-0.5 text-[9px] uppercase tracking-[0.12em] text-neutral-500",children:y.scope?`${y.scope} ${y.kind}`:y.kind}):null]}),s.jsx("div",{className:`${c?"mt-0.5 text-[11px]":"mt-1 text-xs"} text-neutral-500`,children:y.description})]},y.command))})]})}const Lt=12,Vs=8;function dr({open:e,anchorRef:t,commands:r,selectedIndex:a,query:p,hasCatalog:m,title:v,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:c,insertionHint:f,compact:l=!1,onSelect:g}){const b=C.useRef(null),[y,_]=C.useState(null);return C.useLayoutEffect(()=>{if(!e){_(null);return}const o=t.current;if(!o)return;let h=0;const d=()=>{const S=t.current;if(!S)return;const k=S.getBoundingClientRect(),E=window.innerWidth,w=window.innerHeight,j=l?260:320,R=l?E-Lt*2:560,L=Math.min(Math.max(k.width,j),Math.max(j,R)),D=Math.min(Math.max(Lt,k.left),Math.max(Lt,E-Lt-L)),N=w-k.bottom-Vs-Lt,M=k.top-Vs-Lt,O=b.current?.offsetHeight??(l?220:280),F=l?240:320,z=N<180&&M>N,P=Math.max(120,Math.min(F,z?M:N)),I=z?Math.max(Lt,k.top-Vs-Math.min(O,P)):Math.min(w-Lt-Math.min(O,P),k.bottom+Vs);_({top:I,left:D,width:L,maxHeight:P})},u=()=>{cancelAnimationFrame(h),h=requestAnimationFrame(d)};u();const x=new ResizeObserver(u);return x.observe(o),b.current&&x.observe(b.current),window.addEventListener("resize",u),window.addEventListener("scroll",u,!0),window.visualViewport?.addEventListener("resize",u),window.visualViewport?.addEventListener("scroll",u),()=>{cancelAnimationFrame(h),x.disconnect(),window.removeEventListener("resize",u),window.removeEventListener("scroll",u,!0),window.visualViewport?.removeEventListener("resize",u),window.visualViewport?.removeEventListener("scroll",u)}},[t,r.length,l,e,p,a]),!e||!y||typeof document>"u"?null:Ut.createPortal(s.jsx("div",{className:"pointer-events-none fixed inset-0 z-[120]",children:s.jsx("div",{ref:b,className:"pointer-events-auto fixed overflow-hidden rounded-xl border border-neutral-200 bg-white shadow-lg shadow-neutral-200/70",style:{top:y.top,left:y.left,width:y.width,maxHeight:y.maxHeight},children:s.jsx(z0,{commands:r,selectedIndex:a,query:p,hasCatalog:m,title:v,queryPrefix:i,emptyCatalogMessage:n,emptyQueryMessage:c,insertionHint:f,compact:l,onSelect:g})})}),document.body)}function H0({workspaceId:e,gitStatus:t,onResolve:r}){const{t:a}=ne(),p=A0();if(t.operation==="idle"||t.conflictedFiles.length===0)return null;const m=t.operation==="rebase"?"Rebase":"Merge";return s.jsxs("div",{className:"mx-6 mt-3 px-4 py-3 rounded-lg border border-amber-200 bg-amber-50 flex items-center gap-3",children:[s.jsx(Si,{size:18,className:"text-amber-600 shrink-0"}),s.jsx("div",{className:"flex-1 min-w-0",children:s.jsx("p",{className:"text-sm font-medium text-amber-900",children:a("{opLabel} 冲突 — {count} 个文件",{opLabel:m,count:t.conflictedFiles.length})})}),s.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s.jsx(De,{variant:"outline",size:"sm",onClick:()=>p.mutate(e),disabled:p.isPending,children:a("中止操作")}),s.jsx(De,{size:"sm",onClick:r,children:a("解决冲突")})]})]})}function Xa(e){return e.length>0?e.map(t=>`- ${t}`).join(`
74
+ `):"- 未获取到冲突文件列表"}function Va(e){if(!e)return[];const t=[];return e.workspaceId&&t.push(`- Workspace: \`${e.workspaceId}\``),e.worktreePath&&t.push(`- Worktree: \`${e.worktreePath}\``),e.sourceWorkspaceId&&t.push(`- Source workspace: \`${e.sourceWorkspaceId}\``),e.targetWorkspaceId&&t.push(`- Target workspace: \`${e.targetWorkspaceId}\``),e.sourceWorktreePath&&t.push(`- Source worktree: \`${e.sourceWorktreePath}\``),e.targetWorktreePath&&t.push(`- Target worktree: \`${e.targetWorktreePath}\``),e.operation&&e.operation!=="idle"&&t.push(`- Git 状态: \`${e.operation}\``),e.mergeStrategy&&t.push(`- Merge strategy: \`${e.mergeStrategy}\``),e.mergeAborted&&t.push("- Merge state: conflict detected and already aborted by Agent Tower"),t}function W0(e,t){if(!t?.mergeAborted)return["1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git commit` 完成合并"];const r=t.mergeStrategy==="squash"?`git merge --squash --no-commit ${e}`:`git merge --no-ff ${e}`,a=t.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. 执行 ${a} 完成合并`]}function $0(e){if(!e.mergeAborted)return"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 merge 提交,然后说明处理结果。";const t=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;请在${t}中确认工作区干净,重新执行 \`${r}\` 复现冲突,解决后完成提交并汇报验证结果。`}function U0(e,t,r,a,p){const m=Xa(r),v=Va(p);return a===ws.REBASE?["## Rebase 冲突解决","",`在将分支 \`${e}\` rebase 到 \`${t}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤","1. 打开上述冲突文件,解决所有冲突标记(`<<<<<<<`、`=======`、`>>>>>>>`)","2. 对每个已解决的文件执行 `git add <file>`","3. 执行 `git rebase --continue` 继续 rebase 流程"].join(`
75
+ `):["## Merge 冲突解决","",`在将分支 \`${e}\` 合并到 \`${t}\` 时发生了冲突。`,...v.length>0?["","### 上下文",...v]:[],"","### 冲突文件",m,"","### 解决步骤",...W0(e,p)].join(`
76
+ `)}function q0(e){const t=e.conflictOp===ws.REBASE?"Rebase":"Merge",r=Xa(e.conflictedFiles),a=[...Va(e),`- Source branch: \`${e.sourceBranch}\``,`- Target branch: \`${e.targetBranch}\``,`- Conflict type: \`${e.conflictOp}\``];return[`## 请求处理 ${t} 冲突`,"",`用户点击了“AI 辅助解决”,请在对应 workspace 中处理当前 ${t} 冲突,并在 Team Room 汇报处理结果和验证情况。`,"","### 上下文",...a,"","### 冲突文件",r,"","### 用户意图",e.conflictOp===ws.REBASE?"请确认当前 Git 状态,解决所有冲突标记,完成必要的 `git add` 与后续 `git rebase --continue`,然后说明处理结果。":$0(e)].join(`
77
+ `)}function K0(e){if(e.teamRunId)return{type:"team_room",message:q0(e)};const t=e.currentSessionId||e.selectedSessionId;return t?{type:"session",sessionId:t,message:U0(e.sourceBranch,e.targetBranch,e.conflictedFiles,e.conflictOp,e)}:{type:"none"}}function X0({open:e,onOpenChange:t,workspaceId:r,conflictOp:a,conflictedFiles:p,sourceBranch:m,targetBranch:v,operation:i,worktreePath:n,mergeAborted:c,mergeStrategy:f,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:b,targetWorktreePath:y,sessions:_,currentSessionId:o,teamRunId:h}){const{t:d}=ne(),[u,x]=C.useState(""),S=Ui(),k=hi(h??""),E=Wi(),w=!!h,j=o||u,R=w?k.isPending:S.isPending,L=()=>{const F=K0({workspaceId:r,worktreePath:n,operation:i,mergeAborted:c,mergeStrategy:f,sourceWorkspaceId:l,targetWorkspaceId:g,sourceWorktreePath:b,targetWorktreePath:y,sourceBranch:m,targetBranch:v,conflictedFiles:p,conflictOp:a,teamRunId:h,currentSessionId:o,selectedSessionId:u});if(F.type==="team_room"){k.mutate({content:F.message,kind:"chat"},{onSuccess:()=>{ns.success(d("已发送到 Team Room")),t(!1)}});return}F.type==="session"&&S.mutate({id:F.sessionId,message:F.message},{onSuccess:()=>t(!1)})},D=()=>{E.mutate({workspaceId:r},{onSuccess:()=>t(!1)})},N=a==="REBASE"?"Rebase":"Merge",M=!w&&!o&&_.length>0,O=w||!!j;return s.jsx(Ms,{isOpen:e,onClose:()=>t(!1),title:d("解决 {opLabel} 冲突",{opLabel:N}),action:s.jsxs("div",{className:"flex gap-2",children:[s.jsx(De,{variant:"outline",onClick:D,children:d("在 IDE 中打开")}),s.jsx(De,{onClick:L,disabled:!O||R,children:d(R?"发送中...":"AI 辅助解决")})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("冲突文件({count})",{count:p.length})}),s.jsx("div",{className:"max-h-40 overflow-y-auto rounded-md border border-neutral-200 bg-neutral-50",children:p.map(F=>s.jsx("div",{className:"px-3 py-1.5 text-xs font-mono text-neutral-700 border-b border-neutral-100 last:border-b-0",children:F},F))})]}),w&&s.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,由团队调度处理。")}),M&&s.jsxs("div",{children:[s.jsx("h4",{className:"text-sm font-medium text-neutral-700 mb-2",children:d("选择 Session(AI 辅助解决)")}),s.jsxs("select",{value:u,onChange:F=>x(F.target.value),className:"w-full px-3 py-2 text-sm border border-neutral-200 rounded-md bg-white focus:outline-none focus:ring-2 focus:ring-neutral-300",children:[s.jsx("option",{value:"",children:d("选择一个 Session...")}),_.map(F=>s.jsxs("option",{value:F.id,children:[F.agentType," — ",F.status]},F.id))]})]}),!w&&!j&&_.length===0&&s.jsx("p",{className:"text-sm text-neutral-500",children:d("没有可用的 Session,请在 IDE 中手动解决冲突。")})]})})}function Jt(e,t){const r=e[t];return typeof r=="string"&&r.length>0?r:void 0}function V0(e){if(!(e instanceof Co)||e.status!==409)return;const t=e.details;if(t.code!=="MERGE_CONFLICT"||t.conflictOp!==ws.REBASE&&t.conflictOp!==ws.MERGE||!Array.isArray(t.conflictedFiles)||!t.conflictedFiles.every(a=>typeof a=="string"))return;const r=t.mergeStrategy==="squash"||t.mergeStrategy==="no_ff"?t.mergeStrategy:void 0;return{conflictOp:t.conflictOp,conflictedFiles:t.conflictedFiles,mergeAborted:typeof t.mergeAborted=="boolean"?t.mergeAborted:void 0,mergeStrategy:r,sourceBranch:Jt(t,"sourceBranch"),targetBranch:Jt(t,"targetBranch"),sourceWorktreePath:Jt(t,"sourceWorktreePath"),targetWorktreePath:Jt(t,"targetWorktreePath"),sourceWorkspaceId:Jt(t,"sourceWorkspaceId"),targetWorkspaceId:Jt(t,"targetWorkspaceId")}}function io(e,t,r,a){const p=V0(e);if(p){r(p);return}a(e instanceof Error?e.message:t)}function $t({children:e,variant:t}){const r={success:"bg-emerald-50 text-emerald-700 border-emerald-200",warning:"bg-amber-50 text-amber-700 border-amber-200",info:"bg-blue-50 text-blue-700 border-blue-200",neutral:"bg-neutral-50 text-neutral-600 border-neutral-200",danger:"bg-red-50 text-red-700 border-red-200"};return s.jsx("span",{className:`inline-flex items-center gap-1.5 px-2.5 py-1 rounded-full text-xs font-medium border ${r[t]}`,children:e})}function Y0({gitStatus:e,branchName:t,targetBranch:r}){const{t:a}=ne();return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:t}),s.jsx(To,{size:14,className:"text-neutral-400"}),s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:r})]}),s.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.hasUncommittedChanges&&s.jsxs($t,{variant:"danger",children:[s.jsx(kc,{size:12}),a("{count} 个未提交变更",{count:e.uncommittedCount})]}),e.conflictedFiles.length>0&&s.jsxs($t,{variant:"warning",children:[s.jsx(Si,{size:12}),a("{count} 个冲突文件",{count:e.conflictedFiles.length})]}),e.operation==="rebase"&&e.conflictedFiles.length===0&&s.jsxs($t,{variant:"warning",children:[s.jsx(Ke,{size:12,className:"animate-spin"}),a("变基进行中")]}),e.operation==="merge"&&e.conflictedFiles.length===0&&s.jsxs($t,{variant:"warning",children:[s.jsx(Ke,{size:12,className:"animate-spin"}),a("合并进行中")]}),e.ahead>0&&s.jsxs($t,{variant:"success",children:[s.jsx(mn,{size:12}),a("领先 {count} 个提交",{count:e.ahead})]}),e.behind>0&&s.jsx($t,{variant:"warning",children:a("落后 {count} 个提交",{count:e.behind})}),e.operation==="idle"&&e.ahead===0&&e.behind===0&&!e.hasUncommittedChanges&&s.jsxs($t,{variant:"neutral",children:[s.jsx(mn,{size:12}),a("已是最新")]})]}),e.hasUncommittedChanges&&s.jsx("div",{className:"px-3 py-2 rounded-md bg-amber-50 border border-amber-200 text-xs text-amber-800",children:a("工作区有未提交的变更,请先让 Agent 提交或手动处理后再执行 Rebase / Merge 操作。")})]})}function G0({open:e,onOpenChange:t,workspaceId:r,branchName:a,targetBranch:p,commitMessage:m,onRefreshCommitMessage:v,onConflict:i}){const{t:n}=ne(),{data:c,isLoading:f}=Ha(r),l=N0(),g=E0(),[b,y]=C.useState(null),[_,o]=C.useState("select"),[h,d]=C.useState(""),[u,x]=C.useState(!1),S=c?c.conflictedFiles.length>0:!1,k=c?c.operation!=="idle":!1,E=c?.hasUncommittedChanges??!1;C.useEffect(()=>{e&&(o("select"),y(null),x(!1),v?.())},[e,v]),C.useEffect(()=>{!e||u||d(m??"")},[e,m,u]);const w=N=>{x(!0),d(M=>typeof N=="function"?N(M):N)},j=()=>{y(null),l.mutate(r,{onSuccess:()=>t(!1),onError:N=>{io(N,n("变基失败"),M=>{t(!1),i(M)},y)}})},R=()=>{y(null),o("confirm")},L=()=>{y(null);const N=h.trim()||void 0;g.mutate({id:r,commitMessage:N},{onSuccess:()=>t(!1),onError:M=>{io(M,n("合并失败"),O=>{t(!1),i(O)},y)}})},D=n(_==="confirm"?"确认合并":"Git 操作");return s.jsx(Ms,{isOpen:e,onClose:()=>t(!1),title:D,children:f||!c?s.jsxs("div",{className:"flex items-center justify-center py-8 gap-2 text-neutral-400",children:[s.jsx(Ke,{size:18,className:"animate-spin"}),s.jsx("span",{className:"text-sm",children:n("加载分支状态...")})]}):_==="confirm"?s.jsx(Z0,{editableMessage:h,setEditableMessage:w,error:b,isPending:g.isPending,onConfirm:L,onBack:()=>o("select"),branchName:a,targetBranch:p}):s.jsx(Q0,{gitStatus:c,branchName:a,targetBranch:p,error:b,isDirty:E,hasConflicts:S,isOperationInProgress:k,rebasePending:l.isPending,mergePending:g.isPending,onRebase:j,onMerge:R})})}function Q0({gitStatus:e,branchName:t,targetBranch:r,error:a,isDirty:p,hasConflicts:m,isOperationInProgress:v,rebasePending:i,mergePending:n,onRebase:c,onMerge:f}){const{t:l}=ne();return s.jsxs("div",{className:"space-y-5",children:[s.jsx(Y0,{gitStatus:e,branchName:t,targetBranch:r}),a&&s.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:a}),s.jsxs("div",{className:"space-y-2",children:[s.jsxs("button",{onClick:c,disabled:i||m||v||p,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx("div",{className:"w-8 h-8 rounded-md bg-blue-50 flex items-center justify-center shrink-0",children:s.jsx(ji,{size:16,className:"text-blue-600"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900",children:l(i?"变基中...":"变基 (Rebase)")}),s.jsx("div",{className:"text-xs text-neutral-500",children:l("将当前分支变基到最新的 {targetBranch}",{targetBranch:r})})]})]}),s.jsxs("button",{onClick:f,disabled:n||m||v||p||e.ahead===0,className:"w-full flex items-center gap-3 px-4 py-3 rounded-lg border border-neutral-200 hover:border-neutral-300 hover:bg-neutral-50 transition-colors text-left disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx("div",{className:"w-8 h-8 rounded-md bg-emerald-50 flex items-center justify-center shrink-0",children:s.jsx(Do,{size:16,className:"text-emerald-600"})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-900",children:l(n?"合并中...":"合并 (Merge)")}),s.jsx("div",{className:"text-xs text-neutral-500",children:l("合并到 {targetBranch}",{targetBranch:r})})]})]})]})]})}function Z0({editableMessage:e,setEditableMessage:t,error:r,isPending:a,onConfirm:p,onBack:m,branchName:v,targetBranch:i}){const{t:n}=ne();return s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:v}),s.jsx(To,{size:14,className:"text-neutral-400"}),s.jsx("span",{className:"px-2.5 py-1 rounded-md bg-neutral-100 font-mono text-xs text-neutral-700",children:i})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-xs font-medium text-neutral-600 mb-1.5",children:n("提交消息")}),s.jsx("textarea",{value:e,onChange:c=>t(c.target.value),placeholder:n("输入提交消息..."),rows:4,className:"w-full px-3 py-2 rounded-md border border-neutral-200 text-sm font-mono text-neutral-800 placeholder:text-neutral-400 focus:outline-none focus:ring-2 focus:ring-emerald-500/20 focus:border-emerald-300 resize-none"}),!e.trim()&&s.jsx("p",{className:"mt-1 text-xs text-neutral-400",children:n("留空将使用默认消息")})]}),r&&s.jsx("div",{className:"px-3 py-2 rounded-md bg-red-50 border border-red-200 text-sm text-red-700",children:r}),s.jsxs("div",{className:"flex gap-2 justify-end",children:[s.jsx("button",{onClick:m,disabled:a,className:"px-4 py-2 rounded-md text-sm text-neutral-600 hover:bg-neutral-100 transition-colors disabled:opacity-50",children:n("返回")}),s.jsx("button",{onClick:p,disabled:a,className:"flex items-center gap-2 px-4 py-2 rounded-md text-sm font-medium text-white bg-emerald-600 hover:bg-emerald-700 transition-colors disabled:opacity-50",children:a?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{size:14,className:"animate-spin"}),n("合并中...")]}):s.jsxs(s.Fragment,{children:[s.jsx(Do,{size:14}),n("确认合并")]})})]})]})}function J0({agentType:e,workingDir:t}){return vt({queryKey:le.system.slashCommandCatalog(e,t),queryFn:async()=>(await me.get("/system/slash-command-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:!!e,staleTime:3e4})}function eg(e,t){const r=new Set,a=[];for(const p of[...e,...t]){const m=p.command.trim().toLowerCase();!m||r.has(m)||(r.add(m),a.push(p.kind?p:{...p,kind:"builtin"}))}return a}function Nr(e){return e.trim().toLowerCase().replace(/^[/$]/,"")}function tg(e){return Nr(e.command)}function sg(e,t){if(!t)return 1e3;const r=tg(e),a=e.aliases?.map(Nr)??[],p=[r,...a];let m=0;for(const i of p)i===t?m=Math.max(m,500):i.startsWith(t)?m=Math.max(m,400-(i.length-t.length)):i.includes(t)&&(m=Math.max(m,250-i.indexOf(t)));return m>0?m:`${r} ${a.join(" ")} ${e.description}`.toLowerCase().includes(t)?100:0}function no(e){const t=/(^|[\s])\$([^\s]*)$/.exec(e);if(!t||t.index===void 0)return null;const r=t.index+t[1].length;return{query:Nr(t[2]),replaceStart:r}}function Ya(e,t){const r=Nr(t);return r?e.map((a,p)=>({command:a,index:p,score:sg(a,r)})).filter(a=>a.score>0).sort((a,p)=>p.score-a.score||a.index-p.index||a.command.command.localeCompare(p.command.command)).map(a=>a.command):e.slice()}const rg=[{command:"/permissions",description:"Manage what Codex can do without approval"},{command:"/sandbox-add-read-dir",description:"Grant read access to another directory"},{command:"/agent",description:"Switch between built-in agent personas"},{command:"/apps",description:"Manage connected apps"},{command:"/clear",description:"Start a fresh conversation"},{command:"/compact",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last assistant message to your clipboard"},{command:"/diff",description:"Show the current git diff"},{command:"/experimental",description:"Toggle experimental features"},{command:"/feedback",description:"Share feedback on Codex CLI"},{command:"/init",description:"Create or update AGENTS.md for the repo"},{command:"/logout",description:"Sign out of Codex"},{command:"/mcp",description:"Manage MCP servers"},{command:"/mention",description:"Add files or directories to the conversation context"},{command:"/model",description:"Change the active model"},{command:"/fast",description:"Toggle low reasoning mode"},{command:"/plan",description:"Toggle plan mode for code changes"},{command:"/personality",description:"Select how Codex communicates"},{command:"/ps",description:"List running background tasks"},{command:"/fork",description:"Fork the current conversation state"},{command:"/resume",description:"Resume a previous conversation"},{command:"/new",description:"Open a conversation picker to start or resume"},{command:"/quit",description:"Exit Codex CLI",aliases:["exit"]},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show session and configuration status"},{command:"/debug-config",description:"Inspect the effective configuration"},{command:"/statusline",description:"Configure the custom status line"},{command:"/skills",description:"Browse available skills and insert a $skill mention"}],ig=[{command:"/clear",description:"Clear the conversation history"},{command:"/compact",description:"Compact the conversation context",aliases:["compact focus"]},{command:"/config",description:"Open the configuration panel"},{command:"/cost",description:"Show token usage and cost"},{command:"/doctor",description:"Check Claude Code installation health"},{command:"/help",description:"Show help and available commands"},{command:"/init",description:"Initialize project instructions"},{command:"/login",description:"Sign in to Claude Code"},{command:"/logout",description:"Sign out of Claude Code"},{command:"/mcp",description:"Manage MCP servers"},{command:"/memory",description:"Edit project memory files"},{command:"/model",description:"Change the active model"},{command:"/permissions",description:"Review or update tool permissions"},{command:"/pr_comments",description:"Read pull request review comments"},{command:"/review",description:"Run a code review"},{command:"/status",description:"Show account and system status"},{command:"/terminal-setup",description:"Configure terminal newline shortcuts"},{command:"/vim",description:"Toggle vim mode"}],ng=[{command:"/bug",description:"File an issue about Gemini CLI"},{command:"/chat",description:"Manage chat checkpoints and exports"},{command:"/clear",description:"Clear the terminal display"},{command:"/compress",description:"Replace chat context with a summary"},{command:"/copy",description:"Copy the last Gemini CLI output"},{command:"/directory",description:"Manage additional workspace directories",aliases:["dir"]},{command:"/editor",description:"Choose the preferred editor"},{command:"/extensions",description:"List active Gemini CLI extensions"},{command:"/help",description:"Show help and command usage",aliases:["?"]},{command:"/mcp",description:"Show MCP servers and tools"},{command:"/memory",description:"Manage loaded GEMINI.md memory"},{command:"/restore",description:"Restore files from a tool checkpoint"},{command:"/settings",description:"Open the Gemini CLI settings editor"},{command:"/stats",description:"Show session statistics and token usage"},{command:"/theme",description:"Change the Gemini CLI theme"},{command:"/auth",description:"Change the authentication method"},{command:"/about",description:"Show version information"},{command:"/tools",description:"List currently available tools"},{command:"/privacy",description:"Review privacy and data collection settings"},{command:"/quit",description:"Exit Gemini CLI",aliases:["exit"]},{command:"/vim",description:"Toggle vim mode"},{command:"/init",description:"Generate a tailored GEMINI.md file"}],og=[{command:"/model",description:"Change the active model"},{command:"/plan",description:"Create or reopen a plan"},{command:"/ask",description:"Toggle ask mode (read-only Q&A)"},{command:"/debug",description:"Toggle debug mode"},{command:"/clear",description:"Start a new chat session",aliases:["new","new-chat","newchat"]},{command:"/compress",description:"Summarize the conversation to reduce context"},{command:"/vim",description:"Toggle vim mode"},{command:"/shell",description:"Enter shell mode"},{command:"/about",description:"Show CLI, system, and account information"},{command:"/setup-terminal",description:"Configure terminal newline shortcuts"},{command:"/feedback",description:"Share feedback with the Cursor team"},{command:"/open",description:"Open the repository git root in Cursor"},{command:"/cursor",description:"Alias for /open",aliases:["open"]},{command:"/resume-chat",description:"Resume a previous chat by folder name",aliases:["resume"]},{command:"/copy-request-id",description:"Copy the last request ID"},{command:"/copy-conversation-id",description:"Copy the current conversation ID"},{command:"/logout",description:"Sign out from Cursor"},{command:"/quit",description:"Exit Cursor Agent",aliases:["exit"]},{command:"/mcp",description:"Manage MCP servers"}],ag={[Nt.CODEX]:rg,[Nt.CLAUDE_CODE]:ig,[Nt.GEMINI_CLI]:ng,[Nt.CURSOR_AGENT]:og};function Ga(e){return e.trim().toLowerCase().replace(/^\//,"")}function lg(e){return e?(ag[e]??[]).map(t=>({...t,kind:t.kind??"builtin"})):[]}function cg(e){const t=e.match(/^\s*\/([^\s]*)$/);return t?Ga(t[1]):null}function dg(e,t){return Ya(e,Ga(t))}function ug(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return t||r}function Qa({agentType:e,workingDir:t,input:r,setInput:a,textareaRef:p,minHeight:m,maxHeight:v}){const[i,n]=C.useState(0),{data:c=[]}=J0({agentType:e,workingDir:t}),f=C.useMemo(()=>eg(lg(e),c),[e,c]),l=C.useMemo(()=>cg(r),[r]),g=C.useMemo(()=>l===null?[]:dg(f,l),[f,l]),b=C.useCallback(()=>{const o=p.current;o&&(o.style.height="auto",o.style.height=`${Math.max(m,Math.min(o.scrollHeight,v))}px`)},[v,m,p]);C.useEffect(()=>{n(0)},[e,l]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const y=C.useCallback(o=>{const d=`${r.match(/^(\s*)\/[^\s]*$/)?.[1]??""}${o.command} `;a(d),requestAnimationFrame(()=>{const u=p.current;u&&(b(),u.focus(),u.setSelectionRange(d.length,d.length))})},[r,b,a,p]),_=C.useCallback(o=>l===null||g.length===0?!1:o.key==="ArrowDown"?(o.preventDefault(),n(h=>(h+1)%g.length),!0):o.key==="ArrowUp"?(o.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):ug(o)?(o.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,l,i]);return{allCommands:f,query:l,filteredCommands:g,selectedIndex:i,setSelectedIndex:n,applyCommand:y,handleKeyDown:_}}function hg({agentType:e,workingDir:t}){return vt({queryKey:le.system.skillCatalog(e,t),queryFn:async()=>(await me.get("/system/skill-catalog",{params:{agentType:String(e),...t?{workingDir:t}:{}}})).commands,enabled:e===Nt.CODEX,staleTime:3e4})}function fg(e){const t=e.key==="Enter"&&!e.shiftKey&&!e.repeat&&!e.nativeEvent.isComposing&&e.nativeEvent.keyCode!==229,r=e.key==="Tab"&&!e.shiftKey;return t||r}function Za({agentType:e,workingDir:t,input:r,setInput:a,textareaRef:p,minHeight:m,maxHeight:v}){const[i,n]=C.useState(0),{data:c=[]}=hg({agentType:e,workingDir:t}),l=C.useMemo(()=>e===Nt.CODEX?no(r):null,[e,r])?.query??null,g=C.useMemo(()=>l===null?[]:Ya(c,l),[l,c]),b=C.useCallback(()=>{const o=p.current;o&&(o.style.height="auto",o.style.height=`${Math.max(m,Math.min(o.scrollHeight,v))}px`)},[v,m,p]);C.useEffect(()=>{n(0)},[e,l]),C.useEffect(()=>{i<g.length||n(0)},[g.length,i]);const y=C.useCallback(o=>{const h=no(r);if(!h)return;const d=`${r.slice(0,h.replaceStart)}${o.command} `;a(d),requestAnimationFrame(()=>{const u=p.current;u&&(b(),u.focus(),u.setSelectionRange(d.length,d.length))})},[r,b,a,p]),_=C.useCallback(o=>l===null||g.length===0?!1:o.key==="ArrowDown"?(o.preventDefault(),n(h=>(h+1)%g.length),!0):o.key==="ArrowUp"?(o.preventDefault(),n(h=>(h-1+g.length)%g.length),!0):fg(o)?(o.preventDefault(),y(g[i]??g[0]),!0):!1,[y,g,l,i]);return{allSkills:c,query:l,filteredSkills:g,selectedIndex:i,setSelectedIndex:n,applySkill:y,handleKeyDown:_}}const mg="/api",pg=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${mg}/attachments/by-path?path=${encodeURIComponent(e)}`:e,gg=({src:e,alt:t,...r})=>s.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:s.jsx("img",{src:e,alt:t,...r,className:"max-w-[300px] max-h-[200px] object-contain rounded-lg border border-neutral-200 cursor-pointer hover:opacity-90 transition-opacity"})}),vg={img:gg},_g=675,oo=320,ao=1200;function xg(){const{t:e}=ne();return s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center bg-white text-neutral-400 select-none",children:[s.jsx("div",{className:"w-16 h-16 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-6",children:s.jsxs("svg",{width:"28",height:"28",viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",className:"text-neutral-300",children:[s.jsx("path",{d:"M12 2L2 7L12 12L22 7L12 2Z",fill:"currentColor"}),s.jsx("path",{d:"M2 17L12 22L22 17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"}),s.jsx("path",{d:"M2 12L12 17L22 12",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round"})]})}),s.jsx("h3",{className:"text-neutral-900 font-medium mb-2 text-lg",children:"Agent Tower"}),s.jsx("p",{className:"text-sm max-w-sm text-center text-neutral-500 leading-relaxed",children:e("Select a task from the sidebar to view logs, monitor execution, or interact with an agent.")})]})}const lo=[{status:ge.Review,className:"bg-amber-50 text-amber-700 border-amber-100",hoverClass:"hover:bg-amber-100",icon:s.jsx(fi,{className:"w-3 h-3"})},{status:ge.Running,className:"bg-blue-50 text-blue-700 border-blue-100",hoverClass:"hover:bg-blue-100",icon:s.jsx(mi,{className:"w-3 h-3"})},{status:ge.Pending,className:"bg-neutral-50 text-neutral-600 border-neutral-100",hoverClass:"hover:bg-neutral-100",icon:s.jsx(pi,{className:"w-3 h-3"})},{status:ge.Done,className:"bg-emerald-50 text-emerald-700 border-emerald-100",hoverClass:"hover:bg-emerald-100",icon:s.jsx(gi,{className:"w-3 h-3"})},{status:ge.Cancelled,className:"bg-neutral-50 text-neutral-500 border-neutral-200",hoverClass:"hover:bg-neutral-200",icon:s.jsx(vi,{className:"w-3 h-3"})}];function bg({status:e,onChangeStatus:t}){const{t:r}=ne(),[a,p]=C.useState(!1),m=C.useRef(null);C.useEffect(()=>{if(!a)return;const i=n=>{m.current&&!m.current.contains(n.target)&&p(!1)};return document.addEventListener("mousedown",i),()=>document.removeEventListener("mousedown",i)},[a]);const v=lo.find(i=>i.status===e);return s.jsxs("div",{className:"relative",ref:m,children:[s.jsxs("button",{onClick:()=>t&&p(i=>!i),className:`flex items-center gap-1.5 px-3 py-1 rounded-full text-xs font-medium border transition-colors ${v.className} ${t?"cursor-pointer hover:opacity-80":""}`,children:[v.icon,s.jsx("span",{children:r(e)}),t&&s.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"currentColor",className:`ml-0.5 transition-transform ${a?"rotate-180":""}`,children:s.jsx("path",{d:"M2 3.5L5 6.5L8 3.5",stroke:"currentColor",strokeWidth:"1.2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})})]}),a&&s.jsx("div",{className:"absolute right-0 top-full mt-2 w-40 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1 animate-in fade-in zoom-in-95 duration-100",children:lo.filter(i=>i.status!==e).map(i=>s.jsxs("button",{onClick:()=>{t?.(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:[s.jsx("span",{className:i.className.split(" ").find(n=>n.startsWith("text-")),children:i.icon}),s.jsx("span",{className:"text-neutral-700",children:r(i.status)})]},i.status))})]})}function yg({task:e,onDeleteTask:t,isDeleting:r,onTaskStatusChange:a}){const{t:p}=ne(),[m,v]=C.useState(""),[i,n]=C.useState(!1),[c,f]=C.useState(!1),[l,g]=C.useState(!1),[b,y]=C.useState(!1),[_,o]=C.useState(!1),[h,d]=C.useState(!1),[u,x]=C.useState(null),[S,k]=C.useState(!1),[E,w]=C.useState(!1),[j,R]=C.useState(null),[L,D]=C.useState(void 0),[N,M]=C.useState(!1),O=C.useRef(null),F=C.useRef(null),z=C.useRef(null),A=C.useRef(null),{scrollRef:P,contentRef:I,isAtBottom:B,scrollToBottom:$}=Bi({resize:"smooth",initial:"instant"}),[X,Z]=C.useState(_g),[J,ae]=C.useState(!0),[T,H]=C.useState(!1),U=C.useRef(0),W=C.useRef(0),te=C.useRef(null),{data:K,isLoading:ce}=Fa(e?.id??""),he=T0(e?.id),{data:ve}=ko(e?.id??""),{data:Fe}=Eo(ve?.id??""),re=hi(ve?.id??""),pe=ve??null,Ze=!!pe,je=ve===null;C.useEffect(()=>{M(!1),R(null),D(void 0)},[e?.id]);const Le=C.useMemo(()=>oa(K,pe,L),[L,pe,K]);C.useEffect(()=>{L&&!K?.some(G=>G.id===L)&&D(void 0)},[L,K]);const we=C.useMemo(()=>K?.find(G=>G.id===Le),[Le,K]),Ce=we?.status===kt.ACTIVE?we.id:void 0,Xe=$h(we,pe);C.useEffect(()=>{if(!N||!K)return;K.some(de=>de.status==="ACTIVE"&&de.sessions&&de.sessions.length>0)&&M(!1)},[K,N]);const _e=C.useMemo(()=>{if(N||!K)return null;const G=ot=>{const Lr=ot.createdAt,ps=ot.endedAt??ot.startedAt??Lr;if(!ps)return 0;const Qt=Date.parse(ps);return Number.isNaN(Qt)?0:Qt},de=(ot,Lr)=>{const ps=ot.filter(Qt=>Lr.includes(Qt.status));return ps.length===0?null:ps.sort((Qt,Rl)=>G(Rl)-G(Qt))[0]??null},Oe=K.filter(ot=>ot.status==="ACTIVE"&&Array.isArray(ot.sessions)).flatMap(ot=>ot.sessions??[]),yt=de(Oe,[Ge.RUNNING])??de(Oe,[Ge.PENDING])??de(Oe,[Ge.COMPLETED,Ge.FAILED,Ge.CANCELLED]);if(yt)return yt;const mt=K.filter(ot=>(ot.status==="MERGED"||ot.status==="ABANDONED"||ot.status==="HIBERNATED")&&Array.isArray(ot.sessions)).flatMap(ot=>ot.sessions??[]);return de(mt,[Ge.COMPLETED,Ge.FAILED,Ge.CANCELLED])},[K,N]),ze=_e?.id??"",ke=Ze?j??"":ze,tt=C.useMemo(()=>{if(!j||!K)return null;for(const G of K){const de=G.sessions?.find(Oe=>Oe.id===j);if(de)return de}return null},[j,K])??_e??null,qe=tt?.status===Ge.RUNNING||tt?.status===Ge.PENDING,q=!!e?.projectArchivedAt,Q=!!e?.projectRepoDeletedAt,ue=p(Q?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),{data:Te}=Ds(),[Ne,Ee]=C.useState(null);C.useEffect(()=>{Ee(_e?.providerId??null)},[_e?.providerId]);const lt=C.useMemo(()=>!_e||!K?!1:!K.some(de=>de.status==="ACTIVE"&&de.sessions?.some(Oe=>Oe.id===_e.id)),[_e,K]),ft=C.useMemo(()=>{if(!(!K||N)){if(we)return we.worktreePath||void 0;for(const G of K)if(G.status==="ACTIVE"&&G.worktreePath)return G.worktreePath;return K[0]?.worktreePath}},[N,we,K]),Pe=Qa({agentType:_e?.agentType,workingDir:ft,input:m,setInput:v,textareaRef:z,minHeight:60,maxHeight:300}),Ve=Za({agentType:_e?.agentType,workingDir:ft,input:m,setInput:v,textareaRef:z,minHeight:60,maxHeight:300}),{data:He}=Ha(Xe?Ce??"":""),We=we?.sessions??[],st=we?.branchName??"",Je=we?.commitMessage,pt=C.useMemo(()=>Uh(we,K,e?.mainBranch??""),[we,e?.mainBranch,K]),Me=C.useMemo(()=>He?.conflictOp&&He.conflictedFiles.length>0?{conflictOp:He.conflictOp,conflictedFiles:He.conflictedFiles}:u,[He?.conflictOp,He?.conflictedFiles,u]),rt=Me?.targetWorkspaceId??Ce,ht=Me?.targetWorktreePath??we?.worktreePath,xt=Me?.sourceBranch??st,Ie=Me?.targetBranch??pt,Y=Qe(),oe=C.useCallback(()=>e?.id?Y.invalidateQueries({queryKey:le.workspaces.list(e.id)}):Promise.resolve(),[e?.id,Y]);C.useEffect(()=>{if(!E)return;const G=de=>{F.current&&!F.current.contains(de.target)&&w(!1)};return document.addEventListener("mousedown",G),()=>document.removeEventListener("mousedown",G)},[E]);const be=Ui(),ye=Wi(),it=O0(),V=za(e?.id??""),ee=$i(),fe=j0(),Ae=C.useMemo(()=>!K||K.some(de=>de.status==="ACTIVE")?null:K.find(de=>de.status==="HIBERNATED")??null,[K]),$e=C.useRef(null);C.useEffect(()=>{Ae&&$e.current!==Ae.id&&(fe.isPending||($e.current=Ae.id,fe.mutate(Ae.id,{onSettled:()=>{$e.current=null}})))},[Ae,fe]);const nt=C.useCallback(async()=>{if(!e?.id)return;const G=_e?.providerId??Te?.find(Oe=>Oe.availability.type!=="NOT_FOUND")?.provider.id;if(!G)return;const de=[e.title,e.description].filter(Boolean).join(`
78
+
79
+ `);y(!1),o(!0);try{await it.mutateAsync(e.id),M(!0);const Oe=await V.mutateAsync({}),yt=await me.post(`/workspaces/${Oe.id}/sessions`,{providerId:G,prompt:de});await ee.mutateAsync(yt.id),await Y.invalidateQueries({queryKey:le.workspaces.list(e.id)})}catch(Oe){console.error("[retry] failed:",Oe),M(!1)}finally{o(!1)}},[e?.id,e?.title,e?.description,_e?.providerId,Te,it,V,ee,Y]),Mt=C.useCallback(()=>{we?.id&&ye.mutate({workspaceId:we.id})},[ye,we?.id]),Dt=C.useCallback(()=>{!e?.id||!t||(t(e.id),g(!1))},[e?.id,t]),Ki=C.useCallback(G=>{R(G),requestAnimationFrame(()=>{$()})},[$]),ml=C.useCallback(()=>{R(null)},[]),Xi=C.useCallback(G=>{x(G??null),d(!0)},[]),pl=C.useCallback(G=>re.mutateAsync(G),[re]),Yt=C.useCallback(()=>{Y.invalidateQueries({queryKey:Xl.all})},[Y]),{isConnected:Vi,isLoadingSnapshot:Yi,logs:fs,entries:gl,attach:Hs}=jo({sessionId:ke,sessionStatus:tt?.status,onExit:C.useCallback(()=>{Y.invalidateQueries({queryKey:["workspaces"]})},[Y])});C.useEffect(()=>{if(!e?.id)return;const G=Ot.connect();G.emit(es.SUBSCRIBE,{topic:"task",id:e.id});const de=mt=>{mt.taskId===e.id&&(Y.invalidateQueries({queryKey:["tasks"]}),Yt())},Oe=mt=>{mt.taskId===e.id&&(Y.invalidateQueries({queryKey:le.workspaces.list(e.id)}),Yt())},yt=mt=>{mt.taskId===e.id&&(Y.invalidateQueries({queryKey:le.workspaces.list(e.id)}),Yt())};return G.on(ct.TASK_UPDATED,de),G.on(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Oe),G.on(ct.WORKSPACE_HIBERNATED,yt),()=>{G.off(ct.TASK_UPDATED,de),G.off(ct.WORKSPACE_COMMIT_MESSAGE_UPDATED,Oe),G.off(ct.WORKSPACE_HIBERNATED,yt),G.emit(es.UNSUBSCRIBE,{topic:"task",id:e.id})}},[e?.id,Y,Yt]),C.useEffect(()=>{if(!ke)return;const G=Ot.connect(),de=Oe=>{Oe.sessionId===ke&&(Y.invalidateQueries({queryKey:["workspaces"]}),Yt())};return G.on(ct.SESSION_COMPLETED,de),()=>{G.off(ct.SESSION_COMPLETED,de)}},[ke,Y,Yt]);const{todos:Gi}=No(gl),{files:vl,addFiles:Gt,removeFile:_l,clear:Qi,buildMarkdownLinks:Zi,hasFiles:ms,isUploading:Ws}=Sr(),xl=C.useMemo(()=>{if(!_e?.tokenUsage)return;const G=_e.tokenUsage;if(typeof G.totalTokens=="number")return G},[_e?.tokenUsage]),bl=$a(fs,xl);C.useEffect(()=>{ke&&Vi&&Hs()},[ke,Vi,Hs]);const Ji=C.useRef(e?.id);C.useEffect(()=>{if(Ji.current!==e?.id&&P.current){const G=P.current;requestAnimationFrame(()=>{G.scrollTop=G.scrollHeight})}Ji.current=e?.id},[e?.id,P]);const Ar=Wa(),Rr=C.useRef(!1),en=C.useCallback(async()=>{if(!m.trim()&&!ms||!ke||Rr.current||Ws)return;Rr.current=!0;const G=Zi(),de=[m.trim(),G].filter(Boolean).join(`
80
+
81
+ `);v(""),Qi(),z.current&&(z.current.style.height="60px"),be.mutate({id:ke,message:de,providerId:Ne??void 0},{onSuccess:()=>{Hs()},onSettled:()=>{Rr.current=!1}})},[m,ke,be,Hs,ms,Ws,Zi,Qi,Ne]),yl=C.useCallback(async()=>{ke&&(await Ar.mutateAsync(ke),Y.invalidateQueries({queryKey:["workspaces"]}))},[ke,Ar,Y]),Sl=C.useCallback(G=>{const de=G.target.files;de&&de.length>0&&Gt(Array.from(de)),G.target.value=""},[Gt]),wl=C.useCallback(G=>{const de=G.clipboardData.items,Oe=[];for(const yt of de)if(yt.kind==="file"){const mt=yt.getAsFile();mt&&Oe.push(mt)}Oe.length>0&&(G.preventDefault(),Gt(Oe))},[Gt]),[tn,Tr]=C.useState(!1),Cl=C.useCallback(G=>{G.preventDefault(),Tr(!0)},[]),kl=C.useCallback(G=>{G.preventDefault(),Tr(!1)},[]),El=C.useCallback(G=>{G.preventDefault(),Tr(!1);const de=G.dataTransfer.files;de.length>0&&Gt(Array.from(de))},[Gt]),Mr=C.useCallback(G=>{const de=G.clientX-U.current,Oe=Math.max(oo,Math.min(W.current+de,ao));te.current&&(te.current.style.width=`${Oe}px`)},[]),Dr=C.useCallback(()=>{if(H(!1),te.current){const G=te.current.getBoundingClientRect().width;Z(Math.max(oo,Math.min(Math.round(G),ao)))}document.body.style.cursor="",document.body.style.userSelect=""},[]);C.useEffect(()=>{if(T)return document.addEventListener("mousemove",Mr),document.addEventListener("mouseup",Dr),document.body.style.cursor="col-resize",document.body.style.userSelect="none",()=>{document.removeEventListener("mousemove",Mr),document.removeEventListener("mouseup",Dr),document.body.style.cursor="",document.body.style.userSelect=""}},[T,Mr,Dr]);const jl=C.useCallback(G=>{G.preventDefault(),U.current=G.clientX,W.current=X,H(!0)},[X]),Nl=C.useCallback(()=>{ae(G=>!G)},[]),Al=C.useCallback(G=>{v(G.target.value);const de=G.target;de.style.height="auto";const Oe=de.scrollHeight;de.style.height=`${Math.max(60,Math.min(Oe,300))}px`},[]),sn=C.useMemo(()=>{const G=[];if(K&&K.length>0){const de=K.some(mt=>mt.status==="ACTIVE"),Oe=K.some(mt=>mt.sessions?.some(ot=>ot.status===Ge.RUNNING||ot.status===Ge.PENDING)),yt=K.some(mt=>mt.status==="ACTIVE");Oe&&G.push(p("正在运行的 Agent 将被停止")),yt&&G.push(p("分支上未合并的变更将丢失")),de&&G.push(p("关联的工作目录(worktree)将被清理"))}return G},[K,p]);return e?s.jsxs("div",{className:"flex-1 flex flex-col h-full bg-white relative overflow-hidden",children:[s.jsxs("div",{className:"px-6 py-4 flex items-center justify-between border-b border-neutral-100 bg-white/80 backdrop-blur-sm z-20 flex-shrink-0",children:[s.jsxs("div",{className:"flex flex-col",children:[s.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[s.jsx("span",{className:`text-xs font-semibold uppercase tracking-wider ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&s.jsx("span",{className:"rounded-full bg-neutral-100 px-2 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?p("源码已删除"):p("已删除")}),s.jsx("span",{className:"text-neutral-300 text-xs",children:"/"}),s.jsx("span",{className:"text-xs text-neutral-500 font-mono",children:e.branch})]}),s.jsx("h2",{className:"text-lg font-bold text-neutral-900",children:e.title})]}),s.jsxs("div",{className:"flex items-center gap-4",children:[s.jsx(bg,{status:e.status,onChangeStatus:!q&&a?G=>a(e.id,G):void 0}),s.jsx(Ba,{workspaces:K,teamRun:pe,selectedWorkspaceId:Le,onSelectWorkspace:D}),we&&!q&&s.jsx("button",{onClick:()=>k(!0),disabled:!Xe,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:p("Git 操作"),children:s.jsx(Mc,{size:18})}),s.jsx("button",{onClick:Mt,disabled:!we?.worktreePath||q,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors disabled:opacity-30 disabled:cursor-not-allowed",title:p("Open in IDE"),children:s.jsx(pr,{size:18})}),s.jsx("button",{onClick:Nl,className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:p("Toggle Workspace"),children:J?s.jsx(Kc,{size:18}):s.jsx(Ai,{size:18})}),je&&!q&&s.jsxs("button",{onClick:()=>f(!0),className:"flex h-8 items-center justify-center gap-1.5 rounded-md border border-neutral-200 bg-white px-3 text-xs font-medium text-neutral-700 transition-colors hover:border-neutral-300 hover:bg-neutral-50",title:p("创建 TeamRun"),children:[s.jsx(as,{size:14}),s.jsx("span",{children:p("创建 TeamRun")})]}),t&&!q&&s.jsxs("div",{className:"relative",ref:F,children:[s.jsx("button",{onClick:()=>w(G=>!G),className:"w-8 h-8 flex items-center justify-center rounded-md text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 transition-colors",title:p("More actions"),children:s.jsx(Mo,{size:18})}),E&&s.jsxs("div",{className:"absolute right-0 top-full mt-2 w-44 bg-white rounded-lg border border-neutral-200 shadow-lg z-50 py-1",children:[s.jsxs("button",{onClick:()=>{y(!0),w(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-neutral-700 hover:bg-neutral-50 transition-colors",children:[s.jsx(Jl,{size:15}),s.jsx("span",{children:p("重新开始")})]}),s.jsxs("button",{onClick:()=>{g(!0),w(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 hover:bg-red-50 transition-colors",children:[s.jsx(bi,{size:15}),s.jsx("span",{children:p("删除任务")})]})]})]})]})]}),Xe&&Ce&&He&&s.jsx(H0,{workspaceId:Ce,gitStatus:He,onResolve:()=>Xi()}),s.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[s.jsx("div",{ref:te,className:`flex flex-col bg-white relative ${J?"flex-shrink-0":"flex-1"}`,style:{width:J?X:"100%"},children:Ze&&pe?j?s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex items-center justify-between gap-3 border-b border-neutral-200 px-4 py-3 shrink-0",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:p("Invocation details")}),s.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:j})]}),s.jsx(De,{type:"button",size:"sm",variant:"outline",onClick:ml,children:p("Back to room")})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:s.jsx("div",{ref:I,className:"w-full",children:Yi?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:p("Loading logs...")})]}):fs.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8",children:p(qe?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(Qs,{logs:fs})})}),!B&&s.jsxs("button",{onClick:()=>$(),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-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":p("Scroll to bottom"),children:[s.jsx(Cs,{size:14}),s.jsx("span",{children:p("回到底部")})]})]})]}):s.jsx(ia,{teamRun:pe,messages:Fe??pe.messages??[],readOnly:q,readOnlyMessage:ue,onSendMessage:pl,onViewInvocationSession:Ki}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:P,className:"h-full overflow-y-auto scrollbar-app-thin px-6 pt-6 pb-4",children:s.jsxs("div",{ref:I,className:"w-full",children:[s.jsx("div",{className:"mb-4 pb-4 border-b border-neutral-100",children:e.description?s.jsx("div",{className:"text-sm text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:s.jsx(_i,{urlTransform:pg,components:vg,children:e.description})}):s.jsx("p",{className:"text-sm text-neutral-400 italic",children:p("No description")})}),he&&s.jsxs("div",{className:"flex items-center justify-center gap-2 py-3 text-neutral-400 text-sm",children:[he.status==="running"&&s.jsxs(s.Fragment,{children:[s.jsxs("svg",{className:"animate-spin h-3.5 w-3.5 shrink-0",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{children:p("Setup ({current}/{total}): {command}",{current:he.currentIndex,total:he.totalCommands,command:he.currentCommand})})]}),he.status==="completed"&&s.jsx("span",{className:"text-emerald-600",children:p("Setup 完成")}),he.status==="failed"&&s.jsx("span",{className:"text-red-500",children:p("Setup 失败: {error}",{error:he.error})})]}),ce?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:p("Loading...")})]}):ze?Yi?s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:p("Loading logs...")})]}):fs.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8",children:p(qe?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(Qs,{logs:fs}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-16 text-center",children:[s.jsx("div",{className:"w-14 h-14 bg-neutral-50 rounded-2xl border border-neutral-100 flex items-center justify-center mb-5",children:s.jsx(qt,{size:24,className:"text-neutral-400 ml-0.5"})}),s.jsx("h3",{className:"text-base font-medium text-neutral-900 mb-1.5",children:p(q?"项目为只读历史":"尚未启动 Agent")}),s.jsx("p",{className:"text-sm text-neutral-500 mb-6 max-w-xs",children:q?ue:p("选择一个 Agent 来执行此任务,Agent 将自动创建工作空间并开始工作。")}),!q&&s.jsxs("div",{className:"flex flex-wrap items-center justify-center gap-3",children:[s.jsxs(De,{onClick:()=>n(!0),children:[s.jsx(qt,{size:16,className:"mr-1.5"}),p("启动 Agent")]}),je&&s.jsxs(De,{variant:"outline",onClick:()=>f(!0),children:[s.jsx(as,{size:16,className:"mr-1.5"}),p("创建 TeamRun")]})]})]})]})}),!B&&s.jsxs("button",{onClick:()=>$(),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-white/90 backdrop-blur-sm border border-neutral-200 rounded-full shadow-md text-xs text-neutral-600 hover:bg-white hover:text-neutral-900 transition-all","aria-label":p("Scroll to bottom"),children:[s.jsx(Cs,{size:14}),s.jsx("span",{children:p("回到底部")})]})]}),Gi.length>0&&s.jsx("div",{className:"px-6 pt-2 pb-1 bg-white flex-shrink-0 border-t border-neutral-100",children:s.jsx(Ao,{todos:Gi})}),q?s.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:s.jsx("div",{className:"bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3 text-sm text-neutral-500",children:ue})}):lt?s.jsx("div",{className:"p-6 pt-3 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-neutral-100",children:s.jsxs("div",{className:"flex items-center justify-between bg-neutral-50 rounded-xl border border-neutral-200 px-4 py-3",children:[s.jsx("span",{className:"text-sm text-neutral-500",children:p("代码已合并,以上为历史沟通记录")}),s.jsxs(De,{size:"sm",onClick:()=>n(!0),children:[s.jsx(qt,{size:14,className:"mr-1.5"}),p("启动新 Agent")]})]})}):s.jsxs("div",{className:"p-6 pt-2 bg-white flex-shrink-0 w-full z-10 pb-6 border-t border-transparent",onDragOver:Cl,onDragLeave:kl,onDrop:El,children:[s.jsxs("div",{ref:O,className:`relative bg-white rounded-xl border shadow-sm hover:shadow-md focus-within:shadow-md focus-within:border-neutral-300 transition-all duration-200 ${tn?"border-blue-400 bg-blue-50/50 shadow-md":"border-neutral-200"}`,children:[s.jsx(wr,{files:vl,onRemove:_l}),s.jsx("textarea",{ref:z,value:m,onChange:Al,onPaste:wl,onKeyDown:G=>{Ve.handleKeyDown(G)||Pe.handleKeyDown(G)||G.key==="Enter"&&!G.shiftKey&&!G.repeat&&!G.nativeEvent.isComposing&&G.nativeEvent.keyCode!==229&&(G.preventDefault(),en())},rows:1,placeholder:p(tn?"Drop files here...":ze&&!qe?"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-neutral-900 placeholder-neutral-400 leading-relaxed",style:{minHeight:"60px",maxHeight:"300px"}}),s.jsx("input",{ref:A,type:"file",multiple:!0,className:"hidden",onChange:Sl}),s.jsxs("div",{className:"flex items-center justify-between px-2 pb-2 pt-1",children:[s.jsx("div",{className:"flex items-center gap-1",children:s.jsx("button",{onClick:()=>A.current?.click(),className:"p-2 text-neutral-400 hover:text-neutral-600 hover:bg-neutral-100 rounded-lg transition-colors",title:p("Upload file"),children:s.jsx(mr,{size:18})})}),s.jsxs("div",{className:"flex items-center gap-2",children:[_e&&Te&&s.jsx(Ka,{providers:Te,currentProviderId:Ne,agentType:_e.agentType,onSelect:Ee}),s.jsx(ta,{usage:bl}),qe&&!m.trim()&&!ms?s.jsx("button",{onClick:yl,disabled:Ar.isPending,className:"p-2 rounded-lg transition-all duration-200 bg-red-500 text-white hover:bg-red-600 shadow-md disabled:opacity-50",children:s.jsx(os,{size:14})}):s.jsx("button",{onClick:en,disabled:!m.trim()&&!ms||Ws,className:`p-2 rounded-lg transition-all duration-200 ${(m.trim()||ms)&&!Ws?"bg-neutral-900 text-white shadow-md hover:bg-black":"bg-transparent text-neutral-300 cursor-not-allowed"}`,children:s.jsx(wi,{size:18})})]})]})]}),s.jsx(dr,{open:Pe.query!==null,anchorRef:O,commands:Pe.filteredCommands,selectedIndex:Pe.selectedIndex,query:Pe.query??"",hasCatalog:Pe.allCommands.length>0,onSelect:Pe.applyCommand}),s.jsx(dr,{open:Ve.query!==null,anchorRef:O,commands:Ve.filteredSkills,selectedIndex:Ve.selectedIndex,query:Ve.query??"",hasCatalog:Ve.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",onSelect:Ve.applySkill})]})]})}),J&&s.jsx("div",{className:"w-1 cursor-col-resize hover:bg-neutral-200 active:bg-blue-400 transition-colors z-30 flex-shrink-0 border-l border-neutral-200",onMouseDown:jl}),J&&s.jsx("div",{className:"flex-1 flex flex-col min-w-0 bg-white",children:s.jsx(Ia,{sessionId:ze||void 0,workspaceId:Le,workingDir:ft,projectId:e.projectId,readOnly:q,repoDeleted:Q,teamRun:pe,teamStatus:pe?s.jsx(aa,{teamRun:pe,workspaces:K,selectedWorkspaceId:Le,onSelectWorkspace:D,onViewInvocationSession:Ki}):void 0})})]}),!q&&s.jsx(Ua,{isOpen:i,onClose:()=>n(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),je&&!q&&s.jsx(F0,{isOpen:c,onClose:()=>f(!1),taskId:e.id}),Xe&&Ce&&!q&&s.jsx(G0,{open:S,onOpenChange:k,workspaceId:Ce,branchName:st,targetBranch:pt,commitMessage:Je,onRefreshCommitMessage:oe,onConflict:Xi}),Xe&&rt&&Me&&s.jsx(X0,{open:h,onOpenChange:G=>{d(G),G||x(null)},workspaceId:rt,conflictOp:Me.conflictOp,conflictedFiles:Me.conflictedFiles,sourceBranch:xt,targetBranch:Ie,operation:He?.operation,worktreePath:ht,mergeAborted:Me.mergeAborted,mergeStrategy:Me.mergeStrategy,sourceWorkspaceId:Me.sourceWorkspaceId,targetWorkspaceId:Me.targetWorkspaceId,sourceWorktreePath:Me.sourceWorktreePath,targetWorktreePath:Me.targetWorktreePath,sessions:We,currentSessionId:Ze?void 0:ze,teamRunId:pe?.id}),s.jsx(Zs,{isOpen:b,onClose:()=>y(!1),onConfirm:nt,title:p("重新开始任务"),description:s.jsx("p",{children:p("将归档当前工作区并自动在新 Worktree 中重新启动 Agent,旧工作区内容保留供参考。")}),confirmText:p("确认重试"),variant:"default",isLoading:_}),s.jsx(Zs,{isOpen:l,onClose:()=>g(!1),onConfirm:Dt,title:p("删除任务"),description:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:p("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),sn.length>0&&s.jsx("ul",{className:"mt-2 space-y-1",children:sn.map((G,de)=>s.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[s.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),s.jsx("span",{children:G})]},de))})]}),confirmText:p("删除"),variant:"danger",isLoading:r})]}):s.jsx(xg,{})}function qi(e){switch(e){case jt.TODO:return ge.Pending;case jt.IN_PROGRESS:return ge.Running;case jt.IN_REVIEW:return ge.Review;case jt.DONE:return ge.Done;case jt.CANCELLED:return ge.Cancelled}}function Sg(e){switch(e){case ge.Pending:return jt.TODO;case ge.Running:return jt.IN_PROGRESS;case ge.Review:return jt.IN_REVIEW;case ge.Done:return jt.DONE;case ge.Cancelled:return jt.CANCELLED}}function wg(e){switch(e){case Nt.CLAUDE_CODE:return"Claude Code";case Nt.GEMINI_CLI:return"Gemini CLI";case Nt.CURSOR_AGENT:return"Cursor Agent";case Nt.CODEX:return"Codex"}}const ur=["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 Ja(e,t){let r=0;for(let a=0;a<e.length;a++)r=(r<<5)-r+e.charCodeAt(a)|0;return Math.abs(r)%t}function el(e,t){return t??e?.find(r=>r.status==="ACTIVE")??e?.[0]}function Cg(e){return{id:e.id,name:e.name,color:e.color||ur[Ja(e.name,ur.length)],archivedAt:e.archivedAt??null,repoDeletedAt:e.repoDeletedAt??null}}function kg(e){const t=el(e);if(!t)return{agent:"—",branch:"—"};const r=t.branchName,a=t.sessions;if(a&&a.length>0){const p=a[a.length-1];return{agent:wg(p.agentType),branch:r}}return{agent:"—",branch:r}}function Eg(e){const{agent:t,branch:r}=kg(e.workspaces),a=e.project;return{id:e.id,projectId:e.projectId,title:e.title,status:qi(e.status),agent:t,branch:r,description:e.description??"",projectArchivedAt:a?.archivedAt??null,projectRepoDeletedAt:a?.repoDeletedAt??null}}function jg(e,t,r){const a=el(e.workspaces,r),p=a?.branchName??"—";return{id:e.id,projectId:t.id,projectName:t.name,projectColor:t.color||ur[Ja(t.name,ur.length)],title:e.title,status:qi(e.status),branch:p,mainBranch:a?.baseBranch??t.mainBranch??"main",description:e.description??"",projectArchivedAt:t.archivedAt??null,projectRepoDeletedAt:t.repoDeletedAt??null}}const co={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 Ng(e){const t=e.split("/");return t[t.length-1]||e}function Ag(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Rg({workingDir:e,filePath:t,type:r}){const{t:a}=ne(),{data:p,isLoading:m,isError:v}=La(e,t,r);if(m)return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[s.jsx(Ke,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(v)return s.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:a("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return s.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:a("No diff content available.")});const n=i.split(`
82
+ `);return s.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((c,f)=>{let l="",g="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(l="bg-emerald-950/40",g="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(l="bg-red-950/40",g="text-red-400"):c.startsWith("@@")&&(l="bg-blue-950/30",g="text-blue-400"),s.jsx("div",{className:se("px-3 whitespace-pre",l,g),children:c},f)})})}function Tg({entry:e,type:t,workingDir:r}){const[a,p]=C.useState(!1),m=co[e.status]||co.M,v=Ag(e.path);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>p(i=>!i),className:se("flex items-center gap-2.5 w-full px-4 py-3 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[s.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Ng(e.path)}),v&&s.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),s.jsx("span",{className:"text-neutral-400 shrink-0",children:a?s.jsx(_t,{size:14}):s.jsx(Tt,{size:14})})]}),a&&s.jsx(Rg,{workingDir:r,filePath:e.path,type:t})]})}function uo({title:e,entries:t,type:r,workingDir:a,defaultOpen:p}){const{t:m}=ne(),[v,i]=C.useState(p);return t.length===0?null:s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>i(n=>!n),className:"flex items-center gap-2 w-full px-4 py-2.5 active:bg-neutral-50",children:[s.jsx("span",{className:"text-neutral-400",children:v?s.jsx(_t,{size:14}):s.jsx(Tt,{size:14})}),s.jsx("span",{className:"text-xs font-semibold text-neutral-500 uppercase tracking-wider",children:m(e)}),s.jsx("span",{className:"text-[10px] bg-neutral-100 px-1.5 py-0.5 rounded text-neutral-500",children:t.length})]}),v&&s.jsx("div",{className:"divide-y divide-neutral-100",children:t.map(n=>s.jsx(Tg,{entry:n,type:r,workingDir:a},`${r}:${n.path}`))})]})}function Mg({workingDir:e}){const{t}=ne(),{data:r,isLoading:a,isError:p}=Da(e);if(!e)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")});if(a)return s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[s.jsx(Ke,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading changes...")})]});if(p)return s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load changes.")});const m=r?.uncommitted||[],v=r?.committed||[];return m.length+v.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[s.jsx(ls,{size:28,className:"mb-3"}),s.jsx("span",{className:"text-sm",children:t("No pending changes")})]}):s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[s.jsx(uo,{title:"Uncommitted",entries:m,type:"uncommitted",workingDir:e,defaultOpen:!0}),s.jsx(uo,{title:"Committed",entries:v,type:"committed",workingDir:e,defaultOpen:!1})]})}const Qr=50,ho={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 Dg(e){const r=Math.floor(Date.now()/1e3)-e;return r<60?It("{count}s ago",{count:r}):r<3600?It("{count}m ago",{count:Math.floor(r/60)}):r<86400?It("{count}h ago",{count:Math.floor(r/3600)}):r<604800?It("{count}d ago",{count:Math.floor(r/86400)}):new Date(e*1e3).toLocaleDateString()}function Lg(e){const t=e.split("/");return t[t.length-1]||e}function Pg(e){const t=e.lastIndexOf("/");return t>0?e.slice(0,t):""}function Og({workingDir:e,hash:t,filePath:r}){const{t:a}=ne(),{data:p,isLoading:m,isError:v}=Oa(e,t,r);if(m)return s.jsxs("div",{className:"flex items-center gap-2 px-3 py-4 text-neutral-400",children:[s.jsx(Ke,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:a("Loading diff...")})]});if(v)return s.jsx("div",{className:"px-3 py-3 text-xs text-red-500",children:a("Failed to load diff.")});const i=p?.diff||"";if(!i.trim())return s.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:a("No diff content available.")});const n=i.split(`
83
+ `);return s.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((c,f)=>{let l="",g="text-neutral-400";return c.startsWith("+")&&!c.startsWith("+++")?(l="bg-emerald-950/40",g="text-emerald-400"):c.startsWith("-")&&!c.startsWith("---")?(l="bg-red-950/40",g="text-red-400"):c.startsWith("@@")&&(l="bg-blue-950/30",g="text-blue-400"),s.jsx("div",{className:se("px-3 whitespace-pre",l,g),children:c},f)})})}function Ig({entry:e,workingDir:t,hash:r}){const[a,p]=C.useState(!1),m=ho[e.status]||ho.M,v=Pg(e.path);return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>p(i=>!i),className:se("flex items-center gap-2.5 w-full px-4 py-2.5 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[s.jsx("span",{className:se("w-5 h-5 flex items-center justify-center text-[10px] font-bold border rounded shrink-0",m),children:e.status}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("span",{className:"text-sm text-neutral-900 truncate block",children:Lg(e.path)}),v&&s.jsx("span",{className:"text-[11px] text-neutral-400 truncate block",children:v})]}),s.jsx("span",{className:"text-neutral-400 shrink-0",children:a?s.jsx(_t,{size:14}):s.jsx(Tt,{size:14})})]}),a&&s.jsx(Og,{workingDir:t,hash:r,filePath:e.path})]})}function Bg({commit:e,workingDir:t}){const{t:r}=ne(),[a,p]=C.useState(!1),{data:m,isLoading:v}=Pa(t,a?e.hash:null),i=m?.files||[];return s.jsxs("div",{children:[s.jsxs("button",{onClick:()=>p(n=>!n),className:se("flex items-start gap-3 w-full px-4 py-3 text-left active:bg-neutral-50",a&&"bg-neutral-50"),children:[s.jsx("div",{className:"flex flex-col items-center shrink-0 pt-0.5",children:s.jsx("div",{className:se("w-2.5 h-2.5 rounded-full shrink-0",a?"bg-blue-500":"bg-neutral-300")})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("span",{className:"text-xs font-mono text-blue-600 shrink-0",children:e.shortHash}),s.jsx("span",{className:"text-sm text-neutral-900 truncate flex-1",children:e.message})]}),s.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.jsx("span",{className:"text-[11px] text-neutral-500 truncate",children:e.author}),s.jsx("span",{className:"text-[11px] text-neutral-400",children:Dg(e.timestamp)})]})]}),s.jsx("span",{className:"text-neutral-400 shrink-0 pt-0.5",children:a?s.jsx(_t,{size:14}):s.jsx(Tt,{size:14})})]}),a&&s.jsxs("div",{className:"pl-4 border-l-2 border-blue-100 ml-[22px]",children:[e.body&&s.jsx("div",{className:"px-3 py-2 text-xs text-neutral-600 whitespace-pre-wrap leading-4",children:e.body}),v?s.jsxs("div",{className:"flex items-center gap-2 px-3 py-3 text-neutral-400",children:[s.jsx(Ke,{size:14,className:"animate-spin"}),s.jsx("span",{className:"text-xs",children:r("Loading files...")})]}):i.length===0?s.jsx("div",{className:"px-3 py-3 text-xs text-neutral-400",children:r("No files changed")}):s.jsx("div",{className:"divide-y divide-neutral-100",children:i.map(n=>s.jsx(Ig,{entry:n,workingDir:t,hash:e.hash},n.path))})]})]})}function Fg({workingDir:e}){const{t}=ne(),{data:r,isLoading:a,isError:p,fetchNextPage:m,hasNextPage:v,isFetchingNextPage:i}=Ro({queryKey:le.git.log(e||""),queryFn:({pageParam:c=0})=>me.get("/git/log",{params:{workingDir:e||"",limit:String(Qr),skip:String(c)}}),initialPageParam:0,getNextPageParam:(c,f)=>c.commits.length<Qr?void 0:f.length*Qr,enabled:!!e}),n=r?.pages.flatMap(c=>c.commits)||[];return e?a?s.jsxs("div",{className:"flex-1 flex items-center justify-center text-neutral-400",children:[s.jsx(Ke,{size:16,className:"animate-spin mr-2"}),s.jsx("span",{className:"text-sm",children:t("Loading history...")})]}):p?s.jsx("div",{className:"flex-1 flex items-center justify-center text-red-500 text-sm",children:t("Failed to load history.")}):n.length===0?s.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-neutral-400 py-16",children:[s.jsx(cs,{size:28,className:"mb-3"}),s.jsx("span",{className:"text-sm",children:t("No commit history")})]}):s.jsxs("div",{className:"flex-1 overflow-y-auto scrollbar-app-thin overscroll-y-contain",children:[s.jsx("div",{className:"divide-y divide-neutral-100",children:n.map(c=>s.jsx(Bg,{commit:c,workingDir:e},c.hash))}),v&&s.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?s.jsxs(s.Fragment,{children:[s.jsx(Ke,{size:14,className:"animate-spin"})," ",t("Loading...")]}):t("Load more")})]}):s.jsx("div",{className:"flex-1 flex items-center justify-center text-neutral-400 text-sm",children:t("No workspace selected.")})}const zg="/api",Hg=e=>e.includes("://")||e.startsWith("/api/")?e:e.startsWith("/")?`${zg}/attachments/by-path?path=${encodeURIComponent(e)}`:e,Wg=({src:e,alt:t,...r})=>s.jsx("a",{href:e,target:"_blank",rel:"noopener noreferrer",className:"inline-block",children:s.jsx("img",{src:e,alt:t,...r,className:"max-w-[300px] max-h-[200px] object-contain rounded-lg border border-neutral-200 cursor-pointer active:opacity-90 transition-opacity"})}),$g={img:Wg};function Ug({status:e}){const t={[ge.Running]:"bg-blue-500",[ge.Review]:"bg-amber-500",[ge.Pending]:"bg-neutral-400",[ge.Done]:"bg-emerald-500",[ge.Cancelled]:"bg-neutral-400"};return s.jsx("span",{className:`w-2.5 h-2.5 rounded-full ${t[e]}`})}const qg=[{key:"chat",label:"Chat",icon:Js},{key:"changes",label:"Changes",icon:ls},{key:"history",label:"History",icon:cs},{key:"workspace",label:"Workspace",icon:Ei}],Kg=[{key:"chat",label:"Team room",icon:Js},{key:"team-status",label:"Team Status",icon:fr},{key:"changes",label:"Changes",icon:ls},{key:"workspace",label:"Workspace",icon:Ei}];function Xg({task:e,onBack:t,onDeleteTask:r,isDeleting:a}){const{t:p}=ne(),[m,v]=C.useState("chat"),[i,n]=C.useState(""),[c,f]=C.useState(!1),[l,g]=C.useState(!1),[b,y]=C.useState(!1),[_,o]=C.useState(null),[h,d]=C.useState(void 0),u=C.useRef(null),x=C.useRef(null),S=C.useRef(null),k=C.useRef(null),{scrollRef:E,contentRef:w,isAtBottom:j,scrollToBottom:R}=Bi({resize:"smooth",initial:"instant"}),L=Qe();C.useEffect(()=>{if(!b)return;const Y=oe=>{x.current&&!x.current.contains(oe.target)&&y(!1)};return document.addEventListener("mousedown",Y),()=>document.removeEventListener("mousedown",Y)},[b]);const{data:D,isLoading:N}=Fa(e.id),{data:M}=ko(e.id),{data:O}=Eo(M?.id??""),F=hi(M?.id??""),z=M??null,A=z?Kg:qg;C.useEffect(()=>{d(void 0),o(null)},[e.id]),C.useEffect(()=>{z&&m==="history"&&v("chat"),!z&&m==="team-status"&&v("chat")},[m,z]);const P=C.useMemo(()=>oa(D,z,h),[h,z,D]);C.useEffect(()=>{h&&!D?.some(Y=>Y.id===h)&&d(void 0)},[h,D]);const I=C.useMemo(()=>D?.find(Y=>Y.id===P),[P,D]),B=C.useMemo(()=>{if(!D)return null;const Y=D.filter(ee=>ee.status==="ACTIVE"&&Array.isArray(ee.sessions)).flatMap(ee=>ee.sessions??[]),oe=ee=>{const fe=ee.createdAt,Ae=ee.endedAt??ee.startedAt??fe;if(!Ae)return 0;const $e=Date.parse(Ae);return Number.isNaN($e)?0:$e},be=ee=>{const fe=Y.filter(Ae=>ee.includes(Ae.status));return fe.length===0?null:fe.sort((Ae,$e)=>oe($e)-oe(Ae))[0]??null},ye=be([Ge.RUNNING])??be([Ge.PENDING])??be([Ge.COMPLETED,Ge.FAILED,Ge.CANCELLED]);if(ye)return ye;const V=D.filter(ee=>(ee.status==="ABANDONED"||ee.status==="MERGED"||ee.status==="HIBERNATED")&&Array.isArray(ee.sessions)).flatMap(ee=>ee.sessions??[]).filter(ee=>[Ge.COMPLETED,Ge.FAILED,Ge.CANCELLED].includes(ee.status));return V.length===0?null:V.sort((ee,fe)=>oe(fe)-oe(ee))[0]??null},[D]),$=B?.id??"",X=z?_??"":$,J=C.useMemo(()=>{if(!_||!D)return null;for(const Y of D){const oe=Y.sessions?.find(be=>be.id===_);if(oe)return oe}return null},[_,D])??B??null,ae=J?.status===Ge.RUNNING||J?.status===Ge.PENDING,T=!!e.projectArchivedAt,H=!!e.projectRepoDeletedAt,U=p(H?"项目已删除,本地仓库文件也已清理。恢复项目并重新绑定仓库后才能继续操作。":"项目已删除。恢复项目后才能继续创建会话或修改任务。"),W=C.useMemo(()=>!B||!D?!1:!D.some(oe=>oe.status==="ACTIVE"&&oe.sessions?.some(be=>be.id===B.id)),[B,D]),{data:te}=Ds(),[K,ce]=C.useState(null),he=K?.sessionId===$?K.providerId:B?.providerId??null,ve=C.useCallback(Y=>{ce({sessionId:$,providerId:Y})},[$]),Fe=C.useMemo(()=>{if(D){if(I)return I.worktreePath||void 0;for(const Y of D)if(Y.status==="ACTIVE"&&Y.worktreePath)return Y.worktreePath;return D[0]?.worktreePath}},[I,D]),re=Qa({agentType:B?.agentType,workingDir:Fe,input:i,setInput:n,textareaRef:S,minHeight:40,maxHeight:140}),pe=Za({agentType:B?.agentType,workingDir:Fe,input:i,setInput:n,textareaRef:S,minHeight:40,maxHeight:140}),Ze=I?.worktreePath?I.id:void 0,je=C.useMemo(()=>{const Y=[];if(D&&D.length>0){const oe=D.some(ye=>ye.status==="ACTIVE");D.some(ye=>ye.sessions?.some(it=>it.status===Ge.RUNNING||it.status===Ge.PENDING))&&Y.push(p("正在运行的 Agent 将被停止")),oe&&(Y.push(p("分支上未合并的变更将丢失")),Y.push(p("关联的工作目录(worktree)将被清理")))}return Y},[D,p]),Le=Ui(),we=Wi(),Ce=Wa(),{isConnected:Xe,isLoadingSnapshot:_e,logs:ze,entries:ke,attach:Re}=jo({sessionId:X,sessionStatus:J?.status,onExit:C.useCallback(()=>{L.invalidateQueries({queryKey:["workspaces"]})},[L])}),{todos:tt}=No(ke),{files:qe,addFiles:q,removeFile:Q,clear:ue,buildMarkdownLinks:Te,hasFiles:Ne,isUploading:Ee}=Sr(),lt=C.useMemo(()=>{if(!B?.tokenUsage)return;const Y=B.tokenUsage;if(typeof Y.totalTokens=="number")return Y},[B?.tokenUsage]),ft=$a(ze,lt);C.useEffect(()=>{X&&Xe&&Re()},[X,Xe,Re]);const Pe=C.useRef(null);C.useEffect(()=>{if(Pe.current!==e.id&&E.current){const Y=E.current;requestAnimationFrame(()=>{Y.scrollTop=Y.scrollHeight})}Pe.current=e.id},[e.id,E]);const Ve=C.useRef(!1),He=C.useCallback(async()=>{if(!i.trim()&&!Ne||!$||Ve.current||Ee)return;Ve.current=!0;const Y=Te(),oe=[i.trim(),Y].filter(Boolean).join(`
84
+
85
+ `);n(""),ue(),S.current&&(S.current.style.height="40px"),Le.mutate({id:$,message:oe,providerId:he??void 0},{onSuccess:()=>Re(),onSettled:()=>{Ve.current=!1}})},[i,$,Le,Re,Ne,Ee,Te,ue,he]),We=C.useCallback(async()=>{$&&(await Ce.mutateAsync($),L.invalidateQueries({queryKey:["workspaces"]}))},[$,Ce,L]),st=C.useCallback(Y=>F.mutateAsync(Y),[F]),Je=C.useCallback(Y=>{o(Y),v("chat"),requestAnimationFrame(()=>{R()})},[R]),pt=C.useCallback(()=>{o(null)},[]),Me=C.useCallback(Y=>{const oe=Y.target.files;oe&&oe.length>0&&q(Array.from(oe)),Y.target.value=""},[q]),rt=C.useCallback(Y=>{const oe=Y.clipboardData.items,be=[];for(const ye of oe)if(ye.kind==="file"){const it=ye.getAsFile();it&&be.push(it)}be.length>0&&(Y.preventDefault(),q(be))},[q]),ht=C.useCallback(Y=>{n(Y.target.value);const oe=Y.target;oe.style.height="auto",oe.style.height=`${Math.max(40,Math.min(oe.scrollHeight,140))}px`},[]),xt=C.useCallback(()=>{Ze&&we.mutate({workspaceId:Ze})},[we,Ze]),Ie=C.useRef(null);return C.useEffect(()=>{const Y=window.visualViewport;if(!Y)return;let oe=!1;const be=()=>{Ie.current&&(Ie.current.style.height=`${Y.height}px`,Ie.current.style.top=`${Y.offsetTop}px`)},ye=()=>be(),it=()=>{oe||be()},V=()=>{oe=!0},ee=()=>{oe=!1,requestAnimationFrame(be)};return Y.addEventListener("resize",ye),Y.addEventListener("scroll",it),document.addEventListener("touchstart",V,{passive:!0}),document.addEventListener("touchend",ee,{passive:!0}),document.addEventListener("touchcancel",ee,{passive:!0}),()=>{Y.removeEventListener("resize",ye),Y.removeEventListener("scroll",it),document.removeEventListener("touchstart",V),document.removeEventListener("touchend",ee),document.removeEventListener("touchcancel",ee)}},[]),C.useEffect(()=>{const Y=Ie.current;if(!Y)return;const oe=be=>{let ye=be.target;for(;ye&&ye!==Y;){if(ye.tagName==="TEXTAREA"){if(ye.scrollHeight>ye.clientHeight)return;ye=ye.parentElement;continue}const V=window.getComputedStyle(ye).overflowY;if((V==="auto"||V==="scroll")&&ye.scrollHeight>ye.clientHeight)return;ye=ye.parentElement}be.preventDefault()};return Y.addEventListener("touchmove",oe,{passive:!1}),()=>Y.removeEventListener("touchmove",oe)},[]),s.jsxs("div",{ref:Ie,className:"fixed inset-x-0 top-0 flex flex-col h-dvh bg-white overflow-hidden overscroll-none",children:[s.jsxs("header",{className:"shrink-0 bg-white border-b border-neutral-200 z-20",children:[s.jsxs("div",{className:"flex items-center h-11 px-2.5 gap-1.5",children:[s.jsx("button",{onClick:t,className:"p-1.5 -ml-0.5 text-neutral-600 active:text-neutral-900",children:s.jsx(Vl,{size:18})}),s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("h1",{className:"text-[13px] font-bold text-neutral-900 truncate leading-tight",children:e.title}),s.jsxs("div",{className:"flex min-w-0 items-center gap-1 text-[11px] text-neutral-500 leading-tight",children:[s.jsx("span",{className:`truncate font-medium ${e.projectColor}`,children:e.projectName}),e.projectArchivedAt&&s.jsx("span",{className:"rounded-full bg-neutral-100 px-1.5 py-0.5 text-[10px] font-medium text-neutral-500",children:e.projectRepoDeletedAt?p("源码已删除"):p("已删除")}),s.jsx("span",{className:"text-neutral-300",children:"/"}),s.jsx("span",{className:"font-mono truncate",children:e.branch})]})]}),s.jsx(Ug,{status:e.status}),s.jsx("button",{onClick:xt,disabled:!Ze||T,className:"p-1.5 text-neutral-400 active:text-neutral-900 disabled:opacity-30",children:s.jsx(pr,{size:16})}),r&&!T&&s.jsxs("div",{className:"relative",ref:x,children:[s.jsx("button",{onClick:()=>y(Y=>!Y),className:"p-1.5 text-neutral-400 active:text-neutral-900","aria-label":"More actions",children:s.jsx(Mo,{size:16})}),b&&s.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:s.jsxs("button",{onClick:()=>{g(!0),y(!1)},className:"w-full flex items-center gap-2 px-3 py-2 text-sm text-red-600 active:bg-red-50",children:[s.jsx(bi,{size:15}),s.jsx("span",{children:p("删除任务")})]})})]})]}),s.jsx("div",{className:"flex border-t border-neutral-100",children:A.map(({key:Y,label:oe,icon:be})=>s.jsxs("button",{onClick:()=>v(Y),className:`flex min-w-0 flex-1 items-center justify-center gap-1 px-1 py-2 text-[11px] font-medium transition-colors ${m===Y?"text-neutral-900 border-b-2 border-neutral-900":"text-neutral-400 border-b-2 border-transparent"}`,children:[s.jsx(be,{size:13,className:"shrink-0"}),s.jsx("span",{className:"truncate",children:p(oe)})]},Y))})]}),m==="chat"&&(z?s.jsx("main",{className:"flex-1 min-h-0 overflow-hidden",children:_?s.jsxs("div",{className:"flex h-full min-h-0 flex-col bg-white",children:[s.jsxs("div",{className:"flex shrink-0 items-center justify-between gap-3 border-b border-neutral-200 px-3 py-2.5",children:[s.jsxs("div",{className:"min-w-0",children:[s.jsx("div",{className:"text-xs font-semibold text-neutral-900",children:p("Invocation details")}),s.jsx("div",{className:"truncate text-[11px] text-neutral-500",children:_})]}),s.jsx(De,{type:"button",size:"sm",variant:"outline",onClick:pt,children:p("Back to room")})]}),s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:E,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:s.jsx("div",{ref:w,children:_e?s.jsx(Zr,{label:p("Loading logs...")}):ze.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:p(ae?"Waiting for agent output...":"No logs recorded for this session.")}):s.jsx(Qs,{logs:ze})})}),!j&&s.jsxs("button",{onClick:()=>R(),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":p("Scroll to bottom"),children:[s.jsx(Cs,{size:12}),s.jsx("span",{children:p("回到底部")})]})]})]}):s.jsx(ia,{teamRun:z,messages:O??z.messages??[],readOnly:T,readOnlyMessage:U,onSendMessage:st,onViewInvocationSession:Je,compactComposer:!0})}):s.jsxs("div",{className:"flex-1 flex flex-col min-h-0",children:[s.jsxs("div",{className:"relative flex-1 min-h-0",children:[s.jsx("div",{ref:E,className:"h-full overflow-y-auto overflow-x-hidden scrollbar-app-thin overscroll-y-contain px-3 pt-3 pb-2",children:s.jsxs("div",{ref:w,children:[s.jsx("div",{className:"mb-3 pb-2 border-b border-neutral-100",children:e.description?s.jsx("div",{className:"text-[13px] text-neutral-500 leading-relaxed prose prose-sm max-w-none",children:s.jsx(_i,{urlTransform:Hg,components:$g,children:e.description})}):s.jsx("p",{className:"text-[13px] text-neutral-400 italic",children:"No description"})}),N?s.jsx(Zr,{label:"Loading..."}):$?_e?s.jsx(Zr,{label:"Loading logs..."}):ze.length===0?s.jsx("div",{className:"text-neutral-400 text-center py-8 text-sm",children:ae?"Waiting for agent output...":"No logs recorded."}):s.jsx(Qs,{logs:ze}):s.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[s.jsx("div",{className:"w-12 h-12 bg-neutral-50 rounded-xl border border-neutral-100 flex items-center justify-center mb-4",children:s.jsx(qt,{size:20,className:"text-neutral-400 ml-0.5"})}),s.jsx("h3",{className:"text-sm font-medium text-neutral-900 mb-1",children:p("尚未启动 Agent")}),s.jsx("p",{className:"text-xs text-neutral-500 mb-5 max-w-[240px]",children:T?U:p("选择一个 Agent 来执行此任务")}),!T&&s.jsxs(De,{onClick:()=>f(!0),children:[s.jsx(qt,{size:16,className:"mr-1.5"}),p("启动 Agent")]})]})]})}),!j&&s.jsxs("button",{onClick:()=>R(),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:[s.jsx(Cs,{size:12}),s.jsx("span",{children:p("回到底部")})]})]}),tt.length>0&&s.jsx("div",{className:"px-3 pt-1.5 pb-0.5 bg-white shrink-0 border-t border-neutral-100",children:s.jsx(Ao,{todos:tt,compact:!0})}),T?s.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:s.jsx("div",{className:"rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2 text-xs text-neutral-500",children:U})}):W?s.jsx("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:s.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-xl border border-neutral-200 bg-neutral-50 px-3 py-2",children:[s.jsx("span",{className:"text-xs text-neutral-500",children:p("代码已合并,以上为历史沟通记录")}),s.jsxs(De,{size:"sm",onClick:()=>f(!0),children:[s.jsx(qt,{size:14,className:"mr-1.5"}),p("启动新 Agent")]})]})}):$&&s.jsxs("div",{className:"px-3 py-2 bg-white shrink-0 border-t border-neutral-100",children:[s.jsxs("div",{ref:u,className:"relative bg-white rounded-xl border border-neutral-200 shadow-sm focus-within:border-neutral-300",children:[s.jsx(wr,{files:qe,onRemove:Q}),s.jsx("textarea",{ref:S,value:i,onChange:ht,onPaste:rt,onKeyDown:Y=>{pe.handleKeyDown(Y)||re.handleKeyDown(Y)||Y.key==="Enter"&&!Y.shiftKey&&!Y.repeat&&!Y.nativeEvent.isComposing&&Y.nativeEvent.keyCode!==229&&(Y.preventDefault(),He())},rows:1,placeholder:ae?"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}}),s.jsx("input",{ref:k,type:"file",multiple:!0,className:"hidden",onChange:Me}),s.jsxs("div",{className:"flex items-center justify-between px-2 pb-1.5",children:[s.jsx("div",{className:"flex items-center gap-0.5",children:s.jsx("button",{onClick:()=>k.current?.click(),className:"p-1 text-neutral-400 active:text-neutral-600 rounded-lg",children:s.jsx(mr,{size:15})})}),s.jsxs("div",{className:"flex items-center gap-1",children:[B&&te&&s.jsx(Ka,{providers:te,currentProviderId:he,agentType:B.agentType,onSelect:ve}),s.jsx(ta,{usage:ft}),ae&&!i.trim()&&!Ne?s.jsx("button",{onClick:We,disabled:Ce.isPending,className:"p-1.5 rounded-lg bg-red-500 text-white active:bg-red-600 disabled:opacity-50",children:s.jsx(os,{size:12})}):s.jsx("button",{onClick:He,disabled:!i.trim()&&!Ne||Ee,className:`p-1.5 rounded-lg transition-colors ${(i.trim()||Ne)&&!Ee?"bg-neutral-900 text-white active:bg-black":"bg-transparent text-neutral-300"}`,children:s.jsx(wi,{size:15})})]})]})]}),s.jsx(dr,{open:re.query!==null,anchorRef:u,commands:re.filteredCommands,selectedIndex:re.selectedIndex,query:re.query??"",hasCatalog:re.allCommands.length>0,compact:!0,onSelect:re.applyCommand}),s.jsx(dr,{open:pe.query!==null,anchorRef:u,commands:pe.filteredSkills,selectedIndex:pe.selectedIndex,query:pe.query??"",hasCatalog:pe.allSkills.length>0,title:"Skills",queryPrefix:"$",emptyCatalogMessage:"No skills catalog for this agent yet.",compact:!0,onSelect:pe.applySkill})]})]})),m==="team-status"&&z&&s.jsx("div",{className:"flex-1 min-h-0 overflow-hidden",children:s.jsx(aa,{teamRun:z,workspaces:D,selectedWorkspaceId:P,onSelectWorkspace:d,onViewInvocationSession:Je})}),m==="changes"&&s.jsxs("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:[D&&D.length>1&&s.jsx("div",{className:"shrink-0 border-b border-neutral-100 bg-white px-3 py-2",children:s.jsx(Ba,{workspaces:D,teamRun:z,selectedWorkspaceId:P,onSelectWorkspace:d,className:"w-full",buttonClassName:"w-full max-w-none min-w-0 justify-start"})}),s.jsx(Mg,{workingDir:Fe})]}),m==="history"&&s.jsx("div",{className:"flex-1 flex flex-col min-h-0 overflow-hidden",children:s.jsx(Fg,{workingDir:Fe})}),m==="workspace"&&s.jsx("div",{className:"flex-1 overflow-hidden",children:s.jsx(Ia,{sessionId:$||void 0,workspaceId:P,workingDir:Fe,projectId:e.projectId,className:"h-full",hideChanges:!0,readOnly:T,repoDeleted:H})}),!T&&s.jsx(Ua,{isOpen:c,onClose:()=>f(!1),taskId:e.id,taskTitle:e.title,taskDescription:e.description}),s.jsx(Zs,{isOpen:l,onClose:()=>g(!1),onConfirm:()=>{r?.(e.id),g(!1)},title:p("删除任务"),description:s.jsxs(s.Fragment,{children:[s.jsx("p",{children:p("确认删除任务「{title}」?此操作不可撤销。",{title:e.title})}),je.length>0&&s.jsx("ul",{className:"mt-2 space-y-1",children:je.map((Y,oe)=>s.jsxs("li",{className:"flex items-start gap-1.5 text-amber-600",children:[s.jsx("span",{className:"mt-1 shrink-0 w-1.5 h-1.5 rounded-full bg-amber-400"}),s.jsx("span",{children:Y})]},oe))})]}),confirmText:p("删除"),variant:"danger",isLoading:a})]})}function Zr({label:e}){return s.jsxs("div",{className:"flex items-center justify-center py-12 gap-3 text-neutral-400",children:[s.jsxs("svg",{className:"animate-spin h-5 w-5",xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",children:[s.jsx("circle",{className:"opacity-25",cx:"12",cy:"12",r:"10",stroke:"currentColor",strokeWidth:"4"}),s.jsx("path",{className:"opacity-75",fill:"currentColor",d:"M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4z"})]}),s.jsx("span",{className:"text-sm",children:e})]})}var Vg=Object.defineProperty,hr=Object.getOwnPropertySymbols,tl=Object.prototype.hasOwnProperty,sl=Object.prototype.propertyIsEnumerable,fo=(e,t,r)=>t in e?Vg(e,t,{enumerable:!0,configurable:!0,writable:!0,value:r}):e[t]=r,ci=(e,t)=>{for(var r in t||(t={}))tl.call(t,r)&&fo(e,r,t[r]);if(hr)for(var r of hr(t))sl.call(t,r)&&fo(e,r,t[r]);return e},di=(e,t)=>{var r={};for(var a in e)tl.call(e,a)&&t.indexOf(a)<0&&(r[a]=e[a]);if(e!=null&&hr)for(var a of hr(e))t.indexOf(a)<0&&sl.call(e,a)&&(r[a]=e[a]);return r};var Vt;(e=>{const t=class Se{constructor(n,c,f,l){if(this.version=n,this.errorCorrectionLevel=c,this.modules=[],this.isFunction=[],n<Se.MIN_VERSION||n>Se.MAX_VERSION)throw new RangeError("Version value out of range");if(l<-1||l>7)throw new RangeError("Mask value out of range");this.size=n*4+17;let g=[];for(let y=0;y<this.size;y++)g.push(!1);for(let y=0;y<this.size;y++)this.modules.push(g.slice()),this.isFunction.push(g.slice());this.drawFunctionPatterns();const b=this.addEccAndInterleave(f);if(this.drawCodewords(b),l==-1){let y=1e9;for(let _=0;_<8;_++){this.applyMask(_),this.drawFormatBits(_);const o=this.getPenaltyScore();o<y&&(l=_,y=o),this.applyMask(_)}}p(0<=l&&l<=7),this.mask=l,this.applyMask(l),this.drawFormatBits(l),this.isFunction=[]}static encodeText(n,c){const f=e.QrSegment.makeSegments(n);return Se.encodeSegments(f,c)}static encodeBinary(n,c){const f=e.QrSegment.makeBytes(n);return Se.encodeSegments([f],c)}static encodeSegments(n,c,f=1,l=40,g=-1,b=!0){if(!(Se.MIN_VERSION<=f&&f<=l&&l<=Se.MAX_VERSION)||g<-1||g>7)throw new RangeError("Invalid value");let y,_;for(y=f;;y++){const u=Se.getNumDataCodewords(y,c)*8,x=v.getTotalBits(n,y);if(x<=u){_=x;break}if(y>=l)throw new RangeError("Data too long")}for(const u of[Se.Ecc.MEDIUM,Se.Ecc.QUARTILE,Se.Ecc.HIGH])b&&_<=Se.getNumDataCodewords(y,u)*8&&(c=u);let o=[];for(const u of n){r(u.mode.modeBits,4,o),r(u.numChars,u.mode.numCharCountBits(y),o);for(const x of u.getData())o.push(x)}p(o.length==_);const h=Se.getNumDataCodewords(y,c)*8;p(o.length<=h),r(0,Math.min(4,h-o.length),o),r(0,(8-o.length%8)%8,o),p(o.length%8==0);for(let u=236;o.length<h;u^=253)r(u,8,o);let d=[];for(;d.length*8<o.length;)d.push(0);return o.forEach((u,x)=>d[x>>>3]|=u<<7-(x&7)),new Se(y,c,d,g)}getModule(n,c){return 0<=n&&n<this.size&&0<=c&&c<this.size&&this.modules[c][n]}getModules(){return this.modules}drawFunctionPatterns(){for(let f=0;f<this.size;f++)this.setFunctionModule(6,f,f%2==0),this.setFunctionModule(f,6,f%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const n=this.getAlignmentPatternPositions(),c=n.length;for(let f=0;f<c;f++)for(let l=0;l<c;l++)f==0&&l==0||f==0&&l==c-1||f==c-1&&l==0||this.drawAlignmentPattern(n[f],n[l]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(n){const c=this.errorCorrectionLevel.formatBits<<3|n;let f=c;for(let g=0;g<10;g++)f=f<<1^(f>>>9)*1335;const l=(c<<10|f)^21522;p(l>>>15==0);for(let g=0;g<=5;g++)this.setFunctionModule(8,g,a(l,g));this.setFunctionModule(8,7,a(l,6)),this.setFunctionModule(8,8,a(l,7)),this.setFunctionModule(7,8,a(l,8));for(let g=9;g<15;g++)this.setFunctionModule(14-g,8,a(l,g));for(let g=0;g<8;g++)this.setFunctionModule(this.size-1-g,8,a(l,g));for(let g=8;g<15;g++)this.setFunctionModule(8,this.size-15+g,a(l,g));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let n=this.version;for(let f=0;f<12;f++)n=n<<1^(n>>>11)*7973;const c=this.version<<12|n;p(c>>>18==0);for(let f=0;f<18;f++){const l=a(c,f),g=this.size-11+f%3,b=Math.floor(f/3);this.setFunctionModule(g,b,l),this.setFunctionModule(b,g,l)}}drawFinderPattern(n,c){for(let f=-4;f<=4;f++)for(let l=-4;l<=4;l++){const g=Math.max(Math.abs(l),Math.abs(f)),b=n+l,y=c+f;0<=b&&b<this.size&&0<=y&&y<this.size&&this.setFunctionModule(b,y,g!=2&&g!=4)}}drawAlignmentPattern(n,c){for(let f=-2;f<=2;f++)for(let l=-2;l<=2;l++)this.setFunctionModule(n+l,c+f,Math.max(Math.abs(l),Math.abs(f))!=1)}setFunctionModule(n,c,f){this.modules[c][n]=f,this.isFunction[c][n]=!0}addEccAndInterleave(n){const c=this.version,f=this.errorCorrectionLevel;if(n.length!=Se.getNumDataCodewords(c,f))throw new RangeError("Invalid argument");const l=Se.NUM_ERROR_CORRECTION_BLOCKS[f.ordinal][c],g=Se.ECC_CODEWORDS_PER_BLOCK[f.ordinal][c],b=Math.floor(Se.getNumRawDataModules(c)/8),y=l-b%l,_=Math.floor(b/l);let o=[];const h=Se.reedSolomonComputeDivisor(g);for(let u=0,x=0;u<l;u++){let S=n.slice(x,x+_-g+(u<y?0:1));x+=S.length;const k=Se.reedSolomonComputeRemainder(S,h);u<y&&S.push(0),o.push(S.concat(k))}let d=[];for(let u=0;u<o[0].length;u++)o.forEach((x,S)=>{(u!=_-g||S>=y)&&d.push(x[u])});return p(d.length==b),d}drawCodewords(n){if(n.length!=Math.floor(Se.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let c=0;for(let f=this.size-1;f>=1;f-=2){f==6&&(f=5);for(let l=0;l<this.size;l++)for(let g=0;g<2;g++){const b=f-g,_=(f+1&2)==0?this.size-1-l:l;!this.isFunction[_][b]&&c<n.length*8&&(this.modules[_][b]=a(n[c>>>3],7-(c&7)),c++)}}p(c==n.length*8)}applyMask(n){if(n<0||n>7)throw new RangeError("Mask value out of range");for(let c=0;c<this.size;c++)for(let f=0;f<this.size;f++){let l;switch(n){case 0:l=(f+c)%2==0;break;case 1:l=c%2==0;break;case 2:l=f%3==0;break;case 3:l=(f+c)%3==0;break;case 4:l=(Math.floor(f/3)+Math.floor(c/2))%2==0;break;case 5:l=f*c%2+f*c%3==0;break;case 6:l=(f*c%2+f*c%3)%2==0;break;case 7:l=((f+c)%2+f*c%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[c][f]&&l&&(this.modules[c][f]=!this.modules[c][f])}}getPenaltyScore(){let n=0;for(let g=0;g<this.size;g++){let b=!1,y=0,_=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[g][o]==b?(y++,y==5?n+=Se.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),b||(n+=this.finderPenaltyCountPatterns(_)*Se.PENALTY_N3),b=this.modules[g][o],y=1);n+=this.finderPenaltyTerminateAndCount(b,y,_)*Se.PENALTY_N3}for(let g=0;g<this.size;g++){let b=!1,y=0,_=[0,0,0,0,0,0,0];for(let o=0;o<this.size;o++)this.modules[o][g]==b?(y++,y==5?n+=Se.PENALTY_N1:y>5&&n++):(this.finderPenaltyAddHistory(y,_),b||(n+=this.finderPenaltyCountPatterns(_)*Se.PENALTY_N3),b=this.modules[o][g],y=1);n+=this.finderPenaltyTerminateAndCount(b,y,_)*Se.PENALTY_N3}for(let g=0;g<this.size-1;g++)for(let b=0;b<this.size-1;b++){const y=this.modules[g][b];y==this.modules[g][b+1]&&y==this.modules[g+1][b]&&y==this.modules[g+1][b+1]&&(n+=Se.PENALTY_N2)}let c=0;for(const g of this.modules)c=g.reduce((b,y)=>b+(y?1:0),c);const f=this.size*this.size,l=Math.ceil(Math.abs(c*20-f*10)/f)-1;return p(0<=l&&l<=9),n+=l*Se.PENALTY_N4,p(0<=n&&n<=2568888),n}getAlignmentPatternPositions(){if(this.version==1)return[];{const n=Math.floor(this.version/7)+2,c=this.version==32?26:Math.ceil((this.version*4+4)/(n*2-2))*2;let f=[6];for(let l=this.size-7;f.length<n;l-=c)f.splice(1,0,l);return f}}static getNumRawDataModules(n){if(n<Se.MIN_VERSION||n>Se.MAX_VERSION)throw new RangeError("Version number out of range");let c=(16*n+128)*n+64;if(n>=2){const f=Math.floor(n/7)+2;c-=(25*f-10)*f-55,n>=7&&(c-=36)}return p(208<=c&&c<=29648),c}static getNumDataCodewords(n,c){return Math.floor(Se.getNumRawDataModules(n)/8)-Se.ECC_CODEWORDS_PER_BLOCK[c.ordinal][n]*Se.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][n]}static reedSolomonComputeDivisor(n){if(n<1||n>255)throw new RangeError("Degree out of range");let c=[];for(let l=0;l<n-1;l++)c.push(0);c.push(1);let f=1;for(let l=0;l<n;l++){for(let g=0;g<c.length;g++)c[g]=Se.reedSolomonMultiply(c[g],f),g+1<c.length&&(c[g]^=c[g+1]);f=Se.reedSolomonMultiply(f,2)}return c}static reedSolomonComputeRemainder(n,c){let f=c.map(l=>0);for(const l of n){const g=l^f.shift();f.push(0),c.forEach((b,y)=>f[y]^=Se.reedSolomonMultiply(b,g))}return f}static reedSolomonMultiply(n,c){if(n>>>8||c>>>8)throw new RangeError("Byte out of range");let f=0;for(let l=7;l>=0;l--)f=f<<1^(f>>>7)*285,f^=(c>>>l&1)*n;return p(f>>>8==0),f}finderPenaltyCountPatterns(n){const c=n[1];p(c<=this.size*3);const f=c>0&&n[2]==c&&n[3]==c*3&&n[4]==c&&n[5]==c;return(f&&n[0]>=c*4&&n[6]>=c?1:0)+(f&&n[6]>=c*4&&n[0]>=c?1:0)}finderPenaltyTerminateAndCount(n,c,f){return n&&(this.finderPenaltyAddHistory(c,f),c=0),c+=this.size,this.finderPenaltyAddHistory(c,f),this.finderPenaltyCountPatterns(f)}finderPenaltyAddHistory(n,c){c[0]==0&&(n+=this.size),c.pop(),c.unshift(n)}};t.MIN_VERSION=1,t.MAX_VERSION=40,t.PENALTY_N1=3,t.PENALTY_N2=3,t.PENALTY_N3=40,t.PENALTY_N4=10,t.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]],t.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=t;function r(i,n,c){if(n<0||n>31||i>>>n)throw new RangeError("Value out of range");for(let f=n-1;f>=0;f--)c.push(i>>>f&1)}function a(i,n){return(i>>>n&1)!=0}function p(i){if(!i)throw new Error("Assertion error")}const m=class et{constructor(n,c,f){if(this.mode=n,this.numChars=c,this.bitData=f,c<0)throw new RangeError("Invalid argument");this.bitData=f.slice()}static makeBytes(n){let c=[];for(const f of n)r(f,8,c);return new et(et.Mode.BYTE,n.length,c)}static makeNumeric(n){if(!et.isNumeric(n))throw new RangeError("String contains non-numeric characters");let c=[];for(let f=0;f<n.length;){const l=Math.min(n.length-f,3);r(parseInt(n.substring(f,f+l),10),l*3+1,c),f+=l}return new et(et.Mode.NUMERIC,n.length,c)}static makeAlphanumeric(n){if(!et.isAlphanumeric(n))throw new RangeError("String contains unencodable characters in alphanumeric mode");let c=[],f;for(f=0;f+2<=n.length;f+=2){let l=et.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f))*45;l+=et.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f+1)),r(l,11,c)}return f<n.length&&r(et.ALPHANUMERIC_CHARSET.indexOf(n.charAt(f)),6,c),new et(et.Mode.ALPHANUMERIC,n.length,c)}static makeSegments(n){return n==""?[]:et.isNumeric(n)?[et.makeNumeric(n)]:et.isAlphanumeric(n)?[et.makeAlphanumeric(n)]:[et.makeBytes(et.toUtf8ByteArray(n))]}static makeEci(n){let c=[];if(n<0)throw new RangeError("ECI assignment value out of range");if(n<128)r(n,8,c);else if(n<16384)r(2,2,c),r(n,14,c);else if(n<1e6)r(6,3,c),r(n,21,c);else throw new RangeError("ECI assignment value out of range");return new et(et.Mode.ECI,0,c)}static isNumeric(n){return et.NUMERIC_REGEX.test(n)}static isAlphanumeric(n){return et.ALPHANUMERIC_REGEX.test(n)}getData(){return this.bitData.slice()}static getTotalBits(n,c){let f=0;for(const l of n){const g=l.mode.numCharCountBits(c);if(l.numChars>=1<<g)return 1/0;f+=4+g+l.bitData.length}return f}static toUtf8ByteArray(n){n=encodeURI(n);let c=[];for(let f=0;f<n.length;f++)n.charAt(f)!="%"?c.push(n.charCodeAt(f)):(c.push(parseInt(n.substring(f+1,f+3),16)),f+=2);return c}};m.NUMERIC_REGEX=/^[0-9]*$/,m.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,m.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let v=m;e.QrSegment=m})(Vt||(Vt={}));(e=>{(t=>{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),t.Ecc=r})(e.QrCode||(e.QrCode={}))})(Vt||(Vt={}));(e=>{(t=>{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]),t.Mode=r})(e.QrSegment||(e.QrSegment={}))})(Vt||(Vt={}));var rs=Vt;var Yg={L:rs.QrCode.Ecc.LOW,M:rs.QrCode.Ecc.MEDIUM,Q:rs.QrCode.Ecc.QUARTILE,H:rs.QrCode.Ecc.HIGH},rl=128,il="L",nl="#FFFFFF",ol="#000000",al=!1,ll=1,Gg=4,Qg=0,Zg=.1;function cl(e,t=0){const r=[];return e.forEach(function(a,p){let m=null;a.forEach(function(v,i){if(!v&&m!==null){r.push(`M${m+t} ${p+t}h${i-m}v1H${m+t}z`),m=null;return}if(i===a.length-1){if(!v)return;m===null?r.push(`M${i+t},${p+t} h1v1H${i+t}z`):r.push(`M${m+t},${p+t} h${i+1-m}v1H${m+t}z`);return}v&&m===null&&(m=i)})}),r.join("")}function dl(e,t){return e.slice().map((r,a)=>a<t.y||a>=t.y+t.h?r:r.map((p,m)=>m<t.x||m>=t.x+t.w?p:!1))}function Jg(e,t,r,a){if(a==null)return null;const p=e.length+r*2,m=Math.floor(t*Zg),v=p/t,i=(a.width||m)*v,n=(a.height||m)*v,c=a.x==null?e.length/2-i/2:a.x*v,f=a.y==null?e.length/2-n/2:a.y*v,l=a.opacity==null?1:a.opacity;let g=null;if(a.excavate){let y=Math.floor(c),_=Math.floor(f),o=Math.ceil(i+c-y),h=Math.ceil(n+f-_);g={x:y,y:_,w:o,h}}const b=a.crossOrigin;return{x:c,y:f,h:n,w:i,excavation:g,opacity:l,crossOrigin:b}}function ev(e,t){return t!=null?Math.max(Math.floor(t),0):e?Gg:Qg}function ul({value:e,level:t,minVersion:r,includeMargin:a,marginSize:p,imageSettings:m,size:v,boostLevel:i}){let n=ie.useMemo(()=>{const y=(Array.isArray(e)?e:[e]).reduce((_,o)=>(_.push(...rs.QrSegment.makeSegments(o)),_),[]);return rs.QrCode.encodeSegments(y,Yg[t],r,void 0,void 0,i)},[e,t,r,i]);const{cells:c,margin:f,numCells:l,calculatedImageSettings:g}=ie.useMemo(()=>{let b=n.getModules();const y=ev(a,p),_=b.length+y*2,o=Jg(b,v,y,m);return{cells:b,margin:y,numCells:_,calculatedImageSettings:o}},[n,v,m,a,p]);return{qrcode:n,margin:f,cells:c,numCells:l,calculatedImageSettings:g}}var tv=(function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0})(),sv=ie.forwardRef(function(t,r){const a=t,{value:p,size:m=rl,level:v=il,bgColor:i=nl,fgColor:n=ol,includeMargin:c=al,minVersion:f=ll,boostLevel:l,marginSize:g,imageSettings:b}=a,_=di(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:o}=_,h=di(_,["style"]),d=b?.src,u=ie.useRef(null),x=ie.useRef(null),S=ie.useCallback(M=>{u.current=M,typeof r=="function"?r(M):r&&(r.current=M)},[r]),[k,E]=ie.useState(!1),{margin:w,cells:j,numCells:R,calculatedImageSettings:L}=ul({value:p,level:v,minVersion:f,boostLevel:l,includeMargin:c,marginSize:g,imageSettings:b,size:m});ie.useEffect(()=>{if(u.current!=null){const M=u.current,O=M.getContext("2d");if(!O)return;let F=j;const z=x.current,A=L!=null&&z!==null&&z.complete&&z.naturalHeight!==0&&z.naturalWidth!==0;A&&L.excavation!=null&&(F=dl(j,L.excavation));const P=window.devicePixelRatio||1;M.height=M.width=m*P;const I=m/R*P;O.scale(I,I),O.fillStyle=i,O.fillRect(0,0,R,R),O.fillStyle=n,tv?O.fill(new Path2D(cl(F,w))):j.forEach(function(B,$){B.forEach(function(X,Z){X&&O.fillRect(Z+w,$+w,1,1)})}),L&&(O.globalAlpha=L.opacity),A&&O.drawImage(z,L.x+w,L.y+w,L.w,L.h)}}),ie.useEffect(()=>{E(!1)},[d]);const D=ci({height:m,width:m},o);let N=null;return d!=null&&(N=ie.createElement("img",{src:d,key:d,style:{display:"none"},onLoad:()=>{E(!0)},ref:x,crossOrigin:L?.crossOrigin})),ie.createElement(ie.Fragment,null,ie.createElement("canvas",ci({style:D,height:m,width:m,ref:S,role:"img"},h)),N)});sv.displayName="QRCodeCanvas";var hl=ie.forwardRef(function(t,r){const a=t,{value:p,size:m=rl,level:v=il,bgColor:i=nl,fgColor:n=ol,includeMargin:c=al,minVersion:f=ll,boostLevel:l,title:g,marginSize:b,imageSettings:y}=a,_=di(a,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:o,cells:h,numCells:d,calculatedImageSettings:u}=ul({value:p,level:v,minVersion:f,boostLevel:l,includeMargin:c,marginSize:b,imageSettings:y,size:m});let x=h,S=null;y!=null&&u!=null&&(u.excavation!=null&&(x=dl(h,u.excavation)),S=ie.createElement("image",{href:y.src,height:u.h,width:u.w,x:u.x+o,y:u.y+o,preserveAspectRatio:"none",opacity:u.opacity,crossOrigin:u.crossOrigin}));const k=cl(x,o);return ie.createElement("svg",ci({height:m,width:m,viewBox:`0 0 ${d} ${d}`,ref:r,role:"img"},_),!!g&&ie.createElement("title",null,g),ie.createElement("path",{fill:i,d:`M0,0 h${d}v${d}H0z`,shapeRendering:"crispEdges"}),ie.createElement("path",{fill:n,d:k,shapeRendering:"crispEdges"}),S)});hl.displayName="QRCodeSVG";function fl(){return parseInt(window.location.port||(window.location.protocol==="https:"?"443":"80"),10)}function rv(){return vt({queryKey:le.tunnel.status,queryFn:()=>me.get("/tunnel/status"),refetchInterval:e=>e.state.data?.running?5e3:!1})}function iv(){const e=Qe();return ut({mutationFn:()=>me.post("/tunnel/start",{port:fl()}),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function nv(){const e=Qe();return ut({mutationFn:()=>me.post("/tunnel/regenerate",{port:fl()}),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function ov(){const e=Qe();return ut({mutationFn:()=>me.post("/tunnel/stop"),onSuccess:()=>{e.invalidateQueries({queryKey:le.tunnel.status})}})}function av(e){if(!e||e.status==="stopped")return{button:"text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100",dot:"",label:"Share via tunnel",icon:"idle"};switch(e.status){case"healthy":return{button:"text-emerald-600 hover:bg-emerald-50",dot:"bg-emerald-500",label:"Tunnel healthy",icon:"ok"};case"checking":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 lv(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 cv(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 local Agent Tower service and the current public URL are both reachable.";case"checking":return"The tunnel URL exists. Agent Tower is checking whether the original public URL is reachable.";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 mo(e){if(!e)return"Never";const t=new Date(e).getTime();if(!Number.isFinite(t))return e;const r=Math.max(0,Math.round((Date.now()-t)/1e3));if(r<60)return`${r}s ago`;const a=Math.round(r/60);if(a<60)return`${a}m ago`;const p=Math.round(a/60);return p<24?`${p}h ago`:`${Math.round(p/24)}d ago`}function po(){const{t:e}=ne(),{data:t}=rv(),r=iv(),a=ov(),p=nv(),[m,v]=C.useState(!1),[i,n]=C.useState(null),c=C.useRef(null),[f,l]=C.useState({top:0,right:0}),[g,b]=C.useState(!1),[y,_]=C.useState(!1),o=t?.status!==void 0&&t.status!=="stopped",h=r.isPending||t?.status==="starting",d=p.isPending,u=t?.shareableUrl,x=t?.token,S=av(t),k=lv(t),E=t?.lastRemoteError,j=t?.lastLocalError||E||t?.lastError;C.useEffect(()=>{if(m&&c.current){const O=c.current.getBoundingClientRect();l({top:O.bottom+8,right:window.innerWidth-O.right})}},[m]);const R=C.useCallback(()=>{o?v(!0):r.mutate(void 0,{onSuccess:()=>v(!0)})},[o,r]),L=C.useCallback(()=>{u&&(navigator.clipboard.writeText(u),n("url"),setTimeout(()=>n(null),2e3))},[u]),D=C.useCallback(()=>{x&&(navigator.clipboard.writeText(x),n("token"),setTimeout(()=>n(null),2e3))},[x]),N=C.useCallback(()=>{a.mutate(),v(!1),b(!1),_(!1)},[a]),M=C.useCallback(()=>{p.mutate(void 0,{onSuccess:()=>{_(!1),v(!0)}})},[p]);return s.jsxs("div",{className:"relative",children:[s.jsx("button",{ref:c,onClick:R,disabled:h,className:`p-1.5 rounded-md transition-colors ${S.button}`,title:e(S.label),children:h?s.jsx(Ke,{size:16,className:"animate-spin"}):S.icon==="warn"?s.jsx(Si,{size:16}):s.jsx(xi,{size:16})}),o&&!h&&s.jsx("span",{className:`absolute top-0.5 right-0.5 w-2 h-2 ${S.dot} rounded-full`}),m&&o&&Ut.createPortal(s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fixed inset-0 z-[100]",onClick:()=>v(!1)}),s.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:f.top,right:f.right},children:[s.jsxs("div",{className:"flex items-start justify-between mb-2",children:[s.jsxs("div",{children:[s.jsxs("span",{className:`text-xs font-medium flex items-center gap-1.5 ${t?.status==="healthy"?"text-emerald-600":t?.status==="exited"||t?.status==="error"?"text-red-600":"text-amber-600"}`,children:[s.jsx("span",{className:`w-1.5 h-1.5 ${S.dot} rounded-full inline-block`}),e(k)]}),s.jsx("p",{className:"mt-1 text-xs text-neutral-500 leading-relaxed",children:e(cv(t))})]}),s.jsx("button",{onClick:()=>v(!1),className:"p-0.5 text-neutral-400 hover:text-neutral-600 rounded",children:s.jsx(Ht,{size:14})})]}),x&&s.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:[s.jsx(Jc,{size:12}),s.jsx("span",{children:e("Token protected")})]}),u&&s.jsx("div",{className:"flex justify-center py-3",children:s.jsx(hl,{value:u,size:160})}),s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx("input",{readOnly:!0,value:u??t?.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:O=>O.target.select()}),s.jsx("button",{onClick:L,disabled:!u,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"?s.jsx(At,{size:14,className:"text-emerald-500"}):s.jsx(pn,{size:14})})]}),s.jsxs("div",{className:"mt-3 grid grid-cols-2 gap-2 text-xs",children:[s.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[s.jsx("div",{className:"text-neutral-500",children:e("Last checked")}),s.jsx("div",{className:"mt-0.5 text-neutral-800",children:mo(t?.lastCheckedAt)})]}),s.jsxs("div",{className:"rounded-md border border-neutral-200 px-2 py-1.5",children:[s.jsx("div",{className:"text-neutral-500",children:e("Last healthy")}),s.jsx("div",{className:"mt-0.5 text-neutral-800",children:mo(t?.lastHealthyAt)})]})]}),j&&s.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:j}),t?.status==="degraded"&&s.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.")}),t?.status==="linkReplaced"&&s.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.")}),x&&s.jsxs("div",{className:"mt-2",children:[s.jsx("button",{onClick:()=>b(!g),className:"text-xs text-neutral-500 hover:text-neutral-700 transition-colors",children:e(g?"Hide token":"Show token")}),g&&s.jsxs("div",{className:"flex items-center gap-2 mt-1",children:[s.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:x}),s.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"?s.jsx(At,{size:14,className:"text-emerald-500"}):s.jsx(pn,{size:14})})]})]}),y&&s.jsxs("div",{className:"mt-3 rounded-md border border-red-200 bg-red-50 p-2 text-xs text-red-700",children:[s.jsx("div",{children:e("Generating a new link will invalidate the current link. People using the old URL must receive the new one.")}),s.jsxs("div",{className:"mt-2 flex gap-2",children:[s.jsx("button",{onClick:()=>_(!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")}),s.jsx("button",{onClick:M,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")})]})]}),!y&&s.jsxs("button",{onClick:()=>_(!0),disabled:d||t?.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:[s.jsx(Es,{size:13}),e("Regenerate link")]}),s.jsx("button",{onClick:N,disabled:a.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:a.isPending?e("Stopping..."):e("Stop Tunnel")})]})]}),document.body)]})}function Jr({isOpen:e,onClose:t}){const{t:r}=ne(),a=ec(),[p,m]=C.useState(""),[v,i]=C.useState(""),[n,c]=C.useState(null),[f,l]=C.useState(!1),[g,b]=C.useState(!1),y=p.trim(),_=v.trim(),o=f||a.isPending,h=C.useMemo(()=>!!(y&&_&&!o),[y,_,o]),d=C.useCallback(()=>{m(""),i(""),c(null),b(!1)},[]),u=C.useCallback(()=>{o||(d(),t())},[o,t,d]);C.useEffect(()=>{e||d()},[e,d]);const x=C.useCallback(async E=>{try{await a.mutateAsync({name:y,repoPath:_,initEmptyRepo:E}),d(),t()}catch(w){const j=w instanceof Error?w.message:r("Failed to create project");c(j),ns.error(j)}},[a,t,d,r,y,_]),S=C.useCallback(async()=>{if(!(!y||!_||o)){c(null),l(!0);try{const E=await me.get("/filesystem/validate",{params:{path:_}});if(E.valid){await x(!1);return}if(E.reason==="no_git"&&E.isEmpty){b(!0);return}if(E.reason==="no_git"){c(r("The selected directory is not a Git repository and is not empty. Initialize Git manually and make an initial commit, then create the project."));return}c(E.error??r("Selected path is not a valid directory"))}catch(E){c(E instanceof Error?E.message:r("Could not check repository path"))}finally{l(!1)}}},[x,o,r,y,_]),k=C.useCallback(()=>{b(!1),x(!0)},[x]);return s.jsxs(s.Fragment,{children:[s.jsx(Ms,{isOpen:e,onClose:u,title:r("Create New Project"),action:s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:u,disabled:o,className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:r("Cancel")}),s.jsx("button",{onClick:S,disabled:!h,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${h?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:f?r("Checking..."):a.isPending?r("Creating..."):r("Create Project")})]}),children:s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Project Name")}),s.jsx("input",{type:"text",value:p,onChange:E=>m(E.target.value),placeholder:r("e.g., Agent Tower"),disabled:o,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})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:r("Repository Path")}),s.jsx(tc,{value:v,onChange:i,validationMode:"directory"})]}),n&&s.jsx("p",{className:"text-xs text-red-500 leading-relaxed",children:n})]})}),s.jsx(Zs,{isOpen:g,onClose:()=>{a.isPending||b(!1)},onConfirm:k,title:r("Initialize Git repository?"),description: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."),confirmText:"Initialize and Create",cancelText:"Cancel",isLoading:a.isPending})]})}const go={idle:"Create & Start","creating-task":"Creating Task...","creating-teamrun":"Creating TeamRun...","creating-workspace":"Creating Workspace...","creating-session":"Creating Session...","starting-session":"Starting Agent..."},vo=C.lazy(()=>Yl(()=>import("./modal-JMpuh-LG.js").then(e=>e.m),__vite__mapDeps([0,1,2,3])).then(e=>({default:e.Modal}))),_o=s.jsx("span",{className:"font-bold text-neutral-900 tracking-tight text-base",children:"Agent Tower"}),dv=260,uv=600,xo=400;function Av(){const{t:e}=ne(),[t,r]=C.useState(null),[a,p]=C.useState(null),[m,v]=C.useState(xo),[i,n]=C.useState(!1),[c,f]=C.useState(!1),[l,g]=C.useState(""),[b,y]=C.useState(""),[_,o]=C.useState(""),[h,d]=C.useState(""),[u,x]=C.useState("SOLO"),[S,k]=C.useState("AUTO"),[E,w]=C.useState(null),[j,R]=C.useState([]),[L,D]=C.useState(null),[N,M]=C.useState(null),[O,F]=C.useState("idle"),{files:z,addFiles:A,removeFile:P,clear:I,buildMarkdownLinks:B,isUploading:$}=Sr(),X=C.useRef(null),Z=C.useRef(!1),J=C.useRef(0),ae=C.useRef(xo),T=C.useRef(null),H=Qe(),{data:U,isLoading:W}=Ds(),{data:te,isLoading:K}=sc(),ce=C.useMemo(()=>te?.data??[],[te?.data]),he=C.useMemo(()=>ce.map(Cg),[ce]),ve=a&&ce.some(V=>V.id===a)?a:null,{data:Fe,isLoading:re}=M0(ve??""),pe=oc({queries:ve?[]:ce.map(V=>({queryKey:le.tasks.list(V.id),queryFn:()=>me.get(`/projects/${V.id}/tasks`,{params:{limit:"500"}})}))}),Ze=!ve&&pe.some(V=>V.isLoading),je=C.useMemo(()=>{if(ve)return Fe?.data??[];const V=[];for(const ee of pe)ee.data?.data&&V.push(...ee.data.data);return V},[ve,Fe,pe]),Le=t&&je.some(V=>V.id===t)?t:null,we=C.useMemo(()=>{const V=new Map;for(const ee of je){const fe=ee.createdAt?new Date(ee.createdAt).getTime():0,Ae=V.get(ee.projectId)??0;fe>Ae&&V.set(ee.projectId,fe)}return[...ce].sort((ee,fe)=>{const Ae=V.get(ee.id)??(ee.createdAt?new Date(ee.createdAt).getTime():0);return(V.get(fe.id)??(fe.createdAt?new Date(fe.createdAt).getTime():0))-Ae})},[ce,je]),Ce=C.useMemo(()=>we.filter(V=>!V.archivedAt),[we]),Xe=C.useMemo(()=>{if(!U)return[];const V=localStorage.getItem("providerUsageCount"),ee=V?JSON.parse(V):{};return[...U].sort((fe,Ae)=>{const $e=fe.availability.type!=="NOT_FOUND",nt=Ae.availability.type!=="NOT_FOUND";if($e!==nt)return $e?-1:1;const Mt=ee[fe.provider.id]??0;return(ee[Ae.provider.id]??0)-Mt})},[U]),_e=C.useMemo(()=>je.map(Eg),[je]),ze=C.useMemo(()=>new Set,[]),ke=C.useMemo(()=>{if(!Le)return null;const V=je.find(fe=>fe.id===Le);if(!V)return null;const ee=ce.find(fe=>fe.id===V.projectId);if(!ee){const fe=V.workspaces?.find(Ae=>Ae.status==="ACTIVE")?.branchName??V.workspaces?.[0]?.branchName??"—";return{id:V.id,projectId:V.projectId,projectName:"Unknown",projectColor:"text-neutral-500",title:V.title,status:qi(V.status),branch:fe,mainBranch:"main",description:V.description??"",projectArchivedAt:null,projectRepoDeletedAt:null}}return jg(V,ee)},[Le,je,ce]),Re=D0(_),tt=wo(),qe=P0(),q=L0(),Q=C.useCallback(V=>{qe.mutate(V,{onSuccess:()=>{Le===V&&r(null),H.invalidateQueries({queryKey:le.tasks.all})}})},[qe,Le,H]),ue=C.useCallback((V,ee)=>{q.mutate({id:V,status:Sg(ee)},{onError:()=>{ns.error(e("状态变更失败,该操作不被允许"))}})},[q,e]),Te=C.useCallback(V=>{V.preventDefault(),Z.current=!0,J.current=V.clientX,ae.current=m,document.body.style.cursor="col-resize",document.body.style.userSelect="none"},[m]);C.useEffect(()=>{const V=fe=>{if(!Z.current)return;const Ae=fe.clientX-J.current,$e=Math.max(dv,Math.min(uv,ae.current+Ae));v($e)},ee=()=>{Z.current&&(Z.current=!1,document.body.style.cursor="",document.body.style.userSelect="")};return document.addEventListener("mousemove",V),document.addEventListener("mouseup",ee),()=>{document.removeEventListener("mousemove",V),document.removeEventListener("mouseup",ee)}},[]);const Ne=C.useCallback(()=>{n(!0)},[]),Ee=C.useCallback(()=>{if(Ce.length===0){ns.error(e("没有可用项目,请先创建或恢复项目"));return}const V=localStorage.getItem("lastSelectedProjectId"),ee=localStorage.getItem("lastSelectedProviderId"),fe=V&&Ce.find(nt=>nt.id===V)?V:(ve&&Ce.find(nt=>nt.id===ve)?.id)??Ce[0]?.id??"";o(fe);const Ae=Xe?.find(nt=>nt.availability.type!=="NOT_FOUND"),$e=ee&&Xe?.find(nt=>nt.provider.id===ee&&nt.availability.type!=="NOT_FOUND")?ee:Ae?.provider.id??"";d($e),x("SOLO"),k("AUTO"),w(null),R([]),D(null),M(null),F("idle"),f(!0)},[Ce,ve,Xe,e]),lt=C.useCallback(()=>{n(!1)},[]),ft=C.useCallback(()=>{O==="idle"&&(f(!1),g(""),y(""),o(""),d(""),x("SOLO"),k("AUTO"),w(null),R([]),D(null),M(null),F("idle"),I())},[O,I]),Pe=$i(),Ve=C.useCallback(async()=>{const V=!!l.trim()&&!!_,ee=u==="TEAM"&&L!==null;if(u==="TEAM"&&!E&&j.length===0){M(e("请选择至少一个团队模板或成员预设。"));return}if(u==="TEAM"){if(!ee&&!V)return}else if(!V)return;try{M(null);const fe=B(),Ae=[b.trim(),fe].filter(Boolean).join(`
86
+
87
+ `);let $e=L;if(!$e){F("creating-task");const nt=await Re.mutateAsync({title:l.trim(),description:Ae||void 0});if($e=nt.id,D(nt.id),localStorage.setItem("lastSelectedProjectId",_),u==="SOLO"&&h){localStorage.setItem("lastSelectedProviderId",h);const Mt=localStorage.getItem("providerUsageCount"),Dt=Mt?JSON.parse(Mt):{};Dt[h]=(Dt[h]??0)+1,localStorage.setItem("providerUsageCount",JSON.stringify(Dt))}}if(u==="TEAM"){const nt=j;F("creating-teamrun"),await tt.mutateAsync({taskId:$e,mode:S,...E?{teamTemplateId:E}:{},...nt.length>0?{memberPresetIds:nt}:{}}),D(null)}else if(h){const nt=[l.trim(),Ae].filter(Boolean).join(`
88
+
89
+ `);F("creating-workspace");const Mt=await me.post(`/tasks/${$e}/workspaces`,{});F("creating-session");const Dt=await me.post(`/workspaces/${Mt.id}/sessions`,{providerId:h,prompt:nt});F("starting-session"),await Pe.mutateAsync(Dt.id),await H.invalidateQueries({queryKey:le.workspaces.list($e)})}r($e),F("idle"),f(!1),g(""),y(""),o(""),d(""),x("SOLO"),k("AUTO"),w(null),R([]),D(null),M(null),I()}catch(fe){u==="TEAM"&&M(fe instanceof Error?fe.message:e("创建 TeamRun 失败")),F("idle")}},[l,b,_,h,u,S,E,j,L,Re,tt,Pe,H,B,I,e]),He=C.useCallback(V=>{const ee=V.target.files;ee&&ee.length>0&&A(Array.from(ee)),V.target.value=""},[A]),We=C.useCallback(V=>{const ee=V.clipboardData.items,fe=[];for(const Ae of ee)if(Ae.kind==="file"){const $e=Ae.getAsFile();$e&&fe.push($e)}fe.length>0&&(V.preventDefault(),A(fe))},[A]),[st,Je]=C.useState(!1),pt=C.useCallback(V=>{V.preventDefault(),Je(!0)},[]),Me=C.useCallback(V=>{V.preventDefault(),Je(!1)},[]),rt=C.useCallback(V=>{V.preventDefault(),Je(!1);const ee=V.dataTransfer.files;ee.length>0&&A(Array.from(ee))},[A]),ht=K||re||Ze,xt=!!l.trim()&&!!_,Ie=u!=="TEAM"||!!E||j.length>0,Y=O==="idle"&&Ie&&(u==="TEAM"&&L!==null||xt),oe=e(u==="TEAM"&&O==="idle"?"Create TeamRun":go[O]),be=s.jsxs(s.Fragment,{children:[s.jsx("button",{onClick:ft,disabled:O!=="idle",className:"px-4 py-2 text-sm text-neutral-600 hover:text-neutral-900 transition-colors disabled:opacity-50",children:e("Cancel")}),s.jsx("button",{onClick:Ve,disabled:!Y,className:`px-4 py-2 text-sm font-medium rounded-lg transition-all ${Y?"bg-neutral-900 text-white hover:bg-black":"bg-neutral-100 text-neutral-400 cursor-not-allowed"}`,children:oe})]}),ye=s.jsxs("div",{className:"space-y-4",children:[s.jsxs("div",{className:"space-y-2",children:[s.jsx("div",{className:"text-sm font-medium text-neutral-700",children:e("Execution")}),s.jsxs("div",{className:"inline-flex rounded-md border border-neutral-200 bg-neutral-50 p-1",children:[s.jsx("button",{type:"button",onClick:()=>{O==="idle"&&(x("SOLO"),M(null))},disabled:O!=="idle",className:se("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="SOLO"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:e("Solo Agent")}),s.jsx("button",{type:"button",onClick:()=>{O==="idle"&&(x("TEAM"),M(null))},disabled:O!=="idle",className:se("rounded-md px-3 py-1.5 text-sm transition-colors disabled:cursor-not-allowed disabled:opacity-50",u==="TEAM"?"bg-white text-neutral-900 shadow-sm":"text-neutral-500 hover:text-neutral-900"),children:e("TeamRun")})]})]}),s.jsxs("div",{className:"flex gap-3",children:[s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Project")}),s.jsx(hn,{value:_,onChange:o,options:Ce.map(V=>({value:V.id,label:V.name})),placeholder:e("Select project..."),disabled:O!=="idle"})]}),u==="SOLO"?s.jsxs("div",{className:"flex-1 min-w-0",children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Agent")}),s.jsx(hn,{value:h,onChange:d,options:Xe.map(({provider:V,availability:ee})=>({value:V.id,label:V.name+(ee.type==="NOT_FOUND"?e(" (不可用)"):""),disabled:ee.type==="NOT_FOUND"})),placeholder:e(W?"Loading...":"Select provider..."),disabled:O!=="idle"})]}):s.jsx("div",{className:"flex-1 min-w-0"})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Task Title")}),s.jsx("input",{type:"text",value:l,onChange:V=>g(V.target.value),placeholder:e("e.g., Implement login flow"),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:O!=="idle",onKeyDown:V=>{V.key==="Enter"&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&Ve()}})]}),s.jsxs("div",{children:[s.jsx("label",{className:"block text-sm font-medium text-neutral-700 mb-1.5",children:e("Description")}),s.jsxs("div",{className:`relative border rounded-lg transition-colors ${st?"border-neutral-400 bg-neutral-50":"border-neutral-200"}`,onDragOver:pt,onDragLeave:Me,onDrop:rt,children:[s.jsx("textarea",{rows:3,value:b,onChange:V=>y(V.target.value),onPaste:We,placeholder:e("Optional description..."),className:"w-full px-3 py-2 text-sm focus:outline-none bg-transparent resize-none",disabled:O!=="idle",onKeyDown:V=>{(V.metaKey||V.ctrlKey)&&V.key==="Enter"&&!V.nativeEvent.isComposing&&V.nativeEvent.keyCode!==229&&Ve()}}),st&&s.jsx("div",{className:"absolute inset-0 flex items-center justify-center bg-neutral-50/90 pointer-events-none",children:s.jsx("p",{className:"text-sm text-neutral-600",children:e("Drop files here")})})]}),s.jsxs("div",{className:"mt-2 flex items-center gap-2",children:[s.jsxs("button",{type:"button",onClick:()=>X.current?.click(),disabled:O!=="idle"||$,className:"inline-flex items-center gap-1.5 px-3 py-1.5 text-xs text-neutral-600 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors disabled:opacity-50 disabled:cursor-not-allowed",children:[s.jsx(mr,{size:14}),e("Attach files")]}),s.jsx("span",{className:"text-xs text-neutral-400",children:e("or paste/drag files")})]}),s.jsx("input",{ref:X,type:"file",multiple:!0,onChange:He,className:"hidden"}),s.jsx(wr,{files:z,onRemove:P})]}),u==="TEAM"&&s.jsxs("div",{className:"space-y-3 border-t border-neutral-100 pt-4",children:[s.jsx(qa,{mode:S,setMode:k,selectedTemplateId:E,setSelectedTemplateId:w,selectedMemberPresetIds:j,setSelectedMemberPresetIds:R,disabled:O!=="idle"}),N&&s.jsx("p",{className:"text-xs text-red-500",children:N})]}),Re.isError&&s.jsx("p",{className:"text-xs text-red-500",children:Re.error instanceof Error?Re.error.message:e("Failed to create task")})]});return ea()?Le&&ke?s.jsxs(s.Fragment,{children:[s.jsx(Xg,{task:ke,onBack:()=>r(null),onDeleteTask:ke.projectArchivedAt?void 0:Q,isDeleting:qe.isPending}),s.jsx(Jr,{isOpen:i,onClose:lt})]}):s.jsxs(s.Fragment,{children:[s.jsxs("div",{className:"flex flex-col h-dvh bg-neutral-50 overflow-hidden text-sm",children:[s.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between shrink-0 z-10",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ln,{}),_o]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(po,{}),s.jsx(Gs,{to:"/settings",className:"p-1.5 text-neutral-400 active:text-neutral-900 rounded-md",children:s.jsx(dn,{size:16})})]})]}),ht&&_e.length===0?s.jsx("div",{className:"flex-1 flex items-center justify-center text-sm text-neutral-400",children:e("Loading...")}):s.jsx(Nn,{tasks:_e,projects:he,selectedTaskId:null,onSelectTask:r,filterProjectId:ve,setFilterProjectId:p,width:"100%",onCreateProject:Ne,onCreateTask:Ee,activeTaskIds:ze,onTaskStatusChange:ue})]}),s.jsxs(C.Suspense,{fallback:null,children:[s.jsx(Jr,{isOpen:i,onClose:lt}),s.jsx(vo,{isOpen:c,onClose:ft,title:e("Create New Task"),className:u==="TEAM"?"max-w-5xl":void 0,action:be,children:ye})]})]}):s.jsxs("div",{ref:T,className:"flex flex-col h-screen bg-neutral-50 overflow-hidden text-sm",children:[s.jsxs("header",{className:"h-12 bg-white border-b border-neutral-200 flex items-center px-4 justify-between flex-shrink-0 z-10 relative",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(ln,{}),_o]}),s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx(po,{}),s.jsx(Gs,{to:"/settings",className:"p-1.5 text-neutral-400 hover:text-neutral-900 hover:bg-neutral-100 rounded-md transition-colors",children:s.jsx(dn,{size:16})})]})]}),s.jsxs("div",{className:"flex-1 flex overflow-hidden",children:[ht&&_e.length===0?s.jsx("div",{className:"h-full flex items-center justify-center text-sm text-neutral-400 border-r border-neutral-200 flex-shrink-0",style:{width:m},children:e("Loading...")}):s.jsx(Nn,{tasks:_e,projects:he,selectedTaskId:Le,onSelectTask:r,filterProjectId:ve,setFilterProjectId:p,width:m,onCreateProject:Ne,onCreateTask:Ee,activeTaskIds:ze,onTaskStatusChange:ue,onDeleteTask:Q}),s.jsx("div",{onMouseDown:Te,className:"w-1 cursor-col-resize hover:bg-neutral-300 active:bg-neutral-400 transition-colors z-50 -ml-[2px] flex-shrink-0 h-full",title:e("Drag to resize")}),s.jsx(yg,{task:ke,onDeleteTask:ke?.projectArchivedAt?void 0:Q,isDeleting:qe.isPending,onTaskStatusChange:ke?.projectArchivedAt?void 0:ue})]}),s.jsxs(C.Suspense,{fallback:null,children:[s.jsx(Jr,{isOpen:i,onClose:lt}),s.jsx(vo,{isOpen:c,onClose:ft,title:e("Create New Task"),className:u==="TEAM"?"max-w-5xl":void 0,action:be,children:ye})]})]})}export{Av as ProjectKanbanPage};