loki-mode 6.71.1 → 6.72.0

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 (91) hide show
  1. package/README.md +9 -1
  2. package/SKILL.md +2 -2
  3. package/VERSION +1 -1
  4. package/autonomy/hooks/migration-hooks.sh +26 -0
  5. package/autonomy/loki +429 -92
  6. package/autonomy/run.sh +219 -38
  7. package/dashboard/__init__.py +1 -1
  8. package/dashboard/server.py +101 -19
  9. package/docs/INSTALLATION.md +20 -11
  10. package/docs/bug-fixes/agent-01-cli-fixes.md +101 -0
  11. package/docs/bug-fixes/agent-02-purplelab-fixes.md +88 -0
  12. package/docs/bug-fixes/agent-03-dashboard-fixes.md +119 -0
  13. package/docs/bug-fixes/agent-04-memory-fixes.md +105 -0
  14. package/docs/bug-fixes/agent-05-provider-fixes.md +86 -0
  15. package/docs/bug-fixes/agent-06-integration-fixes.md +101 -0
  16. package/docs/bug-fixes/agent-07-dash-run-fixes.md +101 -0
  17. package/docs/bug-fixes/agent-08-docker-fixes.md +164 -0
  18. package/docs/bug-fixes/agent-09-e2e-build-fixes.md +69 -0
  19. package/docs/bug-fixes/agent-10-e2e-fullstack-fixes.md +102 -0
  20. package/docs/bug-fixes/agent-11-e2e-session-fixes.md +70 -0
  21. package/docs/bug-fixes/agent-12-scenario-fixes.md +120 -0
  22. package/docs/bug-fixes/agent-13-enterprise-fixes.md +143 -0
  23. package/docs/bug-fixes/agent-14-uat-newuser-fixes.md +88 -0
  24. package/docs/bug-fixes/agent-15-uat-poweruser-fixes.md +132 -0
  25. package/docs/bug-fixes/agent-19-code-review.md +316 -0
  26. package/docs/bug-fixes/agent-20-architecture-review.md +331 -0
  27. package/docs/competitive/bolt-new-analysis.md +579 -0
  28. package/docs/competitive/emergence-others-analysis.md +605 -0
  29. package/docs/competitive/replit-lovable-analysis.md +622 -0
  30. package/docs/test-scenarios/edge-cases.md +813 -0
  31. package/docs/test-scenarios/enterprise-scenarios.md +732 -0
  32. package/mcp/__init__.py +1 -1
  33. package/mcp/server.py +49 -5
  34. package/memory/consolidation.py +33 -0
  35. package/memory/embeddings.py +10 -1
  36. package/memory/engine.py +83 -38
  37. package/memory/retrieval.py +36 -0
  38. package/memory/storage.py +56 -4
  39. package/memory/token_economics.py +14 -2
  40. package/memory/vector_index.py +36 -7
  41. package/package.json +1 -1
  42. package/providers/gemini.sh +89 -2
  43. package/templates/README.md +1 -1
  44. package/templates/cli-tool.md +30 -0
  45. package/templates/dashboard.md +4 -0
  46. package/templates/data-pipeline.md +4 -0
  47. package/templates/discord-bot.md +47 -0
  48. package/templates/game.md +4 -0
  49. package/templates/microservice.md +4 -0
  50. package/templates/npm-library.md +4 -0
  51. package/templates/rest-api-auth.md +50 -20
  52. package/templates/rest-api.md +15 -0
  53. package/templates/saas-starter.md +1 -1
  54. package/templates/slack-bot.md +36 -0
  55. package/templates/static-landing-page.md +9 -1
  56. package/templates/web-scraper.md +4 -0
  57. package/web-app/dist/assets/Badge-CeBkFjo6.js +1 -0
  58. package/web-app/dist/assets/Button-yuhqo8Fq.js +1 -0
  59. package/web-app/dist/assets/{Card-B1bV4syB.js → Card-BG17vsX0.js} +1 -1
  60. package/web-app/dist/assets/{HomePage-CZTV6Nea.js → HomePage-BMSQ7Apj.js} +3 -3
  61. package/web-app/dist/assets/{LoginPage-D4UdURJc.js → LoginPage-aH_6iolg.js} +1 -1
  62. package/web-app/dist/assets/{NotFoundPage-CCLSeL6j.js → NotFoundPage-Di8cNtB1.js} +1 -1
  63. package/web-app/dist/assets/ProjectPage-BtRssmw9.js +285 -0
  64. package/web-app/dist/assets/ProjectsPage-B-FTFagc.js +6 -0
  65. package/web-app/dist/assets/{SettingsPage-Xuv8EfAg.js → SettingsPage-DIJPBla4.js} +1 -1
  66. package/web-app/dist/assets/TeamsPage--19fNX7w.js +36 -0
  67. package/web-app/dist/assets/TemplatesPage-ChUQNOOv.js +11 -0
  68. package/web-app/dist/assets/TerminalOutput-Dwrzecyl.js +31 -0
  69. package/web-app/dist/assets/activity-BNRWeu9N.js +6 -0
  70. package/web-app/dist/assets/{arrow-left-CaGtolHc.js → arrow-left-Ce6g1_YE.js} +1 -1
  71. package/web-app/dist/assets/circle-alert-LIndawHL.js +11 -0
  72. package/web-app/dist/assets/clock-Bpj4VPlP.js +6 -0
  73. package/web-app/dist/assets/{external-link-CazyUyav.js → external-link-BhhdF0iQ.js} +1 -1
  74. package/web-app/dist/assets/folder-open-CM2LgfxI.js +11 -0
  75. package/web-app/dist/assets/index-8-KpWWq7.css +1 -0
  76. package/web-app/dist/assets/index-kPDW4e_b.js +236 -0
  77. package/web-app/dist/assets/lock-sAk3Xe54.js +16 -0
  78. package/web-app/dist/assets/search-CR-2i9by.js +6 -0
  79. package/web-app/dist/assets/server-DuFh4ymA.js +26 -0
  80. package/web-app/dist/assets/trash-2-BmkkT8V_.js +11 -0
  81. package/web-app/dist/index.html +2 -2
  82. package/web-app/server.py +1321 -53
  83. package/web-app/dist/assets/Badge-CBUx2PjL.js +0 -6
  84. package/web-app/dist/assets/Button-DsRiznlh.js +0 -21
  85. package/web-app/dist/assets/ProjectPage-D0w_X9tG.js +0 -237
  86. package/web-app/dist/assets/ProjectsPage-ByYxDlKC.js +0 -16
  87. package/web-app/dist/assets/TemplatesPage-BKWN07mc.js +0 -1
  88. package/web-app/dist/assets/TerminalOutput-Dj98V8Z-.js +0 -51
  89. package/web-app/dist/assets/clock-C_CDmobx.js +0 -11
  90. package/web-app/dist/assets/index-D452pFGl.css +0 -1
  91. package/web-app/dist/assets/index-Df4_kgLY.js +0 -196
@@ -0,0 +1,285 @@
1
+ var to=e=>{throw TypeError(e)};var so=(e,t,s)=>t.has(e)||to("Cannot "+s);var Ss=(e,t,s)=>(so(e,t,"read from private field"),s?s.call(e):t.get(e)),io=(e,t,s)=>t.has(e)?to("Cannot add the same private member more than once"):t instanceof WeakSet?t.add(e):t.set(e,s),ro=(e,t,s,i)=>(so(e,t,"write to private field"),i?i.call(e,s):t.set(e,s),s);import{c as Q,r as _,W as ls,j as o,a as Y,M as cn,X as Wt,T as ds,C as Gc,I as Xc,d as $a,e as ji,U as Jc,F as hn,f as Fa,b as Zc,E as rs,B as no,S as oo,P as ao,g as Qc,A as eh,h as Xi,i as th,u as sh}from"./index-kPDW4e_b.js";import{S as Di,T as ih,P as gi,a as rh,E as vi,R as nh}from"./TerminalOutput-Dwrzecyl.js";import{B as we}from"./Button-yuhqo8Fq.js";import{C as Ai,a as Oi}from"./lock-sAk3Xe54.js";import{R as gt,P as dn,B as oh,G as gr,S as ah}from"./server-DuFh4ymA.js";import{C as vt}from"./clock-Bpj4VPlP.js";import{A as lh}from"./activity-BNRWeu9N.js";import{C as us,a as un}from"./circle-alert-LIndawHL.js";import{C as Ha,F as vr}from"./folder-open-CM2LgfxI.js";import{E as xr}from"./external-link-BhhdF0iQ.js";import{S as ch}from"./search-CR-2i9by.js";import{P as Ii,T as fn}from"./trash-2-BmkkT8V_.js";import{A as hh}from"./arrow-left-Ce6g1_YE.js";/**
2
+ * @license lucide-react v0.577.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const dh=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M4.929 4.929 19.07 19.071",key:"196cmz"}]],uh=Q("ban",dh);/**
7
+ * @license lucide-react v0.577.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const fh=[["path",{d:"M18 6 7 17l-5-5",key:"116fxf"}],["path",{d:"m22 10-7.5 7.5L13 16",key:"ke71qq"}]],ph=Q("check-check",fh);/**
12
+ * @license lucide-react v0.577.0 - ISC
13
+ *
14
+ * This source code is licensed under the ISC license.
15
+ * See the LICENSE file in the root directory of this source tree.
16
+ */const _h=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],pn=Q("circle-check",_h);/**
17
+ * @license lucide-react v0.577.0 - ISC
18
+ *
19
+ * This source code is licensed under the ISC license.
20
+ * See the LICENSE file in the root directory of this source tree.
21
+ */const mh=[["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"}]],lo=Q("code-xml",mh);/**
22
+ * @license lucide-react v0.577.0 - ISC
23
+ *
24
+ * This source code is licensed under the ISC license.
25
+ * See the LICENSE file in the root directory of this source tree.
26
+ */const gh=[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]],vh=Q("dollar-sign",gh);/**
27
+ * @license lucide-react v0.577.0 - ISC
28
+ *
29
+ * This source code is licensed under the ISC license.
30
+ * See the LICENSE file in the root directory of this source tree.
31
+ */const xh=[["path",{d:"M10.733 5.076a10.744 10.744 0 0 1 11.205 6.575 1 1 0 0 1 0 .696 10.747 10.747 0 0 1-1.444 2.49",key:"ct8e1f"}],["path",{d:"M14.084 14.158a3 3 0 0 1-4.242-4.242",key:"151rxh"}],["path",{d:"M17.479 17.499a10.75 10.75 0 0 1-15.417-5.151 1 1 0 0 1 0-.696 10.75 10.75 0 0 1 4.446-5.143",key:"13bj9a"}],["path",{d:"m2 2 20 20",key:"1ooewy"}]],bh=Q("eye-off",xh);/**
32
+ * @license lucide-react v0.577.0 - ISC
33
+ *
34
+ * This source code is licensed under the ISC license.
35
+ * See the LICENSE file in the root directory of this source tree.
36
+ */const yh=[["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 12a1 1 0 0 0-1 1v1a1 1 0 0 1-1 1 1 1 0 0 1 1 1v1a1 1 0 0 0 1 1",key:"1oajmo"}],["path",{d:"M14 18a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1 1 1 0 0 1-1-1v-1a1 1 0 0 0-1-1",key:"mpwhp6"}]],Wa=Q("file-braces",yh);/**
37
+ * @license lucide-react v0.577.0 - ISC
38
+ *
39
+ * This source code is licensed under the ISC license.
40
+ * See the LICENSE file in the root directory of this source tree.
41
+ */const Sh=[["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"}]],he=Q("file-code-corner",Sh);/**
42
+ * @license lucide-react v0.577.0 - ISC
43
+ *
44
+ * This source code is licensed under the ISC license.
45
+ * See the LICENSE file in the root directory of this source tree.
46
+ */const wh=[["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 12.5 8 15l2 2.5",key:"1tg20x"}],["path",{d:"m14 12.5 2 2.5-2 2.5",key:"yinavb"}]],Ua=Q("file-code",wh);/**
47
+ * @license lucide-react v0.577.0 - ISC
48
+ *
49
+ * This source code is licensed under the ISC license.
50
+ * See the LICENSE file in the root directory of this source tree.
51
+ */const Ch=[["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:"M9 15h6",key:"cctwl0"}],["path",{d:"M12 18v-6",key:"17g6i2"}]],$i=Q("file-plus",Ch);/**
52
+ * @license lucide-react v0.577.0 - ISC
53
+ *
54
+ * This source code is licensed under the ISC license.
55
+ * See the LICENSE file in the root directory of this source tree.
56
+ */const kh=[["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 17h.01",key:"p32p05"}],["path",{d:"M9.1 9a3 3 0 0 1 5.82 1c0 2-3 3-3 3",key:"mhlwft"}]],Ka=Q("file-question-mark",kh);/**
57
+ * @license lucide-react v0.577.0 - ISC
58
+ *
59
+ * This source code is licensed under the ISC license.
60
+ * See the LICENSE file in the root directory of this source tree.
61
+ */const Eh=[["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:"M11 18h2",key:"12mj7e"}],["path",{d:"M12 12v6",key:"3ahymv"}],["path",{d:"M9 13v-.5a.5.5 0 0 1 .5-.5h5a.5.5 0 0 1 .5.5v.5",key:"qbrxap"}]],qa=Q("file-type",Eh);/**
62
+ * @license lucide-react v0.577.0 - ISC
63
+ *
64
+ * This source code is licensed under the ISC license.
65
+ * See the LICENSE file in the root directory of this source tree.
66
+ */const Nh=[["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:"m14.5 12.5-5 5",key:"b62r18"}],["path",{d:"m9.5 12.5 5 5",key:"1rk7el"}]],jh=Q("file-x",Nh);/**
67
+ * @license lucide-react v0.577.0 - ISC
68
+ *
69
+ * This source code is licensed under the ISC license.
70
+ * See the LICENSE file in the root directory of this source tree.
71
+ */const Dh=[["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"}]],Va=Q("file",Dh);/**
72
+ * @license lucide-react v0.577.0 - ISC
73
+ *
74
+ * This source code is licensed under the ISC license.
75
+ * See the LICENSE file in the root directory of this source tree.
76
+ */const Mh=[["path",{d:"M12 10v6",key:"1bos4e"}],["path",{d:"M9 13h6",key:"1uhe8q"}],["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Ph=Q("folder-plus",Mh);/**
77
+ * @license lucide-react v0.577.0 - ISC
78
+ *
79
+ * This source code is licensed under the ISC license.
80
+ * See the LICENSE file in the root directory of this source tree.
81
+ */const Rh=[["path",{d:"M20 20a2 2 0 0 0 2-2V8a2 2 0 0 0-2-2h-7.9a2 2 0 0 1-1.69-.9L9.6 3.9A2 2 0 0 0 7.93 3H4a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2Z",key:"1kt360"}]],Ya=Q("folder",Rh);/**
82
+ * @license lucide-react v0.577.0 - ISC
83
+ *
84
+ * This source code is licensed under the ISC license.
85
+ * See the LICENSE file in the root directory of this source tree.
86
+ */const Lh=[["path",{d:"M15 6a9 9 0 0 0-9 9V3",key:"1cii5b"}],["circle",{cx:"18",cy:"6",r:"3",key:"1h7g24"}],["circle",{cx:"6",cy:"18",r:"3",key:"fqmcym"}]],Te=Q("git-branch",Lh);/**
87
+ * @license lucide-react v0.577.0 - ISC
88
+ *
89
+ * This source code is licensed under the ISC license.
90
+ * See the LICENSE file in the root directory of this source tree.
91
+ */const Bh=[["circle",{cx:"12",cy:"12",r:"3",key:"1v7zrd"}],["line",{x1:"3",x2:"9",y1:"12",y2:"12",key:"1dyftd"}],["line",{x1:"15",x2:"21",y1:"12",y2:"12",key:"oup4p8"}]],Ga=Q("git-commit-horizontal",Bh);/**
92
+ * @license lucide-react v0.577.0 - ISC
93
+ *
94
+ * This source code is licensed under the ISC license.
95
+ * See the LICENSE file in the root directory of this source tree.
96
+ */const zh=[["circle",{cx:"18",cy:"18",r:"3",key:"1xkwt0"}],["circle",{cx:"6",cy:"6",r:"3",key:"1lh9wr"}],["path",{d:"M13 6h3a2 2 0 0 1 2 2v7",key:"1yeb86"}],["line",{x1:"6",x2:"6",y1:"9",y2:"21",key:"rroup"}]],co=Q("git-pull-request",zh);/**
97
+ * @license lucide-react v0.577.0 - ISC
98
+ *
99
+ * This source code is licensed under the ISC license.
100
+ * See the LICENSE file in the root directory of this source tree.
101
+ */const Th=[["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"}]],ho=Q("history",Th);/**
102
+ * @license lucide-react v0.577.0 - ISC
103
+ *
104
+ * This source code is licensed under the ISC license.
105
+ * See the LICENSE file in the root directory of this source tree.
106
+ */const Ah=[["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"}]],uo=Q("image",Ah);/**
107
+ * @license lucide-react v0.577.0 - ISC
108
+ *
109
+ * This source code is licensed under the ISC license.
110
+ * See the LICENSE file in the root directory of this source tree.
111
+ */const Oh=[["path",{d:"M2.586 17.414A2 2 0 0 0 2 18.828V21a1 1 0 0 0 1 1h3a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h1a1 1 0 0 0 1-1v-1a1 1 0 0 1 1-1h.172a2 2 0 0 0 1.414-.586l.814-.814a6.5 6.5 0 1 0-4-4z",key:"1s6t7t"}],["circle",{cx:"16.5",cy:"7.5",r:".5",fill:"currentColor",key:"w0ekpg"}]],Ih=Q("key-round",Oh);/**
112
+ * @license lucide-react v0.577.0 - ISC
113
+ *
114
+ * This source code is licensed under the ISC license.
115
+ * See the LICENSE file in the root directory of this source tree.
116
+ */const $h=[["path",{d:"M10 8h.01",key:"1r9ogq"}],["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M14 8h.01",key:"1primd"}],["path",{d:"M16 12h.01",key:"1l6xoz"}],["path",{d:"M18 8h.01",key:"emo2bl"}],["path",{d:"M6 8h.01",key:"x9i8wu"}],["path",{d:"M7 16h10",key:"wp8him"}],["path",{d:"M8 12h.01",key:"czm47f"}],["rect",{width:"20",height:"16",x:"2",y:"4",rx:"2",key:"18n3k1"}]],Fh=Q("keyboard",$h);/**
117
+ * @license lucide-react v0.577.0 - ISC
118
+ *
119
+ * This source code is licensed under the ISC license.
120
+ * See the LICENSE file in the root directory of this source tree.
121
+ */const Hh=[["rect",{width:"7",height:"9",x:"3",y:"3",rx:"1",key:"10lvy0"}],["rect",{width:"7",height:"5",x:"14",y:"3",rx:"1",key:"16une8"}],["rect",{width:"7",height:"9",x:"14",y:"12",rx:"1",key:"1hutg5"}],["rect",{width:"7",height:"5",x:"3",y:"16",rx:"1",key:"ldoo1y"}]],Ji=Q("layout-dashboard",Hh);/**
122
+ * @license lucide-react v0.577.0 - ISC
123
+ *
124
+ * This source code is licensed under the ISC license.
125
+ * See the LICENSE file in the root directory of this source tree.
126
+ */const Wh=[["path",{d:"M21 12a9 9 0 1 1-6.219-8.56",key:"13zald"}]],Xa=Q("loader-circle",Wh);/**
127
+ * @license lucide-react v0.577.0 - ISC
128
+ *
129
+ * This source code is licensed under the ISC license.
130
+ * See the LICENSE file in the root directory of this source tree.
131
+ */const Uh=[["path",{d:"M12 2v4",key:"3427ic"}],["path",{d:"m16.2 7.8 2.9-2.9",key:"r700ao"}],["path",{d:"M18 12h4",key:"wj9ykh"}],["path",{d:"m16.2 16.2 2.9 2.9",key:"1bxg5t"}],["path",{d:"M12 18v4",key:"jadmvz"}],["path",{d:"m4.9 19.1 2.9-2.9",key:"bwix9q"}],["path",{d:"M2 12h4",key:"j09sii"}],["path",{d:"m4.9 4.9 2.9 2.9",key:"giyufr"}]],Ja=Q("loader",Uh);/**
132
+ * @license lucide-react v0.577.0 - ISC
133
+ *
134
+ * This source code is licensed under the ISC license.
135
+ * See the LICENSE file in the root directory of this source tree.
136
+ */const Kh=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"m21 3-7 7",key:"1l2asr"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M9 21H3v-6",key:"wtvkvv"}]],fo=Q("maximize-2",Kh);/**
137
+ * @license lucide-react v0.577.0 - ISC
138
+ *
139
+ * This source code is licensed under the ISC license.
140
+ * See the LICENSE file in the root directory of this source tree.
141
+ */const qh=[["path",{d:"m14 10 7-7",key:"oa77jy"}],["path",{d:"M20 10h-6V4",key:"mjg0md"}],["path",{d:"m3 21 7-7",key:"tjx5ai"}],["path",{d:"M4 14h6v6",key:"rmj7iw"}]],Vh=Q("minimize-2",qh);/**
142
+ * @license lucide-react v0.577.0 - ISC
143
+ *
144
+ * This source code is licensed under the ISC license.
145
+ * See the LICENSE file in the root directory of this source tree.
146
+ */const Yh=[["path",{d:"M5 12h14",key:"1ays0h"}]],Za=Q("minus",Yh);/**
147
+ * @license lucide-react v0.577.0 - ISC
148
+ *
149
+ * This source code is licensed under the ISC license.
150
+ * See the LICENSE file in the root directory of this source tree.
151
+ */const Gh=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m15 8-3 3-3-3",key:"1oxy1z"}]],Xh=Q("panel-bottom-close",Gh);/**
152
+ * @license lucide-react v0.577.0 - ISC
153
+ *
154
+ * This source code is licensed under the ISC license.
155
+ * See the LICENSE file in the root directory of this source tree.
156
+ */const Jh=[["rect",{width:"18",height:"18",x:"3",y:"3",rx:"2",key:"afitv7"}],["path",{d:"M3 15h18",key:"5xshup"}],["path",{d:"m9 10 3-3 3 3",key:"11gsxs"}]],Zh=Q("panel-bottom-open",Jh);/**
157
+ * @license lucide-react v0.577.0 - ISC
158
+ *
159
+ * This source code is licensed under the ISC license.
160
+ * See the LICENSE file in the root directory of this source tree.
161
+ */const Qh=[["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"}]],ed=Q("panel-left-open",Qh);/**
162
+ * @license lucide-react v0.577.0 - ISC
163
+ *
164
+ * This source code is licensed under the ISC license.
165
+ * See the LICENSE file in the root directory of this source tree.
166
+ */const td=[["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"}]],Os=Q("refresh-cw",td);/**
167
+ * @license lucide-react v0.577.0 - ISC
168
+ *
169
+ * This source code is licensed under the ISC license.
170
+ * See the LICENSE file in the root directory of this source tree.
171
+ */const sd=[["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"}]],id=Q("rotate-ccw",sd);/**
172
+ * @license lucide-react v0.577.0 - ISC
173
+ *
174
+ * This source code is licensed under the ISC license.
175
+ * See the LICENSE file in the root directory of this source tree.
176
+ */const rd=[["path",{d:"M15 12h-5",key:"r7krc0"}],["path",{d:"M15 8h-5",key:"1khuty"}],["path",{d:"M19 17V5a2 2 0 0 0-2-2H4",key:"zz82l3"}],["path",{d:"M8 21h12a2 2 0 0 0 2-2v-1a1 1 0 0 0-1-1H11a1 1 0 0 0-1 1v1a2 2 0 1 1-4 0V5a2 2 0 1 0-4 0v2a1 1 0 0 0 1 1h3",key:"1ph1d7"}]],nd=Q("scroll-text",rd);/**
177
+ * @license lucide-react v0.577.0 - ISC
178
+ *
179
+ * This source code is licensed under the ISC license.
180
+ * See the LICENSE file in the root directory of this source tree.
181
+ */const od=[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]],ad=Q("send",od);/**
182
+ * @license lucide-react v0.577.0 - ISC
183
+ *
184
+ * This source code is licensed under the ISC license.
185
+ * See the LICENSE file in the root directory of this source tree.
186
+ */const ld=[["path",{d:"M20 13c0 5-3.5 7.5-7.66 8.95a1 1 0 0 1-.67-.01C7.5 20.5 4 18 4 13V6a1 1 0 0 1 1-1c2 0 4.5-1.2 6.24-2.72a1.17 1.17 0 0 1 1.52 0C14.51 3.81 17 5 19 5a1 1 0 0 1 1 1z",key:"oel41y"}],["path",{d:"m9 12 2 2 4-4",key:"dzmm74"}]],Qa=Q("shield-check",ld);/**
187
+ * @license lucide-react v0.577.0 - ISC
188
+ *
189
+ * This source code is licensed under the ISC license.
190
+ * See the LICENSE file in the root directory of this source tree.
191
+ */const cd=[["path",{d:"M21 7 6.82 21.18a2.83 2.83 0 0 1-3.99-.01a2.83 2.83 0 0 1 0-4L17 3",key:"1ub6xw"}],["path",{d:"m16 2 6 6",key:"1gw87d"}],["path",{d:"M12 16H4",key:"1cjfip"}]],xi=Q("test-tube-diagonal",cd);/**
192
+ * @license lucide-react v0.577.0 - ISC
193
+ *
194
+ * This source code is licensed under the ISC license.
195
+ * See the LICENSE file in the root directory of this source tree.
196
+ */const hd=[["path",{d:"M12 3v12",key:"1x0j5s"}],["path",{d:"m17 8-5-5-5 5",key:"7q97r8"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}]],dd=Q("upload",hd);/**
197
+ * @license lucide-react v0.577.0 - ISC
198
+ *
199
+ * This source code is licensed under the ISC license.
200
+ * See the LICENSE file in the root directory of this source tree.
201
+ */const ud=[["path",{d:"M14.7 6.3a1 1 0 0 0 0 1.4l1.6 1.6a1 1 0 0 0 1.4 0l3.106-3.105c.32-.322.863-.22.983.218a6 6 0 0 1-8.259 7.057l-7.91 7.91a1 1 0 0 1-2.999-3l7.91-7.91a6 6 0 0 1 7.057-8.259c.438.12.54.662.219.984z",key:"1ngwbx"}]],el=Q("wrench",ud);/**
202
+ * @license lucide-react v0.577.0 - ISC
203
+ *
204
+ * This source code is licensed under the ISC license.
205
+ * See the LICENSE file in the root directory of this source tree.
206
+ */const fd=[["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"}]],pd=Q("zap",fd);function po(e,t){(t==null||t>e.length)&&(t=e.length);for(var s=0,i=Array(t);s<t;s++)i[s]=e[s];return i}function _d(e){if(Array.isArray(e))return e}function md(e,t,s){return(t=wd(t))in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function gd(e,t){var s=e==null?null:typeof Symbol<"u"&&e[Symbol.iterator]||e["@@iterator"];if(s!=null){var i,r,n,a,l=[],h=!0,c=!1;try{if(n=(s=s.call(e)).next,t!==0)for(;!(h=(i=n.call(s)).done)&&(l.push(i.value),l.length!==t);h=!0);}catch(d){c=!0,r=d}finally{try{if(!h&&s.return!=null&&(a=s.return(),Object(a)!==a))return}finally{if(c)throw r}}return l}}function vd(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
207
+ In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _o(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),s.push.apply(s,i)}return s}function mo(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?_o(Object(s),!0).forEach(function(i){md(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):_o(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function xd(e,t){if(e==null)return{};var s,i,r=bd(e,t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);for(i=0;i<n.length;i++)s=n[i],t.indexOf(s)===-1&&{}.propertyIsEnumerable.call(e,s)&&(r[s]=e[s])}return r}function bd(e,t){if(e==null)return{};var s={};for(var i in e)if({}.hasOwnProperty.call(e,i)){if(t.indexOf(i)!==-1)continue;s[i]=e[i]}return s}function yd(e,t){return _d(e)||gd(e,t)||Cd(e,t)||vd()}function Sd(e,t){if(typeof e!="object"||!e)return e;var s=e[Symbol.toPrimitive];if(s!==void 0){var i=s.call(e,t);if(typeof i!="object")return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return(t==="string"?String:Number)(e)}function wd(e){var t=Sd(e,"string");return typeof t=="symbol"?t:t+""}function Cd(e,t){if(e){if(typeof e=="string")return po(e,t);var s={}.toString.call(e).slice(8,-1);return s==="Object"&&e.constructor&&(s=e.constructor.name),s==="Map"||s==="Set"?Array.from(e):s==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(s)?po(e,t):void 0}}function kd(e,t,s){return t in e?Object.defineProperty(e,t,{value:s,enumerable:!0,configurable:!0,writable:!0}):e[t]=s,e}function go(e,t){var s=Object.keys(e);if(Object.getOwnPropertySymbols){var i=Object.getOwnPropertySymbols(e);t&&(i=i.filter(function(r){return Object.getOwnPropertyDescriptor(e,r).enumerable})),s.push.apply(s,i)}return s}function vo(e){for(var t=1;t<arguments.length;t++){var s=arguments[t]!=null?arguments[t]:{};t%2?go(Object(s),!0).forEach(function(i){kd(e,i,s[i])}):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(s)):go(Object(s)).forEach(function(i){Object.defineProperty(e,i,Object.getOwnPropertyDescriptor(s,i))})}return e}function Ed(){for(var e=arguments.length,t=new Array(e),s=0;s<e;s++)t[s]=arguments[s];return function(i){return t.reduceRight(function(r,n){return n(r)},i)}}function Ms(e){return function t(){for(var s=this,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return r.length>=e.length?e.apply(this,r):function(){for(var a=arguments.length,l=new Array(a),h=0;h<a;h++)l[h]=arguments[h];return t.apply(s,[].concat(r,l))}}}function Mi(e){return{}.toString.call(e).includes("Object")}function Nd(e){return!Object.keys(e).length}function Hs(e){return typeof e=="function"}function jd(e,t){return Object.prototype.hasOwnProperty.call(e,t)}function Dd(e,t){return Mi(t)||Dt("changeType"),Object.keys(t).some(function(s){return!jd(e,s)})&&Dt("changeField"),t}function Md(e){Hs(e)||Dt("selectorType")}function Pd(e){Hs(e)||Mi(e)||Dt("handlerType"),Mi(e)&&Object.values(e).some(function(t){return!Hs(t)})&&Dt("handlersType")}function Rd(e){e||Dt("initialIsRequired"),Mi(e)||Dt("initialType"),Nd(e)&&Dt("initialContent")}function Ld(e,t){throw new Error(e[t]||e.default)}var Bd={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"},Dt=Ms(Ld)(Bd),ai={changes:Dd,selector:Md,handler:Pd,initial:Rd};function zd(e){var t=arguments.length>1&&arguments[1]!==void 0?arguments[1]:{};ai.initial(e),ai.handler(t);var s={current:e},i=Ms(Od)(s,t),r=Ms(Ad)(s),n=Ms(ai.changes)(e),a=Ms(Td)(s);function l(){var c=arguments.length>0&&arguments[0]!==void 0?arguments[0]:function(d){return d};return ai.selector(c),c(s.current)}function h(c){Ed(i,r,n,a)(c)}return[l,h]}function Td(e,t){return Hs(t)?t(e.current):t}function Ad(e,t){return e.current=vo(vo({},e.current),t),t}function Od(e,t,s){return Hs(t)?t(e.current):Object.keys(s).forEach(function(i){var r;return(r=t[i])===null||r===void 0?void 0:r.call(t,e.current[i])}),s}var Id={create:zd},$d={paths:{vs:"https://cdn.jsdelivr.net/npm/monaco-editor@0.55.1/min/vs"}};function Fd(e){return function t(){for(var s=this,i=arguments.length,r=new Array(i),n=0;n<i;n++)r[n]=arguments[n];return r.length>=e.length?e.apply(this,r):function(){for(var a=arguments.length,l=new Array(a),h=0;h<a;h++)l[h]=arguments[h];return t.apply(s,[].concat(r,l))}}}function Hd(e){return{}.toString.call(e).includes("Object")}function Wd(e){return e||xo("configIsRequired"),Hd(e)||xo("configType"),e.urls?(Ud(),{paths:{vs:e.urls.monacoBase}}):e}function Ud(){console.warn(tl.deprecation)}function Kd(e,t){throw new Error(e[t]||e.default)}var tl={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!
208
+ You are using deprecated way of configuration.
209
+
210
+ Instead of using
211
+ monaco.config({ urls: { monacoBase: '...' } })
212
+ use
213
+ monaco.config({ paths: { vs: '...' } })
214
+
215
+ For more please check the link https://github.com/suren-atoyan/monaco-loader#config
216
+ `},xo=Fd(Kd)(tl),qd={config:Wd},Vd=function(){for(var t=arguments.length,s=new Array(t),i=0;i<t;i++)s[i]=arguments[i];return function(r){return s.reduceRight(function(n,a){return a(n)},r)}};function sl(e,t){return Object.keys(t).forEach(function(s){t[s]instanceof Object&&e[s]&&Object.assign(t[s],sl(e[s],t[s]))}),mo(mo({},e),t)}var Yd={type:"cancelation",msg:"operation is manually canceled"};function Zi(e){var t=!1,s=new Promise(function(i,r){e.then(function(n){return t?r(Yd):i(n)}),e.catch(r)});return s.cancel=function(){return t=!0},s}var Gd=["monaco"],Xd=Id.create({config:$d,isInitialized:!1,resolve:null,reject:null,monaco:null}),il=yd(Xd,2),Vs=il[0],Fi=il[1];function Jd(e){var t=qd.config(e),s=t.monaco,i=xd(t,Gd);Fi(function(r){return{config:sl(r.config,i),monaco:s}})}function Zd(){var e=Vs(function(t){var s=t.monaco,i=t.isInitialized,r=t.resolve;return{monaco:s,isInitialized:i,resolve:r}});if(!e.isInitialized){if(Fi({isInitialized:!0}),e.monaco)return e.resolve(e.monaco),Zi(Qi);if(window.monaco&&window.monaco.editor)return rl(window.monaco),e.resolve(window.monaco),Zi(Qi);Vd(Qd,tu)(su)}return Zi(Qi)}function Qd(e){return document.body.appendChild(e)}function eu(e){var t=document.createElement("script");return e&&(t.src=e),t}function tu(e){var t=Vs(function(i){var r=i.config,n=i.reject;return{config:r,reject:n}}),s=eu("".concat(t.config.paths.vs,"/loader.js"));return s.onload=function(){return e()},s.onerror=t.reject,s}function su(){var e=Vs(function(s){var i=s.config,r=s.resolve,n=s.reject;return{config:i,resolve:r,reject:n}}),t=window.require;t.config(e.config),t(["vs/editor/editor.main"],function(s){var i=s.m||s;rl(i),e.resolve(i)},function(s){e.reject(s)})}function rl(e){Vs().monaco||Fi({monaco:e})}function iu(){return Vs(function(e){var t=e.monaco;return t})}var Qi=new Promise(function(e,t){return Fi({resolve:e,reject:t})}),nl={config:Jd,init:Zd,__getMonacoInstance:iu},ru={wrapper:{display:"flex",position:"relative",textAlign:"initial"},fullWidth:{width:"100%"},hide:{display:"none"}},er=ru,nu={container:{display:"flex",height:"100%",width:"100%",justifyContent:"center",alignItems:"center"}},ou=nu;function au({children:e}){return ls.createElement("div",{style:ou.container},e)}var lu=au,cu=lu;function hu({width:e,height:t,isEditorReady:s,loading:i,_ref:r,className:n,wrapperProps:a}){return ls.createElement("section",{style:{...er.wrapper,width:e,height:t},...a},!s&&ls.createElement(cu,null,i),ls.createElement("div",{ref:r,style:{...er.fullWidth,...!s&&er.hide},className:n}))}var du=hu,ol=_.memo(du);function uu(e){_.useEffect(e,[])}var al=uu;function fu(e,t,s=!0){let i=_.useRef(!0);_.useEffect(i.current||!s?()=>{i.current=!1}:e,t)}var Je=fu;function Is(){}function ns(e,t,s,i){return pu(e,i)||_u(e,t,s,i)}function pu(e,t){return e.editor.getModel(ll(e,t))}function _u(e,t,s,i){return e.editor.createModel(t,s,i?ll(e,i):void 0)}function ll(e,t){return e.Uri.parse(t)}function mu({original:e,modified:t,language:s,originalLanguage:i,modifiedLanguage:r,originalModelPath:n,modifiedModelPath:a,keepCurrentOriginalModel:l=!1,keepCurrentModifiedModel:h=!1,theme:c="light",loading:d="Loading...",options:f={},height:u="100%",width:g="100%",className:p,wrapperProps:m={},beforeMount:y=Is,onMount:x=Is}){let[b,j]=_.useState(!1),[k,S]=_.useState(!0),E=_.useRef(null),B=_.useRef(null),U=_.useRef(null),X=_.useRef(x),V=_.useRef(y),I=_.useRef(!1);al(()=>{let w=nl.init();return w.then(M=>(B.current=M)&&S(!1)).catch(M=>(M==null?void 0:M.type)!=="cancelation"&&console.error("Monaco initialization: error:",M)),()=>E.current?P():w.cancel()}),Je(()=>{if(E.current&&B.current){let w=E.current.getOriginalEditor(),M=ns(B.current,e||"",i||s||"text",n||"");M!==w.getModel()&&w.setModel(M)}},[n],b),Je(()=>{if(E.current&&B.current){let w=E.current.getModifiedEditor(),M=ns(B.current,t||"",r||s||"text",a||"");M!==w.getModel()&&w.setModel(M)}},[a],b),Je(()=>{let w=E.current.getModifiedEditor();w.getOption(B.current.editor.EditorOption.readOnly)?w.setValue(t||""):t!==w.getValue()&&(w.executeEdits("",[{range:w.getModel().getFullModelRange(),text:t||"",forceMoveMarkers:!0}]),w.pushUndoStop())},[t],b),Je(()=>{var w,M;(M=(w=E.current)==null?void 0:w.getModel())==null||M.original.setValue(e||"")},[e],b),Je(()=>{let{original:w,modified:M}=E.current.getModel();B.current.editor.setModelLanguage(w,i||s||"text"),B.current.editor.setModelLanguage(M,r||s||"text")},[s,i,r],b),Je(()=>{var w;(w=B.current)==null||w.editor.setTheme(c)},[c],b),Je(()=>{var w;(w=E.current)==null||w.updateOptions(f)},[f],b);let D=_.useCallback(()=>{var $;if(!B.current)return;V.current(B.current);let w=ns(B.current,e||"",i||s||"text",n||""),M=ns(B.current,t||"",r||s||"text",a||"");($=E.current)==null||$.setModel({original:w,modified:M})},[s,t,r,e,i,n,a]),C=_.useCallback(()=>{var w;!I.current&&U.current&&(E.current=B.current.editor.createDiffEditor(U.current,{automaticLayout:!0,...f}),D(),(w=B.current)==null||w.editor.setTheme(c),j(!0),I.current=!0)},[f,c,D]);_.useEffect(()=>{b&&X.current(E.current,B.current)},[b]),_.useEffect(()=>{!k&&!b&&C()},[k,b,C]);function P(){var M,$,R,J;let w=(M=E.current)==null?void 0:M.getModel();l||(($=w==null?void 0:w.original)==null||$.dispose()),h||((R=w==null?void 0:w.modified)==null||R.dispose()),(J=E.current)==null||J.dispose()}return ls.createElement(ol,{width:g,height:u,isEditorReady:b,loading:d,_ref:U,className:p,wrapperProps:m})}var gu=mu;_.memo(gu);function vu(e){let t=_.useRef();return _.useEffect(()=>{t.current=e},[e]),t.current}var xu=vu,li=new Map;function bu({defaultValue:e,defaultLanguage:t,defaultPath:s,value:i,language:r,path:n,theme:a="light",line:l,loading:h="Loading...",options:c={},overrideServices:d={},saveViewState:f=!0,keepCurrentModel:u=!1,width:g="100%",height:p="100%",className:m,wrapperProps:y={},beforeMount:x=Is,onMount:b=Is,onChange:j,onValidate:k=Is}){let[S,E]=_.useState(!1),[B,U]=_.useState(!0),X=_.useRef(null),V=_.useRef(null),I=_.useRef(null),D=_.useRef(b),C=_.useRef(x),P=_.useRef(),w=_.useRef(i),M=xu(n),$=_.useRef(!1),R=_.useRef(!1);al(()=>{let O=nl.init();return O.then(K=>(X.current=K)&&U(!1)).catch(K=>(K==null?void 0:K.type)!=="cancelation"&&console.error("Monaco initialization: error:",K)),()=>V.current?L():O.cancel()}),Je(()=>{var K,q,te,se;let O=ns(X.current,e||i||"",t||r||"",n||s||"");O!==((K=V.current)==null?void 0:K.getModel())&&(f&&li.set(M,(q=V.current)==null?void 0:q.saveViewState()),(te=V.current)==null||te.setModel(O),f&&((se=V.current)==null||se.restoreViewState(li.get(n))))},[n],S),Je(()=>{var O;(O=V.current)==null||O.updateOptions(c)},[c],S),Je(()=>{!V.current||i===void 0||(V.current.getOption(X.current.editor.EditorOption.readOnly)?V.current.setValue(i):i!==V.current.getValue()&&(R.current=!0,V.current.executeEdits("",[{range:V.current.getModel().getFullModelRange(),text:i,forceMoveMarkers:!0}]),V.current.pushUndoStop(),R.current=!1))},[i],S),Je(()=>{var K,q;let O=(K=V.current)==null?void 0:K.getModel();O&&r&&((q=X.current)==null||q.editor.setModelLanguage(O,r))},[r],S),Je(()=>{var O;l!==void 0&&((O=V.current)==null||O.revealLine(l))},[l],S),Je(()=>{var O;(O=X.current)==null||O.editor.setTheme(a)},[a],S);let J=_.useCallback(()=>{var O;if(!(!I.current||!X.current)&&!$.current){C.current(X.current);let K=n||s,q=ns(X.current,i||e||"",t||r||"",K||"");V.current=(O=X.current)==null?void 0:O.editor.create(I.current,{model:q,automaticLayout:!0,...c},d),f&&V.current.restoreViewState(li.get(K)),X.current.editor.setTheme(a),l!==void 0&&V.current.revealLine(l),E(!0),$.current=!0}},[e,t,s,i,r,n,c,d,f,a,l]);_.useEffect(()=>{S&&D.current(V.current,X.current)},[S]),_.useEffect(()=>{!B&&!S&&J()},[B,S,J]),w.current=i,_.useEffect(()=>{var O,K;S&&j&&((O=P.current)==null||O.dispose(),P.current=(K=V.current)==null?void 0:K.onDidChangeModelContent(q=>{R.current||j(V.current.getValue(),q)}))},[S,j]),_.useEffect(()=>{if(S){let O=X.current.editor.onDidChangeMarkers(K=>{var te;let q=(te=V.current.getModel())==null?void 0:te.uri;if(q&&K.find(se=>se.path===q.path)){let se=X.current.editor.getModelMarkers({resource:q});k==null||k(se)}});return()=>{O==null||O.dispose()}}return()=>{}},[S,k]);function L(){var O,K;(O=P.current)==null||O.dispose(),u?f&&li.set(n,V.current.saveViewState()):(K=V.current.getModel())==null||K.dispose(),V.current.dispose()}return ls.createElement(ol,{width:g,height:p,isEditorReady:S,loading:h,_ref:I,className:m,wrapperProps:y})}var yu=bu,Su=_.memo(yu),wu=Su;function Cu(e,t){const s=getComputedStyle(e),i=parseFloat(s.fontSize);return t*i}function ku(e,t){const s=getComputedStyle(e.ownerDocument.body),i=parseFloat(s.fontSize);return t*i}function Eu(e){return e/100*window.innerHeight}function Nu(e){return e/100*window.innerWidth}function ju(e){switch(typeof e){case"number":return[e,"px"];case"string":{const t=parseFloat(e);return e.endsWith("%")?[t,"%"]:e.endsWith("px")?[t,"px"]:e.endsWith("rem")?[t,"rem"]:e.endsWith("em")?[t,"em"]:e.endsWith("vh")?[t,"vh"]:e.endsWith("vw")?[t,"vw"]:[t,"%"]}}}function Ps({groupSize:e,panelElement:t,styleProp:s}){let i;const[r,n]=ju(s);switch(n){case"%":{i=r/100*e;break}case"px":{i=r;break}case"rem":{i=ku(t,r);break}case"em":{i=Cu(t,r);break}case"vh":{i=Eu(r);break}case"vw":{i=Nu(r);break}}return i}function qe(e){return parseFloat(e.toFixed(3))}function fs({group:e}){const{orientation:t,panels:s}=e;return s.reduce((i,r)=>(i+=t==="horizontal"?r.element.offsetWidth:r.element.offsetHeight,i),0)}function br(e){const{panels:t}=e,s=fs({group:e});return s===0?t.map(i=>({groupResizeBehavior:i.panelConstraints.groupResizeBehavior,collapsedSize:0,collapsible:i.panelConstraints.collapsible===!0,defaultSize:void 0,disabled:i.panelConstraints.disabled,minSize:0,maxSize:100,panelId:i.id})):t.map(i=>{const{element:r,panelConstraints:n}=i;let a=0;if(n.collapsedSize!==void 0){const d=Ps({groupSize:s,panelElement:r,styleProp:n.collapsedSize});a=qe(d/s*100)}let l;if(n.defaultSize!==void 0){const d=Ps({groupSize:s,panelElement:r,styleProp:n.defaultSize});l=qe(d/s*100)}let h=0;if(n.minSize!==void 0){const d=Ps({groupSize:s,panelElement:r,styleProp:n.minSize});h=qe(d/s*100)}let c=100;if(n.maxSize!==void 0){const d=Ps({groupSize:s,panelElement:r,styleProp:n.maxSize});c=qe(d/s*100)}return{groupResizeBehavior:n.groupResizeBehavior,collapsedSize:a,collapsible:n.collapsible===!0,defaultSize:l,disabled:n.disabled,minSize:h,maxSize:c,panelId:i.id}})}function ue(e,t="Assertion error"){if(!e)throw Error(t)}function yr(e,t){return Array.from(t).sort(e==="horizontal"?Du:Mu)}function Du(e,t){const s=e.element.offsetLeft-t.element.offsetLeft;return s!==0?s:e.element.offsetWidth-t.element.offsetWidth}function Mu(e,t){const s=e.element.offsetTop-t.element.offsetTop;return s!==0?s:e.element.offsetHeight-t.element.offsetHeight}function cl(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.ELEMENT_NODE}function hl(e,t){return{x:e.x>=t.left&&e.x<=t.right?0:Math.min(Math.abs(e.x-t.left),Math.abs(e.x-t.right)),y:e.y>=t.top&&e.y<=t.bottom?0:Math.min(Math.abs(e.y-t.top),Math.abs(e.y-t.bottom))}}function Pu({orientation:e,rects:t,targetRect:s}){const i={x:s.x+s.width/2,y:s.y+s.height/2};let r,n=Number.MAX_VALUE;for(const a of t){const{x:l,y:h}=hl(i,a),c=e==="horizontal"?l:h;c<n&&(n=c,r=a)}return ue(r,"No rect found"),r}let ci;function Ru(){return ci===void 0&&(typeof matchMedia=="function"?ci=!!matchMedia("(pointer:coarse)").matches:ci=!1),ci}function dl(e){const{element:t,orientation:s,panels:i,separators:r}=e,n=yr(s,Array.from(t.children).filter(cl).map(p=>({element:p}))).map(({element:p})=>p),a=[];let l=!1,h=!1,c=-1,d=-1,f=0,u,g=[];{let p=-1;for(const m of n)m.hasAttribute("data-panel")&&(p++,m.ariaDisabled===null&&(f++,c===-1&&(c=p),d=p))}if(f>1){let p=-1;for(const m of n)if(m.hasAttribute("data-panel")){p++;const y=i.find(x=>x.element===m);if(y){if(u){const x=u.element.getBoundingClientRect(),b=m.getBoundingClientRect();let j;if(h){const k=s==="horizontal"?new DOMRect(x.right,x.top,0,x.height):new DOMRect(x.left,x.bottom,x.width,0),S=s==="horizontal"?new DOMRect(b.left,b.top,0,b.height):new DOMRect(b.left,b.top,b.width,0);switch(g.length){case 0:{j=[k,S];break}case 1:{const E=g[0],B=Pu({orientation:s,rects:[x,b],targetRect:E.element.getBoundingClientRect()});j=[E,B===x?S:k];break}default:{j=g;break}}}else g.length?j=g:j=[s==="horizontal"?new DOMRect(x.right,b.top,b.left-x.right,b.height):new DOMRect(b.left,x.bottom,b.width,b.top-x.bottom)];for(const k of j){let S="width"in k?k:k.element.getBoundingClientRect();const E=Ru()?e.resizeTargetMinimumSize.coarse:e.resizeTargetMinimumSize.fine;if(S.width<E){const U=E-S.width;S=new DOMRect(S.x-U/2,S.y,S.width+U,S.height)}if(S.height<E){const U=E-S.height;S=new DOMRect(S.x,S.y-U/2,S.width,S.height+U)}const B=p<=c||p>d;!l&&!B&&a.push({group:e,groupSize:fs({group:e}),panels:[u,y],separator:"width"in k?void 0:k,rect:S}),l=!1}}h=!1,u=y,g=[]}}else if(m.hasAttribute("data-separator")){m.ariaDisabled!==null&&(l=!0);const y=r.find(x=>x.element===m);y?g.push(y):(u=void 0,g=[])}else h=!0}return a}var Nt,Ta;let ul=(Ta=class{constructor(){io(this,Nt,{})}addListener(t,s){const i=Ss(this,Nt)[t];return i===void 0?Ss(this,Nt)[t]=[s]:i.includes(s)||i.push(s),()=>{this.removeListener(t,s)}}emit(t,s){const i=Ss(this,Nt)[t];if(i!==void 0)if(i.length===1)i[0].call(null,s);else{let r=!1,n=null;const a=Array.from(i);for(let l=0;l<a.length;l++){const h=a[l];try{h.call(null,s)}catch(c){n===null&&(r=!0,n=c)}}if(r)throw n}}removeAllListeners(){ro(this,Nt,{})}removeListener(t,s){const i=Ss(this,Nt)[t];if(i!==void 0){const r=i.indexOf(s);r>=0&&i.splice(r,1)}}},Nt=new WeakMap,Ta),lt=new Map;const fl=new ul;function Lu(e){lt=new Map(lt),lt.delete(e)}function bo(e,t){for(const[s]of lt)if(s.id===e)return s}function Mt(e,t){for(const[s,i]of lt)if(s.id===e)return i;if(t)throw Error(`Could not find data for Group with id ${e}`)}function Gt(){return lt}function _n(e,t){return fl.addListener("groupChange",s=>{s.group.id===e&&t(s)})}function xt(e,t){const s=lt.get(e);lt=new Map(lt),lt.set(e,t),fl.emit("groupChange",{group:e,prev:s,next:t})}function Bu(e,t,s){let i,r={x:1/0,y:1/0};for(const n of t){const a=hl(s,n.rect);switch(e){case"horizontal":{a.x<=r.x&&(i=n,r=a);break}case"vertical":{a.y<=r.y&&(i=n,r=a);break}}}return i?{distance:r,hitRegion:i}:void 0}function zu(e){return e!==null&&typeof e=="object"&&"nodeType"in e&&e.nodeType===Node.DOCUMENT_FRAGMENT_NODE}function Tu(e,t){if(e===t)throw new Error("Cannot compare node with itself");const s={a:wo(e),b:wo(t)};let i;for(;s.a.at(-1)===s.b.at(-1);)i=s.a.pop(),s.b.pop();ue(i,"Stacking order can only be calculated for elements with a common ancestor");const r={a:So(yo(s.a)),b:So(yo(s.b))};if(r.a===r.b){const n=i.childNodes,a={a:s.a.at(-1),b:s.b.at(-1)};let l=n.length;for(;l--;){const h=n[l];if(h===a.a)return 1;if(h===a.b)return-1}}return Math.sign(r.a-r.b)}const Au=/\b(?:position|zIndex|opacity|transform|webkitTransform|mixBlendMode|filter|webkitFilter|isolation)\b/;function Ou(e){const t=getComputedStyle(pl(e)??e).display;return t==="flex"||t==="inline-flex"}function Iu(e){const t=getComputedStyle(e);return!!(t.position==="fixed"||t.zIndex!=="auto"&&(t.position!=="static"||Ou(e))||+t.opacity<1||"transform"in t&&t.transform!=="none"||"webkitTransform"in t&&t.webkitTransform!=="none"||"mixBlendMode"in t&&t.mixBlendMode!=="normal"||"filter"in t&&t.filter!=="none"||"webkitFilter"in t&&t.webkitFilter!=="none"||"isolation"in t&&t.isolation==="isolate"||Au.test(t.willChange)||t.webkitOverflowScrolling==="touch")}function yo(e){let t=e.length;for(;t--;){const s=e[t];if(ue(s,"Missing node"),Iu(s))return s}return null}function So(e){return e&&Number(getComputedStyle(e).zIndex)||0}function wo(e){const t=[];for(;e;)t.push(e),e=pl(e);return t}function pl(e){const{parentNode:t}=e;return zu(t)?t.host:t}function $u(e,t){return e.x<t.x+t.width&&e.x+e.width>t.x&&e.y<t.y+t.height&&e.y+e.height>t.y}function Fu({groupElement:e,hitRegion:t,pointerEventTarget:s}){if(!cl(s)||s.contains(e)||e.contains(s))return!0;if(Tu(s,e)>0){let i=s;for(;i;){if(i.contains(e))return!0;if($u(i.getBoundingClientRect(),t))return!1;i=i.parentElement}}return!0}function mn(e,t){const s=[];return t.forEach((i,r)=>{if(r.disabled)return;const n=dl(r),a=Bu(r.orientation,n,{x:e.clientX,y:e.clientY});a&&a.distance.x<=0&&a.distance.y<=0&&Fu({groupElement:r.element,hitRegion:a.hitRegion.rect,pointerEventTarget:e.target})&&s.push(a.hitRegion)}),s}function Hu(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s++)if(e[s]!=t[s])return!1;return!0}function $e(e,t,s=0){return Math.abs(qe(e)-qe(t))<=s}function at(e,t){return $e(e,t)?0:e>t?1:-1}function os({overrideDisabledPanels:e,panelConstraints:t,prevSize:s,size:i}){const{collapsedSize:r=0,collapsible:n,disabled:a,maxSize:l=100,minSize:h=0}=t;if(a&&!e)return s;if(at(i,h)<0)if(n){const c=(r+h)/2;at(i,c)<0?i=r:i=h}else i=h;return i=Math.min(l,i),i=qe(i),i}function Ws({delta:e,initialLayout:t,panelConstraints:s,pivotIndices:i,prevLayout:r,trigger:n}){if($e(e,0))return t;const a=n==="imperative-api",l=Object.values(t),h=Object.values(r),c=[...l],[d,f]=i;ue(d!=null,"Invalid first pivot index"),ue(f!=null,"Invalid second pivot index");let u=0;switch(n){case"keyboard":{{const m=e<0?f:d,y=s[m];ue(y,`Panel constraints not found for index ${m}`);const{collapsedSize:x=0,collapsible:b,minSize:j=0}=y;if(b){const k=l[m];if(ue(k!=null,`Previous layout not found for panel index ${m}`),$e(k,x)){const S=j-k;at(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}{const m=e<0?d:f,y=s[m];ue(y,`No panel constraints found for index ${m}`);const{collapsedSize:x=0,collapsible:b,minSize:j=0}=y;if(b){const k=l[m];if(ue(k!=null,`Previous layout not found for panel index ${m}`),$e(k,j)){const S=k-x;at(S,Math.abs(e))>0&&(e=e<0?0-S:S)}}}break}default:{const m=e<0?f:d,y=s[m];ue(y,`Panel constraints not found for index ${m}`);const x=l[m],{collapsible:b,collapsedSize:j,minSize:k}=y;if(b&&at(x,k)<0)if(e>0){const S=k-j,E=S/2,B=x+e;at(B,k)<0&&(e=at(e,E)<=0?0:S)}else{const S=k-j,E=100-S/2,B=x-e;at(B,k)<0&&(e=at(100+e,E)>0?0:-S)}break}}{const m=e<0?1:-1;let y=e<0?f:d,x=0;for(;;){const j=l[y];ue(j!=null,`Previous layout not found for panel index ${y}`);const k=os({overrideDisabledPanels:a,panelConstraints:s[y],prevSize:j,size:100})-j;if(x+=k,y+=m,y<0||y>=s.length)break}const b=Math.min(Math.abs(e),Math.abs(x));e=e<0?0-b:b}{let m=e<0?d:f;for(;m>=0&&m<s.length;){const y=Math.abs(e)-Math.abs(u),x=l[m];ue(x!=null,`Previous layout not found for panel index ${m}`);const b=x-y,j=os({overrideDisabledPanels:a,panelConstraints:s[m],prevSize:x,size:b});if(!$e(x,j)&&(u+=x-j,c[m]=j,u.toFixed(3).localeCompare(Math.abs(e).toFixed(3),void 0,{numeric:!0})>=0))break;e<0?m--:m++}}if(Hu(h,c))return r;{const m=e<0?f:d,y=l[m];ue(y!=null,`Previous layout not found for panel index ${m}`);const x=y+u,b=os({overrideDisabledPanels:a,panelConstraints:s[m],prevSize:y,size:x});if(c[m]=b,!$e(b,x)){let j=x-b,k=e<0?f:d;for(;k>=0&&k<s.length;){const S=c[k];ue(S!=null,`Previous layout not found for panel index ${k}`);const E=S+j,B=os({overrideDisabledPanels:a,panelConstraints:s[k],prevSize:S,size:E});if($e(S,B)||(j-=B-S,c[k]=B),$e(j,0))break;e>0?k--:k++}}}const g=Object.values(c).reduce((m,y)=>y+m,0);if(!$e(g,100,.1))return r;const p=Object.keys(r);return c.reduce((m,y,x)=>(m[p[x]]=y,m),{})}function Ut(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(t[s]===void 0||at(e[s],t[s])!==0)return!1;return!0}function Kt({layout:e,panelConstraints:t}){const s=Object.values(e),i=[...s],r=i.reduce((l,h)=>l+h,0);if(i.length!==t.length)throw Error(`Invalid ${t.length} panel layout: ${i.map(l=>`${l}%`).join(", ")}`);if(!$e(r,100)&&i.length>0)for(let l=0;l<t.length;l++){const h=i[l];ue(h!=null,`No layout data found for index ${l}`);const c=100/r*h;i[l]=c}let n=0;for(let l=0;l<t.length;l++){const h=s[l];ue(h!=null,`No layout data found for index ${l}`);const c=i[l];ue(c!=null,`No layout data found for index ${l}`);const d=os({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});c!=d&&(n+=c-d,i[l]=d)}if(!$e(n,0))for(let l=0;l<t.length;l++){const h=i[l];ue(h!=null,`No layout data found for index ${l}`);const c=h+n,d=os({overrideDisabledPanels:!0,panelConstraints:t[l],prevSize:h,size:c});if(h!==d&&(n-=d-h,i[l]=d,$e(n,0)))break}const a=Object.keys(e);return i.reduce((l,h,c)=>(l[a[c]]=h,l),{})}function _l({groupId:e,panelId:t}){const s=()=>{const l=Gt();for(const[h,{defaultLayoutDeferred:c,derivedPanelConstraints:d,layout:f,groupSize:u,separatorToPanels:g}]of l)if(h.id===e)return{defaultLayoutDeferred:c,derivedPanelConstraints:d,group:h,groupSize:u,layout:f,separatorToPanels:g};throw Error(`Group ${e} not found`)},i=()=>{const l=s().derivedPanelConstraints.find(h=>h.panelId===t);if(l!==void 0)return l;throw Error(`Panel constraints not found for Panel ${t}`)},r=()=>{const l=s().group.panels.find(h=>h.id===t);if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},n=()=>{const l=s().layout[t];if(l!==void 0)return l;throw Error(`Layout not found for Panel ${t}`)},a=l=>{const h=n();if(l===h)return;const{defaultLayoutDeferred:c,derivedPanelConstraints:d,group:f,groupSize:u,layout:g,separatorToPanels:p}=s(),m=f.panels.findIndex(j=>j.id===t),y=m===f.panels.length-1,x=Ws({delta:y?h-l:l-h,initialLayout:g,panelConstraints:d,pivotIndices:y?[m-1,m]:[m,m+1],prevLayout:g,trigger:"imperative-api"}),b=Kt({layout:x,panelConstraints:d});Ut(g,b)||xt(f,{defaultLayoutDeferred:c,derivedPanelConstraints:d,groupSize:u,layout:b,separatorToPanels:p})};return{collapse:()=>{const{collapsible:l,collapsedSize:h}=i(),{mutableValues:c}=r(),d=n();l&&d!==h&&(c.expandToSize=d,a(h))},expand:()=>{const{collapsible:l,collapsedSize:h,minSize:c}=i(),{mutableValues:d}=r(),f=n();if(l&&f===h){let u=d.expandToSize??c;u===0&&(u=1),a(u)}},getSize:()=>{const{group:l}=s(),h=n(),{element:c}=r(),d=l.orientation==="horizontal"?c.offsetWidth:c.offsetHeight;return{asPercentage:h,inPixels:d}},isCollapsed:()=>{const{collapsible:l,collapsedSize:h}=i(),c=n();return l&&$e(h,c)},resize:l=>{const{group:h}=s(),{element:c}=r(),d=fs({group:h}),f=Ps({groupSize:d,panelElement:c,styleProp:l}),u=qe(f/d*100);a(u)}}}function Co(e){if(e.defaultPrevented)return;const t=Gt();mn(e,t).forEach(s=>{if(s.separator){const i=s.panels.find(r=>r.panelConstraints.defaultSize!==void 0);if(i){const r=i.panelConstraints.defaultSize,n=_l({groupId:s.group.id,panelId:i.id});n&&r!==void 0&&(n.resize(r),e.preventDefault())}}})}function bi(e){const t=Gt();for(const[s]of t)if(s.separators.some(i=>i.element===e))return s;throw Error("Could not find parent Group for separator element")}function ml({groupId:e}){const t=()=>{const s=Gt();for(const[i,r]of s)if(i.id===e)return{group:i,...r};throw Error(`Could not find Group with id "${e}"`)};return{getLayout(){const{defaultLayoutDeferred:s,layout:i}=t();return s?{}:i},setLayout(s){const{defaultLayoutDeferred:i,derivedPanelConstraints:r,group:n,groupSize:a,layout:l,separatorToPanels:h}=t(),c=Kt({layout:s,panelConstraints:r});return i?l:(Ut(l,c)||xt(n,{defaultLayoutDeferred:i,derivedPanelConstraints:r,groupSize:a,layout:c,separatorToPanels:h}),c)}}}function Tt(e,t){const s=bi(e),i=Mt(s.id,!0),r=s.separators.find(d=>d.element===e);ue(r,"Matching separator not found");const n=i.separatorToPanels.get(r);ue(n,"Matching panels not found");const a=n.map(d=>s.panels.indexOf(d)),l=ml({groupId:s.id}).getLayout(),h=Ws({delta:t,initialLayout:l,panelConstraints:i.derivedPanelConstraints,pivotIndices:a,prevLayout:l,trigger:"keyboard"}),c=Kt({layout:h,panelConstraints:i.derivedPanelConstraints});Ut(l,c)||xt(s,{defaultLayoutDeferred:i.defaultLayoutDeferred,derivedPanelConstraints:i.derivedPanelConstraints,groupSize:i.groupSize,layout:c,separatorToPanels:i.separatorToPanels})}function ko(e){if(e.defaultPrevented)return;const t=e.currentTarget,s=bi(t);if(!s.disabled)switch(e.key){case"ArrowDown":{e.preventDefault(),s.orientation==="vertical"&&Tt(t,5);break}case"ArrowLeft":{e.preventDefault(),s.orientation==="horizontal"&&Tt(t,-5);break}case"ArrowRight":{e.preventDefault(),s.orientation==="horizontal"&&Tt(t,5);break}case"ArrowUp":{e.preventDefault(),s.orientation==="vertical"&&Tt(t,-5);break}case"End":{e.preventDefault(),Tt(t,100);break}case"Enter":{e.preventDefault();const i=bi(t),r=Mt(i.id,!0),{derivedPanelConstraints:n,layout:a,separatorToPanels:l}=r,h=i.separators.find(u=>u.element===t);ue(h,"Matching separator not found");const c=l.get(h);ue(c,"Matching panels not found");const d=c[0],f=n.find(u=>u.panelId===d.id);if(ue(f,"Panel metadata not found"),f.collapsible){const u=a[d.id],g=f.collapsedSize===u?i.mutableState.expandedPanelSizes[d.id]??f.minSize:f.collapsedSize;Tt(t,g-u)}break}case"F6":{e.preventDefault();const i=bi(t).separators.map(a=>a.element),r=Array.from(i).findIndex(a=>a===e.currentTarget);ue(r!==null,"Index not found");const n=e.shiftKey?r>0?r-1:i.length-1:r+1<i.length?r+1:0;i[n].focus({preventScroll:!0});break}case"Home":{e.preventDefault(),Tt(t,-100);break}}}let cs={cursorFlags:0,state:"inactive"};const gn=new ul;function qt(){return cs}function Wu(e){return gn.addListener("change",e)}function Uu(e){const t=cs,s={...cs};s.cursorFlags=e,cs=s,gn.emit("change",{prev:t,next:s})}function hs(e){const t=cs;cs=e,gn.emit("change",{prev:t,next:e})}function Eo(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=Gt(),s=mn(e,t),i=new Map;let r=!1;s.forEach(n=>{n.separator&&(r||(r=!0,n.separator.element.focus({preventScroll:!0})));const a=t.get(n.group);a&&i.set(n.group,a.layout)}),hs({cursorFlags:0,hitRegions:s,initialLayoutMap:i,pointerDownAtPoint:{x:e.clientX,y:e.clientY},state:"active"}),s.length&&e.preventDefault()}const Ku=e=>e,tr=()=>{},gl=1,vl=2,xl=4,bl=8,No=3,jo=12;let hi;function Do(){return hi===void 0&&(hi=!1,typeof window<"u"&&(window.navigator.userAgent.includes("Chrome")||window.navigator.userAgent.includes("Firefox"))&&(hi=!0)),hi}function qu({cursorFlags:e,groups:t,state:s}){let i=0,r=0;switch(s){case"active":case"hover":t.forEach(n=>{if(!n.mutableState.disableCursor)switch(n.orientation){case"horizontal":{i++;break}case"vertical":{r++;break}}})}if(!(i===0&&r===0)){switch(s){case"active":{if(e&&Do()){const n=(e&gl)!==0,a=(e&vl)!==0,l=(e&xl)!==0,h=(e&bl)!==0;if(n)return l?"se-resize":h?"ne-resize":"e-resize";if(a)return l?"sw-resize":h?"nw-resize":"w-resize";if(l)return"s-resize";if(h)return"n-resize"}break}}return Do()?i>0&&r>0?"move":i>0?"ew-resize":"ns-resize":i>0&&r>0?"grab":i>0?"col-resize":"row-resize"}}const Mo=new WeakMap;function vn(e){if(e.defaultView===null||e.defaultView===void 0)return;let{prevStyle:t,styleSheet:s}=Mo.get(e)??{};s===void 0&&(s=new e.defaultView.CSSStyleSheet,e.adoptedStyleSheets&&e.adoptedStyleSheets.push(s));const i=qt();switch(i.state){case"active":case"hover":{const r=qu({cursorFlags:i.cursorFlags,groups:i.hitRegions.map(a=>a.group),state:i.state}),n=`*, *:hover {cursor: ${r} !important; }`;if(t===n)return;t=n,r?s.cssRules.length===0?s.insertRule(n):s.replaceSync(n):s.cssRules.length===1&&s.deleteRule(0);break}case"inactive":{t=void 0,s.cssRules.length===1&&s.deleteRule(0);break}}Mo.set(e,{prevStyle:t,styleSheet:s})}function yl({document:e,event:t,hitRegions:s,initialLayoutMap:i,mountedGroups:r,pointerDownAtPoint:n,prevCursorFlags:a}){let l=0;s.forEach(c=>{const{group:d,groupSize:f}=c,{orientation:u,panels:g}=d,{disableCursor:p}=d.mutableState;let m=0;n?u==="horizontal"?m=(t.clientX-n.x)/f*100:m=(t.clientY-n.y)/f*100:u==="horizontal"?m=t.clientX<0?-100:100:m=t.clientY<0?-100:100;const y=i.get(d),x=r.get(d);if(!y||!x)return;const{defaultLayoutDeferred:b,derivedPanelConstraints:j,groupSize:k,layout:S,separatorToPanels:E}=x;if(j&&S&&E){const B=Ws({delta:m,initialLayout:y,panelConstraints:j,pivotIndices:c.panels.map(U=>g.indexOf(U)),prevLayout:S,trigger:"mouse-or-touch"});if(Ut(B,S)){if(m!==0&&!p)switch(u){case"horizontal":{l|=m<0?gl:vl;break}case"vertical":{l|=m<0?xl:bl;break}}}else xt(c.group,{defaultLayoutDeferred:b,derivedPanelConstraints:j,groupSize:k,layout:B,separatorToPanels:E})}});let h=0;t.movementX===0?h|=a&No:h|=l&No,t.movementY===0?h|=a&jo:h|=l&jo,Uu(h),vn(e)}function Po(e){const t=Gt(),s=qt();switch(s.state){case"active":yl({document:e.currentTarget,event:e,hitRegions:s.hitRegions,initialLayoutMap:s.initialLayoutMap,mountedGroups:t,prevCursorFlags:s.cursorFlags})}}function Ro(e){if(e.defaultPrevented)return;const t=qt(),s=Gt();switch(t.state){case"active":{if(e.buttons===0){hs({cursorFlags:0,state:"inactive"}),t.hitRegions.forEach(i=>{const r=Mt(i.group.id,!0);xt(i.group,r)});return}yl({document:e.currentTarget,event:e,hitRegions:t.hitRegions,initialLayoutMap:t.initialLayoutMap,mountedGroups:s,pointerDownAtPoint:t.pointerDownAtPoint,prevCursorFlags:t.cursorFlags});break}default:{const i=mn(e,s);i.length===0?t.state!=="inactive"&&hs({cursorFlags:0,state:"inactive"}):hs({cursorFlags:0,hitRegions:i,state:"hover"}),vn(e.currentTarget);break}}}function Lo(e){if(e.relatedTarget instanceof HTMLIFrameElement)switch(qt().state){case"hover":hs({cursorFlags:0,state:"inactive"})}}function Bo(e){if(e.defaultPrevented||e.pointerType==="mouse"&&e.button>0)return;const t=qt();switch(t.state){case"active":hs({cursorFlags:0,state:"inactive"}),t.hitRegions.length>0&&(vn(e.currentTarget),t.hitRegions.forEach(s=>{const i=Mt(s.group.id,!0);xt(s.group,i)}),e.preventDefault())}}function zo(e){let t=0,s=0;const i={};for(const n of e)if(n.defaultSize!==void 0){t++;const a=qe(n.defaultSize);s+=a,i[n.panelId]=a}else i[n.panelId]=void 0;const r=e.length-t;if(r!==0){const n=qe((100-s)/r);for(const a of e)a.defaultSize===void 0&&(i[a.panelId]=n)}return i}function Vu(e,t,s){if(!s[0])return;const i=e.panels.find(h=>h.element===t);if(!i||!i.onResize)return;const r=fs({group:e}),n=e.orientation==="horizontal"?i.element.offsetWidth:i.element.offsetHeight,a=i.mutableValues.prevSize,l={asPercentage:qe(n/r*100),inPixels:n};i.mutableValues.prevSize=l,i.onResize(l,i.id,a)}function Yu(e,t){if(Object.keys(e).length!==Object.keys(t).length)return!1;for(const s in e)if(e[s]!==t[s])return!1;return!0}function Gu({group:e,nextGroupSize:t,prevGroupSize:s,prevLayout:i}){if(s<=0||t<=0||s===t)return i;let r=0,n=0,a=!1;const l=new Map,h=[];for(const f of e.panels){const u=i[f.id]??0;switch(f.panelConstraints.groupResizeBehavior){case"preserve-pixel-size":{a=!0;const g=u/100*s,p=qe(g/t*100);l.set(f.id,p),r+=p;break}case"preserve-relative-size":default:{h.push(f.id),n+=u;break}}}if(!a||h.length===0)return i;const c=100-r,d={...i};if(l.forEach((f,u)=>{d[u]=f}),n>0)for(const f of h){const u=i[f]??0;d[f]=qe(u/n*c)}else{const f=qe(c/h.length);for(const u of h)d[u]=f}return d}function Xu(e,t){const s=e.map(r=>r.id),i=Object.keys(t);if(s.length!==i.length)return!1;for(const r of s)if(!i.includes(r))return!1;return!0}const ts=new Map;function Ju(e){let t=!0;ue(e.element.ownerDocument.defaultView,"Cannot register an unmounted Group");const s=e.element.ownerDocument.defaultView.ResizeObserver,i=new Set,r=new Set,n=new s(p=>{for(const m of p){const{borderBoxSize:y,target:x}=m;if(x===e.element){if(t){const b=fs({group:e});if(b===0)return;const j=Mt(e.id);if(!j)return;const k=br(e),S=j.defaultLayoutDeferred?zo(k):j.layout,E=Gu({group:e,nextGroupSize:b,prevGroupSize:j.groupSize,prevLayout:S}),B=Kt({layout:E,panelConstraints:k});if(!j.defaultLayoutDeferred&&Ut(j.layout,B)&&Yu(j.derivedPanelConstraints,k)&&j.groupSize===b)return;xt(e,{defaultLayoutDeferred:!1,derivedPanelConstraints:k,groupSize:b,layout:B,separatorToPanels:j.separatorToPanels})}}else Vu(e,x,y)}});n.observe(e.element),e.panels.forEach(p=>{ue(!i.has(p.id),`Panel ids must be unique; id "${p.id}" was used more than once`),i.add(p.id),p.onResize&&n.observe(p.element)});const a=fs({group:e}),l=br(e),h=e.panels.map(({id:p})=>p).join(",");let c=e.mutableState.defaultLayout;c&&(Xu(e.panels,c)||(c=void 0));const d=e.mutableState.layouts[h]??c??zo(l),f=Kt({layout:d,panelConstraints:l}),u=e.element.ownerDocument;ts.set(u,(ts.get(u)??0)+1);const g=new Map;return dl(e).forEach(p=>{p.separator&&g.set(p.separator,p.panels)}),xt(e,{defaultLayoutDeferred:a===0,derivedPanelConstraints:l,groupSize:a,layout:f,separatorToPanels:g}),e.separators.forEach(p=>{ue(!r.has(p.id),`Separator ids must be unique; id "${p.id}" was used more than once`),r.add(p.id),p.element.addEventListener("keydown",ko)}),ts.get(u)===1&&(u.addEventListener("dblclick",Co,!0),u.addEventListener("pointerdown",Eo,!0),u.addEventListener("pointerleave",Po),u.addEventListener("pointermove",Ro),u.addEventListener("pointerout",Lo),u.addEventListener("pointerup",Bo,!0)),function(){t=!1,ts.set(u,Math.max(0,(ts.get(u)??0)-1)),Lu(e),e.separators.forEach(p=>{p.element.removeEventListener("keydown",ko)}),ts.get(u)||(u.removeEventListener("dblclick",Co,!0),u.removeEventListener("pointerdown",Eo,!0),u.removeEventListener("pointerleave",Po),u.removeEventListener("pointermove",Ro),u.removeEventListener("pointerout",Lo),u.removeEventListener("pointerup",Bo,!0)),n.disconnect()}}function Zu(){const[e,t]=_.useState({}),s=_.useCallback(()=>t({}),[]);return[e,s]}function xn(e){const t=_.useId();return`${e??t}`}const Xt=typeof window<"u"?_.useLayoutEffect:_.useEffect;function $s(e){const t=_.useRef(e);return Xt(()=>{t.current=e},[e]),_.useCallback((...s)=>{var i;return(i=t.current)==null?void 0:i.call(t,...s)},[t])}function bn(...e){return $s(t=>{e.forEach(s=>{if(s)switch(typeof s){case"function":{s(t);break}case"object":{s.current=t;break}}})})}function yn(e){const t=_.useRef({...e});return Xt(()=>{for(const s in e)t.current[s]=e[s]},[e]),t.current}const Sl=_.createContext(null);function Qu(e,t){const s=_.useRef({getLayout:()=>({}),setLayout:Ku});_.useImperativeHandle(t,()=>s.current,[]),Xt(()=>{Object.assign(s.current,ml({groupId:e}))})}function Sr({children:e,className:t,defaultLayout:s,disableCursor:i,disabled:r,elementRef:n,groupRef:a,id:l,onLayoutChange:h,onLayoutChanged:c,orientation:d="horizontal",resizeTargetMinimumSize:f={coarse:20,fine:10},style:u,...g}){const p=_.useRef({onLayoutChange:{},onLayoutChanged:{}}),m=$s(I=>{Ut(p.current.onLayoutChange,I)||(p.current.onLayoutChange=I,h==null||h(I))}),y=$s(I=>{Ut(p.current.onLayoutChanged,I)||(p.current.onLayoutChanged=I,c==null||c(I))}),x=xn(l),b=_.useRef(null),[j,k]=Zu(),S=_.useRef({lastExpandedPanelSizes:{},layouts:{},panels:[],resizeTargetMinimumSize:f,separators:[]}),E=bn(b,n);Qu(x,a);const B=$s((I,D)=>{const C=qt(),P=bo(I),w=Mt(I);if(w){let M=!1;switch(C.state){case"active":{M=C.hitRegions.some($=>$.group===P);break}}return{flexGrow:w.layout[D]??1,pointerEvents:M?"none":void 0}}return{flexGrow:(s==null?void 0:s[D])??1}}),U=yn({defaultLayout:s,disableCursor:i}),X=_.useMemo(()=>({get disableCursor(){return!!U.disableCursor},getPanelStyles:B,id:x,orientation:d,registerPanel:I=>{const D=S.current;return D.panels=yr(d,[...D.panels,I]),k(),()=>{D.panels=D.panels.filter(C=>C!==I),k()}},registerSeparator:I=>{const D=S.current;return D.separators=yr(d,[...D.separators,I]),k(),()=>{D.separators=D.separators.filter(C=>C!==I),k()}},togglePanelDisabled:(I,D)=>{const C=S.current.panels.find(M=>M.id===I);C&&(C.panelConstraints.disabled=D);const P=bo(x),w=Mt(x);P&&w&&xt(P,{...w,derivedPanelConstraints:br(P)})},toggleSeparatorDisabled:(I,D)=>{const C=S.current.separators.find(P=>P.id===I);C&&(C.disabled=D)}}),[B,x,k,d,U]),V=_.useRef(null);return Xt(()=>{const I=b.current;if(I===null)return;const D=S.current;let C;if(U.defaultLayout!==void 0&&Object.keys(U.defaultLayout).length===D.panels.length){C={};for(const L of D.panels){const O=U.defaultLayout[L.id];O!==void 0&&(C[L.id]=O)}}const P={disabled:!!r,element:I,id:x,mutableState:{defaultLayout:C,disableCursor:!!U.disableCursor,expandedPanelSizes:S.current.lastExpandedPanelSizes,layouts:S.current.layouts},orientation:d,panels:D.panels,resizeTargetMinimumSize:D.resizeTargetMinimumSize,separators:D.separators};V.current=P;const w=Ju(P),{defaultLayoutDeferred:M,derivedPanelConstraints:$,layout:R}=Mt(P.id,!0);!M&&$.length>0&&(m(R),y(R));const J=_n(x,L=>{const{defaultLayoutDeferred:O,derivedPanelConstraints:K,layout:q}=L.next;if(O||K.length===0)return;const te=P.panels.map(({id:ae})=>ae).join(",");P.mutableState.layouts[te]=q,K.forEach(ae=>{if(ae.collapsible){const{layout:ce}=L.prev??{};if(ce){const fe=$e(ae.collapsedSize,q[ae.panelId]),z=$e(ae.collapsedSize,ce[ae.panelId]);fe&&!z&&(P.mutableState.expandedPanelSizes[ae.panelId]=ce[ae.panelId])}}});const se=qt().state!=="active";m(q),se&&y(q)});return()=>{V.current=null,w(),J()}},[r,x,y,m,d,j,U]),_.useEffect(()=>{const I=V.current;I&&(I.mutableState.defaultLayout=s,I.mutableState.disableCursor=!!i)}),o.jsx(Sl.Provider,{value:X,children:o.jsx("div",{...g,className:t,"data-group":!0,"data-testid":x,id:x,ref:E,style:{height:"100%",width:"100%",overflow:"hidden",...u,display:"flex",flexDirection:d==="horizontal"?"row":"column",flexWrap:"nowrap",touchAction:d==="horizontal"?"pan-y":"pan-x"},children:e})})}Sr.displayName="Group";function Sn(){const e=_.useContext(Sl);return ue(e,"Group Context not found; did you render a Panel or Separator outside of a Group?"),e}function ef(e,t){const{id:s}=Sn(),i=_.useRef({collapse:tr,expand:tr,getSize:()=>({asPercentage:0,inPixels:0}),isCollapsed:()=>!1,resize:tr});_.useImperativeHandle(t,()=>i.current,[]),Xt(()=>{Object.assign(i.current,_l({groupId:s,panelId:e}))})}function Rs({children:e,className:t,collapsedSize:s="0%",collapsible:i=!1,defaultSize:r,disabled:n,elementRef:a,groupResizeBehavior:l="preserve-relative-size",id:h,maxSize:c="100%",minSize:d="0%",onResize:f,panelRef:u,style:g,...p}){const m=!!h,y=xn(h),x=yn({disabled:n}),b=_.useRef(null),j=bn(b,a),{getPanelStyles:k,id:S,orientation:E,registerPanel:B,togglePanelDisabled:U}=Sn(),X=f!==null,V=$s((D,C,P)=>{f==null||f(D,h,P)});Xt(()=>{const D=b.current;if(D!==null){const C={element:D,id:y,idIsStable:m,mutableValues:{expandToSize:void 0,prevSize:void 0},onResize:X?V:void 0,panelConstraints:{groupResizeBehavior:l,collapsedSize:s,collapsible:i,defaultSize:r,disabled:x.disabled,maxSize:c,minSize:d}};return B(C)}},[l,s,i,r,X,y,m,c,d,V,B,x]),_.useEffect(()=>{U(y,!!n)},[n,y,U]),ef(y,u);const I=_.useSyncExternalStore(D=>_n(S,D),()=>JSON.stringify(k(S,y)),()=>JSON.stringify(k(S,y)));return o.jsx("div",{...p,"aria-disabled":n||void 0,"data-panel":!0,"data-testid":y,id:y,ref:j,style:{...tf,display:"flex",flexBasis:0,flexShrink:1,overflow:"visible",...JSON.parse(I)},children:o.jsx("div",{className:t,style:{maxHeight:"100%",maxWidth:"100%",flexGrow:1,overflow:"auto",...g,touchAction:E==="horizontal"?"pan-y":"pan-x"},children:e})})}Rs.displayName="Panel";const tf={minHeight:0,maxHeight:"100%",height:"auto",minWidth:0,maxWidth:"100%",width:"auto",border:"none",borderWidth:0,padding:0,margin:0};function sf({layout:e,panelConstraints:t,panelId:s,panelIndex:i}){let r,n;const a=e[s],l=t.find(h=>h.panelId===s);if(l){const h=l.maxSize,c=l.collapsible?l.collapsedSize:l.minSize,d=[i,i+1];n=Kt({layout:Ws({delta:c-a,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[s],r=Kt({layout:Ws({delta:h-a,initialLayout:e,panelConstraints:t,pivotIndices:d,prevLayout:e}),panelConstraints:t})[s]}return{valueControls:s,valueMax:r,valueMin:n,valueNow:a}}function wr({children:e,className:t,disabled:s,elementRef:i,id:r,style:n,...a}){const l=xn(r),h=yn({disabled:s}),[c,d]=_.useState({}),[f,u]=_.useState("inactive"),g=_.useRef(null),p=bn(g,i),{disableCursor:m,id:y,orientation:x,registerSeparator:b,toggleSeparatorDisabled:j}=Sn(),k=x==="horizontal"?"vertical":"horizontal";Xt(()=>{const E=g.current;if(E!==null){const B={disabled:h.disabled,element:E,id:l},U=b(B),X=Wu(I=>{u(I.next.state!=="inactive"&&I.next.hitRegions.some(D=>D.separator===B)?I.next.state:"inactive")}),V=_n(y,I=>{const{derivedPanelConstraints:D,layout:C,separatorToPanels:P}=I.next,w=P.get(B);if(w){const M=w[0],$=w.indexOf(M);d(sf({layout:C,panelConstraints:D,panelId:M.id,panelIndex:$}))}});return()=>{X(),V(),U()}}},[y,l,b,h]),_.useEffect(()=>{j(l,!!s)},[s,l,j]);let S;return s&&!m&&(S="not-allowed"),o.jsx("div",{...a,"aria-controls":c.valueControls,"aria-disabled":s||void 0,"aria-orientation":k,"aria-valuemax":c.valueMax,"aria-valuemin":c.valueMin,"aria-valuenow":c.valueNow,children:e,className:t,"data-separator":s?"disabled":f,"data-testid":l,id:l,ref:p,role:"separator",style:{flexBasis:"auto",cursor:S,...n,flexGrow:0,flexShrink:0,touchAction:"none"},tabIndex:s?void 0:0})}wr.displayName="Separator";const rf={ghost:"hover:bg-[#F8F4F0] text-[#36342E]",subtle:"hover:bg-[#ECEAE3] text-[#6B6960]"},nf={sm:"w-7 h-7",md:"w-8 h-8"},of={sm:14,md:16};function St({icon:e,label:t,size:s="md",variant:i="ghost",onClick:r,className:n="",disabled:a=!1,title:l}){return o.jsx("button",{type:"button","aria-label":t,title:l??t,disabled:a,onClick:r,className:["inline-flex items-center justify-center rounded-btn transition-colors",rf[i],nf[s],a?"opacity-40 cursor-not-allowed":"",n].filter(Boolean).join(" "),children:o.jsx(e,{size:of[s]})})}function af({x:e,y:t,items:s,onClose:i}){const[r,n]=_.useState(0),a=_.useRef(null),l=_.useRef([]);_.useEffect(()=>{var c;(c=l.current[0])==null||c.focus()},[]),_.useEffect(()=>{const c=d=>{a.current&&!a.current.contains(d.target)&&i()};return document.addEventListener("mousedown",c),()=>document.removeEventListener("mousedown",c)},[i]);const h=_.useCallback(c=>{var d,f;switch(c.key){case"Escape":c.preventDefault(),i();break;case"ArrowDown":c.preventDefault(),n(u=>{var p;const g=(u+1)%s.length;return(p=l.current[g])==null||p.focus(),g});break;case"ArrowUp":c.preventDefault(),n(u=>{var p;const g=(u-1+s.length)%s.length;return(p=l.current[g])==null||p.focus(),g});break;case"Home":c.preventDefault(),n(0),(d=l.current[0])==null||d.focus();break;case"End":c.preventDefault(),n(s.length-1),(f=l.current[s.length-1])==null||f.focus();break}},[s.length,i]);return o.jsx("div",{ref:a,role:"menu",className:"bg-card border border-border rounded-card shadow-card-hover py-1 min-w-[160px]",style:{position:"fixed",left:e,top:t,zIndex:100},onKeyDown:h,children:s.map((c,d)=>{const f=c.icon,u=c.variant==="danger";return o.jsxs("button",{ref:g=>{l.current[d]=g},role:"menuitem",tabIndex:r===d?0:-1,onClick:()=>{c.onClick(),i()},className:["flex items-center gap-2 w-full text-left px-3 py-2 text-sm transition-colors",u?"text-danger hover:bg-danger/10":"text-ink hover:bg-hover"].join(" "),children:[o.jsx(f,{size:14}),c.label]},c.label)})})}/**
217
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
218
+ * @license MIT
219
+ *
220
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
221
+ * @license MIT
222
+ *
223
+ * Originally forked from (with the author's permission):
224
+ * Fabrice Bellard's javascript vt100 for jslinux:
225
+ * http://bellard.org/jslinux/
226
+ * Copyright (c) 2011 Fabrice Bellard
227
+ */var wl=Object.defineProperty,lf=Object.getOwnPropertyDescriptor,cf=(e,t)=>{for(var s in t)wl(e,s,{get:t[s],enumerable:!0})},be=(e,t,s,i)=>{for(var r=i>1?void 0:i?lf(t,s):t,n=e.length-1,a;n>=0;n--)(a=e[n])&&(r=(i?a(t,s,r):a(r))||r);return i&&r&&wl(t,s,r),r},H=(e,t)=>(s,i)=>t(s,i,e),To="Terminal input",Cr={get:()=>To,set:e=>To=e},Ao="Too much output to announce, navigate to rows manually to read",kr={get:()=>Ao,set:e=>Ao=e};function hf(e){return e.replace(/\r?\n/g,"\r")}function df(e,t){return t?"\x1B[200~"+e+"\x1B[201~":e}function uf(e,t){e.clipboardData&&e.clipboardData.setData("text/plain",t.selectionText),e.preventDefault()}function ff(e,t,s,i){if(e.stopPropagation(),e.clipboardData){let r=e.clipboardData.getData("text/plain");Cl(r,t,s,i)}}function Cl(e,t,s,i){e=hf(e),e=df(e,s.decPrivateModes.bracketedPasteMode&&i.rawOptions.ignoreBracketedPasteMode!==!0),s.triggerDataEvent(e,!0),t.value=""}function kl(e,t,s){let i=s.getBoundingClientRect(),r=e.clientX-i.left-10,n=e.clientY-i.top-10;t.style.width="20px",t.style.height="20px",t.style.left=`${r}px`,t.style.top=`${n}px`,t.style.zIndex="1000",t.focus()}function Oo(e,t,s,i,r){kl(e,t,s),r&&i.rightClickSelect(e),t.value=i.selectionText,t.select()}function Et(e){return e>65535?(e-=65536,String.fromCharCode((e>>10)+55296)+String.fromCharCode(e%1024+56320)):String.fromCharCode(e)}function Hi(e,t=0,s=e.length){let i="";for(let r=t;r<s;++r){let n=e[r];n>65535?(n-=65536,i+=String.fromCharCode((n>>10)+55296)+String.fromCharCode(n%1024+56320)):i+=String.fromCharCode(n)}return i}var pf=class{constructor(){this._interim=0}clear(){this._interim=0}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r=0;if(this._interim){let n=e.charCodeAt(r++);56320<=n&&n<=57343?t[i++]=(this._interim-55296)*1024+n-56320+65536:(t[i++]=this._interim,t[i++]=n),this._interim=0}for(let n=r;n<s;++n){let a=e.charCodeAt(n);if(55296<=a&&a<=56319){if(++n>=s)return this._interim=a,i;let l=e.charCodeAt(n);56320<=l&&l<=57343?t[i++]=(a-55296)*1024+l-56320+65536:(t[i++]=a,t[i++]=l);continue}a!==65279&&(t[i++]=a)}return i}},_f=class{constructor(){this.interim=new Uint8Array(3)}clear(){this.interim.fill(0)}decode(e,t){let s=e.length;if(!s)return 0;let i=0,r,n,a,l,h=0,c=0;if(this.interim[0]){let u=!1,g=this.interim[0];g&=(g&224)===192?31:(g&240)===224?15:7;let p=0,m;for(;(m=this.interim[++p]&63)&&p<4;)g<<=6,g|=m;let y=(this.interim[0]&224)===192?2:(this.interim[0]&240)===224?3:4,x=y-p;for(;c<x;){if(c>=s)return 0;if(m=e[c++],(m&192)!==128){c--,u=!0;break}else this.interim[p++]=m,g<<=6,g|=m&63}u||(y===2?g<128?c--:t[i++]=g:y===3?g<2048||g>=55296&&g<=57343||g===65279||(t[i++]=g):g<65536||g>1114111||(t[i++]=g)),this.interim.fill(0)}let d=s-4,f=c;for(;f<s;){for(;f<d&&!((r=e[f])&128)&&!((n=e[f+1])&128)&&!((a=e[f+2])&128)&&!((l=e[f+3])&128);)t[i++]=r,t[i++]=n,t[i++]=a,t[i++]=l,f+=4;if(r=e[f++],r<128)t[i++]=r;else if((r&224)===192){if(f>=s)return this.interim[0]=r,i;if(n=e[f++],(n&192)!==128){f--;continue}if(h=(r&31)<<6|n&63,h<128){f--;continue}t[i++]=h}else if((r&240)===224){if(f>=s)return this.interim[0]=r,i;if(n=e[f++],(n&192)!==128){f--;continue}if(f>=s)return this.interim[0]=r,this.interim[1]=n,i;if(a=e[f++],(a&192)!==128){f--;continue}if(h=(r&15)<<12|(n&63)<<6|a&63,h<2048||h>=55296&&h<=57343||h===65279)continue;t[i++]=h}else if((r&248)===240){if(f>=s)return this.interim[0]=r,i;if(n=e[f++],(n&192)!==128){f--;continue}if(f>=s)return this.interim[0]=r,this.interim[1]=n,i;if(a=e[f++],(a&192)!==128){f--;continue}if(f>=s)return this.interim[0]=r,this.interim[1]=n,this.interim[2]=a,i;if(l=e[f++],(l&192)!==128){f--;continue}if(h=(r&7)<<18|(n&63)<<12|(a&63)<<6|l&63,h<65536||h>1114111)continue;t[i++]=h}}return i}},El="",jt=" ",Ys=class Nl{constructor(){this.fg=0,this.bg=0,this.extended=new Pi}static toColorRGB(t){return[t>>>16&255,t>>>8&255,t&255]}static fromColorRGB(t){return(t[0]&255)<<16|(t[1]&255)<<8|t[2]&255}clone(){let t=new Nl;return t.fg=this.fg,t.bg=this.bg,t.extended=this.extended.clone(),t}isInverse(){return this.fg&67108864}isBold(){return this.fg&134217728}isUnderline(){return this.hasExtendedAttrs()&&this.extended.underlineStyle!==0?1:this.fg&268435456}isBlink(){return this.fg&536870912}isInvisible(){return this.fg&1073741824}isItalic(){return this.bg&67108864}isDim(){return this.bg&134217728}isStrikethrough(){return this.fg&2147483648}isProtected(){return this.bg&536870912}isOverline(){return this.bg&1073741824}getFgColorMode(){return this.fg&50331648}getBgColorMode(){return this.bg&50331648}isFgRGB(){return(this.fg&50331648)===50331648}isBgRGB(){return(this.bg&50331648)===50331648}isFgPalette(){return(this.fg&50331648)===16777216||(this.fg&50331648)===33554432}isBgPalette(){return(this.bg&50331648)===16777216||(this.bg&50331648)===33554432}isFgDefault(){return(this.fg&50331648)===0}isBgDefault(){return(this.bg&50331648)===0}isAttributeDefault(){return this.fg===0&&this.bg===0}getFgColor(){switch(this.fg&50331648){case 16777216:case 33554432:return this.fg&255;case 50331648:return this.fg&16777215;default:return-1}}getBgColor(){switch(this.bg&50331648){case 16777216:case 33554432:return this.bg&255;case 50331648:return this.bg&16777215;default:return-1}}hasExtendedAttrs(){return this.bg&268435456}updateExtended(){this.extended.isEmpty()?this.bg&=-268435457:this.bg|=268435456}getUnderlineColor(){if(this.bg&268435456&&~this.extended.underlineColor)switch(this.extended.underlineColor&50331648){case 16777216:case 33554432:return this.extended.underlineColor&255;case 50331648:return this.extended.underlineColor&16777215;default:return this.getFgColor()}return this.getFgColor()}getUnderlineColorMode(){return this.bg&268435456&&~this.extended.underlineColor?this.extended.underlineColor&50331648:this.getFgColorMode()}isUnderlineColorRGB(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===50331648:this.isFgRGB()}isUnderlineColorPalette(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===16777216||(this.extended.underlineColor&50331648)===33554432:this.isFgPalette()}isUnderlineColorDefault(){return this.bg&268435456&&~this.extended.underlineColor?(this.extended.underlineColor&50331648)===0:this.isFgDefault()}getUnderlineStyle(){return this.fg&268435456?this.bg&268435456?this.extended.underlineStyle:1:0}getUnderlineVariantOffset(){return this.extended.underlineVariantOffset}},Pi=class jl{constructor(t=0,s=0){this._ext=0,this._urlId=0,this._ext=t,this._urlId=s}get ext(){return this._urlId?this._ext&-469762049|this.underlineStyle<<26:this._ext}set ext(t){this._ext=t}get underlineStyle(){return this._urlId?5:(this._ext&469762048)>>26}set underlineStyle(t){this._ext&=-469762049,this._ext|=t<<26&469762048}get underlineColor(){return this._ext&67108863}set underlineColor(t){this._ext&=-67108864,this._ext|=t&67108863}get urlId(){return this._urlId}set urlId(t){this._urlId=t}get underlineVariantOffset(){let t=(this._ext&3758096384)>>29;return t<0?t^4294967288:t}set underlineVariantOffset(t){this._ext&=536870911,this._ext|=t<<29&3758096384}clone(){return new jl(this._ext,this._urlId)}isEmpty(){return this.underlineStyle===0&&this._urlId===0}},st=class Dl extends Ys{constructor(){super(...arguments),this.content=0,this.fg=0,this.bg=0,this.extended=new Pi,this.combinedData=""}static fromCharData(t){let s=new Dl;return s.setFromCharData(t),s}isCombined(){return this.content&2097152}getWidth(){return this.content>>22}getChars(){return this.content&2097152?this.combinedData:this.content&2097151?Et(this.content&2097151):""}getCode(){return this.isCombined()?this.combinedData.charCodeAt(this.combinedData.length-1):this.content&2097151}setFromCharData(t){this.fg=t[0],this.bg=0;let s=!1;if(t[1].length>2)s=!0;else if(t[1].length===2){let i=t[1].charCodeAt(0);if(55296<=i&&i<=56319){let r=t[1].charCodeAt(1);56320<=r&&r<=57343?this.content=(i-55296)*1024+r-56320+65536|t[2]<<22:s=!0}else s=!0}else this.content=t[1].charCodeAt(0)|t[2]<<22;s&&(this.combinedData=t[1],this.content=2097152|t[2]<<22)}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Io="di$target",Er="di$dependencies",sr=new Map;function mf(e){return e[Er]||[]}function Le(e){if(sr.has(e))return sr.get(e);let t=function(s,i,r){if(arguments.length!==3)throw new Error("@IServiceName-decorator can only be used to decorate a parameter");gf(t,s,r)};return t._id=e,sr.set(e,t),t}function gf(e,t,s){t[Io]===t?t[Er].push({id:e,index:s}):(t[Er]=[{id:e,index:s}],t[Io]=t)}var Fe=Le("BufferService"),Ml=Le("CoreMouseService"),Jt=Le("CoreService"),vf=Le("CharsetService"),wn=Le("InstantiationService"),Pl=Le("LogService"),He=Le("OptionsService"),Rl=Le("OscLinkService"),xf=Le("UnicodeService"),Gs=Le("DecorationService"),Nr=class{constructor(e,t,s){this._bufferService=e,this._optionsService=t,this._oscLinkService=s}provideLinks(e,t){var d;let s=this._bufferService.buffer.lines.get(e-1);if(!s){t(void 0);return}let i=[],r=this._optionsService.rawOptions.linkHandler,n=new st,a=s.getTrimmedLength(),l=-1,h=-1,c=!1;for(let f=0;f<a;f++)if(!(h===-1&&!s.hasContent(f))){if(s.loadCell(f,n),n.hasExtendedAttrs()&&n.extended.urlId)if(h===-1){h=f,l=n.extended.urlId;continue}else c=n.extended.urlId!==l;else h!==-1&&(c=!0);if(c||h!==-1&&f===a-1){let u=(d=this._oscLinkService.getLinkData(l))==null?void 0:d.uri;if(u){let g={start:{x:h+1,y:e},end:{x:f+(!c&&f===a-1?1:0),y:e}},p=!1;if(!(r!=null&&r.allowNonHttpProtocols))try{let m=new URL(u);["http:","https:"].includes(m.protocol)||(p=!0)}catch{p=!0}p||i.push({text:u,range:g,activate:(m,y)=>r?r.activate(m,y,g):bf(m,y),hover:(m,y)=>{var x;return(x=r==null?void 0:r.hover)==null?void 0:x.call(r,m,y,g)},leave:(m,y)=>{var x;return(x=r==null?void 0:r.leave)==null?void 0:x.call(r,m,y,g)}})}c=!1,n.hasExtendedAttrs()&&n.extended.urlId?(h=f,l=n.extended.urlId):(h=-1,l=-1)}}t(i)}};Nr=be([H(0,Fe),H(1,He),H(2,Rl)],Nr);function bf(e,t){if(confirm(`Do you want to navigate to ${t}?
228
+
229
+ WARNING: This link could potentially be dangerous`)){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}}var Wi=Le("CharSizeService"),bt=Le("CoreBrowserService"),Cn=Le("MouseService"),yt=Le("RenderService"),yf=Le("SelectionService"),Ll=Le("CharacterJoinerService"),_s=Le("ThemeService"),Bl=Le("LinkProviderService"),Sf=class{constructor(){this.listeners=[],this.unexpectedErrorHandler=function(e){setTimeout(()=>{throw e.stack?$o.isErrorNoTelemetry(e)?new $o(e.message+`
230
+
231
+ `+e.stack):new Error(e.message+`
232
+
233
+ `+e.stack):e},0)}}addListener(e){return this.listeners.push(e),()=>{this._removeListener(e)}}emit(e){this.listeners.forEach(t=>{t(e)})}_removeListener(e){this.listeners.splice(this.listeners.indexOf(e),1)}setUnexpectedErrorHandler(e){this.unexpectedErrorHandler=e}getUnexpectedErrorHandler(){return this.unexpectedErrorHandler}onUnexpectedError(e){this.unexpectedErrorHandler(e),this.emit(e)}onUnexpectedExternalError(e){this.unexpectedErrorHandler(e)}},wf=new Sf;function yi(e){Cf(e)||wf.onUnexpectedError(e)}var jr="Canceled";function Cf(e){return e instanceof kf?!0:e instanceof Error&&e.name===jr&&e.message===jr}var kf=class extends Error{constructor(){super(jr),this.name=this.message}};function Ef(e){return new Error(`Illegal argument: ${e}`)}var $o=class Dr extends Error{constructor(t){super(t),this.name="CodeExpectedError"}static fromError(t){if(t instanceof Dr)return t;let s=new Dr;return s.message=t.message,s.stack=t.stack,s}static isErrorNoTelemetry(t){return t.name==="CodeExpectedError"}},Mr=class zl extends Error{constructor(t){super(t||"An unexpected bug occurred."),Object.setPrototypeOf(this,zl.prototype)}};function Ge(e,t=0){return e[e.length-(1+t)]}var Nf;(e=>{function t(n){return n<0}e.isLessThan=t;function s(n){return n<=0}e.isLessThanOrEqual=s;function i(n){return n>0}e.isGreaterThan=i;function r(n){return n===0}e.isNeitherLessOrGreaterThan=r,e.greaterThan=1,e.lessThan=-1,e.neitherLessOrGreaterThan=0})(Nf||(Nf={}));function jf(e,t){let s=this,i=!1,r;return function(){return i||(i=!0,t||(r=e.apply(s,arguments))),r}}var Tl;(e=>{function t(k){return k&&typeof k=="object"&&typeof k[Symbol.iterator]=="function"}e.is=t;let s=Object.freeze([]);function i(){return s}e.empty=i;function*r(k){yield k}e.single=r;function n(k){return t(k)?k:r(k)}e.wrap=n;function a(k){return k||s}e.from=a;function*l(k){for(let S=k.length-1;S>=0;S--)yield k[S]}e.reverse=l;function h(k){return!k||k[Symbol.iterator]().next().done===!0}e.isEmpty=h;function c(k){return k[Symbol.iterator]().next().value}e.first=c;function d(k,S){let E=0;for(let B of k)if(S(B,E++))return!0;return!1}e.some=d;function f(k,S){for(let E of k)if(S(E))return E}e.find=f;function*u(k,S){for(let E of k)S(E)&&(yield E)}e.filter=u;function*g(k,S){let E=0;for(let B of k)yield S(B,E++)}e.map=g;function*p(k,S){let E=0;for(let B of k)yield*S(B,E++)}e.flatMap=p;function*m(...k){for(let S of k)yield*S}e.concat=m;function y(k,S,E){let B=E;for(let U of k)B=S(B,U);return B}e.reduce=y;function*x(k,S,E=k.length){for(S<0&&(S+=k.length),E<0?E+=k.length:E>k.length&&(E=k.length);S<E;S++)yield k[S]}e.slice=x;function b(k,S=Number.POSITIVE_INFINITY){let E=[];if(S===0)return[E,k];let B=k[Symbol.iterator]();for(let U=0;U<S;U++){let X=B.next();if(X.done)return[E,e.empty()];E.push(X.value)}return[E,{[Symbol.iterator](){return B}}]}e.consume=b;async function j(k){let S=[];for await(let E of k)S.push(E);return Promise.resolve(S)}e.asyncToArray=j})(Tl||(Tl={}));function Vt(e){if(Tl.is(e)){let t=[];for(let s of e)if(s)try{s.dispose()}catch(i){t.push(i)}if(t.length===1)throw t[0];if(t.length>1)throw new AggregateError(t,"Encountered errors while disposing of store");return Array.isArray(e)?[]:e}else if(e)return e.dispose(),e}function Df(...e){return _e(()=>Vt(e))}function _e(e){return{dispose:jf(()=>{e()})}}var Al=class Ol{constructor(){this._toDispose=new Set,this._isDisposed=!1}dispose(){this._isDisposed||(this._isDisposed=!0,this.clear())}get isDisposed(){return this._isDisposed}clear(){if(this._toDispose.size!==0)try{Vt(this._toDispose)}finally{this._toDispose.clear()}}add(t){if(!t)return t;if(t===this)throw new Error("Cannot register a disposable on itself!");return this._isDisposed?Ol.DISABLE_DISPOSED_WARNING||console.warn(new Error("Trying to add a disposable to a DisposableStore that has already been disposed of. The added object will be leaked!").stack):this._toDispose.add(t),t}delete(t){if(t){if(t===this)throw new Error("Cannot dispose a disposable on itself!");this._toDispose.delete(t),t.dispose()}}deleteAndLeak(t){t&&this._toDispose.has(t)&&(this._toDispose.delete(t),void 0)}};Al.DISABLE_DISPOSED_WARNING=!1;var Pt=Al,re=class{constructor(){this._store=new Pt,this._store}dispose(){this._store.dispose()}_register(e){if(e===this)throw new Error("Cannot register a disposable on itself!");return this._store.add(e)}};re.None=Object.freeze({dispose(){}});var ps=class{constructor(){this._isDisposed=!1}get value(){return this._isDisposed?void 0:this._value}set value(e){var t;this._isDisposed||e===this._value||((t=this._value)==null||t.dispose(),this._value=e)}clear(){this.value=void 0}dispose(){var e;this._isDisposed=!0,(e=this._value)==null||e.dispose(),this._value=void 0}clearAndLeak(){let e=this._value;return this._value=void 0,e}},mt=typeof window=="object"?window:globalThis,Pr=class Rr{constructor(t){this.element=t,this.next=Rr.Undefined,this.prev=Rr.Undefined}};Pr.Undefined=new Pr(void 0);var me=Pr,Fo=class{constructor(){this._first=me.Undefined,this._last=me.Undefined,this._size=0}get size(){return this._size}isEmpty(){return this._first===me.Undefined}clear(){let e=this._first;for(;e!==me.Undefined;){let t=e.next;e.prev=me.Undefined,e.next=me.Undefined,e=t}this._first=me.Undefined,this._last=me.Undefined,this._size=0}unshift(e){return this._insert(e,!1)}push(e){return this._insert(e,!0)}_insert(e,t){let s=new me(e);if(this._first===me.Undefined)this._first=s,this._last=s;else if(t){let r=this._last;this._last=s,s.prev=r,r.next=s}else{let r=this._first;this._first=s,s.next=r,r.prev=s}this._size+=1;let i=!1;return()=>{i||(i=!0,this._remove(s))}}shift(){if(this._first!==me.Undefined){let e=this._first.element;return this._remove(this._first),e}}pop(){if(this._last!==me.Undefined){let e=this._last.element;return this._remove(this._last),e}}_remove(e){if(e.prev!==me.Undefined&&e.next!==me.Undefined){let t=e.prev;t.next=e.next,e.next.prev=t}else e.prev===me.Undefined&&e.next===me.Undefined?(this._first=me.Undefined,this._last=me.Undefined):e.next===me.Undefined?(this._last=this._last.prev,this._last.next=me.Undefined):e.prev===me.Undefined&&(this._first=this._first.next,this._first.prev=me.Undefined);this._size-=1}*[Symbol.iterator](){let e=this._first;for(;e!==me.Undefined;)yield e.element,e=e.next}},Mf=globalThis.performance&&typeof globalThis.performance.now=="function",Pf=class Il{static create(t){return new Il(t)}constructor(t){this._now=Mf&&t===!1?Date.now:globalThis.performance.now.bind(globalThis.performance),this._startTime=this._now(),this._stopTime=-1}stop(){this._stopTime=this._now()}reset(){this._startTime=this._now(),this._stopTime=-1}elapsed(){return this._stopTime!==-1?this._stopTime-this._startTime:this._now()-this._startTime}},Ae;(e=>{e.None=()=>re.None;function t(D,C){return f(D,()=>{},0,void 0,!0,void 0,C)}e.defer=t;function s(D){return(C,P=null,w)=>{let M=!1,$;return $=D(R=>{if(!M)return $?$.dispose():M=!0,C.call(P,R)},null,w),M&&$.dispose(),$}}e.once=s;function i(D,C,P){return c((w,M=null,$)=>D(R=>w.call(M,C(R)),null,$),P)}e.map=i;function r(D,C,P){return c((w,M=null,$)=>D(R=>{C(R),w.call(M,R)},null,$),P)}e.forEach=r;function n(D,C,P){return c((w,M=null,$)=>D(R=>C(R)&&w.call(M,R),null,$),P)}e.filter=n;function a(D){return D}e.signal=a;function l(...D){return(C,P=null,w)=>{let M=Df(...D.map($=>$(R=>C.call(P,R))));return d(M,w)}}e.any=l;function h(D,C,P,w){let M=P;return i(D,$=>(M=C(M,$),M),w)}e.reduce=h;function c(D,C){let P,w={onWillAddFirstListener(){P=D(M.fire,M)},onDidRemoveLastListener(){P==null||P.dispose()}},M=new T(w);return C==null||C.add(M),M.event}function d(D,C){return C instanceof Array?C.push(D):C&&C.add(D),D}function f(D,C,P=100,w=!1,M=!1,$,R){let J,L,O,K=0,q,te={leakWarningThreshold:$,onWillAddFirstListener(){J=D(ae=>{K++,L=C(L,ae),w&&!O&&(se.fire(L),L=void 0),q=()=>{let ce=L;L=void 0,O=void 0,(!w||K>1)&&se.fire(ce),K=0},typeof P=="number"?(clearTimeout(O),O=setTimeout(q,P)):O===void 0&&(O=0,queueMicrotask(q))})},onWillRemoveListener(){M&&K>0&&(q==null||q())},onDidRemoveLastListener(){q=void 0,J.dispose()}},se=new T(te);return R==null||R.add(se),se.event}e.debounce=f;function u(D,C=0,P){return e.debounce(D,(w,M)=>w?(w.push(M),w):[M],C,void 0,!0,void 0,P)}e.accumulate=u;function g(D,C=(w,M)=>w===M,P){let w=!0,M;return n(D,$=>{let R=w||!C($,M);return w=!1,M=$,R},P)}e.latch=g;function p(D,C,P){return[e.filter(D,C,P),e.filter(D,w=>!C(w),P)]}e.split=p;function m(D,C=!1,P=[],w){let M=P.slice(),$=D(L=>{M?M.push(L):J.fire(L)});w&&w.add($);let R=()=>{M==null||M.forEach(L=>J.fire(L)),M=null},J=new T({onWillAddFirstListener(){$||($=D(L=>J.fire(L)),w&&w.add($))},onDidAddFirstListener(){M&&(C?setTimeout(R):R())},onDidRemoveLastListener(){$&&$.dispose(),$=null}});return w&&w.add(J),J.event}e.buffer=m;function y(D,C){return(P,w,M)=>{let $=C(new b);return D(function(R){let J=$.evaluate(R);J!==x&&P.call(w,J)},void 0,M)}}e.chain=y;let x=Symbol("HaltChainable");class b{constructor(){this.steps=[]}map(C){return this.steps.push(C),this}forEach(C){return this.steps.push(P=>(C(P),P)),this}filter(C){return this.steps.push(P=>C(P)?P:x),this}reduce(C,P){let w=P;return this.steps.push(M=>(w=C(w,M),w)),this}latch(C=(P,w)=>P===w){let P=!0,w;return this.steps.push(M=>{let $=P||!C(M,w);return P=!1,w=M,$?M:x}),this}evaluate(C){for(let P of this.steps)if(C=P(C),C===x)break;return C}}function j(D,C,P=w=>w){let w=(...J)=>R.fire(P(...J)),M=()=>D.on(C,w),$=()=>D.removeListener(C,w),R=new T({onWillAddFirstListener:M,onDidRemoveLastListener:$});return R.event}e.fromNodeEventEmitter=j;function k(D,C,P=w=>w){let w=(...J)=>R.fire(P(...J)),M=()=>D.addEventListener(C,w),$=()=>D.removeEventListener(C,w),R=new T({onWillAddFirstListener:M,onDidRemoveLastListener:$});return R.event}e.fromDOMEventEmitter=k;function S(D){return new Promise(C=>s(D)(C))}e.toPromise=S;function E(D){let C=new T;return D.then(P=>{C.fire(P)},()=>{C.fire(void 0)}).finally(()=>{C.dispose()}),C.event}e.fromPromise=E;function B(D,C){return D(P=>C.fire(P))}e.forward=B;function U(D,C,P){return C(P),D(w=>C(w))}e.runAndSubscribe=U;class X{constructor(C,P){this._observable=C,this._counter=0,this._hasChanged=!1;let w={onWillAddFirstListener:()=>{C.addObserver(this)},onDidRemoveLastListener:()=>{C.removeObserver(this)}};this.emitter=new T(w),P&&P.add(this.emitter)}beginUpdate(C){this._counter++}handlePossibleChange(C){}handleChange(C,P){this._hasChanged=!0}endUpdate(C){this._counter--,this._counter===0&&(this._observable.reportChanges(),this._hasChanged&&(this._hasChanged=!1,this.emitter.fire(this._observable.get())))}}function V(D,C){return new X(D,C).emitter.event}e.fromObservable=V;function I(D){return(C,P,w)=>{let M=0,$=!1,R={beginUpdate(){M++},endUpdate(){M--,M===0&&(D.reportChanges(),$&&($=!1,C.call(P)))},handlePossibleChange(){},handleChange(){$=!0}};D.addObserver(R),D.reportChanges();let J={dispose(){D.removeObserver(R)}};return w instanceof Pt?w.add(J):Array.isArray(w)&&w.push(J),J}}e.fromObservableLight=I})(Ae||(Ae={}));var Lr=class Br{constructor(t){this.listenerCount=0,this.invocationCount=0,this.elapsedOverall=0,this.durations=[],this.name=`${t}_${Br._idPool++}`,Br.all.add(this)}start(t){this._stopWatch=new Pf,this.listenerCount=t}stop(){if(this._stopWatch){let t=this._stopWatch.elapsed();this.durations.push(t),this.elapsedOverall+=t,this.invocationCount+=1,this._stopWatch=void 0}}};Lr.all=new Set,Lr._idPool=0;var Rf=Lr,Lf=-1,$l=class Fl{constructor(t,s,i=(Fl._idPool++).toString(16).padStart(3,"0")){this._errorHandler=t,this.threshold=s,this.name=i,this._warnCountdown=0}dispose(){var t;(t=this._stacks)==null||t.clear()}check(t,s){let i=this.threshold;if(i<=0||s<i)return;this._stacks||(this._stacks=new Map);let r=this._stacks.get(t.value)||0;if(this._stacks.set(t.value,r+1),this._warnCountdown-=1,this._warnCountdown<=0){this._warnCountdown=i*.5;let[n,a]=this.getMostFrequentStack(),l=`[${this.name}] potential listener LEAK detected, having ${s} listeners already. MOST frequent listener (${a}):`;console.warn(l),console.warn(n);let h=new Tf(l,n);this._errorHandler(h)}return()=>{let n=this._stacks.get(t.value)||0;this._stacks.set(t.value,n-1)}}getMostFrequentStack(){if(!this._stacks)return;let t,s=0;for(let[i,r]of this._stacks)(!t||s<r)&&(t=[i,r],s=r);return t}};$l._idPool=1;var Bf=$l,zf=class Hl{constructor(t){this.value=t}static create(){let t=new Error;return new Hl(t.stack??"")}print(){console.warn(this.value.split(`
234
+ `).slice(2).join(`
235
+ `))}},Tf=class extends Error{constructor(e,t){super(e),this.name="ListenerLeakError",this.stack=t}},Af=class extends Error{constructor(e,t){super(e),this.name="ListenerRefusalError",this.stack=t}},Of=0,ir=class{constructor(e){this.value=e,this.id=Of++}},If=2,$f,T=class{constructor(t){var s,i,r,n;this._size=0,this._options=t,this._leakageMon=(s=this._options)!=null&&s.leakWarningThreshold?new Bf((t==null?void 0:t.onListenerError)??yi,((i=this._options)==null?void 0:i.leakWarningThreshold)??Lf):void 0,this._perfMon=(r=this._options)!=null&&r._profName?new Rf(this._options._profName):void 0,this._deliveryQueue=(n=this._options)==null?void 0:n.deliveryQueue}dispose(){var t,s,i,r;this._disposed||(this._disposed=!0,((t=this._deliveryQueue)==null?void 0:t.current)===this&&this._deliveryQueue.reset(),this._listeners&&(this._listeners=void 0,this._size=0),(i=(s=this._options)==null?void 0:s.onDidRemoveLastListener)==null||i.call(s),(r=this._leakageMon)==null||r.dispose())}get event(){return this._event??(this._event=(t,s,i)=>{var l,h,c,d,f;if(this._leakageMon&&this._size>this._leakageMon.threshold**2){let u=`[${this._leakageMon.name}] REFUSES to accept new listeners because it exceeded its threshold by far (${this._size} vs ${this._leakageMon.threshold})`;console.warn(u);let g=this._leakageMon.getMostFrequentStack()??["UNKNOWN stack",-1],p=new Af(`${u}. HINT: Stack shows most frequent listener (${g[1]}-times)`,g[0]);return(((l=this._options)==null?void 0:l.onListenerError)||yi)(p),re.None}if(this._disposed)return re.None;s&&(t=t.bind(s));let r=new ir(t),n;this._leakageMon&&this._size>=Math.ceil(this._leakageMon.threshold*.2)&&(r.stack=zf.create(),n=this._leakageMon.check(r.stack,this._size+1)),this._listeners?this._listeners instanceof ir?(this._deliveryQueue??(this._deliveryQueue=new Ff),this._listeners=[this._listeners,r]):this._listeners.push(r):((c=(h=this._options)==null?void 0:h.onWillAddFirstListener)==null||c.call(h,this),this._listeners=r,(f=(d=this._options)==null?void 0:d.onDidAddFirstListener)==null||f.call(d,this)),this._size++;let a=_e(()=>{n==null||n(),this._removeListener(r)});return i instanceof Pt?i.add(a):Array.isArray(i)&&i.push(a),a}),this._event}_removeListener(t){var n,a,l,h;if((a=(n=this._options)==null?void 0:n.onWillRemoveListener)==null||a.call(n,this),!this._listeners)return;if(this._size===1){this._listeners=void 0,(h=(l=this._options)==null?void 0:l.onDidRemoveLastListener)==null||h.call(l,this),this._size=0;return}let s=this._listeners,i=s.indexOf(t);if(i===-1)throw console.log("disposed?",this._disposed),console.log("size?",this._size),console.log("arr?",JSON.stringify(this._listeners)),new Error("Attempted to dispose unknown listener");this._size--,s[i]=void 0;let r=this._deliveryQueue.current===this;if(this._size*If<=s.length){let c=0;for(let d=0;d<s.length;d++)s[d]?s[c++]=s[d]:r&&(this._deliveryQueue.end--,c<this._deliveryQueue.i&&this._deliveryQueue.i--);s.length=c}}_deliver(t,s){var r;if(!t)return;let i=((r=this._options)==null?void 0:r.onListenerError)||yi;if(!i){t.value(s);return}try{t.value(s)}catch(n){i(n)}}_deliverQueue(t){let s=t.current._listeners;for(;t.i<t.end;)this._deliver(s[t.i++],t.value);t.reset()}fire(t){var s,i,r,n;if((s=this._deliveryQueue)!=null&&s.current&&(this._deliverQueue(this._deliveryQueue),(i=this._perfMon)==null||i.stop()),(r=this._perfMon)==null||r.start(this._size),this._listeners)if(this._listeners instanceof ir)this._deliver(this._listeners,t);else{let a=this._deliveryQueue;a.enqueue(this,t,this._listeners.length),this._deliverQueue(a)}(n=this._perfMon)==null||n.stop()}hasListeners(){return this._size>0}},Ff=class{constructor(){this.i=-1,this.end=0}enqueue(e,t,s){this.i=0,this.end=s,this.current=e,this.value=t}reset(){this.i=this.end,this.current=void 0,this.value=void 0}},zr=class{constructor(){this.mapWindowIdToZoomLevel=new Map,this._onDidChangeZoomLevel=new T,this.onDidChangeZoomLevel=this._onDidChangeZoomLevel.event,this.mapWindowIdToZoomFactor=new Map,this._onDidChangeFullscreen=new T,this.onDidChangeFullscreen=this._onDidChangeFullscreen.event,this.mapWindowIdToFullScreen=new Map}getZoomLevel(t){return this.mapWindowIdToZoomLevel.get(this.getWindowId(t))??0}setZoomLevel(t,s){if(this.getZoomLevel(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToZoomLevel.set(i,t),this._onDidChangeZoomLevel.fire(i)}getZoomFactor(t){return this.mapWindowIdToZoomFactor.get(this.getWindowId(t))??1}setZoomFactor(t,s){this.mapWindowIdToZoomFactor.set(this.getWindowId(s),t)}setFullscreen(t,s){if(this.isFullscreen(s)===t)return;let i=this.getWindowId(s);this.mapWindowIdToFullScreen.set(i,t),this._onDidChangeFullscreen.fire(i)}isFullscreen(t){return!!this.mapWindowIdToFullScreen.get(this.getWindowId(t))}getWindowId(t){return t.vscodeWindowId}};zr.INSTANCE=new zr;var kn=zr;function Hf(e,t,s){typeof t=="string"&&(t=e.matchMedia(t)),t.addEventListener("change",s)}kn.INSTANCE.onDidChangeZoomLevel;function Wf(e){return kn.INSTANCE.getZoomFactor(e)}kn.INSTANCE.onDidChangeFullscreen;var ms=typeof navigator=="object"?navigator.userAgent:"",Tr=ms.indexOf("Firefox")>=0,Uf=ms.indexOf("AppleWebKit")>=0,En=ms.indexOf("Chrome")>=0,Kf=!En&&ms.indexOf("Safari")>=0;ms.indexOf("Electron/")>=0;ms.indexOf("Android")>=0;var rr=!1;if(typeof mt.matchMedia=="function"){let e=mt.matchMedia("(display-mode: standalone) or (display-mode: window-controls-overlay)"),t=mt.matchMedia("(display-mode: fullscreen)");rr=e.matches,Hf(mt,e,({matches:s})=>{rr&&t.matches||(rr=s)})}var as="en",Ar=!1,Or=!1,Si=!1,Wl=!1,di,wi=as,Ho=as,qf,it,Ht=globalThis,ze,Aa;typeof Ht.vscode<"u"&&typeof Ht.vscode.process<"u"?ze=Ht.vscode.process:typeof process<"u"&&typeof((Aa=process==null?void 0:process.versions)==null?void 0:Aa.node)=="string"&&(ze=process);var Oa,Vf=typeof((Oa=ze==null?void 0:ze.versions)==null?void 0:Oa.electron)=="string",Yf=Vf&&(ze==null?void 0:ze.type)==="renderer",Ia;if(typeof ze=="object"){Ar=ze.platform==="win32",Or=ze.platform==="darwin",Si=ze.platform==="linux",Si&&ze.env.SNAP&&ze.env.SNAP_REVISION,ze.env.CI||ze.env.BUILD_ARTIFACTSTAGINGDIRECTORY,di=as,wi=as;let e=ze.env.VSCODE_NLS_CONFIG;if(e)try{let t=JSON.parse(e);di=t.userLocale,Ho=t.osLocale,wi=t.resolvedLanguage||as,qf=(Ia=t.languagePack)==null?void 0:Ia.translationsConfigFile}catch{}Wl=!0}else typeof navigator=="object"&&!Yf?(it=navigator.userAgent,Ar=it.indexOf("Windows")>=0,Or=it.indexOf("Macintosh")>=0,(it.indexOf("Macintosh")>=0||it.indexOf("iPad")>=0||it.indexOf("iPhone")>=0)&&navigator.maxTouchPoints&&navigator.maxTouchPoints>0,Si=it.indexOf("Linux")>=0,(it==null?void 0:it.indexOf("Mobi"))>=0,wi=globalThis._VSCODE_NLS_LANGUAGE||as,di=navigator.language.toLowerCase(),Ho=di):console.error("Unable to resolve platform.");var Ul=Ar,ht=Or,Gf=Si,Wo=Wl,dt=it,wt=wi,Xf;(e=>{function t(){return wt}e.value=t;function s(){return wt.length===2?wt==="en":wt.length>=3?wt[0]==="e"&&wt[1]==="n"&&wt[2]==="-":!1}e.isDefaultVariant=s;function i(){return wt==="en"}e.isDefault=i})(Xf||(Xf={}));var Jf=typeof Ht.postMessage=="function"&&!Ht.importScripts;(()=>{if(Jf){let e=[];Ht.addEventListener("message",s=>{if(s.data&&s.data.vscodeScheduleAsyncWork)for(let i=0,r=e.length;i<r;i++){let n=e[i];if(n.id===s.data.vscodeScheduleAsyncWork){e.splice(i,1),n.callback();return}}});let t=0;return s=>{let i=++t;e.push({id:i,callback:s}),Ht.postMessage({vscodeScheduleAsyncWork:i},"*")}}return e=>setTimeout(e)})();var Zf=!!(dt&&dt.indexOf("Chrome")>=0);dt&&dt.indexOf("Firefox")>=0;!Zf&&dt&&dt.indexOf("Safari")>=0;dt&&dt.indexOf("Edg/")>=0;dt&&dt.indexOf("Android")>=0;var ss=typeof navigator=="object"?navigator:{};Wo||document.queryCommandSupported&&document.queryCommandSupported("copy")||ss&&ss.clipboard&&ss.clipboard.writeText,Wo||ss&&ss.clipboard&&ss.clipboard.readText;var Nn=class{constructor(){this._keyCodeToStr=[],this._strToKeyCode=Object.create(null)}define(e,t){this._keyCodeToStr[e]=t,this._strToKeyCode[t.toLowerCase()]=e}keyCodeToStr(e){return this._keyCodeToStr[e]}strToKeyCode(e){return this._strToKeyCode[e.toLowerCase()]||0}},nr=new Nn,Uo=new Nn,Ko=new Nn,Qf=new Array(230),Kl;(e=>{function t(l){return nr.keyCodeToStr(l)}e.toString=t;function s(l){return nr.strToKeyCode(l)}e.fromString=s;function i(l){return Uo.keyCodeToStr(l)}e.toUserSettingsUS=i;function r(l){return Ko.keyCodeToStr(l)}e.toUserSettingsGeneral=r;function n(l){return Uo.strToKeyCode(l)||Ko.strToKeyCode(l)}e.fromUserSettings=n;function a(l){if(l>=98&&l<=113)return null;switch(l){case 16:return"Up";case 18:return"Down";case 15:return"Left";case 17:return"Right"}return nr.keyCodeToStr(l)}e.toElectronAccelerator=a})(Kl||(Kl={}));var ep=class ql{constructor(t,s,i,r,n){this.ctrlKey=t,this.shiftKey=s,this.altKey=i,this.metaKey=r,this.keyCode=n}equals(t){return t instanceof ql&&this.ctrlKey===t.ctrlKey&&this.shiftKey===t.shiftKey&&this.altKey===t.altKey&&this.metaKey===t.metaKey&&this.keyCode===t.keyCode}getHashCode(){let t=this.ctrlKey?"1":"0",s=this.shiftKey?"1":"0",i=this.altKey?"1":"0",r=this.metaKey?"1":"0";return`K${t}${s}${i}${r}${this.keyCode}`}isModifierKey(){return this.keyCode===0||this.keyCode===5||this.keyCode===57||this.keyCode===6||this.keyCode===4}toKeybinding(){return new tp([this])}isDuplicateModifierCase(){return this.ctrlKey&&this.keyCode===5||this.shiftKey&&this.keyCode===4||this.altKey&&this.keyCode===6||this.metaKey&&this.keyCode===57}},tp=class{constructor(e){if(e.length===0)throw Ef("chords");this.chords=e}getHashCode(){let e="";for(let t=0,s=this.chords.length;t<s;t++)t!==0&&(e+=";"),e+=this.chords[t].getHashCode();return e}equals(e){if(e===null||this.chords.length!==e.chords.length)return!1;for(let t=0;t<this.chords.length;t++)if(!this.chords[t].equals(e.chords[t]))return!1;return!0}};function sp(e){if(e.charCode){let s=String.fromCharCode(e.charCode).toUpperCase();return Kl.fromString(s)}let t=e.keyCode;if(t===3)return 7;if(Tr)switch(t){case 59:return 85;case 60:if(Gf)return 97;break;case 61:return 86;case 107:return 109;case 109:return 111;case 173:return 88;case 224:if(ht)return 57;break}else if(Uf&&(ht&&t===93||!ht&&t===92))return 57;return Qf[t]||0}var ip=ht?256:2048,rp=512,np=1024,op=ht?2048:256,qo=class{constructor(e){var s;this._standardKeyboardEventBrand=!0;let t=e;this.browserEvent=t,this.target=t.target,this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,this.altGraphKey=(s=t.getModifierState)==null?void 0:s.call(t,"AltGraph"),this.keyCode=sp(t),this.code=t.code,this.ctrlKey=this.ctrlKey||this.keyCode===5,this.altKey=this.altKey||this.keyCode===6,this.shiftKey=this.shiftKey||this.keyCode===4,this.metaKey=this.metaKey||this.keyCode===57,this._asKeybinding=this._computeKeybinding(),this._asKeyCodeChord=this._computeKeyCodeChord()}preventDefault(){this.browserEvent&&this.browserEvent.preventDefault&&this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent&&this.browserEvent.stopPropagation&&this.browserEvent.stopPropagation()}toKeyCodeChord(){return this._asKeyCodeChord}equals(e){return this._asKeybinding===e}_computeKeybinding(){let e=0;this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode);let t=0;return this.ctrlKey&&(t|=ip),this.altKey&&(t|=rp),this.shiftKey&&(t|=np),this.metaKey&&(t|=op),t|=e,t}_computeKeyCodeChord(){let e=0;return this.keyCode!==5&&this.keyCode!==4&&this.keyCode!==6&&this.keyCode!==57&&(e=this.keyCode),new ep(this.ctrlKey,this.shiftKey,this.altKey,this.metaKey,e)}},Vo=new WeakMap;function ap(e){if(!e.parent||e.parent===e)return null;try{let t=e.location,s=e.parent.location;if(t.origin!=="null"&&s.origin!=="null"&&t.origin!==s.origin)return null}catch{return null}return e.parent}var lp=class{static getSameOriginWindowChain(e){let t=Vo.get(e);if(!t){t=[],Vo.set(e,t);let s=e,i;do i=ap(s),i?t.push({window:new WeakRef(s),iframeElement:s.frameElement||null}):t.push({window:new WeakRef(s),iframeElement:null}),s=i;while(s)}return t.slice(0)}static getPositionOfChildWindowRelativeToAncestorWindow(e,t){if(!t||e===t)return{top:0,left:0};let s=0,i=0,r=this.getSameOriginWindowChain(e);for(let n of r){let a=n.window.deref();if(s+=(a==null?void 0:a.scrollY)??0,i+=(a==null?void 0:a.scrollX)??0,a===t||!n.iframeElement)break;let l=n.iframeElement.getBoundingClientRect();s+=l.top,i+=l.left}return{top:s,left:i}}},ui=class{constructor(e,t){this.timestamp=Date.now(),this.browserEvent=t,this.leftButton=t.button===0,this.middleButton=t.button===1,this.rightButton=t.button===2,this.buttons=t.buttons,this.target=t.target,this.detail=t.detail||1,t.type==="dblclick"&&(this.detail=2),this.ctrlKey=t.ctrlKey,this.shiftKey=t.shiftKey,this.altKey=t.altKey,this.metaKey=t.metaKey,typeof t.pageX=="number"?(this.posx=t.pageX,this.posy=t.pageY):(this.posx=t.clientX+this.target.ownerDocument.body.scrollLeft+this.target.ownerDocument.documentElement.scrollLeft,this.posy=t.clientY+this.target.ownerDocument.body.scrollTop+this.target.ownerDocument.documentElement.scrollTop);let s=lp.getPositionOfChildWindowRelativeToAncestorWindow(e,t.view);this.posx-=s.left,this.posy-=s.top}preventDefault(){this.browserEvent.preventDefault()}stopPropagation(){this.browserEvent.stopPropagation()}},Yo=class{constructor(e,t=0,s=0){var r;this.browserEvent=e||null,this.target=e?e.target||e.targetNode||e.srcElement:null,this.deltaY=s,this.deltaX=t;let i=!1;if(En){let n=navigator.userAgent.match(/Chrome\/(\d+)/);i=(n?parseInt(n[1]):123)<=122}if(e){let n=e,a=e,l=((r=e.view)==null?void 0:r.devicePixelRatio)||1;if(typeof n.wheelDeltaY<"u")i?this.deltaY=n.wheelDeltaY/(120*l):this.deltaY=n.wheelDeltaY/120;else if(typeof a.VERTICAL_AXIS<"u"&&a.axis===a.VERTICAL_AXIS)this.deltaY=-a.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Tr&&!ht?this.deltaY=-e.deltaY/3:this.deltaY=-e.deltaY:this.deltaY=-e.deltaY/40}if(typeof n.wheelDeltaX<"u")Kf&&Ul?this.deltaX=-(n.wheelDeltaX/120):i?this.deltaX=n.wheelDeltaX/(120*l):this.deltaX=n.wheelDeltaX/120;else if(typeof a.HORIZONTAL_AXIS<"u"&&a.axis===a.HORIZONTAL_AXIS)this.deltaX=-e.detail/3;else if(e.type==="wheel"){let h=e;h.deltaMode===h.DOM_DELTA_LINE?Tr&&!ht?this.deltaX=-e.deltaX/3:this.deltaX=-e.deltaX:this.deltaX=-e.deltaX/40}this.deltaY===0&&this.deltaX===0&&e.wheelDelta&&(i?this.deltaY=e.wheelDelta/(120*l):this.deltaY=e.wheelDelta/120)}}preventDefault(){var e;(e=this.browserEvent)==null||e.preventDefault()}stopPropagation(){var e;(e=this.browserEvent)==null||e.stopPropagation()}},Vl=Object.freeze(function(e,t){let s=setTimeout(e.bind(t),0);return{dispose(){clearTimeout(s)}}}),cp;(e=>{function t(s){return s===e.None||s===e.Cancelled||s instanceof hp?!0:!s||typeof s!="object"?!1:typeof s.isCancellationRequested=="boolean"&&typeof s.onCancellationRequested=="function"}e.isCancellationToken=t,e.None=Object.freeze({isCancellationRequested:!1,onCancellationRequested:Ae.None}),e.Cancelled=Object.freeze({isCancellationRequested:!0,onCancellationRequested:Vl})})(cp||(cp={}));var hp=class{constructor(){this._isCancelled=!1,this._emitter=null}cancel(){this._isCancelled||(this._isCancelled=!0,this._emitter&&(this._emitter.fire(void 0),this.dispose()))}get isCancellationRequested(){return this._isCancelled}get onCancellationRequested(){return this._isCancelled?Vl:(this._emitter||(this._emitter=new T),this._emitter.event)}dispose(){this._emitter&&(this._emitter.dispose(),this._emitter=null)}},jn=class{constructor(e,t){this._isDisposed=!1,this._token=-1,typeof e=="function"&&typeof t=="number"&&this.setIfNotSet(e,t)}dispose(){this.cancel(),this._isDisposed=!0}cancel(){this._token!==-1&&(clearTimeout(this._token),this._token=-1)}cancelAndSet(e,t){if(this._isDisposed)throw new Mr("Calling 'cancelAndSet' on a disposed TimeoutTimer");this.cancel(),this._token=setTimeout(()=>{this._token=-1,e()},t)}setIfNotSet(e,t){if(this._isDisposed)throw new Mr("Calling 'setIfNotSet' on a disposed TimeoutTimer");this._token===-1&&(this._token=setTimeout(()=>{this._token=-1,e()},t))}},dp=class{constructor(){this.disposable=void 0,this.isDisposed=!1}cancel(){var e;(e=this.disposable)==null||e.dispose(),this.disposable=void 0}cancelAndSet(e,t,s=globalThis){if(this.isDisposed)throw new Mr("Calling 'cancelAndSet' on a disposed IntervalTimer");this.cancel();let i=s.setInterval(()=>{e()},t);this.disposable=_e(()=>{s.clearInterval(i),this.disposable=void 0})}dispose(){this.cancel(),this.isDisposed=!0}},up;(e=>{async function t(i){let r,n=await Promise.all(i.map(a=>a.then(l=>l,l=>{r||(r=l)})));if(typeof r<"u")throw r;return n}e.settled=t;function s(i){return new Promise(async(r,n)=>{try{await i(r,n)}catch(a){n(a)}})}e.withAsyncBody=s})(up||(up={}));var Go=class et{static fromArray(t){return new et(s=>{s.emitMany(t)})}static fromPromise(t){return new et(async s=>{s.emitMany(await t)})}static fromPromises(t){return new et(async s=>{await Promise.all(t.map(async i=>s.emitOne(await i)))})}static merge(t){return new et(async s=>{await Promise.all(t.map(async i=>{for await(let r of i)s.emitOne(r)}))})}constructor(t,s){this._state=0,this._results=[],this._error=null,this._onReturn=s,this._onStateChanged=new T,queueMicrotask(async()=>{let i={emitOne:r=>this.emitOne(r),emitMany:r=>this.emitMany(r),reject:r=>this.reject(r)};try{await Promise.resolve(t(i)),this.resolve()}catch(r){this.reject(r)}finally{i.emitOne=void 0,i.emitMany=void 0,i.reject=void 0}})}[Symbol.asyncIterator](){let t=0;return{next:async()=>{do{if(this._state===2)throw this._error;if(t<this._results.length)return{done:!1,value:this._results[t++]};if(this._state===1)return{done:!0,value:void 0};await Ae.toPromise(this._onStateChanged.event)}while(!0)},return:async()=>{var s;return(s=this._onReturn)==null||s.call(this),{done:!0,value:void 0}}}}static map(t,s){return new et(async i=>{for await(let r of t)i.emitOne(s(r))})}map(t){return et.map(this,t)}static filter(t,s){return new et(async i=>{for await(let r of t)s(r)&&i.emitOne(r)})}filter(t){return et.filter(this,t)}static coalesce(t){return et.filter(t,s=>!!s)}coalesce(){return et.coalesce(this)}static async toPromise(t){let s=[];for await(let i of t)s.push(i);return s}toPromise(){return et.toPromise(this)}emitOne(t){this._state===0&&(this._results.push(t),this._onStateChanged.fire())}emitMany(t){this._state===0&&(this._results=this._results.concat(t),this._onStateChanged.fire())}resolve(){this._state===0&&(this._state=1,this._onStateChanged.fire())}reject(t){this._state===0&&(this._state=2,this._error=t,this._onStateChanged.fire())}};Go.EMPTY=Go.fromArray([]);var{getWindow:ct,getWindowId:fp,onDidRegisterWindow:pp}=(function(){let e=new Map,t={window:mt,disposables:new Pt};e.set(mt.vscodeWindowId,t);let s=new T,i=new T,r=new T;function n(a,l){return(typeof a=="number"?e.get(a):void 0)??(l?t:void 0)}return{onDidRegisterWindow:s.event,onWillUnregisterWindow:r.event,onDidUnregisterWindow:i.event,registerWindow(a){if(e.has(a.vscodeWindowId))return re.None;let l=new Pt,h={window:a,disposables:l.add(new Pt)};return e.set(a.vscodeWindowId,h),l.add(_e(()=>{e.delete(a.vscodeWindowId),i.fire(a)})),l.add(G(a,De.BEFORE_UNLOAD,()=>{r.fire(a)})),s.fire(h),l},getWindows(){return e.values()},getWindowsCount(){return e.size},getWindowId(a){return a.vscodeWindowId},hasWindow(a){return e.has(a)},getWindowById:n,getWindow(a){var c;let l=a;if((c=l==null?void 0:l.ownerDocument)!=null&&c.defaultView)return l.ownerDocument.defaultView.window;let h=a;return h!=null&&h.view?h.view.window:mt},getDocument(a){return ct(a).document}}})(),_p=class{constructor(e,t,s,i){this._node=e,this._type=t,this._handler=s,this._options=i||!1,this._node.addEventListener(this._type,this._handler,this._options)}dispose(){this._handler&&(this._node.removeEventListener(this._type,this._handler,this._options),this._node=null,this._handler=null)}};function G(e,t,s,i){return new _p(e,t,s,i)}var Xo=function(e,t,s,i){return G(e,t,s,i)},Dn,mp=class extends dp{constructor(e){super(),this.defaultTarget=e&&ct(e)}cancelAndSet(e,t,s){return super.cancelAndSet(e,t,s??this.defaultTarget)}},Jo=class{constructor(e,t=0){this._runner=e,this.priority=t,this._canceled=!1}dispose(){this._canceled=!0}execute(){if(!this._canceled)try{this._runner()}catch(e){yi(e)}}static sort(e,t){return t.priority-e.priority}};(function(){let e=new Map,t=new Map,s=new Map,i=new Map,r=n=>{s.set(n,!1);let a=e.get(n)??[];for(t.set(n,a),e.set(n,[]),i.set(n,!0);a.length>0;)a.sort(Jo.sort),a.shift().execute();i.set(n,!1)};Dn=(n,a,l=0)=>{let h=fp(n),c=new Jo(a,l),d=e.get(h);return d||(d=[],e.set(h,d)),d.push(c),s.get(h)||(s.set(h,!0),n.requestAnimationFrame(()=>r(h))),c}})();function gp(e){let t=e.getBoundingClientRect(),s=ct(e);return{left:t.left+s.scrollX,top:t.top+s.scrollY,width:t.width,height:t.height}}var De={CLICK:"click",MOUSE_DOWN:"mousedown",MOUSE_OVER:"mouseover",MOUSE_LEAVE:"mouseleave",MOUSE_WHEEL:"wheel",POINTER_UP:"pointerup",POINTER_DOWN:"pointerdown",POINTER_MOVE:"pointermove",KEY_DOWN:"keydown",KEY_UP:"keyup",BEFORE_UNLOAD:"beforeunload",CHANGE:"change",FOCUS:"focus",BLUR:"blur",INPUT:"input"},vp=class{constructor(e){this.domNode=e,this._maxWidth="",this._width="",this._height="",this._top="",this._left="",this._bottom="",this._right="",this._paddingTop="",this._paddingLeft="",this._paddingBottom="",this._paddingRight="",this._fontFamily="",this._fontWeight="",this._fontSize="",this._fontStyle="",this._fontFeatureSettings="",this._fontVariationSettings="",this._textDecoration="",this._lineHeight="",this._letterSpacing="",this._className="",this._display="",this._position="",this._visibility="",this._color="",this._backgroundColor="",this._layerHint=!1,this._contain="none",this._boxShadow=""}setMaxWidth(e){let t=Ke(e);this._maxWidth!==t&&(this._maxWidth=t,this.domNode.style.maxWidth=this._maxWidth)}setWidth(e){let t=Ke(e);this._width!==t&&(this._width=t,this.domNode.style.width=this._width)}setHeight(e){let t=Ke(e);this._height!==t&&(this._height=t,this.domNode.style.height=this._height)}setTop(e){let t=Ke(e);this._top!==t&&(this._top=t,this.domNode.style.top=this._top)}setLeft(e){let t=Ke(e);this._left!==t&&(this._left=t,this.domNode.style.left=this._left)}setBottom(e){let t=Ke(e);this._bottom!==t&&(this._bottom=t,this.domNode.style.bottom=this._bottom)}setRight(e){let t=Ke(e);this._right!==t&&(this._right=t,this.domNode.style.right=this._right)}setPaddingTop(e){let t=Ke(e);this._paddingTop!==t&&(this._paddingTop=t,this.domNode.style.paddingTop=this._paddingTop)}setPaddingLeft(e){let t=Ke(e);this._paddingLeft!==t&&(this._paddingLeft=t,this.domNode.style.paddingLeft=this._paddingLeft)}setPaddingBottom(e){let t=Ke(e);this._paddingBottom!==t&&(this._paddingBottom=t,this.domNode.style.paddingBottom=this._paddingBottom)}setPaddingRight(e){let t=Ke(e);this._paddingRight!==t&&(this._paddingRight=t,this.domNode.style.paddingRight=this._paddingRight)}setFontFamily(e){this._fontFamily!==e&&(this._fontFamily=e,this.domNode.style.fontFamily=this._fontFamily)}setFontWeight(e){this._fontWeight!==e&&(this._fontWeight=e,this.domNode.style.fontWeight=this._fontWeight)}setFontSize(e){let t=Ke(e);this._fontSize!==t&&(this._fontSize=t,this.domNode.style.fontSize=this._fontSize)}setFontStyle(e){this._fontStyle!==e&&(this._fontStyle=e,this.domNode.style.fontStyle=this._fontStyle)}setFontFeatureSettings(e){this._fontFeatureSettings!==e&&(this._fontFeatureSettings=e,this.domNode.style.fontFeatureSettings=this._fontFeatureSettings)}setFontVariationSettings(e){this._fontVariationSettings!==e&&(this._fontVariationSettings=e,this.domNode.style.fontVariationSettings=this._fontVariationSettings)}setTextDecoration(e){this._textDecoration!==e&&(this._textDecoration=e,this.domNode.style.textDecoration=this._textDecoration)}setLineHeight(e){let t=Ke(e);this._lineHeight!==t&&(this._lineHeight=t,this.domNode.style.lineHeight=this._lineHeight)}setLetterSpacing(e){let t=Ke(e);this._letterSpacing!==t&&(this._letterSpacing=t,this.domNode.style.letterSpacing=this._letterSpacing)}setClassName(e){this._className!==e&&(this._className=e,this.domNode.className=this._className)}toggleClassName(e,t){this.domNode.classList.toggle(e,t),this._className=this.domNode.className}setDisplay(e){this._display!==e&&(this._display=e,this.domNode.style.display=this._display)}setPosition(e){this._position!==e&&(this._position=e,this.domNode.style.position=this._position)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this.domNode.style.visibility=this._visibility)}setColor(e){this._color!==e&&(this._color=e,this.domNode.style.color=this._color)}setBackgroundColor(e){this._backgroundColor!==e&&(this._backgroundColor=e,this.domNode.style.backgroundColor=this._backgroundColor)}setLayerHinting(e){this._layerHint!==e&&(this._layerHint=e,this.domNode.style.transform=this._layerHint?"translate3d(0px, 0px, 0px)":"")}setBoxShadow(e){this._boxShadow!==e&&(this._boxShadow=e,this.domNode.style.boxShadow=e)}setContain(e){this._contain!==e&&(this._contain=e,this.domNode.style.contain=this._contain)}setAttribute(e,t){this.domNode.setAttribute(e,t)}removeAttribute(e){this.domNode.removeAttribute(e)}appendChild(e){this.domNode.appendChild(e.domNode)}removeChild(e){this.domNode.removeChild(e.domNode)}};function Ke(e){return typeof e=="number"?`${e}px`:e}function Fs(e){return new vp(e)}var Yl=class{constructor(){this._hooks=new Pt,this._pointerMoveCallback=null,this._onStopCallback=null}dispose(){this.stopMonitoring(!1),this._hooks.dispose()}stopMonitoring(e,t){if(!this.isMonitoring())return;this._hooks.clear(),this._pointerMoveCallback=null;let s=this._onStopCallback;this._onStopCallback=null,e&&s&&s(t)}isMonitoring(){return!!this._pointerMoveCallback}startMonitoring(e,t,s,i,r){this.isMonitoring()&&this.stopMonitoring(!1),this._pointerMoveCallback=i,this._onStopCallback=r;let n=e;try{e.setPointerCapture(t),this._hooks.add(_e(()=>{try{e.releasePointerCapture(t)}catch{}}))}catch{n=ct(e)}this._hooks.add(G(n,De.POINTER_MOVE,a=>{if(a.buttons!==s){this.stopMonitoring(!0);return}a.preventDefault(),this._pointerMoveCallback(a)})),this._hooks.add(G(n,De.POINTER_UP,a=>this.stopMonitoring(!0)))}};function xp(e,t,s){let i=null,r=null;if(typeof s.value=="function"?(i="value",r=s.value,r.length!==0&&console.warn("Memoize should only be used in functions with zero parameters")):typeof s.get=="function"&&(i="get",r=s.get),!r)throw new Error("not supported");let n=`$memoize$${t}`;s[i]=function(...a){return this.hasOwnProperty(n)||Object.defineProperty(this,n,{configurable:!1,enumerable:!1,writable:!1,value:r.apply(this,a)}),this[n]}}var ot;(e=>(e.Tap="-xterm-gesturetap",e.Change="-xterm-gesturechange",e.Start="-xterm-gesturestart",e.End="-xterm-gesturesend",e.Contextmenu="-xterm-gesturecontextmenu"))(ot||(ot={}));var Ls=class Oe extends re{constructor(){super(),this.dispatched=!1,this.targets=new Fo,this.ignoreTargets=new Fo,this.activeTouches={},this.handle=null,this._lastSetTapCountTime=0,this._register(Ae.runAndSubscribe(pp,({window:t,disposables:s})=>{s.add(G(t.document,"touchstart",i=>this.onTouchStart(i),{passive:!1})),s.add(G(t.document,"touchend",i=>this.onTouchEnd(t,i))),s.add(G(t.document,"touchmove",i=>this.onTouchMove(i),{passive:!1}))},{window:mt,disposables:this._store}))}static addTarget(t){if(!Oe.isTouchDevice())return re.None;Oe.INSTANCE||(Oe.INSTANCE=new Oe);let s=Oe.INSTANCE.targets.push(t);return _e(s)}static ignoreTarget(t){if(!Oe.isTouchDevice())return re.None;Oe.INSTANCE||(Oe.INSTANCE=new Oe);let s=Oe.INSTANCE.ignoreTargets.push(t);return _e(s)}static isTouchDevice(){return"ontouchstart"in mt||navigator.maxTouchPoints>0}dispose(){this.handle&&(this.handle.dispose(),this.handle=null),super.dispose()}onTouchStart(t){let s=Date.now();this.handle&&(this.handle.dispose(),this.handle=null);for(let i=0,r=t.targetTouches.length;i<r;i++){let n=t.targetTouches.item(i);this.activeTouches[n.identifier]={id:n.identifier,initialTarget:n.target,initialTimeStamp:s,initialPageX:n.pageX,initialPageY:n.pageY,rollingTimestamps:[s],rollingPageX:[n.pageX],rollingPageY:[n.pageY]};let a=this.newGestureEvent(ot.Start,n.target);a.pageX=n.pageX,a.pageY=n.pageY,this.dispatchEvent(a)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}onTouchEnd(t,s){let i=Date.now(),r=Object.keys(this.activeTouches).length;for(let n=0,a=s.changedTouches.length;n<a;n++){let l=s.changedTouches.item(n);if(!this.activeTouches.hasOwnProperty(String(l.identifier))){console.warn("move of an UNKNOWN touch",l);continue}let h=this.activeTouches[l.identifier],c=Date.now()-h.initialTimeStamp;if(c<Oe.HOLD_DELAY&&Math.abs(h.initialPageX-Ge(h.rollingPageX))<30&&Math.abs(h.initialPageY-Ge(h.rollingPageY))<30){let d=this.newGestureEvent(ot.Tap,h.initialTarget);d.pageX=Ge(h.rollingPageX),d.pageY=Ge(h.rollingPageY),this.dispatchEvent(d)}else if(c>=Oe.HOLD_DELAY&&Math.abs(h.initialPageX-Ge(h.rollingPageX))<30&&Math.abs(h.initialPageY-Ge(h.rollingPageY))<30){let d=this.newGestureEvent(ot.Contextmenu,h.initialTarget);d.pageX=Ge(h.rollingPageX),d.pageY=Ge(h.rollingPageY),this.dispatchEvent(d)}else if(r===1){let d=Ge(h.rollingPageX),f=Ge(h.rollingPageY),u=Ge(h.rollingTimestamps)-h.rollingTimestamps[0],g=d-h.rollingPageX[0],p=f-h.rollingPageY[0],m=[...this.targets].filter(y=>h.initialTarget instanceof Node&&y.contains(h.initialTarget));this.inertia(t,m,i,Math.abs(g)/u,g>0?1:-1,d,Math.abs(p)/u,p>0?1:-1,f)}this.dispatchEvent(this.newGestureEvent(ot.End,h.initialTarget)),delete this.activeTouches[l.identifier]}this.dispatched&&(s.preventDefault(),s.stopPropagation(),this.dispatched=!1)}newGestureEvent(t,s){let i=document.createEvent("CustomEvent");return i.initEvent(t,!1,!0),i.initialTarget=s,i.tapCount=0,i}dispatchEvent(t){if(t.type===ot.Tap){let s=new Date().getTime(),i=0;s-this._lastSetTapCountTime>Oe.CLEAR_TAP_COUNT_TIME?i=1:i=2,this._lastSetTapCountTime=s,t.tapCount=i}else(t.type===ot.Change||t.type===ot.Contextmenu)&&(this._lastSetTapCountTime=0);if(t.initialTarget instanceof Node){for(let i of this.ignoreTargets)if(i.contains(t.initialTarget))return;let s=[];for(let i of this.targets)if(i.contains(t.initialTarget)){let r=0,n=t.initialTarget;for(;n&&n!==i;)r++,n=n.parentElement;s.push([r,i])}s.sort((i,r)=>i[0]-r[0]);for(let[i,r]of s)r.dispatchEvent(t),this.dispatched=!0}}inertia(t,s,i,r,n,a,l,h,c){this.handle=Dn(t,()=>{let d=Date.now(),f=d-i,u=0,g=0,p=!0;r+=Oe.SCROLL_FRICTION*f,l+=Oe.SCROLL_FRICTION*f,r>0&&(p=!1,u=n*r*f),l>0&&(p=!1,g=h*l*f);let m=this.newGestureEvent(ot.Change);m.translationX=u,m.translationY=g,s.forEach(y=>y.dispatchEvent(m)),p||this.inertia(t,s,d,r,n,a+u,l,h,c+g)})}onTouchMove(t){let s=Date.now();for(let i=0,r=t.changedTouches.length;i<r;i++){let n=t.changedTouches.item(i);if(!this.activeTouches.hasOwnProperty(String(n.identifier))){console.warn("end of an UNKNOWN touch",n);continue}let a=this.activeTouches[n.identifier],l=this.newGestureEvent(ot.Change,a.initialTarget);l.translationX=n.pageX-Ge(a.rollingPageX),l.translationY=n.pageY-Ge(a.rollingPageY),l.pageX=n.pageX,l.pageY=n.pageY,this.dispatchEvent(l),a.rollingPageX.length>3&&(a.rollingPageX.shift(),a.rollingPageY.shift(),a.rollingTimestamps.shift()),a.rollingPageX.push(n.pageX),a.rollingPageY.push(n.pageY),a.rollingTimestamps.push(s)}this.dispatched&&(t.preventDefault(),t.stopPropagation(),this.dispatched=!1)}};Ls.SCROLL_FRICTION=-.005,Ls.HOLD_DELAY=700,Ls.CLEAR_TAP_COUNT_TIME=400,be([xp],Ls,"isTouchDevice",1);var bp=Ls,Mn=class extends re{onclick(e,t){this._register(G(e,De.CLICK,s=>t(new ui(ct(e),s))))}onmousedown(e,t){this._register(G(e,De.MOUSE_DOWN,s=>t(new ui(ct(e),s))))}onmouseover(e,t){this._register(G(e,De.MOUSE_OVER,s=>t(new ui(ct(e),s))))}onmouseleave(e,t){this._register(G(e,De.MOUSE_LEAVE,s=>t(new ui(ct(e),s))))}onkeydown(e,t){this._register(G(e,De.KEY_DOWN,s=>t(new qo(s))))}onkeyup(e,t){this._register(G(e,De.KEY_UP,s=>t(new qo(s))))}oninput(e,t){this._register(G(e,De.INPUT,t))}onblur(e,t){this._register(G(e,De.BLUR,t))}onfocus(e,t){this._register(G(e,De.FOCUS,t))}onchange(e,t){this._register(G(e,De.CHANGE,t))}ignoreGesture(e){return bp.ignoreTarget(e)}},Zo=11,yp=class extends Mn{constructor(e){super(),this._onActivate=e.onActivate,this.bgDomNode=document.createElement("div"),this.bgDomNode.className="arrow-background",this.bgDomNode.style.position="absolute",this.bgDomNode.style.width=e.bgWidth+"px",this.bgDomNode.style.height=e.bgHeight+"px",typeof e.top<"u"&&(this.bgDomNode.style.top="0px"),typeof e.left<"u"&&(this.bgDomNode.style.left="0px"),typeof e.bottom<"u"&&(this.bgDomNode.style.bottom="0px"),typeof e.right<"u"&&(this.bgDomNode.style.right="0px"),this.domNode=document.createElement("div"),this.domNode.className=e.className,this.domNode.style.position="absolute",this.domNode.style.width=Zo+"px",this.domNode.style.height=Zo+"px",typeof e.top<"u"&&(this.domNode.style.top=e.top+"px"),typeof e.left<"u"&&(this.domNode.style.left=e.left+"px"),typeof e.bottom<"u"&&(this.domNode.style.bottom=e.bottom+"px"),typeof e.right<"u"&&(this.domNode.style.right=e.right+"px"),this._pointerMoveMonitor=this._register(new Yl),this._register(Xo(this.bgDomNode,De.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._register(Xo(this.domNode,De.POINTER_DOWN,t=>this._arrowPointerDown(t))),this._pointerdownRepeatTimer=this._register(new mp),this._pointerdownScheduleRepeatTimer=this._register(new jn)}_arrowPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=()=>{this._pointerdownRepeatTimer.cancelAndSet(()=>this._onActivate(),1e3/24,ct(e))};this._onActivate(),this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancelAndSet(t,200),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,s=>{},()=>{this._pointerdownRepeatTimer.cancel(),this._pointerdownScheduleRepeatTimer.cancel()}),e.preventDefault()}},Sp=class Ir{constructor(t,s,i,r,n,a,l){this._forceIntegerValues=t,this._scrollStateBrand=void 0,this._forceIntegerValues&&(s=s|0,i=i|0,r=r|0,n=n|0,a=a|0,l=l|0),this.rawScrollLeft=r,this.rawScrollTop=l,s<0&&(s=0),r+s>i&&(r=i-s),r<0&&(r=0),n<0&&(n=0),l+n>a&&(l=a-n),l<0&&(l=0),this.width=s,this.scrollWidth=i,this.scrollLeft=r,this.height=n,this.scrollHeight=a,this.scrollTop=l}equals(t){return this.rawScrollLeft===t.rawScrollLeft&&this.rawScrollTop===t.rawScrollTop&&this.width===t.width&&this.scrollWidth===t.scrollWidth&&this.scrollLeft===t.scrollLeft&&this.height===t.height&&this.scrollHeight===t.scrollHeight&&this.scrollTop===t.scrollTop}withScrollDimensions(t,s){return new Ir(this._forceIntegerValues,typeof t.width<"u"?t.width:this.width,typeof t.scrollWidth<"u"?t.scrollWidth:this.scrollWidth,s?this.rawScrollLeft:this.scrollLeft,typeof t.height<"u"?t.height:this.height,typeof t.scrollHeight<"u"?t.scrollHeight:this.scrollHeight,s?this.rawScrollTop:this.scrollTop)}withScrollPosition(t){return new Ir(this._forceIntegerValues,this.width,this.scrollWidth,typeof t.scrollLeft<"u"?t.scrollLeft:this.rawScrollLeft,this.height,this.scrollHeight,typeof t.scrollTop<"u"?t.scrollTop:this.rawScrollTop)}createScrollEvent(t,s){let i=this.width!==t.width,r=this.scrollWidth!==t.scrollWidth,n=this.scrollLeft!==t.scrollLeft,a=this.height!==t.height,l=this.scrollHeight!==t.scrollHeight,h=this.scrollTop!==t.scrollTop;return{inSmoothScrolling:s,oldWidth:t.width,oldScrollWidth:t.scrollWidth,oldScrollLeft:t.scrollLeft,width:this.width,scrollWidth:this.scrollWidth,scrollLeft:this.scrollLeft,oldHeight:t.height,oldScrollHeight:t.scrollHeight,oldScrollTop:t.scrollTop,height:this.height,scrollHeight:this.scrollHeight,scrollTop:this.scrollTop,widthChanged:i,scrollWidthChanged:r,scrollLeftChanged:n,heightChanged:a,scrollHeightChanged:l,scrollTopChanged:h}}},wp=class extends re{constructor(e){super(),this._scrollableBrand=void 0,this._onScroll=this._register(new T),this.onScroll=this._onScroll.event,this._smoothScrollDuration=e.smoothScrollDuration,this._scheduleAtNextAnimationFrame=e.scheduleAtNextAnimationFrame,this._state=new Sp(e.forceIntegerValues,0,0,0,0,0,0),this._smoothScrolling=null}dispose(){this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),super.dispose()}setSmoothScrollDuration(e){this._smoothScrollDuration=e}validateScrollPosition(e){return this._state.withScrollPosition(e)}getScrollDimensions(){return this._state}setScrollDimensions(e,t){var i;let s=this._state.withScrollDimensions(e,t);this._setState(s,!!this._smoothScrolling),(i=this._smoothScrolling)==null||i.acceptScrollDimensions(this._state)}getFutureScrollPosition(){return this._smoothScrolling?this._smoothScrolling.to:this._state}getCurrentScrollPosition(){return this._state}setScrollPositionNow(e){let t=this._state.withScrollPosition(e);this._smoothScrolling&&(this._smoothScrolling.dispose(),this._smoothScrolling=null),this._setState(t,!1)}setScrollPositionSmooth(e,t){if(this._smoothScrollDuration===0)return this.setScrollPositionNow(e);if(this._smoothScrolling){e={scrollLeft:typeof e.scrollLeft>"u"?this._smoothScrolling.to.scrollLeft:e.scrollLeft,scrollTop:typeof e.scrollTop>"u"?this._smoothScrolling.to.scrollTop:e.scrollTop};let s=this._state.withScrollPosition(e);if(this._smoothScrolling.to.scrollLeft===s.scrollLeft&&this._smoothScrolling.to.scrollTop===s.scrollTop)return;let i;t?i=new ea(this._smoothScrolling.from,s,this._smoothScrolling.startTime,this._smoothScrolling.duration):i=this._smoothScrolling.combine(this._state,s,this._smoothScrollDuration),this._smoothScrolling.dispose(),this._smoothScrolling=i}else{let s=this._state.withScrollPosition(e);this._smoothScrolling=ea.start(this._state,s,this._smoothScrollDuration)}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}hasPendingScrollAnimation(){return!!this._smoothScrolling}_performSmoothScrolling(){if(!this._smoothScrolling)return;let e=this._smoothScrolling.tick(),t=this._state.withScrollPosition(e);if(this._setState(t,!0),!!this._smoothScrolling){if(e.isDone){this._smoothScrolling.dispose(),this._smoothScrolling=null;return}this._smoothScrolling.animationFrameDisposable=this._scheduleAtNextAnimationFrame(()=>{this._smoothScrolling&&(this._smoothScrolling.animationFrameDisposable=null,this._performSmoothScrolling())})}}_setState(e,t){let s=this._state;s.equals(e)||(this._state=e,this._onScroll.fire(this._state.createScrollEvent(s,t)))}},Qo=class{constructor(e,t,s){this.scrollLeft=e,this.scrollTop=t,this.isDone=s}};function or(e,t){let s=t-e;return function(i){return e+s*Ep(i)}}function Cp(e,t,s){return function(i){return i<s?e(i/s):t((i-s)/(1-s))}}var ea=class $r{constructor(t,s,i,r){this.from=t,this.to=s,this.duration=r,this.startTime=i,this.animationFrameDisposable=null,this._initAnimations()}_initAnimations(){this.scrollLeft=this._initAnimation(this.from.scrollLeft,this.to.scrollLeft,this.to.width),this.scrollTop=this._initAnimation(this.from.scrollTop,this.to.scrollTop,this.to.height)}_initAnimation(t,s,i){if(Math.abs(t-s)>2.5*i){let r,n;return t<s?(r=t+.75*i,n=s-.75*i):(r=t-.75*i,n=s+.75*i),Cp(or(t,r),or(n,s),.33)}return or(t,s)}dispose(){this.animationFrameDisposable!==null&&(this.animationFrameDisposable.dispose(),this.animationFrameDisposable=null)}acceptScrollDimensions(t){this.to=t.withScrollPosition(this.to),this._initAnimations()}tick(){return this._tick(Date.now())}_tick(t){let s=(t-this.startTime)/this.duration;if(s<1){let i=this.scrollLeft(s),r=this.scrollTop(s);return new Qo(i,r,!1)}return new Qo(this.to.scrollLeft,this.to.scrollTop,!0)}combine(t,s,i){return $r.start(t,s,i)}static start(t,s,i){i=i+10;let r=Date.now()-10;return new $r(t,s,r,i)}};function kp(e){return Math.pow(e,3)}function Ep(e){return 1-kp(1-e)}var Np=class extends re{constructor(e,t,s){super(),this._visibility=e,this._visibleClassName=t,this._invisibleClassName=s,this._domNode=null,this._isVisible=!1,this._isNeeded=!1,this._rawShouldBeVisible=!1,this._shouldBeVisible=!1,this._revealTimer=this._register(new jn)}setVisibility(e){this._visibility!==e&&(this._visibility=e,this._updateShouldBeVisible())}setShouldBeVisible(e){this._rawShouldBeVisible=e,this._updateShouldBeVisible()}_applyVisibilitySetting(){return this._visibility===2?!1:this._visibility===3?!0:this._rawShouldBeVisible}_updateShouldBeVisible(){let e=this._applyVisibilitySetting();this._shouldBeVisible!==e&&(this._shouldBeVisible=e,this.ensureVisibility())}setIsNeeded(e){this._isNeeded!==e&&(this._isNeeded=e,this.ensureVisibility())}setDomNode(e){this._domNode=e,this._domNode.setClassName(this._invisibleClassName),this.setShouldBeVisible(!1)}ensureVisibility(){if(!this._isNeeded){this._hide(!1);return}this._shouldBeVisible?this._reveal():this._hide(!0)}_reveal(){this._isVisible||(this._isVisible=!0,this._revealTimer.setIfNotSet(()=>{var e;(e=this._domNode)==null||e.setClassName(this._visibleClassName)},0))}_hide(e){var t;this._revealTimer.cancel(),this._isVisible&&(this._isVisible=!1,(t=this._domNode)==null||t.setClassName(this._invisibleClassName+(e?" fade":"")))}},jp=140,Gl=class extends Mn{constructor(e){super(),this._lazyRender=e.lazyRender,this._host=e.host,this._scrollable=e.scrollable,this._scrollByPage=e.scrollByPage,this._scrollbarState=e.scrollbarState,this._visibilityController=this._register(new Np(e.visibility,"visible scrollbar "+e.extraScrollbarClassName,"invisible scrollbar "+e.extraScrollbarClassName)),this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._pointerMoveMonitor=this._register(new Yl),this._shouldRender=!0,this.domNode=Fs(document.createElement("div")),this.domNode.setAttribute("role","presentation"),this.domNode.setAttribute("aria-hidden","true"),this._visibilityController.setDomNode(this.domNode),this.domNode.setPosition("absolute"),this._register(G(this.domNode.domNode,De.POINTER_DOWN,t=>this._domNodePointerDown(t)))}_createArrow(e){let t=this._register(new yp(e));this.domNode.domNode.appendChild(t.bgDomNode),this.domNode.domNode.appendChild(t.domNode)}_createSlider(e,t,s,i){this.slider=Fs(document.createElement("div")),this.slider.setClassName("slider"),this.slider.setPosition("absolute"),this.slider.setTop(e),this.slider.setLeft(t),typeof s=="number"&&this.slider.setWidth(s),typeof i=="number"&&this.slider.setHeight(i),this.slider.setLayerHinting(!0),this.slider.setContain("strict"),this.domNode.domNode.appendChild(this.slider.domNode),this._register(G(this.slider.domNode,De.POINTER_DOWN,r=>{r.button===0&&(r.preventDefault(),this._sliderPointerDown(r))})),this.onclick(this.slider.domNode,r=>{r.leftButton&&r.stopPropagation()})}_onElementSize(e){return this._scrollbarState.setVisibleSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollSize(e){return this._scrollbarState.setScrollSize(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}_onElementScrollPosition(e){return this._scrollbarState.setScrollPosition(e)&&(this._visibilityController.setIsNeeded(this._scrollbarState.isNeeded()),this._shouldRender=!0,this._lazyRender||this.render()),this._shouldRender}beginReveal(){this._visibilityController.setShouldBeVisible(!0)}beginHide(){this._visibilityController.setShouldBeVisible(!1)}render(){this._shouldRender&&(this._shouldRender=!1,this._renderDomNode(this._scrollbarState.getRectangleLargeSize(),this._scrollbarState.getRectangleSmallSize()),this._updateSlider(this._scrollbarState.getSliderSize(),this._scrollbarState.getArrowSize()+this._scrollbarState.getSliderPosition()))}_domNodePointerDown(e){e.target===this.domNode.domNode&&this._onPointerDown(e)}delegatePointerDown(e){let t=this.domNode.domNode.getClientRects()[0].top,s=t+this._scrollbarState.getSliderPosition(),i=t+this._scrollbarState.getSliderPosition()+this._scrollbarState.getSliderSize(),r=this._sliderPointerPosition(e);s<=r&&r<=i?e.button===0&&(e.preventDefault(),this._sliderPointerDown(e)):this._onPointerDown(e)}_onPointerDown(e){let t,s;if(e.target===this.domNode.domNode&&typeof e.offsetX=="number"&&typeof e.offsetY=="number")t=e.offsetX,s=e.offsetY;else{let r=gp(this.domNode.domNode);t=e.pageX-r.left,s=e.pageY-r.top}let i=this._pointerDownRelativePosition(t,s);this._setDesiredScrollPositionNow(this._scrollByPage?this._scrollbarState.getDesiredScrollPositionFromOffsetPaged(i):this._scrollbarState.getDesiredScrollPositionFromOffset(i)),e.button===0&&(e.preventDefault(),this._sliderPointerDown(e))}_sliderPointerDown(e){if(!e.target||!(e.target instanceof Element))return;let t=this._sliderPointerPosition(e),s=this._sliderOrthogonalPointerPosition(e),i=this._scrollbarState.clone();this.slider.toggleClassName("active",!0),this._pointerMoveMonitor.startMonitoring(e.target,e.pointerId,e.buttons,r=>{let n=this._sliderOrthogonalPointerPosition(r),a=Math.abs(n-s);if(Ul&&a>jp){this._setDesiredScrollPositionNow(i.getScrollPosition());return}let l=this._sliderPointerPosition(r)-t;this._setDesiredScrollPositionNow(i.getDesiredScrollPositionFromDelta(l))},()=>{this.slider.toggleClassName("active",!1),this._host.onDragEnd()}),this._host.onDragStart()}_setDesiredScrollPositionNow(e){let t={};this.writeScrollPosition(t,e),this._scrollable.setScrollPositionNow(t)}updateScrollbarSize(e){this._updateScrollbarSize(e),this._scrollbarState.setScrollbarSize(e),this._shouldRender=!0,this._lazyRender||this.render()}isNeeded(){return this._scrollbarState.isNeeded()}},Xl=class Fr{constructor(t,s,i,r,n,a){this._scrollbarSize=Math.round(s),this._oppositeScrollbarSize=Math.round(i),this._arrowSize=Math.round(t),this._visibleSize=r,this._scrollSize=n,this._scrollPosition=a,this._computedAvailableSize=0,this._computedIsNeeded=!1,this._computedSliderSize=0,this._computedSliderRatio=0,this._computedSliderPosition=0,this._refreshComputedValues()}clone(){return new Fr(this._arrowSize,this._scrollbarSize,this._oppositeScrollbarSize,this._visibleSize,this._scrollSize,this._scrollPosition)}setVisibleSize(t){let s=Math.round(t);return this._visibleSize!==s?(this._visibleSize=s,this._refreshComputedValues(),!0):!1}setScrollSize(t){let s=Math.round(t);return this._scrollSize!==s?(this._scrollSize=s,this._refreshComputedValues(),!0):!1}setScrollPosition(t){let s=Math.round(t);return this._scrollPosition!==s?(this._scrollPosition=s,this._refreshComputedValues(),!0):!1}setScrollbarSize(t){this._scrollbarSize=Math.round(t)}setOppositeScrollbarSize(t){this._oppositeScrollbarSize=Math.round(t)}static _computeValues(t,s,i,r,n){let a=Math.max(0,i-t),l=Math.max(0,a-2*s),h=r>0&&r>i;if(!h)return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(l),computedSliderRatio:0,computedSliderPosition:0};let c=Math.round(Math.max(20,Math.floor(i*l/r))),d=(l-c)/(r-i),f=n*d;return{computedAvailableSize:Math.round(a),computedIsNeeded:h,computedSliderSize:Math.round(c),computedSliderRatio:d,computedSliderPosition:Math.round(f)}}_refreshComputedValues(){let t=Fr._computeValues(this._oppositeScrollbarSize,this._arrowSize,this._visibleSize,this._scrollSize,this._scrollPosition);this._computedAvailableSize=t.computedAvailableSize,this._computedIsNeeded=t.computedIsNeeded,this._computedSliderSize=t.computedSliderSize,this._computedSliderRatio=t.computedSliderRatio,this._computedSliderPosition=t.computedSliderPosition}getArrowSize(){return this._arrowSize}getScrollPosition(){return this._scrollPosition}getRectangleLargeSize(){return this._computedAvailableSize}getRectangleSmallSize(){return this._scrollbarSize}isNeeded(){return this._computedIsNeeded}getSliderSize(){return this._computedSliderSize}getSliderPosition(){return this._computedSliderPosition}getDesiredScrollPositionFromOffset(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize-this._computedSliderSize/2;return Math.round(s/this._computedSliderRatio)}getDesiredScrollPositionFromOffsetPaged(t){if(!this._computedIsNeeded)return 0;let s=t-this._arrowSize,i=this._scrollPosition;return s<this._computedSliderPosition?i-=this._visibleSize:i+=this._visibleSize,i}getDesiredScrollPositionFromDelta(t){if(!this._computedIsNeeded)return 0;let s=this._computedSliderPosition+t;return Math.round(s/this._computedSliderRatio)}},Dp=class extends Gl{constructor(e,t,s){let i=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new Xl(t.horizontalHasArrows?t.arrowSize:0,t.horizontal===2?0:t.horizontalScrollbarSize,t.vertical===2?0:t.verticalScrollbarSize,i.width,i.scrollWidth,r.scrollLeft),visibility:t.horizontal,extraScrollbarClassName:"horizontal",scrollable:e,scrollByPage:t.scrollByPage}),t.horizontalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(Math.floor((t.horizontalScrollbarSize-t.horizontalSliderSize)/2),0,void 0,t.horizontalSliderSize)}_updateSlider(e,t){this.slider.setWidth(e),this.slider.setLeft(t)}_renderDomNode(e,t){this.domNode.setWidth(e),this.domNode.setHeight(t),this.domNode.setLeft(0),this.domNode.setBottom(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollWidth)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollLeft)||this._shouldRender,this._shouldRender=this._onElementSize(e.width)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return e}_sliderPointerPosition(e){return e.pageX}_sliderOrthogonalPointerPosition(e){return e.pageY}_updateScrollbarSize(e){this.slider.setHeight(e)}writeScrollPosition(e,t){e.scrollLeft=t}updateOptions(e){this.updateScrollbarSize(e.horizontal===2?0:e.horizontalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._visibilityController.setVisibility(e.horizontal),this._scrollByPage=e.scrollByPage}},Mp=class extends Gl{constructor(e,t,s){let i=e.getScrollDimensions(),r=e.getCurrentScrollPosition();if(super({lazyRender:t.lazyRender,host:s,scrollbarState:new Xl(t.verticalHasArrows?t.arrowSize:0,t.vertical===2?0:t.verticalScrollbarSize,0,i.height,i.scrollHeight,r.scrollTop),visibility:t.vertical,extraScrollbarClassName:"vertical",scrollable:e,scrollByPage:t.scrollByPage}),t.verticalHasArrows)throw new Error("horizontalHasArrows is not supported in xterm.js");this._createSlider(0,Math.floor((t.verticalScrollbarSize-t.verticalSliderSize)/2),t.verticalSliderSize,void 0)}_updateSlider(e,t){this.slider.setHeight(e),this.slider.setTop(t)}_renderDomNode(e,t){this.domNode.setWidth(t),this.domNode.setHeight(e),this.domNode.setRight(0),this.domNode.setTop(0)}onDidScroll(e){return this._shouldRender=this._onElementScrollSize(e.scrollHeight)||this._shouldRender,this._shouldRender=this._onElementScrollPosition(e.scrollTop)||this._shouldRender,this._shouldRender=this._onElementSize(e.height)||this._shouldRender,this._shouldRender}_pointerDownRelativePosition(e,t){return t}_sliderPointerPosition(e){return e.pageY}_sliderOrthogonalPointerPosition(e){return e.pageX}_updateScrollbarSize(e){this.slider.setWidth(e)}writeScrollPosition(e,t){e.scrollTop=t}updateOptions(e){this.updateScrollbarSize(e.vertical===2?0:e.verticalScrollbarSize),this._scrollbarState.setOppositeScrollbarSize(0),this._visibilityController.setVisibility(e.vertical),this._scrollByPage=e.scrollByPage}},Pp=500,ta=50,Rp=class{constructor(e,t,s){this.timestamp=e,this.deltaX=t,this.deltaY=s,this.score=0}},Hr=class{constructor(){this._capacity=5,this._memory=[],this._front=-1,this._rear=-1}isPhysicalMouseWheel(){if(this._front===-1&&this._rear===-1)return!1;let t=1,s=0,i=1,r=this._rear;do{let n=r===this._front?t:Math.pow(2,-i);if(t-=n,s+=this._memory[r].score*n,r===this._front)break;r=(this._capacity+r-1)%this._capacity,i++}while(!0);return s<=.5}acceptStandardWheelEvent(t){if(En){let s=ct(t.browserEvent),i=Wf(s);this.accept(Date.now(),t.deltaX*i,t.deltaY*i)}else this.accept(Date.now(),t.deltaX,t.deltaY)}accept(t,s,i){let r=null,n=new Rp(t,s,i);this._front===-1&&this._rear===-1?(this._memory[0]=n,this._front=0,this._rear=0):(r=this._memory[this._rear],this._rear=(this._rear+1)%this._capacity,this._rear===this._front&&(this._front=(this._front+1)%this._capacity),this._memory[this._rear]=n),n.score=this._computeScore(n,r)}_computeScore(t,s){if(Math.abs(t.deltaX)>0&&Math.abs(t.deltaY)>0)return 1;let i=.5;if((!this._isAlmostInt(t.deltaX)||!this._isAlmostInt(t.deltaY))&&(i+=.25),s){let r=Math.abs(t.deltaX),n=Math.abs(t.deltaY),a=Math.abs(s.deltaX),l=Math.abs(s.deltaY),h=Math.max(Math.min(r,a),1),c=Math.max(Math.min(n,l),1),d=Math.max(r,a),f=Math.max(n,l);d%h===0&&f%c===0&&(i-=.5)}return Math.min(Math.max(i,0),1)}_isAlmostInt(t){return Math.abs(Math.round(t)-t)<.01}};Hr.INSTANCE=new Hr;var Lp=Hr,Bp=class extends Mn{constructor(e,t,s){super(),this._onScroll=this._register(new T),this.onScroll=this._onScroll.event,this._onWillScroll=this._register(new T),this.onWillScroll=this._onWillScroll.event,this._options=Tp(t),this._scrollable=s,this._register(this._scrollable.onScroll(r=>{this._onWillScroll.fire(r),this._onDidScroll(r),this._onScroll.fire(r)}));let i={onMouseWheel:r=>this._onMouseWheel(r),onDragStart:()=>this._onDragStart(),onDragEnd:()=>this._onDragEnd()};this._verticalScrollbar=this._register(new Mp(this._scrollable,this._options,i)),this._horizontalScrollbar=this._register(new Dp(this._scrollable,this._options,i)),this._domNode=document.createElement("div"),this._domNode.className="xterm-scrollable-element "+this._options.className,this._domNode.setAttribute("role","presentation"),this._domNode.style.position="relative",this._domNode.appendChild(e),this._domNode.appendChild(this._horizontalScrollbar.domNode.domNode),this._domNode.appendChild(this._verticalScrollbar.domNode.domNode),this._options.useShadows?(this._leftShadowDomNode=Fs(document.createElement("div")),this._leftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._leftShadowDomNode.domNode),this._topShadowDomNode=Fs(document.createElement("div")),this._topShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topShadowDomNode.domNode),this._topLeftShadowDomNode=Fs(document.createElement("div")),this._topLeftShadowDomNode.setClassName("shadow"),this._domNode.appendChild(this._topLeftShadowDomNode.domNode)):(this._leftShadowDomNode=null,this._topShadowDomNode=null,this._topLeftShadowDomNode=null),this._listenOnDomNode=this._options.listenOnDomNode||this._domNode,this._mouseWheelToDispose=[],this._setListeningToMouseWheel(this._options.handleMouseWheel),this.onmouseover(this._listenOnDomNode,r=>this._onMouseOver(r)),this.onmouseleave(this._listenOnDomNode,r=>this._onMouseLeave(r)),this._hideTimeout=this._register(new jn),this._isDragging=!1,this._mouseIsOver=!1,this._shouldRender=!0,this._revealOnScroll=!0}get options(){return this._options}dispose(){this._mouseWheelToDispose=Vt(this._mouseWheelToDispose),super.dispose()}getDomNode(){return this._domNode}getOverviewRulerLayoutInfo(){return{parent:this._domNode,insertBefore:this._verticalScrollbar.domNode.domNode}}delegateVerticalScrollbarPointerDown(e){this._verticalScrollbar.delegatePointerDown(e)}getScrollDimensions(){return this._scrollable.getScrollDimensions()}setScrollDimensions(e){this._scrollable.setScrollDimensions(e,!1)}updateClassName(e){this._options.className=e,ht&&(this._options.className+=" mac"),this._domNode.className="xterm-scrollable-element "+this._options.className}updateOptions(e){typeof e.handleMouseWheel<"u"&&(this._options.handleMouseWheel=e.handleMouseWheel,this._setListeningToMouseWheel(this._options.handleMouseWheel)),typeof e.mouseWheelScrollSensitivity<"u"&&(this._options.mouseWheelScrollSensitivity=e.mouseWheelScrollSensitivity),typeof e.fastScrollSensitivity<"u"&&(this._options.fastScrollSensitivity=e.fastScrollSensitivity),typeof e.scrollPredominantAxis<"u"&&(this._options.scrollPredominantAxis=e.scrollPredominantAxis),typeof e.horizontal<"u"&&(this._options.horizontal=e.horizontal),typeof e.vertical<"u"&&(this._options.vertical=e.vertical),typeof e.horizontalScrollbarSize<"u"&&(this._options.horizontalScrollbarSize=e.horizontalScrollbarSize),typeof e.verticalScrollbarSize<"u"&&(this._options.verticalScrollbarSize=e.verticalScrollbarSize),typeof e.scrollByPage<"u"&&(this._options.scrollByPage=e.scrollByPage),this._horizontalScrollbar.updateOptions(this._options),this._verticalScrollbar.updateOptions(this._options),this._options.lazyRender||this._render()}setRevealOnScroll(e){this._revealOnScroll=e}delegateScrollFromMouseWheelEvent(e){this._onMouseWheel(new Yo(e))}_setListeningToMouseWheel(e){if(this._mouseWheelToDispose.length>0!==e&&(this._mouseWheelToDispose=Vt(this._mouseWheelToDispose),e)){let t=s=>{this._onMouseWheel(new Yo(s))};this._mouseWheelToDispose.push(G(this._listenOnDomNode,De.MOUSE_WHEEL,t,{passive:!1}))}}_onMouseWheel(e){var r;if((r=e.browserEvent)!=null&&r.defaultPrevented)return;let t=Lp.INSTANCE;t.acceptStandardWheelEvent(e);let s=!1;if(e.deltaY||e.deltaX){let n=e.deltaY*this._options.mouseWheelScrollSensitivity,a=e.deltaX*this._options.mouseWheelScrollSensitivity;this._options.scrollPredominantAxis&&(this._options.scrollYToX&&a+n===0?a=n=0:Math.abs(n)>=Math.abs(a)?a=0:n=0),this._options.flipAxes&&([n,a]=[a,n]);let l=!ht&&e.browserEvent&&e.browserEvent.shiftKey;(this._options.scrollYToX||l)&&!a&&(a=n,n=0),e.browserEvent&&e.browserEvent.altKey&&(a=a*this._options.fastScrollSensitivity,n=n*this._options.fastScrollSensitivity);let h=this._scrollable.getFutureScrollPosition(),c={};if(n){let d=ta*n,f=h.scrollTop-(d<0?Math.floor(d):Math.ceil(d));this._verticalScrollbar.writeScrollPosition(c,f)}if(a){let d=ta*a,f=h.scrollLeft-(d<0?Math.floor(d):Math.ceil(d));this._horizontalScrollbar.writeScrollPosition(c,f)}c=this._scrollable.validateScrollPosition(c),(h.scrollLeft!==c.scrollLeft||h.scrollTop!==c.scrollTop)&&(this._options.mouseWheelSmoothScroll&&t.isPhysicalMouseWheel()?this._scrollable.setScrollPositionSmooth(c):this._scrollable.setScrollPositionNow(c),s=!0)}let i=s;!i&&this._options.alwaysConsumeMouseWheel&&(i=!0),!i&&this._options.consumeMouseWheelIfScrollbarIsNeeded&&(this._verticalScrollbar.isNeeded()||this._horizontalScrollbar.isNeeded())&&(i=!0),i&&(e.preventDefault(),e.stopPropagation())}_onDidScroll(e){this._shouldRender=this._horizontalScrollbar.onDidScroll(e)||this._shouldRender,this._shouldRender=this._verticalScrollbar.onDidScroll(e)||this._shouldRender,this._options.useShadows&&(this._shouldRender=!0),this._revealOnScroll&&this._reveal(),this._options.lazyRender||this._render()}renderNow(){if(!this._options.lazyRender)throw new Error("Please use `lazyRender` together with `renderNow`!");this._render()}_render(){if(this._shouldRender&&(this._shouldRender=!1,this._horizontalScrollbar.render(),this._verticalScrollbar.render(),this._options.useShadows)){let e=this._scrollable.getCurrentScrollPosition(),t=e.scrollTop>0,s=e.scrollLeft>0,i=s?" left":"",r=t?" top":"",n=s||t?" top-left-corner":"";this._leftShadowDomNode.setClassName(`shadow${i}`),this._topShadowDomNode.setClassName(`shadow${r}`),this._topLeftShadowDomNode.setClassName(`shadow${n}${r}${i}`)}}_onDragStart(){this._isDragging=!0,this._reveal()}_onDragEnd(){this._isDragging=!1,this._hide()}_onMouseLeave(e){this._mouseIsOver=!1,this._hide()}_onMouseOver(e){this._mouseIsOver=!0,this._reveal()}_reveal(){this._verticalScrollbar.beginReveal(),this._horizontalScrollbar.beginReveal(),this._scheduleHide()}_hide(){!this._mouseIsOver&&!this._isDragging&&(this._verticalScrollbar.beginHide(),this._horizontalScrollbar.beginHide())}_scheduleHide(){!this._mouseIsOver&&!this._isDragging&&this._hideTimeout.cancelAndSet(()=>this._hide(),Pp)}},zp=class extends Bp{constructor(e,t,s){super(e,t,s)}setScrollPosition(e){e.reuseAnimation?this._scrollable.setScrollPositionSmooth(e,e.reuseAnimation):this._scrollable.setScrollPositionNow(e)}getScrollPosition(){return this._scrollable.getCurrentScrollPosition()}};function Tp(e){let t={lazyRender:typeof e.lazyRender<"u"?e.lazyRender:!1,className:typeof e.className<"u"?e.className:"",useShadows:typeof e.useShadows<"u"?e.useShadows:!0,handleMouseWheel:typeof e.handleMouseWheel<"u"?e.handleMouseWheel:!0,flipAxes:typeof e.flipAxes<"u"?e.flipAxes:!1,consumeMouseWheelIfScrollbarIsNeeded:typeof e.consumeMouseWheelIfScrollbarIsNeeded<"u"?e.consumeMouseWheelIfScrollbarIsNeeded:!1,alwaysConsumeMouseWheel:typeof e.alwaysConsumeMouseWheel<"u"?e.alwaysConsumeMouseWheel:!1,scrollYToX:typeof e.scrollYToX<"u"?e.scrollYToX:!1,mouseWheelScrollSensitivity:typeof e.mouseWheelScrollSensitivity<"u"?e.mouseWheelScrollSensitivity:1,fastScrollSensitivity:typeof e.fastScrollSensitivity<"u"?e.fastScrollSensitivity:5,scrollPredominantAxis:typeof e.scrollPredominantAxis<"u"?e.scrollPredominantAxis:!0,mouseWheelSmoothScroll:typeof e.mouseWheelSmoothScroll<"u"?e.mouseWheelSmoothScroll:!0,arrowSize:typeof e.arrowSize<"u"?e.arrowSize:11,listenOnDomNode:typeof e.listenOnDomNode<"u"?e.listenOnDomNode:null,horizontal:typeof e.horizontal<"u"?e.horizontal:1,horizontalScrollbarSize:typeof e.horizontalScrollbarSize<"u"?e.horizontalScrollbarSize:10,horizontalSliderSize:typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:0,horizontalHasArrows:typeof e.horizontalHasArrows<"u"?e.horizontalHasArrows:!1,vertical:typeof e.vertical<"u"?e.vertical:1,verticalScrollbarSize:typeof e.verticalScrollbarSize<"u"?e.verticalScrollbarSize:10,verticalHasArrows:typeof e.verticalHasArrows<"u"?e.verticalHasArrows:!1,verticalSliderSize:typeof e.verticalSliderSize<"u"?e.verticalSliderSize:0,scrollByPage:typeof e.scrollByPage<"u"?e.scrollByPage:!1};return t.horizontalSliderSize=typeof e.horizontalSliderSize<"u"?e.horizontalSliderSize:t.horizontalScrollbarSize,t.verticalSliderSize=typeof e.verticalSliderSize<"u"?e.verticalSliderSize:t.verticalScrollbarSize,ht&&(t.className+=" mac"),t}var Wr=class extends re{constructor(e,t,s,i,r,n,a,l){super(),this._bufferService=s,this._optionsService=a,this._renderService=l,this._onRequestScrollLines=this._register(new T),this.onRequestScrollLines=this._onRequestScrollLines.event,this._isSyncing=!1,this._isHandlingScroll=!1,this._suppressOnScrollHandler=!1;let h=this._register(new wp({forceIntegerValues:!1,smoothScrollDuration:this._optionsService.rawOptions.smoothScrollDuration,scheduleAtNextAnimationFrame:c=>Dn(i.window,c)}));this._register(this._optionsService.onSpecificOptionChange("smoothScrollDuration",()=>{h.setSmoothScrollDuration(this._optionsService.rawOptions.smoothScrollDuration)})),this._scrollableElement=this._register(new zp(t,{vertical:1,horizontal:2,useShadows:!1,mouseWheelSmoothScroll:!0,...this._getChangeOptions()},h)),this._register(this._optionsService.onMultipleOptionChange(["scrollSensitivity","fastScrollSensitivity","overviewRuler"],()=>this._scrollableElement.updateOptions(this._getChangeOptions()))),this._register(r.onProtocolChange(c=>{this._scrollableElement.updateOptions({handleMouseWheel:!(c&16)})})),this._scrollableElement.setScrollDimensions({height:0,scrollHeight:0}),this._register(Ae.runAndSubscribe(n.onChangeColors,()=>{this._scrollableElement.getDomNode().style.backgroundColor=n.colors.background.css})),e.appendChild(this._scrollableElement.getDomNode()),this._register(_e(()=>this._scrollableElement.getDomNode().remove())),this._styleElement=i.mainDocument.createElement("style"),t.appendChild(this._styleElement),this._register(_e(()=>this._styleElement.remove())),this._register(Ae.runAndSubscribe(n.onChangeColors,()=>{this._styleElement.textContent=[".xterm .xterm-scrollable-element > .scrollbar > .slider {",` background: ${n.colors.scrollbarSliderBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider:hover {",` background: ${n.colors.scrollbarSliderHoverBackground.css};`,"}",".xterm .xterm-scrollable-element > .scrollbar > .slider.active {",` background: ${n.colors.scrollbarSliderActiveBackground.css};`,"}"].join(`
236
+ `)})),this._register(this._bufferService.onResize(()=>this.queueSync())),this._register(this._bufferService.buffers.onBufferActivate(()=>{this._latestYDisp=void 0,this.queueSync()})),this._register(this._bufferService.onScroll(()=>this._sync())),this._register(this._scrollableElement.onScroll(c=>this._handleScroll(c)))}scrollLines(e){let t=this._scrollableElement.getScrollPosition();this._scrollableElement.setScrollPosition({reuseAnimation:!0,scrollTop:t.scrollTop+e*this._renderService.dimensions.css.cell.height})}scrollToLine(e,t){t&&(this._latestYDisp=e),this._scrollableElement.setScrollPosition({reuseAnimation:!t,scrollTop:e*this._renderService.dimensions.css.cell.height})}_getChangeOptions(){var e;return{mouseWheelScrollSensitivity:this._optionsService.rawOptions.scrollSensitivity,fastScrollSensitivity:this._optionsService.rawOptions.fastScrollSensitivity,verticalScrollbarSize:((e=this._optionsService.rawOptions.overviewRuler)==null?void 0:e.width)||14}}queueSync(e){e!==void 0&&(this._latestYDisp=e),this._queuedAnimationFrame===void 0&&(this._queuedAnimationFrame=this._renderService.addRefreshCallback(()=>{this._queuedAnimationFrame=void 0,this._sync(this._latestYDisp)}))}_sync(e=this._bufferService.buffer.ydisp){!this._renderService||this._isSyncing||(this._isSyncing=!0,this._suppressOnScrollHandler=!0,this._scrollableElement.setScrollDimensions({height:this._renderService.dimensions.css.canvas.height,scrollHeight:this._renderService.dimensions.css.cell.height*this._bufferService.buffer.lines.length}),this._suppressOnScrollHandler=!1,e!==this._latestYDisp&&this._scrollableElement.setScrollPosition({scrollTop:e*this._renderService.dimensions.css.cell.height}),this._isSyncing=!1)}_handleScroll(e){if(!this._renderService||this._isHandlingScroll||this._suppressOnScrollHandler)return;this._isHandlingScroll=!0;let t=Math.round(e.scrollTop/this._renderService.dimensions.css.cell.height),s=t-this._bufferService.buffer.ydisp;s!==0&&(this._latestYDisp=t,this._onRequestScrollLines.fire(s)),this._isHandlingScroll=!1}};Wr=be([H(2,Fe),H(3,bt),H(4,Ml),H(5,_s),H(6,He),H(7,yt)],Wr);var Ur=class extends re{constructor(e,t,s,i,r){super(),this._screenElement=e,this._bufferService=t,this._coreBrowserService=s,this._decorationService=i,this._renderService=r,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(this._coreBrowserService.onDprChange(()=>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(n=>this._removeDecoration(n))),this._register(_e(()=>{this._container.remove(),this._decorationElements.clear()}))}_queueRefresh(){this._animationFrame===void 0&&(this._animationFrame=this._renderService.addRefreshCallback(()=>{this._doRefreshDecorations(),this._animationFrame=void 0}))}_doRefreshDecorations(){for(let e of this._decorationService.decorations)this._renderDecoration(e);this._dimensionsChanged=!1}_renderDecoration(e){this._refreshStyle(e),this._dimensionsChanged&&this._refreshXPosition(e)}_createElement(e){var i;let t=this._coreBrowserService.mainDocument.createElement("div");t.classList.add("xterm-decoration"),t.classList.toggle("xterm-decoration-top-layer",((i=e==null?void 0:e.options)==null?void 0:i.layer)==="top"),t.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,t.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,t.style.top=`${(e.marker.line-this._bufferService.buffers.active.ydisp)*this._renderService.dimensions.css.cell.height}px`,t.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`;let s=e.options.x??0;return s&&s>this._bufferService.cols&&(t.style.display="none"),this._refreshXPosition(e,t),t}_refreshStyle(e){let t=e.marker.line-this._bufferService.buffers.active.ydisp;if(t<0||t>=this._bufferService.rows)e.element&&(e.element.style.display="none",e.onRenderEmitter.fire(e.element));else{let s=this._decorationElements.get(e);s||(s=this._createElement(e),e.element=s,this._decorationElements.set(e,s),this._container.appendChild(s),e.onDispose(()=>{this._decorationElements.delete(e),s.remove()})),s.style.display=this._altBufferIsActive?"none":"block",this._altBufferIsActive||(s.style.width=`${Math.round((e.options.width||1)*this._renderService.dimensions.css.cell.width)}px`,s.style.height=`${(e.options.height||1)*this._renderService.dimensions.css.cell.height}px`,s.style.top=`${t*this._renderService.dimensions.css.cell.height}px`,s.style.lineHeight=`${this._renderService.dimensions.css.cell.height}px`),e.onRenderEmitter.fire(s)}}_refreshXPosition(e,t=e.element){if(!t)return;let s=e.options.x??0;(e.options.anchor||"left")==="right"?t.style.right=s?`${s*this._renderService.dimensions.css.cell.width}px`:"":t.style.left=s?`${s*this._renderService.dimensions.css.cell.width}px`:""}_removeDecoration(e){var t;(t=this._decorationElements.get(e))==null||t.remove(),this._decorationElements.delete(e),e.dispose()}};Ur=be([H(1,Fe),H(2,bt),H(3,Gs),H(4,yt)],Ur);var Ap=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(e){if(e.options.overviewRulerOptions){for(let t of this._zones)if(t.color===e.options.overviewRulerOptions.color&&t.position===e.options.overviewRulerOptions.position){if(this._lineIntersectsZone(t,e.marker.line))return;if(this._lineAdjacentToZone(t,e.marker.line,e.options.overviewRulerOptions.position)){this._addLineToZone(t,e.marker.line);return}}if(this._zonePoolIndex<this._zonePool.length){this._zonePool[this._zonePoolIndex].color=e.options.overviewRulerOptions.color,this._zonePool[this._zonePoolIndex].position=e.options.overviewRulerOptions.position,this._zonePool[this._zonePoolIndex].startBufferLine=e.marker.line,this._zonePool[this._zonePoolIndex].endBufferLine=e.marker.line,this._zones.push(this._zonePool[this._zonePoolIndex++]);return}this._zones.push({color:e.options.overviewRulerOptions.color,position:e.options.overviewRulerOptions.position,startBufferLine:e.marker.line,endBufferLine:e.marker.line}),this._zonePool.push(this._zones[this._zones.length-1]),this._zonePoolIndex++}}setPadding(e){this._linePadding=e}_lineIntersectsZone(e,t){return t>=e.startBufferLine&&t<=e.endBufferLine}_lineAdjacentToZone(e,t,s){return t>=e.startBufferLine-this._linePadding[s||"full"]&&t<=e.endBufferLine+this._linePadding[s||"full"]}_addLineToZone(e,t){e.startBufferLine=Math.min(e.startBufferLine,t),e.endBufferLine=Math.max(e.endBufferLine,t)}},rt={full:0,left:0,center:0,right:0},Ct={full:0,left:0,center:0,right:0},ws={full:0,left:0,center:0,right:0},Ri=class extends re{constructor(e,t,s,i,r,n,a,l){var c;super(),this._viewportElement=e,this._screenElement=t,this._bufferService=s,this._decorationService=i,this._renderService=r,this._optionsService=n,this._themeService=a,this._coreBrowserService=l,this._colorZoneStore=new Ap,this._shouldUpdateDimensions=!0,this._shouldUpdateAnchor=!0,this._lastKnownBufferLength=0,this._canvas=this._coreBrowserService.mainDocument.createElement("canvas"),this._canvas.classList.add("xterm-decoration-overview-ruler"),this._refreshCanvasDimensions(),(c=this._viewportElement.parentElement)==null||c.insertBefore(this._canvas,this._viewportElement),this._register(_e(()=>{var d;return(d=this._canvas)==null?void 0:d.remove()}));let h=this._canvas.getContext("2d");if(h)this._ctx=h;else throw new Error("Ctx cannot be null");this._register(this._decorationService.onDecorationRegistered(()=>this._queueRefresh(void 0,!0))),this._register(this._decorationService.onDecorationRemoved(()=>this._queueRefresh(void 0,!0))),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())})),this._register(this._renderService.onRender(()=>{(!this._containerHeight||this._containerHeight!==this._screenElement.clientHeight)&&(this._queueRefresh(!0),this._containerHeight=this._screenElement.clientHeight)})),this._register(this._coreBrowserService.onDprChange(()=>this._queueRefresh(!0))),this._register(this._optionsService.onSpecificOptionChange("overviewRuler",()=>this._queueRefresh(!0))),this._register(this._themeService.onChangeColors(()=>this._queueRefresh())),this._queueRefresh(!0)}get _width(){var e;return((e=this._optionsService.options.overviewRuler)==null?void 0:e.width)||0}_refreshDrawConstants(){let e=Math.floor((this._canvas.width-1)/3),t=Math.ceil((this._canvas.width-1)/3);Ct.full=this._canvas.width,Ct.left=e,Ct.center=t,Ct.right=e,this._refreshDrawHeightConstants(),ws.full=1,ws.left=1,ws.center=1+Ct.left,ws.right=1+Ct.left+Ct.center}_refreshDrawHeightConstants(){rt.full=Math.round(2*this._coreBrowserService.dpr);let e=this._canvas.height/this._bufferService.buffer.lines.length,t=Math.round(Math.max(Math.min(e,12),6)*this._coreBrowserService.dpr);rt.left=t,rt.center=t,rt.right=t}_refreshColorZonePadding(){this._colorZoneStore.setPadding({full:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rt.full),left:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rt.left),center:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rt.center),right:Math.floor(this._bufferService.buffers.active.lines.length/(this._canvas.height-1)*rt.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._coreBrowserService.dpr),this._canvas.style.height=`${this._screenElement.clientHeight}px`,this._canvas.height=Math.round(this._screenElement.clientHeight*this._coreBrowserService.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(let t of this._decorationService.decorations)this._colorZoneStore.addDecoration(t);this._ctx.lineWidth=1,this._renderRulerOutline();let e=this._colorZoneStore.zones;for(let t of e)t.position!=="full"&&this._renderColorZone(t);for(let t of e)t.position==="full"&&this._renderColorZone(t);this._shouldUpdateDimensions=!1,this._shouldUpdateAnchor=!1}_renderRulerOutline(){this._ctx.fillStyle=this._themeService.colors.overviewRulerBorder.css,this._ctx.fillRect(0,0,1,this._canvas.height),this._optionsService.rawOptions.overviewRuler.showTopBorder&&this._ctx.fillRect(1,0,this._canvas.width-1,1),this._optionsService.rawOptions.overviewRuler.showBottomBorder&&this._ctx.fillRect(1,this._canvas.height-1,this._canvas.width-1,this._canvas.height)}_renderColorZone(e){this._ctx.fillStyle=e.color,this._ctx.fillRect(ws[e.position||"full"],Math.round((this._canvas.height-1)*(e.startBufferLine/this._bufferService.buffers.active.lines.length)-rt[e.position||"full"]/2),Ct[e.position||"full"],Math.round((this._canvas.height-1)*((e.endBufferLine-e.startBufferLine)/this._bufferService.buffers.active.lines.length)+rt[e.position||"full"]))}_queueRefresh(e,t){this._shouldUpdateDimensions=e||this._shouldUpdateDimensions,this._shouldUpdateAnchor=t||this._shouldUpdateAnchor,this._animationFrame===void 0&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>{this._refreshDecorations(),this._animationFrame=void 0}))}};Ri=be([H(2,Fe),H(3,Gs),H(4,yt),H(5,He),H(6,_s),H(7,bt)],Ri);var N;(e=>(e.NUL="\0",e.SOH="",e.STX="",e.ETX="",e.EOT="",e.ENQ="",e.ACK="",e.BEL="\x07",e.BS="\b",e.HT=" ",e.LF=`
237
+ `,e.VT="\v",e.FF="\f",e.CR="\r",e.SO="",e.SI="",e.DLE="",e.DC1="",e.DC2="",e.DC3="",e.DC4="",e.NAK="",e.SYN="",e.ETB="",e.CAN="",e.EM="",e.SUB="",e.ESC="\x1B",e.FS="",e.GS="",e.RS="",e.US="",e.SP=" ",e.DEL=""))(N||(N={}));var Ci;(e=>(e.PAD="€",e.HOP="",e.BPH="‚",e.NBH="ƒ",e.IND="„",e.NEL="…",e.SSA="†",e.ESA="‡",e.HTS="ˆ",e.HTJ="‰",e.VTS="Š",e.PLD="‹",e.PLU="Œ",e.RI="",e.SS2="Ž",e.SS3="",e.DCS="",e.PU1="‘",e.PU2="’",e.STS="“",e.CCH="”",e.MW="•",e.SPA="–",e.EPA="—",e.SOS="˜",e.SGCI="™",e.SCI="š",e.CSI="›",e.ST="œ",e.OSC="",e.PM="ž",e.APC="Ÿ"))(Ci||(Ci={}));var Jl;(e=>e.ST=`${N.ESC}\\`)(Jl||(Jl={}));var Kr=class{constructor(e,t,s,i,r,n){this._textarea=e,this._compositionView=t,this._bufferService=s,this._optionsService=i,this._coreService=r,this._renderService=n,this._isComposing=!1,this._isSendingComposition=!1,this._compositionPosition={start:0,end:0},this._dataAlreadySent=""}get isComposing(){return this._isComposing}compositionstart(){this._isComposing=!0,this._compositionPosition.start=this._textarea.value.length,this._compositionView.textContent="",this._dataAlreadySent="",this._compositionView.classList.add("active")}compositionupdate(e){this._compositionView.textContent=e.data,this.updateCompositionElements(),setTimeout(()=>{this._compositionPosition.end=this._textarea.value.length},0)}compositionend(){this._finalizeComposition(!0)}keydown(e){if(this._isComposing||this._isSendingComposition){if(e.keyCode===20||e.keyCode===229||e.keyCode===16||e.keyCode===17||e.keyCode===18)return!1;this._finalizeComposition(!1)}return e.keyCode===229?(this._handleAnyTextareaChanges(),!1):!0}_finalizeComposition(e){if(this._compositionView.classList.remove("active"),this._isComposing=!1,e){let t={start:this._compositionPosition.start,end:this._compositionPosition.end};this._isSendingComposition=!0,setTimeout(()=>{if(this._isSendingComposition){this._isSendingComposition=!1;let s;t.start+=this._dataAlreadySent.length,this._isComposing?s=this._textarea.value.substring(t.start,this._compositionPosition.start):s=this._textarea.value.substring(t.start),s.length>0&&this._coreService.triggerDataEvent(s,!0)}},0)}else{this._isSendingComposition=!1;let t=this._textarea.value.substring(this._compositionPosition.start,this._compositionPosition.end);this._coreService.triggerDataEvent(t,!0)}}_handleAnyTextareaChanges(){let e=this._textarea.value;setTimeout(()=>{if(!this._isComposing){let t=this._textarea.value,s=t.replace(e,"");this._dataAlreadySent=s,t.length>e.length?this._coreService.triggerDataEvent(s,!0):t.length<e.length?this._coreService.triggerDataEvent(`${N.DEL}`,!0):t.length===e.length&&t!==e&&this._coreService.triggerDataEvent(t,!0)}},0)}updateCompositionElements(e){if(this._isComposing){if(this._bufferService.buffer.isCursorInViewport){let t=Math.min(this._bufferService.buffer.x,this._bufferService.cols-1),s=this._renderService.dimensions.css.cell.height,i=this._bufferService.buffer.y*this._renderService.dimensions.css.cell.height,r=t*this._renderService.dimensions.css.cell.width;this._compositionView.style.left=r+"px",this._compositionView.style.top=i+"px",this._compositionView.style.height=s+"px",this._compositionView.style.lineHeight=s+"px",this._compositionView.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._compositionView.style.fontSize=this._optionsService.rawOptions.fontSize+"px";let n=this._compositionView.getBoundingClientRect();this._textarea.style.left=r+"px",this._textarea.style.top=i+"px",this._textarea.style.width=Math.max(n.width,1)+"px",this._textarea.style.height=Math.max(n.height,1)+"px",this._textarea.style.lineHeight=n.height+"px"}e||setTimeout(()=>this.updateCompositionElements(!0),0)}}};Kr=be([H(2,Fe),H(3,He),H(4,Jt),H(5,yt)],Kr);var Me=0,Pe=0,Re=0,xe=0,sa={css:"#00000000",rgba:0},Ce;(e=>{function t(r,n,a,l){return l!==void 0?`#${At(r)}${At(n)}${At(a)}${At(l)}`:`#${At(r)}${At(n)}${At(a)}`}e.toCss=t;function s(r,n,a,l=255){return(r<<24|n<<16|a<<8|l)>>>0}e.toRgba=s;function i(r,n,a,l){return{css:e.toCss(r,n,a,l),rgba:e.toRgba(r,n,a,l)}}e.toColor=i})(Ce||(Ce={}));var pe;(e=>{function t(h,c){if(xe=(c.rgba&255)/255,xe===1)return{css:c.css,rgba:c.rgba};let d=c.rgba>>24&255,f=c.rgba>>16&255,u=c.rgba>>8&255,g=h.rgba>>24&255,p=h.rgba>>16&255,m=h.rgba>>8&255;Me=g+Math.round((d-g)*xe),Pe=p+Math.round((f-p)*xe),Re=m+Math.round((u-m)*xe);let y=Ce.toCss(Me,Pe,Re),x=Ce.toRgba(Me,Pe,Re);return{css:y,rgba:x}}e.blend=t;function s(h){return(h.rgba&255)===255}e.isOpaque=s;function i(h,c,d){let f=ki.ensureContrastRatio(h.rgba,c.rgba,d);if(f)return Ce.toColor(f>>24&255,f>>16&255,f>>8&255)}e.ensureContrastRatio=i;function r(h){let c=(h.rgba|255)>>>0;return[Me,Pe,Re]=ki.toChannels(c),{css:Ce.toCss(Me,Pe,Re),rgba:c}}e.opaque=r;function n(h,c){return xe=Math.round(c*255),[Me,Pe,Re]=ki.toChannels(h.rgba),{css:Ce.toCss(Me,Pe,Re,xe),rgba:Ce.toRgba(Me,Pe,Re,xe)}}e.opacity=n;function a(h,c){return xe=h.rgba&255,n(h,xe*c/255)}e.multiplyOpacity=a;function l(h){return[h.rgba>>24&255,h.rgba>>16&255,h.rgba>>8&255]}e.toColorRGB=l})(pe||(pe={}));var ge;(e=>{let t,s;try{let r=document.createElement("canvas");r.width=1,r.height=1;let n=r.getContext("2d",{willReadFrequently:!0});n&&(t=n,t.globalCompositeOperation="copy",s=t.createLinearGradient(0,0,1,1))}catch{}function i(r){if(r.match(/#[\da-f]{3,8}/i))switch(r.length){case 4:return Me=parseInt(r.slice(1,2).repeat(2),16),Pe=parseInt(r.slice(2,3).repeat(2),16),Re=parseInt(r.slice(3,4).repeat(2),16),Ce.toColor(Me,Pe,Re);case 5:return Me=parseInt(r.slice(1,2).repeat(2),16),Pe=parseInt(r.slice(2,3).repeat(2),16),Re=parseInt(r.slice(3,4).repeat(2),16),xe=parseInt(r.slice(4,5).repeat(2),16),Ce.toColor(Me,Pe,Re,xe);case 7:return{css:r,rgba:(parseInt(r.slice(1),16)<<8|255)>>>0};case 9:return{css:r,rgba:parseInt(r.slice(1),16)>>>0}}let n=r.match(/rgba?\(\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(,\s*(0|1|\d?\.(\d+))\s*)?\)/);if(n)return Me=parseInt(n[1]),Pe=parseInt(n[2]),Re=parseInt(n[3]),xe=Math.round((n[5]===void 0?1:parseFloat(n[5]))*255),Ce.toColor(Me,Pe,Re,xe);if(!t||!s)throw new Error("css.toColor: Unsupported css format");if(t.fillStyle=s,t.fillStyle=r,typeof t.fillStyle!="string")throw new Error("css.toColor: Unsupported css format");if(t.fillRect(0,0,1,1),[Me,Pe,Re,xe]=t.getImageData(0,0,1,1).data,xe!==255)throw new Error("css.toColor: Unsupported css format");return{rgba:Ce.toRgba(Me,Pe,Re,xe),css:r}}e.toColor=i})(ge||(ge={}));var Ie;(e=>{function t(i){return s(i>>16&255,i>>8&255,i&255)}e.relativeLuminance=t;function s(i,r,n){let a=i/255,l=r/255,h=n/255,c=a<=.03928?a/12.92:Math.pow((a+.055)/1.055,2.4),d=l<=.03928?l/12.92:Math.pow((l+.055)/1.055,2.4),f=h<=.03928?h/12.92:Math.pow((h+.055)/1.055,2.4);return c*.2126+d*.7152+f*.0722}e.relativeLuminance2=s})(Ie||(Ie={}));var ki;(e=>{function t(a,l){if(xe=(l&255)/255,xe===1)return l;let h=l>>24&255,c=l>>16&255,d=l>>8&255,f=a>>24&255,u=a>>16&255,g=a>>8&255;return Me=f+Math.round((h-f)*xe),Pe=u+Math.round((c-u)*xe),Re=g+Math.round((d-g)*xe),Ce.toRgba(Me,Pe,Re)}e.blend=t;function s(a,l,h){let c=Ie.relativeLuminance(a>>8),d=Ie.relativeLuminance(l>>8);if(_t(c,d)<h){if(d<c){let g=i(a,l,h),p=_t(c,Ie.relativeLuminance(g>>8));if(p<h){let m=r(a,l,h),y=_t(c,Ie.relativeLuminance(m>>8));return p>y?g:m}return g}let f=r(a,l,h),u=_t(c,Ie.relativeLuminance(f>>8));if(u<h){let g=i(a,l,h),p=_t(c,Ie.relativeLuminance(g>>8));return u>p?f:g}return f}}e.ensureContrastRatio=s;function i(a,l,h){let c=a>>24&255,d=a>>16&255,f=a>>8&255,u=l>>24&255,g=l>>16&255,p=l>>8&255,m=_t(Ie.relativeLuminance2(u,g,p),Ie.relativeLuminance2(c,d,f));for(;m<h&&(u>0||g>0||p>0);)u-=Math.max(0,Math.ceil(u*.1)),g-=Math.max(0,Math.ceil(g*.1)),p-=Math.max(0,Math.ceil(p*.1)),m=_t(Ie.relativeLuminance2(u,g,p),Ie.relativeLuminance2(c,d,f));return(u<<24|g<<16|p<<8|255)>>>0}e.reduceLuminance=i;function r(a,l,h){let c=a>>24&255,d=a>>16&255,f=a>>8&255,u=l>>24&255,g=l>>16&255,p=l>>8&255,m=_t(Ie.relativeLuminance2(u,g,p),Ie.relativeLuminance2(c,d,f));for(;m<h&&(u<255||g<255||p<255);)u=Math.min(255,u+Math.ceil((255-u)*.1)),g=Math.min(255,g+Math.ceil((255-g)*.1)),p=Math.min(255,p+Math.ceil((255-p)*.1)),m=_t(Ie.relativeLuminance2(u,g,p),Ie.relativeLuminance2(c,d,f));return(u<<24|g<<16|p<<8|255)>>>0}e.increaseLuminance=r;function n(a){return[a>>24&255,a>>16&255,a>>8&255,a&255]}e.toChannels=n})(ki||(ki={}));function At(e){let t=e.toString(16);return t.length<2?"0"+t:t}function _t(e,t){return e<t?(t+.05)/(e+.05):(e+.05)/(t+.05)}var Op=class extends Ys{constructor(e,t,s){super(),this.content=0,this.combinedData="",this.fg=e.fg,this.bg=e.bg,this.combinedData=t,this._width=s}isCombined(){return 2097152}getWidth(){return this._width}getChars(){return this.combinedData}getCode(){return 2097151}setFromCharData(e){throw new Error("not implemented")}getAsCharData(){return[this.fg,this.getChars(),this.getWidth(),this.getCode()]}},Li=class{constructor(e){this._bufferService=e,this._characterJoiners=[],this._nextCharacterJoinerId=0,this._workCell=new st}register(e){let t={id:this._nextCharacterJoinerId++,handler:e};return this._characterJoiners.push(t),t.id}deregister(e){for(let t=0;t<this._characterJoiners.length;t++)if(this._characterJoiners[t].id===e)return this._characterJoiners.splice(t,1),!0;return!1}getJoinedCharacters(e){if(this._characterJoiners.length===0)return[];let t=this._bufferService.buffer.lines.get(e);if(!t||t.length===0)return[];let s=[],i=t.translateToString(!0),r=0,n=0,a=0,l=t.getFg(0),h=t.getBg(0);for(let c=0;c<t.getTrimmedLength();c++)if(t.loadCell(c,this._workCell),this._workCell.getWidth()!==0){if(this._workCell.fg!==l||this._workCell.bg!==h){if(c-r>1){let d=this._getJoinedRanges(i,a,n,t,r);for(let f=0;f<d.length;f++)s.push(d[f])}r=c,a=n,l=this._workCell.fg,h=this._workCell.bg}n+=this._workCell.getChars().length||jt.length}if(this._bufferService.cols-r>1){let c=this._getJoinedRanges(i,a,n,t,r);for(let d=0;d<c.length;d++)s.push(c[d])}return s}_getJoinedRanges(e,t,s,i,r){let n=e.substring(t,s),a=[];try{a=this._characterJoiners[0].handler(n)}catch(l){console.error(l)}for(let l=1;l<this._characterJoiners.length;l++)try{let h=this._characterJoiners[l].handler(n);for(let c=0;c<h.length;c++)Li._mergeRanges(a,h[c])}catch(h){console.error(h)}return this._stringRangesToCellRanges(a,i,r),a}_stringRangesToCellRanges(e,t,s){let i=0,r=!1,n=0,a=e[i];if(a){for(let l=s;l<this._bufferService.cols;l++){let h=t.getWidth(l),c=t.getString(l).length||jt.length;if(h!==0){if(!r&&a[0]<=n&&(a[0]=l,r=!0),a[1]<=n){if(a[1]=l,a=e[++i],!a)break;a[0]<=n?(a[0]=l,r=!0):r=!1}n+=c}}a&&(a[1]=this._bufferService.cols)}}static _mergeRanges(e,t){let s=!1;for(let i=0;i<e.length;i++){let r=e[i];if(s){if(t[1]<=r[0])return e[i-1][1]=t[1],e;if(t[1]<=r[1])return e[i-1][1]=Math.max(t[1],r[1]),e.splice(i,1),e;e.splice(i,1),i--}else{if(t[1]<=r[0])return e.splice(i,0,t),e;if(t[1]<=r[1])return r[0]=Math.min(t[0],r[0]),e;t[0]<r[1]&&(r[0]=Math.min(t[0],r[0]),s=!0);continue}}return s?e[e.length-1][1]=t[1]:e.push(t),e}};Li=be([H(0,Fe)],Li);function Ip(e){return 57508<=e&&e<=57558}function $p(e){return 9472<=e&&e<=9631}function Fp(e){return Ip(e)||$p(e)}function Hp(){return{css:{canvas:fi(),cell:fi()},device:{canvas:fi(),cell:fi(),char:{width:0,height:0,left:0,top:0}}}}function fi(){return{width:0,height:0}}var qr=class{constructor(e,t,s,i,r,n,a){this._document=e,this._characterJoinerService=t,this._optionsService=s,this._coreBrowserService=i,this._coreService=r,this._decorationService=n,this._themeService=a,this._workCell=new st,this._columnSelectMode=!1,this.defaultSpacing=0}handleSelectionChanged(e,t,s){this._selectionStart=e,this._selectionEnd=t,this._columnSelectMode=s}createRow(e,t,s,i,r,n,a,l,h,c,d){let f=[],u=this._characterJoinerService.getJoinedCharacters(t),g=this._themeService.colors,p=e.getNoBgTrimmedLength();s&&p<n+1&&(p=n+1);let m,y=0,x="",b=0,j=0,k=0,S=0,E=!1,B=0,U=!1,X=0,V=0,I=[],D=c!==-1&&d!==-1;for(let C=0;C<p;C++){e.loadCell(C,this._workCell);let P=this._workCell.getWidth();if(P===0)continue;let w=!1,M=C>=V,$=C,R=this._workCell;if(u.length>0&&C===u[0][0]&&M){let ne=u.shift(),ve=this._isCellInSelection(ne[0],t);for(b=ne[0]+1;b<ne[1];b++)M&&(M=ve===this._isCellInSelection(b,t));M&&(M=!s||n<ne[0]||n>=ne[1]),M?(w=!0,R=new Op(this._workCell,e.translateToString(!0,ne[0],ne[1]),ne[1]-ne[0]),$=ne[1]-1,P=R.getWidth()):V=ne[1]}let J=this._isCellInSelection(C,t),L=s&&C===n,O=D&&C>=c&&C<=d,K=!1;this._decorationService.forEachDecorationAtCell(C,t,void 0,ne=>{K=!0});let q=R.getChars()||jt;if(q===" "&&(R.isUnderline()||R.isOverline())&&(q=" "),X=P*l-h.get(q,R.isBold(),R.isItalic()),!m)m=this._document.createElement("span");else if(y&&(J&&U||!J&&!U&&R.bg===j)&&(J&&U&&g.selectionForeground||R.fg===k)&&R.extended.ext===S&&O===E&&X===B&&!L&&!w&&!K&&M){R.isInvisible()?x+=jt:x+=q,y++;continue}else y&&(m.textContent=x),m=this._document.createElement("span"),y=0,x="";if(j=R.bg,k=R.fg,S=R.extended.ext,E=O,B=X,U=J,w&&n>=C&&n<=$&&(n=C),!this._coreService.isCursorHidden&&L&&this._coreService.isCursorInitialized){if(I.push("xterm-cursor"),this._coreBrowserService.isFocused)a&&I.push("xterm-cursor-blink"),I.push(i==="bar"?"xterm-cursor-bar":i==="underline"?"xterm-cursor-underline":"xterm-cursor-block");else if(r)switch(r){case"outline":I.push("xterm-cursor-outline");break;case"block":I.push("xterm-cursor-block");break;case"bar":I.push("xterm-cursor-bar");break;case"underline":I.push("xterm-cursor-underline");break}}if(R.isBold()&&I.push("xterm-bold"),R.isItalic()&&I.push("xterm-italic"),R.isDim()&&I.push("xterm-dim"),R.isInvisible()?x=jt:x=R.getChars()||jt,R.isUnderline()&&(I.push(`xterm-underline-${R.extended.underlineStyle}`),x===" "&&(x=" "),!R.isUnderlineColorDefault()))if(R.isUnderlineColorRGB())m.style.textDecorationColor=`rgb(${Ys.toColorRGB(R.getUnderlineColor()).join(",")})`;else{let ne=R.getUnderlineColor();this._optionsService.rawOptions.drawBoldTextInBrightColors&&R.isBold()&&ne<8&&(ne+=8),m.style.textDecorationColor=g.ansi[ne].css}R.isOverline()&&(I.push("xterm-overline"),x===" "&&(x=" ")),R.isStrikethrough()&&I.push("xterm-strikethrough"),O&&(m.style.textDecoration="underline");let te=R.getFgColor(),se=R.getFgColorMode(),ae=R.getBgColor(),ce=R.getBgColorMode(),fe=!!R.isInverse();if(fe){let ne=te;te=ae,ae=ne;let ve=se;se=ce,ce=ve}let z,oe,We=!1;this._decorationService.forEachDecorationAtCell(C,t,void 0,ne=>{ne.options.layer!=="top"&&We||(ne.backgroundColorRGB&&(ce=50331648,ae=ne.backgroundColorRGB.rgba>>8&16777215,z=ne.backgroundColorRGB),ne.foregroundColorRGB&&(se=50331648,te=ne.foregroundColorRGB.rgba>>8&16777215,oe=ne.foregroundColorRGB),We=ne.options.layer==="top")}),!We&&J&&(z=this._coreBrowserService.isFocused?g.selectionBackgroundOpaque:g.selectionInactiveBackgroundOpaque,ae=z.rgba>>8&16777215,ce=50331648,We=!0,g.selectionForeground&&(se=50331648,te=g.selectionForeground.rgba>>8&16777215,oe=g.selectionForeground)),We&&I.push("xterm-decoration-top");let Ve;switch(ce){case 16777216:case 33554432:Ve=g.ansi[ae],I.push(`xterm-bg-${ae}`);break;case 50331648:Ve=Ce.toColor(ae>>16,ae>>8&255,ae&255),this._addStyle(m,`background-color:#${ia((ae>>>0).toString(16),"0",6)}`);break;case 0:default:fe?(Ve=g.foreground,I.push("xterm-bg-257")):Ve=g.background}switch(z||R.isDim()&&(z=pe.multiplyOpacity(Ve,.5)),se){case 16777216:case 33554432:R.isBold()&&te<8&&this._optionsService.rawOptions.drawBoldTextInBrightColors&&(te+=8),this._applyMinimumContrast(m,Ve,g.ansi[te],R,z,void 0)||I.push(`xterm-fg-${te}`);break;case 50331648:let ne=Ce.toColor(te>>16&255,te>>8&255,te&255);this._applyMinimumContrast(m,Ve,ne,R,z,oe)||this._addStyle(m,`color:#${ia(te.toString(16),"0",6)}`);break;case 0:default:this._applyMinimumContrast(m,Ve,g.foreground,R,z,oe)||fe&&I.push("xterm-fg-257")}I.length&&(m.className=I.join(" "),I.length=0),!L&&!w&&!K&&M?y++:m.textContent=x,X!==this.defaultSpacing&&(m.style.letterSpacing=`${X}px`),f.push(m),C=$}return m&&y&&(m.textContent=x),f}_applyMinimumContrast(e,t,s,i,r,n){if(this._optionsService.rawOptions.minimumContrastRatio===1||Fp(i.getCode()))return!1;let a=this._getContrastCache(i),l;if(!r&&!n&&(l=a.getColor(t.rgba,s.rgba)),l===void 0){let h=this._optionsService.rawOptions.minimumContrastRatio/(i.isDim()?2:1);l=pe.ensureContrastRatio(r||t,n||s,h),a.setColor((r||t).rgba,(n||s).rgba,l??null)}return l?(this._addStyle(e,`color:${l.css}`),!0):!1}_getContrastCache(e){return e.isDim()?this._themeService.colors.halfContrastCache:this._themeService.colors.contrastCache}_addStyle(e,t){e.setAttribute("style",`${e.getAttribute("style")||""}${t};`)}_isCellInSelection(e,t){let s=this._selectionStart,i=this._selectionEnd;return!s||!i?!1:this._columnSelectMode?s[0]<=i[0]?e>=s[0]&&t>=s[1]&&e<i[0]&&t<=i[1]:e<s[0]&&t>=s[1]&&e>=i[0]&&t<=i[1]:t>s[1]&&t<i[1]||s[1]===i[1]&&t===s[1]&&e>=s[0]&&e<i[0]||s[1]<i[1]&&t===i[1]&&e<i[0]||s[1]<i[1]&&t===s[1]&&e>=s[0]}};qr=be([H(1,Ll),H(2,He),H(3,bt),H(4,Jt),H(5,Gs),H(6,_s)],qr);function ia(e,t,s){for(;e.length<s;)e=t+e;return e}var Wp=class{constructor(e,t){this._flat=new Float32Array(256),this._font="",this._fontSize=0,this._weight="normal",this._weightBold="bold",this._measureElements=[],this._container=e.createElement("div"),this._container.classList.add("xterm-width-cache-measure-container"),this._container.setAttribute("aria-hidden","true"),this._container.style.whiteSpace="pre",this._container.style.fontKerning="none";let s=e.createElement("span");s.classList.add("xterm-char-measure-element");let i=e.createElement("span");i.classList.add("xterm-char-measure-element"),i.style.fontWeight="bold";let r=e.createElement("span");r.classList.add("xterm-char-measure-element"),r.style.fontStyle="italic";let n=e.createElement("span");n.classList.add("xterm-char-measure-element"),n.style.fontWeight="bold",n.style.fontStyle="italic",this._measureElements=[s,i,r,n],this._container.appendChild(s),this._container.appendChild(i),this._container.appendChild(r),this._container.appendChild(n),t.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(e,t,s,i){e===this._font&&t===this._fontSize&&s===this._weight&&i===this._weightBold||(this._font=e,this._fontSize=t,this._weight=s,this._weightBold=i,this._container.style.fontFamily=this._font,this._container.style.fontSize=`${this._fontSize}px`,this._measureElements[0].style.fontWeight=`${s}`,this._measureElements[1].style.fontWeight=`${i}`,this._measureElements[2].style.fontWeight=`${s}`,this._measureElements[3].style.fontWeight=`${i}`,this.clear())}get(e,t,s){let i=0;if(!t&&!s&&e.length===1&&(i=e.charCodeAt(0))<256){if(this._flat[i]!==-9999)return this._flat[i];let a=this._measure(e,0);return a>0&&(this._flat[i]=a),a}let r=e;t&&(r+="B"),s&&(r+="I");let n=this._holey.get(r);if(n===void 0){let a=0;t&&(a|=1),s&&(a|=2),n=this._measure(e,a),n>0&&this._holey.set(r,n)}return n}_measure(e,t){let s=this._measureElements[t];return s.textContent=e.repeat(32),s.offsetWidth/32}},Up=class{constructor(){this.clear()}clear(){this.hasSelection=!1,this.columnSelectMode=!1,this.viewportStartRow=0,this.viewportEndRow=0,this.viewportCappedStartRow=0,this.viewportCappedEndRow=0,this.startCol=0,this.endCol=0,this.selectionStart=void 0,this.selectionEnd=void 0}update(e,t,s,i=!1){if(this.selectionStart=t,this.selectionEnd=s,!t||!s||t[0]===s[0]&&t[1]===s[1]){this.clear();return}let r=e.buffers.active.ydisp,n=t[1]-r,a=s[1]-r,l=Math.max(n,0),h=Math.min(a,e.rows-1);if(l>=e.rows||h<0){this.clear();return}this.hasSelection=!0,this.columnSelectMode=i,this.viewportStartRow=n,this.viewportEndRow=a,this.viewportCappedStartRow=l,this.viewportCappedEndRow=h,this.startCol=t[0],this.endCol=s[0]}isCellSelected(e,t,s){return this.hasSelection?(s-=e.buffer.active.viewportY,this.columnSelectMode?this.startCol<=this.endCol?t>=this.startCol&&s>=this.viewportCappedStartRow&&t<this.endCol&&s<=this.viewportCappedEndRow:t<this.startCol&&s>=this.viewportCappedStartRow&&t>=this.endCol&&s<=this.viewportCappedEndRow:s>this.viewportStartRow&&s<this.viewportEndRow||this.viewportStartRow===this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportEndRow&&t<this.endCol||this.viewportStartRow<this.viewportEndRow&&s===this.viewportStartRow&&t>=this.startCol):!1}};function Kp(){return new Up}var ar="xterm-dom-renderer-owner-",Qe="xterm-rows",pi="xterm-fg-",ra="xterm-bg-",Cs="xterm-focus",_i="xterm-selection",qp=1,Vr=class extends re{constructor(e,t,s,i,r,n,a,l,h,c,d,f,u,g){super(),this._terminal=e,this._document=t,this._element=s,this._screenElement=i,this._viewportElement=r,this._helperContainer=n,this._linkifier2=a,this._charSizeService=h,this._optionsService=c,this._bufferService=d,this._coreService=f,this._coreBrowserService=u,this._themeService=g,this._terminalClass=qp++,this._rowElements=[],this._selectionRenderModel=Kp(),this.onRequestRedraw=this._register(new T).event,this._rowContainer=this._document.createElement("div"),this._rowContainer.classList.add(Qe),this._rowContainer.style.lineHeight="normal",this._rowContainer.setAttribute("aria-hidden","true"),this._refreshRowElements(this._bufferService.cols,this._bufferService.rows),this._selectionContainer=this._document.createElement("div"),this._selectionContainer.classList.add(_i),this._selectionContainer.setAttribute("aria-hidden","true"),this.dimensions=Hp(),this._updateDimensions(),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._themeService.onChangeColors(p=>this._injectCss(p))),this._injectCss(this._themeService.colors),this._rowFactory=l.createInstance(qr,document),this._element.classList.add(ar+this._terminalClass),this._screenElement.appendChild(this._rowContainer),this._screenElement.appendChild(this._selectionContainer),this._register(this._linkifier2.onShowLinkUnderline(p=>this._handleLinkHover(p))),this._register(this._linkifier2.onHideLinkUnderline(p=>this._handleLinkLeave(p))),this._register(_e(()=>{this._element.classList.remove(ar+this._terminalClass),this._rowContainer.remove(),this._selectionContainer.remove(),this._widthCache.dispose(),this._themeStyleElement.remove(),this._dimensionsStyleElement.remove()})),this._widthCache=new Wp(this._document,this._helperContainer),this._widthCache.setFont(this._optionsService.rawOptions.fontFamily,this._optionsService.rawOptions.fontSize,this._optionsService.rawOptions.fontWeight,this._optionsService.rawOptions.fontWeightBold),this._setDefaultSpacing()}_updateDimensions(){let e=this._coreBrowserService.dpr;this.dimensions.device.char.width=this._charSizeService.width*e,this.dimensions.device.char.height=Math.ceil(this._charSizeService.height*e),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/e),this.dimensions.css.canvas.height=Math.round(this.dimensions.device.canvas.height/e),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(let s of this._rowElements)s.style.width=`${this.dimensions.css.canvas.width}px`,s.style.height=`${this.dimensions.css.cell.height}px`,s.style.lineHeight=`${this.dimensions.css.cell.height}px`,s.style.overflow="hidden";this._dimensionsStyleElement||(this._dimensionsStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._dimensionsStyleElement));let t=`${this._terminalSelector} .${Qe} span { display: inline-block; height: 100%; vertical-align: top;}`;this._dimensionsStyleElement.textContent=t,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(e){this._themeStyleElement||(this._themeStyleElement=this._document.createElement("style"),this._screenElement.appendChild(this._themeStyleElement));let t=`${this._terminalSelector} .${Qe} { pointer-events: none; color: ${e.foreground.css}; font-family: ${this._optionsService.rawOptions.fontFamily}; font-size: ${this._optionsService.rawOptions.fontSize}px; font-kerning: none; white-space: pre}`;t+=`${this._terminalSelector} .${Qe} .xterm-dim { color: ${pe.multiplyOpacity(e.foreground,.5).css};}`,t+=`${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;}`;let s=`blink_underline_${this._terminalClass}`,i=`blink_bar_${this._terminalClass}`,r=`blink_block_${this._terminalClass}`;t+=`@keyframes ${s} { 50% { border-bottom-style: hidden; }}`,t+=`@keyframes ${i} { 50% { box-shadow: none; }}`,t+=`@keyframes ${r} { 0% { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css}; } 50% { background-color: inherit; color: ${e.cursor.css}; }}`,t+=`${this._terminalSelector} .${Qe}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-underline { animation: ${s} 1s step-end infinite;}${this._terminalSelector} .${Qe}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-bar { animation: ${i} 1s step-end infinite;}${this._terminalSelector} .${Qe}.${Cs} .xterm-cursor.xterm-cursor-blink.xterm-cursor-block { animation: ${r} 1s step-end infinite;}${this._terminalSelector} .${Qe} .xterm-cursor.xterm-cursor-block { background-color: ${e.cursor.css}; color: ${e.cursorAccent.css};}${this._terminalSelector} .${Qe} .xterm-cursor.xterm-cursor-block:not(.xterm-cursor-blink) { background-color: ${e.cursor.css} !important; color: ${e.cursorAccent.css} !important;}${this._terminalSelector} .${Qe} .xterm-cursor.xterm-cursor-outline { outline: 1px solid ${e.cursor.css}; outline-offset: -1px;}${this._terminalSelector} .${Qe} .xterm-cursor.xterm-cursor-bar { box-shadow: ${this._optionsService.rawOptions.cursorWidth}px 0 0 ${e.cursor.css} inset;}${this._terminalSelector} .${Qe} .xterm-cursor.xterm-cursor-underline { border-bottom: 1px ${e.cursor.css}; border-bottom-style: solid; height: calc(100% - 1px);}`,t+=`${this._terminalSelector} .${_i} { position: absolute; top: 0; left: 0; z-index: 1; pointer-events: none;}${this._terminalSelector}.focus .${_i} div { position: absolute; background-color: ${e.selectionBackgroundOpaque.css};}${this._terminalSelector} .${_i} div { position: absolute; background-color: ${e.selectionInactiveBackgroundOpaque.css};}`;for(let[n,a]of e.ansi.entries())t+=`${this._terminalSelector} .${pi}${n} { color: ${a.css}; }${this._terminalSelector} .${pi}${n}.xterm-dim { color: ${pe.multiplyOpacity(a,.5).css}; }${this._terminalSelector} .${ra}${n} { background-color: ${a.css}; }`;t+=`${this._terminalSelector} .${pi}257 { color: ${pe.opaque(e.background).css}; }${this._terminalSelector} .${pi}257.xterm-dim { color: ${pe.multiplyOpacity(pe.opaque(e.background),.5).css}; }${this._terminalSelector} .${ra}257 { background-color: ${e.foreground.css}; }`,this._themeStyleElement.textContent=t}_setDefaultSpacing(){let e=this.dimensions.css.cell.width-this._widthCache.get("W",!1,!1);this._rowContainer.style.letterSpacing=`${e}px`,this._rowFactory.defaultSpacing=e}handleDevicePixelRatioChange(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}_refreshRowElements(e,t){for(let s=this._rowElements.length;s<=t;s++){let i=this._document.createElement("div");this._rowContainer.appendChild(i),this._rowElements.push(i)}for(;this._rowElements.length>t;)this._rowContainer.removeChild(this._rowElements.pop())}handleResize(e,t){this._refreshRowElements(e,t),this._updateDimensions(),this.handleSelectionChanged(this._selectionRenderModel.selectionStart,this._selectionRenderModel.selectionEnd,this._selectionRenderModel.columnSelectMode)}handleCharSizeChanged(){this._updateDimensions(),this._widthCache.clear(),this._setDefaultSpacing()}handleBlur(){this._rowContainer.classList.remove(Cs),this.renderRows(0,this._bufferService.rows-1)}handleFocus(){this._rowContainer.classList.add(Cs),this.renderRows(this._bufferService.buffer.y,this._bufferService.buffer.y)}handleSelectionChanged(e,t,s){if(this._selectionContainer.replaceChildren(),this._rowFactory.handleSelectionChanged(e,t,s),this.renderRows(0,this._bufferService.rows-1),!e||!t||(this._selectionRenderModel.update(this._terminal,e,t,s),!this._selectionRenderModel.hasSelection))return;let i=this._selectionRenderModel.viewportStartRow,r=this._selectionRenderModel.viewportEndRow,n=this._selectionRenderModel.viewportCappedStartRow,a=this._selectionRenderModel.viewportCappedEndRow,l=this._document.createDocumentFragment();if(s){let h=e[0]>t[0];l.appendChild(this._createSelectionElement(n,h?t[0]:e[0],h?e[0]:t[0],a-n+1))}else{let h=i===n?e[0]:0,c=n===r?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(n,h,c));let d=a-n-1;if(l.appendChild(this._createSelectionElement(n+1,0,this._bufferService.cols,d)),n!==a){let f=r===a?t[0]:this._bufferService.cols;l.appendChild(this._createSelectionElement(a,0,f))}}this._selectionContainer.appendChild(l)}_createSelectionElement(e,t,s,i=1){let r=this._document.createElement("div"),n=t*this.dimensions.css.cell.width,a=this.dimensions.css.cell.width*(s-t);return n+a>this.dimensions.css.canvas.width&&(a=this.dimensions.css.canvas.width-n),r.style.height=`${i*this.dimensions.css.cell.height}px`,r.style.top=`${e*this.dimensions.css.cell.height}px`,r.style.left=`${n}px`,r.style.width=`${a}px`,r}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(let e of this._rowElements)e.replaceChildren()}renderRows(e,t){let s=this._bufferService.buffer,i=s.ybase+s.y,r=Math.min(s.x,this._bufferService.cols-1),n=this._coreService.decPrivateModes.cursorBlink??this._optionsService.rawOptions.cursorBlink,a=this._coreService.decPrivateModes.cursorStyle??this._optionsService.rawOptions.cursorStyle,l=this._optionsService.rawOptions.cursorInactiveStyle;for(let h=e;h<=t;h++){let c=h+s.ydisp,d=this._rowElements[h],f=s.lines.get(c);if(!d||!f)break;d.replaceChildren(...this._rowFactory.createRow(f,c,c===i,a,l,r,n,this.dimensions.css.cell.width,this._widthCache,-1,-1))}}get _terminalSelector(){return`.${ar}${this._terminalClass}`}_handleLinkHover(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!0)}_handleLinkLeave(e){this._setCellUnderline(e.x1,e.x2,e.y1,e.y2,e.cols,!1)}_setCellUnderline(e,t,s,i,r,n){s<0&&(e=0),i<0&&(t=0);let a=this._bufferService.rows-1;s=Math.max(Math.min(s,a),0),i=Math.max(Math.min(i,a),0),r=Math.min(r,this._bufferService.cols);let l=this._bufferService.buffer,h=l.ybase+l.y,c=Math.min(l.x,r-1),d=this._optionsService.rawOptions.cursorBlink,f=this._optionsService.rawOptions.cursorStyle,u=this._optionsService.rawOptions.cursorInactiveStyle;for(let g=s;g<=i;++g){let p=g+l.ydisp,m=this._rowElements[g],y=l.lines.get(p);if(!m||!y)break;m.replaceChildren(...this._rowFactory.createRow(y,p,p===h,f,u,c,d,this.dimensions.css.cell.width,this._widthCache,n?g===s?e:0:-1,n?(g===i?t:r)-1:-1))}}};Vr=be([H(7,wn),H(8,Wi),H(9,He),H(10,Fe),H(11,Jt),H(12,bt),H(13,_s)],Vr);var Yr=class extends re{constructor(e,t,s){super(),this._optionsService=s,this.width=0,this.height=0,this._onCharSizeChange=this._register(new T),this.onCharSizeChange=this._onCharSizeChange.event;try{this._measureStrategy=this._register(new Yp(this._optionsService))}catch{this._measureStrategy=this._register(new Vp(e,t,this._optionsService))}this._register(this._optionsService.onMultipleOptionChange(["fontFamily","fontSize"],()=>this.measure()))}get hasValidSize(){return this.width>0&&this.height>0}measure(){let e=this._measureStrategy.measure();(e.width!==this.width||e.height!==this.height)&&(this.width=e.width,this.height=e.height,this._onCharSizeChange.fire())}};Yr=be([H(2,He)],Yr);var Zl=class extends re{constructor(){super(...arguments),this._result={width:0,height:0}}_validateAndSet(e,t){e!==void 0&&e>0&&t!==void 0&&t>0&&(this._result.width=e,this._result.height=t)}},Vp=class extends Zl{constructor(e,t,s){super(),this._document=e,this._parentElement=t,this._optionsService=s,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(){return this._measureElement.style.fontFamily=this._optionsService.rawOptions.fontFamily,this._measureElement.style.fontSize=`${this._optionsService.rawOptions.fontSize}px`,this._validateAndSet(Number(this._measureElement.offsetWidth)/32,Number(this._measureElement.offsetHeight)),this._result}},Yp=class extends Zl{constructor(e){super(),this._optionsService=e,this._canvas=new OffscreenCanvas(100,100),this._ctx=this._canvas.getContext("2d");let t=this._ctx.measureText("W");if(!("width"in t&&"fontBoundingBoxAscent"in t&&"fontBoundingBoxDescent"in t))throw new Error("Required font metrics not supported")}measure(){this._ctx.font=`${this._optionsService.rawOptions.fontSize}px ${this._optionsService.rawOptions.fontFamily}`;let e=this._ctx.measureText("W");return this._validateAndSet(e.width,e.fontBoundingBoxAscent+e.fontBoundingBoxDescent),this._result}},Gp=class extends re{constructor(e,t,s){super(),this._textarea=e,this._window=t,this.mainDocument=s,this._isFocused=!1,this._cachedIsFocused=void 0,this._screenDprMonitor=this._register(new Xp(this._window)),this._onDprChange=this._register(new T),this.onDprChange=this._onDprChange.event,this._onWindowChange=this._register(new T),this.onWindowChange=this._onWindowChange.event,this._register(this.onWindowChange(i=>this._screenDprMonitor.setWindow(i))),this._register(Ae.forward(this._screenDprMonitor.onDprChange,this._onDprChange)),this._register(G(this._textarea,"focus",()=>this._isFocused=!0)),this._register(G(this._textarea,"blur",()=>this._isFocused=!1))}get window(){return this._window}set window(e){this._window!==e&&(this._window=e,this._onWindowChange.fire(this._window))}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}},Xp=class extends re{constructor(e){super(),this._parentWindow=e,this._windowResizeListener=this._register(new ps),this._onDprChange=this._register(new T),this.onDprChange=this._onDprChange.event,this._outerListener=()=>this._setDprAndFireIfDiffers(),this._currentDevicePixelRatio=this._parentWindow.devicePixelRatio,this._updateDpr(),this._setWindowResizeListener(),this._register(_e(()=>this.clearListener()))}setWindow(e){this._parentWindow=e,this._setWindowResizeListener(),this._setDprAndFireIfDiffers()}_setWindowResizeListener(){this._windowResizeListener.value=G(this._parentWindow,"resize",()=>this._setDprAndFireIfDiffers())}_setDprAndFireIfDiffers(){this._parentWindow.devicePixelRatio!==this._currentDevicePixelRatio&&this._onDprChange.fire(this._parentWindow.devicePixelRatio),this._updateDpr()}_updateDpr(){var e;this._outerListener&&((e=this._resolutionMediaMatchList)==null||e.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._outerListener||(this._resolutionMediaMatchList.removeListener(this._outerListener),this._resolutionMediaMatchList=void 0,this._outerListener=void 0)}},Jp=class extends re{constructor(){super(),this.linkProviders=[],this._register(_e(()=>this.linkProviders.length=0))}registerLinkProvider(e){return this.linkProviders.push(e),{dispose:()=>{let t=this.linkProviders.indexOf(e);t!==-1&&this.linkProviders.splice(t,1)}}}};function Pn(e,t,s){let i=s.getBoundingClientRect(),r=e.getComputedStyle(s),n=parseInt(r.getPropertyValue("padding-left")),a=parseInt(r.getPropertyValue("padding-top"));return[t.clientX-i.left-n,t.clientY-i.top-a]}function Zp(e,t,s,i,r,n,a,l,h){if(!n)return;let c=Pn(e,t,s);if(c)return c[0]=Math.ceil((c[0]+(h?a/2:0))/a),c[1]=Math.ceil(c[1]/l),c[0]=Math.min(Math.max(c[0],1),i+(h?1:0)),c[1]=Math.min(Math.max(c[1],1),r),c}var Gr=class{constructor(e,t){this._renderService=e,this._charSizeService=t}getCoords(e,t,s,i,r){return Zp(window,e,t,s,i,this._charSizeService.hasValidSize,this._renderService.dimensions.css.cell.width,this._renderService.dimensions.css.cell.height,r)}getMouseReportCoords(e,t){let s=Pn(window,e,t);if(this._charSizeService.hasValidSize)return s[0]=Math.min(Math.max(s[0],0),this._renderService.dimensions.css.canvas.width-1),s[1]=Math.min(Math.max(s[1],0),this._renderService.dimensions.css.canvas.height-1),{col:Math.floor(s[0]/this._renderService.dimensions.css.cell.width),row:Math.floor(s[1]/this._renderService.dimensions.css.cell.height),x:Math.floor(s[0]),y:Math.floor(s[1])}}};Gr=be([H(0,yt),H(1,Wi)],Gr);var Qp=class{constructor(e,t){this._renderCallback=e,this._coreBrowserService=t,this._refreshCallbacks=[]}dispose(){this._animationFrame&&(this._coreBrowserService.window.cancelAnimationFrame(this._animationFrame),this._animationFrame=void 0)}addRefreshCallback(e){return this._refreshCallbacks.push(e),this._animationFrame||(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh())),this._animationFrame}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t,!this._animationFrame&&(this._animationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._innerRefresh()))}_innerRefresh(){if(this._animationFrame=void 0,this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0){this._runRefreshCallbacks();return}let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t),this._runRefreshCallbacks()}_runRefreshCallbacks(){for(let e of this._refreshCallbacks)e(0);this._refreshCallbacks=[]}},Ql={};cf(Ql,{getSafariVersion:()=>t_,isChromeOS:()=>ic,isFirefox:()=>ec,isIpad:()=>s_,isIphone:()=>i_,isLegacyEdge:()=>e_,isLinux:()=>Rn,isMac:()=>Bi,isNode:()=>Ui,isSafari:()=>tc,isWindows:()=>sc});var Ui=typeof process<"u"&&"title"in process,Xs=Ui?"node":navigator.userAgent,Js=Ui?"node":navigator.platform,ec=Xs.includes("Firefox"),e_=Xs.includes("Edge"),tc=/^((?!chrome|android).)*safari/i.test(Xs);function t_(){if(!tc)return 0;let e=Xs.match(/Version\/(\d+)/);return e===null||e.length<2?0:parseInt(e[1])}var Bi=["Macintosh","MacIntel","MacPPC","Mac68K"].includes(Js),s_=Js==="iPad",i_=Js==="iPhone",sc=["Windows","Win16","Win32","WinCE"].includes(Js),Rn=Js.indexOf("Linux")>=0,ic=/\bCrOS\b/.test(Xs),rc=class{constructor(){this._tasks=[],this._i=0}enqueue(e){this._tasks.push(e),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(e){this._idleCallback=void 0;let t=0,s=0,i=e.timeRemaining(),r=0;for(;this._i<this._tasks.length;){if(t=performance.now(),this._tasks[this._i]()||this._i++,t=Math.max(1,performance.now()-t),s=Math.max(t,s),r=e.timeRemaining(),s*1.5>r){i-t<-20&&console.warn(`task queue exceeded allotted deadline by ${Math.abs(Math.round(i-t))}ms`),this._start();return}i=r}this.clear()}},r_=class extends rc{_requestCallback(e){return setTimeout(()=>e(this._createDeadline(16)))}_cancelCallback(e){clearTimeout(e)}_createDeadline(e){let t=performance.now()+e;return{timeRemaining:()=>Math.max(0,t-performance.now())}}},n_=class extends rc{_requestCallback(e){return requestIdleCallback(e)}_cancelCallback(e){cancelIdleCallback(e)}},zi=!Ui&&"requestIdleCallback"in window?n_:r_,o_=class{constructor(){this._queue=new zi}set(e){this._queue.clear(),this._queue.enqueue(e)}flush(){this._queue.flush()}},Xr=class extends re{constructor(e,t,s,i,r,n,a,l,h){super(),this._rowCount=e,this._optionsService=s,this._charSizeService=i,this._coreService=r,this._coreBrowserService=l,this._renderer=this._register(new ps),this._pausedResizeTask=new o_,this._observerDisposable=this._register(new ps),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 T),this.onDimensionsChange=this._onDimensionsChange.event,this._onRenderedViewportChange=this._register(new T),this.onRenderedViewportChange=this._onRenderedViewportChange.event,this._onRender=this._register(new T),this.onRender=this._onRender.event,this._onRefreshRequest=this._register(new T),this.onRefreshRequest=this._onRefreshRequest.event,this._renderDebouncer=new Qp((c,d)=>this._renderRows(c,d),this._coreBrowserService),this._register(this._renderDebouncer),this._syncOutputHandler=new a_(this._coreBrowserService,this._coreService,()=>this._fullRefresh()),this._register(_e(()=>this._syncOutputHandler.dispose())),this._register(this._coreBrowserService.onDprChange(()=>this.handleDevicePixelRatioChange())),this._register(a.onResize(()=>this._fullRefresh())),this._register(a.buffers.onBufferActivate(()=>{var c;return(c=this._renderer.value)==null?void 0:c.clear()})),this._register(this._optionsService.onOptionChange(()=>this._handleOptionsChanged())),this._register(this._charSizeService.onCharSizeChange(()=>this.handleCharSizeChanged())),this._register(n.onDecorationRegistered(()=>this._fullRefresh())),this._register(n.onDecorationRemoved(()=>this._fullRefresh())),this._register(this._optionsService.onMultipleOptionChange(["customGlyphs","drawBoldTextInBrightColors","letterSpacing","lineHeight","fontFamily","fontSize","fontWeight","fontWeightBold","minimumContrastRatio","rescaleOverlappingGlyphs"],()=>{this.clear(),this.handleResize(a.cols,a.rows),this._fullRefresh()})),this._register(this._optionsService.onMultipleOptionChange(["cursorBlink","cursorStyle"],()=>this.refreshRows(a.buffer.y,a.buffer.y,!0))),this._register(h.onChangeColors(()=>this._fullRefresh())),this._registerIntersectionObserver(this._coreBrowserService.window,t),this._register(this._coreBrowserService.onWindowChange(c=>this._registerIntersectionObserver(c,t)))}get dimensions(){return this._renderer.value.dimensions}_registerIntersectionObserver(e,t){if("IntersectionObserver"in e){let s=new e.IntersectionObserver(i=>this._handleIntersectionChange(i[i.length-1]),{threshold:0});s.observe(t),this._observerDisposable.value=_e(()=>s.disconnect())}}_handleIntersectionChange(e){this._isPaused=e.isIntersecting===void 0?e.intersectionRatio===0:!e.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(e,t,s=!1){if(this._isPaused){this._needsFullRefresh=!0;return}if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}let i=this._syncOutputHandler.flush();i&&(e=Math.min(e,i.start),t=Math.max(t,i.end)),s||(this._isNextRenderRedrawOnly=!1),this._renderDebouncer.refresh(e,t,this._rowCount)}_renderRows(e,t){if(this._renderer.value){if(this._coreService.decPrivateModes.synchronizedOutput){this._syncOutputHandler.bufferRows(e,t);return}e=Math.min(e,this._rowCount-1),t=Math.min(t,this._rowCount-1),this._renderer.value.renderRows(e,t),this._needsSelectionRefresh&&(this._renderer.value.handleSelectionChanged(this._selectionState.start,this._selectionState.end,this._selectionState.columnSelectMode),this._needsSelectionRefresh=!1),this._isNextRenderRedrawOnly||this._onRenderedViewportChange.fire({start:e,end:t}),this._onRender.fire({start:e,end:t}),this._isNextRenderRedrawOnly=!0}}resize(e,t){this._rowCount=t,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(e){this._renderer.value=e,this._renderer.value&&(this._renderer.value.onRequestRedraw(t=>this.refreshRows(t.start,t.end,!0)),this._needsSelectionRefresh=!0,this._fullRefresh())}addRefreshCallback(e){return this._renderDebouncer.addRefreshCallback(e)}_fullRefresh(){this._isPaused?this._needsFullRefresh=!0:this.refreshRows(0,this._rowCount-1)}clearTextureAtlas(){var e,t;this._renderer.value&&((t=(e=this._renderer.value).clearTextureAtlas)==null||t.call(e),this._fullRefresh())}handleDevicePixelRatioChange(){this._charSizeService.measure(),this._renderer.value&&(this._renderer.value.handleDevicePixelRatioChange(),this.refreshRows(0,this._rowCount-1))}handleResize(e,t){this._renderer.value&&(this._isPaused?this._pausedResizeTask.set(()=>{var s;return(s=this._renderer.value)==null?void 0:s.handleResize(e,t)}):this._renderer.value.handleResize(e,t),this._fullRefresh())}handleCharSizeChanged(){var e;(e=this._renderer.value)==null||e.handleCharSizeChanged()}handleBlur(){var e;(e=this._renderer.value)==null||e.handleBlur()}handleFocus(){var e;(e=this._renderer.value)==null||e.handleFocus()}handleSelectionChanged(e,t,s){var i;this._selectionState.start=e,this._selectionState.end=t,this._selectionState.columnSelectMode=s,(i=this._renderer.value)==null||i.handleSelectionChanged(e,t,s)}handleCursorMove(){var e;(e=this._renderer.value)==null||e.handleCursorMove()}clear(){var e;(e=this._renderer.value)==null||e.clear()}};Xr=be([H(2,He),H(3,Wi),H(4,Jt),H(5,Gs),H(6,Fe),H(7,bt),H(8,_s)],Xr);var a_=class{constructor(e,t,s){this._coreBrowserService=e,this._coreService=t,this._onTimeout=s,this._start=0,this._end=0,this._isBuffering=!1}bufferRows(e,t){this._isBuffering?(this._start=Math.min(this._start,e),this._end=Math.max(this._end,t)):(this._start=e,this._end=t,this._isBuffering=!0),this._timeout===void 0&&(this._timeout=this._coreBrowserService.window.setTimeout(()=>{this._timeout=void 0,this._coreService.decPrivateModes.synchronizedOutput=!1,this._onTimeout()},1e3))}flush(){if(this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0),!this._isBuffering)return;let e={start:this._start,end:this._end};return this._isBuffering=!1,e}dispose(){this._timeout!==void 0&&(this._coreBrowserService.window.clearTimeout(this._timeout),this._timeout=void 0)}};function l_(e,t,s,i){let r=s.buffer.x,n=s.buffer.y;if(!s.buffer.hasScrollback)return d_(r,n,e,t,s,i)+Ki(n,t,s,i)+u_(r,n,e,t,s,i);let a;if(n===t)return a=r>e?"D":"C",Ks(Math.abs(r-e),Us(a,i));a=n>t?"D":"C";let l=Math.abs(n-t),h=h_(n>t?e:r,s)+(l-1)*s.cols+1+c_(n>t?r:e);return Ks(h,Us(a,i))}function c_(e,t){return e-1}function h_(e,t){return t.cols-e}function d_(e,t,s,i,r,n){return Ki(t,i,r,n).length===0?"":Ks(oc(e,t,e,t-Yt(t,r),!1,r).length,Us("D",n))}function Ki(e,t,s,i){let r=e-Yt(e,s),n=t-Yt(t,s),a=Math.abs(r-n)-f_(e,t,s);return Ks(a,Us(nc(e,t),i))}function u_(e,t,s,i,r,n){let a;Ki(t,i,r,n).length>0?a=i-Yt(i,r):a=t;let l=i,h=p_(e,t,s,i,r,n);return Ks(oc(e,a,s,l,h==="C",r).length,Us(h,n))}function f_(e,t,s){var a;let i=0,r=e-Yt(e,s),n=t-Yt(t,s);for(let l=0;l<Math.abs(r-n);l++){let h=nc(e,t)==="A"?-1:1;(a=s.buffer.lines.get(r+h*l))!=null&&a.isWrapped&&i++}return i}function Yt(e,t){let s=0,i=t.buffer.lines.get(e),r=i==null?void 0:i.isWrapped;for(;r&&e>=0&&e<t.rows;)s++,i=t.buffer.lines.get(--e),r=i==null?void 0:i.isWrapped;return s}function p_(e,t,s,i,r,n){let a;return Ki(s,i,r,n).length>0?a=i-Yt(i,r):a=t,e<s&&a<=i||e>=s&&a<i?"C":"D"}function nc(e,t){return e>t?"A":"B"}function oc(e,t,s,i,r,n){let a=e,l=t,h="";for(;(a!==s||l!==i)&&l>=0&&l<n.buffer.lines.length;)a+=r?1:-1,r&&a>n.cols-1?(h+=n.buffer.translateBufferLineToString(l,!1,e,a),a=0,e=0,l++):!r&&a<0&&(h+=n.buffer.translateBufferLineToString(l,!1,0,e+1),a=n.cols-1,e=a,l--);return h+n.buffer.translateBufferLineToString(l,!1,e,a)}function Us(e,t){let s=t?"O":"[";return N.ESC+s+e}function Ks(e,t){e=Math.floor(e);let s="";for(let i=0;i<e;i++)s+=t;return s}var __=class{constructor(e){this._bufferService=e,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.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()){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?e%this._bufferService.cols===0?[this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)-1]:[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[e,this.selectionStart[1]]}if(this.selectionStartLength&&this.selectionEnd[1]===this.selectionStart[1]){let e=this.selectionStart[0]+this.selectionStartLength;return e>this._bufferService.cols?[e%this._bufferService.cols,this.selectionStart[1]+Math.floor(e/this._bufferService.cols)]:[Math.max(e,this.selectionEnd[0]),this.selectionEnd[1]]}return this.selectionEnd}}areSelectionValuesReversed(){let e=this.selectionStart,t=this.selectionEnd;return!e||!t?!1:e[1]>t[1]||e[1]===t[1]&&e[0]>t[0]}handleTrim(e){return this.selectionStart&&(this.selectionStart[1]-=e),this.selectionEnd&&(this.selectionEnd[1]-=e),this.selectionEnd&&this.selectionEnd[1]<0?(this.clearSelection(),!0):(this.selectionStart&&this.selectionStart[1]<0&&(this.selectionStart[1]=0),!1)}};function na(e,t){if(e.start.y>e.end.y)throw new Error(`Buffer range end (${e.end.x}, ${e.end.y}) cannot be before start (${e.start.x}, ${e.start.y})`);return t*(e.end.y-e.start.y)+(e.end.x-e.start.x+1)}var lr=50,m_=15,g_=50,v_=500,x_=" ",b_=new RegExp(x_,"g"),Jr=class extends re{constructor(e,t,s,i,r,n,a,l,h){super(),this._element=e,this._screenElement=t,this._linkifier=s,this._bufferService=i,this._coreService=r,this._mouseService=n,this._optionsService=a,this._renderService=l,this._coreBrowserService=h,this._dragScrollAmount=0,this._enabled=!0,this._workCell=new st,this._mouseDownTimeStamp=0,this._oldHasSelection=!1,this._oldSelectionStart=void 0,this._oldSelectionEnd=void 0,this._onLinuxMouseSelection=this._register(new T),this.onLinuxMouseSelection=this._onLinuxMouseSelection.event,this._onRedrawRequest=this._register(new T),this.onRequestRedraw=this._onRedrawRequest.event,this._onSelectionChange=this._register(new T),this.onSelectionChange=this._onSelectionChange.event,this._onRequestScrollLines=this._register(new T),this.onRequestScrollLines=this._onRequestScrollLines.event,this._mouseMoveListener=c=>this._handleMouseMove(c),this._mouseUpListener=c=>this._handleMouseUp(c),this._coreService.onUserInput(()=>{this.hasSelection&&this.clearSelection()}),this._trimListener=this._bufferService.buffer.lines.onTrim(c=>this._handleTrim(c)),this._register(this._bufferService.buffers.onBufferActivate(c=>this._handleBufferActivate(c))),this.enable(),this._model=new __(this._bufferService),this._activeSelectionMode=0,this._register(_e(()=>{this._removeMouseDownListeners()})),this._register(this._bufferService.onResize(c=>{c.rowsChanged&&this.clearSelection()}))}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(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;return!e||!t?!1:e[0]!==t[0]||e[1]!==t[1]}get selectionText(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd;if(!e||!t)return"";let s=this._bufferService.buffer,i=[];if(this._activeSelectionMode===3){if(e[0]===t[0])return"";let r=e[0]<t[0]?e[0]:t[0],n=e[0]<t[0]?t[0]:e[0];for(let a=e[1];a<=t[1];a++){let l=s.translateBufferLineToString(a,!0,r,n);i.push(l)}}else{let r=e[1]===t[1]?t[0]:void 0;i.push(s.translateBufferLineToString(e[1],!0,e[0],r));for(let n=e[1]+1;n<=t[1]-1;n++){let a=s.lines.get(n),l=s.translateBufferLineToString(n,!0);a!=null&&a.isWrapped?i[i.length-1]+=l:i.push(l)}if(e[1]!==t[1]){let n=s.lines.get(t[1]),a=s.translateBufferLineToString(t[1],!0,0,t[0]);n&&n.isWrapped?i[i.length-1]+=a:i.push(a)}}return i.map(r=>r.replace(b_," ")).join(sc?`\r
238
+ `:`
239
+ `)}clearSelection(){this._model.clearSelection(),this._removeMouseDownListeners(),this.refresh(),this._onSelectionChange.fire()}refresh(e){this._refreshAnimationFrame||(this._refreshAnimationFrame=this._coreBrowserService.window.requestAnimationFrame(()=>this._refresh())),Rn&&e&&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(e){let t=this._getMouseBufferCoords(e),s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i||!t?!1:this._areCoordsInSelection(t,s,i)}isCellInSelection(e,t){let s=this._model.finalSelectionStart,i=this._model.finalSelectionEnd;return!s||!i?!1:this._areCoordsInSelection([e,t],s,i)}_areCoordsInSelection(e,t,s){return e[1]>t[1]&&e[1]<s[1]||t[1]===s[1]&&e[1]===t[1]&&e[0]>=t[0]&&e[0]<s[0]||t[1]<s[1]&&e[1]===s[1]&&e[0]<s[0]||t[1]<s[1]&&e[1]===t[1]&&e[0]>=t[0]}_selectWordAtCursor(e,t){var r,n;let s=(n=(r=this._linkifier.currentLink)==null?void 0:r.link)==null?void 0:n.range;if(s)return this._model.selectionStart=[s.start.x-1,s.start.y-1],this._model.selectionStartLength=na(s,this._bufferService.cols),this._model.selectionEnd=void 0,!0;let i=this._getMouseBufferCoords(e);return i?(this._selectWordAt(i,t),this._model.selectionEnd=void 0,!0):!1}selectAll(){this._model.isSelectAllActive=!0,this.refresh(),this._onSelectionChange.fire()}selectLines(e,t){this._model.clearSelection(),e=Math.max(e,0),t=Math.min(t,this._bufferService.buffer.lines.length-1),this._model.selectionStart=[0,e],this._model.selectionEnd=[this._bufferService.cols,t],this.refresh(),this._onSelectionChange.fire()}_handleTrim(e){this._model.handleTrim(e)&&this.refresh()}_getMouseBufferCoords(e){let t=this._mouseService.getCoords(e,this._screenElement,this._bufferService.cols,this._bufferService.rows,!0);if(t)return t[0]--,t[1]--,t[1]+=this._bufferService.buffer.ydisp,t}_getMouseEventScrollAmount(e){let t=Pn(this._coreBrowserService.window,e,this._screenElement)[1],s=this._renderService.dimensions.css.canvas.height;return t>=0&&t<=s?0:(t>s&&(t-=s),t=Math.min(Math.max(t,-lr),lr),t/=lr,t/Math.abs(t)+Math.round(t*(m_-1)))}shouldForceSelection(e){return Bi?e.altKey&&this._optionsService.rawOptions.macOptionClickForcesSelection:e.shiftKey}handleMouseDown(e){if(this._mouseDownTimeStamp=e.timeStamp,!(e.button===2&&this.hasSelection)&&e.button===0){if(!this._enabled){if(!this.shouldForceSelection(e))return;e.stopPropagation()}e.preventDefault(),this._dragScrollAmount=0,this._enabled&&e.shiftKey?this._handleIncrementalClick(e):e.detail===1?this._handleSingleClick(e):e.detail===2?this._handleDoubleClick(e):e.detail===3&&this._handleTripleClick(e),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(),g_)}_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(e){this._model.selectionStart&&(this._model.selectionEnd=this._getMouseBufferCoords(e))}_handleSingleClick(e){if(this._model.selectionStartLength=0,this._model.isSelectAllActive=!1,this._activeSelectionMode=this.shouldColumnSelect(e)?3:0,this._model.selectionStart=this._getMouseBufferCoords(e),!this._model.selectionStart)return;this._model.selectionEnd=void 0;let t=this._bufferService.buffer.lines.get(this._model.selectionStart[1]);t&&t.length!==this._model.selectionStart[0]&&t.hasWidth(this._model.selectionStart[0])===0&&this._model.selectionStart[0]++}_handleDoubleClick(e){this._selectWordAtCursor(e,!0)&&(this._activeSelectionMode=1)}_handleTripleClick(e){let t=this._getMouseBufferCoords(e);t&&(this._activeSelectionMode=2,this._selectLineAt(t[1]))}shouldColumnSelect(e){return e.altKey&&!(Bi&&this._optionsService.rawOptions.macOptionClickForcesSelection)}_handleMouseMove(e){if(e.stopImmediatePropagation(),!this._model.selectionStart)return;let t=this._model.selectionEnd?[this._model.selectionEnd[0],this._model.selectionEnd[1]]:null;if(this._model.selectionEnd=this._getMouseBufferCoords(e),!this._model.selectionEnd){this.refresh(!0);return}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(e),this._activeSelectionMode!==3&&(this._dragScrollAmount>0?this._model.selectionEnd[0]=this._bufferService.cols:this._dragScrollAmount<0&&(this._model.selectionEnd[0]=0));let s=this._bufferService.buffer;if(this._model.selectionEnd[1]<s.lines.length){let i=s.lines.get(this._model.selectionEnd[1]);i&&i.hasWidth(this._model.selectionEnd[0])===0&&this._model.selectionEnd[0]<this._bufferService.cols&&this._model.selectionEnd[0]++}(!t||t[0]!==this._model.selectionEnd[0]||t[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});let e=this._bufferService.buffer;this._dragScrollAmount>0?(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=this._bufferService.cols),this._model.selectionEnd[1]=Math.min(e.ydisp+this._bufferService.rows,e.lines.length-1)):(this._activeSelectionMode!==3&&(this._model.selectionEnd[0]=0),this._model.selectionEnd[1]=e.ydisp),this.refresh()}}_handleMouseUp(e){let t=e.timeStamp-this._mouseDownTimeStamp;if(this._removeMouseDownListeners(),this.selectionText.length<=1&&t<v_&&e.altKey&&this._optionsService.rawOptions.altClickMovesCursor){if(this._bufferService.buffer.ybase===this._bufferService.buffer.ydisp){let s=this._mouseService.getCoords(e,this._element,this._bufferService.cols,this._bufferService.rows,!1);if(s&&s[0]!==void 0&&s[1]!==void 0){let i=l_(s[0]-1,s[1]-1,this._bufferService,this._coreService.decPrivateModes.applicationCursorKeys);this._coreService.triggerDataEvent(i,!0)}}}else this._fireEventIfSelectionChanged()}_fireEventIfSelectionChanged(){let e=this._model.finalSelectionStart,t=this._model.finalSelectionEnd,s=!!e&&!!t&&(e[0]!==t[0]||e[1]!==t[1]);if(!s){this._oldHasSelection&&this._fireOnSelectionChange(e,t,s);return}!e||!t||(!this._oldSelectionStart||!this._oldSelectionEnd||e[0]!==this._oldSelectionStart[0]||e[1]!==this._oldSelectionStart[1]||t[0]!==this._oldSelectionEnd[0]||t[1]!==this._oldSelectionEnd[1])&&this._fireOnSelectionChange(e,t,s)}_fireOnSelectionChange(e,t,s){this._oldSelectionStart=e,this._oldSelectionEnd=t,this._oldHasSelection=s,this._onSelectionChange.fire()}_handleBufferActivate(e){this.clearSelection(),this._trimListener.dispose(),this._trimListener=e.activeBuffer.lines.onTrim(t=>this._handleTrim(t))}_convertViewportColToCharacterIndex(e,t){let s=t;for(let i=0;t>=i;i++){let r=e.loadCell(i,this._workCell).getChars().length;this._workCell.getWidth()===0?s--:r>1&&t!==i&&(s+=r-1)}return s}setSelection(e,t,s){this._model.clearSelection(),this._removeMouseDownListeners(),this._model.selectionStart=[e,t],this._model.selectionStartLength=s,this.refresh(),this._fireEventIfSelectionChanged()}rightClickSelect(e){this._isClickInSelection(e)||(this._selectWordAtCursor(e,!1)&&this.refresh(!0),this._fireEventIfSelectionChanged())}_getWordAt(e,t,s=!0,i=!0){if(e[0]>=this._bufferService.cols)return;let r=this._bufferService.buffer,n=r.lines.get(e[1]);if(!n)return;let a=r.translateBufferLineToString(e[1],!1),l=this._convertViewportColToCharacterIndex(n,e[0]),h=l,c=e[0]-l,d=0,f=0,u=0,g=0;if(a.charAt(l)===" "){for(;l>0&&a.charAt(l-1)===" ";)l--;for(;h<a.length&&a.charAt(h+1)===" ";)h++}else{let y=e[0],x=e[0];n.getWidth(y)===0&&(d++,y--),n.getWidth(x)===2&&(f++,x++);let b=n.getString(x).length;for(b>1&&(g+=b-1,h+=b-1);y>0&&l>0&&!this._isCharWordSeparator(n.loadCell(y-1,this._workCell));){n.loadCell(y-1,this._workCell);let j=this._workCell.getChars().length;this._workCell.getWidth()===0?(d++,y--):j>1&&(u+=j-1,l-=j-1),l--,y--}for(;x<n.length&&h+1<a.length&&!this._isCharWordSeparator(n.loadCell(x+1,this._workCell));){n.loadCell(x+1,this._workCell);let j=this._workCell.getChars().length;this._workCell.getWidth()===2?(f++,x++):j>1&&(g+=j-1,h+=j-1),h++,x++}}h++;let p=l+c-d+u,m=Math.min(this._bufferService.cols,h-l+d+f-u-g);if(!(!t&&a.slice(l,h).trim()==="")){if(s&&p===0&&n.getCodePoint(0)!==32){let y=r.lines.get(e[1]-1);if(y&&n.isWrapped&&y.getCodePoint(this._bufferService.cols-1)!==32){let x=this._getWordAt([this._bufferService.cols-1,e[1]-1],!1,!0,!1);if(x){let b=this._bufferService.cols-x.start;p-=b,m+=b}}}if(i&&p+m===this._bufferService.cols&&n.getCodePoint(this._bufferService.cols-1)!==32){let y=r.lines.get(e[1]+1);if(y!=null&&y.isWrapped&&y.getCodePoint(0)!==32){let x=this._getWordAt([0,e[1]+1],!1,!1,!0);x&&(m+=x.length)}}return{start:p,length:m}}}_selectWordAt(e,t){let s=this._getWordAt(e,t);if(s){for(;s.start<0;)s.start+=this._bufferService.cols,e[1]--;this._model.selectionStart=[s.start,e[1]],this._model.selectionStartLength=s.length}}_selectToWordAt(e){let t=this._getWordAt(e,!0);if(t){let s=e[1];for(;t.start<0;)t.start+=this._bufferService.cols,s--;if(!this._model.areSelectionValuesReversed())for(;t.start+t.length>this._bufferService.cols;)t.length-=this._bufferService.cols,s++;this._model.selectionEnd=[this._model.areSelectionValuesReversed()?t.start:t.start+t.length,s]}}_isCharWordSeparator(e){return e.getWidth()===0?!1:this._optionsService.rawOptions.wordSeparator.indexOf(e.getChars())>=0}_selectLineAt(e){let t=this._bufferService.buffer.getWrappedRangeForLine(e),s={start:{x:0,y:t.first},end:{x:this._bufferService.cols-1,y:t.last}};this._model.selectionStart=[0,t.first],this._model.selectionEnd=void 0,this._model.selectionStartLength=na(s,this._bufferService.cols)}};Jr=be([H(3,Fe),H(4,Jt),H(5,Cn),H(6,He),H(7,yt),H(8,bt)],Jr);var oa=class{constructor(){this._data={}}set(e,t,s){this._data[e]||(this._data[e]={}),this._data[e][t]=s}get(e,t){return this._data[e]?this._data[e][t]:void 0}clear(){this._data={}}},aa=class{constructor(){this._color=new oa,this._css=new oa}setCss(e,t,s){this._css.set(e,t,s)}getCss(e,t){return this._css.get(e,t)}setColor(e,t,s){this._color.set(e,t,s)}getColor(e,t){return this._color.get(e,t)}clear(){this._color.clear(),this._css.clear()}},ke=Object.freeze((()=>{let e=[ge.toColor("#2e3436"),ge.toColor("#cc0000"),ge.toColor("#4e9a06"),ge.toColor("#c4a000"),ge.toColor("#3465a4"),ge.toColor("#75507b"),ge.toColor("#06989a"),ge.toColor("#d3d7cf"),ge.toColor("#555753"),ge.toColor("#ef2929"),ge.toColor("#8ae234"),ge.toColor("#fce94f"),ge.toColor("#729fcf"),ge.toColor("#ad7fa8"),ge.toColor("#34e2e2"),ge.toColor("#eeeeec")],t=[0,95,135,175,215,255];for(let s=0;s<216;s++){let i=t[s/36%6|0],r=t[s/6%6|0],n=t[s%6];e.push({css:Ce.toCss(i,r,n),rgba:Ce.toRgba(i,r,n)})}for(let s=0;s<24;s++){let i=8+s*10;e.push({css:Ce.toCss(i,i,i),rgba:Ce.toRgba(i,i,i)})}return e})()),It=ge.toColor("#ffffff"),Bs=ge.toColor("#000000"),la=ge.toColor("#ffffff"),ca=Bs,ks={css:"rgba(255, 255, 255, 0.3)",rgba:4294967117},y_=It,Zr=class extends re{constructor(e){super(),this._optionsService=e,this._contrastCache=new aa,this._halfContrastCache=new aa,this._onChangeColors=this._register(new T),this.onChangeColors=this._onChangeColors.event,this._colors={foreground:It,background:Bs,cursor:la,cursorAccent:ca,selectionForeground:void 0,selectionBackgroundTransparent:ks,selectionBackgroundOpaque:pe.blend(Bs,ks),selectionInactiveBackgroundTransparent:ks,selectionInactiveBackgroundOpaque:pe.blend(Bs,ks),scrollbarSliderBackground:pe.opacity(It,.2),scrollbarSliderHoverBackground:pe.opacity(It,.4),scrollbarSliderActiveBackground:pe.opacity(It,.5),overviewRulerBorder:It,ansi:ke.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)))}get colors(){return this._colors}_setTheme(e={}){let t=this._colors;if(t.foreground=de(e.foreground,It),t.background=de(e.background,Bs),t.cursor=pe.blend(t.background,de(e.cursor,la)),t.cursorAccent=pe.blend(t.background,de(e.cursorAccent,ca)),t.selectionBackgroundTransparent=de(e.selectionBackground,ks),t.selectionBackgroundOpaque=pe.blend(t.background,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundTransparent=de(e.selectionInactiveBackground,t.selectionBackgroundTransparent),t.selectionInactiveBackgroundOpaque=pe.blend(t.background,t.selectionInactiveBackgroundTransparent),t.selectionForeground=e.selectionForeground?de(e.selectionForeground,sa):void 0,t.selectionForeground===sa&&(t.selectionForeground=void 0),pe.isOpaque(t.selectionBackgroundTransparent)&&(t.selectionBackgroundTransparent=pe.opacity(t.selectionBackgroundTransparent,.3)),pe.isOpaque(t.selectionInactiveBackgroundTransparent)&&(t.selectionInactiveBackgroundTransparent=pe.opacity(t.selectionInactiveBackgroundTransparent,.3)),t.scrollbarSliderBackground=de(e.scrollbarSliderBackground,pe.opacity(t.foreground,.2)),t.scrollbarSliderHoverBackground=de(e.scrollbarSliderHoverBackground,pe.opacity(t.foreground,.4)),t.scrollbarSliderActiveBackground=de(e.scrollbarSliderActiveBackground,pe.opacity(t.foreground,.5)),t.overviewRulerBorder=de(e.overviewRulerBorder,y_),t.ansi=ke.slice(),t.ansi[0]=de(e.black,ke[0]),t.ansi[1]=de(e.red,ke[1]),t.ansi[2]=de(e.green,ke[2]),t.ansi[3]=de(e.yellow,ke[3]),t.ansi[4]=de(e.blue,ke[4]),t.ansi[5]=de(e.magenta,ke[5]),t.ansi[6]=de(e.cyan,ke[6]),t.ansi[7]=de(e.white,ke[7]),t.ansi[8]=de(e.brightBlack,ke[8]),t.ansi[9]=de(e.brightRed,ke[9]),t.ansi[10]=de(e.brightGreen,ke[10]),t.ansi[11]=de(e.brightYellow,ke[11]),t.ansi[12]=de(e.brightBlue,ke[12]),t.ansi[13]=de(e.brightMagenta,ke[13]),t.ansi[14]=de(e.brightCyan,ke[14]),t.ansi[15]=de(e.brightWhite,ke[15]),e.extendedAnsi){let s=Math.min(t.ansi.length-16,e.extendedAnsi.length);for(let i=0;i<s;i++)t.ansi[i+16]=de(e.extendedAnsi[i],ke[i+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){for(let t=0;t<this._restoreColors.ansi.length;++t)this._colors.ansi[t]=this._restoreColors.ansi[t];return}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]}}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()}}};Zr=be([H(0,He)],Zr);function de(e,t){if(e!==void 0)try{return ge.toColor(e)}catch{}return t}var S_=class{constructor(...e){this._entries=new Map;for(let[t,s]of e)this.set(t,s)}set(e,t){let s=this._entries.get(e);return this._entries.set(e,t),s}forEach(e){for(let[t,s]of this._entries.entries())e(t,s)}has(e){return this._entries.has(e)}get(e){return this._entries.get(e)}},w_=class{constructor(){this._services=new S_,this._services.set(wn,this)}setService(e,t){this._services.set(e,t)}getService(e){return this._services.get(e)}createInstance(e,...t){let s=mf(e).sort((n,a)=>n.index-a.index),i=[];for(let n of s){let a=this._services.get(n.id);if(!a)throw new Error(`[createInstance] ${e.name} depends on UNKNOWN service ${n.id._id}.`);i.push(a)}let r=s.length>0?s[0].index:t.length;if(t.length!==r)throw new Error(`[createInstance] First service dependency of ${e.name} at position ${r+1} conflicts with ${t.length} static arguments`);return new e(...t,...i)}},C_={trace:0,debug:1,info:2,warn:3,error:4,off:5},k_="xterm.js: ",Qr=class extends re{constructor(e){super(),this._optionsService=e,this._logLevel=5,this._updateLogLevel(),this._register(this._optionsService.onSpecificOptionChange("logLevel",()=>this._updateLogLevel()))}get logLevel(){return this._logLevel}_updateLogLevel(){this._logLevel=C_[this._optionsService.rawOptions.logLevel]}_evalLazyOptionalParams(e){for(let t=0;t<e.length;t++)typeof e[t]=="function"&&(e[t]=e[t]())}_log(e,t,s){this._evalLazyOptionalParams(s),e.call(console,(this._optionsService.options.logger?"":k_)+t,...s)}trace(e,...t){var s;this._logLevel<=0&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.trace.bind(this._optionsService.options.logger))??console.log,e,t)}debug(e,...t){var s;this._logLevel<=1&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.debug.bind(this._optionsService.options.logger))??console.log,e,t)}info(e,...t){var s;this._logLevel<=2&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.info.bind(this._optionsService.options.logger))??console.info,e,t)}warn(e,...t){var s;this._logLevel<=3&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.warn.bind(this._optionsService.options.logger))??console.warn,e,t)}error(e,...t){var s;this._logLevel<=4&&this._log(((s=this._optionsService.options.logger)==null?void 0:s.error.bind(this._optionsService.options.logger))??console.error,e,t)}};Qr=be([H(0,He)],Qr);var ha=class extends re{constructor(e){super(),this._maxLength=e,this.onDeleteEmitter=this._register(new T),this.onDelete=this.onDeleteEmitter.event,this.onInsertEmitter=this._register(new T),this.onInsert=this.onInsertEmitter.event,this.onTrimEmitter=this._register(new T),this.onTrim=this.onTrimEmitter.event,this._array=new Array(this._maxLength),this._startIndex=0,this._length=0}get maxLength(){return this._maxLength}set maxLength(e){if(this._maxLength===e)return;let t=new Array(e);for(let s=0;s<Math.min(e,this.length);s++)t[s]=this._array[this._getCyclicIndex(s)];this._array=t,this._maxLength=e,this._startIndex=0}get length(){return this._length}set length(e){if(e>this._length)for(let t=this._length;t<e;t++)this._array[t]=void 0;this._length=e}get(e){return this._array[this._getCyclicIndex(e)]}set(e,t){this._array[this._getCyclicIndex(e)]=t}push(e){this._array[this._getCyclicIndex(this._length)]=e,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(e,t,...s){if(t){for(let i=e;i<this._length-t;i++)this._array[this._getCyclicIndex(i)]=this._array[this._getCyclicIndex(i+t)];this._length-=t,this.onDeleteEmitter.fire({index:e,amount:t})}for(let i=this._length-1;i>=e;i--)this._array[this._getCyclicIndex(i+s.length)]=this._array[this._getCyclicIndex(i)];for(let i=0;i<s.length;i++)this._array[this._getCyclicIndex(e+i)]=s[i];if(s.length&&this.onInsertEmitter.fire({index:e,amount:s.length}),this._length+s.length>this._maxLength){let i=this._length+s.length-this._maxLength;this._startIndex+=i,this._length=this._maxLength,this.onTrimEmitter.fire(i)}else this._length+=s.length}trimStart(e){e>this._length&&(e=this._length),this._startIndex+=e,this._length-=e,this.onTrimEmitter.fire(e)}shiftElements(e,t,s){if(!(t<=0)){if(e<0||e>=this._length)throw new Error("start argument out of range");if(e+s<0)throw new Error("Cannot shift elements in list beyond index 0");if(s>0){for(let r=t-1;r>=0;r--)this.set(e+r+s,this.get(e+r));let i=e+t+s-this._length;if(i>0)for(this._length+=i;this._length>this._maxLength;)this._length--,this._startIndex++,this.onTrimEmitter.fire(1)}else for(let i=0;i<t;i++)this.set(e+i+s,this.get(e+i))}}_getCyclicIndex(e){return(this._startIndex+e)%this._maxLength}},ie=3,Se=Object.freeze(new Ys),mi=0,cr=2,zs=class ac{constructor(t,s,i=!1){this.isWrapped=i,this._combined={},this._extendedAttrs={},this._data=new Uint32Array(t*ie);let r=s||st.fromCharData([0,El,1,0]);for(let n=0;n<t;++n)this.setCell(n,r);this.length=t}get(t){let s=this._data[t*ie+0],i=s&2097151;return[this._data[t*ie+1],s&2097152?this._combined[t]:i?Et(i):"",s>>22,s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):i]}set(t,s){this._data[t*ie+1]=s[0],s[1].length>1?(this._combined[t]=s[1],this._data[t*ie+0]=t|2097152|s[2]<<22):this._data[t*ie+0]=s[1].charCodeAt(0)|s[2]<<22}getWidth(t){return this._data[t*ie+0]>>22}hasWidth(t){return this._data[t*ie+0]&12582912}getFg(t){return this._data[t*ie+1]}getBg(t){return this._data[t*ie+2]}hasContent(t){return this._data[t*ie+0]&4194303}getCodePoint(t){let s=this._data[t*ie+0];return s&2097152?this._combined[t].charCodeAt(this._combined[t].length-1):s&2097151}isCombined(t){return this._data[t*ie+0]&2097152}getString(t){let s=this._data[t*ie+0];return s&2097152?this._combined[t]:s&2097151?Et(s&2097151):""}isProtected(t){return this._data[t*ie+2]&536870912}loadCell(t,s){return mi=t*ie,s.content=this._data[mi+0],s.fg=this._data[mi+1],s.bg=this._data[mi+2],s.content&2097152&&(s.combinedData=this._combined[t]),s.bg&268435456&&(s.extended=this._extendedAttrs[t]),s}setCell(t,s){s.content&2097152&&(this._combined[t]=s.combinedData),s.bg&268435456&&(this._extendedAttrs[t]=s.extended),this._data[t*ie+0]=s.content,this._data[t*ie+1]=s.fg,this._data[t*ie+2]=s.bg}setCellFromCodepoint(t,s,i,r){r.bg&268435456&&(this._extendedAttrs[t]=r.extended),this._data[t*ie+0]=s|i<<22,this._data[t*ie+1]=r.fg,this._data[t*ie+2]=r.bg}addCodepointToCell(t,s,i){let r=this._data[t*ie+0];r&2097152?this._combined[t]+=Et(s):r&2097151?(this._combined[t]=Et(r&2097151)+Et(s),r&=-2097152,r|=2097152):r=s|1<<22,i&&(r&=-12582913,r|=i<<22),this._data[t*ie+0]=r}insertCells(t,s,i){if(t%=this.length,t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length-t){let r=new st;for(let n=this.length-t-s-1;n>=0;--n)this.setCell(t+s+n,this.loadCell(t+n,r));for(let n=0;n<s;++n)this.setCell(t+n,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);this.getWidth(this.length-1)===2&&this.setCellFromCodepoint(this.length-1,0,1,i)}deleteCells(t,s,i){if(t%=this.length,s<this.length-t){let r=new st;for(let n=0;n<this.length-t-s;++n)this.setCell(t+n,this.loadCell(t+s+n,r));for(let n=this.length-s;n<this.length;++n)this.setCell(n,i)}else for(let r=t;r<this.length;++r)this.setCell(r,i);t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),this.getWidth(t)===0&&!this.hasContent(t)&&this.setCellFromCodepoint(t,0,1,i)}replaceCells(t,s,i,r=!1){if(r){for(t&&this.getWidth(t-1)===2&&!this.isProtected(t-1)&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&!this.isProtected(s)&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.isProtected(t)||this.setCell(t,i),t++;return}for(t&&this.getWidth(t-1)===2&&this.setCellFromCodepoint(t-1,0,1,i),s<this.length&&this.getWidth(s-1)===2&&this.setCellFromCodepoint(s,0,1,i);t<s&&t<this.length;)this.setCell(t++,i)}resize(t,s){if(t===this.length)return this._data.length*4*cr<this._data.buffer.byteLength;let i=t*ie;if(t>this.length){if(this._data.buffer.byteLength>=i*4)this._data=new Uint32Array(this._data.buffer,0,i);else{let r=new Uint32Array(i);r.set(this._data),this._data=r}for(let r=this.length;r<t;++r)this.setCell(r,s)}else{this._data=this._data.subarray(0,i);let r=Object.keys(this._combined);for(let a=0;a<r.length;a++){let l=parseInt(r[a],10);l>=t&&delete this._combined[l]}let n=Object.keys(this._extendedAttrs);for(let a=0;a<n.length;a++){let l=parseInt(n[a],10);l>=t&&delete this._extendedAttrs[l]}}return this.length=t,i*4*cr<this._data.buffer.byteLength}cleanupMemory(){if(this._data.length*4*cr<this._data.buffer.byteLength){let t=new Uint32Array(this._data.length);return t.set(this._data),this._data=t,1}return 0}fill(t,s=!1){if(s){for(let i=0;i<this.length;++i)this.isProtected(i)||this.setCell(i,t);return}this._combined={},this._extendedAttrs={};for(let i=0;i<this.length;++i)this.setCell(i,t)}copyFrom(t){this.length!==t.length?this._data=new Uint32Array(t._data):this._data.set(t._data),this.length=t.length,this._combined={};for(let s in t._combined)this._combined[s]=t._combined[s];this._extendedAttrs={};for(let s in t._extendedAttrs)this._extendedAttrs[s]=t._extendedAttrs[s];this.isWrapped=t.isWrapped}clone(){let t=new ac(0);t._data=new Uint32Array(this._data),t.length=this.length;for(let s in this._combined)t._combined[s]=this._combined[s];for(let s in this._extendedAttrs)t._extendedAttrs[s]=this._extendedAttrs[s];return t.isWrapped=this.isWrapped,t}getTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ie+0]&4194303)return t+(this._data[t*ie+0]>>22);return 0}getNoBgTrimmedLength(){for(let t=this.length-1;t>=0;--t)if(this._data[t*ie+0]&4194303||this._data[t*ie+2]&50331648)return t+(this._data[t*ie+0]>>22);return 0}copyCellsFrom(t,s,i,r,n){let a=t._data;if(n)for(let h=r-1;h>=0;h--){for(let c=0;c<ie;c++)this._data[(i+h)*ie+c]=a[(s+h)*ie+c];a[(s+h)*ie+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}else for(let h=0;h<r;h++){for(let c=0;c<ie;c++)this._data[(i+h)*ie+c]=a[(s+h)*ie+c];a[(s+h)*ie+2]&268435456&&(this._extendedAttrs[i+h]=t._extendedAttrs[s+h])}let l=Object.keys(t._combined);for(let h=0;h<l.length;h++){let c=parseInt(l[h],10);c>=s&&(this._combined[c-s+i]=t._combined[c])}}translateToString(t,s,i,r){s=s??0,i=i??this.length,t&&(i=Math.min(i,this.getTrimmedLength())),r&&(r.length=0);let n="";for(;s<i;){let a=this._data[s*ie+0],l=a&2097151,h=a&2097152?this._combined[s]:l?Et(l):jt;if(n+=h,r)for(let c=0;c<h.length;++c)r.push(s);s+=a>>22||1}return r&&r.push(s),n}};function E_(e,t,s,i,r,n){let a=[];for(let l=0;l<e.length-1;l++){let h=l,c=e.get(++h);if(!c.isWrapped)continue;let d=[e.get(l)];for(;h<e.length&&c.isWrapped;)d.push(c),c=e.get(++h);if(!n&&i>=l&&i<h){l+=d.length-1;continue}let f=0,u=qs(d,f,t),g=1,p=0;for(;g<d.length;){let y=qs(d,g,t),x=y-p,b=s-u,j=Math.min(x,b);d[f].copyCellsFrom(d[g],p,u,j,!1),u+=j,u===s&&(f++,u=0),p+=j,p===y&&(g++,p=0),u===0&&f!==0&&d[f-1].getWidth(s-1)===2&&(d[f].copyCellsFrom(d[f-1],s-1,u++,1,!1),d[f-1].setCell(s-1,r))}d[f].replaceCells(u,s,r);let m=0;for(let y=d.length-1;y>0&&(y>f||d[y].getTrimmedLength()===0);y--)m++;m>0&&(a.push(l+d.length-m),a.push(m)),l+=d.length-1}return a}function N_(e,t){let s=[],i=0,r=t[i],n=0;for(let a=0;a<e.length;a++)if(r===a){let l=t[++i];e.onDeleteEmitter.fire({index:a-n,amount:l}),a+=l-1,n+=l,r=t[++i]}else s.push(a);return{layout:s,countRemoved:n}}function j_(e,t){let s=[];for(let i=0;i<t.length;i++)s.push(e.get(t[i]));for(let i=0;i<s.length;i++)e.set(i,s[i]);e.length=t.length}function D_(e,t,s){let i=[],r=e.map((h,c)=>qs(e,c,t)).reduce((h,c)=>h+c),n=0,a=0,l=0;for(;l<r;){if(r-l<s){i.push(r-l);break}n+=s;let h=qs(e,a,t);n>h&&(n-=h,a++);let c=e[a].getWidth(n-1)===2;c&&n--;let d=c?s-1:s;i.push(d),l+=d}return i}function qs(e,t,s){if(t===e.length-1)return e[t].getTrimmedLength();let i=!e[t].hasContent(s-1)&&e[t].getWidth(s-1)===1,r=e[t+1].getWidth(0)===2;return i&&r?s-1:s}var lc=class cc{constructor(t){this.line=t,this.isDisposed=!1,this._disposables=[],this._id=cc._nextId++,this._onDispose=this.register(new T),this.onDispose=this._onDispose.event}get id(){return this._id}dispose(){this.isDisposed||(this.isDisposed=!0,this.line=-1,this._onDispose.fire(),Vt(this._disposables),this._disposables.length=0)}register(t){return this._disposables.push(t),t}};lc._nextId=1;var M_=lc,Ne={},$t=Ne.B;Ne[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:"≥","{":"π","|":"≠","}":"£","~":"·"};Ne.A={"#":"£"};Ne.B=void 0;Ne[4]={"#":"£","@":"¾","[":"ij","\\":"½","]":"|","{":"¨","|":"f","}":"¼","~":"´"};Ne.C=Ne[5]={"[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ne.R={"#":"£","@":"à","[":"°","\\":"ç","]":"§","{":"é","|":"ù","}":"è","~":"¨"};Ne.Q={"@":"à","[":"â","\\":"ç","]":"ê","^":"î","`":"ô","{":"é","|":"ù","}":"è","~":"û"};Ne.K={"@":"§","[":"Ä","\\":"Ö","]":"Ü","{":"ä","|":"ö","}":"ü","~":"ß"};Ne.Y={"#":"£","@":"§","[":"°","\\":"ç","]":"é","`":"ù","{":"à","|":"ò","}":"è","~":"ì"};Ne.E=Ne[6]={"@":"Ä","[":"Æ","\\":"Ø","]":"Å","^":"Ü","`":"ä","{":"æ","|":"ø","}":"å","~":"ü"};Ne.Z={"#":"£","@":"§","[":"¡","\\":"Ñ","]":"¿","{":"°","|":"ñ","}":"ç"};Ne.H=Ne[7]={"@":"É","[":"Ä","\\":"Ö","]":"Å","^":"Ü","`":"é","{":"ä","|":"ö","}":"å","~":"ü"};Ne["="]={"#":"ù","@":"à","[":"é","\\":"ç","]":"ê","^":"î",_:"è","`":"ô","{":"ä","|":"ö","}":"ü","~":"û"};var da=4294967295,ua=class{constructor(e,t,s){this._hasScrollback=e,this._optionsService=t,this._bufferService=s,this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.tabs={},this.savedY=0,this.savedX=0,this.savedCurAttrData=Se.clone(),this.savedCharset=$t,this.markers=[],this._nullCell=st.fromCharData([0,El,1,0]),this._whitespaceCell=st.fromCharData([0,jt,1,32]),this._isClearing=!1,this._memoryCleanupQueue=new zi,this._memoryCleanupPosition=0,this._cols=this._bufferService.cols,this._rows=this._bufferService.rows,this.lines=new ha(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}getNullCell(e){return e?(this._nullCell.fg=e.fg,this._nullCell.bg=e.bg,this._nullCell.extended=e.extended):(this._nullCell.fg=0,this._nullCell.bg=0,this._nullCell.extended=new Pi),this._nullCell}getWhitespaceCell(e){return e?(this._whitespaceCell.fg=e.fg,this._whitespaceCell.bg=e.bg,this._whitespaceCell.extended=e.extended):(this._whitespaceCell.fg=0,this._whitespaceCell.bg=0,this._whitespaceCell.extended=new Pi),this._whitespaceCell}getBlankLine(e,t){return new zs(this._bufferService.cols,this.getNullCell(e),t)}get hasScrollback(){return this._hasScrollback&&this.lines.maxLength>this._rows}get isCursorInViewport(){let e=this.ybase+this.y-this.ydisp;return e>=0&&e<this._rows}_getCorrectBufferLength(e){if(!this._hasScrollback)return e;let t=e+this._optionsService.rawOptions.scrollback;return t>da?da:t}fillViewportRows(e){if(this.lines.length===0){e===void 0&&(e=Se);let t=this._rows;for(;t--;)this.lines.push(this.getBlankLine(e))}}clear(){this.ydisp=0,this.ybase=0,this.y=0,this.x=0,this.lines=new ha(this._getCorrectBufferLength(this._rows)),this.scrollTop=0,this.scrollBottom=this._rows-1,this.setupTabStops()}resize(e,t){let s=this.getNullCell(Se),i=0,r=this._getCorrectBufferLength(t);if(r>this.lines.maxLength&&(this.lines.maxLength=r),this.lines.length>0){if(this._cols<e)for(let a=0;a<this.lines.length;a++)i+=+this.lines.get(a).resize(e,s);let n=0;if(this._rows<t)for(let a=this._rows;a<t;a++)this.lines.length<t+this.ybase&&(this._optionsService.rawOptions.windowsMode||this._optionsService.rawOptions.windowsPty.backend!==void 0||this._optionsService.rawOptions.windowsPty.buildNumber!==void 0?this.lines.push(new zs(e,s)):this.ybase>0&&this.lines.length<=this.ybase+this.y+n+1?(this.ybase--,n++,this.ydisp>0&&this.ydisp--):this.lines.push(new zs(e,s)));else for(let a=this._rows;a>t;a--)this.lines.length>t+this.ybase&&(this.lines.length>this.ybase+this.y+1?this.lines.pop():(this.ybase++,this.ydisp++));if(r<this.lines.maxLength){let a=this.lines.length-r;a>0&&(this.lines.trimStart(a),this.ybase=Math.max(this.ybase-a,0),this.ydisp=Math.max(this.ydisp-a,0),this.savedY=Math.max(this.savedY-a,0)),this.lines.maxLength=r}this.x=Math.min(this.x,e-1),this.y=Math.min(this.y,t-1),n&&(this.y+=n),this.savedX=Math.min(this.savedX,e-1),this.scrollTop=0}if(this.scrollBottom=t-1,this._isReflowEnabled&&(this._reflow(e,t),this._cols>e))for(let n=0;n<this.lines.length;n++)i+=+this.lines.get(n).resize(e,s);this._cols=e,this._rows=t,this._memoryCleanupQueue.clear(),i>.1*this.lines.length&&(this._memoryCleanupPosition=0,this._memoryCleanupQueue.enqueue(()=>this._batchedMemoryCleanup()))}_batchedMemoryCleanup(){let e=!0;this._memoryCleanupPosition>=this.lines.length&&(this._memoryCleanupPosition=0,e=!1);let t=0;for(;this._memoryCleanupPosition<this.lines.length;)if(t+=this.lines.get(this._memoryCleanupPosition++).cleanupMemory(),t>100)return!0;return e}get _isReflowEnabled(){let e=this._optionsService.rawOptions.windowsPty;return e&&e.buildNumber?this._hasScrollback&&e.backend==="conpty"&&e.buildNumber>=21376:this._hasScrollback&&!this._optionsService.rawOptions.windowsMode}_reflow(e,t){this._cols!==e&&(e>this._cols?this._reflowLarger(e,t):this._reflowSmaller(e,t))}_reflowLarger(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=E_(this.lines,this._cols,e,this.ybase+this.y,this.getNullCell(Se),s);if(i.length>0){let r=N_(this.lines,i);j_(this.lines,r.layout),this._reflowLargerAdjustViewport(e,t,r.countRemoved)}}_reflowLargerAdjustViewport(e,t,s){let i=this.getNullCell(Se),r=s;for(;r-- >0;)this.ybase===0?(this.y>0&&this.y--,this.lines.length<t&&this.lines.push(new zs(e,i))):(this.ydisp===this.ybase&&this.ydisp--,this.ybase--);this.savedY=Math.max(this.savedY-s,0)}_reflowSmaller(e,t){let s=this._optionsService.rawOptions.reflowCursorLine,i=this.getNullCell(Se),r=[],n=0;for(let a=this.lines.length-1;a>=0;a--){let l=this.lines.get(a);if(!l||!l.isWrapped&&l.getTrimmedLength()<=e)continue;let h=[l];for(;l.isWrapped&&a>0;)l=this.lines.get(--a),h.unshift(l);if(!s){let j=this.ybase+this.y;if(j>=a&&j<a+h.length)continue}let c=h[h.length-1].getTrimmedLength(),d=D_(h,this._cols,e),f=d.length-h.length,u;this.ybase===0&&this.y!==this.lines.length-1?u=Math.max(0,this.y-this.lines.maxLength+f):u=Math.max(0,this.lines.length-this.lines.maxLength+f);let g=[];for(let j=0;j<f;j++){let k=this.getBlankLine(Se,!0);g.push(k)}g.length>0&&(r.push({start:a+h.length+n,newLines:g}),n+=g.length),h.push(...g);let p=d.length-1,m=d[p];m===0&&(p--,m=d[p]);let y=h.length-f-1,x=c;for(;y>=0;){let j=Math.min(x,m);if(h[p]===void 0)break;if(h[p].copyCellsFrom(h[y],x-j,m-j,j,!0),m-=j,m===0&&(p--,m=d[p]),x-=j,x===0){y--;let k=Math.max(y,0);x=qs(h,k,this._cols)}}for(let j=0;j<h.length;j++)d[j]<e&&h[j].setCell(d[j],i);let b=f-u;for(;b-- >0;)this.ybase===0?this.y<t-1?(this.y++,this.lines.pop()):(this.ybase++,this.ydisp++):this.ybase<Math.min(this.lines.maxLength,this.lines.length+n)-t&&(this.ybase===this.ydisp&&this.ydisp++,this.ybase++);this.savedY=Math.min(this.savedY+f,this.ybase+t-1)}if(r.length>0){let a=[],l=[];for(let m=0;m<this.lines.length;m++)l.push(this.lines.get(m));let h=this.lines.length,c=h-1,d=0,f=r[d];this.lines.length=Math.min(this.lines.maxLength,this.lines.length+n);let u=0;for(let m=Math.min(this.lines.maxLength-1,h+n-1);m>=0;m--)if(f&&f.start>c+u){for(let y=f.newLines.length-1;y>=0;y--)this.lines.set(m--,f.newLines[y]);m++,a.push({index:c+1,amount:f.newLines.length}),u+=f.newLines.length,f=r[++d]}else this.lines.set(m,l[c--]);let g=0;for(let m=a.length-1;m>=0;m--)a[m].index+=g,this.lines.onInsertEmitter.fire(a[m]),g+=a[m].amount;let p=Math.max(0,h+n-this.lines.maxLength);p>0&&this.lines.onTrimEmitter.fire(p)}}translateBufferLineToString(e,t,s=0,i){let r=this.lines.get(e);return r?r.translateToString(t,s,i):""}getWrappedRangeForLine(e){let t=e,s=e;for(;t>0&&this.lines.get(t).isWrapped;)t--;for(;s+1<this.lines.length&&this.lines.get(s+1).isWrapped;)s++;return{first:t,last:s}}setupTabStops(e){for(e!=null?this.tabs[e]||(e=this.prevStop(e)):(this.tabs={},e=0);e<this._cols;e+=this._optionsService.rawOptions.tabStopWidth)this.tabs[e]=!0}prevStop(e){for(e==null&&(e=this.x);!this.tabs[--e]&&e>0;);return e>=this._cols?this._cols-1:e<0?0:e}nextStop(e){for(e==null&&(e=this.x);!this.tabs[++e]&&e<this._cols;);return e>=this._cols?this._cols-1:e<0?0:e}clearMarkers(e){this._isClearing=!0;for(let t=0;t<this.markers.length;t++)this.markers[t].line===e&&(this.markers[t].dispose(),this.markers.splice(t--,1));this._isClearing=!1}clearAllMarkers(){this._isClearing=!0;for(let e=0;e<this.markers.length;e++)this.markers[e].dispose();this.markers.length=0,this._isClearing=!1}addMarker(e){let t=new M_(e);return this.markers.push(t),t.register(this.lines.onTrim(s=>{t.line-=s,t.line<0&&t.dispose()})),t.register(this.lines.onInsert(s=>{t.line>=s.index&&(t.line+=s.amount)})),t.register(this.lines.onDelete(s=>{t.line>=s.index&&t.line<s.index+s.amount&&t.dispose(),t.line>s.index&&(t.line-=s.amount)})),t.register(t.onDispose(()=>this._removeMarker(t))),t}_removeMarker(e){this._isClearing||this.markers.splice(this.markers.indexOf(e),1)}},P_=class extends re{constructor(e,t){super(),this._optionsService=e,this._bufferService=t,this._onBufferActivate=this._register(new T),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 ua(!0,this._optionsService,this._bufferService),this._normal.fillViewportRows(),this._alt=new ua(!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(e){this._activeBuffer!==this._alt&&(this._alt.fillViewportRows(e),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(e,t){this._normal.resize(e,t),this._alt.resize(e,t),this.setupTabStops(e)}setupTabStops(e){this._normal.setupTabStops(e),this._alt.setupTabStops(e)}},hc=2,dc=1,en=class extends re{constructor(e){super(),this.isUserScrolling=!1,this._onResize=this._register(new T),this.onResize=this._onResize.event,this._onScroll=this._register(new T),this.onScroll=this._onScroll.event,this.cols=Math.max(e.rawOptions.cols||0,hc),this.rows=Math.max(e.rawOptions.rows||0,dc),this.buffers=this._register(new P_(e,this)),this._register(this.buffers.onBufferActivate(t=>{this._onScroll.fire(t.activeBuffer.ydisp)}))}get buffer(){return this.buffers.active}resize(e,t){let s=this.cols!==e,i=this.rows!==t;this.cols=e,this.rows=t,this.buffers.resize(e,t),this._onResize.fire({cols:e,rows:t,colsChanged:s,rowsChanged:i})}reset(){this.buffers.reset(),this.isUserScrolling=!1}scroll(e,t=!1){let s=this.buffer,i;i=this._cachedBlankLine,(!i||i.length!==this.cols||i.getFg(0)!==e.fg||i.getBg(0)!==e.bg)&&(i=s.getBlankLine(e,t),this._cachedBlankLine=i),i.isWrapped=t;let r=s.ybase+s.scrollTop,n=s.ybase+s.scrollBottom;if(s.scrollTop===0){let a=s.lines.isFull;n===s.lines.length-1?a?s.lines.recycle().copyFrom(i):s.lines.push(i.clone()):s.lines.splice(n+1,0,i.clone()),a?this.isUserScrolling&&(s.ydisp=Math.max(s.ydisp-1,0)):(s.ybase++,this.isUserScrolling||s.ydisp++)}else{let a=n-r+1;s.lines.shiftElements(r+1,a-1,-1),s.lines.set(n,i.clone())}this.isUserScrolling||(s.ydisp=s.ybase),this._onScroll.fire(s.ydisp)}scrollLines(e,t){let s=this.buffer;if(e<0){if(s.ydisp===0)return;this.isUserScrolling=!0}else e+s.ydisp>=s.ybase&&(this.isUserScrolling=!1);let i=s.ydisp;s.ydisp=Math.max(Math.min(s.ydisp+e,s.ybase),0),i!==s.ydisp&&(t||this._onScroll.fire(s.ydisp))}};en=be([H(0,He)],en);var is={cols:80,rows:24,cursorBlink:!1,cursorStyle:"block",cursorWidth:1,cursorInactiveStyle:"outline",customGlyphs:!0,drawBoldTextInBrightColors:!0,documentOverride:null,fastScrollModifier:"alt",fastScrollSensitivity:5,fontFamily:"monospace",fontSize:15,fontWeight:"normal",fontWeightBold:"bold",ignoreBracketedPasteMode:!1,lineHeight:1,letterSpacing:0,linkHandler:null,logLevel:"info",logger:null,scrollback:1e3,scrollOnEraseInDisplay:!1,scrollOnUserInput:!0,scrollSensitivity:1,screenReaderMode:!1,smoothScrollDuration:0,macOptionIsMeta:!1,macOptionClickForcesSelection:!1,minimumContrastRatio:1,disableStdin:!1,allowProposedApi:!1,allowTransparency:!1,tabStopWidth:8,theme:{},reflowCursorLine:!1,rescaleOverlappingGlyphs:!1,rightClickSelectsWord:Bi,windowOptions:{},windowsMode:!1,windowsPty:{},wordSeparator:" ()[]{}',\"`",altClickMovesCursor:!0,convertEol:!1,termName:"xterm",cancelEvents:!1,overviewRuler:{}},R_=["normal","bold","100","200","300","400","500","600","700","800","900"],L_=class extends re{constructor(e){super(),this._onOptionChange=this._register(new T),this.onOptionChange=this._onOptionChange.event;let t={...is};for(let s in e)if(s in t)try{let i=e[s];t[s]=this._sanitizeAndValidateOption(s,i)}catch(i){console.error(i)}this.rawOptions=t,this.options={...t},this._setupOptions(),this._register(_e(()=>{this.rawOptions.linkHandler=null,this.rawOptions.documentOverride=null}))}onSpecificOptionChange(e,t){return this.onOptionChange(s=>{s===e&&t(this.rawOptions[e])})}onMultipleOptionChange(e,t){return this.onOptionChange(s=>{e.indexOf(s)!==-1&&t()})}_setupOptions(){let e=s=>{if(!(s in is))throw new Error(`No option with key "${s}"`);return this.rawOptions[s]},t=(s,i)=>{if(!(s in is))throw new Error(`No option with key "${s}"`);i=this._sanitizeAndValidateOption(s,i),this.rawOptions[s]!==i&&(this.rawOptions[s]=i,this._onOptionChange.fire(s))};for(let s in this.rawOptions){let i={get:e.bind(this,s),set:t.bind(this,s)};Object.defineProperty(this.options,s,i)}}_sanitizeAndValidateOption(e,t){switch(e){case"cursorStyle":if(t||(t=is[e]),!B_(t))throw new Error(`"${t}" is not a valid value for ${e}`);break;case"wordSeparator":t||(t=is[e]);break;case"fontWeight":case"fontWeightBold":if(typeof t=="number"&&1<=t&&t<=1e3)break;t=R_.includes(t)?t:is[e];break;case"cursorWidth":t=Math.floor(t);case"lineHeight":case"tabStopWidth":if(t<1)throw new Error(`${e} cannot be less than 1, value: ${t}`);break;case"minimumContrastRatio":t=Math.max(1,Math.min(21,Math.round(t*10)/10));break;case"scrollback":if(t=Math.min(t,4294967295),t<0)throw new Error(`${e} cannot be less than 0, value: ${t}`);break;case"fastScrollSensitivity":case"scrollSensitivity":if(t<=0)throw new Error(`${e} cannot be less than or equal to 0, value: ${t}`);break;case"rows":case"cols":if(!t&&t!==0)throw new Error(`${e} must be numeric, value: ${t}`);break;case"windowsPty":t=t??{};break}return t}};function B_(e){return e==="block"||e==="underline"||e==="bar"}function Ts(e,t=5){if(typeof e!="object")return e;let s=Array.isArray(e)?[]:{};for(let i in e)s[i]=t<=1?e[i]:e[i]&&Ts(e[i],t-1);return s}var fa=Object.freeze({insertMode:!1}),pa=Object.freeze({applicationCursorKeys:!1,applicationKeypad:!1,bracketedPasteMode:!1,cursorBlink:void 0,cursorStyle:void 0,origin:!1,reverseWraparound:!1,sendFocus:!1,synchronizedOutput:!1,wraparound:!0}),tn=class extends re{constructor(e,t,s){super(),this._bufferService=e,this._logService=t,this._optionsService=s,this.isCursorInitialized=!1,this.isCursorHidden=!1,this._onData=this._register(new T),this.onData=this._onData.event,this._onUserInput=this._register(new T),this.onUserInput=this._onUserInput.event,this._onBinary=this._register(new T),this.onBinary=this._onBinary.event,this._onRequestScrollToBottom=this._register(new T),this.onRequestScrollToBottom=this._onRequestScrollToBottom.event,this.modes=Ts(fa),this.decPrivateModes=Ts(pa)}reset(){this.modes=Ts(fa),this.decPrivateModes=Ts(pa)}triggerDataEvent(e,t=!1){if(this._optionsService.rawOptions.disableStdin)return;let s=this._bufferService.buffer;t&&this._optionsService.rawOptions.scrollOnUserInput&&s.ybase!==s.ydisp&&this._onRequestScrollToBottom.fire(),t&&this._onUserInput.fire(),this._logService.debug(`sending data "${e}"`),this._logService.trace("sending data (codes)",()=>e.split("").map(i=>i.charCodeAt(0))),this._onData.fire(e)}triggerBinaryEvent(e){this._optionsService.rawOptions.disableStdin||(this._logService.debug(`sending binary "${e}"`),this._logService.trace("sending binary (codes)",()=>e.split("").map(t=>t.charCodeAt(0))),this._onBinary.fire(e))}};tn=be([H(0,Fe),H(1,Pl),H(2,He)],tn);var _a={NONE:{events:0,restrict:()=>!1},X10:{events:1,restrict:e=>e.button===4||e.action!==1?!1:(e.ctrl=!1,e.alt=!1,e.shift=!1,!0)},VT200:{events:19,restrict:e=>e.action!==32},DRAG:{events:23,restrict:e=>!(e.action===32&&e.button===3)},ANY:{events:31,restrict:e=>!0}};function hr(e,t){let s=(e.ctrl?16:0)|(e.shift?4:0)|(e.alt?8:0);return e.button===4?(s|=64,s|=e.action):(s|=e.button&3,e.button&4&&(s|=64),e.button&8&&(s|=128),e.action===32?s|=32:e.action===0&&!t&&(s|=3)),s}var dr=String.fromCharCode,ma={DEFAULT:e=>{let t=[hr(e,!1)+32,e.col+32,e.row+32];return t[0]>255||t[1]>255||t[2]>255?"":`\x1B[M${dr(t[0])}${dr(t[1])}${dr(t[2])}`},SGR:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${hr(e,!0)};${e.col};${e.row}${t}`},SGR_PIXELS:e=>{let t=e.action===0&&e.button!==4?"m":"M";return`\x1B[<${hr(e,!0)};${e.x};${e.y}${t}`}},sn=class extends re{constructor(e,t,s){super(),this._bufferService=e,this._coreService=t,this._optionsService=s,this._protocols={},this._encodings={},this._activeProtocol="",this._activeEncoding="",this._lastEvent=null,this._wheelPartialScroll=0,this._onProtocolChange=this._register(new T),this.onProtocolChange=this._onProtocolChange.event;for(let i of Object.keys(_a))this.addProtocol(i,_a[i]);for(let i of Object.keys(ma))this.addEncoding(i,ma[i]);this.reset()}addProtocol(e,t){this._protocols[e]=t}addEncoding(e,t){this._encodings[e]=t}get activeProtocol(){return this._activeProtocol}get areMouseEventsActive(){return this._protocols[this._activeProtocol].events!==0}set activeProtocol(e){if(!this._protocols[e])throw new Error(`unknown protocol "${e}"`);this._activeProtocol=e,this._onProtocolChange.fire(this._protocols[e].events)}get activeEncoding(){return this._activeEncoding}set activeEncoding(e){if(!this._encodings[e])throw new Error(`unknown encoding "${e}"`);this._activeEncoding=e}reset(){this.activeProtocol="NONE",this.activeEncoding="DEFAULT",this._lastEvent=null,this._wheelPartialScroll=0}consumeWheelEvent(e,t,s){if(e.deltaY===0||e.shiftKey||t===void 0||s===void 0)return 0;let i=t/s,r=this._applyScrollModifier(e.deltaY,e);return e.deltaMode===WheelEvent.DOM_DELTA_PIXEL?(r/=i+0,Math.abs(e.deltaY)<50&&(r*=.3),this._wheelPartialScroll+=r,r=Math.floor(Math.abs(this._wheelPartialScroll))*(this._wheelPartialScroll>0?1:-1),this._wheelPartialScroll%=1):e.deltaMode===WheelEvent.DOM_DELTA_PAGE&&(r*=this._bufferService.rows),r}_applyScrollModifier(e,t){return t.altKey||t.ctrlKey||t.shiftKey?e*this._optionsService.rawOptions.fastScrollSensitivity*this._optionsService.rawOptions.scrollSensitivity:e*this._optionsService.rawOptions.scrollSensitivity}triggerMouseEvent(e){if(e.col<0||e.col>=this._bufferService.cols||e.row<0||e.row>=this._bufferService.rows||e.button===4&&e.action===32||e.button===3&&e.action!==32||e.button!==4&&(e.action===2||e.action===3)||(e.col++,e.row++,e.action===32&&this._lastEvent&&this._equalEvents(this._lastEvent,e,this._activeEncoding==="SGR_PIXELS"))||!this._protocols[this._activeProtocol].restrict(e))return!1;let t=this._encodings[this._activeEncoding](e);return t&&(this._activeEncoding==="DEFAULT"?this._coreService.triggerBinaryEvent(t):this._coreService.triggerDataEvent(t,!0)),this._lastEvent=e,!0}explainEvents(e){return{down:!!(e&1),up:!!(e&2),drag:!!(e&4),move:!!(e&8),wheel:!!(e&16)}}_equalEvents(e,t,s){if(s){if(e.x!==t.x||e.y!==t.y)return!1}else if(e.col!==t.col||e.row!==t.row)return!1;return!(e.button!==t.button||e.action!==t.action||e.ctrl!==t.ctrl||e.alt!==t.alt||e.shift!==t.shift)}};sn=be([H(0,Fe),H(1,Jt),H(2,He)],sn);var ur=[[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]],z_=[[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]],Ee;function T_(e,t){let s=0,i=t.length-1,r;if(e<t[0][0]||e>t[i][1])return!1;for(;i>=s;)if(r=s+i>>1,e>t[r][1])s=r+1;else if(e<t[r][0])i=r-1;else return!0;return!1}var A_=class{constructor(){if(this.version="6",!Ee){Ee=new Uint8Array(65536),Ee.fill(1),Ee[0]=0,Ee.fill(0,1,32),Ee.fill(0,127,160),Ee.fill(2,4352,4448),Ee[9001]=2,Ee[9002]=2,Ee.fill(2,11904,42192),Ee[12351]=1,Ee.fill(2,44032,55204),Ee.fill(2,63744,64256),Ee.fill(2,65040,65050),Ee.fill(2,65072,65136),Ee.fill(2,65280,65377),Ee.fill(2,65504,65511);for(let e=0;e<ur.length;++e)Ee.fill(0,ur[e][0],ur[e][1]+1)}}wcwidth(e){return e<32?0:e<127?1:e<65536?Ee[e]:T_(e,z_)?0:e>=131072&&e<=196605||e>=196608&&e<=262141?2:1}charProperties(e,t){let s=this.wcwidth(e),i=s===0&&t!==0;if(i){let r=Ft.extractWidth(t);r===0?i=!1:r>s&&(s=r)}return Ft.createPropertyValue(0,s,i)}},Ft=class Ei{constructor(){this._providers=Object.create(null),this._active="",this._onChange=new T,this.onChange=this._onChange.event;let t=new A_;this.register(t),this._active=t.version,this._activeProvider=t}static extractShouldJoin(t){return(t&1)!==0}static extractWidth(t){return t>>1&3}static extractCharKind(t){return t>>3}static createPropertyValue(t,s,i=!1){return(t&16777215)<<3|(s&3)<<1|(i?1:0)}dispose(){this._onChange.dispose()}get versions(){return Object.keys(this._providers)}get activeVersion(){return this._active}set activeVersion(t){if(!this._providers[t])throw new Error(`unknown Unicode version "${t}"`);this._active=t,this._activeProvider=this._providers[t],this._onChange.fire(t)}register(t){this._providers[t.version]=t}wcwidth(t){return this._activeProvider.wcwidth(t)}getStringCellWidth(t){let s=0,i=0,r=t.length;for(let n=0;n<r;++n){let a=t.charCodeAt(n);if(55296<=a&&a<=56319){if(++n>=r)return s+this.wcwidth(a);let c=t.charCodeAt(n);56320<=c&&c<=57343?a=(a-55296)*1024+c-56320+65536:s+=this.wcwidth(c)}let l=this.charProperties(a,i),h=Ei.extractWidth(l);Ei.extractShouldJoin(l)&&(h-=Ei.extractWidth(i)),s+=h,i=l}return s}charProperties(t,s){return this._activeProvider.charProperties(t,s)}},O_=class{constructor(){this.glevel=0,this._charsets=[]}reset(){this.charset=void 0,this._charsets=[],this.glevel=0}setgLevel(e){this.glevel=e,this.charset=this._charsets[e]}setgCharset(e,t){this._charsets[e]=t,this.glevel===e&&(this.charset=t)}};function ga(e){var i;let t=(i=e.buffer.lines.get(e.buffer.ybase+e.buffer.y-1))==null?void 0:i.get(e.cols-1),s=e.buffer.lines.get(e.buffer.ybase+e.buffer.y);s&&t&&(s.isWrapped=t[3]!==0&&t[3]!==32)}var Es=2147483647,I_=256,uc=class rn{constructor(t=32,s=32){if(this.maxLength=t,this.maxSubParamsLength=s,s>I_)throw new Error("maxSubParamsLength must not be greater than 256");this.params=new Int32Array(t),this.length=0,this._subParams=new Int32Array(s),this._subParamsLength=0,this._subParamsIdx=new Uint16Array(t),this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}static fromArray(t){let s=new rn;if(!t.length)return s;for(let i=Array.isArray(t[0])?1:0;i<t.length;++i){let r=t[i];if(Array.isArray(r))for(let n=0;n<r.length;++n)s.addSubParam(r[n]);else s.addParam(r)}return s}clone(){let t=new rn(this.maxLength,this.maxSubParamsLength);return t.params.set(this.params),t.length=this.length,t._subParams.set(this._subParams),t._subParamsLength=this._subParamsLength,t._subParamsIdx.set(this._subParamsIdx),t._rejectDigits=this._rejectDigits,t._rejectSubDigits=this._rejectSubDigits,t._digitIsSub=this._digitIsSub,t}toArray(){let t=[];for(let s=0;s<this.length;++s){t.push(this.params[s]);let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&t.push(Array.prototype.slice.call(this._subParams,i,r))}return t}reset(){this.length=0,this._subParamsLength=0,this._rejectDigits=!1,this._rejectSubDigits=!1,this._digitIsSub=!1}addParam(t){if(this._digitIsSub=!1,this.length>=this.maxLength){this._rejectDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParamsIdx[this.length]=this._subParamsLength<<8|this._subParamsLength,this.params[this.length++]=t>Es?Es:t}addSubParam(t){if(this._digitIsSub=!0,!!this.length){if(this._rejectDigits||this._subParamsLength>=this.maxSubParamsLength){this._rejectSubDigits=!0;return}if(t<-1)throw new Error("values lesser than -1 are not allowed");this._subParams[this._subParamsLength++]=t>Es?Es:t,this._subParamsIdx[this.length-1]++}}hasSubParams(t){return(this._subParamsIdx[t]&255)-(this._subParamsIdx[t]>>8)>0}getSubParams(t){let s=this._subParamsIdx[t]>>8,i=this._subParamsIdx[t]&255;return i-s>0?this._subParams.subarray(s,i):null}getSubParamsAll(){let t={};for(let s=0;s<this.length;++s){let i=this._subParamsIdx[s]>>8,r=this._subParamsIdx[s]&255;r-i>0&&(t[s]=this._subParams.slice(i,r))}return t}addDigit(t){let s;if(this._rejectDigits||!(s=this._digitIsSub?this._subParamsLength:this.length)||this._digitIsSub&&this._rejectSubDigits)return;let i=this._digitIsSub?this._subParams:this.params,r=i[s-1];i[s-1]=~r?Math.min(r*10+t,Es):t}},Ns=[],$_=class{constructor(){this._state=0,this._active=Ns,this._id=-1,this._handlers=Object.create(null),this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=Ns}reset(){if(this._state===2)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].end(!1);this._stack.paused=!1,this._active=Ns,this._id=-1,this._state=0}_start(){if(this._active=this._handlers[this._id]||Ns,!this._active.length)this._handlerFb(this._id,"START");else for(let e=this._active.length-1;e>=0;e--)this._active[e].start()}_put(e,t,s){if(!this._active.length)this._handlerFb(this._id,"PUT",Hi(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}start(){this.reset(),this._state=1}put(e,t,s){if(this._state!==3){if(this._state===1)for(;t<s;){let i=e[t++];if(i===59){this._state=2,this._start();break}if(i<48||57<i){this._state=3;return}this._id===-1&&(this._id=0),this._id=this._id*10+i-48}this._state===2&&s-t>0&&this._put(e,t,s)}}end(e,t=!0){if(this._state!==0){if(this._state!==3)if(this._state===1&&this._start(),!this._active.length)this._handlerFb(this._id,"END",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].end(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].end(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=Ns,this._id=-1,this._state=0}}},Xe=class{constructor(e){this._handler=e,this._data="",this._hitLimit=!1}start(){this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Hi(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}end(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data),t instanceof Promise))return t.then(s=>(this._data="",this._hitLimit=!1,s));return this._data="",this._hitLimit=!1,t}},js=[],F_=class{constructor(){this._handlers=Object.create(null),this._active=js,this._ident=0,this._handlerFb=()=>{},this._stack={paused:!1,loopPosition:0,fallThrough:!1}}dispose(){this._handlers=Object.create(null),this._handlerFb=()=>{},this._active=js}registerHandler(e,t){this._handlers[e]===void 0&&(this._handlers[e]=[]);let s=this._handlers[e];return s.push(t),{dispose:()=>{let i=s.indexOf(t);i!==-1&&s.splice(i,1)}}}clearHandler(e){this._handlers[e]&&delete this._handlers[e]}setHandlerFallback(e){this._handlerFb=e}reset(){if(this._active.length)for(let e=this._stack.paused?this._stack.loopPosition-1:this._active.length-1;e>=0;--e)this._active[e].unhook(!1);this._stack.paused=!1,this._active=js,this._ident=0}hook(e,t){if(this.reset(),this._ident=e,this._active=this._handlers[e]||js,!this._active.length)this._handlerFb(this._ident,"HOOK",t);else for(let s=this._active.length-1;s>=0;s--)this._active[s].hook(t)}put(e,t,s){if(!this._active.length)this._handlerFb(this._ident,"PUT",Hi(e,t,s));else for(let i=this._active.length-1;i>=0;i--)this._active[i].put(e,t,s)}unhook(e,t=!0){if(!this._active.length)this._handlerFb(this._ident,"UNHOOK",e);else{let s=!1,i=this._active.length-1,r=!1;if(this._stack.paused&&(i=this._stack.loopPosition-1,s=t,r=this._stack.fallThrough,this._stack.paused=!1),!r&&s===!1){for(;i>=0&&(s=this._active[i].unhook(e),s!==!0);i--)if(s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!1,s;i--}for(;i>=0;i--)if(s=this._active[i].unhook(!1),s instanceof Promise)return this._stack.paused=!0,this._stack.loopPosition=i,this._stack.fallThrough=!0,s}this._active=js,this._ident=0}},As=new uc;As.addParam(0);var va=class{constructor(e){this._handler=e,this._data="",this._params=As,this._hitLimit=!1}hook(e){this._params=e.length>1||e.params[0]?e.clone():As,this._data="",this._hitLimit=!1}put(e,t,s){this._hitLimit||(this._data+=Hi(e,t,s),this._data.length>1e7&&(this._data="",this._hitLimit=!0))}unhook(e){let t=!1;if(this._hitLimit)t=!1;else if(e&&(t=this._handler(this._data,this._params),t instanceof Promise))return t.then(s=>(this._params=As,this._data="",this._hitLimit=!1,s));return this._params=As,this._data="",this._hitLimit=!1,t}},H_=class{constructor(e){this.table=new Uint8Array(e)}setDefault(e,t){this.table.fill(e<<4|t)}add(e,t,s,i){this.table[t<<8|e]=s<<4|i}addMany(e,t,s,i){for(let r=0;r<e.length;r++)this.table[t<<8|e[r]]=s<<4|i}},tt=160,W_=(function(){let e=new H_(4095),t=Array.apply(null,Array(256)).map((l,h)=>h),s=(l,h)=>t.slice(l,h),i=s(32,127),r=s(0,24);r.push(25),r.push.apply(r,s(28,32));let n=s(0,14),a;e.setDefault(1,0),e.addMany(i,0,2,0);for(a in n)e.addMany([24,26,153,154],a,3,0),e.addMany(s(128,144),a,3,0),e.addMany(s(144,152),a,3,0),e.add(156,a,0,0),e.add(27,a,11,1),e.add(157,a,4,8),e.addMany([152,158,159],a,0,7),e.add(155,a,11,3),e.add(144,a,11,9);return e.addMany(r,0,3,0),e.addMany(r,1,3,1),e.add(127,1,0,1),e.addMany(r,8,0,8),e.addMany(r,3,3,3),e.add(127,3,0,3),e.addMany(r,4,3,4),e.add(127,4,0,4),e.addMany(r,6,3,6),e.addMany(r,5,3,5),e.add(127,5,0,5),e.addMany(r,2,3,2),e.add(127,2,0,2),e.add(93,1,4,8),e.addMany(i,8,5,8),e.add(127,8,5,8),e.addMany([156,27,24,26,7],8,6,0),e.addMany(s(28,32),8,0,8),e.addMany([88,94,95],1,0,7),e.addMany(i,7,0,7),e.addMany(r,7,0,7),e.add(156,7,0,0),e.add(127,7,0,7),e.add(91,1,11,3),e.addMany(s(64,127),3,7,0),e.addMany(s(48,60),3,8,4),e.addMany([60,61,62,63],3,9,4),e.addMany(s(48,60),4,8,4),e.addMany(s(64,127),4,7,0),e.addMany([60,61,62,63],4,0,6),e.addMany(s(32,64),6,0,6),e.add(127,6,0,6),e.addMany(s(64,127),6,0,0),e.addMany(s(32,48),3,9,5),e.addMany(s(32,48),5,9,5),e.addMany(s(48,64),5,0,6),e.addMany(s(64,127),5,7,0),e.addMany(s(32,48),4,9,5),e.addMany(s(32,48),1,9,2),e.addMany(s(32,48),2,9,2),e.addMany(s(48,127),2,10,0),e.addMany(s(48,80),1,10,0),e.addMany(s(81,88),1,10,0),e.addMany([89,90,92],1,10,0),e.addMany(s(96,127),1,10,0),e.add(80,1,11,9),e.addMany(r,9,0,9),e.add(127,9,0,9),e.addMany(s(28,32),9,0,9),e.addMany(s(32,48),9,9,12),e.addMany(s(48,60),9,8,10),e.addMany([60,61,62,63],9,9,10),e.addMany(r,11,0,11),e.addMany(s(32,128),11,0,11),e.addMany(s(28,32),11,0,11),e.addMany(r,10,0,10),e.add(127,10,0,10),e.addMany(s(28,32),10,0,10),e.addMany(s(48,60),10,8,10),e.addMany([60,61,62,63],10,0,11),e.addMany(s(32,48),10,9,12),e.addMany(r,12,0,12),e.add(127,12,0,12),e.addMany(s(28,32),12,0,12),e.addMany(s(32,48),12,9,12),e.addMany(s(48,64),12,0,11),e.addMany(s(64,127),12,12,13),e.addMany(s(64,127),10,12,13),e.addMany(s(64,127),9,12,13),e.addMany(r,13,13,13),e.addMany(i,13,13,13),e.add(127,13,0,13),e.addMany([27,156,24,26],13,14,0),e.add(tt,0,2,0),e.add(tt,8,5,8),e.add(tt,6,0,6),e.add(tt,11,0,11),e.add(tt,13,13,13),e})(),U_=class extends re{constructor(e=W_){super(),this._transitions=e,this._parseStack={state:0,handlers:[],handlerPos:0,transition:0,chunkPos:0},this.initialState=0,this.currentState=this.initialState,this._params=new uc,this._params.addParam(0),this._collect=0,this.precedingJoinState=0,this._printHandlerFb=(t,s,i)=>{},this._executeHandlerFb=t=>{},this._csiHandlerFb=(t,s)=>{},this._escHandlerFb=t=>{},this._errorHandlerFb=t=>t,this._printHandler=this._printHandlerFb,this._executeHandlers=Object.create(null),this._csiHandlers=Object.create(null),this._escHandlers=Object.create(null),this._register(_e(()=>{this._csiHandlers=Object.create(null),this._executeHandlers=Object.create(null),this._escHandlers=Object.create(null)})),this._oscParser=this._register(new $_),this._dcsParser=this._register(new F_),this._errorHandler=this._errorHandlerFb,this.registerEscHandler({final:"\\"},()=>!0)}_identifier(e,t=[64,126]){let s=0;if(e.prefix){if(e.prefix.length>1)throw new Error("only one byte as prefix supported");if(s=e.prefix.charCodeAt(0),s&&60>s||s>63)throw new Error("prefix must be in range 0x3c .. 0x3f")}if(e.intermediates){if(e.intermediates.length>2)throw new Error("only two bytes as intermediates are supported");for(let r=0;r<e.intermediates.length;++r){let n=e.intermediates.charCodeAt(r);if(32>n||n>47)throw new Error("intermediate must be in range 0x20 .. 0x2f");s<<=8,s|=n}}if(e.final.length!==1)throw new Error("final must be a single byte");let i=e.final.charCodeAt(0);if(t[0]>i||i>t[1])throw new Error(`final must be in range ${t[0]} .. ${t[1]}`);return s<<=8,s|=i,s}identToString(e){let t=[];for(;e;)t.push(String.fromCharCode(e&255)),e>>=8;return t.reverse().join("")}setPrintHandler(e){this._printHandler=e}clearPrintHandler(){this._printHandler=this._printHandlerFb}registerEscHandler(e,t){let s=this._identifier(e,[48,126]);this._escHandlers[s]===void 0&&(this._escHandlers[s]=[]);let i=this._escHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearEscHandler(e){this._escHandlers[this._identifier(e,[48,126])]&&delete this._escHandlers[this._identifier(e,[48,126])]}setEscHandlerFallback(e){this._escHandlerFb=e}setExecuteHandler(e,t){this._executeHandlers[e.charCodeAt(0)]=t}clearExecuteHandler(e){this._executeHandlers[e.charCodeAt(0)]&&delete this._executeHandlers[e.charCodeAt(0)]}setExecuteHandlerFallback(e){this._executeHandlerFb=e}registerCsiHandler(e,t){let s=this._identifier(e);this._csiHandlers[s]===void 0&&(this._csiHandlers[s]=[]);let i=this._csiHandlers[s];return i.push(t),{dispose:()=>{let r=i.indexOf(t);r!==-1&&i.splice(r,1)}}}clearCsiHandler(e){this._csiHandlers[this._identifier(e)]&&delete this._csiHandlers[this._identifier(e)]}setCsiHandlerFallback(e){this._csiHandlerFb=e}registerDcsHandler(e,t){return this._dcsParser.registerHandler(this._identifier(e),t)}clearDcsHandler(e){this._dcsParser.clearHandler(this._identifier(e))}setDcsHandlerFallback(e){this._dcsParser.setHandlerFallback(e)}registerOscHandler(e,t){return this._oscParser.registerHandler(e,t)}clearOscHandler(e){this._oscParser.clearHandler(e)}setOscHandlerFallback(e){this._oscParser.setHandlerFallback(e)}setErrorHandler(e){this._errorHandler=e}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.precedingJoinState=0,this._parseStack.state!==0&&(this._parseStack.state=2,this._parseStack.handlers=[])}_preserveStack(e,t,s,i,r){this._parseStack.state=e,this._parseStack.handlers=t,this._parseStack.handlerPos=s,this._parseStack.transition=i,this._parseStack.chunkPos=r}parse(e,t,s){let i=0,r=0,n=0,a;if(this._parseStack.state)if(this._parseStack.state===2)this._parseStack.state=0,n=this._parseStack.chunkPos+1;else{if(s===void 0||this._parseStack.state===1)throw this._parseStack.state=1,new Error("improper continuation due to previous async handler, giving up parsing");let l=this._parseStack.handlers,h=this._parseStack.handlerPos-1;switch(this._parseStack.state){case 3:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](this._params),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 4:if(s===!1&&h>-1){for(;h>=0&&(a=l[h](),a!==!0);h--)if(a instanceof Promise)return this._parseStack.handlerPos=h,a}this._parseStack.handlers=[];break;case 6:if(i=e[this._parseStack.chunkPos],a=this._dcsParser.unhook(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break;case 5:if(i=e[this._parseStack.chunkPos],a=this._oscParser.end(i!==24&&i!==26,s),a)return a;i===27&&(this._parseStack.transition|=1),this._params.reset(),this._params.addParam(0),this._collect=0;break}this._parseStack.state=0,n=this._parseStack.chunkPos+1,this.precedingJoinState=0,this.currentState=this._parseStack.transition&15}for(let l=n;l<t;++l){switch(i=e[l],r=this._transitions.table[this.currentState<<8|(i<160?i:tt)],r>>4){case 2:for(let u=l+1;;++u){if(u>=t||(i=e[u])<32||i>126&&i<tt){this._printHandler(e,l,u),l=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<tt){this._printHandler(e,l,u),l=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<tt){this._printHandler(e,l,u),l=u-1;break}if(++u>=t||(i=e[u])<32||i>126&&i<tt){this._printHandler(e,l,u),l=u-1;break}}break;case 3:this._executeHandlers[i]?this._executeHandlers[i]():this._executeHandlerFb(i),this.precedingJoinState=0;break;case 0:break;case 1:if(this._errorHandler({position:l,code:i,currentState:this.currentState,collect:this._collect,params:this._params,abort:!1}).abort)return;break;case 7:let h=this._csiHandlers[this._collect<<8|i],c=h?h.length-1:-1;for(;c>=0&&(a=h[c](this._params),a!==!0);c--)if(a instanceof Promise)return this._preserveStack(3,h,c,r,l),a;c<0&&this._csiHandlerFb(this._collect<<8|i,this._params),this.precedingJoinState=0;break;case 8:do switch(i){case 59:this._params.addParam(0);break;case 58:this._params.addSubParam(-1);break;default:this._params.addDigit(i-48)}while(++l<t&&(i=e[l])>47&&i<60);l--;break;case 9:this._collect<<=8,this._collect|=i;break;case 10:let d=this._escHandlers[this._collect<<8|i],f=d?d.length-1:-1;for(;f>=0&&(a=d[f](),a!==!0);f--)if(a instanceof Promise)return this._preserveStack(4,d,f,r,l),a;f<0&&this._escHandlerFb(this._collect<<8|i),this.precedingJoinState=0;break;case 11:this._params.reset(),this._params.addParam(0),this._collect=0;break;case 12:this._dcsParser.hook(this._collect<<8|i,this._params);break;case 13:for(let u=l+1;;++u)if(u>=t||(i=e[u])===24||i===26||i===27||i>127&&i<tt){this._dcsParser.put(e,l,u),l=u-1;break}break;case 14:if(a=this._dcsParser.unhook(i!==24&&i!==26),a)return this._preserveStack(6,[],0,r,l),a;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break;case 4:this._oscParser.start();break;case 5:for(let u=l+1;;u++)if(u>=t||(i=e[u])<32||i>127&&i<tt){this._oscParser.put(e,l,u),l=u-1;break}break;case 6:if(a=this._oscParser.end(i!==24&&i!==26),a)return this._preserveStack(5,[],0,r,l),a;i===27&&(r|=1),this._params.reset(),this._params.addParam(0),this._collect=0,this.precedingJoinState=0;break}this.currentState=r&15}}},K_=/^([\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})$/,q_=/^[\da-f]+$/;function xa(e){if(!e)return;let t=e.toLowerCase();if(t.indexOf("rgb:")===0){t=t.slice(4);let s=K_.exec(t);if(s){let i=s[1]?15:s[4]?255:s[7]?4095:65535;return[Math.round(parseInt(s[1]||s[4]||s[7]||s[10],16)/i*255),Math.round(parseInt(s[2]||s[5]||s[8]||s[11],16)/i*255),Math.round(parseInt(s[3]||s[6]||s[9]||s[12],16)/i*255)]}}else if(t.indexOf("#")===0&&(t=t.slice(1),q_.exec(t)&&[3,6,9,12].includes(t.length))){let s=t.length/3,i=[0,0,0];for(let r=0;r<3;++r){let n=parseInt(t.slice(s*r,s*r+s),16);i[r]=s===1?n<<4:s===2?n:s===3?n>>4:n>>8}return i}}function fr(e,t){let s=e.toString(16),i=s.length<2?"0"+s:s;switch(t){case 4:return s[0];case 8:return i;case 12:return(i+i).slice(0,3);default:return i+i}}function V_(e,t=16){let[s,i,r]=e;return`rgb:${fr(s,t)}/${fr(i,t)}/${fr(r,t)}`}var Y_={"(":0,")":1,"*":2,"+":3,"-":1,".":2},kt=131072,ba=10;function ya(e,t){if(e>24)return t.setWinLines||!1;switch(e){case 1:return!!t.restoreWin;case 2:return!!t.minimizeWin;case 3:return!!t.setWinPosition;case 4:return!!t.setWinSizePixels;case 5:return!!t.raiseWin;case 6:return!!t.lowerWin;case 7:return!!t.refreshWin;case 8:return!!t.setWinSizeChars;case 9:return!!t.maximizeWin;case 10:return!!t.fullscreenWin;case 11:return!!t.getWinState;case 13:return!!t.getWinPosition;case 14:return!!t.getWinSizePixels;case 15:return!!t.getScreenSizePixels;case 16:return!!t.getCellSizePixels;case 18:return!!t.getWinSizeChars;case 19:return!!t.getScreenSizeChars;case 20:return!!t.getIconTitle;case 21:return!!t.getWinTitle;case 22:return!!t.pushTitle;case 23:return!!t.popTitle;case 24:return!!t.setWinLines}return!1}var Sa=5e3,wa=0,G_=class extends re{constructor(e,t,s,i,r,n,a,l,h=new U_){super(),this._bufferService=e,this._charsetService=t,this._coreService=s,this._logService=i,this._optionsService=r,this._oscLinkService=n,this._coreMouseService=a,this._unicodeService=l,this._parser=h,this._parseBuffer=new Uint32Array(4096),this._stringDecoder=new pf,this._utf8Decoder=new _f,this._windowTitle="",this._iconName="",this._windowTitleStack=[],this._iconNameStack=[],this._curAttrData=Se.clone(),this._eraseAttrDataInternal=Se.clone(),this._onRequestBell=this._register(new T),this.onRequestBell=this._onRequestBell.event,this._onRequestRefreshRows=this._register(new T),this.onRequestRefreshRows=this._onRequestRefreshRows.event,this._onRequestReset=this._register(new T),this.onRequestReset=this._onRequestReset.event,this._onRequestSendFocus=this._register(new T),this.onRequestSendFocus=this._onRequestSendFocus.event,this._onRequestSyncScrollBar=this._register(new T),this.onRequestSyncScrollBar=this._onRequestSyncScrollBar.event,this._onRequestWindowsOptionsReport=this._register(new T),this.onRequestWindowsOptionsReport=this._onRequestWindowsOptionsReport.event,this._onA11yChar=this._register(new T),this.onA11yChar=this._onA11yChar.event,this._onA11yTab=this._register(new T),this.onA11yTab=this._onA11yTab.event,this._onCursorMove=this._register(new T),this.onCursorMove=this._onCursorMove.event,this._onLineFeed=this._register(new T),this.onLineFeed=this._onLineFeed.event,this._onScroll=this._register(new T),this.onScroll=this._onScroll.event,this._onTitleChange=this._register(new T),this.onTitleChange=this._onTitleChange.event,this._onColor=this._register(new T),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 nn(this._bufferService),this._activeBuffer=this._bufferService.buffer,this._register(this._bufferService.buffers.onBufferActivate(c=>this._activeBuffer=c.activeBuffer)),this._parser.setCsiHandlerFallback((c,d)=>{this._logService.debug("Unknown CSI code: ",{identifier:this._parser.identToString(c),params:d.toArray()})}),this._parser.setEscHandlerFallback(c=>{this._logService.debug("Unknown ESC code: ",{identifier:this._parser.identToString(c)})}),this._parser.setExecuteHandlerFallback(c=>{this._logService.debug("Unknown EXECUTE code: ",{code:c})}),this._parser.setOscHandlerFallback((c,d,f)=>{this._logService.debug("Unknown OSC code: ",{identifier:c,action:d,data:f})}),this._parser.setDcsHandlerFallback((c,d,f)=>{d==="HOOK"&&(f=f.toArray()),this._logService.debug("Unknown DCS code: ",{identifier:this._parser.identToString(c),action:d,payload:f})}),this._parser.setPrintHandler((c,d,f)=>this.print(c,d,f)),this._parser.registerCsiHandler({final:"@"},c=>this.insertChars(c)),this._parser.registerCsiHandler({intermediates:" ",final:"@"},c=>this.scrollLeft(c)),this._parser.registerCsiHandler({final:"A"},c=>this.cursorUp(c)),this._parser.registerCsiHandler({intermediates:" ",final:"A"},c=>this.scrollRight(c)),this._parser.registerCsiHandler({final:"B"},c=>this.cursorDown(c)),this._parser.registerCsiHandler({final:"C"},c=>this.cursorForward(c)),this._parser.registerCsiHandler({final:"D"},c=>this.cursorBackward(c)),this._parser.registerCsiHandler({final:"E"},c=>this.cursorNextLine(c)),this._parser.registerCsiHandler({final:"F"},c=>this.cursorPrecedingLine(c)),this._parser.registerCsiHandler({final:"G"},c=>this.cursorCharAbsolute(c)),this._parser.registerCsiHandler({final:"H"},c=>this.cursorPosition(c)),this._parser.registerCsiHandler({final:"I"},c=>this.cursorForwardTab(c)),this._parser.registerCsiHandler({final:"J"},c=>this.eraseInDisplay(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"J"},c=>this.eraseInDisplay(c,!0)),this._parser.registerCsiHandler({final:"K"},c=>this.eraseInLine(c,!1)),this._parser.registerCsiHandler({prefix:"?",final:"K"},c=>this.eraseInLine(c,!0)),this._parser.registerCsiHandler({final:"L"},c=>this.insertLines(c)),this._parser.registerCsiHandler({final:"M"},c=>this.deleteLines(c)),this._parser.registerCsiHandler({final:"P"},c=>this.deleteChars(c)),this._parser.registerCsiHandler({final:"S"},c=>this.scrollUp(c)),this._parser.registerCsiHandler({final:"T"},c=>this.scrollDown(c)),this._parser.registerCsiHandler({final:"X"},c=>this.eraseChars(c)),this._parser.registerCsiHandler({final:"Z"},c=>this.cursorBackwardTab(c)),this._parser.registerCsiHandler({final:"`"},c=>this.charPosAbsolute(c)),this._parser.registerCsiHandler({final:"a"},c=>this.hPositionRelative(c)),this._parser.registerCsiHandler({final:"b"},c=>this.repeatPrecedingCharacter(c)),this._parser.registerCsiHandler({final:"c"},c=>this.sendDeviceAttributesPrimary(c)),this._parser.registerCsiHandler({prefix:">",final:"c"},c=>this.sendDeviceAttributesSecondary(c)),this._parser.registerCsiHandler({final:"d"},c=>this.linePosAbsolute(c)),this._parser.registerCsiHandler({final:"e"},c=>this.vPositionRelative(c)),this._parser.registerCsiHandler({final:"f"},c=>this.hVPosition(c)),this._parser.registerCsiHandler({final:"g"},c=>this.tabClear(c)),this._parser.registerCsiHandler({final:"h"},c=>this.setMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"h"},c=>this.setModePrivate(c)),this._parser.registerCsiHandler({final:"l"},c=>this.resetMode(c)),this._parser.registerCsiHandler({prefix:"?",final:"l"},c=>this.resetModePrivate(c)),this._parser.registerCsiHandler({final:"m"},c=>this.charAttributes(c)),this._parser.registerCsiHandler({final:"n"},c=>this.deviceStatus(c)),this._parser.registerCsiHandler({prefix:"?",final:"n"},c=>this.deviceStatusPrivate(c)),this._parser.registerCsiHandler({intermediates:"!",final:"p"},c=>this.softReset(c)),this._parser.registerCsiHandler({intermediates:" ",final:"q"},c=>this.setCursorStyle(c)),this._parser.registerCsiHandler({final:"r"},c=>this.setScrollRegion(c)),this._parser.registerCsiHandler({final:"s"},c=>this.saveCursor(c)),this._parser.registerCsiHandler({final:"t"},c=>this.windowOptions(c)),this._parser.registerCsiHandler({final:"u"},c=>this.restoreCursor(c)),this._parser.registerCsiHandler({intermediates:"'",final:"}"},c=>this.insertColumns(c)),this._parser.registerCsiHandler({intermediates:"'",final:"~"},c=>this.deleteColumns(c)),this._parser.registerCsiHandler({intermediates:'"',final:"q"},c=>this.selectProtected(c)),this._parser.registerCsiHandler({intermediates:"$",final:"p"},c=>this.requestMode(c,!0)),this._parser.registerCsiHandler({prefix:"?",intermediates:"$",final:"p"},c=>this.requestMode(c,!1)),this._parser.setExecuteHandler(N.BEL,()=>this.bell()),this._parser.setExecuteHandler(N.LF,()=>this.lineFeed()),this._parser.setExecuteHandler(N.VT,()=>this.lineFeed()),this._parser.setExecuteHandler(N.FF,()=>this.lineFeed()),this._parser.setExecuteHandler(N.CR,()=>this.carriageReturn()),this._parser.setExecuteHandler(N.BS,()=>this.backspace()),this._parser.setExecuteHandler(N.HT,()=>this.tab()),this._parser.setExecuteHandler(N.SO,()=>this.shiftOut()),this._parser.setExecuteHandler(N.SI,()=>this.shiftIn()),this._parser.setExecuteHandler(Ci.IND,()=>this.index()),this._parser.setExecuteHandler(Ci.NEL,()=>this.nextLine()),this._parser.setExecuteHandler(Ci.HTS,()=>this.tabSet()),this._parser.registerOscHandler(0,new Xe(c=>(this.setTitle(c),this.setIconName(c),!0))),this._parser.registerOscHandler(1,new Xe(c=>this.setIconName(c))),this._parser.registerOscHandler(2,new Xe(c=>this.setTitle(c))),this._parser.registerOscHandler(4,new Xe(c=>this.setOrReportIndexedColor(c))),this._parser.registerOscHandler(8,new Xe(c=>this.setHyperlink(c))),this._parser.registerOscHandler(10,new Xe(c=>this.setOrReportFgColor(c))),this._parser.registerOscHandler(11,new Xe(c=>this.setOrReportBgColor(c))),this._parser.registerOscHandler(12,new Xe(c=>this.setOrReportCursorColor(c))),this._parser.registerOscHandler(104,new Xe(c=>this.restoreIndexedColor(c))),this._parser.registerOscHandler(110,new Xe(c=>this.restoreFgColor(c))),this._parser.registerOscHandler(111,new Xe(c=>this.restoreBgColor(c))),this._parser.registerOscHandler(112,new Xe(c=>this.restoreCursorColor(c))),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(let c in Ne)this._parser.registerEscHandler({intermediates:"(",final:c},()=>this.selectCharset("("+c)),this._parser.registerEscHandler({intermediates:")",final:c},()=>this.selectCharset(")"+c)),this._parser.registerEscHandler({intermediates:"*",final:c},()=>this.selectCharset("*"+c)),this._parser.registerEscHandler({intermediates:"+",final:c},()=>this.selectCharset("+"+c)),this._parser.registerEscHandler({intermediates:"-",final:c},()=>this.selectCharset("-"+c)),this._parser.registerEscHandler({intermediates:".",final:c},()=>this.selectCharset("."+c)),this._parser.registerEscHandler({intermediates:"/",final:c},()=>this.selectCharset("/"+c));this._parser.registerEscHandler({intermediates:"#",final:"8"},()=>this.screenAlignmentPattern()),this._parser.setErrorHandler(c=>(this._logService.error("Parsing error: ",c),c)),this._parser.registerDcsHandler({intermediates:"$",final:"q"},new va((c,d)=>this.requestStatusString(c,d)))}getAttrData(){return this._curAttrData}_preserveStack(e,t,s,i){this._parseStack.paused=!0,this._parseStack.cursorStartX=e,this._parseStack.cursorStartY=t,this._parseStack.decodedLength=s,this._parseStack.position=i}_logSlowResolvingAsync(e){this._logService.logLevel<=3&&Promise.race([e,new Promise((t,s)=>setTimeout(()=>s("#SLOW_TIMEOUT"),Sa))]).catch(t=>{if(t!=="#SLOW_TIMEOUT")throw t;console.warn(`async parser handler taking longer than ${Sa} ms`)})}_getCurrentLinkId(){return this._curAttrData.extended.urlId}parse(e,t){let s,i=this._activeBuffer.x,r=this._activeBuffer.y,n=0,a=this._parseStack.paused;if(a){if(s=this._parser.parse(this._parseBuffer,this._parseStack.decodedLength,t))return this._logSlowResolvingAsync(s),s;i=this._parseStack.cursorStartX,r=this._parseStack.cursorStartY,this._parseStack.paused=!1,e.length>kt&&(n=this._parseStack.position+kt)}if(this._logService.logLevel<=1&&this._logService.debug(`parsing data ${typeof e=="string"?` "${e}"`:` "${Array.prototype.map.call(e,c=>String.fromCharCode(c)).join("")}"`}`),this._logService.logLevel===0&&this._logService.trace("parsing data (codes)",typeof e=="string"?e.split("").map(c=>c.charCodeAt(0)):e),this._parseBuffer.length<e.length&&this._parseBuffer.length<kt&&(this._parseBuffer=new Uint32Array(Math.min(e.length,kt))),a||this._dirtyRowTracker.clearRange(),e.length>kt)for(let c=n;c<e.length;c+=kt){let d=c+kt<e.length?c+kt:e.length,f=typeof e=="string"?this._stringDecoder.decode(e.substring(c,d),this._parseBuffer):this._utf8Decoder.decode(e.subarray(c,d),this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,f))return this._preserveStack(i,r,f,c),this._logSlowResolvingAsync(s),s}else if(!a){let c=typeof e=="string"?this._stringDecoder.decode(e,this._parseBuffer):this._utf8Decoder.decode(e,this._parseBuffer);if(s=this._parser.parse(this._parseBuffer,c))return this._preserveStack(i,r,c,0),this._logSlowResolvingAsync(s),s}(this._activeBuffer.x!==i||this._activeBuffer.y!==r)&&this._onCursorMove.fire();let l=this._dirtyRowTracker.end+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp),h=this._dirtyRowTracker.start+(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp);h<this._bufferService.rows&&this._onRequestRefreshRows.fire({start:Math.min(h,this._bufferService.rows-1),end:Math.min(l,this._bufferService.rows-1)})}print(e,t,s){let i,r,n=this._charsetService.charset,a=this._optionsService.rawOptions.screenReaderMode,l=this._bufferService.cols,h=this._coreService.decPrivateModes.wraparound,c=this._coreService.modes.insertMode,d=this._curAttrData,f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._activeBuffer.x&&s-t>0&&f.getWidth(this._activeBuffer.x-1)===2&&f.setCellFromCodepoint(this._activeBuffer.x-1,0,1,d);let u=this._parser.precedingJoinState;for(let g=t;g<s;++g){if(i=e[g],i<127&&n){let x=n[String.fromCharCode(i)];x&&(i=x.charCodeAt(0))}let p=this._unicodeService.charProperties(i,u);r=Ft.extractWidth(p);let m=Ft.extractShouldJoin(p),y=m?Ft.extractWidth(u):0;if(u=p,a&&this._onA11yChar.fire(Et(i)),this._getCurrentLinkId()&&this._oscLinkService.addLineToLink(this._getCurrentLinkId(),this._activeBuffer.ybase+this._activeBuffer.y),this._activeBuffer.x+r-y>l){if(h){let x=f,b=this._activeBuffer.x-y;for(this._activeBuffer.x=y,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),f=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y),y>0&&f instanceof zs&&f.copyCellsFrom(x,b,0,y,!1);b<l;)x.setCellFromCodepoint(b++,0,1,d)}else if(this._activeBuffer.x=l-1,r===2)continue}if(m&&this._activeBuffer.x){let x=f.getWidth(this._activeBuffer.x-1)?1:2;f.addCodepointToCell(this._activeBuffer.x-x,i,r);for(let b=r-y;--b>=0;)f.setCellFromCodepoint(this._activeBuffer.x++,0,0,d);continue}if(c&&(f.insertCells(this._activeBuffer.x,r-y,this._activeBuffer.getNullCell(d)),f.getWidth(l-1)===2&&f.setCellFromCodepoint(l-1,0,1,d)),f.setCellFromCodepoint(this._activeBuffer.x++,i,r,d),r>0)for(;--r;)f.setCellFromCodepoint(this._activeBuffer.x++,0,0,d)}this._parser.precedingJoinState=u,this._activeBuffer.x<l&&s-t>0&&f.getWidth(this._activeBuffer.x)===0&&!f.hasContent(this._activeBuffer.x)&&f.setCellFromCodepoint(this._activeBuffer.x,0,1,d),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}registerCsiHandler(e,t){return e.final==="t"&&!e.prefix&&!e.intermediates?this._parser.registerCsiHandler(e,s=>ya(s.params[0],this._optionsService.rawOptions.windowOptions)?t(s):!0):this._parser.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._parser.registerDcsHandler(e,new va(t))}registerEscHandler(e,t){return this._parser.registerEscHandler(e,t)}registerOscHandler(e,t){return this._parser.registerOscHandler(e,new Xe(t))}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 e;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&&((e=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y))!=null&&e.isWrapped)){this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).isWrapped=!1,this._activeBuffer.y--,this._activeBuffer.x=this._bufferService.cols-1;let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);t.hasWidth(this._activeBuffer.x)&&!t.hasContent(this._activeBuffer.x)&&this._activeBuffer.x--}return this._restrictCursor(),!0}tab(){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let e=this._activeBuffer.x;return this._activeBuffer.x=this._activeBuffer.nextStop(),this._optionsService.rawOptions.screenReaderMode&&this._onA11yTab.fire(this._activeBuffer.x-e),!0}shiftOut(){return this._charsetService.setgLevel(1),!0}shiftIn(){return this._charsetService.setgLevel(0),!0}_restrictCursor(e=this._bufferService.cols-1){this._activeBuffer.x=Math.min(e,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(e,t){this._dirtyRowTracker.markDirty(this._activeBuffer.y),this._coreService.decPrivateModes.origin?(this._activeBuffer.x=e,this._activeBuffer.y=this._activeBuffer.scrollTop+t):(this._activeBuffer.x=e,this._activeBuffer.y=t),this._restrictCursor(),this._dirtyRowTracker.markDirty(this._activeBuffer.y)}_moveCursor(e,t){this._restrictCursor(),this._setCursor(this._activeBuffer.x+e,this._activeBuffer.y+t)}cursorUp(e){let t=this._activeBuffer.y-this._activeBuffer.scrollTop;return t>=0?this._moveCursor(0,-Math.min(t,e.params[0]||1)):this._moveCursor(0,-(e.params[0]||1)),!0}cursorDown(e){let t=this._activeBuffer.scrollBottom-this._activeBuffer.y;return t>=0?this._moveCursor(0,Math.min(t,e.params[0]||1)):this._moveCursor(0,e.params[0]||1),!0}cursorForward(e){return this._moveCursor(e.params[0]||1,0),!0}cursorBackward(e){return this._moveCursor(-(e.params[0]||1),0),!0}cursorNextLine(e){return this.cursorDown(e),this._activeBuffer.x=0,!0}cursorPrecedingLine(e){return this.cursorUp(e),this._activeBuffer.x=0,!0}cursorCharAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}cursorPosition(e){return this._setCursor(e.length>=2?(e.params[1]||1)-1:0,(e.params[0]||1)-1),!0}charPosAbsolute(e){return this._setCursor((e.params[0]||1)-1,this._activeBuffer.y),!0}hPositionRelative(e){return this._moveCursor(e.params[0]||1,0),!0}linePosAbsolute(e){return this._setCursor(this._activeBuffer.x,(e.params[0]||1)-1),!0}vPositionRelative(e){return this._moveCursor(0,e.params[0]||1),!0}hVPosition(e){return this.cursorPosition(e),!0}tabClear(e){let t=e.params[0];return t===0?delete this._activeBuffer.tabs[this._activeBuffer.x]:t===3&&(this._activeBuffer.tabs={}),!0}cursorForwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.nextStop();return!0}cursorBackwardTab(e){if(this._activeBuffer.x>=this._bufferService.cols)return!0;let t=e.params[0]||1;for(;t--;)this._activeBuffer.x=this._activeBuffer.prevStop();return!0}selectProtected(e){let t=e.params[0];return t===1&&(this._curAttrData.bg|=536870912),(t===2||t===0)&&(this._curAttrData.bg&=-536870913),!0}_eraseInBufferLine(e,t,s,i=!1,r=!1){let n=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);n.replaceCells(t,s,this._activeBuffer.getNullCell(this._eraseAttrData()),r),i&&(n.isWrapped=!1)}_resetBufferLine(e,t=!1){let s=this._activeBuffer.lines.get(this._activeBuffer.ybase+e);s&&(s.fill(this._activeBuffer.getNullCell(this._eraseAttrData()),t),this._bufferService.buffer.clearMarkers(this._activeBuffer.ybase+e),s.isWrapped=!1)}eraseInDisplay(e,t=!1){var i;this._restrictCursor(this._bufferService.cols);let s;switch(e.params[0]){case 0:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s++,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);s<this._bufferService.rows;s++)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(s);break;case 1:for(s=this._activeBuffer.y,this._dirtyRowTracker.markDirty(s),this._eraseInBufferLine(s,0,this._activeBuffer.x+1,!0,t),this._activeBuffer.x+1>=this._bufferService.cols&&(this._activeBuffer.lines.get(s+1).isWrapped=!1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0);break;case 2:if(this._optionsService.rawOptions.scrollOnEraseInDisplay){for(s=this._bufferService.rows,this._dirtyRowTracker.markRangeDirty(0,s-1);s--&&!((i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s))!=null&&i.getTrimmedLength()););for(;s>=0;s--)this._bufferService.scroll(this._eraseAttrData())}else{for(s=this._bufferService.rows,this._dirtyRowTracker.markDirty(s-1);s--;)this._resetBufferLine(s,t);this._dirtyRowTracker.markDirty(0)}break;case 3:let r=this._activeBuffer.lines.length-this._bufferService.rows;r>0&&(this._activeBuffer.lines.trimStart(r),this._activeBuffer.ybase=Math.max(this._activeBuffer.ybase-r,0),this._activeBuffer.ydisp=Math.max(this._activeBuffer.ydisp-r,0),this._onScroll.fire(0));break}return!0}eraseInLine(e,t=!1){switch(this._restrictCursor(this._bufferService.cols),e.params[0]){case 0:this._eraseInBufferLine(this._activeBuffer.y,this._activeBuffer.x,this._bufferService.cols,this._activeBuffer.x===0,t);break;case 1:this._eraseInBufferLine(this._activeBuffer.y,0,this._activeBuffer.x+1,!1,t);break;case 2:this._eraseInBufferLine(this._activeBuffer.y,0,this._bufferService.cols,!0,t);break}return this._dirtyRowTracker.markDirty(this._activeBuffer.y),!0}insertLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,r=this._bufferService.rows-1+this._activeBuffer.ybase-i+1;for(;t--;)this._activeBuffer.lines.splice(r-1,1),this._activeBuffer.lines.splice(s,0,this._activeBuffer.getBlankLine(this._eraseAttrData()));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.y,this._activeBuffer.scrollBottom),this._activeBuffer.x=0,!0}deleteLines(e){this._restrictCursor();let t=e.params[0]||1;if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let s=this._activeBuffer.ybase+this._activeBuffer.y,i;for(i=this._bufferService.rows-1-this._activeBuffer.scrollBottom,i=this._bufferService.rows-1+this._activeBuffer.ybase-i;t--;)this._activeBuffer.lines.splice(s,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}insertChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.insertCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}deleteChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.deleteCells(this._activeBuffer.x,e.params[0]||1,this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}scrollUp(e){let t=e.params[0]||1;for(;t--;)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(e){let t=e.params[0]||1;for(;t--;)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(Se));return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollLeft(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}scrollRight(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(0,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}insertColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.insertCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}deleteColumns(e){if(this._activeBuffer.y>this._activeBuffer.scrollBottom||this._activeBuffer.y<this._activeBuffer.scrollTop)return!0;let t=e.params[0]||1;for(let s=this._activeBuffer.scrollTop;s<=this._activeBuffer.scrollBottom;++s){let i=this._activeBuffer.lines.get(this._activeBuffer.ybase+s);i.deleteCells(this._activeBuffer.x,t,this._activeBuffer.getNullCell(this._eraseAttrData())),i.isWrapped=!1}return this._dirtyRowTracker.markRangeDirty(this._activeBuffer.scrollTop,this._activeBuffer.scrollBottom),!0}eraseChars(e){this._restrictCursor();let t=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y);return t&&(t.replaceCells(this._activeBuffer.x,this._activeBuffer.x+(e.params[0]||1),this._activeBuffer.getNullCell(this._eraseAttrData())),this._dirtyRowTracker.markDirty(this._activeBuffer.y)),!0}repeatPrecedingCharacter(e){let t=this._parser.precedingJoinState;if(!t)return!0;let s=e.params[0]||1,i=Ft.extractWidth(t),r=this._activeBuffer.x-i,n=this._activeBuffer.lines.get(this._activeBuffer.ybase+this._activeBuffer.y).getString(r),a=new Uint32Array(n.length*s),l=0;for(let c=0;c<n.length;){let d=n.codePointAt(c)||0;a[l++]=d,c+=d>65535?2:1}let h=l;for(let c=1;c<s;++c)a.copyWithin(h,0,l),h+=l;return this.print(a,0,h),!0}sendDeviceAttributesPrimary(e){return e.params[0]>0||(this._is("xterm")||this._is("rxvt-unicode")||this._is("screen")?this._coreService.triggerDataEvent(N.ESC+"[?1;2c"):this._is("linux")&&this._coreService.triggerDataEvent(N.ESC+"[?6c")),!0}sendDeviceAttributesSecondary(e){return e.params[0]>0||(this._is("xterm")?this._coreService.triggerDataEvent(N.ESC+"[>0;276;0c"):this._is("rxvt-unicode")?this._coreService.triggerDataEvent(N.ESC+"[>85;95;0c"):this._is("linux")?this._coreService.triggerDataEvent(e.params[0]+"c"):this._is("screen")&&this._coreService.triggerDataEvent(N.ESC+"[>83;40003;0c")),!0}_is(e){return(this._optionsService.rawOptions.termName+"").indexOf(e)===0}setMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!0;break;case 20:this._optionsService.options.convertEol=!0;break}return!0}setModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 1:this._coreService.decPrivateModes.applicationCursorKeys=!0;break;case 2:this._charsetService.setgCharset(0,$t),this._charsetService.setgCharset(1,$t),this._charsetService.setgCharset(2,$t),this._charsetService.setgCharset(3,$t);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(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!0;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!0;break}return!0}resetMode(e){for(let t=0;t<e.length;t++)switch(e.params[t]){case 4:this._coreService.modes.insertMode=!1;break;case 20:this._optionsService.options.convertEol=!1;break}return!0}resetModePrivate(e){for(let t=0;t<e.length;t++)switch(e.params[t]){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:this._coreMouseService.activeEncoding="DEFAULT";break;case 1015:this._logService.debug("DECRST 1015 not supported (see #2507)");break;case 1016:this._coreMouseService.activeEncoding="DEFAULT";break;case 25:this._coreService.isCursorHidden=!0;break;case 1048:this.restoreCursor();break;case 1049:case 47:case 1047:this._bufferService.buffers.activateNormalBuffer(),e.params[t]===1049&&this.restoreCursor(),this._coreService.isCursorInitialized=!0,this._onRequestRefreshRows.fire(void 0),this._onRequestSyncScrollBar.fire();break;case 2004:this._coreService.decPrivateModes.bracketedPasteMode=!1;break;case 2026:this._coreService.decPrivateModes.synchronizedOutput=!1,this._onRequestRefreshRows.fire(void 0);break}return!0}requestMode(e,t){(m=>(m[m.NOT_RECOGNIZED=0]="NOT_RECOGNIZED",m[m.SET=1]="SET",m[m.RESET=2]="RESET",m[m.PERMANENTLY_SET=3]="PERMANENTLY_SET",m[m.PERMANENTLY_RESET=4]="PERMANENTLY_RESET"))(void 0||(s={}));let i=this._coreService.decPrivateModes,{activeProtocol:r,activeEncoding:n}=this._coreMouseService,a=this._coreService,{buffers:l,cols:h}=this._bufferService,{active:c,alt:d}=l,f=this._optionsService.rawOptions,u=(m,y)=>(a.triggerDataEvent(`${N.ESC}[${t?"":"?"}${m};${y}$y`),!0),g=m=>m?1:2,p=e.params[0];return t?p===2?u(p,4):p===4?u(p,g(a.modes.insertMode)):p===12?u(p,3):p===20?u(p,g(f.convertEol)):u(p,0):p===1?u(p,g(i.applicationCursorKeys)):p===3?u(p,f.windowOptions.setWinLines?h===80?2:h===132?1:0:0):p===6?u(p,g(i.origin)):p===7?u(p,g(i.wraparound)):p===8?u(p,3):p===9?u(p,g(r==="X10")):p===12?u(p,g(f.cursorBlink)):p===25?u(p,g(!a.isCursorHidden)):p===45?u(p,g(i.reverseWraparound)):p===66?u(p,g(i.applicationKeypad)):p===67?u(p,4):p===1e3?u(p,g(r==="VT200")):p===1002?u(p,g(r==="DRAG")):p===1003?u(p,g(r==="ANY")):p===1004?u(p,g(i.sendFocus)):p===1005?u(p,4):p===1006?u(p,g(n==="SGR")):p===1015?u(p,4):p===1016?u(p,g(n==="SGR_PIXELS")):p===1048?u(p,1):p===47||p===1047||p===1049?u(p,g(c===d)):p===2004?u(p,g(i.bracketedPasteMode)):p===2026?u(p,g(i.synchronizedOutput)):u(p,0)}_updateAttrColor(e,t,s,i,r){return t===2?(e|=50331648,e&=-16777216,e|=Ys.fromColorRGB([s,i,r])):t===5&&(e&=-50331904,e|=33554432|s&255),e}_extractColor(e,t,s){let i=[0,0,-1,0,0,0],r=0,n=0;do{if(i[n+r]=e.params[t+n],e.hasSubParams(t+n)){let a=e.getSubParams(t+n),l=0;do i[1]===5&&(r=1),i[n+l+1+r]=a[l];while(++l<a.length&&l+n+1+r<i.length);break}if(i[1]===5&&n+r>=2||i[1]===2&&n+r>=5)break;i[1]&&(r=1)}while(++n+t<e.length&&n+r<i.length);for(let a=2;a<i.length;++a)i[a]===-1&&(i[a]=0);switch(i[0]){case 38:s.fg=this._updateAttrColor(s.fg,i[1],i[3],i[4],i[5]);break;case 48:s.bg=this._updateAttrColor(s.bg,i[1],i[3],i[4],i[5]);break;case 58:s.extended=s.extended.clone(),s.extended.underlineColor=this._updateAttrColor(s.extended.underlineColor,i[1],i[3],i[4],i[5])}return n}_processUnderline(e,t){t.extended=t.extended.clone(),(!~e||e>5)&&(e=1),t.extended.underlineStyle=e,t.fg|=268435456,e===0&&(t.fg&=-268435457),t.updateExtended()}_processSGR0(e){e.fg=Se.fg,e.bg=Se.bg,e.extended=e.extended.clone(),e.extended.underlineStyle=0,e.extended.underlineColor&=-67108864,e.updateExtended()}charAttributes(e){if(e.length===1&&e.params[0]===0)return this._processSGR0(this._curAttrData),!0;let t=e.length,s,i=this._curAttrData;for(let r=0;r<t;r++)s=e.params[r],s>=30&&s<=37?(i.fg&=-50331904,i.fg|=16777216|s-30):s>=40&&s<=47?(i.bg&=-50331904,i.bg|=16777216|s-40):s>=90&&s<=97?(i.fg&=-50331904,i.fg|=16777216|s-90|8):s>=100&&s<=107?(i.bg&=-50331904,i.bg|=16777216|s-100|8):s===0?this._processSGR0(i):s===1?i.fg|=134217728:s===3?i.bg|=67108864:s===4?(i.fg|=268435456,this._processUnderline(e.hasSubParams(r)?e.getSubParams(r)[0]:1,i)):s===5?i.fg|=536870912:s===7?i.fg|=67108864:s===8?i.fg|=1073741824:s===9?i.fg|=2147483648:s===2?i.bg|=134217728:s===21?this._processUnderline(2,i):s===22?(i.fg&=-134217729,i.bg&=-134217729):s===23?i.bg&=-67108865:s===24?(i.fg&=-268435457,this._processUnderline(0,i)):s===25?i.fg&=-536870913:s===27?i.fg&=-67108865:s===28?i.fg&=-1073741825:s===29?i.fg&=2147483647:s===39?(i.fg&=-67108864,i.fg|=Se.fg&16777215):s===49?(i.bg&=-67108864,i.bg|=Se.bg&16777215):s===38||s===48||s===58?r+=this._extractColor(e,r,i):s===53?i.bg|=1073741824:s===55?i.bg&=-1073741825:s===59?(i.extended=i.extended.clone(),i.extended.underlineColor=-1,i.updateExtended()):s===100?(i.fg&=-67108864,i.fg|=Se.fg&16777215,i.bg&=-67108864,i.bg|=Se.bg&16777215):this._logService.debug("Unknown SGR attribute: %d.",s);return!0}deviceStatus(e){switch(e.params[0]){case 5:this._coreService.triggerDataEvent(`${N.ESC}[0n`);break;case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${N.ESC}[${t};${s}R`);break}return!0}deviceStatusPrivate(e){switch(e.params[0]){case 6:let t=this._activeBuffer.y+1,s=this._activeBuffer.x+1;this._coreService.triggerDataEvent(`${N.ESC}[?${t};${s}R`);break}return!0}softReset(e){return this._coreService.isCursorHidden=!1,this._onRequestSyncScrollBar.fire(),this._activeBuffer.scrollTop=0,this._activeBuffer.scrollBottom=this._bufferService.rows-1,this._curAttrData=Se.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(e){let t=e.length===0?1:e.params[0];if(t===0)this._coreService.decPrivateModes.cursorStyle=void 0,this._coreService.decPrivateModes.cursorBlink=void 0;else{switch(t){case 1:case 2:this._coreService.decPrivateModes.cursorStyle="block";break;case 3:case 4:this._coreService.decPrivateModes.cursorStyle="underline";break;case 5:case 6:this._coreService.decPrivateModes.cursorStyle="bar";break}let s=t%2===1;this._coreService.decPrivateModes.cursorBlink=s}return!0}setScrollRegion(e){let t=e.params[0]||1,s;return(e.length<2||(s=e.params[1])>this._bufferService.rows||s===0)&&(s=this._bufferService.rows),s>t&&(this._activeBuffer.scrollTop=t-1,this._activeBuffer.scrollBottom=s-1,this._setCursor(0,0)),!0}windowOptions(e){if(!ya(e.params[0],this._optionsService.rawOptions.windowOptions))return!0;let t=e.length>1?e.params[1]:0;switch(e.params[0]){case 14:t!==2&&this._onRequestWindowsOptionsReport.fire(0);break;case 16:this._onRequestWindowsOptionsReport.fire(1);break;case 18:this._bufferService&&this._coreService.triggerDataEvent(`${N.ESC}[8;${this._bufferService.rows};${this._bufferService.cols}t`);break;case 22:(t===0||t===2)&&(this._windowTitleStack.push(this._windowTitle),this._windowTitleStack.length>ba&&this._windowTitleStack.shift()),(t===0||t===1)&&(this._iconNameStack.push(this._iconName),this._iconNameStack.length>ba&&this._iconNameStack.shift());break;case 23:(t===0||t===2)&&this._windowTitleStack.length&&this.setTitle(this._windowTitleStack.pop()),(t===0||t===1)&&this._iconNameStack.length&&this.setIconName(this._iconNameStack.pop());break}return!0}saveCursor(e){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(e){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(e){return this._windowTitle=e,this._onTitleChange.fire(e),!0}setIconName(e){return this._iconName=e,!0}setOrReportIndexedColor(e){let t=[],s=e.split(";");for(;s.length>1;){let i=s.shift(),r=s.shift();if(/^\d+$/.exec(i)){let n=parseInt(i);if(Ca(n))if(r==="?")t.push({type:0,index:n});else{let a=xa(r);a&&t.push({type:1,index:n,color:a})}}}return t.length&&this._onColor.fire(t),!0}setHyperlink(e){let t=e.indexOf(";");if(t===-1)return!0;let s=e.slice(0,t).trim(),i=e.slice(t+1);return i?this._createHyperlink(s,i):s.trim()?!1:this._finishHyperlink()}_createHyperlink(e,t){this._getCurrentLinkId()&&this._finishHyperlink();let s=e.split(":"),i,r=s.findIndex(n=>n.startsWith("id="));return r!==-1&&(i=s[r].slice(3)||void 0),this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=this._oscLinkService.registerLink({id:i,uri:t}),this._curAttrData.updateExtended(),!0}_finishHyperlink(){return this._curAttrData.extended=this._curAttrData.extended.clone(),this._curAttrData.extended.urlId=0,this._curAttrData.updateExtended(),!0}_setOrReportSpecialColor(e,t){let s=e.split(";");for(let i=0;i<s.length&&!(t>=this._specialColors.length);++i,++t)if(s[i]==="?")this._onColor.fire([{type:0,index:this._specialColors[t]}]);else{let r=xa(s[i]);r&&this._onColor.fire([{type:1,index:this._specialColors[t],color:r}])}return!0}setOrReportFgColor(e){return this._setOrReportSpecialColor(e,0)}setOrReportBgColor(e){return this._setOrReportSpecialColor(e,1)}setOrReportCursorColor(e){return this._setOrReportSpecialColor(e,2)}restoreIndexedColor(e){if(!e)return this._onColor.fire([{type:2}]),!0;let t=[],s=e.split(";");for(let i=0;i<s.length;++i)if(/^\d+$/.exec(s[i])){let r=parseInt(s[i]);Ca(r)&&t.push({type:2,index:r})}return t.length&&this._onColor.fire(t),!0}restoreFgColor(e){return this._onColor.fire([{type:2,index:256}]),!0}restoreBgColor(e){return this._onColor.fire([{type:2,index:257}]),!0}restoreCursorColor(e){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,$t),!0}selectCharset(e){return e.length!==2?(this.selectDefaultCharset(),!0):(e[0]==="/"||this._charsetService.setgCharset(Y_[e[0]],Ne[e[1]]||$t),!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){let e=this._activeBuffer.scrollBottom-this._activeBuffer.scrollTop;this._activeBuffer.lines.shiftElements(this._activeBuffer.ybase+this._activeBuffer.y,e,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=Se.clone(),this._eraseAttrDataInternal=Se.clone()}_eraseAttrData(){return this._eraseAttrDataInternal.bg&=-67108864,this._eraseAttrDataInternal.bg|=this._curAttrData.bg&67108863,this._eraseAttrDataInternal}setgLevel(e){return this._charsetService.setgLevel(e),!0}screenAlignmentPattern(){let e=new st;e.content=1<<22|69,e.fg=this._curAttrData.fg,e.bg=this._curAttrData.bg,this._setCursor(0,0);for(let t=0;t<this._bufferService.rows;++t){let s=this._activeBuffer.ybase+this._activeBuffer.y+t,i=this._activeBuffer.lines.get(s);i&&(i.fill(e),i.isWrapped=!1)}return this._dirtyRowTracker.markAllDirty(),this._setCursor(0,0),!0}requestStatusString(e,t){let s=a=>(this._coreService.triggerDataEvent(`${N.ESC}${a}${N.ESC}\\`),!0),i=this._bufferService.buffer,r=this._optionsService.rawOptions;return s(e==='"q'?`P1$r${this._curAttrData.isProtected()?1:0}"q`:e==='"p'?'P1$r61;1"p':e==="r"?`P1$r${i.scrollTop+1};${i.scrollBottom+1}r`:e==="m"?"P1$r0m":e===" q"?`P1$r${{block:2,underline:4,bar:6}[r.cursorStyle]-(r.cursorBlink?1:0)} q`:"P0$r")}markRangeDirty(e,t){this._dirtyRowTracker.markRangeDirty(e,t)}},nn=class{constructor(e){this._bufferService=e,this.clearRange()}clearRange(){this.start=this._bufferService.buffer.y,this.end=this._bufferService.buffer.y}markDirty(e){e<this.start?this.start=e:e>this.end&&(this.end=e)}markRangeDirty(e,t){e>t&&(wa=e,e=t,t=wa),e<this.start&&(this.start=e),t>this.end&&(this.end=t)}markAllDirty(){this.markRangeDirty(0,this._bufferService.rows-1)}};nn=be([H(0,Fe)],nn);function Ca(e){return 0<=e&&e<256}var X_=5e7,ka=12,J_=50,Z_=class extends re{constructor(e){super(),this._action=e,this._writeBuffer=[],this._callbacks=[],this._pendingData=0,this._bufferOffset=0,this._isSyncWriting=!1,this._syncCalls=0,this._didUserInput=!1,this._onWriteParsed=this._register(new T),this.onWriteParsed=this._onWriteParsed.event}handleUserInput(){this._didUserInput=!0}writeSync(e,t){if(t!==void 0&&this._syncCalls>t){this._syncCalls=0;return}if(this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(void 0),this._syncCalls++,this._isSyncWriting)return;this._isSyncWriting=!0;let s;for(;s=this._writeBuffer.shift();){this._action(s);let i=this._callbacks.shift();i&&i()}this._pendingData=0,this._bufferOffset=2147483647,this._isSyncWriting=!1,this._syncCalls=0}write(e,t){if(this._pendingData>X_)throw new Error("write data discarded, use flow control to avoid losing data");if(!this._writeBuffer.length){if(this._bufferOffset=0,this._didUserInput){this._didUserInput=!1,this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t),this._innerWrite();return}setTimeout(()=>this._innerWrite())}this._pendingData+=e.length,this._writeBuffer.push(e),this._callbacks.push(t)}_innerWrite(e=0,t=!0){let s=e||performance.now();for(;this._writeBuffer.length>this._bufferOffset;){let i=this._writeBuffer[this._bufferOffset],r=this._action(i,t);if(r){let a=l=>performance.now()-s>=ka?setTimeout(()=>this._innerWrite(0,l)):this._innerWrite(s,l);r.catch(l=>(queueMicrotask(()=>{throw l}),Promise.resolve(!1))).then(a);return}let n=this._callbacks[this._bufferOffset];if(n&&n(),this._bufferOffset++,this._pendingData-=i.length,performance.now()-s>=ka)break}this._writeBuffer.length>this._bufferOffset?(this._bufferOffset>J_&&(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()}},on=class{constructor(e){this._bufferService=e,this._nextId=1,this._entriesWithId=new Map,this._dataByLinkId=new Map}registerLink(e){let t=this._bufferService.buffer;if(e.id===void 0){let l=t.addMarker(t.ybase+t.y),h={data:e,id:this._nextId++,lines:[l]};return l.onDispose(()=>this._removeMarkerFromLink(h,l)),this._dataByLinkId.set(h.id,h),h.id}let s=e,i=this._getEntryIdKey(s),r=this._entriesWithId.get(i);if(r)return this.addLineToLink(r.id,t.ybase+t.y),r.id;let n=t.addMarker(t.ybase+t.y),a={id:this._nextId++,key:this._getEntryIdKey(s),data:s,lines:[n]};return n.onDispose(()=>this._removeMarkerFromLink(a,n)),this._entriesWithId.set(a.key,a),this._dataByLinkId.set(a.id,a),a.id}addLineToLink(e,t){let s=this._dataByLinkId.get(e);if(s&&s.lines.every(i=>i.line!==t)){let i=this._bufferService.buffer.addMarker(t);s.lines.push(i),i.onDispose(()=>this._removeMarkerFromLink(s,i))}}getLinkData(e){var t;return(t=this._dataByLinkId.get(e))==null?void 0:t.data}_getEntryIdKey(e){return`${e.id};;${e.uri}`}_removeMarkerFromLink(e,t){let s=e.lines.indexOf(t);s!==-1&&(e.lines.splice(s,1),e.lines.length===0&&(e.data.id!==void 0&&this._entriesWithId.delete(e.key),this._dataByLinkId.delete(e.id)))}};on=be([H(0,Fe)],on);var Ea=!1,Q_=class extends re{constructor(e){super(),this._windowsWrappingHeuristics=this._register(new ps),this._onBinary=this._register(new T),this.onBinary=this._onBinary.event,this._onData=this._register(new T),this.onData=this._onData.event,this._onLineFeed=this._register(new T),this.onLineFeed=this._onLineFeed.event,this._onResize=this._register(new T),this.onResize=this._onResize.event,this._onWriteParsed=this._register(new T),this.onWriteParsed=this._onWriteParsed.event,this._onScroll=this._register(new T),this._instantiationService=new w_,this.optionsService=this._register(new L_(e)),this._instantiationService.setService(He,this.optionsService),this._bufferService=this._register(this._instantiationService.createInstance(en)),this._instantiationService.setService(Fe,this._bufferService),this._logService=this._register(this._instantiationService.createInstance(Qr)),this._instantiationService.setService(Pl,this._logService),this.coreService=this._register(this._instantiationService.createInstance(tn)),this._instantiationService.setService(Jt,this.coreService),this.coreMouseService=this._register(this._instantiationService.createInstance(sn)),this._instantiationService.setService(Ml,this.coreMouseService),this.unicodeService=this._register(this._instantiationService.createInstance(Ft)),this._instantiationService.setService(xf,this.unicodeService),this._charsetService=this._instantiationService.createInstance(O_),this._instantiationService.setService(vf,this._charsetService),this._oscLinkService=this._instantiationService.createInstance(on),this._instantiationService.setService(Rl,this._oscLinkService),this._inputHandler=this._register(new G_(this._bufferService,this._charsetService,this.coreService,this._logService,this.optionsService,this._oscLinkService,this.coreMouseService,this.unicodeService)),this._register(Ae.forward(this._inputHandler.onLineFeed,this._onLineFeed)),this._register(this._inputHandler),this._register(Ae.forward(this._bufferService.onResize,this._onResize)),this._register(Ae.forward(this.coreService.onData,this._onData)),this._register(Ae.forward(this.coreService.onBinary,this._onBinary)),this._register(this.coreService.onRequestScrollToBottom(()=>this.scrollToBottom(!0))),this._register(this.coreService.onUserInput(()=>this._writeBuffer.handleUserInput())),this._register(this.optionsService.onMultipleOptionChange(["windowsMode","windowsPty"],()=>this._handleWindowsPtyOptionChange())),this._register(this._bufferService.onScroll(()=>{this._onScroll.fire({position:this._bufferService.buffer.ydisp}),this._inputHandler.markRangeDirty(this._bufferService.buffer.scrollTop,this._bufferService.buffer.scrollBottom)})),this._writeBuffer=this._register(new Z_((t,s)=>this._inputHandler.parse(t,s))),this._register(Ae.forward(this._writeBuffer.onWriteParsed,this._onWriteParsed))}get onScroll(){return this._onScrollApi||(this._onScrollApi=this._register(new T),this._onScroll.event(e=>{var t;(t=this._onScrollApi)==null||t.fire(e.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(e){for(let t in e)this.optionsService.options[t]=e[t]}write(e,t){this._writeBuffer.write(e,t)}writeSync(e,t){this._logService.logLevel<=3&&!Ea&&(this._logService.warn("writeSync is unreliable and will be removed soon."),Ea=!0),this._writeBuffer.writeSync(e,t)}input(e,t=!0){this.coreService.triggerDataEvent(e,t)}resize(e,t){isNaN(e)||isNaN(t)||(e=Math.max(e,hc),t=Math.max(t,dc),this._bufferService.resize(e,t))}scroll(e,t=!1){this._bufferService.scroll(e,t)}scrollLines(e,t){this._bufferService.scrollLines(e,t)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}registerEscHandler(e,t){return this._inputHandler.registerEscHandler(e,t)}registerDcsHandler(e,t){return this._inputHandler.registerDcsHandler(e,t)}registerCsiHandler(e,t){return this._inputHandler.registerCsiHandler(e,t)}registerOscHandler(e,t){return this._inputHandler.registerOscHandler(e,t)}_setup(){this._handleWindowsPtyOptionChange()}reset(){this._inputHandler.reset(),this._bufferService.reset(),this._charsetService.reset(),this.coreService.reset(),this.coreMouseService.reset()}_handleWindowsPtyOptionChange(){let e=!1,t=this.optionsService.rawOptions.windowsPty;t&&t.buildNumber!==void 0&&t.buildNumber!==void 0?e=t.backend==="conpty"&&t.buildNumber<21376:this.optionsService.rawOptions.windowsMode&&(e=!0),e?this._enableWindowsWrappingHeuristics():this._windowsWrappingHeuristics.clear()}_enableWindowsWrappingHeuristics(){if(!this._windowsWrappingHeuristics.value){let e=[];e.push(this.onLineFeed(ga.bind(null,this._bufferService))),e.push(this.registerCsiHandler({final:"H"},()=>(ga(this._bufferService),!1))),this._windowsWrappingHeuristics.value=_e(()=>{for(let t of e)t.dispose()})}}},em={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:["'",'"']};function tm(e,t,s,i){var a;let r={type:0,cancel:!1,key:void 0},n=(e.shiftKey?1:0)|(e.altKey?2:0)|(e.ctrlKey?4:0)|(e.metaKey?8:0);switch(e.keyCode){case 0:e.key==="UIKeyInputUpArrow"?t?r.key=N.ESC+"OA":r.key=N.ESC+"[A":e.key==="UIKeyInputLeftArrow"?t?r.key=N.ESC+"OD":r.key=N.ESC+"[D":e.key==="UIKeyInputRightArrow"?t?r.key=N.ESC+"OC":r.key=N.ESC+"[C":e.key==="UIKeyInputDownArrow"&&(t?r.key=N.ESC+"OB":r.key=N.ESC+"[B");break;case 8:r.key=e.ctrlKey?"\b":N.DEL,e.altKey&&(r.key=N.ESC+r.key);break;case 9:if(e.shiftKey){r.key=N.ESC+"[Z";break}r.key=N.HT,r.cancel=!0;break;case 13:r.key=e.altKey?N.ESC+N.CR:N.CR,r.cancel=!0;break;case 27:r.key=N.ESC,e.altKey&&(r.key=N.ESC+N.ESC),r.cancel=!0;break;case 37:if(e.metaKey)break;n?r.key=N.ESC+"[1;"+(n+1)+"D":t?r.key=N.ESC+"OD":r.key=N.ESC+"[D";break;case 39:if(e.metaKey)break;n?r.key=N.ESC+"[1;"+(n+1)+"C":t?r.key=N.ESC+"OC":r.key=N.ESC+"[C";break;case 38:if(e.metaKey)break;n?r.key=N.ESC+"[1;"+(n+1)+"A":t?r.key=N.ESC+"OA":r.key=N.ESC+"[A";break;case 40:if(e.metaKey)break;n?r.key=N.ESC+"[1;"+(n+1)+"B":t?r.key=N.ESC+"OB":r.key=N.ESC+"[B";break;case 45:!e.shiftKey&&!e.ctrlKey&&(r.key=N.ESC+"[2~");break;case 46:n?r.key=N.ESC+"[3;"+(n+1)+"~":r.key=N.ESC+"[3~";break;case 36:n?r.key=N.ESC+"[1;"+(n+1)+"H":t?r.key=N.ESC+"OH":r.key=N.ESC+"[H";break;case 35:n?r.key=N.ESC+"[1;"+(n+1)+"F":t?r.key=N.ESC+"OF":r.key=N.ESC+"[F";break;case 33:e.shiftKey?r.type=2:e.ctrlKey?r.key=N.ESC+"[5;"+(n+1)+"~":r.key=N.ESC+"[5~";break;case 34:e.shiftKey?r.type=3:e.ctrlKey?r.key=N.ESC+"[6;"+(n+1)+"~":r.key=N.ESC+"[6~";break;case 112:n?r.key=N.ESC+"[1;"+(n+1)+"P":r.key=N.ESC+"OP";break;case 113:n?r.key=N.ESC+"[1;"+(n+1)+"Q":r.key=N.ESC+"OQ";break;case 114:n?r.key=N.ESC+"[1;"+(n+1)+"R":r.key=N.ESC+"OR";break;case 115:n?r.key=N.ESC+"[1;"+(n+1)+"S":r.key=N.ESC+"OS";break;case 116:n?r.key=N.ESC+"[15;"+(n+1)+"~":r.key=N.ESC+"[15~";break;case 117:n?r.key=N.ESC+"[17;"+(n+1)+"~":r.key=N.ESC+"[17~";break;case 118:n?r.key=N.ESC+"[18;"+(n+1)+"~":r.key=N.ESC+"[18~";break;case 119:n?r.key=N.ESC+"[19;"+(n+1)+"~":r.key=N.ESC+"[19~";break;case 120:n?r.key=N.ESC+"[20;"+(n+1)+"~":r.key=N.ESC+"[20~";break;case 121:n?r.key=N.ESC+"[21;"+(n+1)+"~":r.key=N.ESC+"[21~";break;case 122:n?r.key=N.ESC+"[23;"+(n+1)+"~":r.key=N.ESC+"[23~";break;case 123:n?r.key=N.ESC+"[24;"+(n+1)+"~":r.key=N.ESC+"[24~";break;default:if(e.ctrlKey&&!e.shiftKey&&!e.altKey&&!e.metaKey)e.keyCode>=65&&e.keyCode<=90?r.key=String.fromCharCode(e.keyCode-64):e.keyCode===32?r.key=N.NUL:e.keyCode>=51&&e.keyCode<=55?r.key=String.fromCharCode(e.keyCode-51+27):e.keyCode===56?r.key=N.DEL:e.keyCode===219?r.key=N.ESC:e.keyCode===220?r.key=N.FS:e.keyCode===221&&(r.key=N.GS);else if((!s||i)&&e.altKey&&!e.metaKey){let l=(a=em[e.keyCode])==null?void 0:a[e.shiftKey?1:0];if(l)r.key=N.ESC+l;else if(e.keyCode>=65&&e.keyCode<=90){let h=e.ctrlKey?e.keyCode-64:e.keyCode+32,c=String.fromCharCode(h);e.shiftKey&&(c=c.toUpperCase()),r.key=N.ESC+c}else if(e.keyCode===32)r.key=N.ESC+(e.ctrlKey?N.NUL:" ");else if(e.key==="Dead"&&e.code.startsWith("Key")){let h=e.code.slice(3,4);e.shiftKey||(h=h.toLowerCase()),r.key=N.ESC+h,r.cancel=!0}}else s&&!e.altKey&&!e.ctrlKey&&!e.shiftKey&&e.metaKey?e.keyCode===65&&(r.type=1):e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.keyCode>=48&&e.key.length===1?r.key=e.key:e.key&&e.ctrlKey&&(e.key==="_"&&(r.key=N.US),e.key==="@"&&(r.key=N.NUL));break}return r}var ye=0,sm=class{constructor(e){this._getKey=e,this._array=[],this._insertedValues=[],this._flushInsertedTask=new zi,this._isFlushingInserted=!1,this._deletedIndices=[],this._flushDeletedTask=new zi,this._isFlushingDeleted=!1}clear(){this._array.length=0,this._insertedValues.length=0,this._flushInsertedTask.clear(),this._isFlushingInserted=!1,this._deletedIndices.length=0,this._flushDeletedTask.clear(),this._isFlushingDeleted=!1}insert(e){this._flushCleanupDeleted(),this._insertedValues.length===0&&this._flushInsertedTask.enqueue(()=>this._flushInserted()),this._insertedValues.push(e)}_flushInserted(){let e=this._insertedValues.sort((r,n)=>this._getKey(r)-this._getKey(n)),t=0,s=0,i=new Array(this._array.length+this._insertedValues.length);for(let r=0;r<i.length;r++)s>=this._array.length||this._getKey(e[t])<=this._getKey(this._array[s])?(i[r]=e[t],t++):i[r]=this._array[s++];this._array=i,this._insertedValues.length=0}_flushCleanupInserted(){!this._isFlushingInserted&&this._insertedValues.length>0&&this._flushInsertedTask.flush()}delete(e){if(this._flushCleanupInserted(),this._array.length===0)return!1;let t=this._getKey(e);if(t===void 0||(ye=this._search(t),ye===-1)||this._getKey(this._array[ye])!==t)return!1;do if(this._array[ye]===e)return this._deletedIndices.length===0&&this._flushDeletedTask.enqueue(()=>this._flushDeleted()),this._deletedIndices.push(ye),!0;while(++ye<this._array.length&&this._getKey(this._array[ye])===t);return!1}_flushDeleted(){this._isFlushingDeleted=!0;let e=this._deletedIndices.sort((r,n)=>r-n),t=0,s=new Array(this._array.length-e.length),i=0;for(let r=0;r<this._array.length;r++)e[t]===r?t++:s[i++]=this._array[r];this._array=s,this._deletedIndices.length=0,this._isFlushingDeleted=!1}_flushCleanupDeleted(){!this._isFlushingDeleted&&this._deletedIndices.length>0&&this._flushDeletedTask.flush()}*getKeyIterator(e){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ye=this._search(e),!(ye<0||ye>=this._array.length)&&this._getKey(this._array[ye])===e))do yield this._array[ye];while(++ye<this._array.length&&this._getKey(this._array[ye])===e)}forEachByKey(e,t){if(this._flushCleanupInserted(),this._flushCleanupDeleted(),this._array.length!==0&&(ye=this._search(e),!(ye<0||ye>=this._array.length)&&this._getKey(this._array[ye])===e))do t(this._array[ye]);while(++ye<this._array.length&&this._getKey(this._array[ye])===e)}values(){return this._flushCleanupInserted(),this._flushCleanupDeleted(),[...this._array].values()}_search(e){let t=0,s=this._array.length-1;for(;s>=t;){let i=t+s>>1,r=this._getKey(this._array[i]);if(r>e)s=i-1;else if(r<e)t=i+1;else{for(;i>0&&this._getKey(this._array[i-1])===e;)i--;return i}}return t}},pr=0,Na=0,im=class extends re{constructor(){super(),this._decorations=new sm(e=>e==null?void 0:e.marker.line),this._onDecorationRegistered=this._register(new T),this.onDecorationRegistered=this._onDecorationRegistered.event,this._onDecorationRemoved=this._register(new T),this.onDecorationRemoved=this._onDecorationRemoved.event,this._register(_e(()=>this.reset()))}get decorations(){return this._decorations.values()}registerDecoration(e){if(e.marker.isDisposed)return;let t=new rm(e);if(t){let s=t.marker.onDispose(()=>t.dispose()),i=t.onDispose(()=>{i.dispose(),t&&(this._decorations.delete(t)&&this._onDecorationRemoved.fire(t),s.dispose())});this._decorations.insert(t),this._onDecorationRegistered.fire(t)}return t}reset(){for(let e of this._decorations.values())e.dispose();this._decorations.clear()}*getDecorationsAtCell(e,t,s){let i=0,r=0;for(let n of this._decorations.getKeyIterator(t))i=n.options.x??0,r=i+(n.options.width??1),e>=i&&e<r&&(!s||(n.options.layer??"bottom")===s)&&(yield n)}forEachDecorationAtCell(e,t,s,i){this._decorations.forEachByKey(t,r=>{pr=r.options.x??0,Na=pr+(r.options.width??1),e>=pr&&e<Na&&(!s||(r.options.layer??"bottom")===s)&&i(r)})}},rm=class extends Pt{constructor(e){super(),this.options=e,this.onRenderEmitter=this.add(new T),this.onRender=this.onRenderEmitter.event,this._onDispose=this.add(new T),this.onDispose=this._onDispose.event,this._cachedBg=null,this._cachedFg=null,this.marker=e.marker,this.options.overviewRulerOptions&&!this.options.overviewRulerOptions.position&&(this.options.overviewRulerOptions.position="full")}get backgroundColorRGB(){return this._cachedBg===null&&(this.options.backgroundColor?this._cachedBg=ge.toColor(this.options.backgroundColor):this._cachedBg=void 0),this._cachedBg}get foregroundColorRGB(){return this._cachedFg===null&&(this.options.foregroundColor?this._cachedFg=ge.toColor(this.options.foregroundColor):this._cachedFg=void 0),this._cachedFg}dispose(){this._onDispose.fire(),super.dispose()}},nm=1e3,om=class{constructor(e,t=nm){this._renderCallback=e,this._debounceThresholdMS=t,this._lastRefreshMs=0,this._additionalRefreshRequested=!1}dispose(){this._refreshTimeoutID&&clearTimeout(this._refreshTimeoutID)}refresh(e,t,s){this._rowCount=s,e=e!==void 0?e:0,t=t!==void 0?t:this._rowCount-1,this._rowStart=this._rowStart!==void 0?Math.min(this._rowStart,e):e,this._rowEnd=this._rowEnd!==void 0?Math.max(this._rowEnd,t):t;let i=performance.now();if(i-this._lastRefreshMs>=this._debounceThresholdMS)this._lastRefreshMs=i,this._innerRefresh();else if(!this._additionalRefreshRequested){let r=i-this._lastRefreshMs,n=this._debounceThresholdMS-r;this._additionalRefreshRequested=!0,this._refreshTimeoutID=window.setTimeout(()=>{this._lastRefreshMs=performance.now(),this._innerRefresh(),this._additionalRefreshRequested=!1,this._refreshTimeoutID=void 0},n)}}_innerRefresh(){if(this._rowStart===void 0||this._rowEnd===void 0||this._rowCount===void 0)return;let e=Math.max(this._rowStart,0),t=Math.min(this._rowEnd,this._rowCount-1);this._rowStart=void 0,this._rowEnd=void 0,this._renderCallback(e,t)}},ja=20,Ti=class extends re{constructor(e,t,s,i){super(),this._terminal=e,this._coreBrowserService=s,this._renderService=i,this._rowColumns=new WeakMap,this._liveRegionLineCount=0,this._charsToConsume=[],this._charsToAnnounce="";let r=this._coreBrowserService.mainDocument;this._accessibilityContainer=r.createElement("div"),this._accessibilityContainer.classList.add("xterm-accessibility"),this._rowContainer=r.createElement("div"),this._rowContainer.setAttribute("role","list"),this._rowContainer.classList.add("xterm-accessibility-tree"),this._rowElements=[];for(let n=0;n<this._terminal.rows;n++)this._rowElements[n]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[n]);if(this._topBoundaryFocusListener=n=>this._handleBoundaryFocus(n,0),this._bottomBoundaryFocusListener=n=>this._handleBoundaryFocus(n,1),this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._accessibilityContainer.appendChild(this._rowContainer),this._liveRegion=r.createElement("div"),this._liveRegion.classList.add("live-region"),this._liveRegion.setAttribute("aria-live","assertive"),this._accessibilityContainer.appendChild(this._liveRegion),this._liveRegionDebouncer=this._register(new om(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(n=>this._handleResize(n.rows))),this._register(this._terminal.onRender(n=>this._refreshRows(n.start,n.end))),this._register(this._terminal.onScroll(()=>this._refreshRows())),this._register(this._terminal.onA11yChar(n=>this._handleChar(n))),this._register(this._terminal.onLineFeed(()=>this._handleChar(`
240
+ `))),this._register(this._terminal.onA11yTab(n=>this._handleTab(n))),this._register(this._terminal.onKey(n=>this._handleKey(n.key))),this._register(this._terminal.onBlur(()=>this._clearLiveRegion())),this._register(this._renderService.onDimensionsChange(()=>this._refreshRowsDimensions())),this._register(G(r,"selectionchange",()=>this._handleSelectionChange())),this._register(this._coreBrowserService.onDprChange(()=>this._refreshRowsDimensions())),this._refreshRowsDimensions(),this._refreshRows(),this._register(_e(()=>{this._accessibilityContainer.remove(),this._rowElements.length=0}))}_handleTab(e){for(let t=0;t<e;t++)this._handleChar(" ")}_handleChar(e){this._liveRegionLineCount<ja+1&&(this._charsToConsume.length>0?this._charsToConsume.shift()!==e&&(this._charsToAnnounce+=e):this._charsToAnnounce+=e,e===`
241
+ `&&(this._liveRegionLineCount++,this._liveRegionLineCount===ja+1&&(this._liveRegion.textContent+=kr.get())))}_clearLiveRegion(){this._liveRegion.textContent="",this._liveRegionLineCount=0}_handleKey(e){this._clearLiveRegion(),new RegExp("\\p{Control}","u").test(e)||this._charsToConsume.push(e)}_refreshRows(e,t){this._liveRegionDebouncer.refresh(e,t,this._terminal.rows)}_renderRows(e,t){let s=this._terminal.buffer,i=s.lines.length.toString();for(let r=e;r<=t;r++){let n=s.lines.get(s.ydisp+r),a=[],l=(n==null?void 0:n.translateToString(!0,void 0,void 0,a))||"",h=(s.ydisp+r+1).toString(),c=this._rowElements[r];c&&(l.length===0?(c.textContent=" ",this._rowColumns.set(c,[0,1])):(c.textContent=l,this._rowColumns.set(c,a)),c.setAttribute("aria-posinset",h),c.setAttribute("aria-setsize",i),this._alignRowWidth(c))}this._announceCharacters()}_announceCharacters(){this._charsToAnnounce.length!==0&&(this._liveRegion.textContent+=this._charsToAnnounce,this._charsToAnnounce="")}_handleBoundaryFocus(e,t){let s=e.target,i=this._rowElements[t===0?1:this._rowElements.length-2],r=s.getAttribute("aria-posinset"),n=t===0?"1":`${this._terminal.buffer.lines.length}`;if(r===n||e.relatedTarget!==i)return;let a,l;if(t===0?(a=s,l=this._rowElements.pop(),this._rowContainer.removeChild(l)):(a=this._rowElements.shift(),l=s,this._rowContainer.removeChild(a)),a.removeEventListener("focus",this._topBoundaryFocusListener),l.removeEventListener("focus",this._bottomBoundaryFocusListener),t===0){let h=this._createAccessibilityTreeNode();this._rowElements.unshift(h),this._rowContainer.insertAdjacentElement("afterbegin",h)}else{let h=this._createAccessibilityTreeNode();this._rowElements.push(h),this._rowContainer.appendChild(h)}this._rowElements[0].addEventListener("focus",this._topBoundaryFocusListener),this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._terminal.scrollLines(t===0?-1:1),this._rowElements[t===0?1:this._rowElements.length-2].focus(),e.preventDefault(),e.stopImmediatePropagation()}_handleSelectionChange(){var l;if(this._rowElements.length===0)return;let e=this._coreBrowserService.mainDocument.getSelection();if(!e)return;if(e.isCollapsed){this._rowContainer.contains(e.anchorNode)&&this._terminal.clearSelection();return}if(!e.anchorNode||!e.focusNode){console.error("anchorNode and/or focusNode are null");return}let t={node:e.anchorNode,offset:e.anchorOffset},s={node:e.focusNode,offset:e.focusOffset};if((t.node.compareDocumentPosition(s.node)&Node.DOCUMENT_POSITION_PRECEDING||t.node===s.node&&t.offset>s.offset)&&([t,s]=[s,t]),t.node.compareDocumentPosition(this._rowElements[0])&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_FOLLOWING)&&(t={node:this._rowElements[0].childNodes[0],offset:0}),!this._rowContainer.contains(t.node))return;let i=this._rowElements.slice(-1)[0];if(s.node.compareDocumentPosition(i)&(Node.DOCUMENT_POSITION_CONTAINED_BY|Node.DOCUMENT_POSITION_PRECEDING)&&(s={node:i,offset:((l=i.textContent)==null?void 0:l.length)??0}),!this._rowContainer.contains(s.node))return;let r=({node:h,offset:c})=>{let d=h instanceof Text?h.parentNode:h,f=parseInt(d==null?void 0:d.getAttribute("aria-posinset"),10)-1;if(isNaN(f))return console.warn("row is invalid. Race condition?"),null;let u=this._rowColumns.get(d);if(!u)return console.warn("columns is null. Race condition?"),null;let g=c<u.length?u[c]:u.slice(-1)[0]+1;return g>=this._terminal.cols&&(++f,g=0),{row:f,column:g}},n=r(t),a=r(s);if(!(!n||!a)){if(n.row>a.row||n.row===a.row&&n.column>=a.column)throw new Error("invalid range");this._terminal.select(n.column,n.row,(a.row-n.row)*this._terminal.cols-n.column+a.column)}}_handleResize(e){this._rowElements[this._rowElements.length-1].removeEventListener("focus",this._bottomBoundaryFocusListener);for(let t=this._rowContainer.children.length;t<this._terminal.rows;t++)this._rowElements[t]=this._createAccessibilityTreeNode(),this._rowContainer.appendChild(this._rowElements[t]);for(;this._rowElements.length>e;)this._rowContainer.removeChild(this._rowElements.pop());this._rowElements[this._rowElements.length-1].addEventListener("focus",this._bottomBoundaryFocusListener),this._refreshRowsDimensions()}_createAccessibilityTreeNode(){let e=this._coreBrowserService.mainDocument.createElement("div");return e.setAttribute("role","listitem"),e.tabIndex=-1,this._refreshRowDimensions(e),e}_refreshRowsDimensions(){if(this._renderService.dimensions.css.cell.height){Object.assign(this._accessibilityContainer.style,{width:`${this._renderService.dimensions.css.canvas.width}px`,fontSize:`${this._terminal.options.fontSize}px`}),this._rowElements.length!==this._terminal.rows&&this._handleResize(this._terminal.rows);for(let e=0;e<this._terminal.rows;e++)this._refreshRowDimensions(this._rowElements[e]),this._alignRowWidth(this._rowElements[e])}}_refreshRowDimensions(e){e.style.height=`${this._renderService.dimensions.css.cell.height}px`}_alignRowWidth(e){var r,n;e.style.transform="";let t=e.getBoundingClientRect().width,s=(n=(r=this._rowColumns.get(e))==null?void 0:r.slice(-1))==null?void 0:n[0];if(!s)return;let i=s*this._renderService.dimensions.css.cell.width;e.style.transform=`scaleX(${i/t})`}};Ti=be([H(1,wn),H(2,bt),H(3,yt)],Ti);var an=class extends re{constructor(e,t,s,i,r){super(),this._element=e,this._mouseService=t,this._renderService=s,this._bufferService=i,this._linkProviderService=r,this._linkCacheDisposables=[],this._isMouseOut=!0,this._wasResized=!1,this._activeLine=-1,this._onShowLinkUnderline=this._register(new T),this.onShowLinkUnderline=this._onShowLinkUnderline.event,this._onHideLinkUnderline=this._register(new T),this.onHideLinkUnderline=this._onHideLinkUnderline.event,this._register(_e(()=>{var n;Vt(this._linkCacheDisposables),this._linkCacheDisposables.length=0,this._lastMouseEvent=void 0,(n=this._activeProviderReplies)==null||n.clear()})),this._register(this._bufferService.onResize(()=>{this._clearCurrentLink(),this._wasResized=!0})),this._register(G(this._element,"mouseleave",()=>{this._isMouseOut=!0,this._clearCurrentLink()})),this._register(G(this._element,"mousemove",this._handleMouseMove.bind(this))),this._register(G(this._element,"mousedown",this._handleMouseDown.bind(this))),this._register(G(this._element,"mouseup",this._handleMouseUp.bind(this)))}get currentLink(){return this._currentLink}_handleMouseMove(e){this._lastMouseEvent=e;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);if(!t)return;this._isMouseOut=!1;let s=e.composedPath();for(let i=0;i<s.length;i++){let r=s[i];if(r.classList.contains("xterm"))break;if(r.classList.contains("xterm-hover"))return}(!this._lastBufferCell||t.x!==this._lastBufferCell.x||t.y!==this._lastBufferCell.y)&&(this._handleHover(t),this._lastBufferCell=t)}_handleHover(e){if(this._activeLine!==e.y||this._wasResized){this._clearCurrentLink(),this._askForLink(e,!1),this._wasResized=!1;return}this._currentLink&&this._linkAtPosition(this._currentLink.link,e)||(this._clearCurrentLink(),this._askForLink(e,!0))}_askForLink(e,t){var i,r;(!this._activeProviderReplies||!t)&&((i=this._activeProviderReplies)==null||i.forEach(n=>{n==null||n.forEach(a=>{a.link.dispose&&a.link.dispose()})}),this._activeProviderReplies=new Map,this._activeLine=e.y);let s=!1;for(let[n,a]of this._linkProviderService.linkProviders.entries())t?(r=this._activeProviderReplies)!=null&&r.get(n)&&(s=this._checkLinkProviderResult(n,e,s)):a.provideLinks(e.y,l=>{var c,d;if(this._isMouseOut)return;let h=l==null?void 0:l.map(f=>({link:f}));(c=this._activeProviderReplies)==null||c.set(n,h),s=this._checkLinkProviderResult(n,e,s),((d=this._activeProviderReplies)==null?void 0:d.size)===this._linkProviderService.linkProviders.length&&this._removeIntersectingLinks(e.y,this._activeProviderReplies)})}_removeIntersectingLinks(e,t){let s=new Set;for(let i=0;i<t.size;i++){let r=t.get(i);if(r)for(let n=0;n<r.length;n++){let a=r[n],l=a.link.range.start.y<e?0:a.link.range.start.x,h=a.link.range.end.y>e?this._bufferService.cols:a.link.range.end.x;for(let c=l;c<=h;c++){if(s.has(c)){r.splice(n--,1);break}s.add(c)}}}}_checkLinkProviderResult(e,t,s){var n;if(!this._activeProviderReplies)return s;let i=this._activeProviderReplies.get(e),r=!1;for(let a=0;a<e;a++)(!this._activeProviderReplies.has(a)||this._activeProviderReplies.get(a))&&(r=!0);if(!r&&i){let a=i.find(l=>this._linkAtPosition(l.link,t));a&&(s=!0,this._handleNewLink(a))}if(this._activeProviderReplies.size===this._linkProviderService.linkProviders.length&&!s)for(let a=0;a<this._activeProviderReplies.size;a++){let l=(n=this._activeProviderReplies.get(a))==null?void 0:n.find(h=>this._linkAtPosition(h.link,t));if(l){s=!0,this._handleNewLink(l);break}}return s}_handleMouseDown(){this._mouseDownLink=this._currentLink}_handleMouseUp(e){if(!this._currentLink)return;let t=this._positionFromMouseEvent(e,this._element,this._mouseService);t&&this._mouseDownLink&&am(this._mouseDownLink.link,this._currentLink.link)&&this._linkAtPosition(this._currentLink.link,t)&&this._currentLink.link.activate(e,this._currentLink.link.text)}_clearCurrentLink(e,t){!this._currentLink||!this._lastMouseEvent||(!e||!t||this._currentLink.link.range.start.y>=e&&this._currentLink.link.range.end.y<=t)&&(this._linkLeave(this._element,this._currentLink.link,this._lastMouseEvent),this._currentLink=void 0,Vt(this._linkCacheDisposables),this._linkCacheDisposables.length=0)}_handleNewLink(e){if(!this._lastMouseEvent)return;let t=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);t&&this._linkAtPosition(e.link,t)&&(this._currentLink=e,this._currentLink.state={decorations:{underline:e.link.decorations===void 0?!0:e.link.decorations.underline,pointerCursor:e.link.decorations===void 0?!0:e.link.decorations.pointerCursor},isHovered:!0},this._linkHover(this._element,e.link,this._lastMouseEvent),e.link.decorations={},Object.defineProperties(e.link.decorations,{pointerCursor:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.pointerCursor},set:s=>{var i;(i=this._currentLink)!=null&&i.state&&this._currentLink.state.decorations.pointerCursor!==s&&(this._currentLink.state.decorations.pointerCursor=s,this._currentLink.state.isHovered&&this._element.classList.toggle("xterm-cursor-pointer",s))}},underline:{get:()=>{var s,i;return(i=(s=this._currentLink)==null?void 0:s.state)==null?void 0:i.decorations.underline},set:s=>{var i,r,n;(i=this._currentLink)!=null&&i.state&&((n=(r=this._currentLink)==null?void 0:r.state)==null?void 0:n.decorations.underline)!==s&&(this._currentLink.state.decorations.underline=s,this._currentLink.state.isHovered&&this._fireUnderlineEvent(e.link,s))}}}),this._linkCacheDisposables.push(this._renderService.onRenderedViewportChange(s=>{if(!this._currentLink)return;let i=s.start===0?0:s.start+1+this._bufferService.buffer.ydisp,r=this._bufferService.buffer.ydisp+1+s.end;if(this._currentLink.link.range.start.y>=i&&this._currentLink.link.range.end.y<=r&&(this._clearCurrentLink(i,r),this._lastMouseEvent)){let n=this._positionFromMouseEvent(this._lastMouseEvent,this._element,this._mouseService);n&&this._askForLink(n,!1)}})))}_linkHover(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!0,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!0),this._currentLink.state.decorations.pointerCursor&&e.classList.add("xterm-cursor-pointer")),t.hover&&t.hover(s,t.text)}_fireUnderlineEvent(e,t){let s=e.range,i=this._bufferService.buffer.ydisp,r=this._createLinkUnderlineEvent(s.start.x-1,s.start.y-i-1,s.end.x,s.end.y-i-1,void 0);(t?this._onShowLinkUnderline:this._onHideLinkUnderline).fire(r)}_linkLeave(e,t,s){var i;(i=this._currentLink)!=null&&i.state&&(this._currentLink.state.isHovered=!1,this._currentLink.state.decorations.underline&&this._fireUnderlineEvent(t,!1),this._currentLink.state.decorations.pointerCursor&&e.classList.remove("xterm-cursor-pointer")),t.leave&&t.leave(s,t.text)}_linkAtPosition(e,t){let s=e.range.start.y*this._bufferService.cols+e.range.start.x,i=e.range.end.y*this._bufferService.cols+e.range.end.x,r=t.y*this._bufferService.cols+t.x;return s<=r&&r<=i}_positionFromMouseEvent(e,t,s){let i=s.getCoords(e,t,this._bufferService.cols,this._bufferService.rows);if(i)return{x:i[0],y:i[1]+this._bufferService.buffer.ydisp}}_createLinkUnderlineEvent(e,t,s,i,r){return{x1:e,y1:t,x2:s,y2:i,cols:this._bufferService.cols,fg:r}}};an=be([H(1,Cn),H(2,yt),H(3,Fe),H(4,Bl)],an);function am(e,t){return e.text===t.text&&e.range.start.x===t.range.start.x&&e.range.start.y===t.range.start.y&&e.range.end.x===t.range.end.x&&e.range.end.y===t.range.end.y}var lm=class extends Q_{constructor(e={}){super(e),this._linkifier=this._register(new ps),this.browser=Ql,this._keyDownHandled=!1,this._keyDownSeen=!1,this._keyPressHandled=!1,this._unprocessedDeadKey=!1,this._accessibilityManager=this._register(new ps),this._onCursorMove=this._register(new T),this.onCursorMove=this._onCursorMove.event,this._onKey=this._register(new T),this.onKey=this._onKey.event,this._onRender=this._register(new T),this.onRender=this._onRender.event,this._onSelectionChange=this._register(new T),this.onSelectionChange=this._onSelectionChange.event,this._onTitleChange=this._register(new T),this.onTitleChange=this._onTitleChange.event,this._onBell=this._register(new T),this.onBell=this._onBell.event,this._onFocus=this._register(new T),this._onBlur=this._register(new T),this._onA11yCharEmitter=this._register(new T),this._onA11yTabEmitter=this._register(new T),this._onWillOpen=this._register(new T),this._setup(),this._decorationService=this._instantiationService.createInstance(im),this._instantiationService.setService(Gs,this._decorationService),this._linkProviderService=this._instantiationService.createInstance(Jp),this._instantiationService.setService(Bl,this._linkProviderService),this._linkProviderService.registerLinkProvider(this._instantiationService.createInstance(Nr)),this._register(this._inputHandler.onRequestBell(()=>this._onBell.fire())),this._register(this._inputHandler.onRequestRefreshRows(t=>this.refresh((t==null?void 0:t.start)??0,(t==null?void 0:t.end)??this.rows-1))),this._register(this._inputHandler.onRequestSendFocus(()=>this._reportFocus())),this._register(this._inputHandler.onRequestReset(()=>this.reset())),this._register(this._inputHandler.onRequestWindowsOptionsReport(t=>this._reportWindowsOptions(t))),this._register(this._inputHandler.onColor(t=>this._handleColorEvent(t))),this._register(Ae.forward(this._inputHandler.onCursorMove,this._onCursorMove)),this._register(Ae.forward(this._inputHandler.onTitleChange,this._onTitleChange)),this._register(Ae.forward(this._inputHandler.onA11yChar,this._onA11yCharEmitter)),this._register(Ae.forward(this._inputHandler.onA11yTab,this._onA11yTabEmitter)),this._register(this._bufferService.onResize(t=>this._afterResize(t.cols,t.rows))),this._register(_e(()=>{var t,s;this._customKeyEventHandler=void 0,(s=(t=this.element)==null?void 0:t.parentNode)==null||s.removeChild(this.element)}))}get linkifier(){return this._linkifier.value}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}_handleColorEvent(e){if(this._themeService)for(let t of e){let s,i="";switch(t.index){case 256:s="foreground",i="10";break;case 257:s="background",i="11";break;case 258:s="cursor",i="12";break;default:s="ansi",i="4;"+t.index}switch(t.type){case 0:let r=pe.toColorRGB(s==="ansi"?this._themeService.colors.ansi[t.index]:this._themeService.colors[s]);this.coreService.triggerDataEvent(`${N.ESC}]${i};${V_(r)}${Jl.ST}`);break;case 1:if(s==="ansi")this._themeService.modifyColors(n=>n.ansi[t.index]=Ce.toColor(...t.color));else{let n=s;this._themeService.modifyColors(a=>a[n]=Ce.toColor(...t.color))}break;case 2:this._themeService.restoreColor(t.index);break}}}_setup(){super._setup(),this._customKeyEventHandler=void 0}get buffer(){return this.buffers.active}focus(){this.textarea&&this.textarea.focus({preventScroll:!0})}_handleScreenReaderModeOptionChange(e){e?!this._accessibilityManager.value&&this._renderService&&(this._accessibilityManager.value=this._instantiationService.createInstance(Ti,this)):this._accessibilityManager.clear()}_handleTextAreaFocus(e){this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(N.ESC+"[I"),this.element.classList.add("focus"),this._showCursor(),this._onFocus.fire()}blur(){var e;return(e=this.textarea)==null?void 0:e.blur()}_handleTextAreaBlur(){this.textarea.value="",this.refresh(this.buffer.y,this.buffer.y),this.coreService.decPrivateModes.sendFocus&&this.coreService.triggerDataEvent(N.ESC+"[O"),this.element.classList.remove("focus"),this._onBlur.fire()}_syncTextArea(){if(!this.textarea||!this.buffer.isCursorInViewport||this._compositionHelper.isComposing||!this._renderService)return;let e=this.buffer.ybase+this.buffer.y,t=this.buffer.lines.get(e);if(!t)return;let s=Math.min(this.buffer.x,this.cols-1),i=this._renderService.dimensions.css.cell.height,r=t.getWidth(s),n=this._renderService.dimensions.css.cell.width*r,a=this.buffer.y*this._renderService.dimensions.css.cell.height,l=s*this._renderService.dimensions.css.cell.width;this.textarea.style.left=l+"px",this.textarea.style.top=a+"px",this.textarea.style.width=n+"px",this.textarea.style.height=i+"px",this.textarea.style.lineHeight=i+"px",this.textarea.style.zIndex="-5"}_initGlobal(){this._bindKeys(),this._register(G(this.element,"copy",t=>{this.hasSelection()&&uf(t,this._selectionService)}));let e=t=>ff(t,this.textarea,this.coreService,this.optionsService);this._register(G(this.textarea,"paste",e)),this._register(G(this.element,"paste",e)),ec?this._register(G(this.element,"mousedown",t=>{t.button===2&&Oo(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})):this._register(G(this.element,"contextmenu",t=>{Oo(t,this.textarea,this.screenElement,this._selectionService,this.options.rightClickSelectsWord)})),Rn&&this._register(G(this.element,"auxclick",t=>{t.button===1&&kl(t,this.textarea,this.screenElement)}))}_bindKeys(){this._register(G(this.textarea,"keyup",e=>this._keyUp(e),!0)),this._register(G(this.textarea,"keydown",e=>this._keyDown(e),!0)),this._register(G(this.textarea,"keypress",e=>this._keyPress(e),!0)),this._register(G(this.textarea,"compositionstart",()=>this._compositionHelper.compositionstart())),this._register(G(this.textarea,"compositionupdate",e=>this._compositionHelper.compositionupdate(e))),this._register(G(this.textarea,"compositionend",()=>this._compositionHelper.compositionend())),this._register(G(this.textarea,"input",e=>this._inputEvent(e),!0)),this._register(this.onRender(()=>this._compositionHelper.updateCompositionElements()))}open(e){var r;if(!e)throw new Error("Terminal requires a parent element.");if(e.isConnected||this._logService.debug("Terminal.open was called on an element that was not attached to the DOM"),((r=this.element)==null?void 0:r.ownerDocument.defaultView)&&this._coreBrowserService){this.element.ownerDocument.defaultView!==this._coreBrowserService.window&&(this._coreBrowserService.window=this.element.ownerDocument.defaultView);return}this._document=e.ownerDocument,this.options.documentOverride&&this.options.documentOverride instanceof Document&&(this._document=this.optionsService.rawOptions.documentOverride),this.element=this._document.createElement("div"),this.element.dir="ltr",this.element.classList.add("terminal"),this.element.classList.add("xterm"),e.appendChild(this.element);let t=this._document.createDocumentFragment();this._viewportElement=this._document.createElement("div"),this._viewportElement.classList.add("xterm-viewport"),t.appendChild(this._viewportElement),this.screenElement=this._document.createElement("div"),this.screenElement.classList.add("xterm-screen"),this._register(G(this.screenElement,"mousemove",n=>this.updateCursorStyle(n))),this._helperContainer=this._document.createElement("div"),this._helperContainer.classList.add("xterm-helpers"),this.screenElement.appendChild(this._helperContainer),t.appendChild(this.screenElement);let s=this.textarea=this._document.createElement("textarea");this.textarea.classList.add("xterm-helper-textarea"),this.textarea.setAttribute("aria-label",Cr.get()),ic||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._register(this.optionsService.onSpecificOptionChange("disableStdin",()=>s.readOnly=this.optionsService.rawOptions.disableStdin)),this.textarea.readOnly=this.optionsService.rawOptions.disableStdin,this._coreBrowserService=this._register(this._instantiationService.createInstance(Gp,this.textarea,e.ownerDocument.defaultView??window,this._document??typeof window<"u"?window.document:null)),this._instantiationService.setService(bt,this._coreBrowserService),this._register(G(this.textarea,"focus",n=>this._handleTextAreaFocus(n))),this._register(G(this.textarea,"blur",()=>this._handleTextAreaBlur())),this._helperContainer.appendChild(this.textarea),this._charSizeService=this._instantiationService.createInstance(Yr,this._document,this._helperContainer),this._instantiationService.setService(Wi,this._charSizeService),this._themeService=this._instantiationService.createInstance(Zr),this._instantiationService.setService(_s,this._themeService),this._characterJoinerService=this._instantiationService.createInstance(Li),this._instantiationService.setService(Ll,this._characterJoinerService),this._renderService=this._register(this._instantiationService.createInstance(Xr,this.rows,this.screenElement)),this._instantiationService.setService(yt,this._renderService),this._register(this._renderService.onRenderedViewportChange(n=>this._onRender.fire(n))),this.onResize(n=>this._renderService.resize(n.cols,n.rows)),this._compositionView=this._document.createElement("div"),this._compositionView.classList.add("composition-view"),this._compositionHelper=this._instantiationService.createInstance(Kr,this.textarea,this._compositionView),this._helperContainer.appendChild(this._compositionView),this._mouseService=this._instantiationService.createInstance(Gr),this._instantiationService.setService(Cn,this._mouseService);let i=this._linkifier.value=this._register(this._instantiationService.createInstance(an,this.screenElement));this.element.appendChild(t);try{this._onWillOpen.fire(this.element)}catch{}this._renderService.hasRenderer()||this._renderService.setRenderer(this._createRenderer()),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._viewport=this._register(this._instantiationService.createInstance(Wr,this.element,this.screenElement)),this._register(this._viewport.onRequestScrollLines(n=>{super.scrollLines(n,!1),this.refresh(0,this.rows-1)})),this._selectionService=this._register(this._instantiationService.createInstance(Jr,this.element,this.screenElement,i)),this._instantiationService.setService(yf,this._selectionService),this._register(this._selectionService.onRequestScrollLines(n=>this.scrollLines(n.amount,n.suppressScrollEvent))),this._register(this._selectionService.onSelectionChange(()=>this._onSelectionChange.fire())),this._register(this._selectionService.onRequestRedraw(n=>this._renderService.handleSelectionChanged(n.start,n.end,n.columnSelectMode))),this._register(this._selectionService.onLinuxMouseSelection(n=>{this.textarea.value=n,this.textarea.focus(),this.textarea.select()})),this._register(Ae.any(this._onScroll.event,this._inputHandler.onScroll)(()=>{var n;this._selectionService.refresh(),(n=this._viewport)==null||n.queueSync()})),this._register(this._instantiationService.createInstance(Ur,this.screenElement)),this._register(G(this.element,"mousedown",n=>this._selectionService.handleMouseDown(n))),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(Ti,this)),this._register(this.optionsService.onSpecificOptionChange("screenReaderMode",n=>this._handleScreenReaderModeOptionChange(n))),this.options.overviewRuler.width&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ri,this._viewportElement,this.screenElement))),this.optionsService.onSpecificOptionChange("overviewRuler",n=>{!this._overviewRulerRenderer&&n&&this._viewportElement&&this.screenElement&&(this._overviewRulerRenderer=this._register(this._instantiationService.createInstance(Ri,this._viewportElement,this.screenElement)))}),this._charSizeService.measure(),this.refresh(0,this.rows-1),this._initGlobal(),this.bindMouse()}_createRenderer(){return this._instantiationService.createInstance(Vr,this,this._document,this.element,this.screenElement,this._viewportElement,this._helperContainer,this.linkifier)}bindMouse(){let e=this,t=this.element;function s(n){var c,d,f,u,g;let a=e._mouseService.getMouseReportCoords(n,e.screenElement);if(!a)return!1;let l,h;switch(n.overrideType||n.type){case"mousemove":h=32,n.buttons===void 0?(l=3,n.button!==void 0&&(l=n.button<3?n.button:3)):l=n.buttons&1?0:n.buttons&4?1:n.buttons&2?2:3;break;case"mouseup":h=0,l=n.button<3?n.button:3;break;case"mousedown":h=1,l=n.button<3?n.button:3;break;case"wheel":if(e._customWheelEventHandler&&e._customWheelEventHandler(n)===!1)return!1;let p=n.deltaY;if(p===0||e.coreMouseService.consumeWheelEvent(n,(u=(f=(d=(c=e._renderService)==null?void 0:c.dimensions)==null?void 0:d.device)==null?void 0:f.cell)==null?void 0:u.height,(g=e._coreBrowserService)==null?void 0:g.dpr)===0)return!1;h=p<0?0:1,l=4;break;default:return!1}return h===void 0||l===void 0||l>4?!1:e.coreMouseService.triggerMouseEvent({col:a.col,row:a.row,x:a.x,y:a.y,button:l,action:h,ctrl:n.ctrlKey,alt:n.altKey,shift:n.shiftKey})}let i={mouseup:null,wheel:null,mousedrag:null,mousemove:null},r={mouseup:n=>(s(n),n.buttons||(this._document.removeEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.removeEventListener("mousemove",i.mousedrag)),this.cancel(n)),wheel:n=>(s(n),this.cancel(n,!0)),mousedrag:n=>{n.buttons&&s(n)},mousemove:n=>{n.buttons||s(n)}};this._register(this.coreMouseService.onProtocolChange(n=>{n?(this.optionsService.rawOptions.logLevel==="debug"&&this._logService.debug("Binding to mouse events:",this.coreMouseService.explainEvents(n)),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()),n&8?i.mousemove||(t.addEventListener("mousemove",r.mousemove),i.mousemove=r.mousemove):(t.removeEventListener("mousemove",i.mousemove),i.mousemove=null),n&16?i.wheel||(t.addEventListener("wheel",r.wheel,{passive:!1}),i.wheel=r.wheel):(t.removeEventListener("wheel",i.wheel),i.wheel=null),n&2?i.mouseup||(i.mouseup=r.mouseup):(this._document.removeEventListener("mouseup",i.mouseup),i.mouseup=null),n&4?i.mousedrag||(i.mousedrag=r.mousedrag):(this._document.removeEventListener("mousemove",i.mousedrag),i.mousedrag=null)})),this.coreMouseService.activeProtocol=this.coreMouseService.activeProtocol,this._register(G(t,"mousedown",n=>{if(n.preventDefault(),this.focus(),!(!this.coreMouseService.areMouseEventsActive||this._selectionService.shouldForceSelection(n)))return s(n),i.mouseup&&this._document.addEventListener("mouseup",i.mouseup),i.mousedrag&&this._document.addEventListener("mousemove",i.mousedrag),this.cancel(n)})),this._register(G(t,"wheel",n=>{var a,l,h,c,d;if(!i.wheel){if(this._customWheelEventHandler&&this._customWheelEventHandler(n)===!1)return!1;if(!this.buffer.hasScrollback){if(n.deltaY===0)return!1;if(e.coreMouseService.consumeWheelEvent(n,(c=(h=(l=(a=e._renderService)==null?void 0:a.dimensions)==null?void 0:l.device)==null?void 0:h.cell)==null?void 0:c.height,(d=e._coreBrowserService)==null?void 0:d.dpr)===0)return this.cancel(n,!0);let f=N.ESC+(this.coreService.decPrivateModes.applicationCursorKeys?"O":"[")+(n.deltaY<0?"A":"B");return this.coreService.triggerDataEvent(f,!0),this.cancel(n,!0)}}},{passive:!1}))}refresh(e,t){var s;(s=this._renderService)==null||s.refreshRows(e,t)}updateCursorStyle(e){var t;(t=this._selectionService)!=null&&t.shouldColumnSelect(e)?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(e,t){this._viewport?this._viewport.scrollLines(e):super.scrollLines(e,t),this.refresh(0,this.rows-1)}scrollPages(e){this.scrollLines(e*(this.rows-1))}scrollToTop(){this.scrollLines(-this._bufferService.buffer.ydisp)}scrollToBottom(e){e&&this._viewport?this._viewport.scrollToLine(this.buffer.ybase,!0):this.scrollLines(this._bufferService.buffer.ybase-this._bufferService.buffer.ydisp)}scrollToLine(e){let t=e-this._bufferService.buffer.ydisp;t!==0&&this.scrollLines(t)}paste(e){Cl(e,this.textarea,this.coreService,this.optionsService)}attachCustomKeyEventHandler(e){this._customKeyEventHandler=e}attachCustomWheelEventHandler(e){this._customWheelEventHandler=e}registerLinkProvider(e){return this._linkProviderService.registerLinkProvider(e)}registerCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");let t=this._characterJoinerService.register(e);return this.refresh(0,this.rows-1),t}deregisterCharacterJoiner(e){if(!this._characterJoinerService)throw new Error("Terminal must be opened first");this._characterJoinerService.deregister(e)&&this.refresh(0,this.rows-1)}get markers(){return this.buffer.markers}registerMarker(e){return this.buffer.addMarker(this.buffer.ybase+this.buffer.y+e)}registerDecoration(e){return this._decorationService.registerDecoration(e)}hasSelection(){return this._selectionService?this._selectionService.hasSelection:!1}select(e,t,s){this._selectionService.setSelection(e,t,s)}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 e;(e=this._selectionService)==null||e.clearSelection()}selectAll(){var e;(e=this._selectionService)==null||e.selectAll()}selectLines(e,t){var s;(s=this._selectionService)==null||s.selectLines(e,t)}_keyDown(e){if(this._keyDownHandled=!1,this._keyDownSeen=!0,this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;let t=this.browser.isMac&&this.options.macOptionIsMeta&&e.altKey;if(!t&&!this._compositionHelper.keydown(e))return this.options.scrollOnUserInput&&this.buffer.ybase!==this.buffer.ydisp&&this.scrollToBottom(!0),!1;!t&&(e.key==="Dead"||e.key==="AltGraph")&&(this._unprocessedDeadKey=!0);let s=tm(e,this.coreService.decPrivateModes.applicationCursorKeys,this.browser.isMac,this.options.macOptionIsMeta);if(this.updateCursorStyle(e),s.type===3||s.type===2){let i=this.rows-1;return this.scrollLines(s.type===2?-i:i),this.cancel(e,!0)}if(s.type===1&&this.selectAll(),this._isThirdLevelShift(this.browser,e)||(s.cancel&&this.cancel(e,!0),!s.key)||e.key&&!e.ctrlKey&&!e.altKey&&!e.metaKey&&e.key.length===1&&e.key.charCodeAt(0)>=65&&e.key.charCodeAt(0)<=90)return!0;if(this._unprocessedDeadKey)return this._unprocessedDeadKey=!1,!0;if((s.key===N.ETX||s.key===N.CR)&&(this.textarea.value=""),this._onKey.fire({key:s.key,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(s.key,!0),!this.optionsService.rawOptions.screenReaderMode||e.altKey||e.ctrlKey)return this.cancel(e,!0);this._keyDownHandled=!0}_isThirdLevelShift(e,t){let s=e.isMac&&!this.options.macOptionIsMeta&&t.altKey&&!t.ctrlKey&&!t.metaKey||e.isWindows&&t.altKey&&t.ctrlKey&&!t.metaKey||e.isWindows&&t.getModifierState("AltGraph");return t.type==="keypress"?s:s&&(!t.keyCode||t.keyCode>47)}_keyUp(e){this._keyDownSeen=!1,!(this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)&&(cm(e)||this.focus(),this.updateCursorStyle(e),this._keyPressHandled=!1)}_keyPress(e){let t;if(this._keyPressHandled=!1,this._keyDownHandled||this._customKeyEventHandler&&this._customKeyEventHandler(e)===!1)return!1;if(this.cancel(e),e.charCode)t=e.charCode;else if(e.which===null||e.which===void 0)t=e.keyCode;else if(e.which!==0&&e.charCode!==0)t=e.which;else return!1;return!t||(e.altKey||e.ctrlKey||e.metaKey)&&!this._isThirdLevelShift(this.browser,e)?!1:(t=String.fromCharCode(t),this._onKey.fire({key:t,domEvent:e}),this._showCursor(),this.coreService.triggerDataEvent(t,!0),this._keyPressHandled=!0,this._unprocessedDeadKey=!1,!0)}_inputEvent(e){if(e.data&&e.inputType==="insertText"&&(!e.composed||!this._keyDownSeen)&&!this.optionsService.rawOptions.screenReaderMode){if(this._keyPressHandled)return!1;this._unprocessedDeadKey=!1;let t=e.data;return this.coreService.triggerDataEvent(t,!0),this.cancel(e),!0}return!1}resize(e,t){if(e===this.cols&&t===this.rows){this._charSizeService&&!this._charSizeService.hasValidSize&&this._charSizeService.measure();return}super.resize(e,t)}_afterResize(e,t){var s;(s=this._charSizeService)==null||s.measure()}clear(){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 e=1;e<this.rows;e++)this.buffer.lines.push(this.buffer.getBlankLine(Se));this._onScroll.fire({position:this.buffer.ydisp}),this.refresh(0,this.rows-1)}}reset(){var t;this.options.rows=this.rows,this.options.cols=this.cols;let e=this._customKeyEventHandler;this._setup(),super.reset(),(t=this._selectionService)==null||t.reset(),this._decorationService.reset(),this._customKeyEventHandler=e,this.refresh(0,this.rows-1)}clearTextureAtlas(){var e;(e=this._renderService)==null||e.clearTextureAtlas()}_reportFocus(){var e;(e=this.element)!=null&&e.classList.contains("focus")?this.coreService.triggerDataEvent(N.ESC+"[I"):this.coreService.triggerDataEvent(N.ESC+"[O")}_reportWindowsOptions(e){if(this._renderService)switch(e){case 0:let t=this._renderService.dimensions.css.canvas.width.toFixed(0),s=this._renderService.dimensions.css.canvas.height.toFixed(0);this.coreService.triggerDataEvent(`${N.ESC}[4;${s};${t}t`);break;case 1:let i=this._renderService.dimensions.css.cell.width.toFixed(0),r=this._renderService.dimensions.css.cell.height.toFixed(0);this.coreService.triggerDataEvent(`${N.ESC}[6;${r};${i}t`);break}}cancel(e,t){if(!(!this.options.cancelEvents&&!t))return e.preventDefault(),e.stopPropagation(),!1}};function cm(e){return e.keyCode===16||e.keyCode===17||e.keyCode===18}var hm=class{constructor(){this._addons=[]}dispose(){for(let e=this._addons.length-1;e>=0;e--)this._addons[e].instance.dispose()}loadAddon(e,t){let s={instance:t,dispose:t.dispose,isDisposed:!1};this._addons.push(s),t.dispose=()=>this._wrappedAddonDispose(s),t.activate(e)}_wrappedAddonDispose(e){if(e.isDisposed)return;let t=-1;for(let s=0;s<this._addons.length;s++)if(this._addons[s]===e){t=s;break}if(t===-1)throw new Error("Could not dispose an addon that has not been loaded");e.isDisposed=!0,e.dispose.apply(e.instance),this._addons.splice(t,1)}},dm=class{constructor(e){this._line=e}get isWrapped(){return this._line.isWrapped}get length(){return this._line.length}getCell(e,t){if(!(e<0||e>=this._line.length))return t?(this._line.loadCell(e,t),t):this._line.loadCell(e,new st)}translateToString(e,t,s){return this._line.translateToString(e,t,s)}},Da=class{constructor(e,t){this._buffer=e,this.type=t}init(e){return this._buffer=e,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(e){let t=this._buffer.lines.get(e);if(t)return new dm(t)}getNullCell(){return new st}},um=class extends re{constructor(e){super(),this._core=e,this._onBufferChange=this._register(new T),this.onBufferChange=this._onBufferChange.event,this._normal=new Da(this._core.buffers.normal,"normal"),this._alternate=new Da(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)}},fm=class{constructor(e){this._core=e}registerCsiHandler(e,t){return this._core.registerCsiHandler(e,s=>t(s.toArray()))}addCsiHandler(e,t){return this.registerCsiHandler(e,t)}registerDcsHandler(e,t){return this._core.registerDcsHandler(e,(s,i)=>t(s,i.toArray()))}addDcsHandler(e,t){return this.registerDcsHandler(e,t)}registerEscHandler(e,t){return this._core.registerEscHandler(e,t)}addEscHandler(e,t){return this.registerEscHandler(e,t)}registerOscHandler(e,t){return this._core.registerOscHandler(e,t)}addOscHandler(e,t){return this.registerOscHandler(e,t)}},pm=class{constructor(e){this._core=e}register(e){this._core.unicodeService.register(e)}get versions(){return this._core.unicodeService.versions}get activeVersion(){return this._core.unicodeService.activeVersion}set activeVersion(e){this._core.unicodeService.activeVersion=e}},_m=["cols","rows"],nt=0,mm=class extends re{constructor(e){super(),this._core=this._register(new lm(e)),this._addonManager=this._register(new hm),this._publicOptions={...this._core.options};let t=i=>this._core.options[i],s=(i,r)=>{this._checkReadonlyOptions(i),this._core.options[i]=r};for(let i in this._core.options){let r={get:t.bind(this,i),set:s.bind(this,i)};Object.defineProperty(this._publicOptions,i,r)}}_checkReadonlyOptions(e){if(_m.includes(e))throw new Error(`Option "${e}" 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 fm(this._core)),this._parser}get unicode(){return this._checkProposedApi(),new pm(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 um(this._core))),this._buffer}get markers(){return this._checkProposedApi(),this._core.markers}get modes(){let e=this._core.coreService.decPrivateModes,t="none";switch(this._core.coreMouseService.activeProtocol){case"X10":t="x10";break;case"VT200":t="vt200";break;case"DRAG":t="drag";break;case"ANY":t="any";break}return{applicationCursorKeysMode:e.applicationCursorKeys,applicationKeypadMode:e.applicationKeypad,bracketedPasteMode:e.bracketedPasteMode,insertMode:this._core.coreService.modes.insertMode,mouseTrackingMode:t,originMode:e.origin,reverseWraparoundMode:e.reverseWraparound,sendFocusMode:e.sendFocus,synchronizedOutputMode:e.synchronizedOutput,wraparoundMode:e.wraparound}}get options(){return this._publicOptions}set options(e){for(let t in e)this._publicOptions[t]=e[t]}blur(){this._core.blur()}focus(){this._core.focus()}input(e,t=!0){this._core.input(e,t)}resize(e,t){this._verifyIntegers(e,t),this._core.resize(e,t)}open(e){this._core.open(e)}attachCustomKeyEventHandler(e){this._core.attachCustomKeyEventHandler(e)}attachCustomWheelEventHandler(e){this._core.attachCustomWheelEventHandler(e)}registerLinkProvider(e){return this._core.registerLinkProvider(e)}registerCharacterJoiner(e){return this._checkProposedApi(),this._core.registerCharacterJoiner(e)}deregisterCharacterJoiner(e){this._checkProposedApi(),this._core.deregisterCharacterJoiner(e)}registerMarker(e=0){return this._verifyIntegers(e),this._core.registerMarker(e)}registerDecoration(e){return this._checkProposedApi(),this._verifyPositiveIntegers(e.x??0,e.width??0,e.height??0),this._core.registerDecoration(e)}hasSelection(){return this._core.hasSelection()}select(e,t,s){this._verifyIntegers(e,t,s),this._core.select(e,t,s)}getSelection(){return this._core.getSelection()}getSelectionPosition(){return this._core.getSelectionPosition()}clearSelection(){this._core.clearSelection()}selectAll(){this._core.selectAll()}selectLines(e,t){this._verifyIntegers(e,t),this._core.selectLines(e,t)}dispose(){super.dispose()}scrollLines(e){this._verifyIntegers(e),this._core.scrollLines(e)}scrollPages(e){this._verifyIntegers(e),this._core.scrollPages(e)}scrollToTop(){this._core.scrollToTop()}scrollToBottom(){this._core.scrollToBottom()}scrollToLine(e){this._verifyIntegers(e),this._core.scrollToLine(e)}clear(){this._core.clear()}write(e,t){this._core.write(e,t)}writeln(e,t){this._core.write(e),this._core.write(`\r
242
+ `,t)}paste(e){this._core.paste(e)}refresh(e,t){this._verifyIntegers(e,t),this._core.refresh(e,t)}reset(){this._core.reset()}clearTextureAtlas(){this._core.clearTextureAtlas()}loadAddon(e){this._addonManager.loadAddon(this,e)}static get strings(){return{get promptLabel(){return Cr.get()},set promptLabel(e){Cr.set(e)},get tooMuchOutput(){return kr.get()},set tooMuchOutput(e){kr.set(e)}}}_verifyIntegers(...e){for(nt of e)if(nt===1/0||isNaN(nt)||nt%1!==0)throw new Error("This API only accepts integers")}_verifyPositiveIntegers(...e){for(nt of e)if(nt&&(nt===1/0||isNaN(nt)||nt%1!==0||nt<0))throw new Error("This API only accepts positive integers")}};/**
243
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
244
+ * @license MIT
245
+ *
246
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
247
+ * @license MIT
248
+ *
249
+ * Originally forked from (with the author's permission):
250
+ * Fabrice Bellard's javascript vt100 for jslinux:
251
+ * http://bellard.org/jslinux/
252
+ * Copyright (c) 2011 Fabrice Bellard
253
+ */var gm=2,vm=1,xm=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(){var f;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:((f=this._terminal.options.overviewRuler)==null?void 0:f.width)||14,s=window.getComputedStyle(this._terminal.element.parentElement),i=parseInt(s.getPropertyValue("height")),r=Math.max(0,parseInt(s.getPropertyValue("width"))),n=window.getComputedStyle(this._terminal.element),a={top:parseInt(n.getPropertyValue("padding-top")),bottom:parseInt(n.getPropertyValue("padding-bottom")),right:parseInt(n.getPropertyValue("padding-right")),left:parseInt(n.getPropertyValue("padding-left"))},l=a.top+a.bottom,h=a.right+a.left,c=i-l,d=r-h-t;return{cols:Math.max(gm,Math.floor(d/e.css.cell.width)),rows:Math.max(vm,Math.floor(c/e.css.cell.height))}}};/**
254
+ * Copyright (c) 2014-2024 The xterm.js authors. All rights reserved.
255
+ * @license MIT
256
+ *
257
+ * Copyright (c) 2012-2013, Christopher Jeffrey (MIT License)
258
+ * @license MIT
259
+ *
260
+ * Originally forked from (with the author's permission):
261
+ * Fabrice Bellard's javascript vt100 for jslinux:
262
+ * http://bellard.org/jslinux/
263
+ * Copyright (c) 2011 Fabrice Bellard
264
+ */var bm=class{constructor(e,t,s,i={}){this._terminal=e,this._regex=t,this._handler=s,this._options=i}provideLinks(e,t){let s=Sm.computeLink(e,this._regex,this._terminal,this._handler);t(this._addCallbacks(s))}_addCallbacks(e){return e.map(t=>(t.leave=this._options.leave,t.hover=(s,i)=>{if(this._options.hover){let{range:r}=t;this._options.hover(s,i,r)}},t))}};function ym(e){try{let t=new URL(e),s=t.password&&t.username?`${t.protocol}//${t.username}:${t.password}@${t.host}`:t.username?`${t.protocol}//${t.username}@${t.host}`:`${t.protocol}//${t.host}`;return e.toLocaleLowerCase().startsWith(s.toLocaleLowerCase())}catch{return!1}}var Sm=class Ni{static computeLink(t,s,i,r){let n=new RegExp(s.source,(s.flags||"")+"g"),[a,l]=Ni._getWindowedLineStrings(t-1,i),h=a.join(""),c,d=[];for(;c=n.exec(h);){let f=c[0];if(!ym(f))continue;let[u,g]=Ni._mapStrIdx(i,l,0,c.index),[p,m]=Ni._mapStrIdx(i,u,g,f.length);if(u===-1||g===-1||p===-1||m===-1)continue;let y={start:{x:g+1,y:u+1},end:{x:m,y:p+1}};d.push({range:y,text:f,activate:r})}return d}static _getWindowedLineStrings(t,s){let i,r=t,n=t,a=0,l="",h=[];if(i=s.buffer.active.getLine(t)){let c=i.translateToString(!0);if(i.isWrapped&&c[0]!==" "){for(a=0;(i=s.buffer.active.getLine(--r))&&a<2048&&(l=i.translateToString(!0),a+=l.length,h.push(l),!(!i.isWrapped||l.indexOf(" ")!==-1)););h.reverse()}for(h.push(c),a=0;(i=s.buffer.active.getLine(++n))&&i.isWrapped&&a<2048&&(l=i.translateToString(!0),a+=l.length,h.push(l),l.indexOf(" ")===-1););}return[h,r]}static _mapStrIdx(t,s,i,r){let n=t.buffer.active,a=n.getNullCell(),l=i;for(;r;){let h=n.getLine(s);if(!h)return[-1,-1];for(let c=l;c<h.length;++c){h.getCell(c,a);let d=a.getChars();if(a.getWidth()&&(r-=d.length||1,c===h.length-1&&d==="")){let f=n.getLine(s+1);f&&f.isWrapped&&(f.getCell(0,a),a.getWidth()===2&&(r+=1))}if(r<0)return[s,c]}s++,l=0}return[s,l]}},wm=/(https?|HTTPS?):[/]{2}[^\s"'!*(){}|\\\^<>`]*[^\s"':,.!?{}|\\\^~\[\]`()<>]/;function Cm(e,t){let s=window.open();if(s){try{s.opener=null}catch{}s.location.href=t}else console.warn("Opening link blocked as opener could not be cleared")}var km=class{constructor(e=Cm,t={}){this._handler=e,this._options=t}activate(e){this._terminal=e;let t=this._options,s=t.urlRegex||wm;this._linkProvider=this._terminal.registerLinkProvider(new bm(this._terminal,s,this._handler,t))}dispose(){var e;(e=this._linkProvider)==null||e.dispose()}};const Ma=10,Em=1e3,Nm=3e4;function jm({sessionId:e,isActive:t}){const s=_.useRef(null),i=_.useRef(null),r=_.useRef(null),n=_.useRef(null),a=_.useRef(null),l=_.useRef(!0),h=_.useRef(0),c=_.useCallback(()=>{const f=n.current,u=i.current;f&&f.readyState===WebSocket.OPEN&&u&&f.send(JSON.stringify({type:"resize",cols:u.cols,rows:u.rows}))},[]),d=_.useCallback(()=>{if(!l.current)return;n.current&&(n.current.onclose=null,n.current.onerror=null,n.current.close(),n.current=null);const u=`${window.location.protocol==="https:"?"wss:":"ws:"}//${window.location.host}/ws/terminal/${e}`,g=new WebSocket(u);n.current=g,g.onopen=()=>{h.current=0;const p=i.current;p&&p.writeln("\x1B[32m-- Terminal connected --\x1B[0m");const m=r.current;if(m&&p){try{m.fit()}catch{}c()}},g.onmessage=p=>{try{const m=JSON.parse(p.data);m.type==="output"&&i.current?i.current.write(m.data):m.type==="error"&&i.current&&i.current.writeln(`\x1B[31m${m.data}\x1B[0m`)}catch{i.current&&i.current.write(p.data)}},g.onclose=p=>{if(!l.current)return;const m=i.current;if(p.code===4e3){m&&m.writeln(`\r
265
+ \x1B[31m-- Terminal unavailable: `+(p.reason||"server rejected connection")+". --\x1B[0m");return}const y=h.current;if(y>=Ma){m&&m.writeln(`\r
266
+ \x1B[31m-- Terminal disconnected. Max reconnect attempts reached. Refresh the page to try again. --\x1B[0m`);return}const x=Math.min(Em*Math.pow(2,y),Nm);h.current=y+1,m&&m.writeln(`\r
267
+ \x1B[33m-- Terminal disconnected. Reconnecting in ${(x/1e3).toFixed(0)}s (attempt ${y+1}/${Ma})... --\x1B[0m`),a.current=setTimeout(()=>{l.current&&d()},x)},g.onerror=()=>{}},[e,c]);return _.useEffect(()=>{l.current=!0,h.current=0;const f=s.current;if(!f)return;const u=new mm({cursorBlink:!0,fontSize:13,fontFamily:"'JetBrains Mono', 'Fira Code', 'Cascadia Code', Menlo, Monaco, monospace",theme:{background:"#1a1a2e",foreground:"#e0e0e0",cursor:"#a78bfa",selectionBackground:"#3d3d5c",black:"#1a1a2e",red:"#ff6b6b",green:"#51cf66",yellow:"#ffd43b",blue:"#74c0fc",magenta:"#da77f2",cyan:"#66d9ef",white:"#e0e0e0",brightBlack:"#4a4a6a",brightRed:"#ff8787",brightGreen:"#69db7c",brightYellow:"#ffe066",brightBlue:"#91d5ff",brightMagenta:"#e599f7",brightCyan:"#99f7f5",brightWhite:"#ffffff"},scrollback:1e4,convertEol:!0,allowProposedApi:!0}),g=new xm,p=new km;u.loadAddon(g),u.loadAddon(p),u.open(f),i.current=u,r.current=g;try{g.fit()}catch{}u.onData(x=>{const b=n.current;b&&b.readyState===WebSocket.OPEN&&b.send(JSON.stringify({type:"input",data:x}))}),d();let m=null;const y=new ResizeObserver(()=>{m&&clearTimeout(m),m=setTimeout(()=>{if(!(!r.current||!i.current))try{r.current.fit(),c()}catch{}},50)});return y.observe(f),()=>{l.current=!1,y.disconnect(),m&&clearTimeout(m),a.current&&clearTimeout(a.current),n.current&&(n.current.onclose=null,n.current.close(),n.current=null),u.dispose(),i.current=null,r.current=null}},[d,c]),_.useEffect(()=>{if(t&&r.current&&i.current){const f=setTimeout(()=>{var u;try{(u=r.current)==null||u.fit(),c()}catch{}},50);return()=>clearTimeout(f)}},[t,c]),o.jsx("div",{ref:s,className:"h-full w-full",style:{backgroundColor:"#1a1a2e"}})}function Ot(e,t){if(e.length===0)return e;const s=[...e],i=s[s.length-1];return s[s.length-1]={...i,...t(i)},s}function Dm(e){const t=[],s=[],i=[];for(const r of e.split(`
268
+ `))r.startsWith("__FILE_CHANGE__")?s.push(r.replace("__FILE_CHANGE__","")):r.startsWith("__COMMAND__")?i.push(r.replace("__COMMAND__","")):t.push(r);return{textLines:t,fileChanges:s,commands:i}}function Mm({msg:e}){var a;const[t,s]=_.useState(!1),i=_.useMemo(()=>e.role==="system"?Dm(e.content):null,[e.role,e.content]);if(e.role==="user")return o.jsx("div",{className:"flex justify-end",children:o.jsxs("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-primary/10 text-ink",children:[e.imageUrl&&o.jsxs("div",{className:"mb-2",children:[o.jsx("img",{src:e.imageUrl,alt:e.imageName||"Uploaded image",className:"max-w-full max-h-48 rounded border border-border object-contain"}),e.imageName&&o.jsx("span",{className:"text-[10px] text-muted mt-0.5 block",children:e.imageName})]}),o.jsx("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:e.content})]})});const r=i?i.textLines.join(`
269
+ `).trim():e.content,n=r.split(`
270
+ `).length>30;return o.jsx("div",{className:"flex justify-start",children:o.jsxs("div",{className:"max-w-[80%] rounded-lg px-3 py-2 text-xs bg-hover text-ink border-l-2 border-primary/40",children:[i&&i.commands.length>0&&o.jsx("div",{className:"mb-2 space-y-0.5",children:i.commands.map((l,h)=>o.jsxs("div",{className:"flex items-center gap-1.5 text-[11px] font-mono text-muted bg-card/50 px-2 py-0.5 rounded",children:[o.jsx(ds,{size:10,className:"text-muted/60 flex-shrink-0"}),o.jsx("span",{className:"truncate",children:l})]},h))}),o.jsxs("pre",{className:"whitespace-pre-wrap font-mono text-xs leading-relaxed overflow-x-auto",children:[n&&!t?r.split(`
271
+ `).slice(0,30).join(`
272
+ `)+`
273
+ ...`:r,e.isStreaming&&o.jsx("span",{className:"inline-block w-1.5 h-3.5 bg-primary/60 animate-pulse ml-0.5 align-text-bottom"})]}),n&&!e.isStreaming&&o.jsx("button",{onClick:()=>s(l=>!l),className:"text-[10px] text-primary hover:text-primary/80 mt-1 font-medium",children:t?"Show less":`Show all (${r.split(`
274
+ `).length} lines)`}),i&&i.fileChanges.length>0&&o.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[o.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[o.jsx(he,{size:11}),"Files modified (",i.fileChanges.length,")"]}),o.jsx("ul",{className:"mt-1 space-y-0.5",children:i.fileChanges.map((l,h)=>o.jsx("li",{className:"text-[11px] font-mono text-primary/80",children:l},h))})]}),e.filesChanged&&e.filesChanged.length>0&&o.jsxs("div",{className:"mt-2 pt-2 border-t border-border",children:[o.jsxs("span",{className:"text-[11px] text-muted font-semibold uppercase flex items-center gap-1",children:[o.jsx(he,{size:11}),"Changed files (",e.filesChanged.length,")"]}),o.jsx("ul",{className:"mt-1 space-y-0.5",children:e.filesChanged.map((l,h)=>o.jsx("li",{className:"text-[11px] font-mono text-muted",children:l},h))})]}),e.role==="system"&&!e.isStreaming&&e.returncode!==void 0&&o.jsx("div",{className:"mt-1 text-[10px] text-muted",children:e.returncode===0?o.jsxs("span",{children:["Done",i&&(i.fileChanges.length>0||e.filesChanged&&e.filesChanged.length>0)?` -- ${i.fileChanges.length+(((a=e.filesChanged)==null?void 0:a.length)||0)} files changed`:"",i&&i.commands.length>0?`, ${i.commands.length} commands run`:""]}):o.jsxs("span",{className:"text-red-400",children:["Task failed. ",e.returncode===124?"Timed out.":"Check the output above for error details."]})})]})})}const Pm={quick:"Quick: Fast single-task fix (3 iterations max)",standard:"Standard: Thorough implementation with testing",max:"Max: Full autonomous build from your description"};function Rm({sessionId:e,defaultMode:t,onFilesChanged:s,services:i}){var J;const[r,n]=_.useState([]),[a,l]=_.useState(""),[h,c]=_.useState(t||"quick"),[d,f]=_.useState(!1),[u,g]=_.useState(!1),[p,m]=_.useState(null),[y,x]=_.useState(!1),b=_.useRef(null),j=_.useRef(null),k=_.useRef(null),S=_.useRef(null),E=_.useRef(null),B=_.useRef(null);_.useEffect(()=>{const L=sessionStorage.getItem(`chat_${e}`);if(L)try{n(JSON.parse(L))}catch{}},[e]),_.useEffect(()=>{r.length>0&&sessionStorage.setItem(`chat_${e}`,JSON.stringify(r.slice(-50)))},[r,e]),_.useEffect(()=>{b.current&&(b.current.scrollTop=b.current.scrollHeight)},[r]),_.useEffect(()=>()=>{S.current&&S.current.abort(),p!=null&&p.previewUrl&&URL.revokeObjectURL(p.previewUrl)},[]);const U=_.useCallback(L=>{if(!L.type.startsWith("image/"))return;p!=null&&p.previewUrl&&URL.revokeObjectURL(p.previewUrl);const O=URL.createObjectURL(L);m({file:L,previewUrl:O})},[p==null?void 0:p.previewUrl]),X=_.useCallback(()=>{p!=null&&p.previewUrl&&URL.revokeObjectURL(p.previewUrl),m(null)},[p==null?void 0:p.previewUrl]);_.useEffect(()=>{const L=O=>{var q;const K=(q=O.clipboardData)==null?void 0:q.items;if(K){for(const te of K)if(te.type.startsWith("image/")){O.preventDefault();const se=te.getAsFile();se&&U(se);return}}};return document.addEventListener("paste",L),()=>document.removeEventListener("paste",L)},[U]);const[V,I]=_.useState(!1),D=_.useCallback(L=>{L.preventDefault(),L.stopPropagation(),L.dataTransfer.types.includes("Files")&&I(!0)},[]),C=_.useCallback(L=>{L.preventDefault(),L.stopPropagation(),I(!1)},[]),P=_.useCallback(L=>{L.preventDefault(),L.stopPropagation(),I(!1);const O=L.dataTransfer.files;if(O.length>0){const K=O[0];K.type.startsWith("image/")&&U(K)}},[U]),w=_.useCallback(async()=>{var L;if(S.current&&(S.current.abort(),S.current=null),E.current){try{await Y.chatCancel(e,E.current)}catch{}E.current=null}g(!1),f(!1),n(O=>Ot(O,K=>K.isStreaming?{isStreaming:!1,content:K.content+`
275
+ [cancelled]`}:{})),(L=j.current)==null||L.focus()},[e]),M=_.useCallback(async L=>{var te;let K=0,q;do{if(await new Promise(se=>setTimeout(se,2e3)),q=await Y.chatPoll(e,L),K++,q.output_lines.length>0){const se=q.output_lines.join(`
276
+ `);n(ae=>Ot(ae,ce=>ce.role==="system"&&ce.isStreaming?{content:se}:{}))}K>=150&&(q={complete:!0,output_lines:["Task timed out after 5 minutes. The AI may still be working in the background. Try checking the terminal or refreshing."],files_changed:[],returncode:1})}while(!q.complete);n(se=>Ot(se,ae=>ae.role==="system"?{isStreaming:!1,content:q.output_lines.join(`
277
+ `)||"Done.",filesChanged:q.files_changed,returncode:q.returncode}:{})),((te=q.files_changed)==null?void 0:te.length)>0&&s&&s(q.files_changed)},[e,s]),$=_.useCallback(async L=>{var K;const O=new AbortController;S.current=O,E.current=L,g(!0);try{const q=Y.chatStreamUrl(e,L),te=await fetch(q,{signal:O.signal});if(!te.ok||!te.body)throw new Error(`Stream failed: ${te.status}`);const se=te.body.getReader(),ae=new TextDecoder;let ce="";for(;;){const{done:fe,value:z}=await se.read();if(fe)break;ce+=ae.decode(z,{stream:!0});const oe=ce.split(`
278
+
279
+ `);ce=oe.pop()||"";for(const We of oe){if(!We.trim())continue;const Ve=We.split(`
280
+ `);let ne="",ve="";for(const le of Ve)le.startsWith("event:")?ne=le.slice(6).trim():le.startsWith("data:")&&(ve=le.slice(5).trim());if(ne==="output"&&ve)try{const{line:le}=JSON.parse(ve);n(Be=>Ot(Be,je=>je.role==="system"&&je.isStreaming?{content:je.content?je.content+`
281
+ `+le:le}:{}))}catch{}else if(ne==="complete"&&ve)try{const{returncode:le,files_changed:Be}=JSON.parse(ve);n(je=>Ot(je,Rt=>Rt.role==="system"&&Rt.isStreaming?{isStreaming:!1,filesChanged:Be,returncode:le,content:Rt.content||"Done."}:{})),(Be==null?void 0:Be.length)>0&&s&&s(Be)}catch{}else if(ne==="error"&&ve)try{const{error:le}=JSON.parse(ve);n(Be=>Ot(Be,je=>je.role==="system"&&je.isStreaming?{isStreaming:!1,content:`Error: ${le}`}:{}))}catch{}}}}catch(q){if(q instanceof DOMException&&q.name==="AbortError")return;await M(L)}finally{g(!1),f(!1),S.current=null,E.current=null,(K=j.current)==null||K.focus()}},[e,s,M]),R=async()=>{var ce;const L=a.trim();if(!L&&!p||d)return;let O,K,q="";if(p){x(!0);try{const fe=await Y.chatImageUpload(e,p.file);O=p.previewUrl,K=fe.filename,q=`[Attached image: ${fe.filename} (id: ${fe.image_id})] Make it look like this. `}catch{}x(!1)}const te=q+(L||"Make changes based on this screenshot."),se={role:"user",content:L||"Make changes based on this screenshot.",timestamp:new Date().toISOString(),imageUrl:O,imageName:K},ae={role:"system",content:"",timestamp:new Date().toISOString(),isStreaming:!0};n(fe=>[...fe,se,ae]),l(""),m(null),f(!0);try{const fe=r.filter(oe=>oe.role==="user"||oe.role==="system"&&!oe.isStreaming&&oe.content).slice(-10).map(oe=>({role:oe.role==="user"?"user":"assistant",content:oe.content})),{task_id:z}=await Y.chatStart(e,te,h,fe.length>0?fe:void 0);await $(z)}catch(fe){n(z=>Ot(z,oe=>oe.role==="system"&&oe.isStreaming?{isStreaming:!1,content:`Error: ${fe instanceof Error?fe.message:"Request failed"}`}:{})),f(!1),(ce=j.current)==null||ce.focus()}};return o.jsxs("div",{ref:B,className:`flex flex-col h-full relative ${V?"ring-2 ring-primary ring-inset":""}`,onDragOver:D,onDragLeave:C,onDrop:P,children:[V&&o.jsx("div",{className:"absolute inset-0 z-10 flex items-center justify-center bg-primary/5 backdrop-blur-sm",children:o.jsxs("div",{className:"flex flex-col items-center gap-2 text-primary",children:[o.jsx(uo,{size:32}),o.jsx("span",{className:"text-sm font-medium",children:"Drop image here"})]})}),o.jsxs("div",{ref:b,className:"flex-1 overflow-y-auto p-3 space-y-3 terminal-scroll",children:[r.length===0&&o.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o.jsx(cn,{size:28,className:"text-muted/30 mb-3"}),o.jsx("p",{className:"text-xs text-muted font-medium",children:"No messages yet"}),o.jsx("p",{className:"text-[11px] text-muted/70 mt-1 max-w-[200px]",children:"Ask the AI to build, modify, or explain your code. Drop an image or paste a screenshot."})]}),r.map((L,O)=>o.jsx(Mm,{msg:L},O))]}),o.jsxs("div",{className:"border-t border-border p-2 flex-shrink-0",children:[u&&o.jsxs("div",{className:"flex items-center justify-between mb-2 px-1",children:[o.jsx("span",{className:"text-[10px] text-muted font-mono",children:"Streaming..."}),o.jsxs("button",{onClick:w,className:"flex items-center gap-1 text-[10px] text-red-400 hover:text-red-300 transition-colors",children:[o.jsx(Di,{className:"w-2.5 h-2.5"}),"Stop"]})]}),!u&&(i==null?void 0:i.some(L=>L.fix_status==="fixing"))&&o.jsxs("div",{className:"flex items-center gap-1.5 mb-2 px-1",children:[o.jsx(el,{size:10,className:"text-yellow-400 animate-spin"}),o.jsxs("span",{className:"text-[10px] text-yellow-400 font-mono",children:["Auto-fixing: ",(J=i.find(L=>L.fix_status==="fixing"))==null?void 0:J.name]})]}),o.jsx("div",{className:"flex items-center gap-1 mb-2",children:["quick","standard","max"].map(L=>o.jsx("button",{onClick:()=>c(L),title:Pm[L],className:`text-xs font-semibold px-3 py-1.5 rounded-btn transition-colors capitalize ${h===L?"bg-primary text-white":"text-muted hover:text-ink"}`,children:L},L))}),p&&o.jsxs("div",{className:"flex items-center gap-2 mb-2 px-1",children:[o.jsxs("div",{className:"relative",children:[o.jsx("img",{src:p.previewUrl,alt:"Pending upload",className:"h-16 max-w-[120px] rounded border border-border object-cover"}),o.jsx("button",{onClick:X,className:"absolute -top-1.5 -right-1.5 w-4 h-4 bg-red-500 text-white rounded-full flex items-center justify-center hover:bg-red-600",title:"Remove image",children:o.jsx(Wt,{size:10})})]}),o.jsx("span",{className:"text-[10px] text-muted truncate max-w-[150px]",children:p.file.name}),y&&o.jsx("span",{className:"text-[10px] text-primary animate-pulse",children:"Uploading..."})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{ref:k,type:"file",accept:"image/*",className:"hidden",onChange:L=>{var K;const O=(K=L.target.files)==null?void 0:K[0];O&&U(O),L.target.value=""}}),o.jsx("button",{onClick:()=>{var L;return(L=k.current)==null?void 0:L.click()},disabled:d,className:"p-1.5 text-muted hover:text-primary rounded transition-colors disabled:opacity-50",title:"Attach image (or paste/drag-and-drop)",children:o.jsx(uo,{size:16})}),o.jsx("textarea",{ref:j,value:a,onChange:L=>l(L.target.value),onKeyDown:L=>{L.key==="Enter"&&!L.shiftKey&&(L.preventDefault(),R())},placeholder:"Ask AI to modify your project... (Shift+Enter for new line)",rows:1,className:"flex-1 px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none",style:{maxHeight:"120px",overflow:"auto"},disabled:d}),u?o.jsx(we,{size:"sm",icon:Di,onClick:w,"aria-label":"Stop streaming",className:"bg-red-500/10 hover:bg-red-500/20 text-red-400",children:"Stop"}):o.jsx(we,{size:"sm",icon:ad,onClick:R,disabled:d||!a.trim()&&!p,"aria-label":"Send message",children:"Send"})]})]})]})}const Pa={file_created:{icon:$i,color:"bg-blue-500",bgColor:"bg-blue-500/10",labelColor:"text-blue-600"},file_modified:{icon:he,color:"bg-blue-400",bgColor:"bg-blue-400/10",labelColor:"text-blue-500"},dependency_install:{icon:dn,color:"bg-teal-500",bgColor:"bg-teal-500/10",labelColor:"text-teal-600"},test_pass:{icon:pn,color:"bg-green-500",bgColor:"bg-green-500/10",labelColor:"text-green-600"},test_fail:{icon:ji,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},error:{icon:ji,color:"bg-red-500",bgColor:"bg-red-500/10",labelColor:"text-red-500"},narration:{icon:cn,color:"bg-purple-500",bgColor:"bg-purple-500/10",labelColor:"text-purple-600"},command:{icon:ds,color:"bg-gray-500",bgColor:"bg-gray-500/10",labelColor:"text-gray-600"},phase_change:{icon:gt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},deploy:{icon:gt,color:"bg-primary",bgColor:"bg-primary/10",labelColor:"text-primary"},warning:{icon:$a,color:"bg-yellow-500",bgColor:"bg-yellow-500/10",labelColor:"text-yellow-600"},info:{icon:Xc,color:"bg-gray-400",bgColor:"bg-gray-400/10",labelColor:"text-gray-500"}};function Ra(e){try{return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",second:"2-digit"})}catch{return""}}function Lm({event:e,isLast:t,onFileClick:s}){const i=Pa[e.type]||Pa.info,r=i.icon,n=e.type==="narration";return o.jsxs("div",{className:"flex gap-3 group",children:[o.jsxs("div",{className:"flex flex-col items-center flex-shrink-0",children:[o.jsx("div",{className:`w-7 h-7 rounded-full flex items-center justify-center ${i.bgColor}`,children:o.jsx(r,{size:14,className:i.labelColor})}),!t&&o.jsx("div",{className:"w-px flex-1 bg-border min-h-[16px]"})]}),o.jsx("div",{className:"flex-1 min-w-0 pb-4 ",children:n?o.jsxs("div",{className:"relative bg-purple-500/5 border border-purple-500/20 rounded-lg px-3 py-2 mt-0.5",children:[o.jsx("div",{className:"absolute -left-1.5 top-2.5 w-2.5 h-2.5 bg-purple-500/5 border-l border-b border-purple-500/20 rotate-45"}),o.jsx("p",{className:"text-xs text-ink leading-relaxed",children:e.message}),e.detail&&o.jsx("p",{className:"text-[11px] text-muted mt-1 leading-relaxed",children:e.detail}),o.jsxs("span",{className:"text-[10px] text-muted/60 mt-1.5 flex items-center gap-1",children:[o.jsx(vt,{size:10}),Ra(e.timestamp)]})]}):o.jsxs("div",{className:"mt-1",children:[o.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[o.jsx("span",{className:`text-xs font-medium ${i.labelColor}`,children:e.message}),e.filePath&&s&&o.jsx("button",{onClick:()=>s(e.filePath),className:"text-[11px] font-mono text-primary hover:text-primary/80 hover:underline truncate max-w-[200px]",title:e.filePath,children:e.filePath})]}),o.jsxs("span",{className:"text-[10px] text-muted/60 flex items-center gap-1 mt-0.5",children:[o.jsx(vt,{size:10}),Ra(e.timestamp)]})]})})]})}const _r=20,La=10;function Bm({events:e,onFileClick:t,maxHeight:s}){const i=_.useRef(null),[r,n]=_.useState(!0);if(_.useEffect(()=>{i.current&&(i.current.scrollTop=i.current.scrollHeight)},[e.length]),_.useEffect(()=>{e.length>_r},[e.length,r]),e.length===0)return o.jsxs("div",{className:"flex flex-col items-center justify-center py-10 text-center",children:[o.jsx(el,{size:28,className:"text-muted/30 mb-3"}),o.jsx("p",{className:"text-xs text-muted font-medium",children:"No build events yet"}),o.jsx("p",{className:"text-[11px] text-muted/70 mt-1",children:"Events will appear here as the build progresses."})]});const a=e.length>_r&&r,l=a?e.slice(-La):e,h=a?e.length-La:0;return o.jsxs("div",{ref:i,className:"overflow-y-auto terminal-scroll px-3 py-3",style:{maxHeight:s||"100%"},children:[a&&h>0&&o.jsxs("button",{onClick:()=>n(!1),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[o.jsx(Gc,{size:12}),"Show ",h," earlier event",h!==1?"s":""]}),!r&&e.length>_r&&o.jsxs("button",{onClick:()=>n(!0),className:"flex items-center gap-1.5 text-[11px] text-primary hover:text-primary/80 font-medium mb-3 ml-9",children:[o.jsx(Ai,{size:12}),"Collapse older events"]}),l.map((c,d)=>o.jsx(Lm,{event:c,isLast:d===l.length-1,onFileClick:t},c.id))]})}const Ba=[{id:"terminal",label:"Terminal",icon:ds,alwaysShow:!0},{id:"chat",label:"AI Chat",icon:cn,alwaysShow:!0},{id:"activity",label:"Activity",icon:lh,alwaysShow:!0},{id:"build",label:"Build Log",icon:nd},{id:"agents",label:"Agents",icon:oh},{id:"quality",label:"Quality",icon:Qa}];function zm({status:e}){switch(e){case"pass":return o.jsx(us,{size:14,className:"text-success"});case"fail":return o.jsx(Wt,{size:14,className:"text-danger"});default:return o.jsx(vt,{size:14,className:"text-muted"})}}function Tm({agents:e}){return!e||e.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[o.jsx(Jc,{size:24,className:"text-muted/30 mb-2"}),o.jsx("p",{className:"text-xs text-muted font-medium",children:"No agents active"}),o.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Agents appear here during active builds"})]}):o.jsx("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:e.map(t=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-hover text-xs",children:[o.jsx("span",{className:"font-semibold text-ink truncate",children:t.name}),o.jsx("span",{className:"text-xs font-mono text-muted-accessible px-1.5 py-0.5 rounded-btn bg-card",children:t.type}),o.jsx("span",{className:`text-xs font-semibold ${t.status==="running"?"text-success":"text-muted"}`,children:t.status}),o.jsx("span",{className:"ml-auto text-xs text-muted-accessible font-mono truncate max-w-[200px]",children:t.task})]},t.id))})}function Am({checklist:e}){return!e||!e.items||e.items.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[o.jsx(Qa,{size:24,className:"text-muted/30 mb-2"}),o.jsx("p",{className:"text-xs text-muted font-medium",children:"No quality gate data"}),o.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Quality gates appear during active builds"})]}):o.jsxs("div",{className:"p-2 space-y-1 overflow-y-auto terminal-scroll",children:[o.jsxs("div",{className:"flex items-center gap-3 px-3 py-2 text-xs text-muted-accessible font-semibold uppercase",children:[o.jsx("span",{children:"Gate"}),o.jsxs("span",{className:"ml-auto",children:[e.passed,"/",e.total," passed"]})]}),e.items.map(t=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 rounded-btn hover:bg-hover text-xs",children:[o.jsx(zm,{status:t.status}),o.jsx("span",{className:"text-ink",children:t.label}),t.details&&o.jsx("span",{className:"ml-auto text-xs text-muted-accessible truncate max-w-[200px]",children:t.details})]},t.id))]})}function Om({logs:e,logsLoading:t,agents:s,checklist:i,sessionId:r,isRunning:n,subscribe:a,buildMode:l,buildEvents:h,onFileClick:c}){var y;const[d,f]=_.useState("terminal"),u=s&&s.length>0,g=i&&i.items&&i.items.length>0,p=e&&e.length>0,m=Ba.filter(x=>!!(x.alwaysShow||x.id==="build"&&(p||n)||x.id==="agents"&&(u||n)||x.id==="quality"&&(g||n)));return m.find(x=>x.id===d)||f("terminal"),o.jsxs("div",{className:"h-full flex flex-col bg-card",children:[o.jsx("div",{role:"tablist",className:"flex items-center border-b border-border px-2 flex-shrink-0",children:m.map(x=>{const b=x.icon,j=d===x.id;return o.jsxs("button",{role:"tab","aria-selected":j,onClick:()=>f(x.id),className:`flex items-center gap-1.5 px-3 py-2 text-xs font-medium transition-colors border-b-2 ${j?"border-primary text-primary":"border-transparent text-muted hover:text-ink"}`,children:[o.jsx(b,{size:14}),x.label,x.id==="agents"&&u&&o.jsx("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-primary/10 text-primary",children:s.length}),x.id==="quality"&&g&&o.jsxs("span",{className:"ml-0.5 px-1.5 py-0.5 text-[10px] font-bold rounded-full bg-success/10 text-success",children:[i.passed,"/",i.total]})]},x.id)})}),o.jsxs("div",{role:"tabpanel","aria-label":(y=Ba.find(x=>x.id===d))==null?void 0:y.label,className:"flex-1 min-h-0 overflow-hidden relative",children:[o.jsx("div",{className:"absolute inset-0",style:{visibility:d==="terminal"?"visible":"hidden",zIndex:d==="terminal"?1:0},children:o.jsx(jm,{sessionId:r,isActive:d==="terminal"})}),d==="build"&&o.jsx(ih,{logs:e,loading:t,subscribe:a}),d==="agents"&&o.jsx(Tm,{agents:s}),d==="activity"&&o.jsx(Bm,{events:h||[],onFileClick:c}),d==="quality"&&o.jsx(Am,{checklist:i}),d==="chat"&&o.jsx(Rm,{sessionId:r,defaultMode:l})]})]})}const mr=[{id:"planning",label:"Plan",color:"bg-blue-500"},{id:"building",label:"Build",color:"bg-primary"},{id:"testing",label:"Test",color:"bg-teal"},{id:"reviewing",label:"Review",color:"bg-warning"},{id:"complete",label:"Done",color:"bg-success"}];function Im({phase:e,iteration:t,maxIterations:s,cost:i,startTime:r,isRunning:n}){const[a,l]=_.useState(0);if(_.useEffect(()=>{if(!n||!r)return;const p=setInterval(()=>{l(Math.floor((Date.now()-r)/1e3))},1e3);return()=>clearInterval(p)},[n,r]),!n&&e==="idle")return null;const h=mr.findIndex(p=>p.id===e),c=s>0?Math.min(t/s*100,100):0,d=t>0?a/t:60,f=Math.max(0,s-t),u=Math.ceil(d*f),g=p=>p<60?`${p}s`:`${Math.floor(p/60)}m ${p%60}s`;return o.jsxs("div",{className:"flex-shrink-0",children:[o.jsxs("div",{className:"h-1 bg-border relative overflow-hidden",children:[o.jsx("div",{className:"h-full bg-gradient-to-r from-primary to-teal transition-all duration-1000 ease-out",style:{width:`${c}%`}}),n&&o.jsx("div",{className:"absolute inset-0 bg-gradient-to-r from-transparent via-white/20 to-transparent animate-shimmer"})]}),o.jsxs("div",{className:"px-4 py-1.5 flex items-center gap-4 bg-card border-b border-border text-xs",children:[o.jsx("div",{className:"flex items-center gap-1",children:mr.map((p,m)=>o.jsxs("div",{className:"flex items-center gap-1",children:[o.jsx("div",{className:`w-2 h-2 rounded-full transition-colors ${m<h?"bg-success":m===h?`${p.color} animate-pulse`:"bg-border"}`}),o.jsx("span",{className:`text-[11px] font-medium ${m===h?"text-ink":"text-muted"}`,children:p.label}),m<mr.length-1&&o.jsx("span",{className:"text-border mx-0.5",children:"--"})]},p.id))}),o.jsx("div",{className:"flex-1"}),o.jsxs("div",{className:"flex items-center gap-3 text-muted",children:[o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(pd,{size:12}),"Iter ",t,"/",s]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(vt,{size:12}),g(a),n&&u>0&&o.jsxs("span",{className:"text-muted/60",children:["(",g(u)," left)"]})]}),o.jsxs("span",{className:"flex items-center gap-1",children:[o.jsx(vh,{size:12}),"$",i.toFixed(2)]})]})]})]})}const $m=[{id:"vercel",name:"Vercel",description:"Optimized for Next.js, React, and static sites. Global CDN with instant rollbacks.",icon:gr,color:"text-ink",bgColor:"bg-ink/5"},{id:"netlify",name:"Netlify",description:"Deploy with CI/CD, serverless functions, and form handling built in.",icon:gr,color:"text-teal-600",bgColor:"bg-teal-500/5"},{id:"github-pages",name:"GitHub Pages",description:"Free hosting for static sites directly from a GitHub repository.",icon:Te,color:"text-purple-600",bgColor:"bg-purple-500/5"}];function Fm({platform:e,deployState:t,onDeploy:s,disabled:i}){const[r,n]=_.useState(!1),a=e.icon,l=_.useCallback(async()=>{if(t.url)try{await navigator.clipboard.writeText(t.url),n(!0),setTimeout(()=>n(!1),2e3)}catch{}},[t.url]);return o.jsxs("div",{className:`border border-border rounded-lg p-4 transition-colors ${t.status==="success"?"border-green-500/30 bg-green-500/5":t.status==="error"?"border-red-500/30 bg-red-500/5":"hover:border-primary/30 hover:bg-hover"}`,children:[o.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[o.jsx("div",{className:`w-10 h-10 rounded-lg flex items-center justify-center ${e.bgColor}`,children:o.jsx(a,{size:20,className:e.color})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h4",{className:"text-sm font-semibold text-ink",children:e.name}),o.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:e.description})]})]}),t.status==="idle"&&o.jsxs(we,{variant:"secondary",size:"sm",icon:gt,onClick:s,disabled:i,className:"w-full",children:["Deploy to ",e.name]}),t.status==="deploying"&&o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[o.jsx(Xa,{size:14,className:"text-primary animate-spin"}),o.jsxs("span",{className:"text-xs font-medium text-primary",children:["Deploying to ",e.name,"..."]})]}),t.status==="success"&&t.url&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[o.jsx(pn,{size:14}),"Deployed successfully"]}),o.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[o.jsx(gr,{size:12,className:"text-muted flex-shrink-0"}),o.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:t.url}),o.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[r?o.jsx(us,{size:12,className:"text-green-500"}):o.jsx(Ha,{size:12}),r?"Copied":"Copy"]}),o.jsx("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"text-muted hover:text-ink transition-colors flex-shrink-0",title:"Open in new tab",children:o.jsx(xr,{size:12})})]})]}),t.status==="error"&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[o.jsx(un,{size:14}),"Deploy failed"]}),o.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:t.error||"Unknown error"}),o.jsx(we,{variant:"secondary",size:"sm",icon:gt,onClick:s,disabled:i,className:"w-full",children:"Retry"})]})]})}function Hm({sessionId:e,disabled:t}){const[s,i]=_.useState({status:"idle"}),[r,n]=_.useState(!1),a=_.useCallback(async()=>{i({status:"pushing"});try{const h=await Y.githubPush(e);h.repo_url?i({status:"success",repoUrl:h.repo_url}):i({status:"error",error:h.error||"Push failed"})}catch(h){i({status:"error",error:h instanceof Error?h.message:"Push failed"})}},[e]),l=_.useCallback(async()=>{if(s.repoUrl)try{await navigator.clipboard.writeText(s.repoUrl),n(!0),setTimeout(()=>n(!1),2e3)}catch{}},[s.repoUrl]);return o.jsxs("div",{className:"border border-border rounded-lg p-4",children:[o.jsxs("div",{className:"flex items-center gap-3 mb-3",children:[o.jsx("div",{className:"w-10 h-10 rounded-lg flex items-center justify-center bg-ink/5",children:o.jsx(Te,{size:20,className:"text-ink"})}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h4",{className:"text-sm font-semibold text-ink",children:"Push to GitHub"}),o.jsx("p",{className:"text-[11px] text-muted leading-snug mt-0.5",children:"Create a repository and push your code to GitHub."})]})]}),s.status==="idle"&&o.jsx(we,{variant:"secondary",size:"sm",icon:Te,onClick:a,disabled:t,className:"w-full",children:"Create Repo + Push"}),s.status==="pushing"&&o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 rounded-btn bg-primary/5 border border-primary/20",children:[o.jsx(Xa,{size:14,className:"text-primary animate-spin"}),o.jsx("span",{className:"text-xs font-medium text-primary",children:"Creating repository and pushing..."})]}),s.status==="success"&&s.repoUrl&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-green-600 font-medium",children:[o.jsx(pn,{size:14}),"Pushed to GitHub"]}),o.jsxs("div",{className:"flex items-center gap-1.5 bg-card border border-border rounded-btn px-3 py-2",children:[o.jsx(Te,{size:12,className:"text-muted flex-shrink-0"}),o.jsx("a",{href:s.repoUrl,target:"_blank",rel:"noopener noreferrer",className:"text-xs font-mono text-primary hover:underline truncate flex-1",children:s.repoUrl}),o.jsxs("button",{onClick:l,className:"flex items-center gap-1 text-[11px] text-muted hover:text-ink transition-colors flex-shrink-0",title:"Copy URL",children:[r?o.jsx(us,{size:12,className:"text-green-500"}):o.jsx(Ha,{size:12}),r?"Copied":"Copy"]})]})]}),s.status==="error"&&o.jsxs("div",{className:"space-y-2",children:[o.jsxs("div",{className:"flex items-center gap-1.5 text-xs text-red-500 font-medium",children:[o.jsx(un,{size:14}),"Push failed"]}),o.jsx("p",{className:"text-[11px] text-muted bg-red-500/5 border border-red-500/10 rounded px-2 py-1.5 font-mono",children:s.error}),o.jsx(we,{variant:"secondary",size:"sm",icon:Te,onClick:a,disabled:t,className:"w-full",children:"Retry"})]})]})}function Wm({sessionId:e}){const[t,s]=_.useState({vercel:{status:"idle"},netlify:{status:"idle"},"github-pages":{status:"idle"}}),i=Object.values(t).some(n=>n.status==="deploying"),r=_.useCallback(async n=>{s(a=>({...a,[n]:{status:"deploying"}}));try{const a=await Y.deployProject(e,n);a.url?s(l=>({...l,[n]:{status:"success",url:a.url}})):s(l=>({...l,[n]:{status:"error",error:a.error||"Deploy failed"}}))}catch(a){s(l=>({...l,[n]:{status:"error",error:a instanceof Error?a.message:"Deploy failed"}}))}},[e]);return o.jsx("div",{className:"h-full overflow-y-auto terminal-scroll",children:o.jsxs("div",{className:"p-6 max-w-2xl mx-auto space-y-6",children:[o.jsxs("div",{children:[o.jsxs("h3",{className:"text-lg font-heading font-bold text-ink flex items-center gap-2",children:[o.jsx(gt,{size:20,className:"text-primary"}),"Deploy Your Project"]}),o.jsx("p",{className:"text-xs text-muted mt-1",children:"Choose a platform to deploy your project. One click to go live."})]}),o.jsx("div",{className:"space-y-3",children:$m.map(n=>o.jsx(Fm,{platform:n,deployState:t[n.id],onDeploy:()=>r(n.id),disabled:i},n.id))}),o.jsx("div",{className:"border-t border-border"}),o.jsx(Hm,{sessionId:e,disabled:i})]})})}const fc=typeof navigator<"u"&&/Mac/.test(navigator.userAgent),Ds=fc?"Cmd":"Ctrl",Um=[{keys:[`${Ds}+S`],label:"Save file"},{keys:[`${Ds}+P`],label:"Quick open file"},{keys:[`${Ds}+\``],label:"Toggle terminal"},{keys:[`${Ds}+B`],label:"Start / stop build"},{keys:[`${Ds}+?`],label:"Show keyboard shortcuts"},{keys:["Escape"],label:"Close modals"}];function Km({onToggleTerminal:e,onToggleBuild:t}){const[s,i]=_.useState(!1),r=_.useCallback(n=>{const a=fc?n.metaKey:n.ctrlKey;if(a&&(n.key==="?"||n.shiftKey&&n.key==="/")){n.preventDefault(),i(l=>!l);return}if(a&&n.key==="`"){n.preventDefault(),e==null||e();return}if(a&&n.key==="b"){n.preventDefault(),t==null||t();return}n.key==="Escape"&&s&&i(!1)},[e,t,s]);return _.useEffect(()=>(window.addEventListener("keydown",r),()=>window.removeEventListener("keydown",r)),[r]),{showHelp:s,setShowHelp:i}}function qm({open:e,onClose:t}){return e?o.jsx("div",{className:"fixed inset-0 z-50 flex items-center justify-center bg-ink/20",onClick:t,children:o.jsxs("div",{className:"bg-card rounded-card shadow-card-hover border border-border w-full max-w-md mx-4",onClick:s=>s.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center justify-between px-5 py-4 border-b border-border",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Fh,{size:16,className:"text-primary"}),o.jsx("h2",{className:"text-sm font-heading font-bold text-ink",children:"Keyboard Shortcuts"})]}),o.jsx("button",{onClick:t,className:"text-muted hover:text-ink transition-colors p-1 rounded-btn hover:bg-hover",children:o.jsx(Wt,{size:16})})]}),o.jsx("div",{className:"p-4 space-y-1",children:Um.map(s=>o.jsxs("div",{className:"flex items-center justify-between px-2 py-2 rounded-btn hover:bg-hover",children:[o.jsx("span",{className:"text-xs text-ink",children:s.label}),o.jsx("div",{className:"flex items-center gap-1",children:s.keys.map(i=>o.jsx("kbd",{className:"px-2 py-0.5 text-[11px] font-mono bg-hover border border-border rounded text-muted-accessible",children:i},i))})]},s.label))}),o.jsx("div",{className:"px-5 py-3 border-t border-border text-center",children:o.jsxs("span",{className:"text-[11px] text-muted",children:["Press ",o.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Escape"})," to close"]})})]})}):null}function Vm({onClick:e}){return o.jsx("button",{onClick:e,title:"Keyboard shortcuts",className:"inline-flex items-center justify-center w-7 h-7 rounded-btn text-muted hover:text-ink hover:bg-hover transition-colors text-xs font-bold",children:"?"})}function Ym(e){var i;const t=((i=e.split(".").pop())==null?void 0:i.toLowerCase())||"";return{js:he,ts:he,tsx:he,jsx:he,py:he,go:he,rs:he,rb:he,sh:he,html:Ua,css:qa,json:Wa,md:hn}[t]||Va}function Gm({isOpen:e,onClose:t,commands:s,sessionId:i,onFileSelect:r}){const[n,a]=_.useState(""),[l,h]=_.useState(0),[c,d]=_.useState([]),[f,u]=_.useState(!1),g=_.useRef(null),p=_.useRef(null);_.useEffect(()=>{e&&(a(""),h(0),d([]),u(!1),setTimeout(()=>{var E;return(E=g.current)==null?void 0:E.focus()},50))},[e]);const m=s.filter(E=>E.label.toLowerCase().includes(n.toLowerCase()));_.useEffect(()=>{if(!i||!n.trim()){d([]),u(!1);return}return u(!0),p.current&&clearTimeout(p.current),p.current=setTimeout(async()=>{try{const E=await Y.searchFiles(i,n);d(E.filter(B=>B.type==="file"))}catch{d([])}u(!1)},200),()=>{p.current&&clearTimeout(p.current)}},[n,i]);const y=m.length+c.length;_.useEffect(()=>{h(0)},[n]);const x=_.useCallback(E=>{if(E<m.length)m[E].action(),t();else{const B=E-m.length,U=c[B];U&&r&&(r(U.path,U.name),t())}},[m,c,r,t]),b=_.useCallback(E=>{E.key==="ArrowDown"?(E.preventDefault(),h(B=>Math.min(B+1,y-1))):E.key==="ArrowUp"?(E.preventDefault(),h(B=>Math.max(B-1,0))):E.key==="Enter"&&y>0?x(l):E.key==="Escape"&&t()},[y,l,x,t]);if(!e)return null;const j=m.length>0,k=c.length>0,S=f&&n.trim().length>0;return o.jsxs("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",onClick:t,children:[o.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),o.jsxs("div",{className:"relative w-full max-w-lg bg-card rounded-xl shadow-2xl border border-border overflow-hidden",onClick:E=>E.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border",children:[o.jsx(ch,{size:18,className:"text-muted"}),o.jsx("input",{ref:g,value:n,onChange:E=>a(E.target.value),onKeyDown:b,placeholder:"Search commands, files, actions...",className:"flex-1 bg-transparent text-sm outline-none text-ink placeholder:text-muted"}),o.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:"ESC"})]}),o.jsxs("div",{className:"max-h-[360px] overflow-y-auto py-1 terminal-scroll",children:[j&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider",children:"Commands"}),m.map((E,B)=>{const U=E.icon;return o.jsxs("button",{onClick:()=>{E.action(),t()},className:`w-full flex items-center gap-3 px-4 py-2.5 text-sm transition-colors ${B===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[o.jsx(U,{size:16}),o.jsx("span",{className:"flex-1 text-left",children:E.label}),E.shortcut&&o.jsx("kbd",{className:"text-[10px] text-muted bg-hover px-1.5 py-0.5 rounded border border-border font-mono",children:E.shortcut})]},E.id)})]}),k&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-4 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider mt-1",children:"Files"}),c.map((E,B)=>{const U=m.length+B,X=E.type==="directory"?Ya:Ym(E.name);return o.jsxs("button",{onClick:()=>x(U),className:`w-full flex items-center gap-3 px-4 py-2 text-sm transition-colors ${U===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[o.jsx(X,{size:14}),o.jsx("span",{className:"flex-1 text-left font-mono text-xs truncate",children:E.name}),o.jsx("span",{className:"text-[10px] text-muted truncate max-w-[200px]",children:E.path})]},`file-${E.path}`)})]}),S&&!k&&o.jsx("div",{className:"px-4 py-2 text-xs text-muted animate-pulse",children:"Searching files..."}),y===0&&!S&&o.jsx("div",{className:"px-4 py-8 text-center text-sm text-muted",children:"No results found"})]})]})]})}const Xm={modified:o.jsx(he,{size:13,className:"text-yellow-500"}),added:o.jsx($i,{size:13,className:"text-green-500"}),deleted:o.jsx(fn,{size:13,className:"text-red-400"}),renamed:o.jsx(he,{size:13,className:"text-blue-400"}),untracked:o.jsx(Ka,{size:13,className:"text-muted"})},Jm={modified:"M",added:"A",deleted:"D",renamed:"R",untracked:"?"};function Zm({commit:e}){return o.jsx("div",{className:"px-3 py-2 border-b border-border hover:bg-hover transition-colors",children:o.jsxs("div",{className:"flex items-start gap-2",children:[o.jsx(Ga,{size:14,className:"text-primary mt-0.5 flex-shrink-0"}),o.jsxs("div",{className:"min-w-0 flex-1",children:[o.jsx("p",{className:"text-xs font-medium text-ink truncate",children:e.message}),o.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[o.jsx("span",{className:"text-[11px] font-mono text-primary/70",children:e.short_hash}),o.jsx("span",{className:"text-[11px] text-muted",children:e.author}),o.jsx("span",{className:"text-[11px] text-muted ml-auto flex-shrink-0",children:e.date})]}),e.refs.length>0&&o.jsx("div",{className:"flex gap-1 mt-1",children:e.refs.map((t,s)=>o.jsxs("span",{className:"inline-flex items-center gap-0.5 px-1.5 py-0.5 text-[10px] font-mono bg-primary/10 text-primary rounded",children:[o.jsx(Te,{size:9}),t]},s))})]})]})})}function za({file:e}){return o.jsxs("div",{className:"flex items-center gap-2 px-3 py-1.5 hover:bg-hover transition-colors text-xs",children:[Xm[e.status]||o.jsx(Ka,{size:13}),o.jsx("span",{className:"font-mono text-ink truncate flex-1",children:e.path}),o.jsx("span",{className:`font-mono text-[10px] px-1 rounded ${e.staged?"bg-green-500/10 text-green-500":"bg-muted/10 text-muted"}`,children:Jm[e.status]||"?"})]})}function Qm({sessionId:e}){const[t,s]=_.useState("changes"),[i,r]=_.useState(null),[n,a]=_.useState([]),[l,h]=_.useState([]),[c,d]=_.useState(!0),[f,u]=_.useState(null),[g,p]=_.useState(""),[m,y]=_.useState(!1),[x,b]=_.useState(null),[j,k]=_.useState(!1),[S,E]=_.useState(""),[B,U]=_.useState(!1),[X,V]=_.useState(!1),[I,D]=_.useState(""),[C,P]=_.useState(""),[w,M]=_.useState(!1),[$,R]=_.useState(null),[J,L]=_.useState(!1),O=_.useCallback(async()=>{d(!0),u(null);try{const[z,oe,We]=await Promise.all([Y.git.status(e),Y.git.log(e),Y.git.branches(e)]);r(z),a(oe),h(We)}catch(z){u(z instanceof Error?z.message:"Failed to load git data")}d(!1)},[e]);_.useEffect(()=>{O()},[O]);const K=async()=>{if(!(!g.trim()||m)){y(!0),b(null);try{const z=await Y.git.commit(e,g.trim());b(`Committed: ${z.hash}`),p(""),await O()}catch(z){b(`Error: ${z instanceof Error?z.message:"Commit failed"}`)}y(!1)}},q=async()=>{if(!(!S.trim()||B)){U(!0);try{await Y.git.createBranch(e,S.trim()),E(""),k(!1),await O()}catch(z){u(z instanceof Error?z.message:"Branch creation failed")}U(!1)}},te=async z=>{try{await Y.git.checkoutBranch(e,z),await O()}catch(oe){u(oe instanceof Error?oe.message:"Checkout failed")}},se=async()=>{L(!0);try{await Y.git.push(e),await O()}catch(z){u(z instanceof Error?z.message:"Push failed")}L(!1)},ae=async()=>{if(!(!I.trim()||w)){M(!0),R(null);try{const z=await Y.git.pr(e,I.trim(),C.trim());R(z.url),D(""),P(""),V(!1)}catch(z){R(`Error: ${z instanceof Error?z.message:"PR creation failed"}`)}M(!1)}},ce=(i==null?void 0:i.files.filter(z=>z.staged))||[],fe=(i==null?void 0:i.files.filter(z=>!z.staged))||[];return c&&!i?o.jsx("div",{className:"h-full flex items-center justify-center",children:o.jsxs("div",{className:"flex flex-col items-center gap-2",children:[o.jsx(Os,{size:20,className:"text-muted animate-spin"}),o.jsx("span",{className:"text-xs text-muted",children:"Loading git status..."})]})}):f&&!i?o.jsx("div",{className:"h-full flex items-center justify-center p-6",children:o.jsxs("div",{className:"flex flex-col items-center gap-3 text-center",children:[o.jsx(un,{size:32,className:"text-muted/40"}),o.jsx("p",{className:"text-sm text-muted",children:f}),o.jsx("p",{className:"text-xs text-muted/60",children:"This project may not be a git repository."}),o.jsx(we,{size:"sm",variant:"secondary",icon:Os,onClick:O,children:"Retry"})]})}):o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[o.jsx(Te,{size:14,className:"text-primary"}),o.jsx("span",{className:"text-xs font-semibold text-ink",children:(i==null?void 0:i.branch)||"unknown"}),i&&(i.ahead>0||i.behind>0)&&o.jsxs("span",{className:"text-[10px] text-muted font-mono",children:[i.ahead>0&&`+${i.ahead}`,i.ahead>0&&i.behind>0&&" / ",i.behind>0&&`-${i.behind}`]}),(i==null?void 0:i.clean)&&o.jsxs("span",{className:"flex items-center gap-0.5 text-[10px] text-green-500",children:[o.jsx(us,{size:10})," Clean"]}),o.jsx("div",{className:"flex-1"}),o.jsx("button",{onClick:O,className:"p-1 text-muted hover:text-ink rounded transition-colors",title:"Refresh",children:o.jsx(Os,{size:13,className:c?"animate-spin":""})})]}),o.jsx("div",{className:"flex items-center gap-1 px-2 py-1.5 border-b border-border flex-shrink-0",children:[{id:"changes",label:"Changes",icon:he,count:(i==null?void 0:i.files.length)||0},{id:"history",label:"History",icon:vt},{id:"branches",label:"Branches",icon:Te,count:l.length}].map(z=>o.jsxs("button",{onClick:()=>s(z.id),className:`flex items-center gap-1 px-2.5 py-1 text-[11px] font-medium rounded-btn transition-colors ${t===z.id?"bg-primary/10 text-primary":"text-muted hover:text-ink"}`,children:[o.jsx(z.icon,{size:12}),z.label,z.count!==void 0&&z.count>0&&o.jsx("span",{className:"ml-0.5 px-1 py-0 text-[9px] rounded-full bg-primary/20 text-primary font-mono",children:z.count})]},z.id))}),f&&o.jsx("div",{className:"px-3 py-2 bg-red-500/5 border-b border-red-500/20 text-xs text-red-400",children:f}),o.jsxs("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:[t==="changes"&&o.jsx("div",{className:"flex flex-col h-full",children:(i==null?void 0:i.files.length)===0?o.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o.jsx(us,{size:28,className:"text-green-500/30 mb-2"}),o.jsx("p",{className:"text-xs text-muted",children:"Working tree clean"}),o.jsx("p",{className:"text-[11px] text-muted/60 mt-0.5",children:"No changes to commit."})]}):o.jsxs(o.Fragment,{children:[ce.length>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-green-500/5 border-b border-border",children:["Staged (",ce.length,")"]}),ce.map((z,oe)=>o.jsx(za,{file:z},`s-${oe}`))]}),fe.length>0&&o.jsxs("div",{children:[o.jsxs("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-yellow-500/5 border-b border-border",children:["Unstaged (",fe.length,")"]}),fe.map((z,oe)=>o.jsx(za,{file:z},`u-${oe}`))]}),o.jsxs("div",{className:"mt-auto border-t border-border p-3 space-y-2 flex-shrink-0",children:[o.jsx("textarea",{value:g,onChange:z=>p(z.target.value),placeholder:"Commit message...",rows:2,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary transition-colors resize-none font-mono"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(we,{size:"sm",icon:Ga,onClick:K,disabled:!g.trim()||m,loading:m,children:"Commit"}),o.jsx(we,{size:"sm",variant:"secondary",icon:dd,onClick:se,loading:J,disabled:J,children:"Push"}),o.jsx(we,{size:"sm",variant:"ghost",icon:co,onClick:()=>V(!X),children:"PR"})]}),x&&o.jsx("p",{className:`text-[11px] font-mono ${x.startsWith("Error")?"text-red-400":"text-green-500"}`,children:x}),$&&o.jsx("p",{className:"text-[11px] font-mono text-primary",children:$.startsWith("Error")?o.jsx("span",{className:"text-red-400",children:$}):o.jsx("a",{href:$,target:"_blank",rel:"noopener noreferrer",className:"underline hover:text-primary/80",children:$})})]}),X&&o.jsxs("div",{className:"border-t border-border p-3 space-y-2 flex-shrink-0 bg-hover",children:[o.jsx("p",{className:"text-[11px] font-semibold text-ink",children:"Create Pull Request"}),o.jsx("input",{value:I,onChange:z=>D(z.target.value),placeholder:"PR title...",className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary"}),o.jsx("textarea",{value:C,onChange:z=>P(z.target.value),placeholder:"PR description (optional)...",rows:3,className:"w-full px-3 py-1.5 text-xs bg-card border border-border rounded-btn outline-none focus:border-primary resize-none"}),o.jsxs("div",{className:"flex gap-2",children:[o.jsx(we,{size:"sm",icon:co,onClick:ae,disabled:!I.trim()||w,loading:w,children:"Create PR"}),o.jsx(we,{size:"sm",variant:"ghost",onClick:()=>V(!1),children:"Cancel"})]})]})]})}),t==="history"&&o.jsx("div",{children:n.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o.jsx(vt,{size:28,className:"text-muted/30 mb-2"}),o.jsx("p",{className:"text-xs text-muted",children:"No commits yet"})]}):n.map((z,oe)=>o.jsx(Zm,{commit:z},oe))}),t==="branches"&&o.jsxs("div",{children:[o.jsx("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:o.jsxs("button",{onClick:()=>k(!j),className:"flex items-center gap-1 text-xs text-primary hover:text-primary/80 font-medium",children:[o.jsx(Ii,{size:12}),"New Branch"]})}),j&&o.jsxs("div",{className:"px-3 py-2 border-b border-border bg-hover flex items-center gap-2",children:[o.jsx("input",{value:S,onChange:z=>E(z.target.value),placeholder:"branch-name",className:"flex-1 px-2 py-1 text-xs font-mono bg-card border border-border rounded-btn outline-none focus:border-primary",onKeyDown:z=>{z.key==="Enter"&&q()}}),o.jsx(we,{size:"sm",onClick:q,disabled:!S.trim()||B,loading:B,children:"Create"})]}),l.length===0?o.jsxs("div",{className:"flex flex-col items-center justify-center py-12 text-center",children:[o.jsx(Te,{size:28,className:"text-muted/30 mb-2"}),o.jsx("p",{className:"text-xs text-muted",children:"No branches found"})]}):o.jsxs("div",{children:[l.filter(z=>!z.remote).map((z,oe)=>o.jsxs("button",{onClick:()=>!z.current&&te(z.name),disabled:z.current,className:`w-full text-left flex items-center gap-2 px-3 py-2 text-xs border-b border-border transition-colors ${z.current?"bg-primary/5":"hover:bg-hover cursor-pointer"}`,children:[o.jsx(Te,{size:13,className:z.current?"text-primary":"text-muted"}),o.jsx("span",{className:`font-mono ${z.current?"text-primary font-semibold":"text-ink"}`,children:z.name}),z.current&&o.jsx("span",{className:"ml-auto text-[10px] bg-primary/10 text-primary px-1.5 py-0.5 rounded font-medium",children:"current"})]},`l-${oe}`)),l.filter(z=>z.remote).length>0&&o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"px-3 py-1.5 text-[10px] font-semibold text-muted uppercase tracking-wider bg-hover border-b border-border",children:"Remote"}),l.filter(z=>z.remote).map((z,oe)=>o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 text-xs border-b border-border",children:[o.jsx(Te,{size:13,className:"text-muted/60"}),o.jsx("span",{className:"font-mono text-muted",children:z.name})]},`r-${oe}`))]})]})]})]})]})}function eg({sessionId:e,onRestore:t}){const[s,i]=_.useState([]),[r,n]=_.useState(!0),[a,l]=_.useState(null),[h,c]=_.useState(null),[d,f]=_.useState(null),u=_.useCallback(async()=>{try{const m=await Y.getCheckpoints(e);i(m),f(null)}catch{f("Failed to load checkpoints")}n(!1)},[e]);_.useEffect(()=>{u();const m=setInterval(u,15e3);return()=>clearInterval(m)},[u]);const g=_.useCallback(async m=>{if(a)return;const y=s.find(b=>b.id===m);if(!(!y||!window.confirm(`Restore to checkpoint "${y.description}"?
282
+
283
+ This will revert files to this checkpoint state.`))){l(m);try{await Y.restoreCheckpoint(e,m),await u(),t==null||t()}catch{f("Failed to restore checkpoint")}l(null)}},[e,s,a,u,t]);if(r)return o.jsxs("div",{className:"flex items-center gap-2 px-4 py-2 bg-card border-b border-border",children:[o.jsx(ho,{size:14,className:"text-muted animate-pulse"}),o.jsx("span",{className:"text-xs text-muted",children:"Loading checkpoints..."})]});if(d&&s.length===0||s.length===0)return null;const p=m=>{if(!m)return"";try{return new Date(m).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"})}catch{return""}};return o.jsxs("div",{className:"flex items-center gap-2 px-4 py-1.5 bg-card border-b border-border overflow-x-auto",children:[o.jsx(ho,{size:14,className:"text-muted flex-shrink-0"}),o.jsx("span",{className:"text-[11px] font-medium text-muted flex-shrink-0",children:"Checkpoints"}),o.jsx("div",{className:"flex items-center gap-1 flex-1 min-w-0",children:s.map((m,y)=>o.jsxs("div",{className:"flex items-center gap-1",children:[y>0&&o.jsx("div",{className:"w-4 h-px bg-border flex-shrink-0"}),o.jsxs("div",{className:"relative flex-shrink-0",children:[o.jsx("button",{onClick:()=>g(m.id),onMouseEnter:()=>c(m.id),onMouseLeave:()=>c(null),disabled:a!==null,className:`w-3.5 h-3.5 rounded-full border-2 transition-all cursor-pointer ${m.is_current?"bg-primary border-primary shadow-sm shadow-primary/30":a===m.id?"bg-warning border-warning animate-pulse":"bg-card border-border hover:border-primary hover:bg-primary/10"} ${a!==null&&a!==m.id?"opacity-50":""}`,title:`${m.description} -- Click to restore`}),h===m.id&&o.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-2 z-50 pointer-events-none",children:[o.jsxs("div",{className:"bg-card border border-border rounded-lg shadow-lg px-3 py-2 whitespace-nowrap",children:[o.jsx("p",{className:"text-xs font-medium text-ink",children:m.description}),o.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[m.timestamp&&o.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[o.jsx(vt,{size:10}),p(m.timestamp)]}),m.files_changed>0&&o.jsxs("span",{className:"flex items-center gap-1 text-[11px] text-muted",children:[o.jsx(he,{size:10}),m.files_changed," file",m.files_changed!==1?"s":""]}),m.iteration>0&&o.jsxs("span",{className:"text-[11px] text-muted",children:["Iter ",m.iteration]})]}),!m.is_current&&o.jsxs("div",{className:"flex items-center gap-1 mt-1.5 text-[11px] text-primary font-medium",children:[o.jsx(id,{size:10}),"Click to restore"]}),m.is_current&&o.jsx("div",{className:"text-[11px] text-success mt-1",children:"Current"})]}),o.jsx("div",{className:"w-2 h-2 bg-card border-r border-b border-border rotate-45 mx-auto -mt-1"})]})]})]},m.id))}),d&&o.jsx("span",{className:"text-[11px] text-danger flex-shrink-0",children:d})]})}function tg({line:e}){const t=e.type==="add"?"bg-success/10":e.type==="delete"?"bg-danger/10":"",s=e.type==="add"?"text-success":e.type==="delete"?"text-danger":"text-muted",i=e.type==="add"?"+":e.type==="delete"?"-":" ",r=e.type==="delete"?e.old_line:e.new_line;return o.jsxs("div",{className:`flex font-mono text-xs leading-5 ${t}`,children:[o.jsx("span",{className:"w-12 text-right pr-2 text-muted/60 select-none flex-shrink-0 border-r border-border",children:r||""}),o.jsx("span",{className:`w-5 text-center select-none flex-shrink-0 ${s} font-bold`,children:i}),o.jsx("span",{className:`flex-1 whitespace-pre-wrap break-all pl-1 ${e.type==="context"?"text-ink/70":s}`,children:e.content})]})}function sg({file:e,isSelected:t,onToggle:s}){const[i,r]=_.useState(!0),n=e.action==="add"?o.jsx($i,{size:14,className:"text-success"}):e.action==="delete"?o.jsx(jh,{size:14,className:"text-danger"}):o.jsx(he,{size:14,className:"text-blue-500"}),a=e.action==="add"?"New":e.action==="delete"?"Deleted":"Modified";return o.jsxs("div",{className:"border border-border rounded-lg overflow-hidden",children:[o.jsxs("div",{className:"flex items-center gap-2 px-3 py-2 bg-hover/50",children:[o.jsx("input",{type:"checkbox",checked:t,onChange:s,className:"w-3.5 h-3.5 rounded border-border accent-primary cursor-pointer"}),o.jsxs("button",{onClick:()=>r(l=>!l),className:"flex items-center gap-1 flex-1 min-w-0 text-left",children:[o.jsx(Oi,{size:14,className:`text-muted transition-transform flex-shrink-0 ${i?"rotate-90":""}`}),n,o.jsx("span",{className:"text-xs font-mono text-ink truncate",children:e.path})]}),o.jsx("span",{className:`text-[11px] font-medium px-1.5 py-0.5 rounded ${e.action==="add"?"bg-success/10 text-success":e.action==="delete"?"bg-danger/10 text-danger":"bg-blue-500/10 text-blue-500"}`,children:a}),e.additions>0&&o.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-success",children:[o.jsx(Ii,{size:10}),e.additions]}),e.deletions>0&&o.jsxs("span",{className:"flex items-center gap-0.5 text-[11px] text-danger",children:[o.jsx(Za,{size:10}),e.deletions]})]}),i&&e.hunks.length>0&&o.jsx("div",{className:"border-t border-border max-h-[300px] overflow-y-auto terminal-scroll",children:e.hunks.map((l,h)=>o.jsxs("div",{children:[h>0&&o.jsxs("div",{className:"px-3 py-1 bg-hover/30 text-[11px] text-muted font-mono border-y border-border",children:["@@ -",l.old_start,",",l.old_count," +",l.new_start,",",l.new_count," @@"]}),l.lines.map((c,d)=>o.jsx(tg,{line:c},`${h}-${d}`))]},h))})]})}function ig({data:e,onAcceptAll:t,onAcceptSelected:s,onReject:i,onClose:r}){const[n,a]=_.useState(()=>new Set(e.files.map(u=>u.path))),[l,h]=_.useState(0),c=_.useCallback(u=>{a(g=>{const p=new Set(g);return p.has(u)?p.delete(u):p.add(u),p})},[]),d=_.useCallback(()=>{n.size===e.files.length?a(new Set):a(new Set(e.files.map(u=>u.path)))},[n.size,e.files]),f=_.useCallback(()=>{s(Array.from(n))},[n,s]);return e.files.length===0?o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center",onClick:r,children:[o.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),o.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border p-8 max-w-md",onClick:u=>u.stopPropagation(),children:[o.jsx("p",{className:"text-sm text-ink text-center",children:"No pending changes to preview."}),o.jsx("button",{onClick:r,className:"mt-4 w-full py-2 text-sm font-medium rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Close"})]})]}):o.jsxs("div",{className:"fixed inset-0 z-50 flex items-center justify-center p-4",onClick:r,children:[o.jsx("div",{className:"absolute inset-0 bg-black/40 backdrop-blur-sm"}),o.jsxs("div",{className:"relative bg-card rounded-xl shadow-2xl border border-border w-full max-w-5xl max-h-[85vh] flex flex-col overflow-hidden",onClick:u=>u.stopPropagation(),children:[o.jsxs("div",{className:"flex items-center gap-3 px-4 py-3 border-b border-border flex-shrink-0",children:[o.jsx(he,{size:18,className:"text-primary"}),o.jsx("h3",{className:"text-sm font-bold text-ink flex-1",children:"Change Preview"}),o.jsxs("div",{className:"flex items-center gap-2 text-xs text-muted",children:[o.jsxs("span",{className:"flex items-center gap-1 text-success",children:[o.jsx(Ii,{size:12}),e.total_additions]}),o.jsxs("span",{className:"flex items-center gap-1 text-danger",children:[o.jsx(Za,{size:12}),e.total_deletions]}),o.jsxs("span",{children:[e.files.length," file",e.files.length!==1?"s":""]})]}),o.jsx("button",{onClick:r,className:"p-1 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:o.jsx(Wt,{size:16})})]}),o.jsxs("div",{className:"flex flex-1 min-h-0",children:[o.jsxs("div",{className:"w-56 flex-shrink-0 border-r border-border overflow-y-auto terminal-scroll bg-hover/30",children:[o.jsx("div",{className:"px-3 py-2 border-b border-border",children:o.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[o.jsx("input",{type:"checkbox",checked:n.size===e.files.length,onChange:d,className:"w-3.5 h-3.5 rounded border-border accent-primary"}),o.jsx("span",{className:"text-[11px] font-medium text-muted",children:"Select All"})]})}),e.files.map((u,g)=>{const p=u.action==="add"?"text-success":u.action==="delete"?"text-danger":"text-blue-500";return o.jsxs("button",{onClick:()=>h(g),className:`w-full flex items-center gap-2 px-3 py-1.5 text-left transition-colors ${g===l?"bg-primary/10 text-primary":"text-ink hover:bg-hover"}`,children:[o.jsx("input",{type:"checkbox",checked:n.has(u.path),onChange:()=>c(u.path),onClick:m=>m.stopPropagation(),className:"w-3 h-3 rounded border-border accent-primary flex-shrink-0"}),o.jsx("span",{className:"text-xs font-mono truncate flex-1",children:u.path.split("/").pop()}),o.jsx("span",{className:`text-[10px] flex-shrink-0 ${p}`,children:u.action==="add"?"+":u.action==="delete"?"-":"M"})]},u.path)})]}),o.jsx("div",{className:"flex-1 overflow-y-auto p-4 space-y-3 terminal-scroll",children:e.files[l]&&o.jsx(sg,{file:e.files[l],isSelected:n.has(e.files[l].path),onToggle:()=>c(e.files[l].path)})})]}),o.jsxs("div",{className:"flex items-center gap-2 px-4 py-3 border-t border-border bg-hover/30 flex-shrink-0",children:[o.jsxs("button",{onClick:i,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-danger/30 text-danger hover:bg-danger/10 transition-colors",children:[o.jsx(uh,{size:14}),"Reject"]}),o.jsx("div",{className:"flex-1"}),o.jsxs("button",{onClick:f,disabled:n.size===0,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary/30 text-primary hover:bg-primary/10 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[o.jsx(us,{size:14}),"Accept Selected (",n.size,")"]}),o.jsxs("button",{onClick:t,className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover transition-colors",children:[o.jsx(ph,{size:14}),"Accept All"]})]})]})]})}const rg={Build:dn,Test:xi,Deploy:gt},Ln={pending:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:vt,label:"Pending"},running:{color:"text-[#553DE9]",bg:"bg-[#553DE9]/10",Icon:Ja,label:"Running"},success:{color:"text-[#1FC5A8]",bg:"bg-[#1FC5A8]/10",Icon:Fa,label:"Success"},failed:{color:"text-[#C45B5B]",bg:"bg-[#C45B5B]/10",Icon:ji,label:"Failed"},skipped:{color:"text-[#939084]",bg:"bg-[#939084]/10",Icon:vt,label:"Skipped"}};function pc({status:e}){const t=Ln[e];return o.jsxs("span",{className:`inline-flex items-center gap-1 px-2 py-0.5 rounded-full text-xs font-medium ${t.bg} ${t.color}`,children:[o.jsx(t.Icon,{size:12,className:e==="running"?"animate-spin":""}),t.label]})}function ng({stage:e}){const[t,s]=_.useState(!1),i=rg[e.name]||ds;return o.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[o.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[t?o.jsx(Ai,{size:14,className:"text-[#939084]"}):o.jsx(Oi,{size:14,className:"text-[#939084]"}),o.jsx(i,{size:16,className:Ln[e.status].color}),o.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3] flex-1",children:e.name}),e.duration&&o.jsx("span",{className:"text-xs text-[#939084] font-mono",children:e.duration}),o.jsx(pc,{status:e.status})]}),t&&o.jsx("div",{className:"border-t border-[#ECEAE3] dark:border-[#2A2A30] bg-[#0F0F11] text-[#E8E6E3] p-3 max-h-64 overflow-y-auto terminal-scroll",children:e.logs&&e.logs.length>0?o.jsx("pre",{className:"text-xs font-mono leading-relaxed whitespace-pre-wrap",children:e.logs.join(`
284
+ `)}):o.jsx("p",{className:"text-xs text-[#939084] font-mono",children:"No logs available"})})]})}function og({run:e}){const[t,s]=_.useState(!1);return o.jsxs("div",{className:"border border-[#ECEAE3] dark:border-[#2A2A30] rounded-lg overflow-hidden",children:[o.jsxs("button",{onClick:()=>s(!t),className:"w-full flex items-center gap-3 px-4 py-3 text-left hover:bg-[#F8F4F0] dark:hover:bg-[#222228] transition-colors",children:[t?o.jsx(Ai,{size:14,className:"text-[#939084]"}):o.jsx(Oi,{size:14,className:"text-[#939084]"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("span",{className:"text-sm font-medium text-[#201515] dark:text-[#E8E6E3]",children:e.name}),o.jsx(pc,{status:e.status})]}),o.jsxs("div",{className:"flex items-center gap-3 mt-1",children:[o.jsxs("span",{className:"inline-flex items-center gap-1 text-xs text-[#939084]",children:[o.jsx(Te,{size:12}),e.branch]}),o.jsxs("span",{className:"text-xs text-[#939084] font-mono truncate max-w-[200px]",children:[e.commit.substring(0,7)," - ",e.commitMessage]})]})]}),o.jsxs("div",{className:"text-right flex-shrink-0",children:[o.jsxs("p",{className:"text-xs text-[#939084]",children:["by ",e.triggeredBy]}),o.jsx("p",{className:"text-xs text-[#939084] font-mono",children:e.startedAt})]})]}),t&&o.jsxs("div",{className:"px-4 pb-4 border-t border-[#ECEAE3] dark:border-[#2A2A30] space-y-2 pt-3",children:[o.jsx("div",{className:"flex items-center gap-1 mb-3",children:e.stages.map((i,r)=>o.jsxs("div",{className:"flex items-center flex-1",children:[o.jsx("div",{className:`flex-1 h-1.5 rounded-full ${Ln[i.status].bg}`,children:o.jsx("div",{className:`h-full rounded-full transition-all duration-500 ${i.status==="success"?"bg-[#1FC5A8]":i.status==="running"?"bg-[#553DE9] animate-pulse":i.status==="failed"?"bg-[#C45B5B]":"bg-[#939084]/30"}`,style:{width:i.status==="pending"?"0%":i.status==="running"?"50%":"100%"}})}),r<e.stages.length-1&&o.jsx("div",{className:"w-4 flex items-center justify-center",children:o.jsx("div",{className:"w-1 h-1 rounded-full bg-[#ECEAE3] dark:bg-[#2A2A30]"})})]},i.id))}),e.stages.map(i=>o.jsx(ng,{stage:i},i.id))]})]})}function ag(){return[{id:"run-1",name:"CI Pipeline",branch:"main",commit:"a1b2c3d4",commitMessage:"Add notification system",status:"success",triggeredBy:"developer",startedAt:new Date(Date.now()-6e5).toLocaleString(),finishedAt:new Date(Date.now()-3e5).toLocaleString(),stages:[{id:"build-1",name:"Build",status:"success",duration:"1m 23s",logs:["> npm ci","added 1247 packages in 45s","> npm run build","vite v5.4.0 building for production...","transforming (342) src/main.tsx","build completed in 38s","dist/index.html 0.46 kB | gzip: 0.30 kB","dist/assets/index-DiwrgTda.css 45.21 kB | gzip: 8.91 kB","dist/assets/index-BqWFE2Nh.js 285.39 kB | gzip: 91.22 kB","BUILD SUCCESSFUL"]},{id:"test-1",name:"Test",status:"success",duration:"2m 10s",logs:["> npm test","PASS src/components/NotificationSystem.test.tsx","PASS src/components/TeamPanel.test.tsx","PASS src/components/RBACPanel.test.tsx","","Test Suites: 12 passed, 12 total","Tests: 48 passed, 48 total","Time: 2.1s","ALL TESTS PASSED"]},{id:"deploy-1",name:"Deploy",status:"success",duration:"45s",logs:["Deploying to production...","Uploading build artifacts...","Updating service configuration...","Health check: OK","DEPLOY SUCCESSFUL"]}]},{id:"run-2",name:"CI Pipeline",branch:"feature/auth",commit:"e5f6g7h8",commitMessage:"Fix login redirect",status:"failed",triggeredBy:"developer",startedAt:new Date(Date.now()-36e5).toLocaleString(),stages:[{id:"build-2",name:"Build",status:"success",duration:"1m 15s",logs:["BUILD SUCCESSFUL"]},{id:"test-2",name:"Test",status:"failed",duration:"1m 45s",logs:["> npm test","PASS src/components/NotificationSystem.test.tsx","FAIL src/hooks/useAuth.test.tsx"," - should redirect to login on 401 (assertion error)",' Expected: "/login"',' Received: "/"',"","Test Suites: 1 failed, 11 passed, 12 total","Tests: 1 failed, 47 passed, 48 total","TEST FAILED"]},{id:"deploy-2",name:"Deploy",status:"skipped",logs:["Skipped due to test failure"]}]}]}function lg({sessionId:e,onTriggerPipeline:t}){const[s,i]=_.useState([]),[r,n]=_.useState(!0),a=_.useCallback(()=>{n(!0),setTimeout(()=>{i(ag()),n(!1)},500)},[]);_.useEffect(()=>{a()},[a,e]);const l=()=>{t&&t();const h={id:`run-${Date.now()}`,name:"CI Pipeline",branch:"main",commit:Math.random().toString(36).substring(2,10),commitMessage:"Manual trigger",status:"running",triggeredBy:"manual",startedAt:new Date().toLocaleString(),stages:[{id:`build-${Date.now()}`,name:"Build",status:"running",logs:["Starting build..."]},{id:`test-${Date.now()}`,name:"Test",status:"pending",logs:[]},{id:`deploy-${Date.now()}`,name:"Deploy",status:"pending",logs:[]}]};i(c=>[h,...c])};return o.jsxs("div",{className:"card p-6",children:[o.jsxs("div",{className:"flex items-center justify-between mb-4",children:[o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(Te,{size:18,className:"text-[#553DE9]"}),o.jsx("h3",{className:"text-sm font-semibold text-[#201515] dark:text-[#E8E6E3] uppercase tracking-wider",children:"CI/CD Pipelines"})]}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx(we,{size:"sm",variant:"ghost",icon:Os,onClick:a,children:"Refresh"}),o.jsx(we,{size:"sm",icon:gi,onClick:l,children:"Trigger Pipeline"})]})]}),!r&&s.length>0&&o.jsxs("div",{className:"flex items-center gap-4 mb-4 text-xs",children:[o.jsxs("span",{className:"flex items-center gap-1 text-[#1FC5A8]",children:[o.jsx(Fa,{size:12}),s.filter(h=>h.status==="success").length," passed"]}),o.jsxs("span",{className:"flex items-center gap-1 text-[#C45B5B]",children:[o.jsx(ji,{size:12}),s.filter(h=>h.status==="failed").length," failed"]}),o.jsxs("span",{className:"flex items-center gap-1 text-[#553DE9]",children:[o.jsx(Ja,{size:12}),s.filter(h=>h.status==="running").length," running"]})]}),r&&o.jsx("div",{className:"text-center py-8 text-[#939084] text-sm",children:"Loading pipelines..."}),!r&&s.length===0&&o.jsxs("div",{className:"text-center py-8",children:[o.jsx("p",{className:"text-[#939084] text-sm",children:"No pipeline runs yet"}),o.jsx("p",{className:"text-[#553DE9]/60 text-xs mt-1",children:"Trigger a pipeline or push to your repository"})]}),!r&&s.length>0&&o.jsx("div",{className:"space-y-3 max-h-[600px] overflow-y-auto terminal-scroll",children:s.map(h=>o.jsx(og,{run:h},h.id))})]})}function cg({sessionId:e}){return o.jsx(lg,{sessionId:e})}function ln(e,t,s){var n;if(t==="directory")return s?o.jsx(vr,{size:14}):o.jsx(Ya,{size:14});const i=((n=e.split(".").pop())==null?void 0:n.toLowerCase())||"";return{js:o.jsx(he,{size:14,className:"text-yellow-600"}),ts:o.jsx(he,{size:14,className:"text-blue-500"}),tsx:o.jsx(he,{size:14,className:"text-blue-400"}),jsx:o.jsx(he,{size:14,className:"text-yellow-500"}),py:o.jsx(he,{size:14,className:"text-green-600"}),html:o.jsx(Ua,{size:14,className:"text-orange-500"}),css:o.jsx(qa,{size:14,className:"text-purple-500"}),json:o.jsx(Wa,{size:14,className:"text-green-500"}),md:o.jsx(hn,{size:14,className:"text-muted"}),go:o.jsx(he,{size:14,className:"text-cyan-600"}),rs:o.jsx(he,{size:14,className:"text-orange-600"}),rb:o.jsx(he,{size:14,className:"text-red-500"}),sh:o.jsx(he,{size:14,className:"text-green-600"})}[i]||o.jsx(Va,{size:14})}function hg(e){var r;const t=((r=e.split(".").pop())==null?void 0:r.toLowerCase())||"",s={js:"javascript",jsx:"javascript",ts:"typescript",tsx:"typescript",py:"python",html:"html",htm:"html",css:"css",scss:"scss",less:"less",json:"json",md:"markdown",go:"go",rs:"rust",sh:"shell",bash:"shell",yml:"yaml",yaml:"yaml",xml:"xml",svg:"xml",sql:"sql",java:"java",kt:"kotlin",rb:"ruby",dockerfile:"dockerfile"},i=e.toLowerCase();return i==="dockerfile"?"dockerfile":i==="makefile"?"makefile":s[t]||"plaintext"}function _c(e,t){for(const s of e){if(s.path===t)return s.size;if(s.children){const i=_c(s.children,t);if(i!==void 0)return i}}}function mc(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/(1024*1024)).toFixed(1)} MB`}function gc({nodes:e,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:r,depth:n=0}){const[a,l]=_.useState(()=>{const h=new Set;return n<2&&e.filter(c=>c.type==="directory").forEach(c=>h.add(c.path)),h});return o.jsx("div",{role:n===0?"tree":"group",children:e.map(h=>{const c=h.type==="directory",d=a.has(h.path),f=h.path===t;return o.jsxs("div",{className:"group/file",children:[o.jsxs("button",{role:"treeitem","aria-label":h.name,"aria-selected":f,...c?{"aria-expanded":d}:{},onContextMenu:u=>{u.preventDefault(),r==null||r(u,h.path,h.name,h.type)},onClick:()=>{c?l(u=>{const g=new Set(u);return g.has(h.path)?g.delete(h.path):g.add(h.path),g}):s(h.path,h.name)},className:`w-full text-left flex items-center gap-1.5 px-2 py-1 text-xs font-mono rounded transition-colors ${f?"bg-primary/10 text-primary":"text-ink/70 hover:bg-hover"}`,style:{paddingLeft:`${n*14+8}px`},children:[c?o.jsx("span",{className:"w-3 flex items-center justify-center flex-shrink-0 text-muted",children:d?o.jsx(Ai,{size:14}):o.jsx(Oi,{size:14})}):o.jsx("span",{className:"w-3 flex-shrink-0"}),o.jsx("span",{className:`w-5 flex items-center justify-center flex-shrink-0 ${c?"text-primary":""}`,children:ln(h.name,h.type,d)}),o.jsxs("span",{className:"truncate",children:[h.name,c?"/":""]}),!c&&h.size!=null&&h.size>0&&o.jsx("span",{className:"text-xs text-muted ml-auto flex-shrink-0",children:mc(h.size)}),!c&&i&&o.jsx("span",{role:"button",tabIndex:-1,onClick:u=>{u.stopPropagation(),i(h.path,h.name)},onKeyDown:u=>{u.key==="Enter"&&(u.stopPropagation(),i(h.path,h.name))},className:"text-muted hover:text-danger ml-1 flex-shrink-0 opacity-0 group-hover/file:opacity-100 transition-opacity cursor-pointer",title:"Delete file",children:o.jsx(Wt,{size:12})})]}),c&&d&&h.children&&o.jsx(gc,{nodes:h.children,selectedPath:t,onSelect:s,onDelete:i,onContextMenu:r,depth:n+1})]},h.path)})})}function vc(e,t=""){const s=[];for(const i of e)i.type==="file"&&s.push({path:i.path,name:i.name}),i.children&&s.push(...vc(i.children,i.path+"/"));return s}function dg(){const[e,t]=_.useState({}),[s,i]=_.useState(""),[r,n]=_.useState(""),[a,l]=_.useState(!0),[h,c]=_.useState(null),[d,f]=_.useState(new Set),u=_.useCallback(async()=>{try{const x=await Y.getSecrets();t(x)}catch{}l(!1)},[]);_.useEffect(()=>{u()},[u]);const g=async()=>{const x=s.trim();if(x){if(!/^[A-Z_][A-Z0-9_]*$/.test(x)){c("Key must be a valid ENV_VAR name (uppercase letters, digits, underscores)");return}c(null);try{await Y.setSecret(x,r),i(""),n(""),await u()}catch(b){c(b instanceof Error?b.message:"Failed to set secret")}}},p=async x=>{if(window.confirm(`Delete secret "${x}"?`))try{await Y.deleteSecret(x),await u()}catch(b){c(b instanceof Error?b.message:"Failed to delete secret")}},m=x=>{f(b=>{const j=new Set(b);return j.has(x)?j.delete(x):j.add(x),j})},y=Object.keys(e);return a?o.jsxs("div",{className:"p-6 space-y-4",children:[o.jsx(Xi,{variant:"text",width:"180px",height:"16px"}),o.jsx(Xi,{variant:"block",width:"100%",height:"60px"}),o.jsx(Xi,{variant:"block",width:"100%",height:"80px"})]}):o.jsx("div",{className:"h-full flex flex-col",children:o.jsxs("div",{className:"p-6 overflow-y-auto",children:[o.jsx("h3",{className:"text-h3 font-heading text-ink mb-2",children:"Environment Secrets"}),o.jsxs("div",{className:"flex items-start gap-2 px-4 py-3 rounded-btn border border-warning/30 bg-warning/5 mb-6",children:[o.jsx($a,{size:16,className:"text-warning flex-shrink-0 mt-0.5"}),o.jsx("p",{className:"text-xs text-warning leading-relaxed",children:"Secrets are stored locally in plaintext and injected as environment variables during builds. They are never committed to the project repository."})]}),y.length>0&&o.jsx("div",{className:"card mb-6",children:o.jsxs("table",{className:"w-full text-sm",children:[o.jsx("thead",{children:o.jsxs("tr",{className:"border-b border-border",children:[o.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Key"}),o.jsx("th",{className:"text-left px-4 py-2 text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Value"}),o.jsx("th",{className:"w-20 px-4 py-2"})]})}),o.jsx("tbody",{children:y.map(x=>o.jsxs("tr",{className:"border-b border-border last:border-b-0",children:[o.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-ink",children:x}),o.jsx("td",{className:"px-4 py-2.5 font-mono text-xs text-muted-accessible",children:o.jsxs("span",{className:"flex items-center gap-2",children:[o.jsx("span",{children:d.has(x)?e[x]:"***"}),o.jsx("button",{onClick:()=>m(x),className:"text-muted hover:text-ink transition-colors",title:d.has(x)?"Hide value":"Show value",children:d.has(x)?o.jsx(bh,{size:14}):o.jsx(rs,{size:14})})]})}),o.jsx("td",{className:"px-4 py-2.5 text-right",children:o.jsx("button",{onClick:()=>p(x),className:"text-muted hover:text-danger transition-colors",title:"Delete secret",children:o.jsx(fn,{size:14})})})]},x))})]})}),y.length===0&&o.jsx("div",{className:"card p-4 mb-6",children:o.jsx("p",{className:"text-sm text-muted-accessible text-center py-4",children:"No secrets configured yet. Add your first secret below."})}),o.jsxs("div",{className:"card p-4",children:[o.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-3",children:"Add Secret"}),h&&o.jsx("div",{className:"text-xs text-danger mb-3 px-1",children:h}),o.jsxs("div",{className:"flex items-end gap-3",children:[o.jsxs("div",{className:"flex-1",children:[o.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Key"}),o.jsx("input",{type:"text",value:s,onChange:x=>i(x.target.value.toUpperCase()),placeholder:"API_KEY",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),o.jsxs("div",{className:"flex-1",children:[o.jsx("label",{className:"block text-xs text-muted-accessible mb-1",children:"Value"}),o.jsx("input",{type:"password",value:r,onChange:x=>n(x.target.value),placeholder:"secret value",className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink placeholder:text-muted"})]}),o.jsxs("button",{onClick:g,disabled:!s.trim(),className:"flex items-center gap-1.5 px-4 py-2 text-sm font-medium rounded-btn border border-primary bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-40 disabled:cursor-not-allowed",children:[o.jsx(Ii,{size:14}),"Add"]})]})]})]})})}function ug({session:e,onClose:t}){var Qn;const[s,i]=_.useState(null),[r,n]=_.useState(""),[a,l]=_.useState(null),[h,c]=_.useState(null),[d,f]=_.useState(!1),[u,g]=_.useState("code"),[p,m]=_.useState(!1),[y,x]=_.useState(!1),[b,j]=_.useState(e),k=_.useRef(null),[S,E]=_.useState([]),[B,U]=_.useState(!1),[X,V]=_.useState(""),I=_.useRef(null),D=_.useRef(null),[C,P]=_.useState(0),[w,M]=_.useState(null),[$,R]=_.useState(!0),[J,L]=_.useState(!0),[O,K]=_.useState(!1),[q,te]=_.useState("overview"),se=57374,[ae,ce]=_.useState(null),fe=_.useCallback(()=>{K(v=>{const F=!v;return R(!F),L(!F),F})},[]),[z,oe]=_.useState(()=>sessionStorage.getItem(`pl_buildmode_${b.id}`)||"standard"),[We,Ve]=_.useState(()=>sessionStorage.getItem(`pl_provider_${b.id}`)||"claude"),[ne,ve]=_.useState(null),[le,Be]=_.useState(null),[je,Rt]=_.useState(!1),[xc,Zs]=_.useState(!1),[Zt,bc]=_.useState({phase:"idle",iteration:0,maxIterations:10,cost:0,startTime:0}),[yc,Bn]=_.useState(!1),[gs,Qs]=_.useState(null),vs=_.useRef(null),[Sc,zn]=_.useState(!1),[wc,Tn]=_.useState([]),[An,xs]=_.useState(null),{subscribe:On}=Zc(),Ye=_.useCallback(async()=>{try{const v=await Y.getSessionDetail(b.id);j(v)}catch{}},[b.id]),In=_.useCallback(async()=>{try{await Y.stopSession(),Rt(!1),Zs(!1)}catch{}},[]),Cc=_.useCallback(async()=>{try{await Y.pauseSession(),Zs(!0)}catch{}},[]),kc=_.useCallback(async()=>{try{await Y.resumeSession(),Zs(!1)}catch{}},[]),$n=_.useRef("idle");_.useEffect(()=>{const v=async()=>{try{const W=await Y.getStatus();Rt(W.running),Zs(W.paused),W.provider&&Ve(W.provider);const Z=W.phase||"idle";if(Z!==$n.current&&Z!=="idle"){const Ue=new Date().toISOString(),Ze={planning:"Planning phase started",building:"Building your project",testing:"Running tests",reviewing:"Reviewing code quality",complete:"Build complete"},ft={planning:"Analyzing requirements and designing the architecture...",building:"Writing code and creating project files...",testing:"Running test suite to verify everything works...",reviewing:"Checking code quality and best practices...",complete:"All done. Your project is ready."},pt=[{id:`phase-${Date.now()}`,type:"phase_change",message:Ze[Z]||`Phase: ${Z}`,timestamp:Ue}];ft[Z]&&pt.push({id:`narration-${Date.now()}`,type:"narration",message:ft[Z],timestamp:Ue}),Tn(oi=>[...oi,...pt]),$n.current=Z}bc({phase:Z,iteration:W.iteration||0,maxIterations:W.max_iterations||10,cost:W.cost||0,startTime:W.start_time?W.start_time*1e3:0})}catch{}};v();const F=setInterval(v,je?3e3:1e4);return()=>clearInterval(F)},[je]),_.useEffect(()=>{if(!(le!=null&&le.loading))return;const v=setInterval(()=>{Be(F=>F?{...F,elapsed:Math.floor((Date.now()-F.startTime)/1e3)}:null)},1e3);return()=>clearInterval(v)},[le==null?void 0:le.loading]);const[ee,Ec]=_.useState(null);_.useEffect(()=>{Y.getPreviewInfo(b.id).then(Ec).catch(()=>{})},[b.id]);const[A,ei]=_.useState(null),[bs,Fn]=_.useState(!1),[Hn,Wn]=_.useState(!1),[Un,ti]=_.useState(null),[Lt,Nc]=_.useState("");_.useEffect(()=>{const v=On("file_changed",F=>{const W=F;if(!W.paths||W.paths.length===0)return;const Z=new Date().toISOString(),Ue=W.paths.map((Ze,ft)=>{var eo;const pt=(eo=W.event_types)==null?void 0:eo[ft],oi=pt==="created"||pt==="IN_CREATE";return{id:`file-${Date.now()}-${ft}`,type:oi?"file_created":"file_modified",message:oi?`Created ${Ze.split("/").pop()}`:`Modified ${Ze.split("/").pop()}`,timestamp:Z,filePath:Ze}});if(Tn(Ze=>[...Ze,...Ue]),Bn(!0),vs.current&&clearTimeout(vs.current),vs.current=setTimeout(()=>Bn(!1),2e3),Ye(),s&&W.paths.some(ft=>ft===s||s.endsWith(ft))&&Qs(s),u==="preview"){const Ze=["react","vite","next","nuxt","svelte","remix"];(A==null?void 0:A.running)&&(A==null?void 0:A.framework)&&Ze.some(pt=>A.framework.toLowerCase().includes(pt))||P(pt=>pt+1)}});return()=>{v(),vs.current&&clearTimeout(vs.current)}},[On,s,u,A==null?void 0:A.running,Ye]);const jc=_.useCallback(async()=>{if(!(!gs||!b.id)){try{const v=await Y.getSessionFileContent(b.id,gs);l(v.content),c(v.content),m(!1),E(F=>F.map(W=>W.path===gs?{...W,content:v.content,modified:!1}:W))}catch{}Qs(null)}},[gs,b.id]);_.useEffect(()=>{if(u!=="preview")return;let v=!1;const F=async()=>{try{const Z=await Y.devserver.status(b.id);v||ei(Z)}catch{}};F();const W=setInterval(F,3e3);return()=>{v=!0,clearInterval(W)}},[u,b.id]),_.useEffect(()=>{u==="dashboard"&&fetch(`http://127.0.0.1:${se}/health`).then(v=>ce(v.ok)).catch(()=>ce(!1))},[u]);const Qt=_.useCallback(async v=>{Fn(!0),ti(null);try{const F=await Y.devserver.start(b.id,v);if(F.status==="error")ti(F.message||"Failed to start dev server");else{const W=await Y.devserver.status(b.id);ei(W)}}catch(F){ti(F instanceof Error?F.message:"Failed to start dev server")}Fn(!1)},[b.id]),Kn=_.useRef(!1);_.useEffect(()=>{Kn.current||ee!=null&&ee.dev_command&&(A!=null&&A.running||(A==null?void 0:A.status)==="starting"||bs||(Kn.current=!0,Qt(ee.dev_command)))},[ee==null?void 0:ee.dev_command,A==null?void 0:A.running,A==null?void 0:A.status,bs,Qt]);const Dc=_.useCallback(async()=>{try{await Y.devserver.stop(b.id);const v=await Y.devserver.status(b.id);ei(v)}catch{}},[b.id]),Mc=_.useCallback(async()=>{Wn(!0);try{const v=await Y.fixProject(b.id);if(v.task_id){let W=0,Z;do await new Promise(Ze=>setTimeout(Ze,2e3)),Z=await Y.chatPoll(b.id,v.task_id),W++;while(!Z.complete&&W<150);const Ue=await Y.devserver.status(b.id);ei(Ue)}}catch(v){ti(v instanceof Error?v.message:"Fix failed")}Wn(!1)},[b.id]),es=A!=null&&A.running&&(A!=null&&A.port)?A.framework==="expo"?`/api/sessions/${encodeURIComponent(b.id)}/expo-qr`:A.portless_url||`http://localhost:${A.port}/`:null,Pc=(ee==null?void 0:ee.preview_url)||`/api/sessions/${encodeURIComponent(b.id)}/preview/index.html`,Rc=es||Pc,[si,qn]=_.useState([]),[ut,ii]=_.useState(0);_.useEffect(()=>{const v=es||(ee==null?void 0:ee.preview_url);v&&(qn([v]),ii(0))},[es,ee==null?void 0:ee.preview_url]);const Bt=si[ut]||Rc,[Vn,qi]=_.useState(Bt),Lc=_.useCallback((v,F,W,Z)=>{v.preventDefault(),M({x:v.clientX,y:v.clientY,path:F,name:W,type:Z})},[]),Bc=_.useCallback(()=>{ut>0&&(ii(v=>v-1),P(v=>v+1))},[ut]),zc=_.useCallback(()=>{ut<si.length-1&&(ii(v=>v+1),P(v=>v+1))},[ut,si.length]),Tc=_.useCallback(v=>{let F=v;if(v.startsWith("/")&&es)try{F=`${new URL(es).origin}${v}`}catch{const W=A==null?void 0:A.port;W&&(F=`http://localhost:${W}${v}`)}qn(W=>[...W.slice(0,ut+1),F]),ii(W=>W+1),P(W=>W+1)},[ut,es,A==null?void 0:A.port]);_.useEffect(()=>{try{const v=new URL(Bt,window.location.origin);qi(v.pathname+v.search+v.hash||"/")}catch{qi(Bt)}},[Bt]);const ri=_.useCallback(async()=>{Be({type:"review",loading:!0,startTime:Date.now(),elapsed:0}),ve(null);try{const v=await Y.reviewProject(b.id);ve(v.output)}catch(v){ve(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{Be(null)}},[b.id]),ni=_.useCallback(async()=>{Be({type:"test",loading:!0,startTime:Date.now(),elapsed:0}),ve(null);try{const v=await Y.testProject(b.id);ve(v.output)}catch(v){ve(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{Be(null)}},[b.id]),Vi=_.useCallback(async()=>{Be({type:"explain",loading:!0,startTime:Date.now(),elapsed:0}),ve(null);try{const v=await Y.explainProject(b.id);ve(v.output)}catch(v){ve(`Error: ${v instanceof Error?v.message:"Unknown"}`)}finally{Be(null)}},[b.id]),Yi=_.useCallback(async(v,F)=>{if(window.confirm(`Delete "${F}"?`))try{await Y.deleteSessionFile(b.id,v),s===v&&(i(null),n(""),l(null),c(null),m(!1)),await Ye()}catch(Z){const Ue=Z instanceof Error?Z.message:"Unknown error";window.alert(`Delete failed: ${Ue}`)}},[b.id,s,Ye]),Ac=_.useCallback(v=>v.type==="file"?[{label:"Review",icon:rs,onClick:()=>{ri()}},{label:"Generate Tests",icon:xi,onClick:()=>{ni()}},{label:"Explain",icon:no,onClick:()=>{Vi()}},{label:"Delete",icon:fn,onClick:()=>{Yi(v.path,v.name)},variant:"danger"}]:[{label:"Review Project",icon:rs,onClick:()=>{ri()}},{label:"Run Tests",icon:xi,onClick:()=>{ni()}}],[ri,ni,Vi,Yi]),zt=_.useCallback(async(v,F)=>{Qs(null),p&&s&&h!==null&&E(Z=>Z.map(Ue=>Ue.path===s?{...Ue,content:h,modified:!0}:Ue));const W=S.find(Z=>Z.path===v);if(W){i(v),n(F),l(W.content),c(W.content),m(W.modified);return}i(v),n(F),f(!0),m(!1);try{const Z=b.id?await Y.getSessionFileContent(b.id,v):await Y.getFileContent(v);l(Z.content),c(Z.content),E(Ue=>[...Ue,{path:v,name:F,content:Z.content,modified:!1}])}catch{l("[Error loading file]"),c("[Error loading file]")}finally{f(!1)}},[b.id,p,s,h,S]),Gi=_.useCallback(async()=>{var v;if(!(!s||h===null||!b.id)){x(!0);try{await Y.saveSessionFile(b.id,s,h),l(h),m(!1),E(W=>W.map(Z=>Z.path===s?{...Z,content:h,modified:!1}:Z));const F=((v=s.split(".").pop())==null?void 0:v.toLowerCase())||"";["html","css","js","jsx","ts","tsx"].includes(F)&&P(W=>W+1)}catch(F){const W=F instanceof Error?F.message:"Unknown error";window.alert(`Save failed: ${W}`)}finally{x(!1)}}},[s,h,b.id]),Yn=_.useCallback(v=>{const F=S.find(W=>W.path===v);if(!(F!=null&&F.modified&&!window.confirm("Unsaved changes. Close anyway?"))&&(E(W=>W.filter(Z=>Z.path!==v)),s===v)){const W=S.filter(Z=>Z.path!==v);if(W.length>0){const Z=W[W.length-1];i(Z.path),n(Z.name),l(Z.content),c(Z.content),m(Z.modified)}else i(null),n(""),l(null),c(null),m(!1)}},[S,s]);_.useEffect(()=>{const v=F=>{(F.metaKey||F.ctrlKey)&&F.key==="s"&&(F.preventDefault(),p&&s&&Gi()),(F.metaKey||F.ctrlKey)&&F.key==="p"&&(F.preventDefault(),U(W=>!W),V("")),(F.metaKey||F.ctrlKey)&&F.key==="k"&&(F.preventDefault(),zn(W=>!W)),F.key==="Escape"&&B&&U(!1)};return window.addEventListener("keydown",v),()=>window.removeEventListener("keydown",v)},[p,s,Gi,B]),_.useEffect(()=>{B&&I.current&&I.current.focus()},[B]);const Gn=vc(b.files),ys=X?Gn.filter(v=>v.path.toLowerCase().includes(X.toLowerCase())):Gn;_.useEffect(()=>{const v=b.files.find(F=>F.name==="index.html"&&F.type==="file");v&&zt(v.path,v.name)},[]);const Oc=_.useCallback(v=>{v!==void 0&&(c(v),m(v!==a))},[a]),Ic=_.useCallback(v=>{k.current=v},[]),$c=_.useCallback(async()=>{const v=window.prompt("New file name (e.g. src/utils.ts):");if(!(!v||!v.trim()))try{await Y.createSessionFile(b.id,v.trim()),await Ye()}catch(F){const W=F instanceof Error?F.message:"Unknown error";window.alert(`Create file failed: ${W}`)}},[b.id,Ye]),Fc=_.useCallback(async()=>{const v=window.prompt("New folder name (e.g. src/components):");if(!(!v||!v.trim()))try{await Y.createSessionDirectory(b.id,v.trim()),await Ye()}catch(F){const W=F instanceof Error?F.message:"Unknown error";window.alert(`Create folder failed: ${W}`)}},[b.id,Ye]),Xn=_.useCallback(async()=>{try{const v=await Y.previewChanges(b.id,"preview current changes");xs(v)}catch{}},[b.id]),Hc=_.useCallback(()=>{xs(null),Ye()},[Ye]),Wc=_.useCallback(v=>{xs(null),Ye()},[Ye]),Uc=_.useCallback(()=>{xs(null)},[]),Jn=s?_c(b.files,s):void 0,Kc=((Qn=r.split(".").pop())==null?void 0:Qn.toUpperCase())||"",{showHelp:qc,setShowHelp:Zn}=Km({onToggleBuild:()=>{je&&In()}}),Vc=_.useMemo(()=>[{id:"preview",label:"Open Preview",category:"command",icon:rs,action:()=>g("preview"),shortcut:""},{id:"code",label:"Open Code Editor",category:"command",icon:lo,action:()=>g("code")},{id:"terminal",label:"Open Terminal",category:"command",icon:ds,action:()=>L(!0)},{id:"dashboard",label:"Open Dashboard",category:"command",icon:Ji,action:()=>g("dashboard")},{id:"deploy",label:"Deploy Project",category:"command",icon:gt,action:()=>g("deploy")},{id:"git",label:"Git Status",category:"command",icon:Te,action:()=>g("git")},{id:"settings",label:"Settings / Config",category:"setting",icon:oo,action:()=>g("config")},{id:"quick-open",label:"Quick Open File",category:"file",icon:he,action:()=>{U(!0),V("")},shortcut:"Cmd+P"},{id:"zen",label:"Toggle Zen Mode",category:"setting",icon:fo,action:()=>fe()},{id:"sidebar",label:"Toggle File Tree",category:"setting",icon:ao,action:()=>R(v=>!v)},{id:"preview-changes",label:"Preview Pending Changes",category:"command",icon:Te,action:()=>Xn()}],[g,fe,Xn]),Yc=_.useMemo(()=>{if(!je)return"idle";const v=(Zt.phase||b.status||"").toLowerCase();return v.includes("plan")||v.includes("bootstrap")?"planning":v.includes("review")||v.includes("council")?"reviewing":v.includes("test")||v.includes("verify")?"testing":v.includes("complete")||v.includes("fulfilled")?"complete":"building"},[je,Zt.phase,b.status]);return o.jsxs("div",{className:"flex flex-col h-full relative",children:[o.jsxs("div",{className:"bg-card px-3 py-2 flex items-center gap-3 flex-shrink-0 border-b border-border",children:[o.jsx("button",{onClick:()=>{p&&!window.confirm("Unsaved changes. Discard?")||t()},className:"text-xs font-medium px-3 py-1.5 rounded-btn border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Back"}),o.jsxs("div",{className:"flex-1 min-w-0",children:[o.jsx("h2",{className:"text-sm font-bold text-ink truncate",children:b.id}),o.jsx("p",{className:"text-xs font-mono text-muted-accessible truncate",children:b.path})]}),o.jsx("span",{className:`text-xs font-semibold px-2 py-0.5 rounded-full ${b.status==="completed"||b.status==="completion_promise_fulfilled"?"bg-success/10 text-success":"bg-muted/10 text-muted"}`,children:b.status}),o.jsxs("div",{className:"flex items-center gap-0.5 border-l border-border pl-2 ml-1",children:[o.jsx("button",{onClick:()=>R(v=>!v),title:$?"Hide file tree":"Show file tree",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:$?o.jsx(ao,{size:16}):o.jsx(ed,{size:16})}),o.jsx("button",{onClick:()=>L(v=>!v),title:J?"Hide terminal/chat":"Show terminal/chat",className:"p-1.5 rounded hover:bg-hover text-muted hover:text-ink transition-colors",children:J?o.jsx(Xh,{size:16}):o.jsx(Zh,{size:16})}),o.jsx("button",{onClick:fe,title:O?"Exit zen mode":"Zen mode (hide all panels)",className:`p-1.5 rounded hover:bg-hover transition-colors ${O?"text-primary":"text-muted hover:text-ink"}`,children:O?o.jsx(Vh,{size:16}):o.jsx(fo,{size:16})})]}),!je&&o.jsx(we,{variant:"primary",size:"sm",icon:gi,onClick:async()=>{try{const v=b.prd||"";if(!v.trim()){window.alert("No PRD found for this project. Go to Home to start a new build.");return}await Y.startSession({prd:v,provider:We,projectDir:b.path}),Rt(!0)}catch(v){window.alert(`Failed to start: ${v instanceof Error?v.message:"Unknown error"}`)}},title:"Start build for this project",children:"Build"}),je&&o.jsxs("div",{className:"flex items-center gap-1 border-l border-border pl-3 ml-1",children:[xc?o.jsx(we,{variant:"ghost",size:"sm",icon:gi,onClick:kc,title:"Resume build",children:"Resume"}):o.jsx(we,{variant:"ghost",size:"sm",icon:rh,onClick:Cc,title:"Pause build",children:"Pause"}),o.jsx(we,{variant:"danger",size:"sm",icon:Di,onClick:In,title:"Stop build",children:"Stop"})]}),o.jsx(St,{icon:rs,label:"Review project",size:"sm",onClick:ri,disabled:!!(le!=null&&le.loading)}),o.jsx(St,{icon:xi,label:"Run tests",size:"sm",onClick:ni,disabled:!!(le!=null&&le.loading)}),o.jsx(St,{icon:no,label:"Explain project",size:"sm",onClick:Vi,disabled:!!(le!=null&&le.loading)}),o.jsx(we,{variant:"secondary",size:"sm",icon:gt,onClick:()=>g("deploy"),title:"Deploy project",children:"Deploy"}),o.jsx(Vm,{onClick:()=>Zn(!0)})]}),o.jsx(Im,{phase:Yc,iteration:Zt.iteration,maxIterations:Zt.maxIterations,cost:Zt.cost,startTime:Zt.startTime,isRunning:je}),o.jsx(eg,{sessionId:b.id,onRestore:Ye}),o.jsx("div",{className:"flex-1 min-h-0",children:o.jsxs(Sr,{orientation:"vertical",children:[o.jsx(Rs,{defaultSize:70,minSize:40,children:o.jsxs(Sr,{orientation:"horizontal",className:"h-full",children:[$&&o.jsx(Rs,{defaultSize:20,minSize:15,children:o.jsxs("div",{className:"h-full flex flex-col border-r border-border bg-card",children:[o.jsxs("div",{className:"px-3 py-2 border-b border-border flex items-center gap-2",children:[o.jsxs("span",{className:"text-xs text-muted-accessible uppercase tracking-wider font-semibold flex-1",children:["Files",yc&&o.jsx("span",{className:"ml-2 text-[10px] font-normal text-primary animate-pulse",children:"changed"})]}),o.jsxs("button",{onClick:$c,title:"New File",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[o.jsx($i,{size:12})," New"]}),o.jsxs("button",{onClick:Fc,title:"New Folder",className:"flex items-center gap-1 text-xs text-muted-accessible hover:text-primary px-2.5 py-1 rounded border border-border hover:border-primary/30 transition-colors",children:[o.jsx(Ph,{size:12})," New"]})]}),o.jsx("div",{className:"flex-1 overflow-y-auto terminal-scroll",children:b.files.length>0?o.jsx(gc,{nodes:b.files,selectedPath:s,onSelect:zt,onDelete:Yi,onContextMenu:Lc}):o.jsxs("div",{className:"flex flex-col items-center justify-center p-6 text-center h-full",children:[o.jsx(vr,{size:28,className:"text-muted/40 mb-2"}),o.jsx("p",{className:"text-xs text-muted font-medium",children:"No files yet"}),o.jsx("p",{className:"text-[11px] text-muted/70 mt-0.5",children:"Start a build to generate your project."})]})})]})}),$&&o.jsx(wr,{className:"w-1 bg-border hover:bg-primary/30 transition-colors cursor-col-resize"}),o.jsx(Rs,{defaultSize:80,minSize:40,children:o.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[o.jsx("div",{className:"flex items-center border-b border-border bg-hover px-1 flex-shrink-0",role:"tablist",children:[{id:"code",label:"Code",icon:lo},{id:"preview",label:"Preview",icon:rs},{id:"deploy",label:"Deploy",icon:gt},{id:"config",label:"Config",icon:oo},{id:"secrets",label:"Secrets",icon:Ih},{id:"prd",label:"PRD",icon:hn},{id:"dashboard",label:"Dashboard",icon:Ji},{id:"git",label:"Git",icon:Te},{id:"cicd",label:"CI/CD",icon:Te}].map(v=>o.jsxs("button",{role:"tab","aria-selected":u===v.id,onClick:()=>g(v.id),className:`flex items-center gap-1.5 px-4 py-2 text-xs font-medium border-b-2 transition-colors ${u===v.id?"border-primary text-primary":"border-transparent text-muted hover:text-ink hover:border-border"}`,children:[o.jsx(v.icon,{size:14}),v.label]},v.id))}),o.jsxs("div",{className:"flex-1 min-h-0",role:"tabpanel",children:[u==="code"&&o.jsxs("div",{className:"h-full flex flex-col min-w-0",children:[S.length>0&&o.jsx("div",{className:"flex items-center border-b border-border bg-hover overflow-x-auto flex-shrink-0",children:S.map(v=>o.jsxs("button",{onClick:()=>zt(v.path,v.name),className:`flex items-center gap-1.5 px-3 py-1.5 text-[11px] font-mono border-r border-border whitespace-nowrap transition-colors ${v.path===s?"bg-card text-ink":"text-muted hover:text-ink hover:bg-card"}`,children:[o.jsx("span",{className:"w-4 flex items-center justify-center",children:ln(v.name,"file")}),v.name,v.modified&&o.jsx("span",{className:"w-1.5 h-1.5 rounded-full bg-primary"}),o.jsx("span",{role:"button",tabIndex:-1,title:"Close tab",onClick:F=>{F.stopPropagation(),Yn(v.path)},onKeyDown:F=>{F.key==="Enter"&&(F.stopPropagation(),Yn(v.path))},className:"text-muted hover:text-danger ml-1 cursor-pointer",children:o.jsx(Wt,{size:12})})]},v.path))}),s?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-hover",children:[o.jsx("span",{className:"text-xs font-mono text-secondary truncate",children:s}),y&&o.jsx("span",{className:"text-xs text-primary animate-pulse flex-shrink-0",children:"Saving..."}),o.jsx("span",{className:"ml-auto text-xs text-muted/50 font-mono",children:Jn!=null?mc(Jn):""}),o.jsx("span",{className:"text-xs text-muted font-mono uppercase",children:Kc}),p&&o.jsx("button",{onClick:Gi,className:"text-xs font-medium px-2 py-0.5 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors",children:"Save"})]}),gs===s&&o.jsxs("div",{className:"px-4 py-1.5 border-b border-border flex items-center gap-2 flex-shrink-0 bg-warning/10",children:[o.jsx(Os,{size:12,className:"text-warning"}),o.jsx("span",{className:"text-xs text-warning font-medium",children:"File changed externally"}),o.jsxs("div",{className:"ml-auto flex items-center gap-1.5",children:[o.jsx("button",{onClick:jc,className:"text-xs font-medium px-2 py-0.5 rounded border border-warning/40 bg-warning/10 text-warning hover:bg-warning/20 transition-colors",children:"Reload"}),o.jsx("button",{onClick:()=>Qs(null),className:"text-xs font-medium px-2 py-0.5 rounded border border-border text-muted hover:text-ink hover:bg-hover transition-colors",children:"Dismiss"})]})]}),o.jsx("div",{className:"flex-1 min-h-0",children:d?o.jsx(Qc,{}):o.jsx(vi,{name:"Editor",children:o.jsx(wu,{value:h??"",language:hg(r),theme:"vs",onChange:Oc,onMount:Ic,options:{minimap:{enabled:!1},fontSize:13,lineNumbers:"on",wordWrap:"on",scrollBeyondLastLine:!1,automaticLayout:!0,padding:{top:8},renderLineHighlight:"line",smoothScrolling:!0,cursorBlinking:"smooth",folding:!0,bracketPairColorization:{enabled:!0}}})})})]}):o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center text-center p-8",children:[o.jsx(he,{size:32,className:"text-muted/30 mb-3"}),o.jsx("p",{className:"text-sm text-muted",children:"Select a file to view its contents"}),o.jsxs("p",{className:"text-xs text-muted/60 mt-1",children:["Use the file tree or press ",o.jsx("kbd",{className:"px-1.5 py-0.5 text-[10px] font-mono bg-hover border border-border rounded",children:"Cmd+P"})," to quick open"]})]})]}),u==="preview"&&o.jsx(vi,{name:"Preview",children:o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsx("div",{className:"px-3 py-1.5 border-b border-border flex items-center gap-2 bg-hover",children:A!=null&&A.running||ee!=null&&ee.preview_url?o.jsxs(o.Fragment,{children:[o.jsx(St,{icon:hh,label:"Back",size:"sm",onClick:Bc,disabled:ut<=0}),o.jsx(St,{icon:eh,label:"Forward",size:"sm",onClick:zc,disabled:ut>=si.length-1}),o.jsx(St,{icon:nh,label:"Refresh",size:"sm",onClick:()=>P(v=>v+1)}),o.jsx("input",{value:Vn,onChange:v=>qi(v.target.value),onKeyDown:v=>{v.key==="Enter"&&Tc(Vn)},className:"flex-1 px-3 py-1 text-xs font-mono bg-card border border-border rounded-btn"}),o.jsx(St,{icon:xr,label:"Open in new tab",size:"sm",onClick:()=>window.open(Bt,"_blank")}),(A==null?void 0:A.running)&&o.jsxs("button",{onClick:Dc,className:"flex items-center gap-1 px-2 py-1 text-xs font-medium rounded border border-danger/40 bg-danger/10 text-danger hover:bg-danger/20 transition-colors",children:[o.jsx(Di,{size:12}),"Stop"]})]}):ee?o.jsx("div",{className:"flex-1 flex items-center gap-2 text-sm text-muted",children:o.jsx("span",{className:"font-medium text-ink",children:ee.description})}):o.jsx("div",{className:"flex-1 flex items-center text-sm text-muted",children:"Detecting project type..."})}),A&&A.status!=="stopped"&&o.jsxs("div",{className:`px-3 py-1 border-b flex items-center gap-2 text-xs ${A.running?"bg-green-50 border-green-200 text-green-700":A.status==="starting"?"bg-yellow-50 border-yellow-200 text-yellow-700":A.status==="error"?"bg-red-50 border-red-200 text-red-700":"bg-gray-50 border-border text-muted"}`,children:[o.jsx("span",{className:`w-2 h-2 rounded-full ${A.running?"bg-green-500":A.status==="starting"?"bg-yellow-500 animate-pulse":A.status==="error"?"bg-red-500":"bg-gray-400"}`}),A.running&&A.portless_url&&o.jsxs("span",{children:["Running at ",A.portless_url]}),A.running&&A.port&&!A.portless_url&&o.jsxs("span",{children:["Running on port ",A.port]}),A.status==="starting"&&o.jsx("span",{children:"Starting dev server..."}),A.status==="error"&&!A.auto_fix_status&&o.jsx("span",{children:"Dev server crashed"}),A.status==="error"&&A.auto_fix_status&&o.jsxs("span",{children:["Auto-fixing: ",A.auto_fix_status]}),A.command&&o.jsx("span",{className:"text-xs font-mono opacity-60 ml-auto truncate max-w-xs",children:A.command})]}),A!=null&&A.running?o.jsx("div",{className:"flex-1 bg-white",children:o.jsx("iframe",{ref:D,src:Bt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},C)}):ee!=null&&ee.preview_url?o.jsx("div",{className:"flex-1 bg-white",children:o.jsx("iframe",{ref:D,src:Bt,title:"Project Preview",className:"w-full h-full border-0",sandbox:"allow-scripts allow-same-origin allow-forms allow-popups"},C)}):ee?o.jsxs("div",{className:"flex-1 flex flex-col items-center justify-center gap-4 p-8 text-center",children:[o.jsx("div",{className:"w-16 h-16 rounded-full bg-primary/10 flex items-center justify-center",children:ee.type==="api"||ee.type==="python-api"?o.jsx(ah,{size:28,className:"text-primary"}):ee.type==="library"?o.jsx(dn,{size:28,className:"text-primary"}):ee.type==="go-app"||ee.type==="rust-app"?o.jsx(ds,{size:28,className:"text-primary"}):o.jsx(vr,{size:28,className:"text-primary"})}),o.jsxs("div",{children:[o.jsx("h3",{className:"text-lg font-heading text-ink mb-1",children:ee.type.replace(/-/g," ").replace(/\b\w/g,v=>v.toUpperCase())}),o.jsx("p",{className:"text-sm text-muted",children:ee.description})]}),o.jsxs("div",{className:"card p-4 max-w-md w-full space-y-3",children:[ee.dev_command&&o.jsxs(o.Fragment,{children:[o.jsx("p",{className:"text-xs font-semibold text-muted-accessible uppercase tracking-wider",children:"Dev Server"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("code",{className:"text-sm font-mono text-primary bg-hover px-3 py-2 rounded-btn flex-1 text-left truncate",children:ee.dev_command}),o.jsxs("button",{onClick:()=>Qt(ee.dev_command||void 0),disabled:bs,className:"flex items-center gap-1.5 px-3 py-2 text-xs font-medium rounded-btn bg-primary text-white hover:bg-primary/90 transition-colors disabled:opacity-50",children:[o.jsx(gi,{size:12}),bs?"Starting...":"Start"]})]})]}),o.jsxs("div",{className:ee.dev_command?"pt-2 border-t border-border":"",children:[o.jsx("p",{className:"text-xs text-muted mb-2",children:ee.dev_command?"Or use a custom command:":"Start a dev server:"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("input",{value:Lt,onChange:v=>Nc(v.target.value),onKeyDown:v=>{v.key==="Enter"&&Lt.trim()&&Qt(Lt.trim())},placeholder:"e.g. npm run dev",className:"flex-1 px-3 py-1.5 text-xs font-mono bg-card border border-border rounded-btn"}),o.jsx("button",{onClick:()=>Lt.trim()&&Qt(Lt.trim()),disabled:bs||!Lt.trim(),className:"px-3 py-1.5 text-xs font-medium rounded-btn border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:"Run"})]})]})]}),Un&&o.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[o.jsx("p",{className:"text-xs text-danger font-medium mb-1",children:"Dev server error"}),o.jsx("p",{className:"text-xs text-danger/80",children:Un})]}),(A==null?void 0:A.status)==="error"&&o.jsxs("div",{className:"card p-3 max-w-md w-full border-danger/30 bg-danger/5",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("p",{className:"text-xs text-danger font-medium",children:"Dev server crashed"}),o.jsxs("div",{className:"flex items-center gap-2",children:[o.jsx("button",{onClick:Mc,disabled:Hn,className:"text-xs px-2 py-1 rounded border border-primary/40 bg-primary/10 text-primary hover:bg-primary/20 transition-colors disabled:opacity-50",children:Hn?"Fixing...":"Fix Error"}),o.jsx("button",{onClick:()=>Qt(ee.dev_command||Lt||void 0),className:"text-xs px-2 py-1 rounded border border-danger/40 text-danger hover:bg-danger/10 transition-colors",children:"Restart"})]})]}),A.auto_fix_status&&o.jsxs("div",{className:"flex items-center gap-2 mb-2 px-2 py-1 rounded bg-primary/5 border border-primary/20",children:[o.jsx("div",{className:"w-2 h-2 rounded-full bg-primary animate-pulse"}),o.jsxs("span",{className:"text-[11px] text-primary font-medium",children:["Auto-fix: ",A.auto_fix_status]}),A.auto_fix_attempts!==void 0&&A.auto_fix_attempts>0&&o.jsxs("span",{className:"text-[10px] text-muted ml-auto",children:["Attempt ",A.auto_fix_attempts,"/3"]})]}),A.output.length>0&&o.jsx("pre",{className:"text-[11px] font-mono text-danger/70 bg-danger/5 p-2 rounded max-h-32 overflow-y-auto whitespace-pre-wrap",children:A.output.slice(-10).join(`
285
+ `)})]}),ee.port&&!(A!=null&&A.running)&&o.jsxs("p",{className:"text-xs text-muted",children:["Server will run on port ",ee.port]})]}):o.jsx("div",{className:"flex-1 flex items-center justify-center text-muted text-sm",children:"Detecting project type..."})]})}),u==="config"&&o.jsx("div",{className:"h-full flex flex-col",children:o.jsxs("div",{className:"p-6 overflow-y-auto",children:[o.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Project Configuration"}),o.jsxs("div",{className:"space-y-4",children:[o.jsxs("div",{className:"card p-4",children:[o.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Provider"}),o.jsxs("p",{className:"text-xs text-muted mb-2",children:["Current session: ",o.jsx("span",{className:"font-semibold text-ink capitalize",children:We})]}),o.jsx("div",{className:"flex gap-2",children:["claude","codex","gemini"].map(v=>o.jsx("button",{onClick:()=>{Ve(v),sessionStorage.setItem(`pl_provider_${b.id}`,v),Y.setProvider(v).catch(()=>{})},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${We===v?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:v},v))})]}),o.jsxs("div",{className:"card p-4",children:[o.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Build Mode"}),o.jsx("div",{className:"flex gap-2",children:["quick","standard","max"].map(v=>o.jsx("button",{onClick:()=>{oe(v),sessionStorage.setItem(`pl_buildmode_${b.id}`,v)},className:`px-4 py-2 rounded-btn text-sm font-medium border transition-colors capitalize ${z===v?"border-primary bg-primary/10 text-primary":"border-border text-secondary hover:bg-hover"}`,children:v},v))})]}),o.jsxs("div",{className:"card p-4",children:[o.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Project Path"}),o.jsx("input",{value:b.path,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]}),o.jsxs("div",{className:"card p-4",children:[o.jsx("label",{className:"block text-xs font-semibold text-muted-accessible uppercase tracking-wider mb-2",children:"Session ID"}),o.jsx("input",{value:b.id,readOnly:!0,className:"w-full px-3 py-2 text-sm font-mono bg-hover border border-border rounded-btn text-ink"})]})]})]})}),u==="secrets"&&o.jsx(dg,{}),u==="prd"&&o.jsx("div",{className:"h-full flex flex-col",children:o.jsxs("div",{className:"p-6 overflow-y-auto",children:[o.jsx("h3",{className:"text-h3 font-heading text-ink mb-4",children:"Product Requirements"}),b.prd?o.jsx("pre",{className:"text-sm font-mono text-ink whitespace-pre-wrap bg-hover border border-border rounded-card p-4 leading-relaxed",children:b.prd}):o.jsx("div",{className:"text-sm text-muted text-center py-8",children:"No PRD found for this project."})]})}),u==="deploy"&&o.jsx(Wm,{sessionId:b.id}),u==="dashboard"&&(ae===!1?o.jsxs("div",{className:"h-full flex flex-col items-center justify-center text-center p-8 gap-4",children:[o.jsx(Ji,{size:48,className:"text-muted/30"}),o.jsx("h3",{className:"text-lg font-heading font-bold text-ink",children:"Dashboard Not Running"}),o.jsx("p",{className:"text-sm text-muted max-w-md",children:"The Loki Dashboard provides task boards, RARV timeline, quality gates, and cost tracking. Start it to see project analytics."}),o.jsx("button",{onClick:async()=>{ce(null);try{const v=await fetch(`http://127.0.0.1:${se}/health`);ce(v.ok)}catch{ce(!1)}},className:"px-4 py-2 text-sm font-medium rounded-btn bg-primary text-white hover:bg-primary-hover",children:"Check Again"})]}):o.jsxs("div",{className:"h-full flex flex-col",children:[o.jsxs("div",{className:"flex items-center gap-1 px-3 py-2 border-b border-border bg-hover flex-shrink-0",children:[[{id:"overview",label:"Overview"},{id:"tasks",label:"Tasks"},{id:"timeline",label:"RARV Timeline"},{id:"quality",label:"Quality"},{id:"cost",label:"Cost"}].map(v=>o.jsx("button",{onClick:()=>te(v.id),className:`px-3 py-1.5 text-xs font-medium rounded-btn transition-colors ${q===v.id?"bg-primary/10 text-primary":"text-muted hover:text-ink hover:bg-hover"}`,children:v.label},v.id)),o.jsx("div",{className:"flex-1"}),o.jsxs("a",{href:`http://127.0.0.1:${se}/`,target:"_blank",rel:"noopener noreferrer",className:"text-xs text-muted hover:text-primary flex items-center gap-1",children:["Open full dashboard ",o.jsx(xr,{size:12})]})]}),o.jsx("iframe",{src:`http://127.0.0.1:${se}/#${q}`,className:"flex-1 w-full border-none",title:"Loki Dashboard",sandbox:"allow-same-origin allow-scripts allow-popups allow-forms"})]})),u==="git"&&o.jsx(Qm,{sessionId:b.id}),u==="cicd"&&o.jsx("div",{className:"h-full overflow-y-auto p-4",children:o.jsx(cg,{sessionId:e.id})})]})]})})]})}),J&&o.jsx(wr,{className:"h-1 bg-border hover:bg-primary/30 cursor-row-resize"}),J&&o.jsx(Rs,{defaultSize:30,minSize:15,collapsible:!0,children:o.jsx(vi,{name:"ActivityPanel",children:o.jsx(Om,{logs:null,logsLoading:!1,agents:null,checklist:null,sessionId:e.id,isRunning:b.status==="running"||b.status==="in_progress",buildMode:z,buildEvents:wc,onFileClick:v=>zt(v,v.split("/").pop()||v)})})})]})}),(le==null?void 0:le.loading)&&o.jsx("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4",children:o.jsxs("div",{className:"flex items-center gap-3",children:[o.jsx("div",{className:"w-4 h-4 border-2 border-primary border-t-transparent rounded-full animate-spin"}),o.jsxs("span",{className:"text-sm font-medium text-ink",children:[le.type==="review"?"Reviewing project":le.type==="test"?"Generating tests":"Analyzing project","..."]}),o.jsxs("span",{className:"text-xs font-mono text-muted",children:[le.elapsed,"s"]})]})}),ne&&o.jsxs("div",{className:"absolute inset-x-0 bottom-0 z-20 bg-card border-t border-border p-4 max-h-64 overflow-y-auto",children:[o.jsxs("div",{className:"flex items-center justify-between mb-2",children:[o.jsx("span",{className:"text-xs font-semibold text-ink",children:"Action Output"}),o.jsx(St,{icon:Wt,label:"Close",size:"sm",onClick:()=>ve(null)})]}),o.jsx("pre",{className:"text-xs font-mono text-ink whitespace-pre-wrap",children:ne})]}),w&&o.jsx(af,{x:w.x,y:w.y,items:Ac(w),onClose:()=>M(null)}),B&&o.jsx("div",{className:"fixed inset-0 z-50 flex items-start justify-center pt-[20vh]",role:"dialog","aria-modal":"true","aria-label":"Quick open file search",onClick:()=>U(!1),children:o.jsxs("div",{className:"bg-card rounded-card shadow-2xl border border-border w-full max-w-lg",onClick:v=>v.stopPropagation(),children:[o.jsx("input",{ref:I,type:"text",value:X,onChange:v=>V(v.target.value),placeholder:"Search files by name...",className:"w-full px-4 py-3 text-sm font-mono border-b border-border outline-none rounded-t-card bg-transparent",onKeyDown:v=>{v.key==="Enter"&&ys.length>0&&(zt(ys[0].path,ys[0].name),U(!1)),v.key==="Escape"&&U(!1)}}),o.jsxs("div",{className:"max-h-64 overflow-y-auto",children:[ys.slice(0,20).map(v=>o.jsxs("button",{onClick:()=>{zt(v.path,v.name),U(!1)},className:"w-full text-left px-4 py-2 text-xs font-mono hover:bg-primary/5 flex items-center gap-2",children:[o.jsx("span",{className:"w-5 flex items-center justify-center",children:ln(v.name,"file")}),o.jsx("span",{className:"text-ink",children:v.name}),o.jsx("span",{className:"text-muted ml-auto truncate text-xs",children:v.path})]},v.path)),ys.length===0&&o.jsx("div",{className:"px-4 py-3 text-xs text-muted",children:"No matching files"})]})]})}),o.jsx(qm,{open:qc,onClose:()=>Zn(!1)}),o.jsx(Gm,{isOpen:Sc,onClose:()=>zn(!1),commands:Vc,sessionId:b.id,onFileSelect:zt}),An&&o.jsx(ig,{data:An,onAcceptAll:Hc,onAcceptSelected:Wc,onReject:Uc,onClose:()=>xs(null)})]})}function Pg(){const{sessionId:e}=th(),t=sh(),[s,i]=_.useState(null),[r,n]=_.useState(!0),[a,l]=_.useState(null);return _.useEffect(()=>{e&&(n(!0),l(null),Y.getSessionDetail(e).then(h=>{i(h),n(!1)}).catch(h=>{l(h instanceof Error?h.message:"Failed to load session"),n(!1)}))},[e]),r?o.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("div",{className:"text-muted animate-pulse text-sm",children:"Loading project..."}),o.jsx("div",{className:"text-xs font-mono text-muted/50 mt-2",children:e})]})}):a||!s?o.jsx("div",{className:"h-screen bg-background flex items-center justify-center",children:o.jsxs("div",{className:"text-center",children:[o.jsx("p",{className:"text-danger text-sm font-medium",children:"Project not found"}),o.jsx("p",{className:"text-xs text-muted mt-1",children:a||`Session ${e} does not exist`}),o.jsx("button",{onClick:()=>t("/"),className:"mt-4 px-4 py-2 rounded-btn text-sm font-semibold border border-primary/30 text-primary hover:bg-primary/5 transition-all",children:"Back to Home"})]})}):o.jsx("div",{className:"h-screen bg-background flex flex-col",children:o.jsx("div",{className:"flex-1 min-h-0",children:o.jsx(vi,{name:"ProjectWorkspace",children:o.jsx(ug,{session:s,onClose:()=>t("/")})})})})}export{Pg as default};